190proof 1.0.96 → 1.0.97
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/index.d.mts +113 -6
- package/dist/index.d.ts +113 -6
- package/dist/index.js +259 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +259 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -55,12 +55,94 @@ declare enum GeminiModel {
|
|
|
55
55
|
GEMINI_3_FLASH_PREVIEW = "gemini-3-flash-preview",
|
|
56
56
|
GEMINI_3_1_FLASH_LITE_PREVIEW = "gemini-3.1-flash-lite-preview"
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A single conversation turn passed to `callWithRetries`. The SDK serializes
|
|
60
|
+
* these into each provider's native message format.
|
|
61
|
+
*
|
|
62
|
+
* ## Multi-turn tool calls
|
|
63
|
+
* To continue after the model calls a tool, append the model's own assistant
|
|
64
|
+
* turn and then the tool result, then call again:
|
|
65
|
+
*
|
|
66
|
+
* 1. Read the assistant turn off the response: `function_calls` (each with an
|
|
67
|
+
* `id`) and — for reasoning models — `reasoning` / `reasoningDetails`.
|
|
68
|
+
* 2. Push back an `assistant` message carrying those same `functionCalls` (and,
|
|
69
|
+
* to keep the model's chain-of-thought, the captured reasoning fields).
|
|
70
|
+
* 3. Push back one `role: "tool"` message whose `toolResults` answer each call
|
|
71
|
+
* by `toolCallId`.
|
|
72
|
+
*
|
|
73
|
+
* The SDK is a pure transport: it does NOT echo reasoning or pair results for
|
|
74
|
+
* you — it serializes exactly what you put here. Every tool/reasoning field is
|
|
75
|
+
* optional, so a plain `{ role, content }` message behaves as before.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // turn 1 — model asks for the weather
|
|
79
|
+
* const a = await callWithRetries(id, { model, messages, functions });
|
|
80
|
+
* // a.function_calls -> [{ id: "call_abc", name: "get_weather", arguments: { city: "Tokyo" } }]
|
|
81
|
+
*
|
|
82
|
+
* // turn 2 — feed the call + its result back
|
|
83
|
+
* const next = await callWithRetries(id, { model, functions, messages: [
|
|
84
|
+
* ...messages,
|
|
85
|
+
* { role: "assistant", content: a.content ?? "", functionCalls: a.function_calls,
|
|
86
|
+
* reasoning: a.reasoning, reasoningDetails: a.reasoningDetails },
|
|
87
|
+
* { role: "tool", content: "", toolResults: [
|
|
88
|
+
* { toolCallId: "call_abc", name: "get_weather", content: '{"tempC":22}' } ] },
|
|
89
|
+
* ]});
|
|
90
|
+
*/
|
|
58
91
|
interface GenericMessage {
|
|
59
|
-
|
|
92
|
+
/**
|
|
93
|
+
* `"tool"` carries tool results (see `toolResults`) back to the model and
|
|
94
|
+
* must immediately follow the `assistant` turn that made the matching calls.
|
|
95
|
+
*/
|
|
96
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
97
|
+
/** Plain-text content. Use `""` for a tool-call-only or tool-result turn. */
|
|
60
98
|
content: string;
|
|
61
99
|
timestamp?: string;
|
|
62
100
|
files?: File[];
|
|
101
|
+
/**
|
|
102
|
+
* Tool calls the model made on an `assistant` turn. Pass back the `id`s you
|
|
103
|
+
* received in `ParsedResponseMessage.function_calls` so the provider can pair
|
|
104
|
+
* them with the `toolResults` that follow.
|
|
105
|
+
*/
|
|
63
106
|
functionCalls?: FunctionCall[];
|
|
107
|
+
/**
|
|
108
|
+
* Tool outputs on a `role: "tool"` message — one entry per call (parallel
|
|
109
|
+
* calls produce several). Each `toolCallId` must match a `FunctionCall.id`
|
|
110
|
+
* from the preceding assistant turn.
|
|
111
|
+
*/
|
|
112
|
+
toolResults?: ToolResult[];
|
|
113
|
+
/**
|
|
114
|
+
* Optional reasoning string to echo back on an `assistant` turn (e.g.
|
|
115
|
+
* OpenRouter/DeepSeek `reasoning`). Round-tripping it keeps the model's
|
|
116
|
+
* chain-of-thought across tool calls; some thinking models (DeepSeek V4)
|
|
117
|
+
* require it to avoid a 400 on the next turn.
|
|
118
|
+
*/
|
|
119
|
+
reasoning?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Optional structured reasoning to echo back on an `assistant` turn
|
|
122
|
+
* (OpenRouter `reasoning_details`, or Anthropic `thinking` /
|
|
123
|
+
* `redacted_thinking` blocks captured in
|
|
124
|
+
* `ParsedResponseMessage.reasoningDetails`). Preserves the signatures /
|
|
125
|
+
* encrypted payloads that providers validate on round-trip.
|
|
126
|
+
*/
|
|
127
|
+
reasoningDetails?: any;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The result of executing one tool call, fed back to the model on a
|
|
131
|
+
* `role: "tool"` message. The SDK maps this to each provider's native shape:
|
|
132
|
+
* OpenAI/Groq/OpenRouter `{ role: "tool", tool_call_id, content }`, Anthropic a
|
|
133
|
+
* `tool_result` block, Google a `functionResponse` part.
|
|
134
|
+
*/
|
|
135
|
+
interface ToolResult {
|
|
136
|
+
/** The `id` of the `FunctionCall` this answers (from the prior assistant turn). */
|
|
137
|
+
toolCallId: string;
|
|
138
|
+
/**
|
|
139
|
+
* The tool/function name. Required by Anthropic and Google on round-trip; the
|
|
140
|
+
* SDK falls back to the matching call's name when omitted, but supplying it is
|
|
141
|
+
* recommended.
|
|
142
|
+
*/
|
|
143
|
+
name?: string;
|
|
144
|
+
/** The tool output, serialized to a string (JSON or plain text). */
|
|
145
|
+
content: string;
|
|
64
146
|
}
|
|
65
147
|
interface File {
|
|
66
148
|
mimeType: string;
|
|
@@ -70,9 +152,24 @@ interface File {
|
|
|
70
152
|
interface ParsedResponseMessage {
|
|
71
153
|
role: "assistant";
|
|
72
154
|
content: string | null;
|
|
155
|
+
/** First of `function_calls` (backward-compat); carries `id` when the provider returns one. */
|
|
73
156
|
function_call: FunctionCall | null;
|
|
157
|
+
/** All tool calls the model made this turn, each with an `id` for round-tripping. */
|
|
74
158
|
function_calls: FunctionCall[];
|
|
75
159
|
files: File[];
|
|
160
|
+
/**
|
|
161
|
+
* Reasoning string from reasoning models (OpenRouter/DeepSeek `reasoning`).
|
|
162
|
+
* Echo back via `GenericMessage.reasoning` to preserve chain-of-thought across
|
|
163
|
+
* tool calls. Undefined when the model/provider returns none.
|
|
164
|
+
*/
|
|
165
|
+
reasoning?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Structured reasoning (OpenRouter `reasoning_details`, or Anthropic
|
|
168
|
+
* `thinking` / `redacted_thinking` blocks). Echo back verbatim via
|
|
169
|
+
* `GenericMessage.reasoningDetails` — it carries signatures some providers
|
|
170
|
+
* validate. Undefined when the model/provider returns none.
|
|
171
|
+
*/
|
|
172
|
+
reasoningDetails?: any;
|
|
76
173
|
usage: {
|
|
77
174
|
prompt_tokens: number;
|
|
78
175
|
completion_tokens: number;
|
|
@@ -82,12 +179,22 @@ interface ParsedResponseMessage {
|
|
|
82
179
|
} | null;
|
|
83
180
|
}
|
|
84
181
|
interface FunctionCall {
|
|
182
|
+
/**
|
|
183
|
+
* Provider tool-call id, surfaced on responses and used to pair a call with
|
|
184
|
+
* its `ToolResult.toolCallId` on the next turn. The SDK synthesizes
|
|
185
|
+
* `call_<index>` for providers that don't return one (e.g. Google).
|
|
186
|
+
*/
|
|
187
|
+
id?: string;
|
|
85
188
|
name: string;
|
|
86
189
|
arguments: Record<string, any>;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Opaque per-call signature that must be echoed back verbatim on round-trip.
|
|
192
|
+
* Currently Google's `thoughtSignature` — Gemini REQUIRES it on functionCall
|
|
193
|
+
* parts in multi-turn tool use (a missing one 400s the next request). The SDK
|
|
194
|
+
* captures it on responses and re-emits it when you pass the call back;
|
|
195
|
+
* undefined for providers that don't use one.
|
|
196
|
+
*/
|
|
197
|
+
thoughtSignature?: string;
|
|
91
198
|
}
|
|
92
199
|
interface OpenAIConfig {
|
|
93
200
|
service: "azure" | "openai";
|
|
@@ -158,4 +265,4 @@ declare function parseModelString(model: string): {
|
|
|
158
265
|
};
|
|
159
266
|
declare function callWithRetries(id: string | string[], aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
|
|
160
267
|
|
|
161
|
-
export { type AnyModel, ClaudeModel, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type Provider, callWithRetries, parseModelString };
|
|
268
|
+
export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };
|
package/dist/index.d.ts
CHANGED
|
@@ -55,12 +55,94 @@ declare enum GeminiModel {
|
|
|
55
55
|
GEMINI_3_FLASH_PREVIEW = "gemini-3-flash-preview",
|
|
56
56
|
GEMINI_3_1_FLASH_LITE_PREVIEW = "gemini-3.1-flash-lite-preview"
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A single conversation turn passed to `callWithRetries`. The SDK serializes
|
|
60
|
+
* these into each provider's native message format.
|
|
61
|
+
*
|
|
62
|
+
* ## Multi-turn tool calls
|
|
63
|
+
* To continue after the model calls a tool, append the model's own assistant
|
|
64
|
+
* turn and then the tool result, then call again:
|
|
65
|
+
*
|
|
66
|
+
* 1. Read the assistant turn off the response: `function_calls` (each with an
|
|
67
|
+
* `id`) and — for reasoning models — `reasoning` / `reasoningDetails`.
|
|
68
|
+
* 2. Push back an `assistant` message carrying those same `functionCalls` (and,
|
|
69
|
+
* to keep the model's chain-of-thought, the captured reasoning fields).
|
|
70
|
+
* 3. Push back one `role: "tool"` message whose `toolResults` answer each call
|
|
71
|
+
* by `toolCallId`.
|
|
72
|
+
*
|
|
73
|
+
* The SDK is a pure transport: it does NOT echo reasoning or pair results for
|
|
74
|
+
* you — it serializes exactly what you put here. Every tool/reasoning field is
|
|
75
|
+
* optional, so a plain `{ role, content }` message behaves as before.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // turn 1 — model asks for the weather
|
|
79
|
+
* const a = await callWithRetries(id, { model, messages, functions });
|
|
80
|
+
* // a.function_calls -> [{ id: "call_abc", name: "get_weather", arguments: { city: "Tokyo" } }]
|
|
81
|
+
*
|
|
82
|
+
* // turn 2 — feed the call + its result back
|
|
83
|
+
* const next = await callWithRetries(id, { model, functions, messages: [
|
|
84
|
+
* ...messages,
|
|
85
|
+
* { role: "assistant", content: a.content ?? "", functionCalls: a.function_calls,
|
|
86
|
+
* reasoning: a.reasoning, reasoningDetails: a.reasoningDetails },
|
|
87
|
+
* { role: "tool", content: "", toolResults: [
|
|
88
|
+
* { toolCallId: "call_abc", name: "get_weather", content: '{"tempC":22}' } ] },
|
|
89
|
+
* ]});
|
|
90
|
+
*/
|
|
58
91
|
interface GenericMessage {
|
|
59
|
-
|
|
92
|
+
/**
|
|
93
|
+
* `"tool"` carries tool results (see `toolResults`) back to the model and
|
|
94
|
+
* must immediately follow the `assistant` turn that made the matching calls.
|
|
95
|
+
*/
|
|
96
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
97
|
+
/** Plain-text content. Use `""` for a tool-call-only or tool-result turn. */
|
|
60
98
|
content: string;
|
|
61
99
|
timestamp?: string;
|
|
62
100
|
files?: File[];
|
|
101
|
+
/**
|
|
102
|
+
* Tool calls the model made on an `assistant` turn. Pass back the `id`s you
|
|
103
|
+
* received in `ParsedResponseMessage.function_calls` so the provider can pair
|
|
104
|
+
* them with the `toolResults` that follow.
|
|
105
|
+
*/
|
|
63
106
|
functionCalls?: FunctionCall[];
|
|
107
|
+
/**
|
|
108
|
+
* Tool outputs on a `role: "tool"` message — one entry per call (parallel
|
|
109
|
+
* calls produce several). Each `toolCallId` must match a `FunctionCall.id`
|
|
110
|
+
* from the preceding assistant turn.
|
|
111
|
+
*/
|
|
112
|
+
toolResults?: ToolResult[];
|
|
113
|
+
/**
|
|
114
|
+
* Optional reasoning string to echo back on an `assistant` turn (e.g.
|
|
115
|
+
* OpenRouter/DeepSeek `reasoning`). Round-tripping it keeps the model's
|
|
116
|
+
* chain-of-thought across tool calls; some thinking models (DeepSeek V4)
|
|
117
|
+
* require it to avoid a 400 on the next turn.
|
|
118
|
+
*/
|
|
119
|
+
reasoning?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Optional structured reasoning to echo back on an `assistant` turn
|
|
122
|
+
* (OpenRouter `reasoning_details`, or Anthropic `thinking` /
|
|
123
|
+
* `redacted_thinking` blocks captured in
|
|
124
|
+
* `ParsedResponseMessage.reasoningDetails`). Preserves the signatures /
|
|
125
|
+
* encrypted payloads that providers validate on round-trip.
|
|
126
|
+
*/
|
|
127
|
+
reasoningDetails?: any;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The result of executing one tool call, fed back to the model on a
|
|
131
|
+
* `role: "tool"` message. The SDK maps this to each provider's native shape:
|
|
132
|
+
* OpenAI/Groq/OpenRouter `{ role: "tool", tool_call_id, content }`, Anthropic a
|
|
133
|
+
* `tool_result` block, Google a `functionResponse` part.
|
|
134
|
+
*/
|
|
135
|
+
interface ToolResult {
|
|
136
|
+
/** The `id` of the `FunctionCall` this answers (from the prior assistant turn). */
|
|
137
|
+
toolCallId: string;
|
|
138
|
+
/**
|
|
139
|
+
* The tool/function name. Required by Anthropic and Google on round-trip; the
|
|
140
|
+
* SDK falls back to the matching call's name when omitted, but supplying it is
|
|
141
|
+
* recommended.
|
|
142
|
+
*/
|
|
143
|
+
name?: string;
|
|
144
|
+
/** The tool output, serialized to a string (JSON or plain text). */
|
|
145
|
+
content: string;
|
|
64
146
|
}
|
|
65
147
|
interface File {
|
|
66
148
|
mimeType: string;
|
|
@@ -70,9 +152,24 @@ interface File {
|
|
|
70
152
|
interface ParsedResponseMessage {
|
|
71
153
|
role: "assistant";
|
|
72
154
|
content: string | null;
|
|
155
|
+
/** First of `function_calls` (backward-compat); carries `id` when the provider returns one. */
|
|
73
156
|
function_call: FunctionCall | null;
|
|
157
|
+
/** All tool calls the model made this turn, each with an `id` for round-tripping. */
|
|
74
158
|
function_calls: FunctionCall[];
|
|
75
159
|
files: File[];
|
|
160
|
+
/**
|
|
161
|
+
* Reasoning string from reasoning models (OpenRouter/DeepSeek `reasoning`).
|
|
162
|
+
* Echo back via `GenericMessage.reasoning` to preserve chain-of-thought across
|
|
163
|
+
* tool calls. Undefined when the model/provider returns none.
|
|
164
|
+
*/
|
|
165
|
+
reasoning?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Structured reasoning (OpenRouter `reasoning_details`, or Anthropic
|
|
168
|
+
* `thinking` / `redacted_thinking` blocks). Echo back verbatim via
|
|
169
|
+
* `GenericMessage.reasoningDetails` — it carries signatures some providers
|
|
170
|
+
* validate. Undefined when the model/provider returns none.
|
|
171
|
+
*/
|
|
172
|
+
reasoningDetails?: any;
|
|
76
173
|
usage: {
|
|
77
174
|
prompt_tokens: number;
|
|
78
175
|
completion_tokens: number;
|
|
@@ -82,12 +179,22 @@ interface ParsedResponseMessage {
|
|
|
82
179
|
} | null;
|
|
83
180
|
}
|
|
84
181
|
interface FunctionCall {
|
|
182
|
+
/**
|
|
183
|
+
* Provider tool-call id, surfaced on responses and used to pair a call with
|
|
184
|
+
* its `ToolResult.toolCallId` on the next turn. The SDK synthesizes
|
|
185
|
+
* `call_<index>` for providers that don't return one (e.g. Google).
|
|
186
|
+
*/
|
|
187
|
+
id?: string;
|
|
85
188
|
name: string;
|
|
86
189
|
arguments: Record<string, any>;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Opaque per-call signature that must be echoed back verbatim on round-trip.
|
|
192
|
+
* Currently Google's `thoughtSignature` — Gemini REQUIRES it on functionCall
|
|
193
|
+
* parts in multi-turn tool use (a missing one 400s the next request). The SDK
|
|
194
|
+
* captures it on responses and re-emits it when you pass the call back;
|
|
195
|
+
* undefined for providers that don't use one.
|
|
196
|
+
*/
|
|
197
|
+
thoughtSignature?: string;
|
|
91
198
|
}
|
|
92
199
|
interface OpenAIConfig {
|
|
93
200
|
service: "azure" | "openai";
|
|
@@ -158,4 +265,4 @@ declare function parseModelString(model: string): {
|
|
|
158
265
|
};
|
|
159
266
|
declare function callWithRetries(id: string | string[], aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
|
|
160
267
|
|
|
161
|
-
export { type AnyModel, ClaudeModel, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type Provider, callWithRetries, parseModelString };
|
|
268
|
+
export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };
|