@astroanywhere/cli 0.2.1 → 0.2.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.
- package/dist/{chunk-SYY2HHOY.js → chunk-MJRAJPBU.js} +41 -17
- package/dist/client.js +3 -1
- package/dist/index.js +3 -1
- package/dist/tui.js +1146 -405
- package/package.json +1 -1
|
@@ -321,6 +321,10 @@ var AstroClient = class {
|
|
|
321
321
|
async sendApproval(payload) {
|
|
322
322
|
return this.post("/api/dispatch/approval", payload);
|
|
323
323
|
}
|
|
324
|
+
// ── Summarize ──────────────────────────────────────────────────────
|
|
325
|
+
async summarize(payload) {
|
|
326
|
+
return this.post("/api/agent/summarize", payload);
|
|
327
|
+
}
|
|
324
328
|
// ── Slurm Dispatch ────────────────────────────────────────────────
|
|
325
329
|
async dispatchSlurmTask(payload) {
|
|
326
330
|
const url = new URL("/api/relay/slurm/dispatch", this.baseUrl);
|
|
@@ -336,33 +340,51 @@ var AstroClient = class {
|
|
|
336
340
|
return res;
|
|
337
341
|
}
|
|
338
342
|
};
|
|
339
|
-
function parseSSELines(buffer, lines) {
|
|
340
|
-
const events = [];
|
|
341
|
-
for (const line of lines) {
|
|
342
|
-
if (line.startsWith("data: ")) {
|
|
343
|
-
try {
|
|
344
|
-
events.push(JSON.parse(line.slice(6)));
|
|
345
|
-
} catch {
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return events;
|
|
350
|
-
}
|
|
351
343
|
async function readSSEStream(response, handler) {
|
|
352
344
|
if (!response.body) return;
|
|
353
345
|
const reader = response.body.getReader();
|
|
354
346
|
const decoder = new TextDecoder();
|
|
355
347
|
let buffer = "";
|
|
348
|
+
let currentEvent = "";
|
|
349
|
+
let dataLines = [];
|
|
350
|
+
function flushEvent() {
|
|
351
|
+
if (!currentEvent) return null;
|
|
352
|
+
const data = dataLines.join("\n");
|
|
353
|
+
const event = currentEvent;
|
|
354
|
+
currentEvent = "";
|
|
355
|
+
dataLines = [];
|
|
356
|
+
if (event === "text") {
|
|
357
|
+
return { type: "text", content: data, text: data };
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
const parsed = JSON.parse(data);
|
|
361
|
+
return { type: event, ...parsed };
|
|
362
|
+
} catch {
|
|
363
|
+
return { type: event, data };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
356
366
|
while (true) {
|
|
357
367
|
const { done, value } = await reader.read();
|
|
358
368
|
if (done) break;
|
|
359
369
|
buffer += decoder.decode(value, { stream: true });
|
|
360
370
|
const lines = buffer.split("\n");
|
|
361
371
|
buffer = lines.pop() ?? "";
|
|
362
|
-
for (const
|
|
363
|
-
|
|
372
|
+
for (const line of lines) {
|
|
373
|
+
if (line.startsWith("event:")) {
|
|
374
|
+
const pending2 = flushEvent();
|
|
375
|
+
if (pending2) await handler(pending2);
|
|
376
|
+
currentEvent = line.slice(6).trim();
|
|
377
|
+
} else if (line.startsWith("data:")) {
|
|
378
|
+
const value2 = line.slice(5);
|
|
379
|
+
dataLines.push(value2.startsWith(" ") ? value2.slice(1) : value2);
|
|
380
|
+
} else if (line === "") {
|
|
381
|
+
const pending2 = flushEvent();
|
|
382
|
+
if (pending2) await handler(pending2);
|
|
383
|
+
}
|
|
364
384
|
}
|
|
365
385
|
}
|
|
386
|
+
const pending = flushEvent();
|
|
387
|
+
if (pending) await handler(pending);
|
|
366
388
|
}
|
|
367
389
|
async function streamDispatchToStdout(response, opts) {
|
|
368
390
|
const result = {};
|
|
@@ -382,7 +404,7 @@ async function streamDispatchToStdout(response, opts) {
|
|
|
382
404
|
break;
|
|
383
405
|
case "tool_use":
|
|
384
406
|
process.stderr.write(`
|
|
385
|
-
[tool] ${event.name}
|
|
407
|
+
[tool] ${event.toolName ?? event.name}
|
|
386
408
|
`);
|
|
387
409
|
break;
|
|
388
410
|
case "tool_result":
|
|
@@ -428,10 +450,11 @@ async function streamDispatchToStdout(response, opts) {
|
|
|
428
450
|
break;
|
|
429
451
|
case "error":
|
|
430
452
|
console.error(`
|
|
431
|
-
Error: ${event.message}`);
|
|
453
|
+
Error: ${event.error ?? event.message}`);
|
|
432
454
|
break;
|
|
433
455
|
case "done":
|
|
434
456
|
case "heartbeat":
|
|
457
|
+
case "aborted":
|
|
435
458
|
break;
|
|
436
459
|
}
|
|
437
460
|
});
|
|
@@ -458,7 +481,7 @@ async function streamChatToStdout(response, opts) {
|
|
|
458
481
|
break;
|
|
459
482
|
case "tool_use":
|
|
460
483
|
process.stderr.write(`
|
|
461
|
-
[tool] ${event.name}
|
|
484
|
+
[tool] ${event.toolName ?? event.name}
|
|
462
485
|
`);
|
|
463
486
|
break;
|
|
464
487
|
case "tool_result":
|
|
@@ -536,6 +559,7 @@ export {
|
|
|
536
559
|
resetConfig,
|
|
537
560
|
getServerUrl,
|
|
538
561
|
AstroClient,
|
|
562
|
+
readSSEStream,
|
|
539
563
|
streamDispatchToStdout,
|
|
540
564
|
streamChatToStdout,
|
|
541
565
|
getClient
|
package/dist/client.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AstroClient,
|
|
4
4
|
getClient,
|
|
5
|
+
readSSEStream,
|
|
5
6
|
streamChatToStdout,
|
|
6
7
|
streamDispatchToStdout
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MJRAJPBU.js";
|
|
8
9
|
export {
|
|
9
10
|
AstroClient,
|
|
10
11
|
getClient,
|
|
12
|
+
readSSEStream,
|
|
11
13
|
streamChatToStdout,
|
|
12
14
|
streamDispatchToStdout
|
|
13
15
|
};
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
saveConfig,
|
|
9
9
|
streamChatToStdout,
|
|
10
10
|
streamDispatchToStdout
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MJRAJPBU.js";
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
import { Command } from "commander";
|
|
@@ -808,8 +808,10 @@ function registerPlanCommands(program2) {
|
|
|
808
808
|
const response = await client.dispatchTask({
|
|
809
809
|
nodeId: `plan-${cmdOpts.projectId}`,
|
|
810
810
|
projectId: cmdOpts.projectId,
|
|
811
|
+
title: `Interactive planning: ${cmdOpts.description.slice(0, 80)}`,
|
|
811
812
|
isInteractivePlan: true,
|
|
812
813
|
description: cmdOpts.description,
|
|
814
|
+
verification: "human",
|
|
813
815
|
model: cmdOpts.model,
|
|
814
816
|
preferredProvider: cmdOpts.provider,
|
|
815
817
|
targetMachineId: cmdOpts.machine
|