@chroxy/server 0.11.0 → 0.11.11
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 +206 -18
- package/README.md +2 -2
- package/hooks/claude-native-route-check.mjs +17 -0
- package/hooks/permission-hook.sh +166 -11
- package/package.json +16 -12
- 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 +958 -0
- package/src/activity-registry.js +110 -5
- package/src/agent-connections.js +304 -0
- package/src/agent-control/client.js +1645 -0
- package/src/agent-control/events.js +551 -0
- package/src/agent-control/local-connection.js +293 -0
- package/src/agent-control/mcp-server.js +547 -0
- package/src/anthropic-compatible-config.js +30 -4
- package/src/anthropic-compatible-session.js +15 -6
- package/src/anthropic-gemini-shim.js +444 -0
- package/src/anthropic-gemini-translate.js +1030 -0
- 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 +1520 -36
- package/src/bearer-recheck.js +49 -0
- package/src/billing-budget.js +19 -0
- package/src/billing-class.js +40 -7
- package/src/binary-provenance-trust.js +11 -5
- package/src/bound-client-policy.js +291 -0
- package/src/built-in-tools/bash-exec.js +46 -7
- package/src/built-in-tools/file-ops.js +69 -5
- 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 +92 -7
- package/src/byok-mcp-config.js +633 -122
- package/src/byok-mcp-fleet.js +49 -7
- package/src/byok-mcp-oauth-store.js +18 -16
- package/src/byok-mcp-trust.js +37 -23
- package/src/byok-session.js +707 -179
- package/src/byok-tool-executor.js +2742 -26
- package/src/byok-tools.js +9 -2
- package/src/channels/chroxy-channel-server.js +2 -3
- package/src/checkpoint-manager.js +64 -46
- 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-setting-sources.js +74 -0
- package/src/claude-stream-parser.js +53 -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 +215 -88
- 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 +3563 -284
- package/src/claude-tui-tool-response.js +300 -0
- package/src/cli/agent-cmd.js +236 -0
- package/src/cli/agent-control-cmd.js +65 -0
- package/src/cli/config-cmd.js +4 -4
- package/src/cli/config-dir-cmd.js +234 -0
- package/src/cli/connection-state.js +54 -0
- package/src/cli/deploy-cmd.js +45 -10
- package/src/cli/doctor-cmd.js +7 -3
- package/src/cli/freshness-cmd.js +53 -0
- package/src/cli/init-cmd.js +15 -16
- package/src/cli/pages-cmd.js +6 -4
- package/src/cli/pair-code-cmd.js +7 -6
- package/src/cli/pair-discord-cmd.js +7 -6
- package/src/cli/providers-cmd.js +3 -3
- package/src/cli/schedule-cmd.js +91 -40
- package/src/cli/server-cmd.js +54 -1
- package/src/cli/service-cmd.js +33 -10
- package/src/cli/session-cmd.js +227 -74
- package/src/cli/shared.js +162 -11
- package/src/cli/shell-cmd.js +7 -4
- package/src/cli/status-cmd.js +19 -5
- package/src/cli/tokens-cmd.js +4 -5
- package/src/cli/tunnel-cmd.js +255 -24
- package/src/cli/worktree-gc-cmd.js +2 -2
- package/src/cli-session.js +1250 -126
- package/src/cli.js +8 -0
- package/src/codex-app-server-client.js +36 -3
- package/src/codex-app-server-session.js +1517 -81
- package/src/codex-bundled-client.js +66 -0
- package/src/codex-error-text.js +114 -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 +450 -27
- package/src/config-dir-migration.js +449 -0
- package/src/config-dir.js +108 -0
- package/src/config.js +306 -26
- package/src/connection-authority.js +48 -0
- package/src/connection-info.js +78 -23
- 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 +227 -0
- package/src/control-room/host-prune.js +5 -0
- package/src/control-room/integrations.js +7 -20
- package/src/control-room/skills-inventory.js +2 -2
- package/src/conversation-scanner.js +42 -39
- package/src/conversation-scope.js +59 -39
- package/src/conversation-search.js +28 -39
- package/src/credential-store.js +23 -19
- 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 +170 -182
- package/src/device-preferences.js +2 -2
- 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 +172 -3
- package/src/docker-session.js +294 -11
- package/src/doctor.js +781 -64
- package/src/durable-write.js +35 -0
- package/src/edited-input.js +264 -0
- package/src/environment-manager.js +175 -36
- package/src/environments/authority.js +101 -0
- package/src/environments/backends/container-claude-spawn.js +94 -0
- package/src/environments/backends/docker.js +31 -10
- package/src/environments/backends/k8s.js +49 -24
- package/src/environments/destroy-with-sessions.js +142 -0
- package/src/event-ingest.js +118 -13
- package/src/event-normalizer.js +186 -235
- package/src/folder-trust-wire.js +137 -0
- package/src/folder-trust-worker.js +17 -0
- package/src/folder-trust.js +1572 -0
- package/src/freshness/activity-meter.js +101 -0
- package/src/freshness/adapter.js +199 -0
- package/src/freshness/checks.js +239 -0
- package/src/freshness/config.js +98 -0
- package/src/freshness/core.js +185 -0
- package/src/freshness/derive.js +680 -0
- package/src/freshness/exchange.js +305 -0
- package/src/freshness/file-ledger.js +400 -0
- package/src/freshness/grade.js +81 -0
- package/src/freshness/hash.js +45 -0
- package/src/freshness/inbox.js +163 -0
- package/src/freshness/index.js +20 -0
- package/src/freshness/investigation.js +474 -0
- package/src/freshness/keys.js +177 -0
- package/src/freshness/ledger.js +122 -0
- package/src/freshness/outbox.js +131 -0
- package/src/freshness/policy.js +599 -0
- package/src/freshness/queue.js +843 -0
- package/src/freshness/read-errors.js +23 -0
- package/src/freshness/render.js +153 -0
- package/src/freshness/runtime.js +113 -0
- package/src/freshness/session-registry-adapter.js +161 -0
- package/src/freshness/state-file-adapter.js +167 -0
- package/src/freshness-runner/build-info.js +139 -0
- package/src/freshness-runner/cli.js +105 -0
- package/src/freshness-runner/run-tick.js +109 -0
- package/src/freshness-runner/stamp.js +57 -0
- package/src/freshness-sources/claude-transcript-adapter.js +211 -0
- package/src/freshness-sources/codex-transcript-adapter.js +33 -0
- package/src/freshness-sources/index.js +8 -0
- package/src/gemini-byok-session.js +292 -0
- package/src/gemini-credentials.js +67 -0
- package/src/gemini-key-safety.js +246 -0
- package/src/gemini-models.js +386 -0
- package/src/gemini-session.js +81 -5
- package/src/handler-utils.js +540 -80
- package/src/handlers/checkpoint-handlers.js +47 -4
- package/src/handlers/control-room-handlers.js +51 -11
- package/src/handlers/conversation-handlers.js +469 -56
- 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 +57 -13
- package/src/handlers/folder-trust-handlers.js +90 -0
- package/src/handlers/input-handlers.js +714 -48
- package/src/handlers/orchestration-handlers.js +3 -3
- package/src/handlers/principal-admin-handlers.js +229 -0
- package/src/handlers/principal-handlers.js +262 -0
- package/src/handlers/scheduler-handlers.js +92 -18
- package/src/handlers/session-handlers.js +551 -20
- 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 +372 -50
- package/src/handlers/skills-handlers.js +20 -4
- package/src/handlers/summarize-handlers.js +32 -1
- package/src/handlers/survey-throttle.js +380 -0
- package/src/health-proof.js +40 -0
- package/src/history-page.js +112 -0
- package/src/http-routes.js +127 -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 +378 -91
- package/src/jsonl-subprocess-session.js +96 -9
- package/src/keychain.js +1 -1
- package/src/logger.js +166 -30
- package/src/mailbox-route.js +113 -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 +27 -4
- 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 +64 -23
- 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 +9 -2
- package/src/orchestration/git-ops.js +41 -7
- package/src/orchestration/orchestration-manager.js +112 -36
- package/src/orchestration/permission-gate.js +17 -2
- package/src/orchestration/run-model.js +2 -1
- package/src/orchestration/run-record.js +11 -0
- package/src/orchestration/turn-driver.js +185 -43
- package/src/orphan-reaper.js +470 -0
- package/src/outgoing-policy.js +189 -0
- package/src/pairing.js +92 -13
- package/src/path-hash-trust-ledger.js +642 -25
- package/src/permission-deadlines.js +82 -0
- package/src/permission-floor.js +1410 -43
- package/src/permission-hook.js +180 -69
- package/src/permission-manager.js +737 -89
- package/src/permission-mode-support.js +35 -0
- package/src/permission-resolved-by.js +89 -0
- package/src/permission-resolver.js +126 -8
- package/src/permission-scope.js +43 -0
- package/src/platform.js +315 -47
- package/src/preview-ingress.js +54 -0
- package/src/preview-target.js +213 -0
- package/src/principal-audit.js +189 -0
- package/src/principal-binding.js +25 -0
- package/src/principal-brakes.js +21 -0
- package/src/principal-effect.js +101 -0
- package/src/principal-journal.js +905 -0
- package/src/principal-kill-switch.js +183 -0
- package/src/principal-label.js +5 -0
- package/src/principal-pending-permissions.js +177 -0
- package/src/principal-policy.js +1094 -0
- package/src/principal-sessions-snapshot.js +208 -0
- package/src/principal-store.js +488 -0
- package/src/principal-subscriptions.js +283 -0
- package/src/prompt-evaluator.js +34 -4
- package/src/provider-customization.js +180 -0
- package/src/providers.js +209 -4
- package/src/push.js +30 -4
- package/src/question-route-map.js +130 -0
- package/src/redaction.js +531 -20
- package/src/roster-broadcast.js +186 -0
- package/src/scheduled-task-store.js +330 -26
- package/src/scheduler.js +368 -11
- package/src/sdk-session.js +2114 -188
- package/src/server-cli/preview-shutdown.js +22 -0
- package/src/server-cli/push-notification-handler.js +17 -3
- package/src/server-cli/server-orchestrator.js +28 -5
- package/src/server-cli-child.js +33 -18
- package/src/server-cli.js +553 -38
- package/src/server-identity.js +15 -11
- package/src/service.js +396 -25
- 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 +1099 -0
- package/src/session-context.js +7 -2
- package/src/session-manager.js +4062 -312
- package/src/session-message-history.js +841 -16
- package/src/session-name-allocator.js +685 -0
- 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-token-store.js +17 -8
- 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 +2 -3
- package/src/snapshots-store.js +2 -3
- package/src/statusline.js +100 -29
- package/src/summarize-session.js +53 -4
- package/src/supervisor.js +22 -11
- 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/tool-result.js +61 -0
- package/src/transcript-sources.js +109 -0
- package/src/transcript-tasks.js +372 -25
- package/src/trusted-file-read.js +302 -0
- package/src/tunnel/base.js +0 -8
- package/src/tunnel/cloudflare.js +34 -31
- package/src/tunnel/index.js +9 -0
- package/src/tunnel/preview.js +64 -0
- package/src/turn-outcome.js +140 -0
- package/src/usage-normalize.js +9 -5
- package/src/user-shell-session.js +59 -5
- package/src/utils/agent-sdk-version.js +107 -0
- package/src/utils/argv-safety.js +770 -0
- package/src/utils/auth-cause.js +60 -0
- package/src/utils/binary-package-manifest.js +639 -0
- package/src/utils/binary-version.js +224 -0
- package/src/utils/bounded-regex-worker.js +29 -0
- package/src/utils/bounded-regex.js +162 -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 +133 -37
- 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/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/pid-liveness.js +47 -0
- package/src/utils/preflight.js +360 -16
- 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 +189 -4
- package/src/utils/stale-session-dirs.js +182 -0
- package/src/utils/stat-identity.js +43 -0
- package/src/utils/verify-provenance.js +406 -13
- package/src/web-task-manager.js +297 -16
- package/src/worktree-gc.js +202 -6
- package/src/ws-auth.js +163 -31
- package/src/ws-broadcaster.js +49 -5
- package/src/ws-client-manager.js +24 -1
- package/src/ws-client-sender.js +7 -0
- package/src/ws-file-ops/browser.js +363 -58
- package/src/ws-file-ops/common.js +320 -14
- package/src/ws-file-ops/git.js +395 -42
- package/src/ws-file-ops/index.js +2 -0
- package/src/ws-file-ops/memory.js +137 -35
- package/src/ws-file-ops/open-nofollow.js +354 -0
- package/src/ws-file-ops/reader.js +571 -113
- package/src/ws-forwarding.js +349 -39
- package/src/ws-handler-context.js +88 -2
- package/src/ws-history.js +1010 -175
- package/src/ws-message-handlers.js +25 -1
- package/src/ws-permissions.js +307 -37
- package/src/ws-schemas.js +5 -0
- package/src/ws-server.js +885 -98
- package/sidecar/node_modules/.package-lock.json +0 -29
- package/sidecar/node_modules/ws/LICENSE +0 -20
- package/sidecar/node_modules/ws/README.md +0 -548
- package/sidecar/node_modules/ws/browser.js +0 -8
- package/sidecar/node_modules/ws/index.js +0 -22
- package/sidecar/node_modules/ws/lib/buffer-util.js +0 -131
- package/sidecar/node_modules/ws/lib/constants.js +0 -19
- package/sidecar/node_modules/ws/lib/event-target.js +0 -292
- package/sidecar/node_modules/ws/lib/extension.js +0 -203
- package/sidecar/node_modules/ws/lib/limiter.js +0 -55
- package/sidecar/node_modules/ws/lib/permessage-deflate.js +0 -528
- package/sidecar/node_modules/ws/lib/receiver.js +0 -706
- package/sidecar/node_modules/ws/lib/sender.js +0 -602
- package/sidecar/node_modules/ws/lib/stream.js +0 -161
- package/sidecar/node_modules/ws/lib/subprotocol.js +0 -62
- package/sidecar/node_modules/ws/lib/validation.js +0 -152
- package/sidecar/node_modules/ws/lib/websocket-server.js +0 -554
- package/sidecar/node_modules/ws/lib/websocket.js +0 -1393
- package/sidecar/node_modules/ws/package.json +0 -70
- package/sidecar/node_modules/ws/wrapper.mjs +0 -21
- 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/dashboard-next/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
package/src/config.js
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { readFileSync, existsSync, mkdirSync, copyFileSync, constants as fsConstants } from 'fs'
|
|
12
12
|
import { createHash } from 'crypto'
|
|
13
|
-
import {
|
|
14
|
-
import { homedir } from 'os'
|
|
13
|
+
import { dirname } from 'path'
|
|
15
14
|
import { writeFileRestricted } from './platform.js'
|
|
16
15
|
import { parseDuration } from './duration.js'
|
|
17
16
|
import { createLogger } from './logger.js'
|
|
@@ -19,10 +18,19 @@ import { createLogger } from './logger.js'
|
|
|
19
18
|
// deliberately a dependency-free module so importing it here never pulls
|
|
20
19
|
// the BYOK/SDK machinery into the config-load path.
|
|
21
20
|
import { validateProvidersConfigBlock } from './anthropic-compatible-config.js'
|
|
21
|
+
// #7319: pure validation helpers for `providers.acp` — same dependency-free
|
|
22
|
+
// rationale (no spawn/ACP-SDK machinery in the config-load path). Called
|
|
23
|
+
// directly here (not from validateProvidersConfigBlock) to avoid a circular
|
|
24
|
+
// import — acp-config.js already imports RESERVED_PROVIDER_IDS from
|
|
25
|
+
// anthropic-compatible-config.js.
|
|
26
|
+
import { validateAcpProviders } from './acp-config.js'
|
|
22
27
|
// #6764: default cheap model + timeout for the one-shot semantic-title call.
|
|
23
28
|
// Imported from the pure title module (no provider/SDK deps) so config load stays
|
|
24
29
|
// lightweight.
|
|
25
30
|
import { DEFAULT_SEMANTIC_TITLE_MODEL, DEFAULT_SEMANTIC_TITLE_TIMEOUT_MS } from './session-title.js'
|
|
31
|
+
import { configPath } from './config-dir.js'
|
|
32
|
+
import { SESSION_ARCHIVE_MAX_ENTRIES } from './session-archive-limits.js'
|
|
33
|
+
import { validateAgentConnections } from './agent-connections.js'
|
|
26
34
|
|
|
27
35
|
const log = createLogger('config')
|
|
28
36
|
|
|
@@ -82,6 +90,10 @@ const CONFIG_SCHEMA = {
|
|
|
82
90
|
// name an env var (`apiKeyEnv`) or a ~/.chroxy/credentials.json
|
|
83
91
|
// field (`credentialsKey`).
|
|
84
92
|
providers: 'array|object',
|
|
93
|
+
// Explicit host-scoped agent access routes. Entries contain only stable
|
|
94
|
+
// identifiers and credential references; raw credentials are rejected by
|
|
95
|
+
// the connection validator and remain in env/native/vendor stores.
|
|
96
|
+
agentConnections: 'array',
|
|
85
97
|
// #5547: optional override for the one-shot session summarizer (the sidebar
|
|
86
98
|
// "Summarize & start new session" action). `{ provider?: string, model?:
|
|
87
99
|
// string }` — when set, the summarizer uses this (typically cheaper) model
|
|
@@ -150,6 +162,10 @@ const CONFIG_SCHEMA = {
|
|
|
150
162
|
// runs with a GUI/launchd PATH that misses npm globals. Mirrored by the
|
|
151
163
|
// CHROXY_REPO_MEMORY_BIN env var.
|
|
152
164
|
controlRoomRepoMemoryBin: 'string',
|
|
165
|
+
// #8609: explicit path of the codex client the codex provider launches
|
|
166
|
+
// (instead of the first `codex` on PATH). Mirrored by CHROXY_CODEX_BIN, which
|
|
167
|
+
// is what CodexSession.resolvedBinary reads — see applyCodexBinaryConfig.
|
|
168
|
+
codexBinary: 'string',
|
|
153
169
|
maxSessions: 'number',
|
|
154
170
|
maxHistory: 'number',
|
|
155
171
|
maxMessages: 'number',
|
|
@@ -170,11 +186,43 @@ const CONFIG_SCHEMA = {
|
|
|
170
186
|
// discord-credentials.js. Documented in CONFIG.md +
|
|
171
187
|
// docs/guides/discord-notifications.md.
|
|
172
188
|
notifications: 'object',
|
|
173
|
-
// #5158: worktree garbage-collection. `{ autoReap
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
189
|
+
// #5158: worktree garbage-collection. `{ autoReap?: boolean, reapIntervalMs?:
|
|
190
|
+
// number, maxLockAgeMs?: number }` — when `autoReap` is true, the server
|
|
191
|
+
// reclaims orphaned, dead-pid-locked agent worktrees on startup and then
|
|
192
|
+
// every `reapIntervalMs` (clean trees only, never --force); `maxLockAgeMs` is
|
|
193
|
+
// the absolute-age fallback for the PID-liveness check (0 disables it).
|
|
194
|
+
// Defaults to off; the `chroxy worktree gc` CLI is always available for
|
|
195
|
+
// manual/dry-run use.
|
|
177
196
|
worktreeGc: 'object',
|
|
197
|
+
// #7606: orphaned-child reaper. `{ enabled?: boolean, sweepIntervalMs?:
|
|
198
|
+
// number, minAgeMs?: number }` — the daemon periodically SIGKILLs processes
|
|
199
|
+
// that are reparented to pid 1, owned by this uid, older than `minAgeMs`
|
|
200
|
+
// (default 10 min) and whose cwd is inside chroxy's own session-worktree
|
|
201
|
+
// root — work a dead session left behind. `enabled` defaults ON; sweeps
|
|
202
|
+
// every `sweepIntervalMs` (default 5 min). POSIX only.
|
|
203
|
+
orphanReap: 'object',
|
|
204
|
+
// Session archive: the chroxy-held history of a session that leaves the live
|
|
205
|
+
// set (closed, idle-timed-out, stale at boot, dismissed/expired failed
|
|
206
|
+
// restore) is kept as a compressed, read-only record so a Codex / Gemini /
|
|
207
|
+
// BYOK session's content is not lost. `{ enabled?: boolean, maxEntries?:
|
|
208
|
+
// number, maxAgeDays?: number, maxMegabytes?: number }` — defaults ON, 100
|
|
209
|
+
// entries, 30 days, 256 MiB; the oldest records are deleted first.
|
|
210
|
+
sessionArchive: 'object',
|
|
211
|
+
// #7424: the session CI-completion watcher. `{ watch?: boolean, wakeAgent?:
|
|
212
|
+
// boolean, intervalMs?: number, discoveryIntervalMs?: number,
|
|
213
|
+
// maxSurveysPerTick?: number, maxConsecutiveWakes?: number }` (#7436 added
|
|
214
|
+
// the per-tick cap). `watch`
|
|
215
|
+
// defaults ON — the daemon periodically surveys each session's PR through the
|
|
216
|
+
// user's own `gh` and, when a run settles, notifies (`ci_complete`) and wakes
|
|
217
|
+
// the agent with one daemon-authored line: typed into a claude-tui prompt, or
|
|
218
|
+
// delivered as a user turn (queued when busy) to a provider that declares
|
|
219
|
+
// `capabilities.daemonTurnInput` — claude-sdk included (#8301). Set
|
|
220
|
+
// `watch: false` on a host that should make no background GitHub calls;
|
|
221
|
+
// `wakeAgent: false` keeps the notification but never wakes a session.
|
|
222
|
+
// `maxConsecutiveWakes` (#8326, default 3) bounds the wake -> push -> CI ->
|
|
223
|
+
// wake loop: after that many daemon wakes with no user-typed input between,
|
|
224
|
+
// the next is refused (`wake-cap`) while the notification still goes out.
|
|
225
|
+
sessionCi: 'object',
|
|
178
226
|
sandbox: 'object',
|
|
179
227
|
// Optional allowlist of absolute directory paths that sessions may use
|
|
180
228
|
// as their working directory. When set (non-empty array), session
|
|
@@ -192,10 +240,17 @@ const CONFIG_SCHEMA = {
|
|
|
192
240
|
// config file on the dev machine (physical-access proxy for real
|
|
193
241
|
// user confirmation). Added in the 2026-04-11 audit Adversary A5 fix.
|
|
194
242
|
allowAutoPermissionMode: 'boolean',
|
|
243
|
+
// How a session created WITHOUT a name is named: 'project' (default) gives
|
|
244
|
+
// "<project> <n>" ("chroxy 7", numbers kept per project in a durable store next
|
|
245
|
+
// to session-state.json), 'legacy' keeps "Session <n>". An explicit name always
|
|
246
|
+
// wins; a project that cannot be determined, or a store that cannot be trusted,
|
|
247
|
+
// falls back to the legacy name. See resolveSessionNaming().
|
|
248
|
+
sessionNaming: 'string',
|
|
195
249
|
// #5985 (epic #5982): gate for the embedded user-shell terminal — a
|
|
196
250
|
// `user-shell` session spawns the operator's `$SHELL` (arbitrary code
|
|
197
251
|
// execution on the dev machine, reachable through the tunnel). Nested object
|
|
198
|
-
// `{ enabled
|
|
252
|
+
// `{ enabled?: boolean, requireApproval?: boolean }` (#6277 added the
|
|
253
|
+
// host-local approval gate). Defaults to undefined/false so fresh installs are
|
|
199
254
|
// secure-by-default: creating a `user-shell` session is rejected with
|
|
200
255
|
// USER_SHELL_DISABLED unless `userShell.enabled === true`. Enabling is a
|
|
201
256
|
// deliberate edit on the dev machine (physical-access proxy for confirmation),
|
|
@@ -213,7 +268,7 @@ const CONFIG_SCHEMA = {
|
|
|
213
268
|
// the 2026-04-11 audit Adversary A7 fix to close the "register any
|
|
214
269
|
// attacker-controlled image and run it" attack path.
|
|
215
270
|
allowedDockerImages: 'array',
|
|
216
|
-
// Per-session regex source string used by `
|
|
271
|
+
// Per-session regex source string used by `shouldSkipEvaluatorAsync` to extend
|
|
217
272
|
// the default continuation-pattern skip list. Wrapped in try/catch when
|
|
218
273
|
// compiled — malformed sources are logged and ignored, the default
|
|
219
274
|
// pattern still applies. Documented in CONFIG.md. Added in #3187.
|
|
@@ -506,17 +561,33 @@ function warnUnknownKeys(obj, knownSet, prefix, warnings, supportedKeys = knownS
|
|
|
506
561
|
// `workspace` sub-block (#4556); billing-budget.js + billing-canary (egressCheck
|
|
507
562
|
// / datacenterPrefixes via server-cli); worktree-reaper.js; rancher.js (the
|
|
508
563
|
// RancherBackend ctor) + resolveRancherToken (tokenEnv / tokenFile).
|
|
509
|
-
|
|
564
|
+
//
|
|
565
|
+
// #7449: these are EXPORTED solely so the doc gate
|
|
566
|
+
// (tests/config-supported-keys-docs.test.js) can compare CONFIG.md's rosters
|
|
567
|
+
// against the producer itself rather than a hand-copied expectation. Nothing
|
|
568
|
+
// in src/ imports them across module boundaries — but a re-parse of this file
|
|
569
|
+
// as text would be a second implementation of the roster, and that copy is
|
|
570
|
+
// what drifts.
|
|
571
|
+
export const K8S_SUPPORTED_KEYS = new Set([
|
|
510
572
|
'namespace', 'inCluster', 'kubeconfigPath', 'sidecarImage', 'imagePullPolicy',
|
|
511
573
|
'connectMode', 'namespaceQuota', 'namespaceLimitRange', 'workspace',
|
|
512
574
|
])
|
|
513
|
-
const BILLING_SUPPORTED_KEYS = new Set([
|
|
575
|
+
export const BILLING_SUPPORTED_KEYS = new Set([
|
|
514
576
|
'creditTier', 'monthlyCreditBudgetUsd', 'budgetWarningPercent', 'egressCheck', 'datacenterPrefixes',
|
|
515
577
|
])
|
|
516
|
-
const WORKTREE_GC_SUPPORTED_KEYS = new Set([
|
|
578
|
+
export const WORKTREE_GC_SUPPORTED_KEYS = new Set([
|
|
517
579
|
'autoReap', 'reapIntervalMs', 'maxLockAgeMs',
|
|
518
580
|
])
|
|
519
|
-
const
|
|
581
|
+
export const ORPHAN_REAP_SUPPORTED_KEYS = new Set([
|
|
582
|
+
'enabled', 'sweepIntervalMs', 'minAgeMs',
|
|
583
|
+
])
|
|
584
|
+
export const SESSION_ARCHIVE_SUPPORTED_KEYS = new Set([
|
|
585
|
+
'enabled', 'maxEntries', 'maxAgeDays', 'maxMegabytes',
|
|
586
|
+
])
|
|
587
|
+
export const SESSION_CI_SUPPORTED_KEYS = new Set([
|
|
588
|
+
'watch', 'wakeAgent', 'intervalMs', 'discoveryIntervalMs', 'maxSurveysPerTick', 'maxConsecutiveWakes',
|
|
589
|
+
])
|
|
590
|
+
export const RANCHER_SUPPORTED_KEYS = new Set([
|
|
520
591
|
'rancherUrl', 'clusterId', 'token', 'tokenEnv', 'tokenFile', 'caData', 'skipTLSVerify', 'defaultProjectId',
|
|
521
592
|
])
|
|
522
593
|
|
|
@@ -683,8 +754,8 @@ const MAX_DISCORD_COLOR = 16777215
|
|
|
683
754
|
// `{ ...config.notifications.discord }` spread into the sink) surfaces instead of
|
|
684
755
|
// silently no-op'ing / failing the sink closed. Keep in sync with the per-key
|
|
685
756
|
// validation below. The webhook URL is a SECRET (its own warning) — not a knob.
|
|
686
|
-
const DISCORD_SUPPORTED_KEYS = new Set([
|
|
687
|
-
'botName', 'billingAlerts', 'defaultColor', 'permissionColor', 'errorColor',
|
|
757
|
+
export const DISCORD_SUPPORTED_KEYS = new Set([
|
|
758
|
+
'botName', 'billingAlerts', 'ciAlerts', 'defaultColor', 'permissionColor', 'errorColor',
|
|
688
759
|
'colors', 'updateThrottleMs', 'heartbeatIntervalMs', 'pruneAfterMs',
|
|
689
760
|
// #5676 status-watchdog tunables — the sink reads these from the config spread
|
|
690
761
|
// (discord-webhook-sink.js: staleAfterMs/offlineAfterMs, default 10m/30m), so
|
|
@@ -768,7 +839,7 @@ function validateBillingBlock(billing, warnings) {
|
|
|
768
839
|
warnUnknownKeys(billing, BILLING_SUPPORTED_KEYS, 'billing', warnings)
|
|
769
840
|
}
|
|
770
841
|
|
|
771
|
-
const USER_SHELL_SUPPORTED_KEYS = new Set(['enabled', 'requireApproval'])
|
|
842
|
+
export const USER_SHELL_SUPPORTED_KEYS = new Set(['enabled', 'requireApproval'])
|
|
772
843
|
|
|
773
844
|
// #5985 (epic #5982): validate the `userShell` block. Only `enabled` (boolean)
|
|
774
845
|
// today; the security primitives (primary-token gate, audit, isolation) land in
|
|
@@ -800,6 +871,20 @@ function validateUserShellBlock(userShell, warnings) {
|
|
|
800
871
|
warnUnknownKeys(userShell, USER_SHELL_SUPPORTED_KEYS, 'userShell', warnings)
|
|
801
872
|
}
|
|
802
873
|
|
|
874
|
+
/**
|
|
875
|
+
* #8609: CodexSession.resolvedBinary is a static getter with no config handle,
|
|
876
|
+
* so the config-file `codexBinary` is published to CHROXY_CODEX_BIN once at
|
|
877
|
+
* startup. An env var already set wins (it is the same key merged by
|
|
878
|
+
* mergeConfig, so a file value only matters when the env is unset).
|
|
879
|
+
*/
|
|
880
|
+
// Needed beyond the env→config merge: that merge only reads the env, but the static
|
|
881
|
+
// resolvedBinary getter has no config handle, so a file value must be pushed to the env.
|
|
882
|
+
export function applyCodexBinaryConfig(config, env = process.env) {
|
|
883
|
+
const configured = typeof config?.codexBinary === 'string' ? config.codexBinary.trim() : ''
|
|
884
|
+
const current = typeof env.CHROXY_CODEX_BIN === 'string' ? env.CHROXY_CODEX_BIN.trim() : ''
|
|
885
|
+
if (configured && !current) env.CHROXY_CODEX_BIN = configured
|
|
886
|
+
}
|
|
887
|
+
|
|
803
888
|
// #5985: single source of truth for "may a user-shell session be created?".
|
|
804
889
|
// Fail-closed — anything other than an explicit `userShell.enabled === true` is
|
|
805
890
|
// disabled. Used by SessionManager.createSession (the authoritative gate).
|
|
@@ -846,6 +931,12 @@ export function isSchedulerEnabled(config) {
|
|
|
846
931
|
return config?.features?.scheduler === true
|
|
847
932
|
}
|
|
848
933
|
|
|
934
|
+
// Session naming mode. Anything but an explicit 'legacy' is 'project' (the default);
|
|
935
|
+
// validateConfig warns about an unrecognised value.
|
|
936
|
+
export function resolveSessionNaming(config) {
|
|
937
|
+
return config?.sessionNaming === 'legacy' ? 'legacy' : 'project'
|
|
938
|
+
}
|
|
939
|
+
|
|
849
940
|
// #6858 — resolve the opt-in provider-binary provenance PIN-LEDGER mode. One of
|
|
850
941
|
// 'off' | 'warn' | 'block'. Fail-closed to 'off' (behaviour identical to the
|
|
851
942
|
// pre-#6858 spawn path) for anything but an explicit 'warn' / 'block'. Precedence:
|
|
@@ -940,9 +1031,14 @@ export function isUserShellApprovalRequired(config) {
|
|
|
940
1031
|
}
|
|
941
1032
|
|
|
942
1033
|
// #6378: which providers may serve a model id that is NOT in their static
|
|
943
|
-
// allowlist.
|
|
944
|
-
//
|
|
945
|
-
//
|
|
1034
|
+
// allowlist. A static-allowlist subprocess provider (currently gemini and
|
|
1035
|
+
// deepseek — NOT codex since #7727, whose allowlist is the installed binary's
|
|
1036
|
+
// own model/list answer) otherwise hard-rejects an unlisted-but-API-valid
|
|
1037
|
+
// model, forcing a code release just to add one the upstream API already
|
|
1038
|
+
// exposes. This flag is keyed on the provider NAME and checked before any class
|
|
1039
|
+
// lookup, so it stays generic: the set of providers it matters for grows with
|
|
1040
|
+
// every provider that ships a compiled-in list, and the parenthetical above is
|
|
1041
|
+
// an inventory of today, not a closed roster. Opting a provider in here
|
|
946
1042
|
// makes it behave like ollama (#5418 PROVIDER_MODELS_UNRESTRICTED): the id
|
|
947
1043
|
// passes through verbatim and the upstream API becomes the validator. Returns a
|
|
948
1044
|
// Set of provider-name strings; a missing/non-array value → empty Set (the
|
|
@@ -989,6 +1085,13 @@ function validateDiscordNotificationsBlock(discord, warnings) {
|
|
|
989
1085
|
warnings.push(`Invalid value for 'notifications.discord.billingAlerts': expected a boolean, got ${JSON.stringify(discord.billingAlerts)}`)
|
|
990
1086
|
}
|
|
991
1087
|
|
|
1088
|
+
// #7428: kill-switch for the Discord CI-completion sink. Default ON when a
|
|
1089
|
+
// webhook resolves; set false to keep ci_complete notices off Discord while
|
|
1090
|
+
// the status embed / billing alerts stay on.
|
|
1091
|
+
if (Object.prototype.hasOwnProperty.call(discord, 'ciAlerts') && typeof discord.ciAlerts !== 'boolean') {
|
|
1092
|
+
warnings.push(`Invalid value for 'notifications.discord.ciAlerts': expected a boolean, got ${JSON.stringify(discord.ciAlerts)}`)
|
|
1093
|
+
}
|
|
1094
|
+
|
|
992
1095
|
const isValidColor = (v) => Number.isInteger(v) && v >= 0 && v <= MAX_DISCORD_COLOR
|
|
993
1096
|
for (const key of ['defaultColor', 'permissionColor', 'errorColor']) {
|
|
994
1097
|
if (Object.prototype.hasOwnProperty.call(discord, key) && !isValidColor(discord[key])) {
|
|
@@ -1207,6 +1310,10 @@ export function validateConfig(config, verbose = false) {
|
|
|
1207
1310
|
}
|
|
1208
1311
|
}
|
|
1209
1312
|
|
|
1313
|
+
if (typeof config.sessionNaming === 'string' && config.sessionNaming !== 'project' && config.sessionNaming !== 'legacy') {
|
|
1314
|
+
warnings.push(`Invalid value for 'sessionNaming': '${config.sessionNaming}' (expected 'project' or 'legacy'); using 'project'`)
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1210
1317
|
// Range validation for the simple numeric fields (audit P2-6) — declarative
|
|
1211
1318
|
// table + shared validateRange; the Number.isFinite guard skips fields whose
|
|
1212
1319
|
// type the loop above already flagged. Duration/cross-field/map cases below
|
|
@@ -1291,6 +1398,10 @@ export function validateConfig(config, verbose = false) {
|
|
|
1291
1398
|
}
|
|
1292
1399
|
}
|
|
1293
1400
|
|
|
1401
|
+
if (config.agentConnections !== undefined) {
|
|
1402
|
+
validateAgentConnections(config.agentConnections, warnings)
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1294
1405
|
// #4482: per-MCP-call timeout. 1s-10min. Unlike streamStallTimeoutMs,
|
|
1295
1406
|
// 0 isn't meaningful here — a 0-ms callTool timeout fires immediately
|
|
1296
1407
|
// and makes every MCP tool look broken — so any non-finite / non-
|
|
@@ -1430,6 +1541,85 @@ export function validateConfig(config, verbose = false) {
|
|
|
1430
1541
|
}
|
|
1431
1542
|
}
|
|
1432
1543
|
|
|
1544
|
+
// #7606: orphaned-child reaper block. `enabled` boolean; `sweepIntervalMs`
|
|
1545
|
+
// positive; `minAgeMs` non-negative. A bad value warns and the reaper falls
|
|
1546
|
+
// back to its built-in default for that knob (fail-safe: a typo can only
|
|
1547
|
+
// ever leave the defaults in place, never widen the predicate).
|
|
1548
|
+
if (config.orphanReap !== undefined) {
|
|
1549
|
+
if (typeof config.orphanReap !== 'object' || config.orphanReap === null || Array.isArray(config.orphanReap)) {
|
|
1550
|
+
warnings.push(`Invalid type for 'orphanReap': expected object, got ${Array.isArray(config.orphanReap) ? 'array' : typeof config.orphanReap}`)
|
|
1551
|
+
} else {
|
|
1552
|
+
if (
|
|
1553
|
+
Object.prototype.hasOwnProperty.call(config.orphanReap, 'enabled') &&
|
|
1554
|
+
typeof config.orphanReap.enabled !== 'boolean'
|
|
1555
|
+
) {
|
|
1556
|
+
warnings.push(`Invalid type for 'orphanReap.enabled': expected boolean, got ${typeof config.orphanReap.enabled}`)
|
|
1557
|
+
}
|
|
1558
|
+
if (Object.prototype.hasOwnProperty.call(config.orphanReap, 'sweepIntervalMs')) {
|
|
1559
|
+
const v = config.orphanReap.sweepIntervalMs
|
|
1560
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || v <= 0) {
|
|
1561
|
+
warnings.push(`Invalid value for 'orphanReap.sweepIntervalMs': expected a positive number, got ${typeof v === 'number' ? v : typeof v}`)
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (Object.prototype.hasOwnProperty.call(config.orphanReap, 'minAgeMs')) {
|
|
1565
|
+
const v = config.orphanReap.minAgeMs
|
|
1566
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || v < 0) {
|
|
1567
|
+
warnings.push(`Invalid value for 'orphanReap.minAgeMs': expected a non-negative number, got ${typeof v === 'number' ? v : typeof v}`)
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
warnUnknownKeys(config.orphanReap, ORPHAN_REAP_SUPPORTED_KEYS, 'orphanReap', warnings)
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// Session archive block. `enabled` boolean; `maxEntries` a positive integer;
|
|
1575
|
+
// `maxAgeDays` / `maxMegabytes` positive numbers. A bad value warns and the
|
|
1576
|
+
// archive falls back to its built-in default for that knob (SessionArchive
|
|
1577
|
+
// re-validates, so a typo can never widen retention past the defaults).
|
|
1578
|
+
if (config.sessionArchive !== undefined) {
|
|
1579
|
+
if (typeof config.sessionArchive !== 'object' || config.sessionArchive === null || Array.isArray(config.sessionArchive)) {
|
|
1580
|
+
warnings.push(`Invalid type for 'sessionArchive': expected object, got ${Array.isArray(config.sessionArchive) ? 'array' : typeof config.sessionArchive}`)
|
|
1581
|
+
} else {
|
|
1582
|
+
for (const key of SESSION_ARCHIVE_POLICY_KEYS) {
|
|
1583
|
+
if (!Object.prototype.hasOwnProperty.call(config.sessionArchive, key)) continue
|
|
1584
|
+
const problem = sessionArchiveFieldProblem(key, config.sessionArchive[key])
|
|
1585
|
+
if (!problem) continue
|
|
1586
|
+
if (problem.kind === 'type') {
|
|
1587
|
+
warnings.push(`Invalid type for 'sessionArchive.${key}': ${problem.detail}`)
|
|
1588
|
+
} else if (problem.kind === 'above_max') {
|
|
1589
|
+
warnings.push(`Invalid value for 'sessionArchive.${key}': ${config.sessionArchive[key]} is above the maximum of ${SESSION_ARCHIVE_MAX_ENTRIES} and is clamped to it`)
|
|
1590
|
+
} else {
|
|
1591
|
+
warnings.push(`Invalid value for 'sessionArchive.${key}': ${problem.detail}`)
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
warnUnknownKeys(config.sessionArchive, SESSION_ARCHIVE_SUPPORTED_KEYS, 'sessionArchive', warnings)
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// #7424: session CI-completion watcher. Every key is optional; an unset block
|
|
1599
|
+
// means "watch on, wake on, built-in intervals". The two intervals must be
|
|
1600
|
+
// positive finite numbers — a zero or negative sweep interval would spin the
|
|
1601
|
+
// event loop spawning `gh`, so a typo warns and the wiring layer falls back to
|
|
1602
|
+
// the module default rather than honouring it.
|
|
1603
|
+
if (config.sessionCi !== undefined) {
|
|
1604
|
+
if (typeof config.sessionCi !== 'object' || config.sessionCi === null || Array.isArray(config.sessionCi)) {
|
|
1605
|
+
warnings.push(`Invalid type for 'sessionCi': expected object, got ${Array.isArray(config.sessionCi) ? 'array' : typeof config.sessionCi}`)
|
|
1606
|
+
} else {
|
|
1607
|
+
for (const key of ['watch', 'wakeAgent']) {
|
|
1608
|
+
if (Object.prototype.hasOwnProperty.call(config.sessionCi, key) && typeof config.sessionCi[key] !== 'boolean') {
|
|
1609
|
+
warnings.push(`Invalid type for 'sessionCi.${key}': expected boolean, got ${typeof config.sessionCi[key]}`)
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
for (const key of ['intervalMs', 'discoveryIntervalMs', 'maxSurveysPerTick', 'maxConsecutiveWakes']) {
|
|
1613
|
+
if (!Object.prototype.hasOwnProperty.call(config.sessionCi, key)) continue
|
|
1614
|
+
const v = config.sessionCi[key]
|
|
1615
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || v <= 0) {
|
|
1616
|
+
warnings.push(`Invalid value for 'sessionCi.${key}': expected a positive number, got ${typeof v === 'number' ? v : typeof v}`)
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
warnUnknownKeys(config.sessionCi, SESSION_CI_SUPPORTED_KEYS, 'sessionCi', warnings)
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1433
1623
|
// #5413: notifications block. Only `notifications.discord` is recognised
|
|
1434
1624
|
// today. All warnings here are "Invalid value" (not "Invalid type") so a
|
|
1435
1625
|
// typo in a cosmetic color can never become a fatal startup error via the
|
|
@@ -1474,6 +1664,16 @@ export function validateConfig(config, verbose = false) {
|
|
|
1474
1664
|
!Array.isArray(config.providers)
|
|
1475
1665
|
) {
|
|
1476
1666
|
validateProvidersConfigBlock(config.providers, warnings)
|
|
1667
|
+
// #7319 — `providers.acp` (config-driven ACP agents). Validated here
|
|
1668
|
+
// rather than inside validateProvidersConfigBlock to avoid a circular
|
|
1669
|
+
// import (see the import comment above); entry-level warnings use the
|
|
1670
|
+
// same "Invalid value" wording so a malformed entry can't escalate into
|
|
1671
|
+
// a fatal startup error — bad entries are dropped at registration
|
|
1672
|
+
// (acp-session.js) and valid siblings still register.
|
|
1673
|
+
if (Object.prototype.hasOwnProperty.call(config.providers, 'acp')) {
|
|
1674
|
+
const { warnings: acpWarnings } = validateAcpProviders(config.providers.acp)
|
|
1675
|
+
warnings.push(...acpWarnings)
|
|
1676
|
+
}
|
|
1477
1677
|
}
|
|
1478
1678
|
|
|
1479
1679
|
// Validate externalUrl format if provided
|
|
@@ -1580,6 +1780,19 @@ export function mergeConfig({ fileConfig = {}, cliOverrides = {}, defaults = {},
|
|
|
1580
1780
|
|
|
1581
1781
|
/**
|
|
1582
1782
|
* Convert config key to corresponding environment variable name.
|
|
1783
|
+
*
|
|
1784
|
+
* #8151 round-2 review (nit) — was exported (S6) for doctor.js's
|
|
1785
|
+
* `resolveProviders` to read the same env-var name this file uses for a
|
|
1786
|
+
* given config key, rather than a second hand-typed copy. Round-2 Critical
|
|
1787
|
+
* 2 removed that direct read entirely — `resolveProviders` now goes
|
|
1788
|
+
* through `mergeConfig`/`resolveDaemonDefaultProvider` instead, the actual
|
|
1789
|
+
* fix for the regression that export-for-direct-reads turned out to be
|
|
1790
|
+
* (CHROXY_PROVIDERS is `config.providers`'s env var, not a provider-name
|
|
1791
|
+
* list, and a direct per-key env read couldn't tell the difference). No
|
|
1792
|
+
* remaining caller outside this file reads `envKeyForConfig` itself
|
|
1793
|
+
* (confirmed: `grep -rl` finds none), so this reverts to module-private
|
|
1794
|
+
* rather than carry a stale-justification export.
|
|
1795
|
+
*
|
|
1583
1796
|
* @param {string} key - Config key
|
|
1584
1797
|
* @returns {string} Environment variable name
|
|
1585
1798
|
*/
|
|
@@ -1625,6 +1838,8 @@ function envKeyForConfig(key) {
|
|
|
1625
1838
|
controlRoomContainersIncludeStats: 'CHROXY_CONTAINERS_INCLUDE_STATS',
|
|
1626
1839
|
// #5499: explicit repo-memory binary path for the Integrations survey.
|
|
1627
1840
|
controlRoomRepoMemoryBin: 'CHROXY_REPO_MEMORY_BIN',
|
|
1841
|
+
// #8609: codex client to launch (read by CodexSession.resolvedBinary).
|
|
1842
|
+
codexBinary: 'CHROXY_CODEX_BIN',
|
|
1628
1843
|
logFormat: 'CHROXY_LOG_FORMAT',
|
|
1629
1844
|
sandbox: 'CHROXY_SANDBOX',
|
|
1630
1845
|
resultTimeoutMs: 'CHROXY_RESULT_TIMEOUT_MS',
|
|
@@ -1921,14 +2136,80 @@ export async function buildEnvironmentBackend(config, { _execFile, _loadBackends
|
|
|
1921
2136
|
return { backend, type }
|
|
1922
2137
|
}
|
|
1923
2138
|
|
|
1924
|
-
|
|
2139
|
+
/** The four `sessionArchive` retention knobs, in display order. */
|
|
2140
|
+
export const SESSION_ARCHIVE_POLICY_KEYS = ['enabled', 'maxEntries', 'maxAgeDays', 'maxMegabytes']
|
|
2141
|
+
|
|
2142
|
+
/**
|
|
2143
|
+
* The ONE rule for a single `sessionArchive` retention value, shared by the
|
|
2144
|
+
* config validator (which warns) and the dashboard setter (which rejects).
|
|
2145
|
+
* `enabled` is a boolean; `maxEntries` a positive integer no larger than
|
|
2146
|
+
* SESSION_ARCHIVE_MAX_ENTRIES; `maxAgeDays` / `maxMegabytes` positive finite
|
|
2147
|
+
* numbers.
|
|
2148
|
+
* @returns {null | { kind: 'type'|'value'|'above_max', detail: string }}
|
|
2149
|
+
*/
|
|
2150
|
+
export function sessionArchiveFieldProblem(key, v) {
|
|
2151
|
+
const got = typeof v === 'number' ? String(v) : typeof v
|
|
2152
|
+
if (key === 'enabled') {
|
|
2153
|
+
return typeof v === 'boolean' ? null : { kind: 'type', detail: `expected boolean, got ${typeof v}` }
|
|
2154
|
+
}
|
|
2155
|
+
if (key === 'maxEntries') {
|
|
2156
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v <= 0) {
|
|
2157
|
+
return { kind: 'value', detail: `expected a positive integer, got ${got}` }
|
|
2158
|
+
}
|
|
2159
|
+
if (v > SESSION_ARCHIVE_MAX_ENTRIES) {
|
|
2160
|
+
return { kind: 'above_max', detail: `${v} is above the maximum of ${SESSION_ARCHIVE_MAX_ENTRIES}` }
|
|
2161
|
+
}
|
|
2162
|
+
return null
|
|
2163
|
+
}
|
|
2164
|
+
if (key === 'maxAgeDays' || key === 'maxMegabytes') {
|
|
2165
|
+
return typeof v === 'number' && Number.isFinite(v) && v > 0 ? null : { kind: 'value', detail: `expected a positive number, got ${got}` }
|
|
2166
|
+
}
|
|
2167
|
+
return { kind: 'value', detail: 'unknown key' }
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Validate a whole retention policy (all four fields required, exactly as the
|
|
2172
|
+
* dashboard setter sends them). Unlike config loading, an over-max
|
|
2173
|
+
* `maxEntries` is REJECTED, not clamped.
|
|
2174
|
+
* @returns {{ field: string, message: string } | null} the first problem, or null
|
|
2175
|
+
*/
|
|
2176
|
+
export function validateSessionArchivePolicy(policy) {
|
|
2177
|
+
if (!policy || typeof policy !== 'object' || Array.isArray(policy)) {
|
|
2178
|
+
return { field: 'policy', message: 'expected a retention policy object' }
|
|
2179
|
+
}
|
|
2180
|
+
for (const key of SESSION_ARCHIVE_POLICY_KEYS) {
|
|
2181
|
+
const problem = sessionArchiveFieldProblem(key, policy[key])
|
|
2182
|
+
if (problem) return { field: key, message: `sessionArchive.${key}: ${problem.detail}` }
|
|
2183
|
+
}
|
|
2184
|
+
return null
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* Persist the four session-archive retention knobs to a config file,
|
|
2189
|
+
* preserving every other field (including unknown keys inside `sessionArchive`).
|
|
2190
|
+
* Throws on an unreadable/malformed existing config (readConfigForMerge).
|
|
2191
|
+
* Does NOT validate; callers run validateSessionArchivePolicy first.
|
|
2192
|
+
*/
|
|
2193
|
+
export function writeSessionArchiveToConfig(policy, configPath = defaultConfigPath()) {
|
|
2194
|
+
const existing = readConfigForMerge(configPath)
|
|
2195
|
+
if (!existing.sessionArchive || typeof existing.sessionArchive !== 'object' || Array.isArray(existing.sessionArchive)) {
|
|
2196
|
+
existing.sessionArchive = {}
|
|
2197
|
+
}
|
|
2198
|
+
for (const key of SESSION_ARCHIVE_POLICY_KEYS) existing.sessionArchive[key] = policy[key]
|
|
2199
|
+
mkdirSync(dirname(configPath), { recursive: true })
|
|
2200
|
+
writeFileRestricted(configPath, JSON.stringify(existing, null, 2))
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
function defaultConfigPath() {
|
|
2204
|
+
return configPath('config.json')
|
|
2205
|
+
}
|
|
1925
2206
|
|
|
1926
2207
|
/**
|
|
1927
2208
|
* Read the repos array from a config file.
|
|
1928
2209
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
1929
2210
|
* @returns {Array<{ path: string, name?: string }>} Repos array, or [] if missing/invalid.
|
|
1930
2211
|
*/
|
|
1931
|
-
export function readReposFromConfig(configPath =
|
|
2212
|
+
export function readReposFromConfig(configPath = defaultConfigPath()) {
|
|
1932
2213
|
try {
|
|
1933
2214
|
if (!existsSync(configPath)) return []
|
|
1934
2215
|
const raw = JSON.parse(readFileSync(configPath, 'utf-8'))
|
|
@@ -2060,7 +2341,7 @@ function refuseMalformedConfig(configPath, reason, bytes) {
|
|
|
2060
2341
|
* @param {Array<{ path: string, name?: string }>} repos - Repos array to write.
|
|
2061
2342
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
2062
2343
|
*/
|
|
2063
|
-
export function writeReposToConfig(repos, configPath =
|
|
2344
|
+
export function writeReposToConfig(repos, configPath = defaultConfigPath()) {
|
|
2064
2345
|
const existing = readConfigForMerge(configPath)
|
|
2065
2346
|
existing.repos = repos
|
|
2066
2347
|
const dir = dirname(configPath)
|
|
@@ -2083,7 +2364,7 @@ export function writeReposToConfig(repos, configPath = DEFAULT_CONFIG_PATH) {
|
|
|
2083
2364
|
* @param {object|null} preset - The preset object ({ preamble?, seed?, enabled? }) or null to clear.
|
|
2084
2365
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
2085
2366
|
*/
|
|
2086
|
-
export function writeSessionPresetOverrideToConfig(repoPath, preset, configPath =
|
|
2367
|
+
export function writeSessionPresetOverrideToConfig(repoPath, preset, configPath = defaultConfigPath()) {
|
|
2087
2368
|
const existing = readConfigForMerge(configPath)
|
|
2088
2369
|
if (!Array.isArray(existing.repos)) existing.repos = []
|
|
2089
2370
|
|
|
@@ -2134,7 +2415,7 @@ export function writeSessionPresetOverrideToConfig(repoPath, preset, configPath
|
|
|
2134
2415
|
* @param {boolean} enabled - the new gate value.
|
|
2135
2416
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
2136
2417
|
*/
|
|
2137
|
-
export function writeSchedulerEnabledToConfig(enabled, configPath =
|
|
2418
|
+
export function writeSchedulerEnabledToConfig(enabled, configPath = defaultConfigPath()) {
|
|
2138
2419
|
const existing = readConfigForMerge(configPath)
|
|
2139
2420
|
// A non-object `features` is a single stray FIELD, not the whole config, so it
|
|
2140
2421
|
// is repaired in place rather than refused — the operator's other settings
|
|
@@ -2153,7 +2434,7 @@ export function writeSchedulerEnabledToConfig(enabled, configPath = DEFAULT_CONF
|
|
|
2153
2434
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
2154
2435
|
* @returns {string|undefined} The configured root, or undefined if missing/invalid.
|
|
2155
2436
|
*/
|
|
2156
|
-
export function readControlRoomRootFromConfig(configPath =
|
|
2437
|
+
export function readControlRoomRootFromConfig(configPath = defaultConfigPath()) {
|
|
2157
2438
|
try {
|
|
2158
2439
|
if (!existsSync(configPath)) return undefined
|
|
2159
2440
|
const raw = JSON.parse(readFileSync(configPath, 'utf-8'))
|
|
@@ -2173,11 +2454,10 @@ export function readControlRoomRootFromConfig(configPath = DEFAULT_CONFIG_PATH)
|
|
|
2173
2454
|
* @param {string} root - Absolute path to the discovery root.
|
|
2174
2455
|
* @param {string} [configPath] - Path to config.json. Defaults to ~/.chroxy/config.json.
|
|
2175
2456
|
*/
|
|
2176
|
-
export function writeControlRoomRootToConfig(root, configPath =
|
|
2457
|
+
export function writeControlRoomRootToConfig(root, configPath = defaultConfigPath()) {
|
|
2177
2458
|
const existing = readConfigForMerge(configPath)
|
|
2178
2459
|
existing.controlRoomRoot = root
|
|
2179
2460
|
const dir = dirname(configPath)
|
|
2180
2461
|
mkdirSync(dir, { recursive: true })
|
|
2181
2462
|
writeFileRestricted(configPath, JSON.stringify(existing, null, 2))
|
|
2182
2463
|
}
|
|
2183
|
-
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request authority for work that outlives the frame that asked for it.
|
|
3
|
+
*
|
|
4
|
+
* A handler (or a manager it calls) that waits — on a lock, a scan, a trust
|
|
5
|
+
* prompt, a subprocess — keeps the connection record it started with after the
|
|
6
|
+
* connection's credential has been revoked or has expired. `isAuthorized` is the
|
|
7
|
+
* ONE mechanism for carrying that authority into such deferred work: a
|
|
8
|
+
* zero-argument function, true while the requesting connection is still
|
|
9
|
+
* authenticated with a valid credential. Code that has waited calls
|
|
10
|
+
* `assertAuthorized(isAuthorized)` IMMEDIATELY before starting each mutation.
|
|
11
|
+
* Absent (internal callers, timers, tests) means "not tied to a connection".
|
|
12
|
+
*
|
|
13
|
+
* A function rather than an abort signal because expiry is time-based: a token
|
|
14
|
+
* can lapse between sweeps, with no event to abort on, and the check must see it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const AUTHORITY_REVOKED = 'CONNECTION_AUTHORITY_REVOKED'
|
|
18
|
+
|
|
19
|
+
export class AuthorityRevokedError extends Error {
|
|
20
|
+
constructor() {
|
|
21
|
+
super('The requesting connection is no longer authorized; the operation was not started')
|
|
22
|
+
this.name = 'AuthorityRevokedError'
|
|
23
|
+
this.code = AUTHORITY_REVOKED
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** True when `isAuthorized` is absent or reports the connection still authorized. */
|
|
28
|
+
export function stillAuthorized(isAuthorized) {
|
|
29
|
+
return typeof isAuthorized !== 'function' || isAuthorized() !== false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Throw AuthorityRevokedError unless the requesting connection is still authorized. */
|
|
33
|
+
export function assertAuthorized(isAuthorized) {
|
|
34
|
+
if (!stillAuthorized(isAuthorized)) throw new AuthorityRevokedError()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function isAuthorityRevoked(err) {
|
|
38
|
+
return err?.code === AUTHORITY_REVOKED
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The `isAuthorized` function for the connection behind `client`, built from the
|
|
43
|
+
* handler context. A hand-built context without the hook (tests) is never
|
|
44
|
+
* revoked; the production context always carries it (assertCtxShape).
|
|
45
|
+
*/
|
|
46
|
+
export function authorizedFor(ctx, client) {
|
|
47
|
+
return () => ctx?.transport?.isConnectionAuthorized?.(client) ?? true
|
|
48
|
+
}
|