@keystrokehq/cli 0.0.137 → 0.0.139

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.mjs CHANGED
@@ -1,18 +1,94 @@
1
1
  #!/usr/bin/env node
2
- import { _ as _coercedNumber, a as array, c as discriminatedUnion, d as object, f as record, g as url, h as unknown, i as _enum, l as literal, m as union, n as ZodNumber, o as boolean, p as string, r as ZodType, s as custom, t as entryIdFromFile, u as number$1 } from "./discovery-XqwkB9H_-C2XdYbG2.mjs";
2
+ import { $ as QueuedRunResponseSchema, A as ListOrganizationInvitationsResponseSchema, B as PollRunResponseSchema, C as HealthResponseSchema, Ct as listenPortFromPublicUrl, D as HistoryRunListResponseSchema, E as HistoryRunListQuerySchema, Et as parseErrorResponse, F as ListProjectMetricsResponseSchema, G as PresignUserAvatarRequestSchema, H as PresignOrgLogoResponseSchema, I as ListProjectsResponseSchema, J as ProjectResponseSchema, K as PresignUserAvatarResponseSchema, L as OrganizationSidebarBrandingPatchSchema, M as ListOrganizationsResponseSchema, N as ListProjectDeploymentsResponseSchema, O as InviteOrganizationMembersRequestSchema, P as ListProjectFilesResponseSchema, Q as QueuedAgentPromptResponseSchema, R as OrganizationSidebarBrandingSchema, S as GatewayAttachmentRecordSchema, St as WorkflowSummaryListResponseSchema, T as HistoryRunDetailResponseSchema, Tt as originFromPublicUrl, U as PresignProjectSourceRequestSchema, V as PresignOrgLogoRequestSchema, W as PresignProjectSourceResponseSchema, X as PromptInputSchema, Y as ProjectSlugAvailabilityResponseSchema, Z as PromptResponseSchema, _ as CreateProjectResponseSchema, _t as UserAvatarPatchSchema, a as AgentSessionDetailResponseSchema, at as TriggerDetailResponseSchema, b as DeclineOrganizationInvitationResponseSchema, bt as WorkflowRunListResponseSchema, c as AgentSummaryListResponseSchema, ct as TriggerRunListResponseSchema, d as ConnectProvidersResponseSchema, dt as UpdateOrganizationMemberResponseSchema, et as ROUTE_MANIFEST_REL_PATH, f as CreateCredentialInstanceBodySchema, ft as UpdateOrganizationRequestSchema, g as CreateProjectRequestSchema, gt as UpsertGatewayAttachmentBodySchema, h as CreateProjectArtifactResponseSchema, ht as UploadProjectSourceResponseSchema, i as AgentListResponseSchema, it as SlugAvailabilityResponseSchema, j as ListOrganizationMembersResponseSchema, k as InviteOrganizationMembersResponseSchema, l as CompleteProjectArtifactResponseSchema, lt as UpdateCredentialInstanceBodySchema, m as CreateOrganizationResponseSchema, mt as UploadProjectSourceManifestRequestSchema, n as AcceptOrganizationInvitationResponseSchema, nt as SkillSummaryDetailResponseSchema, o as AgentSessionListResponseSchema, ot as TriggerListResponseSchema, p as CreateOrganizationRequestSchema, pt as UpdateProjectRequestSchema, q as ProjectReachabilityResponseSchema, r as ActiveOrganizationResponseSchema, rt as SkillSummaryListResponseSchema, s as AgentSummaryDetailResponseSchema, st as TriggerRunDetailResponseSchema, t as ACTIVE_ORG_HEADER, tt as RecentResourceListResponseSchema, u as ConnectAuthorizeUrlResponseSchema, ut as UpdateOrganizationMemberRequestSchema, v as CredentialInstanceListResponseSchema, vt as UserAvatarSchema, w as HistoryRunCancelResponseSchema, x as ErrorResponseSchema, xt as WorkflowSummaryDetailResponseSchema, y as CredentialInstanceRecordSchema, yt as WorkflowRunDetailResponseSchema, z as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS } from "./dist-B27Z3YpE.mjs";
3
+ import { t as walkProject } from "./walk-project-171B4cvO-DJy3qZKd.mjs";
3
4
  import { a as installPlaygroundDependencies, i as installDependencies, n as buildPlaygroundWorkspace, o as resolvePackageManager, s as resolveCliRoot, t as readCliVersion } from "./version-DESgLEkE.mjs";
4
5
  import { createRequire } from "node:module";
5
6
  import { Command } from "commander";
6
- import { Entry } from "@napi-rs/keyring";
7
7
  import Conf from "conf";
8
8
  import { homedir, platform, tmpdir } from "node:os";
9
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
9
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
10
+ import { Entry } from "@napi-rs/keyring";
10
11
  import { confirm, input, select } from "@inquirer/prompts";
11
- import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
12
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
12
13
  import { spawn, spawnSync } from "node:child_process";
13
- import { createHash } from "node:crypto";
14
- import { pathToFileURL } from "node:url";
15
14
  import { access, copyFile, cp, lstat, mkdir, readFile, readdir, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
15
+ import { pathToFileURL } from "node:url";
16
+ //#region src/resolve-platform-url.ts
17
+ const DEFAULT_WEB_URL = "https://app.keystroke.ai";
18
+ const DEFAULT_PLATFORM_URL = "https://api.keystroke.ai";
19
+ const LOCAL_PLATFORM_URL = "http://localhost:3002";
20
+ function webOriginFromUrl(webUrl) {
21
+ return originFromPublicUrl(webUrl, webUrl.replace(/\/+$/, ""));
22
+ }
23
+ /** Known web origins with a fixed platform API — undefined for custom/staging URLs. */
24
+ function knownPlatformUrlForWebUrl(webUrl) {
25
+ const webOrigin = webOriginFromUrl(webUrl);
26
+ if (webOrigin === "http://localhost:3000" || webOrigin === "http://127.0.0.1:3000") return LOCAL_PLATFORM_URL;
27
+ if (webOrigin === "https://app.keystroke.ai") return DEFAULT_PLATFORM_URL;
28
+ }
29
+ function resolvePlatformUrlForWebUrl(webUrl, options = {}) {
30
+ const explicit = options.platformUrl?.trim();
31
+ if (explicit) return explicit.replace(/\/+$/, "");
32
+ const known = knownPlatformUrlForWebUrl(webUrl);
33
+ if (known) return known;
34
+ return (options.fallback?.trim() || "https://api.keystroke.ai").replace(/\/+$/, "");
35
+ }
36
+ //#endregion
37
+ //#region src/config.ts
38
+ function getCliConfigDir(cwd = join(homedir(), ".keystroke")) {
39
+ return cwd;
40
+ }
41
+ function getConfigDir(config) {
42
+ return dirname(config.path);
43
+ }
44
+ function getEffectiveApiTarget(config) {
45
+ const explicit = config.get("apiTarget");
46
+ if (explicit === "local" || explicit === "platform") return explicit;
47
+ return "local";
48
+ }
49
+ function syncPlatformUrlWithWebUrl(config) {
50
+ const known = knownPlatformUrlForWebUrl(config.get("webUrl"));
51
+ if (!known) return;
52
+ if (config.get("platformUrl") !== known) config.set("platformUrl", known);
53
+ }
54
+ function createCliConfig(cwd = getCliConfigDir()) {
55
+ const config = new Conf({
56
+ projectName: "keystroke",
57
+ cwd,
58
+ schema: {
59
+ serverUrl: {
60
+ type: "string",
61
+ default: "http://localhost:3001"
62
+ },
63
+ webUrl: {
64
+ type: "string",
65
+ default: DEFAULT_WEB_URL
66
+ },
67
+ platformUrl: {
68
+ type: "string",
69
+ default: DEFAULT_PLATFORM_URL
70
+ },
71
+ activeOrganizationId: { type: "string" },
72
+ activeProjectId: { type: "string" },
73
+ apiTarget: {
74
+ type: "string",
75
+ enum: ["local", "platform"]
76
+ }
77
+ }
78
+ });
79
+ syncPlatformUrlWithWebUrl(config);
80
+ return config;
81
+ }
82
+ function getServerUrl(config) {
83
+ return config.get("serverUrl");
84
+ }
85
+ function getWebUrl(config) {
86
+ return config.get("webUrl");
87
+ }
88
+ function getPlatformUrl(config) {
89
+ return resolvePlatformUrlForWebUrl(getWebUrl(config), { fallback: config.get("platformUrl") });
90
+ }
91
+ //#endregion
16
92
  //#region ../../node_modules/.pnpm/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
17
93
  /**
18
94
  Base class for all Ky-specific errors. `HTTPError`, `NetworkError`, `TimeoutError`, and `ForceRetryError` extend this class.
@@ -1292,1539 +1368,6 @@ const createInstance = (defaults) => {
1292
1368
  };
1293
1369
  const ky = createInstance();
1294
1370
  //#endregion
1295
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/coerce.js
1296
- function number(params) {
1297
- return _coercedNumber(ZodNumber, params);
1298
- }
1299
- //#endregion
1300
- //#region ../../packages/shared/dist/index.mjs
1301
- const ACTIVE_ORG_HEADER = "x-keystroke-org-id";
1302
- /** Auth, session, and account-entry URL segments. */
1303
- const AUTH_ACCOUNT_SLUGS = [
1304
- "2fa",
1305
- "accept-invite",
1306
- "auth",
1307
- "authorize",
1308
- "callback",
1309
- "callbacks",
1310
- "confirm-email",
1311
- "confirmation",
1312
- "connect",
1313
- "device",
1314
- "email-verification",
1315
- "forgot-password",
1316
- "invite",
1317
- "invites",
1318
- "login",
1319
- "logout",
1320
- "magic-link",
1321
- "mfa",
1322
- "oauth",
1323
- "onboarding",
1324
- "password",
1325
- "recovery",
1326
- "register",
1327
- "reset-password",
1328
- "saml",
1329
- "session",
1330
- "sessions",
1331
- "sign-in",
1332
- "sign-up",
1333
- "signin",
1334
- "signout",
1335
- "signup",
1336
- "sso",
1337
- "token",
1338
- "tokens",
1339
- "unlink",
1340
- "verify",
1341
- "verify-email"
1342
- ];
1343
- /** Org, workspace, billing, and account-management URL segments. */
1344
- const ORG_ACCOUNT_SLUGS = [
1345
- "account",
1346
- "accounts",
1347
- "billing",
1348
- "console",
1349
- "invoice",
1350
- "invoices",
1351
- "member",
1352
- "members",
1353
- "me",
1354
- "org",
1355
- "organization",
1356
- "organizations",
1357
- "orgs",
1358
- "payment",
1359
- "payments",
1360
- "plan",
1361
- "plans",
1362
- "portal",
1363
- "preferences",
1364
- "profile",
1365
- "settings",
1366
- "subscription",
1367
- "subscriptions",
1368
- "team",
1369
- "teams",
1370
- "upgrade",
1371
- "usage",
1372
- "user",
1373
- "users",
1374
- "workspace",
1375
- "workspaces"
1376
- ];
1377
- /** Product surfaces, resource types, and in-app navigation segments. */
1378
- const PRODUCT_SLUGS = [
1379
- "action",
1380
- "actions",
1381
- "activity",
1382
- "agent",
1383
- "agents",
1384
- "analytics",
1385
- "app",
1386
- "apps",
1387
- "artifact",
1388
- "artifacts",
1389
- "assistant",
1390
- "assistants",
1391
- "audit",
1392
- "audit-log",
1393
- "automation",
1394
- "automations",
1395
- "branch",
1396
- "branches",
1397
- "canvas",
1398
- "chat",
1399
- "chats",
1400
- "connection",
1401
- "connections",
1402
- "create",
1403
- "credential",
1404
- "credentials",
1405
- "dashboard",
1406
- "deployment",
1407
- "deployments",
1408
- "examples",
1409
- "execute",
1410
- "execution",
1411
- "executions",
1412
- "explore",
1413
- "get-started",
1414
- "history",
1415
- "inbox",
1416
- "inspector",
1417
- "integration",
1418
- "integrations",
1419
- "library",
1420
- "logs",
1421
- "marketplace",
1422
- "mcp",
1423
- "mcps",
1424
- "new",
1425
- "notifications",
1426
- "observe",
1427
- "plugin",
1428
- "plugins",
1429
- "primitive",
1430
- "primitives",
1431
- "project",
1432
- "projects",
1433
- "recents",
1434
- "registry",
1435
- "reports",
1436
- "run",
1437
- "runs",
1438
- "runtime",
1439
- "runtimes",
1440
- "sandbox",
1441
- "sandboxes",
1442
- "search",
1443
- "skill",
1444
- "skills",
1445
- "templates",
1446
- "thread",
1447
- "threads",
1448
- "trigger",
1449
- "triggers",
1450
- "version",
1451
- "versions",
1452
- "workflow",
1453
- "workflows"
1454
- ];
1455
- /** Marketing, docs, company, and go-to-market URL segments. */
1456
- const MARKETING_SITE_SLUGS = [
1457
- "about",
1458
- "affiliates",
1459
- "ai",
1460
- "announcements",
1461
- "anthropic",
1462
- "blog",
1463
- "book-demo",
1464
- "brand",
1465
- "campaigns",
1466
- "career",
1467
- "careers",
1468
- "case-studies",
1469
- "casestudies",
1470
- "changelog",
1471
- "chatgpt",
1472
- "chrome-extension",
1473
- "claude",
1474
- "codex",
1475
- "community",
1476
- "company",
1477
- "compare",
1478
- "contact",
1479
- "contribute",
1480
- "creators",
1481
- "customers",
1482
- "demo",
1483
- "demos",
1484
- "discord",
1485
- "docs",
1486
- "documentation",
1487
- "download",
1488
- "downloads",
1489
- "dust",
1490
- "emerging-talent",
1491
- "engineering-blog",
1492
- "enterprise",
1493
- "events",
1494
- "experts",
1495
- "extension",
1496
- "faq",
1497
- "faqs",
1498
- "features",
1499
- "forum",
1500
- "glean",
1501
- "grok",
1502
- "guide",
1503
- "guides",
1504
- "gumloop",
1505
- "handbook",
1506
- "help",
1507
- "help-center",
1508
- "home",
1509
- "how-it-works",
1510
- "howitworks",
1511
- "inspo",
1512
- "intern",
1513
- "investors",
1514
- "jobs",
1515
- "legal",
1516
- "lindy",
1517
- "llm",
1518
- "llms",
1519
- "love",
1520
- "make",
1521
- "manifesto",
1522
- "media",
1523
- "merch",
1524
- "mission",
1525
- "mobile",
1526
- "models",
1527
- "n8n",
1528
- "news",
1529
- "newsroom",
1530
- "open",
1531
- "open-claw",
1532
- "open-source",
1533
- "openai",
1534
- "our-story",
1535
- "overview",
1536
- "partners",
1537
- "pi",
1538
- "pipedream",
1539
- "platform",
1540
- "press",
1541
- "press-kit",
1542
- "pricing",
1543
- "privacy",
1544
- "product",
1545
- "products",
1546
- "provider",
1547
- "providers",
1548
- "quick-start",
1549
- "quickstart",
1550
- "refer",
1551
- "relay",
1552
- "relay-app",
1553
- "reporting",
1554
- "request-demo",
1555
- "resources",
1556
- "roadmap",
1557
- "schedule-demo",
1558
- "security",
1559
- "solutions",
1560
- "stack-ai",
1561
- "stackai",
1562
- "startup",
1563
- "startups",
1564
- "status",
1565
- "stories",
1566
- "story",
1567
- "students",
1568
- "support",
1569
- "swag",
1570
- "switch",
1571
- "talent",
1572
- "terms",
1573
- "testimonials",
1574
- "thesis",
1575
- "tines",
1576
- "trust",
1577
- "tutorials",
1578
- "university",
1579
- "use-case",
1580
- "use-cases",
1581
- "usecases",
1582
- "versus",
1583
- "vellum",
1584
- "vs",
1585
- "webinars",
1586
- "workato",
1587
- "xai",
1588
- "yc",
1589
- "zapier"
1590
- ];
1591
- /** Integrations, competitors, and partner brand slugs (marketing / integration pages). */
1592
- const INTEGRATION_BRAND_SLUGS = [
1593
- "airtable",
1594
- "asana",
1595
- "aws",
1596
- "azure",
1597
- "bun",
1598
- "confluence",
1599
- "copilot",
1600
- "cursor",
1601
- "databricks",
1602
- "figma",
1603
- "firebase",
1604
- "fly",
1605
- "gcp",
1606
- "gemini",
1607
- "github",
1608
- "gitlab",
1609
- "gmail",
1610
- "heroku",
1611
- "hubspot",
1612
- "huggingface",
1613
- "jira",
1614
- "linear",
1615
- "mailchimp",
1616
- "meta",
1617
- "mistral",
1618
- "mixmax",
1619
- "monday",
1620
- "netlify",
1621
- "neon",
1622
- "notion",
1623
- "npm",
1624
- "outlook",
1625
- "outreach",
1626
- "perplexity",
1627
- "planetscale",
1628
- "pnpm",
1629
- "postmark",
1630
- "ramp",
1631
- "railway",
1632
- "render",
1633
- "resend",
1634
- "salesforce",
1635
- "segment",
1636
- "sendgrid",
1637
- "shopify",
1638
- "slack",
1639
- "snowflake",
1640
- "stripe",
1641
- "supabase",
1642
- "terraform",
1643
- "trello",
1644
- "turso",
1645
- "twilio",
1646
- "typeform",
1647
- "vercel",
1648
- "vscode",
1649
- "windsurf",
1650
- "yarn"
1651
- ];
1652
- /** Company, team, and department landing-page segments. */
1653
- const COMPANY_TEAM_SLUGS = [
1654
- "engineers",
1655
- "engineering",
1656
- "executives",
1657
- "hc",
1658
- "intern",
1659
- "it",
1660
- "leadership",
1661
- "marketing",
1662
- "ops",
1663
- "revops",
1664
- "sales",
1665
- "services",
1666
- "tech"
1667
- ];
1668
- /** Legal, trust, compliance, and policy URL segments. */
1669
- const LEGAL_TRUST_SLUGS = [
1670
- "accessibility",
1671
- "agreement",
1672
- "a11y",
1673
- "bug-bounty",
1674
- "compliance",
1675
- "cookie-policy",
1676
- "cookies",
1677
- "disclose",
1678
- "dpa",
1679
- "eula",
1680
- "gdpr",
1681
- "hipaa",
1682
- "iso",
1683
- "msa",
1684
- "pci",
1685
- "responsible-disclosure",
1686
- "sla",
1687
- "soc2",
1688
- "tos",
1689
- "trust-center",
1690
- "trustcenter",
1691
- "vulnerability"
1692
- ];
1693
- /** Developer, API, CLI, and technical URL segments. */
1694
- const DEVELOPER_TECH_SLUGS = [
1695
- "api",
1696
- "api-docs",
1697
- "cli",
1698
- "code",
1699
- "config",
1700
- "developer",
1701
- "developer-tools",
1702
- "developers",
1703
- "dev-tools",
1704
- "devtools",
1705
- "dev",
1706
- "dev-states",
1707
- "graphql",
1708
- "graphql-playground",
1709
- "mcp-server",
1710
- "mcp-servers",
1711
- "openapi",
1712
- "sdk",
1713
- "swagger"
1714
- ];
1715
- /** Infra, ops, static assets, and system URL segments. */
1716
- const INFRA_SYSTEM_SLUGS = [
1717
- "acme-challenge",
1718
- "admin",
1719
- "apple-app-site-association",
1720
- "assets",
1721
- "batch",
1722
- "cache",
1723
- "cdn",
1724
- "cron",
1725
- "debug",
1726
- "error",
1727
- "errors",
1728
- "favicon",
1729
- "feed",
1730
- "files",
1731
- "health",
1732
- "healthcheck",
1733
- "healthz",
1734
- "hooks",
1735
- "internal",
1736
- "item",
1737
- "manifest",
1738
- "metrics",
1739
- "null",
1740
- "ping",
1741
- "prod",
1742
- "public",
1743
- "redirect",
1744
- "robots",
1745
- "rpc",
1746
- "rss",
1747
- "sharer",
1748
- "sitemap",
1749
- "staging",
1750
- "static",
1751
- "storage",
1752
- "test",
1753
- "undefined",
1754
- "universal",
1755
- "webhooks",
1756
- "well-known",
1757
- "www"
1758
- ];
1759
- /** Reserved slugs that are valid org names in theory but blocked for routing safety. */
1760
- const ROUTING_SAFETY_SLUGS = [
1761
- "alpha",
1762
- "anonymous",
1763
- "archive",
1764
- "archived",
1765
- "beta",
1766
- "clone",
1767
- "copy",
1768
- "default",
1769
- "deleted",
1770
- "demo-org",
1771
- "draft",
1772
- "drafts",
1773
- "duplicate",
1774
- "early-access",
1775
- "embed",
1776
- "embedded",
1777
- "export",
1778
- "fork",
1779
- "free",
1780
- "guest",
1781
- "import",
1782
- "index",
1783
- "list",
1784
- "manage",
1785
- "moderator",
1786
- "newsletter",
1787
- "owner",
1788
- "preview",
1789
- "previews",
1790
- "private",
1791
- "pro",
1792
- "public-api",
1793
- "publish",
1794
- "published",
1795
- "queue",
1796
- "remove",
1797
- "root",
1798
- "sample",
1799
- "samples",
1800
- "selection",
1801
- "share",
1802
- "shared",
1803
- "sponsor",
1804
- "sponsors",
1805
- "sponsorship",
1806
- "subscribe",
1807
- "super",
1808
- "superuser",
1809
- "system",
1810
- "sys",
1811
- "test-org",
1812
- "trash",
1813
- "unpublish",
1814
- "unsubscribe",
1815
- "upload",
1816
- "uploads",
1817
- "waitlist",
1818
- "widget",
1819
- "widgets",
1820
- "worker",
1821
- "workers"
1822
- ];
1823
- /**
1824
- * URL segments reserved for global (non-org) routes — cannot be used as an org slug.
1825
- * Prefer adding new entries to the category arrays above; the Set is the enforcement surface.
1826
- */
1827
- const RESERVED_ORGANIZATION_SLUGS = new Set([
1828
- ...AUTH_ACCOUNT_SLUGS,
1829
- ...ORG_ACCOUNT_SLUGS,
1830
- ...PRODUCT_SLUGS,
1831
- ...MARKETING_SITE_SLUGS,
1832
- ...INTEGRATION_BRAND_SLUGS,
1833
- ...COMPANY_TEAM_SLUGS,
1834
- ...LEGAL_TRUST_SLUGS,
1835
- ...DEVELOPER_TECH_SLUGS,
1836
- ...INFRA_SYSTEM_SLUGS,
1837
- ...ROUTING_SAFETY_SLUGS
1838
- ]);
1839
- /**
1840
- * Base slug format: lowercase, 2-64 chars, alphanumeric + dashes.
1841
- *
1842
- * IMPORTANT: this is the schema for *reading* slugs (persisted rows, API
1843
- * responses). It intentionally does NOT enforce the reserved-name list — an org
1844
- * created before a name became reserved must still parse on read. Use
1845
- * `ClaimableOrganizationSlugSchema` to validate slugs a user is trying to claim.
1846
- */
1847
- const OrganizationSlugSchema = string().trim().toLowerCase().min(2, "Slug must be at least 2 characters").max(64, "Slug must be at most 64 characters").regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Use lowercase letters, numbers, and dashes only");
1848
- /**
1849
- * Slug validation for *claiming* a slug (organization create/rename). Adds the
1850
- * reserved-name check on top of the base format. Never use this to parse
1851
- * existing org data, or pre-existing orgs whose slug later became reserved would
1852
- * fail to load.
1853
- */
1854
- const ClaimableOrganizationSlugSchema = OrganizationSlugSchema.refine((slug) => !RESERVED_ORGANIZATION_SLUGS.has(slug), "This slug is reserved");
1855
- /** Same format as organization slugs — org-scoped, no global reserved list. */
1856
- const ProjectSlugSchema = OrganizationSlugSchema;
1857
- /** Browser→platform request budget (ping + small platform overhead). */
1858
- const PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS = 17e3;
1859
- /** Normalize a public origin URL (no trailing slash). */
1860
- function originFromPublicUrl(value, fallback) {
1861
- const trimmed = value?.trim();
1862
- if (!trimmed) return fallback.replace(/\/+$/, "");
1863
- return trimmed.replace(/\/+$/, "");
1864
- }
1865
- /** TCP port to bind for a local server, derived from a public URL. */
1866
- function listenPortFromUrl(url, fallback) {
1867
- const parsed = new URL(url);
1868
- if (parsed.port) {
1869
- const port = Number(parsed.port);
1870
- if (Number.isFinite(port) && port > 0) return port;
1871
- }
1872
- if (parsed.protocol === "https:") return 443;
1873
- if (parsed.protocol === "http:") return 80;
1874
- return fallback;
1875
- }
1876
- /** Shorthand: listen port from `PUBLIC_*_URL` or fallback. */
1877
- function listenPortFromPublicUrl(value, fallback) {
1878
- const trimmed = value?.trim();
1879
- if (!trimmed) return fallback;
1880
- try {
1881
- return listenPortFromUrl(trimmed, fallback);
1882
- } catch {
1883
- return fallback;
1884
- }
1885
- }
1886
- const serializedRouteManifestEntrySchema = discriminatedUnion("kind", [
1887
- object({
1888
- kind: literal("health"),
1889
- method: literal("GET"),
1890
- path: literal("/health")
1891
- }),
1892
- object({
1893
- kind: literal("agent"),
1894
- method: literal("POST"),
1895
- path: string(),
1896
- agentSlug: string(),
1897
- moduleFile: string(),
1898
- requestSchema: record(string(), unknown()),
1899
- responseSchema: record(string(), unknown())
1900
- }),
1901
- object({
1902
- kind: literal("agent-sessions-list"),
1903
- method: literal("GET"),
1904
- path: string(),
1905
- agentSlug: string(),
1906
- moduleFile: string()
1907
- }),
1908
- object({
1909
- kind: literal("agent-session-detail"),
1910
- method: literal("GET"),
1911
- path: string(),
1912
- agentSlug: string(),
1913
- moduleFile: string()
1914
- }),
1915
- object({
1916
- kind: literal("workflow"),
1917
- method: literal("POST"),
1918
- path: string(),
1919
- workflowSlug: string(),
1920
- workflowName: string().optional(),
1921
- moduleFile: string(),
1922
- requestSchema: record(string(), unknown()),
1923
- responseSchema: record(string(), unknown())
1924
- }),
1925
- object({
1926
- kind: literal("workflow-runs-list"),
1927
- method: literal("GET"),
1928
- path: string(),
1929
- workflowSlug: string(),
1930
- workflowName: string().optional(),
1931
- moduleFile: string()
1932
- }),
1933
- object({
1934
- kind: literal("workflow-run-detail"),
1935
- method: literal("GET"),
1936
- path: string(),
1937
- workflowSlug: string(),
1938
- workflowName: string().optional(),
1939
- moduleFile: string()
1940
- }),
1941
- object({
1942
- kind: literal("trigger-webhook"),
1943
- method: literal("POST"),
1944
- path: string(),
1945
- attachmentIds: array(string()),
1946
- moduleFile: string(),
1947
- requestSchema: record(string(), unknown()),
1948
- attachmentSchemas: record(string(), object({
1949
- requestSchema: record(string(), unknown()),
1950
- filterSchema: record(string(), unknown()).optional()
1951
- })),
1952
- responseSchema: record(string(), unknown())
1953
- }),
1954
- object({
1955
- kind: literal("trigger-poll"),
1956
- method: literal("POST"),
1957
- path: string(),
1958
- attachmentId: string(),
1959
- moduleFile: string(),
1960
- schedule: string(),
1961
- responseSchema: record(string(), unknown())
1962
- }),
1963
- object({
1964
- kind: literal("trigger-poll-group"),
1965
- method: literal("POST"),
1966
- path: string(),
1967
- pollId: string(),
1968
- attachmentIds: array(string()),
1969
- moduleFile: string(),
1970
- schedule: string(),
1971
- responseSchema: record(string(), unknown())
1972
- }),
1973
- object({
1974
- kind: literal("trigger-runs-list"),
1975
- method: literal("GET"),
1976
- path: string(),
1977
- attachmentId: string(),
1978
- moduleFile: string()
1979
- }),
1980
- object({
1981
- kind: literal("trigger-run-detail"),
1982
- method: literal("GET"),
1983
- path: string(),
1984
- attachmentId: string(),
1985
- moduleFile: string()
1986
- }),
1987
- object({
1988
- kind: literal("cron-schedule"),
1989
- attachmentId: string(),
1990
- moduleFile: string(),
1991
- schedule: string()
1992
- }),
1993
- object({
1994
- kind: literal("plugin"),
1995
- method: _enum([
1996
- "GET",
1997
- "POST",
1998
- "PUT",
1999
- "PATCH",
2000
- "DELETE"
2001
- ]),
2002
- path: string(),
2003
- plugin: string()
2004
- })
2005
- ]);
2006
- object({
2007
- version: literal(1),
2008
- entries: array(serializedRouteManifestEntrySchema),
2009
- integrations: array(string()).optional()
2010
- });
2011
- /** How a credential instance is stored (`credential_instances.auth_kind`). */
2012
- const CredentialAuthKindSchema = _enum(["api_key", "oauth_managed"]);
2013
- /** Where a credential instance is stored (`credential_instances.scope_type`). */
2014
- const CredentialScopeTypeSchema = _enum([
2015
- "global",
2016
- "organization",
2017
- "project",
2018
- "user"
2019
- ]);
2020
- /**
2021
- * Resolution chain step when an action/tool looks up credentials.
2022
- * `selection` uses explicit instance ids; other levels map to {@link CredentialScopeType}.
2023
- */
2024
- const CredentialScopeLevelSchema = _enum([
2025
- "selection",
2026
- "organization",
2027
- "project",
2028
- "user"
2029
- ]);
2030
- CredentialAuthKindSchema.options;
2031
- CredentialScopeTypeSchema.options;
2032
- CredentialScopeLevelSchema.options;
2033
- function isCredentialInput(value) {
2034
- if (typeof value !== "object" || value === null) return false;
2035
- const candidate = value;
2036
- return typeof candidate.key === "string" && CredentialAuthKindSchema.safeParse(candidate.kind).success && candidate.schema instanceof ZodType;
2037
- }
2038
- custom((value) => isCredentialInput(value), "must be a credential requirement");
2039
- const OrganizationSlugErrorCodeSchema = _enum([
2040
- "slug_taken",
2041
- "slug_reserved",
2042
- "slug_invalid"
2043
- ]);
2044
- const SlugAvailabilityReasonSchema = _enum([
2045
- "taken",
2046
- "reserved",
2047
- "invalid"
2048
- ]);
2049
- const SlugAvailabilityResponseSchema = object({
2050
- slug: string(),
2051
- available: boolean(),
2052
- reason: SlugAvailabilityReasonSchema.optional(),
2053
- suggestion: OrganizationSlugSchema.optional()
2054
- });
2055
- object({
2056
- slug: string().trim().min(1),
2057
- excludeOrganizationId: string().min(1).optional()
2058
- });
2059
- const ProjectSlugAvailabilityReasonSchema = _enum(["taken", "invalid"]);
2060
- const ProjectSlugAvailabilityResponseSchema = object({
2061
- slug: string(),
2062
- available: boolean(),
2063
- reason: ProjectSlugAvailabilityReasonSchema.optional(),
2064
- suggestion: ProjectSlugSchema.optional()
2065
- });
2066
- object({
2067
- slug: string().trim().min(1),
2068
- excludeProjectId: string().min(1).optional()
2069
- });
2070
- const ProjectStatusSchema = _enum([
2071
- "inactive",
2072
- "starting",
2073
- "active",
2074
- "failed"
2075
- ]);
2076
- const OrganizationUserRoleSchema = _enum([
2077
- "owner",
2078
- "admin",
2079
- "builder"
2080
- ]);
2081
- const isoDateTime$3 = string().datetime();
2082
- const OrganizationSchema = object({
2083
- id: string(),
2084
- name: string(),
2085
- slug: OrganizationSlugSchema,
2086
- createdAt: isoDateTime$3,
2087
- updatedAt: isoDateTime$3
2088
- });
2089
- const ProjectSchema = object({
2090
- id: string(),
2091
- organizationId: string(),
2092
- name: string(),
2093
- slug: ProjectSlugSchema,
2094
- description: string().nullable(),
2095
- status: ProjectStatusSchema,
2096
- baseUrl: string().nullable(),
2097
- runtimeId: string().nullable(),
2098
- lastError: string().nullable(),
2099
- createdAt: isoDateTime$3,
2100
- updatedAt: isoDateTime$3
2101
- });
2102
- const UserOrganizationSchema = object({
2103
- organization: OrganizationSchema,
2104
- role: OrganizationUserRoleSchema
2105
- });
2106
- const ActiveOrganizationResponseSchema = object({ organization: UserOrganizationSchema.nullable() });
2107
- const ListOrganizationsResponseSchema = object({ organizations: array(UserOrganizationSchema) });
2108
- const CreateOrganizationRequestSchema = object({
2109
- name: string().trim().min(1),
2110
- /** Format-only at the wire boundary; reserved-name checks run in platform-database. */
2111
- slug: OrganizationSlugSchema.optional()
2112
- });
2113
- const UpdateOrganizationRequestSchema = object({
2114
- name: string().trim().min(1).optional(),
2115
- slug: ClaimableOrganizationSlugSchema.optional()
2116
- }).refine((data) => data.name !== void 0 || data.slug !== void 0, { message: "At least one field is required" });
2117
- const CreateOrganizationResponseSchema = object({ organization: UserOrganizationSchema });
2118
- const ListProjectsResponseSchema = object({ projects: array(ProjectSchema) });
2119
- const ProjectListMetricsSchema = object({
2120
- agentCount: number$1(),
2121
- workflowCount: number$1(),
2122
- skillCount: number$1(),
2123
- credentialCount: number$1(),
2124
- lastDeploymentAt: isoDateTime$3.nullable()
2125
- });
2126
- const ListProjectMetricsResponseSchema = object({ metrics: record(string(), ProjectListMetricsSchema) });
2127
- const CreateProjectRequestSchema = object({
2128
- name: string().trim().min(1),
2129
- description: string().trim().min(1).optional()
2130
- });
2131
- const UpdateProjectRequestSchema = object({
2132
- name: string().trim().min(1).optional(),
2133
- description: string().trim().optional(),
2134
- slug: ProjectSlugSchema.optional()
2135
- }).refine((data) => data.name !== void 0 || data.description !== void 0 || data.slug !== void 0, { message: "At least one field is required" });
2136
- const CreateProjectResponseSchema = object({ project: ProjectSchema });
2137
- const ProjectResponseSchema = object({ project: ProjectSchema });
2138
- const ProjectReachabilityResponseSchema = object({ reachable: boolean() });
2139
- const ValidationErrorDetailSchema = object({
2140
- path: string(),
2141
- message: string()
2142
- });
2143
- /** Machine-readable codes returned in standard API error bodies. */
2144
- const ErrorResponseCodeSchema = OrganizationSlugErrorCodeSchema.or(_enum(["needs_org_selection"]));
2145
- /** Standard JSON error body returned by the HTTP API. */
2146
- const ErrorResponseSchema = object({
2147
- error: string(),
2148
- code: ErrorResponseCodeSchema.optional(),
2149
- message: string().optional(),
2150
- details: array(ValidationErrorDetailSchema).optional()
2151
- });
2152
- const MessageOnlyErrorBodySchema = object({ message: string() });
2153
- /** Parse a JSON error body from the API. */
2154
- function parseErrorResponse(body) {
2155
- const parsed = ErrorResponseSchema.safeParse(body);
2156
- if (parsed.success) return parsed.data;
2157
- const messageOnly = MessageOnlyErrorBodySchema.safeParse(body);
2158
- if (messageOnly.success) return {
2159
- error: messageOnly.data.message,
2160
- message: messageOnly.data.message
2161
- };
2162
- }
2163
- const CredentialRunContextSchema = object({
2164
- orgId: string().min(1).optional(),
2165
- projectId: string().min(1).optional(),
2166
- userId: string().min(1).optional(),
2167
- userIds: record(string(), string()).optional(),
2168
- selection: record(string(), string()).optional()
2169
- });
2170
- const ThinkingLevelSchema = _enum([
2171
- "off",
2172
- "minimal",
2173
- "low",
2174
- "medium",
2175
- "high",
2176
- "xhigh"
2177
- ]);
2178
- const PromptInputSchema = object({
2179
- message: string().min(1),
2180
- sessionId: string().min(1).optional(),
2181
- subscriptionId: string().min(1).optional(),
2182
- context: CredentialRunContextSchema.optional(),
2183
- thinkingLevel: ThinkingLevelSchema.optional()
2184
- });
2185
- const PromptResponseSchema = object({
2186
- sessionId: string(),
2187
- messages: array(record(string(), unknown())),
2188
- error: string().nullable()
2189
- });
2190
- const SkipResponseSchema = object({
2191
- ok: literal(true),
2192
- skipped: literal(true)
2193
- });
2194
- const HealthResponseSchema = object({ ok: literal(true) });
2195
- object({ service: string() });
2196
- const ConnectProvidersResponseSchema = object({ providers: array(object({
2197
- key: string(),
2198
- mode: _enum(["authorize-url", "browser-redirect"]),
2199
- path: string(),
2200
- requiresAuth: boolean()
2201
- })) });
2202
- const ConnectAuthorizeUrlResponseSchema = object({ url: string() });
2203
- const QueuedRunResponseSchema = object({ runId: string() });
2204
- const QueuedAgentPromptResponseSchema = object({ sessionId: string() });
2205
- object({
2206
- workflows: array(string().min(1)).optional(),
2207
- attachments: array(string().min(1)).optional()
2208
- });
2209
- const PollRunMultiResponseSchema = object({ results: array(object({
2210
- attachmentKey: string(),
2211
- workflowKey: string(),
2212
- runId: string().optional(),
2213
- body: unknown().optional(),
2214
- queued: boolean(),
2215
- skipped: boolean().optional()
2216
- })) });
2217
- const PollRunResponseSchema = union([
2218
- record(string(), unknown()),
2219
- PollRunMultiResponseSchema,
2220
- SkipResponseSchema,
2221
- object({ runId: string() })
2222
- ]);
2223
- const RunSourceKindSchema = _enum([
2224
- "api",
2225
- "trigger",
2226
- "gateway",
2227
- "workflow",
2228
- "agent"
2229
- ]);
2230
- object({
2231
- kind: RunSourceKindSchema,
2232
- id: string().nullable()
2233
- });
2234
- const WorkflowRunStatusSchema = _enum([
2235
- "pending",
2236
- "running",
2237
- "completed",
2238
- "failed"
2239
- ]);
2240
- const WorkflowRunTriggerSchema = _enum([
2241
- "api",
2242
- "cron",
2243
- "webhook",
2244
- "poll",
2245
- "retry"
2246
- ]);
2247
- _enum([
2248
- "run_started",
2249
- "step_completed",
2250
- "step_failed",
2251
- "step_retrying",
2252
- "sleep_scheduled",
2253
- "sleep_completed",
2254
- "hook_created",
2255
- "hook_resumed",
2256
- "run_completed",
2257
- "run_failed"
2258
- ]);
2259
- const WorkflowRunSummarySchema = object({
2260
- id: string(),
2261
- status: WorkflowRunStatusSchema,
2262
- trigger: WorkflowRunTriggerSchema,
2263
- triggeredAt: string(),
2264
- startedAt: string().nullable(),
2265
- finishedAt: string().nullable(),
2266
- sourceKind: RunSourceKindSchema,
2267
- sourceId: string().nullable(),
2268
- triggerRunId: string().nullable(),
2269
- attachmentId: string().nullable()
2270
- });
2271
- const WorkflowRunRecordSchema = object({
2272
- id: string(),
2273
- workflowSlug: string(),
2274
- status: WorkflowRunStatusSchema,
2275
- trigger: WorkflowRunTriggerSchema,
2276
- triggeredAt: string(),
2277
- startedAt: string().nullable(),
2278
- finishedAt: string().nullable(),
2279
- sourceKind: RunSourceKindSchema,
2280
- sourceId: string().nullable(),
2281
- triggerRunId: string().nullable(),
2282
- attachmentId: string().nullable(),
2283
- parentWorkflowRunId: string().nullable(),
2284
- parentSpanId: string().nullable(),
2285
- input: unknown().nullable(),
2286
- output: unknown().nullable(),
2287
- error: unknown().nullable()
2288
- });
2289
- object({
2290
- limit: number().int().min(1).max(100).optional().default(20),
2291
- cursor: string().min(1).optional(),
2292
- status: WorkflowRunStatusSchema.optional(),
2293
- trigger: WorkflowRunTriggerSchema.optional()
2294
- });
2295
- const WorkflowRunListResponseSchema = object({
2296
- items: array(WorkflowRunSummarySchema),
2297
- nextCursor: string().nullable()
2298
- });
2299
- _enum([
2300
- "trigger",
2301
- "steps",
2302
- "trace"
2303
- ]);
2304
- object({ include: string().optional() });
2305
- const TriggerRunDetailSchema = object({
2306
- id: string(),
2307
- attachmentId: string(),
2308
- attachmentSlug: string().nullable(),
2309
- triggerType: _enum([
2310
- "cron",
2311
- "webhook",
2312
- "poll"
2313
- ]),
2314
- sourcePath: string().nullable(),
2315
- payload: unknown().nullable(),
2316
- triggeredAt: string()
2317
- });
2318
- const WorkflowStepRunSchema = object({
2319
- id: string(),
2320
- actionKey: string(),
2321
- output: unknown(),
2322
- completedAt: string()
2323
- });
2324
- const TraceTriggerSummarySchema = object({
2325
- triggerType: string(),
2326
- triggerRunId: string(),
2327
- workflowSlug: string().optional(),
2328
- agentSlug: string().optional(),
2329
- attachmentId: string().nullable().optional(),
2330
- attachmentSlug: string().nullable().optional(),
2331
- route: string().optional(),
2332
- sourcePath: string().nullable().optional()
2333
- }).nullable();
2334
- const TraceGatewaySummarySchema = object({
2335
- gatewayAttachmentId: string(),
2336
- gatewayAttachmentKey: string(),
2337
- threadId: string().optional(),
2338
- channelId: string().optional(),
2339
- mode: string().optional()
2340
- }).nullable();
2341
- const TraceSpanSchema = object({
2342
- id: string(),
2343
- traceId: string(),
2344
- parentSpanId: string().nullable(),
2345
- kind: string(),
2346
- refId: string(),
2347
- name: string(),
2348
- status: string(),
2349
- startedAt: string(),
2350
- finishedAt: string().nullable(),
2351
- metadata: unknown().nullable(),
2352
- error: unknown().nullable()
2353
- });
2354
- const TraceLogSchema = object({
2355
- id: string(),
2356
- traceId: string(),
2357
- spanId: string(),
2358
- seq: number$1(),
2359
- level: string(),
2360
- message: string(),
2361
- data: unknown().nullable(),
2362
- source: string(),
2363
- createdAt: string()
2364
- });
2365
- const TraceResponseSchema = object({
2366
- traceId: string(),
2367
- trigger: TraceTriggerSummarySchema,
2368
- gateway: TraceGatewaySummarySchema,
2369
- spans: array(TraceSpanSchema),
2370
- logs: array(TraceLogSchema)
2371
- });
2372
- const WorkflowRunDetailResponseSchema = object({
2373
- run: WorkflowRunRecordSchema,
2374
- trigger: TriggerRunDetailSchema.nullable(),
2375
- steps: array(WorkflowStepRunSchema),
2376
- trace: TraceResponseSchema.nullable()
2377
- });
2378
- const AgentSessionStatusSchema = _enum([
2379
- "running",
2380
- "completed",
2381
- "failed"
2382
- ]);
2383
- const AgentSessionSummarySchema = object({
2384
- id: string(),
2385
- status: AgentSessionStatusSchema,
2386
- source: RunSourceKindSchema,
2387
- sourceId: string().nullable(),
2388
- createdAt: string(),
2389
- updatedAt: string(),
2390
- messageCount: number$1()
2391
- });
2392
- const AgentSessionRecordSchema = object({
2393
- id: string(),
2394
- agentSlug: string(),
2395
- status: AgentSessionStatusSchema,
2396
- source: RunSourceKindSchema,
2397
- sourceId: string().nullable(),
2398
- createdAt: string(),
2399
- updatedAt: string(),
2400
- parentSpanId: string().nullable(),
2401
- messageCount: number$1(),
2402
- error: unknown().nullable()
2403
- });
2404
- object({
2405
- limit: number().int().min(1).max(100).optional().default(20),
2406
- cursor: string().min(1).optional(),
2407
- status: AgentSessionStatusSchema.optional(),
2408
- source: RunSourceKindSchema.optional()
2409
- });
2410
- const AgentSessionListResponseSchema = object({
2411
- items: array(AgentSessionSummarySchema),
2412
- nextCursor: string().nullable()
2413
- });
2414
- _enum([
2415
- "gateway",
2416
- "messages",
2417
- "events",
2418
- "trace"
2419
- ]);
2420
- object({ include: string().optional() });
2421
- const GatewaySessionDetailSchema = object({
2422
- threadId: string(),
2423
- attachmentId: string(),
2424
- attachmentSlug: string().nullable()
2425
- });
2426
- const AgentEventSchema = object({
2427
- id: string(),
2428
- sessionId: string(),
2429
- seq: number$1(),
2430
- eventType: string(),
2431
- payload: unknown(),
2432
- createdAt: string()
2433
- });
2434
- const AgentSessionDetailResponseSchema = object({
2435
- session: AgentSessionRecordSchema,
2436
- gateway: GatewaySessionDetailSchema.nullable(),
2437
- messages: array(record(string(), unknown())),
2438
- events: array(AgentEventSchema),
2439
- trace: TraceResponseSchema.nullable()
2440
- });
2441
- const SlackGatewayModeSchema = _enum([
2442
- "mention",
2443
- "channel",
2444
- "dm"
2445
- ]);
2446
- const GatewayAttachmentSourceSchema = object({
2447
- kind: literal("slack"),
2448
- mode: SlackGatewayModeSchema,
2449
- credentialKey: string(),
2450
- channelIds: array(string()).optional(),
2451
- subscribeOnMention: boolean()
2452
- });
2453
- const GatewayAttachmentRecordSchema = object({
2454
- id: string(),
2455
- key: string(),
2456
- agentKey: string(),
2457
- channelId: string(),
2458
- teamId: string().nullable().optional(),
2459
- platform: string(),
2460
- source: GatewayAttachmentSourceSchema,
2461
- registeredAt: string(),
2462
- updatedAt: string()
2463
- });
2464
- object({ attachments: array(GatewayAttachmentRecordSchema) });
2465
- const UpsertGatewayAttachmentBodySchema = object({
2466
- agentKey: string().min(1),
2467
- teamId: string().min(1).optional(),
2468
- mode: SlackGatewayModeSchema.optional(),
2469
- subscribeOnMention: boolean().optional()
2470
- });
2471
- const AgentListResponseSchema = object({ agents: array(object({
2472
- key: string(),
2473
- name: string().optional(),
2474
- route: string()
2475
- })) });
2476
- object({ subscriptions: array(object({
2477
- id: string(),
2478
- workflowKey: string(),
2479
- userId: string(),
2480
- enabled: boolean(),
2481
- createdAt: string(),
2482
- updatedAt: string()
2483
- })) });
2484
- object({
2485
- userId: string().min(1).optional(),
2486
- enabled: boolean().optional()
2487
- });
2488
- const CredentialInstanceRecordSchema = object({
2489
- id: string(),
2490
- key: string(),
2491
- scopeType: CredentialScopeTypeSchema,
2492
- scopeId: string().nullable(),
2493
- label: string().nullable(),
2494
- isDefault: boolean(),
2495
- authKind: CredentialAuthKindSchema
2496
- });
2497
- const CredentialInstanceListResponseSchema = object({ instances: array(CredentialInstanceRecordSchema) });
2498
- const CreateCredentialInstanceBodySchema = object({
2499
- key: string().min(1),
2500
- scopeType: CredentialScopeTypeSchema,
2501
- scopeId: string().nullable().optional(),
2502
- label: string().nullable().optional(),
2503
- isDefault: boolean().optional(),
2504
- value: record(string(), unknown()).refine((value) => Object.keys(value).length > 0, { message: "value must be a non-empty object" })
2505
- });
2506
- const UpdateCredentialInstanceBodySchema = object({
2507
- label: string().nullable().optional(),
2508
- isDefault: boolean().optional(),
2509
- value: record(string(), unknown()).refine((value) => Object.keys(value).length > 0, { message: "value must be a non-empty object" }).optional()
2510
- });
2511
- const TriggerRunTypeSchema = _enum([
2512
- "cron",
2513
- "webhook",
2514
- "poll"
2515
- ]);
2516
- const TriggerRunWorkflowSummarySchema = object({
2517
- id: string(),
2518
- status: WorkflowRunStatusSchema,
2519
- workflowSlug: string()
2520
- });
2521
- const TriggerRunAgentSessionSummarySchema = object({
2522
- id: string(),
2523
- agentSlug: string()
2524
- });
2525
- const TriggerRunSummarySchema = object({
2526
- id: string(),
2527
- triggerType: TriggerRunTypeSchema,
2528
- triggeredAt: string(),
2529
- sourcePath: string().nullable(),
2530
- workflowRun: TriggerRunWorkflowSummarySchema.nullable(),
2531
- agentSession: TriggerRunAgentSessionSummarySchema.nullable()
2532
- });
2533
- const TriggerRunRecordSchema = object({
2534
- id: string(),
2535
- attachmentId: string(),
2536
- attachmentSlug: string(),
2537
- triggerType: TriggerRunTypeSchema,
2538
- sourcePath: string().nullable(),
2539
- payload: unknown().nullable(),
2540
- triggeredAt: string()
2541
- });
2542
- object({
2543
- limit: number().int().min(1).max(100).optional().default(20),
2544
- cursor: string().min(1).optional(),
2545
- triggerType: TriggerRunTypeSchema.optional()
2546
- });
2547
- const TriggerRunListResponseSchema = object({
2548
- items: array(TriggerRunSummarySchema),
2549
- nextCursor: string().nullable()
2550
- });
2551
- _enum([
2552
- "workflows",
2553
- "agents",
2554
- "trace"
2555
- ]);
2556
- object({ include: string().optional() });
2557
- const TriggerRunAgentSessionDetailSchema = object({
2558
- id: string(),
2559
- agentSlug: string()
2560
- });
2561
- const TriggerRunDetailResponseSchema = object({
2562
- run: TriggerRunRecordSchema,
2563
- workflowRuns: array(WorkflowRunSummarySchema),
2564
- agentSessions: array(TriggerRunAgentSessionDetailSchema),
2565
- trace: TraceResponseSchema.nullable()
2566
- });
2567
- const TriggerTypeSchema = _enum([
2568
- "webhook",
2569
- "poll",
2570
- "cron"
2571
- ]);
2572
- const TriggerTargetKindSchema = _enum(["workflow", "agent"]);
2573
- const TriggerListItemSchema = object({
2574
- key: string(),
2575
- type: TriggerTypeSchema,
2576
- route: string().optional(),
2577
- webhookUrl: string().url().optional(),
2578
- targetKind: TriggerTargetKindSchema,
2579
- workflowKey: string().optional(),
2580
- agentKey: string().optional()
2581
- });
2582
- const TriggerListResponseSchema = object({ triggers: array(TriggerListItemSchema) });
2583
- object({ endpoint: string().min(1).optional() });
2584
- const TriggerDetailResponseSchema = TriggerListItemSchema;
2585
- const OrganizationMemberRoleSchema = _enum([
2586
- "owner",
2587
- "admin",
2588
- "builder"
2589
- ]);
2590
- const OrganizationMemberStatusSchema = _enum([
2591
- "invited",
2592
- "active",
2593
- "rejected",
2594
- "suspended"
2595
- ]);
2596
- const InvitableOrganizationMemberRoleSchema = _enum(["admin", "builder"]);
2597
- const isoDateTime$2 = string().datetime();
2598
- const OrganizationMemberSchema = object({
2599
- id: string(),
2600
- name: string(),
2601
- email: string().email(),
2602
- role: OrganizationMemberRoleSchema,
2603
- status: OrganizationMemberStatusSchema,
2604
- avatarUrl: string().optional(),
2605
- joinedAt: isoDateTime$2.optional(),
2606
- lastActiveAt: isoDateTime$2.nullable().optional()
2607
- });
2608
- const ListOrganizationMembersResponseSchema = object({ members: array(OrganizationMemberSchema) });
2609
- const InviteOrganizationMembersRequestSchema = object({
2610
- emails: array(string().trim().email()).min(1),
2611
- role: InvitableOrganizationMemberRoleSchema
2612
- });
2613
- const InviteOrganizationMemberResultStatusSchema = _enum([
2614
- "sent",
2615
- "already_member",
2616
- "pending",
2617
- "invalid"
2618
- ]);
2619
- const InviteOrganizationMembersResponseSchema = object({ results: array(object({
2620
- email: string(),
2621
- status: InviteOrganizationMemberResultStatusSchema,
2622
- invitationId: string().optional()
2623
- })) });
2624
- const UpdateOrganizationMemberRequestSchema = object({ role: InvitableOrganizationMemberRoleSchema });
2625
- const UpdateOrganizationMemberResponseSchema = object({ member: OrganizationMemberSchema });
2626
- const ListOrganizationInvitationsResponseSchema = object({ invitations: array(object({
2627
- id: string(),
2628
- organizationName: string(),
2629
- organizationSlug: OrganizationSlugSchema,
2630
- invitedByName: string().optional(),
2631
- invitedByEmail: string().email().optional(),
2632
- role: OrganizationMemberRoleSchema
2633
- })) });
2634
- const AcceptOrganizationInvitationResponseSchema = object({ organization: UserOrganizationSchema });
2635
- const DeclineOrganizationInvitationResponseSchema = object({ success: literal(true) });
2636
- /** Custom avatar override; null means fall back to OAuth `users.image`. */
2637
- const UserAvatarSchema = object({ url: url().nullable() });
2638
- const UserAvatarPatchSchema = object({
2639
- /** Storage key returned from presign; null removes the custom override. */
2640
- storageKey: string().min(1).nullable() });
2641
- const PresignUserAvatarRequestSchema = object({ contentType: string().trim().min(1) });
2642
- const PresignUserAvatarResponseSchema = object({
2643
- uploadUrl: url(),
2644
- storageKey: string().min(1)
2645
- });
2646
- const OrganizationLogoVariantSchema = _enum(["light", "dark"]);
2647
- const OrganizationSidebarBrandingSchema = object({
2648
- customLogoEnabled: boolean(),
2649
- customLogoExplicitlyDisabled: boolean(),
2650
- logoLightUrl: url().nullable(),
2651
- logoDarkUrl: url().nullable(),
2652
- logoHeightPx: number$1().int().min(14).max(32)
2653
- });
2654
- const OrganizationSidebarBrandingPatchSchema = object({
2655
- customLogoEnabled: boolean().optional(),
2656
- customLogoExplicitlyDisabled: boolean().optional(),
2657
- logoLightStorageKey: string().min(1).nullable().optional(),
2658
- logoDarkStorageKey: string().min(1).nullable().optional(),
2659
- logoHeightPx: number$1().int().min(14).max(32).optional()
2660
- }).refine((value) => value.customLogoEnabled !== void 0 || value.customLogoExplicitlyDisabled !== void 0 || value.logoLightStorageKey !== void 0 || value.logoDarkStorageKey !== void 0 || value.logoHeightPx !== void 0, { message: "At least one branding field is required" });
2661
- const PresignOrgLogoRequestSchema = object({
2662
- variant: OrganizationLogoVariantSchema,
2663
- contentType: string().trim().min(1)
2664
- });
2665
- const PresignOrgLogoResponseSchema = object({
2666
- uploadUrl: url(),
2667
- storageKey: string().min(1)
2668
- });
2669
- const ProjectArtifactStatusSchema = _enum(["pending", "ready"]);
2670
- const isoDateTime$1 = string().datetime();
2671
- const ProjectArtifactSchema = object({
2672
- id: string(),
2673
- projectId: string(),
2674
- storageKey: string(),
2675
- status: ProjectArtifactStatusSchema,
2676
- createdAt: isoDateTime$1,
2677
- updatedAt: isoDateTime$1
2678
- });
2679
- const CreateProjectArtifactResponseSchema = object({
2680
- artifact: ProjectArtifactSchema,
2681
- uploadUrl: string().url(),
2682
- expiresInSeconds: number$1().int().positive()
2683
- });
2684
- const CompleteProjectArtifactResponseSchema = object({
2685
- artifact: ProjectArtifactSchema,
2686
- project: ProjectSchema
2687
- });
2688
- const ListProjectDeploymentsResponseSchema = object({ deployments: array(object({
2689
- id: string(),
2690
- projectId: string(),
2691
- version: number$1().int().positive(),
2692
- deployedBy: string().nullable(),
2693
- deployedByEmail: string().optional(),
2694
- deployedByAvatarUrl: string().optional(),
2695
- createdAt: isoDateTime$1,
2696
- active: boolean()
2697
- })) });
2698
- const optionalCount = number$1().int().nonnegative().nullable().optional();
2699
- const optionalTimestamp = string().nullable().optional();
2700
- const AgentSummarySchema = object({
2701
- id: string().min(1),
2702
- slug: string().min(1),
2703
- name: string().min(1),
2704
- projectId: string().min(1),
2705
- updatedAt: string().min(1),
2706
- description: string().optional(),
2707
- sourcePath: string().min(1).optional(),
2708
- model: string().optional(),
2709
- toolCount: optionalCount,
2710
- credentialCount: optionalCount,
2711
- lastRunAt: optionalTimestamp
2712
- });
2713
- const WorkflowSummarySchema = object({
2714
- id: string().min(1),
2715
- slug: string().min(1),
2716
- name: string().min(1),
2717
- projectId: string().min(1),
2718
- updatedAt: string().min(1),
2719
- description: string().optional(),
2720
- sourcePath: string().min(1).optional(),
2721
- lastRunAt: optionalTimestamp
2722
- });
2723
- const SkillSummarySchema = object({
2724
- id: string().min(1),
2725
- slug: string().min(1),
2726
- name: string().min(1),
2727
- projectId: string().min(1),
2728
- updatedAt: string().min(1),
2729
- description: string().optional(),
2730
- sourcePath: string().min(1).optional()
2731
- });
2732
- const AgentSummaryListResponseSchema = array(AgentSummarySchema);
2733
- const AgentSummaryDetailResponseSchema = AgentSummarySchema.nullable();
2734
- const WorkflowSummaryListResponseSchema = array(WorkflowSummarySchema);
2735
- const WorkflowSummaryDetailResponseSchema = WorkflowSummarySchema.nullable();
2736
- const SkillSummaryListResponseSchema = array(SkillSummarySchema);
2737
- const SkillSummaryDetailResponseSchema = SkillSummarySchema.nullable();
2738
- const RecentResourceKindSchema = _enum([
2739
- "agent",
2740
- "workflow",
2741
- "skill"
2742
- ]);
2743
- const RecentResourceSourceSchema = _enum(["owned", "shared"]);
2744
- const RecentResourceListResponseSchema = array(object({
2745
- id: string().min(1),
2746
- resourceKind: RecentResourceKindSchema,
2747
- resourceId: string().min(1),
2748
- name: string().min(1),
2749
- description: string().optional(),
2750
- projectId: string().min(1),
2751
- projectName: string().min(1),
2752
- sourcePath: string().min(1).optional(),
2753
- source: RecentResourceSourceSchema,
2754
- lastOpenedAt: string().min(1),
2755
- lastModifiedAt: string().min(1)
2756
- }));
2757
- const isoDateTime = string().datetime();
2758
- const sha256Hex = string().regex(/^[a-f0-9]{64}$/, "Expected a lowercase hex sha256 digest");
2759
- /**
2760
- * A single entry in a deploy's file tree, as served to the dashboard. Carries
2761
- * no contents: `id` is a stable, path-derived handle used for selection and
2762
- * `?file=` deep links; `hash` is the content address used to fetch the bytes
2763
- * lazily and to cache them immutably in the browser.
2764
- */
2765
- const ProjectFileSummarySchema = object({
2766
- id: string(),
2767
- path: string().min(1),
2768
- hash: sha256Hex
2769
- });
2770
- /** Maps a runtime resource slug (agent/workflow/skill) to its source file path. */
2771
- const ProjectSourceResourceRefSchema = object({
2772
- slug: string().min(1),
2773
- path: string().min(1)
2774
- });
2775
- const ProjectSourceResourcesSchema = object({
2776
- agents: array(ProjectSourceResourceRefSchema).default([]),
2777
- workflows: array(ProjectSourceResourceRefSchema).default([]),
2778
- skills: array(ProjectSourceResourceRefSchema).default([])
2779
- });
2780
- const emptyResources = () => ({
2781
- agents: [],
2782
- workflows: [],
2783
- skills: []
2784
- });
2785
- /** Response for the file-tree listing of a project's active deploy. */
2786
- const ListProjectFilesResponseSchema = object({
2787
- artifactId: string().nullable(),
2788
- files: array(ProjectFileSummarySchema),
2789
- resources: ProjectSourceResourcesSchema.default(emptyResources())
2790
- });
2791
- object({
2792
- path: string().min(1),
2793
- contents: string(),
2794
- hash: sha256Hex
2795
- });
2796
- /** Request: ask the platform which blobs are missing and get presigned PUTs. */
2797
- const PresignProjectSourceRequestSchema = object({ blobs: array(object({
2798
- hash: sha256Hex,
2799
- size: number$1().int().nonnegative()
2800
- })) });
2801
- /** Response: presigned PUTs for the subset of blobs not already stored. */
2802
- const PresignProjectSourceResponseSchema = object({ uploads: array(object({
2803
- hash: sha256Hex,
2804
- url: string().url()
2805
- })) });
2806
- /** Request body the CLI sends to finalize a deploy's source manifest. */
2807
- const UploadProjectSourceManifestRequestSchema = object({
2808
- files: array(object({
2809
- path: string().min(1),
2810
- hash: sha256Hex
2811
- })),
2812
- resources: ProjectSourceResourcesSchema.default(emptyResources())
2813
- });
2814
- const UploadProjectSourceResponseSchema = object({
2815
- ok: literal(true),
2816
- fileCount: number$1().int().nonnegative()
2817
- });
2818
- object({
2819
- files: array(object({
2820
- id: string(),
2821
- path: string().min(1),
2822
- hash: sha256Hex
2823
- })),
2824
- resources: ProjectSourceResourcesSchema.default(emptyResources()),
2825
- generatedAt: isoDateTime
2826
- });
2827
- //#endregion
2828
1371
  //#region ../../packages/sdk/dist/index.mjs
2829
1372
  function normalizeBaseUrl$1(baseUrl) {
2830
1373
  return baseUrl.replace(/\/+$/, "");
@@ -4837,105 +3380,29 @@ async function getCliJwt(platformUrl, force = false) {
4837
3380
  return cache.get(force);
4838
3381
  }
4839
3382
  //#endregion
4840
- //#region src/resolve-platform-url.ts
4841
- const DEFAULT_WEB_URL = "https://app.keystroke.ai";
4842
- const DEFAULT_PLATFORM_URL = "https://api.keystroke.ai";
4843
- const LOCAL_PLATFORM_URL = "http://localhost:3002";
4844
- function webOriginFromUrl(webUrl) {
4845
- return originFromPublicUrl(webUrl, webUrl.replace(/\/+$/, ""));
4846
- }
4847
- /** Known web origins with a fixed platform API — undefined for custom/staging URLs. */
4848
- function knownPlatformUrlForWebUrl(webUrl) {
4849
- const webOrigin = webOriginFromUrl(webUrl);
4850
- if (webOrigin === "http://localhost:3000" || webOrigin === "http://127.0.0.1:3000") return LOCAL_PLATFORM_URL;
4851
- if (webOrigin === "https://app.keystroke.ai") return DEFAULT_PLATFORM_URL;
4852
- }
4853
- function resolvePlatformUrlForWebUrl(webUrl, options = {}) {
4854
- const explicit = options.platformUrl?.trim();
4855
- if (explicit) return explicit.replace(/\/+$/, "");
4856
- const known = knownPlatformUrlForWebUrl(webUrl);
4857
- if (known) return known;
4858
- return (options.fallback?.trim() || "https://api.keystroke.ai").replace(/\/+$/, "");
3383
+ //#region src/auth/resolve-cli-auth.ts
3384
+ /** Returns JWT bearer auth when a session refresh token is stored; otherwise none. */
3385
+ function resolveCliAuth(config) {
3386
+ const platformUrl = getPlatformUrl(config);
3387
+ if (!getAccessToken(platformUrl)) return { type: "none" };
3388
+ return {
3389
+ type: "bearer",
3390
+ getToken: () => getCliJwt(platformUrl)
3391
+ };
4859
3392
  }
4860
3393
  //#endregion
4861
- //#region src/config.ts
4862
- function getCliConfigDir(cwd = join(homedir(), ".keystroke")) {
4863
- return cwd;
3394
+ //#region src/client.ts
3395
+ function createCliClient(config, options) {
3396
+ return createKeystrokeClient({
3397
+ baseUrl: options.baseUrl,
3398
+ auth: resolveCliAuth(config),
3399
+ getActiveOrganizationId: options.platform ? () => config.get("activeOrganizationId") ?? null : void 0
3400
+ });
4864
3401
  }
4865
- function getConfigDir(config) {
4866
- return dirname(config.path);
4867
- }
4868
- function getEffectiveApiTarget(config) {
4869
- const explicit = config.get("apiTarget");
4870
- if (explicit === "local" || explicit === "platform") return explicit;
4871
- return "local";
4872
- }
4873
- function syncPlatformUrlWithWebUrl(config) {
4874
- const known = knownPlatformUrlForWebUrl(config.get("webUrl"));
4875
- if (!known) return;
4876
- if (config.get("platformUrl") !== known) config.set("platformUrl", known);
4877
- }
4878
- function createCliConfig(cwd = getCliConfigDir()) {
4879
- const config = new Conf({
4880
- projectName: "keystroke",
4881
- cwd,
4882
- schema: {
4883
- serverUrl: {
4884
- type: "string",
4885
- default: "http://localhost:3001"
4886
- },
4887
- webUrl: {
4888
- type: "string",
4889
- default: DEFAULT_WEB_URL
4890
- },
4891
- platformUrl: {
4892
- type: "string",
4893
- default: DEFAULT_PLATFORM_URL
4894
- },
4895
- activeOrganizationId: { type: "string" },
4896
- activeProjectId: { type: "string" },
4897
- apiTarget: {
4898
- type: "string",
4899
- enum: ["local", "platform"]
4900
- }
4901
- }
4902
- });
4903
- syncPlatformUrlWithWebUrl(config);
4904
- return config;
4905
- }
4906
- function getServerUrl(config) {
4907
- return config.get("serverUrl");
4908
- }
4909
- function getWebUrl(config) {
4910
- return config.get("webUrl");
4911
- }
4912
- function getPlatformUrl(config) {
4913
- return resolvePlatformUrlForWebUrl(getWebUrl(config), { fallback: config.get("platformUrl") });
4914
- }
4915
- //#endregion
4916
- //#region src/auth/resolve-cli-auth.ts
4917
- /** Returns JWT bearer auth when a session refresh token is stored; otherwise none. */
4918
- function resolveCliAuth(config) {
4919
- const platformUrl = getPlatformUrl(config);
4920
- if (!getAccessToken(platformUrl)) return { type: "none" };
4921
- return {
4922
- type: "bearer",
4923
- getToken: () => getCliJwt(platformUrl)
4924
- };
4925
- }
4926
- //#endregion
4927
- //#region src/client.ts
4928
- function createCliClient(config, options) {
4929
- return createKeystrokeClient({
4930
- baseUrl: options.baseUrl,
4931
- auth: resolveCliAuth(config),
4932
- getActiveOrganizationId: options.platform ? () => config.get("activeOrganizationId") ?? null : void 0
4933
- });
4934
- }
4935
- //#endregion
4936
- //#region ../../packages/sdk/dist/platform/index.mjs
4937
- function normalizeBaseUrl(baseUrl) {
4938
- return baseUrl.replace(/\/+$/, "");
3402
+ //#endregion
3403
+ //#region ../../packages/sdk/dist/platform/index.mjs
3404
+ function normalizeBaseUrl(baseUrl) {
3405
+ return baseUrl.replace(/\/+$/, "");
4939
3406
  }
4940
3407
  function applyAuthHeaders(request, auth, getToken) {
4941
3408
  if (!auth || auth.type === "none") return;
@@ -6798,50 +5265,6 @@ const credentialSeed = [
6798
5265
  ownerName: "Nate Wells"
6799
5266
  }
6800
5267
  ];
6801
- const agentSeed = [{
6802
- id: "agent-support",
6803
- slug: "support-agent",
6804
- name: "Support Agent",
6805
- projectId: "project_personal_repo",
6806
- updatedAt: "2026-06-02T14:20:00Z",
6807
- description: "Triage support requests and draft helpful replies.",
6808
- sourcePath: "src/agents/support-agent.ts",
6809
- model: "claude-4-sonnet",
6810
- toolCount: 4,
6811
- credentialCount: 2,
6812
- lastRunAt: "2026-06-02T14:20:00Z"
6813
- }, {
6814
- id: "agent-research",
6815
- slug: "research-agent",
6816
- name: "Research Agent",
6817
- projectId: "project_personal_repo",
6818
- updatedAt: "2026-06-01T09:15:00Z",
6819
- description: "Summarize docs and pull answers from connected sources.",
6820
- sourcePath: "src/agents/research-agent.ts",
6821
- model: "claude-4-sonnet",
6822
- toolCount: 6,
6823
- credentialCount: 3,
6824
- lastRunAt: "2026-06-01T09:15:00Z"
6825
- }];
6826
- const workflowSeed = [{
6827
- id: "workflow-daily-digest",
6828
- slug: "daily-digest",
6829
- name: "Daily Digest",
6830
- projectId: "project_personal_repo",
6831
- updatedAt: "2026-06-02T11:05:00Z",
6832
- description: "Collect project updates and send a daily summary.",
6833
- sourcePath: "src/workflows/daily-digest.ts",
6834
- lastRunAt: "2026-06-02T11:05:00Z"
6835
- }, {
6836
- id: "workflow-email-triage",
6837
- slug: "email-triage",
6838
- name: "Email Triage",
6839
- projectId: "project_personal_repo",
6840
- updatedAt: "2026-05-31T16:40:00Z",
6841
- description: "Label, prioritize, and draft replies for inbound email.",
6842
- sourcePath: "src/workflows/email-triage.ts",
6843
- lastRunAt: "2026-05-31T16:40:00Z"
6844
- }];
6845
5268
  /** Review personas for mocked project members and API key authors (not org membership). */
6846
5269
  const mockPersonaSeed = [
6847
5270
  {
@@ -7120,616 +5543,45 @@ function createApiKeysResource() {
7120
5543
  })
7121
5544
  };
7122
5545
  }
7123
- const historyProjectNameById = { project_personal_repo: "Blake's Project" };
7124
- const MOCK_ACTOR = {
7125
- userId: "user_blake",
7126
- name: "Blake Rouse",
7127
- avatarUrl: null
7128
- };
7129
- function buildCompletedUsage(durationMs) {
5546
+ function createHistoryResource(http) {
7130
5547
  return {
7131
- runDurationMs: durationMs,
7132
- lineItems: [
7133
- {
7134
- id: "claude-opus",
7135
- label: "Claude Opus 4.8",
7136
- amountUsd: .413
7137
- },
7138
- {
7139
- id: "gemini-flash",
7140
- label: "Gemini Flash 3.5",
7141
- amountUsd: .001
7142
- },
7143
- {
7144
- id: "daytona",
7145
- label: "Daytona Sandbox",
7146
- amountUsd: .188
5548
+ /** Runs across projects the current user can access in the active org. */
5549
+ async list(filters) {
5550
+ try {
5551
+ const parsedFilters = filters ? HistoryRunListQuerySchema.parse(filters) : void 0;
5552
+ const searchParams = new URLSearchParams();
5553
+ if (parsedFilters?.project) searchParams.set("project", parsedFilters.project);
5554
+ if (parsedFilters?.status) searchParams.set("status", parsedFilters.status);
5555
+ if (parsedFilters?.kind) searchParams.set("kind", parsedFilters.kind);
5556
+ const query = searchParams.toString();
5557
+ const data = await http.get(query ? `api/history?${query}` : "api/history").json();
5558
+ return HistoryRunListResponseSchema.parse(data);
5559
+ } catch (error) {
5560
+ throw await toPlatformError(error);
7147
5561
  }
7148
- ],
7149
- totalExcludingDurationUsd: .603
7150
- };
7151
- }
7152
- function buildRunningUsage() {
7153
- return {
7154
- runDurationMs: null,
7155
- lineItems: [],
7156
- totalExcludingDurationUsd: null
7157
- };
7158
- }
7159
- function buildFailedUsage(durationMs) {
7160
- if (durationMs == null) return {
7161
- runDurationMs: null,
7162
- lineItems: [],
7163
- totalExcludingDurationUsd: null
7164
- };
7165
- return {
7166
- runDurationMs: durationMs,
7167
- lineItems: [{
7168
- id: "claude-opus",
7169
- label: "Claude Opus 4.8",
7170
- amountUsd: .021
7171
- }],
7172
- totalExcludingDurationUsd: .021
7173
- };
7174
- }
7175
- function workflowSlugFromId(workflowId) {
7176
- return workflowSeed.find((workflow) => workflow.id === workflowId)?.slug ?? workflowId;
7177
- }
7178
- function agentSlugFromId(agentId) {
7179
- return agentSeed.find((agent) => agent.id === agentId)?.slug ?? agentId;
7180
- }
7181
- const historyRunSeed = [
7182
- {
7183
- id: "run-support-agent-001",
7184
- kind: "agent",
7185
- traceId: "run-support-agent-001",
7186
- projectId: "project_personal_repo",
7187
- projectName: historyProjectNameById.project_personal_repo ?? "Project",
7188
- resourceKey: agentSlugFromId("agent-support"),
7189
- resourceId: "agent-support",
7190
- resourceName: "Support Agent",
7191
- status: "completed",
7192
- triggeredAt: "2026-04-20T15:44:00Z",
7193
- timeInQueueMs: 85,
7194
- startedAt: "2026-04-20T15:44:00Z",
7195
- finishedAt: "2026-04-20T15:44:42Z",
7196
- durationMs: 42e3,
7197
- triggerLabel: "Gateway",
7198
- triggerRaw: "gateway",
7199
- ranAs: MOCK_ACTOR,
7200
- modelsUsed: ["Claude Opus 4.8", "Gemini Flash 3.5"],
7201
- otherServicesUsed: ["Slack", "Daytona Sandbox"],
7202
- totalCostUsd: .603,
7203
- messageCount: 8
7204
- },
7205
- {
7206
- id: "run-daily-digest-001",
7207
- kind: "workflow",
7208
- traceId: "run-daily-digest-001",
7209
- projectId: "project_personal_repo",
7210
- projectName: historyProjectNameById.project_personal_repo ?? "Project",
7211
- resourceKey: workflowSlugFromId("workflow-daily-digest"),
7212
- resourceId: "workflow-daily-digest",
7213
- resourceName: "Daily Digest",
7214
- status: "running",
7215
- triggeredAt: "2026-04-20T15:12:00Z",
7216
- timeInQueueMs: null,
7217
- startedAt: "2026-04-20T15:12:00Z",
7218
- finishedAt: null,
7219
- durationMs: null,
7220
- triggerLabel: "Cron",
7221
- triggerRaw: "cron",
7222
- ranAs: MOCK_ACTOR,
7223
- modelsUsed: [],
7224
- otherServicesUsed: [],
7225
- totalCostUsd: null,
7226
- stepCount: 1
7227
- },
7228
- {
7229
- id: "run-support-agent-000",
7230
- kind: "agent",
7231
- traceId: "run-support-agent-000",
7232
- projectId: "project_personal_repo",
7233
- projectName: historyProjectNameById.project_personal_repo ?? "Project",
7234
- resourceKey: agentSlugFromId("agent-support"),
7235
- resourceId: "agent-support",
7236
- resourceName: "Support Agent",
7237
- status: "failed",
7238
- triggeredAt: "2026-04-19T18:22:00Z",
7239
- timeInQueueMs: 45,
7240
- startedAt: "2026-04-19T18:22:00Z",
7241
- finishedAt: "2026-04-19T18:22:12Z",
7242
- durationMs: 12e3,
7243
- triggerLabel: "Gateway",
7244
- triggerRaw: "gateway",
7245
- ranAs: MOCK_ACTOR,
7246
- modelsUsed: ["Claude Opus 4.8"],
7247
- otherServicesUsed: ["Slack"],
7248
- totalCostUsd: .021,
7249
- messageCount: 2
7250
- },
7251
- {
7252
- id: "run-email-triage-002",
7253
- kind: "workflow",
7254
- traceId: "run-email-triage-002",
7255
- projectId: "project_personal_repo",
7256
- projectName: historyProjectNameById.project_personal_repo ?? "Project",
7257
- resourceKey: workflowSlugFromId("workflow-email-triage"),
7258
- resourceId: "workflow-email-triage",
7259
- resourceName: "Email Triage",
7260
- status: "failed",
7261
- triggeredAt: "2026-05-31T16:40:05Z",
7262
- timeInQueueMs: 120,
7263
- startedAt: "2026-05-31T16:40:05Z",
7264
- finishedAt: "2026-05-31T16:40:18Z",
7265
- durationMs: 13e3,
7266
- triggerLabel: "Webhook",
7267
- triggerRaw: "webhook",
7268
- ranAs: MOCK_ACTOR,
7269
- modelsUsed: ["Claude Opus 4.8"],
7270
- otherServicesUsed: ["Gmail"],
7271
- totalCostUsd: .021,
7272
- stepCount: 2
7273
- },
7274
- {
7275
- id: "run-research-agent-003",
7276
- kind: "agent",
7277
- traceId: "run-research-agent-003",
7278
- projectId: "project_personal_repo",
7279
- projectName: historyProjectNameById.project_personal_repo ?? "Project",
7280
- resourceKey: agentSlugFromId("agent-research"),
7281
- resourceId: "agent-research",
7282
- resourceName: "Research Agent",
7283
- status: "completed",
7284
- triggeredAt: "2026-06-01T09:15:00Z",
7285
- timeInQueueMs: 210,
7286
- startedAt: "2026-06-01T09:15:00Z",
7287
- finishedAt: "2026-06-01T09:16:24Z",
7288
- durationMs: 84e3,
7289
- triggerLabel: "API",
7290
- triggerRaw: "api",
7291
- ranAs: MOCK_ACTOR,
7292
- modelsUsed: ["Claude Opus 4.8"],
7293
- otherServicesUsed: ["Exa"],
7294
- totalCostUsd: .603,
7295
- messageCount: 12
7296
- }
7297
- ];
7298
- const historyRunById = Object.fromEntries(historyRunSeed.map((run) => [run.id, run]));
7299
- /** Resolve a seed run by id so fixtures stay consistent if the seed is reordered. */
7300
- function runById(id) {
7301
- const run = historyRunById[id];
7302
- if (!run) throw new Error(`Unknown history run: ${id}`);
7303
- return run;
7304
- }
7305
- let historyRuns = historyRunSeed.map((run) => ({ ...run }));
7306
- const historyRunStatusOverrides = /* @__PURE__ */ new Map();
7307
- function listHistoryRuns() {
7308
- return historyRuns;
7309
- }
7310
- /**
7311
- * Cancel a running/queued run. Terminal runs are returned unchanged. Updates the
7312
- * list row and records an override so {@link getHistoryRunDetail} stays in sync.
7313
- */
7314
- function cancelHistoryRun(runId) {
7315
- const run = historyRuns.find((entry) => entry.id === runId);
7316
- if (!run) return null;
7317
- if (run.status !== "running" && run.status !== "pending") return run;
7318
- const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
7319
- const durationMs = run.startedAt ? Math.max(0, new Date(finishedAt).getTime() - new Date(run.startedAt).getTime()) : run.durationMs;
7320
- const canceled = {
7321
- ...run,
7322
- status: "canceled",
7323
- finishedAt,
7324
- durationMs
7325
- };
7326
- historyRuns = historyRuns.map((entry) => entry.id === runId ? canceled : entry);
7327
- historyRunStatusOverrides.set(runId, {
7328
- status: "canceled",
7329
- finishedAt
7330
- });
7331
- return canceled;
7332
- }
7333
- function buildSupportAgentTrace(runId, failed) {
7334
- const run = runById(runId);
7335
- const startedAt = run.startedAt;
7336
- const finishedAt = run.finishedAt ?? run.startedAt;
7337
- const sessionSpanId = `span-session-${runId}`;
7338
- return {
7339
- traceId: runId,
7340
- trigger: {
7341
- triggerType: "gateway",
7342
- triggerRunId: `trigger-${runId}`,
7343
- agentKey: "support-agent",
7344
- attachmentId: "attach-slack-incoming",
7345
- attachmentKey: "slack-incoming",
7346
- route: "/agents/support-agent",
7347
- sourcePath: "src/triggers/slack-message.ts"
7348
5562
  },
7349
- gateway: {
7350
- gatewayAttachmentId: "attach-slack-incoming",
7351
- gatewayAttachmentKey: "slack-incoming",
7352
- threadId: "C01234567",
7353
- channelId: "support-escalations",
7354
- mode: "thread"
7355
- },
7356
- spans: [{
7357
- id: sessionSpanId,
7358
- traceId: runId,
7359
- parentSpanId: null,
7360
- kind: "agent_session",
7361
- refId: runId,
7362
- name: "Support Agent",
7363
- status: failed ? "error" : "ok",
7364
- startedAt,
7365
- finishedAt,
7366
- metadata: { messageCount: failed ? 2 : 8 },
7367
- error: failed ? { message: "Credential expired" } : null
7368
- }, {
7369
- id: `span-tool-${runId}`,
7370
- traceId: runId,
7371
- parentSpanId: sessionSpanId,
7372
- kind: "tool_call",
7373
- refId: `tool-${runId}`,
7374
- name: "post_slack_reply",
7375
- status: failed ? "error" : "ok",
7376
- startedAt,
7377
- finishedAt,
7378
- metadata: null,
7379
- error: failed ? { message: "oauth_token_expired" } : null
7380
- }],
7381
- logs: [{
7382
- id: `log-${runId}-1`,
7383
- traceId: runId,
7384
- spanId: sessionSpanId,
7385
- seq: 1,
7386
- level: "info",
7387
- message: failed ? "Received Slack message" : "Session started from gateway thread",
7388
- data: null,
7389
- source: "system",
7390
- createdAt: startedAt
7391
- }, {
7392
- id: `log-${runId}-2`,
7393
- traceId: runId,
7394
- spanId: sessionSpanId,
7395
- seq: 2,
7396
- level: failed ? "error" : "info",
7397
- message: failed ? "Credential expired before response could be posted." : "Drafted three support replies.",
7398
- data: null,
7399
- source: "system",
7400
- createdAt: finishedAt
7401
- }]
7402
- };
7403
- }
7404
- function buildDailyDigestTrace() {
7405
- return {
7406
- traceId: "run-daily-digest-001",
7407
- trigger: {
7408
- triggerType: "cron",
7409
- triggerRunId: "trigger-daily-digest-001",
7410
- workflowKey: "daily-digest",
7411
- attachmentId: "attach-schedule-daily",
7412
- attachmentKey: "schedule-daily",
7413
- route: "/workflows/daily-digest",
7414
- sourcePath: "src/triggers/daily-digest.ts"
7415
- },
7416
- gateway: null,
7417
- spans: [{
7418
- id: "span-wf-daily-001",
7419
- traceId: "run-daily-digest-001",
7420
- parentSpanId: null,
7421
- kind: "workflow_run",
7422
- refId: "run-daily-digest-001",
7423
- name: "Daily Digest",
7424
- status: "running",
7425
- startedAt: "2026-04-20T15:12:00Z",
7426
- finishedAt: null,
7427
- metadata: null,
7428
- error: null
7429
- }, {
7430
- id: "span-action-collect",
7431
- traceId: "run-daily-digest-001",
7432
- parentSpanId: "span-wf-daily-001",
7433
- kind: "action",
7434
- refId: "step-collect",
7435
- name: "collect_updates",
7436
- status: "ok",
7437
- startedAt: "2026-04-20T15:12:02Z",
7438
- finishedAt: "2026-04-20T15:12:45Z",
7439
- metadata: {
7440
- runId: "run-daily-digest-001",
7441
- actionKey: "collect_updates"
7442
- },
7443
- error: null
7444
- }],
7445
- logs: [{
7446
- id: "log-daily-1",
7447
- traceId: "run-daily-digest-001",
7448
- spanId: "span-wf-daily-001",
7449
- seq: 1,
7450
- level: "info",
7451
- message: "Cron tick fired",
7452
- data: null,
7453
- source: "system",
7454
- createdAt: "2026-04-20T15:12:00Z"
7455
- }, {
7456
- id: "log-daily-2",
7457
- traceId: "run-daily-digest-001",
7458
- spanId: "span-wf-daily-001",
7459
- seq: 2,
7460
- level: "info",
7461
- message: "Collecting project updates.",
7462
- data: null,
7463
- source: "console",
7464
- createdAt: "2026-04-20T15:12:46Z"
7465
- }]
7466
- };
7467
- }
7468
- function buildEmailTriageDetail() {
7469
- return {
7470
- kind: "workflow",
7471
- run: {
7472
- id: "run-email-triage-002",
7473
- workflowKey: "email-triage",
7474
- status: "failed",
7475
- trigger: "webhook",
7476
- triggeredAt: "2026-05-31T16:40:05Z",
7477
- startedAt: "2026-05-31T16:40:05Z",
7478
- finishedAt: "2026-05-31T16:40:18Z",
7479
- input: { messageId: "msg_abc123" },
7480
- output: null,
7481
- error: { message: "Step classify failed: missing Gmail scope." }
7482
- },
7483
- trigger: {
7484
- id: "trigger-email-002",
7485
- attachmentKey: "gmail-new-message",
7486
- triggerType: "webhook",
7487
- sourcePath: "src/triggers/gmail-new-message.ts",
7488
- payload: { messageId: "msg_abc123" },
7489
- triggeredAt: "2026-05-31T16:40:05Z"
7490
- },
7491
- steps: [{
7492
- id: "step-ingest-002",
7493
- actionKey: "ingest",
7494
- output: { ok: true },
7495
- completedAt: "2026-05-31T16:40:10Z"
7496
- }, {
7497
- id: "step-classify-002",
7498
- actionKey: "classify",
7499
- output: { error: "missing_scope" },
7500
- completedAt: "2026-05-31T16:40:18Z"
7501
- }],
7502
- trace: {
7503
- traceId: "run-email-triage-002",
7504
- trigger: {
7505
- triggerType: "webhook",
7506
- triggerRunId: "trigger-email-002",
7507
- workflowKey: "email-triage",
7508
- attachmentId: "attach-gmail-new-message",
7509
- attachmentKey: "gmail-new-message",
7510
- route: "/workflows/email-triage"
7511
- },
7512
- gateway: null,
7513
- spans: [{
7514
- id: "span-wf-email-002",
7515
- traceId: "run-email-triage-002",
7516
- parentSpanId: null,
7517
- kind: "workflow_run",
7518
- refId: "run-email-triage-002",
7519
- name: "Email Triage",
7520
- status: "error",
7521
- startedAt: "2026-05-31T16:40:05Z",
7522
- finishedAt: "2026-05-31T16:40:18Z",
7523
- metadata: null,
7524
- error: { message: "Step classify failed" }
7525
- }],
7526
- logs: [{
7527
- id: "log-email-1",
7528
- traceId: "run-email-triage-002",
7529
- spanId: "span-wf-email-002",
7530
- seq: 1,
7531
- level: "error",
7532
- message: "Step classify failed: missing Gmail scope.",
7533
- data: { step: "classify" },
7534
- source: "system",
7535
- createdAt: "2026-05-31T16:40:18Z"
7536
- }]
7537
- },
7538
- ranAs: MOCK_ACTOR,
7539
- usage: buildFailedUsage(13e3)
7540
- };
7541
- }
7542
- const historyDetailById = {
7543
- "run-support-agent-001": {
7544
- kind: "agent",
7545
- session: {
7546
- id: "run-support-agent-001",
7547
- agentKey: "support-agent",
7548
- status: "completed",
7549
- source: "gateway",
7550
- sourceId: "gw-slack-incoming",
7551
- createdAt: "2026-04-20T15:44:00Z",
7552
- updatedAt: "2026-04-20T15:44:42Z",
7553
- messageCount: 8,
7554
- error: null
7555
- },
7556
- gateway: {
7557
- threadId: "C01234567",
7558
- attachmentKey: "slack-incoming"
7559
- },
7560
- messages: [{
7561
- role: "user",
7562
- content: "Customer asked about billing cycle."
7563
- }, {
7564
- role: "assistant",
7565
- content: "Drafted reply with prorated credit explanation."
7566
- }],
7567
- trace: buildSupportAgentTrace("run-support-agent-001", false),
7568
- ranAs: MOCK_ACTOR,
7569
- usage: buildCompletedUsage(42e3)
7570
- },
7571
- "run-support-agent-000": {
7572
- kind: "agent",
7573
- session: {
7574
- id: "run-support-agent-000",
7575
- agentKey: "support-agent",
7576
- status: "failed",
7577
- source: "gateway",
7578
- sourceId: "gw-slack-incoming",
7579
- createdAt: "2026-04-19T18:22:00Z",
7580
- updatedAt: "2026-04-19T18:22:12Z",
7581
- messageCount: 2,
7582
- error: { message: "Credential expired" }
7583
- },
7584
- gateway: {
7585
- threadId: "C09876543",
7586
- attachmentKey: "slack-incoming"
7587
- },
7588
- messages: [{
7589
- role: "user",
7590
- content: "Urgent refund request in #support."
7591
- }],
7592
- trace: buildSupportAgentTrace("run-support-agent-000", true),
7593
- ranAs: MOCK_ACTOR,
7594
- usage: buildFailedUsage(12e3)
7595
- },
7596
- "run-daily-digest-001": {
7597
- kind: "workflow",
7598
- run: {
7599
- id: "run-daily-digest-001",
7600
- workflowKey: "daily-digest",
7601
- status: "running",
7602
- trigger: "cron",
7603
- triggeredAt: "2026-04-20T15:12:00Z",
7604
- startedAt: "2026-04-20T15:12:00Z",
7605
- finishedAt: null,
7606
- input: { date: "2026-04-20" },
7607
- output: null,
7608
- error: null
7609
- },
7610
- trigger: {
7611
- id: "trigger-daily-digest-001",
7612
- attachmentKey: "schedule-daily",
7613
- triggerType: "cron",
7614
- sourcePath: "src/triggers/daily-digest.ts",
7615
- payload: { schedule: "0 8 * * *" },
7616
- triggeredAt: "2026-04-20T15:12:00Z"
7617
- },
7618
- steps: [{
7619
- id: "step-collect-001",
7620
- actionKey: "collect_updates",
7621
- output: { projects: 3 },
7622
- completedAt: "2026-04-20T15:12:45Z"
7623
- }],
7624
- trace: buildDailyDigestTrace(),
7625
- ranAs: MOCK_ACTOR,
7626
- usage: buildRunningUsage()
7627
- },
7628
- "run-email-triage-002": buildEmailTriageDetail(),
7629
- "run-research-agent-003": {
7630
- kind: "agent",
7631
- session: {
7632
- id: "run-research-agent-003",
7633
- agentKey: "research-agent",
7634
- status: "completed",
7635
- source: "api",
7636
- sourceId: null,
7637
- createdAt: "2026-06-01T09:15:00Z",
7638
- updatedAt: "2026-06-01T09:16:24Z",
7639
- messageCount: 12,
7640
- error: null
7641
- },
7642
- gateway: null,
7643
- messages: [{
7644
- role: "user",
7645
- content: "Summarize the Q2 roadmap doc."
7646
- }, {
7647
- role: "assistant",
7648
- content: "Found 4 themes: platform, agents, billing, design."
7649
- }],
7650
- trace: {
7651
- traceId: "run-research-agent-003",
7652
- trigger: {
7653
- triggerType: "api",
7654
- triggerRunId: "trigger-research-003",
7655
- agentKey: "research-agent",
7656
- route: "/agents/research-agent"
7657
- },
7658
- gateway: null,
7659
- spans: [{
7660
- id: "span-research-003",
7661
- traceId: "run-research-agent-003",
7662
- parentSpanId: null,
7663
- kind: "agent_session",
7664
- refId: "run-research-agent-003",
7665
- name: "Research Agent",
7666
- status: "ok",
7667
- startedAt: "2026-06-01T09:15:00Z",
7668
- finishedAt: "2026-06-01T09:16:24Z",
7669
- metadata: { messageCount: 12 },
7670
- error: null
7671
- }],
7672
- logs: [{
7673
- id: "log-research-1",
7674
- traceId: "run-research-agent-003",
7675
- spanId: "span-research-003",
7676
- seq: 1,
7677
- level: "info",
7678
- message: "Summarized 4 documents and returned citations.",
7679
- data: null,
7680
- source: "system",
7681
- createdAt: "2026-06-01T09:16:24Z"
7682
- }]
5563
+ async get(runId) {
5564
+ try {
5565
+ const response = await http.get(`api/history/${encodeURIComponent(runId)}`);
5566
+ if (response.status === 404) return null;
5567
+ const data = await response.json();
5568
+ return HistoryRunDetailResponseSchema.parse(data);
5569
+ } catch (error) {
5570
+ throw await toPlatformError(error);
5571
+ }
7683
5572
  },
7684
- ranAs: MOCK_ACTOR,
7685
- usage: buildCompletedUsage(84e3)
7686
- }
7687
- };
7688
- function applyRunStatusOverride(detail, override) {
7689
- if (detail.kind === "workflow") return {
7690
- ...detail,
7691
- run: {
7692
- ...detail.run,
7693
- status: override.status,
7694
- finishedAt: override.finishedAt
7695
- }
7696
- };
7697
- return {
7698
- ...detail,
7699
- session: {
7700
- ...detail.session,
7701
- status: override.status,
7702
- updatedAt: override.finishedAt ?? detail.session.updatedAt
5573
+ async cancel(runId) {
5574
+ try {
5575
+ const response = await http.post(`api/history/${encodeURIComponent(runId)}/cancel`);
5576
+ if (response.status === 404) return null;
5577
+ const data = await response.json();
5578
+ return HistoryRunCancelResponseSchema.parse(data);
5579
+ } catch (error) {
5580
+ throw await toPlatformError(error);
5581
+ }
7703
5582
  }
7704
5583
  };
7705
5584
  }
7706
- function getHistoryRunDetail(runId) {
7707
- const detail = historyDetailById[runId];
7708
- if (!detail) return null;
7709
- const override = historyRunStatusOverrides.get(runId);
7710
- return override ? applyRunStatusOverride(detail, override) : detail;
7711
- }
7712
- function createHistoryResource() {
7713
- return {
7714
- /** Runs across projects the current user can access in the active org. */
7715
- list: mock({
7716
- domain: "history",
7717
- method: "list",
7718
- plannedEndpoint: "GET /api/orgs/:orgSlug/history"
7719
- }, async () => [...listHistoryRuns()].sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime())),
7720
- get: mock({
7721
- domain: "history",
7722
- method: "get",
7723
- plannedEndpoint: "GET /api/orgs/:orgSlug/history/:runId"
7724
- }, async (runId) => getHistoryRunDetail(runId)),
7725
- /** Cancel a running/queued run. Returns the updated run (or null if unknown). */
7726
- cancel: mock({
7727
- domain: "history",
7728
- method: "cancel",
7729
- plannedEndpoint: "POST /api/orgs/:orgSlug/history/:runId/cancel"
7730
- }, async (runId) => cancelHistoryRun(runId))
7731
- };
7732
- }
7733
5585
  async function presignPutAndFinalize(input) {
7734
5586
  const contentType = input.file.type?.trim() || "application/octet-stream";
7735
5587
  const uploadFailedMessage = input.uploadFailedMessage ?? "Upload failed";
@@ -8595,7 +6447,7 @@ function createPlatformClient(options) {
8595
6447
  skills: createSkillsResource(http),
8596
6448
  apps: createAppsResource(),
8597
6449
  credentials: createCredentialsResource(),
8598
- history: createHistoryResource(),
6450
+ history: createHistoryResource(http),
8599
6451
  deployments: createDeploymentsResource(http),
8600
6452
  gatewayAttachments: createGatewayAttachmentsResource(http),
8601
6453
  projectMetrics: createProjectMetricsResource(http),
@@ -8964,6 +6816,30 @@ function parseJsonOption(value, flag) {
8964
6816
  }
8965
6817
  }
8966
6818
  //#endregion
6819
+ //#region src/resolve-project-target.ts
6820
+ async function resolveActiveProject(config, platform) {
6821
+ const ref = getCliTargetOptions().projectId ?? config.get("activeProjectId");
6822
+ if (!ref) return;
6823
+ const client = platform ?? createCliPlatformClient(config);
6824
+ if (!getCliTargetOptions().projectId && looksLikeUuid(ref)) return resolveProjectRef(client, ref);
6825
+ return resolveProjectRef(client, ref);
6826
+ }
6827
+ async function resolveActiveProjectId(config) {
6828
+ return (await resolveActiveProject(config))?.id;
6829
+ }
6830
+ //#endregion
6831
+ //#region src/commands/agent/list.ts
6832
+ function registerAgentListCommand(agent) {
6833
+ agent.command("list").description("List agents in the active organization").action(() => runCliCommand("List agents failed", async () => {
6834
+ const config = createCliConfig();
6835
+ const client = createCliPlatformClient(config);
6836
+ await ensureActiveOrganization(config);
6837
+ const projectId = await resolveActiveProjectId(config);
6838
+ const result = await client.agents.list(projectId ? { projectId } : void 0);
6839
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
6840
+ }, void 0, { orgScoped: true }));
6841
+ }
6842
+ //#endregion
8967
6843
  //#region src/commands/agent/prompt.ts
8968
6844
  function registerAgentPromptCommand(agent) {
8969
6845
  agent.command("prompt").description("Send a message to an agent (or follow up in an existing session)").argument("<agentId>", "Agent key / route id").requiredOption("--message <text>", "Message to send").option("--session-id <id>", "Existing session id for follow-up").action((agentId, options) => runProjectCliCommand("Agent prompt failed", async ({ client }) => {
@@ -8996,6 +6872,7 @@ function registerAgentSessionsCommand(agent) {
8996
6872
  //#region src/commands/agent/index.ts
8997
6873
  function registerAgentCommand(program) {
8998
6874
  const agent = program.command("agent").description("Invoke and inspect agents");
6875
+ registerAgentListCommand(agent);
8999
6876
  registerAgentPromptCommand(agent);
9000
6877
  registerAgentSessionsCommand(agent);
9001
6878
  }
@@ -9393,7 +7270,7 @@ function registerBuildCommand(program) {
9393
7270
  program.command("build").description("Build the keystroke project for production").option("--dir <path>", "Project directory", process.cwd()).action(async (options) => {
9394
7271
  try {
9395
7272
  const root = resolveProjectRoot(options.dir);
9396
- const { buildApp } = await import("./dist-uZuvgIVp.mjs");
7273
+ const { buildApp } = await import("./dist-CSolAKQe.mjs");
9397
7274
  await buildApp({ root });
9398
7275
  process.stdout.write(`Built ${root}\n`);
9399
7276
  } catch (error) {
@@ -9437,115 +7314,10 @@ function packProjectArtifact(projectRoot) {
9437
7314
  }
9438
7315
  //#endregion
9439
7316
  //#region src/project/collect-source.ts
9440
- const IGNORED_DIRS = new Set([
9441
- "node_modules",
9442
- "dist",
9443
- ".git",
9444
- ".turbo",
9445
- "build",
9446
- "coverage",
9447
- ".keystroke",
9448
- ".cache",
9449
- "tmp"
9450
- ]);
9451
- const IGNORED_ENV_FILE = /\.env/;
9452
- const IGNORED_LOG_FILE = /\.log$/;
9453
- const MAX_FILE_BYTES = 256 * 1024;
9454
- const MAX_TOTAL_BYTES = 8 * 1024 * 1024;
9455
- const MAX_FILES = 2e3;
9456
- function isIgnoredFile(name) {
9457
- return IGNORED_ENV_FILE.test(name) || IGNORED_LOG_FILE.test(name);
9458
- }
9459
- function toPosix(path) {
9460
- return path.split(sep).join("/");
9461
- }
9462
- function isProbablyBinary(buffer) {
9463
- const sampleLength = Math.min(buffer.length, 8e3);
9464
- for (let index = 0; index < sampleLength; index += 1) if (buffer[index] === 0) return true;
9465
- return false;
9466
- }
9467
- function walkFiles(root, dir, out, totals) {
9468
- for (const name of readdirSync(dir).sort()) {
9469
- if (out.length >= MAX_FILES || totals.bytes >= MAX_TOTAL_BYTES) return;
9470
- const absolute = join(dir, name);
9471
- const stats = statSync(absolute);
9472
- if (stats.isDirectory()) {
9473
- if (IGNORED_DIRS.has(name)) continue;
9474
- walkFiles(root, absolute, out, totals);
9475
- continue;
9476
- }
9477
- if (!stats.isFile() || stats.size > MAX_FILE_BYTES || isIgnoredFile(name)) continue;
9478
- const buffer = readFileSync(absolute);
9479
- if (isProbablyBinary(buffer)) continue;
9480
- totals.bytes += buffer.byteLength;
9481
- out.push({
9482
- path: toPosix(relative(root, absolute)),
9483
- contents: buffer.toString("utf8"),
9484
- hash: createHash("sha256").update(buffer).digest("hex")
9485
- });
9486
- }
9487
- }
9488
- function posixPrefix(root, srcRoot, subdir) {
9489
- return `${toPosix(relative(root, join(srcRoot, subdir)))}/`;
9490
- }
9491
- function collectModuleRefs(srcRoot, root, files, subdir, nestedEntry) {
9492
- const dir = join(srcRoot, subdir);
9493
- const prefix = posixPrefix(root, srcRoot, subdir);
9494
- const refs = [];
9495
- for (const file of files) {
9496
- if (!file.path.startsWith(prefix) || !/\.(ts|mts)$/.test(file.path)) continue;
9497
- const slug = entryIdFromFile(dir, join(root, file.path), { nestedEntry });
9498
- if (slug) refs.push({
9499
- slug,
9500
- path: file.path
9501
- });
9502
- }
9503
- return refs;
9504
- }
9505
- function collectSkillRefs(srcRoot, root, files) {
9506
- const dir = join(srcRoot, "skills");
9507
- const prefix = posixPrefix(root, srcRoot, "skills");
9508
- const refs = [];
9509
- for (const file of files) {
9510
- if (!file.path.startsWith(prefix) || !file.path.endsWith("SKILL.md")) continue;
9511
- const slug = toPosix(relative(dir, join(root, file.path)).replace(/\/?SKILL\.md$/, ""));
9512
- if (slug) refs.push({
9513
- slug,
9514
- path: file.path
9515
- });
9516
- }
9517
- return refs;
9518
- }
9519
- /**
9520
- * Collect the project's actual source code into a deploy snapshot: every text
9521
- * file under the project root (minus build output / deps) plus a map of each
9522
- * agent / workflow / skill key to its source path. The map mirrors the same
9523
- * path-derived ids the build step uses.
9524
- */
7317
+ /** Collect deploy source files via the shared project walk (for `--skip-build`). */
9525
7318
  function collectProjectSource(root) {
9526
- const files = [];
9527
- walkFiles(root, root, files, { bytes: 0 });
9528
- const srcRoot = join(root, "src");
9529
- return {
9530
- files,
9531
- resources: {
9532
- agents: collectModuleRefs(srcRoot, root, files, "agents", "agent"),
9533
- workflows: collectModuleRefs(srcRoot, root, files, "workflows", "workflow"),
9534
- skills: collectSkillRefs(srcRoot, root, files)
9535
- }
9536
- };
9537
- }
9538
- //#endregion
9539
- //#region src/resolve-project-target.ts
9540
- async function resolveActiveProject(config, platform) {
9541
- const ref = getCliTargetOptions().projectId ?? config.get("activeProjectId");
9542
- if (!ref) return;
9543
- const client = platform ?? createCliPlatformClient(config);
9544
- if (!getCliTargetOptions().projectId && looksLikeUuid(ref)) return resolveProjectRef(client, ref);
9545
- return resolveProjectRef(client, ref);
9546
- }
9547
- async function resolveActiveProjectId(config) {
9548
- return (await resolveActiveProject(config))?.id;
7319
+ if (!existsSync(join(root, "dist/.keystroke/route-manifest.json"))) throw new Error(`Route manifest missing at ${ROUTE_MANIFEST_REL_PATH}. Run keystroke build before deploy --skip-build.`);
7320
+ return { files: walkProject(root, { collectSources: true }).sourceFiles };
9549
7321
  }
9550
7322
  //#endregion
9551
7323
  //#region src/commands/deploy.ts
@@ -9579,13 +7351,10 @@ async function uploadProjectSourceSnapshot(client, projectId, artifactId, source
9579
7351
  });
9580
7352
  if (!response.ok) throw new Error(`Source blob upload failed (${response.status})`);
9581
7353
  }));
9582
- await client.artifacts.uploadManifest(projectId, artifactId, {
9583
- files: source.files.map((file) => ({
9584
- path: file.path,
9585
- hash: file.hash
9586
- })),
9587
- resources: source.resources
9588
- });
7354
+ await client.artifacts.uploadManifest(projectId, artifactId, { files: source.files.map((file) => ({
7355
+ path: file.path,
7356
+ hash: file.hash
7357
+ })) });
9589
7358
  }
9590
7359
  async function sleep(ms) {
9591
7360
  await new Promise((resolve) => {
@@ -9596,16 +7365,20 @@ async function runDeploy(options) {
9596
7365
  const root = resolveProjectRoot(options.dir);
9597
7366
  const config = createCliConfig();
9598
7367
  const client = createCliPlatformClient(config);
7368
+ let source;
9599
7369
  if (!options.skipBuild) {
9600
- const { buildApp } = await import("./dist-uZuvgIVp.mjs");
9601
- await buildApp({ root });
9602
- }
7370
+ const { buildApp } = await import("./dist-CSolAKQe.mjs");
7371
+ source = { files: (await buildApp({
7372
+ root,
7373
+ collectSources: true,
7374
+ emitManifest: true
7375
+ })).sourceFiles };
7376
+ } else source = collectProjectSource(root);
9603
7377
  const archive = packProjectArtifact(root);
9604
7378
  let active = await client.organizations.getActive();
9605
7379
  if (!active) active = await selectActiveOrganization(config);
9606
7380
  client.setActiveOrganizationId(active.organization.id);
9607
7381
  const project = await client.projects.get(options.projectId);
9608
- const source = collectProjectSource(root);
9609
7382
  const created = await client.artifacts.create(project.id);
9610
7383
  const uploadPromise = fetch(created.uploadUrl, {
9611
7384
  method: "PUT",
@@ -9694,7 +7467,7 @@ function runtimeChildEnv(parentEnv, overrides) {
9694
7467
  //#region src/project/bootstrap-run.ts
9695
7468
  /** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
9696
7469
  async function resolveBootstrapRun(options) {
9697
- const { resolveRuntimeBuildArtifact } = await import("./dist-uZuvgIVp.mjs");
7470
+ const { resolveRuntimeBuildArtifact } = await import("./dist-CSolAKQe.mjs");
9698
7471
  const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
9699
7472
  const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/bootstrap.mjs");
9700
7473
  const args = [`--import=${loader}`];
@@ -9844,7 +7617,7 @@ async function runDev(options) {
9844
7617
  process.on("SIGINT", shutdown);
9845
7618
  process.on("SIGTERM", shutdown);
9846
7619
  try {
9847
- const { watchApp } = await import("./dist-uZuvgIVp.mjs");
7620
+ const { watchApp } = await import("./dist-CSolAKQe.mjs");
9848
7621
  await watchApp({
9849
7622
  root,
9850
7623
  clean: false,
@@ -9872,6 +7645,138 @@ function registerDevCommand(program) {
9872
7645
  });
9873
7646
  }
9874
7647
  //#endregion
7648
+ //#region src/commands/project/run-project.ts
7649
+ async function withActivePlatformClient(config, fn) {
7650
+ const platform = createCliPlatformClient(config);
7651
+ let active = await platform.organizations.getActive();
7652
+ if (!active) active = await selectActiveOrganization(config);
7653
+ platform.setActiveOrganizationId(active.organization.id);
7654
+ await fn(platform);
7655
+ }
7656
+ function writeInactiveDeployHints(projects) {
7657
+ const bin = cliBinaryName();
7658
+ for (const project of projects) {
7659
+ if (project.status !== "inactive") continue;
7660
+ process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
7661
+ }
7662
+ }
7663
+ async function runProjectList(config) {
7664
+ await withActivePlatformClient(config, async (platform) => {
7665
+ const projects = await platform.projects.list();
7666
+ process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
7667
+ if (projects.length === 0) {
7668
+ const bin = cliBinaryName();
7669
+ process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
7670
+ return;
7671
+ }
7672
+ writeInactiveDeployHints(projects);
7673
+ });
7674
+ }
7675
+ async function runProjectMetrics(config, options) {
7676
+ await withActivePlatformClient(config, async (platform) => {
7677
+ const metrics = await platform.projectMetrics.list();
7678
+ if (options.projectRef === void 0) {
7679
+ process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
7680
+ return;
7681
+ }
7682
+ const project = await resolveProjectRef(platform, options.projectRef);
7683
+ const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
7684
+ process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
7685
+ });
7686
+ }
7687
+ async function runProjectDeploymentsList(config, options) {
7688
+ await withActivePlatformClient(config, async (platform) => {
7689
+ const project = await resolveProjectRef(platform, options.projectRef);
7690
+ const deployments = await platform.deployments.listForProject(project.id);
7691
+ process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
7692
+ });
7693
+ }
7694
+ async function runProjectCreate(config, input) {
7695
+ await withActivePlatformClient(config, async (platform) => {
7696
+ const project = await platform.projects.create(input);
7697
+ process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
7698
+ writeInactiveDeployHints([project]);
7699
+ });
7700
+ }
7701
+ async function runProjectUpdate(config, input) {
7702
+ await withActivePlatformClient(config, async (platform) => {
7703
+ const { projectId, ...patch } = input;
7704
+ const project = await platform.projects.update(projectId, patch);
7705
+ process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
7706
+ });
7707
+ }
7708
+ async function runProjectDelete(config, projectId) {
7709
+ await withActivePlatformClient(config, async (platform) => {
7710
+ await platform.projects.delete(projectId);
7711
+ process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
7712
+ });
7713
+ }
7714
+ //#endregion
7715
+ //#region src/commands/history/run-history.ts
7716
+ async function runHistoryList(config, filters) {
7717
+ await withActivePlatformClient(config, async (platform) => {
7718
+ const runs = await platform.history.list(filters);
7719
+ process.stdout.write(`${JSON.stringify(runs, null, 2)}\n`);
7720
+ });
7721
+ }
7722
+ async function runHistoryGet(config, runId) {
7723
+ await withActivePlatformClient(config, async (platform) => {
7724
+ const run = await platform.history.get(runId);
7725
+ process.stdout.write(`${JSON.stringify(run, null, 2)}\n`);
7726
+ });
7727
+ }
7728
+ async function runHistoryCancel(config, runId) {
7729
+ await withActivePlatformClient(config, async (platform) => {
7730
+ const run = await platform.history.cancel(runId);
7731
+ process.stdout.write(`${JSON.stringify(run, null, 2)}\n`);
7732
+ });
7733
+ }
7734
+ //#endregion
7735
+ //#region src/commands/history/index.ts
7736
+ function registerHistoryCommand(program) {
7737
+ const history = program.command("history").description("List, inspect, and cancel platform run history");
7738
+ history.command("list").description("List runs across projects in the active organization").option("--project <id>", "Filter by project id").option("--status <status>", "Filter by status (pending, running, sleeping, waiting_hook, completed, failed, canceled)").option("--kind <kind>", "Filter by kind (workflow or agent)").action(async (options) => {
7739
+ const config = createCliConfig();
7740
+ try {
7741
+ await runHistoryList(config, {
7742
+ ...options.project ? { project: options.project } : {},
7743
+ ...options.status ? { status: options.status } : {},
7744
+ ...options.kind ? { kind: options.kind } : {}
7745
+ });
7746
+ } catch (error) {
7747
+ process.stderr.write(`${formatCliError(error, "List history failed", {
7748
+ serverUrl: getPlatformUrl(config),
7749
+ webUrl: getWebUrl(config)
7750
+ })}\n`);
7751
+ process.exitCode = 1;
7752
+ }
7753
+ });
7754
+ history.command("get").description("Get run details").argument("<runId>", "Run id").action(async (runId) => {
7755
+ const config = createCliConfig();
7756
+ try {
7757
+ await runHistoryGet(config, runId);
7758
+ } catch (error) {
7759
+ process.stderr.write(`${formatCliError(error, "Get history run failed", {
7760
+ serverUrl: getPlatformUrl(config),
7761
+ webUrl: getWebUrl(config)
7762
+ })}\n`);
7763
+ process.exitCode = 1;
7764
+ }
7765
+ });
7766
+ history.command("cancel").description("Cancel a pending workflow run").argument("<runId>", "Run id").action(async (runId) => {
7767
+ const config = createCliConfig();
7768
+ try {
7769
+ await runHistoryCancel(config, runId);
7770
+ } catch (error) {
7771
+ process.stderr.write(`${formatCliError(error, "Cancel history run failed", {
7772
+ serverUrl: getPlatformUrl(config),
7773
+ webUrl: getWebUrl(config)
7774
+ })}\n`);
7775
+ process.exitCode = 1;
7776
+ }
7777
+ });
7778
+ }
7779
+ //#endregion
9875
7780
  //#region src/commands/health.ts
9876
7781
  function registerHealthCommand(program) {
9877
7782
  program.command("health").description("Check connectivity to the keystroke API").action(() => runCliCommand("Health check failed", async ({ client }) => {
@@ -10187,73 +8092,6 @@ function registerInitCommand(program) {
10187
8092
  });
10188
8093
  }
10189
8094
  //#endregion
10190
- //#region src/commands/project/run-project.ts
10191
- async function withActivePlatformClient(config, fn) {
10192
- const platform = createCliPlatformClient(config);
10193
- let active = await platform.organizations.getActive();
10194
- if (!active) active = await selectActiveOrganization(config);
10195
- platform.setActiveOrganizationId(active.organization.id);
10196
- await fn(platform);
10197
- }
10198
- function writeInactiveDeployHints(projects) {
10199
- const bin = cliBinaryName();
10200
- for (const project of projects) {
10201
- if (project.status !== "inactive") continue;
10202
- process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
10203
- }
10204
- }
10205
- async function runProjectList(config) {
10206
- await withActivePlatformClient(config, async (platform) => {
10207
- const projects = await platform.projects.list();
10208
- process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
10209
- if (projects.length === 0) {
10210
- const bin = cliBinaryName();
10211
- process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
10212
- return;
10213
- }
10214
- writeInactiveDeployHints(projects);
10215
- });
10216
- }
10217
- async function runProjectMetrics(config, options) {
10218
- await withActivePlatformClient(config, async (platform) => {
10219
- const metrics = await platform.projectMetrics.list();
10220
- if (options.projectRef === void 0) {
10221
- process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
10222
- return;
10223
- }
10224
- const project = await resolveProjectRef(platform, options.projectRef);
10225
- const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
10226
- process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
10227
- });
10228
- }
10229
- async function runProjectDeploymentsList(config, options) {
10230
- await withActivePlatformClient(config, async (platform) => {
10231
- const project = await resolveProjectRef(platform, options.projectRef);
10232
- const deployments = await platform.deployments.listForProject(project.id);
10233
- process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
10234
- });
10235
- }
10236
- async function runProjectCreate(config, input) {
10237
- await withActivePlatformClient(config, async (platform) => {
10238
- const project = await platform.projects.create(input);
10239
- process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
10240
- writeInactiveDeployHints([project]);
10241
- });
10242
- }
10243
- async function runProjectUpdate(config, input) {
10244
- await withActivePlatformClient(config, async (platform) => {
10245
- const { projectId, ...patch } = input;
10246
- const project = await platform.projects.update(projectId, patch);
10247
- process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
10248
- });
10249
- }
10250
- async function runProjectDelete(config, projectId) {
10251
- await withActivePlatformClient(config, async (platform) => {
10252
- await platform.projects.delete(projectId);
10253
- process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
10254
- });
10255
- }
10256
- //#endregion
10257
8095
  //#region src/commands/organization/run-organization.ts
10258
8096
  async function runOrganizationUpdate(config, input) {
10259
8097
  await withActivePlatformClient(config, async (platform) => {
@@ -10382,7 +8220,7 @@ async function runStart(options) {
10382
8220
  const apiPort = Number(new URL(serverUrl).port || 80);
10383
8221
  const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
10384
8222
  ensureNativeDeps(runtimeNodeModules);
10385
- const { buildApp } = await import("./dist-uZuvgIVp.mjs");
8223
+ const { buildApp } = await import("./dist-CSolAKQe.mjs");
10386
8224
  await buildApp({
10387
8225
  root,
10388
8226
  clean: false
@@ -10475,6 +8313,18 @@ function registerTriggerCommand(program) {
10475
8313
  registerTriggerRunsCommand(trigger);
10476
8314
  }
10477
8315
  //#endregion
8316
+ //#region src/commands/workflow/list.ts
8317
+ function registerWorkflowListCommand(workflow) {
8318
+ workflow.command("list").description("List workflows in the active organization").action(() => runCliCommand("List workflows failed", async () => {
8319
+ const config = createCliConfig();
8320
+ const client = createCliPlatformClient(config);
8321
+ await ensureActiveOrganization(config);
8322
+ const projectId = await resolveActiveProjectId(config);
8323
+ const result = await client.workflows.list(projectId ? { projectId } : void 0);
8324
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
8325
+ }, void 0, { orgScoped: true }));
8326
+ }
8327
+ //#endregion
10478
8328
  //#region src/commands/workflow/run.ts
10479
8329
  function registerWorkflowRunCommand(workflow) {
10480
8330
  workflow.command("run").description("Invoke a workflow").argument("<workflowId>", "Workflow key / route id").option("--input <json>", "JSON request body (defaults to {})", "{}").addHelpText("after", `
@@ -10513,6 +8363,7 @@ function registerWorkflowRunsCommand(workflow) {
10513
8363
  //#region src/commands/workflow/index.ts
10514
8364
  function registerWorkflowCommand(program) {
10515
8365
  const workflow = program.command("workflow").description("Invoke and inspect workflows");
8366
+ registerWorkflowListCommand(workflow);
10516
8367
  registerWorkflowRunCommand(workflow);
10517
8368
  registerWorkflowRunsCommand(workflow);
10518
8369
  }
@@ -10586,6 +8437,18 @@ function registerConfigCommand(program) {
10586
8437
  });
10587
8438
  }
10588
8439
  //#endregion
8440
+ //#region src/commands/skill/index.ts
8441
+ function registerSkillCommand(program) {
8442
+ program.command("skill").description("Inspect platform skills").command("list").description("List skills in the active organization").action(() => runCliCommand("List skills failed", async () => {
8443
+ const config = createCliConfig();
8444
+ const client = createCliPlatformClient(config);
8445
+ await ensureActiveOrganization(config);
8446
+ const projectId = await resolveActiveProjectId(config);
8447
+ const result = await client.skills.list(projectId ? { projectId } : void 0);
8448
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
8449
+ }, void 0, { orgScoped: true }));
8450
+ }
8451
+ //#endregion
10589
8452
  //#region src/commands/skills.ts
10590
8453
  function registerSkillsCommand(program) {
10591
8454
  program.command("skills").description("Manage bundled agent skills").command("sync").description("Overwrite bundled skills and AGENTS.md with the CLI version").option("--dir <path>", "Project directory", process.cwd()).action(async (options) => {
@@ -10662,10 +8525,12 @@ function createProgram() {
10662
8525
  registerConfigCommand(program);
10663
8526
  registerOrganizationCommand(program);
10664
8527
  registerProjectCommand(program);
8528
+ registerHistoryCommand(program);
10665
8529
  registerCredentialsCommand(program);
10666
8530
  registerHealthCommand(program);
10667
8531
  registerInitCommand(program);
10668
8532
  registerSkillsCommand(program);
8533
+ registerSkillCommand(program);
10669
8534
  registerBuildCommand(program);
10670
8535
  registerDeployCommand(program);
10671
8536
  registerDevCommand(program);