@agent-api/sdk 1.1.5 → 1.2.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.
@@ -1,40 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalWorkspaceDriver = void 0;
4
- exports.createLocalWorkspaceToolRegistry = createLocalWorkspaceToolRegistry;
5
- exports.localWorkspaceToolDefinition = localWorkspaceToolDefinition;
6
- exports.localWorkspaceToolInstructions = localWorkspaceToolInstructions;
3
+ exports.LocalWorkdirDriver = void 0;
4
+ exports.createLocalWorkdirToolRegistry = createLocalWorkdirToolRegistry;
5
+ exports.localWorkdirToolDefinition = localWorkdirToolDefinition;
6
+ exports.localWorkdirToolInstructions = localWorkdirToolInstructions;
7
7
  const context_js_1 = require("./context.js");
8
- class LocalWorkspaceDriver {
9
- workspace;
8
+ class LocalWorkdirDriver {
9
+ workdir;
10
10
  accessMode;
11
- constructor(workspace, options = {}) {
12
- this.workspace = workspace;
11
+ constructor(workdir, options = {}) {
12
+ this.workdir = workdir;
13
13
  this.accessMode = options.accessMode ?? "approval";
14
14
  }
15
15
  async dispatch(args) {
16
- const action = workspaceAction(args);
16
+ const action = workdirAction(args);
17
17
  switch (action) {
18
18
  case "summarize":
19
- return localToolResult(action, localSummaryResult(await this.workspace.summarize(summaryArgs(args))));
19
+ return localToolResult(action, localSummaryResult(await this.workdir.summarize(summaryArgs(args))));
20
20
  case "list":
21
- return localToolResult(action, await this.workspace.listEntries(optionalStringArg(args, "path") ?? ".", listArgs(args)));
21
+ return localToolResult(action, await this.workdir.listEntries(optionalStringArg(args, "path") ?? ".", listArgs(args)));
22
22
  case "search":
23
- return localToolResult(action, await this.workspace.searchEntries(searchEntriesArgs(args)));
23
+ return localToolResult(action, await this.workdir.searchEntries(searchEntriesArgs(args)));
24
24
  case "grep":
25
- return localToolResult(action, await this.workspace.grep(grepArgs(args)));
25
+ return localToolResult(action, await this.workdir.grep(grepArgs(args)));
26
26
  case "read":
27
- return localToolResult(action, await this.workspace.readFile(stringArg(args, "path"), readFileArgs(args)));
27
+ return localToolResult(action, await this.workdir.readFile(stringArg(args, "path"), readFileArgs(args)));
28
28
  case "read_lines":
29
- return localToolResult(action, await this.workspace.readLines(stringArg(args, "path"), readLinesArgs(args)));
29
+ return localToolResult(action, await this.workdir.readLines(stringArg(args, "path"), readLinesArgs(args)));
30
30
  case "context":
31
- return localToolResult(action, await (0, context_js_1.createLocalContextPackage)(this.workspace, contextPackageArgs(args)));
31
+ return localToolResult(action, await (0, context_js_1.createLocalContextPackage)(this.workdir, contextPackageArgs(args)));
32
32
  case "snapshot":
33
- return localToolResult(action, await this.workspace.snapshot(snapshotArgs(args)));
33
+ return localToolResult(action, await this.workdir.snapshot(snapshotArgs(args)));
34
34
  case "classify_path":
35
- return localToolResult(action, this.workspace.classifyPath(stringArg(args, "path")));
35
+ return localToolResult(action, this.workdir.classifyPath(stringArg(args, "path")));
36
36
  case "preview_edits":
37
- return localToolResult(action, await this.workspace.previewEdits(editsArg(args)));
37
+ return localToolResult(action, await this.workdir.previewEdits(editsArg(args)));
38
38
  case "apply_edits":
39
39
  return await this.dispatchApplyEdits(args);
40
40
  case "write":
@@ -44,74 +44,74 @@ class LocalWorkspaceDriver {
44
44
  case "delete":
45
45
  return await this.dispatchDelete(args);
46
46
  default:
47
- throw new Error(`unsupported local_workspace action: ${action}`);
47
+ throw new Error(`unsupported local_workdir action: ${action}`);
48
48
  }
49
49
  }
50
50
  requiresApproval(args) {
51
51
  if (this.accessMode === "full") {
52
52
  return false;
53
53
  }
54
- return mutatingLocalWorkspaceActions.has(workspaceAction(args));
54
+ return mutatingLocalWorkdirActions.has(workdirAction(args));
55
55
  }
56
56
  async dispatchApplyEdits(args) {
57
57
  const edits = editsArg(args);
58
58
  if (this.accessMode !== "full") {
59
- return approvalRequired("apply_edits", args, await this.workspace.previewEdits(edits));
59
+ return approvalRequired("apply_edits", args, await this.workdir.previewEdits(edits));
60
60
  }
61
- return localToolResult("apply_edits", await this.workspace.applyEdits(edits));
61
+ return localToolResult("apply_edits", await this.workdir.applyEdits(edits));
62
62
  }
63
63
  async dispatchWrite(args) {
64
64
  if (this.accessMode !== "full") {
65
65
  return approvalRequired("write", args);
66
66
  }
67
- return localToolResult("write", await this.workspace.writeText(stringArg(args, "path"), stringArg(args, "content")));
67
+ return localToolResult("write", await this.workdir.writeText(stringArg(args, "path"), stringArg(args, "content")));
68
68
  }
69
69
  async dispatchMkdir(args) {
70
70
  if (this.accessMode !== "full") {
71
71
  return approvalRequired("mkdir", args);
72
72
  }
73
- return localToolResult("mkdir", await this.workspace.createDirectory(stringArg(args, "path")));
73
+ return localToolResult("mkdir", await this.workdir.createDirectory(stringArg(args, "path")));
74
74
  }
75
75
  async dispatchDelete(args) {
76
76
  if (this.accessMode !== "full") {
77
77
  return approvalRequired("delete", args);
78
78
  }
79
- return localToolResult("delete", await this.workspace.deletePath(stringArg(args, "path")));
79
+ return localToolResult("delete", await this.workdir.deletePath(stringArg(args, "path")));
80
80
  }
81
81
  }
82
- exports.LocalWorkspaceDriver = LocalWorkspaceDriver;
83
- function createLocalWorkspaceToolRegistry(workspace, options = {}) {
84
- const toolName = options.toolName ?? "local_workspace";
85
- const driver = new LocalWorkspaceDriver(workspace, { accessMode: options.accessMode });
86
- const definition = localWorkspaceToolDefinition(toolName);
82
+ exports.LocalWorkdirDriver = LocalWorkdirDriver;
83
+ function createLocalWorkdirToolRegistry(workdir, options = {}) {
84
+ const toolName = options.toolName ?? "local_workdir";
85
+ const driver = new LocalWorkdirDriver(workdir, { accessMode: options.accessMode });
86
+ const definition = localWorkdirToolDefinition(toolName);
87
87
  return {
88
- workspace,
88
+ workdir,
89
89
  accessMode: driver.accessMode,
90
90
  toolName,
91
91
  definitions: () => [{ ...definition }],
92
92
  handlers: () => ({ [toolName]: (args) => driver.dispatch(args) }),
93
93
  execute: async (name, args) => {
94
94
  if (name !== toolName) {
95
- throw new Error(`unknown local workspace tool: ${name}`);
95
+ throw new Error(`unknown local workdir tool: ${name}`);
96
96
  }
97
97
  return await driver.dispatch(args);
98
98
  },
99
99
  requiresApproval: (name, args = {}) => name === toolName && driver.requiresApproval(args),
100
100
  };
101
101
  }
102
- function localWorkspaceToolDefinition(name = "local_workspace") {
102
+ function localWorkdirToolDefinition(name = "local_workdir") {
103
103
  return {
104
104
  type: "function",
105
105
  name,
106
- description: localWorkspaceToolDescription,
107
- parameters: localWorkspaceToolParameters(),
106
+ description: localWorkdirToolDescription,
107
+ parameters: localWorkdirToolParameters(),
108
108
  strict: false,
109
109
  };
110
110
  }
111
- function localWorkspaceToolInstructions() {
112
- return localWorkspaceToolDescription;
111
+ function localWorkdirToolInstructions() {
112
+ return localWorkdirToolDescription;
113
113
  }
114
- const localWorkspaceActions = [
114
+ const localWorkdirActions = [
115
115
  "summarize",
116
116
  "list",
117
117
  "search",
@@ -127,24 +127,24 @@ const localWorkspaceActions = [
127
127
  "mkdir",
128
128
  "delete",
129
129
  ];
130
- const mutatingLocalWorkspaceActions = new Set([
130
+ const mutatingLocalWorkdirActions = new Set([
131
131
  "apply_edits",
132
132
  "write",
133
133
  "mkdir",
134
134
  "delete",
135
135
  ]);
136
- const localWorkspaceToolDescription = [
137
- "Inspect and modify the selected local workspace through one model-facing primitive.",
136
+ const localWorkdirToolDescription = [
137
+ "Inspect and modify the selected local workdir through one model-facing primitive.",
138
138
  "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.",
139
139
  "In approval mode, mutating actions return requires_approval with a safe preview instead of changing files. In full mode, mutating actions execute immediately.",
140
- "Paths are relative to the selected local workspace; never use absolute paths.",
140
+ "Paths are relative to the selected local workdir; never use absolute paths.",
141
141
  ].join(" ");
142
- function localWorkspaceToolParameters() {
142
+ function localWorkdirToolParameters() {
143
143
  return objectSchema({
144
144
  action: {
145
145
  type: "string",
146
- enum: localWorkspaceActions,
147
- description: "Workspace operation. Prefer summarize/list/search/grep before reading or editing. Prefer read_lines and apply_edits for source changes.",
146
+ enum: localWorkdirActions,
147
+ description: "Workdir operation. Prefer summarize/list/search/grep before reading or editing. Prefer read_lines and apply_edits for source changes.",
148
148
  },
149
149
  path: stringSchema("Relative path. File path for read/write/delete/edit actions; directory base for list/search/grep/summarize/context/snapshot."),
150
150
  query: stringSchema("Path/name query for search, or optional context query."),
@@ -175,17 +175,17 @@ function localWorkspaceToolParameters() {
175
175
  max_bytes_per_file: integerSchema("Maximum bytes per file."),
176
176
  max_previews: integerSchema("Maximum summary previews."),
177
177
  include_content: booleanSchema("Include file contents in context packages."),
178
- include_summary: booleanSchema("Include workspace summary in context packages."),
178
+ include_summary: booleanSchema("Include workdir summary in context packages."),
179
179
  include_search: booleanSchema("Include grep results in context packages when query is set."),
180
180
  include_secrets: booleanSchema("Include likely secret file contents in context packages."),
181
181
  hash: booleanSchema("Include SHA-256 hashes in snapshots."),
182
182
  }),
183
183
  }, ["action"]);
184
184
  }
185
- function workspaceAction(args) {
185
+ function workdirAction(args) {
186
186
  const value = stringArg(args, "action").trim().toLowerCase();
187
- if (!localWorkspaceActions.includes(value)) {
188
- throw new Error(`unsupported local_workspace action: ${value}`);
187
+ if (!localWorkdirActions.includes(value)) {
188
+ throw new Error(`unsupported local_workdir action: ${value}`);
189
189
  }
190
190
  return value;
191
191
  }
@@ -352,7 +352,7 @@ function approvalRequired(action, args, preview) {
352
352
  requires_approval: true,
353
353
  arguments: args,
354
354
  preview,
355
- message: `local_workspace action ${action} requires approval`,
355
+ message: `local_workdir action ${action} requires approval`,
356
356
  };
357
357
  }
358
358
  function objectSchema(properties, required = []) {
package/dist-cjs/node.js CHANGED
@@ -14,17 +14,22 @@ 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.localWorkspaceToolInstructions = exports.localWorkspaceToolDefinition = exports.createLocalWorkspaceToolRegistry = exports.LocalWorkspaceDriver = 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.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; } });
21
21
  var skills_node_js_1 = require("./resources/skills-node.js");
22
22
  Object.defineProperty(exports, "NodeSkillsResource", { enumerable: true, get: function () { return skills_node_js_1.NodeSkillsResource; } });
23
- var tools_js_1 = require("./local/tools.js");
24
- Object.defineProperty(exports, "LocalWorkspaceDriver", { enumerable: true, get: function () { return tools_js_1.LocalWorkspaceDriver; } });
25
- Object.defineProperty(exports, "createLocalWorkspaceToolRegistry", { enumerable: true, get: function () { return tools_js_1.createLocalWorkspaceToolRegistry; } });
26
- Object.defineProperty(exports, "localWorkspaceToolDefinition", { enumerable: true, get: function () { return tools_js_1.localWorkspaceToolDefinition; } });
27
- Object.defineProperty(exports, "localWorkspaceToolInstructions", { enumerable: true, get: function () { return tools_js_1.localWorkspaceToolInstructions; } });
23
+ var index_js_1 = require("./local/index.js");
24
+ Object.defineProperty(exports, "createLocalShellToolRegistry", { enumerable: true, get: function () { return index_js_1.createLocalShellToolRegistry; } });
25
+ Object.defineProperty(exports, "LocalWorkdirDriver", { enumerable: true, get: function () { return index_js_1.LocalWorkdirDriver; } });
26
+ Object.defineProperty(exports, "HostLocalShellRunner", { enumerable: true, get: function () { return index_js_1.HostLocalShellRunner; } });
27
+ Object.defineProperty(exports, "LocalShellDriver", { enumerable: true, get: function () { return index_js_1.LocalShellDriver; } });
28
+ Object.defineProperty(exports, "localShellToolDefinition", { enumerable: true, get: function () { return index_js_1.localShellToolDefinition; } });
29
+ Object.defineProperty(exports, "localShellToolInstructions", { enumerable: true, get: function () { return index_js_1.localShellToolInstructions; } });
30
+ Object.defineProperty(exports, "createLocalWorkdirToolRegistry", { enumerable: true, get: function () { return index_js_1.createLocalWorkdirToolRegistry; } });
31
+ Object.defineProperty(exports, "localWorkdirToolDefinition", { enumerable: true, get: function () { return index_js_1.localWorkdirToolDefinition; } });
32
+ Object.defineProperty(exports, "localWorkdirToolInstructions", { enumerable: true, get: function () { return index_js_1.localWorkdirToolInstructions; } });
28
33
  var local_skills_js_1 = require("./local-skills.js");
29
34
  Object.defineProperty(exports, "localSkillFromDirectory", { enumerable: true, get: function () { return local_skills_js_1.localSkillFromDirectory; } });
30
35
  Object.defineProperty(exports, "pendingLocalSkillCalls", { enumerable: true, get: function () { return local_skills_js_1.pendingLocalSkillCalls; } });
@@ -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.1.5";
4
+ exports.VERSION = "1.2.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.1.5",
3
+ "version": "1.2.1",
4
4
  "description": "Production JavaScript SDK for the Managed Agent API",
5
5
  "license": "MIT",
6
6
  "repository": {