@zvada/agent-server 0.3.20 → 0.3.21
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 +11 -0
- package/dist/types/core/agents/claude-code/approvals.d.ts +16 -5
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +5 -3
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/agents/claude-code/approvals.ts +33 -6
- package/src/core/agents/claude-code/options.ts +5 -3
- package/src/core/agents/claude-code/session.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.21
|
|
4
|
+
|
|
5
|
+
- A bypass-mode Claude session no longer prints the SDK's "canUseTool will
|
|
6
|
+
not be invoked" warning, with its stack, on the host's stderr at every
|
|
7
|
+
spawn. Claude still asks the callback about what needs a person
|
|
8
|
+
(AskUserQuestion, ExitPlanMode) under `bypass_permissions`; any other SDK
|
|
9
|
+
warning still reaches the host.
|
|
10
|
+
- The docs of `ClaudeToolPolicy` and the approval callback say what the host's
|
|
11
|
+
policy sees: each call Claude asks about (under `bypass_permissions`, only
|
|
12
|
+
questions and plans), not every call.
|
|
13
|
+
|
|
3
14
|
## 0.3.20
|
|
4
15
|
|
|
5
16
|
- zod is a peer dependency, any 4.x (`^4.0.0`), where it was a dependency
|
|
@@ -3,13 +3,24 @@ import { type ClaudeToolPolicy } from "./options.ts";
|
|
|
3
3
|
import type { ClaudeTurn } from "./turn.ts";
|
|
4
4
|
/** What a request needs of the turn it is asked in. */
|
|
5
5
|
export type ClaudeTurnRequests = Pick<ClaudeTurn, "permissions" | "elicitation" | "cancelByRequest">;
|
|
6
|
+
/**
|
|
7
|
+
* Start a session's query. Under `bypassPermissions` the SDK warns that
|
|
8
|
+
* `canUseTool` is never asked, but Claude still asks it about what needs a
|
|
9
|
+
* person (AskUserQuestion, ExitPlanMode), which is what the callback is for:
|
|
10
|
+
* that warning is left off the host's stderr, where it would print a stack at
|
|
11
|
+
* every spawn. Any other warning, and this one in any other mode, passes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function startQuery<Q>(permissionMode: string | undefined, start: () => Q): Q;
|
|
6
14
|
/**
|
|
7
15
|
* The SDK approval callback, fixed at spawn: it asks the turn running when it
|
|
8
|
-
* is called
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
16
|
+
* is called, which Claude does for a call its mode and rules do not approve
|
|
17
|
+
* by themselves (under `bypass_permissions`, only questions and plans). The
|
|
18
|
+
* host `toolPolicy` sees each such call first (full native PermissionResult
|
|
19
|
+
* power), questions and plans included; a call it leaves
|
|
20
|
+
* (`undefined`) goes to the turn: a question to its elicitation, a plan or a
|
|
21
|
+
* tool's approval to its interactive broker. The SDK passes a REAL
|
|
22
|
+
* `toolUseID` (>=0.2.138), so brokered requests correlate to their tool parts
|
|
23
|
+
* exactly.
|
|
13
24
|
*/
|
|
14
25
|
export declare function createCanUseTool(deps: {
|
|
15
26
|
sessionId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../../../../src/core/agents/claude-code/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EAGb,MAAM,gCAAgC,CAAC;AAWxC,OAAO,EAAE,KAAK,gBAAgB,EAA8C,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACpC,UAAU,EACV,aAAa,GAAG,aAAa,GAAG,iBAAiB,CACjD,CAAC;
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../../../../src/core/agents/claude-code/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EAGb,MAAM,gCAAgC,CAAC;AAWxC,OAAO,EAAE,KAAK,gBAAgB,EAA8C,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACpC,UAAU,EACV,aAAa,GAAG,aAAa,GAAG,iBAAiB,CACjD,CAAC;AAQF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAYnF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,kBAAkB,GAAG,IAAI,CAAC;CACtC,GAAG,UAAU,CAoEb;AA+ID;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,kBAAkB,GAAG,IAAI,GAAG,aAAa,CAWxF"}
|
|
@@ -23,9 +23,11 @@ export type SdkMcpServers = Record<string, McpSdkServerConfigWithInstance>;
|
|
|
23
23
|
*/
|
|
24
24
|
export type ClaudeSdkOptionOverrides = Partial<Omit<CCOptions, "canUseTool" | "onElicitation" | "hooks" | "mcpServers" | "resume" | "resumeSessionAt" | "cwd" | "env" | "permissionMode" | "includePartialMessages" | "pathToClaudeCodeExecutable">>;
|
|
25
25
|
/**
|
|
26
|
-
* Pre-broker tool policy: the host's programmatic say on every
|
|
27
|
-
* questions (AskUserQuestion) and plan approvals (ExitPlanMode)
|
|
28
|
-
* BEFORE the interactive permission broker and elicitation.
|
|
26
|
+
* Pre-broker tool policy: the host's programmatic say on every call Claude
|
|
27
|
+
* asks about, questions (AskUserQuestion) and plan approvals (ExitPlanMode)
|
|
28
|
+
* included, BEFORE the interactive permission broker and elicitation. Claude
|
|
29
|
+
* asks about a call its mode and rules do not approve by themselves: under
|
|
30
|
+
* `bypass_permissions`, only questions and plans. Returns the SDK's own
|
|
29
31
|
* `PermissionResult` (so hosts keep full native power: `updatedInput`,
|
|
30
32
|
* `updatedPermissions`) or undefined to fall through to the broker.
|
|
31
33
|
* Operator embed-tier only — never wire-sourced.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../src/core/agents/claude-code/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,OAAO,IAAI,SAAS,EACpB,8BAA8B,EAC9B,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,YAAY,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;AAE3E;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC7C,IAAI,CACH,SAAS,EACP,YAAY,GACZ,eAAe,GACf,OAAO,GACP,YAAY,GACZ,QAAQ,GACR,iBAAiB,GACjB,KAAK,GACL,KAAK,GACL,gBAAgB,GAChB,wBAAwB,GACx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IAkB3B,oGAAoG;IACpG,OAAO,CAAC,OAAO;IAwBf,iFAAiF;IACjF,OAAO,CAAC,KAAK;IAgCb;;;OAGG;IACH,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,cAAc;CAMtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zvada/agent-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"description": "Harness-agnostic agent execution engine: run Claude Code, Codex (app-server), and any ACP agent behind one interface with a normalized event stream, multi-turn sessions, and resume. Root export is the wire contract; /core, /server, /client are the seats.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,13 +27,40 @@ export type ClaudeTurnRequests = Pick<
|
|
|
27
27
|
/** What Claude is told when it asks while no turn runs. */
|
|
28
28
|
const NO_TURN = "No turn is running, so nobody can answer this.";
|
|
29
29
|
|
|
30
|
+
/** The SDK's warning, at `query()`, that its spawn options shadow `canUseTool`. */
|
|
31
|
+
const CALLBACK_SHADOWED = "CLAUDE_SDK_CAN_USE_TOOL_SHADOWED";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Start a session's query. Under `bypassPermissions` the SDK warns that
|
|
35
|
+
* `canUseTool` is never asked, but Claude still asks it about what needs a
|
|
36
|
+
* person (AskUserQuestion, ExitPlanMode), which is what the callback is for:
|
|
37
|
+
* that warning is left off the host's stderr, where it would print a stack at
|
|
38
|
+
* every spawn. Any other warning, and this one in any other mode, passes.
|
|
39
|
+
*/
|
|
40
|
+
export function startQuery<Q>(permissionMode: string | undefined, start: () => Q): Q {
|
|
41
|
+
if (permissionMode !== "bypassPermissions") return start();
|
|
42
|
+
const emit = process.emitWarning;
|
|
43
|
+
process.emitWarning = ((warning: string | Error, ...rest: unknown[]) => {
|
|
44
|
+
if ((rest[0] as { code?: unknown } | undefined)?.code === CALLBACK_SHADOWED) return;
|
|
45
|
+
(emit as (...args: unknown[]) => void).call(process, warning, ...rest);
|
|
46
|
+
}) as typeof process.emitWarning;
|
|
47
|
+
try {
|
|
48
|
+
return start();
|
|
49
|
+
} finally {
|
|
50
|
+
process.emitWarning = emit;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
30
54
|
/**
|
|
31
55
|
* The SDK approval callback, fixed at spawn: it asks the turn running when it
|
|
32
|
-
* is called
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
56
|
+
* is called, which Claude does for a call its mode and rules do not approve
|
|
57
|
+
* by themselves (under `bypass_permissions`, only questions and plans). The
|
|
58
|
+
* host `toolPolicy` sees each such call first (full native PermissionResult
|
|
59
|
+
* power), questions and plans included; a call it leaves
|
|
60
|
+
* (`undefined`) goes to the turn: a question to its elicitation, a plan or a
|
|
61
|
+
* tool's approval to its interactive broker. The SDK passes a REAL
|
|
62
|
+
* `toolUseID` (>=0.2.138), so brokered requests correlate to their tool parts
|
|
63
|
+
* exactly.
|
|
37
64
|
*/
|
|
38
65
|
export function createCanUseTool(deps: {
|
|
39
66
|
sessionId: string;
|
|
@@ -44,7 +71,7 @@ export function createCanUseTool(deps: {
|
|
|
44
71
|
return async (toolName, input, options) => {
|
|
45
72
|
const { signal, toolUseID, agentID, suggestions, blockedPath, decisionReason } = options;
|
|
46
73
|
// The host's policy sees every call first, questions and plans too: a
|
|
47
|
-
// host answers a plan through its own channel (
|
|
74
|
+
// host answers a plan through its own channel (AGNT does). A policy
|
|
48
75
|
// that wants the user to answer them returns undefined.
|
|
49
76
|
const verdict = await deps.policy?.(toolName, input, {
|
|
50
77
|
sessionId: deps.sessionId,
|
|
@@ -48,9 +48,11 @@ export type ClaudeSdkOptionOverrides = Partial<
|
|
|
48
48
|
>;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* Pre-broker tool policy: the host's programmatic say on every
|
|
52
|
-
* questions (AskUserQuestion) and plan approvals (ExitPlanMode)
|
|
53
|
-
* BEFORE the interactive permission broker and elicitation.
|
|
51
|
+
* Pre-broker tool policy: the host's programmatic say on every call Claude
|
|
52
|
+
* asks about, questions (AskUserQuestion) and plan approvals (ExitPlanMode)
|
|
53
|
+
* included, BEFORE the interactive permission broker and elicitation. Claude
|
|
54
|
+
* asks about a call its mode and rules do not approve by themselves: under
|
|
55
|
+
* `bypass_permissions`, only questions and plans. Returns the SDK's own
|
|
54
56
|
* `PermissionResult` (so hosts keep full native power: `updatedInput`,
|
|
55
57
|
* `updatedPermissions`) or undefined to fall through to the broker.
|
|
56
58
|
* Operator embed-tier only — never wire-sourced.
|
|
@@ -14,7 +14,7 @@ import type { NativeProcess } from "../../processes/native-processes.ts";
|
|
|
14
14
|
import { withTimeout } from "../../utils/deadline.ts";
|
|
15
15
|
import { SessionResumeError } from "../../utils/errors.ts";
|
|
16
16
|
import { IDLE_TIMEOUT_MS } from "../session-pool.ts";
|
|
17
|
-
import { createCanUseTool, createOnElicitation } from "./approvals.ts";
|
|
17
|
+
import { createCanUseTool, createOnElicitation, startQuery } from "./approvals.ts";
|
|
18
18
|
import { commandStarted } from "./events.ts";
|
|
19
19
|
import { ClaudeMcpConnections } from "./mcp.ts";
|
|
20
20
|
import {
|
|
@@ -188,7 +188,9 @@ export class ClaudeSession {
|
|
|
188
188
|
// Release/shutdown may finish while an async options/tool factory is
|
|
189
189
|
// pending. Never create a query after its owner has already terminated.
|
|
190
190
|
if (this.currentState === "terminated") throw new Error("Session terminated during startup");
|
|
191
|
-
this.query =
|
|
191
|
+
this.query = startQuery(options.permissionMode, () =>
|
|
192
|
+
sdk.query({ prompt: this.promptQueue, options }),
|
|
193
|
+
);
|
|
192
194
|
const events = this.consumeEvents();
|
|
193
195
|
if (!this.config.disableTools && Object.keys(this.mcp.servers).length) {
|
|
194
196
|
try {
|