@loucompanion/forge-bridge 0.1.3-dev.d1ca67076aa9 → 0.1.3-dev.eeefdb0d19c1

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 (143) 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 +962 -22
  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.js +47 -1
  14. package/dist/cli/cli.service.d.ts +42 -2
  15. package/dist/cli/cli.service.js +351 -22
  16. package/dist/cli/local-config.d.ts +6 -0
  17. package/dist/cli/local-config.js +47 -3
  18. package/dist/runtime/attempt-node-runtime-launcher.d.ts +17 -0
  19. package/dist/runtime/attempt-node-runtime-launcher.js +101 -0
  20. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  21. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  22. package/dist/runtime/attempt-process-supervisor.d.ts +86 -0
  23. package/dist/runtime/attempt-process-supervisor.js +343 -0
  24. package/dist/runtime/generated-output-reset.d.ts +10 -0
  25. package/dist/runtime/generated-output-reset.js +103 -0
  26. package/dist/runtime/host-listener-inspector.d.ts +44 -0
  27. package/dist/runtime/host-listener-inspector.js +324 -0
  28. package/dist/runtime/host-port-broker.d.ts +76 -0
  29. package/dist/runtime/host-port-broker.js +333 -0
  30. package/dist/runtime/host-runtime-contract.d.ts +47 -0
  31. package/dist/runtime/host-runtime-contract.js +700 -0
  32. package/dist/runtime/host-runtime-lease.d.ts +133 -0
  33. package/dist/runtime/host-runtime-lease.js +1460 -0
  34. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  35. package/dist/runtime/host-runtime-promotion.js +159 -0
  36. package/dist/runtime/node-host-runtime-adapter.d.ts +51 -0
  37. package/dist/runtime/node-host-runtime-adapter.js +268 -0
  38. package/dist/runtime/playwright-host-runtime-adapter.d.ts +20 -0
  39. package/dist/runtime/playwright-host-runtime-adapter.js +220 -0
  40. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  41. package/dist/runtime/runtime-isolation-lease.js +158 -0
  42. package/dist/sandbox/command-runner.d.ts +4 -0
  43. package/dist/sandbox/command-runner.js +47 -0
  44. package/dist/sandbox/contract.d.ts +5 -0
  45. package/dist/sandbox/contract.js +276 -0
  46. package/dist/sandbox/event-budget.d.ts +11 -0
  47. package/dist/sandbox/event-budget.js +27 -0
  48. package/dist/sandbox/image-policy.d.ts +35 -0
  49. package/dist/sandbox/image-policy.js +247 -0
  50. package/dist/sandbox/index.d.ts +5 -0
  51. package/dist/sandbox/index.js +5 -0
  52. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  53. package/dist/sandbox/lease-watchdog.js +67 -0
  54. package/dist/sandbox/preflight.d.ts +54 -0
  55. package/dist/sandbox/preflight.js +335 -0
  56. package/dist/sandbox/process.d.ts +20 -0
  57. package/dist/sandbox/process.js +209 -0
  58. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  59. package/dist/sandbox/provider-auth/codex.js +212 -0
  60. package/dist/sandbox/repository-lock.d.ts +5 -0
  61. package/dist/sandbox/repository-lock.js +119 -0
  62. package/dist/sandbox/runtime.d.ts +297 -0
  63. package/dist/sandbox/runtime.js +2338 -0
  64. package/dist/sandbox/sandbox.types.d.ts +86 -0
  65. package/dist/sandbox/sandbox.types.js +1 -0
  66. package/dist/sandbox/smoke.d.ts +76 -0
  67. package/dist/sandbox/smoke.js +380 -0
  68. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  69. package/dist/sandbox/worker-supervisor.js +36 -0
  70. package/dist/sandbox/worker.d.ts +1 -0
  71. package/dist/sandbox/worker.js +225 -0
  72. package/dist/sandbox/workspace.service.d.ts +13 -0
  73. package/dist/sandbox/workspace.service.js +72 -0
  74. package/dist/session/managed-attempt-tools.d.ts +12 -0
  75. package/dist/session/managed-attempt-tools.js +350 -0
  76. package/dist/session/phase-completion.artifacts.js +32 -4
  77. package/dist/session/phase-completion.d.ts +4 -2
  78. package/dist/session/phase-completion.helpers.js +27 -3
  79. package/dist/session/phase-completion.js +12 -3
  80. package/dist/session/phase-completion.prompts.d.ts +3 -3
  81. package/dist/session/phase-completion.prompts.js +19 -5
  82. package/dist/session/phase-completion.runtime.d.ts +12 -1
  83. package/dist/session/phase-completion.runtime.js +127 -7
  84. package/dist/session/phase-completion.schemas.js +108 -3
  85. package/dist/session/phase-completion.validation.d.ts +4 -1
  86. package/dist/session/phase-completion.validation.js +106 -2
  87. package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
  88. package/dist/session/provider-cli/ci-repair-readiness.js +90 -0
  89. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +1 -1
  90. package/dist/session/provider-cli/provider-cli.artifacts.js +28 -4
  91. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  92. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +2 -0
  93. package/dist/session/provider-cli/provider-cli.deterministic.js +66 -9
  94. package/dist/session/provider-cli/provider-cli.process.d.ts +17 -0
  95. package/dist/session/provider-cli/provider-cli.process.js +223 -14
  96. package/dist/session/provider-cli/provider-cli.prompts.d.ts +16 -2
  97. package/dist/session/provider-cli/provider-cli.prompts.js +202 -18
  98. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +1 -0
  99. package/dist/session/provider-cli/provider-cli.runtime.d.ts +1 -1
  100. package/dist/session/provider-cli/provider-cli.runtime.js +3 -2
  101. package/dist/session/provider-cli/provider-cli.service.d.ts +7 -3
  102. package/dist/session/provider-cli/provider-cli.service.js +399 -98
  103. package/dist/session/provider-cli/provider-cli.types.d.ts +6 -0
  104. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  105. package/dist/session/provider-cli/provider-output-state.js +30 -2
  106. package/dist/session/session-redaction.d.ts +3 -0
  107. package/dist/session/session-redaction.js +23 -0
  108. package/dist/session/session.base.d.ts +6 -1
  109. package/dist/session/session.service.d.ts +8 -2
  110. package/dist/session/session.service.js +463 -58
  111. package/dist/session/session.types.d.ts +107 -1
  112. package/dist/session/session.types.js +226 -3
  113. package/dist/shared/path/path.js +3 -1
  114. package/dist/shared/process/host-process-recovery.d.ts +12 -0
  115. package/dist/shared/process/host-process-recovery.js +78 -0
  116. package/dist/shared/process/host-process-supervisor.d.ts +57 -0
  117. package/dist/shared/process/host-process-supervisor.js +282 -0
  118. package/dist/shared/process/process.d.ts +1 -0
  119. package/dist/shared/process/process.js +1 -0
  120. package/dist/shared/process/windows-launch.d.ts +1 -1
  121. package/dist/shared/process/windows-launch.js +6 -3
  122. package/dist/shared/provider-capabilities.d.ts +1 -0
  123. package/dist/shared/provider-capabilities.js +3 -0
  124. package/dist/shared/redaction/redaction.js +10 -3
  125. package/dist/version.d.ts +1 -1
  126. package/dist/version.js +1 -1
  127. package/dist/worktree/artifact-injector.d.ts +3 -2
  128. package/dist/worktree/artifact-injector.js +43 -4
  129. package/dist/worktree/dependency-warmer.d.ts +21 -1
  130. package/dist/worktree/dependency-warmer.js +138 -5
  131. package/dist/worktree/index.d.ts +1 -0
  132. package/dist/worktree/index.js +1 -0
  133. package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
  134. package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
  135. package/dist/worktree/worktree-paths.d.ts +4 -0
  136. package/dist/worktree/worktree-paths.js +30 -0
  137. package/dist/worktree/worktree.base.d.ts +3 -0
  138. package/dist/worktree/worktree.service.d.ts +7 -2
  139. package/dist/worktree/worktree.service.js +72 -44
  140. package/dist/worktree/worktree.types.d.ts +3 -1
  141. package/package.json +6 -3
  142. package/runtime/windows-job-supervisor.ps1 +356 -0
  143. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -1,13 +1,19 @@
1
1
  import type { RunOnceDispatchPacket, RunnerDispatchArtifact, RunnerDispatchEvent, RunnerDispatchSpec } from "../session.types.js";
2
2
  import type { WorktreeHandle } from "../../worktree/worktree.types.js";
3
+ import type { ProviderProcessRunner } from "./provider-cli.process.js";
3
4
  export interface ProviderCliRunContext {
4
5
  readonly dispatch: RunOnceDispatchPacket;
5
6
  readonly worktree: WorktreeHandle;
7
+ readonly runtimeEnvironment?: Readonly<Record<string, string>>;
8
+ readonly processRunner?: ProviderProcessRunner;
6
9
  readonly signal?: AbortSignal;
7
10
  emit(event: RunnerDispatchEvent): Promise<void>;
8
11
  }
9
12
  export interface ProviderCliDraftContext {
10
13
  readonly dispatch: RunOnceDispatchPacket;
14
+ readonly worktree: WorktreeHandle;
15
+ readonly runtimeEnvironment?: Readonly<Record<string, string>>;
16
+ readonly processRunner?: ProviderProcessRunner;
11
17
  readonly signal?: AbortSignal;
12
18
  emit(event: RunnerDispatchEvent): Promise<void>;
13
19
  }
@@ -5,6 +5,8 @@ export declare function clip(value: string, maxLength: number): string;
5
5
  export interface ProviderOutputState {
6
6
  readonly sessionLabel: string | null;
7
7
  finalMessage: string | null;
8
+ /** True only while the provider has reported a tool/command start without a matching completion. */
9
+ readonly hasActiveToolCall: boolean;
8
10
  /** Accumulated provider-reported token usage for this run, or null when none was reported. */
9
11
  readonly usage: ProviderUsage | null;
10
12
  consume(line: string): readonly RunnerDispatchEvent[];
@@ -25,12 +25,16 @@ class CursorStreamJsonState {
25
25
  finalMessage = null;
26
26
  emittedSession = false;
27
27
  accumulatedUsage = null;
28
+ activeToolCallCount = 0;
28
29
  get sessionLabel() {
29
30
  return this.sessionId ? `session ${this.sessionId}` : null;
30
31
  }
31
32
  get usage() {
32
33
  return this.accumulatedUsage;
33
34
  }
35
+ get hasActiveToolCall() {
36
+ return this.activeToolCallCount > 0;
37
+ }
34
38
  consume(line) {
35
39
  const event = parseJsonLine(line);
36
40
  if (!event) {
@@ -65,6 +69,7 @@ class CursorStreamJsonState {
65
69
  const subtype = stringField(event, "subtype");
66
70
  const toolCall = objectField(event, "tool_call");
67
71
  if (subtype === "started") {
72
+ this.activeToolCallCount += 1;
68
73
  const summary = formatCursorToolCallStarted(toolCall);
69
74
  if (summary) {
70
75
  return [{
@@ -76,6 +81,7 @@ class CursorStreamJsonState {
76
81
  }
77
82
  }
78
83
  if (subtype === "completed") {
84
+ this.activeToolCallCount = Math.max(0, this.activeToolCallCount - 1);
79
85
  const completed = formatCursorToolCallCompleted(toolCall);
80
86
  if (completed) {
81
87
  return [{
@@ -224,18 +230,23 @@ class CodexJsonState {
224
230
  finalMessage = null;
225
231
  emittedThread = false;
226
232
  accumulatedUsage = null;
233
+ activeToolCallCount = 0;
227
234
  get sessionLabel() {
228
235
  return this.threadId ? `thread ${this.threadId}` : null;
229
236
  }
230
237
  get usage() {
231
238
  return this.accumulatedUsage;
232
239
  }
240
+ get hasActiveToolCall() {
241
+ return this.activeToolCallCount > 0;
242
+ }
233
243
  consume(line) {
234
244
  const event = parseJsonLine(line);
235
245
  if (!event) {
236
246
  return [];
237
247
  }
238
248
  const type = stringField(event, "type") ?? "";
249
+ this.trackToolActivity(type, event);
239
250
  if (type === "thread.started") {
240
251
  this.threadId = stringField(event, "thread_id");
241
252
  if (this.threadId && !this.emittedThread) {
@@ -265,7 +276,7 @@ class CodexJsonState {
265
276
  eventType: "provider_cli_error"
266
277
  }];
267
278
  }
268
- if (type === "item.completed" || type === "item.updated") {
279
+ if (type === "item.started" || type === "item.completed" || type === "item.updated") {
269
280
  const item = objectField(event, "item");
270
281
  const itemType = stringField(item, "type");
271
282
  if (itemType === "agent_message") {
@@ -287,7 +298,7 @@ class CodexJsonState {
287
298
  return [{
288
299
  role: "worker",
289
300
  kind: "checkpoint",
290
- content: `Codex command ${status || "completed"}: ${clip(command, 500)}`,
301
+ content: `Codex command ${status || (type === "item.started" ? "started" : "completed")}: ${clip(command, 500)}`,
291
302
  eventType: "provider_command"
292
303
  }];
293
304
  }
@@ -299,6 +310,23 @@ class CodexJsonState {
299
310
  }
300
311
  return [];
301
312
  }
313
+ trackToolActivity(type, event) {
314
+ if (type !== "item.started" && type !== "item.completed") {
315
+ return;
316
+ }
317
+ const item = objectField(event, "item");
318
+ const itemType = (stringField(item, "type") ?? "").toLowerCase();
319
+ const toolName = mcpToolName(item);
320
+ const isTool = itemType === "command_execution"
321
+ || itemType.includes("mcp")
322
+ || Boolean(toolName);
323
+ if (!isTool) {
324
+ return;
325
+ }
326
+ this.activeToolCallCount = type === "item.started"
327
+ ? this.activeToolCallCount + 1
328
+ : Math.max(0, this.activeToolCallCount - 1);
329
+ }
302
330
  accumulateUsage(event) {
303
331
  const usage = objectField(event, "usage");
304
332
  if (Object.keys(usage).length === 0) {
@@ -0,0 +1,3 @@
1
+ import type { RunOnceResultPacket, RunnerDispatchEvent } from "./session.types.js";
2
+ export declare function redactRunnerDispatchEvent(event: RunnerDispatchEvent, exactSecrets?: readonly string[]): RunnerDispatchEvent;
3
+ export declare function redactRunOnceResultPacket(result: RunOnceResultPacket, exactSecrets?: readonly string[]): RunOnceResultPacket;
@@ -0,0 +1,23 @@
1
+ import { redactSecrets } from "../shared/redaction/redaction.js";
2
+ const integrityProtectedEventDataTypes = new Set(["sandbox_started"]);
3
+ export function redactRunnerDispatchEvent(event, exactSecrets = []) {
4
+ if (!event.data || !integrityProtectedEventDataTypes.has(event.eventType)) {
5
+ return redactSecrets(event, exactSecrets);
6
+ }
7
+ // sandbox_started data is runner-authored protocol metadata. Its runtime
8
+ // lease repeats the dispatch fence so the API can validate ownership. The
9
+ // transcript redactor treats any serialized `*Token` field as a secret and
10
+ // must not rewrite that identity before transport or result persistence.
11
+ const { data, ...transcript } = event;
12
+ return {
13
+ ...redactSecrets(transcript, exactSecrets),
14
+ data,
15
+ };
16
+ }
17
+ export function redactRunOnceResultPacket(result, exactSecrets = []) {
18
+ const { events, ...payload } = result;
19
+ return {
20
+ ...redactSecrets(payload, exactSecrets),
21
+ events: events.map(event => redactRunnerDispatchEvent(event, exactSecrets)),
22
+ };
23
+ }
@@ -1,7 +1,12 @@
1
- import type { RunOnceDispatchPacket, RunOnceResultPacket, RunnerDispatchEvent } from "./session.types.js";
1
+ import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket, RunnerDispatchEvent } from "./session.types.js";
2
+ import type { HostRuntimeCapacitySnapshot, HostRuntimeReapOptions, HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
2
3
  export interface SessionEventSink {
3
4
  emit(event: RunnerDispatchEvent): Promise<void>;
4
5
  }
5
6
  export interface SessionService {
6
7
  runOnce(dispatch: RunOnceDispatchPacket, sink: SessionEventSink, signal?: AbortSignal): Promise<RunOnceResultPacket>;
8
+ updateLease?(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
9
+ reapHostRuntime?(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
10
+ runtimeCapacity?(): HostRuntimeCapacitySnapshot | null;
11
+ probeHostRuntime?(request: HostRuntimeReadinessProbeRequest, signal?: AbortSignal): Promise<HostRuntimeReadinessProbeResult>;
7
12
  }
@@ -1,10 +1,16 @@
1
1
  import type { ProviderCliService } from "./provider-cli/provider-cli.base.js";
2
2
  import type { SessionEventSink, SessionService } from "./session.base.js";
3
- import type { RunOnceDispatchPacket, RunOnceResultPacket } from "./session.types.js";
3
+ import type { HostRuntimeReadinessProbeRequest, HostRuntimeReadinessProbeResult, RunOnceDispatchPacket, RunOnceResultPacket } from "./session.types.js";
4
4
  import type { WorktreeService } from "../worktree/worktree.base.js";
5
+ import { type HostRuntimeCapacitySnapshot, type HostRuntimeLeaseRuntime, type HostRuntimeReapOptions, type HostRuntimeReapReport } from "../runtime/host-runtime-lease.js";
5
6
  export declare class BridgeSessionService implements SessionService {
6
7
  private readonly worktrees;
7
8
  private readonly providerCli;
8
- constructor(worktrees?: WorktreeService, providerCli?: ProviderCliService);
9
+ private readonly hostRuntime?;
10
+ constructor(worktrees?: WorktreeService, providerCli?: ProviderCliService, hostRuntime?: HostRuntimeLeaseRuntime | undefined);
11
+ updateLease(dispatchAttemptId: string, fencingToken: string, expiresAt: string): Promise<void>;
12
+ reapHostRuntime(options: HostRuntimeReapOptions): Promise<HostRuntimeReapReport | null>;
13
+ runtimeCapacity(): HostRuntimeCapacitySnapshot | null;
14
+ probeHostRuntime(request: HostRuntimeReadinessProbeRequest, signal?: AbortSignal): Promise<HostRuntimeReadinessProbeResult>;
9
15
  runOnce(dispatch: RunOnceDispatchPacket, sink: SessionEventSink, signal?: AbortSignal): Promise<RunOnceResultPacket>;
10
16
  }