@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
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { type WorkspaceIdentity } from "./contracts";
3
+ export declare const SessionArtifactChunk: z.ZodObject<{
4
+ method: z.ZodLiteral<"materializeArtifact">;
5
+ id: z.ZodString;
6
+ filename: z.ZodString;
7
+ sha256: z.ZodString;
8
+ size: z.ZodNumber;
9
+ offset: z.ZodNumber;
10
+ base64: z.ZodString;
11
+ seal: z.ZodBoolean;
12
+ }, z.core.$strict>;
13
+ export type SessionArtifactChunk = z.infer<typeof SessionArtifactChunk>;
14
+ export declare const RESERVED_ARTIFACT_ENV: readonly ["R5D_ROOT", "R5D_SESSION_ID"];
15
+ /** Session artifacts never join repository snapshots or another session's env. */
16
+ export declare class SessionArtifactStore {
17
+ readonly authorityRoot: string;
18
+ constructor(authorityRoot: string);
19
+ environment(identity: WorkspaceIdentity): Promise<{
20
+ R5D_ROOT: string;
21
+ R5D_SESSION_ID: string;
22
+ }>;
23
+ materialize(identity: WorkspaceIdentity, input: SessionArtifactChunk): Promise<{
24
+ filename: string;
25
+ sha256: string;
26
+ size: number;
27
+ nextOffset: number;
28
+ complete: boolean;
29
+ }>;
30
+ }
@@ -0,0 +1,338 @@
1
+ import { OperationEnvelope } from "@ricsam/r5d-api/runtime-protocol";
2
+ import { type PollResult, type RunIdentity } from "../protocol";
3
+ import { WorkspaceConfig, type ExecutorRoute, type WorkspaceIdentity, type ApprovedWorkbench as ApprovedWorkbenchInput } from "./contracts";
4
+ import { SessionArtifactChunk } from "./artifacts";
5
+ import { WorkspaceFileWrite } from "./file-write";
6
+ import { WorkspaceStorageClient } from "./storage-client";
7
+ export interface WorkspaceAuthorityOptions {
8
+ config: WorkspaceConfig;
9
+ storage: (identity: WorkspaceIdentity) => Promise<WorkspaceStorageClient>;
10
+ executor: (identity: WorkspaceIdentity) => Promise<ExecutorRoute>;
11
+ /** Trusted catalog authorization; never a client-supplied filesystem path. */
12
+ resolveWorkbench?: (identity: WorkspaceIdentity) => Promise<ApprovedWorkbenchInput | null>;
13
+ }
14
+ /** Independent resource owner. Gate and workbench never live in replaceable adapters/gateways.
15
+ * Private root is exclusively owned; a crash leaves lock+intent for explicit maintenance.
16
+ */
17
+ export declare class WorkspaceAuthority {
18
+ private readonly options;
19
+ readonly config: ReturnType<typeof WorkspaceConfig.parse>;
20
+ private readonly benches;
21
+ private readonly queues;
22
+ private readonly lockId;
23
+ private closing;
24
+ private closed;
25
+ private closeTask?;
26
+ private readonly actions;
27
+ private pending;
28
+ private constructor();
29
+ static open(options: WorkspaceAuthorityOptions): Promise<WorkspaceAuthority>;
30
+ private readonly registrations;
31
+ private bench;
32
+ private readonly hydrations;
33
+ ensureHydrated(identity: WorkspaceIdentity): Promise<void>;
34
+ readFile(identity: WorkspaceIdentity, file: string): Promise<{
35
+ path: string;
36
+ content: string;
37
+ bytes: number;
38
+ }>;
39
+ processes(identity: WorkspaceIdentity): Promise<{
40
+ workerLabel: string;
41
+ operationId: string;
42
+ userId: string;
43
+ sessionId: string | null;
44
+ payloadHash: string;
45
+ state: "accepted" | "running" | "completed" | "cancelled" | "unknown";
46
+ pid: number | null;
47
+ pty: boolean;
48
+ lane: import("zod").infer<typeof import("../protocol").Lane>;
49
+ stdoutBytes: number;
50
+ stderrBytes: number;
51
+ stdinClosed: boolean;
52
+ exitCode: number | null;
53
+ signal: string | null;
54
+ reason: string | null;
55
+ artifactEnvironment?: boolean;
56
+ mutating: boolean;
57
+ argv?: string[];
58
+ cwd?: string;
59
+ startedAt?: string;
60
+ updatedAt?: string;
61
+ completedAt?: string;
62
+ }[]>;
63
+ fileHistoryDates(identity: WorkspaceIdentity, file: string): Promise<{
64
+ createdAt: string | null;
65
+ updatedAt: string;
66
+ }>;
67
+ /** Bounded file browsing through the same catalog-authorized workbench as tools. */
68
+ inspectFiles(identity: WorkspaceIdentity, command: {
69
+ method: "directory" | "raw";
70
+ path: string;
71
+ }): Promise<{
72
+ path: string;
73
+ base64: string;
74
+ size: number;
75
+ modifiedAt: string;
76
+ directory?: undefined;
77
+ entries?: undefined;
78
+ } | {
79
+ directory: string;
80
+ entries: {
81
+ name: string;
82
+ path: string;
83
+ type: string;
84
+ size: number | null;
85
+ modifiedAt: string;
86
+ }[];
87
+ path?: undefined;
88
+ base64?: undefined;
89
+ size?: undefined;
90
+ modifiedAt?: undefined;
91
+ }>;
92
+ inspectGit(identity: WorkspaceIdentity, command: {
93
+ method: "status" | "diff" | "history" | "fileDiff";
94
+ path?: string;
95
+ base?: string;
96
+ }): Promise<{
97
+ head: string;
98
+ treeHash: string;
99
+ commits: {
100
+ hash: string | undefined;
101
+ parents: string[];
102
+ subject: string | undefined;
103
+ authorName: string | undefined;
104
+ authorEmail: string | undefined;
105
+ authoredAt: string | undefined;
106
+ committedAt: string | undefined;
107
+ }[];
108
+ original?: undefined;
109
+ modified?: undefined;
110
+ } | {
111
+ head: string;
112
+ treeHash: string;
113
+ original: {
114
+ kind: string;
115
+ objectType: null;
116
+ mode: null;
117
+ byteSize: null;
118
+ content: null;
119
+ } | {
120
+ kind: string;
121
+ objectType: string | undefined;
122
+ mode: string | undefined;
123
+ byteSize: null;
124
+ content: null;
125
+ } | {
126
+ kind: string;
127
+ objectType: string;
128
+ mode: string | undefined;
129
+ byteSize: number;
130
+ content: string | null;
131
+ };
132
+ modified: {
133
+ kind: string;
134
+ objectType: null;
135
+ mode: null;
136
+ byteSize: null;
137
+ content: null;
138
+ } | {
139
+ kind: string;
140
+ objectType: string | undefined;
141
+ mode: string | undefined;
142
+ byteSize: null;
143
+ content: null;
144
+ } | {
145
+ kind: string;
146
+ objectType: string;
147
+ mode: string | undefined;
148
+ byteSize: number;
149
+ content: string | null;
150
+ };
151
+ commits?: undefined;
152
+ } | {
153
+ patch?: string | undefined;
154
+ head: string;
155
+ treeHash: string;
156
+ files: {
157
+ path: string;
158
+ status: string;
159
+ additions: number | null;
160
+ deletions: number | null;
161
+ binary: boolean;
162
+ }[];
163
+ commits?: undefined;
164
+ original?: undefined;
165
+ modified?: undefined;
166
+ }>;
167
+ private save;
168
+ private owned;
169
+ private serial;
170
+ private route;
171
+ private storage;
172
+ private refresh;
173
+ private idle;
174
+ status(identity: WorkspaceIdentity): Promise<{
175
+ files: string[] | null;
176
+ initialized: boolean;
177
+ head: string | null;
178
+ publishedMetadata?: {
179
+ head: string;
180
+ indexHash: string;
181
+ };
182
+ blocked: null | {
183
+ code: string;
184
+ message: string;
185
+ operationId?: string;
186
+ commit?: string;
187
+ };
188
+ runs: Record<string, {
189
+ sessionId?: string;
190
+ artifactEnvironment?: boolean;
191
+ mutating: boolean;
192
+ payloadHash: string;
193
+ state: string;
194
+ argv?: string[];
195
+ cwd?: string;
196
+ startedAt?: string;
197
+ updatedAt?: string;
198
+ completedAt?: string;
199
+ }>;
200
+ workbench: {
201
+ id: string;
202
+ userId: string;
203
+ sessionId: string;
204
+ repositoryId: string;
205
+ branch: string;
206
+ cwd: string;
207
+ nonmutatingArgv: string[][];
208
+ sharedSessionId?: string | undefined;
209
+ };
210
+ }>;
211
+ private cleanRefreshBase;
212
+ /** No-argument hydration is initial-only. Explicit expectedBase permits a clean,
213
+ * idle workbench refresh; all replaced source/index/ref bytes are retained. */
214
+ hydrate(identity: WorkspaceIdentity, expectedBase?: string): Promise<{
215
+ head: string;
216
+ }>;
217
+ private hydrateIdle;
218
+ private assertFreshAccountWorkbench;
219
+ private initializeAccountCanonical;
220
+ private replaceFile;
221
+ /** Explicit trusted import boundary for the first isolated README seed, not legacy tree import. */
222
+ seedReadme(identity: WorkspaceIdentity, readme: string): Promise<{
223
+ head: string;
224
+ unchanged?: boolean;
225
+ }>;
226
+ private installGitPolicy;
227
+ /** Scoped receipt lookup never repeats a file effect; completion can clear its own crash marker. */
228
+ fileWriteResult(identity: WorkspaceIdentity, input: {
229
+ id: string;
230
+ }): Promise<{
231
+ state: "absent";
232
+ result?: undefined;
233
+ } | {
234
+ state: "completed";
235
+ result: any;
236
+ }>;
237
+ fileWrite(identity: WorkspaceIdentity, raw: WorkspaceFileWrite): Promise<{
238
+ intentHash?: string | undefined;
239
+ method: string;
240
+ id: string;
241
+ userId: string;
242
+ sessionId: string;
243
+ path: string;
244
+ sha256: string;
245
+ gitBlobHash: string;
246
+ size: number;
247
+ modifiedAt: string;
248
+ requestHash: string;
249
+ }>;
250
+ private productAction;
251
+ private validateGithubRemote;
252
+ /** Import only a selected exact GitHub tree into canonical storage; never execute its Git configuration. */
253
+ importRepository(identity: WorkspaceIdentity, input: {
254
+ id: string;
255
+ url: string;
256
+ token: string;
257
+ defaultBranch: string;
258
+ }): Promise<{
259
+ head: string;
260
+ workspaceHead: string;
261
+ }>;
262
+ cloneBranch(identity: WorkspaceIdentity, sourceIdentity: WorkspaceIdentity, input: {
263
+ id: string;
264
+ workingTree: "carry" | "clean";
265
+ }): Promise<any>;
266
+ private importCommit;
267
+ commit(identity: WorkspaceIdentity, input: {
268
+ id: string;
269
+ expectedHead?: string;
270
+ message: string;
271
+ }): Promise<{
272
+ treeHash: string;
273
+ head: string;
274
+ unchanged?: boolean;
275
+ }>;
276
+ push(identity: WorkspaceIdentity, input: {
277
+ id: string;
278
+ expectedHead?: string;
279
+ remote: {
280
+ url: string;
281
+ token: string;
282
+ branch: string;
283
+ expectedHead?: string | null;
284
+ };
285
+ }): Promise<{
286
+ head: string | null;
287
+ pushed: boolean;
288
+ }>;
289
+ archiveBranch(identity: WorkspaceIdentity, input: {
290
+ id: string;
291
+ }): Promise<{
292
+ removed: boolean;
293
+ receipt: unknown;
294
+ }>;
295
+ /** An explicit user reset retains the complete old tree/index before hydration. */
296
+ reset(identity: WorkspaceIdentity, input: {
297
+ id: string;
298
+ expectedHead?: string | null;
299
+ }): Promise<{
300
+ reset: boolean;
301
+ retained: boolean;
302
+ head: string;
303
+ }>;
304
+ publish(identity: WorkspaceIdentity): Promise<{
305
+ head: string;
306
+ unchanged?: boolean;
307
+ }>;
308
+ private publishIdle;
309
+ /** Read-only resolution of a lost publication ACK; no mutation retry, rebase, reset, or file overwrite. */
310
+ reconcilePublication(identity: WorkspaceIdentity): Promise<{
311
+ head: string;
312
+ }>;
313
+ /** Resolve mutable account settings once, before the first terminal admission.
314
+ * A lost ACK must recover the same command and credential generations even if
315
+ * settings change before redelivery or the workspace service restarts. */
316
+ startWithCredentials(identity: WorkspaceIdentity, input: OperationEnvelope, resolve: () => Promise<Array<{
317
+ id: string;
318
+ generation: number;
319
+ }>>): Promise<import("..").RunReceipt>;
320
+ materializeArtifact(identity: WorkspaceIdentity, input: SessionArtifactChunk): Promise<{
321
+ filename: string;
322
+ sha256: string;
323
+ size: number;
324
+ nextOffset: number;
325
+ complete: boolean;
326
+ }>;
327
+ /** Default arbitrary shell is mutating. Exact trusted config approval is the sole exemption. */
328
+ start(identity: WorkspaceIdentity, input: OperationEnvelope): Promise<import("..").RunReceipt>;
329
+ private runRoute;
330
+ private action;
331
+ poll(identity: WorkspaceIdentity, run: RunIdentity, stdoutOffset?: number, stderrOffset?: number, maxBytes?: number): Promise<PollResult>;
332
+ private actionOutcome;
333
+ write(identity: WorkspaceIdentity, run: RunIdentity, actionId: string, data: string, eof?: boolean): Promise<import("..").ActionReceipt>;
334
+ resize(identity: WorkspaceIdentity, run: RunIdentity, actionId: string, cols: number, rows: number): Promise<import("..").ActionReceipt>;
335
+ cancel(identity: WorkspaceIdentity, run: RunIdentity, actionId: string): Promise<import("..").ActionReceipt>;
336
+ close(): Promise<void>;
337
+ private finishClose;
338
+ }
@@ -0,0 +1,86 @@
1
+ import { z } from "zod";
2
+ import type { HostExecutorClient } from "../client";
3
+ import type { OwnershipFence } from "@ricsam/r5d-api/runtime-protocol";
4
+ export declare const ApprovedWorkbench: z.ZodObject<{
5
+ id: z.ZodString;
6
+ userId: z.ZodString;
7
+ sessionId: z.ZodString;
8
+ sharedSessionId: z.ZodOptional<z.ZodString>;
9
+ repositoryId: z.ZodString;
10
+ branch: z.ZodString;
11
+ cwd: z.ZodString;
12
+ nonmutatingArgv: z.ZodDefault<z.ZodArray<z.ZodArray<z.ZodString>>>;
13
+ }, z.core.$strict>;
14
+ export type ApprovedWorkbench = z.input<typeof ApprovedWorkbench>;
15
+ export declare const WorkspaceConfig: z.ZodObject<{
16
+ installationId: z.ZodString;
17
+ root: z.ZodString;
18
+ workbenches: z.ZodArray<z.ZodObject<{
19
+ id: z.ZodString;
20
+ userId: z.ZodString;
21
+ sessionId: z.ZodString;
22
+ sharedSessionId: z.ZodOptional<z.ZodString>;
23
+ repositoryId: z.ZodString;
24
+ branch: z.ZodString;
25
+ cwd: z.ZodString;
26
+ nonmutatingArgv: z.ZodDefault<z.ZodArray<z.ZodArray<z.ZodString>>>;
27
+ }, z.core.$strict>>;
28
+ dynamicWorkbenches: z.ZodOptional<z.ZodBoolean>;
29
+ }, z.core.$strict>;
30
+ export type WorkspaceConfig = z.input<typeof WorkspaceConfig>;
31
+ export type ExecutorRoute = {
32
+ client: Pick<HostExecutorClient, "start" | "poll" | "write" | "cancel"> & Partial<Pick<HostExecutorClient, "resize">>;
33
+ workerFence: OwnershipFence;
34
+ };
35
+ export type WorkspaceIdentity = {
36
+ userId: string;
37
+ sessionId: string;
38
+ };
39
+ export declare class WorkspaceError extends Error {
40
+ readonly code: string;
41
+ readonly rejectedBeforeAdmission: boolean;
42
+ constructor(code: string, message: string, rejectedBeforeAdmission?: boolean);
43
+ }
44
+ /** Constructed only by the authority before it admits publication work. */
45
+ export declare class WorkspacePublicationNotAdmitted extends WorkspaceError {
46
+ }
47
+ export type WorkspacePublishResult = {
48
+ head: string;
49
+ unchanged?: boolean;
50
+ rejectedBeforeAdmission?: never;
51
+ } | {
52
+ state: "rejected";
53
+ code: "capacity_busy";
54
+ rejectedBeforeAdmission: true;
55
+ message: string;
56
+ head?: never;
57
+ unchanged?: never;
58
+ };
59
+ export type WorkspaceState = {
60
+ initialized: boolean;
61
+ head: string | null;
62
+ /** Unchanged checkout metadata retained by automatic canonical publication. */
63
+ publishedMetadata?: {
64
+ head: string;
65
+ indexHash: string;
66
+ };
67
+ blocked: null | {
68
+ code: string;
69
+ message: string;
70
+ operationId?: string;
71
+ commit?: string;
72
+ };
73
+ runs: Record<string, {
74
+ sessionId?: string;
75
+ artifactEnvironment?: boolean;
76
+ mutating: boolean;
77
+ payloadHash: string;
78
+ state: string;
79
+ argv?: string[];
80
+ cwd?: string;
81
+ startedAt?: string;
82
+ updatedAt?: string;
83
+ completedAt?: string;
84
+ }>;
85
+ };
86
+ export declare const DEFAULT_WORKSPACE_IGNORE = "# Required destination workbench exclusions; keep these rules effective.\n.env\n.env.*\n!.env.example\nnode_modules/\n.r5d/\n.r5d-next/\n.ssh/\n.kube/\nsecrets/\ncredentials/\n.next/\ndist/\nbuild/\ncoverage/\n.cache/\n*.pem\n*.key\n";
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ export declare const WorkspaceFileWrite: z.ZodObject<{
3
+ method: z.ZodLiteral<"fileWrite">;
4
+ id: z.ZodString;
5
+ path: z.ZodString;
6
+ expectedSha256: z.ZodNullable<z.ZodString>;
7
+ intentHash: z.ZodOptional<z.ZodString>;
8
+ base64: z.ZodString;
9
+ }, z.core.$strict>;
10
+ export type WorkspaceFileWrite = z.infer<typeof WorkspaceFileWrite>;
11
+ export declare const WorkspaceFileWriteLookup: z.ZodObject<{
12
+ method: z.ZodLiteral<"fileWriteResult">;
13
+ id: z.ZodString;
14
+ }, z.core.$strict>;
@@ -0,0 +1,21 @@
1
+ export declare const sha256: (bytes: Buffer | string) => string;
2
+ export declare function privateRoot(root: string, installationId: string): Promise<void>;
3
+ export declare function noSymlinkAncestors(file: string): Promise<void>;
4
+ export declare function readRegular(file: string, limit?: number): Promise<Buffer>;
5
+ export declare function durableJson(file: string, value: unknown): Promise<void>;
6
+ /** All Git operates in authority-created repos; NEVER workbench .git/config/index.
7
+ * hash-object --no-filters and update-index --index-info replace git add/checkout.
8
+ */
9
+ export declare function git(cwd: string, args: string[], input?: Buffer | string, indexFile?: string, transport?: {
10
+ token: string;
11
+ }): Promise<Buffer>;
12
+ export declare function sourcePath(file: string): void;
13
+ export declare function sourceBytes(bytes: Buffer, file?: string): void;
14
+ export type TreeEntry = {
15
+ file: string;
16
+ mode: string;
17
+ oid: string;
18
+ };
19
+ export declare function selectedTree(repo: string, commit: string): Promise<TreeEntry[]>;
20
+ export declare function verifyIgnore(repo: string, cwd: string): Promise<void>;
21
+ export declare function snapshotTree(repo: string, cwd: string, canonicalHead?: string | null): Promise<string>;
@@ -0,0 +1,9 @@
1
+ /** Byte-bounded streaming reader. The deadline covers reading only, never downstream effects.
2
+ * Cancellation is best effort and is deliberately NOT awaited: a poisoned underlying
3
+ * source may return a cancellation promise that never settles.
4
+ */
5
+ export declare class BodyReadError extends Error {
6
+ readonly code: "body_too_large" | "body_timeout" | "body_missing";
7
+ constructor(code: "body_too_large" | "body_timeout" | "body_missing");
8
+ }
9
+ export declare function readBoundedBody(body: ReadableStream<Uint8Array> | null, limit: number, timeoutMs: number): Promise<Buffer>;
@@ -0,0 +1,23 @@
1
+ import { OwnershipFence } from "@ricsam/r5d-api/runtime-protocol";
2
+ import { StorageRequest, type StorageMutation } from "./storage-wire";
3
+ export type StorageTransport = (request: StorageRequest) => Promise<unknown>;
4
+ type MutationInput = StorageMutation extends infer T ? (T extends StorageMutation ? Omit<T, "fence" | "callerFence"> : never) : never;
5
+ /** The token provider must issue installation/user/subject/exact storageCallerScope grants.
6
+ * HTTPS deployments inject a fetch implementation with private mTLS, never disable verification.
7
+ * Transport failures are unknown delivery. This client NEVER automatically retries a mutation. */
8
+ export declare class WorkspaceStorageClient {
9
+ readonly installationId: string;
10
+ private readonly transport;
11
+ private readonly caller;
12
+ constructor(installationId: string, transport: StorageTransport, caller: () => Promise<OwnershipFence>);
13
+ static http(options: {
14
+ installationId: string;
15
+ url: string;
16
+ token: (request: StorageRequest) => Promise<string>;
17
+ caller: () => Promise<OwnershipFence>;
18
+ fetch?: typeof fetch;
19
+ }): WorkspaceStorageClient;
20
+ read<T>(request: Exclude<StorageRequest, StorageMutation>): Promise<T>;
21
+ mutate<T>(input: MutationInput): Promise<T>;
22
+ }
23
+ export {};
@@ -0,0 +1,138 @@
1
+ import { z } from "zod";
2
+ /** Client-side v1 wire contract only. No server/control/catalog filesystem imports.
3
+ * Keep matched to storage RPC; integration tests exercise the real authenticated parser.
4
+ */
5
+ export declare const STORAGE_LIMITS: {
6
+ readonly chunkBytes: number;
7
+ readonly blobBytes: number;
8
+ readonly requestBytes: number;
9
+ readonly treeEntries: 10000;
10
+ };
11
+ export declare const StorageId: z.ZodString;
12
+ export declare const GitOid: z.ZodString;
13
+ export declare const BranchName: z.ZodString;
14
+ export declare const StorageRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
+ method: z.ZodLiteral<"hello">;
16
+ }, z.core.$strict>, z.ZodObject<{
17
+ method: z.ZodLiteral<"repository.get">;
18
+ repositoryId: z.ZodString;
19
+ branch: z.ZodString;
20
+ }, z.core.$strict>, z.ZodObject<{
21
+ method: z.ZodLiteral<"repository.bundle">;
22
+ repositoryId: z.ZodString;
23
+ snapshot: z.ZodNullable<z.ZodString>;
24
+ offset: z.ZodNumber;
25
+ limit: z.ZodNumber;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ method: z.ZodLiteral<"operation.get">;
28
+ lookupId: z.ZodString;
29
+ }, z.core.$strict>, z.ZodObject<{
30
+ repositoryId: z.ZodString;
31
+ operationId: z.ZodString;
32
+ fence: z.ZodObject<{
33
+ installationId: z.ZodString;
34
+ resourceType: z.ZodString;
35
+ resourceId: z.ZodString;
36
+ ownerId: z.ZodString;
37
+ epoch: z.ZodNumber;
38
+ }, z.core.$strict>;
39
+ callerFence: z.ZodObject<{
40
+ installationId: z.ZodString;
41
+ resourceType: z.ZodString;
42
+ resourceId: z.ZodString;
43
+ ownerId: z.ZodString;
44
+ epoch: z.ZodNumber;
45
+ }, z.core.$strict>;
46
+ method: z.ZodLiteral<"repository.provision">;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ repositoryId: z.ZodString;
49
+ operationId: z.ZodString;
50
+ fence: z.ZodObject<{
51
+ installationId: z.ZodString;
52
+ resourceType: z.ZodString;
53
+ resourceId: z.ZodString;
54
+ ownerId: z.ZodString;
55
+ epoch: z.ZodNumber;
56
+ }, z.core.$strict>;
57
+ callerFence: z.ZodObject<{
58
+ installationId: z.ZodString;
59
+ resourceType: z.ZodString;
60
+ resourceId: z.ZodString;
61
+ ownerId: z.ZodString;
62
+ epoch: z.ZodNumber;
63
+ }, z.core.$strict>;
64
+ method: z.ZodLiteral<"repository.initializeAccount">;
65
+ }, z.core.$strict>, z.ZodObject<{
66
+ repositoryId: z.ZodString;
67
+ branch: z.ZodString;
68
+ expectedHead: z.ZodNullable<z.ZodString>;
69
+ operationId: z.ZodString;
70
+ fence: z.ZodObject<{
71
+ installationId: z.ZodString;
72
+ resourceType: z.ZodString;
73
+ resourceId: z.ZodString;
74
+ ownerId: z.ZodString;
75
+ epoch: z.ZodNumber;
76
+ }, z.core.$strict>;
77
+ callerFence: z.ZodObject<{
78
+ installationId: z.ZodString;
79
+ resourceType: z.ZodString;
80
+ resourceId: z.ZodString;
81
+ ownerId: z.ZodString;
82
+ epoch: z.ZodNumber;
83
+ }, z.core.$strict>;
84
+ method: z.ZodLiteral<"repository.archive">;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ repositoryId: z.ZodString;
87
+ branch: z.ZodString;
88
+ expectedHead: z.ZodNullable<z.ZodString>;
89
+ commit: z.ZodString;
90
+ bundleId: z.ZodString;
91
+ operationId: z.ZodString;
92
+ fence: z.ZodObject<{
93
+ installationId: z.ZodString;
94
+ resourceType: z.ZodString;
95
+ resourceId: z.ZodString;
96
+ ownerId: z.ZodString;
97
+ epoch: z.ZodNumber;
98
+ }, z.core.$strict>;
99
+ callerFence: z.ZodObject<{
100
+ installationId: z.ZodString;
101
+ resourceType: z.ZodString;
102
+ resourceId: z.ZodString;
103
+ ownerId: z.ZodString;
104
+ epoch: z.ZodNumber;
105
+ }, z.core.$strict>;
106
+ method: z.ZodLiteral<"repository.publish">;
107
+ }, z.core.$strict>, z.ZodObject<{
108
+ blobId: z.ZodString;
109
+ kind: z.ZodEnum<{
110
+ blob: "blob";
111
+ artifact: "artifact";
112
+ log: "log";
113
+ }>;
114
+ offset: z.ZodNumber;
115
+ data: z.ZodString;
116
+ seal: z.ZodBoolean;
117
+ operationId: z.ZodString;
118
+ fence: z.ZodObject<{
119
+ installationId: z.ZodString;
120
+ resourceType: z.ZodString;
121
+ resourceId: z.ZodString;
122
+ ownerId: z.ZodString;
123
+ epoch: z.ZodNumber;
124
+ }, z.core.$strict>;
125
+ callerFence: z.ZodObject<{
126
+ installationId: z.ZodString;
127
+ resourceType: z.ZodString;
128
+ resourceId: z.ZodString;
129
+ ownerId: z.ZodString;
130
+ epoch: z.ZodNumber;
131
+ }, z.core.$strict>;
132
+ method: z.ZodLiteral<"blob.append">;
133
+ }, z.core.$strict>], "method">;
134
+ export type StorageRequest = z.infer<typeof StorageRequest>;
135
+ export type StorageMutation = Extract<StorageRequest, {
136
+ operationId: string;
137
+ }>;
138
+ export declare function safeTreePath(value: string): void;