@kernl-sdk/protocol 0.4.2 → 0.5.1
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +49 -0
- package/dist/language-model/item.d.ts +2 -2
- package/dist/language-model/model.d.ts +80 -25
- package/dist/language-model/model.d.ts.map +1 -1
- package/dist/language-model/stream.d.ts +14 -14
- package/dist/language-model/stream.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/language-model/item.ts +2 -2
- package/src/language-model/model.ts +98 -35
- package/src/language-model/stream.ts +14 -14
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @kernl/protocol
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 884e513: Align with @ai-sdk/provider v3 stable release
|
|
8
|
+
- Update LanguageModelUsage to nested structure (inputTokens.total, outputTokens.total, etc.)
|
|
9
|
+
- Update LanguageModelFinishReason to object with unified and raw properties
|
|
10
|
+
- Rename LanguageModelWarning to SharedWarning with updated structure
|
|
11
|
+
- Update tool type from "provider-defined" to "provider"
|
|
12
|
+
- Bump @ai-sdk peer dependencies from beta to stable (^3.0.3)
|
|
13
|
+
|
|
14
|
+
## 0.5.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 8815744: **BREAKING:** Refactor event kind naming from kebab-case to dot notation
|
|
19
|
+
|
|
20
|
+
This aligns the language model stream/item kinds with the existing realtime events naming convention.
|
|
21
|
+
|
|
22
|
+
### Kind value changes
|
|
23
|
+
|
|
24
|
+
| Old | New |
|
|
25
|
+
| ------------------ | ------------------ |
|
|
26
|
+
| `tool-call` | `tool.call` |
|
|
27
|
+
| `tool-result` | `tool.result` |
|
|
28
|
+
| `text-start` | `text.start` |
|
|
29
|
+
| `text-delta` | `text.delta` |
|
|
30
|
+
| `text-end` | `text.end` |
|
|
31
|
+
| `reasoning-start` | `reasoning.start` |
|
|
32
|
+
| `reasoning-delta` | `reasoning.delta` |
|
|
33
|
+
| `reasoning-end` | `reasoning.end` |
|
|
34
|
+
| `tool-input-start` | `tool.input.start` |
|
|
35
|
+
| `tool-input-delta` | `tool.input.delta` |
|
|
36
|
+
| `tool-input-end` | `tool.input.end` |
|
|
37
|
+
| `stream-start` | `stream.start` |
|
|
38
|
+
|
|
39
|
+
### ToolInputStartEvent: `toolName` → `toolId`
|
|
40
|
+
|
|
41
|
+
The `ToolInputStartEvent` now uses `toolId` to match `ToolCall` and `ToolResult`.
|
|
42
|
+
|
|
43
|
+
### Migration
|
|
44
|
+
|
|
45
|
+
If you have persisted thread events, run:
|
|
46
|
+
|
|
47
|
+
```sql
|
|
48
|
+
UPDATE thread_events SET kind = 'tool.call' WHERE kind = 'tool-call';
|
|
49
|
+
UPDATE thread_events SET kind = 'tool.result' WHERE kind = 'tool-result';
|
|
50
|
+
```
|
|
51
|
+
|
|
3
52
|
## 0.4.2
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|
|
@@ -144,7 +144,7 @@ export type Message = SystemMessage | AssistantMessage | UserMessage;
|
|
|
144
144
|
* Tool calls that the model has generated.
|
|
145
145
|
*/
|
|
146
146
|
export interface ToolCall extends LanguageModelItemBase {
|
|
147
|
-
readonly kind: "tool
|
|
147
|
+
readonly kind: "tool.call";
|
|
148
148
|
/**
|
|
149
149
|
* The identifier of the tool call. It must be unique across all tool calls.
|
|
150
150
|
*/
|
|
@@ -166,7 +166,7 @@ export interface ToolCall extends LanguageModelItemBase {
|
|
|
166
166
|
* Result of a tool call that has been executed by the provider.
|
|
167
167
|
*/
|
|
168
168
|
export interface ToolResult extends LanguageModelItemBase {
|
|
169
|
-
readonly kind: "tool
|
|
169
|
+
readonly kind: "tool.result";
|
|
170
170
|
/**
|
|
171
171
|
* The ID of the tool call that this result is associated with.
|
|
172
172
|
*/
|
|
@@ -2,7 +2,6 @@ import { SharedProviderMetadata } from "../provider/index.js";
|
|
|
2
2
|
import { LanguageModelResponseItem } from "./item.js";
|
|
3
3
|
import { LanguageModelRequest } from "./request.js";
|
|
4
4
|
import { LanguageModelStreamEvent } from "./stream.js";
|
|
5
|
-
import { LanguageModelFunctionTool, LanguageModelProviderTool } from "./tool.js";
|
|
6
5
|
/**
|
|
7
6
|
* Defines the standard interface for language model providers in kernl.
|
|
8
7
|
*/
|
|
@@ -51,7 +50,7 @@ export interface LanguageModelResponse {
|
|
|
51
50
|
/**
|
|
52
51
|
* Warnings for the call, e.g. unsupported settings.
|
|
53
52
|
*/
|
|
54
|
-
warnings:
|
|
53
|
+
warnings: SharedWarning[];
|
|
55
54
|
/**
|
|
56
55
|
* Raw response data from the underlying model provider.
|
|
57
56
|
*/
|
|
@@ -60,7 +59,23 @@ export interface LanguageModelResponse {
|
|
|
60
59
|
/**
|
|
61
60
|
* Reason why a language model finished generating a response.
|
|
62
61
|
*/
|
|
63
|
-
export
|
|
62
|
+
export interface LanguageModelFinishReason {
|
|
63
|
+
/**
|
|
64
|
+
* Unified finish reason across providers.
|
|
65
|
+
*
|
|
66
|
+
* - `stop`: model generated stop sequence
|
|
67
|
+
* - `length`: model generated maximum number of tokens
|
|
68
|
+
* - `content-filter`: content filter violation stopped the model
|
|
69
|
+
* - `tool-calls`: model triggered tool calls
|
|
70
|
+
* - `error`: model stopped because of an error
|
|
71
|
+
* - `other`: model stopped for other reasons
|
|
72
|
+
*/
|
|
73
|
+
unified: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other";
|
|
74
|
+
/**
|
|
75
|
+
* Raw finish reason from the provider.
|
|
76
|
+
*/
|
|
77
|
+
raw: string | undefined;
|
|
78
|
+
}
|
|
64
79
|
/**
|
|
65
80
|
* Usage information for a language model call.
|
|
66
81
|
*
|
|
@@ -69,42 +84,82 @@ export type LanguageModelFinishReason = "stop" | "length" | "content-filter" | "
|
|
|
69
84
|
*/
|
|
70
85
|
export interface LanguageModelUsage {
|
|
71
86
|
/**
|
|
72
|
-
*
|
|
87
|
+
* Input token usage breakdown.
|
|
73
88
|
*/
|
|
74
|
-
inputTokens:
|
|
89
|
+
inputTokens: {
|
|
90
|
+
/**
|
|
91
|
+
* Total input tokens used.
|
|
92
|
+
*/
|
|
93
|
+
total: number | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Input tokens that were not cached.
|
|
96
|
+
*/
|
|
97
|
+
noCache: number | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Input tokens read from cache.
|
|
100
|
+
*/
|
|
101
|
+
cacheRead: number | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Input tokens written to cache.
|
|
104
|
+
*/
|
|
105
|
+
cacheWrite: number | undefined;
|
|
106
|
+
};
|
|
75
107
|
/**
|
|
76
|
-
*
|
|
108
|
+
* Output token usage breakdown.
|
|
77
109
|
*/
|
|
78
|
-
outputTokens:
|
|
110
|
+
outputTokens: {
|
|
111
|
+
/**
|
|
112
|
+
* Total output tokens used.
|
|
113
|
+
*/
|
|
114
|
+
total: number | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Text generation tokens.
|
|
117
|
+
*/
|
|
118
|
+
text: number | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Reasoning/thinking tokens.
|
|
121
|
+
*/
|
|
122
|
+
reasoning: number | undefined;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
127
|
+
* some settings might not be supported, which can lead to suboptimal results.
|
|
128
|
+
*/
|
|
129
|
+
export type SharedWarning = {
|
|
79
130
|
/**
|
|
80
|
-
*
|
|
81
|
-
* This number might be different from the sum of `inputTokens` and `outputTokens`
|
|
82
|
-
* and e.g. include reasoning tokens or other overhead.
|
|
131
|
+
* A feature is not supported by the model.
|
|
83
132
|
*/
|
|
84
|
-
|
|
133
|
+
type: "unsupported";
|
|
85
134
|
/**
|
|
86
|
-
* The
|
|
135
|
+
* The feature that is not supported.
|
|
87
136
|
*/
|
|
88
|
-
|
|
137
|
+
feature: string;
|
|
89
138
|
/**
|
|
90
|
-
*
|
|
139
|
+
* Additional details about the warning.
|
|
91
140
|
*/
|
|
92
|
-
cachedInputTokens?: number | undefined;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
96
|
-
* some settings might not be supported, which can lead to suboptimal results.
|
|
97
|
-
*/
|
|
98
|
-
export type LanguageModelWarning = {
|
|
99
|
-
type: "unsupported-setting";
|
|
100
|
-
setting: Omit<keyof LanguageModelRequest, "input">;
|
|
101
141
|
details?: string;
|
|
102
142
|
} | {
|
|
103
|
-
|
|
104
|
-
|
|
143
|
+
/**
|
|
144
|
+
* A compatibility feature is used that might lead to suboptimal results.
|
|
145
|
+
*/
|
|
146
|
+
type: "compatibility";
|
|
147
|
+
/**
|
|
148
|
+
* The feature that is used in compatibility mode.
|
|
149
|
+
*/
|
|
150
|
+
feature: string;
|
|
151
|
+
/**
|
|
152
|
+
* Additional details about the warning.
|
|
153
|
+
*/
|
|
105
154
|
details?: string;
|
|
106
155
|
} | {
|
|
156
|
+
/**
|
|
157
|
+
* Other warning.
|
|
158
|
+
*/
|
|
107
159
|
type: "other";
|
|
160
|
+
/**
|
|
161
|
+
* The message of the warning.
|
|
162
|
+
*/
|
|
108
163
|
message: string;
|
|
109
164
|
};
|
|
110
165
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/language-model/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC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OAEG;IACH,WAAW,EAAE;QACX;;WAEG;QACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAE1B;;WAEG;QACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAE5B;;WAEG;QACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAE9B;;WAEG;QACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,CAAC;IAEF;;OAEG;IACH,YAAY,EAAE;QACZ;;WAEG;QACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAE1B;;WAEG;QACH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QAEzB;;WAEG;QACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;KAC/B,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB;IACE;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SharedProviderMetadata } from "../provider/index.js";
|
|
2
|
-
import type { LanguageModelFinishReason, LanguageModelUsage,
|
|
2
|
+
import type { LanguageModelFinishReason, LanguageModelUsage, SharedWarning } from "./model.js";
|
|
3
3
|
import type { Message, Reasoning, ToolCall, ToolResult } from "./item.js";
|
|
4
4
|
/**
|
|
5
5
|
* Union of all language model stream events.
|
|
@@ -22,21 +22,21 @@ export interface StreamEventBase {
|
|
|
22
22
|
* Stream event indicating the start of a text output.
|
|
23
23
|
*/
|
|
24
24
|
export interface TextStartEvent extends StreamEventBase {
|
|
25
|
-
readonly kind: "text
|
|
25
|
+
readonly kind: "text.start";
|
|
26
26
|
id: string;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Stream event indicating the end of a text output.
|
|
30
30
|
*/
|
|
31
31
|
export interface TextEndEvent extends StreamEventBase {
|
|
32
|
-
readonly kind: "text
|
|
32
|
+
readonly kind: "text.end";
|
|
33
33
|
id: string;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Stream event containing a delta (chunk) of text output.
|
|
37
37
|
*/
|
|
38
38
|
export interface TextDeltaEvent extends StreamEventBase {
|
|
39
|
-
readonly kind: "text
|
|
39
|
+
readonly kind: "text.delta";
|
|
40
40
|
id: string;
|
|
41
41
|
/**
|
|
42
42
|
* The incremental text chunk.
|
|
@@ -47,21 +47,21 @@ export interface TextDeltaEvent extends StreamEventBase {
|
|
|
47
47
|
* Stream event indicating the start of reasoning output.
|
|
48
48
|
*/
|
|
49
49
|
export interface ReasoningStartEvent extends StreamEventBase {
|
|
50
|
-
readonly kind: "reasoning
|
|
50
|
+
readonly kind: "reasoning.start";
|
|
51
51
|
id: string;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Stream event indicating the end of reasoning output.
|
|
55
55
|
*/
|
|
56
56
|
export interface ReasoningEndEvent extends StreamEventBase {
|
|
57
|
-
readonly kind: "reasoning
|
|
57
|
+
readonly kind: "reasoning.end";
|
|
58
58
|
id: string;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Stream event containing a delta (chunk) of reasoning output.
|
|
62
62
|
*/
|
|
63
63
|
export interface ReasoningDeltaEvent extends StreamEventBase {
|
|
64
|
-
readonly kind: "reasoning
|
|
64
|
+
readonly kind: "reasoning.delta";
|
|
65
65
|
id: string;
|
|
66
66
|
/**
|
|
67
67
|
* The incremental reasoning text chunk.
|
|
@@ -72,12 +72,12 @@ export interface ReasoningDeltaEvent extends StreamEventBase {
|
|
|
72
72
|
* Stream event indicating the start of tool input generation.
|
|
73
73
|
*/
|
|
74
74
|
export interface ToolInputStartEvent extends StreamEventBase {
|
|
75
|
-
readonly kind: "tool
|
|
75
|
+
readonly kind: "tool.input.start";
|
|
76
76
|
id: string;
|
|
77
77
|
/**
|
|
78
|
-
* The
|
|
78
|
+
* The identifier of the tool being called.
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
toolId: string;
|
|
81
81
|
/**
|
|
82
82
|
* Optional title for the tool call.
|
|
83
83
|
*/
|
|
@@ -87,14 +87,14 @@ export interface ToolInputStartEvent extends StreamEventBase {
|
|
|
87
87
|
* Stream event indicating the end of tool input generation.
|
|
88
88
|
*/
|
|
89
89
|
export interface ToolInputEndEvent extends StreamEventBase {
|
|
90
|
-
readonly kind: "tool
|
|
90
|
+
readonly kind: "tool.input.end";
|
|
91
91
|
id: string;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Stream event containing a delta (chunk) of tool input.
|
|
95
95
|
*/
|
|
96
96
|
export interface ToolInputDeltaEvent extends StreamEventBase {
|
|
97
|
-
readonly kind: "tool
|
|
97
|
+
readonly kind: "tool.input.delta";
|
|
98
98
|
id: string;
|
|
99
99
|
/**
|
|
100
100
|
* The incremental tool input chunk.
|
|
@@ -105,11 +105,11 @@ export interface ToolInputDeltaEvent extends StreamEventBase {
|
|
|
105
105
|
* Stream event indicating the start of agent execution.
|
|
106
106
|
*/
|
|
107
107
|
export interface StartEvent extends StreamEventBase {
|
|
108
|
-
readonly kind: "stream
|
|
108
|
+
readonly kind: "stream.start";
|
|
109
109
|
/**
|
|
110
110
|
* Warnings for the call (e.g., unsupported settings).
|
|
111
111
|
*/
|
|
112
|
-
warnings?:
|
|
112
|
+
warnings?: SharedWarning[];
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Stream event indicating the completion of agent execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/language-model/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/language-model/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAChC,cAAc,GACd,cAAc,GACd,YAAY,GACZ,OAAO,GACP,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,SAAS,GACT,mBAAmB,GACnB,iBAAiB,GACjB,mBAAmB,GACnB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B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SAAQ,eAAe;IAClD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB;;OAEG;IACH,YAAY,EAAE,yBAAyB,CAAC;IAExC;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,eAAe;IAC/C,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -195,7 +195,7 @@ export type Message = SystemMessage | AssistantMessage | UserMessage;
|
|
|
195
195
|
* Tool calls that the model has generated.
|
|
196
196
|
*/
|
|
197
197
|
export interface ToolCall extends LanguageModelItemBase {
|
|
198
|
-
readonly kind: "tool
|
|
198
|
+
readonly kind: "tool.call";
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* The identifier of the tool call. It must be unique across all tool calls.
|
|
@@ -222,7 +222,7 @@ export interface ToolCall extends LanguageModelItemBase {
|
|
|
222
222
|
* Result of a tool call that has been executed by the provider.
|
|
223
223
|
*/
|
|
224
224
|
export interface ToolResult extends LanguageModelItemBase {
|
|
225
|
-
readonly kind: "tool
|
|
225
|
+
readonly kind: "tool.result";
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* The ID of the tool call that this result is associated with.
|
|
@@ -85,7 +85,7 @@ export interface LanguageModelResponse {
|
|
|
85
85
|
/**
|
|
86
86
|
* Warnings for the call, e.g. unsupported settings.
|
|
87
87
|
*/
|
|
88
|
-
warnings:
|
|
88
|
+
warnings: SharedWarning[];
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Raw response data from the underlying model provider.
|
|
@@ -96,14 +96,30 @@ export interface LanguageModelResponse {
|
|
|
96
96
|
/**
|
|
97
97
|
* Reason why a language model finished generating a response.
|
|
98
98
|
*/
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
export interface LanguageModelFinishReason {
|
|
100
|
+
/**
|
|
101
|
+
* Unified finish reason across providers.
|
|
102
|
+
*
|
|
103
|
+
* - `stop`: model generated stop sequence
|
|
104
|
+
* - `length`: model generated maximum number of tokens
|
|
105
|
+
* - `content-filter`: content filter violation stopped the model
|
|
106
|
+
* - `tool-calls`: model triggered tool calls
|
|
107
|
+
* - `error`: model stopped because of an error
|
|
108
|
+
* - `other`: model stopped for other reasons
|
|
109
|
+
*/
|
|
110
|
+
unified:
|
|
111
|
+
| "stop"
|
|
112
|
+
| "length"
|
|
113
|
+
| "content-filter"
|
|
114
|
+
| "tool-calls"
|
|
115
|
+
| "error"
|
|
116
|
+
| "other";
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Raw finish reason from the provider.
|
|
120
|
+
*/
|
|
121
|
+
raw: string | undefined;
|
|
122
|
+
}
|
|
107
123
|
|
|
108
124
|
/**
|
|
109
125
|
* Usage information for a language model call.
|
|
@@ -113,49 +129,96 @@ export type LanguageModelFinishReason =
|
|
|
113
129
|
*/
|
|
114
130
|
export interface LanguageModelUsage {
|
|
115
131
|
/**
|
|
116
|
-
*
|
|
132
|
+
* Input token usage breakdown.
|
|
117
133
|
*/
|
|
118
|
-
inputTokens:
|
|
134
|
+
inputTokens: {
|
|
135
|
+
/**
|
|
136
|
+
* Total input tokens used.
|
|
137
|
+
*/
|
|
138
|
+
total: number | undefined;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Input tokens that were not cached.
|
|
142
|
+
*/
|
|
143
|
+
noCache: number | undefined;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Input tokens read from cache.
|
|
147
|
+
*/
|
|
148
|
+
cacheRead: number | undefined;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Input tokens written to cache.
|
|
152
|
+
*/
|
|
153
|
+
cacheWrite: number | undefined;
|
|
154
|
+
};
|
|
119
155
|
|
|
120
156
|
/**
|
|
121
|
-
*
|
|
157
|
+
* Output token usage breakdown.
|
|
122
158
|
*/
|
|
123
|
-
outputTokens:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
cachedInputTokens?: number | undefined;
|
|
159
|
+
outputTokens: {
|
|
160
|
+
/**
|
|
161
|
+
* Total output tokens used.
|
|
162
|
+
*/
|
|
163
|
+
total: number | undefined;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Text generation tokens.
|
|
167
|
+
*/
|
|
168
|
+
text: number | undefined;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Reasoning/thinking tokens.
|
|
172
|
+
*/
|
|
173
|
+
reasoning: number | undefined;
|
|
174
|
+
};
|
|
141
175
|
}
|
|
142
176
|
|
|
143
177
|
/**
|
|
144
178
|
* Warning from the model provider for this call. The call will proceed, but e.g.
|
|
145
179
|
* some settings might not be supported, which can lead to suboptimal results.
|
|
146
180
|
*/
|
|
147
|
-
export type
|
|
181
|
+
export type SharedWarning =
|
|
148
182
|
| {
|
|
149
|
-
|
|
150
|
-
|
|
183
|
+
/**
|
|
184
|
+
* A feature is not supported by the model.
|
|
185
|
+
*/
|
|
186
|
+
type: "unsupported";
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The feature that is not supported.
|
|
190
|
+
*/
|
|
191
|
+
feature: string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Additional details about the warning.
|
|
195
|
+
*/
|
|
151
196
|
details?: string;
|
|
152
197
|
}
|
|
153
198
|
| {
|
|
154
|
-
|
|
155
|
-
|
|
199
|
+
/**
|
|
200
|
+
* A compatibility feature is used that might lead to suboptimal results.
|
|
201
|
+
*/
|
|
202
|
+
type: "compatibility";
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The feature that is used in compatibility mode.
|
|
206
|
+
*/
|
|
207
|
+
feature: string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Additional details about the warning.
|
|
211
|
+
*/
|
|
156
212
|
details?: string;
|
|
157
213
|
}
|
|
158
214
|
| {
|
|
215
|
+
/**
|
|
216
|
+
* Other warning.
|
|
217
|
+
*/
|
|
159
218
|
type: "other";
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The message of the warning.
|
|
222
|
+
*/
|
|
160
223
|
message: string;
|
|
161
224
|
};
|
|
@@ -3,7 +3,7 @@ import { SharedProviderMetadata } from "@/provider";
|
|
|
3
3
|
import type {
|
|
4
4
|
LanguageModelFinishReason,
|
|
5
5
|
LanguageModelUsage,
|
|
6
|
-
|
|
6
|
+
SharedWarning,
|
|
7
7
|
} from "./model";
|
|
8
8
|
import type { Message, Reasoning, ToolCall, ToolResult } from "./item";
|
|
9
9
|
|
|
@@ -49,7 +49,7 @@ export interface StreamEventBase {
|
|
|
49
49
|
* Stream event indicating the start of a text output.
|
|
50
50
|
*/
|
|
51
51
|
export interface TextStartEvent extends StreamEventBase {
|
|
52
|
-
readonly kind: "text
|
|
52
|
+
readonly kind: "text.start";
|
|
53
53
|
id: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ export interface TextStartEvent extends StreamEventBase {
|
|
|
57
57
|
* Stream event indicating the end of a text output.
|
|
58
58
|
*/
|
|
59
59
|
export interface TextEndEvent extends StreamEventBase {
|
|
60
|
-
readonly kind: "text
|
|
60
|
+
readonly kind: "text.end";
|
|
61
61
|
id: string;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,7 +65,7 @@ export interface TextEndEvent extends StreamEventBase {
|
|
|
65
65
|
* Stream event containing a delta (chunk) of text output.
|
|
66
66
|
*/
|
|
67
67
|
export interface TextDeltaEvent extends StreamEventBase {
|
|
68
|
-
readonly kind: "text
|
|
68
|
+
readonly kind: "text.delta";
|
|
69
69
|
id: string;
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -78,7 +78,7 @@ export interface TextDeltaEvent extends StreamEventBase {
|
|
|
78
78
|
* Stream event indicating the start of reasoning output.
|
|
79
79
|
*/
|
|
80
80
|
export interface ReasoningStartEvent extends StreamEventBase {
|
|
81
|
-
readonly kind: "reasoning
|
|
81
|
+
readonly kind: "reasoning.start";
|
|
82
82
|
id: string;
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ export interface ReasoningStartEvent extends StreamEventBase {
|
|
|
86
86
|
* Stream event indicating the end of reasoning output.
|
|
87
87
|
*/
|
|
88
88
|
export interface ReasoningEndEvent extends StreamEventBase {
|
|
89
|
-
readonly kind: "reasoning
|
|
89
|
+
readonly kind: "reasoning.end";
|
|
90
90
|
id: string;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ export interface ReasoningEndEvent extends StreamEventBase {
|
|
|
94
94
|
* Stream event containing a delta (chunk) of reasoning output.
|
|
95
95
|
*/
|
|
96
96
|
export interface ReasoningDeltaEvent extends StreamEventBase {
|
|
97
|
-
readonly kind: "reasoning
|
|
97
|
+
readonly kind: "reasoning.delta";
|
|
98
98
|
id: string;
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -107,13 +107,13 @@ export interface ReasoningDeltaEvent extends StreamEventBase {
|
|
|
107
107
|
* Stream event indicating the start of tool input generation.
|
|
108
108
|
*/
|
|
109
109
|
export interface ToolInputStartEvent extends StreamEventBase {
|
|
110
|
-
readonly kind: "tool
|
|
110
|
+
readonly kind: "tool.input.start";
|
|
111
111
|
id: string;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* The
|
|
114
|
+
* The identifier of the tool being called.
|
|
115
115
|
*/
|
|
116
|
-
|
|
116
|
+
toolId: string;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Optional title for the tool call.
|
|
@@ -125,7 +125,7 @@ export interface ToolInputStartEvent extends StreamEventBase {
|
|
|
125
125
|
* Stream event indicating the end of tool input generation.
|
|
126
126
|
*/
|
|
127
127
|
export interface ToolInputEndEvent extends StreamEventBase {
|
|
128
|
-
readonly kind: "tool
|
|
128
|
+
readonly kind: "tool.input.end";
|
|
129
129
|
id: string;
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -133,7 +133,7 @@ export interface ToolInputEndEvent extends StreamEventBase {
|
|
|
133
133
|
* Stream event containing a delta (chunk) of tool input.
|
|
134
134
|
*/
|
|
135
135
|
export interface ToolInputDeltaEvent extends StreamEventBase {
|
|
136
|
-
readonly kind: "tool
|
|
136
|
+
readonly kind: "tool.input.delta";
|
|
137
137
|
id: string;
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -146,12 +146,12 @@ export interface ToolInputDeltaEvent extends StreamEventBase {
|
|
|
146
146
|
* Stream event indicating the start of agent execution.
|
|
147
147
|
*/
|
|
148
148
|
export interface StartEvent extends StreamEventBase {
|
|
149
|
-
readonly kind: "stream
|
|
149
|
+
readonly kind: "stream.start";
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Warnings for the call (e.g., unsupported settings).
|
|
153
153
|
*/
|
|
154
|
-
warnings?:
|
|
154
|
+
warnings?: SharedWarning[];
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|