@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.
@@ -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
- return mutatingLocalWorkdirActions.has(workdirAction(args));
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; directory base for list/search/grep/summarize/context/snapshot."),
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; } });
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USER_AGENT = exports.VERSION = void 0;
4
- exports.VERSION = "1.2.3";
4
+ exports.VERSION = "1.3.1";
5
5
  exports.USER_AGENT = `@agent-api/sdk/${exports.VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/sdk",
3
- "version": "1.2.3",
3
+ "version": "1.3.1",
4
4
  "description": "Production JavaScript SDK for the Managed Agent API",
5
5
  "license": "MIT",
6
6
  "repository": {