@wisebotai/cli 0.2.0 → 0.2.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/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +511 -0
- package/package.json +29 -26
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const proc = globalThis.process;
|
|
3
|
+
/**
|
|
4
|
+
* WisebotAI CLI — apps/web APIs + optional workflow webhook trigger:
|
|
5
|
+
* GET /api/v1/status, /api/v1/activity, …
|
|
6
|
+
* POST {WISEBOT_WORKFLOW_TRIGGER_ORIGIN}/workflows/trigger — see docs/workflows/cli-and-sdk; full CLI: docs/wisebot-cli
|
|
7
|
+
*
|
|
8
|
+
* Env (dashboard API): WISEBOTAI_BASE_URL, WISEBOT_ACCESS_TOKEN (or WISE_KEY)
|
|
9
|
+
* Env (workflow trigger): WISEBOT_WORKFLOW_TRIGGER_ORIGIN, WISEBOT_WORKFLOW_SECRET
|
|
10
|
+
*/
|
|
11
|
+
function baseUrl() {
|
|
12
|
+
const raw = proc.env.WISEBOTAI_BASE_URL?.trim() ?? "";
|
|
13
|
+
if (!raw) {
|
|
14
|
+
console.error("Missing WISEBOTAI_BASE_URL (apps/web origin, e.g. http://localhost:3000)");
|
|
15
|
+
proc.exit(1);
|
|
16
|
+
}
|
|
17
|
+
return raw.replace(/\/$/, "");
|
|
18
|
+
}
|
|
19
|
+
function bearer() {
|
|
20
|
+
const t = proc.env.WISEBOT_ACCESS_TOKEN?.trim() ||
|
|
21
|
+
proc.env.WISE_KEY?.trim() ||
|
|
22
|
+
"";
|
|
23
|
+
if (!t) {
|
|
24
|
+
console.error("Missing WISEBOT_ACCESS_TOKEN or WISE_KEY (JWT or wb_live_… API key)");
|
|
25
|
+
proc.exit(1);
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
async function cmdStatus() {
|
|
30
|
+
const res = await fetch(`${baseUrl()}/api/v1/status`, {
|
|
31
|
+
headers: { Authorization: `Bearer ${bearer()}` },
|
|
32
|
+
});
|
|
33
|
+
const text = await res.text();
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
console.error(text || res.statusText);
|
|
36
|
+
proc.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const data = JSON.parse(text);
|
|
39
|
+
console.log(JSON.stringify(data, null, 2));
|
|
40
|
+
}
|
|
41
|
+
async function cmdAgentsList() {
|
|
42
|
+
const res = await fetch(`${baseUrl()}/api/v1/agents`, {
|
|
43
|
+
headers: { Authorization: `Bearer ${bearer()}` },
|
|
44
|
+
});
|
|
45
|
+
const text = await res.text();
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
console.error(text || res.statusText);
|
|
48
|
+
proc.exit(1);
|
|
49
|
+
}
|
|
50
|
+
const data = JSON.parse(text);
|
|
51
|
+
console.log(JSON.stringify(data, null, 2));
|
|
52
|
+
}
|
|
53
|
+
async function cmdApiKeysList() {
|
|
54
|
+
const res = await fetch(`${baseUrl()}/api/v1/api-keys`, {
|
|
55
|
+
headers: { Authorization: `Bearer ${bearer()}` },
|
|
56
|
+
});
|
|
57
|
+
const text = await res.text();
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
console.error(text || res.statusText);
|
|
60
|
+
proc.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const data = JSON.parse(text);
|
|
63
|
+
console.log(JSON.stringify(data, null, 2));
|
|
64
|
+
}
|
|
65
|
+
async function cmdWebhooksList() {
|
|
66
|
+
const res = await fetch(`${baseUrl()}/api/v1/webhooks`, {
|
|
67
|
+
headers: { Authorization: `Bearer ${bearer()}` },
|
|
68
|
+
});
|
|
69
|
+
const text = await res.text();
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
console.error(text || res.statusText);
|
|
72
|
+
proc.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const data = JSON.parse(text);
|
|
75
|
+
console.log(JSON.stringify(data, null, 2));
|
|
76
|
+
}
|
|
77
|
+
async function cmdLogs(tail) {
|
|
78
|
+
if (!tail) {
|
|
79
|
+
console.error("Usage: wisebot logs --tail");
|
|
80
|
+
proc.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const res = await fetch(`${baseUrl()}/api/v1/activity?limit=20`, {
|
|
83
|
+
headers: { Authorization: `Bearer ${bearer()}` },
|
|
84
|
+
});
|
|
85
|
+
const text = await res.text();
|
|
86
|
+
if (!res.ok) {
|
|
87
|
+
console.error(text || res.statusText);
|
|
88
|
+
proc.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const data = JSON.parse(text);
|
|
91
|
+
for (const line of data.lines ?? []) {
|
|
92
|
+
const ts = new Date(line.createdAt).toISOString();
|
|
93
|
+
const agent = line.agentName ? ` agent=${line.agentName}` : "";
|
|
94
|
+
console.log(`[${ts}] conversation=${line.conversationId} status=${line.status}${agent}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function workflowTriggerOrigin() {
|
|
98
|
+
const raw = proc.env.WISEBOT_WORKFLOW_TRIGGER_ORIGIN?.trim() ||
|
|
99
|
+
proc.env.WISEBOT_CONVEX_SITE?.trim() ||
|
|
100
|
+
proc.env.CONVEX_SITE_URL?.trim() ||
|
|
101
|
+
"";
|
|
102
|
+
if (!raw) {
|
|
103
|
+
console.error("Missing WISEBOT_WORKFLOW_TRIGGER_ORIGIN (HTTPS origin for workflow triggers, e.g. https://trigger.example.com)");
|
|
104
|
+
proc.exit(1);
|
|
105
|
+
}
|
|
106
|
+
return raw.replace(/\/$/, "");
|
|
107
|
+
}
|
|
108
|
+
function workflowWebhookSecret() {
|
|
109
|
+
const s = proc.env.WISEBOT_WORKFLOW_SECRET?.trim() || "";
|
|
110
|
+
if (!s) {
|
|
111
|
+
console.error("Missing WISEBOT_WORKFLOW_SECRET (from the workflow editor → webhook secret)");
|
|
112
|
+
proc.exit(1);
|
|
113
|
+
}
|
|
114
|
+
return s;
|
|
115
|
+
}
|
|
116
|
+
function playgroundJwt() {
|
|
117
|
+
const t = bearer();
|
|
118
|
+
if (t.startsWith("wb_live_")) {
|
|
119
|
+
console.error("Playground commands require a dashboard JWT (not wb_live_ API keys)");
|
|
120
|
+
proc.exit(1);
|
|
121
|
+
}
|
|
122
|
+
return t;
|
|
123
|
+
}
|
|
124
|
+
async function pgFetch(path, init) {
|
|
125
|
+
return fetch(`${baseUrl()}${path}`, {
|
|
126
|
+
...init,
|
|
127
|
+
headers: {
|
|
128
|
+
Authorization: `Bearer ${playgroundJwt()}`,
|
|
129
|
+
...(init?.headers ?? {}),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function cmdPlaygroundSessionCreate(agentId, forceNew) {
|
|
134
|
+
const res = await pgFetch("/api/v1/playground/sessions", {
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers: { "Content-Type": "application/json" },
|
|
137
|
+
body: JSON.stringify({
|
|
138
|
+
...(agentId ? { agentId } : {}),
|
|
139
|
+
...(forceNew ? { forceNew: true } : {}),
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
const text = await res.text();
|
|
143
|
+
if (!res.ok) {
|
|
144
|
+
console.error(text || res.statusText);
|
|
145
|
+
proc.exit(1);
|
|
146
|
+
}
|
|
147
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
148
|
+
}
|
|
149
|
+
async function cmdPlaygroundSessionsList(agentId) {
|
|
150
|
+
const q = new URLSearchParams({ agentId });
|
|
151
|
+
const res = await pgFetch(`/api/v1/playground/sessions?${q}`);
|
|
152
|
+
const text = await res.text();
|
|
153
|
+
if (!res.ok) {
|
|
154
|
+
console.error(text || res.statusText);
|
|
155
|
+
proc.exit(1);
|
|
156
|
+
}
|
|
157
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
158
|
+
}
|
|
159
|
+
async function cmdPlaygroundSessionResume(conversationId) {
|
|
160
|
+
const res = await pgFetch("/api/v1/playground/sessions/resume", {
|
|
161
|
+
method: "POST",
|
|
162
|
+
headers: { "Content-Type": "application/json" },
|
|
163
|
+
body: JSON.stringify({ conversationId }),
|
|
164
|
+
});
|
|
165
|
+
const text = await res.text();
|
|
166
|
+
if (!res.ok) {
|
|
167
|
+
console.error(text || res.statusText);
|
|
168
|
+
proc.exit(1);
|
|
169
|
+
}
|
|
170
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
171
|
+
}
|
|
172
|
+
async function cmdPlaygroundSend(conversationId, contactSessionId, message) {
|
|
173
|
+
const res = await pgFetch("/api/v1/playground/messages", {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "Content-Type": "application/json" },
|
|
176
|
+
body: JSON.stringify({ conversationId, contactSessionId, message }),
|
|
177
|
+
});
|
|
178
|
+
const text = await res.text();
|
|
179
|
+
if (!res.ok) {
|
|
180
|
+
console.error(text || res.statusText);
|
|
181
|
+
proc.exit(1);
|
|
182
|
+
}
|
|
183
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
184
|
+
}
|
|
185
|
+
async function cmdPlaygroundWait(conversationId, timeoutSec) {
|
|
186
|
+
const deadline = Date.now() + timeoutSec * 1000;
|
|
187
|
+
while (Date.now() < deadline) {
|
|
188
|
+
const q = new URLSearchParams({ conversationId });
|
|
189
|
+
const res = await pgFetch(`/api/v1/playground/runs/latest?${q}`);
|
|
190
|
+
const text = await res.text();
|
|
191
|
+
if (!res.ok) {
|
|
192
|
+
console.error(text || res.statusText);
|
|
193
|
+
proc.exit(1);
|
|
194
|
+
}
|
|
195
|
+
const data = JSON.parse(text);
|
|
196
|
+
const status = data.run?.status ?? "";
|
|
197
|
+
if (status === "completed" ||
|
|
198
|
+
status === "completed_with_warnings" ||
|
|
199
|
+
status === "failed" ||
|
|
200
|
+
status === "stopped" ||
|
|
201
|
+
status === "needs_approval") {
|
|
202
|
+
console.log(JSON.stringify(data.run, null, 2));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
206
|
+
}
|
|
207
|
+
console.error(`Timed out after ${timeoutSec}s`);
|
|
208
|
+
proc.exit(1);
|
|
209
|
+
}
|
|
210
|
+
async function cmdPlaygroundApprovalsPending(runId) {
|
|
211
|
+
const q = new URLSearchParams({ runId });
|
|
212
|
+
const res = await pgFetch(`/api/v1/playground/approvals/pending?${q}`);
|
|
213
|
+
const text = await res.text();
|
|
214
|
+
if (!res.ok) {
|
|
215
|
+
console.error(text || res.statusText);
|
|
216
|
+
proc.exit(1);
|
|
217
|
+
}
|
|
218
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
219
|
+
}
|
|
220
|
+
async function cmdPlaygroundApprove(approvalId) {
|
|
221
|
+
const res = await pgFetch(`/api/v1/playground/approvals/${encodeURIComponent(approvalId)}/approve`, { method: "POST" });
|
|
222
|
+
const text = await res.text();
|
|
223
|
+
if (!res.ok) {
|
|
224
|
+
console.error(text || res.statusText);
|
|
225
|
+
proc.exit(1);
|
|
226
|
+
}
|
|
227
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
228
|
+
}
|
|
229
|
+
async function cmdPlaygroundDeny(approvalId) {
|
|
230
|
+
const res = await pgFetch(`/api/v1/playground/approvals/${encodeURIComponent(approvalId)}/deny`, { method: "POST" });
|
|
231
|
+
const text = await res.text();
|
|
232
|
+
if (!res.ok) {
|
|
233
|
+
console.error(text || res.statusText);
|
|
234
|
+
proc.exit(1);
|
|
235
|
+
}
|
|
236
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
237
|
+
}
|
|
238
|
+
async function cmdPlaygroundStop(conversationId) {
|
|
239
|
+
const res = await pgFetch("/api/v1/playground/runs/stop", {
|
|
240
|
+
method: "POST",
|
|
241
|
+
headers: { "Content-Type": "application/json" },
|
|
242
|
+
body: JSON.stringify({ conversationId }),
|
|
243
|
+
});
|
|
244
|
+
const text = await res.text();
|
|
245
|
+
if (!res.ok) {
|
|
246
|
+
console.error(text || res.statusText);
|
|
247
|
+
proc.exit(1);
|
|
248
|
+
}
|
|
249
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
250
|
+
}
|
|
251
|
+
async function cmdPlaygroundMessages(threadId) {
|
|
252
|
+
const q = new URLSearchParams({ threadId });
|
|
253
|
+
const res = await pgFetch(`/api/v1/playground/messages?${q}`);
|
|
254
|
+
const text = await res.text();
|
|
255
|
+
if (!res.ok) {
|
|
256
|
+
console.error(text || res.statusText);
|
|
257
|
+
proc.exit(1);
|
|
258
|
+
}
|
|
259
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
260
|
+
}
|
|
261
|
+
async function cmdPlaygroundTraces(runId) {
|
|
262
|
+
const res = await pgFetch(`/api/v1/playground/runs/${encodeURIComponent(runId)}/traces`);
|
|
263
|
+
const text = await res.text();
|
|
264
|
+
if (!res.ok) {
|
|
265
|
+
console.error(text || res.statusText);
|
|
266
|
+
proc.exit(1);
|
|
267
|
+
}
|
|
268
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
269
|
+
}
|
|
270
|
+
async function cmdWorkflowTrigger(workflowId, body) {
|
|
271
|
+
const url = `${workflowTriggerOrigin()}/workflows/trigger?workflowId=${encodeURIComponent(workflowId)}`;
|
|
272
|
+
const res = await fetch(url, {
|
|
273
|
+
method: "POST",
|
|
274
|
+
headers: {
|
|
275
|
+
Authorization: `Bearer ${workflowWebhookSecret()}`,
|
|
276
|
+
...(body ? { "Content-Type": "application/json" } : {}),
|
|
277
|
+
},
|
|
278
|
+
...(body ? { body } : {}),
|
|
279
|
+
});
|
|
280
|
+
const text = await res.text();
|
|
281
|
+
try {
|
|
282
|
+
console.log(JSON.stringify(JSON.parse(text), null, 2));
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
console.log(text);
|
|
286
|
+
}
|
|
287
|
+
if (!res.ok) {
|
|
288
|
+
proc.exit(1);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function printHelp() {
|
|
292
|
+
console.log(`wisebot — WisebotAI CLI
|
|
293
|
+
|
|
294
|
+
Environment (dashboard API):
|
|
295
|
+
WISEBOTAI_BASE_URL apps/web origin (no path)
|
|
296
|
+
WISEBOT_ACCESS_TOKEN dashboard JWT, org API key (wb_live_…), or WISE_KEY
|
|
297
|
+
|
|
298
|
+
Environment (workflow webhook trigger — separate from dashboard token):
|
|
299
|
+
WISEBOT_WORKFLOW_TRIGGER_ORIGIN HTTPS origin for POST /workflows/trigger (copy from workflow editor)
|
|
300
|
+
WISEBOT_WORKFLOW_SECRET Secret from the workflow editor
|
|
301
|
+
|
|
302
|
+
Commands:
|
|
303
|
+
wisebot status Session + organization metrics (JWT or API key)
|
|
304
|
+
wisebot logs --tail Recent conversations (JWT or API key)
|
|
305
|
+
wisebot agents list List agents (JWT or API key)
|
|
306
|
+
wisebot api-keys list List key metadata — requires dashboard JWT
|
|
307
|
+
wisebot webhooks list List webhook endpoints — requires dashboard JWT
|
|
308
|
+
wisebot workflow trigger <workflowId> [--data '{"key":"value"}']
|
|
309
|
+
POST to workflow trigger URL (env: origin + secret)
|
|
310
|
+
|
|
311
|
+
Playground (dashboard JWT only — not wb_live_ API keys):
|
|
312
|
+
wisebot playground session create [--agent ID] [--force-new]
|
|
313
|
+
wisebot playground sessions list --agent ID
|
|
314
|
+
wisebot playground session resume --conversation ID
|
|
315
|
+
wisebot playground send --conversation ID --session ID --message "..."
|
|
316
|
+
wisebot playground wait --conversation ID [--timeout 120]
|
|
317
|
+
wisebot playground approvals pending --run ID
|
|
318
|
+
wisebot playground approve --id ID
|
|
319
|
+
wisebot playground deny --id ID
|
|
320
|
+
wisebot playground stop --conversation ID
|
|
321
|
+
wisebot playground messages --thread ID
|
|
322
|
+
wisebot playground traces --run ID
|
|
323
|
+
|
|
324
|
+
For full observability, use the dashboard: Analytics and Conversations.`);
|
|
325
|
+
}
|
|
326
|
+
async function main() {
|
|
327
|
+
const argv = proc.argv.slice(2);
|
|
328
|
+
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
329
|
+
printHelp();
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const [cmd, ...rest] = argv;
|
|
333
|
+
if (cmd === "status") {
|
|
334
|
+
await cmdStatus();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (cmd === "logs" && rest[0] === "--tail") {
|
|
338
|
+
await cmdLogs(true);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (cmd === "agents" && rest[0] === "list") {
|
|
342
|
+
await cmdAgentsList();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (cmd === "api-keys" && rest[0] === "list") {
|
|
346
|
+
await cmdApiKeysList();
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (cmd === "webhooks" && rest[0] === "list") {
|
|
350
|
+
await cmdWebhooksList();
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (cmd === "workflow" && rest[0] === "trigger") {
|
|
354
|
+
const wfIdRaw = rest[1];
|
|
355
|
+
if (!wfIdRaw) {
|
|
356
|
+
console.error('Usage: wisebot workflow trigger <workflowId> [--data \'{"key":"value"}\']');
|
|
357
|
+
proc.exit(1);
|
|
358
|
+
}
|
|
359
|
+
const wfId = String(wfIdRaw);
|
|
360
|
+
const di = rest.indexOf("--data");
|
|
361
|
+
let jsonBody;
|
|
362
|
+
if (di >= 0) {
|
|
363
|
+
const raw = rest[di + 1];
|
|
364
|
+
if (!raw) {
|
|
365
|
+
console.error("wisebot workflow trigger: --data requires a JSON string");
|
|
366
|
+
proc.exit(1);
|
|
367
|
+
}
|
|
368
|
+
jsonBody = String(raw);
|
|
369
|
+
try {
|
|
370
|
+
JSON.parse(jsonBody);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
console.error("wisebot workflow trigger: --data must be valid JSON");
|
|
374
|
+
proc.exit(1);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
await cmdWorkflowTrigger(wfId, jsonBody);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (cmd === "playground") {
|
|
381
|
+
const sub = rest[0];
|
|
382
|
+
if (sub === "session" && rest[1] === "create") {
|
|
383
|
+
let agentId;
|
|
384
|
+
let forceNew = false;
|
|
385
|
+
for (let i = 2; i < rest.length; i++) {
|
|
386
|
+
if (rest[i] === "--agent" && rest[i + 1]) {
|
|
387
|
+
agentId = rest[++i];
|
|
388
|
+
}
|
|
389
|
+
else if (rest[i] === "--force-new") {
|
|
390
|
+
forceNew = true;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
await cmdPlaygroundSessionCreate(agentId, forceNew);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (sub === "sessions" && rest[1] === "list") {
|
|
397
|
+
const ai = rest.indexOf("--agent");
|
|
398
|
+
const agentId = ai >= 0 ? rest[ai + 1] : undefined;
|
|
399
|
+
if (!agentId) {
|
|
400
|
+
console.error("Usage: wisebot playground sessions list --agent ID");
|
|
401
|
+
proc.exit(1);
|
|
402
|
+
}
|
|
403
|
+
await cmdPlaygroundSessionsList(String(agentId));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (sub === "session" && rest[1] === "resume") {
|
|
407
|
+
const ci = rest.indexOf("--conversation");
|
|
408
|
+
const conversationId = ci >= 0 ? rest[ci + 1] : undefined;
|
|
409
|
+
if (!conversationId) {
|
|
410
|
+
console.error("Usage: wisebot playground session resume --conversation ID");
|
|
411
|
+
proc.exit(1);
|
|
412
|
+
}
|
|
413
|
+
await cmdPlaygroundSessionResume(String(conversationId));
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (sub === "send") {
|
|
417
|
+
const getFlag = (flag) => {
|
|
418
|
+
const i = rest.indexOf(flag);
|
|
419
|
+
return i >= 0 ? rest[i + 1] : undefined;
|
|
420
|
+
};
|
|
421
|
+
const conversationId = getFlag("--conversation");
|
|
422
|
+
const contactSessionId = getFlag("--session");
|
|
423
|
+
const message = getFlag("--message");
|
|
424
|
+
if (!conversationId || !contactSessionId || !message) {
|
|
425
|
+
console.error("Usage: wisebot playground send --conversation ID --session ID --message \"...\"");
|
|
426
|
+
proc.exit(1);
|
|
427
|
+
}
|
|
428
|
+
await cmdPlaygroundSend(String(conversationId), String(contactSessionId), String(message));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (sub === "wait") {
|
|
432
|
+
const ci = rest.indexOf("--conversation");
|
|
433
|
+
const conversationId = ci >= 0 ? rest[ci + 1] : undefined;
|
|
434
|
+
const ti = rest.indexOf("--timeout");
|
|
435
|
+
const timeout = ti >= 0 ? Number(rest[ti + 1]) : 120;
|
|
436
|
+
if (!conversationId) {
|
|
437
|
+
console.error("Usage: wisebot playground wait --conversation ID [--timeout 120]");
|
|
438
|
+
proc.exit(1);
|
|
439
|
+
}
|
|
440
|
+
await cmdPlaygroundWait(String(conversationId), Number.isFinite(timeout) ? timeout : 120);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (sub === "approvals" && rest[1] === "pending") {
|
|
444
|
+
const ri = rest.indexOf("--run");
|
|
445
|
+
const runId = ri >= 0 ? rest[ri + 1] : undefined;
|
|
446
|
+
if (!runId) {
|
|
447
|
+
console.error("Usage: wisebot playground approvals pending --run ID");
|
|
448
|
+
proc.exit(1);
|
|
449
|
+
}
|
|
450
|
+
await cmdPlaygroundApprovalsPending(String(runId));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (sub === "approve") {
|
|
454
|
+
const ii = rest.indexOf("--id");
|
|
455
|
+
const id = ii >= 0 ? rest[ii + 1] : undefined;
|
|
456
|
+
if (!id) {
|
|
457
|
+
console.error("Usage: wisebot playground approve --id ID");
|
|
458
|
+
proc.exit(1);
|
|
459
|
+
}
|
|
460
|
+
await cmdPlaygroundApprove(String(id));
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (sub === "deny") {
|
|
464
|
+
const ii = rest.indexOf("--id");
|
|
465
|
+
const id = ii >= 0 ? rest[ii + 1] : undefined;
|
|
466
|
+
if (!id) {
|
|
467
|
+
console.error("Usage: wisebot playground deny --id ID");
|
|
468
|
+
proc.exit(1);
|
|
469
|
+
}
|
|
470
|
+
await cmdPlaygroundDeny(String(id));
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (sub === "stop") {
|
|
474
|
+
const ci = rest.indexOf("--conversation");
|
|
475
|
+
const conversationId = ci >= 0 ? rest[ci + 1] : undefined;
|
|
476
|
+
if (!conversationId) {
|
|
477
|
+
console.error("Usage: wisebot playground stop --conversation ID");
|
|
478
|
+
proc.exit(1);
|
|
479
|
+
}
|
|
480
|
+
await cmdPlaygroundStop(String(conversationId));
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
if (sub === "messages") {
|
|
484
|
+
const ti = rest.indexOf("--thread");
|
|
485
|
+
const threadId = ti >= 0 ? rest[ti + 1] : undefined;
|
|
486
|
+
if (!threadId) {
|
|
487
|
+
console.error("Usage: wisebot playground messages --thread ID");
|
|
488
|
+
proc.exit(1);
|
|
489
|
+
}
|
|
490
|
+
await cmdPlaygroundMessages(String(threadId));
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (sub === "traces") {
|
|
494
|
+
const ri = rest.indexOf("--run");
|
|
495
|
+
const runId = ri >= 0 ? rest[ri + 1] : undefined;
|
|
496
|
+
if (!runId) {
|
|
497
|
+
console.error("Usage: wisebot playground traces --run ID");
|
|
498
|
+
proc.exit(1);
|
|
499
|
+
}
|
|
500
|
+
await cmdPlaygroundTraces(String(runId));
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
printHelp();
|
|
505
|
+
proc.exit(1);
|
|
506
|
+
}
|
|
507
|
+
main().catch((e) => {
|
|
508
|
+
console.error(e instanceof Error ? e.message : e);
|
|
509
|
+
proc.exit(1);
|
|
510
|
+
});
|
|
511
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wisebotai/cli",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "WisebotAI CLI (status + recent conversation activity)",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
|
-
"bin": {
|
|
10
|
-
"wisebot": "./dist/cli.js"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@wisebotai/cli",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "WisebotAI CLI (status + recent conversation activity)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"wisebot": "./dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20",
|
|
17
|
+
"typescript": "5.7.3",
|
|
18
|
+
"@workspace/typescript-config": "0.0.0"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"postbuild": "chmod +x dist/cli.js",
|
|
26
|
+
"dev": "tsc --watch",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
}
|
|
29
|
+
}
|