@heynixie/contract 0.70.2 → 0.72.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.
Files changed (42) hide show
  1. package/dist/contract/action-proposal-schema.d.ts +18 -0
  2. package/dist/contract/approval-contract.d.ts +479 -0
  3. package/dist/{build-query-utils.d.ts → contract/build-query-utils.d.ts} +548 -191
  4. package/dist/{contract.d.ts → contract/contract.d.ts} +704 -243
  5. package/dist/contract/forgettable-kinds.d.ts +1 -0
  6. package/dist/{host-contract.d.ts → contract/host-contract.d.ts} +284 -0
  7. package/dist/contract/input-miss-schema.d.ts +23 -0
  8. package/dist/contract/known-contact-schema.d.ts +7 -0
  9. package/dist/contract/logged-input-schema.d.ts +36 -0
  10. package/dist/{memory-view-contract.d.ts → contract/memory-view-contract.d.ts} +92 -217
  11. package/dist/{moment-contract.d.ts → contract/moment-contract.d.ts} +1 -0
  12. package/dist/contract/pause-state-schema.d.ts +9 -0
  13. package/dist/contract/recovery-schema.d.ts +21 -0
  14. package/dist/contract/rule-contract.d.ts +106 -0
  15. package/dist/contract/turn-inputs-contract.d.ts +134 -0
  16. package/dist/index.d.ts +17 -17
  17. package/dist/index.js +979 -667
  18. package/dist/{build-pending-input.d.ts → span/build-pending-input.d.ts} +1 -1
  19. package/dist/{build-span-state.d.ts → span/build-span-state.d.ts} +1 -1
  20. package/dist/{pick-span-source.d.ts → span/pick-span-source.d.ts} +1 -1
  21. package/dist/types.d.ts +3 -3
  22. package/package.json +2 -2
  23. package/dist/proposal-outcome-schema.d.ts +0 -37
  24. package/dist/rule-contract.d.ts +0 -65
  25. /package/dist/{client-header-name.d.ts → contract/client-header-name.d.ts} +0 -0
  26. /package/dist/{forget-backup-schema.d.ts → contract/forget-backup-schema.d.ts} +0 -0
  27. /package/dist/{image-limits.d.ts → contract/image-limits.d.ts} +0 -0
  28. /package/dist/{image-not-found-error.d.ts → contract/image-not-found-error.d.ts} +0 -0
  29. /package/dist/{image-refused-error.d.ts → contract/image-refused-error.d.ts} +0 -0
  30. /package/dist/{is-time-zone.d.ts → contract/is-time-zone.d.ts} +0 -0
  31. /package/dist/{memory-export-contract.d.ts → contract/memory-export-contract.d.ts} +0 -0
  32. /package/dist/{render-session-cookie.d.ts → contract/render-session-cookie.d.ts} +0 -0
  33. /package/dist/{reused-id-errors.d.ts → contract/reused-id-errors.d.ts} +0 -0
  34. /package/dist/{session-cookie-name.d.ts → contract/session-cookie-name.d.ts} +0 -0
  35. /package/dist/{signed-in.d.ts → contract/signed-in.d.ts} +0 -0
  36. /package/dist/{task-schema.d.ts → contract/task-schema.d.ts} +0 -0
  37. /package/dist/{tool-call-schema.d.ts → contract/tool-call-schema.d.ts} +0 -0
  38. /package/dist/{task-message-input-schema.d.ts → message/task-message-input-schema.d.ts} +0 -0
  39. /package/dist/{task-message-kind-schema.d.ts → message/task-message-kind-schema.d.ts} +0 -0
  40. /package/dist/{task-message-result-schema.d.ts → message/task-message-result-schema.d.ts} +0 -0
  41. /package/dist/{has-several-words.d.ts → span/has-several-words.d.ts} +0 -0
  42. /package/dist/{span-schema.d.ts → span/span-schema.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- // src/has-several-words.ts
1
+ // src/span/has-several-words.ts
2
2
  function hasSeveralWords(text) {
3
3
  return /\S\s+\S/u.test(text);
4
4
  }
5
5
 
6
- // src/pick-span-source.ts
6
+ // src/span/pick-span-source.ts
7
7
  var pastedInputTypes = new Set(["insertFromPaste", "insertFromPasteAsQuotation"]);
8
8
  var typedInputTypes = new Set([
9
9
  "insertCompositionText",
@@ -29,7 +29,7 @@ function pickSpanSource(inputType, data) {
29
29
  return "unknown";
30
30
  }
31
31
 
32
- // src/build-pending-input.ts
32
+ // src/span/build-pending-input.ts
33
33
  function buildPendingInput(fields) {
34
34
  const pending = {
35
35
  selection: {
@@ -41,12 +41,12 @@ function buildPendingInput(fields) {
41
41
  };
42
42
  return fields.inputType === "insertText" && fields.data !== null && hasSeveralWords(fields.data) ? { ...pending, respacing: fields.data } : pending;
43
43
  }
44
- // src/build-query-utils.ts
44
+ // src/contract/build-query-utils.ts
45
45
  import { createTanstackQueryUtils } from "@orpc/tanstack-query";
46
46
  function buildQueryUtils(client) {
47
47
  return createTanstackQueryUtils(client, { path: ["nixie"] });
48
48
  }
49
- // src/build-span-state.ts
49
+ // src/span/build-span-state.ts
50
50
  function buildSpanState(state, pending, text) {
51
51
  const pinned = planEdit(state.text, text, pending?.selection);
52
52
  const fallback = pending === undefined || !isEditAtSelection(pinned, pending.selection);
@@ -146,42 +146,54 @@ function mergeSpans(spans) {
146
146
  }
147
147
  return merged;
148
148
  }
149
- // src/client-header-name.ts
149
+ // src/contract/client-header-name.ts
150
150
  var clientHeaderName = "x-nixie-client";
151
- // src/contract.ts
151
+ // src/contract/forgettable-kinds.ts
152
+ var forgettableKinds = [
153
+ "action.outcome",
154
+ "action.queued",
155
+ "action.retry_scheduled",
156
+ "memory.writer_failed",
157
+ "model.compaction_failed",
158
+ "model.reply",
159
+ "model.session_summarized",
160
+ "owner_message",
161
+ "policy.action_answered",
162
+ "policy.action_proposed",
163
+ "policy.contact_marked_known",
164
+ "prompts.override_rejected",
165
+ "proposals.deferred",
166
+ "session.enrolled",
167
+ "session.labelled",
168
+ "session_kept",
169
+ "skills.write_rejected",
170
+ "task.created",
171
+ "task.run_ended",
172
+ "task.run_report_requested",
173
+ "task.step_errored",
174
+ "task_message",
175
+ "tool_called",
176
+ "tool_result"
177
+ ];
178
+ // src/contract/contract.ts
152
179
  import { eventIterator as eventIterator2, oc as oc2 } from "@orpc/contract";
153
- import { z as z11 } from "zod";
154
-
155
- // src/image-limits.ts
156
- var imageLimits = {
157
- count: 4,
158
- bytes: 5 * 1024 * 1024,
159
- longEdge: 1568,
160
- mediaTypes: ["image/jpeg", "image/png", "image/webp", "image/gif"]
161
- };
162
-
163
- // src/image-not-found-error.ts
164
- var imageNotFoundError = {
165
- message: "No readable image of a message has this position",
166
- status: 404
167
- };
180
+ import { z as z13 } from "zod";
168
181
 
169
- // src/image-refused-error.ts
182
+ // src/span/span-schema.ts
170
183
  import { z } from "zod";
171
- var imageRefusedDataSchema = z.object({
172
- position: z.int().nonnegative().nullable(),
173
- reason: z.enum(["too_many", "too_large", "unsupported_type"])
184
+ var spanSchema = z.object({
185
+ end: z.int().nonnegative(),
186
+ source: z.enum(["typed", "pasted", "dropped", "unknown"]),
187
+ start: z.int().nonnegative()
174
188
  });
175
- var imageRefusedError = {
176
- message: "An image is too large, of a type nixie does not take, or one too many",
177
- status: 422,
178
- data: imageRefusedDataSchema
179
- };
180
189
 
181
- // src/memory-view-contract.ts
190
+ // src/contract/approval-contract.ts
182
191
  import { z as z6 } from "zod";
183
192
 
184
- // src/forget-backup-schema.ts
193
+ // src/contract/memory-view-contract.ts
194
+ import { z as z5 } from "zod";
195
+
196
+ // src/contract/forget-backup-schema.ts
185
197
  import { z as z2 } from "zod";
186
198
  var forgetBackupSchema = z2.discriminatedUnion("state", [
187
199
  z2.object({ state: z2.literal("off") }),
@@ -191,11 +203,11 @@ var forgetBackupSchema = z2.discriminatedUnion("state", [
191
203
  z2.object({ state: z2.literal("unknown") })
192
204
  ]);
193
205
 
194
- // src/memory-export-contract.ts
206
+ // src/contract/memory-export-contract.ts
195
207
  import { eventIterator } from "@orpc/contract";
196
208
  import { z as z3 } from "zod";
197
209
 
198
- // src/reused-id-errors.ts
210
+ // src/contract/reused-id-errors.ts
199
211
  var reusedIDErrors = {
200
212
  CLIENT_ACTION_ID_REUSED: {
201
213
  message: "The client action ID belongs to a different action",
@@ -203,13 +215,13 @@ var reusedIDErrors = {
203
215
  }
204
216
  };
205
217
 
206
- // src/signed-in.ts
218
+ // src/contract/signed-in.ts
207
219
  import { oc } from "@orpc/contract";
208
220
  var signedIn = oc.errors({
209
221
  UNAUTHORIZED: { message: "The device session is missing, lapsed or revoked", status: 401 }
210
222
  });
211
223
 
212
- // src/memory-export-contract.ts
224
+ // src/contract/memory-export-contract.ts
213
225
  var checkedExport = signedIn.errors(reusedIDErrors).errors({
214
226
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
215
227
  });
@@ -222,7 +234,7 @@ var memoryExportContract = {
222
234
  export: checkedExport.input(z3.object({ clientActionID: z3.uuid() })).output(exportEvents)
223
235
  };
224
236
 
225
- // src/moment-contract.ts
237
+ // src/contract/moment-contract.ts
226
238
  import { z as z4 } from "zod";
227
239
  var momentView = signedIn.errors({
228
240
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 },
@@ -298,6 +310,7 @@ var momentDetailSchema = momentSummarySchema.extend({
298
310
  });
299
311
  var spanRecordSchema = z4.object({
300
312
  isGap: z4.boolean(),
313
+ isRemoved: z4.boolean(),
301
314
  kind: z4.string(),
302
315
  recordedAt: z4.date(),
303
316
  sequence: z4.int().nonnegative(),
@@ -342,41 +355,7 @@ var momentContract = {
342
355
  destroyMoment: momentView.errors(reusedIDErrors).input(momentTargetSchema.extend({ clientActionID: z4.uuid() })).output(z4.object({ momentID: z4.string() }))
343
356
  };
344
357
 
345
- // src/proposal-outcome-schema.ts
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()
351
- });
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({
356
- item: closeMatchSchema,
357
- proposalID: z5.string(),
358
- status: z5.literal("close_match")
359
- }),
360
- z5.object({
361
- cause: z5.enum(["lapsed", "answered", "moved", "changed", "gone"]),
362
- proposalID: z5.string(),
363
- status: z5.literal("stale")
364
- }),
365
- z5.object({
366
- code: z5.enum([
367
- "CLIENT_ACTION_ID_REUSED",
368
- "PIN_EDIT",
369
- "PINNED_CORE_FULL",
370
- "RETIREMENT_EDIT",
371
- "REVISION_TARGET",
372
- "WRONG_STATE"
373
- ]),
374
- proposalID: z5.string(),
375
- status: z5.literal("refused")
376
- })
377
- ]);
378
-
379
- // src/memory-view-contract.ts
358
+ // src/contract/memory-view-contract.ts
380
359
  var memoryView = signedIn.errors({
381
360
  MEMORY_NOT_STARTED: { message: "The memory store has not started yet", status: 503 }
382
361
  });
@@ -385,68 +364,67 @@ var memoryChange = memoryView.errors(reusedIDErrors).errors({
385
364
  STALE_VERSION: { message: "The memory item has moved past that version", status: 409 },
386
365
  WRONG_STATE: { message: "The memory item is not in a state that change takes", status: 409 }
387
366
  });
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(),
367
+ var itemIDSchema = z5.string().min(1).max(200);
368
+ var proposalOriginSchema = z5.enum(["owner", "conversation", "task", "memory_writer"]);
369
+ var originSchema = z5.enum([...proposalOriginSchema.options, "lapse"]);
370
+ var sourceSchema = z5.enum(["owner", "owner_data", "untrusted"]);
371
+ var subjectSchema = z5.enum(["owner", "self", "shared"]);
372
+ var kindSchema = z5.enum(["fact", "self"]);
373
+ var memoryItemSchema = z5.object({
374
+ changedAt: z5.date(),
375
+ createdAt: z5.date(),
376
+ forgottenAt: z5.date().nullable(),
377
+ isPinned: z5.boolean(),
378
+ isSensitive: z5.boolean(),
379
+ itemID: z5.string(),
402
380
  kind: kindSchema,
403
381
  origin: originSchema,
404
- shortID: z6.string(),
382
+ shortID: z5.string(),
405
383
  source: sourceSchema,
406
- state: z6.enum(["active", "retired", "forgetting", "forgotten"]),
407
- status: z6.enum(["readable", "shredded", "unreadable"]),
384
+ state: z5.enum(["active", "retired", "forgetting", "forgotten"]),
385
+ status: z5.enum(["readable", "shredded", "unreadable"]),
408
386
  subject: subjectSchema,
409
- text: z6.string().optional(),
410
- until: z6.date().nullable(),
411
- version: z6.int().positive()
387
+ text: z5.string().optional(),
388
+ until: z5.date().nullable(),
389
+ version: z5.int().positive()
412
390
  });
413
391
  var memoryMatchSchema = memoryItemSchema.extend({
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()
392
+ score: z5.number().optional(),
393
+ similarity: z5.number().optional()
394
+ });
395
+ var evidenceSchema = z5.object({
396
+ end: z5.int().nonnegative(),
397
+ message: z5.object({
398
+ status: z5.enum(["readable", "shredded", "unreadable", "missing"]),
399
+ text: z5.string().optional()
422
400
  }).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(),
401
+ sequence: z5.int().nonnegative(),
402
+ start: z5.int().nonnegative()
403
+ });
404
+ var ownerImageSchema = z5.object({
405
+ position: z5.int().nonnegative(),
406
+ sequence: z5.int().positive(),
407
+ thread: z5.string()
408
+ });
409
+ var memoryVersionSchema = z5.object({
410
+ change: z5.enum(["created", "edited", "retired", "restored", "undone"]),
411
+ checkerModel: z5.string().nullable(),
412
+ checks: z5.record(z5.string(), z5.unknown()).nullable(),
435
413
  evidence: evidenceSchema.nullable(),
436
- evidenceQuote: z6.string().nullable(),
414
+ evidenceQuote: z5.string().nullable(),
437
415
  image: ownerImageSchema.nullable(),
438
416
  origin: originSchema,
439
- proposalID: z6.string().nullable(),
440
- recordedAt: z6.date(),
417
+ proposalID: z5.string().nullable(),
418
+ recordedAt: z5.date(),
441
419
  source: sourceSchema,
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([
420
+ state: z5.enum(["active", "retired"]),
421
+ status: z5.enum(["readable", "shredded", "unreadable"]),
422
+ taskID: z5.string().nullable(),
423
+ text: z5.string().optional(),
424
+ version: z5.int().positive(),
425
+ writerModel: z5.string().nullable()
426
+ });
427
+ var reviewReasonSchema = z5.enum([
450
428
  "no_quote",
451
429
  "quote_not_typed",
452
430
  "quote_in_quoted_block",
@@ -462,118 +440,104 @@ var reviewReasonSchema = z6.enum([
462
440
  "self_note",
463
441
  "from_photo",
464
442
  "sensitive",
465
- "subject_change"
443
+ "subject_change",
444
+ "ask_rule"
466
445
  ]);
467
- var proposalSourceSchema = z6.object({
446
+ var proposalSourceSchema = z5.object({
468
447
  origin: proposalOriginSchema,
469
- proposedAt: z6.date(),
470
- thread: z6.string().nullable()
448
+ proposedAt: z5.date(),
449
+ thread: z5.string().nullable()
471
450
  });
472
- var memoryProposalSchema = z6.object({
473
- actionHash: z6.string(),
474
- createdAt: z6.date(),
451
+ var memoryProposalSchema = z5.object({
452
+ actionHash: z5.string(),
453
+ createdAt: z5.date(),
475
454
  evidence: evidenceSchema.nullable(),
476
455
  image: ownerImageSchema.nullable(),
477
- isPinned: z6.boolean(),
478
- isSensitive: z6.boolean(),
479
- itemID: z6.string(),
456
+ isPinned: z5.boolean(),
457
+ isSensitive: z5.boolean(),
458
+ itemID: z5.string(),
480
459
  kind: kindSchema,
481
- lapseAt: z6.date(),
460
+ lapseAt: z5.date(),
482
461
  newSubject: subjectSchema.nullable(),
483
- operation: z6.enum(["remember", "retire", "pin"]),
462
+ operation: z5.enum(["remember", "retire", "pin"]),
484
463
  origin: proposalOriginSchema,
485
- proposalID: z6.string(),
486
- quote: z6.string().nullable(),
464
+ proposalID: z5.string(),
465
+ quote: z5.string().nullable(),
487
466
  reason: reviewReasonSchema,
488
467
  source: sourceSchema,
489
- sources: z6.array(proposalSourceSchema),
468
+ sources: z5.array(proposalSourceSchema),
490
469
  subject: subjectSchema,
491
- targetVersion: z6.int().positive().nullable(),
492
- text: z6.string(),
493
- until: z6.date().nullable()
494
- });
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)
499
- });
500
- var revisionTargetSchema = z6.object({ itemID: itemIDSchema, version: z6.int().positive() });
501
- var approvalAnswerSchema = proposalAnswerSchema.extend({
502
- editedText: itemTextSchema.optional(),
503
- ignoreCloseMatch: z6.boolean().optional(),
504
- revisionOf: revisionTargetSchema.optional()
505
- });
506
- var rejectionReasonSchema = z6.string().max(500).regex(/\S/u);
507
- var rejectionAnswerSchema = proposalAnswerSchema.extend({
508
- reason: rejectionReasonSchema.optional()
470
+ targetVersion: z5.int().positive().nullable(),
471
+ text: z5.string(),
472
+ until: z5.date().nullable()
509
473
  });
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()
474
+ var revisionTargetSchema = z5.object({ itemID: itemIDSchema, version: z5.int().positive() });
475
+ var memoryItemDetailSchema = memoryItemSchema.extend({ versions: z5.array(memoryVersionSchema) });
476
+ var forgetLossSchema = z5.object({
477
+ evidenceMessages: z5.int().nonnegative(),
478
+ proposals: z5.int().nonnegative()
515
479
  });
516
480
  var forgetPreviewSchema = memoryItemDetailSchema.extend({ lost: forgetLossSchema });
517
- var retiredForgetPreviewSchema = z6.object({
518
- hasMore: z6.boolean(),
519
- items: z6.array(memoryItemSchema.extend({ lost: forgetLossSchema }))
481
+ var retiredForgetPreviewSchema = z5.object({
482
+ hasMore: z5.boolean(),
483
+ items: z5.array(memoryItemSchema.extend({ lost: forgetLossSchema }))
520
484
  });
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, {
485
+ var retiredForgetSchema = z5.object({
486
+ clientActionID: z5.uuid(),
487
+ targets: z5.array(revisionTargetSchema).min(1).max(100).refine((targets) => new Set(targets.map((target) => target.itemID)).size === targets.length, {
524
488
  message: "Each item appears once"
525
489
  })
526
490
  });
527
- var forgetStatusSchema = z6.object({
528
- deleted: z6.array(z6.string()),
529
- pending: z6.array(z6.string()),
491
+ var forgetStatusSchema = z5.object({
492
+ deleted: z5.array(z5.string()),
493
+ pending: z5.array(z5.string()),
530
494
  backup: forgetBackupSchema
531
495
  });
532
- var versionTargetSchema = z6.object({
533
- clientActionID: z6.uuid(),
496
+ var versionTargetSchema = z5.object({
497
+ clientActionID: z5.uuid(),
534
498
  itemID: itemIDSchema,
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()
499
+ version: z5.int().positive()
500
+ });
501
+ var versionResultSchema = z5.object({ itemID: z5.string(), version: z5.int().positive() });
502
+ var noticeEntrySchema = z5.object({
503
+ change: z5.enum(["created", "edited", "retired", "restored", "undone", "proposed"]),
504
+ isKept: z5.boolean(),
505
+ item: memoryItemSchema.extend({ change: z5.enum(["created", "edited", "retired", "restored", "undone"]) }).nullable(),
506
+ itemID: z5.string(),
507
+ proposalID: z5.string().nullable(),
508
+ sequence: z5.int().nonnegative(),
509
+ version: z5.int().positive().nullable()
510
+ });
511
+ var memoryNoticeSchema = z5.object({
512
+ entries: z5.array(noticeEntrySchema),
513
+ kind: z5.enum(["turn", "batch", "catch_up", "run"]),
514
+ messageSequence: z5.int().nonnegative().nullable(),
515
+ noticeKey: z5.string(),
516
+ proposed: z5.int().nonnegative(),
517
+ remembered: z5.int().nonnegative(),
518
+ retired: z5.int().nonnegative(),
519
+ sequence: z5.int().nonnegative()
556
520
  });
557
521
  var memoryViewContract = {
558
- listItems: memoryView.errors({ INVALID_CURSOR: { message: "No page returned this cursor", status: 400 } }).input(z6.object({
559
- after: z6.string().max(20).optional(),
522
+ listItems: memoryView.errors({ INVALID_CURSOR: { message: "No page returned this cursor", status: 400 } }).input(z5.object({
523
+ after: z5.string().max(20).optional(),
560
524
  kind: kindSchema.optional(),
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"])
525
+ limit: z5.int().min(1).max(100).optional(),
526
+ state: z5.enum(["active", "retired", "forgotten"])
527
+ })).output(z5.object({ items: z5.array(memoryItemSchema), next: z5.string().nullable() })),
528
+ findItems: memoryView.input(z5.object({ query: z5.string().min(1).max(500) })).output(z5.object({
529
+ items: z5.array(memoryMatchSchema),
530
+ searchMode: z5.enum(["hybrid", "keyword", "keyword-fallback"])
567
531
  })),
568
- readPinnedCore: memoryView.output(z6.object({
569
- budget: z6.int().nonnegative(),
570
- items: z6.array(memoryItemSchema),
571
- tokens: z6.int().nonnegative()
532
+ readPinnedCore: memoryView.output(z5.object({
533
+ budget: z5.int().nonnegative(),
534
+ items: z5.array(memoryItemSchema),
535
+ tokens: z5.int().nonnegative()
572
536
  })),
573
- readItem: memoryView.errors({ MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 } }).input(z6.object({ itemID: itemIDSchema })).output(memoryItemDetailSchema),
537
+ readItem: memoryView.errors({ MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 } }).input(z5.object({ itemID: itemIDSchema })).output(memoryItemDetailSchema),
574
538
  retire: memoryChange.input(versionTargetSchema).output(versionResultSchema),
575
539
  restore: memoryChange.input(versionTargetSchema).output(versionResultSchema),
576
- listNotices: memoryView.input(z6.object({ thread: z6.string().min(1).max(200) })).output(z6.object({ notices: z6.array(memoryNoticeSchema) })),
540
+ listNotices: memoryView.input(z5.object({ thread: z5.string().min(1).max(200) })).output(z5.object({ notices: z5.array(memoryNoticeSchema) })),
577
541
  undo: memoryChange.errors({
578
542
  PINNED_CORE_FULL: { message: "The undo takes the pinned core past its budget", status: 409 }
579
543
  }).input(versionTargetSchema).output(versionResultSchema),
@@ -581,191 +545,365 @@ var memoryViewContract = {
581
545
  previewForget: memoryView.errors({
582
546
  MEMORY_ITEM_NOT_FOUND: { message: "No memory item has this ID", status: 404 },
583
547
  STALE_VERSION: { message: "The memory item has moved past that version", status: 409 }
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 })),
548
+ }).input(z5.object({ itemID: itemIDSchema, version: z5.int().positive() })).output(forgetPreviewSchema),
549
+ forget: memoryChange.input(versionTargetSchema).output(z5.object({ itemID: z5.string(), backup: forgetBackupSchema })),
586
550
  previewForgetRetired: memoryView.output(retiredForgetPreviewSchema),
587
551
  forgetRetired: memoryChange.input(retiredForgetSchema).output(forgetStatusSchema),
588
- readForgetStatus: memoryView.input(z6.object({ itemIDs: z6.array(itemIDSchema).min(1).max(100) })).output(forgetStatusSchema),
552
+ readForgetStatus: memoryView.input(z5.object({ itemIDs: z5.array(itemIDSchema).min(1).max(100) })).output(forgetStatusSchema),
589
553
  pin: memoryChange.errors({
590
554
  PINNED_CORE_FULL: { message: "The pin takes the pinned core past its budget", status: 409 }
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)
596
- })).output(proposalOutcomesSchema),
597
- rejectProposals: memoryView.input(z6.object({
598
- answers: z6.array(rejectionAnswerSchema).min(1).max(50)
599
- })).output(proposalOutcomesSchema),
555
+ }).input(versionTargetSchema.extend({ isPinned: z5.boolean() })).output(z5.object({ isPinned: z5.boolean(), itemID: z5.string() })),
556
+ markSensitive: memoryChange.input(z5.object({ clientActionID: z5.uuid(), isSensitive: z5.boolean(), itemID: itemIDSchema })).output(z5.object({ isSensitive: z5.boolean(), itemID: z5.string() })),
600
557
  ...memoryExportContract,
601
558
  ...momentContract
602
559
  };
603
560
 
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
561
+ // src/contract/approval-contract.ts
562
+ var choiceSchema = z6.enum(["approve", "always_allow", "defer", "decline"]);
563
+ var stateSchema = z6.enum(["pending", "deferred", "approved", "declined", "lapsed", "withdrawn"]);
564
+ var hashesSchema = z6.object({ actionHash: z6.string(), ruleHash: z6.string().nullable() });
565
+ var versionSchema = z6.int().positive();
566
+ var taskSchema = z6.object({ id: z6.string(), name: z6.string() });
567
+ var proposalSchema = z6.object({
568
+ proposalID: z6.string(),
569
+ shortID: z6.string(),
570
+ kind: z6.enum(["action", "memory_write", "internal_change"]),
571
+ riskClass: z6.enum(["routine", "always_ask", "lifting"]),
572
+ actionHash: z6.string(),
573
+ ruleHash: z6.string().nullable(),
574
+ cause: z6.string(),
575
+ state: stateSchema,
576
+ createdAt: z6.date(),
577
+ lapsesAt: z6.date(),
578
+ deadlineAt: z6.date().nullable(),
579
+ deferGeneration: z6.int().nonnegative(),
580
+ deferUntil: z6.date().nullable(),
581
+ thread: z6.string().nullable(),
582
+ taskID: z6.string().nullable(),
583
+ sequence: z6.int().positive()
584
+ });
585
+ var bodySchema = z6.object({
586
+ sentence: z6.string(),
587
+ fields: z6.record(z6.string(), z6.string()),
588
+ ruleSentence: z6.string().nullable(),
589
+ approveLabel: z6.string(),
590
+ memory: memoryProposalSchema.optional()
591
+ });
592
+ var itemSchema = z6.object({
593
+ group: z6.enum(["always_ask", "routine", "memory", "deferred"]),
594
+ proposal: proposalSchema,
595
+ body: bodySchema,
596
+ task: taskSchema.nullable(),
597
+ choices: z6.array(choiceSchema)
598
+ });
599
+ var readItemSchema = z6.object({
600
+ proposal: proposalSchema,
601
+ body: bodySchema.nullable(),
602
+ task: taskSchema.nullable(),
603
+ choices: z6.array(choiceSchema),
604
+ answeredOn: z6.string().nullable(),
605
+ isAnsweredHere: z6.boolean()
606
+ });
607
+ var deferSettingsSchema = z6.object({
608
+ defaultMinutes: z6.int().positive(),
609
+ eveningAt: z6.string(),
610
+ morningAt: z6.string(),
611
+ zone: z6.string()
612
+ });
613
+ var memoryAnswerSchema = z6.object({
614
+ editedText: z6.string().optional(),
615
+ revisionOf: z6.object({ itemID: z6.string(), version: versionSchema }).optional(),
616
+ ignoreCloseMatch: z6.boolean().optional()
617
+ });
618
+ var answerSchema = z6.object({
619
+ proposalID: z6.string().min(1).max(200),
620
+ actionHash: z6.string().min(1),
621
+ choice: choiceSchema,
622
+ ruleHash: z6.string().optional(),
623
+ deferUntil: z6.date().optional(),
624
+ note: z6.string().min(1).max(500).optional(),
625
+ clientActionID: z6.uuid(),
626
+ memory: memoryAnswerSchema.optional()
611
627
  });
612
- var ruleProposalSchema = z7.object({
613
- proposalID: z7.string(),
614
- changes: z7.array(ruleChangeSchema),
615
- createdAt: z7.date(),
616
- lapseAt: z7.date()
628
+ var ruleRefSchema = z6.object({ id: z6.string(), revision: versionSchema });
629
+ var closeMatchSchema = z6.object({ itemID: z6.string(), text: z6.string(), version: versionSchema });
630
+ var approvedSchema = z6.object({
631
+ proposalID: z6.string(),
632
+ state: z6.literal("approved"),
633
+ rule: ruleRefSchema.optional()
617
634
  });
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
635
+ var closedSchema = z6.object({ proposalID: z6.string(), state: z6.enum(["declined", "deferred"]) });
636
+ var closeMatchResultSchema = z6.object({
637
+ proposalID: z6.string(),
638
+ state: z6.literal("pending"),
639
+ closeMatch: closeMatchSchema
640
+ });
641
+ var resultSchema = z6.discriminatedUnion("state", [
642
+ approvedSchema,
643
+ closedSchema,
644
+ closeMatchResultSchema
645
+ ]);
646
+ var refusedSchema = z6.object({
647
+ proposalID: z6.string(),
648
+ error: z6.enum(["CONFLICT", "CLOSED", "NOT_ALLOWED"]),
649
+ current: hashesSchema.optional(),
650
+ state: stateSchema.optional(),
651
+ reason: z6.string().optional()
652
+ });
653
+ var answerErrors = signedIn.errors(reusedIDErrors).errors({
654
+ CONFLICT: {
655
+ message: "The proposal changed since the card showed it",
656
+ status: 409,
657
+ data: z6.object({ current: hashesSchema })
658
+ },
659
+ CLOSED: {
660
+ message: "The proposal is answered, withdrawn or lapsed",
661
+ status: 409,
662
+ data: z6.object({ state: stateSchema })
663
+ },
664
+ NOT_ALLOWED: {
665
+ message: "The proposal does not take this answer",
666
+ status: 403,
667
+ data: z6.object({ reason: z6.string() })
623
668
  }
624
669
  });
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() }))
670
+ var listedSchema = z6.object({ defer: deferSettingsSchema, items: z6.array(itemSchema) });
671
+ var readInputSchema = z6.object({
672
+ proposalIDs: z6.array(z6.string().min(1).max(200)).min(1).max(100)
673
+ });
674
+ var batchInputSchema = z6.object({ answers: z6.array(answerSchema).min(1).max(100) });
675
+ var batchResultSchema = z6.object({ results: z6.array(z6.union([resultSchema, refusedSchema])) });
676
+ var approvalContract = {
677
+ listItems: signedIn.output(listedSchema),
678
+ readProposals: signedIn.input(readInputSchema).output(z6.object({ proposals: z6.array(readItemSchema) })),
679
+ answerProposal: answerErrors.input(answerSchema).output(resultSchema),
680
+ answerProposals: signedIn.errors(reusedIDErrors).input(batchInputSchema).output(batchResultSchema)
630
681
  };
631
682
 
632
- // src/span-schema.ts
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()
683
+ // src/contract/image-limits.ts
684
+ var imageLimits = {
685
+ count: 4,
686
+ bytes: 5 * 1024 * 1024,
687
+ longEdge: 1568,
688
+ mediaTypes: ["image/jpeg", "image/png", "image/webp", "image/gif"]
689
+ };
690
+
691
+ // src/contract/image-not-found-error.ts
692
+ var imageNotFoundError = {
693
+ message: "No readable image of a message has this position",
694
+ status: 404
695
+ };
696
+
697
+ // src/contract/image-refused-error.ts
698
+ import { z as z7 } from "zod";
699
+ var imageRefusedDataSchema = z7.object({
700
+ position: z7.int().nonnegative().nullable(),
701
+ reason: z7.enum(["too_many", "too_large", "unsupported_type"])
638
702
  });
703
+ var imageRefusedError = {
704
+ message: "An image is too large, of a type nixie does not take, or one too many",
705
+ status: 422,
706
+ data: imageRefusedDataSchema
707
+ };
639
708
 
640
- // src/task-schema.ts
709
+ // src/contract/pause-state-schema.ts
710
+ import { z as z8 } from "zod";
711
+ var pauseCauseSchema = z8.enum(["restore", "owner", "spending"]);
712
+ var pauseStateSchema = z8.object({ cause: pauseCauseSchema, since: z8.date() }).nullable();
713
+
714
+ // src/contract/recovery-schema.ts
641
715
  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()
652
- });
716
+ var taskStateSchema = z9.enum([
717
+ "ready",
718
+ "running",
719
+ "waiting",
720
+ "paused",
721
+ "stopped",
722
+ "done",
723
+ "failed",
724
+ "closed"
725
+ ]);
726
+ var taskToCheckSchema = z9.object({
727
+ taskID: z9.string(),
728
+ name: z9.string(),
729
+ stateAtBackup: taskStateSchema,
730
+ wasRunning: z9.boolean(),
731
+ pendingActions: z9.int().nonnegative()
732
+ });
733
+ var recoverySchema = z9.object({
734
+ restoredAt: z9.date(),
735
+ backupTakenAt: z9.date(),
736
+ toCheck: z9.array(taskToCheckSchema)
737
+ }).nullable();
653
738
 
654
- // src/tool-call-schema.ts
739
+ // src/contract/rule-contract.ts
655
740
  import { z as z10 } from "zod";
656
- var jsonObjectSchema = z10.record(z10.string(), z10.unknown());
657
- var toolCallSchema = z10.object({
658
- callID: z10.string(),
741
+ var ruleIDSchema = z10.string().min(1).max(200);
742
+ var revisionSchema = z10.int().positive();
743
+ var ruleSchema = z10.object({
744
+ ruleID: z10.string(),
745
+ revision: revisionSchema,
746
+ sentence: z10.string(),
747
+ outcome: z10.enum(["allow", "ask", "deny"]),
748
+ destinations: z10.array(z10.string())
749
+ });
750
+ var notFound = { NOT_FOUND: { message: "No rule has this ID", status: 404 } };
751
+ var ruleChange = signedIn.errors(reusedIDErrors).errors({
752
+ ...notFound,
753
+ CONFLICT: {
754
+ message: "The rule changed since the notice showed it",
755
+ status: 409,
756
+ data: z10.object({ revision: revisionSchema })
757
+ },
758
+ NOT_ALLOWED: {
759
+ message: "The rule takes no such change",
760
+ status: 403,
761
+ data: z10.object({ reason: z10.enum(["widens", "empty"]) })
762
+ }
763
+ });
764
+ var destinationsSchema = z10.array(z10.string().regex(/^\S+$/u)).max(100);
765
+ var ruleContract = {
766
+ readRule: signedIn.errors(notFound).input(z10.object({ ruleID: ruleIDSchema })).output(ruleSchema),
767
+ removeRule: ruleChange.input(z10.object({ ruleID: ruleIDSchema, revision: revisionSchema, clientActionID: z10.uuid() })).output(z10.object({ ruleID: z10.string() })),
768
+ editRule: ruleChange.input(z10.object({
769
+ ruleID: ruleIDSchema,
770
+ revision: revisionSchema,
771
+ destinations: destinationsSchema,
772
+ clientActionID: z10.uuid()
773
+ })).output(z10.object({ ruleID: z10.string(), revision: revisionSchema }))
774
+ };
775
+
776
+ // src/contract/task-schema.ts
777
+ import { z as z11 } from "zod";
778
+ var taskSchema2 = z11.object({
779
+ error: z11.string().optional(),
780
+ errorLimit: z11.int().positive().optional(),
781
+ errors: z11.int().positive().optional(),
782
+ isWaitingForRetry: z11.boolean().optional(),
783
+ readCursor: z11.int().nonnegative().optional(),
784
+ reason: z11.string().optional(),
785
+ retryAt: z11.date().optional(),
786
+ stepKey: z11.string().optional(),
787
+ taskID: z11.string()
788
+ });
789
+
790
+ // src/contract/tool-call-schema.ts
791
+ import { z as z12 } from "zod";
792
+ var jsonObjectSchema = z12.record(z12.string(), z12.unknown());
793
+ var toolCallSchema = z12.object({
794
+ callID: z12.string(),
659
795
  content: jsonObjectSchema.optional(),
660
796
  input: jsonObjectSchema.optional(),
661
- outcome: z10.string().optional(),
662
- tool: z10.string().optional()
797
+ outcome: z12.string().optional(),
798
+ tool: z12.string().optional()
663
799
  });
664
800
 
665
- // src/contract.ts
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(),
801
+ // src/contract/contract.ts
802
+ var clientActionIDSchema = z13.uuid();
803
+ var sequenceSchema = z13.int().nonnegative();
804
+ var threadSchema = z13.string().min(1).max(200);
805
+ var imageSchema = z13.object({ mediaType: z13.enum(imageLimits.mediaTypes) });
806
+ var imageFilesSchema = z13.array(z13.file());
807
+ var imageRefSchema = z13.object({
808
+ position: z13.int().nonnegative(),
673
809
  sequence: sequenceSchema,
674
810
  thread: threadSchema
675
811
  });
676
- var versionRefSchema = z11.object({
677
- itemID: z11.string().min(1).max(200),
678
- version: z11.int().nonnegative()
812
+ var versionRefSchema = z13.object({
813
+ itemID: z13.string().min(1).max(200),
814
+ version: z13.int().nonnegative()
679
815
  });
680
- var recallItemSchema = versionRefSchema.extend({ score: z11.number().optional() });
681
- var recallSchema = z11.object({ items: z11.array(recallItemSchema) });
816
+ var recallItemSchema = versionRefSchema.extend({ score: z13.number().optional() });
817
+ var recallSchema = z13.object({ items: z13.array(recallItemSchema) });
682
818
  var ratingItemSchema = versionRefSchema.extend({
683
- hasNote: z11.boolean(),
684
- verdict: z11.enum(["helpful", "noise", "misleading"])
819
+ hasNote: z13.boolean(),
820
+ verdict: z13.enum(["helpful", "noise", "misleading"])
685
821
  });
686
- var ratingSchema = z11.object({
687
- items: z11.array(ratingItemSchema),
688
- ratedBy: z11.string().optional(),
822
+ var ratingSchema = z13.object({
823
+ items: z13.array(ratingItemSchema),
824
+ ratedBy: z13.string().optional(),
689
825
  recalledSequence: sequenceSchema
690
826
  });
691
- var tokenCountSchema = z11.int().nonnegative();
692
- var contextSchema = z11.object({ size: tokenCountSchema, window: z11.int().positive() });
693
- var compactionSchema = z11.object({
827
+ var tokenCountSchema = z13.int().nonnegative();
828
+ var contextSchema = z13.object({ size: tokenCountSchema, window: z13.int().positive() });
829
+ var compactionSchema = z13.object({
694
830
  postTokens: tokenCountSchema.optional(),
695
831
  preTokens: tokenCountSchema,
696
- trigger: z11.enum(["manual", "auto"])
832
+ trigger: z13.enum(["manual", "auto"])
697
833
  });
698
- var summarySchema = z11.object({
834
+ var summarySchema = z13.object({
699
835
  contextSize: tokenCountSchema.optional(),
700
836
  summaryTokens: tokenCountSchema,
701
- text: z11.string().optional(),
702
- trigger: z11.enum(["threshold", "overflow"])
837
+ text: z13.string().optional(),
838
+ trigger: z13.enum(["threshold", "overflow"])
703
839
  });
704
- var compactionFailureSchema = z11.object({ failures: z11.int().positive() });
705
- var ratingNoteRefSchema = z11.object({
706
- itemID: z11.string().min(1).max(200),
840
+ var compactionFailureSchema = z13.object({ failures: z13.int().positive() });
841
+ var ratingNoteRefSchema = z13.object({
842
+ itemID: z13.string().min(1).max(200),
707
843
  sequence: sequenceSchema
708
844
  });
709
845
  var ratingNoteSchema = ratingNoteRefSchema.extend({
710
- status: z11.enum(["readable", "shredded", "unreadable", "missing"]),
711
- text: z11.string().optional()
846
+ status: z13.enum(["readable", "shredded", "unreadable", "missing"]),
847
+ text: z13.string().optional()
712
848
  });
713
849
  var versionTextSchema = versionRefSchema.extend({
714
- status: z11.enum(["readable", "shredded", "unreadable", "missing"]),
715
- text: z11.string().optional()
850
+ status: z13.enum(["readable", "shredded", "unreadable", "missing"]),
851
+ text: z13.string().optional()
716
852
  });
717
- var listedActionSchema = z11.object({ actionID: z11.string(), tool: z11.string() });
718
- var taskMessageSchema = z11.object({
853
+ var listedActionSchema = z13.object({ actionID: z13.string(), tool: z13.string() });
854
+ var taskMessageSchema = z13.object({
719
855
  from: threadSchema,
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(),
856
+ fromName: z13.string(),
857
+ hop: z13.int().nonnegative(),
858
+ kind: z13.string(),
859
+ messageID: z13.string(),
860
+ replyTo: z13.string().optional(),
861
+ text: z13.string().optional(),
726
862
  to: threadSchema,
727
- woke: z11.boolean()
863
+ woke: z13.boolean()
728
864
  });
729
- var exchangeNoticeSchema = z11.object({
730
- link: z11.object({ label: z11.string(), messageID: z11.string(), taskID: threadSchema }),
731
- text: z11.string()
865
+ var exchangeNoticeSchema = z13.object({
866
+ link: z13.object({ label: z13.string(), messageID: z13.string(), taskID: threadSchema }),
867
+ text: z13.string()
732
868
  });
733
- var recordSchema = z11.object({
869
+ var recordSchema = z13.object({
734
870
  compaction: compactionSchema.optional(),
735
871
  exchangeNotice: exchangeNoticeSchema.optional(),
736
872
  compactionFailure: compactionFailureSchema.optional(),
737
- forget: z11.object({ sequence: sequenceSchema }).optional(),
873
+ forget: z13.object({ sequence: sequenceSchema }).optional(),
738
874
  context: contextSchema.optional(),
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()
875
+ isRemoved: z13.literal(true).optional(),
876
+ isSilentTurn: z13.literal(true).optional(),
877
+ kind: z13.string(),
878
+ message: z13.object({
879
+ clientMessageId: z13.uuid().optional(),
880
+ images: z13.array(imageSchema).optional(),
881
+ spans: z13.array(spanSchema).optional(),
882
+ text: z13.string()
746
883
  }).optional(),
747
- moment: z11.object({ momentID: z11.string(), shortID: z11.string(), title: z11.string().optional() }).optional(),
884
+ moment: z13.object({ momentID: z13.string(), shortID: z13.string(), title: z13.string().optional() }).optional(),
748
885
  rating: ratingSchema.optional(),
886
+ proposal: z13.object({ proposalID: z13.string(), shortID: z13.string() }).optional(),
749
887
  recall: recallSchema.optional(),
750
- recordedAt: z11.date(),
888
+ recordedAt: z13.date(),
751
889
  sequence: sequenceSchema,
752
- stop: z11.object({ cancelledActions: z11.array(listedActionSchema) }).optional(),
890
+ stop: z13.object({ cancelledActions: z13.array(listedActionSchema) }).optional(),
753
891
  summary: summarySchema.optional(),
754
892
  thread: threadSchema,
755
- task: taskSchema.optional(),
893
+ task: taskSchema2.optional(),
756
894
  taskMessage: taskMessageSchema.optional(),
757
895
  toolCall: toolCallSchema.optional()
758
896
  });
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()
897
+ var writerErrorSchema = z13.object({ at: z13.date(), code: z13.string(), message: z13.string().nullable() }).nullable();
898
+ var sessionSchema = z13.object({
899
+ createdAt: z13.date(),
900
+ current: z13.boolean(),
901
+ deviceName: z13.string(),
902
+ lastUsedAt: z13.date(),
903
+ sessionID: z13.uuid()
766
904
  });
767
905
  var checkedAction = signedIn.errors(reusedIDErrors);
768
- var taskStateSchema = z11.enum([
906
+ var taskStateSchema2 = z13.enum([
769
907
  "ready",
770
908
  "running",
771
909
  "waiting",
@@ -775,28 +913,34 @@ var taskStateSchema = z11.enum([
775
913
  "failed",
776
914
  "closed"
777
915
  ]);
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({
916
+ var taskControlSchema = z13.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
917
+ var actionCountSchema = z13.int().nonnegative();
918
+ var forgetPreviewItemSchema = z13.object({ itemID: z13.string(), text: z13.string() });
919
+ var recordForgetPreviewSchema = z13.object({
920
+ momentCount: actionCountSchema,
921
+ memoryItems: z13.array(forgetPreviewItemSchema)
922
+ });
923
+ var listedTaskSchema = z13.object({
924
+ actions: z13.object({
782
925
  cancelled: actionCountSchema,
783
926
  queued: actionCountSchema,
784
927
  started: actionCountSchema
785
928
  }),
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(),
792
- state: taskStateSchema,
929
+ brief: z13.string(),
930
+ controls: z13.array(taskControlSchema),
931
+ isPauseRequested: z13.boolean(),
932
+ isPausedByNixie: z13.boolean(),
933
+ isTakingMessages: z13.boolean(),
934
+ lastActivityAt: z13.date(),
935
+ name: z13.string(),
936
+ state: taskStateSchema2,
793
937
  taskID: threadSchema,
794
938
  waitingOn: threadSchema.optional()
795
939
  });
796
- var controlledTaskSchema = z11.object({
797
- controlledAt: z11.date(),
798
- isPauseRequested: z11.boolean(),
799
- state: taskStateSchema,
940
+ var controlledTaskSchema = z13.object({
941
+ controlledAt: z13.date(),
942
+ isPauseRequested: z13.boolean(),
943
+ state: taskStateSchema2,
800
944
  taskID: threadSchema
801
945
  });
802
946
  var taskControl = checkedAction.errors({
@@ -804,63 +948,74 @@ var taskControl = checkedAction.errors({
804
948
  TASK_STATE_REFUSED: {
805
949
  message: "The task is in a state that does not take this control",
806
950
  status: 409,
807
- data: z11.object({ isPauseRequested: z11.boolean(), state: taskStateSchema })
951
+ data: z13.object({ isPauseRequested: z13.boolean(), state: taskStateSchema2 })
808
952
  }
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 })));
953
+ }).input(z13.object({ clientActionID: clientActionIDSchema, taskID: threadSchema })).output(controlledTaskSchema);
954
+ var nixieControl = checkedAction.input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ paused: pauseStateSchema }));
955
+ var backupNoticeSchema = z13.object({
956
+ cause: z13.enum(["failed", "missing"]),
957
+ sequence: z13.int().positive(),
958
+ raisedAt: z13.date()
959
+ });
960
+ var followRecords = signedIn.input(z13.object({ afterSequence: sequenceSchema, thread: threadSchema.optional() })).output(eventIterator2(z13.object({ record: recordSchema })));
816
961
  var contract = {
817
962
  conversation: {
818
- read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z11.object({
963
+ read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z13.object({
819
964
  beforeSequence: sequenceSchema.optional(),
820
- limit: z11.int().min(1).max(200).optional(),
965
+ limit: z13.int().min(1).max(200).optional(),
821
966
  thread: threadSchema
822
- })).output(z11.object({
823
- hasEarlier: z11.boolean(),
967
+ })).output(z13.object({
968
+ hasEarlier: z13.boolean(),
824
969
  readAtSequence: sequenceSchema,
825
- records: z11.array(recordSchema),
970
+ records: z13.array(recordSchema),
826
971
  lastStepEnd: recordSchema.nullable().optional()
827
972
  })),
828
973
  send: checkedAction.errors({
829
974
  IMAGE_REFUSED: imageRefusedError,
830
975
  THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 }
831
- }).input(z11.object({
976
+ }).input(z13.object({
832
977
  clientMessageId: clientActionIDSchema,
833
978
  images: imageFilesSchema.optional(),
834
- spans: z11.array(spanSchema).max(1e5),
835
- text: z11.string().min(1).max(1e5),
979
+ spans: z13.array(spanSchema).max(1e5),
980
+ text: z13.string().min(1).max(1e5),
836
981
  thread: threadSchema,
837
- timeZone: z11.string().min(1).max(100).optional(),
838
- writtenAt: z11.iso.datetime().optional()
839
- })).output(z11.object({ duplicate: z11.boolean(), sequence: sequenceSchema })),
982
+ timeZone: z13.string().min(1).max(100).optional(),
983
+ writtenAt: z13.iso.datetime().optional()
984
+ })).output(z13.object({ duplicate: z13.boolean(), sequence: sequenceSchema })),
840
985
  retry: checkedAction.errors({
841
986
  NOTHING_TO_RETRY: {
842
987
  message: "The last turn of the conversation did not fail, or it runs again already",
843
988
  status: 409
844
989
  }
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()),
990
+ }).input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ retriedAt: z13.date() })),
991
+ readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z13.file()),
992
+ previewForget: signedIn.errors({
993
+ RECORD_NOT_FOUND: {
994
+ message: "No record on this thread with its own text that a forget removes has this sequence",
995
+ status: 404
996
+ }
997
+ }).input(z13.object({ thread: threadSchema, sequence: sequenceSchema })).output(recordForgetPreviewSchema),
847
998
  forget: checkedAction.errors({
848
999
  RECORD_NOT_FOUND: {
849
- message: "No message or reply on this thread has this sequence",
1000
+ message: "No record on this thread with its own text that a forget removes has this sequence",
850
1001
  status: 404
1002
+ },
1003
+ ACTION_NOT_FINISHED: {
1004
+ message: "The queued action has not run yet. Cancel it, or wait for it to run.",
1005
+ status: 409
851
1006
  }
852
- }).input(z11.object({
1007
+ }).input(z13.object({
853
1008
  clientActionID: clientActionIDSchema,
854
1009
  sequence: sequenceSchema,
855
1010
  thread: threadSchema
856
- })).output(z11.object({ forgottenAt: z11.date() }))
1011
+ })).output(z13.object({ forgottenAt: z13.date(), backup: forgetBackupSchema }))
857
1012
  },
858
1013
  tasks: {
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)
1014
+ list: signedIn.output(z13.object({ readAtSequence: sequenceSchema, tasks: z13.array(listedTaskSchema) })),
1015
+ read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z13.object({ taskID: threadSchema })).output(listedTaskSchema),
1016
+ readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z13.object({ taskID: threadSchema })).output(z13.object({
1017
+ queued: z13.array(listedActionSchema),
1018
+ started: z13.array(listedActionSchema)
864
1019
  })),
865
1020
  pause: taskControl,
866
1021
  resume: taskControl,
@@ -872,25 +1027,34 @@ var contract = {
872
1027
  interrupt: taskControl
873
1028
  },
874
1029
  memory: {
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(),
1030
+ readVersions: signedIn.input(z13.object({ versions: z13.array(versionRefSchema).min(1).max(100) })).output(z13.object({ versions: z13.array(versionTextSchema) })),
1031
+ readRatingNotes: signedIn.input(z13.object({ notes: z13.array(ratingNoteRefSchema).min(1).max(100) })).output(z13.object({ notes: z13.array(ratingNoteSchema) })),
1032
+ writerStatus: signedIn.output(z13.object({
1033
+ isEnabled: z13.boolean(),
1034
+ backlog: z13.int().nonnegative(),
1035
+ batches: z13.int().nonnegative(),
881
1036
  cursor: sequenceSchema,
882
- failures: z11.int().nonnegative(),
883
- isCatchingUp: z11.boolean(),
1037
+ failures: z13.int().nonnegative(),
1038
+ isCatchingUp: z13.boolean(),
884
1039
  lastError: writerErrorSchema,
885
- retryAt: z11.date().nullable()
1040
+ retryAt: z13.date().nullable()
886
1041
  })),
887
- consolidatorStatus: signedIn.output(z11.object({ isEnabled: z11.boolean() })),
1042
+ consolidatorStatus: signedIn.output(z13.object({ isEnabled: z13.boolean() })),
888
1043
  ...memoryViewContract
889
1044
  },
1045
+ nixie: {
1046
+ read: signedIn.output(z13.object({ paused: pauseStateSchema })),
1047
+ pause: nixieControl,
1048
+ resume: nixieControl
1049
+ },
1050
+ recovery: {
1051
+ read: signedIn.output(z13.object({ recovery: recoverySchema }))
1052
+ },
890
1053
  backups: {
891
- readNotice: signedIn.output(z11.object({ notice: backupNoticeSchema.nullable() }))
1054
+ readNotice: signedIn.output(z13.object({ notice: backupNoticeSchema.nullable() }))
892
1055
  },
893
1056
  rules: ruleContract,
1057
+ approvals: approvalContract,
894
1058
  log: {
895
1059
  follow: followRecords.route({ deprecated: true })
896
1060
  },
@@ -903,30 +1067,142 @@ var contract = {
903
1067
  message: "The enrolment code is unknown, used or lapsed",
904
1068
  status: 400
905
1069
  }
906
- }).input(z11.object({
1070
+ }).input(z13.object({
907
1071
  clientActionID: clientActionIDSchema,
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() }))
1072
+ code: z13.string().min(1).max(100),
1073
+ deviceName: z13.string().min(1).max(100),
1074
+ tokenDelivery: z13.enum(["cookie", "bearer"])
1075
+ })).output(z13.object({ sessionID: z13.uuid(), token: z13.string().optional() })),
1076
+ issueCode: checkedAction.input(z13.object({ clientActionID: clientActionIDSchema })).output(z13.object({ code: z13.string(), expiresAt: z13.date() })),
1077
+ list: signedIn.output(z13.object({ sessions: z13.array(sessionSchema) })),
1078
+ revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(z13.object({ clientActionID: clientActionIDSchema, sessionID: z13.uuid() })).output(z13.object({ revokedAt: z13.date() }))
915
1079
  }
916
1080
  };
917
- // src/host-contract.ts
1081
+ // src/contract/host-contract.ts
1082
+ import { oc as oc4 } from "@orpc/contract";
1083
+ import { z as z19 } from "zod";
1084
+
1085
+ // src/contract/action-proposal-schema.ts
1086
+ import { z as z14 } from "zod";
1087
+ var actionProposalSchema = z14.object({
1088
+ proposalID: z14.string(),
1089
+ tool: z14.string(),
1090
+ effects: z14.array(z14.string()),
1091
+ cause: z14.enum([
1092
+ "outside_steering",
1093
+ "always_ask",
1094
+ "ask_rule",
1095
+ "no_rule",
1096
+ "direct_request",
1097
+ "repeat"
1098
+ ]),
1099
+ sentence: z14.string(),
1100
+ destinations: z14.array(z14.string()),
1101
+ createdAt: z14.date(),
1102
+ lapseAt: z14.date()
1103
+ });
1104
+
1105
+ // src/contract/known-contact-schema.ts
1106
+ import { z as z15 } from "zod";
1107
+ var knownContactSchema = z15.object({
1108
+ contactID: z15.string(),
1109
+ name: z15.string().nullable(),
1110
+ destination: z15.string().nullable(),
1111
+ markedAt: z15.date()
1112
+ });
1113
+
1114
+ // src/contract/turn-inputs-contract.ts
918
1115
  import { oc as oc3 } from "@orpc/contract";
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([
1116
+ import { z as z18 } from "zod";
1117
+
1118
+ // src/contract/input-miss-schema.ts
1119
+ import { z as z16 } from "zod";
1120
+ var inputMissSchema = z16.object({
1121
+ missID: z16.string(),
1122
+ captureID: z16.string().nullable(),
1123
+ taskID: z16.string(),
1124
+ stepRunID: z16.string(),
1125
+ reason: z16.enum([
1126
+ "queue_full",
1127
+ "spool_full",
1128
+ "spool_write_failed",
1129
+ "seal_failed",
1130
+ "no_capture_point",
1131
+ "not_received",
1132
+ "undecodable",
1133
+ "capture_closed",
1134
+ "intake_failed",
1135
+ "holds_own_value"
1136
+ ]),
1137
+ count: z16.int().positive(),
1138
+ writer: z16.string().nullable(),
1139
+ counter: z16.int().nullable(),
1140
+ createdAt: z16.date()
1141
+ });
1142
+
1143
+ // src/contract/logged-input-schema.ts
1144
+ import { z as z17 } from "zod";
1145
+ var loggedInputSchema = z17.object({
1146
+ inputID: z17.string(),
1147
+ captureID: z17.string(),
1148
+ taskID: z17.string(),
1149
+ stepRunID: z17.string(),
1150
+ writer: z17.string(),
1151
+ counter: z17.int(),
1152
+ role: z17.string(),
1153
+ profile: z17.string(),
1154
+ model: z17.string(),
1155
+ harness: z17.string(),
1156
+ api: z17.string(),
1157
+ endpoint: z17.string(),
1158
+ route: z17.string(),
1159
+ isRewritten: z17.boolean(),
1160
+ upstreamStatus: z17.int(),
1161
+ bytes: z17.int(),
1162
+ intakeSequence: z17.int(),
1163
+ receivedAt: z17.date(),
1164
+ takenAt: z17.date(),
1165
+ state: z17.enum(["writing", "stored", "missing", "removed"]),
1166
+ removedCause: z17.enum(["retention_days", "retention_bytes", "forget", "dropped", "restore", "reset"]).nullable()
1167
+ });
1168
+
1169
+ // src/contract/turn-inputs-contract.ts
1170
+ var turnInputOn = z18.strictObject({
1171
+ state: z18.literal("on"),
1172
+ forMs: z18.int().positive().nullable()
1173
+ });
1174
+ var turnInputOff = z18.strictObject({ state: z18.literal("off"), drop: z18.boolean() });
1175
+ var turnInputSetSchema = z18.discriminatedUnion("state", [turnInputOn, turnInputOff]);
1176
+ var turnInputs = oc3.errors({
1177
+ NOT_FOUND: { message: "no logged request has that ID", status: 404 },
1178
+ REMOVED: { message: "that request is removed or its body is missing", status: 410 },
1179
+ OPEN_NOT_RECORDED: {
1180
+ message: "the opening could not be recorded, so no body is read",
1181
+ status: 503
1182
+ },
1183
+ NOT_CONFIGURED: { message: "the turn-input log is not configured", status: 409 }
1184
+ });
1185
+ var listedInputsSchema = z18.object({
1186
+ inputs: z18.array(loggedInputSchema),
1187
+ misses: z18.array(inputMissSchema)
1188
+ });
1189
+ var turnInputsContract = {
1190
+ list: turnInputs.input(z18.strictObject({ limit: z18.int().positive().max(500).default(50) })).output(listedInputsSchema),
1191
+ open: turnInputs.input(z18.strictObject({ inputID: z18.string().min(1) })).output(z18.object({ inputID: z18.string(), body: z18.base64() })),
1192
+ set: turnInputs.input(turnInputSetSchema).output(z18.object({ state: z18.enum(["on", "off"]), until: z18.number().nullable() }))
1193
+ };
1194
+
1195
+ // src/contract/host-contract.ts
1196
+ var versionRefSchema2 = z19.object({ itemID: z19.string(), version: z19.int().positive() });
1197
+ var versionTargetSchema2 = z19.strictObject({
1198
+ itemID: z19.string().min(1),
1199
+ version: z19.int().positive()
1200
+ });
1201
+ var itemTextSchema = z19.string().max(2000).regex(/\S/u);
1202
+ var proposalOriginSchema2 = z19.enum(["owner", "conversation", "task", "memory_writer"]);
1203
+ var memoryOriginSchema = z19.enum([...proposalOriginSchema2.options, "lapse"]);
1204
+ var contentSourceSchema = z19.enum(["owner", "owner_data", "untrusted"]);
1205
+ var reviewReasonSchema2 = z19.enum([
930
1206
  "no_quote",
931
1207
  "quote_not_typed",
932
1208
  "quote_in_quoted_block",
@@ -942,109 +1218,110 @@ var reviewReasonSchema2 = z12.enum([
942
1218
  "self_note",
943
1219
  "from_photo",
944
1220
  "sensitive",
945
- "subject_change"
1221
+ "subject_change",
1222
+ "ask_rule"
946
1223
  ]);
947
- var proposalSourceSchema2 = z12.object({
1224
+ var proposalSourceSchema2 = z19.object({
948
1225
  origin: proposalOriginSchema2,
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"]),
1226
+ thread: z19.string().nullable(),
1227
+ proposedAt: z19.date()
1228
+ });
1229
+ var pendingProposalSchema = z19.object({
1230
+ proposalID: z19.string(),
1231
+ operation: z19.enum(["remember", "retire", "pin"]),
1232
+ itemID: z19.string(),
1233
+ targetVersion: z19.int().nullable(),
1234
+ isPinned: z19.boolean(),
1235
+ subject: z19.enum(["owner", "self", "shared"]),
1236
+ newSubject: z19.enum(["owner", "self", "shared"]).nullable(),
1237
+ isSensitive: z19.boolean(),
1238
+ kind: z19.enum(["fact", "self"]),
962
1239
  reason: reviewReasonSchema2,
963
- actionHash: z12.string(),
1240
+ actionHash: z19.string(),
964
1241
  origin: proposalOriginSchema2,
965
1242
  source: contentSourceSchema,
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 })
1243
+ createdAt: z19.date(),
1244
+ lapseAt: z19.date(),
1245
+ sources: z19.array(proposalSourceSchema2),
1246
+ text: z19.string(),
1247
+ quote: z19.string().nullable()
1248
+ });
1249
+ var closeMatchSchema2 = z19.object({ itemID: z19.string(), version: z19.int(), text: z19.string() });
1250
+ var approvalResultSchema = z19.discriminatedUnion("status", [
1251
+ z19.object({ status: z19.literal("applied"), itemID: z19.string(), version: z19.int() }),
1252
+ z19.object({ status: z19.literal("close_match"), item: closeMatchSchema2 })
976
1253
  ]);
977
- var historyVersionSchema = z12.object({
978
- version: z12.int(),
979
- change: z12.enum(["created", "edited", "retired", "restored", "undone"]),
980
- state: z12.enum(["active", "retired"]),
1254
+ var historyVersionSchema = z19.object({
1255
+ version: z19.int(),
1256
+ change: z19.enum(["created", "edited", "retired", "restored", "undone"]),
1257
+ state: z19.enum(["active", "retired"]),
981
1258
  origin: memoryOriginSchema,
982
1259
  source: contentSourceSchema,
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(),
1260
+ recordedAt: z19.date(),
1261
+ status: z19.enum(["readable", "shredded", "unreadable"]),
1262
+ text: z19.string().nullable()
1263
+ });
1264
+ var itemHistorySchema = z19.object({
1265
+ itemID: z19.string(),
1266
+ subject: z19.enum(["owner", "self", "shared"]),
1267
+ kind: z19.enum(["fact", "self"]),
1268
+ state: z19.enum(["active", "retired", "forgetting", "forgotten"]),
1269
+ versions: z19.array(historyVersionSchema)
1270
+ });
1271
+ var changeInputSchema = z19.object({
1272
+ itemID: z19.string(),
1273
+ version: z19.int(),
1274
+ text: z19.string().nullable(),
1275
+ isCurrent: z19.boolean()
1276
+ });
1277
+ var changeCommentSchema = z19.object({ text: z19.string(), at: z19.date() });
1278
+ var consolidationChangeSchema = z19.object({
1279
+ changeID: z19.string(),
1280
+ shortID: z19.string(),
1281
+ kind: z19.enum(["merge", "rewrite", "retire"]),
1282
+ inputs: z19.array(changeInputSchema),
1283
+ text: z19.string().nullable(),
1284
+ reason: z19.string(),
1008
1285
  source: contentSourceSchema,
1009
- actionHash: z12.string(),
1010
- lapseAt: z12.date(),
1286
+ actionHash: z19.string(),
1287
+ lapseAt: z19.date(),
1011
1288
  comment: changeCommentSchema.nullable()
1012
1289
  });
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)
1290
+ var consolidationDiffSchema = z19.object({
1291
+ diffID: z19.string(),
1292
+ model: z19.string().nullable(),
1293
+ createdAt: z19.date(),
1294
+ changes: z19.array(consolidationChangeSchema),
1295
+ summary: z19.string().nullable()
1296
+ });
1297
+ var changeOutcomeSchema = z19.discriminatedUnion("status", [
1298
+ z19.object({
1299
+ changeID: z19.string(),
1300
+ status: z19.literal("applied"),
1301
+ versions: z19.array(versionRefSchema2)
1025
1302
  }),
1026
- z12.object({ changeID: z12.string(), status: z12.literal("refused"), code: z12.string() })
1303
+ z19.object({ changeID: z19.string(), status: z19.literal("refused"), code: z19.string() })
1027
1304
  ]);
1028
- var changeAnswerSchema = z12.strictObject({
1029
- changeID: z12.string().min(1),
1030
- actionHash: z12.string().min(1)
1031
- });
1032
- var proposalAnswerSchema2 = z12.strictObject({
1033
- proposalID: z12.string().min(1),
1034
- actionHash: z12.string().min(1)
1035
- });
1036
- var hostSessionSchema = z12.object({
1037
- sessionID: z12.string(),
1038
- deviceName: z12.string(),
1039
- createdAt: z12.date(),
1040
- lastUsedAt: z12.date()
1041
- });
1042
- var subjectCountSchema = z12.object({
1043
- owner: z12.int().nonnegative(),
1044
- shared: z12.int().nonnegative(),
1045
- self: z12.int().nonnegative()
1046
- });
1047
- var memory = oc3.errors({
1305
+ var changeAnswerSchema = z19.strictObject({
1306
+ changeID: z19.string().min(1),
1307
+ actionHash: z19.string().min(1)
1308
+ });
1309
+ var proposalAnswerSchema = z19.strictObject({
1310
+ proposalID: z19.string().min(1),
1311
+ actionHash: z19.string().min(1)
1312
+ });
1313
+ var hostSessionSchema = z19.object({
1314
+ sessionID: z19.string(),
1315
+ deviceName: z19.string(),
1316
+ createdAt: z19.date(),
1317
+ lastUsedAt: z19.date()
1318
+ });
1319
+ var subjectCountSchema = z19.object({
1320
+ owner: z19.int().nonnegative(),
1321
+ shared: z19.int().nonnegative(),
1322
+ self: z19.int().nonnegative()
1323
+ });
1324
+ var memory = oc4.errors({
1048
1325
  MEMORY_NOT_STARTED: { message: "the memory store has not started yet", status: 503 },
1049
1326
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
1050
1327
  PROPOSAL_HASH: { message: "the action hash names another proposal", status: 409 },
@@ -1057,30 +1334,30 @@ var memory = oc3.errors({
1057
1334
  PIN_EDIT: { message: "a pin takes no edited text", status: 400 },
1058
1335
  SELF_NOTE_REFUSED: { message: "a self-note never takes that change", status: 409 }
1059
1336
  });
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)
1337
+ var skillFileSchema = z19.object({ path: z19.string(), text: z19.string() });
1338
+ var pendingSkillProposalSchema = z19.object({
1339
+ proposalID: z19.string(),
1340
+ name: z19.string(),
1341
+ skillHash: z19.string(),
1342
+ baseHash: z19.string().nullable(),
1343
+ files: z19.array(skillFileSchema),
1344
+ inForce: z19.object({
1345
+ skillHash: z19.string(),
1346
+ origin: z19.enum(["definitions", "vendored", "nixie"]),
1347
+ files: z19.array(skillFileSchema)
1071
1348
  }).nullable(),
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()
1078
- });
1079
- var skillAnswerSchema = z12.strictObject({
1080
- proposalID: z12.string().min(1),
1081
- skillHash: z12.string().min(1)
1082
- });
1083
- var skills = oc3.errors({
1349
+ untypedToken: z19.object({ kind: z19.string(), raw: z19.string() }).nullable(),
1350
+ thread: z19.string().nullable(),
1351
+ provenance: z19.object({ runID: z19.string(), callID: z19.string(), profile: z19.string() }),
1352
+ createdAt: z19.date(),
1353
+ lapseAt: z19.date(),
1354
+ isStale: z19.boolean()
1355
+ });
1356
+ var skillAnswerSchema = z19.strictObject({
1357
+ proposalID: z19.string().min(1),
1358
+ skillHash: z19.string().min(1)
1359
+ });
1360
+ var skills = oc4.errors({
1084
1361
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
1085
1362
  PROPOSAL_HASH: { message: "the skill hash names other files", status: 409 },
1086
1363
  PROPOSAL_CLOSED: { message: "the proposal is answered or lapsed", status: 409 },
@@ -1088,91 +1365,103 @@ var skills = oc3.errors({
1088
1365
  SKILL_CHECK: { message: "the files fail the seed checks", status: 400 },
1089
1366
  WRONG_STATE: { message: "the skill nixie wrote is no longer in force", status: 409 }
1090
1367
  });
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(),
1368
+ var definitionsSkillSchema = z19.object({ skillHash: z19.string(), origin: z19.enum(["definitions", "vendored"]) }).nullable();
1369
+ var writtenSkillSchema = z19.object({
1370
+ approvalID: z19.string(),
1371
+ proposalID: z19.string(),
1372
+ name: z19.string(),
1373
+ skillHash: z19.string(),
1097
1374
  base: definitionsSkillSchema,
1098
1375
  definitions: definitionsSkillSchema,
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(),
1376
+ isConflict: z19.boolean(),
1377
+ pullRequestURL: z19.url().nullable(),
1378
+ approvedAt: z19.date()
1379
+ });
1380
+ var promptPartFileSchema = z19.object({ path: z19.string(), text: z19.string() });
1381
+ var promptEntrySchema = z19.record(z19.string(), z19.string());
1382
+ var pendingPromptProposalSchema = z19.object({
1383
+ proposalID: z19.string(),
1384
+ promptID: z19.string(),
1385
+ proposalHash: z19.string(),
1386
+ baseHash: z19.string().nullable(),
1110
1387
  entry: promptEntrySchema,
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)
1123
- });
1124
- var prompts = oc3.errors({
1388
+ files: z19.array(promptPartFileSchema),
1389
+ reason: z19.string(),
1390
+ inForce: z19.object({ parts: promptEntrySchema, template: z19.string().nullable() }).nullable(),
1391
+ thread: z19.string().nullable(),
1392
+ provenance: z19.object({ runID: z19.string(), callID: z19.string(), profile: z19.string() }),
1393
+ createdAt: z19.date(),
1394
+ lapseAt: z19.date(),
1395
+ isStale: z19.boolean()
1396
+ });
1397
+ var promptAnswerSchema = z19.strictObject({
1398
+ proposalID: z19.string().min(1),
1399
+ proposalHash: z19.string().min(1)
1400
+ });
1401
+ var prompts = oc4.errors({
1125
1402
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
1126
1403
  PROPOSAL_HASH: { message: "the proposal hash names another override", status: 409 },
1127
1404
  PROPOSAL_CLOSED: { message: "the proposal is answered or lapsed", status: 409 },
1128
1405
  STALE_BASE: { message: "the override in force moved past the proposal", status: 409 },
1129
1406
  PROMPT_CHECK: { message: "the override fails the definitions checks", status: 400 }
1130
1407
  });
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) });
1408
+ var ruleVersionSchema = z19.object({ ruleHash: z19.string(), sentence: z19.string() }).nullable();
1409
+ var ruleInForceSchema = z19.object({
1410
+ ruleID: z19.string(),
1411
+ revision: z19.int().positive(),
1412
+ ruleHash: z19.string(),
1413
+ sentence: z19.string(),
1414
+ origin: z19.enum(["definitions", "nixie"]),
1415
+ changeID: z19.string().nullable(),
1416
+ lastFiredAt: z19.date().nullable()
1417
+ });
1418
+ var ruleConflictSchema = z19.object({
1419
+ ruleID: z19.string(),
1420
+ changeID: z19.string(),
1421
+ nixie: ruleVersionSchema,
1422
+ repo: ruleVersionSchema,
1423
+ base: ruleVersionSchema,
1424
+ changedBy: z19.enum(["owner", "nixie"]),
1425
+ reason: z19.string(),
1426
+ changedAt: z19.date()
1427
+ });
1428
+ var ruleProposalChangeSchema = z19.object({
1429
+ ruleID: z19.string(),
1430
+ before: ruleVersionSchema,
1431
+ after: ruleVersionSchema
1432
+ });
1433
+ var effectChangeSchema = z19.object({
1434
+ tool: z19.string(),
1435
+ remove: z19.array(z19.string()),
1436
+ sentence: z19.string()
1437
+ });
1438
+ var pendingRuleProposalSchema = z19.object({
1439
+ proposalID: z19.string(),
1440
+ changes: z19.array(ruleProposalChangeSchema),
1441
+ effectChanges: z19.array(effectChangeSchema),
1442
+ createdAt: z19.date(),
1443
+ lapseAt: z19.date()
1444
+ });
1445
+ var ruleProposalAnswerSchema = z19.strictObject({ proposalID: z19.string().min(1) });
1163
1446
  var ruleProposalRejectionSchema = ruleProposalAnswerSchema.extend({
1164
- reason: z12.string().max(500).regex(/\S/u)
1447
+ reason: z19.string().max(500).regex(/\S/u)
1448
+ });
1449
+ var actionRejectionSchema = ruleProposalAnswerSchema.extend({
1450
+ reason: z19.string().max(500).regex(/\S/u).optional()
1165
1451
  });
1166
1452
  var ruleProposalErrors = {
1167
1453
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
1168
1454
  PROPOSAL_CLOSED: { message: "the proposal is answered, withdrawn or lapsed", status: 409 }
1169
1455
  };
1170
- var rules = oc3.errors(ruleProposalErrors);
1171
- var forgottenItemsSchema = z12.object({
1172
- itemIDs: z12.array(z12.string()),
1456
+ var rules = oc4.errors(ruleProposalErrors);
1457
+ var contacts = oc4.errors({
1458
+ NOT_FOUND: { message: "no known contact has that ID", status: 404 }
1459
+ });
1460
+ var forgottenItemsSchema = z19.object({
1461
+ itemIDs: z19.array(z19.string()),
1173
1462
  backup: forgetBackupSchema
1174
1463
  });
1175
- var hostTaskStateSchema = z12.enum([
1464
+ var hostTaskStateSchema = z19.enum([
1176
1465
  "ready",
1177
1466
  "running",
1178
1467
  "waiting",
@@ -1182,29 +1471,36 @@ var hostTaskStateSchema = z12.enum([
1182
1471
  "failed",
1183
1472
  "closed"
1184
1473
  ]);
1185
- var taskControl2 = oc3.errors({
1474
+ var taskControl2 = oc4.errors({
1186
1475
  TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
1187
1476
  TASK_STATE_REFUSED: {
1188
1477
  message: "the task is in a state that does not take this control",
1189
1478
  status: 409
1190
1479
  }
1191
- }).input(z12.strictObject({ taskID: z12.string().min(1) })).output(z12.object({
1192
- taskID: z12.string(),
1480
+ }).input(z19.strictObject({ taskID: z19.string().min(1) })).output(z19.object({
1481
+ taskID: z19.string(),
1193
1482
  state: hostTaskStateSchema,
1194
- isPauseRequested: z12.boolean()
1483
+ isPauseRequested: z19.boolean()
1195
1484
  }));
1196
1485
  var hostContract = {
1197
- reset: oc3.output(z12.object({
1198
- resetAt: z12.date(),
1199
- lastSequence: z12.int().nonnegative(),
1200
- keptSessions: z12.int().nonnegative()
1486
+ reset: oc4.output(z19.object({
1487
+ resetAt: z19.date(),
1488
+ lastSequence: z19.int().nonnegative(),
1489
+ keptSessions: z19.int().nonnegative()
1201
1490
  })),
1202
- resetConversations: oc3.output(z12.object({
1203
- resetAt: z12.date(),
1204
- lastSequence: z12.int().nonnegative(),
1205
- shreddedRecords: z12.int().nonnegative(),
1491
+ resetConversations: oc4.output(z19.object({
1492
+ resetAt: z19.date(),
1493
+ lastSequence: z19.int().nonnegative(),
1494
+ shreddedRecords: z19.int().nonnegative(),
1206
1495
  backup: forgetBackupSchema
1207
1496
  })),
1497
+ nixie: {
1498
+ pause: oc4.output(z19.object({ paused: pauseStateSchema })),
1499
+ resume: oc4.output(z19.object({ paused: pauseStateSchema }))
1500
+ },
1501
+ recovery: {
1502
+ read: oc4.output(z19.object({ recovery: recoverySchema }))
1503
+ },
1208
1504
  tasks: {
1209
1505
  pause: taskControl2,
1210
1506
  resume: taskControl2,
@@ -1214,97 +1510,113 @@ var hostContract = {
1214
1510
  CONVERSATION_NEVER_CLOSES: { message: "the conversation is never closed", status: 409 }
1215
1511
  }),
1216
1512
  interrupt: taskControl2,
1217
- raise: oc3.errors({
1513
+ raise: oc4.errors({
1218
1514
  TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
1219
1515
  TASK_NOT_AT_LIMIT: { message: "the task is not paused at its limit", status: 409 },
1220
1516
  LIMIT_NOT_RAISED: { message: "the new limits are not above the old ones", status: 409 }
1221
- }).input(z12.strictObject({
1222
- taskID: z12.string().min(1),
1223
- turns: z12.int().positive().optional(),
1224
- dollars: z12.number().positive().optional()
1517
+ }).input(z19.strictObject({
1518
+ taskID: z19.string().min(1),
1519
+ turns: z19.int().positive().optional(),
1520
+ dollars: z19.number().positive().optional()
1225
1521
  }).refine((input) => input.turns !== undefined || input.dollars !== undefined, {
1226
1522
  message: "a raise sets turns, dollars or both"
1227
- })).output(z12.object({
1228
- taskID: z12.string(),
1523
+ })).output(z19.object({
1524
+ taskID: z19.string(),
1229
1525
  state: hostTaskStateSchema,
1230
- isPauseRequested: z12.boolean(),
1231
- turns: z12.int().positive(),
1232
- dollars: z12.number().positive()
1526
+ isPauseRequested: z19.boolean(),
1527
+ turns: z19.int().positive(),
1528
+ dollars: z19.number().positive()
1233
1529
  }))
1234
1530
  },
1235
1531
  sessions: {
1236
- issueCode: oc3.output(z12.object({ code: z12.string(), expiresAt: z12.date() })),
1237
- list: oc3.output(z12.array(hostSessionSchema)),
1238
- label: oc3.errors({
1532
+ issueCode: oc4.output(z19.object({ code: z19.string(), expiresAt: z19.date() })),
1533
+ list: oc4.output(z19.array(hostSessionSchema)),
1534
+ label: oc4.errors({
1239
1535
  SESSION_NOT_FOUND: {
1240
1536
  message: "no device session that is still signed in has that ID",
1241
1537
  status: 404
1242
1538
  },
1243
1539
  LABEL_INVALID: { message: "a label holds 1 to 100 characters besides spaces", status: 400 }
1244
- }).input(z12.strictObject({ sessionID: z12.string().min(1), label: z12.string() })).output(z12.object({ sessionID: z12.string(), label: z12.string() }))
1540
+ }).input(z19.strictObject({ sessionID: z19.string().min(1), label: z19.string() })).output(z19.object({ sessionID: z19.string(), label: z19.string() }))
1245
1541
  },
1246
1542
  memory: {
1247
1543
  proposals: {
1248
- list: memory.output(z12.array(pendingProposalSchema)),
1249
- approve: memory.input(proposalAnswerSchema2.extend({
1544
+ list: memory.output(z19.array(pendingProposalSchema)),
1545
+ approve: memory.input(proposalAnswerSchema.extend({
1250
1546
  revisionOf: versionTargetSchema2.optional(),
1251
- ignoreCloseMatch: z12.boolean().optional(),
1252
- editedText: itemTextSchema2.optional()
1547
+ ignoreCloseMatch: z19.boolean().optional(),
1548
+ editedText: itemTextSchema.optional()
1253
1549
  })).output(approvalResultSchema),
1254
- reject: memory.input(proposalAnswerSchema2.extend({ reason: z12.string().max(500).regex(/\S/u).optional() })).output(z12.object({ proposalID: z12.string() }))
1550
+ reject: memory.input(proposalAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u).optional() })).output(z19.object({ proposalID: z19.string() }))
1255
1551
  },
1256
- subjects: memory.output(z12.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
1552
+ subjects: memory.output(z19.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
1257
1553
  items: {
1258
- read: memory.input(z12.strictObject({ itemID: z12.string().min(1) })).output(itemHistorySchema),
1259
- edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema2 })).output(versionRefSchema2),
1554
+ read: memory.input(z19.strictObject({ itemID: z19.string().min(1) })).output(itemHistorySchema),
1555
+ edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema })).output(versionRefSchema2),
1260
1556
  retire: memory.input(versionTargetSchema2).output(versionRefSchema2),
1261
1557
  restore: memory.input(versionTargetSchema2).output(versionRefSchema2),
1262
- forget: memory.input(versionTargetSchema2).output(z12.object({ itemID: z12.string(), backup: forgetBackupSchema })),
1558
+ forget: memory.input(versionTargetSchema2).output(z19.object({ itemID: z19.string(), backup: forgetBackupSchema })),
1263
1559
  forgetAll: memory.output(forgottenItemsSchema),
1264
- pin: memory.input(z12.strictObject({ itemID: z12.string().min(1), isPinned: z12.boolean() })).output(z12.object({ itemID: z12.string(), isPinned: z12.boolean() }))
1560
+ pin: memory.input(z19.strictObject({ itemID: z19.string().min(1), isPinned: z19.boolean() })).output(z19.object({ itemID: z19.string(), isPinned: z19.boolean() }))
1265
1561
  },
1266
1562
  consolidation: {
1267
1563
  read: memory.output(consolidationDiffSchema.nullable()),
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() }))
1564
+ approve: memory.input(z19.strictObject({ answers: z19.array(changeAnswerSchema).min(1).max(30) })).output(z19.object({ outcomes: z19.array(changeOutcomeSchema) })),
1565
+ reject: memory.input(changeAnswerSchema).output(z19.object({ changeID: z19.string() }))
1270
1566
  }
1271
1567
  },
1272
1568
  skills: {
1273
1569
  proposals: {
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() }))
1570
+ list: skills.output(z19.array(pendingSkillProposalSchema)),
1571
+ approve: skills.input(skillAnswerSchema.extend({ files: z19.array(skillFileSchema).min(1).optional() })).output(z19.object({ proposalID: z19.string(), approvalID: z19.string(), skillHash: z19.string() })),
1572
+ reject: skills.input(skillAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u) })).output(z19.object({ proposalID: z19.string() }))
1277
1573
  },
1278
1574
  written: {
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"]) }))
1575
+ list: skills.output(z19.array(writtenSkillSchema)),
1576
+ resolve: skills.input(z19.strictObject({
1577
+ approvalID: z19.string().min(1),
1578
+ keep: z19.enum(["nixie", "definitions"])
1579
+ })).output(z19.object({ approvalID: z19.string(), keep: z19.enum(["nixie", "definitions"]) }))
1284
1580
  }
1285
1581
  },
1286
1582
  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"]) })),
1583
+ list: rules.output(z19.array(ruleInForceSchema)),
1584
+ conflicts: rules.output(z19.array(ruleConflictSchema)),
1585
+ resolve: rules.input(z19.strictObject({ ruleID: z19.string().min(1), keep: z19.enum(["nixie", "repo"]) })).output(z19.object({ ruleID: z19.string(), changeID: z19.string(), keep: z19.enum(["nixie", "repo"]) })),
1290
1586
  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() }))
1587
+ list: rules.output(z19.array(pendingRuleProposalSchema)),
1588
+ approve: rules.input(ruleProposalAnswerSchema).output(z19.object({ proposalID: z19.string() })),
1589
+ reject: rules.input(ruleProposalRejectionSchema).output(z19.object({ proposalID: z19.string() }))
1294
1590
  }
1295
1591
  },
1592
+ actions: {
1593
+ proposals: {
1594
+ list: rules.output(z19.array(actionProposalSchema)),
1595
+ approve: rules.input(ruleProposalAnswerSchema).output(z19.object({ proposalID: z19.string() })),
1596
+ reject: rules.input(actionRejectionSchema).output(z19.object({ proposalID: z19.string() }))
1597
+ }
1598
+ },
1599
+ contacts: {
1600
+ list: contacts.output(z19.array(knownContactSchema)),
1601
+ markKnown: contacts.input(z19.strictObject({
1602
+ destination: z19.string().min(1).max(500),
1603
+ name: z19.string().min(1).max(200).optional()
1604
+ })).output(z19.object({ contact: knownContactSchema, isNew: z19.boolean() })),
1605
+ unmark: contacts.input(z19.strictObject({ contactID: z19.string().min(1) })).output(z19.object({ contactID: z19.string() }))
1606
+ },
1607
+ turnInputs: turnInputsContract,
1296
1608
  prompts: {
1297
1609
  proposals: {
1298
- list: prompts.output(z12.array(pendingPromptProposalSchema)),
1610
+ list: prompts.output(z19.array(pendingPromptProposalSchema)),
1299
1611
  approve: prompts.input(promptAnswerSchema.extend({
1300
1612
  entry: promptEntrySchema.optional(),
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() }))
1613
+ files: z19.array(promptPartFileSchema).optional()
1614
+ })).output(z19.object({ proposalID: z19.string(), approvalID: z19.string(), proposalHash: z19.string() })),
1615
+ reject: prompts.input(promptAnswerSchema.extend({ reason: z19.string().max(500).regex(/\S/u) })).output(z19.object({ proposalID: z19.string() }))
1304
1616
  }
1305
1617
  }
1306
1618
  };
1307
- // src/is-time-zone.ts
1619
+ // src/contract/is-time-zone.ts
1308
1620
  function isTimeZone(zone) {
1309
1621
  try {
1310
1622
  return new Intl.DateTimeFormat("en-US", { timeZone: zone }).resolvedOptions().timeZone !== "";
@@ -1312,21 +1624,21 @@ function isTimeZone(zone) {
1312
1624
  return false;
1313
1625
  }
1314
1626
  }
1315
- // src/session-cookie-name.ts
1627
+ // src/contract/session-cookie-name.ts
1316
1628
  var sessionCookieName = "nixie_session";
1317
1629
 
1318
- // src/render-session-cookie.ts
1630
+ // src/contract/render-session-cookie.ts
1319
1631
  var MAX_AGE_S = 400 * 24 * 60 * 60;
1320
1632
  function renderSessionCookie(token) {
1321
1633
  const maxAgeS = token === null ? 0 : MAX_AGE_S;
1322
1634
  return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
1323
1635
  }
1324
- // src/task-message-input-schema.ts
1325
- import { z as z14 } from "zod";
1636
+ // src/message/task-message-input-schema.ts
1637
+ import { z as z21 } from "zod";
1326
1638
 
1327
- // src/task-message-kind-schema.ts
1328
- import { z as z13 } from "zod";
1329
- var taskMessageKindSchema = z13.enum([
1639
+ // src/message/task-message-kind-schema.ts
1640
+ import { z as z20 } from "zod";
1641
+ var taskMessageKindSchema = z20.enum([
1330
1642
  "progress",
1331
1643
  "question",
1332
1644
  "request",
@@ -1335,22 +1647,22 @@ var taskMessageKindSchema = z13.enum([
1335
1647
  "chat"
1336
1648
  ]);
1337
1649
 
1338
- // src/task-message-input-schema.ts
1339
- var taskMessageInputSchema = z14.object({
1340
- to: z14.string(),
1650
+ // src/message/task-message-input-schema.ts
1651
+ var taskMessageInputSchema = z21.object({
1652
+ to: z21.string(),
1341
1653
  kind: taskMessageKindSchema,
1342
- body: z14.string(),
1343
- replyTo: z14.string().optional(),
1344
- onBehalfOf: z14.string().array().optional(),
1345
- wake: z14.boolean().optional()
1346
- });
1347
- // src/task-message-result-schema.ts
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()
1654
+ body: z21.string(),
1655
+ replyTo: z21.string().optional(),
1656
+ onBehalfOf: z21.string().array().optional(),
1657
+ wake: z21.boolean().optional()
1658
+ });
1659
+ // src/message/task-message-result-schema.ts
1660
+ import { z as z22 } from "zod";
1661
+ var taskMessageResultSchema = z22.object({
1662
+ messageID: z22.string(),
1663
+ woke: z22.boolean(),
1664
+ hop: z22.int().nonnegative(),
1665
+ note: z22.string().optional()
1354
1666
  });
1355
1667
  export {
1356
1668
  buildPendingInput,
@@ -1358,11 +1670,11 @@ export {
1358
1670
  buildSpanState,
1359
1671
  clientHeaderName,
1360
1672
  contract,
1673
+ forgettableKinds,
1361
1674
  hostContract,
1362
1675
  imageLimits,
1363
1676
  isTimeZone,
1364
1677
  pickSpanSource,
1365
- proposalOutcomeSchema,
1366
1678
  renderSessionCookie,
1367
1679
  sessionCookieName,
1368
1680
  spanSchema,