@phren/cli 0.3.47 → 0.3.49

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.
@@ -286,10 +286,10 @@ export const gitboy = {
286
286
  return { ok: false, reason: result.reason ?? "failed", message: result.message ?? "gitboy refused the merge." };
287
287
  }
288
288
  },
289
- async whoami(root, host, token) {
289
+ async whoami(root, host, token, checkedApi) {
290
290
  if (!host.domain)
291
291
  throw new HostApiError("failed", "This repository has no gitboy remote.");
292
- const api = await apiRoot(root, host.domain, `https://${host.domain}/api/v1`);
292
+ const api = checkedApi ?? await apiRoot(root, host.domain, `https://${host.domain}/api/v1`);
293
293
  const { json } = await hostJson(`${api}/user`, { token, scheme: "bearer" });
294
294
  return { user: String(obj(json).username ?? "") };
295
295
  },
@@ -219,10 +219,10 @@ export const gitlab = {
219
219
  return { ok: false, reason: result.reason ?? "failed", message: result.message ?? "GitLab refused the merge." };
220
220
  }
221
221
  },
222
- async whoami(root, host, token) {
222
+ async whoami(root, host, token, checkedApi) {
223
223
  if (!host.domain)
224
224
  throw new HostApiError("failed", "This repository has no GitLab remote.");
225
- const base = await apiRoot(root, host.domain, `https://${host.domain}/api/v4`);
225
+ const base = checkedApi ?? await apiRoot(root, host.domain, `https://${host.domain}/api/v4`);
226
226
  const { json } = await hostJson(`${base}/user`, { token, scheme: "private-token" });
227
227
  return { user: String(obj(json).username ?? "") };
228
228
  },
@@ -16,6 +16,15 @@ export declare class HostApiError extends Error {
16
16
  * writable by whatever runs in the checkout, and must never be able to send
17
17
  * a stored token to another server. */
18
18
  export declare function apiRoot(root: string, domain: string, fallback: string): Promise<string>;
19
+ /** Resolve the exact endpoint once, so Connect can check and use the same URL.
20
+ * Only the hostname/port is exposed to clients, never API URL credentials. */
21
+ export declare function tokenDestination(root: string, host: {
22
+ kind: string | null;
23
+ domain: string | null;
24
+ }): Promise<{
25
+ api: string | null;
26
+ apiHost: string | null;
27
+ }>;
19
28
  export interface HostRequest {
20
29
  token?: string;
21
30
  /** How the token is sent: GitLab's PRIVATE-TOKEN header or a bearer token. */
@@ -20,6 +20,17 @@ export async function apiRoot(root, domain, fallback) {
20
20
  const configured = (await git(root, "config", "--global", "--get", `phren.${domain}.api`).catch(() => "")).trim();
21
21
  return (configured || fallback).replace(/\/+$/, "");
22
22
  }
23
+ /** Resolve the exact endpoint once, so Connect can check and use the same URL.
24
+ * Only the hostname/port is exposed to clients, never API URL credentials. */
25
+ export async function tokenDestination(root, host) {
26
+ if (!host.domain || (host.kind !== "gitlab" && host.kind !== "gitboy"))
27
+ return { api: null, apiHost: host.domain };
28
+ const api = await apiRoot(root, host.domain, `https://${host.domain}/api/${host.kind === "gitlab" ? "v4" : "v1"}`);
29
+ const url = new URL(api);
30
+ if (!["https:", "http:"].includes(url.protocol) || !url.host)
31
+ throw new HostApiError("failed", "Invalid git host API address.");
32
+ return { api, apiHost: url.host.toLowerCase() };
33
+ }
23
34
  export async function hostJson(url, request) {
24
35
  const headers = { accept: "application/json", "user-agent": "phren-hook" };
25
36
  if (request.token) {
@@ -22,6 +22,8 @@ export interface GitHost {
22
22
  name: string;
23
23
  /** The remote's domain and the repository's web address, when known. */
24
24
  domain: string | null;
25
+ /** Actual token destination (including a configured API port), when resolved. */
26
+ apiHost?: string | null;
25
27
  webUrl: string | null;
26
28
  remote: string | null;
27
29
  /** How the kind was found: from the URL, from an override, or not at all. */
@@ -56,7 +58,7 @@ export interface GitHostProvider {
56
58
  * comes back as `{ ok: false, reason: "blocked", message }`. */
57
59
  merge(root: string, request: MergeRequest, host: GitHost): Promise<Json>;
58
60
  /** Who a token signs in as, for Connect; HTTP hosts only. */
59
- whoami?(root: string, host: GitHost, token: string): Promise<{
61
+ whoami?(root: string, host: GitHost, token: string, api?: string): Promise<{
60
62
  user: string;
61
63
  }>;
62
64
  }
@@ -7,7 +7,7 @@ import { defaultBranch, invalidatePulls, invalidateTree } from "./git.js";
7
7
  import { z } from "zod";
8
8
  import { detectHost, providerFor, unknownHost } from "./git-hosts.js";
9
9
  import { writeHostToken } from "./git-host-auth.js";
10
- import { HostApiError } from "./git-host-http.js";
10
+ import { HostApiError, tokenDestination } from "./git-host-http.js";
11
11
  /** Finishing a session from the phone: commit what is staged, push the
12
12
  * current branch, open a pull request. Each acts on the repository the
13
13
  * existing /v1/git/* routes resolve (the pane's, a child's worktree, or a
@@ -231,16 +231,22 @@ export async function gitMergeRequest(cwd, data) {
231
231
  * gitboy host: the token is checked against the host first and stored in the
232
232
  * Hook's git-hosts.json with the account it signs in as. GitHub keeps gh's. */
233
233
  export async function gitHostToken(cwd, data) {
234
- const { token } = z.object({ token: z.string().max(4096) }).parse(data);
234
+ const { token, expectedHost } = z.object({ token: z.string().max(4096), expectedHost: z.string().trim().min(1).max(253).optional() }).parse(data);
235
235
  const root = await repository(cwd);
236
236
  const branch = (await git(root, "branch", "--show-current").catch(() => "")).trim();
237
237
  const host = await detectHost(root, branch);
238
+ const { api, apiHost } = await tokenDestination(root, host);
239
+ host.apiHost = apiHost;
240
+ // Pin the resolved endpoint through validation, even if config changes now.
241
+ if (expectedHost !== undefined && apiHost !== expectedHost.toLowerCase()) {
242
+ throw new BridgeError(409, "The project's remote changed. Reopen to review the new host.", { code: "host-changed" });
243
+ }
238
244
  const provider = providerFor(host);
239
245
  if (!provider || !host.domain || !host.kind) {
240
246
  const { reason, message } = unknownHost(host);
241
247
  return { ok: false, reason, message, host };
242
248
  }
243
- if (host.kind === "github" || !provider.whoami)
249
+ if (host.kind === "github" || !provider.whoami || !api)
244
250
  return { ok: false, reason: "unsupported", message: "GitHub uses the GitHub CLI's sign-in: run gh auth login on this computer.", host };
245
251
  const kind = host.kind;
246
252
  if (!token.trim()) {
@@ -248,13 +254,14 @@ export async function gitHostToken(cwd, data) {
248
254
  return { ok: true, disconnected: true, domain: host.domain, host };
249
255
  }
250
256
  try {
251
- const { user } = await provider.whoami(root, host, token.trim());
257
+ const identity = await provider.whoami(root, host, token.trim(), api);
258
+ const user = identity.user.replaceAll(token.trim(), "[redacted]");
252
259
  await writeHostToken(host.domain, kind, token.trim(), user || undefined);
253
260
  return { ok: true, domain: host.domain, kind, ...(user ? { user } : {}), host };
254
261
  }
255
262
  catch (error) {
256
263
  if (error instanceof HostApiError)
257
- return { ok: false, reason: error.reason, message: error.reason === "auth" ? `${host.name} refused that token.` : error.message, host };
264
+ return { ok: false, reason: error.reason, message: error.reason === "auth" ? `${host.name} refused that token.` : `${host.name} could not validate that token.`, host };
258
265
  throw error;
259
266
  }
260
267
  }
@@ -1,4 +1,5 @@
1
1
  import { type Json } from "./protocol.js";
2
+ import { detectHost } from "./git-hosts.js";
2
3
  export { checkRollup, checkRuns } from "./git-hosts.js";
3
4
  interface Counts {
4
5
  additions: number;
@@ -40,6 +41,7 @@ export interface GitStatus {
40
41
  files: GitStatusFile[];
41
42
  /** The branch a push guards: the upstream remote's `HEAD`, else `main`/`master`. */
42
43
  defaultBranch: string | null;
44
+ host: Awaited<ReturnType<typeof detectHost>>;
43
45
  }
44
46
  /** Working-tree status, one record per section: a file edited in both the index
45
47
  * and the working tree appears once with `staged: true` and once with `false`. */
@@ -4,6 +4,7 @@ import { lstat, open, readdir, realpath } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { BridgeError } from "./protocol.js";
6
6
  import { git, gitHead, gitRoot, withGitReadDeadline, withIndependentGitReadDeadline, withoutGitReadDeadline } from "./projects.js";
7
+ import { tokenDestination } from "./git-host-http.js";
7
8
  import { detectHost, providerFor, unknownHost } from "./git-hosts.js";
8
9
  import { hostCredentialIdentity } from "./git-host-auth.js";
9
10
  import { LookupCache } from "./lookup-cache.js";
@@ -130,6 +131,9 @@ async function readGitStatus(cwd, untrackedPath) {
130
131
  treeCache.delete(root);
131
132
  const data = await collect(root);
132
133
  const fallback = await defaultBranch(root, data.upstream?.split("/")[0] || "origin");
134
+ const host = await detectHost(root, data.branch);
135
+ const { apiHost } = await tokenDestination(root, host);
136
+ host.apiHost = apiHost;
133
137
  if (untrackedPath !== undefined) {
134
138
  const prefix = await repositoryPath(root, untrackedPath);
135
139
  if (!data.untracked.some(file => file.endsWith("/") && (prefix + "/").startsWith(file))
@@ -177,7 +181,7 @@ async function readGitStatus(cwd, untrackedPath) {
177
181
  branch: data.branch, upstream: data.upstream ?? null, ahead: data.ahead, behind: data.behind,
178
182
  staged: data.staged.size, unstaged: data.unstaged.size, untracked: data.untracked.length,
179
183
  additions: files.reduce((total, file) => total + file.additions, 0), deletions: files.reduce((total, file) => total + file.deletions, 0), files,
180
- defaultBranch: fallback };
184
+ defaultBranch: fallback, host };
181
185
  }
182
186
  /** The repository's remotes, so a branch ref can be told from a remote-tracking
183
187
  * one even when a local branch name contains a slash. */
@@ -330,7 +334,9 @@ export async function gitPulls(cwd, retried = false) {
330
334
  const { root, branch, host } = await withIndependentGitReadDeadline(async () => {
331
335
  const root = await repository(cwd);
332
336
  const branch = (await git(root, "branch", "--show-current").catch(() => "")).trim();
333
- return { root, branch, host: await detectHost(root, branch) };
337
+ const host = await detectHost(root, branch);
338
+ const { apiHost } = await tokenDestination(root, host);
339
+ return { root, branch, host: { ...host, apiHost } };
334
340
  });
335
341
  const provider = providerFor(host);
336
342
  const credential = await credentialIdentity(host);
@@ -593,14 +593,20 @@ export async function panes(server, workspace, tab) {
593
593
  if (!objects(s.tabs).some(t => t.tab_id === tab && t.workspace_id === workspace))
594
594
  throw new BridgeError(409, "This terminal tab has changed. Refresh the computer.");
595
595
  const mux = (await terminal()).terminalMux(server);
596
+ // Loaded lazily: session-move imports this module, and a static import back makes a cycle.
597
+ const { listMoves, moveSessionFields } = await import("./session-move.js");
598
+ const moves = await listMoves();
596
599
  return { kind: mux.kind, mux, groupId: workspace, childId: tab, panes: await Promise.all(objects(s.panes)
597
600
  .filter(p => p.workspace_id === workspace && p.tab_id === tab).map(async (p) => {
598
601
  const chat = await paneChatState(server, p);
599
602
  const record = await paneRecord(server, p, typeof chat.sessionId === "string" ? chat.sessionId : undefined);
600
603
  const t = objects(s.tabs).find(candidate => candidate.tab_id === tab && candidate.workspace_id === workspace);
601
604
  const w = objects(s.workspaces).find(candidate => candidate.workspace_id === workspace);
605
+ const title = await recordTitle(record, { paneLabel: p.label, harnessTitle: p.title || p.terminal_title_stripped, tabLabel: t?.label, workspaceLabel: w?.label, fallbackLabel: p.label || p.pane_id });
606
+ const moveFields = typeof chat.sessionId === "string" && provider.safeParse(p.agent).success
607
+ ? moveSessionFields(moves, { server, workspace, tab, pane: String(p.pane_id), source: p.agent, session: chat.sessionId }, title) : {};
602
608
  return { id: p.pane_id, label: p.label || p.pane_id, agent: p.agent, agentStatus: p.agent_status,
603
- title: await recordTitle(record, { paneLabel: p.label, harnessTitle: p.title || p.terminal_title_stripped, tabLabel: t?.label, workspaceLabel: w?.label, fallbackLabel: p.label || p.pane_id }),
609
+ title, ...moveFields,
604
610
  cwd: p.foreground_cwd || p.cwd, ...chat, ...paneAccountField(server, p) };
605
611
  })) };
606
612
  }
@@ -1,8 +1,9 @@
1
1
  import { type Json } from "./protocol.js";
2
- /** `GET /v1/projects/:project/git`: the project's host, branch and open pull
2
+ /** Project git reads and token Connect share the same checkout lookup.
3
+ * `GET /v1/projects/:project/git`: the project's host, branch and open pull
3
4
  * requests with their checks, read from its checkout on this computer, so the
4
5
  * desktop's Projects page needs no session running there. */
5
6
  export declare const PROJECT_GIT_ROUTE: RegExp;
6
- /** The recorded source folder for this computer wins; otherwise the folders
7
- * `/v1/projects/locate` offers, newest session first. */
8
7
  export declare function projectGit(base: string, rawProject: string, activity: Json[]): Promise<Json>;
8
+ /** No pull-list read here: resolve locally before passing a token to the host. */
9
+ export declare function projectHostToken(base: string, rawProject: string, activity: Json[], data: unknown): Promise<Json>;
@@ -1,17 +1,20 @@
1
+ import { z } from "zod";
1
2
  import { getProjectSourcePath } from "../project-config.js";
2
3
  import { resolveProject } from "../store-routing.js";
3
4
  import { isValidProjectName } from "../utils.js";
5
+ import { gitHostToken } from "./git-publish.js";
4
6
  import { gitPulls } from "./git.js";
5
7
  import { locateProject } from "./locate.js";
6
8
  import { gitRoot } from "./projects.js";
7
9
  import { BridgeError } from "./protocol.js";
8
- /** `GET /v1/projects/:project/git`: the project's host, branch and open pull
10
+ /** Project git reads and token Connect share the same checkout lookup.
11
+ * `GET /v1/projects/:project/git`: the project's host, branch and open pull
9
12
  * requests with their checks, read from its checkout on this computer, so the
10
13
  * desktop's Projects page needs no session running there. */
11
- export const PROJECT_GIT_ROUTE = /^\/v1\/projects\/([^/]+)\/git$/;
14
+ export const PROJECT_GIT_ROUTE = /^\/v1\/projects\/([^/]+)\/git(?:\/(host-token))?$/;
12
15
  /** The recorded source folder for this computer wins; otherwise the folders
13
16
  * `/v1/projects/locate` offers, newest session first. */
14
- export async function projectGit(base, rawProject, activity) {
17
+ async function projectCheckout(base, rawProject, activity) {
15
18
  let project;
16
19
  try {
17
20
  project = decodeURIComponent(rawProject);
@@ -33,7 +36,17 @@ export async function projectGit(base, rawProject, activity) {
33
36
  for (const folder of folders) {
34
37
  const root = await gitRoot(folder).catch(() => undefined);
35
38
  if (root)
36
- return { project, directory: root, ...(await gitPulls(root)) };
39
+ return { project, directory: root };
37
40
  }
38
41
  throw new BridgeError(404, "No checkout of this project on this computer.", { code: "no-checkout" });
39
42
  }
43
+ export async function projectGit(base, rawProject, activity) {
44
+ const checkout = await projectCheckout(base, rawProject, activity);
45
+ return { ...checkout, ...(await gitPulls(checkout.directory)) };
46
+ }
47
+ /** No pull-list read here: resolve locally before passing a token to the host. */
48
+ export async function projectHostToken(base, rawProject, activity, data) {
49
+ const request = z.object({ token: z.string().max(4096), expectedHost: z.string().trim().min(1).max(253) }).parse(data);
50
+ const checkout = await projectCheckout(base, rawProject, activity);
51
+ return gitHostToken(checkout.directory, request);
52
+ }
@@ -64,8 +64,8 @@ export const requestID = () => randomUUID();
64
64
  export async function atomic(file, value, mode = 0o600) {
65
65
  const temporary = `${file}.${randomUUID()}.tmp`;
66
66
  const text = typeof value === "string" ? value : JSON.stringify(value);
67
- await writeFile(temporary, text, { mode, flag: "wx" });
68
67
  try {
68
+ await writeFile(temporary, text, { mode, flag: "wx" });
69
69
  await renameOver(temporary, file);
70
70
  }
71
71
  finally {
@@ -134,12 +134,14 @@ export declare const capabilities: {
134
134
  agentFolder: boolean;
135
135
  launchPermissionMode: boolean;
136
136
  sessionMove: boolean;
137
+ moveNewChat: boolean;
137
138
  projectMemory: boolean;
138
139
  fileWrite: boolean;
139
140
  fileSearch: boolean;
140
141
  gitReview: boolean;
141
142
  memoryStoreBatch: boolean;
142
143
  gitHosts: boolean;
144
+ projectHostToken: boolean;
143
145
  };
144
146
  export declare function capabilitiesForModules(snapshot: ModuleSnapshot): Record<string, unknown>;
145
147
  export declare function requireRoute(snapshot: ModuleSnapshot, method: string, route: string): void;
@@ -1,4 +1,4 @@
1
- import { listMoves, readMove } from "./session-move.js";
1
+ import { listMoves, moveSessionFields, readMove } from "./session-move.js";
2
2
  import { getTaskRoute, getTaskDirectoryRoute, updateTaskRoute, createTaskRoute, saveTaskRoute, launchTaskRoute } from "./task-routes.js";
3
3
  import { ownerInboxView } from "./owner-inbox-view.js";
4
4
  import { closeFinishedWorker, closeOwnPane } from "./worker-close.js";
@@ -28,7 +28,7 @@ import { MAX_FILE_RANGE, rangeInteger, readFileRange } from "./file-range.js";
28
28
  import { resolveFilePath } from "./file-resolve.js";
29
29
  import { storeRoute } from "./memory-store.js";
30
30
  import { memoryForFiles, memorySearch, PROJECT_MEMORY_ROUTE, projectMemory, saveFinding, tasksForBranch, completeProjectTask } from "./project-memory.js";
31
- import { PROJECT_GIT_ROUTE, projectGit } from "./project-git.js";
31
+ import { PROJECT_GIT_ROUTE, projectGit, projectHostToken } from "./project-git.js";
32
32
  import { liveBackground, markBackground, paneRecord, recordTitle, replyExcerpt } from "./session-activity.js";
33
33
  import { paneAccountField, paneChatState, panes, rpc, servers, snapshot, validateTarget, workspaceSnapshot } from "./herdr.js";
34
34
  import { locateProject } from "./locate.js";
@@ -81,7 +81,7 @@ async function childActivity(source, session) {
81
81
  export const capabilities = { transcript: true, progress: true, images: true, prompt: true, stop: true,
82
82
  terminal: "ssh-pty", shell: "ssh-pty", paneTerminal: "ssh-pty", paneLayout: true, deskPresence: true, herdr: true, sessionRename: true, diff: true, webServers: true, webPreview: "ssh-exec", activity: true,
83
83
  approvals: true, questions: false, accountUsage: true, providers: ["codex", "claude", "copilot", "opencode"],
84
- files: true, repositoryFiles: true, fileResolution: true, subagents: true, sideQuestions: true, dispatch: true, conductorSets: true, setLink: true, ownerInbox: true, workerReports: true, queuedHandOff: true, approvalPush: "direct-apns", simulators: process.platform === "darwin", code: true, codeFiles: true, overviewStream: true, speech: true, speechTimestamps: true, speechTimestampStream: true, speechLive: true, speechVoices: true, speechFormats: [...SPEECH_FORMATS], transcribe: true, memoryStore: true, promptOnce: true, promptStatus: true, deliveryFrames: true, paneDeliveries: true, resources: true, sudo: true, sudoOutcome: true, previewDeltas: true, quickChat: true, agentFolder: true, launchPermissionMode: true, sessionMove: true, projectMemory: true, fileWrite: true, fileSearch: true, gitReview: true, memoryStoreBatch: true, gitHosts: true };
84
+ files: true, repositoryFiles: true, fileResolution: true, subagents: true, sideQuestions: true, dispatch: true, conductorSets: true, setLink: true, ownerInbox: true, workerReports: true, queuedHandOff: true, approvalPush: "direct-apns", simulators: process.platform === "darwin", code: true, codeFiles: true, overviewStream: true, speech: true, speechTimestamps: true, speechTimestampStream: true, speechLive: true, speechVoices: true, speechFormats: [...SPEECH_FORMATS], transcribe: true, memoryStore: true, promptOnce: true, promptStatus: true, deliveryFrames: true, paneDeliveries: true, resources: true, sudo: true, sudoOutcome: true, previewDeltas: true, quickChat: true, agentFolder: true, launchPermissionMode: true, sessionMove: true, moveNewChat: true, projectMemory: true, fileWrite: true, fileSearch: true, gitReview: true, memoryStoreBatch: true, gitHosts: true, projectHostToken: true };
85
85
  export function capabilitiesForModules(snapshot) {
86
86
  const allowed = new Set(snapshot.modules.flatMap(module => module.capabilities));
87
87
  const result = Object.fromEntries(Object.entries(capabilities).filter(([name]) => allowed.has(name)));
@@ -166,6 +166,8 @@ export function workspacesReader(ctx) {
166
166
  agents.push(pane);
167
167
  agentsByTab.set(key, agents);
168
168
  }
169
+ // Move records are decoration: read alongside the rest, inside the budget.
170
+ const movesRead = listMoves().catch(() => []);
169
171
  const tabs = objects(workspaces.groups).flatMap(group => objects(group.children).map(tab => ({ group, tab })));
170
172
  // What a chat needs to open (the exact conversation) comes straight from the
171
173
  // chat states; everything below it is decoration.
@@ -214,6 +216,12 @@ export function workspacesReader(ctx) {
214
216
  return;
215
217
  Object.assign(tab, stall);
216
218
  tab.title = title;
219
+ if (target.success) {
220
+ const moves = await movesRead;
221
+ if (expired)
222
+ return;
223
+ Object.assign(tab, moveSessionFields(moves, target.data, title));
224
+ }
217
225
  // What a finished turn said last; a row still working (background work) has no last word yet.
218
226
  const reply = tab.agentStatus === "working" ? undefined : replyExcerpt(record);
219
227
  if (reply)
@@ -344,11 +352,14 @@ export function createRouteHandler(ctx) {
344
352
  result = await saveFinding(modules.store, project, await body(request));
345
353
  }
346
354
  else if (PROJECT_GIT_ROUTE.test(url.pathname)) {
347
- if (request.method !== "GET")
355
+ const [, project, tokenRoute] = PROJECT_GIT_ROUTE.exec(url.pathname);
356
+ if (request.method !== (tokenRoute ? "POST" : "GET"))
348
357
  throw new BridgeError(405, "Unsupported request method.");
349
358
  if (!modules.has("git"))
350
359
  throw new BridgeError(404, disabledHint("git"));
351
- result = await projectGit(modules.store, PROJECT_GIT_ROUTE.exec(url.pathname)[1], await journal.recent());
360
+ result = tokenRoute
361
+ ? await projectHostToken(modules.store, project, await journal.recent(), await body(request))
362
+ : await projectGit(modules.store, project, await journal.recent());
352
363
  }
353
364
  else if (url.pathname.startsWith("/v1/store/")) {
354
365
  result = await storeRoute(modules.store, request.method ?? "", url, request.method === "POST" ? await body(request) : undefined);
@@ -38,6 +38,10 @@ export declare const moveRequestSchema: z.ZodObject<{
38
38
  xhigh: "xhigh";
39
39
  }>>;
40
40
  }, z.core.$strict>;
41
+ mode: z.ZodDefault<z.ZodEnum<{
42
+ "new-chat": "new-chat";
43
+ replace: "replace";
44
+ }>>;
41
45
  id: z.ZodOptional<z.ZodString>;
42
46
  handoffTimeoutMs: z.ZodOptional<z.ZodNumber>;
43
47
  }, z.core.$strict>;
@@ -48,6 +52,7 @@ declare const moveRecordSchema: z.ZodObject<{
48
52
  failed: "failed";
49
53
  "handing-off": "handing-off";
50
54
  launching: "launching";
55
+ linking: "linking";
51
56
  moved: "moved";
52
57
  }>;
53
58
  createdAt: z.ZodString;
@@ -88,6 +93,57 @@ declare const moveRecordSchema: z.ZodObject<{
88
93
  xhigh: "xhigh";
89
94
  }>>;
90
95
  }, z.core.$strict>;
96
+ mode: z.ZodOptional<z.ZodEnum<{
97
+ "new-chat": "new-chat";
98
+ replace: "replace";
99
+ }>>;
100
+ handedOffTo: z.ZodOptional<z.ZodObject<{
101
+ target: z.ZodUnion<readonly [z.ZodObject<{
102
+ server: z.ZodString;
103
+ workspace: z.ZodString;
104
+ tab: z.ZodString;
105
+ pane: z.ZodString;
106
+ source: z.ZodEnum<{
107
+ claude: "claude";
108
+ codex: "codex";
109
+ copilot: "copilot";
110
+ opencode: "opencode";
111
+ phren: "phren";
112
+ }>;
113
+ session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ server: z.ZodString;
116
+ workspace: z.ZodString;
117
+ tab: z.ZodString;
118
+ pane: z.ZodString;
119
+ source: z.ZodEnum<{
120
+ claude: "claude";
121
+ codex: "codex";
122
+ copilot: "copilot";
123
+ opencode: "opencode";
124
+ phren: "phren";
125
+ }>;
126
+ starting: z.ZodLiteral<true>;
127
+ startingToken: z.ZodString;
128
+ }, z.core.$strip>]>;
129
+ }, z.core.$strict>>;
130
+ handedOffFrom: z.ZodOptional<z.ZodObject<{
131
+ target: z.ZodObject<{
132
+ server: z.ZodString;
133
+ workspace: z.ZodString;
134
+ tab: z.ZodString;
135
+ pane: z.ZodString;
136
+ source: z.ZodEnum<{
137
+ claude: "claude";
138
+ codex: "codex";
139
+ copilot: "copilot";
140
+ opencode: "opencode";
141
+ phren: "phren";
142
+ }>;
143
+ session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
144
+ }, z.core.$strip>;
145
+ title: z.ZodString;
146
+ }, z.core.$strict>>;
91
147
  cwd: z.ZodString;
92
148
  dispatch: z.ZodOptional<z.ZodString>;
93
149
  handoff: z.ZodOptional<z.ZodObject<{
@@ -136,6 +192,21 @@ declare const moveRecordSchema: z.ZodObject<{
136
192
  starting: z.ZodLiteral<true>;
137
193
  startingToken: z.ZodString;
138
194
  }, z.core.$strip>]>>;
195
+ paneTarget: z.ZodOptional<z.ZodObject<{
196
+ server: z.ZodString;
197
+ workspace: z.ZodString;
198
+ tab: z.ZodString;
199
+ pane: z.ZodString;
200
+ source: z.ZodEnum<{
201
+ claude: "claude";
202
+ codex: "codex";
203
+ copilot: "copilot";
204
+ opencode: "opencode";
205
+ phren: "phren";
206
+ }>;
207
+ }, z.core.$strip>>;
208
+ linkPending: z.ZodOptional<z.ZodBoolean>;
209
+ notice: z.ZodOptional<z.ZodString>;
139
210
  movedAt: z.ZodOptional<z.ZodString>;
140
211
  error: z.ZodOptional<z.ZodString>;
141
212
  }, z.core.$strict>;
@@ -166,6 +237,8 @@ export declare function moveFrom(records: readonly MoveRecord[], target: {
166
237
  source: string;
167
238
  session?: string;
168
239
  }): MoveRecord | undefined;
240
+ /** Conversation-bound annotations shared by tab and pane overview rows. */
241
+ export declare function moveSessionFields(records: readonly MoveRecord[], target: Target, title?: string): Json;
169
242
  /** The receipt fields for a finished move. */
170
243
  export declare function movedWorker(record: MoveRecord): MovedWorker | undefined;
171
244
  /** A harness as people name it, with its account and model: "Claude (work, opus)". */
@@ -176,7 +249,7 @@ export declare function harnessName(to: {
176
249
  effort?: string;
177
250
  }): string;
178
251
  /** What the moving agent is asked to write. */
179
- export declare function handoffRequest(id: string, to: MoveTo): string;
252
+ export declare function handoffRequest(id: string, to: MoveTo, mode?: "replace" | "new-chat"): string;
180
253
  /** The hand-off between the markers in the agent's replies after the request,
181
254
  * or undefined while its end marker has not arrived. Code fences around the
182
255
  * block are dropped. */
@@ -281,7 +354,7 @@ export declare class SessionMover {
281
354
  private exit;
282
355
  /** Starts the target in the old pane when its shell has what the target needs, else in a new tab beside it. */
283
356
  private relaunch;
284
- /** The new agent's full target, waiting a little for its conversation id when the launch did not have it yet. */
357
+ /** New chats remain open as linking while the harness establishes its conversation. */
285
358
  private newTarget;
286
359
  }
287
360
  /** The last `bytes` of a transcript as lines, the first (cut) one dropped. */