@ricsam/r5d-worker 0.0.137 → 0.0.139

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 (236) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7543
  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 +359 -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 +3 -1
  41. package/dist/types/runtime/executor.d.ts +6 -1
  42. package/dist/types/runtime/protocol.d.ts +176 -4
  43. package/dist/types/runtime/pty.d.ts +1 -0
  44. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  45. package/dist/types/runtime/releases/grants.d.ts +16 -0
  46. package/dist/types/runtime/releases/manager.d.ts +145 -0
  47. package/dist/types/runtime/releases/process.d.ts +14 -0
  48. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  49. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  50. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  51. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  52. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  53. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  54. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  55. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  56. package/dist/types/runtime/workspace/files.d.ts +21 -0
  57. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  58. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  59. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  60. package/package.json +8 -6
  61. package/dist/cjs/atomic-rename.cjs +0 -303
  62. package/dist/cjs/browser-upload.cjs +0 -73
  63. package/dist/cjs/cli-update.cjs +0 -108
  64. package/dist/cjs/command-launcher.cjs +0 -423
  65. package/dist/cjs/control-command-policy.cjs +0 -177
  66. package/dist/cjs/git-blob-hash.cjs +0 -41
  67. package/dist/cjs/git-identity.cjs +0 -39
  68. package/dist/cjs/git-process-environment.cjs +0 -133
  69. package/dist/cjs/inline-output.cjs +0 -62
  70. package/dist/cjs/main.cjs +0 -7517
  71. package/dist/cjs/managed-paths.cjs +0 -215
  72. package/dist/cjs/plan-lint.cjs +0 -165
  73. package/dist/cjs/plan-parser.cjs +0 -127
  74. package/dist/cjs/plan-paths.cjs +0 -53
  75. package/dist/cjs/port-forward-client.cjs +0 -206
  76. package/dist/cjs/process-tree.cjs +0 -117
  77. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  78. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  79. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  80. package/dist/cjs/project-workspace-state.cjs +0 -972
  81. package/dist/cjs/project-worktrees.cjs +0 -1713
  82. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  83. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  84. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  85. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  86. package/dist/cjs/recovery-journal.cjs +0 -742
  87. package/dist/cjs/recovery-output-window.cjs +0 -77
  88. package/dist/cjs/recovery-protocol.cjs +0 -31
  89. package/dist/cjs/recovery-store.cjs +0 -252
  90. package/dist/cjs/registry-auth.cjs +0 -310
  91. package/dist/cjs/repository-transition-policy.cjs +0 -49
  92. package/dist/cjs/runtime-version.cjs +0 -88
  93. package/dist/cjs/session-file-mutations.cjs +0 -61
  94. package/dist/cjs/supervisor.cjs +0 -147
  95. package/dist/cjs/three-way-merge.cjs +0 -346
  96. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  97. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  98. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  99. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  100. package/dist/cjs/workspace-command-targets.cjs +0 -63
  101. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  102. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  103. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  104. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  105. package/dist/cjs/workspace-git-sync.cjs +0 -3595
  106. package/dist/cjs/workspace-hydration-ledger.cjs +0 -83
  107. package/dist/cjs/workspace-hydration-merge.cjs +0 -448
  108. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  109. package/dist/cjs/workspace-incident-state.cjs +0 -37
  110. package/dist/cjs/workspace-merge-projection.cjs +0 -628
  111. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  112. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  113. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  114. package/dist/cjs/workspace-path-move.cjs +0 -195
  115. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  116. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  117. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  118. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  119. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  120. package/dist/mjs/atomic-rename.mjs +0 -261
  121. package/dist/mjs/browser-upload.mjs +0 -42
  122. package/dist/mjs/command-launcher.mjs +0 -393
  123. package/dist/mjs/control-command-policy.mjs +0 -146
  124. package/dist/mjs/git-blob-hash.mjs +0 -16
  125. package/dist/mjs/git-identity.mjs +0 -15
  126. package/dist/mjs/git-process-environment.mjs +0 -105
  127. package/dist/mjs/inline-output.mjs +0 -37
  128. package/dist/mjs/managed-paths.mjs +0 -174
  129. package/dist/mjs/plan-lint.mjs +0 -129
  130. package/dist/mjs/plan-parser.mjs +0 -94
  131. package/dist/mjs/plan-paths.mjs +0 -25
  132. package/dist/mjs/port-forward-client.mjs +0 -172
  133. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  134. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  135. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  136. package/dist/mjs/project-workspace-state.mjs +0 -937
  137. package/dist/mjs/project-worktrees.mjs +0 -1657
  138. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  139. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  140. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  141. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  142. package/dist/mjs/recovery-journal.mjs +0 -694
  143. package/dist/mjs/recovery-output-window.mjs +0 -53
  144. package/dist/mjs/recovery-protocol.mjs +0 -6
  145. package/dist/mjs/recovery-store.mjs +0 -217
  146. package/dist/mjs/registry-auth.mjs +0 -269
  147. package/dist/mjs/repository-transition-policy.mjs +0 -22
  148. package/dist/mjs/runtime-version.mjs +0 -54
  149. package/dist/mjs/session-file-mutations.mjs +0 -37
  150. package/dist/mjs/supervisor.mjs +0 -114
  151. package/dist/mjs/three-way-merge.mjs +0 -318
  152. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  153. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  154. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  155. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  156. package/dist/mjs/workspace-command-targets.mjs +0 -37
  157. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  158. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  159. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  160. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  161. package/dist/mjs/workspace-git-sync.mjs +0 -3553
  162. package/dist/mjs/workspace-hydration-ledger.mjs +0 -58
  163. package/dist/mjs/workspace-hydration-merge.mjs +0 -414
  164. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  165. package/dist/mjs/workspace-incident-state.mjs +0 -12
  166. package/dist/mjs/workspace-merge-projection.mjs +0 -594
  167. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  168. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  169. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  170. package/dist/mjs/workspace-path-move.mjs +0 -160
  171. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  172. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  173. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  174. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  175. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  176. package/dist/types/atomic-rename.d.ts +0 -78
  177. package/dist/types/browser-upload.d.ts +0 -7
  178. package/dist/types/command-launcher.d.ts +0 -104
  179. package/dist/types/control-command-policy.d.ts +0 -53
  180. package/dist/types/git-blob-hash.d.ts +0 -10
  181. package/dist/types/git-identity.d.ts +0 -9
  182. package/dist/types/git-process-environment.d.ts +0 -9
  183. package/dist/types/inline-output.d.ts +0 -3
  184. package/dist/types/managed-paths.d.ts +0 -19
  185. package/dist/types/plan-lint.d.ts +0 -16
  186. package/dist/types/plan-parser.d.ts +0 -38
  187. package/dist/types/plan-paths.d.ts +0 -36
  188. package/dist/types/port-forward-client.d.ts +0 -8
  189. package/dist/types/project-checkout-garbage.d.ts +0 -86
  190. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  191. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  192. package/dist/types/project-workspace-state.d.ts +0 -188
  193. package/dist/types/project-worktrees.d.ts +0 -397
  194. package/dist/types/pty-output-coalescer.d.ts +0 -20
  195. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  196. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  197. package/dist/types/recovery-journal-stall-fixture.d.ts +0 -1
  198. package/dist/types/recovery-journal-thread.d.ts +0 -1
  199. package/dist/types/recovery-journal.d.ts +0 -248
  200. package/dist/types/recovery-output-window.d.ts +0 -19
  201. package/dist/types/recovery-protocol.d.ts +0 -59
  202. package/dist/types/recovery-store.d.ts +0 -52
  203. package/dist/types/registry-auth.d.ts +0 -47
  204. package/dist/types/repository-transition-policy.d.ts +0 -26
  205. package/dist/types/runtime-version.d.ts +0 -1
  206. package/dist/types/session-file-mutations.d.ts +0 -22
  207. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  208. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  209. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  210. package/dist/types/supervisor.d.ts +0 -23
  211. package/dist/types/three-way-merge.d.ts +0 -77
  212. package/dist/types/working-tree-mirror.d.ts +0 -424
  213. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  214. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  215. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  216. package/dist/types/workspace-command-targets.d.ts +0 -37
  217. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  218. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  219. package/dist/types/workspace-filesystem-job-types.d.ts +0 -302
  220. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  221. package/dist/types/workspace-git-sync.d.ts +0 -514
  222. package/dist/types/workspace-hydration-ledger.d.ts +0 -76
  223. package/dist/types/workspace-hydration-merge.d.ts +0 -103
  224. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  225. package/dist/types/workspace-incident-state.d.ts +0 -19
  226. package/dist/types/workspace-merge-projection.d.ts +0 -69
  227. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  228. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  229. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  230. package/dist/types/workspace-path-move.d.ts +0 -21
  231. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  232. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  233. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  234. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  235. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  236. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,104 +0,0 @@
1
- export type CommandLaunchRequest = {
2
- id: string;
3
- kind: "exec" | "exec_start" | "pty_open";
4
- workspaceEffect?: "none";
5
- /** An explicitly classified short coordination command; the launcher keeps a bounded lane for these. */
6
- commandClass?: "control";
7
- sessionId?: string;
8
- assertAdmission: () => void;
9
- };
10
- export type CommandLaunchLane = "general" | "utility" | "control";
11
- export type CommandLaunchCapacity = {
12
- generalSlots: number;
13
- utilitySlots: number;
14
- controlSlots: number;
15
- controlRuntimeMs: number;
16
- queueTimeoutMs: number;
17
- };
18
- export type CommandLaunchLaneReport = {
19
- /** Null when no launcher bounds this lane (direct execution). */
20
- slots: number | null;
21
- active: Array<{
22
- id: string;
23
- sessionId?: string;
24
- since: string;
25
- }>;
26
- queued: Array<{
27
- id: string;
28
- sessionId?: string;
29
- since: string;
30
- }>;
31
- };
32
- /** Who holds and who waits for each lane, as the worker sees its own admissions. */
33
- export type CommandLaunchCapacityReport = {
34
- /** False for a direct worker: nothing is bounded and nothing can be starved. */
35
- bounded: boolean;
36
- controlRuntimeMs: number | null;
37
- lanes: Record<CommandLaunchLane, CommandLaunchLaneReport>;
38
- };
39
- /** The same lane rule the managed launcher applies; kept here so reports match admissions. */
40
- export declare function commandLaunchLane(request: Pick<CommandLaunchRequest, "kind" | "workspaceEffect" | "commandClass">): CommandLaunchLane;
41
- export type CommandLaunchLease = {
42
- wrap(argv: string[]): string[];
43
- cancel(): Promise<void>;
44
- diagnose(): Promise<string | undefined>;
45
- release(): Promise<void>;
46
- };
47
- export declare class CommandLauncherUnavailableError extends Error {
48
- constructor(message: string, cause?: unknown);
49
- }
50
- export declare class CommandLaunchCancelledError extends Error {
51
- constructor();
52
- }
53
- export declare function parseCommandLauncher(configuration: string | undefined): string[] | undefined;
54
- /** Launcher configuration is operator-owned; do not inherit worker or package credentials. */
55
- export declare function commandLauncherEnvironment(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
56
- /** Generic optional JSONL controller; policy and OS-specific launch prefixes live outside the worker. */
57
- export declare class WorkerCommandLauncher {
58
- private readonly options;
59
- readonly mode: "direct" | "external";
60
- private readonly child?;
61
- private readonly pending;
62
- private readonly launches;
63
- private readonly exited;
64
- private failure?;
65
- private closing;
66
- private initialized;
67
- private closePromise?;
68
- private sequence;
69
- private capacity?;
70
- constructor(options?: {
71
- argv?: string[];
72
- env?: NodeJS.ProcessEnv;
73
- onFailure?: (error: Error, ids: string[]) => void;
74
- onStderr?: (text: string) => void;
75
- requestTimeoutMs?: number;
76
- acquisitionTimeoutMs?: number;
77
- /** Called after any admission changes lane, phase, or is released. */
78
- onCapacityChange?: () => void;
79
- });
80
- initialize(): Promise<void>;
81
- get activeIds(): string[];
82
- /** The lane totals the launcher declared at initialization; undefined for a direct worker or an older launcher. */
83
- get declaredCapacity(): CommandLaunchCapacity | undefined;
84
- get supportsControlLane(): boolean;
85
- /** Current admissions per lane, for the worker's capacity report. */
86
- capacityReport(): CommandLaunchCapacityReport;
87
- private notifyCapacityChange;
88
- acquire(request: CommandLaunchRequest): Promise<CommandLaunchLease>;
89
- /** Revoke a launch. Returns whether this launcher still held it (queued or acquired, not yet released). */
90
- cancel(id: string): Promise<boolean>;
91
- cancelSession(sessionId: string): Promise<void>;
92
- cancelMatching(matches: (id: string, sessionId?: string) => boolean): Promise<void>;
93
- close(): Promise<void>;
94
- private waitForExit;
95
- private releaseRecord;
96
- private assertHealthy;
97
- private rpc;
98
- private receive;
99
- private rejectPending;
100
- private fail;
101
- }
102
- export declare function createWorkerCommandLauncher(options?: Omit<NonNullable<ConstructorParameters<typeof WorkerCommandLauncher>[0]>, "argv"> & {
103
- configuration?: string;
104
- }): Promise<WorkerCommandLauncher>;
@@ -1,53 +0,0 @@
1
- /**
2
- * Which agent shell invocations may run in the managed launcher's bounded
3
- * `control` lane: exactly one plain `r5dctl` coordination/diagnosis command.
4
- *
5
- * The lane exists so an agent can inspect capacity, message another session,
6
- * or stop its own runs while every general slot is held by long work
7
- * (incident 9). It is bounded (small memory, few PIDs, a runtime limit), so
8
- * only commands that are short HTTP calls to the platform qualify. The
9
- * classifier fails closed: anything the shell would interpret (operators,
10
- * substitutions, expansions, quoting the tokenizer cannot prove literal,
11
- * environment assignments, wrapper programs, paths) is refused and keeps its
12
- * ordinary general-lane shell semantics. The resulting argv is validated a
13
- * second time by the worker before it is spawned without a shell.
14
- */
15
- export declare const CONTROL_COMMAND_PROGRAM = "r5dctl";
16
- /** Worker-side runtime bound for a control run; the launcher enforces its own limit as a backstop. */
17
- export declare const CONTROL_COMMAND_RUNTIME_MS = 120000;
18
- export declare const CONTROL_COMMAND_MAX_ARGV = 64;
19
- export declare const CONTROL_COMMAND_MAX_LENGTH = 4096;
20
- export type ControlCommandClassification = {
21
- control: true;
22
- argv: string[];
23
- } | {
24
- control: false;
25
- reason: string;
26
- };
27
- /**
28
- * Validate an argv as an allowed r5dctl coordination invocation. Used on the
29
- * server after tokenizing, and again on the worker before spawning.
30
- */
31
- export declare function assertControlCommandArgv(argv: readonly string[]): void;
32
- /**
33
- * Locate the installed CLI through the worker's own, operator-controlled
34
- * search path. The command's cwd, its environment, and any checkout-local
35
- * shim play no part, so a project cannot substitute the executable the
36
- * reserved lane runs.
37
- */
38
- export declare function resolveControlCommandExecutable(trustedPath: string | undefined, which: (program: string, options: {
39
- PATH: string;
40
- }) => string | null, program?: string): string;
41
- /**
42
- * The environment a control spawn receives: everything the platform sets for
43
- * the run (credentials, session identity, declared project values) minus any
44
- * variable that could load code into the CLI process or redirect which
45
- * executable runs, with the worker's own PATH restored.
46
- */
47
- export declare function controlCommandEnvironment(environment: NodeJS.ProcessEnv, trustedPath: string | undefined): Record<string, string>;
48
- /**
49
- * Classify an agent shell command. Only a plain `r5dctl` coordination
50
- * invocation becomes a control command; the returned argv is spawned without a
51
- * shell. Everything else keeps its ordinary shell semantics and lane.
52
- */
53
- export declare function classifyControlCommand(command: string): ControlCommandClassification;
@@ -1,10 +0,0 @@
1
- export type GitObjectHashAlgorithm = "sha1" | "sha256";
2
- /** The object format an object id of this length belongs to, or null for anything that is not an object id. */
3
- export declare function gitObjectHashAlgorithmFor(objectId: string): GitObjectHashAlgorithm | null;
4
- /**
5
- * The id `git hash-object` gives `content` as a blob: the hash of the
6
- * `blob <size>\0` header followed by the bytes, with no filter applied. The
7
- * sync engine hashes checkout bytes with it to ask whether a file still holds
8
- * what a commit records without spawning git.
9
- */
10
- export declare function gitBlobHash(content: Buffer, algorithm: GitObjectHashAlgorithm): string;
@@ -1,9 +0,0 @@
1
- export type WorkerGitIdentity = {
2
- name: string;
3
- email: string;
4
- };
5
- type RunGit = (args: string[], options?: {
6
- cwd?: string;
7
- }) => string | void;
8
- export declare function configureVisibleGitIdentity(branchPath: string, identity: WorkerGitIdentity | null | undefined, runGit: RunGit): void;
9
- export {};
@@ -1,9 +0,0 @@
1
- /** Build the complete environment for a worker-owned Git child process. */
2
- export declare function workerGitProcessEnvironment(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
3
- /** Clear inherited and repository-local HTTP authorization headers for one transport URL. */
4
- export declare function gitHttpAuthorizationClearArgs(remoteUrl: string): string[];
5
- /** Select only the app-owned credential store, regardless of repository-local helpers. */
6
- export declare function gitCredentialHelperConfigArgs(credentialHelper?: string | null): string[];
7
- export declare function gitCredentialUsernameConfigKey(remoteUrl: string): string;
8
- /** Non-secret command configuration required for an authenticated HTTP transport. */
9
- export declare function gitTransportSecurityArgs(remoteUrl: string, credentialHelper?: string | null, credentialUsername?: string | null): string[];
@@ -1,3 +0,0 @@
1
- export declare const WORKER_INLINE_OUTPUT_MAX_BYTES: number;
2
- /** Bound inline RPC buffers in the worker regardless of child launch policy. */
3
- export declare function collectWorkerInlineOutput(stream: ReadableStream<Uint8Array> | null, maxBytes?: number, signal?: AbortSignal): Promise<string>;
@@ -1,19 +0,0 @@
1
- export declare const BRANCH_NAME_MAX_LENGTH = 45;
2
- export declare const BRANCH_NAME_PATTERN: RegExp;
3
- export type CheckoutPathSegments = [namespace: string, project: string];
4
- export type ManagedRoot = {
5
- label: string;
6
- rootPath: string;
7
- };
8
- /**
9
- * Destructive worker roots must never alias or contain one another. Resolve
10
- * and materialize every root first so symlinks, bind mounts, casing aliases,
11
- * and Unicode-normalization aliases cannot disguise an overlap. This runs
12
- * before any snapshot recovery or other destructive filesystem operation.
13
- */
14
- export declare function assertDisjointManagedRoots(roots: readonly ManagedRoot[]): void;
15
- export declare function validateManagedBranchName(branchName: string): void;
16
- export declare function validateCheckoutPathSegments(value: unknown): CheckoutPathSegments;
17
- export declare function assertPathInside(root: string, candidate: string, label: string): void;
18
- export declare function managedProjectRoot(projectsRoot: string, checkoutPathSegments: unknown): string;
19
- export declare function managedBranchPath(projectsRoot: string, checkoutPathSegments: unknown, branchName: string): string;
@@ -1,16 +0,0 @@
1
- export interface PlanLintError {
2
- planId: string;
3
- message: string;
4
- severity: "warning" | "error";
5
- line?: number;
6
- }
7
- export interface PlanLintResult {
8
- type: "plan_lint";
9
- errors: PlanLintError[];
10
- errorCount: number;
11
- warningCount: number;
12
- lintedPlanCount: number;
13
- }
14
- export declare function lintPlanContent(planId: string, content: string): PlanLintError[];
15
- export declare function lintPlans(plansDir: string, glob?: string): Promise<PlanLintResult>;
16
- export declare function formatPlanLintErrors(errors: PlanLintError[]): string;
@@ -1,38 +0,0 @@
1
- /**
2
- * Markdown plan parser.
3
- *
4
- * Plans are plain Markdown files. The only structured region is the first
5
- * "## Tasks" section, which contains checkbox task lines.
6
- */
7
- export declare const PLAN_TASK_ID_REGEX: RegExp;
8
- export declare const PLAN_TASK_LINE_REGEX: RegExp;
9
- export declare const PLAN_TASKS_HEADING_REGEX: RegExp;
10
- export interface PlanTask {
11
- id: string;
12
- description: string;
13
- checked: boolean;
14
- lineNumber: number;
15
- }
16
- export interface ParsedPlan {
17
- id: string;
18
- title: string;
19
- content: string;
20
- tasks: PlanTask[];
21
- currentTask: PlanTask | null;
22
- complete: boolean;
23
- tasksStartLine: number | null;
24
- tasksEndLine: number | null;
25
- }
26
- export type ParsedMarkdownPlan = ParsedPlan;
27
- export declare function getPlanMetadata(content: string): {
28
- title: string;
29
- };
30
- export declare function getTasksSectionRange(content: string): {
31
- startIndex: number;
32
- endIndex: number;
33
- } | null;
34
- export declare function parseMarkdownPlan(content: string, planId: string): ParsedPlan;
35
- export declare const parsePlan: typeof parseMarkdownPlan;
36
- export declare function createPlanMarkdown(planId: string, title?: string): string;
37
- export declare function updateTaskCheckbox(content: string, taskId: string, checked: boolean): string;
38
- export declare function formatPlanTitle(planId: string): string;
@@ -1,36 +0,0 @@
1
- type PlanTarget = {
2
- type: "project";
3
- } | {
4
- type: "workspace";
5
- rootProfile: "visible_projects" | "canonical_sync";
6
- };
7
- export declare const PLAN_EXTENSION = ".plan.md";
8
- export declare function validatePlanId(planId: string): void;
9
- export declare function assertPlanTarget(target: PlanTarget): void;
10
- export declare function getWorkerPlansPath(target: PlanTarget): string;
11
- /** The same worker path is used in prompts, injected reads, and file tools. */
12
- export declare function getWorkerPlanPath(target: PlanTarget, planId: string): string;
13
- export type WorkerReadPlanInput = {
14
- planId: string;
15
- createIfMissing: boolean;
16
- };
17
- export type WorkerLintPlansInput = {
18
- glob?: string;
19
- };
20
- export type WorkerUpdatePlanTaskInput = {
21
- planId: string;
22
- taskId: string;
23
- checked: boolean;
24
- };
25
- export type WorkerLintPlansResult = {
26
- type: "lint_plans";
27
- content: string;
28
- };
29
- export type WorkerUpdatePlanTaskResult = {
30
- type: "update_task_status";
31
- planId: string;
32
- taskId: string;
33
- checked: boolean;
34
- message: string;
35
- };
36
- export {};
@@ -1,8 +0,0 @@
1
- export declare function openWorkerPortForwardRelay(options: {
2
- baseUrl: string;
3
- token: string;
4
- label: string;
5
- forwardId: string;
6
- relayConnectionId: string;
7
- workerPort: number;
8
- }): void;
@@ -1,86 +0,0 @@
1
- /**
2
- * Where a deleted branch checkout waits for collection. Staging is the only
3
- * platform write into this directory and a live checkout always lives at
4
- * `<projectRoot>/<branch>`, so a crash between staging and collection leaves
5
- * nothing that a later sweep could confuse with a replacement branch. The
6
- * filesystem is user-managed, though, so the collector never trusts the name
7
- * alone: it removes only real directories or leaf links that sit under a real
8
- * garbage directory of a real project directory (see `ownedStagedPath`).
9
- * Distinct from `.r5d-removed`, which preserves paths that were not this
10
- * project's worktree.
11
- */
12
- export declare const PROJECT_DELETED_CHECKOUTS_DIRECTORY = ".r5d-deleted";
13
- /**
14
- * Rename a checkout this project owns out of the active namespace. One
15
- * same-filesystem rename takes milliseconds whatever the tree holds, so the
16
- * branch mutation lease is released long before the bytes are gone. The
17
- * garbage directory must be a real directory: a planted link would make the
18
- * later collection walk through it, so staging refuses rather than continue.
19
- */
20
- export declare function stageProjectCheckoutForDeletion(projectRoot: string, branchName: string, checkoutPath: string): string;
21
- /**
22
- * Rename a whole project root out of the active namespace, into the
23
- * namespace's garbage directory, so removing a deleted project never walks
24
- * its checkouts on the worker event loop. Same guarantees as
25
- * stageProjectCheckoutForDeletion: one same-filesystem rename, a real garbage
26
- * directory, collection by the garbage collector later.
27
- */
28
- export declare function stageProjectForDeletion(projectsRoot: string, projectRoot: string): string;
29
- /**
30
- * True when `candidate` is lexically a direct entry of a project's garbage
31
- * directory (`<namespace>/<project>/.r5d-deleted/<entry>`, a staged checkout)
32
- * or of a namespace's garbage directory (`<namespace>/.r5d-deleted/<entry>`,
33
- * a staged whole project) under `projectsRoot`.
34
- */
35
- export declare function isStagedProjectCheckoutPath(projectsRoot: string, candidate: string): boolean;
36
- /**
37
- * Whether a lexically staged path is safe to remove right now: every ancestor
38
- * below the projects root is a real directory (a linked namespace, project,
39
- * or garbage directory would let a removal reach an unrelated tree through
40
- * the link), and the entry itself is a real directory or a leaf link. Checked
41
- * again immediately before the removal starts, never only at enqueue time.
42
- */
43
- export declare function ownedStagedPath(projectsRoot: string, candidate: string): {
44
- kind: "directory" | "link";
45
- } | null;
46
- /**
47
- * Every owned staged checkout under `<projectsRoot>/<namespace>/<project>/.r5d-deleted/`
48
- * and every owned staged project under `<projectsRoot>/<namespace>/.r5d-deleted/`;
49
- * linked ancestors are not followed.
50
- */
51
- export declare function discoverStagedProjectCheckouts(projectsRoot: string): string[];
52
- /**
53
- * Delete a staged tree in a child process so a large recursive removal never
54
- * runs on the worker event loop, at the lowest CPU and (where supported) I/O
55
- * priority so live agents on the same volume keep their share. A leaf link is
56
- * unlinked in place; its target is never followed.
57
- */
58
- export declare function removeStagedProjectCheckout(stagedPath: string): Promise<void>;
59
- type Logger = (message: string) => void;
60
- /**
61
- * Collects staged checkouts one at a time, outside every workspace lease.
62
- * Entries are enqueued right after staging and by `sweep()` at worker start,
63
- * so a crash at any point converges on the next start. A failed removal is
64
- * logged and left for the next sweep.
65
- */
66
- export declare class ProjectCheckoutGarbageCollector {
67
- private readonly projectsRoot;
68
- private readonly remove;
69
- private readonly log;
70
- private readonly queued;
71
- private tail;
72
- private collectedCount;
73
- constructor(options: {
74
- projectsRoot: string;
75
- remove?: (stagedPath: string) => Promise<void>;
76
- log?: Logger;
77
- });
78
- /** Number of removals that have completed successfully. */
79
- get collected(): number;
80
- /** Resolves once everything queued so far has been attempted. */
81
- get idle(): Promise<void>;
82
- enqueue(stagedPath: string): void;
83
- /** Enqueue every staged checkout left behind by an earlier process. */
84
- sweep(): number;
85
- }
86
- export {};
@@ -1,84 +0,0 @@
1
- /**
2
- * Decides which part of a project's hidden mirror a periodic observation must
3
- * fetch, from the tokens the server advertises and the tokens the worker's
4
- * own mirror refs cover (both computed with `project-mirror-refs-token.ts`).
5
- *
6
- * Skipping is fail-open: any missing or mismatched information fetches.
7
- *
8
- * There is deliberately no timed backstop refetch for matching tokens. The
9
- * server recomputes every advertised token from the canonical repository on
10
- * disk on each heartbeat sweep, so a matching token is a fresh statement that
11
- * the fetch would transfer nothing, whoever moved the refs. The worker
12
- * records the tokens it covers from its own refs after every fetch and lease
13
- * push, with the same shared formula, so a skip can only be stale if the
14
- * canonical repository moved after the sweep that produced the advertisement
15
- * — which the next sweep corrects, exactly like a tip that lands mid-cycle —
16
- * or if the formula itself were wrong, which the shared module and its locked
17
- * vectors guard and a periodic blind fetch would only hide. A project or
18
- * mount the server advertises no token for fetches every cycle, as before
19
- * tokens existed.
20
- */
21
- /** Why a fetch runs. `fail_closed` is never decided here: reset and remediation observation bypasses the gate. */
22
- export type ProjectMirrorFetchReason = "skipping_disabled" | "no_advertised_token" | "never_fetched" | "token_changed" | "fail_closed";
23
- export type ProjectMirrorFetchDecision = {
24
- fetch: true;
25
- reason: ProjectMirrorFetchReason;
26
- } | {
27
- fetch: false;
28
- reason: "token_match";
29
- };
30
- export declare function projectMirrorFetchDecision(input: {
31
- advertisedToken: string | undefined;
32
- fetchedToken: string | undefined;
33
- skippingEnabled: boolean;
34
- }): ProjectMirrorFetchDecision;
35
- export type ProjectMirrorObservationFetchPlan =
36
- /** Fetch every canonical ref of the project, as observation always did before per-mount tokens. */
37
- {
38
- scope: "project";
39
- reason: ProjectMirrorFetchReason;
40
- }
41
- /** Fetch only the named mounts' branch heads and handoff refs. */
42
- | {
43
- scope: "mounts";
44
- mounts: Array<{
45
- branchName: string;
46
- reason: ProjectMirrorFetchReason;
47
- }>;
48
- }
49
- /** Every token the observation depends on matches; reuse the local refs. */
50
- | {
51
- scope: "none";
52
- };
53
- /**
54
- * Plan one project's observation fetch. With per-mount tokens advertised for
55
- * the project, each mount decides for itself and only changed mounts fetch;
56
- * without them (an older server) the project token decides for the whole
57
- * mirror.
58
- */
59
- export declare function planProjectMirrorObservationFetch(input: {
60
- branchNames: readonly string[];
61
- advertisedProjectToken: string | undefined;
62
- /** Per-mount tokens for this project, keyed by branch name; undefined when the server advertised none. */
63
- advertisedMountTokens: ReadonlyMap<string, string> | undefined;
64
- fetchedProjectToken: string | undefined;
65
- fetchedMountTokens: ReadonlyMap<string, string>;
66
- skippingEnabled: boolean;
67
- }): ProjectMirrorObservationFetchPlan;
68
- export type ProjectMirrorRefsTokensAdvertisement = {
69
- /** One token per project id. */
70
- projectTokens: Map<string, string>;
71
- /** Per-mount tokens keyed by project id then branch name; a project is present only when the server advertised mount tokens for it. */
72
- mountTokens: Map<string, Map<string, string>>;
73
- /** Current head of the user's hidden workspace repository, when advertised. */
74
- workspaceHead: string | undefined;
75
- };
76
- /**
77
- * Read a `project_mirror_refs_tokens` message. Older servers send only
78
- * `tokens`; malformed entries are dropped, which fails open into fetching.
79
- */
80
- export declare function parseProjectMirrorRefsTokensMessage(message: {
81
- tokens?: unknown;
82
- mountTokens?: unknown;
83
- workspaceHead?: unknown;
84
- }): ProjectMirrorRefsTokensAdvertisement;
@@ -1,53 +0,0 @@
1
- /** Canonical namespaces the token hashes; also the observation fetch's sources. */
2
- export declare const PROJECT_MIRROR_REFS_TOKEN_NAMESPACES: readonly ["refs/heads/", "refs/r5d/server-synced/"];
3
- /** Worker-local copy of a canonical `refs/heads/*` ref. */
4
- export declare const PROJECT_MIRROR_REF_PREFIX = "refs/r5d/mirror/";
5
- export declare const PROJECT_SERVER_SYNCED_REF_PREFIX = "refs/r5d/server-synced/";
6
- /** `git for-each-ref` format both sides list refs with; see parseProjectMirrorRefListing. */
7
- export declare const PROJECT_MIRROR_REF_LISTING_FORMAT = "--format=%(objectname) %(refname)";
8
- export type ProjectMirrorRef = {
9
- refname: string;
10
- objectName: string;
11
- };
12
- /** One checked-out project branch, identified by its durable incarnation id. */
13
- export type ProjectMirrorMount = {
14
- branchName: string;
15
- branchId: string;
16
- };
17
- export type ProjectMirrorRefsTokens = {
18
- /** Hash over every ref in the observed namespaces. */
19
- project: string;
20
- /** Hash over one mount's branch head plus its handoff refs, keyed by branch name. */
21
- mounts: Map<string, string>;
22
- };
23
- /**
24
- * Hash a ref listing into a mirror-refs token. Both sides sort here rather
25
- * than trusting git's listing order: renaming `refs/r5d/mirror/*` back to
26
- * `refs/heads/*` changes sort neighborhoods.
27
- */
28
- export declare function hashProjectMirrorRefs(refs: readonly ProjectMirrorRef[]): string;
29
- /**
30
- * Parse `git for-each-ref` output produced with
31
- * PROJECT_MIRROR_REF_LISTING_FORMAT. Malformed rows throw rather than being
32
- * dropped: a caller that cannot trust its listing must not produce a token.
33
- * With `namespaces`, rows outside them throw too.
34
- */
35
- export declare function parseProjectMirrorRefListing(output: string, options?: {
36
- namespaces?: readonly string[];
37
- }): ProjectMirrorRef[];
38
- /**
39
- * Rename locally fetched mirror refs into the namespaces the server hashes.
40
- * Rows outside the two observed namespaces are dropped; the caller lists only
41
- * those namespaces, so a dropped row means an unexpected listing, and dropping
42
- * it can only make tokens differ — which fails open into a fetch.
43
- */
44
- export declare function canonicalizeLocalProjectMirrorRefs(refs: readonly ProjectMirrorRef[]): ProjectMirrorRef[];
45
- /** The canonical refs one mount's token covers: its branch head and its server-synced handoff refs. */
46
- export declare function projectMirrorMountRefs(refs: readonly ProjectMirrorRef[], mount: ProjectMirrorMount): ProjectMirrorRef[];
47
- /**
48
- * Compute the project token and one token per mount from one canonical ref
49
- * listing. A mount's token is the project formula applied to the mount's own
50
- * refs, so a mount whose branch is the only ref of its project has the same
51
- * token as the project.
52
- */
53
- export declare function projectMirrorRefsTokens(refs: readonly ProjectMirrorRef[], mounts: readonly ProjectMirrorMount[]): ProjectMirrorRefsTokens;