@kernl-sdk/ai 0.3.5 → 0.4.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.
Files changed (38) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +58 -0
  3. package/dist/__tests__/integration.test.js +16 -16
  4. package/dist/__tests__/language-model.test.js +10 -10
  5. package/dist/convert/__tests__/message.test.js +7 -7
  6. package/dist/convert/__tests__/settings.test.js +1 -1
  7. package/dist/convert/__tests__/stream.test.js +19 -19
  8. package/dist/convert/__tests__/tools.test.js +1 -1
  9. package/dist/convert/__tests__/ui-message.test.js +44 -44
  10. package/dist/convert/__tests__/ui-stream.test.js +42 -42
  11. package/dist/convert/message.js +2 -2
  12. package/dist/convert/response.js +2 -2
  13. package/dist/convert/stream.js +13 -13
  14. package/dist/convert/ui-message.js +5 -5
  15. package/dist/convert/ui-stream.d.ts +2 -1
  16. package/dist/convert/ui-stream.d.ts.map +1 -1
  17. package/dist/convert/ui-stream.js +16 -14
  18. package/dist/language-model.d.ts.map +1 -1
  19. package/dist/language-model.js +9 -8
  20. package/dist/util.d.ts +10 -0
  21. package/dist/util.d.ts.map +1 -0
  22. package/dist/util.js +12 -0
  23. package/package.json +5 -4
  24. package/src/__tests__/integration.test.ts +16 -16
  25. package/src/__tests__/language-model.test.ts +10 -10
  26. package/src/convert/__tests__/message.test.ts +7 -7
  27. package/src/convert/__tests__/settings.test.ts +1 -1
  28. package/src/convert/__tests__/stream.test.ts +19 -19
  29. package/src/convert/__tests__/tools.test.ts +1 -1
  30. package/src/convert/__tests__/ui-message.test.ts +44 -44
  31. package/src/convert/__tests__/ui-stream.test.ts +42 -42
  32. package/src/convert/message.ts +2 -2
  33. package/src/convert/response.ts +2 -2
  34. package/src/convert/stream.ts +13 -13
  35. package/src/convert/ui-message.ts +7 -7
  36. package/src/convert/ui-stream.ts +18 -18
  37. package/src/language-model.ts +9 -8
  38. package/src/util.ts +12 -0
@@ -31,66 +31,66 @@ export const STREAM_PART = {
31
31
  switch (part.type) {
32
32
  case "text-start":
33
33
  return {
34
- kind: "text-start",
34
+ kind: "text.start",
35
35
  id: part.id,
36
36
  providerMetadata: part.providerMetadata,
37
37
  };
38
38
  case "text-delta":
39
39
  return {
40
- kind: "text-delta",
40
+ kind: "text.delta",
41
41
  id: part.id,
42
42
  text: part.delta,
43
43
  providerMetadata: part.providerMetadata,
44
44
  };
45
45
  case "text-end":
46
46
  return {
47
- kind: "text-end",
47
+ kind: "text.end",
48
48
  id: part.id,
49
49
  providerMetadata: part.providerMetadata,
50
50
  };
51
51
  case "reasoning-start":
52
52
  return {
53
- kind: "reasoning-start",
53
+ kind: "reasoning.start",
54
54
  id: part.id,
55
55
  providerMetadata: part.providerMetadata,
56
56
  };
57
57
  case "reasoning-delta":
58
58
  return {
59
- kind: "reasoning-delta",
59
+ kind: "reasoning.delta",
60
60
  id: part.id,
61
61
  text: part.delta,
62
62
  providerMetadata: part.providerMetadata,
63
63
  };
64
64
  case "reasoning-end":
65
65
  return {
66
- kind: "reasoning-end",
66
+ kind: "reasoning.end",
67
67
  id: part.id,
68
68
  providerMetadata: part.providerMetadata,
69
69
  };
70
70
  case "tool-input-start":
71
71
  return {
72
- kind: "tool-input-start",
72
+ kind: "tool.input.start",
73
73
  id: part.id,
74
- toolName: part.toolName,
74
+ toolId: part.toolName,
75
75
  title: part.title,
76
76
  providerMetadata: part.providerMetadata,
77
77
  };
78
78
  case "tool-input-delta":
79
79
  return {
80
- kind: "tool-input-delta",
80
+ kind: "tool.input.delta",
81
81
  id: part.id,
82
82
  delta: part.delta,
83
83
  providerMetadata: part.providerMetadata,
84
84
  };
85
85
  case "tool-input-end":
86
86
  return {
87
- kind: "tool-input-end",
87
+ kind: "tool.input.end",
88
88
  id: part.id,
89
89
  providerMetadata: part.providerMetadata,
90
90
  };
91
91
  case "tool-call":
92
92
  return {
93
- kind: "tool-call",
93
+ kind: "tool.call",
94
94
  callId: part.toolCallId,
95
95
  toolId: part.toolName,
96
96
  state: IN_PROGRESS,
@@ -100,7 +100,7 @@ export const STREAM_PART = {
100
100
  case "tool-result":
101
101
  // provider-defined tools can stream tool results
102
102
  return {
103
- kind: "tool-result",
103
+ kind: "tool.result",
104
104
  callId: part.toolCallId,
105
105
  toolId: part.toolName,
106
106
  state: part.isError ? FAILED : COMPLETED,
@@ -110,7 +110,7 @@ export const STREAM_PART = {
110
110
  };
111
111
  case "stream-start":
112
112
  return {
113
- kind: "stream-start",
113
+ kind: "stream.start",
114
114
  warnings: part.warnings.map(WARNING.decode),
115
115
  };
116
116
  case "finish":
@@ -123,7 +123,7 @@ const TOOL_UI_PART = {
123
123
  switch (part.state) {
124
124
  case "input-available": {
125
125
  const call = {
126
- kind: "tool-call",
126
+ kind: "tool.call",
127
127
  callId,
128
128
  toolId,
129
129
  state: IN_PROGRESS,
@@ -134,7 +134,7 @@ const TOOL_UI_PART = {
134
134
  }
135
135
  case "output-available": {
136
136
  const result = {
137
- kind: "tool-result",
137
+ kind: "tool.result",
138
138
  callId,
139
139
  toolId,
140
140
  state: COMPLETED,
@@ -146,7 +146,7 @@ const TOOL_UI_PART = {
146
146
  }
147
147
  case "output-error": {
148
148
  const result = {
149
- kind: "tool-result",
149
+ kind: "tool.result",
150
150
  callId,
151
151
  toolId,
152
152
  state: FAILED,
@@ -220,11 +220,11 @@ export function historyToUIMessages(items) {
220
220
  const reasoningParts = [];
221
221
  while (j < items.length && items[j].kind !== "message") {
222
222
  const next = items[j];
223
- if (next.kind === "tool-call") {
223
+ if (next.kind === "tool.call") {
224
224
  const existing = toolMap.get(next.callId) || {};
225
225
  toolMap.set(next.callId, { ...existing, call: next });
226
226
  }
227
- else if (next.kind === "tool-result") {
227
+ else if (next.kind === "tool.result") {
228
228
  const existing = toolMap.get(next.callId) || {};
229
229
  toolMap.set(next.callId, { ...existing, result: next });
230
230
  }
@@ -1,5 +1,6 @@
1
1
  import type { Codec } from "@kernl-sdk/shared/lib";
2
2
  import { type LanguageModelStreamEvent } from "@kernl-sdk/protocol";
3
+ import { type ThreadStreamEvent } from "kernl";
3
4
  import { type UIMessageChunk } from "ai";
4
5
  /**
5
6
  * Convert kernl stream to AI SDK UIMessage stream.
@@ -14,7 +15,7 @@ import { type UIMessageChunk } from "ai";
14
15
  * return createUIMessageStreamResponse({ stream: ui });
15
16
  * ```
16
17
  */
17
- export declare function toUIMessageStream(stream: AsyncIterable<LanguageModelStreamEvent>): ReadableStream<UIMessageChunk>;
18
+ export declare function toUIMessageStream(stream: AsyncIterable<ThreadStreamEvent | LanguageModelStreamEvent>): ReadableStream<UIMessageChunk>;
18
19
  /**
19
20
  * Convert kernl's LanguageModelStreamEvent to AI SDK's UIMessageChunk format.
20
21
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ui-stream.d.ts","sourceRoot":"","sources":["../../src/convert/ui-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,IAAI,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,GAC9C,cAAc,CAAC,cAAc,CAAC,CAWhC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAChC,wBAAwB,EACxB,cAAc,GAAG,IAAI,CAuHtB,CAAC"}
1
+ {"version":3,"file":"ui-stream.d.ts","sourceRoot":"","sources":["../../src/convert/ui-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,wBAAwB,EAAU,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,IAAI,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,CAAC,iBAAiB,GAAG,wBAAwB,CAAC,GAClE,cAAc,CAAC,cAAc,CAAC,CAahC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAChC,wBAAwB,EACxB,cAAc,GAAG,IAAI,CAuHtB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FAILED, } from "@kernl-sdk/protocol";
1
+ import { FAILED } from "@kernl-sdk/protocol";
2
2
  import { createUIMessageStream } from "ai";
3
3
  /**
4
4
  * Convert kernl stream to AI SDK UIMessage stream.
@@ -17,6 +17,8 @@ export function toUIMessageStream(stream) {
17
17
  return createUIMessageStream({
18
18
  async execute({ writer }) {
19
19
  for await (const event of stream) {
20
+ if (event.kind === "system")
21
+ continue;
20
22
  const chunk = STREAM_UI_PART.encode(event);
21
23
  if (chunk) {
22
24
  writer.write(chunk);
@@ -38,59 +40,59 @@ export function toUIMessageStream(stream) {
38
40
  export const STREAM_UI_PART = {
39
41
  encode: (event) => {
40
42
  switch (event.kind) {
41
- case "text-start":
43
+ case "text.start":
42
44
  return {
43
45
  type: "text-start",
44
46
  id: event.id,
45
47
  };
46
- case "text-delta":
48
+ case "text.delta":
47
49
  return {
48
50
  type: "text-delta",
49
51
  id: event.id,
50
52
  delta: event.text,
51
53
  };
52
- case "text-end":
54
+ case "text.end":
53
55
  return {
54
56
  type: "text-end",
55
57
  id: event.id,
56
58
  };
57
- case "reasoning-start":
59
+ case "reasoning.start":
58
60
  return {
59
61
  type: "reasoning-start",
60
62
  id: event.id,
61
63
  };
62
- case "reasoning-delta":
64
+ case "reasoning.delta":
63
65
  return {
64
66
  type: "reasoning-delta",
65
67
  id: event.id,
66
68
  delta: event.text,
67
69
  };
68
- case "reasoning-end":
70
+ case "reasoning.end":
69
71
  return {
70
72
  type: "reasoning-end",
71
73
  id: event.id,
72
74
  };
73
- case "tool-input-start":
75
+ case "tool.input.start":
74
76
  return {
75
77
  type: "tool-input-start",
76
78
  toolCallId: event.id,
77
- toolName: event.toolName,
79
+ toolName: event.toolId,
78
80
  ...(event.title != null ? { title: event.title } : {}),
79
81
  };
80
- case "tool-input-delta":
82
+ case "tool.input.delta":
81
83
  return {
82
84
  type: "tool-input-delta",
83
85
  toolCallId: event.id,
84
86
  inputTextDelta: event.delta,
85
87
  };
86
- case "tool-call":
88
+ case "tool.call":
87
89
  return {
88
90
  type: "tool-input-available",
89
91
  toolCallId: event.callId,
90
92
  toolName: event.toolId,
91
93
  input: JSON.parse(event.arguments),
92
94
  };
93
- case "tool-result":
95
+ case "tool.result":
94
96
  // Convert tool result to tool-output-available or tool-output-error
95
97
  if (event.state === FAILED) {
96
98
  return {
@@ -104,7 +106,7 @@ export const STREAM_UI_PART = {
104
106
  toolCallId: event.callId,
105
107
  output: event.result,
106
108
  };
107
- case "stream-start":
109
+ case "stream.start":
108
110
  return {
109
111
  type: "start",
110
112
  };
@@ -125,7 +127,7 @@ export const STREAM_UI_PART = {
125
127
  case "message":
126
128
  case "reasoning":
127
129
  // - events without direct UI equivalents -
128
- case "tool-input-end":
130
+ case "tool.input.end":
129
131
  case "raw":
130
132
  return null;
131
133
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"language-model.d.ts","sourceRoot":"","sources":["../src/language-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAS7B;;GAEG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IAK1C,OAAO,CAAC,KAAK;IAJzB,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEL,KAAK,EAAE,eAAe;IAK1C;;OAEG;IACG,QAAQ,CACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiBjC;;OAEG;IACI,MAAM,CACX,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAAC,wBAAwB,CAAC;CAkF3C"}
1
+ {"version":3,"file":"language-model.d.ts","sourceRoot":"","sources":["../src/language-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAU7B;;GAEG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IAK1C,OAAO,CAAC,KAAK;IAJzB,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEL,KAAK,EAAE,eAAe;IAK1C;;OAEG;IACG,QAAQ,CACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiBjC;;OAEG;IACI,MAAM,CACX,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAAC,wBAAwB,CAAC;CAkF3C"}
@@ -4,6 +4,7 @@ import { TOOL } from "./convert/tools.js";
4
4
  import { MODEL_SETTINGS } from "./convert/settings.js";
5
5
  import { MODEL_RESPONSE, RESPONSE_FORMAT } from "./convert/response.js";
6
6
  import { convertStream } from "./convert/stream.js";
7
+ import { normalizeProvider } from "./util.js";
7
8
  /**
8
9
  * LanguageModel adapter for the AI SDK LanguageModelV3.
9
10
  */
@@ -14,7 +15,7 @@ export class AISDKLanguageModel {
14
15
  modelId;
15
16
  constructor(model) {
16
17
  this.model = model;
17
- this.provider = model.provider;
18
+ this.provider = normalizeProvider(model.provider);
18
19
  this.modelId = model.modelId;
19
20
  }
20
21
  /**
@@ -54,19 +55,19 @@ export class AISDKLanguageModel {
54
55
  const rbuf = {};
55
56
  for await (const event of convertStream(stream.stream)) {
56
57
  switch (event.kind) {
57
- case "text-start": {
58
+ case "text.start": {
58
59
  tbuf[event.id] = "";
59
60
  yield event;
60
61
  break;
61
62
  }
62
- case "text-delta": {
63
+ case "text.delta": {
63
64
  if (tbuf[event.id] !== undefined) {
64
65
  tbuf[event.id] += event.text;
65
66
  }
66
67
  yield event;
67
68
  break;
68
69
  }
69
- case "text-end": {
70
+ case "text.end": {
70
71
  const text = tbuf[event.id];
71
72
  if (text !== undefined) {
72
73
  yield message({
@@ -79,19 +80,19 @@ export class AISDKLanguageModel {
79
80
  yield event;
80
81
  break;
81
82
  }
82
- case "reasoning-start": {
83
+ case "reasoning.start": {
83
84
  rbuf[event.id] = "";
84
85
  yield event;
85
86
  break;
86
87
  }
87
- case "reasoning-delta": {
88
+ case "reasoning.delta": {
88
89
  if (rbuf[event.id] !== undefined) {
89
90
  rbuf[event.id] += event.text;
90
91
  }
91
92
  yield event;
92
93
  break;
93
94
  }
94
- case "reasoning-end": {
95
+ case "reasoning.end": {
95
96
  const text = rbuf[event.id];
96
97
  if (text !== undefined) {
97
98
  yield reasoning({
@@ -104,7 +105,7 @@ export class AISDKLanguageModel {
104
105
  break;
105
106
  }
106
107
  default:
107
- // all other events (tool-call, tool-result, finish, etc.) pass through
108
+ // all other events (tool.call, tool.result, finish, etc.) pass through
108
109
  yield event;
109
110
  break;
110
111
  }
package/dist/util.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Normalize AI SDK provider strings to base provider ID.
3
+ *
4
+ * AI SDK returns provider strings like:
5
+ * - "anthropic.messages" -> "anthropic"
6
+ * - "openai.responses" -> "openai"
7
+ * - "google.generative-ai" -> "google"
8
+ */
9
+ export declare function normalizeProvider(provider: string): string;
10
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG1D"}
package/dist/util.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Normalize AI SDK provider strings to base provider ID.
3
+ *
4
+ * AI SDK returns provider strings like:
5
+ * - "anthropic.messages" -> "anthropic"
6
+ * - "openai.responses" -> "openai"
7
+ * - "google.generative-ai" -> "google"
8
+ */
9
+ export function normalizeProvider(provider) {
10
+ const dot = provider.indexOf(".");
11
+ return dot !== -1 ? provider.slice(0, dot) : provider;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernl-sdk/ai",
3
- "version": "0.3.5",
3
+ "version": "0.4.1",
4
4
  "description": "Vercel AI SDK adapter for kernl",
5
5
  "keywords": [
6
6
  "kernl",
@@ -68,9 +68,10 @@
68
68
  "vitest": "^4.0.8"
69
69
  },
70
70
  "dependencies": {
71
- "@kernl-sdk/protocol": "0.4.2",
72
- "@kernl-sdk/retrieval": "0.1.8",
73
- "@kernl-sdk/shared": "^0.4.0"
71
+ "@kernl-sdk/protocol": "0.5.0",
72
+ "@kernl-sdk/retrieval": "0.1.9",
73
+ "@kernl-sdk/shared": "^0.4.0",
74
+ "kernl": "0.12.1"
74
75
  },
75
76
  "scripts": {
76
77
  "build": "tsc && tsc-alias --resolve-full-paths",
@@ -240,7 +240,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
240
240
  }
241
241
 
242
242
  // Should have text-delta events
243
- const textDeltas = events.filter((e) => e.kind === "text-delta");
243
+ const textDeltas = events.filter((e) => e.kind === "text.delta");
244
244
  expect(textDeltas.length).toBeGreaterThan(0);
245
245
 
246
246
  // Each text-delta should have text
@@ -302,15 +302,15 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
302
302
  expect(events.length).toBeGreaterThan(0);
303
303
 
304
304
  // Should have text-delta events (for streaming UX)
305
- const textDeltas = events.filter((e) => e.kind === "text-delta");
305
+ const textDeltas = events.filter((e) => e.kind === "text.delta");
306
306
  expect(textDeltas.length).toBeGreaterThan(0);
307
307
 
308
308
  // Should have text-start event
309
- const textStarts = events.filter((e) => e.kind === "text-start");
309
+ const textStarts = events.filter((e) => e.kind === "text.start");
310
310
  expect(textStarts.length).toBeGreaterThan(0);
311
311
 
312
312
  // Should have text-end event
313
- const textEnds = events.filter((e) => e.kind === "text-end");
313
+ const textEnds = events.filter((e) => e.kind === "text.end");
314
314
  expect(textEnds.length).toBeGreaterThan(0);
315
315
 
316
316
  // Should have complete Message item (for history)
@@ -386,7 +386,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
386
386
  expect(events.length).toBeGreaterThan(0);
387
387
 
388
388
  // Should have a tool-call event
389
- const toolCalls = events.filter((e) => e.kind === "tool-call");
389
+ const toolCalls = events.filter((e) => e.kind === "tool.call");
390
390
  expect(toolCalls.length).toBeGreaterThan(0);
391
391
 
392
392
  const toolCall = toolCalls[0] as any;
@@ -445,7 +445,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
445
445
 
446
446
  // Should have a tool call
447
447
  const toolCalls = response.content.filter(
448
- (item) => item.kind === "tool-call",
448
+ (item) => item.kind === "tool.call",
449
449
  );
450
450
  expect(toolCalls.length).toBeGreaterThan(0);
451
451
 
@@ -499,7 +499,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
499
499
 
500
500
  // Should have a tool call since it's required
501
501
  const toolCalls = response.content.filter(
502
- (item) => item.kind === "tool-call",
502
+ (item) => item.kind === "tool.call",
503
503
  );
504
504
  expect(toolCalls.length).toBeGreaterThan(0);
505
505
  });
@@ -546,7 +546,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
546
546
 
547
547
  // Should potentially have multiple tool calls
548
548
  const toolCalls = response.content.filter(
549
- (item) => item.kind === "tool-call",
549
+ (item) => item.kind === "tool.call",
550
550
  );
551
551
  expect(toolCalls.length).toBeGreaterThan(0);
552
552
  });
@@ -589,7 +589,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
589
589
 
590
590
  // Extract tool calls
591
591
  const toolCalls = firstResponse.content.filter(
592
- (item) => item.kind === "tool-call",
592
+ (item) => item.kind === "tool.call",
593
593
  );
594
594
  expect(toolCalls.length).toBeGreaterThan(0);
595
595
 
@@ -608,7 +608,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
608
608
  },
609
609
  ...firstResponse.content,
610
610
  {
611
- kind: "tool-result",
611
+ kind: "tool.result",
612
612
  callId: toolCall.callId,
613
613
  toolId: toolCall.toolId,
614
614
  state: "completed",
@@ -699,7 +699,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
699
699
 
700
700
  // Should have a tool call
701
701
  const toolCalls = response.content.filter(
702
- (item) => item.kind === "tool-call",
702
+ (item) => item.kind === "tool.call",
703
703
  );
704
704
  expect(toolCalls.length).toBeGreaterThan(0);
705
705
 
@@ -840,7 +840,7 @@ describe.skipIf(SKIP_OPENAI_TESTS)("AISDKLanguageModel - OpenAI", () => {
840
840
  expect(events.length).toBeGreaterThan(0);
841
841
 
842
842
  // Should have text-delta events for streaming JSON
843
- const textDeltas = events.filter((e) => e.kind === "text-delta");
843
+ const textDeltas = events.filter((e) => e.kind === "text.delta");
844
844
  expect(textDeltas.length).toBeGreaterThan(0);
845
845
 
846
846
  // Should have a complete message with the JSON
@@ -921,7 +921,7 @@ describe.skipIf(SKIP_ANTHROPIC_TESTS)("AISDKLanguageModel - Anthropic", () => {
921
921
 
922
922
  // Should have a tool call
923
923
  const toolCalls = response.content.filter(
924
- (item) => item.kind === "tool-call",
924
+ (item) => item.kind === "tool.call",
925
925
  );
926
926
  expect(toolCalls.length).toBeGreaterThan(0);
927
927
 
@@ -987,7 +987,7 @@ describe.skipIf(SKIP_ANTHROPIC_TESTS)("AISDKLanguageModel - Anthropic", () => {
987
987
  expect(events.length).toBeGreaterThan(0);
988
988
 
989
989
  // Should have a tool-call event
990
- const toolCalls = events.filter((e) => e.kind === "tool-call");
990
+ const toolCalls = events.filter((e) => e.kind === "tool.call");
991
991
  expect(toolCalls.length).toBeGreaterThan(0);
992
992
 
993
993
  const toolCall = toolCalls[0] as any;
@@ -1089,7 +1089,7 @@ describe.skipIf(SKIP_ANTHROPIC_TESTS)("AISDKLanguageModel - Anthropic", () => {
1089
1089
  expect(events.length).toBeGreaterThan(0);
1090
1090
 
1091
1091
  // Should have text-delta events for streaming JSON
1092
- const textDeltas = events.filter((e) => e.kind === "text-delta");
1092
+ const textDeltas = events.filter((e) => e.kind === "text.delta");
1093
1093
  expect(textDeltas.length).toBeGreaterThan(0);
1094
1094
 
1095
1095
  // Should have a complete message with the JSON
@@ -1265,7 +1265,7 @@ describe.skipIf(SKIP_GOOGLE_TESTS)("AISDKLanguageModel - Google", () => {
1265
1265
  expect(events.length).toBeGreaterThan(0);
1266
1266
 
1267
1267
  // Should have text-delta events for streaming JSON
1268
- const textDeltas = events.filter((e) => e.kind === "text-delta");
1268
+ const textDeltas = events.filter((e) => e.kind === "text.delta");
1269
1269
  expect(textDeltas.length).toBeGreaterThan(0);
1270
1270
 
1271
1271
  // Should have a complete message with the JSON
@@ -91,19 +91,19 @@ describe("AISDKLanguageModel", () => {
91
91
  expect(events).toHaveLength(7);
92
92
 
93
93
  // Check delta events
94
- expect(events[0]).toMatchObject({ kind: "text-start", id: "text-1" });
94
+ expect(events[0]).toMatchObject({ kind: "text.start", id: "text-1" });
95
95
  expect(events[1]).toMatchObject({
96
- kind: "text-delta",
96
+ kind: "text.delta",
97
97
  id: "text-1",
98
98
  text: "Hello",
99
99
  });
100
100
  expect(events[2]).toMatchObject({
101
- kind: "text-delta",
101
+ kind: "text.delta",
102
102
  id: "text-1",
103
103
  text: " ",
104
104
  });
105
105
  expect(events[3]).toMatchObject({
106
- kind: "text-delta",
106
+ kind: "text.delta",
107
107
  id: "text-1",
108
108
  text: "World",
109
109
  });
@@ -125,7 +125,7 @@ describe("AISDKLanguageModel", () => {
125
125
  expect(messageEvent.id).toBeDefined();
126
126
 
127
127
  // Check end event (yielded after Message)
128
- expect(events[5]).toMatchObject({ kind: "text-end", id: "text-1" });
128
+ expect(events[5]).toMatchObject({ kind: "text.end", id: "text-1" });
129
129
 
130
130
  // Check finish event
131
131
  expect(events[6]).toMatchObject({ kind: "finish" });
@@ -204,16 +204,16 @@ describe("AISDKLanguageModel", () => {
204
204
 
205
205
  // Check delta events
206
206
  expect(events[0]).toMatchObject({
207
- kind: "reasoning-start",
207
+ kind: "reasoning.start",
208
208
  id: "reason-1",
209
209
  });
210
210
  expect(events[1]).toMatchObject({
211
- kind: "reasoning-delta",
211
+ kind: "reasoning.delta",
212
212
  id: "reason-1",
213
213
  text: "Let me think",
214
214
  });
215
215
  expect(events[2]).toMatchObject({
216
- kind: "reasoning-delta",
216
+ kind: "reasoning.delta",
217
217
  id: "reason-1",
218
218
  text: " about this",
219
219
  });
@@ -230,7 +230,7 @@ describe("AISDKLanguageModel", () => {
230
230
 
231
231
  // Check end event (yielded after Reasoning)
232
232
  expect(events[4]).toMatchObject({
233
- kind: "reasoning-end",
233
+ kind: "reasoning.end",
234
234
  id: "reason-1",
235
235
  });
236
236
 
@@ -453,7 +453,7 @@ describe("AISDKLanguageModel", () => {
453
453
  expect(events).toHaveLength(2);
454
454
 
455
455
  expect(events[0]).toMatchObject({
456
- kind: "tool-call",
456
+ kind: "tool.call",
457
457
  callId: "call-123",
458
458
  toolId: "calculator",
459
459
  state: IN_PROGRESS,
@@ -212,7 +212,7 @@ describe("MESSAGE codec", () => {
212
212
  describe("encode - tool-call items", () => {
213
213
  it("should encode tool-call item", () => {
214
214
  const result = MESSAGE.encode({
215
- kind: "tool-call",
215
+ kind: "tool.call",
216
216
  callId: "call-123",
217
217
  toolId: "get_weather",
218
218
  state: "completed",
@@ -225,7 +225,7 @@ describe("MESSAGE codec", () => {
225
225
  {
226
226
  type: "tool-call",
227
227
  toolCallId: "call-123",
228
- toolName: "get_weather",
228
+ toolId: "get_weather",
229
229
  input: { city: "SF" },
230
230
  providerOptions: undefined,
231
231
  },
@@ -235,7 +235,7 @@ describe("MESSAGE codec", () => {
235
235
 
236
236
  it("should include providerMetadata for tool-call", () => {
237
237
  const result = MESSAGE.encode({
238
- kind: "tool-call",
238
+ kind: "tool.call",
239
239
  callId: "call-123",
240
240
  toolId: "get_weather",
241
241
  state: "completed",
@@ -253,7 +253,7 @@ describe("MESSAGE codec", () => {
253
253
  describe("encode - tool-result items", () => {
254
254
  it("should encode tool-result item", () => {
255
255
  const result = MESSAGE.encode({
256
- kind: "tool-result",
256
+ kind: "tool.result",
257
257
  callId: "call-123",
258
258
  toolId: "get_weather",
259
259
  state: "completed",
@@ -267,7 +267,7 @@ describe("MESSAGE codec", () => {
267
267
  {
268
268
  type: "tool-result",
269
269
  toolCallId: "call-123",
270
- toolName: "get_weather",
270
+ toolId: "get_weather",
271
271
  output: {
272
272
  type: "json",
273
273
  value: { temp: 72, conditions: "sunny" },
@@ -280,7 +280,7 @@ describe("MESSAGE codec", () => {
280
280
 
281
281
  it("should encode tool-result item with error", () => {
282
282
  const result = MESSAGE.encode({
283
- kind: "tool-result",
283
+ kind: "tool.result",
284
284
  callId: "call-123",
285
285
  toolId: "get_weather",
286
286
  state: "failed",
@@ -294,7 +294,7 @@ describe("MESSAGE codec", () => {
294
294
  {
295
295
  type: "tool-result",
296
296
  toolCallId: "call-123",
297
- toolName: "get_weather",
297
+ toolId: "get_weather",
298
298
  output: {
299
299
  type: "error-text",
300
300
  value: "Network timeout",
@@ -109,7 +109,7 @@ describe("MODEL_SETTINGS codec", () => {
109
109
  const result = MODEL_SETTINGS.encode(settings);
110
110
 
111
111
  expect(result).toEqual({
112
- toolChoice: { type: "tool", toolName: "get_weather" },
112
+ toolChoice: { type: "tool", toolId: "get_weather" },
113
113
  });
114
114
  });
115
115