@heynixie/contract 0.76.0 → 0.78.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/contract/approval-contract.d.ts +0 -4
- package/dist/contract/build-query-utils.d.ts +527 -116
- package/dist/contract/clip-record-payloads.d.ts +2 -0
- package/dist/contract/clipped-payload-schema.d.ts +11 -0
- package/dist/contract/contract.d.ts +758 -139
- package/dist/contract/definition-notice-schema.d.ts +24 -0
- package/dist/contract/definitions-contract.d.ts +72 -0
- package/dist/contract/forgettable-kinds.d.ts +1 -1
- package/dist/contract/host-contract.d.ts +31 -2
- package/dist/contract/listed-task-schema.d.ts +91 -0
- package/dist/contract/memory-view-contract.d.ts +15 -45
- package/dist/contract/payload-clip-bytes.d.ts +1 -0
- package/dist/contract/read-payload-contract.d.ts +29 -0
- package/dist/contract/sequence-schema.d.ts +2 -0
- package/dist/contract/thread-schema.d.ts +2 -0
- package/dist/contract/tool-call-schema.d.ts +1 -0
- package/dist/contract/view-contract.d.ts +209 -0
- package/dist/contract/worker-view-schema.d.ts +37 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1053 -686
- package/package.json +1 -1
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
|
|
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
|
|
824
|
-
var imageRefusedDataSchema =
|
|
825
|
-
position:
|
|
826
|
-
reason:
|
|
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
|
|
958
|
+
import { z as z25 } from "zod";
|
|
836
959
|
|
|
837
960
|
// src/contract/challenge-for-schema.ts
|
|
838
|
-
import { z as
|
|
839
|
-
var challengeForSchema =
|
|
840
|
-
|
|
841
|
-
kind:
|
|
842
|
-
proposalID:
|
|
843
|
-
actionHash:
|
|
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:
|
|
968
|
+
ruleHash: z18.string().optional()
|
|
846
969
|
}),
|
|
847
|
-
|
|
848
|
-
kind:
|
|
849
|
-
actionID:
|
|
850
|
-
choice:
|
|
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
|
-
|
|
853
|
-
|
|
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
|
|
980
|
+
import { z as z22 } from "zod";
|
|
858
981
|
|
|
859
982
|
// src/contract/credential-descriptor-schema.ts
|
|
860
|
-
import { z as
|
|
983
|
+
import { z as z20 } from "zod";
|
|
861
984
|
|
|
862
985
|
// src/contract/transports-schema.ts
|
|
863
|
-
import { z as
|
|
864
|
-
var transportSchema =
|
|
865
|
-
var transportsSchema =
|
|
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 =
|
|
991
|
+
var credentialDescriptorSchema = z20.object({
|
|
869
992
|
id: base64URLSchema,
|
|
870
|
-
type:
|
|
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
|
|
876
|
-
var userVerificationSchema =
|
|
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 =
|
|
880
|
-
var parameterSchema =
|
|
881
|
-
var selectionSchema =
|
|
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:
|
|
1006
|
+
requireResidentKey: z22.boolean(),
|
|
884
1007
|
userVerification: userVerificationSchema
|
|
885
1008
|
});
|
|
886
|
-
var creationOptionsSchema =
|
|
887
|
-
rp:
|
|
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:
|
|
891
|
-
timeout:
|
|
892
|
-
excludeCredentials:
|
|
1013
|
+
pubKeyCredParams: z22.array(parameterSchema),
|
|
1014
|
+
timeout: z22.int().positive(),
|
|
1015
|
+
excludeCredentials: z22.array(credentialDescriptorSchema),
|
|
893
1016
|
authenticatorSelection: selectionSchema,
|
|
894
|
-
attestation:
|
|
1017
|
+
attestation: z22.enum(["none", "indirect", "direct", "enterprise"])
|
|
895
1018
|
});
|
|
896
1019
|
|
|
897
1020
|
// src/contract/registration-response-schema.ts
|
|
898
|
-
import { z as
|
|
899
|
-
var attestationSchema =
|
|
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:
|
|
1027
|
+
publicKeyAlgorithm: z23.int().optional(),
|
|
905
1028
|
publicKey: base64URLSchema.optional()
|
|
906
1029
|
});
|
|
907
|
-
var registrationResponseSchema =
|
|
1030
|
+
var registrationResponseSchema = z23.object({
|
|
908
1031
|
id: base64URLSchema,
|
|
909
1032
|
rawId: base64URLSchema,
|
|
910
1033
|
response: attestationSchema,
|
|
911
|
-
authenticatorAttachment:
|
|
912
|
-
clientExtensionResults:
|
|
913
|
-
type:
|
|
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
|
|
918
|
-
var requestOptionsSchema =
|
|
1040
|
+
import { z as z24 } from "zod";
|
|
1041
|
+
var requestOptionsSchema = z24.object({
|
|
919
1042
|
challenge: base64URLSchema,
|
|
920
|
-
rpId:
|
|
921
|
-
allowCredentials:
|
|
1043
|
+
rpId: z24.string(),
|
|
1044
|
+
allowCredentials: z24.array(credentialDescriptorSchema),
|
|
922
1045
|
userVerification: userVerificationSchema,
|
|
923
|
-
timeout:
|
|
1046
|
+
timeout: z24.int().positive()
|
|
924
1047
|
});
|
|
925
1048
|
|
|
926
1049
|
// src/contract/passkey-contract.ts
|
|
927
|
-
var clientActionIDSchema =
|
|
928
|
-
var listedPasskeySchema =
|
|
929
|
-
passkeyID:
|
|
930
|
-
label:
|
|
931
|
-
synced:
|
|
932
|
-
authorizedBy:
|
|
933
|
-
registeredAt:
|
|
934
|
-
lastUsedAt:
|
|
935
|
-
revokedAt:
|
|
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(
|
|
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(
|
|
952
|
-
code:
|
|
1074
|
+
}).input(z25.object({
|
|
1075
|
+
code: z25.string().min(1).max(100).optional(),
|
|
953
1076
|
passkey: authenticationResponseSchema.optional()
|
|
954
|
-
})).output(
|
|
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:
|
|
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(
|
|
1086
|
+
}).input(z25.object({
|
|
964
1087
|
clientActionID: clientActionIDSchema,
|
|
965
1088
|
response: registrationResponseSchema,
|
|
966
|
-
label:
|
|
967
|
-
})).output(
|
|
968
|
-
list: signedIn.output(
|
|
969
|
-
revoke: signedIn.errors(reusedIDErrors).errors(passkeyFailedError).errors({ NOT_FOUND: { message: "No passkey has this ID", status: 404 } }).input(
|
|
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:
|
|
1094
|
+
passkeyID: z25.string().min(1).max(200),
|
|
972
1095
|
passkey: authenticationResponseSchema
|
|
973
|
-
})).output(
|
|
1096
|
+
})).output(z25.object({ revokedAt: z25.date() }))
|
|
974
1097
|
};
|
|
975
1098
|
|
|
976
1099
|
// src/contract/pause-state-schema.ts
|
|
977
|
-
import { z as
|
|
978
|
-
var pauseCauseSchema =
|
|
979
|
-
var pauseStateSchema =
|
|
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
|
|
983
|
-
var
|
|
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 =
|
|
994
|
-
taskID:
|
|
995
|
-
name:
|
|
996
|
-
stateAtBackup:
|
|
997
|
-
wasRunning:
|
|
998
|
-
pendingActions:
|
|
999
|
-
});
|
|
1000
|
-
var recoverySchema =
|
|
1001
|
-
restoredAt:
|
|
1002
|
-
backupTakenAt:
|
|
1003
|
-
toCheck:
|
|
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
|
|
1008
|
-
var ruleIDSchema =
|
|
1009
|
-
var revisionSchema =
|
|
1010
|
-
var ruleSchema =
|
|
1011
|
-
ruleID:
|
|
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:
|
|
1014
|
-
outcome:
|
|
1015
|
-
destinations:
|
|
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:
|
|
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:
|
|
1179
|
+
data: z30.object({ reason: z30.enum(["widens", "empty", "mandate"]) })
|
|
1029
1180
|
}
|
|
1030
1181
|
});
|
|
1031
|
-
var currentHashSchema =
|
|
1032
|
-
var closedStateSchema =
|
|
1033
|
-
state:
|
|
1034
|
-
});
|
|
1035
|
-
var proposalIDSchema =
|
|
1036
|
-
var ruleFormSchema =
|
|
1037
|
-
var mandateRuleSchema =
|
|
1038
|
-
var mandateSchema =
|
|
1039
|
-
mandateID:
|
|
1040
|
-
title:
|
|
1041
|
-
rules:
|
|
1042
|
-
startedAt:
|
|
1043
|
-
expires:
|
|
1044
|
-
});
|
|
1045
|
-
var faultsSchema =
|
|
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 =
|
|
1204
|
+
var destinationsSchema = z30.array(z30.string().regex(/^\S+$/u)).max(100);
|
|
1054
1205
|
var ruleContract = {
|
|
1055
|
-
readRule: signedIn.errors(notFound).input(
|
|
1056
|
-
removeRule: ruleChange.input(
|
|
1057
|
-
editRule: ruleChange.input(
|
|
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:
|
|
1062
|
-
})).output(
|
|
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,194 +1224,331 @@ var ruleContract = {
|
|
|
1073
1224
|
status: 409,
|
|
1074
1225
|
data: closedStateSchema
|
|
1075
1226
|
}
|
|
1076
|
-
}).input(
|
|
1227
|
+
}).input(z30.object({
|
|
1077
1228
|
proposalID: proposalIDSchema,
|
|
1078
|
-
actionHash:
|
|
1229
|
+
actionHash: z30.string(),
|
|
1079
1230
|
rule: ruleFormSchema,
|
|
1080
|
-
clientActionID:
|
|
1081
|
-
})).output(
|
|
1082
|
-
proposeMandate: signedIn.errors(reusedIDErrors).errors(invalid).input(
|
|
1083
|
-
title:
|
|
1084
|
-
rules:
|
|
1085
|
-
expires:
|
|
1086
|
-
clientActionID:
|
|
1087
|
-
})).output(
|
|
1088
|
-
listMandates: signedIn.output(
|
|
1089
|
-
endMandate: signedIn.errors(reusedIDErrors).errors({ NOT_FOUND: { message: "No mandate has this ID", status: 404 } }).input(
|
|
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
|
|
1094
|
-
var taskSchema2 =
|
|
1095
|
-
error:
|
|
1096
|
-
errorLimit:
|
|
1097
|
-
errors:
|
|
1098
|
-
isWaitingForRetry:
|
|
1099
|
-
readCursor:
|
|
1100
|
-
reason:
|
|
1101
|
-
retryAt:
|
|
1102
|
-
stepKey:
|
|
1103
|
-
taskID:
|
|
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
|
|
1108
|
-
var
|
|
1109
|
-
var toolCallSchema =
|
|
1110
|
-
callID:
|
|
1111
|
-
content:
|
|
1112
|
-
input:
|
|
1113
|
-
outcome:
|
|
1114
|
-
|
|
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
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
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
|
-
|
|
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
|
|
1129
|
-
|
|
1130
|
-
|
|
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
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
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
|
|
1139
|
-
|
|
1140
|
-
|
|
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
|
|
1144
|
-
var
|
|
1145
|
-
var
|
|
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:
|
|
1468
|
+
trigger: z37.enum(["manual", "auto"])
|
|
1149
1469
|
});
|
|
1150
|
-
var summarySchema =
|
|
1470
|
+
var summarySchema = z37.object({
|
|
1151
1471
|
contextSize: tokenCountSchema.optional(),
|
|
1152
1472
|
summaryTokens: tokenCountSchema,
|
|
1153
|
-
text:
|
|
1154
|
-
trigger:
|
|
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:
|
|
1167
|
-
text:
|
|
1478
|
+
status: z37.enum(["readable", "shredded", "unreadable", "missing"]),
|
|
1479
|
+
text: z37.string().optional()
|
|
1168
1480
|
});
|
|
1169
|
-
var listedActionSchema =
|
|
1170
|
-
var taskMessageSchema =
|
|
1481
|
+
var listedActionSchema = z37.object({ actionID: z37.string(), tool: z37.string() });
|
|
1482
|
+
var taskMessageSchema = z37.object({
|
|
1171
1483
|
from: threadSchema,
|
|
1172
|
-
fromName:
|
|
1173
|
-
hop:
|
|
1174
|
-
kind:
|
|
1175
|
-
messageID:
|
|
1176
|
-
replyTo:
|
|
1177
|
-
text:
|
|
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:
|
|
1491
|
+
woke: z37.boolean()
|
|
1180
1492
|
});
|
|
1181
|
-
var exchangeNoticeSchema =
|
|
1182
|
-
link:
|
|
1183
|
-
text:
|
|
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
|
|
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:
|
|
1508
|
+
forget: z37.object({ sequence: sequenceSchema }).optional(),
|
|
1190
1509
|
context: contextSchema.optional(),
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
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:
|
|
1201
|
-
|
|
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:
|
|
1205
|
-
removal:
|
|
1523
|
+
recordedAt: z37.date(),
|
|
1524
|
+
removal: z37.object({ kind: z37.string(), sequence: sequenceSchema, callSequence: sequenceSchema.optional() }).optional(),
|
|
1206
1525
|
sequence: sequenceSchema,
|
|
1207
|
-
stop:
|
|
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 =
|
|
1215
|
-
var sessionSchema =
|
|
1216
|
-
createdAt:
|
|
1217
|
-
current:
|
|
1218
|
-
deviceName:
|
|
1219
|
-
lastUsedAt:
|
|
1220
|
-
sessionID:
|
|
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
|
|
1224
|
-
|
|
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:
|
|
1239
|
-
});
|
|
1240
|
-
var listedTaskSchema = z26.object({
|
|
1241
|
-
actions: z26.object({
|
|
1242
|
-
cancelled: actionCountSchema,
|
|
1243
|
-
queued: actionCountSchema,
|
|
1244
|
-
started: actionCountSchema
|
|
1245
|
-
}),
|
|
1246
|
-
brief: z26.string(),
|
|
1247
|
-
closedBy: z26.enum(["owner", "nixie", "disposable"]).optional(),
|
|
1248
|
-
controls: z26.array(taskControlSchema),
|
|
1249
|
-
disposable: z26.boolean().nullable(),
|
|
1250
|
-
isPauseRequested: z26.boolean(),
|
|
1251
|
-
isPausedByNixie: z26.boolean(),
|
|
1252
|
-
isTakingMessages: z26.boolean(),
|
|
1253
|
-
lastActivityAt: z26.date(),
|
|
1254
|
-
name: z26.string(),
|
|
1255
|
-
runner: z26.string(),
|
|
1256
|
-
state: taskStateSchema2,
|
|
1257
|
-
taskID: threadSchema,
|
|
1258
|
-
waitingOn: threadSchema.optional()
|
|
1546
|
+
memoryItems: z37.array(forgetPreviewItemSchema)
|
|
1259
1547
|
});
|
|
1260
|
-
var controlledTaskSchema =
|
|
1261
|
-
controlledAt:
|
|
1262
|
-
isPauseRequested:
|
|
1263
|
-
state:
|
|
1548
|
+
var controlledTaskSchema = z37.object({
|
|
1549
|
+
controlledAt: z37.date(),
|
|
1550
|
+
isPauseRequested: z37.boolean(),
|
|
1551
|
+
state: taskStateSchema,
|
|
1264
1552
|
taskID: threadSchema
|
|
1265
1553
|
});
|
|
1266
1554
|
var taskControl = checkedAction.errors({
|
|
@@ -1268,62 +1556,67 @@ var taskControl = checkedAction.errors({
|
|
|
1268
1556
|
TASK_STATE_REFUSED: {
|
|
1269
1557
|
message: "The task is in a state that does not take this control",
|
|
1270
1558
|
status: 409,
|
|
1271
|
-
data:
|
|
1559
|
+
data: z37.object({ isPauseRequested: z37.boolean(), state: taskStateSchema })
|
|
1272
1560
|
},
|
|
1273
1561
|
RUNNER_LACKS_CONTROL: {
|
|
1274
1562
|
message: "The runner of the task does not take this control",
|
|
1275
1563
|
status: 409
|
|
1276
1564
|
}
|
|
1277
|
-
}).input(
|
|
1278
|
-
var markedTaskSchema =
|
|
1279
|
-
changedAt:
|
|
1280
|
-
disposable:
|
|
1565
|
+
}).input(z37.object({ clientActionID: clientActionIDSchema2, taskID: threadSchema })).output(controlledTaskSchema);
|
|
1566
|
+
var markedTaskSchema = z37.object({
|
|
1567
|
+
changedAt: z37.date(),
|
|
1568
|
+
disposable: z37.boolean(),
|
|
1281
1569
|
taskID: threadSchema
|
|
1282
1570
|
});
|
|
1283
|
-
var nixieControl = checkedAction.input(
|
|
1284
|
-
var backupNoticeSchema =
|
|
1285
|
-
cause:
|
|
1286
|
-
sequence:
|
|
1287
|
-
raisedAt:
|
|
1288
|
-
});
|
|
1289
|
-
var followRecords = signedIn.input(
|
|
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 })));
|
|
1290
1582
|
var contract = {
|
|
1291
1583
|
conversation: {
|
|
1292
|
-
read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(
|
|
1584
|
+
read: signedIn.errors({ THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 } }).input(z37.object({
|
|
1293
1585
|
beforeSequence: sequenceSchema.optional(),
|
|
1294
|
-
|
|
1586
|
+
clipPayloads: z37.boolean().optional(),
|
|
1587
|
+
limit: z37.int().min(1).max(200).optional(),
|
|
1295
1588
|
thread: threadSchema
|
|
1296
|
-
})).output(
|
|
1297
|
-
hasEarlier:
|
|
1589
|
+
})).output(z37.object({
|
|
1590
|
+
hasEarlier: z37.boolean(),
|
|
1298
1591
|
readAtSequence: sequenceSchema,
|
|
1299
|
-
records:
|
|
1592
|
+
records: z37.array(recordSchema),
|
|
1300
1593
|
lastStepEnd: recordSchema.nullable().optional()
|
|
1301
1594
|
})),
|
|
1302
1595
|
send: checkedAction.errors({
|
|
1303
1596
|
IMAGE_REFUSED: imageRefusedError,
|
|
1304
1597
|
THREAD_NOT_FOUND: { message: "No thread has this ID", status: 404 }
|
|
1305
|
-
}).input(
|
|
1598
|
+
}).input(z37.object({
|
|
1306
1599
|
clientMessageId: clientActionIDSchema2,
|
|
1307
1600
|
images: imageFilesSchema.optional(),
|
|
1308
|
-
spans:
|
|
1309
|
-
text:
|
|
1601
|
+
spans: z37.array(spanSchema).max(1e5),
|
|
1602
|
+
text: z37.string().min(1).max(1e5),
|
|
1310
1603
|
thread: threadSchema,
|
|
1311
|
-
timeZone:
|
|
1312
|
-
writtenAt:
|
|
1313
|
-
})).output(
|
|
1604
|
+
timeZone: z37.string().min(1).max(100).optional(),
|
|
1605
|
+
writtenAt: z37.iso.datetime().optional()
|
|
1606
|
+
})).output(z37.object({ duplicate: z37.boolean(), sequence: sequenceSchema })),
|
|
1314
1607
|
retry: checkedAction.errors({
|
|
1315
1608
|
NOTHING_TO_RETRY: {
|
|
1316
1609
|
message: "The last turn of the conversation did not fail, or it runs again already",
|
|
1317
1610
|
status: 409
|
|
1318
1611
|
}
|
|
1319
|
-
}).input(
|
|
1320
|
-
readImage: signedIn.errors({ IMAGE_NOT_FOUND: imageNotFoundError }).input(imageRefSchema).output(
|
|
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()),
|
|
1321
1614
|
previewForget: signedIn.errors({
|
|
1322
1615
|
RECORD_NOT_FOUND: {
|
|
1323
1616
|
message: "No record on this thread with its own text that a forget removes has this sequence",
|
|
1324
1617
|
status: 404
|
|
1325
1618
|
}
|
|
1326
|
-
}).input(
|
|
1619
|
+
}).input(z37.object({ thread: threadSchema, sequence: sequenceSchema })).output(recordForgetPreviewSchema),
|
|
1327
1620
|
forget: checkedAction.errors({
|
|
1328
1621
|
RECORD_NOT_FOUND: {
|
|
1329
1622
|
message: "No record on this thread with its own text that a forget removes has this sequence",
|
|
@@ -1333,25 +1626,34 @@ var contract = {
|
|
|
1333
1626
|
message: "The queued action has not run yet. Cancel it, or wait for it to run.",
|
|
1334
1627
|
status: 409
|
|
1335
1628
|
}
|
|
1336
|
-
}).input(
|
|
1629
|
+
}).input(z37.object({
|
|
1337
1630
|
clientActionID: clientActionIDSchema2,
|
|
1338
1631
|
sequence: sequenceSchema,
|
|
1339
1632
|
thread: threadSchema
|
|
1340
|
-
})).output(
|
|
1633
|
+
})).output(z37.object({ forgottenAt: z37.date(), backup: forgetBackupSchema }))
|
|
1341
1634
|
},
|
|
1342
1635
|
tasks: {
|
|
1343
|
-
list: signedIn.
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
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)
|
|
1348
1646
|
})),
|
|
1349
1647
|
pause: taskControl,
|
|
1350
1648
|
resume: taskControl,
|
|
1351
1649
|
stop: taskControl,
|
|
1352
1650
|
restart: taskControl,
|
|
1353
1651
|
close: taskControl.errors({
|
|
1354
|
-
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
|
+
}
|
|
1355
1657
|
}),
|
|
1356
1658
|
interrupt: taskControl,
|
|
1357
1659
|
setDisposable: checkedAction.errors({
|
|
@@ -1360,40 +1662,42 @@ var contract = {
|
|
|
1360
1662
|
TASK_STATE_REFUSED: {
|
|
1361
1663
|
message: "The task is in a state that does not take this change",
|
|
1362
1664
|
status: 409,
|
|
1363
|
-
data:
|
|
1665
|
+
data: z37.object({ state: taskStateSchema })
|
|
1364
1666
|
}
|
|
1365
|
-
}).input(
|
|
1667
|
+
}).input(z37.object({
|
|
1366
1668
|
clientActionID: clientActionIDSchema2,
|
|
1367
|
-
disposable:
|
|
1669
|
+
disposable: z37.boolean(),
|
|
1368
1670
|
taskID: threadSchema
|
|
1369
|
-
})).output(markedTaskSchema)
|
|
1671
|
+
})).output(markedTaskSchema),
|
|
1672
|
+
...viewContract.tasks
|
|
1370
1673
|
},
|
|
1371
1674
|
memory: {
|
|
1372
|
-
readVersions: signedIn.input(
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
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(),
|
|
1378
1680
|
cursor: sequenceSchema,
|
|
1379
|
-
failures:
|
|
1380
|
-
isCatchingUp:
|
|
1681
|
+
failures: z37.int().nonnegative(),
|
|
1682
|
+
isCatchingUp: z37.boolean(),
|
|
1381
1683
|
lastError: writerErrorSchema,
|
|
1382
|
-
retryAt:
|
|
1684
|
+
retryAt: z37.date().nullable()
|
|
1383
1685
|
})),
|
|
1384
1686
|
...memoryViewContract
|
|
1385
1687
|
},
|
|
1386
1688
|
nixie: {
|
|
1387
|
-
read: signedIn.output(
|
|
1689
|
+
read: signedIn.output(z37.object({ paused: pauseStateSchema })),
|
|
1388
1690
|
pause: nixieControl,
|
|
1389
1691
|
resume: nixieControl
|
|
1390
1692
|
},
|
|
1391
1693
|
recovery: {
|
|
1392
|
-
read: signedIn.output(
|
|
1694
|
+
read: signedIn.output(z37.object({ recovery: recoverySchema }))
|
|
1393
1695
|
},
|
|
1394
1696
|
backups: {
|
|
1395
|
-
readNotice: signedIn.output(
|
|
1697
|
+
readNotice: signedIn.output(z37.object({ notice: backupNoticeSchema.nullable() }))
|
|
1396
1698
|
},
|
|
1699
|
+
triggers: viewContract.triggers,
|
|
1700
|
+
definitions: { ...viewContract.definitions, ...definitionsContract },
|
|
1397
1701
|
rules: ruleContract,
|
|
1398
1702
|
approvals: approvalContract,
|
|
1399
1703
|
passkeys: passkeyContract,
|
|
@@ -1401,7 +1705,8 @@ var contract = {
|
|
|
1401
1705
|
follow: followRecords.route({ deprecated: true })
|
|
1402
1706
|
},
|
|
1403
1707
|
records: {
|
|
1404
|
-
follow: followRecords
|
|
1708
|
+
follow: followRecords,
|
|
1709
|
+
readPayload: readPayloadContract
|
|
1405
1710
|
},
|
|
1406
1711
|
sessions: {
|
|
1407
1712
|
enrol: oc2.errors(reusedIDErrors).errors({
|
|
@@ -1409,28 +1714,28 @@ var contract = {
|
|
|
1409
1714
|
message: "The enrolment code is unknown, used or lapsed",
|
|
1410
1715
|
status: 400
|
|
1411
1716
|
}
|
|
1412
|
-
}).input(
|
|
1717
|
+
}).input(z37.object({
|
|
1413
1718
|
clientActionID: clientActionIDSchema2,
|
|
1414
|
-
code:
|
|
1415
|
-
deviceName:
|
|
1416
|
-
tokenDelivery:
|
|
1417
|
-
})).output(
|
|
1418
|
-
issueCode: checkedAction.input(
|
|
1419
|
-
list: signedIn.output(
|
|
1420
|
-
revoke: checkedAction.errors({ SESSION_NOT_FOUND: { message: "No session has this ID", status: 404 } }).input(
|
|
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() }))
|
|
1421
1726
|
}
|
|
1422
1727
|
};
|
|
1423
1728
|
// src/contract/host-contract.ts
|
|
1424
1729
|
import { oc as oc6 } from "@orpc/contract";
|
|
1425
|
-
import { z as
|
|
1730
|
+
import { z as z46 } from "zod";
|
|
1426
1731
|
|
|
1427
1732
|
// src/contract/action-proposal-schema.ts
|
|
1428
|
-
import { z as
|
|
1429
|
-
var actionProposalSchema =
|
|
1430
|
-
proposalID:
|
|
1431
|
-
tool:
|
|
1432
|
-
effects:
|
|
1433
|
-
cause:
|
|
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([
|
|
1434
1739
|
"outside_steering",
|
|
1435
1740
|
"always_ask",
|
|
1436
1741
|
"ask_rule",
|
|
@@ -1438,81 +1743,81 @@ var actionProposalSchema = z27.object({
|
|
|
1438
1743
|
"direct_request",
|
|
1439
1744
|
"repeat"
|
|
1440
1745
|
]),
|
|
1441
|
-
sentence:
|
|
1442
|
-
destinations:
|
|
1443
|
-
createdAt:
|
|
1444
|
-
lapseAt:
|
|
1746
|
+
sentence: z38.string(),
|
|
1747
|
+
destinations: z38.array(z38.string()),
|
|
1748
|
+
createdAt: z38.date(),
|
|
1749
|
+
lapseAt: z38.date()
|
|
1445
1750
|
});
|
|
1446
1751
|
|
|
1447
1752
|
// src/contract/forgotten-items-schema.ts
|
|
1448
|
-
import { z as
|
|
1449
|
-
var forgottenItemsSchema =
|
|
1450
|
-
itemIDs:
|
|
1753
|
+
import { z as z39 } from "zod";
|
|
1754
|
+
var forgottenItemsSchema = z39.object({
|
|
1755
|
+
itemIDs: z39.array(z39.string()),
|
|
1451
1756
|
backup: forgetBackupSchema
|
|
1452
1757
|
});
|
|
1453
1758
|
|
|
1454
1759
|
// src/contract/host-mandates-contract.ts
|
|
1455
1760
|
import { oc as oc3 } from "@orpc/contract";
|
|
1456
|
-
import { z as
|
|
1761
|
+
import { z as z40 } from "zod";
|
|
1457
1762
|
var mandates = oc3.errors({
|
|
1458
1763
|
NOT_FOUND: { message: "no mandate has that ID", status: 404 }
|
|
1459
1764
|
});
|
|
1460
|
-
var hostMandateRuleSchema =
|
|
1461
|
-
var hostMandateSchema =
|
|
1462
|
-
mandateID:
|
|
1463
|
-
title:
|
|
1464
|
-
rules:
|
|
1465
|
-
startedAt:
|
|
1466
|
-
expires:
|
|
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()
|
|
1467
1772
|
});
|
|
1468
1773
|
var hostMandatesContract = {
|
|
1469
|
-
list: mandates.output(
|
|
1470
|
-
end: mandates.input(
|
|
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"]) }))
|
|
1471
1776
|
};
|
|
1472
1777
|
|
|
1473
1778
|
// src/contract/host-passkey-contract.ts
|
|
1474
1779
|
import { oc as oc4 } from "@orpc/contract";
|
|
1475
|
-
import { z as
|
|
1476
|
-
var hostPasskeySchema =
|
|
1477
|
-
passkeyID:
|
|
1478
|
-
label:
|
|
1479
|
-
synced:
|
|
1480
|
-
origin:
|
|
1481
|
-
registeredBy:
|
|
1482
|
-
authorizedBy:
|
|
1483
|
-
registeredAt:
|
|
1484
|
-
lastUsedAt:
|
|
1485
|
-
revokedAt:
|
|
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()
|
|
1486
1791
|
});
|
|
1487
1792
|
var hostPasskeyContract = {
|
|
1488
|
-
issueCode: oc4.output(
|
|
1489
|
-
list: oc4.output(
|
|
1793
|
+
issueCode: oc4.output(z41.object({ code: z41.string(), expiresAt: z41.date() })),
|
|
1794
|
+
list: oc4.output(z41.array(hostPasskeySchema)),
|
|
1490
1795
|
revoke: oc4.errors({
|
|
1491
1796
|
PASSKEY_NOT_FOUND: { message: "no passkey has that ID", status: 404 }
|
|
1492
|
-
}).input(
|
|
1797
|
+
}).input(z41.strictObject({ passkeyID: z41.string().min(1) })).output(z41.object({ passkeyID: z41.string(), revokedAt: z41.date() }))
|
|
1493
1798
|
};
|
|
1494
1799
|
|
|
1495
1800
|
// src/contract/known-contact-schema.ts
|
|
1496
|
-
import { z as
|
|
1497
|
-
var knownContactSchema =
|
|
1498
|
-
contactID:
|
|
1499
|
-
name:
|
|
1500
|
-
destination:
|
|
1501
|
-
markedAt:
|
|
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()
|
|
1502
1807
|
});
|
|
1503
1808
|
|
|
1504
1809
|
// src/contract/turn-inputs-contract.ts
|
|
1505
1810
|
import { oc as oc5 } from "@orpc/contract";
|
|
1506
|
-
import { z as
|
|
1811
|
+
import { z as z45 } from "zod";
|
|
1507
1812
|
|
|
1508
1813
|
// src/contract/input-miss-schema.ts
|
|
1509
|
-
import { z as
|
|
1510
|
-
var inputMissSchema =
|
|
1511
|
-
missID:
|
|
1512
|
-
captureID:
|
|
1513
|
-
taskID:
|
|
1514
|
-
stepRunID:
|
|
1515
|
-
reason:
|
|
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([
|
|
1516
1821
|
"queue_full",
|
|
1517
1822
|
"spool_full",
|
|
1518
1823
|
"spool_write_failed",
|
|
@@ -1524,45 +1829,45 @@ var inputMissSchema = z32.object({
|
|
|
1524
1829
|
"intake_failed",
|
|
1525
1830
|
"holds_own_value"
|
|
1526
1831
|
]),
|
|
1527
|
-
count:
|
|
1528
|
-
writer:
|
|
1529
|
-
counter:
|
|
1530
|
-
createdAt:
|
|
1832
|
+
count: z43.int().positive(),
|
|
1833
|
+
writer: z43.string().nullable(),
|
|
1834
|
+
counter: z43.int().nullable(),
|
|
1835
|
+
createdAt: z43.date()
|
|
1531
1836
|
});
|
|
1532
1837
|
|
|
1533
1838
|
// src/contract/logged-input-schema.ts
|
|
1534
|
-
import { z as
|
|
1535
|
-
var loggedInputSchema =
|
|
1536
|
-
inputID:
|
|
1537
|
-
captureID:
|
|
1538
|
-
taskID:
|
|
1539
|
-
stepRunID:
|
|
1540
|
-
writer:
|
|
1541
|
-
counter:
|
|
1542
|
-
role:
|
|
1543
|
-
profile:
|
|
1544
|
-
model:
|
|
1545
|
-
harness:
|
|
1546
|
-
api:
|
|
1547
|
-
endpoint:
|
|
1548
|
-
route:
|
|
1549
|
-
isRewritten:
|
|
1550
|
-
upstreamStatus:
|
|
1551
|
-
bytes:
|
|
1552
|
-
intakeSequence:
|
|
1553
|
-
receivedAt:
|
|
1554
|
-
takenAt:
|
|
1555
|
-
state:
|
|
1556
|
-
removedCause:
|
|
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()
|
|
1557
1862
|
});
|
|
1558
1863
|
|
|
1559
1864
|
// src/contract/turn-inputs-contract.ts
|
|
1560
|
-
var turnInputOn =
|
|
1561
|
-
state:
|
|
1562
|
-
forMs:
|
|
1865
|
+
var turnInputOn = z45.strictObject({
|
|
1866
|
+
state: z45.literal("on"),
|
|
1867
|
+
forMs: z45.int().positive().nullable()
|
|
1563
1868
|
});
|
|
1564
|
-
var turnInputOff =
|
|
1565
|
-
var turnInputSetSchema =
|
|
1869
|
+
var turnInputOff = z45.strictObject({ state: z45.literal("off"), drop: z45.boolean() });
|
|
1870
|
+
var turnInputSetSchema = z45.discriminatedUnion("state", [turnInputOn, turnInputOff]);
|
|
1566
1871
|
var turnInputs = oc5.errors({
|
|
1567
1872
|
NOT_FOUND: { message: "no logged request has that ID", status: 404 },
|
|
1568
1873
|
REMOVED: { message: "that request is removed or its body is missing", status: 410 },
|
|
@@ -1572,27 +1877,27 @@ var turnInputs = oc5.errors({
|
|
|
1572
1877
|
},
|
|
1573
1878
|
NOT_CONFIGURED: { message: "the turn-input log is not configured", status: 409 }
|
|
1574
1879
|
});
|
|
1575
|
-
var listedInputsSchema =
|
|
1576
|
-
inputs:
|
|
1577
|
-
misses:
|
|
1880
|
+
var listedInputsSchema = z45.object({
|
|
1881
|
+
inputs: z45.array(loggedInputSchema),
|
|
1882
|
+
misses: z45.array(inputMissSchema)
|
|
1578
1883
|
});
|
|
1579
1884
|
var turnInputsContract = {
|
|
1580
|
-
list: turnInputs.input(
|
|
1581
|
-
open: turnInputs.input(
|
|
1582
|
-
set: turnInputs.input(turnInputSetSchema).output(
|
|
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() }))
|
|
1583
1888
|
};
|
|
1584
1889
|
|
|
1585
1890
|
// src/contract/host-contract.ts
|
|
1586
|
-
var versionRefSchema2 =
|
|
1587
|
-
var versionTargetSchema2 =
|
|
1588
|
-
itemID:
|
|
1589
|
-
version:
|
|
1590
|
-
});
|
|
1591
|
-
var itemTextSchema =
|
|
1592
|
-
var proposalOriginSchema2 =
|
|
1593
|
-
var memoryOriginSchema =
|
|
1594
|
-
var contentSourceSchema =
|
|
1595
|
-
var reviewReasonSchema2 =
|
|
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([
|
|
1596
1901
|
"no_quote",
|
|
1597
1902
|
"quote_not_typed",
|
|
1598
1903
|
"quote_in_quoted_block",
|
|
@@ -1607,72 +1912,72 @@ var reviewReasonSchema2 = z35.enum([
|
|
|
1607
1912
|
"other",
|
|
1608
1913
|
"self_note",
|
|
1609
1914
|
"from_photo",
|
|
1610
|
-
"sensitive",
|
|
1611
1915
|
"subject_change",
|
|
1612
1916
|
"labels",
|
|
1613
1917
|
"ask_rule"
|
|
1614
1918
|
]);
|
|
1615
|
-
var proposalSourceSchema2 =
|
|
1919
|
+
var proposalSourceSchema2 = z46.object({
|
|
1616
1920
|
origin: proposalOriginSchema2,
|
|
1617
|
-
thread:
|
|
1618
|
-
proposedAt:
|
|
1619
|
-
});
|
|
1620
|
-
var pendingProposalSchema =
|
|
1621
|
-
proposalID:
|
|
1622
|
-
operation:
|
|
1623
|
-
itemID:
|
|
1624
|
-
targetVersion:
|
|
1625
|
-
isPinned:
|
|
1626
|
-
subject:
|
|
1627
|
-
newSubject:
|
|
1628
|
-
|
|
1629
|
-
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"]),
|
|
1630
1933
|
reason: reviewReasonSchema2,
|
|
1631
|
-
actionHash:
|
|
1934
|
+
actionHash: z46.string(),
|
|
1632
1935
|
origin: proposalOriginSchema2,
|
|
1633
1936
|
source: contentSourceSchema,
|
|
1634
|
-
createdAt:
|
|
1635
|
-
lapseAt:
|
|
1636
|
-
sources:
|
|
1637
|
-
text:
|
|
1638
|
-
quote:
|
|
1639
|
-
});
|
|
1640
|
-
var closeMatchSchema2 =
|
|
1641
|
-
var approvalResultSchema =
|
|
1642
|
-
|
|
1643
|
-
|
|
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 })
|
|
1644
1947
|
]);
|
|
1645
|
-
var historyVersionSchema =
|
|
1646
|
-
version:
|
|
1647
|
-
change:
|
|
1648
|
-
state:
|
|
1948
|
+
var historyVersionSchema = z46.object({
|
|
1949
|
+
version: z46.int(),
|
|
1950
|
+
change: z46.enum(["created", "edited", "retired", "restored", "undone"]),
|
|
1951
|
+
state: z46.enum(["active", "retired"]),
|
|
1649
1952
|
origin: memoryOriginSchema,
|
|
1650
1953
|
source: contentSourceSchema,
|
|
1651
|
-
recordedAt:
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
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()
|
|
1676
1981
|
});
|
|
1677
1982
|
var memory = oc6.errors({
|
|
1678
1983
|
MEMORY_NOT_STARTED: { message: "the memory store has not started yet", status: 503 },
|
|
@@ -1687,28 +1992,28 @@ var memory = oc6.errors({
|
|
|
1687
1992
|
PIN_EDIT: { message: "a pin takes no edited text", status: 400 },
|
|
1688
1993
|
SELF_NOTE_REFUSED: { message: "a self-note never takes that change", status: 409 }
|
|
1689
1994
|
});
|
|
1690
|
-
var skillFileSchema =
|
|
1691
|
-
var pendingSkillProposalSchema =
|
|
1692
|
-
proposalID:
|
|
1693
|
-
name:
|
|
1694
|
-
skillHash:
|
|
1695
|
-
baseHash:
|
|
1696
|
-
files:
|
|
1697
|
-
inForce:
|
|
1698
|
-
skillHash:
|
|
1699
|
-
origin:
|
|
1700
|
-
files:
|
|
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)
|
|
1701
2006
|
}).nullable(),
|
|
1702
|
-
untypedToken:
|
|
1703
|
-
thread:
|
|
1704
|
-
provenance:
|
|
1705
|
-
createdAt:
|
|
1706
|
-
lapseAt:
|
|
1707
|
-
isStale:
|
|
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()
|
|
1708
2013
|
});
|
|
1709
|
-
var skillAnswerSchema =
|
|
1710
|
-
proposalID:
|
|
1711
|
-
skillHash:
|
|
2014
|
+
var skillAnswerSchema = z46.strictObject({
|
|
2015
|
+
proposalID: z46.string().min(1),
|
|
2016
|
+
skillHash: z46.string().min(1)
|
|
1712
2017
|
});
|
|
1713
2018
|
var skills = oc6.errors({
|
|
1714
2019
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
@@ -1718,38 +2023,38 @@ var skills = oc6.errors({
|
|
|
1718
2023
|
SKILL_CHECK: { message: "the files fail the seed checks", status: 400 },
|
|
1719
2024
|
WRONG_STATE: { message: "the skill nixie wrote is no longer in force", status: 409 }
|
|
1720
2025
|
});
|
|
1721
|
-
var definitionsSkillSchema =
|
|
1722
|
-
var writtenSkillSchema =
|
|
1723
|
-
approvalID:
|
|
1724
|
-
proposalID:
|
|
1725
|
-
name:
|
|
1726
|
-
skillHash:
|
|
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(),
|
|
1727
2032
|
base: definitionsSkillSchema,
|
|
1728
2033
|
definitions: definitionsSkillSchema,
|
|
1729
|
-
isConflict:
|
|
1730
|
-
pullRequestURL:
|
|
1731
|
-
approvedAt:
|
|
1732
|
-
});
|
|
1733
|
-
var promptPartFileSchema =
|
|
1734
|
-
var promptEntrySchema =
|
|
1735
|
-
var pendingPromptProposalSchema =
|
|
1736
|
-
proposalID:
|
|
1737
|
-
promptID:
|
|
1738
|
-
proposalHash:
|
|
1739
|
-
baseHash:
|
|
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(),
|
|
1740
2045
|
entry: promptEntrySchema,
|
|
1741
|
-
files:
|
|
1742
|
-
reason:
|
|
1743
|
-
inForce:
|
|
1744
|
-
thread:
|
|
1745
|
-
provenance:
|
|
1746
|
-
createdAt:
|
|
1747
|
-
lapseAt:
|
|
1748
|
-
isStale:
|
|
1749
|
-
});
|
|
1750
|
-
var promptAnswerSchema =
|
|
1751
|
-
proposalID:
|
|
1752
|
-
proposalHash:
|
|
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)
|
|
1753
2058
|
});
|
|
1754
2059
|
var prompts = oc6.errors({
|
|
1755
2060
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
@@ -1758,59 +2063,63 @@ var prompts = oc6.errors({
|
|
|
1758
2063
|
STALE_BASE: { message: "the override in force moved past the proposal", status: 409 },
|
|
1759
2064
|
PROMPT_CHECK: { message: "the override fails the definitions checks", status: 400 }
|
|
1760
2065
|
});
|
|
1761
|
-
var ruleVersionSchema =
|
|
1762
|
-
var ruleInForceSchema =
|
|
1763
|
-
ruleID:
|
|
1764
|
-
revision:
|
|
1765
|
-
ruleHash:
|
|
1766
|
-
sentence:
|
|
1767
|
-
origin:
|
|
1768
|
-
changeID:
|
|
1769
|
-
lastFiredAt:
|
|
1770
|
-
});
|
|
1771
|
-
var ruleConflictSchema =
|
|
1772
|
-
ruleID:
|
|
1773
|
-
changeID:
|
|
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(),
|
|
1774
2079
|
nixie: ruleVersionSchema,
|
|
1775
2080
|
repo: ruleVersionSchema,
|
|
1776
2081
|
base: ruleVersionSchema,
|
|
1777
|
-
changedBy:
|
|
1778
|
-
reason:
|
|
1779
|
-
changedAt:
|
|
2082
|
+
changedBy: z46.enum(["owner", "nixie"]),
|
|
2083
|
+
reason: z46.string(),
|
|
2084
|
+
changedAt: z46.date()
|
|
1780
2085
|
});
|
|
1781
|
-
var ruleProposalChangeSchema =
|
|
1782
|
-
ruleID:
|
|
2086
|
+
var ruleProposalChangeSchema = z46.object({
|
|
2087
|
+
ruleID: z46.string(),
|
|
1783
2088
|
before: ruleVersionSchema,
|
|
1784
2089
|
after: ruleVersionSchema
|
|
1785
2090
|
});
|
|
1786
|
-
var effectChangeSchema =
|
|
1787
|
-
tool:
|
|
1788
|
-
remove:
|
|
1789
|
-
sentence:
|
|
2091
|
+
var effectChangeSchema = z46.object({
|
|
2092
|
+
tool: z46.string(),
|
|
2093
|
+
remove: z46.array(z46.string()),
|
|
2094
|
+
sentence: z46.string()
|
|
1790
2095
|
});
|
|
1791
|
-
var pendingRuleProposalSchema =
|
|
1792
|
-
proposalID:
|
|
1793
|
-
changes:
|
|
1794
|
-
effectChanges:
|
|
1795
|
-
createdAt:
|
|
1796
|
-
lapseAt:
|
|
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()
|
|
1797
2102
|
});
|
|
1798
|
-
var ruleProposalAnswerSchema =
|
|
2103
|
+
var ruleProposalAnswerSchema = z46.strictObject({ proposalID: z46.string().min(1) });
|
|
1799
2104
|
var ruleProposalRejectionSchema = ruleProposalAnswerSchema.extend({
|
|
1800
|
-
reason:
|
|
2105
|
+
reason: z46.string().max(500).regex(/\S/u)
|
|
1801
2106
|
});
|
|
1802
2107
|
var actionRejectionSchema = ruleProposalAnswerSchema.extend({
|
|
1803
|
-
reason:
|
|
2108
|
+
reason: z46.string().max(500).regex(/\S/u).optional()
|
|
1804
2109
|
});
|
|
1805
2110
|
var ruleProposalErrors = {
|
|
1806
2111
|
NOT_FOUND: { message: "nothing has that ID", status: 404 },
|
|
1807
2112
|
PROPOSAL_CLOSED: { message: "the proposal is answered, withdrawn or lapsed", status: 409 }
|
|
1808
2113
|
};
|
|
1809
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
|
+
});
|
|
1810
2119
|
var contacts = oc6.errors({
|
|
1811
2120
|
NOT_FOUND: { message: "no known contact has that ID", status: 404 }
|
|
1812
2121
|
});
|
|
1813
|
-
var hostTaskStateSchema =
|
|
2122
|
+
var hostTaskStateSchema = z46.enum([
|
|
1814
2123
|
"ready",
|
|
1815
2124
|
"running",
|
|
1816
2125
|
"waiting",
|
|
@@ -1830,29 +2139,29 @@ var taskControl2 = oc6.errors({
|
|
|
1830
2139
|
message: "the runner of the task does not take this control",
|
|
1831
2140
|
status: 409
|
|
1832
2141
|
}
|
|
1833
|
-
}).input(
|
|
1834
|
-
taskID:
|
|
2142
|
+
}).input(z46.strictObject({ taskID: z46.string().min(1) })).output(z46.object({
|
|
2143
|
+
taskID: z46.string(),
|
|
1835
2144
|
state: hostTaskStateSchema,
|
|
1836
|
-
isPauseRequested:
|
|
2145
|
+
isPauseRequested: z46.boolean()
|
|
1837
2146
|
}));
|
|
1838
2147
|
var hostContract = {
|
|
1839
|
-
reset: oc6.output(
|
|
1840
|
-
resetAt:
|
|
1841
|
-
lastSequence:
|
|
1842
|
-
keptSessions:
|
|
2148
|
+
reset: oc6.output(z46.object({
|
|
2149
|
+
resetAt: z46.date(),
|
|
2150
|
+
lastSequence: z46.int().nonnegative(),
|
|
2151
|
+
keptSessions: z46.int().nonnegative()
|
|
1843
2152
|
})),
|
|
1844
|
-
resetConversations: oc6.output(
|
|
1845
|
-
resetAt:
|
|
1846
|
-
lastSequence:
|
|
1847
|
-
shreddedRecords:
|
|
2153
|
+
resetConversations: oc6.output(z46.object({
|
|
2154
|
+
resetAt: z46.date(),
|
|
2155
|
+
lastSequence: z46.int().nonnegative(),
|
|
2156
|
+
shreddedRecords: z46.int().nonnegative(),
|
|
1848
2157
|
backup: forgetBackupSchema
|
|
1849
2158
|
})),
|
|
1850
2159
|
nixie: {
|
|
1851
|
-
pause: oc6.output(
|
|
1852
|
-
resume: oc6.output(
|
|
2160
|
+
pause: oc6.output(z46.object({ paused: pauseStateSchema })),
|
|
2161
|
+
resume: oc6.output(z46.object({ paused: pauseStateSchema }))
|
|
1853
2162
|
},
|
|
1854
2163
|
recovery: {
|
|
1855
|
-
read: oc6.output(
|
|
2164
|
+
read: oc6.output(z46.object({ recovery: recoverySchema }))
|
|
1856
2165
|
},
|
|
1857
2166
|
tasks: {
|
|
1858
2167
|
pause: taskControl2,
|
|
@@ -1860,166 +2169,218 @@ var hostContract = {
|
|
|
1860
2169
|
stop: taskControl2,
|
|
1861
2170
|
restart: taskControl2,
|
|
1862
2171
|
close: taskControl2.errors({
|
|
1863
|
-
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
|
+
}
|
|
1864
2177
|
}),
|
|
1865
2178
|
interrupt: taskControl2,
|
|
1866
2179
|
raise: oc6.errors({
|
|
1867
2180
|
TASK_NOT_FOUND: { message: "no task has that ID", status: 404 },
|
|
1868
2181
|
TASK_NOT_AT_LIMIT: { message: "the task is not paused at its limit", status: 409 },
|
|
1869
2182
|
LIMIT_NOT_RAISED: { message: "the new limits are not above the old ones", status: 409 }
|
|
1870
|
-
}).input(
|
|
1871
|
-
taskID:
|
|
1872
|
-
turns:
|
|
1873
|
-
dollars:
|
|
2183
|
+
}).input(z46.strictObject({
|
|
2184
|
+
taskID: z46.string().min(1),
|
|
2185
|
+
turns: z46.int().positive().optional(),
|
|
2186
|
+
dollars: z46.number().positive().optional()
|
|
1874
2187
|
}).refine((input) => input.turns !== undefined || input.dollars !== undefined, {
|
|
1875
2188
|
message: "a raise sets turns, dollars or both"
|
|
1876
|
-
})).output(
|
|
1877
|
-
taskID:
|
|
2189
|
+
})).output(z46.object({
|
|
2190
|
+
taskID: z46.string(),
|
|
1878
2191
|
state: hostTaskStateSchema,
|
|
1879
|
-
isPauseRequested:
|
|
1880
|
-
turns:
|
|
1881
|
-
dollars:
|
|
2192
|
+
isPauseRequested: z46.boolean(),
|
|
2193
|
+
turns: z46.int().positive(),
|
|
2194
|
+
dollars: z46.number().positive()
|
|
1882
2195
|
}))
|
|
1883
2196
|
},
|
|
1884
2197
|
sessions: {
|
|
1885
|
-
issueCode: oc6.output(
|
|
1886
|
-
list: oc6.output(
|
|
2198
|
+
issueCode: oc6.output(z46.object({ code: z46.string(), expiresAt: z46.date() })),
|
|
2199
|
+
list: oc6.output(z46.array(hostSessionSchema)),
|
|
1887
2200
|
label: oc6.errors({
|
|
1888
2201
|
SESSION_NOT_FOUND: {
|
|
1889
2202
|
message: "no device session that is still signed in has that ID",
|
|
1890
2203
|
status: 404
|
|
1891
2204
|
},
|
|
1892
2205
|
LABEL_INVALID: { message: "a label holds 1 to 100 characters besides spaces", status: 400 }
|
|
1893
|
-
}).input(
|
|
2206
|
+
}).input(z46.strictObject({ sessionID: z46.string().min(1), label: z46.string() })).output(z46.object({ sessionID: z46.string(), label: z46.string() }))
|
|
1894
2207
|
},
|
|
1895
2208
|
passkeys: hostPasskeyContract,
|
|
1896
2209
|
memory: {
|
|
1897
2210
|
proposals: {
|
|
1898
|
-
list: memory.output(
|
|
2211
|
+
list: memory.output(z46.array(pendingProposalSchema)),
|
|
1899
2212
|
approve: memory.input(proposalAnswerSchema.extend({
|
|
1900
2213
|
revisionOf: versionTargetSchema2.optional(),
|
|
1901
|
-
ignoreCloseMatch:
|
|
2214
|
+
ignoreCloseMatch: z46.boolean().optional(),
|
|
1902
2215
|
editedText: itemTextSchema.optional()
|
|
1903
2216
|
})).output(approvalResultSchema),
|
|
1904
|
-
reject: memory.input(proposalAnswerSchema.extend({ reason:
|
|
2217
|
+
reject: memory.input(proposalAnswerSchema.extend({ reason: z46.string().max(500).regex(/\S/u).optional() })).output(z46.object({ proposalID: z46.string() }))
|
|
1905
2218
|
},
|
|
1906
|
-
subjects: memory.output(
|
|
2219
|
+
subjects: memory.output(z46.object({ items: subjectCountSchema, proposals: subjectCountSchema })),
|
|
1907
2220
|
items: {
|
|
1908
|
-
read: memory.input(
|
|
2221
|
+
read: memory.input(z46.strictObject({ itemID: z46.string().min(1) })).output(itemHistorySchema),
|
|
1909
2222
|
edit: memory.input(versionTargetSchema2.extend({ text: itemTextSchema })).output(versionRefSchema2),
|
|
1910
2223
|
retire: memory.input(versionTargetSchema2).output(versionRefSchema2),
|
|
1911
2224
|
restore: memory.input(versionTargetSchema2).output(versionRefSchema2),
|
|
1912
|
-
forget: memory.input(versionTargetSchema2).output(
|
|
2225
|
+
forget: memory.input(versionTargetSchema2).output(z46.object({ itemID: z46.string(), backup: forgetBackupSchema })),
|
|
1913
2226
|
forgetAll: memory.output(forgottenItemsSchema),
|
|
1914
|
-
pin: memory.input(
|
|
2227
|
+
pin: memory.input(z46.strictObject({ itemID: z46.string().min(1), isPinned: z46.boolean() })).output(z46.object({ itemID: z46.string(), isPinned: z46.boolean() }))
|
|
1915
2228
|
}
|
|
1916
2229
|
},
|
|
1917
2230
|
skills: {
|
|
1918
2231
|
proposals: {
|
|
1919
|
-
list: skills.output(
|
|
1920
|
-
approve: skills.input(skillAnswerSchema.extend({ files:
|
|
1921
|
-
reject: skills.input(skillAnswerSchema.extend({ reason:
|
|
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() }))
|
|
1922
2235
|
},
|
|
1923
2236
|
written: {
|
|
1924
|
-
list: skills.output(
|
|
1925
|
-
resolve: skills.input(
|
|
1926
|
-
approvalID:
|
|
1927
|
-
keep:
|
|
1928
|
-
})).output(
|
|
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"]) }))
|
|
1929
2242
|
}
|
|
1930
2243
|
},
|
|
1931
2244
|
rules: {
|
|
1932
|
-
list: rules.output(
|
|
1933
|
-
conflicts: rules.output(
|
|
1934
|
-
resolve: rules.input(
|
|
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"]) })),
|
|
1935
2248
|
proposals: {
|
|
1936
|
-
list: rules.output(
|
|
1937
|
-
approve: rules.input(ruleProposalAnswerSchema).output(
|
|
1938
|
-
reject: rules.input(ruleProposalRejectionSchema).output(
|
|
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() }))
|
|
1939
2252
|
}
|
|
1940
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
|
+
},
|
|
1941
2261
|
actions: {
|
|
1942
2262
|
proposals: {
|
|
1943
|
-
list: rules.output(
|
|
1944
|
-
approve: rules.input(ruleProposalAnswerSchema).output(
|
|
1945
|
-
reject: rules.input(actionRejectionSchema).output(
|
|
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() }))
|
|
1946
2266
|
}
|
|
1947
2267
|
},
|
|
1948
2268
|
mandates: hostMandatesContract,
|
|
1949
2269
|
contacts: {
|
|
1950
|
-
list: contacts.output(
|
|
1951
|
-
markKnown: contacts.input(
|
|
1952
|
-
destination:
|
|
1953
|
-
name:
|
|
1954
|
-
})).output(
|
|
1955
|
-
unmark: contacts.input(
|
|
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() }))
|
|
1956
2276
|
},
|
|
1957
2277
|
turnInputs: turnInputsContract,
|
|
1958
2278
|
prompts: {
|
|
1959
2279
|
proposals: {
|
|
1960
|
-
list: prompts.output(
|
|
2280
|
+
list: prompts.output(z46.array(pendingPromptProposalSchema)),
|
|
1961
2281
|
approve: prompts.input(promptAnswerSchema.extend({
|
|
1962
2282
|
entry: promptEntrySchema.optional(),
|
|
1963
|
-
files:
|
|
1964
|
-
})).output(
|
|
1965
|
-
reject: prompts.input(promptAnswerSchema.extend({ reason:
|
|
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() }))
|
|
1966
2286
|
}
|
|
1967
2287
|
}
|
|
1968
2288
|
};
|
|
1969
|
-
// src/contract/
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
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
|
+
}
|
|
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
|
+
}
|
|
1975
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
|
+
};
|
|
1976
2330
|
}
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
minutes: z36.int().min(5).max(1440)
|
|
1982
|
-
});
|
|
1983
|
-
var weekdaySchema = z36.enum(["mon", "tue", "wed", "thu", "fri", "sat", "sun"]);
|
|
1984
|
-
var scheduleSchema = z36.strictObject({
|
|
1985
|
-
every: z36.union([z36.enum(["day", "week", "hour"]), minutesSchema]),
|
|
1986
|
-
at: clockTimeSchema.optional(),
|
|
1987
|
-
on: weekdaySchema.optional(),
|
|
1988
|
-
window: z36.strictObject({ from: clockTimeSchema, until: clockTimeSchema }).optional(),
|
|
1989
|
-
idleMinutes: z36.int().min(1).max(720).optional(),
|
|
1990
|
-
zone: z36.string().refine((zone) => zone === "owner" || isTimeZone(zone), "a zone is owner or an IANA zone").default("owner"),
|
|
1991
|
-
catchUp: z36.enum(["once", "skip"]).default("once")
|
|
1992
|
-
}).superRefine((schedule, context) => {
|
|
1993
|
-
const isCalendar = schedule.every === "day" || schedule.every === "week";
|
|
1994
|
-
if (isCalendar && schedule.at === undefined && schedule.window === undefined) {
|
|
1995
|
-
context.addIssue({ code: "custom", message: "day and week need at or window" });
|
|
2331
|
+
var maxFieldBytes = 64 * 1024;
|
|
2332
|
+
function clipObjectField(value, field, clipped) {
|
|
2333
|
+
if (value === undefined) {
|
|
2334
|
+
return;
|
|
1996
2335
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
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;
|
|
1999
2342
|
}
|
|
2000
|
-
|
|
2001
|
-
|
|
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;
|
|
2002
2354
|
}
|
|
2003
|
-
if (
|
|
2004
|
-
|
|
2355
|
+
if (Array.isArray(value)) {
|
|
2356
|
+
return value.map((item, index) => clipValue(item, field, [...path, index], found));
|
|
2005
2357
|
}
|
|
2006
|
-
if (
|
|
2007
|
-
|
|
2358
|
+
if (isObject(value)) {
|
|
2359
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
2360
|
+
key,
|
|
2361
|
+
clipValue(item, field, [...path, key], found)
|
|
2362
|
+
]));
|
|
2008
2363
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
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;
|
|
2011
2371
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2372
|
+
let end = payloadClipBytes;
|
|
2373
|
+
while (end > 0 && ((bytes[end] ?? 0) & 192) === 128) {
|
|
2374
|
+
end -= 1;
|
|
2014
2375
|
}
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
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;
|
|
2383
|
+
}
|
|
2023
2384
|
// src/contract/session-cookie-name.ts
|
|
2024
2385
|
var sessionCookieName = "nixie_session";
|
|
2025
2386
|
|
|
@@ -2030,11 +2391,11 @@ function renderSessionCookie(token) {
|
|
|
2030
2391
|
return `${sessionCookieName}=${token ?? ""}; Path=/; HttpOnly; Secure; SameSite=Lax; Max-Age=${maxAgeS}`;
|
|
2031
2392
|
}
|
|
2032
2393
|
// src/message/task-message-input-schema.ts
|
|
2033
|
-
import { z as
|
|
2394
|
+
import { z as z48 } from "zod";
|
|
2034
2395
|
|
|
2035
2396
|
// src/message/task-message-kind-schema.ts
|
|
2036
|
-
import { z as
|
|
2037
|
-
var taskMessageKindSchema =
|
|
2397
|
+
import { z as z47 } from "zod";
|
|
2398
|
+
var taskMessageKindSchema = z47.enum([
|
|
2038
2399
|
"progress",
|
|
2039
2400
|
"question",
|
|
2040
2401
|
"request",
|
|
@@ -2044,40 +2405,46 @@ var taskMessageKindSchema = z38.enum([
|
|
|
2044
2405
|
]);
|
|
2045
2406
|
|
|
2046
2407
|
// src/message/task-message-input-schema.ts
|
|
2047
|
-
var taskMessageInputSchema =
|
|
2048
|
-
to:
|
|
2408
|
+
var taskMessageInputSchema = z48.object({
|
|
2409
|
+
to: z48.string(),
|
|
2049
2410
|
kind: taskMessageKindSchema,
|
|
2050
|
-
body:
|
|
2051
|
-
replyTo:
|
|
2052
|
-
onBehalfOf:
|
|
2053
|
-
wake:
|
|
2411
|
+
body: z48.string(),
|
|
2412
|
+
replyTo: z48.string().optional(),
|
|
2413
|
+
onBehalfOf: z48.string().array().optional(),
|
|
2414
|
+
wake: z48.boolean().optional()
|
|
2054
2415
|
});
|
|
2055
2416
|
// src/message/task-message-result-schema.ts
|
|
2056
|
-
import { z as
|
|
2057
|
-
var taskMessageResultSchema =
|
|
2058
|
-
messageID:
|
|
2059
|
-
woke:
|
|
2060
|
-
hop:
|
|
2061
|
-
note:
|
|
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()
|
|
2062
2423
|
});
|
|
2063
2424
|
export {
|
|
2064
2425
|
buildPendingInput,
|
|
2065
2426
|
buildQueryUtils,
|
|
2066
2427
|
buildSpanState,
|
|
2067
2428
|
clientHeaderName,
|
|
2429
|
+
clipRecordPayloads,
|
|
2068
2430
|
contract,
|
|
2069
2431
|
forgettableKinds,
|
|
2070
2432
|
hostContract,
|
|
2071
2433
|
imageLimits,
|
|
2072
2434
|
isTimeZone,
|
|
2435
|
+
listedStateSchema,
|
|
2436
|
+
payloadClipBytes,
|
|
2073
2437
|
pickSpanSource,
|
|
2074
2438
|
renderSessionCookie,
|
|
2439
|
+
runFireSchema,
|
|
2075
2440
|
scheduleSchema,
|
|
2076
2441
|
sessionCookieName,
|
|
2442
|
+
skipReasonSchema,
|
|
2077
2443
|
spanSchema,
|
|
2078
2444
|
taskMessageInputSchema,
|
|
2079
2445
|
taskMessageKindSchema,
|
|
2080
2446
|
taskMessageResultSchema,
|
|
2081
2447
|
triggerAtSchema,
|
|
2082
|
-
triggerSchema
|
|
2448
|
+
triggerSchema,
|
|
2449
|
+
workerViewSchema
|
|
2083
2450
|
};
|