@loucompanion/forge-bridge 0.1.4-dev.f22f5e3d01fe → 0.2.1-dev.0f07274d438b
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 +128 -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 +27 -3
- package/dist/bridge/bridge-chat-provider-command.js +131 -26
- 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.service.d.ts +29 -12
- package/dist/bridge/bridge.service.js +215 -380
- package/dist/bridge/bridge.types.d.ts +21 -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/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.js +14 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -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 +11 -1
- package/dist/cleanup/cleanup.service.js +80 -62
- package/dist/cleanup/cleanup.types.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.js +9 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +2 -0
- package/dist/cleanup/host-runtime-ledger.js +30 -9
- package/dist/cli/cli.help.js +57 -13
- package/dist/cli/cli.service.d.ts +3 -10
- package/dist/cli/cli.service.js +20 -213
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +14 -1
- package/dist/cli/local-config.js +42 -2
- 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 +104 -26
- 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-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +5 -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 +13 -0
- package/dist/runtime/host-load-child-environment.js +35 -1
- package/dist/runtime/host-load-governor-config.d.ts +33 -3
- package/dist/runtime/host-load-governor-config.js +24 -3
- package/dist/runtime/host-load-governor.d.ts +91 -2
- package/dist/runtime/host-load-governor.js +217 -18
- package/dist/runtime/host-load-ledger-lock.js +6 -4
- 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.js +4 -2
- package/dist/runtime/host-load-sampler.d.ts +25 -1
- package/dist/runtime/host-load-sampler.js +38 -7
- package/dist/runtime/host-load-step-run.d.ts +37 -3
- package/dist/runtime/host-load-step-run.js +63 -7
- package/dist/runtime/host-load-test-slot.d.ts +3 -0
- package/dist/runtime/host-load-test-slot.js +26 -7
- package/dist/runtime/host-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +35 -5
- package/dist/runtime/host-runtime-lease.d.ts +28 -3
- package/dist/runtime/host-runtime-lease.js +140 -296
- 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 +78 -2
- package/dist/runtime/host-runtime-promotion.js +307 -14
- 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/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 +4 -0
- package/dist/runtime/runner-settings.js +22 -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 +3 -1
- package/dist/sandbox/host-capacity-broker.js +4 -2
- 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 +1 -2
- package/dist/sandbox/runtime.js +9 -19
- 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/managed-attempt-tools.d.ts +0 -7
- package/dist/session/managed-attempt-tools.js +54 -109
- 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 +10 -5
- package/dist/session/managed-command-host-load.js +18 -14
- 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 +2 -17
- package/dist/session/phase-completion.artifacts.js +65 -166
- package/dist/session/phase-completion.d.ts +27 -2
- package/dist/session/phase-completion.helpers.js +5 -53
- package/dist/session/phase-completion.js +15 -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 +14 -0
- package/dist/session/phase-completion.runtime.d.ts +8 -9
- package/dist/session/phase-completion.runtime.js +65 -196
- package/dist/session/phase-completion.schemas.js +12 -2
- package/dist/session/phase-completion.validation.d.ts +1 -0
- package/dist/session/phase-completion.validation.js +9 -1
- 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.js +6 -5
- 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-process.js +13 -12
- package/dist/session/pre-publication-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +9 -4
- package/dist/session/pre-publication-validation.js +62 -65
- package/dist/session/provider-cli/claude-background-work.d.ts +3 -2
- package/dist/session/provider-cli/claude-background-work.js +4 -3
- 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 +16 -0
- package/dist/session/provider-cli/pre-publication-repair.js +41 -3
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +4 -2
- 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 +2 -14
- package/dist/session/provider-cli/provider-cli.process.js +4 -94
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +13 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +137 -84
- 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 +37 -2
- 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 +15 -18
- package/dist/session/provider-cli/provider-cli.service.js +59 -190
- package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
- 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-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 +22 -1
- package/dist/session/sandbox-host-capacity-gate.js +63 -22
- 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.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 +8 -1
- package/dist/session/session.service.js +177 -239
- package/dist/session/session.types.d.ts +5 -0
- package/dist/session/session.types.js +9 -79
- 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/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 +13 -1
- package/dist/shared/process/host-process-supervisor.js +66 -14
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +18 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- 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 +49 -5
- package/dist/worktree/worktree.service.js +223 -187
- package/dist/worktree/worktree.types.d.ts +47 -0
- package/package.json +1 -1
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
import { GitClient } from "../../shared/git/git.js";
|
|
2
|
-
import type { WorktreeLifecycleCoordinator } from "../../worktree/worktree.base.js";
|
|
3
2
|
import { type RunnerDispatchEvent } from "../session.types.js";
|
|
4
3
|
import type { ProviderCliService } from "./provider-cli.base.js";
|
|
5
4
|
import type { ProviderCliDraftContext, ProviderCliRunContext, ProviderCliRunResult } from "./provider-cli.types.js";
|
|
6
|
-
import { type ProviderProcessRunner
|
|
5
|
+
import { type ProviderProcessRunner } from "./provider-cli.process.js";
|
|
6
|
+
import { type WorktreeLifecycleCoordinator } from "./provider-cli.service-support.js";
|
|
7
7
|
import { PrePublicationValidator } from "../pre-publication-validation.js";
|
|
8
8
|
export { parseClaudeMcpToolName } from "./provider-output-state.js";
|
|
9
9
|
export { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
10
10
|
export { buildProviderCliCommand, codexSandboxModeForPlatform, formatProviderCliCommand, formatProviderCliCommandForCheckpoint } from "./provider-cli.prompts.js";
|
|
11
11
|
export { buildProviderChildEnvironment, chooseWindowsCommandCandidate, resolveCodexNpmDirectLaunch, resolveClaudeNpmDirectLaunch, resolvePackageManagerDirectLaunch, resolveWindowsCommandFromPath, PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS, CodexModelsCacheRecoveringProcessRunner, CodexResumeRecoveringProcessRunner, isTransientCodexProviderNotFoundFailure, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
12
|
+
export { isProviderCapacityFailure, isProviderConfigurationFailure, isProviderContextWindowExhausted } from "./provider-cli.service-support.js";
|
|
12
13
|
export { buildWindowsLaunchCommand } from "../../shared/process/windows-launch.js";
|
|
13
14
|
export type { ProviderCliCommand, ProviderProcessRunner, ProviderProcessRunRequest, ProviderProcessRunResult } from "./provider-cli.process.js";
|
|
14
|
-
/**
|
|
15
|
-
* Capacity is trusted only when a nonzero provider process writes one of the
|
|
16
|
-
* narrow service-level messages to stderr. Stdout can contain arbitrary agent
|
|
17
|
-
* command output and account usage-limit messages remain ordinary failures.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isProviderCapacityFailure(result: ProviderProcessRunResult): boolean;
|
|
20
|
-
/** Only a nonzero Codex service diagnostic can classify a configuration rejection.
|
|
21
|
-
* JSONL turn.failed is a provider envelope; item/tool output is not retry authority. */
|
|
22
|
-
export declare function isProviderConfigurationFailure(command: string, result: ProviderProcessRunResult): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* A context limit is trusted only at the provider process boundary. The exact
|
|
25
|
-
* Codex message can be embedded in its JSONL stderr envelope, so substring
|
|
26
|
-
* matching is intentional but remains narrow and stderr-only.
|
|
27
|
-
*/
|
|
28
|
-
export declare function isProviderContextWindowExhausted(command: string, result: ProviderProcessRunResult): boolean;
|
|
29
15
|
export declare class ManagedVerificationProgressEmitter {
|
|
30
16
|
private readonly logDirectory;
|
|
31
17
|
private readonly emit;
|
|
@@ -47,6 +33,7 @@ export declare class RoutingProviderCliService implements ProviderCliService {
|
|
|
47
33
|
runArchitect(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
48
34
|
runCiRepair(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
49
35
|
runConflictResolve(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
36
|
+
runPrReview(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
50
37
|
runQa(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
51
38
|
runDraft(context: ProviderCliDraftContext): Promise<ProviderCliRunResult>;
|
|
52
39
|
}
|
|
@@ -65,9 +52,19 @@ export declare class ProcessBackedProviderCliService implements ProviderCliServi
|
|
|
65
52
|
runCiRepair(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
66
53
|
runConflictResolve(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
67
54
|
private runPullRequestRepair;
|
|
55
|
+
/**
|
|
56
|
+
* Review-only session for a pull request head. Never routed through implementation: the worktree
|
|
57
|
+
* is detached at the dispatched head, the provider cannot change or publish anything, and the
|
|
58
|
+
* review is handed to Forge only through the completion tool. No commit, push or GitHub call
|
|
59
|
+
* is made here; a worktree that differs after the session fails with `guardrail_violation`.
|
|
60
|
+
*/
|
|
61
|
+
runPrReview(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
|
|
68
62
|
private recoverMissingQaCompletion;
|
|
69
63
|
private recoverMissingCommentRepairCompletion;
|
|
70
64
|
private validatePrePublicationWithRecovery;
|
|
71
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was.
|
|
67
|
+
* The turn launches with its own Forge MCP server (prepareRepairTurnLaunch), removed when it exits.
|
|
68
|
+
*/
|
|
72
69
|
private runPrePublicationRepairTurn;
|
|
73
70
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { RepositoryCoordinatorLock } from "../../sandbox/repository-lock.js";
|
|
4
3
|
import { GitClient } from "../../shared/git/git.js";
|
|
5
4
|
import { sandboxHostLoadGateFromEnvironment } from "../sandbox-host-capacity-gate.js";
|
|
6
5
|
import { buildSpecBody, selectLaneCommand } from "../../worktree/artifact-injector.js";
|
|
7
|
-
import { defaultWorktreeCoordinatorStateRoot } from "../../worktree/worktree-paths.js";
|
|
8
6
|
import { completionPhaseFromDispatch, prepareCompletionToolRuntime, readCompletionArtifact, usesDebugCycleCompletion, usesDevelopCycleCompletion } from "../phase-completion.js";
|
|
9
7
|
import { ForgeFailureError } from "../session.types.js";
|
|
10
8
|
import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtifact, emitArchitectStructuredEvents, emitCompletionArtifactRecorded, emitDecomposeGateArtifacts, emitDraftGateArtifacts, emitPhaseCompletionEvent, emitPhaseGateEvents, emitQaArtifactRecorded, emitQaStructuredEvents, enforceQaBrowserLaunchTargetGate, LiveArchitectArtifactEmitter, LiveCompletionArtifactEmitter, LiveQaArtifactEmitter, readCompletionArtifactsForRun, readQaCompletionArtifactBundle, waitForCompletionArtifact } from "./provider-cli.artifacts.js";
|
|
11
9
|
import { diffClaimedChangedFiles, findUnpublishedWorktreePaths, normalizeChangedFilePath, stagePublishableWorktreeChangeSet, } from "../publishable-worktree-changes.js";
|
|
12
10
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
13
|
-
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
14
|
-
import {
|
|
15
|
-
import { emitProviderUsageEvent, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
16
|
-
import {
|
|
11
|
+
import { buildArchitectPrompt, buildConflictResolvePrompt, withReapplyConflictInstruction, withRemainingReapplyConflictInstruction, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch, shouldPipePromptToStdin, usesManagedWindowsHost } from "./provider-cli.prompts.js";
|
|
12
|
+
import { providerCompletionToolMissingFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
13
|
+
import { admitUserConfigIsolatedProvider, emitProviderUsageEvent, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
14
|
+
import { defaultPublicationCoordinator, ProviderToolActivityHeartbeat, providerCliExitFailure, } from "./provider-cli.service-support.js";
|
|
15
|
+
import { runPrReviewSession } from "./provider-cli.pr-review.js";
|
|
16
|
+
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
17
17
|
import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
|
|
18
18
|
import { assertRepairHeadEpoch } from "./provider-cli.repair-epoch.js";
|
|
19
19
|
import { PrePublicationValidator } from "../pre-publication-validation.js";
|
|
20
|
-
import { prePublicationRepairTurnsFromEnvironment, validatePrePublicationWithRepair, } from "./pre-publication-repair.js";
|
|
20
|
+
import { prePublicationRepairTurnsFromEnvironment, prepareRepairTurnLaunch, validatePrePublicationWithRepair, } from "./pre-publication-repair.js";
|
|
21
21
|
const maxQaCompletionRecoveryTurns = 2;
|
|
22
22
|
function assertCommentRepairArtifactMatchesDispatch(dispatch, artifact) {
|
|
23
23
|
const pullRequest = dispatch.pullRequest;
|
|
@@ -160,6 +160,7 @@ export { parseClaudeMcpToolName } from "./provider-output-state.js";
|
|
|
160
160
|
export { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
161
161
|
export { buildProviderCliCommand, codexSandboxModeForPlatform, formatProviderCliCommand, formatProviderCliCommandForCheckpoint } from "./provider-cli.prompts.js";
|
|
162
162
|
export { buildProviderChildEnvironment, chooseWindowsCommandCandidate, resolveCodexNpmDirectLaunch, resolveClaudeNpmDirectLaunch, resolvePackageManagerDirectLaunch, resolveWindowsCommandFromPath, PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS, CodexModelsCacheRecoveringProcessRunner, CodexResumeRecoveringProcessRunner, isTransientCodexProviderNotFoundFailure, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
163
|
+
export { isProviderCapacityFailure, isProviderConfigurationFailure, isProviderContextWindowExhausted } from "./provider-cli.service-support.js";
|
|
163
164
|
export { buildWindowsLaunchCommand } from "../../shared/process/windows-launch.js";
|
|
164
165
|
async function pushWorktreeBranch(git, worktreePath, branchName, repoPath, coordinator, signal, emit, expectedRemoteHeadSha) {
|
|
165
166
|
return await coordinator.withLock(repoPath, async () => {
|
|
@@ -227,88 +228,6 @@ function isNonFastForwardPushError(err) {
|
|
|
227
228
|
function errorMessage(err) {
|
|
228
229
|
return err instanceof Error ? err.message : String(err);
|
|
229
230
|
}
|
|
230
|
-
function providerCliExitFailure(command, result) {
|
|
231
|
-
const output = [result.stderr.trim(), result.stdout.trim()]
|
|
232
|
-
.filter(value => value.length > 0)
|
|
233
|
-
.join("\n");
|
|
234
|
-
const detail = clipTail(output, 1200);
|
|
235
|
-
const suffix = detail ? `: ${detail}` : "";
|
|
236
|
-
if (isProviderConfigurationFailure(command, result)) {
|
|
237
|
-
return new ForgeFailureError("provider_configuration_invalid", `${command} rejected its model configuration; correct the configuration before retrying${suffix}`, "provider");
|
|
238
|
-
}
|
|
239
|
-
if (isTransientCodexProviderNotFoundFailure(command, result)) {
|
|
240
|
-
return new ForgeFailureError("provider_request_not_found", `${command} received a transient not-found response from its provider service${suffix}`, "provider");
|
|
241
|
-
}
|
|
242
|
-
if (isProviderCapacityFailure(result)) {
|
|
243
|
-
return new ForgeFailureError("provider_capacity_unavailable", `${command} was deferred because the selected provider model is temporarily at capacity${suffix}`, "provider");
|
|
244
|
-
}
|
|
245
|
-
if (isProviderContextWindowExhausted(command, result)) {
|
|
246
|
-
return new ForgeFailureError("provider_context_window_exhausted", `${command} exhausted the provider context window and must continue in a fresh session${suffix}`, "provider");
|
|
247
|
-
}
|
|
248
|
-
return new Error(`${command} exited ${result.exitCode}${suffix}`);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Capacity is trusted only when a nonzero provider process writes one of the
|
|
252
|
-
* narrow service-level messages to stderr. Stdout can contain arbitrary agent
|
|
253
|
-
* command output and account usage-limit messages remain ordinary failures.
|
|
254
|
-
*/
|
|
255
|
-
export function isProviderCapacityFailure(result) {
|
|
256
|
-
if (result.exitCode === 0)
|
|
257
|
-
return false;
|
|
258
|
-
const capacityMessages = new Set([
|
|
259
|
-
"the selected model is at capacity. please try again later.",
|
|
260
|
-
"the selected model is currently at capacity. please try again later.",
|
|
261
|
-
"the model is currently overloaded. please try again later.",
|
|
262
|
-
"the provider is currently overloaded. please try again later.",
|
|
263
|
-
]);
|
|
264
|
-
return result.stderr
|
|
265
|
-
.split(/\r?\n/u)
|
|
266
|
-
.map(line => line.trim().toLowerCase().replace(/^error:\s*/u, ""))
|
|
267
|
-
.some(line => capacityMessages.has(line));
|
|
268
|
-
}
|
|
269
|
-
/** Only a nonzero Codex service diagnostic can classify a configuration rejection.
|
|
270
|
-
* JSONL turn.failed is a provider envelope; item/tool output is not retry authority. */
|
|
271
|
-
export function isProviderConfigurationFailure(command, result) {
|
|
272
|
-
const names = [path.posix.parse(command).name, path.win32.parse(command).name];
|
|
273
|
-
if (result.exitCode === 0 || !names.some(name => name.toLowerCase() === "codex"))
|
|
274
|
-
return false;
|
|
275
|
-
const reasoningRejected = /Unsupported value: '[^'\r\n]+' is not supported with the '[^'\r\n]+' model\./u.test(result.stderr)
|
|
276
|
-
&& result.stderr.includes("reasoning.effort")
|
|
277
|
-
&& result.stderr.includes("invalid_request_error")
|
|
278
|
-
&& result.stderr.includes("unsupported_value");
|
|
279
|
-
if (reasoningRejected)
|
|
280
|
-
return true;
|
|
281
|
-
return [result.stderr, result.stdout].some(output => output.split(/\r?\n/u).some(line => {
|
|
282
|
-
try {
|
|
283
|
-
const event = JSON.parse(line);
|
|
284
|
-
if (event.type !== "turn.failed")
|
|
285
|
-
return false;
|
|
286
|
-
const error = event.error;
|
|
287
|
-
if (typeof error?.message !== "string")
|
|
288
|
-
return false;
|
|
289
|
-
const service = JSON.parse(error.message);
|
|
290
|
-
return service.type === "error" && service.status === 400
|
|
291
|
-
&& service.error?.type === "invalid_request_error"
|
|
292
|
-
&& typeof service.error.message === "string"
|
|
293
|
-
&& /^The '[^'\r\n]+' model is not supported when using Codex with a ChatGPT account\.$/u.test(service.error.message);
|
|
294
|
-
}
|
|
295
|
-
catch {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
}));
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* A context limit is trusted only at the provider process boundary. The exact
|
|
302
|
-
* Codex message can be embedded in its JSONL stderr envelope, so substring
|
|
303
|
-
* matching is intentional but remains narrow and stderr-only.
|
|
304
|
-
*/
|
|
305
|
-
export function isProviderContextWindowExhausted(command, result) {
|
|
306
|
-
const executableNames = [path.posix.parse(command).name, path.win32.parse(command).name]
|
|
307
|
-
.map(name => name.toLowerCase());
|
|
308
|
-
if (result.exitCode === 0 || !executableNames.includes("codex"))
|
|
309
|
-
return false;
|
|
310
|
-
return result.stderr.toLowerCase().includes("codex ran out of room in the model's context window");
|
|
311
|
-
}
|
|
312
231
|
const defaultProviderToolHeartbeatIntervalMs = 60_000;
|
|
313
232
|
const defaultManagedVerificationProgressIntervalMs = 30_000;
|
|
314
233
|
function compareManagedVerificationSnapshots(left, right) {
|
|
@@ -452,58 +371,6 @@ function formatElapsed(milliseconds) {
|
|
|
452
371
|
const minutes = Math.floor(seconds / 60);
|
|
453
372
|
return minutes > 0 ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
|
|
454
373
|
}
|
|
455
|
-
class ProviderToolActivityHeartbeat {
|
|
456
|
-
outputState;
|
|
457
|
-
emit;
|
|
458
|
-
intervalMs;
|
|
459
|
-
timer = null;
|
|
460
|
-
/** Lets the provider runner hold its end-of-turn timers while a tool call is in flight. */
|
|
461
|
-
isToolCallInFlight = () => this.outputState.hasActiveToolCall;
|
|
462
|
-
/** Forgets tool calls a previous generation left open; called before every relaunch. */
|
|
463
|
-
startGeneration = () => this.outputState.resetActiveToolCalls();
|
|
464
|
-
constructor(outputState, emit, intervalMs) {
|
|
465
|
-
this.outputState = outputState;
|
|
466
|
-
this.emit = emit;
|
|
467
|
-
this.intervalMs = intervalMs;
|
|
468
|
-
// Each heartbeat watches one provider generation. Calls an earlier generation left
|
|
469
|
-
// open died with it; inheriting them would hold the new generation's timers forever.
|
|
470
|
-
this.outputState.resetActiveToolCalls();
|
|
471
|
-
}
|
|
472
|
-
async consume(line) {
|
|
473
|
-
const events = this.outputState.consume(line);
|
|
474
|
-
this.sync();
|
|
475
|
-
for (const event of events) {
|
|
476
|
-
await this.emit(event);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
stop() {
|
|
480
|
-
if (this.timer) {
|
|
481
|
-
clearInterval(this.timer);
|
|
482
|
-
this.timer = null;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
sync() {
|
|
486
|
-
if (!this.outputState.hasActiveToolCall) {
|
|
487
|
-
this.stop();
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
if (this.timer) {
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
this.timer = setInterval(() => {
|
|
494
|
-
if (!this.outputState.hasActiveToolCall) {
|
|
495
|
-
this.stop();
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
void this.emit({
|
|
499
|
-
role: "runner",
|
|
500
|
-
kind: "status",
|
|
501
|
-
content: "A supervised provider tool is still running.",
|
|
502
|
-
eventType: "provider_tool_heartbeat",
|
|
503
|
-
}).catch(() => undefined);
|
|
504
|
-
}, Math.max(1, this.intervalMs));
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
374
|
const fakeWorkerModel = "server-local-fake-worker";
|
|
508
375
|
export class RoutingProviderCliService {
|
|
509
376
|
realProvider;
|
|
@@ -532,6 +399,11 @@ export class RoutingProviderCliService {
|
|
|
532
399
|
? await this.deterministicProvider.runConflictResolve(context)
|
|
533
400
|
: await this.realProvider.runConflictResolve(context);
|
|
534
401
|
}
|
|
402
|
+
async runPrReview(context) {
|
|
403
|
+
return isFakeWorkerModel(context.dispatch.execution.model)
|
|
404
|
+
? await this.deterministicProvider.runPrReview(context)
|
|
405
|
+
: await this.realProvider.runPrReview(context);
|
|
406
|
+
}
|
|
535
407
|
async runQa(context) {
|
|
536
408
|
return isFakeWorkerModel(context.dispatch.execution.model)
|
|
537
409
|
? await this.deterministicProvider.runQa(context)
|
|
@@ -550,7 +422,7 @@ export class ProcessBackedProviderCliService {
|
|
|
550
422
|
publicationCoordinator;
|
|
551
423
|
prePublicationValidator;
|
|
552
424
|
prePublicationRepairTurns;
|
|
553
|
-
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator =
|
|
425
|
+
constructor(processRunner = new StreamingProviderProcessRunner(), git = new GitClient(), providerToolHeartbeatIntervalMs = defaultProviderToolHeartbeatIntervalMs, publicationCoordinator = defaultPublicationCoordinator(),
|
|
554
426
|
// The Docker sandbox worker (`forge` run-once via ForgeBridgeCliService) builds
|
|
555
427
|
// this default. A container cannot reach the host ledger, so when the host
|
|
556
428
|
// bridge enabled it, its steps ask the bridge for tokens over the sandbox
|
|
@@ -564,11 +436,10 @@ export class ProcessBackedProviderCliService {
|
|
|
564
436
|
this.prePublicationRepairTurns = prePublicationRepairTurns;
|
|
565
437
|
}
|
|
566
438
|
async runDraft(context) {
|
|
567
|
-
const { dispatch } = context;
|
|
439
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
568
440
|
if (!dispatch.draft) {
|
|
569
441
|
throw new Error("Draft dispatch context is missing.");
|
|
570
442
|
}
|
|
571
|
-
const { worktree } = context;
|
|
572
443
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
573
444
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
574
445
|
await fs.writeFile(path.join(metadataRoot, "draft-input.json"), JSON.stringify(durableDraftInput(dispatch), null, 2) + "\n", "utf8");
|
|
@@ -743,7 +614,7 @@ export class ProcessBackedProviderCliService {
|
|
|
743
614
|
}
|
|
744
615
|
}
|
|
745
616
|
async runImplementation(context) {
|
|
746
|
-
const { dispatch, worktree } = context;
|
|
617
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
747
618
|
const validationBaselineRevision = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
748
619
|
const phase = completionPhaseFromDispatch(dispatch);
|
|
749
620
|
const developCycle = usesDevelopCycleCompletion(dispatch);
|
|
@@ -759,11 +630,11 @@ export class ProcessBackedProviderCliService {
|
|
|
759
630
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
760
631
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
761
632
|
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
762
|
-
const implementationPrompt = debugCycle
|
|
633
|
+
const implementationPrompt = withReapplyConflictInstruction(debugCycle
|
|
763
634
|
? buildDebugCyclePrompt(dispatch, phase)
|
|
764
635
|
: developCycle
|
|
765
636
|
? buildDevelopCyclePrompt(dispatch, phase)
|
|
766
|
-
: buildImplementationPrompt(dispatch, phase);
|
|
637
|
+
: buildImplementationPrompt(dispatch, phase), context.reapplyConflicts, context.projectStartDeferred);
|
|
767
638
|
const providerPrompt = buildProviderCliPrompt(dispatch, implementationPrompt, context.runtimeEnvironment);
|
|
768
639
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
769
640
|
const command = buildProviderCliCommand(dispatch, {
|
|
@@ -894,7 +765,7 @@ export class ProcessBackedProviderCliService {
|
|
|
894
765
|
};
|
|
895
766
|
}
|
|
896
767
|
async runArchitect(context) {
|
|
897
|
-
const { dispatch, worktree } = context;
|
|
768
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
898
769
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
899
770
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
900
771
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -999,7 +870,7 @@ export class ProcessBackedProviderCliService {
|
|
|
999
870
|
};
|
|
1000
871
|
}
|
|
1001
872
|
async runQa(context) {
|
|
1002
|
-
const { dispatch, worktree } = context;
|
|
873
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1003
874
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
1004
875
|
await fs.mkdir(metadataRoot, { recursive: true });
|
|
1005
876
|
const laneCommand = selectLaneCommand(dispatch.artifacts, dispatch.execution.lane, dispatch.cycleRun.phase);
|
|
@@ -1124,7 +995,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1124
995
|
return await this.runPullRequestRepair(context, "conflict_resolve");
|
|
1125
996
|
}
|
|
1126
997
|
async runPullRequestRepair(context, route) {
|
|
1127
|
-
const { dispatch, worktree } = context;
|
|
998
|
+
const { dispatch, worktree } = admitUserConfigIsolatedProvider(context);
|
|
1128
999
|
const { expectedRepairHeadSha, preparedHeadSha } = await assertRepairHeadEpoch(context, this.git);
|
|
1129
1000
|
const repairChecks = route === "ci_repair" || isPullRequestCheckRepairDispatch(dispatch);
|
|
1130
1001
|
const addressComments = !repairChecks && isPullRequestCommentsDispatch(dispatch);
|
|
@@ -1180,11 +1051,11 @@ export class ProcessBackedProviderCliService {
|
|
|
1180
1051
|
eventType: "completion_tools_configured",
|
|
1181
1052
|
});
|
|
1182
1053
|
}
|
|
1183
|
-
const repairPrompt = repairChecks
|
|
1054
|
+
const repairPrompt = withReapplyConflictInstruction(repairChecks
|
|
1184
1055
|
? buildPullRequestCheckRepairPrompt(dispatch, worktree.branchName)
|
|
1185
1056
|
: addressComments
|
|
1186
1057
|
? buildPullRequestCommentsPrompt(dispatch, worktree.branchName)
|
|
1187
|
-
: buildConflictResolvePrompt(dispatch, worktree.branchName);
|
|
1058
|
+
: buildConflictResolvePrompt(dispatch, worktree.branchName), context.reapplyConflicts, context.projectStartDeferred);
|
|
1188
1059
|
const providerPrompt = buildProviderCliPrompt(dispatch, repairPrompt, repairEnvironment);
|
|
1189
1060
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
1190
1061
|
const command = buildProviderCliCommand(dispatch, {
|
|
@@ -1349,6 +1220,19 @@ export class ProcessBackedProviderCliService {
|
|
|
1349
1220
|
artifacts: repairArtifact ? [repairArtifact] : [],
|
|
1350
1221
|
};
|
|
1351
1222
|
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Review-only session for a pull request head. Never routed through implementation: the worktree
|
|
1225
|
+
* is detached at the dispatched head, the provider cannot change or publish anything, and the
|
|
1226
|
+
* review is handed to Forge only through the completion tool. No commit, push or GitHub call
|
|
1227
|
+
* is made here; a worktree that differs after the session fails with `guardrail_violation`.
|
|
1228
|
+
*/
|
|
1229
|
+
async runPrReview(context) {
|
|
1230
|
+
return await runPrReviewSession({
|
|
1231
|
+
git: this.git,
|
|
1232
|
+
processRunner: this.processRunner,
|
|
1233
|
+
providerToolHeartbeatIntervalMs: this.providerToolHeartbeatIntervalMs,
|
|
1234
|
+
}, admitUserConfigIsolatedProvider(context));
|
|
1235
|
+
}
|
|
1352
1236
|
async recoverMissingQaCompletion(options) {
|
|
1353
1237
|
const { context, outputState } = options;
|
|
1354
1238
|
const { dispatch, worktree } = context;
|
|
@@ -1369,7 +1253,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1369
1253
|
...dispatch,
|
|
1370
1254
|
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1371
1255
|
};
|
|
1372
|
-
const recoveryPrompt = [
|
|
1256
|
+
const recoveryPrompt = await withRemainingReapplyConflictInstruction([
|
|
1373
1257
|
"Your previous turn ended before Forge received the QA verdict, so the provider process exited.",
|
|
1374
1258
|
"Background watchers, monitors and notifications from that turn did not survive and will never report back.",
|
|
1375
1259
|
"Resume QA exactly where it stopped. Do not repeat gates you already recorded.",
|
|
@@ -1377,7 +1261,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1377
1261
|
"and block on long commands with forge.wait_managed_command, calling it again while command_continues is true.",
|
|
1378
1262
|
"Do not end your turn until you have called every remaining QA gate through forge.complete_qa_verdict.",
|
|
1379
1263
|
"If a gate cannot get evidence, record it as blocked with the reason instead of ending the turn.",
|
|
1380
|
-
].join(" ");
|
|
1264
|
+
].join(" "), context);
|
|
1381
1265
|
for (let turn = 1; turn <= maxQaCompletionRecoveryTurns; turn += 1) {
|
|
1382
1266
|
const providerPrompt = buildProviderCliPrompt(recoveryDispatch, recoveryPrompt, context.runtimeEnvironment);
|
|
1383
1267
|
const pipePromptToStdin = shouldPipePromptToStdin(recoveryDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(recoveryDispatch));
|
|
@@ -1478,7 +1362,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1478
1362
|
...dispatch,
|
|
1479
1363
|
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1480
1364
|
};
|
|
1481
|
-
const recoveryPrompt = [
|
|
1365
|
+
const recoveryPrompt = await withRemainingReapplyConflictInstruction([
|
|
1482
1366
|
"Forge did not receive the required forge.complete_comment_repair call from your previous turn, so the provider process exited.",
|
|
1483
1367
|
"Background watchers, monitors and notifications from that turn did not survive and will never report back,",
|
|
1484
1368
|
"and Forge stopped any managed command that process was still running; its receipt reports that.",
|
|
@@ -1488,7 +1372,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1488
1372
|
"and block on long commands with forge.wait_managed_command, calling it again while command_continues is true.",
|
|
1489
1373
|
"Do not end your turn until you have called forge.complete_comment_repair with an evidence-backed disposition for every actionable finding.",
|
|
1490
1374
|
"Do not commit or push; Forge owns publication after the completion gate succeeds.",
|
|
1491
|
-
].join(" ");
|
|
1375
|
+
].join(" "), context);
|
|
1492
1376
|
const providerPrompt = buildProviderCliPrompt(recoveryDispatch, recoveryPrompt, repairEnvironment);
|
|
1493
1377
|
const pipePromptToStdin = shouldPipePromptToStdin(recoveryDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(recoveryDispatch));
|
|
1494
1378
|
const completionTools = await prepareCompletionToolRuntime({
|
|
@@ -1584,23 +1468,15 @@ export class ProcessBackedProviderCliService {
|
|
|
1584
1468
|
runRepairTurn: async (turn) => await this.runPrePublicationRepairTurn(options, processRunner, turn),
|
|
1585
1469
|
});
|
|
1586
1470
|
}
|
|
1587
|
-
/**
|
|
1471
|
+
/**
|
|
1472
|
+
* Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was.
|
|
1473
|
+
* The turn launches with its own Forge MCP server (prepareRepairTurnLaunch), removed when it exits.
|
|
1474
|
+
*/
|
|
1588
1475
|
async runPrePublicationRepairTurn(options, processRunner, turn) {
|
|
1589
1476
|
const { context, outputState, preparedHeadSha } = options;
|
|
1590
|
-
const {
|
|
1591
|
-
const {
|
|
1592
|
-
const repairDispatch =
|
|
1593
|
-
...dispatch,
|
|
1594
|
-
session: { ...dispatch.session, resumeProviderThreadId: turn.providerThreadId },
|
|
1595
|
-
};
|
|
1596
|
-
const providerPrompt = buildProviderCliPrompt(repairDispatch, focusedPrompt, repairEnvironment);
|
|
1597
|
-
const pipePromptToStdin = shouldPipePromptToStdin(repairDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(repairDispatch));
|
|
1598
|
-
const command = buildProviderCliCommand(repairDispatch, {
|
|
1599
|
-
worktreePath: worktree.worktreePath,
|
|
1600
|
-
prompt: focusedPrompt,
|
|
1601
|
-
promptFromStdin: pipePromptToStdin,
|
|
1602
|
-
runtimeEnvironment: repairEnvironment,
|
|
1603
|
-
});
|
|
1477
|
+
const { worktree } = context;
|
|
1478
|
+
const { repairTurn: nextRepairTurn, maxRepairTurns, environment } = turn;
|
|
1479
|
+
const { repairDispatch, providerPrompt, pipePromptToStdin, completionTools, command } = await prepareRepairTurnLaunch(context, turn);
|
|
1604
1480
|
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1605
1481
|
let result;
|
|
1606
1482
|
let providerStarted = false;
|
|
@@ -1631,13 +1507,18 @@ export class ProcessBackedProviderCliService {
|
|
|
1631
1507
|
}
|
|
1632
1508
|
finally {
|
|
1633
1509
|
toolHeartbeat.stop();
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1510
|
+
try {
|
|
1511
|
+
if (providerStarted) {
|
|
1512
|
+
await context.emit({
|
|
1513
|
+
role: "runner",
|
|
1514
|
+
kind: "checkpoint",
|
|
1515
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} exited.`,
|
|
1516
|
+
eventType: "provider_cli_completed",
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
finally {
|
|
1521
|
+
await cleanupCompletionTools(completionTools, context.emit);
|
|
1641
1522
|
}
|
|
1642
1523
|
}
|
|
1643
1524
|
if (result.exitCode !== 0)
|
|
@@ -1709,18 +1590,6 @@ function clipFileName(fileName, maxLength) {
|
|
|
1709
1590
|
const maxStemLength = Math.max(1, maxLength - extension.length);
|
|
1710
1591
|
return `${stem.slice(0, maxStemLength)}${extension}`;
|
|
1711
1592
|
}
|
|
1712
|
-
const providerPromptStdinThreshold = 8_000;
|
|
1713
|
-
function shouldPipePromptToStdin(provider, prompt, force = false) {
|
|
1714
|
-
const normalized = provider.trim().toLowerCase();
|
|
1715
|
-
if (normalized === "claude") {
|
|
1716
|
-
return true;
|
|
1717
|
-
}
|
|
1718
|
-
return normalized === "codex"
|
|
1719
|
-
&& (force || Buffer.byteLength(prompt, "utf8") > providerPromptStdinThreshold);
|
|
1720
|
-
}
|
|
1721
|
-
function usesManagedWindowsHost(dispatch) {
|
|
1722
|
-
return process.platform === "win32" && dispatch.sandbox?.executionMode === "host";
|
|
1723
|
-
}
|
|
1724
1593
|
function isFakeWorkerModel(model) {
|
|
1725
1594
|
return model.trim().toLowerCase() === fakeWorkerModel;
|
|
1726
1595
|
}
|
|
@@ -3,10 +3,11 @@ import type { WorktreeHandle } from "../../worktree/worktree.types.js";
|
|
|
3
3
|
import type { ProviderProcessRunner } from "./provider-cli.process.js";
|
|
4
4
|
/**
|
|
5
5
|
* Why the attempt's runtime stack restarted before a validation pass. The first cause that applies:
|
|
6
|
-
*
|
|
6
|
+
* its first start was deferred until a WIP re-apply's conflicts were resolved (it never ran); a
|
|
7
|
+
* previous restart did not complete; the workspace state could not be compared with the stack's
|
|
7
8
|
* (either reading was unavailable); or the workspace changed since the stack was launched.
|
|
8
9
|
*/
|
|
9
|
-
export type RuntimeRestartReason = "previous_restart_incomplete" | "fingerprint_unavailable" | "workspace_changed";
|
|
10
|
+
export type RuntimeRestartReason = "deferred_start" | "previous_restart_incomplete" | "fingerprint_unavailable" | "workspace_changed";
|
|
10
11
|
export interface RuntimeEnvironmentRefresh {
|
|
11
12
|
/** The restarted stack's runtime environment. */
|
|
12
13
|
readonly environment: Readonly<Record<string, string>>;
|
|
@@ -35,6 +36,10 @@ export interface ProviderCliRunContext {
|
|
|
35
36
|
* ports). A failed restart withholds them from the repair turn, since the stack is down.
|
|
36
37
|
*/
|
|
37
38
|
readonly runtimeStackEnvironmentKeys?: readonly string[];
|
|
39
|
+
/** Unresolved conflicts a WIP re-apply left in the worktree, which the prompt names (withReapplyConflictInstruction). */
|
|
40
|
+
readonly reapplyConflicts?: readonly string[];
|
|
41
|
+
/** True when the project stack's start waits for those conflicts to be resolved. */
|
|
42
|
+
readonly projectStartDeferred?: boolean;
|
|
38
43
|
emit(event: RunnerDispatchEvent): Promise<void>;
|
|
39
44
|
}
|
|
40
45
|
export interface ProviderCliDraftContext {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type LaunchCommand } from "../../shared/process/windows-launch.js";
|
|
2
|
+
export declare function resolveWindowsProviderLaunch(command: string, args: readonly string[]): Promise<LaunchCommand>;
|
|
3
|
+
export declare function resolveCodexNpmDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|
|
4
|
+
/**
|
|
5
|
+
* npm installs of Claude Code (`npm i -g @anthropic-ai/claude-code`) put a `claude.cmd` shim on
|
|
6
|
+
* PATH; launch its cli.js directly for the same Job Object reasons as Codex. The native installer
|
|
7
|
+
* ships `claude.exe`, which is preferred by PATH resolution and needs no rewrite.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveClaudeNpmDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|
|
10
|
+
/**
|
|
11
|
+
* Avoids cmd.exe's nested-quote handling for package-manager shims. That
|
|
12
|
+
* quoting loses executable paths containing spaces after the command is
|
|
13
|
+
* wrapped by the Windows Job Object supervisor.
|
|
14
|
+
*
|
|
15
|
+
* Launches the entry point the shim itself runs. A Windows Node install ships
|
|
16
|
+
* both npm's own CLI and Corepack's npm shim next to `npm.cmd`, and `npm.cmd`
|
|
17
|
+
* runs npm's CLI. Launching Corepack's shim instead would apply Corepack's
|
|
18
|
+
* strict `packageManager` check: in a repository whose root pins pnpm, an npm
|
|
19
|
+
* package below it (with its own package-lock) is refused although its scripts
|
|
20
|
+
* pass when npm runs them. A shim that names none of the candidates prefers
|
|
21
|
+
* the tool's own CLI over Corepack's.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvePackageManagerDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|