Skip to content

Commit a2950da

Browse files
committed
chore: refresh CI fix onto current main
2 parents 7dd2e4d + f5eea31 commit a2950da

120 files changed

Lines changed: 2985 additions & 973 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ Docs: https://docs.openclaw.ai
221221
- **Deepgram realtime custom endpoints:** validate Voice Call streaming base URLs with secret-safe errors, preserve explicit `ws://` and `wss://` endpoints, and map HTTP schemes to their matching WebSocket transport for dedicated and self-hosted deployments. (#105334) Thanks @dwc1997.
222222
- **Control UI New Session reconnects:** rediscover agents, nodes, repository branches, and folder-browser state, refresh derived workspaces, gate unvalidated devices, and block ambiguous retries after Gateway client replacement while preserving the typed task and explicit choices. Fixes #106372.
223223
- **macOS remote node readiness:** take the main-session key from the node hello snapshot instead of opening an operator connection during node admission, preventing remote tunnel recovery from leaving Computer Use and node exec stuck in lifecycle transition.
224+
- **Claude CLI prompt privacy:** keep prompt-build hook context out of visible chat history while preserving ordinary user requests, native session recall, and policy-hook visibility. (#132466) Thanks @RomneyDa.
224225
- **Claude CLI context budgets:** honor Anthropic model and per-agent `contextTokens` limits by passing the effective limit to Claude Code's native auto-compactor and persisting the same prepared budget in OpenClaw session state. Fixes #80933. (#93198) Thanks @mushuiyu886.
225226
- **Transcript read failures:** propagate permission and I/O failures from streaming JSONL session reads instead of treating unreadable transcripts as empty. (#106412) Thanks @zenglingbiao.
226227
- **Restart sentinel diagnostics:** report SQLite read/write and legacy-file cleanup failures while preserving best-effort restart recovery behavior. (#106385) Thanks @zenglingbiao and @wendy-chsy.

‎docs/concepts/compaction.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Type `/compact` in any chat to force a compaction. Add instructions to guide the
7676
/compact Focus on the API design decisions
7777
```
7878

79+
Client-side compaction in the built-in OpenClaw runtime passes focus to both older-history and split-turn-prefix summaries. The host limits operator-provided focus to 800 Unicode code points and escapes it as prompt data before adding it to model requests.
80+
7981
Client-side manual compaction uses `agents.defaults.compaction.keepRecentTokens` (default: 20,000) as its cut-point budget and keeps that recent tail in rebuilt context.
8082

8183
### Provider checkpoints

‎docs/gateway/cli-backends.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ Claude Code subprocess. A changed model, system prompt, or tool policy starts a
125125
new query; persisted Claude session IDs still provide
126126
conversation continuity when the gateway or subprocess restarts.
127127

128+
For local SDK-backed turns, prompt-build hook context stays private: Claude
129+
receives it as a native hook attachment, while OpenClaw history preserves the original user message. The
130+
native session retains the context for resume; imported visible history and
131+
cross-provider fallback preludes do not copy private hook attachments.
132+
128133
Keep Claude Code updated, especially if the SDK reports an incompatible
129134
installed executable:
130135

‎docs/plugins/cli-backend-plugins.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ available to `resolveExecutionArgs(ctx)` for native CLI flags.
265265
backend owns a vendor-supported SDK for the installed CLI. The transport
266266
receives the exact prepared command, arguments, environment, prompt, session,
267267
and tool availability; it yields the backend's existing structured stream
268-
records. Native tool actions must use the provided, run-bound
268+
records. Optional `promptContext.prependContext` and `promptContext.appendContext`
269+
are private prompt-build additions, separate from the ordinary `prompt`. Transport
270+
them through the native SDK's private context mechanism; never record them as
271+
operator-authored input. OpenClaw's policy and observation hooks still receive the
272+
complete logical prompt. Native tool actions must use the provided, run-bound
269273
`requestToolPermission` callback rather than creating independent approval
270274
authority. OpenClaw retains cancellation, watchdogs, session policy, and MCP
271275
grant ownership. Explicit credential forwarding, paired-node execution, and

‎extensions/anthropic/agent-sdk.runtime.test.ts‎

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,21 @@ function sdkPreToolUse(options: Record<string, unknown>): SdkPreToolUseCallback
139139
return callback;
140140
}
141141

142+
type SdkPromptHook = (
143+
input: { hook_event_name: "UserPromptSubmit"; prompt: string },
144+
toolUseId: undefined,
145+
request: { signal: AbortSignal },
146+
) => Promise<unknown>;
147+
148+
function sdkPromptHook(options = sdkOptions()): SdkPromptHook {
149+
const hooks = options.hooks as { UserPromptSubmit?: Array<{ hooks: SdkPromptHook[] }> };
150+
const callback = hooks.UserPromptSubmit?.[0]?.hooks[0];
151+
if (!callback) {
152+
throw new Error("Missing native private-context hook");
153+
}
154+
return callback;
155+
}
156+
142157
function createLiveCapability(
143158
fingerprint = "matching-session-policy",
144159
state: { current?: CliBackendLiveSessionHandle } = {},
@@ -505,6 +520,40 @@ describe("Anthropic Agent SDK runtime ownership", () => {
505520
expect(queryMock).not.toHaveBeenCalled();
506521
});
507522

523+
it.each([undefined, { prependContext: "private prefix", appendContext: "private suffix" }])(
524+
"keeps one-shot user input separate from private prompt context %j",
525+
async (promptContext) => {
526+
let hookResult: unknown;
527+
const context = createContext({ promptContext });
528+
useSdkMessages([SUCCESS_RESULT], async (options) => {
529+
hookResult = await sdkPromptHook(options)(
530+
{ hook_event_name: "UserPromptSubmit", prompt: context.prompt },
531+
undefined,
532+
{ signal: new AbortController().signal },
533+
);
534+
});
535+
await collect(context);
536+
expect(queryMock.mock.calls[0]?.[0]?.prompt).toBe(context.prompt);
537+
expect(hookResult).toEqual(
538+
promptContext
539+
? {
540+
hookSpecificOutput: {
541+
hookEventName: "UserPromptSubmit",
542+
additionalContext: "private prefix\n\nprivate suffix",
543+
},
544+
}
545+
: {},
546+
);
547+
await expect(
548+
sdkPromptHook()(
549+
{ hook_event_name: "UserPromptSubmit", prompt: context.prompt },
550+
undefined,
551+
{ signal: new AbortController().signal },
552+
),
553+
).resolves.toEqual({});
554+
},
555+
);
556+
508557
it("preserves native session identity across fresh and resumed turns", async () => {
509558
useSdkMessages();
510559

@@ -551,15 +600,40 @@ describe("Anthropic Agent SDK runtime ownership", () => {
551600
const live = useLiveSdkStreams();
552601
const capability = createLiveCapability();
553602
const activate = vi.spyOn(capability, "activate");
554-
const first = collect(createContext({ prompt: "Remember orange.", liveSession: capability }));
603+
const first = collect(
604+
createContext({
605+
prompt: "Remember orange.",
606+
promptContext: { prependContext: "private session note" },
607+
liveSession: capability,
608+
}),
609+
);
555610
await vi.waitFor(() => expect(queryMock).toHaveBeenCalledOnce());
611+
const hook = sdkPromptHook();
612+
const hookRequest = { signal: new AbortController().signal };
613+
for (const prompt of ["Remember orange.", "Rewritten orange prompt.", "Remember orange."]) {
614+
await expect(
615+
hook({ hook_event_name: "UserPromptSubmit", prompt }, undefined, hookRequest),
616+
).resolves.toEqual({
617+
hookSpecificOutput: {
618+
hookEventName: "UserPromptSubmit",
619+
additionalContext: "private session note",
620+
},
621+
});
622+
}
556623
live.streams[0]?.write({ ...SUCCESS_RESULT, result: "Remembered orange." });
557624

558625
await expect(first).resolves.toContainEqual(
559626
expect.objectContaining({ result: "Remembered orange." }),
560627
);
561628
const firstHandle = capability.current();
562629
expect(firstHandle?.isIdle()).toBe(true);
630+
await expect(
631+
hook(
632+
{ hook_event_name: "UserPromptSubmit", prompt: "Remember orange." },
633+
undefined,
634+
hookRequest,
635+
),
636+
).resolves.toEqual({});
563637

564638
const second = collect(
565639
createContext({
@@ -569,6 +643,13 @@ describe("Anthropic Agent SDK runtime ownership", () => {
569643
}),
570644
);
571645
await vi.waitFor(() => expect(live.prompts[0]).toHaveLength(2));
646+
await expect(
647+
hook(
648+
{ hook_event_name: "UserPromptSubmit", prompt: "Which color did I mention?" },
649+
undefined,
650+
hookRequest,
651+
),
652+
).resolves.toEqual({});
572653
live.streams[0]?.write({ ...SUCCESS_RESULT, result: "Orange." });
573654

574655
await expect(second).resolves.toContainEqual(expect.objectContaining({ result: "Orange." }));

‎extensions/anthropic/agent-sdk.runtime.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,37 @@ function resolveClaudeAgentSdkOptions(
208208
toolUseId: request.toolUseID,
209209
}),
210210
hooks: {
211+
UserPromptSubmit: [
212+
{
213+
hooks: [
214+
async (input, _toolUseId, request) => {
215+
const turn = currentTurn();
216+
if (
217+
input.hook_event_name !== "UserPromptSubmit" ||
218+
!turn ||
219+
request.signal.aborted ||
220+
turn.controller.signal.aborted
221+
) {
222+
return {};
223+
}
224+
const additionalContext = [
225+
turn.context.promptContext?.prependContext,
226+
turn.context.promptContext?.appendContext,
227+
]
228+
.filter(Boolean)
229+
.join("\n\n");
230+
if (!additionalContext) {
231+
return {};
232+
}
233+
// Native may rerun hooks after rewriting a prompt and commits only the final pass.
234+
// Return this admitted turn's context on each pass; native owns attachment persistence.
235+
return {
236+
hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext },
237+
};
238+
},
239+
],
240+
},
241+
],
211242
PreToolUse: [
212243
{
213244
hooks: [

‎extensions/workboard/src/store-normalizers.ts‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -990,33 +990,36 @@ function completionProofConflicts(existing: WorkboardProof, completion: Workboar
990990

991991
export function appendCompletionProof(
992992
existing: readonly WorkboardProof[] | undefined,
993-
proof: WorkboardProof,
993+
proof: WorkboardProof | undefined,
994994
proofId?: string,
995995
): WorkboardProof[] {
996996
const entries = [...(existing ?? [])];
997997
if (!proofId) {
998-
return [...entries, proof].slice(-MAX_CARD_PROOF);
998+
return proof ? [...entries, proof].slice(-MAX_CARD_PROOF) : entries;
999999
}
10001000
const index = entries.findIndex((entry) => entry.id === proofId);
10011001
const pending = index >= 0 ? entries[index] : undefined;
10021002
if (!pending) {
10031003
throw new Error(`proof not found: ${proofId}`);
10041004
}
1005-
if (proof.status === "unknown") {
1006-
throw new Error("completion proof status must be passed, failed, or skipped.");
1005+
const completionProof = proof ?? pending;
1006+
if (completionProof.status === "unknown") {
1007+
throw new Error(
1008+
proof
1009+
? "completion proof status must be passed, failed, or skipped."
1010+
: "proof is required to resolve a pending proof.",
1011+
);
10071012
}
1008-
if (completionProofConflicts(pending, proof)) {
1013+
if (completionProofConflicts(pending, completionProof)) {
10091014
throw new Error(`completion proof does not match pending proof: ${proofId}`);
10101015
}
1011-
if (pending.status !== "unknown") {
1012-
if (pending.status !== proof.status) {
1013-
throw new Error(`completion proof status does not match existing proof: ${proofId}`);
1014-
}
1015-
return entries.slice(-MAX_CARD_PROOF);
1016+
if (pending.status !== "unknown" && pending.status !== completionProof.status) {
1017+
throw new Error(`completion proof status does not match existing proof: ${proofId}`);
1018+
}
1019+
if (pending.status === "unknown") {
1020+
// Preserve the stored evidence identity and timestamp when resolving its status.
1021+
entries[index] = { ...pending, status: completionProof.status };
10161022
}
1017-
// A proof id is the durable correlation boundary between a separately recorded check and its
1018-
// completion. Preserve the original evidence identity and timestamp while resolving its status.
1019-
entries[index] = { ...pending, status: proof.status };
10201023
return entries.slice(-MAX_CARD_PROOF);
10211024
}
10221025

‎extensions/workboard/src/store-workflow.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ export class WorkboardWorkflowStore extends WorkboardPromoteStore {
267267
if (input.proofId !== undefined && !proofId) {
268268
throw new Error("proofId must be a non-empty string.");
269269
}
270-
if (proofId && !proofInput) {
271-
throw new Error("proof is required when proofId is provided.");
272-
}
273270
const proof = proofInput ? normalizeProofInput(proofInput, now) : undefined;
274271
const artifacts = Array.isArray(input.artifacts)
275272
? input.artifacts
@@ -315,7 +312,7 @@ export class WorkboardWorkflowStore extends WorkboardPromoteStore {
315312
{ id: randomUUID(), body: summary, createdAt: now },
316313
].slice(-MAX_CARD_COMMENTS)
317314
: metadata.comments,
318-
proof: proof ? appendCompletionProof(metadata.proof, proof, proofId) : metadata.proof,
315+
proof: appendCompletionProof(metadata.proof, proof, proofId),
319316
artifacts: artifacts.length
320317
? [...(metadata.artifacts ?? []), ...artifacts].slice(-MAX_CARD_ARTIFACTS)
321318
: metadata.artifacts,
@@ -326,7 +323,7 @@ export class WorkboardWorkflowStore extends WorkboardPromoteStore {
326323
},
327324
{
328325
enforceStatusHolds: true,
329-
...(proof ? { preserveProofId: proofId ?? proof.id } : {}),
326+
preserveProofId: proofId ?? proof?.id,
330327
},
331328
);
332329
}

‎extensions/workboard/src/store.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,14 @@ describe("WorkboardStore", () => {
17461746
token: "token-1",
17471747
});
17481748

1749+
await expect(
1750+
store.complete(claimed.card.id, {
1751+
ownerId: "main",
1752+
token: "token-1",
1753+
proofId: pending.metadata?.proof?.[0]?.id,
1754+
}),
1755+
).rejects.toThrow("proof is required to resolve a pending proof.");
1756+
17491757
vi.setSystemTime(6_000);
17501758
const completed = await store.complete(claimed.card.id, {
17511759
ownerId: "main",

‎extensions/workboard/src/tools.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ describe("workboard tools", () => {
414414
await tools.get("workboard_proof")?.execute("call-proof", {
415415
id: parent.id,
416416
token,
417+
status: "passed",
417418
command: "pnpm test extensions/workboard",
418419
}),
419420
);
@@ -425,7 +426,6 @@ describe("workboard tools", () => {
425426
summary: "Done.",
426427
createdCardIds: [child.id],
427428
proofId: pendingProof.proofId,
428-
proof: { status: "passed", command: "pnpm test extensions/workboard" },
429429
}),
430430
);
431431
expect(completed.card).toMatchObject({

0 commit comments

Comments
 (0)