bigtool-ts 0.1.1 → 0.1.2
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.
- package/dist/adapters/agent-protocol.d.ts +8 -141
- package/dist/adapters/agent-protocol.d.ts.map +1 -1
- package/dist/adapters/agent-protocol.js +9 -125
- package/dist/adapters/agent-protocol.js.map +1 -1
- package/dist/adapters/index.d.ts +12 -3
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +14 -4
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/inngest.d.ts +3 -4
- package/dist/adapters/inngest.d.ts.map +1 -1
- package/dist/adapters/inngest.js +9 -8
- package/dist/adapters/inngest.js.map +1 -1
- package/dist/adapters/mastra.d.ts +45 -9
- package/dist/adapters/mastra.d.ts.map +1 -1
- package/dist/adapters/mastra.js +5 -1
- package/dist/adapters/mastra.js.map +1 -1
- package/dist/adapters/rest-handler.d.ts +154 -0
- package/dist/adapters/rest-handler.d.ts.map +1 -0
- package/dist/adapters/rest-handler.js +128 -0
- package/dist/adapters/rest-handler.js.map +1 -0
- package/dist/adapters/schema-utils.d.ts +44 -0
- package/dist/adapters/schema-utils.d.ts.map +1 -0
- package/dist/adapters/schema-utils.js +163 -0
- package/dist/adapters/schema-utils.js.map +1 -0
- package/dist/adapters/vercel-ai.d.ts +13 -8
- package/dist/adapters/vercel-ai.d.ts.map +1 -1
- package/dist/adapters/vercel-ai.js +13 -7
- package/dist/adapters/vercel-ai.js.map +1 -1
- package/dist/graph/agent.d.ts.map +1 -1
- package/dist/graph/agent.js +13 -2
- package/dist/graph/agent.js.map +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/nodes.d.ts +13 -1
- package/dist/graph/nodes.d.ts.map +1 -1
- package/dist/graph/nodes.js +35 -2
- package/dist/graph/nodes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,149 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Protocol adapter for bigtool-ts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @deprecated This module is misnamed. It provides a REST API for tools,
|
|
5
|
+
* NOT an Agent Protocol implementation. Agent Protocol defines task/step
|
|
6
|
+
* endpoints, not tool endpoints.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* tool operations to a REST-like API. It can be used with any HTTP framework
|
|
9
|
-
* (Express, Fastify, Hono, etc.) or integrated with the Agent Protocol SDK.
|
|
8
|
+
* Use `createToolRestHandler` from './rest-handler.js' instead.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
import type { AdapterConfig } from './types.js';
|
|
15
|
-
/**
|
|
16
|
-
* Tool representation in Agent Protocol wire format.
|
|
17
|
-
*
|
|
18
|
-
* Uses JSON Schema for parameters (not Zod) as required by REST APIs.
|
|
19
|
-
*/
|
|
20
|
-
export interface AgentTool {
|
|
21
|
-
/** Unique tool identifier */
|
|
22
|
-
name: string;
|
|
23
|
-
/** Human-readable description */
|
|
24
|
-
description: string;
|
|
25
|
-
/** JSON Schema for tool parameters */
|
|
26
|
-
parameters: Record<string, unknown>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Result from tool execution.
|
|
30
|
-
*/
|
|
31
|
-
export interface ToolExecutionResult {
|
|
32
|
-
/** Unique identifier for this tool call */
|
|
33
|
-
tool_call_id: string;
|
|
34
|
-
/** Output from the tool (serialized to string) */
|
|
35
|
-
output: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Error response structure.
|
|
39
|
-
*/
|
|
40
|
-
export interface ToolError {
|
|
41
|
-
/** Error code for programmatic handling */
|
|
42
|
-
code: 'TOOL_NOT_FOUND' | 'EXECUTION_ERROR';
|
|
43
|
-
/** Human-readable error message */
|
|
44
|
-
message: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Result type for operations that can fail.
|
|
48
|
-
*/
|
|
49
|
-
export type ToolResult<T> = {
|
|
50
|
-
success: true;
|
|
51
|
-
data: T;
|
|
52
|
-
} | {
|
|
53
|
-
success: false;
|
|
54
|
-
error: ToolError;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Framework-agnostic handler for Agent Protocol tool operations.
|
|
58
|
-
*
|
|
59
|
-
* This interface provides the core operations that can be exposed via any
|
|
60
|
-
* HTTP framework or integrated with the Agent Protocol SDK's step mechanism.
|
|
10
|
+
* All exports from this module are re-exported with deprecation notices
|
|
11
|
+
* for backwards compatibility.
|
|
61
12
|
*
|
|
62
|
-
* @
|
|
63
|
-
* ```typescript
|
|
64
|
-
* import express from 'express';
|
|
65
|
-
* import { createAgentProtocolHandler } from '@repo/bigtool-ts/adapters';
|
|
66
|
-
*
|
|
67
|
-
* const handler = createAgentProtocolHandler({ catalog, loader, searchIndex });
|
|
68
|
-
* const app = express();
|
|
69
|
-
*
|
|
70
|
-
* app.get('/tools', async (req, res) => {
|
|
71
|
-
* const tools = await handler.listTools();
|
|
72
|
-
* res.json(tools);
|
|
73
|
-
* });
|
|
74
|
-
*
|
|
75
|
-
* app.post('/tools/search', async (req, res) => {
|
|
76
|
-
* const { query, limit } = req.body;
|
|
77
|
-
* const tools = await handler.searchTools(query, limit);
|
|
78
|
-
* res.json(tools);
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* app.post('/tools/execute', async (req, res) => {
|
|
82
|
-
* const { name, args } = req.body;
|
|
83
|
-
* const result = await handler.executeTool(name, args);
|
|
84
|
-
* if (result.success) {
|
|
85
|
-
* res.json(result.data);
|
|
86
|
-
* } else {
|
|
87
|
-
* res.status(400).json(result.error);
|
|
88
|
-
* }
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export interface AgentProtocolHandler {
|
|
93
|
-
/**
|
|
94
|
-
* List all available tools.
|
|
95
|
-
*
|
|
96
|
-
* @returns Array of tools in Agent Protocol format
|
|
97
|
-
*/
|
|
98
|
-
listTools(): Promise<AgentTool[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Search for tools matching a query.
|
|
101
|
-
*
|
|
102
|
-
* @param query - Natural language search query
|
|
103
|
-
* @param limit - Maximum number of results (default: 5)
|
|
104
|
-
* @returns Array of matching tools, sorted by relevance
|
|
105
|
-
*/
|
|
106
|
-
searchTools(query: string, limit?: number): Promise<AgentTool[]>;
|
|
107
|
-
/**
|
|
108
|
-
* Execute a tool with the given arguments.
|
|
109
|
-
*
|
|
110
|
-
* @param name - Tool name to execute
|
|
111
|
-
* @param args - Arguments to pass to the tool
|
|
112
|
-
* @returns Result containing output or error
|
|
113
|
-
*/
|
|
114
|
-
executeTool(name: string, args: Record<string, unknown>): Promise<ToolResult<ToolExecutionResult>>;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Creates a framework-agnostic Agent Protocol handler.
|
|
118
|
-
*
|
|
119
|
-
* The handler provides three core operations for tool management:
|
|
120
|
-
* - `listTools()`: Get all available tools
|
|
121
|
-
* - `searchTools()`: Find tools by natural language query
|
|
122
|
-
* - `executeTool()`: Run a specific tool with arguments
|
|
123
|
-
*
|
|
124
|
-
* @param config - Adapter configuration with catalog, loader, and search index
|
|
125
|
-
* @returns Handler instance with tool operations
|
|
126
|
-
*
|
|
127
|
-
* @example Basic usage
|
|
128
|
-
* ```typescript
|
|
129
|
-
* const handler = createAgentProtocolHandler({
|
|
130
|
-
* catalog,
|
|
131
|
-
* loader,
|
|
132
|
-
* searchIndex,
|
|
133
|
-
* });
|
|
134
|
-
*
|
|
135
|
-
* // List all tools
|
|
136
|
-
* const tools = await handler.listTools();
|
|
137
|
-
*
|
|
138
|
-
* // Search for specific tools
|
|
139
|
-
* const githubTools = await handler.searchTools('github pull request', 5);
|
|
140
|
-
*
|
|
141
|
-
* // Execute a tool
|
|
142
|
-
* const result = await handler.executeTool('create_pr', {
|
|
143
|
-
* title: 'My PR',
|
|
144
|
-
* body: 'Description',
|
|
145
|
-
* });
|
|
146
|
-
* ```
|
|
13
|
+
* @module adapters/agent-protocol
|
|
147
14
|
*/
|
|
148
|
-
export
|
|
15
|
+
export { createToolRestHandler as createAgentProtocolHandler, type ToolRestHandler as AgentProtocolHandler, type RestTool as AgentTool, type RestToolExecutionResult as ToolExecutionResult, type RestToolError as ToolError, type RestToolResult as ToolResult, } from './rest-handler.js';
|
|
149
16
|
//# sourceMappingURL=agent-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-protocol.d.ts","sourceRoot":"","sources":["../../src/adapters/agent-protocol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-protocol.d.ts","sourceRoot":"","sources":["../../src/adapters/agent-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,qBAAqB,IAAI,0BAA0B,EACnD,KAAK,eAAe,IAAI,oBAAoB,EAC5C,KAAK,QAAQ,IAAI,SAAS,EAC1B,KAAK,uBAAuB,IAAI,mBAAmB,EACnD,KAAK,aAAa,IAAI,SAAS,EAC/B,KAAK,cAAc,IAAI,UAAU,GAClC,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,133 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Protocol adapter for bigtool-ts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @deprecated This module is misnamed. It provides a REST API for tools,
|
|
5
|
+
* NOT an Agent Protocol implementation. Agent Protocol defines task/step
|
|
6
|
+
* endpoints, not tool endpoints.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* tool operations to a REST-like API. It can be used with any HTTP framework
|
|
9
|
-
* (Express, Fastify, Hono, etc.) or integrated with the Agent Protocol SDK.
|
|
8
|
+
* Use `createToolRestHandler` from './rest-handler.js' instead.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
15
|
-
// IMPLEMENTATION
|
|
16
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
17
|
-
/**
|
|
18
|
-
* Convert bigtool-ts metadata to Agent Protocol wire format.
|
|
19
|
-
*
|
|
20
|
-
* This is a pure function that transforms internal metadata to the
|
|
21
|
-
* external API representation.
|
|
22
|
-
*/
|
|
23
|
-
function toAgentTool(metadata) {
|
|
24
|
-
return {
|
|
25
|
-
name: metadata.name,
|
|
26
|
-
description: metadata.description,
|
|
27
|
-
parameters: metadata.parameters ?? {},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Generate a unique tool call ID.
|
|
10
|
+
* All exports from this module are re-exported with deprecation notices
|
|
11
|
+
* for backwards compatibility.
|
|
32
12
|
*
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
function generateToolCallId() {
|
|
36
|
-
const timestamp = Date.now().toString(36);
|
|
37
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
38
|
-
return `call_${timestamp}_${random}`;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a framework-agnostic Agent Protocol handler.
|
|
42
|
-
*
|
|
43
|
-
* The handler provides three core operations for tool management:
|
|
44
|
-
* - `listTools()`: Get all available tools
|
|
45
|
-
* - `searchTools()`: Find tools by natural language query
|
|
46
|
-
* - `executeTool()`: Run a specific tool with arguments
|
|
47
|
-
*
|
|
48
|
-
* @param config - Adapter configuration with catalog, loader, and search index
|
|
49
|
-
* @returns Handler instance with tool operations
|
|
50
|
-
*
|
|
51
|
-
* @example Basic usage
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const handler = createAgentProtocolHandler({
|
|
54
|
-
* catalog,
|
|
55
|
-
* loader,
|
|
56
|
-
* searchIndex,
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // List all tools
|
|
60
|
-
* const tools = await handler.listTools();
|
|
61
|
-
*
|
|
62
|
-
* // Search for specific tools
|
|
63
|
-
* const githubTools = await handler.searchTools('github pull request', 5);
|
|
64
|
-
*
|
|
65
|
-
* // Execute a tool
|
|
66
|
-
* const result = await handler.executeTool('create_pr', {
|
|
67
|
-
* title: 'My PR',
|
|
68
|
-
* body: 'Description',
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
13
|
+
* @module adapters/agent-protocol
|
|
71
14
|
*/
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
async listTools() {
|
|
76
|
-
const metadata = catalog.getAllMetadata();
|
|
77
|
-
return metadata.map(toAgentTool);
|
|
78
|
-
},
|
|
79
|
-
async searchTools(query, limit = 5) {
|
|
80
|
-
const results = await searchIndex.search(query, { limit });
|
|
81
|
-
// Map search results to agent tools
|
|
82
|
-
// Filter out nulls in case metadata was removed between search and lookup
|
|
83
|
-
const tools = [];
|
|
84
|
-
for (const result of results) {
|
|
85
|
-
const metadata = catalog.getMetadata(result.toolId);
|
|
86
|
-
if (metadata !== null) {
|
|
87
|
-
tools.push(toAgentTool(metadata));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return tools;
|
|
91
|
-
},
|
|
92
|
-
async executeTool(name, args) {
|
|
93
|
-
// Find tool by name (search through metadata)
|
|
94
|
-
const allMetadata = catalog.getAllMetadata();
|
|
95
|
-
const metadata = allMetadata.find((m) => m.name === name);
|
|
96
|
-
if (metadata === undefined) {
|
|
97
|
-
return {
|
|
98
|
-
success: false,
|
|
99
|
-
error: {
|
|
100
|
-
code: 'TOOL_NOT_FOUND',
|
|
101
|
-
message: `Tool not found: ${name}`,
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
// Load and execute the tool
|
|
106
|
-
const tool = await loader.load(metadata.id);
|
|
107
|
-
// Attempt execution with error handling
|
|
108
|
-
const toolCallId = generateToolCallId();
|
|
109
|
-
try {
|
|
110
|
-
const rawResult = await tool.invoke(args);
|
|
111
|
-
const output = typeof rawResult === 'string' ? rawResult : JSON.stringify(rawResult);
|
|
112
|
-
return {
|
|
113
|
-
success: true,
|
|
114
|
-
data: {
|
|
115
|
-
tool_call_id: toolCallId,
|
|
116
|
-
output,
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
const message = error instanceof Error ? error.message : 'Unknown execution error';
|
|
122
|
-
return {
|
|
123
|
-
success: false,
|
|
124
|
-
error: {
|
|
125
|
-
code: 'EXECUTION_ERROR',
|
|
126
|
-
message,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
15
|
+
// Re-export everything from rest-handler with original names for backwards compatibility
|
|
16
|
+
export { createToolRestHandler as createAgentProtocolHandler, } from './rest-handler.js';
|
|
133
17
|
//# sourceMappingURL=agent-protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-protocol.js","sourceRoot":"","sources":["../../src/adapters/agent-protocol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-protocol.js","sourceRoot":"","sources":["../../src/adapters/agent-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,yFAAyF;AACzF,OAAO,EACL,qBAAqB,IAAI,0BAA0B,GAMpD,MAAM,mBAAmB,CAAC"}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example Inngest AgentKit
|
|
11
11
|
* ```typescript
|
|
12
|
-
* import { createInngestAdapter } from '
|
|
12
|
+
* import { createInngestAdapter } from 'bigtool-ts/adapters';
|
|
13
13
|
*
|
|
14
14
|
* const adapter = createInngestAdapter({ catalog, loader, searchIndex });
|
|
15
15
|
* const tools = await adapter.getTools(['github:create_pr']);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @example Vercel AI SDK
|
|
19
19
|
* ```typescript
|
|
20
|
-
* import { createVercelAdapter } from '
|
|
20
|
+
* import { createVercelAdapter } from 'bigtool-ts/adapters';
|
|
21
21
|
*
|
|
22
22
|
* const adapter = createVercelAdapter({ catalog, loader, searchIndex });
|
|
23
23
|
* const tools = await adapter.getToolsAsRecord(['github:create_pr']);
|
|
@@ -25,14 +25,23 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @example Mastra
|
|
27
27
|
* ```typescript
|
|
28
|
-
* import { createMastraAdapter } from '
|
|
28
|
+
* import { createMastraAdapter } from 'bigtool-ts/adapters';
|
|
29
29
|
*
|
|
30
30
|
* const adapter = createMastraAdapter({ catalog, loader, searchIndex });
|
|
31
31
|
* const tools = await adapter.getToolsAsRecord(['github:create_pr']);
|
|
32
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example REST API Handler
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { createToolRestHandler } from 'bigtool-ts/adapters';
|
|
37
|
+
*
|
|
38
|
+
* const handler = createToolRestHandler({ catalog, loader, searchIndex });
|
|
39
|
+
* app.get('/tools', async (req, res) => res.json(await handler.listTools()));
|
|
40
|
+
* ```
|
|
33
41
|
*/
|
|
34
42
|
export type { AdapterConfig, SearchToolOptions, ToolAdapter } from './types.js';
|
|
35
43
|
export { InngestAdapter, createInngestAdapter, type InngestTool, type InngestToolOptions, type InngestNetworkRun, type InngestStep, type SearchToolResult, } from './inngest.js';
|
|
44
|
+
export { createToolRestHandler, type ToolRestHandler, type RestTool, type RestToolExecutionResult, type RestToolError, type RestToolResult, } from './rest-handler.js';
|
|
36
45
|
export { createAgentProtocolHandler, type AgentProtocolHandler, type AgentTool, type ToolExecutionResult, type ToolError, type ToolResult, } from './agent-protocol.js';
|
|
37
46
|
export { VercelAIAdapter, createVercelAdapter, } from './vercel-ai.js';
|
|
38
47
|
export { MastraAdapter, createMastraAdapter, type MastraTool, type MastraToolContext, } from './mastra.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGhF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @example Inngest AgentKit
|
|
11
11
|
* ```typescript
|
|
12
|
-
* import { createInngestAdapter } from '
|
|
12
|
+
* import { createInngestAdapter } from 'bigtool-ts/adapters';
|
|
13
13
|
*
|
|
14
14
|
* const adapter = createInngestAdapter({ catalog, loader, searchIndex });
|
|
15
15
|
* const tools = await adapter.getTools(['github:create_pr']);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @example Vercel AI SDK
|
|
19
19
|
* ```typescript
|
|
20
|
-
* import { createVercelAdapter } from '
|
|
20
|
+
* import { createVercelAdapter } from 'bigtool-ts/adapters';
|
|
21
21
|
*
|
|
22
22
|
* const adapter = createVercelAdapter({ catalog, loader, searchIndex });
|
|
23
23
|
* const tools = await adapter.getToolsAsRecord(['github:create_pr']);
|
|
@@ -25,15 +25,25 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @example Mastra
|
|
27
27
|
* ```typescript
|
|
28
|
-
* import { createMastraAdapter } from '
|
|
28
|
+
* import { createMastraAdapter } from 'bigtool-ts/adapters';
|
|
29
29
|
*
|
|
30
30
|
* const adapter = createMastraAdapter({ catalog, loader, searchIndex });
|
|
31
31
|
* const tools = await adapter.getToolsAsRecord(['github:create_pr']);
|
|
32
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example REST API Handler
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { createToolRestHandler } from 'bigtool-ts/adapters';
|
|
37
|
+
*
|
|
38
|
+
* const handler = createToolRestHandler({ catalog, loader, searchIndex });
|
|
39
|
+
* app.get('/tools', async (req, res) => res.json(await handler.listTools()));
|
|
40
|
+
* ```
|
|
33
41
|
*/
|
|
34
42
|
// Inngest AgentKit adapter
|
|
35
43
|
export { InngestAdapter, createInngestAdapter, } from './inngest.js';
|
|
36
|
-
//
|
|
44
|
+
// REST API handler (preferred)
|
|
45
|
+
export { createToolRestHandler, } from './rest-handler.js';
|
|
46
|
+
// Agent Protocol (deprecated - re-exports from rest-handler)
|
|
37
47
|
export { createAgentProtocolHandler, } from './agent-protocol.js';
|
|
38
48
|
// Vercel AI SDK adapter
|
|
39
49
|
export { VercelAIAdapter, createVercelAdapter, } from './vercel-ai.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAKH,2BAA2B;AAC3B,OAAO,EACL,cAAc,EACd,oBAAoB,GAMrB,MAAM,cAAc,CAAC;AAEtB,+BAA+B;AAC/B,OAAO,EACL,qBAAqB,GAMtB,MAAM,mBAAmB,CAAC;AAE3B,6DAA6D;AAC7D,OAAO,EACL,0BAA0B,GAM3B,MAAM,qBAAqB,CAAC;AAE7B,wBAAwB;AACxB,OAAO,EACL,eAAe,EACf,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,mBAAmB,GAGpB,MAAM,aAAa,CAAC"}
|
|
@@ -121,10 +121,9 @@ export declare class InngestAdapter implements ToolAdapter<InngestTool> {
|
|
|
121
121
|
* The resulting tool wraps the bigtool-ts loader and automatically
|
|
122
122
|
* uses step.run() for durable execution when available.
|
|
123
123
|
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* schemas directly rather than using the adapter.
|
|
124
|
+
* Parameter schemas are converted from JSON Schema to Zod using a
|
|
125
|
+
* simplified converter. For complex schemas, provide tools with Zod
|
|
126
|
+
* schemas directly.
|
|
128
127
|
*
|
|
129
128
|
* @param metadata - Tool metadata from the catalog
|
|
130
129
|
* @returns Inngest-compatible tool
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inngest.d.ts","sourceRoot":"","sources":["../../src/adapters/inngest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAA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f;AAMD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CAE1E"}
|
package/dist/adapters/inngest.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
import { z } from 'zod';
|
|
28
|
+
import { jsonSchemaToZod } from './schema-utils.js';
|
|
28
29
|
// ═══════════════════════════════════════════════════════════════════
|
|
29
30
|
// ADAPTER IMPLEMENTATION
|
|
30
31
|
// ═══════════════════════════════════════════════════════════════════
|
|
@@ -67,23 +68,23 @@ export class InngestAdapter {
|
|
|
67
68
|
* The resulting tool wraps the bigtool-ts loader and automatically
|
|
68
69
|
* uses step.run() for durable execution when available.
|
|
69
70
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* schemas directly rather than using the adapter.
|
|
71
|
+
* Parameter schemas are converted from JSON Schema to Zod using a
|
|
72
|
+
* simplified converter. For complex schemas, provide tools with Zod
|
|
73
|
+
* schemas directly.
|
|
74
74
|
*
|
|
75
75
|
* @param metadata - Tool metadata from the catalog
|
|
76
76
|
* @returns Inngest-compatible tool
|
|
77
77
|
*/
|
|
78
78
|
toFrameworkTool(metadata) {
|
|
79
79
|
const loader = this.loader;
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
// Convert JSON Schema parameters to Zod for AgentKit validation
|
|
81
|
+
const parameters = metadata.parameters
|
|
82
|
+
? jsonSchemaToZod(metadata.parameters)
|
|
83
|
+
: undefined;
|
|
83
84
|
return {
|
|
84
85
|
name: metadata.name,
|
|
85
86
|
description: metadata.description,
|
|
86
|
-
parameters
|
|
87
|
+
parameters,
|
|
87
88
|
handler: async (input, opts) => {
|
|
88
89
|
const execute = async () => {
|
|
89
90
|
const tool = await loader.load(metadata.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inngest.js","sourceRoot":"","sources":["../../src/adapters/inngest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"inngest.js","sourceRoot":"","sources":["../../src/adapters/inngest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAoEpD,sEAAsE;AACtE,yBAAyB;AACzB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,cAAc;IACR,OAAO,CAA2B;IAClC,MAAM,CAA0B;IAChC,WAAW,CAA+B;IAE3D,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,QAAsB;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,gEAAgE;QAChE,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU;YACpC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC;YACtC,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,UAAU;YACV,OAAO,EAAE,KAAK,EAAE,KAAc,EAAE,IAAwB,EAAE,EAAE;gBAC1D,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;oBACzB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE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AI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;oBAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC3B,CAAC,CAAC;gBAEF,iDAAiD;gBACjD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACd,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC5D,CAAC;gBACD,OAAO,OAAO,EAAE,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAkBD,sEAAsE;AACtE,mBAAmB;AACnB,sEAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -31,10 +31,11 @@ import type { AdapterConfig, ToolAdapter, SearchToolOptions } from './types.js';
|
|
|
31
31
|
/**
|
|
32
32
|
* Mastra tool execution context.
|
|
33
33
|
*
|
|
34
|
+
* Matches `ToolExecutionContext` from `@mastra/core/tools` (v0.24+).
|
|
34
35
|
* Provides access to Mastra runtime services during tool execution.
|
|
35
36
|
* All properties are optional to handle various execution contexts.
|
|
36
37
|
*/
|
|
37
|
-
export interface MastraToolContext {
|
|
38
|
+
export interface MastraToolContext<TSuspend = unknown, TResume = unknown> {
|
|
38
39
|
/** Mastra runtime instance for accessing services */
|
|
39
40
|
mastra?: unknown;
|
|
40
41
|
/** Request context for HTTP-triggered executions */
|
|
@@ -43,22 +44,53 @@ export interface MastraToolContext {
|
|
|
43
44
|
tracingContext?: unknown;
|
|
44
45
|
/** Abort signal for cancellation support */
|
|
45
46
|
abortSignal?: AbortSignal;
|
|
46
|
-
/** Agent-specific context (
|
|
47
|
-
agent?:
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
/** Agent-specific context (when called from agent) */
|
|
48
|
+
agent?: {
|
|
49
|
+
/** ID of the tool call from the LLM */
|
|
50
|
+
toolCallId: string;
|
|
51
|
+
/** Conversation messages */
|
|
52
|
+
messages: unknown[];
|
|
53
|
+
/** Suspend execution and wait for input */
|
|
54
|
+
suspend?: (payload: TSuspend, options?: unknown) => Promise<void>;
|
|
55
|
+
/** Thread identifier for memory */
|
|
56
|
+
threadId?: string;
|
|
57
|
+
/** Resource identifier */
|
|
58
|
+
resourceId?: string;
|
|
59
|
+
/** Data from previous suspend (if resuming) */
|
|
60
|
+
resumeData?: TResume;
|
|
61
|
+
};
|
|
62
|
+
/** Workflow-specific context (when called from workflow) */
|
|
63
|
+
workflow?: {
|
|
64
|
+
/** Workflow run identifier */
|
|
65
|
+
runId: string;
|
|
66
|
+
/** Workflow definition identifier */
|
|
67
|
+
workflowId: string;
|
|
68
|
+
/** Current workflow state */
|
|
69
|
+
state: unknown;
|
|
70
|
+
/** Update workflow state */
|
|
71
|
+
setState: (state: unknown) => void;
|
|
72
|
+
/** Suspend workflow and wait for input */
|
|
73
|
+
suspend?: (payload: TSuspend, options?: unknown) => Promise<void>;
|
|
74
|
+
/** Data from previous suspend (if resuming) */
|
|
75
|
+
resumeData?: TResume;
|
|
76
|
+
};
|
|
77
|
+
/** MCP-specific context (when called via Model Context Protocol) */
|
|
78
|
+
mcp?: {
|
|
79
|
+
/** MCP protocol extra context */
|
|
80
|
+
extra: unknown;
|
|
81
|
+
};
|
|
50
82
|
}
|
|
51
83
|
/**
|
|
52
84
|
* Mastra tool definition shape.
|
|
53
85
|
*
|
|
54
|
-
*
|
|
86
|
+
* Matches the output of `createTool()` from `@mastra/core/tools` (v0.24+).
|
|
55
87
|
*
|
|
56
88
|
* Key differences from other frameworks:
|
|
57
89
|
* - Uses `id` only (no `name` property)
|
|
58
90
|
* - Execute signature: `(inputData, context?)` NOT `({ input })`
|
|
59
|
-
* - Context is optional second parameter
|
|
91
|
+
* - Context is optional second parameter with agent/workflow context
|
|
60
92
|
*/
|
|
61
|
-
export interface MastraTool<TInput = unknown, TOutput = unknown> {
|
|
93
|
+
export interface MastraTool<TInput = unknown, TOutput = unknown, TSuspend = unknown, TResume = unknown> {
|
|
62
94
|
/** Unique identifier for the tool */
|
|
63
95
|
id: string;
|
|
64
96
|
/** Description of what the tool does */
|
|
@@ -68,7 +100,9 @@ export interface MastraTool<TInput = unknown, TOutput = unknown> {
|
|
|
68
100
|
/** Zod schema for output validation (null if not specified) */
|
|
69
101
|
outputSchema: z.ZodSchema<TOutput> | undefined;
|
|
70
102
|
/** Tool execution function */
|
|
71
|
-
execute: (inputData: TInput, context?: MastraToolContext) => Promise<TOutput>;
|
|
103
|
+
execute: (inputData: TInput, context?: MastraToolContext<TSuspend, TResume>) => Promise<TOutput>;
|
|
104
|
+
/** Whether tool requires human approval before execution */
|
|
105
|
+
requireApproval?: boolean;
|
|
72
106
|
}
|
|
73
107
|
/**
|
|
74
108
|
* Adapter for converting bigtool-ts tools to Mastra format.
|
|
@@ -99,6 +133,8 @@ export declare class MastraAdapter implements ToolAdapter<MastraTool> {
|
|
|
99
133
|
* Creates a Mastra-compatible tool definition that lazily loads
|
|
100
134
|
* and executes the underlying bigtool-ts tool implementation.
|
|
101
135
|
*
|
|
136
|
+
* Supports abort signal propagation for cancellation.
|
|
137
|
+
*
|
|
102
138
|
* @param metadata - Tool metadata from the catalog
|
|
103
139
|
* @returns Mastra tool definition
|
|
104
140
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.d.ts","sourceRoot":"","sources":["../../src/adapters/mastra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAMhF
|
|
1
|
+
{"version":3,"file":"mastra.d.ts","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AAG,UAAU;IAqBnD;;;;;;;;OAQG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAcxD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAgB9E;;;;;;;;;;;;;;;;;OAiBG;IACH,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU;IAiD7D;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAQtB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,gBAAgB;CAGzB;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAExE"}
|
package/dist/adapters/mastra.js
CHANGED
|
@@ -62,6 +62,8 @@ export class MastraAdapter {
|
|
|
62
62
|
* Creates a Mastra-compatible tool definition that lazily loads
|
|
63
63
|
* and executes the underlying bigtool-ts tool implementation.
|
|
64
64
|
*
|
|
65
|
+
* Supports abort signal propagation for cancellation.
|
|
66
|
+
*
|
|
65
67
|
* @param metadata - Tool metadata from the catalog
|
|
66
68
|
* @returns Mastra tool definition
|
|
67
69
|
*/
|
|
@@ -74,7 +76,9 @@ export class MastraAdapter {
|
|
|
74
76
|
description: metadata.description,
|
|
75
77
|
inputSchema,
|
|
76
78
|
outputSchema: undefined,
|
|
77
|
-
execute: async (inputData) => {
|
|
79
|
+
execute: async (inputData, context) => {
|
|
80
|
+
// Fail fast on abort before expensive loader call
|
|
81
|
+
context?.abortSignal?.throwIfAborted();
|
|
78
82
|
const tool = await loader.load(metadata.id);
|
|
79
83
|
return tool.invoke(inputData);
|
|
80
84
|
},
|