@effect/ai-openai 4.0.0-beta.8 → 4.0.0-beta.81

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