@dexto/tools-builtins 1.6.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/LICENSE +44 -0
- package/dist/builtin-tools-factory.cjs +95 -0
- package/dist/builtin-tools-factory.d.cts +19 -0
- package/dist/builtin-tools-factory.d.ts +17 -0
- package/dist/builtin-tools-factory.d.ts.map +1 -0
- package/dist/builtin-tools-factory.js +69 -0
- package/dist/builtin-tools-factory.test.cjs +26 -0
- package/dist/builtin-tools-factory.test.d.cts +2 -0
- package/dist/builtin-tools-factory.test.d.ts +2 -0
- package/dist/builtin-tools-factory.test.d.ts.map +1 -0
- package/dist/builtin-tools-factory.test.js +25 -0
- package/dist/implementations/ask-user-tool.cjs +65 -0
- package/dist/implementations/ask-user-tool.d.cts +46 -0
- package/dist/implementations/ask-user-tool.d.ts +45 -0
- package/dist/implementations/ask-user-tool.d.ts.map +1 -0
- package/dist/implementations/ask-user-tool.js +41 -0
- package/dist/implementations/delegate-to-url-tool.cjs +183 -0
- package/dist/implementations/delegate-to-url-tool.d.cts +27 -0
- package/dist/implementations/delegate-to-url-tool.d.ts +26 -0
- package/dist/implementations/delegate-to-url-tool.d.ts.map +1 -0
- package/dist/implementations/delegate-to-url-tool.js +159 -0
- package/dist/implementations/delegate-to-url-tool.test.cjs +75 -0
- package/dist/implementations/delegate-to-url-tool.test.d.cts +2 -0
- package/dist/implementations/delegate-to-url-tool.test.d.ts +2 -0
- package/dist/implementations/delegate-to-url-tool.test.d.ts.map +1 -0
- package/dist/implementations/delegate-to-url-tool.test.js +74 -0
- package/dist/implementations/exa-code-search-tool.cjs +57 -0
- package/dist/implementations/exa-code-search-tool.d.cts +21 -0
- package/dist/implementations/exa-code-search-tool.d.ts +20 -0
- package/dist/implementations/exa-code-search-tool.d.ts.map +1 -0
- package/dist/implementations/exa-code-search-tool.js +33 -0
- package/dist/implementations/exa-mcp.cjs +98 -0
- package/dist/implementations/exa-mcp.d.cts +24 -0
- package/dist/implementations/exa-mcp.d.ts +23 -0
- package/dist/implementations/exa-mcp.d.ts.map +1 -0
- package/dist/implementations/exa-mcp.js +74 -0
- package/dist/implementations/exa-tools.test.cjs +91 -0
- package/dist/implementations/exa-tools.test.d.cts +2 -0
- package/dist/implementations/exa-tools.test.d.ts +2 -0
- package/dist/implementations/exa-tools.test.d.ts.map +1 -0
- package/dist/implementations/exa-tools.test.js +90 -0
- package/dist/implementations/exa-web-search-tool.cjs +63 -0
- package/dist/implementations/exa-web-search-tool.d.cts +30 -0
- package/dist/implementations/exa-web-search-tool.d.ts +29 -0
- package/dist/implementations/exa-web-search-tool.d.ts.map +1 -0
- package/dist/implementations/exa-web-search-tool.js +39 -0
- package/dist/implementations/get-resource-tool.cjs +121 -0
- package/dist/implementations/get-resource-tool.d.cts +22 -0
- package/dist/implementations/get-resource-tool.d.ts +21 -0
- package/dist/implementations/get-resource-tool.d.ts.map +1 -0
- package/dist/implementations/get-resource-tool.js +97 -0
- package/dist/implementations/http-request-tool.cjs +327 -0
- package/dist/implementations/http-request-tool.d.cts +31 -0
- package/dist/implementations/http-request-tool.d.ts +30 -0
- package/dist/implementations/http-request-tool.d.ts.map +1 -0
- package/dist/implementations/http-request-tool.js +303 -0
- package/dist/implementations/invoke-skill-tool.cjs +134 -0
- package/dist/implementations/invoke-skill-tool.d.cts +26 -0
- package/dist/implementations/invoke-skill-tool.d.ts +25 -0
- package/dist/implementations/invoke-skill-tool.d.ts.map +1 -0
- package/dist/implementations/invoke-skill-tool.js +110 -0
- package/dist/implementations/list-resources-tool.cjs +99 -0
- package/dist/implementations/list-resources-tool.d.cts +26 -0
- package/dist/implementations/list-resources-tool.d.ts +25 -0
- package/dist/implementations/list-resources-tool.d.ts.map +1 -0
- package/dist/implementations/list-resources-tool.js +75 -0
- package/dist/implementations/sleep-tool.cjs +45 -0
- package/dist/implementations/sleep-tool.d.cts +16 -0
- package/dist/implementations/sleep-tool.d.ts +15 -0
- package/dist/implementations/sleep-tool.d.ts.map +1 -0
- package/dist/implementations/sleep-tool.js +21 -0
- package/dist/index.cjs +33 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
**Acceptance**
|
|
4
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
5
|
+
|
|
6
|
+
**Copyright License**
|
|
7
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
8
|
+
|
|
9
|
+
**Limitations**
|
|
10
|
+
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
11
|
+
|
|
12
|
+
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
13
|
+
|
|
14
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
15
|
+
|
|
16
|
+
**Patents**
|
|
17
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
18
|
+
|
|
19
|
+
**Notices**
|
|
20
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
21
|
+
|
|
22
|
+
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
23
|
+
|
|
24
|
+
**No Other Rights**
|
|
25
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
26
|
+
|
|
27
|
+
**Termination**
|
|
28
|
+
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
29
|
+
|
|
30
|
+
**No Liability**
|
|
31
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
32
|
+
|
|
33
|
+
**Definitions**
|
|
34
|
+
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
35
|
+
|
|
36
|
+
_you_ refers to the individual or entity agreeing to these terms.
|
|
37
|
+
|
|
38
|
+
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
39
|
+
|
|
40
|
+
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
41
|
+
|
|
42
|
+
_use_ means anything you do with the software requiring one of your licenses.
|
|
43
|
+
|
|
44
|
+
_trademark_ means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,95 @@
|
|
|
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 builtin_tools_factory_exports = {};
|
|
20
|
+
__export(builtin_tools_factory_exports, {
|
|
21
|
+
BUILTIN_TOOL_NAMES: () => BUILTIN_TOOL_NAMES,
|
|
22
|
+
BuiltinToolsConfigSchema: () => BuiltinToolsConfigSchema,
|
|
23
|
+
builtinToolsFactory: () => builtinToolsFactory
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(builtin_tools_factory_exports);
|
|
26
|
+
var import_zod = require("zod");
|
|
27
|
+
var import_ask_user_tool = require("./implementations/ask-user-tool.js");
|
|
28
|
+
var import_delegate_to_url_tool = require("./implementations/delegate-to-url-tool.js");
|
|
29
|
+
var import_get_resource_tool = require("./implementations/get-resource-tool.js");
|
|
30
|
+
var import_invoke_skill_tool = require("./implementations/invoke-skill-tool.js");
|
|
31
|
+
var import_list_resources_tool = require("./implementations/list-resources-tool.js");
|
|
32
|
+
var import_http_request_tool = require("./implementations/http-request-tool.js");
|
|
33
|
+
var import_sleep_tool = require("./implementations/sleep-tool.js");
|
|
34
|
+
var import_exa_web_search_tool = require("./implementations/exa-web-search-tool.js");
|
|
35
|
+
var import_exa_code_search_tool = require("./implementations/exa-code-search-tool.js");
|
|
36
|
+
const BUILTIN_TOOL_NAMES = [
|
|
37
|
+
"ask_user",
|
|
38
|
+
"delegate_to_url",
|
|
39
|
+
"list_resources",
|
|
40
|
+
"get_resource",
|
|
41
|
+
"invoke_skill",
|
|
42
|
+
"http_request",
|
|
43
|
+
"sleep",
|
|
44
|
+
"web_search",
|
|
45
|
+
"code_search"
|
|
46
|
+
];
|
|
47
|
+
const BuiltinToolNameSchema = import_zod.z.enum(BUILTIN_TOOL_NAMES);
|
|
48
|
+
const BuiltinToolsConfigSchema = import_zod.z.object({
|
|
49
|
+
type: import_zod.z.literal("builtin-tools"),
|
|
50
|
+
enabledTools: import_zod.z.array(BuiltinToolNameSchema).optional()
|
|
51
|
+
}).strict();
|
|
52
|
+
function createToolByName(name) {
|
|
53
|
+
switch (name) {
|
|
54
|
+
case "ask_user":
|
|
55
|
+
return (0, import_ask_user_tool.createAskUserTool)();
|
|
56
|
+
case "delegate_to_url":
|
|
57
|
+
return (0, import_delegate_to_url_tool.createDelegateToUrlTool)();
|
|
58
|
+
case "list_resources":
|
|
59
|
+
return (0, import_list_resources_tool.createListResourcesTool)();
|
|
60
|
+
case "get_resource":
|
|
61
|
+
return (0, import_get_resource_tool.createGetResourceTool)();
|
|
62
|
+
case "invoke_skill":
|
|
63
|
+
return (0, import_invoke_skill_tool.createInvokeSkillTool)();
|
|
64
|
+
case "http_request":
|
|
65
|
+
return (0, import_http_request_tool.createHttpRequestTool)();
|
|
66
|
+
case "sleep":
|
|
67
|
+
return (0, import_sleep_tool.createSleepTool)();
|
|
68
|
+
case "web_search":
|
|
69
|
+
return (0, import_exa_web_search_tool.createWebSearchTool)();
|
|
70
|
+
case "code_search":
|
|
71
|
+
return (0, import_exa_code_search_tool.createCodeSearchTool)();
|
|
72
|
+
default: {
|
|
73
|
+
const exhaustive = name;
|
|
74
|
+
throw new Error(`Unknown builtin tool: ${exhaustive}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const builtinToolsFactory = {
|
|
79
|
+
configSchema: BuiltinToolsConfigSchema,
|
|
80
|
+
metadata: {
|
|
81
|
+
displayName: "Built-in Tools",
|
|
82
|
+
description: "Core built-in tools shipped with Dexto",
|
|
83
|
+
category: "core"
|
|
84
|
+
},
|
|
85
|
+
create: (config) => {
|
|
86
|
+
const enabled = config.enabledTools ?? [...BUILTIN_TOOL_NAMES];
|
|
87
|
+
return enabled.map(createToolByName);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
BUILTIN_TOOL_NAMES,
|
|
93
|
+
BuiltinToolsConfigSchema,
|
|
94
|
+
builtinToolsFactory
|
|
95
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ToolFactory } from '@dexto/agent-config';
|
|
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"];
|
|
5
|
+
type BuiltinToolName = (typeof BUILTIN_TOOL_NAMES)[number];
|
|
6
|
+
declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"builtin-tools">;
|
|
8
|
+
enabledTools: z.ZodOptional<z.ZodArray<z.ZodEnum<["ask_user", "delegate_to_url", "list_resources", "get_resource", "invoke_skill", "http_request", "sleep", "web_search", "code_search"]>, "many">>;
|
|
9
|
+
}, "strict", z.ZodTypeAny, {
|
|
10
|
+
type: "builtin-tools";
|
|
11
|
+
enabledTools?: ("ask_user" | "delegate_to_url" | "list_resources" | "get_resource" | "invoke_skill" | "http_request" | "sleep" | "web_search" | "code_search")[] | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
type: "builtin-tools";
|
|
14
|
+
enabledTools?: ("ask_user" | "delegate_to_url" | "list_resources" | "get_resource" | "invoke_skill" | "http_request" | "sleep" | "web_search" | "code_search")[] | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
type BuiltinToolsConfig = z.output<typeof BuiltinToolsConfigSchema>;
|
|
17
|
+
declare const builtinToolsFactory: ToolFactory<BuiltinToolsConfig>;
|
|
18
|
+
|
|
19
|
+
export { BUILTIN_TOOL_NAMES, type BuiltinToolName, type BuiltinToolsConfig, BuiltinToolsConfigSchema, builtinToolsFactory };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
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"];
|
|
4
|
+
export type BuiltinToolName = (typeof BUILTIN_TOOL_NAMES)[number];
|
|
5
|
+
export declare const BuiltinToolsConfigSchema: z.ZodObject<{
|
|
6
|
+
type: z.ZodLiteral<"builtin-tools">;
|
|
7
|
+
enabledTools: z.ZodOptional<z.ZodArray<z.ZodEnum<["ask_user", "delegate_to_url", "list_resources", "get_resource", "invoke_skill", "http_request", "sleep", "web_search", "code_search"]>, "many">>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
type: "builtin-tools";
|
|
10
|
+
enabledTools?: ("ask_user" | "delegate_to_url" | "get_resource" | "invoke_skill" | "list_resources" | "http_request" | "sleep" | "web_search" | "code_search")[] | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
type: "builtin-tools";
|
|
13
|
+
enabledTools?: ("ask_user" | "delegate_to_url" | "get_resource" | "invoke_skill" | "list_resources" | "http_request" | "sleep" | "web_search" | "code_search")[] | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export type BuiltinToolsConfig = z.output<typeof BuiltinToolsConfigSchema>;
|
|
16
|
+
export declare const builtinToolsFactory: ToolFactory<BuiltinToolsConfig>;
|
|
17
|
+
//# sourceMappingURL=builtin-tools-factory.d.ts.map
|
|
@@ -0,0 +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;AAYvD,eAAO,MAAM,kBAAkB,kJAUrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIlE,eAAO,MAAM,wBAAwB;;;;;;;;;EAKxB,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AA6B3E,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,kBAAkB,CAW/D,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createAskUserTool } from "./implementations/ask-user-tool.js";
|
|
3
|
+
import { createDelegateToUrlTool } from "./implementations/delegate-to-url-tool.js";
|
|
4
|
+
import { createGetResourceTool } from "./implementations/get-resource-tool.js";
|
|
5
|
+
import { createInvokeSkillTool } from "./implementations/invoke-skill-tool.js";
|
|
6
|
+
import { createListResourcesTool } from "./implementations/list-resources-tool.js";
|
|
7
|
+
import { createHttpRequestTool } from "./implementations/http-request-tool.js";
|
|
8
|
+
import { createSleepTool } from "./implementations/sleep-tool.js";
|
|
9
|
+
import { createWebSearchTool } from "./implementations/exa-web-search-tool.js";
|
|
10
|
+
import { createCodeSearchTool } from "./implementations/exa-code-search-tool.js";
|
|
11
|
+
const BUILTIN_TOOL_NAMES = [
|
|
12
|
+
"ask_user",
|
|
13
|
+
"delegate_to_url",
|
|
14
|
+
"list_resources",
|
|
15
|
+
"get_resource",
|
|
16
|
+
"invoke_skill",
|
|
17
|
+
"http_request",
|
|
18
|
+
"sleep",
|
|
19
|
+
"web_search",
|
|
20
|
+
"code_search"
|
|
21
|
+
];
|
|
22
|
+
const BuiltinToolNameSchema = z.enum(BUILTIN_TOOL_NAMES);
|
|
23
|
+
const BuiltinToolsConfigSchema = z.object({
|
|
24
|
+
type: z.literal("builtin-tools"),
|
|
25
|
+
enabledTools: z.array(BuiltinToolNameSchema).optional()
|
|
26
|
+
}).strict();
|
|
27
|
+
function createToolByName(name) {
|
|
28
|
+
switch (name) {
|
|
29
|
+
case "ask_user":
|
|
30
|
+
return createAskUserTool();
|
|
31
|
+
case "delegate_to_url":
|
|
32
|
+
return createDelegateToUrlTool();
|
|
33
|
+
case "list_resources":
|
|
34
|
+
return createListResourcesTool();
|
|
35
|
+
case "get_resource":
|
|
36
|
+
return createGetResourceTool();
|
|
37
|
+
case "invoke_skill":
|
|
38
|
+
return createInvokeSkillTool();
|
|
39
|
+
case "http_request":
|
|
40
|
+
return createHttpRequestTool();
|
|
41
|
+
case "sleep":
|
|
42
|
+
return createSleepTool();
|
|
43
|
+
case "web_search":
|
|
44
|
+
return createWebSearchTool();
|
|
45
|
+
case "code_search":
|
|
46
|
+
return createCodeSearchTool();
|
|
47
|
+
default: {
|
|
48
|
+
const exhaustive = name;
|
|
49
|
+
throw new Error(`Unknown builtin tool: ${exhaustive}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const builtinToolsFactory = {
|
|
54
|
+
configSchema: BuiltinToolsConfigSchema,
|
|
55
|
+
metadata: {
|
|
56
|
+
displayName: "Built-in Tools",
|
|
57
|
+
description: "Core built-in tools shipped with Dexto",
|
|
58
|
+
category: "core"
|
|
59
|
+
},
|
|
60
|
+
create: (config) => {
|
|
61
|
+
const enabled = config.enabledTools ?? [...BUILTIN_TOOL_NAMES];
|
|
62
|
+
return enabled.map(createToolByName);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
BUILTIN_TOOL_NAMES,
|
|
67
|
+
BuiltinToolsConfigSchema,
|
|
68
|
+
builtinToolsFactory
|
|
69
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_builtin_tools_factory = require("./builtin-tools-factory.js");
|
|
4
|
+
(0, import_vitest.describe)("builtinToolsFactory", () => {
|
|
5
|
+
(0, import_vitest.it)("creates all builtins when enabledTools is omitted", () => {
|
|
6
|
+
const tools = import_builtin_tools_factory.builtinToolsFactory.create({ type: "builtin-tools" });
|
|
7
|
+
(0, import_vitest.expect)(tools.map((t) => t.id)).toEqual([
|
|
8
|
+
"ask_user",
|
|
9
|
+
"delegate_to_url",
|
|
10
|
+
"list_resources",
|
|
11
|
+
"get_resource",
|
|
12
|
+
"invoke_skill",
|
|
13
|
+
"http_request",
|
|
14
|
+
"sleep",
|
|
15
|
+
"web_search",
|
|
16
|
+
"code_search"
|
|
17
|
+
]);
|
|
18
|
+
});
|
|
19
|
+
(0, import_vitest.it)("creates only the selected builtins when enabledTools is provided", () => {
|
|
20
|
+
const tools = import_builtin_tools_factory.builtinToolsFactory.create({
|
|
21
|
+
type: "builtin-tools",
|
|
22
|
+
enabledTools: ["ask_user", "invoke_skill"]
|
|
23
|
+
});
|
|
24
|
+
(0, import_vitest.expect)(tools.map((t) => t.id)).toEqual(["ask_user", "invoke_skill"]);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin-tools-factory.test.d.ts","sourceRoot":"","sources":["../src/builtin-tools-factory.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { builtinToolsFactory } from "./builtin-tools-factory.js";
|
|
3
|
+
describe("builtinToolsFactory", () => {
|
|
4
|
+
it("creates all builtins when enabledTools is omitted", () => {
|
|
5
|
+
const tools = builtinToolsFactory.create({ type: "builtin-tools" });
|
|
6
|
+
expect(tools.map((t) => t.id)).toEqual([
|
|
7
|
+
"ask_user",
|
|
8
|
+
"delegate_to_url",
|
|
9
|
+
"list_resources",
|
|
10
|
+
"get_resource",
|
|
11
|
+
"invoke_skill",
|
|
12
|
+
"http_request",
|
|
13
|
+
"sleep",
|
|
14
|
+
"web_search",
|
|
15
|
+
"code_search"
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
it("creates only the selected builtins when enabledTools is provided", () => {
|
|
19
|
+
const tools = builtinToolsFactory.create({
|
|
20
|
+
type: "builtin-tools",
|
|
21
|
+
enabledTools: ["ask_user", "invoke_skill"]
|
|
22
|
+
});
|
|
23
|
+
expect(tools.map((t) => t.id)).toEqual(["ask_user", "invoke_skill"]);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
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 ask_user_tool_exports = {};
|
|
20
|
+
__export(ask_user_tool_exports, {
|
|
21
|
+
createAskUserTool: () => createAskUserTool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ask_user_tool_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
var import_core = require("@dexto/core");
|
|
26
|
+
const AskUserInputSchema = import_zod.z.object({
|
|
27
|
+
question: import_zod.z.string().describe("The question or prompt to display to the user"),
|
|
28
|
+
schema: import_zod.z.object({
|
|
29
|
+
type: import_zod.z.literal("object"),
|
|
30
|
+
properties: import_zod.z.record(import_zod.z.unknown()),
|
|
31
|
+
required: import_zod.z.array(import_zod.z.string()).optional()
|
|
32
|
+
}).passthrough().describe(
|
|
33
|
+
'JSON Schema defining form fields. Use descriptive property names as labels (e.g., "favorite_team", "World Cup winner country") - NOT generic names like "q1". Use "enum" for dropdowns, "boolean" for yes/no, "number" for numeric inputs, "string" for text. Include "required" array for mandatory fields.'
|
|
34
|
+
)
|
|
35
|
+
}).strict();
|
|
36
|
+
function createAskUserTool() {
|
|
37
|
+
return (0, import_core.defineTool)({
|
|
38
|
+
id: "ask_user",
|
|
39
|
+
displayName: "Ask",
|
|
40
|
+
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.',
|
|
41
|
+
inputSchema: AskUserInputSchema,
|
|
42
|
+
async execute(input, context) {
|
|
43
|
+
const { question, schema } = input;
|
|
44
|
+
const approvalManager = context.services?.approval;
|
|
45
|
+
if (!approvalManager) {
|
|
46
|
+
throw import_core.ToolError.configInvalid(
|
|
47
|
+
"ask_user requires ToolExecutionContext.services.approval"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const elicitationRequest = {
|
|
51
|
+
schema,
|
|
52
|
+
prompt: question,
|
|
53
|
+
serverName: "Dexto Agent"
|
|
54
|
+
};
|
|
55
|
+
if (context.sessionId !== void 0) {
|
|
56
|
+
elicitationRequest.sessionId = context.sessionId;
|
|
57
|
+
}
|
|
58
|
+
return approvalManager.getElicitationData(elicitationRequest);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
createAskUserTool
|
|
65
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Tool } from '@dexto/core';
|
|
3
|
+
|
|
4
|
+
declare const AskUserInputSchema: z.ZodObject<{
|
|
5
|
+
question: z.ZodString;
|
|
6
|
+
schema: z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"object">;
|
|
8
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
9
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
11
|
+
type: z.ZodLiteral<"object">;
|
|
12
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
13
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
15
|
+
type: z.ZodLiteral<"object">;
|
|
16
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
17
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
19
|
+
}, "strict", z.ZodTypeAny, {
|
|
20
|
+
question: string;
|
|
21
|
+
schema: {
|
|
22
|
+
type: "object";
|
|
23
|
+
properties: Record<string, unknown>;
|
|
24
|
+
required?: string[] | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
[k: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
question: string;
|
|
30
|
+
schema: {
|
|
31
|
+
type: "object";
|
|
32
|
+
properties: Record<string, unknown>;
|
|
33
|
+
required?: string[] | undefined;
|
|
34
|
+
} & {
|
|
35
|
+
[k: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Create the `ask_user` tool.
|
|
40
|
+
*
|
|
41
|
+
* Uses the approval/elicitation channel to collect structured user input via a JSON Schema form.
|
|
42
|
+
* Requires `ToolExecutionContext.services.approval`.
|
|
43
|
+
*/
|
|
44
|
+
declare function createAskUserTool(): Tool<typeof AskUserInputSchema>;
|
|
45
|
+
|
|
46
|
+
export { createAskUserTool };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Tool } from '@dexto/core';
|
|
3
|
+
declare const AskUserInputSchema: z.ZodObject<{
|
|
4
|
+
question: z.ZodString;
|
|
5
|
+
schema: z.ZodObject<{
|
|
6
|
+
type: z.ZodLiteral<"object">;
|
|
7
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
8
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
10
|
+
type: z.ZodLiteral<"object">;
|
|
11
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
12
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
13
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
14
|
+
type: z.ZodLiteral<"object">;
|
|
15
|
+
properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
16
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
18
|
+
}, "strict", z.ZodTypeAny, {
|
|
19
|
+
question: string;
|
|
20
|
+
schema: {
|
|
21
|
+
type: "object";
|
|
22
|
+
properties: Record<string, unknown>;
|
|
23
|
+
required?: string[] | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
[k: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
question: string;
|
|
29
|
+
schema: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: Record<string, unknown>;
|
|
32
|
+
required?: string[] | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Create the `ask_user` tool.
|
|
39
|
+
*
|
|
40
|
+
* Uses the approval/elicitation channel to collect structured user input via a JSON Schema form.
|
|
41
|
+
* Requires `ToolExecutionContext.services.approval`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAskUserTool(): Tool<typeof AskUserInputSchema>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=ask-user-tool.d.ts.map
|
|
@@ -0,0 +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;AAExB,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,aAAa,CAAC;AAE9D,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcX,CAAC;AAEd;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAmCnE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolError, defineTool } from "@dexto/core";
|
|
3
|
+
const AskUserInputSchema = z.object({
|
|
4
|
+
question: z.string().describe("The question or prompt to display to the user"),
|
|
5
|
+
schema: z.object({
|
|
6
|
+
type: z.literal("object"),
|
|
7
|
+
properties: z.record(z.unknown()),
|
|
8
|
+
required: z.array(z.string()).optional()
|
|
9
|
+
}).passthrough().describe(
|
|
10
|
+
'JSON Schema defining form fields. Use descriptive property names as labels (e.g., "favorite_team", "World Cup winner country") - NOT generic names like "q1". Use "enum" for dropdowns, "boolean" for yes/no, "number" for numeric inputs, "string" for text. Include "required" array for mandatory fields.'
|
|
11
|
+
)
|
|
12
|
+
}).strict();
|
|
13
|
+
function createAskUserTool() {
|
|
14
|
+
return defineTool({
|
|
15
|
+
id: "ask_user",
|
|
16
|
+
displayName: "Ask",
|
|
17
|
+
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.',
|
|
18
|
+
inputSchema: AskUserInputSchema,
|
|
19
|
+
async execute(input, context) {
|
|
20
|
+
const { question, schema } = input;
|
|
21
|
+
const approvalManager = context.services?.approval;
|
|
22
|
+
if (!approvalManager) {
|
|
23
|
+
throw ToolError.configInvalid(
|
|
24
|
+
"ask_user requires ToolExecutionContext.services.approval"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const elicitationRequest = {
|
|
28
|
+
schema,
|
|
29
|
+
prompt: question,
|
|
30
|
+
serverName: "Dexto Agent"
|
|
31
|
+
};
|
|
32
|
+
if (context.sessionId !== void 0) {
|
|
33
|
+
elicitationRequest.sessionId = context.sessionId;
|
|
34
|
+
}
|
|
35
|
+
return approvalManager.getElicitationData(elicitationRequest);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
createAskUserTool
|
|
41
|
+
};
|