pi-subagents-lite 1.4.3 → 1.4.4
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/package.json
CHANGED
|
@@ -58,6 +58,9 @@ export class SpawnCoordinator {
|
|
|
58
58
|
/** Agent IDs spawned as background — only these trigger a nudge on completion. */
|
|
59
59
|
private backgroundAgentIds = new Set<string>();
|
|
60
60
|
|
|
61
|
+
/** Captured ExtensionContext per background agent, bound to the spawning session. */
|
|
62
|
+
private backgroundContexts = new Map<string, ExtensionContext>();
|
|
63
|
+
|
|
61
64
|
/** Pending nudge agent IDs, batched within the delay window. */
|
|
62
65
|
private pendingNudges = new Set<string>();
|
|
63
66
|
|
|
@@ -106,14 +109,12 @@ export class SpawnCoordinator {
|
|
|
106
109
|
widget.ensureTimer();
|
|
107
110
|
}
|
|
108
111
|
|
|
109
|
-
// Track background agents
|
|
112
|
+
// Track background agents + capture ctx for fallback notification
|
|
110
113
|
if (intent.runInBackground) {
|
|
111
114
|
this.backgroundAgentIds.add(agentId);
|
|
115
|
+
this.backgroundContexts.set(agentId, ctx);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
// pi is read from shell at nudge time, not stored here
|
|
115
|
-
// (avoids stale ctx after session replacement or reload)
|
|
116
|
-
|
|
117
118
|
const record = this.manager.getRecord(agentId)!;
|
|
118
119
|
|
|
119
120
|
if (!intent.runInBackground) {
|
|
@@ -181,6 +182,7 @@ export class SpawnCoordinator {
|
|
|
181
182
|
this.pendingNudges.clear();
|
|
182
183
|
this.liveViews.clear();
|
|
183
184
|
this.backgroundAgentIds.clear();
|
|
185
|
+
this.backgroundContexts.clear();
|
|
184
186
|
this.disposed = true;
|
|
185
187
|
}
|
|
186
188
|
|
|
@@ -242,9 +244,21 @@ export class SpawnCoordinator {
|
|
|
242
244
|
},
|
|
243
245
|
);
|
|
244
246
|
} catch (error) {
|
|
245
|
-
//
|
|
246
|
-
//
|
|
247
|
-
|
|
247
|
+
// sendMessage failed (shared runtime overwritten by subagent bindCore).
|
|
248
|
+
// Fall back to UI notification using the captured spawning-session context.
|
|
249
|
+
const spawnCtx = this.backgroundContexts.get(agentId);
|
|
250
|
+
if (spawnCtx?.ui?.notify) {
|
|
251
|
+
try {
|
|
252
|
+
spawnCtx.ui.notify(
|
|
253
|
+
`[Subagent "${record.display.type}" ${record.lifecycle.status}] Result available`,
|
|
254
|
+
"info",
|
|
255
|
+
);
|
|
256
|
+
} catch {
|
|
257
|
+
// ctx may also be stale if session was replaced
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} finally {
|
|
261
|
+
this.backgroundContexts.delete(agentId);
|
|
248
262
|
}
|
|
249
263
|
}
|
|
250
264
|
}
|