@timmyjl12/pi-subagents 0.21.2 → 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 +30 -0
- 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.js +11 -2
- 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 +11 -4
- package/src/workflow/meta.ts +19 -3
|
@@ -205,9 +205,15 @@ 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 (
|
|
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.
|
|
209
211
|
this.scroll.scrollBy(-1);
|
|
210
|
-
} else if (
|
|
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")) {
|
|
211
217
|
this.scroll.scrollBy(1);
|
|
212
218
|
} else if (matchesKey(data, "pageUp") || matchesKey(data, "shift+up")) {
|
|
213
219
|
this.scroll.scrollBy(-Math.max(1, this.scroll.viewportHeight));
|
|
@@ -361,13 +367,14 @@ export class ConversationViewer implements Component, Focusable {
|
|
|
361
367
|
}
|
|
362
368
|
|
|
363
369
|
/** Wrap `text` literally — the pre-Markdown path, and the fallback from it. */
|
|
364
|
-
private rawLines(text: string, width: number, dim: boolean): string[] {
|
|
370
|
+
private rawLines(text: string, width: number, dim: boolean): readonly string[] {
|
|
365
371
|
const lines = wrapTextWithAnsi(text, width);
|
|
366
372
|
return dim ? lines.map(l => this.theme.fg("dim", l)) : lines;
|
|
367
373
|
}
|
|
368
374
|
|
|
369
375
|
/** Render `text` as Markdown, reusing this message's component instance. */
|
|
370
|
-
|
|
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[] {
|
|
371
378
|
let entry = this.markdownCache.get(msg);
|
|
372
379
|
if (!entry) {
|
|
373
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
|
}
|