@ricsam/r5d-worker 0.0.136 → 0.0.138

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 (240) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7537
  4. package/dist/mjs/package.json +1 -1
  5. package/dist/mjs/personal/action-scheduler.mjs +31 -0
  6. package/dist/mjs/personal/client.mjs +215 -0
  7. package/dist/mjs/personal/runtime.mjs +328 -0
  8. package/dist/mjs/personal/tcp.mjs +217 -0
  9. package/dist/mjs/runtime/adapter.mjs +42 -0
  10. package/dist/mjs/runtime/client.mjs +95 -0
  11. package/dist/mjs/runtime/daemon.mjs +131 -0
  12. package/dist/mjs/runtime/executor.mjs +436 -0
  13. package/dist/mjs/runtime/index.mjs +15 -0
  14. package/dist/mjs/runtime/protocol.mjs +139 -0
  15. package/dist/mjs/runtime/pty-host.mjs +156 -0
  16. package/dist/mjs/runtime/pty.mjs +127 -0
  17. package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
  18. package/dist/mjs/runtime/releases/grants.mjs +93 -0
  19. package/dist/mjs/runtime/releases/main.mjs +101 -0
  20. package/dist/mjs/runtime/releases/manager.mjs +541 -0
  21. package/dist/mjs/runtime/releases/process.mjs +88 -0
  22. package/dist/mjs/runtime/releases/retirement.mjs +18 -0
  23. package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
  24. package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
  25. package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
  26. package/dist/mjs/runtime/storage.mjs +156 -0
  27. package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
  28. package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
  29. package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
  30. package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
  31. package/dist/mjs/runtime/workspace/files.mjs +308 -0
  32. package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
  33. package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
  34. package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
  35. package/dist/types/main.d.ts +0 -1167
  36. package/dist/types/personal/action-scheduler.d.ts +23 -0
  37. package/dist/types/personal/client.d.ts +14 -0
  38. package/dist/types/personal/runtime.d.ts +121 -0
  39. package/dist/types/personal/tcp.d.ts +14 -0
  40. package/dist/types/runtime/client.d.ts +17 -0
  41. package/dist/types/runtime/daemon.d.ts +8 -0
  42. package/dist/types/runtime/executor.d.ts +35 -0
  43. package/dist/types/runtime/index.d.ts +5 -0
  44. package/dist/types/runtime/protocol.d.ts +544 -0
  45. package/dist/types/runtime/pty.d.ts +30 -0
  46. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  47. package/dist/types/runtime/releases/grants.d.ts +16 -0
  48. package/dist/types/runtime/releases/manager.d.ts +145 -0
  49. package/dist/types/runtime/releases/process.d.ts +14 -0
  50. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  51. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  52. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  53. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  54. package/dist/types/runtime/storage.d.ts +21 -0
  55. package/dist/types/runtime/test-harness.d.ts +53 -0
  56. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  57. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  58. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  59. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  60. package/dist/types/runtime/workspace/files.d.ts +21 -0
  61. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  62. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  63. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  64. package/package.json +8 -6
  65. package/dist/cjs/atomic-rename.cjs +0 -303
  66. package/dist/cjs/browser-upload.cjs +0 -73
  67. package/dist/cjs/cli-update.cjs +0 -108
  68. package/dist/cjs/command-launcher.cjs +0 -423
  69. package/dist/cjs/control-command-policy.cjs +0 -177
  70. package/dist/cjs/git-blob-hash.cjs +0 -41
  71. package/dist/cjs/git-identity.cjs +0 -39
  72. package/dist/cjs/git-process-environment.cjs +0 -133
  73. package/dist/cjs/inline-output.cjs +0 -62
  74. package/dist/cjs/main.cjs +0 -7511
  75. package/dist/cjs/managed-paths.cjs +0 -215
  76. package/dist/cjs/plan-lint.cjs +0 -165
  77. package/dist/cjs/plan-parser.cjs +0 -127
  78. package/dist/cjs/plan-paths.cjs +0 -53
  79. package/dist/cjs/port-forward-client.cjs +0 -206
  80. package/dist/cjs/process-tree.cjs +0 -117
  81. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  82. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  83. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  84. package/dist/cjs/project-workspace-state.cjs +0 -972
  85. package/dist/cjs/project-worktrees.cjs +0 -1713
  86. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  87. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  88. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  89. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  90. package/dist/cjs/recovery-journal.cjs +0 -742
  91. package/dist/cjs/recovery-output-window.cjs +0 -77
  92. package/dist/cjs/recovery-protocol.cjs +0 -31
  93. package/dist/cjs/recovery-store.cjs +0 -252
  94. package/dist/cjs/registry-auth.cjs +0 -310
  95. package/dist/cjs/repository-transition-policy.cjs +0 -49
  96. package/dist/cjs/runtime-version.cjs +0 -88
  97. package/dist/cjs/session-file-mutations.cjs +0 -61
  98. package/dist/cjs/supervisor.cjs +0 -147
  99. package/dist/cjs/three-way-merge.cjs +0 -346
  100. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  101. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  102. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  103. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  104. package/dist/cjs/workspace-command-targets.cjs +0 -63
  105. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  106. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  107. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  108. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  109. package/dist/cjs/workspace-git-sync.cjs +0 -3450
  110. package/dist/cjs/workspace-hydration-ledger.cjs +0 -66
  111. package/dist/cjs/workspace-hydration-merge.cjs +0 -433
  112. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  113. package/dist/cjs/workspace-incident-state.cjs +0 -37
  114. package/dist/cjs/workspace-merge-projection.cjs +0 -467
  115. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  116. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  117. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  118. package/dist/cjs/workspace-path-move.cjs +0 -195
  119. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  120. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  121. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  122. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  123. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  124. package/dist/mjs/atomic-rename.mjs +0 -261
  125. package/dist/mjs/browser-upload.mjs +0 -42
  126. package/dist/mjs/command-launcher.mjs +0 -393
  127. package/dist/mjs/control-command-policy.mjs +0 -146
  128. package/dist/mjs/git-blob-hash.mjs +0 -16
  129. package/dist/mjs/git-identity.mjs +0 -15
  130. package/dist/mjs/git-process-environment.mjs +0 -105
  131. package/dist/mjs/inline-output.mjs +0 -37
  132. package/dist/mjs/managed-paths.mjs +0 -174
  133. package/dist/mjs/plan-lint.mjs +0 -129
  134. package/dist/mjs/plan-parser.mjs +0 -94
  135. package/dist/mjs/plan-paths.mjs +0 -25
  136. package/dist/mjs/port-forward-client.mjs +0 -172
  137. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  138. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  139. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  140. package/dist/mjs/project-workspace-state.mjs +0 -937
  141. package/dist/mjs/project-worktrees.mjs +0 -1657
  142. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  143. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  144. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  145. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  146. package/dist/mjs/recovery-journal.mjs +0 -694
  147. package/dist/mjs/recovery-output-window.mjs +0 -53
  148. package/dist/mjs/recovery-protocol.mjs +0 -6
  149. package/dist/mjs/recovery-store.mjs +0 -217
  150. package/dist/mjs/registry-auth.mjs +0 -269
  151. package/dist/mjs/repository-transition-policy.mjs +0 -22
  152. package/dist/mjs/runtime-version.mjs +0 -54
  153. package/dist/mjs/session-file-mutations.mjs +0 -37
  154. package/dist/mjs/supervisor.mjs +0 -114
  155. package/dist/mjs/three-way-merge.mjs +0 -318
  156. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  157. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  158. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  159. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  160. package/dist/mjs/workspace-command-targets.mjs +0 -37
  161. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  162. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  163. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  164. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  165. package/dist/mjs/workspace-git-sync.mjs +0 -3407
  166. package/dist/mjs/workspace-hydration-ledger.mjs +0 -42
  167. package/dist/mjs/workspace-hydration-merge.mjs +0 -399
  168. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  169. package/dist/mjs/workspace-incident-state.mjs +0 -12
  170. package/dist/mjs/workspace-merge-projection.mjs +0 -433
  171. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  172. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  173. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  174. package/dist/mjs/workspace-path-move.mjs +0 -160
  175. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  176. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  177. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  178. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  179. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  180. package/dist/types/atomic-rename.d.ts +0 -78
  181. package/dist/types/browser-upload.d.ts +0 -7
  182. package/dist/types/command-launcher.d.ts +0 -104
  183. package/dist/types/control-command-policy.d.ts +0 -53
  184. package/dist/types/git-blob-hash.d.ts +0 -10
  185. package/dist/types/git-identity.d.ts +0 -9
  186. package/dist/types/git-process-environment.d.ts +0 -9
  187. package/dist/types/inline-output.d.ts +0 -3
  188. package/dist/types/managed-paths.d.ts +0 -19
  189. package/dist/types/plan-lint.d.ts +0 -16
  190. package/dist/types/plan-parser.d.ts +0 -38
  191. package/dist/types/plan-paths.d.ts +0 -36
  192. package/dist/types/port-forward-client.d.ts +0 -8
  193. package/dist/types/project-checkout-garbage.d.ts +0 -86
  194. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  195. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  196. package/dist/types/project-workspace-state.d.ts +0 -188
  197. package/dist/types/project-worktrees.d.ts +0 -397
  198. package/dist/types/pty-output-coalescer.d.ts +0 -20
  199. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  200. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  201. package/dist/types/recovery-journal-thread.d.ts +0 -1
  202. package/dist/types/recovery-journal.d.ts +0 -248
  203. package/dist/types/recovery-output-window.d.ts +0 -19
  204. package/dist/types/recovery-protocol.d.ts +0 -59
  205. package/dist/types/recovery-store.d.ts +0 -52
  206. package/dist/types/registry-auth.d.ts +0 -47
  207. package/dist/types/repository-transition-policy.d.ts +0 -26
  208. package/dist/types/runtime-version.d.ts +0 -1
  209. package/dist/types/session-file-mutations.d.ts +0 -22
  210. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  211. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  212. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  213. package/dist/types/supervisor.d.ts +0 -23
  214. package/dist/types/three-way-merge.d.ts +0 -77
  215. package/dist/types/working-tree-mirror.d.ts +0 -424
  216. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  217. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  218. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  219. package/dist/types/workspace-command-targets.d.ts +0 -37
  220. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  221. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  222. package/dist/types/workspace-filesystem-job-types.d.ts +0 -288
  223. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  224. package/dist/types/workspace-git-sync.d.ts +0 -495
  225. package/dist/types/workspace-hydration-ledger.d.ts +0 -43
  226. package/dist/types/workspace-hydration-merge.d.ts +0 -95
  227. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  228. package/dist/types/workspace-incident-state.d.ts +0 -19
  229. package/dist/types/workspace-merge-projection.d.ts +0 -60
  230. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  231. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  232. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  233. package/dist/types/workspace-path-move.d.ts +0 -21
  234. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  235. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  236. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  237. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  238. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  239. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/adapter.d.ts} +0 -0
  240. /package/dist/types/{recovery-journal-stall-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,1169 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- import type { BrowserUploadChunk, BrowserUploadReadInput } from "@ricsam/r5d-api/browser-upload";
3
- import type { WorkerLintPlansResult, WorkerUpdatePlanTaskResult } from "./plan-paths";
4
- import { WORKER_RESUMABLE_PROTOCOL, type WorkerRecoveryClientMessage, type WorkerRecoveryServerMessage } from "./recovery-protocol";
5
- import { Database } from "bun:sqlite";
6
- import type { WorkerGitIdentity } from "./git-identity";
7
- import { configureGitHubRegistryAuthFiles, type PreparedPrivateAuthFileGeneration } from "./registry-auth";
8
- import { WorkspaceMountHoldFence } from "./workspace-mount-hold-fence";
9
- import { type WorkspaceCommandProjectTarget } from "./workspace-command-targets";
10
- import { type WorkerHydrationRecovery } from "./workspace-hydration-recovery-state";
11
- import { type WorkspaceHydrationTransactionHooks, type WorkspaceGitSyncResult } from "./workspace-git-sync";
12
- type WorkerProjectConfig = {
13
- projectId: string;
14
- checkoutPathSegments: [namespace: string, project: string];
15
- projectPath: string;
16
- repoHttpUrl: string | null;
17
- repoAuthHeader: string | null;
18
- defaultBranch: string;
19
- repositoryTransitionId: string | null;
20
- executionDisabled: boolean;
21
- mirrorWritesDisabled: boolean;
22
- preserveOnlyBranches: Array<{
23
- branchId: string;
24
- branchName: string;
25
- }>;
26
- branches: Array<{
27
- branchId: string;
28
- branchName: string;
29
- sourceBranchName: string | null;
30
- baseCommitHash: string;
31
- }>;
32
- };
33
- type WorkerAheadOfOriginBranch = {
34
- projectId: string;
35
- branchName: string;
36
- ahead: number;
37
- };
38
- type WorkerLifecycleProgress = {
39
- phase: "starting" | "recovering" | "configuring" | "syncing" | "ready" | "failed";
40
- operationId: string;
41
- detail?: string;
42
- completedBytes?: number;
43
- totalBytes?: number;
44
- completedItems?: number;
45
- totalItems?: number;
46
- };
47
- declare function boundedWorkerLifecycleProgress(progress: WorkerLifecycleProgress): WorkerLifecycleProgress;
48
- declare function workerServerHeartbeatAction(input: {
49
- elapsedMs: number;
50
- probeElapsedMs?: number;
51
- timeoutMs: number;
52
- watchdogSweepDelayed: boolean;
53
- }): "wait" | "start_probe" | "terminate";
54
- /**
55
- * A hydration transaction runs on the workspace filesystem executor thread
56
- * and on a stalled disk it can run for a long time; the server bounds its
57
- * deadlines by a hydration heartbeat lease rather than by the ordinary
58
- * request timeout. Declare that lease first: the server keeps the control
59
- * socket open and defers the affected request deadlines while the lease is
60
- * active, which is what turned one slow hydration into a mandatory canonical
61
- * reset before the lease existed (incident 3bccab03). The extra event-loop
62
- * turn lets control messages that were already queued run before the busy
63
- * observation that precedes the transaction. The hooks also hold every mount
64
- * a job reads or writes on the process-wide fence, so command admission for
65
- * those mounts waits until the job ended (incident 10).
66
- */
67
- declare function createWorkspaceHydrationLeaseHooks(send: (message: Extract<WorkerClientMessage, {
68
- type: "heartbeat_lease";
69
- }>) => void, options: {
70
- fence: WorkspaceMountHoldFence;
71
- yieldToEventLoop?: () => Promise<void>;
72
- log?: (line: string) => void;
73
- now?: () => number;
74
- }): WorkspaceHydrationTransactionHooks;
75
- export declare const workerLifecycleTestHarness: {
76
- boundedWorkerLifecycleProgress: typeof boundedWorkerLifecycleProgress;
77
- workerServerHeartbeatAction: typeof workerServerHeartbeatAction;
78
- createWorkspaceHydrationLeaseHooks: typeof createWorkspaceHydrationLeaseHooks;
79
- workerCommandHasWorkspaceEffect: typeof workerCommandHasWorkspaceEffect;
80
- };
81
- type WorkspaceSyncTrigger = {
82
- type: "connect" | "inbound_head" | "write" | "edit" | "shell_inline" | "process_terminal" | "process_cancel" | "periodic" | "manual" | "remediation" | "remediation_confirm" | "remediation_reset";
83
- sessionId?: string;
84
- processRunId?: string;
85
- toolCallId?: string;
86
- projectId?: string;
87
- branchName?: string;
88
- detail?: string;
89
- };
90
- type WorkspaceSyncResult = {
91
- hydrationRecovery?: WorkerHydrationRecovery;
92
- mountSkipReasons?: WorkspaceGitSyncResult["mountSkipReasons"];
93
- type: "workspace_sync";
94
- attemptId: string;
95
- workerLabel: string;
96
- trigger: WorkspaceSyncTrigger;
97
- outcome: "no_change" | "published" | "updated" | "conflict_reset" | "large_diff_blocked" | "conflict_blocked" | "reset" | "failed";
98
- startingHead: string | null;
99
- localHead?: string;
100
- publishedHead?: string;
101
- rebaseCount: number;
102
- diffSizeBytes: number;
103
- gitStatus: string;
104
- affectedProjects: string[];
105
- affectedPaths: string[];
106
- activeMountIds?: string[];
107
- skippedMountIds?: string[];
108
- /** Configured checkouts this cycle excluded because their directory is absent or is not a linked worktree of the project. */
109
- missingCheckouts?: Array<{
110
- projectId: string;
111
- branchName: string;
112
- reason: "missing" | "not_a_worktree";
113
- }>;
114
- activeProjectBranchPublications?: Array<{
115
- branchId: string;
116
- projectId: string;
117
- branchName: string;
118
- }>;
119
- discardedPaths: string[];
120
- localChangesDiscarded: boolean;
121
- conflictPaths?: string[];
122
- conflictSnapshotRefs?: {
123
- local: string;
124
- remote: string;
125
- };
126
- conflictKind?: "integration_rebase" | "projection_merge";
127
- verifiedAncestorHeads?: string[];
128
- telemetry?: {
129
- totalMs: number;
130
- queueMs: number;
131
- prepareMs: number;
132
- synchronizeMs: number;
133
- };
134
- error?: string;
135
- /** Typed reason for a failed outcome the server should surface loudly. */
136
- failureReason?: "unsafe_hydration" | "hydration_recovery_required";
137
- /** Consecutive in-process recovery bounces taken for unsafe hydration failures. */
138
- recoveryAttempt?: number;
139
- };
140
- export type WorkerSessionTarget = {
141
- type: "project";
142
- projectId: string;
143
- branchName: string;
144
- } | {
145
- type: "workspace";
146
- ownerUserId: string;
147
- rootProfile: "visible_projects" | "canonical_sync";
148
- };
149
- type WorkerCancelScope = "unstarted";
150
- type WorkerCancelOutcome = "unstarted" | "started" | "stopped" | "unknown";
151
- type WorkerClientMessage = WorkerRecoveryClientMessage | {
152
- type: "capacity_report";
153
- capacity: import("./command-launcher").CommandLaunchCapacityReport & {
154
- reportedAt: string;
155
- };
156
- } | {
157
- type: "hello";
158
- resumableProtocol: typeof WORKER_RESUMABLE_PROTOCOL;
159
- runtimeId: string;
160
- ledgerId: string;
161
- hostInfo?: Record<string, unknown>;
162
- startupReady?: boolean;
163
- } | {
164
- type: "worker_progress";
165
- progress: WorkerLifecycleProgress;
166
- } | {
167
- type: "heartbeat_lease";
168
- operationId: string;
169
- active: boolean;
170
- /** A hydration transaction may block the worker for hours; the server bounds it separately from preparation leases. */
171
- kind?: "hydration";
172
- } | {
173
- type: "startup_ready";
174
- } | {
175
- type: "active_processes";
176
- processes: Array<{
177
- runId: string;
178
- target: WorkerSessionTarget;
179
- sessionId: string;
180
- platform: string;
181
- arch: string;
182
- mode: "foreground" | "detached";
183
- pid?: number;
184
- processGroupId?: number;
185
- credentialId?: string;
186
- argv: string[];
187
- command: string;
188
- cwd?: string;
189
- startedAt: string;
190
- interactive?: boolean;
191
- workspaceEffect?: "none";
192
- commandClass?: "control";
193
- }>;
194
- } | {
195
- type: "pty_opened";
196
- requestId: string;
197
- ptyId: string;
198
- } | {
199
- type: "pty_output";
200
- ptyId: string;
201
- data: string;
202
- } | {
203
- type: "pty_exit";
204
- ptyId: string;
205
- exitCode: number;
206
- signal?: number | string;
207
- } | {
208
- type: "pty_error";
209
- ptyId: string;
210
- requestId?: string;
211
- error: string;
212
- } | {
213
- type: "browser_upload_read_result";
214
- requestId: string;
215
- result?: WorkerOperationResult;
216
- error?: string;
217
- } | {
218
- type: "operation_result";
219
- requestId: string;
220
- result?: WorkerOperationResult;
221
- error?: string;
222
- } | {
223
- /** Immediate receipt for a branch create/delete; `queuePosition` is 0 when it runs at once. */
224
- type: "operation_queued";
225
- requestId: string;
226
- queuePosition: number;
227
- } | {
228
- type: "exec_result";
229
- requestId: string;
230
- stdout: string;
231
- stderr: string;
232
- exitCode: number;
233
- durationMs?: number;
234
- error?: string;
235
- } | {
236
- type: "exec_accepted";
237
- requestId: string;
238
- runId: string;
239
- } | {
240
- type: "exec_started";
241
- requestId: string;
242
- runId: string;
243
- cwd: string;
244
- pid?: number;
245
- processGroupId?: number;
246
- } | {
247
- type: "exec_start_error";
248
- requestId: string;
249
- runId: string;
250
- error: string;
251
- } | {
252
- type: "exec_output";
253
- runId: string;
254
- stream: "stdout" | "stderr";
255
- data: string;
256
- } | {
257
- type: "exec_exit";
258
- runId: string;
259
- exitCode: number;
260
- durationMs?: number;
261
- timedOut?: boolean;
262
- workspaceEffect?: "none";
263
- canonicalWorkspaceHead?: string;
264
- } | {
265
- type: "exec_error";
266
- runId: string;
267
- error: string;
268
- durationMs?: number;
269
- workspaceEffect?: "none";
270
- canonicalWorkspaceHead?: string;
271
- } | {
272
- type: "cancel_result";
273
- requestId: string;
274
- runId: string;
275
- cancelled: boolean;
276
- message?: string;
277
- /** `unstarted`: a launch that had not spawned was revoked; `started`: a spawned process was left alone; `stopped`; `unknown`: no record, cancellation recorded. */
278
- outcome?: WorkerCancelOutcome;
279
- } | {
280
- type: "pong";
281
- } | {
282
- type: "workspace_configured";
283
- requestId: string;
284
- result: WorkspaceSyncResult;
285
- pendingCheckouts: Array<{
286
- projectId: string;
287
- branchName: string;
288
- }>;
289
- aheadOfOriginBranches: WorkerAheadOfOriginBranch[];
290
- deferredWorkspaceSyncForIncidentId?: string;
291
- /**
292
- * The configuration was not applied because these projects have visible
293
- * checkout activity; every executable checkout above is pending and the
294
- * previous generation stays on disk until a retry lands on idle checkouts.
295
- */
296
- deferredForBusyProjectIds?: string[];
297
- } | {
298
- type: "workspace_sync_started";
299
- attemptId: string;
300
- } | {
301
- type: "workspace_sync_result";
302
- requestId?: string;
303
- result: WorkspaceSyncResult;
304
- } | {
305
- type: "session_artifacts_sync_result";
306
- requestId: string;
307
- sessionId: string;
308
- error?: string;
309
- } | {
310
- type: "update_clis_result";
311
- requestId: string;
312
- installedWorkerVersion?: string;
313
- installedR5dctlVersion?: string;
314
- error?: string;
315
- };
316
- type WorkerServerMessage = WorkerRecoveryServerMessage | {
317
- type: "connected";
318
- label: string;
319
- workerId: string;
320
- } | {
321
- type: "workspace_config";
322
- recoverHydrationTransactionId?: string;
323
- requestId: string;
324
- projects: WorkerProjectConfig[];
325
- workspaceRemoteUrl: string;
326
- gitIdentity: WorkerGitIdentity;
327
- githubCredential: WorkerGitHubCredential | null;
328
- deferWorkspaceSyncForIncidentId?: string;
329
- resetToCanonical?: boolean;
330
- } | {
331
- type: "sync_workspace";
332
- requestId: string;
333
- attemptId: string;
334
- trigger: WorkspaceSyncTrigger;
335
- confirmedLargeDiff?: boolean;
336
- confirmationReason?: string;
337
- resetToCanonical?: boolean;
338
- requiredAncestorHeads?: string[];
339
- } | {
340
- /**
341
- * Content-derived tokens naming ref state the server read from disk:
342
- * `tokens` per canonical project repository, `mountTokens` per
343
- * checked-out project branch (keyed by project id then branch name),
344
- * and the current head of the hidden workspace repository. Replace-all:
345
- * anything absent from a message has no advertised token and the
346
- * corresponding fetch runs. Older servers send `tokens` only. See
347
- * `project-mirror-fetch-policy.ts`.
348
- */
349
- type: "project_mirror_refs_tokens";
350
- tokens: Record<string, string>;
351
- mountTokens?: Record<string, Record<string, string>>;
352
- workspaceHead?: string;
353
- } | {
354
- type: "create_project_branch";
355
- requestId: string;
356
- branchId: string;
357
- projectId: string;
358
- sourceBranch: string;
359
- targetBranch: string;
360
- /** `carry` copies the source checkout's uncommitted changes; `clean` checks out its commit only. */
361
- workingTree: "carry" | "clean";
362
- } | {
363
- type: "delete_project_branch";
364
- requestId: string;
365
- branchId: string;
366
- projectId: string;
367
- branchName: string;
368
- } | {
369
- type: "code_list";
370
- requestId: string;
371
- target: Extract<WorkerSessionTarget, {
372
- type: "project";
373
- }>;
374
- path: string;
375
- } | {
376
- type: "browser_upload_read";
377
- requestId: string;
378
- target: WorkerSessionTarget;
379
- sessionId: string;
380
- input: BrowserUploadReadInput;
381
- } | {
382
- type: "code_read";
383
- requestId: string;
384
- target: Extract<WorkerSessionTarget, {
385
- type: "project";
386
- }>;
387
- path: string;
388
- } | {
389
- type: "sync_session_artifacts";
390
- requestId: string;
391
- sessionId: string;
392
- } | {
393
- type: "workspace_incident_updated";
394
- incidentId: string | null;
395
- status: "remediating" | "waiting_for_worker" | "resolved" | "confirmed" | "reset" | null;
396
- originWorkerLabel?: string;
397
- } | {
398
- type: "exec_terminal_ack";
399
- runId: string;
400
- } | {
401
- type: "port_forward_connect";
402
- forwardId: string;
403
- relayConnectionId: string;
404
- workerPort: number;
405
- } | {
406
- type: "update_clis";
407
- requestId: string;
408
- workerPackageSpec: string;
409
- r5dctlPackageSpec: string;
410
- targetWorkerVersion: string;
411
- targetR5dctlVersion: string;
412
- } | {
413
- type: "exec";
414
- requestId: string;
415
- runId: string;
416
- target: WorkerSessionTarget;
417
- /** Sibling checkouts fenced for the command's lifetime alongside `target`; project branches only. */
418
- additionalTargets?: WorkspaceCommandProjectTarget[];
419
- sessionId?: string;
420
- argv: string[];
421
- cwd?: string;
422
- env?: Record<string, string>;
423
- timeoutMs?: number;
424
- workspaceEffect?: "none";
425
- } | {
426
- type: "exec_start";
427
- requestId: string;
428
- runId: string;
429
- target: WorkerSessionTarget;
430
- /** Fixed at admission; kept until the process exits, whatever happens to the claim that produced it. */
431
- additionalTargets?: WorkspaceCommandProjectTarget[];
432
- sessionId: string;
433
- argv: string[];
434
- command: string;
435
- mode: "foreground" | "detached";
436
- credentialId?: string;
437
- cwd?: string;
438
- env?: Record<string, string>;
439
- envFiles?: Array<{
440
- path: string;
441
- content: string;
442
- mode?: number;
443
- }>;
444
- accountEnvironmentWorkerId?: string;
445
- timeoutMs?: number;
446
- interactive?: boolean;
447
- workspaceEffect?: "none";
448
- commandClass?: "control";
449
- } | {
450
- type: "exec_stdin";
451
- requestId: string;
452
- runId: string;
453
- data?: string;
454
- eof?: boolean;
455
- } | {
456
- type: "pty_open";
457
- requestId: string;
458
- ptyId: string;
459
- target: WorkerSessionTarget;
460
- /** Fixed when the shell opens; kept until the PTY exits. */
461
- additionalTargets?: WorkspaceCommandProjectTarget[];
462
- cols: number;
463
- rows: number;
464
- command?: string;
465
- env?: Record<string, string>;
466
- envFiles?: Array<{
467
- path: string;
468
- content: string;
469
- mode?: number;
470
- }>;
471
- } | {
472
- type: "pty_input";
473
- requestId: string;
474
- ptyId: string;
475
- data: string;
476
- } | {
477
- type: "pty_resize";
478
- requestId: string;
479
- ptyId: string;
480
- cols: number;
481
- rows: number;
482
- } | {
483
- type: "pty_close";
484
- requestId: string;
485
- ptyId: string;
486
- } | {
487
- type: "read_plan";
488
- requestId: string;
489
- target: WorkerSessionTarget;
490
- sessionId?: string;
491
- planId: string;
492
- createIfMissing: boolean;
493
- } | {
494
- type: "lint_plans";
495
- requestId: string;
496
- target: WorkerSessionTarget;
497
- sessionId?: string;
498
- glob?: string;
499
- } | {
500
- type: "update_task_status";
501
- requestId: string;
502
- target: WorkerSessionTarget;
503
- sessionId?: string;
504
- planId: string;
505
- taskId: string;
506
- checked: boolean;
507
- } | {
508
- type: "read";
509
- requestId: string;
510
- target: WorkerSessionTarget;
511
- sessionId?: string;
512
- activePlanId?: string;
513
- filePath: string;
514
- offset?: number;
515
- limit?: number;
516
- } | {
517
- type: "write";
518
- requestId: string;
519
- target: WorkerSessionTarget;
520
- sessionId?: string;
521
- activePlanId?: string;
522
- filePath: string;
523
- content: string;
524
- } | {
525
- type: "edit";
526
- requestId: string;
527
- target: WorkerSessionTarget;
528
- sessionId?: string;
529
- activePlanId?: string;
530
- filePath: string;
531
- edits: Array<{
532
- oldText: string;
533
- newText: string;
534
- }>;
535
- } | {
536
- type: "grep";
537
- requestId: string;
538
- target: WorkerSessionTarget;
539
- sessionId?: string;
540
- activePlanId?: string;
541
- pattern: string;
542
- path?: string;
543
- glob?: string;
544
- caseSensitive?: boolean;
545
- limit?: number;
546
- } | {
547
- type: "find";
548
- requestId: string;
549
- target: WorkerSessionTarget;
550
- sessionId?: string;
551
- activePlanId?: string;
552
- pattern?: string;
553
- path?: string;
554
- entryType?: string;
555
- limit?: number;
556
- } | {
557
- type: "ls";
558
- requestId: string;
559
- target: WorkerSessionTarget;
560
- sessionId?: string;
561
- activePlanId?: string;
562
- path?: string;
563
- limit?: number;
564
- } | {
565
- type: "view_file_bytes";
566
- requestId: string;
567
- target: WorkerSessionTarget;
568
- sessionId?: string;
569
- activePlanId?: string;
570
- filePath: string;
571
- } | {
572
- type: "cancel";
573
- requestId: string;
574
- runId: string;
575
- /** `unstarted`: the server's start-deadline abandonment; never touch a spawned process. */
576
- scope?: WorkerCancelScope;
577
- } | {
578
- type: "ping";
579
- };
580
- type WorkerReadFileResult = {
581
- type: "read";
582
- kind: "text";
583
- file: string;
584
- gitBlobHash?: string;
585
- content: string;
586
- totalLines: number;
587
- startLine: number;
588
- endLine: number;
589
- truncated: boolean;
590
- continuation?: string;
591
- };
592
- type WorkerGitHubCredential = {
593
- host: "github.com";
594
- registry: "ghcr.io";
595
- username: string;
596
- token: string;
597
- missingScopes: Array<"repo" | "read:org" | "gist" | "workflow" | "read:packages" | "write:packages">;
598
- };
599
- type WorkerReadPlanResult = {
600
- type: "read_plan";
601
- read: WorkerReadFileResult;
602
- created: boolean;
603
- };
604
- type WorkerWriteFileResult = {
605
- type: "write";
606
- file: string;
607
- gitBlobHash?: string;
608
- };
609
- type WorkerEditFileResult = {
610
- type: "edit";
611
- file: string;
612
- edits: number;
613
- };
614
- type WorkerGrepResult = {
615
- type: "grep";
616
- content: string;
617
- matchCount: number;
618
- truncated: boolean;
619
- };
620
- type WorkerFindResult = {
621
- type: "find";
622
- content: string;
623
- count: number;
624
- truncated: boolean;
625
- };
626
- type WorkerLsResult = {
627
- type: "ls";
628
- path: string;
629
- content: string;
630
- count: number;
631
- truncated: boolean;
632
- };
633
- type WorkerViewFileBytesResult = {
634
- type: "view_file_bytes";
635
- filePath: string;
636
- mediaType: "image/png" | "image/jpeg";
637
- base64: string;
638
- fileSizeBytes: number;
639
- width: number;
640
- height: number;
641
- };
642
- type WorkerExecStdinAck = {
643
- type: "exec_stdin";
644
- runId: string;
645
- bytesWritten: number;
646
- eof: boolean;
647
- };
648
- type WorkerCreateProjectBranchResult = {
649
- type: "create_project_branch";
650
- branchId: string;
651
- branchName: string;
652
- baseCommitHash: string;
653
- };
654
- type WorkerDeleteProjectBranchResult = {
655
- type: "delete_project_branch";
656
- branchId: string;
657
- branchName: string;
658
- };
659
- type WorkerCodeEntry = {
660
- name: string;
661
- type: "file" | "directory";
662
- size: number | null;
663
- mtime: string;
664
- };
665
- type WorkerCodeListResult = {
666
- type: "code_list";
667
- path: string;
668
- entries: WorkerCodeEntry[];
669
- };
670
- type WorkerCodeReadResult = {
671
- type: "code_read";
672
- path: string;
673
- size: number;
674
- mtime: string;
675
- base64: string;
676
- };
677
- type WorkerOperationResult = WorkerReadFileResult | WorkerReadPlanResult | WorkerLintPlansResult | WorkerUpdatePlanTaskResult | WorkerWriteFileResult | WorkerEditFileResult | WorkerGrepResult | WorkerFindResult | WorkerLsResult | WorkerViewFileBytesResult | WorkerExecStdinAck | WorkerCreateProjectBranchResult | WorkerDeleteProjectBranchResult | WorkerCodeListResult | WorkerCodeReadResult | BrowserUploadChunk;
678
- type WorkerOperationServerMessage = Extract<WorkerServerMessage, {
679
- type: "read_plan" | "lint_plans" | "update_task_status" | "read" | "write" | "edit" | "grep" | "find" | "ls" | "view_file_bytes" | "code_list" | "code_read" | "browser_upload_read";
680
- }>;
681
- declare class WorkspaceSyncAdmissionChangedError extends Error {
682
- readonly name = "WorkspaceSyncAdmissionChangedError";
683
- }
684
- declare function assertWorkerChildAdmission(input: {
685
- capturedGeneration: number;
686
- currentGeneration: number;
687
- sourceSocketIsCurrent: boolean;
688
- sourceSocketOpen: boolean;
689
- workspaceConfigured: boolean;
690
- runtimeHealthy: boolean;
691
- }): void;
692
- type WorkerPty = {
693
- write(data: string): void;
694
- resize(cols: number, rows: number): void;
695
- kill(): void;
696
- terminate(): Promise<void>;
697
- };
698
- type ActiveWorkerPty = WorkerPty & {
699
- target: WorkerSessionTarget;
700
- /** Declared sibling checkouts, fenced like `target` while the PTY is busy. */
701
- additionalTargets: readonly WorkerSessionTarget[];
702
- foregroundBusy: boolean;
703
- lastInputAt: number;
704
- releaseWorkspaceMutation?: () => void;
705
- };
706
- type StagedPtyEnvFiles = {
707
- paths: string[];
708
- resolvedByRequestedPath: Map<string, string>;
709
- };
710
- declare function resolvePtyEnvFilePath(requestedPath: string, temporaryRoot?: string): string;
711
- declare function removePtyEnvFiles(paths: readonly string[]): void;
712
- declare function stagePtyEnvFiles(envFiles: readonly {
713
- path: string;
714
- content: string;
715
- mode?: number;
716
- }[] | undefined, temporaryRoot?: string): StagedPtyEnvFiles;
717
- declare function resolvePtyEnvFileReferences(env: Record<string, string>, staged: StagedPtyEnvFiles): Record<string, string>;
718
- declare function workerCommandHasWorkspaceEffect(message: {
719
- workspaceEffect?: "none";
720
- }): boolean;
721
- declare function workerPtyIsWorkspaceBusy(pty: Pick<ActiveWorkerPty, "foregroundBusy" | "lastInputAt">, now?: number, foregroundIdleEnabled?: boolean): boolean;
722
- declare function parseLinuxPtyForegroundBusy(stat: string): boolean | null;
723
- export declare const workerPtyTestHarness: {
724
- temporaryPathPrefix: string;
725
- inputBusyGraceMs: number;
726
- resolveEnvFilePath: typeof resolvePtyEnvFilePath;
727
- stageEnvFiles: typeof stagePtyEnvFiles;
728
- removeEnvFiles: typeof removePtyEnvFiles;
729
- resolveEnvFileReferences: typeof resolvePtyEnvFileReferences;
730
- commandHasWorkspaceEffect: typeof workerCommandHasWorkspaceEffect;
731
- targetProcessEnv: typeof targetProcessEnv;
732
- canonicalSyncTerminalHead: typeof canonicalSyncTerminalHead;
733
- ptyIsWorkspaceBusy: typeof workerPtyIsWorkspaceBusy;
734
- parseLinuxForegroundBusy: typeof parseLinuxPtyForegroundBusy;
735
- };
736
- export type WorkerBuiltInToolPaths = {
737
- rootDir?: string;
738
- sessionId?: string;
739
- projectId?: string;
740
- branchName?: string;
741
- activePlanId?: string;
742
- };
743
- export declare function isArtifactEnvPath(filePath: string): boolean;
744
- export declare function syncSessionArtifacts(input: {
745
- baseUrl: string;
746
- token: string;
747
- sessionId: string;
748
- artifactRoot: string;
749
- }): Promise<string>;
750
- export declare function prepareArtifactEnvForShell(input: {
751
- baseUrl: string;
752
- token: string;
753
- sessionId?: string;
754
- rootDir: string;
755
- }): Promise<Record<string, string>>;
756
- export declare function preparePlanEnvForShell(input: {
757
- target: WorkerSessionTarget;
758
- rootDir: string;
759
- activePlanId?: string;
760
- }): Record<string, string>;
761
- type ResolvedWorkerFilePath = {
762
- absolutePath: string;
763
- displayPath: string;
764
- repoRelativePath: string;
765
- scope: "project";
766
- } | {
767
- absolutePath: string;
768
- displayPath: string;
769
- repoRelativePath: null;
770
- scope: "host";
771
- } | {
772
- absolutePath: string;
773
- displayPath: string;
774
- repoRelativePath: null;
775
- scope: "virtual";
776
- virtualRootPath: string;
777
- };
778
- export declare function resolveWorkerFilePath(branchPath: string, inputPath: string, builtInPaths?: WorkerBuiltInToolPaths): ResolvedWorkerFilePath;
779
- declare function readOnlyCredentialStoreHelper(storePath: string): string;
780
- declare function credentialGenerationReceiptPath(directoryPath?: string): string;
781
- declare function pendingCredentialGenerationPath(directoryPath?: string): string;
782
- declare function bootstrapCredentialGenerationPath(directoryPath?: string): string;
783
- type PendingCredentialGenerationBoundary = {
784
- kind: "systemd";
785
- machineId: string | null;
786
- invocationId: string;
787
- } | {
788
- kind: "boot";
789
- machineId: string | null;
790
- bootSessionId: string | null;
791
- };
792
- type PendingCredentialGenerationIntent = {
793
- fingerprint: string;
794
- boundary: PendingCredentialGenerationBoundary;
795
- };
796
- declare function pendingCredentialGenerationIntentContent(intent: PendingCredentialGenerationIntent): string;
797
- declare function readPendingCredentialGenerationIntent(intentPath?: string): PendingCredentialGenerationIntent | null;
798
- type BootSessionIdentifierProbe = {
799
- platform: NodeJS.Platform;
800
- kernelValue: string;
801
- };
802
- declare function readBootSessionIdentifier(probe?: BootSessionIdentifierProbe): string | null;
803
- type MachineIdentifierProbe = {
804
- platform: NodeJS.Platform;
805
- kernelValue: string;
806
- };
807
- declare function readMachineIdentifier(probe?: MachineIdentifierProbe): string | null;
808
- type CredentialAuthorityLockHandle = {
809
- lockPath: string;
810
- database: Database;
811
- };
812
- declare function credentialAuthorityLockPath(rootPath?: string): string;
813
- declare function acquireCredentialAuthorityLock(input: {
814
- rootPath?: string;
815
- machineId: string | null;
816
- }): CredentialAuthorityLockHandle;
817
- declare function releaseCredentialAuthorityLockHandle(handle: CredentialAuthorityLockHandle): void;
818
- declare function legacySharedCredentialStorePath(): string;
819
- declare function credentialStorePathForProject(projectId: string): string;
820
- declare function credentialStorePathForWorkspace(remoteUrl: string): string;
821
- declare function removeLegacySharedCredentialStore(storePath?: string): void;
822
- declare function resetCredentialStoreDirectory(directoryPath?: string): void;
823
- declare function readCredentialGenerationReceipt(receiptPath?: string): string | null;
824
- declare function pruneCredentialStoreFiles(requiredStorePaths: ReadonlySet<string>, directoryPath?: string): string[];
825
- declare function replaceCredentialStoreFile(storePath: string, content: string): void;
826
- declare function credentialHelperForRemotes(remotes: readonly {
827
- remoteUrl: string;
828
- authHeader: string | null | undefined;
829
- }[], storePath: string, desiredFiles?: Map<string, string | null>): string | null;
830
- type CredentialGenerationConfiguration = {
831
- workerBaseUrl: string;
832
- workerAuthHeader: string;
833
- workspaceRemoteUrl: string;
834
- githubCredential: WorkerGitHubCredential | null;
835
- projects: readonly Pick<WorkerProjectConfig, "projectId" | "repoHttpUrl" | "repoAuthHeader">[];
836
- };
837
- declare function credentialGenerationFingerprint(config: CredentialGenerationConfiguration): string;
838
- type CredentialGenerationTransitionPhase = "current" | "stage_pending_restart" | "publish_from_clean_restart";
839
- declare function credentialGenerationTransitionPhase(input: {
840
- committedFingerprint: string | null;
841
- pendingFingerprintAtProcessStart: string | null;
842
- incomingFingerprint: string;
843
- }): CredentialGenerationTransitionPhase;
844
- declare function initialCredentialBootstrapIsSafe(input: {
845
- transitionPhase: CredentialGenerationTransitionPhase;
846
- committedFingerprint: string | null;
847
- pendingFingerprintAtProcessStart: string | null;
848
- bootstrapFingerprintAtProcessStart: string | null;
849
- incomingFingerprint: string;
850
- credentialArtifactsProvenAbsentAtProcessStart: boolean;
851
- trackedChildTerminationProven: boolean;
852
- activeProcessCount: number;
853
- credentialProcessGroupCount: number;
854
- activePtyCount: number;
855
- }): boolean;
856
- declare function fenceCredentialGenerationAtConfigureEntry(input: {
857
- currentFingerprint: string | null;
858
- incomingFingerprint: string;
859
- revokeInMemory: () => void;
860
- terminatePreviousGeneration: () => Promise<void>;
861
- }): Promise<boolean>;
862
- declare function requireCredentialGenerationRestart(required: boolean, fatalExit?: (exitCode: number) => void, exitCode?: number): void;
863
- declare function pendingCredentialGenerationBoundary(input: {
864
- systemdContract: boolean;
865
- systemdInvocationId: string | null;
866
- bootSessionId: string | null;
867
- machineId: string | null;
868
- }): PendingCredentialGenerationBoundary;
869
- declare function credentialGenerationBoundaryIsComplete(boundary: PendingCredentialGenerationBoundary): boolean;
870
- declare function credentialGenerationRestartIsContained(input: {
871
- systemdContract: boolean;
872
- pendingBoundary: PendingCredentialGenerationBoundary | null;
873
- currentSystemdInvocationId: string | null;
874
- currentBootSessionId: string | null;
875
- currentMachineId: string | null;
876
- }): boolean;
877
- type CredentialReapContractProbe = {
878
- platform: NodeJS.Platform;
879
- invocationId: string | undefined;
880
- cgroupText: string;
881
- unitProperties: string;
882
- };
883
- type CredentialReapContractStatus = "direct" | "systemd_unverified" | "verified_systemd";
884
- declare function credentialReapContractStatus(probe?: CredentialReapContractProbe): CredentialReapContractStatus;
885
- declare function verifiedCredentialReapContract(probe?: CredentialReapContractProbe): boolean;
886
- declare function workspaceConfigurationIncidentDeferral(input: {
887
- requestedIncidentId: string | undefined;
888
- activeIncidentId: string | null;
889
- }): {
890
- incidentId: string | null;
891
- error?: Error;
892
- };
893
- type DeferredWorkspaceConfiguration = {
894
- incidentId: string;
895
- serverRefreshExpected: boolean;
896
- };
897
- declare function workspaceIncidentTerminalClearDisposition(input: {
898
- deferredConfiguration: DeferredWorkspaceConfiguration | null;
899
- clearedIncidentId: string;
900
- }): "await_server_refresh" | "reconnect_for_refresh";
901
- declare function workspaceIncidentTerminalRefreshFence(input: {
902
- deferredConfiguration: DeferredWorkspaceConfiguration | null;
903
- clearedIncidentId: string;
904
- }): {
905
- disposition: "await_server_refresh" | "reconnect_for_refresh";
906
- deferredConfiguration: DeferredWorkspaceConfiguration;
907
- };
908
- declare function workspaceAutomaticSyncIsAdmitted(input: {
909
- workspaceConfigured: boolean;
910
- activeIncidentId: string | null;
911
- deferredConfiguration: DeferredWorkspaceConfiguration | null;
912
- }): boolean;
913
- declare function deferredWorkspaceTargetIsAllowed(deferredConfiguration: DeferredWorkspaceConfiguration | null, activeIncidentId: string | null, target: WorkerSessionTarget): boolean;
914
- declare function deferredWorkspaceSyncTriggerIsAllowed(deferredConfiguration: DeferredWorkspaceConfiguration | null, activeIncidentId: string | null, trigger: WorkspaceSyncTrigger): boolean;
915
- declare function workspaceOperationsAreFenced(deferredConfiguration: DeferredWorkspaceConfiguration | null, activeIncidentId: string | null): boolean;
916
- declare function workspaceCommandTransportIsAllowed(deferredConfiguration: DeferredWorkspaceConfiguration | null, activeIncidentId: string | null, transport: "exec" | "exec_start"): boolean;
917
- declare function deferredCredentialTransitionMustWait(input: {
918
- incidentId: string | null;
919
- transitionPhase: CredentialGenerationTransitionPhase;
920
- canonicalRemediationActive: boolean;
921
- }): boolean;
922
- declare function workspaceConfigurationIncidentSnapshotIsCurrent(capturedIncidentId: string | null, activeIncidentId: string | null): boolean;
923
- declare function workspaceConfigurationResetToCanonicalIsAllowed(requested: boolean | undefined, incidentId: string | null): boolean;
924
- declare function deferredWorkspaceRefreshWatchdogIsCurrent(input: {
925
- capturedIncidentId: string;
926
- deferredConfiguration: DeferredWorkspaceConfiguration | null;
927
- activeIncidentId: string | null;
928
- }): boolean;
929
- declare function incidentDeferredProjectCheckouts(projects: readonly WorkerProjectConfig[]): Array<{
930
- projectId: string;
931
- branchName: string;
932
- }>;
933
- declare function deferredIncidentWorkspaceConfigurationResult(input: {
934
- attemptId: string;
935
- workerLabel: string;
936
- head: string | null;
937
- skippedMountIds: string[];
938
- }): WorkspaceSyncResult;
939
- declare function workspaceSyncFailureHydrationIsSafe(input: {
940
- error: unknown;
941
- resetToCanonical: boolean;
942
- inspectRecoverableHydration: () => boolean;
943
- }): boolean;
944
- declare function unsafeWorkspaceSyncRecoveryBounceDelayMs(attempt: number): number;
945
- type UnsafeWorkspaceSyncFailureResponse = "fatal_exit" | "recovery_bounce" | "recovery_pending";
946
- declare function unsafeWorkspaceSyncFailureResponse(input: {
947
- resetToCanonical: boolean;
948
- recoveryAttempts: number;
949
- maxRecoveryAttempts: number;
950
- hasRetainableWork: boolean;
951
- bouncePending: boolean;
952
- }): UnsafeWorkspaceSyncFailureResponse;
953
- declare function fenceUnsafeWorkspaceSyncFailure(input: {
954
- hydrationRecoverable: boolean;
955
- resetToCanonical: boolean;
956
- recoveryAttempts: number;
957
- maxRecoveryAttempts: number;
958
- hasRetainableWork: boolean;
959
- bouncePending: boolean;
960
- invalidateExecution: () => void;
961
- scheduleRecoveryBounce: () => void;
962
- fatalExit?: (exitCode: number) => void;
963
- exitCode?: number;
964
- }): "none" | "recovery_bounce" | "recovery_pending";
965
- export declare const workerGitSecurityTestHarness: {
966
- commandArgs: (args: string[]) => string[];
967
- credentialHelperForRemotes: typeof credentialHelperForRemotes;
968
- credentialStorePathForProject: typeof credentialStorePathForProject;
969
- credentialStorePathForWorkspace: typeof credentialStorePathForWorkspace;
970
- legacySharedCredentialStorePath: typeof legacySharedCredentialStorePath;
971
- removeLegacySharedCredentialStore: typeof removeLegacySharedCredentialStore;
972
- pruneCredentialStoreFiles: typeof pruneCredentialStoreFiles;
973
- readOnlyCredentialStoreHelper: typeof readOnlyCredentialStoreHelper;
974
- resetCredentialStoreDirectory: typeof resetCredentialStoreDirectory;
975
- replaceCredentialStoreFile: typeof replaceCredentialStoreFile;
976
- configureGitHubAuth(credential: WorkerGitHubCredential | null, filePaths: readonly string[], configureFiles?: typeof configureGitHubRegistryAuthFiles): void;
977
- githubCredential: () => WorkerGitHubCredential | null;
978
- credentialGenerationFingerprint: typeof credentialGenerationFingerprint;
979
- credentialGenerationTransitionPhase: typeof credentialGenerationTransitionPhase;
980
- initialCredentialBootstrapIsSafe: typeof initialCredentialBootstrapIsSafe;
981
- fenceCredentialGenerationAtConfigureEntry: typeof fenceCredentialGenerationAtConfigureEntry;
982
- requireCredentialGenerationRestart: typeof requireCredentialGenerationRestart;
983
- pendingCredentialGenerationBoundary: typeof pendingCredentialGenerationBoundary;
984
- credentialGenerationBoundaryIsComplete: typeof credentialGenerationBoundaryIsComplete;
985
- credentialGenerationRestartIsContained: typeof credentialGenerationRestartIsContained;
986
- credentialReapContractStatus: typeof credentialReapContractStatus;
987
- verifiedCredentialReapContract: typeof verifiedCredentialReapContract;
988
- fenceUnsafeWorkspaceSyncFailure: typeof fenceUnsafeWorkspaceSyncFailure;
989
- unsafeWorkspaceSyncFailureResponse: typeof unsafeWorkspaceSyncFailureResponse;
990
- unsafeWorkspaceSyncRecoveryBounceDelayMs: typeof unsafeWorkspaceSyncRecoveryBounceDelayMs;
991
- WORKSPACE_UNSAFE_SYNC_MAX_RECOVERY_ATTEMPTS: number;
992
- WORKSPACE_UNSAFE_SYNC_RECOVERY_CLOSE_CODE: number;
993
- WorkspaceSyncAdmissionChangedError: typeof WorkspaceSyncAdmissionChangedError;
994
- workspaceConfigurationIncidentDeferral: typeof workspaceConfigurationIncidentDeferral;
995
- workspaceIncidentTerminalClearDisposition: typeof workspaceIncidentTerminalClearDisposition;
996
- workspaceIncidentTerminalRefreshFence: typeof workspaceIncidentTerminalRefreshFence;
997
- workspaceAutomaticSyncIsAdmitted: typeof workspaceAutomaticSyncIsAdmitted;
998
- deferredWorkspaceTargetIsAllowed: typeof deferredWorkspaceTargetIsAllowed;
999
- deferredWorkspaceSyncTriggerIsAllowed: typeof deferredWorkspaceSyncTriggerIsAllowed;
1000
- workspaceOperationsAreFenced: typeof workspaceOperationsAreFenced;
1001
- workspaceCommandTransportIsAllowed: typeof workspaceCommandTransportIsAllowed;
1002
- deferredCredentialTransitionMustWait: typeof deferredCredentialTransitionMustWait;
1003
- workspaceConfigurationIncidentSnapshotIsCurrent: typeof workspaceConfigurationIncidentSnapshotIsCurrent;
1004
- workspaceConfigurationResetToCanonicalIsAllowed: typeof workspaceConfigurationResetToCanonicalIsAllowed;
1005
- deferredWorkspaceRefreshWatchdogIsCurrent: typeof deferredWorkspaceRefreshWatchdogIsCurrent;
1006
- incidentDeferredProjectCheckouts: typeof incidentDeferredProjectCheckouts;
1007
- deferredIncidentWorkspaceConfigurationResult: typeof deferredIncidentWorkspaceConfigurationResult;
1008
- workspaceSyncFailureHydrationIsSafe: typeof workspaceSyncFailureHydrationIsSafe;
1009
- assertWorkerChildAdmission: typeof assertWorkerChildAdmission;
1010
- executeWriteFileOperation: typeof executeWriteFileOperation;
1011
- executeOperation: typeof executeOperation;
1012
- executeEditFileOperation: typeof executeEditFileOperation;
1013
- terminateCredentialBearingChildren: typeof terminateCredentialBearingChildren;
1014
- terminateCredentialBearingChildrenWithRetention: typeof terminateCredentialBearingChildrenWithRetention;
1015
- commitCredentialGeneration(prepared: PreparedPrivateAuthFileGeneration, credential: WorkerGitHubCredential | null, options: {
1016
- children: readonly {
1017
- label: string;
1018
- terminate: () => void | Promise<void>;
1019
- }[];
1020
- secretMaterialChanged: boolean;
1021
- beforeMutation?: (filePath: string, index: number) => void;
1022
- previousGenerationFenced?: boolean;
1023
- }): Promise<boolean>;
1024
- credentialGenerationReceiptPath: typeof credentialGenerationReceiptPath;
1025
- credentialAuthorityLockPath: typeof credentialAuthorityLockPath;
1026
- acquireCredentialAuthorityLock: typeof acquireCredentialAuthorityLock;
1027
- releaseCredentialAuthorityLockHandle: typeof releaseCredentialAuthorityLockHandle;
1028
- pendingCredentialGenerationPath: typeof pendingCredentialGenerationPath;
1029
- pendingCredentialGenerationIntentContent: typeof pendingCredentialGenerationIntentContent;
1030
- readPendingCredentialGenerationIntent: typeof readPendingCredentialGenerationIntent;
1031
- readBootSessionIdentifier: typeof readBootSessionIdentifier;
1032
- readMachineIdentifier: typeof readMachineIdentifier;
1033
- bootstrapCredentialGenerationPath: typeof bootstrapCredentialGenerationPath;
1034
- readCredentialGenerationReceipt: typeof readCredentialGenerationReceipt;
1035
- };
1036
- export declare function githubCliEnv(token: string | null | undefined): Record<string, string>;
1037
- /**
1038
- * Build an agent-command environment without inheriting credentials that were
1039
- * supplied to bootstrap or authenticate the worker itself. Later layers are
1040
- * explicit server-issued per-run credentials or the currently committed GitHub
1041
- * generation and are intentionally allowed to use the same public variable
1042
- * names.
1043
- */
1044
- export declare function workerChildProcessEnvironment(layers: readonly NodeJS.ProcessEnv[], inherited?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
1045
- type ResolvedWorkerSessionTarget = {
1046
- target: WorkerSessionTarget;
1047
- rootPath: string;
1048
- config?: WorkerProjectConfig;
1049
- };
1050
- declare function canonicalSyncTerminalHead(resolvedTarget: Pick<ResolvedWorkerSessionTarget, "target" | "rootPath">, readHead?: (rootPath: string) => string): string | undefined;
1051
- export declare function describeWorkerSessionTarget(target: WorkerSessionTarget): string;
1052
- export declare function resolveWorkerSessionTarget(input: {
1053
- target: WorkerSessionTarget;
1054
- projectsRoot: string;
1055
- workspaceShadowRoot: string;
1056
- projectConfigById: Map<string, WorkerProjectConfig>;
1057
- }): ResolvedWorkerSessionTarget;
1058
- export declare function prepareBuiltInToolPathsForTarget(input: {
1059
- target: WorkerSessionTarget;
1060
- filePath: string;
1061
- baseUrl: string;
1062
- token: string;
1063
- sessionId?: string;
1064
- activePlanId?: string;
1065
- rootDir: string;
1066
- access: "read" | "write";
1067
- }): Promise<WorkerBuiltInToolPaths | undefined>;
1068
- export declare function readWorkerTextFile(branchPath: string, filePath: string, offset?: number, limit?: number, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerReadFileResult>;
1069
- export declare function writeWorkerTextFile(branchPath: string, filePath: string, content: string, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerWriteFileResult>;
1070
- export declare function editWorkerTextFile(branchPath: string, filePath: string, edits: Array<{
1071
- oldText: string;
1072
- newText: string;
1073
- }>, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerEditFileResult>;
1074
- declare function executeWriteFileOperation(input: {
1075
- message: Extract<WorkerServerMessage, {
1076
- type: "write";
1077
- }>;
1078
- resolvedTarget: ResolvedWorkerSessionTarget;
1079
- baseUrl: string;
1080
- token: string;
1081
- rootDir: string;
1082
- assertAdmission: () => void;
1083
- }): Promise<WorkerWriteFileResult>;
1084
- declare function executeEditFileOperation(input: {
1085
- message: Extract<WorkerServerMessage, {
1086
- type: "edit";
1087
- }>;
1088
- resolvedTarget: ResolvedWorkerSessionTarget;
1089
- baseUrl: string;
1090
- token: string;
1091
- rootDir: string;
1092
- assertAdmission: () => void;
1093
- }): Promise<WorkerEditFileResult>;
1094
- export declare function grepWorkerFiles(branchPath: string, input: {
1095
- pattern: string;
1096
- path?: string;
1097
- glob?: string;
1098
- caseSensitive?: boolean;
1099
- limit?: number;
1100
- }, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerGrepResult>;
1101
- export declare function findWorkerFiles(branchPath: string, input: {
1102
- pattern?: string;
1103
- path?: string;
1104
- entryType?: string;
1105
- limit?: number;
1106
- }, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerFindResult>;
1107
- export declare function listWorkerDirectory(branchPath: string, inputPath?: string, inputLimit?: number, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerLsResult>;
1108
- export declare function listWorkerCodeDirectory(branchPath: string, inputPath: string): Promise<WorkerCodeListResult>;
1109
- export declare function readWorkerCodeFile(branchPath: string, inputPath: string): Promise<WorkerCodeReadResult>;
1110
- export declare function readWorkerImageFile(branchPath: string, filePath: string, builtInPaths?: WorkerBuiltInToolPaths): Promise<WorkerViewFileBytesResult>;
1111
- declare function executeOperation(input: {
1112
- message: WorkerOperationServerMessage;
1113
- resolvedTarget: ResolvedWorkerSessionTarget;
1114
- baseUrl: string;
1115
- token: string;
1116
- rootDir: string;
1117
- assertAdmission: () => void;
1118
- }): Promise<WorkerOperationResult>;
1119
- declare function targetProcessEnv(rootDir: string, target: WorkerSessionTarget): Record<string, string>;
1120
- export declare function prepareShellEnvForTarget(input: {
1121
- target: WorkerSessionTarget;
1122
- baseUrl: string;
1123
- token: string;
1124
- sessionId?: string;
1125
- activePlanId?: string;
1126
- rootDir: string;
1127
- }): Promise<Record<string, string>>;
1128
- declare function createNodePtyBridge(options: {
1129
- file: string;
1130
- args: string[];
1131
- ptyOptions: {
1132
- name: string;
1133
- cols: number;
1134
- rows: number;
1135
- cwd: string;
1136
- env: Record<string, string | undefined>;
1137
- };
1138
- onOpened: (pid: number) => void;
1139
- onForeground: (busy: boolean) => void;
1140
- onOutput: (data: string) => void;
1141
- onExit: (event: {
1142
- exitCode: number;
1143
- signal?: number | string;
1144
- }) => void;
1145
- onError: (error: Error) => void;
1146
- onTerminationError: (error: Error) => void;
1147
- }): WorkerPty;
1148
- export declare const workerPtyBridgeTestHarness: {
1149
- create: typeof createNodePtyBridge;
1150
- closeAllBestEffort: typeof closePtysBestEffort;
1151
- };
1152
- export declare function resolveHostShell(command?: string, platform?: NodeJS.Platform): {
1153
- file: string;
1154
- args: string[];
1155
- env?: Record<string, string>;
1156
- };
1157
- declare function closePtysBestEffort(ptys: Iterable<readonly [string, {
1158
- kill: () => void;
1159
- }]>, reportFailure: (ptyId: string, error: unknown) => void): void;
1160
- declare function terminateCredentialBearingChildren(children: readonly {
1161
- label: string;
1162
- terminate: () => void | Promise<void>;
1163
- }[]): Promise<void>;
1164
- declare function terminateCredentialBearingChildrenWithRetention(children: readonly {
1165
- label: string;
1166
- terminate: () => void | Promise<void>;
1167
- onTerminated: () => void;
1168
- }[]): Promise<void>;
1169
2
  export {};