@runtypelabs/cli 2.19.0 → 2.19.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.
- package/dist/index.js +292 -45
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -15164,7 +15164,7 @@ var apiRoutingDocSchema = external_exports.object({
|
|
|
15164
15164
|
path: ["api", "activeScript"]
|
|
15165
15165
|
});
|
|
15166
15166
|
|
|
15167
|
-
// ../shared/dist/chunk-
|
|
15167
|
+
// ../shared/dist/chunk-R66POVE6.mjs
|
|
15168
15168
|
function getNestedValue(obj, path18) {
|
|
15169
15169
|
let normalizedPath = path18;
|
|
15170
15170
|
normalizedPath = normalizedPath.replace(/^\$\.?/, "");
|
|
@@ -15200,6 +15200,55 @@ function getNestedValue(obj, path18) {
|
|
|
15200
15200
|
return current;
|
|
15201
15201
|
}
|
|
15202
15202
|
var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
15203
|
+
var SYSTEM_VARIABLES = /* @__PURE__ */ new Set([
|
|
15204
|
+
"_flow",
|
|
15205
|
+
"_user",
|
|
15206
|
+
"_execution",
|
|
15207
|
+
"_record",
|
|
15208
|
+
"_now",
|
|
15209
|
+
"_schedule",
|
|
15210
|
+
"messages",
|
|
15211
|
+
"userMessage",
|
|
15212
|
+
"lastMessage",
|
|
15213
|
+
"messageCount"
|
|
15214
|
+
]);
|
|
15215
|
+
var SECRET_REF_PATTERN = /\{\{secret:([A-Z][A-Z0-9_]*[A-Z0-9])\}\}/g;
|
|
15216
|
+
var RUNTIME_PREFIXES = {
|
|
15217
|
+
"secret:": {
|
|
15218
|
+
prefix: "secret:",
|
|
15219
|
+
namespace: "secret",
|
|
15220
|
+
resolvedBy: "the secret pre-pass (substituteSecretReferences) before the template engine runs \u2014 never the template engine itself",
|
|
15221
|
+
mayReachModelUnresolved: false
|
|
15222
|
+
},
|
|
15223
|
+
"flow:": {
|
|
15224
|
+
prefix: "flow:",
|
|
15225
|
+
namespace: "flow",
|
|
15226
|
+
resolvedBy: "the template engine, which treats it as an alias for the bare flow variable of the same name",
|
|
15227
|
+
mayReachModelUnresolved: false
|
|
15228
|
+
}
|
|
15229
|
+
};
|
|
15230
|
+
var PREFIX_PATTERN = /^([A-Za-z][A-Za-z0-9_-]*):(.*)$/s;
|
|
15231
|
+
function classifyVariableReference(token) {
|
|
15232
|
+
const trimmed = token.trim();
|
|
15233
|
+
const prefixMatch = PREFIX_PATTERN.exec(trimmed);
|
|
15234
|
+
if (prefixMatch) {
|
|
15235
|
+
const prefix = `${prefixMatch[1]}:`;
|
|
15236
|
+
const rest = prefixMatch[2] ?? "";
|
|
15237
|
+
const spec = RUNTIME_PREFIXES[prefix];
|
|
15238
|
+
if (spec) {
|
|
15239
|
+
return { namespace: spec.namespace, baseName: rest.trim() };
|
|
15240
|
+
}
|
|
15241
|
+
return { namespace: "unknown", raw: trimmed };
|
|
15242
|
+
}
|
|
15243
|
+
if (isSystemVariable(trimmed)) {
|
|
15244
|
+
return { namespace: "system", baseName: trimmed };
|
|
15245
|
+
}
|
|
15246
|
+
return { namespace: "plain", baseName: trimmed };
|
|
15247
|
+
}
|
|
15248
|
+
function isSystemVariable(varName) {
|
|
15249
|
+
const rootSegment = varName.split(".")[0] || "";
|
|
15250
|
+
return SYSTEM_VARIABLES.has(rootSegment);
|
|
15251
|
+
}
|
|
15203
15252
|
var TEMPLATE_EXPRESSION_PATTERN = /\{\{([^{}]+)\}\}/g;
|
|
15204
15253
|
function parseTemplateExpression(expr) {
|
|
15205
15254
|
const tokens = tokenizeFallbackExpression(expr);
|
|
@@ -15286,7 +15335,7 @@ function parseOperand(raw) {
|
|
|
15286
15335
|
}
|
|
15287
15336
|
function evaluateOperand(operand, context) {
|
|
15288
15337
|
if (operand.kind === "literal") return operand.value;
|
|
15289
|
-
return getNestedValue(context, operand.path);
|
|
15338
|
+
return getNestedValue(context, classifiedLookupKey(operand.path));
|
|
15290
15339
|
}
|
|
15291
15340
|
function countTrailingBackslashes(s, i) {
|
|
15292
15341
|
let n = 0;
|
|
@@ -15311,6 +15360,7 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
|
|
|
15311
15360
|
const usedVariables = [];
|
|
15312
15361
|
const usedDefaults = [];
|
|
15313
15362
|
const missingVariables = [];
|
|
15363
|
+
const unknownNamespaceVariables = [];
|
|
15314
15364
|
const result = template.replace(_SimpleTemplateEngine2.EXPRESSION_PATTERN, (match, expr) => {
|
|
15315
15365
|
let parsed;
|
|
15316
15366
|
try {
|
|
@@ -15323,12 +15373,14 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
|
|
|
15323
15373
|
usedVariables,
|
|
15324
15374
|
usedDefaults,
|
|
15325
15375
|
missingVariables,
|
|
15376
|
+
unknownNamespaceVariables,
|
|
15326
15377
|
match
|
|
15327
15378
|
});
|
|
15328
15379
|
}
|
|
15329
15380
|
return resolveFallback(parsed, context, {
|
|
15330
15381
|
usedVariables,
|
|
15331
15382
|
missingVariables,
|
|
15383
|
+
unknownNamespaceVariables,
|
|
15332
15384
|
match
|
|
15333
15385
|
});
|
|
15334
15386
|
});
|
|
@@ -15336,7 +15388,8 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
|
|
|
15336
15388
|
result,
|
|
15337
15389
|
usedVariables,
|
|
15338
15390
|
usedDefaults,
|
|
15339
|
-
missingVariables
|
|
15391
|
+
missingVariables,
|
|
15392
|
+
unknownNamespaceVariables
|
|
15340
15393
|
};
|
|
15341
15394
|
}
|
|
15342
15395
|
/**
|
|
@@ -15411,28 +15464,49 @@ var _SimpleTemplateEngine = class _SimpleTemplateEngine2 {
|
|
|
15411
15464
|
};
|
|
15412
15465
|
_SimpleTemplateEngine.EXPRESSION_PATTERN = TEMPLATE_EXPRESSION_PATTERN;
|
|
15413
15466
|
var SimpleTemplateEngine = _SimpleTemplateEngine;
|
|
15467
|
+
function classifiedLookupKey(rawKey, onUnknown) {
|
|
15468
|
+
const classification = classifyVariableReference(rawKey);
|
|
15469
|
+
if (classification.namespace === "flow") {
|
|
15470
|
+
return classification.baseName;
|
|
15471
|
+
}
|
|
15472
|
+
if (classification.namespace === "unknown") {
|
|
15473
|
+
onUnknown?.(classification.raw);
|
|
15474
|
+
return rawKey;
|
|
15475
|
+
}
|
|
15476
|
+
return rawKey;
|
|
15477
|
+
}
|
|
15414
15478
|
function resolveLegacy(parsed, context, tracking) {
|
|
15415
|
-
const
|
|
15479
|
+
const lookupKey = classifiedLookupKey(
|
|
15480
|
+
parsed.variable,
|
|
15481
|
+
(raw) => tracking.unknownNamespaceVariables.push(raw)
|
|
15482
|
+
);
|
|
15483
|
+
const value = getNestedValue(context, lookupKey);
|
|
15416
15484
|
if (value !== void 0 && value !== null) {
|
|
15417
|
-
tracking.usedVariables.push(
|
|
15485
|
+
tracking.usedVariables.push(lookupKey);
|
|
15418
15486
|
return stringifyValue(value);
|
|
15419
15487
|
}
|
|
15420
15488
|
if (parsed.defaultValue !== void 0) {
|
|
15421
15489
|
tracking.usedDefaults.push({
|
|
15422
|
-
variable:
|
|
15490
|
+
variable: lookupKey,
|
|
15423
15491
|
defaultValue: parsed.defaultValue
|
|
15424
15492
|
});
|
|
15425
15493
|
return parsed.defaultValue;
|
|
15426
15494
|
}
|
|
15427
|
-
tracking.missingVariables.push(
|
|
15495
|
+
tracking.missingVariables.push(lookupKey);
|
|
15428
15496
|
return tracking.match;
|
|
15429
15497
|
}
|
|
15430
15498
|
function resolveFallback(parsed, context, tracking) {
|
|
15431
15499
|
let chosen = null;
|
|
15432
15500
|
for (const operand of parsed.operands) {
|
|
15433
15501
|
const value = evaluateOperand(operand, context);
|
|
15434
|
-
if (operand.kind === "path"
|
|
15435
|
-
|
|
15502
|
+
if (operand.kind === "path") {
|
|
15503
|
+
const key = classifiedLookupKey(
|
|
15504
|
+
operand.path,
|
|
15505
|
+
(raw) => tracking.unknownNamespaceVariables.push(raw)
|
|
15506
|
+
);
|
|
15507
|
+
if (value !== void 0) {
|
|
15508
|
+
tracking.usedVariables.push(key);
|
|
15509
|
+
}
|
|
15436
15510
|
}
|
|
15437
15511
|
if (chosen === null && passesOperator(value, parsed.operator)) {
|
|
15438
15512
|
chosen = { value, isPath: operand.kind === "path" };
|
|
@@ -15444,13 +15518,18 @@ function resolveFallback(parsed, context, tracking) {
|
|
|
15444
15518
|
return stringifyValue(last.value);
|
|
15445
15519
|
}
|
|
15446
15520
|
for (const operand of parsed.operands) {
|
|
15447
|
-
if (operand.kind === "path")
|
|
15521
|
+
if (operand.kind === "path") {
|
|
15522
|
+
tracking.missingVariables.push(classifiedLookupKey(operand.path));
|
|
15523
|
+
}
|
|
15448
15524
|
}
|
|
15449
15525
|
return tracking.match;
|
|
15450
15526
|
}
|
|
15451
15527
|
var templateEngine = new SimpleTemplateEngine();
|
|
15452
15528
|
|
|
15453
15529
|
// ../shared/dist/index.mjs
|
|
15530
|
+
function neutralizeCsvFormula(value) {
|
|
15531
|
+
return /^[=+\-@\t\r\n]/.test(value) ? `'${value}` : value;
|
|
15532
|
+
}
|
|
15454
15533
|
var mediaAnnotationsSchema = external_exports.object({
|
|
15455
15534
|
audience: external_exports.array(external_exports.enum(["user", "assistant"])).optional()
|
|
15456
15535
|
});
|
|
@@ -30449,7 +30528,7 @@ var CORE_BUILTIN_TOOLS_REGISTRY = [
|
|
|
30449
30528
|
{
|
|
30450
30529
|
id: "publish_page",
|
|
30451
30530
|
name: "Publish Page",
|
|
30452
|
-
description: "Publish an HTML page on Runtype's CDN and get back a shareable URL that renders the page inline in the browser. Two source modes: (1) pass `url` to download an HTML file from an HTTP(S) URL, or (2) pass base64-encoded `content` (defaults to `contentType: text/html`) to upload inline HTML directly \u2014 useful when running inside a sandboxed code-execution environment with restricted outbound network. Exactly one of `url` or `content` must be provided. Served inline from a `/preview/` path under a locked-down CSP that blocks scripts, network requests, and form submissions. Page URLs are public and expire
|
|
30531
|
+
description: "Publish an HTML page on Runtype's CDN and get back a shareable URL that renders the page inline in the browser. Two source modes: (1) pass `url` to download an HTML file from an HTTP(S) URL, or (2) pass base64-encoded `content` (defaults to `contentType: text/html`) to upload inline HTML directly \u2014 useful when running inside a sandboxed code-execution environment with restricted outbound network. Exactly one of `url` or `content` must be provided. Served inline from a `/preview/` path under a locked-down CSP that blocks scripts, network requests, and form submissions. Page URLs are public and expire based on the account's plan (7 days on the default plan; longer or permanent on higher tiers \u2014 check `expiresAt` in the result). Pass `expiresInSeconds` to choose a shorter lifetime; the plan TTL is a hard ceiling. A page can be re-upped to the current plan TTL at the same URL via `POST /v1/assets/:assetId/extend`. Accepts only HTML content. 25 MB max. To host a non-HTML file, or HTML as a permanent downloadable file, use `store_asset` instead.",
|
|
30453
30532
|
category: BuiltInToolCategory.FILE_OPERATIONS,
|
|
30454
30533
|
toolGroup: BuiltInToolGroup.FILE_OUTPUTS,
|
|
30455
30534
|
providers: [BuiltInToolProvider.MULTI],
|
|
@@ -30471,6 +30550,10 @@ var CORE_BUILTIN_TOOLS_REGISTRY = [
|
|
|
30471
30550
|
filename: {
|
|
30472
30551
|
type: "string",
|
|
30473
30552
|
description: "Optional filename for the stored page"
|
|
30553
|
+
},
|
|
30554
|
+
expiresInSeconds: {
|
|
30555
|
+
type: "number",
|
|
30556
|
+
description: "Optional page lifetime in seconds (positive integer). Capped at the account plan's preview TTL \u2014 a shorter lifetime is honored, a longer one is clamped to the plan ceiling. Omit to use the plan default."
|
|
30474
30557
|
}
|
|
30475
30558
|
},
|
|
30476
30559
|
required: []
|
|
@@ -33524,7 +33607,11 @@ var userProfileFeaturesSchema = external_exports.object({
|
|
|
33524
33607
|
// Gates the chrome_extension surface type in the dashboard (surface picker
|
|
33525
33608
|
// and downstream config/ship UI). Driven by the `CHROME_SURFACE` boolean
|
|
33526
33609
|
// flag.
|
|
33527
|
-
enableChromeSurface: external_exports.boolean()
|
|
33610
|
+
enableChromeSurface: external_exports.boolean(),
|
|
33611
|
+
// Gates the Runtype Apps nav entry + routes in the dashboard. Driven by the
|
|
33612
|
+
// `enable-runtype-apps` boolean flag (fail-closed in production until the
|
|
33613
|
+
// prod ops set lands). The whole /v1/apps surface 404s when this is off.
|
|
33614
|
+
enableRuntypeApps: external_exports.boolean()
|
|
33528
33615
|
});
|
|
33529
33616
|
var MODEL_FAMILY_PROVIDER_IDS = {
|
|
33530
33617
|
"claude-fable-5": {
|
|
@@ -36160,7 +36247,6 @@ var agentRuntimeConfigSchema = external_exports.object({
|
|
|
36160
36247
|
// mirroring how `temporalConfigSchema` is shared.
|
|
36161
36248
|
memory: memoryConfigSchema.optional()
|
|
36162
36249
|
});
|
|
36163
|
-
var SECRET_REF_PATTERN = /\{\{secret:([A-Z][A-Z0-9_]*[A-Z0-9])\}\}/g;
|
|
36164
36250
|
function extractSecretReferences(template) {
|
|
36165
36251
|
const keys = /* @__PURE__ */ new Set();
|
|
36166
36252
|
let match;
|
|
@@ -41126,6 +41212,131 @@ recordsCommand.command("get <id>").description("Get record details").option("--j
|
|
|
41126
41212
|
const { waitUntilExit } = render3(React3.createElement(App));
|
|
41127
41213
|
await waitUntilExit();
|
|
41128
41214
|
});
|
|
41215
|
+
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(
|
|
41216
|
+
async (id, options) => {
|
|
41217
|
+
const apiKey = await ensureAuth();
|
|
41218
|
+
if (!apiKey) return;
|
|
41219
|
+
const client = createCliClient(apiKey);
|
|
41220
|
+
const params = {
|
|
41221
|
+
...options.flowId ? { flowId: options.flowId } : {},
|
|
41222
|
+
...options.batchId ? { batchId: options.batchId } : {},
|
|
41223
|
+
...options.status ? { status: options.status } : {},
|
|
41224
|
+
...options.limit ? { limit: parseInt(options.limit, 10) } : {},
|
|
41225
|
+
...options.offset ? { offset: parseInt(options.offset, 10) } : {}
|
|
41226
|
+
};
|
|
41227
|
+
if (!isTTY(options) || options.json) {
|
|
41228
|
+
try {
|
|
41229
|
+
const data = await client.records.getStepResults(id, params);
|
|
41230
|
+
if (options.json) {
|
|
41231
|
+
printJson(data);
|
|
41232
|
+
return;
|
|
41233
|
+
}
|
|
41234
|
+
const results = data.data ?? [];
|
|
41235
|
+
if (results.length === 0) {
|
|
41236
|
+
console.log(chalk6.yellow("No step results found"));
|
|
41237
|
+
return;
|
|
41238
|
+
}
|
|
41239
|
+
for (const r of results) {
|
|
41240
|
+
console.log(
|
|
41241
|
+
` ${chalk6.green(r.id)} ${r.stepName} (${r.stepType}) ${r.status}` + (r.modelUsed ? ` ${r.modelUsed}` : "")
|
|
41242
|
+
);
|
|
41243
|
+
}
|
|
41244
|
+
} catch (error51) {
|
|
41245
|
+
const message = error51 instanceof Error ? error51.message : "Unknown error";
|
|
41246
|
+
console.error(chalk6.red(`Failed to fetch step results: ${message}`));
|
|
41247
|
+
process.exit(1);
|
|
41248
|
+
}
|
|
41249
|
+
return;
|
|
41250
|
+
}
|
|
41251
|
+
const App = () => {
|
|
41252
|
+
const [items, setItems] = useState4(null);
|
|
41253
|
+
const [error51, setError] = useState4(null);
|
|
41254
|
+
useEffect5(() => {
|
|
41255
|
+
client.records.getStepResults(id, params).then((res) => setItems(res.data ?? [])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
41256
|
+
}, []);
|
|
41257
|
+
return React3.createElement(DataList, {
|
|
41258
|
+
title: "Step results",
|
|
41259
|
+
items,
|
|
41260
|
+
error: error51,
|
|
41261
|
+
loading: items === null && error51 === null,
|
|
41262
|
+
renderCard: (item) => {
|
|
41263
|
+
const r = item;
|
|
41264
|
+
return React3.createElement(EntityCard, {
|
|
41265
|
+
fields: [
|
|
41266
|
+
{ label: "ID", value: r.id, color: "green" },
|
|
41267
|
+
{ label: "Step", value: `${r.stepName} (${r.stepType})` },
|
|
41268
|
+
{ label: "Status", value: r.status },
|
|
41269
|
+
{ label: "Model", value: r.modelUsed ?? null },
|
|
41270
|
+
{
|
|
41271
|
+
label: "Duration",
|
|
41272
|
+
value: r.durationMs !== null ? `${r.durationMs}ms` : null
|
|
41273
|
+
}
|
|
41274
|
+
]
|
|
41275
|
+
});
|
|
41276
|
+
}
|
|
41277
|
+
});
|
|
41278
|
+
};
|
|
41279
|
+
const { waitUntilExit } = render3(React3.createElement(App));
|
|
41280
|
+
await waitUntilExit();
|
|
41281
|
+
}
|
|
41282
|
+
);
|
|
41283
|
+
recordsCommand.command("costs <id>").description("Get aggregated cost breakdown for a record").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
|
|
41284
|
+
const apiKey = await ensureAuth();
|
|
41285
|
+
if (!apiKey) return;
|
|
41286
|
+
const client = createCliClient(apiKey);
|
|
41287
|
+
if (!isTTY(options) || options.json) {
|
|
41288
|
+
try {
|
|
41289
|
+
const data = await client.records.getCosts(id);
|
|
41290
|
+
if (options.json) {
|
|
41291
|
+
printJson(data);
|
|
41292
|
+
return;
|
|
41293
|
+
}
|
|
41294
|
+
console.log(` Total cost: $${data.totalCost}`);
|
|
41295
|
+
console.log(` Total tokens: ${data.totalTokens}`);
|
|
41296
|
+
console.log(` Executions: ${data.executionCount}`);
|
|
41297
|
+
if (data.modelBreakdown.length > 0) {
|
|
41298
|
+
console.log(" By model:");
|
|
41299
|
+
for (const m2 of data.modelBreakdown) {
|
|
41300
|
+
console.log(` ${m2.model}: $${m2.cost} ${m2.tokens} tokens ${m2.count} calls`);
|
|
41301
|
+
}
|
|
41302
|
+
}
|
|
41303
|
+
} catch (error51) {
|
|
41304
|
+
const message = error51 instanceof Error ? error51.message : "Unknown error";
|
|
41305
|
+
console.error(chalk6.red(`Failed to fetch record costs: ${message}`));
|
|
41306
|
+
process.exit(1);
|
|
41307
|
+
}
|
|
41308
|
+
return;
|
|
41309
|
+
}
|
|
41310
|
+
const App = () => {
|
|
41311
|
+
const [items, setItems] = useState4(null);
|
|
41312
|
+
const [error51, setError] = useState4(null);
|
|
41313
|
+
useEffect5(() => {
|
|
41314
|
+
client.records.getCosts(id).then((res) => setItems([res])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
41315
|
+
}, []);
|
|
41316
|
+
return React3.createElement(DataList, {
|
|
41317
|
+
title: "Record costs",
|
|
41318
|
+
items,
|
|
41319
|
+
error: error51,
|
|
41320
|
+
loading: items === null && error51 === null,
|
|
41321
|
+
renderCard: (item) => {
|
|
41322
|
+
const c2 = item;
|
|
41323
|
+
return React3.createElement(EntityCard, {
|
|
41324
|
+
fields: [
|
|
41325
|
+
{ label: "Total cost", value: `$${c2.totalCost}`, color: "green" },
|
|
41326
|
+
{ label: "Total tokens", value: String(c2.totalTokens) },
|
|
41327
|
+
{ label: "Executions", value: String(c2.executionCount) },
|
|
41328
|
+
{
|
|
41329
|
+
label: "Models",
|
|
41330
|
+
value: c2.modelBreakdown.map((m2) => `${m2.model} ($${m2.cost})`).join(", ") || null
|
|
41331
|
+
}
|
|
41332
|
+
]
|
|
41333
|
+
});
|
|
41334
|
+
}
|
|
41335
|
+
});
|
|
41336
|
+
};
|
|
41337
|
+
const { waitUntilExit } = render3(React3.createElement(App));
|
|
41338
|
+
await waitUntilExit();
|
|
41339
|
+
});
|
|
41129
41340
|
recordsCommand.command("create").description("Create a new record").requiredOption("-n, --name <name>", "Record name").requiredOption("-t, --type <type>", "Record type").option("-m, --metadata <json>", "Metadata as JSON string").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(
|
|
41130
41341
|
async (options) => {
|
|
41131
41342
|
const apiKey = await ensureAuth();
|
|
@@ -41533,10 +41744,11 @@ recordsCommand.command("export").description("Export records to a file").option(
|
|
|
41533
41744
|
}
|
|
41534
41745
|
});
|
|
41535
41746
|
function csvEscape(value) {
|
|
41536
|
-
|
|
41537
|
-
|
|
41747
|
+
const text = neutralizeCsvFormula(value);
|
|
41748
|
+
if (text.includes(",") || text.includes('"') || text.includes("\n")) {
|
|
41749
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
41538
41750
|
}
|
|
41539
|
-
return
|
|
41751
|
+
return text;
|
|
41540
41752
|
}
|
|
41541
41753
|
|
|
41542
41754
|
// src/commands/prompts.ts
|
|
@@ -48903,29 +49115,40 @@ function primeTreeLogSyncFromState(stateFilePath2, log, state) {
|
|
|
48903
49115
|
lastCheckpointJson: JSON.stringify(toCheckpoint(state))
|
|
48904
49116
|
});
|
|
48905
49117
|
}
|
|
49118
|
+
function ensureTreeLogSync(stateFilePath2, seed) {
|
|
49119
|
+
const logPath = treeLogPathForStateFile(stateFilePath2);
|
|
49120
|
+
let sync = syncStates.get(stateFilePath2);
|
|
49121
|
+
if (!sync || sync.log.filePath !== logPath) {
|
|
49122
|
+
const existing = loadTreeLog(logPath);
|
|
49123
|
+
if (existing) {
|
|
49124
|
+
const materialized = materializeAtHead(existing);
|
|
49125
|
+
sync = {
|
|
49126
|
+
log: existing,
|
|
49127
|
+
lastMessages: materialized?.messages ?? [],
|
|
49128
|
+
lastCheckpointJson: JSON.stringify(materialized?.state ?? null)
|
|
49129
|
+
};
|
|
49130
|
+
} else {
|
|
49131
|
+
const log = createTreeLog(logPath, {
|
|
49132
|
+
taskName: seed.taskName,
|
|
49133
|
+
agentId: seed.agentId,
|
|
49134
|
+
...seed.originalMessage ? { originalMessage: seed.originalMessage } : {}
|
|
49135
|
+
});
|
|
49136
|
+
sync = { log, lastMessages: [], lastCheckpointJson: "null" };
|
|
49137
|
+
}
|
|
49138
|
+
syncStates.set(stateFilePath2, sync);
|
|
49139
|
+
}
|
|
49140
|
+
return sync;
|
|
49141
|
+
}
|
|
49142
|
+
function getOrLoadTreeLogSync(stateFilePath2, seed) {
|
|
49143
|
+
return ensureTreeLogSync(stateFilePath2, seed).log;
|
|
49144
|
+
}
|
|
48906
49145
|
function syncTreeLogWithState(stateFilePath2, state) {
|
|
48907
49146
|
try {
|
|
48908
|
-
const
|
|
48909
|
-
|
|
48910
|
-
|
|
48911
|
-
|
|
48912
|
-
|
|
48913
|
-
const materialized = materializeAtHead(existing);
|
|
48914
|
-
sync = {
|
|
48915
|
-
log: existing,
|
|
48916
|
-
lastMessages: materialized?.messages ?? [],
|
|
48917
|
-
lastCheckpointJson: JSON.stringify(materialized?.state ?? null)
|
|
48918
|
-
};
|
|
48919
|
-
} else {
|
|
48920
|
-
const log = createTreeLog(logPath, {
|
|
48921
|
-
taskName: state.taskName,
|
|
48922
|
-
agentId: state.agentId,
|
|
48923
|
-
...state.originalMessage ? { originalMessage: state.originalMessage } : {}
|
|
48924
|
-
});
|
|
48925
|
-
sync = { log, lastMessages: [], lastCheckpointJson: "null" };
|
|
48926
|
-
}
|
|
48927
|
-
syncStates.set(stateFilePath2, sync);
|
|
48928
|
-
}
|
|
49147
|
+
const sync = ensureTreeLogSync(stateFilePath2, {
|
|
49148
|
+
taskName: state.taskName,
|
|
49149
|
+
agentId: state.agentId,
|
|
49150
|
+
...state.originalMessage ? { originalMessage: state.originalMessage } : {}
|
|
49151
|
+
});
|
|
48929
49152
|
const nextMessages = state.messages ?? sync.lastMessages;
|
|
48930
49153
|
const messagesDelta = computeMessagesDelta(sync.lastMessages, nextMessages);
|
|
48931
49154
|
const checkpoint = toCheckpoint(state);
|
|
@@ -55472,9 +55695,8 @@ function stateFilePathForTask(taskName, stateDir) {
|
|
|
55472
55695
|
}
|
|
55473
55696
|
function recordOffloadedArtifact(details) {
|
|
55474
55697
|
const stateFilePath2 = details.options.ledger?.stateFilePath || stateFilePathForTask(details.taskName, details.stateDir);
|
|
55475
|
-
const logPath = treeLogPathForStateFile(stateFilePath2);
|
|
55476
55698
|
try {
|
|
55477
|
-
const log =
|
|
55699
|
+
const log = getOrLoadTreeLogSync(stateFilePath2, {
|
|
55478
55700
|
taskName: details.taskName,
|
|
55479
55701
|
agentId: details.options.ledger?.agentId || "unknown",
|
|
55480
55702
|
...details.options.ledger?.originalMessage ? { originalMessage: details.options.ledger.originalMessage } : {}
|
|
@@ -56803,6 +57025,30 @@ ${rulesContext}`;
|
|
|
56803
57025
|
return tools;
|
|
56804
57026
|
};
|
|
56805
57027
|
localTools = applyOffloadWrapping(localTools);
|
|
57028
|
+
const ledgerOffloadRecorder = offloadOptions ? (details) => {
|
|
57029
|
+
const result = offloadToolOutput(
|
|
57030
|
+
taskName,
|
|
57031
|
+
details.toolName,
|
|
57032
|
+
details.content,
|
|
57033
|
+
{
|
|
57034
|
+
...offloadOptions,
|
|
57035
|
+
threshold: 0,
|
|
57036
|
+
ledger: { stateFilePath: filePath, agentId, originalMessage: baseMessage },
|
|
57037
|
+
onEvent: (event) => {
|
|
57038
|
+
if (event.kind !== "offloaded") return;
|
|
57039
|
+
reportContextNotice({
|
|
57040
|
+
kind: "tool_output_offloaded",
|
|
57041
|
+
message: `${event.toolName} returned ${Math.ceil(event.outputLength / 4).toLocaleString()} estimated tokens and was offloaded to the context ledger to protect the context window.`,
|
|
57042
|
+
toolName: event.toolName,
|
|
57043
|
+
outputLength: event.outputLength,
|
|
57044
|
+
filePath: event.filePath
|
|
57045
|
+
});
|
|
57046
|
+
}
|
|
57047
|
+
},
|
|
57048
|
+
options.stateDir
|
|
57049
|
+
);
|
|
57050
|
+
return result.offloaded ? { reference: result.content } : void 0;
|
|
57051
|
+
} : void 0;
|
|
56806
57052
|
let toolsEnabled = true;
|
|
56807
57053
|
const checkpointHasConfigChanges = (result) => Boolean(result.model) || result.tools === true || result.sandbox !== void 0;
|
|
56808
57054
|
const rebuildCheckpointTools = () => applyOffloadWrapping(
|
|
@@ -57053,6 +57299,7 @@ Saving state... done. Session saved to ${filePath}`);
|
|
|
57053
57299
|
stream: true,
|
|
57054
57300
|
streamCallbacks: currentStreamCallbacks,
|
|
57055
57301
|
localTools,
|
|
57302
|
+
...ledgerOffloadRecorder ? { offloadRecorder: ledgerOffloadRecorder } : {},
|
|
57056
57303
|
trackProgress: options.track ? taskName : void 0,
|
|
57057
57304
|
// Mid-run steering queue (Enter while streaming): the UI owns the
|
|
57058
57305
|
// queue; the SDK drains it at session boundaries and ends in-flight
|
|
@@ -60036,9 +60283,9 @@ import { execFileSync } from "child_process";
|
|
|
60036
60283
|
// src/lib/persona-init.ts
|
|
60037
60284
|
init_credential_store();
|
|
60038
60285
|
|
|
60039
|
-
// ../../node_modules/.pnpm/@runtypelabs+persona@3.
|
|
60040
|
-
var S =
|
|
60041
|
-
var c = S
|
|
60286
|
+
// ../../node_modules/.pnpm/@runtypelabs+persona@3.34.0/node_modules/@runtypelabs/persona/dist/codegen.js
|
|
60287
|
+
var S = "3.34.0";
|
|
60288
|
+
var c = S;
|
|
60042
60289
|
function u(e) {
|
|
60043
60290
|
if (e !== void 0) return typeof e == "string" ? e : Array.isArray(e) ? `[${e.map((r) => r.toString()).join(", ")}]` : e.toString();
|
|
60044
60291
|
}
|
|
@@ -60200,7 +60447,7 @@ function I(e, r = "esm", n) {
|
|
|
60200
60447
|
let s = { ...e };
|
|
60201
60448
|
delete s.postprocessMessage, delete s.initialMessages;
|
|
60202
60449
|
let o = n ? { ...n, hooks: T(n.hooks) } : void 0;
|
|
60203
|
-
return r === "esm" ? W(s, o) : r === "script-installer" ?
|
|
60450
|
+
return r === "esm" ? W(s, o) : r === "script-installer" ? D(s, o) : r === "script-advanced" ? F(s, o) : r === "react-component" ? H(s, o) : r === "react-advanced" ? N(s, o) : k(s, o);
|
|
60204
60451
|
}
|
|
60205
60452
|
function W(e, r) {
|
|
60206
60453
|
let n = r == null ? void 0 : r.hooks, s = h(e), o = s !== "plain", t = ["import '@runtypelabs/persona/widget.css';", "import { initAgentWidget, markdownPostprocessor } from '@runtypelabs/persona';", "", "initAgentWidget({", ` target: '${g(r)}',`, " config: {"];
|
|
@@ -60296,11 +60543,11 @@ function P(e) {
|
|
|
60296
60543
|
}
|
|
60297
60544
|
return s;
|
|
60298
60545
|
}
|
|
60299
|
-
function
|
|
60546
|
+
function D(e, r) {
|
|
60300
60547
|
let n = P(e), o = !!(r != null && r.windowKey || r != null && r.target) ? { config: n, ...r != null && r.windowKey ? { windowKey: r.windowKey } : {}, ...r != null && r.target ? { target: r.target } : {} } : n, t = JSON.stringify(o, null, 0).replace(/'/g, "'");
|
|
60301
60548
|
return `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/install.global.js" data-config='${t}'></script>`;
|
|
60302
60549
|
}
|
|
60303
|
-
function
|
|
60550
|
+
function k(e, r) {
|
|
60304
60551
|
let n = r == null ? void 0 : r.hooks, s = h(e), o = s !== "plain", t = ["<!-- Load CSS -->", `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/widget.css" />`, "", "<!-- Load JavaScript -->", `<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@${c}/dist/index.global.js"></script>`, "", "<!-- Initialize widget -->", "<script>", " var handle = window.AgentWidget.initAgentWidget({", ` target: '${g(r)}',`, ...r != null && r.windowKey ? [` windowKey: '${r.windowKey}',`] : [], " config: {"];
|
|
60305
60552
|
return e.apiUrl && t.push(` apiUrl: "${e.apiUrl}",`), e.clientToken && t.push(` clientToken: "${e.clientToken}",`), e.flowId && t.push(` flowId: "${e.flowId}",`), o && t.push(` parserType: "${s}",`), e.theme && typeof e.theme == "object" && Object.keys(e.theme).length > 0 && l(t, "theme", e.theme, " "), e.launcher && l(t, "launcher", e.launcher, " "), e.copy && (t.push(" copy: {"), Object.entries(e.copy).forEach(([i, a]) => {
|
|
60306
60553
|
t.push(` ${i}: "${a}",`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.1",
|
|
4
4
|
"description": "Command-line interface for Runtype AI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,11 +24,11 @@
|
|
|
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.
|
|
27
|
+
"@runtypelabs/sdk": "4.12.0",
|
|
28
28
|
"@runtypelabs/terminal-animations": "0.2.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@runtypelabs/persona": "3.
|
|
31
|
+
"@runtypelabs/persona": "3.34.0",
|
|
32
32
|
"@types/express": "^5.0.6",
|
|
33
33
|
"@types/micromatch": "^4.0.9",
|
|
34
34
|
"@types/node": "^25.3.3",
|
|
@@ -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.
|
|
42
|
+
"@runtypelabs/shared": "1.26.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=22.0.0"
|