@dexto/tools-builtins 1.7.2 → 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
|
@@ -22,7 +22,7 @@ __export(list_resources_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(list_resources_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
const ListResourcesInputSchema = import_zod.z.object({
|
|
27
27
|
source: import_zod.z.enum(["all", "tool", "user"]).optional().default("all").describe(
|
|
28
28
|
'Filter by source: "tool" for tool-generated resources, "user" for user-uploaded, "all" for both'
|
|
@@ -31,7 +31,7 @@ const ListResourcesInputSchema = import_zod.z.object({
|
|
|
31
31
|
limit: import_zod.z.number().optional().default(50).describe("Maximum number of resources to return (default: 50)")
|
|
32
32
|
}).strict();
|
|
33
33
|
function createListResourcesTool() {
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, import_tools.defineTool)({
|
|
35
35
|
id: "list_resources",
|
|
36
36
|
description: "List available resources (images, files, etc.). Returns resource references that can be used with get_resource to obtain shareable URLs or metadata. Filter by source (tool/user) or kind (image/audio/video/binary).",
|
|
37
37
|
inputSchema: ListResourcesInputSchema,
|
|
@@ -41,7 +41,7 @@ function createListResourcesTool() {
|
|
|
41
41
|
if (input.source && input.source !== "all") parts.push(`source=${input.source}`);
|
|
42
42
|
if (input.kind && input.kind !== "all") parts.push(`kind=${input.kind}`);
|
|
43
43
|
if (typeof input.limit === "number") parts.push(`limit=${input.limit}`);
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, import_tools.createLocalToolCallHeader)({
|
|
45
45
|
title: "List Resources",
|
|
46
46
|
...parts.length > 0 ? { argsText: parts.join(", ") } : {}
|
|
47
47
|
});
|
|
@@ -51,22 +51,22 @@ function createListResourcesTool() {
|
|
|
51
51
|
const { source, kind, limit } = input;
|
|
52
52
|
const resourceManager = context.services?.resources;
|
|
53
53
|
if (!resourceManager) {
|
|
54
|
-
throw
|
|
54
|
+
throw import_tools.ToolError.configInvalid(
|
|
55
55
|
"list_resources requires ToolExecutionContext.services.resources"
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
try {
|
|
59
|
-
const
|
|
60
|
-
const
|
|
59
|
+
const artifactStore = resourceManager.getArtifactStore();
|
|
60
|
+
const artifacts = await artifactStore.listArtifacts();
|
|
61
61
|
const resources = [];
|
|
62
|
-
for (const
|
|
63
|
-
if (
|
|
62
|
+
for (const artifact of artifacts) {
|
|
63
|
+
if (artifact.metadata.source === "system") {
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
|
-
if (source !== "all" &&
|
|
66
|
+
if (source !== "all" && artifact.metadata.source !== source) {
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
|
-
const mimeType =
|
|
69
|
+
const mimeType = artifact.metadata.mimeType;
|
|
70
70
|
let resourceKind = "binary";
|
|
71
71
|
if (mimeType.startsWith("image/")) resourceKind = "image";
|
|
72
72
|
else if (mimeType.startsWith("audio/")) resourceKind = "audio";
|
|
@@ -75,13 +75,15 @@ function createListResourcesTool() {
|
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
77
|
resources.push({
|
|
78
|
-
reference:
|
|
78
|
+
reference: artifact.uri,
|
|
79
79
|
kind: resourceKind,
|
|
80
|
-
mimeType:
|
|
81
|
-
...
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
mimeType: artifact.metadata.mimeType,
|
|
81
|
+
...artifact.metadata.originalName && {
|
|
82
|
+
filename: artifact.metadata.originalName
|
|
83
|
+
},
|
|
84
|
+
source: artifact.metadata.source || "tool",
|
|
85
|
+
size: artifact.metadata.size,
|
|
86
|
+
createdAt: artifact.metadata.createdAt.toISOString()
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
resources.sort(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { Tool } from '@dexto/core';
|
|
2
|
+
import type { Tool } from '@dexto/core/tools';
|
|
3
3
|
declare const ListResourcesInputSchema: z.ZodObject<{
|
|
4
4
|
source: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
5
5
|
user: "user";
|
|
@@ -18,7 +18,7 @@ declare const ListResourcesInputSchema: z.ZodObject<{
|
|
|
18
18
|
/**
|
|
19
19
|
* Create the `list_resources` tool.
|
|
20
20
|
*
|
|
21
|
-
* Lists stored resources (backed by the configured
|
|
21
|
+
* Lists stored resources (backed by the configured artifact store) and returns references
|
|
22
22
|
* that can be passed to `get_resource`.
|
|
23
23
|
* Requires `ToolExecutionContext.services.resources`.
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-resources-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/list-resources-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"list-resources-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/list-resources-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAEpE,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;kBAoBjB,CAAC;AAYd;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAAC,OAAO,wBAAwB,CAAC,CA4F/E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { ToolError, createLocalToolCallHeader, defineTool } from "@dexto/core";
|
|
2
|
+
import { ToolError, createLocalToolCallHeader, defineTool } from "@dexto/core/tools";
|
|
3
3
|
const ListResourcesInputSchema = z.object({
|
|
4
4
|
source: z.enum(["all", "tool", "user"]).optional().default("all").describe(
|
|
5
5
|
'Filter by source: "tool" for tool-generated resources, "user" for user-uploaded, "all" for both'
|
|
@@ -33,17 +33,17 @@ function createListResourcesTool() {
|
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
try {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
36
|
+
const artifactStore = resourceManager.getArtifactStore();
|
|
37
|
+
const artifacts = await artifactStore.listArtifacts();
|
|
38
38
|
const resources = [];
|
|
39
|
-
for (const
|
|
40
|
-
if (
|
|
39
|
+
for (const artifact of artifacts) {
|
|
40
|
+
if (artifact.metadata.source === "system") {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
if (source !== "all" &&
|
|
43
|
+
if (source !== "all" && artifact.metadata.source !== source) {
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
|
-
const mimeType =
|
|
46
|
+
const mimeType = artifact.metadata.mimeType;
|
|
47
47
|
let resourceKind = "binary";
|
|
48
48
|
if (mimeType.startsWith("image/")) resourceKind = "image";
|
|
49
49
|
else if (mimeType.startsWith("audio/")) resourceKind = "audio";
|
|
@@ -52,13 +52,15 @@ function createListResourcesTool() {
|
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
resources.push({
|
|
55
|
-
reference:
|
|
55
|
+
reference: artifact.uri,
|
|
56
56
|
kind: resourceKind,
|
|
57
|
-
mimeType:
|
|
58
|
-
...
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
mimeType: artifact.metadata.mimeType,
|
|
58
|
+
...artifact.metadata.originalName && {
|
|
59
|
+
filename: artifact.metadata.originalName
|
|
60
|
+
},
|
|
61
|
+
source: artifact.metadata.source || "tool",
|
|
62
|
+
size: artifact.metadata.size,
|
|
63
|
+
createdAt: artifact.metadata.createdAt.toISOString()
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
resources.sort(
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var read_skill_tool_exports = {};
|
|
20
|
+
__export(read_skill_tool_exports, {
|
|
21
|
+
createReadSkillTool: () => createReadSkillTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(read_skill_tool_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
|
+
const ReadSkillInputSchema = import_zod.z.object({
|
|
27
|
+
skill: import_zod.z.string().min(1, "Skill name is required"),
|
|
28
|
+
path: import_zod.z.string().min(1).optional()
|
|
29
|
+
}).strict();
|
|
30
|
+
function createReadSkillTool() {
|
|
31
|
+
return (0, import_tools.defineTool)({
|
|
32
|
+
id: "read_skill",
|
|
33
|
+
description: "Read skill instructions or a file from a skill bundle. This is read-only and does not invoke the skill.",
|
|
34
|
+
inputSchema: ReadSkillInputSchema,
|
|
35
|
+
presentation: {
|
|
36
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
37
|
+
title: "Read Skill",
|
|
38
|
+
argsText: input.path ? `${input.skill}/${input.path}` : input.skill
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
async execute(input, context) {
|
|
42
|
+
const skillManager = getSkillManager(context);
|
|
43
|
+
if (!skillManager) {
|
|
44
|
+
throw import_tools.ToolError.configInvalid(
|
|
45
|
+
"read_skill requires ToolExecutionContext.services.skills"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (input.path) {
|
|
49
|
+
try {
|
|
50
|
+
const content = await skillManager.readFile(input.skill, input.path);
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
skill: input.skill,
|
|
54
|
+
path: input.path,
|
|
55
|
+
content
|
|
56
|
+
};
|
|
57
|
+
} catch {
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: `Skill file not found: ${input.skill}/${input.path}`,
|
|
61
|
+
_hint: "Use a valid file path from the skill bundle."
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const skill = await skillManager.get(input.skill);
|
|
66
|
+
if (!skill) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: `Skill not found: ${input.skill}`,
|
|
70
|
+
_hint: "Use a skill from the available skills list."
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
success: true,
|
|
75
|
+
skill: skill.id,
|
|
76
|
+
displayName: skill.displayName,
|
|
77
|
+
content: skill.instructions
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getSkillManager(context) {
|
|
83
|
+
const services = context.services;
|
|
84
|
+
return services?.skills;
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
createReadSkillTool
|
|
89
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Tool } from '@dexto/core/tools';
|
|
3
|
+
declare const ReadSkillInputSchema: z.ZodObject<{
|
|
4
|
+
skill: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare function createReadSkillTool(): Tool<typeof ReadSkillInputSchema>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=read-skill-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-skill-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/read-skill-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAapE,QAAA,MAAM,oBAAoB;;;kBAKb,CAAC;AAEd,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAwDvE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolError, createLocalToolCallHeader, defineTool } from "@dexto/core/tools";
|
|
3
|
+
const ReadSkillInputSchema = z.object({
|
|
4
|
+
skill: z.string().min(1, "Skill name is required"),
|
|
5
|
+
path: z.string().min(1).optional()
|
|
6
|
+
}).strict();
|
|
7
|
+
function createReadSkillTool() {
|
|
8
|
+
return defineTool({
|
|
9
|
+
id: "read_skill",
|
|
10
|
+
description: "Read skill instructions or a file from a skill bundle. This is read-only and does not invoke the skill.",
|
|
11
|
+
inputSchema: ReadSkillInputSchema,
|
|
12
|
+
presentation: {
|
|
13
|
+
describeHeader: (input) => createLocalToolCallHeader({
|
|
14
|
+
title: "Read Skill",
|
|
15
|
+
argsText: input.path ? `${input.skill}/${input.path}` : input.skill
|
|
16
|
+
})
|
|
17
|
+
},
|
|
18
|
+
async execute(input, context) {
|
|
19
|
+
const skillManager = getSkillManager(context);
|
|
20
|
+
if (!skillManager) {
|
|
21
|
+
throw ToolError.configInvalid(
|
|
22
|
+
"read_skill requires ToolExecutionContext.services.skills"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (input.path) {
|
|
26
|
+
try {
|
|
27
|
+
const content = await skillManager.readFile(input.skill, input.path);
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
skill: input.skill,
|
|
31
|
+
path: input.path,
|
|
32
|
+
content
|
|
33
|
+
};
|
|
34
|
+
} catch {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: `Skill file not found: ${input.skill}/${input.path}`,
|
|
38
|
+
_hint: "Use a valid file path from the skill bundle."
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const skill = await skillManager.get(input.skill);
|
|
43
|
+
if (!skill) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
error: `Skill not found: ${input.skill}`,
|
|
47
|
+
_hint: "Use a skill from the available skills list."
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
skill: skill.id,
|
|
53
|
+
displayName: skill.displayName,
|
|
54
|
+
content: skill.instructions
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function getSkillManager(context) {
|
|
60
|
+
const services = context.services;
|
|
61
|
+
return services?.skills;
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
createReadSkillTool
|
|
65
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_tools = require("@dexto/core/tools");
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_read_skill_tool = require("./read-skill-tool.js");
|
|
5
|
+
(0, import_vitest.describe)("read_skill tool", () => {
|
|
6
|
+
(0, import_vitest.it)("returns primary skill instructions when no path is provided", async () => {
|
|
7
|
+
const skills = {
|
|
8
|
+
get: import_vitest.vi.fn().mockResolvedValue({
|
|
9
|
+
id: "alpha",
|
|
10
|
+
displayName: "Alpha",
|
|
11
|
+
instructions: "Use alpha instructions."
|
|
12
|
+
})
|
|
13
|
+
};
|
|
14
|
+
const tool = (0, import_read_skill_tool.createReadSkillTool)();
|
|
15
|
+
const result = await tool.execute({ skill: "Alpha" }, {
|
|
16
|
+
services: { skills }
|
|
17
|
+
});
|
|
18
|
+
(0, import_vitest.expect)(skills.get).toHaveBeenCalledWith("Alpha");
|
|
19
|
+
(0, import_vitest.expect)(result).toEqual({
|
|
20
|
+
success: true,
|
|
21
|
+
skill: "alpha",
|
|
22
|
+
displayName: "Alpha",
|
|
23
|
+
content: "Use alpha instructions."
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
(0, import_vitest.it)("delegates file reads to SkillManager when path is provided", async () => {
|
|
27
|
+
const skills = {
|
|
28
|
+
get: import_vitest.vi.fn(),
|
|
29
|
+
readFile: import_vitest.vi.fn().mockResolvedValue("# Details\nUse more context.")
|
|
30
|
+
};
|
|
31
|
+
const tool = (0, import_read_skill_tool.createReadSkillTool)();
|
|
32
|
+
const result = await tool.execute({ skill: "Alpha", path: "docs/details.md" }, {
|
|
33
|
+
services: { skills }
|
|
34
|
+
});
|
|
35
|
+
(0, import_vitest.expect)(skills.get).not.toHaveBeenCalled();
|
|
36
|
+
(0, import_vitest.expect)(skills.readFile).toHaveBeenCalledWith("Alpha", "docs/details.md");
|
|
37
|
+
(0, import_vitest.expect)(result).toEqual({
|
|
38
|
+
success: true,
|
|
39
|
+
skill: "Alpha",
|
|
40
|
+
path: "docs/details.md",
|
|
41
|
+
content: "# Details\nUse more context."
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
(0, import_vitest.it)("returns a structured error when the skill is missing", async () => {
|
|
45
|
+
const skills = {
|
|
46
|
+
get: import_vitest.vi.fn().mockResolvedValue(null)
|
|
47
|
+
};
|
|
48
|
+
const tool = (0, import_read_skill_tool.createReadSkillTool)();
|
|
49
|
+
const result = await tool.execute({ skill: "Missing" }, {
|
|
50
|
+
services: { skills }
|
|
51
|
+
});
|
|
52
|
+
(0, import_vitest.expect)(result).toEqual({
|
|
53
|
+
success: false,
|
|
54
|
+
error: "Skill not found: Missing",
|
|
55
|
+
_hint: "Use a skill from the available skills list."
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
(0, import_vitest.it)("returns a structured error when a skill file is missing", async () => {
|
|
59
|
+
const skills = {
|
|
60
|
+
readFile: import_vitest.vi.fn().mockRejectedValue(new Error("Skill file not found"))
|
|
61
|
+
};
|
|
62
|
+
const tool = (0, import_read_skill_tool.createReadSkillTool)();
|
|
63
|
+
const result = await tool.execute({ skill: "Alpha", path: "missing.md" }, {
|
|
64
|
+
services: { skills }
|
|
65
|
+
});
|
|
66
|
+
(0, import_vitest.expect)(result).toEqual({
|
|
67
|
+
success: false,
|
|
68
|
+
error: "Skill file not found: Alpha/missing.md",
|
|
69
|
+
_hint: "Use a valid file path from the skill bundle."
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
(0, import_vitest.it)("requires ToolExecutionContext.services.skills", async () => {
|
|
73
|
+
const tool = (0, import_read_skill_tool.createReadSkillTool)();
|
|
74
|
+
await (0, import_vitest.expect)(
|
|
75
|
+
tool.execute({ skill: "Alpha" }, {})
|
|
76
|
+
).rejects.toMatchObject({
|
|
77
|
+
code: import_tools.ToolError.configInvalid(
|
|
78
|
+
"read_skill requires ToolExecutionContext.services.skills"
|
|
79
|
+
).code
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-skill-tool.test.d.ts","sourceRoot":"","sources":["../../src/implementations/read-skill-tool.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ToolError } from "@dexto/core/tools";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { createReadSkillTool } from "./read-skill-tool.js";
|
|
4
|
+
describe("read_skill tool", () => {
|
|
5
|
+
it("returns primary skill instructions when no path is provided", async () => {
|
|
6
|
+
const skills = {
|
|
7
|
+
get: vi.fn().mockResolvedValue({
|
|
8
|
+
id: "alpha",
|
|
9
|
+
displayName: "Alpha",
|
|
10
|
+
instructions: "Use alpha instructions."
|
|
11
|
+
})
|
|
12
|
+
};
|
|
13
|
+
const tool = createReadSkillTool();
|
|
14
|
+
const result = await tool.execute({ skill: "Alpha" }, {
|
|
15
|
+
services: { skills }
|
|
16
|
+
});
|
|
17
|
+
expect(skills.get).toHaveBeenCalledWith("Alpha");
|
|
18
|
+
expect(result).toEqual({
|
|
19
|
+
success: true,
|
|
20
|
+
skill: "alpha",
|
|
21
|
+
displayName: "Alpha",
|
|
22
|
+
content: "Use alpha instructions."
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it("delegates file reads to SkillManager when path is provided", async () => {
|
|
26
|
+
const skills = {
|
|
27
|
+
get: vi.fn(),
|
|
28
|
+
readFile: vi.fn().mockResolvedValue("# Details\nUse more context.")
|
|
29
|
+
};
|
|
30
|
+
const tool = createReadSkillTool();
|
|
31
|
+
const result = await tool.execute({ skill: "Alpha", path: "docs/details.md" }, {
|
|
32
|
+
services: { skills }
|
|
33
|
+
});
|
|
34
|
+
expect(skills.get).not.toHaveBeenCalled();
|
|
35
|
+
expect(skills.readFile).toHaveBeenCalledWith("Alpha", "docs/details.md");
|
|
36
|
+
expect(result).toEqual({
|
|
37
|
+
success: true,
|
|
38
|
+
skill: "Alpha",
|
|
39
|
+
path: "docs/details.md",
|
|
40
|
+
content: "# Details\nUse more context."
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it("returns a structured error when the skill is missing", async () => {
|
|
44
|
+
const skills = {
|
|
45
|
+
get: vi.fn().mockResolvedValue(null)
|
|
46
|
+
};
|
|
47
|
+
const tool = createReadSkillTool();
|
|
48
|
+
const result = await tool.execute({ skill: "Missing" }, {
|
|
49
|
+
services: { skills }
|
|
50
|
+
});
|
|
51
|
+
expect(result).toEqual({
|
|
52
|
+
success: false,
|
|
53
|
+
error: "Skill not found: Missing",
|
|
54
|
+
_hint: "Use a skill from the available skills list."
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
it("returns a structured error when a skill file is missing", async () => {
|
|
58
|
+
const skills = {
|
|
59
|
+
readFile: vi.fn().mockRejectedValue(new Error("Skill file not found"))
|
|
60
|
+
};
|
|
61
|
+
const tool = createReadSkillTool();
|
|
62
|
+
const result = await tool.execute({ skill: "Alpha", path: "missing.md" }, {
|
|
63
|
+
services: { skills }
|
|
64
|
+
});
|
|
65
|
+
expect(result).toEqual({
|
|
66
|
+
success: false,
|
|
67
|
+
error: "Skill file not found: Alpha/missing.md",
|
|
68
|
+
_hint: "Use a valid file path from the skill bundle."
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it("requires ToolExecutionContext.services.skills", async () => {
|
|
72
|
+
const tool = createReadSkillTool();
|
|
73
|
+
await expect(
|
|
74
|
+
tool.execute({ skill: "Alpha" }, {})
|
|
75
|
+
).rejects.toMatchObject({
|
|
76
|
+
code: ToolError.configInvalid(
|
|
77
|
+
"read_skill requires ToolExecutionContext.services.skills"
|
|
78
|
+
).code
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -22,17 +22,17 @@ __export(sleep_tool_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(sleep_tool_exports);
|
|
24
24
|
var import_zod = require("zod");
|
|
25
|
-
var
|
|
25
|
+
var import_tools = require("@dexto/core/tools");
|
|
26
26
|
const SleepInputSchema = import_zod.z.object({
|
|
27
27
|
ms: import_zod.z.number().int().positive().max(6e5).describe("Milliseconds to sleep (max 10 minutes)")
|
|
28
28
|
}).strict();
|
|
29
29
|
function createSleepTool() {
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, import_tools.defineTool)({
|
|
31
31
|
id: "sleep",
|
|
32
32
|
description: "Pause execution for a specified number of milliseconds.",
|
|
33
33
|
inputSchema: SleepInputSchema,
|
|
34
34
|
presentation: {
|
|
35
|
-
describeHeader: (input) => (0,
|
|
35
|
+
describeHeader: (input) => (0, import_tools.createLocalToolCallHeader)({
|
|
36
36
|
title: "Sleep",
|
|
37
37
|
argsText: `${input.ms}ms`
|
|
38
38
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/sleep-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"sleep-tool.d.ts","sourceRoot":"","sources":["../../src/implementations/sleep-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,mBAAmB,CAAC;AAEpE,QAAA,MAAM,gBAAgB;;kBAST,CAAC;AAEd;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAkB/D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createLocalToolCallHeader, defineTool } from "@dexto/core";
|
|
2
|
+
import { createLocalToolCallHeader, defineTool } from "@dexto/core/tools";
|
|
3
3
|
const SleepInputSchema = z.object({
|
|
4
4
|
ms: z.number().int().positive().max(6e5).describe("Milliseconds to sleep (max 10 minutes)")
|
|
5
5
|
}).strict();
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ToolFactory } from '@dexto/agent-config';
|
|
3
3
|
|
|
4
|
-
declare const BUILTIN_TOOL_NAMES: readonly ["ask_user", "delegate_to_url", "list_resources", "get_resource", "invoke_skill", "http_request", "sleep", "web_search", "code_search"];
|
|
4
|
+
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"];
|
|
5
5
|
type BuiltinToolName = (typeof BUILTIN_TOOL_NAMES)[number];
|
|
6
6
|
declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
7
7
|
type: z.ZodLiteral<"builtin-tools">;
|
|
@@ -10,6 +10,7 @@ declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
|
10
10
|
delegate_to_url: "delegate_to_url";
|
|
11
11
|
get_resource: "get_resource";
|
|
12
12
|
invoke_skill: "invoke_skill";
|
|
13
|
+
read_skill: "read_skill";
|
|
13
14
|
list_resources: "list_resources";
|
|
14
15
|
http_request: "http_request";
|
|
15
16
|
sleep: "sleep";
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/tools-builtins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Built-in tools factory for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"undici": "^7.24.6",
|
|
21
21
|
"zod": "^4.3.6",
|
|
22
|
-
"@dexto/agent-config": "1.
|
|
23
|
-
"@dexto/core": "1.
|
|
22
|
+
"@dexto/agent-config": "1.8.0",
|
|
23
|
+
"@dexto/core": "1.8.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"tsup": "^8.0.0",
|