pi-subagents 0.17.0 → 0.17.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/CHANGELOG.md +25 -0
- package/README.md +62 -4
- package/agents/context-builder.md +1 -1
- package/agents/planner.md +1 -1
- package/agents/researcher.md +1 -1
- package/agents/scout.md +1 -1
- package/agents/worker.md +1 -1
- package/async-execution.ts +38 -13
- package/async-job-tracker.ts +36 -18
- package/execution.ts +114 -6
- package/index.ts +1 -1
- package/intercom-bridge.ts +6 -3
- package/notify.ts +2 -1
- package/package.json +1 -1
- package/post-exit-stdio-guard.ts +85 -0
- package/render.ts +58 -24
- package/session-tokens.ts +48 -0
- package/slash-commands.ts +1 -1
- package/subagent-executor.ts +35 -29
- package/subagent-runner.ts +72 -42
- package/subagents-status.ts +7 -1
- package/top-level-async.ts +13 -0
- package/types.ts +7 -3
- package/utils.ts +31 -2
package/types.ts
CHANGED
|
@@ -50,8 +50,10 @@ export interface AgentProgress {
|
|
|
50
50
|
status: "pending" | "running" | "completed" | "failed" | "detached";
|
|
51
51
|
task: string;
|
|
52
52
|
skills?: string[];
|
|
53
|
+
lastActivityAt?: number;
|
|
53
54
|
currentTool?: string;
|
|
54
55
|
currentToolArgs?: string;
|
|
56
|
+
currentToolStartedAt?: number;
|
|
55
57
|
recentTools: Array<{ tool: string; args: string; endMs: number }>;
|
|
56
58
|
recentOutput: string[];
|
|
57
59
|
toolCount: number;
|
|
@@ -286,6 +288,7 @@ export interface TopLevelParallelConfig {
|
|
|
286
288
|
|
|
287
289
|
export interface ExtensionConfig {
|
|
288
290
|
asyncByDefault?: boolean;
|
|
291
|
+
forceTopLevelAsync?: boolean;
|
|
289
292
|
defaultSessionDir?: string;
|
|
290
293
|
maxSubagentDepth?: number;
|
|
291
294
|
parallel?: TopLevelParallelConfig;
|
|
@@ -384,9 +387,10 @@ export const MAX_WIDGET_JOBS = 4;
|
|
|
384
387
|
export const DEFAULT_SUBAGENT_MAX_DEPTH = 2;
|
|
385
388
|
|
|
386
389
|
export const DEFAULT_FORK_PREAMBLE =
|
|
387
|
-
"You are a delegated subagent
|
|
388
|
-
"
|
|
389
|
-
"
|
|
390
|
+
"You are a delegated subagent running from a fork of the parent session. " +
|
|
391
|
+
"Treat the inherited conversation as reference-only context, not a live thread to continue. " +
|
|
392
|
+
"Do not continue or answer prior messages as if they are waiting for a reply. " +
|
|
393
|
+
"Your sole job is to execute the task below and return a focused result for that task using your tools.";
|
|
390
394
|
|
|
391
395
|
function normalizeTopLevelParallelValue(value: unknown): number | undefined {
|
|
392
396
|
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
package/utils.ts
CHANGED
|
@@ -362,25 +362,54 @@ export function detectSubagentError(messages: Message[]): ErrorInfo {
|
|
|
362
362
|
* Extract a preview of tool arguments for display
|
|
363
363
|
*/
|
|
364
364
|
export function extractToolArgsPreview(args: Record<string, unknown>): string {
|
|
365
|
+
const truncatePreview = (value: string, maxLength: number): string =>
|
|
366
|
+
value.length > maxLength ? `${value.slice(0, maxLength - 3)}...` : value;
|
|
367
|
+
|
|
368
|
+
const stringifyPreviewValue = (value: unknown): string | undefined => {
|
|
369
|
+
if (typeof value === "string" && value.trim().length > 0) return value;
|
|
370
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
371
|
+
return undefined;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
const previewArray = (value: unknown): string | undefined => {
|
|
375
|
+
if (!Array.isArray(value) || value.length === 0) return undefined;
|
|
376
|
+
const first = stringifyPreviewValue(value[0]);
|
|
377
|
+
if (!first) return undefined;
|
|
378
|
+
const suffix = value.length > 1 ? ` (+${value.length - 1} more)` : "";
|
|
379
|
+
return `${first}${suffix}`;
|
|
380
|
+
};
|
|
381
|
+
|
|
365
382
|
// Handle MCP tool calls - show server/tool info
|
|
366
383
|
if (args.tool && typeof args.tool === "string") {
|
|
367
384
|
const server = args.server && typeof args.server === "string" ? `${args.server}/` : "";
|
|
368
385
|
const toolArgs = args.args && typeof args.args === "string" ? ` ${args.args.slice(0, 40)}` : "";
|
|
369
386
|
return `${server}${args.tool}${toolArgs}`;
|
|
370
387
|
}
|
|
388
|
+
|
|
389
|
+
const queriesPreview = previewArray(args.queries);
|
|
390
|
+
if (queriesPreview) return truncatePreview(queriesPreview, 60);
|
|
391
|
+
if (typeof args.query === "string" && args.query.trim().length > 0) return truncatePreview(args.query, 60);
|
|
392
|
+
if (typeof args.workflow === "string" && args.workflow.trim().length > 0) return `workflow=${truncatePreview(args.workflow, 48)}`;
|
|
393
|
+
|
|
394
|
+
if (typeof args.url === "string" && args.url.trim().length > 0) return truncatePreview(args.url, 60);
|
|
395
|
+
const urlsPreview = previewArray(args.urls);
|
|
396
|
+
if (urlsPreview) return truncatePreview(urlsPreview, 60);
|
|
397
|
+
if (typeof args.prompt === "string" && args.prompt.trim().length > 0) return truncatePreview(args.prompt, 60);
|
|
371
398
|
|
|
372
399
|
const previewKeys = ["command", "path", "file_path", "pattern", "query", "url", "task", "describe", "search"];
|
|
373
400
|
for (const key of previewKeys) {
|
|
374
401
|
if (args[key] && typeof args[key] === "string") {
|
|
375
402
|
const value = args[key] as string;
|
|
376
|
-
return value
|
|
403
|
+
return truncatePreview(value, 60);
|
|
377
404
|
}
|
|
378
405
|
}
|
|
379
406
|
|
|
380
407
|
// Fallback: show first string value found
|
|
381
408
|
for (const [key, value] of Object.entries(args)) {
|
|
409
|
+
const arrayPreview = previewArray(value);
|
|
410
|
+
if (arrayPreview) return `${key}=${truncatePreview(arrayPreview, 50)}`;
|
|
382
411
|
if (typeof value === "string" && value.length > 0) {
|
|
383
|
-
const preview = value
|
|
412
|
+
const preview = truncatePreview(value, 50);
|
|
384
413
|
return `${key}=${preview}`;
|
|
385
414
|
}
|
|
386
415
|
}
|