@loucompanion/forge-bridge 0.1.4-dev.a690038a6849 → 0.1.4-dev.b1c678efffd2
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 +44 -2
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +125 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +73 -2
- package/dist/bridge/bridge.service.js +312 -119
- package/dist/bridge/bridge.types.d.ts +16 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/runner-host-capabilities.d.ts +2 -0
- package/dist/bridge/runner-host-capabilities.js +4 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cleanup/cleanup.service.d.ts +9 -0
- package/dist/cleanup/cleanup.service.js +72 -109
- package/dist/cleanup/cleanup.types.d.ts +4 -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 +5 -0
- package/dist/cleanup/host-runtime-ledger.js +109 -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 +18 -0
- package/dist/cli/cli.service.d.ts +16 -0
- package/dist/cli/cli.service.js +142 -16
- package/dist/cli/local-config.d.ts +4 -0
- package/dist/cli/local-config.js +26 -4
- package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
- package/dist/runtime/host-load-admission.d.ts +60 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-child-environment.d.ts +22 -0
- package/dist/runtime/host-load-child-environment.js +67 -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 +43 -0
- package/dist/runtime/host-load-governor-config.js +76 -0
- package/dist/runtime/host-load-governor.d.ts +174 -0
- package/dist/runtime/host-load-governor.js +541 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +43 -0
- package/dist/runtime/host-load-sampler.js +74 -6
- package/dist/runtime/host-load-step-class.d.ts +68 -0
- package/dist/runtime/host-load-step-class.js +106 -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-token-ledger.d.ts +174 -0
- package/dist/runtime/host-load-token-ledger.js +421 -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 +3 -0
- package/dist/runtime/host-runtime-contract.js +4 -1
- package/dist/runtime/host-runtime-lease.d.ts +74 -4
- package/dist/runtime/host-runtime-lease.js +281 -11
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +48 -0
- 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/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/runner-settings.d.ts +100 -0
- package/dist/runtime/runner-settings.js +214 -0
- package/dist/sandbox/host-capacity-broker.d.ts +107 -0
- package/dist/sandbox/host-capacity-broker.js +315 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -0
- package/dist/session/managed-attempt-tools.js +156 -37
- package/dist/session/managed-command-host-load.d.ts +45 -0
- package/dist/session/managed-command-host-load.js +82 -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 +94 -25
- 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 +4 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +4 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -3
- package/dist/session/phase-completion.runtime.js +49 -19
- 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 +206 -221
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +46 -92
- 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-pass.d.ts +60 -0
- package/dist/session/pre-publication-pass.js +145 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +23 -11
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +30 -20
- package/dist/session/pre-publication-validation.js +166 -155
- package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
- package/dist/session/provider-cli/claude-background-work.js +180 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
- package/dist/session/provider-cli/pre-publication-repair.js +243 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +15 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +14 -6
- package/dist/session/provider-cli/provider-cli.process.js +29 -61
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +2 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +52 -10
- package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
- package/dist/session/provider-cli/provider-cli.service.js +107 -153
- package/dist/session/provider-cli/provider-cli.types.d.ts +30 -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-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/publishable-worktree-changes.d.ts +10 -1
- package/dist/session/publishable-worktree-changes.js +21 -5
- package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +229 -0
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.service.d.ts +9 -2
- package/dist/session/session.service.js +120 -5
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +7 -4
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/process/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- 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/provider-capabilities.js +5 -6
- 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/worktree.service.d.ts +10 -1
- package/dist/worktree/worktree.service.js +42 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +2 -2
|
@@ -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";
|
|
@@ -11,12 +12,12 @@ import { diffClaimedChangedFiles, findUnpublishedWorktreePaths, normalizeChanged
|
|
|
11
12
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
12
13
|
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
13
14
|
import { isTransientCodexProviderNotFoundFailure, providerCompletionToolMissingFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
14
|
-
import { emitProviderUsageEvent,
|
|
15
|
-
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
15
|
+
import { 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, 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 {
|
|
@@ -474,6 +459,8 @@ class ProviderToolActivityHeartbeat {
|
|
|
474
459
|
timer = null;
|
|
475
460
|
/** Lets the provider runner hold its end-of-turn timers while a tool call is in flight. */
|
|
476
461
|
isToolCallInFlight = () => this.outputState.hasActiveToolCall;
|
|
462
|
+
/** Forgets tool calls a previous generation left open; called before every relaunch. */
|
|
463
|
+
startGeneration = () => this.outputState.resetActiveToolCalls();
|
|
477
464
|
constructor(outputState, emit, intervalMs) {
|
|
478
465
|
this.outputState = outputState;
|
|
479
466
|
this.emit = emit;
|
|
@@ -562,12 +549,19 @@ export class ProcessBackedProviderCliService {
|
|
|
562
549
|
providerToolHeartbeatIntervalMs;
|
|
563
550
|
publicationCoordinator;
|
|
564
551
|
prePublicationValidator;
|
|
565
|
-
|
|
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()) {
|
|
566
559
|
this.processRunner = processRunner;
|
|
567
560
|
this.git = git;
|
|
568
561
|
this.providerToolHeartbeatIntervalMs = providerToolHeartbeatIntervalMs;
|
|
569
562
|
this.publicationCoordinator = publicationCoordinator;
|
|
570
563
|
this.prePublicationValidator = prePublicationValidator;
|
|
564
|
+
this.prePublicationRepairTurns = prePublicationRepairTurns;
|
|
571
565
|
}
|
|
572
566
|
async runDraft(context) {
|
|
573
567
|
const { dispatch } = context;
|
|
@@ -581,7 +575,7 @@ export class ProcessBackedProviderCliService {
|
|
|
581
575
|
await fs.writeFile(path.join(metadataRoot, "spec.md"), buildDraftSpec(dispatch), "utf8");
|
|
582
576
|
const stagedAttachments = await stageDraftAttachments(dispatch, metadataRoot);
|
|
583
577
|
const decomposeDraft = isDecomposeDraftDispatch(dispatch);
|
|
584
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment });
|
|
578
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: decomposeDraft ? "decompose" : "draft", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
585
579
|
const draftPrompt = buildDraftPrompt(dispatch, { attachmentReferences: stagedAttachments.textReferences });
|
|
586
580
|
const providerPrompt = buildProviderCliPrompt(dispatch, draftPrompt, context.runtimeEnvironment);
|
|
587
581
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -646,6 +640,7 @@ export class ProcessBackedProviderCliService {
|
|
|
646
640
|
});
|
|
647
641
|
},
|
|
648
642
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
643
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
649
644
|
onStdoutLine: async (line) => {
|
|
650
645
|
await toolHeartbeat.consume(line);
|
|
651
646
|
}
|
|
@@ -763,7 +758,7 @@ export class ProcessBackedProviderCliService {
|
|
|
763
758
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
764
759
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
765
760
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
766
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment });
|
|
761
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase, runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
767
762
|
const implementationPrompt = debugCycle
|
|
768
763
|
? buildDebugCyclePrompt(dispatch, phase)
|
|
769
764
|
: developCycle
|
|
@@ -817,6 +812,7 @@ export class ProcessBackedProviderCliService {
|
|
|
817
812
|
});
|
|
818
813
|
},
|
|
819
814
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
815
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
820
816
|
onStdoutLine: async (line) => {
|
|
821
817
|
await toolHeartbeat.consume(line);
|
|
822
818
|
}
|
|
@@ -827,9 +823,8 @@ export class ProcessBackedProviderCliService {
|
|
|
827
823
|
await liveCompletionEvents.stop();
|
|
828
824
|
await cleanupCompletionTools(completionTools, context.emit);
|
|
829
825
|
}
|
|
830
|
-
if (result.exitCode !== 0)
|
|
826
|
+
if (result.exitCode !== 0)
|
|
831
827
|
throw providerCliExitFailure(command.command, result);
|
|
832
|
-
}
|
|
833
828
|
await context.emit({
|
|
834
829
|
role: "runner",
|
|
835
830
|
kind: "checkpoint",
|
|
@@ -910,7 +905,7 @@ export class ProcessBackedProviderCliService {
|
|
|
910
905
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
911
906
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
912
907
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "pending_approval", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
913
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment });
|
|
908
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "architect", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
914
909
|
const architectPrompt = buildArchitectPrompt(dispatch);
|
|
915
910
|
const providerPrompt = buildProviderCliPrompt(dispatch, architectPrompt, context.runtimeEnvironment);
|
|
916
911
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -957,6 +952,7 @@ export class ProcessBackedProviderCliService {
|
|
|
957
952
|
});
|
|
958
953
|
},
|
|
959
954
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
955
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
960
956
|
onStdoutLine: async (line) => await toolHeartbeat.consume(line)
|
|
961
957
|
}, context.signal);
|
|
962
958
|
}
|
|
@@ -1014,7 +1010,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1014
1010
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1015
1011
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1016
1012
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" }) + "\n", "utf8");
|
|
1017
|
-
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment });
|
|
1013
|
+
const completionTools = await prepareCompletionToolRuntime({ dispatch, worktree, phase: "qa", runtimeEnvironment: context.runtimeEnvironment, hostLoadEnvironment: context.hostLoadEnvironment });
|
|
1018
1014
|
const qaPrompt = buildQaPrompt(dispatch, specBody);
|
|
1019
1015
|
const providerPrompt = buildProviderCliPrompt(dispatch, qaPrompt, context.runtimeEnvironment);
|
|
1020
1016
|
const pipePromptToStdin = shouldPipePromptToStdin(dispatch.execution.provider, providerPrompt, usesManagedWindowsHost(dispatch));
|
|
@@ -1063,6 +1059,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1063
1059
|
});
|
|
1064
1060
|
},
|
|
1065
1061
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1062
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1066
1063
|
onStdoutLine: async (line) => await toolHeartbeat.consume(line)
|
|
1067
1064
|
}, context.signal);
|
|
1068
1065
|
}
|
|
@@ -1133,6 +1130,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1133
1130
|
const addressComments = !repairChecks && isPullRequestCommentsDispatch(dispatch);
|
|
1134
1131
|
let repairSpec = null;
|
|
1135
1132
|
let repairEnvironment = context.runtimeEnvironment;
|
|
1133
|
+
let ciRepairSpecPath = null;
|
|
1136
1134
|
let completionTools = null;
|
|
1137
1135
|
if (repairChecks) {
|
|
1138
1136
|
const metadataRoot = path.join(worktree.worktreePath, ".forge", "work-items", dispatch.workItem.id);
|
|
@@ -1143,6 +1141,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1143
1141
|
}
|
|
1144
1142
|
const specBody = buildSpecBody(laneCommand, dispatch.workItem, "ci_repair");
|
|
1145
1143
|
const specPath = path.join(metadataRoot, "spec.md");
|
|
1144
|
+
ciRepairSpecPath = specPath;
|
|
1146
1145
|
await fs.writeFile(specPath, specBody, "utf8");
|
|
1147
1146
|
await fs.writeFile(path.join(metadataRoot, "spec.meta.json"), `${JSON.stringify({ schema_version: 1, status: "approved", produced_by: "forge-lane-command" })}\n`, "utf8");
|
|
1148
1147
|
repairSpec = {
|
|
@@ -1154,7 +1153,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1154
1153
|
};
|
|
1155
1154
|
const readiness = await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, specPath, context.runtimeEnvironment);
|
|
1156
1155
|
repairEnvironment = readiness.environment;
|
|
1157
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1156
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1157
|
+
dispatch, worktree, phase: "ci_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1158
|
+
});
|
|
1158
1159
|
await context.emit({
|
|
1159
1160
|
role: "runner",
|
|
1160
1161
|
kind: "checkpoint",
|
|
@@ -1169,7 +1170,9 @@ export class ProcessBackedProviderCliService {
|
|
|
1169
1170
|
});
|
|
1170
1171
|
}
|
|
1171
1172
|
if (addressComments) {
|
|
1172
|
-
completionTools = await prepareCompletionToolRuntime({
|
|
1173
|
+
completionTools = await prepareCompletionToolRuntime({
|
|
1174
|
+
dispatch, worktree, phase: "comment_repair", runtimeEnvironment: repairEnvironment, hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1175
|
+
});
|
|
1173
1176
|
await context.emit({
|
|
1174
1177
|
role: "runner",
|
|
1175
1178
|
kind: "checkpoint",
|
|
@@ -1220,6 +1223,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1220
1223
|
providerStarted = true;
|
|
1221
1224
|
},
|
|
1222
1225
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1226
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1223
1227
|
onStdoutLine: async (line) => {
|
|
1224
1228
|
await toolHeartbeat.consume(line);
|
|
1225
1229
|
}
|
|
@@ -1292,6 +1296,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1292
1296
|
: addressComments
|
|
1293
1297
|
? "comment_repair"
|
|
1294
1298
|
: "conflict_repair";
|
|
1299
|
+
const readinessSpecPath = ciRepairSpecPath;
|
|
1295
1300
|
await this.validatePrePublicationWithRecovery({
|
|
1296
1301
|
context,
|
|
1297
1302
|
validationProfile,
|
|
@@ -1299,6 +1304,10 @@ export class ProcessBackedProviderCliService {
|
|
|
1299
1304
|
outputState,
|
|
1300
1305
|
preparedHeadSha,
|
|
1301
1306
|
repairScope: "pull_request",
|
|
1307
|
+
...(readinessSpecPath ? {
|
|
1308
|
+
// The readiness manifest records the attempt URLs; a restart must not leave it pointing at the old stack.
|
|
1309
|
+
onRuntimeEnvironmentRefreshed: async (runtimeEnvironment) => (await writeCiRepairReadinessManifest(dispatch, worktree.worktreePath, readinessSpecPath, runtimeEnvironment)).environment,
|
|
1310
|
+
} : {}),
|
|
1302
1311
|
});
|
|
1303
1312
|
const stagedChangeSet = await stagePublishableWorktreeChangeSet(this.git, worktree.worktreePath);
|
|
1304
1313
|
const stagedChangedFiles = stagedChangeSet.publishable;
|
|
@@ -1377,6 +1386,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1377
1386
|
worktree,
|
|
1378
1387
|
phase: "qa",
|
|
1379
1388
|
runtimeEnvironment: context.runtimeEnvironment,
|
|
1389
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1380
1390
|
});
|
|
1381
1391
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1382
1392
|
worktreePath: worktree.worktreePath,
|
|
@@ -1402,7 +1412,11 @@ export class ProcessBackedProviderCliService {
|
|
|
1402
1412
|
env: providerProcessEnv(recoveryDispatch, context.runtimeEnvironment),
|
|
1403
1413
|
resumesProviderThread: Boolean(recoveryDispatch.session.resumeProviderThreadId),
|
|
1404
1414
|
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1405
|
-
}, {
|
|
1415
|
+
}, {
|
|
1416
|
+
onStdoutLine: async (line) => await toolHeartbeat.consume(line),
|
|
1417
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1418
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1419
|
+
}, context.signal);
|
|
1406
1420
|
}
|
|
1407
1421
|
finally {
|
|
1408
1422
|
toolHeartbeat.stop();
|
|
@@ -1482,6 +1496,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1482
1496
|
worktree,
|
|
1483
1497
|
phase: "comment_repair",
|
|
1484
1498
|
runtimeEnvironment: repairEnvironment,
|
|
1499
|
+
hostLoadEnvironment: context.hostLoadEnvironment,
|
|
1485
1500
|
});
|
|
1486
1501
|
const command = buildProviderCliCommand(recoveryDispatch, {
|
|
1487
1502
|
worktreePath: worktree.worktreePath,
|
|
@@ -1519,6 +1534,7 @@ export class ProcessBackedProviderCliService {
|
|
|
1519
1534
|
});
|
|
1520
1535
|
},
|
|
1521
1536
|
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1537
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1522
1538
|
onStdoutLine: async (line) => {
|
|
1523
1539
|
await toolHeartbeat.consume(line);
|
|
1524
1540
|
},
|
|
@@ -1560,140 +1576,78 @@ export class ProcessBackedProviderCliService {
|
|
|
1560
1576
|
return artifact;
|
|
1561
1577
|
}
|
|
1562
1578
|
async validatePrePublicationWithRecovery(options) {
|
|
1563
|
-
const
|
|
1579
|
+
const processRunner = recoveringProviderProcessRunner(options.context.processRunner ?? this.processRunner);
|
|
1580
|
+
await validatePrePublicationWithRepair(options, {
|
|
1581
|
+
validator: this.prePublicationValidator,
|
|
1582
|
+
defaultProcessRunner: this.processRunner,
|
|
1583
|
+
maxRepairTurns: this.prePublicationRepairTurns,
|
|
1584
|
+
runRepairTurn: async (turn) => await this.runPrePublicationRepairTurn(options, processRunner, turn),
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
/** Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was. */
|
|
1588
|
+
async runPrePublicationRepairTurn(options, processRunner, turn) {
|
|
1589
|
+
const { context, outputState, preparedHeadSha } = options;
|
|
1564
1590
|
const { dispatch, worktree } = context;
|
|
1565
|
-
const
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1591
|
+
const { prompt: focusedPrompt, repairTurn: nextRepairTurn, maxRepairTurns, repairEnvironment, environment } = turn;
|
|
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
|
+
});
|
|
1604
|
+
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1605
|
+
let result;
|
|
1606
|
+
let providerStarted = false;
|
|
1607
|
+
try {
|
|
1608
|
+
result = await processRunner.run({
|
|
1609
|
+
command: command.command,
|
|
1610
|
+
args: command.args,
|
|
1611
|
+
cwd: worktree.worktreePath,
|
|
1612
|
+
env: environment,
|
|
1613
|
+
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1614
|
+
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1615
|
+
}, {
|
|
1616
|
+
onStarted: async () => {
|
|
1572
1617
|
await context.emit({
|
|
1573
1618
|
role: "runner",
|
|
1574
1619
|
kind: "checkpoint",
|
|
1575
|
-
content: `
|
|
1576
|
-
eventType: "
|
|
1577
|
-
data: JSON.stringify({ repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
return;
|
|
1581
|
-
}
|
|
1582
|
-
catch (error) {
|
|
1583
|
-
if (!(error instanceof PrePublicationValidationError))
|
|
1584
|
-
throw error;
|
|
1585
|
-
if (repairTurn >= maxPrePublicationRepairTurns) {
|
|
1586
|
-
await context.emit({
|
|
1587
|
-
role: "runner",
|
|
1588
|
-
kind: "error",
|
|
1589
|
-
content: `Pre-publication validation still fails after ${maxPrePublicationRepairTurns} in-place repair turns: ${clip(error.message, 4000)}`,
|
|
1590
|
-
eventType: "prepublication_repair_exhausted",
|
|
1591
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurns: repairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1620
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} is supervised and ready.`,
|
|
1621
|
+
eventType: "provider_cli_started",
|
|
1592
1622
|
});
|
|
1593
|
-
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
const providerPrompt = buildProviderCliPrompt(repairDispatch, focusedPrompt, repairEnvironment);
|
|
1606
|
-
const pipePromptToStdin = shouldPipePromptToStdin(repairDispatch.execution.provider, providerPrompt, usesManagedWindowsHost(repairDispatch));
|
|
1607
|
-
const command = buildProviderCliCommand(repairDispatch, {
|
|
1608
|
-
worktreePath: worktree.worktreePath,
|
|
1609
|
-
prompt: focusedPrompt,
|
|
1610
|
-
promptFromStdin: pipePromptToStdin,
|
|
1611
|
-
runtimeEnvironment: repairEnvironment,
|
|
1612
|
-
});
|
|
1623
|
+
providerStarted = true;
|
|
1624
|
+
},
|
|
1625
|
+
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1626
|
+
onGenerationStart: toolHeartbeat.startGeneration,
|
|
1627
|
+
onStdoutLine: async (line) => {
|
|
1628
|
+
await toolHeartbeat.consume(line);
|
|
1629
|
+
},
|
|
1630
|
+
}, context.signal);
|
|
1631
|
+
}
|
|
1632
|
+
finally {
|
|
1633
|
+
toolHeartbeat.stop();
|
|
1634
|
+
if (providerStarted) {
|
|
1613
1635
|
await context.emit({
|
|
1614
1636
|
role: "runner",
|
|
1615
1637
|
kind: "checkpoint",
|
|
1616
|
-
content: `
|
|
1617
|
-
eventType: "
|
|
1618
|
-
data: JSON.stringify({ checkId: error.checkId, repairTurn: nextRepairTurn, maxRepairTurns: maxPrePublicationRepairTurns }),
|
|
1638
|
+
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxRepairTurns} exited.`,
|
|
1639
|
+
eventType: "provider_cli_completed",
|
|
1619
1640
|
});
|
|
1620
|
-
const toolHeartbeat = new ProviderToolActivityHeartbeat(outputState, context.emit, this.providerToolHeartbeatIntervalMs);
|
|
1621
|
-
let result;
|
|
1622
|
-
let providerStarted = false;
|
|
1623
|
-
try {
|
|
1624
|
-
result = await processRunner.run({
|
|
1625
|
-
command: command.command,
|
|
1626
|
-
args: command.args,
|
|
1627
|
-
cwd: worktree.worktreePath,
|
|
1628
|
-
env: environment,
|
|
1629
|
-
resumesProviderThread: Boolean(repairDispatch.session.resumeProviderThreadId),
|
|
1630
|
-
stdin: pipePromptToStdin ? providerPrompt : undefined,
|
|
1631
|
-
}, {
|
|
1632
|
-
onStarted: async () => {
|
|
1633
|
-
await context.emit({
|
|
1634
|
-
role: "runner",
|
|
1635
|
-
kind: "checkpoint",
|
|
1636
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} is supervised and ready.`,
|
|
1637
|
-
eventType: "provider_cli_started",
|
|
1638
|
-
});
|
|
1639
|
-
providerStarted = true;
|
|
1640
|
-
},
|
|
1641
|
-
isToolCallInFlight: toolHeartbeat.isToolCallInFlight,
|
|
1642
|
-
onStdoutLine: async (line) => {
|
|
1643
|
-
await toolHeartbeat.consume(line);
|
|
1644
|
-
},
|
|
1645
|
-
}, context.signal);
|
|
1646
|
-
}
|
|
1647
|
-
finally {
|
|
1648
|
-
toolHeartbeat.stop();
|
|
1649
|
-
if (providerStarted) {
|
|
1650
|
-
await context.emit({
|
|
1651
|
-
role: "runner",
|
|
1652
|
-
kind: "checkpoint",
|
|
1653
|
-
content: `Provider pre-publication repair turn ${nextRepairTurn}/${maxPrePublicationRepairTurns} exited.`,
|
|
1654
|
-
eventType: "provider_cli_completed",
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
if (result.exitCode !== 0)
|
|
1659
|
-
throw providerCliExitFailure(command.command, result);
|
|
1660
|
-
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1661
|
-
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1662
|
-
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 });
|
|
1663
|
-
}
|
|
1664
1641
|
}
|
|
1665
1642
|
}
|
|
1643
|
+
if (result.exitCode !== 0)
|
|
1644
|
+
throw providerCliExitFailure(command.command, result);
|
|
1645
|
+
const postRepairHeadSha = (await this.git.run(worktree.worktreePath, ["rev-parse", "HEAD"])).trim();
|
|
1646
|
+
if (postRepairHeadSha.toLowerCase() !== preparedHeadSha.toLowerCase()) {
|
|
1647
|
+
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 });
|
|
1648
|
+
}
|
|
1666
1649
|
}
|
|
1667
1650
|
}
|
|
1668
|
-
function buildPrePublicationRepairPrompt(error, repairTurn, repairScope) {
|
|
1669
|
-
const invocation = [error.command, ...error.args].join(" ");
|
|
1670
|
-
const priorWork = repairScope === "implementation"
|
|
1671
|
-
? "Keep the completed implementation and its Forge-owned completion artifacts intact."
|
|
1672
|
-
: "Keep the existing PR-comment or CI repairs intact.";
|
|
1673
|
-
return [
|
|
1674
|
-
`Forge pre-publication validation failed after your ${repairScope === "implementation" ? "implementation" : "PR repair"} turn.`,
|
|
1675
|
-
`This is bounded in-place repair turn ${repairTurn}/${maxPrePublicationRepairTurns}.`,
|
|
1676
|
-
`Failed check: ${error.checkId}`,
|
|
1677
|
-
`Command: ${invocation}`,
|
|
1678
|
-
`Exit code: ${error.exitCode}`,
|
|
1679
|
-
"Diagnostics:",
|
|
1680
|
-
error.detail || "The validation command returned no diagnostic output.",
|
|
1681
|
-
"Fix the root cause in the current worktree and run the focused failing check.",
|
|
1682
|
-
`${priorWork} Do not commit, push, rebase, or modify Forge-owned protocol artifacts.`,
|
|
1683
|
-
"When the focused check passes, stop; Bridge will rerun the complete required pre-publication profile and owns commit/push.",
|
|
1684
|
-
].join("\n\n");
|
|
1685
|
-
}
|
|
1686
|
-
function publicationCapabilities(context, runtimeEnvironment) {
|
|
1687
|
-
const capabilities = new Set();
|
|
1688
|
-
const launchTarget = context.dispatch.qaBrowser?.launchTarget;
|
|
1689
|
-
if (runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG
|
|
1690
|
-
|| launchTarget?.url
|
|
1691
|
-
|| launchTarget?.command
|
|
1692
|
-
|| launchTarget?.managed_runtime_port) {
|
|
1693
|
-
capabilities.add("browser_launch");
|
|
1694
|
-
}
|
|
1695
|
-
return capabilities;
|
|
1696
|
-
}
|
|
1697
1651
|
async function stageDraftAttachments(dispatch, metadataRoot) {
|
|
1698
1652
|
const attachments = dispatch.draft?.attachments ?? [];
|
|
1699
1653
|
const stageable = attachments.filter((attachment) => (attachment.kind === "text" && typeof attachment.textContent === "string")
|
|
@@ -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>;
|
|
@@ -4,3 +4,7 @@
|
|
|
4
4
|
* Unreadable or stale receipts do not count.
|
|
5
5
|
*/
|
|
6
6
|
export declare function hasNonterminalManagedCommand(logDirectory: string | undefined, nowMs?: number): Promise<boolean>;
|
|
7
|
+
/** A stream event that shows the provider is working on a turn: model output or a tool result. */
|
|
8
|
+
export declare function isProviderTurnActivity(line: string): boolean;
|
|
9
|
+
export declare function isProviderTerminalFailure(line: string): boolean;
|
|
10
|
+
export declare function isProviderTerminalSuccess(line: string): boolean;
|
|
@@ -45,3 +45,48 @@ async function receiptHoldsProvider(receiptPath, nowMs) {
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
/** A stream event that shows the provider is working on a turn: model output or a tool result. */
|
|
49
|
+
export function isProviderTurnActivity(line) {
|
|
50
|
+
const trimmed = line.trim();
|
|
51
|
+
if (!trimmed.startsWith("{"))
|
|
52
|
+
return false;
|
|
53
|
+
try {
|
|
54
|
+
const event = JSON.parse(trimmed);
|
|
55
|
+
return event.type === "assistant"
|
|
56
|
+
|| event.type === "user"
|
|
57
|
+
|| (event.type === "system" && event.subtype === "init")
|
|
58
|
+
|| event.type === "turn.started"
|
|
59
|
+
|| event.type === "item.started";
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function isProviderTerminalFailure(line) {
|
|
66
|
+
const trimmed = line.trim();
|
|
67
|
+
if (!trimmed.startsWith("{"))
|
|
68
|
+
return false;
|
|
69
|
+
try {
|
|
70
|
+
const event = JSON.parse(trimmed);
|
|
71
|
+
// The same events the output parsers report as provider errors.
|
|
72
|
+
return event.type === "turn.failed"
|
|
73
|
+
|| event.type === "error"
|
|
74
|
+
|| (event.type === "result" && (event.subtype !== "success" || event.is_error === true));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function isProviderTerminalSuccess(line) {
|
|
81
|
+
const trimmed = line.trim();
|
|
82
|
+
if (!trimmed.startsWith("{"))
|
|
83
|
+
return false;
|
|
84
|
+
try {
|
|
85
|
+
const event = JSON.parse(trimmed);
|
|
86
|
+
return event.type === "turn.completed"
|
|
87
|
+
|| (event.type === "result" && event.subtype === "success" && event.is_error !== true);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { RunnerDispatchEvent } from "../session.types.js";
|
|
2
2
|
import { type ProviderUsage } from "./provider-usage.js";
|
|
3
3
|
export declare function messageFromError(error: unknown): string;
|
|
4
|
+
/** Keeps the end of `value`, where a process's failure detail is, within `maximumLength`. */
|
|
5
|
+
export declare function clipTail(value: string, maximumLength: number): string;
|
|
4
6
|
export declare function clip(value: string, maxLength: number): string;
|
|
5
7
|
export interface ProviderOutputState {
|
|
6
8
|
readonly sessionLabel: string | null;
|
|
@@ -2,6 +2,12 @@ import { addUsage, emptyUsage, readUsageNumber } from "./provider-usage.js";
|
|
|
2
2
|
export function messageFromError(error) {
|
|
3
3
|
return error instanceof Error ? error.message : String(error);
|
|
4
4
|
}
|
|
5
|
+
/** Keeps the end of `value`, where a process's failure detail is, within `maximumLength`. */
|
|
6
|
+
export function clipTail(value, maximumLength) {
|
|
7
|
+
if (value.length <= maximumLength)
|
|
8
|
+
return value;
|
|
9
|
+
return `...${value.slice(-(maximumLength - 3))}`;
|
|
10
|
+
}
|
|
5
11
|
export function clip(value, maxLength) {
|
|
6
12
|
if (maxLength <= 0) {
|
|
7
13
|
return "";
|
|
@@ -16,7 +16,16 @@ export interface PublishableWorktreeChangeSet {
|
|
|
16
16
|
* `.forge/` file that differs from HEAD is an author edit and must be published.
|
|
17
17
|
*/
|
|
18
18
|
export declare function isNonPublishableWorktreeChange(relativePath: string, status: string): boolean;
|
|
19
|
-
/**
|
|
19
|
+
/** `.local/`, `.forge/work-items/` and `.forge/stories/`: never published, even during a merge. */
|
|
20
|
+
export declare function isRuntimeOnlyPath(relativePath: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Stages every publishable worktree change in the real index and returns both sets.
|
|
23
|
+
*
|
|
24
|
+
* During an in-progress merge it first refuses unresolved conflicts, and afterwards
|
|
25
|
+
* restores merge-owned paths that the exclusion unstaged back to HEAD (the story side),
|
|
26
|
+
* such as `.forge/` files the target branch added (#491). Runtime-only paths are never
|
|
27
|
+
* restored.
|
|
28
|
+
*/
|
|
20
29
|
export declare function stagePublishableWorktreeChangeSet(git: Pick<GitClient, "run">, worktreePath: string): Promise<PublishableWorktreeChangeSet>;
|
|
21
30
|
/**
|
|
22
31
|
* Computes the same change set as {@link stagePublishableWorktreeChangeSet} without
|