@h-rig/pi-rig 0.0.6-alpha.21 → 0.0.6-alpha.23
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/src/index.js +47 -9
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -381,6 +381,28 @@ function setWidget(ctx, id, lines) {
|
|
|
381
381
|
setWidgetFn.call(ui, id, lines);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
+
function setStatus(ctx, id, text) {
|
|
385
|
+
const ui = ctx && typeof ctx === "object" ? ctx.ui : null;
|
|
386
|
+
const setStatusFn = ui && typeof ui === "object" ? ui.setStatus : null;
|
|
387
|
+
if (typeof setStatusFn === "function") {
|
|
388
|
+
setStatusFn.call(ui, id, text);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function setFooter(ctx, line) {
|
|
392
|
+
const ui = ctx && typeof ctx === "object" ? ctx.ui : null;
|
|
393
|
+
const setFooterFn = ui && typeof ui === "object" ? ui.setFooter : null;
|
|
394
|
+
if (typeof setFooterFn !== "function")
|
|
395
|
+
return;
|
|
396
|
+
setFooterFn.call(ui, () => ({
|
|
397
|
+
render(width) {
|
|
398
|
+
const max = Math.max(0, Math.trunc(width));
|
|
399
|
+
if (max === 0)
|
|
400
|
+
return [""];
|
|
401
|
+
return [line.length > max ? `${line.slice(0, Math.max(0, max - 1))}\u2026` : line];
|
|
402
|
+
},
|
|
403
|
+
invalidate() {}
|
|
404
|
+
}));
|
|
405
|
+
}
|
|
384
406
|
function steeringText(message) {
|
|
385
407
|
const text = typeof message.message === "string" ? message.message.trim() : "";
|
|
386
408
|
if (!text)
|
|
@@ -432,6 +454,12 @@ function shortEntry(entry) {
|
|
|
432
454
|
const text = typeof entry.text === "string" ? entry.text : typeof entry.detail === "string" ? entry.detail : typeof entry.message === "string" ? entry.message : "";
|
|
433
455
|
return `${type}: ${text}`.slice(0, 160);
|
|
434
456
|
}
|
|
457
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
458
|
+
function runLocation(run) {
|
|
459
|
+
const worktree = typeof run.worktreePath === "string" && run.worktreePath.trim() ? run.worktreePath.trim() : null;
|
|
460
|
+
const projectRoot = typeof run.projectRoot === "string" && run.projectRoot.trim() ? run.projectRoot.trim() : null;
|
|
461
|
+
return worktree ?? projectRoot ?? "remote/local worker workspace";
|
|
462
|
+
}
|
|
435
463
|
function runPayload(payload) {
|
|
436
464
|
return payload.run && typeof payload.run === "object" && !Array.isArray(payload.run) ? payload.run : payload;
|
|
437
465
|
}
|
|
@@ -439,28 +467,42 @@ function startOperatorRunWidget(state, ctx) {
|
|
|
439
467
|
if (!state.operatorSession || !state.active || !state.runId)
|
|
440
468
|
return;
|
|
441
469
|
let inFlight = false;
|
|
470
|
+
let frame = 0;
|
|
442
471
|
const refresh = async () => {
|
|
443
472
|
if (inFlight)
|
|
444
473
|
return;
|
|
445
474
|
inFlight = true;
|
|
475
|
+
const spinner = SPINNER_FRAMES[frame++ % SPINNER_FRAMES.length] ?? "\u2022";
|
|
446
476
|
try {
|
|
447
477
|
const [runPayloadRecord, timeline] = await Promise.all([
|
|
448
478
|
state.client.attach(state.runId),
|
|
449
479
|
state.client.runTimeline(state.runId, 8).catch(() => [])
|
|
450
480
|
]);
|
|
451
481
|
const run = runPayload(runPayloadRecord);
|
|
452
|
-
const
|
|
482
|
+
const status = String(run.status ?? "unknown");
|
|
483
|
+
const header = `${spinner} Rig ${String(run.runId ?? state.runId)} \xB7 ${status}`;
|
|
484
|
+
const location = runLocation(run);
|
|
453
485
|
const detail = typeof run.statusDetail === "string" && run.statusDetail.trim() ? run.statusDetail.trim() : String(run.title ?? run.taskId ?? "");
|
|
454
|
-
const lines = [
|
|
486
|
+
const lines = [
|
|
487
|
+
header,
|
|
488
|
+
`worker: ${location}`.slice(0, 200),
|
|
489
|
+
...detail ? [detail.slice(0, 160)] : [],
|
|
490
|
+
...timeline.slice(-5).map(shortEntry)
|
|
491
|
+
];
|
|
492
|
+
setStatus(ctx, "rig", `${spinner} Rig ${status}`);
|
|
493
|
+
setFooter(ctx, `${spinner} Rig ${String(run.runId ?? state.runId)} \xB7 ${status} \xB7 worker ${location}`);
|
|
455
494
|
setWidget(ctx, "rig-run", lines);
|
|
456
495
|
} catch (error) {
|
|
457
|
-
|
|
496
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
497
|
+
setStatus(ctx, "rig", `${spinner} Rig unavailable`);
|
|
498
|
+
setFooter(ctx, `${spinner} Rig ${state.runId} \xB7 unavailable \xB7 ${message}`);
|
|
499
|
+
setWidget(ctx, "rig-run", [`${spinner} Rig ${state.runId} \xB7 unavailable`, message]);
|
|
458
500
|
} finally {
|
|
459
501
|
inFlight = false;
|
|
460
502
|
}
|
|
461
503
|
};
|
|
462
504
|
refresh();
|
|
463
|
-
const timer = setInterval(() => void refresh(),
|
|
505
|
+
const timer = setInterval(() => void refresh(), 1000);
|
|
464
506
|
if (typeof timer.unref === "function") {
|
|
465
507
|
timer.unref();
|
|
466
508
|
}
|
|
@@ -514,11 +556,7 @@ function createPiRigExtension(pi, options = {}) {
|
|
|
514
556
|
pi.on?.("session_start", async (_event, ctx) => {
|
|
515
557
|
if (!state.active || !state.runId)
|
|
516
558
|
return;
|
|
517
|
-
|
|
518
|
-
const setStatus = ui && typeof ui === "object" ? ui.setStatus : null;
|
|
519
|
-
if (typeof setStatus === "function") {
|
|
520
|
-
setStatus.call(ui, "rig", `Rig ${state.runId}`);
|
|
521
|
-
}
|
|
559
|
+
setStatus(ctx, "rig", `Rig ${state.runId}`);
|
|
522
560
|
startOperatorRunWidget(state, ctx);
|
|
523
561
|
await consumeQueuedSteering(pi, state, ctx);
|
|
524
562
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/pi-rig",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@earendil-works/pi-coding-agent": "
|
|
36
|
+
"@earendil-works/pi-coding-agent": "npm:@h-rig/pi-coding-agent@0.0.6-alpha.23",
|
|
37
37
|
"typebox": "*"
|
|
38
38
|
}
|
|
39
39
|
}
|