@kernl-sdk/ai 0.2.10 → 0.3.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.
@@ -1,130 +0,0 @@
1
- export const messages = {
2
- encode: (kernlItems) => {
3
- const aiMessages = [];
4
- for (const item of kernlItems) {
5
- if (item.kind === "message") {
6
- // Convert Kernl Message to AI SDK Message
7
- if (item.role === "system") {
8
- // System messages must have string content in AI SDK
9
- const textContent = item.content
10
- .filter((part) => part.kind === "text")
11
- .map((part) => (part.kind === "text" ? part.text : ""))
12
- .join("\n");
13
- aiMessages.push({
14
- role: "system",
15
- content: textContent,
16
- providerOptions: item.providerMetadata,
17
- });
18
- }
19
- else if (item.role === "user") {
20
- // User messages have array of text/file parts
21
- const content = [];
22
- for (const part of item.content) {
23
- if (part.kind === "text") {
24
- content.push({
25
- type: "text",
26
- text: part.text,
27
- providerOptions: part.providerMetadata,
28
- });
29
- }
30
- else if (part.kind === "file") {
31
- content.push({
32
- type: "file",
33
- filename: part.filename,
34
- data: part.data,
35
- mediaType: part.mimeType,
36
- providerOptions: part.providerMetadata,
37
- });
38
- }
39
- // TODO: Handle DataPart
40
- }
41
- aiMessages.push({
42
- role: "user",
43
- content,
44
- providerOptions: item.providerMetadata,
45
- });
46
- }
47
- else if (item.role === "assistant") {
48
- // Assistant messages can have text, file, reasoning, tool call parts
49
- const content = [];
50
- for (const part of item.content) {
51
- if (part.kind === "text") {
52
- content.push({
53
- type: "text",
54
- text: part.text,
55
- providerOptions: part.providerMetadata,
56
- });
57
- }
58
- else if (part.kind === "file") {
59
- content.push({
60
- type: "file",
61
- filename: part.filename,
62
- data: part.data,
63
- mediaType: part.mimeType,
64
- providerOptions: part.providerMetadata,
65
- });
66
- }
67
- // TODO: Handle DataPart
68
- }
69
- aiMessages.push({
70
- role: "assistant",
71
- content,
72
- providerOptions: item.providerMetadata,
73
- });
74
- }
75
- }
76
- else if (item.kind === "reasoning") {
77
- // Reasoning should be part of an assistant message
78
- // For now, create a standalone assistant message with reasoning
79
- aiMessages.push({
80
- role: "assistant",
81
- content: [
82
- {
83
- type: "reasoning",
84
- text: item.text,
85
- providerOptions: item.providerMetadata,
86
- },
87
- ],
88
- });
89
- }
90
- else if (item.kind === "tool-call") {
91
- // Tool calls should be part of an assistant message
92
- // For now, create a standalone assistant message with tool call
93
- aiMessages.push({
94
- role: "assistant",
95
- content: [
96
- {
97
- type: "tool-call",
98
- toolCallId: item.callId,
99
- toolName: item.toolId,
100
- input: JSON.parse(item.arguments),
101
- providerOptions: item.providerMetadata,
102
- },
103
- ],
104
- });
105
- }
106
- else if (item.kind === "tool-result") {
107
- // Tool results go into a separate 'tool' role message
108
- aiMessages.push({
109
- role: "tool",
110
- content: [
111
- {
112
- type: "tool-result",
113
- toolCallId: item.callId,
114
- toolName: item.toolId,
115
- output: {
116
- type: "json",
117
- value: item.result,
118
- },
119
- providerOptions: item.providerMetadata,
120
- },
121
- ],
122
- });
123
- }
124
- }
125
- return aiMessages;
126
- },
127
- decode: () => {
128
- throw new Error("codec:unimplemented");
129
- },
130
- };
package/dist/error.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Wrap AI SDK errors with additional context.
3
- *
4
- * @param error - The error from AI SDK
5
- * @param context - Additional context about where the error occurred
6
- */
7
- export declare function wrapError(error: unknown, context: string): Error;
8
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAShE"}
package/dist/error.js DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * Wrap AI SDK errors with additional context.
3
- *
4
- * @param error - The error from AI SDK
5
- * @param context - Additional context about where the error occurred
6
- */
7
- export function wrapError(error, context) {
8
- if (error instanceof Error) {
9
- const wrapped = new Error(`AI SDK error in ${context}: ${error.message}`);
10
- wrapped.stack = error.stack;
11
- wrapped.cause = error;
12
- return wrapped;
13
- }
14
- return new Error(`AI SDK error in ${context}: ${String(error)}`);
15
- }
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- "use strict";