@loucompanion/forge-bridge 0.1.4-dev.1ff37038366e → 0.1.4-dev.217a9a59468f
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 +1 -1
- package/dist/bridge/bridge.service.d.ts +9 -0
- package/dist/bridge/bridge.service.js +40 -3
- package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
- package/dist/bridge/dispatch-result-outbox.js +31 -6
- package/dist/cli/cli.help.js +2 -2
- package/dist/runtime/attempt-process-supervisor.d.ts +24 -0
- package/dist/runtime/attempt-process-supervisor.js +77 -3
- package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
- package/dist/runtime/host-database-capability-boundary.js +1 -0
- package/dist/runtime/host-diagnostics.js +4 -3
- package/dist/runtime/host-runtime-contract.d.ts +1 -0
- package/dist/runtime/host-runtime-contract.js +2 -0
- package/dist/runtime/host-runtime-lease.js +55 -9
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +607 -0
- package/dist/runtime/node-host-runtime-adapter.js +5 -4
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +11 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +48 -54
- package/dist/sandbox/repository-lock.js +3 -2
- package/dist/sandbox/runtime.js +5 -4
- package/dist/session/managed-attempt-tools.d.ts +25 -0
- package/dist/session/managed-attempt-tools.js +216 -18
- package/dist/session/managed-build-coordinator.d.ts +1 -1
- package/dist/session/managed-build-coordinator.js +8 -4
- package/dist/session/phase-completion.runtime.js +22 -17
- package/dist/session/pre-publication-process.d.ts +20 -0
- package/dist/session/pre-publication-process.js +97 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-validation.js +27 -57
- package/dist/session/provider-cli/provider-cli.process.d.ts +6 -1
- package/dist/session/provider-cli/provider-cli.process.js +198 -16
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +11 -0
- package/dist/session/provider-cli/provider-cli.service.js +10 -5
- package/dist/session/provider-cli/provider-usage.d.ts +2 -1
- package/dist/shared/process/host-process-recovery.js +3 -2
- package/dist/shared/process/host-process-supervisor.js +5 -4
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.js +74 -0
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import { cleanupCompletionTools, commitWorktreeChanges, completionPhaseFromArtif
|
|
|
10
10
|
import { DeterministicProviderCliService } from "./provider-cli.deterministic.js";
|
|
11
11
|
import { buildArchitectPrompt, buildConflictResolvePrompt, buildDebugCyclePrompt, buildDevelopCyclePrompt, buildDraftPrompt, buildDraftSpec, buildImplementationPrompt, buildProviderCliPrompt, buildProviderCliCommand, durableDraftInput, buildPullRequestCheckRepairPrompt, buildPullRequestCommentsPrompt, buildQaPrompt, formatProviderCliCommandForCheckpoint, isDecomposeDraftDispatch, isPullRequestCheckRepairDispatch, isPullRequestCommentsDispatch } from "./provider-cli.prompts.js";
|
|
12
12
|
import { isTransientCodexProviderNotFoundFailure, recoveringProviderProcessRunner, StreamingProviderProcessRunner } from "./provider-cli.process.js";
|
|
13
|
-
import { emitProviderUsageEvent, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
13
|
+
import { emitProviderUsageEvent, prePublicationValidationEnv, providerProcessEnv } from "./provider-cli.runtime.js";
|
|
14
14
|
import { clip, createProviderOutputState, parseJsonLine } from "./provider-output-state.js";
|
|
15
15
|
import { writeCiRepairReadinessManifest } from "./ci-repair-readiness.js";
|
|
16
16
|
import { assertRepairHeadEpoch } from "./provider-cli.repair-epoch.js";
|
|
@@ -1397,10 +1397,14 @@ export class ProcessBackedProviderCliService {
|
|
|
1397
1397
|
session: { ...dispatch.session, resumeProviderThreadId: providerThreadId },
|
|
1398
1398
|
};
|
|
1399
1399
|
const recoveryPrompt = [
|
|
1400
|
-
"Forge did not receive the required forge.complete_comment_repair call from your previous turn.",
|
|
1400
|
+
"Forge did not receive the required forge.complete_comment_repair call from your previous turn, so the provider process exited.",
|
|
1401
|
+
"Background watchers, monitors and notifications from that turn did not survive and will never report back,",
|
|
1402
|
+
"and Forge stopped any managed command that process was still running; its receipt reports that.",
|
|
1401
1403
|
"Resume the existing work exactly where it is. Do not reimplement or discard the prepared changes.",
|
|
1402
|
-
"Review the current diff and the durable review snapshot
|
|
1403
|
-
"
|
|
1404
|
+
"Review the current diff and the durable review snapshot and preserve the validation evidence already gathered.",
|
|
1405
|
+
"Check each managed command with forge.get_managed_command, restart any that were interrupted,",
|
|
1406
|
+
"and block on long commands with forge.wait_managed_command, calling it again while command_continues is true.",
|
|
1407
|
+
"Do not end your turn until you have called forge.complete_comment_repair with an evidence-backed disposition for every actionable finding.",
|
|
1404
1408
|
"Do not commit or push; Forge owns publication after the completion gate succeeds.",
|
|
1405
1409
|
].join(" ");
|
|
1406
1410
|
const providerPrompt = buildProviderCliPrompt(recoveryDispatch, recoveryPrompt, repairEnvironment);
|
|
@@ -1489,9 +1493,10 @@ export class ProcessBackedProviderCliService {
|
|
|
1489
1493
|
const { dispatch, worktree } = context;
|
|
1490
1494
|
const processRunner = recoveringProviderProcessRunner(context.processRunner ?? this.processRunner);
|
|
1491
1495
|
const environment = providerProcessEnv(dispatch, repairEnvironment);
|
|
1496
|
+
const validationEnvironment = prePublicationValidationEnv(dispatch, repairEnvironment);
|
|
1492
1497
|
for (let repairTurn = 0;; repairTurn += 1) {
|
|
1493
1498
|
try {
|
|
1494
|
-
await this.prePublicationValidator.validate(worktree.worktreePath, validationProfile, publicationCapabilities(context, repairEnvironment), context.emit, context.signal, prePublicationExecution(context,
|
|
1499
|
+
await this.prePublicationValidator.validate(worktree.worktreePath, validationProfile, publicationCapabilities(context, repairEnvironment), context.emit, context.signal, prePublicationExecution(context, validationEnvironment, this.processRunner, preparedHeadSha));
|
|
1495
1500
|
if (repairTurn > 0) {
|
|
1496
1501
|
await context.emit({
|
|
1497
1502
|
role: "runner",
|
|
@@ -4,7 +4,8 @@ export type InputTokenSemantics = "includes_cached_input" | "excludes_cache_toke
|
|
|
4
4
|
export declare const PROVIDER_USAGE_SCHEMA_VERSION = 1;
|
|
5
5
|
/**
|
|
6
6
|
* Normalized, provider-agnostic token usage accumulated for a dispatch. Cost is never computed
|
|
7
|
-
* here; the API recomputes cost from these tokens x model rates (
|
|
7
|
+
* here; the API recomputes cost from these tokens x model rates (legacy
|
|
8
|
+
* ADR-0006, .forge-designer/decisions/legacy/0006-cost-capture.md).
|
|
8
9
|
*/
|
|
9
10
|
export interface ProviderUsage {
|
|
10
11
|
/** Normalized total input. Cached input is a subset, never an additive peer. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { captureHostProcessIdentity } from "./host-process-supervisor.js";
|
|
2
|
+
import { monotonicNowMs } from "../time/monotonic.js";
|
|
2
3
|
/** Exact, birth-marker-fenced recovery for a process tree left by an old bridge. */
|
|
3
4
|
export class ExactHostProcessRecovery {
|
|
4
5
|
platform;
|
|
@@ -71,8 +72,8 @@ function signalExactProcessGroup(pid, signal) {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
async function waitForExit(pid, timeoutMs) {
|
|
74
|
-
const deadline =
|
|
75
|
-
while (
|
|
75
|
+
const deadline = monotonicNowMs() + timeoutMs;
|
|
76
|
+
while (monotonicNowMs() < deadline && processExists(pid)) {
|
|
76
77
|
await new Promise(resolve => setTimeout(resolve, 25));
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -3,6 +3,7 @@ import { execFileSync } from "node:child_process";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { monotonicNowMs } from "../time/monotonic.js";
|
|
6
7
|
const windowsJobSupervisorPath = fileURLToPath(new URL("../../../runtime/windows-job-supervisor.ps1", import.meta.url));
|
|
7
8
|
export function resolveHostProcessSupervisedLaunch(request, resolvedCommand, resolvedArgs, platform = process.platform) {
|
|
8
9
|
const env = request.env;
|
|
@@ -277,8 +278,8 @@ function unixProcessGroupExists(processGroupId) {
|
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
async function waitForUnixProcessGroupExit(processGroupId, timeoutMs) {
|
|
280
|
-
const deadline =
|
|
281
|
-
while (
|
|
281
|
+
const deadline = monotonicNowMs() + timeoutMs;
|
|
282
|
+
while (monotonicNowMs() < deadline && unixProcessGroupExists(processGroupId)) {
|
|
282
283
|
await new Promise(resolve => setTimeout(resolve, 25));
|
|
283
284
|
}
|
|
284
285
|
}
|
|
@@ -307,8 +308,8 @@ function processExists(pid) {
|
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
async function waitForExactProcessExit(pid, identity, timeoutMs, platform) {
|
|
310
|
-
const deadline =
|
|
311
|
-
while (
|
|
311
|
+
const deadline = monotonicNowMs() + timeoutMs;
|
|
312
|
+
while (monotonicNowMs() < deadline && exactProcessExists(pid, identity, platform)) {
|
|
312
313
|
await new Promise(resolve => setTimeout(resolve, 25));
|
|
313
314
|
}
|
|
314
315
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function monotonicNowMs(): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Elapsed time and local deadlines use the monotonic clock. The wall clock can step:
|
|
2
|
+
// a WSL VM's clock is corrected in multi-second jumps, which would end a local wait
|
|
3
|
+
// early or count time that never passed. Timestamps that are persisted or compared
|
|
4
|
+
// across processes (lease expiry, receipts, file mtimes) stay on the wall clock.
|
|
5
|
+
// Read through the global so test fake timers that replace `performance` apply.
|
|
6
|
+
export function monotonicNowMs() {
|
|
7
|
+
return performance.now();
|
|
8
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const forgeBridgeVersion = "0.1.4-dev.
|
|
1
|
+
export declare const forgeBridgeVersion = "0.1.4-dev.217a9a59468f";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const forgeBridgeVersion = "0.1.4-dev.
|
|
1
|
+
export const forgeBridgeVersion = "0.1.4-dev.217a9a59468f";
|
|
@@ -36,6 +36,7 @@ const dependencyPreparationCoordinator = new RepositoryCoordinatorLock(defaultWo
|
|
|
36
36
|
export async function detectWarmPaths(repoRoot, warmPathOverrides = []) {
|
|
37
37
|
const entries = new Map();
|
|
38
38
|
await collectDetectedPaths(repoRoot, repoRoot, entries, 0);
|
|
39
|
+
await collectSolutionProjectRestores(repoRoot, entries);
|
|
39
40
|
for (const override of warmPathOverrides) {
|
|
40
41
|
const normalized = normalizeRelativePath(override);
|
|
41
42
|
if (!normalized) {
|
|
@@ -539,6 +540,79 @@ async function hasPythonMarker(dir) {
|
|
|
539
540
|
return (await pathExists(path.join(dir, "pyproject.toml")))
|
|
540
541
|
|| (await pathExists(path.join(dir, "requirements.txt")));
|
|
541
542
|
}
|
|
543
|
+
const solutionProjectPattern = /^Project\("\{[0-9A-Fa-f-]+\}"\)\s*=\s*"[^"]*"\s*,\s*"([^"]+\.(?:cs|fs|vb)proj)"/gimu;
|
|
544
|
+
const slnxProjectPattern = /<Project\b[^>]*\bPath\s*=\s*"([^"]+\.(?:cs|fs|vb)proj)"/giu;
|
|
545
|
+
const projectFilePattern = /\.(?:cs|fs|vb)proj$/iu;
|
|
546
|
+
const solutionFilePattern = /\.(?:sln|slnx|slnf)$/iu;
|
|
547
|
+
/**
|
|
548
|
+
* A worktree built from a never-built base checkout (a fresh runner clone has no bin/ or obj/)
|
|
549
|
+
* still needs its .NET projects restored, or the --no-restore runtime build fails with NETSDK1004.
|
|
550
|
+
* Restore exactly the projects the root solution(s) (.sln, .slnx, .slnf) list, or a lone root
|
|
551
|
+
* project when there is no solution. Other projects (fixtures, samples) keep the base-checkout
|
|
552
|
+
* output heuristic above.
|
|
553
|
+
*/
|
|
554
|
+
async function collectSolutionProjectRestores(repoRoot, entries) {
|
|
555
|
+
const rootNames = await fs.readdir(repoRoot).catch(() => []);
|
|
556
|
+
const solutions = rootNames.filter((name) => solutionFilePattern.test(name));
|
|
557
|
+
if (solutions.length === 0) {
|
|
558
|
+
const rootProjects = rootNames.filter((name) => name.toLowerCase().endsWith(".csproj"));
|
|
559
|
+
if (rootProjects.length === 1) {
|
|
560
|
+
addEntry(entries, repoRoot, "", "obj", "dotnet", "obj");
|
|
561
|
+
}
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
for (const solution of solutions) {
|
|
565
|
+
for (const listed of await readSolutionProjectPaths(repoRoot, solution)) {
|
|
566
|
+
const projectPath = path.posix.normalize(normalizeRelativePath(listed));
|
|
567
|
+
if (!projectPath || projectPath === ".." || projectPath.startsWith("../") || path.posix.isAbsolute(projectPath)) {
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
const absoluteProject = path.resolve(repoRoot, ...projectPath.split("/"));
|
|
571
|
+
if (!isSubPath(repoRoot, absoluteProject) || !(await pathExists(absoluteProject))) {
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
const projectDir = path.posix.dirname(projectPath);
|
|
575
|
+
// The fallback runs a bare `dotnet restore` in the project's directory. Beside the solution,
|
|
576
|
+
// or next to another project file, that restore is ambiguous (MSB1011); leave those layouts
|
|
577
|
+
// to the base-checkout output heuristic.
|
|
578
|
+
if (projectDir === "." || (await countProjectFiles(path.dirname(absoluteProject))) !== 1) {
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
addEntry(entries, repoRoot, projectDir, "obj", "dotnet", joinRelative(projectDir, "obj"));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
/** Project paths a root solution lists, relative to the repo root (forward slashes). */
|
|
586
|
+
async function readSolutionProjectPaths(repoRoot, solution) {
|
|
587
|
+
const text = await fs.readFile(path.join(repoRoot, solution), "utf8").catch(() => "");
|
|
588
|
+
const lower = solution.toLowerCase();
|
|
589
|
+
if (lower.endsWith(".sln")) {
|
|
590
|
+
return [...text.matchAll(solutionProjectPattern)].map((match) => match[1].replace(/\\/g, "/"));
|
|
591
|
+
}
|
|
592
|
+
if (lower.endsWith(".slnx")) {
|
|
593
|
+
return [...text.matchAll(slnxProjectPattern)].map((match) => match[1].replace(/\\/g, "/"));
|
|
594
|
+
}
|
|
595
|
+
// .slnf: {"solution": {"path": "<solution>", "projects": [...]}}, projects relative to that solution.
|
|
596
|
+
let filter;
|
|
597
|
+
try {
|
|
598
|
+
filter = JSON.parse(text.replace(/^\uFEFF/u, ""));
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return [];
|
|
602
|
+
}
|
|
603
|
+
const body = filter?.solution;
|
|
604
|
+
if (!body || typeof body.path !== "string" || !Array.isArray(body.projects)) {
|
|
605
|
+
return [];
|
|
606
|
+
}
|
|
607
|
+
const solutionDir = path.posix.dirname(body.path.replace(/\\/g, "/"));
|
|
608
|
+
return body.projects
|
|
609
|
+
.filter((project) => typeof project === "string" && projectFilePattern.test(project))
|
|
610
|
+
.map((project) => path.posix.join(solutionDir, project.replace(/\\/g, "/")));
|
|
611
|
+
}
|
|
612
|
+
async function countProjectFiles(dir) {
|
|
613
|
+
const names = await fs.readdir(dir).catch(() => []);
|
|
614
|
+
return names.filter((name) => projectFilePattern.test(name)).length;
|
|
615
|
+
}
|
|
542
616
|
async function hasDotNetMarker(dir) {
|
|
543
617
|
const entries = await fs.readdir(dir).catch(() => []);
|
|
544
618
|
return entries.some((name) => name.endsWith(".csproj") || name.endsWith(".sln"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.4-dev.
|
|
3
|
+
"version": "0.1.4-dev.217a9a59468f",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|