@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f8fb73715e8
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 +183 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
- package/dist/bridge/bridge-chat-provider-command.js +230 -0
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- 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 +15 -0
- package/dist/bridge/bridge-state-io.js +68 -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 +9 -0
- package/dist/bridge/bridge.service.d.ts +102 -14
- package/dist/bridge/bridge.service.js +499 -471
- package/dist/bridge/bridge.types.d.ts +37 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -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 +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +31 -1
- 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/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -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 +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +11 -0
- package/dist/cleanup/forge-owned-paths.js +62 -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 +75 -13
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +161 -228
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +18 -1
- package/dist/cli/local-config.js +67 -5
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- 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 +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -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/host-facts.d.ts +2 -1
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +72 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +40 -0
- package/dist/runtime/host-load-child-environment.js +110 -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 +82 -0
- package/dist/runtime/host-load-governor-config.js +104 -0
- package/dist/runtime/host-load-governor.d.ts +273 -0
- package/dist/runtime/host-load-governor.js +831 -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-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -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 +92 -2
- package/dist/runtime/host-load-sampler.js +166 -8
- 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 +107 -0
- package/dist/runtime/host-load-step-run.js +158 -0
- package/dist/runtime/host-load-test-slot.d.ts +46 -0
- package/dist/runtime/host-load-test-slot.js +100 -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 +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +39 -6
- package/dist/runtime/host-runtime-lease.d.ts +101 -6
- package/dist/runtime/host-runtime-lease.js +408 -294
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +101 -2
- package/dist/runtime/host-runtime-promotion.js +355 -14
- 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.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -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 +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +11 -3
- package/dist/sandbox/runtime.js +53 -20
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- 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 +2 -7
- package/dist/session/managed-attempt-tools.js +204 -141
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +52 -0
- package/dist/session/managed-command-host-load.js +87 -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.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +9 -17
- package/dist/session/phase-completion.artifacts.js +158 -190
- 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 +31 -2
- package/dist/session/phase-completion.helpers.js +18 -65
- package/dist/session/phase-completion.js +19 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +20 -1
- package/dist/session/phase-completion.runtime.d.ts +13 -12
- package/dist/session/phase-completion.runtime.js +113 -214
- 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 +219 -232
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +58 -94
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +112 -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 +3 -0
- package/dist/session/pre-publication-process.js +32 -19
- 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 +39 -22
- package/dist/session/pre-publication-validation.js +241 -207
- 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/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -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/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +281 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- 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.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +41 -432
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
- package/dist/session/provider-cli/provider-cli.service.js +127 -317
- package/dist/session/provider-cli/provider-cli.types.d.ts +35 -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 +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -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 +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- 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/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 +279 -0
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +16 -2
- package/dist/session/session.service.js +208 -155
- package/dist/session/session.types.d.ts +8 -0
- package/dist/session/session.types.js +13 -83
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -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/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- 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 +67 -0
- package/dist/shared/process/process.js +213 -11
- 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 +2 -0
- package/dist/shared/provider-capabilities.js +23 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +58 -5
- package/dist/worktree/worktree.service.js +237 -161
- package/dist/worktree/worktree.types.d.ts +54 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HostRuntimeRequirements } from "../runtime/host-runtime-requirements.js";
|
|
2
|
+
import type { BridgeTestPostgresCapability } from "./test-postgres-capability.js";
|
|
1
3
|
import type { ApiKeySecretGrant, DispatchSandboxResourceRequest, RunOnceResultPacket, RunnerDispatchEvent } from "../session/session.types.js";
|
|
2
4
|
import type { SandboxFeatureMatrix } from "../sandbox/sandbox.types.js";
|
|
3
5
|
import type { HostRuntimeCapacitySnapshot } from "../runtime/host-runtime-lease.js";
|
|
@@ -5,7 +7,12 @@ import type { MemoryAdmissionDiagnostics } from "../runtime/memory-capacity.js";
|
|
|
5
7
|
import type { DockerEngineCapabilitySnapshot } from "../runtime/docker-engine-probe.js";
|
|
6
8
|
import type { HostFacts } from "../runtime/host-facts.js";
|
|
7
9
|
import type { HostLoadSnapshot } from "../runtime/host-load-sampler.js";
|
|
10
|
+
import type { RunnerSettingsReport } from "../runtime/runner-settings.js";
|
|
8
11
|
import type { BridgeChatCapability, ChatTurnCancelPacket } from "./bridge-chat.types.js";
|
|
12
|
+
/** Capability fields the bridge derives from its provider list (see provider-capabilities.ts). */
|
|
13
|
+
export declare const derivedCapabilityFields: readonly ["supportsDraftImageAttachments", "sandboxProfiles"];
|
|
14
|
+
export type DerivedCapabilityField = (typeof derivedCapabilityFields)[number];
|
|
15
|
+
export type CapabilitySource = "derived" | "explicit";
|
|
9
16
|
export interface BridgeServiceConfig {
|
|
10
17
|
readonly serverUrl: string;
|
|
11
18
|
readonly runnerId: string;
|
|
@@ -16,6 +23,12 @@ export interface BridgeServiceConfig {
|
|
|
16
23
|
readonly sandboxPidCapacity: number;
|
|
17
24
|
readonly dockerEnabled: boolean;
|
|
18
25
|
readonly allowOpenPublicSandbox: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The runner owner accepts Forge PR reviews placed on this host, outside the Docker sandbox, where the
|
|
28
|
+
* provider reads author-controlled code with this user's credentials in reach. Default false: such a
|
|
29
|
+
* review is refused (pr-review-placement.ts).
|
|
30
|
+
*/
|
|
31
|
+
readonly allowUnsandboxedPrReview?: boolean;
|
|
19
32
|
readonly sandboxPublicationMode?: "bridge_push" | "shared_filesystem";
|
|
20
33
|
readonly dockerExecutable: string;
|
|
21
34
|
readonly dockerContext: string;
|
|
@@ -55,6 +68,12 @@ export interface BridgeServiceConfig {
|
|
|
55
68
|
readonly supportsDraftRunOnce: boolean;
|
|
56
69
|
readonly supportsDraftAttachments: boolean;
|
|
57
70
|
readonly supportsDraftImageAttachments: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Where each provider-derived capability's value came from: "derived" from the provider list
|
|
73
|
+
* (pair or the defaults) or "explicit" (set by the user in bridge.json). A field with no entry
|
|
74
|
+
* comes from a bridge.json written before the marker existed, so its source is unknown.
|
|
75
|
+
*/
|
|
76
|
+
readonly capabilitySources?: Readonly<Partial<Record<DerivedCapabilityField, CapabilitySource>>>;
|
|
58
77
|
readonly bridgeChat: BridgeChatCapability;
|
|
59
78
|
readonly version: string;
|
|
60
79
|
readonly protocolVersion: number;
|
|
@@ -63,6 +82,16 @@ export interface BridgeServiceConfig {
|
|
|
63
82
|
readonly callbackAckTimeoutMs?: number;
|
|
64
83
|
readonly heartbeatDockerProbeWaitMs?: number;
|
|
65
84
|
readonly reconnectBackoffMs: readonly number[];
|
|
85
|
+
/**
|
|
86
|
+
* Decision 0014: the `forge-bridge yield` flag file next to the bridge config,
|
|
87
|
+
* polled while running. Null or absent: no local yield flag.
|
|
88
|
+
*/
|
|
89
|
+
readonly localYieldFlagPath?: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Where the running bridge publishes whether it is idle (`bridge.state.json` next to
|
|
92
|
+
* the bridge config), read by `forge-bridge status --idle`. Null or absent: not published.
|
|
93
|
+
*/
|
|
94
|
+
readonly bridgeStatePath?: string | null;
|
|
66
95
|
}
|
|
67
96
|
export interface BridgeRepoMapping {
|
|
68
97
|
readonly repoId?: string | null;
|
|
@@ -144,10 +173,17 @@ export interface BridgeCapabilities {
|
|
|
144
173
|
readonly playwrightProjects?: readonly string[] | null;
|
|
145
174
|
readonly browserLaunch?: boolean | null;
|
|
146
175
|
readonly providerConnectivity?: Readonly<Record<string, boolean>> | null;
|
|
176
|
+
/** Native test PostgreSQL and whether its role is a superuser (decision 0013 placement). */
|
|
177
|
+
readonly testPostgres?: BridgeTestPostgresCapability | null;
|
|
147
178
|
/** Static host hardware facts (schema 7). Material: changes are persisted immediately. */
|
|
148
179
|
readonly host?: HostFacts | null;
|
|
149
180
|
/** Live host load sample (schema 7). Never material: heartbeats with only load changes are not persisted. */
|
|
150
181
|
readonly load?: HostLoadSnapshot | null;
|
|
182
|
+
/** Decision 0014 (schema 8): server settings support and the last `SettingsApplied` report. Material. */
|
|
183
|
+
readonly settings?: BridgeSettingsCapability | null;
|
|
184
|
+
}
|
|
185
|
+
export interface BridgeSettingsCapability extends RunnerSettingsReport {
|
|
186
|
+
readonly supportsServerSettings: true;
|
|
151
187
|
}
|
|
152
188
|
export interface SandboxMemoryCapacityDiagnostics {
|
|
153
189
|
readonly defaultWorkerMemoryLimitBytes: number;
|
|
@@ -298,6 +334,7 @@ export interface BridgeRuntimeReadinessResult {
|
|
|
298
334
|
readonly status: "parallel_ready" | "serialized" | "failed";
|
|
299
335
|
readonly runtimeContractFingerprint?: string | null;
|
|
300
336
|
readonly runtimeContractSource?: string | null;
|
|
337
|
+
readonly runtimeRequirements?: HostRuntimeRequirements | null;
|
|
301
338
|
readonly reasonCode?: string | null;
|
|
302
339
|
readonly reasonMessage?: string | null;
|
|
303
340
|
readonly qaAppLaunchTarget?: BridgeRuntimeReadinessQaLaunchTarget | null;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** Capability fields the bridge derives from its provider list (see provider-capabilities.ts). */
|
|
2
|
+
export const derivedCapabilityFields = ["supportsDraftImageAttachments", "sandboxProfiles"];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SessionService } from "../session/session.base.js";
|
|
2
|
+
import type { HostLoadGovernor } from "../runtime/host-load-governor.js";
|
|
3
|
+
import type { HostLoadSource } from "../runtime/host-load-sampler.js";
|
|
4
|
+
import type { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
|
|
5
|
+
/**
|
|
6
|
+
* The session service a bridge builds when none is injected, wired to one host load governor
|
|
7
|
+
* (the host runtime's): worktree builds, pre-publication validation and host runtimes all ask
|
|
8
|
+
* it for capacity. The governor is returned too, for the bridge's startup capacity log line.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDefaultSessionService(sandboxStateRoot: string, sandboxExecutionRoot: string, dockerEngineProbe: DockerEngineProbe, hostLoad: HostLoadSource): {
|
|
11
|
+
readonly sessions: SessionService;
|
|
12
|
+
readonly hostLoadGovernor: HostLoadGovernor;
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BridgeSessionService } from "../session/session.service.js";
|
|
2
|
+
import { ProcessBackedProviderCliService, RoutingProviderCliService, StreamingProviderProcessRunner, } from "../session/provider-cli/provider-cli.service.js";
|
|
3
|
+
import { PrePublicationValidator } from "../session/pre-publication-validation.js";
|
|
4
|
+
import { HostRuntimeLeaseManager } from "../runtime/host-runtime-lease.js";
|
|
5
|
+
import { createNativeTestClusterDatabaseBroker } from "../runtime/attempt-database-broker.js";
|
|
6
|
+
import { readNativeTestPostgresFallback } from "../runtime/native-test-postgres-fallback.js";
|
|
7
|
+
import { GitWorktreeService } from "../worktree/worktree.service.js";
|
|
8
|
+
import { RepositoryCoordinatorLock } from "../sandbox/repository-lock.js";
|
|
9
|
+
import { AttemptCoordinatedProviderProcessRunner, AttemptProcessSupervisorRegistry, } from "../runtime/attempt-process-supervisor-registry.js";
|
|
10
|
+
/**
|
|
11
|
+
* The session service a bridge builds when none is injected, wired to one host load governor
|
|
12
|
+
* (the host runtime's): worktree builds, pre-publication validation and host runtimes all ask
|
|
13
|
+
* it for capacity. The governor is returned too, for the bridge's startup capacity log line.
|
|
14
|
+
*/
|
|
15
|
+
export function createDefaultSessionService(sandboxStateRoot, sandboxExecutionRoot, dockerEngineProbe, hostLoad) {
|
|
16
|
+
const rawProcessRunner = new StreamingProviderProcessRunner();
|
|
17
|
+
const processSupervisors = new AttemptProcessSupervisorRegistry();
|
|
18
|
+
const coordinatedProcessRunner = new AttemptCoordinatedProviderProcessRunner(processSupervisors, rawProcessRunner);
|
|
19
|
+
const hostRuntime = new HostRuntimeLeaseManager(sandboxStateRoot, undefined, undefined, processSupervisors, rawProcessRunner, undefined, undefined, undefined, undefined, undefined, sandboxExecutionRoot, createNativeTestClusterDatabaseBroker(readNativeTestPostgresFallback, sandboxStateRoot), hostLoad);
|
|
20
|
+
const sessions = new BridgeSessionService(new GitWorktreeService(undefined, new RepositoryCoordinatorLock(sandboxStateRoot), hostRuntime.hostLoadGovernor, sandboxStateRoot), new RoutingProviderCliService(new ProcessBackedProviderCliService(coordinatedProcessRunner, undefined, undefined, undefined, new PrePublicationValidator(undefined, dockerEngineProbe, readNativeTestPostgresFallback, hostRuntime.hostLoadGovernor))), hostRuntime);
|
|
21
|
+
return { sessions, hostLoadGovernor: hostRuntime.hostLoadGovernor };
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { unmetHostRuntimeRequirements, type HostRequirementFacts } from "../runtime/host-runtime-requirements-check.js";
|
|
2
|
+
export { prReviewExecutionFacilities, prReviewPlacementRefusalResult, runWithUnsandboxedReviewWarning } from "../session/pr-review-placement.js";
|
|
3
|
+
import type { RunOnceDispatchPacket } from "../session/session.types.js";
|
|
4
|
+
import type { BridgeServiceConfig } from "./bridge.types.js";
|
|
5
|
+
export interface OfferRefusal {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Why this runner refuses an offer on policy, after its Docker preflight passed: a Forge PR review placed
|
|
11
|
+
* outside the Docker sandbox without the owner's opt-in, then, for a Docker offer, its network policy, the
|
|
12
|
+
* provider's need for a network, and the provider's auth (`authFailure`). Null when it may take the offer.
|
|
13
|
+
*/
|
|
14
|
+
export declare function offerPolicyRefusal(dispatch: RunOnceDispatchPacket, config: BridgeServiceConfig, authFailure: () => string | null): OfferRefusal | null;
|
|
15
|
+
/**
|
|
16
|
+
* The code a Docker offer is refused with when its sandbox contract cannot be profiled: a capacity wait for
|
|
17
|
+
* ordinary work, but for a Forge PR review the non-retryable refusal Forge remembers for this runner and head.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sandboxProfileRefusalCode(dispatch: RunOnceDispatchPacket): string;
|
|
20
|
+
/** Why this runner refuses a Docker offer under its network policy, or null. */
|
|
21
|
+
export declare function sandboxNetworkPolicyFailure(dispatch: RunOnceDispatchPacket, config: BridgeServiceConfig): string | null;
|
|
22
|
+
export declare function sandboxProviderNetworkFailure(dispatch: RunOnceDispatchPacket, config: BridgeServiceConfig): string | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// What a runner checks before it takes a dispatch: the host runtime requirements, a Docker offer's network
|
|
2
|
+
// policy, and where a Forge PR review may run (pr-review-placement.ts).
|
|
3
|
+
export { unmetHostRuntimeRequirements } from "../runtime/host-runtime-requirements-check.js";
|
|
4
|
+
export { prReviewExecutionFacilities, prReviewPlacementRefusalResult, runWithUnsandboxedReviewWarning } from "../session/pr-review-placement.js";
|
|
5
|
+
import { isPrReviewDispatch, prReviewPlacementRefusalResult, prReviewSandboxUnavailableCode } from "../session/pr-review-placement.js";
|
|
6
|
+
/**
|
|
7
|
+
* Why this runner refuses an offer on policy, after its Docker preflight passed: a Forge PR review placed
|
|
8
|
+
* outside the Docker sandbox without the owner's opt-in, then, for a Docker offer, its network policy, the
|
|
9
|
+
* provider's need for a network, and the provider's auth (`authFailure`). Null when it may take the offer.
|
|
10
|
+
*/
|
|
11
|
+
export function offerPolicyRefusal(dispatch, config, authFailure) {
|
|
12
|
+
const review = prReviewPlacementRefusalResult(dispatch, config.allowUnsandboxedPrReview)?.failure;
|
|
13
|
+
if (review)
|
|
14
|
+
return { code: review.code, message: review.message };
|
|
15
|
+
if (dispatch.sandbox?.executionMode !== "docker")
|
|
16
|
+
return null;
|
|
17
|
+
const network = sandboxNetworkPolicyFailure(dispatch, config);
|
|
18
|
+
if (network)
|
|
19
|
+
return { code: "policy_mismatch", message: network };
|
|
20
|
+
const providerNetwork = sandboxProviderNetworkFailure(dispatch, config);
|
|
21
|
+
if (providerNetwork)
|
|
22
|
+
return { code: "provider_network_policy_denied", message: providerNetwork };
|
|
23
|
+
const auth = authFailure();
|
|
24
|
+
return auth ? { code: "sandbox_auth_unavailable", message: auth } : null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The code a Docker offer is refused with when its sandbox contract cannot be profiled: a capacity wait for
|
|
28
|
+
* ordinary work, but for a Forge PR review the non-retryable refusal Forge remembers for this runner and head.
|
|
29
|
+
*/
|
|
30
|
+
export function sandboxProfileRefusalCode(dispatch) {
|
|
31
|
+
return isPrReviewDispatch(dispatch) ? prReviewSandboxUnavailableCode : "sandbox_capacity_profile_unavailable";
|
|
32
|
+
}
|
|
33
|
+
/** Why this runner refuses a Docker offer under its network policy, or null. */
|
|
34
|
+
export function sandboxNetworkPolicyFailure(dispatch, config) {
|
|
35
|
+
const sandbox = dispatch.sandbox;
|
|
36
|
+
if (!sandbox)
|
|
37
|
+
return "Protocol-v2 sandbox context is missing.";
|
|
38
|
+
if (sandbox.networkPolicy.mode === "open_public"
|
|
39
|
+
&& (sandbox.executionPolicy === "sandbox_required" || !config.allowOpenPublicSandbox)) {
|
|
40
|
+
return "open_public sandbox networking is not permitted by this runner policy.";
|
|
41
|
+
}
|
|
42
|
+
if (sandbox.networkPolicy.mode === "public_allowlist"
|
|
43
|
+
&& sandbox.networkPolicy.allowedHosts.length > 0
|
|
44
|
+
&& process.env.FORGE_SANDBOX_EGRESS_ENFORCED !== "true") {
|
|
45
|
+
return "public_allowlist requires an operator-enforced Forge egress proxy or firewall.";
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
export function sandboxProviderNetworkFailure(dispatch, config) {
|
|
50
|
+
const sandbox = dispatch.sandbox;
|
|
51
|
+
if (!sandbox || sandbox.networkPolicy.mode !== "offline")
|
|
52
|
+
return null;
|
|
53
|
+
const provider = dispatch.execution.provider.trim().toLowerCase();
|
|
54
|
+
const isNetworkProvider = config.cliProviders.some(candidate => candidate.trim().toLowerCase() === provider);
|
|
55
|
+
if (!isNetworkProvider)
|
|
56
|
+
return null;
|
|
57
|
+
return `Provider ${dispatch.execution.provider} requires outbound network access, but this Docker attempt uses the offline network policy.`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type InFlightKind = "offer" | "start" | "dispatch" | "chat_turn" | "readiness_probe" | "reservation" | "session"
|
|
2
|
+
/** The bridge could not read its own ledgers; treated as busy. */
|
|
3
|
+
| "unknown";
|
|
4
|
+
export interface InFlightIds {
|
|
5
|
+
readonly dispatchAttemptId?: string;
|
|
6
|
+
readonly leaseId?: string;
|
|
7
|
+
readonly sessionId?: string;
|
|
8
|
+
readonly cycleRunId?: string;
|
|
9
|
+
readonly workItemId?: string;
|
|
10
|
+
readonly turnId?: string;
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface InFlightEntry {
|
|
14
|
+
readonly kind: InFlightKind;
|
|
15
|
+
readonly ids: InFlightIds;
|
|
16
|
+
readonly phase: string;
|
|
17
|
+
/** When this bridge took the work on, or null when the ledger does not record it. */
|
|
18
|
+
readonly since: string | null;
|
|
19
|
+
/** When the current phase began, or null when unknown. */
|
|
20
|
+
readonly phaseSince: string | null;
|
|
21
|
+
}
|
|
22
|
+
export type InFlightSource = () => readonly InFlightEntry[];
|
|
23
|
+
export declare class BridgeInFlightRegistry {
|
|
24
|
+
private readonly now;
|
|
25
|
+
private readonly tracked;
|
|
26
|
+
private readonly sources;
|
|
27
|
+
private readonly listeners;
|
|
28
|
+
private nextKey;
|
|
29
|
+
constructor(now?: () => Date);
|
|
30
|
+
/** Starts tracking one piece of work; returns the key that ends it. */
|
|
31
|
+
begin(kind: InFlightKind, ids: InFlightIds, phase?: string): number;
|
|
32
|
+
end(key: number): void;
|
|
33
|
+
/** Moves every tracked entry for this lease to a new phase. */
|
|
34
|
+
notePhase(leaseId: string, phase: string | null | undefined): void;
|
|
35
|
+
/** Tracks a hub handler for as long as it runs, whether it resolves or throws. */
|
|
36
|
+
track<T>(kind: InFlightKind, raw: unknown, run: () => Promise<T>): Promise<T>;
|
|
37
|
+
addSource(source: InFlightSource): void;
|
|
38
|
+
onChange(listener: () => void): () => void;
|
|
39
|
+
snapshot(): InFlightEntry[];
|
|
40
|
+
get idle(): boolean;
|
|
41
|
+
private changed;
|
|
42
|
+
}
|
|
43
|
+
/** Reads the ids of a hub payload: an Offer/Start envelope, a dispatch packet, a chat turn or a readiness probe. */
|
|
44
|
+
export declare function inFlightIdsFrom(raw: unknown): InFlightIds;
|
|
45
|
+
/** Accepted offers whose Start has not arrived yet. A claimed one is the Start handler's. */
|
|
46
|
+
export declare function reservationInFlightEntries(reservations: ReadonlyMap<string, {
|
|
47
|
+
readonly leaseId: string;
|
|
48
|
+
readonly reservedUntil: string;
|
|
49
|
+
readonly startClaim?: unknown;
|
|
50
|
+
}>, now?: number): InFlightEntry[];
|
|
51
|
+
export declare function sessionInFlightEntries(sessions: ReadonlyMap<string, {
|
|
52
|
+
readonly kind: string;
|
|
53
|
+
readonly dispatchAttemptId: string | null;
|
|
54
|
+
readonly turnId?: string;
|
|
55
|
+
}>): InFlightEntry[];
|
|
56
|
+
export declare function readinessInFlightEntries(probes: ReadonlyMap<string, unknown>): InFlightEntry[];
|
|
57
|
+
/** Whether a value read back from the state file is a complete in-flight entry. */
|
|
58
|
+
export declare function isInFlightEntry(value: unknown): value is InFlightEntry;
|
|
59
|
+
/** A server-supplied label (role, phase) made safe for one log line: plain identifier or "unknown". */
|
|
60
|
+
export declare function safeLogLabel(value: unknown): string;
|
|
61
|
+
/** "attempt=…, lease=…, session=…, cycle=…" for log lines and status output. */
|
|
62
|
+
export declare function describeInFlightIds(ids: InFlightIds): string;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// The connected bridge's in-flight work, so a host can tell whether restarting the
|
|
2
|
+
// bridge would kill something (owner, 2026-11-19: a restart killed a develop session
|
|
3
|
+
// that was still in host-runtime preparation, with no agent process yet).
|
|
4
|
+
//
|
|
5
|
+
// Two kinds of entries make up the snapshot:
|
|
6
|
+
// - tracked entries: every Offer, Start, Dispatch, chat turn and readiness probe
|
|
7
|
+
// handler from the moment Forge hands it over until the handler returns, with
|
|
8
|
+
// the phase updated from the runner events the dispatch emits;
|
|
9
|
+
// - source entries: work the bridge still holds after a handler returned or before
|
|
10
|
+
// one is tracked, read from the bridge's own ledgers (accepted offers waiting for
|
|
11
|
+
// Start, active sessions, readiness probes). A source entry that names the same
|
|
12
|
+
// work as a tracked one is dropped.
|
|
13
|
+
// Entries leave the snapshot when the handler settles (success, failure or cancel)
|
|
14
|
+
// or when the ledger releases the work, so nothing has to remember to remove them.
|
|
15
|
+
const idKeys = ["dispatchAttemptId", "leaseId", "sessionId", "cycleRunId", "workItemId", "turnId", "requestId"];
|
|
16
|
+
const identityKeys = ["dispatchAttemptId", "leaseId", "turnId", "requestId"];
|
|
17
|
+
// Ids are written to a local file and logs: keep only plain identifiers.
|
|
18
|
+
const safeId = /^[A-Za-z0-9._:-]{1,200}$/u;
|
|
19
|
+
const safePhase = /^[A-Za-z0-9._:-]{1,120}$/u;
|
|
20
|
+
export class BridgeInFlightRegistry {
|
|
21
|
+
now;
|
|
22
|
+
tracked = new Map();
|
|
23
|
+
sources = [];
|
|
24
|
+
listeners = new Set();
|
|
25
|
+
nextKey = 1;
|
|
26
|
+
constructor(now = () => new Date()) {
|
|
27
|
+
this.now = now;
|
|
28
|
+
}
|
|
29
|
+
/** Starts tracking one piece of work; returns the key that ends it. */
|
|
30
|
+
begin(kind, ids, phase = `${kind}_received`) {
|
|
31
|
+
const key = this.nextKey++;
|
|
32
|
+
const at = this.now().toISOString();
|
|
33
|
+
this.tracked.set(key, { kind, ids, phase: cleanPhase(phase), since: at, phaseSince: at });
|
|
34
|
+
this.changed();
|
|
35
|
+
return key;
|
|
36
|
+
}
|
|
37
|
+
end(key) {
|
|
38
|
+
if (this.tracked.delete(key))
|
|
39
|
+
this.changed();
|
|
40
|
+
}
|
|
41
|
+
/** Moves every tracked entry for this lease to a new phase. */
|
|
42
|
+
notePhase(leaseId, phase) {
|
|
43
|
+
if (!phase || !safePhase.test(phase))
|
|
44
|
+
return;
|
|
45
|
+
let changed = false;
|
|
46
|
+
for (const entry of this.tracked.values()) {
|
|
47
|
+
if (entry.ids.leaseId !== leaseId || entry.phase === phase)
|
|
48
|
+
continue;
|
|
49
|
+
entry.phase = phase;
|
|
50
|
+
entry.phaseSince = this.now().toISOString();
|
|
51
|
+
changed = true;
|
|
52
|
+
}
|
|
53
|
+
if (changed)
|
|
54
|
+
this.changed();
|
|
55
|
+
}
|
|
56
|
+
/** Tracks a hub handler for as long as it runs, whether it resolves or throws. */
|
|
57
|
+
async track(kind, raw, run) {
|
|
58
|
+
const key = this.begin(kind, inFlightIdsFrom(raw));
|
|
59
|
+
try {
|
|
60
|
+
return await run();
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
this.end(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
addSource(source) {
|
|
67
|
+
this.sources.push(source);
|
|
68
|
+
}
|
|
69
|
+
onChange(listener) {
|
|
70
|
+
this.listeners.add(listener);
|
|
71
|
+
return () => this.listeners.delete(listener);
|
|
72
|
+
}
|
|
73
|
+
snapshot() {
|
|
74
|
+
const tracked = [...this.tracked.values()].map(entry => ({ ...entry, ids: { ...entry.ids } }));
|
|
75
|
+
const fromSources = [];
|
|
76
|
+
for (const source of this.sources) {
|
|
77
|
+
for (const entry of source()) {
|
|
78
|
+
if (![...tracked, ...fromSources].some(other => sameWork(entry.ids, other.ids)))
|
|
79
|
+
fromSources.push(entry);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [...tracked, ...fromSources];
|
|
83
|
+
}
|
|
84
|
+
get idle() {
|
|
85
|
+
return this.snapshot().length === 0;
|
|
86
|
+
}
|
|
87
|
+
changed() {
|
|
88
|
+
for (const listener of this.listeners) {
|
|
89
|
+
try {
|
|
90
|
+
listener();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// A listener (the state file publisher) must never break the bridge.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Reads the ids of a hub payload: an Offer/Start envelope, a dispatch packet, a chat turn or a readiness probe. */
|
|
99
|
+
export function inFlightIdsFrom(raw) {
|
|
100
|
+
const root = asRecord(raw);
|
|
101
|
+
if (!root)
|
|
102
|
+
return {};
|
|
103
|
+
const packet = asRecord(field(root, "dispatch")) ?? root;
|
|
104
|
+
const values = {
|
|
105
|
+
dispatchAttemptId: firstId(root, asRecord(field(packet, "sandbox")), "dispatchAttemptId"),
|
|
106
|
+
leaseId: firstId(root, null, "leaseId") ?? firstId(asRecord(field(packet, "lease")), null, "id"),
|
|
107
|
+
sessionId: firstId(asRecord(field(packet, "session")), null, "id"),
|
|
108
|
+
cycleRunId: firstId(asRecord(field(packet, "cycleRun")), null, "id"),
|
|
109
|
+
workItemId: firstId(asRecord(field(packet, "workItem")), null, "id"),
|
|
110
|
+
turnId: firstId(root, null, "turnId"),
|
|
111
|
+
requestId: firstId(root, null, "requestId"),
|
|
112
|
+
};
|
|
113
|
+
return Object.fromEntries(idKeys.flatMap(key => values[key] ? [[key, values[key]]] : []));
|
|
114
|
+
}
|
|
115
|
+
/** Accepted offers whose Start has not arrived yet. A claimed one is the Start handler's. */
|
|
116
|
+
export function reservationInFlightEntries(reservations, now = Date.now()) {
|
|
117
|
+
return [...reservations].flatMap(([dispatchAttemptId, reservation]) => {
|
|
118
|
+
if (Date.parse(reservation.reservedUntil) <= now)
|
|
119
|
+
return [];
|
|
120
|
+
return [{
|
|
121
|
+
kind: "reservation",
|
|
122
|
+
ids: cleanIds({ dispatchAttemptId, leaseId: reservation.leaseId }),
|
|
123
|
+
phase: reservation.startClaim ? "start_claimed" : "awaiting_start",
|
|
124
|
+
since: null,
|
|
125
|
+
phaseSince: null,
|
|
126
|
+
}];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function sessionInFlightEntries(sessions) {
|
|
130
|
+
return [...sessions].map(([leaseId, session]) => ({
|
|
131
|
+
kind: session.kind === "chat" ? "chat_turn" : "session",
|
|
132
|
+
ids: cleanIds({ leaseId, dispatchAttemptId: session.dispatchAttemptId ?? undefined, turnId: session.turnId }),
|
|
133
|
+
phase: "active",
|
|
134
|
+
since: null,
|
|
135
|
+
phaseSince: null,
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
export function readinessInFlightEntries(probes) {
|
|
139
|
+
return [...probes.keys()].map(requestId => ({
|
|
140
|
+
kind: "readiness_probe",
|
|
141
|
+
ids: cleanIds({ requestId }),
|
|
142
|
+
phase: "probing",
|
|
143
|
+
since: null,
|
|
144
|
+
phaseSince: null,
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
const inFlightKinds = new Set([
|
|
148
|
+
"offer", "start", "dispatch", "chat_turn", "readiness_probe", "reservation", "session", "unknown",
|
|
149
|
+
]);
|
|
150
|
+
/** Whether a value read back from the state file is a complete in-flight entry. */
|
|
151
|
+
export function isInFlightEntry(value) {
|
|
152
|
+
const entry = asRecord(value);
|
|
153
|
+
const ids = entry ? asRecord(entry.ids) : null;
|
|
154
|
+
return entry !== null && ids !== null
|
|
155
|
+
&& typeof entry.kind === "string" && inFlightKinds.has(entry.kind)
|
|
156
|
+
&& Object.values(ids).every(id => typeof id === "string")
|
|
157
|
+
&& typeof entry.phase === "string" && entry.phase.length > 0
|
|
158
|
+
&& isNullableString(entry.since) && isNullableString(entry.phaseSince);
|
|
159
|
+
}
|
|
160
|
+
function isNullableString(value) {
|
|
161
|
+
return value === null || typeof value === "string";
|
|
162
|
+
}
|
|
163
|
+
/** A server-supplied label (role, phase) made safe for one log line: plain identifier or "unknown". */
|
|
164
|
+
export function safeLogLabel(value) {
|
|
165
|
+
return typeof value === "string" && safePhase.test(value) ? value : "unknown";
|
|
166
|
+
}
|
|
167
|
+
/** "attempt=…, lease=…, session=…, cycle=…" for log lines and status output. */
|
|
168
|
+
export function describeInFlightIds(ids) {
|
|
169
|
+
const labels = {
|
|
170
|
+
dispatchAttemptId: "attempt",
|
|
171
|
+
leaseId: "lease",
|
|
172
|
+
sessionId: "session",
|
|
173
|
+
cycleRunId: "cycle",
|
|
174
|
+
workItemId: "work item",
|
|
175
|
+
turnId: "turn",
|
|
176
|
+
requestId: "request",
|
|
177
|
+
};
|
|
178
|
+
const parts = idKeys.flatMap(key => ids[key] ? [`${labels[key]} ${ids[key]}`] : []);
|
|
179
|
+
return parts.length > 0 ? parts.join(", ") : "no ids";
|
|
180
|
+
}
|
|
181
|
+
function sameWork(left, right) {
|
|
182
|
+
return identityKeys.some(key => left[key] !== undefined && left[key] === right[key]);
|
|
183
|
+
}
|
|
184
|
+
function cleanIds(values) {
|
|
185
|
+
return Object.fromEntries(idKeys.flatMap(key => {
|
|
186
|
+
const value = values[key];
|
|
187
|
+
return typeof value === "string" && safeId.test(value) ? [[key, value]] : [];
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
function cleanPhase(phase) {
|
|
191
|
+
return safePhase.test(phase) ? phase : "unknown";
|
|
192
|
+
}
|
|
193
|
+
function firstId(primary, fallback, key) {
|
|
194
|
+
for (const source of [primary, fallback]) {
|
|
195
|
+
const value = source ? field(source, key) : undefined;
|
|
196
|
+
if (typeof value === "string" && safeId.test(value))
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
// Hub payloads arrive camelCase; older servers sent PascalCase.
|
|
202
|
+
function field(source, camelKey) {
|
|
203
|
+
return source[camelKey] ?? source[camelKey.charAt(0).toUpperCase() + camelKey.slice(1)];
|
|
204
|
+
}
|
|
205
|
+
function asRecord(value) {
|
|
206
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
207
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** `<config dir>/<config name>.yield.json`, e.g. `~/.config/forge/bridge.yield.json` beside `bridge.json`. */
|
|
2
|
+
export declare function localYieldFlagPathFor(configPath: string): string;
|
|
3
|
+
/** The local flag; a missing or unreadable file means off. */
|
|
4
|
+
export declare function readLocalYieldFlag(flagPath: string): Promise<boolean>;
|
|
5
|
+
/** Writes the flag atomically with mode 0600. */
|
|
6
|
+
export declare function writeLocalYieldFlag(flagPath: string, yieldToForeground: boolean): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
/** `<config dir>/<config name>.yield.json`, e.g. `~/.config/forge/bridge.yield.json` beside `bridge.json`. */
|
|
5
|
+
export function localYieldFlagPathFor(configPath) {
|
|
6
|
+
const parsed = path.parse(path.resolve(configPath));
|
|
7
|
+
return path.join(parsed.dir, `${parsed.name}.yield.json`);
|
|
8
|
+
}
|
|
9
|
+
/** The local flag; a missing or unreadable file means off. */
|
|
10
|
+
export async function readLocalYieldFlag(flagPath) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(await fs.readFile(flagPath, "utf8"));
|
|
13
|
+
return parsed?.schemaVersion === 1 && parsed.yieldToForeground === true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Writes the flag atomically with mode 0600. */
|
|
20
|
+
export async function writeLocalYieldFlag(flagPath, yieldToForeground) {
|
|
21
|
+
const content = { schemaVersion: 1, yieldToForeground, updatedAt: new Date().toISOString() };
|
|
22
|
+
await fs.mkdir(path.dirname(flagPath), { recursive: true, mode: 0o700 });
|
|
23
|
+
const temporary = `${flagPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
24
|
+
try {
|
|
25
|
+
await fs.writeFile(temporary, `${JSON.stringify(content, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
26
|
+
// The umask can narrow the create mode but never widen it; set it exactly.
|
|
27
|
+
await fs.chmod(temporary, 0o600);
|
|
28
|
+
await fs.rename(temporary, flagPath);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
await fs.rm(temporary, { force: true }).catch(() => undefined);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BridgeRuntimeReadinessResult } from "./bridge.types.js";
|
|
1
|
+
import type { BridgeRuntimeReadinessRequest, BridgeRuntimeReadinessResult } from "./bridge.types.js";
|
|
2
2
|
export interface DurableReadinessResult {
|
|
3
3
|
readonly schemaVersion: 1;
|
|
4
4
|
readonly expiresAt: string;
|
|
@@ -19,3 +19,7 @@ export declare class FileReadinessResultOutbox implements ReadinessResultOutbox
|
|
|
19
19
|
acknowledge(requestId: string): Promise<void>;
|
|
20
20
|
private operate;
|
|
21
21
|
}
|
|
22
|
+
/** A failed result Forge retries later (`host_runtime_probe_deferred`), for a probe the bridge will not run now. */
|
|
23
|
+
export declare function deferredReadinessResult(request: BridgeRuntimeReadinessRequest, runnerInstanceId: string, reasonMessage?: string): BridgeRuntimeReadinessResult;
|
|
24
|
+
/** The deferral reason a probe was aborted with, or null when it was aborted for another reason. */
|
|
25
|
+
export declare function readinessDeferralReason(signal: AbortSignal): string | null;
|
|
@@ -52,3 +52,23 @@ function recordName(requestId) {
|
|
|
52
52
|
throw new Error("runtime_readiness_result_invalid: request id must be a UUID.");
|
|
53
53
|
return `${value}.json`;
|
|
54
54
|
}
|
|
55
|
+
/** A failed result Forge retries later (`host_runtime_probe_deferred`), for a probe the bridge will not run now. */
|
|
56
|
+
export function deferredReadinessResult(request, runnerInstanceId, reasonMessage = "Foreground agent work is active; Forge deferred background runtime readiness so it cannot consume the agent's host capacity.") {
|
|
57
|
+
return {
|
|
58
|
+
schemaVersion: 1,
|
|
59
|
+
requestId: request.requestId,
|
|
60
|
+
fencingToken: request.fencingToken,
|
|
61
|
+
runnerInstanceId,
|
|
62
|
+
status: "failed",
|
|
63
|
+
reasonCode: "host_runtime_probe_deferred",
|
|
64
|
+
reasonMessage,
|
|
65
|
+
checkedAt: new Date().toISOString(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The deferral reason a probe was aborted with, or null when it was aborted for another reason. */
|
|
69
|
+
export function readinessDeferralReason(signal) {
|
|
70
|
+
if (!signal.aborted)
|
|
71
|
+
return null;
|
|
72
|
+
const reason = signal.reason instanceof Error ? signal.reason.message : String(signal.reason);
|
|
73
|
+
return reason.startsWith("host_runtime_probe_deferred:") ? reason : null;
|
|
74
|
+
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { BridgeServiceConfig, BridgeToolchainCapabilities } from "./bridge.types.js";
|
|
2
|
+
import { type BridgeTestPostgresCapability } from "./test-postgres-capability.js";
|
|
2
3
|
export interface RunnerHostCapabilitySnapshot {
|
|
3
4
|
readonly toolchains: BridgeToolchainCapabilities;
|
|
4
5
|
readonly playwrightProjects: readonly string[];
|
|
5
6
|
readonly browserLaunch: boolean;
|
|
6
7
|
readonly providerConnectivity: Readonly<Record<string, boolean>>;
|
|
8
|
+
readonly testPostgres: BridgeTestPostgresCapability;
|
|
7
9
|
}
|
|
8
10
|
export interface RunnerHostCapabilityProbe {
|
|
9
11
|
detect(config: BridgeServiceConfig): Promise<RunnerHostCapabilitySnapshot>;
|
|
10
12
|
}
|
|
11
13
|
export declare class ProcessRunnerHostCapabilityProbe implements RunnerHostCapabilityProbe {
|
|
14
|
+
private readonly warn;
|
|
15
|
+
private readonly providerEnvironment;
|
|
16
|
+
constructor(warn?: (message: string) => void, providerEnvironment?: () => NodeJS.ProcessEnv);
|
|
12
17
|
detect(config: BridgeServiceConfig): Promise<RunnerHostCapabilitySnapshot>;
|
|
13
18
|
}
|
|
14
19
|
export declare function isUnavailablePlaywrightConfigError(error: unknown): boolean;
|
|
@@ -2,20 +2,36 @@ import { execFile } from "node:child_process";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
|
+
import { probeTestPostgresCapability } from "./test-postgres-capability.js";
|
|
6
|
+
import { appExecutionAliasWarning } from "../shared/process/windows-app-execution-alias.js";
|
|
7
|
+
import { buildProviderChildEnvironment } from "../session/provider-cli/provider-cli.process.js";
|
|
8
|
+
import { resolveBashExecutable } from "./windows-bash-resolution.js";
|
|
5
9
|
const execFileAsync = promisify(execFile);
|
|
6
10
|
export class ProcessRunnerHostCapabilityProbe {
|
|
11
|
+
warn;
|
|
12
|
+
providerEnvironment;
|
|
13
|
+
constructor(warn = message => process.stderr.write(`[${new Date().toISOString()}] ${message}\n`), providerEnvironment = () => buildProviderChildEnvironment()) {
|
|
14
|
+
this.warn = warn;
|
|
15
|
+
this.providerEnvironment = providerEnvironment;
|
|
16
|
+
}
|
|
7
17
|
async detect(config) {
|
|
18
|
+
// Readiness, not a capability: the bridge still settles an attempt whose descendant escaped
|
|
19
|
+
// the Job Object (see OutputPipeRelease), but the host should not hand out aliases.
|
|
20
|
+
const aliasWarning = appExecutionAliasWarning(this.providerEnvironment());
|
|
21
|
+
if (aliasWarning)
|
|
22
|
+
this.warn(aliasWarning);
|
|
8
23
|
const [pnpm, dotnet, git, bash, pwsh, windowsPowerShell] = await Promise.all([
|
|
9
24
|
probe("pnpm", ["--version"]),
|
|
10
25
|
probe("dotnet", ["--version"]),
|
|
11
26
|
probe("git", ["--version"]),
|
|
12
|
-
|
|
27
|
+
probeBash(this.warn),
|
|
13
28
|
probe("pwsh", ["-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()"]),
|
|
14
29
|
process.platform === "win32"
|
|
15
30
|
? probe("powershell.exe", ["-NoProfile", "-Command", "$PSVersionTable.PSVersion.ToString()"])
|
|
16
31
|
: Promise.resolve(unavailable("powershell.exe")),
|
|
17
32
|
]);
|
|
18
33
|
const playwrightProjects = await detectPlaywrightProjects(config.repoMappings);
|
|
34
|
+
const testPostgres = await probeTestPostgresCapability();
|
|
19
35
|
const browserLaunch = playwrightProjects.length > 0
|
|
20
36
|
|| config.repoMappings.some(mapping => Boolean(mapping.qaAppLaunchTarget?.url
|
|
21
37
|
|| mapping.qaAppLaunchTarget?.command
|
|
@@ -33,6 +49,7 @@ export class ProcessRunnerHostCapabilityProbe {
|
|
|
33
49
|
browserLaunch,
|
|
34
50
|
providerConnectivity: Object.fromEntries(Object.entries(config.providerStatuses)
|
|
35
51
|
.map(([provider, status]) => [provider, status.signedIn === true])),
|
|
52
|
+
testPostgres,
|
|
36
53
|
};
|
|
37
54
|
}
|
|
38
55
|
}
|
|
@@ -46,6 +63,18 @@ async function probe(executable, args) {
|
|
|
46
63
|
return unavailable(executable);
|
|
47
64
|
}
|
|
48
65
|
}
|
|
66
|
+
// On Windows a bare "bash" can resolve to WSL's System32\bash.exe (see resolveBashExecutable), so
|
|
67
|
+
// the probe runs, and reports, the resolved absolute Git Bash path instead.
|
|
68
|
+
async function probeBash(warn) {
|
|
69
|
+
const resolution = await resolveBashExecutable({
|
|
70
|
+
platform: process.platform,
|
|
71
|
+
env: process.env,
|
|
72
|
+
gitExecPath: async () => (await execFileAsync("git", ["--exec-path"], { encoding: "utf8", timeout: 5_000 })).stdout,
|
|
73
|
+
});
|
|
74
|
+
if (resolution.warning)
|
|
75
|
+
warn(resolution.warning);
|
|
76
|
+
return resolution.executable ? probe(resolution.executable, ["--version"]) : unavailable("bash");
|
|
77
|
+
}
|
|
49
78
|
function unavailable(executable) {
|
|
50
79
|
return { available: false, executable, version: null };
|
|
51
80
|
}
|
|
@@ -89,5 +118,6 @@ export function emptyRunnerHostCapabilitySnapshot() {
|
|
|
89
118
|
playwrightProjects: [],
|
|
90
119
|
browserLaunch: false,
|
|
91
120
|
providerConnectivity: {},
|
|
121
|
+
testPostgres: { available: false, superuser: null },
|
|
92
122
|
};
|
|
93
123
|
}
|