@usenaive-sdk/blueprints 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +44 -3
- package/dist/index.js +644 -514
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,10 +116,6 @@ function decimalStringFromMicro(amount) {
|
|
|
116
116
|
return `${amount < 0 ? "-" : ""}${absolute / BigInt(USD)}.${fraction}`;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// ../core/src/session-token.ts
|
|
120
|
-
var SESSION_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
121
|
-
var encoder = new TextEncoder();
|
|
122
|
-
|
|
123
119
|
// ../core/src/schema/audit-actions.ts
|
|
124
120
|
var AUDIT_ACTIONS_SHIPPED = [
|
|
125
121
|
"agent.updated",
|
|
@@ -185,6 +181,8 @@ var AUDIT_ACTIONS_P2 = [
|
|
|
185
181
|
"connection.auth_config_created",
|
|
186
182
|
"connection.auth_config_deleted",
|
|
187
183
|
"domain.created",
|
|
184
|
+
"domain.purchased",
|
|
185
|
+
"domain.purchase_refunded",
|
|
188
186
|
"domain.verified",
|
|
189
187
|
"domain.deleted",
|
|
190
188
|
"email.created",
|
|
@@ -735,8 +733,131 @@ var AgentSchema = z6.object({
|
|
|
735
733
|
});
|
|
736
734
|
|
|
737
735
|
// ../core/src/schema/session.ts
|
|
736
|
+
import { z as z8 } from "zod";
|
|
737
|
+
|
|
738
|
+
// ../core/src/schema/social.ts
|
|
738
739
|
import { z as z7 } from "zod";
|
|
739
|
-
var
|
|
740
|
+
var SOCIAL_PLATFORMS = [
|
|
741
|
+
"bluesky",
|
|
742
|
+
"facebook",
|
|
743
|
+
"instagram",
|
|
744
|
+
"linkedin",
|
|
745
|
+
"mastodon",
|
|
746
|
+
"pinterest",
|
|
747
|
+
"reddit",
|
|
748
|
+
"threads",
|
|
749
|
+
"tiktok",
|
|
750
|
+
"x",
|
|
751
|
+
"youtube"
|
|
752
|
+
];
|
|
753
|
+
var SOCIAL_APPS = /* @__PURE__ */ new Set([...SOCIAL_PLATFORMS, "twitter"]);
|
|
754
|
+
var SOCIAL_TEXT_PLATFORMS = [
|
|
755
|
+
"bluesky",
|
|
756
|
+
"facebook",
|
|
757
|
+
"linkedin",
|
|
758
|
+
"mastodon",
|
|
759
|
+
"threads",
|
|
760
|
+
"x"
|
|
761
|
+
];
|
|
762
|
+
var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
|
|
763
|
+
var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
|
|
764
|
+
var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
|
|
765
|
+
var SocialVisibilitySchema = z7.enum(SOCIAL_VISIBILITIES);
|
|
766
|
+
var SOCIAL_VISIBILITY_RULE = `visibility is ${SOCIAL_VISIBILITIES.join(", ")} and only ${SOCIAL_VISIBILITY_PLATFORMS.join(" and ")} accept it; omit it and the post publishes at the account's own default, which on a video channel is normally public`;
|
|
767
|
+
var SocialPlatformSchema = z7.enum(SOCIAL_PLATFORMS);
|
|
768
|
+
var SocialTextPlatformSchema = z7.enum(SOCIAL_TEXT_PLATFORMS);
|
|
769
|
+
var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
|
|
770
|
+
var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
|
|
771
|
+
var SOCIAL_PLATFORM_RULE = `${SOCIAL_TEXT_PLATFORMS.join(", ")} take a text-only post; ${SOCIAL_MEDIA_PLATFORMS.join(", ")} may be named only when the post carries media_urls or file_ids; ${SOCIAL_PLATFORMS.filter((platform) => !isText(platform) && !isMedia(platform)).join(", ")} cannot be posted to`;
|
|
772
|
+
var SocialAccountSchema = z7.object({
|
|
773
|
+
id: z7.string().min(1),
|
|
774
|
+
object: z7.literal("social_account"),
|
|
775
|
+
identity_id: idOf("idn"),
|
|
776
|
+
platform: SocialPlatformSchema,
|
|
777
|
+
username: z7.string().nullable(),
|
|
778
|
+
display_name: z7.string().nullable(),
|
|
779
|
+
avatar_url: z7.url().nullable(),
|
|
780
|
+
connected_at: Timestamp.nullable()
|
|
781
|
+
});
|
|
782
|
+
var SocialPostStatusSchema = z7.enum([
|
|
783
|
+
"draft",
|
|
784
|
+
"scheduled",
|
|
785
|
+
"processing",
|
|
786
|
+
"posted",
|
|
787
|
+
"failed",
|
|
788
|
+
"deleted"
|
|
789
|
+
]);
|
|
790
|
+
var SocialPostSchema = z7.object({
|
|
791
|
+
id: z7.string().min(1),
|
|
792
|
+
object: z7.literal("social_post"),
|
|
793
|
+
identity_id: idOf("idn"),
|
|
794
|
+
title: z7.string(),
|
|
795
|
+
platforms: z7.array(SocialPlatformSchema),
|
|
796
|
+
status: SocialPostStatusSchema,
|
|
797
|
+
scheduled_at: Timestamp.nullable(),
|
|
798
|
+
posted_at: Timestamp.nullable(),
|
|
799
|
+
error: z7.string().nullable()
|
|
800
|
+
});
|
|
801
|
+
var SocialUploadSchema = z7.object({
|
|
802
|
+
id: z7.string().min(1),
|
|
803
|
+
object: z7.literal("social_upload"),
|
|
804
|
+
identity_id: idOf("idn"),
|
|
805
|
+
type: z7.enum(["image", "video", "document"]),
|
|
806
|
+
url: z7.url().nullable()
|
|
807
|
+
});
|
|
808
|
+
var SocialAnalyticsSchema = z7.object({
|
|
809
|
+
object: z7.literal("social_analytics"),
|
|
810
|
+
identity_id: idOf("idn"),
|
|
811
|
+
resource_id: z7.string().min(1),
|
|
812
|
+
platform: SocialPlatformSchema.nullable(),
|
|
813
|
+
data: z7.unknown()
|
|
814
|
+
});
|
|
815
|
+
var SocialCommentSchema = z7.object({
|
|
816
|
+
id: z7.string().min(1),
|
|
817
|
+
object: z7.literal("social_comment"),
|
|
818
|
+
identity_id: idOf("idn"),
|
|
819
|
+
post_id: z7.string().min(1),
|
|
820
|
+
platforms: z7.array(SocialPlatformSchema),
|
|
821
|
+
status: SocialPostStatusSchema,
|
|
822
|
+
posted_at: Timestamp.nullable(),
|
|
823
|
+
data: z7.unknown()
|
|
824
|
+
});
|
|
825
|
+
var POST_STATUSES = ["pending", "scheduled", "posted", "failed"];
|
|
826
|
+
var PostStatusSchema = z7.enum(POST_STATUSES);
|
|
827
|
+
var PostSchema = z7.object({
|
|
828
|
+
object: z7.literal("post"),
|
|
829
|
+
id: z7.string().min(1),
|
|
830
|
+
status: PostStatusSchema,
|
|
831
|
+
identity_id: z7.string().nullable(),
|
|
832
|
+
agent_id: z7.string().nullable(),
|
|
833
|
+
session_id: z7.string().nullable(),
|
|
834
|
+
tool_call_id: z7.string().nullable(),
|
|
835
|
+
content: z7.string().nullable(),
|
|
836
|
+
platforms: z7.array(z7.string()),
|
|
837
|
+
file_ids: z7.array(z7.string()),
|
|
838
|
+
media_urls: z7.array(z7.string()),
|
|
839
|
+
visibility: SocialVisibilitySchema.nullable(),
|
|
840
|
+
scheduled_at: Timestamp.nullable(),
|
|
841
|
+
posted_at: Timestamp.nullable(),
|
|
842
|
+
url: z7.string().nullable(),
|
|
843
|
+
error: z7.string().nullable(),
|
|
844
|
+
/** The latest stored reading, `{metric: value}`; `null` before `social.post_metrics` read any. */
|
|
845
|
+
metrics: z7.record(z7.string(), z7.number()).nullable(),
|
|
846
|
+
measured_at: Timestamp.nullable(),
|
|
847
|
+
/** Pending only: the earlier post this call would repeat — same identity, network and file. */
|
|
848
|
+
duplicate_of: z7.object({
|
|
849
|
+
id: z7.string(),
|
|
850
|
+
status: PostStatusSchema,
|
|
851
|
+
platform: z7.string(),
|
|
852
|
+
at: Timestamp.nullable(),
|
|
853
|
+
agent_id: z7.string().nullable(),
|
|
854
|
+
session_id: z7.string().nullable()
|
|
855
|
+
}).nullable(),
|
|
856
|
+
created_at: Timestamp
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// ../core/src/schema/session.ts
|
|
860
|
+
var SessionStatusSchema = z8.enum([
|
|
740
861
|
"queued",
|
|
741
862
|
"running",
|
|
742
863
|
"idle",
|
|
@@ -744,23 +865,23 @@ var SessionStatusSchema = z7.enum([
|
|
|
744
865
|
"failed",
|
|
745
866
|
"cancelled"
|
|
746
867
|
]);
|
|
747
|
-
var SessionModeSchema =
|
|
868
|
+
var SessionModeSchema = z8.enum(["plan", "build"]);
|
|
748
869
|
var PLAN_MAX_CHARS = 2e4;
|
|
749
|
-
var PlanSchema =
|
|
750
|
-
object:
|
|
751
|
-
markdown:
|
|
752
|
-
version:
|
|
753
|
-
by:
|
|
870
|
+
var PlanSchema = z8.object({
|
|
871
|
+
object: z8.literal("plan"),
|
|
872
|
+
markdown: z8.string().max(PLAN_MAX_CHARS),
|
|
873
|
+
version: z8.number().int().nonnegative(),
|
|
874
|
+
by: z8.enum(["agent", "owner"]).nullable()
|
|
754
875
|
});
|
|
755
|
-
var PlanWriteSchema =
|
|
756
|
-
markdown:
|
|
757
|
-
base_version:
|
|
876
|
+
var PlanWriteSchema = z8.object({
|
|
877
|
+
markdown: z8.string().max(PLAN_MAX_CHARS),
|
|
878
|
+
base_version: z8.number().int().nonnegative()
|
|
758
879
|
});
|
|
759
|
-
var ProposePlanSchema =
|
|
760
|
-
version:
|
|
761
|
-
spends_or_publishes:
|
|
880
|
+
var ProposePlanSchema = z8.object({
|
|
881
|
+
version: z8.number().int().positive(),
|
|
882
|
+
spends_or_publishes: z8.array(z8.string().min(1).max(200)).max(10).optional()
|
|
762
883
|
});
|
|
763
|
-
var StopReasonSchema =
|
|
884
|
+
var StopReasonSchema = z8.enum([
|
|
764
885
|
"end_turn",
|
|
765
886
|
"awaiting_input",
|
|
766
887
|
"awaiting_approval",
|
|
@@ -786,27 +907,27 @@ var StopReasonSchema = z7.enum([
|
|
|
786
907
|
*/
|
|
787
908
|
"awaiting_answer"
|
|
788
909
|
]);
|
|
789
|
-
var ThreadRoleSchema =
|
|
790
|
-
var MessageSchema =
|
|
791
|
-
role:
|
|
792
|
-
content:
|
|
793
|
-
tool_call_id:
|
|
910
|
+
var ThreadRoleSchema = z8.enum(["coordinator", "member"]);
|
|
911
|
+
var MessageSchema = z8.object({
|
|
912
|
+
role: z8.enum(["system", "user", "assistant", "tool"]),
|
|
913
|
+
content: z8.string(),
|
|
914
|
+
tool_call_id: z8.string().optional()
|
|
794
915
|
});
|
|
795
|
-
var ToolImageSchema =
|
|
916
|
+
var ToolImageSchema = z8.object({
|
|
796
917
|
file_id: idOf("fil"),
|
|
797
|
-
url:
|
|
798
|
-
media_type:
|
|
918
|
+
url: z8.string().url().describe("A short-lived signed read for the file's bytes."),
|
|
919
|
+
media_type: z8.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
|
|
799
920
|
});
|
|
800
|
-
var ToolResultSchema =
|
|
801
|
-
output:
|
|
802
|
-
is_error:
|
|
803
|
-
content:
|
|
804
|
-
images:
|
|
921
|
+
var ToolResultSchema = z8.object({
|
|
922
|
+
output: z8.unknown(),
|
|
923
|
+
is_error: z8.boolean().optional(),
|
|
924
|
+
content: z8.string().optional(),
|
|
925
|
+
images: z8.array(ToolImageSchema).max(12).optional()
|
|
805
926
|
});
|
|
806
927
|
var QuestionFieldBase = {
|
|
807
|
-
key:
|
|
808
|
-
label:
|
|
809
|
-
help:
|
|
928
|
+
key: z8.string().min(1).max(64),
|
|
929
|
+
label: z8.string().min(1).max(200),
|
|
930
|
+
help: z8.string().max(500).optional(),
|
|
810
931
|
/**
|
|
811
932
|
* A field that may be left blank, and it defaults to **false** — the rule "every field must be
|
|
812
933
|
* answered" (`assertAnswers`) is still the rule, and this is the one documented way out of it.
|
|
@@ -826,42 +947,79 @@ var QuestionFieldBase = {
|
|
|
826
947
|
* required on the OUTPUT type — so every hand-written `QuestionField` in the codebase, and every
|
|
827
948
|
* one written after it, would have to spell out the flag it does not use.
|
|
828
949
|
*/
|
|
829
|
-
optional:
|
|
950
|
+
optional: z8.boolean().optional()
|
|
830
951
|
};
|
|
831
|
-
var QuestionFieldSchema =
|
|
832
|
-
|
|
952
|
+
var QuestionFieldSchema = z8.discriminatedUnion("type", [
|
|
953
|
+
z8.object({
|
|
833
954
|
...QuestionFieldBase,
|
|
834
|
-
type:
|
|
835
|
-
placeholder:
|
|
955
|
+
type: z8.literal("text"),
|
|
956
|
+
placeholder: z8.string().max(200).optional()
|
|
836
957
|
}),
|
|
837
|
-
|
|
958
|
+
z8.object({
|
|
838
959
|
...QuestionFieldBase,
|
|
839
|
-
type:
|
|
960
|
+
type: z8.literal("choice"),
|
|
840
961
|
/**
|
|
841
962
|
* Plain strings: the option is both the value and the label, because the answer is read back by
|
|
842
963
|
* a model, which wants the words and not an id. Fewer than two is not a choice, and more than
|
|
843
964
|
* twelve is a list — which belongs in the prompt.
|
|
844
965
|
*/
|
|
845
|
-
options:
|
|
846
|
-
multiple:
|
|
966
|
+
options: z8.array(z8.string().min(1).max(200)).min(2).max(12),
|
|
967
|
+
multiple: z8.boolean().default(false),
|
|
847
968
|
/**
|
|
848
969
|
* The free-text escape, and it defaults to **true** on purpose: the agent wrote the options and
|
|
849
970
|
* the agent is the one that does not know the answer, so an operator must always be able to say
|
|
850
971
|
* something it did not think of. A question that truly admits only its list opts out explicitly.
|
|
851
972
|
*/
|
|
852
|
-
other:
|
|
973
|
+
other: z8.boolean().default(true),
|
|
974
|
+
/**
|
|
975
|
+
* A PICTURE OR A LINE FOR AN OPTION (ADR-1103): a template's "how it looks" shows its looks, and
|
|
976
|
+
* a niche says what it means in one line. Each names its option by its words; one naming no
|
|
977
|
+
* option is ignored, never refused. With a picture on any option the dashboard draws the choice
|
|
978
|
+
* as a grid of pictures. `image` is `https://`, or a path on the dashboard itself. An array
|
|
979
|
+
* and not a map, because a model's tool schema cannot always take a map. An older reader drops
|
|
980
|
+
* it and draws the plain list.
|
|
981
|
+
*/
|
|
982
|
+
details: z8.array(
|
|
983
|
+
z8.object({
|
|
984
|
+
option: z8.string().min(1).max(200),
|
|
985
|
+
note: z8.string().min(1).max(120).optional(),
|
|
986
|
+
image: z8.string().max(500).regex(/^\/(?!\/)/, "an image is a path on the dashboard").optional()
|
|
987
|
+
})
|
|
988
|
+
).max(12).optional()
|
|
989
|
+
}),
|
|
990
|
+
/**
|
|
991
|
+
* THE PERSON'S OWN MEDIA (ADR-1103): "show us what you like". The dashboard offers an upload for
|
|
992
|
+
* images or a video, which land in the organization's files, and a box for a link. The answer is
|
|
993
|
+
* the list: `fil_` ids and `https://` links, which an agent opens with `files_get`, `view_image`
|
|
994
|
+
* or the browser. `placeholder` is the link box's.
|
|
995
|
+
*/
|
|
996
|
+
z8.object({
|
|
997
|
+
...QuestionFieldBase,
|
|
998
|
+
type: z8.literal("media"),
|
|
999
|
+
placeholder: z8.string().max(200).optional()
|
|
853
1000
|
})
|
|
854
1001
|
]);
|
|
1002
|
+
var ConnectFieldSchema = z8.object({
|
|
1003
|
+
...QuestionFieldBase,
|
|
1004
|
+
type: z8.literal("connect"),
|
|
1005
|
+
platforms: z8.array(SocialPlatformSchema).min(1).max(6)
|
|
1006
|
+
});
|
|
1007
|
+
var AskFieldSchema = z8.discriminatedUnion("type", [...QuestionFieldSchema.options, ConnectFieldSchema]);
|
|
855
1008
|
var QUESTION_FIELDS_MAX = 3;
|
|
856
|
-
var QuestionSchema =
|
|
857
|
-
prompt:
|
|
858
|
-
fields:
|
|
1009
|
+
var QuestionSchema = z8.object({
|
|
1010
|
+
prompt: z8.string().min(1).max(1e3),
|
|
1011
|
+
fields: z8.array(AskFieldSchema).min(1).max(QUESTION_FIELDS_MAX, {
|
|
859
1012
|
message: `a question has at most ${QUESTION_FIELDS_MAX} fields \u2014 ask the rest in a second question once these are answered`
|
|
860
1013
|
})
|
|
861
|
-
})
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1014
|
+
}).refine((question) => question.fields.length === 1 || question.fields.every((field) => field.type !== "connect"), {
|
|
1015
|
+
// A connect card answers itself when the accounts land (ADR-1102); a field beside it would need
|
|
1016
|
+
// a Send the card does not have.
|
|
1017
|
+
message: "a connect field is a question of its own: ask anything else in a separate question",
|
|
1018
|
+
path: ["fields"]
|
|
1019
|
+
});
|
|
1020
|
+
var answersOf = (max, message3) => z8.record(
|
|
1021
|
+
z8.string().min(1).max(64),
|
|
1022
|
+
z8.union([z8.string().max(2e3), z8.array(z8.string().max(2e3)).min(1).max(12)])
|
|
865
1023
|
).refine((answers) => Object.keys(answers).length <= max, { message: message3 });
|
|
866
1024
|
var AnswersSchema = answersOf(
|
|
867
1025
|
QUESTION_FIELDS_MAX,
|
|
@@ -872,24 +1030,29 @@ var InstallAnswersSchema = answersOf(
|
|
|
872
1030
|
TEMPLATE_QUESTIONS_MAX,
|
|
873
1031
|
`a template asks at most ${TEMPLATE_QUESTIONS_MAX} questions, so an install has at most ${TEMPLATE_QUESTIONS_MAX} answers`
|
|
874
1032
|
);
|
|
875
|
-
var PendingActionSchema =
|
|
876
|
-
kind:
|
|
877
|
-
tool_call_id:
|
|
878
|
-
name:
|
|
879
|
-
args:
|
|
1033
|
+
var PendingActionSchema = z8.object({
|
|
1034
|
+
kind: z8.enum(["tool", "question"]).default("tool"),
|
|
1035
|
+
tool_call_id: z8.string(),
|
|
1036
|
+
name: z8.string(),
|
|
1037
|
+
args: z8.record(z8.string(), z8.unknown()),
|
|
880
1038
|
/**
|
|
881
1039
|
* Present iff `kind` is `"question"`, and it is the parse of `args` rather than a second source
|
|
882
1040
|
* of truth: `args` is what the model called and therefore what replays byte-identically, while
|
|
883
1041
|
* `question` is what a renderer reads without having to know that `ask_operator`'s arguments
|
|
884
1042
|
* happen to be the question. Same content, two jobs.
|
|
885
1043
|
*/
|
|
886
|
-
question: QuestionSchema.optional()
|
|
1044
|
+
question: QuestionSchema.optional(),
|
|
1045
|
+
/**
|
|
1046
|
+
* The helper's thread a coordinator adopted this call from (§28, B-3; ADR-1101): the dashboard
|
|
1047
|
+
* marks that helper as waiting on you. Absent on the session's own calls.
|
|
1048
|
+
*/
|
|
1049
|
+
thread_id: idOf("ses").optional()
|
|
887
1050
|
});
|
|
888
|
-
var SessionSchema =
|
|
1051
|
+
var SessionSchema = z8.object({
|
|
889
1052
|
id: idOf("ses"),
|
|
890
|
-
object:
|
|
1053
|
+
object: z8.literal("session"),
|
|
891
1054
|
agent_id: idOf("agt"),
|
|
892
|
-
agent_version:
|
|
1055
|
+
agent_version: z8.number().int().positive(),
|
|
893
1056
|
deployment_id: idOf("dep").nullable(),
|
|
894
1057
|
/**
|
|
895
1058
|
* The persona this session acts as (`canonical-spec §22`). Chosen per task from the personas the
|
|
@@ -916,7 +1079,7 @@ var SessionSchema = z7.object({
|
|
|
916
1079
|
* The model the latest send picked (§7 `model`), or `null` when none has and the session runs its
|
|
917
1080
|
* pinned version's model (§10, ADR-0832). Defaulted so a reply from an older control plane parses.
|
|
918
1081
|
*/
|
|
919
|
-
model:
|
|
1082
|
+
model: z8.string().nullable().default(null),
|
|
920
1083
|
/** Plan mode (§7.5, §10): defaulted so a reply from an older control plane parses as `build`. */
|
|
921
1084
|
mode: SessionModeSchema.default("build"),
|
|
922
1085
|
status: SessionStatusSchema,
|
|
@@ -925,38 +1088,38 @@ var SessionSchema = z7.object({
|
|
|
925
1088
|
budget_micro_usd: MicroUsdField.nonnegative(),
|
|
926
1089
|
consumed_micro_usd: MicroUsdField.nonnegative(),
|
|
927
1090
|
token_usage: TokenUsageSchema,
|
|
928
|
-
pending_actions:
|
|
1091
|
+
pending_actions: z8.array(PendingActionSchema),
|
|
929
1092
|
output_schema: JsonSchemaDocument.nullable(),
|
|
930
|
-
structured_output:
|
|
931
|
-
last_seq:
|
|
1093
|
+
structured_output: z8.record(z8.string(), z8.unknown()).nullable(),
|
|
1094
|
+
last_seq: z8.number().int().nonnegative(),
|
|
932
1095
|
metadata: Metadata,
|
|
933
1096
|
started_at: Timestamp.nullable(),
|
|
934
1097
|
ended_at: Timestamp.nullable(),
|
|
935
1098
|
created_at: Timestamp
|
|
936
1099
|
});
|
|
937
|
-
var SendMessageSchema =
|
|
938
|
-
message:
|
|
939
|
-
interrupt:
|
|
940
|
-
queue:
|
|
1100
|
+
var SendMessageSchema = z8.object({
|
|
1101
|
+
message: z8.string(),
|
|
1102
|
+
interrupt: z8.boolean().optional(),
|
|
1103
|
+
queue: z8.boolean().optional(),
|
|
941
1104
|
/** A catalogue id: this session runs on it from this message's turn on (§7, ADR-0832). */
|
|
942
|
-
model:
|
|
1105
|
+
model: z8.string().min(1).optional(),
|
|
943
1106
|
/** Plan mode from this message's turn on (§7.5, ADR-0905). */
|
|
944
1107
|
mode: SessionModeSchema.optional(),
|
|
945
|
-
idempotency_key:
|
|
1108
|
+
idempotency_key: z8.string().optional()
|
|
946
1109
|
}).refine((body) => !(body.interrupt === true && body.queue === true), {
|
|
947
1110
|
message: "a send is either an interrupt or queued, not both",
|
|
948
1111
|
path: ["queue"]
|
|
949
1112
|
});
|
|
950
|
-
var SendAcceptedSchema =
|
|
951
|
-
session_id:
|
|
1113
|
+
var SendAcceptedSchema = z8.object({
|
|
1114
|
+
session_id: z8.string(),
|
|
952
1115
|
status: SessionStatusSchema,
|
|
953
|
-
accepted_seq:
|
|
1116
|
+
accepted_seq: z8.number().int().nonnegative()
|
|
954
1117
|
});
|
|
955
|
-
var ToolConfirmationSchema =
|
|
956
|
-
tool_call_id:
|
|
957
|
-
decision:
|
|
958
|
-
reason:
|
|
959
|
-
scope:
|
|
1118
|
+
var ToolConfirmationSchema = z8.object({
|
|
1119
|
+
tool_call_id: z8.string(),
|
|
1120
|
+
decision: z8.enum(["allow", "deny"]),
|
|
1121
|
+
reason: z8.string().optional(),
|
|
1122
|
+
scope: z8.enum(["call", "session"]).default("call"),
|
|
960
1123
|
/**
|
|
961
1124
|
* THE PERSON'S OWN ANSWERS for a template install they approve (ADR-1030): the call runs with
|
|
962
1125
|
* these in place of the `answers` the agent proposed, and with nothing else changed. A modifier on
|
|
@@ -965,14 +1128,14 @@ var ToolConfirmationSchema = z7.object({
|
|
|
965
1128
|
*/
|
|
966
1129
|
answers: InstallAnswersSchema.optional()
|
|
967
1130
|
});
|
|
968
|
-
var SessionAnswerSchema =
|
|
969
|
-
tool_call_id:
|
|
970
|
-
answers:
|
|
1131
|
+
var SessionAnswerSchema = z8.object({
|
|
1132
|
+
tool_call_id: z8.string(),
|
|
1133
|
+
answers: z8.record(z8.string(), z8.union([z8.string(), z8.array(z8.string())]))
|
|
971
1134
|
});
|
|
972
1135
|
|
|
973
1136
|
// ../core/src/schema/event.ts
|
|
974
|
-
import { z as
|
|
975
|
-
var EventTypeSchema =
|
|
1137
|
+
import { z as z9 } from "zod";
|
|
1138
|
+
var EventTypeSchema = z9.enum([
|
|
976
1139
|
"message.delta",
|
|
977
1140
|
/**
|
|
978
1141
|
* The agent's answer (no `role`), or a user row `{ role: "user", content, client_message_id? }` (§8).
|
|
@@ -1087,78 +1250,78 @@ var EventTypeSchema = z8.enum([
|
|
|
1087
1250
|
"card.refunded",
|
|
1088
1251
|
"card.credentials_revealed"
|
|
1089
1252
|
]);
|
|
1090
|
-
var EventSchema =
|
|
1253
|
+
var EventSchema = z9.object({
|
|
1091
1254
|
id: idOf("evt"),
|
|
1092
|
-
seq:
|
|
1255
|
+
seq: z9.number().int().positive(),
|
|
1093
1256
|
type: EventTypeSchema,
|
|
1094
1257
|
session_id: idOf("ses"),
|
|
1095
|
-
data:
|
|
1258
|
+
data: z9.record(z9.string(), z9.unknown()),
|
|
1096
1259
|
created_at: Timestamp
|
|
1097
1260
|
});
|
|
1098
|
-
var ThreadEventDataSchema =
|
|
1099
|
-
var ToolConfirmResolvedDataSchema =
|
|
1100
|
-
tool_call_id:
|
|
1101
|
-
decision:
|
|
1102
|
-
reason:
|
|
1103
|
-
scope:
|
|
1261
|
+
var ThreadEventDataSchema = z9.looseObject({ thread_id: idOf("ses") });
|
|
1262
|
+
var ToolConfirmResolvedDataSchema = z9.object({
|
|
1263
|
+
tool_call_id: z9.string(),
|
|
1264
|
+
decision: z9.enum(["allow", "deny"]),
|
|
1265
|
+
reason: z9.string().nullable(),
|
|
1266
|
+
scope: z9.enum(["call", "session"]),
|
|
1104
1267
|
actor: PrincipalSchema.nullable(),
|
|
1105
1268
|
decided_at: Timestamp,
|
|
1106
|
-
proposed_args:
|
|
1107
|
-
final_args:
|
|
1269
|
+
proposed_args: z9.record(z9.string(), z9.unknown()).nullable(),
|
|
1270
|
+
final_args: z9.record(z9.string(), z9.unknown()).nullable()
|
|
1108
1271
|
});
|
|
1109
|
-
var ToolConfirmAnsweredDataSchema =
|
|
1110
|
-
tool_call_id:
|
|
1272
|
+
var ToolConfirmAnsweredDataSchema = z9.object({
|
|
1273
|
+
tool_call_id: z9.string(),
|
|
1111
1274
|
answers: AnswersSchema,
|
|
1112
1275
|
answered_at: Timestamp
|
|
1113
1276
|
});
|
|
1114
|
-
var SessionUsageDataSchema =
|
|
1277
|
+
var SessionUsageDataSchema = z9.object({
|
|
1115
1278
|
token_usage: TokenUsageSchema,
|
|
1116
1279
|
consumed_micro_usd: MicroUsdField.nonnegative(),
|
|
1117
|
-
active_seconds:
|
|
1118
|
-
tool_calls:
|
|
1280
|
+
active_seconds: z9.number().nonnegative(),
|
|
1281
|
+
tool_calls: z9.number().int().nonnegative()
|
|
1119
1282
|
});
|
|
1120
1283
|
|
|
1121
1284
|
// ../core/src/schema/board.ts
|
|
1122
|
-
import { z as
|
|
1285
|
+
import { z as z10 } from "zod";
|
|
1123
1286
|
var BOARD_STATUSES = ["todo", "doing", "blocked", "done"];
|
|
1124
|
-
var BoardStatusSchema =
|
|
1125
|
-
var BoardCountsSchema =
|
|
1126
|
-
todo:
|
|
1127
|
-
doing:
|
|
1128
|
-
blocked:
|
|
1129
|
-
done:
|
|
1130
|
-
});
|
|
1131
|
-
var BoardSchema =
|
|
1287
|
+
var BoardStatusSchema = z10.enum(BOARD_STATUSES);
|
|
1288
|
+
var BoardCountsSchema = z10.object({
|
|
1289
|
+
todo: z10.number().int().nonnegative(),
|
|
1290
|
+
doing: z10.number().int().nonnegative(),
|
|
1291
|
+
blocked: z10.number().int().nonnegative(),
|
|
1292
|
+
done: z10.number().int().nonnegative()
|
|
1293
|
+
});
|
|
1294
|
+
var BoardSchema = z10.object({
|
|
1132
1295
|
id: idOf("brd"),
|
|
1133
|
-
object:
|
|
1296
|
+
object: z10.literal("board"),
|
|
1134
1297
|
agent_id: idOf("agt"),
|
|
1135
1298
|
cards: BoardCountsSchema,
|
|
1136
1299
|
created_at: Timestamp
|
|
1137
1300
|
});
|
|
1138
|
-
var BoardCardSchema =
|
|
1301
|
+
var BoardCardSchema = z10.object({
|
|
1139
1302
|
id: idOf("crd"),
|
|
1140
|
-
object:
|
|
1303
|
+
object: z10.literal("board_card"),
|
|
1141
1304
|
board_id: idOf("brd"),
|
|
1142
|
-
title:
|
|
1305
|
+
title: z10.string().min(1),
|
|
1143
1306
|
/** The brief — what was asked. */
|
|
1144
|
-
body:
|
|
1307
|
+
body: z10.string(),
|
|
1145
1308
|
/** What the holder wrote back; a `done` carries one. */
|
|
1146
|
-
note:
|
|
1309
|
+
note: z10.string().nullable().default(null),
|
|
1147
1310
|
status: BoardStatusSchema,
|
|
1148
|
-
assignee:
|
|
1311
|
+
assignee: z10.string().nullable(),
|
|
1149
1312
|
/** The cards this one waits on. A `blocked` card with an empty list is stuck on the world. */
|
|
1150
|
-
blocked_by:
|
|
1313
|
+
blocked_by: z10.array(idOf("crd")),
|
|
1151
1314
|
// The wake fields default on read: a reader whose API predates one still gets the card (§28.11).
|
|
1152
1315
|
woken_session_id: idOf("ses").nullable().default(null),
|
|
1153
1316
|
reported_status: BoardStatusSchema.nullable().default(null),
|
|
1154
1317
|
/** Sessions the board has started for this card; the third is its last (§28.18). */
|
|
1155
|
-
wake_count:
|
|
1318
|
+
wake_count: z10.number().int().nonnegative().default(0),
|
|
1156
1319
|
created_at: Timestamp,
|
|
1157
1320
|
updated_at: Timestamp
|
|
1158
1321
|
});
|
|
1159
|
-
var BoardCommentSchema =
|
|
1322
|
+
var BoardCommentSchema = z10.object({
|
|
1160
1323
|
id: idOf("bcm"),
|
|
1161
|
-
object:
|
|
1324
|
+
object: z10.literal("board_comment"),
|
|
1162
1325
|
card_id: idOf("crd"),
|
|
1163
1326
|
/**
|
|
1164
1327
|
* Who wrote it, as an id the server derived — never a name the caller supplied. A member's
|
|
@@ -1166,42 +1329,42 @@ var BoardCommentSchema = z9.object({
|
|
|
1166
1329
|
* `key_` principal. The prefix is what lets a reader tell an agent's comment from a person's,
|
|
1167
1330
|
* which is the distinction a free-text author field could not make and could be used to forge.
|
|
1168
1331
|
*/
|
|
1169
|
-
author:
|
|
1170
|
-
body:
|
|
1332
|
+
author: z10.string(),
|
|
1333
|
+
body: z10.string(),
|
|
1171
1334
|
created_at: Timestamp
|
|
1172
1335
|
});
|
|
1173
1336
|
|
|
1174
1337
|
// ../core/src/schema/identity.ts
|
|
1175
|
-
import { z as
|
|
1338
|
+
import { z as z11 } from "zod";
|
|
1176
1339
|
var IDENTITY_NAME_MAX = 128;
|
|
1177
1340
|
var IDENTITY_DESCRIPTION_MAX = 1024;
|
|
1178
|
-
var IdentitySchema =
|
|
1341
|
+
var IdentitySchema = z11.object({
|
|
1179
1342
|
id: idOf("idn"),
|
|
1180
|
-
object:
|
|
1343
|
+
object: z11.literal("identity"),
|
|
1181
1344
|
/** Human-facing persona name. Surfaced to the model so it acts in character. */
|
|
1182
|
-
name:
|
|
1345
|
+
name: z11.string().min(1).max(IDENTITY_NAME_MAX),
|
|
1183
1346
|
/** What the persona is for. The model reads it to choose tone, scope and endpoint. */
|
|
1184
|
-
description:
|
|
1347
|
+
description: z11.string().max(IDENTITY_DESCRIPTION_MAX).nullable(),
|
|
1185
1348
|
/** Inbox addresses (`localpart@domain`) this identity owns. */
|
|
1186
|
-
emails:
|
|
1349
|
+
emails: z11.array(z11.string()),
|
|
1187
1350
|
/** Provisioned numbers in E.164. */
|
|
1188
|
-
phones:
|
|
1351
|
+
phones: z11.array(z11.string()),
|
|
1189
1352
|
/** Verified web domains reachable through this identity's inboxes. */
|
|
1190
|
-
domains:
|
|
1353
|
+
domains: z11.array(z11.string()),
|
|
1191
1354
|
/** `conn_` ids of authorized third-party connections. */
|
|
1192
|
-
connections:
|
|
1355
|
+
connections: z11.array(z11.string()),
|
|
1193
1356
|
metadata: Metadata,
|
|
1194
1357
|
created_at: Timestamp,
|
|
1195
1358
|
updated_at: Timestamp
|
|
1196
1359
|
});
|
|
1197
1360
|
|
|
1198
1361
|
// ../core/src/schema/resource.ts
|
|
1199
|
-
import { z as
|
|
1362
|
+
import { z as z13 } from "zod";
|
|
1200
1363
|
|
|
1201
1364
|
// ../core/src/schema/files-library.ts
|
|
1202
|
-
import { z as
|
|
1365
|
+
import { z as z12 } from "zod";
|
|
1203
1366
|
var FILE_KINDS = ["image", "video", "audio", "document", "other"];
|
|
1204
|
-
var FileKindSchema =
|
|
1367
|
+
var FileKindSchema = z12.enum(FILE_KINDS);
|
|
1205
1368
|
var FILE_SOURCE_TYPES = [
|
|
1206
1369
|
"upload",
|
|
1207
1370
|
"url_import",
|
|
@@ -1211,53 +1374,53 @@ var FILE_SOURCE_TYPES = [
|
|
|
1211
1374
|
"screenshot",
|
|
1212
1375
|
"speech_generation"
|
|
1213
1376
|
];
|
|
1214
|
-
var FileSourceTypeSchema =
|
|
1215
|
-
var FileSourceSchema =
|
|
1377
|
+
var FileSourceTypeSchema = z12.enum(FILE_SOURCE_TYPES);
|
|
1378
|
+
var FileSourceSchema = z12.object({
|
|
1216
1379
|
type: FileSourceTypeSchema,
|
|
1217
|
-
job_id:
|
|
1218
|
-
url:
|
|
1380
|
+
job_id: z12.union([idOf("med"), idOf("clj")]).nullable(),
|
|
1381
|
+
url: z12.string().url().nullable(),
|
|
1219
1382
|
/** What a generator was asked with (§36.1, ADR-0886); absent on every other writer's row. */
|
|
1220
|
-
model:
|
|
1221
|
-
prompt:
|
|
1383
|
+
model: z12.string().nullable().optional(),
|
|
1384
|
+
prompt: z12.string().nullable().optional()
|
|
1222
1385
|
});
|
|
1223
|
-
var FileTagsSchema =
|
|
1224
|
-
var FileLibraryFieldsSchema =
|
|
1225
|
-
title:
|
|
1226
|
-
description:
|
|
1386
|
+
var FileTagsSchema = z12.array(z12.string().min(1).max(64)).max(32);
|
|
1387
|
+
var FileLibraryFieldsSchema = z12.object({
|
|
1388
|
+
title: z12.string().max(256).nullable().default(null),
|
|
1389
|
+
description: z12.string().max(4096).nullable().default(null),
|
|
1227
1390
|
tags: FileTagsSchema.default([]),
|
|
1228
1391
|
kind: FileKindSchema.default("other"),
|
|
1229
1392
|
source: FileSourceSchema.nullable().default(null),
|
|
1230
1393
|
thumbnail_file_id: idOf("fil").nullable().default(null),
|
|
1231
|
-
width:
|
|
1232
|
-
height:
|
|
1233
|
-
duration_seconds:
|
|
1394
|
+
width: z12.number().int().positive().nullable().default(null),
|
|
1395
|
+
height: z12.number().int().positive().nullable().default(null),
|
|
1396
|
+
duration_seconds: z12.number().nonnegative().nullable().default(null)
|
|
1234
1397
|
});
|
|
1235
|
-
var UpdateFileSchema =
|
|
1236
|
-
title:
|
|
1237
|
-
description:
|
|
1398
|
+
var UpdateFileSchema = z12.object({
|
|
1399
|
+
title: z12.string().max(256).nullable().optional(),
|
|
1400
|
+
description: z12.string().max(4096).nullable().optional(),
|
|
1238
1401
|
tags: FileTagsSchema.optional()
|
|
1239
1402
|
});
|
|
1240
|
-
var ImportFileSchema =
|
|
1241
|
-
url:
|
|
1242
|
-
title:
|
|
1243
|
-
description:
|
|
1403
|
+
var ImportFileSchema = z12.object({
|
|
1404
|
+
url: z12.string().url().startsWith("http"),
|
|
1405
|
+
title: z12.string().max(256).optional(),
|
|
1406
|
+
description: z12.string().max(4096).optional(),
|
|
1244
1407
|
tags: FileTagsSchema.optional()
|
|
1245
1408
|
});
|
|
1246
1409
|
|
|
1247
1410
|
// ../core/src/schema/resource.ts
|
|
1248
|
-
var ComputerStatusSchema =
|
|
1249
|
-
var VolumeSchema =
|
|
1411
|
+
var ComputerStatusSchema = z13.enum(["creating", "running", "paused", "failed", "destroyed"]);
|
|
1412
|
+
var VolumeSchema = z13.object({
|
|
1250
1413
|
id: idOf("vol"),
|
|
1251
|
-
size_gb:
|
|
1252
|
-
mount_path:
|
|
1414
|
+
size_gb: z13.number().int().positive(),
|
|
1415
|
+
mount_path: z13.string()
|
|
1253
1416
|
});
|
|
1254
|
-
var ComputerSchema =
|
|
1417
|
+
var ComputerSchema = z13.object({
|
|
1255
1418
|
id: idOf("cmp"),
|
|
1256
|
-
object:
|
|
1257
|
-
name:
|
|
1258
|
-
vcpu:
|
|
1259
|
-
memory_mb:
|
|
1260
|
-
disk_gb:
|
|
1419
|
+
object: z13.literal("computer"),
|
|
1420
|
+
name: z13.string(),
|
|
1421
|
+
vcpu: z13.number().int().positive(),
|
|
1422
|
+
memory_mb: z13.number().int().positive(),
|
|
1423
|
+
disk_gb: z13.number().int().positive(),
|
|
1261
1424
|
status: ComputerStatusSchema,
|
|
1262
1425
|
// core-gaps: U2-browser-api — the whole option object (§32.2); `{ allowed_domains }` still parses.
|
|
1263
1426
|
browser: BrowserOptionsSchema.nullable(),
|
|
@@ -1270,127 +1433,127 @@ var ComputerSchema = z12.object({
|
|
|
1270
1433
|
agent_id: idOf("agt").nullable().default(null),
|
|
1271
1434
|
created_at: Timestamp
|
|
1272
1435
|
});
|
|
1273
|
-
var SnapshotSchema =
|
|
1436
|
+
var SnapshotSchema = z13.object({
|
|
1274
1437
|
snapshot_id: idOf("snp"),
|
|
1275
1438
|
computer_id: idOf("cmp"),
|
|
1276
1439
|
created_at: Timestamp
|
|
1277
1440
|
});
|
|
1278
|
-
var ComputerProbeSchema =
|
|
1441
|
+
var ComputerProbeSchema = z13.object({
|
|
1279
1442
|
sampled_at: Timestamp,
|
|
1280
|
-
uptime_seconds:
|
|
1281
|
-
processes:
|
|
1282
|
-
load_1m:
|
|
1283
|
-
memory_used_mb:
|
|
1284
|
-
memory_total_mb:
|
|
1285
|
-
disk_used_gb:
|
|
1286
|
-
disk_total_gb:
|
|
1287
|
-
});
|
|
1288
|
-
var ComputerInspectSchema =
|
|
1289
|
-
object:
|
|
1443
|
+
uptime_seconds: z13.number().int().nonnegative(),
|
|
1444
|
+
processes: z13.number().int().nonnegative(),
|
|
1445
|
+
load_1m: z13.number().nonnegative(),
|
|
1446
|
+
memory_used_mb: z13.number().int().nonnegative(),
|
|
1447
|
+
memory_total_mb: z13.number().int().positive(),
|
|
1448
|
+
disk_used_gb: z13.number().nonnegative(),
|
|
1449
|
+
disk_total_gb: z13.number().positive()
|
|
1450
|
+
});
|
|
1451
|
+
var ComputerInspectSchema = z13.object({
|
|
1452
|
+
object: z13.literal("computer_inspect"),
|
|
1290
1453
|
id: idOf("cmp"),
|
|
1291
1454
|
status: ComputerStatusSchema,
|
|
1292
1455
|
last_active_at: Timestamp.nullable(),
|
|
1293
1456
|
/** Where the provider's file API is rooted (§41.1); `null` when it does not say. */
|
|
1294
|
-
home:
|
|
1457
|
+
home: z13.string().min(1).nullable(),
|
|
1295
1458
|
probe: ComputerProbeSchema.nullable()
|
|
1296
1459
|
});
|
|
1297
1460
|
var COMMAND_OUTPUT_CAP = 65536;
|
|
1298
|
-
var ComputerCommandSchema =
|
|
1461
|
+
var ComputerCommandSchema = z13.object({
|
|
1299
1462
|
id: idOf("cmd"),
|
|
1300
|
-
object:
|
|
1463
|
+
object: z13.literal("computer_command"),
|
|
1301
1464
|
computer_id: idOf("cmp"),
|
|
1302
|
-
command:
|
|
1303
|
-
exit_code:
|
|
1304
|
-
timed_out:
|
|
1305
|
-
duration_ms:
|
|
1306
|
-
stdout:
|
|
1307
|
-
stderr:
|
|
1308
|
-
truncated:
|
|
1465
|
+
command: z13.string(),
|
|
1466
|
+
exit_code: z13.number().int().nullable(),
|
|
1467
|
+
timed_out: z13.boolean(),
|
|
1468
|
+
duration_ms: z13.number().int().nonnegative(),
|
|
1469
|
+
stdout: z13.string().max(COMMAND_OUTPUT_CAP),
|
|
1470
|
+
stderr: z13.string().max(COMMAND_OUTPUT_CAP),
|
|
1471
|
+
truncated: z13.boolean(),
|
|
1309
1472
|
actor: PrincipalSchema,
|
|
1310
1473
|
created_at: Timestamp
|
|
1311
1474
|
});
|
|
1312
|
-
var ExecStreamFrameSchema =
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
exit:
|
|
1317
|
-
exit_code:
|
|
1318
|
-
timed_out:
|
|
1319
|
-
duration_ms:
|
|
1475
|
+
var ExecStreamFrameSchema = z13.union([
|
|
1476
|
+
z13.object({ stdout: z13.string() }),
|
|
1477
|
+
z13.object({ stderr: z13.string() }),
|
|
1478
|
+
z13.object({
|
|
1479
|
+
exit: z13.object({
|
|
1480
|
+
exit_code: z13.number().int().nullable(),
|
|
1481
|
+
timed_out: z13.boolean(),
|
|
1482
|
+
duration_ms: z13.number().int().nonnegative(),
|
|
1320
1483
|
command_id: idOf("cmd")
|
|
1321
1484
|
})
|
|
1322
1485
|
})
|
|
1323
1486
|
]);
|
|
1324
|
-
var FileEntryTypeSchema =
|
|
1325
|
-
var FileEntrySchema =
|
|
1326
|
-
name:
|
|
1327
|
-
path:
|
|
1487
|
+
var FileEntryTypeSchema = z13.enum(["file", "directory", "symlink", "other"]);
|
|
1488
|
+
var FileEntrySchema = z13.object({
|
|
1489
|
+
name: z13.string().min(1),
|
|
1490
|
+
path: z13.string().min(1),
|
|
1328
1491
|
type: FileEntryTypeSchema,
|
|
1329
|
-
size_bytes:
|
|
1492
|
+
size_bytes: z13.number().int().nonnegative(),
|
|
1330
1493
|
/** POSIX `st_mode`. */
|
|
1331
|
-
mode:
|
|
1494
|
+
mode: z13.number().int().nonnegative(),
|
|
1332
1495
|
modified_at: Timestamp.nullable()
|
|
1333
1496
|
});
|
|
1334
|
-
var ComputerUpdateSchema =
|
|
1335
|
-
var SkillSchema =
|
|
1497
|
+
var ComputerUpdateSchema = z13.strictObject({ name: z13.string().min(1).max(200) });
|
|
1498
|
+
var SkillSchema = z13.object({
|
|
1336
1499
|
id: idOf("skl"),
|
|
1337
|
-
object:
|
|
1338
|
-
name:
|
|
1339
|
-
description:
|
|
1340
|
-
latest_version:
|
|
1500
|
+
object: z13.literal("skill"),
|
|
1501
|
+
name: z13.string(),
|
|
1502
|
+
description: z13.string().nullable(),
|
|
1503
|
+
latest_version: z13.number().int().positive(),
|
|
1341
1504
|
created_at: Timestamp
|
|
1342
1505
|
});
|
|
1343
|
-
var ResolvedSkillRefSchema =
|
|
1506
|
+
var ResolvedSkillRefSchema = z13.object({
|
|
1344
1507
|
/** The reference exactly as the agent version wrote it: `slug` or `slug@N`. */
|
|
1345
|
-
ref:
|
|
1346
|
-
slug:
|
|
1347
|
-
version:
|
|
1348
|
-
description:
|
|
1349
|
-
storage_key:
|
|
1350
|
-
});
|
|
1351
|
-
var SkillVersionSchema =
|
|
1352
|
-
version:
|
|
1353
|
-
sha256:
|
|
1354
|
-
size_bytes:
|
|
1508
|
+
ref: z13.string().min(1),
|
|
1509
|
+
slug: z13.string().min(1),
|
|
1510
|
+
version: z13.number().int().positive(),
|
|
1511
|
+
description: z13.string(),
|
|
1512
|
+
storage_key: z13.string().min(1)
|
|
1513
|
+
});
|
|
1514
|
+
var SkillVersionSchema = z13.object({
|
|
1515
|
+
version: z13.number().int().positive(),
|
|
1516
|
+
sha256: z13.string().regex(/^[0-9a-f]{64}$/),
|
|
1517
|
+
size_bytes: z13.number().int().nonnegative(),
|
|
1355
1518
|
created_at: Timestamp
|
|
1356
1519
|
});
|
|
1357
|
-
var SkillCatalogEntrySchema =
|
|
1358
|
-
object:
|
|
1359
|
-
slug:
|
|
1360
|
-
version:
|
|
1361
|
-
name:
|
|
1362
|
-
description:
|
|
1363
|
-
tags:
|
|
1364
|
-
content_hash:
|
|
1520
|
+
var SkillCatalogEntrySchema = z13.object({
|
|
1521
|
+
object: z13.literal("skill_catalog_entry"),
|
|
1522
|
+
slug: z13.string().regex(/^[a-z0-9][a-z0-9-]*$/),
|
|
1523
|
+
version: z13.number().int().positive(),
|
|
1524
|
+
name: z13.string().min(1),
|
|
1525
|
+
description: z13.string(),
|
|
1526
|
+
tags: z13.array(z13.string().min(1)),
|
|
1527
|
+
content_hash: z13.string().regex(/^[0-9a-f]{64}$/),
|
|
1365
1528
|
published_at: Timestamp
|
|
1366
1529
|
});
|
|
1367
|
-
var SkillCatalogVersionSchema = SkillCatalogEntrySchema.extend({ content:
|
|
1368
|
-
var FileSchema =
|
|
1530
|
+
var SkillCatalogVersionSchema = SkillCatalogEntrySchema.extend({ content: z13.string() });
|
|
1531
|
+
var FileSchema = z13.object({
|
|
1369
1532
|
id: idOf("fil"),
|
|
1370
|
-
object:
|
|
1371
|
-
name:
|
|
1372
|
-
content_type:
|
|
1373
|
-
size_bytes:
|
|
1374
|
-
scope:
|
|
1533
|
+
object: z13.literal("file"),
|
|
1534
|
+
name: z13.string(),
|
|
1535
|
+
content_type: z13.string(),
|
|
1536
|
+
size_bytes: z13.number().int().nonnegative(),
|
|
1537
|
+
scope: z13.enum(["session", "published"]),
|
|
1375
1538
|
session_id: idOf("ses").nullable(),
|
|
1376
|
-
sha256:
|
|
1539
|
+
sha256: z13.string().regex(/^[0-9a-f]{64}$/),
|
|
1377
1540
|
created_at: Timestamp,
|
|
1378
1541
|
// The asset-library fields (`canonical-spec §36.1`), all nullable or defaulted.
|
|
1379
1542
|
...FileLibraryFieldsSchema.shape,
|
|
1380
1543
|
/** The agent of `session_id`, joined at read (§36.1, ADR-0887); a writer never sets it. */
|
|
1381
1544
|
agent_id: idOf("agt").nullable().optional()
|
|
1382
1545
|
});
|
|
1383
|
-
var ScheduleStatusSchema =
|
|
1384
|
-
var DeploymentSchema =
|
|
1546
|
+
var ScheduleStatusSchema = z13.enum(["scheduled", "paused", "unscheduled"]);
|
|
1547
|
+
var DeploymentSchema = z13.object({
|
|
1385
1548
|
id: idOf("dep"),
|
|
1386
|
-
object:
|
|
1549
|
+
object: z13.literal("deployment"),
|
|
1387
1550
|
agent_id: idOf("agt"),
|
|
1388
1551
|
/** A pin. `null` tracks the agent's `current_version` on every fire (§12). */
|
|
1389
|
-
agent_version:
|
|
1390
|
-
cron:
|
|
1552
|
+
agent_version: z13.number().int().positive().nullable(),
|
|
1553
|
+
cron: z13.string(),
|
|
1391
1554
|
/** IANA zone the `cron` is read in. "0 9 * * 1" means 09:00 *here*, across DST (ADR-0074). */
|
|
1392
|
-
timezone:
|
|
1393
|
-
input_template:
|
|
1555
|
+
timezone: z13.string(),
|
|
1556
|
+
input_template: z13.string(),
|
|
1394
1557
|
budget_micro_usd: MicroUsdField.nonnegative(),
|
|
1395
1558
|
window: WindowSchema,
|
|
1396
1559
|
/**
|
|
@@ -1400,21 +1563,21 @@ var DeploymentSchema = z12.object({
|
|
|
1400
1563
|
* those endpoints, and a signed delivery over cleartext is not a delivery. Until the push was
|
|
1401
1564
|
* wired this field went nowhere, so nothing can be relying on an `http://` value (ADR-0161).
|
|
1402
1565
|
*/
|
|
1403
|
-
on_idle:
|
|
1566
|
+
on_idle: z13.url().startsWith("https://", { error: "a webhook URL must be https" }).nullable(),
|
|
1404
1567
|
/**
|
|
1405
1568
|
* The persona every fire speaks as, or `null` to run as nobody (§22). Written as an `idn_` id
|
|
1406
1569
|
* **or** the persona's name, the way a session names one, and always echoed as the id: a fire at
|
|
1407
1570
|
* 3am must not be silenced by someone renaming the persona at noon.
|
|
1408
1571
|
*/
|
|
1409
1572
|
identity: idOf("idn").nullable(),
|
|
1410
|
-
enabled:
|
|
1573
|
+
enabled: z13.boolean(),
|
|
1411
1574
|
/** Derived per deploy, never stored — the row cannot know whether a clock is watching it. */
|
|
1412
1575
|
schedule_status: ScheduleStatusSchema,
|
|
1413
1576
|
/** The next fire, or `null` when nothing will fire it (`schedule_status` says which). */
|
|
1414
1577
|
next_run_at: Timestamp.nullable(),
|
|
1415
1578
|
created_at: Timestamp
|
|
1416
1579
|
});
|
|
1417
|
-
var DeploymentRunSchema =
|
|
1580
|
+
var DeploymentRunSchema = z13.object({
|
|
1418
1581
|
id: idOf("run"),
|
|
1419
1582
|
session_id: idOf("ses"),
|
|
1420
1583
|
status: SessionStatusSchema,
|
|
@@ -1422,62 +1585,62 @@ var DeploymentRunSchema = z12.object({
|
|
|
1422
1585
|
});
|
|
1423
1586
|
|
|
1424
1587
|
// ../core/src/schema/comms.ts
|
|
1425
|
-
import { z as
|
|
1426
|
-
var DomainKindSchema =
|
|
1427
|
-
var DomainStatusSchema =
|
|
1428
|
-
var DomainDnsStatusSchema =
|
|
1429
|
-
var DomainInboundStatusSchema =
|
|
1430
|
-
var DomainAppConnectStatusSchema =
|
|
1431
|
-
var DnsRecordSchema =
|
|
1432
|
-
type:
|
|
1433
|
-
host:
|
|
1434
|
-
value:
|
|
1435
|
-
priority:
|
|
1588
|
+
import { z as z14 } from "zod";
|
|
1589
|
+
var DomainKindSchema = z14.enum(["system", "external", "purchased"]);
|
|
1590
|
+
var DomainStatusSchema = z14.enum(["pending_dns", "active", "failed"]);
|
|
1591
|
+
var DomainDnsStatusSchema = z14.enum(["pending_verification", "provisioned", "failed"]);
|
|
1592
|
+
var DomainInboundStatusSchema = z14.enum(["pending", "verified", "failed"]);
|
|
1593
|
+
var DomainAppConnectStatusSchema = z14.enum(["pending", "connected", "failed"]);
|
|
1594
|
+
var DnsRecordSchema = z14.object({
|
|
1595
|
+
type: z14.enum(["TXT", "CNAME", "MX"]),
|
|
1596
|
+
host: z14.string(),
|
|
1597
|
+
value: z14.string(),
|
|
1598
|
+
priority: z14.number().int().nullable(),
|
|
1436
1599
|
/** Vetta owns this record: `_dmarc`, DKIM, inbound MX. The agent may read it, never write it. */
|
|
1437
|
-
managed:
|
|
1600
|
+
managed: z14.boolean()
|
|
1438
1601
|
});
|
|
1439
|
-
var DomainSchema =
|
|
1602
|
+
var DomainSchema = z14.object({
|
|
1440
1603
|
id: idOf("dom"),
|
|
1441
|
-
object:
|
|
1604
|
+
object: z14.literal("domain"),
|
|
1442
1605
|
/** A domain belongs to the **organization**, not to one identity: two identities share one. */
|
|
1443
|
-
name:
|
|
1606
|
+
name: z14.string(),
|
|
1444
1607
|
kind: DomainKindSchema,
|
|
1445
1608
|
status: DomainStatusSchema,
|
|
1446
1609
|
dns_status: DomainDnsStatusSchema,
|
|
1447
1610
|
inbound_status: DomainInboundStatusSchema,
|
|
1448
1611
|
app_connect_status: DomainAppConnectStatusSchema,
|
|
1449
|
-
records:
|
|
1612
|
+
records: z14.array(DnsRecordSchema),
|
|
1450
1613
|
last_verified_at: Timestamp.nullable(),
|
|
1451
1614
|
created_at: Timestamp
|
|
1452
1615
|
});
|
|
1453
|
-
var EmailInboxSchema =
|
|
1616
|
+
var EmailInboxSchema = z14.object({
|
|
1454
1617
|
id: idOf("eml"),
|
|
1455
|
-
object:
|
|
1618
|
+
object: z14.literal("email_inbox"),
|
|
1456
1619
|
identity_id: idOf("idn"),
|
|
1457
1620
|
domain_id: idOf("dom"),
|
|
1458
|
-
address:
|
|
1459
|
-
localpart:
|
|
1621
|
+
address: z14.string(),
|
|
1622
|
+
localpart: z14.string(),
|
|
1460
1623
|
/** Inbound routing keys off this: mail to the address wakes exactly this agent. */
|
|
1461
1624
|
owning_agent_id: idOf("agt"),
|
|
1462
|
-
status:
|
|
1625
|
+
status: z14.enum(["active", "disabled"]),
|
|
1463
1626
|
created_at: Timestamp
|
|
1464
1627
|
});
|
|
1465
|
-
var PhoneTierSchema =
|
|
1466
|
-
var BrandStatusSchema =
|
|
1467
|
-
var CampaignStatusSchema =
|
|
1468
|
-
var PhoneNumberSchema =
|
|
1628
|
+
var PhoneTierSchema = z14.enum(["sole_prop", "standard"]);
|
|
1629
|
+
var BrandStatusSchema = z14.enum(["none", "pending_verification", "verified", "rejected"]);
|
|
1630
|
+
var CampaignStatusSchema = z14.enum(["none", "pending", "approved", "rejected"]);
|
|
1631
|
+
var PhoneNumberSchema = z14.object({
|
|
1469
1632
|
id: idOf("pho"),
|
|
1470
|
-
object:
|
|
1633
|
+
object: z14.literal("phone_number"),
|
|
1471
1634
|
identity_id: idOf("idn"),
|
|
1472
|
-
e164:
|
|
1473
|
-
country:
|
|
1474
|
-
capabilities:
|
|
1635
|
+
e164: z14.string(),
|
|
1636
|
+
country: z14.string(),
|
|
1637
|
+
capabilities: z14.object({
|
|
1475
1638
|
/** Live the moment the number is bought — inbound never waits on carrier registration. */
|
|
1476
|
-
sms_inbound:
|
|
1639
|
+
sms_inbound: z14.boolean(),
|
|
1477
1640
|
/** True **iff** `campaign_status === "approved"`. Nothing else may set it. */
|
|
1478
|
-
sms_outbound:
|
|
1641
|
+
sms_outbound: z14.boolean(),
|
|
1479
1642
|
/** Voice is not a P2 capability; the field exists so its absence is explicit. */
|
|
1480
|
-
voice:
|
|
1643
|
+
voice: z14.literal(false)
|
|
1481
1644
|
}),
|
|
1482
1645
|
tier: PhoneTierSchema,
|
|
1483
1646
|
brand_status: BrandStatusSchema,
|
|
@@ -1485,19 +1648,19 @@ var PhoneNumberSchema = z13.object({
|
|
|
1485
1648
|
provisioned_at: Timestamp.nullable(),
|
|
1486
1649
|
created_at: Timestamp
|
|
1487
1650
|
});
|
|
1488
|
-
var InboundMessageSchema =
|
|
1651
|
+
var InboundMessageSchema = z14.object({
|
|
1489
1652
|
id: idOf("inb"),
|
|
1490
|
-
object:
|
|
1491
|
-
channel:
|
|
1653
|
+
object: z14.literal("inbound_message"),
|
|
1654
|
+
channel: z14.enum(["email", "sms"]),
|
|
1492
1655
|
identity_id: idOf("idn"),
|
|
1493
1656
|
/** The `eml_`/`pho_` endpoint it arrived at — the persona is decided by *where*, not by *who*. */
|
|
1494
|
-
endpoint_id:
|
|
1495
|
-
from:
|
|
1496
|
-
to:
|
|
1497
|
-
subject:
|
|
1498
|
-
text:
|
|
1657
|
+
endpoint_id: z14.string(),
|
|
1658
|
+
from: z14.string(),
|
|
1659
|
+
to: z14.string(),
|
|
1660
|
+
subject: z14.string().nullable(),
|
|
1661
|
+
text: z14.string(),
|
|
1499
1662
|
/** SPF/DKIM/DMARC for mail, carrier origin for SMS. Kept for the audit of why it was accepted. */
|
|
1500
|
-
auth:
|
|
1663
|
+
auth: z14.record(z14.string(), z14.string()),
|
|
1501
1664
|
/** The session this message woke. Null until the wake seam lands (see ADR-0120). */
|
|
1502
1665
|
session_id: idOf("ses").nullable(),
|
|
1503
1666
|
received_at: Timestamp,
|
|
@@ -1507,44 +1670,44 @@ var InboundMessageSchema = z13.object({
|
|
|
1507
1670
|
*/
|
|
1508
1671
|
read_at: Timestamp.nullable().default(null)
|
|
1509
1672
|
});
|
|
1510
|
-
var OutboundMessageSchema =
|
|
1673
|
+
var OutboundMessageSchema = z14.object({
|
|
1511
1674
|
id: idOf("out"),
|
|
1512
|
-
object:
|
|
1675
|
+
object: z14.literal("outbound_message"),
|
|
1513
1676
|
channel: InboundMessageSchema.shape.channel,
|
|
1514
1677
|
identity_id: idOf("idn"),
|
|
1515
1678
|
/** The `eml_` endpoint it was sent from. */
|
|
1516
|
-
endpoint_id:
|
|
1517
|
-
from:
|
|
1518
|
-
to:
|
|
1519
|
-
subject:
|
|
1520
|
-
text:
|
|
1679
|
+
endpoint_id: z14.string(),
|
|
1680
|
+
from: z14.string(),
|
|
1681
|
+
to: z14.array(z14.string()),
|
|
1682
|
+
subject: z14.string().nullable(),
|
|
1683
|
+
text: z14.string(),
|
|
1521
1684
|
sent_by_agent_id: idOf("agt").nullable(),
|
|
1522
1685
|
actor: PrincipalSchema.nullable(),
|
|
1523
1686
|
sent_at: Timestamp
|
|
1524
1687
|
});
|
|
1525
1688
|
|
|
1526
1689
|
// ../core/src/schema/app.ts
|
|
1527
|
-
import { z as
|
|
1528
|
-
var AppTypeSchema =
|
|
1529
|
-
var AppStatusSchema =
|
|
1530
|
-
var AppMcpPathSchema =
|
|
1531
|
-
var AppSchema =
|
|
1690
|
+
import { z as z15 } from "zod";
|
|
1691
|
+
var AppTypeSchema = z15.enum(["frontend_only", "fullstack"]);
|
|
1692
|
+
var AppStatusSchema = z15.enum(["provisioning", "active", "error"]);
|
|
1693
|
+
var AppMcpPathSchema = z15.string().regex(/^\/\S*$/, "must be an absolute path beginning with /").max(128);
|
|
1694
|
+
var AppSchema = z15.object({
|
|
1532
1695
|
id: idOf("app"),
|
|
1533
|
-
object:
|
|
1534
|
-
name:
|
|
1535
|
-
description:
|
|
1696
|
+
object: z15.literal("app"),
|
|
1697
|
+
name: z15.string(),
|
|
1698
|
+
description: z15.string().nullable(),
|
|
1536
1699
|
type: AppTypeSchema,
|
|
1537
1700
|
/**
|
|
1538
1701
|
* The customer's own project name that made this app, or `null` for one made outside a project
|
|
1539
1702
|
* (ADR-0375). Customer-visible, unlike the provider handles: it is the word the customer typed,
|
|
1540
1703
|
* and the refusal that guards a name quotes it.
|
|
1541
1704
|
*/
|
|
1542
|
-
project:
|
|
1705
|
+
project: z15.string().nullable(),
|
|
1543
1706
|
status: AppStatusSchema,
|
|
1544
1707
|
/** The address the app answers on — platform hostname until a custom domain connects. */
|
|
1545
|
-
url:
|
|
1708
|
+
url: z15.string().nullable(),
|
|
1546
1709
|
/** White-label words when `status` is `error`; never the provider's. */
|
|
1547
|
-
error:
|
|
1710
|
+
error: z15.string().nullable(),
|
|
1548
1711
|
/** Where the app serves MCP, or `null`. The bearer token for it is a server column. */
|
|
1549
1712
|
mcp: AppMcpPathSchema.nullable(),
|
|
1550
1713
|
/**
|
|
@@ -1552,80 +1715,80 @@ var AppSchema = z14.object({
|
|
|
1552
1715
|
* than linking its `url` (`§29.1`)? True when the platform holds the app's `DASHBOARD_TOKEN`
|
|
1553
1716
|
* or a secret of that name exists on the app; derived on read, never stored.
|
|
1554
1717
|
*/
|
|
1555
|
-
dashboard:
|
|
1718
|
+
dashboard: z15.boolean(),
|
|
1556
1719
|
created_at: Timestamp
|
|
1557
1720
|
});
|
|
1558
|
-
var AppDeploymentStatusSchema =
|
|
1559
|
-
var AppDeploymentSchema =
|
|
1721
|
+
var AppDeploymentStatusSchema = z15.enum(["queued", "building", "ready", "error"]);
|
|
1722
|
+
var AppDeploymentSchema = z15.object({
|
|
1560
1723
|
id: idOf("apd"),
|
|
1561
|
-
object:
|
|
1724
|
+
object: z15.literal("app_deployment"),
|
|
1562
1725
|
app_id: idOf("app"),
|
|
1563
1726
|
status: AppDeploymentStatusSchema,
|
|
1564
|
-
url:
|
|
1565
|
-
error:
|
|
1727
|
+
url: z15.string().nullable(),
|
|
1728
|
+
error: z15.string().nullable(),
|
|
1566
1729
|
/** The client's opaque digest of the files, echoed verbatim so it can skip an unchanged deploy. */
|
|
1567
|
-
content_hash:
|
|
1730
|
+
content_hash: z15.string().nullable(),
|
|
1568
1731
|
created_at: Timestamp
|
|
1569
1732
|
});
|
|
1570
|
-
var AppDeploymentFilesSchema =
|
|
1571
|
-
object:
|
|
1733
|
+
var AppDeploymentFilesSchema = z15.object({
|
|
1734
|
+
object: z15.literal("app_deployment_files"),
|
|
1572
1735
|
deployment_id: idOf("apd"),
|
|
1573
|
-
files:
|
|
1736
|
+
files: z15.record(z15.string().min(1), z15.string())
|
|
1574
1737
|
});
|
|
1575
|
-
var AppSecretSchema =
|
|
1576
|
-
object:
|
|
1577
|
-
name:
|
|
1738
|
+
var AppSecretSchema = z15.object({
|
|
1739
|
+
object: z15.literal("app_secret"),
|
|
1740
|
+
name: z15.string(),
|
|
1578
1741
|
/** The client's opaque digest of the value, echoed verbatim so it can skip an unchanged write. */
|
|
1579
|
-
value_hash:
|
|
1742
|
+
value_hash: z15.string().nullable(),
|
|
1580
1743
|
created_at: Timestamp
|
|
1581
1744
|
});
|
|
1582
|
-
var AppEntrySchema =
|
|
1583
|
-
object:
|
|
1584
|
-
url:
|
|
1585
|
-
ticket:
|
|
1745
|
+
var AppEntrySchema = z15.object({
|
|
1746
|
+
object: z15.literal("app_entry"),
|
|
1747
|
+
url: z15.string(),
|
|
1748
|
+
ticket: z15.string()
|
|
1586
1749
|
});
|
|
1587
|
-
var AppAccessSchema =
|
|
1588
|
-
object:
|
|
1589
|
-
url:
|
|
1590
|
-
password:
|
|
1750
|
+
var AppAccessSchema = z15.object({
|
|
1751
|
+
object: z15.literal("app_access"),
|
|
1752
|
+
url: z15.string().nullable(),
|
|
1753
|
+
password: z15.string().nullable()
|
|
1591
1754
|
});
|
|
1592
|
-
var AppDomainStatusSchema =
|
|
1593
|
-
var AppDomainSchema =
|
|
1594
|
-
object:
|
|
1755
|
+
var AppDomainStatusSchema = z15.enum(["pending", "connected", "failed"]);
|
|
1756
|
+
var AppDomainSchema = z15.object({
|
|
1757
|
+
object: z15.literal("app_domain"),
|
|
1595
1758
|
app_id: idOf("app"),
|
|
1596
1759
|
domain_id: idOf("dom"),
|
|
1597
|
-
domain:
|
|
1760
|
+
domain: z15.string(),
|
|
1598
1761
|
status: AppDomainStatusSchema,
|
|
1599
1762
|
created_at: Timestamp
|
|
1600
1763
|
});
|
|
1601
1764
|
var ENV_NAME = /^[A-Z_][A-Z0-9_]*$/;
|
|
1602
1765
|
var APP_NAME = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
1603
|
-
var AppPermissionsSchema =
|
|
1604
|
-
object:
|
|
1766
|
+
var AppPermissionsSchema = z15.object({
|
|
1767
|
+
object: z15.literal("app_permissions"),
|
|
1605
1768
|
app_id: idOf("app"),
|
|
1606
|
-
scopes:
|
|
1769
|
+
scopes: z15.array(z15.string())
|
|
1607
1770
|
});
|
|
1608
1771
|
|
|
1609
1772
|
// ../core/src/schema/install.ts
|
|
1610
|
-
import { z as
|
|
1611
|
-
var BlueprintInstallSourceSchema =
|
|
1612
|
-
var BlueprintInstallStatusSchema =
|
|
1613
|
-
var ResourceActionSchema =
|
|
1614
|
-
var ResourceReportSchema =
|
|
1615
|
-
name:
|
|
1773
|
+
import { z as z16 } from "zod";
|
|
1774
|
+
var BlueprintInstallSourceSchema = z16.enum(["studio", "cli"]);
|
|
1775
|
+
var BlueprintInstallStatusSchema = z16.enum(["pending", "applied", "failed"]);
|
|
1776
|
+
var ResourceActionSchema = z16.enum(["created", "updated", "unchanged", "deleted", "refused"]);
|
|
1777
|
+
var ResourceReportSchema = z16.object({
|
|
1778
|
+
name: z16.string().min(1),
|
|
1616
1779
|
action: ResourceActionSchema,
|
|
1617
1780
|
/** The `agt_`/`app_`/`ses_`… the line resolved to. Absent on a refusal that never got an id. */
|
|
1618
|
-
id:
|
|
1781
|
+
id: z16.string().optional(),
|
|
1619
1782
|
/** An app's hostname once its build went live; `null` while it has none. Apps only. */
|
|
1620
|
-
url:
|
|
1783
|
+
url: z16.string().nullable().optional(),
|
|
1621
1784
|
/**
|
|
1622
1785
|
* What a TASK is called and who owes it. `name` is the declaration key (`first-render`), which is
|
|
1623
1786
|
* how a re-apply finds the same card and is not a sentence anybody wants read to them. The
|
|
1624
1787
|
* dashboard's opening message lists the team's work, so it needs the title the board shows and the
|
|
1625
1788
|
* seat that holds it. Tasks only.
|
|
1626
1789
|
*/
|
|
1627
|
-
title:
|
|
1628
|
-
assignee:
|
|
1790
|
+
title: z16.string().optional(),
|
|
1791
|
+
assignee: z16.string().optional(),
|
|
1629
1792
|
/**
|
|
1630
1793
|
* A SCHEDULE'S brief, in one short line — the opening sentence of its `input_template`. A
|
|
1631
1794
|
* schedules line is named `<agent> @ <cron>`, which says when something runs and nothing at all
|
|
@@ -1633,50 +1796,50 @@ var ResourceReportSchema = z15.object({
|
|
|
1633
1796
|
* Written here rather than read back from the deployment so the receipt stays the one read the
|
|
1634
1797
|
* welcome needs. Schedules only.
|
|
1635
1798
|
*/
|
|
1636
|
-
summary:
|
|
1637
|
-
reason:
|
|
1638
|
-
});
|
|
1639
|
-
var BlueprintReportSchema =
|
|
1640
|
-
skills:
|
|
1641
|
-
identities:
|
|
1642
|
-
vaults:
|
|
1643
|
-
apps:
|
|
1644
|
-
agents:
|
|
1645
|
-
schedules:
|
|
1646
|
-
intake:
|
|
1799
|
+
summary: z16.string().optional(),
|
|
1800
|
+
reason: z16.string().optional()
|
|
1801
|
+
});
|
|
1802
|
+
var BlueprintReportSchema = z16.object({
|
|
1803
|
+
skills: z16.array(ResourceReportSchema),
|
|
1804
|
+
identities: z16.array(ResourceReportSchema),
|
|
1805
|
+
vaults: z16.array(ResourceReportSchema),
|
|
1806
|
+
apps: z16.array(ResourceReportSchema),
|
|
1807
|
+
agents: z16.array(ResourceReportSchema),
|
|
1808
|
+
schedules: z16.array(ResourceReportSchema),
|
|
1809
|
+
intake: z16.array(ResourceReportSchema),
|
|
1647
1810
|
/** One line per declared task (§31.11), `id` the card's `crd_`. Defaulted so older rows parse. */
|
|
1648
|
-
tasks:
|
|
1649
|
-
skipped:
|
|
1650
|
-
deselected:
|
|
1811
|
+
tasks: z16.array(ResourceReportSchema).default([]),
|
|
1812
|
+
skipped: z16.array(z16.string()),
|
|
1813
|
+
deselected: z16.array(z16.string()).default([])
|
|
1651
1814
|
});
|
|
1652
|
-
var BlueprintSelectionSchema =
|
|
1653
|
-
agents:
|
|
1654
|
-
apps:
|
|
1815
|
+
var BlueprintSelectionSchema = z16.object({
|
|
1816
|
+
agents: z16.array(z16.string().min(1)),
|
|
1817
|
+
apps: z16.array(z16.string().min(1))
|
|
1655
1818
|
});
|
|
1656
|
-
var BlueprintInstallSchema =
|
|
1819
|
+
var BlueprintInstallSchema = z16.object({
|
|
1657
1820
|
id: idOf("bpi"),
|
|
1658
|
-
object:
|
|
1821
|
+
object: z16.literal("blueprint_install"),
|
|
1659
1822
|
/** The customer's own `defineProject({ name })` — the same word `app.project` stamps (§29.2). */
|
|
1660
|
-
project:
|
|
1823
|
+
project: z16.string().min(1),
|
|
1661
1824
|
/** The pair the declaration resolved to; `null` for a declaration that names no blueprint. */
|
|
1662
|
-
blueprint:
|
|
1663
|
-
template:
|
|
1825
|
+
blueprint: z16.string().nullable(),
|
|
1826
|
+
template: z16.string().nullable(),
|
|
1664
1827
|
/**
|
|
1665
1828
|
* Applies, not versions of anything: 1 on the first apply, +1 on each one after, whichever writer
|
|
1666
1829
|
* made it. It is not an agent version and it never rolls back.
|
|
1667
1830
|
*/
|
|
1668
|
-
revision:
|
|
1831
|
+
revision: z16.number().int().positive(),
|
|
1669
1832
|
/**
|
|
1670
1833
|
* The blueprint artifact version this came from, or `null` when it was applied from a working
|
|
1671
1834
|
* tree — an operator editing a clone has no version to name.
|
|
1672
1835
|
*/
|
|
1673
|
-
artifact_version:
|
|
1836
|
+
artifact_version: z16.string().nullable(),
|
|
1674
1837
|
/**
|
|
1675
1838
|
* The setup answers this project was configured with (§7.1 fields, keyed by their `key`), so a
|
|
1676
1839
|
* re-apply does not re-ask and both writers configure from the same answers. Configuration only:
|
|
1677
1840
|
* a secret is a vault credential (§23) or an app secret (§29.2), and neither is ever an answer.
|
|
1678
1841
|
*/
|
|
1679
|
-
answers:
|
|
1842
|
+
answers: z16.record(z16.string(), z16.unknown()),
|
|
1680
1843
|
/**
|
|
1681
1844
|
* NO `declaration` ON THE WIRE, and that is the reconciliation of §29.6 with §31.1.
|
|
1682
1845
|
*
|
|
@@ -1708,7 +1871,7 @@ var BlueprintInstallSchema = z15.object({
|
|
|
1708
1871
|
* Why a `failed` run threw, in one sentence — or, on an `applied` row, which `required` agent or
|
|
1709
1872
|
* app the apply refused and why (§29.6). `null` otherwise. Never a stack or a key.
|
|
1710
1873
|
*/
|
|
1711
|
-
failure:
|
|
1874
|
+
failure: z16.string().nullable(),
|
|
1712
1875
|
/**
|
|
1713
1876
|
* The `selection` the apply carried, or `null` — every row written before §31.2 and every apply
|
|
1714
1877
|
* that omitted it, both meaning "everything". Defaulted so those rows parse unchanged.
|
|
@@ -1716,152 +1879,37 @@ var BlueprintInstallSchema = z15.object({
|
|
|
1716
1879
|
selection: BlueprintSelectionSchema.nullable().default(null),
|
|
1717
1880
|
/** When the answers were last edited through `PATCH …/installs/{id}` (§31.8); `null` if never. */
|
|
1718
1881
|
context_updated_at: Timestamp.nullable().default(null),
|
|
1882
|
+
/**
|
|
1883
|
+
* What this install's agent, app, identity and vault names start with (§29.6, ADR-1104): `""`
|
|
1884
|
+
* when its template's names were free in the organization, `"<project>-"` when any was already
|
|
1885
|
+
* another project's. Decided once, by the apply that created the row, and never again. `null` is
|
|
1886
|
+
* an install from before that rule, or one a working tree recorded: its names are the template's.
|
|
1887
|
+
* Optional only so a Worker from before the field still parses; this API always sends it.
|
|
1888
|
+
*/
|
|
1889
|
+
name_prefix: z16.string().nullable().optional(),
|
|
1719
1890
|
applied_at: Timestamp,
|
|
1720
1891
|
created_at: Timestamp
|
|
1721
1892
|
});
|
|
1722
|
-
var ProjectContextAnswerSchema =
|
|
1723
|
-
key:
|
|
1724
|
-
label:
|
|
1725
|
-
value:
|
|
1726
|
-
});
|
|
1727
|
-
var ProjectContextSchema =
|
|
1728
|
-
object:
|
|
1729
|
-
project:
|
|
1730
|
-
blueprint:
|
|
1731
|
-
template:
|
|
1732
|
-
artifact_version:
|
|
1733
|
-
answers:
|
|
1734
|
-
apps:
|
|
1735
|
-
agents:
|
|
1893
|
+
var ProjectContextAnswerSchema = z16.object({
|
|
1894
|
+
key: z16.string().min(1),
|
|
1895
|
+
label: z16.string(),
|
|
1896
|
+
value: z16.union([z16.string(), z16.array(z16.string())])
|
|
1897
|
+
});
|
|
1898
|
+
var ProjectContextSchema = z16.object({
|
|
1899
|
+
object: z16.literal("project_context"),
|
|
1900
|
+
project: z16.string().min(1),
|
|
1901
|
+
blueprint: z16.string().nullable(),
|
|
1902
|
+
template: z16.string().nullable(),
|
|
1903
|
+
artifact_version: z16.string().nullable(),
|
|
1904
|
+
answers: z16.array(ProjectContextAnswerSchema),
|
|
1905
|
+
apps: z16.array(z16.object({ name: z16.string().min(1), url: z16.string().nullable() })),
|
|
1906
|
+
agents: z16.array(z16.object({ name: z16.string().min(1), role: z16.string().nullable() })),
|
|
1736
1907
|
/** `context_updated_at` once the answers have been edited, `applied_at` until then. */
|
|
1737
1908
|
updated_at: Timestamp
|
|
1738
1909
|
});
|
|
1739
1910
|
|
|
1740
1911
|
// ../core/src/schema/blueprint.ts
|
|
1741
1912
|
import { z as z17 } from "zod";
|
|
1742
|
-
|
|
1743
|
-
// ../core/src/schema/social.ts
|
|
1744
|
-
import { z as z16 } from "zod";
|
|
1745
|
-
var SOCIAL_PLATFORMS = [
|
|
1746
|
-
"bluesky",
|
|
1747
|
-
"facebook",
|
|
1748
|
-
"instagram",
|
|
1749
|
-
"linkedin",
|
|
1750
|
-
"mastodon",
|
|
1751
|
-
"pinterest",
|
|
1752
|
-
"reddit",
|
|
1753
|
-
"threads",
|
|
1754
|
-
"tiktok",
|
|
1755
|
-
"x",
|
|
1756
|
-
"youtube"
|
|
1757
|
-
];
|
|
1758
|
-
var SOCIAL_APPS = /* @__PURE__ */ new Set([...SOCIAL_PLATFORMS, "twitter"]);
|
|
1759
|
-
var SOCIAL_TEXT_PLATFORMS = [
|
|
1760
|
-
"bluesky",
|
|
1761
|
-
"facebook",
|
|
1762
|
-
"linkedin",
|
|
1763
|
-
"mastodon",
|
|
1764
|
-
"threads",
|
|
1765
|
-
"x"
|
|
1766
|
-
];
|
|
1767
|
-
var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
|
|
1768
|
-
var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
|
|
1769
|
-
var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
|
|
1770
|
-
var SocialVisibilitySchema = z16.enum(SOCIAL_VISIBILITIES);
|
|
1771
|
-
var SOCIAL_VISIBILITY_RULE = `visibility is ${SOCIAL_VISIBILITIES.join(", ")} and only ${SOCIAL_VISIBILITY_PLATFORMS.join(" and ")} accept it; omit it and the post publishes at the account's own default, which on a video channel is normally public`;
|
|
1772
|
-
var SocialPlatformSchema = z16.enum(SOCIAL_PLATFORMS);
|
|
1773
|
-
var SocialTextPlatformSchema = z16.enum(SOCIAL_TEXT_PLATFORMS);
|
|
1774
|
-
var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
|
|
1775
|
-
var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
|
|
1776
|
-
var SOCIAL_PLATFORM_RULE = `${SOCIAL_TEXT_PLATFORMS.join(", ")} take a text-only post; ${SOCIAL_MEDIA_PLATFORMS.join(", ")} may be named only when the post carries media_urls or file_ids; ${SOCIAL_PLATFORMS.filter((platform) => !isText(platform) && !isMedia(platform)).join(", ")} cannot be posted to`;
|
|
1777
|
-
var SocialAccountSchema = z16.object({
|
|
1778
|
-
id: z16.string().min(1),
|
|
1779
|
-
object: z16.literal("social_account"),
|
|
1780
|
-
identity_id: idOf("idn"),
|
|
1781
|
-
platform: SocialPlatformSchema,
|
|
1782
|
-
username: z16.string().nullable(),
|
|
1783
|
-
display_name: z16.string().nullable(),
|
|
1784
|
-
avatar_url: z16.url().nullable(),
|
|
1785
|
-
connected_at: Timestamp.nullable()
|
|
1786
|
-
});
|
|
1787
|
-
var SocialPostStatusSchema = z16.enum([
|
|
1788
|
-
"draft",
|
|
1789
|
-
"scheduled",
|
|
1790
|
-
"processing",
|
|
1791
|
-
"posted",
|
|
1792
|
-
"failed",
|
|
1793
|
-
"deleted"
|
|
1794
|
-
]);
|
|
1795
|
-
var SocialPostSchema = z16.object({
|
|
1796
|
-
id: z16.string().min(1),
|
|
1797
|
-
object: z16.literal("social_post"),
|
|
1798
|
-
identity_id: idOf("idn"),
|
|
1799
|
-
title: z16.string(),
|
|
1800
|
-
platforms: z16.array(SocialPlatformSchema),
|
|
1801
|
-
status: SocialPostStatusSchema,
|
|
1802
|
-
scheduled_at: Timestamp.nullable(),
|
|
1803
|
-
posted_at: Timestamp.nullable(),
|
|
1804
|
-
error: z16.string().nullable()
|
|
1805
|
-
});
|
|
1806
|
-
var SocialUploadSchema = z16.object({
|
|
1807
|
-
id: z16.string().min(1),
|
|
1808
|
-
object: z16.literal("social_upload"),
|
|
1809
|
-
identity_id: idOf("idn"),
|
|
1810
|
-
type: z16.enum(["image", "video", "document"]),
|
|
1811
|
-
url: z16.url().nullable()
|
|
1812
|
-
});
|
|
1813
|
-
var SocialAnalyticsSchema = z16.object({
|
|
1814
|
-
object: z16.literal("social_analytics"),
|
|
1815
|
-
identity_id: idOf("idn"),
|
|
1816
|
-
resource_id: z16.string().min(1),
|
|
1817
|
-
platform: SocialPlatformSchema.nullable(),
|
|
1818
|
-
data: z16.unknown()
|
|
1819
|
-
});
|
|
1820
|
-
var SocialCommentSchema = z16.object({
|
|
1821
|
-
id: z16.string().min(1),
|
|
1822
|
-
object: z16.literal("social_comment"),
|
|
1823
|
-
identity_id: idOf("idn"),
|
|
1824
|
-
post_id: z16.string().min(1),
|
|
1825
|
-
platforms: z16.array(SocialPlatformSchema),
|
|
1826
|
-
status: SocialPostStatusSchema,
|
|
1827
|
-
posted_at: Timestamp.nullable(),
|
|
1828
|
-
data: z16.unknown()
|
|
1829
|
-
});
|
|
1830
|
-
var POST_STATUSES = ["pending", "scheduled", "posted", "failed"];
|
|
1831
|
-
var PostStatusSchema = z16.enum(POST_STATUSES);
|
|
1832
|
-
var PostSchema = z16.object({
|
|
1833
|
-
object: z16.literal("post"),
|
|
1834
|
-
id: z16.string().min(1),
|
|
1835
|
-
status: PostStatusSchema,
|
|
1836
|
-
identity_id: z16.string().nullable(),
|
|
1837
|
-
agent_id: z16.string().nullable(),
|
|
1838
|
-
session_id: z16.string().nullable(),
|
|
1839
|
-
tool_call_id: z16.string().nullable(),
|
|
1840
|
-
content: z16.string().nullable(),
|
|
1841
|
-
platforms: z16.array(z16.string()),
|
|
1842
|
-
file_ids: z16.array(z16.string()),
|
|
1843
|
-
media_urls: z16.array(z16.string()),
|
|
1844
|
-
visibility: SocialVisibilitySchema.nullable(),
|
|
1845
|
-
scheduled_at: Timestamp.nullable(),
|
|
1846
|
-
posted_at: Timestamp.nullable(),
|
|
1847
|
-
url: z16.string().nullable(),
|
|
1848
|
-
error: z16.string().nullable(),
|
|
1849
|
-
/** The latest stored reading, `{metric: value}`; `null` before `social.post_metrics` read any. */
|
|
1850
|
-
metrics: z16.record(z16.string(), z16.number()).nullable(),
|
|
1851
|
-
measured_at: Timestamp.nullable(),
|
|
1852
|
-
/** Pending only: the earlier post this call would repeat — same identity, network and file. */
|
|
1853
|
-
duplicate_of: z16.object({
|
|
1854
|
-
id: z16.string(),
|
|
1855
|
-
status: PostStatusSchema,
|
|
1856
|
-
platform: z16.string(),
|
|
1857
|
-
at: Timestamp.nullable(),
|
|
1858
|
-
agent_id: z16.string().nullable(),
|
|
1859
|
-
session_id: z16.string().nullable()
|
|
1860
|
-
}).nullable(),
|
|
1861
|
-
created_at: Timestamp
|
|
1862
|
-
});
|
|
1863
|
-
|
|
1864
|
-
// ../core/src/schema/blueprint.ts
|
|
1865
1913
|
var BlueprintScheduleSchema = z17.object({
|
|
1866
1914
|
agent: z17.string().min(1),
|
|
1867
1915
|
cron: z17.string().min(1),
|
|
@@ -1978,6 +2026,13 @@ var VaultCredentialSchema = z18.object({
|
|
|
1978
2026
|
host: z18.string().nullable(),
|
|
1979
2027
|
/** The exact MCP server URL an `mcp_*` token is matched to. */
|
|
1980
2028
|
mcp_server_url: z18.url().nullable(),
|
|
2029
|
+
/**
|
|
2030
|
+
* The one agent this credential may be injected into (ADR-1097). `null` is any agent that
|
|
2031
|
+
* declares `mcp_server_url` — except the platform's own `/v1/mcp`, whose key is never injected
|
|
2032
|
+
* unbound. Set at create, by `admin`, and immutable like the rest. Defaults to `null` so a
|
|
2033
|
+
* client reading a control plane older than the field still parses the row.
|
|
2034
|
+
*/
|
|
2035
|
+
agent_id: idOf("agt").nullable().default(null),
|
|
1981
2036
|
placeholder_ref: z18.string(),
|
|
1982
2037
|
expires_at: Timestamp.nullable(),
|
|
1983
2038
|
last_injected_at: Timestamp.nullable(),
|
|
@@ -2025,7 +2080,12 @@ var SessionHandoffSchema = z19.object({
|
|
|
2025
2080
|
var ChannelBriefSchema = z19.object({
|
|
2026
2081
|
root_session_id: idOf("ses"),
|
|
2027
2082
|
name: z19.string().min(1),
|
|
2028
|
-
members: z19.array(z19.string().min(1))
|
|
2083
|
+
members: z19.array(z19.string().min(1)),
|
|
2084
|
+
/**
|
|
2085
|
+
* The receiver's own name, so it can tell the part of a post addressed to it from a teammate's
|
|
2086
|
+
* (ADR-1099). Optional: a brief pinned before it existed still parses.
|
|
2087
|
+
*/
|
|
2088
|
+
you: z19.string().min(1).optional()
|
|
2029
2089
|
});
|
|
2030
2090
|
var ChannelPostRequestSchema = z19.object({
|
|
2031
2091
|
message: z19.string().min(1).max(2e4)
|
|
@@ -3235,6 +3295,10 @@ var MiniAppSchema = MiniAppSummarySchema.extend({
|
|
|
3235
3295
|
spec: ResolvedPageSpecSchema
|
|
3236
3296
|
});
|
|
3237
3297
|
|
|
3298
|
+
// ../core/src/session-token.ts
|
|
3299
|
+
var SESSION_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
3300
|
+
var encoder = new TextEncoder();
|
|
3301
|
+
|
|
3238
3302
|
// ../core/src/logo-svg.ts
|
|
3239
3303
|
var MAX_BYTES = 16 * 1024;
|
|
3240
3304
|
|
|
@@ -3394,8 +3458,14 @@ var BLUEPRINTS = {
|
|
|
3394
3458
|
* Post queue, accounts, calendar, analytics. The wire ids are frozen: `install.template` is a
|
|
3395
3459
|
* stored string on every provisioned org, so the display names moved ("Naive Short Form v1",
|
|
3396
3460
|
* "Naive Long Form v1", "Naive Clipping v1") and these did not.
|
|
3461
|
+
*
|
|
3462
|
+
* The first three are the base crews. The six after them are NICHE CHANNEL TEMPLATES (ADR-1115,
|
|
3463
|
+
* ADR-1119): each is a thin template that reuses a base crew (`gaming-clips`/`news`/`sports` on
|
|
3464
|
+
* `clipping`; `ufc`/`history`/`animal-feast` on `faceless`) and pins `naive/channel-template-<niche>`
|
|
3465
|
+
* in every seat's `skills[]`. They are ordinary templates of this blueprint, so they publish, install
|
|
3466
|
+
* and switch through the exact paths the base three do — the whole point of a template being data.
|
|
3397
3467
|
*/
|
|
3398
|
-
media: { templates: ["faceless", "longform", "clipping"] },
|
|
3468
|
+
media: { templates: ["faceless", "longform", "clipping", "gaming-clips", "news", "sports", "ufc", "history", "animal-feast"] },
|
|
3399
3469
|
/** Pages, posts, forms, analytics — a published site with a crew behind it (`usenaive/web-blueprint`). */
|
|
3400
3470
|
web: { templates: ["publisher"], default: "publisher" }
|
|
3401
3471
|
};
|
|
@@ -4203,7 +4273,7 @@ function desiredMetadata(decl, of, current) {
|
|
|
4203
4273
|
project: of.project,
|
|
4204
4274
|
...of.blueprint !== void 0 ? { blueprint: of.blueprint } : {},
|
|
4205
4275
|
template: of.template,
|
|
4206
|
-
group: of.template
|
|
4276
|
+
group: of.group ?? of.template
|
|
4207
4277
|
};
|
|
4208
4278
|
}
|
|
4209
4279
|
function desiredSystem(decl, of) {
|
|
@@ -4247,14 +4317,14 @@ async function createAgent(client, decl, tools, team, identityId, system, metada
|
|
|
4247
4317
|
if (identityId !== void 0) await client.identities.attach(created.id, identityId);
|
|
4248
4318
|
return { name: decl.name, action: "created", id: created.id };
|
|
4249
4319
|
}
|
|
4250
|
-
async function upsertAgent(client, decl, existing, ids, dryRun,
|
|
4320
|
+
async function upsertAgent(client, decl, existing, ids, dryRun, scoped2, of) {
|
|
4251
4321
|
const unresolved = (decl.allowed_apps ?? []).filter((name) => !ids.apps.has(name));
|
|
4252
4322
|
const identityId = decl.identity === void 0 ? void 0 : ids.identities.get(decl.identity);
|
|
4253
4323
|
const missing = unresolved.length > 0 ? `allowed_apps needs app "${unresolved[0]}"` : decl.identity !== void 0 && identityId === void 0 ? `identity needs "${decl.identity}"` : null;
|
|
4254
4324
|
if (missing !== null && !dryRun) {
|
|
4255
4325
|
return { name: decl.name, action: "refused", reason: `${missing}, which was not provisioned in this run` };
|
|
4256
4326
|
}
|
|
4257
|
-
const appIds = decl.allowed_apps !== void 0 ? decl.allowed_apps.flatMap((name) => ids.apps.get(name) ?? []) :
|
|
4327
|
+
const appIds = decl.allowed_apps !== void 0 ? decl.allowed_apps.flatMap((name) => ids.apps.get(name) ?? []) : scoped2;
|
|
4258
4328
|
const current = existing.find((agent) => agent.name === decl.name) ?? null;
|
|
4259
4329
|
const owner = typeof current?.metadata?.["project"] === "string" ? current.metadata["project"] : null;
|
|
4260
4330
|
if (current && of.template !== void 0 && owner !== null && owner !== of.project && !of.adopt) {
|
|
@@ -4352,6 +4422,7 @@ async function reconcileSchedules(client, agent, declared, live, identityIds, dr
|
|
|
4352
4422
|
summary: brief(decl.input)
|
|
4353
4423
|
}))
|
|
4354
4424
|
);
|
|
4425
|
+
if (agent.action === "refused") return;
|
|
4355
4426
|
for (const row of rows.filter((row2) => !declared.some((decl) => decl.cron === row2.cron))) {
|
|
4356
4427
|
const name = `${agent.name} @ ${row.cron}`;
|
|
4357
4428
|
await attempt(into, name, () => tombstone(name, row, (id) => client.deployments.delete(id), dryRun));
|
|
@@ -4672,17 +4743,22 @@ async function upsertSkill(client, decl, opts) {
|
|
|
4672
4743
|
const pushed = await client.skills.push({ slug: decl.slug, content, sha256 });
|
|
4673
4744
|
return { name: decl.slug, action, id: pushed.id };
|
|
4674
4745
|
}
|
|
4675
|
-
async function upsertIdentity(client, decl, dryRun, identityIds) {
|
|
4746
|
+
async function upsertIdentity(client, decl, dryRun, identityIds, owner) {
|
|
4676
4747
|
const current = await absent(client.identities.get(decl.name));
|
|
4677
4748
|
if (!current) {
|
|
4678
4749
|
if (dryRun) return { name: decl.name, action: "created" };
|
|
4679
4750
|
const created = await client.identities.create({
|
|
4680
4751
|
name: decl.name,
|
|
4681
|
-
...decl.description !== void 0 ? { description: decl.description } : {}
|
|
4752
|
+
...decl.description !== void 0 ? { description: decl.description } : {},
|
|
4753
|
+
...owner !== void 0 ? { metadata: { project: owner } } : {}
|
|
4682
4754
|
});
|
|
4683
4755
|
identityIds.set(decl.name, created.id);
|
|
4684
4756
|
return { name: decl.name, action: "created", id: created.id };
|
|
4685
4757
|
}
|
|
4758
|
+
const held = typeof current.metadata["project"] === "string" ? current.metadata["project"] : null;
|
|
4759
|
+
if (owner !== void 0 && held !== owner) {
|
|
4760
|
+
return { name: decl.name, action: "refused", id: current.id, reason: ownershipRefusal(decl.name, owner, held, "identity") };
|
|
4761
|
+
}
|
|
4686
4762
|
identityIds.set(decl.name, current.id);
|
|
4687
4763
|
const drifted = decl.description !== void 0 && decl.description !== current.description;
|
|
4688
4764
|
if (drifted && !dryRun) await client.identities.update(current.id, { description: decl.description ?? null });
|
|
@@ -4745,12 +4821,14 @@ async function up(config, client, opts = {}) {
|
|
|
4745
4821
|
const taken = selectCrew(config, opts.select);
|
|
4746
4822
|
const report2 = { dry_run: dryRun, ...applied(config), skills: [], identities: [], vaults: [], apps: [], agents: [], schedules: [], intake: [], tasks: [], skipped: [], deselected: taken.deselected };
|
|
4747
4823
|
const owner = { project: config.name, adopt: opts.adopt ?? false, skipped: report2.skipped };
|
|
4824
|
+
const project = opts.project ?? config.name;
|
|
4825
|
+
const isolated = opts.isolated === true ? project : void 0;
|
|
4748
4826
|
const hosted = opts.trees !== void 0;
|
|
4749
4827
|
for (const decl of config.skills) {
|
|
4750
4828
|
await attempt(report2.skills, decl.slug, () => upsertSkill(client, decl, { dryRun, dir, hosted, skills: opts.skills ?? {} }));
|
|
4751
4829
|
}
|
|
4752
4830
|
for (const decl of config.identities) {
|
|
4753
|
-
await attempt(report2.identities, decl.name, () => upsertIdentity(client, decl, dryRun, ids.identities));
|
|
4831
|
+
await attempt(report2.identities, decl.name, () => upsertIdentity(client, decl, dryRun, ids.identities, isolated));
|
|
4754
4832
|
const identityId = ids.identities.get(decl.name);
|
|
4755
4833
|
report2.identities.push(...await reportLegal(client, decl.legal ?? [], identityId, report2.skipped));
|
|
4756
4834
|
for (const wallet of decl.wallet === void 0 ? [] : Array.isArray(decl.wallet) ? decl.wallet : [decl.wallet]) {
|
|
@@ -4779,7 +4857,7 @@ async function up(config, client, opts = {}) {
|
|
|
4779
4857
|
...opts.platform,
|
|
4780
4858
|
known: {
|
|
4781
4859
|
...opts.platform.known,
|
|
4782
|
-
[PLATFORM_ENV.project]:
|
|
4860
|
+
[PLATFORM_ENV.project]: project,
|
|
4783
4861
|
...identityEnv(config, ids.identities)
|
|
4784
4862
|
}
|
|
4785
4863
|
};
|
|
@@ -4812,9 +4890,10 @@ async function up(config, client, opts = {}) {
|
|
|
4812
4890
|
);
|
|
4813
4891
|
const existing = taken.agents.length > 0 || config.removed.agents.length > 0 || config.kept.agents.length > 0 || config.tasks.length > 0 ? await listAll(client.config, "/v1/agents", AgentSchema, report2.skipped) : [];
|
|
4814
4892
|
const deployments = taken.agents.some((decl) => decl.schedules !== void 0) ? await listAll(client.config, "/v1/deployments", DeploymentSchema, report2.skipped) : [];
|
|
4815
|
-
const
|
|
4893
|
+
const scoped2 = config.apps.length > 0 ? [...ids.apps.values()] : void 0;
|
|
4816
4894
|
const crew = await eachInFlight(taken.agents, async (decl) => {
|
|
4817
|
-
const
|
|
4895
|
+
const of = { project, ...applied(config), adopt: opts.adopt ?? false, ...isolated === void 0 ? {} : { group: project } };
|
|
4896
|
+
const agent = await line(decl.name, () => upsertAgent(client, decl, existing, ids, dryRun, scoped2, of));
|
|
4818
4897
|
const schedules = [];
|
|
4819
4898
|
if (decl.schedules !== void 0) {
|
|
4820
4899
|
await reconcileSchedules(client, agent, decl.schedules, deployments, ids.identities, dryRun, schedules);
|
|
@@ -4851,6 +4930,56 @@ async function up(config, client, opts = {}) {
|
|
|
4851
4930
|
);
|
|
4852
4931
|
return report2;
|
|
4853
4932
|
}
|
|
4933
|
+
|
|
4934
|
+
// src/scoped.ts
|
|
4935
|
+
function scoped(config, prefix, project) {
|
|
4936
|
+
const removed = { ...config.removed, skills: [] };
|
|
4937
|
+
if (prefix === "") return { ...config, name: project, removed };
|
|
4938
|
+
const as = (name) => prefix + name;
|
|
4939
|
+
const apps = new Set(config.apps.map((app) => app.name));
|
|
4940
|
+
const tool = (key) => {
|
|
4941
|
+
const app = key.split(".")[0] ?? "";
|
|
4942
|
+
return key.includes(".") && apps.has(app) ? as(key) : key;
|
|
4943
|
+
};
|
|
4944
|
+
const team = teamLine(config, as);
|
|
4945
|
+
const agent = (decl) => ({
|
|
4946
|
+
...decl,
|
|
4947
|
+
name: as(decl.name),
|
|
4948
|
+
system: decl.system === void 0 ? team : `${decl.system}
|
|
4949
|
+
|
|
4950
|
+
${team}`,
|
|
4951
|
+
...decl.tools === void 0 ? {} : { tools: { ...decl.tools, configs: Object.fromEntries(Object.entries(decl.tools.configs).map(([key, one]) => [tool(key), one])) } },
|
|
4952
|
+
...decl.allowed_apps === void 0 ? {} : { allowed_apps: decl.allowed_apps.map(as) },
|
|
4953
|
+
...decl.identity === void 0 ? {} : { identity: as(decl.identity) },
|
|
4954
|
+
...Array.isArray(decl.handoffs) ? { handoffs: decl.handoffs.map(as) } : {},
|
|
4955
|
+
...hasRoster(decl.multiagent) ? { multiagent: { ...decl.multiagent, agents: decl.multiagent.agents.map((one) => one.type === "agent" ? { ...one, name: as(one.name) } : one) } } : {},
|
|
4956
|
+
...decl.schedules === void 0 ? {} : { schedules: decl.schedules.map((one) => one.identity === void 0 ? one : { ...one, identity: as(one.identity) }) }
|
|
4957
|
+
});
|
|
4958
|
+
return {
|
|
4959
|
+
...config,
|
|
4960
|
+
name: project,
|
|
4961
|
+
identities: config.identities.map((one) => ({ ...one, name: as(one.name) })),
|
|
4962
|
+
vaults: config.vaults.map((one) => ({ ...one, name: as(one.name), ...one.identity === void 0 ? {} : { identity: as(one.identity) } })),
|
|
4963
|
+
apps: config.apps.map((one) => ({ ...one, name: as(one.name) })),
|
|
4964
|
+
agents: config.agents.map(agent),
|
|
4965
|
+
tasks: config.tasks.map((one) => one.assignee === void 0 ? one : { ...one, assignee: as(one.assignee) }),
|
|
4966
|
+
removed: {
|
|
4967
|
+
...removed,
|
|
4968
|
+
apps: config.removed.apps.map(as),
|
|
4969
|
+
agents: config.removed.agents.map(as),
|
|
4970
|
+
identities: config.removed.identities.map(as),
|
|
4971
|
+
vaults: config.removed.vaults.map(as)
|
|
4972
|
+
},
|
|
4973
|
+
kept: { agents: config.kept.agents.map(as) }
|
|
4974
|
+
};
|
|
4975
|
+
}
|
|
4976
|
+
function teamLine(config, as) {
|
|
4977
|
+
const names = [
|
|
4978
|
+
...config.agents.map((one) => `${one.name} is ${as(one.name)}`),
|
|
4979
|
+
...config.apps.map((one) => `the app ${one.name} is ${as(one.name)} (its tools are ${as(one.name)}.*)`)
|
|
4980
|
+
];
|
|
4981
|
+
return `Your team's names here: ${names.join("; ")}.`;
|
|
4982
|
+
}
|
|
4854
4983
|
export {
|
|
4855
4984
|
BLUEPRINTS,
|
|
4856
4985
|
BlueprintRefusal,
|
|
@@ -4867,6 +4996,7 @@ export {
|
|
|
4867
4996
|
loadConfig,
|
|
4868
4997
|
migrationFiles,
|
|
4869
4998
|
parseProject,
|
|
4999
|
+
scoped,
|
|
4870
5000
|
selectCrew,
|
|
4871
5001
|
up
|
|
4872
5002
|
};
|