@inkeep/ai-sdk-provider 0.0.0-dev-20251222193816 → 0.0.0-dev-20251222214618

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 (40) hide show
  1. package/dist/convert-to-inkeep-messages.cjs +82 -0
  2. package/dist/convert-to-inkeep-messages.d.cts +7 -0
  3. package/dist/convert-to-inkeep-messages.d.ts +7 -0
  4. package/dist/convert-to-inkeep-messages.js +81 -0
  5. package/dist/get-response-metadata.cjs +12 -0
  6. package/dist/get-response-metadata.d.cts +10 -0
  7. package/dist/get-response-metadata.d.ts +10 -0
  8. package/dist/get-response-metadata.js +11 -0
  9. package/dist/index.cjs +5 -3511
  10. package/dist/index.d.cts +6 -197
  11. package/dist/index.d.ts +6 -198
  12. package/dist/index.js +3 -3510
  13. package/dist/inkeep-chat-language-model.cjs +270 -0
  14. package/dist/inkeep-chat-language-model.d.cts +81 -0
  15. package/dist/inkeep-chat-language-model.d.ts +81 -0
  16. package/dist/inkeep-chat-language-model.js +269 -0
  17. package/dist/inkeep-chat-options.cjs +0 -0
  18. package/dist/inkeep-chat-options.d.cts +8 -0
  19. package/dist/inkeep-chat-options.d.ts +8 -0
  20. package/dist/inkeep-chat-options.js +1 -0
  21. package/dist/inkeep-chat-prompt.cjs +0 -0
  22. package/dist/inkeep-chat-prompt.d.cts +84 -0
  23. package/dist/inkeep-chat-prompt.d.ts +84 -0
  24. package/dist/inkeep-chat-prompt.js +1 -0
  25. package/dist/inkeep-error.cjs +20 -0
  26. package/dist/inkeep-error.d.cts +18 -0
  27. package/dist/inkeep-error.d.ts +18 -0
  28. package/dist/inkeep-error.js +20 -0
  29. package/dist/inkeep-provider.cjs +35 -0
  30. package/dist/inkeep-provider.d.cts +18 -0
  31. package/dist/inkeep-provider.d.ts +18 -0
  32. package/dist/inkeep-provider.js +34 -0
  33. package/dist/map-inkeep-finish-reason.cjs +15 -0
  34. package/dist/map-inkeep-finish-reason.d.cts +7 -0
  35. package/dist/map-inkeep-finish-reason.d.ts +7 -0
  36. package/dist/map-inkeep-finish-reason.js +14 -0
  37. package/package.json +4 -3
  38. package/dist/index.d.cts.map +0 -1
  39. package/dist/index.d.ts.map +0 -1
  40. package/dist/index.js.map +0 -1
@@ -0,0 +1,82 @@
1
+
2
+ //#region src/convert-to-inkeep-messages.ts
3
+ function convertToInkeepChatMessages(prompt) {
4
+ const messages = [];
5
+ for (const { role, content } of prompt) switch (role) {
6
+ case "system":
7
+ messages.push({
8
+ role: "system",
9
+ content
10
+ });
11
+ break;
12
+ case "user": {
13
+ const contentParts = [];
14
+ for (const part of content) switch (part.type) {
15
+ case "text":
16
+ contentParts.push({
17
+ type: "text",
18
+ text: part.text
19
+ });
20
+ break;
21
+ case "file": throw new Error("File content is not yet supported by Inkeep provider");
22
+ default: {
23
+ const _exhaustiveCheck = part;
24
+ throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
25
+ }
26
+ }
27
+ messages.push({
28
+ role: "user",
29
+ content: contentParts.length === 1 ? contentParts[0].text ?? "" : contentParts
30
+ });
31
+ break;
32
+ }
33
+ case "assistant": {
34
+ let text = "";
35
+ const toolCalls = [];
36
+ for (const part of content) switch (part.type) {
37
+ case "text":
38
+ text += part.text;
39
+ break;
40
+ case "tool-call":
41
+ toolCalls.push({
42
+ id: part.toolCallId,
43
+ type: "function",
44
+ function: {
45
+ name: part.toolName,
46
+ arguments: JSON.stringify(part.input)
47
+ }
48
+ });
49
+ break;
50
+ case "file": throw new Error("File content is not yet supported by Inkeep provider");
51
+ case "reasoning":
52
+ text += part.text;
53
+ break;
54
+ case "tool-result": throw new Error("Tool result content should not appear in assistant messages");
55
+ default: {
56
+ const _exhaustiveCheck = part;
57
+ throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
58
+ }
59
+ }
60
+ messages.push({
61
+ role: "assistant",
62
+ content: text || ""
63
+ });
64
+ break;
65
+ }
66
+ case "tool":
67
+ for (const toolResponse of content) messages.push({
68
+ role: "tool",
69
+ content: JSON.stringify(toolResponse.output),
70
+ name: toolResponse.toolName
71
+ });
72
+ break;
73
+ default: {
74
+ const _exhaustiveCheck = role;
75
+ throw new Error(`Unsupported message role: ${_exhaustiveCheck}`);
76
+ }
77
+ }
78
+ return messages;
79
+ }
80
+
81
+ //#endregion
82
+ exports.convertToInkeepChatMessages = convertToInkeepChatMessages;
@@ -0,0 +1,7 @@
1
+ import { InkeepChatMessage } from "./inkeep-chat-prompt.cjs";
2
+ import { LanguageModelV2Prompt } from "@ai-sdk/provider";
3
+
4
+ //#region src/convert-to-inkeep-messages.d.ts
5
+ declare function convertToInkeepChatMessages(prompt: LanguageModelV2Prompt): Array<InkeepChatMessage>;
6
+ //#endregion
7
+ export { convertToInkeepChatMessages };
@@ -0,0 +1,7 @@
1
+ import { InkeepChatMessage } from "./inkeep-chat-prompt.js";
2
+ import { LanguageModelV2Prompt } from "@ai-sdk/provider";
3
+
4
+ //#region src/convert-to-inkeep-messages.d.ts
5
+ declare function convertToInkeepChatMessages(prompt: LanguageModelV2Prompt): Array<InkeepChatMessage>;
6
+ //#endregion
7
+ export { convertToInkeepChatMessages };
@@ -0,0 +1,81 @@
1
+ //#region src/convert-to-inkeep-messages.ts
2
+ function convertToInkeepChatMessages(prompt) {
3
+ const messages = [];
4
+ for (const { role, content } of prompt) switch (role) {
5
+ case "system":
6
+ messages.push({
7
+ role: "system",
8
+ content
9
+ });
10
+ break;
11
+ case "user": {
12
+ const contentParts = [];
13
+ for (const part of content) switch (part.type) {
14
+ case "text":
15
+ contentParts.push({
16
+ type: "text",
17
+ text: part.text
18
+ });
19
+ break;
20
+ case "file": throw new Error("File content is not yet supported by Inkeep provider");
21
+ default: {
22
+ const _exhaustiveCheck = part;
23
+ throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
24
+ }
25
+ }
26
+ messages.push({
27
+ role: "user",
28
+ content: contentParts.length === 1 ? contentParts[0].text ?? "" : contentParts
29
+ });
30
+ break;
31
+ }
32
+ case "assistant": {
33
+ let text = "";
34
+ const toolCalls = [];
35
+ for (const part of content) switch (part.type) {
36
+ case "text":
37
+ text += part.text;
38
+ break;
39
+ case "tool-call":
40
+ toolCalls.push({
41
+ id: part.toolCallId,
42
+ type: "function",
43
+ function: {
44
+ name: part.toolName,
45
+ arguments: JSON.stringify(part.input)
46
+ }
47
+ });
48
+ break;
49
+ case "file": throw new Error("File content is not yet supported by Inkeep provider");
50
+ case "reasoning":
51
+ text += part.text;
52
+ break;
53
+ case "tool-result": throw new Error("Tool result content should not appear in assistant messages");
54
+ default: {
55
+ const _exhaustiveCheck = part;
56
+ throw new Error(`Unsupported content part type: ${_exhaustiveCheck}`);
57
+ }
58
+ }
59
+ messages.push({
60
+ role: "assistant",
61
+ content: text || ""
62
+ });
63
+ break;
64
+ }
65
+ case "tool":
66
+ for (const toolResponse of content) messages.push({
67
+ role: "tool",
68
+ content: JSON.stringify(toolResponse.output),
69
+ name: toolResponse.toolName
70
+ });
71
+ break;
72
+ default: {
73
+ const _exhaustiveCheck = role;
74
+ throw new Error(`Unsupported message role: ${_exhaustiveCheck}`);
75
+ }
76
+ }
77
+ return messages;
78
+ }
79
+
80
+ //#endregion
81
+ export { convertToInkeepChatMessages };
@@ -0,0 +1,12 @@
1
+
2
+ //#region src/get-response-metadata.ts
3
+ function getResponseMetadata(response) {
4
+ return {
5
+ id: response.id,
6
+ modelId: response.model,
7
+ timestamp: /* @__PURE__ */ new Date(response.created * 1e3)
8
+ };
9
+ }
10
+
11
+ //#endregion
12
+ exports.getResponseMetadata = getResponseMetadata;
@@ -0,0 +1,10 @@
1
+ import { InkeepChatCompletion } from "./inkeep-chat-prompt.cjs";
2
+
3
+ //#region src/get-response-metadata.d.ts
4
+ declare function getResponseMetadata(response: InkeepChatCompletion): {
5
+ id: string;
6
+ modelId: string | undefined;
7
+ timestamp: Date;
8
+ };
9
+ //#endregion
10
+ export { getResponseMetadata };
@@ -0,0 +1,10 @@
1
+ import { InkeepChatCompletion } from "./inkeep-chat-prompt.js";
2
+
3
+ //#region src/get-response-metadata.d.ts
4
+ declare function getResponseMetadata(response: InkeepChatCompletion): {
5
+ id: string;
6
+ modelId: string | undefined;
7
+ timestamp: Date;
8
+ };
9
+ //#endregion
10
+ export { getResponseMetadata };
@@ -0,0 +1,11 @@
1
+ //#region src/get-response-metadata.ts
2
+ function getResponseMetadata(response) {
3
+ return {
4
+ id: response.id,
5
+ modelId: response.model,
6
+ timestamp: /* @__PURE__ */ new Date(response.created * 1e3)
7
+ };
8
+ }
9
+
10
+ //#endregion
11
+ export { getResponseMetadata };