@usenaive-sdk/blueprints 0.10.0 → 0.11.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
@@ -1,3 +1,8 @@
1
+ import {
2
+ BLUEPRINTS,
3
+ chooseTemplate
4
+ } from "./chunk-CVZ2DY27.js";
5
+
1
6
  // ../core/src/id.ts
2
7
  var ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
3
8
  var SUFFIX_LENGTH = 26;
@@ -157,6 +162,7 @@ var AUDIT_ACTIONS_P1 = [
157
162
  "org.updated",
158
163
  "subscription.updated",
159
164
  "subscription.canceled",
165
+ "subscription.plan_changed",
160
166
  "session.budget_updated",
161
167
  "session.cancelled",
162
168
  "skill.created",
@@ -218,6 +224,9 @@ var AUDIT_ACTIONS_P3 = [
218
224
  "referral.attributed"
219
225
  ];
220
226
  var AUDIT_ACTIONS_PRIMITIVES = [
227
+ "ad_campaign.created",
228
+ "ad_campaign.activated",
229
+ "ad_campaign.paused",
221
230
  "legal_verification.started",
222
231
  "legal_member.completed",
223
232
  "legal_member.link_resent",
@@ -280,7 +289,7 @@ var JsonSchemaDocument = z.record(z.string(), z.unknown()).refine((schema) => sc
280
289
  var WindowSchema = z.enum(["immediate", "priority", "loose"]);
281
290
  var TOKEN_TIERS = ["input", "cache_write", "cache_read", "output", "reasoning"];
282
291
  var TokenTierSchema = z.enum(TOKEN_TIERS);
283
- var TOOL_TIERS = ["search", "media", "social", "browser", "storage", "email"];
292
+ var TOOL_TIERS = ["search", "media", "social", "browser", "storage", "email", "voice"];
284
293
  var LINE_ITEM_TIERS = [...TOKEN_TIERS, "computer", ...TOOL_TIERS];
285
294
  var LineItemTierSchema = z.enum(LINE_ITEM_TIERS);
286
295
  var TokenUsageSchema = z.object({
@@ -328,6 +337,12 @@ var TimezoneSchema = z3.string().transform((name, ctx) => {
328
337
  }
329
338
  return zone;
330
339
  });
340
+ var BRAND_TYPEFACES = ["grotesk", "serif", "rounded", "mono"];
341
+ var BrandKitSchema = z3.object({
342
+ palette: z3.array(z3.object({ name: z3.string().trim().min(1).max(24), hex: z3.string().regex(/^#[0-9a-f]{6}$/) }).strict()).min(3).max(6),
343
+ typeface: z3.enum(BRAND_TYPEFACES),
344
+ tagline: z3.string().trim().max(80)
345
+ }).strict();
331
346
  var OrganizationSchema = z3.object({
332
347
  id: idOf("org"),
333
348
  object: z3.literal("organization"),
@@ -345,6 +360,15 @@ var OrganizationSchema = z3.object({
345
360
  * until one is set. Defaulted so a reply from a control plane older than 0093 still parses.
346
361
  */
347
362
  logo_svg: z3.string().nullable().default(null),
363
+ /** Its brand kit (ADR-1163), `null` until one is set. Defaulted so an older control plane parses. */
364
+ brand: BrandKitSchema.nullable().default(null),
365
+ /**
366
+ * Still being set up: made in a chat with its CEO and not yet activated by a payment (ADR-1108).
367
+ * Defaulted `false`, so a reply from a control plane older than 0101 reads as an ordinary company.
368
+ */
369
+ setting_up: z3.boolean().default(false),
370
+ /** The `blueprint/template` a link named when the company was made, else `null` (ADR-1108). */
371
+ start_template: z3.string().nullable().default(null),
348
372
  created_at: Timestamp
349
373
  });
350
374
  var RoleSchema = z3.enum(["owner", "admin", "member"]);
@@ -664,7 +688,35 @@ var BudgetSchema = z6.object({
664
688
  var SkillRefSchema = z6.string().regex(/^(naive\/)?[a-z0-9][a-z0-9-]*(@\d+)?$/, {
665
689
  error: "expected `slug`, `slug@N`, `naive/slug` or `naive/slug@N`"
666
690
  });
691
+ var SECRET_HEADER = /^(authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token)$/i;
667
692
  var McpServerSchema = z6.object({
693
+ name: z6.string().min(1).max(64),
694
+ url: z6.url().startsWith("https://", { error: "an MCP server URL must be HTTPS" }),
695
+ headers: z6.record(z6.string().max(128), z6.string().max(4096)).optional()
696
+ }).superRefine((server, ctx) => {
697
+ let url = null;
698
+ try {
699
+ url = new URL(server.url);
700
+ } catch {
701
+ }
702
+ if (url && (url.username !== "" || url.password !== "")) {
703
+ ctx.addIssue({
704
+ code: "custom",
705
+ path: ["url"],
706
+ message: "credentials belong in a vault-bound MCP credential, not the server URL"
707
+ });
708
+ }
709
+ for (const name of Object.keys(server.headers ?? {})) {
710
+ if (SECRET_HEADER.test(name)) {
711
+ ctx.addIssue({
712
+ code: "custom",
713
+ path: ["headers", name],
714
+ message: "credentials belong in a vault-bound MCP credential, not agent config"
715
+ });
716
+ }
717
+ }
718
+ });
719
+ var StoredMcpServerSchema = z6.object({
668
720
  name: z6.string(),
669
721
  url: z6.url(),
670
722
  headers: z6.record(z6.string(), z6.string()).optional()
@@ -702,7 +754,7 @@ var agentConfigShape = {
702
754
  window: WindowSchema,
703
755
  system: z6.string(),
704
756
  tools: ToolsetSchema,
705
- mcp_servers: z6.array(McpServerSchema),
757
+ mcp_servers: z6.array(StoredMcpServerSchema),
706
758
  skills: z6.array(SkillRefSchema),
707
759
  multiagent: MultiagentField,
708
760
  /** Optional on the type so a version minted before §28.15 still parses; read it through `handoffsOf`. */
@@ -1772,7 +1824,7 @@ var AppPermissionsSchema = z15.object({
1772
1824
  // ../core/src/schema/install.ts
1773
1825
  import { z as z16 } from "zod";
1774
1826
  var BlueprintInstallSourceSchema = z16.enum(["studio", "cli"]);
1775
- var BlueprintInstallStatusSchema = z16.enum(["pending", "applied", "failed"]);
1827
+ var BlueprintInstallStatusSchema = z16.enum(["held", "pending", "applied", "failed"]);
1776
1828
  var ResourceActionSchema = z16.enum(["created", "updated", "unchanged", "deleted", "refused"]);
1777
1829
  var ResourceReportSchema = z16.object({
1778
1830
  name: z16.string().min(1),
@@ -1909,264 +1961,79 @@ var ProjectContextSchema = z16.object({
1909
1961
  });
1910
1962
 
1911
1963
  // ../core/src/schema/blueprint.ts
1912
- import { z as z17 } from "zod";
1913
- var BlueprintScheduleSchema = z17.object({
1914
- agent: z17.string().min(1),
1915
- cron: z17.string().min(1),
1916
- timezone: z17.string().nullable(),
1917
- /** The message each fire opens its session with — the sentence worth printing. */
1918
- input: z17.string().min(1),
1919
- budget_micro_usd: MicroUsdField.nonnegative()
1920
- });
1921
- var BlueprintBudgetSchema = BlueprintScheduleSchema.pick({ agent: true, cron: true, budget_micro_usd: true });
1922
- var BlueprintCrewSchema = z17.object({
1923
- name: z17.string().min(1),
1924
- description: z17.string().nullable(),
1925
- model: z17.string().min(1),
1926
- briefed: z17.boolean(),
1927
- intake: z17.string().nullable().optional(),
1928
- /** What the first session may spend: the intake's own cap, else the agent's (§31.4). Set iff `briefed`. */
1929
- intake_micro_usd: MicroUsdField.nonnegative().optional(),
1930
- role: z17.string().min(1).optional(),
1931
- skills: z17.array(SkillRefSchema).optional(),
1932
- tools: z17.array(z17.string().min(1)).optional(),
1933
- required: z17.boolean().optional()
1934
- });
1935
- var BlueprintAppSchema = z17.object({
1936
- name: z17.string().min(1),
1937
- type: AppTypeSchema,
1938
- description: z17.string().nullable(),
1939
- mcp: z17.string().nullable().optional(),
1940
- tools: z17.array(z17.string().min(1)).optional(),
1941
- /** Whether an install may deselect it (§31.2). Optional: the rollout argument above. */
1942
- required: z17.boolean().optional()
1943
- });
1944
- var BlueprintIdentitySchema = z17.object({
1945
- name: z17.string().min(1),
1946
- description: z17.string().nullable()
1947
- });
1948
- var ContentHashSchema = z17.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
1949
- var BlueprintTreeSchema = z17.object({
1950
- /** `apps[].name` in the declaration — the same name §31.5 prints and the install ensures by. */
1951
- app: z17.string().min(1),
1952
- content_hash: ContentHashSchema
1953
- });
1954
- var BlueprintArtifactSchema = z17.object({
1955
- id: idOf("bpa"),
1956
- object: z17.literal("blueprint_artifact"),
1957
- /** The machine — its repository, screens and `/api/*`. */
1958
- blueprint: z17.string().min(1),
1959
- /** Which of that blueprint's templates provides the crew. */
1960
- template: z17.string().min(1),
1961
- /** The blueprint repository's own released version. Stored, never parsed (ADR-0401). */
1962
- version: z17.string().min(1),
1963
- /**
1964
- * What a person calls the template, one line on what its crew does, and the networks it publishes
1965
- * to — printed, never provisioned (§31.5, ADR-0921). `platforms` is decoration: where the crew
1966
- * posts is the accounts connected to its persona. Optional for the §31.5 rollout reason.
1967
- */
1968
- title: z17.string().min(1).optional(),
1969
- description: z17.string().min(1).optional(),
1970
- platforms: z17.array(SocialPlatformSchema).optional(),
1971
- /**
1972
- * The built trees, one per deployable app, ordered as the declaration orders its apps. Empty for
1973
- * a data-only blueprint: it declares no app, builds nothing, and still ships a crew (ADR-0900).
1974
- */
1975
- trees: z17.array(BlueprintTreeSchema),
1976
- /**
1977
- * The setup questions, asked by the studio **before** provisioning. `QuestionField` (§7.1) is
1978
- * reused rather than restated: a setup question and a question a parked agent asks are the same
1979
- * object at different times, so one component renders both.
1980
- */
1981
- questions: z17.array(QuestionFieldSchema),
1982
- schedules: z17.array(BlueprintScheduleSchema),
1983
- /** Who the crew is, and what it deploys — §31.5. Derived from `declaration`, never stored twice. */
1984
- agents: z17.array(BlueprintCrewSchema),
1985
- apps: z17.array(BlueprintAppSchema),
1986
- /**
1987
- * The agents a template creates per client the operator signs — printed, never provisioned by an
1988
- * apply (§31.1). Absent on rows published before WS12 v2, hence optional.
1989
- */
1990
- crew_per_client: z17.array(BlueprintCrewSchema).optional(),
1991
- /**
1992
- * The personas the crew posts from, and which accounts to connect to each before the crew
1993
- * exists (§31.10). Derived from `declaration` like `agents`; optional for the §31.5 rollout reason.
1994
- */
1995
- identities: z17.array(BlueprintIdentitySchema).optional(),
1996
- /**
1997
- * The creator template a row was published from (§42.8), `null` on every first-party row.
1998
- * `creator_name` is the public display name the landing page credits. The API sends all three
1999
- * on every row; they are optional here only so an artifact typed before §42 still reads.
2000
- */
2001
- creator_template_id: idOf("ctp").nullish(),
2002
- creator_template_version: z17.number().int().positive().nullish(),
2003
- creator_name: z17.string().min(1).nullish(),
2004
- published_at: Timestamp
2005
- });
2006
-
2007
- // ../core/src/schema/vault.ts
2008
- import { z as z18 } from "zod";
2009
- var VaultCredentialKindSchema = z18.enum(["env_var", "static_bearer", "mcp_oauth"]);
2010
- var VaultSchema = z18.object({
2011
- id: idOf("vlt"),
2012
- object: z18.literal("vault"),
2013
- identity_id: idOf("idn").nullable(),
2014
- display_name: z18.string().min(1).max(128),
2015
- credential_count: z18.number().int().nonnegative(),
2016
- created_at: Timestamp
2017
- });
2018
- var VaultCredentialSchema = z18.object({
2019
- id: idOf("vcr"),
2020
- object: z18.literal("vault_credential"),
2021
- vault_id: idOf("vlt"),
2022
- kind: VaultCredentialKindSchema,
2023
- /** For `env_var`, the environment variable name. For the MCP kinds, a display label. */
2024
- key: z18.string().min(1).max(128),
2025
- /** The exact destination host an `env_var` credential is bound to. Never a wildcard. */
2026
- host: z18.string().nullable(),
2027
- /** The exact MCP server URL an `mcp_*` token is matched to. */
2028
- mcp_server_url: z18.url().nullable(),
2029
- /**
2030
- * The one agent this credential may be injected into (ADR-1097). `null` is any agent that
2031
- * declares `mcp_server_url` — except the platform's own `/v1/mcp`, whose key is never injected
2032
- * unbound. Set at create, by `admin`, and immutable like the rest. Defaults to `null` so a
2033
- * client reading a control plane older than the field still parses the row.
2034
- */
2035
- agent_id: idOf("agt").nullable().default(null),
2036
- placeholder_ref: z18.string(),
2037
- expires_at: Timestamp.nullable(),
2038
- last_injected_at: Timestamp.nullable(),
2039
- created_at: Timestamp
2040
- });
1964
+ import { z as z20 } from "zod";
2041
1965
 
2042
- // ../core/src/schema/handoff.ts
1966
+ // ../core/src/schema/mini-app.ts
2043
1967
  import { z as z19 } from "zod";
2044
- var MAX_HANDOFF_TARGETS = 6;
2045
- var HandoffRequestSchema = z19.object({
2046
- agent: z19.string().min(1),
2047
- message: z19.string().min(1),
2048
- handoff_key: z19.string().min(1).max(128).optional(),
2049
- budget_micro_usd: z19.number().int().positive().optional()
2050
- });
2051
- var HandoffSchema = z19.object({
2052
- object: z19.literal("handoff"),
2053
- session_id: idOf("ses"),
2054
- status: z19.enum(["queued", "already_running"]),
2055
- handoff_key: z19.string().nullable()
2056
- });
2057
- var SessionHandoffRequestSchema = z19.object({
2058
- agents: z19.array(z19.string().min(1)).min(1).max(MAX_HANDOFF_TARGETS),
2059
- message: z19.string().min(1),
2060
- handoff_key: z19.string().min(1).max(128).optional(),
2061
- budget_micro_usd: z19.number().int().positive().optional()
2062
- });
2063
- var HandoffRefusalSchema = z19.object({
2064
- object: z19.literal("handoff_refusal"),
2065
- agent: z19.string(),
2066
- code: z19.string(),
2067
- message: z19.string()
2068
- });
2069
- var HandoffBatchSchema = z19.object({
2070
- object: z19.literal("handoff_batch"),
2071
- handoffs: z19.array(HandoffSchema.extend({ agent_id: idOf("agt") })),
2072
- refusals: z19.array(HandoffRefusalSchema)
2073
- });
2074
- var SessionHandoffSchema = z19.object({
2075
- from_session: idOf("ses"),
2076
- from_agent: idOf("agt"),
2077
- key: z19.string().nullable(),
2078
- depth: z19.number().int().positive()
2079
- });
2080
- var ChannelBriefSchema = z19.object({
2081
- root_session_id: idOf("ses"),
2082
- name: z19.string().min(1),
2083
- members: z19.array(z19.string().min(1)),
2084
- /**
2085
- * The receiver's own name, so it can tell the part of a post addressed to it from a teammate's
2086
- * (ADR-1099). Optional: a brief pinned before it existed still parses.
2087
- */
2088
- you: z19.string().min(1).optional()
2089
- });
2090
- var ChannelPostRequestSchema = z19.object({
2091
- message: z19.string().min(1).max(2e4)
2092
- });
2093
- var ChannelPostSchema = z19.object({
2094
- object: z19.literal("channel_post"),
2095
- root_session_id: idOf("ses"),
2096
- queued: z19.boolean()
2097
- });
2098
1968
 
2099
1969
  // ../core/src/schema/show.ts
2100
- import { z as z20 } from "zod";
1970
+ import { z as z17 } from "zod";
2101
1971
  var SHOW_SOURCES = ["spend_by_day", "post_views", "roadmap", "schedule"];
2102
- var ShowSourceSchema = z20.enum(SHOW_SOURCES);
2103
- var ShowArgsSchema = z20.object({
1972
+ var ShowSourceSchema = z17.enum(SHOW_SOURCES);
1973
+ var ShowArgsSchema = z17.object({
2104
1974
  source: ShowSourceSchema.describe(
2105
1975
  "What to show: spend_by_day (company spend per day, a line), post_views (views per recent post, bars), roadmap (the board's work by status), schedule (routines and scheduled posts over the next 7 days)."
2106
1976
  ),
2107
- days: z20.number().int().min(2).max(30).optional().describe("spend_by_day only: days back, today included. Default 14.")
1977
+ days: z17.number().int().min(2).max(30).optional().describe("spend_by_day only: days back, today included. Default 14.")
2108
1978
  });
2109
- var Day = z20.string().regex(/^\d{4}-\d{2}-\d{2}$/);
2110
- var Count = z20.number().int().nonnegative();
2111
- var head = { title: z20.string().min(1), as_of: Timestamp, timezone: z20.string().min(1) };
2112
- var SpendByDayViewSchema = z20.object({
2113
- source: z20.literal("spend_by_day"),
1979
+ var Day = z17.string().regex(/^\d{4}-\d{2}-\d{2}$/);
1980
+ var Count = z17.number().int().nonnegative();
1981
+ var head = { title: z17.string().min(1), as_of: Timestamp, timezone: z17.string().min(1) };
1982
+ var SpendByDayViewSchema = z17.object({
1983
+ source: z17.literal("spend_by_day"),
2114
1984
  ...head,
2115
- days: z20.array(z20.object({ day: Day, micro_usd: Count })).min(2).max(30)
1985
+ days: z17.array(z17.object({ day: Day, micro_usd: Count })).min(2).max(30)
2116
1986
  });
2117
- var PostViewsViewSchema = z20.object({
2118
- source: z20.literal("post_views"),
1987
+ var PostViewsViewSchema = z17.object({
1988
+ source: z17.literal("post_views"),
2119
1989
  ...head,
2120
- posts: z20.array(z20.object({ post_id: z20.string().min(1), label: z20.string(), networks: z20.array(z20.string()), posted_at: Timestamp, views: Count })).max(12)
1990
+ posts: z17.array(z17.object({ post_id: z17.string().min(1), label: z17.string(), networks: z17.array(z17.string()), posted_at: Timestamp, views: Count })).max(12)
2121
1991
  });
2122
- var RoadmapViewSchema = z20.object({
2123
- source: z20.literal("roadmap"),
1992
+ var RoadmapViewSchema = z17.object({
1993
+ source: z17.literal("roadmap"),
2124
1994
  ...head,
2125
- groups: z20.array(
2126
- z20.object({
1995
+ groups: z17.array(
1996
+ z17.object({
2127
1997
  status: BoardStatusSchema,
2128
1998
  count: Count,
2129
- cards: z20.array(z20.object({ title: z20.string(), assignee: z20.string().nullable(), waits_on: z20.array(z20.string()) })).max(5)
1999
+ cards: z17.array(z17.object({ title: z17.string(), assignee: z17.string().nullable(), waits_on: z17.array(z17.string()) })).max(5)
2130
2000
  })
2131
2001
  )
2132
2002
  });
2133
- var ScheduleViewSchema = z20.object({
2134
- source: z20.literal("schedule"),
2003
+ var ScheduleViewSchema = z17.object({
2004
+ source: z17.literal("schedule"),
2135
2005
  ...head,
2136
- days: z20.array(
2137
- z20.object({
2006
+ days: z17.array(
2007
+ z17.object({
2138
2008
  day: Day,
2139
2009
  count: Count,
2140
- items: z20.array(
2141
- z20.discriminatedUnion("kind", [
2142
- z20.object({ kind: z20.literal("routine"), at: Timestamp, agent: z20.string(), text: z20.string(), runs: z20.number().int().min(1).max(100) }),
2143
- z20.object({ kind: z20.literal("post"), at: Timestamp, networks: z20.array(z20.string()), text: z20.string() })
2010
+ items: z17.array(
2011
+ z17.discriminatedUnion("kind", [
2012
+ z17.object({ kind: z17.literal("routine"), at: Timestamp, agent: z17.string(), text: z17.string(), runs: z17.number().int().min(1).max(100) }),
2013
+ z17.object({ kind: z17.literal("post"), at: Timestamp, networks: z17.array(z17.string()), text: z17.string() })
2144
2014
  ])
2145
2015
  ).max(8)
2146
2016
  })
2147
2017
  ).max(7)
2148
2018
  });
2149
- var ShowViewSchema = z20.discriminatedUnion("source", [
2019
+ var ShowViewSchema = z17.discriminatedUnion("source", [
2150
2020
  SpendByDayViewSchema,
2151
2021
  PostViewsViewSchema,
2152
2022
  RoadmapViewSchema,
2153
2023
  ScheduleViewSchema
2154
2024
  ]);
2155
2025
 
2156
- // ../core/src/schema/compose.ts
2157
- import { z as z22 } from "zod";
2158
-
2159
2026
  // ../core/src/schema/catalog.ts
2160
- import { z as z21 } from "zod";
2161
- var Key = z21.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,39}$/, "an element key is a short name: a letter, then letters, digits, - or _");
2162
- var Count2 = z21.number().int().nonnegative();
2027
+ import { z as z18 } from "zod";
2028
+ var Key = z18.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,39}$/, "an element key is a short name: a letter, then letters, digits, - or _");
2029
+ var Count2 = z18.number().int().nonnegative();
2163
2030
  var DIGIT = "words only: a digit is refused, because every number on the card is read by code from a $source binding";
2164
- var words = (max) => z21.string().trim().min(1).max(max).regex(/^[^0-9]*$/, DIGIT).refine((text) => !new RegExp("\\p{N}", "u").test(text), DIGIT);
2165
- var Days = z21.number().int().min(1).max(30).default(7).describe("The window: today and the days before it, on the company's clock. Default 7.");
2031
+ var words = (max) => z18.string().trim().min(1).max(max).regex(/^[^0-9]*$/, DIGIT).refine((text) => !new RegExp("\\p{N}", "u").test(text), DIGIT);
2032
+ var Days = z18.number().int().min(1).max(30).default(7).describe("The window: today and the days before it, on the company's clock. Default 7.");
2166
2033
  function bound(sources2, shape) {
2167
2034
  const example = JSON.stringify({ $source: sources2[0] });
2168
- return z21.strictObject(
2169
- { $source: z21.enum(sources2), ...shape },
2035
+ return z18.strictObject(
2036
+ { $source: z18.enum(sources2), ...shape },
2170
2037
  { error: (issue) => issue.code === "invalid_type" ? `must be a binding such as ${example}: a literal value is refused, code reads every number` : void 0 }
2171
2038
  );
2172
2039
  }
@@ -2177,38 +2044,38 @@ var Bound = {
2177
2044
  delta: bound(["views_change"], {}).describe(
2178
2045
  "views_change: the value's views_total against the same number of days before it, as a percentage. Its window is the value's."
2179
2046
  ),
2180
- series: bound(["spend_by_day"], { days: z21.number().int().min(2).max(30).default(14) }).describe("spend_by_day: the company's spend per day (the CEO only)."),
2181
- bars: bound(["post_views"], { limit: z21.number().int().min(1).max(12).default(5).describe("How many posts, newest first. Default 5.") }).describe(
2047
+ series: bound(["spend_by_day"], { days: z18.number().int().min(2).max(30).default(14) }).describe("spend_by_day: the company's spend per day (the CEO only)."),
2048
+ bars: bound(["post_views"], { limit: z18.number().int().min(1).max(12).default(5).describe("How many posts, newest first. Default 5.") }).describe(
2182
2049
  "post_views: each recent post's latest views, newest first."
2183
2050
  ),
2184
- progress: bound(["posts_this_week"], {}).describe("posts_this_week: posts published since Monday against the weekly cadence from the company's setup."),
2051
+ progress: bound(["posts_this_week"], {}).describe("posts_this_week: posts published since Monday against the weekly cadence from the company's setup or its channel plan, else 3\xD7 a week."),
2185
2052
  board: bound(["roadmap"], {}).describe("roadmap: the board's work by status."),
2186
2053
  week: bound(["schedule"], {}).describe("schedule: routines and scheduled posts over the next 7 days."),
2187
- media: z21.union([bound(["latest_media"], { count: z21.number().int().min(1).max(4).default(1) }), z21.array(idOf("fil")).min(1).max(4)]).describe('{"$source":"latest_media","count":1} for the newest posted pictures or clips, or up to 4 fil_ ids.')
2054
+ media: z18.union([bound(["latest_media"], { count: z18.number().int().min(1).max(4).default(1) }), z18.array(idOf("fil")).min(1).max(4)]).describe('{"$source":"latest_media","count":1} for the newest posted pictures or clips, or up to 4 fil_ ids.')
2188
2055
  };
2189
- var SpendDay = z21.strictObject({ day: z21.string().regex(/^\d{4}-\d{2}-\d{2}$/), micro_usd: Count2 });
2056
+ var SpendDay = z18.strictObject({ day: z18.string().regex(/^\d{4}-\d{2}-\d{2}$/), micro_usd: Count2 });
2190
2057
  var Resolved = {
2191
- value: z21.discriminatedUnion("$source", [
2192
- z21.strictObject({ $source: z21.literal("views_total"), days: z21.number().int(), value: Count2, posts: Count2 }),
2193
- z21.strictObject({ $source: z21.literal("spend_total"), days: z21.number().int(), value: Count2 })
2058
+ value: z18.discriminatedUnion("$source", [
2059
+ z18.strictObject({ $source: z18.literal("views_total"), days: z18.number().int(), value: Count2, posts: Count2 }),
2060
+ z18.strictObject({ $source: z18.literal("spend_total"), days: z18.number().int(), value: Count2 })
2194
2061
  ]),
2195
- delta: z21.strictObject({ $source: z21.literal("views_change"), days: z21.number().int(), current: Count2, previous: Count2 }),
2196
- series: z21.strictObject({ $source: z21.literal("spend_by_day"), days: z21.number().int(), points: z21.array(SpendDay).min(2).max(30) }),
2197
- bars: z21.strictObject({ $source: z21.literal("post_views"), limit: z21.number().int(), posts: PostViewsViewSchema.shape.posts }),
2198
- progress: z21.strictObject({ $source: z21.literal("posts_this_week"), value: Count2, max: z21.number().int().positive(), cadence: z21.string() }),
2199
- board: z21.strictObject({ $source: z21.literal("roadmap"), groups: RoadmapViewSchema.shape.groups }),
2200
- week: z21.strictObject({ $source: z21.literal("schedule"), days: ScheduleViewSchema.shape.days }),
2201
- media: z21.array(z21.strictObject({ id: idOf("fil"), kind: z21.enum(["image", "video"]) })).min(1).max(4)
2062
+ delta: z18.strictObject({ $source: z18.literal("views_change"), days: z18.number().int(), current: Count2, previous: Count2 }),
2063
+ series: z18.strictObject({ $source: z18.literal("spend_by_day"), days: z18.number().int(), points: z18.array(SpendDay).min(2).max(30) }),
2064
+ bars: z18.strictObject({ $source: z18.literal("post_views"), limit: z18.number().int(), posts: PostViewsViewSchema.shape.posts }),
2065
+ progress: z18.strictObject({ $source: z18.literal("posts_this_week"), value: Count2, max: z18.number().int().positive(), cadence: z18.string() }),
2066
+ board: z18.strictObject({ $source: z18.literal("roadmap"), groups: RoadmapViewSchema.shape.groups }),
2067
+ week: z18.strictObject({ $source: z18.literal("schedule"), days: ScheduleViewSchema.shape.days }),
2068
+ media: z18.array(z18.strictObject({ id: idOf("fil"), kind: z18.enum(["image", "video"]) })).min(1).max(4)
2202
2069
  };
2203
- var box = { children: z21.array(Key).min(1).max(12) };
2204
- var leaf = { children: z21.array(Key).max(0).optional() };
2070
+ var box = { children: z18.array(Key).min(1).max(12) };
2071
+ var leaf = { children: z18.array(Key).max(0).optional() };
2205
2072
  var label = words(40).optional();
2206
- var element = (type, props, children, about) => z21.strictObject({ type: z21.literal(type), props: z21.strictObject(props), ...children }).describe(about);
2073
+ var element = (type, props, children, about) => z18.strictObject({ type: z18.literal(type), props: z18.strictObject(props), ...children }).describe(about);
2207
2074
  function catalog(slot) {
2208
2075
  return {
2209
2076
  Card: element("Card", { title: words(60) }, box, "The card, with a short title. It is the root, and only the root."),
2210
2077
  Stack: element("Stack", {}, box, "Children one under another."),
2211
- Grid: element("Grid", { columns: z21.literal([1, 2, 3]) }, box, "Children side by side, 1 to 3 columns."),
2078
+ Grid: element("Grid", { columns: z18.literal([1, 2, 3]) }, box, "Children side by side, 1 to 3 columns."),
2212
2079
  Metric: element("Metric", { label: words(40), value: slot.value, delta: slot.delta.optional() }, leaf, "One big number with a label, and optionally its change."),
2213
2080
  LineChart: element("LineChart", { label, series: slot.series }, leaf, "A line over days."),
2214
2081
  BarList: element("BarList", { label, bars: slot.bars }, leaf, "One bar per post."),
@@ -2244,14 +2111,374 @@ function tree(rootType, max, spec2, ctx) {
2244
2111
  const lost = keys.find((key) => !reached.has(key));
2245
2112
  if (lost) refuse2(`"${lost}" is not under the root`, ["elements", lost]);
2246
2113
  }
2247
- var spec = (element2, rootType, max) => z21.strictObject({ root: Key, elements: z21.record(Key, element2) }).superRefine((value, ctx) => tree(rootType, max, value, ctx));
2114
+ var spec = (element2, rootType, max) => z18.strictObject({ root: Key, elements: z18.record(Key, element2) }).superRefine((value, ctx) => tree(rootType, max, value, ctx));
2115
+
2116
+ // ../core/src/schema/mini-app.ts
2117
+ var PAGE_BLOCKS = [
2118
+ "Page",
2119
+ "Section",
2120
+ "Stack",
2121
+ "Grid",
2122
+ "Metric",
2123
+ "LineChart",
2124
+ "BarList",
2125
+ "Progress",
2126
+ "Roadmap",
2127
+ "Schedule",
2128
+ "Media",
2129
+ "Text",
2130
+ "Needs",
2131
+ "Activity",
2132
+ "Accounts",
2133
+ "Posts",
2134
+ "Answers",
2135
+ "MediaLibrary"
2136
+ ];
2137
+ var MAX_PAGE_ELEMENTS = 48;
2138
+ var MINI_APP_ICONS = ["grid", "list", "chart", "calendar", "play"];
2139
+ var MiniAppIconSchema = z19.enum(MINI_APP_ICONS);
2140
+ var SLUG = "[a-z][a-z0-9-]{0,39}";
2141
+ var MiniAppSlugSchema = z19.string().regex(new RegExp(`^${SLUG}$`), "a slug is lowercase letters, digits and -");
2142
+ var Place = z19.string().regex(new RegExp(`^/(board|connections|apps/${SLUG}(\\?page=${SLUG})?)$`), "a section links to /board, /connections or /apps/<slug>[?page=<slug>]");
2143
+ var POSTS = ["waiting", "scheduled", "posted"];
2144
+ var PostStatus = z19.enum(POSTS);
2145
+ var PostLayout = z19.enum(["list", "row", "grid"]);
2146
+ var PostStatuses = z19.union([PostStatus, z19.array(PostStatus).min(1).max(3).refine((all) => new Set(all).size === all.length, "each status once")]);
2147
+ var PageBound = {
2148
+ ...Bound,
2149
+ board: bound(["roadmap"], { per_group: z19.number().int().min(1).max(5).default(5) }),
2150
+ media: bound(["latest_media", "newest_media"], { count: z19.number().int().min(1).max(6).default(4) })
2151
+ };
2152
+ var PageResolved = {
2153
+ ...Resolved,
2154
+ board: z19.strictObject({ $source: z19.literal("roadmap"), per_group: z19.number().int(), groups: RoadmapViewSchema.shape.groups }),
2155
+ media: z19.array(z19.strictObject({ id: z19.string(), kind: z19.enum(["image", "video"]) })).max(6)
2156
+ };
2157
+ function pageBlocks(slot) {
2158
+ return {
2159
+ Page: element("Page", {}, box, "The page itself, the root and only the root."),
2160
+ Section: element("Section", { title: words(40), to: Place.optional(), hide_empty: z19.boolean().optional() }, box, "A titled part of the page; hidden when every block in it is empty, if asked."),
2161
+ Needs: element("Needs", { label, needs: slot.needs }, leaf, "What waits on a person: approvals, questions, spent caps."),
2162
+ Activity: element("Activity", { label, agents: slot.agents }, leaf, "The agents working or waiting, and on what."),
2163
+ Accounts: element("Accounts", { accounts: slot.accounts }, leaf, "The template's networks: connected with a handle, or not."),
2164
+ Posts: element(
2165
+ "Posts",
2166
+ { label, layout: PostLayout.optional(), posts: slot.posts },
2167
+ leaf,
2168
+ "Posts waiting on a person, scheduled, or posted; several statuses make one list. Drawn as rows (list, the default), one sideways row of cards (row), or a picture grid (grid)."
2169
+ ),
2170
+ Answers: element("Answers", { answers: slot.answers }, leaf, "The setup's answers in one line, linking to the setup."),
2171
+ // No binding: the studio's gallery reads and pages the company's files itself (ADR-0987).
2172
+ MediaLibrary: element("MediaLibrary", {}, leaf, "Every picture and clip the company's agents made, with filters, sort and a viewer.")
2173
+ };
2174
+ }
2175
+ var OwnBound = pageBlocks({
2176
+ needs: bound(["needs"], {}),
2177
+ agents: bound(["agents_activity"], {}),
2178
+ accounts: bound(["accounts"], {}),
2179
+ posts: bound(["posts"], { status: PostStatuses, limit: z19.number().int().min(1).max(50).default(10) }),
2180
+ answers: bound(["answers"], { keys: z19.array(Key).min(1).max(TEMPLATE_QUESTIONS_MAX) })
2181
+ });
2182
+ var Need = z19.object({
2183
+ session_id: z19.string(),
2184
+ agent_id: z19.string(),
2185
+ agent: z19.string(),
2186
+ since: Timestamp,
2187
+ /** The chat's stored title, or `null`: the studio names it by when it began. */
2188
+ title: z19.string().nullable(),
2189
+ kind: z19.enum(["tool", "question", "budget"]),
2190
+ /** The call or question it is held on; `null` for a spent cap. */
2191
+ action: PendingActionSchema.nullable()
2192
+ });
2193
+ var Working = z19.object({
2194
+ agent_id: z19.string(),
2195
+ agent: z19.string(),
2196
+ state: z19.enum(["working", "waiting"]),
2197
+ session_id: z19.string().nullable(),
2198
+ title: z19.string().nullable(),
2199
+ at: Timestamp
2200
+ });
2201
+ var OwnResolved = pageBlocks({
2202
+ needs: z19.strictObject({ $source: z19.literal("needs"), items: z19.array(Need) }),
2203
+ agents: z19.strictObject({ $source: z19.literal("agents_activity"), agents: z19.array(Working) }),
2204
+ accounts: z19.strictObject({
2205
+ $source: z19.literal("accounts"),
2206
+ accounts: z19.array(z19.object({ platform: SocialPlatformSchema, connected: z19.boolean(), handle: z19.string().nullable() }))
2207
+ }),
2208
+ posts: z19.strictObject({ $source: z19.literal("posts"), status: z19.union([PostStatus, z19.array(PostStatus)]), limit: z19.number().int(), posts: z19.array(PostSchema), more: z19.boolean() }),
2209
+ answers: z19.strictObject({
2210
+ $source: z19.literal("answers"),
2211
+ keys: z19.array(z19.string()),
2212
+ values: z19.array(z19.string()),
2213
+ template: z19.object({ blueprint: z19.string(), template: z19.string() }).nullable()
2214
+ })
2215
+ });
2216
+ var BoundBlocks = { ...catalog(PageBound), ...OwnBound };
2217
+ var ResolvedBlocks = { ...catalog(PageResolved), ...OwnResolved };
2218
+ var Unread = element("Unread", { of: z19.string(), label: z19.string().nullable(), reason: z19.string() }, leaf, "A block that could not be read.");
2219
+ var B = BoundBlocks;
2220
+ var PageSpecSchema = spec(
2221
+ z19.discriminatedUnion(
2222
+ "type",
2223
+ [B.Page, B.Section, B.Stack, B.Grid, B.Metric, B.LineChart, B.BarList, B.Progress, B.Roadmap, B.Schedule, B.Media, B.Text, B.Needs, B.Activity, B.Accounts, B.Posts, B.Answers, B.MediaLibrary],
2224
+ unknownComponent(PAGE_BLOCKS)
2225
+ ),
2226
+ "Page",
2227
+ MAX_PAGE_ELEMENTS
2228
+ );
2229
+ var R = ResolvedBlocks;
2230
+ var ResolvedPageElementSchema = z19.discriminatedUnion(
2231
+ "type",
2232
+ [R.Page, R.Section, R.Stack, R.Grid, R.Metric, R.LineChart, R.BarList, R.Progress, R.Roadmap, R.Schedule, R.Media, R.Text, R.Needs, R.Activity, R.Accounts, R.Posts, R.Answers, R.MediaLibrary, Unread],
2233
+ unknownComponent(PAGE_BLOCKS)
2234
+ );
2235
+ var ResolvedPageSpecSchema = spec(ResolvedPageElementSchema, "Page", MAX_PAGE_ELEMENTS);
2236
+ var unique = (items) => new Set(items.map((item) => item.slug)).size === items.length;
2237
+ var MiniAppPageSchema = z19.strictObject({ slug: MiniAppSlugSchema, title: words(24), spec: PageSpecSchema });
2238
+ var MiniAppDeclSchema = z19.strictObject({
2239
+ slug: MiniAppSlugSchema,
2240
+ name: words(40),
2241
+ icon: MiniAppIconSchema,
2242
+ pages: z19.array(MiniAppPageSchema).min(1).max(6).refine(unique, "each page's slug is its own")
2243
+ });
2244
+ var MiniAppDeclsSchema = z19.array(MiniAppDeclSchema).max(8).refine(unique, "each mini app's slug is its own");
2245
+ var MiniAppSummarySchema = z19.object({
2246
+ object: z19.literal("mini_app"),
2247
+ slug: MiniAppSlugSchema,
2248
+ name: z19.string(),
2249
+ icon: MiniAppIconSchema,
2250
+ pages: z19.array(z19.object({ slug: MiniAppSlugSchema, title: z19.string() })).min(1),
2251
+ /** What it reads (`miniAppReads`). Absent from an older API: the Studio then claims nothing it cannot see. */
2252
+ reads: z19.array(z19.string()).optional()
2253
+ });
2254
+ var MiniAppSchema = MiniAppSummarySchema.extend({
2255
+ networks: z19.array(z19.object({ platform: SocialPlatformSchema, connected: z19.boolean().nullable() })),
2256
+ page: MiniAppSlugSchema,
2257
+ as_of: Timestamp,
2258
+ timezone: z19.string().min(1),
2259
+ spec: ResolvedPageSpecSchema
2260
+ });
2261
+
2262
+ // ../core/src/schema/blueprint.ts
2263
+ var BlueprintScheduleSchema = z20.object({
2264
+ agent: z20.string().min(1),
2265
+ cron: z20.string().min(1),
2266
+ timezone: z20.string().nullable(),
2267
+ /** The message each fire opens its session with — the sentence worth printing. */
2268
+ input: z20.string().min(1),
2269
+ /** What a fire does in a few words, as the template says it (ADR-1172); absent on a row that declares none. */
2270
+ summary: z20.string().min(1).optional(),
2271
+ budget_micro_usd: MicroUsdField.nonnegative()
2272
+ });
2273
+ var BlueprintBudgetSchema = BlueprintScheduleSchema.pick({ agent: true, cron: true, budget_micro_usd: true });
2274
+ var BlueprintCrewSchema = z20.object({
2275
+ name: z20.string().min(1),
2276
+ description: z20.string().nullable(),
2277
+ model: z20.string().min(1),
2278
+ briefed: z20.boolean(),
2279
+ intake: z20.string().nullable().optional(),
2280
+ /** What the first session may spend: the intake's own cap, else the agent's (§31.4). Set iff `briefed`. */
2281
+ intake_micro_usd: MicroUsdField.nonnegative().optional(),
2282
+ role: z20.string().min(1).optional(),
2283
+ skills: z20.array(SkillRefSchema).optional(),
2284
+ tools: z20.array(z20.string().min(1)).optional(),
2285
+ required: z20.boolean().optional()
2286
+ });
2287
+ var BlueprintAppSchema = z20.object({
2288
+ name: z20.string().min(1),
2289
+ type: AppTypeSchema,
2290
+ description: z20.string().nullable(),
2291
+ mcp: z20.string().nullable().optional(),
2292
+ tools: z20.array(z20.string().min(1)).optional(),
2293
+ /** Whether an install may deselect it (§31.2). Optional: the rollout argument above. */
2294
+ required: z20.boolean().optional()
2295
+ });
2296
+ var BlueprintIdentitySchema = z20.object({
2297
+ name: z20.string().min(1),
2298
+ description: z20.string().nullable()
2299
+ });
2300
+ var ContentHashSchema = z20.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
2301
+ var BlueprintTaskSchema = z20.object({ title: z20.string().min(1), assignee: z20.string().min(1).nullable() });
2302
+ var BlueprintMiniAppSchema = z20.object({ slug: MiniAppSlugSchema, name: z20.string().min(1), icon: MiniAppIconSchema });
2303
+ var BlueprintTreeSchema = z20.object({
2304
+ /** `apps[].name` in the declaration — the same name §31.5 prints and the install ensures by. */
2305
+ app: z20.string().min(1),
2306
+ content_hash: ContentHashSchema
2307
+ });
2308
+ var BlueprintArtifactSchema = z20.object({
2309
+ id: idOf("bpa"),
2310
+ object: z20.literal("blueprint_artifact"),
2311
+ /** The machine — its repository, screens and `/api/*`. */
2312
+ blueprint: z20.string().min(1),
2313
+ /** Which of that blueprint's templates provides the crew. */
2314
+ template: z20.string().min(1),
2315
+ /** The blueprint repository's own released version. Stored, never parsed (ADR-0401). */
2316
+ version: z20.string().min(1),
2317
+ /**
2318
+ * What a person calls the template, one line on what its crew does, and the networks it publishes
2319
+ * to — printed, never provisioned (§31.5, ADR-0921). `platforms` is decoration: where the crew
2320
+ * posts is the accounts connected to its persona. Optional for the §31.5 rollout reason.
2321
+ */
2322
+ title: z20.string().min(1).optional(),
2323
+ description: z20.string().min(1).optional(),
2324
+ platforms: z20.array(SocialPlatformSchema).optional(),
2325
+ /**
2326
+ * The built trees, one per deployable app, ordered as the declaration orders its apps. Empty for
2327
+ * a data-only blueprint: it declares no app, builds nothing, and still ships a crew (ADR-0900).
2328
+ */
2329
+ trees: z20.array(BlueprintTreeSchema),
2330
+ /**
2331
+ * The setup questions, asked by the studio **before** provisioning. `QuestionField` (§7.1) is
2332
+ * reused rather than restated: a setup question and a question a parked agent asks are the same
2333
+ * object at different times, so one component renders both.
2334
+ */
2335
+ questions: z20.array(QuestionFieldSchema),
2336
+ schedules: z20.array(BlueprintScheduleSchema),
2337
+ /** Who the crew is, and what it deploys — §31.5. Derived from `declaration`, never stored twice. */
2338
+ agents: z20.array(BlueprintCrewSchema),
2339
+ apps: z20.array(BlueprintAppSchema),
2340
+ /**
2341
+ * The agents a template creates per client the operator signs — printed, never provisioned by an
2342
+ * apply (§31.1). Absent on rows published before WS12 v2, hence optional.
2343
+ */
2344
+ crew_per_client: z20.array(BlueprintCrewSchema).optional(),
2345
+ /**
2346
+ * The personas the crew posts from, and which accounts to connect to each before the crew
2347
+ * exists (§31.10). Derived from `declaration` like `agents`; optional for the §31.5 rollout reason.
2348
+ */
2349
+ identities: z20.array(BlueprintIdentitySchema).optional(),
2350
+ /**
2351
+ * The crew's first work: the cards an apply seeds on the board (§31.11), as a title and who has
2352
+ * it, in the declared order. Derived from `declaration` like `agents`, so a person reads day one
2353
+ * before paying for it (the launch roadmap, ADR-1170); optional for the §31.5 rollout reason.
2354
+ */
2355
+ tasks: z20.array(BlueprintTaskSchema).optional(),
2356
+ /**
2357
+ * The mini apps the template brings (§50.1): no tree, no deploy, so they are not in `apps`, and a
2358
+ * person is shown them beside the hosted ones before paying (ADR-1171). Derived from
2359
+ * `declaration.mini_apps` like `tasks`; optional for the §31.5 rollout reason.
2360
+ */
2361
+ mini_apps: z20.array(BlueprintMiniAppSchema).optional(),
2362
+ /** The first week in the template's own words (ADR-1172): Day 1, what each day after it carries, and what follows the week. */
2363
+ roadmap: z20.object({ day_one: z20.string().min(1).optional(), every_day: z20.string().min(1).optional(), after: z20.string().min(1).optional() }).optional(),
2364
+ /**
2365
+ * The creator template a row was published from (§42.8), `null` on every first-party row.
2366
+ * `creator_name` is the public display name the landing page credits. The API sends all three
2367
+ * on every row; they are optional here only so an artifact typed before §42 still reads.
2368
+ */
2369
+ creator_template_id: idOf("ctp").nullish(),
2370
+ creator_template_version: z20.number().int().positive().nullish(),
2371
+ creator_name: z20.string().min(1).nullish(),
2372
+ /**
2373
+ * The listing a reviewer curated for a creator row (§42.8): its one-line pitch, and a public
2374
+ * sample video with its poster frame. Optional and nullish — a first-party row and a row whose
2375
+ * listing names no hero carry none, and the landing page prints only what is present.
2376
+ */
2377
+ creator_tagline: z20.string().min(1).nullish(),
2378
+ creator_hero_url: z20.string().url().nullish(),
2379
+ creator_hero_poster_url: z20.string().url().nullish(),
2380
+ published_at: Timestamp
2381
+ });
2382
+
2383
+ // ../core/src/schema/vault.ts
2384
+ import { z as z21 } from "zod";
2385
+ var VaultCredentialKindSchema = z21.enum(["env_var", "static_bearer", "mcp_oauth"]);
2386
+ var VaultSchema = z21.object({
2387
+ id: idOf("vlt"),
2388
+ object: z21.literal("vault"),
2389
+ identity_id: idOf("idn").nullable(),
2390
+ display_name: z21.string().min(1).max(128),
2391
+ credential_count: z21.number().int().nonnegative(),
2392
+ created_at: Timestamp
2393
+ });
2394
+ var VaultCredentialSchema = z21.object({
2395
+ id: idOf("vcr"),
2396
+ object: z21.literal("vault_credential"),
2397
+ vault_id: idOf("vlt"),
2398
+ kind: VaultCredentialKindSchema,
2399
+ /** For `env_var`, the environment variable name. For the MCP kinds, a display label. */
2400
+ key: z21.string().min(1).max(128),
2401
+ /** The exact destination host an `env_var` credential is bound to. Never a wildcard. */
2402
+ host: z21.string().nullable(),
2403
+ /** The exact MCP server URL an `mcp_*` token is matched to. */
2404
+ mcp_server_url: z21.url().nullable(),
2405
+ /**
2406
+ * The one agent this credential may be injected into (ADR-1097). `null` is any agent that
2407
+ * declares `mcp_server_url` — except the platform's own `/v1/mcp`, whose key is never injected
2408
+ * unbound. Set at create, by `admin`, and immutable like the rest. Defaults to `null` so a
2409
+ * client reading a control plane older than the field still parses the row.
2410
+ */
2411
+ agent_id: idOf("agt").nullable().default(null),
2412
+ placeholder_ref: z21.string(),
2413
+ expires_at: Timestamp.nullable(),
2414
+ last_injected_at: Timestamp.nullable(),
2415
+ created_at: Timestamp
2416
+ });
2417
+
2418
+ // ../core/src/schema/handoff.ts
2419
+ import { z as z22 } from "zod";
2420
+ var MAX_HANDOFF_TARGETS = 6;
2421
+ var HandoffRequestSchema = z22.object({
2422
+ agent: z22.string().min(1),
2423
+ message: z22.string().min(1),
2424
+ handoff_key: z22.string().min(1).max(128).optional(),
2425
+ budget_micro_usd: z22.number().int().positive().optional()
2426
+ });
2427
+ var HandoffSchema = z22.object({
2428
+ object: z22.literal("handoff"),
2429
+ session_id: idOf("ses"),
2430
+ status: z22.enum(["queued", "already_running"]),
2431
+ handoff_key: z22.string().nullable()
2432
+ });
2433
+ var SessionHandoffRequestSchema = z22.object({
2434
+ agents: z22.array(z22.string().min(1)).min(1).max(MAX_HANDOFF_TARGETS),
2435
+ message: z22.string().min(1),
2436
+ handoff_key: z22.string().min(1).max(128).optional(),
2437
+ budget_micro_usd: z22.number().int().positive().optional()
2438
+ });
2439
+ var HandoffRefusalSchema = z22.object({
2440
+ object: z22.literal("handoff_refusal"),
2441
+ agent: z22.string(),
2442
+ code: z22.string(),
2443
+ message: z22.string()
2444
+ });
2445
+ var HandoffBatchSchema = z22.object({
2446
+ object: z22.literal("handoff_batch"),
2447
+ handoffs: z22.array(HandoffSchema.extend({ agent_id: idOf("agt") })),
2448
+ refusals: z22.array(HandoffRefusalSchema)
2449
+ });
2450
+ var SessionHandoffSchema = z22.object({
2451
+ from_session: idOf("ses"),
2452
+ from_agent: idOf("agt"),
2453
+ key: z22.string().nullable(),
2454
+ depth: z22.number().int().positive()
2455
+ });
2456
+ var ChannelBriefSchema = z22.object({
2457
+ root_session_id: idOf("ses"),
2458
+ name: z22.string().min(1),
2459
+ members: z22.array(z22.string().min(1)),
2460
+ /**
2461
+ * The receiver's own name, so it can tell the part of a post addressed to it from a teammate's
2462
+ * (ADR-1099). Optional: a brief pinned before it existed still parses.
2463
+ */
2464
+ you: z22.string().min(1).optional()
2465
+ });
2466
+ var ChannelPostRequestSchema = z22.object({
2467
+ message: z22.string().min(1).max(2e4)
2468
+ });
2469
+ var ChannelPostSchema = z22.object({
2470
+ object: z22.literal("channel_post"),
2471
+ root_session_id: idOf("ses"),
2472
+ queued: z22.boolean()
2473
+ });
2248
2474
 
2249
2475
  // ../core/src/schema/compose.ts
2476
+ import { z as z23 } from "zod";
2250
2477
  var COMPOSE_COMPONENTS = ["Card", "Stack", "Grid", "Metric", "LineChart", "BarList", "Progress", "Roadmap", "Schedule", "Media", "Text"];
2251
2478
  var MAX_COMPOSE_ELEMENTS = 24;
2252
2479
  var BoundComponents = catalog(Bound);
2253
2480
  var ComposeSpecSchema = spec(
2254
- z22.discriminatedUnion(
2481
+ z23.discriminatedUnion(
2255
2482
  "type",
2256
2483
  [
2257
2484
  BoundComponents.Card,
@@ -2271,14 +2498,14 @@ var ComposeSpecSchema = spec(
2271
2498
  "Card",
2272
2499
  MAX_COMPOSE_ELEMENTS
2273
2500
  );
2274
- var ComposeArgsSchema = z22.object({
2501
+ var ComposeArgsSchema = z23.object({
2275
2502
  spec: ComposeSpecSchema.describe(
2276
2503
  'A json-render spec: { "root": key, "elements": { key: { "type", "props", "children"? } } }. The root is one Card.'
2277
2504
  )
2278
2505
  });
2279
2506
  var ComposedComponents = catalog(Resolved);
2280
2507
  var ComposedSpecSchema = spec(
2281
- z22.discriminatedUnion(
2508
+ z23.discriminatedUnion(
2282
2509
  "type",
2283
2510
  [
2284
2511
  ComposedComponents.Card,
@@ -2298,39 +2525,39 @@ var ComposedSpecSchema = spec(
2298
2525
  "Card",
2299
2526
  MAX_COMPOSE_ELEMENTS
2300
2527
  );
2301
- var ComposedSchema = z22.object({ as_of: Timestamp, timezone: z22.string().min(1), spec: ComposedSpecSchema });
2528
+ var ComposedSchema = z23.object({ as_of: Timestamp, timezone: z23.string().min(1), spec: ComposedSpecSchema });
2302
2529
 
2303
2530
  // ../core/src/schema/media.ts
2304
- import { z as z23 } from "zod";
2531
+ import { z as z24 } from "zod";
2305
2532
  var MEDIA_JOB_KINDS = ["video", "clip", "transcription"];
2306
- var MediaJobKindSchema = z23.enum(MEDIA_JOB_KINDS);
2307
- var MediaJobStatusSchema = z23.enum(["queued", "processing", "completed", "failed"]);
2308
- var PublicUrl = z23.string().url().startsWith("http");
2309
- var Score = z23.number().int().min(0).max(100);
2310
- var Seconds = z23.number().nonnegative();
2311
- var VideoResultSchema = z23.object({
2312
- files: z23.array(
2313
- z23.object({
2533
+ var MediaJobKindSchema = z24.enum(MEDIA_JOB_KINDS);
2534
+ var MediaJobStatusSchema = z24.enum(["queued", "processing", "completed", "failed"]);
2535
+ var PublicUrl = z24.string().url().startsWith("http");
2536
+ var Score = z24.number().int().min(0).max(100);
2537
+ var Seconds = z24.number().nonnegative();
2538
+ var VideoResultSchema = z24.object({
2539
+ files: z24.array(
2540
+ z24.object({
2314
2541
  file_id: idOf("fil"),
2315
- content_type: z23.string(),
2316
- width: z23.number().int().positive().nullable(),
2317
- height: z23.number().int().positive().nullable(),
2542
+ content_type: z24.string(),
2543
+ width: z24.number().int().positive().nullable(),
2544
+ height: z24.number().int().positive().nullable(),
2318
2545
  duration_seconds: Seconds.nullable()
2319
2546
  })
2320
2547
  )
2321
2548
  });
2322
- var ViralityScoreSchema = z23.object({
2549
+ var ViralityScoreSchema = z24.object({
2323
2550
  total: Score,
2324
2551
  shareability: Score,
2325
2552
  hook_strength: Score,
2326
2553
  story_quality: Score,
2327
2554
  emotional_impact: Score
2328
2555
  });
2329
- var ClipResultSchema = z23.object({
2330
- clips: z23.array(
2331
- z23.object({
2556
+ var ClipResultSchema = z24.object({
2557
+ clips: z24.array(
2558
+ z24.object({
2332
2559
  file_id: idOf("fil"),
2333
- title: z23.string(),
2560
+ title: z24.string(),
2334
2561
  start_seconds: Seconds,
2335
2562
  end_seconds: Seconds,
2336
2563
  duration_seconds: Seconds,
@@ -2338,192 +2565,192 @@ var ClipResultSchema = z23.object({
2338
2565
  })
2339
2566
  )
2340
2567
  });
2341
- var TranscriptSchema = z23.object({
2342
- text: z23.string(),
2343
- language: z23.string().nullable(),
2568
+ var TranscriptSchema = z24.object({
2569
+ text: z24.string(),
2570
+ language: z24.string().nullable(),
2344
2571
  duration_seconds: Seconds.nullable(),
2345
- segments: z23.array(z23.object({ start_seconds: Seconds, end_seconds: Seconds, text: z23.string() }))
2572
+ segments: z24.array(z24.object({ start_seconds: Seconds, end_seconds: Seconds, text: z24.string() }))
2346
2573
  });
2347
- var MediaJobResultSchema = z23.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
2348
- var MediaJobSchema = z23.object({
2574
+ var MediaJobResultSchema = z24.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
2575
+ var MediaJobSchema = z24.object({
2349
2576
  id: idOf("med"),
2350
- object: z23.literal("media_job"),
2577
+ object: z24.literal("media_job"),
2351
2578
  kind: MediaJobKindSchema,
2352
2579
  status: MediaJobStatusSchema,
2353
- model: z23.string().nullable(),
2354
- input: z23.record(z23.string(), z23.unknown()),
2580
+ model: z24.string().nullable(),
2581
+ input: z24.record(z24.string(), z24.unknown()),
2355
2582
  result: MediaJobResultSchema.nullable(),
2356
- error: z23.object({ code: z23.string(), message: z23.string() }).nullable(),
2583
+ error: z24.object({ code: z24.string(), message: z24.string() }).nullable(),
2357
2584
  cost_micro_usd: MicroUsdField.nullable(),
2358
2585
  session_id: idOf("ses").nullable(),
2359
2586
  created_at: Timestamp,
2360
2587
  completed_at: Timestamp.nullable()
2361
2588
  });
2362
- var ImageRequestSchema = z23.object({
2363
- model: z23.string().min(1).optional(),
2364
- prompt: z23.string().min(1),
2365
- image_urls: z23.array(PublicUrl).max(4).optional(),
2366
- aspect_ratio: z23.string().optional(),
2367
- seed: z23.number().int().optional(),
2368
- n: z23.number().int().min(1).max(4).default(1)
2589
+ var ImageRequestSchema = z24.object({
2590
+ model: z24.string().min(1).optional(),
2591
+ prompt: z24.string().min(1),
2592
+ image_urls: z24.array(PublicUrl).max(4).optional(),
2593
+ aspect_ratio: z24.string().optional(),
2594
+ seed: z24.number().int().optional(),
2595
+ n: z24.number().int().min(1).max(4).default(1)
2369
2596
  });
2370
- var VideoRequestSchema = z23.object({
2597
+ var VideoRequestSchema = z24.object({
2371
2598
  /** Omitted: the platform's video default while the catalogue publishes it (`resolveModel`, §33.2). */
2372
- model: z23.string().min(1).optional(),
2373
- prompt: z23.string().min(1),
2374
- image_urls: z23.array(PublicUrl).max(1).optional(),
2599
+ model: z24.string().min(1).optional(),
2600
+ prompt: z24.string().min(1),
2601
+ image_urls: z24.array(PublicUrl).max(1).optional(),
2375
2602
  /** The source clip of a video-to-video edit (ADR-0814). */
2376
2603
  video_url: PublicUrl.optional(),
2377
- aspect_ratio: z23.string().optional(),
2378
- seed: z23.number().int().optional(),
2379
- seconds: z23.number().int().min(1).max(60).optional()
2380
- });
2381
- var ImageGenerationSchema = z23.object({
2382
- object: z23.literal("image_generation"),
2383
- model: z23.string(),
2384
- files: z23.array(FileSchema),
2604
+ aspect_ratio: z24.string().optional(),
2605
+ seed: z24.number().int().optional(),
2606
+ seconds: z24.number().int().min(1).max(60).optional()
2607
+ });
2608
+ var ImageGenerationSchema = z24.object({
2609
+ object: z24.literal("image_generation"),
2610
+ model: z24.string(),
2611
+ files: z24.array(FileSchema),
2385
2612
  cost_micro_usd: MicroUsdField
2386
2613
  });
2387
- var ClipLength = z23.number().int().min(5).max(180);
2388
- var ClipRequestSchema = z23.object({
2614
+ var ClipLength = z24.number().int().min(5).max(180);
2615
+ var ClipRequestSchema = z24.object({
2389
2616
  video_url: PublicUrl,
2390
- aspect_ratio: z23.enum(["9:16", "16:9"]).default("9:16"),
2391
- remove_silence: z23.boolean().default(false),
2392
- caption_preset: z23.enum(["none", "clean", "bold", "karaoke"]).default("none"),
2393
- language: z23.string().min(2).optional(),
2617
+ aspect_ratio: z24.enum(["9:16", "16:9"]).default("9:16"),
2618
+ remove_silence: z24.boolean().default(false),
2619
+ caption_preset: z24.enum(["none", "clean", "bold", "karaoke"]).default("none"),
2620
+ language: z24.string().min(2).optional(),
2394
2621
  min_seconds: ClipLength.default(15),
2395
2622
  max_seconds: ClipLength.default(60),
2396
- title: z23.string().min(1).optional()
2623
+ title: z24.string().min(1).optional()
2397
2624
  });
2398
- var AudioFormatSchema = z23.enum(["mp3", "wav", "ogg"]);
2399
- var TranscriptionRequestSchema = z23.object({
2400
- model: z23.string().min(1).optional(),
2625
+ var AudioFormatSchema = z24.enum(["mp3", "wav", "ogg"]);
2626
+ var TranscriptionRequestSchema = z24.object({
2627
+ model: z24.string().min(1).optional(),
2401
2628
  file_id: idOf("fil").optional(),
2402
2629
  url: PublicUrl.optional(),
2403
- language: z23.string().min(2).optional(),
2404
- timestamps: z23.boolean().default(true)
2630
+ language: z24.string().min(2).optional(),
2631
+ timestamps: z24.boolean().default(true)
2405
2632
  }).refine((request) => request.file_id === void 0 !== (request.url === void 0), {
2406
2633
  error: "exactly one of file_id or url",
2407
2634
  path: ["file_id"]
2408
2635
  });
2409
- var SpeechRequestSchema = z23.object({
2410
- model: z23.string().min(1).optional(),
2411
- text: z23.string().min(1).max(4096),
2412
- voice: z23.string().min(1).optional(),
2636
+ var SpeechRequestSchema = z24.object({
2637
+ model: z24.string().min(1).optional(),
2638
+ text: z24.string().min(1).max(4096),
2639
+ voice: z24.string().min(1).optional(),
2413
2640
  format: AudioFormatSchema.default("mp3"),
2414
- speed: z23.number().min(0.5).max(2).optional()
2641
+ speed: z24.number().min(0.5).max(2).optional()
2415
2642
  });
2416
- var SpeechToSpeechRequestSchema = z23.object({
2417
- model: z23.string().min(1).optional(),
2643
+ var SpeechToSpeechRequestSchema = z24.object({
2644
+ model: z24.string().min(1).optional(),
2418
2645
  file_id: idOf("fil"),
2419
- voice: z23.string().min(1).optional(),
2646
+ voice: z24.string().min(1).optional(),
2420
2647
  format: AudioFormatSchema.default("mp3")
2421
2648
  });
2422
- var SpeechGenerationSchema = z23.object({
2423
- object: z23.literal("speech_generation"),
2424
- model: z23.string(),
2649
+ var SpeechGenerationSchema = z24.object({
2650
+ object: z24.literal("speech_generation"),
2651
+ model: z24.string(),
2425
2652
  file: FileSchema,
2426
2653
  duration_seconds: Seconds.nullable(),
2427
2654
  cost_micro_usd: MicroUsdField
2428
2655
  });
2429
2656
 
2430
2657
  // ../core/src/schema/app-data.ts
2431
- import { z as z24 } from "zod";
2432
- var DbTableSchema = z24.object({
2433
- object: z24.literal("db_table"),
2434
- name: z24.string(),
2435
- schema: z24.string().default("public"),
2436
- rows: z24.number().int().nonnegative().nullable(),
2437
- size_bytes: z24.number().int().nonnegative().nullable()
2438
- });
2439
- var DbMigrationSchema = z24.object({
2658
+ import { z as z25 } from "zod";
2659
+ var DbTableSchema = z25.object({
2660
+ object: z25.literal("db_table"),
2661
+ name: z25.string(),
2662
+ schema: z25.string().default("public"),
2663
+ rows: z25.number().int().nonnegative().nullable(),
2664
+ size_bytes: z25.number().int().nonnegative().nullable()
2665
+ });
2666
+ var DbMigrationSchema = z25.object({
2440
2667
  id: idOf("dbm"),
2441
- object: z24.literal("db_migration"),
2442
- name: z24.string(),
2443
- sha256: z24.string().regex(/^[0-9a-f]{64}$/),
2668
+ object: z25.literal("db_migration"),
2669
+ name: z25.string(),
2670
+ sha256: z25.string().regex(/^[0-9a-f]{64}$/),
2444
2671
  applied_at: Timestamp,
2445
- statements: z24.number().int().nonnegative()
2672
+ statements: z25.number().int().nonnegative()
2446
2673
  });
2447
- var ApplyDbMigrationSchema = z24.object({
2448
- name: z24.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
2449
- sql: z24.string().min(1)
2674
+ var ApplyDbMigrationSchema = z25.object({
2675
+ name: z25.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
2676
+ sql: z25.string().min(1)
2450
2677
  });
2451
2678
  var DB_REST_METHODS = ["GET", "POST", "PATCH", "PUT", "DELETE", "HEAD"];
2452
- var DbRestMethodSchema = z24.enum(DB_REST_METHODS);
2679
+ var DbRestMethodSchema = z25.enum(DB_REST_METHODS);
2453
2680
  var BUCKET_NAME = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
2454
- var BucketSchema = z24.object({
2455
- object: z24.literal("bucket"),
2456
- name: z24.string().regex(BUCKET_NAME),
2457
- public: z24.boolean(),
2681
+ var BucketSchema = z25.object({
2682
+ object: z25.literal("bucket"),
2683
+ name: z25.string().regex(BUCKET_NAME),
2684
+ public: z25.boolean(),
2458
2685
  created_at: Timestamp
2459
2686
  });
2460
- var CreateBucketSchema = z24.object({
2461
- name: z24.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
2462
- public: z24.boolean().default(false)
2463
- });
2464
- var StorageObjectSchema = z24.object({
2465
- object: z24.literal("storage_object"),
2466
- bucket: z24.string(),
2467
- key: z24.string().min(1),
2468
- size_bytes: z24.number().int().nonnegative(),
2469
- content_type: z24.string(),
2470
- etag: z24.string().nullable(),
2687
+ var CreateBucketSchema = z25.object({
2688
+ name: z25.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
2689
+ public: z25.boolean().default(false)
2690
+ });
2691
+ var StorageObjectSchema = z25.object({
2692
+ object: z25.literal("storage_object"),
2693
+ bucket: z25.string(),
2694
+ key: z25.string().min(1),
2695
+ size_bytes: z25.number().int().nonnegative(),
2696
+ content_type: z25.string(),
2697
+ etag: z25.string().nullable(),
2471
2698
  updated_at: Timestamp
2472
2699
  });
2473
- var SignedUrlMethodSchema = z24.enum(["PUT", "GET"]);
2474
- var SignedUrlSchema = z24.object({
2475
- object: z24.literal("signed_url"),
2476
- url: z24.string().url(),
2700
+ var SignedUrlMethodSchema = z25.enum(["PUT", "GET"]);
2701
+ var SignedUrlSchema = z25.object({
2702
+ object: z25.literal("signed_url"),
2703
+ url: z25.string().url(),
2477
2704
  method: SignedUrlMethodSchema,
2478
2705
  expires_at: Timestamp
2479
2706
  });
2480
- var CreateUploadUrlSchema = z24.object({
2481
- content_type: z24.string().min(1),
2482
- expires_seconds: z24.number().int().min(60).max(3600).default(900)
2707
+ var CreateUploadUrlSchema = z25.object({
2708
+ content_type: z25.string().min(1),
2709
+ expires_seconds: z25.number().int().min(60).max(3600).default(900)
2483
2710
  });
2484
2711
 
2485
2712
  // ../core/src/schema/stock-photo.ts
2486
- import { z as z25 } from "zod";
2713
+ import { z as z26 } from "zod";
2487
2714
  var STOCK_PHOTO_ORIENTATIONS = ["landscape", "portrait", "square"];
2488
2715
  var STOCK_PHOTO_SIZES = ["small", "medium", "large"];
2489
- var StockPhotoQuerySchema = z25.object({
2490
- query: z25.string().min(1).max(200),
2491
- count: z25.coerce.number().int().min(1).max(30).default(10),
2492
- orientation: z25.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
2493
- color: z25.string().min(1).max(32).optional(),
2494
- size: z25.enum(STOCK_PHOTO_SIZES).optional()
2495
- });
2496
- var StockPhotoSchema = z25.object({
2497
- object: z25.literal("stock_photo"),
2498
- id: z25.string().min(1),
2499
- width: z25.number().int().positive(),
2500
- height: z25.number().int().positive(),
2501
- url: z25.string().url(),
2502
- preview_url: z25.string().url(),
2503
- alt: z25.string().nullable(),
2504
- photographer: z25.string().nullable(),
2505
- attribution_url: z25.string().url().nullable(),
2506
- dominant_color: z25.string().nullable()
2716
+ var StockPhotoQuerySchema = z26.object({
2717
+ query: z26.string().min(1).max(200),
2718
+ count: z26.coerce.number().int().min(1).max(30).default(10),
2719
+ orientation: z26.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
2720
+ color: z26.string().min(1).max(32).optional(),
2721
+ size: z26.enum(STOCK_PHOTO_SIZES).optional()
2722
+ });
2723
+ var StockPhotoSchema = z26.object({
2724
+ object: z26.literal("stock_photo"),
2725
+ id: z26.string().min(1),
2726
+ width: z26.number().int().positive(),
2727
+ height: z26.number().int().positive(),
2728
+ url: z26.string().url(),
2729
+ preview_url: z26.string().url(),
2730
+ alt: z26.string().nullable(),
2731
+ photographer: z26.string().nullable(),
2732
+ attribution_url: z26.string().url().nullable(),
2733
+ dominant_color: z26.string().nullable()
2507
2734
  });
2508
2735
 
2509
2736
  // ../core/src/schema/creator.ts
2510
- import { z as z26 } from "zod";
2511
- var CreatorCodeSchema = z26.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
2512
- var PayoutMethodSchema = z26.enum(["wise", "paypal"]);
2513
- var PayoutDetailsSchema = z26.object({
2737
+ import { z as z27 } from "zod";
2738
+ var CreatorCodeSchema = z27.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
2739
+ var PayoutMethodSchema = z27.enum(["wise", "paypal"]);
2740
+ var PayoutDetailsSchema = z27.object({
2514
2741
  method: PayoutMethodSchema,
2515
- account: z26.string().min(1).max(320)
2742
+ account: z27.string().min(1).max(320)
2516
2743
  });
2517
- var CreatorStatusSchema = z26.enum(["active", "suspended"]);
2518
- var CreatorSchema = z26.object({
2744
+ var CreatorStatusSchema = z27.enum(["active", "suspended"]);
2745
+ var CreatorSchema = z27.object({
2519
2746
  id: idOf("crt"),
2520
- object: z26.literal("creator"),
2521
- email: z26.email(),
2522
- display_name: z26.string().min(1).max(80),
2747
+ object: z27.literal("creator"),
2748
+ email: z27.email(),
2749
+ display_name: z27.string().min(1).max(80),
2523
2750
  code: CreatorCodeSchema,
2524
2751
  status: CreatorStatusSchema,
2525
2752
  payout: PayoutDetailsSchema.nullable(),
2526
- clicks: z26.number().int().nonnegative(),
2753
+ clicks: z27.number().int().nonnegative(),
2527
2754
  created_at: Timestamp,
2528
2755
  updated_at: Timestamp
2529
2756
  });
@@ -2531,45 +2758,47 @@ var IdentityCreatorSchema = CreatorSchema.pick({
2531
2758
  id: true,
2532
2759
  status: true
2533
2760
  });
2534
- var CreatorApplicationStatusSchema = z26.enum([
2761
+ var CreatorApplicationStatusSchema = z27.enum([
2535
2762
  "pending",
2536
2763
  "approved",
2537
2764
  "rejected"
2538
2765
  ]);
2539
- var CreatorApplicationSchema = z26.object({
2766
+ var CreatorApplicationSchema = z27.object({
2540
2767
  id: idOf("cra"),
2541
- object: z26.literal("creator_application"),
2542
- email: z26.email(),
2543
- display_name: z26.string().min(1).max(80),
2544
- pitch: z26.string().min(1).max(2e3),
2545
- links: z26.array(z26.url({ protocol: /^https$/ })).max(5),
2768
+ object: z27.literal("creator_application"),
2769
+ email: z27.email(),
2770
+ display_name: z27.string().min(1).max(80),
2771
+ pitch: z27.string().min(1).max(2e3),
2772
+ links: z27.array(z27.url({ protocol: /^https$/ })).max(5),
2546
2773
  status: CreatorApplicationStatusSchema,
2547
- note: z26.string().nullable(),
2774
+ note: z27.string().nullable(),
2548
2775
  creator_id: idOf("crt").nullable(),
2549
2776
  created_at: Timestamp,
2550
2777
  decided_at: Timestamp.nullable()
2551
2778
  });
2552
- var ReferralStatusSchema = z26.enum(["pending", "active", "expired"]);
2553
- var ReferralSchema = z26.object({
2779
+ var ReferralStatusSchema = z27.enum(["pending", "active", "expired"]);
2780
+ var ReferralSchema = z27.object({
2554
2781
  id: idOf("crf"),
2555
- object: z26.literal("referral"),
2782
+ object: z27.literal("referral"),
2556
2783
  creator_id: idOf("crt"),
2557
2784
  organization_id: idOf("org"),
2558
2785
  status: ReferralStatusSchema,
2559
2786
  attributed_at: Timestamp,
2560
2787
  first_paid_at: Timestamp.nullable(),
2561
- commission_until: Timestamp.nullable()
2788
+ commission_until: Timestamp.nullable(),
2789
+ /** Opaque per-creator hash of the referred person, so organizations group by person; never the email. */
2790
+ person_key: z27.string().nullable().optional()
2562
2791
  });
2563
- var CommissionKindSchema = z26.enum(["referral", "template"]);
2564
- var CommissionStatusSchema = z26.enum([
2792
+ var CommissionKindSchema = z27.enum(["referral", "template"]);
2793
+ var CommissionStatusSchema = z27.enum([
2565
2794
  "pending",
2566
2795
  "available",
2567
2796
  "claimed",
2568
2797
  "paid"
2569
2798
  ]);
2570
- var CommissionSchema = z26.object({
2799
+ var CommissionSchema = z27.object({
2571
2800
  id: idOf("crc"),
2572
- object: z26.literal("commission"),
2801
+ object: z27.literal("commission"),
2573
2802
  creator_id: idOf("crt"),
2574
2803
  kind: CommissionKindSchema,
2575
2804
  referral_id: idOf("crf").nullable(),
@@ -2582,123 +2811,290 @@ var CommissionSchema = z26.object({
2582
2811
  available_at: Timestamp,
2583
2812
  payout_id: idOf("crp").nullable()
2584
2813
  });
2585
- var PayoutStatusSchema = z26.enum(["requested", "paid", "rejected"]);
2586
- var PayoutSchema = z26.object({
2814
+ var PayoutStatusSchema = z27.enum(["requested", "paid", "rejected"]);
2815
+ var PayoutSchema = z27.object({
2587
2816
  id: idOf("crp"),
2588
- object: z26.literal("payout"),
2817
+ object: z27.literal("payout"),
2589
2818
  creator_id: idOf("crt"),
2590
2819
  amount_micro_usd: MicroUsdField.positive(),
2591
- currency: z26.literal("USD"),
2820
+ currency: z27.literal("USD"),
2592
2821
  method: PayoutMethodSchema,
2593
- account: z26.string().min(1),
2822
+ account: z27.string().min(1),
2594
2823
  status: PayoutStatusSchema,
2595
- reference: z26.string().nullable(),
2596
- note: z26.string().nullable(),
2824
+ reference: z27.string().nullable(),
2825
+ note: z27.string().nullable(),
2597
2826
  requested_at: Timestamp,
2598
2827
  decided_at: Timestamp.nullable()
2599
2828
  });
2600
2829
  var CREATOR_PROGRAM = {
2601
- referral_percent: 20,
2602
- template_percent: 5,
2830
+ referral_percent: 15,
2831
+ /** Of each qualifying subscription invoice of an org whose FIRST install was the template. */
2832
+ template_percent: 15,
2603
2833
  commission_months: 12,
2604
2834
  hold_days: 30,
2605
2835
  attribution_days: 30,
2606
- minimum_payout_micro_usd: 2e7
2836
+ /** A template install earns only for an org it was installed in within this many days of creation. */
2837
+ template_new_org_days: 35,
2838
+ minimum_payout_micro_usd: 2e7,
2839
+ /** The creator studio's per-draft spend caps; one session never plans past what the draft has left. */
2840
+ studio: {
2841
+ draft_budget_micro_usd: 4e7,
2842
+ author_budget_micro_usd: 8e6,
2843
+ demo_budget_micro_usd: 1e7,
2844
+ uploads: 3,
2845
+ upload_max_bytes: 60 * 1024 * 1024,
2846
+ upload_token_minutes: 15,
2847
+ skill_max_bytes: 32 * 1024
2848
+ }
2607
2849
  };
2608
- var CreatorTemplateSlugSchema = z26.string().max(32).regex(
2850
+ var CreatorTemplateSlugSchema = z27.string().max(32).regex(
2609
2851
  /^[a-z0-9]+(-[a-z0-9]+)*$/,
2610
2852
  "lowercase letters, digits and single dashes"
2611
2853
  );
2612
- var CreatorSkillSchema = z26.object({
2613
- slug: z26.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2614
- body: z26.string().min(1).max(64 * 1024)
2615
- });
2616
- var CreatorDeclarationSchema = z26.object({
2617
- agents: z26.array(z26.unknown()),
2618
- questions: z26.array(z26.unknown()),
2619
- skills: z26.array(CreatorSkillSchema).max(16)
2620
- });
2621
- var CreatorTemplateVersionStatusSchema = z26.enum([
2854
+ var CreatorSkillSchema = z27.object({
2855
+ slug: z27.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2856
+ body: z27.string().min(1).max(64 * 1024)
2857
+ });
2858
+ var CreatorDeclarationSchema = z27.object({
2859
+ agents: z27.array(z27.unknown()),
2860
+ questions: z27.array(z27.unknown()),
2861
+ skills: z27.array(CreatorSkillSchema).max(16),
2862
+ /** A `niche` version only: the studio round it froze (see `NicheVersionStudioSchema`, below). */
2863
+ studio: z27.lazy(() => NicheVersionStudioSchema).optional()
2864
+ });
2865
+ var CreatorTemplateVersionStatusSchema = z27.enum([
2622
2866
  "in_review",
2623
2867
  "approved",
2624
2868
  "changes_requested"
2625
2869
  ]);
2626
- var VersionNumber = z26.number().int().positive();
2627
- var CreatorTemplateSchema = z26.object({
2870
+ var VersionNumber = z27.number().int().positive();
2871
+ var CreatorTemplateKindSchema = z27.enum(["crew", "niche"]);
2872
+ var StudioStateSchema = z27.enum([
2873
+ "setup",
2874
+ "building",
2875
+ "ready",
2876
+ "in_review",
2877
+ "live",
2878
+ "changes_requested"
2879
+ ]);
2880
+ var StudioUploadContentTypeSchema = z27.enum([
2881
+ "video/mp4",
2882
+ "video/quicktime",
2883
+ "video/webm"
2884
+ ]);
2885
+ var UploadPosition = z27.number().int().min(1).max(CREATOR_PROGRAM.studio.uploads);
2886
+ var StudioPrompt = z27.string().max(2e3);
2887
+ var StudioUploadSchema = z27.object({
2888
+ position: UploadPosition,
2889
+ file_id: z27.string().nullable(),
2890
+ prompt: StudioPrompt,
2891
+ bytes: z27.number().int().positive().max(CREATOR_PROGRAM.studio.upload_max_bytes),
2892
+ content_type: StudioUploadContentTypeSchema,
2893
+ filename: z27.string().min(1).max(200)
2894
+ });
2895
+ var CreatorStudioSchema = z27.object({
2896
+ uploads: z27.array(StudioUploadSchema).max(CREATOR_PROGRAM.studio.uploads).default([]),
2897
+ state: StudioStateSchema.default("setup"),
2898
+ spend_micro_usd: MicroUsdField.nonnegative().default(0),
2899
+ rights_attested_at: Timestamp.nullable().default(null)
2900
+ });
2901
+ var CreatorTemplateListingSchema = z27.object({
2902
+ listed: z27.boolean(),
2903
+ featured: z27.boolean(),
2904
+ sort_order: z27.number().int(),
2905
+ tagline: z27.string().max(140).nullable(),
2906
+ hero_file_id: z27.string().nullable()
2907
+ });
2908
+ var StudioRoundStateSchema = z27.enum([
2909
+ "queued",
2910
+ "authoring",
2911
+ "rendering",
2912
+ "ready",
2913
+ "failed"
2914
+ ]);
2915
+ var StudioFrameSchema = z27.object({
2916
+ file: z27.string().min(1),
2917
+ file_id: z27.string().min(1),
2918
+ role: z27.string()
2919
+ });
2920
+ var StudioSampleSchema = z27.object({
2921
+ file_id: z27.string().min(1),
2922
+ poster_file_id: z27.string().nullable(),
2923
+ seconds: z27.number().nonnegative(),
2924
+ title: z27.string()
2925
+ });
2926
+ var CreatorTemplateRoundSchema = z27.object({
2927
+ object: z27.literal("creator_template_round"),
2928
+ template_id: idOf("ctp"),
2929
+ n: z27.number().int().positive(),
2930
+ feedback: z27.string().nullable(),
2931
+ state: StudioRoundStateSchema,
2932
+ author_session_id: z27.string().nullable(),
2933
+ demo_session_id: z27.string().nullable(),
2934
+ skill_md: z27.string().nullable(),
2935
+ reference_json: z27.unknown().nullable(),
2936
+ frames: z27.array(StudioFrameSchema),
2937
+ samples: z27.array(StudioSampleSchema),
2938
+ spend_micro_usd: MicroUsdField.nonnegative(),
2939
+ error: z27.string().nullable(),
2940
+ created_at: Timestamp,
2941
+ finished_at: Timestamp.nullable()
2942
+ });
2943
+ var NicheVersionStudioSchema = z27.object({
2944
+ round: z27.number().int().positive(),
2945
+ uploads: z27.array(StudioUploadSchema),
2946
+ reference_json: z27.unknown().nullable(),
2947
+ frames: z27.array(StudioFrameSchema),
2948
+ samples: z27.array(StudioSampleSchema),
2949
+ tagline: z27.string().max(140),
2950
+ hero_sample_index: z27.number().int().nonnegative()
2951
+ });
2952
+ var CreatorTemplateSchema = z27.object({
2628
2953
  id: idOf("ctp"),
2629
- object: z26.literal("creator_template"),
2954
+ object: z27.literal("creator_template"),
2630
2955
  creator_id: idOf("crt"),
2631
- blueprint: z26.string().min(1),
2632
- base_template: z26.string().min(1),
2956
+ blueprint: z27.string().min(1),
2957
+ base_template: z27.string().min(1),
2633
2958
  slug: CreatorTemplateSlugSchema,
2634
- template: z26.string().min(1).max(64),
2635
- name: z26.string().min(1).max(80),
2636
- description: z26.string().max(2e3),
2959
+ template: z27.string().min(1).max(64),
2960
+ name: z27.string().min(1).max(80),
2961
+ description: z27.string().max(2e3),
2637
2962
  declaration: CreatorDeclarationSchema,
2638
2963
  published_version: VersionNumber.nullable(),
2639
- latest_version: z26.object({
2964
+ latest_version: z27.object({
2640
2965
  version: VersionNumber,
2641
2966
  status: CreatorTemplateVersionStatusSchema
2642
2967
  }).nullable(),
2968
+ kind: CreatorTemplateKindSchema,
2969
+ studio: CreatorStudioSchema,
2970
+ listing: CreatorTemplateListingSchema,
2643
2971
  created_at: Timestamp,
2644
2972
  updated_at: Timestamp
2645
2973
  });
2646
- var CreatorTemplateVersionSchema = z26.object({
2647
- object: z26.literal("creator_template_version"),
2974
+ var CreatorTemplateVersionSchema = z27.object({
2975
+ object: z27.literal("creator_template_version"),
2648
2976
  template_id: idOf("ctp"),
2649
2977
  version: VersionNumber,
2650
2978
  declaration: CreatorDeclarationSchema,
2651
2979
  status: CreatorTemplateVersionStatusSchema,
2652
- note: z26.string().nullable(),
2980
+ note: z27.string().nullable(),
2653
2981
  artifact_id: idOf("bpa").nullable(),
2654
2982
  submitted_at: Timestamp,
2655
2983
  decided_at: Timestamp.nullable()
2656
2984
  });
2657
- var CreatorBalanceSchema = z26.object({
2658
- object: z26.literal("creator_balance"),
2985
+ var CreatorBalanceSchema = z27.object({
2986
+ object: z27.literal("creator_balance"),
2659
2987
  pending_micro_usd: MicroUsdField.nonnegative(),
2660
2988
  available_micro_usd: MicroUsdField.nonnegative(),
2661
2989
  claimed_micro_usd: MicroUsdField.nonnegative(),
2662
2990
  paid_micro_usd: MicroUsdField.nonnegative(),
2663
- minimum_payout_micro_usd: z26.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
2991
+ minimum_payout_micro_usd: z27.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
2664
2992
  });
2665
- var ReferralClickSchema = z26.object({
2666
- object: z26.literal("referral_click"),
2993
+ var ReferralClickSchema = z27.object({
2994
+ object: z27.literal("referral_click"),
2667
2995
  code: CreatorCodeSchema,
2668
- creator: z26.object({ display_name: z26.string().min(1) }),
2996
+ creator: z27.object({ display_name: z27.string().min(1) }),
2669
2997
  expires_at: Timestamp
2670
2998
  });
2671
- var Day2 = z26.iso.date();
2672
- var CreatorAnalyticsSchema = z26.object({
2673
- object: z26.literal("creator_analytics"),
2674
- days: z26.number().int().min(1).max(90),
2999
+ var Day2 = z27.iso.date();
3000
+ var CreatorAnalyticsSchema = z27.object({
3001
+ object: z27.literal("creator_analytics"),
3002
+ days: z27.number().int().min(1).max(90),
2675
3003
  from: Day2,
2676
3004
  to: Day2,
2677
- clicks: z26.number().int().nonnegative(),
2678
- referrals: z26.number().int().nonnegative(),
2679
- installs: z26.number().int().nonnegative(),
2680
- active_installs: z26.number().int().nonnegative(),
2681
- usage_by_day: z26.array(
2682
- z26.object({ day: Day2, debit_micro_usd: MicroUsdField.nonnegative() })
2683
- ),
2684
- commission_micro_usd: z26.object({
3005
+ clicks: z27.number().int().nonnegative(),
3006
+ referrals: z27.number().int().nonnegative(),
3007
+ installs: z27.number().int().nonnegative(),
3008
+ active_installs: z27.number().int().nonnegative(),
3009
+ /** Distinct orgs with at least one commission-bearing invoice in the window (invoice-based template commission). */
3010
+ paying_orgs: z27.number().int().nonnegative().optional(),
3011
+ /** DEPRECATED with the 5% usage accrual; optional until `analytics()` stops returning it. */
3012
+ usage_by_day: z27.array(z27.object({ day: Day2, debit_micro_usd: MicroUsdField.nonnegative() })).optional(),
3013
+ commission_micro_usd: z27.object({
2685
3014
  pending: MicroUsdField.nonnegative(),
2686
3015
  available: MicroUsdField.nonnegative(),
2687
3016
  claimed: MicroUsdField.nonnegative(),
2688
3017
  paid: MicroUsdField.nonnegative()
2689
3018
  }),
2690
- commissions_by_template: z26.array(
2691
- z26.object({
3019
+ commissions_by_template: z27.array(
3020
+ z27.object({
2692
3021
  creator_template_id: idOf("ctp"),
2693
3022
  amount_micro_usd: MicroUsdField.nonnegative()
2694
3023
  })
2695
3024
  ),
2696
3025
  /** Every install covered, newest first: the day it was created and the day its twelve months end. */
2697
- install_windows: z26.array(z26.object({ install_id: idOf("bpi"), from: Day2, until: Day2 }))
3026
+ install_windows: z27.array(z27.object({ install_id: idOf("bpi"), from: Day2, until: Day2 })).optional()
3027
+ });
3028
+ var CreatorTemplateCreateKindSchema = z27.object({
3029
+ kind: CreatorTemplateKindSchema.default("crew")
3030
+ });
3031
+ var StudioUploadCreateSchema = z27.object({
3032
+ position: UploadPosition,
3033
+ filename: z27.string().min(1).max(200),
3034
+ content_type: StudioUploadContentTypeSchema,
3035
+ bytes: z27.number().int().positive().max(CREATOR_PROGRAM.studio.upload_max_bytes)
3036
+ });
3037
+ var StudioUploadTicketSchema = z27.object({
3038
+ object: z27.literal("studio_upload_ticket"),
3039
+ position: UploadPosition,
3040
+ upload_url: z27.url(),
3041
+ expires_at: Timestamp
3042
+ });
3043
+ var StudioUploadPatchSchema = z27.object({ prompt: StudioPrompt });
3044
+ var StudioUploadResultSchema = z27.object({
3045
+ object: z27.literal("studio_upload"),
3046
+ template_id: idOf("ctp"),
3047
+ upload: StudioUploadSchema
3048
+ });
3049
+ var StudioRoundCreateSchema = z27.object({
3050
+ feedback: z27.string().min(1).max(4e3).optional(),
3051
+ rights_attested: z27.boolean().optional()
3052
+ });
3053
+ var StudioBudgetSchema = z27.object({
3054
+ draft_micro_usd: MicroUsdField.nonnegative(),
3055
+ spent_micro_usd: MicroUsdField.nonnegative(),
3056
+ remaining_micro_usd: MicroUsdField.nonnegative()
3057
+ });
3058
+ var CreatorStudioViewSchema = z27.object({
3059
+ object: z27.literal("creator_studio"),
3060
+ template_id: idOf("ctp"),
3061
+ studio: CreatorStudioSchema,
3062
+ /** Newest first. */
3063
+ rounds: z27.array(CreatorTemplateRoundSchema),
3064
+ budget: StudioBudgetSchema
3065
+ });
3066
+ var NicheSubmitSchema = z27.object({
3067
+ round: z27.number().int().positive(),
3068
+ listing: z27.object({
3069
+ tagline: z27.string().min(1).max(140),
3070
+ hero_sample_index: z27.number().int().nonnegative()
3071
+ })
3072
+ });
3073
+ var CreatorListingPatchSchema = CreatorTemplateListingSchema.partial();
3074
+ var CreatorListingSchema = z27.object({
3075
+ object: z27.literal("creator_listing"),
3076
+ template_id: idOf("ctp"),
3077
+ template: z27.string().min(1),
3078
+ name: z27.string(),
3079
+ kind: CreatorTemplateKindSchema,
3080
+ blueprint: z27.string(),
3081
+ base_template: z27.string(),
3082
+ published_version: VersionNumber.nullable(),
3083
+ creator: z27.object({
3084
+ id: idOf("crt"),
3085
+ display_name: z27.string(),
3086
+ code: CreatorCodeSchema,
3087
+ status: CreatorStatusSchema
3088
+ }),
3089
+ listing: CreatorTemplateListingSchema,
3090
+ /** Installs of the template, and distinct orgs among them that earned a template commission. */
3091
+ deploys: z27.number().int().nonnegative().optional(),
3092
+ paying_orgs: z27.number().int().nonnegative().optional(),
3093
+ updated_at: Timestamp
2698
3094
  });
2699
3095
 
2700
3096
  // ../core/src/schema/legal.ts
2701
- import { z as z27 } from "zod";
3097
+ import { z as z28 } from "zod";
2702
3098
  var LEGAL_MEMBER_STATUSES = [
2703
3099
  "pending",
2704
3100
  "link_ready",
@@ -2708,16 +3104,16 @@ var LEGAL_MEMBER_STATUSES = [
2708
3104
  "verified",
2709
3105
  "failed"
2710
3106
  ];
2711
- var LegalMemberStatusSchema = z27.enum(LEGAL_MEMBER_STATUSES);
3107
+ var LegalMemberStatusSchema = z28.enum(LEGAL_MEMBER_STATUSES);
2712
3108
  var LEGAL_VERIFICATION_STATUSES = ["in_progress", "pending_review", "verified", "failed"];
2713
- var LegalVerificationStatusSchema = z27.enum(LEGAL_VERIFICATION_STATUSES);
3109
+ var LegalVerificationStatusSchema = z28.enum(LEGAL_VERIFICATION_STATUSES);
2714
3110
  var LEGAL_COMPANY_STATUSES = ["awaiting_payment", "paid", "submitted", "formed", "failed"];
2715
- var LegalCompanyStatusSchema = z27.enum(LEGAL_COMPANY_STATUSES);
3111
+ var LegalCompanyStatusSchema = z28.enum(LEGAL_COMPANY_STATUSES);
2716
3112
  var LEGAL_DOCUMENT_KINDS = ["articles", "ein_letter", "operating_agreement", "other"];
2717
- var LegalDocumentKindSchema = z27.enum(LEGAL_DOCUMENT_KINDS);
2718
- var LegalMemberRoleSchema = z27.enum(["primary", "secondary"]);
2719
- var LegalEinStatusSchema = z27.enum(["none", "pending", "issued"]);
2720
- var LegalRequiredActionKindSchema = z27.enum(["signature", "information", "payment", "other"]);
3113
+ var LegalDocumentKindSchema = z28.enum(LEGAL_DOCUMENT_KINDS);
3114
+ var LegalMemberRoleSchema = z28.enum(["primary", "secondary"]);
3115
+ var LegalEinStatusSchema = z28.enum(["none", "pending", "issued"]);
3116
+ var LegalRequiredActionKindSchema = z28.enum(["signature", "information", "payment", "other"]);
2721
3117
  var US_STATES = [
2722
3118
  "AL",
2723
3119
  "AK",
@@ -2771,105 +3167,105 @@ var US_STATES = [
2771
3167
  "WI",
2772
3168
  "WY"
2773
3169
  ];
2774
- var UsStateSchema = z27.enum(US_STATES);
2775
- var LegalMemberInputSchema = z27.object({
2776
- first_name: z27.string().min(1).max(128),
2777
- last_name: z27.string().min(1).max(128),
2778
- email: z27.string().min(1).max(320),
3170
+ var UsStateSchema = z28.enum(US_STATES);
3171
+ var LegalMemberInputSchema = z28.object({
3172
+ first_name: z28.string().min(1).max(128),
3173
+ last_name: z28.string().min(1).max(128),
3174
+ email: z28.string().min(1).max(320),
2779
3175
  role: LegalMemberRoleSchema,
2780
- is_responsible_party: z27.boolean(),
2781
- ownership_percent: z27.number().int()
3176
+ is_responsible_party: z28.boolean(),
3177
+ ownership_percent: z28.number().int()
2782
3178
  });
2783
3179
  var LegalMemberSchema = LegalMemberInputSchema.extend({
2784
3180
  id: idOf("lgm"),
2785
- object: z27.literal("legal_member"),
3181
+ object: z28.literal("legal_member"),
2786
3182
  verification_id: idOf("lgv"),
2787
3183
  status: LegalMemberStatusSchema,
2788
- link_url: z27.url().nullable(),
3184
+ link_url: z28.url().nullable(),
2789
3185
  link_expires_at: Timestamp.nullable(),
2790
3186
  completed_at: Timestamp.nullable()
2791
3187
  });
2792
- var LegalVerificationSchema = z27.object({
3188
+ var LegalVerificationSchema = z28.object({
2793
3189
  id: idOf("lgv"),
2794
- object: z27.literal("legal_verification"),
3190
+ object: z28.literal("legal_verification"),
2795
3191
  identity_id: idOf("idn"),
2796
3192
  status: LegalVerificationStatusSchema,
2797
- members: z27.array(LegalMemberSchema),
2798
- ready_for_formation: z27.boolean(),
3193
+ members: z28.array(LegalMemberSchema),
3194
+ ready_for_formation: z28.boolean(),
2799
3195
  started_at: Timestamp,
2800
3196
  completed_at: Timestamp.nullable(),
2801
3197
  created_at: Timestamp,
2802
3198
  updated_at: Timestamp
2803
3199
  });
2804
- var StartLegalVerificationSchema = z27.object({ members: z27.array(LegalMemberInputSchema) });
2805
- var CompleteLegalMemberSchema = z27.object({ token: z27.string().min(1) });
2806
- var LegalNameOptionSchema = z27.object({ name: z27.string().min(1).max(200), ending: z27.literal("LLC") });
2807
- var LegalMailingAddressSchema = z27.object({
2808
- line1: z27.string().min(1).max(200),
2809
- line2: z27.string().max(200).nullable(),
2810
- city: z27.string().min(1).max(100),
3200
+ var StartLegalVerificationSchema = z28.object({ members: z28.array(LegalMemberInputSchema) });
3201
+ var CompleteLegalMemberSchema = z28.object({ token: z28.string().min(1) });
3202
+ var LegalNameOptionSchema = z28.object({ name: z28.string().min(1).max(200), ending: z28.literal("LLC") });
3203
+ var LegalMailingAddressSchema = z28.object({
3204
+ line1: z28.string().min(1).max(200),
3205
+ line2: z28.string().max(200).nullable(),
3206
+ city: z28.string().min(1).max(100),
2811
3207
  state: UsStateSchema,
2812
- postal_code: z27.string().min(1).max(16),
2813
- country: z27.literal("US")
3208
+ postal_code: z28.string().min(1).max(16),
3209
+ country: z28.literal("US")
2814
3210
  });
2815
- var LegalRequiredActionSchema = z27.object({
3211
+ var LegalRequiredActionSchema = z28.object({
2816
3212
  kind: LegalRequiredActionKindSchema,
2817
- description: z27.string(),
2818
- url: z27.url().nullable()
3213
+ description: z28.string(),
3214
+ url: z28.url().nullable()
2819
3215
  });
2820
3216
  var LEGAL_DESCRIPTION_MAX = 50;
2821
- var CreateLegalCompanySchema = z27.object({
3217
+ var CreateLegalCompanySchema = z28.object({
2822
3218
  verification_id: idOf("lgv"),
2823
3219
  state: UsStateSchema,
2824
- name_options: z27.array(z27.string().min(1).max(200)).min(1).max(3),
2825
- naics_code: z27.string().regex(/^\d{2,6}$/),
2826
- description: z27.string().min(1).max(LEGAL_DESCRIPTION_MAX),
3220
+ name_options: z28.array(z28.string().min(1).max(200)).min(1).max(3),
3221
+ naics_code: z28.string().regex(/^\d{2,6}$/),
3222
+ description: z28.string().min(1).max(LEGAL_DESCRIPTION_MAX),
2827
3223
  mailing_address: LegalMailingAddressSchema
2828
3224
  });
2829
3225
  var LegalCompanySchema = CreateLegalCompanySchema.omit({ name_options: true }).extend({
2830
3226
  id: idOf("lgc"),
2831
- object: z27.literal("legal_company"),
3227
+ object: z28.literal("legal_company"),
2832
3228
  identity_id: idOf("idn"),
2833
3229
  status: LegalCompanyStatusSchema,
2834
- entity_type: z27.literal("llc"),
2835
- name_options: z27.array(LegalNameOptionSchema),
2836
- legal_name: z27.string().nullable(),
3230
+ entity_type: z28.literal("llc"),
3231
+ name_options: z28.array(LegalNameOptionSchema),
3232
+ legal_name: z28.string().nullable(),
2837
3233
  ein_status: LegalEinStatusSchema,
2838
3234
  price_micro_usd: MicroUsdField,
2839
- required_actions: z27.array(LegalRequiredActionSchema),
2840
- failure_reason: z27.string().max(256).nullable(),
3235
+ required_actions: z28.array(LegalRequiredActionSchema),
3236
+ failure_reason: z28.string().max(256).nullable(),
2841
3237
  submitted_at: Timestamp.nullable(),
2842
3238
  formed_at: Timestamp.nullable(),
2843
3239
  created_at: Timestamp,
2844
3240
  updated_at: Timestamp
2845
3241
  });
2846
- var LegalDocumentSchema = z27.object({
3242
+ var LegalDocumentSchema = z28.object({
2847
3243
  id: idOf("lgd"),
2848
- object: z27.literal("legal_document"),
3244
+ object: z28.literal("legal_document"),
2849
3245
  company_id: idOf("lgc"),
2850
3246
  kind: LegalDocumentKindSchema,
2851
- name: z27.string(),
3247
+ name: z28.string(),
2852
3248
  created_at: Timestamp
2853
3249
  });
2854
- var LegalDocumentLinkSchema = z27.object({
2855
- object: z27.literal("legal_document_link"),
2856
- url: z27.url(),
3250
+ var LegalDocumentLinkSchema = z28.object({
3251
+ object: z28.literal("legal_document_link"),
3252
+ url: z28.url(),
2857
3253
  expires_at: Timestamp
2858
3254
  });
2859
- var NaicsCodeSchema = z27.object({
2860
- object: z27.literal("naics_code"),
2861
- code: z27.string().regex(/^\d{2,6}$/),
2862
- title: z27.string()
3255
+ var NaicsCodeSchema = z28.object({
3256
+ object: z28.literal("naics_code"),
3257
+ code: z28.string().regex(/^\d{2,6}$/),
3258
+ title: z28.string()
2863
3259
  });
2864
- var LegalStateSchema = z27.object({
2865
- object: z27.literal("legal_state"),
3260
+ var LegalStateSchema = z28.object({
3261
+ object: z28.literal("legal_state"),
2866
3262
  code: UsStateSchema,
2867
- name: z27.string(),
3263
+ name: z28.string(),
2868
3264
  formation_fee_micro_usd: MicroUsdField
2869
3265
  });
2870
- var LegalWebhookEventSchema = z27.object({
2871
- provider_session_ref: z27.string().min(1),
2872
- status: z27.enum(["verified", "failed", "pending_review"]),
3266
+ var LegalWebhookEventSchema = z28.object({
3267
+ provider_session_ref: z28.string().min(1),
3268
+ status: z28.enum(["verified", "failed", "pending_review"]),
2873
3269
  metadata: Metadata
2874
3270
  });
2875
3271
  var LLC_ENDING = /\s*(?:,\s*)?(?:l\.?l\.?c\.?|limited\s+liability\s+company)\s*$/i;
@@ -2880,419 +3276,302 @@ function canonicalName(raw) {
2880
3276
  }
2881
3277
 
2882
3278
  // ../core/src/schema/wallet.ts
2883
- import { z as z28 } from "zod";
3279
+ import { z as z29 } from "zod";
2884
3280
  var WALLET_NETWORKS = ["eip155:84532", "eip155:8453"];
2885
- var WalletNetworkSchema = z28.enum(WALLET_NETWORKS);
3281
+ var WalletNetworkSchema = z29.enum(WALLET_NETWORKS);
2886
3282
  var DEFAULT_WALLET_NETWORK = "eip155:84532";
2887
- var WalletSelectSchema = z28.object({ network: WalletNetworkSchema.optional() });
3283
+ var WalletSelectSchema = z29.object({ network: WalletNetworkSchema.optional() });
2888
3284
  var WALLET_STATUSES = ["active", "frozen", "swept"];
2889
- var WalletStatusSchema = z28.enum(WALLET_STATUSES);
3285
+ var WalletStatusSchema = z29.enum(WALLET_STATUSES);
2890
3286
  var WALLET_TRANSACTION_KINDS = ["fund", "transfer", "pay", "sweep"];
2891
- var WalletTransactionKindSchema = z28.enum(WALLET_TRANSACTION_KINDS);
3287
+ var WalletTransactionKindSchema = z29.enum(WALLET_TRANSACTION_KINDS);
2892
3288
  var WALLET_TRANSACTION_STATUSES = ["pending", "confirmed", "failed"];
2893
- var WalletTransactionStatusSchema = z28.enum(WALLET_TRANSACTION_STATUSES);
2894
- var WalletDirectionSchema = z28.enum(["in", "out"]);
2895
- var WalletFundSourceSchema = z28.enum(["faucet", "treasury"]);
2896
- var EvmAddressSchema = z28.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
2897
- var TxHashSchema = z28.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
2898
- var WalletPolicySchema = z28.object({
3289
+ var WalletTransactionStatusSchema = z29.enum(WALLET_TRANSACTION_STATUSES);
3290
+ var WalletDirectionSchema = z29.enum(["in", "out"]);
3291
+ var WalletFundSourceSchema = z29.enum(["faucet", "treasury"]);
3292
+ var EvmAddressSchema = z29.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
3293
+ var TxHashSchema = z29.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
3294
+ var WalletPolicySchema = z29.object({
2899
3295
  per_tx_cap_micro_usd: MicroUsdField.nonnegative(),
2900
3296
  daily_cap_micro_usd: MicroUsdField.positive().nullable(),
2901
3297
  low_balance_micro_usd: MicroUsdField.nonnegative().nullable()
2902
3298
  });
2903
- var WalletSchema = z28.object({
3299
+ var WalletSchema = z29.object({
2904
3300
  id: idOf("wlt"),
2905
- object: z28.literal("wallet"),
3301
+ object: z29.literal("wallet"),
2906
3302
  identity_id: idOf("idn"),
2907
3303
  status: WalletStatusSchema,
2908
3304
  network: WalletNetworkSchema,
2909
3305
  address: EvmAddressSchema,
2910
- asset: z28.literal("usdc"),
3306
+ asset: z29.literal("usdc"),
2911
3307
  balance_micro_usd: MicroUsdField,
2912
3308
  policy: WalletPolicySchema,
2913
3309
  spent_today_micro_usd: MicroUsdField,
2914
3310
  created_at: Timestamp,
2915
3311
  updated_at: Timestamp
2916
3312
  });
2917
- var CreateWalletSchema = z28.object({
3313
+ var CreateWalletSchema = z29.object({
2918
3314
  network: WalletNetworkSchema.optional(),
2919
3315
  policy: WalletPolicySchema.partial().optional()
2920
3316
  });
2921
3317
  var UpdateWalletPolicySchema = WalletPolicySchema.partial();
2922
- var FundWalletSchema = z28.object({
3318
+ var FundWalletSchema = z29.object({
2923
3319
  amount_micro_usd: MicroUsdField.positive(),
2924
3320
  source: WalletFundSourceSchema
2925
3321
  });
2926
- var TransferWalletSchema = z28.object({
2927
- to: z28.union([EvmAddressSchema, idOf("idn")]),
3322
+ var TransferWalletSchema = z29.object({
3323
+ to: z29.union([EvmAddressSchema, idOf("idn")]),
2928
3324
  amount_micro_usd: MicroUsdField.positive(),
2929
- purpose: z28.string().min(1).max(256)
3325
+ purpose: z29.string().min(1).max(256)
2930
3326
  });
2931
- var SweepWalletSchema = z28.object({ to: EvmAddressSchema.optional() });
2932
- var WalletTransactionSchema = z28.object({
3327
+ var SweepWalletSchema = z29.object({ to: EvmAddressSchema.optional() });
3328
+ var WalletTransactionSchema = z29.object({
2933
3329
  id: idOf("wtx"),
2934
- object: z28.literal("wallet_transaction"),
3330
+ object: z29.literal("wallet_transaction"),
2935
3331
  wallet_id: idOf("wlt"),
2936
3332
  kind: WalletTransactionKindSchema,
2937
3333
  direction: WalletDirectionSchema,
2938
3334
  amount_micro_usd: MicroUsdField,
2939
- counterparty: z28.string().nullable(),
2940
- origin: z28.string().nullable(),
2941
- purpose: z28.string().nullable(),
3335
+ counterparty: z29.string().nullable(),
3336
+ origin: z29.string().nullable(),
3337
+ purpose: z29.string().nullable(),
2942
3338
  tx_hash: TxHashSchema.nullable(),
2943
3339
  session_id: idOf("ses").nullable(),
2944
3340
  status: WalletTransactionStatusSchema,
2945
3341
  created_at: Timestamp
2946
3342
  });
2947
- var ListWalletTransactionsSchema = z28.object({
3343
+ var ListWalletTransactionsSchema = z29.object({
2948
3344
  kind: WalletTransactionKindSchema.optional(),
2949
3345
  direction: WalletDirectionSchema.optional(),
2950
- origin: z28.string().optional(),
3346
+ origin: z29.string().optional(),
2951
3347
  since: Timestamp.optional()
2952
3348
  });
2953
- var HttpMethodSchema = z28.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
2954
- var WalletQuoteRequestSchema = z28.object({ url: z28.url(), method: HttpMethodSchema.optional() });
2955
- var WalletQuoteSchema = z28.object({
2956
- object: z28.literal("wallet_quote"),
2957
- url: z28.url(),
2958
- payable: z28.boolean(),
3349
+ var HttpMethodSchema = z29.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
3350
+ var WalletQuoteRequestSchema = z29.object({ url: z29.url(), method: HttpMethodSchema.optional() });
3351
+ var WalletQuoteSchema = z29.object({
3352
+ object: z29.literal("wallet_quote"),
3353
+ url: z29.url(),
3354
+ payable: z29.boolean(),
2959
3355
  network: WalletNetworkSchema.nullable(),
2960
- asset: z28.literal("usdc").nullable(),
3356
+ asset: z29.literal("usdc").nullable(),
2961
3357
  amount_micro_usd: MicroUsdField.nullable(),
2962
3358
  pay_to: EvmAddressSchema.nullable(),
2963
- description: z28.string().nullable(),
2964
- max_timeout_seconds: z28.number().int().nullable()
3359
+ description: z29.string().nullable(),
3360
+ max_timeout_seconds: z29.number().int().nullable()
2965
3361
  });
2966
3362
  var WalletPayRequestSchema = WalletQuoteRequestSchema.extend({
2967
3363
  max_amount_micro_usd: MicroUsdField.positive().optional()
2968
3364
  });
2969
3365
  var WALLET_RESPONSE_BODY_MAX = 64 * 1024;
2970
- var WalletPaymentSchema = z28.object({
2971
- object: z28.literal("wallet_payment"),
2972
- paid: z28.boolean(),
3366
+ var WalletPaymentSchema = z29.object({
3367
+ object: z29.literal("wallet_payment"),
3368
+ paid: z29.boolean(),
2973
3369
  transaction_id: idOf("wtx").nullable(),
2974
3370
  amount_micro_usd: MicroUsdField.nullable(),
2975
- response_status: z28.number().int(),
2976
- response_body: z28.string().max(WALLET_RESPONSE_BODY_MAX)
3371
+ response_status: z29.number().int(),
3372
+ response_body: z29.string().max(WALLET_RESPONSE_BODY_MAX)
2977
3373
  });
2978
3374
 
2979
3375
  // ../core/src/schema/cards.ts
2980
- import { z as z29 } from "zod";
3376
+ import { z as z30 } from "zod";
2981
3377
  var CARD_STATUSES = ["pending_payment", "issuing", "active", "failed", "cancelled", "refunded"];
2982
- var CardStatusSchema = z29.enum(CARD_STATUSES);
3378
+ var CardStatusSchema = z30.enum(CARD_STATUSES);
2983
3379
  var CARD_MIN_LOAD_MICRO_USD = 1e6;
2984
3380
  var CARD_MAX_LOAD_MICRO_USD = 15e7;
2985
3381
  var CARD_LOAD_GRANULARITY_MICRO_USD = 1e4;
2986
- var CardSchema = z29.object({
3382
+ var CardSchema = z30.object({
2987
3383
  id: idOf("vcd"),
2988
- object: z29.literal("card"),
3384
+ object: z30.literal("card"),
2989
3385
  identity_id: idOf("idn"),
2990
- kind: z29.literal("prepaid"),
3386
+ kind: z30.literal("prepaid"),
2991
3387
  status: CardStatusSchema,
2992
- label: z29.string().min(1).max(128),
2993
- brand: z29.string().nullable(),
2994
- last4: z29.string().regex(/^\d{4}$/).nullable(),
3388
+ label: z30.string().min(1).max(128),
3389
+ brand: z30.string().nullable(),
3390
+ last4: z30.string().regex(/^\d{4}$/).nullable(),
2995
3391
  load_micro_usd: MicroUsdField,
2996
3392
  spent_micro_usd: MicroUsdField,
2997
- currency: z29.literal("usd"),
3393
+ currency: z30.literal("usd"),
2998
3394
  expires_at: Timestamp.nullable(),
2999
- failure_reason: z29.string().max(256).nullable(),
3395
+ failure_reason: z30.string().max(256).nullable(),
3000
3396
  created_at: Timestamp,
3001
3397
  updated_at: Timestamp
3002
3398
  });
3003
- var IssueCardSchema = z29.object({
3399
+ var IssueCardSchema = z30.object({
3004
3400
  label: CardSchema.shape.label,
3005
3401
  load_micro_usd: MicroUsdField.min(CARD_MIN_LOAD_MICRO_USD).max(CARD_MAX_LOAD_MICRO_USD).multipleOf(CARD_LOAD_GRANULARITY_MICRO_USD)
3006
3402
  });
3007
3403
  var CardQuoteRequestSchema = IssueCardSchema.pick({ load_micro_usd: true });
3008
- var CardQuoteSchema = z29.object({
3009
- object: z29.literal("card_quote"),
3404
+ var CardQuoteSchema = z30.object({
3405
+ object: z30.literal("card_quote"),
3010
3406
  load_micro_usd: MicroUsdField,
3011
3407
  price_micro_usd: MicroUsdField,
3012
- brand: z29.string().nullable(),
3408
+ brand: z30.string().nullable(),
3013
3409
  min_load_micro_usd: MicroUsdField,
3014
3410
  max_load_micro_usd: MicroUsdField
3015
3411
  });
3016
- var CardCredentialsSchema = z29.object({
3017
- object: z29.literal("card_credentials"),
3412
+ var CardCredentialsSchema = z30.object({
3413
+ object: z30.literal("card_credentials"),
3018
3414
  card_id: idOf("vcd"),
3019
- number: z29.string().min(1),
3020
- pin: z29.string().nullable(),
3021
- cvv: z29.string().nullable(),
3022
- expiry: z29.string().nullable(),
3023
- url: z29.url().nullable(),
3024
- instructions: z29.string().nullable(),
3415
+ number: z30.string().min(1),
3416
+ pin: z30.string().nullable(),
3417
+ cvv: z30.string().nullable(),
3418
+ expiry: z30.string().nullable(),
3419
+ url: z30.url().nullable(),
3420
+ instructions: z30.string().nullable(),
3025
3421
  revealed_at: Timestamp
3026
3422
  });
3027
- var CardTransactionSchema = z29.object({
3423
+ var CardTransactionSchema = z30.object({
3028
3424
  id: idOf("vct"),
3029
- object: z29.literal("card_transaction"),
3425
+ object: z30.literal("card_transaction"),
3030
3426
  card_id: idOf("vcd"),
3031
3427
  amount_micro_usd: MicroUsdField,
3032
- merchant: z29.string().nullable(),
3033
- description: z29.string().nullable(),
3428
+ merchant: z30.string().nullable(),
3429
+ description: z30.string().nullable(),
3034
3430
  session_id: idOf("ses").nullable(),
3035
3431
  metadata: Metadata,
3036
3432
  created_at: Timestamp
3037
3433
  });
3038
- var LogCardTransactionSchema = z29.object({
3434
+ var LogCardTransactionSchema = z30.object({
3039
3435
  amount_micro_usd: MicroUsdField.positive(),
3040
- merchant: z29.string().max(256).optional(),
3041
- description: z29.string().max(1024).optional(),
3436
+ merchant: z30.string().max(256).optional(),
3437
+ description: z30.string().max(1024).optional(),
3042
3438
  metadata: Metadata.optional()
3043
3439
  });
3044
- var ListCardsSchema = z29.object({ status: CardStatusSchema.optional() });
3440
+ var ListCardsSchema = z30.object({ status: CardStatusSchema.optional() });
3045
3441
 
3046
3442
  // ../core/src/schema/proxy-trace.ts
3047
- import { z as z30 } from "zod";
3048
- var ProxyDialectSchema = z30.enum(["anthropic", "openai", "native"]);
3049
- var ProxyTraceContentScopeSchema = z30.enum(["full", "metadata", "object"]);
3050
- var TraceToolCall = z30.object({ id: z30.string().optional(), name: z30.string(), arguments: z30.string() });
3051
- var ProxyTraceRequestSchema = z30.object({
3052
- model: z30.string().optional(),
3443
+ import { z as z31 } from "zod";
3444
+ var ProxyDialectSchema = z31.enum(["anthropic", "openai", "native"]);
3445
+ var ProxyTraceContentScopeSchema = z31.enum(["full", "metadata", "object"]);
3446
+ var TraceToolCall = z31.object({ id: z31.string().optional(), name: z31.string(), arguments: z31.string() });
3447
+ var ProxyTraceRequestSchema = z31.object({
3448
+ model: z31.string().optional(),
3053
3449
  window: WindowSchema.optional(),
3054
- system: z30.string(),
3055
- messages: z30.array(
3056
- z30.looseObject({
3057
- role: z30.string(),
3058
- content: z30.string(),
3059
- tool_calls: z30.array(z30.looseObject({ id: z30.string(), name: z30.string() })).optional(),
3060
- tool_call_id: z30.string().optional()
3450
+ system: z31.string(),
3451
+ messages: z31.array(
3452
+ z31.looseObject({
3453
+ role: z31.string(),
3454
+ content: z31.string(),
3455
+ tool_calls: z31.array(z31.looseObject({ id: z31.string(), name: z31.string() })).optional(),
3456
+ tool_call_id: z31.string().optional()
3061
3457
  })
3062
3458
  ),
3063
- tools: z30.array(z30.object({ name: z30.string(), description: z30.string(), parameters: z30.record(z30.string(), z30.unknown()) })).optional(),
3064
- tool_schema_hash: z30.string().optional(),
3065
- max_output_tokens: z30.number().int().optional(),
3066
- tool_names: z30.array(z30.string()).optional()
3067
- });
3068
- var ProxyTraceResponseSchema = z30.object({
3069
- text: z30.string(),
3070
- reasoning: z30.string().optional(),
3071
- reasoning_details: z30.array(z30.unknown()).optional(),
3072
- tool_calls: z30.array(TraceToolCall),
3459
+ tools: z31.array(z31.object({ name: z31.string(), description: z31.string(), parameters: z31.record(z31.string(), z31.unknown()) })).optional(),
3460
+ tool_schema_hash: z31.string().optional(),
3461
+ max_output_tokens: z31.number().int().optional(),
3462
+ tool_names: z31.array(z31.string()).optional()
3463
+ });
3464
+ var ProxyTraceResponseSchema = z31.object({
3465
+ text: z31.string(),
3466
+ reasoning: z31.string().optional(),
3467
+ reasoning_details: z31.array(z31.unknown()).optional(),
3468
+ tool_calls: z31.array(TraceToolCall),
3073
3469
  /** A call that threw, was abandoned or never completed (ADR-0794): the reply is what streamed before. */
3074
- is_error: z30.literal(true).optional(),
3470
+ is_error: z31.literal(true).optional(),
3075
3471
  /** The error's class name — never its message — or `incomplete` for a stream that just stopped. */
3076
- error_class: z30.string().optional(),
3077
- partial: z30.literal(true).optional()
3472
+ error_class: z31.string().optional(),
3473
+ partial: z31.literal(true).optional()
3078
3474
  });
3079
- var Sha256 = z30.string().regex(/^[0-9a-f]{64}$/);
3080
- var ProxyCallTraceSchema = z30.object({
3475
+ var Sha256 = z31.string().regex(/^[0-9a-f]{64}$/);
3476
+ var ProxyCallTraceSchema = z31.object({
3081
3477
  /** The request id: also `x-request-id`, the reply's `id`, and the ledger entry's idempotency key. */
3082
3478
  id: idOf("req"),
3083
- object: z30.literal("proxy_call_trace"),
3479
+ object: z31.literal("proxy_call_trace"),
3084
3480
  dialect: ProxyDialectSchema,
3085
3481
  /** The principal that made the call (§17). An API key here is the answer to "who sent this". */
3086
3482
  actor: PrincipalSchema,
3087
3483
  /** The public model id the caller asked for. */
3088
- model: z30.string(),
3484
+ model: z31.string(),
3089
3485
  window: WindowSchema,
3090
3486
  /** The model the reply said served it — where `vetta/auto` resolves — or null if it named none. */
3091
- resolved_model: z30.string().nullable(),
3487
+ resolved_model: z31.string().nullable(),
3092
3488
  /**
3093
3489
  * The serving provider and the gateway's own generation id. Null on every row written before the
3094
3490
  * adapter stops dropping them (Track A); together they are what lets an upstream invoice line be
3095
3491
  * matched back to an organization, a key and a ledger entry.
3096
3492
  */
3097
- provider: z30.string().nullable(),
3098
- generation_id: z30.string().nullable(),
3099
- stop: z30.enum(["end_turn", "tool_use", "length"]).nullable(),
3493
+ provider: z31.string().nullable(),
3494
+ generation_id: z31.string().nullable(),
3495
+ stop: z31.enum(["end_turn", "tool_use", "length"]).nullable(),
3100
3496
  usage: TokenUsageSchema,
3101
3497
  /** What the customer was charged, µUSD. The ledger entry is the authority; this is its copy. */
3102
3498
  billed_micro_usd: MicroUsdField.nullable(),
3103
3499
  /** What the vendor said it cost, µUSD. A CROSS-CHECK, NEVER A DEBIT. */
3104
3500
  vendor_cost_micro_usd: MicroUsdField.nullable(),
3105
- duration_ms: z30.number().int().nonnegative().nullable(),
3501
+ duration_ms: z31.number().int().nonnegative().nullable(),
3106
3502
  content_scope: ProxyTraceContentScopeSchema,
3107
3503
  /** `proxy` — a `/v1/proxy/*` call; `harness` — a hosted harness's own model call (ADR-0762). */
3108
- source: z30.enum(["proxy", "harness"]),
3504
+ source: z31.enum(["proxy", "harness"]),
3109
3505
  /** The session the call belongs to: a harness call's, or a sandbox token's `sub` on the proxy. */
3110
- session_id: z30.string().nullable(),
3506
+ session_id: z31.string().nullable(),
3111
3507
  /**
3112
3508
  * The `seq` of the call's `span.model_request.end` event — or of its `.start` when the call failed
3113
3509
  * or its `.end` was withheld (ADR-0794). Null on the proxy, which writes no event.
3114
3510
  */
3115
- seq: z30.number().int().nullable(),
3511
+ seq: z31.number().int().nullable(),
3116
3512
  /** The board card the session was woken for (`session.metadata.board.card_id`), or null. */
3117
- board_card_id: z30.string().nullable(),
3513
+ board_card_id: z31.string().nullable(),
3118
3514
  /** The ids of the tool calls this reply made — the join to the `tool.*` events they caused. */
3119
- tool_call_ids: z30.array(z30.string()),
3515
+ tool_call_ids: z31.array(z31.string()),
3120
3516
  /** sha-256 of the canonical JSON of the tool schema array the model was offered, or null. */
3121
3517
  tool_schema_hash: Sha256.nullable(),
3122
3518
  request_sha256: Sha256,
3123
3519
  response_sha256: Sha256,
3124
3520
  /** The UTF-8 size of each stored body. */
3125
- request_bytes: z30.number().int().nonnegative(),
3126
- response_bytes: z30.number().int().nonnegative(),
3521
+ request_bytes: z31.number().int().nonnegative(),
3522
+ response_bytes: z31.number().int().nonnegative(),
3127
3523
  /** Inline in `full` scope — every new row. Null on a legacy `metadata` or `object` row. */
3128
3524
  request: ProxyTraceRequestSchema.nullable(),
3129
3525
  response: ProxyTraceResponseSchema.nullable(),
3130
3526
  /** Always false since ADR-0762 (nothing is cut); true only on rows from before it. */
3131
- truncated: z30.boolean(),
3527
+ truncated: z31.boolean(),
3132
3528
  created_at: Timestamp,
3133
3529
  /** When the reaper deletes this row. Null since ADR-0762: model I/O is kept, not expired. */
3134
3530
  expires_at: Timestamp.nullable()
3135
3531
  });
3136
3532
 
3137
3533
  // ../core/src/schema/review.ts
3138
- import { z as z31 } from "zod";
3139
- var ReviewDecisionSchema = z31.enum(["approve", "reject", "edit"]);
3140
- var Fields = z31.record(z31.string().max(100), z31.unknown()).nullable().optional();
3141
- var CreateReviewSchema = z31.object({
3534
+ import { z as z32 } from "zod";
3535
+ var ReviewDecisionSchema = z32.enum(["approve", "reject", "edit"]);
3536
+ var Fields = z32.record(z32.string().max(100), z32.unknown()).nullable().optional();
3537
+ var CreateReviewSchema = z32.object({
3142
3538
  decision: ReviewDecisionSchema,
3143
- reason: z31.string().max(4e3).nullable().optional(),
3144
- file_ids: z31.array(idOf("fil")).max(50).optional(),
3539
+ reason: z32.string().max(4e3).nullable().optional(),
3540
+ file_ids: z32.array(idOf("fil")).max(50).optional(),
3145
3541
  session_id: idOf("ses").optional(),
3146
- subject: z31.record(z31.string().max(100), z31.unknown()).optional(),
3542
+ subject: z32.record(z32.string().max(100), z32.unknown()).optional(),
3147
3543
  before: Fields,
3148
3544
  after: Fields
3149
3545
  });
3150
3546
 
3151
- // ../core/src/schema/mini-app.ts
3152
- import { z as z32 } from "zod";
3153
- var PAGE_BLOCKS = [
3154
- "Page",
3155
- "Section",
3156
- "Stack",
3157
- "Grid",
3158
- "Metric",
3159
- "LineChart",
3160
- "BarList",
3161
- "Progress",
3162
- "Roadmap",
3163
- "Schedule",
3164
- "Media",
3165
- "Text",
3166
- "Needs",
3167
- "Activity",
3168
- "Accounts",
3169
- "Posts",
3170
- "Answers",
3171
- "MediaLibrary"
3172
- ];
3173
- var MAX_PAGE_ELEMENTS = 48;
3174
- var MINI_APP_ICONS = ["grid", "list", "chart", "calendar", "play"];
3175
- var MiniAppIconSchema = z32.enum(MINI_APP_ICONS);
3176
- var SLUG = "[a-z][a-z0-9-]{0,39}";
3177
- var MiniAppSlugSchema = z32.string().regex(new RegExp(`^${SLUG}$`), "a slug is lowercase letters, digits and -");
3178
- var Place = z32.string().regex(new RegExp(`^/(board|connections|apps/${SLUG}(\\?page=${SLUG})?)$`), "a section links to /board, /connections or /apps/<slug>[?page=<slug>]");
3179
- var POSTS = ["waiting", "scheduled", "posted"];
3180
- var PostStatus = z32.enum(POSTS);
3181
- var PostLayout = z32.enum(["list", "row", "grid"]);
3182
- var PostStatuses = z32.union([PostStatus, z32.array(PostStatus).min(1).max(3).refine((all) => new Set(all).size === all.length, "each status once")]);
3183
- var PageBound = {
3184
- ...Bound,
3185
- board: bound(["roadmap"], { per_group: z32.number().int().min(1).max(5).default(5) }),
3186
- media: bound(["latest_media", "newest_media"], { count: z32.number().int().min(1).max(6).default(4) })
3187
- };
3188
- var PageResolved = {
3189
- ...Resolved,
3190
- board: z32.strictObject({ $source: z32.literal("roadmap"), per_group: z32.number().int(), groups: RoadmapViewSchema.shape.groups }),
3191
- media: z32.array(z32.strictObject({ id: z32.string(), kind: z32.enum(["image", "video"]) })).max(6)
3192
- };
3193
- function pageBlocks(slot) {
3194
- return {
3195
- Page: element("Page", {}, box, "The page itself, the root and only the root."),
3196
- Section: element("Section", { title: words(40), to: Place.optional(), hide_empty: z32.boolean().optional() }, box, "A titled part of the page; hidden when every block in it is empty, if asked."),
3197
- Needs: element("Needs", { label, needs: slot.needs }, leaf, "What waits on a person: approvals, questions, spent caps."),
3198
- Activity: element("Activity", { label, agents: slot.agents }, leaf, "The agents working or waiting, and on what."),
3199
- Accounts: element("Accounts", { accounts: slot.accounts }, leaf, "The template's networks: connected with a handle, or not."),
3200
- Posts: element(
3201
- "Posts",
3202
- { label, layout: PostLayout.optional(), posts: slot.posts },
3203
- leaf,
3204
- "Posts waiting on a person, scheduled, or posted; several statuses make one list. Drawn as rows (list, the default), one sideways row of cards (row), or a picture grid (grid)."
3205
- ),
3206
- Answers: element("Answers", { answers: slot.answers }, leaf, "The setup's answers in one line, linking to the setup."),
3207
- // No binding: the studio's gallery reads and pages the company's files itself (ADR-0987).
3208
- MediaLibrary: element("MediaLibrary", {}, leaf, "Every picture and clip the company's agents made, with filters, sort and a viewer.")
3209
- };
3210
- }
3211
- var OwnBound = pageBlocks({
3212
- needs: bound(["needs"], {}),
3213
- agents: bound(["agents_activity"], {}),
3214
- accounts: bound(["accounts"], {}),
3215
- posts: bound(["posts"], { status: PostStatuses, limit: z32.number().int().min(1).max(50).default(10) }),
3216
- answers: bound(["answers"], { keys: z32.array(Key).min(1).max(TEMPLATE_QUESTIONS_MAX) })
3217
- });
3218
- var Need = z32.object({
3219
- session_id: z32.string(),
3220
- agent_id: z32.string(),
3221
- agent: z32.string(),
3222
- since: Timestamp,
3223
- /** The chat's stored title, or `null`: the studio names it by when it began. */
3224
- title: z32.string().nullable(),
3225
- kind: z32.enum(["tool", "question", "budget"]),
3226
- /** The call or question it is held on; `null` for a spent cap. */
3227
- action: PendingActionSchema.nullable()
3228
- });
3229
- var Working = z32.object({
3230
- agent_id: z32.string(),
3231
- agent: z32.string(),
3232
- state: z32.enum(["working", "waiting"]),
3233
- session_id: z32.string().nullable(),
3234
- title: z32.string().nullable(),
3235
- at: Timestamp
3236
- });
3237
- var OwnResolved = pageBlocks({
3238
- needs: z32.strictObject({ $source: z32.literal("needs"), items: z32.array(Need) }),
3239
- agents: z32.strictObject({ $source: z32.literal("agents_activity"), agents: z32.array(Working) }),
3240
- accounts: z32.strictObject({
3241
- $source: z32.literal("accounts"),
3242
- accounts: z32.array(z32.object({ platform: SocialPlatformSchema, connected: z32.boolean(), handle: z32.string().nullable() }))
3243
- }),
3244
- posts: z32.strictObject({ $source: z32.literal("posts"), status: z32.union([PostStatus, z32.array(PostStatus)]), limit: z32.number().int(), posts: z32.array(PostSchema), more: z32.boolean() }),
3245
- answers: z32.strictObject({
3246
- $source: z32.literal("answers"),
3247
- keys: z32.array(z32.string()),
3248
- values: z32.array(z32.string()),
3249
- template: z32.object({ blueprint: z32.string(), template: z32.string() }).nullable()
3250
- })
3251
- });
3252
- var BoundBlocks = { ...catalog(PageBound), ...OwnBound };
3253
- var ResolvedBlocks = { ...catalog(PageResolved), ...OwnResolved };
3254
- var Unread = element("Unread", { of: z32.string(), label: z32.string().nullable(), reason: z32.string() }, leaf, "A block that could not be read.");
3255
- var B = BoundBlocks;
3256
- var PageSpecSchema = spec(
3257
- z32.discriminatedUnion(
3258
- "type",
3259
- [B.Page, B.Section, B.Stack, B.Grid, B.Metric, B.LineChart, B.BarList, B.Progress, B.Roadmap, B.Schedule, B.Media, B.Text, B.Needs, B.Activity, B.Accounts, B.Posts, B.Answers, B.MediaLibrary],
3260
- unknownComponent(PAGE_BLOCKS)
3261
- ),
3262
- "Page",
3263
- MAX_PAGE_ELEMENTS
3264
- );
3265
- var R = ResolvedBlocks;
3266
- var ResolvedPageElementSchema = z32.discriminatedUnion(
3267
- "type",
3268
- [R.Page, R.Section, R.Stack, R.Grid, R.Metric, R.LineChart, R.BarList, R.Progress, R.Roadmap, R.Schedule, R.Media, R.Text, R.Needs, R.Activity, R.Accounts, R.Posts, R.Answers, R.MediaLibrary, Unread],
3269
- unknownComponent(PAGE_BLOCKS)
3270
- );
3271
- var ResolvedPageSpecSchema = spec(ResolvedPageElementSchema, "Page", MAX_PAGE_ELEMENTS);
3272
- var unique = (items) => new Set(items.map((item) => item.slug)).size === items.length;
3273
- var MiniAppPageSchema = z32.strictObject({ slug: MiniAppSlugSchema, title: words(24), spec: PageSpecSchema });
3274
- var MiniAppDeclSchema = z32.strictObject({
3275
- slug: MiniAppSlugSchema,
3276
- name: words(40),
3277
- icon: MiniAppIconSchema,
3278
- pages: z32.array(MiniAppPageSchema).min(1).max(6).refine(unique, "each page's slug is its own")
3279
- });
3280
- var MiniAppDeclsSchema = z32.array(MiniAppDeclSchema).max(8).refine(unique, "each mini app's slug is its own");
3281
- var MiniAppSummarySchema = z32.object({
3282
- object: z32.literal("mini_app"),
3283
- slug: MiniAppSlugSchema,
3284
- name: z32.string(),
3285
- icon: MiniAppIconSchema,
3286
- pages: z32.array(z32.object({ slug: MiniAppSlugSchema, title: z32.string() })).min(1),
3287
- /** What it reads (`miniAppReads`). Absent from an older API: the Studio then claims nothing it cannot see. */
3288
- reads: z32.array(z32.string()).optional()
3289
- });
3290
- var MiniAppSchema = MiniAppSummarySchema.extend({
3291
- networks: z32.array(z32.object({ platform: SocialPlatformSchema, connected: z32.boolean().nullable() })),
3292
- page: MiniAppSlugSchema,
3293
- as_of: Timestamp,
3294
- timezone: z32.string().min(1),
3295
- spec: ResolvedPageSpecSchema
3547
+ // ../core/src/schema/ads.ts
3548
+ import { z as z33 } from "zod";
3549
+ var AdProviderSchema = z33.enum(["google"]);
3550
+ var AdCampaignStatusSchema = z33.enum(["enabled", "paused", "removed", "unknown"]);
3551
+ var AdCampaignSchema = z33.object({
3552
+ id: z33.string().min(1),
3553
+ object: z33.literal("ad_campaign"),
3554
+ provider: AdProviderSchema,
3555
+ connection_id: z33.string().min(1),
3556
+ customer_id: z33.string().regex(/^\d{10}$/),
3557
+ resource_name: z33.string().min(1),
3558
+ name: z33.string().min(1),
3559
+ type: z33.literal("search"),
3560
+ status: AdCampaignStatusSchema,
3561
+ /** Null for provider campaigns with no ad; list and status reads are campaign-based. */
3562
+ final_url: z33.url().nullable(),
3563
+ budget_micro_usd: MicroUsdField.nonnegative(),
3564
+ start_date: z33.iso.date(),
3565
+ end_date: z33.iso.date()
3566
+ });
3567
+ var AdCampaignInsightsSchema = z33.object({
3568
+ object: z33.literal("ad_campaign_insights"),
3569
+ provider: AdProviderSchema,
3570
+ campaign_id: z33.string().min(1),
3571
+ impressions: z33.number().int().nonnegative(),
3572
+ clicks: z33.number().int().nonnegative(),
3573
+ conversions: z33.number().nonnegative(),
3574
+ spend_micro_usd: MicroUsdField.nonnegative()
3296
3575
  });
3297
3576
 
3298
3577
  // ../core/src/session-token.ts
@@ -3302,19 +3581,30 @@ var encoder = new TextEncoder();
3302
3581
  // ../core/src/logo-svg.ts
3303
3582
  var MAX_BYTES = 16 * 1024;
3304
3583
 
3584
+ // ../core/src/brand-kit.ts
3585
+ import { z as z34 } from "zod";
3586
+ var HARMONIES = [165, 40, 120, 200];
3587
+ var BRAND_HARMONIES = HARMONIES.length;
3588
+ var BrandKitArgsSchema = z34.object({
3589
+ colour: z34.string().regex(/^#[0-9a-fA-F]{6}$/).describe("The brand's main colour, as #rrggbb \u2014 usually the logo's own. The palette is drawn around it."),
3590
+ harmony: z34.number().int().min(0).max(BRAND_HARMONIES - 1).optional().describe("Which accent the palette takes, 0\u20133. Change it when asked for other colours with the same main one."),
3591
+ typeface: z34.enum(BRAND_TYPEFACES).describe("grotesk (clean), serif (classic), rounded (friendly) or mono (technical)."),
3592
+ tagline: z34.string().max(80).optional().describe("One short line under the name. Leave it out when there is none.")
3593
+ });
3594
+
3305
3595
  // ../core/src/file-url.ts
3306
3596
  var encoder2 = new TextEncoder();
3307
3597
  var SESSION_FILE_URL_TTL_MS = 15 * 6e4;
3308
3598
 
3309
3599
  // src/define.ts
3310
- import { z as z35 } from "zod";
3600
+ import { z as z37 } from "zod";
3311
3601
 
3312
3602
  // src/roster.ts
3313
- import { z as z34 } from "zod";
3603
+ import { z as z36 } from "zod";
3314
3604
 
3315
3605
  // src/report.ts
3316
3606
  import { ApiError, send } from "@usenaive-sdk/vetta";
3317
- import { z as z33 } from "zod";
3607
+ import { z as z35 } from "zod";
3318
3608
  function message(error) {
3319
3609
  if (error instanceof ApiError && error.requestId !== "") return `${error.message} (request ${error.requestId})`;
3320
3610
  return error instanceof Error ? error.message : String(error);
@@ -3356,10 +3646,10 @@ async function absent(work) {
3356
3646
  throw error;
3357
3647
  }
3358
3648
  }
3359
- var PageShape = z33.object({
3360
- data: z33.array(z33.unknown()),
3361
- has_more: z33.boolean(),
3362
- next_cursor: z33.string().nullable()
3649
+ var PageShape = z35.object({
3650
+ data: z35.array(z35.unknown()),
3651
+ has_more: z35.boolean(),
3652
+ next_cursor: z35.string().nullable()
3363
3653
  });
3364
3654
  function rowLabel(row) {
3365
3655
  const { object, id } = row ?? {};
@@ -3391,17 +3681,17 @@ async function tombstone(name, current, remove, dryRun) {
3391
3681
  }
3392
3682
 
3393
3683
  // src/roster.ts
3394
- var NAME = z34.string().min(1);
3395
- var RosterNameSchema = z34.union([
3684
+ var NAME = z36.string().min(1);
3685
+ var RosterNameSchema = z36.union([
3396
3686
  NAME.transform((name) => ({ type: "agent", name })),
3397
- z34.object({ type: z34.literal("agent"), name: NAME, version: z34.number().int().positive().optional() }),
3398
- z34.object({ type: z34.literal("self") }),
3399
- z34.object({ type: z34.literal("advisor"), model: z34.string().min(1) })
3687
+ z36.object({ type: z36.literal("agent"), name: NAME, version: z36.number().int().positive().optional() }),
3688
+ z36.object({ type: z36.literal("self") }),
3689
+ z36.object({ type: z36.literal("advisor"), model: z36.string().min(1) })
3400
3690
  ]);
3401
- var DeclMultiagentField = z34.union([
3402
- z34.boolean(),
3403
- z34.object({ ...MultiagentSchema.shape, agents: z34.array(RosterNameSchema).min(1).max(20) }),
3404
- z34.null()
3691
+ var DeclMultiagentField = z36.union([
3692
+ z36.boolean(),
3693
+ z36.object({ ...MultiagentSchema.shape, agents: z36.array(RosterNameSchema).min(1).max(20) }),
3694
+ z36.null()
3405
3695
  ]);
3406
3696
  var hasRoster = (value) => typeof value === "object" && value !== null;
3407
3697
  var rosterNames = (roster) => roster.agents.flatMap((entry) => entry.type === "agent" ? [entry.name] : []);
@@ -3450,114 +3740,75 @@ async function patchRoster(client, decl, roster, existing, ids, dryRun, lines) {
3450
3740
  updated();
3451
3741
  }
3452
3742
 
3453
- // src/template.ts
3454
- var BLUEPRINTS = {
3455
- /** Clients, pipeline, deliverables, calendar. */
3456
- agency: { templates: ["blank", "seo-geo"], default: "blank" },
3457
- /**
3458
- * Post queue, accounts, calendar, analytics. The wire ids are frozen: `install.template` is a
3459
- * stored string on every provisioned org, so the display names moved ("Naive Short Form v1",
3460
- * "Naive Long Form v1", "Naive Clipping v1") and these did not.
3461
- *
3462
- * The first three are the base crews. The six after them are NICHE CHANNEL TEMPLATES (ADR-1115,
3463
- * ADR-1119): each is a thin template that reuses a base crew (`gaming-clips`/`news`/`sports` on
3464
- * `clipping`; `ufc`/`history`/`animal-feast` on `faceless`) and pins `naive/channel-template-<niche>`
3465
- * in every seat's `skills[]`. They are ordinary templates of this blueprint, so they publish, install
3466
- * and switch through the exact paths the base three do — the whole point of a template being data.
3467
- */
3468
- media: { templates: ["faceless", "longform", "clipping", "gaming-clips", "news", "sports", "ufc", "history", "animal-feast"] },
3469
- /** Pages, posts, forms, analytics — a published site with a crew behind it (`usenaive/web-blueprint`). */
3470
- web: { templates: ["publisher"], default: "publisher" }
3471
- };
3472
- var list = (names) => names.join(", ");
3473
- function chooseTemplate(blueprint, template) {
3474
- if (blueprint === void 0) {
3475
- if (template === void 0) return { ok: true, template: void 0 };
3476
- return {
3477
- ok: false,
3478
- message: `template "${template}" names no blueprint \u2014 a template belongs to one, so add \`blueprint: "\u2026"\` (${list(Object.keys(BLUEPRINTS))})`
3479
- };
3480
- }
3481
- const known = BLUEPRINTS[blueprint];
3482
- if (known === void 0) {
3483
- return { ok: false, message: `blueprint "${blueprint}" is not a blueprint \u2014 the blueprints are ${list(Object.keys(BLUEPRINTS))}` };
3484
- }
3485
- if (template === void 0) {
3486
- if (known.default !== void 0) return { ok: true, template: known.default };
3487
- return {
3488
- ok: false,
3489
- message: `blueprint "${blueprint}" needs a template \u2014 choose one of ${list(known.templates)}. Its crews spend money in different ways, so there is no default to fall back to.`
3490
- };
3491
- }
3492
- if (!known.templates.includes(template)) {
3493
- return { ok: false, message: `template "${template}" is not a template of blueprint "${blueprint}" \u2014 its templates are ${list(known.templates)}` };
3494
- }
3495
- return { ok: true, template };
3496
- }
3497
-
3498
3743
  // src/define.ts
3499
3744
  var BlueprintRefusal = class extends Error {
3500
3745
  name = "BlueprintRefusal";
3501
3746
  };
3502
- var EnvValueSchema = z35.union([
3503
- z35.string(),
3504
- z35.object({ from_env: z35.string().min(1) }),
3505
- z35.object({ generate: z35.literal(true) })
3747
+ var EnvValueSchema = z37.union([
3748
+ z37.string(),
3749
+ z37.object({ from_env: z37.string().min(1) }),
3750
+ z37.object({ generate: z37.literal(true) })
3506
3751
  ]);
3507
- var AppDeclSchema = z35.object({
3752
+ var AppDeclSchema = z37.object({
3508
3753
  /** Becomes a hostname, so the grammar is the platform's `APP_NAME` (a DNS label). */
3509
- name: z35.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
3754
+ name: z37.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
3510
3755
  type: AppTypeSchema,
3511
- description: z35.string().optional(),
3756
+ description: z37.string().optional(),
3512
3757
  /** A directory whose files are collected and shipped as the app's file-map deployment. */
3513
- deploy_dir: z35.string().min(1).optional(),
3758
+ deploy_dir: z37.string().min(1).optional(),
3514
3759
  /** The path the app itself serves MCP on (§29.5); `fullstack` only. Absent means none. */
3515
3760
  mcp: AppMcpPathSchema.optional(),
3516
3761
  /** Written as the app's write-only secrets (§29.2) on every apply; names follow the platform's `ENV_NAME`. */
3517
- env: z35.record(z35.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
3762
+ env: z37.record(z37.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
3518
3763
  /** An install may not leave this app out of its `selection` (§31.2). Absent means it may. */
3519
- required: z35.boolean().optional(),
3764
+ required: z37.boolean().optional(),
3520
3765
  // core-gaps: U8-database
3521
3766
  /** SQL files applied in order to the app's database after it is provisioned (§37); `fullstack` only. */
3522
- migrations: z35.array(z35.string().min(1)).optional(),
3767
+ migrations: z37.array(z37.string().min(1)).optional(),
3523
3768
  // core-gaps: storage-stock
3524
3769
  /** Buckets the app's object store must hold (§38.2); `fullstack` only. `public` defaults to false. */
3525
- buckets: z35.array(CreateBucketSchema).optional()
3770
+ buckets: z37.array(CreateBucketSchema).optional()
3526
3771
  });
3527
- var ScheduleDeclSchema = z35.object({
3528
- cron: z35.string().min(1),
3529
- timezone: z35.string().min(1).optional(),
3772
+ var ScheduleDeclSchema = z37.object({
3773
+ cron: z37.string().min(1),
3774
+ timezone: z37.string().min(1).optional(),
3530
3775
  /** The message every fire opens its session with (`input_template` on the wire). */
3531
- input: z35.string().min(1),
3776
+ input: z37.string().min(1),
3777
+ /**
3778
+ * What a fire does, in a few words a person reads ("Weekly report") — the launch card's line for it
3779
+ * and the receipt's (`canonical-spec §31.3`, ADR-1172). Printed, never provisioned; absent, the
3780
+ * platform reads the opening of `input`.
3781
+ */
3782
+ summary: z37.string().min(1).max(48).optional(),
3532
3783
  budget_micro_usd: MicroUsdField.nonnegative(),
3533
- identity: z35.string().min(1).optional(),
3534
- enabled: z35.boolean().optional()
3784
+ identity: z37.string().min(1).optional(),
3785
+ enabled: z37.boolean().optional()
3535
3786
  });
3536
3787
  var ToolsDeclSchema = ToolsetSchema;
3537
- var AgentDeclSchema = z35.object({
3538
- name: z35.string().min(1),
3539
- model: z35.string().min(1),
3788
+ var AgentDeclSchema = z37.object({
3789
+ name: z37.string().min(1),
3790
+ model: z37.string().min(1),
3540
3791
  budget: BudgetSchema,
3541
- description: z35.string().optional(),
3792
+ description: z37.string().optional(),
3542
3793
  /** Two or three words the studio prints beside the name (§31.5) — "Head of content", not a sentence. */
3543
- role: z35.string().min(1).optional(),
3794
+ role: z37.string().min(1).optional(),
3544
3795
  /** An install may not leave this agent out of its `selection` (§31.2). Absent means it may. */
3545
- required: z35.boolean().optional(),
3546
- system: z35.string().optional(),
3796
+ required: z37.boolean().optional(),
3797
+ system: z37.string().optional(),
3547
3798
  tools: ToolsDeclSchema.optional(),
3548
- skills: z35.array(SkillRefSchema).optional(),
3549
- mcp_servers: z35.array(McpServerSchema).optional(),
3799
+ skills: z37.array(SkillRefSchema).optional(),
3800
+ mcp_servers: z37.array(McpServerSchema).optional(),
3550
3801
  /** The rest of the runtime's agent config (§31.6), each the core schema; absent means the route's default and never drift. */
3551
3802
  window: WindowSchema.optional(),
3552
3803
  /** A roster names crew members by declared *name*; `up` resolves them to `agt_` ids in a second pass (`roster.ts`). */
3553
3804
  multiagent: DeclMultiagentField.optional(),
3554
3805
  output_schema: JsonSchemaDocument.nullable().optional(),
3555
- structured_output_required: z35.boolean().optional(),
3806
+ structured_output_required: z37.boolean().optional(),
3556
3807
  metadata: Metadata.optional(),
3557
3808
  /** Declared app *names*; `up` resolves them to `app_` ids in `tools.configs.apps` (§29.3). */
3558
- allowed_apps: z35.array(z35.string()).optional(),
3809
+ allowed_apps: z37.array(z37.string()).optional(),
3559
3810
  /** A declared identity *name*; `up` attaches it after the agent upsert (§22). */
3560
- identity: z35.string().min(1).optional(),
3811
+ identity: z37.string().min(1).optional(),
3561
3812
  /**
3562
3813
  * Who this agent may `send_to_agent` (§31.7, §28.12): `true` (anyone in the organization),
3563
3814
  * `false` (nobody), `"team"` (its `multiagent` roster), or declared agent *names*, checked
@@ -3565,7 +3816,7 @@ var AgentDeclSchema = z35.object({
3565
3816
  */
3566
3817
  handoffs: HandoffsField.optional(),
3567
3818
  /** The agent's deployments as a complete set: declared → owned, and the rest are pruned (ADR-0355). */
3568
- schedules: z35.array(ScheduleDeclSchema).optional(),
3819
+ schedules: z37.array(ScheduleDeclSchema).optional(),
3569
3820
  /**
3570
3821
  * The first thing this agent reads, once, on the apply that **creates** it (`canonical-spec
3571
3822
  * §31.4`). It is what turns a provisioned crew into a crew that has started working.
@@ -3578,73 +3829,86 @@ var AgentDeclSchema = z35.object({
3578
3829
  * repeatedly and unattended while an intake spends once, at an apply a person is watching. Absent
3579
3830
  * means the agent's own `budget` governs.
3580
3831
  */
3581
- intake: z35.object({ message: z35.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
3832
+ intake: z37.object({ message: z37.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
3582
3833
  });
3583
- var CredentialDeclSchema = z35.object({
3834
+ var CredentialDeclSchema = z37.object({
3584
3835
  kind: VaultCredentialKindSchema,
3585
- key: z35.string().min(1).max(128),
3836
+ key: z37.string().min(1).max(128),
3586
3837
  /** The one exact destination host an `env_var` is bound to. */
3587
- host: z35.string().min(1).optional(),
3838
+ host: z37.string().min(1).optional(),
3588
3839
  /** The MCP server URL a `static_bearer` / `mcp_oauth` token is matched to. */
3589
- mcp_server_url: z35.url().optional(),
3590
- value: z35.object({ from_env: z35.string().min(1) })
3840
+ mcp_server_url: z37.url().optional(),
3841
+ value: z37.object({ from_env: z37.string().min(1) })
3591
3842
  });
3592
- var VaultDeclSchema = z35.object({
3843
+ var VaultDeclSchema = z37.object({
3593
3844
  name: VaultSchema.shape.display_name,
3594
- identity: z35.string().min(1).optional(),
3595
- credentials: z35.array(CredentialDeclSchema)
3845
+ identity: z37.string().min(1).optional(),
3846
+ credentials: z37.array(CredentialDeclSchema)
3596
3847
  });
3597
- var SkillDeclSchema = z35.object({
3598
- slug: z35.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
3599
- file: z35.string().min(1)
3848
+ var SkillDeclSchema = z37.object({
3849
+ slug: z37.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
3850
+ file: z37.string().min(1)
3600
3851
  });
3601
3852
  var LegalDeclSchema = CreateLegalCompanySchema.pick({
3602
3853
  state: true,
3603
3854
  name_options: true,
3604
3855
  naics_code: true,
3605
3856
  description: true
3606
- }).extend({ label: z35.string().min(1).max(128) });
3857
+ }).extend({ label: z37.string().min(1).max(128) });
3607
3858
  var WalletDeclSchema = CreateWalletSchema.or(
3608
- z35.array(CreateWalletSchema).refine(
3609
- (list2) => new Set(list2.map((w) => w.network ?? DEFAULT_WALLET_NETWORK)).size === list2.length,
3859
+ z37.array(CreateWalletSchema).refine(
3860
+ (list) => new Set(list.map((w) => w.network ?? DEFAULT_WALLET_NETWORK)).size === list.length,
3610
3861
  { message: "one wallet per network" }
3611
3862
  )
3612
3863
  );
3613
3864
  var CardDeclSchema = IssueCardSchema;
3614
3865
  var IdentityDeclSchema = IdentitySchema.pick({ name: true, description: true }).partial({ description: true }).extend({
3615
- legal: z35.array(LegalDeclSchema).optional(),
3866
+ legal: z37.array(LegalDeclSchema).optional(),
3616
3867
  wallet: WalletDeclSchema.optional(),
3617
- cards: z35.array(CardDeclSchema).optional()
3618
- });
3619
- var RemovedSchema = z35.object({
3620
- apps: z35.array(z35.string().min(1)).default([]),
3621
- agents: z35.array(z35.string().min(1)).default([]),
3622
- skills: z35.array(z35.string().min(1)).default([]),
3623
- identities: z35.array(z35.string().min(1)).default([]),
3624
- vaults: z35.array(z35.string().min(1)).default([])
3625
- });
3626
- var KeptSchema = z35.object({ agents: z35.array(z35.string().min(1)).default([]) });
3627
- var TaskDeclSchema = z35.object({
3628
- key: z35.string().min(1),
3629
- title: z35.string().min(1).max(200),
3630
- body: z35.string().max(8192).optional(),
3631
- assignee: z35.string().min(1).optional(),
3632
- blocked_by: z35.array(z35.string().min(1)).optional()
3633
- });
3634
- var ProjectSchema = z35.object({
3635
- name: z35.string().min(1),
3868
+ cards: z37.array(CardDeclSchema).optional()
3869
+ });
3870
+ var RemovedSchema = z37.object({
3871
+ apps: z37.array(z37.string().min(1)).default([]),
3872
+ agents: z37.array(z37.string().min(1)).default([]),
3873
+ skills: z37.array(z37.string().min(1)).default([]),
3874
+ identities: z37.array(z37.string().min(1)).default([]),
3875
+ vaults: z37.array(z37.string().min(1)).default([])
3876
+ });
3877
+ var KeptSchema = z37.object({ agents: z37.array(z37.string().min(1)).default([]) });
3878
+ var TaskDeclSchema = z37.object({
3879
+ key: z37.string().min(1),
3880
+ title: z37.string().min(1).max(200),
3881
+ body: z37.string().max(8192).optional(),
3882
+ assignee: z37.string().min(1).optional(),
3883
+ blocked_by: z37.array(z37.string().min(1)).optional()
3884
+ });
3885
+ var ProjectSchema = z37.object({
3886
+ name: z37.string().min(1),
3636
3887
  /** The machine this project runs: its repo, its screens, its `/api/*` (`template.ts`). */
3637
- blueprint: z35.string().min(1).optional(),
3888
+ blueprint: z37.string().min(1).optional(),
3638
3889
  /** Which of that blueprint's templates provides the crew; a blueprint with a default may omit it. */
3639
- template: z35.string().min(1).optional(),
3890
+ template: z37.string().min(1).optional(),
3640
3891
  /**
3641
3892
  * What a person calls this template, one line on what its crew does, and the networks it
3642
3893
  * publishes to (`canonical-spec §31.5`). Printed on the artifact and never provisioned: where the
3643
3894
  * crew posts is the accounts connected to its persona, not this list.
3644
3895
  */
3645
- title: z35.string().min(1).max(80).optional(),
3646
- description: z35.string().min(1).max(280).optional(),
3647
- platforms: z35.array(SocialPlatformSchema).optional(),
3896
+ title: z37.string().min(1).max(80).optional(),
3897
+ description: z37.string().min(1).max(280).optional(),
3898
+ platforms: z37.array(SocialPlatformSchema).optional(),
3899
+ /**
3900
+ * The first week in the template's own words, for the launch card (`canonical-spec §31.5`,
3901
+ * ADR-1172): `day_one` is what Day 1 comes to ("Set up and publish the first post"), `every_day`
3902
+ * what each day after it carries ("New posts · Performance analysis"), and `after` what the card's
3903
+ * "Day 8 on" line says follows the week ("The week repeats · the CEO finds sponsors…"). Printed,
3904
+ * never provisioned; absent, the card reads the seeded cards and the timers, and "Day 8 on" says
3905
+ * only "The week repeats".
3906
+ */
3907
+ roadmap: z37.object({
3908
+ day_one: z37.string().min(1).max(60).optional(),
3909
+ every_day: z37.string().min(1).max(60).optional(),
3910
+ after: z37.string().min(1).max(80).optional()
3911
+ }).optional(),
3648
3912
  /**
3649
3913
  * The company's mini apps (`canonical-spec §50`): each a name, an icon and pages of the platform's
3650
3914
  * blocks — data only, checked with the platform's catalog here and again when a page is read. The
@@ -3662,21 +3926,21 @@ var ProjectSchema = z35.object({
3662
3926
  *
3663
3927
  * **Configuration only.** A secret is a vault credential or an app secret; neither is an answer.
3664
3928
  */
3665
- questions: z35.array(QuestionFieldSchema).default([]),
3666
- skills: z35.array(SkillDeclSchema).default([]),
3667
- identities: z35.array(IdentityDeclSchema).default([]),
3668
- vaults: z35.array(VaultDeclSchema).default([]),
3669
- apps: z35.array(AppDeclSchema).default([]),
3670
- agents: z35.array(AgentDeclSchema).default([]),
3929
+ questions: z37.array(QuestionFieldSchema).default([]),
3930
+ skills: z37.array(SkillDeclSchema).default([]),
3931
+ identities: z37.array(IdentityDeclSchema).default([]),
3932
+ vaults: z37.array(VaultDeclSchema).default([]),
3933
+ apps: z37.array(AppDeclSchema).default([]),
3934
+ agents: z37.array(AgentDeclSchema).default([]),
3671
3935
  /**
3672
3936
  * The agents this template creates PER CLIENT the operator signs (`canonical-spec §31.1`) —
3673
3937
  * printed on the artifact so a person sees the whole company, never provisioned by an apply,
3674
3938
  * because the apply does not know the clients yet. Names only: a model and a budget are the
3675
3939
  * crew's business at the moment a client is signed, not the declaration's.
3676
3940
  */
3677
- crew_per_client: z35.array(z35.object({ name: z35.string().min(1), role: z35.string().min(1).optional(), description: z35.string().optional() })).optional(),
3941
+ crew_per_client: z37.array(z37.object({ name: z37.string().min(1), role: z37.string().min(1).optional(), description: z37.string().optional() })).optional(),
3678
3942
  /** The crew's first work, as cards on the organization's board rather than N private intakes (§31.11). */
3679
- tasks: z35.array(TaskDeclSchema).default([]),
3943
+ tasks: z37.array(TaskDeclSchema).default([]),
3680
3944
  removed: RemovedSchema.default({ apps: [], agents: [], skills: [], identities: [], vaults: [] }),
3681
3945
  kept: KeptSchema.default({ agents: [] })
3682
3946
  });
@@ -4419,7 +4683,7 @@ async function reconcileSchedules(client, agent, declared, live, identityIds, dr
4419
4683
  // `<agent> @ <cron>` says WHEN a timer runs and nothing about what it does, so the dashboard's
4420
4684
  // opening message could only ever draw a timetable from these lines. The brief's first
4421
4685
  // sentence is what turns that timetable into a roadmap (§29.6).
4422
- summary: brief(decl.input)
4686
+ summary: decl.summary ?? brief(decl.input)
4423
4687
  }))
4424
4688
  );
4425
4689
  if (agent.action === "refused") return;
@@ -4530,6 +4794,7 @@ async function reportLegal(client, decls, identityId, skipped) {
4530
4794
  }
4531
4795
 
4532
4796
  // src/tasks.ts
4797
+ import { ApiError as ApiError2 } from "@usenaive-sdk/vetta";
4533
4798
  var ORCHESTRATOR_MARKER = "orchestrator";
4534
4799
  var CEO_LABEL = "CEO";
4535
4800
  var CEO_DETAIL = "Hires and directs the crew";
@@ -4561,7 +4826,13 @@ async function ensureOrchestrator(client, existing, members, dryRun) {
4561
4826
  return { name: CEO_LABEL, action: "created", id: made.id };
4562
4827
  }
4563
4828
  if (live !== null && !changed(team, live)) return { name: current.name, action: "unchanged", id: current.id };
4564
- if (!dryRun) await client.agents.update(current.id, { multiagent: team });
4829
+ if (dryRun) return { name: current.name, action: "updated", id: current.id };
4830
+ try {
4831
+ await client.agents.update(current.id, { multiagent: team });
4832
+ } catch (error) {
4833
+ if (!(error instanceof ApiError2 && error.status === 403)) throw error;
4834
+ return { name: current.name, action: "unchanged", id: current.id, reason: `crew not seated on its roster: ${error.message} (request ${error.requestId})` };
4835
+ }
4565
4836
  return { name: current.name, action: "updated", id: current.id };
4566
4837
  }
4567
4838
  async function seedTasks(client, config, existing, agents, dryRun, into, skipped) {