@phren/cli 0.3.36 → 0.3.39

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 (103) hide show
  1. package/dist/bridge/account-choice.d.ts +82 -0
  2. package/dist/bridge/account-choice.js +173 -0
  3. package/dist/bridge/account-failover.d.ts +61 -0
  4. package/dist/bridge/account-failover.js +189 -0
  5. package/dist/bridge/account-usage.d.ts +7 -2
  6. package/dist/bridge/account-usage.js +53 -8
  7. package/dist/bridge/agent-hooks.js +2 -0
  8. package/dist/bridge/changes.d.ts +5 -0
  9. package/dist/bridge/changes.js +4 -0
  10. package/dist/bridge/claude-accounts.d.ts +15 -4
  11. package/dist/bridge/claude-accounts.js +31 -16
  12. package/dist/bridge/claude-credits.d.ts +43 -0
  13. package/dist/bridge/claude-credits.js +236 -0
  14. package/dist/bridge/claude-question-dialog.js +6 -2
  15. package/dist/bridge/command.js +64 -3
  16. package/dist/bridge/device-enroll.d.ts +34 -0
  17. package/dist/bridge/device-enroll.js +57 -0
  18. package/dist/bridge/dispatch-command.d.ts +2 -0
  19. package/dist/bridge/dispatch-command.js +25 -1
  20. package/dist/bridge/dispatch-returns.d.ts +19 -0
  21. package/dist/bridge/dispatch-returns.js +93 -12
  22. package/dist/bridge/dispatch.d.ts +83 -3
  23. package/dist/bridge/dispatch.js +82 -10
  24. package/dist/bridge/file-range.d.ts +3 -0
  25. package/dist/bridge/file-range.js +5 -4
  26. package/dist/bridge/file-search.d.ts +37 -0
  27. package/dist/bridge/file-search.js +87 -0
  28. package/dist/bridge/file-write.d.ts +6 -0
  29. package/dist/bridge/file-write.js +120 -0
  30. package/dist/bridge/git-host-auth.d.ts +31 -0
  31. package/dist/bridge/git-host-auth.js +110 -0
  32. package/dist/bridge/git-host-gitboy.d.ts +46 -0
  33. package/dist/bridge/git-host-gitboy.js +296 -0
  34. package/dist/bridge/git-host-gitlab.d.ts +25 -0
  35. package/dist/bridge/git-host-gitlab.js +229 -0
  36. package/dist/bridge/git-host-http.d.ts +33 -0
  37. package/dist/bridge/git-host-http.js +70 -0
  38. package/dist/bridge/git-hosts.d.ts +92 -0
  39. package/dist/bridge/git-hosts.js +244 -0
  40. package/dist/bridge/git-publish.d.ts +15 -5
  41. package/dist/bridge/git-publish.js +69 -21
  42. package/dist/bridge/git-review.d.ts +23 -0
  43. package/dist/bridge/git-review.js +170 -0
  44. package/dist/bridge/git-sync.d.ts +14 -0
  45. package/dist/bridge/git-sync.js +143 -0
  46. package/dist/bridge/git.d.ts +20 -7
  47. package/dist/bridge/git.js +87 -68
  48. package/dist/bridge/gitboy-contract.d.ts +32 -0
  49. package/dist/bridge/gitboy-contract.js +46 -0
  50. package/dist/bridge/hand-off.d.ts +75 -3
  51. package/dist/bridge/hand-off.js +113 -27
  52. package/dist/bridge/health.d.ts +1 -1
  53. package/dist/bridge/health.js +5 -3
  54. package/dist/bridge/install.d.ts +14 -0
  55. package/dist/bridge/install.js +40 -1
  56. package/dist/bridge/launch-brief.d.ts +3 -0
  57. package/dist/bridge/launch-brief.js +16 -0
  58. package/dist/bridge/memory-store.d.ts +8 -0
  59. package/dist/bridge/memory-store.js +80 -2
  60. package/dist/bridge/pair.d.ts +6 -1
  61. package/dist/bridge/pair.js +74 -2
  62. package/dist/bridge/peers.js +4 -2
  63. package/dist/bridge/project-memory.d.ts +94 -0
  64. package/dist/bridge/project-memory.js +235 -0
  65. package/dist/bridge/push.d.ts +15 -0
  66. package/dist/bridge/push.js +39 -0
  67. package/dist/bridge/schedule-launch.js +5 -1
  68. package/dist/bridge/schedule-watch.d.ts +3 -0
  69. package/dist/bridge/schedule-watch.js +27 -1
  70. package/dist/bridge/scoped-gateway.d.ts +29 -0
  71. package/dist/bridge/scoped-gateway.js +239 -0
  72. package/dist/bridge/server-launch.d.ts +12 -0
  73. package/dist/bridge/server-launch.js +23 -12
  74. package/dist/bridge/server-pane-routes.js +54 -3
  75. package/dist/bridge/server-routes.d.ts +12 -0
  76. package/dist/bridge/server-routes.js +64 -5
  77. package/dist/bridge/server.js +50 -5
  78. package/dist/bridge/session-move.d.ts +288 -0
  79. package/dist/bridge/session-move.js +600 -0
  80. package/dist/bridge/subscription.d.ts +15 -0
  81. package/dist/bridge/subscription.js +23 -0
  82. package/dist/bridge/transport.js +21 -1
  83. package/dist/bridge/usage.d.ts +23 -4
  84. package/dist/bridge/usage.js +63 -11
  85. package/dist/bridge-hook.mjs +23280 -13252
  86. package/dist/cli/config.js +28 -2
  87. package/dist/cli-registry.js +10 -4
  88. package/dist/computers/command.js +3 -1
  89. package/dist/computers/read.d.ts +3 -0
  90. package/dist/computers/read.js +6 -0
  91. package/dist/content/summarize.d.ts +21 -0
  92. package/dist/content/summarize.js +56 -18
  93. package/dist/init/preferences.d.ts +6 -0
  94. package/dist/modules/registry.js +13 -13
  95. package/dist/project-config.d.ts +12 -0
  96. package/dist/project-config.js +29 -0
  97. package/dist/shared/retrieval.d.ts +1 -0
  98. package/dist/shared/retrieval.js +1 -1
  99. package/dist/sync/conflict-resolve.js +5 -6
  100. package/dist/tools/dispatch.js +20 -3
  101. package/dist/tools/finding.d.ts +25 -0
  102. package/dist/tools/finding.js +2 -1
  103. package/package.json +57 -1
@@ -1,3 +1,5 @@
1
+ import { setChoiceReaders } from "./account-choice.js";
2
+ import { AccountFailover } from "./account-failover.js";
1
3
  import { ownerInboxSources } from "./owner-inbox-sources.js";
2
4
  import { OwnerInbox } from "./owner-inbox.js";
3
5
  import { closeFinishedWorker } from "./worker-close.js";
@@ -50,6 +52,14 @@ import { typedMuxRequest } from "./mux-wire.js";
50
52
  import { overviewStream } from "./server-overview.js";
51
53
  import { transcriptStreams } from "./server-stream.js";
52
54
  import { launchSession } from "./server-launch.js";
55
+ import { SessionMover, transcriptTail } from "./session-move.js";
56
+ import { harnessInventoryWithin, launchCheckOff } from "./harnesses.js";
57
+ import { paneAccount, paneAccountKey } from "./pane-accounts.js";
58
+ import { readTurn } from "./turn-records.js";
59
+ import { readLaunchBrief } from "./launch-brief.js";
60
+ import { conductorPane } from "./conductor-role.js";
61
+ import { terminalKind, terminalProvider } from "./terminal.js";
62
+ import { targetTranscriptPath } from "./transcripts.js";
53
63
  import { codexAppServerEnabled, codexServers } from "./codex-servers.js";
54
64
  import { CodexAuthKeeper, codexAuthRefreshEnabled } from "./codex-auth-refresh.js";
55
65
  import { localNames } from "./computer-names.js";
@@ -88,6 +98,8 @@ export async function serve(version, options = {}) {
88
98
  const agentHooks = new AgentHooks(undefined, modules, path.join(bridgeRoot(), "deliveries.json"));
89
99
  // Follows what dispatched workers do and tells the dispatching agent.
90
100
  const returns = dispatches ? new DispatchReturns({
101
+ // Continue on another signed-in account when a Claude worker stops at its usage limit: opt-in, `phren config account-failover on`.
102
+ failover: new AccountFailover({ rooms: () => dispatches.claudeRooms(), dispatch: (input, origin, continues) => dispatches.dispatch(input, origin, continues) }),
91
103
  localWorkers: hookWorkers(agentHooks),
92
104
  close: async (receipt) => {
93
105
  const data = { target: receipt.target, dispatch: receipt.id, turn: receipt.closePending.turn };
@@ -118,6 +130,7 @@ export async function serve(version, options = {}) {
118
130
  const settingsSwitcher = new SettingsSwitcher(agentHooks);
119
131
  const permissionModeSwitcher = new PermissionModeSwitcher(agentHooks);
120
132
  const sideQuestions = new SideQuestions();
133
+ const sendPrompt = async (target, text, deliveryId, typing) => await paneRouteOnce({ agentHooks, modelSwitcher, settingsSwitcher, permissionModeSwitcher, codexQuestions, sideQuestions }, new URL("http://phren.local/v1/prompt"), { target, text, deliveryId, hookQueued: true }, {}, typing);
121
134
  const handOffs = dispatches ? new HandOffQueue({
122
135
  validate: target => validateTarget(target, false, true),
123
136
  current: async (target) => {
@@ -126,10 +139,31 @@ export async function serve(version, options = {}) {
126
139
  return pane && session ? { session, terminal: pane.terminal_id } : undefined;
127
140
  },
128
141
  notify: (target, text, deliveryId, computer) => handOff({ computer, target, text, deliveryId }, { notifySender: false }),
129
- send: async (target, text, deliveryId, typing) => await paneRouteOnce({ agentHooks, modelSwitcher, settingsSwitcher, permissionModeSwitcher, codexQuestions, sideQuestions }, new URL("http://phren.local/v1/prompt"), { target, text, deliveryId, hookQueued: true }, {}, typing),
142
+ send: sendPrompt,
130
143
  }) : undefined;
144
+ // Moving a session to another agent (session-move.ts): its hand-off request
145
+ // takes the hand_off path, and the new agent starts through the launch path.
146
+ const mover = new SessionMover({
147
+ snapshot: server => snapshot(server),
148
+ identity: (server, pane) => paneIdentity(server, pane, true),
149
+ terminal: terminalProvider(),
150
+ deliver: (target, text, deliveryId) => handOffs ? handOffs.enqueue({ target, text, deliveryId }) : sendPrompt(target, text, deliveryId, async () => { }),
151
+ // The new agent starts in the folder an agent already ran in, so it is trusted for the new harness too.
152
+ launch: (server, data, options) => launches.run(() => launchSession(server, data, { trustFolder: true, ...options })),
153
+ inventory: () => launchCheckOff() ? Promise.resolve(undefined) : harnessInventoryWithin(2_500),
154
+ transcript: async (target) => transcriptTail(await targetTranscriptPath(target)),
155
+ paneAccount: (server, pane) => paneAccount(paneAccountKey(server, pane.pane_id), typeof pane.terminal_id === "string" ? pane.terminal_id : undefined)?.id,
156
+ paneDispatch: async (server, pane) => (await readTurn(server, String(pane.pane_id)))?.dispatch,
157
+ brief: readLaunchBrief,
158
+ isConductor: async (server, pane) => (await conductorPane(server, await snapshot(server)))?.pane_id === pane.pane_id,
159
+ envAtStart: server => terminalKind(server) === "tmux",
160
+ afterExit: async (server, pane) => { const entry = codexServers.forPane(server, pane); if (entry)
161
+ await codexServers.stop(entry); },
162
+ });
131
163
  const contextUsage = new WorkspaceContextUsage();
132
164
  const accountUsage = options.accountUsage ?? new AccountUsageReader();
165
+ // A Claude launch that names no account runs under the one with the most room (account-choice.ts).
166
+ setChoiceReaders({ usage: () => accountUsage.limits(true) });
133
167
  const resources = new ResourceMonitor();
134
168
  const tabActivity = new TabActivityStore();
135
169
  const codexQuestions = new CodexQuestions(undefined, codexServers);
@@ -194,13 +228,15 @@ export async function serve(version, options = {}) {
194
228
  resources: () => resources.read(),
195
229
  sudo: agentHooks.sudo,
196
230
  });
197
- const http = createServer(createRouteHandler({ version, modules, info, computerID, scheduleStore, scheduler, dispatches, agentHooks,
231
+ // 256 KiB: gitboy's /memory/files asks about up to 500 paths in one query string.
232
+ const http = createServer({ maxHeaderSize: 256 * 1024 }, createRouteHandler({ version, modules, info, computerID, scheduleStore, scheduler, dispatches, agentHooks,
198
233
  journal, tabActivity, contextUsage, modelCatalog, modelSwitcher, settingsSwitcher, permissionModeSwitcher, sideQuestions, accountUsage, resources, codexQuestions, launches, locatedDirectories,
199
- fanoutMessages, canary, streams, returns, handOffs, inbox }));
234
+ fanoutMessages, canary, streams, returns, handOffs, inbox, mover }));
200
235
  http.requestTimeout = 20_000;
201
236
  http.headersTimeout = 10_000;
202
237
  http.maxHeadersCount = 32;
203
238
  const ws = new WebSocketServer({ noServer: true, maxPayload: 65_536, perMessageDeflate: false });
239
+ const socketPools = new Map();
204
240
  http.on("upgrade", (request, socket, head) => {
205
241
  try {
206
242
  const url = new URL(request.url || "/", "http://phren.local");
@@ -211,11 +247,20 @@ export async function serve(version, options = {}) {
211
247
  requireRoute(modules, "WS", url.pathname);
212
248
  // Parsed before the upgrade: an invalid server name is refused as the other routes refuse it.
213
249
  const overviewServer = url.pathname === "/v1/overview" ? selectedServer(url) : undefined;
250
+ // Each client kind has its own pool of 16, so a desktop that holds many
251
+ // sockets never evicts the phone's (and the reverse). The header is a
252
+ // fairness hint between already-authorized clients, not an identity.
253
+ const pool = request.headers["x-phren-client"] === "desktop" ? "desktop" : "default";
214
254
  ws.handleUpgrade(request, socket, head, client => {
215
- while (ws.clients.size > 16) {
216
- const oldest = ws.clients.values().next().value;
255
+ const members = socketPools.get(pool) ?? new Set();
256
+ socketPools.set(pool, members);
257
+ members.add(client);
258
+ client.once("close", () => members.delete(client));
259
+ while (members.size > 16) {
260
+ const oldest = members.values().next().value;
217
261
  oldest.close(1008, "Too many connections; reconnect");
218
262
  oldest.terminate();
263
+ members.delete(oldest);
219
264
  ws.clients.delete(oldest);
220
265
  }
221
266
  if (overviewServer !== undefined) {
@@ -0,0 +1,288 @@
1
+ import { z } from "zod";
2
+ import { moveToSchema } from "./dispatch.js";
3
+ import { type HarnessInventory } from "./harnesses.js";
4
+ import { type Json, type Provider, type StartingTarget, type Target } from "./protocol.js";
5
+ import type { TerminalProvider } from "./terminal.js";
6
+ export { moveToSchema };
7
+ export type MoveTo = z.infer<typeof moveToSchema>;
8
+ export declare const moveRequestSchema: z.ZodObject<{
9
+ target: z.ZodObject<{
10
+ server: z.ZodString;
11
+ workspace: z.ZodString;
12
+ tab: z.ZodString;
13
+ pane: z.ZodString;
14
+ source: z.ZodEnum<{
15
+ claude: "claude";
16
+ codex: "codex";
17
+ copilot: "copilot";
18
+ opencode: "opencode";
19
+ phren: "phren";
20
+ }>;
21
+ session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
22
+ }, z.core.$strip>;
23
+ to: z.ZodObject<{
24
+ harness: z.ZodEnum<{
25
+ claude: "claude";
26
+ codex: "codex";
27
+ copilot: "copilot";
28
+ opencode: "opencode";
29
+ }>;
30
+ account: z.ZodOptional<z.ZodString>;
31
+ model: z.ZodOptional<z.ZodString>;
32
+ effort: z.ZodOptional<z.ZodEnum<{
33
+ high: "high";
34
+ low: "low";
35
+ max: "max";
36
+ medium: "medium";
37
+ minimal: "minimal";
38
+ xhigh: "xhigh";
39
+ }>>;
40
+ }, z.core.$strict>;
41
+ id: z.ZodOptional<z.ZodString>;
42
+ handoffTimeoutMs: z.ZodOptional<z.ZodNumber>;
43
+ }, z.core.$strict>;
44
+ declare const moveRecordSchema: z.ZodObject<{
45
+ id: z.ZodString;
46
+ state: z.ZodEnum<{
47
+ exiting: "exiting";
48
+ failed: "failed";
49
+ "handing-off": "handing-off";
50
+ launching: "launching";
51
+ moved: "moved";
52
+ }>;
53
+ createdAt: z.ZodString;
54
+ updatedAt: z.ZodString;
55
+ from: z.ZodObject<{
56
+ target: z.ZodObject<{
57
+ server: z.ZodString;
58
+ workspace: z.ZodString;
59
+ tab: z.ZodString;
60
+ pane: z.ZodString;
61
+ source: z.ZodEnum<{
62
+ claude: "claude";
63
+ codex: "codex";
64
+ copilot: "copilot";
65
+ opencode: "opencode";
66
+ phren: "phren";
67
+ }>;
68
+ session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
69
+ }, z.core.$strip>;
70
+ account: z.ZodOptional<z.ZodString>;
71
+ label: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strict>;
73
+ to: z.ZodObject<{
74
+ harness: z.ZodEnum<{
75
+ claude: "claude";
76
+ codex: "codex";
77
+ copilot: "copilot";
78
+ opencode: "opencode";
79
+ }>;
80
+ account: z.ZodOptional<z.ZodString>;
81
+ model: z.ZodOptional<z.ZodString>;
82
+ effort: z.ZodOptional<z.ZodEnum<{
83
+ high: "high";
84
+ low: "low";
85
+ max: "max";
86
+ medium: "medium";
87
+ minimal: "minimal";
88
+ xhigh: "xhigh";
89
+ }>>;
90
+ }, z.core.$strict>;
91
+ cwd: z.ZodString;
92
+ dispatch: z.ZodOptional<z.ZodString>;
93
+ handoff: z.ZodOptional<z.ZodObject<{
94
+ path: z.ZodString;
95
+ source: z.ZodEnum<{
96
+ agent: "agent";
97
+ fallback: "fallback";
98
+ }>;
99
+ reason: z.ZodOptional<z.ZodString>;
100
+ chars: z.ZodNumber;
101
+ }, z.core.$strict>>;
102
+ exit: z.ZodOptional<z.ZodEnum<{
103
+ clean: "clean";
104
+ interrupted: "interrupted";
105
+ killed: "killed";
106
+ }>>;
107
+ placement: z.ZodOptional<z.ZodEnum<{
108
+ "adjacent-pane": "adjacent-pane";
109
+ "same-pane": "same-pane";
110
+ }>>;
111
+ target: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
112
+ server: z.ZodString;
113
+ workspace: z.ZodString;
114
+ tab: z.ZodString;
115
+ pane: z.ZodString;
116
+ source: z.ZodEnum<{
117
+ claude: "claude";
118
+ codex: "codex";
119
+ copilot: "copilot";
120
+ opencode: "opencode";
121
+ phren: "phren";
122
+ }>;
123
+ session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ server: z.ZodString;
126
+ workspace: z.ZodString;
127
+ tab: z.ZodString;
128
+ pane: z.ZodString;
129
+ source: z.ZodEnum<{
130
+ claude: "claude";
131
+ codex: "codex";
132
+ copilot: "copilot";
133
+ opencode: "opencode";
134
+ phren: "phren";
135
+ }>;
136
+ starting: z.ZodLiteral<true>;
137
+ startingToken: z.ZodString;
138
+ }, z.core.$strip>]>>;
139
+ movedAt: z.ZodOptional<z.ZodString>;
140
+ error: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strict>;
142
+ export type MoveRecord = z.infer<typeof moveRecordSchema>;
143
+ /** What a dispatching Hook records on its receipt when its worker moved. */
144
+ export interface MovedWorker {
145
+ id: string;
146
+ at: string;
147
+ handoff?: string;
148
+ from: {
149
+ harness: Provider;
150
+ account?: string;
151
+ };
152
+ to: MoveTo;
153
+ target: Target | StartingTarget;
154
+ }
155
+ export declare function movesRoot(): string;
156
+ /** The hand-off sits beside the new agent's brief, in a folder Claude is given read access to. */
157
+ export declare const handoffPath: (id: string) => string;
158
+ export declare function readMove(id: string): Promise<MoveRecord | undefined>;
159
+ /** Recent moves, newest first; old ones are removed on the way. */
160
+ export declare function listMoves(now?: number): Promise<MoveRecord[]>;
161
+ /** The move that took the agent out of `target`'s pane: a target with a
162
+ * conversation matches only that conversation; a starting one, the pane. */
163
+ export declare function moveFrom(records: readonly MoveRecord[], target: {
164
+ server: string;
165
+ pane: string;
166
+ source: string;
167
+ session?: string;
168
+ }): MoveRecord | undefined;
169
+ /** The receipt fields for a finished move. */
170
+ export declare function movedWorker(record: MoveRecord): MovedWorker | undefined;
171
+ /** A harness as people name it, with its account and model: "Claude (work, opus)". */
172
+ export declare function harnessName(to: {
173
+ harness: string;
174
+ account?: string;
175
+ model?: string;
176
+ effort?: string;
177
+ }): string;
178
+ /** What the moving agent is asked to write. */
179
+ export declare function handoffRequest(id: string, to: MoveTo): string;
180
+ /** The hand-off between the markers in the agent's replies after the request,
181
+ * or undefined while its end marker has not arrived. Code fences around the
182
+ * block are dropped. */
183
+ export declare function extractHandoff(replies: readonly string[], id: string): string | undefined;
184
+ /** One message from a conversation's tail. */
185
+ export interface TailEntry {
186
+ role: "owner" | "agent";
187
+ text: string;
188
+ }
189
+ /** The owner's prompts and the agent's replies in a transcript's lines, oldest first. */
190
+ export declare function conversationEntries(lines: readonly string[], source: Provider): TailEntry[];
191
+ /** The agent's replies after the move's request: the request names the move, so an older hand-off never counts. */
192
+ export declare function repliesAfterRequest(entries: readonly TailEntry[], id: string): string[];
193
+ /** What `git` shows in the checkout at the move. */
194
+ export interface GitState {
195
+ root: string;
196
+ branch?: string;
197
+ head?: string;
198
+ upstream?: string;
199
+ ahead?: number;
200
+ behind?: number;
201
+ /** `git status --porcelain` lines: every change, tracked or not. */
202
+ changes: string[];
203
+ }
204
+ export declare function readGitState(directory: string): Promise<GitState | undefined>;
205
+ /** The commands of every process below `pids` (the agent's own children), not the agent itself. */
206
+ export declare function processesBelow(pids: readonly number[]): Promise<string[]>;
207
+ /** What Phren itself saw at the move, appended to every hand-off. */
208
+ export declare function observedState(git: GitState | undefined, processes: readonly string[]): string;
209
+ /** A hand-off built without the agent: the conversation's tail, the original brief and the git state. */
210
+ export declare function fallbackHandoff(input: {
211
+ reason: string;
212
+ from: string;
213
+ entries: readonly TailEntry[];
214
+ original?: string;
215
+ dispatch?: string;
216
+ label?: string;
217
+ }): string;
218
+ /** The hand-off file: who moved where and when, the body, then what Phren saw. */
219
+ export declare function handoffDocument(record: MoveRecord, body: string, observed: string, at: string): string;
220
+ /** The new agent's first prompt: the whole hand-off when it fits the brief, else where to read it. */
221
+ export declare function continuePrompt(document: string, file: string): string;
222
+ export interface MoverDeps {
223
+ snapshot: (server: string) => Promise<Json>;
224
+ /** The conversation the pane runs now. */
225
+ identity: (server: string, pane: Json) => Promise<string | undefined>;
226
+ terminal: Pick<TerminalProvider, "prompt" | "sendKeys" | "processes" | "closePane">;
227
+ /** The `hand_off` delivery path: queued while the agent is busy. */
228
+ deliver: (target: Target, text: string, deliveryId: string) => Promise<Json>;
229
+ /** Starts the new agent (`startSession`), in `into` when given. */
230
+ launch: (server: string, data: Json, options: {
231
+ into?: {
232
+ workspaceId: string;
233
+ tabId: string;
234
+ paneId: string;
235
+ };
236
+ dispatchId?: string;
237
+ }) => Promise<Json>;
238
+ inventory: () => Promise<HarnessInventory | undefined>;
239
+ /** The conversation's transcript lines, its tail is enough. */
240
+ transcript: (target: Target) => Promise<string[]>;
241
+ git?: (directory: string) => Promise<GitState | undefined>;
242
+ processesBelow?: (pids: readonly number[]) => Promise<string[]>;
243
+ /** The Claude account the pane runs under, when known. */
244
+ paneAccount?: (server: string, pane: Json) => string | undefined;
245
+ /** The dispatch the pane's agent was launched for. */
246
+ paneDispatch?: (server: string, pane: Json) => Promise<string | undefined>;
247
+ /** The text of a brief this computer wrote. */
248
+ brief?: (id: string) => Promise<string | undefined>;
249
+ /** Whether the pane holds this computer's conductor. */
250
+ isConductor?: (server: string, pane: Json) => Promise<boolean>;
251
+ /** Herdr gives a pane its variables only when it is created; tmux sets them on every start. */
252
+ envAtStart?: (server: string) => boolean;
253
+ /** Cleanup after the old agent exited (a Codex pane's app-server). */
254
+ afterExit?: (server: string, pane: string) => Promise<void>;
255
+ kill?: (pid: number, signal: NodeJS.Signals) => void;
256
+ now?: () => number;
257
+ sleep?: (ms: number) => Promise<void>;
258
+ pollMs?: number;
259
+ /** How long a clean exit, then an interrupt, may take before the agent counts as hung. */
260
+ exitMs?: number;
261
+ }
262
+ /** Runs moves on the computer that runs the session. A move outlives the
263
+ * request that started it (the Hook answers in seconds); its record says where it is. */
264
+ export declare class SessionMover {
265
+ private readonly deps;
266
+ private readonly running;
267
+ constructor(deps: MoverDeps);
268
+ private get now();
269
+ private sleep;
270
+ private get poll();
271
+ /** Checks the move can happen, records it and starts it. Refuses before anything is typed. */
272
+ start(input: unknown): Promise<MoveRecord>;
273
+ /** For tests: the move under way in a pane, until it settles. */
274
+ settled(server: string, pane: string): Promise<void> | undefined;
275
+ private update;
276
+ private run;
277
+ /** The agent's own hand-off, or why there is none. Fails only when the session itself went away. */
278
+ private askForHandoff;
279
+ private fallback;
280
+ /** Ends the old agent with its own exit command; an interrupt, then a kill, only when it hangs. */
281
+ private exit;
282
+ /** Starts the target in the old pane when its shell has what the target needs, else in a new tab beside it. */
283
+ private relaunch;
284
+ /** The new agent's full target, waiting a little for its conversation id when the launch did not have it yet. */
285
+ private newTarget;
286
+ }
287
+ /** The last `bytes` of a transcript as lines, the first (cut) one dropped. */
288
+ export declare function transcriptTail(file: string, bytes?: number): Promise<string[]>;