@chroxy/server 0.10.0 → 0.11.10
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/CONFIG.md +602 -19
- package/README.md +2 -2
- package/hooks/claude-native-route-check.mjs +17 -0
- package/hooks/permission-hook.sh +416 -11
- package/package.json +20 -23
- package/sidecar/Dockerfile +1 -1
- package/sidecar/PROTOCOL.md +9 -1
- package/sidecar/agent.js +102 -10
- package/sidecar/package-lock.json +3 -3
- package/src/acp-config.js +206 -0
- package/src/acp-session.js +954 -0
- package/src/activity-registry.js +110 -5
- package/src/agent-connections.js +293 -0
- package/src/agent-control/client.js +1616 -0
- package/src/agent-control/events.js +547 -0
- package/src/agent-control/local-connection.js +275 -0
- package/src/agent-control/mcp-server.js +545 -0
- package/src/anthropic-compatible-config.js +29 -4
- package/src/anthropic-compatible-session.js +15 -6
- package/src/anthropic-openai-shim.js +0 -1
- package/src/archive-continuation.js +164 -0
- package/src/assistant-response.js +24 -0
- package/src/auth-probes.js +120 -13
- package/src/background-shell-tracker.js +27 -0
- package/src/base-session.js +1353 -41
- package/src/bearer-recheck.js +49 -0
- package/src/billing-budget.js +24 -1
- package/src/billing-class.js +40 -7
- package/src/binary-provenance-trust.js +101 -0
- package/src/bound-client-policy.js +279 -0
- package/src/built-in-tools/bash-exec.js +46 -7
- package/src/built-in-tools/file-ops.js +74 -9
- package/src/built-in-tools/tool-transforms.js +1113 -13
- package/src/byok-compose-state.js +6 -9
- package/src/byok-credentials.js +2 -3
- package/src/byok-mcp-client.js +1153 -20
- package/src/byok-mcp-config.js +1712 -8
- package/src/byok-mcp-fleet.js +416 -29
- package/src/byok-mcp-oauth-store.js +329 -0
- package/src/byok-mcp-oauth.js +635 -0
- package/src/byok-mcp-trust.js +257 -40
- package/src/byok-session.js +1400 -149
- package/src/byok-tool-executor.js +2681 -38
- package/src/byok-tools.js +9 -2
- package/src/channels/chroxy-channel-server.js +2 -3
- package/src/checkpoint-manager.js +96 -51
- package/src/chroxy-host-metadata.js +122 -0
- package/src/claude-channel-session.js +16 -10
- package/src/claude-model-catalog.js +131 -16
- package/src/claude-model-refresh.js +385 -0
- package/src/claude-model-request.js +103 -0
- package/src/claude-stream-parser.js +109 -3
- package/src/claude-tui/diagnostic-tail.js +83 -0
- package/src/claude-tui/form-driver.js +44 -7
- package/src/claude-tui/model-error.js +41 -0
- package/src/claude-tui/pty-driver.js +223 -60
- package/src/claude-tui/sanitize-question-payload.js +109 -0
- package/src/claude-tui/usage-limit.js +239 -0
- package/src/claude-tui-session.js +3611 -286
- package/src/claude-tui-tool-response.js +300 -0
- package/src/cli/agent-control-cmd.js +65 -0
- package/src/cli/config-cmd.js +6 -6
- package/src/cli/config-dir-cmd.js +234 -0
- package/src/cli/deploy-cmd.js +46 -11
- package/src/cli/doctor-cmd.js +7 -3
- package/src/cli/init-cmd.js +16 -17
- package/src/cli/providers-cmd.js +6 -6
- package/src/cli/schedule-cmd.js +804 -0
- package/src/cli/server-cmd.js +64 -2
- package/src/cli/service-cmd.js +70 -27
- package/src/cli/session-cmd.js +227 -74
- package/src/cli/shared.js +168 -14
- package/src/cli/tokens-cmd.js +212 -0
- package/src/cli/tunnel-cmd.js +256 -25
- package/src/cli/worktree-gc-cmd.js +2 -2
- package/src/cli-session.js +1117 -116
- package/src/cli.js +8 -0
- package/src/codex-app-server-client.js +36 -3
- package/src/codex-app-server-session.js +2108 -101
- package/src/codex-bundled-client.js +66 -0
- package/src/codex-model-catalog.js +548 -0
- package/src/codex-model-rejections.js +87 -0
- package/src/codex-native-resume.js +104 -0
- package/src/codex-protocol-capabilities.js +188 -0
- package/src/codex-session.js +571 -45
- package/src/config-dir-migration.js +444 -0
- package/src/config-dir.js +108 -0
- package/src/config.js +738 -52
- package/src/connection-authority.js +48 -0
- package/src/connection-info.js +5 -9
- package/src/connection-locality.js +60 -0
- package/src/container-liveness-monitor.js +189 -0
- package/src/continuation-metadata-worker.js +17 -0
- package/src/continuations.js +114 -0
- package/src/control-room/host-prune.js +5 -0
- package/src/control-room/integrations.js +23 -30
- package/src/control-room/skills-inventory.js +8 -3
- package/src/control-room/survey.js +32 -0
- package/src/conversation-scanner.js +40 -18
- package/src/conversation-scope.js +59 -39
- package/src/conversation-search.js +24 -22
- package/src/credential-store.js +279 -29
- package/src/daemon-commit.js +92 -0
- package/src/daemon-idle-state.js +171 -0
- package/src/daemon-update-status.js +314 -0
- package/src/dashboard-build.js +70 -0
- package/src/declared-status.js +90 -0
- package/src/deepseek-credentials.js +2 -3
- package/src/dev-preview.js +169 -182
- package/src/device-preferences.js +2 -2
- package/src/diagnostics.js +3 -0
- package/src/diff-parser.js +87 -0
- package/src/discord-credentials.js +2 -3
- package/src/docker-byok-pool.js +3 -1
- package/src/docker-byok-session.js +678 -78
- package/src/docker-image-allowlist.js +23 -1
- package/src/docker-sdk-session.js +188 -4
- package/src/docker-session.js +293 -10
- package/src/doctor.js +783 -66
- package/src/edited-input.js +264 -0
- package/src/environment-manager.js +175 -36
- package/src/environments/authority.js +95 -0
- package/src/environments/backends/container-claude-spawn.js +94 -0
- package/src/environments/backends/docker.js +39 -10
- package/src/environments/backends/k8s.js +58 -24
- package/src/environments/destroy-with-sessions.js +142 -0
- package/src/event-ingest.js +137 -14
- package/src/event-normalizer.js +363 -110
- package/src/external-session-registry.js +0 -0
- package/src/gemini-session.js +100 -7
- package/src/github-webhook.js +188 -4
- package/src/handler-utils.js +563 -62
- package/src/handlers/checkpoint-handlers.js +162 -20
- package/src/handlers/control-room-handlers.js +99 -29
- package/src/handlers/conversation-handlers.js +563 -25
- package/src/handlers/credential-handlers.js +43 -2
- package/src/handlers/daemon-update-handlers.js +81 -0
- package/src/handlers/evaluator-handlers.js +14 -1
- package/src/handlers/feature-handlers.js +186 -69
- package/src/handlers/file-handlers.js +101 -13
- package/src/handlers/github-webhook-handlers.js +204 -0
- package/src/handlers/input-handlers.js +689 -48
- package/src/handlers/orchestration-handlers.js +238 -0
- package/src/handlers/scheduler-handlers.js +584 -0
- package/src/handlers/session-handlers.js +546 -16
- package/src/handlers/session-pr-status-handlers.js +283 -0
- package/src/handlers/session-pr-threads-handlers.js +247 -0
- package/src/handlers/settings-handlers.js +822 -35
- package/src/handlers/skills-handlers.js +13 -4
- package/src/handlers/summarize-handlers.js +32 -1
- package/src/handlers/survey-throttle.js +380 -0
- package/src/handlers/token-handlers.js +11 -2
- package/src/health-proof.js +40 -0
- package/src/history-page.js +104 -0
- package/src/http-routes.js +286 -8
- package/src/ide/search.js +24 -6
- package/src/ide/symbols.js +20 -6
- package/src/input-context.js +117 -0
- package/src/instruction-policy-compiler.js +229 -0
- package/src/instruction-policy.js +250 -0
- package/src/jsonl-reader.js +309 -48
- package/src/jsonl-subprocess-session.js +122 -9
- package/src/keychain.js +160 -13
- package/src/logger.js +240 -31
- package/src/mailbox-route.js +11 -22
- package/src/message-wire.js +386 -0
- package/src/model-discovery.js +43 -3
- package/src/models.js +1276 -174
- package/src/notification-prefs.js +100 -10
- package/src/notifications/discord-billing-sink.js +22 -5
- package/src/notifications/discord-ci-sink.js +243 -0
- package/src/notifications/discord-webhook-client.js +71 -0
- package/src/notifications/discord-webhook-sink.js +82 -12
- package/src/notifications/expo-push-sink.js +85 -6
- package/src/notifications/ready-body.js +16 -5
- package/src/ollama-session.js +34 -2
- package/src/orchestration/build-manager.js +63 -0
- package/src/orchestration/decision-contract.js +245 -0
- package/src/orchestration/git-ops.js +381 -0
- package/src/orchestration/orchestration-manager.js +1342 -0
- package/src/orchestration/permission-gate.js +121 -0
- package/src/orchestration/role-prompts.js +136 -0
- package/src/orchestration/run-budget.js +81 -0
- package/src/orchestration/run-ledger.js +487 -0
- package/src/orchestration/run-model.js +206 -0
- package/src/orchestration/run-record.js +336 -0
- package/src/orchestration/run-report.js +194 -0
- package/src/orchestration/to-wire.js +201 -0
- package/src/orchestration/turn-driver.js +422 -0
- package/src/orphan-reaper.js +413 -0
- package/src/outgoing-policy.js +183 -0
- package/src/pairing.js +236 -12
- package/src/path-hash-trust-ledger.js +642 -25
- package/src/permission-audit.js +79 -3
- package/src/permission-deadlines.js +82 -0
- package/src/permission-floor.js +1770 -0
- package/src/permission-hook.js +180 -69
- package/src/permission-manager.js +1175 -94
- package/src/permission-mode-support.js +35 -0
- package/src/permission-resolver.js +174 -12
- package/src/permission-rule-store.js +411 -0
- package/src/permission-scope.js +43 -0
- package/src/platform.js +483 -23
- package/src/preview-ingress.js +54 -0
- package/src/preview-target.js +213 -0
- package/src/prompt-evaluator.js +34 -4
- package/src/provider-customization.js +180 -0
- package/src/providers.js +228 -6
- package/src/push.js +30 -4
- package/src/question-route-map.js +130 -0
- package/src/redaction.js +360 -8
- package/src/roster-broadcast.js +186 -0
- package/src/schedule-parser.js +311 -0
- package/src/scheduled-task-store.js +945 -0
- package/src/scheduler.js +1099 -0
- package/src/sdk-session.js +2374 -168
- package/src/server-cli/preview-shutdown.js +22 -0
- package/src/server-cli/push-notification-handler.js +11 -2
- package/src/server-cli/server-orchestrator.js +50 -4
- package/src/server-cli/tunnel-lifecycle-handler.js +3 -2
- package/src/server-cli-child.js +33 -18
- package/src/server-cli.js +760 -62
- package/src/server-identity.js +42 -14
- package/src/service.js +682 -53
- package/src/session-archive-limits.js +15 -0
- package/src/session-archive.js +1029 -0
- package/src/session-busy-state.js +72 -0
- package/src/session-ci-watcher.js +926 -0
- package/src/session-context.js +7 -2
- package/src/session-manager.js +3879 -308
- package/src/session-message-history.js +749 -37
- package/src/session-pr-status.js +654 -0
- package/src/session-pr-threads.js +271 -0
- package/src/session-preset-trust.js +3 -3
- package/src/session-preset.js +10 -5
- package/src/session-state-persistence.js +94 -17
- package/src/session-timeout-manager.js +20 -0
- package/src/session-title.js +168 -0
- package/src/session-token-store.js +70 -36
- package/src/session-wake.js +240 -0
- package/src/shell-approval-info.js +2 -2
- package/src/shell-approval-store.js +3 -1
- package/src/skills-loader.js +7 -4
- package/src/skills-manager.js +2 -2
- package/src/skills-trust.js +95 -13
- package/src/skills-usage.js +22 -5
- package/src/snapshots-store.js +2 -3
- package/src/statusline.js +596 -0
- package/src/subagent-counter.js +9 -1
- package/src/summarize-session.js +51 -4
- package/src/supervisor.js +99 -38
- package/src/sweep-stale-provider-dirs.js +95 -0
- package/src/thinking-level-wire.js +39 -0
- package/src/thinking-stream.js +179 -0
- package/src/token-manager.js +39 -9
- package/src/tool-result.js +61 -0
- package/src/transcript-sources.js +109 -0
- package/src/transcript-tasks.js +413 -31
- package/src/trusted-file-read.js +302 -0
- package/src/tunnel/base.js +0 -8
- package/src/tunnel/cloudflare.js +145 -35
- package/src/tunnel/index.js +13 -1
- package/src/tunnel/preview.js +64 -0
- package/src/tunnel-check.js +1 -1
- package/src/turn-outcome.js +137 -0
- package/src/turn-tracker.js +0 -0
- package/src/usage-normalize.js +122 -0
- package/src/user-shell-session.js +157 -37
- package/src/utils/agent-sdk-version.js +107 -0
- package/src/utils/argv-safety.js +741 -0
- package/src/utils/auth-cause.js +60 -0
- package/src/utils/binary-package-manifest.js +597 -0
- package/src/utils/binary-version.js +224 -0
- package/src/utils/bounded-regex-worker.js +25 -0
- package/src/utils/bounded-regex.js +153 -0
- package/src/utils/claude-binary.js +43 -0
- package/src/utils/claude-config-dir.js +245 -0
- package/src/utils/claude-login-command.js +16 -0
- package/src/utils/claude-native-route.js +81 -0
- package/src/utils/componentwise-resolver.js +301 -0
- package/src/utils/composite-key.js +45 -0
- package/src/utils/deploy-control-files.js +87 -0
- package/src/utils/exec-failure-reason.js +21 -0
- package/src/utils/git-repo.js +42 -0
- package/src/utils/is-entry-point.js +137 -0
- package/src/utils/iso-datetime.js +51 -0
- package/src/utils/node-pty-probe.js +95 -0
- package/src/utils/node-pty-support.js +118 -0
- package/src/utils/opened-file-path.js +167 -0
- package/src/utils/path-containment.js +165 -0
- package/src/utils/permission-mode-sidecar.js +51 -0
- package/src/utils/preflight.js +485 -29
- package/src/utils/read-limiter.js +217 -0
- package/src/utils/regular-file.js +375 -0
- package/src/utils/safe-regex.js +113 -0
- package/src/utils/small-file.js +129 -0
- package/src/utils/spawn-env.js +196 -5
- package/src/utils/stale-session-dirs.js +182 -0
- package/src/utils/stat-identity.js +43 -0
- package/src/utils/verify-binary.js +276 -0
- package/src/utils/verify-provenance.js +634 -0
- package/src/utils/wire-counters.js +48 -0
- package/src/web-task-manager.js +256 -16
- package/src/worktree-gc.js +11 -3
- package/src/ws-auth.js +69 -21
- package/src/ws-broadcaster.js +14 -2
- package/src/ws-client-manager.js +16 -1
- package/src/ws-client-sender.js +7 -0
- package/src/ws-file-ops/browser.js +370 -66
- package/src/ws-file-ops/common.js +384 -11
- package/src/ws-file-ops/git.js +615 -44
- package/src/ws-file-ops/index.js +7 -0
- package/src/ws-file-ops/memory.js +460 -0
- package/src/ws-file-ops/open-nofollow.js +354 -0
- package/src/ws-file-ops/reader.js +676 -94
- package/src/ws-forwarding.js +373 -55
- package/src/ws-handler-context.js +89 -2
- package/src/ws-history.js +1018 -177
- package/src/ws-message-handlers.js +23 -1
- package/src/ws-outbound-schemas.js +207 -0
- package/src/ws-permissions.js +589 -38
- package/src/ws-schemas.js +6 -0
- package/src/ws-server.js +936 -105
- package/src/dashboard-next/dist/assets/index-C2ipeGlq.js +0 -111
- package/src/dashboard-next/dist/assets/index-DM-_dISG.css +0 -1
- package/src/dashboard-next/dist/index.html +0 -13
package/src/cli/server-cmd.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { addServerOptions, loadAndMergeConfig, parseExtraOverrides } from './shared.js'
|
|
7
7
|
import { parseTunnelArg } from '../tunnel/index.js'
|
|
8
8
|
import { runDoctorChecks } from '../doctor.js'
|
|
9
|
+
import { resolveBinaryProvenanceMode, isBinarySignatureGateEnabled } from '../config.js'
|
|
10
|
+
import { resolveDaemonDefaultProvider } from '../providers.js'
|
|
9
11
|
|
|
10
12
|
export function registerServerCommands(program) {
|
|
11
13
|
const startCmd = program
|
|
@@ -35,7 +37,52 @@ export function registerServerCommands(program) {
|
|
|
35
37
|
const needsTunnel = !!parsedTunnel && !config.noAuth && !config.externalUrl
|
|
36
38
|
if (!options.skipChecks) {
|
|
37
39
|
const port = config.port || 8765
|
|
38
|
-
|
|
40
|
+
// #8074 review C1: resolve the binary-provenance gate from the SAME
|
|
41
|
+
// merged config `startCliServer`/`startSupervisor` below are about to
|
|
42
|
+
// use (loadAndMergeConfig, which honours `-c <path>`) — not doctor's
|
|
43
|
+
// own default `configPath('config.json')` read. Without this, `chroxy
|
|
44
|
+
// start -c other.json` gated its dependency checks against the
|
|
45
|
+
// OPERATOR'S DEFAULT config file while the daemon it then started
|
|
46
|
+
// read `other.json`, so a `-c` invocation's checks could silently
|
|
47
|
+
// gate against the wrong file's `binaryProvenance` settings (or none
|
|
48
|
+
// at all). Env vars still win inside the resolvers themselves, so
|
|
49
|
+
// CHROXY_BINARY_PROVENANCE / CHROXY_BINARY_SIGNATURE_GATE precedence
|
|
50
|
+
// is unchanged.
|
|
51
|
+
//
|
|
52
|
+
// #8075: same defect family, the remaining half C1 left open — the
|
|
53
|
+
// PROVIDER selection. Without an explicit `providers` override,
|
|
54
|
+
// `runDoctorChecks` falls back to `resolveProviders`, which re-reads
|
|
55
|
+
// the provider out of doctor's own default `configPath('config.json')`
|
|
56
|
+
// (or DEFAULT_PROVIDER when that file is missing/unset) — never the
|
|
57
|
+
// provider `--provider`, `-c <path>`, or CHROXY_PROVIDER actually
|
|
58
|
+
// selected on the MERGED config above. That silently checked the
|
|
59
|
+
// wrong provider's binary/credentials/provenance (and, via
|
|
60
|
+
// `resolvedProviders[0]`, the wrong provider in the billing-canary
|
|
61
|
+
// line and the claude-tui version-pin probe too) while the daemon
|
|
62
|
+
// below spawned the one the operator actually asked for.
|
|
63
|
+
// `resolveDaemonDefaultProvider` is the ONE derivation of "this
|
|
64
|
+
// daemon's resolved default provider" (#7932, providers.js) — reused
|
|
65
|
+
// here rather than a second `config.provider || DEFAULT_PROVIDER`
|
|
66
|
+
// inline, so this can never drift from what `startCliServer` /
|
|
67
|
+
// `startSupervisor` are about to spawn.
|
|
68
|
+
// #8116: same rationale as the two overrides above (review C1 /
|
|
69
|
+
// #8075) — the named-tunnel routability probe (doctor.js step 5.6,
|
|
70
|
+
// #5328 WP-5.6) must target the MERGED config's tunnel coordinates
|
|
71
|
+
// (-c <path> / --tunnel / --tunnel-hostname / CHROXY_TUNNEL* env),
|
|
72
|
+
// not doctor's own default config.json read, which names whatever
|
|
73
|
+
// tunnel a PRIOR `chroxy init`/`chroxy tunnel setup` configured —
|
|
74
|
+
// not necessarily the one the daemon below is about to actually use.
|
|
75
|
+
// Reuses the SAME `parsedTunnel` already computed above (no second,
|
|
76
|
+
// differently-normalized parse of config.tunnel) and `config`'s own
|
|
77
|
+
// merged `tunnelHostname` field.
|
|
78
|
+
const { checks } = await runDoctorChecks({
|
|
79
|
+
port,
|
|
80
|
+
providers: [resolveDaemonDefaultProvider(config)],
|
|
81
|
+
binaryProvenanceMode: resolveBinaryProvenanceMode(config),
|
|
82
|
+
binarySignatureGate: isBinarySignatureGateEnabled(config),
|
|
83
|
+
tunnelMode: parsedTunnel?.mode ?? null,
|
|
84
|
+
tunnelHostname: config.tunnelHostname || null,
|
|
85
|
+
})
|
|
39
86
|
const failures = checks.filter((c) => {
|
|
40
87
|
if (c.status !== 'fail') return false
|
|
41
88
|
// Only require cloudflared when a tunnel will actually be used
|
|
@@ -47,11 +94,26 @@ export function registerServerCommands(program) {
|
|
|
47
94
|
for (const f of failures) {
|
|
48
95
|
console.error(` ✗ ${f.name}: ${f.message}`)
|
|
49
96
|
}
|
|
50
|
-
console.error('\nRun `
|
|
97
|
+
console.error('\nRun `chroxy doctor` for details, or `--skip-checks` to bypass.\n')
|
|
51
98
|
process.exitCode = 1
|
|
52
99
|
return
|
|
53
100
|
}
|
|
54
101
|
}
|
|
102
|
+
// #7162: bound the service-manager capture files exactly once per
|
|
103
|
+
// service boot — here, in the process the service manager spawned,
|
|
104
|
+
// BEFORE any supervisor fork. This is the only point where the capture
|
|
105
|
+
// fd offset is guaranteed ~0 on the non-append platform (systemd
|
|
106
|
+
// `file:`); a supervised child restart must never re-truncate under
|
|
107
|
+
// the supervisor's live fd (capStdioCaptureLogs itself excludes
|
|
108
|
+
// win32 — the .cmd wrapper rotates before the redirect opens). The
|
|
109
|
+
// notice lands at the top of the freshly truncated capture.
|
|
110
|
+
if (process.env.CHROXY_DAEMON === '1' && process.env.CHROXY_SUPERVISED !== '1') {
|
|
111
|
+
const { capStdioCaptureLogs } = await import('../logger.js')
|
|
112
|
+
for (const { file, archive, preservedBytes } of capStdioCaptureLogs()) {
|
|
113
|
+
console.log(`[chroxy] capped oversized capture log ${file} (last ${preservedBytes} bytes preserved to ${archive})`)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
55
117
|
const useSupervisor = !!parsedTunnel
|
|
56
118
|
&& !config.noAuth
|
|
57
119
|
&& !config.externalUrl
|
package/src/cli/service-cmd.js
CHANGED
|
@@ -12,44 +12,50 @@ export function registerServiceCommand(program) {
|
|
|
12
12
|
|
|
13
13
|
serviceCmd
|
|
14
14
|
.command('install')
|
|
15
|
-
.description('Register Chroxy as a system daemon (launchd/systemd)')
|
|
15
|
+
.description('Register Chroxy as a system daemon (launchd / systemd / Windows Task Scheduler)')
|
|
16
16
|
.option('--cwd <path>', 'Working directory for Claude sessions')
|
|
17
17
|
.option('--start-at-login', 'Start automatically on login')
|
|
18
|
+
.option('--force', 'Re-point an already-installed service at THIS working copy (#7161)')
|
|
18
19
|
.action(async (options) => {
|
|
19
20
|
const {
|
|
20
21
|
getServicePaths,
|
|
21
22
|
resolveNode22Path,
|
|
22
23
|
resolveChroxyBin,
|
|
23
24
|
resolveClaudeBin,
|
|
24
|
-
|
|
25
|
+
assertReinstallAllowed,
|
|
26
|
+
assertChroxyTreeReady,
|
|
25
27
|
installService,
|
|
26
28
|
} = await import('../service.js')
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
let nodePath
|
|
31
|
+
try {
|
|
32
|
+
nodePath = resolveNode22Path()
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.error(`Error: ${err.message}`)
|
|
31
35
|
process.exit(1)
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.error(
|
|
38
|
+
let chroxyBin
|
|
39
|
+
try {
|
|
40
|
+
chroxyBin = resolveChroxyBin()
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.error(`Error: ${err.message}`)
|
|
39
43
|
process.exit(1)
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
// #7161: an existing service is never re-pointed at this working copy
|
|
47
|
+
// without --force. Checked before the (slower) preflight and before any write.
|
|
43
48
|
try {
|
|
44
|
-
|
|
49
|
+
assertReinstallAllowed({ chroxyBin, force: options.force === true })
|
|
45
50
|
} catch (err) {
|
|
46
|
-
console.error(
|
|
51
|
+
console.error(err.message)
|
|
47
52
|
process.exit(1)
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
// #7161: fail here, offline, if the target tree cannot start, rather than
|
|
56
|
+
// letting launchd KeepAlive discover it as a crash loop.
|
|
51
57
|
try {
|
|
52
|
-
chroxyBin
|
|
58
|
+
assertChroxyTreeReady(chroxyBin)
|
|
53
59
|
} catch (err) {
|
|
54
60
|
console.error(`Error: ${err.message}`)
|
|
55
61
|
process.exit(1)
|
|
@@ -76,31 +82,47 @@ export function registerServiceCommand(program) {
|
|
|
76
82
|
const startAtLogin = options.startAtLogin || false
|
|
77
83
|
|
|
78
84
|
try {
|
|
79
|
-
installService({
|
|
85
|
+
const result = installService({
|
|
80
86
|
nodePath,
|
|
81
87
|
chroxyBin,
|
|
82
88
|
claudeBin,
|
|
83
89
|
cwd,
|
|
84
90
|
startAtLogin,
|
|
91
|
+
force: options.force === true,
|
|
85
92
|
})
|
|
86
93
|
|
|
87
94
|
const paths = getServicePaths()
|
|
88
|
-
const servicePath = paths.type === 'launchd' ? paths.plistPath : paths.unitPath
|
|
89
95
|
|
|
90
96
|
console.log('\n\u2705 Chroxy service installed successfully!\n')
|
|
91
97
|
console.log(` Node: ${nodePath}`)
|
|
92
98
|
console.log(` Chroxy CLI: ${chroxyBin}`)
|
|
93
99
|
console.log(` Claude CLI: ${claudeBin}`)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.log(
|
|
100
|
-
console.log('
|
|
100
|
+
|
|
101
|
+
if (paths.type === 'windows') {
|
|
102
|
+
console.log(` Task: ${result?.taskName || 'Chroxy'} (Windows Task Scheduler)`)
|
|
103
|
+
console.log(` Wrapper: ${result?.wrapperPath}`)
|
|
104
|
+
console.log(` Log dir: ${paths.logDir}`)
|
|
105
|
+
console.log(` Working dir: ${cwd}`)
|
|
106
|
+
console.log(' Start on login: true (ONLOGON)')
|
|
107
|
+
console.log('\nThe scheduled task is registered and will start Chroxy at your next logon.')
|
|
108
|
+
console.log('To start it now: chroxy service start')
|
|
109
|
+
console.log('To check it: chroxy service status')
|
|
110
|
+
console.log('\nNote: the task runs at LOGON as your user (schtasks /SC ONLOGON /IT), not at')
|
|
111
|
+
console.log('boot. A boot-time daemon would run as SYSTEM with no access to your credential')
|
|
112
|
+
console.log('store or session \u2014 the wrong model for a per-user dev daemon.')
|
|
101
113
|
} else {
|
|
102
|
-
|
|
103
|
-
console.log(
|
|
114
|
+
const servicePath = paths.type === 'launchd' ? paths.plistPath : paths.unitPath
|
|
115
|
+
console.log(` Service file: ${servicePath}`)
|
|
116
|
+
console.log(` Log dir: ${paths.logDir}`)
|
|
117
|
+
console.log(` Working dir: ${cwd}`)
|
|
118
|
+
console.log(` Start on login: ${startAtLogin}`)
|
|
119
|
+
if (paths.type === 'launchd') {
|
|
120
|
+
console.log('\nThe service is installed but not running. To start it now:')
|
|
121
|
+
console.log(' launchctl start com.chroxy.server')
|
|
122
|
+
} else {
|
|
123
|
+
console.log('\nThe service is enabled and running. To restart it:')
|
|
124
|
+
console.log(' systemctl --user restart chroxy.service')
|
|
125
|
+
}
|
|
104
126
|
}
|
|
105
127
|
} catch (err) {
|
|
106
128
|
console.error(`Error installing service: ${err.message}`)
|
|
@@ -126,6 +148,8 @@ export function registerServiceCommand(program) {
|
|
|
126
148
|
console.log(' Service file and state have been removed.')
|
|
127
149
|
if (state.platform === 'darwin') {
|
|
128
150
|
console.log(' The launchd job has been unloaded.')
|
|
151
|
+
} else if (state.platform === 'win32') {
|
|
152
|
+
console.log(' The Windows scheduled task has been deleted.')
|
|
129
153
|
} else {
|
|
130
154
|
console.log(' The systemd unit has been disabled and stopped.')
|
|
131
155
|
}
|
|
@@ -190,7 +214,7 @@ export function registerServiceCommand(program) {
|
|
|
190
214
|
.command('status')
|
|
191
215
|
.description('Show daemon status')
|
|
192
216
|
.action(async () => {
|
|
193
|
-
const { getFullServiceStatus } = await import('../service.js')
|
|
217
|
+
const { getFullServiceStatus, getWindowsTaskStatus, inspectInstalledService } = await import('../service.js')
|
|
194
218
|
const status = await getFullServiceStatus()
|
|
195
219
|
|
|
196
220
|
console.log('\nChroxy Service Status\n')
|
|
@@ -203,6 +227,25 @@ export function registerServiceCommand(program) {
|
|
|
203
227
|
|
|
204
228
|
console.log(' Installed: Yes')
|
|
205
229
|
|
|
230
|
+
// #7161: surface a service.json / wrapper disagreement instead of hiding it.
|
|
231
|
+
const target = inspectInstalledService()
|
|
232
|
+
const pinned = target.wrapperBin || target.recordedBin
|
|
233
|
+
if (pinned) console.log(' Runs from: ' + pinned)
|
|
234
|
+
if (target.drift) {
|
|
235
|
+
console.log(' WARNING: service.json records ' + target.recordedBin)
|
|
236
|
+
console.log(' but the wrapper execs ' + target.wrapperBin)
|
|
237
|
+
console.log(' Re-run "chroxy service install --force" from the intended tree.')
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// On Windows, surface the scheduled task's registration/run state
|
|
241
|
+
// (schtasks /Query /V) alongside the daemon-liveness (PID) check (#6647).
|
|
242
|
+
if (isWindows) {
|
|
243
|
+
const task = getWindowsTaskStatus()
|
|
244
|
+
console.log(' Task: ' + (task.registered
|
|
245
|
+
? `registered${task.status ? ` (${task.status})` : ''}`
|
|
246
|
+
: 'not registered'))
|
|
247
|
+
}
|
|
248
|
+
|
|
206
249
|
if (!status.running) {
|
|
207
250
|
if (status.stale) {
|
|
208
251
|
console.log(' Running: No (stale PID file)')
|
package/src/cli/session-cmd.js
CHANGED
|
@@ -3,14 +3,106 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { existsSync, readFileSync } from 'fs'
|
|
5
5
|
import { join } from 'path'
|
|
6
|
-
import {
|
|
6
|
+
import { configDir, configFile, resolveVerifiedCliBinary } from './shared.js'
|
|
7
|
+
import { CliSession } from '../cli-session.js'
|
|
8
|
+
import { buildClaudeLaunchEnv } from '../utils/spawn-env.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* #8061 — resolve AND verify the exact `claude` binary `chroxy resume`
|
|
12
|
+
* is about to exec, through the SAME opt-in provenance gate a fresh chat
|
|
13
|
+
* session (or the summarizer/web-task one-shots) would run:
|
|
14
|
+
* `runProviderPreflight(ProviderClass, { provenance })`, the machinery
|
|
15
|
+
* `SessionManager.verifyOneShotExecutable()` wraps (#8030/#8036) — reused
|
|
16
|
+
* here rather than a second gate implementation.
|
|
17
|
+
*
|
|
18
|
+
* This CLI subcommand runs standalone, with no daemon `SessionManager`
|
|
19
|
+
* instance to read `_binaryProvenanceMode` / `_binarySignatureGate` /
|
|
20
|
+
* `binaryProvenanceLedger` off of. So the two flags are resolved straight
|
|
21
|
+
* from the loaded config via the exact same resolvers `chroxy start` uses
|
|
22
|
+
* (`resolveBinaryProvenanceMode` / `isBinarySignatureGateEnabled`), folded
|
|
23
|
+
* into the options bag through the SAME normalizer
|
|
24
|
+
* `SessionManager._binaryProvenanceOptions()` uses
|
|
25
|
+
* (`buildBinaryProvenanceOptions`, utils/preflight.js) — so "the gate is off"
|
|
26
|
+
* is defined once, not twice.
|
|
27
|
+
*
|
|
28
|
+
* #8065 review S4: `configPath` defaults to the CLI's normal config file
|
|
29
|
+
* (`configFile()`) but is overridable — `chroxy resume -c <path>` reads
|
|
30
|
+
* `binaryProvenance` from THAT file, mirroring how a daemon started with
|
|
31
|
+
* `chroxy start -c <path>` reads its own gate config. `CHROXY_BINARY_PROVENANCE`
|
|
32
|
+
* / `CHROXY_BINARY_SIGNATURE_GATE` still take precedence over either file
|
|
33
|
+
* (`resolveBinaryProvenanceMode`/`isBinarySignatureGateEnabled`'s own
|
|
34
|
+
* precedence) — but those are read from THIS process's environment, i.e. the
|
|
35
|
+
* invoking shell's, which is NOT the same environment a `chroxy start`
|
|
36
|
+
* daemon (a background service, a desktop app, a different shell) was
|
|
37
|
+
* launched under. An env-only gate set on that daemon is invisible here;
|
|
38
|
+
* only its config FILE is shared ground truth.
|
|
39
|
+
*
|
|
40
|
+
* #8065 review nitpick 3: the ledger is opened LAZILY, only when a gate is
|
|
41
|
+
* actually on (`mode !== 'off'` or `signatureGate`). `chroxy resume`'s
|
|
42
|
+
* default mode is off, so opening — and potentially warning on — the ledger
|
|
43
|
+
* file on every single invocation regardless would be pointless disk I/O and
|
|
44
|
+
* a confusing warning for a file the resolved options bag is about to
|
|
45
|
+
* discard anyway (`buildBinaryProvenanceOptions` returns `null` in that
|
|
46
|
+
* case). This differs from the daemon, which constructs its one ledger
|
|
47
|
+
* instance once at startup and can be re-armed to `warn`/`block` at runtime
|
|
48
|
+
* without a restart (so it always keeps the ledger warm) — a short-lived CLI
|
|
49
|
+
* invocation with gates off will never touch the ledger at all.
|
|
50
|
+
*
|
|
51
|
+
* `chroxy resume` always shells out to the `claude` CLI directly —
|
|
52
|
+
* never the Agent SDK, never claude-tui's PTY — so `CliSession` (whose
|
|
53
|
+
* `preflight` / `resolvedBinary` describe exactly that binary, the same
|
|
54
|
+
* class `web-task-manager.js`'s one-shot spawns gate against, #8039) is the
|
|
55
|
+
* provider to verify: the same binary a fresh `claude-cli` chat session
|
|
56
|
+
* would refuse under `binaryProvenance.mode: 'block'` is refused here too.
|
|
57
|
+
*
|
|
58
|
+
* Fails CLOSED: any thrown error — one of `runProviderPreflight`'s typed
|
|
59
|
+
* errors (`ProviderBinaryProvenanceError`, `ProviderBinaryNotFoundError`, …),
|
|
60
|
+
* `readGateConfig`'s `GATE_CONFIG_UNREADABLE`, or the
|
|
61
|
+
* `PROVIDER_BINARY_UNVERIFIED` this throws itself when preflight resolves no
|
|
62
|
+
* path — propagates to the caller (`runSessionResume`), which prints it and
|
|
63
|
+
* exits non-zero WITHOUT spawning anything. This function itself never calls
|
|
64
|
+
* `process.exit`, so it stays safely unit-testable in-process (#8061 tests).
|
|
65
|
+
*
|
|
66
|
+
* @param {object} [deps] - test seams; production supplies none of them.
|
|
67
|
+
* @param {string} [deps.configPath] - defaults to `configFile()`; the config
|
|
68
|
+
* file `binaryProvenance` is read from (#8065 review S4).
|
|
69
|
+
* @param {Function} [deps.readConfig] - defaults to `readGateConfig(configPath)`.
|
|
70
|
+
* @param {object} [deps.ledger] - defaults to a lazily-opened, default-path
|
|
71
|
+
* ledger (see nitpick 3 above); pass one explicitly to override, including
|
|
72
|
+
* `null`.
|
|
73
|
+
* @param {Function} [deps.preflight] - defaults to `runProviderPreflight`.
|
|
74
|
+
* @param {Function} [deps.ProviderClass] - defaults to `CliSession`.
|
|
75
|
+
* @returns {string} the verified, spawnable absolute path to `claude`.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveVerifiedClaudeBinary({
|
|
78
|
+
configPath,
|
|
79
|
+
readConfig,
|
|
80
|
+
ledger,
|
|
81
|
+
preflight,
|
|
82
|
+
ProviderClass = CliSession,
|
|
83
|
+
} = {}) {
|
|
84
|
+
// #8076 review S2: the actual gate sequence (read config → mode →
|
|
85
|
+
// signatureGate → gateIsOn → lazy ledger → buildBinaryProvenanceOptions →
|
|
86
|
+
// preflight → PROVIDER_BINARY_UNVERIFIED) now lives once, in
|
|
87
|
+
// `resolveVerifiedCliBinary` (cli/shared.js), shared with `chroxy tunnel
|
|
88
|
+
// setup`'s `resolveVerifiedCloudflaredBinary`. This wrapper only supplies
|
|
89
|
+
// this command's own default (`ProviderClass = CliSession`) and label.
|
|
90
|
+
return resolveVerifiedCliBinary({
|
|
91
|
+
configPath,
|
|
92
|
+
readConfig,
|
|
93
|
+
ledger,
|
|
94
|
+
preflight,
|
|
95
|
+
ProviderClass,
|
|
96
|
+
providerLabel: ProviderClass.displayLabel || ProviderClass.name || 'claude-cli',
|
|
97
|
+
})
|
|
98
|
+
}
|
|
7
99
|
|
|
8
100
|
export function registerSessionCommands(program) {
|
|
9
101
|
program
|
|
10
102
|
.command('sessions')
|
|
11
103
|
.description('List saved sessions with conversation IDs for terminal handoff')
|
|
12
104
|
.action(() => {
|
|
13
|
-
const stateFile = join(
|
|
105
|
+
const stateFile = join(configDir(), 'session-state.json')
|
|
14
106
|
|
|
15
107
|
if (!existsSync(stateFile)) {
|
|
16
108
|
console.log('\nNo saved sessions found.')
|
|
@@ -57,87 +149,148 @@ export function registerSessionCommands(program) {
|
|
|
57
149
|
.description('Resume a Chroxy session in your terminal')
|
|
58
150
|
.argument('[session]', 'Session name or number (default: most recent)')
|
|
59
151
|
.option('--dangerously-skip-permissions', 'Pass --dangerously-skip-permissions to claude')
|
|
152
|
+
// #8065 review S4: mirrors `providers-cmd.js`'s `-c, --config` — lets the
|
|
153
|
+
// binary-provenance gate read the SAME config file a `chroxy start -c
|
|
154
|
+
// <path>` daemon reads its own gate settings from, instead of always
|
|
155
|
+
// reading `<configDir>/config.json`. Only affects the gate (mode /
|
|
156
|
+
// signatureGate); CHROXY_BINARY_PROVENANCE / CHROXY_BINARY_SIGNATURE_GATE
|
|
157
|
+
// env vars still win when set, but they are read from THIS invocation's
|
|
158
|
+
// own shell, not from whatever environment a running daemon started in.
|
|
159
|
+
.option('-c, --config <path>', 'Path to config file (only affects the binary-provenance gate; env overrides come from the invoking shell, not a running daemon)', configFile())
|
|
60
160
|
.action(async (sessionArg, options) => {
|
|
61
|
-
|
|
62
|
-
|
|
161
|
+
await runSessionResume(sessionArg, options)
|
|
162
|
+
})
|
|
163
|
+
}
|
|
63
164
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Core `chroxy resume` logic, extracted from the Commander `.action()`
|
|
167
|
+
* above so it is directly callable — with injectable deps — from tests
|
|
168
|
+
* without spawning a subprocess (#8061). Production callers (the `.action()`
|
|
169
|
+
* above) pass no `deps`, so every seam below resolves to the exact same
|
|
170
|
+
* behaviour this command always had, plus the #8061 binary-verification gate.
|
|
171
|
+
*
|
|
172
|
+
* @param {string|undefined} sessionArg - session name or 1-based index.
|
|
173
|
+
* @param {{ dangerouslySkipPermissions?: boolean, config?: string }} options - Commander options.
|
|
174
|
+
* @param {object} [deps]
|
|
175
|
+
* @param {string} [deps.stateFile] - defaults to `<configDir>/session-state.json`.
|
|
176
|
+
* @param {Function} [deps.resolveBinary] - defaults to `resolveVerifiedClaudeBinary`,
|
|
177
|
+
* called as `resolveBinary({ configPath: options.config })` in production.
|
|
178
|
+
* Tests inject a thunk that calls `resolveVerifiedClaudeBinary` with a
|
|
179
|
+
* fixture provider / ledger / config instead of exercising the real host
|
|
180
|
+
* `claude` install (the thunk's own arity decides whether it even looks at
|
|
181
|
+
* the argument passed here).
|
|
182
|
+
*/
|
|
183
|
+
export async function runSessionResume(sessionArg, options, deps = {}) {
|
|
184
|
+
const {
|
|
185
|
+
stateFile = join(configDir(), 'session-state.json'),
|
|
186
|
+
resolveBinary = resolveVerifiedClaudeBinary,
|
|
187
|
+
} = deps
|
|
68
188
|
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
state = JSON.parse(readFileSync(stateFile, 'utf-8'))
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.error(`Failed to read session state: ${err.message}`)
|
|
74
|
-
process.exit(1)
|
|
75
|
-
}
|
|
189
|
+
const { execFileSync } = await import('child_process')
|
|
76
190
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
191
|
+
if (!existsSync(stateFile)) {
|
|
192
|
+
console.error('No saved sessions found. Start the server first.')
|
|
193
|
+
process.exit(1)
|
|
194
|
+
}
|
|
81
195
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
196
|
+
let state
|
|
197
|
+
try {
|
|
198
|
+
state = JSON.parse(readFileSync(stateFile, 'utf-8'))
|
|
199
|
+
} catch (err) {
|
|
200
|
+
console.error(`Failed to read session state: ${err.message}`)
|
|
201
|
+
process.exit(1)
|
|
202
|
+
}
|
|
85
203
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
204
|
+
if (!Array.isArray(state.sessions) || state.sessions.length === 0) {
|
|
205
|
+
console.error('No saved sessions.')
|
|
206
|
+
process.exit(1)
|
|
207
|
+
}
|
|
90
208
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (!isNaN(num) && num >= 1 && num <= resumable.length) {
|
|
95
|
-
target = resumable[num - 1]
|
|
96
|
-
} else {
|
|
97
|
-
target = resumable.find(s => s.name.toLowerCase() === sessionArg.toLowerCase())
|
|
98
|
-
}
|
|
99
|
-
if (!target) {
|
|
100
|
-
console.error(`Session "${sessionArg}" not found. Available:`)
|
|
101
|
-
resumable.forEach((s, i) => console.error(` ${i + 1}. ${s.name}`))
|
|
102
|
-
process.exit(1)
|
|
103
|
-
}
|
|
104
|
-
} else if (resumable.length === 1) {
|
|
105
|
-
target = resumable[0]
|
|
106
|
-
} else {
|
|
107
|
-
const readline = await import('readline')
|
|
108
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
109
|
-
console.log('\nAvailable sessions:\n')
|
|
110
|
-
resumable.forEach((s, i) => {
|
|
111
|
-
console.log(` ${i + 1}. ${s.name} (${s.cwd})`)
|
|
112
|
-
})
|
|
113
|
-
const answer = await new Promise(resolve => {
|
|
114
|
-
rl.question(`\nPick session [1]: `, resolve)
|
|
115
|
-
})
|
|
116
|
-
rl.close()
|
|
117
|
-
const pick = parseInt(answer, 10) || 1
|
|
118
|
-
if (pick < 1 || pick > resumable.length) {
|
|
119
|
-
console.error('Invalid selection.')
|
|
120
|
-
process.exit(1)
|
|
121
|
-
}
|
|
122
|
-
target = resumable[pick - 1]
|
|
123
|
-
}
|
|
209
|
+
const resumable = state.sessions
|
|
210
|
+
.map((s, i) => ({ ...s, index: i, convId: s.conversationId || s.sdkSessionId }))
|
|
211
|
+
.filter(s => s.convId)
|
|
124
212
|
|
|
125
|
-
|
|
126
|
-
|
|
213
|
+
if (resumable.length === 0) {
|
|
214
|
+
console.error('No sessions have conversation IDs yet. Send a message first.')
|
|
215
|
+
process.exit(1)
|
|
216
|
+
}
|
|
127
217
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
218
|
+
let target
|
|
219
|
+
if (sessionArg) {
|
|
220
|
+
const num = parseInt(sessionArg, 10)
|
|
221
|
+
if (!isNaN(num) && num >= 1 && num <= resumable.length) {
|
|
222
|
+
target = resumable[num - 1]
|
|
223
|
+
} else {
|
|
224
|
+
target = resumable.find(s => s.name.toLowerCase() === sessionArg.toLowerCase())
|
|
225
|
+
}
|
|
226
|
+
if (!target) {
|
|
227
|
+
console.error(`Session "${sessionArg}" not found. Available:`)
|
|
228
|
+
resumable.forEach((s, i) => console.error(` ${i + 1}. ${s.name}`))
|
|
229
|
+
process.exit(1)
|
|
230
|
+
}
|
|
231
|
+
} else if (resumable.length === 1) {
|
|
232
|
+
target = resumable[0]
|
|
233
|
+
} else {
|
|
234
|
+
const readline = await import('readline')
|
|
235
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
236
|
+
console.log('\nAvailable sessions:\n')
|
|
237
|
+
resumable.forEach((s, i) => {
|
|
238
|
+
console.log(` ${i + 1}. ${s.name} (${s.cwd})`)
|
|
239
|
+
})
|
|
240
|
+
const answer = await new Promise(resolve => {
|
|
241
|
+
rl.question(`\nPick session [1]: `, resolve)
|
|
242
|
+
})
|
|
243
|
+
rl.close()
|
|
244
|
+
const pick = parseInt(answer, 10) || 1
|
|
245
|
+
if (pick < 1 || pick > resumable.length) {
|
|
246
|
+
console.error('Invalid selection.')
|
|
247
|
+
process.exit(1)
|
|
248
|
+
}
|
|
249
|
+
target = resumable[pick - 1]
|
|
250
|
+
}
|
|
132
251
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
252
|
+
// #8061 — resolve AND verify the exact binary before printing anything that
|
|
253
|
+
// implies a resume is actually happening, and before touching execFileSync
|
|
254
|
+
// at all. A refusal here fails CLOSED: nothing is spawned. #8065 review
|
|
255
|
+
// nitpick 4: this REFUSAL path is the one that avoids `process.exit` (sets
|
|
256
|
+
// `process.exitCode` and returns instead), which is what keeps it
|
|
257
|
+
// unit-testable in-process — several OTHER paths in this function (above
|
|
258
|
+
// and below) do call `process.exit` directly, matching this command's
|
|
259
|
+
// pre-existing early-exit conventions; only this path and the docblock
|
|
260
|
+
// above describe promise not to.
|
|
261
|
+
let verifiedClaudePath
|
|
262
|
+
try {
|
|
263
|
+
verifiedClaudePath = resolveBinary({ configPath: options.config })
|
|
264
|
+
} catch (err) {
|
|
265
|
+
console.error(`\nRefusing to resume: ${err.message}`)
|
|
266
|
+
process.exitCode = 1
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
console.log(`\nResuming "${target.name}" in ${target.cwd}`)
|
|
271
|
+
console.log(`Conversation: ${target.convId}\n`)
|
|
272
|
+
|
|
273
|
+
const args = ['--resume', target.convId]
|
|
274
|
+
if (options.dangerouslySkipPermissions) {
|
|
275
|
+
args.push('--dangerously-skip-permissions')
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
try {
|
|
279
|
+
execFileSync(verifiedClaudePath, args, {
|
|
280
|
+
stdio: 'inherit',
|
|
281
|
+
cwd: target.cwd,
|
|
282
|
+
// #8262: a resumed claude is a top-level session; do not hand it the
|
|
283
|
+
// parent session's markers from the shell running `chroxy resume`.
|
|
284
|
+
env: buildClaudeLaunchEnv(),
|
|
142
285
|
})
|
|
286
|
+
} catch (err) {
|
|
287
|
+
// #8065 review nitpick 4: `process.exitCode = ...; return` rather than
|
|
288
|
+
// `process.exit(...)` — a test shim that exits non-zero here now fails
|
|
289
|
+
// its assertion legibly instead of killing the whole test file.
|
|
290
|
+
if (err.status != null) {
|
|
291
|
+
process.exitCode = err.status
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
throw err
|
|
295
|
+
}
|
|
143
296
|
}
|