@usenaive-sdk/blueprints 0.4.0 → 0.6.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
@@ -203,6 +203,10 @@ var AUDIT_ACTIONS_P3 = [
203
203
  "app.db_queried",
204
204
  /** A ticket was minted that lets one browser past an app's own operator gate (§29.7). */
205
205
  "app.entered",
206
+ /** The dashboard password was read — the one audited reveal of an app secret (§29.7, ADR-0656). */
207
+ "app.access_read",
208
+ /** The dashboard password was regenerated (and a lost `DASHBOARD_TOKEN` copy repaired). */
209
+ "app.access_rotated",
206
210
  /** A link was minted that serves one file's bytes to anyone holding it, for seven days (§40). */
207
211
  "file.linked",
208
212
  "blueprint.installed",
@@ -411,6 +415,19 @@ var AuditEntrySchema = z3.object({
411
415
  var BROWSER_MAX_TIMEOUT_MINUTES = 360;
412
416
  var BROWSER_REGIONS = ["us-west", "us-east", "eu-central", "ap-southeast"];
413
417
  var BROWSER_OS = ["windows", "mac", "linux", "mobile", "tablet"];
418
+ var BROWSER_TOOL_ACTIONS = [
419
+ "goto",
420
+ "click",
421
+ "type",
422
+ "extract",
423
+ "act",
424
+ "observe",
425
+ "links",
426
+ "screenshot",
427
+ "login",
428
+ "signup",
429
+ "save_context"
430
+ ];
414
431
  var BrowserOptionsSchema = z4.object({
415
432
  allowed_domains: z4.array(z4.string().min(1)).min(1),
416
433
  timeout_minutes: z4.number().int().min(1).max(BROWSER_MAX_TIMEOUT_MINUTES).default(15),
@@ -426,7 +443,8 @@ var BrowserOptionsSchema = z4.object({
426
443
  context_name: z4.string().min(1).max(64).optional(),
427
444
  persist_context: z4.boolean().default(false),
428
445
  human_login: z4.boolean().default(false),
429
- proxy: z4.boolean().default(false)
446
+ proxy: z4.boolean().default(false),
447
+ ask_actions: z4.array(z4.enum(BROWSER_TOOL_ACTIONS)).default(["signup"])
430
448
  }).refine((options) => !(options.proxy && options.allowed_domains.includes("*")), {
431
449
  error: "a proxied browser needs a bounded allow-list, not *",
432
450
  path: ["proxy"]
@@ -590,6 +608,9 @@ function normaliseMultiagent(value) {
590
608
  if (value === false || value === null) return null;
591
609
  return value;
592
610
  }
611
+ var HandoffsField = z5.union([z5.boolean(), z5.literal("team"), z5.array(z5.string().min(1)).max(50)]);
612
+ var handoffsOf = (config) => config.handoffs ?? true;
613
+ var handoffsEnabled = (handoffs) => handoffs === true || handoffs === "team" || handoffs !== false && handoffs.length > 0;
593
614
  var agentConfigShape = {
594
615
  model: z5.string(),
595
616
  window: WindowSchema,
@@ -598,6 +619,8 @@ var agentConfigShape = {
598
619
  mcp_servers: z5.array(McpServerSchema),
599
620
  skills: z5.array(SkillRefSchema),
600
621
  multiagent: MultiagentField,
622
+ /** Optional on the type so a version minted before §28.15 still parses; read it through `handoffsOf`. */
623
+ handoffs: HandoffsField.optional(),
601
624
  budget: BudgetSchema,
602
625
  output_schema: JsonSchemaDocument.nullable(),
603
626
  structured_output_required: z5.boolean(),
@@ -765,7 +788,11 @@ var SessionSchema = z6.object({
765
788
  var SendMessageSchema = z6.object({
766
789
  message: z6.string(),
767
790
  interrupt: z6.boolean().optional(),
791
+ queue: z6.boolean().optional(),
768
792
  idempotency_key: z6.string().optional()
793
+ }).refine((body) => !(body.interrupt === true && body.queue === true), {
794
+ message: "a send is either an interrupt or queued, not both",
795
+ path: ["queue"]
769
796
  });
770
797
  var SendAcceptedSchema = z6.object({
771
798
  session_id: z6.string(),
@@ -869,11 +896,16 @@ var BoardCardSchema = z8.object({
869
896
  object: z8.literal("board_card"),
870
897
  board_id: idOf("brd"),
871
898
  title: z8.string().min(1),
899
+ /** The brief — what was asked. */
872
900
  body: z8.string(),
901
+ /** What the holder wrote back; a `done` carries one. */
902
+ note: z8.string().nullable(),
873
903
  status: BoardStatusSchema,
874
904
  assignee: z8.string().nullable(),
875
905
  /** The cards this one waits on. A `blocked` card with an empty list is stuck on the world. */
876
906
  blocked_by: z8.array(idOf("crd")),
907
+ woken_session_id: idOf("ses").nullable(),
908
+ reported_status: BoardStatusSchema.nullable(),
877
909
  created_at: Timestamp,
878
910
  updated_at: Timestamp
879
911
  });
@@ -1238,6 +1270,12 @@ var AppSchema = z13.object({
1238
1270
  error: z13.string().nullable(),
1239
1271
  /** Where the app serves MCP, or `null`. The bearer token for it is a server column. */
1240
1272
  mcp: AppMcpPathSchema.nullable(),
1273
+ /**
1274
+ * Is this a gated blueprint dashboard — one the Studio opens through `/apps/{id}/open` rather
1275
+ * than linking its `url` (`§29.1`)? True when the platform holds the app's `DASHBOARD_TOKEN`
1276
+ * or a secret of that name exists on the app; derived on read, never stored.
1277
+ */
1278
+ dashboard: z13.boolean(),
1241
1279
  created_at: Timestamp
1242
1280
  });
1243
1281
  var AppDeploymentStatusSchema = z13.enum(["queued", "building", "ready", "error"]);
@@ -1269,6 +1307,11 @@ var AppEntrySchema = z13.object({
1269
1307
  url: z13.string(),
1270
1308
  ticket: z13.string()
1271
1309
  });
1310
+ var AppAccessSchema = z13.object({
1311
+ object: z13.literal("app_access"),
1312
+ url: z13.string().nullable(),
1313
+ password: z13.string().nullable()
1314
+ });
1272
1315
  var AppDomainStatusSchema = z13.enum(["pending", "connected", "failed"]);
1273
1316
  var AppDomainSchema = z13.object({
1274
1317
  object: z13.literal("app_domain"),
@@ -1303,6 +1346,8 @@ var BlueprintReportSchema = z14.object({
1303
1346
  agents: z14.array(ResourceReportSchema),
1304
1347
  schedules: z14.array(ResourceReportSchema),
1305
1348
  intake: z14.array(ResourceReportSchema),
1349
+ /** One line per declared task (§31.11), `id` the card's `crd_`. Defaulted so older rows parse. */
1350
+ tasks: z14.array(ResourceReportSchema).default([]),
1306
1351
  skipped: z14.array(z14.string()),
1307
1352
  deselected: z14.array(z14.string()).default([])
1308
1353
  });
@@ -1392,231 +1437,301 @@ var ProjectContextSchema = z14.object({
1392
1437
  });
1393
1438
 
1394
1439
  // ../core/src/schema/blueprint.ts
1440
+ import { z as z16 } from "zod";
1441
+
1442
+ // ../core/src/schema/social.ts
1395
1443
  import { z as z15 } from "zod";
1396
- var BlueprintScheduleSchema = z15.object({
1397
- agent: z15.string().min(1),
1398
- cron: z15.string().min(1),
1399
- timezone: z15.string().nullable(),
1444
+ var SOCIAL_PLATFORMS = [
1445
+ "bluesky",
1446
+ "facebook",
1447
+ "instagram",
1448
+ "linkedin",
1449
+ "mastodon",
1450
+ "pinterest",
1451
+ "reddit",
1452
+ "threads",
1453
+ "tiktok",
1454
+ "x",
1455
+ "youtube"
1456
+ ];
1457
+ var SOCIAL_TEXT_PLATFORMS = [
1458
+ "bluesky",
1459
+ "facebook",
1460
+ "linkedin",
1461
+ "mastodon",
1462
+ "threads",
1463
+ "x"
1464
+ ];
1465
+ var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
1466
+ var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
1467
+ var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
1468
+ var SocialVisibilitySchema = z15.enum(SOCIAL_VISIBILITIES);
1469
+ var SOCIAL_VISIBILITY_RULE = `visibility is ${SOCIAL_VISIBILITIES.join(", ")} and only ${SOCIAL_VISIBILITY_PLATFORMS.join(" and ")} accept it; omit it and the post publishes at the account's own default, which on a video channel is normally public`;
1470
+ var SocialPlatformSchema = z15.enum(SOCIAL_PLATFORMS);
1471
+ var SocialTextPlatformSchema = z15.enum(SOCIAL_TEXT_PLATFORMS);
1472
+ var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
1473
+ var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
1474
+ var SOCIAL_PLATFORM_RULE = `${SOCIAL_TEXT_PLATFORMS.join(", ")} take a text-only post; ${SOCIAL_MEDIA_PLATFORMS.join(", ")} may be named only when the post carries media_urls or file_ids; ${SOCIAL_PLATFORMS.filter((platform) => !isText(platform) && !isMedia(platform)).join(", ")} cannot be posted to`;
1475
+ var SocialAccountSchema = z15.object({
1476
+ id: z15.string().min(1),
1477
+ object: z15.literal("social_account"),
1478
+ identity_id: idOf("idn"),
1479
+ platform: SocialPlatformSchema,
1480
+ username: z15.string().nullable(),
1481
+ display_name: z15.string().nullable(),
1482
+ avatar_url: z15.url().nullable(),
1483
+ connected_at: Timestamp.nullable()
1484
+ });
1485
+ var SocialPostStatusSchema = z15.enum([
1486
+ "draft",
1487
+ "scheduled",
1488
+ "processing",
1489
+ "posted",
1490
+ "failed",
1491
+ "deleted"
1492
+ ]);
1493
+ var SocialPostSchema = z15.object({
1494
+ id: z15.string().min(1),
1495
+ object: z15.literal("social_post"),
1496
+ identity_id: idOf("idn"),
1497
+ title: z15.string(),
1498
+ platforms: z15.array(SocialPlatformSchema),
1499
+ status: SocialPostStatusSchema,
1500
+ scheduled_at: Timestamp.nullable(),
1501
+ posted_at: Timestamp.nullable(),
1502
+ error: z15.string().nullable()
1503
+ });
1504
+ var SocialUploadSchema = z15.object({
1505
+ id: z15.string().min(1),
1506
+ object: z15.literal("social_upload"),
1507
+ identity_id: idOf("idn"),
1508
+ type: z15.enum(["image", "video", "document"]),
1509
+ url: z15.url().nullable()
1510
+ });
1511
+ var SocialAnalyticsSchema = z15.object({
1512
+ object: z15.literal("social_analytics"),
1513
+ identity_id: idOf("idn"),
1514
+ resource_id: z15.string().min(1),
1515
+ platform: SocialPlatformSchema.nullable(),
1516
+ data: z15.unknown()
1517
+ });
1518
+ var SocialCommentSchema = z15.object({
1519
+ id: z15.string().min(1),
1520
+ object: z15.literal("social_comment"),
1521
+ identity_id: idOf("idn"),
1522
+ post_id: z15.string().min(1),
1523
+ platforms: z15.array(SocialPlatformSchema),
1524
+ status: SocialPostStatusSchema,
1525
+ posted_at: Timestamp.nullable(),
1526
+ data: z15.unknown()
1527
+ });
1528
+
1529
+ // ../core/src/schema/blueprint.ts
1530
+ var BlueprintScheduleSchema = z16.object({
1531
+ agent: z16.string().min(1),
1532
+ cron: z16.string().min(1),
1533
+ timezone: z16.string().nullable(),
1400
1534
  /** The message each fire opens its session with — the sentence worth printing. */
1401
- input: z15.string().min(1),
1535
+ input: z16.string().min(1),
1402
1536
  budget_micro_usd: MicroUsdField.nonnegative()
1403
1537
  });
1404
1538
  var BlueprintBudgetSchema = BlueprintScheduleSchema.pick({ agent: true, cron: true, budget_micro_usd: true });
1405
- var BlueprintCrewSchema = z15.object({
1406
- name: z15.string().min(1),
1407
- description: z15.string().nullable(),
1408
- model: z15.string().min(1),
1409
- briefed: z15.boolean(),
1410
- intake: z15.string().nullable().optional(),
1539
+ var BlueprintCrewSchema = z16.object({
1540
+ name: z16.string().min(1),
1541
+ description: z16.string().nullable(),
1542
+ model: z16.string().min(1),
1543
+ briefed: z16.boolean(),
1544
+ intake: z16.string().nullable().optional(),
1411
1545
  /** What the first session may spend: the intake's own cap, else the agent's (§31.4). Set iff `briefed`. */
1412
1546
  intake_micro_usd: MicroUsdField.nonnegative().optional(),
1413
- role: z15.string().min(1).optional(),
1414
- skills: z15.array(SkillRefSchema).optional(),
1415
- tools: z15.array(z15.string().min(1)).optional(),
1416
- required: z15.boolean().optional()
1547
+ role: z16.string().min(1).optional(),
1548
+ skills: z16.array(SkillRefSchema).optional(),
1549
+ tools: z16.array(z16.string().min(1)).optional(),
1550
+ required: z16.boolean().optional()
1417
1551
  });
1418
- var BlueprintAppSchema = z15.object({
1419
- name: z15.string().min(1),
1552
+ var BlueprintAppSchema = z16.object({
1553
+ name: z16.string().min(1),
1420
1554
  type: AppTypeSchema,
1421
- description: z15.string().nullable(),
1422
- mcp: z15.string().nullable().optional(),
1423
- tools: z15.array(z15.string().min(1)).optional(),
1555
+ description: z16.string().nullable(),
1556
+ mcp: z16.string().nullable().optional(),
1557
+ tools: z16.array(z16.string().min(1)).optional(),
1424
1558
  /** Whether an install may deselect it (§31.2). Optional: the rollout argument above. */
1425
- required: z15.boolean().optional()
1559
+ required: z16.boolean().optional()
1560
+ });
1561
+ var BlueprintIdentityConnectionsSchema = z16.object({
1562
+ social: z16.object({
1563
+ from: z16.string().min(1),
1564
+ map: z16.record(z16.string().min(1), SocialPlatformSchema)
1565
+ }).optional()
1426
1566
  });
1427
- var ContentHashSchema = z15.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
1428
- var BlueprintTreeSchema = z15.object({
1567
+ var BlueprintIdentitySchema = z16.object({
1568
+ name: z16.string().min(1),
1569
+ description: z16.string().nullable(),
1570
+ connections: BlueprintIdentityConnectionsSchema.optional()
1571
+ });
1572
+ var ContentHashSchema = z16.string().regex(/^[0-9a-f]{64}$/, "a lowercase sha-256 hex digest");
1573
+ var BlueprintTreeSchema = z16.object({
1429
1574
  /** `apps[].name` in the declaration — the same name §31.5 prints and the install ensures by. */
1430
- app: z15.string().min(1),
1575
+ app: z16.string().min(1),
1431
1576
  content_hash: ContentHashSchema
1432
1577
  });
1433
- var BlueprintArtifactSchema = z15.object({
1578
+ var BlueprintArtifactSchema = z16.object({
1434
1579
  id: idOf("bpa"),
1435
- object: z15.literal("blueprint_artifact"),
1580
+ object: z16.literal("blueprint_artifact"),
1436
1581
  /** The machine — its repository, screens and `/api/*`. */
1437
- blueprint: z15.string().min(1),
1582
+ blueprint: z16.string().min(1),
1438
1583
  /** Which of that blueprint's templates provides the crew. */
1439
- template: z15.string().min(1),
1584
+ template: z16.string().min(1),
1440
1585
  /** The blueprint repository's own released version. Stored, never parsed (ADR-0401). */
1441
- version: z15.string().min(1),
1586
+ version: z16.string().min(1),
1442
1587
  /**
1443
1588
  * The built trees, one per deployable app, ordered as the declaration orders its apps. Never
1444
1589
  * empty: an artifact that built nothing is not an artifact, and the column behind it says so
1445
1590
  * (migration 0040) exactly as the single `content_hash` it replaces was `not null`.
1446
1591
  */
1447
- trees: z15.array(BlueprintTreeSchema).min(1),
1592
+ trees: z16.array(BlueprintTreeSchema).min(1),
1448
1593
  /**
1449
1594
  * The setup questions, asked by the studio **before** provisioning. `QuestionField` (§7.1) is
1450
1595
  * reused rather than restated: a setup question and a question a parked agent asks are the same
1451
1596
  * object at different times, so one component renders both.
1452
1597
  */
1453
- questions: z15.array(QuestionFieldSchema),
1454
- schedules: z15.array(BlueprintScheduleSchema),
1598
+ questions: z16.array(QuestionFieldSchema),
1599
+ schedules: z16.array(BlueprintScheduleSchema),
1455
1600
  /** Who the crew is, and what it deploys — §31.5. Derived from `declaration`, never stored twice. */
1456
- agents: z15.array(BlueprintCrewSchema),
1457
- apps: z15.array(BlueprintAppSchema),
1601
+ agents: z16.array(BlueprintCrewSchema),
1602
+ apps: z16.array(BlueprintAppSchema),
1458
1603
  /**
1459
1604
  * The agents a template creates per client the operator signs — printed, never provisioned by an
1460
1605
  * apply (§31.1). Absent on rows published before WS12 v2, hence optional.
1461
1606
  */
1462
- crew_per_client: z15.array(BlueprintCrewSchema).optional(),
1607
+ crew_per_client: z16.array(BlueprintCrewSchema).optional(),
1608
+ /**
1609
+ * The personas the crew posts from, and which accounts to connect to each before the crew
1610
+ * exists (§31.10). Derived from `declaration` like `agents`; optional for the §31.5 rollout reason.
1611
+ */
1612
+ identities: z16.array(BlueprintIdentitySchema).optional(),
1463
1613
  /**
1464
1614
  * The creator template a row was published from (§42.8), `null` on every first-party row.
1465
1615
  * `creator_name` is the public display name the landing page credits. The API sends all three
1466
1616
  * on every row; they are optional here only so an artifact typed before §42 still reads.
1467
1617
  */
1468
1618
  creator_template_id: idOf("ctp").nullish(),
1469
- creator_template_version: z15.number().int().positive().nullish(),
1470
- creator_name: z15.string().min(1).nullish(),
1619
+ creator_template_version: z16.number().int().positive().nullish(),
1620
+ creator_name: z16.string().min(1).nullish(),
1471
1621
  published_at: Timestamp
1472
1622
  });
1473
1623
 
1474
1624
  // ../core/src/schema/vault.ts
1475
- import { z as z16 } from "zod";
1476
- var VaultCredentialKindSchema = z16.enum(["env_var", "static_bearer", "mcp_oauth"]);
1477
- var VaultSchema = z16.object({
1625
+ import { z as z17 } from "zod";
1626
+ var VaultCredentialKindSchema = z17.enum(["env_var", "static_bearer", "mcp_oauth"]);
1627
+ var VaultSchema = z17.object({
1478
1628
  id: idOf("vlt"),
1479
- object: z16.literal("vault"),
1629
+ object: z17.literal("vault"),
1480
1630
  identity_id: idOf("idn").nullable(),
1481
- display_name: z16.string().min(1).max(128),
1482
- credential_count: z16.number().int().nonnegative(),
1631
+ display_name: z17.string().min(1).max(128),
1632
+ credential_count: z17.number().int().nonnegative(),
1483
1633
  created_at: Timestamp
1484
1634
  });
1485
- var VaultCredentialSchema = z16.object({
1635
+ var VaultCredentialSchema = z17.object({
1486
1636
  id: idOf("vcr"),
1487
- object: z16.literal("vault_credential"),
1637
+ object: z17.literal("vault_credential"),
1488
1638
  vault_id: idOf("vlt"),
1489
1639
  kind: VaultCredentialKindSchema,
1490
1640
  /** For `env_var`, the environment variable name. For the MCP kinds, a display label. */
1491
- key: z16.string().min(1).max(128),
1641
+ key: z17.string().min(1).max(128),
1492
1642
  /** The exact destination host an `env_var` credential is bound to. Never a wildcard. */
1493
- host: z16.string().nullable(),
1643
+ host: z17.string().nullable(),
1494
1644
  /** The exact MCP server URL an `mcp_*` token is matched to. */
1495
- mcp_server_url: z16.url().nullable(),
1496
- placeholder_ref: z16.string(),
1645
+ mcp_server_url: z17.url().nullable(),
1646
+ placeholder_ref: z17.string(),
1497
1647
  expires_at: Timestamp.nullable(),
1498
1648
  last_injected_at: Timestamp.nullable(),
1499
1649
  created_at: Timestamp
1500
1650
  });
1501
1651
 
1502
- // ../core/src/schema/social.ts
1503
- import { z as z17 } from "zod";
1504
- var SOCIAL_PLATFORMS = [
1505
- "bluesky",
1506
- "facebook",
1507
- "instagram",
1508
- "linkedin",
1509
- "mastodon",
1510
- "pinterest",
1511
- "reddit",
1512
- "threads",
1513
- "tiktok",
1514
- "x",
1515
- "youtube"
1516
- ];
1517
- var SOCIAL_TEXT_PLATFORMS = [
1518
- "bluesky",
1519
- "facebook",
1520
- "linkedin",
1521
- "mastodon",
1522
- "threads",
1523
- "x"
1524
- ];
1525
- var SOCIAL_MEDIA_PLATFORMS = ["instagram", "tiktok", "youtube"];
1526
- var SOCIAL_VISIBILITIES = ["public", "unlisted", "private"];
1527
- var SOCIAL_VISIBILITY_PLATFORMS = ["mastodon", "youtube"];
1528
- var SocialVisibilitySchema = z17.enum(SOCIAL_VISIBILITIES);
1529
- var SOCIAL_VISIBILITY_RULE = `visibility is ${SOCIAL_VISIBILITIES.join(", ")} and only ${SOCIAL_VISIBILITY_PLATFORMS.join(" and ")} accept it; omit it and the post publishes at the account's own default, which on a video channel is normally public`;
1530
- var SocialPlatformSchema = z17.enum(SOCIAL_PLATFORMS);
1531
- var SocialTextPlatformSchema = z17.enum(SOCIAL_TEXT_PLATFORMS);
1532
- var isText = (platform) => SOCIAL_TEXT_PLATFORMS.includes(platform);
1533
- var isMedia = (platform) => SOCIAL_MEDIA_PLATFORMS.includes(platform);
1534
- var SOCIAL_PLATFORM_RULE = `${SOCIAL_TEXT_PLATFORMS.join(", ")} take a text-only post; ${SOCIAL_MEDIA_PLATFORMS.join(", ")} may be named only when the post carries media_urls or file_ids; ${SOCIAL_PLATFORMS.filter((platform) => !isText(platform) && !isMedia(platform)).join(", ")} cannot be posted to`;
1535
- var SocialAccountSchema = z17.object({
1536
- id: z17.string().min(1),
1537
- object: z17.literal("social_account"),
1538
- identity_id: idOf("idn"),
1539
- platform: SocialPlatformSchema,
1540
- username: z17.string().nullable(),
1541
- display_name: z17.string().nullable(),
1542
- avatar_url: z17.url().nullable(),
1543
- connected_at: Timestamp.nullable()
1544
- });
1545
- var SocialPostStatusSchema = z17.enum([
1546
- "draft",
1547
- "scheduled",
1548
- "processing",
1549
- "posted",
1550
- "failed",
1551
- "deleted"
1552
- ]);
1553
- var SocialPostSchema = z17.object({
1554
- id: z17.string().min(1),
1555
- object: z17.literal("social_post"),
1556
- identity_id: idOf("idn"),
1557
- title: z17.string(),
1558
- platforms: z17.array(SocialPlatformSchema),
1559
- status: SocialPostStatusSchema,
1560
- scheduled_at: Timestamp.nullable(),
1561
- posted_at: Timestamp.nullable(),
1562
- error: z17.string().nullable()
1563
- });
1564
- var SocialUploadSchema = z17.object({
1565
- id: z17.string().min(1),
1566
- object: z17.literal("social_upload"),
1567
- identity_id: idOf("idn"),
1568
- type: z17.enum(["image", "video", "document"]),
1569
- url: z17.url().nullable()
1570
- });
1571
- var SocialAnalyticsSchema = z17.object({
1572
- object: z17.literal("social_analytics"),
1573
- identity_id: idOf("idn"),
1574
- resource_id: z17.string().min(1),
1575
- platform: SocialPlatformSchema.nullable(),
1576
- data: z17.unknown()
1577
- });
1578
- var SocialCommentSchema = z17.object({
1579
- id: z17.string().min(1),
1580
- object: z17.literal("social_comment"),
1581
- identity_id: idOf("idn"),
1582
- post_id: z17.string().min(1),
1583
- platforms: z17.array(SocialPlatformSchema),
1584
- status: SocialPostStatusSchema,
1585
- posted_at: Timestamp.nullable(),
1586
- data: z17.unknown()
1652
+ // ../core/src/schema/handoff.ts
1653
+ import { z as z18 } from "zod";
1654
+ var MAX_HANDOFF_TARGETS = 6;
1655
+ var HandoffRequestSchema = z18.object({
1656
+ agent: z18.string().min(1),
1657
+ message: z18.string().min(1),
1658
+ handoff_key: z18.string().min(1).max(128).optional(),
1659
+ budget_micro_usd: z18.number().int().positive().optional()
1660
+ });
1661
+ var HandoffSchema = z18.object({
1662
+ object: z18.literal("handoff"),
1663
+ session_id: idOf("ses"),
1664
+ status: z18.enum(["queued", "already_running"]),
1665
+ handoff_key: z18.string().nullable()
1666
+ });
1667
+ var SessionHandoffRequestSchema = z18.object({
1668
+ agents: z18.array(z18.string().min(1)).min(1).max(MAX_HANDOFF_TARGETS),
1669
+ message: z18.string().min(1),
1670
+ handoff_key: z18.string().min(1).max(128).optional(),
1671
+ budget_micro_usd: z18.number().int().positive().optional()
1672
+ });
1673
+ var HandoffRefusalSchema = z18.object({
1674
+ object: z18.literal("handoff_refusal"),
1675
+ agent: z18.string(),
1676
+ code: z18.string(),
1677
+ message: z18.string()
1678
+ });
1679
+ var HandoffBatchSchema = z18.object({
1680
+ object: z18.literal("handoff_batch"),
1681
+ handoffs: z18.array(HandoffSchema.extend({ agent_id: idOf("agt") })),
1682
+ refusals: z18.array(HandoffRefusalSchema)
1683
+ });
1684
+ var SessionHandoffSchema = z18.object({
1685
+ from_session: idOf("ses"),
1686
+ from_agent: idOf("agt"),
1687
+ key: z18.string().nullable(),
1688
+ depth: z18.number().int().positive()
1689
+ });
1690
+ var ChannelBriefSchema = z18.object({
1691
+ root_session_id: idOf("ses"),
1692
+ name: z18.string().min(1),
1693
+ members: z18.array(z18.string().min(1))
1694
+ });
1695
+ var ChannelPostRequestSchema = z18.object({
1696
+ message: z18.string().min(1).max(2e4)
1697
+ });
1698
+ var ChannelPostSchema = z18.object({
1699
+ object: z18.literal("channel_post"),
1700
+ root_session_id: idOf("ses"),
1701
+ queued: z18.boolean()
1587
1702
  });
1588
1703
 
1589
1704
  // ../core/src/schema/media.ts
1590
- import { z as z18 } from "zod";
1705
+ import { z as z19 } from "zod";
1591
1706
  var MEDIA_JOB_KINDS = ["video", "clip", "transcription"];
1592
- var MediaJobKindSchema = z18.enum(MEDIA_JOB_KINDS);
1593
- var MediaJobStatusSchema = z18.enum(["queued", "processing", "completed", "failed"]);
1594
- var PublicUrl = z18.string().url().startsWith("http");
1595
- var Score = z18.number().int().min(0).max(100);
1596
- var Seconds = z18.number().nonnegative();
1597
- var VideoResultSchema = z18.object({
1598
- files: z18.array(
1599
- z18.object({
1707
+ var MediaJobKindSchema = z19.enum(MEDIA_JOB_KINDS);
1708
+ var MediaJobStatusSchema = z19.enum(["queued", "processing", "completed", "failed"]);
1709
+ var PublicUrl = z19.string().url().startsWith("http");
1710
+ var Score = z19.number().int().min(0).max(100);
1711
+ var Seconds = z19.number().nonnegative();
1712
+ var VideoResultSchema = z19.object({
1713
+ files: z19.array(
1714
+ z19.object({
1600
1715
  file_id: idOf("fil"),
1601
- content_type: z18.string(),
1602
- width: z18.number().int().positive().nullable(),
1603
- height: z18.number().int().positive().nullable(),
1716
+ content_type: z19.string(),
1717
+ width: z19.number().int().positive().nullable(),
1718
+ height: z19.number().int().positive().nullable(),
1604
1719
  duration_seconds: Seconds.nullable()
1605
1720
  })
1606
1721
  )
1607
1722
  });
1608
- var ViralityScoreSchema = z18.object({
1723
+ var ViralityScoreSchema = z19.object({
1609
1724
  total: Score,
1610
1725
  shareability: Score,
1611
1726
  hook_strength: Score,
1612
1727
  story_quality: Score,
1613
1728
  emotional_impact: Score
1614
1729
  });
1615
- var ClipResultSchema = z18.object({
1616
- clips: z18.array(
1617
- z18.object({
1730
+ var ClipResultSchema = z19.object({
1731
+ clips: z19.array(
1732
+ z19.object({
1618
1733
  file_id: idOf("fil"),
1619
- title: z18.string(),
1734
+ title: z19.string(),
1620
1735
  start_seconds: Seconds,
1621
1736
  end_seconds: Seconds,
1622
1737
  duration_seconds: Seconds,
@@ -1624,189 +1739,189 @@ var ClipResultSchema = z18.object({
1624
1739
  })
1625
1740
  )
1626
1741
  });
1627
- var TranscriptSchema = z18.object({
1628
- text: z18.string(),
1629
- language: z18.string().nullable(),
1742
+ var TranscriptSchema = z19.object({
1743
+ text: z19.string(),
1744
+ language: z19.string().nullable(),
1630
1745
  duration_seconds: Seconds.nullable(),
1631
- segments: z18.array(z18.object({ start_seconds: Seconds, end_seconds: Seconds, text: z18.string() }))
1746
+ segments: z19.array(z19.object({ start_seconds: Seconds, end_seconds: Seconds, text: z19.string() }))
1632
1747
  });
1633
- var MediaJobResultSchema = z18.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
1634
- var MediaJobSchema = z18.object({
1748
+ var MediaJobResultSchema = z19.union([VideoResultSchema, ClipResultSchema, TranscriptSchema]);
1749
+ var MediaJobSchema = z19.object({
1635
1750
  id: idOf("med"),
1636
- object: z18.literal("media_job"),
1751
+ object: z19.literal("media_job"),
1637
1752
  kind: MediaJobKindSchema,
1638
1753
  status: MediaJobStatusSchema,
1639
- model: z18.string().nullable(),
1640
- input: z18.record(z18.string(), z18.unknown()),
1754
+ model: z19.string().nullable(),
1755
+ input: z19.record(z19.string(), z19.unknown()),
1641
1756
  result: MediaJobResultSchema.nullable(),
1642
- error: z18.object({ code: z18.string(), message: z18.string() }).nullable(),
1757
+ error: z19.object({ code: z19.string(), message: z19.string() }).nullable(),
1643
1758
  cost_micro_usd: MicroUsdField.nullable(),
1644
1759
  session_id: idOf("ses").nullable(),
1645
1760
  created_at: Timestamp,
1646
1761
  completed_at: Timestamp.nullable()
1647
1762
  });
1648
- var ImageRequestSchema = z18.object({
1649
- model: z18.string().min(1).optional(),
1650
- prompt: z18.string().min(1),
1651
- image_urls: z18.array(PublicUrl).max(4).optional(),
1652
- aspect_ratio: z18.string().optional(),
1653
- seed: z18.number().int().optional(),
1654
- n: z18.number().int().min(1).max(4).default(1)
1655
- });
1656
- var VideoRequestSchema = z18.object({
1657
- model: z18.string().min(1),
1658
- prompt: z18.string().min(1),
1659
- image_urls: z18.array(PublicUrl).max(1).optional(),
1660
- aspect_ratio: z18.string().optional(),
1661
- seed: z18.number().int().optional(),
1662
- seconds: z18.number().int().min(1).max(60).optional()
1663
- });
1664
- var ImageGenerationSchema = z18.object({
1665
- object: z18.literal("image_generation"),
1666
- model: z18.string(),
1667
- files: z18.array(FileSchema),
1763
+ var ImageRequestSchema = z19.object({
1764
+ model: z19.string().min(1).optional(),
1765
+ prompt: z19.string().min(1),
1766
+ image_urls: z19.array(PublicUrl).max(4).optional(),
1767
+ aspect_ratio: z19.string().optional(),
1768
+ seed: z19.number().int().optional(),
1769
+ n: z19.number().int().min(1).max(4).default(1)
1770
+ });
1771
+ var VideoRequestSchema = z19.object({
1772
+ model: z19.string().min(1),
1773
+ prompt: z19.string().min(1),
1774
+ image_urls: z19.array(PublicUrl).max(1).optional(),
1775
+ aspect_ratio: z19.string().optional(),
1776
+ seed: z19.number().int().optional(),
1777
+ seconds: z19.number().int().min(1).max(60).optional()
1778
+ });
1779
+ var ImageGenerationSchema = z19.object({
1780
+ object: z19.literal("image_generation"),
1781
+ model: z19.string(),
1782
+ files: z19.array(FileSchema),
1668
1783
  cost_micro_usd: MicroUsdField
1669
1784
  });
1670
- var ClipLength = z18.number().int().min(5).max(180);
1671
- var ClipRequestSchema = z18.object({
1785
+ var ClipLength = z19.number().int().min(5).max(180);
1786
+ var ClipRequestSchema = z19.object({
1672
1787
  video_url: PublicUrl,
1673
- aspect_ratio: z18.enum(["9:16", "16:9"]).default("9:16"),
1674
- remove_silence: z18.boolean().default(false),
1675
- caption_preset: z18.enum(["none", "clean", "bold", "karaoke"]).default("none"),
1676
- language: z18.string().min(2).optional(),
1788
+ aspect_ratio: z19.enum(["9:16", "16:9"]).default("9:16"),
1789
+ remove_silence: z19.boolean().default(false),
1790
+ caption_preset: z19.enum(["none", "clean", "bold", "karaoke"]).default("none"),
1791
+ language: z19.string().min(2).optional(),
1677
1792
  min_seconds: ClipLength.default(15),
1678
1793
  max_seconds: ClipLength.default(60),
1679
- title: z18.string().min(1).optional()
1794
+ title: z19.string().min(1).optional()
1680
1795
  });
1681
- var AudioFormatSchema = z18.enum(["mp3", "wav", "ogg"]);
1682
- var TranscriptionRequestSchema = z18.object({
1683
- model: z18.string().min(1).optional(),
1796
+ var AudioFormatSchema = z19.enum(["mp3", "wav", "ogg"]);
1797
+ var TranscriptionRequestSchema = z19.object({
1798
+ model: z19.string().min(1).optional(),
1684
1799
  file_id: idOf("fil").optional(),
1685
1800
  url: PublicUrl.optional(),
1686
- language: z18.string().min(2).optional(),
1687
- timestamps: z18.boolean().default(true)
1801
+ language: z19.string().min(2).optional(),
1802
+ timestamps: z19.boolean().default(true)
1688
1803
  }).refine((request) => request.file_id === void 0 !== (request.url === void 0), {
1689
1804
  error: "exactly one of file_id or url",
1690
1805
  path: ["file_id"]
1691
1806
  });
1692
- var SpeechRequestSchema = z18.object({
1693
- model: z18.string().min(1).optional(),
1694
- text: z18.string().min(1).max(4096),
1695
- voice: z18.string().min(1).optional(),
1807
+ var SpeechRequestSchema = z19.object({
1808
+ model: z19.string().min(1).optional(),
1809
+ text: z19.string().min(1).max(4096),
1810
+ voice: z19.string().min(1).optional(),
1696
1811
  format: AudioFormatSchema.default("mp3"),
1697
- speed: z18.number().min(0.5).max(2).optional()
1812
+ speed: z19.number().min(0.5).max(2).optional()
1698
1813
  });
1699
- var SpeechToSpeechRequestSchema = z18.object({
1700
- model: z18.string().min(1).optional(),
1814
+ var SpeechToSpeechRequestSchema = z19.object({
1815
+ model: z19.string().min(1).optional(),
1701
1816
  file_id: idOf("fil"),
1702
- voice: z18.string().min(1).optional(),
1817
+ voice: z19.string().min(1).optional(),
1703
1818
  format: AudioFormatSchema.default("mp3")
1704
1819
  });
1705
- var SpeechGenerationSchema = z18.object({
1706
- object: z18.literal("speech_generation"),
1707
- model: z18.string(),
1820
+ var SpeechGenerationSchema = z19.object({
1821
+ object: z19.literal("speech_generation"),
1822
+ model: z19.string(),
1708
1823
  file: FileSchema,
1709
1824
  duration_seconds: Seconds.nullable(),
1710
1825
  cost_micro_usd: MicroUsdField
1711
1826
  });
1712
1827
 
1713
1828
  // ../core/src/schema/app-data.ts
1714
- import { z as z19 } from "zod";
1715
- var DbTableSchema = z19.object({
1716
- object: z19.literal("db_table"),
1717
- name: z19.string(),
1718
- schema: z19.string().default("public"),
1719
- rows: z19.number().int().nonnegative().nullable(),
1720
- size_bytes: z19.number().int().nonnegative().nullable()
1721
- });
1722
- var DbMigrationSchema = z19.object({
1829
+ import { z as z20 } from "zod";
1830
+ var DbTableSchema = z20.object({
1831
+ object: z20.literal("db_table"),
1832
+ name: z20.string(),
1833
+ schema: z20.string().default("public"),
1834
+ rows: z20.number().int().nonnegative().nullable(),
1835
+ size_bytes: z20.number().int().nonnegative().nullable()
1836
+ });
1837
+ var DbMigrationSchema = z20.object({
1723
1838
  id: idOf("dbm"),
1724
- object: z19.literal("db_migration"),
1725
- name: z19.string(),
1726
- sha256: z19.string().regex(/^[0-9a-f]{64}$/),
1839
+ object: z20.literal("db_migration"),
1840
+ name: z20.string(),
1841
+ sha256: z20.string().regex(/^[0-9a-f]{64}$/),
1727
1842
  applied_at: Timestamp,
1728
- statements: z19.number().int().nonnegative()
1843
+ statements: z20.number().int().nonnegative()
1729
1844
  });
1730
- var ApplyDbMigrationSchema = z19.object({
1731
- name: z19.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
1732
- sql: z19.string().min(1)
1845
+ var ApplyDbMigrationSchema = z20.object({
1846
+ name: z20.string().min(1).max(128).regex(/^[a-z0-9][a-z0-9_-]*$/),
1847
+ sql: z20.string().min(1)
1733
1848
  });
1734
1849
  var DB_REST_METHODS = ["GET", "POST", "PATCH", "PUT", "DELETE", "HEAD"];
1735
- var DbRestMethodSchema = z19.enum(DB_REST_METHODS);
1850
+ var DbRestMethodSchema = z20.enum(DB_REST_METHODS);
1736
1851
  var BUCKET_NAME = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/;
1737
- var BucketSchema = z19.object({
1738
- object: z19.literal("bucket"),
1739
- name: z19.string().regex(BUCKET_NAME),
1740
- public: z19.boolean(),
1852
+ var BucketSchema = z20.object({
1853
+ object: z20.literal("bucket"),
1854
+ name: z20.string().regex(BUCKET_NAME),
1855
+ public: z20.boolean(),
1741
1856
  created_at: Timestamp
1742
1857
  });
1743
- var CreateBucketSchema = z19.object({
1744
- name: z19.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
1745
- public: z19.boolean().default(false)
1746
- });
1747
- var StorageObjectSchema = z19.object({
1748
- object: z19.literal("storage_object"),
1749
- bucket: z19.string(),
1750
- key: z19.string().min(1),
1751
- size_bytes: z19.number().int().nonnegative(),
1752
- content_type: z19.string(),
1753
- etag: z19.string().nullable(),
1858
+ var CreateBucketSchema = z20.object({
1859
+ name: z20.string().regex(BUCKET_NAME, { error: "3\u201363 lowercase letters, digits and hyphens" }),
1860
+ public: z20.boolean().default(false)
1861
+ });
1862
+ var StorageObjectSchema = z20.object({
1863
+ object: z20.literal("storage_object"),
1864
+ bucket: z20.string(),
1865
+ key: z20.string().min(1),
1866
+ size_bytes: z20.number().int().nonnegative(),
1867
+ content_type: z20.string(),
1868
+ etag: z20.string().nullable(),
1754
1869
  updated_at: Timestamp
1755
1870
  });
1756
- var SignedUrlMethodSchema = z19.enum(["PUT", "GET"]);
1757
- var SignedUrlSchema = z19.object({
1758
- object: z19.literal("signed_url"),
1759
- url: z19.string().url(),
1871
+ var SignedUrlMethodSchema = z20.enum(["PUT", "GET"]);
1872
+ var SignedUrlSchema = z20.object({
1873
+ object: z20.literal("signed_url"),
1874
+ url: z20.string().url(),
1760
1875
  method: SignedUrlMethodSchema,
1761
1876
  expires_at: Timestamp
1762
1877
  });
1763
- var CreateUploadUrlSchema = z19.object({
1764
- content_type: z19.string().min(1),
1765
- expires_seconds: z19.number().int().min(60).max(3600).default(900)
1878
+ var CreateUploadUrlSchema = z20.object({
1879
+ content_type: z20.string().min(1),
1880
+ expires_seconds: z20.number().int().min(60).max(3600).default(900)
1766
1881
  });
1767
1882
 
1768
1883
  // ../core/src/schema/stock-photo.ts
1769
- import { z as z20 } from "zod";
1884
+ import { z as z21 } from "zod";
1770
1885
  var STOCK_PHOTO_ORIENTATIONS = ["landscape", "portrait", "square"];
1771
1886
  var STOCK_PHOTO_SIZES = ["small", "medium", "large"];
1772
- var StockPhotoQuerySchema = z20.object({
1773
- query: z20.string().min(1).max(200),
1774
- count: z20.coerce.number().int().min(1).max(30).default(10),
1775
- orientation: z20.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
1776
- color: z20.string().min(1).max(32).optional(),
1777
- size: z20.enum(STOCK_PHOTO_SIZES).optional()
1778
- });
1779
- var StockPhotoSchema = z20.object({
1780
- object: z20.literal("stock_photo"),
1781
- id: z20.string().min(1),
1782
- width: z20.number().int().positive(),
1783
- height: z20.number().int().positive(),
1784
- url: z20.string().url(),
1785
- preview_url: z20.string().url(),
1786
- alt: z20.string().nullable(),
1787
- photographer: z20.string().nullable(),
1788
- attribution_url: z20.string().url().nullable(),
1789
- dominant_color: z20.string().nullable()
1887
+ var StockPhotoQuerySchema = z21.object({
1888
+ query: z21.string().min(1).max(200),
1889
+ count: z21.coerce.number().int().min(1).max(30).default(10),
1890
+ orientation: z21.enum(STOCK_PHOTO_ORIENTATIONS).optional(),
1891
+ color: z21.string().min(1).max(32).optional(),
1892
+ size: z21.enum(STOCK_PHOTO_SIZES).optional()
1893
+ });
1894
+ var StockPhotoSchema = z21.object({
1895
+ object: z21.literal("stock_photo"),
1896
+ id: z21.string().min(1),
1897
+ width: z21.number().int().positive(),
1898
+ height: z21.number().int().positive(),
1899
+ url: z21.string().url(),
1900
+ preview_url: z21.string().url(),
1901
+ alt: z21.string().nullable(),
1902
+ photographer: z21.string().nullable(),
1903
+ attribution_url: z21.string().url().nullable(),
1904
+ dominant_color: z21.string().nullable()
1790
1905
  });
1791
1906
 
1792
1907
  // ../core/src/schema/creator.ts
1793
- import { z as z21 } from "zod";
1794
- var CreatorCodeSchema = z21.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
1795
- var PayoutMethodSchema = z21.enum(["wise", "paypal"]);
1796
- var PayoutDetailsSchema = z21.object({
1908
+ import { z as z22 } from "zod";
1909
+ var CreatorCodeSchema = z22.string().regex(/^[a-z0-9]{3,24}$/, "3 to 24 lowercase letters or digits");
1910
+ var PayoutMethodSchema = z22.enum(["wise", "paypal"]);
1911
+ var PayoutDetailsSchema = z22.object({
1797
1912
  method: PayoutMethodSchema,
1798
- account: z21.string().min(1).max(320)
1913
+ account: z22.string().min(1).max(320)
1799
1914
  });
1800
- var CreatorStatusSchema = z21.enum(["active", "suspended"]);
1801
- var CreatorSchema = z21.object({
1915
+ var CreatorStatusSchema = z22.enum(["active", "suspended"]);
1916
+ var CreatorSchema = z22.object({
1802
1917
  id: idOf("crt"),
1803
- object: z21.literal("creator"),
1804
- email: z21.email(),
1805
- display_name: z21.string().min(1).max(80),
1918
+ object: z22.literal("creator"),
1919
+ email: z22.email(),
1920
+ display_name: z22.string().min(1).max(80),
1806
1921
  code: CreatorCodeSchema,
1807
1922
  status: CreatorStatusSchema,
1808
1923
  payout: PayoutDetailsSchema.nullable(),
1809
- clicks: z21.number().int().nonnegative(),
1924
+ clicks: z22.number().int().nonnegative(),
1810
1925
  created_at: Timestamp,
1811
1926
  updated_at: Timestamp
1812
1927
  });
@@ -1814,28 +1929,28 @@ var IdentityCreatorSchema = CreatorSchema.pick({
1814
1929
  id: true,
1815
1930
  status: true
1816
1931
  });
1817
- var CreatorApplicationStatusSchema = z21.enum([
1932
+ var CreatorApplicationStatusSchema = z22.enum([
1818
1933
  "pending",
1819
1934
  "approved",
1820
1935
  "rejected"
1821
1936
  ]);
1822
- var CreatorApplicationSchema = z21.object({
1937
+ var CreatorApplicationSchema = z22.object({
1823
1938
  id: idOf("cra"),
1824
- object: z21.literal("creator_application"),
1825
- email: z21.email(),
1826
- display_name: z21.string().min(1).max(80),
1827
- pitch: z21.string().min(1).max(2e3),
1828
- links: z21.array(z21.url({ protocol: /^https$/ })).max(5),
1939
+ object: z22.literal("creator_application"),
1940
+ email: z22.email(),
1941
+ display_name: z22.string().min(1).max(80),
1942
+ pitch: z22.string().min(1).max(2e3),
1943
+ links: z22.array(z22.url({ protocol: /^https$/ })).max(5),
1829
1944
  status: CreatorApplicationStatusSchema,
1830
- note: z21.string().nullable(),
1945
+ note: z22.string().nullable(),
1831
1946
  creator_id: idOf("crt").nullable(),
1832
1947
  created_at: Timestamp,
1833
1948
  decided_at: Timestamp.nullable()
1834
1949
  });
1835
- var ReferralStatusSchema = z21.enum(["pending", "active", "expired"]);
1836
- var ReferralSchema = z21.object({
1950
+ var ReferralStatusSchema = z22.enum(["pending", "active", "expired"]);
1951
+ var ReferralSchema = z22.object({
1837
1952
  id: idOf("crf"),
1838
- object: z21.literal("referral"),
1953
+ object: z22.literal("referral"),
1839
1954
  creator_id: idOf("crt"),
1840
1955
  organization_id: idOf("org"),
1841
1956
  status: ReferralStatusSchema,
@@ -1843,16 +1958,16 @@ var ReferralSchema = z21.object({
1843
1958
  first_paid_at: Timestamp.nullable(),
1844
1959
  commission_until: Timestamp.nullable()
1845
1960
  });
1846
- var CommissionKindSchema = z21.enum(["referral", "template"]);
1847
- var CommissionStatusSchema = z21.enum([
1961
+ var CommissionKindSchema = z22.enum(["referral", "template"]);
1962
+ var CommissionStatusSchema = z22.enum([
1848
1963
  "pending",
1849
1964
  "available",
1850
1965
  "claimed",
1851
1966
  "paid"
1852
1967
  ]);
1853
- var CommissionSchema = z21.object({
1968
+ var CommissionSchema = z22.object({
1854
1969
  id: idOf("crc"),
1855
- object: z21.literal("commission"),
1970
+ object: z22.literal("commission"),
1856
1971
  creator_id: idOf("crt"),
1857
1972
  kind: CommissionKindSchema,
1858
1973
  referral_id: idOf("crf").nullable(),
@@ -1865,18 +1980,18 @@ var CommissionSchema = z21.object({
1865
1980
  available_at: Timestamp,
1866
1981
  payout_id: idOf("crp").nullable()
1867
1982
  });
1868
- var PayoutStatusSchema = z21.enum(["requested", "paid", "rejected"]);
1869
- var PayoutSchema = z21.object({
1983
+ var PayoutStatusSchema = z22.enum(["requested", "paid", "rejected"]);
1984
+ var PayoutSchema = z22.object({
1870
1985
  id: idOf("crp"),
1871
- object: z21.literal("payout"),
1986
+ object: z22.literal("payout"),
1872
1987
  creator_id: idOf("crt"),
1873
1988
  amount_micro_usd: MicroUsdField.positive(),
1874
- currency: z21.literal("USD"),
1989
+ currency: z22.literal("USD"),
1875
1990
  method: PayoutMethodSchema,
1876
- account: z21.string().min(1),
1991
+ account: z22.string().min(1),
1877
1992
  status: PayoutStatusSchema,
1878
- reference: z21.string().nullable(),
1879
- note: z21.string().nullable(),
1993
+ reference: z22.string().nullable(),
1994
+ note: z22.string().nullable(),
1880
1995
  requested_at: Timestamp,
1881
1996
  decided_at: Timestamp.nullable()
1882
1997
  });
@@ -1888,100 +2003,100 @@ var CREATOR_PROGRAM = {
1888
2003
  attribution_days: 30,
1889
2004
  minimum_payout_micro_usd: 2e7
1890
2005
  };
1891
- var CreatorTemplateSlugSchema = z21.string().max(32).regex(
2006
+ var CreatorTemplateSlugSchema = z22.string().max(32).regex(
1892
2007
  /^[a-z0-9]+(-[a-z0-9]+)*$/,
1893
2008
  "lowercase letters, digits and single dashes"
1894
2009
  );
1895
- var CreatorSkillSchema = z21.object({
1896
- slug: z21.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
1897
- body: z21.string().min(1).max(64 * 1024)
2010
+ var CreatorSkillSchema = z22.object({
2011
+ slug: z22.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2012
+ body: z22.string().min(1).max(64 * 1024)
1898
2013
  });
1899
- var CreatorDeclarationSchema = z21.object({
1900
- agents: z21.array(z21.unknown()),
1901
- questions: z21.array(z21.unknown()),
1902
- skills: z21.array(CreatorSkillSchema).max(16)
2014
+ var CreatorDeclarationSchema = z22.object({
2015
+ agents: z22.array(z22.unknown()),
2016
+ questions: z22.array(z22.unknown()),
2017
+ skills: z22.array(CreatorSkillSchema).max(16)
1903
2018
  });
1904
- var CreatorTemplateVersionStatusSchema = z21.enum([
2019
+ var CreatorTemplateVersionStatusSchema = z22.enum([
1905
2020
  "in_review",
1906
2021
  "approved",
1907
2022
  "changes_requested"
1908
2023
  ]);
1909
- var VersionNumber = z21.number().int().positive();
1910
- var CreatorTemplateSchema = z21.object({
2024
+ var VersionNumber = z22.number().int().positive();
2025
+ var CreatorTemplateSchema = z22.object({
1911
2026
  id: idOf("ctp"),
1912
- object: z21.literal("creator_template"),
2027
+ object: z22.literal("creator_template"),
1913
2028
  creator_id: idOf("crt"),
1914
- blueprint: z21.string().min(1),
1915
- base_template: z21.string().min(1),
2029
+ blueprint: z22.string().min(1),
2030
+ base_template: z22.string().min(1),
1916
2031
  slug: CreatorTemplateSlugSchema,
1917
- template: z21.string().min(1).max(64),
1918
- name: z21.string().min(1).max(80),
1919
- description: z21.string().max(2e3),
2032
+ template: z22.string().min(1).max(64),
2033
+ name: z22.string().min(1).max(80),
2034
+ description: z22.string().max(2e3),
1920
2035
  declaration: CreatorDeclarationSchema,
1921
2036
  published_version: VersionNumber.nullable(),
1922
- latest_version: z21.object({
2037
+ latest_version: z22.object({
1923
2038
  version: VersionNumber,
1924
2039
  status: CreatorTemplateVersionStatusSchema
1925
2040
  }).nullable(),
1926
2041
  created_at: Timestamp,
1927
2042
  updated_at: Timestamp
1928
2043
  });
1929
- var CreatorTemplateVersionSchema = z21.object({
1930
- object: z21.literal("creator_template_version"),
2044
+ var CreatorTemplateVersionSchema = z22.object({
2045
+ object: z22.literal("creator_template_version"),
1931
2046
  template_id: idOf("ctp"),
1932
2047
  version: VersionNumber,
1933
2048
  declaration: CreatorDeclarationSchema,
1934
2049
  status: CreatorTemplateVersionStatusSchema,
1935
- note: z21.string().nullable(),
2050
+ note: z22.string().nullable(),
1936
2051
  artifact_id: idOf("bpa").nullable(),
1937
2052
  submitted_at: Timestamp,
1938
2053
  decided_at: Timestamp.nullable()
1939
2054
  });
1940
- var CreatorBalanceSchema = z21.object({
1941
- object: z21.literal("creator_balance"),
2055
+ var CreatorBalanceSchema = z22.object({
2056
+ object: z22.literal("creator_balance"),
1942
2057
  pending_micro_usd: MicroUsdField.nonnegative(),
1943
2058
  available_micro_usd: MicroUsdField.nonnegative(),
1944
2059
  claimed_micro_usd: MicroUsdField.nonnegative(),
1945
2060
  paid_micro_usd: MicroUsdField.nonnegative(),
1946
- minimum_payout_micro_usd: z21.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
2061
+ minimum_payout_micro_usd: z22.literal(CREATOR_PROGRAM.minimum_payout_micro_usd)
1947
2062
  });
1948
- var ReferralClickSchema = z21.object({
1949
- object: z21.literal("referral_click"),
2063
+ var ReferralClickSchema = z22.object({
2064
+ object: z22.literal("referral_click"),
1950
2065
  code: CreatorCodeSchema,
1951
- creator: z21.object({ display_name: z21.string().min(1) }),
2066
+ creator: z22.object({ display_name: z22.string().min(1) }),
1952
2067
  expires_at: Timestamp
1953
2068
  });
1954
- var Day = z21.iso.date();
1955
- var CreatorAnalyticsSchema = z21.object({
1956
- object: z21.literal("creator_analytics"),
1957
- days: z21.number().int().min(1).max(90),
2069
+ var Day = z22.iso.date();
2070
+ var CreatorAnalyticsSchema = z22.object({
2071
+ object: z22.literal("creator_analytics"),
2072
+ days: z22.number().int().min(1).max(90),
1958
2073
  from: Day,
1959
2074
  to: Day,
1960
- clicks: z21.number().int().nonnegative(),
1961
- referrals: z21.number().int().nonnegative(),
1962
- installs: z21.number().int().nonnegative(),
1963
- active_installs: z21.number().int().nonnegative(),
1964
- usage_by_day: z21.array(
1965
- z21.object({ day: Day, debit_micro_usd: MicroUsdField.nonnegative() })
2075
+ clicks: z22.number().int().nonnegative(),
2076
+ referrals: z22.number().int().nonnegative(),
2077
+ installs: z22.number().int().nonnegative(),
2078
+ active_installs: z22.number().int().nonnegative(),
2079
+ usage_by_day: z22.array(
2080
+ z22.object({ day: Day, debit_micro_usd: MicroUsdField.nonnegative() })
1966
2081
  ),
1967
- commission_micro_usd: z21.object({
2082
+ commission_micro_usd: z22.object({
1968
2083
  pending: MicroUsdField.nonnegative(),
1969
2084
  available: MicroUsdField.nonnegative(),
1970
2085
  claimed: MicroUsdField.nonnegative(),
1971
2086
  paid: MicroUsdField.nonnegative()
1972
2087
  }),
1973
- commissions_by_template: z21.array(
1974
- z21.object({
2088
+ commissions_by_template: z22.array(
2089
+ z22.object({
1975
2090
  creator_template_id: idOf("ctp"),
1976
2091
  amount_micro_usd: MicroUsdField.nonnegative()
1977
2092
  })
1978
2093
  ),
1979
2094
  /** Every install covered, newest first: the day it was created and the day its twelve months end. */
1980
- install_windows: z21.array(z21.object({ install_id: idOf("bpi"), from: Day, until: Day }))
2095
+ install_windows: z22.array(z22.object({ install_id: idOf("bpi"), from: Day, until: Day }))
1981
2096
  });
1982
2097
 
1983
2098
  // ../core/src/schema/legal.ts
1984
- import { z as z22 } from "zod";
2099
+ import { z as z23 } from "zod";
1985
2100
  var LEGAL_MEMBER_STATUSES = [
1986
2101
  "pending",
1987
2102
  "link_ready",
@@ -1991,16 +2106,16 @@ var LEGAL_MEMBER_STATUSES = [
1991
2106
  "verified",
1992
2107
  "failed"
1993
2108
  ];
1994
- var LegalMemberStatusSchema = z22.enum(LEGAL_MEMBER_STATUSES);
2109
+ var LegalMemberStatusSchema = z23.enum(LEGAL_MEMBER_STATUSES);
1995
2110
  var LEGAL_VERIFICATION_STATUSES = ["in_progress", "pending_review", "verified", "failed"];
1996
- var LegalVerificationStatusSchema = z22.enum(LEGAL_VERIFICATION_STATUSES);
2111
+ var LegalVerificationStatusSchema = z23.enum(LEGAL_VERIFICATION_STATUSES);
1997
2112
  var LEGAL_COMPANY_STATUSES = ["awaiting_payment", "paid", "submitted", "formed", "failed"];
1998
- var LegalCompanyStatusSchema = z22.enum(LEGAL_COMPANY_STATUSES);
2113
+ var LegalCompanyStatusSchema = z23.enum(LEGAL_COMPANY_STATUSES);
1999
2114
  var LEGAL_DOCUMENT_KINDS = ["articles", "ein_letter", "operating_agreement", "other"];
2000
- var LegalDocumentKindSchema = z22.enum(LEGAL_DOCUMENT_KINDS);
2001
- var LegalMemberRoleSchema = z22.enum(["primary", "secondary"]);
2002
- var LegalEinStatusSchema = z22.enum(["none", "pending", "issued"]);
2003
- var LegalRequiredActionKindSchema = z22.enum(["signature", "information", "payment", "other"]);
2115
+ var LegalDocumentKindSchema = z23.enum(LEGAL_DOCUMENT_KINDS);
2116
+ var LegalMemberRoleSchema = z23.enum(["primary", "secondary"]);
2117
+ var LegalEinStatusSchema = z23.enum(["none", "pending", "issued"]);
2118
+ var LegalRequiredActionKindSchema = z23.enum(["signature", "information", "payment", "other"]);
2004
2119
  var US_STATES = [
2005
2120
  "AL",
2006
2121
  "AK",
@@ -2054,105 +2169,105 @@ var US_STATES = [
2054
2169
  "WI",
2055
2170
  "WY"
2056
2171
  ];
2057
- var UsStateSchema = z22.enum(US_STATES);
2058
- var LegalMemberInputSchema = z22.object({
2059
- first_name: z22.string().min(1).max(128),
2060
- last_name: z22.string().min(1).max(128),
2061
- email: z22.string().min(1).max(320),
2172
+ var UsStateSchema = z23.enum(US_STATES);
2173
+ var LegalMemberInputSchema = z23.object({
2174
+ first_name: z23.string().min(1).max(128),
2175
+ last_name: z23.string().min(1).max(128),
2176
+ email: z23.string().min(1).max(320),
2062
2177
  role: LegalMemberRoleSchema,
2063
- is_responsible_party: z22.boolean(),
2064
- ownership_percent: z22.number().int()
2178
+ is_responsible_party: z23.boolean(),
2179
+ ownership_percent: z23.number().int()
2065
2180
  });
2066
2181
  var LegalMemberSchema = LegalMemberInputSchema.extend({
2067
2182
  id: idOf("lgm"),
2068
- object: z22.literal("legal_member"),
2183
+ object: z23.literal("legal_member"),
2069
2184
  verification_id: idOf("lgv"),
2070
2185
  status: LegalMemberStatusSchema,
2071
- link_url: z22.url().nullable(),
2186
+ link_url: z23.url().nullable(),
2072
2187
  link_expires_at: Timestamp.nullable(),
2073
2188
  completed_at: Timestamp.nullable()
2074
2189
  });
2075
- var LegalVerificationSchema = z22.object({
2190
+ var LegalVerificationSchema = z23.object({
2076
2191
  id: idOf("lgv"),
2077
- object: z22.literal("legal_verification"),
2192
+ object: z23.literal("legal_verification"),
2078
2193
  identity_id: idOf("idn"),
2079
2194
  status: LegalVerificationStatusSchema,
2080
- members: z22.array(LegalMemberSchema),
2081
- ready_for_formation: z22.boolean(),
2195
+ members: z23.array(LegalMemberSchema),
2196
+ ready_for_formation: z23.boolean(),
2082
2197
  started_at: Timestamp,
2083
2198
  completed_at: Timestamp.nullable(),
2084
2199
  created_at: Timestamp,
2085
2200
  updated_at: Timestamp
2086
2201
  });
2087
- var StartLegalVerificationSchema = z22.object({ members: z22.array(LegalMemberInputSchema) });
2088
- var CompleteLegalMemberSchema = z22.object({ token: z22.string().min(1) });
2089
- var LegalNameOptionSchema = z22.object({ name: z22.string().min(1).max(200), ending: z22.literal("LLC") });
2090
- var LegalMailingAddressSchema = z22.object({
2091
- line1: z22.string().min(1).max(200),
2092
- line2: z22.string().max(200).nullable(),
2093
- city: z22.string().min(1).max(100),
2202
+ var StartLegalVerificationSchema = z23.object({ members: z23.array(LegalMemberInputSchema) });
2203
+ var CompleteLegalMemberSchema = z23.object({ token: z23.string().min(1) });
2204
+ var LegalNameOptionSchema = z23.object({ name: z23.string().min(1).max(200), ending: z23.literal("LLC") });
2205
+ var LegalMailingAddressSchema = z23.object({
2206
+ line1: z23.string().min(1).max(200),
2207
+ line2: z23.string().max(200).nullable(),
2208
+ city: z23.string().min(1).max(100),
2094
2209
  state: UsStateSchema,
2095
- postal_code: z22.string().min(1).max(16),
2096
- country: z22.literal("US")
2210
+ postal_code: z23.string().min(1).max(16),
2211
+ country: z23.literal("US")
2097
2212
  });
2098
- var LegalRequiredActionSchema = z22.object({
2213
+ var LegalRequiredActionSchema = z23.object({
2099
2214
  kind: LegalRequiredActionKindSchema,
2100
- description: z22.string(),
2101
- url: z22.url().nullable()
2215
+ description: z23.string(),
2216
+ url: z23.url().nullable()
2102
2217
  });
2103
2218
  var LEGAL_DESCRIPTION_MAX = 50;
2104
- var CreateLegalCompanySchema = z22.object({
2219
+ var CreateLegalCompanySchema = z23.object({
2105
2220
  verification_id: idOf("lgv"),
2106
2221
  state: UsStateSchema,
2107
- name_options: z22.array(z22.string().min(1).max(200)).min(1).max(3),
2108
- naics_code: z22.string().regex(/^\d{2,6}$/),
2109
- description: z22.string().min(1).max(LEGAL_DESCRIPTION_MAX),
2222
+ name_options: z23.array(z23.string().min(1).max(200)).min(1).max(3),
2223
+ naics_code: z23.string().regex(/^\d{2,6}$/),
2224
+ description: z23.string().min(1).max(LEGAL_DESCRIPTION_MAX),
2110
2225
  mailing_address: LegalMailingAddressSchema
2111
2226
  });
2112
2227
  var LegalCompanySchema = CreateLegalCompanySchema.omit({ name_options: true }).extend({
2113
2228
  id: idOf("lgc"),
2114
- object: z22.literal("legal_company"),
2229
+ object: z23.literal("legal_company"),
2115
2230
  identity_id: idOf("idn"),
2116
2231
  status: LegalCompanyStatusSchema,
2117
- entity_type: z22.literal("llc"),
2118
- name_options: z22.array(LegalNameOptionSchema),
2119
- legal_name: z22.string().nullable(),
2232
+ entity_type: z23.literal("llc"),
2233
+ name_options: z23.array(LegalNameOptionSchema),
2234
+ legal_name: z23.string().nullable(),
2120
2235
  ein_status: LegalEinStatusSchema,
2121
2236
  price_micro_usd: MicroUsdField,
2122
- required_actions: z22.array(LegalRequiredActionSchema),
2123
- failure_reason: z22.string().max(256).nullable(),
2237
+ required_actions: z23.array(LegalRequiredActionSchema),
2238
+ failure_reason: z23.string().max(256).nullable(),
2124
2239
  submitted_at: Timestamp.nullable(),
2125
2240
  formed_at: Timestamp.nullable(),
2126
2241
  created_at: Timestamp,
2127
2242
  updated_at: Timestamp
2128
2243
  });
2129
- var LegalDocumentSchema = z22.object({
2244
+ var LegalDocumentSchema = z23.object({
2130
2245
  id: idOf("lgd"),
2131
- object: z22.literal("legal_document"),
2246
+ object: z23.literal("legal_document"),
2132
2247
  company_id: idOf("lgc"),
2133
2248
  kind: LegalDocumentKindSchema,
2134
- name: z22.string(),
2249
+ name: z23.string(),
2135
2250
  created_at: Timestamp
2136
2251
  });
2137
- var LegalDocumentLinkSchema = z22.object({
2138
- object: z22.literal("legal_document_link"),
2139
- url: z22.url(),
2252
+ var LegalDocumentLinkSchema = z23.object({
2253
+ object: z23.literal("legal_document_link"),
2254
+ url: z23.url(),
2140
2255
  expires_at: Timestamp
2141
2256
  });
2142
- var NaicsCodeSchema = z22.object({
2143
- object: z22.literal("naics_code"),
2144
- code: z22.string().regex(/^\d{2,6}$/),
2145
- title: z22.string()
2257
+ var NaicsCodeSchema = z23.object({
2258
+ object: z23.literal("naics_code"),
2259
+ code: z23.string().regex(/^\d{2,6}$/),
2260
+ title: z23.string()
2146
2261
  });
2147
- var LegalStateSchema = z22.object({
2148
- object: z22.literal("legal_state"),
2262
+ var LegalStateSchema = z23.object({
2263
+ object: z23.literal("legal_state"),
2149
2264
  code: UsStateSchema,
2150
- name: z22.string(),
2265
+ name: z23.string(),
2151
2266
  formation_fee_micro_usd: MicroUsdField
2152
2267
  });
2153
- var LegalWebhookEventSchema = z22.object({
2154
- provider_session_ref: z22.string().min(1),
2155
- status: z22.enum(["verified", "failed", "pending_review"]),
2268
+ var LegalWebhookEventSchema = z23.object({
2269
+ provider_session_ref: z23.string().min(1),
2270
+ status: z23.enum(["verified", "failed", "pending_review"]),
2156
2271
  metadata: Metadata
2157
2272
  });
2158
2273
  var LLC_ENDING = /\s*(?:,\s*)?(?:l\.?l\.?c\.?|limited\s+liability\s+company)\s*$/i;
@@ -2163,178 +2278,178 @@ function canonicalName(raw) {
2163
2278
  }
2164
2279
 
2165
2280
  // ../core/src/schema/wallet.ts
2166
- import { z as z23 } from "zod";
2281
+ import { z as z24 } from "zod";
2167
2282
  var WALLET_NETWORKS = ["eip155:84532", "eip155:8453"];
2168
- var WalletNetworkSchema = z23.enum(WALLET_NETWORKS);
2283
+ var WalletNetworkSchema = z24.enum(WALLET_NETWORKS);
2169
2284
  var DEFAULT_WALLET_NETWORK = "eip155:84532";
2170
- var WalletSelectSchema = z23.object({ network: WalletNetworkSchema.optional() });
2285
+ var WalletSelectSchema = z24.object({ network: WalletNetworkSchema.optional() });
2171
2286
  var WALLET_STATUSES = ["active", "frozen", "swept"];
2172
- var WalletStatusSchema = z23.enum(WALLET_STATUSES);
2287
+ var WalletStatusSchema = z24.enum(WALLET_STATUSES);
2173
2288
  var WALLET_TRANSACTION_KINDS = ["fund", "transfer", "pay", "sweep"];
2174
- var WalletTransactionKindSchema = z23.enum(WALLET_TRANSACTION_KINDS);
2289
+ var WalletTransactionKindSchema = z24.enum(WALLET_TRANSACTION_KINDS);
2175
2290
  var WALLET_TRANSACTION_STATUSES = ["pending", "confirmed", "failed"];
2176
- var WalletTransactionStatusSchema = z23.enum(WALLET_TRANSACTION_STATUSES);
2177
- var WalletDirectionSchema = z23.enum(["in", "out"]);
2178
- var WalletFundSourceSchema = z23.enum(["faucet", "treasury"]);
2179
- var EvmAddressSchema = z23.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
2180
- var TxHashSchema = z23.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
2181
- var WalletPolicySchema = z23.object({
2291
+ var WalletTransactionStatusSchema = z24.enum(WALLET_TRANSACTION_STATUSES);
2292
+ var WalletDirectionSchema = z24.enum(["in", "out"]);
2293
+ var WalletFundSourceSchema = z24.enum(["faucet", "treasury"]);
2294
+ var EvmAddressSchema = z24.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x address");
2295
+ var TxHashSchema = z24.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 0x transaction hash");
2296
+ var WalletPolicySchema = z24.object({
2182
2297
  per_tx_cap_micro_usd: MicroUsdField.nonnegative(),
2183
2298
  daily_cap_micro_usd: MicroUsdField.positive().nullable(),
2184
2299
  low_balance_micro_usd: MicroUsdField.nonnegative().nullable()
2185
2300
  });
2186
- var WalletSchema = z23.object({
2301
+ var WalletSchema = z24.object({
2187
2302
  id: idOf("wlt"),
2188
- object: z23.literal("wallet"),
2303
+ object: z24.literal("wallet"),
2189
2304
  identity_id: idOf("idn"),
2190
2305
  status: WalletStatusSchema,
2191
2306
  network: WalletNetworkSchema,
2192
2307
  address: EvmAddressSchema,
2193
- asset: z23.literal("usdc"),
2308
+ asset: z24.literal("usdc"),
2194
2309
  balance_micro_usd: MicroUsdField,
2195
2310
  policy: WalletPolicySchema,
2196
2311
  spent_today_micro_usd: MicroUsdField,
2197
2312
  created_at: Timestamp,
2198
2313
  updated_at: Timestamp
2199
2314
  });
2200
- var CreateWalletSchema = z23.object({
2315
+ var CreateWalletSchema = z24.object({
2201
2316
  network: WalletNetworkSchema.optional(),
2202
2317
  policy: WalletPolicySchema.partial().optional()
2203
2318
  });
2204
2319
  var UpdateWalletPolicySchema = WalletPolicySchema.partial();
2205
- var FundWalletSchema = z23.object({
2320
+ var FundWalletSchema = z24.object({
2206
2321
  amount_micro_usd: MicroUsdField.positive(),
2207
2322
  source: WalletFundSourceSchema
2208
2323
  });
2209
- var TransferWalletSchema = z23.object({
2210
- to: z23.union([EvmAddressSchema, idOf("idn")]),
2324
+ var TransferWalletSchema = z24.object({
2325
+ to: z24.union([EvmAddressSchema, idOf("idn")]),
2211
2326
  amount_micro_usd: MicroUsdField.positive(),
2212
- purpose: z23.string().min(1).max(256)
2327
+ purpose: z24.string().min(1).max(256)
2213
2328
  });
2214
- var SweepWalletSchema = z23.object({ to: EvmAddressSchema.optional() });
2215
- var WalletTransactionSchema = z23.object({
2329
+ var SweepWalletSchema = z24.object({ to: EvmAddressSchema.optional() });
2330
+ var WalletTransactionSchema = z24.object({
2216
2331
  id: idOf("wtx"),
2217
- object: z23.literal("wallet_transaction"),
2332
+ object: z24.literal("wallet_transaction"),
2218
2333
  wallet_id: idOf("wlt"),
2219
2334
  kind: WalletTransactionKindSchema,
2220
2335
  direction: WalletDirectionSchema,
2221
2336
  amount_micro_usd: MicroUsdField,
2222
- counterparty: z23.string().nullable(),
2223
- origin: z23.string().nullable(),
2224
- purpose: z23.string().nullable(),
2337
+ counterparty: z24.string().nullable(),
2338
+ origin: z24.string().nullable(),
2339
+ purpose: z24.string().nullable(),
2225
2340
  tx_hash: TxHashSchema.nullable(),
2226
2341
  session_id: idOf("ses").nullable(),
2227
2342
  status: WalletTransactionStatusSchema,
2228
2343
  created_at: Timestamp
2229
2344
  });
2230
- var ListWalletTransactionsSchema = z23.object({
2345
+ var ListWalletTransactionsSchema = z24.object({
2231
2346
  kind: WalletTransactionKindSchema.optional(),
2232
2347
  direction: WalletDirectionSchema.optional(),
2233
- origin: z23.string().optional(),
2348
+ origin: z24.string().optional(),
2234
2349
  since: Timestamp.optional()
2235
2350
  });
2236
- var HttpMethodSchema = z23.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
2237
- var WalletQuoteRequestSchema = z23.object({ url: z23.url(), method: HttpMethodSchema.optional() });
2238
- var WalletQuoteSchema = z23.object({
2239
- object: z23.literal("wallet_quote"),
2240
- url: z23.url(),
2241
- payable: z23.boolean(),
2351
+ var HttpMethodSchema = z24.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
2352
+ var WalletQuoteRequestSchema = z24.object({ url: z24.url(), method: HttpMethodSchema.optional() });
2353
+ var WalletQuoteSchema = z24.object({
2354
+ object: z24.literal("wallet_quote"),
2355
+ url: z24.url(),
2356
+ payable: z24.boolean(),
2242
2357
  network: WalletNetworkSchema.nullable(),
2243
- asset: z23.literal("usdc").nullable(),
2358
+ asset: z24.literal("usdc").nullable(),
2244
2359
  amount_micro_usd: MicroUsdField.nullable(),
2245
2360
  pay_to: EvmAddressSchema.nullable(),
2246
- description: z23.string().nullable(),
2247
- max_timeout_seconds: z23.number().int().nullable()
2361
+ description: z24.string().nullable(),
2362
+ max_timeout_seconds: z24.number().int().nullable()
2248
2363
  });
2249
2364
  var WalletPayRequestSchema = WalletQuoteRequestSchema.extend({
2250
2365
  max_amount_micro_usd: MicroUsdField.positive().optional()
2251
2366
  });
2252
2367
  var WALLET_RESPONSE_BODY_MAX = 64 * 1024;
2253
- var WalletPaymentSchema = z23.object({
2254
- object: z23.literal("wallet_payment"),
2255
- paid: z23.boolean(),
2368
+ var WalletPaymentSchema = z24.object({
2369
+ object: z24.literal("wallet_payment"),
2370
+ paid: z24.boolean(),
2256
2371
  transaction_id: idOf("wtx").nullable(),
2257
2372
  amount_micro_usd: MicroUsdField.nullable(),
2258
- response_status: z23.number().int(),
2259
- response_body: z23.string().max(WALLET_RESPONSE_BODY_MAX)
2373
+ response_status: z24.number().int(),
2374
+ response_body: z24.string().max(WALLET_RESPONSE_BODY_MAX)
2260
2375
  });
2261
2376
 
2262
2377
  // ../core/src/schema/cards.ts
2263
- import { z as z24 } from "zod";
2378
+ import { z as z25 } from "zod";
2264
2379
  var CARD_STATUSES = ["pending_payment", "issuing", "active", "failed", "cancelled", "refunded"];
2265
- var CardStatusSchema = z24.enum(CARD_STATUSES);
2380
+ var CardStatusSchema = z25.enum(CARD_STATUSES);
2266
2381
  var CARD_MIN_LOAD_MICRO_USD = 1e6;
2267
2382
  var CARD_MAX_LOAD_MICRO_USD = 15e7;
2268
2383
  var CARD_LOAD_GRANULARITY_MICRO_USD = 1e4;
2269
- var CardSchema = z24.object({
2384
+ var CardSchema = z25.object({
2270
2385
  id: idOf("vcd"),
2271
- object: z24.literal("card"),
2386
+ object: z25.literal("card"),
2272
2387
  identity_id: idOf("idn"),
2273
- kind: z24.literal("prepaid"),
2388
+ kind: z25.literal("prepaid"),
2274
2389
  status: CardStatusSchema,
2275
- label: z24.string().min(1).max(128),
2276
- brand: z24.string().nullable(),
2277
- last4: z24.string().regex(/^\d{4}$/).nullable(),
2390
+ label: z25.string().min(1).max(128),
2391
+ brand: z25.string().nullable(),
2392
+ last4: z25.string().regex(/^\d{4}$/).nullable(),
2278
2393
  load_micro_usd: MicroUsdField,
2279
2394
  spent_micro_usd: MicroUsdField,
2280
- currency: z24.literal("usd"),
2395
+ currency: z25.literal("usd"),
2281
2396
  expires_at: Timestamp.nullable(),
2282
- failure_reason: z24.string().max(256).nullable(),
2397
+ failure_reason: z25.string().max(256).nullable(),
2283
2398
  created_at: Timestamp,
2284
2399
  updated_at: Timestamp
2285
2400
  });
2286
- var IssueCardSchema = z24.object({
2401
+ var IssueCardSchema = z25.object({
2287
2402
  label: CardSchema.shape.label,
2288
2403
  load_micro_usd: MicroUsdField.min(CARD_MIN_LOAD_MICRO_USD).max(CARD_MAX_LOAD_MICRO_USD).multipleOf(CARD_LOAD_GRANULARITY_MICRO_USD)
2289
2404
  });
2290
2405
  var CardQuoteRequestSchema = IssueCardSchema.pick({ load_micro_usd: true });
2291
- var CardQuoteSchema = z24.object({
2292
- object: z24.literal("card_quote"),
2406
+ var CardQuoteSchema = z25.object({
2407
+ object: z25.literal("card_quote"),
2293
2408
  load_micro_usd: MicroUsdField,
2294
2409
  price_micro_usd: MicroUsdField,
2295
- brand: z24.string().nullable(),
2410
+ brand: z25.string().nullable(),
2296
2411
  min_load_micro_usd: MicroUsdField,
2297
2412
  max_load_micro_usd: MicroUsdField
2298
2413
  });
2299
- var CardCredentialsSchema = z24.object({
2300
- object: z24.literal("card_credentials"),
2414
+ var CardCredentialsSchema = z25.object({
2415
+ object: z25.literal("card_credentials"),
2301
2416
  card_id: idOf("vcd"),
2302
- number: z24.string().min(1),
2303
- pin: z24.string().nullable(),
2304
- cvv: z24.string().nullable(),
2305
- expiry: z24.string().nullable(),
2306
- url: z24.url().nullable(),
2307
- instructions: z24.string().nullable(),
2417
+ number: z25.string().min(1),
2418
+ pin: z25.string().nullable(),
2419
+ cvv: z25.string().nullable(),
2420
+ expiry: z25.string().nullable(),
2421
+ url: z25.url().nullable(),
2422
+ instructions: z25.string().nullable(),
2308
2423
  revealed_at: Timestamp
2309
2424
  });
2310
- var CardTransactionSchema = z24.object({
2425
+ var CardTransactionSchema = z25.object({
2311
2426
  id: idOf("vct"),
2312
- object: z24.literal("card_transaction"),
2427
+ object: z25.literal("card_transaction"),
2313
2428
  card_id: idOf("vcd"),
2314
2429
  amount_micro_usd: MicroUsdField,
2315
- merchant: z24.string().nullable(),
2316
- description: z24.string().nullable(),
2430
+ merchant: z25.string().nullable(),
2431
+ description: z25.string().nullable(),
2317
2432
  session_id: idOf("ses").nullable(),
2318
2433
  metadata: Metadata,
2319
2434
  created_at: Timestamp
2320
2435
  });
2321
- var LogCardTransactionSchema = z24.object({
2436
+ var LogCardTransactionSchema = z25.object({
2322
2437
  amount_micro_usd: MicroUsdField.positive(),
2323
- merchant: z24.string().max(256).optional(),
2324
- description: z24.string().max(1024).optional(),
2438
+ merchant: z25.string().max(256).optional(),
2439
+ description: z25.string().max(1024).optional(),
2325
2440
  metadata: Metadata.optional()
2326
2441
  });
2327
- var ListCardsSchema = z24.object({ status: CardStatusSchema.optional() });
2442
+ var ListCardsSchema = z25.object({ status: CardStatusSchema.optional() });
2328
2443
 
2329
2444
  // src/define.ts
2330
- import { z as z27 } from "zod";
2445
+ import { z as z28 } from "zod";
2331
2446
 
2332
2447
  // src/roster.ts
2333
- import { z as z26 } from "zod";
2448
+ import { z as z27 } from "zod";
2334
2449
 
2335
2450
  // src/report.ts
2336
2451
  import { ApiError, send } from "@usenaive-sdk/vetta";
2337
- import { z as z25 } from "zod";
2452
+ import { z as z26 } from "zod";
2338
2453
  function message(error) {
2339
2454
  return error instanceof Error ? error.message : String(error);
2340
2455
  }
@@ -2374,10 +2489,10 @@ async function absent(work) {
2374
2489
  throw error;
2375
2490
  }
2376
2491
  }
2377
- var PageShape = z25.object({
2378
- data: z25.array(z25.unknown()),
2379
- has_more: z25.boolean(),
2380
- next_cursor: z25.string().nullable()
2492
+ var PageShape = z26.object({
2493
+ data: z26.array(z26.unknown()),
2494
+ has_more: z26.boolean(),
2495
+ next_cursor: z26.string().nullable()
2381
2496
  });
2382
2497
  function rowLabel(row) {
2383
2498
  const { object, id } = row ?? {};
@@ -2409,17 +2524,17 @@ async function tombstone(name, current, remove, dryRun) {
2409
2524
  }
2410
2525
 
2411
2526
  // src/roster.ts
2412
- var NAME = z26.string().min(1);
2413
- var RosterNameSchema = z26.union([
2527
+ var NAME = z27.string().min(1);
2528
+ var RosterNameSchema = z27.union([
2414
2529
  NAME.transform((name) => ({ type: "agent", name })),
2415
- z26.object({ type: z26.literal("agent"), name: NAME, version: z26.number().int().positive().optional() }),
2416
- z26.object({ type: z26.literal("self") }),
2417
- z26.object({ type: z26.literal("advisor"), model: z26.string().min(1) })
2530
+ z27.object({ type: z27.literal("agent"), name: NAME, version: z27.number().int().positive().optional() }),
2531
+ z27.object({ type: z27.literal("self") }),
2532
+ z27.object({ type: z27.literal("advisor"), model: z27.string().min(1) })
2418
2533
  ]);
2419
- var DeclMultiagentField = z26.union([
2420
- z26.boolean(),
2421
- z26.object({ ...MultiagentSchema.shape, agents: z26.array(RosterNameSchema).min(1).max(20) }),
2422
- z26.null()
2534
+ var DeclMultiagentField = z27.union([
2535
+ z27.boolean(),
2536
+ z27.object({ ...MultiagentSchema.shape, agents: z27.array(RosterNameSchema).min(1).max(20) }),
2537
+ z27.null()
2423
2538
  ]);
2424
2539
  var hasRoster = (value) => typeof value === "object" && value !== null;
2425
2540
  var rosterNames = (roster) => roster.agents.flatMap((entry) => entry.type === "agent" ? [entry.name] : []);
@@ -2507,67 +2622,73 @@ function chooseTemplate(blueprint, template) {
2507
2622
  var BlueprintRefusal = class extends Error {
2508
2623
  name = "BlueprintRefusal";
2509
2624
  };
2510
- var EnvValueSchema = z27.union([
2511
- z27.string(),
2512
- z27.object({ from_env: z27.string().min(1) }),
2513
- z27.object({ generate: z27.literal(true) })
2625
+ var EnvValueSchema = z28.union([
2626
+ z28.string(),
2627
+ z28.object({ from_env: z28.string().min(1) }),
2628
+ z28.object({ generate: z28.literal(true) })
2514
2629
  ]);
2515
- var AppDeclSchema = z27.object({
2630
+ var AppDeclSchema = z28.object({
2516
2631
  /** Becomes a hostname, so the grammar is the platform's `APP_NAME` (a DNS label). */
2517
- name: z27.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
2632
+ name: z28.string().regex(APP_NAME, "a lowercase DNS label, 63 characters or fewer"),
2518
2633
  type: AppTypeSchema,
2519
- description: z27.string().optional(),
2634
+ description: z28.string().optional(),
2520
2635
  /** A directory whose files are collected and shipped as the app's file-map deployment. */
2521
- deploy_dir: z27.string().min(1).optional(),
2636
+ deploy_dir: z28.string().min(1).optional(),
2522
2637
  /** The path the app itself serves MCP on (§29.5); `fullstack` only. Absent means none. */
2523
2638
  mcp: AppMcpPathSchema.optional(),
2524
2639
  /** Written as the app's write-only secrets (§29.2) on every apply; names follow the platform's `ENV_NAME`. */
2525
- env: z27.record(z27.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
2640
+ env: z28.record(z28.string().regex(ENV_NAME), EnvValueSchema, { error: "keyed by environment variable name (A-Z, 0-9, _)" }).optional(),
2526
2641
  /** An install may not leave this app out of its `selection` (§31.2). Absent means it may. */
2527
- required: z27.boolean().optional(),
2642
+ required: z28.boolean().optional(),
2528
2643
  // core-gaps: U8-database
2529
2644
  /** SQL files applied in order to the app's database after it is provisioned (§37); `fullstack` only. */
2530
- migrations: z27.array(z27.string().min(1)).optional(),
2645
+ migrations: z28.array(z28.string().min(1)).optional(),
2531
2646
  // core-gaps: storage-stock
2532
2647
  /** Buckets the app's object store must hold (§38.2); `fullstack` only. `public` defaults to false. */
2533
- buckets: z27.array(CreateBucketSchema).optional()
2648
+ buckets: z28.array(CreateBucketSchema).optional()
2534
2649
  });
2535
- var ScheduleDeclSchema = z27.object({
2536
- cron: z27.string().min(1),
2537
- timezone: z27.string().min(1).optional(),
2650
+ var ScheduleDeclSchema = z28.object({
2651
+ cron: z28.string().min(1),
2652
+ timezone: z28.string().min(1).optional(),
2538
2653
  /** The message every fire opens its session with (`input_template` on the wire). */
2539
- input: z27.string().min(1),
2654
+ input: z28.string().min(1),
2540
2655
  budget_micro_usd: MicroUsdField.nonnegative(),
2541
- identity: z27.string().min(1).optional(),
2542
- enabled: z27.boolean().optional()
2656
+ identity: z28.string().min(1).optional(),
2657
+ enabled: z28.boolean().optional()
2543
2658
  });
2544
2659
  var ToolsDeclSchema = ToolsetSchema;
2545
- var AgentDeclSchema = z27.object({
2546
- name: z27.string().min(1),
2547
- model: z27.string().min(1),
2660
+ var AgentDeclSchema = z28.object({
2661
+ name: z28.string().min(1),
2662
+ model: z28.string().min(1),
2548
2663
  budget: BudgetSchema,
2549
- description: z27.string().optional(),
2664
+ description: z28.string().optional(),
2550
2665
  /** Two or three words the studio prints beside the name (§31.5) — "Head of content", not a sentence. */
2551
- role: z27.string().min(1).optional(),
2666
+ role: z28.string().min(1).optional(),
2552
2667
  /** An install may not leave this agent out of its `selection` (§31.2). Absent means it may. */
2553
- required: z27.boolean().optional(),
2554
- system: z27.string().optional(),
2668
+ required: z28.boolean().optional(),
2669
+ system: z28.string().optional(),
2555
2670
  tools: ToolsDeclSchema.optional(),
2556
- skills: z27.array(SkillRefSchema).optional(),
2557
- mcp_servers: z27.array(McpServerSchema).optional(),
2671
+ skills: z28.array(SkillRefSchema).optional(),
2672
+ mcp_servers: z28.array(McpServerSchema).optional(),
2558
2673
  /** The rest of the runtime's agent config (§31.6), each the core schema; absent means the route's default and never drift. */
2559
2674
  window: WindowSchema.optional(),
2560
2675
  /** A roster names crew members by declared *name*; `up` resolves them to `agt_` ids in a second pass (`roster.ts`). */
2561
2676
  multiagent: DeclMultiagentField.optional(),
2562
2677
  output_schema: JsonSchemaDocument.nullable().optional(),
2563
- structured_output_required: z27.boolean().optional(),
2678
+ structured_output_required: z28.boolean().optional(),
2564
2679
  metadata: Metadata.optional(),
2565
2680
  /** Declared app *names*; `up` resolves them to `app_` ids in `tools.configs.apps` (§29.3). */
2566
- allowed_apps: z27.array(z27.string()).optional(),
2681
+ allowed_apps: z28.array(z28.string()).optional(),
2567
2682
  /** A declared identity *name*; `up` attaches it after the agent upsert (§22). */
2568
- identity: z27.string().min(1).optional(),
2683
+ identity: z28.string().min(1).optional(),
2684
+ /**
2685
+ * Who this agent may `send_to_agent` (§31.7, §28.12): `true` (anyone in the organization),
2686
+ * `false` (nobody), `"team"` (its `multiagent` roster), or declared agent *names*, checked
2687
+ * against the roster here. Absent means the route's default, `true`, and is never drift.
2688
+ */
2689
+ handoffs: HandoffsField.optional(),
2569
2690
  /** The agent's deployments as a complete set: declared → owned, and the rest are pruned (ADR-0355). */
2570
- schedules: z27.array(ScheduleDeclSchema).optional(),
2691
+ schedules: z28.array(ScheduleDeclSchema).optional(),
2571
2692
  /**
2572
2693
  * The first thing this agent reads, once, on the apply that **creates** it (`canonical-spec
2573
2694
  * §31.4`). It is what turns a provisioned crew into a crew that has started working.
@@ -2580,58 +2701,66 @@ var AgentDeclSchema = z27.object({
2580
2701
  * repeatedly and unattended while an intake spends once, at an apply a person is watching. Absent
2581
2702
  * means the agent's own `budget` governs.
2582
2703
  */
2583
- intake: z27.object({ message: z27.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
2704
+ intake: z28.object({ message: z28.string().min(1), budget_micro_usd: MicroUsdField.nonnegative().optional() }).optional()
2584
2705
  });
2585
- var CredentialDeclSchema = z27.object({
2706
+ var CredentialDeclSchema = z28.object({
2586
2707
  kind: VaultCredentialKindSchema,
2587
- key: z27.string().min(1).max(128),
2708
+ key: z28.string().min(1).max(128),
2588
2709
  /** The one exact destination host an `env_var` is bound to. */
2589
- host: z27.string().min(1).optional(),
2710
+ host: z28.string().min(1).optional(),
2590
2711
  /** The MCP server URL a `static_bearer` / `mcp_oauth` token is matched to. */
2591
- mcp_server_url: z27.url().optional(),
2592
- value: z27.object({ from_env: z27.string().min(1) })
2712
+ mcp_server_url: z28.url().optional(),
2713
+ value: z28.object({ from_env: z28.string().min(1) })
2593
2714
  });
2594
- var VaultDeclSchema = z27.object({
2715
+ var VaultDeclSchema = z28.object({
2595
2716
  name: VaultSchema.shape.display_name,
2596
- identity: z27.string().min(1).optional(),
2597
- credentials: z27.array(CredentialDeclSchema)
2717
+ identity: z28.string().min(1).optional(),
2718
+ credentials: z28.array(CredentialDeclSchema)
2598
2719
  });
2599
- var SkillDeclSchema = z27.object({
2600
- slug: z27.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2601
- file: z27.string().min(1)
2720
+ var SkillDeclSchema = z28.object({
2721
+ slug: z28.string().regex(/^[a-z0-9][a-z0-9-]*$/, "lowercase letters, digits and dashes"),
2722
+ file: z28.string().min(1)
2602
2723
  });
2603
2724
  var LegalDeclSchema = CreateLegalCompanySchema.pick({
2604
2725
  state: true,
2605
2726
  name_options: true,
2606
2727
  naics_code: true,
2607
2728
  description: true
2608
- }).extend({ label: z27.string().min(1).max(128) });
2729
+ }).extend({ label: z28.string().min(1).max(128) });
2609
2730
  var WalletDeclSchema = CreateWalletSchema.or(
2610
- z27.array(CreateWalletSchema).refine(
2731
+ z28.array(CreateWalletSchema).refine(
2611
2732
  (list2) => new Set(list2.map((w) => w.network ?? DEFAULT_WALLET_NETWORK)).size === list2.length,
2612
2733
  { message: "one wallet per network" }
2613
2734
  )
2614
2735
  );
2615
2736
  var CardDeclSchema = IssueCardSchema;
2616
2737
  var IdentityDeclSchema = IdentitySchema.pick({ name: true, description: true }).partial({ description: true }).extend({
2617
- legal: z27.array(LegalDeclSchema).optional(),
2738
+ connections: BlueprintIdentityConnectionsSchema.optional(),
2739
+ legal: z28.array(LegalDeclSchema).optional(),
2618
2740
  wallet: WalletDeclSchema.optional(),
2619
- cards: z27.array(CardDeclSchema).optional()
2620
- });
2621
- var RemovedSchema = z27.object({
2622
- apps: z27.array(z27.string().min(1)).default([]),
2623
- agents: z27.array(z27.string().min(1)).default([]),
2624
- skills: z27.array(z27.string().min(1)).default([]),
2625
- identities: z27.array(z27.string().min(1)).default([]),
2626
- vaults: z27.array(z27.string().min(1)).default([])
2627
- });
2628
- var KeptSchema = z27.object({ agents: z27.array(z27.string().min(1)).default([]) });
2629
- var ProjectSchema = z27.object({
2630
- name: z27.string().min(1),
2741
+ cards: z28.array(CardDeclSchema).optional()
2742
+ });
2743
+ var RemovedSchema = z28.object({
2744
+ apps: z28.array(z28.string().min(1)).default([]),
2745
+ agents: z28.array(z28.string().min(1)).default([]),
2746
+ skills: z28.array(z28.string().min(1)).default([]),
2747
+ identities: z28.array(z28.string().min(1)).default([]),
2748
+ vaults: z28.array(z28.string().min(1)).default([])
2749
+ });
2750
+ var KeptSchema = z28.object({ agents: z28.array(z28.string().min(1)).default([]) });
2751
+ var TaskDeclSchema = z28.object({
2752
+ key: z28.string().min(1),
2753
+ title: z28.string().min(1).max(200),
2754
+ body: z28.string().max(8192).optional(),
2755
+ assignee: z28.string().min(1).optional(),
2756
+ blocked_by: z28.array(z28.string().min(1)).optional()
2757
+ });
2758
+ var ProjectSchema = z28.object({
2759
+ name: z28.string().min(1),
2631
2760
  /** The machine this project runs: its repo, its screens, its `/api/*` (`template.ts`). */
2632
- blueprint: z27.string().min(1).optional(),
2761
+ blueprint: z28.string().min(1).optional(),
2633
2762
  /** Which of that blueprint's templates provides the crew; a blueprint with a default may omit it. */
2634
- template: z27.string().min(1).optional(),
2763
+ template: z28.string().min(1).optional(),
2635
2764
  /**
2636
2765
  * What a person is asked BEFORE the crew is provisioned (`canonical-spec §31.2`).
2637
2766
  *
@@ -2643,19 +2772,21 @@ var ProjectSchema = z27.object({
2643
2772
  *
2644
2773
  * **Configuration only.** A secret is a vault credential or an app secret; neither is an answer.
2645
2774
  */
2646
- questions: z27.array(QuestionFieldSchema).default([]),
2647
- skills: z27.array(SkillDeclSchema).default([]),
2648
- identities: z27.array(IdentityDeclSchema).default([]),
2649
- vaults: z27.array(VaultDeclSchema).default([]),
2650
- apps: z27.array(AppDeclSchema).default([]),
2651
- agents: z27.array(AgentDeclSchema).default([]),
2775
+ questions: z28.array(QuestionFieldSchema).default([]),
2776
+ skills: z28.array(SkillDeclSchema).default([]),
2777
+ identities: z28.array(IdentityDeclSchema).default([]),
2778
+ vaults: z28.array(VaultDeclSchema).default([]),
2779
+ apps: z28.array(AppDeclSchema).default([]),
2780
+ agents: z28.array(AgentDeclSchema).default([]),
2652
2781
  /**
2653
2782
  * The agents this template creates PER CLIENT the operator signs (`canonical-spec §31.1`) —
2654
2783
  * printed on the artifact so a person sees the whole company, never provisioned by an apply,
2655
2784
  * because the apply does not know the clients yet. Names only: a model and a budget are the
2656
2785
  * crew's business at the moment a client is signed, not the declaration's.
2657
2786
  */
2658
- crew_per_client: z27.array(z27.object({ name: z27.string().min(1), role: z27.string().min(1).optional(), description: z27.string().optional() })).optional(),
2787
+ crew_per_client: z28.array(z28.object({ name: z28.string().min(1), role: z28.string().min(1).optional(), description: z28.string().optional() })).optional(),
2788
+ /** The crew's first work, as cards on the organization's board rather than N private intakes (§31.11). */
2789
+ tasks: z28.array(TaskDeclSchema).default([]),
2659
2790
  removed: RemovedSchema.default({ apps: [], agents: [], skills: [], identities: [], vaults: [] }),
2660
2791
  kept: KeptSchema.default({ agents: [] })
2661
2792
  });
@@ -2671,6 +2802,20 @@ function assertUniqueNames(kind, names) {
2671
2802
  seen.add(name);
2672
2803
  }
2673
2804
  }
2805
+ function inDependencyOrder(tasks) {
2806
+ const placed = /* @__PURE__ */ new Set();
2807
+ const out = [];
2808
+ while (out.length < tasks.length) {
2809
+ const next = tasks.find((task) => !placed.has(task.key) && (task.blocked_by ?? []).every((key) => placed.has(key)));
2810
+ if (next === void 0) {
2811
+ const stuck = tasks.filter((task) => !placed.has(task.key)).map((task) => `"${task.key}"`);
2812
+ refuse(`tasks ${stuck.join(", ")}: blocked_by forms a cycle \u2014 a card cannot wait on a card that waits on it`);
2813
+ }
2814
+ placed.add(next.key);
2815
+ out.push(next);
2816
+ }
2817
+ return out;
2818
+ }
2674
2819
  function deepFreeze(value) {
2675
2820
  if (value !== null && typeof value === "object") {
2676
2821
  for (const child of Object.values(value)) deepFreeze(child);
@@ -2718,6 +2863,20 @@ function parseProject(input) {
2718
2863
  assertUniqueNames("bucket", (app.buckets ?? []).map((bucket) => bucket.name));
2719
2864
  }
2720
2865
  const identityNames = new Set(config.identities.map((i) => i.name));
2866
+ const connectable = config.identities.filter((i) => i.connections !== void 0).map((i) => i.name);
2867
+ if (connectable.length > 1) {
2868
+ refuse(`identities ${connectable.map((n) => `"${n}"`).join(", ")} each declare connections, but the studio's Add connections step connects one persona \u2014 declare connections on the one the crew publishes through`);
2869
+ }
2870
+ for (const identity of config.identities) {
2871
+ const social = identity.connections?.social;
2872
+ if (social === void 0) continue;
2873
+ const question = config.questions.find((q) => q.key === social.from);
2874
+ if (question === void 0) refuse(`identity "${identity.name}": connections.social.from names "${social.from}", but no question with that key is declared in this project`);
2875
+ if (question.type !== "choice") refuse(`identity "${identity.name}": connections.social.from names "${social.from}", which is a ${question.type} question \u2014 the map is keyed by a choice question's options`);
2876
+ for (const label of Object.keys(social.map)) {
2877
+ if (!question.options.includes(label)) refuse(`identity "${identity.name}": connections.social.map names "${label}", which is not one of question "${social.from}"'s options \u2014 a key no answer can equal is a row nobody can reach`);
2878
+ }
2879
+ }
2721
2880
  for (const vault of config.vaults) {
2722
2881
  if (vault.identity !== void 0 && !identityNames.has(vault.identity)) {
2723
2882
  refuse(`vault "${vault.name}": identity names "${vault.identity}", but no identity with that name is declared in this project`);
@@ -2754,6 +2913,17 @@ function parseProject(input) {
2754
2913
  if (agent.identity !== void 0 && !identityNames.has(agent.identity)) {
2755
2914
  refuse(`agent "${agent.name}": identity names "${agent.identity}", but no identity with that name is declared in this project`);
2756
2915
  }
2916
+ if (agent.handoffs === "team" && !hasRoster(agent.multiagent)) {
2917
+ refuse(`agent "${agent.name}": handoffs is "team", but the agent declares no multiagent roster \u2014 there is no team to hand to`);
2918
+ }
2919
+ const handoffs = /* @__PURE__ */ new Set();
2920
+ for (const name of Array.isArray(agent.handoffs) ? agent.handoffs : []) {
2921
+ if (name === agent.name) refuse(`agent "${agent.name}": handoffs names itself \u2014 an agent cannot send_to_agent its own seat`);
2922
+ if (config.removed.agents.includes(name)) refuse(`agent "${agent.name}": handoffs names "${name}", which this config removes \u2014 drop it from handoffs or keep the agent`);
2923
+ if (!agentNames.has(name)) refuse(`agent "${agent.name}": handoffs names "${name}", but no agent with that name is declared in this project`);
2924
+ if (handoffs.has(name)) refuse(`agent "${agent.name}": handoffs names "${name}" twice`);
2925
+ handoffs.add(name);
2926
+ }
2757
2927
  const crons = /* @__PURE__ */ new Set();
2758
2928
  for (const schedule of agent.schedules ?? []) {
2759
2929
  if (crons.has(schedule.cron)) {
@@ -2765,6 +2935,21 @@ function parseProject(input) {
2765
2935
  }
2766
2936
  }
2767
2937
  }
2938
+ assertUniqueNames("task", config.tasks.map((task) => task.key));
2939
+ const taskKeys = new Set(config.tasks.map((task) => task.key));
2940
+ for (const task of config.tasks) {
2941
+ if (`${config.name}:${task.key}`.length > 128) {
2942
+ refuse(`task "${task.key}": "${config.name}:${task.key}" is longer than the 128 characters a card key holds \u2014 shorten the key`);
2943
+ }
2944
+ if (task.assignee !== void 0 && !agentNames.has(task.assignee)) {
2945
+ refuse(`task "${task.key}": assignee names "${task.assignee}", but no agent with that name is declared in this project`);
2946
+ }
2947
+ for (const key of task.blocked_by ?? []) {
2948
+ if (key === task.key) refuse(`task "${task.key}": blocked_by names itself \u2014 a card cannot wait on itself`);
2949
+ if (!taskKeys.has(key)) refuse(`task "${task.key}": blocked_by names "${key}", but no task with that key is declared in this project`);
2950
+ }
2951
+ }
2952
+ inDependencyOrder(config.tasks);
2768
2953
  return deepFreeze(config);
2769
2954
  }
2770
2955
  function withTemplate(input, templates) {
@@ -2922,14 +3107,17 @@ function desiredSystem(decl, of) {
2922
3107
  ${decl.system}`;
2923
3108
  }
2924
3109
  function desiredTools(decl, current, ids) {
2925
- if (ids === void 0) return decl.tools;
3110
+ const handoff = decl.handoffs !== void 0 && handoffsEnabled(decl.handoffs);
3111
+ if (ids === void 0 && !handoff) return decl.tools;
2926
3112
  const base = decl.tools ?? current?.tools ?? { default_config: { permission: "allow" }, configs: {} };
2927
3113
  const appsTool = base.configs["apps"] ?? { enabled: true, permission: base.default_config.permission };
3114
+ const allowed = { enabled: true, permission: "allow" };
2928
3115
  return {
2929
3116
  default_config: base.default_config,
2930
3117
  configs: {
2931
3118
  ...base.configs,
2932
- apps: { ...appsTool, config: { ...appsTool.config, allowed_apps: ids } }
3119
+ ...ids !== void 0 ? { apps: { ...appsTool, config: { ...appsTool.config, allowed_apps: ids } } } : {},
3120
+ ...handoff ? { send_to_agent: allowed, list_agents: allowed } : {}
2933
3121
  }
2934
3122
  };
2935
3123
  }
@@ -2945,6 +3133,7 @@ async function createAgent(client, decl, tools, team, identityId, system, metada
2945
3133
  ...tools !== void 0 ? { tools } : {},
2946
3134
  ...decl.window !== void 0 ? { window: decl.window } : {},
2947
3135
  ...team !== void 0 ? { multiagent: team } : {},
3136
+ ...decl.handoffs !== void 0 ? { handoffs: decl.handoffs } : {},
2948
3137
  ...decl.output_schema !== void 0 ? { output_schema: decl.output_schema } : {},
2949
3138
  ...decl.structured_output_required !== void 0 ? { structured_output_required: decl.structured_output_required } : {},
2950
3139
  ...metadata !== void 0 ? { metadata } : {}
@@ -2990,6 +3179,7 @@ function drift(decl, current, tools, team, system, metadata) {
2990
3179
  if (changed(tools, current.tools)) patch.tools = tools;
2991
3180
  if (changed(decl.window, current.window)) patch.window = decl.window;
2992
3181
  if (team !== void 0 && changed(normaliseMultiagent(team), normaliseMultiagent(current.multiagent))) patch.multiagent = team;
3182
+ if (changed(decl.handoffs, handoffsOf(current))) patch.handoffs = decl.handoffs;
2993
3183
  if (changed(decl.output_schema, current.output_schema)) patch.output_schema = decl.output_schema;
2994
3184
  if (changed(decl.structured_output_required, current.structured_output_required)) patch.structured_output_required = decl.structured_output_required;
2995
3185
  if (changed(metadata, current.metadata)) patch.metadata = metadata;
@@ -3122,9 +3312,14 @@ var PLATFORM_ENV = {
3122
3312
  identity_id: "NAIVE_IDENTITY_ID",
3123
3313
  /** The install's `project` — the row the app's own context lookup lands on (§31.8). */
3124
3314
  project: "NAIVE_PROJECT",
3315
+ /** The base URL of the Studio that installed the app, so it can send a signed-out visitor back. */
3316
+ studio_url: "NAIVE_STUDIO_URL",
3317
+ /** The app's own `app_…` id — the one known value learnt from the row, not from the apply. */
3318
+ app_id: "NAIVE_APP_ID",
3125
3319
  /** A scoped organization API key minted for the app that asks for it. */
3126
3320
  api_key: "NAIVE_API_KEY"
3127
3321
  };
3322
+ var DASHBOARD_PASSWORD = "DASHBOARD_PASSWORD";
3128
3323
  function planEnv(decl, opts) {
3129
3324
  if (decl.env === void 0) return [];
3130
3325
  const plan = /* @__PURE__ */ new Map();
@@ -3134,7 +3329,7 @@ function planEnv(decl, opts) {
3134
3329
  continue;
3135
3330
  }
3136
3331
  if ("generate" in value) {
3137
- plan.set(name, { name, invent: async () => generated() });
3332
+ plan.set(name, { name, invent: async () => name === DASHBOARD_PASSWORD ? generatedPassword() : generatedSecret() });
3138
3333
  continue;
3139
3334
  }
3140
3335
  const known = opts.platform?.known[value.from_env];
@@ -3170,7 +3365,31 @@ async function invent(one) {
3170
3365
  );
3171
3366
  }
3172
3367
  }
3173
- var generated = () => randomBytes(32).toString("base64url");
3368
+ var generatedSecret = () => randomBytes(32).toString("base64url");
3369
+ var PASSWORD_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
3370
+ var PASSWORD_GROUPS = 4;
3371
+ var PASSWORD_GROUP_LENGTH = 4;
3372
+ function generatedPassword() {
3373
+ const limit = 256 - 256 % PASSWORD_ALPHABET.length;
3374
+ const groups = [];
3375
+ let group = "";
3376
+ while (groups.length < PASSWORD_GROUPS) {
3377
+ for (const byte of randomBytes(PASSWORD_GROUPS * PASSWORD_GROUP_LENGTH * 2)) {
3378
+ if (byte >= limit) continue;
3379
+ group += PASSWORD_ALPHABET[byte % PASSWORD_ALPHABET.length];
3380
+ if (group.length === PASSWORD_GROUP_LENGTH) {
3381
+ groups.push(group);
3382
+ group = "";
3383
+ if (groups.length === PASSWORD_GROUPS) break;
3384
+ }
3385
+ }
3386
+ }
3387
+ return groups.join("-");
3388
+ }
3389
+ function withAppId(env, decl, opts, id) {
3390
+ if (decl.env === void 0 || opts.platform === void 0) return env;
3391
+ return { ...env, [PLATFORM_ENV.app_id]: id };
3392
+ }
3174
3393
  var EMPTY = /* @__PURE__ */ new Set();
3175
3394
  function secretHash(name, value) {
3176
3395
  return createHash2("sha256").update(`${name}\0`).update(value).digest("hex");
@@ -3214,7 +3433,7 @@ async function createApp(client, decl, env, tree, migrations, opts, appIds) {
3214
3433
  ...decl.mcp !== void 0 ? { mcp: decl.mcp } : {}
3215
3434
  });
3216
3435
  appIds.set(decl.name, created.id);
3217
- await writeApp(client, created.id, env, tree);
3436
+ await writeApp(client, created.id, withAppId(env, decl, opts, created.id), tree);
3218
3437
  const notes = [];
3219
3438
  if (migrations.length > 0) notes.push((await applyMigrations(client, created.id, migrations)).note);
3220
3439
  if (decl.buckets !== void 0) notes.push((await applyBuckets(client, created.id, decl.buckets)).note);
@@ -3228,7 +3447,8 @@ async function createApp(client, decl, env, tree, migrations, opts, appIds) {
3228
3447
  }
3229
3448
  async function upsertApp(client, decl, opts, appIds) {
3230
3449
  const declared = planEnv(decl, opts);
3231
- const names = declared.map((one) => one.name);
3450
+ const writesAppId = decl.env !== void 0 && opts.platform !== void 0;
3451
+ const names = [...declared.map((one) => one.name), ...writesAppId ? [PLATFORM_ENV.app_id] : []];
3232
3452
  const note = (notes) => notes.length > 0 ? { reason: notes.join("; ") } : {};
3233
3453
  const mcpPlan = decl.mcp !== void 0 ? [`will set mcp ${decl.mcp}`] : [];
3234
3454
  const migrationPlan = decl.migrations !== void 0 ? [`will apply migrations ${decl.migrations.join(", ")}`] : [];
@@ -3243,8 +3463,8 @@ async function upsertApp(client, decl, opts, appIds) {
3243
3463
  ...note([...willSet, ...mcpPlan, ...decl.deploy_dir ? [`will deploy ${decl.deploy_dir}`] : [], ...migrationPlan, ...bucketPlan])
3244
3464
  };
3245
3465
  }
3246
- const { values } = await materialize(declared, EMPTY, false);
3247
- return createApp(client, decl, values, builtTree(decl, opts), declaredMigrations(decl, opts), opts, appIds);
3466
+ const { values: values2 } = await materialize(declared, EMPTY, false);
3467
+ return createApp(client, decl, values2, builtTree(decl, opts), declaredMigrations(decl, opts), opts, appIds);
3248
3468
  }
3249
3469
  const owned = current.project === opts.project;
3250
3470
  if (!owned && !opts.adopt) {
@@ -3273,7 +3493,8 @@ async function upsertApp(client, decl, opts, appIds) {
3273
3493
  const managed = new Set(names);
3274
3494
  const unmanaged = live.map((secret) => secret.name).filter((name) => !managed.has(name));
3275
3495
  const held = new Map(live.map((secret) => [secret.name, secret.value_hash]));
3276
- const { values: env, unmade } = await materialize(declared, new Set(held.keys()), opts.dryRun);
3496
+ const { values, unmade } = await materialize(declared, new Set(held.keys()), opts.dryRun);
3497
+ const env = withAppId(values, decl, opts, current.id);
3277
3498
  const staleEnv = Object.fromEntries(
3278
3499
  Object.entries(env).filter(([name, value]) => held.get(name) !== secretHash(name, value))
3279
3500
  );
@@ -3419,6 +3640,75 @@ async function reportLegal(client, decls, identityId, skipped) {
3419
3640
  );
3420
3641
  }
3421
3642
 
3643
+ // src/tasks.ts
3644
+ var ORCHESTRATOR_MARKER = "orchestrator";
3645
+ var CEO_LABEL = "CEO";
3646
+ var CEO_DETAIL = "Hires and directs the crew";
3647
+ var CEO_BUDGET = { cap_micro_usd: 5e7, max_task_micro_usd: 5e6, period: "month" };
3648
+ var isOrchestrator = (agent) => agent.metadata["role"] === ORCHESTRATOR_MARKER;
3649
+ function seated(live, members) {
3650
+ const roster = live?.agents ?? [];
3651
+ const already = new Set(roster.flatMap((entry) => entry.type === "agent" ? [entry.id] : []));
3652
+ const joining = members.filter((id) => !already.has(id)).map((id) => ({ type: "agent", id }));
3653
+ return { type: "coordinator", board: true, agents: [...roster, ...joining] };
3654
+ }
3655
+ async function ensureOrchestrator(client, existing, members, dryRun) {
3656
+ const current = existing.find(isOrchestrator);
3657
+ const live = current === void 0 ? null : normaliseMultiagent(current.multiagent);
3658
+ const team = seated(live, members);
3659
+ if (current === void 0) {
3660
+ if (dryRun) return { name: CEO_LABEL, action: "created" };
3661
+ const model = (await client.models.list({ window: "immediate", limit: 1 })).data[0];
3662
+ if (model === void 0) throw new BlueprintRefusal("no model is served, so the board's owner cannot be created");
3663
+ const made = await client.agents.create({
3664
+ name: CEO_LABEL,
3665
+ harness: "pi",
3666
+ model: model.id,
3667
+ description: CEO_DETAIL,
3668
+ budget: CEO_BUDGET,
3669
+ metadata: { role: ORCHESTRATOR_MARKER },
3670
+ multiagent: team
3671
+ });
3672
+ return { name: CEO_LABEL, action: "created", id: made.id };
3673
+ }
3674
+ if (live !== null && !changed(team, live)) return { name: current.name, action: "unchanged", id: current.id };
3675
+ if (!dryRun) await client.agents.update(current.id, { multiagent: team });
3676
+ return { name: current.name, action: "updated", id: current.id };
3677
+ }
3678
+ async function seedTasks(client, config, existing, agents, dryRun, into, skipped) {
3679
+ const members = agents.flatMap((one) => one.id === void 0 ? [] : [one.id]);
3680
+ const owner = await line(CEO_LABEL, () => ensureOrchestrator(client, existing, members, dryRun));
3681
+ agents.push(owner);
3682
+ const board = owner.action === "refused" || dryRun || owner.id === void 0 ? null : await client.board.create(owner.id);
3683
+ const before = board === null ? [] : await listAll(client.config, `/v1/boards/${board.id}/cards`, BoardCardSchema, skipped);
3684
+ const known = new Set(before.map((card) => card.id));
3685
+ const ids = /* @__PURE__ */ new Map();
3686
+ for (const task of inDependencyOrder(config.tasks)) {
3687
+ into.push(
3688
+ await line(task.key, async () => {
3689
+ if (owner.action === "refused") return { name: task.key, action: "refused", reason: `board owner "${owner.name}" was refused: ${owner.reason}` };
3690
+ const assignee = task.assignee;
3691
+ if (assignee !== void 0 && !agents.some((one) => one.name === assignee && one.action !== "refused")) {
3692
+ return { name: task.key, action: "refused", reason: `assignee "${assignee}" was not provisioned in this run` };
3693
+ }
3694
+ if (board === null) return { name: task.key, action: "created" };
3695
+ const blockers = task.blocked_by ?? [];
3696
+ const unmet = blockers.find((key) => !ids.has(key));
3697
+ if (unmet !== void 0) return { name: task.key, action: "refused", reason: `blocked_by "${unmet}" was not seeded in this run` };
3698
+ const card = await client.board.cards.create(board.id, {
3699
+ key: `${config.name}:${task.key}`,
3700
+ title: task.title,
3701
+ body: task.body,
3702
+ assignee,
3703
+ blocked_by: blockers.map((key) => ids.get(key))
3704
+ });
3705
+ ids.set(task.key, card.id);
3706
+ return { name: task.key, action: known.has(card.id) ? "unchanged" : "created", id: card.id };
3707
+ })
3708
+ );
3709
+ }
3710
+ }
3711
+
3422
3712
  // src/vaults.ts
3423
3713
  async function upsertVault(client, decl, existing, identityIds, dryRun) {
3424
3714
  const identityId = decl.identity === void 0 ? void 0 : identityIds.get(decl.identity);
@@ -3629,7 +3919,7 @@ async function up(config, client, opts = {}) {
3629
3919
  const dir = opts.dir ?? process.cwd();
3630
3920
  const ids = { apps: /* @__PURE__ */ new Map(), identities: /* @__PURE__ */ new Map() };
3631
3921
  const taken = selectCrew(config, opts.select);
3632
- const report2 = { dry_run: dryRun, ...applied(config), skills: [], identities: [], vaults: [], apps: [], agents: [], schedules: [], intake: [], skipped: [], deselected: taken.deselected };
3922
+ const report2 = { dry_run: dryRun, ...applied(config), skills: [], identities: [], vaults: [], apps: [], agents: [], schedules: [], intake: [], tasks: [], skipped: [], deselected: taken.deselected };
3633
3923
  const owner = { project: config.name, adopt: opts.adopt ?? false, skipped: report2.skipped };
3634
3924
  const hosted = opts.trees !== void 0;
3635
3925
  for (const decl of config.skills) {
@@ -3692,7 +3982,7 @@ async function up(config, client, opts = {}) {
3692
3982
  )
3693
3983
  )
3694
3984
  );
3695
- const existing = taken.agents.length > 0 || config.removed.agents.length > 0 || config.kept.agents.length > 0 ? await listAll(client.config, "/v1/agents", AgentSchema, report2.skipped) : [];
3985
+ const existing = taken.agents.length > 0 || config.removed.agents.length > 0 || config.kept.agents.length > 0 || config.tasks.length > 0 ? await listAll(client.config, "/v1/agents", AgentSchema, report2.skipped) : [];
3696
3986
  const deployments = taken.agents.some((decl) => decl.schedules !== void 0) ? await listAll(client.config, "/v1/deployments", DeploymentSchema, report2.skipped) : [];
3697
3987
  const scoped = config.apps.length > 0 ? [...ids.apps.values()] : void 0;
3698
3988
  const crew = await eachInFlight(taken.agents, async (decl) => {
@@ -3719,6 +4009,7 @@ async function up(config, client, opts = {}) {
3719
4009
  if (hasRoster(decl.multiagent)) await patchRoster(client, decl, decl.multiagent, existing, agentIds, dryRun, report2.agents);
3720
4010
  }
3721
4011
  reportKept(config, existing, report2.agents);
4012
+ if (config.tasks.length > 0) await seedTasks(client, config, existing, report2.agents, dryRun, report2.tasks, report2.skipped);
3722
4013
  await applyRemoved(client, config.removed, { agents: existing, vaults }, owner, report2);
3723
4014
  if (briefed.length > 0 && !dryRun) {
3724
4015
  const serving = taken.apps.flatMap((decl) => {
@@ -3742,6 +4033,8 @@ export {
3742
4033
  collectFiles,
3743
4034
  contentHash,
3744
4035
  defineProject,
4036
+ generatedPassword,
4037
+ generatedSecret,
3745
4038
  hasRoster,
3746
4039
  loadConfig,
3747
4040
  migrationFiles,