@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 0.1.4-dev.0098fdb4e213
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/README.md +232 -5
- package/dist/bridge/bridge-chat-provider-command.d.ts +19 -0
- package/dist/bridge/bridge-chat-provider-command.js +132 -0
- package/dist/bridge/bridge-chat.types.d.ts +121 -0
- package/dist/bridge/bridge-chat.types.js +416 -0
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +11 -0
- package/dist/bridge/bridge-state-io.js +50 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +13 -1
- package/dist/bridge/bridge.service.d.ts +169 -14
- package/dist/bridge/bridge.service.js +1868 -330
- package/dist/bridge/bridge.types.d.ts +73 -1
- package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
- package/dist/bridge/dispatch-result-outbox.js +87 -0
- package/dist/bridge/dispatch-result-worker.d.ts +2 -0
- package/dist/bridge/dispatch-result-worker.js +122 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/internals.d.ts +2 -0
- package/dist/bridge/internals.js +1 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +25 -0
- package/dist/bridge/readiness-result-outbox.js +74 -0
- package/dist/bridge/readiness-result-worker.d.ts +2 -0
- package/dist/bridge/readiness-result-worker.js +121 -0
- package/dist/bridge/runner-host-capabilities.d.ts +20 -0
- package/dist/bridge/runner-host-capabilities.js +110 -0
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +21 -1
- package/dist/cleanup/cleanup.service.js +185 -143
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +78 -16
- package/dist/cli/cli.service.d.ts +32 -15
- package/dist/cli/cli.service.js +206 -182
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +7 -0
- package/dist/cli/local-config.js +36 -4
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +41 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +474 -0
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
- package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
- package/dist/runtime/attempt-path-operation.d.ts +21 -0
- package/dist/runtime/attempt-path-operation.js +94 -0
- package/dist/runtime/attempt-private-directory.d.ts +6 -0
- package/dist/runtime/attempt-private-directory.js +54 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
- package/dist/runtime/attempt-process-supervisor.js +144 -23
- package/dist/runtime/canonical-source-file.d.ts +3 -0
- package/dist/runtime/canonical-source-file.js +54 -0
- package/dist/runtime/docker-engine-probe.d.ts +95 -0
- package/dist/runtime/docker-engine-probe.js +340 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/generated-output-reset.d.ts +10 -0
- package/dist/runtime/generated-output-reset.js +62 -8
- package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
- package/dist/runtime/host-database-capability-boundary.js +63 -0
- package/dist/runtime/host-diagnostics.d.ts +11 -0
- package/dist/runtime/host-diagnostics.js +192 -0
- package/dist/runtime/host-execution-root.d.ts +4 -0
- package/dist/runtime/host-execution-root.js +39 -0
- package/dist/runtime/host-facts.d.ts +36 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-listener-inspector.d.ts +8 -1
- package/dist/runtime/host-listener-inspector.js +121 -60
- package/dist/runtime/host-load-admission.d.ts +67 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +52 -0
- package/dist/runtime/host-load-governor-config.js +83 -0
- package/dist/runtime/host-load-governor.d.ts +186 -0
- package/dist/runtime/host-load-governor.js +632 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +156 -0
- package/dist/runtime/host-load-sampler.js +298 -0
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +28 -1
- package/dist/runtime/host-runtime-contract.js +203 -57
- package/dist/runtime/host-runtime-lease.d.ts +163 -9
- package/dist/runtime/host-runtime-lease.js +1427 -124
- package/dist/runtime/host-runtime-promotion.d.ts +35 -3
- package/dist/runtime/host-runtime-promotion.js +107 -12
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +596 -0
- package/dist/runtime/memory-capacity.d.ts +70 -0
- package/dist/runtime/memory-capacity.js +123 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +69 -0
- package/dist/runtime/native-test-postgres-fallback.js +143 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
- package/dist/runtime/node-host-runtime-adapter.js +29 -11
- package/dist/runtime/pinned-directory-process.d.ts +9 -0
- package/dist/runtime/pinned-directory-process.js +61 -0
- package/dist/runtime/pinned-source-directory.d.ts +17 -0
- package/dist/runtime/pinned-source-directory.js +94 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
- package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
- package/dist/runtime/prepared-runtime-identity.js +218 -0
- package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
- package/dist/runtime/prepared-runtime-readiness.js +285 -0
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/runtime-isolation-lease.js +4 -1
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +36 -0
- package/dist/sandbox/preflight.d.ts +31 -1
- package/dist/sandbox/preflight.js +237 -51
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/repository-lock.d.ts +2 -1
- package/dist/sandbox/repository-lock.js +19 -9
- package/dist/sandbox/runtime.d.ts +16 -2
- package/dist/sandbox/runtime.js +183 -114
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox.types.d.ts +7 -0
- package/dist/sandbox/workspace.service.js +2 -0
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +37 -1
- package/dist/session/managed-attempt-tools.js +822 -84
- package/dist/session/managed-build-coordinator.d.ts +5 -0
- package/dist/session/managed-build-coordinator.js +109 -0
- package/dist/session/managed-build-receipt.d.ts +26 -0
- package/dist/session/managed-build-receipt.js +342 -0
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -0
- package/dist/session/managed-verification-timeouts.d.ts +8 -0
- package/dist/session/managed-verification-timeouts.js +17 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +24 -0
- package/dist/session/phase-completion.artifacts.js +321 -45
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +23 -1
- package/dist/session/phase-completion.helpers.d.ts +5 -0
- package/dist/session/phase-completion.helpers.js +43 -19
- package/dist/session/phase-completion.js +19 -3
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +22 -18
- package/dist/session/phase-completion.runtime.d.ts +6 -10
- package/dist/session/phase-completion.runtime.js +214 -224
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +250 -226
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +135 -89
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +91 -0
- package/dist/session/pre-publication-validation.js +670 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +34 -2
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +85 -19
- package/dist/session/provider-cli/provider-cli.process.js +566 -283
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +211 -36
- package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +22 -1
- package/dist/session/provider-cli/provider-cli.runtime.js +83 -4
- package/dist/session/provider-cli/provider-cli.service.d.ts +36 -5
- package/dist/session/provider-cli/provider-cli.service.js +818 -99
- package/dist/session/provider-cli/provider-cli.types.d.ts +32 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +18 -0
- package/dist/session/provider-cli/provider-output-state.js +376 -17
- package/dist/session/provider-cli/provider-usage.d.ts +9 -1
- package/dist/session/provider-cli/provider-usage.js +28 -5
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +257 -0
- package/dist/session/session-redaction.js +284 -9
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +11 -2
- package/dist/session/session.service.js +301 -58
- package/dist/session/session.types.d.ts +150 -2
- package/dist/session/session.types.js +599 -7
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/unreferenced-exports.d.ts +12 -0
- package/dist/session/unreferenced-exports.js +59 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/format/format-bytes.d.ts +1 -0
- package/dist/shared/format/format-bytes.js +9 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/git/git.js +2 -1
- package/dist/shared/path/path.d.ts +1 -0
- package/dist/shared/path/path.js +18 -0
- package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
- package/dist/shared/process/dotnet-toolchain.js +307 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +26 -5
- package/dist/shared/process/host-process-supervisor.d.ts +16 -1
- package/dist/shared/process/host-process-supervisor.js +124 -23
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +69 -0
- package/dist/shared/process/process.js +223 -16
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.d.ts +3 -0
- package/dist/shared/provider-capabilities.js +92 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +39 -3
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +66 -9
- package/dist/worktree/dependency-warmer.js +609 -24
- package/dist/worktree/index.d.ts +1 -1
- package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
- package/dist/worktree/story-qa-reference-hydrator.js +253 -0
- package/dist/worktree/wip-git.d.ts +33 -0
- package/dist/worktree/wip-git.js +122 -0
- package/dist/worktree/wip-refs.d.ts +62 -0
- package/dist/worktree/wip-refs.js +119 -0
- package/dist/worktree/wip-restore.d.ts +38 -0
- package/dist/worktree/wip-restore.js +190 -0
- package/dist/worktree/wip-snapshot.d.ts +50 -0
- package/dist/worktree/wip-snapshot.js +268 -0
- package/dist/worktree/worktree-wip-events.d.ts +18 -0
- package/dist/worktree/worktree-wip-events.js +98 -0
- package/dist/worktree/worktree-wip.d.ts +49 -0
- package/dist/worktree/worktree-wip.js +182 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +22 -2
- package/dist/worktree/worktree.service.js +302 -25
- package/dist/worktree/worktree.types.d.ts +36 -1
- package/package.json +8 -6
- package/runtime/windows-job-supervisor.ps1 +380 -14
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { evaluateBridgeIdle, formatAge, isProcessAlive, readBridgeStateFile, } from "../bridge/bridge-state-file.js";
|
|
2
|
+
import { describeInFlightIds } from "../bridge/in-flight-registry.js";
|
|
3
|
+
import { readLocalYieldFlag } from "../bridge/local-yield-flag.js";
|
|
4
|
+
import { resolveBridgeStatePath, resolveLocalYieldFlagPath } from "./local-config.js";
|
|
5
|
+
const statusUsage = "Usage: forge-bridge status [--check-updates] | forge-bridge status --idle [--require-yield] [--json] [--wait <seconds>]";
|
|
6
|
+
export function parseStatusArgs(argv, config) {
|
|
7
|
+
// --wait is tracked apart from its value: `--wait 0` without --idle is the same usage error as `--wait 5`.
|
|
8
|
+
const flags = { checkUpdates: false, idle: false, json: false, requireYield: false, waitSeconds: null };
|
|
9
|
+
const switches = {
|
|
10
|
+
"--check-updates": "checkUpdates", "--idle": "idle", "--json": "json", "--require-yield": "requireYield",
|
|
11
|
+
};
|
|
12
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
13
|
+
const arg = argv[index];
|
|
14
|
+
if (Object.hasOwn(switches, arg)) {
|
|
15
|
+
flags[switches[arg]] = true;
|
|
16
|
+
}
|
|
17
|
+
else if (arg === "--wait") {
|
|
18
|
+
const seconds = Number(argv[++index]);
|
|
19
|
+
if (!Number.isFinite(seconds) || seconds < 0)
|
|
20
|
+
return { ok: false, error: "--wait requires a number of seconds (0 or more)." };
|
|
21
|
+
flags.waitSeconds = seconds;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return { ok: false, error: `Unknown argument: ${arg}\n${statusUsage}` };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!flags.idle && (flags.json || flags.requireYield || flags.waitSeconds !== null)) {
|
|
28
|
+
return { ok: false, error: `--json, --require-yield and --wait apply to --idle.\n${statusUsage}` };
|
|
29
|
+
}
|
|
30
|
+
if (flags.idle && flags.checkUpdates) {
|
|
31
|
+
return { ok: false, error: `--check-updates cannot be combined with --idle.\n${statusUsage}` };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
ok: true,
|
|
35
|
+
command: "status",
|
|
36
|
+
config: config(),
|
|
37
|
+
checkUpdates: flags.checkUpdates,
|
|
38
|
+
idle: flags.idle ? { json: flags.json, waitSeconds: flags.waitSeconds ?? 0, requireYield: flags.requireYield } : null,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function defaultIdleStatusDependencies() {
|
|
42
|
+
return {
|
|
43
|
+
statePath: resolveBridgeStatePath(),
|
|
44
|
+
now: () => Date.now(),
|
|
45
|
+
pidAlive: isProcessAlive,
|
|
46
|
+
read: readBridgeStateFile,
|
|
47
|
+
localYield: () => readLocalYieldFlag(resolveLocalYieldFlagPath()),
|
|
48
|
+
sleep: ms => new Promise(resolve => setTimeout(resolve, ms)),
|
|
49
|
+
pollMs: 2_000,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export async function runIdleStatusCommand(options, io, deps = defaultIdleStatusDependencies()) {
|
|
53
|
+
const check = async () => evaluateBridgeIdle(await deps.read(deps.statePath), {
|
|
54
|
+
now: deps.now(),
|
|
55
|
+
pidAlive: deps.pidAlive,
|
|
56
|
+
requireYield: options.requireYield,
|
|
57
|
+
});
|
|
58
|
+
let evaluation = await check();
|
|
59
|
+
const deadline = deps.now() + options.waitSeconds * 1000;
|
|
60
|
+
if (worthWaiting(evaluation) && deps.now() < deadline && !options.json) {
|
|
61
|
+
io.stderr.write(`Waiting up to ${options.waitSeconds}s for the bridge to become idle (${evaluation.verdict})...\n`);
|
|
62
|
+
}
|
|
63
|
+
while (worthWaiting(evaluation) && deps.now() < deadline) {
|
|
64
|
+
await deps.sleep(Math.max(1, Math.min(deps.pollMs, deadline - deps.now())));
|
|
65
|
+
evaluation = await check();
|
|
66
|
+
}
|
|
67
|
+
const localYield = await deps.localYield().catch(() => false);
|
|
68
|
+
if (options.json) {
|
|
69
|
+
io.stdout.write(`${JSON.stringify(idleStatusJson(evaluation, deps, localYield), null, 2)}\n`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
io.stdout.write(idleStatusText(evaluation, deps, localYield));
|
|
73
|
+
}
|
|
74
|
+
return evaluation.exitCode;
|
|
75
|
+
}
|
|
76
|
+
/** One line for plain `forge-bridge status`. */
|
|
77
|
+
export async function idleSummaryLine(deps = defaultIdleStatusDependencies()) {
|
|
78
|
+
const evaluation = evaluateBridgeIdle(await deps.read(deps.statePath), { now: deps.now(), pidAlive: deps.pidAlive });
|
|
79
|
+
return `${verdictTitles[evaluation.verdict]}: ${evaluation.reason} Details: forge-bridge status --idle`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Busy work finishes, yield reaches Forge within a heartbeat, a stale heartbeat can recover and an
|
|
83
|
+
* unreadable or missing file can be a reader holding it (antivirus, the indexer) or a bridge
|
|
84
|
+
* starting. Only a dead bridge process will not change by waiting.
|
|
85
|
+
*/
|
|
86
|
+
function worthWaiting(evaluation) {
|
|
87
|
+
return evaluation.verdict !== "idle" && evaluation.verdict !== "not_running";
|
|
88
|
+
}
|
|
89
|
+
export function idleStatusJson(evaluation, deps, localYield) {
|
|
90
|
+
return {
|
|
91
|
+
schemaVersion: 1,
|
|
92
|
+
verdict: evaluation.verdict,
|
|
93
|
+
idle: evaluation.verdict === "idle",
|
|
94
|
+
exitCode: evaluation.exitCode,
|
|
95
|
+
reason: evaluation.reason,
|
|
96
|
+
statePath: deps.statePath,
|
|
97
|
+
checkedAt: new Date(deps.now()).toISOString(),
|
|
98
|
+
pidAlive: evaluation.pidAlive,
|
|
99
|
+
heartbeatAgeMs: evaluation.heartbeatAgeMs,
|
|
100
|
+
staleAfterMs: evaluation.staleAfterMs,
|
|
101
|
+
localYield,
|
|
102
|
+
...publishedStateFields(evaluation.state),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function publishedStateFields(state) {
|
|
106
|
+
if (!state) {
|
|
107
|
+
return {
|
|
108
|
+
pid: null, runnerId: null, runnerInstanceId: null, version: null, state: null, startedAt: null,
|
|
109
|
+
updatedAt: null, connected: null, yielding: null, yieldApplied: null, conflict: null, inFlight: [],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
pid: state.pid,
|
|
114
|
+
runnerId: state.runnerId,
|
|
115
|
+
runnerInstanceId: state.runnerInstanceId,
|
|
116
|
+
version: state.version,
|
|
117
|
+
state: state.state,
|
|
118
|
+
startedAt: state.startedAt,
|
|
119
|
+
updatedAt: state.updatedAt,
|
|
120
|
+
connected: state.connected,
|
|
121
|
+
yielding: state.yielding,
|
|
122
|
+
yieldApplied: state.yieldApplied ?? state.yielding,
|
|
123
|
+
conflict: state.conflict ?? null,
|
|
124
|
+
inFlight: state.inFlight,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const verdictTitles = {
|
|
128
|
+
idle: "Bridge idle",
|
|
129
|
+
busy: "Bridge busy",
|
|
130
|
+
not_yielding: "Bridge idle but not yielding",
|
|
131
|
+
stale: "Bridge state stale",
|
|
132
|
+
unknown: "Bridge state unknown",
|
|
133
|
+
not_running: "Bridge not running",
|
|
134
|
+
};
|
|
135
|
+
function idleStatusText(evaluation, deps, localYield) {
|
|
136
|
+
const state = evaluation.state;
|
|
137
|
+
const lines = [`${verdictTitles[evaluation.verdict]}: ${evaluation.reason}`, `State file: ${deps.statePath}`];
|
|
138
|
+
if (state) {
|
|
139
|
+
lines.push(`Process: pid ${state.pid} (${evaluation.pidAlive ? "running" : "not running"}), runner ${state.runnerId || "unknown"}, instance ${state.runnerInstanceId}, bridge ${state.version}`, `Heartbeat: ${state.updatedAt} (${formatAge(evaluation.heartbeatAgeMs ?? Number.NaN)} ago, stale after ${formatAge(evaluation.staleAfterMs)}); connected to Forge: ${state.connected ? "yes" : "no"}`, `Yield: ${yieldLine(state)} (local flag ${localYield ? "on" : "off"})`);
|
|
140
|
+
lines.push(...inFlightLines(state.inFlight, deps.now()));
|
|
141
|
+
}
|
|
142
|
+
lines.push(nextStep(evaluation, localYield));
|
|
143
|
+
return `${lines.join("\n")}\n`;
|
|
144
|
+
}
|
|
145
|
+
function inFlightLines(entries, now) {
|
|
146
|
+
if (entries.length === 0)
|
|
147
|
+
return ["In flight: nothing"];
|
|
148
|
+
return ["In flight:", ...entries.map(entry => {
|
|
149
|
+
const phaseAge = entry.phaseSince ? ` for ${formatAge(now - Date.parse(entry.phaseSince))}` : "";
|
|
150
|
+
const since = entry.since ? `, since ${entry.since}` : "";
|
|
151
|
+
return ` - ${entry.kind}: phase ${entry.phase}${phaseAge}${since}; ${describeInFlightIds(entry.ids)}`;
|
|
152
|
+
})];
|
|
153
|
+
}
|
|
154
|
+
function nextStep(evaluation, localYield) {
|
|
155
|
+
switch (evaluation.verdict) {
|
|
156
|
+
case "idle":
|
|
157
|
+
return evaluation.state?.yielding ? "Safe to restart now. After the new bridge connects, run `forge-bridge yield off` so it takes work again." : idleWithoutYieldStep(localYield);
|
|
158
|
+
case "not_yielding":
|
|
159
|
+
return evaluation.state?.yieldApplied
|
|
160
|
+
? "The bridge applies yield but Forge has not acknowledged it yet (at most one heartbeat). Check again before restarting."
|
|
161
|
+
: idleWithoutYieldStep(localYield);
|
|
162
|
+
case "busy":
|
|
163
|
+
return "Do not restart. Run `forge-bridge yield on`, then `forge-bridge status --idle --require-yield --wait <seconds>` until it exits 0.";
|
|
164
|
+
case "not_running":
|
|
165
|
+
return "Nothing to interrupt, but confirm no other bridge process serves this runner before starting one.";
|
|
166
|
+
default:
|
|
167
|
+
return "Do not restart on this result: idle could not be confirmed.";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function yieldLine(state) {
|
|
171
|
+
if (state.yielding)
|
|
172
|
+
return "on and acknowledged by Forge, no new attempts";
|
|
173
|
+
return state.yieldApplied ? "applied, waiting for Forge to acknowledge it" : "off, Forge can still send new work";
|
|
174
|
+
}
|
|
175
|
+
// The bridge's own report is what counts: a flag written from another environment
|
|
176
|
+
// (another user, FORGE_BRIDGE_CONFIG, or a sandbox that virtualizes %APPDATA%) never reaches it.
|
|
177
|
+
function idleWithoutYieldStep(localYield) {
|
|
178
|
+
return localYield
|
|
179
|
+
? "The local yield flag is on but the bridge has not reported yield yet. It picks the flag up within one heartbeat; if it never does, this flag file is not the one the bridge reads. Check again before restarting."
|
|
180
|
+
: "Idle now, but yield is off: run `forge-bridge yield on` and check again with --require-yield so no new work starts before the restart.";
|
|
181
|
+
}
|
|
@@ -8,6 +8,7 @@ export interface BridgeLocalConfig {
|
|
|
8
8
|
readonly defaultRepoRoot?: string;
|
|
9
9
|
readonly cleanupWorktrees?: boolean;
|
|
10
10
|
readonly dockerEnabled?: boolean;
|
|
11
|
+
readonly dockerDesktopRecoveryEnabled?: boolean;
|
|
11
12
|
readonly allowOpenPublicSandbox?: boolean;
|
|
12
13
|
readonly cliProviders?: readonly string[];
|
|
13
14
|
readonly providerStatuses?: Readonly<Record<string, BridgeProviderStatus>>;
|
|
@@ -29,8 +30,14 @@ export interface LocalRepoMapping extends BridgeRepoMapping {
|
|
|
29
30
|
export declare function resolveLocalConfigPath(): string;
|
|
30
31
|
export declare function readLocalConfig(): Promise<BridgeLocalConfig>;
|
|
31
32
|
export declare function readLocalConfigSync(): BridgeLocalConfig;
|
|
33
|
+
/** Decision 0014 §5: `bridge.json` holds the device token, so only its owner may read it. */
|
|
34
|
+
export declare const localConfigFileMode = 384;
|
|
32
35
|
export declare function writeLocalConfig(config: BridgeLocalConfig): Promise<void>;
|
|
33
36
|
export declare function applyLocalConfigDefaults(config: BridgeServiceConfig, local: BridgeLocalConfig): BridgeServiceConfig;
|
|
37
|
+
/** Where `forge-bridge connect` publishes whether it is idle: `bridge.state.json` beside the config. */
|
|
38
|
+
export declare function resolveBridgeStatePath(): string;
|
|
39
|
+
/** Decision 0014: the `forge-bridge yield` flag, beside the bridge config and never inside it. */
|
|
40
|
+
export declare function resolveLocalYieldFlagPath(): string;
|
|
34
41
|
export declare function addRepoMapping(label: string, repoPath: string): Promise<BridgeLocalConfig>;
|
|
35
42
|
export declare function removeRepoMapping(label: string): Promise<{
|
|
36
43
|
readonly config: BridgeLocalConfig;
|
package/dist/cli/local-config.js
CHANGED
|
@@ -2,6 +2,8 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import fsSync from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { localYieldFlagPathFor } from "../bridge/local-yield-flag.js";
|
|
6
|
+
import { bridgeStatePathFor } from "../bridge/bridge-state-file.js";
|
|
5
7
|
export function resolveLocalConfigPath() {
|
|
6
8
|
if (process.env.FORGE_BRIDGE_CONFIG?.trim()) {
|
|
7
9
|
return path.resolve(process.env.FORGE_BRIDGE_CONFIG);
|
|
@@ -28,12 +30,28 @@ export function readLocalConfigSync() {
|
|
|
28
30
|
}
|
|
29
31
|
return parseLocalConfig(fsSync.readFileSync(configPath, "utf8"));
|
|
30
32
|
}
|
|
33
|
+
/** Decision 0014 §5: `bridge.json` holds the device token, so only its owner may read it. */
|
|
34
|
+
export const localConfigFileMode = 0o600;
|
|
35
|
+
const localConfigDirectoryMode = 0o700;
|
|
31
36
|
export async function writeLocalConfig(config) {
|
|
32
37
|
const configPath = resolveLocalConfigPath();
|
|
33
|
-
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
38
|
+
await fs.mkdir(path.dirname(configPath), { recursive: true, mode: localConfigDirectoryMode });
|
|
34
39
|
const tempPath = `${configPath}.${process.pid}.${Date.now()}.tmp`;
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
try {
|
|
41
|
+
await fs.writeFile(tempPath, `${JSON.stringify(normalizeLocalConfig(config), null, 2)}\n`, {
|
|
42
|
+
encoding: "utf8",
|
|
43
|
+
mode: localConfigFileMode
|
|
44
|
+
});
|
|
45
|
+
if (process.platform !== "win32") {
|
|
46
|
+
// The create mode is masked by the umask; set it exactly before the file becomes visible.
|
|
47
|
+
await fs.chmod(tempPath, localConfigFileMode);
|
|
48
|
+
}
|
|
49
|
+
await fs.rename(tempPath, configPath);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
await fs.rm(tempPath, { force: true }).catch(() => undefined);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
37
55
|
}
|
|
38
56
|
export function applyLocalConfigDefaults(config, local) {
|
|
39
57
|
const cliProviders = local.cliProviders && local.cliProviders.length > 0 ? [...local.cliProviders] : config.cliProviders;
|
|
@@ -48,6 +66,9 @@ export function applyLocalConfigDefaults(config, local) {
|
|
|
48
66
|
dockerEnabled: process.env.FORGE_DOCKER_SANDBOX === undefined
|
|
49
67
|
? local.dockerEnabled ?? config.dockerEnabled
|
|
50
68
|
: config.dockerEnabled,
|
|
69
|
+
dockerDesktopRecoveryEnabled: process.env.FORGE_DOCKER_DESKTOP_AUTO_RECOVERY === undefined
|
|
70
|
+
? local.dockerDesktopRecoveryEnabled ?? config.dockerDesktopRecoveryEnabled
|
|
71
|
+
: config.dockerDesktopRecoveryEnabled,
|
|
51
72
|
allowOpenPublicSandbox: process.env.FORGE_ALLOW_OPEN_PUBLIC_SANDBOX === undefined
|
|
52
73
|
? local.allowOpenPublicSandbox ?? config.allowOpenPublicSandbox
|
|
53
74
|
: config.allowOpenPublicSandbox,
|
|
@@ -62,9 +83,19 @@ export function applyLocalConfigDefaults(config, local) {
|
|
|
62
83
|
supportsRunnerAuthoredPhaseArtifacts: local.supportsRunnerAuthoredPhaseArtifacts ?? config.supportsRunnerAuthoredPhaseArtifacts,
|
|
63
84
|
supportsDraftRunOnce: local.supportsDraftRunOnce ?? config.supportsDraftRunOnce,
|
|
64
85
|
supportsDraftAttachments: local.supportsDraftAttachments ?? config.supportsDraftAttachments,
|
|
65
|
-
supportsDraftImageAttachments: local.supportsDraftImageAttachments ?? config.supportsDraftImageAttachments
|
|
86
|
+
supportsDraftImageAttachments: local.supportsDraftImageAttachments ?? config.supportsDraftImageAttachments,
|
|
87
|
+
localYieldFlagPath: resolveLocalYieldFlagPath(),
|
|
88
|
+
bridgeStatePath: resolveBridgeStatePath()
|
|
66
89
|
};
|
|
67
90
|
}
|
|
91
|
+
/** Where `forge-bridge connect` publishes whether it is idle: `bridge.state.json` beside the config. */
|
|
92
|
+
export function resolveBridgeStatePath() {
|
|
93
|
+
return bridgeStatePathFor(resolveLocalConfigPath());
|
|
94
|
+
}
|
|
95
|
+
/** Decision 0014: the `forge-bridge yield` flag, beside the bridge config and never inside it. */
|
|
96
|
+
export function resolveLocalYieldFlagPath() {
|
|
97
|
+
return localYieldFlagPathFor(resolveLocalConfigPath());
|
|
98
|
+
}
|
|
68
99
|
export async function addRepoMapping(label, repoPath) {
|
|
69
100
|
const normalizedLabel = normalizeLabel(label);
|
|
70
101
|
const localPath = path.resolve(repoPath);
|
|
@@ -126,6 +157,7 @@ function normalizeLocalConfig(config) {
|
|
|
126
157
|
defaultRepoRoot: cleanString(config.defaultRepoRoot),
|
|
127
158
|
cleanupWorktrees: config.cleanupWorktrees,
|
|
128
159
|
dockerEnabled: config.dockerEnabled,
|
|
160
|
+
dockerDesktopRecoveryEnabled: config.dockerDesktopRecoveryEnabled,
|
|
129
161
|
allowOpenPublicSandbox: config.allowOpenPublicSandbox,
|
|
130
162
|
cliProviders: cleanList(config.cliProviders),
|
|
131
163
|
providerStatuses: normalizeProviderStatuses(config.providerStatuses),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface CliProviderDetection {
|
|
2
|
+
readonly provider: string;
|
|
3
|
+
readonly found: boolean;
|
|
4
|
+
readonly version: string;
|
|
5
|
+
readonly models: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function detectCliProviders(providers: readonly string[]): Promise<CliProviderDetection[]>;
|
|
8
|
+
export declare const claudeDefaultModels: readonly string[];
|
|
9
|
+
export declare function parseCodexModelCatalog(raw: string): string[];
|
|
10
|
+
export declare function parseCursorModelList(raw: string): string[];
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { resolveCursorAgentDirectLaunch } from "../shared/cursor-agent/cursor-agent.launch.js";
|
|
4
|
+
import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
|
|
5
|
+
// Provider CLI detection probes for `forge-bridge status`, `connect` and `pair`: which
|
|
6
|
+
// provider CLIs are installed, their versions and the models they list. Split out of
|
|
7
|
+
// cli.service.ts (file-size inventory plan).
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
export async function detectCliProviders(providers) {
|
|
10
|
+
const results = [];
|
|
11
|
+
for (const provider of providers) {
|
|
12
|
+
let detected = null;
|
|
13
|
+
for (const probe of cliProbeCommandsFor(provider)) {
|
|
14
|
+
try {
|
|
15
|
+
detected = await execVersionCommand(probe, probe.timeoutMs);
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Try the next provider-specific probe.
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
results.push({
|
|
23
|
+
provider,
|
|
24
|
+
found: detected !== null,
|
|
25
|
+
version: detected ? versionLine(`${detected.stdout || detected.stderr}`) : "",
|
|
26
|
+
models: detected ? await detectCliModels(provider) : []
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return results;
|
|
30
|
+
}
|
|
31
|
+
function cliProbeCommandsFor(provider) {
|
|
32
|
+
const normalized = provider.toLowerCase();
|
|
33
|
+
if (normalized === "codex") {
|
|
34
|
+
return [
|
|
35
|
+
{ command: "codex", args: ["-V"] },
|
|
36
|
+
{ command: "codex", args: ["--version"] }
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
if (normalized === "claude") {
|
|
40
|
+
return [
|
|
41
|
+
// Claude Code's Node startup can exceed the default 2s probe on a cold Windows host.
|
|
42
|
+
{ command: "claude", args: ["--version"], timeoutMs: 8000 },
|
|
43
|
+
{ command: "claude", args: ["-v"], timeoutMs: 8000 }
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
if (normalized === "cursor") {
|
|
47
|
+
return [
|
|
48
|
+
{ command: "cursor-agent", args: ["-v"] },
|
|
49
|
+
{ command: "agent", args: ["-v"] },
|
|
50
|
+
{ command: "cursor-agent", args: ["--version"] },
|
|
51
|
+
{ command: "agent", args: ["--version"] }
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
{ command: provider, args: ["--version"] },
|
|
56
|
+
{ command: provider, args: ["-V"] }
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
async function execVersionCommand(probe, timeout = 2000, maxBuffer) {
|
|
60
|
+
const directLaunch = process.platform === "win32"
|
|
61
|
+
? await resolveCursorAgentDirectLaunch(probe.command, probe.args)
|
|
62
|
+
: null;
|
|
63
|
+
if (directLaunch) {
|
|
64
|
+
return await execFileAsync(directLaunch.command, [...directLaunch.args], { timeout, maxBuffer });
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return await execFileAsync(probe.command, probe.args, { timeout, maxBuffer });
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (process.platform !== "win32") {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
const launch = buildWindowsCmdLaunch(probe.command, probe.args);
|
|
74
|
+
return await execFileAsync(launch.command, [...launch.args], { timeout, maxBuffer });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function versionLine(output) {
|
|
78
|
+
const lines = output
|
|
79
|
+
.trim()
|
|
80
|
+
.split(/\r?\n/)
|
|
81
|
+
.map((line) => line.trim())
|
|
82
|
+
.filter((line) => line.length > 0);
|
|
83
|
+
return lines.at(-1) ?? "";
|
|
84
|
+
}
|
|
85
|
+
async function detectCliModels(provider) {
|
|
86
|
+
const normalized = provider.toLowerCase();
|
|
87
|
+
try {
|
|
88
|
+
if (normalized === "codex") {
|
|
89
|
+
// Windows installs codex as a .cmd shim, which execFile cannot launch directly.
|
|
90
|
+
const result = await execVersionCommand({ command: "codex", args: ["debug", "models"] }, 10_000, 10 * 1024 * 1024);
|
|
91
|
+
return parseCodexModelCatalog(result.stdout);
|
|
92
|
+
}
|
|
93
|
+
if (normalized === "cursor") {
|
|
94
|
+
const result = await execVersionCommand({ command: "cursor-agent", args: ["models"] }, 10_000);
|
|
95
|
+
return parseCursorModelList(`${result.stdout || result.stderr}`);
|
|
96
|
+
}
|
|
97
|
+
if (normalized === "claude") {
|
|
98
|
+
// Claude Code has no model-listing command; it accepts these aliases and full model IDs.
|
|
99
|
+
const configured = (process.env.FORGE_CLAUDE_MODELS ?? "").split(",").map(model => model.trim()).filter(Boolean);
|
|
100
|
+
return configured.length > 0 ? configured : [...claudeDefaultModels];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
export const claudeDefaultModels = ["sonnet", "opus", "haiku"];
|
|
109
|
+
export function parseCodexModelCatalog(raw) {
|
|
110
|
+
try {
|
|
111
|
+
const parsed = JSON.parse(raw);
|
|
112
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.models)) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const entries = parsed.models
|
|
116
|
+
.map((entry, index) => {
|
|
117
|
+
if (!isRecord(entry) || typeof entry.slug !== "string") {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const visibility = typeof entry.visibility === "string" ? entry.visibility.toLowerCase() : "list";
|
|
121
|
+
if (visibility !== "list") {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const priority = typeof entry.priority === "number" && Number.isFinite(entry.priority) ? entry.priority : index;
|
|
125
|
+
return { slug: entry.slug, priority, index };
|
|
126
|
+
})
|
|
127
|
+
.filter((entry) => entry !== null)
|
|
128
|
+
.sort((left, right) => left.priority - right.priority || left.index - right.index)
|
|
129
|
+
.map((entry) => entry.slug);
|
|
130
|
+
return uniqueModels(entries);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function parseCursorModelList(raw) {
|
|
137
|
+
return uniqueModels(raw
|
|
138
|
+
.split(/\r?\n/)
|
|
139
|
+
.map((line) => line.trim())
|
|
140
|
+
.filter((line) => line.length > 0 && !line.toLowerCase().startsWith("available models"))
|
|
141
|
+
.map((line) => line.split(/\s+-\s+/, 1)[0]?.trim() ?? "")
|
|
142
|
+
.filter((model) => model.length > 0));
|
|
143
|
+
}
|
|
144
|
+
function uniqueModels(models) {
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
const result = [];
|
|
147
|
+
for (const model of models) {
|
|
148
|
+
const trimmed = model.trim();
|
|
149
|
+
const key = trimmed.toLowerCase();
|
|
150
|
+
if (!trimmed || seen.has(key)) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
seen.add(key);
|
|
154
|
+
result.push(trimmed);
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
function isRecord(value) {
|
|
159
|
+
return typeof value === "object" && value !== null;
|
|
160
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AttemptProcessSupervisor } from "./attempt-process-supervisor.js";
|
|
2
|
+
export interface AspNetRuntimePrebuildPlan {
|
|
3
|
+
readonly fingerprint: string;
|
|
4
|
+
readonly receiptPath: string;
|
|
5
|
+
readonly command: string;
|
|
6
|
+
readonly args: readonly string[];
|
|
7
|
+
readonly cwd: string;
|
|
8
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
9
|
+
readonly projectPath: string;
|
|
10
|
+
readonly worktreePath: string;
|
|
11
|
+
readonly inputCommitSha: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AspNetRuntimePrebuildResult {
|
|
14
|
+
readonly cacheHit: boolean;
|
|
15
|
+
readonly receiptPath: string;
|
|
16
|
+
readonly fingerprint: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AspNetRuntimeBuildExecutionResult {
|
|
19
|
+
readonly exitCode: number;
|
|
20
|
+
readonly stdoutTail: string;
|
|
21
|
+
readonly stderrTail: string;
|
|
22
|
+
readonly stdoutLogPath: string;
|
|
23
|
+
readonly stderrLogPath: string;
|
|
24
|
+
}
|
|
25
|
+
export type AspNetRuntimeBuildExecutor = (plan: AspNetRuntimePrebuildPlan, signal?: AbortSignal) => Promise<AspNetRuntimeBuildExecutionResult>;
|
|
26
|
+
/** Runs one ASP.NET runtime build under the attempt's supervisor, logging only redacted output. */
|
|
27
|
+
export declare function executeAspNetRuntimeBuild(supervisor: AttemptProcessSupervisor, logDirectory: string, plan: AspNetRuntimePrebuildPlan, signal?: AbortSignal, exactSecrets?: readonly string[],
|
|
28
|
+
/** Once the build's supervised tree is up: records it on the build's host load token. */
|
|
29
|
+
onStarted?: (metadataPath: string) => Promise<void>): Promise<AspNetRuntimeBuildExecutionResult>;
|
|
30
|
+
export declare function createAspNetRuntimePrebuildPlan(options: {
|
|
31
|
+
readonly command: string;
|
|
32
|
+
readonly args: readonly string[];
|
|
33
|
+
readonly cwd: string;
|
|
34
|
+
readonly worktreePath: string;
|
|
35
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
36
|
+
readonly inputCommitSha: string;
|
|
37
|
+
readonly runtimeContractFingerprint: string;
|
|
38
|
+
}): AspNetRuntimePrebuildPlan | null;
|
|
39
|
+
export declare function ensureAspNetRuntimePrebuilt(plan: AspNetRuntimePrebuildPlan, execute: AspNetRuntimeBuildExecutor, signal?: AbortSignal): Promise<AspNetRuntimePrebuildResult>;
|
|
40
|
+
export declare function withAspNetPrebuiltRunArguments(command: string, args: readonly string[]): readonly string[];
|
|
41
|
+
export declare function resolveWorktreeCommitSha(worktreePath: string, supplied?: string | null): Promise<string>;
|