zapagent 1.14.26 → 1.14.27

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.
Files changed (49) hide show
  1. package/LICENSE +2 -3
  2. package/README.md +3 -3
  3. package/README.zh-CN.md +3 -3
  4. package/SECURITY.md +3 -2
  5. package/THIRD_PARTY_NOTICES.md +4 -8
  6. package/bundled-dependencies.json +204 -204
  7. package/package.json +1 -1
  8. package/src/App.tsx +19 -6
  9. package/src/agent/remote-agent.ts +150 -0
  10. package/src/agent/remote-turn.ts +72 -0
  11. package/src/agent/wireRunHandlers.ts +5 -2
  12. package/src/agent-factory.ts +19 -2
  13. package/src/approval-facts.ts +20 -3
  14. package/src/commands/dispatcher.ts +47 -3
  15. package/src/commands.ts +4 -0
  16. package/src/config.ts +13 -2
  17. package/src/execution-environment.ts +20 -2
  18. package/src/goal-command.ts +6 -3
  19. package/src/goal-session.ts +1 -1
  20. package/src/goal-turn.ts +1 -1
  21. package/src/headless/runHeadless.ts +2 -1
  22. package/src/hooks/useAgentObjects.ts +8 -0
  23. package/src/hooks/useAgentRunner.ts +50 -1
  24. package/src/permission-policy.ts +5 -2
  25. package/src/permissions.ts +19 -12
  26. package/src/singletons.ts +21 -3
  27. package/src/tool-grants.ts +2 -2
  28. package/src/ui/Transcript.tsx +2 -1
  29. package/src/ui/dialog-approval.tsx +1 -1
  30. package/src/ui/dialog-tool-grant.tsx +2 -2
  31. package/src/ui/footer.tsx +4 -1
  32. package/src/ui/group-logs.ts +1 -1
  33. package/src/ui/live-activity.tsx +1 -1
  34. package/src/ui/slash-palette.tsx +1 -0
  35. package/src/ui/transcript-format.ts +5 -1
  36. package/zapsdk/acp-client/connection.ts +228 -0
  37. package/zapsdk/acp-client/detect.ts +28 -0
  38. package/zapsdk/acp-client/event-mapper.ts +231 -0
  39. package/zapsdk/acp-client/host-handlers.ts +225 -0
  40. package/zapsdk/acp-client/index.ts +6 -0
  41. package/zapsdk/acp-client/run.ts +169 -0
  42. package/zapsdk/acp-client/types.ts +52 -0
  43. package/zapsdk/builtin-tools/acp-agent.ts +188 -0
  44. package/zapsdk/builtin-tools/delegate-detect.ts +1 -1
  45. package/zapsdk/builtin-tools/index.ts +9 -0
  46. package/zapsdk/execution/process.ts +1 -1
  47. package/zapsdk/execution/sandbox.ts +6 -4
  48. package/zapsdk/execution/types.ts +3 -0
  49. package/zapsdk/goal/git-history-snapshot.ts +3 -1
@@ -26,6 +26,7 @@ import type { CronToolsHandle } from "./cron.js";
26
26
  import type { MonitorToolHandle } from "./monitor.js";
27
27
  import { taskStatusTool, taskStopTool, type TaskToolsOptions } from "./task.js";
28
28
  import { delegateAgentTool } from "./delegate.js";
29
+ import { acpAgentTool, type AcpAgentToolOptions } from "./acp-agent.js";
29
30
  import type { DetectedProvider } from "./delegate-detect.js";
30
31
  import type { AgentEventHandler } from "../agent/events.js";
31
32
 
@@ -78,6 +79,7 @@ export { taskStatusTool, taskStopTool, type TaskToolsOptions } from "./task.js";
78
79
  export { subagentTool, type SubagentToolOptions } from "./subagent.js";
79
80
 
80
81
  export { delegateAgentTool, type DelegateAgentOptions } from "./delegate.js";
82
+ export { acpAgentTool, ACP_AGENT_TOOL, type AcpAgentToolOptions } from "./acp-agent.js";
81
83
  export { detectProviders, type DetectedProvider } from "./delegate-detect.js";
82
84
  export { memoryMergeTool, memoryReviewTool, memorySaveTool, type MemoryMergeToolOptions, type MemoryReviewToolOptions, type MemorySaveToolOptions } from "./memory.js";
83
85
 
@@ -134,6 +136,8 @@ export interface BuiltinToolsOptions {
134
136
  timeoutMs?: number;
135
137
  stateDir?: string;
136
138
  };
139
+ /** External ACP agents. Absent or empty → `acp_agent` is not registered. */
140
+ acpAgent?: Omit<AcpAgentToolOptions, "defaultCwd">;
137
141
  exclude?: string[];
138
142
  }
139
143
 
@@ -195,5 +199,10 @@ export function createBuiltinRegistry(options: BuiltinToolsOptions = {}): ToolRe
195
199
  if (tool) registry.register(tool);
196
200
  }
197
201
 
202
+ if (options.acpAgent && !exclude.has("acp_agent")) {
203
+ const tool = acpAgentTool({ ...options.acpAgent, defaultCwd: options.executeCommand?.defaultCwd });
204
+ if (tool) registry.register(tool);
205
+ }
206
+
198
207
  return registry;
199
208
  }
@@ -88,7 +88,7 @@ export class DefaultExecutionProcessBroker implements ExecutionProcessBroker {
88
88
  detached: process.platform !== "win32",
89
89
  shell: false,
90
90
  });
91
- child.stdin?.end();
91
+ if (options.stdin !== "pipe") child.stdin?.end();
92
92
  } catch (error) {
93
93
  release?.();
94
94
  throw error;
@@ -1,7 +1,7 @@
1
1
  import { prepareRootGit } from "./root-git.js";
2
2
  import { existsSync, mkdirSync, mkdtempSync, realpathSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
3
3
  import { homedir, tmpdir } from "node:os";
4
- import { delimiter, dirname, join, resolve } from "node:path";
4
+ import { delimiter, dirname, isAbsolute, join, resolve } from "node:path";
5
5
  import type {
6
6
  OsSandbox,
7
7
  SandboxCommandOptions,
@@ -132,7 +132,6 @@ abstract class CommandWrappingSandbox implements OsSandbox {
132
132
  ): SandboxedCommand => {
133
133
  mkdirSync(this.tempRoot, { recursive: true, mode: 0o700 });
134
134
  const tempDir = mkdtempSync(join(this.tempRoot, "run-"));
135
- const canonicalExecutable = canonicalPath(executable);
136
135
  let proxy: NetworkProxy | undefined;
137
136
  let wrapped: { executable: string; args: string[]; release?: () => void } | undefined;
138
137
  try {
@@ -150,7 +149,9 @@ abstract class CommandWrappingSandbox implements OsSandbox {
150
149
  cwd: canonicalPath(resolve(options.cwd)),
151
150
  readablePaths: [...new Set([
152
151
  ...readablePaths,
153
- dirname(canonicalExecutable),
152
+ // Bare commands resolve on the sandbox PATH. Only an explicit
153
+ // absolute executable needs an additional host directory mount.
154
+ ...(isAbsolute(executable) ? [dirname(canonicalPath(executable))] : []),
154
155
  canonicalPath(tempDir),
155
156
  ])],
156
157
  writablePaths,
@@ -376,9 +377,10 @@ function pathIsWithin(path: string, root: string): boolean {
376
377
  }
377
378
 
378
379
  function missingMountParents(path: string, systemRoots: string[]): string[] {
380
+ if (!isAbsolute(path)) throw new Error("Sandbox mount paths must be absolute");
379
381
  const parents: string[] = [];
380
382
  let current = dirname(path);
381
- while (current !== "/" && !systemRoots.some((root) => pathIsWithin(current, root))) {
383
+ while (dirname(current) !== current && !systemRoots.some((root) => pathIsWithin(current, root))) {
382
384
  parents.push(current);
383
385
  current = dirname(current);
384
386
  }
@@ -47,6 +47,9 @@ export interface SandboxCommandOptions {
47
47
  temporaryDirectoryEnvironment?: string[];
48
48
  /** Trusted adapter endpoints, scoped to this command; explicit host denials still win. */
49
49
  networkDomains?: string[];
50
+ /** "pipe" keeps the child's stdin writable for stdio protocols (ACP).
51
+ * Default closes it right after launch so commands observe EOF. */
52
+ stdin?: "close" | "pipe";
50
53
  }
51
54
 
52
55
  export interface SandboxExecutionContext {
@@ -199,7 +199,9 @@ export async function materializePrivateGitMetadata(repository: string, workspac
199
199
  await validate(repo);
200
200
  await mkdir(directory, { mode: 0o700 }); // exclusive: never replace a user's .git
201
201
  try {
202
- await cp(repo, directory, { recursive: true, force: false, errorOnExist: true, verbatimSymlinks: true });
202
+ for (const name of await readdir(repo)) {
203
+ await cp(join(repo, name), join(directory, name), { recursive: true, force: false, errorOnExist: true, verbatimSymlinks: true });
204
+ }
203
205
  await validate(directory);
204
206
  await writeFile(join(directory, "config"), "[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = false\n\tlogallrefupdates = true\n", { mode: 0o600 });
205
207
  await execute(git, directory, [`--git-dir=${directory}`, "read-tree", "HEAD"], deadline, undefined, undefined, undefined, directory);