@usenaive-sdk/blueprints 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -301,7 +301,7 @@ var HARNESS_IDS = ["pi", "claude_code", "vetta", "hermes"];
301
301
  var HarnessIdSchema = z2.enum(HARNESS_IDS);
302
302
 
303
303
  // ../core/src/schema/agent.ts
304
- import { z as z5 } from "zod";
304
+ import { z as z6 } from "zod";
305
305
 
306
306
  // ../core/src/schema/browser.ts
307
307
  import { z as z4 } from "zod";
@@ -553,16 +553,70 @@ var BrowserCredentialSchema = z4.object({
553
553
  });
554
554
  var LiveViewSchema = z4.object({ url: z4.string().url(), expires_at: Timestamp });
555
555
 
556
+ // ../core/src/schema/model-selection.ts
557
+ import { z as z5 } from "zod";
558
+ var MODEL_SELECTION_MIN_OPTIONS = 2;
559
+ var MODEL_SELECTION_MAX_OPTIONS = 16;
560
+ var MODEL_SELECTION_MAX_MESSAGES = 32;
561
+ var MODEL_SELECTION_MAX_CONTENT_CHARS = 32e3;
562
+ var ModelSelectionMessageSchema = z5.object({
563
+ role: z5.enum(["user", "assistant"]),
564
+ content: z5.string().min(1)
565
+ });
566
+ var OptionsSchema = z5.record(z5.string().min(1), z5.string().trim().min(1).max(500)).refine((options) => Object.keys(options).length >= MODEL_SELECTION_MIN_OPTIONS, {
567
+ message: `at least ${MODEL_SELECTION_MIN_OPTIONS} options are required`
568
+ }).refine((options) => Object.keys(options).length <= MODEL_SELECTION_MAX_OPTIONS, {
569
+ message: `at most ${MODEL_SELECTION_MAX_OPTIONS} options are allowed`
570
+ });
571
+ var ModelSelectionPolicySchema = z5.object({
572
+ options: OptionsSchema,
573
+ min_confidence: z5.number().gt(0).max(1).optional()
574
+ });
575
+ var ModelSelectionRequestSchema = z5.object({
576
+ options: OptionsSchema,
577
+ messages: z5.array(ModelSelectionMessageSchema).min(1).max(MODEL_SELECTION_MAX_MESSAGES),
578
+ default: z5.string().min(1).optional(),
579
+ min_confidence: z5.number().gt(0).max(1).optional()
580
+ }).superRefine((body, ctx) => {
581
+ const total = body.messages.reduce((sum, message3) => sum + message3.content.length, 0);
582
+ if (total > MODEL_SELECTION_MAX_CONTENT_CHARS) {
583
+ ctx.addIssue({
584
+ code: "custom",
585
+ path: ["messages"],
586
+ message: `total message content exceeds ${MODEL_SELECTION_MAX_CONTENT_CHARS} characters`
587
+ });
588
+ }
589
+ if (body.default !== void 0 && !Object.hasOwn(body.options, body.default)) {
590
+ ctx.addIssue({ code: "custom", path: ["default"], message: "default must be one of the options" });
591
+ }
592
+ if (body.min_confidence !== void 0 && body.default === void 0) {
593
+ ctx.addIssue({
594
+ code: "custom",
595
+ path: ["min_confidence"],
596
+ message: "min_confidence requires a default to fall back to"
597
+ });
598
+ }
599
+ });
600
+ var ModelSelectionSchema = z5.object({
601
+ object: z5.literal("model_selection"),
602
+ model: z5.string().min(1),
603
+ confidence: z5.number().min(0).max(1).nullable(),
604
+ probabilities: z5.record(z5.string(), z5.number()).nullable(),
605
+ defaulted: z5.boolean(),
606
+ spent_micro_usd: z5.number().int().nonnegative(),
607
+ usage: z5.object({ input_tokens: z5.number().int().nonnegative() })
608
+ });
609
+
556
610
  // ../core/src/schema/agent.ts
557
- var ToolPermissionSchema = z5.enum(["allow", "ask", "deny"]);
558
- var ToolConfigSchema = z5.object({
559
- enabled: z5.boolean(),
611
+ var ToolPermissionSchema = z6.enum(["allow", "ask", "deny"]);
612
+ var ToolConfigSchema = z6.object({
613
+ enabled: z6.boolean(),
560
614
  permission: ToolPermissionSchema,
561
- config: z5.record(z5.string(), z5.unknown()).optional()
615
+ config: z6.record(z6.string(), z6.unknown()).optional()
562
616
  });
563
- var ToolsetSchema = z5.object({
564
- default_config: z5.object({ permission: ToolPermissionSchema }),
565
- configs: z5.record(z5.string(), ToolConfigSchema)
617
+ var ToolsetSchema = z6.object({
618
+ default_config: z6.object({ permission: ToolPermissionSchema }),
619
+ configs: z6.record(z6.string(), ToolConfigSchema)
566
620
  }).superRefine((tools, ctx) => {
567
621
  const config = tools.configs["browser"]?.config;
568
622
  if (config === void 0) return;
@@ -570,83 +624,85 @@ var ToolsetSchema = z5.object({
570
624
  ctx.addIssue({ code: "custom", message: issue.message, path: ["configs", "browser", "config", ...issue.path] });
571
625
  }
572
626
  });
573
- var BudgetSchema = z5.object({
627
+ var BudgetSchema = z6.object({
574
628
  cap_micro_usd: MicroUsdField.nonnegative(),
575
629
  max_task_micro_usd: MicroUsdField.nonnegative(),
576
- period: z5.enum(["day", "week", "month"])
630
+ period: z6.enum(["day", "week", "month"])
577
631
  });
578
- var SkillRefSchema = z5.string().regex(/^(naive\/)?[a-z0-9][a-z0-9-]*(@\d+)?$/, {
632
+ var SkillRefSchema = z6.string().regex(/^(naive\/)?[a-z0-9][a-z0-9-]*(@\d+)?$/, {
579
633
  error: "expected `slug`, `slug@N`, `naive/slug` or `naive/slug@N`"
580
634
  });
581
- var McpServerSchema = z5.object({
582
- name: z5.string(),
583
- url: z5.url(),
584
- headers: z5.record(z5.string(), z5.string()).optional()
635
+ var McpServerSchema = z6.object({
636
+ name: z6.string(),
637
+ url: z6.url(),
638
+ headers: z6.record(z6.string(), z6.string()).optional()
585
639
  });
586
- var RosterEntrySchema = z5.union([
640
+ var RosterEntrySchema = z6.union([
587
641
  idOf("agt").transform((id) => ({ type: "agent", id })),
588
- z5.object({
589
- type: z5.literal("agent"),
642
+ z6.object({
643
+ type: z6.literal("agent"),
590
644
  id: idOf("agt"),
591
- version: z5.number().int().positive().optional()
645
+ version: z6.number().int().positive().optional()
592
646
  }),
593
- z5.object({ type: z5.literal("self") }),
594
- z5.object({ type: z5.literal("advisor"), model: z5.string().min(1) })
647
+ z6.object({ type: z6.literal("self") }),
648
+ z6.object({ type: z6.literal("advisor"), model: z6.string().min(1) })
595
649
  ]);
596
650
  var SINGLETON_ENTRIES = ["self", "advisor"];
597
- var MultiagentSchema = z5.object({
598
- type: z5.literal("coordinator"),
599
- agents: z5.array(RosterEntrySchema).min(1).max(20).refine(
651
+ var MultiagentSchema = z6.object({
652
+ type: z6.literal("coordinator"),
653
+ agents: z6.array(RosterEntrySchema).min(1).max(20).refine(
600
654
  (roster) => SINGLETON_ENTRIES.every((t) => roster.filter((e) => e.type === t).length <= 1),
601
655
  { error: "a roster carries at most one `self` and at most one `advisor` entry" }
602
656
  ),
603
- board: z5.boolean().optional()
657
+ board: z6.boolean().optional()
604
658
  });
605
- var MultiagentField = z5.union([z5.boolean(), MultiagentSchema, z5.null()]);
659
+ var MultiagentField = z6.union([z6.boolean(), MultiagentSchema, z6.null()]);
606
660
  function normaliseMultiagent(value) {
607
661
  if (value === true) return { type: "coordinator", agents: [], board: false };
608
662
  if (value === false || value === null) return null;
609
663
  return value;
610
664
  }
611
- var HandoffsField = z5.union([z5.boolean(), z5.literal("team"), z5.array(z5.string().min(1)).max(50)]);
665
+ var HandoffsField = z6.union([z6.boolean(), z6.literal("team"), z6.array(z6.string().min(1)).max(50)]);
612
666
  var handoffsOf = (config) => config.handoffs ?? true;
613
667
  var handoffsEnabled = (handoffs) => handoffs === true || handoffs === "team" || handoffs !== false && handoffs.length > 0;
614
668
  var agentConfigShape = {
615
- model: z5.string(),
669
+ model: z6.string(),
616
670
  window: WindowSchema,
617
- system: z5.string(),
671
+ system: z6.string(),
618
672
  tools: ToolsetSchema,
619
- mcp_servers: z5.array(McpServerSchema),
620
- skills: z5.array(SkillRefSchema),
673
+ mcp_servers: z6.array(McpServerSchema),
674
+ skills: z6.array(SkillRefSchema),
621
675
  multiagent: MultiagentField,
622
676
  /** Optional on the type so a version minted before §28.15 still parses; read it through `handoffsOf`. */
623
677
  handoffs: HandoffsField.optional(),
678
+ /** §46.6: when set, every turn picks one of its options and `model` is the default. Absent before it existed. */
679
+ model_selection: ModelSelectionPolicySchema.nullable().optional(),
624
680
  budget: BudgetSchema,
625
681
  output_schema: JsonSchemaDocument.nullable(),
626
- structured_output_required: z5.boolean(),
627
- description: z5.string().nullable(),
682
+ structured_output_required: z6.boolean(),
683
+ description: z6.string().nullable(),
628
684
  metadata: Metadata
629
685
  };
630
- var AgentVersionSchema = z5.object({
631
- version: z5.number().int().positive(),
686
+ var AgentVersionSchema = z6.object({
687
+ version: z6.number().int().positive(),
632
688
  created_at: Timestamp,
633
689
  created_by: PrincipalSchema,
634
690
  ...agentConfigShape
635
691
  });
636
- var AgentSchema = z5.object({
692
+ var AgentSchema = z6.object({
637
693
  id: idOf("agt"),
638
- object: z5.literal("agent"),
639
- name: z5.string(),
694
+ object: z6.literal("agent"),
695
+ name: z6.string(),
640
696
  /** The agent loop this agent runs (§19). Chosen at create; the catalog lives in `harness.ts`. */
641
697
  harness: HarnessIdSchema,
642
- current_version: z5.number().int().positive(),
698
+ current_version: z6.number().int().positive(),
643
699
  created_at: Timestamp,
644
700
  ...agentConfigShape
645
701
  });
646
702
 
647
703
  // ../core/src/schema/session.ts
648
- import { z as z6 } from "zod";
649
- var SessionStatusSchema = z6.enum([
704
+ import { z as z7 } from "zod";
705
+ var SessionStatusSchema = z7.enum([
650
706
  "queued",
651
707
  "running",
652
708
  "idle",
@@ -654,7 +710,7 @@ var SessionStatusSchema = z6.enum([
654
710
  "failed",
655
711
  "cancelled"
656
712
  ]);
657
- var StopReasonSchema = z6.enum([
713
+ var StopReasonSchema = z7.enum([
658
714
  "end_turn",
659
715
  "awaiting_input",
660
716
  "awaiting_approval",
@@ -680,61 +736,86 @@ var StopReasonSchema = z6.enum([
680
736
  */
681
737
  "awaiting_answer"
682
738
  ]);
683
- var ThreadRoleSchema = z6.enum(["coordinator", "member"]);
684
- var MessageSchema = z6.object({
685
- role: z6.enum(["system", "user", "assistant", "tool"]),
686
- content: z6.string(),
687
- tool_call_id: z6.string().optional()
688
- });
689
- var ToolResultSchema = z6.object({
690
- output: z6.unknown(),
691
- is_error: z6.boolean().optional(),
692
- content: z6.string().optional()
739
+ var ThreadRoleSchema = z7.enum(["coordinator", "member"]);
740
+ var MessageSchema = z7.object({
741
+ role: z7.enum(["system", "user", "assistant", "tool"]),
742
+ content: z7.string(),
743
+ tool_call_id: z7.string().optional()
744
+ });
745
+ var ToolImageSchema = z7.object({
746
+ data: z7.string().min(1).max(5e6).describe("The image's bytes, base64."),
747
+ media_type: z7.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
748
+ });
749
+ var ToolResultSchema = z7.object({
750
+ output: z7.unknown(),
751
+ is_error: z7.boolean().optional(),
752
+ content: z7.string().optional(),
753
+ images: z7.array(ToolImageSchema).max(12).optional()
693
754
  });
694
755
  var QuestionFieldBase = {
695
- key: z6.string().min(1).max(64),
696
- label: z6.string().min(1).max(200),
697
- help: z6.string().max(500).optional()
756
+ key: z7.string().min(1).max(64),
757
+ label: z7.string().min(1).max(200),
758
+ help: z7.string().max(500).optional(),
759
+ /**
760
+ * A field that may be left blank, and it defaults to **false** — the rule "every field must be
761
+ * answered" (`assertAnswers`) is still the rule, and this is the one documented way out of it.
762
+ *
763
+ * It exists for the question whose answer genuinely improves the work and does not gate it: a
764
+ * template's setup form asking for a reference to imitate, say. Before the flag the only way to
765
+ * ask such a thing was to make it mandatory — which forces an answer out of someone who has none,
766
+ * and an invented answer is worse than an absent one, because the crew cannot tell them apart.
767
+ *
768
+ * Nothing downstream needs an "if absent" branch: `projectContextFor` already lists only the
769
+ * questions that were answered, so an unanswered optional key is simply not in the context.
770
+ *
771
+ * ABSENT rather than `false`, which is why it is `.optional()` and not `.default(false)` like the
772
+ * `multiple` and `other` beside it. Those two sit on the `choice` branch, where a renderer has to
773
+ * branch on them and a definite value earns its place; this sits on the base, next to `help`,
774
+ * which is absent-by-default for the same reason. A default here would make `optional: boolean`
775
+ * required on the OUTPUT type — so every hand-written `QuestionField` in the codebase, and every
776
+ * one written after it, would have to spell out the flag it does not use.
777
+ */
778
+ optional: z7.boolean().optional()
698
779
  };
699
- var QuestionFieldSchema = z6.discriminatedUnion("type", [
700
- z6.object({
780
+ var QuestionFieldSchema = z7.discriminatedUnion("type", [
781
+ z7.object({
701
782
  ...QuestionFieldBase,
702
- type: z6.literal("text"),
703
- placeholder: z6.string().max(200).optional()
783
+ type: z7.literal("text"),
784
+ placeholder: z7.string().max(200).optional()
704
785
  }),
705
- z6.object({
786
+ z7.object({
706
787
  ...QuestionFieldBase,
707
- type: z6.literal("choice"),
788
+ type: z7.literal("choice"),
708
789
  /**
709
790
  * Plain strings: the option is both the value and the label, because the answer is read back by
710
791
  * a model, which wants the words and not an id. Fewer than two is not a choice, and more than
711
792
  * twelve is a list — which belongs in the prompt.
712
793
  */
713
- options: z6.array(z6.string().min(1).max(200)).min(2).max(12),
714
- multiple: z6.boolean().default(false),
794
+ options: z7.array(z7.string().min(1).max(200)).min(2).max(12),
795
+ multiple: z7.boolean().default(false),
715
796
  /**
716
797
  * The free-text escape, and it defaults to **true** on purpose: the agent wrote the options and
717
798
  * the agent is the one that does not know the answer, so an operator must always be able to say
718
799
  * something it did not think of. A question that truly admits only its list opts out explicitly.
719
800
  */
720
- other: z6.boolean().default(true)
801
+ other: z7.boolean().default(true)
721
802
  })
722
803
  ]);
723
- var QuestionSchema = z6.object({
724
- prompt: z6.string().min(1).max(1e3),
725
- fields: z6.array(QuestionFieldSchema).min(1).max(3)
804
+ var QuestionSchema = z7.object({
805
+ prompt: z7.string().min(1).max(1e3),
806
+ fields: z7.array(QuestionFieldSchema).min(1).max(3)
726
807
  });
727
- var AnswersSchema = z6.record(
728
- z6.string().min(1).max(64),
729
- z6.union([z6.string().max(2e3), z6.array(z6.string().max(2e3)).min(1).max(12)])
808
+ var AnswersSchema = z7.record(
809
+ z7.string().min(1).max(64),
810
+ z7.union([z7.string().max(2e3), z7.array(z7.string().max(2e3)).min(1).max(12)])
730
811
  ).refine((answers) => Object.keys(answers).length <= 3, {
731
812
  message: "a question has at most 3 fields, so an answer has at most 3 keys"
732
813
  });
733
- var PendingActionSchema = z6.object({
734
- kind: z6.enum(["tool", "question"]).default("tool"),
735
- tool_call_id: z6.string(),
736
- name: z6.string(),
737
- args: z6.record(z6.string(), z6.unknown()),
814
+ var PendingActionSchema = z7.object({
815
+ kind: z7.enum(["tool", "question"]).default("tool"),
816
+ tool_call_id: z7.string(),
817
+ name: z7.string(),
818
+ args: z7.record(z7.string(), z7.unknown()),
738
819
  /**
739
820
  * Present iff `kind` is `"question"`, and it is the parse of `args` rather than a second source
740
821
  * of truth: `args` is what the model called and therefore what replays byte-identically, while
@@ -743,11 +824,11 @@ var PendingActionSchema = z6.object({
743
824
  */
744
825
  question: QuestionSchema.optional()
745
826
  });
746
- var SessionSchema = z6.object({
827
+ var SessionSchema = z7.object({
747
828
  id: idOf("ses"),
748
- object: z6.literal("session"),
829
+ object: z7.literal("session"),
749
830
  agent_id: idOf("agt"),
750
- agent_version: z6.number().int().positive(),
831
+ agent_version: z7.number().int().positive(),
751
832
  deployment_id: idOf("dep").nullable(),
752
833
  /**
753
834
  * The persona this session acts as (`canonical-spec §22`). Chosen per task from the personas the
@@ -776,50 +857,109 @@ var SessionSchema = z6.object({
776
857
  budget_micro_usd: MicroUsdField.nonnegative(),
777
858
  consumed_micro_usd: MicroUsdField.nonnegative(),
778
859
  token_usage: TokenUsageSchema,
779
- pending_actions: z6.array(PendingActionSchema),
860
+ pending_actions: z7.array(PendingActionSchema),
780
861
  output_schema: JsonSchemaDocument.nullable(),
781
- structured_output: z6.record(z6.string(), z6.unknown()).nullable(),
782
- last_seq: z6.number().int().nonnegative(),
862
+ structured_output: z7.record(z7.string(), z7.unknown()).nullable(),
863
+ last_seq: z7.number().int().nonnegative(),
783
864
  metadata: Metadata,
784
865
  started_at: Timestamp.nullable(),
785
866
  ended_at: Timestamp.nullable(),
786
867
  created_at: Timestamp
787
868
  });
788
- var SendMessageSchema = z6.object({
789
- message: z6.string(),
790
- interrupt: z6.boolean().optional(),
791
- idempotency_key: z6.string().optional()
792
- });
793
- var SendAcceptedSchema = z6.object({
794
- session_id: z6.string(),
869
+ var SendMessageSchema = z7.object({
870
+ message: z7.string(),
871
+ interrupt: z7.boolean().optional(),
872
+ queue: z7.boolean().optional(),
873
+ idempotency_key: z7.string().optional()
874
+ }).refine((body) => !(body.interrupt === true && body.queue === true), {
875
+ message: "a send is either an interrupt or queued, not both",
876
+ path: ["queue"]
877
+ });
878
+ var SendAcceptedSchema = z7.object({
879
+ session_id: z7.string(),
795
880
  status: SessionStatusSchema,
796
- accepted_seq: z6.number().int().nonnegative()
881
+ accepted_seq: z7.number().int().nonnegative()
797
882
  });
798
- var ToolConfirmationSchema = z6.object({
799
- tool_call_id: z6.string(),
800
- decision: z6.enum(["allow", "deny"]),
801
- reason: z6.string().optional(),
802
- scope: z6.enum(["call", "session"]).default("call")
883
+ var ToolConfirmationSchema = z7.object({
884
+ tool_call_id: z7.string(),
885
+ decision: z7.enum(["allow", "deny"]),
886
+ reason: z7.string().optional(),
887
+ scope: z7.enum(["call", "session"]).default("call")
803
888
  });
804
- var SessionAnswerSchema = z6.object({
805
- tool_call_id: z6.string(),
806
- answers: z6.record(z6.string(), z6.union([z6.string(), z6.array(z6.string())]))
889
+ var SessionAnswerSchema = z7.object({
890
+ tool_call_id: z7.string(),
891
+ answers: z7.record(z7.string(), z7.union([z7.string(), z7.array(z7.string())]))
807
892
  });
808
893
 
809
894
  // ../core/src/schema/event.ts
810
- import { z as z7 } from "zod";
811
- var EventTypeSchema = z7.enum([
895
+ import { z as z8 } from "zod";
896
+ var EventTypeSchema = z8.enum([
812
897
  "message.delta",
813
898
  "message.completed",
899
+ /** A caller's message, durable in the inbox and not yet admitted to a turn (§7, §8): `{ client_message_id, content }`. */
900
+ "message.accepted",
901
+ /** A person's fan-out, on the sender's log without waking it (§8, §28.16): `{ client_message_id, content, handoffs, refusals }`. */
902
+ "handoff.sent",
814
903
  "tool.started",
815
904
  "tool.completed",
816
905
  "tool.confirm",
817
906
  "session.running",
818
907
  "session.usage",
819
908
  "session.idle",
909
+ /** A failed attempt the loop will retry (§8): `{ attempt, in_ms, code }`. */
910
+ "session.retrying",
911
+ /**
912
+ * The turn ran, but without something it needed (§8): `{ reason, detail? }`.
913
+ *
914
+ * Emitted for a turn whose sandbox could not be woken. That turn used to be indistinguishable
915
+ * from a success — the model was handed the failure as a tool result, answered around it from the
916
+ * transcript, and the session ended `idle`/`end_turn` with no field anywhere saying the
917
+ * filesystem had been unavailable. This is the field. `reason` is open on purpose; today the only
918
+ * value is `"sandbox_unavailable"`.
919
+ *
920
+ * `detail` is the boot failure's own message, and it is here because `reason` alone reads the
921
+ * same for a vendor outage and for a fault of ours. Staging round 3 spent its whole budget
922
+ * establishing with raw Connect RPC that the vendor was refusing every `ResumeSession` on the
923
+ * account — a question the adapter could have answered, since its give-up names the vendor state
924
+ * it last saw and how long it waited (`compute-tenki index.ts`). It is diagnostic prose, not a
925
+ * contract: never parse it, and it may be absent.
926
+ */
927
+ "session.degraded",
928
+ /**
929
+ * The session let go of a sandbox that would not resume and will run the next turn on a fresh
930
+ * one: `{ from, reason, failures, replacements }`.
931
+ *
932
+ * *** THE ONE TURN WHERE A FILESYSTEM ACTUALLY GOES MISSING USED TO BE THE SILENT ONE. ***
933
+ * `session.degraded` marks the turns whose resume FAILED, and those turns lose nothing — the box
934
+ * is still there and the next turn may still get it back. The turn that swaps the box is the
935
+ * damaging one, and it has no failure to report: it provisions a replacement and runs normally.
936
+ * Staging watched a session answer `cat: … No such file or directory` with nothing in its event
937
+ * log to tell that apart from the file never having been written, and support could not tell
938
+ * either. `from` is the box that was let go of, so a customer can still reach it through
939
+ * `GET /v1/computers/:id` while it lives.
940
+ *
941
+ * `reason` is open like `session.degraded`'s, and it carries the one distinction an operator
942
+ * cannot make any other way: `"resume_refused"` is the FIRST swap, where everything knowable here
943
+ * says the fault is that box's, and `"vendor_resume_unavailable"` is a swap that follows one — a
944
+ * fault that already outlived a fresh machine, so it is the account and not the box.
945
+ * `replacements` counts them. There is no third swap: past `box.ts MAX_BOX_REPLACEMENTS` the
946
+ * session keeps the box it holds and reports `session.degraded` under that same
947
+ * `vendor_resume_unavailable` reason, rather than abandoning one more live micro-VM every cycle
948
+ * for a fault a fresh one demonstrably does not fix.
949
+ */
950
+ "session.computer_replaced",
820
951
  "budget.exceeded",
821
952
  "span.model_request.start",
822
953
  "span.model_request.end",
954
+ // Pre-model spans (§15): what the gap before the first model request was spent on.
955
+ "span.transcript_load.start",
956
+ "span.transcript_load.end",
957
+ "span.harness_load.start",
958
+ "span.harness_load.end",
959
+ "span.harness_build.start",
960
+ "span.harness_build.end",
961
+ "span.box_resume.start",
962
+ "span.box_resume.end",
823
963
  /**
824
964
  * A delegated thread's lifecycle, on the **coordinator's** stream (§28). The child's own
825
965
  * `ses_…` rides inside `data.thread_id` — the event schema gains no field and `vetta.event` gains
@@ -854,55 +994,63 @@ var EventTypeSchema = z7.enum([
854
994
  "card.refunded",
855
995
  "card.credentials_revealed"
856
996
  ]);
857
- var EventSchema = z7.object({
997
+ var EventSchema = z8.object({
858
998
  id: idOf("evt"),
859
- seq: z7.number().int().positive(),
999
+ seq: z8.number().int().positive(),
860
1000
  type: EventTypeSchema,
861
1001
  session_id: idOf("ses"),
862
- data: z7.record(z7.string(), z7.unknown()),
1002
+ data: z8.record(z8.string(), z8.unknown()),
863
1003
  created_at: Timestamp
864
1004
  });
865
- var ThreadEventDataSchema = z7.looseObject({ thread_id: idOf("ses") });
866
- var SessionUsageDataSchema = z7.object({
1005
+ var ThreadEventDataSchema = z8.looseObject({ thread_id: idOf("ses") });
1006
+ var SessionUsageDataSchema = z8.object({
867
1007
  token_usage: TokenUsageSchema,
868
1008
  consumed_micro_usd: MicroUsdField.nonnegative(),
869
- active_seconds: z7.number().nonnegative(),
870
- tool_calls: z7.number().int().nonnegative()
1009
+ active_seconds: z8.number().nonnegative(),
1010
+ tool_calls: z8.number().int().nonnegative()
871
1011
  });
872
1012
 
873
1013
  // ../core/src/schema/board.ts
874
- import { z as z8 } from "zod";
1014
+ import { z as z9 } from "zod";
875
1015
  var BOARD_STATUSES = ["todo", "doing", "blocked", "done"];
876
- var BoardStatusSchema = z8.enum(BOARD_STATUSES);
877
- var BoardCountsSchema = z8.object({
878
- todo: z8.number().int().nonnegative(),
879
- doing: z8.number().int().nonnegative(),
880
- blocked: z8.number().int().nonnegative(),
881
- done: z8.number().int().nonnegative()
882
- });
883
- var BoardSchema = z8.object({
1016
+ var BoardStatusSchema = z9.enum(BOARD_STATUSES);
1017
+ var BoardCountsSchema = z9.object({
1018
+ todo: z9.number().int().nonnegative(),
1019
+ doing: z9.number().int().nonnegative(),
1020
+ blocked: z9.number().int().nonnegative(),
1021
+ done: z9.number().int().nonnegative()
1022
+ });
1023
+ var BoardSchema = z9.object({
884
1024
  id: idOf("brd"),
885
- object: z8.literal("board"),
1025
+ object: z9.literal("board"),
886
1026
  agent_id: idOf("agt"),
887
1027
  cards: BoardCountsSchema,
888
1028
  created_at: Timestamp
889
1029
  });
890
- var BoardCardSchema = z8.object({
1030
+ var BoardCardSchema = z9.object({
891
1031
  id: idOf("crd"),
892
- object: z8.literal("board_card"),
1032
+ object: z9.literal("board_card"),
893
1033
  board_id: idOf("brd"),
894
- title: z8.string().min(1),
895
- body: z8.string(),
1034
+ title: z9.string().min(1),
1035
+ /** The brief — what was asked. */
1036
+ body: z9.string(),
1037
+ /** What the holder wrote back; a `done` carries one. */
1038
+ note: z9.string().nullable().default(null),
896
1039
  status: BoardStatusSchema,
897
- assignee: z8.string().nullable(),
1040
+ assignee: z9.string().nullable(),
898
1041
  /** The cards this one waits on. A `blocked` card with an empty list is stuck on the world. */
899
- blocked_by: z8.array(idOf("crd")),
1042
+ blocked_by: z9.array(idOf("crd")),
1043
+ // The wake fields default on read: a reader whose API predates one still gets the card (§28.11).
1044
+ woken_session_id: idOf("ses").nullable().default(null),
1045
+ reported_status: BoardStatusSchema.nullable().default(null),
1046
+ /** Sessions the board has started for this card; the third is its last (§28.18). */
1047
+ wake_count: z9.number().int().nonnegative().default(0),
900
1048
  created_at: Timestamp,
901
1049
  updated_at: Timestamp
902
1050
  });
903
- var BoardCommentSchema = z8.object({
1051
+ var BoardCommentSchema = z9.object({
904
1052
  id: idOf("bcm"),
905
- object: z8.literal("board_comment"),
1053
+ object: z9.literal("board_comment"),
906
1054
  card_id: idOf("crd"),
907
1055
  /**
908
1056
  * Who wrote it, as an id the server derived — never a name the caller supplied. A member's
@@ -910,42 +1058,42 @@ var BoardCommentSchema = z8.object({
910
1058
  * `key_` principal. The prefix is what lets a reader tell an agent's comment from a person's,
911
1059
  * which is the distinction a free-text author field could not make and could be used to forge.
912
1060
  */
913
- author: z8.string(),
914
- body: z8.string(),
1061
+ author: z9.string(),
1062
+ body: z9.string(),
915
1063
  created_at: Timestamp
916
1064
  });
917
1065
 
918
1066
  // ../core/src/schema/identity.ts
919
- import { z as z9 } from "zod";
1067
+ import { z as z10 } from "zod";
920
1068
  var IDENTITY_NAME_MAX = 128;
921
1069
  var IDENTITY_DESCRIPTION_MAX = 1024;
922
- var IdentitySchema = z9.object({
1070
+ var IdentitySchema = z10.object({
923
1071
  id: idOf("idn"),
924
- object: z9.literal("identity"),
1072
+ object: z10.literal("identity"),
925
1073
  /** Human-facing persona name. Surfaced to the model so it acts in character. */
926
- name: z9.string().min(1).max(IDENTITY_NAME_MAX),
1074
+ name: z10.string().min(1).max(IDENTITY_NAME_MAX),
927
1075
  /** What the persona is for. The model reads it to choose tone, scope and endpoint. */
928
- description: z9.string().max(IDENTITY_DESCRIPTION_MAX).nullable(),
1076
+ description: z10.string().max(IDENTITY_DESCRIPTION_MAX).nullable(),
929
1077
  /** Inbox addresses (`localpart@domain`) this identity owns. */
930
- emails: z9.array(z9.string()),
1078
+ emails: z10.array(z10.string()),
931
1079
  /** Provisioned numbers in E.164. */
932
- phones: z9.array(z9.string()),
1080
+ phones: z10.array(z10.string()),
933
1081
  /** Verified web domains reachable through this identity's inboxes. */
934
- domains: z9.array(z9.string()),
1082
+ domains: z10.array(z10.string()),
935
1083
  /** `conn_` ids of authorized third-party connections. */
936
- connections: z9.array(z9.string()),
1084
+ connections: z10.array(z10.string()),
937
1085
  metadata: Metadata,
938
1086
  created_at: Timestamp,
939
1087
  updated_at: Timestamp
940
1088
  });
941
1089
 
942
1090
  // ../core/src/schema/resource.ts
943
- import { z as z11 } from "zod";
1091
+ import { z as z12 } from "zod";
944
1092
 
945
1093
  // ../core/src/schema/files-library.ts
946
- import { z as z10 } from "zod";
1094
+ import { z as z11 } from "zod";
947
1095
  var FILE_KINDS = ["image", "video", "audio", "document", "other"];
948
- var FileKindSchema = z10.enum(FILE_KINDS);
1096
+ var FileKindSchema = z11.enum(FILE_KINDS);
949
1097
  var FILE_SOURCE_TYPES = [
950
1098
  "upload",
951
1099
  "url_import",
@@ -955,50 +1103,50 @@ var FILE_SOURCE_TYPES = [
955
1103
  "screenshot",
956
1104
  "speech_generation"
957
1105
  ];
958
- var FileSourceTypeSchema = z10.enum(FILE_SOURCE_TYPES);
959
- var FileSourceSchema = z10.object({
1106
+ var FileSourceTypeSchema = z11.enum(FILE_SOURCE_TYPES);
1107
+ var FileSourceSchema = z11.object({
960
1108
  type: FileSourceTypeSchema,
961
- job_id: z10.union([idOf("med"), idOf("clj")]).nullable(),
962
- url: z10.string().url().nullable()
1109
+ job_id: z11.union([idOf("med"), idOf("clj")]).nullable(),
1110
+ url: z11.string().url().nullable()
963
1111
  });
964
- var FileTagsSchema = z10.array(z10.string().min(1).max(64)).max(32);
965
- var FileLibraryFieldsSchema = z10.object({
966
- title: z10.string().max(256).nullable().default(null),
967
- description: z10.string().max(4096).nullable().default(null),
1112
+ var FileTagsSchema = z11.array(z11.string().min(1).max(64)).max(32);
1113
+ var FileLibraryFieldsSchema = z11.object({
1114
+ title: z11.string().max(256).nullable().default(null),
1115
+ description: z11.string().max(4096).nullable().default(null),
968
1116
  tags: FileTagsSchema.default([]),
969
1117
  kind: FileKindSchema.default("other"),
970
1118
  source: FileSourceSchema.nullable().default(null),
971
1119
  thumbnail_file_id: idOf("fil").nullable().default(null),
972
- width: z10.number().int().positive().nullable().default(null),
973
- height: z10.number().int().positive().nullable().default(null),
974
- duration_seconds: z10.number().nonnegative().nullable().default(null)
1120
+ width: z11.number().int().positive().nullable().default(null),
1121
+ height: z11.number().int().positive().nullable().default(null),
1122
+ duration_seconds: z11.number().nonnegative().nullable().default(null)
975
1123
  });
976
- var UpdateFileSchema = z10.object({
977
- title: z10.string().max(256).nullable().optional(),
978
- description: z10.string().max(4096).nullable().optional(),
1124
+ var UpdateFileSchema = z11.object({
1125
+ title: z11.string().max(256).nullable().optional(),
1126
+ description: z11.string().max(4096).nullable().optional(),
979
1127
  tags: FileTagsSchema.optional()
980
1128
  });
981
- var ImportFileSchema = z10.object({
982
- url: z10.string().url().startsWith("http"),
983
- title: z10.string().max(256).optional(),
984
- description: z10.string().max(4096).optional(),
1129
+ var ImportFileSchema = z11.object({
1130
+ url: z11.string().url().startsWith("http"),
1131
+ title: z11.string().max(256).optional(),
1132
+ description: z11.string().max(4096).optional(),
985
1133
  tags: FileTagsSchema.optional()
986
1134
  });
987
1135
 
988
1136
  // ../core/src/schema/resource.ts
989
- var ComputerStatusSchema = z11.enum(["creating", "running", "paused", "failed", "destroyed"]);
990
- var VolumeSchema = z11.object({
1137
+ var ComputerStatusSchema = z12.enum(["creating", "running", "paused", "failed", "destroyed"]);
1138
+ var VolumeSchema = z12.object({
991
1139
  id: idOf("vol"),
992
- size_gb: z11.number().int().positive(),
993
- mount_path: z11.string()
1140
+ size_gb: z12.number().int().positive(),
1141
+ mount_path: z12.string()
994
1142
  });
995
- var ComputerSchema = z11.object({
1143
+ var ComputerSchema = z12.object({
996
1144
  id: idOf("cmp"),
997
- object: z11.literal("computer"),
998
- name: z11.string(),
999
- vcpu: z11.number().int().positive(),
1000
- memory_mb: z11.number().int().positive(),
1001
- disk_gb: z11.number().int().positive(),
1145
+ object: z12.literal("computer"),
1146
+ name: z12.string(),
1147
+ vcpu: z12.number().int().positive(),
1148
+ memory_mb: z12.number().int().positive(),
1149
+ disk_gb: z12.number().int().positive(),
1002
1150
  status: ComputerStatusSchema,
1003
1151
  // core-gaps: U2-browser-api — the whole option object (§32.2); `{ allowed_domains }` still parses.
1004
1152
  browser: BrowserOptionsSchema.nullable(),
@@ -1006,125 +1154,125 @@ var ComputerSchema = z11.object({
1006
1154
  snapshot_id: idOf("snp").nullable(),
1007
1155
  created_at: Timestamp
1008
1156
  });
1009
- var SnapshotSchema = z11.object({
1157
+ var SnapshotSchema = z12.object({
1010
1158
  snapshot_id: idOf("snp"),
1011
1159
  computer_id: idOf("cmp"),
1012
1160
  created_at: Timestamp
1013
1161
  });
1014
- var ComputerProbeSchema = z11.object({
1162
+ var ComputerProbeSchema = z12.object({
1015
1163
  sampled_at: Timestamp,
1016
- uptime_seconds: z11.number().int().nonnegative(),
1017
- processes: z11.number().int().nonnegative(),
1018
- load_1m: z11.number().nonnegative(),
1019
- memory_used_mb: z11.number().int().nonnegative(),
1020
- memory_total_mb: z11.number().int().positive(),
1021
- disk_used_gb: z11.number().nonnegative(),
1022
- disk_total_gb: z11.number().positive()
1023
- });
1024
- var ComputerInspectSchema = z11.object({
1025
- object: z11.literal("computer_inspect"),
1164
+ uptime_seconds: z12.number().int().nonnegative(),
1165
+ processes: z12.number().int().nonnegative(),
1166
+ load_1m: z12.number().nonnegative(),
1167
+ memory_used_mb: z12.number().int().nonnegative(),
1168
+ memory_total_mb: z12.number().int().positive(),
1169
+ disk_used_gb: z12.number().nonnegative(),
1170
+ disk_total_gb: z12.number().positive()
1171
+ });
1172
+ var ComputerInspectSchema = z12.object({
1173
+ object: z12.literal("computer_inspect"),
1026
1174
  id: idOf("cmp"),
1027
1175
  status: ComputerStatusSchema,
1028
1176
  last_active_at: Timestamp.nullable(),
1029
1177
  /** Where the provider's file API is rooted (§41.1); `null` when it does not say. */
1030
- home: z11.string().min(1).nullable(),
1178
+ home: z12.string().min(1).nullable(),
1031
1179
  probe: ComputerProbeSchema.nullable()
1032
1180
  });
1033
1181
  var COMMAND_OUTPUT_CAP = 65536;
1034
- var ComputerCommandSchema = z11.object({
1182
+ var ComputerCommandSchema = z12.object({
1035
1183
  id: idOf("cmd"),
1036
- object: z11.literal("computer_command"),
1184
+ object: z12.literal("computer_command"),
1037
1185
  computer_id: idOf("cmp"),
1038
- command: z11.string(),
1039
- exit_code: z11.number().int().nullable(),
1040
- timed_out: z11.boolean(),
1041
- duration_ms: z11.number().int().nonnegative(),
1042
- stdout: z11.string().max(COMMAND_OUTPUT_CAP),
1043
- stderr: z11.string().max(COMMAND_OUTPUT_CAP),
1044
- truncated: z11.boolean(),
1186
+ command: z12.string(),
1187
+ exit_code: z12.number().int().nullable(),
1188
+ timed_out: z12.boolean(),
1189
+ duration_ms: z12.number().int().nonnegative(),
1190
+ stdout: z12.string().max(COMMAND_OUTPUT_CAP),
1191
+ stderr: z12.string().max(COMMAND_OUTPUT_CAP),
1192
+ truncated: z12.boolean(),
1045
1193
  actor: PrincipalSchema,
1046
1194
  created_at: Timestamp
1047
1195
  });
1048
- var ExecStreamFrameSchema = z11.union([
1049
- z11.object({ stdout: z11.string() }),
1050
- z11.object({ stderr: z11.string() }),
1051
- z11.object({
1052
- exit: z11.object({
1053
- exit_code: z11.number().int().nullable(),
1054
- timed_out: z11.boolean(),
1055
- duration_ms: z11.number().int().nonnegative(),
1196
+ var ExecStreamFrameSchema = z12.union([
1197
+ z12.object({ stdout: z12.string() }),
1198
+ z12.object({ stderr: z12.string() }),
1199
+ z12.object({
1200
+ exit: z12.object({
1201
+ exit_code: z12.number().int().nullable(),
1202
+ timed_out: z12.boolean(),
1203
+ duration_ms: z12.number().int().nonnegative(),
1056
1204
  command_id: idOf("cmd")
1057
1205
  })
1058
1206
  })
1059
1207
  ]);
1060
- var FileEntryTypeSchema = z11.enum(["file", "directory", "symlink", "other"]);
1061
- var FileEntrySchema = z11.object({
1062
- name: z11.string().min(1),
1063
- path: z11.string().min(1),
1208
+ var FileEntryTypeSchema = z12.enum(["file", "directory", "symlink", "other"]);
1209
+ var FileEntrySchema = z12.object({
1210
+ name: z12.string().min(1),
1211
+ path: z12.string().min(1),
1064
1212
  type: FileEntryTypeSchema,
1065
- size_bytes: z11.number().int().nonnegative(),
1213
+ size_bytes: z12.number().int().nonnegative(),
1066
1214
  /** POSIX `st_mode`. */
1067
- mode: z11.number().int().nonnegative(),
1215
+ mode: z12.number().int().nonnegative(),
1068
1216
  modified_at: Timestamp.nullable()
1069
1217
  });
1070
- var ComputerUpdateSchema = z11.strictObject({ name: z11.string().min(1).max(200) });
1071
- var SkillSchema = z11.object({
1218
+ var ComputerUpdateSchema = z12.strictObject({ name: z12.string().min(1).max(200) });
1219
+ var SkillSchema = z12.object({
1072
1220
  id: idOf("skl"),
1073
- object: z11.literal("skill"),
1074
- name: z11.string(),
1075
- description: z11.string().nullable(),
1076
- latest_version: z11.number().int().positive(),
1221
+ object: z12.literal("skill"),
1222
+ name: z12.string(),
1223
+ description: z12.string().nullable(),
1224
+ latest_version: z12.number().int().positive(),
1077
1225
  created_at: Timestamp
1078
1226
  });
1079
- var ResolvedSkillRefSchema = z11.object({
1227
+ var ResolvedSkillRefSchema = z12.object({
1080
1228
  /** The reference exactly as the agent version wrote it: `slug` or `slug@N`. */
1081
- ref: z11.string().min(1),
1082
- slug: z11.string().min(1),
1083
- version: z11.number().int().positive(),
1084
- description: z11.string(),
1085
- storage_key: z11.string().min(1)
1086
- });
1087
- var SkillVersionSchema = z11.object({
1088
- version: z11.number().int().positive(),
1089
- sha256: z11.string().regex(/^[0-9a-f]{64}$/),
1090
- size_bytes: z11.number().int().nonnegative(),
1229
+ ref: z12.string().min(1),
1230
+ slug: z12.string().min(1),
1231
+ version: z12.number().int().positive(),
1232
+ description: z12.string(),
1233
+ storage_key: z12.string().min(1)
1234
+ });
1235
+ var SkillVersionSchema = z12.object({
1236
+ version: z12.number().int().positive(),
1237
+ sha256: z12.string().regex(/^[0-9a-f]{64}$/),
1238
+ size_bytes: z12.number().int().nonnegative(),
1091
1239
  created_at: Timestamp
1092
1240
  });
1093
- var SkillCatalogEntrySchema = z11.object({
1094
- object: z11.literal("skill_catalog_entry"),
1095
- slug: z11.string().regex(/^[a-z0-9][a-z0-9-]*$/),
1096
- version: z11.number().int().positive(),
1097
- name: z11.string().min(1),
1098
- description: z11.string(),
1099
- tags: z11.array(z11.string().min(1)),
1100
- content_hash: z11.string().regex(/^[0-9a-f]{64}$/),
1241
+ var SkillCatalogEntrySchema = z12.object({
1242
+ object: z12.literal("skill_catalog_entry"),
1243
+ slug: z12.string().regex(/^[a-z0-9][a-z0-9-]*$/),
1244
+ version: z12.number().int().positive(),
1245
+ name: z12.string().min(1),
1246
+ description: z12.string(),
1247
+ tags: z12.array(z12.string().min(1)),
1248
+ content_hash: z12.string().regex(/^[0-9a-f]{64}$/),
1101
1249
  published_at: Timestamp
1102
1250
  });
1103
- var SkillCatalogVersionSchema = SkillCatalogEntrySchema.extend({ content: z11.string() });
1104
- var FileSchema = z11.object({
1251
+ var SkillCatalogVersionSchema = SkillCatalogEntrySchema.extend({ content: z12.string() });
1252
+ var FileSchema = z12.object({
1105
1253
  id: idOf("fil"),
1106
- object: z11.literal("file"),
1107
- name: z11.string(),
1108
- content_type: z11.string(),
1109
- size_bytes: z11.number().int().nonnegative(),
1110
- scope: z11.enum(["session", "published"]),
1254
+ object: z12.literal("file"),
1255
+ name: z12.string(),
1256
+ content_type: z12.string(),
1257
+ size_bytes: z12.number().int().nonnegative(),
1258
+ scope: z12.enum(["session", "published"]),
1111
1259
  session_id: idOf("ses").nullable(),
1112
- sha256: z11.string().regex(/^[0-9a-f]{64}$/),
1260
+ sha256: z12.string().regex(/^[0-9a-f]{64}$/),
1113
1261
  created_at: Timestamp,
1114
1262
  // The asset-library fields (`canonical-spec §36.1`), all nullable or defaulted.
1115
1263
  ...FileLibraryFieldsSchema.shape
1116
1264
  });
1117
- var ScheduleStatusSchema = z11.enum(["scheduled", "paused", "unscheduled"]);
1118
- var DeploymentSchema = z11.object({
1265
+ var ScheduleStatusSchema = z12.enum(["scheduled", "paused", "unscheduled"]);
1266
+ var DeploymentSchema = z12.object({
1119
1267
  id: idOf("dep"),
1120
- object: z11.literal("deployment"),
1268
+ object: z12.literal("deployment"),
1121
1269
  agent_id: idOf("agt"),
1122
1270
  /** A pin. `null` tracks the agent's `current_version` on every fire (§12). */
1123
- agent_version: z11.number().int().positive().nullable(),
1124
- cron: z11.string(),
1271
+ agent_version: z12.number().int().positive().nullable(),
1272
+ cron: z12.string(),
1125
1273
  /** IANA zone the `cron` is read in. "0 9 * * 1" means 09:00 *here*, across DST (ADR-0074). */
1126
- timezone: z11.string(),
1127
- input_template: z11.string(),
1274
+ timezone: z12.string(),
1275
+ input_template: z12.string(),
1128
1276
  budget_micro_usd: MicroUsdField.nonnegative(),
1129
1277
  window: WindowSchema,
1130
1278
  /**
@@ -1134,21 +1282,21 @@ var DeploymentSchema = z11.object({
1134
1282
  * those endpoints, and a signed delivery over cleartext is not a delivery. Until the push was
1135
1283
  * wired this field went nowhere, so nothing can be relying on an `http://` value (ADR-0161).
1136
1284
  */
1137
- on_idle: z11.url().startsWith("https://", { error: "a webhook URL must be https" }).nullable(),
1285
+ on_idle: z12.url().startsWith("https://", { error: "a webhook URL must be https" }).nullable(),
1138
1286
  /**
1139
1287
  * The persona every fire speaks as, or `null` to run as nobody (§22). Written as an `idn_` id
1140
1288
  * **or** the persona's name, the way a session names one, and always echoed as the id: a fire at
1141
1289
  * 3am must not be silenced by someone renaming the persona at noon.
1142
1290
  */
1143
1291
  identity: idOf("idn").nullable(),
1144
- enabled: z11.boolean(),
1292
+ enabled: z12.boolean(),
1145
1293
  /** Derived per deploy, never stored — the row cannot know whether a clock is watching it. */
1146
1294
  schedule_status: ScheduleStatusSchema,
1147
1295
  /** The next fire, or `null` when nothing will fire it (`schedule_status` says which). */
1148
1296
  next_run_at: Timestamp.nullable(),
1149
1297
  created_at: Timestamp
1150
1298
  });
1151
- var DeploymentRunSchema = z11.object({
1299
+ var DeploymentRunSchema = z12.object({
1152
1300
  id: idOf("run"),
1153
1301
  session_id: idOf("ses"),
1154
1302
  status: SessionStatusSchema,
@@ -1156,62 +1304,62 @@ var DeploymentRunSchema = z11.object({
1156
1304
  });
1157
1305
 
1158
1306
  // ../core/src/schema/comms.ts
1159
- import { z as z12 } from "zod";
1160
- var DomainKindSchema = z12.enum(["system", "external", "purchased"]);
1161
- var DomainStatusSchema = z12.enum(["pending_dns", "active", "failed"]);
1162
- var DomainDnsStatusSchema = z12.enum(["pending_verification", "provisioned", "failed"]);
1163
- var DomainInboundStatusSchema = z12.enum(["pending", "verified", "failed"]);
1164
- var DomainAppConnectStatusSchema = z12.enum(["pending", "connected", "failed"]);
1165
- var DnsRecordSchema = z12.object({
1166
- type: z12.enum(["TXT", "CNAME", "MX"]),
1167
- host: z12.string(),
1168
- value: z12.string(),
1169
- priority: z12.number().int().nullable(),
1307
+ import { z as z13 } from "zod";
1308
+ var DomainKindSchema = z13.enum(["system", "external", "purchased"]);
1309
+ var DomainStatusSchema = z13.enum(["pending_dns", "active", "failed"]);
1310
+ var DomainDnsStatusSchema = z13.enum(["pending_verification", "provisioned", "failed"]);
1311
+ var DomainInboundStatusSchema = z13.enum(["pending", "verified", "failed"]);
1312
+ var DomainAppConnectStatusSchema = z13.enum(["pending", "connected", "failed"]);
1313
+ var DnsRecordSchema = z13.object({
1314
+ type: z13.enum(["TXT", "CNAME", "MX"]),
1315
+ host: z13.string(),
1316
+ value: z13.string(),
1317
+ priority: z13.number().int().nullable(),
1170
1318
  /** Vetta owns this record: `_dmarc`, DKIM, inbound MX. The agent may read it, never write it. */
1171
- managed: z12.boolean()
1319
+ managed: z13.boolean()
1172
1320
  });
1173
- var DomainSchema = z12.object({
1321
+ var DomainSchema = z13.object({
1174
1322
  id: idOf("dom"),
1175
- object: z12.literal("domain"),
1323
+ object: z13.literal("domain"),
1176
1324
  /** A domain belongs to the **organization**, not to one identity: two identities share one. */
1177
- name: z12.string(),
1325
+ name: z13.string(),
1178
1326
  kind: DomainKindSchema,
1179
1327
  status: DomainStatusSchema,
1180
1328
  dns_status: DomainDnsStatusSchema,
1181
1329
  inbound_status: DomainInboundStatusSchema,
1182
1330
  app_connect_status: DomainAppConnectStatusSchema,
1183
- records: z12.array(DnsRecordSchema),
1331
+ records: z13.array(DnsRecordSchema),
1184
1332
  last_verified_at: Timestamp.nullable(),
1185
1333
  created_at: Timestamp
1186
1334
  });
1187
- var EmailInboxSchema = z12.object({
1335
+ var EmailInboxSchema = z13.object({
1188
1336
  id: idOf("eml"),
1189
- object: z12.literal("email_inbox"),
1337
+ object: z13.literal("email_inbox"),
1190
1338
  identity_id: idOf("idn"),
1191
1339
  domain_id: idOf("dom"),
1192
- address: z12.string(),
1193
- localpart: z12.string(),
1340
+ address: z13.string(),
1341
+ localpart: z13.string(),
1194
1342
  /** Inbound routing keys off this: mail to the address wakes exactly this agent. */
1195
1343
  owning_agent_id: idOf("agt"),
1196
- status: z12.enum(["active", "disabled"]),
1344
+ status: z13.enum(["active", "disabled"]),
1197
1345
  created_at: Timestamp
1198
1346
  });
1199
- var PhoneTierSchema = z12.enum(["sole_prop", "standard"]);
1200
- var BrandStatusSchema = z12.enum(["none", "pending_verification", "verified", "rejected"]);
1201
- var CampaignStatusSchema = z12.enum(["none", "pending", "approved", "rejected"]);
1202
- var PhoneNumberSchema = z12.object({
1347
+ var PhoneTierSchema = z13.enum(["sole_prop", "standard"]);
1348
+ var BrandStatusSchema = z13.enum(["none", "pending_verification", "verified", "rejected"]);
1349
+ var CampaignStatusSchema = z13.enum(["none", "pending", "approved", "rejected"]);
1350
+ var PhoneNumberSchema = z13.object({
1203
1351
  id: idOf("pho"),
1204
- object: z12.literal("phone_number"),
1352
+ object: z13.literal("phone_number"),
1205
1353
  identity_id: idOf("idn"),
1206
- e164: z12.string(),
1207
- country: z12.string(),
1208
- capabilities: z12.object({
1354
+ e164: z13.string(),
1355
+ country: z13.string(),
1356
+ capabilities: z13.object({
1209
1357
  /** Live the moment the number is bought — inbound never waits on carrier registration. */
1210
- sms_inbound: z12.boolean(),
1358
+ sms_inbound: z13.boolean(),
1211
1359
  /** True **iff** `campaign_status === "approved"`. Nothing else may set it. */
1212
- sms_outbound: z12.boolean(),
1360
+ sms_outbound: z13.boolean(),
1213
1361
  /** Voice is not a P2 capability; the field exists so its absence is explicit. */
1214
- voice: z12.literal(false)
1362
+ voice: z13.literal(false)
1215
1363
  }),
1216
1364
  tier: PhoneTierSchema,
1217
1365
  brand_status: BrandStatusSchema,
@@ -1219,46 +1367,46 @@ var PhoneNumberSchema = z12.object({
1219
1367
  provisioned_at: Timestamp.nullable(),
1220
1368
  created_at: Timestamp
1221
1369
  });
1222
- var InboundMessageSchema = z12.object({
1370
+ var InboundMessageSchema = z13.object({
1223
1371
  id: idOf("inb"),
1224
- object: z12.literal("inbound_message"),
1225
- channel: z12.enum(["email", "sms"]),
1372
+ object: z13.literal("inbound_message"),
1373
+ channel: z13.enum(["email", "sms"]),
1226
1374
  identity_id: idOf("idn"),
1227
1375
  /** The `eml_`/`pho_` endpoint it arrived at — the persona is decided by *where*, not by *who*. */
1228
- endpoint_id: z12.string(),
1229
- from: z12.string(),
1230
- to: z12.string(),
1231
- subject: z12.string().nullable(),
1232
- text: z12.string(),
1376
+ endpoint_id: z13.string(),
1377
+ from: z13.string(),
1378
+ to: z13.string(),
1379
+ subject: z13.string().nullable(),
1380
+ text: z13.string(),
1233
1381
  /** SPF/DKIM/DMARC for mail, carrier origin for SMS. Kept for the audit of why it was accepted. */
1234
- auth: z12.record(z12.string(), z12.string()),
1382
+ auth: z13.record(z13.string(), z13.string()),
1235
1383
  /** The session this message woke. Null until the wake seam lands (see ADR-0120). */
1236
1384
  session_id: idOf("ses").nullable(),
1237
1385
  received_at: Timestamp
1238
1386
  });
1239
1387
 
1240
1388
  // ../core/src/schema/app.ts
1241
- import { z as z13 } from "zod";
1242
- var AppTypeSchema = z13.enum(["frontend_only", "fullstack"]);
1243
- var AppStatusSchema = z13.enum(["provisioning", "active", "error"]);
1244
- var AppMcpPathSchema = z13.string().regex(/^\/\S*$/, "must be an absolute path beginning with /").max(128);
1245
- var AppSchema = z13.object({
1389
+ import { z as z14 } from "zod";
1390
+ var AppTypeSchema = z14.enum(["frontend_only", "fullstack"]);
1391
+ var AppStatusSchema = z14.enum(["provisioning", "active", "error"]);
1392
+ var AppMcpPathSchema = z14.string().regex(/^\/\S*$/, "must be an absolute path beginning with /").max(128);
1393
+ var AppSchema = z14.object({
1246
1394
  id: idOf("app"),
1247
- object: z13.literal("app"),
1248
- name: z13.string(),
1249
- description: z13.string().nullable(),
1395
+ object: z14.literal("app"),
1396
+ name: z14.string(),
1397
+ description: z14.string().nullable(),
1250
1398
  type: AppTypeSchema,
1251
1399
  /**
1252
1400
  * The customer's own project name that made this app, or `null` for one made outside a project
1253
1401
  * (ADR-0375). Customer-visible, unlike the provider handles: it is the word the customer typed,
1254
1402
  * and the refusal that guards a name quotes it.
1255
1403
  */
1256
- project: z13.string().nullable(),
1404
+ project: z14.string().nullable(),
1257
1405
  status: AppStatusSchema,
1258
1406
  /** The address the app answers on — platform hostname until a custom domain connects. */
1259
- url: z13.string().nullable(),
1407
+ url: z14.string().nullable(),
1260
1408
  /** White-label words when `status` is `error`; never the provider's. */
1261
- error: z13.string().nullable(),
1409
+ error: z14.string().nullable(),
1262
1410
  /** Where the app serves MCP, or `null`. The bearer token for it is a server column. */
1263
1411
  mcp: AppMcpPathSchema.nullable(),
1264
1412
  /**
@@ -1266,49 +1414,49 @@ var AppSchema = z13.object({
1266
1414
  * than linking its `url` (`§29.1`)? True when the platform holds the app's `DASHBOARD_TOKEN`
1267
1415
  * or a secret of that name exists on the app; derived on read, never stored.
1268
1416
  */
1269
- dashboard: z13.boolean(),
1417
+ dashboard: z14.boolean(),
1270
1418
  created_at: Timestamp
1271
1419
  });
1272
- var AppDeploymentStatusSchema = z13.enum(["queued", "building", "ready", "error"]);
1273
- var AppDeploymentSchema = z13.object({
1420
+ var AppDeploymentStatusSchema = z14.enum(["queued", "building", "ready", "error"]);
1421
+ var AppDeploymentSchema = z14.object({
1274
1422
  id: idOf("apd"),
1275
- object: z13.literal("app_deployment"),
1423
+ object: z14.literal("app_deployment"),
1276
1424
  app_id: idOf("app"),
1277
1425
  status: AppDeploymentStatusSchema,
1278
- url: z13.string().nullable(),
1279
- error: z13.string().nullable(),
1426
+ url: z14.string().nullable(),
1427
+ error: z14.string().nullable(),
1280
1428
  /** The client's opaque digest of the files, echoed verbatim so it can skip an unchanged deploy. */
1281
- content_hash: z13.string().nullable(),
1429
+ content_hash: z14.string().nullable(),
1282
1430
  created_at: Timestamp
1283
1431
  });
1284
- var AppDeploymentFilesSchema = z13.object({
1285
- object: z13.literal("app_deployment_files"),
1432
+ var AppDeploymentFilesSchema = z14.object({
1433
+ object: z14.literal("app_deployment_files"),
1286
1434
  deployment_id: idOf("apd"),
1287
- files: z13.record(z13.string().min(1), z13.string())
1435
+ files: z14.record(z14.string().min(1), z14.string())
1288
1436
  });
1289
- var AppSecretSchema = z13.object({
1290
- object: z13.literal("app_secret"),
1291
- name: z13.string(),
1437
+ var AppSecretSchema = z14.object({
1438
+ object: z14.literal("app_secret"),
1439
+ name: z14.string(),
1292
1440
  /** The client's opaque digest of the value, echoed verbatim so it can skip an unchanged write. */
1293
- value_hash: z13.string().nullable(),
1441
+ value_hash: z14.string().nullable(),
1294
1442
  created_at: Timestamp
1295
1443
  });
1296
- var AppEntrySchema = z13.object({
1297
- object: z13.literal("app_entry"),
1298
- url: z13.string(),
1299
- ticket: z13.string()
1444
+ var AppEntrySchema = z14.object({
1445
+ object: z14.literal("app_entry"),
1446
+ url: z14.string(),
1447
+ ticket: z14.string()
1300
1448
  });
1301
- var AppAccessSchema = z13.object({
1302
- object: z13.literal("app_access"),
1303
- url: z13.string().nullable(),
1304
- password: z13.string().nullable()
1449
+ var AppAccessSchema = z14.object({
1450
+ object: z14.literal("app_access"),
1451
+ url: z14.string().nullable(),
1452
+ password: z14.string().nullable()
1305
1453
  });
1306
- var AppDomainStatusSchema = z13.enum(["pending", "connected", "failed"]);
1307
- var AppDomainSchema = z13.object({
1308
- object: z13.literal("app_domain"),
1454
+ var AppDomainStatusSchema = z14.enum(["pending", "connected", "failed"]);
1455
+ var AppDomainSchema = z14.object({
1456
+ object: z14.literal("app_domain"),
1309
1457
  app_id: idOf("app"),
1310
1458
  domain_id: idOf("dom"),
1311
- domain: z13.string(),
1459
+ domain: z14.string(),
1312
1460
  status: AppDomainStatusSchema,
1313
1461
  created_at: Timestamp
1314
1462
  });
@@ -1316,58 +1464,76 @@ var ENV_NAME = /^[A-Z_][A-Z0-9_]*$/;
1316
1464
  var APP_NAME = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
1317
1465
 
1318
1466
  // ../core/src/schema/install.ts
1319
- import { z as z14 } from "zod";
1320
- var BlueprintInstallSourceSchema = z14.enum(["studio", "cli"]);
1321
- var BlueprintInstallStatusSchema = z14.enum(["pending", "applied", "failed"]);
1322
- var ResourceActionSchema = z14.enum(["created", "updated", "unchanged", "deleted", "refused"]);
1323
- var ResourceReportSchema = z14.object({
1324
- name: z14.string().min(1),
1467
+ import { z as z15 } from "zod";
1468
+ var BlueprintInstallSourceSchema = z15.enum(["studio", "cli"]);
1469
+ var BlueprintInstallStatusSchema = z15.enum(["pending", "applied", "failed"]);
1470
+ var ResourceActionSchema = z15.enum(["created", "updated", "unchanged", "deleted", "refused"]);
1471
+ var ResourceReportSchema = z15.object({
1472
+ name: z15.string().min(1),
1325
1473
  action: ResourceActionSchema,
1326
1474
  /** The `agt_`/`app_`/`ses_`… the line resolved to. Absent on a refusal that never got an id. */
1327
- id: z14.string().optional(),
1475
+ id: z15.string().optional(),
1328
1476
  /** An app's hostname once its build went live; `null` while it has none. Apps only. */
1329
- url: z14.string().nullable().optional(),
1330
- reason: z14.string().optional()
1331
- });
1332
- var BlueprintReportSchema = z14.object({
1333
- skills: z14.array(ResourceReportSchema),
1334
- identities: z14.array(ResourceReportSchema),
1335
- vaults: z14.array(ResourceReportSchema),
1336
- apps: z14.array(ResourceReportSchema),
1337
- agents: z14.array(ResourceReportSchema),
1338
- schedules: z14.array(ResourceReportSchema),
1339
- intake: z14.array(ResourceReportSchema),
1340
- skipped: z14.array(z14.string()),
1341
- deselected: z14.array(z14.string()).default([])
1342
- });
1343
- var BlueprintSelectionSchema = z14.object({
1344
- agents: z14.array(z14.string().min(1)),
1345
- apps: z14.array(z14.string().min(1))
1346
- });
1347
- var BlueprintInstallSchema = z14.object({
1477
+ url: z15.string().nullable().optional(),
1478
+ /**
1479
+ * What a TASK is called and who owes it. `name` is the declaration key (`first-render`), which is
1480
+ * how a re-apply finds the same card and is not a sentence anybody wants read to them. The
1481
+ * dashboard's opening message lists the team's work, so it needs the title the board shows and the
1482
+ * seat that holds it. Tasks only.
1483
+ */
1484
+ title: z15.string().optional(),
1485
+ assignee: z15.string().optional(),
1486
+ /**
1487
+ * A SCHEDULE'S brief, in one short line — the opening sentence of its `input_template`. A
1488
+ * schedules line is named `<agent> @ <cron>`, which says when something runs and nothing at all
1489
+ * about what it does, so a roadmap built from these lines could only ever have been a timetable.
1490
+ * Written here rather than read back from the deployment so the receipt stays the one read the
1491
+ * welcome needs. Schedules only.
1492
+ */
1493
+ summary: z15.string().optional(),
1494
+ reason: z15.string().optional()
1495
+ });
1496
+ var BlueprintReportSchema = z15.object({
1497
+ skills: z15.array(ResourceReportSchema),
1498
+ identities: z15.array(ResourceReportSchema),
1499
+ vaults: z15.array(ResourceReportSchema),
1500
+ apps: z15.array(ResourceReportSchema),
1501
+ agents: z15.array(ResourceReportSchema),
1502
+ schedules: z15.array(ResourceReportSchema),
1503
+ intake: z15.array(ResourceReportSchema),
1504
+ /** One line per declared task (§31.11), `id` the card's `crd_`. Defaulted so older rows parse. */
1505
+ tasks: z15.array(ResourceReportSchema).default([]),
1506
+ skipped: z15.array(z15.string()),
1507
+ deselected: z15.array(z15.string()).default([])
1508
+ });
1509
+ var BlueprintSelectionSchema = z15.object({
1510
+ agents: z15.array(z15.string().min(1)),
1511
+ apps: z15.array(z15.string().min(1))
1512
+ });
1513
+ var BlueprintInstallSchema = z15.object({
1348
1514
  id: idOf("bpi"),
1349
- object: z14.literal("blueprint_install"),
1515
+ object: z15.literal("blueprint_install"),
1350
1516
  /** The customer's own `defineProject({ name })` — the same word `app.project` stamps (§29.2). */
1351
- project: z14.string().min(1),
1517
+ project: z15.string().min(1),
1352
1518
  /** The pair the declaration resolved to; `null` for a declaration that names no blueprint. */
1353
- blueprint: z14.string().nullable(),
1354
- template: z14.string().nullable(),
1519
+ blueprint: z15.string().nullable(),
1520
+ template: z15.string().nullable(),
1355
1521
  /**
1356
1522
  * Applies, not versions of anything: 1 on the first apply, +1 on each one after, whichever writer
1357
1523
  * made it. It is not an agent version and it never rolls back.
1358
1524
  */
1359
- revision: z14.number().int().positive(),
1525
+ revision: z15.number().int().positive(),
1360
1526
  /**
1361
1527
  * The blueprint artifact version this came from, or `null` when it was applied from a working
1362
1528
  * tree — an operator editing a clone has no version to name.
1363
1529
  */
1364
- artifact_version: z14.string().nullable(),
1530
+ artifact_version: z15.string().nullable(),
1365
1531
  /**
1366
1532
  * The setup answers this project was configured with (§7.1 fields, keyed by their `key`), so a
1367
1533
  * re-apply does not re-ask and both writers configure from the same answers. Configuration only:
1368
1534
  * a secret is a vault credential (§23) or an app secret (§29.2), and neither is ever an answer.
1369
1535
  */
1370
- answers: z14.record(z14.string(), z14.unknown()),
1536
+ answers: z15.record(z15.string(), z15.unknown()),
1371
1537
  /**
1372
1538
  * NO `declaration` ON THE WIRE, and that is the reconciliation of §29.6 with §31.1.
1373
1539
  *
@@ -1396,7 +1562,7 @@ var BlueprintInstallSchema = z14.object({
1396
1562
  report: BlueprintReportSchema.nullable(),
1397
1563
  status: BlueprintInstallStatusSchema,
1398
1564
  /** Why a `failed` run threw, in one sentence; `null` on every other row. Never a stack or a key. */
1399
- failure: z14.string().nullable(),
1565
+ failure: z15.string().nullable(),
1400
1566
  /**
1401
1567
  * The `selection` the apply carried, or `null` — every row written before §31.2 and every apply
1402
1568
  * that omitted it, both meaning "everything". Defaulted so those rows parse unchanged.
@@ -1407,271 +1573,321 @@ var BlueprintInstallSchema = z14.object({
1407
1573
  applied_at: Timestamp,
1408
1574
  created_at: Timestamp
1409
1575
  });
1410
- var ProjectContextAnswerSchema = z14.object({
1411
- key: z14.string().min(1),
1412
- label: z14.string(),
1413
- value: z14.union([z14.string(), z14.array(z14.string())])
1414
- });
1415
- var ProjectContextSchema = z14.object({
1416
- object: z14.literal("project_context"),
1417
- project: z14.string().min(1),
1418
- blueprint: z14.string().nullable(),
1419
- template: z14.string().nullable(),
1420
- artifact_version: z14.string().nullable(),
1421
- answers: z14.array(ProjectContextAnswerSchema),
1422
- apps: z14.array(z14.object({ name: z14.string().min(1), url: z14.string().nullable() })),
1423
- agents: z14.array(z14.object({ name: z14.string().min(1), role: z14.string().nullable() })),
1576
+ var ProjectContextAnswerSchema = z15.object({
1577
+ key: z15.string().min(1),
1578
+ label: z15.string(),
1579
+ value: z15.union([z15.string(), z15.array(z15.string())])
1580
+ });
1581
+ var ProjectContextSchema = z15.object({
1582
+ object: z15.literal("project_context"),
1583
+ project: z15.string().min(1),
1584
+ blueprint: z15.string().nullable(),
1585
+ template: z15.string().nullable(),
1586
+ artifact_version: z15.string().nullable(),
1587
+ answers: z15.array(ProjectContextAnswerSchema),
1588
+ apps: z15.array(z15.object({ name: z15.string().min(1), url: z15.string().nullable() })),
1589
+ agents: z15.array(z15.object({ name: z15.string().min(1), role: z15.string().nullable() })),
1424
1590
  /** `context_updated_at` once the answers have been edited, `applied_at` until then. */
1425
1591
  updated_at: Timestamp
1426
1592
  });
1427
1593
 
1428
1594
  // ../core/src/schema/blueprint.ts
1429
- import { z as z15 } from "zod";
1430
- var BlueprintScheduleSchema = z15.object({
1431
- agent: z15.string().min(1),
1432
- cron: z15.string().min(1),
1433
- timezone: z15.string().nullable(),
1595
+ import { z as z17 } from "zod";
1596
+
1597
+ // ../core/src/schema/social.ts
1598
+ import { z as z16 } from "zod";
1599
+ var SOCIAL_PLATFORMS = [
1600
+ "bluesky",
1601
+ "facebook",
1602
+ "instagram",
1603
+ "linkedin",
1604
+ "mastodon",
1605
+ "pinterest",
1606
+ "reddit",
1607
+ "threads",
1608
+ "tiktok",
1609
+ "x",
1610
+ "youtube"
1611
+ ];
1612
+ var SOCIAL_APPS = /* @__PURE__ */ new Set([...SOCIAL_PLATFORMS, "twitter"]);
1613
+ var SOCIAL_TEXT_PLATFORMS = [
1614
+ "bluesky",
1615
+ "facebook",
1616
+ "linkedin",
1617
+ "mastodon",
1618
+ "threads",
1619
+ "x"
1620
+ ];
1621
+ var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
1622
+ var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
1623
+ var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
1624
+ var SocialVisibilitySchema = z16.enum(SOCIAL_VISIBILITIES);
1625
+ 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`;
1626
+ var SocialPlatformSchema = z16.enum(SOCIAL_PLATFORMS);
1627
+ var SocialTextPlatformSchema = z16.enum(SOCIAL_TEXT_PLATFORMS);
1628
+ var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
1629
+ var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
1630
+ 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`;
1631
+ var SocialAccountSchema = z16.object({
1632
+ id: z16.string().min(1),
1633
+ object: z16.literal("social_account"),
1634
+ identity_id: idOf("idn"),
1635
+ platform: SocialPlatformSchema,
1636
+ username: z16.string().nullable(),
1637
+ display_name: z16.string().nullable(),
1638
+ avatar_url: z16.url().nullable(),
1639
+ connected_at: Timestamp.nullable()
1640
+ });
1641
+ var SocialPostStatusSchema = z16.enum([
1642
+ "draft",
1643
+ "scheduled",
1644
+ "processing",
1645
+ "posted",
1646
+ "failed",
1647
+ "deleted"
1648
+ ]);
1649
+ var SocialPostSchema = z16.object({
1650
+ id: z16.string().min(1),
1651
+ object: z16.literal("social_post"),
1652
+ identity_id: idOf("idn"),
1653
+ title: z16.string(),
1654
+ platforms: z16.array(SocialPlatformSchema),
1655
+ status: SocialPostStatusSchema,
1656
+ scheduled_at: Timestamp.nullable(),
1657
+ posted_at: Timestamp.nullable(),
1658
+ error: z16.string().nullable()
1659
+ });
1660
+ var SocialUploadSchema = z16.object({
1661
+ id: z16.string().min(1),
1662
+ object: z16.literal("social_upload"),
1663
+ identity_id: idOf("idn"),
1664
+ type: z16.enum(["image", "video", "document"]),
1665
+ url: z16.url().nullable()
1666
+ });
1667
+ var SocialAnalyticsSchema = z16.object({
1668
+ object: z16.literal("social_analytics"),
1669
+ identity_id: idOf("idn"),
1670
+ resource_id: z16.string().min(1),
1671
+ platform: SocialPlatformSchema.nullable(),
1672
+ data: z16.unknown()
1673
+ });
1674
+ var SocialCommentSchema = z16.object({
1675
+ id: z16.string().min(1),
1676
+ object: z16.literal("social_comment"),
1677
+ identity_id: idOf("idn"),
1678
+ post_id: z16.string().min(1),
1679
+ platforms: z16.array(SocialPlatformSchema),
1680
+ status: SocialPostStatusSchema,
1681
+ posted_at: Timestamp.nullable(),
1682
+ data: z16.unknown()
1683
+ });
1684
+
1685
+ // ../core/src/schema/blueprint.ts
1686
+ var BlueprintScheduleSchema = z17.object({
1687
+ agent: z17.string().min(1),
1688
+ cron: z17.string().min(1),
1689
+ timezone: z17.string().nullable(),
1434
1690
  /** The message each fire opens its session with — the sentence worth printing. */
1435
- input: z15.string().min(1),
1691
+ input: z17.string().min(1),
1436
1692
  budget_micro_usd: MicroUsdField.nonnegative()
1437
1693
  });
1438
1694
  var BlueprintBudgetSchema = BlueprintScheduleSchema.pick({ agent: true, cron: true, budget_micro_usd: true });
1439
- var BlueprintCrewSchema = z15.object({
1440
- name: z15.string().min(1),
1441
- description: z15.string().nullable(),
1442
- model: z15.string().min(1),
1443
- briefed: z15.boolean(),
1444
- intake: z15.string().nullable().optional(),
1695
+ var BlueprintCrewSchema = z17.object({
1696
+ name: z17.string().min(1),
1697
+ description: z17.string().nullable(),
1698
+ model: z17.string().min(1),
1699
+ briefed: z17.boolean(),
1700
+ intake: z17.string().nullable().optional(),
1445
1701
  /** What the first session may spend: the intake's own cap, else the agent's (§31.4). Set iff `briefed`. */
1446
1702
  intake_micro_usd: MicroUsdField.nonnegative().optional(),
1447
- role: z15.string().min(1).optional(),
1448
- skills: z15.array(SkillRefSchema).optional(),
1449
- tools: z15.array(z15.string().min(1)).optional(),
1450
- required: z15.boolean().optional()
1703
+ role: z17.string().min(1).optional(),
1704
+ skills: z17.array(SkillRefSchema).optional(),
1705
+ tools: z17.array(z17.string().min(1)).optional(),
1706
+ required: z17.boolean().optional()
1451
1707
  });
1452
- var BlueprintAppSchema = z15.object({
1453
- name: z15.string().min(1),
1708
+ var BlueprintAppSchema = z17.object({
1709
+ name: z17.string().min(1),
1454
1710
  type: AppTypeSchema,
1455
- description: z15.string().nullable(),
1456
- mcp: z15.string().nullable().optional(),
1457
- tools: z15.array(z15.string().min(1)).optional(),
1711
+ description: z17.string().nullable(),
1712
+ mcp: z17.string().nullable().optional(),
1713
+ tools: z17.array(z17.string().min(1)).optional(),
1458
1714
  /** Whether an install may deselect it (§31.2). Optional: the rollout argument above. */
1459
- required: z15.boolean().optional()
1715
+ required: z17.boolean().optional()
1716
+ });
1717
+ var BlueprintIdentityConnectionsSchema = z17.object({
1718
+ social: z17.object({
1719
+ from: z17.string().min(1),
1720
+ map: z17.record(z17.string().min(1), SocialPlatformSchema)
1721
+ }).optional()
1722
+ });
1723
+ var BlueprintIdentitySchema = z17.object({
1724
+ name: z17.string().min(1),
1725
+ description: z17.string().nullable(),
1726
+ connections: BlueprintIdentityConnectionsSchema.optional()
1460
1727
  });
1461
- var ContentHashSchema = z15.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
1462
- var BlueprintTreeSchema = z15.object({
1728
+ var ContentHashSchema = z17.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
1729
+ var BlueprintTreeSchema = z17.object({
1463
1730
  /** `apps[].name` in the declaration — the same name §31.5 prints and the install ensures by. */
1464
- app: z15.string().min(1),
1731
+ app: z17.string().min(1),
1465
1732
  content_hash: ContentHashSchema
1466
1733
  });
1467
- var BlueprintArtifactSchema = z15.object({
1734
+ var BlueprintArtifactSchema = z17.object({
1468
1735
  id: idOf("bpa"),
1469
- object: z15.literal("blueprint_artifact"),
1736
+ object: z17.literal("blueprint_artifact"),
1470
1737
  /** The machine — its repository, screens and `/api/*`. */
1471
- blueprint: z15.string().min(1),
1738
+ blueprint: z17.string().min(1),
1472
1739
  /** Which of that blueprint's templates provides the crew. */
1473
- template: z15.string().min(1),
1740
+ template: z17.string().min(1),
1474
1741
  /** The blueprint repository's own released version. Stored, never parsed (ADR-0401). */
1475
- version: z15.string().min(1),
1742
+ version: z17.string().min(1),
1476
1743
  /**
1477
1744
  * The built trees, one per deployable app, ordered as the declaration orders its apps. Never
1478
1745
  * empty: an artifact that built nothing is not an artifact, and the column behind it says so
1479
1746
  * (migration 0040) exactly as the single `content_hash` it replaces was `not null`.
1480
1747
  */
1481
- trees: z15.array(BlueprintTreeSchema).min(1),
1748
+ trees: z17.array(BlueprintTreeSchema).min(1),
1482
1749
  /**
1483
1750
  * The setup questions, asked by the studio **before** provisioning. `QuestionField` (§7.1) is
1484
1751
  * reused rather than restated: a setup question and a question a parked agent asks are the same
1485
1752
  * object at different times, so one component renders both.
1486
1753
  */
1487
- questions: z15.array(QuestionFieldSchema),
1488
- schedules: z15.array(BlueprintScheduleSchema),
1754
+ questions: z17.array(QuestionFieldSchema),
1755
+ schedules: z17.array(BlueprintScheduleSchema),
1489
1756
  /** Who the crew is, and what it deploys — §31.5. Derived from `declaration`, never stored twice. */
1490
- agents: z15.array(BlueprintCrewSchema),
1491
- apps: z15.array(BlueprintAppSchema),
1757
+ agents: z17.array(BlueprintCrewSchema),
1758
+ apps: z17.array(BlueprintAppSchema),
1492
1759
  /**
1493
1760
  * The agents a template creates per client the operator signs — printed, never provisioned by an
1494
1761
  * apply (§31.1). Absent on rows published before WS12 v2, hence optional.
1495
1762
  */
1496
- crew_per_client: z15.array(BlueprintCrewSchema).optional(),
1763
+ crew_per_client: z17.array(BlueprintCrewSchema).optional(),
1764
+ /**
1765
+ * The personas the crew posts from, and which accounts to connect to each before the crew
1766
+ * exists (§31.10). Derived from `declaration` like `agents`; optional for the §31.5 rollout reason.
1767
+ */
1768
+ identities: z17.array(BlueprintIdentitySchema).optional(),
1497
1769
  /**
1498
1770
  * The creator template a row was published from (§42.8), `null` on every first-party row.
1499
1771
  * `creator_name` is the public display name the landing page credits. The API sends all three
1500
1772
  * on every row; they are optional here only so an artifact typed before §42 still reads.
1501
1773
  */
1502
1774
  creator_template_id: idOf("ctp").nullish(),
1503
- creator_template_version: z15.number().int().positive().nullish(),
1504
- creator_name: z15.string().min(1).nullish(),
1775
+ creator_template_version: z17.number().int().positive().nullish(),
1776
+ creator_name: z17.string().min(1).nullish(),
1505
1777
  published_at: Timestamp
1506
1778
  });
1507
1779
 
1508
1780
  // ../core/src/schema/vault.ts
1509
- import { z as z16 } from "zod";
1510
- var VaultCredentialKindSchema = z16.enum(["env_var", "static_bearer", "mcp_oauth"]);
1511
- var VaultSchema = z16.object({
1781
+ import { z as z18 } from "zod";
1782
+ var VaultCredentialKindSchema = z18.enum(["env_var", "static_bearer", "mcp_oauth"]);
1783
+ var VaultSchema = z18.object({
1512
1784
  id: idOf("vlt"),
1513
- object: z16.literal("vault"),
1785
+ object: z18.literal("vault"),
1514
1786
  identity_id: idOf("idn").nullable(),
1515
- display_name: z16.string().min(1).max(128),
1516
- credential_count: z16.number().int().nonnegative(),
1787
+ display_name: z18.string().min(1).max(128),
1788
+ credential_count: z18.number().int().nonnegative(),
1517
1789
  created_at: Timestamp
1518
1790
  });
1519
- var VaultCredentialSchema = z16.object({
1791
+ var VaultCredentialSchema = z18.object({
1520
1792
  id: idOf("vcr"),
1521
- object: z16.literal("vault_credential"),
1793
+ object: z18.literal("vault_credential"),
1522
1794
  vault_id: idOf("vlt"),
1523
1795
  kind: VaultCredentialKindSchema,
1524
1796
  /** For `env_var`, the environment variable name. For the MCP kinds, a display label. */
1525
- key: z16.string().min(1).max(128),
1797
+ key: z18.string().min(1).max(128),
1526
1798
  /** The exact destination host an `env_var` credential is bound to. Never a wildcard. */
1527
- host: z16.string().nullable(),
1799
+ host: z18.string().nullable(),
1528
1800
  /** The exact MCP server URL an `mcp_*` token is matched to. */
1529
- mcp_server_url: z16.url().nullable(),
1530
- placeholder_ref: z16.string(),
1801
+ mcp_server_url: z18.url().nullable(),
1802
+ placeholder_ref: z18.string(),
1531
1803
  expires_at: Timestamp.nullable(),
1532
1804
  last_injected_at: Timestamp.nullable(),
1533
1805
  created_at: Timestamp
1534
1806
  });
1535
1807
 
1536
- // ../core/src/schema/social.ts
1537
- import { z as z17 } from "zod";
1538
- var SOCIAL_PLATFORMS = [
1539
- "bluesky",
1540
- "facebook",
1541
- "instagram",
1542
- "linkedin",
1543
- "mastodon",
1544
- "pinterest",
1545
- "reddit",
1546
- "threads",
1547
- "tiktok",
1548
- "x",
1549
- "youtube"
1550
- ];
1551
- var SOCIAL_TEXT_PLATFORMS = [
1552
- "bluesky",
1553
- "facebook",
1554
- "linkedin",
1555
- "mastodon",
1556
- "threads",
1557
- "x"
1558
- ];
1559
- var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
1560
- var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
1561
- var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
1562
- var SocialVisibilitySchema = z17.enum(SOCIAL_VISIBILITIES);
1563
- 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`;
1564
- var SocialPlatformSchema = z17.enum(SOCIAL_PLATFORMS);
1565
- var SocialTextPlatformSchema = z17.enum(SOCIAL_TEXT_PLATFORMS);
1566
- var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
1567
- var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
1568
- 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`;
1569
- var SocialAccountSchema = z17.object({
1570
- id: z17.string().min(1),
1571
- object: z17.literal("social_account"),
1572
- identity_id: idOf("idn"),
1573
- platform: SocialPlatformSchema,
1574
- username: z17.string().nullable(),
1575
- display_name: z17.string().nullable(),
1576
- avatar_url: z17.url().nullable(),
1577
- connected_at: Timestamp.nullable()
1578
- });
1579
- var SocialPostStatusSchema = z17.enum([
1580
- "draft",
1581
- "scheduled",
1582
- "processing",
1583
- "posted",
1584
- "failed",
1585
- "deleted"
1586
- ]);
1587
- var SocialPostSchema = z17.object({
1588
- id: z17.string().min(1),
1589
- object: z17.literal("social_post"),
1590
- identity_id: idOf("idn"),
1591
- title: z17.string(),
1592
- platforms: z17.array(SocialPlatformSchema),
1593
- status: SocialPostStatusSchema,
1594
- scheduled_at: Timestamp.nullable(),
1595
- posted_at: Timestamp.nullable(),
1596
- error: z17.string().nullable()
1597
- });
1598
- var SocialUploadSchema = z17.object({
1599
- id: z17.string().min(1),
1600
- object: z17.literal("social_upload"),
1601
- identity_id: idOf("idn"),
1602
- type: z17.enum(["image", "video", "document"]),
1603
- url: z17.url().nullable()
1604
- });
1605
- var SocialAnalyticsSchema = z17.object({
1606
- object: z17.literal("social_analytics"),
1607
- identity_id: idOf("idn"),
1608
- resource_id: z17.string().min(1),
1609
- platform: SocialPlatformSchema.nullable(),
1610
- data: z17.unknown()
1611
- });
1612
- var SocialCommentSchema = z17.object({
1613
- id: z17.string().min(1),
1614
- object: z17.literal("social_comment"),
1615
- identity_id: idOf("idn"),
1616
- post_id: z17.string().min(1),
1617
- platforms: z17.array(SocialPlatformSchema),
1618
- status: SocialPostStatusSchema,
1619
- posted_at: Timestamp.nullable(),
1620
- data: z17.unknown()
1621
- });
1622
-
1623
1808
  // ../core/src/schema/handoff.ts
1624
- import { z as z18 } from "zod";
1625
- var HandoffRequestSchema = z18.object({
1626
- agent: z18.string().min(1),
1627
- message: z18.string().min(1),
1628
- handoff_key: z18.string().min(1).max(128).optional(),
1629
- budget_micro_usd: z18.number().int().positive().optional()
1630
- });
1631
- var HandoffSchema = z18.object({
1632
- object: z18.literal("handoff"),
1809
+ import { z as z19 } from "zod";
1810
+ var MAX_HANDOFF_TARGETS = 6;
1811
+ var HandoffRequestSchema = z19.object({
1812
+ agent: z19.string().min(1),
1813
+ message: z19.string().min(1),
1814
+ handoff_key: z19.string().min(1).max(128).optional(),
1815
+ budget_micro_usd: z19.number().int().positive().optional()
1816
+ });
1817
+ var HandoffSchema = z19.object({
1818
+ object: z19.literal("handoff"),
1633
1819
  session_id: idOf("ses"),
1634
- status: z18.enum(["queued", "already_running"]),
1635
- handoff_key: z18.string().nullable()
1636
- });
1637
- var SessionHandoffSchema = z18.object({
1820
+ status: z19.enum(["queued", "already_running"]),
1821
+ handoff_key: z19.string().nullable()
1822
+ });
1823
+ var SessionHandoffRequestSchema = z19.object({
1824
+ agents: z19.array(z19.string().min(1)).min(1).max(MAX_HANDOFF_TARGETS),
1825
+ message: z19.string().min(1),
1826
+ handoff_key: z19.string().min(1).max(128).optional(),
1827
+ budget_micro_usd: z19.number().int().positive().optional()
1828
+ });
1829
+ var HandoffRefusalSchema = z19.object({
1830
+ object: z19.literal("handoff_refusal"),
1831
+ agent: z19.string(),
1832
+ code: z19.string(),
1833
+ message: z19.string()
1834
+ });
1835
+ var HandoffBatchSchema = z19.object({
1836
+ object: z19.literal("handoff_batch"),
1837
+ handoffs: z19.array(HandoffSchema.extend({ agent_id: idOf("agt") })),
1838
+ refusals: z19.array(HandoffRefusalSchema)
1839
+ });
1840
+ var SessionHandoffSchema = z19.object({
1638
1841
  from_session: idOf("ses"),
1639
1842
  from_agent: idOf("agt"),
1640
- key: z18.string().nullable(),
1641
- depth: z18.number().int().positive()
1843
+ key: z19.string().nullable(),
1844
+ depth: z19.number().int().positive()
1845
+ });
1846
+ var ChannelBriefSchema = z19.object({
1847
+ root_session_id: idOf("ses"),
1848
+ name: z19.string().min(1),
1849
+ members: z19.array(z19.string().min(1))
1850
+ });
1851
+ var ChannelPostRequestSchema = z19.object({
1852
+ message: z19.string().min(1).max(2e4)
1853
+ });
1854
+ var ChannelPostSchema = z19.object({
1855
+ object: z19.literal("channel_post"),
1856
+ root_session_id: idOf("ses"),
1857
+ queued: z19.boolean()
1642
1858
  });
1643
1859
 
1644
1860
  // ../core/src/schema/media.ts
1645
- import { z as z19 } from "zod";
1861
+ import { z as z20 } from "zod";
1646
1862
  var MEDIA_JOB_KINDS = ["video", "clip", "transcription"];
1647
- var MediaJobKindSchema = z19.enum(MEDIA_JOB_KINDS);
1648
- var MediaJobStatusSchema = z19.enum(["queued", "processing", "completed", "failed"]);
1649
- var PublicUrl = z19.string().url().startsWith("http");
1650
- var Score = z19.number().int().min(0).max(100);
1651
- var Seconds = z19.number().nonnegative();
1652
- var VideoResultSchema = z19.object({
1653
- files: z19.array(
1654
- z19.object({
1863
+ var MediaJobKindSchema = z20.enum(MEDIA_JOB_KINDS);
1864
+ var MediaJobStatusSchema = z20.enum(["queued", "processing", "completed", "failed"]);
1865
+ var PublicUrl = z20.string().url().startsWith("http");
1866
+ var Score = z20.number().int().min(0).max(100);
1867
+ var Seconds = z20.number().nonnegative();
1868
+ var VideoResultSchema = z20.object({
1869
+ files: z20.array(
1870
+ z20.object({
1655
1871
  file_id: idOf("fil"),
1656
- content_type: z19.string(),
1657
- width: z19.number().int().positive().nullable(),
1658
- height: z19.number().int().positive().nullable(),
1872
+ content_type: z20.string(),
1873
+ width: z20.number().int().positive().nullable(),
1874
+ height: z20.number().int().positive().nullable(),
1659
1875
  duration_seconds: Seconds.nullable()
1660
1876
  })
1661
1877
  )
1662
1878
  });
1663
- var ViralityScoreSchema = z19.object({
1879
+ var ViralityScoreSchema = z20.object({
1664
1880
  total: Score,
1665
1881
  shareability: Score,
1666
1882
  hook_strength: Score,
1667
1883
  story_quality: Score,
1668
1884
  emotional_impact: Score
1669
1885
  });
1670
- var ClipResultSchema = z19.object({
1671
- clips: z19.array(
1672
- z19.object({
1886
+ var ClipResultSchema = z20.object({
1887
+ clips: z20.array(
1888
+ z20.object({
1673
1889
  file_id: idOf("fil"),
1674
- title: z19.string(),
1890
+ title: z20.string(),
1675
1891
  start_seconds: Seconds,
1676
1892
  end_seconds: Seconds,
1677
1893
  duration_seconds: Seconds,
@@ -1679,189 +1895,189 @@ var ClipResultSchema = z19.object({
1679
1895
  })
1680
1896
  )
1681
1897
  });
1682
- var TranscriptSchema = z19.object({
1683
- text: z19.string(),
1684
- language: z19.string().nullable(),
1898
+ var TranscriptSchema = z20.object({
1899
+ text: z20.string(),
1900
+ language: z20.string().nullable(),
1685
1901
  duration_seconds: Seconds.nullable(),
1686
- segments: z19.array(z19.object({ start_seconds: Seconds, end_seconds: Seconds, text: z19.string() }))
1902
+ segments: z20.array(z20.object({ start_seconds: Seconds, end_seconds: Seconds, text: z20.string() }))
1687
1903
  });
1688
- var MediaJobResultSchema = z19.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
1689
- var MediaJobSchema = z19.object({
1904
+ var MediaJobResultSchema = z20.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
1905
+ var MediaJobSchema = z20.object({
1690
1906
  id: idOf("med"),
1691
- object: z19.literal("media_job"),
1907
+ object: z20.literal("media_job"),
1692
1908
  kind: MediaJobKindSchema,
1693
1909
  status: MediaJobStatusSchema,
1694
- model: z19.string().nullable(),
1695
- input: z19.record(z19.string(), z19.unknown()),
1910
+ model: z20.string().nullable(),
1911
+ input: z20.record(z20.string(), z20.unknown()),
1696
1912
  result: MediaJobResultSchema.nullable(),
1697
- error: z19.object({ code: z19.string(), message: z19.string() }).nullable(),
1913
+ error: z20.object({ code: z20.string(), message: z20.string() }).nullable(),
1698
1914
  cost_micro_usd: MicroUsdField.nullable(),
1699
1915
  session_id: idOf("ses").nullable(),
1700
1916
  created_at: Timestamp,
1701
1917
  completed_at: Timestamp.nullable()
1702
1918
  });
1703
- var ImageRequestSchema = z19.object({
1704
- model: z19.string().min(1).optional(),
1705
- prompt: z19.string().min(1),
1706
- image_urls: z19.array(PublicUrl).max(4).optional(),
1707
- aspect_ratio: z19.string().optional(),
1708
- seed: z19.number().int().optional(),
1709
- n: z19.number().int().min(1).max(4).default(1)
1710
- });
1711
- var VideoRequestSchema = z19.object({
1712
- model: z19.string().min(1),
1713
- prompt: z19.string().min(1),
1714
- image_urls: z19.array(PublicUrl).max(1).optional(),
1715
- aspect_ratio: z19.string().optional(),
1716
- seed: z19.number().int().optional(),
1717
- seconds: z19.number().int().min(1).max(60).optional()
1718
- });
1719
- var ImageGenerationSchema = z19.object({
1720
- object: z19.literal("image_generation"),
1721
- model: z19.string(),
1722
- files: z19.array(FileSchema),
1919
+ var ImageRequestSchema = z20.object({
1920
+ model: z20.string().min(1).optional(),
1921
+ prompt: z20.string().min(1),
1922
+ image_urls: z20.array(PublicUrl).max(4).optional(),
1923
+ aspect_ratio: z20.string().optional(),
1924
+ seed: z20.number().int().optional(),
1925
+ n: z20.number().int().min(1).max(4).default(1)
1926
+ });
1927
+ var VideoRequestSchema = z20.object({
1928
+ model: z20.string().min(1),
1929
+ prompt: z20.string().min(1),
1930
+ image_urls: z20.array(PublicUrl).max(1).optional(),
1931
+ aspect_ratio: z20.string().optional(),
1932
+ seed: z20.number().int().optional(),
1933
+ seconds: z20.number().int().min(1).max(60).optional()
1934
+ });
1935
+ var ImageGenerationSchema = z20.object({
1936
+ object: z20.literal("image_generation"),
1937
+ model: z20.string(),
1938
+ files: z20.array(FileSchema),
1723
1939
  cost_micro_usd: MicroUsdField
1724
1940
  });
1725
- var ClipLength = z19.number().int().min(5).max(180);
1726
- var ClipRequestSchema = z19.object({
1941
+ var ClipLength = z20.number().int().min(5).max(180);
1942
+ var ClipRequestSchema = z20.object({
1727
1943
  video_url: PublicUrl,
1728
- aspect_ratio: z19.enum(["9:16", "16:9"]).default("9:16"),
1729
- remove_silence: z19.boolean().default(false),
1730
- caption_preset: z19.enum(["none", "clean", "bold", "karaoke"]).default("none"),
1731
- language: z19.string().min(2).optional(),
1944
+ aspect_ratio: z20.enum(["9:16", "16:9"]).default("9:16"),
1945
+ remove_silence: z20.boolean().default(false),
1946
+ caption_preset: z20.enum(["none", "clean", "bold", "karaoke"]).default("none"),
1947
+ language: z20.string().min(2).optional(),
1732
1948
  min_seconds: ClipLength.default(15),
1733
1949
  max_seconds: ClipLength.default(60),
1734
- title: z19.string().min(1).optional()
1950
+ title: z20.string().min(1).optional()
1735
1951
  });
1736
- var AudioFormatSchema = z19.enum(["mp3", "wav", "ogg"]);
1737
- var TranscriptionRequestSchema = z19.object({
1738
- model: z19.string().min(1).optional(),
1952
+ var AudioFormatSchema = z20.enum(["mp3", "wav", "ogg"]);
1953
+ var TranscriptionRequestSchema = z20.object({
1954
+ model: z20.string().min(1).optional(),
1739
1955
  file_id: idOf("fil").optional(),
1740
1956
  url: PublicUrl.optional(),
1741
- language: z19.string().min(2).optional(),
1742
- timestamps: z19.boolean().default(true)
1957
+ language: z20.string().min(2).optional(),
1958
+ timestamps: z20.boolean().default(true)
1743
1959
  }).refine((request) => request.file_id === void 0 !== (request.url === void 0), {
1744
1960
  error: "exactly one of file_id or url",
1745
1961
  path: ["file_id"]
1746
1962
  });
1747
- var SpeechRequestSchema = z19.object({
1748
- model: z19.string().min(1).optional(),
1749
- text: z19.string().min(1).max(4096),
1750
- voice: z19.string().min(1).optional(),
1963
+ var SpeechRequestSchema = z20.object({
1964
+ model: z20.string().min(1).optional(),
1965
+ text: z20.string().min(1).max(4096),
1966
+ voice: z20.string().min(1).optional(),
1751
1967
  format: AudioFormatSchema.default("mp3"),
1752
- speed: z19.number().min(0.5).max(2).optional()
1968
+ speed: z20.number().min(0.5).max(2).optional()
1753
1969
  });
1754
- var SpeechToSpeechRequestSchema = z19.object({
1755
- model: z19.string().min(1).optional(),
1970
+ var SpeechToSpeechRequestSchema = z20.object({
1971
+ model: z20.string().min(1).optional(),
1756
1972
  file_id: idOf("fil"),
1757
- voice: z19.string().min(1).optional(),
1973
+ voice: z20.string().min(1).optional(),
1758
1974
  format: AudioFormatSchema.default("mp3")
1759
1975
  });
1760
- var SpeechGenerationSchema = z19.object({
1761
- object: z19.literal("speech_generation"),
1762
- model: z19.string(),
1976
+ var SpeechGenerationSchema = z20.object({
1977
+ object: z20.literal("speech_generation"),
1978
+ model: z20.string(),
1763
1979
  file: FileSchema,
1764
1980
  duration_seconds: Seconds.nullable(),
1765
1981
  cost_micro_usd: MicroUsdField
1766
1982
  });
1767
1983
 
1768
1984
  // ../core/src/schema/app-data.ts
1769
- import { z as z20 } from "zod";
1770
- var DbTableSchema = z20.object({
1771
- object: z20.literal("db_table"),
1772
- name: z20.string(),
1773
- schema: z20.string().default("public"),
1774
- rows: z20.number().int().nonnegative().nullable(),
1775
- size_bytes: z20.number().int().nonnegative().nullable()
1776
- });
1777
- var DbMigrationSchema = z20.object({
1985
+ import { z as z21 } from "zod";
1986
+ var DbTableSchema = z21.object({
1987
+ object: z21.literal("db_table"),
1988
+ name: z21.string(),
1989
+ schema: z21.string().default("public"),
1990
+ rows: z21.number().int().nonnegative().nullable(),
1991
+ size_bytes: z21.number().int().nonnegative().nullable()
1992
+ });
1993
+ var DbMigrationSchema = z21.object({
1778
1994
  id: idOf("dbm"),
1779
- object: z20.literal("db_migration"),
1780
- name: z20.string(),
1781
- sha256: z20.string().regex(/^[0-9a-f]{64}$/),
1995
+ object: z21.literal("db_migration"),
1996
+ name: z21.string(),
1997
+ sha256: z21.string().regex(/^[0-9a-f]{64}$/),
1782
1998
  applied_at: Timestamp,
1783
- statements: z20.number().int().nonnegative()
1999
+ statements: z21.number().int().nonnegative()
1784
2000
  });
1785
- var ApplyDbMigrationSchema = z20.object({
1786
- name: z20.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
1787
- sql: z20.string().min(1)
2001
+ var ApplyDbMigrationSchema = z21.object({
2002
+ name: z21.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
2003
+ sql: z21.string().min(1)
1788
2004
  });
1789
2005
  var DB_REST_METHODS = ["GET", "POST", "PATCH", "PUT", "DELETE", "HEAD"];
1790
- var DbRestMethodSchema = z20.enum(DB_REST_METHODS);
2006
+ var DbRestMethodSchema = z21.enum(DB_REST_METHODS);
1791
2007
  var BUCKET_NAME = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
1792
- var BucketSchema = z20.object({
1793
- object: z20.literal("bucket"),
1794
- name: z20.string().regex(BUCKET_NAME),
1795
- public: z20.boolean(),
2008
+ var BucketSchema = z21.object({
2009
+ object: z21.literal("bucket"),
2010
+ name: z21.string().regex(BUCKET_NAME),
2011
+ public: z21.boolean(),
1796
2012
  created_at: Timestamp
1797
2013
  });
1798
- var CreateBucketSchema = z20.object({
1799
- name: z20.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
1800
- public: z20.boolean().default(false)
1801
- });
1802
- var StorageObjectSchema = z20.object({
1803
- object: z20.literal("storage_object"),
1804
- bucket: z20.string(),
1805
- key: z20.string().min(1),
1806
- size_bytes: z20.number().int().nonnegative(),
1807
- content_type: z20.string(),
1808
- etag: z20.string().nullable(),
2014
+ var CreateBucketSchema = z21.object({
2015
+ name: z21.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
2016
+ public: z21.boolean().default(false)
2017
+ });
2018
+ var StorageObjectSchema = z21.object({
2019
+ object: z21.literal("storage_object"),
2020
+ bucket: z21.string(),
2021
+ key: z21.string().min(1),
2022
+ size_bytes: z21.number().int().nonnegative(),
2023
+ content_type: z21.string(),
2024
+ etag: z21.string().nullable(),
1809
2025
  updated_at: Timestamp
1810
2026
  });
1811
- var SignedUrlMethodSchema = z20.enum(["PUT", "GET"]);
1812
- var SignedUrlSchema = z20.object({
1813
- object: z20.literal("signed_url"),
1814
- url: z20.string().url(),
2027
+ var SignedUrlMethodSchema = z21.enum(["PUT", "GET"]);
2028
+ var SignedUrlSchema = z21.object({
2029
+ object: z21.literal("signed_url"),
2030
+ url: z21.string().url(),
1815
2031
  method: SignedUrlMethodSchema,
1816
2032
  expires_at: Timestamp
1817
2033
  });
1818
- var CreateUploadUrlSchema = z20.object({
1819
- content_type: z20.string().min(1),
1820
- expires_seconds: z20.number().int().min(60).max(3600).default(900)
2034
+ var CreateUploadUrlSchema = z21.object({
2035
+ content_type: z21.string().min(1),
2036
+ expires_seconds: z21.number().int().min(60).max(3600).default(900)
1821
2037
  });
1822
2038
 
1823
2039
  // ../core/src/schema/stock-photo.ts
1824
- import { z as z21 } from "zod";
2040
+ import { z as z22 } from "zod";
1825
2041
  var STOCK_PHOTO_ORIENTATIONS = ["landscape", "portrait", "square"];
1826
2042
  var STOCK_PHOTO_SIZES = ["small", "medium", "large"];
1827
- var StockPhotoQuerySchema = z21.object({
1828
- query: z21.string().min(1).max(200),
1829
- count: z21.coerce.number().int().min(1).max(30).default(10),
1830
- orientation: z21.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
1831
- color: z21.string().min(1).max(32).optional(),
1832
- size: z21.enum(STOCK_PHOTO_SIZES).optional()
1833
- });
1834
- var StockPhotoSchema = z21.object({
1835
- object: z21.literal("stock_photo"),
1836
- id: z21.string().min(1),
1837
- width: z21.number().int().positive(),
1838
- height: z21.number().int().positive(),
1839
- url: z21.string().url(),
1840
- preview_url: z21.string().url(),
1841
- alt: z21.string().nullable(),
1842
- photographer: z21.string().nullable(),
1843
- attribution_url: z21.string().url().nullable(),
1844
- dominant_color: z21.string().nullable()
2043
+ var StockPhotoQuerySchema = z22.object({
2044
+ query: z22.string().min(1).max(200),
2045
+ count: z22.coerce.number().int().min(1).max(30).default(10),
2046
+ orientation: z22.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
2047
+ color: z22.string().min(1).max(32).optional(),
2048
+ size: z22.enum(STOCK_PHOTO_SIZES).optional()
2049
+ });
2050
+ var StockPhotoSchema = z22.object({
2051
+ object: z22.literal("stock_photo"),
2052
+ id: z22.string().min(1),
2053
+ width: z22.number().int().positive(),
2054
+ height: z22.number().int().positive(),
2055
+ url: z22.string().url(),
2056
+ preview_url: z22.string().url(),
2057
+ alt: z22.string().nullable(),
2058
+ photographer: z22.string().nullable(),
2059
+ attribution_url: z22.string().url().nullable(),
2060
+ dominant_color: z22.string().nullable()
1845
2061
  });
1846
2062
 
1847
2063
  // ../core/src/schema/creator.ts
1848
- import { z as z22 } from "zod";
1849
- var CreatorCodeSchema = z22.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
1850
- var PayoutMethodSchema = z22.enum(["wise", "paypal"]);
1851
- var PayoutDetailsSchema = z22.object({
2064
+ import { z as z23 } from "zod";
2065
+ var CreatorCodeSchema = z23.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
2066
+ var PayoutMethodSchema = z23.enum(["wise", "paypal"]);
2067
+ var PayoutDetailsSchema = z23.object({
1852
2068
  method: PayoutMethodSchema,
1853
- account: z22.string().min(1).max(320)
2069
+ account: z23.string().min(1).max(320)
1854
2070
  });
1855
- var CreatorStatusSchema = z22.enum(["active", "suspended"]);
1856
- var CreatorSchema = z22.object({
2071
+ var CreatorStatusSchema = z23.enum(["active", "suspended"]);
2072
+ var CreatorSchema = z23.object({
1857
2073
  id: idOf("crt"),
1858
- object: z22.literal("creator"),
1859
- email: z22.email(),
1860
- display_name: z22.string().min(1).max(80),
2074
+ object: z23.literal("creator"),
2075
+ email: z23.email(),
2076
+ display_name: z23.string().min(1).max(80),
1861
2077
  code: CreatorCodeSchema,
1862
2078
  status: CreatorStatusSchema,
1863
2079
  payout: PayoutDetailsSchema.nullable(),
1864
- clicks: z22.number().int().nonnegative(),
2080
+ clicks: z23.number().int().nonnegative(),
1865
2081
  created_at: Timestamp,
1866
2082
  updated_at: Timestamp
1867
2083
  });
@@ -1869,28 +2085,28 @@ var IdentityCreatorSchema = CreatorSchema.pick({
1869
2085
  id: true,
1870
2086
  status: true
1871
2087
  });
1872
- var CreatorApplicationStatusSchema = z22.enum([
2088
+ var CreatorApplicationStatusSchema = z23.enum([
1873
2089
  "pending",
1874
2090
  "approved",
1875
2091
  "rejected"
1876
2092
  ]);
1877
- var CreatorApplicationSchema = z22.object({
2093
+ var CreatorApplicationSchema = z23.object({
1878
2094
  id: idOf("cra"),
1879
- object: z22.literal("creator_application"),
1880
- email: z22.email(),
1881
- display_name: z22.string().min(1).max(80),
1882
- pitch: z22.string().min(1).max(2e3),
1883
- links: z22.array(z22.url({ protocol: /^https$/ })).max(5),
2095
+ object: z23.literal("creator_application"),
2096
+ email: z23.email(),
2097
+ display_name: z23.string().min(1).max(80),
2098
+ pitch: z23.string().min(1).max(2e3),
2099
+ links: z23.array(z23.url({ protocol: /^https$/ })).max(5),
1884
2100
  status: CreatorApplicationStatusSchema,
1885
- note: z22.string().nullable(),
2101
+ note: z23.string().nullable(),
1886
2102
  creator_id: idOf("crt").nullable(),
1887
2103
  created_at: Timestamp,
1888
2104
  decided_at: Timestamp.nullable()
1889
2105
  });
1890
- var ReferralStatusSchema = z22.enum(["pending", "active", "expired"]);
1891
- var ReferralSchema = z22.object({
2106
+ var ReferralStatusSchema = z23.enum(["pending", "active", "expired"]);
2107
+ var ReferralSchema = z23.object({
1892
2108
  id: idOf("crf"),
1893
- object: z22.literal("referral"),
2109
+ object: z23.literal("referral"),
1894
2110
  creator_id: idOf("crt"),
1895
2111
  organization_id: idOf("org"),
1896
2112
  status: ReferralStatusSchema,
@@ -1898,16 +2114,16 @@ var ReferralSchema = z22.object({
1898
2114
  first_paid_at: Timestamp.nullable(),
1899
2115
  commission_until: Timestamp.nullable()
1900
2116
  });
1901
- var CommissionKindSchema = z22.enum(["referral", "template"]);
1902
- var CommissionStatusSchema = z22.enum([
2117
+ var CommissionKindSchema = z23.enum(["referral", "template"]);
2118
+ var CommissionStatusSchema = z23.enum([
1903
2119
  "pending",
1904
2120
  "available",
1905
2121
  "claimed",
1906
2122
  "paid"
1907
2123
  ]);
1908
- var CommissionSchema = z22.object({
2124
+ var CommissionSchema = z23.object({
1909
2125
  id: idOf("crc"),
1910
- object: z22.literal("commission"),
2126
+ object: z23.literal("commission"),
1911
2127
  creator_id: idOf("crt"),
1912
2128
  kind: CommissionKindSchema,
1913
2129
  referral_id: idOf("crf").nullable(),
@@ -1920,18 +2136,18 @@ var CommissionSchema = z22.object({
1920
2136
  available_at: Timestamp,
1921
2137
  payout_id: idOf("crp").nullable()
1922
2138
  });
1923
- var PayoutStatusSchema = z22.enum(["requested", "paid", "rejected"]);
1924
- var PayoutSchema = z22.object({
2139
+ var PayoutStatusSchema = z23.enum(["requested", "paid", "rejected"]);
2140
+ var PayoutSchema = z23.object({
1925
2141
  id: idOf("crp"),
1926
- object: z22.literal("payout"),
2142
+ object: z23.literal("payout"),
1927
2143
  creator_id: idOf("crt"),
1928
2144
  amount_micro_usd: MicroUsdField.positive(),
1929
- currency: z22.literal("USD"),
2145
+ currency: z23.literal("USD"),
1930
2146
  method: PayoutMethodSchema,
1931
- account: z22.string().min(1),
2147
+ account: z23.string().min(1),
1932
2148
  status: PayoutStatusSchema,
1933
- reference: z22.string().nullable(),
1934
- note: z22.string().nullable(),
2149
+ reference: z23.string().nullable(),
2150
+ note: z23.string().nullable(),
1935
2151
  requested_at: Timestamp,
1936
2152
  decided_at: Timestamp.nullable()
1937
2153
  });
@@ -1943,100 +2159,100 @@ var CREATOR_PROGRAM = {
1943
2159
  attribution_days: 30,
1944
2160
  minimum_payout_micro_usd: 2e7
1945
2161
  };
1946
- var CreatorTemplateSlugSchema = z22.string().max(32).regex(
2162
+ var CreatorTemplateSlugSchema = z23.string().max(32).regex(
1947
2163
  /^[a-z0-9]+(-[a-z0-9]+)*$/,
1948
2164
  "lowercase letters, digits and single dashes"
1949
2165
  );
1950
- var CreatorSkillSchema = z22.object({
1951
- slug: z22.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
1952
- body: z22.string().min(1).max(64 * 1024)
2166
+ var CreatorSkillSchema = z23.object({
2167
+ slug: z23.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2168
+ body: z23.string().min(1).max(64 * 1024)
1953
2169
  });
1954
- var CreatorDeclarationSchema = z22.object({
1955
- agents: z22.array(z22.unknown()),
1956
- questions: z22.array(z22.unknown()),
1957
- skills: z22.array(CreatorSkillSchema).max(16)
2170
+ var CreatorDeclarationSchema = z23.object({
2171
+ agents: z23.array(z23.unknown()),
2172
+ questions: z23.array(z23.unknown()),
2173
+ skills: z23.array(CreatorSkillSchema).max(16)
1958
2174
  });
1959
- var CreatorTemplateVersionStatusSchema = z22.enum([
2175
+ var CreatorTemplateVersionStatusSchema = z23.enum([
1960
2176
  "in_review",
1961
2177
  "approved",
1962
2178
  "changes_requested"
1963
2179
  ]);
1964
- var VersionNumber = z22.number().int().positive();
1965
- var CreatorTemplateSchema = z22.object({
2180
+ var VersionNumber = z23.number().int().positive();
2181
+ var CreatorTemplateSchema = z23.object({
1966
2182
  id: idOf("ctp"),
1967
- object: z22.literal("creator_template"),
2183
+ object: z23.literal("creator_template"),
1968
2184
  creator_id: idOf("crt"),
1969
- blueprint: z22.string().min(1),
1970
- base_template: z22.string().min(1),
2185
+ blueprint: z23.string().min(1),
2186
+ base_template: z23.string().min(1),
1971
2187
  slug: CreatorTemplateSlugSchema,
1972
- template: z22.string().min(1).max(64),
1973
- name: z22.string().min(1).max(80),
1974
- description: z22.string().max(2e3),
2188
+ template: z23.string().min(1).max(64),
2189
+ name: z23.string().min(1).max(80),
2190
+ description: z23.string().max(2e3),
1975
2191
  declaration: CreatorDeclarationSchema,
1976
2192
  published_version: VersionNumber.nullable(),
1977
- latest_version: z22.object({
2193
+ latest_version: z23.object({
1978
2194
  version: VersionNumber,
1979
2195
  status: CreatorTemplateVersionStatusSchema
1980
2196
  }).nullable(),
1981
2197
  created_at: Timestamp,
1982
2198
  updated_at: Timestamp
1983
2199
  });
1984
- var CreatorTemplateVersionSchema = z22.object({
1985
- object: z22.literal("creator_template_version"),
2200
+ var CreatorTemplateVersionSchema = z23.object({
2201
+ object: z23.literal("creator_template_version"),
1986
2202
  template_id: idOf("ctp"),
1987
2203
  version: VersionNumber,
1988
2204
  declaration: CreatorDeclarationSchema,
1989
2205
  status: CreatorTemplateVersionStatusSchema,
1990
- note: z22.string().nullable(),
2206
+ note: z23.string().nullable(),
1991
2207
  artifact_id: idOf("bpa").nullable(),
1992
2208
  submitted_at: Timestamp,
1993
2209
  decided_at: Timestamp.nullable()
1994
2210
  });
1995
- var CreatorBalanceSchema = z22.object({
1996
- object: z22.literal("creator_balance"),
2211
+ var CreatorBalanceSchema = z23.object({
2212
+ object: z23.literal("creator_balance"),
1997
2213
  pending_micro_usd: MicroUsdField.nonnegative(),
1998
2214
  available_micro_usd: MicroUsdField.nonnegative(),
1999
2215
  claimed_micro_usd: MicroUsdField.nonnegative(),
2000
2216
  paid_micro_usd: MicroUsdField.nonnegative(),
2001
- minimum_payout_micro_usd: z22.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
2217
+ minimum_payout_micro_usd: z23.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
2002
2218
  });
2003
- var ReferralClickSchema = z22.object({
2004
- object: z22.literal("referral_click"),
2219
+ var ReferralClickSchema = z23.object({
2220
+ object: z23.literal("referral_click"),
2005
2221
  code: CreatorCodeSchema,
2006
- creator: z22.object({ display_name: z22.string().min(1) }),
2222
+ creator: z23.object({ display_name: z23.string().min(1) }),
2007
2223
  expires_at: Timestamp
2008
2224
  });
2009
- var Day = z22.iso.date();
2010
- var CreatorAnalyticsSchema = z22.object({
2011
- object: z22.literal("creator_analytics"),
2012
- days: z22.number().int().min(1).max(90),
2225
+ var Day = z23.iso.date();
2226
+ var CreatorAnalyticsSchema = z23.object({
2227
+ object: z23.literal("creator_analytics"),
2228
+ days: z23.number().int().min(1).max(90),
2013
2229
  from: Day,
2014
2230
  to: Day,
2015
- clicks: z22.number().int().nonnegative(),
2016
- referrals: z22.number().int().nonnegative(),
2017
- installs: z22.number().int().nonnegative(),
2018
- active_installs: z22.number().int().nonnegative(),
2019
- usage_by_day: z22.array(
2020
- z22.object({ day: Day, debit_micro_usd: MicroUsdField.nonnegative() })
2231
+ clicks: z23.number().int().nonnegative(),
2232
+ referrals: z23.number().int().nonnegative(),
2233
+ installs: z23.number().int().nonnegative(),
2234
+ active_installs: z23.number().int().nonnegative(),
2235
+ usage_by_day: z23.array(
2236
+ z23.object({ day: Day, debit_micro_usd: MicroUsdField.nonnegative() })
2021
2237
  ),
2022
- commission_micro_usd: z22.object({
2238
+ commission_micro_usd: z23.object({
2023
2239
  pending: MicroUsdField.nonnegative(),
2024
2240
  available: MicroUsdField.nonnegative(),
2025
2241
  claimed: MicroUsdField.nonnegative(),
2026
2242
  paid: MicroUsdField.nonnegative()
2027
2243
  }),
2028
- commissions_by_template: z22.array(
2029
- z22.object({
2244
+ commissions_by_template: z23.array(
2245
+ z23.object({
2030
2246
  creator_template_id: idOf("ctp"),
2031
2247
  amount_micro_usd: MicroUsdField.nonnegative()
2032
2248
  })
2033
2249
  ),
2034
2250
  /** Every install covered, newest first: the day it was created and the day its twelve months end. */
2035
- install_windows: z22.array(z22.object({ install_id: idOf("bpi"), from: Day, until: Day }))
2251
+ install_windows: z23.array(z23.object({ install_id: idOf("bpi"), from: Day, until: Day }))
2036
2252
  });
2037
2253
 
2038
2254
  // ../core/src/schema/legal.ts
2039
- import { z as z23 } from "zod";
2255
+ import { z as z24 } from "zod";
2040
2256
  var LEGAL_MEMBER_STATUSES = [
2041
2257
  "pending",
2042
2258
  "link_ready",
@@ -2046,16 +2262,16 @@ var LEGAL_MEMBER_STATUSES = [
2046
2262
  "verified",
2047
2263
  "failed"
2048
2264
  ];
2049
- var LegalMemberStatusSchema = z23.enum(LEGAL_MEMBER_STATUSES);
2265
+ var LegalMemberStatusSchema = z24.enum(LEGAL_MEMBER_STATUSES);
2050
2266
  var LEGAL_VERIFICATION_STATUSES = ["in_progress", "pending_review", "verified", "failed"];
2051
- var LegalVerificationStatusSchema = z23.enum(LEGAL_VERIFICATION_STATUSES);
2267
+ var LegalVerificationStatusSchema = z24.enum(LEGAL_VERIFICATION_STATUSES);
2052
2268
  var LEGAL_COMPANY_STATUSES = ["awaiting_payment", "paid", "submitted", "formed", "failed"];
2053
- var LegalCompanyStatusSchema = z23.enum(LEGAL_COMPANY_STATUSES);
2269
+ var LegalCompanyStatusSchema = z24.enum(LEGAL_COMPANY_STATUSES);
2054
2270
  var LEGAL_DOCUMENT_KINDS = ["articles", "ein_letter", "operating_agreement", "other"];
2055
- var LegalDocumentKindSchema = z23.enum(LEGAL_DOCUMENT_KINDS);
2056
- var LegalMemberRoleSchema = z23.enum(["primary", "secondary"]);
2057
- var LegalEinStatusSchema = z23.enum(["none", "pending", "issued"]);
2058
- var LegalRequiredActionKindSchema = z23.enum(["signature", "information", "payment", "other"]);
2271
+ var LegalDocumentKindSchema = z24.enum(LEGAL_DOCUMENT_KINDS);
2272
+ var LegalMemberRoleSchema = z24.enum(["primary", "secondary"]);
2273
+ var LegalEinStatusSchema = z24.enum(["none", "pending", "issued"]);
2274
+ var LegalRequiredActionKindSchema = z24.enum(["signature", "information", "payment", "other"]);
2059
2275
  var US_STATES = [
2060
2276
  "AL",
2061
2277
  "AK",
@@ -2109,105 +2325,105 @@ var US_STATES = [
2109
2325
  "WI",
2110
2326
  "WY"
2111
2327
  ];
2112
- var UsStateSchema = z23.enum(US_STATES);
2113
- var LegalMemberInputSchema = z23.object({
2114
- first_name: z23.string().min(1).max(128),
2115
- last_name: z23.string().min(1).max(128),
2116
- email: z23.string().min(1).max(320),
2328
+ var UsStateSchema = z24.enum(US_STATES);
2329
+ var LegalMemberInputSchema = z24.object({
2330
+ first_name: z24.string().min(1).max(128),
2331
+ last_name: z24.string().min(1).max(128),
2332
+ email: z24.string().min(1).max(320),
2117
2333
  role: LegalMemberRoleSchema,
2118
- is_responsible_party: z23.boolean(),
2119
- ownership_percent: z23.number().int()
2334
+ is_responsible_party: z24.boolean(),
2335
+ ownership_percent: z24.number().int()
2120
2336
  });
2121
2337
  var LegalMemberSchema = LegalMemberInputSchema.extend({
2122
2338
  id: idOf("lgm"),
2123
- object: z23.literal("legal_member"),
2339
+ object: z24.literal("legal_member"),
2124
2340
  verification_id: idOf("lgv"),
2125
2341
  status: LegalMemberStatusSchema,
2126
- link_url: z23.url().nullable(),
2342
+ link_url: z24.url().nullable(),
2127
2343
  link_expires_at: Timestamp.nullable(),
2128
2344
  completed_at: Timestamp.nullable()
2129
2345
  });
2130
- var LegalVerificationSchema = z23.object({
2346
+ var LegalVerificationSchema = z24.object({
2131
2347
  id: idOf("lgv"),
2132
- object: z23.literal("legal_verification"),
2348
+ object: z24.literal("legal_verification"),
2133
2349
  identity_id: idOf("idn"),
2134
2350
  status: LegalVerificationStatusSchema,
2135
- members: z23.array(LegalMemberSchema),
2136
- ready_for_formation: z23.boolean(),
2351
+ members: z24.array(LegalMemberSchema),
2352
+ ready_for_formation: z24.boolean(),
2137
2353
  started_at: Timestamp,
2138
2354
  completed_at: Timestamp.nullable(),
2139
2355
  created_at: Timestamp,
2140
2356
  updated_at: Timestamp
2141
2357
  });
2142
- var StartLegalVerificationSchema = z23.object({ members: z23.array(LegalMemberInputSchema) });
2143
- var CompleteLegalMemberSchema = z23.object({ token: z23.string().min(1) });
2144
- var LegalNameOptionSchema = z23.object({ name: z23.string().min(1).max(200), ending: z23.literal("LLC") });
2145
- var LegalMailingAddressSchema = z23.object({
2146
- line1: z23.string().min(1).max(200),
2147
- line2: z23.string().max(200).nullable(),
2148
- city: z23.string().min(1).max(100),
2358
+ var StartLegalVerificationSchema = z24.object({ members: z24.array(LegalMemberInputSchema) });
2359
+ var CompleteLegalMemberSchema = z24.object({ token: z24.string().min(1) });
2360
+ var LegalNameOptionSchema = z24.object({ name: z24.string().min(1).max(200), ending: z24.literal("LLC") });
2361
+ var LegalMailingAddressSchema = z24.object({
2362
+ line1: z24.string().min(1).max(200),
2363
+ line2: z24.string().max(200).nullable(),
2364
+ city: z24.string().min(1).max(100),
2149
2365
  state: UsStateSchema,
2150
- postal_code: z23.string().min(1).max(16),
2151
- country: z23.literal("US")
2366
+ postal_code: z24.string().min(1).max(16),
2367
+ country: z24.literal("US")
2152
2368
  });
2153
- var LegalRequiredActionSchema = z23.object({
2369
+ var LegalRequiredActionSchema = z24.object({
2154
2370
  kind: LegalRequiredActionKindSchema,
2155
- description: z23.string(),
2156
- url: z23.url().nullable()
2371
+ description: z24.string(),
2372
+ url: z24.url().nullable()
2157
2373
  });
2158
2374
  var LEGAL_DESCRIPTION_MAX = 50;
2159
- var CreateLegalCompanySchema = z23.object({
2375
+ var CreateLegalCompanySchema = z24.object({
2160
2376
  verification_id: idOf("lgv"),
2161
2377
  state: UsStateSchema,
2162
- name_options: z23.array(z23.string().min(1).max(200)).min(1).max(3),
2163
- naics_code: z23.string().regex(/^\d{2,6}$/),
2164
- description: z23.string().min(1).max(LEGAL_DESCRIPTION_MAX),
2378
+ name_options: z24.array(z24.string().min(1).max(200)).min(1).max(3),
2379
+ naics_code: z24.string().regex(/^\d{2,6}$/),
2380
+ description: z24.string().min(1).max(LEGAL_DESCRIPTION_MAX),
2165
2381
  mailing_address: LegalMailingAddressSchema
2166
2382
  });
2167
2383
  var LegalCompanySchema = CreateLegalCompanySchema.omit({ name_options: true }).extend({
2168
2384
  id: idOf("lgc"),
2169
- object: z23.literal("legal_company"),
2385
+ object: z24.literal("legal_company"),
2170
2386
  identity_id: idOf("idn"),
2171
2387
  status: LegalCompanyStatusSchema,
2172
- entity_type: z23.literal("llc"),
2173
- name_options: z23.array(LegalNameOptionSchema),
2174
- legal_name: z23.string().nullable(),
2388
+ entity_type: z24.literal("llc"),
2389
+ name_options: z24.array(LegalNameOptionSchema),
2390
+ legal_name: z24.string().nullable(),
2175
2391
  ein_status: LegalEinStatusSchema,
2176
2392
  price_micro_usd: MicroUsdField,
2177
- required_actions: z23.array(LegalRequiredActionSchema),
2178
- failure_reason: z23.string().max(256).nullable(),
2393
+ required_actions: z24.array(LegalRequiredActionSchema),
2394
+ failure_reason: z24.string().max(256).nullable(),
2179
2395
  submitted_at: Timestamp.nullable(),
2180
2396
  formed_at: Timestamp.nullable(),
2181
2397
  created_at: Timestamp,
2182
2398
  updated_at: Timestamp
2183
2399
  });
2184
- var LegalDocumentSchema = z23.object({
2400
+ var LegalDocumentSchema = z24.object({
2185
2401
  id: idOf("lgd"),
2186
- object: z23.literal("legal_document"),
2402
+ object: z24.literal("legal_document"),
2187
2403
  company_id: idOf("lgc"),
2188
2404
  kind: LegalDocumentKindSchema,
2189
- name: z23.string(),
2405
+ name: z24.string(),
2190
2406
  created_at: Timestamp
2191
2407
  });
2192
- var LegalDocumentLinkSchema = z23.object({
2193
- object: z23.literal("legal_document_link"),
2194
- url: z23.url(),
2408
+ var LegalDocumentLinkSchema = z24.object({
2409
+ object: z24.literal("legal_document_link"),
2410
+ url: z24.url(),
2195
2411
  expires_at: Timestamp
2196
2412
  });
2197
- var NaicsCodeSchema = z23.object({
2198
- object: z23.literal("naics_code"),
2199
- code: z23.string().regex(/^\d{2,6}$/),
2200
- title: z23.string()
2413
+ var NaicsCodeSchema = z24.object({
2414
+ object: z24.literal("naics_code"),
2415
+ code: z24.string().regex(/^\d{2,6}$/),
2416
+ title: z24.string()
2201
2417
  });
2202
- var LegalStateSchema = z23.object({
2203
- object: z23.literal("legal_state"),
2418
+ var LegalStateSchema = z24.object({
2419
+ object: z24.literal("legal_state"),
2204
2420
  code: UsStateSchema,
2205
- name: z23.string(),
2421
+ name: z24.string(),
2206
2422
  formation_fee_micro_usd: MicroUsdField
2207
2423
  });
2208
- var LegalWebhookEventSchema = z23.object({
2209
- provider_session_ref: z23.string().min(1),
2210
- status: z23.enum(["verified", "failed", "pending_review"]),
2424
+ var LegalWebhookEventSchema = z24.object({
2425
+ provider_session_ref: z24.string().min(1),
2426
+ status: z24.enum(["verified", "failed", "pending_review"]),
2211
2427
  metadata: Metadata
2212
2428
  });
2213
2429
  var LLC_ENDING = /\s*(?:,\s*)?(?:l\.?l\.?c\.?|limited\s+liability\s+company)\s*$/i;
@@ -2218,186 +2434,243 @@ function canonicalName(raw) {
2218
2434
  }
2219
2435
 
2220
2436
  // ../core/src/schema/wallet.ts
2221
- import { z as z24 } from "zod";
2437
+ import { z as z25 } from "zod";
2222
2438
  var WALLET_NETWORKS = ["eip155:84532", "eip155:8453"];
2223
- var WalletNetworkSchema = z24.enum(WALLET_NETWORKS);
2439
+ var WalletNetworkSchema = z25.enum(WALLET_NETWORKS);
2224
2440
  var DEFAULT_WALLET_NETWORK = "eip155:84532";
2225
- var WalletSelectSchema = z24.object({ network: WalletNetworkSchema.optional() });
2441
+ var WalletSelectSchema = z25.object({ network: WalletNetworkSchema.optional() });
2226
2442
  var WALLET_STATUSES = ["active", "frozen", "swept"];
2227
- var WalletStatusSchema = z24.enum(WALLET_STATUSES);
2443
+ var WalletStatusSchema = z25.enum(WALLET_STATUSES);
2228
2444
  var WALLET_TRANSACTION_KINDS = ["fund", "transfer", "pay", "sweep"];
2229
- var WalletTransactionKindSchema = z24.enum(WALLET_TRANSACTION_KINDS);
2445
+ var WalletTransactionKindSchema = z25.enum(WALLET_TRANSACTION_KINDS);
2230
2446
  var WALLET_TRANSACTION_STATUSES = ["pending", "confirmed", "failed"];
2231
- var WalletTransactionStatusSchema = z24.enum(WALLET_TRANSACTION_STATUSES);
2232
- var WalletDirectionSchema = z24.enum(["in", "out"]);
2233
- var WalletFundSourceSchema = z24.enum(["faucet", "treasury"]);
2234
- var EvmAddressSchema = z24.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
2235
- var TxHashSchema = z24.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
2236
- var WalletPolicySchema = z24.object({
2447
+ var WalletTransactionStatusSchema = z25.enum(WALLET_TRANSACTION_STATUSES);
2448
+ var WalletDirectionSchema = z25.enum(["in", "out"]);
2449
+ var WalletFundSourceSchema = z25.enum(["faucet", "treasury"]);
2450
+ var EvmAddressSchema = z25.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
2451
+ var TxHashSchema = z25.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
2452
+ var WalletPolicySchema = z25.object({
2237
2453
  per_tx_cap_micro_usd: MicroUsdField.nonnegative(),
2238
2454
  daily_cap_micro_usd: MicroUsdField.positive().nullable(),
2239
2455
  low_balance_micro_usd: MicroUsdField.nonnegative().nullable()
2240
2456
  });
2241
- var WalletSchema = z24.object({
2457
+ var WalletSchema = z25.object({
2242
2458
  id: idOf("wlt"),
2243
- object: z24.literal("wallet"),
2459
+ object: z25.literal("wallet"),
2244
2460
  identity_id: idOf("idn"),
2245
2461
  status: WalletStatusSchema,
2246
2462
  network: WalletNetworkSchema,
2247
2463
  address: EvmAddressSchema,
2248
- asset: z24.literal("usdc"),
2464
+ asset: z25.literal("usdc"),
2249
2465
  balance_micro_usd: MicroUsdField,
2250
2466
  policy: WalletPolicySchema,
2251
2467
  spent_today_micro_usd: MicroUsdField,
2252
2468
  created_at: Timestamp,
2253
2469
  updated_at: Timestamp
2254
2470
  });
2255
- var CreateWalletSchema = z24.object({
2471
+ var CreateWalletSchema = z25.object({
2256
2472
  network: WalletNetworkSchema.optional(),
2257
2473
  policy: WalletPolicySchema.partial().optional()
2258
2474
  });
2259
2475
  var UpdateWalletPolicySchema = WalletPolicySchema.partial();
2260
- var FundWalletSchema = z24.object({
2476
+ var FundWalletSchema = z25.object({
2261
2477
  amount_micro_usd: MicroUsdField.positive(),
2262
2478
  source: WalletFundSourceSchema
2263
2479
  });
2264
- var TransferWalletSchema = z24.object({
2265
- to: z24.union([EvmAddressSchema, idOf("idn")]),
2480
+ var TransferWalletSchema = z25.object({
2481
+ to: z25.union([EvmAddressSchema, idOf("idn")]),
2266
2482
  amount_micro_usd: MicroUsdField.positive(),
2267
- purpose: z24.string().min(1).max(256)
2483
+ purpose: z25.string().min(1).max(256)
2268
2484
  });
2269
- var SweepWalletSchema = z24.object({ to: EvmAddressSchema.optional() });
2270
- var WalletTransactionSchema = z24.object({
2485
+ var SweepWalletSchema = z25.object({ to: EvmAddressSchema.optional() });
2486
+ var WalletTransactionSchema = z25.object({
2271
2487
  id: idOf("wtx"),
2272
- object: z24.literal("wallet_transaction"),
2488
+ object: z25.literal("wallet_transaction"),
2273
2489
  wallet_id: idOf("wlt"),
2274
2490
  kind: WalletTransactionKindSchema,
2275
2491
  direction: WalletDirectionSchema,
2276
2492
  amount_micro_usd: MicroUsdField,
2277
- counterparty: z24.string().nullable(),
2278
- origin: z24.string().nullable(),
2279
- purpose: z24.string().nullable(),
2493
+ counterparty: z25.string().nullable(),
2494
+ origin: z25.string().nullable(),
2495
+ purpose: z25.string().nullable(),
2280
2496
  tx_hash: TxHashSchema.nullable(),
2281
2497
  session_id: idOf("ses").nullable(),
2282
2498
  status: WalletTransactionStatusSchema,
2283
2499
  created_at: Timestamp
2284
2500
  });
2285
- var ListWalletTransactionsSchema = z24.object({
2501
+ var ListWalletTransactionsSchema = z25.object({
2286
2502
  kind: WalletTransactionKindSchema.optional(),
2287
2503
  direction: WalletDirectionSchema.optional(),
2288
- origin: z24.string().optional(),
2504
+ origin: z25.string().optional(),
2289
2505
  since: Timestamp.optional()
2290
2506
  });
2291
- var HttpMethodSchema = z24.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
2292
- var WalletQuoteRequestSchema = z24.object({ url: z24.url(), method: HttpMethodSchema.optional() });
2293
- var WalletQuoteSchema = z24.object({
2294
- object: z24.literal("wallet_quote"),
2295
- url: z24.url(),
2296
- payable: z24.boolean(),
2507
+ var HttpMethodSchema = z25.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
2508
+ var WalletQuoteRequestSchema = z25.object({ url: z25.url(), method: HttpMethodSchema.optional() });
2509
+ var WalletQuoteSchema = z25.object({
2510
+ object: z25.literal("wallet_quote"),
2511
+ url: z25.url(),
2512
+ payable: z25.boolean(),
2297
2513
  network: WalletNetworkSchema.nullable(),
2298
- asset: z24.literal("usdc").nullable(),
2514
+ asset: z25.literal("usdc").nullable(),
2299
2515
  amount_micro_usd: MicroUsdField.nullable(),
2300
2516
  pay_to: EvmAddressSchema.nullable(),
2301
- description: z24.string().nullable(),
2302
- max_timeout_seconds: z24.number().int().nullable()
2517
+ description: z25.string().nullable(),
2518
+ max_timeout_seconds: z25.number().int().nullable()
2303
2519
  });
2304
2520
  var WalletPayRequestSchema = WalletQuoteRequestSchema.extend({
2305
2521
  max_amount_micro_usd: MicroUsdField.positive().optional()
2306
2522
  });
2307
2523
  var WALLET_RESPONSE_BODY_MAX = 64 * 1024;
2308
- var WalletPaymentSchema = z24.object({
2309
- object: z24.literal("wallet_payment"),
2310
- paid: z24.boolean(),
2524
+ var WalletPaymentSchema = z25.object({
2525
+ object: z25.literal("wallet_payment"),
2526
+ paid: z25.boolean(),
2311
2527
  transaction_id: idOf("wtx").nullable(),
2312
2528
  amount_micro_usd: MicroUsdField.nullable(),
2313
- response_status: z24.number().int(),
2314
- response_body: z24.string().max(WALLET_RESPONSE_BODY_MAX)
2529
+ response_status: z25.number().int(),
2530
+ response_body: z25.string().max(WALLET_RESPONSE_BODY_MAX)
2315
2531
  });
2316
2532
 
2317
2533
  // ../core/src/schema/cards.ts
2318
- import { z as z25 } from "zod";
2534
+ import { z as z26 } from "zod";
2319
2535
  var CARD_STATUSES = ["pending_payment", "issuing", "active", "failed", "cancelled", "refunded"];
2320
- var CardStatusSchema = z25.enum(CARD_STATUSES);
2536
+ var CardStatusSchema = z26.enum(CARD_STATUSES);
2321
2537
  var CARD_MIN_LOAD_MICRO_USD = 1e6;
2322
2538
  var CARD_MAX_LOAD_MICRO_USD = 15e7;
2323
2539
  var CARD_LOAD_GRANULARITY_MICRO_USD = 1e4;
2324
- var CardSchema = z25.object({
2540
+ var CardSchema = z26.object({
2325
2541
  id: idOf("vcd"),
2326
- object: z25.literal("card"),
2542
+ object: z26.literal("card"),
2327
2543
  identity_id: idOf("idn"),
2328
- kind: z25.literal("prepaid"),
2544
+ kind: z26.literal("prepaid"),
2329
2545
  status: CardStatusSchema,
2330
- label: z25.string().min(1).max(128),
2331
- brand: z25.string().nullable(),
2332
- last4: z25.string().regex(/^\d{4}$/).nullable(),
2546
+ label: z26.string().min(1).max(128),
2547
+ brand: z26.string().nullable(),
2548
+ last4: z26.string().regex(/^\d{4}$/).nullable(),
2333
2549
  load_micro_usd: MicroUsdField,
2334
2550
  spent_micro_usd: MicroUsdField,
2335
- currency: z25.literal("usd"),
2551
+ currency: z26.literal("usd"),
2336
2552
  expires_at: Timestamp.nullable(),
2337
- failure_reason: z25.string().max(256).nullable(),
2553
+ failure_reason: z26.string().max(256).nullable(),
2338
2554
  created_at: Timestamp,
2339
2555
  updated_at: Timestamp
2340
2556
  });
2341
- var IssueCardSchema = z25.object({
2557
+ var IssueCardSchema = z26.object({
2342
2558
  label: CardSchema.shape.label,
2343
2559
  load_micro_usd: MicroUsdField.min(CARD_MIN_LOAD_MICRO_USD).max(CARD_MAX_LOAD_MICRO_USD).multipleOf(CARD_LOAD_GRANULARITY_MICRO_USD)
2344
2560
  });
2345
2561
  var CardQuoteRequestSchema = IssueCardSchema.pick({ load_micro_usd: true });
2346
- var CardQuoteSchema = z25.object({
2347
- object: z25.literal("card_quote"),
2562
+ var CardQuoteSchema = z26.object({
2563
+ object: z26.literal("card_quote"),
2348
2564
  load_micro_usd: MicroUsdField,
2349
2565
  price_micro_usd: MicroUsdField,
2350
- brand: z25.string().nullable(),
2566
+ brand: z26.string().nullable(),
2351
2567
  min_load_micro_usd: MicroUsdField,
2352
2568
  max_load_micro_usd: MicroUsdField
2353
2569
  });
2354
- var CardCredentialsSchema = z25.object({
2355
- object: z25.literal("card_credentials"),
2570
+ var CardCredentialsSchema = z26.object({
2571
+ object: z26.literal("card_credentials"),
2356
2572
  card_id: idOf("vcd"),
2357
- number: z25.string().min(1),
2358
- pin: z25.string().nullable(),
2359
- cvv: z25.string().nullable(),
2360
- expiry: z25.string().nullable(),
2361
- url: z25.url().nullable(),
2362
- instructions: z25.string().nullable(),
2573
+ number: z26.string().min(1),
2574
+ pin: z26.string().nullable(),
2575
+ cvv: z26.string().nullable(),
2576
+ expiry: z26.string().nullable(),
2577
+ url: z26.url().nullable(),
2578
+ instructions: z26.string().nullable(),
2363
2579
  revealed_at: Timestamp
2364
2580
  });
2365
- var CardTransactionSchema = z25.object({
2581
+ var CardTransactionSchema = z26.object({
2366
2582
  id: idOf("vct"),
2367
- object: z25.literal("card_transaction"),
2583
+ object: z26.literal("card_transaction"),
2368
2584
  card_id: idOf("vcd"),
2369
2585
  amount_micro_usd: MicroUsdField,
2370
- merchant: z25.string().nullable(),
2371
- description: z25.string().nullable(),
2586
+ merchant: z26.string().nullable(),
2587
+ description: z26.string().nullable(),
2372
2588
  session_id: idOf("ses").nullable(),
2373
2589
  metadata: Metadata,
2374
2590
  created_at: Timestamp
2375
2591
  });
2376
- var LogCardTransactionSchema = z25.object({
2592
+ var LogCardTransactionSchema = z26.object({
2377
2593
  amount_micro_usd: MicroUsdField.positive(),
2378
- merchant: z25.string().max(256).optional(),
2379
- description: z25.string().max(1024).optional(),
2594
+ merchant: z26.string().max(256).optional(),
2595
+ description: z26.string().max(1024).optional(),
2380
2596
  metadata: Metadata.optional()
2381
2597
  });
2382
- var ListCardsSchema = z25.object({ status: CardStatusSchema.optional() });
2598
+ var ListCardsSchema = z26.object({ status: CardStatusSchema.optional() });
2599
+
2600
+ // ../core/src/schema/proxy-trace.ts
2601
+ import { z as z27 } from "zod";
2602
+ var ProxyDialectSchema = z27.enum(["anthropic", "openai"]);
2603
+ var ProxyTraceContentScopeSchema = z27.enum(["full", "metadata"]);
2604
+ var ProxyTraceRequestSchema = z27.object({
2605
+ system: z27.string(),
2606
+ messages: z27.array(z27.object({ role: z27.string(), content: z27.string() })),
2607
+ tool_names: z27.array(z27.string())
2608
+ });
2609
+ var ProxyTraceResponseSchema = z27.object({
2610
+ text: z27.string(),
2611
+ tool_calls: z27.array(z27.object({ name: z27.string(), arguments: z27.string() }))
2612
+ });
2613
+ var Sha256 = z27.string().regex(/^[0-9a-f]{64}$/);
2614
+ var ProxyCallTraceSchema = z27.object({
2615
+ /** The request id: also `x-request-id`, the reply's `id`, and the ledger entry's idempotency key. */
2616
+ id: idOf("req"),
2617
+ object: z27.literal("proxy_call_trace"),
2618
+ dialect: ProxyDialectSchema,
2619
+ /** The principal that made the call (§17). An API key here is the answer to "who sent this". */
2620
+ actor: PrincipalSchema,
2621
+ /** The public model id the caller asked for. */
2622
+ model: z27.string(),
2623
+ window: WindowSchema,
2624
+ /** The model the reply said served it — where `vetta/auto` resolves — or null if it named none. */
2625
+ resolved_model: z27.string().nullable(),
2626
+ /**
2627
+ * The serving provider and the gateway's own generation id. Null on every row written before the
2628
+ * adapter stops dropping them (Track A); together they are what lets an upstream invoice line be
2629
+ * matched back to an organization, a key and a ledger entry.
2630
+ */
2631
+ provider: z27.string().nullable(),
2632
+ generation_id: z27.string().nullable(),
2633
+ stop: z27.enum(["end_turn", "tool_use", "length"]).nullable(),
2634
+ usage: TokenUsageSchema,
2635
+ /** What the customer was charged, µUSD. The ledger entry is the authority; this is its copy. */
2636
+ billed_micro_usd: MicroUsdField.nullable(),
2637
+ /** What the vendor said it cost, µUSD. A CROSS-CHECK, NEVER A DEBIT. */
2638
+ vendor_cost_micro_usd: MicroUsdField.nullable(),
2639
+ duration_ms: z27.number().int().nonnegative().nullable(),
2640
+ content_scope: ProxyTraceContentScopeSchema,
2641
+ request_sha256: Sha256,
2642
+ response_sha256: Sha256,
2643
+ /** The size of each body BEFORE any cap, so a truncated row still reports what was really sent. */
2644
+ request_bytes: z27.number().int().nonnegative(),
2645
+ response_bytes: z27.number().int().nonnegative(),
2646
+ /** Null whenever `content_scope` is `metadata`. */
2647
+ request: ProxyTraceRequestSchema.nullable(),
2648
+ response: ProxyTraceResponseSchema.nullable(),
2649
+ truncated: z27.boolean(),
2650
+ created_at: Timestamp,
2651
+ /** When the reaper deletes this row. Never null: there is no row that is kept forever. */
2652
+ expires_at: Timestamp
2653
+ });
2383
2654
 
2384
2655
  // src/define.ts
2385
- import { z as z28 } from "zod";
2656
+ import { z as z30 } from "zod";
2386
2657
 
2387
2658
  // src/roster.ts
2388
- import { z as z27 } from "zod";
2659
+ import { z as z29 } from "zod";
2389
2660
 
2390
2661
  // src/report.ts
2391
2662
  import { ApiError, send } from "@usenaive-sdk/vetta";
2392
- import { z as z26 } from "zod";
2663
+ import { z as z28 } from "zod";
2393
2664
  function message(error) {
2665
+ if (error instanceof ApiError && error.requestId !== "") return `${error.message} (request ${error.requestId})`;
2394
2666
  return error instanceof Error ? error.message : String(error);
2395
2667
  }
2396
- async function line(name, work) {
2668
+ async function line(name, work, id) {
2397
2669
  try {
2398
2670
  return await work();
2399
2671
  } catch (error) {
2400
- return { name, action: "refused", reason: message(error) };
2672
+ const resolved = id?.();
2673
+ return { name, action: "refused", ...resolved !== void 0 ? { id: resolved } : {}, reason: message(error) };
2401
2674
  }
2402
2675
  }
2403
2676
  var AT_ONCE = 6;
@@ -2429,10 +2702,10 @@ async function absent(work) {
2429
2702
  throw error;
2430
2703
  }
2431
2704
  }
2432
- var PageShape = z26.object({
2433
- data: z26.array(z26.unknown()),
2434
- has_more: z26.boolean(),
2435
- next_cursor: z26.string().nullable()
2705
+ var PageShape = z28.object({
2706
+ data: z28.array(z28.unknown()),
2707
+ has_more: z28.boolean(),
2708
+ next_cursor: z28.string().nullable()
2436
2709
  });
2437
2710
  function rowLabel(row) {
2438
2711
  const { object, id } = row ?? {};
@@ -2464,17 +2737,17 @@ async function tombstone(name, current, remove, dryRun) {
2464
2737
  }
2465
2738
 
2466
2739
  // src/roster.ts
2467
- var NAME = z27.string().min(1);
2468
- var RosterNameSchema = z27.union([
2740
+ var NAME = z29.string().min(1);
2741
+ var RosterNameSchema = z29.union([
2469
2742
  NAME.transform((name) => ({ type: "agent", name })),
2470
- z27.object({ type: z27.literal("agent"), name: NAME, version: z27.number().int().positive().optional() }),
2471
- z27.object({ type: z27.literal("self") }),
2472
- z27.object({ type: z27.literal("advisor"), model: z27.string().min(1) })
2743
+ z29.object({ type: z29.literal("agent"), name: NAME, version: z29.number().int().positive().optional() }),
2744
+ z29.object({ type: z29.literal("self") }),
2745
+ z29.object({ type: z29.literal("advisor"), model: z29.string().min(1) })
2473
2746
  ]);
2474
- var DeclMultiagentField = z27.union([
2475
- z27.boolean(),
2476
- z27.object({ ...MultiagentSchema.shape, agents: z27.array(RosterNameSchema).min(1).max(20) }),
2477
- z27.null()
2747
+ var DeclMultiagentField = z29.union([
2748
+ z29.boolean(),
2749
+ z29.object({ ...MultiagentSchema.shape, agents: z29.array(RosterNameSchema).min(1).max(20) }),
2750
+ z29.null()
2478
2751
  ]);
2479
2752
  var hasRoster = (value) => typeof value === "object" && value !== null;
2480
2753
  var rosterNames = (roster) => roster.agents.flatMap((entry) => entry.type === "agent" ? [entry.name] : []);
@@ -2562,65 +2835,65 @@ function chooseTemplate(blueprint, template) {
2562
2835
  var BlueprintRefusal = class extends Error {
2563
2836
  name = "BlueprintRefusal";
2564
2837
  };
2565
- var EnvValueSchema = z28.union([
2566
- z28.string(),
2567
- z28.object({ from_env: z28.string().min(1) }),
2568
- z28.object({ generate: z28.literal(true) })
2838
+ var EnvValueSchema = z30.union([
2839
+ z30.string(),
2840
+ z30.object({ from_env: z30.string().min(1) }),
2841
+ z30.object({ generate: z30.literal(true) })
2569
2842
  ]);
2570
- var AppDeclSchema = z28.object({
2843
+ var AppDeclSchema = z30.object({
2571
2844
  /** Becomes a hostname, so the grammar is the platform's `APP_NAME` (a DNS label). */
2572
- name: z28.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
2845
+ name: z30.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
2573
2846
  type: AppTypeSchema,
2574
- description: z28.string().optional(),
2847
+ description: z30.string().optional(),
2575
2848
  /** A directory whose files are collected and shipped as the app's file-map deployment. */
2576
- deploy_dir: z28.string().min(1).optional(),
2849
+ deploy_dir: z30.string().min(1).optional(),
2577
2850
  /** The path the app itself serves MCP on (§29.5); `fullstack` only. Absent means none. */
2578
2851
  mcp: AppMcpPathSchema.optional(),
2579
2852
  /** Written as the app's write-only secrets (§29.2) on every apply; names follow the platform's `ENV_NAME`. */
2580
- env: z28.record(z28.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
2853
+ env: z30.record(z30.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
2581
2854
  /** An install may not leave this app out of its `selection` (§31.2). Absent means it may. */
2582
- required: z28.boolean().optional(),
2855
+ required: z30.boolean().optional(),
2583
2856
  // core-gaps: U8-database
2584
2857
  /** SQL files applied in order to the app's database after it is provisioned (§37); `fullstack` only. */
2585
- migrations: z28.array(z28.string().min(1)).optional(),
2858
+ migrations: z30.array(z30.string().min(1)).optional(),
2586
2859
  // core-gaps: storage-stock
2587
2860
  /** Buckets the app's object store must hold (§38.2); `fullstack` only. `public` defaults to false. */
2588
- buckets: z28.array(CreateBucketSchema).optional()
2861
+ buckets: z30.array(CreateBucketSchema).optional()
2589
2862
  });
2590
- var ScheduleDeclSchema = z28.object({
2591
- cron: z28.string().min(1),
2592
- timezone: z28.string().min(1).optional(),
2863
+ var ScheduleDeclSchema = z30.object({
2864
+ cron: z30.string().min(1),
2865
+ timezone: z30.string().min(1).optional(),
2593
2866
  /** The message every fire opens its session with (`input_template` on the wire). */
2594
- input: z28.string().min(1),
2867
+ input: z30.string().min(1),
2595
2868
  budget_micro_usd: MicroUsdField.nonnegative(),
2596
- identity: z28.string().min(1).optional(),
2597
- enabled: z28.boolean().optional()
2869
+ identity: z30.string().min(1).optional(),
2870
+ enabled: z30.boolean().optional()
2598
2871
  });
2599
2872
  var ToolsDeclSchema = ToolsetSchema;
2600
- var AgentDeclSchema = z28.object({
2601
- name: z28.string().min(1),
2602
- model: z28.string().min(1),
2873
+ var AgentDeclSchema = z30.object({
2874
+ name: z30.string().min(1),
2875
+ model: z30.string().min(1),
2603
2876
  budget: BudgetSchema,
2604
- description: z28.string().optional(),
2877
+ description: z30.string().optional(),
2605
2878
  /** Two or three words the studio prints beside the name (§31.5) — "Head of content", not a sentence. */
2606
- role: z28.string().min(1).optional(),
2879
+ role: z30.string().min(1).optional(),
2607
2880
  /** An install may not leave this agent out of its `selection` (§31.2). Absent means it may. */
2608
- required: z28.boolean().optional(),
2609
- system: z28.string().optional(),
2881
+ required: z30.boolean().optional(),
2882
+ system: z30.string().optional(),
2610
2883
  tools: ToolsDeclSchema.optional(),
2611
- skills: z28.array(SkillRefSchema).optional(),
2612
- mcp_servers: z28.array(McpServerSchema).optional(),
2884
+ skills: z30.array(SkillRefSchema).optional(),
2885
+ mcp_servers: z30.array(McpServerSchema).optional(),
2613
2886
  /** The rest of the runtime's agent config (§31.6), each the core schema; absent means the route's default and never drift. */
2614
2887
  window: WindowSchema.optional(),
2615
2888
  /** A roster names crew members by declared *name*; `up` resolves them to `agt_` ids in a second pass (`roster.ts`). */
2616
2889
  multiagent: DeclMultiagentField.optional(),
2617
2890
  output_schema: JsonSchemaDocument.nullable().optional(),
2618
- structured_output_required: z28.boolean().optional(),
2891
+ structured_output_required: z30.boolean().optional(),
2619
2892
  metadata: Metadata.optional(),
2620
2893
  /** Declared app *names*; `up` resolves them to `app_` ids in `tools.configs.apps` (§29.3). */
2621
- allowed_apps: z28.array(z28.string()).optional(),
2894
+ allowed_apps: z30.array(z30.string()).optional(),
2622
2895
  /** A declared identity *name*; `up` attaches it after the agent upsert (§22). */
2623
- identity: z28.string().min(1).optional(),
2896
+ identity: z30.string().min(1).optional(),
2624
2897
  /**
2625
2898
  * Who this agent may `send_to_agent` (§31.7, §28.12): `true` (anyone in the organization),
2626
2899
  * `false` (nobody), `"team"` (its `multiagent` roster), or declared agent *names*, checked
@@ -2628,7 +2901,7 @@ var AgentDeclSchema = z28.object({
2628
2901
  */
2629
2902
  handoffs: HandoffsField.optional(),
2630
2903
  /** The agent's deployments as a complete set: declared → owned, and the rest are pruned (ADR-0355). */
2631
- schedules: z28.array(ScheduleDeclSchema).optional(),
2904
+ schedules: z30.array(ScheduleDeclSchema).optional(),
2632
2905
  /**
2633
2906
  * The first thing this agent reads, once, on the apply that **creates** it (`canonical-spec
2634
2907
  * §31.4`). It is what turns a provisioned crew into a crew that has started working.
@@ -2641,58 +2914,66 @@ var AgentDeclSchema = z28.object({
2641
2914
  * repeatedly and unattended while an intake spends once, at an apply a person is watching. Absent
2642
2915
  * means the agent's own `budget` governs.
2643
2916
  */
2644
- intake: z28.object({ message: z28.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
2917
+ intake: z30.object({ message: z30.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
2645
2918
  });
2646
- var CredentialDeclSchema = z28.object({
2919
+ var CredentialDeclSchema = z30.object({
2647
2920
  kind: VaultCredentialKindSchema,
2648
- key: z28.string().min(1).max(128),
2921
+ key: z30.string().min(1).max(128),
2649
2922
  /** The one exact destination host an `env_var` is bound to. */
2650
- host: z28.string().min(1).optional(),
2923
+ host: z30.string().min(1).optional(),
2651
2924
  /** The MCP server URL a `static_bearer` / `mcp_oauth` token is matched to. */
2652
- mcp_server_url: z28.url().optional(),
2653
- value: z28.object({ from_env: z28.string().min(1) })
2925
+ mcp_server_url: z30.url().optional(),
2926
+ value: z30.object({ from_env: z30.string().min(1) })
2654
2927
  });
2655
- var VaultDeclSchema = z28.object({
2928
+ var VaultDeclSchema = z30.object({
2656
2929
  name: VaultSchema.shape.display_name,
2657
- identity: z28.string().min(1).optional(),
2658
- credentials: z28.array(CredentialDeclSchema)
2930
+ identity: z30.string().min(1).optional(),
2931
+ credentials: z30.array(CredentialDeclSchema)
2659
2932
  });
2660
- var SkillDeclSchema = z28.object({
2661
- slug: z28.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2662
- file: z28.string().min(1)
2933
+ var SkillDeclSchema = z30.object({
2934
+ slug: z30.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2935
+ file: z30.string().min(1)
2663
2936
  });
2664
2937
  var LegalDeclSchema = CreateLegalCompanySchema.pick({
2665
2938
  state: true,
2666
2939
  name_options: true,
2667
2940
  naics_code: true,
2668
2941
  description: true
2669
- }).extend({ label: z28.string().min(1).max(128) });
2942
+ }).extend({ label: z30.string().min(1).max(128) });
2670
2943
  var WalletDeclSchema = CreateWalletSchema.or(
2671
- z28.array(CreateWalletSchema).refine(
2944
+ z30.array(CreateWalletSchema).refine(
2672
2945
  (list2) => new Set(list2.map((w) => w.network ?? DEFAULT_WALLET_NETWORK)).size === list2.length,
2673
2946
  { message: "one wallet per network" }
2674
2947
  )
2675
2948
  );
2676
2949
  var CardDeclSchema = IssueCardSchema;
2677
2950
  var IdentityDeclSchema = IdentitySchema.pick({ name: true, description: true }).partial({ description: true }).extend({
2678
- legal: z28.array(LegalDeclSchema).optional(),
2951
+ connections: BlueprintIdentityConnectionsSchema.optional(),
2952
+ legal: z30.array(LegalDeclSchema).optional(),
2679
2953
  wallet: WalletDeclSchema.optional(),
2680
- cards: z28.array(CardDeclSchema).optional()
2681
- });
2682
- var RemovedSchema = z28.object({
2683
- apps: z28.array(z28.string().min(1)).default([]),
2684
- agents: z28.array(z28.string().min(1)).default([]),
2685
- skills: z28.array(z28.string().min(1)).default([]),
2686
- identities: z28.array(z28.string().min(1)).default([]),
2687
- vaults: z28.array(z28.string().min(1)).default([])
2688
- });
2689
- var KeptSchema = z28.object({ agents: z28.array(z28.string().min(1)).default([]) });
2690
- var ProjectSchema = z28.object({
2691
- name: z28.string().min(1),
2954
+ cards: z30.array(CardDeclSchema).optional()
2955
+ });
2956
+ var RemovedSchema = z30.object({
2957
+ apps: z30.array(z30.string().min(1)).default([]),
2958
+ agents: z30.array(z30.string().min(1)).default([]),
2959
+ skills: z30.array(z30.string().min(1)).default([]),
2960
+ identities: z30.array(z30.string().min(1)).default([]),
2961
+ vaults: z30.array(z30.string().min(1)).default([])
2962
+ });
2963
+ var KeptSchema = z30.object({ agents: z30.array(z30.string().min(1)).default([]) });
2964
+ var TaskDeclSchema = z30.object({
2965
+ key: z30.string().min(1),
2966
+ title: z30.string().min(1).max(200),
2967
+ body: z30.string().max(8192).optional(),
2968
+ assignee: z30.string().min(1).optional(),
2969
+ blocked_by: z30.array(z30.string().min(1)).optional()
2970
+ });
2971
+ var ProjectSchema = z30.object({
2972
+ name: z30.string().min(1),
2692
2973
  /** The machine this project runs: its repo, its screens, its `/api/*` (`template.ts`). */
2693
- blueprint: z28.string().min(1).optional(),
2974
+ blueprint: z30.string().min(1).optional(),
2694
2975
  /** Which of that blueprint's templates provides the crew; a blueprint with a default may omit it. */
2695
- template: z28.string().min(1).optional(),
2976
+ template: z30.string().min(1).optional(),
2696
2977
  /**
2697
2978
  * What a person is asked BEFORE the crew is provisioned (`canonical-spec §31.2`).
2698
2979
  *
@@ -2704,19 +2985,21 @@ var ProjectSchema = z28.object({
2704
2985
  *
2705
2986
  * **Configuration only.** A secret is a vault credential or an app secret; neither is an answer.
2706
2987
  */
2707
- questions: z28.array(QuestionFieldSchema).default([]),
2708
- skills: z28.array(SkillDeclSchema).default([]),
2709
- identities: z28.array(IdentityDeclSchema).default([]),
2710
- vaults: z28.array(VaultDeclSchema).default([]),
2711
- apps: z28.array(AppDeclSchema).default([]),
2712
- agents: z28.array(AgentDeclSchema).default([]),
2988
+ questions: z30.array(QuestionFieldSchema).default([]),
2989
+ skills: z30.array(SkillDeclSchema).default([]),
2990
+ identities: z30.array(IdentityDeclSchema).default([]),
2991
+ vaults: z30.array(VaultDeclSchema).default([]),
2992
+ apps: z30.array(AppDeclSchema).default([]),
2993
+ agents: z30.array(AgentDeclSchema).default([]),
2713
2994
  /**
2714
2995
  * The agents this template creates PER CLIENT the operator signs (`canonical-spec §31.1`) —
2715
2996
  * printed on the artifact so a person sees the whole company, never provisioned by an apply,
2716
2997
  * because the apply does not know the clients yet. Names only: a model and a budget are the
2717
2998
  * crew's business at the moment a client is signed, not the declaration's.
2718
2999
  */
2719
- crew_per_client: z28.array(z28.object({ name: z28.string().min(1), role: z28.string().min(1).optional(), description: z28.string().optional() })).optional(),
3000
+ crew_per_client: z30.array(z30.object({ name: z30.string().min(1), role: z30.string().min(1).optional(), description: z30.string().optional() })).optional(),
3001
+ /** The crew's first work, as cards on the organization's board rather than N private intakes (§31.11). */
3002
+ tasks: z30.array(TaskDeclSchema).default([]),
2720
3003
  removed: RemovedSchema.default({ apps: [], agents: [], skills: [], identities: [], vaults: [] }),
2721
3004
  kept: KeptSchema.default({ agents: [] })
2722
3005
  });
@@ -2732,6 +3015,20 @@ function assertUniqueNames(kind, names) {
2732
3015
  seen.add(name);
2733
3016
  }
2734
3017
  }
3018
+ function inDependencyOrder(tasks) {
3019
+ const placed = /* @__PURE__ */ new Set();
3020
+ const out = [];
3021
+ while (out.length < tasks.length) {
3022
+ const next = tasks.find((task) => !placed.has(task.key) && (task.blocked_by ?? []).every((key) => placed.has(key)));
3023
+ if (next === void 0) {
3024
+ const stuck = tasks.filter((task) => !placed.has(task.key)).map((task) => `"${task.key}"`);
3025
+ refuse(`tasks ${stuck.join(", ")}: blocked_by forms a cycle \u2014 a card cannot wait on a card that waits on it`);
3026
+ }
3027
+ placed.add(next.key);
3028
+ out.push(next);
3029
+ }
3030
+ return out;
3031
+ }
2735
3032
  function deepFreeze(value) {
2736
3033
  if (value !== null && typeof value === "object") {
2737
3034
  for (const child of Object.values(value)) deepFreeze(child);
@@ -2757,8 +3054,8 @@ function parseProject(input) {
2757
3054
  }
2758
3055
  const config = parsed.data;
2759
3056
  applyChoice(config);
2760
- if (config.template !== void 0 && config.questions.length > 3) {
2761
- refuse(`template "${config.template}" asks ${config.questions.length} questions, but a template asks at most 3 before anything is provisioned \u2014 a fourth belongs to the crew's first conversation`);
3057
+ if (config.template !== void 0 && config.questions.length > 4) {
3058
+ refuse(`template "${config.template}" asks ${config.questions.length} questions, but a template asks at most 4 before anything is provisioned \u2014 a fifth belongs to the crew's first conversation`);
2762
3059
  }
2763
3060
  assertUniqueNames("app", [...config.apps.map((a) => a.name), ...config.removed.apps]);
2764
3061
  assertUniqueNames("agent", [...config.agents.map((a) => a.name), ...config.removed.agents, ...config.kept.agents]);
@@ -2779,6 +3076,20 @@ function parseProject(input) {
2779
3076
  assertUniqueNames("bucket", (app.buckets ?? []).map((bucket) => bucket.name));
2780
3077
  }
2781
3078
  const identityNames = new Set(config.identities.map((i) => i.name));
3079
+ const connectable = config.identities.filter((i) => i.connections !== void 0).map((i) => i.name);
3080
+ if (connectable.length > 1) {
3081
+ refuse(`identities ${connectable.map((n) => `"${n}"`).join(", ")} each declare connections, but the studio's Add connections step connects one persona \u2014 declare connections on the one the crew publishes through`);
3082
+ }
3083
+ for (const identity of config.identities) {
3084
+ const social = identity.connections?.social;
3085
+ if (social === void 0) continue;
3086
+ const question = config.questions.find((q) => q.key === social.from);
3087
+ if (question === void 0) refuse(`identity "${identity.name}": connections.social.from names "${social.from}", but no question with that key is declared in this project`);
3088
+ if (question.type !== "choice") refuse(`identity "${identity.name}": connections.social.from names "${social.from}", which is a ${question.type} question \u2014 the map is keyed by a choice question's options`);
3089
+ for (const label of Object.keys(social.map)) {
3090
+ if (!question.options.includes(label)) refuse(`identity "${identity.name}": connections.social.map names "${label}", which is not one of question "${social.from}"'s options \u2014 a key no answer can equal is a row nobody can reach`);
3091
+ }
3092
+ }
2782
3093
  for (const vault of config.vaults) {
2783
3094
  if (vault.identity !== void 0 && !identityNames.has(vault.identity)) {
2784
3095
  refuse(`vault "${vault.name}": identity names "${vault.identity}", but no identity with that name is declared in this project`);
@@ -2837,6 +3148,21 @@ function parseProject(input) {
2837
3148
  }
2838
3149
  }
2839
3150
  }
3151
+ assertUniqueNames("task", config.tasks.map((task) => task.key));
3152
+ const taskKeys = new Set(config.tasks.map((task) => task.key));
3153
+ for (const task of config.tasks) {
3154
+ if (`${config.name}:${task.key}`.length > 128) {
3155
+ refuse(`task "${task.key}": "${config.name}:${task.key}" is longer than the 128 characters a card key holds \u2014 shorten the key`);
3156
+ }
3157
+ if (task.assignee !== void 0 && !agentNames.has(task.assignee)) {
3158
+ refuse(`task "${task.key}": assignee names "${task.assignee}", but no agent with that name is declared in this project`);
3159
+ }
3160
+ for (const key of task.blocked_by ?? []) {
3161
+ if (key === task.key) refuse(`task "${task.key}": blocked_by names itself \u2014 a card cannot wait on itself`);
3162
+ if (!taskKeys.has(key)) refuse(`task "${task.key}": blocked_by names "${key}", but no task with that key is declared in this project`);
3163
+ }
3164
+ }
3165
+ inDependencyOrder(config.tasks);
2840
3166
  return deepFreeze(config);
2841
3167
  }
2842
3168
  function withTemplate(input, templates) {
@@ -3081,6 +3407,11 @@ async function openIntake(client, agent, decl, dryRun) {
3081
3407
  });
3082
3408
  return { name: agent.name, action: "created", id: started.id };
3083
3409
  }
3410
+ function brief(input) {
3411
+ const first = input.trim().split(/(?<=[.!?])\s|\n/)[0]?.trim() ?? "";
3412
+ const text = first.replace(/[.\s]+$/, "");
3413
+ return text.length > 72 ? `${text.slice(0, 71).trimEnd()}\u2026` : text;
3414
+ }
3084
3415
  async function upsertSchedule(client, agent, decl, current, identityIds, dryRun) {
3085
3416
  const name = `${agent.name} @ ${decl.cron}`;
3086
3417
  if (agent.action === "refused") throw new Error(`agent "${agent.name}" was not provisioned in this run`);
@@ -3113,13 +3444,16 @@ async function upsertSchedule(client, agent, decl, current, identityIds, dryRun)
3113
3444
  async function reconcileSchedules(client, agent, declared, live, identityIds, dryRun, into) {
3114
3445
  const rows = live.filter((row) => row.agent_id === agent.id);
3115
3446
  into.push(
3116
- ...await eachInFlight(
3117
- declared,
3118
- (decl) => line(
3447
+ ...await eachInFlight(declared, async (decl) => ({
3448
+ ...await line(
3119
3449
  `${agent.name} @ ${decl.cron}`,
3120
3450
  () => upsertSchedule(client, agent, decl, rows.find((row) => row.cron === decl.cron), identityIds, dryRun)
3121
- )
3122
- )
3451
+ ),
3452
+ // `<agent> @ <cron>` says WHEN a timer runs and nothing about what it does, so the dashboard's
3453
+ // opening message could only ever draw a timetable from these lines. The brief's first
3454
+ // sentence is what turns that timetable into a roadmap (§29.6).
3455
+ summary: brief(decl.input)
3456
+ }))
3123
3457
  );
3124
3458
  for (const row of rows.filter((row2) => !declared.some((decl) => decl.cron === row2.cron))) {
3125
3459
  const name = `${agent.name} @ ${row.cron}`;
@@ -3527,6 +3861,81 @@ async function reportLegal(client, decls, identityId, skipped) {
3527
3861
  );
3528
3862
  }
3529
3863
 
3864
+ // src/tasks.ts
3865
+ var ORCHESTRATOR_MARKER = "orchestrator";
3866
+ var CEO_LABEL = "CEO";
3867
+ var CEO_DETAIL = "Hires and directs the crew";
3868
+ var CEO_BUDGET = { cap_micro_usd: 5e7, max_task_micro_usd: 5e6, period: "month" };
3869
+ var isOrchestrator = (agent) => agent.metadata["role"] === ORCHESTRATOR_MARKER;
3870
+ function seated(live, members) {
3871
+ const roster = live?.agents ?? [];
3872
+ const already = new Set(roster.flatMap((entry) => entry.type === "agent" ? [entry.id] : []));
3873
+ const joining = members.filter((id) => !already.has(id)).map((id) => ({ type: "agent", id }));
3874
+ return { type: "coordinator", board: true, agents: [...roster, ...joining] };
3875
+ }
3876
+ async function ensureOrchestrator(client, existing, members, dryRun) {
3877
+ const current = existing.find(isOrchestrator);
3878
+ const live = current === void 0 ? null : normaliseMultiagent(current.multiagent);
3879
+ const team = seated(live, members);
3880
+ if (current === void 0) {
3881
+ if (dryRun) return { name: CEO_LABEL, action: "created" };
3882
+ const model = (await client.models.list({ window: "immediate", limit: 1 })).data[0];
3883
+ if (model === void 0) throw new BlueprintRefusal("no model is served, so the board's owner cannot be created");
3884
+ const made = await client.agents.create({
3885
+ name: CEO_LABEL,
3886
+ harness: "pi",
3887
+ model: model.id,
3888
+ description: CEO_DETAIL,
3889
+ budget: CEO_BUDGET,
3890
+ metadata: { role: ORCHESTRATOR_MARKER },
3891
+ multiagent: team
3892
+ });
3893
+ return { name: CEO_LABEL, action: "created", id: made.id };
3894
+ }
3895
+ if (live !== null && !changed(team, live)) return { name: current.name, action: "unchanged", id: current.id };
3896
+ if (!dryRun) await client.agents.update(current.id, { multiagent: team });
3897
+ return { name: current.name, action: "updated", id: current.id };
3898
+ }
3899
+ async function seedTasks(client, config, existing, agents, dryRun, into, skipped) {
3900
+ const members = agents.flatMap((one) => one.id === void 0 ? [] : [one.id]);
3901
+ const owner = await line(CEO_LABEL, () => ensureOrchestrator(client, existing, members, dryRun));
3902
+ agents.push(owner);
3903
+ const board = owner.action === "refused" || dryRun || owner.id === void 0 ? null : await client.board.create(owner.id);
3904
+ const before = board === null ? [] : await listAll(client.config, `/v1/boards/${board.id}/cards`, BoardCardSchema, skipped);
3905
+ const known = new Set(before.map((card) => card.id));
3906
+ const ids = /* @__PURE__ */ new Map();
3907
+ for (const task of inDependencyOrder(config.tasks)) {
3908
+ into.push(
3909
+ await line(task.key, async () => {
3910
+ if (owner.action === "refused") return { name: task.key, action: "refused", reason: `board owner "${owner.name}" was refused: ${owner.reason}` };
3911
+ const assignee = task.assignee;
3912
+ if (assignee !== void 0 && !agents.some((one) => one.name === assignee && one.action !== "refused")) {
3913
+ return { name: task.key, action: "refused", reason: `assignee "${assignee}" was not provisioned in this run` };
3914
+ }
3915
+ if (board === null) return { name: task.key, action: "created" };
3916
+ const blockers = task.blocked_by ?? [];
3917
+ const unmet = blockers.find((key) => !ids.has(key));
3918
+ if (unmet !== void 0) return { name: task.key, action: "refused", reason: `blocked_by "${unmet}" was not seeded in this run` };
3919
+ const card = await client.board.cards.create(board.id, {
3920
+ key: `${config.name}:${task.key}`,
3921
+ title: task.title,
3922
+ body: task.body,
3923
+ assignee,
3924
+ blocked_by: blockers.map((key) => ids.get(key))
3925
+ });
3926
+ ids.set(task.key, card.id);
3927
+ return {
3928
+ name: task.key,
3929
+ action: known.has(card.id) ? "unchanged" : "created",
3930
+ id: card.id,
3931
+ title: task.title,
3932
+ ...assignee === void 0 ? {} : { assignee }
3933
+ };
3934
+ })
3935
+ );
3936
+ }
3937
+ }
3938
+
3530
3939
  // src/vaults.ts
3531
3940
  async function upsertVault(client, decl, existing, identityIds, dryRun) {
3532
3941
  const identityId = decl.identity === void 0 ? void 0 : identityIds.get(decl.identity);
@@ -3737,7 +4146,7 @@ async function up(config, client, opts = {}) {
3737
4146
  const dir = opts.dir ?? process.cwd();
3738
4147
  const ids = { apps: /* @__PURE__ */ new Map(), identities: /* @__PURE__ */ new Map() };
3739
4148
  const taken = selectCrew(config, opts.select);
3740
- const report2 = { dry_run: dryRun, ...applied(config), skills: [], identities: [], vaults: [], apps: [], agents: [], schedules: [], intake: [], skipped: [], deselected: taken.deselected };
4149
+ const report2 = { dry_run: dryRun, ...applied(config), skills: [], identities: [], vaults: [], apps: [], agents: [], schedules: [], intake: [], tasks: [], skipped: [], deselected: taken.deselected };
3741
4150
  const owner = { project: config.name, adopt: opts.adopt ?? false, skipped: report2.skipped };
3742
4151
  const hosted = opts.trees !== void 0;
3743
4152
  for (const decl of config.skills) {
@@ -3796,11 +4205,15 @@ async function up(config, client, opts = {}) {
3796
4205
  platform
3797
4206
  },
3798
4207
  ids.apps
3799
- )
4208
+ ),
4209
+ // The app's id is recorded the moment it exists — before its secrets and deploy — so a
4210
+ // failure in that upload reports `refused` naming the created app, not one the operator
4211
+ // cannot find. A pre-create refusal (an unset `from_env`, a missing tree) has set nothing.
4212
+ () => ids.apps.get(decl.name)
3800
4213
  )
3801
4214
  )
3802
4215
  );
3803
- const existing = taken.agents.length > 0 || config.removed.agents.length > 0 || config.kept.agents.length > 0 ? await listAll(client.config, "/v1/agents", AgentSchema, report2.skipped) : [];
4216
+ 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) : [];
3804
4217
  const deployments = taken.agents.some((decl) => decl.schedules !== void 0) ? await listAll(client.config, "/v1/deployments", DeploymentSchema, report2.skipped) : [];
3805
4218
  const scoped = config.apps.length > 0 ? [...ids.apps.values()] : void 0;
3806
4219
  const crew = await eachInFlight(taken.agents, async (decl) => {
@@ -3827,6 +4240,7 @@ async function up(config, client, opts = {}) {
3827
4240
  if (hasRoster(decl.multiagent)) await patchRoster(client, decl, decl.multiagent, existing, agentIds, dryRun, report2.agents);
3828
4241
  }
3829
4242
  reportKept(config, existing, report2.agents);
4243
+ if (config.tasks.length > 0) await seedTasks(client, config, existing, report2.agents, dryRun, report2.tasks, report2.skipped);
3830
4244
  await applyRemoved(client, config.removed, { agents: existing, vaults }, owner, report2);
3831
4245
  if (briefed.length > 0 && !dryRun) {
3832
4246
  const serving = taken.apps.flatMap((decl) => {