@effect/ai-openai 4.0.0-beta.50 → 4.0.0-beta.52

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.
@@ -12,8 +12,8 @@ import * as Layer from "effect/Layer";
12
12
  import * as Schema from "effect/Schema";
13
13
  import * as LanguageModel from "effect/unstable/ai/LanguageModel";
14
14
  import * as AiModel from "effect/unstable/ai/Model";
15
- import * as Generated from "./Generated.ts";
16
15
  import { OpenAiClient } from "./OpenAiClient.ts";
16
+ import type * as OpenAiSchema from "./OpenAiSchema.ts";
17
17
  declare const ResponseModelIds: Schema.Literals<readonly ["o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", "gpt-5-pro-2025-10-06", "gpt-5.1-codex-max"]>;
18
18
  declare const SharedModelIds: Schema.Literals<readonly ["gpt-5.2", "gpt-5.2-2025-12-11", "gpt-5.2-chat-latest", "gpt-5.2-pro", "gpt-5.2-pro-2025-12-11", "gpt-5.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613"]>;
19
19
  /**
@@ -26,45 +26,27 @@ export type Model = typeof ResponseModelIds.Encoded | typeof SharedModelIds.Enco
26
26
  */
27
27
  type ImageDetail = "auto" | "low" | "high";
28
28
  declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai/OpenAiLanguageModel/Config", {
29
- readonly metadata?: {} | null;
29
+ readonly metadata?: {
30
+ readonly [x: string]: string;
31
+ } | null;
30
32
  readonly top_logprobs?: number;
31
33
  readonly user?: string | null;
32
34
  readonly model?: string;
33
35
  readonly instructions?: string | null;
34
- readonly prompt?: {
35
- readonly id: string;
36
- readonly version?: string | null;
37
- readonly variables?: {} | null;
38
- } | null;
39
36
  readonly temperature?: number | null;
40
37
  readonly top_p?: number | null;
41
38
  readonly background?: boolean | null;
42
- readonly conversation?: string | {
43
- readonly id: string;
44
- } | null;
45
- readonly service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
46
- readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null;
47
- readonly stream_options?: {
48
- readonly include_obfuscation?: boolean;
49
- } | null;
39
+ readonly conversation?: string | null;
40
+ readonly modalities?: readonly ("text" | "audio")[];
41
+ readonly service_tier?: string;
42
+ readonly seed?: number;
43
+ readonly include?: readonly ("web_search_call.action.sources" | "message.input_image.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null;
50
44
  readonly max_output_tokens?: number | null;
51
- readonly reasoning?: {
52
- readonly summary?: "auto" | "concise" | "detailed" | null;
53
- readonly effort?: "low" | "high" | "none" | "minimal" | "medium" | "xhigh" | null;
54
- readonly generate_summary?: "auto" | "concise" | "detailed" | null;
55
- } | null;
45
+ readonly reasoning?: unknown;
56
46
  readonly truncation?: "auto" | "disabled" | null;
57
- readonly parallel_tool_calls?: boolean | null;
58
- readonly safety_identifier?: string | null;
59
- readonly prompt_cache_key?: string | null;
60
- readonly prompt_cache_retention?: "in-memory" | "24h" | null;
61
47
  readonly store?: boolean | null;
62
48
  readonly previous_response_id?: string | null;
63
49
  readonly max_tool_calls?: number | null;
64
- readonly context_management?: readonly {
65
- readonly type: string;
66
- readonly compact_threshold?: number | null;
67
- }[] | null;
68
50
  readonly fileIdPrefixes?: readonly string[] | undefined;
69
51
  readonly text?: {
70
52
  /**
@@ -124,7 +106,7 @@ declare module "effect/unstable/ai/Prompt" {
124
106
  /**
125
107
  * The status of item.
126
108
  */
127
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
109
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
128
110
  /**
129
111
  * The ID of the approval request.
130
112
  */
@@ -140,7 +122,7 @@ declare module "effect/unstable/ai/Prompt" {
140
122
  /**
141
123
  * The status of item.
142
124
  */
143
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
125
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
144
126
  /**
145
127
  * The ID of the approval request.
146
128
  */
@@ -156,11 +138,11 @@ declare module "effect/unstable/ai/Prompt" {
156
138
  /**
157
139
  * The status of item.
158
140
  */
159
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
141
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
160
142
  /**
161
143
  * A list of annotations that apply to the output text.
162
144
  */
163
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
145
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
164
146
  } | null;
165
147
  }
166
148
  }
@@ -177,11 +159,11 @@ declare module "effect/unstable/ai/Response" {
177
159
  /**
178
160
  * The status of item.
179
161
  */
180
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
162
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
181
163
  /**
182
164
  * The text content part annotations.
183
165
  */
184
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
166
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
185
167
  };
186
168
  }
187
169
  interface TextStartPartMetadata extends ProviderMetadata {
@@ -192,7 +174,7 @@ declare module "effect/unstable/ai/Response" {
192
174
  interface TextEndPartMetadata extends ProviderMetadata {
193
175
  readonly openai?: {
194
176
  readonly itemId?: string | null;
195
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
177
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
196
178
  } | null;
197
179
  }
198
180
  interface ReasoningPartMetadata extends ProviderMetadata {
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAiLanguageModel.d.ts","sourceRoot":"","sources":["../src/OpenAiLanguageModel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAIr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,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAwBhH,CAAA"}
@@ -113,17 +113,11 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
113
113
  text: {
114
114
  verbosity: config.text?.verbosity ?? null,
115
115
  format: responseFormat
116
- },
117
- ...(tools ? {
118
- tools
119
- } : undefined),
120
- ...(toolChoice ? {
121
- tool_choice: toolChoice
122
- } : undefined),
123
- ...(options.previousResponseId ? {
124
- previous_response_id: options.previousResponseId
125
- } : undefined)
116
+ }
126
117
  };
118
+ if (tools) request.tools = tools;
119
+ if (toolChoice) request.tool_choice = toolChoice;
120
+ if (options.previousResponseId) request.previous_response_id = options.previousResponseId;
127
121
  return request;
128
122
  });
129
123
  return yield* LanguageModel.make({
@@ -385,7 +379,9 @@ const prepareMessages = /*#__PURE__*/Effect.fnUntraced(function* ({
385
379
  type: "reasoning",
386
380
  id,
387
381
  summary: summaryParts,
388
- encrypted_content: encryptedContent ?? null
382
+ ...(Predicate.isNotNull(encryptedContent) ? {
383
+ encrypted_content: encryptedContent
384
+ } : undefined)
389
385
  };
390
386
  messages.push(reasoningMessages[id]);
391
387
  } else {
@@ -583,6 +579,8 @@ const buildHttpResponseDetails = response => ({
583
579
  status: response.status,
584
580
  headers: Redactable.redact(response.headers)
585
581
  });
582
+ const knownResponseStreamEventTypes = /*#__PURE__*/new Set(["response.created", "response.completed", "response.incomplete", "response.failed", "response.output_item.added", "response.output_item.done", "response.output_text.delta", "response.output_text.annotation.added", "response.reasoning_summary_part.added", "response.reasoning_summary_part.done", "response.reasoning_summary_text.delta", "response.function_call_arguments.delta", "response.function_call_arguments.done", "response.code_interpreter_call_code.delta", "response.code_interpreter_call_code.done", "response.apply_patch_call_operation_diff.delta", "response.apply_patch_call_operation_diff.done", "response.image_generation_call.partial_image", "error"]);
583
+ const isKnownResponseStreamEvent = event => knownResponseStreamEventTypes.has(event.type);
586
584
  const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
587
585
  options,
588
586
  rawResponse,
@@ -616,9 +614,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
616
614
  operation: part.operation
617
615
  },
618
616
  metadata: {
619
- openai: {
620
- ...makeItemIdMetadata(part.id)
621
- }
617
+ openai: makeItemIdMetadata(part.id)
622
618
  }
623
619
  });
624
620
  break;
@@ -695,9 +691,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
695
691
  name: toolName,
696
692
  params,
697
693
  metadata: {
698
- openai: {
699
- ...makeItemIdMetadata(part.id)
700
- }
694
+ openai: makeItemIdMetadata(part.id)
701
695
  }
702
696
  });
703
697
  break;
@@ -734,9 +728,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
734
728
  action: part.action
735
729
  },
736
730
  metadata: {
737
- openai: {
738
- ...makeItemIdMetadata(part.id)
739
- }
731
+ openai: makeItemIdMetadata(part.id)
740
732
  }
741
733
  });
742
734
  break;
@@ -771,9 +763,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
771
763
  } : undefined)
772
764
  },
773
765
  metadata: {
774
- openai: {
775
- ...makeItemIdMetadata(part.id)
776
- }
766
+ openai: makeItemIdMetadata(part.id)
777
767
  }
778
768
  });
779
769
  break;
@@ -789,7 +779,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
789
779
  const toolId = yield* idGenerator.generateId();
790
780
  const toolName = `mcp.${part.name}`;
791
781
  const params = yield* Effect.try({
792
- try: () => Tool.unsafeSecureJsonParse(part.arguments),
782
+ try: () => Tool.unsafeSecureJsonParse(typeof part.arguments === "string" ? part.arguments : JSON.stringify(part.arguments)),
793
783
  catch: cause => AiError.make({
794
784
  module: "OpenAiLanguageModel",
795
785
  method: "makeResponse",
@@ -959,9 +949,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
959
949
  action: part.action
960
950
  },
961
951
  metadata: {
962
- openai: {
963
- ...makeItemIdMetadata(part.id)
964
- }
952
+ openai: makeItemIdMetadata(part.id)
965
953
  }
966
954
  });
967
955
  break;
@@ -997,13 +985,7 @@ const makeResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
997
985
  reason: finishReason,
998
986
  usage: getUsage(rawResponse.usage),
999
987
  response: buildHttpResponseDetails(response),
1000
- ...(rawResponse.service_tier && {
1001
- metadata: {
1002
- openai: {
1003
- serviceTier: rawResponse.service_tier
1004
- }
1005
- }
1006
- })
988
+ ...toServiceTier(rawResponse.service_tier)
1007
989
  });
1008
990
  return parts;
1009
991
  });
@@ -1042,6 +1024,9 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1042
1024
  const webSearchTool = options.tools.find(tool => Tool.isProviderDefined(tool) && (tool.name === "OpenAiWebSearch" || tool.name === "OpenAiWebSearchPreview"));
1043
1025
  return stream.pipe(Stream.mapEffect(Effect.fnUntraced(function* (event) {
1044
1026
  const parts = [];
1027
+ if (!isKnownResponseStreamEvent(event)) {
1028
+ return parts;
1029
+ }
1045
1030
  switch (event.type) {
1046
1031
  case "response.created":
1047
1032
  {
@@ -1072,13 +1057,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1072
1057
  reason: InternalUtilities.resolveFinishReason(event.response.incomplete_details?.reason, hasToolCalls),
1073
1058
  usage: getUsage(event.response.usage),
1074
1059
  response: buildHttpResponseDetails(response),
1075
- ...(event.response.service_tier && {
1076
- metadata: {
1077
- openai: {
1078
- serviceTier: event.response.service_tier
1079
- }
1080
- }
1081
- })
1060
+ ...toServiceTier(event.response.service_tier)
1082
1061
  });
1083
1062
  break;
1084
1063
  }
@@ -1220,9 +1199,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1220
1199
  type: "text-start",
1221
1200
  id: event.item.id,
1222
1201
  metadata: {
1223
- openai: {
1224
- ...makeItemIdMetadata(event.item.id)
1225
- }
1202
+ openai: makeItemIdMetadata(event.item.id)
1226
1203
  }
1227
1204
  });
1228
1205
  break;
@@ -1249,7 +1226,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1249
1226
  {
1250
1227
  const toolName = toolNameMapper.getCustomName("shell");
1251
1228
  activeToolCalls[event.output_index] = {
1252
- id: event.item.id,
1229
+ id: event.item.id ?? event.item.call_id,
1253
1230
  name: toolName
1254
1231
  };
1255
1232
  break;
@@ -1294,7 +1271,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1294
1271
  parts.push({
1295
1272
  type: "tool-params-delta",
1296
1273
  id: toolCall.id,
1297
- delta: InternalUtilities.escapeJSONDelta(event.item.operation.diff)
1274
+ delta: InternalUtilities.escapeJSONDelta(event.item.operation.diff ?? "")
1298
1275
  });
1299
1276
  }
1300
1277
  parts.push({
@@ -1320,9 +1297,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1320
1297
  operation: event.item.operation
1321
1298
  },
1322
1299
  metadata: {
1323
- openai: {
1324
- ...makeItemIdMetadata(event.item.id)
1325
- }
1300
+ openai: makeItemIdMetadata(event.item.id)
1326
1301
  }
1327
1302
  });
1328
1303
  }
@@ -1426,9 +1401,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1426
1401
  name: toolName,
1427
1402
  params,
1428
1403
  metadata: {
1429
- openai: {
1430
- ...makeItemIdMetadata(event.item.id)
1431
- }
1404
+ openai: makeItemIdMetadata(event.item.id)
1432
1405
  }
1433
1406
  });
1434
1407
  break;
@@ -1459,9 +1432,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1459
1432
  action: event.item.action
1460
1433
  },
1461
1434
  metadata: {
1462
- openai: {
1463
- ...makeItemIdMetadata(event.item.id)
1464
- }
1435
+ openai: makeItemIdMetadata(event.item.id)
1465
1436
  }
1466
1437
  });
1467
1438
  break;
@@ -1498,9 +1469,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1498
1469
  } : undefined)
1499
1470
  },
1500
1471
  metadata: {
1501
- openai: {
1502
- ...makeItemIdMetadata(event.item.id)
1503
- }
1472
+ openai: makeItemIdMetadata(event.item.id)
1504
1473
  }
1505
1474
  });
1506
1475
  break;
@@ -1573,15 +1542,13 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1573
1542
  const toolName = toolNameMapper.getCustomName("shell");
1574
1543
  parts.push({
1575
1544
  type: "tool-call",
1576
- id: event.item.id,
1545
+ id: event.item.id ?? event.item.call_id,
1577
1546
  name: toolName,
1578
1547
  params: {
1579
1548
  action: event.item.action
1580
1549
  },
1581
1550
  metadata: {
1582
- openai: {
1583
- ...makeItemIdMetadata(event.item.id)
1584
- }
1551
+ openai: makeItemIdMetadata(event.item.id)
1585
1552
  }
1586
1553
  });
1587
1554
  break;
@@ -1726,9 +1693,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1726
1693
  name: toolCall.name,
1727
1694
  params,
1728
1695
  metadata: {
1729
- openai: {
1730
- ...makeItemIdMetadata(event.item_id)
1731
- }
1696
+ openai: makeItemIdMetadata(event.item_id)
1732
1697
  }
1733
1698
  });
1734
1699
  toolCall.functionCall.emitted = true;
@@ -1871,9 +1836,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1871
1836
  id: `${event.item_id}:${event.summary_index}`,
1872
1837
  delta: event.delta,
1873
1838
  metadata: {
1874
- openai: {
1875
- ...makeItemIdMetadata(event.item_id)
1876
- }
1839
+ openai: makeItemIdMetadata(event.item_id)
1877
1840
  }
1878
1841
  });
1879
1842
  break;
@@ -1888,9 +1851,7 @@ const makeStreamResponse = /*#__PURE__*/Effect.fnUntraced(function* ({
1888
1851
  type: "reasoning-end",
1889
1852
  id: `${event.item_id}:${event.summary_index}`,
1890
1853
  metadata: {
1891
- openai: {
1892
- ...makeItemIdMetadata(event.item_id)
1893
- }
1854
+ openai: makeItemIdMetadata(event.item_id)
1894
1855
  }
1895
1856
  });
1896
1857
  // Mark the summary part concluded
@@ -2180,7 +2141,7 @@ const getEncryptedContent = part => part.options.openai?.encryptedContent ?? nul
2180
2141
  const getImageDetail = part => part.options.openai?.imageDetail ?? "auto";
2181
2142
  const makeItemIdMetadata = itemId => Predicate.isNotUndefined(itemId) ? {
2182
2143
  itemId
2183
- } : undefined;
2144
+ } : {};
2184
2145
  const makeEncryptedContentMetadata = encryptedContent => Predicate.isNotNullish(encryptedContent) ? {
2185
2146
  encryptedContent
2186
2147
  } : undefined;
@@ -2281,8 +2242,8 @@ const getUsage = usage => {
2281
2242
  }
2282
2243
  const inputTokens = usage.input_tokens;
2283
2244
  const outputTokens = usage.output_tokens;
2284
- const cachedTokens = usage.input_tokens_details.cached_tokens;
2285
- const reasoningTokens = usage.output_tokens_details.reasoning_tokens;
2245
+ const cachedTokens = getUsageTokenDetail(usage.input_tokens_details, "cached_tokens");
2246
+ const reasoningTokens = getUsageTokenDetail(usage.output_tokens_details, "reasoning_tokens");
2286
2247
  return {
2287
2248
  inputTokens: {
2288
2249
  uncached: inputTokens - cachedTokens,
@@ -2297,6 +2258,25 @@ const getUsage = usage => {
2297
2258
  }
2298
2259
  };
2299
2260
  };
2261
+ const toServiceTier = value => {
2262
+ switch (value) {
2263
+ case "default":
2264
+ case "auto":
2265
+ case "flex":
2266
+ case "scale":
2267
+ case "priority":
2268
+ return {
2269
+ metadata: {
2270
+ openai: {
2271
+ serviceTier: value
2272
+ }
2273
+ }
2274
+ };
2275
+ default:
2276
+ return undefined;
2277
+ }
2278
+ };
2279
+ const getUsageTokenDetail = (details, key) => Predicate.hasProperty(details, key) && typeof details[key] === "number" ? details[key] : 0;
2300
2280
  const transformToolCallParams = /*#__PURE__*/Effect.fnUntraced(function* (tools, toolName, toolParams) {
2301
2281
  const tool = tools.find(tool => tool.name === toolName);
2302
2282
  if (Predicate.isUndefined(tool)) {