@effect/ai-openai 4.0.0-beta.7 → 4.0.0-beta.71

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 (58) hide show
  1. package/dist/Generated.d.ts +66734 -37723
  2. package/dist/Generated.d.ts.map +1 -1
  3. package/dist/Generated.js +1 -1
  4. package/dist/Generated.js.map +1 -1
  5. package/dist/OpenAiClient.d.ts +167 -27
  6. package/dist/OpenAiClient.d.ts.map +1 -1
  7. package/dist/OpenAiClient.js +337 -44
  8. package/dist/OpenAiClient.js.map +1 -1
  9. package/dist/OpenAiClientGenerated.d.ts +91 -0
  10. package/dist/OpenAiClientGenerated.d.ts.map +1 -0
  11. package/dist/OpenAiClientGenerated.js +84 -0
  12. package/dist/OpenAiClientGenerated.js.map +1 -0
  13. package/dist/OpenAiConfig.d.ts +114 -10
  14. package/dist/OpenAiConfig.d.ts.map +1 -1
  15. package/dist/OpenAiConfig.js +68 -7
  16. package/dist/OpenAiConfig.js.map +1 -1
  17. package/dist/OpenAiEmbeddingModel.d.ts +213 -0
  18. package/dist/OpenAiEmbeddingModel.d.ts.map +1 -0
  19. package/dist/OpenAiEmbeddingModel.js +219 -0
  20. package/dist/OpenAiEmbeddingModel.js.map +1 -0
  21. package/dist/OpenAiError.d.ts +168 -35
  22. package/dist/OpenAiError.d.ts.map +1 -1
  23. package/dist/OpenAiError.js +1 -1
  24. package/dist/OpenAiLanguageModel.d.ts +384 -62
  25. package/dist/OpenAiLanguageModel.d.ts.map +1 -1
  26. package/dist/OpenAiLanguageModel.js +416 -166
  27. package/dist/OpenAiLanguageModel.js.map +1 -1
  28. package/dist/OpenAiSchema.d.ts +2298 -0
  29. package/dist/OpenAiSchema.d.ts.map +1 -0
  30. package/dist/OpenAiSchema.js +814 -0
  31. package/dist/OpenAiSchema.js.map +1 -0
  32. package/dist/OpenAiTelemetry.d.ts +59 -18
  33. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  34. package/dist/OpenAiTelemetry.js +35 -8
  35. package/dist/OpenAiTelemetry.js.map +1 -1
  36. package/dist/OpenAiTool.d.ts +157 -62
  37. package/dist/OpenAiTool.d.ts.map +1 -1
  38. package/dist/OpenAiTool.js +134 -39
  39. package/dist/OpenAiTool.js.map +1 -1
  40. package/dist/index.d.ts +19 -33
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +19 -33
  43. package/dist/index.js.map +1 -1
  44. package/dist/internal/errors.js +4 -4
  45. package/dist/internal/errors.js.map +1 -1
  46. package/package.json +3 -3
  47. package/src/Generated.ts +9858 -5044
  48. package/src/OpenAiClient.ts +513 -95
  49. package/src/OpenAiClientGenerated.ts +202 -0
  50. package/src/OpenAiConfig.ts +115 -11
  51. package/src/OpenAiEmbeddingModel.ts +357 -0
  52. package/src/OpenAiError.ts +170 -35
  53. package/src/OpenAiLanguageModel.ts +802 -167
  54. package/src/OpenAiSchema.ts +1289 -0
  55. package/src/OpenAiTelemetry.ts +81 -23
  56. package/src/OpenAiTool.ts +135 -40
  57. package/src/index.ts +22 -33
  58. package/src/internal/errors.ts +6 -4
@@ -1,29 +1,52 @@
1
1
  /**
2
- * OpenAI provider-defined tools for use with the LanguageModel.
2
+ * OpenAI provider-defined tools for Effect AI language model requests.
3
3
  *
4
- * Provides tools that are natively supported by OpenAI's API, including
5
- * code interpreter, file search, and web search functionality.
4
+ * This module exposes typed descriptors for OpenAI tools such as code
5
+ * interpreter, file search, image generation, MCP, web search, and shell-like
6
+ * local tools. Each descriptor captures the OpenAI provider name, user-facing
7
+ * configuration arguments, provider call parameters, success output schema, and
8
+ * whether the tool call needs an application-provided handler.
6
9
  *
7
- * @since 1.0.0
10
+ * **Mental model**
11
+ *
12
+ * Provider-defined tools are not implementations of the capability themselves.
13
+ * They are schemas and metadata that tell the language model provider which
14
+ * tool to make available and tell Effect AI how to decode any tool calls or
15
+ * tool results that come back.
16
+ *
17
+ * **Common tasks**
18
+ *
19
+ * Use hosted or provider-routed tools such as {@link CodeInterpreter},
20
+ * {@link FileSearch}, {@link ImageGeneration}, {@link Mcp}, {@link WebSearch},
21
+ * and {@link WebSearchPreview} to opt into OpenAI-managed capabilities. Use
22
+ * handler-required tools such as {@link ApplyPatch}, {@link Shell}, and
23
+ * {@link LocalShell} only when your application is prepared to execute the
24
+ * requested local operation and enforce its own safety policy.
25
+ *
26
+ * @since 4.0.0
8
27
  */
9
28
  import * as Schema from "effect/Schema";
10
29
  import * as Tool from "effect/unstable/ai/Tool";
11
30
  /**
12
31
  * Union of all OpenAI provider-defined tools.
13
32
  *
14
- * @since 1.0.0
15
33
  * @category models
34
+ * @since 4.0.0
16
35
  */
17
36
  export type OpenAiTool = ReturnType<typeof ApplyPatch> | ReturnType<typeof CodeInterpreter> | ReturnType<typeof FileSearch> | ReturnType<typeof Shell> | ReturnType<typeof ImageGeneration> | ReturnType<typeof LocalShell> | ReturnType<typeof Mcp> | ReturnType<typeof WebSearch> | ReturnType<typeof WebSearchPreview>;
18
37
  /**
19
- * OpenAI Apply Patch tool.
38
+ * OpenAI Apply Patch tool that allows the model to apply diffs by creating,
39
+ * deleting, or updating files. This local tool runs in your environment and
40
+ * requires a handler to execute file operations.
41
+ *
42
+ * **When to use**
20
43
  *
21
- * Allows the model to apply diffs by creating, deleting, or updating files.
22
- * This is a local tool that runs in your environment and requires a handler
23
- * to execute file operations.
44
+ * Use when you want an OpenAI model to request structured file edits as create,
45
+ * delete, or update operations that your application executes through a local
46
+ * handler.
24
47
  *
25
- * @since 1.0.0
26
48
  * @category tools
49
+ * @since 4.0.0
27
50
  */
28
51
  export declare const ApplyPatch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
29
52
  readonly failureMode?: Mode | undefined;
@@ -52,16 +75,26 @@ export declare const ApplyPatch: <Mode extends Tool.FailureMode | undefined = un
52
75
  readonly failureMode: Mode extends undefined ? "error" : Mode;
53
76
  }, true>;
54
77
  /**
55
- * OpenAI Code Interpreter tool.
78
+ * OpenAI Code Interpreter tool that allows the model to execute Python code in
79
+ * a sandboxed environment.
56
80
  *
57
- * Allows the model to execute Python code in a sandboxed environment.
81
+ * **When to use**
82
+ *
83
+ * Use to enable OpenAI-hosted Python execution for a model response.
84
+ *
85
+ * **Details**
86
+ *
87
+ * The tool is configured with a `container` argument. Successful tool calls
88
+ * expose `outputs`, which may contain logs or generated images, or `null` when
89
+ * no outputs are available.
58
90
  *
59
- * @since 1.0.0
60
91
  * @category tools
92
+ * @since 4.0.0
61
93
  */
62
94
  export declare const CodeInterpreter: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
63
95
  readonly container: string | {
64
96
  readonly type: "auto";
97
+ readonly file_ids?: readonly string[];
65
98
  readonly memory_limit?: "1g" | "4g" | "16g" | "64g" | null;
66
99
  readonly network_policy?: {
67
100
  readonly type: "disabled";
@@ -69,12 +102,11 @@ export declare const CodeInterpreter: <Mode extends Tool.FailureMode | undefined
69
102
  readonly type: "allowlist";
70
103
  readonly allowed_domains: readonly string[];
71
104
  readonly domain_secrets?: readonly {
72
- readonly value: string;
73
- readonly name: string;
74
105
  readonly domain: string;
106
+ readonly name: string;
107
+ readonly value: string;
75
108
  }[];
76
109
  };
77
- readonly file_ids?: readonly string[];
78
110
  };
79
111
  }) => Tool.ProviderDefined<"openai.code_interpreter", "OpenAiCodeInterpreter", {
80
112
  readonly args: Schema.Struct<{
@@ -112,19 +144,29 @@ export declare const CodeInterpreter: <Mode extends Tool.FailureMode | undefined
112
144
  readonly failureMode: Mode extends undefined ? "error" : Mode;
113
145
  }, false>;
114
146
  /**
115
- * OpenAI File Search tool.
147
+ * OpenAI File Search tool that enables the model to search through uploaded
148
+ * files and vector stores.
149
+ *
150
+ * **When to use**
151
+ *
152
+ * Use to let an OpenAI model search uploaded files through one or more vector
153
+ * stores.
154
+ *
155
+ * **Details**
116
156
  *
117
- * Enables the model to search through uploaded files and vector stores.
157
+ * The tool requires `vector_store_ids` and accepts optional `filters`,
158
+ * `max_num_results`, and `ranking_options`. Successful tool calls expose the
159
+ * search `status`, generated `queries`, and optional `results`.
118
160
  *
119
- * @since 1.0.0
120
161
  * @category tools
162
+ * @since 4.0.0
121
163
  */
122
164
  export declare const FileSearch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
123
165
  readonly vector_store_ids: readonly string[];
124
166
  readonly filters?: {
125
- readonly value: string | number | boolean | readonly (string | number)[];
126
- readonly type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
167
+ readonly type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin";
127
168
  readonly key: string;
169
+ readonly value: string | number | boolean | readonly (string | number)[];
128
170
  } | {
129
171
  readonly type: "and" | "or";
130
172
  readonly filters: readonly unknown[];
@@ -141,13 +183,13 @@ export declare const FileSearch: <Mode extends Tool.FailureMode | undefined = un
141
183
  }) => Tool.ProviderDefined<"openai.file_search", "OpenAiFileSearch", {
142
184
  readonly args: Schema.Struct<{
143
185
  readonly filters: Schema.optionalKey<Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
144
- readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte"]>;
186
+ readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
145
187
  readonly key: Schema.String;
146
188
  readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
147
189
  }>, Schema.Struct<{
148
190
  readonly type: Schema.Literals<readonly ["and", "or"]>;
149
191
  readonly filters: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
150
- readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte"]>;
192
+ readonly type: Schema.Literals<readonly ["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]>;
151
193
  readonly key: Schema.String;
152
194
  readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>]>;
153
195
  }>, Schema.Unknown]>>;
@@ -179,27 +221,38 @@ export declare const FileSearch: <Mode extends Tool.FailureMode | undefined = un
179
221
  readonly failureMode: Mode extends undefined ? "error" : Mode;
180
222
  }, false>;
181
223
  /**
182
- * OpenAI Image Generation tool.
224
+ * OpenAI Image Generation tool that enables the model to generate images using
225
+ * the GPT image models.
226
+ *
227
+ * **When to use**
228
+ *
229
+ * Use to enable OpenAI provider-defined image generation through a language
230
+ * model response.
183
231
  *
184
- * Enables the model to generate images using the GPT image models.
232
+ * **Details**
233
+ *
234
+ * The tool configures the `image_generation` provider tool, including model,
235
+ * size, quality, output format, moderation, background, input-image options,
236
+ * and partial image settings. Successful tool calls expose `result` as base64
237
+ * image data or `null`.
185
238
  *
186
- * @since 1.0.0
187
239
  * @category tools
240
+ * @since 4.0.0
188
241
  */
189
242
  export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
190
- readonly model?: string;
191
- readonly size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024";
192
- readonly quality?: "auto" | "low" | "high" | "medium";
193
243
  readonly background?: "auto" | "transparent" | "opaque";
194
- readonly output_format?: "png" | "webp" | "jpeg";
195
- readonly output_compression?: number;
196
- readonly partial_images?: number;
197
- readonly moderation?: "auto" | "low";
198
244
  readonly input_fidelity?: "low" | "high" | null;
199
245
  readonly input_image_mask?: {
200
- readonly file_id?: string;
201
246
  readonly image_url?: string;
247
+ readonly file_id?: string;
202
248
  };
249
+ readonly model?: string;
250
+ readonly moderation?: "auto" | "low";
251
+ readonly output_compression?: number;
252
+ readonly output_format?: "png" | "webp" | "jpeg";
253
+ readonly partial_images?: number;
254
+ readonly quality?: "auto" | "low" | "high" | "medium";
255
+ readonly size?: string;
203
256
  }) => Tool.ProviderDefined<"openai.image_generation", "OpenAiImageGeneration", {
204
257
  readonly args: Schema.Struct<{
205
258
  readonly background: Schema.optionalKey<Schema.Literals<readonly ["transparent", "opaque", "auto"]>>;
@@ -214,7 +267,7 @@ export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined
214
267
  readonly output_format: Schema.optionalKey<Schema.Literals<readonly ["png", "webp", "jpeg"]>>;
215
268
  readonly partial_images: Schema.optionalKey<Schema.Number>;
216
269
  readonly quality: Schema.optionalKey<Schema.Literals<readonly ["low", "medium", "high", "auto"]>>;
217
- readonly size: Schema.optionalKey<Schema.Literals<readonly ["1024x1024", "1024x1536", "1536x1024", "auto"]>>;
270
+ readonly size: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Literals<readonly ["1024x1024", "1024x1536", "1536x1024", "auto"]>]>>;
218
271
  }>;
219
272
  readonly parameters: Schema.Void;
220
273
  readonly success: Schema.Struct<{
@@ -224,13 +277,23 @@ export declare const ImageGeneration: <Mode extends Tool.FailureMode | undefined
224
277
  readonly failureMode: Mode extends undefined ? "error" : Mode;
225
278
  }, false>;
226
279
  /**
227
- * OpenAI Local Shell tool.
280
+ * OpenAI Local Shell tool that enables the model to run a command with a local
281
+ * shell. This local tool runs in your environment and requires a handler to
282
+ * execute commands.
283
+ *
284
+ * **When to use**
285
+ *
286
+ * Use to let an OpenAI model request local shell commands that your application
287
+ * executes through a handler.
228
288
  *
229
- * Enables the model to run a command with a local shell. This is a local tool
230
- * that runs in your environment and requires a handler to execute commands.
289
+ * **Details**
290
+ *
291
+ * The tool exposes a provider-defined `local_shell` call. It is marked as
292
+ * handler-required, so applications must provide the command execution policy
293
+ * and implementation.
231
294
  *
232
- * @since 1.0.0
233
295
  * @category tools
296
+ * @since 4.0.0
234
297
  */
235
298
  export declare const LocalShell: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
236
299
  readonly failureMode?: Mode | undefined;
@@ -253,13 +316,27 @@ export declare const LocalShell: <Mode extends Tool.FailureMode | undefined = un
253
316
  readonly failureMode: Mode extends undefined ? "error" : Mode;
254
317
  }, true>;
255
318
  /**
256
- * OpenAI MCP tool.
319
+ * OpenAI MCP tool that gives the model access to additional tools via remote
320
+ * Model Context Protocol (MCP) servers.
321
+ *
322
+ * **When to use**
323
+ *
324
+ * Use to let an OpenAI model call tools exposed by a remote MCP server.
325
+ *
326
+ * **Details**
257
327
  *
258
- * Gives the model access to additional tools via remote Model Context Protocol
259
- * (MCP) servers
328
+ * The tool accepts MCP server configuration such as allowed tools,
329
+ * authorization, connector id, approval requirements, server metadata, and
330
+ * server URL. Tool call results include the called tool name, arguments, output,
331
+ * error, and server label.
332
+ *
333
+ * **Gotchas**
334
+ *
335
+ * This schema leaves both `server_url` and `connector_id` optional, but OpenAI
336
+ * may require a server URL or connector id for a usable MCP tool configuration.
260
337
  *
261
- * @since 1.0.0
262
338
  * @category tools
339
+ * @since 4.0.0
263
340
  */
264
341
  export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
265
342
  readonly server_label: string;
@@ -267,10 +344,8 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
267
344
  readonly tool_names?: readonly string[];
268
345
  readonly read_only?: boolean;
269
346
  } | null;
270
- readonly server_url?: string;
271
- readonly connector_id?: "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | "connector_googledrive" | "connector_microsoftteams" | "connector_outlookcalendar" | "connector_outlookemail" | "connector_sharepoint";
272
347
  readonly authorization?: string;
273
- readonly server_description?: string;
348
+ readonly connector_id?: "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | "connector_googledrive" | "connector_microsoftteams" | "connector_outlookcalendar" | "connector_outlookemail" | "connector_sharepoint";
274
349
  readonly require_approval?: "always" | "never" | {
275
350
  readonly always?: {
276
351
  readonly tool_names?: readonly string[];
@@ -281,6 +356,8 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
281
356
  readonly read_only?: boolean;
282
357
  };
283
358
  } | null;
359
+ readonly server_description?: string;
360
+ readonly server_url?: string;
284
361
  }) => Tool.ProviderDefined<"openai.mcp", "OpenAiMcp", {
285
362
  readonly args: Schema.Struct<{
286
363
  readonly allowed_tools: Schema.optionalKey<Schema.Union<readonly [Schema.Union<readonly [Schema.$Array<Schema.String>, Schema.Struct<{
@@ -303,7 +380,7 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
303
380
  readonly server_label: Schema.String;
304
381
  readonly server_url: Schema.optionalKey<Schema.String>;
305
382
  }>;
306
- readonly parameters: Schema.Void;
383
+ readonly parameters: Schema.Unknown;
307
384
  readonly success: Schema.Struct<{
308
385
  readonly type: Schema.Literal<"mcp_call">;
309
386
  readonly name: Schema.String;
@@ -316,14 +393,12 @@ export declare const Mcp: <Mode extends Tool.FailureMode | undefined = undefined
316
393
  readonly failureMode: Mode extends undefined ? "error" : Mode;
317
394
  }, false>;
318
395
  /**
319
- * OpenAI Function Shell tool.
320
- *
321
- * Enables the model to execute one or more shell commands in a managed
322
- * environment. This is a local tool that runs in your environment and requires
323
- * a handler to execute commands.
396
+ * OpenAI Function Shell tool that enables the model to execute one or more shell
397
+ * commands in a managed environment. This local tool runs in your environment
398
+ * and requires a handler to execute commands.
324
399
  *
325
- * @since 1.0.0
326
400
  * @category tools
401
+ * @since 4.0.0
327
402
  */
328
403
  export declare const Shell: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
329
404
  readonly failureMode?: Mode | undefined;
@@ -346,20 +421,34 @@ export declare const Shell: <Mode extends Tool.FailureMode | undefined = undefin
346
421
  readonly type: Schema.Literal<"exit">;
347
422
  readonly exit_code: Schema.Number;
348
423
  }>]>;
424
+ readonly created_by: Schema.optionalKey<Schema.String>;
349
425
  }>>;
350
426
  }>;
351
427
  readonly failure: Schema.Never;
352
428
  readonly failureMode: Mode extends undefined ? "error" : Mode;
353
429
  }, true>;
354
430
  /**
355
- * OpenAI Web Search tool.
431
+ * OpenAI Web Search tool that enables the model to search the web for
432
+ * information.
433
+ *
434
+ * **When to use**
435
+ *
436
+ * Use to enable OpenAI provider-defined web search for a model response.
356
437
  *
357
- * Enables the model to search the web for information.
438
+ * **Details**
439
+ *
440
+ * The tool accepts optional filters, user location, and search context size.
441
+ * Successful calls expose the performed search action and status.
442
+ *
443
+ * @see {@link WebSearchPreview} for the preview web search provider tool
358
444
  *
359
- * @since 1.0.0
360
445
  * @category tools
446
+ * @since 4.0.0
361
447
  */
362
448
  export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
449
+ readonly filters?: {
450
+ readonly allowed_domains?: readonly string[] | null;
451
+ } | null;
363
452
  readonly user_location?: {
364
453
  readonly type?: "approximate";
365
454
  readonly country?: string | null;
@@ -368,9 +457,6 @@ export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = und
368
457
  readonly timezone?: string | null;
369
458
  } | null;
370
459
  readonly search_context_size?: "low" | "high" | "medium";
371
- readonly filters?: {
372
- readonly allowed_domains?: readonly string[] | null;
373
- } | null;
374
460
  }) => Tool.ProviderDefined<"openai.web_search", "OpenAiWebSearch", {
375
461
  readonly args: Schema.Struct<{
376
462
  readonly filters: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
@@ -426,12 +512,21 @@ export declare const WebSearch: <Mode extends Tool.FailureMode | undefined = und
426
512
  readonly failureMode: Mode extends undefined ? "error" : Mode;
427
513
  }, false>;
428
514
  /**
429
- * OpenAI Web Search Preview tool.
515
+ * OpenAI preview Web Search tool for model responses.
516
+ *
517
+ * **When to use**
518
+ *
519
+ * Use to enable the preview OpenAI web search provider tool.
520
+ *
521
+ * **Details**
522
+ *
523
+ * The preview tool accepts optional user location and search context size, then
524
+ * exposes the performed search action and status in successful calls.
430
525
  *
431
- * Preview version of the web search tool with additional features.
526
+ * @see {@link WebSearch} for the stable web search provider tool
432
527
  *
433
- * @since 1.0.0
434
528
  * @category tools
529
+ * @since 4.0.0
435
530
  */
436
531
  export declare const WebSearchPreview: <Mode extends Tool.FailureMode | undefined = undefined>(args: {
437
532
  readonly user_location?: {
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAiTool.d.ts","sourceRoot":"","sources":["../src/OpenAiTool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OA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AAM,UAAU;;;;;;;;;;;;;;;;;;;QAWrB,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAsBd,CAAA;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;QAWhB,CAAA;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBpB,CAAA;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAY3B,CAAA"}
@@ -1,23 +1,46 @@
1
1
  /**
2
- * OpenAI provider-defined tools for use with the LanguageModel.
2
+ * OpenAI provider-defined tools for Effect AI language model requests.
3
3
  *
4
- * Provides tools that are natively supported by OpenAI's API, including
5
- * code interpreter, file search, and web search functionality.
4
+ * This module exposes typed descriptors for OpenAI tools such as code
5
+ * interpreter, file search, image generation, MCP, web search, and shell-like
6
+ * local tools. Each descriptor captures the OpenAI provider name, user-facing
7
+ * configuration arguments, provider call parameters, success output schema, and
8
+ * whether the tool call needs an application-provided handler.
6
9
  *
7
- * @since 1.0.0
10
+ * **Mental model**
11
+ *
12
+ * Provider-defined tools are not implementations of the capability themselves.
13
+ * They are schemas and metadata that tell the language model provider which
14
+ * tool to make available and tell Effect AI how to decode any tool calls or
15
+ * tool results that come back.
16
+ *
17
+ * **Common tasks**
18
+ *
19
+ * Use hosted or provider-routed tools such as {@link CodeInterpreter},
20
+ * {@link FileSearch}, {@link ImageGeneration}, {@link Mcp}, {@link WebSearch},
21
+ * and {@link WebSearchPreview} to opt into OpenAI-managed capabilities. Use
22
+ * handler-required tools such as {@link ApplyPatch}, {@link Shell}, and
23
+ * {@link LocalShell} only when your application is prepared to execute the
24
+ * requested local operation and enforce its own safety policy.
25
+ *
26
+ * @since 4.0.0
8
27
  */
9
28
  import * as Schema from "effect/Schema";
10
29
  import * as Tool from "effect/unstable/ai/Tool";
11
30
  import * as Generated from "./Generated.js";
12
31
  /**
13
- * OpenAI Apply Patch tool.
32
+ * OpenAI Apply Patch tool that allows the model to apply diffs by creating,
33
+ * deleting, or updating files. This local tool runs in your environment and
34
+ * requires a handler to execute file operations.
14
35
  *
15
- * Allows the model to apply diffs by creating, deleting, or updating files.
16
- * This is a local tool that runs in your environment and requires a handler
17
- * to execute file operations.
36
+ * **When to use**
37
+ *
38
+ * Use when you want an OpenAI model to request structured file edits as create,
39
+ * delete, or update operations that your application executes through a local
40
+ * handler.
18
41
  *
19
- * @since 1.0.0
20
42
  * @category tools
43
+ * @since 4.0.0
21
44
  */
22
45
  export const ApplyPatch = /*#__PURE__*/Tool.providerDefined({
23
46
  id: "openai.apply_patch",
@@ -34,12 +57,21 @@ export const ApplyPatch = /*#__PURE__*/Tool.providerDefined({
34
57
  })
35
58
  });
36
59
  /**
37
- * OpenAI Code Interpreter tool.
60
+ * OpenAI Code Interpreter tool that allows the model to execute Python code in
61
+ * a sandboxed environment.
62
+ *
63
+ * **When to use**
64
+ *
65
+ * Use to enable OpenAI-hosted Python execution for a model response.
66
+ *
67
+ * **Details**
38
68
  *
39
- * Allows the model to execute Python code in a sandboxed environment.
69
+ * The tool is configured with a `container` argument. Successful tool calls
70
+ * expose `outputs`, which may contain logs or generated images, or `null` when
71
+ * no outputs are available.
40
72
  *
41
- * @since 1.0.0
42
73
  * @category tools
74
+ * @since 4.0.0
43
75
  */
44
76
  export const CodeInterpreter = /*#__PURE__*/Tool.providerDefined({
45
77
  id: "openai.code_interpreter",
@@ -57,12 +89,22 @@ export const CodeInterpreter = /*#__PURE__*/Tool.providerDefined({
57
89
  })
58
90
  });
59
91
  /**
60
- * OpenAI File Search tool.
92
+ * OpenAI File Search tool that enables the model to search through uploaded
93
+ * files and vector stores.
61
94
  *
62
- * Enables the model to search through uploaded files and vector stores.
95
+ * **When to use**
96
+ *
97
+ * Use to let an OpenAI model search uploaded files through one or more vector
98
+ * stores.
99
+ *
100
+ * **Details**
101
+ *
102
+ * The tool requires `vector_store_ids` and accepts optional `filters`,
103
+ * `max_num_results`, and `ranking_options`. Successful tool calls expose the
104
+ * search `status`, generated `queries`, and optional `results`.
63
105
  *
64
- * @since 1.0.0
65
106
  * @category tools
107
+ * @since 4.0.0
66
108
  */
67
109
  export const FileSearch = /*#__PURE__*/Tool.providerDefined({
68
110
  id: "openai.file_search",
@@ -81,12 +123,23 @@ export const FileSearch = /*#__PURE__*/Tool.providerDefined({
81
123
  })
82
124
  });
83
125
  /**
84
- * OpenAI Image Generation tool.
126
+ * OpenAI Image Generation tool that enables the model to generate images using
127
+ * the GPT image models.
128
+ *
129
+ * **When to use**
85
130
  *
86
- * Enables the model to generate images using the GPT image models.
131
+ * Use to enable OpenAI provider-defined image generation through a language
132
+ * model response.
133
+ *
134
+ * **Details**
135
+ *
136
+ * The tool configures the `image_generation` provider tool, including model,
137
+ * size, quality, output format, moderation, background, input-image options,
138
+ * and partial image settings. Successful tool calls expose `result` as base64
139
+ * image data or `null`.
87
140
  *
88
- * @since 1.0.0
89
141
  * @category tools
142
+ * @since 4.0.0
90
143
  */
91
144
  export const ImageGeneration = /*#__PURE__*/Tool.providerDefined({
92
145
  id: "openai.image_generation",
@@ -109,13 +162,23 @@ export const ImageGeneration = /*#__PURE__*/Tool.providerDefined({
109
162
  })
110
163
  });
111
164
  /**
112
- * OpenAI Local Shell tool.
165
+ * OpenAI Local Shell tool that enables the model to run a command with a local
166
+ * shell. This local tool runs in your environment and requires a handler to
167
+ * execute commands.
168
+ *
169
+ * **When to use**
170
+ *
171
+ * Use to let an OpenAI model request local shell commands that your application
172
+ * executes through a handler.
113
173
  *
114
- * Enables the model to run a command with a local shell. This is a local tool
115
- * that runs in your environment and requires a handler to execute commands.
174
+ * **Details**
175
+ *
176
+ * The tool exposes a provider-defined `local_shell` call. It is marked as
177
+ * handler-required, so applications must provide the command execution policy
178
+ * and implementation.
116
179
  *
117
- * @since 1.0.0
118
180
  * @category tools
181
+ * @since 4.0.0
119
182
  */
120
183
  export const LocalShell = /*#__PURE__*/Tool.providerDefined({
121
184
  id: "openai.local_shell",
@@ -130,13 +193,27 @@ export const LocalShell = /*#__PURE__*/Tool.providerDefined({
130
193
  })
131
194
  });
132
195
  /**
133
- * OpenAI MCP tool.
196
+ * OpenAI MCP tool that gives the model access to additional tools via remote
197
+ * Model Context Protocol (MCP) servers.
198
+ *
199
+ * **When to use**
200
+ *
201
+ * Use to let an OpenAI model call tools exposed by a remote MCP server.
202
+ *
203
+ * **Details**
134
204
  *
135
- * Gives the model access to additional tools via remote Model Context Protocol
136
- * (MCP) servers
205
+ * The tool accepts MCP server configuration such as allowed tools,
206
+ * authorization, connector id, approval requirements, server metadata, and
207
+ * server URL. Tool call results include the called tool name, arguments, output,
208
+ * error, and server label.
209
+ *
210
+ * **Gotchas**
211
+ *
212
+ * This schema leaves both `server_url` and `connector_id` optional, but OpenAI
213
+ * may require a server URL or connector id for a usable MCP tool configuration.
137
214
  *
138
- * @since 1.0.0
139
215
  * @category tools
216
+ * @since 4.0.0
140
217
  */
141
218
  export const Mcp = /*#__PURE__*/Tool.providerDefined({
142
219
  id: "openai.mcp",
@@ -151,6 +228,7 @@ export const Mcp = /*#__PURE__*/Tool.providerDefined({
151
228
  server_label: Generated.MCPTool.fields.server_label,
152
229
  server_url: Generated.MCPTool.fields.server_url
153
230
  }),
231
+ parameters: Schema.Unknown,
154
232
  success: /*#__PURE__*/Schema.Struct({
155
233
  type: Generated.MCPToolCall.fields.type,
156
234
  name: Generated.MCPToolCall.fields.name,
@@ -161,14 +239,12 @@ export const Mcp = /*#__PURE__*/Tool.providerDefined({
161
239
  })
162
240
  });
163
241
  /**
164
- * OpenAI Function Shell tool.
242
+ * OpenAI Function Shell tool that enables the model to execute one or more shell
243
+ * commands in a managed environment. This local tool runs in your environment
244
+ * and requires a handler to execute commands.
165
245
  *
166
- * Enables the model to execute one or more shell commands in a managed
167
- * environment. This is a local tool that runs in your environment and requires
168
- * a handler to execute commands.
169
- *
170
- * @since 1.0.0
171
246
  * @category tools
247
+ * @since 4.0.0
172
248
  */
173
249
  export const Shell = /*#__PURE__*/Tool.providerDefined({
174
250
  id: "openai.shell",
@@ -179,16 +255,26 @@ export const Shell = /*#__PURE__*/Tool.providerDefined({
179
255
  action: Generated.FunctionShellCall.fields.action
180
256
  }),
181
257
  success: /*#__PURE__*/Schema.Struct({
182
- output: Generated.FunctionShellCallOutputItemParam.fields.output
258
+ output: Generated.FunctionShellCallOutput.fields.output
183
259
  })
184
260
  });
185
261
  /**
186
- * OpenAI Web Search tool.
262
+ * OpenAI Web Search tool that enables the model to search the web for
263
+ * information.
264
+ *
265
+ * **When to use**
187
266
  *
188
- * Enables the model to search the web for information.
267
+ * Use to enable OpenAI provider-defined web search for a model response.
268
+ *
269
+ * **Details**
270
+ *
271
+ * The tool accepts optional filters, user location, and search context size.
272
+ * Successful calls expose the performed search action and status.
273
+ *
274
+ * @see {@link WebSearchPreview} for the preview web search provider tool
189
275
  *
190
- * @since 1.0.0
191
276
  * @category tools
277
+ * @since 4.0.0
192
278
  */
193
279
  export const WebSearch = /*#__PURE__*/Tool.providerDefined({
194
280
  id: "openai.web_search",
@@ -208,12 +294,21 @@ export const WebSearch = /*#__PURE__*/Tool.providerDefined({
208
294
  })
209
295
  });
210
296
  /**
211
- * OpenAI Web Search Preview tool.
297
+ * OpenAI preview Web Search tool for model responses.
298
+ *
299
+ * **When to use**
300
+ *
301
+ * Use to enable the preview OpenAI web search provider tool.
302
+ *
303
+ * **Details**
304
+ *
305
+ * The preview tool accepts optional user location and search context size, then
306
+ * exposes the performed search action and status in successful calls.
212
307
  *
213
- * Preview version of the web search tool with additional features.
308
+ * @see {@link WebSearch} for the stable web search provider tool
214
309
  *
215
- * @since 1.0.0
216
310
  * @category tools
311
+ * @since 4.0.0
217
312
  */
218
313
  export const WebSearchPreview = /*#__PURE__*/Tool.providerDefined({
219
314
  id: "openai.web_search_preview",