zapagent 1.14.28 → 1.14.30
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/README.md +2 -4
- package/README.zh-CN.md +1 -3
- package/bundled-dependencies.json +197 -197
- package/package.json +1 -1
- package/src/App.tsx +20 -16
- package/src/acp/agent.ts +2 -1
- package/src/agent/cacheScope.ts +11 -0
- package/src/agent/claude-code.ts +160 -0
- package/src/agent/official-agents.ts +83 -0
- package/src/agent/outputThroughput.ts +27 -0
- package/src/agent/remote-agent.ts +5 -2
- package/src/agent/remote-turn.ts +42 -6
- package/src/agent/wireRunHandlers.ts +6 -7
- package/src/agent-factory.ts +3 -15
- package/src/codex-auth-command.ts +14 -27
- package/src/codex-auth.ts +25 -227
- package/src/codex-provider.ts +9 -11
- package/src/commands/dispatcher.ts +26 -9
- package/src/commands/status.ts +9 -7
- package/src/config.ts +18 -4
- package/src/headless/runHeadless.ts +9 -0
- package/src/hooks/useAgentRunner.ts +25 -6
- package/src/index.tsx +2 -2
- package/src/ui/dialog-codex-login.tsx +15 -19
- package/src/ui/dialog-config.tsx +3 -1
- package/src/ui/dialog-connect.tsx +9 -5
- package/src/ui/dialog-model.tsx +82 -22
- package/src/ui/footer.tsx +10 -8
- package/src/ui/provider-directory.tsx +5 -3
- package/zapsdk/acp-client/event-mapper.ts +9 -2
- package/zapsdk/acp-client/host-handlers.ts +18 -4
- package/zapsdk/acp-client/run.ts +6 -1
- package/zapsdk/acp-client/types.ts +2 -0
- package/zapsdk/execution/process.ts +9 -2
package/zapsdk/acp-client/run.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface AcpTurnOptions {
|
|
|
27
27
|
/** Event path prefix for nested rendering (subagent path). */
|
|
28
28
|
path?: string[];
|
|
29
29
|
onEvent?: (event: AgentEvent) => void;
|
|
30
|
+
onContextUsage?: (usage: { used: number; size: number }) => void;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export interface AcpTurnResult {
|
|
@@ -84,6 +85,7 @@ export class AcpAgentSession {
|
|
|
84
85
|
}
|
|
85
86
|
const mode = options.mode ?? spec.mode;
|
|
86
87
|
if (mode) await session.attempt(`mode ${mode}`, () => connection.setMode(session.sessionId, mode));
|
|
88
|
+
if (spec.requireSettings && session.warnings.length) throw new Error(session.warnings.join("; "));
|
|
87
89
|
return session;
|
|
88
90
|
} catch (error) {
|
|
89
91
|
await connection.close();
|
|
@@ -100,7 +102,10 @@ export class AcpAgentSession {
|
|
|
100
102
|
async prompt(content: string | ContentBlock[], options: AcpTurnOptions = {}): Promise<AcpTurnResult> {
|
|
101
103
|
const mapper = new AcpEventMapper(options.path ?? []);
|
|
102
104
|
const emit = (events: AgentEvent[]) => { for (const event of events) options.onEvent?.(event); };
|
|
103
|
-
this.turn = update =>
|
|
105
|
+
this.turn = update => {
|
|
106
|
+
emit(mapper.map(update));
|
|
107
|
+
if (update.sessionUpdate === "usage_update" && mapper.contextUsage) options.onContextUsage?.(mapper.contextUsage);
|
|
108
|
+
};
|
|
104
109
|
const blocks = typeof content === "string" ? [{ type: "text" as const, text: content }] : content;
|
|
105
110
|
let response;
|
|
106
111
|
try {
|
|
@@ -26,6 +26,8 @@ export interface AcpAgentSpec {
|
|
|
26
26
|
model?: string;
|
|
27
27
|
/** Session mode to select after session/new (`session/set_mode`). */
|
|
28
28
|
mode?: string;
|
|
29
|
+
/** Reject the session if a requested mode, model or config option is refused. */
|
|
30
|
+
requireSettings?: boolean;
|
|
29
31
|
/** Session config options to apply after session/new
|
|
30
32
|
* (`session/set_config_option`), e.g. `{ thought_level: "high" }`. */
|
|
31
33
|
config?: Record<string, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { spawnSync, spawn, type ChildProcess } from "node:child_process";
|
|
2
3
|
import { localExecutionShell } from "./shell.js";
|
|
3
4
|
import { readProcessTable, snapshotDescendants } from "./process-tree.js";
|
|
4
5
|
import type {
|
|
@@ -135,7 +136,13 @@ export function terminateProcessTree(
|
|
|
135
136
|
let delivered = false;
|
|
136
137
|
const killChild = () => child.exitCode === null && child.signalCode === null && child.kill(signal);
|
|
137
138
|
try {
|
|
138
|
-
if (process.platform === "win32" ||
|
|
139
|
+
if (process.platform === "win32" && (signal === "SIGTERM" || signal === "SIGKILL") && child.pid && child.exitCode === null && child.signalCode === null) {
|
|
140
|
+
const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
|
|
141
|
+
const result = spawnSync(join(systemRoot, "System32", "taskkill.exe"), ["/PID", String(child.pid), "/T", "/F"], {
|
|
142
|
+
stdio: "ignore", windowsHide: true, timeout: 3000,
|
|
143
|
+
});
|
|
144
|
+
delivered = result.status === 0 || killChild();
|
|
145
|
+
} else if (!child.pid || process.platform === "win32") delivered = killChild();
|
|
139
146
|
// The group can outlive its leader and keep stdout/stderr open. A leader's
|
|
140
147
|
// exit must not suppress escalation to surviving descendants.
|
|
141
148
|
else delivered = process.kill(-child.pid, signal);
|