@runtypelabs/cli 2.59.1 → 2.59.2

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 (84) hide show
  1. package/dist/chunk-0-T9NWjH.js +3899 -0
  2. package/dist/chunk-0x7UKC1U.js +17 -0
  3. package/dist/chunk-2ySxXtcg.js +418 -0
  4. package/dist/chunk-3An_BRHv.js +501 -0
  5. package/dist/chunk-6uTxgdiY.js +16218 -0
  6. package/dist/chunk-87nRnNRG.js +1363 -0
  7. package/dist/chunk-B3wo8uRx.js +322 -0
  8. package/dist/chunk-BGp3ZdBy.js +560 -0
  9. package/dist/chunk-BJQv9Elp.js +107 -0
  10. package/dist/chunk-BOpO6xE-.js +6053 -0
  11. package/dist/chunk-BQXXCL8B.js +102 -0
  12. package/dist/chunk-BV-8isOd.js +34 -0
  13. package/dist/chunk-BVMhjGVe.js +826 -0
  14. package/dist/chunk-BW2fg46T.js +141 -0
  15. package/dist/chunk-BWJdY5Ag.js +36 -0
  16. package/dist/chunk-BYJOrLhh.js +302 -0
  17. package/dist/chunk-BYab8EVL.js +127 -0
  18. package/dist/chunk-BfEKvp7h.js +82 -0
  19. package/dist/chunk-BhgLSfH6.js +1123 -0
  20. package/dist/chunk-BirUxTtH.js +296 -0
  21. package/dist/chunk-BmB6UVZ9.js +1559 -0
  22. package/dist/chunk-BnWhIqW1.js +109 -0
  23. package/dist/chunk-Bpfnfk0t.js +123 -0
  24. package/dist/chunk-BrhgdnM3.js +108 -0
  25. package/dist/chunk-Bt0XAgX5.js +327 -0
  26. package/dist/chunk-Bu0FJr6S.js +84 -0
  27. package/dist/chunk-BvEoKpN3.js +255 -0
  28. package/dist/chunk-BxNJgYbE.js +28 -0
  29. package/dist/chunk-C1OFhd7F.js +6131 -0
  30. package/dist/chunk-C7e7WwbU.js +331 -0
  31. package/dist/chunk-CDTYP6bN.js +558 -0
  32. package/dist/chunk-CGDQoqDC.js +24 -0
  33. package/dist/chunk-CJraEBVd.js +127 -0
  34. package/dist/chunk-CQrNhOtv.js +40 -0
  35. package/dist/chunk-CW6AzBH6.js +128 -0
  36. package/dist/chunk-CXgL4w-9.js +317 -0
  37. package/dist/chunk-CZrqoPyf.js +233 -0
  38. package/dist/chunk-CcFCyqbB.js +83 -0
  39. package/dist/chunk-CdaIvO-y.js +485 -0
  40. package/dist/chunk-CehSXtgK.js +624 -0
  41. package/dist/chunk-Ciqkop65.js +218 -0
  42. package/dist/chunk-CoAWdSiE.js +43 -0
  43. package/dist/chunk-Crb4y7t4.js +830 -0
  44. package/dist/chunk-CrlqIfmb.js +337 -0
  45. package/dist/chunk-Cs4pwCQ-.js +324 -0
  46. package/dist/chunk-CwM_9y01.js +519 -0
  47. package/dist/chunk-CyRbIJg8.js +440 -0
  48. package/dist/chunk-D0OHsyMy.js +212 -0
  49. package/dist/chunk-D3y2bURs.js +1347 -0
  50. package/dist/chunk-D4_mJk03.js +2338 -0
  51. package/dist/chunk-D6C8rned.js +578 -0
  52. package/dist/chunk-D9ZbUnks.js +11 -0
  53. package/dist/chunk-DEPmLshX.js +834 -0
  54. package/dist/chunk-DFj1UPB2.js +330 -0
  55. package/dist/chunk-DGdFdZVf.js +197 -0
  56. package/dist/chunk-DGv7X9S_.js +63 -0
  57. package/dist/chunk-DJQ47WYZ.js +664 -0
  58. package/dist/chunk-DJw3O61j.js +1974 -0
  59. package/dist/chunk-DK4FbWVK.js +100 -0
  60. package/dist/chunk-DSRYhUus.js +993 -0
  61. package/dist/chunk-DajZ9Eg4.js +299 -0
  62. package/dist/chunk-Df4dunvU.js +195 -0
  63. package/dist/chunk-DjNTPhfO.js +481 -0
  64. package/dist/chunk-Dn8eaJuu.js +1042 -0
  65. package/dist/chunk-DwDWqSxM.js +637 -0
  66. package/dist/chunk-Dz7cEtxl.js +84 -0
  67. package/dist/chunk-E_0bgjrS.js +359 -0
  68. package/dist/chunk-KPYN2vUp.js +776 -0
  69. package/dist/chunk-KcqPQJBi.js +86 -0
  70. package/dist/chunk-N9H0JnoG.js +349 -0
  71. package/dist/chunk-NONFcXkn.js +728 -0
  72. package/dist/chunk-PrFjcpmH.js +256 -0
  73. package/dist/chunk-QSfNYiw9.js +11 -0
  74. package/dist/chunk-R265bzj9.js +226 -0
  75. package/dist/chunk-X9V_r6jM.js +166 -0
  76. package/dist/chunk-ZBtPUtyA.js +55 -0
  77. package/dist/chunk-ZCTfmOs7.js +4939 -0
  78. package/dist/chunk-h6oavj0t.js +97 -0
  79. package/dist/chunk-i7DwkvvD.js +42 -0
  80. package/dist/chunk-mG-4eZ6S.js +203 -0
  81. package/dist/chunk-o0ygUbCf.js +313 -0
  82. package/dist/chunk-ucu5lrDZ.js +5715 -0
  83. package/dist/index.js +11367 -73789
  84. package/package.json +4 -4
@@ -0,0 +1,624 @@
1
+ #!/usr/bin/env node
2
+ import { t as isTTY } from "./index.js";
3
+ import { ConfirmPrompt, DataList, EntityCard, MutationResult, React, render, useEffect, useState } from "./chunk-CoAWdSiE.js";
4
+ import { t as isRecord } from "./chunk-QSfNYiw9.js";
5
+ import { r as createCliClient } from "./chunk-BW2fg46T.js";
6
+ import { n as ensureAuth } from "./chunk-CJraEBVd.js";
7
+ import { a as printJson, i as printDetail, n as buildListParams, s as printNextCursorHint } from "./chunk-CcFCyqbB.js";
8
+ import { n as resolveJsonPayload } from "./chunk-DGv7X9S_.js";
9
+ import { a as TOOL_ENSURE_SPEC, c as buildEntityPullCommand, s as buildEntityEnsureCommand } from "./chunk-BirUxTtH.js";
10
+ import { Command } from "commander";
11
+ import chalk from "chalk";
12
+ // src/commands/tools.ts
13
+ function buildToolRunBody(options) {
14
+ const parameters = resolveJsonPayload(options.input, options.fromFile, "input parameters");
15
+ const toolConfig = options.config !== void 0 || options.configFile !== void 0 ? resolveJsonPayload(options.config, options.configFile, "tool config") : void 0;
16
+ return {
17
+ parameters,
18
+ ...toolConfig ? { toolConfig } : {}
19
+ };
20
+ }
21
+ /**
22
+ * One line for a built-in result's `metadata`. A judgment reads as its
23
+ * resolved model, key source and estimated cost; any other key stays JSON.
24
+ */
25
+ function formatToolMetadata(metadata) {
26
+ if (!metadata || Object.keys(metadata).length === 0) return void 0;
27
+ const { judgment, ...rest } = metadata;
28
+ const parts = [];
29
+ if (isRecord(judgment)) {
30
+ const model = judgment.resolvedModelId ?? judgment.requestedModel ?? "unknown";
31
+ const cost = typeof judgment.estimatedCostUsd === "number" ? `$${judgment.estimatedCostUsd.toFixed(6)}` : "unknown";
32
+ parts.push(`judgment: model ${String(model)}, key source ${String(judgment.keySource ?? "unknown")}, estimated cost ${cost}`);
33
+ } else if (judgment !== void 0) rest.judgment = judgment;
34
+ if (Object.keys(rest).length > 0) parts.push(JSON.stringify(rest));
35
+ return parts.join("; ");
36
+ }
37
+ const toolsCommand = new Command("tools").description("Manage runtime tools (saved tools)");
38
+ toolsCommand.addCommand(buildEntityEnsureCommand(TOOL_ENSURE_SPEC));
39
+ toolsCommand.addCommand(buildEntityPullCommand(TOOL_ENSURE_SPEC));
40
+ toolsCommand.command("list").description("List your tools").option("--limit <n>", "Limit results (defaults to the API page size)").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(async (options) => {
41
+ const apiKey = await ensureAuth();
42
+ if (!apiKey) return;
43
+ const client = createCliClient(apiKey);
44
+ const params = buildListParams(options);
45
+ if (!isTTY(options) || options.json) {
46
+ try {
47
+ const data = await client.get("/tools", params);
48
+ if (options.json) {
49
+ printJson(data);
50
+ return;
51
+ }
52
+ const toolList = data.data ?? [];
53
+ if (toolList.length === 0) {
54
+ console.log(chalk.gray("No tools found"));
55
+ return;
56
+ }
57
+ console.log(chalk.cyan("Your Tools:"));
58
+ for (const t of toolList) {
59
+ const status = t.isActive === false ? chalk.yellow("inactive") : chalk.green("active");
60
+ const type = t.toolType ? chalk.dim(` [${t.toolType}]`) : "";
61
+ const desc = t.description ? chalk.gray(` — ${t.description}`) : "";
62
+ console.log(` ${chalk.green(t.id)} ${t.name}${type} (${status})${desc}`);
63
+ }
64
+ const total = data.pagination?.totalCount ?? toolList.length;
65
+ console.log(chalk.dim(`\n Total: ${total} tools`));
66
+ printNextCursorHint("runtype tools list", data.pagination);
67
+ } catch (error) {
68
+ const message = error instanceof Error ? error.message : "Unknown error";
69
+ console.error(chalk.red(`Failed to fetch tools: ${message}`));
70
+ process.exit(1);
71
+ }
72
+ return;
73
+ }
74
+ const App = () => {
75
+ const [items, setItems] = useState(null);
76
+ const [error, setError] = useState(null);
77
+ const [total, setTotal] = useState();
78
+ useEffect(() => {
79
+ client.get("/tools", params).then((res) => {
80
+ const toolList = res.data ?? [];
81
+ setItems(toolList);
82
+ setTotal(res.pagination?.totalCount ?? toolList.length);
83
+ }).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
84
+ }, []);
85
+ return React.createElement(DataList, {
86
+ title: "Your Tools",
87
+ items,
88
+ error,
89
+ loading: items === null && error === null,
90
+ total,
91
+ emptyMessage: "No tools found",
92
+ renderCard: (item) => {
93
+ const t = item;
94
+ return React.createElement(EntityCard, { fields: [
95
+ {
96
+ label: "ID",
97
+ value: t.id,
98
+ color: "green"
99
+ },
100
+ {
101
+ label: "Name",
102
+ value: t.name
103
+ },
104
+ {
105
+ label: "Type",
106
+ value: t.toolType,
107
+ color: "gray"
108
+ },
109
+ {
110
+ label: "Active",
111
+ value: t.isActive === false ? "no" : "yes"
112
+ },
113
+ {
114
+ label: "Description",
115
+ value: t.description,
116
+ color: "gray"
117
+ }
118
+ ] });
119
+ }
120
+ });
121
+ };
122
+ const { waitUntilExit } = render(React.createElement(App));
123
+ await waitUntilExit();
124
+ });
125
+ toolsCommand.command("get <id>").description("Get tool details including its full configuration").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
126
+ const apiKey = await ensureAuth();
127
+ if (!apiKey) return;
128
+ const client = createCliClient(apiKey);
129
+ if (!isTTY(options) || options.json) {
130
+ try {
131
+ const data = await client.get(`/tools/${id}`);
132
+ if (options.json) {
133
+ printJson(data);
134
+ return;
135
+ }
136
+ printDetail("Tool", [
137
+ {
138
+ label: "ID",
139
+ value: data.id
140
+ },
141
+ {
142
+ label: "Name",
143
+ value: data.name
144
+ },
145
+ {
146
+ label: "Description",
147
+ value: data.description
148
+ },
149
+ {
150
+ label: "Type",
151
+ value: data.toolType
152
+ },
153
+ {
154
+ label: "Active",
155
+ value: data.isActive === false ? "no" : "yes"
156
+ },
157
+ {
158
+ label: "Parameters Schema",
159
+ value: data.parametersSchema
160
+ },
161
+ {
162
+ label: "Config",
163
+ value: data.config
164
+ },
165
+ {
166
+ label: "Created",
167
+ value: data.createdAt
168
+ },
169
+ {
170
+ label: "Updated",
171
+ value: data.updatedAt
172
+ }
173
+ ]);
174
+ } catch (error) {
175
+ const message = error instanceof Error ? error.message : "Unknown error";
176
+ console.error(chalk.red(`Failed to fetch tool: ${message}`));
177
+ process.exit(1);
178
+ }
179
+ return;
180
+ }
181
+ const App = () => {
182
+ const [loading, setLoading] = useState(true);
183
+ const [success, setSuccess] = useState(null);
184
+ const [error, setError] = useState(null);
185
+ const [resultNode, setResultNode] = useState(void 0);
186
+ useEffect(() => {
187
+ const run = async () => {
188
+ try {
189
+ const data = await client.get(`/tools/${id}`);
190
+ setResultNode(React.createElement(EntityCard, { fields: [
191
+ {
192
+ label: "ID",
193
+ value: data.id,
194
+ color: "green"
195
+ },
196
+ {
197
+ label: "Name",
198
+ value: data.name
199
+ },
200
+ {
201
+ label: "Description",
202
+ value: data.description
203
+ },
204
+ {
205
+ label: "Type",
206
+ value: data.toolType,
207
+ color: "gray"
208
+ },
209
+ {
210
+ label: "Active",
211
+ value: data.isActive === false ? "no" : "yes"
212
+ },
213
+ {
214
+ label: "Config",
215
+ value: data.config ? JSON.stringify(data.config) : void 0
216
+ },
217
+ {
218
+ label: "Created",
219
+ value: data.createdAt
220
+ }
221
+ ] }));
222
+ setSuccess(true);
223
+ setLoading(false);
224
+ } catch (err) {
225
+ setError(err instanceof Error ? err : new Error(String(err)));
226
+ setSuccess(false);
227
+ setLoading(false);
228
+ }
229
+ };
230
+ run();
231
+ }, []);
232
+ return React.createElement(MutationResult, {
233
+ loading,
234
+ loadingLabel: "Fetching tool...",
235
+ success,
236
+ successMessage: "Tool",
237
+ error,
238
+ result: resultNode
239
+ });
240
+ };
241
+ const { waitUntilExit } = render(React.createElement(App));
242
+ await waitUntilExit();
243
+ });
244
+ toolsCommand.command("create").description("Create a new tool from a JSON definition").option("--from-file <file>", "Read the tool definition JSON from a file").option("--json-body <json>", "Inline tool definition JSON").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
245
+ const apiKey = await ensureAuth();
246
+ if (!apiKey) return;
247
+ const body = resolveJsonPayload(options.jsonBody, options.fromFile, "tool definition");
248
+ const client = createCliClient(apiKey);
249
+ if (!isTTY(options) || options.json) {
250
+ try {
251
+ const data = await client.post("/tools", body);
252
+ if (options.json) {
253
+ printJson(data);
254
+ return;
255
+ }
256
+ console.log(chalk.green("Tool created"));
257
+ console.log(` ID: ${chalk.green(data.id)}`);
258
+ console.log(` Name: ${data.name}`);
259
+ if (data.toolType) console.log(` Type: ${data.toolType}`);
260
+ } catch (error) {
261
+ const message = error instanceof Error ? error.message : "Unknown error";
262
+ console.error(chalk.red(`Failed to create tool: ${message}`));
263
+ process.exit(1);
264
+ }
265
+ return;
266
+ }
267
+ const App = () => {
268
+ const [loading, setLoading] = useState(true);
269
+ const [success, setSuccess] = useState(null);
270
+ const [error, setError] = useState(null);
271
+ const [resultNode, setResultNode] = useState(void 0);
272
+ useEffect(() => {
273
+ const run = async () => {
274
+ try {
275
+ const data = await client.post("/tools", body);
276
+ setResultNode(React.createElement(EntityCard, { fields: [
277
+ {
278
+ label: "ID",
279
+ value: data.id,
280
+ color: "green"
281
+ },
282
+ {
283
+ label: "Name",
284
+ value: data.name
285
+ },
286
+ {
287
+ label: "Type",
288
+ value: data.toolType,
289
+ color: "gray"
290
+ }
291
+ ] }));
292
+ setSuccess(true);
293
+ setLoading(false);
294
+ } catch (err) {
295
+ setError(err instanceof Error ? err : new Error(String(err)));
296
+ setSuccess(false);
297
+ setLoading(false);
298
+ }
299
+ };
300
+ run();
301
+ }, []);
302
+ return React.createElement(MutationResult, {
303
+ loading,
304
+ loadingLabel: "Creating tool...",
305
+ success,
306
+ successMessage: "Tool created",
307
+ error,
308
+ result: resultNode
309
+ });
310
+ };
311
+ const { waitUntilExit } = render(React.createElement(App));
312
+ await waitUntilExit();
313
+ });
314
+ toolsCommand.command("update <id>").description("Update an existing tool from a JSON definition").option("--from-file <file>", "Read the (partial) tool definition JSON from a file").option("--json-body <json>", "Inline (partial) tool definition JSON").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
315
+ const apiKey = await ensureAuth();
316
+ if (!apiKey) return;
317
+ const body = resolveJsonPayload(options.jsonBody, options.fromFile, "tool definition");
318
+ const client = createCliClient(apiKey);
319
+ if (!isTTY(options) || options.json) {
320
+ try {
321
+ const data = await client.put(`/tools/${id}`, body);
322
+ if (options.json) {
323
+ printJson(data);
324
+ return;
325
+ }
326
+ console.log(chalk.green("Tool updated"));
327
+ console.log(` ID: ${chalk.green(data.id)}`);
328
+ console.log(` Name: ${data.name}`);
329
+ console.log(` Active: ${data.isActive === false ? "no" : "yes"}`);
330
+ } catch (error) {
331
+ const message = error instanceof Error ? error.message : "Unknown error";
332
+ console.error(chalk.red(`Failed to update tool: ${message}`));
333
+ process.exit(1);
334
+ }
335
+ return;
336
+ }
337
+ const App = () => {
338
+ const [loading, setLoading] = useState(true);
339
+ const [success, setSuccess] = useState(null);
340
+ const [error, setError] = useState(null);
341
+ const [resultNode, setResultNode] = useState(void 0);
342
+ useEffect(() => {
343
+ const run = async () => {
344
+ try {
345
+ const data = await client.put(`/tools/${id}`, body);
346
+ setResultNode(React.createElement(EntityCard, { fields: [
347
+ {
348
+ label: "ID",
349
+ value: data.id,
350
+ color: "green"
351
+ },
352
+ {
353
+ label: "Name",
354
+ value: data.name
355
+ },
356
+ {
357
+ label: "Active",
358
+ value: data.isActive === false ? "no" : "yes"
359
+ }
360
+ ] }));
361
+ setSuccess(true);
362
+ setLoading(false);
363
+ } catch (err) {
364
+ setError(err instanceof Error ? err : new Error(String(err)));
365
+ setSuccess(false);
366
+ setLoading(false);
367
+ }
368
+ };
369
+ run();
370
+ }, []);
371
+ return React.createElement(MutationResult, {
372
+ loading,
373
+ loadingLabel: "Updating tool...",
374
+ success,
375
+ successMessage: "Tool updated",
376
+ error,
377
+ result: resultNode
378
+ });
379
+ };
380
+ const { waitUntilExit } = render(React.createElement(App));
381
+ await waitUntilExit();
382
+ });
383
+ toolsCommand.command("delete <id>").description("Delete a tool").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").option("--yes", "Skip confirmation").action(async (id, options) => {
384
+ const apiKey = await ensureAuth();
385
+ if (!apiKey) return;
386
+ const client = createCliClient(apiKey);
387
+ if (!isTTY(options)) {
388
+ try {
389
+ await client.tools.delete(id);
390
+ console.log(chalk.green("Tool deleted"));
391
+ } catch (error) {
392
+ const message = error instanceof Error ? error.message : "Unknown error";
393
+ console.error(chalk.red(`Failed to delete tool: ${message}`));
394
+ process.exit(1);
395
+ }
396
+ return;
397
+ }
398
+ const runDelete = () => {
399
+ const App = () => {
400
+ const [loading, setLoading] = useState(true);
401
+ const [success, setSuccess] = useState(null);
402
+ const [error, setError] = useState(null);
403
+ useEffect(() => {
404
+ client.delete(`/tools/${id}`).then(() => {
405
+ setSuccess(true);
406
+ setLoading(false);
407
+ }).catch((err) => {
408
+ setError(err instanceof Error ? err : new Error(String(err)));
409
+ setSuccess(false);
410
+ setLoading(false);
411
+ });
412
+ }, []);
413
+ return React.createElement(MutationResult, {
414
+ loading,
415
+ loadingLabel: "Deleting tool...",
416
+ success,
417
+ successMessage: "Tool deleted",
418
+ error
419
+ });
420
+ };
421
+ return App;
422
+ };
423
+ if (options.yes) {
424
+ const { waitUntilExit } = render(React.createElement(runDelete()));
425
+ await waitUntilExit();
426
+ return;
427
+ }
428
+ if (!await new Promise((resolve) => {
429
+ const { unmount } = render(React.createElement(ConfirmPrompt, {
430
+ message: `Delete tool ${id}?`,
431
+ defaultValue: false,
432
+ onConfirm: (result) => {
433
+ resolve(result);
434
+ unmount();
435
+ }
436
+ }));
437
+ })) return;
438
+ const { waitUntilExit } = render(React.createElement(runDelete()));
439
+ await waitUntilExit();
440
+ });
441
+ toolsCommand.command("execute <id>").description("Execute a tool with input parameters").option("--input <json>", "Inline input parameters JSON").option("--from-file <file>", "Read input parameters JSON from a file").option("--config <json>", "Inline tool config JSON (builtin: and platform: tools)").option("--config-file <file>", "Read tool config JSON from a file").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
442
+ const apiKey = await ensureAuth();
443
+ if (!apiKey) return;
444
+ const body = buildToolRunBody(options);
445
+ const client = createCliClient(apiKey);
446
+ if (!isTTY(options) || options.json) {
447
+ try {
448
+ const data = await client.post(`/tools/${id}/execute`, body);
449
+ if (options.json) {
450
+ printJson(data);
451
+ return;
452
+ }
453
+ const status = data.status ?? "unknown";
454
+ const statusColor = status === "failed" ? chalk.red : chalk.green;
455
+ console.log(chalk.cyan("Tool execution:"));
456
+ console.log(` Status: ${statusColor(status)}`);
457
+ if (data.executionId) console.log(` Execution ID: ${data.executionId}`);
458
+ if (data.executionTimeMs !== void 0) console.log(` Duration: ${data.executionTimeMs}ms`);
459
+ const errMsg = data.error ?? data.errorMessage;
460
+ if (errMsg) console.log(` ${chalk.red("Error")}: ${errMsg}`);
461
+ const metadataLine = formatToolMetadata(data.metadata);
462
+ if (metadataLine) console.log(` Metadata: ${metadataLine}`);
463
+ console.log(` Result: ${JSON.stringify(data.result ?? data, null, 2)}`);
464
+ } catch (error) {
465
+ const message = error instanceof Error ? error.message : "Unknown error";
466
+ console.error(chalk.red(`Failed to execute tool: ${message}`));
467
+ process.exit(1);
468
+ }
469
+ return;
470
+ }
471
+ const App = () => {
472
+ const [loading, setLoading] = useState(true);
473
+ const [success, setSuccess] = useState(null);
474
+ const [error, setError] = useState(null);
475
+ const [resultNode, setResultNode] = useState(void 0);
476
+ useEffect(() => {
477
+ const run = async () => {
478
+ try {
479
+ const data = await client.post(`/tools/${id}/execute`, body);
480
+ const errMsg = data.error ?? data.errorMessage;
481
+ setResultNode(React.createElement(EntityCard, { fields: [
482
+ {
483
+ label: "Status",
484
+ value: data.status ?? "unknown",
485
+ color: data.status === "failed" ? "red" : "green"
486
+ },
487
+ {
488
+ label: "Execution ID",
489
+ value: data.executionId,
490
+ color: "gray"
491
+ },
492
+ {
493
+ label: "Duration",
494
+ value: data.executionTimeMs !== void 0 ? `${data.executionTimeMs}ms` : void 0
495
+ },
496
+ {
497
+ label: "Error",
498
+ value: errMsg,
499
+ color: "red"
500
+ },
501
+ {
502
+ label: "Metadata",
503
+ value: formatToolMetadata(data.metadata)
504
+ },
505
+ {
506
+ label: "Result",
507
+ value: JSON.stringify(data.result ?? data)
508
+ }
509
+ ] }));
510
+ setSuccess(data.status !== "failed");
511
+ setLoading(false);
512
+ } catch (err) {
513
+ setError(err instanceof Error ? err : new Error(String(err)));
514
+ setSuccess(false);
515
+ setLoading(false);
516
+ }
517
+ };
518
+ run();
519
+ }, []);
520
+ return React.createElement(MutationResult, {
521
+ loading,
522
+ loadingLabel: "Executing tool...",
523
+ success,
524
+ successMessage: "Tool executed",
525
+ error,
526
+ result: resultNode
527
+ });
528
+ };
529
+ const { waitUntilExit } = render(React.createElement(App));
530
+ await waitUntilExit();
531
+ });
532
+ toolsCommand.command("test <id>").description("Test a tool with sample input parameters").option("--input <json>", "Inline input parameters JSON").option("--from-file <file>", "Read input parameters JSON from a file").option("--config <json>", "Inline tool config JSON (builtin: and platform: tools)").option("--config-file <file>", "Read tool config JSON from a file").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
533
+ const apiKey = await ensureAuth();
534
+ if (!apiKey) return;
535
+ const body = buildToolRunBody(options);
536
+ const client = createCliClient(apiKey);
537
+ if (!isTTY(options) || options.json) {
538
+ try {
539
+ const data = await client.post(`/tools/${id}/test`, body);
540
+ if (options.json) {
541
+ printJson(data);
542
+ return;
543
+ }
544
+ const status = data.status ?? "unknown";
545
+ const statusColor = status === "failed" ? chalk.red : chalk.green;
546
+ console.log(chalk.cyan("Tool test:"));
547
+ console.log(` Status: ${statusColor(status)}`);
548
+ if (data.executionId) console.log(` Execution ID: ${data.executionId}`);
549
+ if (data.executionTimeMs !== void 0) console.log(` Duration: ${data.executionTimeMs}ms`);
550
+ const errMsg = data.error ?? data.errorMessage;
551
+ if (errMsg) console.log(` ${chalk.red("Error")}: ${errMsg}`);
552
+ const metadataLine = formatToolMetadata(data.metadata);
553
+ if (metadataLine) console.log(` Metadata: ${metadataLine}`);
554
+ console.log(` Result: ${JSON.stringify(data.result ?? data, null, 2)}`);
555
+ } catch (error) {
556
+ const message = error instanceof Error ? error.message : "Unknown error";
557
+ console.error(chalk.red(`Failed to test tool: ${message}`));
558
+ process.exit(1);
559
+ }
560
+ return;
561
+ }
562
+ const App = () => {
563
+ const [loading, setLoading] = useState(true);
564
+ const [success, setSuccess] = useState(null);
565
+ const [error, setError] = useState(null);
566
+ const [resultNode, setResultNode] = useState(void 0);
567
+ useEffect(() => {
568
+ const run = async () => {
569
+ try {
570
+ const data = await client.post(`/tools/${id}/test`, body);
571
+ const errMsg = data.error ?? data.errorMessage;
572
+ setResultNode(React.createElement(EntityCard, { fields: [
573
+ {
574
+ label: "Status",
575
+ value: data.status ?? "unknown",
576
+ color: data.status === "failed" ? "red" : "green"
577
+ },
578
+ {
579
+ label: "Execution ID",
580
+ value: data.executionId,
581
+ color: "gray"
582
+ },
583
+ {
584
+ label: "Duration",
585
+ value: data.executionTimeMs !== void 0 ? `${data.executionTimeMs}ms` : void 0
586
+ },
587
+ {
588
+ label: "Error",
589
+ value: errMsg,
590
+ color: "red"
591
+ },
592
+ {
593
+ label: "Metadata",
594
+ value: formatToolMetadata(data.metadata)
595
+ },
596
+ {
597
+ label: "Result",
598
+ value: JSON.stringify(data.result ?? data)
599
+ }
600
+ ] }));
601
+ setSuccess(data.status !== "failed");
602
+ setLoading(false);
603
+ } catch (err) {
604
+ setError(err instanceof Error ? err : new Error(String(err)));
605
+ setSuccess(false);
606
+ setLoading(false);
607
+ }
608
+ };
609
+ run();
610
+ }, []);
611
+ return React.createElement(MutationResult, {
612
+ loading,
613
+ loadingLabel: "Testing tool...",
614
+ success,
615
+ successMessage: "Tool tested",
616
+ error,
617
+ result: resultNode
618
+ });
619
+ };
620
+ const { waitUntilExit } = render(React.createElement(App));
621
+ await waitUntilExit();
622
+ });
623
+ export { toolsCommand };
624
+