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