@henryqw/pi-subagent 30.1.0 → 31.1.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 (41) hide show
  1. package/CONTEXT.md +2 -2
  2. package/README.md +19 -23
  3. package/dist/direct-herdr.d.ts +5 -0
  4. package/dist/direct-herdr.js +9 -1
  5. package/dist/ephemeral.d.ts +9 -3
  6. package/dist/ephemeral.js +70 -11
  7. package/dist/herdr-runtime.js +4 -0
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +2 -2
  10. package/dist/native-host.d.ts +96 -0
  11. package/dist/native-host.js +243 -0
  12. package/dist/runner.d.ts +8 -1
  13. package/dist/runner.js +22 -15
  14. package/dist/schema.d.ts +71 -2
  15. package/dist/schema.js +14 -1
  16. package/dist/workspace-schema.d.ts +11 -0
  17. package/dist/workspace.d.ts +5 -2
  18. package/dist/workspace.js +58 -29
  19. package/docs/measurement.md +12 -1
  20. package/docs/orchestration-architecture.html +4 -4
  21. package/docs/orchestration-architecture.svg +2 -2
  22. package/docs/orchestration.md +72 -259
  23. package/docs/workspace.md +4 -80
  24. package/extensions/admission.ts +36 -11
  25. package/extensions/direct-check-exec.py +91 -0
  26. package/extensions/direct-check-supervisor.mjs +42 -0
  27. package/extensions/direct-check-witness.mjs +34 -0
  28. package/extensions/direct-native.ts +17 -5
  29. package/extensions/direct-outbox.ts +189 -0
  30. package/extensions/direct-owner.ts +49 -0
  31. package/extensions/direct-verification.ts +73 -0
  32. package/extensions/isolated.ts +25 -301
  33. package/extensions/prerequisite-evidence.ts +81 -0
  34. package/extensions/result-transport.ts +6 -4
  35. package/extensions/subagent-command.ts +12 -7
  36. package/extensions/subagent.ts +378 -499
  37. package/extensions/workflow-recovery.ts +359 -0
  38. package/extensions/workflow.ts +156 -40
  39. package/extensions/workspace.ts +16 -74
  40. package/package.json +2 -2
  41. package/skills/pi-subagent/SKILL.md +15 -37
package/CONTEXT.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pi Subagent
2
2
 
3
- Pi Subagent delegates bounded work to Role-configured Pi workers. Direct tasks share Main's checkout; isolated requests produce checked candidates for explicit integration.
3
+ Pi Subagent delegates bounded work to Role-configured Pi workers. New tasks share Main's checkout. Pi displays native workers in its widget. Isolated terms below describe saved requests from earlier versions.
4
4
 
5
5
  ## Language
6
6
 
@@ -90,7 +90,7 @@ The caller emits a mutable `{ sessionId: string, pending: false }` object, then
90
90
  `pending` when `emit` returns. Pi Subagent changes only `pending`, and only to `true`.
91
91
  No listener means no pending result. Listeners must not wait for asynchronous work.
92
92
 
93
- A positive answer means that this process owns live direct or isolated work for
93
+ A positive answer means that this process owns live direct work for
94
94
  that exact current Pi session, with a future result message that triggers a turn.
95
95
  Direct ownership starts after a verified launch. Isolated ownership starts after
96
96
  durable acknowledgement. Ownership ends on completion or failure, before result
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@henryqw/pi-subagent`
2
2
 
3
- Delegate bounded tasks to Pi workers. Direct tasks share your checkout. Isolated tasks produce candidates for checked integration.
3
+ Delegate bounded tasks to Pi workers. Workers share your current checkout. A native Pi widget shows their progress.
4
4
 
5
5
  ## Install
6
6
 
@@ -12,40 +12,36 @@ pi install npm:@henryqw/pi-subagent
12
12
 
13
13
  If you use Billion Context for compression, set `pi.subagents` to `false` in `~/.config/billion-context/billion-context.json`. If you set `BILI_CONFIG_FILE`, edit that file instead. Restart Pi after you change the setting.
14
14
 
15
- Configure the required role profiles with `/task-models`. Direct tasks run in native Pi. For visible worker tabs or isolated tasks, use Herdr client and server version 0.9.3 or later.
15
+ Configure the required role profiles with `/task-models`. Pi shows workers in the current terminal. Shared-checkout writes require `lsof` for process checks.
16
16
 
17
17
  ## Use
18
18
 
19
- Ask a scout to trace a function and report the relevant files. Main uses `delegate_task` to dispatch the work. Use `/subagent` to inspect or recover a worker.
19
+ Ask a scout to trace a function and report the relevant files. Main uses `delegate_task` to dispatch the work. Use `/subagent` to inspect worker sessions, stop a worker, or review recovery actions. The terminal widget shows each direct worker’s task, model, activity, and measured usage.
20
20
 
21
- Print and JSON sessions receive the direct result in the tool call. Interactive and remote control sessions receive one follow-up when the workers finish. Set `wait` to `true` for an inline answer in these sessions.
21
+ Print and JSON sessions receive the direct result in the tool call. Saved interactive and remote control sessions group ready results into one follow-up at a turn boundary. After a restart on the same host, Pi starts eligible reads on the original session branch and returns one workflow result. Unsaved sessions receive results inline. Set `wait` to `true` for an inline answer in these sessions.
22
22
 
23
- Direct workers share 4,096 bytes of inline answer text per request. A short answer appears once. The result links to a private file for each oversized answer. A chain passes the complete answer to its next worker.
23
+ Direct workers share 4,096 bytes of inline answer text per request. A short answer appears once. The result links to a private file for each oversized answer. A chain passes the complete answer to its next worker. A dependent receives a verified file reference when its prerequisite excerpt is incomplete.
24
24
 
25
- Use the `scout`, `reviewer`, `implementer`, `planner`, or `oracle` role. Main can cancel an owned workflow with `mode: "cancel"` and its exact `id`.
25
+ Use the `scout`, `reviewer`, `implementer`, `planner`, or `oracle` role. Main can cancel an owned workflow with `mode: "cancel"` and its exact `id`. After a restart, the same call stops a recovered native writer and releases its checkout reservation. It finds the writer by its saved PID and the process lease that it held from spawn. Other recovered records need the user in `/subagent`.
26
26
 
27
27
  The [delegation measurements](./docs/measurement.md) compare parent results and report live worker usage.
28
28
 
29
- Direct writes immediately affect your checkout. The extension holds the checkout until it verifies that the worker and its lease holders stopped. Use isolated mode for work that requires validation before integration.
29
+ Direct writes immediately affect your checkout. The extension holds the checkout until it verifies that the worker and its lease holders stopped.
30
+
31
+ Each writer can run up to three acceptance checks within the configured worker timeout. Checks require `/usr/bin/python3`. Linux also requires `libseccomp.so.2`. On macOS, checks that use `posix_spawn` to start children receive a permission error.
32
+
33
+ A writer can correct one failed check if the workflow has corrections left. Set `maxCorrections` to zero to disable corrections. After a final acceptance failure, inspect the edits and close the workflow to release the checkout.
30
34
 
31
35
  ```json
32
36
  {
33
- "mode": "isolated",
34
- "id": "refresh-repair",
35
- "goal": "Repair token refresh.",
36
- "tasks": [{
37
- "id": "repair",
38
- "kind": "changeset",
39
- "role": "implementer",
40
- "modelClass": "balanced",
41
- "requirements": "Implement the smallest correct repair.",
42
- "deliverable": "A committed candidate in the owned worktree.",
43
- "dependsOn": [],
44
- "contextFrom": [],
45
- "checks": [{ "command": "pnpm", "args": ["test", "--", "refresh"] }]
46
- }],
47
- "finalChecks": [{ "command": "pnpm", "args": ["test", "--", "refresh"] }]
37
+ "mode": "direct",
38
+ "role": "implementer",
39
+ "name": "Repair token refresh",
40
+ "access": "write",
41
+ "task": "Repair token refresh and run its tests. Report the changes and results."
48
42
  }
49
43
  ```
50
44
 
51
- See the [orchestration contract](./docs/orchestration.md) for roles, parallel tasks, cancellation, recovery, and checked integration.
45
+ Use `dependsOn` to start a task when its named prerequisites pass. After an interruption, Main can continue eligible read tasks from the saved branch. Inspect partial changes before starting another writer.
46
+
47
+ Use `/subagent` to inspect saved work from earlier versions. The [orchestration contract](./docs/orchestration.md) covers roles, parallel tasks, cancellation, and recovery.
@@ -26,6 +26,11 @@ export interface DirectHandle {
26
26
  export declare function exactDirectTerminalTurn(jsonl: string, prompt: string): boolean;
27
27
  /** Refuse continuation unless the saved session's exact recorded turn is terminal and no later user turn exists. */
28
28
  export declare function assertSettledDirectSession(sessionFile: string, turn: string, provedStopped?: boolean): Promise<void>;
29
+ /** A write-access worker ended its turn normally and reported that it did not succeed. */
30
+ export declare class DirectReportedOutcomeError extends Error {
31
+ readonly outcome: "failed" | "blocked";
32
+ constructor(outcome: "failed" | "blocked", answer: string);
33
+ }
29
34
  export declare function exactDirectAnswer(jsonl: string, prompt: string, requireSuccess?: boolean): string;
30
35
  /** Measured from one session read; each field is absent when no turn record carried it. */
31
36
  export interface DirectUsage {
@@ -117,6 +117,14 @@ export async function assertSettledDirectSession(sessionFile, turn, provedStoppe
117
117
  throw new Error(`Saved Pi session ${sessionFile} has no terminal final turn for the recorded prompt; the worker may still be running`);
118
118
  }
119
119
  }
120
+ /** A write-access worker ended its turn normally and reported that it did not succeed. */
121
+ export class DirectReportedOutcomeError extends Error {
122
+ outcome;
123
+ constructor(outcome, answer) {
124
+ super(`Direct task reported ${outcome}: ${answer}`);
125
+ this.outcome = outcome;
126
+ }
127
+ }
120
128
  export function exactDirectAnswer(jsonl, prompt, requireSuccess = false) {
121
129
  const final = exactFinalTurn(jsonl, prompt);
122
130
  if (!final || final.stopReason !== "stop" || !Array.isArray(final.content)) {
@@ -143,7 +151,7 @@ export function exactDirectAnswer(jsonl, prompt, requireSuccess = false) {
143
151
  throw new Error("Pi write-access completion must have a valid outcome and a non-empty answer.");
144
152
  }
145
153
  if (completion.outcome !== "succeeded")
146
- throw new Error(`Direct task reported ${completion.outcome}: ${completion.answer}`);
154
+ throw new DirectReportedOutcomeError(completion.outcome, completion.answer);
147
155
  return completion.answer;
148
156
  }
149
157
  class DirectSessionState {
@@ -35,12 +35,17 @@ export interface EphemeralSubagentRunInput {
35
35
  onUpdate?: (text: string) => void;
36
36
  onTokens?: (tokens: number) => void;
37
37
  onActivity?: (event: EphemeralSubagentActivityEvent) => void;
38
+ /** Allow one retry only for an EAGAIN spawn failure before a child exists. */
39
+ retryReadOnlySpawn?: boolean;
38
40
  /** Distinguish confirmed absence before spawn from an observed process exit. */
39
41
  onProcessEnd?: (reason: "not-started" | "exited") => void;
42
+ /** Receives the worker PID right after spawn. A throw stops the worker. */
43
+ onSpawn?: (pid: number) => void;
40
44
  prepare: () => Promise<{
41
45
  launch: PiLaunch;
42
46
  task: string;
43
47
  cwd: string;
48
+ leaseFd?: number;
44
49
  }>;
45
50
  }
46
51
  interface EphemeralSubagentResultBase {
@@ -68,13 +73,14 @@ export declare class EphemeralSubagentError extends Error {
68
73
  export interface EphemeralSubagentExecutor {
69
74
  run(input: EphemeralSubagentRunInput): Promise<EphemeralSubagentResult>;
70
75
  }
76
+ export interface EphemeralExecutorPool extends EphemeralSubagentExecutor {
77
+ withLimits(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor;
78
+ }
71
79
  /**
72
80
  * Creates a bounded ephemeral executor for callers already running inside Pi.
73
81
  * It reuses the active Pi process invocation; it does not resolve a standalone Pi installation.
74
82
  */
75
- export declare function createEphemeralSubagentExecutor(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor & {
76
- withLimits(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor;
77
- };
83
+ export declare function createEphemeralSubagentExecutor(options: EphemeralSubagentExecutorOptions): EphemeralExecutorPool;
78
84
  /** Longest prefix of `text` within `maxBytes` UTF-8 bytes, never splitting a code point. */
79
85
  export declare function utf8Prefix(text: string, maxBytes: number): string;
80
86
  export declare function capEphemeralSubagentOutput(text: string): string;
package/dist/ephemeral.js CHANGED
@@ -110,9 +110,15 @@ function validateRunInput(value) {
110
110
  if (input.onActivity !== undefined && typeof input.onActivity !== "function") {
111
111
  throw new TypeError("run.onActivity must be a function.");
112
112
  }
113
+ if (input.retryReadOnlySpawn !== undefined && typeof input.retryReadOnlySpawn !== "boolean") {
114
+ throw new TypeError("run.retryReadOnlySpawn must be a boolean.");
115
+ }
113
116
  if (input.onProcessEnd !== undefined && typeof input.onProcessEnd !== "function") {
114
117
  throw new TypeError("run.onProcessEnd must be a function.");
115
118
  }
119
+ if (input.onSpawn !== undefined && typeof input.onSpawn !== "function") {
120
+ throw new TypeError("run.onSpawn must be a function.");
121
+ }
116
122
  return value;
117
123
  }
118
124
  function record(value, field) {
@@ -148,7 +154,11 @@ function validatePrepared(value) {
148
154
  }
149
155
  env[name] = value;
150
156
  }
157
+ const fd = prepared.leaseFd;
158
+ if (fd !== undefined && (typeof fd !== "number" || !Number.isSafeInteger(fd) || fd < 3))
159
+ throw new TypeError("Invalid native process lease descriptor.");
151
160
  return {
161
+ ...(typeof fd === "number" ? { leaseFd: fd } : {}),
152
162
  launch: { args, env },
153
163
  task: preparedText(prepared.task, "Prepared Subagent task"),
154
164
  cwd: preparedText(prepared.cwd, "Prepared Subagent cwd"),
@@ -391,15 +401,35 @@ export function formatDuration(milliseconds) {
391
401
  const minutes = Math.floor(seconds % 3_600 / 60);
392
402
  return hours ? `${hours}h ${minutes}m` : minutes ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
393
403
  }
404
+ class RetryableSpawnFailure extends Error {
405
+ }
406
+ function isTransientSpawnFailure(cause) {
407
+ return cause instanceof Error && cause.code === "EAGAIN";
408
+ }
394
409
  async function runPi(prepared, input, budget, invocation) {
410
+ const startedAt = Date.now();
411
+ try {
412
+ return await runPiAttempt(prepared, input, budget, invocation, startedAt, input.retryReadOnlySpawn === true);
413
+ }
414
+ catch (cause) {
415
+ if (!(cause instanceof RetryableSpawnFailure))
416
+ throw cause;
417
+ return await runPiAttempt(prepared, input, budget, invocation, startedAt, false);
418
+ }
419
+ }
420
+ async function runPiAttempt(prepared, input, budget, invocation, startedAt, allowRetry) {
395
421
  if (input.signal?.aborted) {
396
422
  notifyNotStarted(input);
397
423
  throw abortError(input.signal);
398
424
  }
399
425
  const timeoutPolicy = budget.timeout;
426
+ if (Date.now() >= startedAt + timeoutPolicy.idleMs) {
427
+ notifyNotStarted(input);
428
+ const message = `Subagent timed out after ${formatDuration(timeoutPolicy.idleMs)} without a recognized Pi event.`;
429
+ throw new EphemeralSubagentError("timeout", message, new Error(message));
430
+ }
400
431
  return await new Promise((resolve, reject) => {
401
432
  const args = [...invocation.args, "--mode", "json", "-p", ...prepared.launch.args, `Task: ${prepared.task}`];
402
- const startedAt = Date.now();
403
433
  const maxDeadline = timeoutPolicy.maxMs === null ? undefined : startedAt + timeoutPolicy.maxMs;
404
434
  let child;
405
435
  try {
@@ -417,13 +447,20 @@ async function runPi(prepared, input, budget, invocation) {
417
447
  [EXECUTION_BUDGET_ENV]: JSON.stringify(executionBudget),
418
448
  },
419
449
  shell: false,
420
- stdio: ["ignore", "pipe", "pipe"],
450
+ stdio: prepared.leaseFd === undefined ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe", prepared.leaseFd],
421
451
  detached: process.platform !== "win32",
422
452
  });
423
453
  }
424
454
  catch (cause) {
455
+ if (allowRetry && !input.signal?.aborted && Date.now() < startedAt + timeoutPolicy.idleMs && isTransientSpawnFailure(cause)) {
456
+ reject(new RetryableSpawnFailure());
457
+ return;
458
+ }
425
459
  notifyNotStarted(input);
426
- reject(new EphemeralSubagentError("spawn", cause instanceof Error ? cause.message : String(cause), cause));
460
+ if (input.signal?.aborted)
461
+ reject(abortError(input.signal));
462
+ else
463
+ reject(new EphemeralSubagentError("spawn", cause instanceof Error ? cause.message : String(cause), cause));
427
464
  return;
428
465
  }
429
466
  child.stdout.setEncoding("utf8");
@@ -456,6 +493,7 @@ async function runPi(prepared, input, budget, invocation) {
456
493
  let timedOutAfterMs;
457
494
  let timeoutReason;
458
495
  let childExited = false;
496
+ let childObserved = child.pid !== undefined;
459
497
  let completedTokens = 0;
460
498
  let currentTokens = 0;
461
499
  let completedUsage;
@@ -480,6 +518,7 @@ async function runPi(prepared, input, budget, invocation) {
480
518
  let onStderrEnd;
481
519
  let onStdoutClose;
482
520
  let onStderrClose;
521
+ let onChildSpawn;
483
522
  let onChildError;
484
523
  let onChildExit;
485
524
  let onChildClose;
@@ -509,6 +548,8 @@ async function runPi(prepared, input, budget, invocation) {
509
548
  child.stdout.off("close", onStdoutClose);
510
549
  if (onStderrClose)
511
550
  child.stderr.off("close", onStderrClose);
551
+ if (onChildSpawn)
552
+ child.off("spawn", onChildSpawn);
512
553
  if (onChildError)
513
554
  child.off("error", onChildError);
514
555
  if (onChildExit)
@@ -521,6 +562,20 @@ async function runPi(prepared, input, budget, invocation) {
521
562
  return;
522
563
  settled = true;
523
564
  clearLifecycle();
565
+ const notStarted = spawnError !== undefined && child.pid === undefined && !childExited && !childObserved;
566
+ if (notStarted && allowRetry && (code === null || code < 0) && !callbackFailure && !aborted && !input.signal?.aborted
567
+ && timedOutAfterMs === undefined && !limit && !protocolError && Date.now() < deadline && isTransientSpawnFailure(spawnError)) {
568
+ reject(new RetryableSpawnFailure());
569
+ return;
570
+ }
571
+ if (notStarted) {
572
+ try {
573
+ input.onProcessEnd?.("not-started");
574
+ }
575
+ catch (cause) {
576
+ callbackFailure = new EphemeralSubagentError("callback", "Subagent onProcessEnd callback failed.", cause);
577
+ }
578
+ }
524
579
  if (callbackFailure) {
525
580
  reject(new EphemeralSubagentError("callback", callbackFailure.message, callbackFailure.cause, accumulatedUsage()));
526
581
  }
@@ -569,6 +624,14 @@ async function runPi(prepared, input, budget, invocation) {
569
624
  signalCallbackFailure();
570
625
  stop(true);
571
626
  };
627
+ if (child.pid !== undefined && input.onSpawn) {
628
+ try {
629
+ input.onSpawn(child.pid);
630
+ }
631
+ catch (cause) {
632
+ failCallback("onSpawn", cause);
633
+ }
634
+ }
572
635
  let activityQueue = Promise.resolve();
573
636
  const invokeCallback = (name, callback, value) => {
574
637
  if (!callback || callbackFailure)
@@ -797,6 +860,7 @@ async function runPi(prepared, input, budget, invocation) {
797
860
  clearPostExitTimers();
798
861
  };
799
862
  onStdoutData = (data) => {
863
+ childObserved = true;
800
864
  armPostExitIdleDeadline();
801
865
  if (callbackFailure || protocolError || limit)
802
866
  return;
@@ -850,6 +914,7 @@ async function runPi(prepared, input, budget, invocation) {
850
914
  }
851
915
  };
852
916
  onStderrData = (data) => {
917
+ childObserved = true;
853
918
  armPostExitIdleDeadline();
854
919
  appendBounded(stderr, data);
855
920
  };
@@ -901,16 +966,9 @@ async function runPi(prepared, input, budget, invocation) {
901
966
  timeoutReason = reason;
902
967
  stop();
903
968
  }
969
+ onChildSpawn = () => { childObserved = true; };
904
970
  onChildError = (error) => {
905
971
  spawnError = error;
906
- if (child.pid === undefined) {
907
- try {
908
- input.onProcessEnd?.("not-started");
909
- }
910
- catch (cause) {
911
- failCallback("onProcessEnd", cause);
912
- }
913
- }
914
972
  if (input.signal?.aborted)
915
973
  aborted = true;
916
974
  };
@@ -944,6 +1002,7 @@ async function runPi(prepared, input, budget, invocation) {
944
1002
  await Promise.race([Promise.all(pendingCallbacks), callbackFailed]);
945
1003
  complete(code);
946
1004
  };
1005
+ child.once("spawn", onChildSpawn);
947
1006
  child.once("error", onChildError);
948
1007
  child.once("exit", onChildExit);
949
1008
  child.once("close", onChildClose);
@@ -377,6 +377,8 @@ export class HerdrHostRuntime {
377
377
  };
378
378
  }
379
379
  async allocateHost(input, context) {
380
+ if (input.intent.kind === "native")
381
+ throw new Error("Native worker cannot be managed through Herdr.");
380
382
  requireIntentIdentity(input.intent, input.attempt);
381
383
  if (input.intent.kind === "workspace") {
382
384
  if (input.acquireLaunch)
@@ -391,6 +393,8 @@ export class HerdrHostRuntime {
391
393
  return await this.allocateAgent(input.intent, input.task.role, input.attempt, input.acquireLaunch, context);
392
394
  }
393
395
  async reconcileHostAllocation(input, context) {
396
+ if (input.intent.kind === "native")
397
+ throw new Error("Native worker cannot be managed through Herdr.");
394
398
  requireIntentIdentity(input.intent, input.attempt);
395
399
  const allocation = input.intent;
396
400
  if (allocation.kind === "workspace") {
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare const CHILD_EXCLUDED_TOOL_NAMES: readonly ["delegate_task", "ask_
18
18
  export declare const DELEGATE_TASK: {
19
19
  readonly id: "pi-subagent/delegateTask";
20
20
  readonly label: "Subagent delegation";
21
- readonly purpose: "Launch direct or checked isolated Pi delegation.";
21
+ readonly purpose: "Launch shared-checkout Pi delegation.";
22
22
  readonly defaultProfile: "fast";
23
23
  };
24
24
  export type RoleName = string;
package/dist/index.js CHANGED
@@ -63,7 +63,7 @@ const CHILD_IDENTITY_POLICY = "You are a delegated Pi Subagent, not Main. Execut
63
63
  export const DELEGATE_TASK = {
64
64
  id: "pi-subagent/delegateTask",
65
65
  label: "Subagent delegation",
66
- purpose: "Launch direct or checked isolated Pi delegation.",
66
+ purpose: "Launch shared-checkout Pi delegation.",
67
67
  defaultProfile: "fast",
68
68
  };
69
69
  const cleanText = (value, field, source) => {
@@ -145,7 +145,7 @@ function roleModelClass(value, source) {
145
145
  function rejectRetiredRoleIsolation(value, source) {
146
146
  if (value === undefined)
147
147
  return;
148
- throw new Error(`${source}: Role isolation is retired; select mode \"isolated\" on delegate_task instead.`);
148
+ throw new Error(`${source}: Role isolation is retired; workers share the existing checkout.`);
149
149
  }
150
150
  const ROLE_FRONTMATTER_KEYS = ["name", "description", "modelClass", "tools", "extensions", "skills", "mcps"];
151
151
  const ROLE_DEFAULT_KEYS = ["extensions", "tools", "skills"];
@@ -0,0 +1,96 @@
1
+ import type { EphemeralExecutorPool } from "./ephemeral.ts";
2
+ import { type CoordinatorRuntime, type HostRuntime, type InFlightTaskCandidateInspector, type OperationContext, type WorkerResult } from "./runner.ts";
3
+ import { type TaskAttempt } from "./schema.ts";
4
+ type Input<K extends keyof HostRuntime> = Parameters<NonNullable<HostRuntime[K]>>[0];
5
+ /** New checked tasks own a session and process lease. Saved Herdr allocations retain their original recovery authority. */
6
+ export declare class NativeHostRuntime implements HostRuntime {
7
+ private readonly directory;
8
+ private readonly previous;
9
+ private readonly coordinator;
10
+ private readonly executor;
11
+ private readonly git;
12
+ constructor(previous: HostRuntime, coordinator: CoordinatorRuntime, executor: EphemeralExecutorPool, git: InFlightTaskCandidateInspector, agentDir?: string);
13
+ allocationKinds(attempt: TaskAttempt): readonly ["native"] | readonly ["workspace", "worker_tab", "agent"];
14
+ private address;
15
+ private check;
16
+ planHostAllocation(input: Input<"planHostAllocation">, ctx: OperationContext): Promise<import("./schema.ts").HostAllocationPlan>;
17
+ allocateHost(input: Input<"allocateHost">, ctx: OperationContext): Promise<{
18
+ kind: "native";
19
+ outcome: "owned";
20
+ leaseIdentity: string;
21
+ } | {
22
+ kind: "agent";
23
+ outcome: "absent";
24
+ failure: string;
25
+ } | {
26
+ kind: "native";
27
+ outcome: "absent";
28
+ failure: string;
29
+ } | {
30
+ kind: "worker_tab";
31
+ outcome: "absent";
32
+ failure: string;
33
+ } | {
34
+ kind: "workspace";
35
+ outcome: "absent";
36
+ failure: string;
37
+ } | {
38
+ kind: "agent";
39
+ outcome: "unknown";
40
+ failure: string;
41
+ possibleResources?: string[];
42
+ } | {
43
+ kind: "native";
44
+ outcome: "unknown";
45
+ failure: string;
46
+ possibleResources?: string[];
47
+ } | {
48
+ kind: "worker_tab";
49
+ outcome: "unknown";
50
+ failure: string;
51
+ possibleResources?: string[];
52
+ } | {
53
+ kind: "workspace";
54
+ outcome: "unknown";
55
+ failure: string;
56
+ possibleResources?: string[];
57
+ } | {
58
+ kind: "workspace";
59
+ outcome: "owned";
60
+ workspaceId: string;
61
+ rootTabId: string;
62
+ rootPaneId: string;
63
+ } | {
64
+ kind: "worker_tab";
65
+ outcome: "owned";
66
+ tabId: string;
67
+ paneId: string;
68
+ } | {
69
+ kind: "agent";
70
+ outcome: "owned";
71
+ }>;
72
+ reconcileHostAllocation(input: Input<"reconcileHostAllocation">, ctx: OperationContext): Promise<import("./runner.ts").AllocationReconciliation<import("./runner.ts").HostAllocationKind>>;
73
+ private identity;
74
+ private holders;
75
+ runWorker(input: Input<"runWorker">, ctx: OperationContext): Promise<WorkerResult>;
76
+ reconcileWorkerTermination(input: Input<"reconcileWorkerTermination">, ctx: OperationContext): Promise<{
77
+ outcome: "terminated" | "active";
78
+ } | {
79
+ outcome: "unknown";
80
+ failure: string;
81
+ }>;
82
+ terminateWorker(input: Input<"terminateWorker">, ctx: OperationContext): Promise<{
83
+ outcome: "unknown";
84
+ failure: string;
85
+ } | {
86
+ failure?: undefined;
87
+ outcome: "terminated";
88
+ }>;
89
+ cleanupHost(input: Input<"cleanupHost">, ctx: OperationContext): Promise<{
90
+ outcome: "completed" | "absent";
91
+ } | {
92
+ outcome: "blocked";
93
+ failure: string;
94
+ }>;
95
+ }
96
+ export {};