@dexto/tools-builtins 1.7.1 → 1.8.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.
- package/dist/builtin-tools-factory.cjs +4 -0
- package/dist/builtin-tools-factory.d.ts +2 -1
- package/dist/builtin-tools-factory.d.ts.map +1 -1
- package/dist/builtin-tools-factory.js +4 -0
- package/dist/builtin-tools-factory.test.cjs +3 -2
- package/dist/builtin-tools-factory.test.js +3 -2
- package/dist/implementations/ask-user-tool.cjs +5 -5
- package/dist/implementations/ask-user-tool.d.ts +1 -1
- package/dist/implementations/ask-user-tool.d.ts.map +1 -1
- package/dist/implementations/ask-user-tool.js +6 -1
- package/dist/implementations/delegate-to-url-tool.cjs +15 -14
- package/dist/implementations/delegate-to-url-tool.d.ts +1 -1
- package/dist/implementations/delegate-to-url-tool.d.ts.map +1 -1
- package/dist/implementations/delegate-to-url-tool.js +2 -8
- package/dist/implementations/exa-code-search-tool.cjs +4 -4
- package/dist/implementations/exa-code-search-tool.d.ts +1 -1
- package/dist/implementations/exa-code-search-tool.d.ts.map +1 -1
- package/dist/implementations/exa-code-search-tool.js +1 -1
- package/dist/implementations/exa-mcp.cjs +7 -7
- package/dist/implementations/exa-mcp.d.ts +1 -1
- package/dist/implementations/exa-mcp.d.ts.map +1 -1
- package/dist/implementations/exa-mcp.js +2 -2
- package/dist/implementations/exa-web-search-tool.cjs +4 -4
- package/dist/implementations/exa-web-search-tool.d.ts +1 -1
- package/dist/implementations/exa-web-search-tool.d.ts.map +1 -1
- package/dist/implementations/exa-web-search-tool.js +1 -1
- package/dist/implementations/get-resource-tool.cjs +11 -11
- package/dist/implementations/get-resource-tool.d.ts +1 -1
- package/dist/implementations/get-resource-tool.d.ts.map +1 -1
- package/dist/implementations/get-resource-tool.js +12 -7
- package/dist/implementations/http-request-tool.cjs +45 -44
- package/dist/implementations/http-request-tool.d.ts +1 -1
- package/dist/implementations/http-request-tool.d.ts.map +1 -1
- package/dist/implementations/http-request-tool.js +2 -8
- package/dist/implementations/invoke-skill-tool.cjs +22 -170
- package/dist/implementations/invoke-skill-tool.d.ts +1 -8
- package/dist/implementations/invoke-skill-tool.d.ts.map +1 -1
- package/dist/implementations/invoke-skill-tool.js +19 -167
- package/dist/implementations/invoke-skill-tool.test.cjs +61 -85
- package/dist/implementations/invoke-skill-tool.test.js +61 -85
- package/dist/implementations/list-resources-tool.cjs +18 -16
- package/dist/implementations/list-resources-tool.d.ts +2 -2
- package/dist/implementations/list-resources-tool.d.ts.map +1 -1
- package/dist/implementations/list-resources-tool.js +15 -13
- package/dist/implementations/read-skill-tool.cjs +89 -0
- package/dist/implementations/read-skill-tool.d.ts +9 -0
- package/dist/implementations/read-skill-tool.d.ts.map +1 -0
- package/dist/implementations/read-skill-tool.js +65 -0
- package/dist/implementations/read-skill-tool.test.cjs +82 -0
- package/dist/implementations/read-skill-tool.test.d.ts +2 -0
- package/dist/implementations/read-skill-tool.test.d.ts.map +1 -0
- package/dist/implementations/read-skill-tool.test.js +81 -0
- package/dist/implementations/sleep-tool.cjs +3 -3
- package/dist/implementations/sleep-tool.d.ts +1 -1
- package/dist/implementations/sleep-tool.d.ts.map +1 -1
- package/dist/implementations/sleep-tool.js +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -28,6 +28,7 @@ var import_ask_user_tool = require("./implementations/ask-user-tool.js");
|
|
|
28
28
|
var import_delegate_to_url_tool = require("./implementations/delegate-to-url-tool.js");
|
|
29
29
|
var import_get_resource_tool = require("./implementations/get-resource-tool.js");
|
|
30
30
|
var import_invoke_skill_tool = require("./implementations/invoke-skill-tool.js");
|
|
31
|
+
var import_read_skill_tool = require("./implementations/read-skill-tool.js");
|
|
31
32
|
var import_list_resources_tool = require("./implementations/list-resources-tool.js");
|
|
32
33
|
var import_http_request_tool = require("./implementations/http-request-tool.js");
|
|
33
34
|
var import_sleep_tool = require("./implementations/sleep-tool.js");
|
|
@@ -39,6 +40,7 @@ const BUILTIN_TOOL_NAMES = [
|
|
|
39
40
|
"list_resources",
|
|
40
41
|
"get_resource",
|
|
41
42
|
"invoke_skill",
|
|
43
|
+
"read_skill",
|
|
42
44
|
"http_request",
|
|
43
45
|
"sleep",
|
|
44
46
|
"web_search",
|
|
@@ -61,6 +63,8 @@ function createToolByName(name) {
|
|
|
61
63
|
return (0, import_get_resource_tool.createGetResourceTool)();
|
|
62
64
|
case "invoke_skill":
|
|
63
65
|
return (0, import_invoke_skill_tool.createInvokeSkillTool)();
|
|
66
|
+
case "read_skill":
|
|
67
|
+
return (0, import_read_skill_tool.createReadSkillTool)();
|
|
64
68
|
case "http_request":
|
|
65
69
|
return (0, import_http_request_tool.createHttpRequestTool)();
|
|
66
70
|
case "sleep":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ToolFactory } from '@dexto/agent-config';
|
|
3
|
-
export declare const BUILTIN_TOOL_NAMES: readonly ["ask_user", "delegate_to_url", "list_resources", "get_resource", "invoke_skill", "http_request", "sleep", "web_search", "code_search"];
|
|
3
|
+
export declare const BUILTIN_TOOL_NAMES: readonly ["ask_user", "delegate_to_url", "list_resources", "get_resource", "invoke_skill", "read_skill", "http_request", "sleep", "web_search", "code_search"];
|
|
4
4
|
export type BuiltinToolName = (typeof BUILTIN_TOOL_NAMES)[number];
|
|
5
5
|
export declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
6
6
|
type: z.ZodLiteral<"builtin-tools">;
|
|
@@ -9,6 +9,7 @@ export declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
|
9
9
|
delegate_to_url: "delegate_to_url";
|
|
10
10
|
get_resource: "get_resource";
|
|
11
11
|
invoke_skill: "invoke_skill";
|
|
12
|
+
read_skill: "read_skill";
|
|
12
13
|
list_resources: "list_resources";
|
|
13
14
|
http_request: "http_request";
|
|
14
15
|
sleep: "sleep";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-tools-factory.d.ts","sourceRoot":"","sources":["../src/builtin-tools-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"builtin-tools-factory.d.ts","sourceRoot":"","sources":["../src/builtin-tools-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAavD,eAAO,MAAM,kBAAkB,gKAWrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIlE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;kBAKxB,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AA+B3E,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,kBAAkB,CAW/D,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { createAskUserTool } from "./implementations/ask-user-tool.js";
|
|
|
3
3
|
import { createDelegateToUrlTool } from "./implementations/delegate-to-url-tool.js";
|
|
4
4
|
import { createGetResourceTool } from "./implementations/get-resource-tool.js";
|
|
5
5
|
import { createInvokeSkillTool } from "./implementations/invoke-skill-tool.js";
|
|
6
|
+
import { createReadSkillTool } from "./implementations/read-skill-tool.js";
|
|
6
7
|
import { createListResourcesTool } from "./implementations/list-resources-tool.js";
|
|
7
8
|
import { createHttpRequestTool } from "./implementations/http-request-tool.js";
|
|
8
9
|
import { createSleepTool } from "./implementations/sleep-tool.js";
|
|
@@ -14,6 +15,7 @@ const BUILTIN_TOOL_NAMES = [
|
|
|
14
15
|
"list_resources",
|
|
15
16
|
"get_resource",
|
|
16
17
|
"invoke_skill",
|
|
18
|
+
"read_skill",
|
|
17
19
|
"http_request",
|
|
18
20
|
"sleep",
|
|
19
21
|
"web_search",
|
|
@@ -36,6 +38,8 @@ function createToolByName(name) {
|
|
|
36
38
|
return createGetResourceTool();
|
|
37
39
|
case "invoke_skill":
|
|
38
40
|
return createInvokeSkillTool();
|
|
41
|
+
case "read_skill":
|
|
42
|
+
return createReadSkillTool();
|
|
39
43
|
case "http_request":
|
|
40
44
|
return createHttpRequestTool();
|
|
41
45
|
case "sleep":
|
|
@@ -10,6 +10,7 @@ var import_builtin_tools_factory = require("./builtin-tools-factory.js");
|
|
|
10
10
|
"list_resources",
|
|
11
11
|
"get_resource",
|
|
12
12
|
"invoke_skill",
|
|
13
|
+
"read_skill",
|
|
13
14
|
"http_request",
|
|
14
15
|
"sleep",
|
|
15
16
|
"web_search",
|
|
@@ -19,8 +20,8 @@ var import_builtin_tools_factory = require("./builtin-tools-factory.js");
|
|
|
19
20
|
(0, import_vitest.it)("creates only the selected builtins when enabledTools is provided", () => {
|
|
20
21
|
const tools = import_builtin_tools_factory.builtinToolsFactory.create({
|
|
21
22
|
type: "builtin-tools",
|
|
22
|
-
enabledTools: ["ask_user", "
|
|
23
|
+
enabledTools: ["ask_user", "read_skill"]
|
|
23
24
|
});
|
|
24
|
-
(0, import_vitest.expect)(tools.map((t) => t.id)).toEqual(["ask_user", "
|
|
25
|
+
(0, import_vitest.expect)(tools.map((t) => t.id)).toEqual(["ask_user", "read_skill"]);
|
|
25
26
|
});
|
|
26
27
|
});
|
|
@@ -9,6 +9,7 @@ describe("builtinToolsFactory", () => {
|
|
|
9
9
|
"list_resources",
|
|
10
10
|
"get_resource",
|
|
11
11
|
"invoke_skill",
|
|
12
|
+
"read_skill",
|
|
12
13
|
"http_request",
|
|
13
14
|
"sleep",
|
|
14
15
|
"web_search",
|
|
@@ -18,8 +19,8 @@ describe("builtinToolsFactory", () => {
|
|
|
18
19
|
it("creates only the selected builtins when enabledTools is provided", () => {
|
|
19
20
|
const tools = builtinToolsFactory.create({
|
|
20
21
|
type: "builtin-tools",
|
|
21
|
-
enabledTools: ["ask_user", "
|
|
22
|
+
enabledTools: ["ask_user", "read_skill"]
|
|
22
23
|
});
|
|
23
|
-
expect(tools.map((t) => t.id)).toEqual(["ask_user", "
|
|
24
|
+
expect(tools.map((t) => t.id)).toEqual(["ask_user", "read_skill"]);
|
|
24
25
|
});
|
|
25
26
|
});
|
|
@@ -22,7 +22,7 @@ __export(ask_user_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(ask_user_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
const AskUserInputSchema = import_zod.z.object({
|
|
27
27
|
question: import_zod.z.string().describe(
|
|
28
28
|
"High-level prompt/title for the form. Keep this short; clients may display or ignore it."
|
|
@@ -67,21 +67,21 @@ function enrichSchemaTitles(schema) {
|
|
|
67
67
|
return { ...schema, properties: nextProperties };
|
|
68
68
|
}
|
|
69
69
|
function createAskUserTool() {
|
|
70
|
-
return (0,
|
|
70
|
+
return (0, import_tools.defineTool)({
|
|
71
71
|
id: "ask_user",
|
|
72
72
|
description: 'Collect structured input from the user through a form interface. ONLY use this tool when you need: 1) Multiple fields at once (e.g., name + email + preferences), 2) Pre-defined options/choices (use enum for dropdowns like ["small","medium","large"]), 3) Specific data types with validation (boolean for yes/no, number for quantities). DO NOT use for simple conversational questions - just ask those naturally in your response. This tool is for form-like data collection, not chat. Examples: collecting user profile info, configuration settings, or selecting from preset options.',
|
|
73
73
|
inputSchema: AskUserInputSchema,
|
|
74
74
|
presentation: {
|
|
75
|
-
describeHeader: (input) => (0,
|
|
75
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
76
76
|
title: "Ask",
|
|
77
|
-
argsText: (0,
|
|
77
|
+
argsText: (0, import_tools.truncateForHeader)(input.question, 140)
|
|
78
78
|
})
|
|
79
79
|
},
|
|
80
80
|
async execute(input, context) {
|
|
81
81
|
const { question, schema } = input;
|
|
82
82
|
const approvalManager = context.services?.approval;
|
|
83
83
|
if (!approvalManager) {
|
|
84
|
-
throw
|
|
84
|
+
throw import_tools.ToolError.configInvalid(
|
|
85
85
|
"ask_user requires ToolExecutionContext.services.approval"
|
|
86
86
|
);
|
|
87
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-user-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/ask-user-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ask-user-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/ask-user-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAEpE,QAAA,MAAM,kBAAkB;;;;;;;kBAiCX,CAAC;AAiCd;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAiCnE"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ToolError,
|
|
4
|
+
createLocalToolCallHeader,
|
|
5
|
+
defineTool,
|
|
6
|
+
truncateForHeader
|
|
7
|
+
} from "@dexto/core/tools";
|
|
3
8
|
const AskUserInputSchema = z.object({
|
|
4
9
|
question: z.string().describe(
|
|
5
10
|
"High-level prompt/title for the form. Keep this short; clients may display or ignore it."
|
|
@@ -22,7 +22,8 @@ __export(delegate_to_url_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(delegate_to_url_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_errors = require("@dexto/core/errors");
|
|
26
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
27
|
const DelegateToUrlInputSchema = import_zod.z.object({
|
|
27
28
|
url: import_zod.z.string().url().describe(
|
|
28
29
|
'The A2A-compliant agent URL (e.g., "http://localhost:3001" or "https://agent.example.com"). The tool will automatically append the correct JSON-RPC endpoint.'
|
|
@@ -104,10 +105,10 @@ class SimpleA2AClient {
|
|
|
104
105
|
return data;
|
|
105
106
|
} catch (error) {
|
|
106
107
|
if (error instanceof Error && error.name === "AbortError") {
|
|
107
|
-
throw new
|
|
108
|
+
throw new import_errors.DextoRuntimeError(
|
|
108
109
|
"DELEGATION_TIMEOUT",
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
import_errors.ErrorScope.TOOLS,
|
|
111
|
+
import_errors.ErrorType.TIMEOUT,
|
|
111
112
|
`Delegation timeout after ${this.timeout}ms`
|
|
112
113
|
);
|
|
113
114
|
}
|
|
@@ -116,10 +117,10 @@ class SimpleA2AClient {
|
|
|
116
117
|
clearTimeout(timeoutId);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
throw new
|
|
120
|
+
throw new import_errors.DextoRuntimeError(
|
|
120
121
|
"DELEGATION_FAILED",
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
import_errors.ErrorScope.TOOLS,
|
|
123
|
+
import_errors.ErrorType.THIRD_PARTY,
|
|
123
124
|
`Failed to connect to agent at ${this.url}. Tried endpoints: ${endpoints.join(", ")}. Last error: ${lastError?.message || "Unknown error"}`
|
|
124
125
|
);
|
|
125
126
|
}
|
|
@@ -145,14 +146,14 @@ class SimpleA2AClient {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
function createDelegateToUrlTool() {
|
|
148
|
-
return (0,
|
|
149
|
+
return (0, import_tools.defineTool)({
|
|
149
150
|
id: "delegate_to_url",
|
|
150
151
|
description: 'Delegate a task to another A2A-compliant agent at a specific URL. Supports STATEFUL multi-turn conversations via sessionId parameter. USAGE: (1) First delegation: provide url + message. Tool returns a response AND a sessionId. (2) Follow-up: use the SAME sessionId to continue the conversation with that agent. The agent remembers previous context. EXAMPLE: First call {url: "http://agent:3001", message: "Analyze data X"} returns {sessionId: "xyz", response: "..."}. Second call {url: "http://agent:3001", message: "What was the top insight?", sessionId: "xyz"}. The agent will remember the first analysis and can answer specifically.',
|
|
151
152
|
inputSchema: DelegateToUrlInputSchema,
|
|
152
153
|
presentation: {
|
|
153
|
-
describeHeader: (input) => (0,
|
|
154
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
154
155
|
title: "Delegate",
|
|
155
|
-
argsText: (0,
|
|
156
|
+
argsText: (0, import_tools.truncateForHeader)(`${input.url} ${input.message}`, 140)
|
|
156
157
|
})
|
|
157
158
|
},
|
|
158
159
|
async execute(input, _context) {
|
|
@@ -169,13 +170,13 @@ function createDelegateToUrlTool() {
|
|
|
169
170
|
_hint: sessionId ? "Continued existing conversation" : "Started new conversation - use this sessionId for follow-ups"
|
|
170
171
|
};
|
|
171
172
|
} catch (error) {
|
|
172
|
-
if (error instanceof
|
|
173
|
+
if (error instanceof import_errors.DextoRuntimeError) {
|
|
173
174
|
throw error;
|
|
174
175
|
}
|
|
175
|
-
throw new
|
|
176
|
+
throw new import_errors.DextoRuntimeError(
|
|
176
177
|
"DELEGATION_ERROR",
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
import_errors.ErrorScope.TOOLS,
|
|
179
|
+
import_errors.ErrorType.SYSTEM,
|
|
179
180
|
`Delegation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
180
181
|
);
|
|
181
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-to-url-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/delegate-to-url-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"delegate-to-url-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/delegate-to-url-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAIpE,QAAA,MAAM,wBAAwB;;;;;kBA0BjB,CAAC;AAsJd;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAAC,OAAO,wBAAwB,CAAC,CA+C/E"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ErrorScope,
|
|
5
|
-
ErrorType,
|
|
6
|
-
createLocalToolCallHeader,
|
|
7
|
-
defineTool,
|
|
8
|
-
truncateForHeader
|
|
9
|
-
} from "@dexto/core";
|
|
2
|
+
import { DextoRuntimeError, ErrorScope, ErrorType } from "@dexto/core/errors";
|
|
3
|
+
import { createLocalToolCallHeader, defineTool, truncateForHeader } from "@dexto/core/tools";
|
|
10
4
|
const DelegateToUrlInputSchema = z.object({
|
|
11
5
|
url: z.string().url().describe(
|
|
12
6
|
'The A2A-compliant agent URL (e.g., "http://localhost:3001" or "https://agent.example.com"). The tool will automatically append the correct JSON-RPC endpoint.'
|
|
@@ -22,7 +22,7 @@ __export(exa_code_search_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(exa_code_search_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
var import_exa_mcp = require("./exa-mcp.js");
|
|
27
27
|
const CodeSearchInputSchema = import_zod.z.object({
|
|
28
28
|
query: import_zod.z.string().min(1).describe(
|
|
@@ -31,14 +31,14 @@ const CodeSearchInputSchema = import_zod.z.object({
|
|
|
31
31
|
tokensNum: import_zod.z.number().int().min(1e3).max(5e4).optional().default(5e3).describe("Approximate token budget to return (1000\u201350000, default: 5000)")
|
|
32
32
|
}).strict();
|
|
33
33
|
function createCodeSearchTool() {
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, import_tools.defineTool)({
|
|
35
35
|
id: "code_search",
|
|
36
36
|
description: "Search for code examples and documentation across sources like official docs, GitHub, and Stack Overflow. Returns formatted text context.",
|
|
37
37
|
inputSchema: CodeSearchInputSchema,
|
|
38
38
|
presentation: {
|
|
39
|
-
describeHeader: (input) => (0,
|
|
39
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
40
40
|
title: "Code Search",
|
|
41
|
-
argsText: (0,
|
|
41
|
+
argsText: (0, import_tools.truncateForHeader)(input.query, 140)
|
|
42
42
|
})
|
|
43
43
|
},
|
|
44
44
|
async execute(input, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exa-code-search-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-code-search-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"exa-code-search-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-code-search-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAGpE,QAAA,MAAM,qBAAqB;;;kBAiBd,CAAC;AACd;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAAC,OAAO,qBAAqB,CAAC,CA4BzE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createLocalToolCallHeader, defineTool, truncateForHeader } from "@dexto/core";
|
|
2
|
+
import { createLocalToolCallHeader, defineTool, truncateForHeader } from "@dexto/core/tools";
|
|
3
3
|
import { callExaTool } from "./exa-mcp.js";
|
|
4
4
|
const CodeSearchInputSchema = z.object({
|
|
5
5
|
query: z.string().min(1).describe(
|
|
@@ -21,8 +21,8 @@ __export(exa_mcp_exports, {
|
|
|
21
21
|
callExaTool: () => callExaTool
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(exa_mcp_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_mcp = require("@dexto/core/mcp");
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
const EXA_SERVER_URL = "https://mcp.exa.ai/mcp";
|
|
27
27
|
function isPlainObject(value) {
|
|
28
28
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -60,8 +60,8 @@ function extractFirstText(result) {
|
|
|
60
60
|
}
|
|
61
61
|
async function callExaTool(options) {
|
|
62
62
|
const { logger, toolId, toolName, args, timeoutMs } = options;
|
|
63
|
-
const mcpClient = new
|
|
64
|
-
const config =
|
|
63
|
+
const mcpClient = new import_mcp.DextoMcpClient(logger);
|
|
64
|
+
const config = import_mcp.McpServerConfigSchema.parse({
|
|
65
65
|
type: "http",
|
|
66
66
|
enabled: true,
|
|
67
67
|
url: EXA_SERVER_URL,
|
|
@@ -79,15 +79,15 @@ async function callExaTool(options) {
|
|
|
79
79
|
const parsed = asExaToolResult(result);
|
|
80
80
|
if (parsed?.isError) {
|
|
81
81
|
const message = extractFirstText(parsed) ?? "Unknown error from Exa MCP tool";
|
|
82
|
-
throw
|
|
82
|
+
throw import_tools.ToolError.executionFailed(toolId, message);
|
|
83
83
|
}
|
|
84
84
|
const text = parsed ? extractFirstText(parsed) : null;
|
|
85
85
|
return text ?? "No results found. Try a different query.";
|
|
86
86
|
} catch (error) {
|
|
87
87
|
if (error instanceof Error) {
|
|
88
|
-
throw
|
|
88
|
+
throw import_tools.ToolError.executionFailed(toolId, error.message);
|
|
89
89
|
}
|
|
90
|
-
throw
|
|
90
|
+
throw import_tools.ToolError.executionFailed(toolId, String(error));
|
|
91
91
|
} finally {
|
|
92
92
|
await mcpClient.disconnect();
|
|
93
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exa-mcp.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-mcp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"exa-mcp.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-mcp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,KAAK,WAAW,GAAG,gBAAgB,GAAG,sBAAsB,CAAC;AAmD7D;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqClB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DextoMcpClient, McpServerConfigSchema } from "@dexto/core";
|
|
2
|
-
import { ToolError } from "@dexto/core";
|
|
1
|
+
import { DextoMcpClient, McpServerConfigSchema } from "@dexto/core/mcp";
|
|
2
|
+
import { ToolError } from "@dexto/core/tools";
|
|
3
3
|
const EXA_SERVER_URL = "https://mcp.exa.ai/mcp";
|
|
4
4
|
function isPlainObject(value) {
|
|
5
5
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -22,7 +22,7 @@ __export(exa_web_search_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(exa_web_search_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
var import_exa_mcp = require("./exa-mcp.js");
|
|
27
27
|
const WebSearchInputSchema = import_zod.z.object({
|
|
28
28
|
query: import_zod.z.string().min(1).describe("Web search query"),
|
|
@@ -34,14 +34,14 @@ const WebSearchInputSchema = import_zod.z.object({
|
|
|
34
34
|
contextMaxCharacters: import_zod.z.number().int().positive().optional().default(1e4).describe("Maximum context length in characters (default: 10000)")
|
|
35
35
|
}).strict();
|
|
36
36
|
function createWebSearchTool() {
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, import_tools.defineTool)({
|
|
38
38
|
id: "web_search",
|
|
39
39
|
description: "Search the web for current information and return clean, ready-to-use text. Use for news, facts, and up-to-date context.",
|
|
40
40
|
inputSchema: WebSearchInputSchema,
|
|
41
41
|
presentation: {
|
|
42
|
-
describeHeader: (input) => (0,
|
|
42
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
43
43
|
title: "Web Search",
|
|
44
|
-
argsText: (0,
|
|
44
|
+
argsText: (0, import_tools.truncateForHeader)(input.query, 140)
|
|
45
45
|
})
|
|
46
46
|
},
|
|
47
47
|
async execute(input, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exa-web-search-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-web-search-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"exa-web-search-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/exa-web-search-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAGpE,QAAA,MAAM,oBAAoB;;;;;;;;;;;;kBA8Bb,CAAC;AACd;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,OAAO,oBAAoB,CAAC,CA+BvE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createLocalToolCallHeader, defineTool, truncateForHeader } from "@dexto/core";
|
|
2
|
+
import { createLocalToolCallHeader, defineTool, truncateForHeader } from "@dexto/core/tools";
|
|
3
3
|
import { callExaTool } from "./exa-mcp.js";
|
|
4
4
|
const WebSearchInputSchema = z.object({
|
|
5
5
|
query: z.string().min(1).describe("Web search query"),
|
|
@@ -22,7 +22,7 @@ __export(get_resource_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_resource_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
const GetResourceInputSchema = import_zod.z.object({
|
|
27
27
|
reference: import_zod.z.string().describe(
|
|
28
28
|
'The resource reference to access. Formats: "blob:abc123" (from list_resources), "resource_ref:blob:abc123" (from tool annotations)'
|
|
@@ -32,14 +32,14 @@ const GetResourceInputSchema = import_zod.z.object({
|
|
|
32
32
|
)
|
|
33
33
|
}).strict();
|
|
34
34
|
function createGetResourceTool() {
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, import_tools.defineTool)({
|
|
36
36
|
id: "get_resource",
|
|
37
37
|
description: 'Access a stored resource. Use format "url" to get a shareable URL for other agents or external systems (requires remote storage like Supabase). Use format "metadata" to get resource information without loading data. References can be obtained from tool result annotations or list_resources.',
|
|
38
38
|
inputSchema: GetResourceInputSchema,
|
|
39
39
|
presentation: {
|
|
40
|
-
describeHeader: (input) => (0,
|
|
40
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
41
41
|
title: "Get Resource",
|
|
42
|
-
argsText: (0,
|
|
42
|
+
argsText: (0, import_tools.truncateForHeader)(
|
|
43
43
|
input.format === "metadata" ? `${input.reference} (metadata)` : input.reference,
|
|
44
44
|
140
|
|
45
45
|
)
|
|
@@ -49,13 +49,13 @@ function createGetResourceTool() {
|
|
|
49
49
|
const { reference, format } = input;
|
|
50
50
|
const resourceManager = context.services?.resources;
|
|
51
51
|
if (!resourceManager) {
|
|
52
|
-
throw
|
|
52
|
+
throw import_tools.ToolError.configInvalid(
|
|
53
53
|
"get_resource requires ToolExecutionContext.services.resources"
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
|
-
const
|
|
58
|
-
const storeType =
|
|
57
|
+
const artifactStore = resourceManager.getArtifactStore();
|
|
58
|
+
const storeType = (await artifactStore.getStats()).backendType;
|
|
59
59
|
let blobUri = reference;
|
|
60
60
|
if (blobUri.startsWith("resource_ref:")) {
|
|
61
61
|
blobUri = blobUri.substring("resource_ref:".length);
|
|
@@ -66,7 +66,7 @@ function createGetResourceTool() {
|
|
|
66
66
|
if (!blobUri.startsWith("blob:")) {
|
|
67
67
|
blobUri = `blob:${blobUri}`;
|
|
68
68
|
}
|
|
69
|
-
const exists = await
|
|
69
|
+
const exists = await artifactStore.exists({ reference: blobUri });
|
|
70
70
|
if (!exists) {
|
|
71
71
|
return {
|
|
72
72
|
success: false,
|
|
@@ -75,8 +75,8 @@ function createGetResourceTool() {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
if (format === "metadata") {
|
|
78
|
-
const
|
|
79
|
-
const blobRef =
|
|
78
|
+
const artifacts = await artifactStore.listArtifacts();
|
|
79
|
+
const blobRef = artifacts.find((artifact) => artifact.uri === blobUri);
|
|
80
80
|
if (!blobRef) {
|
|
81
81
|
return {
|
|
82
82
|
success: false,
|
|
@@ -103,7 +103,7 @@ function createGetResourceTool() {
|
|
|
103
103
|
storeType
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
const blob = await
|
|
106
|
+
const blob = await artifactStore.retrieve({ reference: blobUri, format: "url" });
|
|
107
107
|
return {
|
|
108
108
|
success: true,
|
|
109
109
|
format: "url",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-resource-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/get-resource-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"get-resource-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/get-resource-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAEpE,QAAA,MAAM,sBAAsB;;;;;;kBAgBf,CAAC;AAEd;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAiH3E"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ToolError,
|
|
4
|
+
createLocalToolCallHeader,
|
|
5
|
+
defineTool,
|
|
6
|
+
truncateForHeader
|
|
7
|
+
} from "@dexto/core/tools";
|
|
3
8
|
const GetResourceInputSchema = z.object({
|
|
4
9
|
reference: z.string().describe(
|
|
5
10
|
'The resource reference to access. Formats: "blob:abc123" (from list_resources), "resource_ref:blob:abc123" (from tool annotations)'
|
|
@@ -31,8 +36,8 @@ function createGetResourceTool() {
|
|
|
31
36
|
);
|
|
32
37
|
}
|
|
33
38
|
try {
|
|
34
|
-
const
|
|
35
|
-
const storeType =
|
|
39
|
+
const artifactStore = resourceManager.getArtifactStore();
|
|
40
|
+
const storeType = (await artifactStore.getStats()).backendType;
|
|
36
41
|
let blobUri = reference;
|
|
37
42
|
if (blobUri.startsWith("resource_ref:")) {
|
|
38
43
|
blobUri = blobUri.substring("resource_ref:".length);
|
|
@@ -43,7 +48,7 @@ function createGetResourceTool() {
|
|
|
43
48
|
if (!blobUri.startsWith("blob:")) {
|
|
44
49
|
blobUri = `blob:${blobUri}`;
|
|
45
50
|
}
|
|
46
|
-
const exists = await
|
|
51
|
+
const exists = await artifactStore.exists({ reference: blobUri });
|
|
47
52
|
if (!exists) {
|
|
48
53
|
return {
|
|
49
54
|
success: false,
|
|
@@ -52,8 +57,8 @@ function createGetResourceTool() {
|
|
|
52
57
|
};
|
|
53
58
|
}
|
|
54
59
|
if (format === "metadata") {
|
|
55
|
-
const
|
|
56
|
-
const blobRef =
|
|
60
|
+
const artifacts = await artifactStore.listArtifacts();
|
|
61
|
+
const blobRef = artifacts.find((artifact) => artifact.uri === blobUri);
|
|
57
62
|
if (!blobRef) {
|
|
58
63
|
return {
|
|
59
64
|
success: false,
|
|
@@ -80,7 +85,7 @@ function createGetResourceTool() {
|
|
|
80
85
|
storeType
|
|
81
86
|
};
|
|
82
87
|
}
|
|
83
|
-
const blob = await
|
|
88
|
+
const blob = await artifactStore.retrieve({ reference: blobUri, format: "url" });
|
|
84
89
|
return {
|
|
85
90
|
success: true,
|
|
86
91
|
format: "url",
|