@loucompanion/forge-bridge 0.1.3-dev.9d8f2e7e5241 → 0.1.3-dev.a58d7cd1092f

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 +83 -0
  2. package/dist/bridge/bridge.base.d.ts +4 -1
  3. package/dist/bridge/bridge.service.d.ts +55 -3
  4. package/dist/bridge/bridge.service.js +834 -87
  5. package/dist/bridge/bridge.types.d.ts +89 -1
  6. package/dist/bridge/runner-host-capabilities.d.ts +15 -0
  7. package/dist/bridge/runner-host-capabilities.js +93 -0
  8. package/dist/cleanup/cleanup.service.d.ts +14 -2
  9. package/dist/cleanup/cleanup.service.js +496 -3
  10. package/dist/cleanup/cleanup.types.d.ts +10 -0
  11. package/dist/cleanup/index.d.ts +1 -1
  12. package/dist/cleanup/index.js +1 -1
  13. package/dist/cleanup/internals.d.ts +2 -2
  14. package/dist/cleanup/internals.js +1 -1
  15. package/dist/cli/cli.help.js +37 -3
  16. package/dist/cli/cli.service.d.ts +33 -2
  17. package/dist/cli/cli.service.js +209 -27
  18. package/dist/cli/local-config.d.ts +5 -0
  19. package/dist/cli/local-config.js +45 -1
  20. package/dist/runtime/aspnet-runtime-prebuild.d.ts +36 -0
  21. package/dist/runtime/aspnet-runtime-prebuild.js +340 -0
  22. package/dist/runtime/attempt-node-runtime-launcher.d.ts +17 -0
  23. package/dist/runtime/attempt-node-runtime-launcher.js +105 -0
  24. package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
  25. package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
  26. package/dist/runtime/attempt-process-supervisor.d.ts +97 -0
  27. package/dist/runtime/attempt-process-supervisor.js +386 -0
  28. package/dist/runtime/docker-engine-probe.d.ts +83 -0
  29. package/dist/runtime/docker-engine-probe.js +300 -0
  30. package/dist/runtime/generated-output-reset.d.ts +10 -0
  31. package/dist/runtime/generated-output-reset.js +103 -0
  32. package/dist/runtime/host-listener-inspector.d.ts +46 -0
  33. package/dist/runtime/host-listener-inspector.js +349 -0
  34. package/dist/runtime/host-port-broker.d.ts +76 -0
  35. package/dist/runtime/host-port-broker.js +333 -0
  36. package/dist/runtime/host-runtime-contract.d.ts +47 -0
  37. package/dist/runtime/host-runtime-contract.js +700 -0
  38. package/dist/runtime/host-runtime-lease.d.ts +197 -0
  39. package/dist/runtime/host-runtime-lease.js +2203 -0
  40. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  41. package/dist/runtime/host-runtime-promotion.js +159 -0
  42. package/dist/runtime/memory-capacity.d.ts +68 -0
  43. package/dist/runtime/memory-capacity.js +121 -0
  44. package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
  45. package/dist/runtime/node-host-runtime-adapter.js +284 -0
  46. package/dist/runtime/playwright-host-runtime-adapter.d.ts +21 -0
  47. package/dist/runtime/playwright-host-runtime-adapter.js +231 -0
  48. package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
  49. package/dist/runtime/runtime-isolation-lease.js +158 -0
  50. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  51. package/dist/runtime/workspace-resource-estimator.js +174 -0
  52. package/dist/sandbox/preflight.d.ts +45 -1
  53. package/dist/sandbox/preflight.js +299 -34
  54. package/dist/sandbox/process.js +21 -2
  55. package/dist/sandbox/repository-lock.js +41 -3
  56. package/dist/sandbox/runtime.d.ts +66 -3
  57. package/dist/sandbox/runtime.js +670 -105
  58. package/dist/sandbox/sandbox.types.d.ts +10 -0
  59. package/dist/sandbox/smoke.d.ts +76 -0
  60. package/dist/sandbox/smoke.js +380 -0
  61. package/dist/sandbox/worker-supervisor.js +1 -1
  62. package/dist/sandbox/worker.js +2 -5
  63. package/dist/sandbox/workspace.service.d.ts +1 -0
  64. package/dist/sandbox/workspace.service.js +28 -5
  65. package/dist/session/managed-attempt-tools.d.ts +21 -0
  66. package/dist/session/managed-attempt-tools.js +912 -0
  67. package/dist/session/managed-build-coordinator.d.ts +5 -0
  68. package/dist/session/managed-build-coordinator.js +105 -0
  69. package/dist/session/managed-build-receipt.d.ts +21 -0
  70. package/dist/session/managed-build-receipt.js +335 -0
  71. package/dist/session/phase-completion.artifacts.d.ts +17 -0
  72. package/dist/session/phase-completion.artifacts.js +233 -24
  73. package/dist/session/phase-completion.d.ts +12 -2
  74. package/dist/session/phase-completion.helpers.d.ts +5 -0
  75. package/dist/session/phase-completion.helpers.js +51 -10
  76. package/dist/session/phase-completion.js +14 -3
  77. package/dist/session/phase-completion.prompts.d.ts +3 -3
  78. package/dist/session/phase-completion.prompts.js +24 -8
  79. package/dist/session/phase-completion.runtime.d.ts +13 -1
  80. package/dist/session/phase-completion.runtime.js +189 -8
  81. package/dist/session/phase-completion.schemas.js +117 -4
  82. package/dist/session/phase-completion.validation.d.ts +4 -1
  83. package/dist/session/phase-completion.validation.js +153 -22
  84. package/dist/session/pre-publication-validation.d.ts +46 -0
  85. package/dist/session/pre-publication-validation.js +208 -0
  86. package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
  87. package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
  88. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +3 -2
  89. package/dist/session/provider-cli/provider-cli.artifacts.js +65 -7
  90. package/dist/session/provider-cli/provider-cli.deterministic.js +47 -1
  91. package/dist/session/provider-cli/provider-cli.process.d.ts +25 -0
  92. package/dist/session/provider-cli/provider-cli.process.js +463 -34
  93. package/dist/session/provider-cli/provider-cli.prompts.d.ts +4 -1
  94. package/dist/session/provider-cli/provider-cli.prompts.js +108 -25
  95. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +1 -0
  96. package/dist/session/provider-cli/provider-cli.runtime.d.ts +1 -1
  97. package/dist/session/provider-cli/provider-cli.runtime.js +6 -3
  98. package/dist/session/provider-cli/provider-cli.service.d.ts +22 -2
  99. package/dist/session/provider-cli/provider-cli.service.js +529 -100
  100. package/dist/session/provider-cli/provider-cli.types.d.ts +5 -0
  101. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  102. package/dist/session/provider-cli/provider-output-state.js +91 -16
  103. package/dist/session/provider-cli/provider-usage.d.ts +7 -0
  104. package/dist/session/provider-cli/provider-usage.js +28 -5
  105. package/dist/session/session-redaction.d.ts +3 -0
  106. package/dist/session/session-redaction.js +38 -0
  107. package/dist/session/session.base.d.ts +6 -1
  108. package/dist/session/session.service.d.ts +8 -2
  109. package/dist/session/session.service.js +522 -41
  110. package/dist/session/session.types.d.ts +72 -0
  111. package/dist/session/session.types.js +74 -3
  112. package/dist/shared/format/format-bytes.d.ts +1 -0
  113. package/dist/shared/format/format-bytes.js +9 -0
  114. package/dist/shared/path/path.d.ts +1 -0
  115. package/dist/shared/path/path.js +21 -1
  116. package/dist/shared/process/dotnet-toolchain.d.ts +14 -0
  117. package/dist/shared/process/dotnet-toolchain.js +179 -0
  118. package/dist/shared/process/host-process-recovery.d.ts +12 -0
  119. package/dist/shared/process/host-process-recovery.js +78 -0
  120. package/dist/shared/process/host-process-supervisor.d.ts +59 -0
  121. package/dist/shared/process/host-process-supervisor.js +330 -0
  122. package/dist/shared/process/process.d.ts +1 -0
  123. package/dist/shared/process/process.js +1 -0
  124. package/dist/shared/redaction/redaction.js +12 -2
  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 +28 -1
  130. package/dist/worktree/dependency-warmer.js +308 -9
  131. package/dist/worktree/index.d.ts +2 -1
  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 +13 -2
  139. package/dist/worktree/worktree.service.js +238 -47
  140. package/dist/worktree/worktree.types.d.ts +5 -1
  141. package/package.json +5 -3
  142. package/runtime/windows-job-supervisor.ps1 +444 -0
  143. package/runtime/windows-listener-owner.ps1 +33 -0
@@ -2,6 +2,7 @@ import type { BridgeServiceConfig } from "../bridge/bridge.types.js";
2
2
  import type { SessionEventSink } from "../session/session.base.js";
3
3
  import { type RunOnceDispatchPacket, type RunOnceResultPacket } from "../session/session.types.js";
4
4
  import type { SandboxService, ValidatedSandboxContract } from "./sandbox.types.js";
5
+ import { type RuntimeIsolationLease } from "../runtime/runtime-isolation-lease.js";
5
6
  export interface SandboxRuntime {
6
7
  runOnce(dispatch: RunOnceDispatchPacket, sink: SessionEventSink, signal?: AbortSignal): Promise<RunOnceResultPacket>;
7
8
  reap(options?: SandboxReapOptions): Promise<void>;
@@ -41,6 +42,28 @@ export interface SandboxRuntimeSnapshot {
41
42
  readonly active: number;
42
43
  readonly degraded: number;
43
44
  }
45
+ export interface SandboxContainerMemoryPeak {
46
+ readonly containerId: string;
47
+ readonly name: string;
48
+ readonly role: string;
49
+ readonly peakMemoryBytes: number;
50
+ }
51
+ export interface SandboxPeakMemoryTelemetry {
52
+ readonly schemaVersion: 1;
53
+ readonly source: "docker_stats_sampled";
54
+ readonly sampleIntervalMs: number;
55
+ readonly sampleCount: number;
56
+ readonly failedSampleCount: number;
57
+ readonly peakMemoryBytes: number;
58
+ readonly firstSampledAt: string;
59
+ readonly lastSampledAt: string;
60
+ readonly containers: readonly SandboxContainerMemoryPeak[];
61
+ }
62
+ export interface DockerStatsMemorySample {
63
+ readonly containerId: string;
64
+ readonly name: string;
65
+ readonly memoryBytes: number;
66
+ }
44
67
  export interface SandboxPublicationGrantRequest {
45
68
  readonly dispatchAttemptId: string;
46
69
  readonly leaseId: string;
@@ -84,6 +107,7 @@ export declare class DockerSandboxRuntime implements SandboxRuntime {
84
107
  private buildImageCore;
85
108
  private runBuildStage;
86
109
  private ensureBuildxBuilder;
110
+ private stopBuildxBuilder;
87
111
  private initializeVolumes;
88
112
  private inspectContainerState;
89
113
  private initializeServiceSecrets;
@@ -102,9 +126,12 @@ export declare class DockerSandboxRuntime implements SandboxRuntime {
102
126
  private readImageCacheRecord;
103
127
  private collectExpiredImages;
104
128
  private purgeRestrictedAuditArtifacts;
129
+ private inspectImageMetadata;
130
+ private startPeakMemorySampler;
105
131
  private docker;
106
132
  private dockerArgs;
107
133
  }
134
+ export declare function managedBranchUpdateExpectedValue(current: string, expectedInput: string, imported: string): string;
108
135
  export declare function publicationPushArgs(branch: string, resultCommitSha: string, inputCommitSha: string, remoteCommitSha: string, remote?: string): string[] | null;
109
136
  export declare function validatePublicationCredential(credential: SandboxPublicationCredential, nowMs?: number): void;
110
137
  export declare function publicationCredentialEnvironment(credential: SandboxPublicationCredential, environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -129,6 +156,7 @@ export declare function selectSandboxConfigRefs(executionPolicy: string, configu
129
156
  readonly refs: readonly string[];
130
157
  readonly approvedSha: string | null;
131
158
  };
159
+ export declare function selectSandboxInputRefs(worktreeKey: string, baseBranch: string): readonly string[];
132
160
  export declare function sandboxTimeLimits(environment?: NodeJS.ProcessEnv): {
133
161
  readonly hardWallMs: number;
134
162
  readonly idleMs: number;
@@ -144,8 +172,10 @@ export interface ImageCacheRecord {
144
172
  readonly overlayTag: string;
145
173
  readonly imageDigest: string;
146
174
  readonly helperImageDigest: string;
175
+ readonly bridgeRuntimeDigest?: string;
147
176
  readonly policyDigest: string;
148
177
  }
178
+ export declare function sandboxWorkerFailureMessage(exitCode: number, stderr: string, containerError: string | null): string;
149
179
  interface ResourceNames {
150
180
  prefix: string;
151
181
  container: string;
@@ -162,18 +192,30 @@ interface SandboxRuntimeVolume {
162
192
  readonly name: string;
163
193
  readonly role: string;
164
194
  }
195
+ export declare function parseDockerMemoryBytes(value: string): number | null;
196
+ export declare function parseDockerStatsMemorySample(output: string): DockerStatsMemorySample[];
165
197
  interface ActiveSandbox {
166
198
  dispatchAttemptId: string;
167
199
  fencingToken: string;
168
200
  expiresAt: string;
169
201
  controller: AbortController;
170
202
  phase: "starting" | "active";
203
+ runtimeLease: RuntimeIsolationLease;
171
204
  ledger: SandboxLedger | null;
172
205
  leaseControlKey: string;
173
206
  }
174
207
  export declare function assertSandboxImportCurrent(expected: Pick<ActiveSandbox, "dispatchAttemptId" | "fencingToken" | "expiresAt">, current: Pick<ActiveSandbox, "dispatchAttemptId" | "fencingToken"> | undefined, signal: AbortSignal, nowMs?: number): void;
175
208
  interface SandboxLedger {
176
- schemaVersion: 1;
209
+ schemaVersion: 3;
210
+ runtimeLease: RuntimeIsolationLease;
211
+ resources: ResourceNames;
212
+ labels: Record<string, string>;
213
+ includeCredentials?: boolean;
214
+ peakMemory?: SandboxPeakMemoryTelemetry;
215
+ }
216
+ interface LegacySandboxLedger {
217
+ schemaVersion: 2;
218
+ resourceLeaseId: string;
177
219
  dispatchAttemptId: string;
178
220
  fencingToken: string;
179
221
  runnerInstanceId: string;
@@ -181,13 +223,18 @@ interface SandboxLedger {
181
223
  resources: ResourceNames;
182
224
  labels: Record<string, string>;
183
225
  includeCredentials?: boolean;
226
+ peakMemory?: SandboxPeakMemoryTelemetry;
184
227
  }
228
+ export declare function validSandboxLedger(value: unknown): boolean;
229
+ export declare function normalizeSandboxLedger(value: unknown): SandboxLedger | null;
185
230
  export declare function resourceNames(attemptHex: string, perAttemptCaches?: readonly string[]): ResourceNames;
186
231
  export declare function dockerObjectId(output: string, kind: "container" | "network"): string;
187
232
  export declare function sandboxRuntimeVolumes(resources: ResourceNames, includeEgressPolicy?: boolean, includeCredentials?: boolean): SandboxRuntimeVolume[];
188
233
  export declare function sandboxRuntimeCleanupVolumeNames(resources: ResourceNames, includeCredentials?: boolean): string[];
234
+ export declare function sandboxResourceLabels(dispatch: RunOnceDispatchPacket, image: string, contract: string): Record<string, string>;
189
235
  export declare function mayReapManagedResource(labels: Readonly<Record<string, string>>, runnerId: string, liveAttempts: ReadonlySet<string>): boolean;
190
- export declare function shouldReapSandboxLedger(ledger: Readonly<Pick<SandboxLedger, "dispatchAttemptId" | "fencingToken" | "runnerInstanceId" | "expiresAt">>, currentRunnerInstanceId: string, serverAttempt: SandboxAttemptSnapshot | undefined, snapshotAvailable: boolean, nowMs?: number): boolean;
236
+ export declare function shouldReapSandboxLedger(ledger: Readonly<Pick<SandboxLedger, "runtimeLease">> | Readonly<Pick<LegacySandboxLedger, "dispatchAttemptId" | "fencingToken" | "runnerInstanceId" | "expiresAt">>, currentRunnerInstanceId: string, serverAttempt: SandboxAttemptSnapshot | undefined, snapshotAvailable: boolean, nowMs?: number): boolean;
237
+ export declare function bridgeRuntimeCacheMatches(record: Pick<ImageCacheRecord, "bridgeRuntimeDigest"> | null | undefined, expectedDigest: string, imageLabels: readonly (Readonly<Record<string, string>> | null | undefined)[]): boolean;
191
238
  export declare function prepareOverlayBuildRoot(overlayRoot: string): Promise<void>;
192
239
  export declare function extractOciLayoutArchive(archivePath: string, destination: string, signal?: AbortSignal): Promise<void>;
193
240
  export declare function ociLayoutContextRef(layoutPath: string): string;
@@ -200,6 +247,20 @@ export declare function readOciLayoutImageDigest(layoutRoot: string): Promise<st
200
247
  export declare function removeExtractedOciLayout(layoutRoot: string): Promise<void>;
201
248
  export declare function ociLayoutScanTarget(layoutPath: string): string;
202
249
  export declare function agentOverlayDockerignore(): string;
250
+ export interface SandboxImageCacheKeyInput {
251
+ readonly contextDigest: string;
252
+ readonly contractDigest: string;
253
+ readonly platform: string;
254
+ readonly architecture: string;
255
+ readonly bridgeVersion: string;
256
+ readonly bridgeRuntimeDigest: string;
257
+ readonly toolingImage: string;
258
+ readonly codexVersion: string;
259
+ readonly policy: string;
260
+ readonly policyConfigurationDigest: string;
261
+ }
262
+ export declare function sandboxImageCacheKey(input: SandboxImageCacheKeyInput): string;
263
+ export declare function bridgeRuntimeContentDigest(packageRoot: string): Promise<string>;
203
264
  export declare function agentOverlayDockerfile(toolingImage: string, projectContextName: string, installMode: BridgePackageInstallMode, codexVersion: string): string;
204
265
  export type BridgePackageInstallMode = "ci" | "install";
205
266
  export declare function copyBridgePackageManifests(packageRoot: string, bridgeRoot: string): Promise<BridgePackageInstallMode>;
@@ -211,17 +272,19 @@ export declare function buildResourcePolicy(environment?: NodeJS.ProcessEnv): {
211
272
  readonly nofile: number;
212
273
  readonly sharedMemory: string;
213
274
  readonly builderPidsLimit: number;
275
+ readonly builderMemoryBytes: number;
214
276
  };
215
277
  export declare function dedicatedBuildxBuilderName(runnerId: string, dockerContext: string | null | undefined): string;
216
278
  export declare function dedicatedBuildxBuilderContainerName(builder: string): string;
217
279
  export declare function selectImageGcCandidates(records: readonly ImageCacheRecord[], keepPerProject: number, ttlMs: number, nowMs: number): ImageCacheRecord[];
218
280
  export declare function workerCreateArgs(dispatch: RunOnceDispatchPacket, contract: ValidatedSandboxContract, resources: ResourceNames, labels: Record<string, string>, image: string, securityOptions?: readonly string[]): string[];
281
+ export declare function validateSandboxMemoryReservation(dispatch: RunOnceDispatchPacket, contract: ValidatedSandboxContract): void;
219
282
  export declare function cacheVolumeArgs(contract: ValidatedSandboxContract, resources: ResourceNames): string[];
220
283
  export declare function proxyEnvironmentArgs(dispatch: RunOnceDispatchPacket, contract: ValidatedSandboxContract, resources: ResourceNames): string[];
221
284
  export declare function egressProxyConfig(allowedHosts: readonly string[]): string;
222
285
  export declare function serviceContainerArgs(service: SandboxService, image: string, resources: ResourceNames, labels: Record<string, string>, securityOptions: readonly string[], environment?: NodeJS.ProcessEnv): string[];
223
286
  export declare function resolveSandboxSecurityOptions(executionPolicy: string, environment?: NodeJS.ProcessEnv): string[];
224
- export declare function networkCreateArgs(dispatch: RunOnceDispatchPacket, environment?: NodeJS.ProcessEnv): string[];
287
+ export declare function networkCreateArgs(dispatch: RunOnceDispatchPacket, environment?: NodeJS.ProcessEnv, allowOpenPublicSandbox?: boolean): string[];
225
288
  export declare function classifySandboxRuntimeFailure(value: string): {
226
289
  readonly code: string;
227
290
  readonly phase: string;