@kernl-sdk/ai 0.3.4 → 0.4.0

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.
@@ -16,7 +16,7 @@ describe("STREAM_PART codec", () => {
16
16
  const result = STREAM_PART.decode(part);
17
17
 
18
18
  expect(result).toEqual({
19
- kind: "text-start",
19
+ kind: "text.start",
20
20
  id: "text-1",
21
21
  providerMetadata: { openai: { data: "value" } },
22
22
  });
@@ -33,7 +33,7 @@ describe("STREAM_PART codec", () => {
33
33
  const result = STREAM_PART.decode(part);
34
34
 
35
35
  expect(result).toEqual({
36
- kind: "text-delta",
36
+ kind: "text.delta",
37
37
  id: "text-1",
38
38
  text: "Hello",
39
39
  providerMetadata: undefined,
@@ -50,7 +50,7 @@ describe("STREAM_PART codec", () => {
50
50
  const result = STREAM_PART.decode(part);
51
51
 
52
52
  expect(result).toEqual({
53
- kind: "text-end",
53
+ kind: "text.end",
54
54
  id: "text-1",
55
55
  providerMetadata: undefined,
56
56
  });
@@ -68,7 +68,7 @@ describe("STREAM_PART codec", () => {
68
68
  const result = STREAM_PART.decode(part);
69
69
 
70
70
  expect(result).toEqual({
71
- kind: "reasoning-start",
71
+ kind: "reasoning.start",
72
72
  id: "reason-1",
73
73
  providerMetadata: undefined,
74
74
  });
@@ -85,7 +85,7 @@ describe("STREAM_PART codec", () => {
85
85
  const result = STREAM_PART.decode(part);
86
86
 
87
87
  expect(result).toEqual({
88
- kind: "reasoning-delta",
88
+ kind: "reasoning.delta",
89
89
  id: "reason-1",
90
90
  text: "thinking...",
91
91
  providerMetadata: undefined,
@@ -102,7 +102,7 @@ describe("STREAM_PART codec", () => {
102
102
  const result = STREAM_PART.decode(part);
103
103
 
104
104
  expect(result).toEqual({
105
- kind: "reasoning-end",
105
+ kind: "reasoning.end",
106
106
  id: "reason-1",
107
107
  providerMetadata: undefined,
108
108
  });
@@ -122,9 +122,9 @@ describe("STREAM_PART codec", () => {
122
122
  const result = STREAM_PART.decode(part);
123
123
 
124
124
  expect(result).toEqual({
125
- kind: "tool-input-start",
125
+ kind: "tool.input.start",
126
126
  id: "tool-1",
127
- toolName: "calculator",
127
+ toolId: "calculator",
128
128
  title: "Calculate",
129
129
  providerMetadata: undefined,
130
130
  });
@@ -141,7 +141,7 @@ describe("STREAM_PART codec", () => {
141
141
  const result = STREAM_PART.decode(part);
142
142
 
143
143
  expect(result).toEqual({
144
- kind: "tool-input-delta",
144
+ kind: "tool.input.delta",
145
145
  id: "tool-1",
146
146
  delta: "partial input",
147
147
  providerMetadata: undefined,
@@ -158,7 +158,7 @@ describe("STREAM_PART codec", () => {
158
158
  const result = STREAM_PART.decode(part);
159
159
 
160
160
  expect(result).toEqual({
161
- kind: "tool-input-end",
161
+ kind: "tool.input.end",
162
162
  id: "tool-1",
163
163
  providerMetadata: undefined,
164
164
  });
@@ -176,7 +176,7 @@ describe("STREAM_PART codec", () => {
176
176
  const result = STREAM_PART.decode(part);
177
177
 
178
178
  expect(result).toEqual({
179
- kind: "tool-call",
179
+ kind: "tool.call",
180
180
  callId: "call-123",
181
181
  toolId: "get_weather",
182
182
  state: IN_PROGRESS,
@@ -197,7 +197,7 @@ describe("STREAM_PART codec", () => {
197
197
  const result = STREAM_PART.decode(part);
198
198
 
199
199
  expect(result).toEqual({
200
- kind: "tool-call",
200
+ kind: "tool.call",
201
201
  callId: "call-empty",
202
202
  toolId: "list_issues",
203
203
  state: IN_PROGRESS,
@@ -219,7 +219,7 @@ describe("STREAM_PART codec", () => {
219
219
  const result = STREAM_PART.decode(part);
220
220
 
221
221
  expect(result).toEqual({
222
- kind: "tool-result",
222
+ kind: "tool.result",
223
223
  callId: "call-123",
224
224
  toolId: "get_weather",
225
225
  state: "completed",
@@ -242,7 +242,7 @@ describe("STREAM_PART codec", () => {
242
242
  const result = STREAM_PART.decode(part);
243
243
 
244
244
  expect(result).toEqual({
245
- kind: "tool-result",
245
+ kind: "tool.result",
246
246
  callId: "call-123",
247
247
  toolId: "get_weather",
248
248
  state: "failed",
@@ -268,7 +268,7 @@ describe("STREAM_PART codec", () => {
268
268
  const result = STREAM_PART.decode(part);
269
269
 
270
270
  expect(result).toEqual({
271
- kind: "stream-start",
271
+ kind: "stream.start",
272
272
  warnings: [
273
273
  {
274
274
  type: "unsupported-setting",
@@ -426,9 +426,9 @@ describe("convertStream", () => {
426
426
  }
427
427
 
428
428
  expect(events).toHaveLength(4);
429
- expect(events[0]).toMatchObject({ kind: "text-start" });
430
- expect(events[1]).toMatchObject({ kind: "text-delta", text: "Hello" });
431
- expect(events[2]).toMatchObject({ kind: "text-end" });
429
+ expect(events[0]).toMatchObject({ kind: "text.start" });
430
+ expect(events[1]).toMatchObject({ kind: "text.delta", text: "Hello" });
431
+ expect(events[2]).toMatchObject({ kind: "text.end" });
432
432
  expect(events[3]).toMatchObject({ kind: "finish", finishReason: "stop" });
433
433
  });
434
434
 
@@ -466,7 +466,7 @@ describe("convertStream", () => {
466
466
  }
467
467
 
468
468
  expect(events).toHaveLength(2);
469
- expect(events[0]).toMatchObject({ kind: "text-delta" });
469
+ expect(events[0]).toMatchObject({ kind: "text.delta" });
470
470
  expect(events[1]).toMatchObject({ kind: "finish" });
471
471
  });
472
472
 
@@ -164,7 +164,7 @@ describe("TOOL_CHOICE codec", () => {
164
164
 
165
165
  expect(result).toEqual({
166
166
  type: "tool",
167
- toolName: "get_weather",
167
+ toolId: "get_weather",
168
168
  });
169
169
  });
170
170
  });
@@ -424,7 +424,7 @@ describe("UIMessageCodec", () => {
424
424
 
425
425
  expect(result).toHaveLength(1);
426
426
  expect(result[0]).toMatchObject({
427
- kind: "tool-call",
427
+ kind: "tool.call",
428
428
  callId: "call-1",
429
429
  toolId: "calculator",
430
430
  state: IN_PROGRESS,
@@ -449,7 +449,7 @@ describe("UIMessageCodec", () => {
449
449
 
450
450
  expect(result).toHaveLength(1);
451
451
  expect(result[0]).toMatchObject({
452
- kind: "tool-result",
452
+ kind: "tool.result",
453
453
  callId: "call-1",
454
454
  toolId: "calculator",
455
455
  state: COMPLETED,
@@ -475,7 +475,7 @@ describe("UIMessageCodec", () => {
475
475
 
476
476
  expect(result).toHaveLength(1);
477
477
  expect(result[0]).toMatchObject({
478
- kind: "tool-result",
478
+ kind: "tool.result",
479
479
  callId: "call-1",
480
480
  toolId: "calculator",
481
481
  state: FAILED,
@@ -525,7 +525,7 @@ describe("UIMessageCodec", () => {
525
525
 
526
526
  expect(result).toHaveLength(1);
527
527
  expect(result[0]).toMatchObject({
528
- kind: "tool-call",
528
+ kind: "tool.call",
529
529
  callId: "call-1",
530
530
  toolId: "weather",
531
531
  providerMetadata: {
@@ -554,7 +554,7 @@ describe("UIMessageCodec", () => {
554
554
 
555
555
  expect(result).toHaveLength(1);
556
556
  expect(result[0]).toMatchObject({
557
- kind: "tool-result",
557
+ kind: "tool.result",
558
558
  callId: "call-1",
559
559
  toolId: "weather",
560
560
  providerMetadata: {
@@ -582,7 +582,7 @@ describe("UIMessageCodec", () => {
582
582
 
583
583
  expect(result).toHaveLength(1);
584
584
  expect(result[0]).toMatchObject({
585
- kind: "tool-call",
585
+ kind: "tool.call",
586
586
  callId: "call-1",
587
587
  toolId: "screenshot",
588
588
  state: IN_PROGRESS,
@@ -608,7 +608,7 @@ describe("UIMessageCodec", () => {
608
608
 
609
609
  expect(result).toHaveLength(1);
610
610
  expect(result[0]).toMatchObject({
611
- kind: "tool-result",
611
+ kind: "tool.result",
612
612
  callId: "call-1",
613
613
  toolId: "screenshot",
614
614
  state: COMPLETED,
@@ -635,7 +635,7 @@ describe("UIMessageCodec", () => {
635
635
 
636
636
  expect(result).toHaveLength(1);
637
637
  expect(result[0]).toMatchObject({
638
- kind: "tool-result",
638
+ kind: "tool.result",
639
639
  callId: "call-1",
640
640
  toolId: "screenshot",
641
641
  state: FAILED,
@@ -673,12 +673,12 @@ describe("UIMessageCodec", () => {
673
673
  content: [{ kind: "text", text: "Let me help with that" }],
674
674
  });
675
675
  expect(result[1]).toMatchObject({
676
- kind: "tool-call",
676
+ kind: "tool.call",
677
677
  callId: "call-1",
678
678
  toolId: "calculator",
679
679
  });
680
680
  expect(result[2]).toMatchObject({
681
- kind: "tool-call",
681
+ kind: "tool.call",
682
682
  callId: "call-2",
683
683
  toolId: "weather",
684
684
  });
@@ -713,11 +713,11 @@ describe("UIMessageCodec", () => {
713
713
  content: [{ kind: "text", text: "The result is 3" }],
714
714
  });
715
715
  expect(result[1]).toMatchObject({
716
- kind: "tool-result",
716
+ kind: "tool.result",
717
717
  callId: "call-1",
718
718
  });
719
719
  expect(result[2]).toMatchObject({
720
- kind: "tool-call",
720
+ kind: "tool.call",
721
721
  callId: "call-2",
722
722
  });
723
723
  });
@@ -745,11 +745,11 @@ describe("UIMessageCodec", () => {
745
745
 
746
746
  expect(result).toHaveLength(2);
747
747
  expect(result[0]).toMatchObject({
748
- kind: "tool-call",
748
+ kind: "tool.call",
749
749
  toolId: "calculator",
750
750
  });
751
751
  expect(result[1]).toMatchObject({
752
- kind: "tool-call",
752
+ kind: "tool.call",
753
753
  toolId: "screenshot",
754
754
  });
755
755
  });
@@ -772,7 +772,7 @@ describe("UIMessageCodec", () => {
772
772
  });
773
773
 
774
774
  expect(result[0]).toMatchObject({
775
- kind: "tool-result",
775
+ kind: "tool.result",
776
776
  result: "result string",
777
777
  });
778
778
  });
@@ -793,7 +793,7 @@ describe("UIMessageCodec", () => {
793
793
  });
794
794
 
795
795
  expect(result[0]).toMatchObject({
796
- kind: "tool-result",
796
+ kind: "tool.result",
797
797
  result: 42,
798
798
  });
799
799
  });
@@ -818,7 +818,7 @@ describe("UIMessageCodec", () => {
818
818
  });
819
819
 
820
820
  expect(result[0]).toMatchObject({
821
- kind: "tool-result",
821
+ kind: "tool.result",
822
822
  result: {
823
823
  temperature: 20,
824
824
  condition: "sunny",
@@ -843,7 +843,7 @@ describe("UIMessageCodec", () => {
843
843
  });
844
844
 
845
845
  expect(result[0]).toMatchObject({
846
- kind: "tool-result",
846
+ kind: "tool.result",
847
847
  result: ["result1", "result2", "result3"],
848
848
  });
849
849
  });
@@ -864,7 +864,7 @@ describe("UIMessageCodec", () => {
864
864
  });
865
865
 
866
866
  expect(result[0]).toMatchObject({
867
- kind: "tool-result",
867
+ kind: "tool.result",
868
868
  result: null,
869
869
  });
870
870
  });
@@ -884,7 +884,7 @@ describe("UIMessageCodec", () => {
884
884
  });
885
885
 
886
886
  expect(result[0]).toMatchObject({
887
- kind: "tool-call",
887
+ kind: "tool.call",
888
888
  arguments: "{}",
889
889
  });
890
890
  });
@@ -1448,14 +1448,14 @@ describe("historyToUIMessages", () => {
1448
1448
  content: [{ kind: "text", text: "Let me calculate that." }],
1449
1449
  },
1450
1450
  {
1451
- kind: "tool-call",
1451
+ kind: "tool.call",
1452
1452
  callId: "call-1",
1453
1453
  toolId: "calculator",
1454
1454
  state: IN_PROGRESS,
1455
1455
  arguments: JSON.stringify({ operation: "add", numbers: [1, 2] }),
1456
1456
  },
1457
1457
  {
1458
- kind: "tool-result",
1458
+ kind: "tool.result",
1459
1459
  callId: "call-1",
1460
1460
  toolId: "calculator",
1461
1461
  state: COMPLETED,
@@ -1475,7 +1475,7 @@ describe("historyToUIMessages", () => {
1475
1475
  {
1476
1476
  type: "tool-calculator",
1477
1477
  toolCallId: "call-1",
1478
- toolName: "calculator",
1478
+ toolId: "calculator",
1479
1479
  input: { operation: "add", numbers: [1, 2] },
1480
1480
  state: "output-available",
1481
1481
  output: 3,
@@ -1494,14 +1494,14 @@ describe("historyToUIMessages", () => {
1494
1494
  content: [{ kind: "text", text: "Let me try that." }],
1495
1495
  },
1496
1496
  {
1497
- kind: "tool-call",
1497
+ kind: "tool.call",
1498
1498
  callId: "call-1",
1499
1499
  toolId: "calculator",
1500
1500
  state: IN_PROGRESS,
1501
1501
  arguments: JSON.stringify({ operation: "divide", numbers: [1, 0] }),
1502
1502
  },
1503
1503
  {
1504
- kind: "tool-result",
1504
+ kind: "tool.result",
1505
1505
  callId: "call-1",
1506
1506
  toolId: "calculator",
1507
1507
  state: FAILED,
@@ -1521,7 +1521,7 @@ describe("historyToUIMessages", () => {
1521
1521
  {
1522
1522
  type: "tool-calculator",
1523
1523
  toolCallId: "call-1",
1524
- toolName: "calculator",
1524
+ toolId: "calculator",
1525
1525
  input: { operation: "divide", numbers: [1, 0] },
1526
1526
  state: "output-error",
1527
1527
  errorText: "Division by zero",
@@ -1540,7 +1540,7 @@ describe("historyToUIMessages", () => {
1540
1540
  content: [{ kind: "text", text: "Processing..." }],
1541
1541
  },
1542
1542
  {
1543
- kind: "tool-call",
1543
+ kind: "tool.call",
1544
1544
  callId: "call-1",
1545
1545
  toolId: "search",
1546
1546
  state: IN_PROGRESS,
@@ -1559,7 +1559,7 @@ describe("historyToUIMessages", () => {
1559
1559
  {
1560
1560
  type: "tool-search",
1561
1561
  toolCallId: "call-1",
1562
- toolName: "search",
1562
+ toolId: "search",
1563
1563
  input: { query: "weather" },
1564
1564
  state: "input-available",
1565
1565
  },
@@ -1577,14 +1577,14 @@ describe("historyToUIMessages", () => {
1577
1577
  content: [{ kind: "text", text: "I'll use multiple tools." }],
1578
1578
  },
1579
1579
  {
1580
- kind: "tool-call",
1580
+ kind: "tool.call",
1581
1581
  callId: "call-1",
1582
1582
  toolId: "tool1",
1583
1583
  state: IN_PROGRESS,
1584
1584
  arguments: JSON.stringify({ value: "value-1" }),
1585
1585
  },
1586
1586
  {
1587
- kind: "tool-result",
1587
+ kind: "tool.result",
1588
1588
  callId: "call-1",
1589
1589
  toolId: "tool1",
1590
1590
  state: COMPLETED,
@@ -1592,14 +1592,14 @@ describe("historyToUIMessages", () => {
1592
1592
  error: null,
1593
1593
  },
1594
1594
  {
1595
- kind: "tool-call",
1595
+ kind: "tool.call",
1596
1596
  callId: "call-2",
1597
1597
  toolId: "tool2",
1598
1598
  state: IN_PROGRESS,
1599
1599
  arguments: JSON.stringify({ value: "value-2" }),
1600
1600
  },
1601
1601
  {
1602
- kind: "tool-result",
1602
+ kind: "tool.result",
1603
1603
  callId: "call-2",
1604
1604
  toolId: "tool2",
1605
1605
  state: COMPLETED,
@@ -1607,14 +1607,14 @@ describe("historyToUIMessages", () => {
1607
1607
  error: null,
1608
1608
  },
1609
1609
  {
1610
- kind: "tool-call",
1610
+ kind: "tool.call",
1611
1611
  callId: "call-3",
1612
1612
  toolId: "tool3",
1613
1613
  state: IN_PROGRESS,
1614
1614
  arguments: JSON.stringify({ value: "value-3" }),
1615
1615
  },
1616
1616
  {
1617
- kind: "tool-result",
1617
+ kind: "tool.result",
1618
1618
  callId: "call-3",
1619
1619
  toolId: "tool3",
1620
1620
  state: COMPLETED,
@@ -1634,7 +1634,7 @@ describe("historyToUIMessages", () => {
1634
1634
  {
1635
1635
  type: "tool-tool1",
1636
1636
  toolCallId: "call-1",
1637
- toolName: "tool1",
1637
+ toolId: "tool1",
1638
1638
  input: { value: "value-1" },
1639
1639
  state: "output-available",
1640
1640
  output: "result-1",
@@ -1642,7 +1642,7 @@ describe("historyToUIMessages", () => {
1642
1642
  {
1643
1643
  type: "tool-tool2",
1644
1644
  toolCallId: "call-2",
1645
- toolName: "tool2",
1645
+ toolId: "tool2",
1646
1646
  input: { value: "value-2" },
1647
1647
  state: "output-available",
1648
1648
  output: "result-2",
@@ -1650,7 +1650,7 @@ describe("historyToUIMessages", () => {
1650
1650
  {
1651
1651
  type: "tool-tool3",
1652
1652
  toolCallId: "call-3",
1653
- toolName: "tool3",
1653
+ toolId: "tool3",
1654
1654
  input: { value: "value-3" },
1655
1655
  state: "output-available",
1656
1656
  output: "result-3",
@@ -1669,7 +1669,7 @@ describe("historyToUIMessages", () => {
1669
1669
  content: [{ kind: "text", text: "Response" }],
1670
1670
  },
1671
1671
  {
1672
- kind: "tool-result",
1672
+ kind: "tool.result",
1673
1673
  callId: "orphan-1",
1674
1674
  toolId: "calculator",
1675
1675
  state: COMPLETED,
@@ -1698,14 +1698,14 @@ describe("historyToUIMessages", () => {
1698
1698
  content: [{ kind: "text", text: "Using tool" }],
1699
1699
  },
1700
1700
  {
1701
- kind: "tool-call",
1701
+ kind: "tool.call",
1702
1702
  callId: "call-1",
1703
1703
  toolId: "search",
1704
1704
  state: IN_PROGRESS,
1705
1705
  arguments: JSON.stringify({ query: "test" }),
1706
1706
  },
1707
1707
  {
1708
- kind: "tool-result",
1708
+ kind: "tool.result",
1709
1709
  callId: "call-1",
1710
1710
  toolId: "search",
1711
1711
  state: COMPLETED,
@@ -1731,7 +1731,7 @@ describe("historyToUIMessages", () => {
1731
1731
  {
1732
1732
  type: "tool-search",
1733
1733
  toolCallId: "call-1",
1734
- toolName: "search",
1734
+ toolId: "search",
1735
1735
  input: { query: "test" },
1736
1736
  state: "output-available",
1737
1737
  output: "found it",
@@ -1934,14 +1934,14 @@ describe("historyToUIMessages", () => {
1934
1934
  text: "The image shows numerical data",
1935
1935
  },
1936
1936
  {
1937
- kind: "tool-call",
1937
+ kind: "tool.call",
1938
1938
  callId: "call-1",
1939
1939
  toolId: "calculator",
1940
1940
  state: IN_PROGRESS,
1941
1941
  arguments: JSON.stringify({ operation: "sum", values: [10, 20, 30] }),
1942
1942
  },
1943
1943
  {
1944
- kind: "tool-result",
1944
+ kind: "tool.result",
1945
1945
  callId: "call-1",
1946
1946
  toolId: "calculator",
1947
1947
  state: COMPLETED,
@@ -1987,7 +1987,7 @@ describe("historyToUIMessages", () => {
1987
1987
  {
1988
1988
  type: "tool-calculator",
1989
1989
  toolCallId: "call-1",
1990
- toolName: "calculator",
1990
+ toolId: "calculator",
1991
1991
  input: { operation: "sum", values: [10, 20, 30] },
1992
1992
  state: "output-available",
1993
1993
  output: 60,