@deathbeam/pi-delegate 0.0.19 → 0.0.21
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/format.ts +5 -1
- package/index.ts +9 -2
- package/inspector.ts +17 -3
- package/package.json +1 -1
package/format.ts
CHANGED
|
@@ -72,7 +72,7 @@ function formatTokens(count: number): string {
|
|
|
72
72
|
return `${Math.round(count / 1000000)}M`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function formatDuration(ms: number): string {
|
|
75
|
+
export function formatDuration(ms: number): string {
|
|
76
76
|
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
77
77
|
if (seconds < 60) return `${seconds}s`;
|
|
78
78
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -88,6 +88,10 @@ export function usageStats(usage: UsageInfo, elapsedMs: number): string {
|
|
|
88
88
|
: "";
|
|
89
89
|
return [tokens, formatDuration(elapsedMs)].filter(Boolean).join(" · ");
|
|
90
90
|
}
|
|
91
|
+
/** Summed wall-clock across jobs; running jobs tick from `now`. Parallel jobs each count their full span. */
|
|
92
|
+
export function totalElapsedMs(jobs: { startedAt: number; endedAt?: number }[], now = Date.now()): number {
|
|
93
|
+
return jobs.reduce((sum, job) => sum + (job.endedAt ?? now) - job.startedAt, 0);
|
|
94
|
+
}
|
|
91
95
|
|
|
92
96
|
export function toolCallDetail(toolName: string, args: unknown): string {
|
|
93
97
|
const input = (args ?? {}) as Record<string, unknown>;
|
package/index.ts
CHANGED
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
reportText,
|
|
24
24
|
resumeHint,
|
|
25
25
|
SPINNER_INTERVAL_MS,
|
|
26
|
+
formatDuration,
|
|
26
27
|
statusText,
|
|
28
|
+
totalElapsedMs,
|
|
27
29
|
usageStats,
|
|
28
30
|
widgetJobs,
|
|
29
31
|
} from "./format.ts";
|
|
@@ -143,7 +145,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
143
145
|
const now = Date.now();
|
|
144
146
|
const { shown, hidden, detail } = widgetJobs(jobs);
|
|
145
147
|
const lines: string[] = [];
|
|
146
|
-
const
|
|
148
|
+
const all = store.all();
|
|
149
|
+
const counts = `${jobs.length} running · ${all.length} total · ${formatDuration(totalElapsedMs(all, now))}`;
|
|
147
150
|
lines.push(`${statusText(theme, "running", now)} ${theme.fg("muted", counts)}`);
|
|
148
151
|
for (const job of shown) {
|
|
149
152
|
lines.push(
|
|
@@ -313,7 +316,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
313
316
|
}),
|
|
314
317
|
),
|
|
315
318
|
}),
|
|
316
|
-
async execute(_toolCallId,
|
|
319
|
+
async execute(_toolCallId, rawParams, signal, _onUpdate, ctx) {
|
|
320
|
+
// Strict models inject literal "null" for optional params they omit; drop it before reading any.
|
|
321
|
+
const params = Object.fromEntries(
|
|
322
|
+
Object.entries(rawParams).filter(([, value]) => value !== null && value !== "null"),
|
|
323
|
+
) as typeof rawParams;
|
|
317
324
|
const config = configFor(ctx.cwd);
|
|
318
325
|
const agents = discoverAgents(ctx.cwd, config.agentDirs);
|
|
319
326
|
const resuming = params.resume
|
package/inspector.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { type ExtensionAPI, getMarkdownTheme, keyHint, rawKeyHint } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { HStack, Markdown, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { ChildActivity } from "./child.ts";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
formatDuration,
|
|
6
|
+
formatTools,
|
|
7
|
+
jobIdentity,
|
|
8
|
+
STATUS_COLORS,
|
|
9
|
+
statusText,
|
|
10
|
+
totalElapsedMs,
|
|
11
|
+
usageStats,
|
|
12
|
+
} from "./format.ts";
|
|
5
13
|
import type { InspectJob, JobStore } from "./store.ts";
|
|
6
14
|
|
|
7
15
|
/** The /delegate command: a full-screen inspector over the job store. */
|
|
@@ -108,7 +116,10 @@ export function registerInspector(pi: ExtensionAPI, store: JobStore) {
|
|
|
108
116
|
]
|
|
109
117
|
: [];
|
|
110
118
|
return [
|
|
111
|
-
truncateToWidth(
|
|
119
|
+
truncateToWidth(
|
|
120
|
+
`${statusText(theme, job.status)} ${jobIdentity(theme, job)} ${theme.fg("muted", usageStats(job, (job.endedAt ?? Date.now()) - job.startedAt))}`,
|
|
121
|
+
width,
|
|
122
|
+
),
|
|
112
123
|
truncateToWidth(theme.fg("dim", job.model), width),
|
|
113
124
|
...tools,
|
|
114
125
|
truncateToWidth(theme.fg("text", theme.bold(job.description)), width),
|
|
@@ -136,7 +147,10 @@ export function registerInspector(pi: ExtensionAPI, store: JobStore) {
|
|
|
136
147
|
const title = truncateToWidth(
|
|
137
148
|
`${theme.fg(focus === "list" ? "accent" : "muted", focus === "list" ? "[Jobs]" : "Jobs")} ` +
|
|
138
149
|
`${theme.fg(focus === "history" ? "accent" : "muted", focus === "history" ? "[Activity]" : "Activity")}` +
|
|
139
|
-
theme.fg(
|
|
150
|
+
theme.fg(
|
|
151
|
+
"dim",
|
|
152
|
+
` · ${store.live().length} running · ${items.length} total · ${formatDuration(totalElapsedMs(items))}`,
|
|
153
|
+
),
|
|
140
154
|
width,
|
|
141
155
|
);
|
|
142
156
|
const footer = truncateToWidth(
|