@timmyjl12/pi-subagents 0.21.1 → 0.21.6
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/CHANGELOG.md +35 -0
- package/README.md +2 -2
- package/dist/agent-manager.js +11 -2
- package/dist/report-store.d.ts +9 -0
- package/dist/report-store.js +41 -4
- package/dist/schedule.d.ts +3 -1
- package/dist/schedule.js +15 -0
- package/dist/ui/cleanup-preview.js +1 -0
- package/dist/ui/conversation-viewer.d.ts +2 -0
- package/dist/ui/conversation-viewer.js +18 -1
- package/dist/workflow/meta.js +20 -3
- package/package.json +4 -4
- package/src/agent-manager.ts +3322 -3312
- package/src/report-store.ts +44 -4
- package/src/schedule-store.ts +244 -244
- package/src/schedule.ts +16 -1
- package/src/ui/cleanup-preview.ts +2 -1
- package/src/ui/conversation-viewer.ts +15 -4
- package/src/workflow/meta.ts +19 -3
|
@@ -142,7 +142,7 @@ export class ConversationViewer implements Component, Focusable {
|
|
|
142
142
|
/** Abort the agent shown here. Omitted → no stop affordance (e.g. read-only history). */
|
|
143
143
|
private onStop?: () => void,
|
|
144
144
|
/** User keybindings from `ctx.ui.custom()`. Omitted → hardcoded defaults. */
|
|
145
|
-
keybindings: KeybindingsManager = getKeybindings() as KeybindingsManager,
|
|
145
|
+
private readonly keybindings: KeybindingsManager = getKeybindings() as KeybindingsManager,
|
|
146
146
|
/** Resolves only after steering/resume acceptance. False or rejection retains the draft. */
|
|
147
147
|
private onSubmitMessage?: (message: string) => Promise<boolean>,
|
|
148
148
|
/**
|
|
@@ -205,6 +205,16 @@ export class ConversationViewer implements Component, Focusable {
|
|
|
205
205
|
const next = MARKDOWN_MODES[(MARKDOWN_MODES.indexOf(this.markdownMode()) + 1) % MARKDOWN_MODES.length];
|
|
206
206
|
this.markdownModeOverride = next;
|
|
207
207
|
this.onMarkdownMode?.(next);
|
|
208
|
+
} else if (this.keybindings.matches(data, "tui.altScreen.lineUp")) {
|
|
209
|
+
// Configured bindings first: a key the user bound to one direction must
|
|
210
|
+
// win over the built-in Alt+arrow default for the other.
|
|
211
|
+
this.scroll.scrollBy(-1);
|
|
212
|
+
} else if (this.keybindings.matches(data, "tui.altScreen.lineDown")) {
|
|
213
|
+
this.scroll.scrollBy(1);
|
|
214
|
+
} else if (matchesKey(data, "alt+up")) {
|
|
215
|
+
this.scroll.scrollBy(-1);
|
|
216
|
+
} else if (matchesKey(data, "alt+down")) {
|
|
217
|
+
this.scroll.scrollBy(1);
|
|
208
218
|
} else if (matchesKey(data, "pageUp") || matchesKey(data, "shift+up")) {
|
|
209
219
|
this.scroll.scrollBy(-Math.max(1, this.scroll.viewportHeight));
|
|
210
220
|
} else if (matchesKey(data, "pageDown") || matchesKey(data, "shift+down")) {
|
|
@@ -323,7 +333,7 @@ export class ConversationViewer implements Component, Focusable {
|
|
|
323
333
|
this.editorTop = lines.length;
|
|
324
334
|
lines.push(...editorLines.slice(this.editorClip, this.editorClip + editorHeight).map(row));
|
|
325
335
|
if (footerRows) {
|
|
326
|
-
lines.push(row(th.fg("dim", `Esc parent · Ctrl+R ${MARKDOWN_MODE_LABELS[this.markdownMode()]} · PgUp/Dn
|
|
336
|
+
lines.push(row(th.fg("dim", `Esc parent · Ctrl+R ${MARKDOWN_MODE_LABELS[this.markdownMode()]} · Alt+↑/↓ line · PgUp/Dn page · Ctrl+Shift+End tail`)));
|
|
327
337
|
lines.push(hrBot);
|
|
328
338
|
}
|
|
329
339
|
return lines.slice(0, rows);
|
|
@@ -357,13 +367,14 @@ export class ConversationViewer implements Component, Focusable {
|
|
|
357
367
|
}
|
|
358
368
|
|
|
359
369
|
/** Wrap `text` literally — the pre-Markdown path, and the fallback from it. */
|
|
360
|
-
private rawLines(text: string, width: number, dim: boolean): string[] {
|
|
370
|
+
private rawLines(text: string, width: number, dim: boolean): readonly string[] {
|
|
361
371
|
const lines = wrapTextWithAnsi(text, width);
|
|
362
372
|
return dim ? lines.map(l => this.theme.fg("dim", l)) : lines;
|
|
363
373
|
}
|
|
364
374
|
|
|
365
375
|
/** Render `text` as Markdown, reusing this message's component instance. */
|
|
366
|
-
|
|
376
|
+
// Read-only: Markdown.render() returns (and may cache) a readonly array in pi >= 1.6.
|
|
377
|
+
private markdownLines(msg: AgentSession["messages"][number], text: string, width: number, dim: boolean): readonly string[] {
|
|
367
378
|
let entry = this.markdownCache.get(msg);
|
|
368
379
|
if (!entry) {
|
|
369
380
|
entry = {
|
package/src/workflow/meta.ts
CHANGED
|
@@ -51,8 +51,14 @@ export class WorkflowMetaError extends Error {}
|
|
|
51
51
|
/**
|
|
52
52
|
* Wall-clock bound on evaluating the `meta` fragment. Generous for a literal —
|
|
53
53
|
* this exists only to stop a pathological one from hanging the host thread.
|
|
54
|
+
*
|
|
55
|
+
* It is wall-clock, so a loaded machine (a busy event loop, GC, many pi
|
|
56
|
+
* sessions) can make even `{ name: "x" }` miss it. A first miss is therefore
|
|
57
|
+
* retried once with a longer bound before the literal is called non-terminating;
|
|
58
|
+
* a real infinite loop still fails, within META_EVAL_RETRY_TIMEOUT_MS.
|
|
54
59
|
*/
|
|
55
60
|
const META_EVAL_TIMEOUT_MS = 100;
|
|
61
|
+
const META_EVAL_RETRY_TIMEOUT_MS = 1_000;
|
|
56
62
|
|
|
57
63
|
const PURE_LITERAL_HINT =
|
|
58
64
|
"The `meta` object must be a PURE LITERAL — no variables, function calls, spreads, or template interpolation.";
|
|
@@ -247,13 +253,23 @@ export function extractMeta(source: string): MetaExtraction {
|
|
|
247
253
|
// host thread, before the script ever reaches the worker. Without a bound it
|
|
248
254
|
// would wedge pi itself. `timeout` only governs synchronous execution, which
|
|
249
255
|
// is all a literal can contain.
|
|
250
|
-
|
|
251
|
-
|
|
256
|
+
//
|
|
257
|
+
// Compile and create the context BEFORE the timed run: V8's first context
|
|
258
|
+
// setup can itself take longer than the bound under load.
|
|
259
|
+
const script = new Script(`(${fragment})`, { filename: "workflow-meta.js" });
|
|
260
|
+
const isTimeout = (error: unknown) =>
|
|
261
|
+
/timed out|Script execution/i.test(error instanceof Error ? error.message : String(error));
|
|
262
|
+
try {
|
|
263
|
+
value = script.runInContext(createContext({}), { timeout: META_EVAL_TIMEOUT_MS });
|
|
264
|
+
} catch (first) {
|
|
265
|
+
if (!isTimeout(first)) throw first;
|
|
266
|
+
value = script.runInContext(createContext({}), { timeout: META_EVAL_RETRY_TIMEOUT_MS });
|
|
267
|
+
}
|
|
252
268
|
} catch (error) {
|
|
253
269
|
const detail = error instanceof Error ? error.message : String(error);
|
|
254
270
|
if (/timed out|Script execution/i.test(detail)) {
|
|
255
271
|
fail(
|
|
256
|
-
`\`meta\` did not finish evaluating within ${
|
|
272
|
+
`\`meta\` did not finish evaluating within ${META_EVAL_RETRY_TIMEOUT_MS}ms — it must be a literal, not a computation.\n` +
|
|
257
273
|
PURE_LITERAL_HINT,
|
|
258
274
|
);
|
|
259
275
|
}
|