Repository navigation
Conversation
72b1b88 to
a75a5c2
Compare
305ba71 to
54d0151
Compare
| if (!isAbsolute(expected) || await realpath(app) !== await realpath(expected)) return 'needs_user_action' | ||
| const name = (await command('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleExecutable', join(app, 'Contents', 'Info.plist')], env, signal)).trim() | ||
| if (!name || name.includes('/') || name === '.' || name === '..') return 'unknown' | ||
| return await realpath(join(app, 'Contents', 'MacOS', name)) === await realpath(executable) ? 'ready' : 'needs_user_action' |
There was a problem hiding this comment.
[P2] Bind readiness to the currently selected terminal
After qualification, starting Claude in another supported terminal changes where deep links open (documented behavior), but this check still accepts the same handler executable and the configuration fingerprint omits terminal selection. Re-observe and bind the selected terminal so a switch invalidates qualification instead of validating the captured environment for a different receiver.
| manifest, mcp, settings, Object.fromEntries(Object.entries(targetEnv).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)), | ||
| credentials, clients, roots, parsed, promptHooks, receiverHash, options.environmentEvidence])).digest('hex') | ||
| return { effectiveCwd: cwd, serverIdentity: parsed.serverIdentity, scopeId: parsed.scopeId, | ||
| configurationGeneration: generation, newSession: true, unsentPrefill: true, packageAccess: roots.length > 0 } |
There was a problem hiding this comment.
[P2] Validate effective Read permissions before claiming package access
On a new preflight with a user-level permissions.deny rule blocking the package root, this still reports package access and canReadPackage checks only host filesystem access, although Claude's Read rules prevent the receiver from reading the package. Bind access qualification to the effective permission configuration or reject unverified permissions before declaring readiness.
There was a problem hiding this comment.
[P2] The linked-worktree permission case still passes at 779b08cabbb49bacc53d6a4392bbf74707895889. The direct user-settings deny case is now rejected, but observeSettings() only checks cwd and git rev-parse --show-toplevel, which both identify the linked worktree root. Claude Code v2.1.211+ reads .claude/settings.local.json from the main checkout. In an adapter probe using a real linked Git worktree, adding {"permissions":{"deny":["Read"]}} there left receiver.environment() ready with the same configuration generation, and canReadPackage() still returned true. Resolve the effective local-settings location (or reject linked worktrees that cannot be qualified) so an inherited deny cannot pass package-access preflight. This reproduces the adapter behavior with fixture CLI/Server responses; it is not a macOS receiving-session acceptance result.
| export async function createClaudeCodeCliTarget(options: ClaudeCodeCliTargetOptions = {}): Promise<ClaudeCliAdapter> { | ||
| const { integrationOptions = {}, ...adapterOptions } = options | ||
| const inherited = integrationOptions.environment ?? process.env | ||
| const configDir = integrationOptions.configDir ?? inherited.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude') |
There was a problem hiding this comment.
[P2] Derive the default profile from the supplied HOME
When the supplied environment has a different HOME and no explicit configuration directory, this selects the host process's home; createClaudeIntegration then sets CLAUDE_CONFIG_DIR, causing doctor and setup to target a different profile from the receiving terminal. Derive the default directory from inherited.HOME and preserve the default profile's unset CLAUDE_CONFIG_DIR.
hidb4ai
left a comment
There was a problem hiding this comment.
Two receiver-readiness gaps remain on this head: a project-disabled PowerContext MCP server still passes preflight, and linked worktrees omit the main checkout's effective local permission settings (details in the existing permission thread).
| ? join(options.configDir, '.claude.json') : join(env.HOME ?? homedir(), '.claude.json') | ||
| const qualifiedTerminal = options.environmentEvidence.terminal | ||
| const observeTerminal = async () => { | ||
| const { deepLinkTerminal } = await readObject(terminalPreferenceFile) |
There was a problem hiding this comment.
[P2] Honor the receiver project's disabled MCP servers
This reads only deepLinkTerminal from the Claude global configuration. With projects[cwd].disabledMcpServers = ["plugin:powercontext:powercontext"] in that same file, receiver.environment() still returns a ready environment with the identical configurationGeneration; the direct Python MCP probe bypasses Claude's disabled-server state. Claude does not connect to plugin servers disabled through /mcp, so the receiving session cannot perform Continue/ACK despite passing preflight. Check the effective project MCP enablement and include it in the binding, or reject this configuration before preparation/launch.
hidb4ai
left a comment
There was a problem hiding this comment.
Both previous counterexamples now reject correctly: a disabled PowerContext MCP server and a Read denial inherited from the main checkout. One new non-Git workspace regression remains in project discovery; see the inline finding.
| '--git-dir', '--git-common-dir'], gitEnv, signal, cwd) | ||
| } catch (error) { | ||
| signal.throwIfAborted() | ||
| if ((error as { stderr?: string }).stderr?.trim() !== 'fatal: not a git repository (or any of the parent directories): .git') throw error |
There was a problem hiding this comment.
[P2] Recognize non-repositories at filesystem boundaries
Git does not always emit this exact message for a valid non-Git directory. When discovery reaches a filesystem boundary, it returns fatal: not a git repository (or any parent up to mount point /) followed by Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). This branch rethrows that normal non-repository result, so environment() returns undefined and handoff is rejected for an otherwise qualified directory. A same-fixture comparison returned ready on 779b08ca and unavailable on this head; the two supplied runtime tests that use non-Git workspaces also fail at their readiness assertions in this environment. Recognize this non-repository outcome while continuing to reject corrupt or indeterminate Git layouts. Reproduced with real Git 2.43.7 on Linux and fixture CLI/Server responses; no native macOS launch was exercised.
* feat(dsh): add the Codex Desktop handoff adapter * fix(dsh): ship Codex Desktop diagnostics in the default Host * fix(dsh): recover Codex probes and isolate target discovery
| if (!qualified || !buildReceiverPrompt) throw new HandoffError('integration_unavailable') | ||
| if (bundle.binding.targetId !== 'claude-desktop' | ||
| || bundle.binding.targetVersion !== target.version) throw new HandoffError('binding_mismatch') | ||
| return { draft: buildReceiverPrompt(bundle, locale) } |
There was a problem hiding this comment.
[P2] launchIntent 未校验 buildReceiverPrompt 的返回值
这里直接 return { draft: buildReceiverPrompt(bundle, locale) }。同 PR 的 CLI 适配器(claude-code-cli.ts 的 launchIntent)对同一契约做了 typeof draft !== 'string' || !draft.trim() 校验并抛 HandoffError('payload_invalid')。可复现:qualified Desktop adapter + 返回空串/非字符串的 buildReceiverPrompt → launchIntent 返回 { draft: '' },空 draft 会被当作合法预填内容交付,两个同批适配器行为不一致。
* feat(dsh): add the Claude Desktop Code handoff adapter * feat(dsh): connect the reply menu and one-click handoff * feat(dsh): enable Codex Desktop and Claude CLI handoff by default * fix(dsh): preserve the original objective and recover rejected input * fix(dsh): allow explicit retry of unacknowledged handoffs
| }) | ||
| return [createHostCodexDesktopAdapter({ | ||
| appPath: options.codexAppPath, codexHome, deliveryStorage: options.deliveryStorage, | ||
| setup, buildReceiverPrompt, qualification: CODEX, |
There was a problem hiding this comment.
[P2] Serialize setup writes to shared client settings
Concurrent Codex and Claude installation decisions use different installer keys, but both setup commands rewrite the shared clients.json through setup_transport_updates() and publish(), allowing the last writer to discard the other host's saved connection. Serialize this shared configuration write across both adapters or make the read-modify-write atomic.
| } | ||
| if (plugin.status !== 'failed' || typeof plugin.detail !== 'string') return { state: 'unknown' } | ||
| if (plugin.detail === 'PowerContext plugin is not installed') return { state: 'missing', repairable: true } | ||
| if (plugin.detail.includes('enabled=False')) return { state: 'disabled', repairable: true } |
There was a problem hiding this comment.
[P2] Enable disabled plugins during the consented repair
For an installed plugin disabled in user settings, this branch offers automatic repair, but install() invokes powercontext setup claude-code, whose existing-plugin path updates the plugin while preserving its disabled setting, leaving handoff blocked. Enable the plugin under the same consent and profile, or require manual action using the documented enable command.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed f21d79f2. The active-objective issue and unquoted credential example are fixed, and the shared setup write is serialized across processes. The credential disclosure remains reproducible with a shell-quoted option name; current-head reproduction is in the existing thread.
| const value = capabilities?.kind === 'json' ? capabilities.value : undefined | ||
| const enabled = value && typeof value === 'object' && !Array.isArray(value) | ||
| && (value as Record<string, unknown>).handoff_generation === true | ||
| return { client, assertDispatch: assertInstaller, ...(enabled ? { generation: { maxInputBytes: 192 * 1024, maxOutputBytes: 8000 } } : {}) } |
There was a problem hiding this comment.
[P2] Honor the generation request's timeout budget
When the Server advertises handoff_generation, this enables automatic generation using the ordinary runtime client, whose default three-second timeout aborts longer model calls and leaves the delivery unknown despite prepareCarrier allowing 90 seconds. Give the generation request a timeout that honors that budget while preserving normal hook timeouts.
There was a problem hiding this comment.
Confirmed at f21d79f26083981ffd64d63f54d606295d537380 through createHandoffServices, a real HTTP Server, persistent SQLite, and a live LLM. With resolveConfig()'s default client timeout, /v1/handoff/prepare aborted after 3.005 seconds; the delivery became unknown / outcome_unknown and remained so after closing/reopening the services. A 90-second client control completed generation in 22.725 seconds, finalized the package, and successfully resolved it through continue_handoff. The outer 90-second signal cannot extend the client's independent 3-second deadline. Give generation its intended request budget without increasing ordinary hook timeouts. Source evidence and receiver qualification were fixtures; native application launch was not exercised.
There was a problem hiding this comment.
Re-verified at head 16acfba192: the root cause is closed for prepare_handoff.
Running the head sources directly under node with a deliberately tiny base timeout (300 ms) and a server stub that never answers:
flush_profile(a method that keeps the default budget) aborts withTimeoutErrorafter 323 ms.prepare_handoffwith the same 300 ms configuration is still pending after 1504 ms and only settles when the stub responds.
So requestTimeoutMsFor('prepare_handoff') does route generation through HANDOFF_GENERATION_TIMEOUT_MS = 90_000 instead of the shared request timeout, and client.spec.ts now pins the boundary at 89_999 / 90_001 ms. The 3.005 s abort you observed at f21d79f2 no longer reproduces.
Remaining gap, if you want to keep this thread open: the specialised budget is keyed on the RPC id only, so any other long-running Server call (for example a large flush_profile or an artifact revision read) still shares requestTimeoutMs. Nothing in the current surface needs it, but a comment at requestTimeoutMsFor saying which calls are intentionally left on the shared budget would prevent the next one from being added silently.
| readBoundary: createBoundaryReader(ui), | ||
| resolveReceiptConnection: async (context, binding) => { | ||
| requireLocal() | ||
| const live = await connection(context, binding.source) |
There was a problem hiding this comment.
[P2] Decouple receipt reads from inference readiness
If an inference provider becomes unavailable after an ACK is written but before DSH first reads it, this resolver rejects the degraded readiness status before reading the otherwise accessible receipt, leaving the delivery awaiting confirmation. Preserve the saved Server, authentication, and Scope checks without requiring inference readiness for receipt reads.
There was a problem hiding this comment.
Confirmed at 16acfba1925002fb02dcca9d97b719b4d9fe139b with a real HTTP Server and persistent SQLite. After live-LLM preparation, Continue and ACK succeeded, I restarted the same Server/database with an unavailable model endpoint before the first receipt read. Readiness returned HTTP 200 with status: degraded, database: ready, and inference.generation: unavailable; Server identity and Scope were unchanged. The receipt Source still returned HTTP 200 with status: accepted. However, the production sourceConnection check used by this resolver caused LocalReceiptReader to return state: awaiting, readState: unavailable, and error: read_unavailable. A control reader using the same client verified that exact receipt as accepted. Receipt reads should retain identity, authentication and Scope validation without depending on model availability. DSH events and receiver qualification were fixtures; the private resolver was exposed unchanged for the probe, and native macOS launch was not exercised.
There was a problem hiding this comment.
Rechecked c79cbf4cf1fb814803f557d47660f63a6840807c: the receipt-read regression is fixed. With a real HTTP Server, persistent SQLite and the configured live LLM, preparation, reopening, Continue and ACK succeeded. After restarting the same Server/database with an unavailable model endpoint, readiness was degraded but the production createHostConnectionResolvers plus LocalReceiptReader verified the persisted ACK as accepted. Server identity and Scope were unchanged. Source events and receiver qualification were fixtures; native macOS launch was not exercised.
|
|
||
| export function unsafeCommandEvidence(command: string): boolean { | ||
| // Escapes and shell expansions can change argument names. Omit those commands without evaluating them. | ||
| if (/[\\$`*?\[{}~!]/u.test(command)) return true |
There was a problem hiding this comment.
[P2] The escape/expansion guard rejects ordinary commands, so most command evidence is dropped instead of filtered
if (/[\\$`*?\[{}~!]/u.test(command)) return trueMeasured against the head implementation (node executes this module directly, 23 cases):
unsafe=true pytest C:\repo\tests\test_a.py
unsafe=true .\scripts\check.ps1
unsafe=true pytest tests/test_[ab].py
unsafe=true cargo test --features {a,b}
unsafe=true git commit -m "fix: done!"
unsafe=true ls ~/src
unsafe=false pnpm test
unsafe=false cargo test --locked -p pc-gateway-core
A single backslash makes every Windows path unsafe, so on a Windows host this channel degrades to "no command evidence at all": materials.ts:157 then emits could not be included safely for essentially every observed check. The same applies to ! (any message with an exclamation mark), ~ (home-relative paths), [/?/* (test selectors such as test_[ab].py, common in this repository's own suites) and {} (cargo --features {a,b}).
The change to handoff-boundary-reader.spec.ts, which replaces the fixture command pnpm test with pnpm test "ordinary case", is a symptom: the previous fixture command is no longer safe under this rule.
The intent ("escapes and shell expansions can change argument names") is sound, but a blanket character class trades the entire evidence channel away for it. Two narrower options keep the safety property:
- treat these characters as unsafe only when they appear outside quotes in a position that can change word splitting (the same reasoning the
CREDENTIAL_OPTIONrewrite already uses), and - keep backtick,
$(,${as unconditional rejects, but let a backslash pass unless the command is known to be interpreted by a POSIX shell.
If the current behaviour is intentional, the accompanying spec should assert the Windows-path and glob cases explicitly so that the trade-off is a documented decision rather than an accident.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 16acfba1925002fb02dcca9d97b719b4d9fe139b. The previously reported quoted-option credential leak and three-second generation timeout no longer reproduce: the default client completed live-LLM generation in 26.37 seconds, and the synthetic credential was absent from captured input, the exported package and Continue results.
Changes are still required for the receipt-read failure confirmed in the existing thread: a model outage prevents DSH from observing an already persisted, readable ACK. The reproduction and validation limits are recorded in the reply to that finding.
|
The affected modules are Core. @hidb4ai, please coordinate follow-up. Core: @hidb4ai @frf12 @Fengzdadi @beatenevo. Please coordinate the review of the affected changes. |
hidb4ai
left a comment
There was a problem hiding this comment.
The previously reproduced receipt-read failure no longer reproduces on this head; see the existing thread for the real-Server verification. No new correctness blocker was confirmed in this pass. Native macOS receiving-session acceptance has not been rerun for this commit, and GitHub currently shows only the CLA check, without Actions validation. Merge score: 60/100 pending those validations. No database tables are added; the interface additions are not an approval blocker.
happy-v587
left a comment
There was a problem hiding this comment.
Reviewed independently (branch @ c79cbf4, full clone, real runs, macOS arm64 / Node 26):
Server-side: verified green locally
tests/test_setup_transport.py+tests/builtin/artifacts/handoff: 134 passed;tests/e2e/test_runtime_server.py -k handoff: 2 passed.output_languageviaAccept-Languageand thecommitted_receipt_identityhardening (committed event must match the observed identity event, elsereceipt_identity_pending) are covered by existing access-control tests.
Client (DSH plugin) — two local test failures I could not clear:
make cindy-testfails on a clean checkout:git diff --exit-code -- integrations/cindy/plugins/powercontext-hooks/node/worker.cjsshows the committed bundle is stale — the rebuilt bundle addsHANDOFF_GENERATION_TIMEOUT_MS/90sprepare_handofftimeout and theAccept-Languageheader line. This is the exactcindy-packageCI failure (run 46811304109). Fix: rebuild and commitworker.cjs.pnpm vitest run tests/codex-desktop-runtime.spec.tsfails 3/6 locally withHandoffError('integration_unavailable')atcodex-desktop-runtime.ts:438(the fixture fakecodexCLI'sinitializereply isn't accepted).tests/ui-handoff-interaction.spec.tsfails 34/34 atlocalStorage.clear()—localStorageis undefined. Both spec files are new in this PR; CI'sdsh-packagejob did runmake js-testonpowercontext-ci-lightand passed, and these are environment-sensitive (Node 22.19 via mise on CI vs Node 26 local, jsdom environment application), so I treat them as local-environment artifacts rather than code bugs — but they are reproducible on a clean tree here, so they deserve a look: the// @vitest-environment jsdompragma attests/ui-handoff-interaction.spec.ts:22is not taking effect in my run, which suggests the environment may be resolved too late forbeforeEachon some Node versions.
Server review of the adapter-facing contract: sound.
prepare_handoffnow normalizesAccept-Languagetoen/zh-CN/None, excluding None from the generated input; MCP guidance adds the receive-context rule (do not guess Scope or acknowledge unverified deliveries) — good injection-resistance posture.get_committed_receipt_identitycorrectly refuses to attribute a receipt until the committed identity event exists and matches the observed one.GET_CONNECTION_IDENTITYadded to the MCP surface matches the adapter's needs.
Verdict: the Cindy stale bundle is a hard blocker (CI red, reproduced locally, mechanical fix). The two local-only spec failures need a CI-parity check before merge but are not, by themselves, blockers given the green dsh-package run. Previously requested changes (receipt-read failure) were addressed per hidb4ai's 12-02 pass. Merge state: CI result fail → fix the bundle and re-run.
Which issue or RFC does this PR close?
Refs #2514 and RFC #2528. This PR builds on #2602, which includes the receipt and initial Codex Desktop work from #2651 and #2652. It includes the Claude Desktop adapter from #2654 and the reply handoff menu from #2655.
Rationale for this change
An installed agent does not establish that a new session can read the package and acknowledge the exact handoff. The DSH menu needs to show installation status independently of launch eligibility and recover when a read temporarily fails.
What changes are included in this PR?
How was this change tested?
make check, the DSH package build, andmake docs-testpassed.d093opened Claude Code CLI, which read the requested proof, called Continue and ACK, and produced the exact verified receipt. The credential compatibility tests use an isolated fixture Server.AI usage statement
OpenAI Codex assisted with implementation, tests, local validation, and preparing this PR.