@opencode/ai 0.0.0-beta-19507 → 0.0.0-dev-19276

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 (114) hide show
  1. package/README.md +0 -200
  2. package/dist/protocols/anthropic-messages.d.ts +1 -24
  3. package/dist/protocols/anthropic-messages.js +12 -58
  4. package/dist/protocols/meta-messages.d.ts +0 -6
  5. package/dist/protocols/open-responses-channel.d.ts +0 -2
  6. package/dist/protocols/open-responses-channel.js +2 -2
  7. package/dist/protocols/open-responses-continuation.d.ts +3 -7
  8. package/dist/protocols/open-responses-continuation.js +7 -16
  9. package/dist/protocols/open-responses.d.ts +9 -141
  10. package/dist/protocols/open-responses.js +7 -29
  11. package/dist/provider-package.d.ts +0 -4
  12. package/dist/providers/amazon-bedrock-mantle.d.ts +62 -4
  13. package/dist/providers/amazon-bedrock-mantle.js +20 -23
  14. package/dist/providers/amazon-bedrock.js +3 -3
  15. package/dist/providers/anthropic-compatible.d.ts +2 -7
  16. package/dist/providers/anthropic-compatible.js +12 -18
  17. package/dist/providers/anthropic.d.ts +2 -7
  18. package/dist/providers/anthropic.js +9 -12
  19. package/dist/providers/azure.d.ts +2 -1
  20. package/dist/providers/azure.js +14 -14
  21. package/dist/providers/baseten.d.ts +3 -2
  22. package/dist/providers/baseten.js +6 -6
  23. package/dist/providers/cerebras.d.ts +3 -2
  24. package/dist/providers/cerebras.js +6 -6
  25. package/dist/providers/cloudflare-ai-gateway.d.ts +2 -1
  26. package/dist/providers/cloudflare-ai-gateway.js +10 -16
  27. package/dist/providers/cloudflare-workers-ai.d.ts +2 -1
  28. package/dist/providers/cloudflare-workers-ai.js +9 -15
  29. package/dist/providers/deepinfra.d.ts +3 -2
  30. package/dist/providers/deepinfra.js +6 -6
  31. package/dist/providers/deepseek.d.ts +3 -2
  32. package/dist/providers/deepseek.js +6 -6
  33. package/dist/providers/fireworks.d.ts +3 -2
  34. package/dist/providers/fireworks.js +6 -6
  35. package/dist/providers/google-vertex-chat.d.ts +3 -2
  36. package/dist/providers/google-vertex-chat.js +12 -12
  37. package/dist/providers/google-vertex-messages.d.ts +3 -8
  38. package/dist/providers/google-vertex-messages.js +12 -12
  39. package/dist/providers/google-vertex-responses.d.ts +3 -2
  40. package/dist/providers/google-vertex-responses.js +12 -12
  41. package/dist/providers/google-vertex-shared.js +3 -14
  42. package/dist/providers/google-vertex.d.ts +2 -1
  43. package/dist/providers/google-vertex.js +12 -18
  44. package/dist/providers/google.d.ts +3 -2
  45. package/dist/providers/google.js +6 -6
  46. package/dist/providers/groq.d.ts +3 -2
  47. package/dist/providers/groq.js +6 -6
  48. package/dist/providers/index.d.ts +0 -3
  49. package/dist/providers/index.js +0 -3
  50. package/dist/providers/meta.d.ts +3 -8
  51. package/dist/providers/meta.js +6 -6
  52. package/dist/providers/minimax/chat.js +6 -6
  53. package/dist/providers/minimax/responses.js +6 -6
  54. package/dist/providers/minimax.d.ts +3 -8
  55. package/dist/providers/minimax.js +6 -6
  56. package/dist/providers/mistral.d.ts +3 -2
  57. package/dist/providers/mistral.js +6 -6
  58. package/dist/providers/openai-compatible-responses.d.ts +3 -2
  59. package/dist/providers/openai-compatible-responses.js +7 -7
  60. package/dist/providers/openai-compatible.d.ts +3 -2
  61. package/dist/providers/openai-compatible.js +7 -7
  62. package/dist/providers/openai.d.ts +3 -2
  63. package/dist/providers/openai.js +9 -9
  64. package/dist/providers/openrouter.d.ts +3 -2
  65. package/dist/providers/openrouter.js +6 -6
  66. package/dist/providers/togetherai.d.ts +3 -2
  67. package/dist/providers/togetherai.js +6 -6
  68. package/dist/providers/xai.d.ts +3 -2
  69. package/dist/providers/xai.js +6 -10
  70. package/dist/providers/zai.d.ts +8 -133
  71. package/dist/providers/zai.js +0 -32
  72. package/dist/route/client.js +2 -5
  73. package/dist/route/transport/websocket.js +2 -6
  74. package/dist/schema/errors.d.ts +0 -12
  75. package/dist/schema/errors.js +0 -11
  76. package/dist/schema/options.d.ts +0 -2
  77. package/dist/schema/options.js +0 -2
  78. package/package.json +3 -3
  79. package/dist/protocols/alibaba-chat.d.ts +0 -225
  80. package/dist/protocols/alibaba-chat.js +0 -75
  81. package/dist/protocols/alibaba-messages.d.ts +0 -350
  82. package/dist/protocols/alibaba-messages.js +0 -40
  83. package/dist/protocols/alibaba-responses.d.ts +0 -255
  84. package/dist/protocols/alibaba-responses.js +0 -80
  85. package/dist/protocols/zai-chat.d.ts +0 -202
  86. package/dist/protocols/zai-chat.js +0 -49
  87. package/dist/protocols/zai-messages.d.ts +0 -344
  88. package/dist/protocols/zai-messages.js +0 -27
  89. package/dist/providers/alibaba/chat.d.ts +0 -1
  90. package/dist/providers/alibaba/chat.js +0 -1
  91. package/dist/providers/alibaba/messages.d.ts +0 -3
  92. package/dist/providers/alibaba/messages.js +0 -1
  93. package/dist/providers/alibaba/responses.d.ts +0 -3
  94. package/dist/providers/alibaba/responses.js +0 -1
  95. package/dist/providers/alibaba.d.ts +0 -711
  96. package/dist/providers/alibaba.js +0 -94
  97. package/dist/providers/moonshot/chat.d.ts +0 -1
  98. package/dist/providers/moonshot/chat.js +0 -1
  99. package/dist/providers/moonshot/messages.d.ts +0 -4
  100. package/dist/providers/moonshot/messages.js +0 -8
  101. package/dist/providers/moonshot/responses.d.ts +0 -4
  102. package/dist/providers/moonshot/responses.js +0 -8
  103. package/dist/providers/moonshot.d.ts +0 -596
  104. package/dist/providers/moonshot.js +0 -90
  105. package/dist/providers/zai/chat.d.ts +0 -1
  106. package/dist/providers/zai/chat.js +0 -1
  107. package/dist/providers/zai-coding-plan/chat.d.ts +0 -1
  108. package/dist/providers/zai-coding-plan/chat.js +0 -1
  109. package/dist/providers/zai-coding-plan/messages.d.ts +0 -4
  110. package/dist/providers/zai-coding-plan/messages.js +0 -8
  111. package/dist/providers/zai-coding-plan/responses.d.ts +0 -4
  112. package/dist/providers/zai-coding-plan/responses.js +0 -8
  113. package/dist/providers/zai-coding-plan.d.ts +0 -577
  114. package/dist/providers/zai-coding-plan.js +0 -63
@@ -1,80 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { Protocol } from "../route/protocol.js";
3
- import { OpenResponses } from "./open-responses.js";
4
- import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
5
- import { OpenResponsesOptions } from "./utils/open-responses-options.js";
6
- import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
7
- const Options = Schema.Struct({
8
- reasoningEffort: OpenResponsesOptions.Options.fields.reasoningEffort,
9
- enableThinking: Schema.optional(Schema.Boolean),
10
- store: OpenResponsesOptions.Options.fields.store,
11
- previousResponseId: Schema.optional(Schema.String),
12
- conversation: Schema.optional(Schema.String),
13
- });
14
- const NativeTool = Schema.Struct({ type: Schema.Literals(["web_search", "web_extractor", "code_interpreter"]) });
15
- const WebExtractorItem = Schema.StructWithRest(Schema.Struct({
16
- type: Schema.Literal("web_extractor_call"),
17
- id: Schema.String,
18
- urls: Schema.optional(Schema.Array(Schema.String)),
19
- goal: Schema.optional(Schema.String),
20
- }), [JsonObject]);
21
- const Body = Schema.Struct({
22
- ...OpenResponses.coreFields,
23
- input: Schema.Array(Schema.Union([OpenResponses.InputItem, WebExtractorItem])),
24
- tools: optionalArray(Schema.Union([OpenResponses.Tool, NativeTool])),
25
- enable_thinking: Options.fields.enableThinking,
26
- previous_response_id: Options.fields.previousResponseId,
27
- conversation: Options.fields.conversation,
28
- stream: Schema.Literal(true),
29
- });
30
- const adapter = {
31
- id: "alibaba-responses",
32
- name: "Alibaba Responses",
33
- nativeTool: (native) => ProviderShared.validateWith(Schema.decodeUnknownEffect(NativeTool))(native.alibaba),
34
- restoreHostedToolItem: (item) => (Schema.is(WebExtractorItem)(item) ? item : undefined),
35
- };
36
- const tools = {
37
- web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
38
- code_interpreter_call: { name: "code_interpreter", input: (item) => ({ code: item.code }) },
39
- };
40
- export const protocol = Protocol.make({
41
- id: adapter.id,
42
- body: {
43
- schema: Body,
44
- from: Effect.fn("AlibabaResponses.fromRequest")(function* (req) {
45
- const opts = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(req.providerOptions ?? {});
46
- const body = yield* OpenResponses.fromRequestWithAdapter(req, adapter);
47
- const choice = body.tool_choice;
48
- return yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Body))({
49
- ...body,
50
- enable_thinking: opts.enableThinking,
51
- previous_response_id: opts.previousResponseId,
52
- conversation: opts.conversation,
53
- // Model Studio expresses named selection through allowed_tools.
54
- tool_choice: typeof choice === "object" && choice.type === "function"
55
- ? { type: "allowed_tools", mode: "required", tools: [choice] }
56
- : choice,
57
- });
58
- }),
59
- },
60
- stream: {
61
- event: OpenResponses.protocol.stream.event,
62
- initial: (req) => OpenResponses.initial(req, adapter),
63
- step: (state, input) => Effect.gen(function* () {
64
- const event = OpenResponses.normalize(state, input);
65
- if (event.type !== "response.output_item.done" || !event.item)
66
- return yield* OpenResponses.step(state, event);
67
- if (event.item.type === "web_extractor_call") {
68
- const item = yield* Schema.decodeUnknownEffect(WebExtractorItem)(event.item).pipe(Effect.mapError((cause) => ProviderShared.eventError(adapter.id, "Alibaba returned an invalid web extraction item", ProviderShared.encodeJson(event), cause)));
69
- return yield* ResponsesHostedTools.onDone(state, item, {
70
- web_extractor_call: { name: "web_extractor", input: () => ({ urls: item.urls, goal: item.goal }) },
71
- });
72
- }
73
- if (ResponsesHostedTools.isItem(event.item, tools))
74
- return yield* ResponsesHostedTools.onDone(state, event.item, tools);
75
- return yield* OpenResponses.step(state, event);
76
- }),
77
- terminal: OpenResponses.terminal,
78
- },
79
- });
80
- export * as AlibabaResponses from "./alibaba-responses.js";
@@ -1,202 +0,0 @@
1
- import { Protocol } from "../route/protocol.js";
2
- import { OpenAIChat } from "./openai-chat.js";
3
- export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | (string & {});
4
- export type OptionsInput = {
5
- readonly reasoningEffort?: ReasoningEffort;
6
- readonly thinking?: {
7
- readonly type?: "enabled" | "disabled" | (string & {});
8
- /** False retains historical reasoning; omission preserves the endpoint's default. */
9
- readonly clear_thinking?: boolean;
10
- };
11
- readonly toolStream?: boolean;
12
- readonly doSample?: boolean;
13
- readonly responseFormat?: {
14
- readonly type: "text" | "json_object" | (string & {});
15
- };
16
- readonly requestID?: string;
17
- readonly userID?: string;
18
- };
19
- export declare const compatibility: {
20
- maxTokensField: "max_tokens";
21
- supportsStore: false;
22
- supportsStrictMode: false;
23
- reasoningField: string;
24
- zaiToolStream: false;
25
- };
26
- export declare const protocol: Protocol<{
27
- readonly model: string;
28
- readonly messages: readonly ({
29
- readonly role: "system";
30
- readonly content: string | readonly ({
31
- readonly type: "text";
32
- readonly text: string;
33
- readonly cache_control?: {
34
- readonly type: "ephemeral";
35
- readonly ttl?: string | undefined;
36
- } | undefined;
37
- } | {
38
- readonly type: "image_url";
39
- readonly image_url: {
40
- readonly url: string;
41
- };
42
- })[];
43
- } | {
44
- readonly role: "user";
45
- readonly content: string | readonly ({
46
- readonly type: "text";
47
- readonly text: string;
48
- readonly cache_control?: {
49
- readonly type: "ephemeral";
50
- readonly ttl?: string | undefined;
51
- } | undefined;
52
- } | {
53
- readonly type: "image_url";
54
- readonly image_url: {
55
- readonly url: string;
56
- };
57
- })[];
58
- } | {
59
- readonly [x: string]: unknown;
60
- readonly content: string | null;
61
- readonly role: "assistant";
62
- readonly reasoning?: string | undefined;
63
- readonly reasoning_content?: string | undefined;
64
- readonly reasoning_text?: string | undefined;
65
- readonly cache_control?: {
66
- readonly type: "ephemeral";
67
- readonly ttl?: string | undefined;
68
- } | undefined;
69
- readonly tool_calls?: readonly {
70
- readonly id: string;
71
- readonly type: "function";
72
- readonly function: {
73
- readonly name: string;
74
- readonly arguments: string;
75
- };
76
- }[] | undefined;
77
- readonly reasoning_details?: unknown;
78
- } | {
79
- readonly content: string;
80
- readonly role: "tool";
81
- readonly tool_call_id: string;
82
- readonly cache_control?: {
83
- readonly type: "ephemeral";
84
- readonly ttl?: string | undefined;
85
- } | undefined;
86
- })[];
87
- readonly stream: true;
88
- readonly max_completion_tokens?: number | undefined;
89
- readonly max_tokens?: number | undefined;
90
- readonly tools?: readonly {
91
- readonly function: {
92
- readonly description: string;
93
- readonly name: string;
94
- readonly parameters: {
95
- readonly [x: string]: unknown;
96
- };
97
- readonly strict?: boolean | undefined;
98
- };
99
- readonly type: "function";
100
- readonly cache_control?: {
101
- readonly type: "ephemeral";
102
- readonly ttl?: string | undefined;
103
- } | undefined;
104
- }[] | undefined;
105
- readonly stop?: readonly string[] | undefined;
106
- readonly temperature?: number | undefined;
107
- readonly seed?: number | undefined;
108
- readonly thinking?: {
109
- readonly type?: string | undefined;
110
- readonly clear_thinking?: boolean | undefined;
111
- } | undefined;
112
- readonly user_id?: string | undefined;
113
- readonly tool_choice?: "required" | "auto" | "none" | {
114
- readonly type: "function";
115
- readonly function: {
116
- readonly name: string;
117
- };
118
- } | undefined;
119
- readonly top_p?: number | undefined;
120
- readonly frequency_penalty?: number | undefined;
121
- readonly presence_penalty?: number | undefined;
122
- readonly prompt_cache_key?: string | undefined;
123
- readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
124
- readonly store?: boolean | undefined;
125
- readonly stream_options?: {
126
- readonly include_usage: boolean;
127
- } | undefined;
128
- readonly tool_stream?: boolean | undefined;
129
- readonly response_format?: {
130
- readonly type: string;
131
- } | undefined;
132
- readonly do_sample?: boolean | undefined;
133
- readonly request_id?: string | undefined;
134
- }, string, "[DONE]" | {
135
- readonly [x: string]: unknown;
136
- readonly error?: {
137
- readonly [x: string]: unknown;
138
- readonly message: string;
139
- readonly code?: string | number | null | undefined;
140
- } | null | undefined;
141
- readonly usage?: {
142
- readonly [x: string]: unknown;
143
- readonly cached_tokens?: number | null | undefined;
144
- readonly prompt_tokens?: number | null | undefined;
145
- readonly completion_tokens?: number | null | undefined;
146
- readonly total_tokens?: number | null | undefined;
147
- readonly prompt_tokens_details?: {
148
- readonly [x: string]: unknown;
149
- readonly cached_tokens?: number | null | undefined;
150
- readonly cache_write_tokens?: number | null | undefined;
151
- } | null | undefined;
152
- readonly prompt_cache_hit_tokens?: number | null | undefined;
153
- readonly completion_tokens_details?: {
154
- readonly [x: string]: unknown;
155
- readonly reasoning_tokens?: number | null | undefined;
156
- readonly accepted_prediction_tokens?: number | null | undefined;
157
- readonly rejected_prediction_tokens?: number | null | undefined;
158
- } | null | undefined;
159
- } | null | undefined;
160
- readonly choices?: readonly {
161
- readonly [x: string]: unknown;
162
- readonly delta?: {
163
- readonly [x: string]: unknown;
164
- readonly reasoning?: string | null | undefined;
165
- readonly reasoning_content?: string | null | undefined;
166
- readonly reasoning_text?: string | null | undefined;
167
- readonly content?: string | null | undefined;
168
- readonly refusal?: string | null | undefined;
169
- readonly tool_calls?: readonly {
170
- readonly function?: {
171
- readonly name?: string | null | undefined;
172
- readonly arguments?: string | null | undefined;
173
- } | null | undefined;
174
- readonly id?: string | null | undefined;
175
- readonly index?: number | null | undefined;
176
- }[] | null | undefined;
177
- readonly reasoning_details?: unknown;
178
- } | null | undefined;
179
- readonly usage?: {
180
- readonly [x: string]: unknown;
181
- readonly cached_tokens?: number | null | undefined;
182
- readonly prompt_tokens?: number | null | undefined;
183
- readonly completion_tokens?: number | null | undefined;
184
- readonly total_tokens?: number | null | undefined;
185
- readonly prompt_tokens_details?: {
186
- readonly [x: string]: unknown;
187
- readonly cached_tokens?: number | null | undefined;
188
- readonly cache_write_tokens?: number | null | undefined;
189
- } | null | undefined;
190
- readonly prompt_cache_hit_tokens?: number | null | undefined;
191
- readonly completion_tokens_details?: {
192
- readonly [x: string]: unknown;
193
- readonly reasoning_tokens?: number | null | undefined;
194
- readonly accepted_prediction_tokens?: number | null | undefined;
195
- readonly rejected_prediction_tokens?: number | null | undefined;
196
- } | null | undefined;
197
- } | null | undefined;
198
- readonly finish_reason?: string | null | undefined;
199
- readonly native_finish_reason?: string | null | undefined;
200
- }[] | null | undefined;
201
- }, OpenAIChat.ParserState>;
202
- export * as ZAIChat from "./zai-chat.js";
@@ -1,49 +0,0 @@
1
- import { Effect, Schema } from "effect";
2
- import { Protocol } from "../route/protocol.js";
3
- import { OpenAIChat } from "./openai-chat.js";
4
- import { ProviderShared } from "./shared.js";
5
- const Options = Schema.Struct({
6
- reasoningEffort: Schema.optional(Schema.String),
7
- thinking: Schema.optional(Schema.Struct({ type: Schema.optional(Schema.String), clear_thinking: Schema.optional(Schema.Boolean) })),
8
- toolStream: Schema.optional(Schema.Boolean),
9
- doSample: Schema.optional(Schema.Boolean),
10
- responseFormat: Schema.optional(Schema.Struct({ type: Schema.String })),
11
- requestID: Schema.optional(Schema.String),
12
- userID: Schema.optional(Schema.String),
13
- });
14
- const Body = Schema.Struct({
15
- ...OpenAIChat.bodyFields,
16
- thinking: Options.fields.thinking,
17
- do_sample: Options.fields.doSample,
18
- response_format: Options.fields.responseFormat,
19
- request_id: Options.fields.requestID,
20
- user_id: Options.fields.userID,
21
- });
22
- const fromRequest = Effect.fn("ZAIChat.fromRequest")(function* (request) {
23
- const options = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(request.providerOptions ?? {});
24
- const body = yield* OpenAIChat.protocol.body.from(request);
25
- return {
26
- ...body,
27
- thinking: options.thinking,
28
- // Tool streaming was introduced in GLM-4.6; older models must not receive the opt-in.
29
- tool_stream: options.toolStream ??
30
- (body.tools?.length && /^glm-(?:4\.[67]|5(?:[.-]|$))/i.test(request.model.id) ? true : undefined),
31
- do_sample: options.doSample,
32
- response_format: options.responseFormat,
33
- request_id: options.requestID,
34
- user_id: options.userID,
35
- };
36
- });
37
- export const compatibility = {
38
- maxTokensField: "max_tokens",
39
- supportsStore: false,
40
- supportsStrictMode: false,
41
- reasoningField: "reasoning_content",
42
- zaiToolStream: false,
43
- };
44
- export const protocol = Protocol.make({
45
- id: "zai-chat",
46
- body: { schema: Body, from: fromRequest },
47
- stream: OpenAIChat.protocol.stream,
48
- });
49
- export * as ZAIChat from "./zai-chat.js";
@@ -1,344 +0,0 @@
1
- import { Protocol } from "../route/protocol.js";
2
- import type { ZAIChat } from "./zai-chat.js";
3
- export type OptionsInput = {
4
- readonly effort?: ZAIChat.ReasoningEffort;
5
- readonly thinking?: {
6
- readonly type: "enabled" | "adaptive" | "disabled" | (string & {});
7
- };
8
- };
9
- export declare const protocol: Protocol<{
10
- readonly max_tokens: number;
11
- readonly model: string;
12
- readonly messages: readonly ({
13
- readonly role: "user";
14
- readonly content: readonly ({
15
- readonly type: "text";
16
- readonly text: string;
17
- readonly cache_control?: {
18
- readonly type: "ephemeral";
19
- readonly ttl?: "1h" | "5m" | undefined;
20
- } | undefined;
21
- } | {
22
- readonly type: "image";
23
- readonly source: {
24
- readonly type: "base64";
25
- readonly media_type: string;
26
- readonly data: string;
27
- } | {
28
- readonly type: "url";
29
- readonly url: string;
30
- } | {
31
- readonly type: "file";
32
- readonly file_id: string;
33
- };
34
- readonly cache_control?: {
35
- readonly type: "ephemeral";
36
- readonly ttl?: "1h" | "5m" | undefined;
37
- } | undefined;
38
- readonly transformations?: {
39
- readonly oversized_image?: "error" | "downsize" | undefined;
40
- } | undefined;
41
- } | {
42
- readonly type: "document";
43
- readonly source: {
44
- readonly type: "base64";
45
- readonly media_type: "application/pdf";
46
- readonly data: string;
47
- } | {
48
- readonly type: "text";
49
- readonly media_type: "text/plain";
50
- readonly data: string;
51
- } | {
52
- readonly type: "url";
53
- readonly url: string;
54
- } | {
55
- readonly type: "file";
56
- readonly file_id: string;
57
- };
58
- readonly title?: string | undefined;
59
- readonly context?: string | undefined;
60
- readonly cache_control?: {
61
- readonly type: "ephemeral";
62
- readonly ttl?: "1h" | "5m" | undefined;
63
- } | undefined;
64
- readonly citations?: {
65
- readonly enabled: boolean;
66
- } | undefined;
67
- } | {
68
- readonly type: "tool_result";
69
- readonly content: string | readonly ({
70
- readonly type: "text";
71
- readonly text: string;
72
- readonly cache_control?: {
73
- readonly type: "ephemeral";
74
- readonly ttl?: "1h" | "5m" | undefined;
75
- } | undefined;
76
- } | {
77
- readonly type: "image";
78
- readonly source: {
79
- readonly type: "base64";
80
- readonly media_type: string;
81
- readonly data: string;
82
- } | {
83
- readonly type: "url";
84
- readonly url: string;
85
- } | {
86
- readonly type: "file";
87
- readonly file_id: string;
88
- };
89
- readonly cache_control?: {
90
- readonly type: "ephemeral";
91
- readonly ttl?: "1h" | "5m" | undefined;
92
- } | undefined;
93
- readonly transformations?: {
94
- readonly oversized_image?: "error" | "downsize" | undefined;
95
- } | undefined;
96
- } | {
97
- readonly type: "document";
98
- readonly source: {
99
- readonly type: "base64";
100
- readonly media_type: "application/pdf";
101
- readonly data: string;
102
- } | {
103
- readonly type: "text";
104
- readonly media_type: "text/plain";
105
- readonly data: string;
106
- } | {
107
- readonly type: "url";
108
- readonly url: string;
109
- } | {
110
- readonly type: "file";
111
- readonly file_id: string;
112
- };
113
- readonly title?: string | undefined;
114
- readonly context?: string | undefined;
115
- readonly cache_control?: {
116
- readonly type: "ephemeral";
117
- readonly ttl?: "1h" | "5m" | undefined;
118
- } | undefined;
119
- readonly citations?: {
120
- readonly enabled: boolean;
121
- } | undefined;
122
- })[];
123
- readonly tool_use_id: string;
124
- readonly cache_control?: {
125
- readonly type: "ephemeral";
126
- readonly ttl?: "1h" | "5m" | undefined;
127
- } | undefined;
128
- readonly is_error?: boolean | undefined;
129
- })[];
130
- } | {
131
- readonly role: "assistant";
132
- readonly content: readonly ({
133
- readonly type: "text";
134
- readonly text: string;
135
- readonly cache_control?: {
136
- readonly type: "ephemeral";
137
- readonly ttl?: "1h" | "5m" | undefined;
138
- } | undefined;
139
- } | {
140
- readonly id: string;
141
- readonly type: "tool_use";
142
- readonly name: string;
143
- readonly input: unknown;
144
- readonly cache_control?: {
145
- readonly type: "ephemeral";
146
- readonly ttl?: "1h" | "5m" | undefined;
147
- } | undefined;
148
- } | {
149
- readonly id: string;
150
- readonly type: "server_tool_use";
151
- readonly name: string;
152
- readonly input: unknown;
153
- readonly cache_control?: {
154
- readonly type: "ephemeral";
155
- readonly ttl?: "1h" | "5m" | undefined;
156
- } | undefined;
157
- } | {
158
- readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
159
- readonly content: unknown;
160
- readonly tool_use_id: string;
161
- readonly cache_control?: {
162
- readonly type: "ephemeral";
163
- readonly ttl?: "1h" | "5m" | undefined;
164
- } | undefined;
165
- } | {
166
- readonly type: "thinking";
167
- readonly thinking: string;
168
- readonly signature: string;
169
- readonly cache_control?: {
170
- readonly type: "ephemeral";
171
- readonly ttl?: "1h" | "5m" | undefined;
172
- } | undefined;
173
- } | {
174
- readonly data: string;
175
- readonly type: "redacted_thinking";
176
- readonly cache_control?: {
177
- readonly type: "ephemeral";
178
- readonly ttl?: "1h" | "5m" | undefined;
179
- } | undefined;
180
- } | {
181
- readonly type: "compaction";
182
- readonly content: string | null;
183
- })[];
184
- } | {
185
- readonly role: "system";
186
- readonly content: readonly {
187
- readonly type: "text";
188
- readonly text: string;
189
- readonly cache_control?: {
190
- readonly type: "ephemeral";
191
- readonly ttl?: "1h" | "5m" | undefined;
192
- } | undefined;
193
- }[];
194
- })[];
195
- readonly stream: true;
196
- readonly metadata?: {
197
- readonly user_id?: string | null | undefined;
198
- } | undefined;
199
- readonly tools?: readonly {
200
- readonly description: string;
201
- readonly name: string;
202
- readonly input_schema: {
203
- readonly [x: string]: unknown;
204
- };
205
- readonly cache_control?: {
206
- readonly type: "ephemeral";
207
- readonly ttl?: "1h" | "5m" | undefined;
208
- } | undefined;
209
- }[] | undefined;
210
- readonly system?: readonly {
211
- readonly type: "text";
212
- readonly text: string;
213
- readonly cache_control?: {
214
- readonly type: "ephemeral";
215
- readonly ttl?: "1h" | "5m" | undefined;
216
- } | undefined;
217
- }[] | undefined;
218
- readonly temperature?: number | undefined;
219
- readonly thinking?: {
220
- readonly type: string;
221
- } | undefined;
222
- readonly service_tier?: "auto" | "standard_only" | undefined;
223
- readonly container?: string | {
224
- readonly id?: string | null | undefined;
225
- readonly skills?: readonly {
226
- readonly [x: string]: unknown;
227
- }[] | null | undefined;
228
- } | null | undefined;
229
- readonly inference_geo?: string | null | undefined;
230
- readonly cache_control?: {
231
- readonly type: "ephemeral";
232
- readonly ttl?: "1h" | "5m" | undefined;
233
- } | undefined;
234
- readonly output_config?: {
235
- readonly format?: {
236
- readonly type: "json_schema";
237
- readonly schema: {
238
- readonly [x: string]: unknown;
239
- };
240
- } | null | undefined;
241
- readonly effort?: string | undefined;
242
- } | undefined;
243
- readonly context_management?: {
244
- readonly edits: readonly {
245
- readonly type: "compact_20260112";
246
- readonly instructions?: string | undefined;
247
- readonly trigger?: {
248
- readonly type: "input_tokens";
249
- readonly value: number;
250
- } | undefined;
251
- readonly pause_after_compaction?: boolean | undefined;
252
- }[];
253
- } | undefined;
254
- readonly tool_choice?: {
255
- readonly type: "auto" | "none" | "any";
256
- readonly disable_parallel_tool_use?: boolean | undefined;
257
- } | {
258
- readonly type: "tool";
259
- readonly name: string;
260
- readonly disable_parallel_tool_use?: boolean | undefined;
261
- } | undefined;
262
- readonly top_p?: number | undefined;
263
- readonly top_k?: number | undefined;
264
- readonly stop_sequences?: readonly string[] | undefined;
265
- }, string, {
266
- readonly type: string;
267
- readonly message?: {
268
- readonly usage?: {
269
- readonly [x: string]: unknown;
270
- readonly input_tokens?: number | null | undefined;
271
- readonly server_tool_use?: {
272
- readonly [x: string]: unknown;
273
- readonly web_search_requests?: number | undefined;
274
- } | null | undefined;
275
- readonly output_tokens?: number | undefined;
276
- readonly cache_creation_input_tokens?: number | null | undefined;
277
- readonly cache_read_input_tokens?: number | null | undefined;
278
- readonly output_tokens_details?: {
279
- readonly [x: string]: unknown;
280
- readonly thinking_tokens?: number | undefined;
281
- } | null | undefined;
282
- readonly iterations?: readonly {
283
- readonly [x: string]: unknown;
284
- readonly input_tokens?: number | null | undefined;
285
- readonly server_tool_use?: {
286
- readonly [x: string]: unknown;
287
- readonly web_search_requests?: number | undefined;
288
- } | null | undefined;
289
- readonly output_tokens?: number | undefined;
290
- readonly cache_creation_input_tokens?: number | null | undefined;
291
- readonly cache_read_input_tokens?: number | null | undefined;
292
- readonly output_tokens_details?: {
293
- readonly [x: string]: unknown;
294
- readonly thinking_tokens?: number | undefined;
295
- } | null | undefined;
296
- }[] | undefined;
297
- } | undefined;
298
- } | undefined;
299
- readonly error?: {
300
- readonly type?: string | undefined;
301
- readonly message?: string | undefined;
302
- } | undefined;
303
- readonly delta?: unknown;
304
- readonly index?: number | undefined;
305
- readonly usage?: {
306
- readonly [x: string]: unknown;
307
- readonly input_tokens?: number | null | undefined;
308
- readonly server_tool_use?: {
309
- readonly [x: string]: unknown;
310
- readonly web_search_requests?: number | undefined;
311
- } | null | undefined;
312
- readonly output_tokens?: number | undefined;
313
- readonly cache_creation_input_tokens?: number | null | undefined;
314
- readonly cache_read_input_tokens?: number | null | undefined;
315
- readonly output_tokens_details?: {
316
- readonly [x: string]: unknown;
317
- readonly thinking_tokens?: number | undefined;
318
- } | null | undefined;
319
- readonly iterations?: readonly {
320
- readonly [x: string]: unknown;
321
- readonly input_tokens?: number | null | undefined;
322
- readonly server_tool_use?: {
323
- readonly [x: string]: unknown;
324
- readonly web_search_requests?: number | undefined;
325
- } | null | undefined;
326
- readonly output_tokens?: number | undefined;
327
- readonly cache_creation_input_tokens?: number | null | undefined;
328
- readonly cache_read_input_tokens?: number | null | undefined;
329
- readonly output_tokens_details?: {
330
- readonly [x: string]: unknown;
331
- readonly thinking_tokens?: number | undefined;
332
- } | null | undefined;
333
- }[] | undefined;
334
- } | undefined;
335
- readonly content_block?: unknown;
336
- }, {
337
- provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
338
- compactions: {};
339
- providerMetadataKey: string;
340
- tools: Partial<Record<number, import("./utils/tool-stream.js").PendingTool>>;
341
- reasoningSignatures: {};
342
- lifecycle: import("./utils/lifecycle.js").State;
343
- }>;
344
- export * as ZAIMessages from "./zai-messages.js";