@runtypelabs/cli 2.59.1 → 2.59.4
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/chunk-0x7UKC1U.js +17 -0
- package/dist/chunk-2ySxXtcg.js +418 -0
- package/dist/chunk-3An_BRHv.js +501 -0
- package/dist/chunk-6uTxgdiY.js +16218 -0
- package/dist/chunk-87nRnNRG.js +1363 -0
- package/dist/chunk-B3wo8uRx.js +322 -0
- package/dist/chunk-BGp3ZdBy.js +560 -0
- package/dist/chunk-BJQv9Elp.js +107 -0
- package/dist/chunk-BOpO6xE-.js +6053 -0
- package/dist/chunk-BQXXCL8B.js +102 -0
- package/dist/chunk-BV-8isOd.js +34 -0
- package/dist/chunk-BVMhjGVe.js +826 -0
- package/dist/chunk-BW2fg46T.js +141 -0
- package/dist/chunk-BWJdY5Ag.js +36 -0
- package/dist/chunk-BYJOrLhh.js +302 -0
- package/dist/chunk-BYab8EVL.js +127 -0
- package/dist/chunk-BfEKvp7h.js +82 -0
- package/dist/chunk-BhgLSfH6.js +1123 -0
- package/dist/chunk-BirUxTtH.js +296 -0
- package/dist/chunk-BmB6UVZ9.js +1559 -0
- package/dist/chunk-BnWhIqW1.js +109 -0
- package/dist/chunk-Bpfnfk0t.js +123 -0
- package/dist/chunk-BrhgdnM3.js +108 -0
- package/dist/chunk-Bt0XAgX5.js +327 -0
- package/dist/chunk-Bu0FJr6S.js +84 -0
- package/dist/chunk-BvEoKpN3.js +255 -0
- package/dist/chunk-BxNJgYbE.js +28 -0
- package/dist/chunk-C1OFhd7F.js +6131 -0
- package/dist/chunk-C7e7WwbU.js +331 -0
- package/dist/chunk-CDTYP6bN.js +558 -0
- package/dist/chunk-CGDQoqDC.js +24 -0
- package/dist/chunk-CJraEBVd.js +127 -0
- package/dist/chunk-CQrNhOtv.js +40 -0
- package/dist/chunk-CW6AzBH6.js +128 -0
- package/dist/chunk-CXgL4w-9.js +317 -0
- package/dist/chunk-CZrqoPyf.js +233 -0
- package/dist/chunk-CcFCyqbB.js +83 -0
- package/dist/chunk-CdaIvO-y.js +485 -0
- package/dist/chunk-CehSXtgK.js +624 -0
- package/dist/chunk-Ciqkop65.js +218 -0
- package/dist/chunk-CoAWdSiE.js +43 -0
- package/dist/chunk-Crb4y7t4.js +830 -0
- package/dist/chunk-CrlqIfmb.js +337 -0
- package/dist/chunk-Cs4pwCQ-.js +324 -0
- package/dist/chunk-CwM_9y01.js +519 -0
- package/dist/chunk-CyRbIJg8.js +440 -0
- package/dist/chunk-D0OHsyMy.js +212 -0
- package/dist/chunk-D3y2bURs.js +1347 -0
- package/dist/chunk-D4_mJk03.js +2338 -0
- package/dist/chunk-D6C8rned.js +578 -0
- package/dist/chunk-D9ZbUnks.js +11 -0
- package/dist/chunk-DEPmLshX.js +834 -0
- package/dist/chunk-DFj1UPB2.js +330 -0
- package/dist/chunk-DGdFdZVf.js +197 -0
- package/dist/chunk-DGv7X9S_.js +63 -0
- package/dist/chunk-DJQ47WYZ.js +664 -0
- package/dist/chunk-DJw3O61j.js +1974 -0
- package/dist/chunk-DK4FbWVK.js +100 -0
- package/dist/chunk-DPuofXMp.js +3907 -0
- package/dist/chunk-DSRYhUus.js +993 -0
- package/dist/chunk-DajZ9Eg4.js +299 -0
- package/dist/chunk-Df4dunvU.js +195 -0
- package/dist/chunk-DjNTPhfO.js +481 -0
- package/dist/chunk-Dn8eaJuu.js +1042 -0
- package/dist/chunk-DwDWqSxM.js +637 -0
- package/dist/chunk-Dz7cEtxl.js +84 -0
- package/dist/chunk-E_0bgjrS.js +359 -0
- package/dist/chunk-KPYN2vUp.js +776 -0
- package/dist/chunk-KcqPQJBi.js +86 -0
- package/dist/chunk-N9H0JnoG.js +349 -0
- package/dist/chunk-NONFcXkn.js +728 -0
- package/dist/chunk-PrFjcpmH.js +256 -0
- package/dist/chunk-QSfNYiw9.js +11 -0
- package/dist/chunk-R265bzj9.js +226 -0
- package/dist/chunk-X9V_r6jM.js +166 -0
- package/dist/chunk-ZBtPUtyA.js +55 -0
- package/dist/chunk-ZCTfmOs7.js +4939 -0
- package/dist/chunk-h6oavj0t.js +97 -0
- package/dist/chunk-i7DwkvvD.js +42 -0
- package/dist/chunk-mG-4eZ6S.js +203 -0
- package/dist/chunk-o0ygUbCf.js +313 -0
- package/dist/chunk-ucu5lrDZ.js +5715 -0
- package/dist/index.js +11367 -73789
- package/package.json +5 -5
|
@@ -0,0 +1,440 @@
|
|
|
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 { r as createCliClient } from "./chunk-BW2fg46T.js";
|
|
5
|
+
import { n as ensureAuth } from "./chunk-CJraEBVd.js";
|
|
6
|
+
import { a as printJson, i as printDetail, n as buildListParams, r as getTotalCount, s as printNextCursorHint } from "./chunk-CcFCyqbB.js";
|
|
7
|
+
import { t as readJsonFile } from "./chunk-DGv7X9S_.js";
|
|
8
|
+
import { Command } from "commander";
|
|
9
|
+
import chalk from "chalk";
|
|
10
|
+
import { processStream } from "@runtypelabs/sdk";
|
|
11
|
+
// src/commands/prompts.ts
|
|
12
|
+
const promptsCommand = new Command("prompts").description("Manage prompts");
|
|
13
|
+
promptsCommand.command("list").description("List all prompts").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) => {
|
|
14
|
+
const apiKey = await ensureAuth();
|
|
15
|
+
if (!apiKey) return;
|
|
16
|
+
const client = createCliClient(apiKey);
|
|
17
|
+
const params = buildListParams(options);
|
|
18
|
+
if (!isTTY(options) || options.json) {
|
|
19
|
+
try {
|
|
20
|
+
const data = await client.get("/prompts", params);
|
|
21
|
+
if (options.json) {
|
|
22
|
+
printJson(data);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const prompts = data.data ?? [];
|
|
26
|
+
if (prompts.length === 0) {
|
|
27
|
+
console.log("No prompts found");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
for (const prompt of prompts) {
|
|
31
|
+
console.log(` ${prompt.id} - ${prompt.name}`);
|
|
32
|
+
if (prompt.description) console.log(` ${prompt.description}`);
|
|
33
|
+
if (prompt.model) console.log(` Model: ${prompt.model}`);
|
|
34
|
+
}
|
|
35
|
+
const total = getTotalCount(data.pagination);
|
|
36
|
+
if (total !== void 0) console.log(`\n Total: ${total} prompts`);
|
|
37
|
+
printNextCursorHint("runtype prompts list", data.pagination);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
40
|
+
console.error(chalk.red(`Failed to fetch prompts: ${message}`));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const App = () => {
|
|
46
|
+
const [items, setItems] = useState(null);
|
|
47
|
+
const [error, setError] = useState(null);
|
|
48
|
+
const [total, setTotal] = useState();
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
client.get("/prompts", params).then((res) => {
|
|
51
|
+
setItems(res.data ?? []);
|
|
52
|
+
setTotal(getTotalCount(res.pagination));
|
|
53
|
+
}).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
54
|
+
}, []);
|
|
55
|
+
return React.createElement(DataList, {
|
|
56
|
+
title: "Your Prompts",
|
|
57
|
+
items,
|
|
58
|
+
error,
|
|
59
|
+
loading: items === null && error === null,
|
|
60
|
+
total,
|
|
61
|
+
renderCard: (item) => {
|
|
62
|
+
const prompt = item;
|
|
63
|
+
return React.createElement(EntityCard, { fields: [
|
|
64
|
+
{
|
|
65
|
+
label: "ID",
|
|
66
|
+
value: prompt.id,
|
|
67
|
+
color: "green"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "Name",
|
|
71
|
+
value: prompt.name
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: "Description",
|
|
75
|
+
value: prompt.description,
|
|
76
|
+
color: "gray"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Model",
|
|
80
|
+
value: prompt.model,
|
|
81
|
+
color: "blue"
|
|
82
|
+
}
|
|
83
|
+
] });
|
|
84
|
+
},
|
|
85
|
+
emptyMessage: "No prompts found"
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
89
|
+
await waitUntilExit();
|
|
90
|
+
});
|
|
91
|
+
promptsCommand.command("get <id>").description("Get prompt details").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
|
|
92
|
+
const apiKey = await ensureAuth();
|
|
93
|
+
if (!apiKey) return;
|
|
94
|
+
const client = createCliClient(apiKey);
|
|
95
|
+
if (!isTTY(options) || options.json) {
|
|
96
|
+
try {
|
|
97
|
+
const data = await client.get(`/prompts/${id}`);
|
|
98
|
+
if (options.json) {
|
|
99
|
+
printJson(data);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
printDetail("Prompt", [
|
|
103
|
+
{
|
|
104
|
+
label: "ID",
|
|
105
|
+
value: data.id
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: "Name",
|
|
109
|
+
value: data.name
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: "Description",
|
|
113
|
+
value: data.description
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: "Model",
|
|
117
|
+
value: data.model
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
122
|
+
console.error(chalk.red(`Failed to fetch prompt: ${message}`));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const App = () => {
|
|
128
|
+
const [items, setItems] = useState(null);
|
|
129
|
+
const [error, setError] = useState(null);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
client.get(`/prompts/${id}`).then((res) => setItems([res])).catch((err) => setError(err instanceof Error ? err : new Error(String(err))));
|
|
132
|
+
}, []);
|
|
133
|
+
return React.createElement(DataList, {
|
|
134
|
+
title: "Prompt",
|
|
135
|
+
items,
|
|
136
|
+
error,
|
|
137
|
+
loading: items === null && error === null,
|
|
138
|
+
renderCard: (item) => {
|
|
139
|
+
const prompt = item;
|
|
140
|
+
return React.createElement(EntityCard, { fields: [
|
|
141
|
+
{
|
|
142
|
+
label: "ID",
|
|
143
|
+
value: prompt.id,
|
|
144
|
+
color: "green"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: "Name",
|
|
148
|
+
value: prompt.name
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: "Description",
|
|
152
|
+
value: prompt.description
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: "Model",
|
|
156
|
+
value: prompt.model,
|
|
157
|
+
color: "blue"
|
|
158
|
+
}
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
164
|
+
await waitUntilExit();
|
|
165
|
+
});
|
|
166
|
+
promptsCommand.command("test <id>").description("Test a prompt with input").option("-i, --input <text>", "Input text for the prompt").option("--stream", "Stream the response (default)", true).option("--no-stream", "Wait for complete response").option("--json", "Output as JSON").action(async (promptId, options) => {
|
|
167
|
+
const apiKey = await ensureAuth();
|
|
168
|
+
if (!apiKey) return;
|
|
169
|
+
const client = createCliClient(apiKey);
|
|
170
|
+
const payload = {
|
|
171
|
+
flow: { steps: [{
|
|
172
|
+
name: "test",
|
|
173
|
+
type: "prompt",
|
|
174
|
+
config: {
|
|
175
|
+
promptId,
|
|
176
|
+
text: options.input || ""
|
|
177
|
+
}
|
|
178
|
+
}] },
|
|
179
|
+
options: { streamResponse: options.stream }
|
|
180
|
+
};
|
|
181
|
+
if (options.input) payload.messages = [{
|
|
182
|
+
role: "user",
|
|
183
|
+
content: options.input
|
|
184
|
+
}];
|
|
185
|
+
if (options.stream) {
|
|
186
|
+
console.log(chalk.gray("Testing prompt..."));
|
|
187
|
+
try {
|
|
188
|
+
const response = await client.requestStream("/dispatch", {
|
|
189
|
+
method: "POST",
|
|
190
|
+
body: JSON.stringify(payload),
|
|
191
|
+
headers: { Accept: "text/event-stream" }
|
|
192
|
+
});
|
|
193
|
+
await processStream(response, {
|
|
194
|
+
onStepDelta: (chunk) => {
|
|
195
|
+
process.stdout.write(chunk);
|
|
196
|
+
},
|
|
197
|
+
onError: (err) => {
|
|
198
|
+
console.error(chalk.red(`\nError: ${err.message}`));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
console.log();
|
|
202
|
+
} catch (error) {
|
|
203
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
204
|
+
console.error(chalk.red(`Prompt test failed: ${message}`));
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
console.log(chalk.gray("Testing prompt..."));
|
|
209
|
+
try {
|
|
210
|
+
const result = await client.post("/dispatch", payload);
|
|
211
|
+
console.log(chalk.green("Prompt test complete"));
|
|
212
|
+
if (options.json) printJson(result);
|
|
213
|
+
else printJson(result);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
216
|
+
console.error(chalk.red(`Prompt test failed: ${message}`));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
promptsCommand.command("create").description("Create a new prompt").option("--from-file <file>", "Create prompt from a JSON file (body or { prompt: {...} })").option("-n, --name <name>", "Prompt name").option("-t, --text <text>", "Prompt text").option("-s, --system-prompt <text>", "System prompt").option("-u, --user-prompt <text>", "User prompt").option("-r, --response-format <format>", "Response format (json, markdown, text, html, xml)").option("-m, --model <model>", "Model ID").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
222
|
+
const apiKey = await ensureAuth();
|
|
223
|
+
if (!apiKey) return;
|
|
224
|
+
const client = createCliClient(apiKey);
|
|
225
|
+
let body = {};
|
|
226
|
+
if (options.fromFile) body = readJsonFile(options.fromFile, {
|
|
227
|
+
label: "prompt file",
|
|
228
|
+
unwrapKey: "prompt"
|
|
229
|
+
});
|
|
230
|
+
if (options.name !== void 0) body.name = options.name;
|
|
231
|
+
if (options.text !== void 0) body.text = options.text;
|
|
232
|
+
if (options.systemPrompt !== void 0) body.systemPrompt = options.systemPrompt;
|
|
233
|
+
if (options.userPrompt !== void 0) body.userPrompt = options.userPrompt;
|
|
234
|
+
if (options.responseFormat !== void 0) body.responseFormat = options.responseFormat;
|
|
235
|
+
if (options.model !== void 0) body.model = options.model;
|
|
236
|
+
if (body.name === void 0 || body.text === void 0) {
|
|
237
|
+
console.error(chalk.red("Error: a prompt requires both a name and text (provide --name/--text or --from-file)"));
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
if (!isTTY(options) || options.json) {
|
|
241
|
+
try {
|
|
242
|
+
const data = await client.post("/prompts", body);
|
|
243
|
+
if (options.json) {
|
|
244
|
+
printJson(data);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
console.log(chalk.green("Prompt created"));
|
|
248
|
+
console.log(` ID: ${chalk.green(data.id)}`);
|
|
249
|
+
console.log(` Name: ${data.name}`);
|
|
250
|
+
if (data.model) console.log(` Model: ${data.model}`);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
253
|
+
console.error(chalk.red(`Failed to create prompt: ${message}`));
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const App = () => {
|
|
259
|
+
const [loading, setLoading] = useState(true);
|
|
260
|
+
const [success, setSuccess] = useState(null);
|
|
261
|
+
const [error, setError] = useState(null);
|
|
262
|
+
const [result, setResult] = useState(null);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
client.post("/prompts", body).then((data) => {
|
|
265
|
+
setResult(data);
|
|
266
|
+
setSuccess(true);
|
|
267
|
+
setLoading(false);
|
|
268
|
+
}).catch((err) => {
|
|
269
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
270
|
+
setSuccess(false);
|
|
271
|
+
setLoading(false);
|
|
272
|
+
});
|
|
273
|
+
}, []);
|
|
274
|
+
return React.createElement(MutationResult, {
|
|
275
|
+
loading,
|
|
276
|
+
loadingLabel: "Creating prompt...",
|
|
277
|
+
success,
|
|
278
|
+
successMessage: "Prompt created",
|
|
279
|
+
error,
|
|
280
|
+
result: result ? React.createElement(EntityCard, { fields: [
|
|
281
|
+
{
|
|
282
|
+
label: "ID",
|
|
283
|
+
value: result.id,
|
|
284
|
+
color: "green"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
label: "Name",
|
|
288
|
+
value: result.name
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
label: "Model",
|
|
292
|
+
value: result.model,
|
|
293
|
+
color: "blue"
|
|
294
|
+
}
|
|
295
|
+
] }) : void 0
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
299
|
+
await waitUntilExit();
|
|
300
|
+
});
|
|
301
|
+
promptsCommand.command("update <id>").description("Update a prompt (only provided fields are changed)").option("--from-file <file>", "Update prompt from a JSON file (body or { prompt: {...} })").option("-n, --name <name>", "New prompt name").option("-t, --text <text>", "New prompt text").option("-s, --system-prompt <text>", "New system prompt").option("-u, --user-prompt <text>", "New user prompt").option("-r, --response-format <format>", "New response format (json, markdown, text, html, xml)").option("-m, --model <model>", "New model ID").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
|
|
302
|
+
const apiKey = await ensureAuth();
|
|
303
|
+
if (!apiKey) return;
|
|
304
|
+
const client = createCliClient(apiKey);
|
|
305
|
+
let body = {};
|
|
306
|
+
if (options.fromFile) body = readJsonFile(options.fromFile, {
|
|
307
|
+
label: "prompt file",
|
|
308
|
+
unwrapKey: "prompt"
|
|
309
|
+
});
|
|
310
|
+
if (options.name !== void 0) body.name = options.name;
|
|
311
|
+
if (options.text !== void 0) body.text = options.text;
|
|
312
|
+
if (options.systemPrompt !== void 0) body.systemPrompt = options.systemPrompt;
|
|
313
|
+
if (options.userPrompt !== void 0) body.userPrompt = options.userPrompt;
|
|
314
|
+
if (options.responseFormat !== void 0) body.responseFormat = options.responseFormat;
|
|
315
|
+
if (options.model !== void 0) body.model = options.model;
|
|
316
|
+
if (Object.keys(body).length === 0) {
|
|
317
|
+
console.error(chalk.red("Error: provide at least one field to update (--name, --text, --system-prompt, --user-prompt, --response-format, --model, or --from-file)"));
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
if (!isTTY(options) || options.json) {
|
|
321
|
+
try {
|
|
322
|
+
const data = await client.put(`/prompts/${id}`, body);
|
|
323
|
+
if (options.json) {
|
|
324
|
+
printJson(data);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
console.log(chalk.green("Prompt updated"));
|
|
328
|
+
console.log(` ID: ${chalk.green(data.id)}`);
|
|
329
|
+
console.log(` Name: ${data.name}`);
|
|
330
|
+
if (data.model) console.log(` Model: ${data.model}`);
|
|
331
|
+
} catch (error) {
|
|
332
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
333
|
+
console.error(chalk.red(`Failed to update prompt: ${message}`));
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const App = () => {
|
|
339
|
+
const [loading, setLoading] = useState(true);
|
|
340
|
+
const [success, setSuccess] = useState(null);
|
|
341
|
+
const [error, setError] = useState(null);
|
|
342
|
+
const [result, setResult] = useState(null);
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
client.put(`/prompts/${id}`, body).then((data) => {
|
|
345
|
+
setResult(data);
|
|
346
|
+
setSuccess(true);
|
|
347
|
+
setLoading(false);
|
|
348
|
+
}).catch((err) => {
|
|
349
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
350
|
+
setSuccess(false);
|
|
351
|
+
setLoading(false);
|
|
352
|
+
});
|
|
353
|
+
}, []);
|
|
354
|
+
return React.createElement(MutationResult, {
|
|
355
|
+
loading,
|
|
356
|
+
loadingLabel: "Updating prompt...",
|
|
357
|
+
success,
|
|
358
|
+
successMessage: "Prompt updated",
|
|
359
|
+
error,
|
|
360
|
+
result: result ? React.createElement(EntityCard, { fields: [
|
|
361
|
+
{
|
|
362
|
+
label: "ID",
|
|
363
|
+
value: result.id,
|
|
364
|
+
color: "green"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
label: "Name",
|
|
368
|
+
value: result.name
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
label: "Model",
|
|
372
|
+
value: result.model,
|
|
373
|
+
color: "blue"
|
|
374
|
+
}
|
|
375
|
+
] }) : void 0
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
379
|
+
await waitUntilExit();
|
|
380
|
+
});
|
|
381
|
+
promptsCommand.command("delete <id>").description("Delete a prompt").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").option("--yes", "Skip confirmation").action(async (id, options) => {
|
|
382
|
+
const apiKey = await ensureAuth();
|
|
383
|
+
if (!apiKey) return;
|
|
384
|
+
const client = createCliClient(apiKey);
|
|
385
|
+
if (!isTTY(options)) {
|
|
386
|
+
try {
|
|
387
|
+
await client.prompts.delete(id);
|
|
388
|
+
console.log(chalk.green("Prompt deleted"));
|
|
389
|
+
} catch (error) {
|
|
390
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
391
|
+
console.error(chalk.red(`Failed to delete prompt: ${message}`));
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const runDelete = () => {
|
|
397
|
+
const App = () => {
|
|
398
|
+
const [loading, setLoading] = useState(true);
|
|
399
|
+
const [success, setSuccess] = useState(null);
|
|
400
|
+
const [error, setError] = useState(null);
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
client.delete(`/prompts/${id}`).then(() => {
|
|
403
|
+
setSuccess(true);
|
|
404
|
+
setLoading(false);
|
|
405
|
+
}).catch((err) => {
|
|
406
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
407
|
+
setSuccess(false);
|
|
408
|
+
setLoading(false);
|
|
409
|
+
});
|
|
410
|
+
}, []);
|
|
411
|
+
return React.createElement(MutationResult, {
|
|
412
|
+
loading,
|
|
413
|
+
loadingLabel: "Deleting prompt...",
|
|
414
|
+
success,
|
|
415
|
+
successMessage: "Prompt deleted",
|
|
416
|
+
error
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
return App;
|
|
420
|
+
};
|
|
421
|
+
if (options.yes) {
|
|
422
|
+
const { waitUntilExit } = render(React.createElement(runDelete()));
|
|
423
|
+
await waitUntilExit();
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (!await new Promise((resolve) => {
|
|
427
|
+
const { unmount } = render(React.createElement(ConfirmPrompt, {
|
|
428
|
+
message: `Delete prompt ${id}?`,
|
|
429
|
+
defaultValue: false,
|
|
430
|
+
onConfirm: (result) => {
|
|
431
|
+
resolve(result);
|
|
432
|
+
unmount();
|
|
433
|
+
}
|
|
434
|
+
}));
|
|
435
|
+
})) return;
|
|
436
|
+
const { waitUntilExit } = render(React.createElement(runDelete()));
|
|
437
|
+
await waitUntilExit();
|
|
438
|
+
});
|
|
439
|
+
export { promptsCommand };
|
|
440
|
+
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as isTTY } from "./index.js";
|
|
3
|
+
import { DataList, EntityCard, MutationResult, React, Text, render, useEffect, useState } from "./chunk-CoAWdSiE.js";
|
|
4
|
+
import { r as createCliClient } from "./chunk-BW2fg46T.js";
|
|
5
|
+
import { n as ensureAuth } from "./chunk-CJraEBVd.js";
|
|
6
|
+
import { a as printJson, i as printDetail } from "./chunk-CcFCyqbB.js";
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
// src/commands/integrations.ts
|
|
10
|
+
const integrationsCommand = new Command("integrations").description("View built-in integrations (Slack, Google, Linear, GitHub, and more)");
|
|
11
|
+
integrationsCommand.command("list").description("List all available integrations").option("--environment <env>", "Filter credential status by environment: development or production").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (options) => {
|
|
12
|
+
const apiKey = await ensureAuth();
|
|
13
|
+
if (!apiKey) return;
|
|
14
|
+
const client = createCliClient(apiKey);
|
|
15
|
+
const params = {};
|
|
16
|
+
if (options.environment) params.environment = options.environment;
|
|
17
|
+
if (!isTTY(options) || options.json) {
|
|
18
|
+
try {
|
|
19
|
+
const data = await client.get("/integrations", params);
|
|
20
|
+
const integrations = data.integrations ?? [];
|
|
21
|
+
if (options.json) printJson(data);
|
|
22
|
+
else {
|
|
23
|
+
if (integrations.length === 0) {
|
|
24
|
+
console.log(chalk.gray("No integrations found"));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(chalk.cyan("Available Integrations:"));
|
|
28
|
+
for (const integration of integrations) {
|
|
29
|
+
const status = integration.isConfigured ? chalk.green("configured") : chalk.yellow("not configured");
|
|
30
|
+
const tools = chalk.gray(` (${integration.toolCount} tools)`);
|
|
31
|
+
console.log(` ${chalk.green(integration.id)} ${integration.name} [${status}]${tools}`);
|
|
32
|
+
}
|
|
33
|
+
console.log(chalk.dim(`\n Total: ${integrations.length} integrations`));
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
37
|
+
console.error(chalk.red("Failed to fetch integrations"));
|
|
38
|
+
console.error(chalk.red(message));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const App = () => {
|
|
44
|
+
const [loading, setLoading] = useState(true);
|
|
45
|
+
const [items, setItems] = useState(null);
|
|
46
|
+
const [total, setTotal] = useState(void 0);
|
|
47
|
+
const [error, setError] = useState(null);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const run = async () => {
|
|
50
|
+
try {
|
|
51
|
+
const integrations = (await client.get("/integrations", params)).integrations ?? [];
|
|
52
|
+
setItems(integrations);
|
|
53
|
+
setTotal(integrations.length);
|
|
54
|
+
setLoading(false);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
57
|
+
setLoading(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
run();
|
|
61
|
+
}, []);
|
|
62
|
+
return React.createElement(DataList, {
|
|
63
|
+
title: "Available Integrations",
|
|
64
|
+
items,
|
|
65
|
+
error,
|
|
66
|
+
loading,
|
|
67
|
+
total,
|
|
68
|
+
emptyMessage: "No integrations found",
|
|
69
|
+
renderCard: (item) => {
|
|
70
|
+
const i = item;
|
|
71
|
+
const status = i.isConfigured ? "configured" : "not configured";
|
|
72
|
+
return React.createElement(Text, null, ` ${i.id} ${i.name} [${status}] (${i.toolCount} tools)`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
77
|
+
await waitUntilExit();
|
|
78
|
+
});
|
|
79
|
+
integrationsCommand.command("get <id>").description("Get integration details, including its tools").option("--json", "Output as JSON").option("--tty", "Force TTY mode").option("--no-tty", "Force non-TTY mode").action(async (id, options) => {
|
|
80
|
+
const apiKey = await ensureAuth();
|
|
81
|
+
if (!apiKey) return;
|
|
82
|
+
const client = createCliClient(apiKey);
|
|
83
|
+
if (!isTTY(options) || options.json) {
|
|
84
|
+
try {
|
|
85
|
+
const data = await client.get(`/integrations/${id}`);
|
|
86
|
+
if (options.json) printJson(data);
|
|
87
|
+
else {
|
|
88
|
+
printDetail("Integration", [
|
|
89
|
+
{
|
|
90
|
+
label: "ID",
|
|
91
|
+
value: data.id
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: "Name",
|
|
95
|
+
value: data.name
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
label: "Description",
|
|
99
|
+
value: data.description
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: "Category",
|
|
103
|
+
value: data.category
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: "Configured",
|
|
107
|
+
value: data.isConfigured
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: "Required Credentials",
|
|
111
|
+
value: (data.requiredCredentials || []).join(", ") || null
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: "Missing Credentials",
|
|
115
|
+
value: (data.missingCredentials || []).join(", ") || null
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: "Documentation",
|
|
119
|
+
value: data.documentationUrl
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: "Tool Count",
|
|
123
|
+
value: (data.tools || []).length
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
const tools = data.tools ?? [];
|
|
127
|
+
if (tools.length > 0) {
|
|
128
|
+
console.log(chalk.cyan("\nTools:"));
|
|
129
|
+
for (const tool of tools) console.log(` ${chalk.green(tool.toolId)} ${chalk.gray(tool.description)}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
134
|
+
console.error(chalk.red("Failed to fetch integration"));
|
|
135
|
+
console.error(chalk.red(message));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const App = () => {
|
|
141
|
+
const [loading, setLoading] = useState(true);
|
|
142
|
+
const [success, setSuccess] = useState(null);
|
|
143
|
+
const [error, setError] = useState(null);
|
|
144
|
+
const [resultNode, setResultNode] = useState(void 0);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
const run = async () => {
|
|
147
|
+
try {
|
|
148
|
+
const data = await client.get(`/integrations/${id}`);
|
|
149
|
+
const tools = data.tools ?? [];
|
|
150
|
+
setResultNode(React.createElement(EntityCard, { fields: [
|
|
151
|
+
{
|
|
152
|
+
label: "ID",
|
|
153
|
+
value: data.id,
|
|
154
|
+
color: "green"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: "Name",
|
|
158
|
+
value: data.name
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
label: "Description",
|
|
162
|
+
value: data.description
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: "Category",
|
|
166
|
+
value: data.category
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: "Configured",
|
|
170
|
+
value: String(data.isConfigured)
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
label: "Required Credentials",
|
|
174
|
+
value: (data.requiredCredentials || []).join(", ") || null
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
label: "Missing Credentials",
|
|
178
|
+
value: (data.missingCredentials || []).join(", ") || null
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: "Documentation",
|
|
182
|
+
value: data.documentationUrl
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: "Tool Count",
|
|
186
|
+
value: String(tools.length)
|
|
187
|
+
}
|
|
188
|
+
] }));
|
|
189
|
+
setSuccess(true);
|
|
190
|
+
setLoading(false);
|
|
191
|
+
} catch (err) {
|
|
192
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
193
|
+
setSuccess(false);
|
|
194
|
+
setLoading(false);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
run();
|
|
198
|
+
}, []);
|
|
199
|
+
return React.createElement(MutationResult, {
|
|
200
|
+
loading,
|
|
201
|
+
loadingLabel: "Fetching integration...",
|
|
202
|
+
success,
|
|
203
|
+
successMessage: "Integration",
|
|
204
|
+
error,
|
|
205
|
+
result: resultNode
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
const { waitUntilExit } = render(React.createElement(App));
|
|
209
|
+
await waitUntilExit();
|
|
210
|
+
});
|
|
211
|
+
export { integrationsCommand };
|
|
212
|
+
|