@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.
- package/CONTEXT.md +2 -2
- package/README.md +18 -22
- package/dist/ephemeral.d.ts +7 -3
- package/dist/ephemeral.js +59 -11
- package/dist/herdr-runtime.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/native-host.d.ts +96 -0
- package/dist/native-host.js +243 -0
- package/dist/runner.d.ts +8 -1
- package/dist/runner.js +22 -15
- package/dist/schema.d.ts +71 -2
- package/dist/schema.js +14 -1
- package/dist/workspace-schema.d.ts +11 -0
- package/dist/workspace.d.ts +5 -2
- package/dist/workspace.js +58 -29
- package/docs/measurement.md +12 -1
- package/docs/orchestration-architecture.html +4 -4
- package/docs/orchestration-architecture.svg +2 -2
- package/docs/orchestration.md +69 -258
- package/docs/workspace.md +4 -80
- package/extensions/direct-check-exec.py +91 -0
- package/extensions/direct-check-supervisor.mjs +42 -0
- package/extensions/direct-check-witness.mjs +34 -0
- package/extensions/direct-native.ts +5 -3
- package/extensions/direct-outbox.ts +189 -0
- package/extensions/direct-owner.ts +49 -0
- package/extensions/direct-verification.ts +73 -0
- package/extensions/isolated.ts +25 -301
- package/extensions/prerequisite-evidence.ts +81 -0
- package/extensions/result-transport.ts +6 -4
- package/extensions/subagent-command.ts +12 -7
- package/extensions/subagent.ts +302 -495
- package/extensions/workflow-recovery.ts +359 -0
- package/extensions/workflow.ts +156 -40
- package/extensions/workspace.ts +16 -74
- package/package.json +2 -2
- 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.
|
|
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
|
|
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.
|
|
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`.
|
|
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
|
|
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.
|
|
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
25
|
Use the `scout`, `reviewer`, `implementer`, `planner`, or `oracle` role. Main can cancel an owned workflow with `mode: "cancel"` and its exact `id`.
|
|
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.
|
|
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": "
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
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
|
-
|
|
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.
|
package/dist/ephemeral.d.ts
CHANGED
|
@@ -35,12 +35,15 @@ 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;
|
|
40
42
|
prepare: () => Promise<{
|
|
41
43
|
launch: PiLaunch;
|
|
42
44
|
task: string;
|
|
43
45
|
cwd: string;
|
|
46
|
+
leaseFd?: number;
|
|
44
47
|
}>;
|
|
45
48
|
}
|
|
46
49
|
interface EphemeralSubagentResultBase {
|
|
@@ -68,13 +71,14 @@ export declare class EphemeralSubagentError extends Error {
|
|
|
68
71
|
export interface EphemeralSubagentExecutor {
|
|
69
72
|
run(input: EphemeralSubagentRunInput): Promise<EphemeralSubagentResult>;
|
|
70
73
|
}
|
|
74
|
+
export interface EphemeralExecutorPool extends EphemeralSubagentExecutor {
|
|
75
|
+
withLimits(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor;
|
|
76
|
+
}
|
|
71
77
|
/**
|
|
72
78
|
* Creates a bounded ephemeral executor for callers already running inside Pi.
|
|
73
79
|
* It reuses the active Pi process invocation; it does not resolve a standalone Pi installation.
|
|
74
80
|
*/
|
|
75
|
-
export declare function createEphemeralSubagentExecutor(options: EphemeralSubagentExecutorOptions):
|
|
76
|
-
withLimits(options: EphemeralSubagentExecutorOptions): EphemeralSubagentExecutor;
|
|
77
|
-
};
|
|
81
|
+
export declare function createEphemeralSubagentExecutor(options: EphemeralSubagentExecutorOptions): EphemeralExecutorPool;
|
|
78
82
|
/** Longest prefix of `text` within `maxBytes` UTF-8 bytes, never splitting a code point. */
|
|
79
83
|
export declare function utf8Prefix(text: string, maxBytes: number): string;
|
|
80
84
|
export declare function capEphemeralSubagentOutput(text: string): string;
|
package/dist/ephemeral.js
CHANGED
|
@@ -110,6 +110,9 @@ 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
|
}
|
|
@@ -148,7 +151,11 @@ function validatePrepared(value) {
|
|
|
148
151
|
}
|
|
149
152
|
env[name] = value;
|
|
150
153
|
}
|
|
154
|
+
const fd = prepared.leaseFd;
|
|
155
|
+
if (fd !== undefined && (typeof fd !== "number" || !Number.isSafeInteger(fd) || fd < 3))
|
|
156
|
+
throw new TypeError("Invalid native process lease descriptor.");
|
|
151
157
|
return {
|
|
158
|
+
...(typeof fd === "number" ? { leaseFd: fd } : {}),
|
|
152
159
|
launch: { args, env },
|
|
153
160
|
task: preparedText(prepared.task, "Prepared Subagent task"),
|
|
154
161
|
cwd: preparedText(prepared.cwd, "Prepared Subagent cwd"),
|
|
@@ -391,15 +398,35 @@ export function formatDuration(milliseconds) {
|
|
|
391
398
|
const minutes = Math.floor(seconds % 3_600 / 60);
|
|
392
399
|
return hours ? `${hours}h ${minutes}m` : minutes ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
|
|
393
400
|
}
|
|
401
|
+
class RetryableSpawnFailure extends Error {
|
|
402
|
+
}
|
|
403
|
+
function isTransientSpawnFailure(cause) {
|
|
404
|
+
return cause instanceof Error && cause.code === "EAGAIN";
|
|
405
|
+
}
|
|
394
406
|
async function runPi(prepared, input, budget, invocation) {
|
|
407
|
+
const startedAt = Date.now();
|
|
408
|
+
try {
|
|
409
|
+
return await runPiAttempt(prepared, input, budget, invocation, startedAt, input.retryReadOnlySpawn === true);
|
|
410
|
+
}
|
|
411
|
+
catch (cause) {
|
|
412
|
+
if (!(cause instanceof RetryableSpawnFailure))
|
|
413
|
+
throw cause;
|
|
414
|
+
return await runPiAttempt(prepared, input, budget, invocation, startedAt, false);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async function runPiAttempt(prepared, input, budget, invocation, startedAt, allowRetry) {
|
|
395
418
|
if (input.signal?.aborted) {
|
|
396
419
|
notifyNotStarted(input);
|
|
397
420
|
throw abortError(input.signal);
|
|
398
421
|
}
|
|
399
422
|
const timeoutPolicy = budget.timeout;
|
|
423
|
+
if (Date.now() >= startedAt + timeoutPolicy.idleMs) {
|
|
424
|
+
notifyNotStarted(input);
|
|
425
|
+
const message = `Subagent timed out after ${formatDuration(timeoutPolicy.idleMs)} without a recognized Pi event.`;
|
|
426
|
+
throw new EphemeralSubagentError("timeout", message, new Error(message));
|
|
427
|
+
}
|
|
400
428
|
return await new Promise((resolve, reject) => {
|
|
401
429
|
const args = [...invocation.args, "--mode", "json", "-p", ...prepared.launch.args, `Task: ${prepared.task}`];
|
|
402
|
-
const startedAt = Date.now();
|
|
403
430
|
const maxDeadline = timeoutPolicy.maxMs === null ? undefined : startedAt + timeoutPolicy.maxMs;
|
|
404
431
|
let child;
|
|
405
432
|
try {
|
|
@@ -417,13 +444,20 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
417
444
|
[EXECUTION_BUDGET_ENV]: JSON.stringify(executionBudget),
|
|
418
445
|
},
|
|
419
446
|
shell: false,
|
|
420
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
447
|
+
stdio: prepared.leaseFd === undefined ? ["ignore", "pipe", "pipe"] : ["ignore", "pipe", "pipe", prepared.leaseFd],
|
|
421
448
|
detached: process.platform !== "win32",
|
|
422
449
|
});
|
|
423
450
|
}
|
|
424
451
|
catch (cause) {
|
|
452
|
+
if (allowRetry && !input.signal?.aborted && Date.now() < startedAt + timeoutPolicy.idleMs && isTransientSpawnFailure(cause)) {
|
|
453
|
+
reject(new RetryableSpawnFailure());
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
425
456
|
notifyNotStarted(input);
|
|
426
|
-
|
|
457
|
+
if (input.signal?.aborted)
|
|
458
|
+
reject(abortError(input.signal));
|
|
459
|
+
else
|
|
460
|
+
reject(new EphemeralSubagentError("spawn", cause instanceof Error ? cause.message : String(cause), cause));
|
|
427
461
|
return;
|
|
428
462
|
}
|
|
429
463
|
child.stdout.setEncoding("utf8");
|
|
@@ -456,6 +490,7 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
456
490
|
let timedOutAfterMs;
|
|
457
491
|
let timeoutReason;
|
|
458
492
|
let childExited = false;
|
|
493
|
+
let childObserved = child.pid !== undefined;
|
|
459
494
|
let completedTokens = 0;
|
|
460
495
|
let currentTokens = 0;
|
|
461
496
|
let completedUsage;
|
|
@@ -480,6 +515,7 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
480
515
|
let onStderrEnd;
|
|
481
516
|
let onStdoutClose;
|
|
482
517
|
let onStderrClose;
|
|
518
|
+
let onChildSpawn;
|
|
483
519
|
let onChildError;
|
|
484
520
|
let onChildExit;
|
|
485
521
|
let onChildClose;
|
|
@@ -509,6 +545,8 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
509
545
|
child.stdout.off("close", onStdoutClose);
|
|
510
546
|
if (onStderrClose)
|
|
511
547
|
child.stderr.off("close", onStderrClose);
|
|
548
|
+
if (onChildSpawn)
|
|
549
|
+
child.off("spawn", onChildSpawn);
|
|
512
550
|
if (onChildError)
|
|
513
551
|
child.off("error", onChildError);
|
|
514
552
|
if (onChildExit)
|
|
@@ -521,6 +559,20 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
521
559
|
return;
|
|
522
560
|
settled = true;
|
|
523
561
|
clearLifecycle();
|
|
562
|
+
const notStarted = spawnError !== undefined && child.pid === undefined && !childExited && !childObserved;
|
|
563
|
+
if (notStarted && allowRetry && (code === null || code < 0) && !callbackFailure && !aborted && !input.signal?.aborted
|
|
564
|
+
&& timedOutAfterMs === undefined && !limit && !protocolError && Date.now() < deadline && isTransientSpawnFailure(spawnError)) {
|
|
565
|
+
reject(new RetryableSpawnFailure());
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (notStarted) {
|
|
569
|
+
try {
|
|
570
|
+
input.onProcessEnd?.("not-started");
|
|
571
|
+
}
|
|
572
|
+
catch (cause) {
|
|
573
|
+
callbackFailure = new EphemeralSubagentError("callback", "Subagent onProcessEnd callback failed.", cause);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
524
576
|
if (callbackFailure) {
|
|
525
577
|
reject(new EphemeralSubagentError("callback", callbackFailure.message, callbackFailure.cause, accumulatedUsage()));
|
|
526
578
|
}
|
|
@@ -797,6 +849,7 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
797
849
|
clearPostExitTimers();
|
|
798
850
|
};
|
|
799
851
|
onStdoutData = (data) => {
|
|
852
|
+
childObserved = true;
|
|
800
853
|
armPostExitIdleDeadline();
|
|
801
854
|
if (callbackFailure || protocolError || limit)
|
|
802
855
|
return;
|
|
@@ -850,6 +903,7 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
850
903
|
}
|
|
851
904
|
};
|
|
852
905
|
onStderrData = (data) => {
|
|
906
|
+
childObserved = true;
|
|
853
907
|
armPostExitIdleDeadline();
|
|
854
908
|
appendBounded(stderr, data);
|
|
855
909
|
};
|
|
@@ -901,16 +955,9 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
901
955
|
timeoutReason = reason;
|
|
902
956
|
stop();
|
|
903
957
|
}
|
|
958
|
+
onChildSpawn = () => { childObserved = true; };
|
|
904
959
|
onChildError = (error) => {
|
|
905
960
|
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
961
|
if (input.signal?.aborted)
|
|
915
962
|
aborted = true;
|
|
916
963
|
};
|
|
@@ -944,6 +991,7 @@ async function runPi(prepared, input, budget, invocation) {
|
|
|
944
991
|
await Promise.race([Promise.all(pendingCallbacks), callbackFailed]);
|
|
945
992
|
complete(code);
|
|
946
993
|
};
|
|
994
|
+
child.once("spawn", onChildSpawn);
|
|
947
995
|
child.once("error", onChildError);
|
|
948
996
|
child.once("exit", onChildExit);
|
|
949
997
|
child.once("close", onChildClose);
|
package/dist/herdr-runtime.js
CHANGED
|
@@ -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
|
|
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
|
|
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;
|
|
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 {};
|