@loucompanion/forge-bridge 0.1.3-dev.b6be5e7f9668 → 0.1.3-dev.bca7d0ccee53
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 +78 -0
- package/dist/bridge/bridge.base.d.ts +6 -1
- package/dist/bridge/bridge.service.d.ts +60 -3
- package/dist/bridge/bridge.service.js +970 -24
- package/dist/bridge/bridge.types.d.ts +172 -1
- package/dist/cleanup/cleanup.service.d.ts +13 -2
- package/dist/cleanup/cleanup.service.js +435 -3
- package/dist/cleanup/cleanup.types.d.ts +10 -0
- package/dist/cleanup/index.d.ts +1 -1
- package/dist/cleanup/index.js +1 -1
- package/dist/cleanup/internals.d.ts +2 -2
- package/dist/cleanup/internals.js +1 -1
- package/dist/cli/cli.help.d.ts +2 -0
- package/dist/cli/cli.help.js +217 -0
- package/dist/cli/cli.service.d.ts +42 -2
- package/dist/cli/cli.service.js +357 -206
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +47 -3
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +17 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +101 -0
- package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
- package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +86 -0
- package/dist/runtime/attempt-process-supervisor.js +350 -0
- package/dist/runtime/generated-output-reset.d.ts +10 -0
- package/dist/runtime/generated-output-reset.js +103 -0
- package/dist/runtime/host-listener-inspector.d.ts +44 -0
- package/dist/runtime/host-listener-inspector.js +324 -0
- package/dist/runtime/host-port-broker.d.ts +76 -0
- package/dist/runtime/host-port-broker.js +333 -0
- package/dist/runtime/host-runtime-contract.d.ts +47 -0
- package/dist/runtime/host-runtime-contract.js +700 -0
- package/dist/runtime/host-runtime-lease.d.ts +133 -0
- package/dist/runtime/host-runtime-lease.js +1462 -0
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +159 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +51 -0
- package/dist/runtime/node-host-runtime-adapter.js +268 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +20 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +220 -0
- package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
- package/dist/runtime/runtime-isolation-lease.js +158 -0
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/image-policy.d.ts +35 -0
- package/dist/sandbox/image-policy.js +247 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/preflight.d.ts +54 -0
- package/dist/sandbox/preflight.js +335 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +209 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +5 -0
- package/dist/sandbox/repository-lock.js +119 -0
- package/dist/sandbox/runtime.d.ts +297 -0
- package/dist/sandbox/runtime.js +2338 -0
- package/dist/sandbox/sandbox.types.d.ts +86 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/smoke.d.ts +76 -0
- package/dist/sandbox/smoke.js +380 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +225 -0
- package/dist/sandbox/workspace.service.d.ts +13 -0
- package/dist/sandbox/workspace.service.js +72 -0
- package/dist/session/managed-attempt-tools.d.ts +17 -0
- package/dist/session/managed-attempt-tools.js +712 -0
- package/dist/session/phase-completion.artifacts.d.ts +10 -0
- package/dist/session/phase-completion.artifacts.js +627 -0
- package/dist/session/phase-completion.d.ts +43 -46
- package/dist/session/phase-completion.helpers.d.ts +117 -0
- package/dist/session/phase-completion.helpers.js +701 -0
- package/dist/session/phase-completion.js +40 -3488
- package/dist/session/phase-completion.prompts.d.ts +14 -0
- package/dist/session/phase-completion.prompts.js +235 -0
- package/dist/session/phase-completion.runtime.d.ts +48 -0
- package/dist/session/phase-completion.runtime.js +786 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -0
- package/dist/session/phase-completion.schemas.js +812 -0
- package/dist/session/phase-completion.validation.d.ts +37 -0
- package/dist/session/phase-completion.validation.js +850 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +95 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +93 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +778 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +375 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +48 -0
- package/dist/session/provider-cli/provider-cli.process.js +474 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +47 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +595 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +9 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +41 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +26 -53
- package/dist/session/provider-cli/provider-cli.service.js +524 -2571
- package/dist/session/provider-cli/provider-cli.types.d.ts +6 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +22 -0
- package/dist/session/provider-cli/provider-output-state.js +473 -0
- package/dist/session/session-redaction.d.ts +3 -0
- package/dist/session/session-redaction.js +23 -0
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +8 -2
- package/dist/session/session.service.js +480 -58
- package/dist/session/session.types.d.ts +161 -1
- package/dist/session/session.types.js +318 -3
- package/dist/shared/path/path.js +3 -1
- package/dist/shared/process/host-process-recovery.d.ts +12 -0
- package/dist/shared/process/host-process-recovery.js +78 -0
- package/dist/shared/process/host-process-supervisor.d.ts +57 -0
- package/dist/shared/process/host-process-supervisor.js +282 -0
- package/dist/shared/process/process.d.ts +1 -0
- package/dist/shared/process/process.js +1 -0
- package/dist/shared/process/windows-launch.d.ts +8 -0
- package/dist/shared/process/windows-launch.js +41 -0
- package/dist/shared/provider-capabilities.d.ts +1 -0
- package/dist/shared/provider-capabilities.js +3 -0
- package/dist/shared/redaction/redaction.js +10 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.d.ts +3 -2
- package/dist/worktree/artifact-injector.js +82 -10
- package/dist/worktree/dependency-warmer.d.ts +21 -1
- package/dist/worktree/dependency-warmer.js +138 -5
- package/dist/worktree/index.d.ts +1 -0
- package/dist/worktree/index.js +1 -0
- package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
- package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
- package/dist/worktree/worktree-paths.d.ts +4 -0
- package/dist/worktree/worktree-paths.js +30 -0
- package/dist/worktree/worktree.base.d.ts +3 -0
- package/dist/worktree/worktree.service.d.ts +9 -3
- package/dist/worktree/worktree.service.js +100 -52
- package/dist/worktree/worktree.types.d.ts +3 -1
- package/package.json +6 -3
- package/runtime/windows-job-supervisor.ps1 +356 -0
- package/runtime/windows-listener-owner.ps1 +33 -0
package/README.md
CHANGED
|
@@ -33,6 +33,16 @@ The bridge can also read connection settings from environment variables:
|
|
|
33
33
|
- `FORGE_CLI_PROVIDERS`
|
|
34
34
|
- `FORGE_CODEX_MODELS` / `FORGE_CURSOR_MODELS` (optional comma-separated model ids advertised in runner capabilities)
|
|
35
35
|
|
|
36
|
+
Show or change the saved server without editing `bridge.json`:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
forge-bridge server show
|
|
40
|
+
forge-bridge server set http://localhost:5208
|
|
41
|
+
forge-bridge server set https://srv1493013.tail66073d.ts.net:8443
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`FORGE_URL` overrides the saved server. Changing the saved URL retains runner credentials so aliases for the same deployment keep working; pair again with `--server` when switching to a different Forge deployment.
|
|
45
|
+
|
|
36
46
|
## Repo-local development
|
|
37
47
|
|
|
38
48
|
For active Forge branch development, run the bridge directly from the checkout instead of publishing a package:
|
|
@@ -53,6 +63,74 @@ forge-bridge add-repo Forge /path/to/Forge
|
|
|
53
63
|
forge-bridge remove-repo Forge
|
|
54
64
|
```
|
|
55
65
|
|
|
66
|
+
## Docker sandbox runners
|
|
67
|
+
|
|
68
|
+
Protocol-v2 bridges preflight Docker before advertising the `docker` sandbox runtime. Validate a repository contract and the local runner before enabling a project's `sandbox_required` policy:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
forge sandbox init
|
|
72
|
+
forge sandbox doctor
|
|
73
|
+
forge sandbox smoke
|
|
74
|
+
forge-bridge sandbox reap
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Configure the local bridge's persistent Docker placement policy with:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
forge-bridge sandbox on
|
|
81
|
+
forge-bridge sandbox on --allow-open-public
|
|
82
|
+
forge-bridge sandbox status
|
|
83
|
+
forge-bridge sandbox off
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`sandbox on` keeps unrestricted public networking denied by default. The developer-only
|
|
87
|
+
`--allow-open-public` option stores an explicit local approval in `bridge.json`; it survives
|
|
88
|
+
bridge restarts and is reported by `sandbox status`. Restart a connected bridge after changing
|
|
89
|
+
the policy. `FORGE_DOCKER_SANDBOX` and `FORGE_ALLOW_OPEN_PUBLIC_SANDBOX` remain higher-priority
|
|
90
|
+
operator overrides when present.
|
|
91
|
+
|
|
92
|
+
`forge sandbox smoke` runs doctor, builds the repository-owned `.forge/Dockerfile`, launches a disposable hardened container on an internal network with a fresh workspace volume, and verifies that its exact attempt-labeled container, network, volume, and image are gone afterward. It writes a redacted JSON report under `FORGE_SANDBOX_STATE_ROOT/smoke-reports`; use `--report <path>` to choose a different destination. Stop the connected bridge before running smoke so the command can exclusively acquire the Docker-context ownership lock.
|
|
93
|
+
|
|
94
|
+
Use `forge sandbox smoke --probe-loopback-port` only when proving Docker host-port allocation. The normal hardened container remains internal with no publication; a separate exact-labeled fixture requests `127.0.0.1::8080/tcp`, records Docker's assigned loopback port, rejects wildcard or ambiguous mappings, and is removed by the same exact-label cleanup verification.
|
|
95
|
+
|
|
96
|
+
Production shared runners require a Linux rootless Docker daemon. Docker Desktop is developer-only and must be opted in with `FORGE_ALLOW_DOCKER_DESKTOP_SANDBOX=true`. Useful runner settings are:
|
|
97
|
+
|
|
98
|
+
- `FORGE_TRUST_DOMAIN_ID` — must match the project trust domain.
|
|
99
|
+
- `FORGE_MAX_CONCURRENT_SANDBOXES` — hard slot ceiling; start at `1`.
|
|
100
|
+
- `FORGE_MAX_CONCURRENT_SANDBOX_BUILDS` / `FORGE_SANDBOX_PID_CAPACITY` — weighted build and PID admission ceilings (defaults: `1` and `2048`).
|
|
101
|
+
- `FORGE_DOCKER_CONTEXT` / `FORGE_DOCKER_EXECUTABLE` — dedicated daemon selection.
|
|
102
|
+
- `FORGE_SANDBOX_STATE_ROOT` — fsync'd attempt ledgers, restricted diagnostics, and build state.
|
|
103
|
+
- `FORGE_DISK_HIGH_WATERMARK_PERCENT` / `FORGE_DISK_LOW_WATERMARK_PERCENT` / `FORGE_MINIMUM_WORKSPACE_BYTES` — admission watermarks with high/low hysteresis.
|
|
104
|
+
- `FORGE_SANDBOX_HOST_MEMORY_RESERVE_BYTES` — host memory withheld from sandbox admission. The default is 2 GiB, or 1 GiB when Docker Desktop developer mode is explicitly enabled; production Linux/rootless runners retain 2 GiB unless an operator supplies a measured override.
|
|
105
|
+
- `FORGE_SANDBOX_MEMORY_SAMPLE_INTERVAL_MS` — interval for sampled Docker peak-memory telemetry (default `1000` ms, clamped to `250`–`30000` ms). Sampling is diagnostic and never changes an attempt outcome.
|
|
106
|
+
- `FORGE_SANDBOX_DEDICATED_DISK=true` — operator assertion that sandbox storage is on a dedicated, conservatively watermarked disk when the Docker storage driver cannot enforce per-volume quotas. `sandbox_required` fails placement unless either quota support or this assertion is advertised.
|
|
107
|
+
- `FORGE_SANDBOX_IMAGE_RETENTION_COUNT` / `FORGE_SANDBOX_IMAGE_RETENTION_TTL_MS` — per-project image-cache retention (defaults: 3 images and 7 days).
|
|
108
|
+
- `FORGE_SANDBOX_AUDIT_RETENTION_COUNT` / `FORGE_SANDBOX_AUDIT_RETENTION_TTL_MS` — restricted failed-build/attestation retention (defaults: 200 keys and 30 days); evidence for active image digests is protected.
|
|
109
|
+
- `FORGE_AGENT_TOOLING_IMAGE` — digest-pinned Node tooling base required by `sandbox_required`.
|
|
110
|
+
- `FORGE_SANDBOX_IMAGE_POLICY_ENFORCED`, `FORGE_SANDBOX_SBOM_EXECUTABLE`, `FORGE_SANDBOX_VULNERABILITY_EXECUTABLE`, and `FORGE_SANDBOX_PROVENANCE_SIGNING_KEY` — required generated-image promotion gates. The SBOM command must accept Syft-compatible `<image> -o spdx-json`; the vulnerability command must accept Trivy-compatible image arguments.
|
|
111
|
+
- `FORGE_SANDBOX_SIGNATURE_EXECUTABLE` / `FORGE_SANDBOX_SIGNATURE_PUBLIC_KEY` — Cosign-compatible verifier and bounded public-key file. `sandbox_required` verifies every digest-pinned external Dockerfile base/`COPY --from` source and Forge tooling base before generated-image promotion, plus every service-catalog and egress-proxy image before runtime use; adoption modes emit a warning when verification is not configured.
|
|
112
|
+
- `FORGE_SANDBOX_BUILD_EGRESS_ENFORCED` — confirms the dedicated BuildKit builder is behind the approved build-egress control; required for `sandbox_required`.
|
|
113
|
+
- `FORGE_SANDBOX_BUILD_NOFILE` — bounded per-build-step file-descriptor cap (default: `4096`). `FORGE_SANDBOX_BUILDER_PIDS_LIMIT` caps and verifies aggregate processes on the dedicated BuildKit container (default `512`). Buildx `--resource` memory/CPU caps are intentionally not emitted because they are not portable across supported Buildx versions; agent runtime containers still receive Docker memory/CPU limits.
|
|
114
|
+
- `FORGE_SANDBOX_BUILDKIT_CACHE_MAX` / `FORGE_SANDBOX_BUILDKIT_CACHE_RESERVED` — pressure-triggered dedicated-builder cache bounds (defaults: 20 GiB maximum and 2 GiB reserved; minimum free space follows `FORGE_MINIMUM_WORKSPACE_BYTES`).
|
|
115
|
+
- `FORGE_SANDBOX_SECCOMP_PROFILE` / `FORGE_SANDBOX_LSM_SECURITY_OPT` — absolute hardened seccomp profile and AppArmor/SELinux Docker security option applied to every agent and service; required for `sandbox_required`.
|
|
116
|
+
- `FORGE_SANDBOX_HARD_WALL_SECONDS` / `FORGE_SANDBOX_IDLE_SECONDS` — monotonic worker deadlines (defaults: 8 hours and 30 minutes; both are capped by the 8-hour hard maximum).
|
|
117
|
+
- `FORGE_SANDBOX_PUBLICATION_MODE=bridge_push` — remote-safe exact-SHA result publication. This is required for `sandbox_required`; the default `shared_filesystem` mode is intended only for deployments where the bridge and API intentionally share the repository filesystem.
|
|
118
|
+
- `FORGE_SERVICE_POSTGRES_IMAGE`, `FORGE_SERVICE_REDIS_IMAGE`, and `FORGE_SERVICE_BROWSER_IMAGE` — digest-pinned service-catalog images when declared by a contract.
|
|
119
|
+
|
|
120
|
+
`public_allowlist` uses an internal agent network plus a separate external network joined only by a restricted Squid-compatible proxy. Configure a digest-pinned `FORGE_SANDBOX_EGRESS_PROXY_IMAGE` and `FORGE_SANDBOX_EGRESS_ENFORCED=true`; Forge generates the domain allowlist with private, loopback, link-local, metadata, unsafe-port, and default-deny rules and injects proxy variables into the worker. `open_public` is developer-only and additionally requires `FORGE_ALLOW_OPEN_PUBLIC_SANDBOX=true`. Neither setting weakens `sandbox_required`.
|
|
121
|
+
|
|
122
|
+
Before selecting `sandbox_required`, save the full approved 40- or 64-character Git commit SHA in the project's Sandbox policy dialog. The server persists that SHA on the immutable attempt and the bridge reads `.forge/forge.sandbox.yml`, `.forge/Dockerfile`, and the tracked build context only from that commit. API-key dispatches carry an opaque one-time grant handle; the authenticated current runner instance redeems it after reservation, and plaintext stays out of offers, database payloads, Docker metadata, and host-persisted control files.
|
|
123
|
+
|
|
124
|
+
Temporary host fallback for `sandbox_preferred` requires both sides to opt in: a project owner must save a reason and future expiry (maximum 30 days), and an operator must enable **Host fallback** for the runner in Profile Settings. Either missing or expired authorization fails closed. `sandbox_required` never falls back.
|
|
125
|
+
|
|
126
|
+
The bridge reaps exact-labeled orphan resources before connecting and every minute afterward. Connected passes reconcile current-instance ledgers against an authoritative, instance-scoped server attempt snapshot; startup does not adopt old-instance resources and terminates them before advertising capacity. Per-resource removal outcomes are written mode-0600 under `FORGE_SANDBOX_STATE_ROOT/cleanup-reports` before transmission, replayed after reconnect, acknowledged by report ID, and persisted by the API only when attempt, fence, resource runner instance, and current reporting runner match. Fenced dispatch events also persist image/cache status, build/agent-start/import/teardown timestamps, and a validated inventory of created agent/sidecar containers, networks, volumes, and published ports. Selected-session diagnostics expose that lifecycle data and recent cleanup actions while retaining cleanup-pending state after the agent outcome is terminal. Install `forge-bridge sandbox reap` as an independently supervised OS timer with the same `FORGE_RUNNER_ID`, Docker context, and state root so resources are reconciled while the bridge is down; the Docker-context ownership lock makes an overlapping pass fail safely. A non-zero `degradedReservationCount` means teardown has not completed; the affected capacity remains unavailable until a successful reaper pass. Drain a runner from Profile Settings before upgrades or Docker maintenance, wait for active/starting counts to reach zero, then restart the bridge. Profile Settings also exposes a scoped **Reap** action; the API delivers it only to the currently established protocol-v2 runner instance. Image GC runs only while disk pressure is latched, shares the build lock, preserves active image digests, and prunes only expired images beyond the per-project retention count. Lease renewals are HMAC-bound to the attempt and fence and advance an in-container monotonic deadline; lease, hard-wall, and idle expiry produce distinct failure codes.
|
|
127
|
+
|
|
128
|
+
Every attempt-owned container (including short-lived initialization helpers), network, and volume carries `dev.forge.resource-lease-id` equal to the dispatch execution lease. Ledger schema v2 persists the same `resourceLeaseId`; teardown compares the complete expected label set, and orphan reaping fails closed unless the managed, resource-lease, execution-lease, attempt, runner, runner-instance, and fencing identities are all present and consistent.
|
|
129
|
+
|
|
130
|
+
In `bridge_push` mode, the start packet carries only an attempt/fence/branch-bound publication handle. After validating and importing the output bundle, the authenticated current bridge redeems that handle for an in-memory, exact-repository credential; the API rechecks the live lease/fence/grant/branch/result SHA and records redemption before returning it. Git receives the credential through a process environment configuration, never command arguments, files, Git config, or the container. The bridge compares the remote branch with the immutable input commit and pushes only the exact result commit using `--force-with-lease`; cancellation aborts Git, an already-published matching result is an idempotent success, and any other remote value is rejected as stale. The API records the fenced publication acknowledgment before sign-off and does not push the branch a second time while opening the pull request.
|
|
131
|
+
|
|
132
|
+
Failed project, tooling, and agent image stages preserve only a redacted, capped, mode-0600 diagnostic at `FORGE_SANDBOX_STATE_ROOT/build-logs/<image-key>/<stage>.log`. The event stream carries its digest, byte count, and truncation flag, never the log contents. Treat this directory as restricted source-bearing audit data and apply local retention controls.
|
|
133
|
+
|
|
56
134
|
## Package smoke check
|
|
57
135
|
|
|
58
136
|
From this package directory:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BridgeCancelHandler, BridgeDispatchHandler, BridgeServiceConfig } from "./bridge.types.js";
|
|
1
|
+
import type { BridgeCancelHandler, BridgeDispatchHandler, BridgeLeaseUpdateHandler, BridgeOfferHandler, BridgeReadinessProbeHandler, BridgeReapHandler, BridgeServiceConfig, BridgeStartHandler } from "./bridge.types.js";
|
|
2
2
|
export interface BridgeService {
|
|
3
3
|
connectOnce(): Promise<void>;
|
|
4
4
|
run(signal?: AbortSignal): Promise<void>;
|
|
@@ -9,7 +9,12 @@ export interface BridgeConnection {
|
|
|
9
9
|
stop(): Promise<void>;
|
|
10
10
|
onClose(handler: (error?: Error) => void): void;
|
|
11
11
|
onDispatch(handler: BridgeDispatchHandler): void;
|
|
12
|
+
onOffer?(handler: BridgeOfferHandler): void;
|
|
13
|
+
onStart?(handler: BridgeStartHandler): void;
|
|
14
|
+
onLeaseUpdate?(handler: BridgeLeaseUpdateHandler): void;
|
|
12
15
|
onCancel(handler: BridgeCancelHandler): void;
|
|
16
|
+
onReap?(handler: BridgeReapHandler): void;
|
|
17
|
+
onReadinessProbe?(handler: BridgeReadinessProbeHandler): void;
|
|
13
18
|
invoke<TResponse>(methodName: string, payload: unknown): Promise<TResponse>;
|
|
14
19
|
}
|
|
15
20
|
export interface BridgeConnectionFactory {
|
|
@@ -1,29 +1,72 @@
|
|
|
1
1
|
import type { SessionService } from "../session/session.base.js";
|
|
2
|
+
import { type DispatchSandboxResourceRequest, type RunOnceDispatchPacket } from "../session/session.types.js";
|
|
3
|
+
import { DockerPreflight } from "../sandbox/preflight.js";
|
|
4
|
+
import type { SandboxPreflightResult } from "../sandbox/sandbox.types.js";
|
|
5
|
+
import { type SandboxRuntime } from "../sandbox/runtime.js";
|
|
2
6
|
import type { BridgeConnection, BridgeConnectionFactory, BridgeService } from "./bridge.base.js";
|
|
3
|
-
import type { BridgeCancelHandler, BridgeDispatchHandler, BridgeServiceConfig } from "./bridge.types.js";
|
|
7
|
+
import type { BridgeCancelHandler, BridgeDispatchHandler, BridgeLeaseUpdateRequest, BridgeReapRequest, BridgeServiceConfig } from "./bridge.types.js";
|
|
8
|
+
export type SandboxResourceResolver = (dispatch: RunOnceDispatchPacket) => Promise<ResolvedSandboxResourceProfile>;
|
|
9
|
+
export interface ResolvedSandboxResourceProfile {
|
|
10
|
+
readonly resources: DispatchSandboxResourceRequest;
|
|
11
|
+
readonly sandboxConfigCommitSha: string;
|
|
12
|
+
}
|
|
4
13
|
export declare class ForgeBridgeService implements BridgeService {
|
|
5
14
|
private readonly config;
|
|
6
|
-
private readonly sessions;
|
|
7
15
|
private readonly connections;
|
|
8
16
|
private connection;
|
|
9
17
|
private heartbeatTimer;
|
|
18
|
+
private heartbeatInFlight;
|
|
19
|
+
private consecutiveHeartbeatFailures;
|
|
20
|
+
private reconnectingFromHeartbeatFailure;
|
|
21
|
+
private leaseWatchdogTimer;
|
|
22
|
+
private sandboxMaintenanceTimer;
|
|
23
|
+
private sandboxMaintenanceRunning;
|
|
10
24
|
private closed;
|
|
11
25
|
private stopped;
|
|
12
26
|
private readonly activeSessions;
|
|
13
|
-
|
|
27
|
+
private readonly reservations;
|
|
28
|
+
private readonly activeReadinessProbes;
|
|
29
|
+
private readonly preflight;
|
|
30
|
+
private readonly sandboxRuntime;
|
|
31
|
+
private readonly sandboxResourceResolver;
|
|
32
|
+
private readonly sessions;
|
|
33
|
+
constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver);
|
|
14
34
|
connectOnce(): Promise<void>;
|
|
15
35
|
run(signal?: AbortSignal): Promise<void>;
|
|
16
36
|
stop(): Promise<void>;
|
|
17
37
|
private handleDispatch;
|
|
38
|
+
private handleOffer;
|
|
39
|
+
private handleStart;
|
|
40
|
+
private redeemSecretGrant;
|
|
41
|
+
private redeemPublishGrant;
|
|
42
|
+
private handleLeaseUpdate;
|
|
43
|
+
private sendOfferDecision;
|
|
18
44
|
private parseDispatchOrReport;
|
|
19
45
|
private handleCancel;
|
|
46
|
+
private handleReap;
|
|
47
|
+
private handleReadinessProbe;
|
|
20
48
|
private abortActiveSessions;
|
|
49
|
+
private abortActiveReadinessProbes;
|
|
21
50
|
private normalizeDispatch;
|
|
22
51
|
private sendResult;
|
|
52
|
+
private sendLegacyResult;
|
|
53
|
+
private sendResultPayload;
|
|
23
54
|
private startHeartbeat;
|
|
55
|
+
private heartbeatTick;
|
|
56
|
+
private startLeaseWatchdog;
|
|
57
|
+
private stopLeaseWatchdog;
|
|
58
|
+
private expireLeases;
|
|
24
59
|
private stopHeartbeat;
|
|
60
|
+
private startSandboxMaintenance;
|
|
61
|
+
private stopSandboxMaintenance;
|
|
62
|
+
private runSandboxMaintenance;
|
|
63
|
+
private readAttemptSnapshot;
|
|
64
|
+
private flushCleanupReports;
|
|
25
65
|
private sendHeartbeat;
|
|
26
66
|
private capabilities;
|
|
67
|
+
private usedSandboxResources;
|
|
68
|
+
private activeSandboxResources;
|
|
69
|
+
private sandboxResourceCapacity;
|
|
27
70
|
private invokeAck;
|
|
28
71
|
private waitForClose;
|
|
29
72
|
private stopConnection;
|
|
@@ -39,8 +82,22 @@ export declare class SignalRBridgeConnection implements BridgeConnection {
|
|
|
39
82
|
stop(): Promise<void>;
|
|
40
83
|
onClose(handler: (error?: Error) => void): void;
|
|
41
84
|
onDispatch(handler: BridgeDispatchHandler): void;
|
|
85
|
+
onOffer(handler: BridgeDispatchHandler): void;
|
|
86
|
+
onStart(handler: BridgeDispatchHandler): void;
|
|
87
|
+
onLeaseUpdate(handler: (request: BridgeLeaseUpdateRequest) => Promise<void>): void;
|
|
42
88
|
onCancel(handler: BridgeCancelHandler): void;
|
|
89
|
+
onReap(handler: (request: BridgeReapRequest) => Promise<void>): void;
|
|
90
|
+
onReadinessProbe(handler: (request: unknown) => Promise<void>): void;
|
|
43
91
|
invoke<TResponse>(methodName: string, payload: unknown): Promise<TResponse>;
|
|
44
92
|
}
|
|
45
93
|
export declare function defaultBridgeServiceConfig(overrides?: Partial<BridgeServiceConfig>): BridgeServiceConfig;
|
|
46
94
|
export declare function resolveBridgeRunnerHubUrl(serverUrl: string): URL;
|
|
95
|
+
export declare function canReapManagedSandboxes(preflight: {
|
|
96
|
+
readonly healthy: boolean;
|
|
97
|
+
readonly unavailableCode?: string | null;
|
|
98
|
+
}): boolean;
|
|
99
|
+
export type SandboxResourceVector = DispatchSandboxResourceRequest;
|
|
100
|
+
export declare function canReserveSandboxResources(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector): boolean;
|
|
101
|
+
export declare function sandboxCapacityFailureMessage(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector, preflight: SandboxPreflightResult | null, config: BridgeServiceConfig): string;
|
|
102
|
+
export declare function resolveDynamicSandboxResources(requested: DispatchSandboxResourceRequest, serviceCount: number, networkMode: "offline" | "public_allowlist" | "open_public", baseRuntimeOverheadBytes?: number): DispatchSandboxResourceRequest;
|
|
103
|
+
export declare function resolveSandboxResourcesFromRepo(dispatch: RunOnceDispatchPacket, baseRuntimeOverheadBytes?: number): Promise<ResolvedSandboxResourceProfile>;
|