@heynixie/contract 0.75.0 → 0.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -176,11 +176,13 @@ var forgettableKinds = [
176
176
  "task.step_errored",
177
177
  "task_message",
178
178
  "tool_called",
179
- "tool_result"
179
+ "tool_result",
180
+ "worker.run_ended",
181
+ "worker.turn_ended"
180
182
  ];
181
183
  // src/contract/contract.ts
182
184
  import { eventIterator as eventIterator2, oc as oc2 } from "@orpc/contract";
183
- import { z as z26 } from "zod";
185
+ import { z as z37 } from "zod";
184
186
 
185
187
  // src/span/span-schema.ts
186
188
  import { z } from "zod";
@@ -404,8 +406,8 @@ var memoryItemSchema = z8.object({
404
406
  changedAt: z8.date(),
405
407
  createdAt: z8.date(),
406
408
  forgottenAt: z8.date().nullable(),
409
+ isBridge: z8.boolean(),
407
410
  isPinned: z8.boolean(),
408
- isSensitive: z8.boolean(),
409
411
  itemID: z8.string(),
410
412
  kind: kindSchema,
411
413
  origin: originSchema,
@@ -443,6 +445,8 @@ var memoryVersionSchema = z8.object({
443
445
  evidence: evidenceSchema.nullable(),
444
446
  evidenceQuote: z8.string().nullable(),
445
447
  image: ownerImageSchema.nullable(),
448
+ isBridge: z8.boolean(),
449
+ isRemoved: z8.boolean(),
446
450
  origin: originSchema,
447
451
  proposalID: z8.string().nullable(),
448
452
  recordedAt: z8.date(),
@@ -469,7 +473,6 @@ var reviewReasonSchema = z8.enum([
469
473
  "other",
470
474
  "self_note",
471
475
  "from_photo",
472
- "sensitive",
473
476
  "subject_change",
474
477
  "labels",
475
478
  "ask_rule"
@@ -491,7 +494,6 @@ var memoryProposalSchema = z8.object({
491
494
  evidence: evidenceSchema.nullable(),
492
495
  image: ownerImageSchema.nullable(),
493
496
  isPinned: z8.boolean(),
494
- isSensitive: z8.boolean(),
495
497
  itemID: z8.string(),
496
498
  kind: kindSchema,
497
499
  labels: proposalLabelsSchema.nullable(),
@@ -577,7 +579,11 @@ var memoryViewContract = {
577
579
  restore: memoryChange.input(versionTargetSchema).output(versionResultSchema),
578
580
  listNotices: memoryView.input(z8.object({ thread: z8.string().min(1).max(200) })).output(z8.object({ notices: z8.array(memoryNoticeSchema) })),
579
581
  undo: memoryChange.errors({
580
- PINNED_CORE_FULL: { message: "The undo takes the pinned core past its budget", status: 409 }
582
+ PINNED_CORE_FULL: { message: "The undo takes the pinned core past its budget", status: 409 },
583
+ VERSION_REMOVED: {
584
+ message: "The earlier version was removed with a message it quoted",
585
+ status: 409
586
+ }
581
587
  }).input(versionTargetSchema).output(versionResultSchema),
582
588
  keep: memoryChange.input(versionTargetSchema).output(versionResultSchema),
583
589
  previewForget: memoryView.errors({
@@ -591,7 +597,6 @@ var memoryViewContract = {
591
597
  pin: memoryChange.errors({
592
598
  PINNED_CORE_FULL: { message: "The pin takes the pinned core past its budget", status: 409 }
593
599
  }).input(versionTargetSchema.extend({ isPinned: z8.boolean() })).output(z8.object({ isPinned: z8.boolean(), itemID: z8.string() })),
594
- markSensitive: memoryChange.input(z8.object({ clientActionID: z8.uuid(), isSensitive: z8.boolean(), itemID: itemIDSchema })).output(z8.object({ isSensitive: z8.boolean(), itemID: z8.string() })),
595
600
  ...memoryExportContract,
596
601
  ...momentContract
597
602
  };
@@ -805,6 +810,72 @@ var approvalContract = {
805
810
  answerProposals: signedIn.errors(reusedIDErrors).input(batchInputSchema).output(batchResultSchema)
806
811
  };
807
812
 
813
+ // src/contract/clipped-payload-schema.ts
814
+ import { z as z12 } from "zod";
815
+ var fieldSchema = z12.enum(["toolCall.input", "toolCall.content", "worker.text", "worker.detail"]);
816
+ var pathStepSchema = z12.union([z12.string(), z12.number()]);
817
+ var clippedPayloadSchema = z12.object({
818
+ field: fieldSchema,
819
+ path: z12.array(pathStepSchema),
820
+ bytes: z12.number()
821
+ });
822
+
823
+ // src/contract/definition-notice-schema.ts
824
+ import { z as z13 } from "zod";
825
+ var definitionNoticeSchema = z13.object({
826
+ definitionID: z13.string(),
827
+ name: z13.string().nullable(),
828
+ operation: z13.enum(["add", "change", "remove", "undo"]),
829
+ shortID: z13.string(),
830
+ changeID: z13.string(),
831
+ hasVersion: z13.boolean(),
832
+ rendered: z13.string().nullable(),
833
+ next: z13.string().nullable(),
834
+ state: z13.enum(["in_force", "superseded", "adopted", "retired"]),
835
+ isUnreadable: z13.boolean()
836
+ });
837
+
838
+ // src/contract/definitions-contract.ts
839
+ import { z as z14 } from "zod";
840
+ var operationSchema = z14.enum(["add", "change", "remove", "undo"]);
841
+ var headSchema = z14.object({
842
+ changeID: z14.string(),
843
+ shortID: z14.string(),
844
+ operation: operationSchema
845
+ });
846
+ var replacedSchema = z14.object({ head: headSchema });
847
+ var undo = signedIn.errors(reusedIDErrors).errors({
848
+ NOT_STARTED: { message: "Task definitions are not ready yet", status: 503 },
849
+ NOT_FOUND: { message: "No change has this ID", status: 404 },
850
+ REPLACED: {
851
+ message: "A later change replaced this one",
852
+ status: 409,
853
+ data: replacedSchema
854
+ },
855
+ REPO_MOVED: {
856
+ message: "The definitions repo changed this definition since",
857
+ status: 409,
858
+ data: z14.object({ seedSequence: z14.int().nonnegative() })
859
+ },
860
+ NOT_IN_FORCE: {
861
+ message: "The change is no longer in force",
862
+ status: 409,
863
+ data: z14.object({ cause: z14.enum(["one_shot_fired", "one_shot_skipped", "kept_repo"]) })
864
+ },
865
+ ONE_SHOT_OVER_REPO: {
866
+ message: "A one-time trigger cannot go back over a definition in the repo",
867
+ status: 409
868
+ },
869
+ ONE_SHOT_PAST: { message: "The time of that one-time trigger has passed", status: 409 }
870
+ });
871
+ var definitionsContract = {
872
+ undo: undo.input(z14.object({ clientActionID: z14.uuid(), changeID: z14.string().min(1).max(64) })).output(z14.object({
873
+ definitionID: z14.string(),
874
+ changeID: z14.string(),
875
+ restored: z14.literal("repo").optional()
876
+ }))
877
+ };
878
+
808
879
  // src/contract/image-limits.ts
809
880
  var imageLimits = {
810
881
  count: 4,
@@ -820,10 +891,10 @@ var imageNotFoundError = {
820
891
  };
821
892
 
822
893
  // src/contract/image-refused-error.ts
823
- import { z as z12 } from "zod";
824
- var imageRefusedDataSchema = z12.object({
825
- position: z12.int().nonnegative().nullable(),
826
- reason: z12.enum(["too_many", "too_large", "unsupported_type"])
894
+ import { z as z15 } from "zod";
895
+ var imageRefusedDataSchema = z15.object({
896
+ position: z15.int().nonnegative().nullable(),
897
+ reason: z15.enum(["too_many", "too_large", "unsupported_type"])
827
898
  });
828
899
  var imageRefusedError = {
829
900
  message: "An image is too large, of a type nixie does not take, or one too many",
@@ -831,108 +902,160 @@ var imageRefusedError = {
831
902
  data: imageRefusedDataSchema
832
903
  };
833
904
 
905
+ // src/contract/listed-task-schema.ts
906
+ import { z as z17 } from "zod";
907
+
908
+ // src/contract/thread-schema.ts
909
+ import { z as z16 } from "zod";
910
+ var threadSchema = z16.string().min(1).max(200);
911
+
912
+ // src/contract/listed-task-schema.ts
913
+ var taskStateSchema = z17.enum([
914
+ "ready",
915
+ "running",
916
+ "waiting",
917
+ "paused",
918
+ "stopped",
919
+ "done",
920
+ "failed",
921
+ "closed"
922
+ ]);
923
+ var listedStateSchema = z17.enum([...taskStateSchema.options, "idle", "finished", "asleep"]);
924
+ var runFireSchema = z17.object({
925
+ scheduledFor: z17.string(),
926
+ firedAt: z17.string(),
927
+ isCatchUp: z17.boolean()
928
+ });
929
+ var taskControlSchema = z17.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
930
+ var actionCountSchema = z17.int().nonnegative();
931
+ var listedTaskSchema = z17.object({
932
+ actions: z17.object({
933
+ cancelled: actionCountSchema,
934
+ queued: actionCountSchema,
935
+ started: actionCountSchema
936
+ }),
937
+ brief: z17.string(),
938
+ closedBy: z17.enum(["owner", "nixie", "disposable"]).optional(),
939
+ controls: z17.array(taskControlSchema),
940
+ definitionID: z17.string().optional(),
941
+ disposable: z17.boolean().nullable(),
942
+ fire: runFireSchema.nullable().optional(),
943
+ isPauseRequested: z17.boolean(),
944
+ isPausedByNixie: z17.boolean(),
945
+ isTakingMessages: z17.boolean(),
946
+ lastActivityAt: z17.date(),
947
+ listedState: listedStateSchema.optional(),
948
+ name: z17.string(),
949
+ nextRunAt: z17.string().optional(),
950
+ runner: z17.string(),
951
+ state: taskStateSchema,
952
+ taskID: threadSchema,
953
+ wakeable: z17.boolean().optional(),
954
+ waitingOn: threadSchema.optional()
955
+ });
956
+
834
957
  // src/contract/passkey-contract.ts
835
- import { z as z20 } from "zod";
958
+ import { z as z25 } from "zod";
836
959
 
837
960
  // src/contract/challenge-for-schema.ts
838
- import { z as z13 } from "zod";
839
- var challengeForSchema = z13.discriminatedUnion("kind", [
840
- z13.object({
841
- kind: z13.literal("answer"),
842
- proposalID: z13.string().min(1).max(200),
843
- actionHash: z13.string().min(1),
961
+ import { z as z18 } from "zod";
962
+ var challengeForSchema = z18.discriminatedUnion("kind", [
963
+ z18.object({
964
+ kind: z18.literal("answer"),
965
+ proposalID: z18.string().min(1).max(200),
966
+ actionHash: z18.string().min(1),
844
967
  choice: choiceSchema,
845
- ruleHash: z13.string().optional()
968
+ ruleHash: z18.string().optional()
846
969
  }),
847
- z13.object({
848
- kind: z13.literal("unknown_outcome"),
849
- actionID: z13.string().min(1).max(200),
850
- choice: z13.literal("retry")
970
+ z18.object({
971
+ kind: z18.literal("unknown_outcome"),
972
+ actionID: z18.string().min(1).max(200),
973
+ choice: z18.literal("retry")
851
974
  }),
852
- z13.object({ kind: z13.literal("register") }),
853
- z13.object({ kind: z13.literal("revoke"), passkeyID: z13.string().min(1).max(200) })
975
+ z18.object({ kind: z18.literal("register") }),
976
+ z18.object({ kind: z18.literal("revoke"), passkeyID: z18.string().min(1).max(200) })
854
977
  ]);
855
978
 
856
979
  // src/contract/creation-options-schema.ts
857
- import { z as z17 } from "zod";
980
+ import { z as z22 } from "zod";
858
981
 
859
982
  // src/contract/credential-descriptor-schema.ts
860
- import { z as z15 } from "zod";
983
+ import { z as z20 } from "zod";
861
984
 
862
985
  // src/contract/transports-schema.ts
863
- import { z as z14 } from "zod";
864
- var transportSchema = z14.string().max(40);
865
- var transportsSchema = z14.array(transportSchema).max(10);
986
+ import { z as z19 } from "zod";
987
+ var transportSchema = z19.string().max(40);
988
+ var transportsSchema = z19.array(transportSchema).max(10);
866
989
 
867
990
  // src/contract/credential-descriptor-schema.ts
868
- var credentialDescriptorSchema = z15.object({
991
+ var credentialDescriptorSchema = z20.object({
869
992
  id: base64URLSchema,
870
- type: z15.literal("public-key"),
993
+ type: z20.literal("public-key"),
871
994
  transports: transportsSchema.optional()
872
995
  });
873
996
 
874
997
  // src/contract/user-verification-schema.ts
875
- import { z as z16 } from "zod";
876
- var userVerificationSchema = z16.enum(["required", "preferred", "discouraged"]);
998
+ import { z as z21 } from "zod";
999
+ var userVerificationSchema = z21.enum(["required", "preferred", "discouraged"]);
877
1000
 
878
1001
  // src/contract/creation-options-schema.ts
879
- var userSchema = z17.object({ id: base64URLSchema, name: z17.string(), displayName: z17.string() });
880
- var parameterSchema = z17.object({ type: z17.literal("public-key"), alg: z17.int() });
881
- var selectionSchema = z17.object({
1002
+ var userSchema = z22.object({ id: base64URLSchema, name: z22.string(), displayName: z22.string() });
1003
+ var parameterSchema = z22.object({ type: z22.literal("public-key"), alg: z22.int() });
1004
+ var selectionSchema = z22.object({
882
1005
  residentKey: userVerificationSchema,
883
- requireResidentKey: z17.boolean(),
1006
+ requireResidentKey: z22.boolean(),
884
1007
  userVerification: userVerificationSchema
885
1008
  });
886
- var creationOptionsSchema = z17.object({
887
- rp: z17.object({ id: z17.string(), name: z17.string() }),
1009
+ var creationOptionsSchema = z22.object({
1010
+ rp: z22.object({ id: z22.string(), name: z22.string() }),
888
1011
  user: userSchema,
889
1012
  challenge: base64URLSchema,
890
- pubKeyCredParams: z17.array(parameterSchema),
891
- timeout: z17.int().positive(),
892
- excludeCredentials: z17.array(credentialDescriptorSchema),
1013
+ pubKeyCredParams: z22.array(parameterSchema),
1014
+ timeout: z22.int().positive(),
1015
+ excludeCredentials: z22.array(credentialDescriptorSchema),
893
1016
  authenticatorSelection: selectionSchema,
894
- attestation: z17.enum(["none", "indirect", "direct", "enterprise"])
1017
+ attestation: z22.enum(["none", "indirect", "direct", "enterprise"])
895
1018
  });
896
1019
 
897
1020
  // src/contract/registration-response-schema.ts
898
- import { z as z18 } from "zod";
899
- var attestationSchema = z18.object({
1021
+ import { z as z23 } from "zod";
1022
+ var attestationSchema = z23.object({
900
1023
  clientDataJSON: base64URLSchema,
901
1024
  attestationObject: base64URLSchema,
902
1025
  authenticatorData: base64URLSchema.optional(),
903
1026
  transports: transportsSchema.optional(),
904
- publicKeyAlgorithm: z18.int().optional(),
1027
+ publicKeyAlgorithm: z23.int().optional(),
905
1028
  publicKey: base64URLSchema.optional()
906
1029
  });
907
- var registrationResponseSchema = z18.object({
1030
+ var registrationResponseSchema = z23.object({
908
1031
  id: base64URLSchema,
909
1032
  rawId: base64URLSchema,
910
1033
  response: attestationSchema,
911
- authenticatorAttachment: z18.enum(["cross-platform", "platform"]).optional(),
912
- clientExtensionResults: z18.object({}),
913
- type: z18.literal("public-key")
1034
+ authenticatorAttachment: z23.enum(["cross-platform", "platform"]).optional(),
1035
+ clientExtensionResults: z23.object({}),
1036
+ type: z23.literal("public-key")
914
1037
  });
915
1038
 
916
1039
  // src/contract/request-options-schema.ts
917
- import { z as z19 } from "zod";
918
- var requestOptionsSchema = z19.object({
1040
+ import { z as z24 } from "zod";
1041
+ var requestOptionsSchema = z24.object({
919
1042
  challenge: base64URLSchema,
920
- rpId: z19.string(),
921
- allowCredentials: z19.array(credentialDescriptorSchema),
1043
+ rpId: z24.string(),
1044
+ allowCredentials: z24.array(credentialDescriptorSchema),
922
1045
  userVerification: userVerificationSchema,
923
- timeout: z19.int().positive()
1046
+ timeout: z24.int().positive()
924
1047
  });
925
1048
 
926
1049
  // src/contract/passkey-contract.ts
927
- var clientActionIDSchema = z20.uuid();
928
- var listedPasskeySchema = z20.object({
929
- passkeyID: z20.string(),
930
- label: z20.string(),
931
- synced: z20.boolean(),
932
- authorizedBy: z20.string(),
933
- registeredAt: z20.date(),
934
- lastUsedAt: z20.date().nullable(),
935
- revokedAt: z20.date().nullable()
1050
+ var clientActionIDSchema = z25.uuid();
1051
+ var listedPasskeySchema = z25.object({
1052
+ passkeyID: z25.string(),
1053
+ label: z25.string(),
1054
+ synced: z25.boolean(),
1055
+ authorizedBy: z25.string(),
1056
+ registeredAt: z25.date(),
1057
+ lastUsedAt: z25.date().nullable(),
1058
+ revokedAt: z25.date().nullable()
936
1059
  });
937
1060
  var registrationErrors = {
938
1061
  ...passkeyFailedError,
@@ -944,43 +1067,71 @@ var registrationErrors = {
944
1067
  ORIGIN_CHANGED: { message: "Live passkeys hold another origin", status: 409 }
945
1068
  };
946
1069
  var passkeyContract = {
947
- challenge: signedIn.errors(noPasskeyError).input(z20.object({ for: challengeForSchema })).output(z20.object({ options: requestOptionsSchema })),
1070
+ challenge: signedIn.errors(noPasskeyError).input(z25.object({ for: challengeForSchema })).output(z25.object({ options: requestOptionsSchema })),
948
1071
  registrationOptions: signedIn.errors(registrationErrors).errors({
949
1072
  CODE_REQUIRED: { message: "A host code is required", status: 403 },
950
1073
  CODE_INVALID: { message: "The host code is unknown, used or lapsed", status: 403 }
951
- }).input(z20.object({
952
- code: z20.string().min(1).max(100).optional(),
1074
+ }).input(z25.object({
1075
+ code: z25.string().min(1).max(100).optional(),
953
1076
  passkey: authenticationResponseSchema.optional()
954
- })).output(z20.object({ options: creationOptionsSchema })),
1077
+ })).output(z25.object({ options: creationOptionsSchema })),
955
1078
  register: signedIn.errors(reusedIDErrors).errors({
956
1079
  REGISTRATION_FAILED: {
957
1080
  message: "The registration failed",
958
1081
  status: 400,
959
- data: z20.object({ reason: z20.string() })
1082
+ data: z25.object({ reason: z25.string() })
960
1083
  },
961
1084
  TOO_MANY_PASSKEYS: registrationErrors.TOO_MANY_PASSKEYS,
962
1085
  ORIGIN_UNSUPPORTED: registrationErrors.ORIGIN_UNSUPPORTED
963
- }).input(z20.object({
1086
+ }).input(z25.object({
964
1087
  clientActionID: clientActionIDSchema,
965
1088
  response: registrationResponseSchema,
966
- label: z20.string().min(1).max(64).optional()
967
- })).output(z20.object({ passkeyID: z20.string() })),
968
- list: signedIn.output(z20.object({ passkeys: z20.array(listedPasskeySchema) })),
969
- revoke: signedIn.errors(reusedIDErrors).errors(passkeyFailedError).errors({ NOT_FOUND: { message: "No passkey has this ID", status: 404 } }).input(z20.object({
1089
+ label: z25.string().min(1).max(64).optional()
1090
+ })).output(z25.object({ passkeyID: z25.string() })),
1091
+ list: signedIn.output(z25.object({ passkeys: z25.array(listedPasskeySchema) })),
1092
+ revoke: signedIn.errors(reusedIDErrors).errors(passkeyFailedError).errors({ NOT_FOUND: { message: "No passkey has this ID", status: 404 } }).input(z25.object({
970
1093
  clientActionID: clientActionIDSchema,
971
- passkeyID: z20.string().min(1).max(200),
1094
+ passkeyID: z25.string().min(1).max(200),
972
1095
  passkey: authenticationResponseSchema
973
- })).output(z20.object({ revokedAt: z20.date() }))
1096
+ })).output(z25.object({ revokedAt: z25.date() }))
974
1097
  };
975
1098
 
976
1099
  // src/contract/pause-state-schema.ts
977
- import { z as z21 } from "zod";
978
- var pauseCauseSchema = z21.enum(["restore", "owner", "spending"]);
979
- var pauseStateSchema = z21.object({ cause: pauseCauseSchema, since: z21.date() }).nullable();
1100
+ import { z as z26 } from "zod";
1101
+ var pauseCauseSchema = z26.enum(["restore", "owner", "spending"]);
1102
+ var pauseStateSchema = z26.object({ cause: pauseCauseSchema, since: z26.date() }).nullable();
1103
+
1104
+ // src/contract/read-payload-contract.ts
1105
+ import { z as z28 } from "zod";
1106
+
1107
+ // src/contract/sequence-schema.ts
1108
+ import { z as z27 } from "zod";
1109
+ var sequenceSchema = z27.int().nonnegative();
1110
+
1111
+ // src/contract/read-payload-contract.ts
1112
+ var jsonObjectSchema = z28.record(z28.string(), z28.unknown());
1113
+ var readableSchema = z28.object({
1114
+ status: z28.literal("readable"),
1115
+ toolCall: z28.object({ input: jsonObjectSchema.optional(), content: jsonObjectSchema.optional() }).optional(),
1116
+ worker: z28.object({ text: z28.string().optional(), detail: z28.string().optional() }).optional()
1117
+ });
1118
+ var forgottenSchema = z28.object({ status: z28.literal("forgotten") });
1119
+ var unreadableSchema = z28.object({ status: z28.literal("unreadable") });
1120
+ var payloadSchema = z28.discriminatedUnion("status", [
1121
+ readableSchema,
1122
+ forgottenSchema,
1123
+ unreadableSchema
1124
+ ]);
1125
+ var notFoundError = {
1126
+ message: "No record on this thread has this sequence",
1127
+ status: 404
1128
+ };
1129
+ var inputSchema = z28.object({ thread: threadSchema, sequence: sequenceSchema });
1130
+ var readPayloadContract = signedIn.errors({ RECORD_NOT_FOUND: notFoundError }).input(inputSchema).output(payloadSchema);
980
1131
 
981
1132
  // src/contract/recovery-schema.ts
982
- import { z as z22 } from "zod";
983
- var taskStateSchema = z22.enum([
1133
+ import { z as z29 } from "zod";
1134
+ var taskStateSchema2 = z29.enum([
984
1135
  "ready",
985
1136
  "running",
986
1137
  "waiting",
@@ -990,29 +1141,29 @@ var taskStateSchema = z22.enum([
990
1141
  "failed",
991
1142
  "closed"
992
1143
  ]);
993
- var taskToCheckSchema = z22.object({
994
- taskID: z22.string(),
995
- name: z22.string(),
996
- stateAtBackup: taskStateSchema,
997
- wasRunning: z22.boolean(),
998
- pendingActions: z22.int().nonnegative()
999
- });
1000
- var recoverySchema = z22.object({
1001
- restoredAt: z22.date(),
1002
- backupTakenAt: z22.date(),
1003
- toCheck: z22.array(taskToCheckSchema)
1144
+ var taskToCheckSchema = z29.object({
1145
+ taskID: z29.string(),
1146
+ name: z29.string(),
1147
+ stateAtBackup: taskStateSchema2,
1148
+ wasRunning: z29.boolean(),
1149
+ pendingActions: z29.int().nonnegative()
1150
+ });
1151
+ var recoverySchema = z29.object({
1152
+ restoredAt: z29.date(),
1153
+ backupTakenAt: z29.date(),
1154
+ toCheck: z29.array(taskToCheckSchema)
1004
1155
  }).nullable();
1005
1156
 
1006
1157
  // src/contract/rule-contract.ts
1007
- import { z as z23 } from "zod";
1008
- var ruleIDSchema = z23.string().min(1).max(200);
1009
- var revisionSchema = z23.int().positive();
1010
- var ruleSchema = z23.object({
1011
- ruleID: z23.string(),
1158
+ import { z as z30 } from "zod";
1159
+ var ruleIDSchema = z30.string().min(1).max(200);
1160
+ var revisionSchema = z30.int().positive();
1161
+ var ruleSchema = z30.object({
1162
+ ruleID: z30.string(),
1012
1163
  revision: revisionSchema,
1013
- sentence: z23.string(),
1014
- outcome: z23.enum(["allow", "ask", "deny"]),
1015
- destinations: z23.array(z23.string())
1164
+ sentence: z30.string(),
1165
+ outcome: z30.enum(["allow", "ask", "deny"]),
1166
+ destinations: z30.array(z30.string())
1016
1167
  });
1017
1168
  var notFound = { NOT_FOUND: { message: "No rule has this ID", status: 404 } };
1018
1169
  var ruleChange = signedIn.errors(reusedIDErrors).errors({
@@ -1020,29 +1171,29 @@ var ruleChange = signedIn.errors(reusedIDErrors).errors({
1020
1171
  CONFLICT: {
1021
1172
  message: "The rule changed since the notice showed it",
1022
1173
  status: 409,
1023
- data: z23.object({ revision: revisionSchema })
1174
+ data: z30.object({ revision: revisionSchema })
1024
1175
  },
1025
1176
  NOT_ALLOWED: {
1026
1177
  message: "The rule takes no such change",
1027
1178
  status: 403,
1028
- data: z23.object({ reason: z23.enum(["widens", "empty", "mandate"]) })
1179
+ data: z30.object({ reason: z30.enum(["widens", "empty", "mandate"]) })
1029
1180
  }
1030
1181
  });
1031
- var currentHashSchema = z23.object({ current: z23.object({ actionHash: z23.string() }) });
1032
- var closedStateSchema = z23.object({
1033
- state: z23.enum(["approved", "declined", "lapsed", "withdrawn"])
1034
- });
1035
- var proposalIDSchema = z23.string().min(1).max(64);
1036
- var ruleFormSchema = z23.record(z23.string(), z23.unknown());
1037
- var mandateRuleSchema = z23.object({ ruleID: z23.string(), sentence: z23.string() });
1038
- var mandateSchema = z23.object({
1039
- mandateID: z23.string(),
1040
- title: z23.string().nullable(),
1041
- rules: z23.array(mandateRuleSchema),
1042
- startedAt: z23.date(),
1043
- expires: z23.date()
1044
- });
1045
- var faultsSchema = z23.object({ faults: z23.array(z23.string()) });
1182
+ var currentHashSchema = z30.object({ current: z30.object({ actionHash: z30.string() }) });
1183
+ var closedStateSchema = z30.object({
1184
+ state: z30.enum(["approved", "declined", "lapsed", "withdrawn"])
1185
+ });
1186
+ var proposalIDSchema = z30.string().min(1).max(64);
1187
+ var ruleFormSchema = z30.record(z30.string(), z30.unknown());
1188
+ var mandateRuleSchema = z30.object({ ruleID: z30.string(), sentence: z30.string() });
1189
+ var mandateSchema = z30.object({
1190
+ mandateID: z30.string(),
1191
+ title: z30.string().nullable(),
1192
+ rules: z30.array(mandateRuleSchema),
1193
+ startedAt: z30.date(),
1194
+ expires: z30.date()
1195
+ });
1196
+ var faultsSchema = z30.object({ faults: z30.array(z30.string()) });
1046
1197
  var invalid = {
1047
1198
  INVALID: {
1048
1199
  message: "The rule or the mandate breaks the rule format or its limits",
@@ -1050,16 +1201,16 @@ var invalid = {
1050
1201
  data: faultsSchema
1051
1202
  }
1052
1203
  };
1053
- var destinationsSchema = z23.array(z23.string().regex(/^\S+$/u)).max(100);
1204
+ var destinationsSchema = z30.array(z30.string().regex(/^\S+$/u)).max(100);
1054
1205
  var ruleContract = {
1055
- readRule: signedIn.errors(notFound).input(z23.object({ ruleID: ruleIDSchema })).output(ruleSchema),
1056
- removeRule: ruleChange.input(z23.object({ ruleID: ruleIDSchema, revision: revisionSchema, clientActionID: z23.uuid() })).output(z23.object({ ruleID: z23.string() })),
1057
- editRule: ruleChange.input(z23.object({
1206
+ readRule: signedIn.errors(notFound).input(z30.object({ ruleID: ruleIDSchema })).output(ruleSchema),
1207
+ removeRule: ruleChange.input(z30.object({ ruleID: ruleIDSchema, revision: revisionSchema, clientActionID: z30.uuid() })).output(z30.object({ ruleID: z30.string() })),
1208
+ editRule: ruleChange.input(z30.object({
1058
1209
  ruleID: ruleIDSchema,
1059
1210
  revision: revisionSchema,
1060
1211
  destinations: destinationsSchema,
1061
- clientActionID: z23.uuid()
1062
- })).output(z23.object({ ruleID: z23.string(), revision: revisionSchema })),
1212
+ clientActionID: z30.uuid()
1213
+ })).output(z30.object({ ruleID: z30.string(), revision: revisionSchema })),
1063
1214
  editProposedRule: signedIn.errors(reusedIDErrors).errors({
1064
1215
  ...invalid,
1065
1216
  NOT_FOUND: { message: "No proposed rule has this ID", status: 404 },
@@ -1073,192 +1224,331 @@ var ruleContract = {
1073
1224
  status: 409,
1074
1225
  data: closedStateSchema
1075
1226
  }
1076
- }).input(z23.object({
1227
+ }).input(z30.object({
1077
1228
  proposalID: proposalIDSchema,
1078
- actionHash: z23.string(),
1229
+ actionHash: z30.string(),
1079
1230
  rule: ruleFormSchema,
1080
- clientActionID: z23.uuid()
1081
- })).output(z23.object({ proposalID: z23.string() })),
1082
- proposeMandate: signedIn.errors(reusedIDErrors).errors(invalid).input(z23.object({
1083
- title: z23.string(),
1084
- rules: z23.array(ruleFormSchema),
1085
- expires: z23.string().optional(),
1086
- clientActionID: z23.uuid()
1087
- })).output(z23.object({ proposalID: z23.string(), mandateID: z23.string(), expires: z23.date() })),
1088
- listMandates: signedIn.output(z23.object({ mandates: z23.array(mandateSchema) })),
1089
- endMandate: signedIn.errors(reusedIDErrors).errors({ NOT_FOUND: { message: "No mandate has this ID", status: 404 } }).input(z23.object({ mandateID: z23.string().min(1).max(64), clientActionID: z23.uuid() })).output(z23.object({ mandateID: z23.string(), state: z23.enum(["ended", "expired"]) }))
1231
+ clientActionID: z30.uuid()
1232
+ })).output(z30.object({ proposalID: z30.string() })),
1233
+ proposeMandate: signedIn.errors(reusedIDErrors).errors(invalid).input(z30.object({
1234
+ title: z30.string(),
1235
+ rules: z30.array(ruleFormSchema),
1236
+ expires: z30.string().optional(),
1237
+ clientActionID: z30.uuid()
1238
+ })).output(z30.object({ proposalID: z30.string(), mandateID: z30.string(), expires: z30.date() })),
1239
+ listMandates: signedIn.output(z30.object({ mandates: z30.array(mandateSchema) })),
1240
+ endMandate: signedIn.errors(reusedIDErrors).errors({ NOT_FOUND: { message: "No mandate has this ID", status: 404 } }).input(z30.object({ mandateID: z30.string().min(1).max(64), clientActionID: z30.uuid() })).output(z30.object({ mandateID: z30.string(), state: z30.enum(["ended", "expired"]) }))
1090
1241
  };
1091
1242
 
1092
1243
  // src/contract/task-schema.ts
1093
- import { z as z24 } from "zod";
1094
- var taskSchema2 = z24.object({
1095
- error: z24.string().optional(),
1096
- errorLimit: z24.int().positive().optional(),
1097
- errors: z24.int().positive().optional(),
1098
- isWaitingForRetry: z24.boolean().optional(),
1099
- readCursor: z24.int().nonnegative().optional(),
1100
- reason: z24.string().optional(),
1101
- retryAt: z24.date().optional(),
1102
- stepKey: z24.string().optional(),
1103
- taskID: z24.string()
1244
+ import { z as z31 } from "zod";
1245
+ var taskSchema2 = z31.object({
1246
+ error: z31.string().optional(),
1247
+ errorLimit: z31.int().positive().optional(),
1248
+ errors: z31.int().positive().optional(),
1249
+ isWaitingForRetry: z31.boolean().optional(),
1250
+ readCursor: z31.int().nonnegative().optional(),
1251
+ reason: z31.string().optional(),
1252
+ retryAt: z31.date().optional(),
1253
+ stepKey: z31.string().optional(),
1254
+ taskID: z31.string()
1104
1255
  });
1105
1256
 
1106
1257
  // src/contract/tool-call-schema.ts
1107
- import { z as z25 } from "zod";
1108
- var jsonObjectSchema = z25.record(z25.string(), z25.unknown());
1109
- var toolCallSchema = z25.object({
1110
- callID: z25.string(),
1111
- content: jsonObjectSchema.optional(),
1112
- input: jsonObjectSchema.optional(),
1113
- outcome: z25.string().optional(),
1114
- tool: z25.string().optional()
1258
+ import { z as z32 } from "zod";
1259
+ var jsonObjectSchema2 = z32.record(z32.string(), z32.unknown());
1260
+ var toolCallSchema = z32.object({
1261
+ callID: z32.string(),
1262
+ content: jsonObjectSchema2.optional(),
1263
+ input: jsonObjectSchema2.optional(),
1264
+ outcome: z32.string().optional(),
1265
+ runID: z32.string().optional(),
1266
+ tool: z32.string().optional()
1115
1267
  });
1116
1268
 
1117
- // src/contract/contract.ts
1118
- var clientActionIDSchema2 = z26.uuid();
1119
- var sequenceSchema = z26.int().nonnegative();
1120
- var threadSchema = z26.string().min(1).max(200);
1121
- var imageSchema = z26.object({ mediaType: z26.enum(imageLimits.mediaTypes) });
1122
- var imageFilesSchema = z26.array(z26.file());
1123
- var imageRefSchema = z26.object({
1124
- position: z26.int().nonnegative(),
1269
+ // src/contract/view-contract.ts
1270
+ import { z as z35 } from "zod";
1271
+
1272
+ // src/contract/trigger-schema.ts
1273
+ import { z as z34 } from "zod";
1274
+
1275
+ // src/contract/schedule-schema.ts
1276
+ import { z as z33 } from "zod";
1277
+
1278
+ // src/contract/is-time-zone.ts
1279
+ function isTimeZone(zone) {
1280
+ try {
1281
+ return new Intl.DateTimeFormat("en-US", { timeZone: zone }).resolvedOptions().timeZone !== "";
1282
+ } catch {
1283
+ return false;
1284
+ }
1285
+ }
1286
+
1287
+ // src/contract/schedule-schema.ts
1288
+ var clockTimeSchema = z33.string().regex(/^(?:[01]\d|2[0-3]):[0-5]\d$/u, "a time is HH:MM, 24-hour");
1289
+ var minutesSchema = z33.strictObject({
1290
+ minutes: z33.int().min(5).max(1440)
1291
+ });
1292
+ var weekdaySchema = z33.enum(["mon", "tue", "wed", "thu", "fri", "sat", "sun"]);
1293
+ var scheduleSchema = z33.strictObject({
1294
+ every: z33.union([z33.enum(["day", "week", "hour"]), minutesSchema]),
1295
+ at: clockTimeSchema.optional(),
1296
+ on: weekdaySchema.optional(),
1297
+ window: z33.strictObject({ from: clockTimeSchema, until: clockTimeSchema }).optional(),
1298
+ idleMinutes: z33.int().min(1).max(720).optional(),
1299
+ zone: z33.string().refine((zone) => zone === "owner" || isTimeZone(zone), "a zone is owner or an IANA zone").default("owner"),
1300
+ catchUp: z33.enum(["once", "skip"]).default("once")
1301
+ }).superRefine((schedule, context) => {
1302
+ const isCalendar = schedule.every === "day" || schedule.every === "week";
1303
+ if (isCalendar && schedule.at === undefined && schedule.window === undefined) {
1304
+ context.addIssue({ code: "custom", message: "day and week need at or window" });
1305
+ }
1306
+ if (isCalendar && schedule.at !== undefined && schedule.window !== undefined) {
1307
+ context.addIssue({ code: "custom", message: "at and window never come together" });
1308
+ }
1309
+ if (!isCalendar && schedule.at !== undefined) {
1310
+ context.addIssue({ code: "custom", message: "hour and minutes schedules take no at" });
1311
+ }
1312
+ if (!isCalendar && schedule.window !== undefined) {
1313
+ context.addIssue({ code: "custom", message: "hour and minutes schedules take no window" });
1314
+ }
1315
+ if (schedule.every === "week" && schedule.on === undefined) {
1316
+ context.addIssue({ code: "custom", message: "a week schedule needs on" });
1317
+ }
1318
+ if (schedule.every !== "week" && schedule.on !== undefined) {
1319
+ context.addIssue({ code: "custom", message: "only a week schedule takes on" });
1320
+ }
1321
+ if (schedule.idleMinutes !== undefined && schedule.window === undefined) {
1322
+ context.addIssue({ code: "custom", message: "idleMinutes needs window" });
1323
+ }
1324
+ });
1325
+
1326
+ // src/contract/trigger-schema.ts
1327
+ var triggerAtSchema = z34.iso.datetime({ offset: true });
1328
+ var triggerSchema = z34.union([
1329
+ z34.strictObject({ schedule: scheduleSchema }),
1330
+ z34.strictObject({ at: triggerAtSchema })
1331
+ ]);
1332
+
1333
+ // src/contract/view-contract.ts
1334
+ var skipReasonSchema = z35.enum([
1335
+ "too_late",
1336
+ "catch_up_off",
1337
+ "window_closed",
1338
+ "still_running",
1339
+ "task_held"
1340
+ ]);
1341
+ var endedRunSchema = z35.object({
1342
+ runID: z35.string(),
1343
+ taskID: threadSchema,
1344
+ definitionID: z35.string().nullable(),
1345
+ startedAt: z35.date(),
1346
+ endedAt: z35.date(),
1125
1347
  sequence: sequenceSchema,
1126
- thread: threadSchema
1348
+ cause: z35.string(),
1349
+ endedBy: z35.string(),
1350
+ carriesRunID: z35.string().nullable(),
1351
+ reportID: z35.string(),
1352
+ delivery: z35.enum(["wake", "next_turn", "kept"]),
1353
+ fire: runFireSchema.nullable(),
1354
+ used: z35.object({ turns: z35.number(), dollars: z35.number() })
1355
+ });
1356
+ var reportEntrySchema = z35.object({
1357
+ definitionID: z35.string(),
1358
+ name: z35.string(),
1359
+ kind: z35.enum(["late", "skipped"]),
1360
+ scheduledFor: z35.string(),
1361
+ firedAt: z35.string().nullable(),
1362
+ lateBySeconds: z35.number().nullable(),
1363
+ reason: skipReasonSchema.nullable(),
1364
+ sequence: sequenceSchema
1127
1365
  });
1128
- var versionRefSchema = z26.object({
1129
- itemID: z26.string().min(1).max(200),
1130
- version: z26.int().nonnegative()
1366
+ var listedDefinitionSchema = z35.object({
1367
+ definitionID: z35.string(),
1368
+ name: z35.string(),
1369
+ enabled: z35.boolean(),
1370
+ target: z35.enum(["task", "conversation"]),
1371
+ trigger: triggerSchema.nullable(),
1372
+ rendered: z35.string().nullable(),
1373
+ next: z35.string().nullable(),
1374
+ tools: z35.array(z35.string()),
1375
+ origin: z35.enum(["definitions", "nixie"]),
1376
+ createdBy: z35.object({
1377
+ sequence: sequenceSchema,
1378
+ kind: z35.enum(["definition.changed", "definitions_seeded"])
1379
+ }),
1380
+ taskID: threadSchema.nullable(),
1381
+ isUnreadable: z35.boolean()
1131
1382
  });
1132
- var recallItemSchema = versionRefSchema.extend({ score: z26.number().optional() });
1133
- var recallSchema = z26.object({ items: z26.array(recallItemSchema) });
1134
- var ratingItemSchema = versionRefSchema.extend({
1135
- hasNote: z26.boolean(),
1136
- verdict: z26.enum(["helpful", "noise", "misleading"])
1383
+ var viewContract = {
1384
+ tasks: {
1385
+ listEnded: signedIn.input(z35.object({
1386
+ limit: z35.int().min(1).max(100),
1387
+ before: sequenceSchema.optional(),
1388
+ definitionID: z35.string().min(1).max(200).optional()
1389
+ })).output(z35.object({
1390
+ tasks: z35.array(listedTaskSchema),
1391
+ runs: z35.array(endedRunSchema),
1392
+ next: sequenceSchema.nullable()
1393
+ }))
1394
+ },
1395
+ triggers: {
1396
+ report: signedIn.input(z35.object({
1397
+ since: z35.string().regex(/^\d{4}-\d{2}-\d{2}$/u),
1398
+ definitionID: z35.string().min(1).max(200).optional()
1399
+ })).output(z35.object({ entries: z35.array(reportEntrySchema) }))
1400
+ },
1401
+ definitions: {
1402
+ listTasks: signedIn.output(z35.object({ definitions: z35.array(listedDefinitionSchema) }))
1403
+ }
1404
+ };
1405
+
1406
+ // src/contract/worker-view-schema.ts
1407
+ import { z as z36 } from "zod";
1408
+ var usedSchema = z36.object({
1409
+ minutes: z36.number(),
1410
+ turns: z36.number(),
1411
+ tokens: z36.number(),
1412
+ dollars: z36.number()
1413
+ });
1414
+ var startedSchema = z36.object({
1415
+ phase: z36.literal("started"),
1416
+ workerRunID: z36.string(),
1417
+ shortID: z36.string(),
1418
+ callID: z36.string(),
1419
+ model: z36.string(),
1420
+ tools: z36.array(z36.string()),
1421
+ limits: usedSchema,
1422
+ isTaskLimit: z36.boolean()
1423
+ });
1424
+ var turnSchema = z36.object({
1425
+ phase: z36.literal("turn"),
1426
+ workerRunID: z36.string(),
1427
+ callID: z36.string(),
1428
+ turn: z36.number(),
1429
+ tokens: z36.number(),
1430
+ dollars: z36.number(),
1431
+ text: z36.string().optional()
1432
+ });
1433
+ var endedSchema = z36.object({
1434
+ phase: z36.literal("ended"),
1435
+ workerRunID: z36.string(),
1436
+ callID: z36.string(),
1437
+ outcome: z36.string(),
1438
+ limit: z36.string().optional(),
1439
+ used: usedSchema,
1440
+ detail: z36.string().optional()
1441
+ });
1442
+ var workerViewSchema = z36.discriminatedUnion("phase", [
1443
+ startedSchema,
1444
+ turnSchema,
1445
+ endedSchema
1446
+ ]);
1447
+
1448
+ // src/contract/contract.ts
1449
+ var clientActionIDSchema2 = z37.uuid();
1450
+ var imageSchema = z37.object({ mediaType: z37.enum(imageLimits.mediaTypes) });
1451
+ var imageFilesSchema = z37.array(z37.file());
1452
+ var imageRefSchema = z37.object({
1453
+ position: z37.int().nonnegative(),
1454
+ sequence: sequenceSchema,
1455
+ thread: threadSchema
1137
1456
  });
1138
- var ratingSchema = z26.object({
1139
- items: z26.array(ratingItemSchema),
1140
- ratedBy: z26.string().optional(),
1141
- recalledSequence: sequenceSchema
1457
+ var versionRefSchema = z37.object({
1458
+ itemID: z37.string().min(1).max(200),
1459
+ version: z37.int().nonnegative()
1142
1460
  });
1143
- var tokenCountSchema = z26.int().nonnegative();
1144
- var contextSchema = z26.object({ size: tokenCountSchema, window: z26.int().positive() });
1145
- var compactionSchema = z26.object({
1461
+ var recallItemSchema = versionRefSchema.extend({ score: z37.number().optional() });
1462
+ var recallSchema = z37.object({ items: z37.array(recallItemSchema) });
1463
+ var tokenCountSchema = z37.int().nonnegative();
1464
+ var contextSchema = z37.object({ size: tokenCountSchema, window: z37.int().positive() });
1465
+ var compactionSchema = z37.object({
1146
1466
  postTokens: tokenCountSchema.optional(),
1147
1467
  preTokens: tokenCountSchema,
1148
- trigger: z26.enum(["manual", "auto"])
1468
+ trigger: z37.enum(["manual", "auto"])
1149
1469
  });
1150
- var summarySchema = z26.object({
1470
+ var summarySchema = z37.object({
1151
1471
  contextSize: tokenCountSchema.optional(),
1152
1472
  summaryTokens: tokenCountSchema,
1153
- text: z26.string().optional(),
1154
- trigger: z26.enum(["threshold", "overflow"])
1155
- });
1156
- var compactionFailureSchema = z26.object({ failures: z26.int().positive() });
1157
- var ratingNoteRefSchema = z26.object({
1158
- itemID: z26.string().min(1).max(200),
1159
- sequence: sequenceSchema
1160
- });
1161
- var ratingNoteSchema = ratingNoteRefSchema.extend({
1162
- status: z26.enum(["readable", "shredded", "unreadable", "missing"]),
1163
- text: z26.string().optional()
1473
+ text: z37.string().optional(),
1474
+ trigger: z37.enum(["threshold", "overflow"])
1164
1475
  });
1476
+ var compactionFailureSchema = z37.object({ failures: z37.int().positive() });
1165
1477
  var versionTextSchema = versionRefSchema.extend({
1166
- status: z26.enum(["readable", "shredded", "unreadable", "missing"]),
1167
- text: z26.string().optional()
1478
+ status: z37.enum(["readable", "shredded", "unreadable", "missing"]),
1479
+ text: z37.string().optional()
1168
1480
  });
1169
- var listedActionSchema = z26.object({ actionID: z26.string(), tool: z26.string() });
1170
- var taskMessageSchema = z26.object({
1481
+ var listedActionSchema = z37.object({ actionID: z37.string(), tool: z37.string() });
1482
+ var taskMessageSchema = z37.object({
1171
1483
  from: threadSchema,
1172
- fromName: z26.string(),
1173
- hop: z26.int().nonnegative(),
1174
- kind: z26.string(),
1175
- messageID: z26.string(),
1176
- replyTo: z26.string().optional(),
1177
- text: z26.string().optional(),
1484
+ fromName: z37.string(),
1485
+ hop: z37.int().nonnegative(),
1486
+ kind: z37.string(),
1487
+ messageID: z37.string(),
1488
+ replyTo: z37.string().optional(),
1489
+ text: z37.string().optional(),
1178
1490
  to: threadSchema,
1179
- woke: z26.boolean()
1491
+ woke: z37.boolean()
1180
1492
  });
1181
- var exchangeNoticeSchema = z26.object({
1182
- link: z26.object({ label: z26.string(), messageID: z26.string(), taskID: threadSchema }),
1183
- text: z26.string()
1493
+ var exchangeNoticeSchema = z37.object({
1494
+ link: z37.object({ label: z37.string(), messageID: z37.string(), taskID: threadSchema }),
1495
+ text: z37.string()
1184
1496
  });
1185
- var recordSchema = z26.object({
1497
+ var reminderSchema = z37.object({
1498
+ brief: z37.string(),
1499
+ scheduledFor: z37.iso.datetime({ offset: true }),
1500
+ lateBySeconds: z37.number().nullable()
1501
+ });
1502
+ var recordSchema = z37.object({
1503
+ clipped: z37.array(clippedPayloadSchema).optional(),
1186
1504
  compaction: compactionSchema.optional(),
1187
1505
  exchangeNotice: exchangeNoticeSchema.optional(),
1506
+ reminder: reminderSchema.optional(),
1188
1507
  compactionFailure: compactionFailureSchema.optional(),
1189
- forget: z26.object({ sequence: sequenceSchema }).optional(),
1508
+ forget: z37.object({ sequence: sequenceSchema }).optional(),
1190
1509
  context: contextSchema.optional(),
1191
- isRemoved: z26.literal(true).optional(),
1192
- isSilentTurn: z26.literal(true).optional(),
1193
- kind: z26.string(),
1194
- message: z26.object({
1195
- clientMessageId: z26.uuid().optional(),
1196
- images: z26.array(imageSchema).optional(),
1197
- spans: z26.array(spanSchema).optional(),
1198
- text: z26.string()
1510
+ definitionNotice: definitionNoticeSchema.optional(),
1511
+ isRemoved: z37.literal(true).optional(),
1512
+ isSilentTurn: z37.literal(true).optional(),
1513
+ kind: z37.string(),
1514
+ message: z37.object({
1515
+ clientMessageId: z37.uuid().optional(),
1516
+ images: z37.array(imageSchema).optional(),
1517
+ spans: z37.array(spanSchema).optional(),
1518
+ text: z37.string()
1199
1519
  }).optional(),
1200
- moment: z26.object({ momentID: z26.string(), shortID: z26.string(), title: z26.string().optional() }).optional(),
1201
- rating: ratingSchema.optional(),
1202
- proposal: z26.object({ proposalID: z26.string(), shortID: z26.string() }).optional(),
1520
+ moment: z37.object({ momentID: z37.string(), shortID: z37.string(), title: z37.string().optional() }).optional(),
1521
+ proposal: z37.object({ proposalID: z37.string(), shortID: z37.string() }).optional(),
1203
1522
  recall: recallSchema.optional(),
1204
- recordedAt: z26.date(),
1205
- removal: z26.object({ kind: z26.string(), sequence: sequenceSchema, callSequence: sequenceSchema.optional() }).optional(),
1523
+ recordedAt: z37.date(),
1524
+ removal: z37.object({ kind: z37.string(), sequence: sequenceSchema, callSequence: sequenceSchema.optional() }).optional(),
1206
1525
  sequence: sequenceSchema,
1207
- stop: z26.object({ cancelledActions: z26.array(listedActionSchema) }).optional(),
1526
+ stop: z37.object({ cancelledActions: z37.array(listedActionSchema) }).optional(),
1208
1527
  summary: summarySchema.optional(),
1209
1528
  thread: threadSchema,
1210
1529
  task: taskSchema2.optional(),
1211
1530
  taskMessage: taskMessageSchema.optional(),
1212
- toolCall: toolCallSchema.optional()
1531
+ toolCall: toolCallSchema.optional(),
1532
+ worker: workerViewSchema.optional()
1213
1533
  });
1214
- var writerErrorSchema = z26.object({ at: z26.date(), code: z26.string(), message: z26.string().nullable() }).nullable();
1215
- var sessionSchema = z26.object({
1216
- createdAt: z26.date(),
1217
- current: z26.boolean(),
1218
- deviceName: z26.string(),
1219
- lastUsedAt: z26.date(),
1220
- sessionID: z26.uuid()
1534
+ var writerErrorSchema = z37.object({ at: z37.date(), code: z37.string(), message: z37.string().nullable() }).nullable();
1535
+ var sessionSchema = z37.object({
1536
+ createdAt: z37.date(),
1537
+ current: z37.boolean(),
1538
+ deviceName: z37.string(),
1539
+ lastUsedAt: z37.date(),
1540
+ sessionID: z37.uuid()
1221
1541
  });
1222
1542
  var checkedAction = signedIn.errors(reusedIDErrors);
1223
- var taskStateSchema2 = z26.enum([
1224
- "ready",
1225
- "running",
1226
- "waiting",
1227
- "paused",
1228
- "stopped",
1229
- "done",
1230
- "failed",
1231
- "closed"
1232
- ]);
1233
- var taskControlSchema = z26.enum(["pause", "resume", "stop", "restart", "close", "interrupt"]);
1234
- var actionCountSchema = z26.int().nonnegative();
1235
- var forgetPreviewItemSchema = z26.object({ itemID: z26.string(), text: z26.string() });
1236
- var recordForgetPreviewSchema = z26.object({
1543
+ var forgetPreviewItemSchema = z37.object({ itemID: z37.string(), text: z37.string() });
1544
+ var recordForgetPreviewSchema = z37.object({
1237
1545
  momentCount: actionCountSchema,
1238
- memoryItems: z26.array(forgetPreviewItemSchema)
1546
+ memoryItems: z37.array(forgetPreviewItemSchema)
1239
1547
  });
1240
- var listedTaskSchema = z26.object({
1241
- actions: z26.object({
1242
- cancelled: actionCountSchema,
1243
- queued: actionCountSchema,
1244
- started: actionCountSchema
1245
- }),
1246
- brief: z26.string(),
1247
- controls: z26.array(taskControlSchema),
1248
- isPauseRequested: z26.boolean(),
1249
- isPausedByNixie: z26.boolean(),
1250
- isTakingMessages: z26.boolean(),
1251
- lastActivityAt: z26.date(),
1252
- name: z26.string(),
1253
- runner: z26.string(),
1254
- state: taskStateSchema2,
1255
- taskID: threadSchema,
1256
- waitingOn: threadSchema.optional()
1257
- });
1258
- var controlledTaskSchema = z26.object({
1259
- controlledAt: z26.date(),
1260
- isPauseRequested: z26.boolean(),
1261
- state: taskStateSchema2,
1548
+ var controlledTaskSchema = z37.object({
1549
+ controlledAt: z37.date(),
1550
+ isPauseRequested: z37.boolean(),
1551
+ state: taskStateSchema,
1262
1552
  taskID: threadSchema
1263
1553
  });
1264
1554
  var taskControl = checkedAction.errors({
@@ -1266,57 +1556,67 @@ var taskControl = checkedAction.errors({
1266
1556
  TASK_STATE_REFUSED: {
1267
1557
  message: "The task is in a state that does not take this control",
1268
1558
  status: 409,
1269
- data: z26.object({ isPauseRequested: z26.boolean(), state: taskStateSchema2 })
1559
+ data: z37.object({ isPauseRequested: z37.boolean(), state: taskStateSchema })
1270
1560
  },
1271
1561
  RUNNER_LACKS_CONTROL: {
1272
1562
  message: "The runner of the task does not take this control",
1273
1563
  status: 409
1274
1564
  }
1275
- }).input(z26.object({ clientActionID: clientActionIDSchema2, taskID: threadSchema })).output(controlledTaskSchema);
1276
- var nixieControl = checkedAction.input(z26.object({ clientActionID: clientActionIDSchema2 })).output(z26.object({ paused: pauseStateSchema }));
1277
- var backupNoticeSchema = z26.object({
1278
- cause: z26.enum(["failed", "missing"]),
1279
- sequence: z26.int().positive(),
1280
- raisedAt: z26.date()
1281
- });
1282
- var followRecords = signedIn.input(z26.object({ afterSequence: sequenceSchema, thread: threadSchema.optional() })).output(eventIterator2(z26.object({ record: recordSchema })));
1565
+ }).input(z37.object({ clientActionID: clientActionIDSchema2, taskID: threadSchema })).output(controlledTaskSchema);
1566
+ var markedTaskSchema = z37.object({
1567
+ changedAt: z37.date(),
1568
+ disposable: z37.boolean(),
1569
+ taskID: threadSchema
1570
+ });
1571
+ var nixieControl = checkedAction.input(z37.object({ clientActionID: clientActionIDSchema2 })).output(z37.object({ paused: pauseStateSchema }));
1572
+ var backupNoticeSchema = z37.object({
1573
+ cause: z37.enum(["failed", "missing"]),
1574
+ sequence: z37.int().positive(),
1575
+ raisedAt: z37.date()
1576
+ });
1577
+ var followRecords = signedIn.input(z37.object({
1578
+ afterSequence: sequenceSchema,
1579
+ clipPayloads: z37.boolean().optional(),
1580
+ thread: threadSchema.optional()
1581
+ })).output(eventIterator2(z37.object({ record: recordSchema })));
1283
1582
  var contract = {
1284
1583
  conversation: {
1285
- read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z26.object({
1584
+ read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z37.object({
1286
1585
  beforeSequence: sequenceSchema.optional(),
1287
- limit: z26.int().min(1).max(200).optional(),
1586
+ clipPayloads: z37.boolean().optional(),
1587
+ limit: z37.int().min(1).max(200).optional(),
1288
1588
  thread: threadSchema
1289
- })).output(z26.object({
1290
- hasEarlier: z26.boolean(),
1589
+ })).output(z37.object({
1590
+ hasEarlier: z37.boolean(),
1291
1591
  readAtSequence: sequenceSchema,
1292
- records: z26.array(recordSchema),
1592
+ records: z37.array(recordSchema),
1293
1593
  lastStepEnd: recordSchema.nullable().optional()
1294
1594
  })),
1295
1595
  send: checkedAction.errors({
1296
1596
  IMAGE_REFUSED: imageRefusedError,
1297
1597
  THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 }
1298
- }).input(z26.object({
1598
+ }).input(z37.object({
1299
1599
  clientMessageId: clientActionIDSchema2,
1300
1600
  images: imageFilesSchema.optional(),
1301
- spans: z26.array(spanSchema).max(1e5),
1302
- text: z26.string().min(1).max(1e5),
1601
+ spans: z37.array(spanSchema).max(1e5),
1602
+ text: z37.string().min(1).max(1e5),
1303
1603
  thread: threadSchema,
1304
- timeZone: z26.string().min(1).max(100).optional(),
1305
- writtenAt: z26.iso.datetime().optional()
1306
- })).output(z26.object({ duplicate: z26.boolean(), sequence: sequenceSchema })),
1604
+ timeZone: z37.string().min(1).max(100).optional(),
1605
+ writtenAt: z37.iso.datetime().optional()
1606
+ })).output(z37.object({ duplicate: z37.boolean(), sequence: sequenceSchema })),
1307
1607
  retry: checkedAction.errors({
1308
1608
  NOTHING_TO_RETRY: {
1309
1609
  message: "The last turn of the conversation did not fail, or it runs again already",
1310
1610
  status: 409
1311
1611
  }
1312
- }).input(z26.object({ clientActionID: clientActionIDSchema2 })).output(z26.object({ retriedAt: z26.date() })),
1313
- readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z26.file()),
1612
+ }).input(z37.object({ clientActionID: clientActionIDSchema2 })).output(z37.object({ retriedAt: z37.date() })),
1613
+ readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(z37.file()),
1314
1614
  previewForget: signedIn.errors({
1315
1615
  RECORD_NOT_FOUND: {
1316
1616
  message: "No record on this thread with its own text that a forget removes has this sequence",
1317
1617
  status: 404
1318
1618
  }
1319
- }).input(z26.object({ thread: threadSchema, sequence: sequenceSchema })).output(recordForgetPreviewSchema),
1619
+ }).input(z37.object({ thread: threadSchema, sequence: sequenceSchema })).output(recordForgetPreviewSchema),
1320
1620
  forget: checkedAction.errors({
1321
1621
  RECORD_NOT_FOUND: {
1322
1622
  message: "No record on this thread with its own text that a forget removes has this sequence",
@@ -1326,54 +1626,78 @@ var contract = {
1326
1626
  message: "The queued action has not run yet. Cancel it, or wait for it to run.",
1327
1627
  status: 409
1328
1628
  }
1329
- }).input(z26.object({
1629
+ }).input(z37.object({
1330
1630
  clientActionID: clientActionIDSchema2,
1331
1631
  sequence: sequenceSchema,
1332
1632
  thread: threadSchema
1333
- })).output(z26.object({ forgottenAt: z26.date(), backup: forgetBackupSchema }))
1633
+ })).output(z37.object({ forgottenAt: z37.date(), backup: forgetBackupSchema }))
1334
1634
  },
1335
1635
  tasks: {
1336
- list: signedIn.output(z26.object({ readAtSequence: sequenceSchema, tasks: z26.array(listedTaskSchema) })),
1337
- read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z26.object({ taskID: threadSchema })).output(listedTaskSchema),
1338
- readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z26.object({ taskID: threadSchema })).output(z26.object({
1339
- queued: z26.array(listedActionSchema),
1340
- started: z26.array(listedActionSchema)
1636
+ list: signedIn.input(z37.object({
1637
+ definitionID: z37.string().min(1).max(200).optional(),
1638
+ states: z37.array(listedStateSchema).min(1).max(11).refine((states) => new Set(states).size === states.length, {
1639
+ message: "Each state may appear once"
1640
+ }).optional()
1641
+ }).optional()).output(z37.object({ readAtSequence: sequenceSchema, tasks: z37.array(listedTaskSchema) })),
1642
+ read: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z37.object({ taskID: threadSchema })).output(listedTaskSchema),
1643
+ readActions: signedIn.errors({ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 } }).input(z37.object({ taskID: threadSchema })).output(z37.object({
1644
+ queued: z37.array(listedActionSchema),
1645
+ started: z37.array(listedActionSchema)
1341
1646
  })),
1342
1647
  pause: taskControl,
1343
1648
  resume: taskControl,
1344
1649
  stop: taskControl,
1345
1650
  restart: taskControl,
1346
1651
  close: taskControl.errors({
1347
- CONVERSATION_NEVER_CLOSES: { message: "The conversation is never closed", status: 409 }
1652
+ CONVERSATION_NEVER_CLOSES: { message: "The conversation is never closed", status: 409 },
1653
+ DEFINITION_TASK_NEVER_CLOSES: {
1654
+ message: "The task of a definition is never closed",
1655
+ status: 409
1656
+ }
1348
1657
  }),
1349
- interrupt: taskControl
1658
+ interrupt: taskControl,
1659
+ setDisposable: checkedAction.errors({
1660
+ TASK_NOT_FOUND: { message: "No task has this ID", status: 404 },
1661
+ TASK_HAS_NO_MARK: { message: "The task has no disposable mark", status: 409 },
1662
+ TASK_STATE_REFUSED: {
1663
+ message: "The task is in a state that does not take this change",
1664
+ status: 409,
1665
+ data: z37.object({ state: taskStateSchema })
1666
+ }
1667
+ }).input(z37.object({
1668
+ clientActionID: clientActionIDSchema2,
1669
+ disposable: z37.boolean(),
1670
+ taskID: threadSchema
1671
+ })).output(markedTaskSchema),
1672
+ ...viewContract.tasks
1350
1673
  },
1351
1674
  memory: {
1352
- readVersions: signedIn.input(z26.object({ versions: z26.array(versionRefSchema).min(1).max(100) })).output(z26.object({ versions: z26.array(versionTextSchema) })),
1353
- readRatingNotes: signedIn.input(z26.object({ notes: z26.array(ratingNoteRefSchema).min(1).max(100) })).output(z26.object({ notes: z26.array(ratingNoteSchema) })),
1354
- writerStatus: signedIn.route({ deprecated: true }).output(z26.object({
1355
- isEnabled: z26.boolean(),
1356
- backlog: z26.int().nonnegative(),
1357
- batches: z26.int().nonnegative(),
1675
+ readVersions: signedIn.input(z37.object({ versions: z37.array(versionRefSchema).min(1).max(100) })).output(z37.object({ versions: z37.array(versionTextSchema) })),
1676
+ writerStatus: signedIn.route({ deprecated: true }).output(z37.object({
1677
+ isEnabled: z37.boolean(),
1678
+ backlog: z37.int().nonnegative(),
1679
+ batches: z37.int().nonnegative(),
1358
1680
  cursor: sequenceSchema,
1359
- failures: z26.int().nonnegative(),
1360
- isCatchingUp: z26.boolean(),
1681
+ failures: z37.int().nonnegative(),
1682
+ isCatchingUp: z37.boolean(),
1361
1683
  lastError: writerErrorSchema,
1362
- retryAt: z26.date().nullable()
1684
+ retryAt: z37.date().nullable()
1363
1685
  })),
1364
1686
  ...memoryViewContract
1365
1687
  },
1366
1688
  nixie: {
1367
- read: signedIn.output(z26.object({ paused: pauseStateSchema })),
1689
+ read: signedIn.output(z37.object({ paused: pauseStateSchema })),
1368
1690
  pause: nixieControl,
1369
1691
  resume: nixieControl
1370
1692
  },
1371
1693
  recovery: {
1372
- read: signedIn.output(z26.object({ recovery: recoverySchema }))
1694
+ read: signedIn.output(z37.object({ recovery: recoverySchema }))
1373
1695
  },
1374
1696
  backups: {
1375
- readNotice: signedIn.output(z26.object({ notice: backupNoticeSchema.nullable() }))
1697
+ readNotice: signedIn.output(z37.object({ notice: backupNoticeSchema.nullable() }))
1376
1698
  },
1699
+ triggers: viewContract.triggers,
1700
+ definitions: { ...viewContract.definitions, ...definitionsContract },
1377
1701
  rules: ruleContract,
1378
1702
  approvals: approvalContract,
1379
1703
  passkeys: passkeyContract,
@@ -1381,7 +1705,8 @@ var contract = {
1381
1705
  follow: followRecords.route({ deprecated: true })
1382
1706
  },
1383
1707
  records: {
1384
- follow: followRecords
1708
+ follow: followRecords,
1709
+ readPayload: readPayloadContract
1385
1710
  },
1386
1711
  sessions: {
1387
1712
  enrol: oc2.errors(reusedIDErrors).errors({
@@ -1389,28 +1714,28 @@ var contract = {
1389
1714
  message: "The enrolment code is unknown, used or lapsed",
1390
1715
  status: 400
1391
1716
  }
1392
- }).input(z26.object({
1717
+ }).input(z37.object({
1393
1718
  clientActionID: clientActionIDSchema2,
1394
- code: z26.string().min(1).max(100),
1395
- deviceName: z26.string().min(1).max(100),
1396
- tokenDelivery: z26.enum(["cookie", "bearer"])
1397
- })).output(z26.object({ sessionID: z26.uuid(), token: z26.string().optional() })),
1398
- issueCode: checkedAction.input(z26.object({ clientActionID: clientActionIDSchema2 })).output(z26.object({ code: z26.string(), expiresAt: z26.date() })),
1399
- list: signedIn.output(z26.object({ sessions: z26.array(sessionSchema) })),
1400
- 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() }))
1719
+ code: z37.string().min(1).max(100),
1720
+ deviceName: z37.string().min(1).max(100),
1721
+ tokenDelivery: z37.enum(["cookie", "bearer"])
1722
+ })).output(z37.object({ sessionID: z37.uuid(), token: z37.string().optional() })),
1723
+ issueCode: checkedAction.input(z37.object({ clientActionID: clientActionIDSchema2 })).output(z37.object({ code: z37.string(), expiresAt: z37.date() })),
1724
+ list: signedIn.output(z37.object({ sessions: z37.array(sessionSchema) })),
1725
+ revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(z37.object({ clientActionID: clientActionIDSchema2, sessionID: z37.uuid() })).output(z37.object({ revokedAt: z37.date() }))
1401
1726
  }
1402
1727
  };
1403
1728
  // src/contract/host-contract.ts
1404
1729
  import { oc as oc6 } from "@orpc/contract";
1405
- import { z as z35 } from "zod";
1730
+ import { z as z46 } from "zod";
1406
1731
 
1407
1732
  // src/contract/action-proposal-schema.ts
1408
- import { z as z27 } from "zod";
1409
- var actionProposalSchema = z27.object({
1410
- proposalID: z27.string(),
1411
- tool: z27.string(),
1412
- effects: z27.array(z27.string()),
1413
- cause: z27.enum([
1733
+ import { z as z38 } from "zod";
1734
+ var actionProposalSchema = z38.object({
1735
+ proposalID: z38.string(),
1736
+ tool: z38.string(),
1737
+ effects: z38.array(z38.string()),
1738
+ cause: z38.enum([
1414
1739
  "outside_steering",
1415
1740
  "always_ask",
1416
1741
  "ask_rule",
@@ -1418,81 +1743,81 @@ var actionProposalSchema = z27.object({
1418
1743
  "direct_request",
1419
1744
  "repeat"
1420
1745
  ]),
1421
- sentence: z27.string(),
1422
- destinations: z27.array(z27.string()),
1423
- createdAt: z27.date(),
1424
- lapseAt: z27.date()
1746
+ sentence: z38.string(),
1747
+ destinations: z38.array(z38.string()),
1748
+ createdAt: z38.date(),
1749
+ lapseAt: z38.date()
1425
1750
  });
1426
1751
 
1427
1752
  // src/contract/forgotten-items-schema.ts
1428
- import { z as z28 } from "zod";
1429
- var forgottenItemsSchema = z28.object({
1430
- itemIDs: z28.array(z28.string()),
1753
+ import { z as z39 } from "zod";
1754
+ var forgottenItemsSchema = z39.object({
1755
+ itemIDs: z39.array(z39.string()),
1431
1756
  backup: forgetBackupSchema
1432
1757
  });
1433
1758
 
1434
1759
  // src/contract/host-mandates-contract.ts
1435
1760
  import { oc as oc3 } from "@orpc/contract";
1436
- import { z as z29 } from "zod";
1761
+ import { z as z40 } from "zod";
1437
1762
  var mandates = oc3.errors({
1438
1763
  NOT_FOUND: { message: "no mandate has that ID", status: 404 }
1439
1764
  });
1440
- var hostMandateRuleSchema = z29.object({ ruleID: z29.string(), sentence: z29.string() });
1441
- var hostMandateSchema = z29.object({
1442
- mandateID: z29.string(),
1443
- title: z29.string().nullable(),
1444
- rules: z29.array(hostMandateRuleSchema),
1445
- startedAt: z29.date(),
1446
- expires: z29.date()
1765
+ var hostMandateRuleSchema = z40.object({ ruleID: z40.string(), sentence: z40.string() });
1766
+ var hostMandateSchema = z40.object({
1767
+ mandateID: z40.string(),
1768
+ title: z40.string().nullable(),
1769
+ rules: z40.array(hostMandateRuleSchema),
1770
+ startedAt: z40.date(),
1771
+ expires: z40.date()
1447
1772
  });
1448
1773
  var hostMandatesContract = {
1449
- list: mandates.output(z29.array(hostMandateSchema)),
1450
- end: mandates.input(z29.strictObject({ mandateID: z29.string().min(1) })).output(z29.object({ mandateID: z29.string(), state: z29.enum(["ended", "expired"]) }))
1774
+ list: mandates.output(z40.array(hostMandateSchema)),
1775
+ end: mandates.input(z40.strictObject({ mandateID: z40.string().min(1) })).output(z40.object({ mandateID: z40.string(), state: z40.enum(["ended", "expired"]) }))
1451
1776
  };
1452
1777
 
1453
1778
  // src/contract/host-passkey-contract.ts
1454
1779
  import { oc as oc4 } from "@orpc/contract";
1455
- import { z as z30 } from "zod";
1456
- var hostPasskeySchema = z30.object({
1457
- passkeyID: z30.string(),
1458
- label: z30.string(),
1459
- synced: z30.boolean(),
1460
- origin: z30.string(),
1461
- registeredBy: z30.string(),
1462
- authorizedBy: z30.string(),
1463
- registeredAt: z30.date(),
1464
- lastUsedAt: z30.date().nullable(),
1465
- revokedAt: z30.date().nullable()
1780
+ import { z as z41 } from "zod";
1781
+ var hostPasskeySchema = z41.object({
1782
+ passkeyID: z41.string(),
1783
+ label: z41.string(),
1784
+ synced: z41.boolean(),
1785
+ origin: z41.string(),
1786
+ registeredBy: z41.string(),
1787
+ authorizedBy: z41.string(),
1788
+ registeredAt: z41.date(),
1789
+ lastUsedAt: z41.date().nullable(),
1790
+ revokedAt: z41.date().nullable()
1466
1791
  });
1467
1792
  var hostPasskeyContract = {
1468
- issueCode: oc4.output(z30.object({ code: z30.string(), expiresAt: z30.date() })),
1469
- list: oc4.output(z30.array(hostPasskeySchema)),
1793
+ issueCode: oc4.output(z41.object({ code: z41.string(), expiresAt: z41.date() })),
1794
+ list: oc4.output(z41.array(hostPasskeySchema)),
1470
1795
  revoke: oc4.errors({
1471
1796
  PASSKEY_NOT_FOUND: { message: "no passkey has that ID", status: 404 }
1472
- }).input(z30.strictObject({ passkeyID: z30.string().min(1) })).output(z30.object({ passkeyID: z30.string(), revokedAt: z30.date() }))
1797
+ }).input(z41.strictObject({ passkeyID: z41.string().min(1) })).output(z41.object({ passkeyID: z41.string(), revokedAt: z41.date() }))
1473
1798
  };
1474
1799
 
1475
1800
  // src/contract/known-contact-schema.ts
1476
- import { z as z31 } from "zod";
1477
- var knownContactSchema = z31.object({
1478
- contactID: z31.string(),
1479
- name: z31.string().nullable(),
1480
- destination: z31.string().nullable(),
1481
- markedAt: z31.date()
1801
+ import { z as z42 } from "zod";
1802
+ var knownContactSchema = z42.object({
1803
+ contactID: z42.string(),
1804
+ name: z42.string().nullable(),
1805
+ destination: z42.string().nullable(),
1806
+ markedAt: z42.date()
1482
1807
  });
1483
1808
 
1484
1809
  // src/contract/turn-inputs-contract.ts
1485
1810
  import { oc as oc5 } from "@orpc/contract";
1486
- import { z as z34 } from "zod";
1811
+ import { z as z45 } from "zod";
1487
1812
 
1488
1813
  // src/contract/input-miss-schema.ts
1489
- import { z as z32 } from "zod";
1490
- var inputMissSchema = z32.object({
1491
- missID: z32.string(),
1492
- captureID: z32.string().nullable(),
1493
- taskID: z32.string(),
1494
- stepRunID: z32.string(),
1495
- reason: z32.enum([
1814
+ import { z as z43 } from "zod";
1815
+ var inputMissSchema = z43.object({
1816
+ missID: z43.string(),
1817
+ captureID: z43.string().nullable(),
1818
+ taskID: z43.string(),
1819
+ stepRunID: z43.string(),
1820
+ reason: z43.enum([
1496
1821
  "queue_full",
1497
1822
  "spool_full",
1498
1823
  "spool_write_failed",
@@ -1504,45 +1829,45 @@ var inputMissSchema = z32.object({
1504
1829
  "intake_failed",
1505
1830
  "holds_own_value"
1506
1831
  ]),
1507
- count: z32.int().positive(),
1508
- writer: z32.string().nullable(),
1509
- counter: z32.int().nullable(),
1510
- createdAt: z32.date()
1832
+ count: z43.int().positive(),
1833
+ writer: z43.string().nullable(),
1834
+ counter: z43.int().nullable(),
1835
+ createdAt: z43.date()
1511
1836
  });
1512
1837
 
1513
1838
  // src/contract/logged-input-schema.ts
1514
- import { z as z33 } from "zod";
1515
- var loggedInputSchema = z33.object({
1516
- inputID: z33.string(),
1517
- captureID: z33.string(),
1518
- taskID: z33.string(),
1519
- stepRunID: z33.string(),
1520
- writer: z33.string(),
1521
- counter: z33.int(),
1522
- role: z33.string(),
1523
- profile: z33.string(),
1524
- model: z33.string(),
1525
- harness: z33.string(),
1526
- api: z33.string(),
1527
- endpoint: z33.string(),
1528
- route: z33.string(),
1529
- isRewritten: z33.boolean(),
1530
- upstreamStatus: z33.int(),
1531
- bytes: z33.int(),
1532
- intakeSequence: z33.int(),
1533
- receivedAt: z33.date(),
1534
- takenAt: z33.date(),
1535
- state: z33.enum(["writing", "stored", "missing", "removed"]),
1536
- removedCause: z33.enum(["retention_days", "retention_bytes", "forget", "dropped", "restore", "reset"]).nullable()
1839
+ import { z as z44 } from "zod";
1840
+ var loggedInputSchema = z44.object({
1841
+ inputID: z44.string(),
1842
+ captureID: z44.string(),
1843
+ taskID: z44.string(),
1844
+ stepRunID: z44.string(),
1845
+ writer: z44.string(),
1846
+ counter: z44.int(),
1847
+ role: z44.string(),
1848
+ profile: z44.string(),
1849
+ model: z44.string(),
1850
+ harness: z44.string(),
1851
+ api: z44.string(),
1852
+ endpoint: z44.string(),
1853
+ route: z44.string(),
1854
+ isRewritten: z44.boolean(),
1855
+ upstreamStatus: z44.int(),
1856
+ bytes: z44.int(),
1857
+ intakeSequence: z44.int(),
1858
+ receivedAt: z44.date(),
1859
+ takenAt: z44.date(),
1860
+ state: z44.enum(["writing", "stored", "missing", "removed"]),
1861
+ removedCause: z44.enum(["retention_days", "retention_bytes", "forget", "dropped", "restore", "reset"]).nullable()
1537
1862
  });
1538
1863
 
1539
1864
  // src/contract/turn-inputs-contract.ts
1540
- var turnInputOn = z34.strictObject({
1541
- state: z34.literal("on"),
1542
- forMs: z34.int().positive().nullable()
1865
+ var turnInputOn = z45.strictObject({
1866
+ state: z45.literal("on"),
1867
+ forMs: z45.int().positive().nullable()
1543
1868
  });
1544
- var turnInputOff = z34.strictObject({ state: z34.literal("off"), drop: z34.boolean() });
1545
- var turnInputSetSchema = z34.discriminatedUnion("state", [turnInputOn, turnInputOff]);
1869
+ var turnInputOff = z45.strictObject({ state: z45.literal("off"), drop: z45.boolean() });
1870
+ var turnInputSetSchema = z45.discriminatedUnion("state", [turnInputOn, turnInputOff]);
1546
1871
  var turnInputs = oc5.errors({
1547
1872
  NOT_FOUND: { message: "no logged request has that ID", status: 404 },
1548
1873
  REMOVED: { message: "that request is removed or its body is missing", status: 410 },
@@ -1552,27 +1877,27 @@ var turnInputs = oc5.errors({
1552
1877
  },
1553
1878
  NOT_CONFIGURED: { message: "the turn-input log is not configured", status: 409 }
1554
1879
  });
1555
- var listedInputsSchema = z34.object({
1556
- inputs: z34.array(loggedInputSchema),
1557
- misses: z34.array(inputMissSchema)
1880
+ var listedInputsSchema = z45.object({
1881
+ inputs: z45.array(loggedInputSchema),
1882
+ misses: z45.array(inputMissSchema)
1558
1883
  });
1559
1884
  var turnInputsContract = {
1560
- list: turnInputs.input(z34.strictObject({ limit: z34.int().positive().max(500).default(50) })).output(listedInputsSchema),
1561
- open: turnInputs.input(z34.strictObject({ inputID: z34.string().min(1) })).output(z34.object({ inputID: z34.string(), body: z34.base64() })),
1562
- set: turnInputs.input(turnInputSetSchema).output(z34.object({ state: z34.enum(["on", "off"]), until: z34.number().nullable() }))
1885
+ list: turnInputs.input(z45.strictObject({ limit: z45.int().positive().max(500).default(50) })).output(listedInputsSchema),
1886
+ open: turnInputs.input(z45.strictObject({ inputID: z45.string().min(1) })).output(z45.object({ inputID: z45.string(), body: z45.base64() })),
1887
+ set: turnInputs.input(turnInputSetSchema).output(z45.object({ state: z45.enum(["on", "off"]), until: z45.number().nullable() }))
1563
1888
  };
1564
1889
 
1565
1890
  // src/contract/host-contract.ts
1566
- var versionRefSchema2 = z35.object({ itemID: z35.string(), version: z35.int().positive() });
1567
- var versionTargetSchema2 = z35.strictObject({
1568
- itemID: z35.string().min(1),
1569
- version: z35.int().positive()
1570
- });
1571
- var itemTextSchema = z35.string().max(2000).regex(/\S/u);
1572
- var proposalOriginSchema2 = z35.enum(["owner", "conversation", "task"]);
1573
- var memoryOriginSchema = z35.enum([...proposalOriginSchema2.options, "lapse"]);
1574
- var contentSourceSchema = z35.enum(["owner", "owner_data", "untrusted"]);
1575
- var reviewReasonSchema2 = z35.enum([
1891
+ var versionRefSchema2 = z46.object({ itemID: z46.string(), version: z46.int().positive() });
1892
+ var versionTargetSchema2 = z46.strictObject({
1893
+ itemID: z46.string().min(1),
1894
+ version: z46.int().positive()
1895
+ });
1896
+ var itemTextSchema = z46.string().max(2000).regex(/\S/u);
1897
+ var proposalOriginSchema2 = z46.enum(["owner", "conversation", "task"]);
1898
+ var memoryOriginSchema = z46.enum([...proposalOriginSchema2.options, "lapse"]);
1899
+ var contentSourceSchema = z46.enum(["owner", "owner_data", "untrusted"]);
1900
+ var reviewReasonSchema2 = z46.enum([
1576
1901
  "no_quote",
1577
1902
  "quote_not_typed",
1578
1903
  "quote_in_quoted_block",
@@ -1587,72 +1912,72 @@ var reviewReasonSchema2 = z35.enum([
1587
1912
  "other",
1588
1913
  "self_note",
1589
1914
  "from_photo",
1590
- "sensitive",
1591
1915
  "subject_change",
1592
1916
  "labels",
1593
1917
  "ask_rule"
1594
1918
  ]);
1595
- var proposalSourceSchema2 = z35.object({
1919
+ var proposalSourceSchema2 = z46.object({
1596
1920
  origin: proposalOriginSchema2,
1597
- thread: z35.string().nullable(),
1598
- proposedAt: z35.date()
1599
- });
1600
- var pendingProposalSchema = z35.object({
1601
- proposalID: z35.string(),
1602
- operation: z35.enum(["remember", "retire", "pin"]),
1603
- itemID: z35.string(),
1604
- targetVersion: z35.int().nullable(),
1605
- isPinned: z35.boolean(),
1606
- subject: z35.enum(["owner", "self", "shared"]),
1607
- newSubject: z35.enum(["owner", "self", "shared"]).nullable(),
1608
- isSensitive: z35.boolean(),
1609
- kind: z35.enum(["fact", "self"]),
1921
+ thread: z46.string().nullable(),
1922
+ proposedAt: z46.date()
1923
+ });
1924
+ var pendingProposalSchema = z46.object({
1925
+ proposalID: z46.string(),
1926
+ operation: z46.enum(["remember", "retire", "pin"]),
1927
+ itemID: z46.string(),
1928
+ targetVersion: z46.int().nullable(),
1929
+ isPinned: z46.boolean(),
1930
+ subject: z46.enum(["owner", "self", "shared"]),
1931
+ newSubject: z46.enum(["owner", "self", "shared"]).nullable(),
1932
+ kind: z46.enum(["fact", "self"]),
1610
1933
  reason: reviewReasonSchema2,
1611
- actionHash: z35.string(),
1934
+ actionHash: z46.string(),
1612
1935
  origin: proposalOriginSchema2,
1613
1936
  source: contentSourceSchema,
1614
- createdAt: z35.date(),
1615
- lapseAt: z35.date(),
1616
- sources: z35.array(proposalSourceSchema2),
1617
- text: z35.string(),
1618
- quote: z35.string().nullable()
1619
- });
1620
- var closeMatchSchema2 = z35.object({ itemID: z35.string(), version: z35.int(), text: z35.string() });
1621
- var approvalResultSchema = z35.discriminatedUnion("status", [
1622
- z35.object({ status: z35.literal("applied"), itemID: z35.string(), version: z35.int() }),
1623
- z35.object({ status: z35.literal("close_match"), item: closeMatchSchema2 })
1937
+ createdAt: z46.date(),
1938
+ lapseAt: z46.date(),
1939
+ sources: z46.array(proposalSourceSchema2),
1940
+ text: z46.string(),
1941
+ quote: z46.string().nullable()
1942
+ });
1943
+ var closeMatchSchema2 = z46.object({ itemID: z46.string(), version: z46.int(), text: z46.string() });
1944
+ var approvalResultSchema = z46.discriminatedUnion("status", [
1945
+ z46.object({ status: z46.literal("applied"), itemID: z46.string(), version: z46.int() }),
1946
+ z46.object({ status: z46.literal("close_match"), item: closeMatchSchema2 })
1624
1947
  ]);
1625
- var historyVersionSchema = z35.object({
1626
- version: z35.int(),
1627
- change: z35.enum(["created", "edited", "retired", "restored", "undone"]),
1628
- state: z35.enum(["active", "retired"]),
1948
+ var historyVersionSchema = z46.object({
1949
+ version: z46.int(),
1950
+ change: z46.enum(["created", "edited", "retired", "restored", "undone"]),
1951
+ state: z46.enum(["active", "retired"]),
1629
1952
  origin: memoryOriginSchema,
1630
1953
  source: contentSourceSchema,
1631
- recordedAt: z35.date(),
1632
- status: z35.enum(["readable", "shredded", "unreadable"]),
1633
- text: z35.string().nullable()
1634
- });
1635
- var itemHistorySchema = z35.object({
1636
- itemID: z35.string(),
1637
- subject: z35.enum(["owner", "self", "shared"]),
1638
- kind: z35.enum(["fact", "self"]),
1639
- state: z35.enum(["active", "retired", "forgetting", "forgotten"]),
1640
- versions: z35.array(historyVersionSchema)
1641
- });
1642
- var proposalAnswerSchema = z35.strictObject({
1643
- proposalID: z35.string().min(1),
1644
- actionHash: z35.string().min(1)
1645
- });
1646
- var hostSessionSchema = z35.object({
1647
- sessionID: z35.string(),
1648
- deviceName: z35.string(),
1649
- createdAt: z35.date(),
1650
- lastUsedAt: z35.date()
1651
- });
1652
- var subjectCountSchema = z35.object({
1653
- owner: z35.int().nonnegative(),
1654
- shared: z35.int().nonnegative(),
1655
- self: z35.int().nonnegative()
1954
+ recordedAt: z46.date(),
1955
+ isRemoved: z46.boolean(),
1956
+ isBridge: z46.boolean(),
1957
+ status: z46.enum(["readable", "shredded", "unreadable"]),
1958
+ text: z46.string().nullable()
1959
+ });
1960
+ var itemHistorySchema = z46.object({
1961
+ itemID: z46.string(),
1962
+ subject: z46.enum(["owner", "self", "shared"]),
1963
+ kind: z46.enum(["fact", "self"]),
1964
+ state: z46.enum(["active", "retired", "forgetting", "forgotten"]),
1965
+ versions: z46.array(historyVersionSchema)
1966
+ });
1967
+ var proposalAnswerSchema = z46.strictObject({
1968
+ proposalID: z46.string().min(1),
1969
+ actionHash: z46.string().min(1)
1970
+ });
1971
+ var hostSessionSchema = z46.object({
1972
+ sessionID: z46.string(),
1973
+ deviceName: z46.string(),
1974
+ createdAt: z46.date(),
1975
+ lastUsedAt: z46.date()
1976
+ });
1977
+ var subjectCountSchema = z46.object({
1978
+ owner: z46.int().nonnegative(),
1979
+ shared: z46.int().nonnegative(),
1980
+ self: z46.int().nonnegative()
1656
1981
  });
1657
1982
  var memory = oc6.errors({
1658
1983
  MEMORY_NOT_STARTED: { message: "the memory store has not started yet", status: 503 },
@@ -1667,28 +1992,28 @@ var memory = oc6.errors({
1667
1992
  PIN_EDIT: { message: "a pin takes no edited text", status: 400 },
1668
1993
  SELF_NOTE_REFUSED: { message: "a self-note never takes that change", status: 409 }
1669
1994
  });
1670
- var skillFileSchema = z35.object({ path: z35.string(), text: z35.string() });
1671
- var pendingSkillProposalSchema = z35.object({
1672
- proposalID: z35.string(),
1673
- name: z35.string(),
1674
- skillHash: z35.string(),
1675
- baseHash: z35.string().nullable(),
1676
- files: z35.array(skillFileSchema),
1677
- inForce: z35.object({
1678
- skillHash: z35.string(),
1679
- origin: z35.enum(["definitions", "vendored", "nixie"]),
1680
- files: z35.array(skillFileSchema)
1995
+ var skillFileSchema = z46.object({ path: z46.string(), text: z46.string() });
1996
+ var pendingSkillProposalSchema = z46.object({
1997
+ proposalID: z46.string(),
1998
+ name: z46.string(),
1999
+ skillHash: z46.string(),
2000
+ baseHash: z46.string().nullable(),
2001
+ files: z46.array(skillFileSchema),
2002
+ inForce: z46.object({
2003
+ skillHash: z46.string(),
2004
+ origin: z46.enum(["definitions", "vendored", "nixie"]),
2005
+ files: z46.array(skillFileSchema)
1681
2006
  }).nullable(),
1682
- untypedToken: z35.object({ kind: z35.string(), raw: z35.string() }).nullable(),
1683
- thread: z35.string().nullable(),
1684
- provenance: z35.object({ runID: z35.string(), callID: z35.string(), profile: z35.string() }),
1685
- createdAt: z35.date(),
1686
- lapseAt: z35.date(),
1687
- isStale: z35.boolean()
2007
+ untypedToken: z46.object({ kind: z46.string(), raw: z46.string() }).nullable(),
2008
+ thread: z46.string().nullable(),
2009
+ provenance: z46.object({ runID: z46.string(), callID: z46.string(), profile: z46.string() }),
2010
+ createdAt: z46.date(),
2011
+ lapseAt: z46.date(),
2012
+ isStale: z46.boolean()
1688
2013
  });
1689
- var skillAnswerSchema = z35.strictObject({
1690
- proposalID: z35.string().min(1),
1691
- skillHash: z35.string().min(1)
2014
+ var skillAnswerSchema = z46.strictObject({
2015
+ proposalID: z46.string().min(1),
2016
+ skillHash: z46.string().min(1)
1692
2017
  });
1693
2018
  var skills = oc6.errors({
1694
2019
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
@@ -1698,38 +2023,38 @@ var skills = oc6.errors({
1698
2023
  SKILL_CHECK: { message: "the files fail the seed checks", status: 400 },
1699
2024
  WRONG_STATE: { message: "the skill nixie wrote is no longer in force", status: 409 }
1700
2025
  });
1701
- var definitionsSkillSchema = z35.object({ skillHash: z35.string(), origin: z35.enum(["definitions", "vendored"]) }).nullable();
1702
- var writtenSkillSchema = z35.object({
1703
- approvalID: z35.string(),
1704
- proposalID: z35.string(),
1705
- name: z35.string(),
1706
- skillHash: z35.string(),
2026
+ var definitionsSkillSchema = z46.object({ skillHash: z46.string(), origin: z46.enum(["definitions", "vendored"]) }).nullable();
2027
+ var writtenSkillSchema = z46.object({
2028
+ approvalID: z46.string(),
2029
+ proposalID: z46.string(),
2030
+ name: z46.string(),
2031
+ skillHash: z46.string(),
1707
2032
  base: definitionsSkillSchema,
1708
2033
  definitions: definitionsSkillSchema,
1709
- isConflict: z35.boolean(),
1710
- pullRequestURL: z35.url().nullable(),
1711
- approvedAt: z35.date()
1712
- });
1713
- var promptPartFileSchema = z35.object({ path: z35.string(), text: z35.string() });
1714
- var promptEntrySchema = z35.record(z35.string(), z35.string());
1715
- var pendingPromptProposalSchema = z35.object({
1716
- proposalID: z35.string(),
1717
- promptID: z35.string(),
1718
- proposalHash: z35.string(),
1719
- baseHash: z35.string().nullable(),
2034
+ isConflict: z46.boolean(),
2035
+ pullRequestURL: z46.url().nullable(),
2036
+ approvedAt: z46.date()
2037
+ });
2038
+ var promptPartFileSchema = z46.object({ path: z46.string(), text: z46.string() });
2039
+ var promptEntrySchema = z46.record(z46.string(), z46.string());
2040
+ var pendingPromptProposalSchema = z46.object({
2041
+ proposalID: z46.string(),
2042
+ promptID: z46.string(),
2043
+ proposalHash: z46.string(),
2044
+ baseHash: z46.string().nullable(),
1720
2045
  entry: promptEntrySchema,
1721
- files: z35.array(promptPartFileSchema),
1722
- reason: z35.string(),
1723
- inForce: z35.object({ parts: promptEntrySchema, template: z35.string().nullable() }).nullable(),
1724
- thread: z35.string().nullable(),
1725
- provenance: z35.object({ runID: z35.string(), callID: z35.string(), profile: z35.string() }),
1726
- createdAt: z35.date(),
1727
- lapseAt: z35.date(),
1728
- isStale: z35.boolean()
1729
- });
1730
- var promptAnswerSchema = z35.strictObject({
1731
- proposalID: z35.string().min(1),
1732
- proposalHash: z35.string().min(1)
2046
+ files: z46.array(promptPartFileSchema),
2047
+ reason: z46.string(),
2048
+ inForce: z46.object({ parts: promptEntrySchema, template: z46.string().nullable() }).nullable(),
2049
+ thread: z46.string().nullable(),
2050
+ provenance: z46.object({ runID: z46.string(), callID: z46.string(), profile: z46.string() }),
2051
+ createdAt: z46.date(),
2052
+ lapseAt: z46.date(),
2053
+ isStale: z46.boolean()
2054
+ });
2055
+ var promptAnswerSchema = z46.strictObject({
2056
+ proposalID: z46.string().min(1),
2057
+ proposalHash: z46.string().min(1)
1733
2058
  });
1734
2059
  var prompts = oc6.errors({
1735
2060
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
@@ -1738,59 +2063,63 @@ var prompts = oc6.errors({
1738
2063
  STALE_BASE: { message: "the override in force moved past the proposal", status: 409 },
1739
2064
  PROMPT_CHECK: { message: "the override fails the definitions checks", status: 400 }
1740
2065
  });
1741
- var ruleVersionSchema = z35.object({ ruleHash: z35.string(), sentence: z35.string() }).nullable();
1742
- var ruleInForceSchema = z35.object({
1743
- ruleID: z35.string(),
1744
- revision: z35.int().positive(),
1745
- ruleHash: z35.string(),
1746
- sentence: z35.string(),
1747
- origin: z35.enum(["definitions", "nixie"]),
1748
- changeID: z35.string().nullable(),
1749
- lastFiredAt: z35.date().nullable()
1750
- });
1751
- var ruleConflictSchema = z35.object({
1752
- ruleID: z35.string(),
1753
- changeID: z35.string(),
2066
+ var ruleVersionSchema = z46.object({ ruleHash: z46.string(), sentence: z46.string() }).nullable();
2067
+ var ruleInForceSchema = z46.object({
2068
+ ruleID: z46.string(),
2069
+ revision: z46.int().positive(),
2070
+ ruleHash: z46.string(),
2071
+ sentence: z46.string(),
2072
+ origin: z46.enum(["definitions", "nixie"]),
2073
+ changeID: z46.string().nullable(),
2074
+ lastFiredAt: z46.date().nullable()
2075
+ });
2076
+ var ruleConflictSchema = z46.object({
2077
+ ruleID: z46.string(),
2078
+ changeID: z46.string(),
1754
2079
  nixie: ruleVersionSchema,
1755
2080
  repo: ruleVersionSchema,
1756
2081
  base: ruleVersionSchema,
1757
- changedBy: z35.enum(["owner", "nixie"]),
1758
- reason: z35.string(),
1759
- changedAt: z35.date()
2082
+ changedBy: z46.enum(["owner", "nixie"]),
2083
+ reason: z46.string(),
2084
+ changedAt: z46.date()
1760
2085
  });
1761
- var ruleProposalChangeSchema = z35.object({
1762
- ruleID: z35.string(),
2086
+ var ruleProposalChangeSchema = z46.object({
2087
+ ruleID: z46.string(),
1763
2088
  before: ruleVersionSchema,
1764
2089
  after: ruleVersionSchema
1765
2090
  });
1766
- var effectChangeSchema = z35.object({
1767
- tool: z35.string(),
1768
- remove: z35.array(z35.string()),
1769
- sentence: z35.string()
2091
+ var effectChangeSchema = z46.object({
2092
+ tool: z46.string(),
2093
+ remove: z46.array(z46.string()),
2094
+ sentence: z46.string()
1770
2095
  });
1771
- var pendingRuleProposalSchema = z35.object({
1772
- proposalID: z35.string(),
1773
- changes: z35.array(ruleProposalChangeSchema),
1774
- effectChanges: z35.array(effectChangeSchema),
1775
- createdAt: z35.date(),
1776
- lapseAt: z35.date()
2096
+ var pendingRuleProposalSchema = z46.object({
2097
+ proposalID: z46.string(),
2098
+ changes: z46.array(ruleProposalChangeSchema),
2099
+ effectChanges: z46.array(effectChangeSchema),
2100
+ createdAt: z46.date(),
2101
+ lapseAt: z46.date()
1777
2102
  });
1778
- var ruleProposalAnswerSchema = z35.strictObject({ proposalID: z35.string().min(1) });
2103
+ var ruleProposalAnswerSchema = z46.strictObject({ proposalID: z46.string().min(1) });
1779
2104
  var ruleProposalRejectionSchema = ruleProposalAnswerSchema.extend({
1780
- reason: z35.string().max(500).regex(/\S/u)
2105
+ reason: z46.string().max(500).regex(/\S/u)
1781
2106
  });
1782
2107
  var actionRejectionSchema = ruleProposalAnswerSchema.extend({
1783
- reason: z35.string().max(500).regex(/\S/u).optional()
2108
+ reason: z46.string().max(500).regex(/\S/u).optional()
1784
2109
  });
1785
2110
  var ruleProposalErrors = {
1786
2111
  NOT_FOUND: { message: "nothing has that ID", status: 404 },
1787
2112
  PROPOSAL_CLOSED: { message: "the proposal is answered, withdrawn or lapsed", status: 409 }
1788
2113
  };
1789
2114
  var rules = oc6.errors(ruleProposalErrors);
2115
+ var definitions = oc6.errors({
2116
+ NOT_FOUND: { message: "the definition has no conflict with the repo", status: 404 },
2117
+ DEFINITIONS_NOT_STARTED: { message: "nixie has not started its definitions yet", status: 503 }
2118
+ });
1790
2119
  var contacts = oc6.errors({
1791
2120
  NOT_FOUND: { message: "no known contact has that ID", status: 404 }
1792
2121
  });
1793
- var hostTaskStateSchema = z35.enum([
2122
+ var hostTaskStateSchema = z46.enum([
1794
2123
  "ready",
1795
2124
  "running",
1796
2125
  "waiting",
@@ -1810,29 +2139,29 @@ var taskControl2 = oc6.errors({
1810
2139
  message: "the runner of the task does not take this control",
1811
2140
  status: 409
1812
2141
  }
1813
- }).input(z35.strictObject({ taskID: z35.string().min(1) })).output(z35.object({
1814
- taskID: z35.string(),
2142
+ }).input(z46.strictObject({ taskID: z46.string().min(1) })).output(z46.object({
2143
+ taskID: z46.string(),
1815
2144
  state: hostTaskStateSchema,
1816
- isPauseRequested: z35.boolean()
2145
+ isPauseRequested: z46.boolean()
1817
2146
  }));
1818
2147
  var hostContract = {
1819
- reset: oc6.output(z35.object({
1820
- resetAt: z35.date(),
1821
- lastSequence: z35.int().nonnegative(),
1822
- keptSessions: z35.int().nonnegative()
2148
+ reset: oc6.output(z46.object({
2149
+ resetAt: z46.date(),
2150
+ lastSequence: z46.int().nonnegative(),
2151
+ keptSessions: z46.int().nonnegative()
1823
2152
  })),
1824
- resetConversations: oc6.output(z35.object({
1825
- resetAt: z35.date(),
1826
- lastSequence: z35.int().nonnegative(),
1827
- shreddedRecords: z35.int().nonnegative(),
2153
+ resetConversations: oc6.output(z46.object({
2154
+ resetAt: z46.date(),
2155
+ lastSequence: z46.int().nonnegative(),
2156
+ shreddedRecords: z46.int().nonnegative(),
1828
2157
  backup: forgetBackupSchema
1829
2158
  })),
1830
2159
  nixie: {
1831
- pause: oc6.output(z35.object({ paused: pauseStateSchema })),
1832
- resume: oc6.output(z35.object({ paused: pauseStateSchema }))
2160
+ pause: oc6.output(z46.object({ paused: pauseStateSchema })),
2161
+ resume: oc6.output(z46.object({ paused: pauseStateSchema }))
1833
2162
  },
1834
2163
  recovery: {
1835
- read: oc6.output(z35.object({ recovery: recoverySchema }))
2164
+ read: oc6.output(z46.object({ recovery: recoverySchema }))
1836
2165
  },
1837
2166
  tasks: {
1838
2167
  pause: taskControl2,
@@ -1840,119 +2169,217 @@ var hostContract = {
1840
2169
  stop: taskControl2,
1841
2170
  restart: taskControl2,
1842
2171
  close: taskControl2.errors({
1843
- CONVERSATION_NEVER_CLOSES: { message: "the conversation is never closed", status: 409 }
2172
+ CONVERSATION_NEVER_CLOSES: { message: "the conversation is never closed", status: 409 },
2173
+ DEFINITION_TASK_NEVER_CLOSES: {
2174
+ message: "the task of a definition is never closed",
2175
+ status: 409
2176
+ }
1844
2177
  }),
1845
2178
  interrupt: taskControl2,
1846
2179
  raise: oc6.errors({
1847
2180
  TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
1848
2181
  TASK_NOT_AT_LIMIT: { message: "the task is not paused at its limit", status: 409 },
1849
2182
  LIMIT_NOT_RAISED: { message: "the new limits are not above the old ones", status: 409 }
1850
- }).input(z35.strictObject({
1851
- taskID: z35.string().min(1),
1852
- turns: z35.int().positive().optional(),
1853
- dollars: z35.number().positive().optional()
2183
+ }).input(z46.strictObject({
2184
+ taskID: z46.string().min(1),
2185
+ turns: z46.int().positive().optional(),
2186
+ dollars: z46.number().positive().optional()
1854
2187
  }).refine((input) => input.turns !== undefined || input.dollars !== undefined, {
1855
2188
  message: "a raise sets turns, dollars or both"
1856
- })).output(z35.object({
1857
- taskID: z35.string(),
2189
+ })).output(z46.object({
2190
+ taskID: z46.string(),
1858
2191
  state: hostTaskStateSchema,
1859
- isPauseRequested: z35.boolean(),
1860
- turns: z35.int().positive(),
1861
- dollars: z35.number().positive()
2192
+ isPauseRequested: z46.boolean(),
2193
+ turns: z46.int().positive(),
2194
+ dollars: z46.number().positive()
1862
2195
  }))
1863
2196
  },
1864
2197
  sessions: {
1865
- issueCode: oc6.output(z35.object({ code: z35.string(), expiresAt: z35.date() })),
1866
- list: oc6.output(z35.array(hostSessionSchema)),
2198
+ issueCode: oc6.output(z46.object({ code: z46.string(), expiresAt: z46.date() })),
2199
+ list: oc6.output(z46.array(hostSessionSchema)),
1867
2200
  label: oc6.errors({
1868
2201
  SESSION_NOT_FOUND: {
1869
2202
  message: "no device session that is still signed in has that ID",
1870
2203
  status: 404
1871
2204
  },
1872
2205
  LABEL_INVALID: { message: "a label holds 1 to 100 characters besides spaces", status: 400 }
1873
- }).input(z35.strictObject({ sessionID: z35.string().min(1), label: z35.string() })).output(z35.object({ sessionID: z35.string(), label: z35.string() }))
2206
+ }).input(z46.strictObject({ sessionID: z46.string().min(1), label: z46.string() })).output(z46.object({ sessionID: z46.string(), label: z46.string() }))
1874
2207
  },
1875
2208
  passkeys: hostPasskeyContract,
1876
2209
  memory: {
1877
2210
  proposals: {
1878
- list: memory.output(z35.array(pendingProposalSchema)),
2211
+ list: memory.output(z46.array(pendingProposalSchema)),
1879
2212
  approve: memory.input(proposalAnswerSchema.extend({
1880
2213
  revisionOf: versionTargetSchema2.optional(),
1881
- ignoreCloseMatch: z35.boolean().optional(),
2214
+ ignoreCloseMatch: z46.boolean().optional(),
1882
2215
  editedText: itemTextSchema.optional()
1883
2216
  })).output(approvalResultSchema),
1884
- reject: memory.input(proposalAnswerSchema.extend({ reason: z35.string().max(500).regex(/\S/u).optional() })).output(z35.object({ proposalID: z35.string() }))
2217
+ reject: memory.input(proposalAnswerSchema.extend({ reason: z46.string().max(500).regex(/\S/u).optional() })).output(z46.object({ proposalID: z46.string() }))
1885
2218
  },
1886
- subjects: memory.output(z35.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
2219
+ subjects: memory.output(z46.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
1887
2220
  items: {
1888
- read: memory.input(z35.strictObject({ itemID: z35.string().min(1) })).output(itemHistorySchema),
2221
+ read: memory.input(z46.strictObject({ itemID: z46.string().min(1) })).output(itemHistorySchema),
1889
2222
  edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema })).output(versionRefSchema2),
1890
2223
  retire: memory.input(versionTargetSchema2).output(versionRefSchema2),
1891
2224
  restore: memory.input(versionTargetSchema2).output(versionRefSchema2),
1892
- forget: memory.input(versionTargetSchema2).output(z35.object({ itemID: z35.string(), backup: forgetBackupSchema })),
2225
+ forget: memory.input(versionTargetSchema2).output(z46.object({ itemID: z46.string(), backup: forgetBackupSchema })),
1893
2226
  forgetAll: memory.output(forgottenItemsSchema),
1894
- pin: memory.input(z35.strictObject({ itemID: z35.string().min(1), isPinned: z35.boolean() })).output(z35.object({ itemID: z35.string(), isPinned: z35.boolean() }))
2227
+ pin: memory.input(z46.strictObject({ itemID: z46.string().min(1), isPinned: z46.boolean() })).output(z46.object({ itemID: z46.string(), isPinned: z46.boolean() }))
1895
2228
  }
1896
2229
  },
1897
2230
  skills: {
1898
2231
  proposals: {
1899
- list: skills.output(z35.array(pendingSkillProposalSchema)),
1900
- approve: skills.input(skillAnswerSchema.extend({ files: z35.array(skillFileSchema).min(1).optional() })).output(z35.object({ proposalID: z35.string(), approvalID: z35.string(), skillHash: z35.string() })),
1901
- reject: skills.input(skillAnswerSchema.extend({ reason: z35.string().max(500).regex(/\S/u) })).output(z35.object({ proposalID: z35.string() }))
2232
+ list: skills.output(z46.array(pendingSkillProposalSchema)),
2233
+ approve: skills.input(skillAnswerSchema.extend({ files: z46.array(skillFileSchema).min(1).optional() })).output(z46.object({ proposalID: z46.string(), approvalID: z46.string(), skillHash: z46.string() })),
2234
+ reject: skills.input(skillAnswerSchema.extend({ reason: z46.string().max(500).regex(/\S/u) })).output(z46.object({ proposalID: z46.string() }))
1902
2235
  },
1903
2236
  written: {
1904
- list: skills.output(z35.array(writtenSkillSchema)),
1905
- resolve: skills.input(z35.strictObject({
1906
- approvalID: z35.string().min(1),
1907
- keep: z35.enum(["nixie", "definitions"])
1908
- })).output(z35.object({ approvalID: z35.string(), keep: z35.enum(["nixie", "definitions"]) }))
2237
+ list: skills.output(z46.array(writtenSkillSchema)),
2238
+ resolve: skills.input(z46.strictObject({
2239
+ approvalID: z46.string().min(1),
2240
+ keep: z46.enum(["nixie", "definitions"])
2241
+ })).output(z46.object({ approvalID: z46.string(), keep: z46.enum(["nixie", "definitions"]) }))
1909
2242
  }
1910
2243
  },
1911
2244
  rules: {
1912
- list: rules.output(z35.array(ruleInForceSchema)),
1913
- conflicts: rules.output(z35.array(ruleConflictSchema)),
1914
- resolve: rules.input(z35.strictObject({ ruleID: z35.string().min(1), keep: z35.enum(["nixie", "repo"]) })).output(z35.object({ ruleID: z35.string(), changeID: z35.string(), keep: z35.enum(["nixie", "repo"]) })),
2245
+ list: rules.output(z46.array(ruleInForceSchema)),
2246
+ conflicts: rules.output(z46.array(ruleConflictSchema)),
2247
+ resolve: rules.input(z46.strictObject({ ruleID: z46.string().min(1), keep: z46.enum(["nixie", "repo"]) })).output(z46.object({ ruleID: z46.string(), changeID: z46.string(), keep: z46.enum(["nixie", "repo"]) })),
1915
2248
  proposals: {
1916
- list: rules.output(z35.array(pendingRuleProposalSchema)),
1917
- approve: rules.input(ruleProposalAnswerSchema).output(z35.object({ proposalID: z35.string() })),
1918
- reject: rules.input(ruleProposalRejectionSchema).output(z35.object({ proposalID: z35.string() }))
2249
+ list: rules.output(z46.array(pendingRuleProposalSchema)),
2250
+ approve: rules.input(ruleProposalAnswerSchema).output(z46.object({ proposalID: z46.string() })),
2251
+ reject: rules.input(ruleProposalRejectionSchema).output(z46.object({ proposalID: z46.string() }))
1919
2252
  }
1920
2253
  },
2254
+ definitions: {
2255
+ resolve: definitions.input(z46.strictObject({ definitionID: z46.string().min(1), keep: z46.enum(["nixie", "repo"]) })).output(z46.object({
2256
+ definitionID: z46.string(),
2257
+ changeID: z46.string(),
2258
+ keep: z46.enum(["nixie", "repo"])
2259
+ }))
2260
+ },
1921
2261
  actions: {
1922
2262
  proposals: {
1923
- list: rules.output(z35.array(actionProposalSchema)),
1924
- approve: rules.input(ruleProposalAnswerSchema).output(z35.object({ proposalID: z35.string() })),
1925
- reject: rules.input(actionRejectionSchema).output(z35.object({ proposalID: z35.string() }))
2263
+ list: rules.output(z46.array(actionProposalSchema)),
2264
+ approve: rules.input(ruleProposalAnswerSchema).output(z46.object({ proposalID: z46.string() })),
2265
+ reject: rules.input(actionRejectionSchema).output(z46.object({ proposalID: z46.string() }))
1926
2266
  }
1927
2267
  },
1928
2268
  mandates: hostMandatesContract,
1929
2269
  contacts: {
1930
- list: contacts.output(z35.array(knownContactSchema)),
1931
- markKnown: contacts.input(z35.strictObject({
1932
- destination: z35.string().min(1).max(500),
1933
- name: z35.string().min(1).max(200).optional()
1934
- })).output(z35.object({ contact: knownContactSchema, isNew: z35.boolean() })),
1935
- unmark: contacts.input(z35.strictObject({ contactID: z35.string().min(1) })).output(z35.object({ contactID: z35.string() }))
2270
+ list: contacts.output(z46.array(knownContactSchema)),
2271
+ markKnown: contacts.input(z46.strictObject({
2272
+ destination: z46.string().min(1).max(500),
2273
+ name: z46.string().min(1).max(200).optional()
2274
+ })).output(z46.object({ contact: knownContactSchema, isNew: z46.boolean() })),
2275
+ unmark: contacts.input(z46.strictObject({ contactID: z46.string().min(1) })).output(z46.object({ contactID: z46.string() }))
1936
2276
  },
1937
2277
  turnInputs: turnInputsContract,
1938
2278
  prompts: {
1939
2279
  proposals: {
1940
- list: prompts.output(z35.array(pendingPromptProposalSchema)),
2280
+ list: prompts.output(z46.array(pendingPromptProposalSchema)),
1941
2281
  approve: prompts.input(promptAnswerSchema.extend({
1942
2282
  entry: promptEntrySchema.optional(),
1943
- files: z35.array(promptPartFileSchema).optional()
1944
- })).output(z35.object({ proposalID: z35.string(), approvalID: z35.string(), proposalHash: z35.string() })),
1945
- reject: prompts.input(promptAnswerSchema.extend({ reason: z35.string().max(500).regex(/\S/u) })).output(z35.object({ proposalID: z35.string() }))
2283
+ files: z46.array(promptPartFileSchema).optional()
2284
+ })).output(z46.object({ proposalID: z46.string(), approvalID: z46.string(), proposalHash: z46.string() })),
2285
+ reject: prompts.input(promptAnswerSchema.extend({ reason: z46.string().max(500).regex(/\S/u) })).output(z46.object({ proposalID: z46.string() }))
1946
2286
  }
1947
2287
  }
1948
2288
  };
1949
- // src/contract/is-time-zone.ts
1950
- function isTimeZone(zone) {
1951
- try {
1952
- return new Intl.DateTimeFormat("en-US", { timeZone: zone }).resolvedOptions().timeZone !== "";
1953
- } catch {
1954
- return false;
2289
+ // src/contract/payload-clip-bytes.ts
2290
+ var payloadClipBytes = 4096;
2291
+
2292
+ // src/contract/clip-record-payloads.ts
2293
+ function clipRecordPayloads(record) {
2294
+ const clipped = [];
2295
+ let toolCall = record.toolCall;
2296
+ let worker = record.worker;
2297
+ if (toolCall !== undefined) {
2298
+ const input = clipObjectField(toolCall.input, "toolCall.input", clipped);
2299
+ const content = clipObjectField(toolCall.content, "toolCall.content", clipped);
2300
+ const { input: _input, content: _content, ...rest } = toolCall;
2301
+ toolCall = {
2302
+ ...rest,
2303
+ ...input === undefined ? {} : { input },
2304
+ ...content === undefined ? {} : { content }
2305
+ };
2306
+ }
2307
+ if (worker?.phase === "turn" && worker.text !== undefined) {
2308
+ const cut = cutString(worker.text);
2309
+ if (cut !== null) {
2310
+ clipped.push({ field: "worker.text", path: [], bytes: cut.bytes });
2311
+ worker = { ...worker, text: cut.text };
2312
+ }
1955
2313
  }
2314
+ if (worker?.phase === "ended" && worker.detail !== undefined) {
2315
+ const cut = cutString(worker.detail);
2316
+ if (cut !== null) {
2317
+ clipped.push({ field: "worker.detail", path: [], bytes: cut.bytes });
2318
+ worker = { ...worker, detail: cut.text };
2319
+ }
2320
+ }
2321
+ if (clipped.length === 0) {
2322
+ return record;
2323
+ }
2324
+ return {
2325
+ ...record,
2326
+ clipped,
2327
+ ...toolCall === undefined ? {} : { toolCall },
2328
+ ...worker === undefined ? {} : { worker }
2329
+ };
2330
+ }
2331
+ var maxFieldBytes = 64 * 1024;
2332
+ function clipObjectField(value, field, clipped) {
2333
+ if (value === undefined) {
2334
+ return;
2335
+ }
2336
+ const found = [];
2337
+ const cut = clipValue(value, field, [], found);
2338
+ const size = byteLength(JSON.stringify(cut));
2339
+ if (size > maxFieldBytes) {
2340
+ clipped.push({ field, path: [], bytes: byteLength(JSON.stringify(value)) });
2341
+ return;
2342
+ }
2343
+ clipped.push(...found);
2344
+ return isObject(cut) ? cut : value;
2345
+ }
2346
+ function clipValue(value, field, path, found) {
2347
+ if (typeof value === "string") {
2348
+ const cut = cutString(value);
2349
+ if (cut === null) {
2350
+ return value;
2351
+ }
2352
+ found.push({ field, path, bytes: cut.bytes });
2353
+ return cut.text;
2354
+ }
2355
+ if (Array.isArray(value)) {
2356
+ return value.map((item, index) => clipValue(item, field, [...path, index], found));
2357
+ }
2358
+ if (isObject(value)) {
2359
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
2360
+ key,
2361
+ clipValue(item, field, [...path, key], found)
2362
+ ]));
2363
+ }
2364
+ return value;
2365
+ }
2366
+ var decoder = new TextDecoder;
2367
+ function cutString(text) {
2368
+ const bytes = new TextEncoder().encode(text);
2369
+ if (bytes.length <= payloadClipBytes) {
2370
+ return null;
2371
+ }
2372
+ let end = payloadClipBytes;
2373
+ while (end > 0 && ((bytes[end] ?? 0) & 192) === 128) {
2374
+ end -= 1;
2375
+ }
2376
+ return { text: decoder.decode(bytes.subarray(0, end)), bytes: bytes.length };
2377
+ }
2378
+ function isObject(value) {
2379
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2380
+ }
2381
+ function byteLength(text) {
2382
+ return new TextEncoder().encode(text).length;
1956
2383
  }
1957
2384
  // src/contract/session-cookie-name.ts
1958
2385
  var sessionCookieName = "nixie_session";
@@ -1964,11 +2391,11 @@ function renderSessionCookie(token) {
1964
2391
  return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
1965
2392
  }
1966
2393
  // src/message/task-message-input-schema.ts
1967
- import { z as z37 } from "zod";
2394
+ import { z as z48 } from "zod";
1968
2395
 
1969
2396
  // src/message/task-message-kind-schema.ts
1970
- import { z as z36 } from "zod";
1971
- var taskMessageKindSchema = z36.enum([
2397
+ import { z as z47 } from "zod";
2398
+ var taskMessageKindSchema = z47.enum([
1972
2399
  "progress",
1973
2400
  "question",
1974
2401
  "request",
@@ -1978,37 +2405,46 @@ var taskMessageKindSchema = z36.enum([
1978
2405
  ]);
1979
2406
 
1980
2407
  // src/message/task-message-input-schema.ts
1981
- var taskMessageInputSchema = z37.object({
1982
- to: z37.string(),
2408
+ var taskMessageInputSchema = z48.object({
2409
+ to: z48.string(),
1983
2410
  kind: taskMessageKindSchema,
1984
- body: z37.string(),
1985
- replyTo: z37.string().optional(),
1986
- onBehalfOf: z37.string().array().optional(),
1987
- wake: z37.boolean().optional()
2411
+ body: z48.string(),
2412
+ replyTo: z48.string().optional(),
2413
+ onBehalfOf: z48.string().array().optional(),
2414
+ wake: z48.boolean().optional()
1988
2415
  });
1989
2416
  // src/message/task-message-result-schema.ts
1990
- import { z as z38 } from "zod";
1991
- var taskMessageResultSchema = z38.object({
1992
- messageID: z38.string(),
1993
- woke: z38.boolean(),
1994
- hop: z38.int().nonnegative(),
1995
- note: z38.string().optional()
2417
+ import { z as z49 } from "zod";
2418
+ var taskMessageResultSchema = z49.object({
2419
+ messageID: z49.string(),
2420
+ woke: z49.boolean(),
2421
+ hop: z49.int().nonnegative(),
2422
+ note: z49.string().optional()
1996
2423
  });
1997
2424
  export {
1998
2425
  buildPendingInput,
1999
2426
  buildQueryUtils,
2000
2427
  buildSpanState,
2001
2428
  clientHeaderName,
2429
+ clipRecordPayloads,
2002
2430
  contract,
2003
2431
  forgettableKinds,
2004
2432
  hostContract,
2005
2433
  imageLimits,
2006
2434
  isTimeZone,
2435
+ listedStateSchema,
2436
+ payloadClipBytes,
2007
2437
  pickSpanSource,
2008
2438
  renderSessionCookie,
2439
+ runFireSchema,
2440
+ scheduleSchema,
2009
2441
  sessionCookieName,
2442
+ skipReasonSchema,
2010
2443
  spanSchema,
2011
2444
  taskMessageInputSchema,
2012
2445
  taskMessageKindSchema,
2013
- taskMessageResultSchema
2446
+ taskMessageResultSchema,
2447
+ triggerAtSchema,
2448
+ triggerSchema,
2449
+ workerViewSchema
2014
2450
  };