pi-cowboy 0.22.2 → 0.23.2
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/README.md +16 -1
- package/dist/agents/agent-assets.d.ts +11 -2
- package/dist/agents/agent-cleanup.d.ts +6 -22
- package/dist/agents/agent-environment.d.ts +6 -0
- package/dist/agents/agent-host.d.ts +3 -3
- package/dist/agents/agent-manager.d.ts +5 -1
- package/dist/agents/batch.d.ts +2 -1
- package/dist/agents/cleanup-policy.d.ts +15 -16
- package/dist/agents/handover.d.ts +71 -0
- package/dist/agents/harness/claude/session-export.d.ts +7 -0
- package/dist/agents/harness/claude/staging.d.ts +9 -1
- package/dist/agents/harness/codex-session-schema.d.ts +90 -0
- package/dist/agents/harness/codex-session.d.ts +17 -0
- package/dist/agents/harness/opencode/session-export.d.ts +39 -0
- package/dist/agents/harness/pi-compatible.d.ts +3 -1
- package/dist/agents/harness/pi-session.d.ts +12 -0
- package/dist/agents/harness/pi-store.d.ts +8 -0
- package/dist/agents/harness/pi.d.ts +2 -0
- package/dist/agents/harness/pig-store.d.ts +7 -0
- package/dist/agents/harness/stop-keys.d.ts +2 -0
- package/dist/agents/harness.d.ts +53 -0
- package/dist/agents/run-state.d.ts +1 -0
- package/dist/agents/schemas/handover.schema.d.ts +8 -0
- package/dist/agents/subagent-session.d.ts +8 -1
- package/dist/agents/tool-cleanup.d.ts +16 -2
- package/dist/agents/tool-execution.d.ts +21 -2
- package/dist/agents/tool-handover.d.ts +28 -0
- package/dist/agents/tool-merge.d.ts +18 -2
- package/dist/agents/tool-renderer.d.ts +21 -0
- package/dist/agents/tool-result.d.ts +9 -2
- package/dist/agents/tool-steer.d.ts +17 -2
- package/dist/{chunk-F526OOT6.js → chunk-277WT5MT.js} +2 -2
- package/dist/chunk-J5TU3AFX.js +2 -0
- package/dist/chunk-M42XWVYW.js +45 -0
- package/dist/{chunk-WL3QYM2F.js → chunk-MZROKRT4.js} +2 -2
- package/dist/chunk-S4BS2R6G.js +26 -0
- package/dist/chunk-TFQCH2TO.js +14 -0
- package/dist/config/config-store.d.ts +1 -0
- package/dist/config/layered-config.d.ts +2 -3
- package/dist/cowboy-tools.d.ts +13 -0
- package/dist/dev-mode.d.ts +1 -0
- package/dist/index.js +18 -18
- package/dist/infrastructure/herdr/agent-exit.d.ts +12 -0
- package/dist/infrastructure/herdr/agents.d.ts +0 -1
- package/dist/infrastructure/herdr/index.d.ts +1 -1
- package/dist/{menu-worktree-command-SXLBWK4D.js → menu-worktree-command-THJ3VSWU.js} +2 -2
- package/dist/{menus-Q3TEDIPV.js → menus-KXKDXZRN.js} +3 -3
- package/dist/{model-picker-IIXU4GJP.js → model-picker-FMMQY4KI.js} +2 -2
- package/dist/models/model-precedence.d.ts +1 -0
- package/dist/models/model-request-types.d.ts +8 -2
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/predicates.d.ts +1 -0
- package/dist/registration.d.ts +3 -8
- package/dist/spawn/sandbox.d.ts +22 -0
- package/dist/subagent/result-artifacts.d.ts +1 -0
- package/dist/subagent/supervisor.d.ts +2 -0
- package/dist/types.d.ts +11 -0
- package/package.json +2 -2
- package/dist/chunk-254PTGN5.js +0 -2
- package/dist/chunk-CTBFJWEE.js +0 -10
- package/dist/chunk-KMXT7XW7.js +0 -15
- package/dist/chunk-PDV4AFO7.js +0 -24
- package/dist/infrastructure/herdr/agent-stopper.d.ts +0 -14
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ Once the work is merged, the orchestrator cleans up the agent's resources (or yo
|
|
|
120
120
|
|
|
121
121
|
<code>✓ Cleaned up agent b7g2nspx:</code><br>
|
|
122
122
|
<code>agent status: completed</code><br>
|
|
123
|
-
<code>
|
|
123
|
+
<code>panes: w1:p2 closed</code><br>
|
|
124
124
|
<code>worktree: removed ($HOME/.pi/agent/pi-cowboy/worktrees/cow-audit-perms-b7g2nspx)</code><br>
|
|
125
125
|
<code>branch: deleted (cow-audit-perms-b7g2nspx)</code>
|
|
126
126
|
|
|
@@ -221,6 +221,8 @@ Run `/cowboy` to open the interactive menu, or pass a subcommand directly. See [
|
|
|
221
221
|
|
|
222
222
|
## Tools
|
|
223
223
|
|
|
224
|
+
Every tool result is marked by how the call ended: `✓` success, `!` refused (nothing failed and nothing changed), `✗` failure. A batch shows the worst outcome among its items. A `cowboy_agent` run sent to the background or waiting in the queue is an acknowledgement and reads as a success; a foreground run (`run_in_background: false`) reads as a success when completed and as a refusal when stopped.
|
|
225
|
+
|
|
224
226
|
### `cowboy_agent`
|
|
225
227
|
|
|
226
228
|
Delegates one or more tasks to cowboy agents. By default, the call returns immediately with an agent ID for each task, and results arrive in the parent session as each agent settles.
|
|
@@ -251,6 +253,19 @@ Queued agents cannot be steered because they do not have a pane yet. Agents that
|
|
|
251
253
|
| `agent_ids[]` | yes | Agent IDs to send the message to. |
|
|
252
254
|
| `message` | yes | The message to deliver to each agent. |
|
|
253
255
|
|
|
256
|
+
### `handover_cowboy_agent`
|
|
257
|
+
|
|
258
|
+
Hands one settled agent over to another harness without starting over: the ended run is stopped, its session is exported by the source harness, the run is archived, and the next run launches in the same checkout with that session and its ID quoted in its task. Earlier panes and harness state remain until `cleanup_cowboy_agent`, which removes all runs.
|
|
259
|
+
|
|
260
|
+
A live agent is refused, never stopped — stop it with `stop_cowboy_agent` first. `harness_type` is required and never falls back to the configured default. The **source** harness must be able to export its own session; a harness that cannot is reported in the result, and nothing is stopped or changed.
|
|
261
|
+
|
|
262
|
+
| Parameter | Required | Description |
|
|
263
|
+
| -------------- | -------- | ----------------------------------------------------------- |
|
|
264
|
+
| `agent_id` | yes | The settled agent to hand over. |
|
|
265
|
+
| `harness_type` | yes | Harness that executes the next run. |
|
|
266
|
+
| `model` | no | Model for the next run, in the target harness's vocabulary. |
|
|
267
|
+
| `thinking` | no | Thinking level for the next run. |
|
|
268
|
+
|
|
254
269
|
### `stop_cowboy_agent`
|
|
255
270
|
|
|
256
271
|
Interrupts one or more running agents and marks them as stopped. Their worktrees, branches, and panes are preserved so you can inspect or clean them up afterward.
|
|
@@ -2,7 +2,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import type { AgentSpawn } from "../types.js";
|
|
3
3
|
import type { BranchCleanupResult, DeleteBranchOptions } from "../infrastructure/git-client.js";
|
|
4
4
|
import type { AgentMultiplexer, AgentHost, AgentHostRef, HostObservation, PlacementCatalog, PlacementRecord, PlacementWorktree } from "./agent-host.js";
|
|
5
|
-
import type { AnyHarnessId
|
|
5
|
+
import type { AnyHarnessId } from "./harness.js";
|
|
6
6
|
import type { CleanupSource, LocatedArtifacts, RecoveredDeliverable } from "./cleanup-policy.js";
|
|
7
7
|
export interface CleanupDeps {
|
|
8
8
|
isWorktreeDirty: (worktreePath: string) => Promise<boolean | undefined>;
|
|
@@ -11,7 +11,16 @@ export interface CleanupDeps {
|
|
|
11
11
|
removeGitWorktree: (worktreePath: string, repoCwd: string) => Promise<boolean>;
|
|
12
12
|
deleteBranch: (options: DeleteBranchOptions) => Promise<BranchCleanupResult>;
|
|
13
13
|
closePane: (ref: AgentHostRef) => Promise<void>;
|
|
14
|
-
|
|
14
|
+
teardownEnvironment: (request: EnvironmentTeardown) => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface RunTeardown {
|
|
17
|
+
readonly harness: AnyHarnessId;
|
|
18
|
+
readonly paneId: string | null;
|
|
19
|
+
readonly cwd: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface EnvironmentTeardown {
|
|
22
|
+
readonly subagentId: string;
|
|
23
|
+
readonly runs: readonly RunTeardown[];
|
|
15
24
|
}
|
|
16
25
|
export interface PaneRef {
|
|
17
26
|
readonly paneId: string;
|
|
@@ -2,7 +2,7 @@ import type { AgentSpawn, WorktreeRetentionReason } from "../types.js";
|
|
|
2
2
|
import type { BranchCleanupResult } from "../infrastructure/git-client.js";
|
|
3
3
|
import type { AgentHostRef } from "./agent-host.js";
|
|
4
4
|
import type { AgentAssets, CleanupDeps } from "./agent-assets.js";
|
|
5
|
-
import { type CleanupOptions, type CleanupReport, type
|
|
5
|
+
import { type CleanupOptions, type CleanupReport, type WorktreeRemovalMechanism, type WorktreeTarget } from "./cleanup-policy.js";
|
|
6
6
|
export type { CleanupDeps } from "./agent-assets.js";
|
|
7
7
|
export interface AgentCleanupRegistry {
|
|
8
8
|
getSpawn(id: string): AgentSpawn | undefined;
|
|
@@ -26,27 +26,11 @@ export type WorktreeTeardownOutcome = {
|
|
|
26
26
|
path: string;
|
|
27
27
|
detail: string;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
export type WorktreeRemovalTarget = {
|
|
36
|
-
kind: "adopted";
|
|
37
|
-
worktree: AdoptedWorktreeTarget;
|
|
38
|
-
pane: PaneTarget | null;
|
|
39
|
-
ref: AgentHostRef;
|
|
40
|
-
} | {
|
|
41
|
-
kind: "closing-pane";
|
|
42
|
-
worktree: WorktreeTarget;
|
|
43
|
-
pane: SelfCreatedPaneTarget;
|
|
44
|
-
ref: AgentHostRef;
|
|
45
|
-
} | {
|
|
46
|
-
kind: "detached";
|
|
47
|
-
worktree: WorktreeTarget;
|
|
48
|
-
pane: PaneTarget | null;
|
|
49
|
-
};
|
|
29
|
+
export interface WorktreeRemovalTarget {
|
|
30
|
+
readonly worktree: WorktreeTarget;
|
|
31
|
+
readonly address: AgentHostRef | undefined;
|
|
32
|
+
readonly panes: readonly AgentHostRef[];
|
|
33
|
+
}
|
|
50
34
|
interface WorktreeTeardown {
|
|
51
35
|
removeWorktree(target: WorktreeRemovalTarget, opts?: CleanupOptions): Promise<WorktreeTeardownOutcome>;
|
|
52
36
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentExecutionState, EndedRun } from "../types.js";
|
|
2
|
+
import type { AgentHostRef } from "./agent-host.js";
|
|
3
|
+
import type { AnyHarnessId } from "./harness.js";
|
|
4
|
+
export declare function placeExecution(execution: AgentExecutionState, host: AgentHostRef): void;
|
|
5
|
+
export declare function engageExecution(execution: AgentExecutionState, harness: AnyHarnessId): void;
|
|
6
|
+
export declare function endExecutionRun(execution: AgentExecutionState, run: EndedRun): void;
|
|
@@ -34,6 +34,7 @@ export interface AgentView {
|
|
|
34
34
|
export interface PaneControl {
|
|
35
35
|
readonly kind: string;
|
|
36
36
|
run(paneId: string, command: string): Promise<void>;
|
|
37
|
+
sendKeys(paneId: string, keys: readonly string[]): Promise<void>;
|
|
37
38
|
waitForOutput(paneId: string, output: string, timeoutMs: number): Promise<void>;
|
|
38
39
|
}
|
|
39
40
|
export interface HostObservation {
|
|
@@ -72,9 +73,8 @@ export interface AgentHost {
|
|
|
72
73
|
agentMultiplexerKind: AgentMultiplexerKind;
|
|
73
74
|
}): Promise<void>;
|
|
74
75
|
observe(ref: AgentHostRef): Promise<HostObservation | undefined>;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
confirmMs?: number;
|
|
76
|
+
waitUntilGone(ref: AgentHostRef, options?: {
|
|
77
|
+
timeoutMs?: number;
|
|
78
78
|
}): Promise<boolean>;
|
|
79
79
|
release(ref: AgentHostRef, scope: "placement" | "worktree-association"): Promise<boolean>;
|
|
80
80
|
isAttached(worktreePath: string, opts?: {
|
|
@@ -6,7 +6,8 @@ import type { SupervisorTransport } from "../subagent/pane-supervisor.js";
|
|
|
6
6
|
import type { ExecutionRuntime } from "./agent-host.js";
|
|
7
7
|
import { type LocateResult } from "./agent-assets.js";
|
|
8
8
|
import type { CleanupOptions, CleanupReport } from "./cleanup-policy.js";
|
|
9
|
-
import
|
|
9
|
+
import type { HandoverOutcome } from "./handover.js";
|
|
10
|
+
import { DISPOSE_QUEUED_MESSAGE, type SessionHandoverRequest, type SpawnOptions, type SteerOutcome } from "./subagent-session.js";
|
|
10
11
|
import type { SubagentType } from "./types.js";
|
|
11
12
|
export type { SpawnOptions, SteerOutcome } from "./subagent-session.js";
|
|
12
13
|
export declare function createAgentManagerTransport(runtime: ExecutionRuntime): SupervisorTransport;
|
|
@@ -18,6 +19,7 @@ export declare class AgentManager {
|
|
|
18
19
|
private onComplete?;
|
|
19
20
|
private onFollowUp?;
|
|
20
21
|
private readonly teardowns;
|
|
22
|
+
private readonly handovers;
|
|
21
23
|
private readonly pools;
|
|
22
24
|
private readonly registry;
|
|
23
25
|
constructor(pools: ConcurrencyPools, transport: SupervisorTransport);
|
|
@@ -29,6 +31,8 @@ export declare class AgentManager {
|
|
|
29
31
|
spawn(pi: ExtensionAPI, ctx: ExtensionContext, type: SubagentType, prompt: string, options: SpawnOptions): string;
|
|
30
32
|
private startSession;
|
|
31
33
|
steer(id: string, message: string): Promise<SteerOutcome>;
|
|
34
|
+
isHandingOver(id: string): boolean;
|
|
35
|
+
handover(id: string, request: SessionHandoverRequest): Promise<HandoverOutcome>;
|
|
32
36
|
getSpawn(id: string): AgentSpawn | undefined;
|
|
33
37
|
private assets;
|
|
34
38
|
locate(id: string): Promise<LocateResult>;
|
package/dist/agents/batch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ToolResult } from "./tool-result.js";
|
|
1
|
+
import { type ToolResult, type ToolSeverity } from "./tool-result.js";
|
|
2
2
|
export declare const BATCH_ITEM_SEPARATOR = "\n\n---\n\n";
|
|
3
3
|
export type BatchParam = "agent_ids" | "branches";
|
|
4
4
|
export interface BatchItem<TOutcome> {
|
|
@@ -23,6 +23,7 @@ export type BatchSpec<TOutcome, TKey extends string> = ItemHandler<TOutcome> & {
|
|
|
23
23
|
items: readonly string[];
|
|
24
24
|
detailsKey: TKey;
|
|
25
25
|
prepare?: () => void | Promise<void>;
|
|
26
|
+
severity: (outcome: TOutcome) => ToolSeverity;
|
|
26
27
|
};
|
|
27
28
|
export declare function runBatch<TOutcome, TKey extends string>(spec: BatchSpec<TOutcome, TKey>): Promise<ToolResult<Record<TKey, TOutcome[]>>>;
|
|
28
29
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActivePhase, AgentPhase, AgentSpawn, WorktreeRetentionReason } from "../types.js";
|
|
2
2
|
import type { BranchCleanupResult } from "../infrastructure/git-client.js";
|
|
3
|
-
import type { HostObservation } from "./agent-host.js";
|
|
3
|
+
import type { AgentHostRef, HostObservation } from "./agent-host.js";
|
|
4
4
|
type AgentActiveReason = {
|
|
5
5
|
kind: "agent-active";
|
|
6
6
|
phase: ActivePhase;
|
|
@@ -57,8 +57,6 @@ export type PaneOutcome = {
|
|
|
57
57
|
} | {
|
|
58
58
|
kind: "unknown";
|
|
59
59
|
paneId: string;
|
|
60
|
-
} | {
|
|
61
|
-
kind: "none";
|
|
62
60
|
};
|
|
63
61
|
export type WorktreeOutcome = {
|
|
64
62
|
kind: "removed";
|
|
@@ -92,7 +90,7 @@ export interface CleanupReport {
|
|
|
92
90
|
source: CleanupSource;
|
|
93
91
|
outcome: CleanupVerdictOutcome;
|
|
94
92
|
settlement: SettlementVerdict;
|
|
95
|
-
|
|
93
|
+
panes: readonly PaneOutcome[];
|
|
96
94
|
worktree: WorktreeOutcome;
|
|
97
95
|
branch: BranchCleanupResult;
|
|
98
96
|
branchName?: string;
|
|
@@ -118,10 +116,6 @@ export interface LocatedArtifacts {
|
|
|
118
116
|
worktree: LocatedWorktree | null;
|
|
119
117
|
pane: LocatedPane | null;
|
|
120
118
|
}
|
|
121
|
-
export interface PaneTarget {
|
|
122
|
-
paneId: string;
|
|
123
|
-
origin: "self-created" | "adopted";
|
|
124
|
-
}
|
|
125
119
|
export interface WorktreeTarget {
|
|
126
120
|
workspaceId?: string;
|
|
127
121
|
worktreePath: string;
|
|
@@ -131,17 +125,17 @@ export interface WorktreeTarget {
|
|
|
131
125
|
export type CleanupPlan = {
|
|
132
126
|
kind: "worktree";
|
|
133
127
|
worktree: WorktreeTarget;
|
|
134
|
-
|
|
128
|
+
panes: readonly AgentHostRef[];
|
|
135
129
|
} | {
|
|
136
130
|
kind: "worktree-unlocatable";
|
|
137
131
|
branchName: string;
|
|
138
132
|
worktreePath: string | null;
|
|
139
|
-
|
|
133
|
+
panes: readonly AgentHostRef[];
|
|
140
134
|
} | {
|
|
141
135
|
kind: "no-worktree";
|
|
142
|
-
|
|
136
|
+
panes: readonly AgentHostRef[];
|
|
143
137
|
};
|
|
144
|
-
export declare function planRecovered(artifacts: LocatedArtifacts): CleanupPlan;
|
|
138
|
+
export declare function planRecovered(artifacts: LocatedArtifacts, panes: readonly AgentHostRef[]): CleanupPlan;
|
|
145
139
|
export type GateOutcome = {
|
|
146
140
|
kind: "removable";
|
|
147
141
|
} | {
|
|
@@ -151,7 +145,7 @@ export type GateOutcome = {
|
|
|
151
145
|
type WorktreeDirtyProbe = (worktreePath: string) => Promise<boolean | undefined>;
|
|
152
146
|
export declare function assessRemovability(isDirty: WorktreeDirtyProbe, opts: CleanupOptions | undefined, worktree: WorktreeTarget): Promise<GateOutcome>;
|
|
153
147
|
export type RemovalOutcomes = {
|
|
154
|
-
|
|
148
|
+
panes: readonly PaneOutcome[];
|
|
155
149
|
worktree: WorktreeOutcome;
|
|
156
150
|
branch: BranchCleanupResult;
|
|
157
151
|
};
|
|
@@ -186,8 +180,6 @@ export declare function isForceableRefusal(report: CleanupReport): report is For
|
|
|
186
180
|
export declare function shouldDropSpawn(report: CleanupReport): boolean;
|
|
187
181
|
export type WorktreeRemovalMechanism = "multiplexer" | "git";
|
|
188
182
|
type PaneDisposition = {
|
|
189
|
-
kind: "none";
|
|
190
|
-
} | {
|
|
191
183
|
kind: "closed-with-workspace";
|
|
192
184
|
} | {
|
|
193
185
|
kind: "close";
|
|
@@ -195,5 +187,12 @@ type PaneDisposition = {
|
|
|
195
187
|
kind: "leave-open";
|
|
196
188
|
};
|
|
197
189
|
export declare function removalMechanismOf(worktree: WorktreeTarget): WorktreeRemovalMechanism;
|
|
198
|
-
export
|
|
190
|
+
export type PaneRemovalContext = {
|
|
191
|
+
readonly kind: "retained";
|
|
192
|
+
} | {
|
|
193
|
+
readonly kind: "removed";
|
|
194
|
+
readonly mechanism: WorktreeRemovalMechanism | null;
|
|
195
|
+
readonly workspaceId: string | undefined;
|
|
196
|
+
};
|
|
197
|
+
export declare function paneDispositionFor(pane: AgentHostRef, removal: PaneRemovalContext): PaneDisposition;
|
|
199
198
|
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { AgentStatus } from "../types.js";
|
|
2
|
+
import type { HarnessRegistry } from "./harness/harness-registry.js";
|
|
3
|
+
import type { ToolSeverity } from "./tool-result.js";
|
|
4
|
+
import { type AnyHarnessId, type HandoverRecordSource, type HarnessExport, type HarnessExportLoss, type HarnessExportRequest, type SessionExportFault } from "./harness.js";
|
|
5
|
+
export interface SessionExportPolicy {
|
|
6
|
+
readonly maxExcludedRatio: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_MAX_EXCLUDED_RATIO = 0.5;
|
|
9
|
+
export type HandoverFault = {
|
|
10
|
+
readonly kind: "agent-unknown";
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "agent-not-settled";
|
|
13
|
+
readonly status: AgentStatus;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "harness-cannot-export-session";
|
|
16
|
+
readonly harness: AnyHarnessId;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "never-started";
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "stop-failed";
|
|
21
|
+
readonly detail: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "session-empty";
|
|
24
|
+
readonly harness: AnyHarnessId;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "session-export-failed";
|
|
27
|
+
readonly harness: AnyHarnessId;
|
|
28
|
+
readonly detail: string;
|
|
29
|
+
readonly exportFault?: SessionExportFault;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "request-refused";
|
|
32
|
+
readonly detail: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "launch-failed";
|
|
35
|
+
readonly detail: string;
|
|
36
|
+
};
|
|
37
|
+
export type HandoverOutcome = {
|
|
38
|
+
readonly kind: "handed-over";
|
|
39
|
+
readonly from: AnyHarnessId;
|
|
40
|
+
readonly to: AnyHarnessId;
|
|
41
|
+
readonly loss?: HarnessExportLoss;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "faulted";
|
|
44
|
+
readonly fault: HandoverFault;
|
|
45
|
+
};
|
|
46
|
+
export declare function handoverSeverity(outcome: HandoverOutcome): ToolSeverity;
|
|
47
|
+
export type RunSession = {
|
|
48
|
+
readonly kind: "exported";
|
|
49
|
+
readonly sessionId: string;
|
|
50
|
+
readonly session: string;
|
|
51
|
+
readonly loss?: HarnessExportLoss;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "faulted";
|
|
54
|
+
readonly fault: HandoverFault;
|
|
55
|
+
};
|
|
56
|
+
export declare function completeHandoverExport(source: HandoverRecordSource): HarnessExport;
|
|
57
|
+
export declare function exportRunSession(harnesses: HarnessRegistry, from: AnyHarnessId, request: HarnessExportRequest, policy: SessionExportPolicy): Promise<RunSession>;
|
|
58
|
+
export interface HandoverSessionRef {
|
|
59
|
+
readonly harness: AnyHarnessId;
|
|
60
|
+
readonly sessionId: string;
|
|
61
|
+
}
|
|
62
|
+
export declare function renderHandoverMarker(chain: readonly HandoverSessionRef[]): string;
|
|
63
|
+
export declare function parseHandoverMarker(text: string): readonly HandoverSessionRef[] | undefined;
|
|
64
|
+
export interface HandoverTaskRequest {
|
|
65
|
+
readonly taskSlug: string | undefined;
|
|
66
|
+
readonly sourceName: string;
|
|
67
|
+
readonly previous: readonly HandoverSessionRef[];
|
|
68
|
+
readonly current: HandoverSessionRef;
|
|
69
|
+
readonly session: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function renderHandoverTask(request: HandoverTaskRequest): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type HandoverRecordSource } from "../../harness.js";
|
|
2
|
+
export interface ClaudeSessionExportRequest {
|
|
3
|
+
readonly configDir: string;
|
|
4
|
+
readonly cwd: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function readClaudeSessionRecords(request: ClaudeSessionExportRequest): HandoverRecordSource;
|
|
7
|
+
export declare function readClaudeSession(file: string, sessionId: string): HandoverRecordSource;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
export interface ClaudeStaging {
|
|
2
|
+
readonly configDir: string;
|
|
3
|
+
readonly sessionId: string;
|
|
4
|
+
}
|
|
1
5
|
export declare function claudeConfigDir(subagentId: string): string;
|
|
2
6
|
export declare function claudeSettingsFile(configDir: string): string;
|
|
7
|
+
export declare function claudeSessionRecordFile(configDir: string): string;
|
|
8
|
+
export declare function claudeProjectsDir(configDir: string): string;
|
|
9
|
+
export declare function claudeProjectsStore(): string;
|
|
10
|
+
export declare function claudeProjectDir(configDir: string, cwd: string): string;
|
|
3
11
|
export declare function writeClaudeStaging(input: {
|
|
4
12
|
subagentId: string;
|
|
5
13
|
cwd: string;
|
|
6
|
-
}):
|
|
14
|
+
}): ClaudeStaging;
|
|
7
15
|
export declare function removeClaudeStaging(subagentId: string): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const SessionMetaSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"session_meta">;
|
|
4
|
+
payload: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
cwd: z.ZodString;
|
|
7
|
+
thread_source: z.ZodOptional<z.ZodUnknown>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const RolloutLineSchema: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"response_item">;
|
|
12
|
+
payload: z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"message">;
|
|
14
|
+
role: z.ZodEnum<{
|
|
15
|
+
user: "user";
|
|
16
|
+
assistant: "assistant";
|
|
17
|
+
}>;
|
|
18
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<{
|
|
20
|
+
input_text: "input_text";
|
|
21
|
+
output_text: "output_text";
|
|
22
|
+
}>;
|
|
23
|
+
text: z.ZodString;
|
|
24
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
25
|
+
kind: "prose";
|
|
26
|
+
type: "input_text" | "output_text";
|
|
27
|
+
text: string;
|
|
28
|
+
}, {
|
|
29
|
+
type: "input_text" | "output_text";
|
|
30
|
+
text: string;
|
|
31
|
+
}>>, z.ZodPipe<z.ZodObject<{
|
|
32
|
+
type: z.ZodString;
|
|
33
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
34
|
+
kind: "attachment";
|
|
35
|
+
}, {
|
|
36
|
+
type: string;
|
|
37
|
+
}>>]>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
40
|
+
kind: "turn";
|
|
41
|
+
role: "user" | "assistant";
|
|
42
|
+
parts: ({
|
|
43
|
+
kind: "prose";
|
|
44
|
+
type: "input_text" | "output_text";
|
|
45
|
+
text: string;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "attachment";
|
|
48
|
+
})[];
|
|
49
|
+
}, {
|
|
50
|
+
type: "response_item";
|
|
51
|
+
payload: {
|
|
52
|
+
type: "message";
|
|
53
|
+
role: "user" | "assistant";
|
|
54
|
+
content: ({
|
|
55
|
+
kind: "prose";
|
|
56
|
+
type: "input_text" | "output_text";
|
|
57
|
+
text: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "attachment";
|
|
60
|
+
})[];
|
|
61
|
+
};
|
|
62
|
+
}>>, z.ZodPipe<z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"response_item">;
|
|
64
|
+
payload: z.ZodUnion<readonly [z.ZodObject<{
|
|
65
|
+
type: z.ZodLiteral<"message">;
|
|
66
|
+
role: z.ZodString;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
+
type: z.ZodString;
|
|
69
|
+
}, z.core.$strip>]>;
|
|
70
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
71
|
+
kind: "traffic";
|
|
72
|
+
}, {
|
|
73
|
+
type: "response_item";
|
|
74
|
+
payload: {
|
|
75
|
+
type: "message";
|
|
76
|
+
role: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
}>>, z.ZodPipe<z.ZodObject<{
|
|
81
|
+
type: z.ZodString;
|
|
82
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
83
|
+
kind: "traffic";
|
|
84
|
+
}, {
|
|
85
|
+
type: string;
|
|
86
|
+
}>>]>;
|
|
87
|
+
export type RolloutRecord = z.infer<typeof RolloutLineSchema>;
|
|
88
|
+
export type Turn = Extract<RolloutRecord, {
|
|
89
|
+
kind: "turn";
|
|
90
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type HandoverRecord } from "../harness.js";
|
|
2
|
+
export interface CodexSessionRecord {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CodexSessionExportRequest {
|
|
7
|
+
readonly cwd: string;
|
|
8
|
+
readonly codexHome: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CodexSessionExport extends CodexSessionRecord {
|
|
11
|
+
readonly records: readonly HandoverRecord[];
|
|
12
|
+
}
|
|
13
|
+
export declare const CODEX_HOME_ENV_VAR = "CODEX_HOME";
|
|
14
|
+
export declare function codexHomeDirectory(): string;
|
|
15
|
+
export declare function findCodexSession(request: CodexSessionExportRequest): CodexSessionRecord;
|
|
16
|
+
export declare function exportCodexSession(request: CodexSessionExportRequest): CodexSessionExport;
|
|
17
|
+
export declare function readCodexSession(file: string): readonly HandoverRecord[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { type HandoverRecord, type HandoverRecordSource } from "../../harness.js";
|
|
4
|
+
declare const OpencodeSessionSummarySchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
7
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
providerID: z.ZodString;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
time: z.ZodObject<{
|
|
12
|
+
updated: z.ZodNumber;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
location: z.ZodObject<{
|
|
15
|
+
directory: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type OpencodeSessionSummary = z.infer<typeof OpencodeSessionSummarySchema>;
|
|
19
|
+
export interface OpencodeSessionExport {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
readonly messages: readonly unknown[];
|
|
22
|
+
}
|
|
23
|
+
export interface OpencodeSessionExportRequest {
|
|
24
|
+
readonly pi: ExtensionAPI;
|
|
25
|
+
readonly subagentId: string;
|
|
26
|
+
readonly cwd: string;
|
|
27
|
+
readonly proofModel: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function opencodeSessionListPath(cwd: string): string;
|
|
30
|
+
export declare function parseOpencodeSessionList(stdout: string): readonly OpencodeSessionSummary[] | undefined;
|
|
31
|
+
export declare function selectOpencodeRunSession(sessions: readonly OpencodeSessionSummary[], input: {
|
|
32
|
+
readonly cwd: string;
|
|
33
|
+
readonly subagentId: string;
|
|
34
|
+
readonly proofModel: string;
|
|
35
|
+
}): OpencodeSessionSummary | undefined;
|
|
36
|
+
export declare function parseOpencodeSessionExport(stdout: string): OpencodeSessionExport | undefined;
|
|
37
|
+
export declare function classifyOpencodeMessages(messages: readonly unknown[]): readonly HandoverRecord[];
|
|
38
|
+
export declare function readOpencodeSessionRecords(request: OpencodeSessionExportRequest): Promise<HandoverRecordSource>;
|
|
39
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Harness, type HarnessListModels, type PiFamilyLaunchRequest } from "../harness.js";
|
|
2
|
+
import { type SessionStore } from "./pi-session.js";
|
|
2
3
|
export declare function buildPiLaunchArgs(request: PiFamilyLaunchRequest): string[];
|
|
3
4
|
export declare const piFamilyListModels: HarnessListModels;
|
|
4
5
|
export interface PiCompatibleSpec {
|
|
5
6
|
readonly binary: string;
|
|
6
7
|
readonly signature: string;
|
|
7
8
|
readonly readyMarker: string;
|
|
9
|
+
readonly store: SessionStore;
|
|
8
10
|
}
|
|
9
11
|
export declare function createPiCompatibleHarness(spec: PiCompatibleSpec): Harness<PiFamilyLaunchRequest>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type HandoverRecordSource, type ReadHandoverRecords } from "../harness.js";
|
|
2
|
+
export type SessionStoreEnv = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
export interface SessionStore {
|
|
4
|
+
readonly reservedNames: readonly string[];
|
|
5
|
+
sessionDir(cwd: string, env: SessionStoreEnv): Promise<string>;
|
|
6
|
+
inheritedEnv(env: SessionStoreEnv): Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function sessionBucketName(cwd: string): string;
|
|
9
|
+
export declare function readSessionDirSetting(configDir: string): Promise<string | undefined>;
|
|
10
|
+
export declare function findSessionFile(sessionDir: string, subagentId: string, cwd: string): Promise<string>;
|
|
11
|
+
export declare function readSessionFile(filePath: string): Promise<HandoverRecordSource>;
|
|
12
|
+
export declare function readHandoverRecordsOf(store: SessionStore): ReadHandoverRecords;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SessionStore, type SessionStoreEnv } from "./pi-session.js";
|
|
2
|
+
export declare const PI_SESSION_DIR_ENV_VAR = "PI_CODING_AGENT_SESSION_DIR";
|
|
3
|
+
export declare const PI_AGENT_DIR_ENV_VAR = "PI_CODING_AGENT_DIR";
|
|
4
|
+
export declare const PI_STORE_ENV_VARS: readonly string[];
|
|
5
|
+
export declare function piAgentDirectory(env: SessionStoreEnv): string;
|
|
6
|
+
export declare function resolvePiSessionDir(cwd: string, env?: SessionStoreEnv): Promise<string>;
|
|
7
|
+
export declare function inheritedPiStoreEnv(env?: SessionStoreEnv): Record<string, string>;
|
|
8
|
+
export declare const piStore: SessionStore;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SessionStore, type SessionStoreEnv } from "./pi-session.js";
|
|
2
|
+
export declare function pigUsesPiDirectories(env: SessionStoreEnv): boolean;
|
|
3
|
+
export declare function pigConfigurationRoot(env: SessionStoreEnv): string;
|
|
4
|
+
export declare function pigAgentDirectory(env: SessionStoreEnv): string;
|
|
5
|
+
export declare function resolvePigSessionDir(cwd: string, env?: SessionStoreEnv): Promise<string>;
|
|
6
|
+
export declare function inheritedPigStoreEnv(env?: SessionStoreEnv): Record<string, string>;
|
|
7
|
+
export declare const pigStore: SessionStore;
|
package/dist/agents/harness.d.ts
CHANGED
|
@@ -100,6 +100,12 @@ export interface HarnessPrepareRequest<L extends SubagentLaunchInputs = HarnessL
|
|
|
100
100
|
readonly cwd: string;
|
|
101
101
|
readonly launch: L;
|
|
102
102
|
}
|
|
103
|
+
export interface HarnessStopRequest {
|
|
104
|
+
readonly pi: ExtensionAPI;
|
|
105
|
+
readonly pane: PaneControl;
|
|
106
|
+
readonly paneId: string;
|
|
107
|
+
}
|
|
108
|
+
export type HarnessStop = (request: HarnessStopRequest) => Promise<void>;
|
|
103
109
|
export interface HarnessTeardownContext {
|
|
104
110
|
readonly paneId: string | null;
|
|
105
111
|
readonly cwd: string | null;
|
|
@@ -108,6 +114,45 @@ export interface HarnessTeardownContext {
|
|
|
108
114
|
export interface HarnessTeardownRequest extends HarnessTeardownContext {
|
|
109
115
|
readonly pi: ExtensionAPI;
|
|
110
116
|
}
|
|
117
|
+
export interface HarnessExportRequest {
|
|
118
|
+
readonly pi: ExtensionAPI;
|
|
119
|
+
readonly subagentId: string;
|
|
120
|
+
readonly paneId: string;
|
|
121
|
+
readonly cwd: string;
|
|
122
|
+
}
|
|
123
|
+
export type HandoverRecord = {
|
|
124
|
+
readonly kind: "export";
|
|
125
|
+
readonly turn: SessionExportTurn;
|
|
126
|
+
} | {
|
|
127
|
+
readonly kind: "dont-export";
|
|
128
|
+
readonly content: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly kind: "unparseable";
|
|
131
|
+
readonly content: string;
|
|
132
|
+
};
|
|
133
|
+
export interface HandoverRecordSource {
|
|
134
|
+
readonly sessionId: string;
|
|
135
|
+
readonly records: readonly HandoverRecord[];
|
|
136
|
+
}
|
|
137
|
+
export interface HarnessExportLoss {
|
|
138
|
+
readonly excluded: number;
|
|
139
|
+
readonly total: number;
|
|
140
|
+
}
|
|
141
|
+
export interface HarnessExport {
|
|
142
|
+
readonly sessionId: string;
|
|
143
|
+
readonly session: string;
|
|
144
|
+
readonly loss?: HarnessExportLoss;
|
|
145
|
+
}
|
|
146
|
+
export type ReadHandoverRecords = (request: HarnessExportRequest) => Promise<HandoverRecordSource>;
|
|
147
|
+
export type SessionExportFault = "session-not-found" | "ambiguous-session" | "unreadable-record" | "malformed-record" | "unsupported-version" | "missing-session-id" | "export-command-failed";
|
|
148
|
+
export declare class SessionExportError extends Error {
|
|
149
|
+
readonly fault: SessionExportFault;
|
|
150
|
+
constructor(fault: SessionExportFault, message: string);
|
|
151
|
+
}
|
|
152
|
+
export interface SessionExportTurn {
|
|
153
|
+
readonly role: "User" | "Assistant";
|
|
154
|
+
readonly text: string;
|
|
155
|
+
}
|
|
111
156
|
export type ThinkingLevels = {
|
|
112
157
|
readonly kind: "closed";
|
|
113
158
|
readonly levels: readonly string[];
|
|
@@ -154,14 +199,22 @@ export type HarnessAvailability = {
|
|
|
154
199
|
export interface Harness<L extends SubagentLaunchInputs = HarnessLaunch, C = unknown> {
|
|
155
200
|
readonly config?: HarnessConfigCodec<C>;
|
|
156
201
|
readonly reservedEnvVars?: () => readonly string[];
|
|
202
|
+
readonly inheritedEnv?: () => Readonly<Record<string, string>>;
|
|
157
203
|
readonly agentMultiplexerKind: AgentMultiplexerKind;
|
|
158
204
|
availability(): HarnessAvailability;
|
|
159
205
|
prepare(request: HarnessPrepareRequest<L, C>): Promise<void>;
|
|
206
|
+
stop: HarnessStop;
|
|
160
207
|
buildArgs(launch: L): string[];
|
|
161
208
|
teardown(request: HarnessTeardownRequest): Promise<void>;
|
|
209
|
+
readHandoverRecords?: ReadHandoverRecords;
|
|
162
210
|
listModels(request: HarnessListModelsRequest): Promise<ModelList>;
|
|
163
211
|
prefetchModels(pi: ExtensionAPI): void;
|
|
164
212
|
}
|
|
213
|
+
export declare function canReadHandoverRecords(harness: {
|
|
214
|
+
readonly readHandoverRecords?: ReadHandoverRecords;
|
|
215
|
+
}): harness is {
|
|
216
|
+
readonly readHandoverRecords: ReadHandoverRecords;
|
|
217
|
+
};
|
|
165
218
|
export interface PluginLaunchRequest extends SubagentLaunchInputs {
|
|
166
219
|
readonly family: "plugin";
|
|
167
220
|
}
|
|
@@ -68,6 +68,7 @@ export declare function abortQueuedRun(state: RunState, initiator: StopInitiator
|
|
|
68
68
|
export declare function failStart(state: RunState, error: string, completedAt: number): RunState;
|
|
69
69
|
export declare function enterSettling(state: RunState, terminal: RunTerminal, completedAt: number): RunState;
|
|
70
70
|
export declare function finishSettling(state: RunState): RunState;
|
|
71
|
+
export declare function handoverRun(state: RunState, startedAt: number): RunState;
|
|
71
72
|
export declare function reviveRun(state: RunState, startedAt: number): RunState;
|
|
72
73
|
export declare function disposeQueuedRun(state: RunState, completedAt: number): RunState;
|
|
73
74
|
export declare function disposeLiveRun(state: RunState): RunState;
|