@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 0.1.3-dev.fbe15023cdfe

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.
Files changed (150) hide show
  1. package/README.md +78 -0
  2. package/dist/bridge/bridge.base.d.ts +6 -1
  3. package/dist/bridge/bridge.service.d.ts +60 -3
  4. package/dist/bridge/bridge.service.js +970 -24
  5. package/dist/bridge/bridge.types.d.ts +172 -1
  6. package/dist/cleanup/cleanup.service.d.ts +13 -2
  7. package/dist/cleanup/cleanup.service.js +435 -3
  8. package/dist/cleanup/cleanup.types.d.ts +10 -0
  9. package/dist/cleanup/index.d.ts +1 -1
  10. package/dist/cleanup/index.js +1 -1
  11. package/dist/cleanup/internals.d.ts +2 -2
  12. package/dist/cleanup/internals.js +1 -1
  13. package/dist/cli/cli.help.d.ts +2 -0
  14. package/dist/cli/cli.help.js +217 -0
  15. package/dist/cli/cli.service.d.ts +42 -2
  16. package/dist/cli/cli.service.js +356 -205
  17. package/dist/cli/local-config.d.ts +6 -0
  18. package/dist/cli/local-config.js +47 -3
  19. package/dist/runtime/attempt-node-runtime-launcher.d.ts +17 -0
  20. package/dist/runtime/attempt-node-runtime-launcher.js +101 -0
  21. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  22. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  23. package/dist/runtime/attempt-process-supervisor.d.ts +86 -0
  24. package/dist/runtime/attempt-process-supervisor.js +350 -0
  25. package/dist/runtime/generated-output-reset.d.ts +10 -0
  26. package/dist/runtime/generated-output-reset.js +103 -0
  27. package/dist/runtime/host-listener-inspector.d.ts +44 -0
  28. package/dist/runtime/host-listener-inspector.js +324 -0
  29. package/dist/runtime/host-port-broker.d.ts +76 -0
  30. package/dist/runtime/host-port-broker.js +333 -0
  31. package/dist/runtime/host-runtime-contract.d.ts +47 -0
  32. package/dist/runtime/host-runtime-contract.js +700 -0
  33. package/dist/runtime/host-runtime-lease.d.ts +133 -0
  34. package/dist/runtime/host-runtime-lease.js +1460 -0
  35. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  36. package/dist/runtime/host-runtime-promotion.js +159 -0
  37. package/dist/runtime/node-host-runtime-adapter.d.ts +51 -0
  38. package/dist/runtime/node-host-runtime-adapter.js +268 -0
  39. package/dist/runtime/playwright-host-runtime-adapter.d.ts +20 -0
  40. package/dist/runtime/playwright-host-runtime-adapter.js +220 -0
  41. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  42. package/dist/runtime/runtime-isolation-lease.js +158 -0
  43. package/dist/sandbox/command-runner.d.ts +4 -0
  44. package/dist/sandbox/command-runner.js +47 -0
  45. package/dist/sandbox/contract.d.ts +5 -0
  46. package/dist/sandbox/contract.js +276 -0
  47. package/dist/sandbox/event-budget.d.ts +11 -0
  48. package/dist/sandbox/event-budget.js +27 -0
  49. package/dist/sandbox/image-policy.d.ts +35 -0
  50. package/dist/sandbox/image-policy.js +247 -0
  51. package/dist/sandbox/index.d.ts +5 -0
  52. package/dist/sandbox/index.js +5 -0
  53. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  54. package/dist/sandbox/lease-watchdog.js +67 -0
  55. package/dist/sandbox/preflight.d.ts +54 -0
  56. package/dist/sandbox/preflight.js +335 -0
  57. package/dist/sandbox/process.d.ts +20 -0
  58. package/dist/sandbox/process.js +209 -0
  59. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  60. package/dist/sandbox/provider-auth/codex.js +212 -0
  61. package/dist/sandbox/repository-lock.d.ts +5 -0
  62. package/dist/sandbox/repository-lock.js +119 -0
  63. package/dist/sandbox/runtime.d.ts +297 -0
  64. package/dist/sandbox/runtime.js +2338 -0
  65. package/dist/sandbox/sandbox.types.d.ts +86 -0
  66. package/dist/sandbox/sandbox.types.js +1 -0
  67. package/dist/sandbox/smoke.d.ts +76 -0
  68. package/dist/sandbox/smoke.js +380 -0
  69. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  70. package/dist/sandbox/worker-supervisor.js +36 -0
  71. package/dist/sandbox/worker.d.ts +1 -0
  72. package/dist/sandbox/worker.js +225 -0
  73. package/dist/sandbox/workspace.service.d.ts +13 -0
  74. package/dist/sandbox/workspace.service.js +72 -0
  75. package/dist/session/managed-attempt-tools.d.ts +12 -0
  76. package/dist/session/managed-attempt-tools.js +561 -0
  77. package/dist/session/phase-completion.artifacts.d.ts +10 -0
  78. package/dist/session/phase-completion.artifacts.js +627 -0
  79. package/dist/session/phase-completion.d.ts +43 -42
  80. package/dist/session/phase-completion.helpers.d.ts +112 -0
  81. package/dist/session/phase-completion.helpers.js +684 -0
  82. package/dist/session/phase-completion.js +114 -3007
  83. package/dist/session/phase-completion.prompts.d.ts +14 -0
  84. package/dist/session/phase-completion.prompts.js +234 -0
  85. package/dist/session/phase-completion.runtime.d.ts +47 -0
  86. package/dist/session/phase-completion.runtime.js +731 -0
  87. package/dist/session/phase-completion.schemas.d.ts +3 -0
  88. package/dist/session/phase-completion.schemas.js +812 -0
  89. package/dist/session/phase-completion.validation.d.ts +37 -0
  90. package/dist/session/phase-completion.validation.js +828 -0
  91. package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
  92. package/dist/session/provider-cli/ci-repair-readiness.js +90 -0
  93. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +93 -0
  94. package/dist/session/provider-cli/provider-cli.artifacts.js +778 -0
  95. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  96. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  97. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  98. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  99. package/dist/session/provider-cli/provider-cli.deterministic.js +375 -0
  100. package/dist/session/provider-cli/provider-cli.process.d.ts +48 -0
  101. package/dist/session/provider-cli/provider-cli.process.js +474 -0
  102. package/dist/session/provider-cli/provider-cli.prompts.d.ts +47 -0
  103. package/dist/session/provider-cli/provider-cli.prompts.js +595 -0
  104. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  105. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
  106. package/dist/session/provider-cli/provider-cli.runtime.d.ts +9 -0
  107. package/dist/session/provider-cli/provider-cli.runtime.js +41 -0
  108. package/dist/session/provider-cli/provider-cli.service.d.ts +22 -53
  109. package/dist/session/provider-cli/provider-cli.service.js +587 -2530
  110. package/dist/session/provider-cli/provider-cli.types.d.ts +6 -0
  111. package/dist/session/provider-cli/provider-output-state.d.ts +22 -0
  112. package/dist/session/provider-cli/provider-output-state.js +473 -0
  113. package/dist/session/session-redaction.d.ts +3 -0
  114. package/dist/session/session-redaction.js +23 -0
  115. package/dist/session/session.base.d.ts +6 -1
  116. package/dist/session/session.service.d.ts +8 -2
  117. package/dist/session/session.service.js +463 -58
  118. package/dist/session/session.types.d.ts +177 -1
  119. package/dist/session/session.types.js +352 -3
  120. package/dist/shared/path/path.js +3 -1
  121. package/dist/shared/process/host-process-recovery.d.ts +12 -0
  122. package/dist/shared/process/host-process-recovery.js +78 -0
  123. package/dist/shared/process/host-process-supervisor.d.ts +57 -0
  124. package/dist/shared/process/host-process-supervisor.js +282 -0
  125. package/dist/shared/process/process.d.ts +1 -0
  126. package/dist/shared/process/process.js +1 -0
  127. package/dist/shared/process/windows-launch.d.ts +8 -0
  128. package/dist/shared/process/windows-launch.js +41 -0
  129. package/dist/shared/provider-capabilities.d.ts +1 -0
  130. package/dist/shared/provider-capabilities.js +3 -0
  131. package/dist/shared/redaction/redaction.js +10 -3
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.js +1 -1
  134. package/dist/worktree/artifact-injector.d.ts +3 -2
  135. package/dist/worktree/artifact-injector.js +82 -10
  136. package/dist/worktree/dependency-warmer.d.ts +21 -1
  137. package/dist/worktree/dependency-warmer.js +138 -5
  138. package/dist/worktree/index.d.ts +1 -0
  139. package/dist/worktree/index.js +1 -0
  140. package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
  141. package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
  142. package/dist/worktree/worktree-paths.d.ts +4 -0
  143. package/dist/worktree/worktree-paths.js +30 -0
  144. package/dist/worktree/worktree.base.d.ts +3 -0
  145. package/dist/worktree/worktree.service.d.ts +9 -3
  146. package/dist/worktree/worktree.service.js +100 -52
  147. package/dist/worktree/worktree.types.d.ts +3 -1
  148. package/package.json +6 -3
  149. package/runtime/windows-job-supervisor.ps1 +356 -0
  150. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -0,0 +1,8 @@
1
+ import type { RunOnceDispatchPacket } from "../session.types.js";
2
+ export declare const ciRepairProviderOnlySpecs: readonly ["**/bridge-dispatch.spec.ts", "**/develop-agent-run.spec.ts", "**/runner-availability.spec.ts"];
3
+ export interface CiRepairReadinessResult {
4
+ readonly path: string;
5
+ readonly environment: Readonly<Record<string, string>>;
6
+ readonly manifest: Readonly<Record<string, unknown>>;
7
+ }
8
+ export declare function writeCiRepairReadinessManifest(dispatch: RunOnceDispatchPacket, worktreePath: string, specPath: string, runtimeEnvironment: Readonly<Record<string, string>> | undefined): Promise<CiRepairReadinessResult>;
@@ -0,0 +1,90 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ export const ciRepairProviderOnlySpecs = [
4
+ "**/bridge-dispatch.spec.ts",
5
+ "**/develop-agent-run.spec.ts",
6
+ "**/runner-availability.spec.ts",
7
+ ];
8
+ export async function writeCiRepairReadinessManifest(dispatch, worktreePath, specPath, runtimeEnvironment) {
9
+ const metadataRoot = path.dirname(specPath);
10
+ const manifestPath = path.join(metadataRoot, "ci-repair.readiness.json");
11
+ const workflowPath = path.join(worktreePath, ".github", "workflows", "ci.yml");
12
+ const browserReady = runtimeEnvironment?.FORGE_PLAYWRIGHT_BROWSER_READY === "true";
13
+ const apiUrl = runtimeEnvironment?.FORGE_E2E_API_URL ?? runtimeEnvironment?.FORGE_API_URL ?? null;
14
+ const webUrl = runtimeEnvironment?.FORGE_E2E_WEB_URL
15
+ ?? runtimeEnvironment?.FORGE_WEB_URL
16
+ ?? runtimeEnvironment?.FORGE_PLAYWRIGHT_BASE_URL
17
+ ?? null;
18
+ const environment = {
19
+ ...(runtimeEnvironment ?? {}),
20
+ ...(apiUrl ? { FORGE_E2E_API_URL: apiUrl } : {}),
21
+ ...(webUrl ? { FORGE_E2E_WEB_URL: webUrl } : {}),
22
+ FORGE_CI_REPAIR_READINESS_PATH: manifestPath,
23
+ FORGE_CI_REPAIR_HANDOFF_PATH: path.join(metadataRoot, "artifacts", "ci-repair.handoff.json"),
24
+ FORGE_CI_REPAIR_PROVIDER_ONLY_SPECS: JSON.stringify(ciRepairProviderOnlySpecs),
25
+ };
26
+ const manifest = {
27
+ schema_version: 1,
28
+ generated_by: "forge-bridge",
29
+ work_item_id: dispatch.workItem.id,
30
+ session_id: dispatch.session.id,
31
+ spec: {
32
+ path: relativePath(worktreePath, specPath),
33
+ ready: await isFile(specPath),
34
+ },
35
+ handoff: {
36
+ path: relativePath(worktreePath, environment.FORGE_CI_REPAIR_HANDOFF_PATH),
37
+ completion_tool: "forge.complete_ci_repair",
38
+ required_before_commit_or_push: true,
39
+ },
40
+ pull_request: {
41
+ provider: dispatch.pullRequest?.provider ?? "unknown",
42
+ number: dispatch.pullRequest?.number ?? null,
43
+ url: dispatch.pullRequest?.url ?? null,
44
+ source_branch: dispatch.pullRequest?.sourceBranch ?? dispatch.cycleRun.baseBranch,
45
+ target_branch: dispatch.pullRequest?.targetBranch ?? dispatch.cycleRun.requestedBase,
46
+ check_state: dispatch.pullRequest?.checkState ?? "unknown",
47
+ required_checks_passed: dispatch.pullRequest?.requiredChecksPassed ?? 0,
48
+ required_checks_total: dispatch.pullRequest?.requiredChecksTotal ?? 0,
49
+ failed_job_discovery: "Inspect provider check runs and record exact job/step in the completion payload.",
50
+ },
51
+ workflow: {
52
+ path: relativePath(worktreePath, workflowPath),
53
+ ready: await isFile(workflowPath),
54
+ requirement: "Record the failed step and every earlier guard/drift step in workflow_validation.",
55
+ },
56
+ runtime: {
57
+ mode: runtimeEnvironment?.FORGE_RUNTIME_MODE ?? "unknown",
58
+ application_runtime_ready: Boolean(apiUrl || webUrl),
59
+ api_url: apiUrl,
60
+ web_url: webUrl,
61
+ playwright_config: runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG ?? null,
62
+ playwright_browser_cache: runtimeEnvironment?.PLAYWRIGHT_BROWSERS_PATH ?? null,
63
+ playwright_browser_ready: browserReady,
64
+ playwright_browser_install_command: browserReady
65
+ ? null
66
+ : runtimeEnvironment?.FORGE_PLAYWRIGHT_BROWSER_INSTALL_COMMAND ?? "npx playwright install chromium",
67
+ },
68
+ local_equivalence: {
69
+ default: "supported",
70
+ nested_bridge: "provider_only",
71
+ provider_only_specs: ciRepairProviderOnlySpecs,
72
+ reason: "A managed Forge attempt cannot safely create a second Bridge/runner control plane inside itself. Provider CI remains authoritative for these specs.",
73
+ policy: "Do not delete, skip, or weaken provider CI coverage. Record provider_only steps in workflow_validation with this reason.",
74
+ },
75
+ };
76
+ await fs.mkdir(metadataRoot, { recursive: true });
77
+ await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
78
+ return { path: manifestPath, environment, manifest };
79
+ }
80
+ async function isFile(candidate) {
81
+ try {
82
+ return (await fs.stat(candidate)).isFile();
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ }
88
+ function relativePath(worktreePath, candidate) {
89
+ return path.relative(worktreePath, candidate).replaceAll(path.sep, "/");
90
+ }
@@ -0,0 +1,93 @@
1
+ import { GitClient } from "../../shared/git/git.js";
2
+ import { type CompletionPhase, type CompletionToolRuntime, type DebugCompletionPhase, type QaCompletionGate } from "../phase-completion.js";
3
+ import type { RunOnceDispatchPacket, RunnerDispatchArtifact } from "../session.types.js";
4
+ import type { ProviderCliRunContext } from "./provider-cli.types.js";
5
+ export declare function emitDraftGateArtifacts(emit: ProviderCliRunContext["emit"], worktreePath: string, workItemId: string): Promise<void>;
6
+ export declare function emitDecomposeGateArtifacts(emit: ProviderCliRunContext["emit"], worktreePath: string, workItemId: string): Promise<void>;
7
+ export declare function fileExists(filePath: string): Promise<boolean>;
8
+ export declare function summarizeStderr(stderr: string): string;
9
+ export declare function waitForCompletionArtifact(worktreePath: string, workItemId: string, phase: "draft" | "decompose", signal?: AbortSignal): Promise<RunnerDispatchArtifact>;
10
+ export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
11
+ export declare function cleanupCompletionTools(completionTools: CompletionToolRuntime, emit: ProviderCliRunContext["emit"]): Promise<void>;
12
+ export declare function commitWorktreeChanges(git: GitClient, worktreePath: string, workItemId: string): Promise<{
13
+ readonly commitSha: string;
14
+ readonly changedFiles: readonly string[];
15
+ }>;
16
+ export declare function phaseCompleteEventType(phase: CompletionPhase): string;
17
+ export declare function isDebugCompletionPhaseForProvider(phase: CompletionPhase): phase is DebugCompletionPhase;
18
+ export declare function emitQaArtifactRecorded(emit: ProviderCliRunContext["emit"], worktreePath: string, artifact: RunnerDispatchArtifact): Promise<void>;
19
+ export declare function readQaCompletionArtifactBundle(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<RunnerDispatchArtifact | null>;
20
+ export declare function hasCompleteQaArtifactBundle(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<boolean>;
21
+ export declare function enforceQaBrowserLaunchTargetGate(dispatch: RunOnceDispatchPacket, artifact: RunnerDispatchArtifact): Promise<void>;
22
+ export declare function validateQaBundleSidecarReferences(worktreePath: string, workItemId: string, ownerType?: string | null, ownerId?: string | null): Promise<void>;
23
+ export declare function emitQaStructuredEvents(emit: ProviderCliRunContext["emit"], artifact: RunnerDispatchArtifact): Promise<void>;
24
+ interface QaGateArtifactSnapshot {
25
+ readonly gate: QaCompletionGate;
26
+ readonly path: string;
27
+ readonly status: string;
28
+ readonly producedBy?: string;
29
+ readonly contentHash?: string;
30
+ }
31
+ export declare function qaArtifactRootForDispatch(worktreePath: string, workItemId: string, dispatch: RunOnceDispatchPacket): string;
32
+ export declare function readQaGateArtifact(artifactRoot: string, gate: QaCompletionGate): Promise<QaGateArtifactSnapshot | null>;
33
+ export declare function nextQaGate(gate: QaCompletionGate): QaCompletionGate | null;
34
+ export declare function emitQaGateAccepted(emit: ProviderCliRunContext["emit"], worktreePath: string, artifact: QaGateArtifactSnapshot, nextGate: QaCompletionGate | null): Promise<void>;
35
+ export declare class LiveQaArtifactEmitter {
36
+ private readonly worktreePath;
37
+ private readonly workItemId;
38
+ private readonly dispatch;
39
+ private readonly emit;
40
+ private emittedBundle;
41
+ private readonly emittedGates;
42
+ private timer;
43
+ private pending;
44
+ constructor(worktreePath: string, workItemId: string, dispatch: RunOnceDispatchPacket, emit: ProviderCliRunContext["emit"]);
45
+ start(): void;
46
+ stop(): Promise<void>;
47
+ hasEmitted(): boolean;
48
+ private pollQueued;
49
+ private poll;
50
+ private emitAvailableGateEvents;
51
+ }
52
+ export declare class LiveArchitectArtifactEmitter {
53
+ private readonly worktreePath;
54
+ private readonly workItemId;
55
+ private readonly emit;
56
+ private emitted;
57
+ private timer;
58
+ private pending;
59
+ constructor(worktreePath: string, workItemId: string, emit: ProviderCliRunContext["emit"]);
60
+ start(): void;
61
+ stop(): Promise<void>;
62
+ hasEmitted(): boolean;
63
+ private pollQueued;
64
+ private poll;
65
+ }
66
+ export declare function hasCompleteArchitectArtifactBundle(worktreePath: string, workItemId: string): Promise<boolean>;
67
+ export declare function emitArchitectStructuredEvents(emit: ProviderCliRunContext["emit"], worktreePath: string, workItemId: string, artifact: RunnerDispatchArtifact): Promise<void>;
68
+ export declare function readJsonObjectFile(filePath: string): Promise<Record<string, unknown>>;
69
+ export declare function arrayField(source: Record<string, unknown>, key: string): Record<string, unknown>[];
70
+ export declare function stringArrayField(source: Record<string, unknown>, key: string): string[];
71
+ export declare function summarizeQaObject(source: Record<string, unknown>): string;
72
+ export declare function qaArtifactRelativePath(workItemId: string, fileName: string, ownerType?: string | null, ownerId?: string | null): string;
73
+ export declare function emitCompletionArtifactRecorded(emit: ProviderCliRunContext["emit"], worktreePath: string, artifact: RunnerDispatchArtifact): Promise<void>;
74
+ export declare function emitPhaseCompletionEvent(emit: ProviderCliRunContext["emit"], artifact: RunnerDispatchArtifact): Promise<void>;
75
+ export declare function emitPhaseGateEvents(emit: ProviderCliRunContext["emit"], artifact: RunnerDispatchArtifact): Promise<void>;
76
+ export declare function completionPhaseFromArtifact(artifact: RunnerDispatchArtifact): CompletionPhase;
77
+ export declare class LiveCompletionArtifactEmitter {
78
+ private readonly worktreePath;
79
+ private readonly workItemId;
80
+ private readonly emit;
81
+ private readonly phases;
82
+ private readonly emitted;
83
+ private timer;
84
+ private pending;
85
+ constructor(worktreePath: string, workItemId: string, phase: CompletionPhase, developCycle: boolean, debugCycle: boolean, emit: ProviderCliRunContext["emit"]);
86
+ start(): void;
87
+ stop(): Promise<void>;
88
+ hasEmitted(phase: CompletionPhase): boolean;
89
+ private pollQueued;
90
+ private poll;
91
+ }
92
+ export declare function readCompletionArtifactsForRun(worktreePath: string, workItemId: string, phase: CompletionPhase, developCycle: boolean, debugCycle: boolean): Promise<RunnerDispatchArtifact[]>;
93
+ export {};