@vinhnt-sdk/tools 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-provider.d.ts +30 -0
- package/dist/agent-provider.d.ts.map +1 -0
- package/dist/agent-provider.js +35 -0
- package/dist/agent-provider.js.map +1 -0
- package/dist/define-tool.d.ts +6 -1
- package/dist/define-tool.d.ts.map +1 -1
- package/dist/define-tool.js +8 -5
- package/dist/define-tool.js.map +1 -1
- package/dist/definitions.d.ts +12 -1
- package/dist/definitions.d.ts.map +1 -1
- package/dist/definitions.js +2 -1
- package/dist/definitions.js.map +1 -1
- package/dist/description-lint.d.ts +2 -0
- package/dist/description-lint.d.ts.map +1 -1
- package/dist/description-lint.js.map +1 -1
- package/dist/diff.d.ts +2 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +1 -0
- package/dist/diff.js.map +1 -1
- package/dist/file-history.d.ts +4 -0
- package/dist/file-history.d.ts.map +1 -1
- package/dist/file-history.js +1 -0
- package/dist/file-history.js.map +1 -1
- package/dist/file-tools.d.ts +45 -12
- package/dist/file-tools.d.ts.map +1 -1
- package/dist/file-tools.js +104 -30
- package/dist/file-tools.js.map +1 -1
- package/dist/git-tools.d.ts +5 -1
- package/dist/git-tools.d.ts.map +1 -1
- package/dist/git-tools.js +7 -2
- package/dist/git-tools.js.map +1 -1
- package/dist/history-hook.d.ts +2 -1
- package/dist/history-hook.d.ts.map +1 -1
- package/dist/history-hook.js +4 -3
- package/dist/history-hook.js.map +1 -1
- package/dist/image-tools.d.ts +13 -3
- package/dist/image-tools.d.ts.map +1 -1
- package/dist/image-tools.js +62 -13
- package/dist/image-tools.js.map +1 -1
- package/dist/index.d.ts +38 -230
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -131
- package/dist/index.js.map +1 -1
- package/dist/json-schema.d.ts +3 -0
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/kill-tree.d.ts +36 -0
- package/dist/kill-tree.d.ts.map +1 -0
- package/dist/kill-tree.js +80 -0
- package/dist/kill-tree.js.map +1 -0
- package/dist/lazy-registry.d.ts +5 -3
- package/dist/lazy-registry.d.ts.map +1 -1
- package/dist/lazy-registry.js +1 -0
- package/dist/lazy-registry.js.map +1 -1
- package/dist/policy.d.ts +1 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/providers/builtin-provider.d.ts.map +1 -1
- package/dist/providers/builtin-provider.js +1 -4
- package/dist/providers/builtin-provider.js.map +1 -1
- package/dist/providers/file-loader.d.ts +20 -2
- package/dist/providers/file-loader.d.ts.map +1 -1
- package/dist/providers/file-loader.js +46 -6
- package/dist/providers/file-loader.js.map +1 -1
- package/dist/providers/index.d.ts +0 -4
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/question-tool.d.ts +9 -3
- package/dist/question-tool.d.ts.map +1 -1
- package/dist/question-tool.js +5 -1
- package/dist/question-tool.js.map +1 -1
- package/dist/read-tracker.d.ts +10 -1
- package/dist/read-tracker.d.ts.map +1 -1
- package/dist/read-tracker.js +38 -8
- package/dist/read-tracker.js.map +1 -1
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -2
- package/dist/registry.js.map +1 -1
- package/dist/saga.d.ts +32 -0
- package/dist/saga.d.ts.map +1 -0
- package/dist/saga.js +65 -0
- package/dist/saga.js.map +1 -0
- package/dist/sandbox.d.ts +2 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +10 -43
- package/dist/sandbox.js.map +1 -1
- package/dist/search-tools.d.ts +3 -1
- package/dist/search-tools.d.ts.map +1 -1
- package/dist/search-tools.js +7 -3
- package/dist/search-tools.js.map +1 -1
- package/dist/shell-parser.js +1 -0
- package/dist/shell-parser.js.map +1 -1
- package/dist/shell-tool.d.ts +11 -4
- package/dist/shell-tool.d.ts.map +1 -1
- package/dist/shell-tool.js +16 -9
- package/dist/shell-tool.js.map +1 -1
- package/dist/skill-provider.d.ts +21 -0
- package/dist/skill-provider.d.ts.map +1 -0
- package/dist/skill-provider.js +28 -0
- package/dist/skill-provider.js.map +1 -0
- package/dist/todo-tool.d.ts +2 -1
- package/dist/todo-tool.d.ts.map +1 -1
- package/dist/todo-tool.js +2 -1
- package/dist/todo-tool.js.map +1 -1
- package/dist/tool-sandbox.d.ts +19 -0
- package/dist/tool-sandbox.d.ts.map +1 -0
- package/dist/tool-sandbox.js +100 -0
- package/dist/tool-sandbox.js.map +1 -0
- package/dist/tool-search.d.ts +6 -3
- package/dist/tool-search.d.ts.map +1 -1
- package/dist/tool-search.js +2 -1
- package/dist/tool-search.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +4 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +3 -0
- package/dist/validate.js.map +1 -1
- package/dist/web-search-tool.d.ts +10 -5
- package/dist/web-search-tool.d.ts.map +1 -1
- package/dist/web-search-tool.js +5 -3
- package/dist/web-search-tool.js.map +1 -1
- package/dist/web-tools.d.ts +8 -3
- package/dist/web-tools.d.ts.map +1 -1
- package/dist/web-tools.js +5 -1
- package/dist/web-tools.js.map +1 -1
- package/package.json +10 -9
package/dist/image-tools.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { extname } from "node:path";
|
|
2
|
+
import { extname, resolve } from "node:path";
|
|
3
3
|
import { ValidationError } from "@vinhnt-sdk/schema";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { defineTool } from "
|
|
5
|
+
import { defineTool } from "@vinhnt-sdk/tools";
|
|
6
|
+
import { ensurePathAccess, isWithinWorkspace, resolveRoot } from "./file-tools.js";
|
|
6
7
|
const ReadImageSchema = z.object({
|
|
7
8
|
filePath: z.string().min(1),
|
|
8
9
|
});
|
|
@@ -13,44 +14,92 @@ const MIME_TYPES = {
|
|
|
13
14
|
".gif": "image/gif",
|
|
14
15
|
".webp": "image/webp",
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const DEFAULT_MAX_IMAGE_SIZE = 8 * 1024 * 1024;
|
|
18
|
+
/** Sniff the first bytes of a buffer to confirm it matches the claimed extension. */
|
|
19
|
+
function sniffMagic(buffer, mimeType) {
|
|
20
|
+
switch (mimeType) {
|
|
21
|
+
case "image/png":
|
|
22
|
+
return buffer.length >= 8 && buffer.readUInt32BE(0) === 0x89504e47 && buffer.readUInt32BE(4) === 0x0d0a1a0a;
|
|
23
|
+
case "image/jpeg":
|
|
24
|
+
return buffer.length >= 3 && buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff;
|
|
25
|
+
case "image/gif":
|
|
26
|
+
return buffer.length >= 6 && buffer.subarray(0, 6).toString("ascii") === "GIF87a" || buffer.length >= 6 && buffer.subarray(0, 6).toString("ascii") === "GIF89a";
|
|
27
|
+
case "image/webp": {
|
|
28
|
+
if (buffer.length < 12)
|
|
29
|
+
return false;
|
|
30
|
+
const riff = buffer.subarray(0, 4).toString("ascii");
|
|
31
|
+
const webp = buffer.subarray(8, 12).toString("ascii");
|
|
32
|
+
return riff === "RIFF" && webp === "WEBP";
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Read an image file into model message parts (`text` + base64 `image`),
|
|
40
|
+
* validating the file extension, magic bytes and workspace containment.
|
|
41
|
+
*
|
|
42
|
+
* When `workspaceRoot` is provided the path is checked against the workspace
|
|
43
|
+
* boundary (realpath-aware, symlink-safe) before reading.
|
|
44
|
+
*/
|
|
45
|
+
export function readImageToContentParts(filePath, workspaceRoot, externalDirAccess) {
|
|
46
|
+
return readImageToContentPartsInner(filePath, workspaceRoot, externalDirAccess);
|
|
18
47
|
}
|
|
19
|
-
async function readImageToContentPartsInner(filePath) {
|
|
48
|
+
async function readImageToContentPartsInner(filePath, workspaceRoot, externalDirAccess, ctx, maxSize) {
|
|
20
49
|
const ext = extname(filePath).toLowerCase();
|
|
21
50
|
const mimeType = MIME_TYPES[ext];
|
|
22
51
|
if (!mimeType) {
|
|
23
52
|
throw new ValidationError(`Unsupported image format: ${ext}. Supported: png, jpg, jpeg, gif, webp`);
|
|
24
53
|
}
|
|
25
|
-
const
|
|
54
|
+
const target = workspaceRoot ? await ensurePathAccess(resolve(resolveRoot(workspaceRoot), filePath), resolveRoot(workspaceRoot), filePath, ctx ?? { ask: async () => "reject" }, externalDirAccess) : filePath;
|
|
55
|
+
const buffer = await readFile(target);
|
|
56
|
+
const cap = maxSize ?? DEFAULT_MAX_IMAGE_SIZE;
|
|
57
|
+
if (buffer.length > cap) {
|
|
58
|
+
throw new ValidationError(`Image too large (${buffer.length} bytes). Max: ${cap} bytes`);
|
|
59
|
+
}
|
|
60
|
+
if (!sniffMagic(buffer, mimeType)) {
|
|
61
|
+
throw new ValidationError(`File "${filePath}" does not match its extension (${ext}) — magic bytes mismatch`);
|
|
62
|
+
}
|
|
26
63
|
const base64 = buffer.toString("base64");
|
|
27
64
|
return [
|
|
28
65
|
{ type: "text", text: `[Image: ${filePath}]` },
|
|
29
66
|
{ type: "image", image: base64, mimeType },
|
|
30
67
|
];
|
|
31
68
|
}
|
|
32
|
-
|
|
69
|
+
/** Create the `read_image` tool that returns image content for the model to analyze. */
|
|
70
|
+
export function createReadImageTool(workspaceRoot, externalDirAccess) {
|
|
33
71
|
return defineTool({
|
|
34
72
|
name: "read_image",
|
|
35
73
|
description: "Read an image file and return its content for the model to analyze",
|
|
36
74
|
risk: "read",
|
|
37
75
|
input: ReadImageSchema,
|
|
76
|
+
normalize: (input) => {
|
|
77
|
+
const v = input;
|
|
78
|
+
if (!v || typeof v !== "object")
|
|
79
|
+
return {};
|
|
80
|
+
if (!v.filePath && v.path && typeof v.path === "string") {
|
|
81
|
+
return { filePath: v.path };
|
|
82
|
+
}
|
|
83
|
+
return v;
|
|
84
|
+
},
|
|
38
85
|
jsonSchema: {
|
|
39
86
|
type: "object",
|
|
40
87
|
properties: {
|
|
41
|
-
filePath: { type: "string", description: "Path to
|
|
88
|
+
filePath: { type: "string", description: "Path relative to workspace root" },
|
|
89
|
+
path: { type: "string", description: "Alias for filePath" },
|
|
42
90
|
},
|
|
43
|
-
required: ["filePath"],
|
|
44
91
|
},
|
|
45
|
-
async execute(v) {
|
|
46
|
-
const
|
|
92
|
+
async execute(v, ctx) {
|
|
93
|
+
const filePath = v.filePath;
|
|
94
|
+
const parts = await readImageToContentPartsInner(filePath, workspaceRoot, externalDirAccess, ctx);
|
|
47
95
|
return {
|
|
48
|
-
filePath
|
|
96
|
+
filePath,
|
|
49
97
|
mimeType: parts[1] && "mimeType" in parts[1] ? parts[1].mimeType : undefined,
|
|
50
98
|
size: parts[1] && "image" in parts[1] ? parts[1].image.length : 0,
|
|
51
|
-
message: `Image loaded: ${
|
|
99
|
+
message: `Image loaded: ${filePath}`,
|
|
52
100
|
};
|
|
53
101
|
},
|
|
54
102
|
}).toDefinition();
|
|
55
103
|
}
|
|
104
|
+
export { isWithinWorkspace };
|
|
56
105
|
//# sourceMappingURL=image-tools.js.map
|
package/dist/image-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-tools.js","sourceRoot":"","sources":["../src/image-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"image-tools.js","sourceRoot":"","sources":["../src/image-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC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C;gBACxD,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAC9B,CAAC;YACD,OAAO,CAA4B,CAAC;QACtC,CAAC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;gBAC5E,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAE;aAC5D;SACF;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG;YAClB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;YAC5B,MAAM,KAAK,GAAG,MAAM,4BAA4B,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,CAAC,CAAC;YAClG,OAAO;gBACL,QAAQ;gBACR,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,CAAC,CAAC,CAA2B,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;gBACvG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,CAAC,CAAC,CAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACxF,OAAO,EAAE,iBAAiB,QAAQ,EAAE;aACrC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,YAAY,EAAE,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,247 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Tools enable agents to interact with the file system, execute shell commands,
|
|
5
|
-
* search code, and perform other operations.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { defineTool, ToolRegistry } from "@vinhnt-sdk/tools";
|
|
10
|
-
* import { z } from "zod";
|
|
11
|
-
*
|
|
12
|
-
* const myTool = defineTool({
|
|
13
|
-
* name: "my_tool",
|
|
14
|
-
* description: "A custom tool",
|
|
15
|
-
* risk: "read",
|
|
16
|
-
* input: z.object({
|
|
17
|
-
* query: z.string(),
|
|
18
|
-
* }),
|
|
19
|
-
* async execute(input, ctx) {
|
|
20
|
-
* return `Result: ${input.query}`;
|
|
21
|
-
* },
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* const registry = new ToolRegistry();
|
|
25
|
-
* registry.register(myTool);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* Tool type definition.
|
|
2
|
+
* @module tools
|
|
3
|
+
* Built-in tools for VNT Agent — file, shell, git, web, search, and more.
|
|
30
4
|
*/
|
|
31
5
|
export type { Tool, ToolConfig } from "./define-tool.js";
|
|
32
|
-
/**
|
|
33
|
-
* Define a new tool.
|
|
34
|
-
*/
|
|
35
6
|
export { defineTool, toolToDefinition, zodSchemaToNestedJsonSchema } from "./define-tool.js";
|
|
36
|
-
|
|
37
|
-
* Tool registry for managing tools.
|
|
38
|
-
*/
|
|
39
|
-
export { ToolRegistry } from "./registry.js";
|
|
40
|
-
/**
|
|
41
|
-
* Tool registry types.
|
|
42
|
-
*/
|
|
43
|
-
export type { ToolFilter, ToolPermissionRule, ToolMaterialization } from "./registry.js";
|
|
44
|
-
/**
|
|
45
|
-
* Tool risk levels and definitions.
|
|
46
|
-
*/
|
|
47
|
-
export type { ToolRisk, ToolDefinition } from "./definitions.js";
|
|
48
|
-
/**
|
|
49
|
-
* Tool definition like interface from schema.
|
|
50
|
-
*/
|
|
7
|
+
export { commandPattern, prefix } from "./arity.js";
|
|
51
8
|
export type { ToolDefinitionLike } from "@vinhnt-sdk/schema";
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Tool execution context.
|
|
57
|
-
*/
|
|
9
|
+
export type { ToolDefinition, ToolRisk } from "./definitions.js";
|
|
10
|
+
export type { ToolFilter, ToolPermissionRule, ToolMaterialization } from "./registry.js";
|
|
11
|
+
export { ToolRegistry } from "./registry.js";
|
|
58
12
|
export type { ToolContext, PermissionReply } from "./context.js";
|
|
59
|
-
/**
|
|
60
|
-
* JSON Schema types.
|
|
61
|
-
*/
|
|
62
|
-
export type { JsonSchema7Object, JsonSchemaProperty } from "./json-schema.js";
|
|
63
|
-
/**
|
|
64
|
-
* Tool hooks and execution results.
|
|
65
|
-
*/
|
|
66
13
|
export type { ToolHook, ToolExecutionResult } from "./types.js";
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import { createReadFileTool, createShellTool } from "@vinhnt-sdk/tools";
|
|
73
|
-
*
|
|
74
|
-
* const readFile = createReadFileTool(() => "/workspace");
|
|
75
|
-
* const shell = createShellTool(() => "/workspace");
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
/**
|
|
79
|
-
* File operation tools.
|
|
80
|
-
*/
|
|
81
|
-
export { createReadFileTool, createWriteFileTool, createEditFileTool, createApplyPatchTool } from "./file-tools.js";
|
|
82
|
-
/**
|
|
83
|
-
* Directory listing tool.
|
|
84
|
-
*/
|
|
85
|
-
export { createListDirectoryTool } from "./file-tools.js";
|
|
86
|
-
/**
|
|
87
|
-
* Shell command execution tool.
|
|
88
|
-
*/
|
|
89
|
-
export { createShellTool } from "./shell-tool.js";
|
|
90
|
-
/**
|
|
91
|
-
* Shell tool configuration.
|
|
92
|
-
*/
|
|
93
|
-
export type { ShellToolConfig } from "./shell-tool.js";
|
|
94
|
-
/**
|
|
95
|
-
* Git operation tools.
|
|
96
|
-
*/
|
|
97
|
-
export { createGitStatusTool, createGitDiffTool, createGitLogTool, createGitCommitTool } from "./git-tools.js";
|
|
98
|
-
/**
|
|
99
|
-
* Search tools for file and content search.
|
|
100
|
-
*/
|
|
101
|
-
export { createGlobFilesTool, createGrepFilesTool } from "./search-tools.js";
|
|
102
|
-
/**
|
|
103
|
-
* Web fetch tool.
|
|
104
|
-
*/
|
|
105
|
-
export { createWebFetchTool } from "./web-tools.js";
|
|
106
|
-
/**
|
|
107
|
-
* Image reading tool.
|
|
108
|
-
*/
|
|
109
|
-
export { createReadImageTool, readImageToContentParts } from "./image-tools.js";
|
|
110
|
-
/**
|
|
111
|
-
* Question tool for user interaction.
|
|
112
|
-
*/
|
|
113
|
-
export { createQuestionTool } from "./question-tool.js";
|
|
114
|
-
/**
|
|
115
|
-
* Question tool types.
|
|
116
|
-
*/
|
|
117
|
-
export type { QuestionInput, QuestionHandler } from "./question-tool.js";
|
|
118
|
-
/**
|
|
119
|
-
* Web search tool.
|
|
120
|
-
*/
|
|
121
|
-
export { createWebSearchTool } from "./web-search-tool.js";
|
|
122
|
-
/**
|
|
123
|
-
* Web search tool configuration.
|
|
124
|
-
*/
|
|
125
|
-
export type { WebSearchToolConfig, WebSearchProvider } from "./web-search-tool.js";
|
|
126
|
-
/**
|
|
127
|
-
* Todo list management tool.
|
|
128
|
-
*/
|
|
129
|
-
export { createTodoWriteTool } from "./todo-tool.js";
|
|
130
|
-
/**
|
|
131
|
-
* Tool search tool for finding other tools.
|
|
132
|
-
*/
|
|
133
|
-
export { createToolSearchTool } from "./tool-search.js";
|
|
134
|
-
/**
|
|
135
|
-
* Tool search types.
|
|
136
|
-
*/
|
|
137
|
-
export type { ToolSearchInput, ToolSearchResult } from "./tool-search.js";
|
|
138
|
-
/**
|
|
139
|
-
* Sandbox system for isolated tool execution.
|
|
140
|
-
*/
|
|
141
|
-
/**
|
|
142
|
-
* Sandbox for isolated tool execution.
|
|
143
|
-
*/
|
|
144
|
-
export { ToolSandbox, signalToToolContext, createSandbox } from "./sandbox.js";
|
|
145
|
-
/**
|
|
146
|
-
* Sandbox configuration and types.
|
|
147
|
-
*/
|
|
148
|
-
export type { SandboxConfig, SandboxScope, ProcessSandbox, SandboxResult } from "./sandbox.js";
|
|
149
|
-
/**
|
|
150
|
-
* Utility functions for tools.
|
|
151
|
-
*/
|
|
152
|
-
/**
|
|
153
|
-
* Generate unified diffs.
|
|
154
|
-
*/
|
|
14
|
+
export type { JsonSchema7Object, JsonSchemaProperty } from "./json-schema.js";
|
|
15
|
+
export { validateInput } from "./validate.js";
|
|
16
|
+
export { ToolInputError } from "./validate.js";
|
|
155
17
|
export { generateDiff } from "./diff.js";
|
|
156
|
-
/**
|
|
157
|
-
* Diff types.
|
|
158
|
-
*/
|
|
159
18
|
export type { UnifiedDiff } from "./diff.js";
|
|
160
|
-
/**
|
|
161
|
-
* Tool description linting utilities.
|
|
162
|
-
*/
|
|
163
|
-
export { lintToolDescription, lintToolDefinitions } from "./description-lint.js";
|
|
164
|
-
/**
|
|
165
|
-
* Tool description linting types.
|
|
166
|
-
*/
|
|
167
|
-
export type { ToolDescriptionReport, ToolDescriptionIssue, DescriptionIssueCode } from "./description-lint.js";
|
|
168
|
-
/**
|
|
169
|
-
* Input validation utilities.
|
|
170
|
-
*/
|
|
171
|
-
export { validateInput, ToolInputError } from "./validate.js";
|
|
172
|
-
/**
|
|
173
|
-
* Command pattern utilities.
|
|
174
|
-
*/
|
|
175
|
-
export { commandPattern } from "./arity.js";
|
|
176
|
-
/**
|
|
177
|
-
* File history tracking system.
|
|
178
|
-
*/
|
|
179
|
-
/**
|
|
180
|
-
* File read tracker.
|
|
181
|
-
*/
|
|
182
|
-
export { FileReadTracker } from "./read-tracker.js";
|
|
183
|
-
/**
|
|
184
|
-
* In-memory file history store.
|
|
185
|
-
*/
|
|
186
|
-
export { InMemoryFileHistory } from "./file-history.js";
|
|
187
|
-
/**
|
|
188
|
-
* File history hook for tracking changes.
|
|
189
|
-
*/
|
|
190
|
-
export { createFileHistoryHook } from "./history-hook.js";
|
|
191
|
-
/**
|
|
192
|
-
* File history types.
|
|
193
|
-
*/
|
|
194
|
-
export type { FileHistory, FileVersion, UndoEntry } from "./file-history.js";
|
|
195
|
-
/**
|
|
196
|
-
* Domain system for organizing tools.
|
|
197
|
-
*/
|
|
198
|
-
/**
|
|
199
|
-
* Create a coding domain.
|
|
200
|
-
*/
|
|
201
19
|
export { createCodingDomain } from "./domain.js";
|
|
202
|
-
/**
|
|
203
|
-
* Domain manifest type.
|
|
204
|
-
*/
|
|
205
20
|
export type { DomainManifest } from "./domain.js";
|
|
206
|
-
/**
|
|
207
|
-
* Lazy loading for tools.
|
|
208
|
-
*/
|
|
209
|
-
/**
|
|
210
|
-
* Lazy tool registry for deferred loading.
|
|
211
|
-
*/
|
|
212
21
|
export { LazyToolRegistry } from "./lazy-registry.js";
|
|
213
|
-
/**
|
|
214
|
-
* Lazy tool entry type.
|
|
215
|
-
*/
|
|
216
22
|
export type { LazyToolEntry } from "./lazy-registry.js";
|
|
217
|
-
/**
|
|
218
|
-
* Tool provider system.
|
|
219
|
-
*/
|
|
220
|
-
/**
|
|
221
|
-
* Tool provider registry.
|
|
222
|
-
*/
|
|
223
23
|
export { ToolProviderRegistry } from "./provider.js";
|
|
224
|
-
/**
|
|
225
|
-
* Tool provider interface.
|
|
226
|
-
*/
|
|
227
24
|
export type { ToolProvider } from "./provider.js";
|
|
228
|
-
|
|
229
|
-
* Built-in tool providers.
|
|
230
|
-
*/
|
|
231
|
-
export { BuiltinToolProvider, ToolFileProvider, ToolFileLoader, AgentToolProvider, SkillToolProvider } from "./providers/index.js";
|
|
232
|
-
/**
|
|
233
|
-
* Built-in tool provider configuration.
|
|
234
|
-
*/
|
|
235
|
-
export type { BuiltinToolConfig } from "./providers/index.js";
|
|
236
|
-
/**
|
|
237
|
-
* Tool provider helper functions.
|
|
238
|
-
*/
|
|
239
|
-
export { createToolProviderRegistry, createToolProvider } from "./provider-helpers.js";
|
|
240
|
-
/**
|
|
241
|
-
* Policy system for tool permissions.
|
|
242
|
-
*/
|
|
243
|
-
/**
|
|
244
|
-
* Approval handler type.
|
|
245
|
-
*/
|
|
25
|
+
export { ToolFileProvider, ToolFileLoader } from "./providers/index.js";
|
|
246
26
|
export type { ApprovalHandler } from "./policy.js";
|
|
27
|
+
export { ToolSaga } from "./saga.js";
|
|
28
|
+
export type { SagaEntry, CompensationAction } from "./saga.js";
|
|
29
|
+
export { createReadFileTool, createWriteFileTool, createEditFileTool, createApplyPatchTool, createListDirectoryTool, ensurePathAccess, resolveRoot, DEFAULT_EXCLUDED_DIRS, } from "./file-tools.js";
|
|
30
|
+
export type { RootGetter } from "./file-tools.js";
|
|
31
|
+
export { createReadImageTool, readImageToContentParts } from "./image-tools.js";
|
|
32
|
+
export { FileReadTracker } from "./read-tracker.js";
|
|
33
|
+
export { InMemoryFileHistory } from "./file-history.js";
|
|
34
|
+
export { createFileHistoryHook } from "./history-hook.js";
|
|
35
|
+
export type { FileHistory, FileVersion, UndoEntry } from "./file-history.js";
|
|
36
|
+
export { createShellTool } from "./shell-tool.js";
|
|
37
|
+
export type { ShellToolConfig } from "./shell-tool.js";
|
|
38
|
+
export { ToolSandbox, signalToToolContext, createSandbox } from "./tool-sandbox.js";
|
|
39
|
+
export { createGlobFilesTool, createGrepFilesTool, DEFAULT_IGNORED_DIRS } from "./search-tools.js";
|
|
40
|
+
export { createToolSearchTool } from "./tool-search.js";
|
|
41
|
+
export type { ToolSearchInput, ToolSearchResult } from "./tool-search.js";
|
|
42
|
+
export { createWebFetchTool } from "./web-tools.js";
|
|
43
|
+
export type { WebFetchToolConfig } from "./web-tools.js";
|
|
44
|
+
export { createWebSearchTool, TavilySearchProvider, SerperSearchProvider } from "./web-search-tool.js";
|
|
45
|
+
export type { WebSearchToolConfig, WebSearchProvider, WebSearchResponse, SearchResult } from "./web-search-tool.js";
|
|
46
|
+
export { createGitStatusTool, createGitDiffTool, createGitLogTool, createGitCommitTool } from "./git-tools.js";
|
|
47
|
+
export { createQuestionTool } from "./question-tool.js";
|
|
48
|
+
export type { QuestionInput, QuestionHandler } from "./question-tool.js";
|
|
49
|
+
export { createTodoWriteTool } from "./todo-tool.js";
|
|
50
|
+
export { AgentToolProvider } from "./agent-provider.js";
|
|
51
|
+
export type { KernelLike } from "./agent-provider.js";
|
|
52
|
+
export { SkillToolProvider } from "./skill-provider.js";
|
|
53
|
+
export { readImageToContentParts as readImageFromImageTools } from "./image-tools.js";
|
|
54
|
+
export { lintToolDescription, lintToolDefinitions } from "./description-lint.js";
|
|
247
55
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAIhE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI9E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,E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/tools
|
|
2
|
-
// Tool system for building AI coding agents
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* @module tools
|
|
3
|
+
* Built-in tools for VNT Agent — file, shell, git, web, search, and more.
|
|
5
4
|
*/
|
|
6
5
|
export { defineTool, toolToDefinition, zodSchemaToNestedJsonSchema } from "./define-tool.js";
|
|
7
|
-
|
|
8
|
-
* Tool registry for managing tools.
|
|
9
|
-
*/
|
|
6
|
+
export { commandPattern, prefix } from "./arity.js";
|
|
10
7
|
export { ToolRegistry } from "./registry.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* ```typescript
|
|
16
|
-
* import { createReadFileTool, createShellTool } from "@vinhnt-sdk/tools";
|
|
17
|
-
*
|
|
18
|
-
* const readFile = createReadFileTool(() => "/workspace");
|
|
19
|
-
* const shell = createShellTool(() => "/workspace");
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
// === Built-in tools ===
|
|
23
|
-
/**
|
|
24
|
-
* File operation tools.
|
|
25
|
-
*/
|
|
26
|
-
export { createReadFileTool, createWriteFileTool, createEditFileTool, createApplyPatchTool } from "./file-tools.js";
|
|
27
|
-
/**
|
|
28
|
-
* Directory listing tool.
|
|
29
|
-
*/
|
|
30
|
-
export { createListDirectoryTool } from "./file-tools.js";
|
|
31
|
-
/**
|
|
32
|
-
* Shell command execution tool.
|
|
33
|
-
*/
|
|
34
|
-
export { createShellTool } from "./shell-tool.js";
|
|
35
|
-
/**
|
|
36
|
-
* Git operation tools.
|
|
37
|
-
*/
|
|
38
|
-
export { createGitStatusTool, createGitDiffTool, createGitLogTool, createGitCommitTool } from "./git-tools.js";
|
|
39
|
-
/**
|
|
40
|
-
* Search tools for file and content search.
|
|
41
|
-
*/
|
|
42
|
-
export { createGlobFilesTool, createGrepFilesTool } from "./search-tools.js";
|
|
43
|
-
/**
|
|
44
|
-
* Web fetch tool.
|
|
45
|
-
*/
|
|
46
|
-
export { createWebFetchTool } from "./web-tools.js";
|
|
47
|
-
/**
|
|
48
|
-
* Image reading tool.
|
|
49
|
-
*/
|
|
50
|
-
export { createReadImageTool, readImageToContentParts } from "./image-tools.js";
|
|
51
|
-
/**
|
|
52
|
-
* Question tool for user interaction.
|
|
53
|
-
*/
|
|
54
|
-
export { createQuestionTool } from "./question-tool.js";
|
|
55
|
-
/**
|
|
56
|
-
* Web search tool.
|
|
57
|
-
*/
|
|
58
|
-
export { createWebSearchTool } from "./web-search-tool.js";
|
|
59
|
-
/**
|
|
60
|
-
* Todo list management tool.
|
|
61
|
-
*/
|
|
62
|
-
export { createTodoWriteTool } from "./todo-tool.js";
|
|
63
|
-
/**
|
|
64
|
-
* Tool search tool for finding other tools.
|
|
65
|
-
*/
|
|
66
|
-
export { createToolSearchTool } from "./tool-search.js";
|
|
67
|
-
/**
|
|
68
|
-
* Sandbox system for isolated tool execution.
|
|
69
|
-
*/
|
|
70
|
-
// === Sandbox ===
|
|
71
|
-
/**
|
|
72
|
-
* Sandbox for isolated tool execution.
|
|
73
|
-
*/
|
|
74
|
-
export { ToolSandbox, signalToToolContext, createSandbox } from "./sandbox.js";
|
|
75
|
-
/**
|
|
76
|
-
* Utility functions for tools.
|
|
77
|
-
*/
|
|
78
|
-
// === Utilities ===
|
|
79
|
-
/**
|
|
80
|
-
* Generate unified diffs.
|
|
81
|
-
*/
|
|
8
|
+
// === Validation ===
|
|
9
|
+
export { validateInput } from "./validate.js";
|
|
10
|
+
export { ToolInputError } from "./validate.js";
|
|
11
|
+
// === Diff ===
|
|
82
12
|
export { generateDiff } from "./diff.js";
|
|
83
|
-
/**
|
|
84
|
-
* Tool description linting utilities.
|
|
85
|
-
*/
|
|
86
|
-
export { lintToolDescription, lintToolDefinitions } from "./description-lint.js";
|
|
87
|
-
/**
|
|
88
|
-
* Input validation utilities.
|
|
89
|
-
*/
|
|
90
|
-
export { validateInput, ToolInputError } from "./validate.js";
|
|
91
|
-
/**
|
|
92
|
-
* Command pattern utilities.
|
|
93
|
-
*/
|
|
94
|
-
export { commandPattern } from "./arity.js";
|
|
95
|
-
/**
|
|
96
|
-
* File history tracking system.
|
|
97
|
-
*/
|
|
98
|
-
// === File history ===
|
|
99
|
-
/**
|
|
100
|
-
* File read tracker.
|
|
101
|
-
*/
|
|
102
|
-
export { FileReadTracker } from "./read-tracker.js";
|
|
103
|
-
/**
|
|
104
|
-
* In-memory file history store.
|
|
105
|
-
*/
|
|
106
|
-
export { InMemoryFileHistory } from "./file-history.js";
|
|
107
|
-
/**
|
|
108
|
-
* File history hook for tracking changes.
|
|
109
|
-
*/
|
|
110
|
-
export { createFileHistoryHook } from "./history-hook.js";
|
|
111
|
-
/**
|
|
112
|
-
* Domain system for organizing tools.
|
|
113
|
-
*/
|
|
114
13
|
// === Domain ===
|
|
115
|
-
/**
|
|
116
|
-
* Create a coding domain.
|
|
117
|
-
*/
|
|
118
14
|
export { createCodingDomain } from "./domain.js";
|
|
119
|
-
/**
|
|
120
|
-
* Lazy loading for tools.
|
|
121
|
-
*/
|
|
122
15
|
// === Lazy registry ===
|
|
123
|
-
/**
|
|
124
|
-
* Lazy tool registry for deferred loading.
|
|
125
|
-
*/
|
|
126
16
|
export { LazyToolRegistry } from "./lazy-registry.js";
|
|
127
|
-
/**
|
|
128
|
-
* Tool provider system.
|
|
129
|
-
*/
|
|
130
17
|
// === Provider system ===
|
|
131
|
-
/**
|
|
132
|
-
* Tool provider registry.
|
|
133
|
-
*/
|
|
134
18
|
export { ToolProviderRegistry } from "./provider.js";
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
19
|
+
export { ToolFileProvider, ToolFileLoader } from "./providers/index.js";
|
|
20
|
+
// === Saga ===
|
|
21
|
+
export { ToolSaga } from "./saga.js";
|
|
22
|
+
// === File tools ===
|
|
23
|
+
export { createReadFileTool, createWriteFileTool, createEditFileTool, createApplyPatchTool, createListDirectoryTool, ensurePathAccess, resolveRoot, DEFAULT_EXCLUDED_DIRS, } from "./file-tools.js";
|
|
24
|
+
// === Image tools ===
|
|
25
|
+
export { createReadImageTool, readImageToContentParts } from "./image-tools.js";
|
|
26
|
+
// === File history ===
|
|
27
|
+
export { FileReadTracker } from "./read-tracker.js";
|
|
28
|
+
export { InMemoryFileHistory } from "./file-history.js";
|
|
29
|
+
export { createFileHistoryHook } from "./history-hook.js";
|
|
30
|
+
// === Shell tool ===
|
|
31
|
+
export { createShellTool } from "./shell-tool.js";
|
|
32
|
+
export { ToolSandbox, signalToToolContext, createSandbox } from "./tool-sandbox.js";
|
|
33
|
+
// === Search tools ===
|
|
34
|
+
export { createGlobFilesTool, createGrepFilesTool, DEFAULT_IGNORED_DIRS } from "./search-tools.js";
|
|
35
|
+
export { createToolSearchTool } from "./tool-search.js";
|
|
36
|
+
// === Web tools ===
|
|
37
|
+
export { createWebFetchTool } from "./web-tools.js";
|
|
38
|
+
export { createWebSearchTool, TavilySearchProvider, SerperSearchProvider } from "./web-search-tool.js";
|
|
39
|
+
// === Git tools ===
|
|
40
|
+
export { createGitStatusTool, createGitDiffTool, createGitLogTool, createGitCommitTool } from "./git-tools.js";
|
|
41
|
+
// === Agent tools ===
|
|
42
|
+
export { createQuestionTool } from "./question-tool.js";
|
|
43
|
+
export { createTodoWriteTool } from "./todo-tool.js";
|
|
44
|
+
export { AgentToolProvider } from "./agent-provider.js";
|
|
45
|
+
export { SkillToolProvider } from "./skill-provider.js";
|
|
46
|
+
// === Image tools ===
|
|
47
|
+
export { readImageToContentParts as readImageFromImageTools } from "./image-tools.js";
|
|
48
|
+
// === Description lint ===
|
|
49
|
+
export { lintToolDescription, lintToolDefinitions } from "./description-lint.js";
|
|
143
50
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.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AAiB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpF,uBAAuB;AAEvB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,oBAAoB;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGvG,oBAAoB;AAEpB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE/G,sBAAsB;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,sBAAsB;AAEtB,OAAO,EAAE,uBAAuB,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEtF,2BAA2B;AAE3B,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/json-schema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Nested JSON Schema shape used to describe tool inputs. */
|
|
1
2
|
export interface NestedJsonSchema {
|
|
2
3
|
readonly type: "string" | "number" | "boolean" | "array" | "object";
|
|
3
4
|
readonly description?: string;
|
|
@@ -7,6 +8,7 @@ export interface NestedJsonSchema {
|
|
|
7
8
|
readonly items?: NestedJsonSchema;
|
|
8
9
|
readonly required?: readonly string[];
|
|
9
10
|
}
|
|
11
|
+
/** A single property within a {@link JsonSchema7Object}. */
|
|
10
12
|
export interface JsonSchemaProperty {
|
|
11
13
|
readonly type: "string" | "number" | "boolean" | "array" | "object";
|
|
12
14
|
readonly description?: string;
|
|
@@ -14,6 +16,7 @@ export interface JsonSchemaProperty {
|
|
|
14
16
|
readonly default?: unknown;
|
|
15
17
|
readonly items?: JsonSchemaProperty;
|
|
16
18
|
}
|
|
19
|
+
/** Minimal JSON Schema 7 object for tool input validation. */
|
|
17
20
|
export interface JsonSchema7Object {
|
|
18
21
|
readonly type: "object";
|
|
19
22
|
readonly properties?: Record<string, JsonSchemaProperty>;
|