@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
@@ -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;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.136",
3
+ "version": "0.0.138",
4
4
  "type": "module",
5
- "main": "./dist/cjs/main.cjs",
5
+ "main": "./dist/mjs/main.mjs",
6
6
  "module": "./dist/mjs/main.mjs",
7
7
  "types": "./dist/types/main.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/types/main.d.ts",
11
11
  "import": "./dist/mjs/main.mjs",
12
- "require": "./dist/cjs/main.cjs"
12
+ "default": "./dist/mjs/main.mjs"
13
13
  }
14
14
  },
15
15
  "repository": {
@@ -18,11 +18,13 @@
18
18
  "directory": "packages/r5d-worker"
19
19
  },
20
20
  "bin": {
21
- "r5d-worker": "dist/cjs/main.cjs"
21
+ "r5d-worker": "dist/mjs/main.mjs"
22
22
  },
23
23
  "dependencies": {
24
- "@ricsam/r5d-api": "^0.0.136",
25
- "node-pty": "^1.1.0",
24
+ "@ricsam/r5d-api": "^0.0.138",
25
+ "@ricsam/r5dctl": "0.0.138",
26
+ "node-pty": "1.1.0",
27
+ "zod": "^4.1.13",
26
28
  "picomatch": "^4.0.3"
27
29
  },
28
30
  "files": [
@@ -1,303 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var atomic_rename_exports = {};
30
- __export(atomic_rename_exports, {
31
- AtomicRenameError: () => AtomicRenameError,
32
- atomicRenamePrimitivesFor: () => atomicRenamePrimitivesFor,
33
- atomicRenameSupport: () => atomicRenameSupport,
34
- exchangePaths: () => exchangePaths,
35
- isAtomicRenameUnsupported: () => isAtomicRenameUnsupported,
36
- overrideAtomicRenameSupportForTests: () => overrideAtomicRenameSupportForTests,
37
- probeAtomicRenameSupport: () => probeAtomicRenameSupport,
38
- renameNoReplace: () => renameNoReplace,
39
- resetAtomicRenameProbesForTests: () => resetAtomicRenameProbesForTests
40
- });
41
- module.exports = __toCommonJS(atomic_rename_exports);
42
- var import_node_fs = __toESM(require("node:fs"), 1);
43
- var import_node_os = __toESM(require("node:os"), 1);
44
- var import_node_path = __toESM(require("node:path"), 1);
45
- var import_node_crypto = require("node:crypto");
46
- class AtomicRenameError extends Error {
47
- constructor(syscall, code, errno, path2, dest) {
48
- super(`${code}: ${syscall} failed, ${path2} -> ${dest}`);
49
- this.syscall = syscall;
50
- this.code = code;
51
- this.errno = errno;
52
- this.path = path2;
53
- this.dest = dest;
54
- this.name = "AtomicRenameError";
55
- }
56
- syscall;
57
- code;
58
- errno;
59
- path;
60
- dest;
61
- }
62
- const UNSUPPORTED_CODES = /* @__PURE__ */ new Set(["EINVAL", "ENOSYS", "ENOTSUP", "EOPNOTSUPP", "EPERM"]);
63
- function isAtomicRenameUnsupported(error) {
64
- return error instanceof AtomicRenameError && UNSUPPORTED_CODES.has(error.code);
65
- }
66
- const LINUX_AT_FDCWD = -100;
67
- const LINUX_RENAME_NOREPLACE = 1;
68
- const LINUX_RENAME_EXCHANGE = 2;
69
- const DARWIN_RENAME_SWAP = 2;
70
- const DARWIN_RENAME_EXCL = 4;
71
- const LINUX_SYS_RENAMEAT2 = { x64: 316, arm64: 276 };
72
- const PROBE_PREFIX = ".r5d-atomic-rename-probe-";
73
- let loaded = null;
74
- let override = null;
75
- const errnoNames = /* @__PURE__ */ new Map();
76
- for (const [name, value] of Object.entries(import_node_os.default.constants.errno)) errnoNames.set(value, name);
77
- function errnoCode(errno) {
78
- return errnoNames.get(errno) ?? `E${errno}`;
79
- }
80
- function cString(value) {
81
- return Buffer.from(`${value}\0`, "utf8");
82
- }
83
- function loadNative() {
84
- if (loaded) return loaded;
85
- loaded = { calls: null, detail: "not attempted" };
86
- try {
87
- const ffi = require("bun:ffi");
88
- const { dlopen, FFIType, ptr, read } = ffi;
89
- if (process.platform === "darwin") {
90
- const lib = dlopen("libSystem.B.dylib", {
91
- renamex_np: { args: [FFIType.ptr, FFIType.ptr, FFIType.u32], returns: FFIType.i32 },
92
- __error: { args: [], returns: FFIType.ptr }
93
- });
94
- loaded = {
95
- calls: {
96
- rename2: (from, to, flags) => {
97
- const fromBuffer = cString(from);
98
- const toBuffer = cString(to);
99
- return lib.symbols.renamex_np(ptr(fromBuffer), ptr(toBuffer), flags);
100
- },
101
- errno: () => read.i32(lib.symbols.__error(), 0),
102
- exchangeFlag: DARWIN_RENAME_SWAP,
103
- noReplaceFlag: DARWIN_RENAME_EXCL,
104
- backend: "renamex_np"
105
- }
106
- };
107
- return loaded;
108
- }
109
- if (process.platform === "linux") {
110
- const errnoLib = dlopen("libc.so.6", { __errno_location: { args: [], returns: FFIType.ptr } });
111
- const errno = () => read.i32(errnoLib.symbols.__errno_location(), 0);
112
- try {
113
- const lib = dlopen("libc.so.6", {
114
- renameat2: { args: [FFIType.i32, FFIType.ptr, FFIType.i32, FFIType.ptr, FFIType.u32], returns: FFIType.i32 }
115
- });
116
- loaded = {
117
- calls: {
118
- rename2: (from, to, flags) => {
119
- const fromBuffer = cString(from);
120
- const toBuffer = cString(to);
121
- return lib.symbols.renameat2(LINUX_AT_FDCWD, ptr(fromBuffer), LINUX_AT_FDCWD, ptr(toBuffer), flags);
122
- },
123
- errno,
124
- exchangeFlag: LINUX_RENAME_EXCHANGE,
125
- noReplaceFlag: LINUX_RENAME_NOREPLACE,
126
- backend: "renameat2"
127
- }
128
- };
129
- return loaded;
130
- } catch (error) {
131
- const number = LINUX_SYS_RENAMEAT2[process.arch];
132
- if (number === void 0) {
133
- loaded = { calls: null, detail: `renameat2 symbol unavailable and no syscall number for ${process.arch}: ${String(error)}` };
134
- return loaded;
135
- }
136
- const lib = dlopen("libc.so.6", {
137
- syscall: {
138
- args: [FFIType.i64, FFIType.i64, FFIType.i64, FFIType.i64, FFIType.i64, FFIType.i64],
139
- returns: FFIType.i64
140
- }
141
- });
142
- loaded = {
143
- calls: {
144
- rename2: (from, to, flags) => {
145
- const fromBuffer = cString(from);
146
- const toBuffer = cString(to);
147
- return Number(
148
- lib.symbols.syscall(number, LINUX_AT_FDCWD, Number(ptr(fromBuffer)), LINUX_AT_FDCWD, Number(ptr(toBuffer)), flags)
149
- );
150
- },
151
- errno,
152
- exchangeFlag: LINUX_RENAME_EXCHANGE,
153
- noReplaceFlag: LINUX_RENAME_NOREPLACE,
154
- backend: "syscall"
155
- }
156
- };
157
- return loaded;
158
- }
159
- }
160
- loaded = { calls: null, detail: `no atomic exchange primitive on ${process.platform}` };
161
- } catch (error) {
162
- loaded = { calls: null, detail: `bun:ffi unavailable: ${error instanceof Error ? error.message : String(error)}` };
163
- }
164
- return loaded;
165
- }
166
- function applyOverride(support) {
167
- if (override?.exchange !== void 0) support.exchange = override.exchange;
168
- if (override?.noReplace !== void 0) support.noReplace = override.noReplace;
169
- return support;
170
- }
171
- function atomicRenameSupport() {
172
- const native = loadNative();
173
- return applyOverride(
174
- native.calls ? { platform: process.platform, exchange: native.calls.backend, noReplace: native.calls.backend } : { platform: process.platform, exchange: "unavailable", noReplace: "link", detail: native.detail }
175
- );
176
- }
177
- function overrideAtomicRenameSupportForTests(value) {
178
- override = value;
179
- }
180
- function resetAtomicRenameProbesForTests() {
181
- probes.clear();
182
- }
183
- function call(native, syscall, from, to, flags) {
184
- if (native.rename2(from, to, flags) === 0) return;
185
- const errno = native.errno();
186
- throw new AtomicRenameError(syscall, errnoCode(errno), errno, from, to);
187
- }
188
- function exchangeWith(support, a, b) {
189
- const native = loadNative().calls;
190
- if (support.exchange === "unavailable" || !native) {
191
- throw new AtomicRenameError("exchange", "ENOSYS", import_node_os.default.constants.errno.ENOSYS, a, b);
192
- }
193
- call(native, support.exchange, a, b, native.exchangeFlag);
194
- }
195
- function renameNoReplaceWith(support, from, to) {
196
- const native = loadNative().calls;
197
- if (support.noReplace !== "link" && native) {
198
- call(native, support.noReplace, from, to, native.noReplaceFlag);
199
- return;
200
- }
201
- const source = import_node_fs.default.lstatSync(from);
202
- if (!source.isFile()) throw new AtomicRenameError("link", "ENOTSUP", import_node_os.default.constants.errno.ENOTSUP, from, to);
203
- try {
204
- import_node_fs.default.linkSync(from, to);
205
- } catch (error) {
206
- const code = error.code ?? "EIO";
207
- throw new AtomicRenameError("link", code, error.errno ?? 0, from, to);
208
- }
209
- import_node_fs.default.unlinkSync(from);
210
- }
211
- function exchangePaths(a, b) {
212
- exchangeWith(atomicRenameSupport(), a, b);
213
- }
214
- function renameNoReplace(from, to) {
215
- renameNoReplaceWith(atomicRenameSupport(), from, to);
216
- }
217
- const probes = /* @__PURE__ */ new Map();
218
- function withoutTemporaries(directory, run) {
219
- const token = (0, import_node_crypto.randomUUID)();
220
- const a = import_node_path.default.join(directory, `${PROBE_PREFIX}${token}-a`);
221
- const b = import_node_path.default.join(directory, `${PROBE_PREFIX}${token}-b`);
222
- try {
223
- run(a, b);
224
- } finally {
225
- import_node_fs.default.rmSync(a, { force: true });
226
- import_node_fs.default.rmSync(b, { force: true });
227
- }
228
- }
229
- function createProbeFile(filePath, content) {
230
- const descriptor = import_node_fs.default.openSync(filePath, import_node_fs.default.constants.O_WRONLY | import_node_fs.default.constants.O_CREAT | import_node_fs.default.constants.O_EXCL, 384);
231
- try {
232
- import_node_fs.default.writeSync(descriptor, content);
233
- return import_node_fs.default.fstatSync(descriptor);
234
- } finally {
235
- import_node_fs.default.closeSync(descriptor);
236
- }
237
- }
238
- function probeAtomicRenameSupport(directory) {
239
- const native = atomicRenameSupport();
240
- const dev = import_node_fs.default.lstatSync(directory).dev;
241
- const cached = probes.get(dev);
242
- if (cached) return applyOverride({ ...cached });
243
- const probed = { ...native };
244
- if (native.exchange !== "unavailable") {
245
- withoutTemporaries(directory, (a, b) => {
246
- const statA = createProbeFile(a, "a");
247
- const statB = createProbeFile(b, "b");
248
- let swapped = false;
249
- let detail;
250
- try {
251
- exchangeWith(native, a, b);
252
- const afterA = import_node_fs.default.lstatSync(a);
253
- const afterB = import_node_fs.default.lstatSync(b);
254
- swapped = afterA.ino === statB.ino && afterB.ino === statA.ino;
255
- if (!swapped) detail = `exchange flag ignored by the filesystem holding ${directory}`;
256
- } catch (error) {
257
- detail = `exchange rejected by the filesystem holding ${directory}: ${error instanceof Error ? error.message : String(error)}`;
258
- }
259
- if (!swapped) {
260
- probed.exchange = "unavailable";
261
- probed.detail = detail;
262
- }
263
- });
264
- }
265
- if (native.noReplace !== "link") {
266
- withoutTemporaries(directory, (a, b) => {
267
- createProbeFile(a, "a");
268
- createProbeFile(b, "b");
269
- let refused = false;
270
- try {
271
- renameNoReplaceWith(native, a, b);
272
- } catch (error) {
273
- refused = error instanceof AtomicRenameError && error.code === "EEXIST";
274
- }
275
- if (!refused) {
276
- probed.noReplace = "link";
277
- probed.detail = `${probed.detail ? `${probed.detail}; ` : ""}no-replace flag ignored by the filesystem holding ${directory}`;
278
- }
279
- });
280
- }
281
- probes.set(dev, probed);
282
- return applyOverride({ ...probed });
283
- }
284
- function atomicRenamePrimitivesFor(directory) {
285
- const support = probeAtomicRenameSupport(directory);
286
- return {
287
- support,
288
- exchange: (a, b) => exchangeWith(support, a, b),
289
- renameNoReplace: (from, to) => renameNoReplaceWith(support, from, to)
290
- };
291
- }
292
- // Annotate the CommonJS export names for ESM import in node:
293
- 0 && (module.exports = {
294
- AtomicRenameError,
295
- atomicRenamePrimitivesFor,
296
- atomicRenameSupport,
297
- exchangePaths,
298
- isAtomicRenameUnsupported,
299
- overrideAtomicRenameSupportForTests,
300
- probeAtomicRenameSupport,
301
- renameNoReplace,
302
- resetAtomicRenameProbesForTests
303
- });
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var browser_upload_exports = {};
30
- __export(browser_upload_exports, {
31
- readBrowserUploadChunk: () => readBrowserUploadChunk
32
- });
33
- module.exports = __toCommonJS(browser_upload_exports);
34
- var import_promises = __toESM(require("node:fs/promises"), 1);
35
- var import_node_fs = require("node:fs");
36
- var import_node_os = __toESM(require("node:os"), 1);
37
- var import_node_path = __toESM(require("node:path"), 1);
38
- var import_browser_upload = require("@ricsam/r5d-api/browser-upload");
39
- async function readBrowserUploadChunk(input, context) {
40
- if (typeof input.filePath !== "string" || !input.filePath.trim() || input.filePath.includes("\0"))
41
- throw new Error("Upload requires a file path.");
42
- if (!Number.isSafeInteger(input.offset) || input.offset < 0) throw new Error("Invalid upload read offset.");
43
- if (input.offset > 0 && !input.version) throw new Error("Upload continuation requires a file version.");
44
- const expanded = input.filePath.replace(/\$\{R5D_ROOT\}|\$R5D_ROOT\b/g, () => context.rootDir).replace(/\$\{R5D_SESSION_ID\}|\$R5D_SESSION_ID\b/g, () => context.sessionId).replace(/^~\//, () => `${import_node_os.default.homedir()}/`);
45
- const filePath = import_node_path.default.resolve(context.cwd, expanded);
46
- const handle = await import_promises.default.open(filePath, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
47
- try {
48
- const stat = await handle.stat({ bigint: true });
49
- if (!stat.isFile()) throw new Error(`Upload source is not a regular file: ${input.filePath}`);
50
- const metadata = (0, import_browser_upload.validateUploadFile)({ filename: import_node_path.default.basename(filePath), size: Number(stat.size) });
51
- const versionOf = (s) => `${s.dev}:${s.ino}:${s.size}:${s.mtimeNs}:${s.ctimeNs}`;
52
- const version = versionOf(stat);
53
- if (input.version !== void 0 && input.version !== version)
54
- throw new Error(`Upload source changed while being transferred: ${input.filePath}`);
55
- if (input.offset > metadata.size) throw new Error("Upload offset is past the end of the file.");
56
- const bytes = Buffer.alloc(input.metadataOnly === true ? 0 : Math.min(import_browser_upload.BROWSER_UPLOAD_CHUNK_BYTES, metadata.size - input.offset));
57
- let read = 0;
58
- while (read < bytes.length) {
59
- const { bytesRead } = await handle.read(bytes, read, bytes.length - read, input.offset + read);
60
- if (!bytesRead) throw new Error(`Upload source was truncated: ${input.filePath}`);
61
- read += bytesRead;
62
- }
63
- if (versionOf(await handle.stat({ bigint: true })) !== version)
64
- throw new Error(`Upload source changed while being read: ${input.filePath}`);
65
- return { type: "browser_upload_read", ...metadata, version, offset: input.offset, base64: bytes.toString("base64") };
66
- } finally {
67
- await handle.close();
68
- }
69
- }
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- readBrowserUploadChunk
73
- });
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var cli_update_exports = {};
20
- __export(cli_update_exports, {
21
- getManualCliUpdateCommand: () => getManualCliUpdateCommand,
22
- installCliUpdate: () => installCliUpdate,
23
- parseCliVersion: () => parseCliVersion,
24
- readInstalledCliVersion: () => readInstalledCliVersion,
25
- runCommand: () => runCommand
26
- });
27
- module.exports = __toCommonJS(cli_update_exports);
28
- const UPDATE_OUTPUT_LIMIT = 8e3;
29
- function collectOutput(value) {
30
- if (!value || typeof value === "number") {
31
- return Promise.resolve("");
32
- }
33
- return new Response(value).text();
34
- }
35
- async function runCommand(argv) {
36
- const child = Bun.spawn(argv, {
37
- stdout: "pipe",
38
- stderr: "pipe",
39
- env: process.env
40
- });
41
- const [stdout, stderr, exitCode] = await Promise.all([collectOutput(child.stdout), collectOutput(child.stderr), child.exited]);
42
- return { exitCode, stdout, stderr };
43
- }
44
- function parseCliVersion(cliName, output) {
45
- const escapedName = cliName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
46
- const match = output.trim().match(new RegExp(`(?:^|\\n)${escapedName}\\s+(\\S+)`));
47
- return match?.[1]?.trim() || null;
48
- }
49
- function readInstalledCliVersion(cliName) {
50
- try {
51
- const result = Bun.spawnSync([cliName, "--version"], {
52
- stdout: "pipe",
53
- stderr: "pipe",
54
- env: process.env
55
- });
56
- if (result.exitCode !== 0) {
57
- return null;
58
- }
59
- return parseCliVersion(cliName, Buffer.from(result.stdout).toString("utf8"));
60
- } catch {
61
- return null;
62
- }
63
- }
64
- function shellQuote(value) {
65
- return `'${value.replaceAll("'", `'\\''`)}'`;
66
- }
67
- function getManualCliUpdateCommand(input) {
68
- return `npm install -g --omit=dev ${shellQuote(input.workerPackageSpec)} ${shellQuote(input.r5dctlPackageSpec)}`;
69
- }
70
- function commandErrorDetail(result) {
71
- const detail = `${result.stderr.trim()}${result.stderr.trim() && result.stdout.trim() ? "\n" : ""}${result.stdout.trim()}`.trim();
72
- if (!detail) {
73
- return `exit code ${result.exitCode}`;
74
- }
75
- return detail.slice(-UPDATE_OUTPUT_LIMIT);
76
- }
77
- async function readVerifiedVersion(cliName, targetVersion, runner) {
78
- const result = await runner([cliName, "--version"]);
79
- const installedVersion = result.exitCode === 0 ? parseCliVersion(cliName, result.stdout) : null;
80
- if (!installedVersion) {
81
- throw new Error(`${cliName} was installed but is not runnable: ${commandErrorDetail(result)}`);
82
- }
83
- if (installedVersion !== targetVersion) {
84
- throw new Error(`${cliName} ${installedVersion} was installed; expected ${targetVersion}`);
85
- }
86
- return installedVersion;
87
- }
88
- async function installCliUpdate(input, runner = runCommand) {
89
- const installArgs = ["npm", "install", "-g", "--omit=dev", input.workerPackageSpec, input.r5dctlPackageSpec];
90
- const result = await runner(installArgs);
91
- if (result.exitCode !== 0) {
92
- throw new Error(`CLI update failed: ${commandErrorDetail(result)}
93
- Run manually: ${getManualCliUpdateCommand(input)}`);
94
- }
95
- const [installedWorkerVersion, installedR5dctlVersion] = await Promise.all([
96
- readVerifiedVersion("r5d-worker", input.targetWorkerVersion, runner),
97
- readVerifiedVersion("r5dctl", input.targetR5dctlVersion, runner)
98
- ]);
99
- return { installedWorkerVersion, installedR5dctlVersion };
100
- }
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
103
- getManualCliUpdateCommand,
104
- installCliUpdate,
105
- parseCliVersion,
106
- readInstalledCliVersion,
107
- runCommand
108
- });