@hcflabs/pi-subagent 0.0.0-stage → 27.10.7
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 +77 -0
- package/LICENSE +22 -0
- package/README.md +282 -2
- package/dist/composition.d.ts +11 -0
- package/dist/composition.js +104 -0
- package/dist/direct-herdr.d.ts +71 -0
- package/dist/direct-herdr.js +527 -0
- package/dist/discard.d.ts +51 -0
- package/dist/discard.js +218 -0
- package/dist/display-text.d.ts +5 -0
- package/dist/display-text.js +9 -0
- package/dist/ephemeral.d.ts +79 -0
- package/dist/ephemeral.js +916 -0
- package/dist/git-process.d.ts +8 -0
- package/dist/git-process.js +25 -0
- package/dist/git-runtime.d.ts +115 -0
- package/dist/git-runtime.js +489 -0
- package/dist/herdr-runtime.d.ts +147 -0
- package/dist/herdr-runtime.js +1366 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.js +587 -0
- package/dist/integration-git.d.ts +63 -0
- package/dist/integration-git.js +504 -0
- package/dist/launch-runtime.d.ts +54 -0
- package/dist/launch-runtime.js +178 -0
- package/dist/mcp-role.d.ts +12 -0
- package/dist/mcp-role.js +152 -0
- package/dist/process-lease.d.ts +5 -0
- package/dist/process-lease.js +43 -0
- package/dist/process.d.ts +9 -0
- package/dist/process.js +11 -0
- package/dist/prune.d.ts +78 -0
- package/dist/prune.js +205 -0
- package/dist/review-evidence.d.ts +17 -0
- package/dist/review-evidence.js +221 -0
- package/dist/runner.d.ts +431 -0
- package/dist/runner.js +3380 -0
- package/dist/schema.d.ts +2560 -0
- package/dist/schema.js +1365 -0
- package/dist/store.d.ts +66 -0
- package/dist/store.js +394 -0
- package/dist/worktree.d.ts +65 -0
- package/dist/worktree.js +288 -0
- package/docs/orchestration-architecture.html +138 -0
- package/docs/orchestration-architecture.svg +135 -0
- package/docs/orchestration.md +577 -0
- package/docs/worker-lifecycle.html +97 -0
- package/docs/worker-lifecycle.svg +86 -0
- package/example.png +0 -0
- package/examples/roles/implementer.md +25 -0
- package/examples/roles/reviewer.md +25 -0
- package/examples/roles/scout.md +25 -0
- package/extensions/admission.ts +82 -0
- package/extensions/config.ts +19 -0
- package/extensions/git-read.ts +126 -0
- package/extensions/isolated.ts +945 -0
- package/extensions/model-class-policy.ts +1 -0
- package/extensions/result-transport.ts +236 -0
- package/extensions/role-mcp.ts +14 -0
- package/extensions/role-tools.ts +178 -0
- package/extensions/subagent-command.ts +699 -0
- package/extensions/subagent.ts +958 -0
- package/extensions/workflow.ts +336 -0
- package/package.json +84 -4
- package/prompts/review.md +20 -0
- package/skills/pi-subagent/SKILL.md +41 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type ExecuteRequest, type HostAllocationIntent, type HostAllocationPlan, type TaskAttempt, type TaskRequest, type WorkspaceIdentity } from "./schema.ts";
|
|
2
|
+
import { type AllocationReconciliation, type HostAllocationKind, type HostAllocationResult, type HostCleanupKind, type HostRuntime, type InFlightTaskCandidateInspector, type OperationContext, type TextTaskContext, type TransientLaunchHandle, type VerifiedLaunch, type WorkerResult } from "./runner.ts";
|
|
3
|
+
import { type EphemeralSubagentExecutionBudget } from "./ephemeral.ts";
|
|
4
|
+
export interface HostProcessOptions {
|
|
5
|
+
cwd: string;
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
timeoutMs: number;
|
|
8
|
+
}
|
|
9
|
+
export type HostProcessRunner = (command: string, args: string[], options: HostProcessOptions) => Promise<{
|
|
10
|
+
code: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
killed?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export interface HerdrHostRuntimeOptions {
|
|
16
|
+
inspectInFlightTaskCandidate: InFlightTaskCandidateInspector["inspectInFlightTaskCandidate"];
|
|
17
|
+
runProcess?: HostProcessRunner;
|
|
18
|
+
killProcess?: (pid: number, signal: NodeJS.Signals) => void;
|
|
19
|
+
delay?: (milliseconds: number, signal: AbortSignal) => Promise<void>;
|
|
20
|
+
now?: () => number;
|
|
21
|
+
randomId?: () => string;
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
leaseDirectory?: string;
|
|
24
|
+
lsofCommand?: string;
|
|
25
|
+
executionBudget?: () => Omit<EphemeralSubagentExecutionBudget, "startedAt">;
|
|
26
|
+
}
|
|
27
|
+
export declare function workspaceLabel(attempt: TaskAttempt): string;
|
|
28
|
+
export declare class HerdrHostRuntime implements HostRuntime {
|
|
29
|
+
private readonly inspectInFlightCandidate;
|
|
30
|
+
private readonly execute;
|
|
31
|
+
private readonly herdr;
|
|
32
|
+
private readonly kill;
|
|
33
|
+
private readonly delay;
|
|
34
|
+
private readonly now;
|
|
35
|
+
private readonly randomId;
|
|
36
|
+
private readonly env;
|
|
37
|
+
private readonly leaseDirectory;
|
|
38
|
+
private readonly lsofCommand;
|
|
39
|
+
private readonly executionBudget?;
|
|
40
|
+
constructor(options: HerdrHostRuntimeOptions);
|
|
41
|
+
/** Fail-closed Herdr caller/capability gate. This method creates no state or host resource. */
|
|
42
|
+
preflightHost(input: {
|
|
43
|
+
root: string;
|
|
44
|
+
}, context: OperationContext): Promise<void>;
|
|
45
|
+
planHostAllocation(input: {
|
|
46
|
+
readonly requestId: ExecuteRequest["id"];
|
|
47
|
+
readonly goal: ExecuteRequest["goal"];
|
|
48
|
+
kind: HostAllocationKind;
|
|
49
|
+
task: TaskRequest;
|
|
50
|
+
attempt: TaskAttempt;
|
|
51
|
+
}, context: OperationContext): Promise<HostAllocationPlan>;
|
|
52
|
+
allocateHost(input: {
|
|
53
|
+
requestId: ExecuteRequest["id"];
|
|
54
|
+
intent: HostAllocationIntent;
|
|
55
|
+
task: TaskRequest;
|
|
56
|
+
attempt: TaskAttempt;
|
|
57
|
+
acquireLaunch?: () => Promise<TransientLaunchHandle<VerifiedLaunch>>;
|
|
58
|
+
}, context: OperationContext): Promise<HostAllocationResult>;
|
|
59
|
+
reconcileHostAllocation(input: {
|
|
60
|
+
requestId: ExecuteRequest["id"];
|
|
61
|
+
intent: HostAllocationIntent;
|
|
62
|
+
task: TaskRequest;
|
|
63
|
+
attempt: TaskAttempt;
|
|
64
|
+
}, context: OperationContext): Promise<AllocationReconciliation<HostAllocationKind>>;
|
|
65
|
+
runWorker(input: {
|
|
66
|
+
readonly goal: ExecuteRequest["goal"];
|
|
67
|
+
readonly contexts: readonly TextTaskContext[];
|
|
68
|
+
task: TaskRequest;
|
|
69
|
+
attempt: TaskAttempt;
|
|
70
|
+
workerId: string;
|
|
71
|
+
kind: "initial" | "correction" | "followup";
|
|
72
|
+
preCandidate: WorkspaceIdentity;
|
|
73
|
+
failure?: string;
|
|
74
|
+
instruction?: string;
|
|
75
|
+
}, context: OperationContext): Promise<WorkerResult>;
|
|
76
|
+
terminateWorker(input: {
|
|
77
|
+
task: TaskRequest;
|
|
78
|
+
attempt: TaskAttempt;
|
|
79
|
+
workerId: string;
|
|
80
|
+
candidate: WorkspaceIdentity;
|
|
81
|
+
}, context: OperationContext): Promise<{
|
|
82
|
+
outcome: "terminated";
|
|
83
|
+
} | {
|
|
84
|
+
outcome: "unknown";
|
|
85
|
+
failure: string;
|
|
86
|
+
}>;
|
|
87
|
+
reconcileWorkerTermination(input: {
|
|
88
|
+
task: TaskRequest;
|
|
89
|
+
attempt: TaskAttempt;
|
|
90
|
+
workerId: string;
|
|
91
|
+
candidate: WorkspaceIdentity;
|
|
92
|
+
}, context: OperationContext): Promise<{
|
|
93
|
+
outcome: "terminated" | "active";
|
|
94
|
+
} | {
|
|
95
|
+
outcome: "unknown";
|
|
96
|
+
failure: string;
|
|
97
|
+
}>;
|
|
98
|
+
private proveAbsentAgentForCleanup;
|
|
99
|
+
cleanupHost(input: {
|
|
100
|
+
requestId: ExecuteRequest["id"];
|
|
101
|
+
kind: HostCleanupKind;
|
|
102
|
+
task: TaskRequest;
|
|
103
|
+
attempt: TaskAttempt;
|
|
104
|
+
}, context: OperationContext): Promise<{
|
|
105
|
+
outcome: "completed" | "absent";
|
|
106
|
+
} | {
|
|
107
|
+
outcome: "blocked";
|
|
108
|
+
failure: string;
|
|
109
|
+
}>;
|
|
110
|
+
private allocateWorkspace;
|
|
111
|
+
private allocateWorkerTab;
|
|
112
|
+
private allocateAgent;
|
|
113
|
+
private reconcileDeliveredPrompt;
|
|
114
|
+
private candidateResult;
|
|
115
|
+
private isExpectedCandidate;
|
|
116
|
+
private waitForSettledAgent;
|
|
117
|
+
private waitForAgentLifecycle;
|
|
118
|
+
private diagnostic;
|
|
119
|
+
private assertStartableAgentPane;
|
|
120
|
+
private createPrivateLease;
|
|
121
|
+
private removeLeaseArtifacts;
|
|
122
|
+
private assertPrivateLeaseDirectories;
|
|
123
|
+
private workerSessionFile;
|
|
124
|
+
private sessionFileExists;
|
|
125
|
+
private privateSessionFile;
|
|
126
|
+
private workerTurnFinished;
|
|
127
|
+
private removeWorkerSessionFile;
|
|
128
|
+
private assertLeasePath;
|
|
129
|
+
private scanLease;
|
|
130
|
+
private signalExactHolders;
|
|
131
|
+
private listTabs;
|
|
132
|
+
private listAgents;
|
|
133
|
+
private listPanes;
|
|
134
|
+
private waitForStableWorkspacePanes;
|
|
135
|
+
private getTab;
|
|
136
|
+
private paneAbsent;
|
|
137
|
+
private workspaceAbsent;
|
|
138
|
+
private assertWorkspaceEvidence;
|
|
139
|
+
private repositoryIdentity;
|
|
140
|
+
private assertRepositoryIdentity;
|
|
141
|
+
/** Herdr and lsof queries are global, so a checkout removed outside Pi Subagent must not be their process cwd. */
|
|
142
|
+
private queryCwd;
|
|
143
|
+
private processOptions;
|
|
144
|
+
private childContext;
|
|
145
|
+
private callTimeout;
|
|
146
|
+
private contextInterrupted;
|
|
147
|
+
}
|