opencodekit 0.20.8 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/AGENTS.md +25 -1
  3. package/dist/template/.opencode/memory.db +0 -0
  4. package/dist/template/.opencode/memory.db-shm +0 -0
  5. package/dist/template/.opencode/memory.db-wal +0 -0
  6. package/dist/template/.opencode/opencode.json +83 -609
  7. package/dist/template/.opencode/opencodex-fast.jsonc +1 -1
  8. package/dist/template/.opencode/package.json +2 -2
  9. package/dist/template/.opencode/plugin/copilot-auth.ts +86 -12
  10. package/dist/template/.opencode/plugin/prompt-leverage.ts +191 -0
  11. package/dist/template/.opencode/plugin/sdk/copilot/copilot-provider.ts +14 -2
  12. package/dist/template/.opencode/plugin/sdk/copilot/index.ts +2 -2
  13. package/dist/template/.opencode/plugin/sdk/copilot/responses/convert-to-openai-responses-input.ts +335 -0
  14. package/dist/template/.opencode/plugin/sdk/copilot/responses/map-openai-responses-finish-reason.ts +22 -0
  15. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-config.ts +18 -0
  16. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-error.ts +22 -0
  17. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-responses-api-types.ts +214 -0
  18. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-responses-language-model.ts +1770 -0
  19. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-responses-prepare-tools.ts +173 -0
  20. package/dist/template/.opencode/plugin/sdk/copilot/responses/openai-responses-settings.ts +1 -0
  21. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/code-interpreter.ts +87 -0
  22. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/file-search.ts +127 -0
  23. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/image-generation.ts +114 -0
  24. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/local-shell.ts +64 -0
  25. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/web-search-preview.ts +103 -0
  26. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/web-search.ts +102 -0
  27. package/dist/template/.opencode/skill/gh-address-comments/SKILL.md +29 -0
  28. package/dist/template/.opencode/skill/gh-address-comments/scripts/fetch_comments.py +237 -0
  29. package/dist/template/.opencode/skill/gh-fix-ci/SKILL.md +38 -0
  30. package/dist/template/.opencode/skill/gh-fix-ci/scripts/inspect_pr_checks.py +509 -0
  31. package/dist/template/.opencode/skill/prompt-leverage/SKILL.md +90 -0
  32. package/dist/template/.opencode/skill/prompt-leverage/references/framework.md +91 -0
  33. package/dist/template/.opencode/skill/prompt-leverage/scripts/augment_prompt.py +157 -0
  34. package/dist/template/.opencode/skill/screenshot/SKILL.md +48 -0
  35. package/dist/template/.opencode/skill/screenshot/scripts/ensure_macos_permissions.sh +54 -0
  36. package/dist/template/.opencode/skill/screenshot/scripts/macos_display_info.swift +22 -0
  37. package/dist/template/.opencode/skill/screenshot/scripts/macos_permissions.swift +40 -0
  38. package/dist/template/.opencode/skill/screenshot/scripts/macos_window_info.swift +126 -0
  39. package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.ps1 +163 -0
  40. package/dist/template/.opencode/skill/screenshot/scripts/take_screenshot.py +585 -0
  41. package/dist/template/.opencode/skill/security-threat-model/SKILL.md +36 -0
  42. package/dist/template/.opencode/skill/security-threat-model/references/prompt-template.md +255 -0
  43. package/dist/template/.opencode/skill/security-threat-model/references/security-controls-and-assets.md +32 -0
  44. package/dist/template/.opencode/skill/skill-installer/SKILL.md +58 -0
  45. package/dist/template/.opencode/skill/skill-installer/scripts/github_utils.py +21 -0
  46. package/dist/template/.opencode/skill/skill-installer/scripts/install-skill-from-github.py +313 -0
  47. package/dist/template/.opencode/skill/skill-installer/scripts/list-skills.py +106 -0
  48. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ import { type LanguageModelV3CallOptions, type SharedV3Warning, UnsupportedFunctionalityError } from "@ai-sdk/provider"
2
+ import { codeInterpreterArgsSchema } from "./tool/code-interpreter.js"
3
+ import { fileSearchArgsSchema } from "./tool/file-search.js"
4
+ import { webSearchArgsSchema } from "./tool/web-search.js"
5
+ import { webSearchPreviewArgsSchema } from "./tool/web-search-preview.js"
6
+ import { imageGenerationArgsSchema } from "./tool/image-generation.js"
7
+ import type { OpenAIResponsesTool } from "./openai-responses-api-types.js"
8
+
9
+ export function prepareResponsesTools({
10
+ tools,
11
+ toolChoice,
12
+ strictJsonSchema,
13
+ }: {
14
+ tools: LanguageModelV3CallOptions["tools"]
15
+ toolChoice?: LanguageModelV3CallOptions["toolChoice"]
16
+ strictJsonSchema: boolean
17
+ }): {
18
+ tools?: Array<OpenAIResponsesTool>
19
+ toolChoice?:
20
+ | "auto"
21
+ | "none"
22
+ | "required"
23
+ | { type: "file_search" }
24
+ | { type: "web_search_preview" }
25
+ | { type: "web_search" }
26
+ | { type: "function"; name: string }
27
+ | { type: "code_interpreter" }
28
+ | { type: "image_generation" }
29
+ toolWarnings: SharedV3Warning[]
30
+ } {
31
+ // when the tools array is empty, change it to undefined to prevent errors:
32
+ tools = tools?.length ? tools : undefined
33
+
34
+ const toolWarnings: SharedV3Warning[] = []
35
+
36
+ if (tools == null) {
37
+ return { tools: undefined, toolChoice: undefined, toolWarnings }
38
+ }
39
+
40
+ const openaiTools: Array<OpenAIResponsesTool> = []
41
+
42
+ for (const tool of tools) {
43
+ switch (tool.type) {
44
+ case "function":
45
+ openaiTools.push({
46
+ type: "function",
47
+ name: tool.name,
48
+ description: tool.description,
49
+ parameters: tool.inputSchema,
50
+ strict: strictJsonSchema,
51
+ })
52
+ break
53
+ case "provider": {
54
+ switch (tool.id) {
55
+ case "openai.file_search": {
56
+ const args = fileSearchArgsSchema.parse(tool.args)
57
+
58
+ openaiTools.push({
59
+ type: "file_search",
60
+ vector_store_ids: args.vectorStoreIds,
61
+ max_num_results: args.maxNumResults,
62
+ ranking_options: args.ranking
63
+ ? {
64
+ ranker: args.ranking.ranker,
65
+ score_threshold: args.ranking.scoreThreshold,
66
+ }
67
+ : undefined,
68
+ filters: args.filters,
69
+ })
70
+
71
+ break
72
+ }
73
+ case "openai.local_shell": {
74
+ openaiTools.push({
75
+ type: "local_shell",
76
+ })
77
+ break
78
+ }
79
+ case "openai.web_search_preview": {
80
+ const args = webSearchPreviewArgsSchema.parse(tool.args)
81
+ openaiTools.push({
82
+ type: "web_search_preview",
83
+ search_context_size: args.searchContextSize,
84
+ user_location: args.userLocation,
85
+ })
86
+ break
87
+ }
88
+ case "openai.web_search": {
89
+ const args = webSearchArgsSchema.parse(tool.args)
90
+ openaiTools.push({
91
+ type: "web_search",
92
+ filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : undefined,
93
+ search_context_size: args.searchContextSize,
94
+ user_location: args.userLocation,
95
+ })
96
+ break
97
+ }
98
+ case "openai.code_interpreter": {
99
+ const args = codeInterpreterArgsSchema.parse(tool.args)
100
+ openaiTools.push({
101
+ type: "code_interpreter",
102
+ container:
103
+ args.container == null
104
+ ? { type: "auto", file_ids: undefined }
105
+ : typeof args.container === "string"
106
+ ? args.container
107
+ : { type: "auto", file_ids: args.container.fileIds },
108
+ })
109
+ break
110
+ }
111
+ case "openai.image_generation": {
112
+ const args = imageGenerationArgsSchema.parse(tool.args)
113
+ openaiTools.push({
114
+ type: "image_generation",
115
+ background: args.background,
116
+ input_fidelity: args.inputFidelity,
117
+ input_image_mask: args.inputImageMask
118
+ ? {
119
+ file_id: args.inputImageMask.fileId,
120
+ image_url: args.inputImageMask.imageUrl,
121
+ }
122
+ : undefined,
123
+ model: args.model,
124
+ moderation: args.moderation,
125
+ partial_images: args.partialImages,
126
+ quality: args.quality,
127
+ output_compression: args.outputCompression,
128
+ output_format: args.outputFormat,
129
+ size: args.size,
130
+ })
131
+ break
132
+ }
133
+ }
134
+ break
135
+ }
136
+ default:
137
+ toolWarnings.push({ type: "unsupported", feature: "tool type" })
138
+ break
139
+ }
140
+ }
141
+
142
+ if (toolChoice == null) {
143
+ return { tools: openaiTools, toolChoice: undefined, toolWarnings }
144
+ }
145
+
146
+ const type = toolChoice.type
147
+
148
+ switch (type) {
149
+ case "auto":
150
+ case "none":
151
+ case "required":
152
+ return { tools: openaiTools, toolChoice: type, toolWarnings }
153
+ case "tool":
154
+ return {
155
+ tools: openaiTools,
156
+ toolChoice:
157
+ toolChoice.toolName === "code_interpreter" ||
158
+ toolChoice.toolName === "file_search" ||
159
+ toolChoice.toolName === "image_generation" ||
160
+ toolChoice.toolName === "web_search_preview" ||
161
+ toolChoice.toolName === "web_search"
162
+ ? { type: toolChoice.toolName }
163
+ : { type: "function", name: toolChoice.toolName },
164
+ toolWarnings,
165
+ }
166
+ default: {
167
+ const _exhaustiveCheck: never = type
168
+ throw new UnsupportedFunctionalityError({
169
+ functionality: `tool choice type: ${_exhaustiveCheck}`,
170
+ })
171
+ }
172
+ }
173
+ }
@@ -0,0 +1 @@
1
+ export type OpenAIResponsesModelId = string
@@ -0,0 +1,87 @@
1
+ import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
2
+ import { z } from "zod/v4"
3
+
4
+ export const codeInterpreterInputSchema = z.object({
5
+ code: z.string().nullish(),
6
+ containerId: z.string(),
7
+ })
8
+
9
+ export const codeInterpreterOutputSchema = z.object({
10
+ outputs: z
11
+ .array(
12
+ z.discriminatedUnion("type", [
13
+ z.object({ type: z.literal("logs"), logs: z.string() }),
14
+ z.object({ type: z.literal("image"), url: z.string() }),
15
+ ]),
16
+ )
17
+ .nullish(),
18
+ })
19
+
20
+ export const codeInterpreterArgsSchema = z.object({
21
+ container: z
22
+ .union([
23
+ z.string(),
24
+ z.object({
25
+ fileIds: z.array(z.string()).optional(),
26
+ }),
27
+ ])
28
+ .optional(),
29
+ })
30
+
31
+ type CodeInterpreterArgs = {
32
+ /**
33
+ * The code interpreter container.
34
+ * Can be a container ID
35
+ * or an object that specifies uploaded file IDs to make available to your code.
36
+ */
37
+ container?: string | { fileIds?: string[] }
38
+ }
39
+
40
+ export const codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema<
41
+ {
42
+ /**
43
+ * The code to run, or null if not available.
44
+ */
45
+ code?: string | null
46
+
47
+ /**
48
+ * The ID of the container used to run the code.
49
+ */
50
+ containerId: string
51
+ },
52
+ {
53
+ /**
54
+ * The outputs generated by the code interpreter, such as logs or images.
55
+ * Can be null if no outputs are available.
56
+ */
57
+ outputs?: Array<
58
+ | {
59
+ type: "logs"
60
+
61
+ /**
62
+ * The logs output from the code interpreter.
63
+ */
64
+ logs: string
65
+ }
66
+ | {
67
+ type: "image"
68
+
69
+ /**
70
+ * The URL of the image output from the code interpreter.
71
+ */
72
+ url: string
73
+ }
74
+ > | null
75
+ },
76
+ CodeInterpreterArgs
77
+ >({
78
+ id: "openai.code_interpreter",
79
+ inputSchema: codeInterpreterInputSchema,
80
+ outputSchema: codeInterpreterOutputSchema,
81
+ })
82
+
83
+ export const codeInterpreter = (
84
+ args: CodeInterpreterArgs = {}, // default
85
+ ) => {
86
+ return codeInterpreterToolFactory(args)
87
+ }
@@ -0,0 +1,127 @@
1
+ import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
2
+ import type {
3
+ OpenAIResponsesFileSearchToolComparisonFilter,
4
+ OpenAIResponsesFileSearchToolCompoundFilter,
5
+ } from "../openai-responses-api-types.js"
6
+ import { z } from "zod/v4"
7
+
8
+ const comparisonFilterSchema = z.object({
9
+ key: z.string(),
10
+ type: z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
11
+ value: z.union([z.string(), z.number(), z.boolean()]),
12
+ })
13
+
14
+ const compoundFilterSchema: z.ZodType<any> = z.object({
15
+ type: z.enum(["and", "or"]),
16
+ filters: z.array(z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)])),
17
+ })
18
+
19
+ export const fileSearchArgsSchema = z.object({
20
+ vectorStoreIds: z.array(z.string()),
21
+ maxNumResults: z.number().optional(),
22
+ ranking: z
23
+ .object({
24
+ ranker: z.string().optional(),
25
+ scoreThreshold: z.number().optional(),
26
+ })
27
+ .optional(),
28
+ filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional(),
29
+ })
30
+
31
+ export const fileSearchOutputSchema = z.object({
32
+ queries: z.array(z.string()),
33
+ results: z
34
+ .array(
35
+ z.object({
36
+ attributes: z.record(z.string(), z.unknown()),
37
+ fileId: z.string(),
38
+ filename: z.string(),
39
+ score: z.number(),
40
+ text: z.string(),
41
+ }),
42
+ )
43
+ .nullable(),
44
+ })
45
+
46
+ export const fileSearch = createProviderToolFactoryWithOutputSchema<
47
+ {},
48
+ {
49
+ /**
50
+ * The search query to execute.
51
+ */
52
+ queries: string[]
53
+
54
+ /**
55
+ * The results of the file search tool call.
56
+ */
57
+ results:
58
+ | null
59
+ | {
60
+ /**
61
+ * Set of 16 key-value pairs that can be attached to an object.
62
+ * This can be useful for storing additional information about the object
63
+ * in a structured format, and querying for objects via API or the dashboard.
64
+ * Keys are strings with a maximum length of 64 characters.
65
+ * Values are strings with a maximum length of 512 characters, booleans, or numbers.
66
+ */
67
+ attributes: Record<string, unknown>
68
+
69
+ /**
70
+ * The unique ID of the file.
71
+ */
72
+ fileId: string
73
+
74
+ /**
75
+ * The name of the file.
76
+ */
77
+ filename: string
78
+
79
+ /**
80
+ * The relevance score of the file - a value between 0 and 1.
81
+ */
82
+ score: number
83
+
84
+ /**
85
+ * The text that was retrieved from the file.
86
+ */
87
+ text: string
88
+ }[]
89
+ },
90
+ {
91
+ /**
92
+ * List of vector store IDs to search through.
93
+ */
94
+ vectorStoreIds: string[]
95
+
96
+ /**
97
+ * Maximum number of search results to return. Defaults to 10.
98
+ */
99
+ maxNumResults?: number
100
+
101
+ /**
102
+ * Ranking options for the search.
103
+ */
104
+ ranking?: {
105
+ /**
106
+ * The ranker to use for the file search.
107
+ */
108
+ ranker?: string
109
+
110
+ /**
111
+ * The score threshold for the file search, a number between 0 and 1.
112
+ * Numbers closer to 1 will attempt to return only the most relevant results,
113
+ * but may return fewer results.
114
+ */
115
+ scoreThreshold?: number
116
+ }
117
+
118
+ /**
119
+ * A filter to apply.
120
+ */
121
+ filters?: OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter
122
+ }
123
+ >({
124
+ id: "openai.file_search",
125
+ inputSchema: z.object({}),
126
+ outputSchema: fileSearchOutputSchema,
127
+ })
@@ -0,0 +1,114 @@
1
+ import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
2
+ import { z } from "zod/v4"
3
+
4
+ export const imageGenerationArgsSchema = z
5
+ .object({
6
+ background: z.enum(["auto", "opaque", "transparent"]).optional(),
7
+ inputFidelity: z.enum(["low", "high"]).optional(),
8
+ inputImageMask: z
9
+ .object({
10
+ fileId: z.string().optional(),
11
+ imageUrl: z.string().optional(),
12
+ })
13
+ .optional(),
14
+ model: z.string().optional(),
15
+ moderation: z.enum(["auto"]).optional(),
16
+ outputCompression: z.number().int().min(0).max(100).optional(),
17
+ outputFormat: z.enum(["png", "jpeg", "webp"]).optional(),
18
+ partialImages: z.number().int().min(0).max(3).optional(),
19
+ quality: z.enum(["auto", "low", "medium", "high"]).optional(),
20
+ size: z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional(),
21
+ })
22
+ .strict()
23
+
24
+ export const imageGenerationOutputSchema = z.object({
25
+ result: z.string(),
26
+ })
27
+
28
+ type ImageGenerationArgs = {
29
+ /**
30
+ * Background type for the generated image. Default is 'auto'.
31
+ */
32
+ background?: "auto" | "opaque" | "transparent"
33
+
34
+ /**
35
+ * Input fidelity for the generated image. Default is 'low'.
36
+ */
37
+ inputFidelity?: "low" | "high"
38
+
39
+ /**
40
+ * Optional mask for inpainting.
41
+ * Contains image_url (string, optional) and file_id (string, optional).
42
+ */
43
+ inputImageMask?: {
44
+ /**
45
+ * File ID for the mask image.
46
+ */
47
+ fileId?: string
48
+
49
+ /**
50
+ * Base64-encoded mask image.
51
+ */
52
+ imageUrl?: string
53
+ }
54
+
55
+ /**
56
+ * The image generation model to use. Default: gpt-image-1.
57
+ */
58
+ model?: string
59
+
60
+ /**
61
+ * Moderation level for the generated image. Default: auto.
62
+ */
63
+ moderation?: "auto"
64
+
65
+ /**
66
+ * Compression level for the output image. Default: 100.
67
+ */
68
+ outputCompression?: number
69
+
70
+ /**
71
+ * The output format of the generated image. One of png, webp, or jpeg.
72
+ * Default: png
73
+ */
74
+ outputFormat?: "png" | "jpeg" | "webp"
75
+
76
+ /**
77
+ * Number of partial images to generate in streaming mode, from 0 (default value) to 3.
78
+ */
79
+ partialImages?: number
80
+
81
+ /**
82
+ * The quality of the generated image.
83
+ * One of low, medium, high, or auto. Default: auto.
84
+ */
85
+ quality?: "auto" | "low" | "medium" | "high"
86
+
87
+ /**
88
+ * The size of the generated image.
89
+ * One of 1024x1024, 1024x1536, 1536x1024, or auto.
90
+ * Default: auto.
91
+ */
92
+ size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024"
93
+ }
94
+
95
+ const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
96
+ {},
97
+ {
98
+ /**
99
+ * The generated image encoded in base64.
100
+ */
101
+ result: string
102
+ },
103
+ ImageGenerationArgs
104
+ >({
105
+ id: "openai.image_generation",
106
+ inputSchema: z.object({}),
107
+ outputSchema: imageGenerationOutputSchema,
108
+ })
109
+
110
+ export const imageGeneration = (
111
+ args: ImageGenerationArgs = {}, // default
112
+ ) => {
113
+ return imageGenerationToolFactory(args)
114
+ }
@@ -0,0 +1,64 @@
1
+ import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
2
+ import { z } from "zod/v4"
3
+
4
+ export const localShellInputSchema = z.object({
5
+ action: z.object({
6
+ type: z.literal("exec"),
7
+ command: z.array(z.string()),
8
+ timeoutMs: z.number().optional(),
9
+ user: z.string().optional(),
10
+ workingDirectory: z.string().optional(),
11
+ env: z.record(z.string(), z.string()).optional(),
12
+ }),
13
+ })
14
+
15
+ export const localShellOutputSchema = z.object({
16
+ output: z.string(),
17
+ })
18
+
19
+ export const localShell = createProviderToolFactoryWithOutputSchema<
20
+ {
21
+ /**
22
+ * Execute a shell command on the server.
23
+ */
24
+ action: {
25
+ type: "exec"
26
+
27
+ /**
28
+ * The command to run.
29
+ */
30
+ command: string[]
31
+
32
+ /**
33
+ * Optional timeout in milliseconds for the command.
34
+ */
35
+ timeoutMs?: number
36
+
37
+ /**
38
+ * Optional user to run the command as.
39
+ */
40
+ user?: string
41
+
42
+ /**
43
+ * Optional working directory to run the command in.
44
+ */
45
+ workingDirectory?: string
46
+
47
+ /**
48
+ * Environment variables to set for the command.
49
+ */
50
+ env?: Record<string, string>
51
+ }
52
+ },
53
+ {
54
+ /**
55
+ * The output of local shell tool call.
56
+ */
57
+ output: string
58
+ },
59
+ {}
60
+ >({
61
+ id: "openai.local_shell",
62
+ inputSchema: localShellInputSchema,
63
+ outputSchema: localShellOutputSchema,
64
+ })
@@ -0,0 +1,103 @@
1
+ import { createProviderToolFactory } from "@ai-sdk/provider-utils"
2
+ import { z } from "zod/v4"
3
+
4
+ // Args validation schema
5
+ export const webSearchPreviewArgsSchema = z.object({
6
+ /**
7
+ * Search context size to use for the web search.
8
+ * - high: Most comprehensive context, highest cost, slower response
9
+ * - medium: Balanced context, cost, and latency (default)
10
+ * - low: Least context, lowest cost, fastest response
11
+ */
12
+ searchContextSize: z.enum(["low", "medium", "high"]).optional(),
13
+
14
+ /**
15
+ * User location information to provide geographically relevant search results.
16
+ */
17
+ userLocation: z
18
+ .object({
19
+ /**
20
+ * Type of location (always 'approximate')
21
+ */
22
+ type: z.literal("approximate"),
23
+ /**
24
+ * Two-letter ISO country code (e.g., 'US', 'GB')
25
+ */
26
+ country: z.string().optional(),
27
+ /**
28
+ * City name (free text, e.g., 'Minneapolis')
29
+ */
30
+ city: z.string().optional(),
31
+ /**
32
+ * Region name (free text, e.g., 'Minnesota')
33
+ */
34
+ region: z.string().optional(),
35
+ /**
36
+ * IANA timezone (e.g., 'America/Chicago')
37
+ */
38
+ timezone: z.string().optional(),
39
+ })
40
+ .optional(),
41
+ })
42
+
43
+ export const webSearchPreview = createProviderToolFactory<
44
+ {
45
+ // Web search doesn't take input parameters - it's controlled by the prompt
46
+ },
47
+ {
48
+ /**
49
+ * Search context size to use for the web search.
50
+ * - high: Most comprehensive context, highest cost, slower response
51
+ * - medium: Balanced context, cost, and latency (default)
52
+ * - low: Least context, lowest cost, fastest response
53
+ */
54
+ searchContextSize?: "low" | "medium" | "high"
55
+
56
+ /**
57
+ * User location information to provide geographically relevant search results.
58
+ */
59
+ userLocation?: {
60
+ /**
61
+ * Type of location (always 'approximate')
62
+ */
63
+ type: "approximate"
64
+ /**
65
+ * Two-letter ISO country code (e.g., 'US', 'GB')
66
+ */
67
+ country?: string
68
+ /**
69
+ * City name (free text, e.g., 'Minneapolis')
70
+ */
71
+ city?: string
72
+ /**
73
+ * Region name (free text, e.g., 'Minnesota')
74
+ */
75
+ region?: string
76
+ /**
77
+ * IANA timezone (e.g., 'America/Chicago')
78
+ */
79
+ timezone?: string
80
+ }
81
+ }
82
+ >({
83
+ id: "openai.web_search_preview",
84
+ inputSchema: z.object({
85
+ action: z
86
+ .discriminatedUnion("type", [
87
+ z.object({
88
+ type: z.literal("search"),
89
+ query: z.string().nullish(),
90
+ }),
91
+ z.object({
92
+ type: z.literal("open_page"),
93
+ url: z.string(),
94
+ }),
95
+ z.object({
96
+ type: z.literal("find"),
97
+ url: z.string(),
98
+ pattern: z.string(),
99
+ }),
100
+ ])
101
+ .nullish(),
102
+ }),
103
+ })