pi-cowboy 0.22.1 → 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.
Files changed (65) hide show
  1. package/README.md +16 -1
  2. package/agents/explore.toml +9 -11
  3. package/dist/agents/agent-assets.d.ts +11 -2
  4. package/dist/agents/agent-cleanup.d.ts +6 -22
  5. package/dist/agents/agent-environment.d.ts +6 -0
  6. package/dist/agents/agent-host.d.ts +3 -3
  7. package/dist/agents/agent-manager.d.ts +5 -1
  8. package/dist/agents/batch.d.ts +2 -1
  9. package/dist/agents/cleanup-policy.d.ts +15 -16
  10. package/dist/agents/handover.d.ts +71 -0
  11. package/dist/agents/harness/claude/session-export.d.ts +7 -0
  12. package/dist/agents/harness/claude/staging.d.ts +9 -1
  13. package/dist/agents/harness/codex-session-schema.d.ts +90 -0
  14. package/dist/agents/harness/codex-session.d.ts +17 -0
  15. package/dist/agents/harness/opencode/session-export.d.ts +39 -0
  16. package/dist/agents/harness/pi-compatible.d.ts +3 -1
  17. package/dist/agents/harness/pi-session.d.ts +12 -0
  18. package/dist/agents/harness/pi-store.d.ts +8 -0
  19. package/dist/agents/harness/pi.d.ts +2 -0
  20. package/dist/agents/harness/pig-store.d.ts +7 -0
  21. package/dist/agents/harness/stop-keys.d.ts +2 -0
  22. package/dist/agents/harness.d.ts +53 -0
  23. package/dist/agents/run-state.d.ts +1 -0
  24. package/dist/agents/schemas/handover.schema.d.ts +8 -0
  25. package/dist/agents/subagent-session.d.ts +8 -1
  26. package/dist/agents/tool-cleanup.d.ts +16 -2
  27. package/dist/agents/tool-execution.d.ts +21 -2
  28. package/dist/agents/tool-handover.d.ts +28 -0
  29. package/dist/agents/tool-merge.d.ts +18 -2
  30. package/dist/agents/tool-renderer.d.ts +21 -0
  31. package/dist/agents/tool-result.d.ts +9 -2
  32. package/dist/agents/tool-steer.d.ts +17 -2
  33. package/dist/{chunk-2GTF3FFO.js → chunk-277WT5MT.js} +2 -2
  34. package/dist/chunk-J5TU3AFX.js +2 -0
  35. package/dist/chunk-M42XWVYW.js +45 -0
  36. package/dist/{chunk-7KLHCZK2.js → chunk-MZROKRT4.js} +2 -2
  37. package/dist/chunk-S4BS2R6G.js +26 -0
  38. package/dist/chunk-TFQCH2TO.js +14 -0
  39. package/dist/config/config-store.d.ts +1 -0
  40. package/dist/config/layered-config.d.ts +2 -3
  41. package/dist/cowboy-tools.d.ts +13 -0
  42. package/dist/dev-mode.d.ts +1 -0
  43. package/dist/index.js +18 -18
  44. package/dist/infrastructure/herdr/agent-exit.d.ts +12 -0
  45. package/dist/infrastructure/herdr/agents.d.ts +0 -1
  46. package/dist/infrastructure/herdr/index.d.ts +1 -1
  47. package/dist/{menu-worktree-command-NH52QLGX.js → menu-worktree-command-THJ3VSWU.js} +2 -2
  48. package/dist/{menus-Z5QGWG5V.js → menus-KXKDXZRN.js} +3 -3
  49. package/dist/{model-picker-VQEDJJFS.js → model-picker-FMMQY4KI.js} +2 -2
  50. package/dist/models/model-precedence.d.ts +1 -0
  51. package/dist/models/model-request-types.d.ts +8 -2
  52. package/dist/plugin/index.d.ts +1 -1
  53. package/dist/plugin/index.js +1 -1
  54. package/dist/predicates.d.ts +1 -0
  55. package/dist/registration.d.ts +3 -8
  56. package/dist/spawn/sandbox.d.ts +22 -0
  57. package/dist/subagent/result-artifacts.d.ts +1 -0
  58. package/dist/subagent/supervisor.d.ts +2 -0
  59. package/dist/types.d.ts +11 -0
  60. package/package.json +4 -3
  61. package/dist/chunk-254PTGN5.js +0 -2
  62. package/dist/chunk-7W5EBKER.js +0 -10
  63. package/dist/chunk-EFERFQIQ.js +0 -24
  64. package/dist/chunk-HPB3IRXW.js +0 -15
  65. package/dist/infrastructure/herdr/agent-stopper.d.ts +0 -14
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { Type, type Static } from "typebox";
2
+ export declare const HandoverAgentSchema: Type.TObject<{
3
+ agent_id: Type.TString;
4
+ harness_type: Type.TString;
5
+ model: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
6
+ thinking: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
7
+ }>;
8
+ export type HandoverAgentParams = Static<typeof HandoverAgentSchema>;
@@ -1,8 +1,9 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { type SupervisorTransport } from "../subagent/pane-supervisor.js";
3
3
  import type { ConcurrencyPools, PoolReservation } from "../concurrency-pools.js";
4
- import type { AgentSpawn, SpawnConfig, StopInitiator } from "../types.js";
4
+ import type { AgentSpawn, ModelChoice, SpawnConfig, StopInitiator } from "../types.js";
5
5
  import type { AnyHarnessId } from "./harness.js";
6
+ import { type HandoverOutcome } from "./handover.js";
6
7
  import type { SubagentType } from "./types.js";
7
8
  export { DISPOSE_QUEUED_MESSAGE } from "./run-state.js";
8
9
  export type SteerOutcome = {
@@ -40,6 +41,10 @@ interface SubagentSessionOptions {
40
41
  args: SpawnArgs;
41
42
  deps: SubagentSessionDeps;
42
43
  }
44
+ export interface SessionHandoverRequest {
45
+ readonly harness: AnyHarnessId;
46
+ readonly modelChoice?: ModelChoice;
47
+ }
43
48
  export declare class SubagentSession {
44
49
  readonly id: string;
45
50
  private readonly args;
@@ -66,10 +71,12 @@ export declare class SubagentSession {
66
71
  steer(message: string): Promise<SteerOutcome>;
67
72
  private revive;
68
73
  abort(initiator?: StopInitiator): Promise<boolean>;
74
+ handover(request: SessionHandoverRequest): Promise<HandoverOutcome>;
69
75
  drop(): void;
70
76
  settleForDispose(): void;
71
77
  private launch;
72
78
  private supervisorOptions;
79
+ private stopHarnessProcess;
73
80
  private resultFilePath;
74
81
  private applySupervisorOutcome;
75
82
  private stopPaneProcess;
@@ -1,7 +1,20 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import type { CleanupBatchParams } from "./schemas/cleanup-batch.schema.js";
2
+ import { type CleanupBatchParams } from "./schemas/cleanup-batch.schema.js";
3
3
  import type { CleanupReport } from "./cleanup-policy.js";
4
- import type { ToolResult } from "./tool-result.js";
4
+ import type { ToolResult, ToolSeverity } from "./tool-result.js";
5
+ export declare const cleanupAgentTool: {
6
+ name: "cleanup_cowboy_agent";
7
+ label: "cleanup_cowboy_agent";
8
+ description: string;
9
+ parameters: import("typebox").TObject<{
10
+ agent_ids: import("typebox").TArray<import("typebox").TString>;
11
+ }>;
12
+ execute: typeof executeCleanupAgentTool;
13
+ constrainedSampling: {
14
+ readonly type: "json_schema";
15
+ readonly strict: "prefer";
16
+ };
17
+ };
5
18
  export type CleanupItemOutcome = {
6
19
  kind: "cleaned";
7
20
  agentId: string;
@@ -11,6 +24,7 @@ export type CleanupItemOutcome = {
11
24
  agentId: string;
12
25
  activeAgents: string;
13
26
  };
27
+ export declare function cleanupSeverity(outcome: CleanupItemOutcome): ToolSeverity;
14
28
  export declare function renderCleanupOutcome(outcome: CleanupItemOutcome): string;
15
29
  export declare function executeCleanupAgentTool(_toolCallId: string, params: CleanupBatchParams, _signal: AbortSignal | undefined, _onUpdate: ((update: ToolResult<{
16
30
  agents: CleanupItemOutcome[];
@@ -1,9 +1,23 @@
1
1
  import type { ExtensionContext, ToolCallEvent } from "@earendil-works/pi-coding-agent";
2
2
  import { type AgentStatus } from "../types.js";
3
3
  import type { CowboyAgents } from "./schemas/cowboy-agents.schema.js";
4
- import type { StopBatchParams } from "./schemas/stop-batch.schema.js";
5
- import { type ToolResult } from "./tool-result.js";
4
+ import { type StopBatchParams } from "./schemas/stop-batch.schema.js";
5
+ import { type ToolResult, type ToolSeverity } from "./tool-result.js";
6
+ export declare function delegationSeverity(details: Record<string, unknown>): ToolSeverity;
6
7
  export declare function executeAgentTool(_toolCallId: string, params: CowboyAgents, signal: AbortSignal | undefined, _onUpdate: ((update: ToolResult<Record<string, unknown>>) => void) | undefined, ctx: ExtensionContext): Promise<ToolResult<Record<string, unknown>>>;
8
+ export declare const stopAgentTool: {
9
+ name: "stop_cowboy_agent";
10
+ label: "stop_cowboy_agent";
11
+ description: string;
12
+ parameters: import("typebox").TObject<{
13
+ agent_ids: import("typebox").TArray<import("typebox").TString>;
14
+ }>;
15
+ execute: typeof executeStopAgentTool;
16
+ constrainedSampling: {
17
+ readonly type: "json_schema";
18
+ readonly strict: "prefer";
19
+ };
20
+ };
7
21
  export type StopItemOutcome = {
8
22
  kind: "stopped";
9
23
  agentId: string;
@@ -16,11 +30,16 @@ export type StopItemOutcome = {
16
30
  kind: "unknown";
17
31
  agentId: string;
18
32
  activeAgents: string;
33
+ } | {
34
+ kind: "refused";
35
+ agentId: string;
36
+ reason: string;
19
37
  } | {
20
38
  kind: "failed";
21
39
  agentId: string;
22
40
  error: string;
23
41
  };
42
+ export declare function stopSeverity(outcome: StopItemOutcome): ToolSeverity;
24
43
  export declare function renderStopOutcome(outcome: StopItemOutcome): string;
25
44
  export declare function executeStopAgentTool(_toolCallId: string, params: StopBatchParams, _signal: AbortSignal | undefined, _onUpdate: ((update: ToolResult<{
26
45
  agents: StopItemOutcome[];
@@ -0,0 +1,28 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { type HandoverOutcome } from "./handover.js";
3
+ import { type HandoverAgentParams } from "./schemas/handover.schema.js";
4
+ import { type ToolResult } from "./tool-result.js";
5
+ export declare function renderHandoverOutcome(agentId: string, outcome: HandoverOutcome): string;
6
+ export declare function executeHandoverAgentTool(_toolCallId: string, params: HandoverAgentParams, _signal: AbortSignal | undefined, _onUpdate: ((update: ToolResult<{
7
+ agentId: string;
8
+ outcome: HandoverOutcome;
9
+ }>) => void) | undefined, ctx: ExtensionContext): Promise<ToolResult<{
10
+ agentId: string;
11
+ outcome: HandoverOutcome;
12
+ }>>;
13
+ export declare const handoverAgentTool: {
14
+ name: "handover_cowboy_agent";
15
+ label: "handover_cowboy_agent";
16
+ description: string;
17
+ parameters: import("typebox").TObject<{
18
+ agent_id: import("typebox").TString;
19
+ harness_type: import("typebox").TString;
20
+ model: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>>;
21
+ thinking: import("typebox").TOptional<import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>>;
22
+ }>;
23
+ execute: typeof executeHandoverAgentTool;
24
+ constrainedSampling: {
25
+ readonly type: "json_schema";
26
+ readonly strict: "prefer";
27
+ };
28
+ };
@@ -1,9 +1,24 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import type { MergeBatchParams } from "./schemas/merge-batch.schema.js";
3
- import type { ToolResult } from "./tool-result.js";
2
+ import { type MergeBatchParams } from "./schemas/merge-batch.schema.js";
3
+ import type { ToolResult, ToolSeverity } from "./tool-result.js";
4
4
  export declare function normalizeRepoRoot(root: string): string;
5
5
  export declare function isSameRepoRoot(a: string, b: string): boolean;
6
6
  export declare function formatOutsideRepoWarning(mainRoot: string, sessionRoot: string): string;
7
+ export declare const mergeBranchTool: {
8
+ name: "merge_cowboy_branch";
9
+ label: "merge_cowboy_branch";
10
+ description: string;
11
+ parameters: import("typebox").TObject<{
12
+ branches: import("typebox").TArray<import("typebox").TString>;
13
+ target: import("typebox").TOptional<import("typebox").TString>;
14
+ repo: import("typebox").TOptional<import("typebox").TString>;
15
+ }>;
16
+ execute: typeof executeMergeBranchTool;
17
+ constrainedSampling: {
18
+ readonly type: "json_schema";
19
+ readonly strict: "prefer";
20
+ };
21
+ };
7
22
  export type MergeItemOutcome = {
8
23
  kind: "merged";
9
24
  branch: string;
@@ -30,6 +45,7 @@ export type MergeItemOutcome = {
30
45
  branch: string;
31
46
  reason: string;
32
47
  };
48
+ export declare function mergeSeverity(outcome: MergeItemOutcome): ToolSeverity;
33
49
  export declare function executeMergeBranchTool(_toolCallId: string, params: MergeBatchParams, _signal: AbortSignal | undefined, _onUpdate: ((update: ToolResult<{
34
50
  branches: MergeItemOutcome[];
35
51
  }>) => void) | undefined, ctx: ExtensionContext): Promise<ToolResult<{
@@ -0,0 +1,21 @@
1
+ import { Text } from "@earendil-works/pi-tui";
2
+ import type { Theme } from "../ui/types.js";
3
+ import type { ToolSeverity } from "./tool-result.js";
4
+ interface RenderedResult {
5
+ content: ReadonlyArray<{
6
+ type: string;
7
+ text?: string;
8
+ }>;
9
+ details?: {
10
+ severity?: ToolSeverity;
11
+ };
12
+ }
13
+ export declare function renderCowboyToolResult(result: RenderedResult, _options: {
14
+ expanded?: boolean;
15
+ }, theme: Theme, context: {
16
+ isError?: boolean;
17
+ }): Text;
18
+ export declare function withCowboyRenderer<TTool extends object>(tool: TTool): TTool & {
19
+ renderResult: typeof renderCowboyToolResult;
20
+ };
21
+ export {};
@@ -1,9 +1,16 @@
1
+ export type ToolSeverity = "success" | "warning" | "error";
1
2
  export interface ToolResult<TDetails = Record<string, unknown>> {
2
3
  content: Array<{
3
4
  type: "text";
4
5
  text: string;
5
6
  }>;
6
- details: TDetails;
7
+ details: TDetails & {
8
+ severity: ToolSeverity;
9
+ };
7
10
  }
11
+ export declare function resultWithSeverity<TDetails>(severity: ToolSeverity, text: string, details: TDetails): ToolResult<TDetails>;
8
12
  export declare function successResult<TDetails>(text: string, details: TDetails): ToolResult<TDetails>;
9
- export declare function textOnlyResult<TDetails = undefined>(text: string): ToolResult<TDetails>;
13
+ export declare function warningResult<TDetails>(text: string, details: TDetails): ToolResult<TDetails>;
14
+ export declare function errorResult<TDetails>(text: string, details: TDetails): ToolResult<TDetails>;
15
+ export declare function textOnlyResult(text: string): ToolResult<Record<never, never>>;
16
+ export declare function foldSeverity(severities: readonly ToolSeverity[]): ToolSeverity;
@@ -1,6 +1,21 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import type { SteerBatchParams } from "./schemas/steer-batch.schema.js";
3
- import type { ToolResult } from "./tool-result.js";
2
+ import { type SteerBatchParams } from "./schemas/steer-batch.schema.js";
3
+ import type { ToolResult, ToolSeverity } from "./tool-result.js";
4
+ export declare const steerAgentTool: {
5
+ name: "steer_cowboy_agent";
6
+ label: "steer_cowboy_agent";
7
+ description: string;
8
+ parameters: import("typebox").TObject<{
9
+ agent_ids: import("typebox").TArray<import("typebox").TString>;
10
+ message: import("typebox").TString;
11
+ }>;
12
+ execute: typeof executeSteerAgentTool;
13
+ constrainedSampling: {
14
+ readonly type: "json_schema";
15
+ readonly strict: "prefer";
16
+ };
17
+ };
18
+ export declare function steerSeverity(outcome: SteerItemOutcome): ToolSeverity;
4
19
  export type SteerItemOutcome = {
5
20
  kind: "delivered";
6
21
  agentId: string;
@@ -1,2 +1,2 @@
1
- import{h as l,n as h}from"./chunk-7KLHCZK2.js";import{a as r}from"./chunk-254PTGN5.js";import{isFocusable as c}from"@earendil-works/pi-tui";var g=new Map([["\x1B[C","\r"],["\x1BOC","\r"],["\x1B[D","\x1B"],["\x1BOD","\x1B"]]),p=class{static{r(this,"SettingsListWrapper")}settingsList;title;theme;separatorChar;passthroughKeys;constructor(t,e){this.settingsList=e.passthroughKeys?t:h(t),this.title=e.title,this.theme=e.theme,this.separatorChar=e.separatorChar??"\u2500",this.passthroughKeys=e.passthroughKeys??!1;let n=this.settingsList;if(e.onCancel&&!n.onCancel){let s=e.onCancel;n.onCancel=()=>s()}if(e.onCancel&&l(n),e.onRebuild){let s=r((o,m)=>{n.items=o,n.filteredItems=o,n.submenuComponent=null;let a=o.findIndex(u=>u.id===m);n.selectedIndex=a>0?a:0},"rebuild");e.onRebuild(s)}}invalidate(){this.settingsList.invalidate()}get submenuComponent(){return this.settingsList.submenuComponent??null}get hasSubmenu(){return c(this.submenuComponent)}handleInput(t){if(this.passthroughKeys||this.hasSubmenu){this.settingsList.handleInput?.(t);return}let e=g.get(t);if(e!==void 0){this.settingsList.handleInput?.(e);return}this.settingsList.handleInput?.(t)}render(t){let e=[];e.push(this.separatorChar.repeat(t)),e.push("");let n=this.theme.bold(this.theme.fg("accent",this.title));e.push(" "+n),e.push("");let s=this.settingsList.render(t),o=/Enter\/Space|Esc to cancel/;return s.length>=2&&o.test(s[s.length-1]??"")?e.push(...s.slice(0,-2)):e.push(...s),e.push(""),e.push(this.separatorChar.repeat(t)),e}};import{Input as d}from"@earendil-works/pi-tui";function f(i){let t=i.codePointAt(0)??0;return t<32||t===127||t>=128&&t<=159}r(f,"isControlCharacter");function S(i){let t=new d;t.focused=!0;for(let e of i.prefill)f(e)||t.handleInput(e);return t.onSubmit=e=>{let n=e.trim(),s=i.validate(n);if(s){i.notify(i.describeProblem(s),"error");return}i.onDone(n)},t.onEscape=()=>i.onCancel(),t}r(S,"createNameField");export{S as a,p as b};
2
- //# sourceMappingURL=chunk-2GTF3FFO.js.map
1
+ import{h as l,n as h}from"./chunk-MZROKRT4.js";import{a as r}from"./chunk-J5TU3AFX.js";import{isFocusable as c}from"@earendil-works/pi-tui";var g=new Map([["\x1B[C","\r"],["\x1BOC","\r"],["\x1B[D","\x1B"],["\x1BOD","\x1B"]]),p=class{static{r(this,"SettingsListWrapper")}settingsList;title;theme;separatorChar;passthroughKeys;constructor(t,e){this.settingsList=e.passthroughKeys?t:h(t),this.title=e.title,this.theme=e.theme,this.separatorChar=e.separatorChar??"\u2500",this.passthroughKeys=e.passthroughKeys??!1;let n=this.settingsList;if(e.onCancel&&!n.onCancel){let s=e.onCancel;n.onCancel=()=>s()}if(e.onCancel&&l(n),e.onRebuild){let s=r((o,m)=>{n.items=o,n.filteredItems=o,n.submenuComponent=null;let a=o.findIndex(u=>u.id===m);n.selectedIndex=a>0?a:0},"rebuild");e.onRebuild(s)}}invalidate(){this.settingsList.invalidate()}get submenuComponent(){return this.settingsList.submenuComponent??null}get hasSubmenu(){return c(this.submenuComponent)}handleInput(t){if(this.passthroughKeys||this.hasSubmenu){this.settingsList.handleInput?.(t);return}let e=g.get(t);if(e!==void 0){this.settingsList.handleInput?.(e);return}this.settingsList.handleInput?.(t)}render(t){let e=[];e.push(this.separatorChar.repeat(t)),e.push("");let n=this.theme.bold(this.theme.fg("accent",this.title));e.push(" "+n),e.push("");let s=this.settingsList.render(t),o=/Enter\/Space|Esc to cancel/;return s.length>=2&&o.test(s[s.length-1]??"")?e.push(...s.slice(0,-2)):e.push(...s),e.push(""),e.push(this.separatorChar.repeat(t)),e}};import{Input as d}from"@earendil-works/pi-tui";function f(i){let t=i.codePointAt(0)??0;return t<32||t===127||t>=128&&t<=159}r(f,"isControlCharacter");function S(i){let t=new d;t.focused=!0;for(let e of i.prefill)f(e)||t.handleInput(e);return t.onSubmit=e=>{let n=e.trim(),s=i.validate(n);if(s){i.notify(i.describeProblem(s),"error");return}i.onDone(n)},t.onEscape=()=>i.onCancel(),t}r(S,"createNameField");export{S as a,p as b};
2
+ //# sourceMappingURL=chunk-277WT5MT.js.map
@@ -0,0 +1,2 @@
1
+ var p=Object.defineProperty;var r=(e,n)=>p(e,"name",{value:n,configurable:!0});function C(e){return!e||e.length>128||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e)}r(C,"isUnsafeName");function c(e){return e.replace(/[\r\n]+/g," ").trim()}r(c,"toSingleLine");function a(e){return new Promise(n=>setTimeout(n,e))}r(a,"sleep");function A(e){return c(e instanceof Error?e.message:String(e))}r(A,"errorMessage");function y(e){if(typeof e!="string")return null;let n=e.indexOf("/");return n<=0?null:{provider:e.slice(0,n),modelId:e.slice(n+1)}}r(y,"parseModelKey");function v(e,n,t){if(!e)return t;let o=y(e);return o?n.find(o.provider,o.modelId)??t:t}r(v,"findModelInRegistry");function M(e){if(e)return"model"in e?e.model.id:"harness"in e?e.name:void 0}r(M,"modelChoiceName");function N(e){return e!=null&&"key"in e?e.key:void 0}r(N,"modelChoiceKey");var O=5e3;function T(e){throw new Error(`Unhandled variant: ${JSON.stringify(e)}`)}r(T,"assertNever");var g=["pi","pig","pi-bolt","opencode","codex","claude"];var x=["pi","pig","pi-bolt"];function D(e){return x.some(n=>n===e)}r(D,"isPiFamilyHarness");function F(e){return g.find(n=>n===e)}r(F,"parseHarnessId");var f=["PATH","HOME","SHELL","PWD","OLDPWD","IFS","CDPATH","GLOBIGNORE","PS1","PS2","PS3","PS4","BASH_ENV","ENV","NODE_OPTIONS","LD_PRELOAD","LD_AUDIT"],E=["DYLD_","HERDR_","COWBOY_"],d=Object.freeze([]),R=/^[A-Za-z_][A-Za-z0-9_]*$/;function q(e){return R.test(e)}r(q,"isEnvVarName");function w(e){return new RegExp("\\p{Cc}","u").test(e)}r(w,"hasControlCharacter");function m(e){return f.includes(e)||E.some(n=>e.startsWith(n))}r(m,"isUniversalReservedEnvVar");function V(e,n=d){return m(e)||n.includes(e)}r(V,"isReservedEnvVar");function U(e){return e.reservedEnvVars?.()??d}r(U,"reservedEnvVarsOf");var $={pi:["PI_CODING_AGENT_DIR","PI_CODING_AGENT_SESSION_DIR","HERDR_AGENT"],opencode:["OPENCODE_CONFIG_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_CONTENT","OPENCODE_DISABLE_PROJECT_CONFIG","OPENCODE_DISABLE_AUTOUPDATE"],codex:["CODEX_HOME"],claude:["CLAUDE_CONFIG_DIR","CLAUDE_SECURESTORAGE_CONFIG_DIR","CLAUDE_CODE_DISABLE_CLAUDE_MDS","ANTHROPIC_API_KEY","COWBOY_API_KEY"]},i=class extends Error{static{r(this,"SessionExportError")}fault;constructor(n,t){super(t),this.name="SessionExportError",this.fault=n}};function G(e){return e.kind==="unavailable"?[]:e.entries}r(G,"modelListEntries");function B(e){return e.kind==="listed"?void 0:e.notice}r(B,"modelListNotice");function K(e){return e.readHandoverRecords!==void 0}r(K,"canReadHandoverRecords");function L(e){return`'${e.replaceAll("'","'\\''")}'`}r(L,"singleQuoteShellWord");function z(e,n){return e===null?n:`( . ${L(e)} && { ${n}; } )`}r(z,"launchEnvBody");var l=5,I=2e3,H=250;function P(e){let n=e.indexOf("_");return n===-1?e:`${e.slice(0,n+1)}""${e.slice(n+1)}`}r(P,"splitMarker");async function X(e,n,t){let o=`${t.commandName}() { : "${t.signature}"; ${t.body}; }`,u=`typeset -f ${t.commandName} 2>/dev/null | grep -q "${t.signature}" && echo ${P(t.readyMarker)}`;for(let s=1;s<=l;s++){if(await e.run(n,o),await e.run(n,u),await _(e,n,t.readyMarker,I)){t.proof!==void 0&&await S(e,n,t.proof);return}s<l&&await a(H)}throw new Error(`failed to prepare pane ${n}: the ${t.commandName} launcher never landed`)}r(X,"installPaneLauncher");async function _(e,n,t,o){try{return await e.waitForOutput(n,t,o),!0}catch{return!1}}r(_,"panePrinted");async function S(e,n,t){await e.run(n,t.command);try{await e.waitForOutput(n,t.output,t.timeoutMs)}catch{throw new Error(t.failure)}}r(S,"requirePaneProof");export{r as a,C as b,a as c,A as d,y as e,v as f,M as g,N as h,O as i,T as j,g as k,D as l,F as m,q as n,w as o,m as p,V as q,U as r,$ as s,i as t,G as u,B as v,K as w,L as x,z as y,P as z,X as A};
2
+ //# sourceMappingURL=chunk-J5TU3AFX.js.map