@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.c3166221b6e7
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 +144 -3
- 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 +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -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 +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 +9 -0
- package/dist/bridge/bridge.service.d.ts +90 -14
- package/dist/bridge/bridge.service.js +436 -350
- package/dist/bridge/bridge.types.d.ts +21 -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 +17 -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 +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 +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 +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +152 -187
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -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 +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 +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 +75 -2
- package/dist/runtime/host-load-sampler.js +142 -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 +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 +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 +33 -2
- 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 +13 -1
- package/dist/runtime/prepared-runtime-readiness.js +63 -16
- 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 +10 -1
- package/dist/sandbox/runtime.js +47 -8
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -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 +2 -7
- package/dist/session/managed-attempt-tools.js +207 -121
- 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 +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -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 +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- 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 +12 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- 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 +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -11
- package/dist/session/phase-completion.runtime.js +91 -215
- 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 +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- 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 +3 -0
- package/dist/session/pre-publication-process.js +31 -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 +37 -21
- package/dist/session/pre-publication-validation.js +221 -182
- 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.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.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 +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +72 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +98 -173
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -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 +257 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +15 -2
- package/dist/session/session.service.js +242 -88
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +5 -5
- 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.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- 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 +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-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +34 -0
- package/dist/worktree/worktree-origin-sync.js +127 -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 +50 -0
- package/dist/worktree/worktree-wip.js +185 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +36 -5
- package/dist/worktree/worktree.service.js +124 -155
- package/dist/worktree/worktree.types.d.ts +38 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { RepositoryCoordinatorLock } from "../../sandbox/repository-lock.js";
|
|
4
4
|
import { GitClient } from "../../shared/git/git.js";
|
|
5
|
+
import { sandboxHostLoadGateFromEnvironment } from "../sandbox-host-capacity-gate.js";
|
|
5
6
|
import { buildSpecBody, selectLaneCommand } from "../../worktree/artifact-injector.js";
|
|
6
7
|
import { defaultWorktreeCoordinatorStateRoot } from "../../worktree/worktree-paths.js";
|
|
7
8
|
import { completionPhaseFromDispatch, prepareCompletionToolRuntime, readCompletionArtifact, usesDebugCycleCompletion, usesDevelopCycleCompletion } from "../phase-completion.js";
|
|
@@ -9,14 +10,14 @@ import { ForgeFailureError } from "../session.types.js";
|
|
|
9
10
|
import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtifact, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitDecomposeGateArtifacts, emitDraftGateArtifacts, emitPhaseCompletionEvent, emitPhaseGateEvents, emitQaArtifactRecorded, emitQaStructuredEvents, enforceQaBrowserLaunchTargetGate, LiveArchitectArtifactEmitter, LiveCompletionArtifactEmitter, LiveQaArtifactEmitter, readCompletionArtifactsForRun, readQaCompletionArtifactBundle, waitForCompletionArtifact } from "./provider-cli.artifacts.js";
|
|
10
11
|
import { diffClaimedChangedFiles, findUnpublishedWorktreePaths, normalizeChangedFilePath, stagePublishableWorktreeChangeSet, } from "../publishable-worktree-changes.js";
|
|
11
12
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
12
|
-
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
13
|
+
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch, shouldPipePromptToStdin, usesManagedWindowsHost } from "./provider-cli.prompts.js";
|
|
13
14
|
import { isTransientCodexProviderNotFoundFailure, providerCompletionToolMissingFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
14
|
-
import {
|
|
15
|
-
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
15
|
+
import { admitUserConfigIsolatedProvider, emitProviderUsageEvent, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
16
|
+
import { clip, clipTail, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
16
17
|
import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
|
|
17
18
|
import { assertRepairHeadEpoch } from "./provider-cli.repair-epoch.js";
|
|
18
|
-
import {
|
|
19
|
-
|
|
19
|
+
import { PrePublicationValidator } from "../pre-publication-validation.js";
|
|
20
|
+
import { prePublicationRepairTurnsFromEnvironment, prepareRepairTurnLaunch, validatePrePublicationWithRepair, } from "./pre-publication-repair.js";
|
|
20
21
|
const maxQaCompletionRecoveryTurns = 2;
|
|
21
22
|
function assertCommentRepairArtifactMatchesDispatch(dispatch, artifact) {
|
|
22
23
|
const pullRequest = dispatch.pullRequest;
|
|
@@ -212,18 +213,6 @@ async function pushWorktreeBranch(git, worktreePath, branchName, repoPath, coord
|
|
|
212
213
|
function providerOwnsBranchPublication(context) {
|
|
213
214
|
return context.dispatch.sandbox?.executionMode !== "docker";
|
|
214
215
|
}
|
|
215
|
-
function prePublicationExecution(context, environment, defaultRunner, baselineRevision) {
|
|
216
|
-
if (context.processRunner)
|
|
217
|
-
return { baselineRevision, environment, processRunner: context.processRunner };
|
|
218
|
-
if (context.dispatch.sandbox?.executionMode !== "docker")
|
|
219
|
-
return { baselineRevision, environment };
|
|
220
|
-
const expectedSandboxId = context.dispatch.sandbox.dispatchAttemptId;
|
|
221
|
-
const observedSandboxId = context.runtimeEnvironment?.FORGE_SANDBOX_ID ?? process.env.FORGE_SANDBOX_ID;
|
|
222
|
-
if (observedSandboxId !== expectedSandboxId) {
|
|
223
|
-
throw new ForgeFailureError("prepublication_execution_scope_invalid", `prepublication_execution_scope_invalid: Docker attempt ${expectedSandboxId} has no runner proven to execute inside that sandbox.`, "bridge");
|
|
224
|
-
}
|
|
225
|
-
return { baselineRevision, environment, processRunner: defaultRunner };
|
|
226
|
-
}
|
|
227
216
|
function remoteTrackingRefspec(branchName) {
|
|
228
217
|
return `refs/heads/${branchName}:refs/remotes/origin/${branchName}`;
|
|
229
218
|
}
|
|
@@ -258,11 +247,6 @@ function providerCliExitFailure(command, result) {
|
|
|
258
247
|
}
|
|
259
248
|
return new Error(`${command} exited ${result.exitCode}${suffix}`);
|
|
260
249
|
}
|
|
261
|
-
function clipTail(value, maximumLength) {
|
|
262
|
-
if (value.length <= maximumLength)
|
|
263
|
-
return value;
|
|
264
|
-
return `...${value.slice(-(maximumLength - 3))}`;
|
|
265
|
-
}
|
|
266
250
|
/**
|
|
267
251
|
* Capacity is trusted only when a nonzero provider process writes one of the
|
|
268
252
|
* narrow service-level messages to stderr. Stdout can contain arbitrary agent
|
|
@@ -432,7 +416,8 @@ export class ManagedVerificationProgressEmitter {
|
|
|
432
416
|
}
|
|
433
417
|
}
|
|
434
418
|
function isManagedVerificationNonterminal(status) {
|
|
435
|
-
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
419
|
+
return status === "starting" || status === "running" || status === "waiting_for_build_slot"
|
|
420
|
+
|| status === "waiting_for_host_capacity";
|
|
436
421
|
}
|
|
437
422
|
async function parseManagedVerificationSnapshot(receiptPath) {
|
|
438
423
|
try {
|
|
@@ -564,26 +549,32 @@ export class ProcessBackedProviderCliService {
|
|
|
564
549
|
providerToolHeartbeatIntervalMs;
|
|
565
550
|
publicationCoordinator;
|
|
566
551
|
prePublicationValidator;
|
|
567
|
-
|
|
552
|
+
prePublicationRepairTurns;
|
|
553
|
+
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator = new RepositoryCoordinatorLock(defaultWorktreeCoordinatorStateRoot()),
|
|
554
|
+
// The Docker sandbox worker (`forge` run-once via ForgeBridgeCliService) builds
|
|
555
|
+
// this default. A container cannot reach the host ledger, so when the host
|
|
556
|
+
// bridge enabled it, its steps ask the bridge for tokens over the sandbox
|
|
557
|
+
// channel (decision 0013); elsewhere the gate is absent and validation is ungated.
|
|
558
|
+
prePublicationValidator = new PrePublicationValidator(undefined, undefined, undefined, sandboxHostLoadGateFromEnvironment()), prePublicationRepairTurns = prePublicationRepairTurnsFromEnvironment()) {
|
|
568
559
|
this.processRunner = processRunner;
|
|
569
560
|
this.git = git;
|
|
570
561
|
this.providerToolHeartbeatIntervalMs = providerToolHeartbeatIntervalMs;
|
|
571
562
|
this.publicationCoordinator = publicationCoordinator;
|
|
572
563
|
this.prePublicationValidator = prePublicationValidator;
|
|
564
|
+
this.prePublicationRepairTurns = prePublicationRepairTurns;
|
|
573
565
|
}
|
|
574
566
|
async runDraft(context) {
|
|
575
|
-
const { dispatch } = context;
|
|
567
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
576
568
|
if (!dispatch.draft) {
|
|
577
569
|
throw new Error("Draft dispatch context is missing.");
|
|
578
570
|
}
|
|
579
|
-
const { worktree } = context;
|
|
580
571
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
581
572
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
582
573
|
await fs.writeFile(path.join(metadataRoot, "draft-input.json"), JSON.stringify(durableDraftInput(dispatch), null, 2) + "\n", "utf8");
|
|
583
574
|
await fs.writeFile(path.join(metadataRoot, "spec.md"), buildDraftSpec(dispatch), "utf8");
|
|
584
575
|
const stagedAttachments = await stageDraftAttachments(dispatch, metadataRoot);
|
|
585
576
|
const decomposeDraft = isDecomposeDraftDispatch(dispatch);
|
|
586
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment });
|
|
577
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
587
578
|
const draftPrompt = buildDraftPrompt(dispatch, { attachmentReferences: stagedAttachments.textReferences });
|
|
588
579
|
const providerPrompt = buildProviderCliPrompt(dispatch, draftPrompt, context.runtimeEnvironment);
|
|
589
580
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -751,7 +742,7 @@ export class ProcessBackedProviderCliService {
|
|
|
751
742
|
}
|
|
752
743
|
}
|
|
753
744
|
async runImplementation(context) {
|
|
754
|
-
const { dispatch, worktree } = context;
|
|
745
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
755
746
|
const validationBaselineRevision = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
756
747
|
const phase = completionPhaseFromDispatch(dispatch);
|
|
757
748
|
const developCycle = usesDevelopCycleCompletion(dispatch);
|
|
@@ -766,7 +757,7 @@ export class ProcessBackedProviderCliService {
|
|
|
766
757
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
767
758
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
768
759
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
769
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment });
|
|
760
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
770
761
|
const implementationPrompt = debugCycle
|
|
771
762
|
? buildDebugCyclePrompt(dispatch, phase)
|
|
772
763
|
: developCycle
|
|
@@ -831,9 +822,8 @@ export class ProcessBackedProviderCliService {
|
|
|
831
822
|
await liveCompletionEvents.stop();
|
|
832
823
|
await cleanupCompletionTools(completionTools, context.emit);
|
|
833
824
|
}
|
|
834
|
-
if (result.exitCode !== 0)
|
|
825
|
+
if (result.exitCode !== 0)
|
|
835
826
|
throw providerCliExitFailure(command.command, result);
|
|
836
|
-
}
|
|
837
827
|
await context.emit({
|
|
838
828
|
role: "runner",
|
|
839
829
|
kind: "checkpoint",
|
|
@@ -903,7 +893,7 @@ export class ProcessBackedProviderCliService {
|
|
|
903
893
|
};
|
|
904
894
|
}
|
|
905
895
|
async runArchitect(context) {
|
|
906
|
-
const { dispatch, worktree } = context;
|
|
896
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
907
897
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
908
898
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
909
899
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -914,7 +904,7 @@ export class ProcessBackedProviderCliService {
|
|
|
914
904
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
915
905
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
916
906
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "pending_approval", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
917
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment });
|
|
907
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
918
908
|
const architectPrompt = buildArchitectPrompt(dispatch);
|
|
919
909
|
const providerPrompt = buildProviderCliPrompt(dispatch, architectPrompt, context.runtimeEnvironment);
|
|
920
910
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -1008,7 +998,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1008
998
|
};
|
|
1009
999
|
}
|
|
1010
1000
|
async runQa(context) {
|
|
1011
|
-
const { dispatch, worktree } = context;
|
|
1001
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1012
1002
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
1013
1003
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
1014
1004
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -1019,7 +1009,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1019
1009
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1020
1010
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1021
1011
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
1022
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment });
|
|
1012
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
1023
1013
|
const qaPrompt = buildQaPrompt(dispatch, specBody);
|
|
1024
1014
|
const providerPrompt = buildProviderCliPrompt(dispatch, qaPrompt, context.runtimeEnvironment);
|
|
1025
1015
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -1133,12 +1123,13 @@ export class ProcessBackedProviderCliService {
|
|
|
1133
1123
|
return await this.runPullRequestRepair(context, "conflict_resolve");
|
|
1134
1124
|
}
|
|
1135
1125
|
async runPullRequestRepair(context, route) {
|
|
1136
|
-
const { dispatch, worktree } = context;
|
|
1126
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1137
1127
|
const { expectedRepairHeadSha, preparedHeadSha } = await assertRepairHeadEpoch(context, this.git);
|
|
1138
1128
|
const repairChecks = route === "ci_repair" || isPullRequestCheckRepairDispatch(dispatch);
|
|
1139
1129
|
const addressComments = !repairChecks && isPullRequestCommentsDispatch(dispatch);
|
|
1140
1130
|
let repairSpec = null;
|
|
1141
1131
|
let repairEnvironment = context.runtimeEnvironment;
|
|
1132
|
+
let ciRepairSpecPath = null;
|
|
1142
1133
|
let completionTools = null;
|
|
1143
1134
|
if (repairChecks) {
|
|
1144
1135
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
@@ -1149,6 +1140,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1149
1140
|
}
|
|
1150
1141
|
const specBody = buildSpecBody(laneCommand, dispatch.workItem, "ci_repair");
|
|
1151
1142
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1143
|
+
ciRepairSpecPath = specPath;
|
|
1152
1144
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1153
1145
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), `${JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" })}\n`, "utf8");
|
|
1154
1146
|
repairSpec = {
|
|
@@ -1160,7 +1152,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1160
1152
|
};
|
|
1161
1153
|
const readiness = await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, specPath, context.runtimeEnvironment);
|
|
1162
1154
|
repairEnvironment = readiness.environment;
|
|
1163
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1155
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1156
|
+
dispatch, worktree, phase: "ci_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1157
|
+
});
|
|
1164
1158
|
await context.emit({
|
|
1165
1159
|
role: "runner",
|
|
1166
1160
|
kind: "checkpoint",
|
|
@@ -1175,7 +1169,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1175
1169
|
});
|
|
1176
1170
|
}
|
|
1177
1171
|
if (addressComments) {
|
|
1178
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1172
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1173
|
+
dispatch, worktree, phase: "comment_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1174
|
+
});
|
|
1179
1175
|
await context.emit({
|
|
1180
1176
|
role: "runner",
|
|
1181
1177
|
kind: "checkpoint",
|
|
@@ -1299,6 +1295,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1299
1295
|
: addressComments
|
|
1300
1296
|
? "comment_repair"
|
|
1301
1297
|
: "conflict_repair";
|
|
1298
|
+
const readinessSpecPath = ciRepairSpecPath;
|
|
1302
1299
|
await this.validatePrePublicationWithRecovery({
|
|
1303
1300
|
context,
|
|
1304
1301
|
validationProfile,
|
|
@@ -1306,6 +1303,10 @@ export class ProcessBackedProviderCliService {
|
|
|
1306
1303
|
outputState,
|
|
1307
1304
|
preparedHeadSha,
|
|
1308
1305
|
repairScope: "pull_request",
|
|
1306
|
+
...(readinessSpecPath ? {
|
|
1307
|
+
// The readiness manifest records the attempt URLs; a restart must not leave it pointing at the old stack.
|
|
1308
|
+
onRuntimeEnvironmentRefreshed: async (runtimeEnvironment) => (await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, readinessSpecPath, runtimeEnvironment)).environment,
|
|
1309
|
+
} : {}),
|
|
1309
1310
|
});
|
|
1310
1311
|
const stagedChangeSet = await stagePublishableWorktreeChangeSet(this.git, worktree.worktreePath);
|
|
1311
1312
|
const stagedChangedFiles = stagedChangeSet.publishable;
|
|
@@ -1384,6 +1385,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1384
1385
|
worktree,
|
|
1385
1386
|
phase: "qa",
|
|
1386
1387
|
runtimeEnvironment: context.runtimeEnvironment,
|
|
1388
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1387
1389
|
});
|
|
1388
1390
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1389
1391
|
worktreePath: worktree.worktreePath,
|
|
@@ -1493,6 +1495,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1493
1495
|
worktree,
|
|
1494
1496
|
phase: "comment_repair",
|
|
1495
1497
|
runtimeEnvironment: repairEnvironment,
|
|
1498
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1496
1499
|
});
|
|
1497
1500
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1498
1501
|
worktreePath: worktree.worktreePath,
|
|
@@ -1572,141 +1575,75 @@ export class ProcessBackedProviderCliService {
|
|
|
1572
1575
|
return artifact;
|
|
1573
1576
|
}
|
|
1574
1577
|
async validatePrePublicationWithRecovery(options) {
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1578
|
+
const processRunner = recoveringProviderProcessRunner(options.context.processRunner ?? this.processRunner);
|
|
1579
|
+
await validatePrePublicationWithRepair(options, {
|
|
1580
|
+
validator: this.prePublicationValidator,
|
|
1581
|
+
defaultProcessRunner: this.processRunner,
|
|
1582
|
+
maxRepairTurns: this.prePublicationRepairTurns,
|
|
1583
|
+
runRepairTurn: async (turn) => await this.runPrePublicationRepairTurn(options, processRunner, turn),
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was.
|
|
1588
|
+
* The turn launches with its own Forge MCP server (prepareRepairTurnLaunch), removed when it exits.
|
|
1589
|
+
*/
|
|
1590
|
+
async runPrePublicationRepairTurn(options, processRunner, turn) {
|
|
1591
|
+
const { context, outputState, preparedHeadSha } = options;
|
|
1592
|
+
const { worktree } = context;
|
|
1593
|
+
const { repairTurn: nextRepairTurn, maxRepairTurns, environment } = turn;
|
|
1594
|
+
const { repairDispatch, providerPrompt, pipePromptToStdin, completionTools, command } = await prepareRepairTurnLaunch(context, turn);
|
|
1595
|
+
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1596
|
+
let result;
|
|
1597
|
+
let providerStarted = false;
|
|
1598
|
+
try {
|
|
1599
|
+
result = await processRunner.run({
|
|
1600
|
+
command: command.command,
|
|
1601
|
+
args: command.args,
|
|
1602
|
+
cwd: worktree.worktreePath,
|
|
1603
|
+
env: environment,
|
|
1604
|
+
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1605
|
+
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1606
|
+
}, {
|
|
1607
|
+
onStarted: async () => {
|
|
1584
1608
|
await context.emit({
|
|
1585
1609
|
role: "runner",
|
|
1586
1610
|
kind: "checkpoint",
|
|
1587
|
-
content: `
|
|
1588
|
-
eventType: "
|
|
1589
|
-
data: JSON.stringify({ repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1611
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} is supervised and ready.`,
|
|
1612
|
+
eventType: "provider_cli_started",
|
|
1590
1613
|
});
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1614
|
+
providerStarted = true;
|
|
1615
|
+
},
|
|
1616
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1617
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1618
|
+
onStdoutLine: async (line) => {
|
|
1619
|
+
await toolHeartbeat.consume(line);
|
|
1620
|
+
},
|
|
1621
|
+
}, context.signal);
|
|
1622
|
+
}
|
|
1623
|
+
finally {
|
|
1624
|
+
toolHeartbeat.stop();
|
|
1625
|
+
try {
|
|
1626
|
+
if (providerStarted) {
|
|
1598
1627
|
await context.emit({
|
|
1599
1628
|
role: "runner",
|
|
1600
|
-
kind: "
|
|
1601
|
-
content: `
|
|
1602
|
-
eventType: "
|
|
1603
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurns: repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1629
|
+
kind: "checkpoint",
|
|
1630
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} exited.`,
|
|
1631
|
+
eventType: "provider_cli_completed",
|
|
1604
1632
|
});
|
|
1605
|
-
throw error;
|
|
1606
|
-
}
|
|
1607
|
-
const providerThreadId = outputState.providerThreadId?.trim();
|
|
1608
|
-
if (!providerThreadId) {
|
|
1609
|
-
throw new Error(`prepublication_repair_unavailable: ${error.message}; provider did not report a resumable thread id, so Forge preserved the dirty worktree without starting a blind replacement run.`, { cause: error });
|
|
1610
|
-
}
|
|
1611
|
-
const nextRepairTurn = repairTurn + 1;
|
|
1612
|
-
const focusedPrompt = buildPrePublicationRepairPrompt(error, nextRepairTurn, repairScope);
|
|
1613
|
-
const repairDispatch = {
|
|
1614
|
-
...dispatch,
|
|
1615
|
-
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1616
|
-
};
|
|
1617
|
-
const providerPrompt = buildProviderCliPrompt(repairDispatch, focusedPrompt, repairEnvironment);
|
|
1618
|
-
const pipePromptToStdin = shouldPipePromptToStdin(repairDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(repairDispatch));
|
|
1619
|
-
const command = buildProviderCliCommand(repairDispatch, {
|
|
1620
|
-
worktreePath: worktree.worktreePath,
|
|
1621
|
-
prompt: focusedPrompt,
|
|
1622
|
-
promptFromStdin: pipePromptToStdin,
|
|
1623
|
-
runtimeEnvironment: repairEnvironment,
|
|
1624
|
-
});
|
|
1625
|
-
await context.emit({
|
|
1626
|
-
role: "runner",
|
|
1627
|
-
kind: "checkpoint",
|
|
1628
|
-
content: `Resuming ${dispatch.execution.provider} ${outputState.sessionLabel ?? "provider thread"} for bounded pre-publication repair ${nextRepairTurn}/${maxPrePublicationRepairTurns} after '${error.checkId}' failed.`,
|
|
1629
|
-
eventType: "prepublication_repair_started",
|
|
1630
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurn: nextRepairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1631
|
-
});
|
|
1632
|
-
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1633
|
-
let result;
|
|
1634
|
-
let providerStarted = false;
|
|
1635
|
-
try {
|
|
1636
|
-
result = await processRunner.run({
|
|
1637
|
-
command: command.command,
|
|
1638
|
-
args: command.args,
|
|
1639
|
-
cwd: worktree.worktreePath,
|
|
1640
|
-
env: environment,
|
|
1641
|
-
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1642
|
-
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1643
|
-
}, {
|
|
1644
|
-
onStarted: async () => {
|
|
1645
|
-
await context.emit({
|
|
1646
|
-
role: "runner",
|
|
1647
|
-
kind: "checkpoint",
|
|
1648
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} is supervised and ready.`,
|
|
1649
|
-
eventType: "provider_cli_started",
|
|
1650
|
-
});
|
|
1651
|
-
providerStarted = true;
|
|
1652
|
-
},
|
|
1653
|
-
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1654
|
-
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1655
|
-
onStdoutLine: async (line) => {
|
|
1656
|
-
await toolHeartbeat.consume(line);
|
|
1657
|
-
},
|
|
1658
|
-
}, context.signal);
|
|
1659
|
-
}
|
|
1660
|
-
finally {
|
|
1661
|
-
toolHeartbeat.stop();
|
|
1662
|
-
if (providerStarted) {
|
|
1663
|
-
await context.emit({
|
|
1664
|
-
role: "runner",
|
|
1665
|
-
kind: "checkpoint",
|
|
1666
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} exited.`,
|
|
1667
|
-
eventType: "provider_cli_completed",
|
|
1668
|
-
});
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
if (result.exitCode !== 0)
|
|
1672
|
-
throw providerCliExitFailure(command.command, result);
|
|
1673
|
-
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1674
|
-
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1675
|
-
throw new Error(`provider_publication_boundary_violation: pre-publication repair changed HEAD from ${preparedHeadSha} to ${postRepairHeadSha}; Forge requires provider changes to remain uncommitted and unpushed until validation passes.`, { cause: error });
|
|
1676
1633
|
}
|
|
1677
1634
|
}
|
|
1635
|
+
finally {
|
|
1636
|
+
await cleanupCompletionTools(completionTools, context.emit);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
if (result.exitCode !== 0)
|
|
1640
|
+
throw providerCliExitFailure(command.command, result);
|
|
1641
|
+
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1642
|
+
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1643
|
+
throw new Error(`provider_publication_boundary_violation: pre-publication repair changed HEAD from ${preparedHeadSha} to ${postRepairHeadSha}; Forge requires provider changes to remain uncommitted and unpushed until validation passes.`, { cause: turn.failure });
|
|
1678
1644
|
}
|
|
1679
1645
|
}
|
|
1680
1646
|
}
|
|
1681
|
-
function buildPrePublicationRepairPrompt(error, repairTurn, repairScope) {
|
|
1682
|
-
const invocation = [error.command, ...error.args].join(" ");
|
|
1683
|
-
const priorWork = repairScope === "implementation"
|
|
1684
|
-
? "Keep the completed implementation and its Forge-owned completion artifacts intact."
|
|
1685
|
-
: "Keep the existing PR-comment or CI repairs intact.";
|
|
1686
|
-
return [
|
|
1687
|
-
`Forge pre-publication validation failed after your ${repairScope === "implementation" ? "implementation" : "PR repair"} turn.`,
|
|
1688
|
-
`This is bounded in-place repair turn ${repairTurn}/${maxPrePublicationRepairTurns}.`,
|
|
1689
|
-
`Failed check: ${error.checkId}`,
|
|
1690
|
-
`Command: ${invocation}`,
|
|
1691
|
-
`Exit code: ${error.exitCode}`,
|
|
1692
|
-
"Diagnostics:",
|
|
1693
|
-
error.detail || "The validation command returned no diagnostic output.",
|
|
1694
|
-
"Fix the root cause in the current worktree and run the focused failing check.",
|
|
1695
|
-
`${priorWork} Do not commit, push, rebase, or modify Forge-owned protocol artifacts.`,
|
|
1696
|
-
"When the focused check passes, stop; Bridge will rerun the complete required pre-publication profile and owns commit/push.",
|
|
1697
|
-
].join("\n\n");
|
|
1698
|
-
}
|
|
1699
|
-
function publicationCapabilities(context, runtimeEnvironment) {
|
|
1700
|
-
const capabilities = new Set();
|
|
1701
|
-
const launchTarget = context.dispatch.qaBrowser?.launchTarget;
|
|
1702
|
-
if (runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG
|
|
1703
|
-
|| launchTarget?.url
|
|
1704
|
-
|| launchTarget?.command
|
|
1705
|
-
|| launchTarget?.managed_runtime_port) {
|
|
1706
|
-
capabilities.add("browser_launch");
|
|
1707
|
-
}
|
|
1708
|
-
return capabilities;
|
|
1709
|
-
}
|
|
1710
1647
|
async function stageDraftAttachments(dispatch, metadataRoot) {
|
|
1711
1648
|
const attachments = dispatch.draft?.attachments ?? [];
|
|
1712
1649
|
const stageable = attachments.filter((attachment) => (attachment.kind === "text" && typeof attachment.textContent === "string")
|
|
@@ -1768,18 +1705,6 @@ function clipFileName(fileName, maxLength) {
|
|
|
1768
1705
|
const maxStemLength = Math.max(1, maxLength - extension.length);
|
|
1769
1706
|
return `${stem.slice(0, maxStemLength)}${extension}`;
|
|
1770
1707
|
}
|
|
1771
|
-
const providerPromptStdinThreshold = 8_000;
|
|
1772
|
-
function shouldPipePromptToStdin(provider, prompt, force = false) {
|
|
1773
|
-
const normalized = provider.trim().toLowerCase();
|
|
1774
|
-
if (normalized === "claude") {
|
|
1775
|
-
return true;
|
|
1776
|
-
}
|
|
1777
|
-
return normalized === "codex"
|
|
1778
|
-
&& (force || Buffer.byteLength(prompt, "utf8") > providerPromptStdinThreshold);
|
|
1779
|
-
}
|
|
1780
|
-
function usesManagedWindowsHost(dispatch) {
|
|
1781
|
-
return process.platform === "win32" && dispatch.sandbox?.executionMode === "host";
|
|
1782
|
-
}
|
|
1783
1708
|
function isFakeWorkerModel(model) {
|
|
1784
1709
|
return model.trim().toLowerCase() === fakeWorkerModel;
|
|
1785
1710
|
}
|
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
import type { RunOnceDispatchPacket, RunnerDispatchArtifact, RunnerDispatchEvent, RunnerDispatchSpec } from "../session.types.js";
|
|
2
2
|
import type { WorktreeHandle } from "../../worktree/worktree.types.js";
|
|
3
3
|
import type { ProviderProcessRunner } from "./provider-cli.process.js";
|
|
4
|
+
/**
|
|
5
|
+
* Why the attempt's runtime stack restarted before a validation pass. The first cause that applies:
|
|
6
|
+
* a previous restart did not complete; the workspace state could not be compared with the stack's
|
|
7
|
+
* (either reading was unavailable); or the workspace changed since the stack was launched.
|
|
8
|
+
*/
|
|
9
|
+
export type RuntimeRestartReason = "previous_restart_incomplete" | "fingerprint_unavailable" | "workspace_changed";
|
|
10
|
+
export interface RuntimeEnvironmentRefresh {
|
|
11
|
+
/** The restarted stack's runtime environment. */
|
|
12
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
13
|
+
readonly reason: RuntimeRestartReason;
|
|
14
|
+
/** What changed in the workspace since the stack was launched, when both states could be read. */
|
|
15
|
+
readonly changes: readonly string[];
|
|
16
|
+
}
|
|
4
17
|
export interface ProviderCliRunContext {
|
|
5
18
|
readonly dispatch: RunOnceDispatchPacket;
|
|
6
19
|
readonly worktree: WorktreeHandle;
|
|
7
20
|
readonly runtimeEnvironment?: Readonly<Record<string, string>>;
|
|
21
|
+
/** Host load governor variables for the completion MCP server only (decision 0013). */
|
|
22
|
+
readonly hostLoadEnvironment?: Readonly<Record<string, string>>;
|
|
8
23
|
readonly processRunner?: ProviderProcessRunner;
|
|
9
24
|
readonly signal?: AbortSignal;
|
|
25
|
+
/**
|
|
26
|
+
* Restarts the attempt's host runtime stack when the workspace changed since it was
|
|
27
|
+
* launched (an uncommitted edit, an in-progress merge), so validation and repair
|
|
28
|
+
* turns run against the current source. Resolves to the refreshed runtime
|
|
29
|
+
* environment and why the stack restarted, or null when the stack is current or
|
|
30
|
+
* there is no configured project.
|
|
31
|
+
*/
|
|
32
|
+
refreshRuntimeEnvironment?(signal?: AbortSignal): Promise<RuntimeEnvironmentRefresh | null>;
|
|
33
|
+
/**
|
|
34
|
+
* The runtime environment keys that name the configured project's live stack (its URLs and
|
|
35
|
+
* ports). A failed restart withholds them from the repair turn, since the stack is down.
|
|
36
|
+
*/
|
|
37
|
+
readonly runtimeStackEnvironmentKeys?: readonly string[];
|
|
10
38
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
11
39
|
}
|
|
12
40
|
export interface ProviderCliDraftContext {
|
|
13
41
|
readonly dispatch: RunOnceDispatchPacket;
|
|
14
42
|
readonly worktree: WorktreeHandle;
|
|
15
43
|
readonly runtimeEnvironment?: Readonly<Record<string, string>>;
|
|
44
|
+
/** Host load governor variables for the completion MCP server only (decision 0013). */
|
|
45
|
+
readonly hostLoadEnvironment?: Readonly<Record<string, string>>;
|
|
16
46
|
readonly processRunner?: ProviderProcessRunner;
|
|
17
47
|
readonly signal?: AbortSignal;
|
|
18
48
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Windows environment a provider child (and every tool it runs, such as dotnet and pwsh)
|
|
3
|
+
* gets from the Bridge. Provider children start from an allowlist, not the Bridge's whole
|
|
4
|
+
* environment, so each variable Windows tools expect must be listed here or defaulted below.
|
|
5
|
+
*/
|
|
6
|
+
export declare const windowsAllowedProviderParentEnvNames: readonly ["SystemRoot", "SystemDrive", "ComSpec", "PATHEXT", "APPDATA", "LOCALAPPDATA", "USERNAME", "USERDOMAIN", "HOMEDRIVE", "HOMEPATH", "ProgramData", "ProgramFiles", "ProgramFiles(x86)", "ProgramW6432", "PROCESSOR_ARCHITECTURE", "PROCESSOR_IDENTIFIER", "NUMBER_OF_PROCESSORS", "ALLUSERSPROFILE", "PUBLIC", "CommonProgramFiles", "CommonProgramFiles(x86)", "CommonProgramW6432", "OS", "windir", "DOTNET_ROOT", "DOTNET_ROOT(x86)", "DOTNET_CLI_HOME", "NUGET_PACKAGES", "NUGET_HTTP_CACHE_PATH", "CLAUDE_CODE_GIT_BASH_PATH"];
|
|
7
|
+
/** Fills in the Windows system, machine, profile and .NET variables a provider child needs. */
|
|
8
|
+
export declare function normalizeWindowsProviderEnvironment(env: NodeJS.ProcessEnv, parentEnv: NodeJS.ProcessEnv, homeDir: string, arch: string): void;
|
|
9
|
+
/** A case-insensitive, non-blank environment lookup (Windows variable names ignore case). */
|
|
10
|
+
export declare function readEnvironmentValue(env: NodeJS.ProcessEnv, name: string): string | undefined;
|