@runtypelabs/cli 2.20.0 → 2.21.1

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.
Files changed (2) hide show
  1. package/dist/index.js +193 -146
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -15128,7 +15128,7 @@ function date4(params) {
15128
15128
  // ../../node_modules/.pnpm/zod@4.4.2/node_modules/zod/v4/classic/external.js
15129
15129
  config(en_default());
15130
15130
 
15131
- // ../shared/dist/chunk-TWJN5HII.mjs
15131
+ // ../shared/dist/chunk-ENDRXULJ.mjs
15132
15132
  var apiReleaseChannelSchema = external_exports.enum(["staging", "production"]);
15133
15133
  var API_ARTIFACT_SCRIPT_PATTERN = /^api-[a-z0-9][a-z0-9-]{0,62}$/;
15134
15134
  var apiArtifactScriptNameSchema = external_exports.string().regex(
@@ -16218,6 +16218,7 @@ var AGENT_CONTENT_CONFIG_KEYS = {
16218
16218
  model: true,
16219
16219
  systemPrompt: true,
16220
16220
  temperature: true,
16221
+ maxTokens: true,
16221
16222
  topP: true,
16222
16223
  topK: true,
16223
16224
  frequencyPenalty: true,
@@ -39252,6 +39253,16 @@ var agentRuntimeConfigSchema = external_exports.object({
39252
39253
  model: external_exports.string().optional(),
39253
39254
  systemPrompt: external_exports.string().optional(),
39254
39255
  temperature: external_exports.number().min(0).max(2).optional(),
39256
+ // Maximum output tokens (the model call's `maxOutputTokens`). A sibling of
39257
+ // the sampling params: a static generation budget that belongs on the saved
39258
+ // agent definition. Notably load-bearing for "thinking" default models that
39259
+ // share reasoning + answer tokens in one output budget (Moonshot requires
39260
+ // `>= 16k` or the visible answer can truncate to nothing after a long
39261
+ // reasoning trace) — the Product Generator pins `24000` for exactly this.
39262
+ // `buildVirtualFlow` already maps this onto the prompt step (defaulting to
39263
+ // 16384 when unset), so saving it here is all that's required for it to take
39264
+ // effect at execution time.
39265
+ maxTokens: external_exports.number().int().min(1).optional(),
39255
39266
  ...samplingConfigSchema,
39256
39267
  // Unified tools configuration (nested under 'tools').
39257
39268
  //
@@ -44228,6 +44239,135 @@ import React3 from "react";
44228
44239
  import { render as render3 } from "ink";
44229
44240
  import { useState as useState4, useEffect as useEffect5 } from "react";
44230
44241
  import { writeFileSync } from "fs";
44242
+
44243
+ // src/lib/terminal-image.ts
44244
+ var ESC = "\x1B";
44245
+ var BEL = "\x07";
44246
+ var ST = `${ESC}\\`;
44247
+ function detectImageProtocol(env = process.env, isTTY2 = process.stdout.isTTY === true) {
44248
+ if (!isTTY2) return null;
44249
+ if (env.TERM === "xterm-kitty" || env.KITTY_WINDOW_ID || env.TERM_PROGRAM === "ghostty") {
44250
+ return "kitty";
44251
+ }
44252
+ if (env.TERM_PROGRAM === "iTerm.app" || env.TERM_PROGRAM === "WezTerm" || env.LC_TERMINAL === "iTerm2") {
44253
+ return "iterm2";
44254
+ }
44255
+ return null;
44256
+ }
44257
+ function parseImageDataUri(value) {
44258
+ if (typeof value !== "string" || !value.startsWith("data:")) return null;
44259
+ const match = value.match(/^data:([^;,]+)(?:;[^,]*)?;base64,(.+)$/s);
44260
+ if (!match || !match[1] || !match[2]) return null;
44261
+ return { mimeType: match[1], base64: match[2] };
44262
+ }
44263
+ function base64DecodedByteLength(base643) {
44264
+ const len = base643.length;
44265
+ if (len === 0) return 0;
44266
+ let padding = 0;
44267
+ if (base643.endsWith("==")) padding = 2;
44268
+ else if (base643.endsWith("=")) padding = 1;
44269
+ return Math.floor(len * 3 / 4) - padding;
44270
+ }
44271
+ function kittyImageSequence(base643) {
44272
+ const CHUNK = 4096;
44273
+ if (base643.length <= CHUNK) {
44274
+ return `${ESC}_Ga=T,f=100,m=0;${base643}${ST}`;
44275
+ }
44276
+ let out = "";
44277
+ for (let i = 0; i < base643.length; i += CHUNK) {
44278
+ const piece = base643.slice(i, i + CHUNK);
44279
+ const more = i + CHUNK < base643.length ? 1 : 0;
44280
+ out += i === 0 ? `${ESC}_Ga=T,f=100,m=${more};${piece}${ST}` : `${ESC}_Gm=${more};${piece}${ST}`;
44281
+ }
44282
+ return out;
44283
+ }
44284
+ function encodeInlineImage(opts) {
44285
+ const { base64: base643, mimeType, protocol } = opts;
44286
+ if (!base643) return null;
44287
+ if (protocol === "iterm2") {
44288
+ const sizeBytes = base64DecodedByteLength(base643);
44289
+ return `${ESC}]1337;File=inline=1;size=${sizeBytes};width=auto;height=auto;preserveAspectRatio=1:${base643}${BEL}`;
44290
+ }
44291
+ if (mimeType !== "image/png") return null;
44292
+ return kittyImageSequence(base643);
44293
+ }
44294
+ function renderInlineImage(value, protocol) {
44295
+ const parsed = parseImageDataUri(value);
44296
+ if (!parsed) return null;
44297
+ return encodeInlineImage({ base64: parsed.base64, mimeType: parsed.mimeType, protocol });
44298
+ }
44299
+
44300
+ // src/lib/message-content.ts
44301
+ function renderMessageContent(content) {
44302
+ if (typeof content === "string") return content;
44303
+ if (!Array.isArray(content)) return content == null ? "" : String(content);
44304
+ return content.map((part) => {
44305
+ if (part == null || typeof part !== "object") return part == null ? "" : String(part);
44306
+ const p = part;
44307
+ switch (p.type) {
44308
+ case "text":
44309
+ case "reasoning":
44310
+ return typeof p.text === "string" ? p.text : "";
44311
+ case "image":
44312
+ return `[image${"mimeType" in p && p.mimeType ? ` ${p.mimeType}` : ""}]`;
44313
+ case "file":
44314
+ return `[file${"filename" in p && p.filename ? ` ${p.filename}` : ""}${"mimeType" in p && p.mimeType ? ` (${p.mimeType})` : ""}]`;
44315
+ case "asset_ref":
44316
+ return `[attachment${"filename" in p && p.filename ? ` ${p.filename}` : ""}${"mimeType" in p && p.mimeType ? ` ${p.mimeType}` : ""}]`;
44317
+ default:
44318
+ return typeof p.type === "string" ? `[${p.type}]` : "";
44319
+ }
44320
+ }).filter((s) => s.length > 0).join(" ");
44321
+ }
44322
+ function renderMessageContentWithImages(content, protocol) {
44323
+ if (!Array.isArray(content)) {
44324
+ return { text: renderMessageContent(content), images: [] };
44325
+ }
44326
+ const inline = [];
44327
+ const images = [];
44328
+ for (const part of content) {
44329
+ if (part && typeof part === "object" && part.type === "image") {
44330
+ const image = part.image;
44331
+ const seq = typeof image === "string" ? renderInlineImage(image, protocol) : null;
44332
+ if (seq) {
44333
+ images.push(seq);
44334
+ continue;
44335
+ }
44336
+ }
44337
+ inline.push(renderMessageContent([part]));
44338
+ }
44339
+ return { text: inline.filter((s) => s.length > 0).join(" "), images };
44340
+ }
44341
+
44342
+ // src/commands/records.ts
44343
+ function printRecordDetail(data, imageProtocol) {
44344
+ console.log(` ID: ${data.id}`);
44345
+ console.log(` Name: ${data.name}`);
44346
+ console.log(` Type: ${data.type}`);
44347
+ if (data.metadata) {
44348
+ console.log(` Metadata: ${JSON.stringify(data.metadata, null, 2)}`);
44349
+ }
44350
+ const messages = data.messages ?? [];
44351
+ if (messages.length === 0) return;
44352
+ console.log(chalk6.cyan(`
44353
+ Messages (${messages.length}):`));
44354
+ for (const msg of messages) {
44355
+ const role = typeof msg.role === "string" ? msg.role : "message";
44356
+ const roleColor = role === "user" ? chalk6.blue : role === "assistant" ? chalk6.green : chalk6.gray;
44357
+ const rolePrefix = ` ${roleColor(role)}: `;
44358
+ if (imageProtocol) {
44359
+ const { text, images } = renderMessageContentWithImages(msg.content, imageProtocol);
44360
+ process.stdout.write(`${rolePrefix}${text}
44361
+ `);
44362
+ for (const seq of images) {
44363
+ process.stdout.write(`${seq}
44364
+ `);
44365
+ }
44366
+ } else {
44367
+ console.log(`${rolePrefix}${renderMessageContent(msg.content)}`);
44368
+ }
44369
+ }
44370
+ }
44231
44371
  var recordsCommand = new Command3("records").description("Manage records");
44232
44372
  recordsCommand.command("list").description("List all records").option("--type <type>", "Filter by record type").option("--limit <n>", "Limit number of results", "20").option("--cursor <cursor>", "Pagination cursor for the next page").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
44233
44373
  async (options) => {
@@ -44307,45 +44447,43 @@ recordsCommand.command("list").description("List all records").option("--type <t
44307
44447
  await waitUntilExit();
44308
44448
  }
44309
44449
  );
44310
- recordsCommand.command("get <id>").description("Get record details").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
44311
- const apiKey = await ensureAuth();
44312
- if (!apiKey) return;
44313
- const client = createCliClient(apiKey);
44314
- if (!isTTY(options) || options.json) {
44315
- try {
44316
- const data = await client.get(`/records/${id}`);
44317
- if (options.json) {
44318
- printJson(data);
44319
- return;
44320
- }
44321
- console.log(` ID: ${data.id}`);
44322
- console.log(` Name: ${data.name}`);
44323
- console.log(` Type: ${data.type}`);
44324
- if (data.metadata) {
44325
- console.log(` Metadata: ${JSON.stringify(data.metadata, null, 2)}`);
44450
+ recordsCommand.command("get <id>").description("Get record details").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").option("--no-images", "Disable inline image rendering even in supported terminals").action(
44451
+ async (id, options) => {
44452
+ const apiKey = await ensureAuth();
44453
+ if (!apiKey) return;
44454
+ const client = createCliClient(apiKey);
44455
+ const interactive = isTTY(options) && !options.json;
44456
+ const imageProtocol = interactive && options.images !== false ? detectImageProtocol() : null;
44457
+ if (!interactive || imageProtocol) {
44458
+ try {
44459
+ const data = await client.get(`/records/${id}`);
44460
+ if (options.json) {
44461
+ printJson(data);
44462
+ return;
44463
+ }
44464
+ printRecordDetail(data, imageProtocol);
44465
+ } catch (error51) {
44466
+ const message = error51 instanceof Error ? error51.message : "Unknown error";
44467
+ console.error(chalk6.red(`Failed to fetch record: ${message}`));
44468
+ process.exit(1);
44326
44469
  }
44327
- } catch (error51) {
44328
- const message = error51 instanceof Error ? error51.message : "Unknown error";
44329
- console.error(chalk6.red(`Failed to fetch record: ${message}`));
44330
- process.exit(1);
44470
+ return;
44331
44471
  }
44332
- return;
44333
- }
44334
- const App = () => {
44335
- const [items, setItems] = useState4(null);
44336
- const [error51, setError] = useState4(null);
44337
- useEffect5(() => {
44338
- client.get(`/records/${id}`).then((res) => setItems([res])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
44339
- }, []);
44340
- return React3.createElement(DataList, {
44341
- title: "Record",
44342
- items,
44343
- error: error51,
44344
- loading: items === null && error51 === null,
44345
- renderCard: (item) => {
44346
- const record2 = item;
44347
- return React3.createElement(EntityCard, {
44348
- fields: [
44472
+ const App = () => {
44473
+ const [items, setItems] = useState4(null);
44474
+ const [error51, setError] = useState4(null);
44475
+ useEffect5(() => {
44476
+ client.get(`/records/${id}`).then((res) => setItems([res])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
44477
+ }, []);
44478
+ return React3.createElement(DataList, {
44479
+ title: "Record",
44480
+ items,
44481
+ error: error51,
44482
+ loading: items === null && error51 === null,
44483
+ renderCard: (item) => {
44484
+ const record2 = item;
44485
+ const messages = record2.messages ?? [];
44486
+ const fields = [
44349
44487
  { label: "ID", value: record2.id, color: "green" },
44350
44488
  { label: "Name", value: record2.name },
44351
44489
  { label: "Type", value: record2.type },
@@ -44353,14 +44491,21 @@ recordsCommand.command("get <id>").description("Get record details").option("--j
44353
44491
  label: "Metadata",
44354
44492
  value: record2.metadata ? JSON.stringify(record2.metadata) : null
44355
44493
  }
44356
- ]
44357
- });
44358
- }
44359
- });
44360
- };
44361
- const { waitUntilExit } = render3(React3.createElement(App));
44362
- await waitUntilExit();
44363
- });
44494
+ ];
44495
+ if (messages.length > 0) {
44496
+ fields.push({
44497
+ label: `Messages (${messages.length})`,
44498
+ value: messages.map((m2) => `${m2.role ?? "message"}: ${renderMessageContent(m2.content)}`).join("\n")
44499
+ });
44500
+ }
44501
+ return React3.createElement(EntityCard, { fields });
44502
+ }
44503
+ });
44504
+ };
44505
+ const { waitUntilExit } = render3(React3.createElement(App));
44506
+ await waitUntilExit();
44507
+ }
44508
+ );
44364
44509
  recordsCommand.command("results <id>").description("Get step-level execution results for a record").option("--flow-id <flowId>", "Filter by flow ID").option("--batch-id <batchId>", "Filter by batch ID").option("--status <status>", "Filter by status").option("--limit <n>", "Limit number of results").option("--offset <n>", "Offset for pagination").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
44365
44510
  async (id, options) => {
44366
44511
  const apiKey = await ensureAuth();
@@ -48784,108 +48929,10 @@ import chalk17 from "chalk";
48784
48929
  import React14 from "react";
48785
48930
  import { render as render14 } from "ink";
48786
48931
  import { useState as useState15, useEffect as useEffect16 } from "react";
48787
-
48788
- // src/lib/terminal-image.ts
48789
- var ESC = "\x1B";
48790
- var BEL = "\x07";
48791
- var ST = `${ESC}\\`;
48792
- function detectImageProtocol(env = process.env, isTTY2 = process.stdout.isTTY === true) {
48793
- if (!isTTY2) return null;
48794
- if (env.TERM === "xterm-kitty" || env.KITTY_WINDOW_ID || env.TERM_PROGRAM === "ghostty") {
48795
- return "kitty";
48796
- }
48797
- if (env.TERM_PROGRAM === "iTerm.app" || env.TERM_PROGRAM === "WezTerm" || env.LC_TERMINAL === "iTerm2") {
48798
- return "iterm2";
48799
- }
48800
- return null;
48801
- }
48802
- function parseImageDataUri(value) {
48803
- if (typeof value !== "string" || !value.startsWith("data:")) return null;
48804
- const match = value.match(/^data:([^;,]+)(?:;[^,]*)?;base64,(.+)$/s);
48805
- if (!match || !match[1] || !match[2]) return null;
48806
- return { mimeType: match[1], base64: match[2] };
48807
- }
48808
- function base64DecodedByteLength(base643) {
48809
- const len = base643.length;
48810
- if (len === 0) return 0;
48811
- let padding = 0;
48812
- if (base643.endsWith("==")) padding = 2;
48813
- else if (base643.endsWith("=")) padding = 1;
48814
- return Math.floor(len * 3 / 4) - padding;
48815
- }
48816
- function kittyImageSequence(base643) {
48817
- const CHUNK = 4096;
48818
- if (base643.length <= CHUNK) {
48819
- return `${ESC}_Ga=T,f=100,m=0;${base643}${ST}`;
48820
- }
48821
- let out = "";
48822
- for (let i = 0; i < base643.length; i += CHUNK) {
48823
- const piece = base643.slice(i, i + CHUNK);
48824
- const more = i + CHUNK < base643.length ? 1 : 0;
48825
- out += i === 0 ? `${ESC}_Ga=T,f=100,m=${more};${piece}${ST}` : `${ESC}_Gm=${more};${piece}${ST}`;
48826
- }
48827
- return out;
48828
- }
48829
- function encodeInlineImage(opts) {
48830
- const { base64: base643, mimeType, protocol } = opts;
48831
- if (!base643) return null;
48832
- if (protocol === "iterm2") {
48833
- const sizeBytes = base64DecodedByteLength(base643);
48834
- return `${ESC}]1337;File=inline=1;size=${sizeBytes};width=auto;height=auto;preserveAspectRatio=1:${base643}${BEL}`;
48835
- }
48836
- if (mimeType !== "image/png") return null;
48837
- return kittyImageSequence(base643);
48838
- }
48839
- function renderInlineImage(value, protocol) {
48840
- const parsed = parseImageDataUri(value);
48841
- if (!parsed) return null;
48842
- return encodeInlineImage({ base64: parsed.base64, mimeType: parsed.mimeType, protocol });
48843
- }
48844
-
48845
- // src/commands/conversations.ts
48846
- function renderMessageContent(content) {
48847
- if (typeof content === "string") return content;
48848
- if (!Array.isArray(content)) return content == null ? "" : String(content);
48849
- return content.map((part) => {
48850
- if (part == null || typeof part !== "object") return part == null ? "" : String(part);
48851
- const p = part;
48852
- switch (p.type) {
48853
- case "text":
48854
- case "reasoning":
48855
- return typeof p.text === "string" ? p.text : "";
48856
- case "image":
48857
- return `[image${"mimeType" in p && p.mimeType ? ` ${p.mimeType}` : ""}]`;
48858
- case "file":
48859
- return `[file${"filename" in p && p.filename ? ` ${p.filename}` : ""}${"mimeType" in p && p.mimeType ? ` (${p.mimeType})` : ""}]`;
48860
- case "asset_ref":
48861
- return `[attachment${"filename" in p && p.filename ? ` ${p.filename}` : ""}${"mimeType" in p && p.mimeType ? ` ${p.mimeType}` : ""}]`;
48862
- default:
48863
- return typeof p.type === "string" ? `[${p.type}]` : "";
48864
- }
48865
- }).filter((s) => s.length > 0).join(" ");
48866
- }
48867
48932
  function writeMessageWithImages(msg, rolePrefix, protocol) {
48868
48933
  const out = process.stdout;
48869
- const content = msg.content;
48870
- if (!Array.isArray(content)) {
48871
- out.write(`${rolePrefix}${renderMessageContent(content)}
48872
- `);
48873
- return;
48874
- }
48875
- const inline = [];
48876
- const images = [];
48877
- for (const part of content) {
48878
- if (part && typeof part === "object" && part.type === "image") {
48879
- const image = part.image;
48880
- const seq = typeof image === "string" ? renderInlineImage(image, protocol) : null;
48881
- if (seq) {
48882
- images.push(seq);
48883
- continue;
48884
- }
48885
- }
48886
- inline.push(renderMessageContent([part]));
48887
- }
48888
- out.write(`${rolePrefix}${inline.filter((s) => s.length > 0).join(" ")}
48934
+ const { text, images } = renderMessageContentWithImages(msg.content, protocol);
48935
+ out.write(`${rolePrefix}${text}
48889
48936
  `);
48890
48937
  for (const seq of images) {
48891
48938
  out.write(`${seq}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.20.0",
3
+ "version": "2.21.1",
4
4
  "description": "Command-line interface for Runtype AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "rosie-skills": "0.8.1",
25
25
  "yaml": "^2.9.0",
26
26
  "@runtypelabs/ink-components": "0.3.2",
27
- "@runtypelabs/sdk": "4.13.1",
27
+ "@runtypelabs/sdk": "4.14.0",
28
28
  "@runtypelabs/terminal-animations": "0.2.1"
29
29
  },
30
30
  "devDependencies": {
@@ -39,7 +39,7 @@
39
39
  "tsx": "^4.7.1",
40
40
  "typescript": "^5.3.3",
41
41
  "vitest": "^4.1.0",
42
- "@runtypelabs/shared": "1.29.0"
42
+ "@runtypelabs/shared": "1.30.0"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=22.0.0"