@heynixie/contract 0.68.0 → 0.69.0

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.
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ function mergeSpans(spans) {
150
150
  var clientHeaderName = "x-nixie-client";
151
151
  // src/contract.ts
152
152
  import { eventIterator as eventIterator2, oc as oc2 } from "@orpc/contract";
153
- import { z as z9 } from "zod";
153
+ import { z as z11 } from "zod";
154
154
 
155
155
  // src/image-limits.ts
156
156
  var imageLimits = {
@@ -179,11 +179,21 @@ var imageRefusedError = {
179
179
  };
180
180
 
181
181
  // src/memory-view-contract.ts
182
- import { z as z5 } from "zod";
182
+ import { z as z6 } from "zod";
183
+
184
+ // src/forget-backup-schema.ts
185
+ import { z as z2 } from "zod";
186
+ var forgetBackupSchema = z2.discriminatedUnion("state", [
187
+ z2.object({ state: z2.literal("off") }),
188
+ z2.object({ state: z2.literal("pending") }),
189
+ z2.object({ state: z2.literal("failed"), failure: z2.string() }),
190
+ z2.object({ state: z2.literal("complete") }),
191
+ z2.object({ state: z2.literal("unknown") })
192
+ ]);
183
193
 
184
194
  // src/memory-export-contract.ts
185
195
  import { eventIterator } from "@orpc/contract";
186
- import { z as z2 } from "zod";
196
+ import { z as z3 } from "zod";
187
197
 
188
198
  // src/reused-id-errors.ts
189
199
  var reusedIDErrors = {
@@ -203,42 +213,42 @@ var signedIn = oc.errors({
203
213
  var checkedExport = signedIn.errors(reusedIDErrors).errors({
204
214
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
205
215
  });
206
- var exportEvent = z2.union([
207
- z2.object({ chunk: z2.string() }),
208
- z2.object({ isComplete: z2.literal(true) })
216
+ var exportEvent = z3.union([
217
+ z3.object({ chunk: z3.string() }),
218
+ z3.object({ isComplete: z3.literal(true) })
209
219
  ]);
210
220
  var exportEvents = eventIterator(exportEvent);
211
221
  var memoryExportContract = {
212
- export: checkedExport.input(z2.object({ clientActionID: z2.uuid() })).output(exportEvents)
222
+ export: checkedExport.input(z3.object({ clientActionID: z3.uuid() })).output(exportEvents)
213
223
  };
214
224
 
215
225
  // src/moment-contract.ts
216
- import { z as z3 } from "zod";
226
+ import { z as z4 } from "zod";
217
227
  var momentView = signedIn.errors({
218
228
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 },
219
229
  MOMENT_NOT_FOUND: { message: "No moment has this ID", status: 404 },
220
230
  STALE_VERSION: { message: "The moment has moved past that version", status: 409 }
221
231
  });
222
- var momentIDSchema = z3.string().min(1).max(200);
223
- var momentTargetSchema = z3.object({ momentID: momentIDSchema, version: z3.int().positive() });
224
- var reflectionSchema = z3.object({
225
- model: z3.string(),
226
- text: z3.string().nullable(),
227
- writtenAt: z3.date()
228
- });
229
- var destroyPreviewSchema = z3.object({
230
- keptAt: z3.date(),
231
- keptBy: z3.enum(["owner", "model"]),
232
- kept: z3.object({ records: z3.int().nonnegative() }),
233
- lost: z3.object({ links: z3.int().nonnegative(), texts: z3.int().nonnegative() }),
234
- momentID: z3.string(),
235
- note: z3.string().nullable(),
236
- reflections: z3.array(reflectionSchema),
237
- shortID: z3.string(),
238
- state: z3.enum(["active", "retired"]),
239
- thread: z3.string(),
240
- title: z3.string().nullable(),
241
- version: z3.int().positive()
232
+ var momentIDSchema = z4.string().min(1).max(200);
233
+ var momentTargetSchema = z4.object({ momentID: momentIDSchema, version: z4.int().positive() });
234
+ var reflectionSchema = z4.object({
235
+ model: z4.string(),
236
+ text: z4.string().nullable(),
237
+ writtenAt: z4.date()
238
+ });
239
+ var destroyPreviewSchema = z4.object({
240
+ keptAt: z4.date(),
241
+ keptBy: z4.enum(["owner", "model"]),
242
+ kept: z4.object({ records: z4.int().nonnegative() }),
243
+ lost: z4.object({ links: z4.int().nonnegative(), texts: z4.int().nonnegative() }),
244
+ momentID: z4.string(),
245
+ note: z4.string().nullable(),
246
+ reflections: z4.array(reflectionSchema),
247
+ shortID: z4.string(),
248
+ state: z4.enum(["active", "retired"]),
249
+ thread: z4.string(),
250
+ title: z4.string().nullable(),
251
+ version: z4.int().positive()
242
252
  });
243
253
  var momentKeep = signedIn.errors(reusedIDErrors).errors({
244
254
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 },
@@ -247,113 +257,113 @@ var momentKeep = signedIn.errors(reusedIDErrors).errors({
247
257
  status: 422
248
258
  }
249
259
  });
250
- var titleSchema = z3.string().min(1).max(120).regex(/\S/u);
251
- var keepSchema = z3.object({
252
- clientActionID: z3.uuid(),
253
- firstSequence: z3.int().nonnegative(),
254
- lastSequence: z3.int().nonnegative(),
255
- thread: z3.string().min(1).max(200),
260
+ var titleSchema = z4.string().min(1).max(120).regex(/\S/u);
261
+ var keepSchema = z4.object({
262
+ clientActionID: z4.uuid(),
263
+ firstSequence: z4.int().nonnegative(),
264
+ lastSequence: z4.int().nonnegative(),
265
+ thread: z4.string().min(1).max(200),
256
266
  title: titleSchema
257
267
  });
258
- var momentSummarySchema = z3.object({
259
- editedAt: z3.date().nullable(),
260
- keptAt: z3.date(),
261
- keptBy: z3.enum(["owner", "model"]),
262
- momentID: z3.string(),
263
- shortID: z3.string(),
264
- state: z3.enum(["active", "retired"]),
265
- title: z3.string().nullable()
266
- });
267
- var momentListSchema = z3.object({
268
- before: z3.int().nonnegative().optional(),
269
- includeRetired: z3.boolean(),
270
- query: z3.string().max(500).optional()
271
- });
272
- var linkSchema = z3.object({
273
- itemID: z3.string(),
274
- shortID: z3.string(),
275
- text: z3.string().nullable()
276
- });
277
- var noteSchema = z3.object({ text: z3.string(), writtenAt: z3.date() });
278
- var shownReflectionSchema = reflectionSchema.extend({ reflectionID: z3.string() });
268
+ var momentSummarySchema = z4.object({
269
+ editedAt: z4.date().nullable(),
270
+ keptAt: z4.date(),
271
+ keptBy: z4.enum(["owner", "model"]),
272
+ momentID: z4.string(),
273
+ shortID: z4.string(),
274
+ state: z4.enum(["active", "retired"]),
275
+ title: z4.string().nullable()
276
+ });
277
+ var momentListSchema = z4.object({
278
+ before: z4.int().nonnegative().optional(),
279
+ includeRetired: z4.boolean(),
280
+ query: z4.string().max(500).optional()
281
+ });
282
+ var linkSchema = z4.object({
283
+ itemID: z4.string(),
284
+ shortID: z4.string(),
285
+ text: z4.string().nullable()
286
+ });
287
+ var noteSchema = z4.object({ text: z4.string(), writtenAt: z4.date() });
288
+ var shownReflectionSchema = reflectionSchema.extend({ reflectionID: z4.string() });
279
289
  var momentDetailSchema = momentSummarySchema.extend({
280
- firstSequence: z3.int().nonnegative(),
281
- lastSequence: z3.int().nonnegative(),
282
- links: z3.array(linkSchema),
290
+ firstSequence: z4.int().nonnegative(),
291
+ lastSequence: z4.int().nonnegative(),
292
+ links: z4.array(linkSchema),
283
293
  note: noteSchema.nullable(),
284
- reflections: z3.array(shownReflectionSchema),
285
- thread: z3.string(),
286
- titleBy: z3.enum(["owner", "model"]),
287
- version: z3.int().positive()
288
- });
289
- var spanRecordSchema = z3.object({
290
- isGap: z3.boolean(),
291
- kind: z3.string(),
292
- recordedAt: z3.date(),
293
- sequence: z3.int().nonnegative(),
294
- text: z3.string().nullable(),
295
- tool: z3.string().nullable()
296
- });
297
- var momentChangeSchema = z3.discriminatedUnion("kind", [
298
- z3.object({ kind: z3.literal("title"), title: titleSchema }),
299
- z3.object({
300
- kind: z3.literal("edges"),
301
- firstSequence: z3.int().nonnegative(),
302
- lastSequence: z3.int().nonnegative()
294
+ reflections: z4.array(shownReflectionSchema),
295
+ thread: z4.string(),
296
+ titleBy: z4.enum(["owner", "model"]),
297
+ version: z4.int().positive()
298
+ });
299
+ var spanRecordSchema = z4.object({
300
+ isGap: z4.boolean(),
301
+ kind: z4.string(),
302
+ recordedAt: z4.date(),
303
+ sequence: z4.int().nonnegative(),
304
+ text: z4.string().nullable(),
305
+ tool: z4.string().nullable()
306
+ });
307
+ var momentChangeSchema = z4.discriminatedUnion("kind", [
308
+ z4.object({ kind: z4.literal("title"), title: titleSchema }),
309
+ z4.object({
310
+ kind: z4.literal("edges"),
311
+ firstSequence: z4.int().nonnegative(),
312
+ lastSequence: z4.int().nonnegative()
303
313
  }),
304
- z3.object({ kind: z3.literal("note"), note: z3.string().min(1).max(4000).regex(/\S/u) }),
305
- z3.object({ kind: z3.literal("reflection_removed"), reflectionID: z3.string().min(1).max(200) })
314
+ z4.object({ kind: z4.literal("note"), note: z4.string().min(1).max(4000).regex(/\S/u) }),
315
+ z4.object({ kind: z4.literal("reflection_removed"), reflectionID: z4.string().min(1).max(200) })
306
316
  ]);
307
317
  var momentChange = momentView.errors(reusedIDErrors);
308
318
  var momentContract = {
309
- keepMoment: momentKeep.input(keepSchema).output(z3.object({ momentID: z3.string(), shortID: z3.string() })),
319
+ keepMoment: momentKeep.input(keepSchema).output(z4.object({ momentID: z4.string(), shortID: z4.string() })),
310
320
  listMoments: signedIn.errors({
311
321
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
312
- }).input(momentListSchema).output(z3.object({ moments: z3.array(momentSummarySchema), next: z3.int().nonnegative().nullable() })),
313
- readMoment: momentView.input(z3.object({ momentID: momentIDSchema })).output(momentDetailSchema),
314
- readMomentSpan: momentView.input(z3.object({ momentID: momentIDSchema, after: z3.int().nonnegative().optional() })).output(z3.object({ records: z3.array(spanRecordSchema), next: z3.int().nonnegative().nullable() })),
322
+ }).input(momentListSchema).output(z4.object({ moments: z4.array(momentSummarySchema), next: z4.int().nonnegative().nullable() })),
323
+ readMoment: momentView.input(z4.object({ momentID: momentIDSchema })).output(momentDetailSchema),
324
+ readMomentSpan: momentView.input(z4.object({ momentID: momentIDSchema, after: z4.int().nonnegative().optional() })).output(z4.object({ records: z4.array(spanRecordSchema), next: z4.int().nonnegative().nullable() })),
315
325
  editMoment: momentChange.errors({
316
326
  BAD_SPAN: {
317
327
  message: "The span needs a first and a last record on the thread, in order",
318
328
  status: 422
319
329
  },
320
330
  REFLECTION_NOT_FOUND: { message: "The moment has no reflection with this ID", status: 404 }
321
- }).input(momentTargetSchema.extend({ clientActionID: z3.uuid(), change: momentChangeSchema })).output(z3.object({ momentID: z3.string(), version: z3.int().positive() })),
331
+ }).input(momentTargetSchema.extend({ clientActionID: z4.uuid(), change: momentChangeSchema })).output(z4.object({ momentID: z4.string(), version: z4.int().positive() })),
322
332
  linkMoment: momentChange.errors({
323
333
  MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 },
324
334
  ALREADY_LINKED: { message: "The item is already linked to the moment", status: 409 },
325
335
  NOT_LINKED: { message: "The item is not linked to the moment", status: 409 }
326
336
  }).input(momentTargetSchema.extend({
327
- clientActionID: z3.uuid(),
328
- isLinked: z3.boolean(),
329
- itemID: z3.string().min(1).max(200)
330
- })).output(z3.object({ momentID: z3.string(), version: z3.int().positive() })),
337
+ clientActionID: z4.uuid(),
338
+ isLinked: z4.boolean(),
339
+ itemID: z4.string().min(1).max(200)
340
+ })).output(z4.object({ momentID: z4.string(), version: z4.int().positive() })),
331
341
  previewMomentDestroy: momentView.input(momentTargetSchema).output(destroyPreviewSchema),
332
- destroyMoment: momentView.errors(reusedIDErrors).input(momentTargetSchema.extend({ clientActionID: z3.uuid() })).output(z3.object({ momentID: z3.string() }))
342
+ destroyMoment: momentView.errors(reusedIDErrors).input(momentTargetSchema.extend({ clientActionID: z4.uuid() })).output(z4.object({ momentID: z4.string() }))
333
343
  };
334
344
 
335
345
  // src/proposal-outcome-schema.ts
336
- import { z as z4 } from "zod";
337
- var closeMatchSchema = z4.object({
338
- itemID: z4.string(),
339
- text: z4.string(),
340
- version: z4.int().positive()
346
+ import { z as z5 } from "zod";
347
+ var closeMatchSchema = z5.object({
348
+ itemID: z5.string(),
349
+ text: z5.string(),
350
+ version: z5.int().positive()
341
351
  });
342
- var proposalOutcomeSchema = z4.discriminatedUnion("status", [
343
- z4.object({ proposalID: z4.string(), status: z4.literal("applied") }),
344
- z4.object({ proposalID: z4.string(), status: z4.literal("rejected") }),
345
- z4.object({
352
+ var proposalOutcomeSchema = z5.discriminatedUnion("status", [
353
+ z5.object({ proposalID: z5.string(), status: z5.literal("applied") }),
354
+ z5.object({ proposalID: z5.string(), status: z5.literal("rejected") }),
355
+ z5.object({
346
356
  item: closeMatchSchema,
347
- proposalID: z4.string(),
348
- status: z4.literal("close_match")
357
+ proposalID: z5.string(),
358
+ status: z5.literal("close_match")
349
359
  }),
350
- z4.object({
351
- cause: z4.enum(["lapsed", "answered", "moved", "changed", "gone"]),
352
- proposalID: z4.string(),
353
- status: z4.literal("stale")
360
+ z5.object({
361
+ cause: z5.enum(["lapsed", "answered", "moved", "changed", "gone"]),
362
+ proposalID: z5.string(),
363
+ status: z5.literal("stale")
354
364
  }),
355
- z4.object({
356
- code: z4.enum([
365
+ z5.object({
366
+ code: z5.enum([
357
367
  "CLIENT_ACTION_ID_REUSED",
358
368
  "PIN_EDIT",
359
369
  "PINNED_CORE_FULL",
@@ -361,8 +371,8 @@ var proposalOutcomeSchema = z4.discriminatedUnion("status", [
361
371
  "REVISION_TARGET",
362
372
  "WRONG_STATE"
363
373
  ]),
364
- proposalID: z4.string(),
365
- status: z4.literal("refused")
374
+ proposalID: z5.string(),
375
+ status: z5.literal("refused")
366
376
  })
367
377
  ]);
368
378
 
@@ -375,68 +385,68 @@ var memoryChange = memoryView.errors(reusedIDErrors).errors({
375
385
  STALE_VERSION: { message: "The memory item has moved past that version", status: 409 },
376
386
  WRONG_STATE: { message: "The memory item is not in a state that change takes", status: 409 }
377
387
  });
378
- var itemIDSchema = z5.string().min(1).max(200);
379
- var itemTextSchema = z5.string().max(2000).regex(/\S/u);
380
- var proposalOriginSchema = z5.enum(["owner", "conversation", "task", "memory_writer"]);
381
- var originSchema = z5.enum([...proposalOriginSchema.options, "lapse"]);
382
- var sourceSchema = z5.enum(["owner", "owner_data", "untrusted"]);
383
- var subjectSchema = z5.enum(["owner", "self", "shared"]);
384
- var kindSchema = z5.enum(["fact", "self"]);
385
- var memoryItemSchema = z5.object({
386
- changedAt: z5.date(),
387
- createdAt: z5.date(),
388
- forgottenAt: z5.date().nullable(),
389
- isPinned: z5.boolean(),
390
- isSensitive: z5.boolean(),
391
- itemID: z5.string(),
388
+ var itemIDSchema = z6.string().min(1).max(200);
389
+ var itemTextSchema = z6.string().max(2000).regex(/\S/u);
390
+ var proposalOriginSchema = z6.enum(["owner", "conversation", "task", "memory_writer"]);
391
+ var originSchema = z6.enum([...proposalOriginSchema.options, "lapse"]);
392
+ var sourceSchema = z6.enum(["owner", "owner_data", "untrusted"]);
393
+ var subjectSchema = z6.enum(["owner", "self", "shared"]);
394
+ var kindSchema = z6.enum(["fact", "self"]);
395
+ var memoryItemSchema = z6.object({
396
+ changedAt: z6.date(),
397
+ createdAt: z6.date(),
398
+ forgottenAt: z6.date().nullable(),
399
+ isPinned: z6.boolean(),
400
+ isSensitive: z6.boolean(),
401
+ itemID: z6.string(),
392
402
  kind: kindSchema,
393
403
  origin: originSchema,
394
- shortID: z5.string(),
404
+ shortID: z6.string(),
395
405
  source: sourceSchema,
396
- state: z5.enum(["active", "retired", "forgetting", "forgotten"]),
397
- status: z5.enum(["readable", "shredded", "unreadable"]),
406
+ state: z6.enum(["active", "retired", "forgetting", "forgotten"]),
407
+ status: z6.enum(["readable", "shredded", "unreadable"]),
398
408
  subject: subjectSchema,
399
- text: z5.string().optional(),
400
- until: z5.date().nullable(),
401
- version: z5.int().positive()
409
+ text: z6.string().optional(),
410
+ until: z6.date().nullable(),
411
+ version: z6.int().positive()
402
412
  });
403
413
  var memoryMatchSchema = memoryItemSchema.extend({
404
- score: z5.number().optional(),
405
- similarity: z5.number().optional()
406
- });
407
- var evidenceSchema = z5.object({
408
- end: z5.int().nonnegative(),
409
- message: z5.object({
410
- status: z5.enum(["readable", "shredded", "unreadable", "missing"]),
411
- text: z5.string().optional()
414
+ score: z6.number().optional(),
415
+ similarity: z6.number().optional()
416
+ });
417
+ var evidenceSchema = z6.object({
418
+ end: z6.int().nonnegative(),
419
+ message: z6.object({
420
+ status: z6.enum(["readable", "shredded", "unreadable", "missing"]),
421
+ text: z6.string().optional()
412
422
  }).nullable(),
413
- sequence: z5.int().nonnegative(),
414
- start: z5.int().nonnegative()
415
- });
416
- var ownerImageSchema = z5.object({
417
- position: z5.int().nonnegative(),
418
- sequence: z5.int().positive(),
419
- thread: z5.string()
420
- });
421
- var memoryVersionSchema = z5.object({
422
- change: z5.enum(["created", "edited", "retired", "restored", "undone"]),
423
- checkerModel: z5.string().nullable(),
424
- checks: z5.record(z5.string(), z5.unknown()).nullable(),
423
+ sequence: z6.int().nonnegative(),
424
+ start: z6.int().nonnegative()
425
+ });
426
+ var ownerImageSchema = z6.object({
427
+ position: z6.int().nonnegative(),
428
+ sequence: z6.int().positive(),
429
+ thread: z6.string()
430
+ });
431
+ var memoryVersionSchema = z6.object({
432
+ change: z6.enum(["created", "edited", "retired", "restored", "undone"]),
433
+ checkerModel: z6.string().nullable(),
434
+ checks: z6.record(z6.string(), z6.unknown()).nullable(),
425
435
  evidence: evidenceSchema.nullable(),
426
- evidenceQuote: z5.string().nullable(),
436
+ evidenceQuote: z6.string().nullable(),
427
437
  image: ownerImageSchema.nullable(),
428
438
  origin: originSchema,
429
- proposalID: z5.string().nullable(),
430
- recordedAt: z5.date(),
439
+ proposalID: z6.string().nullable(),
440
+ recordedAt: z6.date(),
431
441
  source: sourceSchema,
432
- state: z5.enum(["active", "retired"]),
433
- status: z5.enum(["readable", "shredded", "unreadable"]),
434
- taskID: z5.string().nullable(),
435
- text: z5.string().optional(),
436
- version: z5.int().positive(),
437
- writerModel: z5.string().nullable()
438
- });
439
- var reviewReasonSchema = z5.enum([
442
+ state: z6.enum(["active", "retired"]),
443
+ status: z6.enum(["readable", "shredded", "unreadable"]),
444
+ taskID: z6.string().nullable(),
445
+ text: z6.string().optional(),
446
+ version: z6.int().positive(),
447
+ writerModel: z6.string().nullable()
448
+ });
449
+ var reviewReasonSchema = z6.enum([
440
450
  "no_quote",
441
451
  "quote_not_typed",
442
452
  "quote_in_quoted_block",
@@ -454,115 +464,116 @@ var reviewReasonSchema = z5.enum([
454
464
  "sensitive",
455
465
  "subject_change"
456
466
  ]);
457
- var proposalSourceSchema = z5.object({
467
+ var proposalSourceSchema = z6.object({
458
468
  origin: proposalOriginSchema,
459
- proposedAt: z5.date(),
460
- thread: z5.string().nullable()
469
+ proposedAt: z6.date(),
470
+ thread: z6.string().nullable()
461
471
  });
462
- var memoryProposalSchema = z5.object({
463
- actionHash: z5.string(),
464
- createdAt: z5.date(),
472
+ var memoryProposalSchema = z6.object({
473
+ actionHash: z6.string(),
474
+ createdAt: z6.date(),
465
475
  evidence: evidenceSchema.nullable(),
466
476
  image: ownerImageSchema.nullable(),
467
- isPinned: z5.boolean(),
468
- isSensitive: z5.boolean(),
469
- itemID: z5.string(),
477
+ isPinned: z6.boolean(),
478
+ isSensitive: z6.boolean(),
479
+ itemID: z6.string(),
470
480
  kind: kindSchema,
471
- lapseAt: z5.date(),
481
+ lapseAt: z6.date(),
472
482
  newSubject: subjectSchema.nullable(),
473
- operation: z5.enum(["remember", "retire", "pin"]),
483
+ operation: z6.enum(["remember", "retire", "pin"]),
474
484
  origin: proposalOriginSchema,
475
- proposalID: z5.string(),
476
- quote: z5.string().nullable(),
485
+ proposalID: z6.string(),
486
+ quote: z6.string().nullable(),
477
487
  reason: reviewReasonSchema,
478
488
  source: sourceSchema,
479
- sources: z5.array(proposalSourceSchema),
489
+ sources: z6.array(proposalSourceSchema),
480
490
  subject: subjectSchema,
481
- targetVersion: z5.int().positive().nullable(),
482
- text: z5.string(),
483
- until: z5.date().nullable()
491
+ targetVersion: z6.int().positive().nullable(),
492
+ text: z6.string(),
493
+ until: z6.date().nullable()
484
494
  });
485
- var proposalAnswerSchema = z5.object({
486
- actionHash: z5.string().min(1).max(200),
487
- clientActionID: z5.uuid(),
488
- proposalID: z5.string().min(1).max(200)
495
+ var proposalAnswerSchema = z6.object({
496
+ actionHash: z6.string().min(1).max(200),
497
+ clientActionID: z6.uuid(),
498
+ proposalID: z6.string().min(1).max(200)
489
499
  });
490
- var revisionTargetSchema = z5.object({ itemID: itemIDSchema, version: z5.int().positive() });
500
+ var revisionTargetSchema = z6.object({ itemID: itemIDSchema, version: z6.int().positive() });
491
501
  var approvalAnswerSchema = proposalAnswerSchema.extend({
492
502
  editedText: itemTextSchema.optional(),
493
- ignoreCloseMatch: z5.boolean().optional(),
503
+ ignoreCloseMatch: z6.boolean().optional(),
494
504
  revisionOf: revisionTargetSchema.optional()
495
505
  });
496
- var rejectionReasonSchema = z5.string().max(500).regex(/\S/u);
506
+ var rejectionReasonSchema = z6.string().max(500).regex(/\S/u);
497
507
  var rejectionAnswerSchema = proposalAnswerSchema.extend({
498
508
  reason: rejectionReasonSchema.optional()
499
509
  });
500
- var proposalOutcomesSchema = z5.object({ outcomes: z5.array(proposalOutcomeSchema) });
501
- var memoryItemDetailSchema = memoryItemSchema.extend({ versions: z5.array(memoryVersionSchema) });
502
- var forgetLossSchema = z5.object({
503
- evidenceMessages: z5.int().nonnegative(),
504
- proposals: z5.int().nonnegative()
510
+ var proposalOutcomesSchema = z6.object({ outcomes: z6.array(proposalOutcomeSchema) });
511
+ var memoryItemDetailSchema = memoryItemSchema.extend({ versions: z6.array(memoryVersionSchema) });
512
+ var forgetLossSchema = z6.object({
513
+ evidenceMessages: z6.int().nonnegative(),
514
+ proposals: z6.int().nonnegative()
505
515
  });
506
516
  var forgetPreviewSchema = memoryItemDetailSchema.extend({ lost: forgetLossSchema });
507
- var retiredForgetPreviewSchema = z5.object({
508
- hasMore: z5.boolean(),
509
- items: z5.array(memoryItemSchema.extend({ lost: forgetLossSchema }))
517
+ var retiredForgetPreviewSchema = z6.object({
518
+ hasMore: z6.boolean(),
519
+ items: z6.array(memoryItemSchema.extend({ lost: forgetLossSchema }))
510
520
  });
511
- var retiredForgetSchema = z5.object({
512
- clientActionID: z5.uuid(),
513
- targets: z5.array(revisionTargetSchema).min(1).max(100).refine((targets) => new Set(targets.map((target) => target.itemID)).size === targets.length, {
521
+ var retiredForgetSchema = z6.object({
522
+ clientActionID: z6.uuid(),
523
+ targets: z6.array(revisionTargetSchema).min(1).max(100).refine((targets) => new Set(targets.map((target) => target.itemID)).size === targets.length, {
514
524
  message: "Each item appears once"
515
525
  })
516
526
  });
517
- var forgetStatusSchema = z5.object({
518
- deleted: z5.array(z5.string()),
519
- pending: z5.array(z5.string())
527
+ var forgetStatusSchema = z6.object({
528
+ deleted: z6.array(z6.string()),
529
+ pending: z6.array(z6.string()),
530
+ backup: forgetBackupSchema
520
531
  });
521
- var versionTargetSchema = z5.object({
522
- clientActionID: z5.uuid(),
532
+ var versionTargetSchema = z6.object({
533
+ clientActionID: z6.uuid(),
523
534
  itemID: itemIDSchema,
524
- version: z5.int().positive()
525
- });
526
- var versionResultSchema = z5.object({ itemID: z5.string(), version: z5.int().positive() });
527
- var noticeEntrySchema = z5.object({
528
- change: z5.enum(["created", "edited", "retired", "restored", "undone", "proposed"]),
529
- isKept: z5.boolean(),
530
- item: memoryItemSchema.extend({ change: z5.enum(["created", "edited", "retired", "restored", "undone"]) }).nullable(),
531
- itemID: z5.string(),
532
- proposalID: z5.string().nullable(),
533
- sequence: z5.int().nonnegative(),
534
- version: z5.int().positive().nullable()
535
- });
536
- var memoryNoticeSchema = z5.object({
537
- entries: z5.array(noticeEntrySchema),
538
- kind: z5.enum(["turn", "batch", "catch_up", "run"]),
539
- messageSequence: z5.int().nonnegative().nullable(),
540
- noticeKey: z5.string(),
541
- proposed: z5.int().nonnegative(),
542
- remembered: z5.int().nonnegative(),
543
- retired: z5.int().nonnegative(),
544
- sequence: z5.int().nonnegative()
535
+ version: z6.int().positive()
536
+ });
537
+ var versionResultSchema = z6.object({ itemID: z6.string(), version: z6.int().positive() });
538
+ var noticeEntrySchema = z6.object({
539
+ change: z6.enum(["created", "edited", "retired", "restored", "undone", "proposed"]),
540
+ isKept: z6.boolean(),
541
+ item: memoryItemSchema.extend({ change: z6.enum(["created", "edited", "retired", "restored", "undone"]) }).nullable(),
542
+ itemID: z6.string(),
543
+ proposalID: z6.string().nullable(),
544
+ sequence: z6.int().nonnegative(),
545
+ version: z6.int().positive().nullable()
546
+ });
547
+ var memoryNoticeSchema = z6.object({
548
+ entries: z6.array(noticeEntrySchema),
549
+ kind: z6.enum(["turn", "batch", "catch_up", "run"]),
550
+ messageSequence: z6.int().nonnegative().nullable(),
551
+ noticeKey: z6.string(),
552
+ proposed: z6.int().nonnegative(),
553
+ remembered: z6.int().nonnegative(),
554
+ retired: z6.int().nonnegative(),
555
+ sequence: z6.int().nonnegative()
545
556
  });
546
557
  var memoryViewContract = {
547
- listItems: memoryView.errors({ INVALID_CURSOR: { message: "No page returned this cursor", status: 400 } }).input(z5.object({
548
- after: z5.string().max(20).optional(),
558
+ listItems: memoryView.errors({ INVALID_CURSOR: { message: "No page returned this cursor", status: 400 } }).input(z6.object({
559
+ after: z6.string().max(20).optional(),
549
560
  kind: kindSchema.optional(),
550
- limit: z5.int().min(1).max(100).optional(),
551
- state: z5.enum(["active", "retired", "forgotten"])
552
- })).output(z5.object({ items: z5.array(memoryItemSchema), next: z5.string().nullable() })),
553
- findItems: memoryView.input(z5.object({ query: z5.string().min(1).max(500) })).output(z5.object({
554
- items: z5.array(memoryMatchSchema),
555
- searchMode: z5.enum(["hybrid", "keyword", "keyword-fallback"])
561
+ limit: z6.int().min(1).max(100).optional(),
562
+ state: z6.enum(["active", "retired", "forgotten"])
563
+ })).output(z6.object({ items: z6.array(memoryItemSchema), next: z6.string().nullable() })),
564
+ findItems: memoryView.input(z6.object({ query: z6.string().min(1).max(500) })).output(z6.object({
565
+ items: z6.array(memoryMatchSchema),
566
+ searchMode: z6.enum(["hybrid", "keyword", "keyword-fallback"])
556
567
  })),
557
- readPinnedCore: memoryView.output(z5.object({
558
- budget: z5.int().nonnegative(),
559
- items: z5.array(memoryItemSchema),
560
- tokens: z5.int().nonnegative()
568
+ readPinnedCore: memoryView.output(z6.object({
569
+ budget: z6.int().nonnegative(),
570
+ items: z6.array(memoryItemSchema),
571
+ tokens: z6.int().nonnegative()
561
572
  })),
562
- readItem: memoryView.errors({ MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 } }).input(z5.object({ itemID: itemIDSchema })).output(memoryItemDetailSchema),
573
+ readItem: memoryView.errors({ MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 } }).input(z6.object({ itemID: itemIDSchema })).output(memoryItemDetailSchema),
563
574
  retire: memoryChange.input(versionTargetSchema).output(versionResultSchema),
564
575
  restore: memoryChange.input(versionTargetSchema).output(versionResultSchema),
565
- listNotices: memoryView.input(z5.object({ thread: z5.string().min(1).max(200) })).output(z5.object({ notices: z5.array(memoryNoticeSchema) })),
576
+ listNotices: memoryView.input(z6.object({ thread: z6.string().min(1).max(200) })).output(z6.object({ notices: z6.array(memoryNoticeSchema) })),
566
577
  undo: memoryChange.errors({
567
578
  PINNED_CORE_FULL: { message: "The undo takes the pinned core past its budget", status: 409 }
568
579
  }).input(versionTargetSchema).output(versionResultSchema),
@@ -570,163 +581,191 @@ var memoryViewContract = {
570
581
  previewForget: memoryView.errors({
571
582
  MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 },
572
583
  STALE_VERSION: { message: "The memory item has moved past that version", status: 409 }
573
- }).input(z5.object({ itemID: itemIDSchema, version: z5.int().positive() })).output(forgetPreviewSchema),
574
- forget: memoryChange.input(versionTargetSchema).output(z5.object({ itemID: z5.string() })),
584
+ }).input(z6.object({ itemID: itemIDSchema, version: z6.int().positive() })).output(forgetPreviewSchema),
585
+ forget: memoryChange.input(versionTargetSchema).output(z6.object({ itemID: z6.string(), backup: forgetBackupSchema })),
575
586
  previewForgetRetired: memoryView.output(retiredForgetPreviewSchema),
576
587
  forgetRetired: memoryChange.input(retiredForgetSchema).output(forgetStatusSchema),
577
- readForgetStatus: memoryView.input(z5.object({ itemIDs: z5.array(itemIDSchema).min(1).max(100) })).output(forgetStatusSchema),
588
+ readForgetStatus: memoryView.input(z6.object({ itemIDs: z6.array(itemIDSchema).min(1).max(100) })).output(forgetStatusSchema),
578
589
  pin: memoryChange.errors({
579
590
  PINNED_CORE_FULL: { message: "The pin takes the pinned core past its budget", status: 409 }
580
- }).input(versionTargetSchema.extend({ isPinned: z5.boolean() })).output(z5.object({ isPinned: z5.boolean(), itemID: z5.string() })),
581
- markSensitive: memoryChange.input(z5.object({ clientActionID: z5.uuid(), isSensitive: z5.boolean(), itemID: itemIDSchema })).output(z5.object({ isSensitive: z5.boolean(), itemID: z5.string() })),
582
- listProposals: memoryView.output(z5.object({ proposals: z5.array(memoryProposalSchema) })),
583
- approveProposals: memoryView.input(z5.object({
584
- answers: z5.array(approvalAnswerSchema).min(1).max(50)
591
+ }).input(versionTargetSchema.extend({ isPinned: z6.boolean() })).output(z6.object({ isPinned: z6.boolean(), itemID: z6.string() })),
592
+ markSensitive: memoryChange.input(z6.object({ clientActionID: z6.uuid(), isSensitive: z6.boolean(), itemID: itemIDSchema })).output(z6.object({ isSensitive: z6.boolean(), itemID: z6.string() })),
593
+ listProposals: memoryView.output(z6.object({ proposals: z6.array(memoryProposalSchema) })),
594
+ approveProposals: memoryView.input(z6.object({
595
+ answers: z6.array(approvalAnswerSchema).min(1).max(50)
585
596
  })).output(proposalOutcomesSchema),
586
- rejectProposals: memoryView.input(z5.object({
587
- answers: z5.array(rejectionAnswerSchema).min(1).max(50)
597
+ rejectProposals: memoryView.input(z6.object({
598
+ answers: z6.array(rejectionAnswerSchema).min(1).max(50)
588
599
  })).output(proposalOutcomesSchema),
589
600
  ...memoryExportContract,
590
601
  ...momentContract
591
602
  };
592
603
 
604
+ // src/rule-contract.ts
605
+ import { z as z7 } from "zod";
606
+ var ruleVersionSchema = z7.object({ ruleHash: z7.string(), sentence: z7.string() }).nullable();
607
+ var ruleChangeSchema = z7.object({
608
+ ruleID: z7.string(),
609
+ before: ruleVersionSchema,
610
+ after: ruleVersionSchema
611
+ });
612
+ var ruleProposalSchema = z7.object({
613
+ proposalID: z7.string(),
614
+ changes: z7.array(ruleChangeSchema),
615
+ createdAt: z7.date(),
616
+ lapseAt: z7.date()
617
+ });
618
+ var ruleAnswer = signedIn.errors({
619
+ NOT_FOUND: { message: "No rule change proposal has this ID", status: 404 },
620
+ PROPOSAL_CLOSED: {
621
+ message: "The rule change proposal is answered, withdrawn or lapsed",
622
+ status: 409
623
+ }
624
+ });
625
+ var proposalIDSchema = z7.string().min(1).max(200);
626
+ var ruleContract = {
627
+ listProposals: signedIn.output(z7.object({ proposals: z7.array(ruleProposalSchema) })),
628
+ approveProposal: ruleAnswer.input(z7.object({ proposalID: proposalIDSchema })).output(z7.object({ proposalID: z7.string() })),
629
+ rejectProposal: ruleAnswer.input(z7.object({ proposalID: proposalIDSchema, reason: z7.string().max(500).regex(/\S/u) })).output(z7.object({ proposalID: z7.string() }))
630
+ };
631
+
593
632
  // src/span-schema.ts
594
- import { z as z6 } from "zod";
595
- var spanSchema = z6.object({
596
- end: z6.int().nonnegative(),
597
- source: z6.enum(["typed", "pasted", "dropped", "unknown"]),
598
- start: z6.int().nonnegative()
633
+ import { z as z8 } from "zod";
634
+ var spanSchema = z8.object({
635
+ end: z8.int().nonnegative(),
636
+ source: z8.enum(["typed", "pasted", "dropped", "unknown"]),
637
+ start: z8.int().nonnegative()
599
638
  });
600
639
 
601
640
  // src/task-schema.ts
602
- import { z as z7 } from "zod";
603
- var taskSchema = z7.object({
604
- error: z7.string().optional(),
605
- errorLimit: z7.int().positive().optional(),
606
- errors: z7.int().positive().optional(),
607
- isWaitingForRetry: z7.boolean().optional(),
608
- readCursor: z7.int().nonnegative().optional(),
609
- reason: z7.string().optional(),
610
- retryAt: z7.date().optional(),
611
- stepKey: z7.string().optional(),
612
- taskID: z7.string()
641
+ import { z as z9 } from "zod";
642
+ var taskSchema = z9.object({
643
+ error: z9.string().optional(),
644
+ errorLimit: z9.int().positive().optional(),
645
+ errors: z9.int().positive().optional(),
646
+ isWaitingForRetry: z9.boolean().optional(),
647
+ readCursor: z9.int().nonnegative().optional(),
648
+ reason: z9.string().optional(),
649
+ retryAt: z9.date().optional(),
650
+ stepKey: z9.string().optional(),
651
+ taskID: z9.string()
613
652
  });
614
653
 
615
654
  // src/tool-call-schema.ts
616
- import { z as z8 } from "zod";
617
- var jsonObjectSchema = z8.record(z8.string(), z8.unknown());
618
- var toolCallSchema = z8.object({
619
- callID: z8.string(),
655
+ import { z as z10 } from "zod";
656
+ var jsonObjectSchema = z10.record(z10.string(), z10.unknown());
657
+ var toolCallSchema = z10.object({
658
+ callID: z10.string(),
620
659
  content: jsonObjectSchema.optional(),
621
660
  input: jsonObjectSchema.optional(),
622
- outcome: z8.string().optional(),
623
- tool: z8.string().optional()
661
+ outcome: z10.string().optional(),
662
+ tool: z10.string().optional()
624
663
  });
625
664
 
626
665
  // src/contract.ts
627
- var clientActionIDSchema = z9.uuid();
628
- var sequenceSchema = z9.int().nonnegative();
629
- var threadSchema = z9.string().min(1).max(200);
630
- var imageSchema = z9.object({ mediaType: z9.enum(imageLimits.mediaTypes) });
631
- var imageFilesSchema = z9.array(z9.file());
632
- var imageRefSchema = z9.object({
633
- position: z9.int().nonnegative(),
666
+ var clientActionIDSchema = z11.uuid();
667
+ var sequenceSchema = z11.int().nonnegative();
668
+ var threadSchema = z11.string().min(1).max(200);
669
+ var imageSchema = z11.object({ mediaType: z11.enum(imageLimits.mediaTypes) });
670
+ var imageFilesSchema = z11.array(z11.file());
671
+ var imageRefSchema = z11.object({
672
+ position: z11.int().nonnegative(),
634
673
  sequence: sequenceSchema,
635
674
  thread: threadSchema
636
675
  });
637
- var versionRefSchema = z9.object({
638
- itemID: z9.string().min(1).max(200),
639
- version: z9.int().nonnegative()
676
+ var versionRefSchema = z11.object({
677
+ itemID: z11.string().min(1).max(200),
678
+ version: z11.int().nonnegative()
640
679
  });
641
- var recallItemSchema = versionRefSchema.extend({ score: z9.number().optional() });
642
- var recallSchema = z9.object({ items: z9.array(recallItemSchema) });
680
+ var recallItemSchema = versionRefSchema.extend({ score: z11.number().optional() });
681
+ var recallSchema = z11.object({ items: z11.array(recallItemSchema) });
643
682
  var ratingItemSchema = versionRefSchema.extend({
644
- hasNote: z9.boolean(),
645
- verdict: z9.enum(["helpful", "noise", "misleading"])
683
+ hasNote: z11.boolean(),
684
+ verdict: z11.enum(["helpful", "noise", "misleading"])
646
685
  });
647
- var ratingSchema = z9.object({
648
- items: z9.array(ratingItemSchema),
649
- ratedBy: z9.string().optional(),
686
+ var ratingSchema = z11.object({
687
+ items: z11.array(ratingItemSchema),
688
+ ratedBy: z11.string().optional(),
650
689
  recalledSequence: sequenceSchema
651
690
  });
652
- var tokenCountSchema = z9.int().nonnegative();
653
- var contextSchema = z9.object({ size: tokenCountSchema, window: z9.int().positive() });
654
- var compactionSchema = z9.object({
691
+ var tokenCountSchema = z11.int().nonnegative();
692
+ var contextSchema = z11.object({ size: tokenCountSchema, window: z11.int().positive() });
693
+ var compactionSchema = z11.object({
655
694
  postTokens: tokenCountSchema.optional(),
656
695
  preTokens: tokenCountSchema,
657
- trigger: z9.enum(["manual", "auto"])
696
+ trigger: z11.enum(["manual", "auto"])
658
697
  });
659
- var summarySchema = z9.object({
698
+ var summarySchema = z11.object({
660
699
  contextSize: tokenCountSchema.optional(),
661
700
  summaryTokens: tokenCountSchema,
662
- text: z9.string().optional(),
663
- trigger: z9.enum(["threshold", "overflow"])
701
+ text: z11.string().optional(),
702
+ trigger: z11.enum(["threshold", "overflow"])
664
703
  });
665
- var compactionFailureSchema = z9.object({ failures: z9.int().positive() });
666
- var ratingNoteRefSchema = z9.object({
667
- itemID: z9.string().min(1).max(200),
704
+ var compactionFailureSchema = z11.object({ failures: z11.int().positive() });
705
+ var ratingNoteRefSchema = z11.object({
706
+ itemID: z11.string().min(1).max(200),
668
707
  sequence: sequenceSchema
669
708
  });
670
709
  var ratingNoteSchema = ratingNoteRefSchema.extend({
671
- status: z9.enum(["readable", "shredded", "unreadable", "missing"]),
672
- text: z9.string().optional()
710
+ status: z11.enum(["readable", "shredded", "unreadable", "missing"]),
711
+ text: z11.string().optional()
673
712
  });
674
713
  var versionTextSchema = versionRefSchema.extend({
675
- status: z9.enum(["readable", "shredded", "unreadable", "missing"]),
676
- text: z9.string().optional()
714
+ status: z11.enum(["readable", "shredded", "unreadable", "missing"]),
715
+ text: z11.string().optional()
677
716
  });
678
- var listedActionSchema = z9.object({ actionID: z9.string(), tool: z9.string() });
679
- var taskMessageSchema = z9.object({
717
+ var listedActionSchema = z11.object({ actionID: z11.string(), tool: z11.string() });
718
+ var taskMessageSchema = z11.object({
680
719
  from: threadSchema,
681
- fromName: z9.string(),
682
- hop: z9.int().nonnegative(),
683
- kind: z9.string(),
684
- messageID: z9.string(),
685
- replyTo: z9.string().optional(),
686
- text: z9.string().optional(),
720
+ fromName: z11.string(),
721
+ hop: z11.int().nonnegative(),
722
+ kind: z11.string(),
723
+ messageID: z11.string(),
724
+ replyTo: z11.string().optional(),
725
+ text: z11.string().optional(),
687
726
  to: threadSchema,
688
- woke: z9.boolean()
727
+ woke: z11.boolean()
689
728
  });
690
- var exchangeNoticeSchema = z9.object({
691
- link: z9.object({ label: z9.string(), messageID: z9.string(), taskID: threadSchema }),
692
- text: z9.string()
729
+ var exchangeNoticeSchema = z11.object({
730
+ link: z11.object({ label: z11.string(), messageID: z11.string(), taskID: threadSchema }),
731
+ text: z11.string()
693
732
  });
694
- var recordSchema = z9.object({
733
+ var recordSchema = z11.object({
695
734
  compaction: compactionSchema.optional(),
696
735
  exchangeNotice: exchangeNoticeSchema.optional(),
697
736
  compactionFailure: compactionFailureSchema.optional(),
698
- forget: z9.object({ sequence: sequenceSchema }).optional(),
737
+ forget: z11.object({ sequence: sequenceSchema }).optional(),
699
738
  context: contextSchema.optional(),
700
- isSilentTurn: z9.literal(true).optional(),
701
- kind: z9.string(),
702
- message: z9.object({
703
- clientMessageId: z9.uuid().optional(),
704
- images: z9.array(imageSchema).optional(),
705
- spans: z9.array(spanSchema).optional(),
706
- text: z9.string()
739
+ isSilentTurn: z11.literal(true).optional(),
740
+ kind: z11.string(),
741
+ message: z11.object({
742
+ clientMessageId: z11.uuid().optional(),
743
+ images: z11.array(imageSchema).optional(),
744
+ spans: z11.array(spanSchema).optional(),
745
+ text: z11.string()
707
746
  }).optional(),
708
- moment: z9.object({ momentID: z9.string(), shortID: z9.string(), title: z9.string().optional() }).optional(),
747
+ moment: z11.object({ momentID: z11.string(), shortID: z11.string(), title: z11.string().optional() }).optional(),
709
748
  rating: ratingSchema.optional(),
710
749
  recall: recallSchema.optional(),
711
- recordedAt: z9.date(),
750
+ recordedAt: z11.date(),
712
751
  sequence: sequenceSchema,
713
- stop: z9.object({ cancelledActions: z9.array(listedActionSchema) }).optional(),
752
+ stop: z11.object({ cancelledActions: z11.array(listedActionSchema) }).optional(),
714
753
  summary: summarySchema.optional(),
715
754
  thread: threadSchema,
716
755
  task: taskSchema.optional(),
717
756
  taskMessage: taskMessageSchema.optional(),
718
757
  toolCall: toolCallSchema.optional()
719
758
  });
720
- var writerErrorSchema = z9.object({ at: z9.date(), code: z9.string(), message: z9.string().nullable() }).nullable();
721
- var sessionSchema = z9.object({
722
- createdAt: z9.date(),
723
- current: z9.boolean(),
724
- deviceName: z9.string(),
725
- lastUsedAt: z9.date(),
726
- sessionID: z9.uuid()
759
+ var writerErrorSchema = z11.object({ at: z11.date(), code: z11.string(), message: z11.string().nullable() }).nullable();
760
+ var sessionSchema = z11.object({
761
+ createdAt: z11.date(),
762
+ current: z11.boolean(),
763
+ deviceName: z11.string(),
764
+ lastUsedAt: z11.date(),
765
+ sessionID: z11.uuid()
727
766
  });
728
767
  var checkedAction = signedIn.errors(reusedIDErrors);
729
- var taskStateSchema = z9.enum([
768
+ var taskStateSchema = z11.enum([
730
769
  "ready",
731
770
  "running",
732
771
  "waiting",
@@ -736,27 +775,27 @@ var taskStateSchema = z9.enum([
736
775
  "failed",
737
776
  "closed"
738
777
  ]);
739
- var taskControlSchema = z9.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
740
- var actionCountSchema = z9.int().nonnegative();
741
- var listedTaskSchema = z9.object({
742
- actions: z9.object({
778
+ var taskControlSchema = z11.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
779
+ var actionCountSchema = z11.int().nonnegative();
780
+ var listedTaskSchema = z11.object({
781
+ actions: z11.object({
743
782
  cancelled: actionCountSchema,
744
783
  queued: actionCountSchema,
745
784
  started: actionCountSchema
746
785
  }),
747
- brief: z9.string(),
748
- controls: z9.array(taskControlSchema),
749
- isPauseRequested: z9.boolean(),
750
- isTakingMessages: z9.boolean(),
751
- lastActivityAt: z9.date(),
752
- name: z9.string(),
786
+ brief: z11.string(),
787
+ controls: z11.array(taskControlSchema),
788
+ isPauseRequested: z11.boolean(),
789
+ isTakingMessages: z11.boolean(),
790
+ lastActivityAt: z11.date(),
791
+ name: z11.string(),
753
792
  state: taskStateSchema,
754
793
  taskID: threadSchema,
755
794
  waitingOn: threadSchema.optional()
756
795
  });
757
- var controlledTaskSchema = z9.object({
758
- controlledAt: z9.date(),
759
- isPauseRequested: z9.boolean(),
796
+ var controlledTaskSchema = z11.object({
797
+ controlledAt: z11.date(),
798
+ isPauseRequested: z11.boolean(),
760
799
  state: taskStateSchema,
761
800
  taskID: threadSchema
762
801
  });
@@ -765,58 +804,63 @@ var taskControl = checkedAction.errors({
765
804
  TASK_STATE_REFUSED: {
766
805
  message: "The task is in a state that does not take this control",
767
806
  status: 409,
768
- data: z9.object({ isPauseRequested: z9.boolean(), state: taskStateSchema })
807
+ data: z11.object({ isPauseRequested: z11.boolean(), state: taskStateSchema })
769
808
  }
770
- }).input(z9.object({ clientActionID: clientActionIDSchema, taskID: threadSchema })).output(controlledTaskSchema);
771
- var followRecords = signedIn.input(z9.object({ afterSequence: sequenceSchema, thread: threadSchema.optional() })).output(eventIterator2(z9.object({ record: recordSchema })));
809
+ }).input(z11.object({ clientActionID: clientActionIDSchema, taskID: threadSchema })).output(controlledTaskSchema);
810
+ var backupNoticeSchema = z11.object({
811
+ cause: z11.enum(["failed", "missing"]),
812
+ sequence: z11.int().positive(),
813
+ raisedAt: z11.date()
814
+ });
815
+ var followRecords = signedIn.input(z11.object({ afterSequence: sequenceSchema, thread: threadSchema.optional() })).output(eventIterator2(z11.object({ record: recordSchema })));
772
816
  var contract = {
773
817
  conversation: {
774
- read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z9.object({
818
+ read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z11.object({
775
819
  beforeSequence: sequenceSchema.optional(),
776
- limit: z9.int().min(1).max(200).optional(),
820
+ limit: z11.int().min(1).max(200).optional(),
777
821
  thread: threadSchema
778
- })).output(z9.object({
779
- hasEarlier: z9.boolean(),
822
+ })).output(z11.object({
823
+ hasEarlier: z11.boolean(),
780
824
  readAtSequence: sequenceSchema,
781
- records: z9.array(recordSchema),
825
+ records: z11.array(recordSchema),
782
826
  lastStepEnd: recordSchema.nullable().optional()
783
827
  })),
784
828
  send: checkedAction.errors({
785
829
  IMAGE_REFUSED: imageRefusedError,
786
830
  THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 }
787
- }).input(z9.object({
831
+ }).input(z11.object({
788
832
  clientMessageId: clientActionIDSchema,
789
833
  images: imageFilesSchema.optional(),
790
- spans: z9.array(spanSchema).max(1e5),
791
- text: z9.string().min(1).max(1e5),
834
+ spans: z11.array(spanSchema).max(1e5),
835
+ text: z11.string().min(1).max(1e5),
792
836
  thread: threadSchema,
793
- timeZone: z9.string().min(1).max(100).optional(),
794
- writtenAt: z9.iso.datetime().optional()
795
- })).output(z9.object({ duplicate: z9.boolean(), sequence: sequenceSchema })),
837
+ timeZone: z11.string().min(1).max(100).optional(),
838
+ writtenAt: z11.iso.datetime().optional()
839
+ })).output(z11.object({ duplicate: z11.boolean(), sequence: sequenceSchema })),
796
840
  retry: checkedAction.errors({
797
841
  NOTHING_TO_RETRY: {
798
842
  message: "The last turn of the conversation did not fail, or it runs again already",
799
843
  status: 409
800
844
  }
801
- }).input(z9.object({ clientActionID: clientActionIDSchema })).output(z9.object({ retriedAt: z9.date() })),
802
- readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z9.file()),
845
+ }).input(z11.object({ clientActionID: clientActionIDSchema })).output(z11.object({ retriedAt: z11.date() })),
846
+ readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z11.file()),
803
847
  forget: checkedAction.errors({
804
848
  RECORD_NOT_FOUND: {
805
849
  message: "No message or reply on this thread has this sequence",
806
850
  status: 404
807
851
  }
808
- }).input(z9.object({
852
+ }).input(z11.object({
809
853
  clientActionID: clientActionIDSchema,
810
854
  sequence: sequenceSchema,
811
855
  thread: threadSchema
812
- })).output(z9.object({ forgottenAt: z9.date() }))
856
+ })).output(z11.object({ forgottenAt: z11.date() }))
813
857
  },
814
858
  tasks: {
815
- list: signedIn.output(z9.object({ readAtSequence: sequenceSchema, tasks: z9.array(listedTaskSchema) })),
816
- read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z9.object({ taskID: threadSchema })).output(listedTaskSchema),
817
- readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z9.object({ taskID: threadSchema })).output(z9.object({
818
- queued: z9.array(listedActionSchema),
819
- started: z9.array(listedActionSchema)
859
+ list: signedIn.output(z11.object({ readAtSequence: sequenceSchema, tasks: z11.array(listedTaskSchema) })),
860
+ read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z11.object({ taskID: threadSchema })).output(listedTaskSchema),
861
+ readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z11.object({ taskID: threadSchema })).output(z11.object({
862
+ queued: z11.array(listedActionSchema),
863
+ started: z11.array(listedActionSchema)
820
864
  })),
821
865
  pause: taskControl,
822
866
  resume: taskControl,
@@ -828,21 +872,25 @@ var contract = {
828
872
  interrupt: taskControl
829
873
  },
830
874
  memory: {
831
- readVersions: signedIn.input(z9.object({ versions: z9.array(versionRefSchema).min(1).max(100) })).output(z9.object({ versions: z9.array(versionTextSchema) })),
832
- readRatingNotes: signedIn.input(z9.object({ notes: z9.array(ratingNoteRefSchema).min(1).max(100) })).output(z9.object({ notes: z9.array(ratingNoteSchema) })),
833
- writerStatus: signedIn.output(z9.object({
834
- isEnabled: z9.boolean(),
835
- backlog: z9.int().nonnegative(),
836
- batches: z9.int().nonnegative(),
875
+ readVersions: signedIn.input(z11.object({ versions: z11.array(versionRefSchema).min(1).max(100) })).output(z11.object({ versions: z11.array(versionTextSchema) })),
876
+ readRatingNotes: signedIn.input(z11.object({ notes: z11.array(ratingNoteRefSchema).min(1).max(100) })).output(z11.object({ notes: z11.array(ratingNoteSchema) })),
877
+ writerStatus: signedIn.output(z11.object({
878
+ isEnabled: z11.boolean(),
879
+ backlog: z11.int().nonnegative(),
880
+ batches: z11.int().nonnegative(),
837
881
  cursor: sequenceSchema,
838
- failures: z9.int().nonnegative(),
839
- isCatchingUp: z9.boolean(),
882
+ failures: z11.int().nonnegative(),
883
+ isCatchingUp: z11.boolean(),
840
884
  lastError: writerErrorSchema,
841
- retryAt: z9.date().nullable()
885
+ retryAt: z11.date().nullable()
842
886
  })),
843
- consolidatorStatus: signedIn.output(z9.object({ isEnabled: z9.boolean() })),
887
+ consolidatorStatus: signedIn.output(z11.object({ isEnabled: z11.boolean() })),
844
888
  ...memoryViewContract
845
889
  },
890
+ backups: {
891
+ readNotice: signedIn.output(z11.object({ notice: backupNoticeSchema.nullable() }))
892
+ },
893
+ rules: ruleContract,
846
894
  log: {
847
895
  follow: followRecords.route({ deprecated: true })
848
896
  },
@@ -855,30 +903,30 @@ var contract = {
855
903
  message: "The enrolment code is unknown, used or lapsed",
856
904
  status: 400
857
905
  }
858
- }).input(z9.object({
906
+ }).input(z11.object({
859
907
  clientActionID: clientActionIDSchema,
860
- code: z9.string().min(1).max(100),
861
- deviceName: z9.string().min(1).max(100),
862
- tokenDelivery: z9.enum(["cookie", "bearer"])
863
- })).output(z9.object({ sessionID: z9.uuid(), token: z9.string().optional() })),
864
- issueCode: checkedAction.input(z9.object({ clientActionID: clientActionIDSchema })).output(z9.object({ code: z9.string(), expiresAt: z9.date() })),
865
- list: signedIn.output(z9.object({ sessions: z9.array(sessionSchema) })),
866
- revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(z9.object({ clientActionID: clientActionIDSchema, sessionID: z9.uuid() })).output(z9.object({ revokedAt: z9.date() }))
908
+ code: z11.string().min(1).max(100),
909
+ deviceName: z11.string().min(1).max(100),
910
+ tokenDelivery: z11.enum(["cookie", "bearer"])
911
+ })).output(z11.object({ sessionID: z11.uuid(), token: z11.string().optional() })),
912
+ issueCode: checkedAction.input(z11.object({ clientActionID: clientActionIDSchema })).output(z11.object({ code: z11.string(), expiresAt: z11.date() })),
913
+ list: signedIn.output(z11.object({ sessions: z11.array(sessionSchema) })),
914
+ revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(z11.object({ clientActionID: clientActionIDSchema, sessionID: z11.uuid() })).output(z11.object({ revokedAt: z11.date() }))
867
915
  }
868
916
  };
869
917
  // src/host-contract.ts
870
918
  import { oc as oc3 } from "@orpc/contract";
871
- import { z as z10 } from "zod";
872
- var versionRefSchema2 = z10.object({ itemID: z10.string(), version: z10.int().positive() });
873
- var versionTargetSchema2 = z10.strictObject({
874
- itemID: z10.string().min(1),
875
- version: z10.int().positive()
876
- });
877
- var itemTextSchema2 = z10.string().max(2000).regex(/\S/u);
878
- var proposalOriginSchema2 = z10.enum(["owner", "conversation", "task", "memory_writer"]);
879
- var memoryOriginSchema = z10.enum([...proposalOriginSchema2.options, "lapse"]);
880
- var contentSourceSchema = z10.enum(["owner", "owner_data", "untrusted"]);
881
- var reviewReasonSchema2 = z10.enum([
919
+ import { z as z12 } from "zod";
920
+ var versionRefSchema2 = z12.object({ itemID: z12.string(), version: z12.int().positive() });
921
+ var versionTargetSchema2 = z12.strictObject({
922
+ itemID: z12.string().min(1),
923
+ version: z12.int().positive()
924
+ });
925
+ var itemTextSchema2 = z12.string().max(2000).regex(/\S/u);
926
+ var proposalOriginSchema2 = z12.enum(["owner", "conversation", "task", "memory_writer"]);
927
+ var memoryOriginSchema = z12.enum([...proposalOriginSchema2.options, "lapse"]);
928
+ var contentSourceSchema = z12.enum(["owner", "owner_data", "untrusted"]);
929
+ var reviewReasonSchema2 = z12.enum([
882
930
  "no_quote",
883
931
  "quote_not_typed",
884
932
  "quote_in_quoted_block",
@@ -896,105 +944,105 @@ var reviewReasonSchema2 = z10.enum([
896
944
  "sensitive",
897
945
  "subject_change"
898
946
  ]);
899
- var proposalSourceSchema2 = z10.object({
947
+ var proposalSourceSchema2 = z12.object({
900
948
  origin: proposalOriginSchema2,
901
- thread: z10.string().nullable(),
902
- proposedAt: z10.date()
903
- });
904
- var pendingProposalSchema = z10.object({
905
- proposalID: z10.string(),
906
- operation: z10.enum(["remember", "retire", "pin"]),
907
- itemID: z10.string(),
908
- targetVersion: z10.int().nullable(),
909
- isPinned: z10.boolean(),
910
- subject: z10.enum(["owner", "self", "shared"]),
911
- newSubject: z10.enum(["owner", "self", "shared"]).nullable(),
912
- isSensitive: z10.boolean(),
913
- kind: z10.enum(["fact", "self"]),
949
+ thread: z12.string().nullable(),
950
+ proposedAt: z12.date()
951
+ });
952
+ var pendingProposalSchema = z12.object({
953
+ proposalID: z12.string(),
954
+ operation: z12.enum(["remember", "retire", "pin"]),
955
+ itemID: z12.string(),
956
+ targetVersion: z12.int().nullable(),
957
+ isPinned: z12.boolean(),
958
+ subject: z12.enum(["owner", "self", "shared"]),
959
+ newSubject: z12.enum(["owner", "self", "shared"]).nullable(),
960
+ isSensitive: z12.boolean(),
961
+ kind: z12.enum(["fact", "self"]),
914
962
  reason: reviewReasonSchema2,
915
- actionHash: z10.string(),
963
+ actionHash: z12.string(),
916
964
  origin: proposalOriginSchema2,
917
965
  source: contentSourceSchema,
918
- createdAt: z10.date(),
919
- lapseAt: z10.date(),
920
- sources: z10.array(proposalSourceSchema2),
921
- text: z10.string(),
922
- quote: z10.string().nullable()
923
- });
924
- var closeMatchSchema2 = z10.object({ itemID: z10.string(), version: z10.int(), text: z10.string() });
925
- var approvalResultSchema = z10.discriminatedUnion("status", [
926
- z10.object({ status: z10.literal("applied"), itemID: z10.string(), version: z10.int() }),
927
- z10.object({ status: z10.literal("close_match"), item: closeMatchSchema2 })
966
+ createdAt: z12.date(),
967
+ lapseAt: z12.date(),
968
+ sources: z12.array(proposalSourceSchema2),
969
+ text: z12.string(),
970
+ quote: z12.string().nullable()
971
+ });
972
+ var closeMatchSchema2 = z12.object({ itemID: z12.string(), version: z12.int(), text: z12.string() });
973
+ var approvalResultSchema = z12.discriminatedUnion("status", [
974
+ z12.object({ status: z12.literal("applied"), itemID: z12.string(), version: z12.int() }),
975
+ z12.object({ status: z12.literal("close_match"), item: closeMatchSchema2 })
928
976
  ]);
929
- var historyVersionSchema = z10.object({
930
- version: z10.int(),
931
- change: z10.enum(["created", "edited", "retired", "restored", "undone"]),
932
- state: z10.enum(["active", "retired"]),
977
+ var historyVersionSchema = z12.object({
978
+ version: z12.int(),
979
+ change: z12.enum(["created", "edited", "retired", "restored", "undone"]),
980
+ state: z12.enum(["active", "retired"]),
933
981
  origin: memoryOriginSchema,
934
982
  source: contentSourceSchema,
935
- recordedAt: z10.date(),
936
- status: z10.enum(["readable", "shredded", "unreadable"]),
937
- text: z10.string().nullable()
938
- });
939
- var itemHistorySchema = z10.object({
940
- itemID: z10.string(),
941
- subject: z10.enum(["owner", "self", "shared"]),
942
- kind: z10.enum(["fact", "self"]),
943
- state: z10.enum(["active", "retired", "forgetting", "forgotten"]),
944
- versions: z10.array(historyVersionSchema)
945
- });
946
- var changeInputSchema = z10.object({
947
- itemID: z10.string(),
948
- version: z10.int(),
949
- text: z10.string().nullable(),
950
- isCurrent: z10.boolean()
951
- });
952
- var changeCommentSchema = z10.object({ text: z10.string(), at: z10.date() });
953
- var consolidationChangeSchema = z10.object({
954
- changeID: z10.string(),
955
- shortID: z10.string(),
956
- kind: z10.enum(["merge", "rewrite", "retire"]),
957
- inputs: z10.array(changeInputSchema),
958
- text: z10.string().nullable(),
959
- reason: z10.string(),
983
+ recordedAt: z12.date(),
984
+ status: z12.enum(["readable", "shredded", "unreadable"]),
985
+ text: z12.string().nullable()
986
+ });
987
+ var itemHistorySchema = z12.object({
988
+ itemID: z12.string(),
989
+ subject: z12.enum(["owner", "self", "shared"]),
990
+ kind: z12.enum(["fact", "self"]),
991
+ state: z12.enum(["active", "retired", "forgetting", "forgotten"]),
992
+ versions: z12.array(historyVersionSchema)
993
+ });
994
+ var changeInputSchema = z12.object({
995
+ itemID: z12.string(),
996
+ version: z12.int(),
997
+ text: z12.string().nullable(),
998
+ isCurrent: z12.boolean()
999
+ });
1000
+ var changeCommentSchema = z12.object({ text: z12.string(), at: z12.date() });
1001
+ var consolidationChangeSchema = z12.object({
1002
+ changeID: z12.string(),
1003
+ shortID: z12.string(),
1004
+ kind: z12.enum(["merge", "rewrite", "retire"]),
1005
+ inputs: z12.array(changeInputSchema),
1006
+ text: z12.string().nullable(),
1007
+ reason: z12.string(),
960
1008
  source: contentSourceSchema,
961
- actionHash: z10.string(),
962
- lapseAt: z10.date(),
1009
+ actionHash: z12.string(),
1010
+ lapseAt: z12.date(),
963
1011
  comment: changeCommentSchema.nullable()
964
1012
  });
965
- var consolidationDiffSchema = z10.object({
966
- diffID: z10.string(),
967
- model: z10.string().nullable(),
968
- createdAt: z10.date(),
969
- changes: z10.array(consolidationChangeSchema),
970
- summary: z10.string().nullable()
971
- });
972
- var changeOutcomeSchema = z10.discriminatedUnion("status", [
973
- z10.object({
974
- changeID: z10.string(),
975
- status: z10.literal("applied"),
976
- versions: z10.array(versionRefSchema2)
1013
+ var consolidationDiffSchema = z12.object({
1014
+ diffID: z12.string(),
1015
+ model: z12.string().nullable(),
1016
+ createdAt: z12.date(),
1017
+ changes: z12.array(consolidationChangeSchema),
1018
+ summary: z12.string().nullable()
1019
+ });
1020
+ var changeOutcomeSchema = z12.discriminatedUnion("status", [
1021
+ z12.object({
1022
+ changeID: z12.string(),
1023
+ status: z12.literal("applied"),
1024
+ versions: z12.array(versionRefSchema2)
977
1025
  }),
978
- z10.object({ changeID: z10.string(), status: z10.literal("refused"), code: z10.string() })
1026
+ z12.object({ changeID: z12.string(), status: z12.literal("refused"), code: z12.string() })
979
1027
  ]);
980
- var changeAnswerSchema = z10.strictObject({
981
- changeID: z10.string().min(1),
982
- actionHash: z10.string().min(1)
1028
+ var changeAnswerSchema = z12.strictObject({
1029
+ changeID: z12.string().min(1),
1030
+ actionHash: z12.string().min(1)
983
1031
  });
984
- var proposalAnswerSchema2 = z10.strictObject({
985
- proposalID: z10.string().min(1),
986
- actionHash: z10.string().min(1)
1032
+ var proposalAnswerSchema2 = z12.strictObject({
1033
+ proposalID: z12.string().min(1),
1034
+ actionHash: z12.string().min(1)
987
1035
  });
988
- var hostSessionSchema = z10.object({
989
- sessionID: z10.string(),
990
- deviceName: z10.string(),
991
- createdAt: z10.date(),
992
- lastUsedAt: z10.date()
1036
+ var hostSessionSchema = z12.object({
1037
+ sessionID: z12.string(),
1038
+ deviceName: z12.string(),
1039
+ createdAt: z12.date(),
1040
+ lastUsedAt: z12.date()
993
1041
  });
994
- var subjectCountSchema = z10.object({
995
- owner: z10.int().nonnegative(),
996
- shared: z10.int().nonnegative(),
997
- self: z10.int().nonnegative()
1042
+ var subjectCountSchema = z12.object({
1043
+ owner: z12.int().nonnegative(),
1044
+ shared: z12.int().nonnegative(),
1045
+ self: z12.int().nonnegative()
998
1046
  });
999
1047
  var memory = oc3.errors({
1000
1048
  MEMORY_NOT_STARTED: { message: "the memory store has not started yet", status: 503 },
@@ -1009,28 +1057,28 @@ var memory = oc3.errors({
1009
1057
  PIN_EDIT: { message: "a pin takes no edited text", status: 400 },
1010
1058
  SELF_NOTE_REFUSED: { message: "a self-note never takes that change", status: 409 }
1011
1059
  });
1012
- var skillFileSchema = z10.object({ path: z10.string(), text: z10.string() });
1013
- var pendingSkillProposalSchema = z10.object({
1014
- proposalID: z10.string(),
1015
- name: z10.string(),
1016
- skillHash: z10.string(),
1017
- baseHash: z10.string().nullable(),
1018
- files: z10.array(skillFileSchema),
1019
- inForce: z10.object({
1020
- skillHash: z10.string(),
1021
- origin: z10.enum(["definitions", "vendored", "nixie"]),
1022
- files: z10.array(skillFileSchema)
1060
+ var skillFileSchema = z12.object({ path: z12.string(), text: z12.string() });
1061
+ var pendingSkillProposalSchema = z12.object({
1062
+ proposalID: z12.string(),
1063
+ name: z12.string(),
1064
+ skillHash: z12.string(),
1065
+ baseHash: z12.string().nullable(),
1066
+ files: z12.array(skillFileSchema),
1067
+ inForce: z12.object({
1068
+ skillHash: z12.string(),
1069
+ origin: z12.enum(["definitions", "vendored", "nixie"]),
1070
+ files: z12.array(skillFileSchema)
1023
1071
  }).nullable(),
1024
- untypedToken: z10.object({ kind: z10.string(), raw: z10.string() }).nullable(),
1025
- thread: z10.string().nullable(),
1026
- provenance: z10.object({ runID: z10.string(), callID: z10.string(), profile: z10.string() }),
1027
- createdAt: z10.date(),
1028
- lapseAt: z10.date(),
1029
- isStale: z10.boolean()
1072
+ untypedToken: z12.object({ kind: z12.string(), raw: z12.string() }).nullable(),
1073
+ thread: z12.string().nullable(),
1074
+ provenance: z12.object({ runID: z12.string(), callID: z12.string(), profile: z12.string() }),
1075
+ createdAt: z12.date(),
1076
+ lapseAt: z12.date(),
1077
+ isStale: z12.boolean()
1030
1078
  });
1031
- var skillAnswerSchema = z10.strictObject({
1032
- proposalID: z10.string().min(1),
1033
- skillHash: z10.string().min(1)
1079
+ var skillAnswerSchema = z12.strictObject({
1080
+ proposalID: z12.string().min(1),
1081
+ skillHash: z12.string().min(1)
1034
1082
  });
1035
1083
  var skills = oc3.errors({
1036
1084
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
@@ -1040,38 +1088,38 @@ var skills = oc3.errors({
1040
1088
  SKILL_CHECK: { message: "the files fail the seed checks", status: 400 },
1041
1089
  WRONG_STATE: { message: "the skill nixie wrote is no longer in force", status: 409 }
1042
1090
  });
1043
- var definitionsSkillSchema = z10.object({ skillHash: z10.string(), origin: z10.enum(["definitions", "vendored"]) }).nullable();
1044
- var writtenSkillSchema = z10.object({
1045
- approvalID: z10.string(),
1046
- proposalID: z10.string(),
1047
- name: z10.string(),
1048
- skillHash: z10.string(),
1091
+ var definitionsSkillSchema = z12.object({ skillHash: z12.string(), origin: z12.enum(["definitions", "vendored"]) }).nullable();
1092
+ var writtenSkillSchema = z12.object({
1093
+ approvalID: z12.string(),
1094
+ proposalID: z12.string(),
1095
+ name: z12.string(),
1096
+ skillHash: z12.string(),
1049
1097
  base: definitionsSkillSchema,
1050
1098
  definitions: definitionsSkillSchema,
1051
- isConflict: z10.boolean(),
1052
- pullRequestURL: z10.url().nullable(),
1053
- approvedAt: z10.date()
1054
- });
1055
- var promptPartFileSchema = z10.object({ path: z10.string(), text: z10.string() });
1056
- var promptEntrySchema = z10.record(z10.string(), z10.string());
1057
- var pendingPromptProposalSchema = z10.object({
1058
- proposalID: z10.string(),
1059
- promptID: z10.string(),
1060
- proposalHash: z10.string(),
1061
- baseHash: z10.string().nullable(),
1099
+ isConflict: z12.boolean(),
1100
+ pullRequestURL: z12.url().nullable(),
1101
+ approvedAt: z12.date()
1102
+ });
1103
+ var promptPartFileSchema = z12.object({ path: z12.string(), text: z12.string() });
1104
+ var promptEntrySchema = z12.record(z12.string(), z12.string());
1105
+ var pendingPromptProposalSchema = z12.object({
1106
+ proposalID: z12.string(),
1107
+ promptID: z12.string(),
1108
+ proposalHash: z12.string(),
1109
+ baseHash: z12.string().nullable(),
1062
1110
  entry: promptEntrySchema,
1063
- files: z10.array(promptPartFileSchema),
1064
- reason: z10.string(),
1065
- inForce: z10.object({ parts: promptEntrySchema, template: z10.string().nullable() }).nullable(),
1066
- thread: z10.string().nullable(),
1067
- provenance: z10.object({ runID: z10.string(), callID: z10.string(), profile: z10.string() }),
1068
- createdAt: z10.date(),
1069
- lapseAt: z10.date(),
1070
- isStale: z10.boolean()
1071
- });
1072
- var promptAnswerSchema = z10.strictObject({
1073
- proposalID: z10.string().min(1),
1074
- proposalHash: z10.string().min(1)
1111
+ files: z12.array(promptPartFileSchema),
1112
+ reason: z12.string(),
1113
+ inForce: z12.object({ parts: promptEntrySchema, template: z12.string().nullable() }).nullable(),
1114
+ thread: z12.string().nullable(),
1115
+ provenance: z12.object({ runID: z12.string(), callID: z12.string(), profile: z12.string() }),
1116
+ createdAt: z12.date(),
1117
+ lapseAt: z12.date(),
1118
+ isStale: z12.boolean()
1119
+ });
1120
+ var promptAnswerSchema = z12.strictObject({
1121
+ proposalID: z12.string().min(1),
1122
+ proposalHash: z12.string().min(1)
1075
1123
  });
1076
1124
  var prompts = oc3.errors({
1077
1125
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
@@ -1080,8 +1128,51 @@ var prompts = oc3.errors({
1080
1128
  STALE_BASE: { message: "the override in force moved past the proposal", status: 409 },
1081
1129
  PROMPT_CHECK: { message: "the override fails the definitions checks", status: 400 }
1082
1130
  });
1083
- var forgottenItemsSchema = z10.object({ itemIDs: z10.array(z10.string()) });
1084
- var hostTaskStateSchema = z10.enum([
1131
+ var ruleVersionSchema2 = z12.object({ ruleHash: z12.string(), sentence: z12.string() }).nullable();
1132
+ var ruleInForceSchema = z12.object({
1133
+ ruleID: z12.string(),
1134
+ revision: z12.int().positive(),
1135
+ ruleHash: z12.string(),
1136
+ sentence: z12.string(),
1137
+ origin: z12.enum(["definitions", "nixie"]),
1138
+ changeID: z12.string().nullable(),
1139
+ lastFiredAt: z12.date().nullable()
1140
+ });
1141
+ var ruleConflictSchema = z12.object({
1142
+ ruleID: z12.string(),
1143
+ changeID: z12.string(),
1144
+ nixie: ruleVersionSchema2,
1145
+ repo: ruleVersionSchema2,
1146
+ base: ruleVersionSchema2,
1147
+ changedBy: z12.enum(["owner", "nixie"]),
1148
+ reason: z12.string(),
1149
+ changedAt: z12.date()
1150
+ });
1151
+ var ruleProposalChangeSchema = z12.object({
1152
+ ruleID: z12.string(),
1153
+ before: ruleVersionSchema2,
1154
+ after: ruleVersionSchema2
1155
+ });
1156
+ var pendingRuleProposalSchema = z12.object({
1157
+ proposalID: z12.string(),
1158
+ changes: z12.array(ruleProposalChangeSchema),
1159
+ createdAt: z12.date(),
1160
+ lapseAt: z12.date()
1161
+ });
1162
+ var ruleProposalAnswerSchema = z12.strictObject({ proposalID: z12.string().min(1) });
1163
+ var ruleProposalRejectionSchema = ruleProposalAnswerSchema.extend({
1164
+ reason: z12.string().max(500).regex(/\S/u)
1165
+ });
1166
+ var ruleProposalErrors = {
1167
+ NOT_FOUND: { message: "nothing has that ID", status: 404 },
1168
+ PROPOSAL_CLOSED: { message: "the proposal is answered, withdrawn or lapsed", status: 409 }
1169
+ };
1170
+ var rules = oc3.errors(ruleProposalErrors);
1171
+ var forgottenItemsSchema = z12.object({
1172
+ itemIDs: z12.array(z12.string()),
1173
+ backup: forgetBackupSchema
1174
+ });
1175
+ var hostTaskStateSchema = z12.enum([
1085
1176
  "ready",
1086
1177
  "running",
1087
1178
  "waiting",
@@ -1097,21 +1188,22 @@ var taskControl2 = oc3.errors({
1097
1188
  message: "the task is in a state that does not take this control",
1098
1189
  status: 409
1099
1190
  }
1100
- }).input(z10.strictObject({ taskID: z10.string().min(1) })).output(z10.object({
1101
- taskID: z10.string(),
1191
+ }).input(z12.strictObject({ taskID: z12.string().min(1) })).output(z12.object({
1192
+ taskID: z12.string(),
1102
1193
  state: hostTaskStateSchema,
1103
- isPauseRequested: z10.boolean()
1194
+ isPauseRequested: z12.boolean()
1104
1195
  }));
1105
1196
  var hostContract = {
1106
- reset: oc3.output(z10.object({
1107
- resetAt: z10.date(),
1108
- lastSequence: z10.int().nonnegative(),
1109
- keptSessions: z10.int().nonnegative()
1197
+ reset: oc3.output(z12.object({
1198
+ resetAt: z12.date(),
1199
+ lastSequence: z12.int().nonnegative(),
1200
+ keptSessions: z12.int().nonnegative()
1110
1201
  })),
1111
- resetConversations: oc3.output(z10.object({
1112
- resetAt: z10.date(),
1113
- lastSequence: z10.int().nonnegative(),
1114
- shreddedRecords: z10.int().nonnegative()
1202
+ resetConversations: oc3.output(z12.object({
1203
+ resetAt: z12.date(),
1204
+ lastSequence: z12.int().nonnegative(),
1205
+ shreddedRecords: z12.int().nonnegative(),
1206
+ backup: forgetBackupSchema
1115
1207
  })),
1116
1208
  tasks: {
1117
1209
  pause: taskControl2,
@@ -1126,79 +1218,89 @@ var hostContract = {
1126
1218
  TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
1127
1219
  TASK_NOT_AT_LIMIT: { message: "the task is not paused at its limit", status: 409 },
1128
1220
  LIMIT_NOT_RAISED: { message: "the new limits are not above the old ones", status: 409 }
1129
- }).input(z10.strictObject({
1130
- taskID: z10.string().min(1),
1131
- turns: z10.int().positive().optional(),
1132
- dollars: z10.number().positive().optional()
1221
+ }).input(z12.strictObject({
1222
+ taskID: z12.string().min(1),
1223
+ turns: z12.int().positive().optional(),
1224
+ dollars: z12.number().positive().optional()
1133
1225
  }).refine((input) => input.turns !== undefined || input.dollars !== undefined, {
1134
1226
  message: "a raise sets turns, dollars or both"
1135
- })).output(z10.object({
1136
- taskID: z10.string(),
1227
+ })).output(z12.object({
1228
+ taskID: z12.string(),
1137
1229
  state: hostTaskStateSchema,
1138
- isPauseRequested: z10.boolean(),
1139
- turns: z10.int().positive(),
1140
- dollars: z10.number().positive()
1230
+ isPauseRequested: z12.boolean(),
1231
+ turns: z12.int().positive(),
1232
+ dollars: z12.number().positive()
1141
1233
  }))
1142
1234
  },
1143
1235
  sessions: {
1144
- issueCode: oc3.output(z10.object({ code: z10.string(), expiresAt: z10.date() })),
1145
- list: oc3.output(z10.array(hostSessionSchema)),
1236
+ issueCode: oc3.output(z12.object({ code: z12.string(), expiresAt: z12.date() })),
1237
+ list: oc3.output(z12.array(hostSessionSchema)),
1146
1238
  label: oc3.errors({
1147
1239
  SESSION_NOT_FOUND: {
1148
1240
  message: "no device session that is still signed in has that ID",
1149
1241
  status: 404
1150
1242
  },
1151
1243
  LABEL_INVALID: { message: "a label holds 1 to 100 characters besides spaces", status: 400 }
1152
- }).input(z10.strictObject({ sessionID: z10.string().min(1), label: z10.string() })).output(z10.object({ sessionID: z10.string(), label: z10.string() }))
1244
+ }).input(z12.strictObject({ sessionID: z12.string().min(1), label: z12.string() })).output(z12.object({ sessionID: z12.string(), label: z12.string() }))
1153
1245
  },
1154
1246
  memory: {
1155
1247
  proposals: {
1156
- list: memory.output(z10.array(pendingProposalSchema)),
1248
+ list: memory.output(z12.array(pendingProposalSchema)),
1157
1249
  approve: memory.input(proposalAnswerSchema2.extend({
1158
1250
  revisionOf: versionTargetSchema2.optional(),
1159
- ignoreCloseMatch: z10.boolean().optional(),
1251
+ ignoreCloseMatch: z12.boolean().optional(),
1160
1252
  editedText: itemTextSchema2.optional()
1161
1253
  })).output(approvalResultSchema),
1162
- reject: memory.input(proposalAnswerSchema2.extend({ reason: z10.string().max(500).regex(/\S/u).optional() })).output(z10.object({ proposalID: z10.string() }))
1254
+ reject: memory.input(proposalAnswerSchema2.extend({ reason: z12.string().max(500).regex(/\S/u).optional() })).output(z12.object({ proposalID: z12.string() }))
1163
1255
  },
1164
- subjects: memory.output(z10.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
1256
+ subjects: memory.output(z12.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
1165
1257
  items: {
1166
- read: memory.input(z10.strictObject({ itemID: z10.string().min(1) })).output(itemHistorySchema),
1258
+ read: memory.input(z12.strictObject({ itemID: z12.string().min(1) })).output(itemHistorySchema),
1167
1259
  edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema2 })).output(versionRefSchema2),
1168
1260
  retire: memory.input(versionTargetSchema2).output(versionRefSchema2),
1169
1261
  restore: memory.input(versionTargetSchema2).output(versionRefSchema2),
1170
- forget: memory.input(versionTargetSchema2).output(z10.object({ itemID: z10.string() })),
1262
+ forget: memory.input(versionTargetSchema2).output(z12.object({ itemID: z12.string(), backup: forgetBackupSchema })),
1171
1263
  forgetAll: memory.output(forgottenItemsSchema),
1172
- pin: memory.input(z10.strictObject({ itemID: z10.string().min(1), isPinned: z10.boolean() })).output(z10.object({ itemID: z10.string(), isPinned: z10.boolean() }))
1264
+ pin: memory.input(z12.strictObject({ itemID: z12.string().min(1), isPinned: z12.boolean() })).output(z12.object({ itemID: z12.string(), isPinned: z12.boolean() }))
1173
1265
  },
1174
1266
  consolidation: {
1175
1267
  read: memory.output(consolidationDiffSchema.nullable()),
1176
- approve: memory.input(z10.strictObject({ answers: z10.array(changeAnswerSchema).min(1).max(30) })).output(z10.object({ outcomes: z10.array(changeOutcomeSchema) })),
1177
- reject: memory.input(changeAnswerSchema).output(z10.object({ changeID: z10.string() }))
1268
+ approve: memory.input(z12.strictObject({ answers: z12.array(changeAnswerSchema).min(1).max(30) })).output(z12.object({ outcomes: z12.array(changeOutcomeSchema) })),
1269
+ reject: memory.input(changeAnswerSchema).output(z12.object({ changeID: z12.string() }))
1178
1270
  }
1179
1271
  },
1180
1272
  skills: {
1181
1273
  proposals: {
1182
- list: skills.output(z10.array(pendingSkillProposalSchema)),
1183
- approve: skills.input(skillAnswerSchema.extend({ files: z10.array(skillFileSchema).min(1).optional() })).output(z10.object({ proposalID: z10.string(), approvalID: z10.string(), skillHash: z10.string() })),
1184
- reject: skills.input(skillAnswerSchema.extend({ reason: z10.string().max(500).regex(/\S/u) })).output(z10.object({ proposalID: z10.string() }))
1274
+ list: skills.output(z12.array(pendingSkillProposalSchema)),
1275
+ approve: skills.input(skillAnswerSchema.extend({ files: z12.array(skillFileSchema).min(1).optional() })).output(z12.object({ proposalID: z12.string(), approvalID: z12.string(), skillHash: z12.string() })),
1276
+ reject: skills.input(skillAnswerSchema.extend({ reason: z12.string().max(500).regex(/\S/u) })).output(z12.object({ proposalID: z12.string() }))
1185
1277
  },
1186
1278
  written: {
1187
- list: skills.output(z10.array(writtenSkillSchema)),
1188
- resolve: skills.input(z10.strictObject({
1189
- approvalID: z10.string().min(1),
1190
- keep: z10.enum(["nixie", "definitions"])
1191
- })).output(z10.object({ approvalID: z10.string(), keep: z10.enum(["nixie", "definitions"]) }))
1279
+ list: skills.output(z12.array(writtenSkillSchema)),
1280
+ resolve: skills.input(z12.strictObject({
1281
+ approvalID: z12.string().min(1),
1282
+ keep: z12.enum(["nixie", "definitions"])
1283
+ })).output(z12.object({ approvalID: z12.string(), keep: z12.enum(["nixie", "definitions"]) }))
1284
+ }
1285
+ },
1286
+ rules: {
1287
+ list: rules.output(z12.array(ruleInForceSchema)),
1288
+ conflicts: rules.output(z12.array(ruleConflictSchema)),
1289
+ resolve: rules.input(z12.strictObject({ ruleID: z12.string().min(1), keep: z12.enum(["nixie", "repo"]) })).output(z12.object({ ruleID: z12.string(), changeID: z12.string(), keep: z12.enum(["nixie", "repo"]) })),
1290
+ proposals: {
1291
+ list: rules.output(z12.array(pendingRuleProposalSchema)),
1292
+ approve: rules.input(ruleProposalAnswerSchema).output(z12.object({ proposalID: z12.string() })),
1293
+ reject: rules.input(ruleProposalRejectionSchema).output(z12.object({ proposalID: z12.string() }))
1192
1294
  }
1193
1295
  },
1194
1296
  prompts: {
1195
1297
  proposals: {
1196
- list: prompts.output(z10.array(pendingPromptProposalSchema)),
1298
+ list: prompts.output(z12.array(pendingPromptProposalSchema)),
1197
1299
  approve: prompts.input(promptAnswerSchema.extend({
1198
1300
  entry: promptEntrySchema.optional(),
1199
- files: z10.array(promptPartFileSchema).optional()
1200
- })).output(z10.object({ proposalID: z10.string(), approvalID: z10.string(), proposalHash: z10.string() })),
1201
- reject: prompts.input(promptAnswerSchema.extend({ reason: z10.string().max(500).regex(/\S/u) })).output(z10.object({ proposalID: z10.string() }))
1301
+ files: z12.array(promptPartFileSchema).optional()
1302
+ })).output(z12.object({ proposalID: z12.string(), approvalID: z12.string(), proposalHash: z12.string() })),
1303
+ reject: prompts.input(promptAnswerSchema.extend({ reason: z12.string().max(500).regex(/\S/u) })).output(z12.object({ proposalID: z12.string() }))
1202
1304
  }
1203
1305
  }
1204
1306
  };
@@ -1220,11 +1322,11 @@ function renderSessionCookie(token) {
1220
1322
  return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
1221
1323
  }
1222
1324
  // src/task-message-input-schema.ts
1223
- import { z as z12 } from "zod";
1325
+ import { z as z14 } from "zod";
1224
1326
 
1225
1327
  // src/task-message-kind-schema.ts
1226
- import { z as z11 } from "zod";
1227
- var taskMessageKindSchema = z11.enum([
1328
+ import { z as z13 } from "zod";
1329
+ var taskMessageKindSchema = z13.enum([
1228
1330
  "progress",
1229
1331
  "question",
1230
1332
  "request",
@@ -1234,21 +1336,21 @@ var taskMessageKindSchema = z11.enum([
1234
1336
  ]);
1235
1337
 
1236
1338
  // src/task-message-input-schema.ts
1237
- var taskMessageInputSchema = z12.object({
1238
- to: z12.string(),
1339
+ var taskMessageInputSchema = z14.object({
1340
+ to: z14.string(),
1239
1341
  kind: taskMessageKindSchema,
1240
- body: z12.string(),
1241
- replyTo: z12.string().optional(),
1242
- onBehalfOf: z12.string().array().optional(),
1243
- wake: z12.boolean().optional()
1342
+ body: z14.string(),
1343
+ replyTo: z14.string().optional(),
1344
+ onBehalfOf: z14.string().array().optional(),
1345
+ wake: z14.boolean().optional()
1244
1346
  });
1245
1347
  // src/task-message-result-schema.ts
1246
- import { z as z13 } from "zod";
1247
- var taskMessageResultSchema = z13.object({
1248
- messageID: z13.string(),
1249
- woke: z13.boolean(),
1250
- hop: z13.int().nonnegative(),
1251
- note: z13.string().optional()
1348
+ import { z as z15 } from "zod";
1349
+ var taskMessageResultSchema = z15.object({
1350
+ messageID: z15.string(),
1351
+ woke: z15.boolean(),
1352
+ hop: z15.int().nonnegative(),
1353
+ note: z15.string().optional()
1252
1354
  });
1253
1355
  export {
1254
1356
  buildPendingInput,