@henryqw/pi-subagent 30.1.0 → 31.0.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.
Files changed (38) hide show
  1. package/CONTEXT.md +2 -2
  2. package/README.md +18 -22
  3. package/dist/ephemeral.d.ts +7 -3
  4. package/dist/ephemeral.js +59 -11
  5. package/dist/herdr-runtime.js +4 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/native-host.d.ts +96 -0
  9. package/dist/native-host.js +243 -0
  10. package/dist/runner.d.ts +8 -1
  11. package/dist/runner.js +22 -15
  12. package/dist/schema.d.ts +71 -2
  13. package/dist/schema.js +14 -1
  14. package/dist/workspace-schema.d.ts +11 -0
  15. package/dist/workspace.d.ts +5 -2
  16. package/dist/workspace.js +58 -29
  17. package/docs/measurement.md +12 -1
  18. package/docs/orchestration-architecture.html +4 -4
  19. package/docs/orchestration-architecture.svg +2 -2
  20. package/docs/orchestration.md +69 -258
  21. package/docs/workspace.md +4 -80
  22. package/extensions/direct-check-exec.py +91 -0
  23. package/extensions/direct-check-supervisor.mjs +42 -0
  24. package/extensions/direct-check-witness.mjs +34 -0
  25. package/extensions/direct-native.ts +5 -3
  26. package/extensions/direct-outbox.ts +189 -0
  27. package/extensions/direct-owner.ts +49 -0
  28. package/extensions/direct-verification.ts +73 -0
  29. package/extensions/isolated.ts +25 -301
  30. package/extensions/prerequisite-evidence.ts +81 -0
  31. package/extensions/result-transport.ts +6 -4
  32. package/extensions/subagent-command.ts +12 -7
  33. package/extensions/subagent.ts +302 -495
  34. package/extensions/workflow-recovery.ts +359 -0
  35. package/extensions/workflow.ts +156 -40
  36. package/extensions/workspace.ts +16 -74
  37. package/package.json +2 -2
  38. package/skills/pi-subagent/SKILL.md +15 -37
@@ -32,6 +32,7 @@ export interface DirectTask {
32
32
  cost?: number;
33
33
  /** Recorded workers by original index; empty for legacy records. */
34
34
  workers: readonly DirectDisplay[];
35
+ sessions?: readonly { entryId: string; sessionFile: string; turn: string; display?: DirectDisplay; cost?: number }[];
35
36
  tabs: readonly { entryId: string; name: string; tabId: string; paneId: string; sessionFile: string; display?: DirectDisplay; cost?: number }[];
36
37
  }
37
38
  const costSuffix = (cost: number | undefined) => compactCost(cost) === undefined ? "" : ` · ${compactCost(cost)}`;
@@ -89,7 +90,7 @@ export interface SubagentCommandAdapter {
89
90
  prune(cwd: string, items: readonly PruneItem[], allowIgnored: boolean, force: boolean, current: () => boolean, progress?: PruneProgress): Promise<CleanupReport>;
90
91
  /** Read-only Role catalog report with routes and per-file load errors. */
91
92
  roles(ctx: ExtensionContext): RolesReport;
92
- inspectInTab(root: string, requestId: string, ctx: ExtensionContext, current: () => boolean): Promise<{ ref: string; tabId: string; name: string; sessionFile: string }>;
93
+ inspect(root: string, requestId: string, ctx: ExtensionContext, current: () => boolean): Promise<string>;
93
94
  canFollowup(root: string, requestId: string, taskId: string): boolean;
94
95
  enqueue(root: string, requestId: string, taskId: string, text: string, current: () => boolean): string;
95
96
  drain(root: string, requestId: string, taskId: string, current: () => boolean): readonly string[];
@@ -284,7 +285,7 @@ function discardReview(plan: DiscardPlan): { report: Report; shown: DiscardPlan[
284
285
  function directReport(task: DirectTask): Report {
285
286
  const [first] = task.workers;
286
287
  const missing = first ? first.workers - task.workers.length : 0;
287
- const untabbed = task.workers.filter((worker) => !task.tabs.some((tab) => tab.display?.worker === worker.worker));
288
+ const untabbed = task.workers.filter((worker) => !task.tabs.some((tab) => tab.display?.worker === worker.worker) && !task.sessions?.some((session) => session.display?.worker === worker.worker));
288
289
  return { tone: statusTone(task.status), title: `Direct workflow ${directLabel(task)} · ${task.status}${costSuffix(task.cost)}`, sections: [
289
290
  { rows: [{ label: "ID", value: task.id, code: true }, ...(task.recovery ? [{ label: "recovery", value: clean(task.recovery, 4000), tone: "warning" as const }] : [])] },
290
291
  ...(task.admission ? [{ heading: "Checkout protection", rows: [
@@ -292,6 +293,11 @@ function directReport(task: DirectTask): Report {
292
293
  { label: "complete checkout set", value: task.admission.checkouts.join("\n"), code: true },
293
294
  { label: "saved effect evidence", value: task.admission.evidence, code: true },
294
295
  ] }] : []),
296
+ ...(task.sessions ?? []).map((session): Section => ({ heading: session.display ? workerLabel(session.display) : session.entryId, rows: [
297
+ { label: "task", value: session.entryId, code: true }, { label: "session", value: session.sessionFile, code: true },
298
+ { label: "turn", value: session.turn, code: true },
299
+ ...(compactCost(session.cost) === undefined ? [] : [{ label: "cost", value: compactCost(session.cost)! }]),
300
+ ] })),
295
301
  ...task.tabs.map((tab): Section => ({ heading: tab.display ? workerLabel(tab.display) : tab.name, rows: [
296
302
  ...([["task", tab.entryId], ["agent", tab.name], ["tab", tab.tabId], ["pane", tab.paneId], ["session", tab.sessionFile]] as const).map(([label, value]) => ({ label, value, code: true })),
297
303
  ...(compactCost(tab.cost) === undefined ? [] : [{ label: "cost", value: compactCost(tab.cost)! }]),
@@ -850,12 +856,12 @@ export function registerSubagentCommand(pi: ExtensionAPI, adapter: SubagentComma
850
856
  const { task } = selected;
851
857
  const label = clean(directLabel(task));
852
858
  deliver(ctx, directReport(task));
853
- const stoppable = task.tabs.filter((tab) => task.stoppable?.includes(tab.entryId));
859
+ const stoppable = [...task.tabs, ...(task.sessions ?? [])].filter((worker) => task.stoppable?.includes(worker.entryId));
854
860
  if (task.canClose || stoppable.length || task.admission?.canRecover) {
855
861
  const action = await choose<{ kind: "close" | "back" | "recover" } | { kind: "stop"; entryId: string }>(ctx, `Direct · ${label}`, [
856
862
  ...(task.canClose ? [{ label: "Close/cancel-and-release ALL owned workers in this workflow (preserve files and commits)", value: { kind: "close" as const } }] : []),
857
863
  ...(task.admission?.canRecover && adapter.recoverDirect ? [{ label: "Review recovered checkout protection", value: { kind: "recover" as const } }] : []),
858
- ...stoppable.map((tab) => ({ label: `Stop this worker: ${tab.display ? workerLabel(tab.display) : tab.name} (other workers continue)`, value: { kind: "stop" as const, entryId: tab.entryId } })),
864
+ ...stoppable.map((tab) => ({ label: `Stop this worker: ${tab.display ? workerLabel(tab.display) : ("name" in tab ? tab.name : tab.entryId)} (other workers continue)`, value: { kind: "stop" as const, entryId: tab.entryId } })),
859
865
  { label: "Back / refresh", value: { kind: "back" as const } },
860
866
  ]);
861
867
  if (!valid()) return;
@@ -900,9 +906,8 @@ export function registerSubagentCommand(pi: ExtensionAPI, adapter: SubagentComma
900
906
  }
901
907
  if (action === "inspect") {
902
908
  try {
903
- const tab = await adapter.inspectInTab(root, request.id, ctx, current);
904
- if (valid()) deliver(ctx, { tone: "success", title: `Status inspection ${tab.ref} started`, sections: [{ rows: [
905
- { label: "tab", value: tab.tabId, code: true }, { label: "agent", value: tab.name, code: true }, { label: "session", value: tab.sessionFile, code: true }] }] });
909
+ const status = await adapter.inspect(root, request.id, ctx, current);
910
+ if (valid()) deliver(ctx, textReport("info", status, `Status · ${request.id}`));
906
911
  }
907
912
  catch (error) { if (valid()) ctx.ui.notify(`Inspection failed: ${errorText(error)}`, "error"); }
908
913
  continue;