pi-cowboy 0.22.2 → 0.27.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/README.md +19 -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 +7 -1
- package/dist/agents/batch.d.ts +2 -1
- package/dist/agents/cleanup-policy.d.ts +15 -16
- package/dist/agents/handover-export.d.ts +32 -0
- package/dist/agents/handover-file.d.ts +14 -0
- package/dist/agents/handover-target.d.ts +16 -0
- package/dist/agents/handover.d.ts +73 -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 +103 -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 +56 -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 +13 -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-67VN34QV.js} +2 -2
- package/dist/chunk-CAWIXE4E.js +14 -0
- package/dist/chunk-GYO352IF.js +47 -0
- package/dist/chunk-NF2BSEPU.js +26 -0
- package/dist/{chunk-WL3QYM2F.js → chunk-ROCBRG4A.js} +2 -2
- package/dist/chunk-XXNZAWMK.js +2 -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/host-multiplexer.d.ts +1 -1
- package/dist/index.js +17 -17
- 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-FGIFMYRD.js} +2 -2
- package/dist/menus-QMEWZXAL.js +9 -0
- package/dist/{model-picker-IIXU4GJP.js → model-picker-I2L5LYS7.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 +32 -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/dist/ui/action-report.d.ts +1 -0
- package/dist/ui/menu/menu-agent-handover.d.ts +12 -0
- package/dist/ui/menu/menu-agent-status.d.ts +1 -1
- package/package.json +3 -3
- 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/dist/menus-Q3TEDIPV.js +0 -9
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
**✨ NEW FEATURE - Cross-harness handover: pi-cowboy can now handover sessions between harnesses automatically. Ask pi to hand over a cowboy agent from one harness to another, or [use the menu](docs/Menu.md#handing-over-and-exporting).**
|
|
1
2
|
<p align="center">
|
|
2
3
|
<img src="https://raw.githubusercontent.com/electric-dragon-80000v/pi-cowboy/main/docs/assets/logo-labeled-readme.png" alt="pi-cowboy">
|
|
3
4
|
</p>
|
|
@@ -8,6 +9,8 @@
|
|
|
8
9
|
|
|
9
10
|
**License:** MIT
|
|
10
11
|
|
|
12
|
+
|
|
13
|
+
`
|
|
11
14
|
`pi-cowboy` is a multi-agent orchestrator for [pi](https://pi.dev). Break a large job into focused subtasks, hand them off to background agents running in parallel, and consolidate them when they finish.
|
|
12
15
|
|
|
13
16
|
Each agent runs in its own terminal pane inside [Herdr](https://github.com/electric-dragon-80000v/herdr) and works in an isolated copy-on-write Git worktree. You can watch agents work in real time, jump into any pane to steer them, or mix and match harnesses like Pi, Claude Code, OpenCode, and Codex in the same session. When the work is finished, `pi-cowboy` cleans up the leftovers for you.
|
|
@@ -120,7 +123,7 @@ Once the work is merged, the orchestrator cleans up the agent's resources (or yo
|
|
|
120
123
|
|
|
121
124
|
<code>✓ Cleaned up agent b7g2nspx:</code><br>
|
|
122
125
|
<code>agent status: completed</code><br>
|
|
123
|
-
<code>
|
|
126
|
+
<code>panes: w1:p2 closed</code><br>
|
|
124
127
|
<code>worktree: removed ($HOME/.pi/agent/pi-cowboy/worktrees/cow-audit-perms-b7g2nspx)</code><br>
|
|
125
128
|
<code>branch: deleted (cow-audit-perms-b7g2nspx)</code>
|
|
126
129
|
|
|
@@ -221,6 +224,8 @@ Run `/cowboy` to open the interactive menu, or pass a subcommand directly. See [
|
|
|
221
224
|
|
|
222
225
|
## Tools
|
|
223
226
|
|
|
227
|
+
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.
|
|
228
|
+
|
|
224
229
|
### `cowboy_agent`
|
|
225
230
|
|
|
226
231
|
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 +256,19 @@ Queued agents cannot be steered because they do not have a pane yet. Agents that
|
|
|
251
256
|
| `agent_ids[]` | yes | Agent IDs to send the message to. |
|
|
252
257
|
| `message` | yes | The message to deliver to each agent. |
|
|
253
258
|
|
|
259
|
+
### `handover_cowboy_agent`
|
|
260
|
+
|
|
261
|
+
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.
|
|
262
|
+
|
|
263
|
+
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.
|
|
264
|
+
|
|
265
|
+
| Parameter | Required | Description |
|
|
266
|
+
| -------------- | -------- | ----------------------------------------------------------- |
|
|
267
|
+
| `agent_id` | yes | The settled agent to hand over. |
|
|
268
|
+
| `harness_type` | yes | Harness that executes the next run. |
|
|
269
|
+
| `model` | no | Model for the next run, in the target harness's vocabulary. |
|
|
270
|
+
| `thinking` | no | Thinking level for the next run. |
|
|
271
|
+
|
|
254
272
|
### `stop_cowboy_agent`
|
|
255
273
|
|
|
256
274
|
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,9 @@ 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 { HandoverExportOutcome } from "./handover-export.js";
|
|
10
|
+
import type { HandoverOutcome } from "./handover.js";
|
|
11
|
+
import { DISPOSE_QUEUED_MESSAGE, type SessionHandoverRequest, type SpawnOptions, type SteerOutcome } from "./subagent-session.js";
|
|
10
12
|
import type { SubagentType } from "./types.js";
|
|
11
13
|
export type { SpawnOptions, SteerOutcome } from "./subagent-session.js";
|
|
12
14
|
export declare function createAgentManagerTransport(runtime: ExecutionRuntime): SupervisorTransport;
|
|
@@ -18,6 +20,7 @@ export declare class AgentManager {
|
|
|
18
20
|
private onComplete?;
|
|
19
21
|
private onFollowUp?;
|
|
20
22
|
private readonly teardowns;
|
|
23
|
+
private readonly handovers;
|
|
21
24
|
private readonly pools;
|
|
22
25
|
private readonly registry;
|
|
23
26
|
constructor(pools: ConcurrencyPools, transport: SupervisorTransport);
|
|
@@ -29,6 +32,9 @@ export declare class AgentManager {
|
|
|
29
32
|
spawn(pi: ExtensionAPI, ctx: ExtensionContext, type: SubagentType, prompt: string, options: SpawnOptions): string;
|
|
30
33
|
private startSession;
|
|
31
34
|
steer(id: string, message: string): Promise<SteerOutcome>;
|
|
35
|
+
isHandingOver(id: string): boolean;
|
|
36
|
+
handover(id: string, request: SessionHandoverRequest): Promise<HandoverOutcome>;
|
|
37
|
+
exportHandover(id: string): Promise<HandoverExportOutcome>;
|
|
32
38
|
getSpawn(id: string): AgentSpawn | undefined;
|
|
33
39
|
private assets;
|
|
34
40
|
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,32 @@
|
|
|
1
|
+
import type { AnyHarnessId, HarnessExportLoss } from "./harness.js";
|
|
2
|
+
import type { HandoverSourceFault } from "./handover.js";
|
|
3
|
+
import type { ToolSeverity } from "./tool-result.js";
|
|
4
|
+
export interface HandoverExportArtifact {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
readonly loss?: HarnessExportLoss;
|
|
9
|
+
}
|
|
10
|
+
export type HandoverExportFault = HandoverSourceFault | {
|
|
11
|
+
readonly kind: "handover-in-progress";
|
|
12
|
+
readonly detail: string;
|
|
13
|
+
};
|
|
14
|
+
export type HandoverExportOutcome = ({
|
|
15
|
+
readonly kind: "prepared";
|
|
16
|
+
} & HandoverExportArtifact) | {
|
|
17
|
+
readonly kind: "faulted";
|
|
18
|
+
readonly fault: HandoverExportFault;
|
|
19
|
+
};
|
|
20
|
+
export type PreparedHandoverExport = Extract<HandoverExportOutcome, {
|
|
21
|
+
kind: "prepared";
|
|
22
|
+
}>;
|
|
23
|
+
export interface HandoverExportRequest {
|
|
24
|
+
readonly worktree: string;
|
|
25
|
+
readonly harness: AnyHarnessId;
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly text: string;
|
|
28
|
+
readonly loss?: HarnessExportLoss;
|
|
29
|
+
}
|
|
30
|
+
export declare function handoverExportArtifact(request: HandoverExportRequest): PreparedHandoverExport;
|
|
31
|
+
export declare function handoverExportFaultReason(fault: HandoverExportFault): string;
|
|
32
|
+
export declare function handoverExportSeverity(outcome: HandoverExportOutcome): ToolSeverity;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AnyHarnessId } from "./harness.js";
|
|
2
|
+
export declare const HANDOVER_EXPORT_DIR = "/tmp";
|
|
3
|
+
export declare function handoverNameField(value: string): string;
|
|
4
|
+
export interface HandoverFileRequest {
|
|
5
|
+
readonly worktree: string;
|
|
6
|
+
readonly harness: AnyHarnessId;
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function handoverFileName(request: HandoverFileRequest): string;
|
|
10
|
+
export declare function handoverFilePath(name: string): string;
|
|
11
|
+
export declare function handoverFileExists(path: string): boolean;
|
|
12
|
+
export declare function writeHandoverFile(path: string, text: string): {
|
|
13
|
+
readonly replaced: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Availability } from "../availability.js";
|
|
2
|
+
import type { HarnessRegistry } from "./harness/harness-registry.js";
|
|
3
|
+
import type { AnyHarnessId } from "./harness.js";
|
|
4
|
+
export interface HandoverTargetFault {
|
|
5
|
+
readonly kind: "request-refused";
|
|
6
|
+
readonly detail: string;
|
|
7
|
+
}
|
|
8
|
+
export type TargetRegistry = Pick<HarnessRegistry, "ids" | "get">;
|
|
9
|
+
export declare function handoverTargets(registry: TargetRegistry, availability: Availability<AnyHarnessId>, source: AnyHarnessId): AnyHarnessId[];
|
|
10
|
+
export declare function resolveHandoverTarget(raw: string, registry: TargetRegistry, availability: Availability<AnyHarnessId>): {
|
|
11
|
+
readonly kind: "ready";
|
|
12
|
+
readonly harness: AnyHarnessId;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "faulted";
|
|
15
|
+
readonly fault: HandoverTargetFault;
|
|
16
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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 HandoverSourceFault = {
|
|
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: "session-empty";
|
|
21
|
+
readonly harness: AnyHarnessId;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "session-export-failed";
|
|
24
|
+
readonly harness: AnyHarnessId;
|
|
25
|
+
readonly detail: string;
|
|
26
|
+
readonly exportFault?: SessionExportFault;
|
|
27
|
+
};
|
|
28
|
+
export type HandoverFault = HandoverSourceFault | {
|
|
29
|
+
readonly kind: "stop-failed";
|
|
30
|
+
readonly detail: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "request-refused";
|
|
33
|
+
readonly detail: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "launch-failed";
|
|
36
|
+
readonly detail: string;
|
|
37
|
+
};
|
|
38
|
+
export type HandoverOutcome = {
|
|
39
|
+
readonly kind: "handed-over";
|
|
40
|
+
readonly from: AnyHarnessId;
|
|
41
|
+
readonly to: AnyHarnessId;
|
|
42
|
+
readonly loss?: HarnessExportLoss;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: "faulted";
|
|
45
|
+
readonly fault: HandoverFault;
|
|
46
|
+
};
|
|
47
|
+
export declare function handoverLossClause(loss: HarnessExportLoss): string;
|
|
48
|
+
export declare function handoverSeverity(outcome: HandoverOutcome): ToolSeverity;
|
|
49
|
+
export type RunSession = {
|
|
50
|
+
readonly kind: "exported";
|
|
51
|
+
readonly sessionId: string;
|
|
52
|
+
readonly session: string;
|
|
53
|
+
readonly loss?: HarnessExportLoss;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "faulted";
|
|
56
|
+
readonly fault: HandoverSourceFault;
|
|
57
|
+
};
|
|
58
|
+
export declare function completeHandoverExport(source: HandoverRecordSource): HarnessExport;
|
|
59
|
+
export declare function exportRunSession(harnesses: HarnessRegistry, from: AnyHarnessId, request: HarnessExportRequest, policy: SessionExportPolicy): Promise<RunSession>;
|
|
60
|
+
export interface HandoverSessionRef {
|
|
61
|
+
readonly harness: AnyHarnessId;
|
|
62
|
+
readonly sessionId: string;
|
|
63
|
+
}
|
|
64
|
+
export declare function renderHandoverMarker(chain: readonly HandoverSessionRef[]): string;
|
|
65
|
+
export declare function parseHandoverMarker(text: string): readonly HandoverSessionRef[] | undefined;
|
|
66
|
+
export interface HandoverTaskRequest {
|
|
67
|
+
readonly taskSlug: string | undefined;
|
|
68
|
+
readonly sourceName: string;
|
|
69
|
+
readonly previous: readonly HandoverSessionRef[];
|
|
70
|
+
readonly current: HandoverSessionRef;
|
|
71
|
+
readonly session: string;
|
|
72
|
+
}
|
|
73
|
+
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,103 @@
|
|
|
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.ZodLiteral<"compacted">;
|
|
82
|
+
payload: z.ZodObject<{
|
|
83
|
+
message: z.ZodString;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
86
|
+
kind: "compacted";
|
|
87
|
+
summary: string;
|
|
88
|
+
}, {
|
|
89
|
+
type: "compacted";
|
|
90
|
+
payload: {
|
|
91
|
+
message: string;
|
|
92
|
+
};
|
|
93
|
+
}>>, z.ZodPipe<z.ZodObject<{
|
|
94
|
+
type: z.ZodString;
|
|
95
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
96
|
+
kind: "traffic";
|
|
97
|
+
}, {
|
|
98
|
+
type: string;
|
|
99
|
+
}>>]>;
|
|
100
|
+
export type RolloutRecord = z.infer<typeof RolloutLineSchema>;
|
|
101
|
+
export type Turn = Extract<RolloutRecord, {
|
|
102
|
+
kind: "turn";
|
|
103
|
+
}>;
|
|
@@ -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: Iterable<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): Iterable<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[]): Iterable<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;
|