@agent-api/sdk 1.2.3 → 1.3.1
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/CHANGELOG.md +21 -0
- package/README.md +8 -0
- package/dist/local/core.d.ts +1 -0
- package/dist/local/core.js +22 -1
- package/dist/local/shell.d.ts +76 -0
- package/dist/local/shell.js +347 -13
- package/dist/local/tools.d.ts +1 -0
- package/dist/local/tools.js +38 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/dist-cjs/local/core.js +22 -1
- package/dist-cjs/local/shell.js +348 -13
- package/dist-cjs/local/tools.js +38 -2
- package/dist-cjs/node.js +2 -1
- package/dist-cjs/version.js +1 -1
- package/package.json +1 -1
package/dist-cjs/local/tools.js
CHANGED
|
@@ -13,6 +13,15 @@ class LocalWorkdirDriver {
|
|
|
13
13
|
this.accessMode = options.accessMode ?? "approval";
|
|
14
14
|
}
|
|
15
15
|
async dispatch(args) {
|
|
16
|
+
const action = safeWorkdirAction(args);
|
|
17
|
+
try {
|
|
18
|
+
return await this.dispatchUnsafe(args);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return localToolErrorResult(action, error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async dispatchUnsafe(args) {
|
|
16
25
|
const action = workdirAction(args);
|
|
17
26
|
switch (action) {
|
|
18
27
|
case "summarize":
|
|
@@ -51,7 +60,8 @@ class LocalWorkdirDriver {
|
|
|
51
60
|
if (this.accessMode === "full") {
|
|
52
61
|
return false;
|
|
53
62
|
}
|
|
54
|
-
|
|
63
|
+
const action = safeWorkdirAction(args);
|
|
64
|
+
return action !== "unknown" && mutatingLocalWorkdirActions.has(action);
|
|
55
65
|
}
|
|
56
66
|
async dispatchApplyEdits(args) {
|
|
57
67
|
const edits = editsArg(args);
|
|
@@ -136,6 +146,7 @@ const mutatingLocalWorkdirActions = new Set([
|
|
|
136
146
|
const localWorkdirToolDescription = [
|
|
137
147
|
"Inspect and modify the selected local workdir through one model-facing primitive.",
|
|
138
148
|
"Use action=list/search/grep/summarize/context to discover files, read/read_lines for file content, preview_edits before edits, and apply_edits/write/mkdir/delete only when mutation is intended.",
|
|
149
|
+
"grep searches file contents for a literal substring; path may be omitted, a file path, or a directory subtree.",
|
|
139
150
|
"In approval mode, mutating actions return requires_approval with a safe preview instead of changing files. In full mode, mutating actions execute immediately.",
|
|
140
151
|
"Paths are relative to the selected local workdir; never use absolute paths.",
|
|
141
152
|
].join(" ");
|
|
@@ -146,7 +157,7 @@ function localWorkdirToolParameters() {
|
|
|
146
157
|
enum: localWorkdirActions,
|
|
147
158
|
description: "Workdir operation. Prefer summarize/list/search/grep before reading or editing. Prefer read_lines and apply_edits for source changes.",
|
|
148
159
|
},
|
|
149
|
-
path: stringSchema("Relative path. File path for read/write/delete/edit actions
|
|
160
|
+
path: stringSchema("Relative path. File path for read/write/delete/edit actions. For grep, path may be a file or a directory subtree. For list/search/summarize/context/snapshot, path is a directory base."),
|
|
150
161
|
query: stringSchema("Path/name query for search, or optional context query."),
|
|
151
162
|
pattern: stringSchema("Literal text pattern for grep."),
|
|
152
163
|
content: stringSchema("Text content for write."),
|
|
@@ -189,6 +200,10 @@ function workdirAction(args) {
|
|
|
189
200
|
}
|
|
190
201
|
return value;
|
|
191
202
|
}
|
|
203
|
+
function safeWorkdirAction(args) {
|
|
204
|
+
const value = typeof args.action === "string" ? args.action.trim().toLowerCase() : "";
|
|
205
|
+
return localWorkdirActions.includes(value) ? value : "unknown";
|
|
206
|
+
}
|
|
192
207
|
function summaryArgs(args) {
|
|
193
208
|
return {
|
|
194
209
|
path: optionalStringArg(args, "path"),
|
|
@@ -284,6 +299,27 @@ function localToolResult(action, value) {
|
|
|
284
299
|
}
|
|
285
300
|
return { ok: true, action, result };
|
|
286
301
|
}
|
|
302
|
+
function localToolErrorResult(action, error) {
|
|
303
|
+
const details = errorDetails(error);
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
action,
|
|
307
|
+
error: details.message,
|
|
308
|
+
code: details.code,
|
|
309
|
+
path: details.path,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function errorDetails(error) {
|
|
313
|
+
if (error instanceof Error) {
|
|
314
|
+
const record = error;
|
|
315
|
+
return {
|
|
316
|
+
code: typeof record.code === "string" ? record.code : undefined,
|
|
317
|
+
message: error.message || "local_workdir action failed",
|
|
318
|
+
path: typeof record.path === "string" ? record.path : undefined,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
return { message: String(error || "local_workdir action failed") };
|
|
322
|
+
}
|
|
287
323
|
function stringArg(args, key, alternateKey) {
|
|
288
324
|
const direct = args[key] ?? (alternateKey ? args[alternateKey] : undefined);
|
|
289
325
|
const fromOptions = args.options && typeof args.options === "object"
|
package/dist-cjs/node.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.runLocalSkillHandlers = exports.pendingLocalSkillCalls = exports.localSkillFromDirectory = exports.localWorkdirToolInstructions = exports.localWorkdirToolDefinition = exports.createLocalWorkdirToolRegistry = exports.localShellToolInstructions = exports.localShellToolDefinition = exports.LocalShellDriver = exports.HostLocalShellRunner = exports.LocalWorkdirDriver = exports.createLocalShellToolRegistry = exports.NodeSkillsResource = exports.NodeAgentAPI = void 0;
|
|
17
|
+
exports.runLocalSkillHandlers = exports.pendingLocalSkillCalls = exports.localSkillFromDirectory = exports.localWorkdirToolInstructions = exports.localWorkdirToolDefinition = exports.createLocalWorkdirToolRegistry = exports.localShellToolInstructions = exports.localShellToolDefinition = exports.LocalShellDriver = exports.IsolatorLocalShellRunner = exports.HostLocalShellRunner = exports.LocalWorkdirDriver = exports.createLocalShellToolRegistry = exports.NodeSkillsResource = exports.NodeAgentAPI = void 0;
|
|
18
18
|
__exportStar(require("./index.js"), exports);
|
|
19
19
|
var node_client_js_1 = require("./node-client.js");
|
|
20
20
|
Object.defineProperty(exports, "NodeAgentAPI", { enumerable: true, get: function () { return node_client_js_1.NodeAgentAPI; } });
|
|
@@ -24,6 +24,7 @@ var index_js_1 = require("./local/index.js");
|
|
|
24
24
|
Object.defineProperty(exports, "createLocalShellToolRegistry", { enumerable: true, get: function () { return index_js_1.createLocalShellToolRegistry; } });
|
|
25
25
|
Object.defineProperty(exports, "LocalWorkdirDriver", { enumerable: true, get: function () { return index_js_1.LocalWorkdirDriver; } });
|
|
26
26
|
Object.defineProperty(exports, "HostLocalShellRunner", { enumerable: true, get: function () { return index_js_1.HostLocalShellRunner; } });
|
|
27
|
+
Object.defineProperty(exports, "IsolatorLocalShellRunner", { enumerable: true, get: function () { return index_js_1.IsolatorLocalShellRunner; } });
|
|
27
28
|
Object.defineProperty(exports, "LocalShellDriver", { enumerable: true, get: function () { return index_js_1.LocalShellDriver; } });
|
|
28
29
|
Object.defineProperty(exports, "localShellToolDefinition", { enumerable: true, get: function () { return index_js_1.localShellToolDefinition; } });
|
|
29
30
|
Object.defineProperty(exports, "localShellToolInstructions", { enumerable: true, get: function () { return index_js_1.localShellToolInstructions; } });
|
package/dist-cjs/version.js
CHANGED