@loucompanion/forge-bridge 0.1.3-dev.bd0c67bbf352 → 0.1.3-dev.bf78fdcaa623

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 (88) hide show
  1. package/README.md +44 -0
  2. package/dist/bridge/bridge.base.d.ts +5 -1
  3. package/dist/bridge/bridge.service.d.ts +36 -2
  4. package/dist/bridge/bridge.service.js +588 -18
  5. package/dist/bridge/bridge.types.d.ts +114 -1
  6. package/dist/cli/cli.help.d.ts +2 -0
  7. package/dist/cli/cli.help.js +183 -0
  8. package/dist/cli/cli.service.d.ts +12 -0
  9. package/dist/cli/cli.service.js +176 -184
  10. package/dist/cli/local-config.d.ts +2 -0
  11. package/dist/cli/local-config.js +6 -2
  12. package/dist/sandbox/command-runner.d.ts +4 -0
  13. package/dist/sandbox/command-runner.js +47 -0
  14. package/dist/sandbox/contract.d.ts +5 -0
  15. package/dist/sandbox/contract.js +276 -0
  16. package/dist/sandbox/event-budget.d.ts +11 -0
  17. package/dist/sandbox/event-budget.js +27 -0
  18. package/dist/sandbox/image-policy.d.ts +33 -0
  19. package/dist/sandbox/image-policy.js +245 -0
  20. package/dist/sandbox/index.d.ts +5 -0
  21. package/dist/sandbox/index.js +5 -0
  22. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  23. package/dist/sandbox/lease-watchdog.js +67 -0
  24. package/dist/sandbox/preflight.d.ts +36 -0
  25. package/dist/sandbox/preflight.js +239 -0
  26. package/dist/sandbox/process.d.ts +20 -0
  27. package/dist/sandbox/process.js +124 -0
  28. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  29. package/dist/sandbox/provider-auth/codex.js +212 -0
  30. package/dist/sandbox/repository-lock.d.ts +5 -0
  31. package/dist/sandbox/repository-lock.js +83 -0
  32. package/dist/sandbox/runtime.d.ts +216 -0
  33. package/dist/sandbox/runtime.js +1658 -0
  34. package/dist/sandbox/sandbox.types.d.ts +83 -0
  35. package/dist/sandbox/sandbox.types.js +1 -0
  36. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  37. package/dist/sandbox/worker-supervisor.js +36 -0
  38. package/dist/sandbox/worker.d.ts +1 -0
  39. package/dist/sandbox/worker.js +228 -0
  40. package/dist/sandbox/workspace.service.d.ts +12 -0
  41. package/dist/sandbox/workspace.service.js +49 -0
  42. package/dist/session/phase-completion.artifacts.d.ts +10 -0
  43. package/dist/session/phase-completion.artifacts.js +620 -0
  44. package/dist/session/phase-completion.d.ts +32 -44
  45. package/dist/session/phase-completion.helpers.d.ts +112 -0
  46. package/dist/session/phase-completion.helpers.js +660 -0
  47. package/dist/session/phase-completion.js +28 -3501
  48. package/dist/session/phase-completion.prompts.d.ts +14 -0
  49. package/dist/session/phase-completion.prompts.js +220 -0
  50. package/dist/session/phase-completion.runtime.d.ts +36 -0
  51. package/dist/session/phase-completion.runtime.js +609 -0
  52. package/dist/session/phase-completion.schemas.d.ts +3 -0
  53. package/dist/session/phase-completion.schemas.js +707 -0
  54. package/dist/session/phase-completion.validation.d.ts +34 -0
  55. package/dist/session/phase-completion.validation.js +724 -0
  56. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +93 -0
  57. package/dist/session/provider-cli/provider-cli.artifacts.js +754 -0
  58. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  59. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  60. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  61. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  62. package/dist/session/provider-cli/provider-cli.deterministic.js +329 -0
  63. package/dist/session/provider-cli/provider-cli.process.d.ts +32 -0
  64. package/dist/session/provider-cli/provider-cli.process.js +287 -0
  65. package/dist/session/provider-cli/provider-cli.prompts.d.ts +44 -0
  66. package/dist/session/provider-cli/provider-cli.prompts.js +528 -0
  67. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  68. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +65 -0
  69. package/dist/session/provider-cli/provider-cli.runtime.d.ts +9 -0
  70. package/dist/session/provider-cli/provider-cli.runtime.js +40 -0
  71. package/dist/session/provider-cli/provider-cli.service.d.ts +9 -53
  72. package/dist/session/provider-cli/provider-cli.service.js +161 -2561
  73. package/dist/session/provider-cli/provider-cli.types.d.ts +1 -0
  74. package/dist/session/provider-cli/provider-output-state.d.ts +20 -0
  75. package/dist/session/provider-cli/provider-output-state.js +445 -0
  76. package/dist/session/session.service.js +34 -24
  77. package/dist/session/session.types.d.ts +89 -1
  78. package/dist/session/session.types.js +209 -3
  79. package/dist/shared/process/windows-launch.d.ts +8 -0
  80. package/dist/shared/process/windows-launch.js +41 -0
  81. package/dist/shared/provider-capabilities.d.ts +1 -0
  82. package/dist/shared/provider-capabilities.js +3 -0
  83. package/dist/shared/redaction/redaction.js +4 -2
  84. package/dist/version.d.ts +1 -1
  85. package/dist/version.js +1 -1
  86. package/dist/worktree/dependency-warmer.d.ts +11 -0
  87. package/dist/worktree/dependency-warmer.js +45 -1
  88. package/package.json +4 -2
@@ -1,7 +1,26 @@
1
- import type { RunOnceResultPacket, RunnerDispatchEvent } from "../session/session.types.js";
1
+ import type { ApiKeySecretGrant, RunOnceResultPacket, RunnerDispatchEvent } from "../session/session.types.js";
2
+ import type { SandboxFeatureMatrix } from "../sandbox/sandbox.types.js";
2
3
  export interface BridgeServiceConfig {
3
4
  readonly serverUrl: string;
4
5
  readonly runnerId: string;
6
+ readonly runnerInstanceId: string;
7
+ readonly trustDomainId: string;
8
+ readonly maxConcurrentSandboxes: number;
9
+ readonly maxConcurrentSandboxBuilds: number;
10
+ readonly sandboxPidCapacity: number;
11
+ readonly dockerEnabled: boolean;
12
+ readonly sandboxPublicationMode?: "bridge_push" | "shared_filesystem";
13
+ readonly dockerExecutable: string;
14
+ readonly dockerContext: string;
15
+ readonly sandboxStateRoot: string;
16
+ readonly requireRootlessDocker: boolean;
17
+ readonly diskHighWatermarkPercent: number;
18
+ readonly diskLowWatermarkPercent: number;
19
+ readonly minimumWorkspaceBytes: number;
20
+ readonly imageRetentionCount: number;
21
+ readonly imageRetentionTtlMs: number;
22
+ readonly auditRetentionCount: number;
23
+ readonly auditRetentionTtlMs: number;
5
24
  readonly deviceToken: string;
6
25
  readonly deviceName: string;
7
26
  readonly defaultRepoRoot: string;
@@ -17,6 +36,8 @@ export interface BridgeServiceConfig {
17
36
  readonly supportsManagedForgeArtifacts: boolean;
18
37
  readonly supportsRunnerAuthoredPhaseArtifacts: boolean;
19
38
  readonly supportsDraftRunOnce: boolean;
39
+ readonly supportsDraftAttachments: boolean;
40
+ readonly supportsDraftImageAttachments: boolean;
20
41
  readonly version: string;
21
42
  readonly protocolVersion: number;
22
43
  readonly minServerVersion?: string | null;
@@ -52,17 +73,51 @@ export interface BridgeCapabilities {
52
73
  readonly repoMappings?: readonly BridgeRepoMapping[] | null;
53
74
  readonly os?: string | null;
54
75
  readonly sandboxProfiles?: readonly string[] | null;
76
+ readonly runnerInstanceId?: string | null;
77
+ readonly trustDomainId?: string | null;
78
+ readonly sandboxRuntimes?: readonly string[] | null;
79
+ readonly sandboxRuntimeVersion?: string | null;
80
+ readonly sandboxFeatures?: SandboxFeatureMatrix | null;
81
+ readonly sandboxPublicationModes?: readonly string[] | null;
82
+ readonly sandboxAuthModes?: Readonly<Record<string, readonly string[]>> | null;
83
+ readonly maxConcurrentSandboxes?: number | null;
84
+ readonly reservedSandboxCount?: number | null;
85
+ readonly activeSandboxCount?: number | null;
86
+ readonly startingSandboxCount?: number | null;
87
+ readonly degradedReservationCount?: number | null;
88
+ readonly availableMemoryBytes?: number | null;
89
+ readonly availableCpuMillis?: number | null;
90
+ readonly availableWorkspaceBytes?: number | null;
91
+ readonly diskLow?: boolean | null;
92
+ readonly preflightGeneration?: number | null;
93
+ readonly sandboxUnavailableCode?: string | null;
94
+ readonly sandboxUnavailableReason?: string | null;
55
95
  readonly supportsApiSecretGrant?: boolean | null;
56
96
  readonly supportsManagedWorktrees?: boolean | null;
57
97
  readonly supportsManagedForgeArtifacts?: boolean | null;
58
98
  readonly supportsRunnerAuthoredPhaseArtifacts?: boolean | null;
59
99
  readonly supportsDraftRunOnce?: boolean | null;
100
+ readonly supportsDraftAttachments?: boolean | null;
101
+ readonly supportsDraftImageAttachments?: boolean | null;
60
102
  }
61
103
  export interface BridgeHelloRequest {
62
104
  readonly version: string;
63
105
  readonly protocolVersion: number;
64
106
  readonly capabilities: BridgeCapabilities;
65
107
  readonly minServerVersion?: string | null;
108
+ readonly runnerInstanceId: string;
109
+ }
110
+ export interface BridgePublishCredential {
111
+ readonly username: string;
112
+ readonly secret: string;
113
+ readonly remoteUrl: string;
114
+ readonly expiresAt: string;
115
+ }
116
+ export interface BridgePublishGrantRedemptionResponse {
117
+ readonly accepted: boolean;
118
+ readonly code?: string | null;
119
+ readonly message?: string | null;
120
+ readonly credential?: BridgePublishCredential | null;
66
121
  }
67
122
  export interface BridgeHeartbeatRequest {
68
123
  readonly status?: string | null;
@@ -78,17 +133,75 @@ export interface BridgeCallbackAck {
78
133
  export interface BridgeDispatchEventCallback {
79
134
  readonly leaseId: string;
80
135
  readonly fencingToken: string;
136
+ readonly dispatchAttemptId?: string | null;
137
+ readonly runnerInstanceId?: string | null;
81
138
  readonly event: RunnerDispatchEvent;
82
139
  }
83
140
  export interface BridgeDispatchResultCallback {
84
141
  readonly leaseId: string;
85
142
  readonly fencingToken: string;
143
+ readonly dispatchAttemptId?: string | null;
144
+ readonly runnerInstanceId?: string | null;
86
145
  readonly result: RunOnceResultPacket;
87
146
  }
147
+ export interface BridgeOfferDecisionCallback {
148
+ readonly dispatchAttemptId: string;
149
+ readonly leaseId: string;
150
+ readonly fencingToken: string;
151
+ readonly runnerInstanceId: string;
152
+ readonly accepted: boolean;
153
+ readonly code?: string | null;
154
+ readonly message?: string | null;
155
+ readonly reservedUntil?: string | null;
156
+ }
157
+ export interface BridgeDispatchStartedCallback {
158
+ readonly dispatchAttemptId: string;
159
+ readonly leaseId: string;
160
+ readonly fencingToken: string;
161
+ readonly runnerInstanceId: string;
162
+ }
163
+ export interface BridgeSecretGrantRedemptionRequest {
164
+ readonly dispatchAttemptId: string;
165
+ readonly leaseId: string;
166
+ readonly fencingToken: string;
167
+ readonly runnerInstanceId: string;
168
+ readonly grantId: string;
169
+ }
170
+ export interface BridgeSecretGrantRedemptionResponse extends BridgeCallbackAck {
171
+ readonly grant?: ApiKeySecretGrant | null;
172
+ }
173
+ export interface BridgeLeaseUpdateRequest {
174
+ readonly dispatchAttemptId: string;
175
+ readonly leaseId: string;
176
+ readonly fencingToken: string;
177
+ readonly runnerInstanceId: string;
178
+ readonly expiresAt: string;
179
+ }
88
180
  export interface BridgeCancelRequest {
89
181
  readonly leaseId: string;
90
182
  readonly fencingToken: string;
91
183
  readonly reason?: string | null;
92
184
  }
185
+ export interface BridgeReapRequest {
186
+ readonly runnerId: string;
187
+ readonly runnerInstanceId: string;
188
+ readonly requestedAt: string;
189
+ readonly reason?: string | null;
190
+ }
191
+ export interface BridgeAttemptSnapshotItem {
192
+ readonly dispatchAttemptId: string;
193
+ readonly fencingToken: string;
194
+ readonly runnerInstanceId: string;
195
+ readonly status: string;
196
+ readonly expiresAt: string;
197
+ }
198
+ export interface BridgeAttemptSnapshotResponse extends BridgeCallbackAck {
199
+ readonly attempts?: readonly BridgeAttemptSnapshotItem[] | null;
200
+ readonly generatedAt?: string | null;
201
+ }
93
202
  export type BridgeDispatchHandler = (dispatch: unknown) => Promise<void>;
203
+ export type BridgeOfferHandler = (dispatch: unknown) => Promise<void>;
204
+ export type BridgeStartHandler = (dispatch: unknown) => Promise<void>;
205
+ export type BridgeLeaseUpdateHandler = (request: BridgeLeaseUpdateRequest) => Promise<void>;
94
206
  export type BridgeCancelHandler = (request: BridgeCancelRequest) => Promise<void>;
207
+ export type BridgeReapHandler = (request: BridgeReapRequest) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function helpText(): string;
2
+ export declare function commandHelpText(command: string): string;
@@ -0,0 +1,183 @@
1
+ import { defaultBridgeServiceConfig } from "../bridge/bridge.service.js";
2
+ import { forgeBridgeVersion } from "../version.js";
3
+ export function helpText() {
4
+ const version = defaultBridgeServiceConfig().version ?? forgeBridgeVersion;
5
+ return [
6
+ `🛠 Forge Bridge ${version} — Local provider runners for Forge.`,
7
+ "",
8
+ "Usage: forge-bridge [options] [command]",
9
+ "",
10
+ "Options:",
11
+ " -h, --help Display help for command",
12
+ " -v, --version Output the version number",
13
+ "",
14
+ "Commands:",
15
+ " Hint: commands suffixed with * have detailed help. Run <command> --help for details.",
16
+ " connect * Start the runner bridge and wait for Forge dispatches",
17
+ " pair * Pair this machine with Forge and save runner credentials",
18
+ " status * Show config, runner identity, repos, provider CLIs, and updates",
19
+ " add-repo * Map a Forge repo label/name to a local checkout path",
20
+ " remove-repo * Remove a saved repo mapping",
21
+ " cleanup * Prune managed bridge worktrees",
22
+ " sandbox * Initialize, diagnose, or reap Docker sandboxes",
23
+ " version * Print the installed bridge package version",
24
+ " help * Display help for command",
25
+ " run-once * Internal: run one dispatch packet from JSON",
26
+ " mcp * Internal: run the phase-completion MCP server",
27
+ "",
28
+ "Examples:",
29
+ " npm install -g @loucompanion/forge-bridge@next",
30
+ " forge-bridge pair 1234-5678 --server https://srv1493013.tail66073d.ts.net:8443 --repo-root \"%USERPROFILE%\\ForgeRepos\"",
31
+ " forge-bridge connect",
32
+ " forge-bridge status --check-updates",
33
+ " forge-bridge add-repo Forge D:\\Programming\\repos\\Forge",
34
+ " forge-bridge cleanup --stale",
35
+ "",
36
+ "Troubleshooting:",
37
+ " If Forge says the bridge is old: npm install -g @loucompanion/forge-bridge@next",
38
+ " If connect shows 502/500: leave it open; it reconnects with backoff while dev restarts.",
39
+ " If a provider is missing: run forge-bridge status --check-updates and verify CLI login.",
40
+ "",
41
+ "Docs:",
42
+ " https://github.com/coleman399/Forge/tree/develop/tools/forge-bridge#readme",
43
+ "",
44
+ ].join("\n");
45
+ }
46
+ export function commandHelpText(command) {
47
+ switch (command) {
48
+ case "pair":
49
+ return [
50
+ "Forge Bridge — pair",
51
+ "Pair this machine with Forge and save runner credentials.",
52
+ "",
53
+ "Usage:",
54
+ " forge-bridge pair [code] [options]",
55
+ "",
56
+ "Options:",
57
+ " --server <url> Forge server URL.",
58
+ " --repo-root <path> Folder where bridge-managed repos/worktrees live.",
59
+ " --name <name> Display name for this runner.",
60
+ " --fingerprint <value> Stable device fingerprint override.",
61
+ " --cli-provider <list> Comma-separated providers, e.g. codex,cursor.",
62
+ " --cleanup-worktrees Enable managed worktree cleanup.",
63
+ " --no-cleanup-worktrees Disable managed worktree cleanup.",
64
+ "",
65
+ "Example:",
66
+ " forge-bridge pair 1234-5678 --server https://forge.example.com --repo-root \"%USERPROFILE%\\ForgeRepos\"",
67
+ "",
68
+ ].join("\n");
69
+ case "connect":
70
+ return [
71
+ "Forge Bridge — connect",
72
+ "Start the runner bridge and keep it connected for Forge dispatches.",
73
+ "",
74
+ "Usage:",
75
+ " forge-bridge connect [options]",
76
+ "",
77
+ "Options:",
78
+ " --server <url> Forge server URL; saved config is used when omitted.",
79
+ " --runner-id <id> Runner id; saved config is used when omitted.",
80
+ " --device-token <token> Device token; saved config is used when omitted.",
81
+ " --repo-root <path> Override repo/worktree folder for this run.",
82
+ " --cli-provider <list> Comma-separated providers, e.g. codex,cursor.",
83
+ " --heartbeat-interval-ms <n> Heartbeat interval in milliseconds.",
84
+ " --cleanup-worktrees Enable managed worktree cleanup for this run.",
85
+ " --no-cleanup-worktrees Disable managed worktree cleanup for this run.",
86
+ "",
87
+ "Example:",
88
+ " forge-bridge connect",
89
+ "",
90
+ ].join("\n");
91
+ case "status":
92
+ return [
93
+ "Forge Bridge — status",
94
+ "Show saved configuration, paired runner identity, repo mappings, detected provider CLIs, and optional update info.",
95
+ "",
96
+ "Usage:",
97
+ " forge-bridge status [--check-updates]",
98
+ "",
99
+ "Example:",
100
+ " forge-bridge status --check-updates",
101
+ "",
102
+ ].join("\n");
103
+ case "add-repo":
104
+ return [
105
+ "Forge Bridge — add-repo",
106
+ "Map a Forge repo label/name to an existing local checkout.",
107
+ "",
108
+ "Usage:",
109
+ " forge-bridge add-repo <label> <path>",
110
+ "",
111
+ "Example:",
112
+ " forge-bridge add-repo Forge D:\\Programming\\repos\\Forge",
113
+ "",
114
+ ].join("\n");
115
+ case "remove-repo":
116
+ return [
117
+ "Forge Bridge — remove-repo",
118
+ "Remove a saved local repo mapping.",
119
+ "",
120
+ "Usage:",
121
+ " forge-bridge remove-repo <label>",
122
+ "",
123
+ ].join("\n");
124
+ case "cleanup":
125
+ return [
126
+ "Forge Bridge — cleanup",
127
+ "Prune managed bridge worktrees under the configured repo folder.",
128
+ "",
129
+ "Usage:",
130
+ " forge-bridge cleanup [--stale|--merged|--all] [--force]",
131
+ "",
132
+ "Examples:",
133
+ " forge-bridge cleanup --stale",
134
+ " forge-bridge cleanup --all --force",
135
+ "",
136
+ ].join("\n");
137
+ case "sandbox":
138
+ return [
139
+ "Forge Bridge — sandbox",
140
+ "Initialize or diagnose a repository-owned Forge sandbox contract.",
141
+ "",
142
+ "Usage:",
143
+ " forge-bridge sandbox init [--repo <path>]",
144
+ " forge-bridge sandbox doctor [--repo <path>] [--require-pinned-base]",
145
+ " forge-bridge sandbox reap",
146
+ "",
147
+ ].join("\n");
148
+ case "run-once":
149
+ return [
150
+ "Forge Bridge — run-once",
151
+ "Internal command used by Forge to run a single dispatch packet.",
152
+ "",
153
+ "Usage:",
154
+ " forge-bridge run-once --dispatch <dispatch-json-path> --result <result-json-path>",
155
+ "",
156
+ ].join("\n");
157
+ case "mcp":
158
+ return [
159
+ "Forge Bridge — mcp",
160
+ "Internal MCP server used by provider CLIs to report Forge phase artifacts.",
161
+ "",
162
+ "Usage:",
163
+ " forge-bridge mcp --worktree <path> --work-item-id <id> --phase <phase>",
164
+ "",
165
+ ].join("\n");
166
+ case "version":
167
+ return [
168
+ "Forge Bridge — version",
169
+ "Print the installed bridge package version.",
170
+ "",
171
+ "Usage:",
172
+ " forge-bridge version",
173
+ "",
174
+ ].join("\n");
175
+ default:
176
+ return [
177
+ `Unknown forge-bridge command: ${command}`,
178
+ "",
179
+ "Run `forge-bridge help` to see available commands.",
180
+ "",
181
+ ].join("\n");
182
+ }
183
+ }
@@ -45,6 +45,18 @@ export declare function parseArgs(argv: readonly string[]): {
45
45
  readonly config: BridgeServiceConfig;
46
46
  readonly mode: CleanupMode;
47
47
  readonly force: boolean;
48
+ } | {
49
+ readonly ok: true;
50
+ readonly command: "sandbox-init";
51
+ readonly repoPath: string;
52
+ } | {
53
+ readonly ok: true;
54
+ readonly command: "sandbox-doctor";
55
+ readonly repoPath: string;
56
+ readonly requirePinnedBase: boolean;
57
+ } | {
58
+ readonly ok: true;
59
+ readonly command: "sandbox-reap";
48
60
  } | {
49
61
  readonly ok: false;
50
62
  readonly error: string;