@effect/ai-openai 4.0.0-beta.51 → 4.0.0-beta.53
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.
- package/dist/OpenAiClient.d.ts +9 -9
- package/dist/OpenAiClient.d.ts.map +1 -1
- package/dist/OpenAiClient.js +27 -32
- package/dist/OpenAiClient.js.map +1 -1
- package/dist/OpenAiClientGenerated.d.ts +91 -0
- package/dist/OpenAiClientGenerated.d.ts.map +1 -0
- package/dist/OpenAiClientGenerated.js +84 -0
- package/dist/OpenAiClientGenerated.js.map +1 -0
- package/dist/OpenAiEmbeddingModel.d.ts.map +1 -1
- package/dist/OpenAiEmbeddingModel.js +3 -0
- package/dist/OpenAiEmbeddingModel.js.map +1 -1
- package/dist/OpenAiLanguageModel.d.ts +28 -47
- package/dist/OpenAiLanguageModel.d.ts.map +1 -1
- package/dist/OpenAiLanguageModel.js +56 -76
- package/dist/OpenAiLanguageModel.js.map +1 -1
- package/dist/OpenAiSchema.d.ts +1925 -0
- package/dist/OpenAiSchema.d.ts.map +1 -0
- package/dist/OpenAiSchema.js +537 -0
- package/dist/OpenAiSchema.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/OpenAiClient.ts +90 -59
- package/src/OpenAiClientGenerated.ts +202 -0
- package/src/OpenAiEmbeddingModel.ts +6 -3
- package/src/OpenAiLanguageModel.ts +148 -63
- package/src/OpenAiSchema.ts +878 -0
- package/src/index.ts +12 -0
|
@@ -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,26 @@ 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?: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
41
|
-
readonly
|
|
42
|
-
readonly
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
readonly
|
|
46
|
-
readonly
|
|
47
|
-
readonly
|
|
48
|
-
|
|
49
|
-
} | null;
|
|
50
|
-
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;
|
|
56
|
-
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
|
-
readonly store?: boolean | null;
|
|
62
|
-
readonly previous_response_id?: string | null;
|
|
63
|
-
readonly max_tool_calls?: number | null;
|
|
64
|
-
readonly context_management?: readonly {
|
|
65
|
-
readonly type: string;
|
|
66
|
-
readonly compact_threshold?: number | null;
|
|
67
|
-
}[] | null;
|
|
29
|
+
readonly metadata?: {
|
|
30
|
+
readonly [x: string]: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
readonly top_logprobs?: number | undefined;
|
|
33
|
+
readonly user?: string | undefined;
|
|
34
|
+
readonly model?: string | undefined;
|
|
35
|
+
readonly instructions?: string | undefined;
|
|
36
|
+
readonly temperature?: number | undefined;
|
|
37
|
+
readonly top_p?: number | undefined;
|
|
38
|
+
readonly background?: boolean | undefined;
|
|
39
|
+
readonly conversation?: string | undefined;
|
|
40
|
+
readonly modalities?: readonly ("text" | "audio")[] | undefined;
|
|
41
|
+
readonly service_tier?: string | undefined;
|
|
42
|
+
readonly seed?: number | undefined;
|
|
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")[] | undefined;
|
|
44
|
+
readonly max_output_tokens?: number | undefined;
|
|
45
|
+
readonly truncation?: "auto" | "disabled" | undefined;
|
|
46
|
+
readonly store?: boolean | undefined;
|
|
47
|
+
readonly previous_response_id?: string | undefined;
|
|
48
|
+
readonly max_tool_calls?: number | undefined;
|
|
68
49
|
readonly fileIdPrefixes?: readonly string[] | undefined;
|
|
69
50
|
readonly text?: {
|
|
70
51
|
/**
|
|
@@ -124,7 +105,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
124
105
|
/**
|
|
125
106
|
* The status of item.
|
|
126
107
|
*/
|
|
127
|
-
readonly status?: typeof
|
|
108
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
128
109
|
/**
|
|
129
110
|
* The ID of the approval request.
|
|
130
111
|
*/
|
|
@@ -140,7 +121,7 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
140
121
|
/**
|
|
141
122
|
* The status of item.
|
|
142
123
|
*/
|
|
143
|
-
readonly status?: typeof
|
|
124
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
144
125
|
/**
|
|
145
126
|
* The ID of the approval request.
|
|
146
127
|
*/
|
|
@@ -156,11 +137,11 @@ declare module "effect/unstable/ai/Prompt" {
|
|
|
156
137
|
/**
|
|
157
138
|
* The status of item.
|
|
158
139
|
*/
|
|
159
|
-
readonly status?: typeof
|
|
140
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
160
141
|
/**
|
|
161
142
|
* A list of annotations that apply to the output text.
|
|
162
143
|
*/
|
|
163
|
-
readonly annotations?: ReadonlyArray<typeof
|
|
144
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
164
145
|
} | null;
|
|
165
146
|
}
|
|
166
147
|
}
|
|
@@ -177,11 +158,11 @@ declare module "effect/unstable/ai/Response" {
|
|
|
177
158
|
/**
|
|
178
159
|
* The status of item.
|
|
179
160
|
*/
|
|
180
|
-
readonly status?: typeof
|
|
161
|
+
readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
|
|
181
162
|
/**
|
|
182
163
|
* The text content part annotations.
|
|
183
164
|
*/
|
|
184
|
-
readonly annotations?: ReadonlyArray<typeof
|
|
165
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
185
166
|
};
|
|
186
167
|
}
|
|
187
168
|
interface TextStartPartMetadata extends ProviderMetadata {
|
|
@@ -192,7 +173,7 @@ declare module "effect/unstable/ai/Response" {
|
|
|
192
173
|
interface TextEndPartMetadata extends ProviderMetadata {
|
|
193
174
|
readonly openai?: {
|
|
194
175
|
readonly itemId?: string | null;
|
|
195
|
-
readonly annotations?: ReadonlyArray<typeof
|
|
176
|
+
readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
|
|
196
177
|
} | null;
|
|
197
178
|
}
|
|
198
179
|
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;AAIrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAOvC,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;
|
|
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;AAIrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAOvC,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AASnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAItD,QAAA,MAAM,gBAAgB,8UAAyC,CAAA;AAC/D,QAAA,MAAM,cAAc,69CAAsC,CAAA;AAE1D;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,gBAAgB,CAAC,OAAO,GAAG,OAAO,cAAc,CAAC,OAAO,CAAA;AAEnF;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;;;;;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AAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;CAwBhH,CAAA"}
|
|
@@ -109,21 +109,15 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* ({
|
|
|
109
109
|
const request = {
|
|
110
110
|
...config,
|
|
111
111
|
input: messages,
|
|
112
|
-
include: include.size > 0 ? Array.from(include) :
|
|
112
|
+
include: include.size > 0 ? Array.from(include) : undefined,
|
|
113
113
|
text: {
|
|
114
|
-
verbosity: config.text?.verbosity ??
|
|
114
|
+
verbosity: config.text?.verbosity ?? undefined,
|
|
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
|
-
|
|
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
|
-
} :
|
|
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
|
|
2285
|
-
const reasoningTokens = usage.output_tokens_details
|
|
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)) {
|