From 56c6add5c3d69e33da95aae48f567899ebe9906e Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2026 16:17:14 -0500 Subject: [PATCH] refactor(core): remove unused helpers (#39943) Co-authored-by: Aiden Cline --- packages/core/src/aisdk.ts | 2 - .../responses/tool/image-generation.ts | 89 ------------------- .../responses/tool/local-shell.ts | 48 ---------- .../responses/tool/web-search-preview.ts | 63 ------------- .../responses/tool/web-search.ts | 81 ----------------- packages/core/src/util/module.ts | 10 --- packages/core/src/util/path.ts | 6 -- 7 files changed, 299 deletions(-) delete mode 100644 packages/core/src/util/module.ts diff --git a/packages/core/src/aisdk.ts b/packages/core/src/aisdk.ts index da6b9a7e0e..4114f4aaea 100644 --- a/packages/core/src/aisdk.ts +++ b/packages/core/src/aisdk.ts @@ -299,8 +299,6 @@ export const locationLayer = Layer.effect( }), ) -export const defaultLayer = locationLayer - function modelFromLanguage(info: Info, language: LanguageModelV3) { const packageName = Provider.packageName(info.package!) const projected = mapBodyToProviderOptions(info, packageName) diff --git a/packages/core/src/github-copilot/responses/tool/image-generation.ts b/packages/core/src/github-copilot/responses/tool/image-generation.ts index b67bb76f9c..4beac1903a 100644 --- a/packages/core/src/github-copilot/responses/tool/image-generation.ts +++ b/packages/core/src/github-copilot/responses/tool/image-generation.ts @@ -1,4 +1,3 @@ -import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils" import { z } from "zod/v4" export const imageGenerationArgsSchema = z @@ -24,91 +23,3 @@ export const imageGenerationArgsSchema = z export const imageGenerationOutputSchema = z.object({ result: z.string(), }) - -type ImageGenerationArgs = { - /** - * Background type for the generated image. Default is 'auto'. - */ - background?: "auto" | "opaque" | "transparent" - - /** - * Input fidelity for the generated image. Default is 'low'. - */ - inputFidelity?: "low" | "high" - - /** - * Optional mask for inpainting. - * Contains image_url (string, optional) and file_id (string, optional). - */ - inputImageMask?: { - /** - * File ID for the mask image. - */ - fileId?: string - - /** - * Base64-encoded mask image. - */ - imageUrl?: string - } - - /** - * The image generation model to use. Default: gpt-image-1. - */ - model?: string - - /** - * Moderation level for the generated image. Default: auto. - */ - moderation?: "auto" - - /** - * Compression level for the output image. Default: 100. - */ - outputCompression?: number - - /** - * The output format of the generated image. One of png, webp, or jpeg. - * Default: png - */ - outputFormat?: "png" | "jpeg" | "webp" - - /** - * Number of partial images to generate in streaming mode, from 0 (default value) to 3. - */ - partialImages?: number - - /** - * The quality of the generated image. - * One of low, medium, high, or auto. Default: auto. - */ - quality?: "auto" | "low" | "medium" | "high" - - /** - * The size of the generated image. - * One of 1024x1024, 1024x1536, 1536x1024, or auto. - * Default: auto. - */ - size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" -} - -const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema< - {}, - { - /** - * The generated image encoded in base64. - */ - result: string - }, - ImageGenerationArgs ->({ - id: "openai.image_generation", - inputSchema: z.object({}), - outputSchema: imageGenerationOutputSchema, -}) - -export const imageGeneration = ( - args: ImageGenerationArgs = {}, // default -) => { - return imageGenerationToolFactory(args) -} diff --git a/packages/core/src/github-copilot/responses/tool/local-shell.ts b/packages/core/src/github-copilot/responses/tool/local-shell.ts index 45230d5ce5..683dd5984f 100644 --- a/packages/core/src/github-copilot/responses/tool/local-shell.ts +++ b/packages/core/src/github-copilot/responses/tool/local-shell.ts @@ -1,4 +1,3 @@ -import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils" import { z } from "zod/v4" export const localShellInputSchema = z.object({ @@ -15,50 +14,3 @@ export const localShellInputSchema = z.object({ export const localShellOutputSchema = z.object({ output: z.string(), }) - -export const localShell = createProviderToolFactoryWithOutputSchema< - { - /** - * Execute a shell command on the server. - */ - action: { - type: "exec" - - /** - * The command to run. - */ - command: string[] - - /** - * Optional timeout in milliseconds for the command. - */ - timeoutMs?: number - - /** - * Optional user to run the command as. - */ - user?: string - - /** - * Optional working directory to run the command in. - */ - workingDirectory?: string - - /** - * Environment variables to set for the command. - */ - env?: Record - } - }, - { - /** - * The output of local shell tool call. - */ - output: string - }, - {} ->({ - id: "openai.local_shell", - inputSchema: localShellInputSchema, - outputSchema: localShellOutputSchema, -}) diff --git a/packages/core/src/github-copilot/responses/tool/web-search-preview.ts b/packages/core/src/github-copilot/responses/tool/web-search-preview.ts index 3d9a308d8a..1d219a4823 100644 --- a/packages/core/src/github-copilot/responses/tool/web-search-preview.ts +++ b/packages/core/src/github-copilot/responses/tool/web-search-preview.ts @@ -1,4 +1,3 @@ -import { createProviderToolFactory } from "@ai-sdk/provider-utils" import { z } from "zod/v4" // Args validation schema @@ -39,65 +38,3 @@ export const webSearchPreviewArgsSchema = z.object({ }) .optional(), }) - -export const webSearchPreview = createProviderToolFactory< - { - // Web search doesn't take input parameters - it's controlled by the prompt - }, - { - /** - * Search context size to use for the web search. - * - high: Most comprehensive context, highest cost, slower response - * - medium: Balanced context, cost, and latency (default) - * - low: Least context, lowest cost, fastest response - */ - searchContextSize?: "low" | "medium" | "high" - - /** - * User location information to provide geographically relevant search results. - */ - userLocation?: { - /** - * Type of location (always 'approximate') - */ - type: "approximate" - /** - * Two-letter ISO country code (e.g., 'US', 'GB') - */ - country?: string - /** - * City name (free text, e.g., 'Minneapolis') - */ - city?: string - /** - * Region name (free text, e.g., 'Minnesota') - */ - region?: string - /** - * IANA timezone (e.g., 'America/Chicago') - */ - timezone?: string - } - } ->({ - id: "openai.web_search_preview", - inputSchema: z.object({ - action: z - .discriminatedUnion("type", [ - z.object({ - type: z.literal("search"), - query: z.string().nullish(), - }), - z.object({ - type: z.literal("open_page"), - url: z.string(), - }), - z.object({ - type: z.literal("find"), - url: z.string(), - pattern: z.string(), - }), - ]) - .nullish(), - }), -}) diff --git a/packages/core/src/github-copilot/responses/tool/web-search.ts b/packages/core/src/github-copilot/responses/tool/web-search.ts index e380bb13b6..84aa7baaca 100644 --- a/packages/core/src/github-copilot/responses/tool/web-search.ts +++ b/packages/core/src/github-copilot/responses/tool/web-search.ts @@ -1,4 +1,3 @@ -import { createProviderToolFactory } from "@ai-sdk/provider-utils" import { z } from "zod/v4" export const webSearchArgsSchema = z.object({ @@ -20,83 +19,3 @@ export const webSearchArgsSchema = z.object({ }) .optional(), }) - -export const webSearchToolFactory = createProviderToolFactory< - { - // Web search doesn't take input parameters - it's controlled by the prompt - }, - { - /** - * Filters for the search. - */ - filters?: { - /** - * Allowed domains for the search. - * If not provided, all domains are allowed. - * Subdomains of the provided domains are allowed as well. - */ - allowedDomains?: string[] - } - - /** - * Search context size to use for the web search. - * - high: Most comprehensive context, highest cost, slower response - * - medium: Balanced context, cost, and latency (default) - * - low: Least context, lowest cost, fastest response - */ - searchContextSize?: "low" | "medium" | "high" - - /** - * User location information to provide geographically relevant search results. - */ - userLocation?: { - /** - * Type of location (always 'approximate') - */ - type: "approximate" - /** - * Two-letter ISO country code (e.g., 'US', 'GB') - */ - country?: string - /** - * City name (free text, e.g., 'Minneapolis') - */ - city?: string - /** - * Region name (free text, e.g., 'Minnesota') - */ - region?: string - /** - * IANA timezone (e.g., 'America/Chicago') - */ - timezone?: string - } - } ->({ - id: "openai.web_search", - inputSchema: z.object({ - action: z - .discriminatedUnion("type", [ - z.object({ - type: z.literal("search"), - query: z.string().nullish(), - }), - z.object({ - type: z.literal("open_page"), - url: z.string(), - }), - z.object({ - type: z.literal("find"), - url: z.string(), - pattern: z.string(), - }), - ]) - .nullish(), - }), -}) - -export const webSearch = ( - args: Parameters[0] = {}, // default -) => { - return webSearchToolFactory(args) -} diff --git a/packages/core/src/util/module.ts b/packages/core/src/util/module.ts deleted file mode 100644 index 6ed3b23d7a..0000000000 --- a/packages/core/src/util/module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createRequire } from "node:module" -import path from "node:path" - -export namespace Module { - export function resolve(id: string, dir: string) { - try { - return createRequire(path.join(dir, "package.json")).resolve(id) - } catch {} - } -} diff --git a/packages/core/src/util/path.ts b/packages/core/src/util/path.ts index b87316358f..a3f2b550b5 100644 --- a/packages/core/src/util/path.ts +++ b/packages/core/src/util/path.ts @@ -12,12 +12,6 @@ export function getDirectory(path: string | undefined) { return parts.slice(0, parts.length - 1).join("/") + "/" } -export function getFileExtension(path: string | undefined) { - if (!path) return "" - const parts = path.split(".") - return parts[parts.length - 1] -} - export function getFilenameTruncated(path: string | undefined, maxLength: number = 20) { const filename = getFilename(path) if (filename.length <= maxLength) return filename