pi-subagents 0.86.0 → 0.88.0
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 +59 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-PYOAIN3V.js → chunk-2DIEL4WG.js} +2 -2
- package/bundle/{chunk-GJGTMLPE.js → chunk-3DT5X2QC.js} +483 -477
- package/bundle/{chunk-374MZFF4.js → chunk-3MFYKBKI.js} +23 -13
- package/bundle/{chunk-ZJJCPV3L.js → chunk-47GJDBIK.js} +10 -6
- package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
- package/bundle/{chunk-O3YH7XIY.js → chunk-4PM6RDE5.js} +46 -32
- package/bundle/{chunk-BWC2LVII.js → chunk-4UGWHREQ.js} +200 -64
- package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
- package/bundle/{chunk-A637IMAO.js → chunk-6OWNDN7R.js} +2 -2
- package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
- package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
- package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
- package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
- package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
- package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-QM3JGE4W.js → chunk-MTPICU4A.js} +12 -12
- package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
- package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
- package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
- package/bundle/{chunk-7ADDXUGF.js → chunk-UVDLJXL6.js} +14 -5
- package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
- package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-2IYBCYFU.js → chunk-XAOHLFJO.js} +174 -56
- package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
- package/bundle/chunk-YDZ7BZD5.js +523 -0
- package/bundle/{chunk-WN2E5XHN.js → chunk-YZPVALSQ.js} +30 -5
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +4 -4
- package/docs/configuration.md +17 -5
- package/docs/extension-api.md +2 -0
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +5 -1
- package/package.json +2 -2
- package/skills/pi-subagents/SKILL.md +15 -6
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +22 -10
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +1 -0
- package/src/agents/agents.js +39 -14
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +1 -0
- package/src/extension/config.js +6 -0
- package/src/extension/index.js +8 -5
- package/src/extension/schemas.d.ts +4 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/tool-activation.js +20 -3
- package/src/runs/background/async-execution.d.ts +2 -1
- package/src/runs/background/async-execution.js +4 -2
- package/src/runs/background/async-resume.js +2 -1
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +11 -5
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/run-child-session.d.ts +2 -2
- package/src/runs/background/run-child-session.js +4 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +0 -2
- package/src/runs/background/subagent-runner.js +73 -58
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.js +33 -15
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +2 -8
- package/src/runs/foreground/subagent-executor.js +57 -23
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- package/src/runs/shared/child-session.d.ts +5 -4
- package/src/runs/shared/child-session.js +64 -36
- package/src/runs/shared/herdr-placed-run.js +3 -2
- package/src/runs/shared/mcp-config-sources.d.ts +4 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
- package/src/runs/shared/model-resolution.d.ts +19 -4
- package/src/runs/shared/model-resolution.js +50 -51
- package/src/runs/shared/subagent-prompt-runtime.js +14 -2
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +23 -0
- package/src/shared/utils.d.ts +3 -1
- package/src/shared/utils.js +4 -0
- package/src/tui/render.js +33 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +103 -39
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +1 -1
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +3 -1
- package/src/workflows/workflow-script-worker.js +3 -1
- package/bundle/chunk-GRJHIXYF.js +0 -235
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectSubagentsDir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YDZ7BZD5.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverAgents,
|
|
6
6
|
formatUnknownAgentError,
|
|
7
7
|
resolveAgentName,
|
|
8
8
|
unknownAgentDiagnosticContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4MVDMA5C.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/agent-refinements.ts
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAtomicJsonWriter,
|
|
3
|
+
getAgentDir,
|
|
4
|
+
readStatus
|
|
5
|
+
} from "./chunk-4MVDMA5C.js";
|
|
6
|
+
import {
|
|
7
|
+
DIRS,
|
|
8
|
+
TEMP_ARTIFACTS_DIR,
|
|
9
|
+
TEMP_ROOT_DIR
|
|
10
|
+
} from "./chunk-JEZOSEWG.js";
|
|
11
|
+
|
|
12
|
+
// src/shared/artifacts.ts
|
|
13
|
+
import * as fs2 from "node:fs";
|
|
14
|
+
import * as path2 from "node:path";
|
|
15
|
+
|
|
16
|
+
// src/runs/shared/session-lease.ts
|
|
17
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
18
|
+
import * as fs from "node:fs";
|
|
19
|
+
import * as os from "node:os";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
var SESSION_LEASES_DIR = path.join(TEMP_ROOT_DIR, "session-leases");
|
|
22
|
+
var SessionLeaseConflictError = class extends Error {
|
|
23
|
+
owner;
|
|
24
|
+
constructor(message, owner) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "SessionLeaseConflictError";
|
|
27
|
+
this.owner = owner;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function getProcessStartIdentity(pid) {
|
|
31
|
+
if (process.platform === "linux") {
|
|
32
|
+
try {
|
|
33
|
+
const stat = fs.readFileSync(`/proc/${pid}/stat`, "utf-8");
|
|
34
|
+
const commandEnd = stat.lastIndexOf(")");
|
|
35
|
+
if (commandEnd === -1) return void 0;
|
|
36
|
+
const fields = stat.slice(commandEnd + 1).trim().split(/\s+/);
|
|
37
|
+
const startTicks = fields[19];
|
|
38
|
+
return startTicks ? `linux:${startTicks}` : void 0;
|
|
39
|
+
} catch {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function processIsAlive(pid) {
|
|
46
|
+
try {
|
|
47
|
+
process.kill(pid, 0);
|
|
48
|
+
return true;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
const code = error.code;
|
|
51
|
+
if (code === "ESRCH") return false;
|
|
52
|
+
if (code === "EPERM") return true;
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function canonicalSessionFilePath(sessionFile) {
|
|
57
|
+
return fs.realpathSync.native(path.resolve(sessionFile));
|
|
58
|
+
}
|
|
59
|
+
function canonicalSessionId(sessionFile) {
|
|
60
|
+
const canonical = canonicalSessionFilePath(sessionFile);
|
|
61
|
+
const key = process.platform === "win32" ? canonical.toLowerCase() : canonical;
|
|
62
|
+
return createHash("sha256").update(key).digest("hex");
|
|
63
|
+
}
|
|
64
|
+
function sessionLeaseDir(sessionFile, rootDir = SESSION_LEASES_DIR) {
|
|
65
|
+
return path.join(rootDir, canonicalSessionId(sessionFile));
|
|
66
|
+
}
|
|
67
|
+
function inspectSessionLease(sessionFile, rootDir = SESSION_LEASES_DIR) {
|
|
68
|
+
const canonicalSessionFile = canonicalSessionFilePath(sessionFile);
|
|
69
|
+
const canonicalSessionIdValue = canonicalSessionId(canonicalSessionFile);
|
|
70
|
+
const leaseDir = path.join(rootDir, canonicalSessionIdValue);
|
|
71
|
+
if (!fs.existsSync(leaseDir)) return { state: "free", canonicalSessionFile, canonicalSessionId: canonicalSessionIdValue };
|
|
72
|
+
const owner = readLeaseOwner(leaseDir);
|
|
73
|
+
return owner ? { state: "owned", canonicalSessionFile, canonicalSessionId: canonicalSessionIdValue, owner } : { state: "unreadable", canonicalSessionFile, canonicalSessionId: canonicalSessionIdValue };
|
|
74
|
+
}
|
|
75
|
+
function parseOwner(value) {
|
|
76
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
77
|
+
const owner = value;
|
|
78
|
+
if (owner.version !== 1 || typeof owner.token !== "string" || typeof owner.canonicalSessionFile !== "string" || typeof owner.runId !== "string" || typeof owner.sourceRunId !== "string" || typeof owner.pid !== "number" || !Number.isInteger(owner.pid) || owner.pid <= 0 || typeof owner.hostname !== "string" || owner.writerState !== "none" && owner.writerState !== "spawning" && owner.writerState !== "running" || typeof owner.acquiredAt !== "string" || typeof owner.acquiredAtMs !== "number" || typeof owner.updatedAtMs !== "number") return void 0;
|
|
79
|
+
if (owner.parentSessionId !== void 0 && typeof owner.parentSessionId !== "string") return void 0;
|
|
80
|
+
if (owner.processStartIdentity !== void 0 && typeof owner.processStartIdentity !== "string") return void 0;
|
|
81
|
+
if (owner.writerPid !== void 0 && (typeof owner.writerPid !== "number" || !Number.isInteger(owner.writerPid) || owner.writerPid <= 0)) return void 0;
|
|
82
|
+
if (owner.writerProcessStartIdentity !== void 0 && typeof owner.writerProcessStartIdentity !== "string") return void 0;
|
|
83
|
+
if (owner.writerState === "running" && owner.writerPid === void 0) return void 0;
|
|
84
|
+
if (owner.writerState !== "running" && (owner.writerPid !== void 0 || owner.writerProcessStartIdentity !== void 0)) return void 0;
|
|
85
|
+
return owner;
|
|
86
|
+
}
|
|
87
|
+
function readLeaseOwner(leaseDir) {
|
|
88
|
+
try {
|
|
89
|
+
return parseOwner(JSON.parse(fs.readFileSync(path.join(leaseDir, "owner.json"), "utf-8")));
|
|
90
|
+
} catch {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function conflictMessage(canonicalSessionFile, owner) {
|
|
95
|
+
if (!owner) {
|
|
96
|
+
return `Direct revival of session '${canonicalSessionFile}' is blocked by an existing lease with unreadable owner metadata. Refusing to reclaim it without proof that the owner is stale.`;
|
|
97
|
+
}
|
|
98
|
+
const parent = owner.parentSessionId ? `, parent session '${owner.parentSessionId}'` : "";
|
|
99
|
+
return `Direct revival of session '${canonicalSessionFile}' is already owned by run '${owner.runId}' (source run '${owner.sourceRunId}'${parent}, pid ${owner.pid} on ${owner.hostname}). Wait for that revival to finish or start a separate continuation without reusing this session file.`;
|
|
100
|
+
}
|
|
101
|
+
function processDemonstrablyGone(pid, startIdentity, options) {
|
|
102
|
+
const alive = options.isProcessAlive(pid);
|
|
103
|
+
if (alive === false) return true;
|
|
104
|
+
if (alive !== true || !startIdentity) return false;
|
|
105
|
+
const currentIdentity = options.getProcessStartIdentity(pid);
|
|
106
|
+
return currentIdentity !== void 0 && currentIdentity !== startIdentity;
|
|
107
|
+
}
|
|
108
|
+
function demonstrablyStale(owner, options) {
|
|
109
|
+
if (owner.hostname !== options.hostname) return false;
|
|
110
|
+
if (!processDemonstrablyGone(owner.pid, owner.processStartIdentity, options)) return false;
|
|
111
|
+
if (owner.writerState === "spawning") return false;
|
|
112
|
+
if (owner.writerState === "none") return true;
|
|
113
|
+
return owner.writerPid !== void 0 && processDemonstrablyGone(owner.writerPid, owner.writerProcessStartIdentity, options);
|
|
114
|
+
}
|
|
115
|
+
function createLeaseDirectory(leaseDir, owner) {
|
|
116
|
+
const tempDir = `${leaseDir}.candidate-${owner.token}`;
|
|
117
|
+
fs.mkdirSync(path.dirname(leaseDir), { recursive: true, mode: 448 });
|
|
118
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
119
|
+
fs.mkdirSync(tempDir, { mode: 448 });
|
|
120
|
+
try {
|
|
121
|
+
fs.writeFileSync(path.join(tempDir, "owner.json"), JSON.stringify(owner, null, 2), { encoding: "utf-8", mode: 384 });
|
|
122
|
+
try {
|
|
123
|
+
fs.renameSync(tempDir, leaseDir);
|
|
124
|
+
return true;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (fs.existsSync(leaseDir)) return false;
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
} finally {
|
|
130
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function acquireSessionLease(request, options = {}) {
|
|
134
|
+
const canonicalSessionFile = canonicalSessionFilePath(request.sessionFile);
|
|
135
|
+
const rootDir = options.rootDir ?? SESSION_LEASES_DIR;
|
|
136
|
+
const leaseDir = sessionLeaseDir(canonicalSessionFile, rootDir);
|
|
137
|
+
const now = options.now ?? Date.now;
|
|
138
|
+
const pid = options.pid ?? process.pid;
|
|
139
|
+
const hostname2 = options.hostname ?? os.hostname();
|
|
140
|
+
const getIdentity = options.getProcessStartIdentity ?? getProcessStartIdentity;
|
|
141
|
+
const processStartIdentity = options.processStartIdentity ?? getIdentity(pid) ?? (pid === process.pid ? `runtime:${Math.round(Date.now() - process.uptime() * 1e3)}` : void 0);
|
|
142
|
+
const acquiredAtMs = now();
|
|
143
|
+
const owner = {
|
|
144
|
+
version: 1,
|
|
145
|
+
token: options.token?.() ?? randomUUID(),
|
|
146
|
+
canonicalSessionFile,
|
|
147
|
+
runId: request.runId,
|
|
148
|
+
sourceRunId: request.sourceRunId,
|
|
149
|
+
...request.parentSessionId ? { parentSessionId: request.parentSessionId } : {},
|
|
150
|
+
pid,
|
|
151
|
+
hostname: hostname2,
|
|
152
|
+
...processStartIdentity ? { processStartIdentity } : {},
|
|
153
|
+
writerState: "none",
|
|
154
|
+
acquiredAt: new Date(acquiredAtMs).toISOString(),
|
|
155
|
+
acquiredAtMs,
|
|
156
|
+
updatedAtMs: acquiredAtMs
|
|
157
|
+
};
|
|
158
|
+
const staleOptions = {
|
|
159
|
+
hostname: hostname2,
|
|
160
|
+
isProcessAlive: options.isProcessAlive ?? processIsAlive,
|
|
161
|
+
getProcessStartIdentity: getIdentity
|
|
162
|
+
};
|
|
163
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
164
|
+
if (createLeaseDirectory(leaseDir, owner)) {
|
|
165
|
+
const writeOwner = createAtomicJsonWriter();
|
|
166
|
+
return {
|
|
167
|
+
leaseDir,
|
|
168
|
+
owner,
|
|
169
|
+
updateWriter(writer) {
|
|
170
|
+
const currentOwner = readLeaseOwner(leaseDir);
|
|
171
|
+
if (!currentOwner || currentOwner.token !== owner.token) {
|
|
172
|
+
throw new Error(`Session revival lease ownership changed for run '${owner.runId}'.`);
|
|
173
|
+
}
|
|
174
|
+
const writerProcessStartIdentity = writer.state === "running" ? getIdentity(writer.pid) : void 0;
|
|
175
|
+
const nextOwner = {
|
|
176
|
+
...owner,
|
|
177
|
+
writerState: writer.state,
|
|
178
|
+
...writer.state === "running" ? { writerPid: writer.pid } : {},
|
|
179
|
+
...writerProcessStartIdentity ? { writerProcessStartIdentity } : {},
|
|
180
|
+
updatedAtMs: now()
|
|
181
|
+
};
|
|
182
|
+
delete nextOwner.writerPid;
|
|
183
|
+
delete nextOwner.writerProcessStartIdentity;
|
|
184
|
+
if (writer.state === "running") {
|
|
185
|
+
nextOwner.writerPid = writer.pid;
|
|
186
|
+
if (writerProcessStartIdentity) nextOwner.writerProcessStartIdentity = writerProcessStartIdentity;
|
|
187
|
+
}
|
|
188
|
+
writeOwner(path.join(leaseDir, "owner.json"), nextOwner);
|
|
189
|
+
delete owner.writerPid;
|
|
190
|
+
delete owner.writerProcessStartIdentity;
|
|
191
|
+
Object.assign(owner, nextOwner);
|
|
192
|
+
},
|
|
193
|
+
release() {
|
|
194
|
+
const currentOwner = readLeaseOwner(leaseDir);
|
|
195
|
+
if (!currentOwner || currentOwner.token !== owner.token) return false;
|
|
196
|
+
fs.rmSync(leaseDir, { recursive: true, force: true });
|
|
197
|
+
return !fs.existsSync(leaseDir);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const existingOwner2 = readLeaseOwner(leaseDir);
|
|
202
|
+
if (!existingOwner2 || !demonstrablyStale(existingOwner2, staleOptions)) {
|
|
203
|
+
throw new SessionLeaseConflictError(conflictMessage(canonicalSessionFile, existingOwner2), existingOwner2);
|
|
204
|
+
}
|
|
205
|
+
const tombstone = `${leaseDir}.stale-${existingOwner2.token.replace(/[^A-Za-z0-9._-]/g, "-")}`;
|
|
206
|
+
try {
|
|
207
|
+
fs.renameSync(leaseDir, tombstone);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
const code = error.code;
|
|
210
|
+
if (code === "ENOENT" || fs.existsSync(tombstone)) continue;
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const existingOwner = readLeaseOwner(leaseDir);
|
|
215
|
+
throw new SessionLeaseConflictError(conflictMessage(canonicalSessionFile, existingOwner), existingOwner);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/shared/artifacts.ts
|
|
219
|
+
var CLEANUP_MARKER_FILE = ".last-cleanup";
|
|
220
|
+
var FORK_CLEANUP_MARKER_FILE = ".pi-subagents-fork-cleanup";
|
|
221
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
222
|
+
var RETAINED_ARTIFACT_DIRS = /* @__PURE__ */ new Set(["handoffs", "worktree-diffs"]);
|
|
223
|
+
var PROJECT_SUBAGENTS_RELATIVE_DIR = ".pi/subagents";
|
|
224
|
+
var PROJECT_ARTIFACT_PATHS = [
|
|
225
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/output.md`,
|
|
226
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/run_worker_input.md`,
|
|
227
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/run_worker_output.md`,
|
|
228
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/run_worker.jsonl`,
|
|
229
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/run_worker_transcript.jsonl`,
|
|
230
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/run_worker_meta.json`,
|
|
231
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/progress/run/progress.md`,
|
|
232
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/outputs/output.md`,
|
|
233
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/artifacts/outputs/run/output.md`,
|
|
234
|
+
`${PROJECT_SUBAGENTS_RELATIVE_DIR}/chain-runs/run.json`
|
|
235
|
+
];
|
|
236
|
+
function globMatchesPath(pattern, filePath) {
|
|
237
|
+
let expression = "^";
|
|
238
|
+
for (let index = 0; index < pattern.length; index += 1) {
|
|
239
|
+
const character = pattern[index];
|
|
240
|
+
if (character === void 0) break;
|
|
241
|
+
if (character === "*" && pattern[index + 1] === "*") {
|
|
242
|
+
index += 1;
|
|
243
|
+
if (pattern[index + 1] === "/") {
|
|
244
|
+
index += 1;
|
|
245
|
+
expression += "(?:.*/)?";
|
|
246
|
+
} else {
|
|
247
|
+
expression += ".*";
|
|
248
|
+
}
|
|
249
|
+
} else if (character === "*") {
|
|
250
|
+
expression += "[^/]*";
|
|
251
|
+
} else if (character === "?") {
|
|
252
|
+
expression += "[^/]";
|
|
253
|
+
} else if (character === "[") {
|
|
254
|
+
const end = pattern.indexOf("]", index + 1);
|
|
255
|
+
if (end === -1) expression += "\\[";
|
|
256
|
+
else {
|
|
257
|
+
expression += pattern.slice(index, end + 1);
|
|
258
|
+
index = end;
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
expression += character.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
return new RegExp(`${expression}$`).test(filePath);
|
|
266
|
+
} catch {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function normalizePattern(pattern) {
|
|
271
|
+
return pattern.replace(/^\.\//, "").replace(/^\//, "").replace(/\/+$/, "");
|
|
272
|
+
}
|
|
273
|
+
function patternMatchesArtifactPath(pattern, artifactPath) {
|
|
274
|
+
const normalized = normalizePattern(pattern);
|
|
275
|
+
return normalized === PROJECT_SUBAGENTS_RELATIVE_DIR || normalized === "*" || artifactPath.startsWith(`${normalized}/`) || globMatchesPath(normalized, artifactPath);
|
|
276
|
+
}
|
|
277
|
+
function ignoreFileExcludesProjectArtifacts(filePath) {
|
|
278
|
+
if (!fs2.existsSync(filePath)) return false;
|
|
279
|
+
try {
|
|
280
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
281
|
+
for (const rawLine of fs2.readFileSync(filePath, "utf-8").split(/\r?\n/)) {
|
|
282
|
+
const line = rawLine.trim();
|
|
283
|
+
if (!line || line.startsWith("#")) continue;
|
|
284
|
+
const negated = line.startsWith("!");
|
|
285
|
+
const pattern = negated ? line.slice(1) : line;
|
|
286
|
+
for (const artifactPath of PROJECT_ARTIFACT_PATHS) {
|
|
287
|
+
if (!patternMatchesArtifactPath(pattern, artifactPath)) continue;
|
|
288
|
+
if (negated) excluded.delete(artifactPath);
|
|
289
|
+
else excluded.add(artifactPath);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return excluded.size === PROJECT_ARTIFACT_PATHS.length;
|
|
293
|
+
} catch {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function filesIncludeProjectArtifacts(files) {
|
|
298
|
+
if (!Array.isArray(files)) return void 0;
|
|
299
|
+
const included = /* @__PURE__ */ new Set();
|
|
300
|
+
for (const entry of files) {
|
|
301
|
+
if (typeof entry !== "string") continue;
|
|
302
|
+
const negated = entry.startsWith("!");
|
|
303
|
+
const pattern = negated ? entry.slice(1) : entry;
|
|
304
|
+
for (const artifactPath of PROJECT_ARTIFACT_PATHS) {
|
|
305
|
+
if (!patternMatchesArtifactPath(pattern, artifactPath)) continue;
|
|
306
|
+
if (negated) included.delete(artifactPath);
|
|
307
|
+
else included.add(artifactPath);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return included.size > 0;
|
|
311
|
+
}
|
|
312
|
+
function getProjectArtifactPackagingWarning(cwd) {
|
|
313
|
+
const packagePath = path2.join(cwd, "package.json");
|
|
314
|
+
if (!fs2.existsSync(packagePath)) return void 0;
|
|
315
|
+
let packageJson;
|
|
316
|
+
try {
|
|
317
|
+
const parsed = JSON.parse(fs2.readFileSync(packagePath, "utf-8"));
|
|
318
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
|
|
319
|
+
packageJson = parsed;
|
|
320
|
+
} catch {
|
|
321
|
+
return void 0;
|
|
322
|
+
}
|
|
323
|
+
const filesIncludeArtifacts = filesIncludeProjectArtifacts(packageJson.files);
|
|
324
|
+
if (filesIncludeArtifacts === false) return void 0;
|
|
325
|
+
const npmIgnorePath = path2.join(cwd, ".npmignore");
|
|
326
|
+
const ignorePath = fs2.existsSync(npmIgnorePath) ? npmIgnorePath : path2.join(cwd, ".gitignore");
|
|
327
|
+
if (filesIncludeArtifacts === void 0 && ignoreFileExcludesProjectArtifacts(ignorePath)) return void 0;
|
|
328
|
+
return "Project-scoped subagent artifacts can be included when this package is published. Add '.pi/subagents/' to .npmignore, restrict package.json files, or set artifactDir to 'session' or 'temp'.";
|
|
329
|
+
}
|
|
330
|
+
function getProjectSubagentsDir(cwd) {
|
|
331
|
+
return path2.join(cwd, PROJECT_SUBAGENTS_RELATIVE_DIR);
|
|
332
|
+
}
|
|
333
|
+
function getProjectArtifactsDir(cwd) {
|
|
334
|
+
return path2.join(getProjectSubagentsDir(cwd), "artifacts");
|
|
335
|
+
}
|
|
336
|
+
function getArtifactsDir(sessionFile, projectCwd, dirPreference = "session") {
|
|
337
|
+
switch (dirPreference) {
|
|
338
|
+
case "session":
|
|
339
|
+
if (sessionFile) {
|
|
340
|
+
const sessionDir = path2.dirname(sessionFile);
|
|
341
|
+
return path2.join(sessionDir, "subagent-artifacts");
|
|
342
|
+
}
|
|
343
|
+
return TEMP_ARTIFACTS_DIR;
|
|
344
|
+
case "temp":
|
|
345
|
+
return TEMP_ARTIFACTS_DIR;
|
|
346
|
+
case "project":
|
|
347
|
+
if (projectCwd) return getProjectArtifactsDir(projectCwd);
|
|
348
|
+
if (sessionFile) {
|
|
349
|
+
const sessionDir = path2.dirname(sessionFile);
|
|
350
|
+
return path2.join(sessionDir, "subagent-artifacts");
|
|
351
|
+
}
|
|
352
|
+
return TEMP_ARTIFACTS_DIR;
|
|
353
|
+
default:
|
|
354
|
+
throw new Error(`Unsupported artifactDir ${JSON.stringify(dirPreference)}; expected "project", "session", or "temp".`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function getArtifactPaths(artifactsDir, runId, agent, index) {
|
|
358
|
+
const suffix = index !== void 0 ? `_${index}` : "";
|
|
359
|
+
const safeAgent = agent.replace(/[^\w.-]/g, "_");
|
|
360
|
+
const base = `${runId}_${safeAgent}${suffix}`;
|
|
361
|
+
return {
|
|
362
|
+
inputPath: path2.join(artifactsDir, `${base}_input.md`),
|
|
363
|
+
outputPath: path2.join(artifactsDir, `${base}_output.md`),
|
|
364
|
+
jsonlPath: path2.join(artifactsDir, `${base}.jsonl`),
|
|
365
|
+
transcriptPath: path2.join(artifactsDir, `${base}_transcript.jsonl`),
|
|
366
|
+
metadataPath: path2.join(artifactsDir, `${base}_meta.json`)
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function ensureArtifactsDir(dir) {
|
|
370
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
371
|
+
}
|
|
372
|
+
function writeArtifact(filePath, content) {
|
|
373
|
+
fs2.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
374
|
+
fs2.writeFileSync(filePath, content, "utf-8");
|
|
375
|
+
}
|
|
376
|
+
function formatOutputArtifactContent(input) {
|
|
377
|
+
if (input.output.trim() || !input.error) return input.output;
|
|
378
|
+
const lines = ["Subagent run failed before producing output.", "", "Error:", input.error];
|
|
379
|
+
if (input.transcriptPath) lines.push("", `Transcript: ${input.transcriptPath}`);
|
|
380
|
+
if (input.metadataPath) lines.push(`Metadata: ${input.metadataPath}`);
|
|
381
|
+
return lines.join("\n");
|
|
382
|
+
}
|
|
383
|
+
function writeMetadata(filePath, metadata) {
|
|
384
|
+
fs2.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
385
|
+
fs2.writeFileSync(filePath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
386
|
+
}
|
|
387
|
+
function appendJsonl(filePath, line) {
|
|
388
|
+
fs2.appendFileSync(filePath, `${line}
|
|
389
|
+
`);
|
|
390
|
+
}
|
|
391
|
+
function cleanupOldArtifacts(dir, maxAgeDays) {
|
|
392
|
+
if (maxAgeDays <= 0 || !fs2.existsSync(dir)) return;
|
|
393
|
+
const markerPath = path2.join(dir, CLEANUP_MARKER_FILE);
|
|
394
|
+
const now = Date.now();
|
|
395
|
+
if (ranWithinDay(markerPath, now)) return;
|
|
396
|
+
const cutoff = now - maxAgeDays * DAY_MS;
|
|
397
|
+
for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
|
|
398
|
+
if (entry.name === CLEANUP_MARKER_FILE || entry.isDirectory() && RETAINED_ARTIFACT_DIRS.has(entry.name)) continue;
|
|
399
|
+
removeOldEntry(path2.join(dir, entry.name), cutoff);
|
|
400
|
+
}
|
|
401
|
+
fs2.writeFileSync(markerPath, String(now));
|
|
402
|
+
}
|
|
403
|
+
function removeOldEntry(entryPath, cutoff) {
|
|
404
|
+
try {
|
|
405
|
+
const stat = fs2.lstatSync(entryPath);
|
|
406
|
+
const old = stat.mtimeMs < cutoff;
|
|
407
|
+
if (!stat.isDirectory()) {
|
|
408
|
+
if (old) fs2.unlinkSync(entryPath);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
for (const name of fs2.readdirSync(entryPath)) removeOldEntry(path2.join(entryPath, name), cutoff);
|
|
412
|
+
if (old && fs2.readdirSync(entryPath).length === 0) fs2.rmdirSync(entryPath);
|
|
413
|
+
} catch {
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function cleanupAllArtifactDirs(maxAgeDays) {
|
|
417
|
+
cleanupOldArtifacts(TEMP_ARTIFACTS_DIR, maxAgeDays);
|
|
418
|
+
const sessionsBase = path2.join(getAgentDir(), "sessions");
|
|
419
|
+
if (!fs2.existsSync(sessionsBase)) return;
|
|
420
|
+
let dirs;
|
|
421
|
+
try {
|
|
422
|
+
dirs = fs2.readdirSync(sessionsBase);
|
|
423
|
+
} catch {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const forkMarkerPath = path2.join(sessionsBase, FORK_CLEANUP_MARKER_FILE);
|
|
427
|
+
const now = Date.now();
|
|
428
|
+
const pruneForks = maxAgeDays > 0 && !ranWithinDay(forkMarkerPath, now);
|
|
429
|
+
for (const dir of dirs) {
|
|
430
|
+
const artifactsDir = path2.join(sessionsBase, dir, "subagent-artifacts");
|
|
431
|
+
try {
|
|
432
|
+
cleanupOldArtifacts(artifactsDir, maxAgeDays);
|
|
433
|
+
} catch {
|
|
434
|
+
}
|
|
435
|
+
if (pruneForks) removeOldForkCopies(path2.join(sessionsBase, dir), now - maxAgeDays * DAY_MS);
|
|
436
|
+
}
|
|
437
|
+
if (!pruneForks) return;
|
|
438
|
+
try {
|
|
439
|
+
fs2.writeFileSync(forkMarkerPath, String(now));
|
|
440
|
+
} catch {
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function ranWithinDay(markerPath, now) {
|
|
444
|
+
try {
|
|
445
|
+
return now - fs2.statSync(markerPath).mtimeMs < DAY_MS;
|
|
446
|
+
} catch {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function removeOldForkCopies(projectDir, cutoff) {
|
|
451
|
+
let sessions;
|
|
452
|
+
try {
|
|
453
|
+
sessions = fs2.readdirSync(projectDir, { withFileTypes: true });
|
|
454
|
+
} catch {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
for (const session of sessions) {
|
|
458
|
+
if (!session.isDirectory()) continue;
|
|
459
|
+
const forksDir = path2.join(projectDir, session.name, "forks");
|
|
460
|
+
let runIds;
|
|
461
|
+
try {
|
|
462
|
+
if (!fs2.lstatSync(forksDir).isDirectory()) continue;
|
|
463
|
+
runIds = fs2.readdirSync(forksDir);
|
|
464
|
+
} catch {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
for (const runId of runIds) {
|
|
468
|
+
const runDir = path2.join(forksDir, runId);
|
|
469
|
+
const leases = [];
|
|
470
|
+
try {
|
|
471
|
+
const sessionFiles = idleSessionFiles(runDir, cutoff);
|
|
472
|
+
if (!sessionFiles || asyncRunActive(runId)) continue;
|
|
473
|
+
for (const file of sessionFiles) leases.push(acquireSessionLease({ sessionFile: file, runId: "fork-cleanup", sourceRunId: runId }));
|
|
474
|
+
fs2.rmSync(runDir, { recursive: true, force: true });
|
|
475
|
+
} catch {
|
|
476
|
+
} finally {
|
|
477
|
+
for (const lease of leases) lease.release();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function idleSessionFiles(entryPath, cutoff, files = []) {
|
|
483
|
+
const stat = fs2.lstatSync(entryPath);
|
|
484
|
+
if (stat.mtimeMs >= cutoff) return void 0;
|
|
485
|
+
if (!stat.isDirectory()) {
|
|
486
|
+
if (stat.isFile() && entryPath.endsWith(".jsonl")) files.push(entryPath);
|
|
487
|
+
return files;
|
|
488
|
+
}
|
|
489
|
+
for (const name of fs2.readdirSync(entryPath)) {
|
|
490
|
+
if (!idleSessionFiles(path2.join(entryPath, name), cutoff, files)) return void 0;
|
|
491
|
+
}
|
|
492
|
+
return files;
|
|
493
|
+
}
|
|
494
|
+
function asyncRunActive(runId) {
|
|
495
|
+
try {
|
|
496
|
+
const state = readStatus(path2.join(DIRS.async, runId))?.state;
|
|
497
|
+
return state === "queued" || state === "running";
|
|
498
|
+
} catch {
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function missingForkCopyNote(sessionFile) {
|
|
503
|
+
if (path2.basename(path2.dirname(path2.dirname(sessionFile))) !== "forks") return "";
|
|
504
|
+
return ". It was a forked child's copy of the parent session; such copies are deleted once nothing has written to them for artifactConfig.cleanupDays days (default 7).";
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export {
|
|
508
|
+
canonicalSessionId,
|
|
509
|
+
inspectSessionLease,
|
|
510
|
+
PROJECT_SUBAGENTS_RELATIVE_DIR,
|
|
511
|
+
getProjectArtifactPackagingWarning,
|
|
512
|
+
getProjectSubagentsDir,
|
|
513
|
+
getArtifactsDir,
|
|
514
|
+
getArtifactPaths,
|
|
515
|
+
ensureArtifactsDir,
|
|
516
|
+
writeArtifact,
|
|
517
|
+
formatOutputArtifactContent,
|
|
518
|
+
writeMetadata,
|
|
519
|
+
appendJsonl,
|
|
520
|
+
cleanupOldArtifacts,
|
|
521
|
+
cleanupAllArtifactDirs,
|
|
522
|
+
missingForkCopyNote
|
|
523
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildWorkflowChatProgressRows
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RHYVKQQL.js";
|
|
4
4
|
import {
|
|
5
5
|
aggregateStepStatus,
|
|
6
6
|
contextModeBadge,
|
|
7
7
|
contextModeLabel,
|
|
8
8
|
contextModePrefix,
|
|
9
|
+
formatActivityAge,
|
|
9
10
|
formatActivityLabel,
|
|
10
11
|
formatAgentRunningLabel,
|
|
11
12
|
formatNestedAggregate,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
projectAsyncWorkflowRows,
|
|
22
23
|
projectWorkflowChecklist,
|
|
23
24
|
workflowGraphStageNodes
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SVIXQDIV.js";
|
|
25
26
|
import {
|
|
26
27
|
isStaleExtensionContextError,
|
|
27
28
|
isUnboundExtensionRuntimeError,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
formatWorkflowJsonPreview,
|
|
34
35
|
hostStepReportName,
|
|
35
36
|
hostStepVerdictLabel
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-3DT5X2QC.js";
|
|
37
38
|
import {
|
|
38
39
|
snapshotExternalRuns
|
|
39
40
|
} from "./chunk-UKG4V45O.js";
|
|
@@ -51,7 +52,7 @@ import {
|
|
|
51
52
|
getSingleResultOutput,
|
|
52
53
|
shortenPath,
|
|
53
54
|
unresolvedChildWatchdogBlockers
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-4MVDMA5C.js";
|
|
55
56
|
import {
|
|
56
57
|
MAX_WIDGET_JOBS,
|
|
57
58
|
WIDGET_ANIMATION_INTERVAL_MS,
|
|
@@ -636,6 +637,16 @@ function workflowLabelForResult(details, resultIndex) {
|
|
|
636
637
|
};
|
|
637
638
|
return details.workflowGraph ? visit(details.workflowGraph.nodes) : void 0;
|
|
638
639
|
}
|
|
640
|
+
function reportedProgressRow(progress, theme, indent, width) {
|
|
641
|
+
const text = progress.progressText?.trim();
|
|
642
|
+
if (!text) return void 0;
|
|
643
|
+
let updated = "";
|
|
644
|
+
if (progress.progressUpdatedAt !== void 0) {
|
|
645
|
+
const age = formatActivityAge(Math.max(0, Date.now() - progress.progressUpdatedAt));
|
|
646
|
+
updated = age === "now" ? " \xB7 updated now" : ` \xB7 updated ${age} ago`;
|
|
647
|
+
}
|
|
648
|
+
return truncLine(theme.fg("dim", `${indent}progress: ${sanitizeDisplayText(text)}${updated}`), width);
|
|
649
|
+
}
|
|
639
650
|
function foregroundProgressForResult(details, resultIndex) {
|
|
640
651
|
const result = details.results[resultIndex];
|
|
641
652
|
if (result?.progress) return result.progress;
|
|
@@ -907,6 +918,8 @@ function widgetStepRenderKey(step, index, expanded = false) {
|
|
|
907
918
|
step.workflowKey,
|
|
908
919
|
step.phase,
|
|
909
920
|
step.label,
|
|
921
|
+
step.progressText,
|
|
922
|
+
step.progressUpdatedAt,
|
|
910
923
|
step.status,
|
|
911
924
|
step.activityState,
|
|
912
925
|
step.lastActivityAt,
|
|
@@ -2002,6 +2015,8 @@ function foregroundStyleWidgetStepLines(job, theme, step, itemTitle, index, tota
|
|
|
2002
2015
|
const task = fullTask ? void 0 : collapseDetails ? stepTaskSummary(step, displayName) : compactTaskText(step.description, step.label);
|
|
2003
2016
|
for (const line of fullTask ?? []) lines.push(`${detailIndent}${theme.fg("dim", line)}`);
|
|
2004
2017
|
if (task) lines.push(`${detailIndent}${theme.fg("dim", `task: ${task}`)}`);
|
|
2018
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, detailIndent, width - 4) : void 0;
|
|
2019
|
+
if (progressRow) lines.push(progressRow);
|
|
2005
2020
|
const activity = widgetStepActivityLine(step, width, expanded, job.updatedAt);
|
|
2006
2021
|
const currentPath = options?.includeCurrentPath && step.currentPath ? shortenPath(step.currentPath) : void 0;
|
|
2007
2022
|
const activityWithPath = currentPath && activity && !activity.includes(currentPath) ? `${activity} \xB7 ${currentPath}` : activity ?? currentPath;
|
|
@@ -2126,12 +2141,14 @@ function compactSingleWidgetLines(job, theme, width, frame, projection = buildWo
|
|
|
2126
2141
|
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2127
2142
|
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2128
2143
|
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2129
|
-
const activitySuffix = activity ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", activity)}` : "";
|
|
2130
2144
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2131
2145
|
const task = compactTaskText(step.description, step.label);
|
|
2132
2146
|
const taskSuffix = task ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2147
|
+
const activitySuffix = activity ? ` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", activity)}` : "";
|
|
2133
2148
|
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
2134
2149
|
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame, thinking)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "\xB7")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "\xB7")} ${stepStats}` : ""}`);
|
|
2150
|
+
const progressRow = step.status === "running" ? reportedProgressRow(step, theme, " ", width) : void 0;
|
|
2151
|
+
if (progressRow) lines.push(progressRow);
|
|
2135
2152
|
const lane = projectAsyncLane(job, step);
|
|
2136
2153
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2137
2154
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2699,6 +2716,8 @@ function renderSingleCompact(d, r, theme, layout, frame, foregroundDetachShortcu
|
|
|
2699
2716
|
if (isRunning && r.progress) {
|
|
2700
2717
|
const task = compactTaskText(r.task);
|
|
2701
2718
|
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2719
|
+
const reportedRow = reportedProgressRow(r.progress, theme, detailIndent, width);
|
|
2720
|
+
if (reportedRow) c.addChild(new Text(reportedRow, 0, 0));
|
|
2702
2721
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
2703
2722
|
const activity = compactCurrentActivity(r.progress);
|
|
2704
2723
|
c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}\u23BF ${activity}`), width), 0, 0));
|
|
@@ -2936,6 +2955,8 @@ function renderMultiCompact(d, theme, layout, frame) {
|
|
|
2936
2955
|
const task = compactTaskText(r.task, workflowLabelForResult(d, i));
|
|
2937
2956
|
if (task) c.addChild(new Text(truncLine(theme.fg("dim", `${detailIndent}task: ${task}`), width), 0, 0));
|
|
2938
2957
|
}
|
|
2958
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, detailIndent, width) : void 0;
|
|
2959
|
+
if (reportedRow) c.addChild(new Text(reportedRow, 0, 0));
|
|
2939
2960
|
if (rRunning && rProg && "status" in rProg) {
|
|
2940
2961
|
const liveProgress = rProg;
|
|
2941
2962
|
const activity = compactCurrentActivity(liveProgress);
|
|
@@ -3034,6 +3055,8 @@ function renderSubagentResult(result, options, theme, frame, rendererConfig, for
|
|
|
3034
3055
|
c2.addChild(new Text(fit2(theme.fg(r.exitCode !== 0 ? "error" : "dim", ` \u23BF ${resultStatusLine(r, output)}`)), 0, 0));
|
|
3035
3056
|
}
|
|
3036
3057
|
if (isRunning && r.progress) {
|
|
3058
|
+
const reportedRow = reportedProgressRow(r.progress, theme, " ", w2);
|
|
3059
|
+
if (reportedRow) c2.addChild(new Text(fit2(reportedRow), 0, 0));
|
|
3037
3060
|
const progressSnapshotNow = snapshotNowForProgress(r.progress);
|
|
3038
3061
|
for (const nestedLine of formatNestedWidgetLines(r.children, theme, w2, true, progressSnapshotNow, 12)) {
|
|
3039
3062
|
c2.addChild(new Text(fit2(` ${nestedLine}`), 0, 0));
|
|
@@ -3202,6 +3225,8 @@ function renderSubagentResult(result, options, theme, frame, rendererConfig, for
|
|
|
3202
3225
|
const taskMaxLen = Math.max(20, w - 12);
|
|
3203
3226
|
const taskPreview = expanded || r.task.length <= taskMaxLen ? r.task : `${r.task.slice(0, taskMaxLen)}...`;
|
|
3204
3227
|
c.addChild(new Text(fit(theme.fg("dim", ` task: ${taskPreview}`)), 0, 0));
|
|
3228
|
+
const reportedRow = rRunning && progressFromArray ? reportedProgressRow(progressFromArray, theme, " ", w) : void 0;
|
|
3229
|
+
if (reportedRow) c.addChild(new Text(fit(reportedRow), 0, 0));
|
|
3205
3230
|
const outputTarget = extractOutputTarget(r.task);
|
|
3206
3231
|
if (outputTarget) {
|
|
3207
3232
|
c.addChild(new Text(fit(theme.fg("dim", ` output: ${outputTarget}`)), 0, 0));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestAsyncStop
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W6HIYD2Z.js";
|
|
4
4
|
import "./chunk-NIXWDZZV.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-4MVDMA5C.js";
|
|
6
6
|
import "./chunk-JEZOSEWG.js";
|
|
7
7
|
import "./chunk-YFCK7H2S.js";
|
|
8
8
|
import "./chunk-QXASAHIA.js";
|
package/bundle/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function readInstalledPackageVersion() {
|
|
|
17
17
|
var loadedPackageVersion = readInstalledPackageVersion();
|
|
18
18
|
|
|
19
19
|
// index.ts
|
|
20
|
-
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-
|
|
20
|
+
var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-MTPICU4A.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-4PM6RDE5.js")).default;
|
|
21
21
|
function registerSubagentExtension(pi) {
|
|
22
22
|
const installedVersion = readInstalledPackageVersion();
|
|
23
23
|
if (installedVersion !== loadedPackageVersion) {
|