@runtypelabs/cli 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10905,7 +10905,8 @@ var require_builtin_tools_registry = __commonJS({
10905
10905
  KNOWLEDGE_RETRIEVAL: "knowledge_retrieval",
10906
10906
  TEXT_TO_SPEECH: "text_to_speech",
10907
10907
  VOICE_PROCESSING: "voice_processing",
10908
- THIRD_PARTY_API: "third_party_api"
10908
+ THIRD_PARTY_API: "third_party_api",
10909
+ ARTIFACT: "artifact"
10909
10910
  };
10910
10911
  exports.BuiltInToolIdPrefix = {
10911
10912
  BUILTIN: "builtin",
@@ -11387,6 +11388,57 @@ var require_builtin_tools_registry = __commonJS({
11387
11388
  platformKeySupport: true,
11388
11389
  marginPercent: 20,
11389
11390
  hidden: true
11391
+ },
11392
+ // Artifact-emit tools (auto-injected at runtime when ArtifactConfig is enabled)
11393
+ {
11394
+ id: "emit_artifact_markdown",
11395
+ name: "Emit Artifact (Markdown)",
11396
+ description: "Stream markdown content to the artifact channel on supported clients.",
11397
+ category: exports.BuiltInToolCategory.ARTIFACT,
11398
+ providers: [exports.BuiltInToolProvider.MULTI],
11399
+ parametersSchema: {
11400
+ type: "object",
11401
+ properties: {
11402
+ title: {
11403
+ type: "string",
11404
+ description: "Optional title for the artifact"
11405
+ },
11406
+ markdown: {
11407
+ type: "string",
11408
+ description: "Markdown content to render"
11409
+ }
11410
+ },
11411
+ required: ["markdown"]
11412
+ },
11413
+ executionHint: "platform",
11414
+ hidden: true
11415
+ },
11416
+ {
11417
+ id: "emit_artifact_component",
11418
+ name: "Emit Artifact (Component)",
11419
+ description: "Emit a named component reference with props to the artifact channel. The client renders it using its registered component library.",
11420
+ category: exports.BuiltInToolCategory.ARTIFACT,
11421
+ providers: [exports.BuiltInToolProvider.MULTI],
11422
+ parametersSchema: {
11423
+ type: "object",
11424
+ properties: {
11425
+ title: {
11426
+ type: "string",
11427
+ description: "Optional title for the artifact"
11428
+ },
11429
+ component: {
11430
+ type: "string",
11431
+ description: "Name of a component registered in the client-side component registry"
11432
+ },
11433
+ props: {
11434
+ type: "object",
11435
+ description: "Props object passed to the component renderer"
11436
+ }
11437
+ },
11438
+ required: ["component"]
11439
+ },
11440
+ executionHint: "platform",
11441
+ hidden: true
11390
11442
  }
11391
11443
  ];
11392
11444
  exports.BUILTIN_TOOLS_REGISTRY = [
@@ -11584,6 +11636,7 @@ var require_generated_model_routing = __commonJS({
11584
11636
  "gemini-3.1-flash-lite-preview": ["vercel"],
11585
11637
  "gemini-3.1-pro-preview": ["vercel"],
11586
11638
  "gemini-embedding-001": ["vercel"],
11639
+ "gemini-embedding-2": ["vercel"],
11587
11640
  "gemini-flash-1.5-8b": ["google"],
11588
11641
  "gemini-pro": ["google"],
11589
11642
  "gemma-2-9b": ["vercel"],
@@ -11733,8 +11786,11 @@ var require_generated_model_routing = __commonJS({
11733
11786
  "grok-4-fast-reasoning": ["vercel"],
11734
11787
  "grok-4.1-fast-non-reasoning": ["vercel"],
11735
11788
  "grok-4.1-fast-reasoning": ["vercel"],
11789
+ "grok-4.20-multi-agent": ["vercel"],
11736
11790
  "grok-4.20-multi-agent-beta": ["vercel"],
11791
+ "grok-4.20-non-reasoning": ["vercel"],
11737
11792
  "grok-4.20-non-reasoning-beta": ["vercel"],
11793
+ "grok-4.20-reasoning": ["vercel"],
11738
11794
  "grok-4.20-reasoning-beta": ["vercel"],
11739
11795
  "grok-beta": ["xai"],
11740
11796
  "grok-code-fast-1": ["vercel", "xai"],
@@ -11791,6 +11847,7 @@ var require_generated_model_routing = __commonJS({
11791
11847
  "Meta-Llama-3.3-70B-Instruct-Turbo": ["togetherai"],
11792
11848
  "meta.llama3-8b-instruct-v1%3A0": ["bedrock"],
11793
11849
  "mimo-v2-flash": ["vercel"],
11850
+ "mimo-v2-pro": ["vercel"],
11794
11851
  "minimax-m2": ["vercel"],
11795
11852
  "minimax-m2.1": ["vercel"],
11796
11853
  "minimax-m2.1-lightning": ["vercel"],
@@ -12039,6 +12096,7 @@ var require_generated_model_routing = __commonJS({
12039
12096
  "gemini-3-flash": ["google", "vercel"],
12040
12097
  "gemini-3-pro-image": ["vercel"],
12041
12098
  "gemini-embedding-001": ["vercel"],
12099
+ "gemini-embedding-2": ["vercel"],
12042
12100
  "gemini-flash-1-5-8b": ["google"],
12043
12101
  "gemini-pro": ["google"],
12044
12102
  "gemma-2-9b": ["vercel"],
@@ -12179,8 +12237,11 @@ var require_generated_model_routing = __commonJS({
12179
12237
  "grok-4": ["vercel", "xai"],
12180
12238
  "grok-4-1-fast-non-reasoning": ["vercel"],
12181
12239
  "grok-4-1-fast-reasoning": ["vercel"],
12240
+ "grok-4-20-multi-agent": ["vercel"],
12182
12241
  "grok-4-20-multi-agent-beta": ["vercel"],
12242
+ "grok-4-20-non-reasoning": ["vercel"],
12183
12243
  "grok-4-20-non-reasoning-beta": ["vercel"],
12244
+ "grok-4-20-reasoning": ["vercel"],
12184
12245
  "grok-4-20-reasoning-beta": ["vercel"],
12185
12246
  "grok-4-fast": ["xai"],
12186
12247
  "grok-4-fast-non-reasoning": ["vercel"],
@@ -12232,6 +12293,7 @@ var require_generated_model_routing = __commonJS({
12232
12293
  "meta-llama-3-8b-instruct-turbo": ["togetherai"],
12233
12294
  "meta.llama3-8b-instruct-v1%3a0": ["bedrock"],
12234
12295
  "mimo-v2-flash": ["vercel"],
12296
+ "mimo-v2-pro": ["vercel"],
12235
12297
  "minimax-m2": ["vercel"],
12236
12298
  "minimax-m2-1": ["vercel"],
12237
12299
  "minimax-m2-1-lightning": ["vercel"],
@@ -12765,6 +12827,9 @@ var require_generated_model_routing = __commonJS({
12765
12827
  "gemini-embedding-001": {
12766
12828
  "vercel": "google/gemini-embedding-001"
12767
12829
  },
12830
+ "gemini-embedding-2": {
12831
+ "vercel": "google/gemini-embedding-2"
12832
+ },
12768
12833
  "gemini-flash-1-5-8b": {
12769
12834
  "google": "gemini-flash-1.5-8b"
12770
12835
  },
@@ -13403,12 +13468,21 @@ var require_generated_model_routing = __commonJS({
13403
13468
  "grok-4-1-fast-reasoning": {
13404
13469
  "vercel": "xai/grok-4.1-fast-reasoning"
13405
13470
  },
13471
+ "grok-4-20-multi-agent": {
13472
+ "vercel": "xai/grok-4.20-multi-agent"
13473
+ },
13406
13474
  "grok-4-20-multi-agent-beta": {
13407
13475
  "vercel": "xai/grok-4.20-multi-agent-beta"
13408
13476
  },
13477
+ "grok-4-20-non-reasoning": {
13478
+ "vercel": "xai/grok-4.20-non-reasoning"
13479
+ },
13409
13480
  "grok-4-20-non-reasoning-beta": {
13410
13481
  "vercel": "xai/grok-4.20-non-reasoning-beta"
13411
13482
  },
13483
+ "grok-4-20-reasoning": {
13484
+ "vercel": "xai/grok-4.20-reasoning"
13485
+ },
13412
13486
  "grok-4-20-reasoning-beta": {
13413
13487
  "vercel": "xai/grok-4.20-reasoning-beta"
13414
13488
  },
@@ -13427,12 +13501,21 @@ var require_generated_model_routing = __commonJS({
13427
13501
  "grok-4.1-fast-reasoning": {
13428
13502
  "vercel": "xai/grok-4.1-fast-reasoning"
13429
13503
  },
13504
+ "grok-4.20-multi-agent": {
13505
+ "vercel": "xai/grok-4.20-multi-agent"
13506
+ },
13430
13507
  "grok-4.20-multi-agent-beta": {
13431
13508
  "vercel": "xai/grok-4.20-multi-agent-beta"
13432
13509
  },
13510
+ "grok-4.20-non-reasoning": {
13511
+ "vercel": "xai/grok-4.20-non-reasoning"
13512
+ },
13433
13513
  "grok-4.20-non-reasoning-beta": {
13434
13514
  "vercel": "xai/grok-4.20-non-reasoning-beta"
13435
13515
  },
13516
+ "grok-4.20-reasoning": {
13517
+ "vercel": "xai/grok-4.20-reasoning"
13518
+ },
13436
13519
  "grok-4.20-reasoning-beta": {
13437
13520
  "vercel": "xai/grok-4.20-reasoning-beta"
13438
13521
  },
@@ -13674,6 +13757,9 @@ var require_generated_model_routing = __commonJS({
13674
13757
  "mimo-v2-flash": {
13675
13758
  "vercel": "xiaomi/mimo-v2-flash"
13676
13759
  },
13760
+ "mimo-v2-pro": {
13761
+ "vercel": "xiaomi/mimo-v2-pro"
13762
+ },
13677
13763
  "minimax-m2": {
13678
13764
  "vercel": "minimax/minimax-m2"
13679
13765
  },
@@ -15290,8 +15376,8 @@ var require_provider_routing = __commonJS({
15290
15376
  });
15291
15377
 
15292
15378
  // src/index.ts
15293
- import { Command as Command19 } from "commander";
15294
- import chalk26 from "chalk";
15379
+ import { Command as Command20 } from "commander";
15380
+ import chalk27 from "chalk";
15295
15381
  import { config as loadEnv } from "dotenv";
15296
15382
 
15297
15383
  // src/commands/auth.ts
@@ -21500,12 +21586,21 @@ function isRecord(value) {
21500
21586
  function parseSandboxProvider(value) {
21501
21587
  if (!value) return void 0;
21502
21588
  const normalized = value.trim().toLowerCase();
21503
- if (normalized === "quickjs" || normalized === "daytona" || normalized === "cloudflare-worker")
21589
+ if (normalized === "quickjs" || normalized === "daytona" || normalized === "cloudflare-worker" || normalized === "cloudflare-shell")
21504
21590
  return normalized;
21505
21591
  return void 0;
21506
21592
  }
21507
21593
  function parseSandboxLanguage(provider, value) {
21508
21594
  if (provider === "quickjs" || provider === "cloudflare-worker") return "javascript";
21595
+ if (provider === "cloudflare-shell") {
21596
+ if (typeof value === "string") {
21597
+ const normalized = value.trim().toLowerCase();
21598
+ if (normalized === "javascript" || normalized === "typescript") {
21599
+ return normalized;
21600
+ }
21601
+ }
21602
+ return "javascript";
21603
+ }
21509
21604
  if (typeof value === "string") {
21510
21605
  const normalized = value.trim().toLowerCase();
21511
21606
  if (normalized === "javascript" || normalized === "typescript" || normalized === "python") {
@@ -21585,6 +21680,44 @@ function createSandboxInstructions(provider) {
21585
21680
  "return { sum, count: nums.length }"
21586
21681
  ].join("\n");
21587
21682
  }
21683
+ if (provider === "cloudflare-shell") {
21684
+ return [
21685
+ "--- Sandbox Tooling (Cloudflare Shell) ---",
21686
+ "You can execute JavaScript/TypeScript code with the local tool `run_sandbox_code`.",
21687
+ "Call shape:",
21688
+ '{ "code": "...", "parameters": { ... }, "language": "javascript|typescript", "timeoutMs": 30000 }',
21689
+ "Cloudflare Shell rules:",
21690
+ "1. Choose one language: javascript or typescript.",
21691
+ "2. TypeScript is fully supported with runtime compilation and npm dependency resolution.",
21692
+ "3. Inputs are passed via the `parameters` object (for example: `const x = parameters.x`).",
21693
+ "4. async/await and Promises are fully supported.",
21694
+ "5. The snippet is wrapped in an async function. Use top-level `return ...` to produce the result.",
21695
+ "6. Return JSON-serializable values (object, array, string, number, boolean, null).",
21696
+ "7. Helper functions are available under `helpers.*` namespace (e.g., `helpers.extractEmails(text)`).",
21697
+ "8. Persistent filesystem: `state.writeFile()`, `state.readFile()`, `state.glob()` are available for working with files.",
21698
+ "9. Files persist across multiple `run_sandbox_code` calls within the same sandbox.",
21699
+ "10. No Python support \u2014 use Daytona for Python workloads.",
21700
+ "11. No network access (fetch calls are blocked by default).",
21701
+ "Example:",
21702
+ "const nums = parameters.nums || []",
21703
+ "const sum = nums.reduce((acc: number, n: number) => acc + n, 0)",
21704
+ "return { sum, count: nums.length }",
21705
+ "",
21706
+ "--- Deploy with Preview (Cloudflare Shell) ---",
21707
+ "You also have `deploy_sandbox` to deploy a persistent web server and get a live preview URL.",
21708
+ "Call shape:",
21709
+ '{ "code": "...", "files": { "public/index.html": "..." }, "packageJson": "{\\"dependencies\\": {\\"hono\\": \\"^4.0.0\\"}}", "language": "typescript", "port": 3000 }',
21710
+ "Deploy rules:",
21711
+ "1. Use this when you need to run a web server (Hono, etc.) that the user can visit in their browser.",
21712
+ "2. The `code` is the main entry point file. The `packageJson` string provides npm dependencies.",
21713
+ "3. The `files` parameter writes additional files (path \u2192 content). Keys must be plain file paths.",
21714
+ "4. The code must export a fetch handler (Cloudflare Workers format): `export default { fetch(req) { ... } }`",
21715
+ "5. The sandbox is persistent \u2014 each sandbox has its own Durable Object with isolated state.",
21716
+ "6. The returned `previewUrl` is a REAL live URL (e.g., https://api.runtype.com/preview/{sandboxId}/) that the user can open in their browser.",
21717
+ "7. The sandbox persists for 2 hours after the last activity, then auto-cleans up.",
21718
+ "8. Prefer this over `run_sandbox_code` when building web apps, APIs, or anything with a UI."
21719
+ ].join("\n");
21720
+ }
21588
21721
  return [
21589
21722
  "--- Sandbox Tooling (Daytona) ---",
21590
21723
  "You can execute code snippets with the local tool `run_sandbox_code`.",
@@ -21614,7 +21747,7 @@ function createSandboxInstructions(provider) {
21614
21747
  }
21615
21748
  function createSandboxLocalTool(client, provider, debugMode) {
21616
21749
  return {
21617
- description: provider === "cloudflare-worker" ? "Execute JavaScript code in Cloudflare Worker sandbox. Async/await supported. Inputs are passed via parameters object." : provider === "quickjs" ? "Execute JavaScript code in QuickJS sandbox (legacy). Inputs are passed via parameters object." : "Execute JavaScript/TypeScript/Python code in Daytona sandbox. Inputs are injected as top-level variables.",
21750
+ description: provider === "cloudflare-worker" ? "Execute JavaScript code in Cloudflare Worker sandbox. Async/await supported. Inputs are passed via parameters object." : provider === "quickjs" ? "Execute JavaScript code in QuickJS sandbox (legacy). Inputs are passed via parameters object." : provider === "cloudflare-shell" ? "Execute JavaScript/TypeScript code in Cloudflare Shell sandbox. TypeScript and npm dependencies supported. Inputs are passed via parameters object." : "Execute JavaScript/TypeScript/Python code in Daytona sandbox. Inputs are injected as top-level variables.",
21618
21751
  parametersSchema: {
21619
21752
  type: "object",
21620
21753
  properties: {
@@ -21625,8 +21758,8 @@ function createSandboxLocalTool(client, provider, debugMode) {
21625
21758
  },
21626
21759
  language: {
21627
21760
  type: "string",
21628
- enum: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : ["javascript", "typescript", "python"],
21629
- description: provider === "quickjs" ? "QuickJS only accepts javascript" : provider === "cloudflare-worker" ? "Cloudflare Worker only accepts javascript" : "Daytona code language"
21761
+ enum: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : provider === "cloudflare-shell" ? ["javascript", "typescript"] : ["javascript", "typescript", "python"],
21762
+ description: provider === "quickjs" ? "QuickJS only accepts javascript" : provider === "cloudflare-worker" ? "Cloudflare Worker only accepts javascript" : provider === "cloudflare-shell" ? "Cloudflare Shell accepts javascript or typescript" : "Daytona code language"
21630
21763
  },
21631
21764
  timeoutMs: { type: "number", description: "Execution timeout in ms (max 30000)" }
21632
21765
  },
@@ -21657,7 +21790,7 @@ function createSandboxLocalTool(client, provider, debugMode) {
21657
21790
  {
21658
21791
  allowedToolTypes: ["custom"],
21659
21792
  allowedSandboxProviders: [provider],
21660
- allowedLanguages: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : ["javascript", "typescript", "python"],
21793
+ allowedLanguages: provider === "quickjs" || provider === "cloudflare-worker" ? ["javascript"] : provider === "cloudflare-shell" ? ["javascript", "typescript"] : ["javascript", "typescript", "python"],
21661
21794
  maxTimeoutMs: 3e4,
21662
21795
  maxCodeLength: 12e3
21663
21796
  }
@@ -21819,6 +21952,84 @@ function createDeploySandboxLocalTool(client, debugMode) {
21819
21952
  }
21820
21953
  };
21821
21954
  }
21955
+ var activeCfShellWorkerId;
21956
+ function createDeployCfShellLocalTool(client, debugMode) {
21957
+ return {
21958
+ description: "Deploy code to a persistent Cloudflare Shell Dynamic Worker and get a live preview URL. Use this to run web servers, APIs, or UIs that the user can visit in their browser. Supports JavaScript and TypeScript with npm dependencies.",
21959
+ parametersSchema: {
21960
+ type: "object",
21961
+ properties: {
21962
+ code: { type: "string", description: "Code to deploy (main entry point file)" },
21963
+ packageJson: {
21964
+ type: "object",
21965
+ description: 'package.json content as a JSON object, e.g. { "dependencies": { "hono": "^4.0.0" } }'
21966
+ },
21967
+ language: {
21968
+ type: "string",
21969
+ enum: ["javascript", "typescript"],
21970
+ description: "Language of the code (default: typescript)"
21971
+ },
21972
+ port: {
21973
+ type: "number",
21974
+ description: "Port the server listens on (default: 3000)"
21975
+ },
21976
+ files: {
21977
+ type: "object",
21978
+ description: 'Additional files to write (path \u2192 content), e.g. { "public/index.html": "<html>..." }. Keys must be plain file paths. Use this for multi-file projects.',
21979
+ additionalProperties: { type: "string" }
21980
+ }
21981
+ },
21982
+ required: ["code"]
21983
+ },
21984
+ execute: async (args) => {
21985
+ const code = typeof args.code === "string" ? args.code : "";
21986
+ if (!code.trim()) {
21987
+ return { success: false, error: "code is required" };
21988
+ }
21989
+ const request = {
21990
+ code,
21991
+ ...args.packageJson && typeof args.packageJson === "object" ? { packageJson: JSON.stringify(args.packageJson) } : typeof args.packageJson === "string" ? { packageJson: args.packageJson } : {},
21992
+ ...typeof args.language === "string" ? { language: args.language } : {},
21993
+ ...typeof args.port === "number" ? { port: args.port } : {},
21994
+ ...args.files && typeof args.files === "object" && !Array.isArray(args.files) ? { files: args.files } : {},
21995
+ // Reuse existing worker if one was created
21996
+ ...activeCfShellWorkerId ? { workerId: activeCfShellWorkerId } : {}
21997
+ };
21998
+ try {
21999
+ const result = await client.tools.deployCfShell(request);
22000
+ if (result.workerId) {
22001
+ activeCfShellWorkerId = result.workerId;
22002
+ }
22003
+ if (result.previewUrl) {
22004
+ activeDeploySandboxPreviewUrl = result.previewUrl;
22005
+ }
22006
+ if (debugMode) {
22007
+ console.log(
22008
+ chalk11.gray(
22009
+ ` [deploy_cf_shell] ${result.status} \u2014 ${result.previewUrl || "no preview URL"}`
22010
+ )
22011
+ );
22012
+ }
22013
+ return {
22014
+ success: result.status === "running",
22015
+ workerId: result.workerId,
22016
+ previewUrl: result.previewUrl,
22017
+ output: result.output,
22018
+ ...result.error ? { error: result.error } : {}
22019
+ };
22020
+ } catch (error) {
22021
+ const message = error instanceof Error ? error.message : String(error);
22022
+ if (debugMode) {
22023
+ console.log(chalk11.gray(` [deploy_cf_shell] error: ${message}`));
22024
+ }
22025
+ return {
22026
+ success: false,
22027
+ error: message
22028
+ };
22029
+ }
22030
+ }
22031
+ };
22032
+ }
21822
22033
 
21823
22034
  // src/marathon/event-log.ts
21824
22035
  import * as fs3 from "fs";
@@ -27312,6 +27523,8 @@ function buildLocalTools(client, sandboxProvider, options, context) {
27312
27523
  enabledTools.run_sandbox_code = createSandboxLocalTool(client, sandboxProvider, options.debug);
27313
27524
  if (sandboxProvider === "daytona") {
27314
27525
  enabledTools.deploy_sandbox = createDeploySandboxLocalTool(client, options.debug);
27526
+ } else if (sandboxProvider === "cloudflare-shell") {
27527
+ enabledTools.deploy_sandbox = createDeployCfShellLocalTool(client, options.debug);
27315
27528
  }
27316
27529
  }
27317
27530
  return Object.keys(enabledTools).length > 0 ? enabledTools : void 0;
@@ -31044,14 +31257,439 @@ apiKeysCommand.command("analytics").description("Show API key usage analytics").
31044
31257
  await waitUntilExit();
31045
31258
  });
31046
31259
 
31047
- // src/commands/analytics.ts
31260
+ // src/commands/client-tokens.ts
31048
31261
  import { Command as Command16 } from "commander";
31049
31262
  import chalk22 from "chalk";
31050
31263
  import React15 from "react";
31051
31264
  import { render as render15 } from "ink";
31052
31265
  import { useState as useState29, useEffect as useEffect26 } from "react";
31053
31266
  import { Text as Text32 } from "ink";
31054
- var analyticsCommand = new Command16("analytics").description("View analytics and execution results");
31267
+ var clientTokensCommand = new Command16("client-tokens").description(
31268
+ "Manage client tokens for Persona widget embedding"
31269
+ );
31270
+ clientTokensCommand.command("list").description("List your client tokens").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
31271
+ const apiKey = await ensureAuth();
31272
+ if (!apiKey) return;
31273
+ const client = new ApiClient(apiKey);
31274
+ if (!isTTY(options) || options.json) {
31275
+ try {
31276
+ const data = await client.get("/client-tokens");
31277
+ const tokens = data.clientTokens ?? [];
31278
+ if (options.json) {
31279
+ printJson(data);
31280
+ } else {
31281
+ if (tokens.length === 0) {
31282
+ console.log(chalk22.gray("No client tokens found"));
31283
+ return;
31284
+ }
31285
+ console.log(chalk22.cyan("Your Client Tokens:"));
31286
+ for (const token of tokens) {
31287
+ const env = token.environment === "live" ? chalk22.green("live") : chalk22.yellow("test");
31288
+ const active = token.isActive ? "" : chalk22.red(" (inactive)");
31289
+ const origins = chalk22.gray(` origins: ${(token.allowedOrigins || []).join(", ")}`);
31290
+ console.log(` ${chalk22.green(token.id)} ${token.name} [${env}]${active}${origins}`);
31291
+ }
31292
+ console.log(chalk22.dim(`
31293
+ Total: ${tokens.length} tokens`));
31294
+ }
31295
+ } catch (error) {
31296
+ const message = error instanceof Error ? error.message : "Unknown error";
31297
+ console.error(chalk22.red("Failed to fetch client tokens"));
31298
+ console.error(chalk22.red(message));
31299
+ process.exit(1);
31300
+ }
31301
+ return;
31302
+ }
31303
+ const App = () => {
31304
+ const [loading, setLoading] = useState29(true);
31305
+ const [items, setItems] = useState29(null);
31306
+ const [total, setTotal] = useState29(void 0);
31307
+ const [error, setError] = useState29(null);
31308
+ useEffect26(() => {
31309
+ const run = async () => {
31310
+ try {
31311
+ const data = await client.get("/client-tokens");
31312
+ const tokens = data.clientTokens ?? [];
31313
+ setItems(tokens);
31314
+ setTotal(tokens.length);
31315
+ setLoading(false);
31316
+ } catch (err) {
31317
+ setError(err instanceof Error ? err : new Error(String(err)));
31318
+ setLoading(false);
31319
+ }
31320
+ };
31321
+ run();
31322
+ }, []);
31323
+ return React15.createElement(DataList, {
31324
+ title: "Your Client Tokens",
31325
+ items,
31326
+ error,
31327
+ loading,
31328
+ total,
31329
+ emptyMessage: "No client tokens found",
31330
+ renderCard: (item) => {
31331
+ const t = item;
31332
+ const env = t.environment === "live" ? "live" : "test";
31333
+ const active = t.isActive ? "" : " (inactive)";
31334
+ return React15.createElement(Text32, null, ` ${t.id} ${t.name} [${env}]${active}`);
31335
+ }
31336
+ });
31337
+ };
31338
+ const { waitUntilExit } = render15(React15.createElement(App));
31339
+ await waitUntilExit();
31340
+ });
31341
+ clientTokensCommand.command("get <id>").description("Get client token details").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
31342
+ const apiKey = await ensureAuth();
31343
+ if (!apiKey) return;
31344
+ const client = new ApiClient(apiKey);
31345
+ if (!isTTY(options) || options.json) {
31346
+ try {
31347
+ const data = await client.get(`/client-tokens/${id}`);
31348
+ const token = data.clientToken;
31349
+ if (options.json) {
31350
+ printJson(data);
31351
+ } else {
31352
+ printDetail("Client Token", [
31353
+ { label: "ID", value: token.id },
31354
+ { label: "Name", value: token.name },
31355
+ { label: "Environment", value: token.environment },
31356
+ { label: "Active", value: token.isActive },
31357
+ { label: "Token Value", value: token.tokenValue },
31358
+ { label: "Flow IDs", value: (token.flowIds || []).join(", ") || null },
31359
+ { label: "Default Flow ID", value: token.defaultFlowId },
31360
+ { label: "Agent IDs", value: (token.agentIds || []).join(", ") || null },
31361
+ { label: "Allowed Origins", value: (token.allowedOrigins || []).join(", ") },
31362
+ { label: "Rate Limit/min", value: token.rateLimitPerMinute },
31363
+ { label: "Rate Limit/hr", value: token.rateLimitPerHour },
31364
+ { label: "Max Messages/Session", value: token.maxMessagesPerSession },
31365
+ { label: "Session Timeout (min)", value: token.sessionIdleTimeoutMinutes },
31366
+ { label: "Conversations", value: token.conversationCount },
31367
+ { label: "Last Used", value: token.lastUsedAt },
31368
+ { label: "Created", value: token.createdAt }
31369
+ ]);
31370
+ }
31371
+ } catch (error) {
31372
+ const message = error instanceof Error ? error.message : "Unknown error";
31373
+ console.error(chalk22.red("Failed to fetch client token"));
31374
+ console.error(chalk22.red(message));
31375
+ process.exit(1);
31376
+ }
31377
+ return;
31378
+ }
31379
+ const App = () => {
31380
+ const [loading, setLoading] = useState29(true);
31381
+ const [success, setSuccess] = useState29(null);
31382
+ const [error, setError] = useState29(null);
31383
+ const [resultNode, setResultNode] = useState29(void 0);
31384
+ useEffect26(() => {
31385
+ const run = async () => {
31386
+ try {
31387
+ const data = await client.get(
31388
+ `/client-tokens/${id}`
31389
+ );
31390
+ const token = data.clientToken;
31391
+ setResultNode(
31392
+ React15.createElement(EntityCard, {
31393
+ fields: [
31394
+ { label: "ID", value: token.id },
31395
+ { label: "Name", value: token.name },
31396
+ { label: "Environment", value: token.environment },
31397
+ { label: "Active", value: String(token.isActive) },
31398
+ { label: "Token Value", value: token.tokenValue },
31399
+ { label: "Flow IDs", value: (token.flowIds || []).join(", ") || null },
31400
+ { label: "Agent IDs", value: (token.agentIds || []).join(", ") || null },
31401
+ { label: "Allowed Origins", value: (token.allowedOrigins || []).join(", ") },
31402
+ { label: "Last Used", value: token.lastUsedAt },
31403
+ { label: "Created", value: token.createdAt }
31404
+ ]
31405
+ })
31406
+ );
31407
+ setSuccess(true);
31408
+ setLoading(false);
31409
+ } catch (err) {
31410
+ setError(err instanceof Error ? err : new Error(String(err)));
31411
+ setSuccess(false);
31412
+ setLoading(false);
31413
+ }
31414
+ };
31415
+ run();
31416
+ }, []);
31417
+ return React15.createElement(MutationResult, {
31418
+ loading,
31419
+ loadingLabel: "Fetching client token...",
31420
+ success,
31421
+ successMessage: "Client Token",
31422
+ error,
31423
+ result: resultNode
31424
+ });
31425
+ };
31426
+ const { waitUntilExit } = render15(React15.createElement(App));
31427
+ await waitUntilExit();
31428
+ });
31429
+ clientTokensCommand.command("create").description("Create a new client token").requiredOption("-n, --name <name>", "Token name").option("--origins <origins...>", "Allowed origins (e.g. https://example.com). Defaults to * (all origins)").option("--environment <env>", "Token environment: test or live", "test").option("--flow-ids <ids...>", "Flow IDs to associate").option("--default-flow-id <id>", "Default flow ID (required when flow-ids provided)").option("--agent-ids <ids...>", "Agent IDs to associate").option("--rate-limit-per-minute <n>", "Rate limit per minute", "10").option("--rate-limit-per-hour <n>", "Rate limit per hour", "100").option("--max-messages <n>", "Max messages per session", "100").option("--session-timeout <n>", "Session idle timeout in minutes", "30").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
31430
+ async (options) => {
31431
+ const flowIds = options.flowIds || [];
31432
+ const agentIds = options.agentIds || [];
31433
+ if (flowIds.length === 0 && agentIds.length === 0) {
31434
+ console.error(chalk22.red("Error: At least one --flow-ids or --agent-ids is required"));
31435
+ process.exit(1);
31436
+ }
31437
+ if (flowIds.length > 0 && !options.defaultFlowId) {
31438
+ console.error(chalk22.red("Error: --default-flow-id is required when --flow-ids is provided"));
31439
+ process.exit(1);
31440
+ }
31441
+ if (!["test", "live"].includes(options.environment)) {
31442
+ console.error(chalk22.red('Error: --environment must be "test" or "live"'));
31443
+ process.exit(1);
31444
+ }
31445
+ const apiKey = await ensureAuth();
31446
+ if (!apiKey) return;
31447
+ const client = new ApiClient(apiKey);
31448
+ const body = {
31449
+ name: options.name,
31450
+ flowIds,
31451
+ defaultFlowId: options.defaultFlowId,
31452
+ agentIds,
31453
+ allowedOrigins: options.origins || ["*"],
31454
+ environment: options.environment,
31455
+ rateLimitPerMinute: parseInt(options.rateLimitPerMinute, 10),
31456
+ rateLimitPerHour: parseInt(options.rateLimitPerHour, 10),
31457
+ maxMessagesPerSession: parseInt(options.maxMessages, 10),
31458
+ sessionIdleTimeoutMinutes: parseInt(options.sessionTimeout, 10)
31459
+ };
31460
+ if (!isTTY(options) || options.json) {
31461
+ try {
31462
+ const data = await client.post("/client-tokens", body);
31463
+ if (options.json) {
31464
+ printJson(data);
31465
+ } else {
31466
+ const token = data.clientToken;
31467
+ console.log(chalk22.green("Client token created"));
31468
+ console.log(` ID: ${chalk22.green(token.id)}`);
31469
+ console.log(` Name: ${token.name}`);
31470
+ console.log(` Environment: ${token.environment}`);
31471
+ console.log(` Token: ${chalk22.yellow(data.token)}`);
31472
+ if (data.warnings?.length > 0) {
31473
+ console.log("");
31474
+ for (const w of data.warnings) {
31475
+ console.log(chalk22.yellow(` \u26A0 ${w.message}`));
31476
+ }
31477
+ }
31478
+ }
31479
+ } catch (error) {
31480
+ const message = error instanceof Error ? error.message : "Unknown error";
31481
+ console.error(chalk22.red("Failed to create client token"));
31482
+ console.error(chalk22.red(message));
31483
+ process.exit(1);
31484
+ }
31485
+ return;
31486
+ }
31487
+ const App = () => {
31488
+ const [loading, setLoading] = useState29(true);
31489
+ const [success, setSuccess] = useState29(null);
31490
+ const [error, setError] = useState29(null);
31491
+ const [resultNode, setResultNode] = useState29(void 0);
31492
+ useEffect26(() => {
31493
+ const run = async () => {
31494
+ try {
31495
+ const data = await client.post("/client-tokens", body);
31496
+ const fields = [
31497
+ { label: "ID", value: data.clientToken.id, color: "green" },
31498
+ { label: "Name", value: data.clientToken.name },
31499
+ { label: "Environment", value: data.clientToken.environment },
31500
+ { label: "Token", value: data.token, color: "yellow" }
31501
+ ];
31502
+ if (data.warnings?.length > 0) {
31503
+ for (const w of data.warnings) {
31504
+ fields.push({ label: "Warning", value: w.message, color: "yellow" });
31505
+ }
31506
+ }
31507
+ setResultNode(React15.createElement(EntityCard, { fields }));
31508
+ setSuccess(true);
31509
+ setLoading(false);
31510
+ } catch (err) {
31511
+ setError(err instanceof Error ? err : new Error(String(err)));
31512
+ setSuccess(false);
31513
+ setLoading(false);
31514
+ }
31515
+ };
31516
+ run();
31517
+ }, []);
31518
+ return React15.createElement(MutationResult, {
31519
+ loading,
31520
+ loadingLabel: "Creating client token...",
31521
+ success,
31522
+ successMessage: "Client token created",
31523
+ error,
31524
+ result: resultNode
31525
+ });
31526
+ };
31527
+ const { waitUntilExit } = render15(React15.createElement(App));
31528
+ await waitUntilExit();
31529
+ }
31530
+ );
31531
+ clientTokensCommand.command("delete <id>").description("Delete a client token").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").option("--yes", "Skip confirmation").action(async (id, options) => {
31532
+ const apiKey = await ensureAuth();
31533
+ if (!apiKey) return;
31534
+ const client = new ApiClient(apiKey);
31535
+ if (!isTTY(options)) {
31536
+ try {
31537
+ await client.delete(`/client-tokens/${id}`);
31538
+ console.log(chalk22.green("Client token deleted"));
31539
+ } catch (error) {
31540
+ const message = error instanceof Error ? error.message : "Unknown error";
31541
+ console.error(chalk22.red("Failed to delete client token"));
31542
+ console.error(chalk22.red(message));
31543
+ process.exit(1);
31544
+ }
31545
+ return;
31546
+ }
31547
+ if (options.yes) {
31548
+ const App = () => {
31549
+ const [loading, setLoading] = useState29(true);
31550
+ const [success, setSuccess] = useState29(null);
31551
+ const [error, setError] = useState29(null);
31552
+ useEffect26(() => {
31553
+ const run = async () => {
31554
+ try {
31555
+ await client.delete(`/client-tokens/${id}`);
31556
+ setSuccess(true);
31557
+ setLoading(false);
31558
+ } catch (err) {
31559
+ setError(err instanceof Error ? err : new Error(String(err)));
31560
+ setSuccess(false);
31561
+ setLoading(false);
31562
+ }
31563
+ };
31564
+ run();
31565
+ }, []);
31566
+ return React15.createElement(MutationResult, {
31567
+ loading,
31568
+ loadingLabel: "Deleting client token...",
31569
+ success,
31570
+ successMessage: "Client token deleted",
31571
+ error
31572
+ });
31573
+ };
31574
+ const { waitUntilExit: waitUntilExit2 } = render15(React15.createElement(App));
31575
+ await waitUntilExit2();
31576
+ return;
31577
+ }
31578
+ const confirmed = await new Promise((resolve8) => {
31579
+ const { unmount } = render15(
31580
+ React15.createElement(ConfirmPrompt, {
31581
+ message: `Delete client token ${id}?`,
31582
+ defaultValue: false,
31583
+ onConfirm: (result) => {
31584
+ resolve8(result);
31585
+ unmount();
31586
+ }
31587
+ })
31588
+ );
31589
+ });
31590
+ if (!confirmed) return;
31591
+ const DeleteApp = () => {
31592
+ const [loading, setLoading] = useState29(true);
31593
+ const [success, setSuccess] = useState29(null);
31594
+ const [error, setError] = useState29(null);
31595
+ useEffect26(() => {
31596
+ const run = async () => {
31597
+ try {
31598
+ await client.delete(`/client-tokens/${id}`);
31599
+ setSuccess(true);
31600
+ setLoading(false);
31601
+ } catch (err) {
31602
+ setError(err instanceof Error ? err : new Error(String(err)));
31603
+ setSuccess(false);
31604
+ setLoading(false);
31605
+ }
31606
+ };
31607
+ run();
31608
+ }, []);
31609
+ return React15.createElement(MutationResult, {
31610
+ loading,
31611
+ loadingLabel: "Deleting client token...",
31612
+ success,
31613
+ successMessage: "Client token deleted",
31614
+ error
31615
+ });
31616
+ };
31617
+ const { waitUntilExit } = render15(React15.createElement(DeleteApp));
31618
+ await waitUntilExit();
31619
+ });
31620
+ clientTokensCommand.command("regenerate <id>").description("Regenerate a client token (invalidates the old token)").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
31621
+ const apiKey = await ensureAuth();
31622
+ if (!apiKey) return;
31623
+ const client = new ApiClient(apiKey);
31624
+ if (!isTTY(options) || options.json) {
31625
+ try {
31626
+ const data = await client.post(`/client-tokens/${id}/regenerate`);
31627
+ if (options.json) {
31628
+ printJson(data);
31629
+ } else {
31630
+ console.log(chalk22.green("Client token regenerated"));
31631
+ console.log(` New Token: ${chalk22.yellow(data.token)}`);
31632
+ console.log(chalk22.gray(" Previous token is now invalid. Update your client-side code."));
31633
+ }
31634
+ } catch (error) {
31635
+ const message = error instanceof Error ? error.message : "Unknown error";
31636
+ console.error(chalk22.red("Failed to regenerate client token"));
31637
+ console.error(chalk22.red(message));
31638
+ process.exit(1);
31639
+ }
31640
+ return;
31641
+ }
31642
+ const App = () => {
31643
+ const [loading, setLoading] = useState29(true);
31644
+ const [success, setSuccess] = useState29(null);
31645
+ const [error, setError] = useState29(null);
31646
+ const [resultNode, setResultNode] = useState29(void 0);
31647
+ useEffect26(() => {
31648
+ const run = async () => {
31649
+ try {
31650
+ const data = await client.post(`/client-tokens/${id}/regenerate`);
31651
+ setResultNode(
31652
+ React15.createElement(EntityCard, {
31653
+ fields: [
31654
+ { label: "New Token", value: data.token, color: "yellow" },
31655
+ {
31656
+ label: "Note",
31657
+ value: "Previous token is now invalid. Update your client-side code."
31658
+ }
31659
+ ]
31660
+ })
31661
+ );
31662
+ setSuccess(true);
31663
+ setLoading(false);
31664
+ } catch (err) {
31665
+ setError(err instanceof Error ? err : new Error(String(err)));
31666
+ setSuccess(false);
31667
+ setLoading(false);
31668
+ }
31669
+ };
31670
+ run();
31671
+ }, []);
31672
+ return React15.createElement(MutationResult, {
31673
+ loading,
31674
+ loadingLabel: "Regenerating client token...",
31675
+ success,
31676
+ successMessage: "Client token regenerated",
31677
+ error,
31678
+ result: resultNode
31679
+ });
31680
+ };
31681
+ const { waitUntilExit } = render15(React15.createElement(App));
31682
+ await waitUntilExit();
31683
+ });
31684
+
31685
+ // src/commands/analytics.ts
31686
+ import { Command as Command17 } from "commander";
31687
+ import chalk23 from "chalk";
31688
+ import React16 from "react";
31689
+ import { render as render16 } from "ink";
31690
+ import { useState as useState30, useEffect as useEffect27 } from "react";
31691
+ import { Text as Text33 } from "ink";
31692
+ var analyticsCommand = new Command17("analytics").description("View analytics and execution results");
31055
31693
  analyticsCommand.command("stats").description("Show account statistics").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
31056
31694
  const apiKey = await ensureAuth();
31057
31695
  if (!apiKey) return;
@@ -31071,22 +31709,22 @@ analyticsCommand.command("stats").description("Show account statistics").option(
31071
31709
  }
31072
31710
  } catch (error) {
31073
31711
  const message = error instanceof Error ? error.message : "Unknown error";
31074
- console.error(chalk22.red("Failed to fetch stats"));
31075
- console.error(chalk22.red(message));
31712
+ console.error(chalk23.red("Failed to fetch stats"));
31713
+ console.error(chalk23.red(message));
31076
31714
  process.exit(1);
31077
31715
  }
31078
31716
  return;
31079
31717
  }
31080
31718
  const App = () => {
31081
- const [loading, setLoading] = useState29(true);
31082
- const [success, setSuccess] = useState29(null);
31083
- const [error, setError] = useState29(null);
31084
- const [resultNode, setResultNode] = useState29(void 0);
31085
- useEffect26(() => {
31719
+ const [loading, setLoading] = useState30(true);
31720
+ const [success, setSuccess] = useState30(null);
31721
+ const [error, setError] = useState30(null);
31722
+ const [resultNode, setResultNode] = useState30(void 0);
31723
+ useEffect27(() => {
31086
31724
  const run = async () => {
31087
31725
  try {
31088
31726
  const data = await client.get("/analytics/stats");
31089
- setResultNode(React15.createElement(EntityCard, {
31727
+ setResultNode(React16.createElement(EntityCard, {
31090
31728
  fields: [
31091
31729
  { label: "Flows", value: data.flows },
31092
31730
  { label: "Prompts", value: data.prompts },
@@ -31104,7 +31742,7 @@ analyticsCommand.command("stats").description("Show account statistics").option(
31104
31742
  };
31105
31743
  run();
31106
31744
  }, []);
31107
- return React15.createElement(MutationResult, {
31745
+ return React16.createElement(MutationResult, {
31108
31746
  loading,
31109
31747
  loadingLabel: "Fetching stats...",
31110
31748
  success,
@@ -31113,7 +31751,7 @@ analyticsCommand.command("stats").description("Show account statistics").option(
31113
31751
  result: resultNode
31114
31752
  });
31115
31753
  };
31116
- const { waitUntilExit } = render15(React15.createElement(App));
31754
+ const { waitUntilExit } = render16(React16.createElement(App));
31117
31755
  await waitUntilExit();
31118
31756
  });
31119
31757
  analyticsCommand.command("results").description("List execution results").option("--flow <id>", "Filter by flow ID").option("--record <id>", "Filter by record ID").option("--status <status>", "Filter by status").option("--limit <n>", "Limit results", "20").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
@@ -31136,37 +31774,37 @@ analyticsCommand.command("results").description("List execution results").option
31136
31774
  } else {
31137
31775
  const results = data.data ?? [];
31138
31776
  if (results.length === 0) {
31139
- console.log(chalk22.gray("No results found"));
31777
+ console.log(chalk23.gray("No results found"));
31140
31778
  return;
31141
31779
  }
31142
- console.log(chalk22.cyan("Execution Results:"));
31780
+ console.log(chalk23.cyan("Execution Results:"));
31143
31781
  for (const result of results) {
31144
31782
  const statusColor = result.status === "completed" ? "green" : "red";
31145
- const date = result.createdAt ? chalk22.gray(` ${result.createdAt}`) : "";
31783
+ const date = result.createdAt ? chalk23.gray(` ${result.createdAt}`) : "";
31146
31784
  console.log(
31147
- ` ${chalk22.green(result.id)} ${chalk22[statusColor](`[${result.status}]`)} flow=${chalk22.gray(result.flowId)} record=${chalk22.gray(result.recordId)}${date}`
31785
+ ` ${chalk23.green(result.id)} ${chalk23[statusColor](`[${result.status}]`)} flow=${chalk23.gray(result.flowId)} record=${chalk23.gray(result.recordId)}${date}`
31148
31786
  );
31149
31787
  }
31150
31788
  const total = getTotalCount(data.pagination);
31151
31789
  if (total !== void 0) {
31152
- console.log(chalk22.dim(`
31790
+ console.log(chalk23.dim(`
31153
31791
  Total: ${total} results`));
31154
31792
  }
31155
31793
  }
31156
31794
  } catch (error) {
31157
31795
  const message = error instanceof Error ? error.message : "Unknown error";
31158
- console.error(chalk22.red("Failed to fetch results"));
31159
- console.error(chalk22.red(message));
31796
+ console.error(chalk23.red("Failed to fetch results"));
31797
+ console.error(chalk23.red(message));
31160
31798
  process.exit(1);
31161
31799
  }
31162
31800
  return;
31163
31801
  }
31164
31802
  const App = () => {
31165
- const [loading, setLoading] = useState29(true);
31166
- const [items, setItems] = useState29(null);
31167
- const [total, setTotal] = useState29(void 0);
31168
- const [error, setError] = useState29(null);
31169
- useEffect26(() => {
31803
+ const [loading, setLoading] = useState30(true);
31804
+ const [items, setItems] = useState30(null);
31805
+ const [total, setTotal] = useState30(void 0);
31806
+ const [error, setError] = useState30(null);
31807
+ useEffect27(() => {
31170
31808
  const run = async () => {
31171
31809
  try {
31172
31810
  const data = await client.get(
@@ -31183,7 +31821,7 @@ analyticsCommand.command("results").description("List execution results").option
31183
31821
  };
31184
31822
  run();
31185
31823
  }, []);
31186
- return React15.createElement(DataList, {
31824
+ return React16.createElement(DataList, {
31187
31825
  title: "Execution Results",
31188
31826
  items,
31189
31827
  error,
@@ -31193,27 +31831,27 @@ analyticsCommand.command("results").description("List execution results").option
31193
31831
  renderCard: (item) => {
31194
31832
  const r = item;
31195
31833
  const statusColor = r.status === "completed" ? "green" : "red";
31196
- return React15.createElement(
31197
- Text32,
31834
+ return React16.createElement(
31835
+ Text33,
31198
31836
  { color: statusColor },
31199
31837
  ` ${r.id} [${r.status}] flow=${r.flowId} record=${r.recordId}${r.createdAt ? ` ${r.createdAt}` : ""}`
31200
31838
  );
31201
31839
  }
31202
31840
  });
31203
31841
  };
31204
- const { waitUntilExit } = render15(React15.createElement(App));
31842
+ const { waitUntilExit } = render16(React16.createElement(App));
31205
31843
  await waitUntilExit();
31206
31844
  }
31207
31845
  );
31208
31846
 
31209
31847
  // src/commands/billing.ts
31210
- import { Command as Command17 } from "commander";
31211
- import chalk23 from "chalk";
31212
- import React16 from "react";
31213
- import { render as render16 } from "ink";
31214
- import { useState as useState30, useEffect as useEffect27 } from "react";
31848
+ import { Command as Command18 } from "commander";
31849
+ import chalk24 from "chalk";
31850
+ import React17 from "react";
31851
+ import { render as render17 } from "ink";
31852
+ import { useState as useState31, useEffect as useEffect28 } from "react";
31215
31853
  import open5 from "open";
31216
- var billingCommand = new Command17("billing").description("View billing and subscription info");
31854
+ var billingCommand = new Command18("billing").description("View billing and subscription info");
31217
31855
  billingCommand.command("status").description("Show current plan and usage").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
31218
31856
  const apiKey = await ensureAuth();
31219
31857
  if (!apiKey) return;
@@ -31250,18 +31888,18 @@ billingCommand.command("status").description("Show current plan and usage").opti
31250
31888
  }
31251
31889
  } catch (error) {
31252
31890
  const message = error instanceof Error ? error.message : "Unknown error";
31253
- console.error(chalk23.red("Failed to fetch billing status"));
31254
- console.error(chalk23.red(message));
31891
+ console.error(chalk24.red("Failed to fetch billing status"));
31892
+ console.error(chalk24.red(message));
31255
31893
  process.exit(1);
31256
31894
  }
31257
31895
  return;
31258
31896
  }
31259
31897
  const App = () => {
31260
- const [loading, setLoading] = useState30(true);
31261
- const [success, setSuccess] = useState30(null);
31262
- const [error, setError] = useState30(null);
31263
- const [resultNode, setResultNode] = useState30(void 0);
31264
- useEffect27(() => {
31898
+ const [loading, setLoading] = useState31(true);
31899
+ const [success, setSuccess] = useState31(null);
31900
+ const [error, setError] = useState31(null);
31901
+ const [resultNode, setResultNode] = useState31(void 0);
31902
+ useEffect28(() => {
31265
31903
  const run = async () => {
31266
31904
  try {
31267
31905
  const data = await client.get("/billing/status");
@@ -31282,7 +31920,7 @@ billingCommand.command("status").description("Show current plan and usage").opti
31282
31920
  if (data.limits.monthlyLimit) fields.push({ label: "Monthly limit", value: data.limits.monthlyLimit });
31283
31921
  if (data.limits.rateLimit) fields.push({ label: "Rate limit", value: data.limits.rateLimit });
31284
31922
  }
31285
- setResultNode(React16.createElement(EntityCard, { fields }));
31923
+ setResultNode(React17.createElement(EntityCard, { fields }));
31286
31924
  setSuccess(true);
31287
31925
  setLoading(false);
31288
31926
  } catch (err) {
@@ -31293,7 +31931,7 @@ billingCommand.command("status").description("Show current plan and usage").opti
31293
31931
  };
31294
31932
  run();
31295
31933
  }, []);
31296
- return React16.createElement(MutationResult, {
31934
+ return React17.createElement(MutationResult, {
31297
31935
  loading,
31298
31936
  loadingLabel: "Fetching billing status...",
31299
31937
  success,
@@ -31302,7 +31940,7 @@ billingCommand.command("status").description("Show current plan and usage").opti
31302
31940
  result: resultNode
31303
31941
  });
31304
31942
  };
31305
- const { waitUntilExit } = render16(React16.createElement(App));
31943
+ const { waitUntilExit } = render17(React17.createElement(App));
31306
31944
  await waitUntilExit();
31307
31945
  });
31308
31946
  billingCommand.command("portal").description("Open the billing portal in your browser").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
@@ -31321,18 +31959,18 @@ billingCommand.command("portal").description("Open the billing portal in your br
31321
31959
  }
31322
31960
  } catch (error) {
31323
31961
  const message = error instanceof Error ? error.message : "Unknown error";
31324
- console.error(chalk23.red("Failed to open billing portal"));
31325
- console.error(chalk23.red(message));
31962
+ console.error(chalk24.red("Failed to open billing portal"));
31963
+ console.error(chalk24.red(message));
31326
31964
  process.exit(1);
31327
31965
  }
31328
31966
  return;
31329
31967
  }
31330
31968
  const App = () => {
31331
- const [loading, setLoading] = useState30(true);
31332
- const [success, setSuccess] = useState30(null);
31333
- const [error, setError] = useState30(null);
31334
- const [msg, setMsg] = useState30("Opening billing portal...");
31335
- useEffect27(() => {
31969
+ const [loading, setLoading] = useState31(true);
31970
+ const [success, setSuccess] = useState31(null);
31971
+ const [error, setError] = useState31(null);
31972
+ const [msg, setMsg] = useState31("Opening billing portal...");
31973
+ useEffect28(() => {
31336
31974
  const run = async () => {
31337
31975
  try {
31338
31976
  const data = await client.post("/billing/portal");
@@ -31353,7 +31991,7 @@ billingCommand.command("portal").description("Open the billing portal in your br
31353
31991
  };
31354
31992
  run();
31355
31993
  }, []);
31356
- return React16.createElement(MutationResult, {
31994
+ return React17.createElement(MutationResult, {
31357
31995
  loading,
31358
31996
  loadingLabel: "Generating portal link...",
31359
31997
  success,
@@ -31361,7 +31999,7 @@ billingCommand.command("portal").description("Open the billing portal in your br
31361
31999
  error
31362
32000
  });
31363
32001
  };
31364
- const { waitUntilExit } = render16(React16.createElement(App));
32002
+ const { waitUntilExit } = render17(React17.createElement(App));
31365
32003
  await waitUntilExit();
31366
32004
  });
31367
32005
  billingCommand.command("refresh").description("Refresh plan data from billing provider").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
@@ -31371,20 +32009,20 @@ billingCommand.command("refresh").description("Refresh plan data from billing pr
31371
32009
  if (!isTTY(options)) {
31372
32010
  try {
31373
32011
  await client.post("/billing/refresh");
31374
- console.log(chalk23.green("Plan data refreshed"));
32012
+ console.log(chalk24.green("Plan data refreshed"));
31375
32013
  } catch (error) {
31376
32014
  const message = error instanceof Error ? error.message : "Unknown error";
31377
- console.error(chalk23.red("Failed to refresh plan data"));
31378
- console.error(chalk23.red(message));
32015
+ console.error(chalk24.red("Failed to refresh plan data"));
32016
+ console.error(chalk24.red(message));
31379
32017
  process.exit(1);
31380
32018
  }
31381
32019
  return;
31382
32020
  }
31383
32021
  const App = () => {
31384
- const [loading, setLoading] = useState30(true);
31385
- const [success, setSuccess] = useState30(null);
31386
- const [error, setError] = useState30(null);
31387
- useEffect27(() => {
32022
+ const [loading, setLoading] = useState31(true);
32023
+ const [success, setSuccess] = useState31(null);
32024
+ const [error, setError] = useState31(null);
32025
+ useEffect28(() => {
31388
32026
  const run = async () => {
31389
32027
  try {
31390
32028
  await client.post("/billing/refresh");
@@ -31398,7 +32036,7 @@ billingCommand.command("refresh").description("Refresh plan data from billing pr
31398
32036
  };
31399
32037
  run();
31400
32038
  }, []);
31401
- return React16.createElement(MutationResult, {
32039
+ return React17.createElement(MutationResult, {
31402
32040
  loading,
31403
32041
  loadingLabel: "Refreshing plan data...",
31404
32042
  success,
@@ -31406,18 +32044,18 @@ billingCommand.command("refresh").description("Refresh plan data from billing pr
31406
32044
  error
31407
32045
  });
31408
32046
  };
31409
- const { waitUntilExit } = render16(React16.createElement(App));
32047
+ const { waitUntilExit } = render17(React17.createElement(App));
31410
32048
  await waitUntilExit();
31411
32049
  });
31412
32050
 
31413
32051
  // src/commands/flow-versions.ts
31414
- import { Command as Command18 } from "commander";
31415
- import chalk24 from "chalk";
31416
- import React17 from "react";
31417
- import { render as render17 } from "ink";
31418
- import { useState as useState31, useEffect as useEffect28 } from "react";
31419
- import { Text as Text33 } from "ink";
31420
- var flowVersionsCommand = new Command18("flow-versions").description(
32052
+ import { Command as Command19 } from "commander";
32053
+ import chalk25 from "chalk";
32054
+ import React18 from "react";
32055
+ import { render as render18 } from "ink";
32056
+ import { useState as useState32, useEffect as useEffect29 } from "react";
32057
+ import { Text as Text34 } from "ink";
32058
+ var flowVersionsCommand = new Command19("flow-versions").description(
31421
32059
  "Manage flow versions"
31422
32060
  );
31423
32061
  flowVersionsCommand.command("list <flowId>").description("List all versions for a flow").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (flowId, options) => {
@@ -31432,30 +32070,30 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
31432
32070
  } else {
31433
32071
  const versions = data.data ?? [];
31434
32072
  if (versions.length === 0) {
31435
- console.log(chalk24.gray("No versions found"));
32073
+ console.log(chalk25.gray("No versions found"));
31436
32074
  return;
31437
32075
  }
31438
- console.log(chalk24.cyan(`Versions for flow ${flowId}:`));
32076
+ console.log(chalk25.cyan(`Versions for flow ${flowId}:`));
31439
32077
  for (const v of versions) {
31440
- const publishedTag = v.published ? chalk24.green(" [published]") : "";
32078
+ const publishedTag = v.published ? chalk25.green(" [published]") : "";
31441
32079
  const versionNum = v.version !== void 0 ? `v${v.version}` : v.id;
31442
- const date = v.createdAt ? chalk24.gray(` ${v.createdAt}`) : "";
31443
- console.log(` ${chalk24.green(v.id)} ${versionNum}${publishedTag}${date}`);
32080
+ const date = v.createdAt ? chalk25.gray(` ${v.createdAt}`) : "";
32081
+ console.log(` ${chalk25.green(v.id)} ${versionNum}${publishedTag}${date}`);
31444
32082
  }
31445
32083
  }
31446
32084
  } catch (error) {
31447
32085
  const message = error instanceof Error ? error.message : "Unknown error";
31448
- console.error(chalk24.red("Failed to fetch versions"));
31449
- console.error(chalk24.red(message));
32086
+ console.error(chalk25.red("Failed to fetch versions"));
32087
+ console.error(chalk25.red(message));
31450
32088
  process.exit(1);
31451
32089
  }
31452
32090
  return;
31453
32091
  }
31454
32092
  const App = () => {
31455
- const [loading, setLoading] = useState31(true);
31456
- const [items, setItems] = useState31(null);
31457
- const [error, setError] = useState31(null);
31458
- useEffect28(() => {
32093
+ const [loading, setLoading] = useState32(true);
32094
+ const [items, setItems] = useState32(null);
32095
+ const [error, setError] = useState32(null);
32096
+ useEffect29(() => {
31459
32097
  const run = async () => {
31460
32098
  try {
31461
32099
  const data = await client.get(`/flow-versions/${flowId}`);
@@ -31468,7 +32106,7 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
31468
32106
  };
31469
32107
  run();
31470
32108
  }, []);
31471
- return React17.createElement(DataList, {
32109
+ return React18.createElement(DataList, {
31472
32110
  title: `Versions for flow ${flowId}`,
31473
32111
  items,
31474
32112
  error,
@@ -31478,11 +32116,11 @@ flowVersionsCommand.command("list <flowId>").description("List all versions for
31478
32116
  const v = item;
31479
32117
  const publishedTag = v.published ? " [published]" : "";
31480
32118
  const versionNum = v.version !== void 0 ? `v${v.version}` : v.id;
31481
- return React17.createElement(Text33, null, ` ${v.id} ${versionNum}${publishedTag}${v.createdAt ? ` ${v.createdAt}` : ""}`);
32119
+ return React18.createElement(Text34, null, ` ${v.id} ${versionNum}${publishedTag}${v.createdAt ? ` ${v.createdAt}` : ""}`);
31482
32120
  }
31483
32121
  });
31484
32122
  };
31485
- const { waitUntilExit } = render17(React17.createElement(App));
32123
+ const { waitUntilExit } = render18(React18.createElement(App));
31486
32124
  await waitUntilExit();
31487
32125
  });
31488
32126
  flowVersionsCommand.command("get <flowId> <versionId>").description("Get a specific version").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (flowId, versionId, options) => {
@@ -31506,22 +32144,22 @@ flowVersionsCommand.command("get <flowId> <versionId>").description("Get a speci
31506
32144
  }
31507
32145
  } catch (error) {
31508
32146
  const message = error instanceof Error ? error.message : "Unknown error";
31509
- console.error(chalk24.red("Failed to fetch version"));
31510
- console.error(chalk24.red(message));
32147
+ console.error(chalk25.red("Failed to fetch version"));
32148
+ console.error(chalk25.red(message));
31511
32149
  process.exit(1);
31512
32150
  }
31513
32151
  return;
31514
32152
  }
31515
32153
  const App = () => {
31516
- const [loading, setLoading] = useState31(true);
31517
- const [success, setSuccess] = useState31(null);
31518
- const [error, setError] = useState31(null);
31519
- const [resultNode, setResultNode] = useState31(void 0);
31520
- useEffect28(() => {
32154
+ const [loading, setLoading] = useState32(true);
32155
+ const [success, setSuccess] = useState32(null);
32156
+ const [error, setError] = useState32(null);
32157
+ const [resultNode, setResultNode] = useState32(void 0);
32158
+ useEffect29(() => {
31521
32159
  const run = async () => {
31522
32160
  try {
31523
32161
  const data = await client.get(`/flow-versions/${flowId}/${versionId}`);
31524
- setResultNode(React17.createElement(EntityCard, {
32162
+ setResultNode(React18.createElement(EntityCard, {
31525
32163
  fields: [
31526
32164
  { label: "ID", value: data.id },
31527
32165
  { label: "Flow ID", value: data.flowId },
@@ -31541,7 +32179,7 @@ flowVersionsCommand.command("get <flowId> <versionId>").description("Get a speci
31541
32179
  };
31542
32180
  run();
31543
32181
  }, []);
31544
- return React17.createElement(MutationResult, {
32182
+ return React18.createElement(MutationResult, {
31545
32183
  loading,
31546
32184
  loadingLabel: "Fetching version...",
31547
32185
  success,
@@ -31550,7 +32188,7 @@ flowVersionsCommand.command("get <flowId> <versionId>").description("Get a speci
31550
32188
  result: resultNode
31551
32189
  });
31552
32190
  };
31553
- const { waitUntilExit } = render17(React17.createElement(App));
32191
+ const { waitUntilExit } = render18(React18.createElement(App));
31554
32192
  await waitUntilExit();
31555
32193
  });
31556
32194
  flowVersionsCommand.command("published <flowId>").description("Get the published version for a flow").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (flowId, options) => {
@@ -31572,22 +32210,22 @@ flowVersionsCommand.command("published <flowId>").description("Get the published
31572
32210
  }
31573
32211
  } catch (error) {
31574
32212
  const message = error instanceof Error ? error.message : "Unknown error";
31575
- console.error(chalk24.red("Failed to fetch published version"));
31576
- console.error(chalk24.red(message));
32213
+ console.error(chalk25.red("Failed to fetch published version"));
32214
+ console.error(chalk25.red(message));
31577
32215
  process.exit(1);
31578
32216
  }
31579
32217
  return;
31580
32218
  }
31581
32219
  const App = () => {
31582
- const [loading, setLoading] = useState31(true);
31583
- const [success, setSuccess] = useState31(null);
31584
- const [error, setError] = useState31(null);
31585
- const [resultNode, setResultNode] = useState31(void 0);
31586
- useEffect28(() => {
32220
+ const [loading, setLoading] = useState32(true);
32221
+ const [success, setSuccess] = useState32(null);
32222
+ const [error, setError] = useState32(null);
32223
+ const [resultNode, setResultNode] = useState32(void 0);
32224
+ useEffect29(() => {
31587
32225
  const run = async () => {
31588
32226
  try {
31589
32227
  const data = await client.get(`/flow-versions/${flowId}/published`);
31590
- setResultNode(React17.createElement(EntityCard, {
32228
+ setResultNode(React18.createElement(EntityCard, {
31591
32229
  fields: [
31592
32230
  { label: "ID", value: data.id },
31593
32231
  { label: "Version", value: data.version },
@@ -31605,7 +32243,7 @@ flowVersionsCommand.command("published <flowId>").description("Get the published
31605
32243
  };
31606
32244
  run();
31607
32245
  }, []);
31608
- return React17.createElement(MutationResult, {
32246
+ return React18.createElement(MutationResult, {
31609
32247
  loading,
31610
32248
  loadingLabel: "Fetching published version...",
31611
32249
  success,
@@ -31614,7 +32252,7 @@ flowVersionsCommand.command("published <flowId>").description("Get the published
31614
32252
  result: resultNode
31615
32253
  });
31616
32254
  };
31617
- const { waitUntilExit } = render17(React17.createElement(App));
32255
+ const { waitUntilExit } = render18(React18.createElement(App));
31618
32256
  await waitUntilExit();
31619
32257
  });
31620
32258
  flowVersionsCommand.command("publish <flowId>").description("Publish a version").requiredOption("-v, --version <versionId>", "Version ID to publish").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (flowId, options) => {
@@ -31626,20 +32264,20 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
31626
32264
  await client.post(`/flow-versions/${flowId}/publish`, {
31627
32265
  versionId: options.version
31628
32266
  });
31629
- console.log(chalk24.green("Version published"));
32267
+ console.log(chalk25.green("Version published"));
31630
32268
  } catch (error) {
31631
32269
  const message = error instanceof Error ? error.message : "Unknown error";
31632
- console.error(chalk24.red("Failed to publish version"));
31633
- console.error(chalk24.red(message));
32270
+ console.error(chalk25.red("Failed to publish version"));
32271
+ console.error(chalk25.red(message));
31634
32272
  process.exit(1);
31635
32273
  }
31636
32274
  return;
31637
32275
  }
31638
32276
  const App = () => {
31639
- const [loading, setLoading] = useState31(true);
31640
- const [success, setSuccess] = useState31(null);
31641
- const [error, setError] = useState31(null);
31642
- useEffect28(() => {
32277
+ const [loading, setLoading] = useState32(true);
32278
+ const [success, setSuccess] = useState32(null);
32279
+ const [error, setError] = useState32(null);
32280
+ useEffect29(() => {
31643
32281
  const run = async () => {
31644
32282
  try {
31645
32283
  await client.post(`/flow-versions/${flowId}/publish`, {
@@ -31655,7 +32293,7 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
31655
32293
  };
31656
32294
  run();
31657
32295
  }, []);
31658
- return React17.createElement(MutationResult, {
32296
+ return React18.createElement(MutationResult, {
31659
32297
  loading,
31660
32298
  loadingLabel: "Publishing version...",
31661
32299
  success,
@@ -31663,7 +32301,7 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
31663
32301
  error
31664
32302
  });
31665
32303
  };
31666
- const { waitUntilExit } = render17(React17.createElement(App));
32304
+ const { waitUntilExit } = render18(React18.createElement(App));
31667
32305
  await waitUntilExit();
31668
32306
  });
31669
32307
 
@@ -31671,7 +32309,7 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
31671
32309
  init_credential_store();
31672
32310
 
31673
32311
  // src/lib/update-check.ts
31674
- import chalk25 from "chalk";
32312
+ import chalk26 from "chalk";
31675
32313
  import Conf3 from "conf";
31676
32314
  var UPDATE_CHECK_INTERVAL_MS = 12 * 60 * 60 * 1e3;
31677
32315
  var UPDATE_NOTIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
@@ -31765,7 +32403,7 @@ function notifyFromCachedCliUpdate(args, options = {}) {
31765
32403
  console.error(message);
31766
32404
  });
31767
32405
  notify(
31768
- `${chalk25.yellow("Update available:")} ${chalk25.red(currentVersion)} ${chalk25.gray("->")} ${chalk25.green(latestVersion)} ${chalk25.gray(`(${getUpgradeCommand()})`)}`
32406
+ `${chalk26.yellow("Update available:")} ${chalk26.red(currentVersion)} ${chalk26.gray("->")} ${chalk26.green(latestVersion)} ${chalk26.gray(`(${getUpgradeCommand()})`)}`
31769
32407
  );
31770
32408
  store.set("lastNotifiedAt", now.toISOString());
31771
32409
  store.set("lastNotifiedVersion", latestVersion);
@@ -31807,7 +32445,7 @@ function maybeNotifyAboutCliUpdate(args, options = {}) {
31807
32445
  // src/index.ts
31808
32446
  loadEnv();
31809
32447
  setCliTitle();
31810
- var program = new Command19();
32448
+ var program = new Command20();
31811
32449
  program.name("runtype").description("CLI for Runtype AI Platform").version(getCliVersion()).option("-v, --verbose", "Enable verbose output").option("--api-url <url>", "Override API URL").option("--json", "Output in JSON format");
31812
32450
  program.addCommand(initCommand);
31813
32451
  program.addCommand(loginCommand);
@@ -31824,6 +32462,7 @@ program.addCommand(modelsCommand);
31824
32462
  program.addCommand(schedulesCommand);
31825
32463
  program.addCommand(evalCommand);
31826
32464
  program.addCommand(apiKeysCommand);
32465
+ program.addCommand(clientTokensCommand);
31827
32466
  program.addCommand(analyticsCommand);
31828
32467
  program.addCommand(billingCommand);
31829
32468
  program.addCommand(flowVersionsCommand);
@@ -31841,15 +32480,15 @@ try {
31841
32480
  } catch (error) {
31842
32481
  const commanderError = error;
31843
32482
  if (commanderError.code === "commander.missingArgument") {
31844
- console.error(chalk26.red(`Error: ${commanderError.message}`));
32483
+ console.error(chalk27.red(`Error: ${commanderError.message}`));
31845
32484
  process.exit(1);
31846
32485
  } else if (commanderError.code === "commander.unknownOption") {
31847
- console.error(chalk26.red(`Error: ${commanderError.message}`));
32486
+ console.error(chalk27.red(`Error: ${commanderError.message}`));
31848
32487
  process.exit(1);
31849
32488
  } else if (commanderError.code === "commander.help" || commanderError.code === "commander.version") {
31850
32489
  process.exit(0);
31851
32490
  } else {
31852
- console.error(chalk26.red("An unexpected error occurred:"));
32491
+ console.error(chalk27.red("An unexpected error occurred:"));
31853
32492
  console.error(error);
31854
32493
  process.exit(1);
31855
32494
  }
@@ -31858,12 +32497,12 @@ async function handleNoCommand() {
31858
32497
  const store = new CredentialStore();
31859
32498
  const hasCredentials = await store.hasCredentials();
31860
32499
  if (!hasCredentials) {
31861
- console.log(chalk26.cyan("\nWelcome to Runtype CLI!\n"));
32500
+ console.log(chalk27.cyan("\nWelcome to Runtype CLI!\n"));
31862
32501
  console.log("It looks like this is your first time. Run the setup wizard:");
31863
- console.log(` ${chalk26.green("runtype init")}
32502
+ console.log(` ${chalk27.green("runtype init")}
31864
32503
  `);
31865
32504
  console.log("Or see all available commands:");
31866
- console.log(` ${chalk26.green("runtype --help")}
32505
+ console.log(` ${chalk27.green("runtype --help")}
31867
32506
  `);
31868
32507
  } else {
31869
32508
  try {