@runtypelabs/cli 2.6.2 → 2.7.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 +436 -13
- package/package.json +3 -3
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -10906,7 +10906,8 @@ var require_builtin_tools_registry = __commonJS({
|
|
|
10906
10906
|
TEXT_TO_SPEECH: "text_to_speech",
|
|
10907
10907
|
VOICE_PROCESSING: "voice_processing",
|
|
10908
10908
|
THIRD_PARTY_API: "third_party_api",
|
|
10909
|
-
ARTIFACT: "artifact"
|
|
10909
|
+
ARTIFACT: "artifact",
|
|
10910
|
+
DATA_MANAGEMENT: "data_management"
|
|
10910
10911
|
};
|
|
10911
10912
|
exports.BuiltInToolIdPrefix = {
|
|
10912
10913
|
BUILTIN: "builtin",
|
|
@@ -11439,6 +11440,170 @@ var require_builtin_tools_registry = __commonJS({
|
|
|
11439
11440
|
},
|
|
11440
11441
|
executionHint: "platform",
|
|
11441
11442
|
hidden: true
|
|
11443
|
+
},
|
|
11444
|
+
// Record Management Tools — CRUD operations on Runtype records
|
|
11445
|
+
{
|
|
11446
|
+
id: "runtype_record_upsert",
|
|
11447
|
+
name: "Upsert Record",
|
|
11448
|
+
description: "Create or update a Runtype record with structured metadata. Records are identified by type and name. If a record with the same type and name already exists, it will be updated based on the merge strategy.",
|
|
11449
|
+
category: exports.BuiltInToolCategory.DATA_MANAGEMENT,
|
|
11450
|
+
providers: [exports.BuiltInToolProvider.MULTI],
|
|
11451
|
+
parametersSchema: {
|
|
11452
|
+
type: "object",
|
|
11453
|
+
properties: {
|
|
11454
|
+
type: {
|
|
11455
|
+
type: "string",
|
|
11456
|
+
description: 'Record type category (e.g., "customer", "order", "note", "task")'
|
|
11457
|
+
},
|
|
11458
|
+
name: {
|
|
11459
|
+
type: "string",
|
|
11460
|
+
description: "Unique name for this record within its type"
|
|
11461
|
+
},
|
|
11462
|
+
metadata: {
|
|
11463
|
+
type: "object",
|
|
11464
|
+
description: "JSON object containing the record data"
|
|
11465
|
+
},
|
|
11466
|
+
mergeStrategy: {
|
|
11467
|
+
type: "string",
|
|
11468
|
+
description: 'How to handle existing data when updating: "merge" (shallow merge, new keys override) or "replace" (completely replace metadata)',
|
|
11469
|
+
enum: ["merge", "replace"],
|
|
11470
|
+
default: "merge"
|
|
11471
|
+
}
|
|
11472
|
+
},
|
|
11473
|
+
required: ["type", "name", "metadata"]
|
|
11474
|
+
},
|
|
11475
|
+
executionHint: "platform",
|
|
11476
|
+
requiresApiKey: false,
|
|
11477
|
+
platformKeySupport: false
|
|
11478
|
+
},
|
|
11479
|
+
{
|
|
11480
|
+
id: "runtype_record_batch_upsert",
|
|
11481
|
+
name: "Batch Upsert Records",
|
|
11482
|
+
description: "Create or update multiple Runtype records at once in a single transaction. Each record is identified by type and name. Maximum 100 records per call.",
|
|
11483
|
+
category: exports.BuiltInToolCategory.DATA_MANAGEMENT,
|
|
11484
|
+
providers: [exports.BuiltInToolProvider.MULTI],
|
|
11485
|
+
parametersSchema: {
|
|
11486
|
+
type: "object",
|
|
11487
|
+
properties: {
|
|
11488
|
+
records: {
|
|
11489
|
+
type: "array",
|
|
11490
|
+
description: "Array of records to upsert (max 100)",
|
|
11491
|
+
items: {
|
|
11492
|
+
type: "object",
|
|
11493
|
+
properties: {
|
|
11494
|
+
type: {
|
|
11495
|
+
type: "string",
|
|
11496
|
+
description: "Record type category"
|
|
11497
|
+
},
|
|
11498
|
+
name: {
|
|
11499
|
+
type: "string",
|
|
11500
|
+
description: "Unique name within this type"
|
|
11501
|
+
},
|
|
11502
|
+
metadata: {
|
|
11503
|
+
type: "object",
|
|
11504
|
+
description: "JSON object containing the record data"
|
|
11505
|
+
}
|
|
11506
|
+
},
|
|
11507
|
+
required: ["type", "name", "metadata"]
|
|
11508
|
+
}
|
|
11509
|
+
},
|
|
11510
|
+
mergeStrategy: {
|
|
11511
|
+
type: "string",
|
|
11512
|
+
description: 'How to handle existing data: "merge" or "replace". Applies to all records.',
|
|
11513
|
+
enum: ["merge", "replace"],
|
|
11514
|
+
default: "merge"
|
|
11515
|
+
}
|
|
11516
|
+
},
|
|
11517
|
+
required: ["records"]
|
|
11518
|
+
},
|
|
11519
|
+
executionHint: "platform",
|
|
11520
|
+
requiresApiKey: false,
|
|
11521
|
+
platformKeySupport: false
|
|
11522
|
+
},
|
|
11523
|
+
{
|
|
11524
|
+
id: "runtype_record_get",
|
|
11525
|
+
name: "Get Record",
|
|
11526
|
+
description: "Retrieve a single Runtype record by its type and name. Returns the full record including metadata, or null if not found.",
|
|
11527
|
+
category: exports.BuiltInToolCategory.DATA_MANAGEMENT,
|
|
11528
|
+
providers: [exports.BuiltInToolProvider.MULTI],
|
|
11529
|
+
parametersSchema: {
|
|
11530
|
+
type: "object",
|
|
11531
|
+
properties: {
|
|
11532
|
+
type: {
|
|
11533
|
+
type: "string",
|
|
11534
|
+
description: "Record type to look up"
|
|
11535
|
+
},
|
|
11536
|
+
name: {
|
|
11537
|
+
type: "string",
|
|
11538
|
+
description: "Record name to look up"
|
|
11539
|
+
}
|
|
11540
|
+
},
|
|
11541
|
+
required: ["type", "name"]
|
|
11542
|
+
},
|
|
11543
|
+
executionHint: "platform",
|
|
11544
|
+
requiresApiKey: false,
|
|
11545
|
+
platformKeySupport: false
|
|
11546
|
+
},
|
|
11547
|
+
{
|
|
11548
|
+
id: "runtype_record_list",
|
|
11549
|
+
name: "List Records",
|
|
11550
|
+
description: "List and search Runtype records with optional filtering by type and text search. Returns paginated results.",
|
|
11551
|
+
category: exports.BuiltInToolCategory.DATA_MANAGEMENT,
|
|
11552
|
+
providers: [exports.BuiltInToolProvider.MULTI],
|
|
11553
|
+
parametersSchema: {
|
|
11554
|
+
type: "object",
|
|
11555
|
+
properties: {
|
|
11556
|
+
type: {
|
|
11557
|
+
type: "string",
|
|
11558
|
+
description: "Filter by record type (optional)"
|
|
11559
|
+
},
|
|
11560
|
+
search: {
|
|
11561
|
+
type: "string",
|
|
11562
|
+
description: "Text search across record names (optional, case-insensitive)"
|
|
11563
|
+
},
|
|
11564
|
+
limit: {
|
|
11565
|
+
type: "number",
|
|
11566
|
+
description: "Maximum number of records to return (1-50, default 20)",
|
|
11567
|
+
minimum: 1,
|
|
11568
|
+
maximum: 50,
|
|
11569
|
+
default: 20
|
|
11570
|
+
},
|
|
11571
|
+
offset: {
|
|
11572
|
+
type: "number",
|
|
11573
|
+
description: "Number of records to skip for pagination (default 0)",
|
|
11574
|
+
minimum: 0,
|
|
11575
|
+
default: 0
|
|
11576
|
+
}
|
|
11577
|
+
},
|
|
11578
|
+
required: []
|
|
11579
|
+
},
|
|
11580
|
+
executionHint: "platform",
|
|
11581
|
+
requiresApiKey: false,
|
|
11582
|
+
platformKeySupport: false
|
|
11583
|
+
},
|
|
11584
|
+
{
|
|
11585
|
+
id: "runtype_record_delete",
|
|
11586
|
+
name: "Delete Record",
|
|
11587
|
+
description: "Delete a Runtype record by its type and name. Returns whether the record was found and deleted.",
|
|
11588
|
+
category: exports.BuiltInToolCategory.DATA_MANAGEMENT,
|
|
11589
|
+
providers: [exports.BuiltInToolProvider.MULTI],
|
|
11590
|
+
parametersSchema: {
|
|
11591
|
+
type: "object",
|
|
11592
|
+
properties: {
|
|
11593
|
+
type: {
|
|
11594
|
+
type: "string",
|
|
11595
|
+
description: "Record type of the record to delete"
|
|
11596
|
+
},
|
|
11597
|
+
name: {
|
|
11598
|
+
type: "string",
|
|
11599
|
+
description: "Name of the record to delete"
|
|
11600
|
+
}
|
|
11601
|
+
},
|
|
11602
|
+
required: ["type", "name"]
|
|
11603
|
+
},
|
|
11604
|
+
executionHint: "platform",
|
|
11605
|
+
requiresApiKey: false,
|
|
11606
|
+
platformKeySupport: false
|
|
11442
11607
|
}
|
|
11443
11608
|
];
|
|
11444
11609
|
exports.BUILTIN_TOOLS_REGISTRY = [
|
|
@@ -11655,6 +11820,7 @@ var require_generated_model_routing = __commonJS({
|
|
|
11655
11820
|
"glm-4.7-flashx": ["vercel"],
|
|
11656
11821
|
"glm-5": ["vercel"],
|
|
11657
11822
|
"glm-5-turbo": ["vercel"],
|
|
11823
|
+
"glm-5v-turbo": ["vercel"],
|
|
11658
11824
|
"gpt-3-5-turbo": ["vercel"],
|
|
11659
11825
|
"gpt-3-5-turbo-instruct": ["vercel"],
|
|
11660
11826
|
"gpt-3.5-turbo": ["openai", "vercel"],
|
|
@@ -12117,6 +12283,7 @@ var require_generated_model_routing = __commonJS({
|
|
|
12117
12283
|
"glm-4-7-flashx": ["vercel"],
|
|
12118
12284
|
"glm-5": ["vercel"],
|
|
12119
12285
|
"glm-5-turbo": ["vercel"],
|
|
12286
|
+
"glm-5v-turbo": ["vercel"],
|
|
12120
12287
|
"gpt-3-5-turbo": ["openai", "vercel"],
|
|
12121
12288
|
"gpt-3-5-turbo-0125": ["openai"],
|
|
12122
12289
|
"gpt-3-5-turbo-0125-batch": ["openai"],
|
|
@@ -12917,6 +13084,9 @@ var require_generated_model_routing = __commonJS({
|
|
|
12917
13084
|
"glm-5-turbo": {
|
|
12918
13085
|
"vercel": "zai/glm-5-turbo"
|
|
12919
13086
|
},
|
|
13087
|
+
"glm-5v-turbo": {
|
|
13088
|
+
"vercel": "zai/glm-5v-turbo"
|
|
13089
|
+
},
|
|
12920
13090
|
"gpt-3-5-turbo": {
|
|
12921
13091
|
"openai": "gpt-3.5-turbo",
|
|
12922
13092
|
"vercel": "openai/gpt-3-5-turbo"
|
|
@@ -15401,8 +15571,8 @@ var require_provider_routing = __commonJS({
|
|
|
15401
15571
|
});
|
|
15402
15572
|
|
|
15403
15573
|
// src/index.ts
|
|
15404
|
-
import { Command as
|
|
15405
|
-
import
|
|
15574
|
+
import { Command as Command22 } from "commander";
|
|
15575
|
+
import chalk29 from "chalk";
|
|
15406
15576
|
import { config as loadEnv } from "dotenv";
|
|
15407
15577
|
|
|
15408
15578
|
// src/commands/auth.ts
|
|
@@ -16433,6 +16603,16 @@ authCommand.command("status").description("Show authentication status").option("
|
|
|
16433
16603
|
const { waitUntilExit } = render(React.createElement(App));
|
|
16434
16604
|
await waitUntilExit();
|
|
16435
16605
|
});
|
|
16606
|
+
authCommand.command("export-key").description("Print the stored API key to stdout (for use in scripts and .env files)").action(async () => {
|
|
16607
|
+
const store = new CredentialStore();
|
|
16608
|
+
const apiKey = await store.getApiKey();
|
|
16609
|
+
if (!apiKey) {
|
|
16610
|
+
console.error("Not authenticated. Run `runtype auth login` first.");
|
|
16611
|
+
process.exit(1);
|
|
16612
|
+
return;
|
|
16613
|
+
}
|
|
16614
|
+
process.stdout.write(apiKey);
|
|
16615
|
+
});
|
|
16436
16616
|
authCommand.command("logout").description("Remove stored credentials").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
16437
16617
|
const store = new CredentialStore();
|
|
16438
16618
|
if (!isTTY(options)) {
|
|
@@ -32858,11 +33038,254 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
|
|
|
32858
33038
|
await waitUntilExit();
|
|
32859
33039
|
});
|
|
32860
33040
|
|
|
33041
|
+
// src/commands/tail.ts
|
|
33042
|
+
import { Command as Command21 } from "commander";
|
|
33043
|
+
import chalk27 from "chalk";
|
|
33044
|
+
function abbreviateId(id) {
|
|
33045
|
+
const underscoreIdx = id.lastIndexOf("_");
|
|
33046
|
+
if (underscoreIdx === -1) {
|
|
33047
|
+
return id.length > 8 ? `${id.slice(0, 8)}...` : id;
|
|
33048
|
+
}
|
|
33049
|
+
const prefix = id.slice(0, underscoreIdx);
|
|
33050
|
+
const suffix = id.slice(underscoreIdx + 1);
|
|
33051
|
+
return `${prefix}_${suffix.slice(0, 4)}...`;
|
|
33052
|
+
}
|
|
33053
|
+
function formatTime(ts) {
|
|
33054
|
+
const d = new Date(ts);
|
|
33055
|
+
const hh = String(d.getHours()).padStart(2, "0");
|
|
33056
|
+
const mm = String(d.getMinutes()).padStart(2, "0");
|
|
33057
|
+
const ss = String(d.getSeconds()).padStart(2, "0");
|
|
33058
|
+
const ms = String(d.getMilliseconds()).padStart(3, "0");
|
|
33059
|
+
return `${hh}:${mm}:${ss}.${ms}`;
|
|
33060
|
+
}
|
|
33061
|
+
var LEVEL_COLORS = {
|
|
33062
|
+
debug: chalk27.gray,
|
|
33063
|
+
info: chalk27.blue,
|
|
33064
|
+
warn: chalk27.yellow,
|
|
33065
|
+
error: chalk27.red
|
|
33066
|
+
};
|
|
33067
|
+
function levelBadge(level, useColor) {
|
|
33068
|
+
const tag = level.toUpperCase().padEnd(5);
|
|
33069
|
+
if (!useColor) return `[${tag}]`;
|
|
33070
|
+
const colorFn = LEVEL_COLORS[level] || chalk27.white;
|
|
33071
|
+
return colorFn(`[${tag}]`);
|
|
33072
|
+
}
|
|
33073
|
+
function categoryBadge(category, useColor) {
|
|
33074
|
+
if (!useColor) return `[${category}]`;
|
|
33075
|
+
return chalk27.magenta(`[${category}]`);
|
|
33076
|
+
}
|
|
33077
|
+
function formatTailData(data) {
|
|
33078
|
+
return Object.entries(data).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(" ");
|
|
33079
|
+
}
|
|
33080
|
+
function formatContextIds(event, useColor) {
|
|
33081
|
+
const ids = [];
|
|
33082
|
+
if (event.executionId) ids.push(`exec=${abbreviateId(event.executionId)}`);
|
|
33083
|
+
if (event.flowId) ids.push(`flow=${abbreviateId(event.flowId)}`);
|
|
33084
|
+
if (event.agentId) ids.push(`agent=${abbreviateId(event.agentId)}`);
|
|
33085
|
+
if (event.surfaceId) ids.push(`surface=${abbreviateId(event.surfaceId)}`);
|
|
33086
|
+
if (event.requestId) ids.push(`req=${abbreviateId(event.requestId)}`);
|
|
33087
|
+
if (event.conversationId) ids.push(`conv=${abbreviateId(event.conversationId)}`);
|
|
33088
|
+
if (ids.length === 0) return "";
|
|
33089
|
+
const text = ids.join(" ");
|
|
33090
|
+
return useColor ? chalk27.gray(` ${text}`) : ` ${text}`;
|
|
33091
|
+
}
|
|
33092
|
+
function formatEvent(event, useColor) {
|
|
33093
|
+
const time = useColor ? chalk27.gray(formatTime(event.timestamp)) : formatTime(event.timestamp);
|
|
33094
|
+
const level = levelBadge(event.level, useColor);
|
|
33095
|
+
const cat = categoryBadge(event.category, useColor);
|
|
33096
|
+
const ctx = formatContextIds(event, useColor);
|
|
33097
|
+
const data = event.tailData && Object.keys(event.tailData).length > 0 ? useColor ? chalk27.gray(` | ${formatTailData(event.tailData)}`) : ` | ${formatTailData(event.tailData)}` : "";
|
|
33098
|
+
return `${time} ${level} ${cat} ${event.message}${data}${ctx}`;
|
|
33099
|
+
}
|
|
33100
|
+
async function consumeSSEStream(reader, options, signal) {
|
|
33101
|
+
const decoder = new TextDecoder();
|
|
33102
|
+
let buffer = "";
|
|
33103
|
+
const useColor = options.color;
|
|
33104
|
+
while (!signal.aborted) {
|
|
33105
|
+
const { done, value } = await reader.read();
|
|
33106
|
+
if (done) return "eof";
|
|
33107
|
+
buffer += decoder.decode(value, { stream: true });
|
|
33108
|
+
let boundary;
|
|
33109
|
+
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
33110
|
+
const chunk = buffer.slice(0, boundary);
|
|
33111
|
+
buffer = buffer.slice(boundary + 2);
|
|
33112
|
+
const dataLines = [];
|
|
33113
|
+
for (const line of chunk.split("\n")) {
|
|
33114
|
+
if (line.startsWith("data: ")) {
|
|
33115
|
+
dataLines.push(line.slice(6));
|
|
33116
|
+
}
|
|
33117
|
+
}
|
|
33118
|
+
if (dataLines.length === 0) continue;
|
|
33119
|
+
const raw = dataLines.join("\n");
|
|
33120
|
+
let msg;
|
|
33121
|
+
try {
|
|
33122
|
+
msg = JSON.parse(raw);
|
|
33123
|
+
} catch {
|
|
33124
|
+
continue;
|
|
33125
|
+
}
|
|
33126
|
+
switch (msg.type) {
|
|
33127
|
+
case "tail_event":
|
|
33128
|
+
if (options.json) {
|
|
33129
|
+
process.stdout.write(JSON.stringify(msg.event) + "\n");
|
|
33130
|
+
} else {
|
|
33131
|
+
process.stdout.write(formatEvent(msg.event, useColor) + "\n");
|
|
33132
|
+
}
|
|
33133
|
+
break;
|
|
33134
|
+
case "tail_gap":
|
|
33135
|
+
process.stderr.write(
|
|
33136
|
+
(useColor ? chalk27.yellow(`[warn] Dropped ${msg.droppedCount} event(s) between ${msg.fromTimestamp} and ${msg.toTimestamp}`) : `[warn] Dropped ${msg.droppedCount} event(s) between ${msg.fromTimestamp} and ${msg.toTimestamp}`) + "\n"
|
|
33137
|
+
);
|
|
33138
|
+
break;
|
|
33139
|
+
case "tail_connected":
|
|
33140
|
+
process.stderr.write(
|
|
33141
|
+
(useColor ? chalk27.green(`Connected to tail session ${msg.sessionId}`) : `Connected to tail session ${msg.sessionId}`) + "\n"
|
|
33142
|
+
);
|
|
33143
|
+
break;
|
|
33144
|
+
case "tail_error":
|
|
33145
|
+
process.stderr.write(
|
|
33146
|
+
(useColor ? chalk27.red(`[error] ${msg.error}`) : `[error] ${msg.error}`) + "\n"
|
|
33147
|
+
);
|
|
33148
|
+
break;
|
|
33149
|
+
}
|
|
33150
|
+
}
|
|
33151
|
+
}
|
|
33152
|
+
return "aborted";
|
|
33153
|
+
}
|
|
33154
|
+
async function createSession(apiUrl, apiKey, filters) {
|
|
33155
|
+
const filter = {};
|
|
33156
|
+
const arrayFields = {
|
|
33157
|
+
flowId: "flowIds",
|
|
33158
|
+
agentId: "agentIds",
|
|
33159
|
+
surfaceId: "surfaceIds",
|
|
33160
|
+
executionId: "executionIds",
|
|
33161
|
+
level: "levels",
|
|
33162
|
+
category: "categories"
|
|
33163
|
+
};
|
|
33164
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
33165
|
+
if (v !== void 0 && arrayFields[k]) {
|
|
33166
|
+
filter[arrayFields[k]] = [v];
|
|
33167
|
+
}
|
|
33168
|
+
}
|
|
33169
|
+
const body = Object.keys(filter).length > 0 ? { filter } : {};
|
|
33170
|
+
const res = await fetch(`${apiUrl}/v1/tail/sessions`, {
|
|
33171
|
+
method: "POST",
|
|
33172
|
+
headers: {
|
|
33173
|
+
Authorization: `Bearer ${apiKey}`,
|
|
33174
|
+
"Content-Type": "application/json",
|
|
33175
|
+
"User-Agent": `Runtype-CLI/${getCliVersion()}`
|
|
33176
|
+
},
|
|
33177
|
+
body: JSON.stringify(body)
|
|
33178
|
+
});
|
|
33179
|
+
if (!res.ok) {
|
|
33180
|
+
const text = await res.text().catch(() => "");
|
|
33181
|
+
throw new Error(`Failed to create tail session: ${res.status} ${res.statusText}${text ? ` \u2014 ${text}` : ""}`);
|
|
33182
|
+
}
|
|
33183
|
+
return await res.json();
|
|
33184
|
+
}
|
|
33185
|
+
async function connectAndStream(sseUrl, apiKey, options, signal) {
|
|
33186
|
+
const res = await fetch(sseUrl, {
|
|
33187
|
+
headers: {
|
|
33188
|
+
Authorization: `Bearer ${apiKey}`,
|
|
33189
|
+
Accept: "text/event-stream",
|
|
33190
|
+
"User-Agent": `Runtype-CLI/${getCliVersion()}`
|
|
33191
|
+
},
|
|
33192
|
+
signal
|
|
33193
|
+
});
|
|
33194
|
+
if (!res.ok) {
|
|
33195
|
+
const text = await res.text().catch(() => "");
|
|
33196
|
+
throw new Error(`SSE connection failed: ${res.status} ${res.statusText}${text ? ` \u2014 ${text}` : ""}`);
|
|
33197
|
+
}
|
|
33198
|
+
if (!res.body) {
|
|
33199
|
+
throw new Error("SSE response has no body");
|
|
33200
|
+
}
|
|
33201
|
+
const reader = res.body.getReader();
|
|
33202
|
+
try {
|
|
33203
|
+
return await consumeSSEStream(reader, options, signal);
|
|
33204
|
+
} finally {
|
|
33205
|
+
reader.releaseLock();
|
|
33206
|
+
}
|
|
33207
|
+
}
|
|
33208
|
+
var BASE_DELAY_MS = 1e3;
|
|
33209
|
+
var MAX_DELAY_MS = 3e4;
|
|
33210
|
+
var MAX_ATTEMPTS = 10;
|
|
33211
|
+
async function runTail(options) {
|
|
33212
|
+
const apiKey = await ensureAuth();
|
|
33213
|
+
if (!apiKey) return;
|
|
33214
|
+
const apiUrl = getApiUrl();
|
|
33215
|
+
const filters = {
|
|
33216
|
+
flowId: options.flow,
|
|
33217
|
+
agentId: options.agent,
|
|
33218
|
+
surfaceId: options.surface,
|
|
33219
|
+
executionId: options.execution,
|
|
33220
|
+
level: options.level,
|
|
33221
|
+
category: options.category
|
|
33222
|
+
};
|
|
33223
|
+
const useColor = options.color;
|
|
33224
|
+
const activeFilters = Object.entries(filters).filter(([, v]) => v !== void 0).map(([k, v]) => `${k}=${v}`);
|
|
33225
|
+
process.stderr.write(
|
|
33226
|
+
(useColor ? chalk27.gray(`Connecting to ${apiUrl}...${activeFilters.length ? ` filters: ${activeFilters.join(", ")}` : ""}`) : `Connecting to ${apiUrl}...${activeFilters.length ? ` filters: ${activeFilters.join(", ")}` : ""}`) + "\n"
|
|
33227
|
+
);
|
|
33228
|
+
const controller = new AbortController();
|
|
33229
|
+
let shuttingDown = false;
|
|
33230
|
+
const shutdown = () => {
|
|
33231
|
+
if (shuttingDown) return;
|
|
33232
|
+
shuttingDown = true;
|
|
33233
|
+
process.stderr.write(
|
|
33234
|
+
(useColor ? chalk27.gray("\nDisconnecting...") : "\nDisconnecting...") + "\n"
|
|
33235
|
+
);
|
|
33236
|
+
controller.abort();
|
|
33237
|
+
};
|
|
33238
|
+
process.on("SIGINT", shutdown);
|
|
33239
|
+
process.on("SIGTERM", shutdown);
|
|
33240
|
+
let attempt = 0;
|
|
33241
|
+
while (!shuttingDown && attempt < MAX_ATTEMPTS) {
|
|
33242
|
+
try {
|
|
33243
|
+
const session = await createSession(apiUrl, apiKey, filters);
|
|
33244
|
+
attempt = 0;
|
|
33245
|
+
const result = await connectAndStream(session.sseUrl, apiKey, options, controller.signal);
|
|
33246
|
+
if (result === "aborted" || shuttingDown) break;
|
|
33247
|
+
process.stderr.write(
|
|
33248
|
+
(useColor ? chalk27.yellow("Stream ended, reconnecting...") : "Stream ended, reconnecting...") + "\n"
|
|
33249
|
+
);
|
|
33250
|
+
} catch (err) {
|
|
33251
|
+
if (shuttingDown || controller.signal.aborted) break;
|
|
33252
|
+
attempt++;
|
|
33253
|
+
const delay = Math.min(BASE_DELAY_MS * Math.pow(2, attempt - 1), MAX_DELAY_MS);
|
|
33254
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
33255
|
+
process.stderr.write(
|
|
33256
|
+
(useColor ? chalk27.red(`Connection error: ${message}`) : `Connection error: ${message}`) + "\n"
|
|
33257
|
+
);
|
|
33258
|
+
if (attempt >= MAX_ATTEMPTS) {
|
|
33259
|
+
process.stderr.write(
|
|
33260
|
+
(useColor ? chalk27.red(`Max reconnect attempts (${MAX_ATTEMPTS}) reached. Exiting.`) : `Max reconnect attempts (${MAX_ATTEMPTS}) reached. Exiting.`) + "\n"
|
|
33261
|
+
);
|
|
33262
|
+
process.exit(1);
|
|
33263
|
+
}
|
|
33264
|
+
process.stderr.write(
|
|
33265
|
+
(useColor ? chalk27.gray(`Retrying in ${delay / 1e3}s (attempt ${attempt}/${MAX_ATTEMPTS})...`) : `Retrying in ${delay / 1e3}s (attempt ${attempt}/${MAX_ATTEMPTS})...`) + "\n"
|
|
33266
|
+
);
|
|
33267
|
+
await new Promise((resolve8) => {
|
|
33268
|
+
const timer = setTimeout(resolve8, delay);
|
|
33269
|
+
const onAbort = () => {
|
|
33270
|
+
clearTimeout(timer);
|
|
33271
|
+
resolve8();
|
|
33272
|
+
};
|
|
33273
|
+
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
33274
|
+
});
|
|
33275
|
+
}
|
|
33276
|
+
}
|
|
33277
|
+
process.removeListener("SIGINT", shutdown);
|
|
33278
|
+
process.removeListener("SIGTERM", shutdown);
|
|
33279
|
+
}
|
|
33280
|
+
var tailCommand = new Command21("tail").description("Stream live execution logs from the Runtype API").option("--flow <id>", "Filter by flow ID").option("--agent <id>", "Filter by agent ID").option("--surface <id>", "Filter by surface ID").option("--execution <id>", "Filter by execution ID").option("--level <level>", "Filter by level (debug/info/warn/error)").option("--category <category>", "Filter by category (execution/agent/tool/model/system/error)").option("--json", "Output raw JSON (one object per line)").option("--no-color", "Disable color output").action(async (options) => {
|
|
33281
|
+
await runTail(options);
|
|
33282
|
+
});
|
|
33283
|
+
|
|
32861
33284
|
// src/index.ts
|
|
32862
33285
|
init_credential_store();
|
|
32863
33286
|
|
|
32864
33287
|
// src/lib/update-check.ts
|
|
32865
|
-
import
|
|
33288
|
+
import chalk28 from "chalk";
|
|
32866
33289
|
import Conf3 from "conf";
|
|
32867
33290
|
var UPDATE_CHECK_INTERVAL_MS = 12 * 60 * 60 * 1e3;
|
|
32868
33291
|
var UPDATE_NOTIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -32956,7 +33379,7 @@ function notifyFromCachedCliUpdate(args, options = {}) {
|
|
|
32956
33379
|
console.error(message);
|
|
32957
33380
|
});
|
|
32958
33381
|
notify(
|
|
32959
|
-
`${
|
|
33382
|
+
`${chalk28.yellow("Update available:")} ${chalk28.red(currentVersion)} ${chalk28.gray("->")} ${chalk28.green(latestVersion)} ${chalk28.gray(`(${getUpgradeCommand()})`)}`
|
|
32960
33383
|
);
|
|
32961
33384
|
store.set("lastNotifiedAt", now.toISOString());
|
|
32962
33385
|
store.set("lastNotifiedVersion", latestVersion);
|
|
@@ -32998,7 +33421,7 @@ function maybeNotifyAboutCliUpdate(args, options = {}) {
|
|
|
32998
33421
|
// src/index.ts
|
|
32999
33422
|
loadEnv();
|
|
33000
33423
|
setCliTitle();
|
|
33001
|
-
var program = new
|
|
33424
|
+
var program = new Command22();
|
|
33002
33425
|
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");
|
|
33003
33426
|
program.addCommand(initCommand);
|
|
33004
33427
|
program.addCommand(loginCommand);
|
|
@@ -33021,6 +33444,7 @@ program.addCommand(analyticsCommand);
|
|
|
33021
33444
|
program.addCommand(billingCommand);
|
|
33022
33445
|
program.addCommand(flowVersionsCommand);
|
|
33023
33446
|
program.addCommand(createMarathonCommand());
|
|
33447
|
+
program.addCommand(tailCommand);
|
|
33024
33448
|
program.exitOverride();
|
|
33025
33449
|
try {
|
|
33026
33450
|
const userArgs = process.argv.slice(2);
|
|
@@ -33034,15 +33458,15 @@ try {
|
|
|
33034
33458
|
} catch (error) {
|
|
33035
33459
|
const commanderError = error;
|
|
33036
33460
|
if (commanderError.code === "commander.missingArgument") {
|
|
33037
|
-
console.error(
|
|
33461
|
+
console.error(chalk29.red(`Error: ${commanderError.message}`));
|
|
33038
33462
|
process.exit(1);
|
|
33039
33463
|
} else if (commanderError.code === "commander.unknownOption") {
|
|
33040
|
-
console.error(
|
|
33464
|
+
console.error(chalk29.red(`Error: ${commanderError.message}`));
|
|
33041
33465
|
process.exit(1);
|
|
33042
33466
|
} else if (commanderError.code === "commander.help" || commanderError.code === "commander.version") {
|
|
33043
33467
|
process.exit(0);
|
|
33044
33468
|
} else {
|
|
33045
|
-
console.error(
|
|
33469
|
+
console.error(chalk29.red("An unexpected error occurred:"));
|
|
33046
33470
|
console.error(error);
|
|
33047
33471
|
process.exit(1);
|
|
33048
33472
|
}
|
|
@@ -33051,12 +33475,12 @@ async function handleNoCommand() {
|
|
|
33051
33475
|
const store = new CredentialStore();
|
|
33052
33476
|
const hasCredentials = await store.hasCredentials();
|
|
33053
33477
|
if (!hasCredentials) {
|
|
33054
|
-
console.log(
|
|
33478
|
+
console.log(chalk29.cyan("\nWelcome to Runtype CLI!\n"));
|
|
33055
33479
|
console.log("It looks like this is your first time. Run the setup wizard:");
|
|
33056
|
-
console.log(` ${
|
|
33480
|
+
console.log(` ${chalk29.green("runtype init")}
|
|
33057
33481
|
`);
|
|
33058
33482
|
console.log("Or see all available commands:");
|
|
33059
|
-
console.log(` ${
|
|
33483
|
+
console.log(` ${chalk29.green("runtype --help")}
|
|
33060
33484
|
`);
|
|
33061
33485
|
} else {
|
|
33062
33486
|
try {
|
|
@@ -33071,4 +33495,3 @@ async function handleNoCommand() {
|
|
|
33071
33495
|
}
|
|
33072
33496
|
}
|
|
33073
33497
|
}
|
|
33074
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Command-line interface for Runtype AI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"uuid": "^9.0.1",
|
|
23
23
|
"micromatch": "^4.0.8",
|
|
24
24
|
"yaml": "^2.8.3",
|
|
25
|
-
"@runtypelabs/
|
|
26
|
-
"@runtypelabs/
|
|
25
|
+
"@runtypelabs/sdk": "1.13.1",
|
|
26
|
+
"@runtypelabs/ink-components": "0.3.1",
|
|
27
27
|
"@runtypelabs/terminal-animations": "0.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|