@cleocode/contracts 2026.9.20 → 2026.9.22

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 (165) hide show
  1. package/README.md +1 -1
  2. package/dist/__tests__/decide.test.d.ts +7 -0
  3. package/dist/__tests__/decide.test.d.ts.map +1 -0
  4. package/dist/__tests__/decide.test.js +91 -0
  5. package/dist/__tests__/decide.test.js.map +1 -0
  6. package/dist/__tests__/evidence-atom-schema.test.js +19 -1
  7. package/dist/__tests__/evidence-atom-schema.test.js.map +1 -1
  8. package/dist/__tests__/memory-wire-shapes.test.js.map +1 -1
  9. package/dist/acceptance-gate-schema.d.ts +5 -0
  10. package/dist/acceptance-gate-schema.d.ts.map +1 -1
  11. package/dist/acceptance-gate-schema.js +26 -0
  12. package/dist/acceptance-gate-schema.js.map +1 -1
  13. package/dist/acceptance-gate.d.ts +70 -3
  14. package/dist/acceptance-gate.d.ts.map +1 -1
  15. package/dist/backup-manifest.d.ts +13 -2
  16. package/dist/backup-manifest.d.ts.map +1 -1
  17. package/dist/branch-lock.d.ts +11 -0
  18. package/dist/branch-lock.d.ts.map +1 -1
  19. package/dist/branch-lock.js +31 -4
  20. package/dist/branch-lock.js.map +1 -1
  21. package/dist/cloud/api.d.ts +607 -0
  22. package/dist/cloud/api.d.ts.map +1 -0
  23. package/dist/cloud/api.js +417 -0
  24. package/dist/cloud/api.js.map +1 -0
  25. package/dist/cloud/envelope.d.ts +84 -0
  26. package/dist/cloud/envelope.d.ts.map +1 -0
  27. package/dist/cloud/envelope.js +54 -0
  28. package/dist/cloud/envelope.js.map +1 -0
  29. package/dist/cloud/ids.d.ts +30 -0
  30. package/dist/cloud/ids.d.ts.map +1 -0
  31. package/dist/cloud/ids.js +32 -0
  32. package/dist/cloud/ids.js.map +1 -0
  33. package/dist/cloud/index.d.ts +17 -0
  34. package/dist/cloud/index.d.ts.map +1 -0
  35. package/dist/cloud/index.js +17 -0
  36. package/dist/cloud/index.js.map +1 -0
  37. package/dist/data-accessor.d.ts +23 -3
  38. package/dist/data-accessor.d.ts.map +1 -1
  39. package/dist/data-accessor.js.map +1 -1
  40. package/dist/decide.d.ts +333 -0
  41. package/dist/decide.d.ts.map +1 -0
  42. package/dist/decide.js +184 -0
  43. package/dist/decide.js.map +1 -0
  44. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  45. package/dist/dispatch/operations-registry.js +56 -0
  46. package/dist/dispatch/operations-registry.js.map +1 -1
  47. package/dist/done-plan.d.ts +330 -0
  48. package/dist/done-plan.d.ts.map +1 -0
  49. package/dist/done-plan.js +17 -0
  50. package/dist/done-plan.js.map +1 -0
  51. package/dist/evidence-atom-schema.d.ts +29 -44
  52. package/dist/evidence-atom-schema.d.ts.map +1 -1
  53. package/dist/evidence-atom-schema.js +48 -8
  54. package/dist/evidence-atom-schema.js.map +1 -1
  55. package/dist/exit-codes.d.ts +40 -0
  56. package/dist/exit-codes.d.ts.map +1 -1
  57. package/dist/exit-codes.js +41 -0
  58. package/dist/exit-codes.js.map +1 -1
  59. package/dist/graph.d.ts +40 -0
  60. package/dist/graph.d.ts.map +1 -1
  61. package/dist/index.d.ts +13 -6
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +4 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/memory/observe.d.ts +16 -0
  66. package/dist/memory/observe.d.ts.map +1 -1
  67. package/dist/operations/__tests__/release-shared-surface.test.d.ts +10 -0
  68. package/dist/operations/__tests__/release-shared-surface.test.d.ts.map +1 -0
  69. package/dist/operations/__tests__/release-shared-surface.test.js +84 -0
  70. package/dist/operations/__tests__/release-shared-surface.test.js.map +1 -0
  71. package/dist/operations/dialectic.d.ts +16 -0
  72. package/dist/operations/dialectic.d.ts.map +1 -1
  73. package/dist/operations/docs.d.ts +5 -2
  74. package/dist/operations/docs.d.ts.map +1 -1
  75. package/dist/operations/docs.js.map +1 -1
  76. package/dist/operations/memory.d.ts +48 -0
  77. package/dist/operations/memory.d.ts.map +1 -1
  78. package/dist/operations/nexus-scope-map.d.ts +8 -0
  79. package/dist/operations/nexus-scope-map.d.ts.map +1 -1
  80. package/dist/operations/nexus-scope-map.js +8 -0
  81. package/dist/operations/nexus-scope-map.js.map +1 -1
  82. package/dist/operations/nexus-user-profile.d.ts +27 -1
  83. package/dist/operations/nexus-user-profile.d.ts.map +1 -1
  84. package/dist/operations/nexus-user-profile.js +11 -1
  85. package/dist/operations/nexus-user-profile.js.map +1 -1
  86. package/dist/operations/nexus.d.ts +394 -3
  87. package/dist/operations/nexus.d.ts.map +1 -1
  88. package/dist/operations/release.d.ts +259 -0
  89. package/dist/operations/release.d.ts.map +1 -1
  90. package/dist/operations/release.js +130 -1
  91. package/dist/operations/release.js.map +1 -1
  92. package/dist/operations/session.d.ts +6 -4
  93. package/dist/operations/session.d.ts.map +1 -1
  94. package/dist/operations/tasks.d.ts +6 -0
  95. package/dist/operations/tasks.d.ts.map +1 -1
  96. package/dist/operations/tasks.js +1 -0
  97. package/dist/operations/tasks.js.map +1 -1
  98. package/dist/operations/validate.d.ts +5 -0
  99. package/dist/operations/validate.d.ts.map +1 -1
  100. package/dist/operations/worktree.d.ts +125 -1
  101. package/dist/operations/worktree.d.ts.map +1 -1
  102. package/dist/process-probe.d.ts +17 -0
  103. package/dist/process-probe.d.ts.map +1 -0
  104. package/dist/process-probe.js +21 -0
  105. package/dist/process-probe.js.map +1 -0
  106. package/dist/project-context.d.ts +44 -2
  107. package/dist/project-context.d.ts.map +1 -1
  108. package/dist/project-lifecycle.d.ts +143 -0
  109. package/dist/project-lifecycle.d.ts.map +1 -0
  110. package/dist/project-lifecycle.js +21 -0
  111. package/dist/project-lifecycle.js.map +1 -0
  112. package/dist/release/plan.d.ts +6 -2
  113. package/dist/release/plan.d.ts.map +1 -1
  114. package/dist/release/plan.js +8 -2
  115. package/dist/release/plan.js.map +1 -1
  116. package/dist/release/plan.test.js +6 -1
  117. package/dist/release/plan.test.js.map +1 -1
  118. package/dist/table-classification.d.ts +208 -0
  119. package/dist/table-classification.d.ts.map +1 -0
  120. package/dist/table-classification.js +23 -0
  121. package/dist/table-classification.js.map +1 -0
  122. package/dist/task.d.ts +97 -1
  123. package/dist/task.d.ts.map +1 -1
  124. package/package.json +6 -2
  125. package/schemas/gate-result.schema.json +43 -0
  126. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  127. package/src/__tests__/decide.test.ts +139 -0
  128. package/src/__tests__/evidence-atom-schema.test.ts +24 -1
  129. package/src/__tests__/memory-wire-shapes.test.ts +3 -0
  130. package/src/acceptance-gate-schema.ts +29 -0
  131. package/src/acceptance-gate.ts +68 -3
  132. package/src/backup-manifest.ts +13 -2
  133. package/src/branch-lock.ts +36 -4
  134. package/src/cloud/api.ts +512 -0
  135. package/src/cloud/envelope.ts +63 -0
  136. package/src/cloud/ids.ts +51 -0
  137. package/src/cloud/index.ts +16 -0
  138. package/src/data-accessor.ts +24 -3
  139. package/src/decide.ts +355 -0
  140. package/src/dispatch/operations-registry.ts +59 -0
  141. package/src/done-plan.ts +370 -0
  142. package/src/evidence-atom-schema.ts +51 -9
  143. package/src/exit-codes.ts +42 -0
  144. package/src/graph.ts +44 -0
  145. package/src/index.ts +118 -0
  146. package/src/memory/observe.ts +16 -0
  147. package/src/operations/__tests__/release-shared-surface.test.ts +112 -0
  148. package/src/operations/dialectic.ts +17 -0
  149. package/src/operations/docs.ts +5 -2
  150. package/src/operations/memory.ts +48 -0
  151. package/src/operations/nexus-scope-map.ts +9 -0
  152. package/src/operations/nexus-user-profile.ts +29 -1
  153. package/src/operations/nexus.ts +416 -3
  154. package/src/operations/release.ts +197 -0
  155. package/src/operations/session.ts +6 -4
  156. package/src/operations/tasks.ts +7 -0
  157. package/src/operations/validate.ts +5 -0
  158. package/src/operations/worktree.ts +133 -1
  159. package/src/process-probe.ts +21 -0
  160. package/src/project-context.ts +42 -2
  161. package/src/project-lifecycle.ts +149 -0
  162. package/src/release/plan.test.ts +6 -1
  163. package/src/release/plan.ts +8 -2
  164. package/src/table-classification.ts +232 -0
  165. package/src/task.ts +102 -2
@@ -0,0 +1,417 @@
1
+ import { z } from 'zod';
2
+ import { Base64, DeviceId, Hlc, ProjectId, ReplicaId, Sha256Hex, StreamId } from './ids.js';
3
+ /**
4
+ * Wire contract for the Cleo Nexus API (v1).
5
+ *
6
+ * Privacy rule: the server never receives plaintext content (ADR-093). Everything below is
7
+ * routing or integrity metadata. Content travels only as ciphertext (`Base64`) or as blobs
8
+ * addressed by the sha256 of their ciphertext.
9
+ */
10
+ export const API_VERSION = 'v1';
11
+ /**
12
+ * The highest key version any schema accepts. Key versions go up by one per rotation, so this is far above
13
+ * any real account, and it keeps an absurd value (2^53 - 1, say) out of client state.
14
+ */
15
+ export const MAX_KEY_VERSION = 1_000_000;
16
+ /** A master key or project key version: a positive integer, at most MAX_KEY_VERSION. */
17
+ export const KeyVersion = z.number().int().positive().max(MAX_KEY_VERSION);
18
+ /** Largest inline segment. Larger segments go to R2 as a blob and are referenced by sha256. */
19
+ export const MAX_INLINE_SEGMENT_BYTES = 1_048_576;
20
+ export const MAX_PULL_LIMIT = 500;
21
+ // ---------- devices ----------
22
+ export const Platform = z.enum(['darwin', 'linux', 'win32', 'other']);
23
+ export const RegisterDeviceRequest = z.object({
24
+ deviceId: DeviceId,
25
+ name: z.string().min(1).max(120),
26
+ platform: Platform,
27
+ /** X25519 public key, base64 (32 bytes). Used to wrap the user master key for this device. */
28
+ encryptionPublicKey: Base64,
29
+ /** Ed25519 public key, base64 (32 bytes). Verifies segments this device's replicas sign. */
30
+ signingPublicKey: Base64,
31
+ cliVersion: z.string().max(40),
32
+ });
33
+ export const Device = z.object({
34
+ deviceId: DeviceId,
35
+ name: z.string(),
36
+ platform: Platform,
37
+ encryptionPublicKey: Base64,
38
+ signingPublicKey: Base64,
39
+ cliVersion: z.string(),
40
+ createdAt: z.iso.datetime(),
41
+ lastSeenAt: z.iso.datetime().nullable(),
42
+ revokedAt: z.iso.datetime().nullable(),
43
+ /**
44
+ * The device certificate from this device's current key grant: an HMAC under a key derived from the
45
+ * user master key over deviceCertificateMessage(...). Only a holder of the master key can make one,
46
+ * so a client that holds the master key can tell the user's real devices from rows the server
47
+ * invented (docs/security/e2e-keys.md, "Device trust"). Null until the device holds a grant.
48
+ */
49
+ certificate: Base64.nullable(),
50
+ /** The master key version the certificate was made under. */
51
+ certificateKeyVersion: KeyVersion.nullable(),
52
+ });
53
+ export const ListDevicesResult = z.object({ devices: z.array(Device) });
54
+ // ---------- projects ----------
55
+ export const RegisterProjectRequest = z.object({
56
+ projectId: ProjectId,
57
+ /**
58
+ * Optional plaintext label for the web view. The client decides whether to reveal a name;
59
+ * the default is the encrypted name only.
60
+ */
61
+ label: z.string().max(120).optional(),
62
+ /** The project name, encrypted with the project data key. */
63
+ encryptedName: Base64.optional(),
64
+ /** The git origin, only if the user opts in (it can reveal a private repo's name). */
65
+ remoteUrl: z.string().max(500).optional(),
66
+ /**
67
+ * The organization that will own the project. The caller must be a member of it. Defaults to the
68
+ * caller's personal organization, which every account has.
69
+ */
70
+ organizationId: z.string().uuid().optional(),
71
+ });
72
+ export const Project = z.object({
73
+ projectId: ProjectId,
74
+ label: z.string().nullable(),
75
+ encryptedName: Base64.nullable(),
76
+ remoteUrl: z.string().nullable(),
77
+ /** Projects are owned by an organization. Access derives from membership (ADR-095, ownership). */
78
+ organizationId: z.string().uuid(),
79
+ /** Who registered the project. Provenance only: it grants nothing. Null once that account is deleted. */
80
+ createdByUserId: z.string().uuid().nullable(),
81
+ createdAt: z.iso.datetime(),
82
+ });
83
+ export const RegisterProjectResult = z.object({ project: Project, streamId: StreamId });
84
+ /**
85
+ * Which devices hold a project. The server stores NO filesystem path, not even as a hint.
86
+ * Paths are per-device local state (cleo-dev review, 2026-09-27).
87
+ */
88
+ export const AttachProjectDeviceRequest = z.object({
89
+ deviceId: DeviceId,
90
+ replicaId: ReplicaId,
91
+ });
92
+ /**
93
+ * Path-free presence of one replica, for fleet status (cleo-dev SG-AGENTIC-CORE, T12479).
94
+ * The device keeps the full record, including paths. The cloud mirrors only this.
95
+ */
96
+ export const ReplicaPresence = z.object({
97
+ git: z
98
+ .object({
99
+ /** Sent only when the user opts in: branch names can be sensitive. */
100
+ branch: z.string().max(200).optional(),
101
+ dirty: z.boolean(),
102
+ ahead: z.number().int().nonnegative(),
103
+ behind: z.number().int().nonnegative(),
104
+ /** The remote tracking state: in sync, diverged, no upstream, or unknown. */
105
+ remote: z.enum(['in-sync', 'ahead', 'behind', 'diverged', 'no-upstream', 'unknown']),
106
+ lastCommitAt: z.iso.datetime().optional(),
107
+ })
108
+ .optional(),
109
+ cliVersion: z.string().max(40),
110
+ schemaVersion: z.number().int().positive(),
111
+ /** When the device measured this. The server also records when it received it. */
112
+ observedAt: z.iso.datetime(),
113
+ });
114
+ // ---------- journal segments ----------
115
+ /**
116
+ * Per-table row deltas in a segment: plaintext counts, no content. They let the server check a
117
+ * checkpoint manifest for regressions without reading any row (E_REGRESSION).
118
+ */
119
+ export const TableDeltas = z.record(z.string().regex(/^[a-z][a-z0-9_]{0,62}$/), z.object({ created: z.number().int().nonnegative(), deleted: z.number().int().nonnegative() }));
120
+ export const AppendSegmentRequest = z
121
+ .object({
122
+ replicaId: ReplicaId,
123
+ deviceId: DeviceId,
124
+ /** sha256 of the ciphertext bytes. With `replicaId`, it is the idempotency key. */
125
+ segmentHash: Sha256Hex,
126
+ /** The replica's own monotonically increasing segment counter, so gaps are detectable. */
127
+ replicaSeq: z.number().int().nonnegative(),
128
+ schemaVersion: z.number().int().positive(),
129
+ opCount: z.number().int().positive(),
130
+ hlcMin: Hlc,
131
+ hlcMax: Hlc,
132
+ deltas: TableDeltas,
133
+ /**
134
+ * Ed25519 signature by the device signing key over segmentSigningMessage (v2), which covers the
135
+ * stream, replica, device, replicaSeq, the ciphertext hash and the hash of every metadata field
136
+ * above (segmentMetaCanonical). The server verifies it on append; every client re-verifies it on pull.
137
+ */
138
+ signature: Base64,
139
+ ciphertext: Base64.optional(),
140
+ /** Set instead of `ciphertext` for segments over MAX_INLINE_SEGMENT_BYTES (uploaded first). */
141
+ blobSha256: Sha256Hex.optional(),
142
+ })
143
+ .refine((r) => (r.ciphertext === undefined) !== (r.blobSha256 === undefined), {
144
+ message: 'exactly one of ciphertext or blobSha256 is required',
145
+ })
146
+ .refine((r) => r.hlcMin <= r.hlcMax, { message: 'hlcMin must not exceed hlcMax' });
147
+ export const AppendSegmentResult = z.object({
148
+ streamId: StreamId,
149
+ /** The server-assigned position in the stream. */
150
+ seq: z.number().int().positive(),
151
+ /** True when this exact segment was already stored. The retry was a no-op. */
152
+ duplicate: z.boolean(),
153
+ });
154
+ export const Segment = z.object({
155
+ seq: z.number().int().positive(),
156
+ replicaId: ReplicaId,
157
+ deviceId: DeviceId,
158
+ replicaSeq: z.number().int().nonnegative(),
159
+ segmentHash: Sha256Hex,
160
+ schemaVersion: z.number().int().positive(),
161
+ opCount: z.number().int().positive(),
162
+ hlcMin: Hlc,
163
+ hlcMax: Hlc,
164
+ deltas: TableDeltas,
165
+ signature: Base64,
166
+ ciphertext: Base64.nullable(),
167
+ blobSha256: Sha256Hex.nullable(),
168
+ receivedAt: z.iso.datetime(),
169
+ });
170
+ export const PullSegmentsQuery = z.object({
171
+ after: z.coerce.number().int().nonnegative().default(0),
172
+ limit: z.coerce.number().int().positive().max(MAX_PULL_LIMIT).default(100),
173
+ });
174
+ export const PullSegmentsResult = z.object({
175
+ streamId: StreamId,
176
+ segments: z.array(Segment),
177
+ /** The stream head at read time. When `nextAfter < head`, keep pulling. */
178
+ head: z.number().int().nonnegative(),
179
+ nextAfter: z.number().int().nonnegative(),
180
+ });
181
+ // ---------- checkpoints ----------
182
+ /**
183
+ * A checkpoint id (UUIDv7). The authoring client mints it, because its signature and the bundle's AAD
184
+ * both cover it, so the id must exist before the bundle is encrypted.
185
+ */
186
+ export const CheckpointId = z
187
+ .string()
188
+ .regex(/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, 'expected a UUIDv7 checkpoint id');
189
+ export const TableManifestEntry = z.object({
190
+ rows: z.number().int().nonnegative(),
191
+ /** Canonical content hash keyed by uid (Gate D). The same algorithm runs in core and on replay. */
192
+ hash: Sha256Hex,
193
+ });
194
+ /** Plaintext manifest: per-table counts and uid-keyed hashes. No content (ADR-093 §3). */
195
+ export const Manifest = z.object({
196
+ schemaVersion: z.number().int().positive(),
197
+ tables: z.record(z.string().regex(/^[a-z][a-z0-9_]{0,62}$/), TableManifestEntry),
198
+ });
199
+ /**
200
+ * Where one replica stood at a checkpoint: the device that signs its segments and the last replicaSeq
201
+ * folded in. A checkpoint lists every replica with a segment at or below its coversSeq, so a client that
202
+ * restores it can check every later segment for gaps and re-attribution (PullCursor).
203
+ */
204
+ export const ReplicaHead = z.object({
205
+ deviceId: DeviceId,
206
+ lastReplicaSeq: z.number().int().nonnegative(),
207
+ });
208
+ /** Per replica id, keys are replica ids. Covered by the checkpoint signature (replicasCanonical). */
209
+ export const ReplicaHeads = z.record(ReplicaId, ReplicaHead);
210
+ export const CreateCheckpointRequest = z.object({
211
+ /** Minted by the author: the signature and the bundle's AAD both cover it. */
212
+ checkpointId: CheckpointId,
213
+ replicaId: ReplicaId,
214
+ /** The authoring device. It must be the calling device. */
215
+ deviceId: DeviceId,
216
+ /** null only for a stream's genesis checkpoint. */
217
+ parentCheckpointId: z.string().uuid().nullable(),
218
+ /** The last stream seq whose ops are folded into this checkpoint. */
219
+ coversSeq: z.number().int().nonnegative(),
220
+ manifest: Manifest,
221
+ /** Every replica with a segment at or below coversSeq. The server checks it against the journal. */
222
+ replicas: ReplicaHeads,
223
+ /** The encrypted checkpoint bundle, uploaded to R2 first. */
224
+ blobSha256: Sha256Hex,
225
+ sizeBytes: z.number().int().positive(),
226
+ /**
227
+ * Ed25519 signature by the authoring device over checkpointSigningMessage(...): the stream, the
228
+ * checkpoint and parent ids, replica, device, coversSeq, the manifest hash (manifestCanonical), the
229
+ * replica map hash (replicasCanonical), the bundle sha256 and size. The server verifies it on create;
230
+ * a client verifies it before restoring. Creating the same checkpoint again is a no-op.
231
+ */
232
+ signature: Base64,
233
+ });
234
+ export const Checkpoint = z.object({
235
+ checkpointId: CheckpointId,
236
+ streamId: StreamId,
237
+ parentCheckpointId: CheckpointId.nullable(),
238
+ replicaId: ReplicaId,
239
+ deviceId: DeviceId,
240
+ coversSeq: z.number().int().nonnegative(),
241
+ manifest: Manifest,
242
+ replicas: ReplicaHeads,
243
+ blobSha256: Sha256Hex,
244
+ sizeBytes: z.number().int().positive(),
245
+ signature: Base64,
246
+ /**
247
+ * Re-signatures by other devices (checkpointEndorsementMessage). A client accepts a checkpoint whose
248
+ * author it no longer trusts without a pin (a revoked device) when a live device endorsed it.
249
+ */
250
+ endorsements: z.array(z.object({ deviceId: DeviceId, signature: Base64 })),
251
+ createdAt: z.iso.datetime(),
252
+ });
253
+ /** A live device re-signs a checkpoint. The device must be the calling device. */
254
+ export const EndorseCheckpointRequest = z.object({ deviceId: DeviceId, signature: Base64 });
255
+ export const CreateCheckpointResult = z.object({ checkpoint: Checkpoint });
256
+ /** Newest first, at most 100. */
257
+ export const ListCheckpointsResult = z.object({ checkpoints: z.array(Checkpoint) });
258
+ // ---------- blobs ----------
259
+ export const PresignUploadRequest = z.object({
260
+ sha256: Sha256Hex,
261
+ sizeBytes: z
262
+ .number()
263
+ .int()
264
+ .positive()
265
+ .max(5 * 1024 ** 3),
266
+ purpose: z.enum(['segment', 'checkpoint', 'attachment']),
267
+ });
268
+ export const PresignUploadResult = z.object({
269
+ /** True when the blob is already stored and verified. Skip the upload. */
270
+ alreadyPresent: z.boolean(),
271
+ uploadUrl: z.string().nullable(),
272
+ /** Headers the uploader must send exactly (signed). They include the sha256 checksum the store enforces. */
273
+ uploadHeaders: z.record(z.string(), z.string()).nullable(),
274
+ expiresAt: z.iso.datetime().nullable(),
275
+ });
276
+ export const CompleteUploadResult = z.object({ sha256: Sha256Hex, verified: z.literal(true) });
277
+ /**
278
+ * A short-lived presigned download URL. The response of `GET /v1/streams/:streamId/segments/:seq/blob`
279
+ * and of `GET /v1/streams/:streamId/checkpoints/:checkpointId/download`. The client downloads at most
280
+ * `sizeBytes` and checks the bytes against the sha256 it already trusts, never against this one alone.
281
+ */
282
+ export const BlobDownload = z.object({
283
+ url: z.string().min(1),
284
+ sha256: Sha256Hex,
285
+ sizeBytes: z.number().int().positive(),
286
+ expiresInSeconds: z.number().int().positive(),
287
+ });
288
+ // ---------- elected-writer leases (T12338) ----------
289
+ /**
290
+ * Roles that must run on exactly one replica per stream (cleo-dev review R4). Consolidation
291
+ * writes (invalid_at, citation_count), sentient proposals and checkpoint authoring would otherwise
292
+ * produce op storms or duplicates. Ordinary journal appends are not leased, because merge handles concurrency.
293
+ */
294
+ export const LeaseRole = z.enum(['consolidator', 'sentient', 'checkpointer']);
295
+ export const AcquireLeaseRequest = z.object({
296
+ role: LeaseRole,
297
+ replicaId: ReplicaId,
298
+ ttlSeconds: z.number().int().min(15).max(3600).default(300),
299
+ /** Take the lease from a live holder. The server records a labelled fork event. */
300
+ force: z.boolean().default(false),
301
+ reason: z.string().max(300).optional(),
302
+ });
303
+ export const Lease = z.object({
304
+ streamId: StreamId,
305
+ role: LeaseRole,
306
+ leaseId: z.string().uuid(),
307
+ replicaId: ReplicaId,
308
+ expiresAt: z.iso.datetime(),
309
+ /** Set when this lease was taken by force from another replica. */
310
+ forkedFromReplicaId: ReplicaId.nullable(),
311
+ });
312
+ // ---------- keys (E2E; the server stores wrapped keys only) ----------
313
+ /**
314
+ * Bounds on Argon2id parameters. The server stores the parameters, so a client must not trust them: too
315
+ * low weakens the passphrase, too high is a denial of service (a 64 GiB allocation). Both sides enforce these.
316
+ */
317
+ export const KDF_LIMITS = {
318
+ memoryKiB: { min: 65_536, max: 1_048_576 },
319
+ iterations: { min: 2, max: 10 },
320
+ parallelism: { min: 1, max: 16 },
321
+ };
322
+ export const KdfParams = z.object({
323
+ algorithm: z.literal('argon2id'),
324
+ memoryKiB: z.number().int().min(KDF_LIMITS.memoryKiB.min).max(KDF_LIMITS.memoryKiB.max),
325
+ iterations: z.number().int().min(KDF_LIMITS.iterations.min).max(KDF_LIMITS.iterations.max),
326
+ parallelism: z.number().int().min(KDF_LIMITS.parallelism.min).max(KDF_LIMITS.parallelism.max),
327
+ salt: Base64,
328
+ });
329
+ export const PutUserKeysRequest = z.object({
330
+ /** The user master key wrapped by a passphrase-derived key (XChaCha20-Poly1305). */
331
+ passphraseWrappedMasterKey: Base64,
332
+ kdf: KdfParams,
333
+ /** The master key wrapped by the recovery key, which is shown to the user once. */
334
+ recoveryWrappedMasterKey: Base64,
335
+ /** sha256 of the master key's public verifier, so a wrong unwrap is detected client-side. */
336
+ masterKeyVerifier: Sha256Hex,
337
+ keyVersion: KeyVersion,
338
+ });
339
+ /** What the server returns for `GET /v1/account/keys`. */
340
+ export const UserKeys = PutUserKeysRequest.extend({
341
+ /** The account the keys belong to. */
342
+ userId: z.string().uuid(),
343
+ updatedAt: z.iso.datetime(),
344
+ });
345
+ /**
346
+ * A device key grant: the master key sealed to the recipient device, signed by a device that holds the
347
+ * master key (docs/security/e2e-keys.md, "Device trust"). The sealed box alone is anonymous, so anyone,
348
+ * the server included, could seal a key of their choosing to a device. The signature is what the
349
+ * recipient checks, against a signer it already trusts, before it accepts the key.
350
+ */
351
+ export const PutDeviceWrappedKeyRequest = z.object({
352
+ /** The master key sealed to the recipient device's X25519 key. */
353
+ sealedMasterKey: Base64,
354
+ keyVersion: KeyVersion,
355
+ /** The recipient's device certificate (see Device.certificate), made by the signer under the master key. */
356
+ certificate: Base64,
357
+ /** The device that made the grant. It must be the calling device: a self-grant names the recipient. */
358
+ signerDeviceId: DeviceId,
359
+ /** Ed25519 by the signer over deviceGrantMessage(...). */
360
+ grantSignature: Base64,
361
+ });
362
+ /** What the server returns for `GET /v1/devices/:deviceId/key`. */
363
+ export const DeviceKeyGrant = PutDeviceWrappedKeyRequest.extend({ deviceId: DeviceId });
364
+ /**
365
+ * Where a revoked signing key stops being trusted: per replica, the last replicaSeq it may have signed,
366
+ * and per stream, the highest coversSeq of a checkpoint it may have signed. Keys are replica ids and
367
+ * stream ids. Covered by the revocation signature (revocationPinsCanonical).
368
+ */
369
+ export const RevocationPins = z.object({
370
+ replicas: z.record(ReplicaId, z.number().int().nonnegative()),
371
+ checkpoints: z.record(StreamId, z.number().int().nonnegative()),
372
+ });
373
+ /**
374
+ * A revocation record (docs/security/e2e-keys.md, "Revocation"): a certified device signs that one
375
+ * signing key of a device is revoked, and pins what it signed before. History up to the pins stays
376
+ * verifiable; anything past them is refused. The signer must be the calling device.
377
+ */
378
+ export const CreateDeviceRevocationRequest = z.object({
379
+ /** The revoked key (base64 Ed25519 public key): the device's current key or an earlier one. */
380
+ signingPublicKey: Base64,
381
+ pins: RevocationPins,
382
+ signerDeviceId: DeviceId,
383
+ /** Ed25519 by the signer over deviceRevocationMessage(...). */
384
+ signature: Base64,
385
+ });
386
+ export const DeviceRevocation = CreateDeviceRevocationRequest.extend({ deviceId: DeviceId });
387
+ /**
388
+ * One device certificate ever issued, kept for as long as the device's history exists. A revoke or a
389
+ * re-registration with new keys never deletes one. `live` is the server's claim that the key is the
390
+ * device's current key and the device is not revoked; clients trust it only in the safe direction.
391
+ */
392
+ export const DeviceCertificateRecord = z.object({
393
+ deviceId: DeviceId,
394
+ encryptionPublicKey: Base64,
395
+ signingPublicKey: Base64,
396
+ keyVersion: KeyVersion,
397
+ certificate: Base64,
398
+ live: z.boolean(),
399
+ });
400
+ /** `GET /v1/devices/trust`: everything a client needs to build its trusted signer set (certifiedSigners). */
401
+ export const DeviceTrust = z.object({
402
+ certificates: z.array(DeviceCertificateRecord),
403
+ revocations: z.array(DeviceRevocation),
404
+ });
405
+ export const PutProjectKeyRequest = z.object({
406
+ /** The project data key, wrapped by the member's master key. */
407
+ wrappedProjectKey: Base64,
408
+ keyVersion: KeyVersion,
409
+ });
410
+ // ---------- conflicts (metadata only; the content stays E2E) ----------
411
+ export const ConflictSummary = z.object({
412
+ replicaId: ReplicaId,
413
+ open: z.number().int().nonnegative(),
414
+ byKind: z.record(z.string().max(60), z.number().int().nonnegative()),
415
+ reportedAt: z.iso.datetime(),
416
+ });
417
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/cloud/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE5F;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AAEzC,wFAAwF;AACxF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAE3E,+FAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,gCAAgC;AAEhC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,QAAQ,EAAE,QAAQ;IAClB,8FAA8F;IAC9F,mBAAmB,EAAE,MAAM;IAC3B,4FAA4F;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M;IACnB,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE;CAClB,CAAC,CAAC;AAGH,6GAA6G;AAC7G,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAC9C,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC;CACvC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,gEAAgE;IAChE,iBAAiB,EAAE,MAAM;IACzB,UAAU,EAAE,UAAU;CACvB,CAAC,CAAC;AAEH,yEAAyE;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IACpE,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Stable error codes. Clients branch on `code`, never on `message`.
4
+ * Codes that describe a refused sync action are never retried blindly: the client must
5
+ * reassess (pull, then re-verify) first.
6
+ */
7
+ export declare const ErrorCode: z.ZodEnum<{
8
+ E_NOT_FOUND: "E_NOT_FOUND";
9
+ E_VALIDATION: "E_VALIDATION";
10
+ E_UNAUTHENTICATED: "E_UNAUTHENTICATED";
11
+ E_FORBIDDEN: "E_FORBIDDEN";
12
+ E_CONFLICT: "E_CONFLICT";
13
+ E_RATE_LIMITED: "E_RATE_LIMITED";
14
+ E_PAYLOAD_TOO_LARGE: "E_PAYLOAD_TOO_LARGE";
15
+ E_LINEAGE: "E_LINEAGE";
16
+ E_REGRESSION: "E_REGRESSION";
17
+ E_SCHEMA_AHEAD: "E_SCHEMA_AHEAD";
18
+ E_LEASE_HELD: "E_LEASE_HELD";
19
+ E_BLOB_MISSING: "E_BLOB_MISSING";
20
+ E_BLOB_INTEGRITY: "E_BLOB_INTEGRITY";
21
+ E_UNAVAILABLE: "E_UNAVAILABLE";
22
+ E_INTERNAL: "E_INTERNAL";
23
+ }>;
24
+ export type ErrorCode = z.infer<typeof ErrorCode>;
25
+ export declare const ErrorBody: z.ZodObject<{
26
+ code: z.ZodEnum<{
27
+ E_NOT_FOUND: "E_NOT_FOUND";
28
+ E_VALIDATION: "E_VALIDATION";
29
+ E_UNAUTHENTICATED: "E_UNAUTHENTICATED";
30
+ E_FORBIDDEN: "E_FORBIDDEN";
31
+ E_CONFLICT: "E_CONFLICT";
32
+ E_RATE_LIMITED: "E_RATE_LIMITED";
33
+ E_PAYLOAD_TOO_LARGE: "E_PAYLOAD_TOO_LARGE";
34
+ E_LINEAGE: "E_LINEAGE";
35
+ E_REGRESSION: "E_REGRESSION";
36
+ E_SCHEMA_AHEAD: "E_SCHEMA_AHEAD";
37
+ E_LEASE_HELD: "E_LEASE_HELD";
38
+ E_BLOB_MISSING: "E_BLOB_MISSING";
39
+ E_BLOB_INTEGRITY: "E_BLOB_INTEGRITY";
40
+ E_UNAVAILABLE: "E_UNAVAILABLE";
41
+ E_INTERNAL: "E_INTERNAL";
42
+ }>;
43
+ message: z.ZodString;
44
+ requestId: z.ZodString;
45
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
46
+ }, z.core.$strip>;
47
+ export type ErrorBody = z.infer<typeof ErrorBody>;
48
+ export declare const ErrorEnvelope: z.ZodObject<{
49
+ success: z.ZodLiteral<false>;
50
+ error: z.ZodObject<{
51
+ code: z.ZodEnum<{
52
+ E_NOT_FOUND: "E_NOT_FOUND";
53
+ E_VALIDATION: "E_VALIDATION";
54
+ E_UNAUTHENTICATED: "E_UNAUTHENTICATED";
55
+ E_FORBIDDEN: "E_FORBIDDEN";
56
+ E_CONFLICT: "E_CONFLICT";
57
+ E_RATE_LIMITED: "E_RATE_LIMITED";
58
+ E_PAYLOAD_TOO_LARGE: "E_PAYLOAD_TOO_LARGE";
59
+ E_LINEAGE: "E_LINEAGE";
60
+ E_REGRESSION: "E_REGRESSION";
61
+ E_SCHEMA_AHEAD: "E_SCHEMA_AHEAD";
62
+ E_LEASE_HELD: "E_LEASE_HELD";
63
+ E_BLOB_MISSING: "E_BLOB_MISSING";
64
+ E_BLOB_INTEGRITY: "E_BLOB_INTEGRITY";
65
+ E_UNAVAILABLE: "E_UNAVAILABLE";
66
+ E_INTERNAL: "E_INTERNAL";
67
+ }>;
68
+ message: z.ZodString;
69
+ requestId: z.ZodString;
70
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
71
+ }, z.core.$strip>;
72
+ }, z.core.$strip>;
73
+ export type ErrorEnvelope = z.infer<typeof ErrorEnvelope>;
74
+ export type OkEnvelope<T> = {
75
+ success: true;
76
+ data: T;
77
+ meta: {
78
+ requestId: string;
79
+ };
80
+ };
81
+ export type Envelope<T> = OkEnvelope<T> | ErrorEnvelope;
82
+ /** HTTP status for each code, so server and client agree. */
83
+ export declare const errorStatus: Record<ErrorCode, number>;
84
+ //# sourceMappingURL=envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/cloud/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;EAqBpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;iBAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;iBAA4D,CAAC;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AACpF,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAExD,6DAA6D;AAC7D,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAgBjD,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Stable error codes. Clients branch on `code`, never on `message`.
4
+ * Codes that describe a refused sync action are never retried blindly: the client must
5
+ * reassess (pull, then re-verify) first.
6
+ */
7
+ export const ErrorCode = z.enum([
8
+ 'E_VALIDATION',
9
+ 'E_UNAUTHENTICATED',
10
+ 'E_FORBIDDEN',
11
+ 'E_NOT_FOUND',
12
+ 'E_CONFLICT',
13
+ 'E_RATE_LIMITED',
14
+ 'E_PAYLOAD_TOO_LARGE',
15
+ /** The manifest does not descend from the stream's current head checkpoint. */
16
+ 'E_LINEAGE',
17
+ /** The manifest loses rows that no tombstone in the covered segments accounts for. */
18
+ 'E_REGRESSION',
19
+ /** A segment or manifest uses a schemaVersion newer than the stream accepts. It is quarantined, never dropped. */
20
+ 'E_SCHEMA_AHEAD',
21
+ /** Another replica holds the exporter lease for this stream. */
22
+ 'E_LEASE_HELD',
23
+ /** The referenced blob has not been uploaded and verified yet. */
24
+ 'E_BLOB_MISSING',
25
+ 'E_BLOB_INTEGRITY',
26
+ 'E_UNAVAILABLE',
27
+ 'E_INTERNAL',
28
+ ]);
29
+ export const ErrorBody = z.object({
30
+ code: ErrorCode,
31
+ message: z.string(),
32
+ requestId: z.string(),
33
+ details: z.record(z.string(), z.unknown()).optional(),
34
+ });
35
+ export const ErrorEnvelope = z.object({ success: z.literal(false), error: ErrorBody });
36
+ /** HTTP status for each code, so server and client agree. */
37
+ export const errorStatus = {
38
+ E_VALIDATION: 400,
39
+ E_UNAUTHENTICATED: 401,
40
+ E_FORBIDDEN: 403,
41
+ E_NOT_FOUND: 404,
42
+ E_CONFLICT: 409,
43
+ E_LINEAGE: 409,
44
+ E_REGRESSION: 409,
45
+ E_LEASE_HELD: 409,
46
+ E_SCHEMA_AHEAD: 422,
47
+ E_BLOB_MISSING: 424,
48
+ E_BLOB_INTEGRITY: 422,
49
+ E_PAYLOAD_TOO_LARGE: 413,
50
+ E_RATE_LIMITED: 429,
51
+ E_UNAVAILABLE: 503,
52
+ E_INTERNAL: 500,
53
+ };
54
+ //# sourceMappingURL=envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/cloud/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9B,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,qBAAqB;IACrB,+EAA+E;IAC/E,WAAW;IACX,sFAAsF;IACtF,cAAc;IACd,kHAAkH;IAClH,gBAAgB;IAChB,gEAAgE;IAChE,cAAc;IACd,kEAAkE;IAClE,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;IACf,YAAY;CACb,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACtD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAMvF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,WAAW,GAA8B;IACpD,YAAY,EAAE,GAAG;IACjB,iBAAiB,EAAE,GAAG;IACtB,WAAW,EAAE,GAAG;IAChB,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,GAAG;IACf,SAAS,EAAE,GAAG;IACd,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE,GAAG;IACjB,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,GAAG;IACrB,mBAAmB,EAAE,GAAG;IACxB,cAAc,EAAE,GAAG;IACnB,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,GAAG;CAChB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * A CLEO project id, read from `.cleo/project-id` (write-once, ADR-094 / T12325).
4
+ * New projects use a UUID. Older projects carry a 12-hex id. Paths are never identity.
5
+ */
6
+ export declare const ProjectId: z.ZodString;
7
+ export type ProjectId = z.infer<typeof ProjectId>;
8
+ /** A replica is one `cleo.db` store (per store, not per machine; worktree copies are separate replicas). */
9
+ export declare const ReplicaId: z.ZodString;
10
+ export type ReplicaId = z.infer<typeof ReplicaId>;
11
+ export declare const DeviceId: z.ZodString;
12
+ export type DeviceId = z.infer<typeof DeviceId>;
13
+ export declare const Sha256Hex: z.ZodString;
14
+ export type Sha256Hex = z.infer<typeof Sha256Hex>;
15
+ /**
16
+ * A journal stream. `project:<projectId>` carries portable·project ops. `home:<userId>` carries
17
+ * portable·personal ops for one account.
18
+ */
19
+ export declare const StreamId: z.ZodString;
20
+ export type StreamId = z.infer<typeof StreamId>;
21
+ /**
22
+ * Hybrid logical clock, encoded so that lexical order is causal order:
23
+ * 13-digit zero-padded wall millis, 6-digit counter, and the replica id, joined by '-'. Example:
24
+ * 1790545492500-000003-0192f1c2-....
25
+ */
26
+ export declare const Hlc: z.ZodString;
27
+ export type Hlc = z.infer<typeof Hlc>;
28
+ /** Base64 (standard alphabet, padded). Used for ciphertext and wrapped keys on the wire. */
29
+ export declare const Base64: z.ZodString;
30
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/cloud/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;GAGG;AACH,eAAO,MAAM,SAAS,aAKnB,CAAC;AACJ,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,4GAA4G;AAC5G,eAAO,MAAM,SAAS,aAA4D,CAAC;AACnF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,QAAQ,aAAsD,CAAC;AAC5E,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS,aAAgE,CAAC;AACvF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,QAAQ,aAKlB,CAAC;AACJ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,GAAG,aAA8E,CAAC;AAC/F,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;AAEtC,4FAA4F;AAC5F,eAAO,MAAM,MAAM,aAAgE,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
3
+ const UUID_V7 = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
4
+ const LEGACY_PROJECT_ID = /^[0-9a-f]{12}$/;
5
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
6
+ /**
7
+ * A CLEO project id, read from `.cleo/project-id` (write-once, ADR-094 / T12325).
8
+ * New projects use a UUID. Older projects carry a 12-hex id. Paths are never identity.
9
+ */
10
+ export const ProjectId = z
11
+ .string()
12
+ .refine((s) => UUID.test(s) || LEGACY_PROJECT_ID.test(s), 'expected a UUID or legacy 12-hex project id');
13
+ /** A replica is one `cleo.db` store (per store, not per machine; worktree copies are separate replicas). */
14
+ export const ReplicaId = z.string().regex(UUID_V7, 'expected a UUIDv7 replica id');
15
+ export const DeviceId = z.string().regex(UUID, 'expected a UUID device id');
16
+ export const Sha256Hex = z.string().regex(SHA256_HEX, 'expected lowercase hex sha256');
17
+ /**
18
+ * A journal stream. `project:<projectId>` carries portable·project ops. `home:<userId>` carries
19
+ * portable·personal ops for one account.
20
+ */
21
+ export const StreamId = z
22
+ .string()
23
+ .regex(/^(project:[0-9a-f-]{12,36}|home:[A-Za-z0-9_-]{8,64})$/, 'expected project:<id> or home:<userId>');
24
+ /**
25
+ * Hybrid logical clock, encoded so that lexical order is causal order:
26
+ * 13-digit zero-padded wall millis, 6-digit counter, and the replica id, joined by '-'. Example:
27
+ * 1790545492500-000003-0192f1c2-....
28
+ */
29
+ export const Hlc = z.string().regex(/^\d{13}-\d{6}-[0-9a-f-]{36}$/, 'expected an encoded HLC');
30
+ /** Base64 (standard alphabet, padded). Used for ciphertext and wrapped keys on the wire. */
31
+ export const Base64 = z.string().regex(/^[A-Za-z0-9+/]*={0,2}$/, 'expected base64');
32
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/cloud/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,gEAAgE,CAAC;AAC9E,MAAM,OAAO,GAAG,uEAAuE,CAAC;AACxF,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,MAAM,EAAE;KACR,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAChD,6CAA6C,CAC9C,CAAC;AAGJ,4GAA4G;AAC5G,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC;AAGnF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAC;AAG5E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,+BAA+B,CAAC,CAAC;AAGvF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC;KACtB,MAAM,EAAE;KACR,KAAK,CACJ,uDAAuD,EACvD,wCAAwC,CACzC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