@omarestrella/ai-sdk-agent-sdk 1.0.0-beta.1 → 1.0.0-beta.3

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 (41) hide show
  1. package/dist/index.d.mts +41 -0
  2. package/dist/index.d.mts.map +1 -0
  3. package/dist/index.mjs +641 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/package.json +9 -8
  6. package/dist/src/index.d.ts +0 -4
  7. package/dist/src/index.d.ts.map +0 -1
  8. package/dist/src/index.js +0 -6
  9. package/dist/src/index.js.map +0 -1
  10. package/dist/src/json.d.ts +0 -6
  11. package/dist/src/json.d.ts.map +0 -1
  12. package/dist/src/json.js +0 -29
  13. package/dist/src/json.js.map +0 -1
  14. package/dist/src/language-model.d.ts +0 -23
  15. package/dist/src/language-model.d.ts.map +0 -1
  16. package/dist/src/language-model.js +0 -440
  17. package/dist/src/language-model.js.map +0 -1
  18. package/dist/src/logger.d.ts +0 -15
  19. package/dist/src/logger.d.ts.map +0 -1
  20. package/dist/src/logger.js +0 -142
  21. package/dist/src/logger.js.map +0 -1
  22. package/dist/src/messages.d.ts +0 -14
  23. package/dist/src/messages.d.ts.map +0 -1
  24. package/dist/src/messages.js +0 -92
  25. package/dist/src/messages.js.map +0 -1
  26. package/dist/src/provider.d.ts +0 -15
  27. package/dist/src/provider.d.ts.map +0 -1
  28. package/dist/src/provider.js +0 -19
  29. package/dist/src/provider.js.map +0 -1
  30. package/dist/src/tools.d.ts +0 -21
  31. package/dist/src/tools.d.ts.map +0 -1
  32. package/dist/src/tools.js +0 -82
  33. package/dist/src/tools.js.map +0 -1
  34. package/dist/test/messages.test.d.ts +0 -2
  35. package/dist/test/messages.test.d.ts.map +0 -1
  36. package/dist/test/messages.test.js +0 -173
  37. package/dist/test/messages.test.js.map +0 -1
  38. package/dist/test/tools.test.d.ts +0 -2
  39. package/dist/test/tools.test.d.ts.map +0 -1
  40. package/dist/test/tools.test.js +0 -175
  41. package/dist/test/tools.test.js.map +0 -1
@@ -1,92 +0,0 @@
1
- import { safeJsonStringify } from "./json";
2
- import { logger } from "./logger";
3
- /**
4
- * Converts an AI SDK LanguageModelV2 prompt (array of system/user/assistant/tool messages)
5
- * into a system prompt string and a user prompt string for the Claude Agent SDK's query().
6
- *
7
- * Since we use maxTurns: 1, the Agent SDK makes a single LLM call. We serialize the full
8
- * conversation history into the prompt so the LLM has context from prior turns.
9
- */
10
- export function convertMessages(messages) {
11
- logger.debug("Converting messages:", { count: messages.length });
12
- const systemParts = [];
13
- const conversationParts = [];
14
- for (const message of messages) {
15
- logger.debug("Processing message:", { role: message.role });
16
- switch (message.role) {
17
- case "system": {
18
- systemParts.push(message.content);
19
- break;
20
- }
21
- case "user": {
22
- const parts = [];
23
- logger.debug("Processing user message parts:", { count: message.content.length });
24
- for (const part of message.content) {
25
- switch (part.type) {
26
- case "text":
27
- parts.push(part.text);
28
- break;
29
- case "file":
30
- parts.push(`[File: ${part.filename ?? part.mediaType}]`);
31
- break;
32
- }
33
- }
34
- if (parts.length > 0) {
35
- conversationParts.push(`[user]\n${parts.join("\n")}`);
36
- }
37
- break;
38
- }
39
- case "assistant": {
40
- const parts = [];
41
- logger.debug("Processing assistant message parts:", { count: message.content.length });
42
- for (const part of message.content) {
43
- switch (part.type) {
44
- case "text":
45
- parts.push(part.text);
46
- break;
47
- case "tool-call":
48
- parts.push(`[tool_call: ${part.toolName}(${safeJsonStringify(part.input)})]`);
49
- break;
50
- case "reasoning":
51
- parts.push(`[thinking]\n${part.text}\n[/thinking]`);
52
- break;
53
- }
54
- }
55
- if (parts.length > 0) {
56
- conversationParts.push(`[assistant]\n${parts.join("\n")}`);
57
- }
58
- break;
59
- }
60
- case "tool": {
61
- const parts = [];
62
- for (const part of message.content) {
63
- const output = part.output;
64
- let outputText;
65
- if (Array.isArray(output)) {
66
- // Output is LanguageModelV2ToolResultOutput (array of parts)
67
- outputText = output
68
- .map((o) => {
69
- if (o.type === "text")
70
- return o.text;
71
- return `[${o.type}]`;
72
- })
73
- .join("\n");
74
- }
75
- else {
76
- outputText = typeof output === "string" ? output : safeJsonStringify(output);
77
- }
78
- parts.push(`[tool_result: ${part.toolName} (id: ${part.toolCallId})]\n${outputText}`);
79
- }
80
- if (parts.length > 0) {
81
- conversationParts.push(parts.join("\n"));
82
- }
83
- break;
84
- }
85
- }
86
- }
87
- return {
88
- systemPrompt: systemParts.join("\n\n"),
89
- prompt: conversationParts.join("\n\n"),
90
- };
91
- }
92
- //# sourceMappingURL=messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,QAA+B;IAC7D,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEjE,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAClC,MAAM;YACR,CAAC;YAED,KAAK,MAAM,CAAC,CAAC,CAAC;gBACZ,MAAM,KAAK,GAAa,EAAE,CAAC;gBAC3B,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,C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CAAC,MAAM,CAAC;QACtC,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;KACvC,CAAC;AACJ,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { LanguageModelV2 } from "@ai-sdk/provider";
2
- export interface ClaudeAgentProviderSettings {
3
- name?: string;
4
- /**
5
- * Working directory for the Agent SDK.
6
- * @default process.cwd()
7
- */
8
- cwd?: string;
9
- }
10
- export interface ClaudeAgentProvider {
11
- (modelId: string): LanguageModelV2;
12
- languageModel(modelId: string): LanguageModelV2;
13
- }
14
- export declare function createClaudeAgent(options?: ClaudeAgentProviderSettings): ClaudeAgentProvider;
15
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQxD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC;IACnC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC;CACjD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,2BAAgC,GACxC,mBAAmB,CAmBrB"}
@@ -1,19 +0,0 @@
1
- import { ClaudeAgentLanguageModel, } from "./language-model";
2
- import { safeJsonStringify } from "./json";
3
- import { logger } from "./logger";
4
- export function createClaudeAgent(options = {}) {
5
- const config = {
6
- provider: options.name ?? "claude-agent",
7
- cwd: options.cwd,
8
- };
9
- logger.debug("Creating agent with:", safeJsonStringify(options));
10
- const createLanguageModel = (modelId) => {
11
- return new ClaudeAgentLanguageModel(modelId, config);
12
- };
13
- const provider = function (modelId) {
14
- return createLanguageModel(modelId);
15
- };
16
- provider.languageModel = createLanguageModel;
17
- return provider;
18
- }
19
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,GAEzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAiBlC,MAAM,UAAU,iBAAiB,CAC/B,UAAuC,EAAE;IAEzC,MAAM,MAAM,GAAmC;QAC7C,QAAQ,EAAE,OAAO,CAAC,IAAI,IAAI,cAAc;QACxC,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEjE,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAmB,EAAE;QAC/D,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,UAAU,OAAe;QACxC,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,QAAQ,CAAC,aAAa,GAAG,mBAAmB,CAAC;IAE7C,OAAO,QAA+B,CAAC;AACzC,CAAC"}
@@ -1,21 +0,0 @@
1
- import type { LanguageModelV2FunctionTool } from "@ai-sdk/provider";
2
- import { type McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
3
- /**
4
- * The name of the MCP server that hosts AI SDK tools.
5
- * This is used to identify tools when the Agent SDK returns them
6
- * in the format: mcp__{SERVER_NAME}__{tool_name}
7
- */
8
- export declare const AI_SDK_MCP_SERVER_NAME = "ai-sdk-tools";
9
- /**
10
- * Converts AI SDK function tool definitions into an in-process Agent SDK MCP server.
11
- *
12
- * Each AI SDK tool becomes an MCP tool with proper parameter validation.
13
- * Since we use maxTurns: 1, the Agent SDK will report tool_use blocks in the
14
- * assistant message but won't execute them. The AI SDK caller handles actual
15
- * tool execution.
16
- */
17
- export declare function convertTools(tools: LanguageModelV2FunctionTool[] | undefined): {
18
- mcpServer: McpServerConfig;
19
- allowedTools: string[];
20
- } | undefined;
21
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,gCAAgC,CAAC;AAKxC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AA8BrD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,2BAA2B,EAAE,GAAG,SAAS,GACzE;IACE,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,GACD,SAAS,CAqDZ"}
package/dist/src/tools.js DELETED
@@ -1,82 +0,0 @@
1
- import { createSdkMcpServer, tool, } from "@anthropic-ai/claude-agent-sdk";
2
- import * as z from "zod";
3
- import { safeJsonStringify } from "./json";
4
- import { logger } from "./logger";
5
- /**
6
- * The name of the MCP server that hosts AI SDK tools.
7
- * This is used to identify tools when the Agent SDK returns them
8
- * in the format: mcp__{SERVER_NAME}__{tool_name}
9
- */
10
- export const AI_SDK_MCP_SERVER_NAME = "ai-sdk-tools";
11
- /**
12
- * Extracts Zod schema from AI SDK tool inputSchema using Zod 4's native
13
- * JSON Schema conversion.
14
- */
15
- function extractZodSchema(tool) {
16
- const inputSchema = tool.inputSchema;
17
- if (!inputSchema || typeof inputSchema !== "object") {
18
- return {};
19
- }
20
- try {
21
- const zodSchema = z.fromJSONSchema(inputSchema);
22
- if (zodSchema instanceof z.ZodObject) {
23
- return zodSchema.shape;
24
- }
25
- return { value: zodSchema };
26
- }
27
- catch (error) {
28
- logger.error("Failed to convert JSON Schema to Zod:", {
29
- tool: tool.name,
30
- error,
31
- });
32
- return {};
33
- }
34
- }
35
- /**
36
- * Converts AI SDK function tool definitions into an in-process Agent SDK MCP server.
37
- *
38
- * Each AI SDK tool becomes an MCP tool with proper parameter validation.
39
- * Since we use maxTurns: 1, the Agent SDK will report tool_use blocks in the
40
- * assistant message but won't execute them. The AI SDK caller handles actual
41
- * tool execution.
42
- */
43
- export function convertTools(tools) {
44
- if (!tools || tools.length === 0)
45
- return undefined;
46
- logger.debug("Converting tools:", {
47
- count: tools.length,
48
- tools: tools.map((t) => t.name),
49
- });
50
- const mcpTools = tools.map((aiTool) => {
51
- const zodSchema = extractZodSchema(aiTool);
52
- logger.debug("Creating tool:", {
53
- name: aiTool.name,
54
- schemaKeys: Object.keys(zodSchema),
55
- });
56
- return tool(aiTool.name, aiTool.description ?? "", zodSchema, async () => {
57
- // Stub handler — tool execution is deferred to the AI SDK caller.
58
- // This should rarely (if ever) be called with maxTurns: 1.
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: safeJsonStringify({
64
- _deferred: true,
65
- message: "Tool execution deferred to AI SDK caller",
66
- }),
67
- },
68
- ],
69
- };
70
- });
71
- });
72
- logger.info("Created MCP server with", mcpTools.length, "tools");
73
- const mcpServer = createSdkMcpServer({
74
- name: AI_SDK_MCP_SERVER_NAME,
75
- tools: mcpTools,
76
- });
77
- // Generate the allowed tool names with MCP prefix format
78
- const allowedTools = tools.map((t) => `mcp__${AI_SDK_MCP_SERVER_NAME}__${t.name}`);
79
- logger.debug("Allowed tools:", allowedTools);
80
- return { mcpServer, allowedTools };
81
- }
82
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,IAAI,GAEL,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;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AgB,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SACnC,CAAC,CAAC;QAEH,OAAO,IAAI,CACT,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,WAAW,IAAI,EAAE,EACxB,SAAS,EACT,KAAK,IAAI,EAAE;YACT,kEAAkE;YAClE,2DAA2D;YAC3D,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,iBAAiB,CAAC;4BACtB,SAAS,EAAE,IAAI;4BACf,OAAO,EAAE,0CAA0C;yBACpD,CAAC;qBACH;iBACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjE,MAAM,SAAS,GAAG,kBAAkB,CAAC;QACnC,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,yDAAyD;IACzD,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,sBAAsB,KAAK,CAAC,CAAC,IAAI,EAAE,CACnD,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IAE7C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AACrC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=messages.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.test.d.ts","sourceRoot":"","sources":["../../test/messages.test.ts"],"names":[],"mappings":""}
@@ -1,173 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { convertMessages } from "../src/messages";
3
- describe("convertMessages", () => {
4
- test("should convert system message", () => {
5
- const messages = [
6
- { role: "system", content: "You are a helpful assistant." },
7
- ];
8
- const result = convertMessages(messages);
9
- expect(result.systemPrompt).toBe("You are a helpful assistant.");
10
- expect(result.prompt).toBe("");
11
- });
12
- test("should convert user text message", () => {
13
- const messages = [
14
- {
15
- role: "user",
16
- content: [{ type: "text", text: "Hello, how are you?" }],
17
- },
18
- ];
19
- const result = convertMessages(messages);
20
- expect(result.systemPrompt).toBe("");
21
- expect(result.prompt).toBe("[user]\nHello, how are you?");
22
- });
23
- test("should convert user file message", () => {
24
- const messages = [
25
- {
26
- role: "user",
27
- content: [
28
- {
29
- type: "file",
30
- data: Buffer.from("test content").toString("base64"),
31
- mediaType: "application/pdf",
32
- },
33
- ],
34
- },
35
- ];
36
- const result = convertMessages(messages);
37
- expect(result.systemPrompt).toBe("");
38
- expect(result.prompt).toBe("[user]\n[File: application/pdf]");
39
- });
40
- test("should convert assistant text message", () => {
41
- const messages = [
42
- {
43
- role: "assistant",
44
- content: [{ type: "text", text: "I'm doing well, thank you!" }],
45
- },
46
- ];
47
- const result = convertMessages(messages);
48
- expect(result.systemPrompt).toBe("");
49
- expect(result.prompt).toBe("[assistant]\nI'm doing well, thank you!");
50
- });
51
- test("should convert assistant tool call", () => {
52
- const messages = [
53
- {
54
- role: "assistant",
55
- content: [
56
- {
57
- type: "tool-call",
58
- toolCallId: "call-123",
59
- toolName: "getWeather",
60
- input: { city: "San Francisco" },
61
- },
62
- ],
63
- },
64
- ];
65
- const result = convertMessages(messages);
66
- expect(result.systemPrompt).toBe("");
67
- expect(result.prompt).toContain('[tool_call: getWeather({"city":"San Francisco"})]');
68
- });
69
- test("should convert assistant reasoning", () => {
70
- const messages = [
71
- {
72
- role: "assistant",
73
- content: [{ type: "reasoning", text: "Let me think about this..." }],
74
- },
75
- ];
76
- const result = convertMessages(messages);
77
- expect(result.systemPrompt).toBe("");
78
- expect(result.prompt).toBe("[assistant]\n[thinking]\nLet me think about this...\n[/thinking]");
79
- });
80
- test("should convert tool result with text output", () => {
81
- const messages = [
82
- {
83
- role: "tool",
84
- content: [
85
- {
86
- type: "tool-result",
87
- toolCallId: "call-123",
88
- toolName: "getWeather",
89
- output: { type: "text", value: "Sunny, 72°F" },
90
- },
91
- ],
92
- },
93
- ];
94
- const result = convertMessages(messages);
95
- expect(result.systemPrompt).toBe("");
96
- expect(result.prompt).toContain("[tool_result: getWeather (id: call-123)]");
97
- expect(result.prompt).toContain('{"type":"text","value":"Sunny, 72°F"}');
98
- });
99
- test("should convert tool result with json output", () => {
100
- const messages = [
101
- {
102
- role: "tool",
103
- content: [
104
- {
105
- type: "tool-result",
106
- toolCallId: "call-456",
107
- toolName: "calculate",
108
- output: { type: "json", value: 42 },
109
- },
110
- ],
111
- },
112
- ];
113
- const result = convertMessages(messages);
114
- expect(result.systemPrompt).toBe("");
115
- expect(result.prompt).toContain("[tool_result: calculate (id: call-456)]");
116
- expect(result.prompt).toContain("42");
117
- });
118
- test("should handle full conversation flow", () => {
119
- const messages = [
120
- { role: "system", content: "You are a helpful assistant." },
121
- {
122
- role: "user",
123
- content: [{ type: "text", text: "What's the weather?" }],
124
- },
125
- {
126
- role: "assistant",
127
- content: [
128
- {
129
- type: "tool-call",
130
- toolCallId: "call-1",
131
- toolName: "getWeather",
132
- input: { city: "NYC" },
133
- },
134
- ],
135
- },
136
- {
137
- role: "tool",
138
- content: [
139
- {
140
- type: "tool-result",
141
- toolCallId: "call-1",
142
- toolName: "getWeather",
143
- output: { type: "text", value: "Rainy, 60°F" },
144
- },
145
- ],
146
- },
147
- {
148
- role: "assistant",
149
- content: [{ type: "text", text: "It's rainy in NYC today." }],
150
- },
151
- ];
152
- const result = convertMessages(messages);
153
- expect(result.systemPrompt).toBe("You are a helpful assistant.");
154
- expect(result.prompt).toContain("[user]\nWhat's the weather?");
155
- expect(result.prompt).toContain('[tool_call: getWeather({"city":"NYC"})]');
156
- expect(result.prompt).toContain("It's rainy in NYC today.");
157
- });
158
- test("should handle empty messages", () => {
159
- const messages = [];
160
- const result = convertMessages(messages);
161
- expect(result.systemPrompt).toBe("");
162
- expect(result.prompt).toBe("");
163
- });
164
- test("should handle multiple system messages", () => {
165
- const messages = [
166
- { role: "system", content: "You are an AI assistant." },
167
- { role: "system", content: "Be concise and helpful." },
168
- ];
169
- const result = convertMessages(messages);
170
- expect(result.systemPrompt).toBe("You are an AI assistant.\n\nBe concise and helpful.");
171
- });
172
- });
173
- //# sourceMappingURL=messages.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.test.js","sourceRoot":"","sources":["../../test/messages.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,QAAQ,GAA0B;YACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,8BAA8B,EAAE;SAC5D,CAAC;QAEF,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QAEzC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACjE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC5C,MAAM,QAAQ,GAA0B;YACtC;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;aACzD;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CA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CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAClD,MAAM,QAAQ,GAA0B;YACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,0BAA0B,EAAE;YACvD,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,yBAAyB,EAAE;SACvD,CAAC;QAEF,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QAEzC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=tools.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.test.d.ts","sourceRoot":"","sources":["../../test/tools.test.ts"],"names":[],"mappings":""}
@@ -1,175 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { convertTools } from "../src/tools";
3
- describe("convertTools", () => {
4
- test("should return undefined for empty tools array", () => {
5
- const result = convertTools([]);
6
- expect(result).toBeUndefined();
7
- });
8
- test("should return undefined for undefined tools", () => {
9
- const result = convertTools(undefined);
10
- expect(result).toBeUndefined();
11
- });
12
- test("should convert tool with simple string parameter", () => {
13
- const tools = [
14
- {
15
- type: "function",
16
- name: "getWeather",
17
- description: "Get the weather for a city",
18
- inputSchema: {
19
- type: "object",
20
- properties: {
21
- city: { type: "string" },
22
- },
23
- required: ["city"],
24
- },
25
- },
26
- ];
27
- const result = convertTools(tools);
28
- expect(result).toBeDefined();
29
- // The MCP server should be created successfully
30
- });
31
- test("should convert tool with multiple parameter types", () => {
32
- const tools = [
33
- {
34
- type: "function",
35
- name: "createUser",
36
- description: "Create a new user",
37
- inputSchema: {
38
- type: "object",
39
- properties: {
40
- name: { type: "string" },
41
- age: { type: "integer" },
42
- email: { type: "string", format: "email" },
43
- isActive: { type: "boolean" },
44
- },
45
- required: ["name", "email"],
46
- },
47
- },
48
- ];
49
- const result = convertTools(tools);
50
- expect(result).toBeDefined();
51
- });
52
- test("should convert tool with nested object parameters", () => {
53
- const tools = [
54
- {
55
- type: "function",
56
- name: "updateConfig",
57
- description: "Update configuration",
58
- inputSchema: {
59
- type: "object",
60
- properties: {
61
- settings: {
62
- type: "object",
63
- properties: {
64
- theme: { type: "string" },
65
- notifications: { type: "boolean" },
66
- },
67
- },
68
- },
69
- },
70
- },
71
- ];
72
- const result = convertTools(tools);
73
- expect(result).toBeDefined();
74
- });
75
- test("should convert tool with array parameters", () => {
76
- const tools = [
77
- {
78
- type: "function",
79
- name: "addTags",
80
- description: "Add tags to an item",
81
- inputSchema: {
82
- type: "object",
83
- properties: {
84
- tags: {
85
- type: "array",
86
- items: { type: "string" },
87
- },
88
- },
89
- },
90
- },
91
- ];
92
- const result = convertTools(tools);
93
- expect(result).toBeDefined();
94
- });
95
- test("should convert tool with enum parameters", () => {
96
- const tools = [
97
- {
98
- type: "function",
99
- name: "setPriority",
100
- description: "Set task priority",
101
- inputSchema: {
102
- type: "object",
103
- properties: {
104
- priority: {
105
- type: "string",
106
- enum: ["low", "medium", "high"],
107
- },
108
- },
109
- },
110
- },
111
- ];
112
- const result = convertTools(tools);
113
- expect(result).toBeDefined();
114
- });
115
- test("should convert multiple tools", () => {
116
- const tools = [
117
- {
118
- type: "function",
119
- name: "getWeather",
120
- description: "Get weather",
121
- inputSchema: {
122
- type: "object",
123
- properties: { city: { type: "string" } },
124
- },
125
- },
126
- {
127
- type: "function",
128
- name: "getTime",
129
- description: "Get current time",
130
- inputSchema: {
131
- type: "object",
132
- properties: {},
133
- },
134
- },
135
- ];
136
- const result = convertTools(tools);
137
- expect(result).toBeDefined();
138
- });
139
- test("should handle tool without parameters", () => {
140
- const tools = [
141
- {
142
- type: "function",
143
- name: "getStatus",
144
- description: "Get system status",
145
- inputSchema: {
146
- type: "object",
147
- properties: {},
148
- },
149
- },
150
- ];
151
- const result = convertTools(tools);
152
- expect(result).toBeDefined();
153
- });
154
- test("should convert tool with optional parameters", () => {
155
- const tools = [
156
- {
157
- type: "function",
158
- name: "search",
159
- description: "Search items",
160
- inputSchema: {
161
- type: "object",
162
- properties: {
163
- query: { type: "string" },
164
- limit: { type: "integer" },
165
- offset: { type: "integer" },
166
- },
167
- required: ["query"],
168
- },
169
- },
170
- ];
171
- const result = convertTools(tools);
172
- expect(result).toBeDefined();
173
- });
174
- });
175
- //# sourceMappingURL=tools.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.test.js","sourceRoot":"","sources":["../../test/tools.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACvD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC5D,MAAM,KAAK,GAAkC;YAC3C;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,4BAA4B;gBACzC,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBACzB;oBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;iBACnB;aACF;SACF,CAA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