@phren/cli 0.3.61 → 0.3.63

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.
@@ -0,0 +1,25 @@
1
+ export type ClaudeQueueAction = "send-now" | "withdraw";
2
+ export interface ClaudeQueueDeps {
3
+ /** The pane's screen with styles, as `readScreen` with format "ansi" returns it. */
4
+ screen(): Promise<string>;
5
+ sendKeys(keys: string[]): Promise<void>;
6
+ /** An approval, terminal prompt or question the Hook holds for this pane. */
7
+ held(): boolean;
8
+ /** The conversation's transcript text, at least its recent tail. */
9
+ transcript(): Promise<string>;
10
+ sleep(ms: number): Promise<void>;
11
+ }
12
+ /** The last `TAIL_BYTES` of a transcript, from its first whole line. */
13
+ export declare function transcriptTail(file: string): Promise<string>;
14
+ /** The person's messages still in Claude's queue, oldest first, from its
15
+ * queue rows: an `enqueue` joins it; `dequeue` takes the head; `remove` and
16
+ * `popAll` take the message they name. The harness's own envelopes (task
17
+ * notifications, reminders) are left out, as the phone never shows them. */
18
+ export declare function claudeQueued(transcript: string): string[];
19
+ /** Send Claude's queued messages to the running turn now, or withdraw them
20
+ * all unsent. `status` is the pane's agent status. Answers the messages it
21
+ * acted on, oldest first. */
22
+ export declare function claudeQueueAction(action: ClaudeQueueAction, status: string, deps: ClaudeQueueDeps): Promise<{
23
+ ok: true;
24
+ messages: string[];
25
+ }>;
@@ -0,0 +1,124 @@
1
+ // Messages a busy Claude Code pane holds in its own queue: text typed (or sent
2
+ // from the phone) mid-turn waits there, drawn under the input box, until the
3
+ // next tool boundary or the end of the turn. Claude Code acts on the whole
4
+ // queue, never on one message, through its default chat keys (2.1.312):
5
+ // - `ctrl+x ctrl+s` (chat:sendNow) on an empty input hands every queued
6
+ // message to the running turn now, moving a running tool to the
7
+ // background: `remove` rows with reason `absorbed_mid_turn`.
8
+ // - `up` (history:previous) on an empty input pulls every queued message
9
+ // back into the input (`popAll` rows), and `ctrl+l` (chat:clearInput)
10
+ // clears it. The turn keeps running and the agent never sees them.
11
+ // With nothing queued, `up` recalls the last prompt instead, so the queue is
12
+ // read from the transcript's queue rows first, and each step is confirmed by
13
+ // the rows Claude writes before the next key goes. The screen read only
14
+ // guards the input box: with text in it, `up` moves the cursor and send-now
15
+ // would send the draft.
16
+ import { open } from "node:fs/promises";
17
+ import { BridgeError } from "./protocol.js";
18
+ import { claudeInputEmpty, claudeSubagentView } from "./claude-suggestion.js";
19
+ import { unwrapPastedContent } from "./transcript-claude.js";
20
+ const TAIL_BYTES = 1_048_576;
21
+ /** How long Claude has to write the rows that confirm a key, in 100 ms reads. */
22
+ const CONFIRM_READS = 30;
23
+ /** The last `TAIL_BYTES` of a transcript, from its first whole line. */
24
+ export async function transcriptTail(file) {
25
+ const handle = await open(file, "r");
26
+ try {
27
+ const { size } = await handle.stat();
28
+ const start = Math.max(0, size - TAIL_BYTES), buffer = Buffer.alloc(size - start);
29
+ await handle.read(buffer, 0, buffer.length, start);
30
+ const text = buffer.toString("utf8");
31
+ return start === 0 ? text : text.slice(text.indexOf("\n") + 1);
32
+ }
33
+ finally {
34
+ await handle.close();
35
+ }
36
+ }
37
+ /** The person's messages still in Claude's queue, oldest first, from its
38
+ * queue rows: an `enqueue` joins it; `dequeue` takes the head; `remove` and
39
+ * `popAll` take the message they name. The harness's own envelopes (task
40
+ * notifications, reminders) are left out, as the phone never shows them. */
41
+ export function claudeQueued(transcript) {
42
+ const queue = [];
43
+ for (const line of transcript.split("\n")) {
44
+ if (!line.includes('"queue-operation"'))
45
+ continue;
46
+ let row;
47
+ try {
48
+ row = JSON.parse(line);
49
+ }
50
+ catch {
51
+ continue;
52
+ }
53
+ if (row.type !== "queue-operation" || row.isSidechain)
54
+ continue;
55
+ const content = typeof row.content === "string" ? row.content : undefined;
56
+ if (row.operation === "enqueue" && content !== undefined)
57
+ queue.push(content);
58
+ else if (row.operation === "dequeue")
59
+ queue.shift();
60
+ else if ((row.operation === "remove" || row.operation === "popAll") && content !== undefined) {
61
+ const index = queue.indexOf(content);
62
+ if (index >= 0)
63
+ queue.splice(index, 1);
64
+ }
65
+ }
66
+ return queue.map(unwrapPastedContent).filter(text => !text.trimStart().startsWith("<"));
67
+ }
68
+ /** Send Claude's queued messages to the running turn now, or withdraw them
69
+ * all unsent. `status` is the pane's agent status. Answers the messages it
70
+ * acted on, oldest first. */
71
+ export async function claudeQueueAction(action, status, deps) {
72
+ if (status !== "working")
73
+ throw new BridgeError(409, "This agent is no longer working, so it has already taken its queued messages.", { code: "queue-idle" });
74
+ const queued = claudeQueued(await deps.transcript());
75
+ if (!queued.length)
76
+ throw new BridgeError(409, "The agent has no queued messages now; it has already taken them.", { code: "queue-empty" });
77
+ await ready(deps);
78
+ if (action === "send-now") {
79
+ await deps.sendKeys(["ctrl+x", "ctrl+s"]);
80
+ if (!await settled(deps))
81
+ throw new BridgeError(409, "Claude did not take its queued messages. This Claude Code may not have send-now, or its keys were changed.", { code: "queue-not-sent" });
82
+ return { ok: true, messages: queued };
83
+ }
84
+ await deps.sendKeys(["up"]);
85
+ // Only once Claude logged the queue as pulled back into the input is the
86
+ // input cleared: an `up` that went anywhere else is left alone.
87
+ if (!await settled(deps)) {
88
+ // The input was empty before `up`; whatever it recalled is not the owner's.
89
+ if (!deps.held())
90
+ await deps.sendKeys(["ctrl+l"]);
91
+ throw new BridgeError(409, "Claude did not take its queued messages back. Check the terminal.", { code: "queue-not-withdrawn" });
92
+ }
93
+ if (deps.held())
94
+ throw new BridgeError(409, "Claude moved its queued messages into its input box, then asked for input. Clear the box in the terminal.", { code: "queue-not-cleared" });
95
+ await deps.sendKeys(["ctrl+l"]);
96
+ await deps.sleep(250);
97
+ // A remapped key would leave the queued text in the input, where the next
98
+ // Enter in the pane sends it. Say so rather than report it withdrawn.
99
+ if (!claudeInputEmpty(await deps.screen().catch(() => ""))) {
100
+ throw new BridgeError(409, "Claude moved its queued messages into its input box but did not clear it. Clear it in the terminal.", { code: "queue-not-cleared" });
101
+ }
102
+ return { ok: true, messages: queued };
103
+ }
104
+ async function ready(deps) {
105
+ if (deps.held())
106
+ throw new BridgeError(409, "This agent needs input in the terminal first.", { code: "queue-held" });
107
+ const screen = await deps.screen();
108
+ if (claudeSubagentView(screen))
109
+ throw new BridgeError(409, "The terminal is showing a subagent. Return to the main conversation there first.", { code: "queue-subagent-view" });
110
+ if (!claudeInputEmpty(screen))
111
+ throw new BridgeError(409, "The terminal's input box has text in it. Send or clear it there first.", { code: "queue-input-busy" });
112
+ // A prompt that opened while the screen was read takes the keys instead.
113
+ if (deps.held())
114
+ throw new BridgeError(409, "This agent needs input in the terminal first.", { code: "queue-held" });
115
+ }
116
+ /** Whether the queue emptied: the rows Claude writes for the key landed. */
117
+ async function settled(deps) {
118
+ for (let read = 0; read < CONFIRM_READS; read++) {
119
+ await deps.sleep(100);
120
+ if (!claudeQueued(await deps.transcript().catch(() => "")).length)
121
+ return true;
122
+ }
123
+ return false;
124
+ }
@@ -15,3 +15,8 @@ export declare function claudeSuggestionShown(screen: string): string | undefine
15
15
  * Escape returns to the main view. */
16
16
  export declare const SUBAGENT_VIEW: RegExp;
17
17
  export declare function claudeSubagentView(screen: string): boolean;
18
+ /** Whether Claude's live input box holds no typed text: nothing after the
19
+ * prompt glyph, or only dim placeholder or suggestion text. False for typed
20
+ * text, a subagent's view, or no single-line live box on screen (typed text
21
+ * that wraps leaves no rule under the prompt line). */
22
+ export declare function claudeInputEmpty(screen: string): boolean;
@@ -46,9 +46,27 @@ export function claudeSubagentView(screen) {
46
46
  const text = liveInputDimText(screen);
47
47
  return !!text && SUBAGENT_VIEW.test(text);
48
48
  }
49
+ /** Whether Claude's live input box holds no typed text: nothing after the
50
+ * prompt glyph, or only dim placeholder or suggestion text. False for typed
51
+ * text, a subagent's view, or no single-line live box on screen (typed text
52
+ * that wraps leaves no rule under the prompt line). */
53
+ export function claudeInputEmpty(screen) {
54
+ const line = liveInputLine(screen);
55
+ if (line === undefined)
56
+ return false;
57
+ if (!stripTerminal(line).replace(/^\s*❯/, "").trim())
58
+ return true;
59
+ const dim = dimText(line);
60
+ return !!dim && !SUBAGENT_VIEW.test(dim);
61
+ }
49
62
  /** The dim text in the live input box (between its two rules), "" when the
50
63
  * box holds typed text, undefined when there is no live box on screen. */
51
64
  function liveInputDimText(screen) {
65
+ const line = liveInputLine(screen);
66
+ return line === undefined ? undefined : dimText(line);
67
+ }
68
+ /** The live input box's prompt line, as read with its styles. */
69
+ function liveInputLine(screen) {
52
70
  const lines = screen.split("\n").map(line => line.replace(/\r$/, ""));
53
71
  for (let index = lines.length - 2; index > 0; index--) {
54
72
  const plain = stripTerminal(lines[index]);
@@ -57,7 +75,7 @@ function liveInputDimText(screen) {
57
75
  // Only the live input box: a sent prompt in the history has no rules around it.
58
76
  if (!rule(stripTerminal(lines[index - 1])) || !rule(stripTerminal(lines[index + 1])))
59
77
  return undefined;
60
- return dimText(lines[index]);
78
+ return lines[index];
61
79
  }
62
80
  return undefined;
63
81
  }
@@ -1,5 +1,6 @@
1
1
  /** Read-only browsing beneath a root selected and verified by the server. */
2
2
  export declare function browseFiles(root: string, relative: string): Promise<{
3
+ size?: undefined;
3
4
  path: string;
4
5
  kind: string;
5
6
  truncated: boolean;
@@ -8,7 +9,6 @@ export declare function browseFiles(root: string, relative: string): Promise<{
8
9
  path: string;
9
10
  kind: string;
10
11
  }[];
11
- size?: undefined;
12
12
  data?: undefined;
13
13
  } | {
14
14
  truncated?: undefined;
@@ -107,7 +107,7 @@ const request = z.object({
107
107
  });
108
108
  /** Listen for one phone. Resolves once its key is authorized; rejects on timeout or too many bad proofs. */
109
109
  export async function startPairing(options) {
110
- let failures = 0, finished = false, timer;
110
+ let failures = 0, finished = false, claimed = false, timer;
111
111
  let approvals = Promise.resolve();
112
112
  let resolve, reject;
113
113
  const done = new Promise((yes, no) => { resolve = yes; reject = no; });
@@ -152,11 +152,11 @@ export async function startPairing(options) {
152
152
  if (input.typed) {
153
153
  // One question at a time, each bound to its own phone: a single answer
154
154
  // never allows two keys.
155
- const ask = approvals.then(() => finished || incoming.socket.destroyed ? false
155
+ const ask = approvals.then(() => finished || claimed || incoming.socket.destroyed ? false
156
156
  : options.approve ? options.approve({ device: input.device, name: input.name, check: pairingCheckCode(keyFingerprint(publicKey)) }) : false);
157
157
  approvals = ask.catch(() => false);
158
158
  const allowed = await ask;
159
- if (finished)
159
+ if (finished || claimed)
160
160
  throw new BridgeError(410, "Pairing is closed. Run phren pair again.");
161
161
  // A phone that gave up while the question waited gets nothing written.
162
162
  if (incoming.socket.destroyed)
@@ -164,9 +164,20 @@ export async function startPairing(options) {
164
164
  if (!allowed)
165
165
  throw new BridgeError(403, "The computer didn't allow this phone. Run phren pair again and allow it there.");
166
166
  }
167
+ // Claimed before the key is written, so a phone queued behind this one is
168
+ // told pairing is closed rather than asked about while the write runs.
169
+ if (finished || claimed)
170
+ throw new BridgeError(410, "Pairing is closed. Run phren pair again.");
171
+ claimed = true;
167
172
  const comment = input.device === "android" ? "phren-android" : "phren-iphone";
168
173
  const encoded = publicKey.split(" ")[1];
169
- await appendAuthorizedKey(`restrict,pty,${forcedCommand} ${publicKey} ${comment}`, existing => existing.split(/\s+/).includes(encoded), "This phone key is already authorized with different options.", options.sshDirectory);
174
+ try {
175
+ await appendAuthorizedKey(`restrict,pty,${forcedCommand} ${publicKey} ${comment}`, existing => existing.split(/\s+/).includes(encoded), "This phone key is already authorized with different options.", options.sshDirectory);
176
+ }
177
+ catch (error) {
178
+ claimed = false;
179
+ throw error;
180
+ }
170
181
  reply(response, 200, {
171
182
  v: 1, name: options.name, user: options.user, sshPort: options.sshPort, fingerprint: options.fingerprint ?? null,
172
183
  proof: pairingProof(options.code, "computer", options.fingerprint ?? "", publicKey),
@@ -29,6 +29,7 @@ import { deliveryIdSchema, PromptOnce, promptScope } from "./prompt-once.js";
29
29
  import { promptWithStartupRetry } from "./prompt-startup.js";
30
30
  import { sendServedPrompt, servedPane } from "./opencode-panes.js";
31
31
  import { claudeSuggestionShown } from "./claude-suggestion.js";
32
+ import { claudeQueueAction, transcriptTail } from "./claude-queue.js";
32
33
  export /** A file from the phone: a plain name and base64 bytes, bounded. */ function uploadBody(data) {
33
34
  const name = z.string().regex(/^[A-Za-z0-9_][A-Za-z0-9_ .()-]{0,199}$/).refine(n => !n.includes("..")).parse(data.name);
34
35
  const encoded = z.string().max(11_184_812).regex(/^[A-Za-z0-9+/]*={0,2}$/).parse(data.data);
@@ -483,7 +484,7 @@ export async function paneRouteOnce(ctx, url, data, response, typing) {
483
484
  const target = targetSchema.parse(data.target);
484
485
  // Uploads store bytes without answering or interrupting the agent.
485
486
  // They still require fresh identity, just like prompt mutations.
486
- const sendsInput = ["/v1/prompt", "/v1/keys", "/v1/secret", "/v1/model", "/v1/settings", "/v1/agents/permission-mode"].includes(url.pathname);
487
+ const sendsInput = ["/v1/prompt", "/v1/prompt/queue", "/v1/keys", "/v1/secret", "/v1/model", "/v1/settings", "/v1/agents/permission-mode"].includes(url.pathname);
487
488
  if (sendsInput) {
488
489
  modelSwitcher.assertAvailable(target);
489
490
  settingsSwitcher.assertAvailable(target);
@@ -665,6 +666,21 @@ export async function paneRouteOnce(ctx, url, data, response, typing) {
665
666
  // Bound to the pane: the conversation that took it may be a newer one.
666
667
  result = { ok: true, ...agentHooks.deliveries.status(id, target) };
667
668
  }
669
+ else if (url.pathname === "/v1/prompt/queue") {
670
+ // The messages a busy agent holds in its own queue: sent to the running
671
+ // turn now, or withdrawn unsent. Only Claude Code's queue can be reached;
672
+ // a pane the Hook types into for any other harness has none it can act on.
673
+ // The owner's words: an agent may not send or discard another pane's queue.
674
+ if (data && typeof data === "object" && "origin" in data)
675
+ throw new BridgeError(403, "Only the owner sends or cancels queued messages, from the phone.");
676
+ const action = z.enum(["send-now", "withdraw"]).parse(data.action);
677
+ if (target.source !== "claude")
678
+ throw new BridgeError(409, "Only Claude Code's queued messages can be sent now or withdrawn.", { code: "queue-unsupported" });
679
+ const guards = promptGuards(agentHooks, target);
680
+ const transcript = await targetTranscriptPath(target);
681
+ result = await claudeQueueAction(action, String(pane.agent_status), { held: guards.held, screen: guards.screen,
682
+ transcript: () => transcriptTail(transcript), sendKeys: keys => terminalProvider().sendKeys(target.server, target.pane, keys), sleep: ms => sleep(ms) });
683
+ }
668
684
  else if (url.pathname === "/v1/side-question/dismiss") {
669
685
  result = sideQuestions.dismiss(target, z.string().uuid().parse(data.id));
670
686
  }
@@ -133,6 +133,7 @@ export declare const capabilities: {
133
133
  memoryStore: boolean;
134
134
  promptOnce: boolean;
135
135
  promptStatus: boolean;
136
+ queuedMessageActions: string[];
136
137
  deliveryFrames: boolean;
137
138
  paneDeliveries: boolean;
138
139
  resources: boolean;
@@ -92,7 +92,7 @@ async function childActivity(source, session) {
92
92
  export const capabilities = { transcript: true, progress: true, images: true, prompt: true, stop: true,
93
93
  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,
94
94
  approvals: true, questions: false, accountUsage: true, providers: ["codex", "claude", "copilot", "opencode"],
95
- 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", simulatorStream: process.platform === "darwin", simulatorDevices: process.platform === "darwin", simulatorDrag: 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, moveConductor: true, moveToComputer: true, moveConductorToComputer: true, moveResume: true, moveSummaryByTarget: true, moveConversationCopy: true, claudeAccountAdd: true, accountPools: true, workerRelocation: 1, projectMemory: true, fileWrite: true, fileSearch: true, gitReview: true, memoryStoreBatch: true, gitHosts: true, projectHostToken: true, gitRemoteIdentity: true };
95
+ 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", simulatorStream: process.platform === "darwin", simulatorDevices: process.platform === "darwin", simulatorDrag: 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, queuedMessageActions: ["claude"], deliveryFrames: true, paneDeliveries: true, resources: true, sudo: true, sudoOutcome: true, previewDeltas: true, quickChat: true, agentFolder: true, launchPermissionMode: true, sessionMove: true, moveNewChat: true, moveConductor: true, moveToComputer: true, moveConductorToComputer: true, moveResume: true, moveSummaryByTarget: true, moveConversationCopy: true, claudeAccountAdd: true, accountPools: true, workerRelocation: 1, projectMemory: true, fileWrite: true, fileSearch: true, gitReview: true, memoryStoreBatch: true, gitHosts: true, projectHostToken: true, gitRemoteIdentity: true };
96
96
  export function capabilitiesForModules(snapshot) {
97
97
  const allowed = new Set(snapshot.modules.flatMap(module => module.capabilities));
98
98
  const result = Object.fromEntries(Object.entries(capabilities).filter(([name]) => allowed.has(name)));
@@ -20792,15 +20792,15 @@ var init_limits = __esm({
20792
20792
  signal?.throwIfAborted();
20793
20793
  if (this.active >= this.limit) {
20794
20794
  await new Promise((resolve17, reject) => {
20795
- const ready = () => {
20795
+ const ready2 = () => {
20796
20796
  signal?.removeEventListener("abort", abort);
20797
20797
  resolve17();
20798
20798
  };
20799
20799
  const abort = () => {
20800
- this.waiting = this.waiting.filter((w) => w !== ready);
20800
+ this.waiting = this.waiting.filter((w) => w !== ready2);
20801
20801
  reject(signal.reason);
20802
20802
  };
20803
- this.waiting.push(ready);
20803
+ this.waiting.push(ready2);
20804
20804
  signal?.addEventListener("abort", abort, { once: true });
20805
20805
  });
20806
20806
  } else this.active++;
@@ -27713,10 +27713,10 @@ function decodeEntities(text5) {
27713
27713
  }
27714
27714
  function probe(port, host) {
27715
27715
  return new Promise((resolve17) => {
27716
- let settled3 = false;
27716
+ let settled4 = false;
27717
27717
  const finish = (value2) => {
27718
- if (!settled3) {
27719
- settled3 = true;
27718
+ if (!settled4) {
27719
+ settled4 = true;
27720
27720
  clearTimeout(deadline);
27721
27721
  resolve17(value2);
27722
27722
  }
@@ -29948,9 +29948,9 @@ function resolveString(expression, source) {
29948
29948
  const declaration = new RegExp(`\\b(?:const|let|var)\\s+${identifier}\\s*=\\s*("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`)`).exec(source);
29949
29949
  return declaration ? unescapeJs(declaration[1].slice(1, -1)) : void 0;
29950
29950
  }
29951
- function callArguments(source, open30) {
29951
+ function callArguments(source, open31) {
29952
29952
  let depth = 0, quote6 = "";
29953
- for (let index2 = open30; index2 < source.length; index2++) {
29953
+ for (let index2 = open31; index2 < source.length; index2++) {
29954
29954
  const character = source[index2];
29955
29955
  if (quote6) {
29956
29956
  if (character === "\\") index2++;
@@ -29963,7 +29963,7 @@ function callArguments(source, open30) {
29963
29963
  }
29964
29964
  if (character === "(" || character === "{" || character === "[") depth++;
29965
29965
  else if (character === ")" || character === "}" || character === "]") {
29966
- if (--depth === 0) return source.slice(open30 + 1, index2);
29966
+ if (--depth === 0) return source.slice(open31 + 1, index2);
29967
29967
  }
29968
29968
  }
29969
29969
  return void 0;
@@ -31206,14 +31206,14 @@ async function sameDirectory(a, b) {
31206
31206
  return path26.resolve(a) === path26.resolve(b) || await real(a) === await real(b);
31207
31207
  }
31208
31208
  function assignDaemonConversation(here, self, claimed, rivals, now = Date.now()) {
31209
- const open30 = here.filter((r) => !claimed.has(r.id) && r.startedAt <= now + 6e4);
31210
- const after2 = (from) => open30.filter((r) => r.startedAt >= from - START_SLACK_MS);
31209
+ const open31 = here.filter((r) => !claimed.has(r.id) && r.startedAt <= now + 6e4);
31210
+ const after2 = (from) => open31.filter((r) => r.startedAt >= from - START_SLACK_MS);
31211
31211
  if (!rivals.length) {
31212
31212
  const pool2 = after2(self.start);
31213
31213
  const held = pool2.filter((r) => r.held);
31214
31214
  const current2 = (held.length ? held : pool2).sort((a, b) => b.activeAt - a.activeAt)[0]?.id;
31215
31215
  if (current2) return current2;
31216
- const resumed = open30.filter((r) => r.held && r.activeAt >= self.start && r.activeAt <= now + 6e4);
31216
+ const resumed = open31.filter((r) => r.held && r.activeAt >= self.start && r.activeAt <= now + 6e4);
31217
31217
  return resumed.length === 1 && resumed[0].id === self.resumed ? self.resumed : void 0;
31218
31218
  }
31219
31219
  const order = [...rivals, self].sort((a, b) => b.start - a.start || (a.key < b.key ? 1 : a.key > b.key ? -1 : 0));
@@ -34445,7 +34445,7 @@ var require_stream = __commonJS({
34445
34445
  };
34446
34446
  duplex._final = function(callback) {
34447
34447
  if (ws2.readyState === ws2.CONNECTING) {
34448
- ws2.once("open", function open30() {
34448
+ ws2.once("open", function open31() {
34449
34449
  duplex._final(callback);
34450
34450
  });
34451
34451
  return;
@@ -34466,7 +34466,7 @@ var require_stream = __commonJS({
34466
34466
  };
34467
34467
  duplex._write = function(chunk, encoding, callback) {
34468
34468
  if (ws2.readyState === ws2.CONNECTING) {
34469
- ws2.once("open", function open30() {
34469
+ ws2.once("open", function open31() {
34470
34470
  duplex._write(chunk, encoding, callback);
34471
34471
  });
34472
34472
  return;
@@ -35079,10 +35079,10 @@ async function socketAccepts(socketPath2) {
35079
35079
  }
35080
35080
  return new Promise((resolve17) => {
35081
35081
  const ws2 = new import_websocket.default(socketUrl(socketPath2), { perMessageDeflate: false });
35082
- let settled3 = false;
35082
+ let settled4 = false;
35083
35083
  const finish = (ok) => {
35084
- if (settled3) return;
35085
- settled3 = true;
35084
+ if (settled4) return;
35085
+ settled4 = true;
35086
35086
  ws2.close();
35087
35087
  resolve17(ok);
35088
35088
  };
@@ -36507,10 +36507,10 @@ async function tmuxScroll(server, pane, lines) {
36507
36507
  const target2 = pane ? toTmuxId(pane, "p") : await activeClientPane(server);
36508
36508
  const key4 = `${server}\0${target2}`;
36509
36509
  const run5 = (scrollQueues.get(key4) ?? Promise.resolve()).then(() => scrollPane(server, target2, lines), () => scrollPane(server, target2, lines));
36510
- const settled3 = run5.catch(() => void 0);
36511
- scrollQueues.set(key4, settled3);
36512
- void settled3.then(() => {
36513
- if (scrollQueues.get(key4) === settled3) scrollQueues.delete(key4);
36510
+ const settled4 = run5.catch(() => void 0);
36511
+ scrollQueues.set(key4, settled4);
36512
+ void settled4.then(() => {
36513
+ if (scrollQueues.get(key4) === settled4) scrollQueues.delete(key4);
36514
36514
  });
36515
36515
  return run5;
36516
36516
  }
@@ -37414,7 +37414,7 @@ var init_package_metadata = __esm({
37414
37414
  __dirname = path35.dirname(fileURLToPath2(import.meta.url));
37415
37415
  ROOT = path35.join(__dirname, "..");
37416
37416
  PACKAGE_JSON_PATH = path35.join(ROOT, "package.json");
37417
- BUNDLED_VERSION = true ? "0.3.61" : "0.0.0";
37417
+ BUNDLED_VERSION = true ? "0.3.63" : "0.0.0";
37418
37418
  PACKAGE_JSON = readPackageJson();
37419
37419
  PACKAGE_NAME = PACKAGE_JSON.name || "phren";
37420
37420
  VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
@@ -37766,6 +37766,7 @@ var init_registry = __esm({
37766
37766
  "/v1/sessions/move/launch",
37767
37767
  "/v1/prompt",
37768
37768
  "/v1/prompt/status",
37769
+ "/v1/prompt/queue",
37769
37770
  "/v1/model",
37770
37771
  "/v1/settings",
37771
37772
  "/v1/agents/permission-mode",
@@ -37824,6 +37825,7 @@ var init_registry = __esm({
37824
37825
  "transcribe",
37825
37826
  "promptOnce",
37826
37827
  "promptStatus",
37828
+ "queuedMessageActions",
37827
37829
  "deliveryFrames",
37828
37830
  "resources",
37829
37831
  "sessionRename",
@@ -41031,17 +41033,17 @@ function validateTaskDependencies(phrenPath, doc, item, refs) {
41031
41033
  function filterTaskDoc(base, doc, filter) {
41032
41034
  if (!filter.responsibility && !filter.readiness) return doc;
41033
41035
  return { ...doc, items: Object.fromEntries(Object.entries(doc.items).map(([section, items]) => [section, items.filter((item) => {
41034
- const ready = taskReadiness(base, doc, item);
41035
- return (!filter.responsibility || ready.responsibility === filter.responsibility) && (!filter.readiness || ready.readiness === filter.readiness);
41036
+ const ready2 = taskReadiness(base, doc, item);
41037
+ return (!filter.responsibility || ready2.responsibility === filter.responsibility) && (!filter.readiness || ready2.readiness === filter.readiness);
41036
41038
  })])) };
41037
41039
  }
41038
41040
  function taskCounts(base, doc) {
41039
41041
  const counts = { human: 0, agentReady: 0, agentWaitingOnHuman: 0, agentWaitingOnTask: 0, done: doc.items.Done.length };
41040
41042
  for (const item of [...doc.items.Active, ...doc.items.Queue]) {
41041
- const ready = taskReadiness(base, doc, item);
41042
- if (ready.responsibility === "human") counts.human++;
41043
- else if (ready.readiness === "ready") counts.agentReady++;
41044
- else if (ready.readiness === "waiting-on-human") counts.agentWaitingOnHuman++;
41043
+ const ready2 = taskReadiness(base, doc, item);
41044
+ if (ready2.responsibility === "human") counts.human++;
41045
+ else if (ready2.readiness === "ready") counts.agentReady++;
41046
+ else if (ready2.readiness === "waiting-on-human") counts.agentWaitingOnHuman++;
41045
41047
  else counts.agentWaitingOnTask++;
41046
41048
  }
41047
41049
  return counts;
@@ -45402,7 +45404,7 @@ async function moveSession(input2, options = {}) {
45402
45404
  const data = moveSessionSchema.parse(input2);
45403
45405
  const { request: request10, peer } = await hookFor(data.computer);
45404
45406
  const read = async (id2) => object2((await request10(`/v1/sessions/move?id=${encodeURIComponent(id2)}`)).move);
45405
- const settled3 = (move2) => move2.state === "moved" || move2.state === "failed";
45407
+ const settled4 = (move2) => move2.state === "moved" || move2.state === "failed";
45406
45408
  let move;
45407
45409
  if (data.status) move = await read(data.id);
45408
45410
  else {
@@ -45418,13 +45420,13 @@ async function moveSession(input2, options = {}) {
45418
45420
  })).move);
45419
45421
  if (data.wait !== false && typeof move.id === "string") {
45420
45422
  const until = Date.now() + (options.waitMs ?? MOVE_WAIT_MS);
45421
- while (!settled3(move) && Date.now() < until) {
45423
+ while (!settled4(move) && Date.now() < until) {
45422
45424
  await new Promise((resolve17) => setTimeout(resolve17, options.pollMs ?? 3e3));
45423
45425
  move = await read(String(move.id)).catch(() => move);
45424
45426
  }
45425
45427
  }
45426
45428
  }
45427
- return { ok: move.state !== "failed", move, settled: settled3(move) };
45429
+ return { ok: move.state !== "failed", move, settled: settled4(move) };
45428
45430
  }
45429
45431
  function claudeAccountRooms(answer2, computer, now = Date.now()) {
45430
45432
  const window2 = (room) => {
@@ -46360,8 +46362,8 @@ var init_dispatch_returns = __esm({
46360
46362
  async poll() {
46361
46363
  await this.confirmArrivals(await this.peers().catch(() => []));
46362
46364
  const now = this.now();
46363
- const open30 = (await dispatchStatus()).filter((receipt) => (receipt.state === "accepted" || receipt.state === "uncertain") && receipt.target && !receipt.closedAt && receipt.worker?.state !== "gone" && now - Date.parse(receipt.createdAt) < WATCH_MS);
46364
- if (!open30.length) return;
46365
+ const open31 = (await dispatchStatus()).filter((receipt) => (receipt.state === "accepted" || receipt.state === "uncertain") && receipt.target && !receipt.closedAt && receipt.worker?.state !== "gone" && now - Date.parse(receipt.createdAt) < WATCH_MS);
46366
+ if (!open31.length) return;
46365
46367
  const peers = await this.peers().catch(() => []);
46366
46368
  const identities2 = /* @__PURE__ */ new Map();
46367
46369
  const identity = (peer) => {
@@ -46369,7 +46371,7 @@ var init_dispatch_returns = __esm({
46369
46371
  return identities2.get(peer);
46370
46372
  };
46371
46373
  const byComputer = /* @__PURE__ */ new Map();
46372
- for (const receipt of open30) {
46374
+ for (const receipt of open31) {
46373
46375
  const key4 = this.isSelf(receipt) ? "\0self" : receipt.computer;
46374
46376
  byComputer.set(key4, [...byComputer.get(key4) ?? [], receipt]);
46375
46377
  }
@@ -47311,12 +47313,12 @@ var init_schedules = __esm({
47311
47313
  const resume = this.launch.resume;
47312
47314
  if (this.recovered || !resume) return;
47313
47315
  this.recovered = true;
47314
- const open30 = await this.exclusive(async () => {
47316
+ const open31 = await this.exclusive(async () => {
47315
47317
  const pending3 = (await readScheduleRuns(this.runsFile)).filter((run5) => runningStatuses.has(run5.status) && !this.own.has(run5.id));
47316
47318
  for (const run5 of pending3) this.own.add(run5.id);
47317
47319
  return pending3;
47318
47320
  });
47319
- for (const run5 of open30) {
47321
+ for (const run5 of open31) {
47320
47322
  let schedule;
47321
47323
  try {
47322
47324
  schedule = (await readScheduleDocument(this.projectDirectory(run5.scheduleProject ?? run5.project))).schedules.find((item) => item.id === run5.scheduleId);
@@ -49171,12 +49173,12 @@ function accountWindows(usage, now) {
49171
49173
  }
49172
49174
  function chooseAccount(rooms, blocked = () => void 0) {
49173
49175
  const skipped = [];
49174
- const open30 = rooms.filter((room) => {
49176
+ const open31 = rooms.filter((room) => {
49175
49177
  const why = room.usable === false ? "not signed in" : room.exhausted ? `out of quota${room.until ? ` until ${room.until}` : ""}` : blocked(room);
49176
49178
  if (why) skipped.push(`${room.account}: ${why}`);
49177
49179
  return !why;
49178
49180
  });
49179
- const sorted = [...open30].sort((a, b) => rank(b.fiveHour) - rank(a.fiveHour) || rank(b.week) - rank(a.week) || Number(b.account === DEFAULT_ACCOUNT) - Number(a.account === DEFAULT_ACCOUNT) || a.account.localeCompare(b.account));
49181
+ const sorted = [...open31].sort((a, b) => rank(b.fiveHour) - rank(a.fiveHour) || rank(b.week) - rank(a.week) || Number(b.account === DEFAULT_ACCOUNT) - Number(a.account === DEFAULT_ACCOUNT) || a.account.localeCompare(b.account));
49180
49182
  const best = sorted[0];
49181
49183
  if (!best) return { skipped };
49182
49184
  const others = sorted.slice(1).map(describe3);
@@ -51277,13 +51279,13 @@ WantedBy=default.target
51277
51279
  try {
51278
51280
  if (!noService) {
51279
51281
  let kickstartError = await startService();
51280
- let ready = await serviceReady(version2);
51281
- if (!ready && process.platform === "darwin") {
51282
+ let ready2 = await serviceReady(version2);
51283
+ if (!ready2 && process.platform === "darwin") {
51282
51284
  await stopService();
51283
51285
  kickstartError = await startService();
51284
- ready = await serviceReady(version2);
51286
+ ready2 = await serviceReady(version2);
51285
51287
  }
51286
- if (!ready) {
51288
+ if (!ready2) {
51287
51289
  const uid = process.getuid(), domain2 = process.platform === "darwin" ? launchDomain(uid, await guiSession(uid)) : void 0;
51288
51290
  throw new Error(`The new Phren Hook ${version2} did not become ready after ${domain2 ? "two launchd starts" : "starting the service"}.${kickstartError ? ` Last launchctl kickstart error: ${kickstartError}.` : ""} See ${serviceLog}. ` + (domain2 ? `To start it by hand:
51289
51291
  ${launchCommands(domain2, launchAgentPlist()).join("\n ")}` : `Check systemctl --user status ${unit}.`));
@@ -53155,12 +53157,12 @@ var init_dispatch = __esm({
53155
53157
  return { ok: receipt.state === "accepted", ...receipt };
53156
53158
  }
53157
53159
  receipt.brief = "typed";
53158
- const settled3 = launched.target ? { target: launched.target } : await settledTarget(peer, launched, data.harness, this.settleIntervalMs);
53159
- if (!settled3.target) {
53160
- if (["blocked", "waiting"].includes(String(settled3.status ?? launched.agentStatus))) throw new StartupScreen(String(settled3.status ?? launched.agentStatus));
53161
- throw new BridgeError(504, `${data.harness} started in the new "${data.label}" pane on ${peer.name} but never showed a conversation or a starting pane (last status ${settled3.status ?? "unknown"}), so the brief was not sent. The pane is still open.`);
53160
+ const settled4 = launched.target ? { target: launched.target } : await settledTarget(peer, launched, data.harness, this.settleIntervalMs);
53161
+ if (!settled4.target) {
53162
+ if (["blocked", "waiting"].includes(String(settled4.status ?? launched.agentStatus))) throw new StartupScreen(String(settled4.status ?? launched.agentStatus));
53163
+ throw new BridgeError(504, `${data.harness} started in the new "${data.label}" pane on ${peer.name} but never showed a conversation or a starting pane (last status ${settled4.status ?? "unknown"}), so the brief was not sent. The pane is still open.`);
53162
53164
  }
53163
- const target2 = remoteTarget.parse(settled3.target);
53165
+ const target2 = remoteTarget.parse(settled4.target);
53164
53166
  if (target2.source !== data.harness || target2.server !== peer.server) throw new BridgeError(502, "The remote Hook returned a different launch target.");
53165
53167
  receipt.target = target2;
53166
53168
  receipt.state = "sending";
@@ -53231,8 +53233,8 @@ var init_dispatch = __esm({
53231
53233
  }
53232
53234
  const launched = outcome.result;
53233
53235
  if (launched.target) await placed?.(launched.target);
53234
- const settled3 = launched.target ? { target: launched.target } : await settledTarget(peer, launched, to.harness, this.settleIntervalMs);
53235
- const target2 = remoteTarget.parse(settled3.target);
53236
+ const settled4 = launched.target ? { target: launched.target } : await settledTarget(peer, launched, to.harness, this.settleIntervalMs);
53237
+ const target2 = remoteTarget.parse(settled4.target);
53236
53238
  await placed?.(target2);
53237
53239
  if (target2.server !== peer.server || target2.source !== to.harness) throw new BridgeError(502, "The peer returned a different launch target.");
53238
53240
  if (launched.briefLaunched !== true) {
@@ -54100,10 +54102,10 @@ async function readMove(id2) {
54100
54102
  async function listMoves(now = Date.now()) {
54101
54103
  const names = (await readdir14(movesRoot()).catch(() => [])).filter((name) => /^[a-f0-9-]{36}\.json$/.test(name));
54102
54104
  const records = (await Promise.all(names.map((name) => readMove(name.slice(0, -5))))).filter((record4) => !!record4).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
54103
- const settled3 = (record4) => record4.state === "moved" || record4.state === "failed";
54104
- const stale = records.filter((record4, index2) => settled3(record4) && (index2 >= MAX_MOVES || now - Date.parse(record4.updatedAt) > MOVE_KEEP_MS));
54105
+ const settled4 = (record4) => record4.state === "moved" || record4.state === "failed";
54106
+ const stale = records.filter((record4, index2) => settled4(record4) && (index2 >= MAX_MOVES || now - Date.parse(record4.updatedAt) > MOVE_KEEP_MS));
54105
54107
  await Promise.all(stale.flatMap((record4) => [recordFile(record4.id), interruptFile(record4.id)].map((file4) => rm11(file4, { force: true }).catch(() => void 0))));
54106
- const finished2 = new Set(records.filter(settled3).map((record4) => record4.id));
54108
+ const finished2 = new Set(records.filter(settled4).map((record4) => record4.id));
54107
54109
  await pruneContinuationConversations(async (id2, age) => finished2.has(id2) || age > ORPHAN_GRACE_MS && !await Promise.resolve().then(() => lstat23(recordFile(id2))).then(() => true, () => false), now, MOVE_KEEP_MS).catch(() => void 0);
54108
54110
  return records.filter((record4) => !stale.includes(record4));
54109
54111
  }
@@ -55667,8 +55669,8 @@ async function identityFromProcesses(server, pane, pids) {
55667
55669
  });
55668
55670
  if (new Set(candidates).size === 1) {
55669
55671
  if (pane.agent === "claude") {
55670
- const open30 = files.find((file4) => file4.endsWith(`/${candidates[0]}.jsonl`));
55671
- if (open30) notePaneTranscript(paneAccountKey(server, pane.pane_id), open30, String(pane.terminal_id ?? ""));
55672
+ const open31 = files.find((file4) => file4.endsWith(`/${candidates[0]}.jsonl`));
55673
+ if (open31) notePaneTranscript(paneAccountKey(server, pane.pane_id), open31, String(pane.terminal_id ?? ""));
55672
55674
  }
55673
55675
  return { sessionId: candidates[0], noTranscriptLogs: false };
55674
55676
  }
@@ -56462,10 +56464,10 @@ var init_sudo = __esm({
56462
56464
  this.watchers++;
56463
56465
  const handler = () => listener(this.list());
56464
56466
  this.events.on("change", handler);
56465
- let open30 = true;
56467
+ let open31 = true;
56466
56468
  return () => {
56467
- if (!open30) return;
56468
- open30 = false;
56469
+ if (!open31) return;
56470
+ open31 = false;
56469
56471
  this.watchers--;
56470
56472
  this.events.off("change", handler);
56471
56473
  };
@@ -58168,11 +58170,11 @@ var init_git = __esm({
58168
58170
  import { spawn as spawn10 } from "node:child_process";
58169
58171
  function runCombined(command, args, cwd, timeout, extraEnv = {}, killGraceMs = KILL_GRACE_MS2) {
58170
58172
  return new Promise((resolve17) => {
58171
- let output2 = "", truncated = false, timedOut = false, settled3 = false;
58173
+ let output2 = "", truncated = false, timedOut = false, settled4 = false;
58172
58174
  let deadline;
58173
58175
  const finish = (run5) => {
58174
- if (settled3) return;
58175
- settled3 = true;
58176
+ if (settled4) return;
58177
+ settled4 = true;
58176
58178
  clearTimeout(deadline);
58177
58179
  resolve17(run5);
58178
58180
  };
@@ -58838,13 +58840,13 @@ var init_git_host_gitboy = __esm({
58838
58840
  const ctx = await context2(root, host);
58839
58841
  if (!("api" in ctx)) return { ok: false, reason: ctx.reason, message: ctx.message };
58840
58842
  try {
58841
- const { json: open30 } = await call2(ctx, `/pulls?state=open&limit=100&head_branch=${encodeURIComponent(branch)}`);
58842
- const existing = rows(open30).find((pull2) => pull2.head_branch === branch);
58843
+ const { json: open31 } = await call2(ctx, `/pulls?state=open&limit=100&head_branch=${encodeURIComponent(branch)}`);
58844
+ const existing = rows(open31).find((pull2) => pull2.head_branch === branch);
58843
58845
  if (existing) return { ok: true, url: pullUrl(ctx, existing), number: existing.index, branch, existing: true };
58844
58846
  const { json: repo } = await call2(ctx, "");
58845
58847
  const target2 = String(obj2(repo).default_branch ?? "main");
58846
58848
  const fill = await fillFromCommits(root, `${host.remote ?? "origin"}/${target2}`, branch);
58847
- const native = draft && await hasDraftState(ctx, open30);
58849
+ const native = draft && await hasDraftState(ctx, open31);
58848
58850
  const title2 = draft && !native && !/^draft:/i.test(fill.title) ? `Draft: ${fill.title}` : fill.title;
58849
58851
  const { json: json2 } = await call2(ctx, "/pulls", { method: "POST", body: { head_branch: branch, base_branch: target2, title: title2, body: fill.body, ...native ? { draft: true } : {} } });
58850
58852
  const pull = obj2(json2);
@@ -60667,8 +60669,8 @@ var init_prompt_deliveries = __esm({
60667
60669
  this.hookPanes.add(this.paneKey(target2));
60668
60670
  const stop = this.lastStop.get(this.paneKey(target2)) ?? -Infinity;
60669
60671
  const pick3 = () => {
60670
- const open30 = this.records.filter((record5) => record5.hash === hash2 && this.samePane(record5, target2) && record5.state !== "delivered" && (record5.state !== "failed" || (record5.settledAt ?? record5.at) >= stop));
60671
- return open30.find((entry3) => entry3.session === target2.session) ?? open30[0];
60672
+ const open31 = this.records.filter((record5) => record5.hash === hash2 && this.samePane(record5, target2) && record5.state !== "delivered" && (record5.state !== "failed" || (record5.settledAt ?? record5.at) >= stop));
60673
+ return open31.find((entry3) => entry3.session === target2.session) ?? open31[0];
60672
60674
  };
60673
60675
  let record4 = pick3();
60674
60676
  if (!record4) {
@@ -60811,8 +60813,8 @@ var init_prompt_deliveries = __esm({
60811
60813
  async taken(record4, pass, working = false) {
60812
60814
  if (record4.source !== "claude") return this.takenCodex(record4);
60813
60815
  const same2 = (other) => other.hash === record4.hash && other.server === record4.server && other.pane === record4.pane && other.session === record4.session;
60814
- const open30 = this.records.filter((other) => same2(other) && _PromptDeliveries.claimable(other)).sort((a, b) => a.at - b.at);
60815
- if (open30[0] !== record4) return false;
60816
+ const open31 = this.records.filter((other) => same2(other) && _PromptDeliveries.claimable(other)).sort((a, b) => a.at - b.at);
60817
+ if (open31[0] !== record4) return false;
60816
60818
  const key4 = [record4.hash, record4.server, record4.pane, record4.session, working].join("|");
60817
60819
  let free = pass.get(key4);
60818
60820
  if (!free) {
@@ -61031,13 +61033,24 @@ function claudeSubagentView(screen) {
61031
61033
  const text5 = liveInputDimText(screen);
61032
61034
  return !!text5 && SUBAGENT_VIEW.test(text5);
61033
61035
  }
61036
+ function claudeInputEmpty(screen) {
61037
+ const line = liveInputLine(screen);
61038
+ if (line === void 0) return false;
61039
+ if (!stripTerminal(line).replace(/^\s*❯/, "").trim()) return true;
61040
+ const dim = dimText(line);
61041
+ return !!dim && !SUBAGENT_VIEW.test(dim);
61042
+ }
61034
61043
  function liveInputDimText(screen) {
61044
+ const line = liveInputLine(screen);
61045
+ return line === void 0 ? void 0 : dimText(line);
61046
+ }
61047
+ function liveInputLine(screen) {
61035
61048
  const lines = screen.split("\n").map((line) => line.replace(/\r$/, ""));
61036
61049
  for (let index2 = lines.length - 2; index2 > 0; index2--) {
61037
61050
  const plain2 = stripTerminal(lines[index2]);
61038
61051
  if (!/^\s*❯/.test(plain2)) continue;
61039
61052
  if (!rule(stripTerminal(lines[index2 - 1])) || !rule(stripTerminal(lines[index2 + 1]))) return void 0;
61040
- return dimText(lines[index2]);
61053
+ return lines[index2];
61041
61054
  }
61042
61055
  return void 0;
61043
61056
  }
@@ -61936,10 +61949,10 @@ var init_push = __esm({
61936
61949
  const authority = device.environment === "production" ? "https://api.push.apple.com" : "https://api.sandbox.push.apple.com";
61937
61950
  return new Promise((resolve17) => {
61938
61951
  const client = connect3(authority);
61939
- let settled3 = false;
61952
+ let settled4 = false;
61940
61953
  const finish = (ok) => {
61941
- if (settled3) return;
61942
- settled3 = true;
61954
+ if (settled4) return;
61955
+ settled4 = true;
61943
61956
  client.close();
61944
61957
  resolve17(ok);
61945
61958
  };
@@ -64626,9 +64639,9 @@ ${target2.source}`) ?? 0) > Date.now();
64626
64639
  settleTerminalAnswered(target2, body2) {
64627
64640
  const event = String(body2.event), key4 = JSON.stringify(target2);
64628
64641
  const asked = event === "PermissionRequest" ? JSON.stringify([body2.tool, body2.input]) : void 0;
64629
- const settled3 = (held) => ["Stop", "UserPromptSubmit"].includes(event) || event === "PermissionRequest" && JSON.stringify([held.tool, held.input]) !== asked || event === "PostToolUse" && held.tool === body2.tool && JSON.stringify(held.input) === JSON.stringify(body2.input);
64642
+ const settled4 = (held) => ["Stop", "UserPromptSubmit"].includes(event) || event === "PermissionRequest" && JSON.stringify([held.tool, held.input]) !== asked || event === "PostToolUse" && held.tool === body2.tool && JSON.stringify(held.input) === JSON.stringify(body2.input);
64630
64643
  for (const [action, held] of this.pending) {
64631
- if (held.appServer || JSON.stringify(held.target) !== key4 || !settled3(held)) continue;
64644
+ if (held.appServer || JSON.stringify(held.target) !== key4 || !settled4(held)) continue;
64632
64645
  clearTimeout(held.timer);
64633
64646
  this.pending.delete(action);
64634
64647
  this.pushedHolds.delete(action);
@@ -64636,7 +64649,7 @@ ${target2.source}`) ?? 0) > Date.now();
64636
64649
  if (!held.response.destroyed) held.response.end("{}");
64637
64650
  }
64638
64651
  const hold = this.releasedHolds.get(key4), remembered = this.terminalPrompts.get(key4);
64639
- if (remembered && !remembered.questions?.length && settled3({ tool: remembered.tool, input: remembered.input })) {
64652
+ if (remembered && !remembered.questions?.length && settled4({ tool: remembered.tool, input: remembered.input })) {
64640
64653
  this.terminalPrompts.delete(key4);
64641
64654
  if (hold) {
64642
64655
  this.dropPushBindings(hold.action);
@@ -66414,6 +66427,90 @@ var init_prompt_startup = __esm({
66414
66427
  }
66415
66428
  });
66416
66429
 
66430
+ // src/bridge/claude-queue.ts
66431
+ import { open as open24 } from "node:fs/promises";
66432
+ async function transcriptTail3(file4) {
66433
+ const handle = await open24(file4, "r");
66434
+ try {
66435
+ const { size } = await handle.stat();
66436
+ const start = Math.max(0, size - TAIL_BYTES2), buffer = Buffer.alloc(size - start);
66437
+ await handle.read(buffer, 0, buffer.length, start);
66438
+ const text5 = buffer.toString("utf8");
66439
+ return start === 0 ? text5 : text5.slice(text5.indexOf("\n") + 1);
66440
+ } finally {
66441
+ await handle.close();
66442
+ }
66443
+ }
66444
+ function claudeQueued(transcript) {
66445
+ const queue2 = [];
66446
+ for (const line of transcript.split("\n")) {
66447
+ if (!line.includes('"queue-operation"')) continue;
66448
+ let row;
66449
+ try {
66450
+ row = JSON.parse(line);
66451
+ } catch {
66452
+ continue;
66453
+ }
66454
+ if (row.type !== "queue-operation" || row.isSidechain) continue;
66455
+ const content = typeof row.content === "string" ? row.content : void 0;
66456
+ if (row.operation === "enqueue" && content !== void 0) queue2.push(content);
66457
+ else if (row.operation === "dequeue") queue2.shift();
66458
+ else if ((row.operation === "remove" || row.operation === "popAll") && content !== void 0) {
66459
+ const index2 = queue2.indexOf(content);
66460
+ if (index2 >= 0) queue2.splice(index2, 1);
66461
+ }
66462
+ }
66463
+ return queue2.map(unwrapPastedContent).filter((text5) => !text5.trimStart().startsWith("<"));
66464
+ }
66465
+ async function claudeQueueAction(action, status, deps2) {
66466
+ if (status !== "working") throw new BridgeError(409, "This agent is no longer working, so it has already taken its queued messages.", { code: "queue-idle" });
66467
+ const queued = claudeQueued(await deps2.transcript());
66468
+ if (!queued.length) throw new BridgeError(409, "The agent has no queued messages now; it has already taken them.", { code: "queue-empty" });
66469
+ await ready(deps2);
66470
+ if (action === "send-now") {
66471
+ await deps2.sendKeys(["ctrl+x", "ctrl+s"]);
66472
+ if (!await settled3(deps2)) throw new BridgeError(409, "Claude did not take its queued messages. This Claude Code may not have send-now, or its keys were changed.", { code: "queue-not-sent" });
66473
+ return { ok: true, messages: queued };
66474
+ }
66475
+ await deps2.sendKeys(["up"]);
66476
+ if (!await settled3(deps2)) {
66477
+ if (!deps2.held()) await deps2.sendKeys(["ctrl+l"]);
66478
+ throw new BridgeError(409, "Claude did not take its queued messages back. Check the terminal.", { code: "queue-not-withdrawn" });
66479
+ }
66480
+ if (deps2.held()) throw new BridgeError(409, "Claude moved its queued messages into its input box, then asked for input. Clear the box in the terminal.", { code: "queue-not-cleared" });
66481
+ await deps2.sendKeys(["ctrl+l"]);
66482
+ await deps2.sleep(250);
66483
+ if (!claudeInputEmpty(await deps2.screen().catch(() => ""))) {
66484
+ throw new BridgeError(409, "Claude moved its queued messages into its input box but did not clear it. Clear it in the terminal.", { code: "queue-not-cleared" });
66485
+ }
66486
+ return { ok: true, messages: queued };
66487
+ }
66488
+ async function ready(deps2) {
66489
+ if (deps2.held()) throw new BridgeError(409, "This agent needs input in the terminal first.", { code: "queue-held" });
66490
+ const screen = await deps2.screen();
66491
+ if (claudeSubagentView(screen)) throw new BridgeError(409, "The terminal is showing a subagent. Return to the main conversation there first.", { code: "queue-subagent-view" });
66492
+ if (!claudeInputEmpty(screen)) throw new BridgeError(409, "The terminal's input box has text in it. Send or clear it there first.", { code: "queue-input-busy" });
66493
+ if (deps2.held()) throw new BridgeError(409, "This agent needs input in the terminal first.", { code: "queue-held" });
66494
+ }
66495
+ async function settled3(deps2) {
66496
+ for (let read = 0; read < CONFIRM_READS; read++) {
66497
+ await deps2.sleep(100);
66498
+ if (!claudeQueued(await deps2.transcript().catch(() => "")).length) return true;
66499
+ }
66500
+ return false;
66501
+ }
66502
+ var TAIL_BYTES2, CONFIRM_READS;
66503
+ var init_claude_queue = __esm({
66504
+ "src/bridge/claude-queue.ts"() {
66505
+ "use strict";
66506
+ init_protocol();
66507
+ init_claude_suggestion();
66508
+ init_transcript_claude();
66509
+ TAIL_BYTES2 = 1048576;
66510
+ CONFIRM_READS = 30;
66511
+ }
66512
+ });
66513
+
66417
66514
  // src/bridge/server-pane-routes.ts
66418
66515
  import path117 from "node:path";
66419
66516
  import { setTimeout as sleep4 } from "node:timers/promises";
@@ -66611,7 +66708,7 @@ async function submitStartingPrompt(server, target2, terminal2, looks = 4, inter
66611
66708
  return "unknown";
66612
66709
  }
66613
66710
  };
66614
- const settled3 = async () => {
66711
+ const settled4 = async () => {
66615
66712
  for (let look = 0; look < looks; look++) {
66616
66713
  await sleep4(intervalMs);
66617
66714
  const current2 = await status();
@@ -66619,10 +66716,10 @@ async function submitStartingPrompt(server, target2, terminal2, looks = 4, inter
66619
66716
  }
66620
66717
  return "idle";
66621
66718
  };
66622
- const first = await settled3();
66719
+ const first = await settled4();
66623
66720
  if (first !== "idle") return first !== "gone";
66624
66721
  await terminalProvider().sendKeys(server, target2.pane, ["enter"]);
66625
- const second = await settled3();
66722
+ const second = await settled4();
66626
66723
  return second !== "idle" && second !== "gone";
66627
66724
  }
66628
66725
  function secretKeys(text5) {
@@ -66743,7 +66840,7 @@ async function paneRouteOnce(ctx, url2, data, response, typing) {
66743
66840
  }
66744
66841
  } else {
66745
66842
  const target2 = targetSchema.parse(data.target);
66746
- const sendsInput = ["/v1/prompt", "/v1/keys", "/v1/secret", "/v1/model", "/v1/settings", "/v1/agents/permission-mode"].includes(url2.pathname);
66843
+ const sendsInput = ["/v1/prompt", "/v1/prompt/queue", "/v1/keys", "/v1/secret", "/v1/model", "/v1/settings", "/v1/agents/permission-mode"].includes(url2.pathname);
66747
66844
  if (sendsInput) {
66748
66845
  modelSwitcher.assertAvailable(target2);
66749
66846
  settingsSwitcher.assertAvailable(target2);
@@ -66862,6 +66959,19 @@ async function paneRouteOnce(ctx, url2, data, response, typing) {
66862
66959
  const id2 = deliveryIdSchema.parse(data.deliveryId);
66863
66960
  if (!id2) throw new BridgeError(400, "Name the message by its deliveryId.");
66864
66961
  result = { ok: true, ...agentHooks.deliveries.status(id2, target2) };
66962
+ } else if (url2.pathname === "/v1/prompt/queue") {
66963
+ if (data && typeof data === "object" && "origin" in data) throw new BridgeError(403, "Only the owner sends or cancels queued messages, from the phone.");
66964
+ const action = external_exports.enum(["send-now", "withdraw"]).parse(data.action);
66965
+ if (target2.source !== "claude") throw new BridgeError(409, "Only Claude Code's queued messages can be sent now or withdrawn.", { code: "queue-unsupported" });
66966
+ const guards = promptGuards(agentHooks, target2);
66967
+ const transcript = await targetTranscriptPath(target2);
66968
+ result = await claudeQueueAction(action, String(pane.agent_status), {
66969
+ held: guards.held,
66970
+ screen: guards.screen,
66971
+ transcript: () => transcriptTail3(transcript),
66972
+ sendKeys: (keys2) => terminalProvider().sendKeys(target2.server, target2.pane, keys2),
66973
+ sleep: (ms2) => sleep4(ms2)
66974
+ });
66865
66975
  } else if (url2.pathname === "/v1/side-question/dismiss") {
66866
66976
  result = sideQuestions.dismiss(target2, external_exports.string().uuid().parse(data.id));
66867
66977
  } else if (url2.pathname === "/v1/model") {
@@ -67046,6 +67156,7 @@ var init_server_pane_routes = __esm({
67046
67156
  init_prompt_startup();
67047
67157
  init_opencode_panes();
67048
67158
  init_claude_suggestion();
67159
+ init_claude_queue();
67049
67160
  ANSWER_KEYS = ["Escape", "Enter", "Up", "Down", "Tab", "AltUp", "y", "n", "p", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
67050
67161
  HERDR_KEYS = { Escape: "esc", Enter: "enter", Up: "up", Down: "down", Tab: "tab", AltUp: "alt+Up" };
67051
67162
  questionText = external_exports.string().trim().min(1).max(4e3).refine((t) => !/[\x00-\x08\x0b-\x1f\x7f]/.test(t));
@@ -68241,9 +68352,9 @@ function relayLiveSpeech(client, query, options = {}) {
68241
68352
  const reopen = () => {
68242
68353
  const words = resume ?? [];
68243
68354
  resume = void 0;
68244
- open30(words, true);
68355
+ open31(words, true);
68245
68356
  };
68246
- const open30 = (replay = [], resumed = false) => {
68357
+ const open31 = (replay = [], resumed = false) => {
68247
68358
  const model = models[0];
68248
68359
  endpoint = liveEndpoint(model);
68249
68360
  format = formats[0];
@@ -68316,7 +68427,7 @@ function relayLiveSpeech(client, query, options = {}) {
68316
68427
  if (models.length > 1) {
68317
68428
  if (bench) state.bench(model, "failed");
68318
68429
  models = models.slice(1);
68319
- open30([...sent], resumed);
68430
+ open31([...sent], resumed);
68320
68431
  return;
68321
68432
  }
68322
68433
  fail(failure2);
@@ -68326,7 +68437,7 @@ function relayLiveSpeech(client, query, options = {}) {
68326
68437
  detach();
68327
68438
  state.refuseFormat(format);
68328
68439
  formats.shift();
68329
- open30([...sent], resumed);
68440
+ open31([...sent], resumed);
68330
68441
  return;
68331
68442
  }
68332
68443
  if (!accountFailure(status, code) && (status >= 500 || /model/.test(code))) {
@@ -68477,7 +68588,7 @@ function relayLiveSpeech(client, query, options = {}) {
68477
68588
  };
68478
68589
  for (const data of early) handle(data);
68479
68590
  early = [];
68480
- if (!closed) open30(before);
68591
+ if (!closed) open31(before);
68481
68592
  })();
68482
68593
  }
68483
68594
  var OPEN2, MAX_SESSION_MS, KEEP_ALIVE_MS2, HANDSHAKE_MS, FIRST_AUDIO_MS, FORCED_TEXT, MAX_BUFFERED, MAX_EARLY_BYTES, MAX_TEXT3, VOICE_SETTINGS, MAX_PENDING, SpeakableStream;
@@ -68508,9 +68619,9 @@ var init_speech_live = __esm({
68508
68619
  for (const match of this.pending.matchAll(/[.!?:;](?=\s)/g)) cut = Math.max(cut, match.index + 1);
68509
68620
  if (!cut && this.pending.length > MAX_PENDING) cut = this.pending.lastIndexOf(" ", MAX_PENDING) + 1 || MAX_PENDING;
68510
68621
  if (!cut) return "";
68511
- const ready = this.pending.slice(0, cut);
68622
+ const ready2 = this.pending.slice(0, cut);
68512
68623
  this.pending = this.pending.slice(cut);
68513
- return this.speak(ready);
68624
+ return this.speak(ready2);
68514
68625
  }
68515
68626
  end() {
68516
68627
  const rest = this.pending;
@@ -70011,7 +70122,7 @@ var init_code_routes = __esm({
70011
70122
  });
70012
70123
 
70013
70124
  // src/bridge/context.ts
70014
- import { open as open24 } from "node:fs/promises";
70125
+ import { open as open25 } from "node:fs/promises";
70015
70126
  import { constants as constants5 } from "node:fs";
70016
70127
  function count(value2) {
70017
70128
  return typeof value2 === "number" && Number.isSafeInteger(value2) && value2 >= 0 && value2 <= 1e12 ? value2 : void 0;
@@ -70051,7 +70162,7 @@ var init_context2 = __esm({
70051
70162
  ContextUsageReader = class {
70052
70163
  cache = /* @__PURE__ */ new Map();
70053
70164
  async read(file4, session) {
70054
- const handle = await open24(file4, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
70165
+ const handle = await open25(file4, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
70055
70166
  try {
70056
70167
  const metadata = await handle.stat();
70057
70168
  if (!metadata.isFile()) return void 0;
@@ -70147,7 +70258,7 @@ var init_context2 = __esm({
70147
70258
  // src/bridge/questions.ts
70148
70259
  import { execFile as execFile28 } from "node:child_process";
70149
70260
  import { createHash as createHash35 } from "node:crypto";
70150
- import { mkdir as mkdir31, open as open25, stat as stat30, readFile as readFile51, writeFile as writeFile11 } from "node:fs/promises";
70261
+ import { mkdir as mkdir31, open as open26, stat as stat30, readFile as readFile51, writeFile as writeFile11 } from "node:fs/promises";
70151
70262
  import path126 from "node:path";
70152
70263
  import { promisify as promisify26 } from "node:util";
70153
70264
  function asyncQuestion(raw, id2) {
@@ -70427,7 +70538,7 @@ ${attachedFiles(paths)}` : answer2;
70427
70538
  await mkdir31(directory, { recursive: true, mode: 448 });
70428
70539
  const key4 = createHash35("sha256").update(JSON.stringify([target2.source, target2.session, id2])).digest("hex");
70429
70540
  const receiptPath = path126.join(directory, key4);
70430
- const receipt = await open25(receiptPath, "wx", 384).catch((error62) => {
70541
+ const receipt = await open26(receiptPath, "wx", 384).catch((error62) => {
70431
70542
  if (error62.code === "EEXIST") throw new BridgeError(409, "An answer was already submitted. Check the conversation before answering again.");
70432
70543
  throw new BridgeError(503, "Phren could not record this answer. Nothing was sent.");
70433
70544
  });
@@ -70445,7 +70556,7 @@ ${attachedFiles(paths)}` : answer2;
70445
70556
  });
70446
70557
 
70447
70558
  // src/bridge/settings-switch.ts
70448
- import { open as open26, stat as stat31 } from "node:fs/promises";
70559
+ import { open as open27, stat as stat31 } from "node:fs/promises";
70449
70560
  function codexModeFlags(mode) {
70450
70561
  const { approvalPolicy, approvalsReviewer, sandboxPolicy } = CODEX_MODES[mode];
70451
70562
  const sandbox = { readOnly: "read-only", workspaceWrite: "workspace-write", dangerFullAccess: "danger-full-access" }[String(sandboxPolicy?.type)];
@@ -70463,7 +70574,7 @@ function settingsCapabilities(source, codexServed, claudeBypass = false) {
70463
70574
  return void 0;
70464
70575
  }
70465
70576
  async function commandOutput2(file4, from) {
70466
- const handle = await open26(file4, "r");
70577
+ const handle = await open27(file4, "r");
70467
70578
  try {
70468
70579
  const { size } = await handle.stat(), length = Math.min(Math.max(size - from, 0), 1048576), buffer = Buffer.alloc(length);
70469
70580
  await handle.read(buffer, 0, length, from);
@@ -73494,7 +73605,7 @@ var init_enroll = __esm({
73494
73605
 
73495
73606
  // src/bridge/files.ts
73496
73607
  import { constants as constants7 } from "node:fs";
73497
- import { lstat as lstat36, open as open27, readdir as readdir24, realpath as realpath24 } from "node:fs/promises";
73608
+ import { lstat as lstat36, open as open28, readdir as readdir24, realpath as realpath24 } from "node:fs/promises";
73498
73609
  import path139 from "node:path";
73499
73610
  async function browseFiles(root, relative5) {
73500
73611
  if (relative5.length > 4096 || relative5.includes("\0") || relative5.includes("\\") || path139.isAbsolute(relative5) || relative5.split("/").some((part) => part === ".." || part === ".git")) {
@@ -73519,7 +73630,7 @@ async function browseFiles(root, relative5) {
73519
73630
  };
73520
73631
  }
73521
73632
  if (!metadata.isFile()) throw new BridgeError(400, "Only regular files can be viewed.");
73522
- const handle = await open27(resolved, constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK);
73633
+ const handle = await open28(resolved, constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK);
73523
73634
  try {
73524
73635
  const current2 = await handle.stat();
73525
73636
  if (!current2.isFile() || current2.ino !== metadata.ino || current2.dev !== metadata.dev) throw new BridgeError(409, "The file changed. Refresh and try again.");
@@ -78870,8 +78981,8 @@ function completeProjectTask(base, rawProject, input2) {
78870
78981
  const doc = readTasks(root, project);
78871
78982
  if (!doc.ok) throw new BridgeError(404, "No tasks for this project.");
78872
78983
  const stable = id2.slice(4);
78873
- const open30 = [...doc.data.items.Active, ...doc.data.items.Queue].find((item) => item.stableId === stable);
78874
- if (!open30) {
78984
+ const open31 = [...doc.data.items.Active, ...doc.data.items.Queue].find((item) => item.stableId === stable);
78985
+ if (!open31) {
78875
78986
  if (doc.data.items.Done.some((item) => item.stableId === stable)) return { project, id: id2, status: "already-done" };
78876
78987
  throw new BridgeError(404, "No task with this id.");
78877
78988
  }
@@ -79205,7 +79316,7 @@ var init_schedule_update = __esm({
79205
79316
  });
79206
79317
 
79207
79318
  // src/bridge/session-rename.ts
79208
- import { open as open28 } from "node:fs/promises";
79319
+ import { open as open29 } from "node:fs/promises";
79209
79320
  import path148 from "node:path";
79210
79321
  function lastCustomTitle(text5) {
79211
79322
  for (const line of text5.split("\n").reverse()) {
@@ -79230,11 +79341,11 @@ function lastIndexedName(text5, thread) {
79230
79341
  return void 0;
79231
79342
  }
79232
79343
  async function tail(file4) {
79233
- const handle = await open28(file4, "r").catch(() => void 0);
79344
+ const handle = await open29(file4, "r").catch(() => void 0);
79234
79345
  if (!handle) return void 0;
79235
79346
  try {
79236
79347
  const { size } = await handle.stat();
79237
- const length = Math.min(size, TAIL_BYTES2), buffer = Buffer.alloc(length);
79348
+ const length = Math.min(size, TAIL_BYTES3), buffer = Buffer.alloc(length);
79238
79349
  await handle.read(buffer, 0, length, size - length);
79239
79350
  return buffer.toString("utf8");
79240
79351
  } finally {
@@ -79319,7 +79430,7 @@ async function renameSession(server, data, deps2 = defaultRenameDeps) {
79319
79430
  const native = await nativeRename(deps2, server, workspaceId, tabId, pane, label2);
79320
79431
  return { ok: true, label: label2, pane: pane.pane_id, native };
79321
79432
  }
79322
- var renameLabel, renameRequest, TAIL_BYTES2, defaultRenameDeps;
79433
+ var renameLabel, renameRequest, TAIL_BYTES3, defaultRenameDeps;
79323
79434
  var init_session_rename = __esm({
79324
79435
  "src/bridge/session-rename.ts"() {
79325
79436
  "use strict";
@@ -79336,7 +79447,7 @@ var init_session_rename = __esm({
79336
79447
  init_transcripts();
79337
79448
  renameLabel = external_exports.string().trim().min(1).max(80).refine((t) => !/[\x00-\x1f\x7f]/.test(t));
79338
79449
  renameRequest = external_exports.object({ workspaceId: id, tabId: id, paneId: id.optional(), label: renameLabel });
79339
- TAIL_BYTES2 = 262144;
79450
+ TAIL_BYTES3 = 262144;
79340
79451
  defaultRenameDeps = {
79341
79452
  snapshot,
79342
79453
  identity: (server, pane) => paneIdentity(server, pane, true),
@@ -80792,6 +80903,7 @@ var init_server_routes = __esm({
80792
80903
  memoryStore: true,
80793
80904
  promptOnce: true,
80794
80905
  promptStatus: true,
80906
+ queuedMessageActions: ["claude"],
80795
80907
  deliveryFrames: true,
80796
80908
  paneDeliveries: true,
80797
80909
  resources: true,
@@ -80827,7 +80939,7 @@ var init_server_routes = __esm({
80827
80939
 
80828
80940
  // src/bridge/transcript-preview.ts
80829
80941
  import { constants as constants8 } from "node:fs";
80830
- import { open as open29 } from "node:fs/promises";
80942
+ import { open as open30 } from "node:fs/promises";
80831
80943
  function claudePanePreview(rendered, prompt, previous = "", inTurn = false) {
80832
80944
  const screen = rendered.split("\n");
80833
80945
  const raw = screen.map(stripTerminal);
@@ -81013,7 +81125,7 @@ async function readDeltaPreview(target2, file4, rollout) {
81013
81125
  if (target2.source === "codex") return await codexThreadPreview(target2.session) ?? (file4 && rollout ? await rollout.read(file4).catch(() => null) : null);
81014
81126
  if (target2.source !== "opencode" && target2.source !== "phren" || !file4) return null;
81015
81127
  try {
81016
- const handle = await open29(file4 + ".preview.json", constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK);
81128
+ const handle = await open30(file4 + ".preview.json", constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK);
81017
81129
  let bytes;
81018
81130
  try {
81019
81131
  const stat36 = await handle.stat();
@@ -81348,7 +81460,7 @@ function transcriptStreams(ctx) {
81348
81460
  const abort = new AbortController();
81349
81461
  let reader, timer;
81350
81462
  let unwatch;
81351
- let busy2 = false, ready = false, first = true;
81463
+ let busy2 = false, ready2 = false, first = true;
81352
81464
  let awaitingTranscript = false, lastTranscriptLookup = 0;
81353
81465
  let initialPane;
81354
81466
  let busyAt = 0;
@@ -81382,7 +81494,7 @@ function transcriptStreams(ctx) {
81382
81494
  }
81383
81495
  };
81384
81496
  const tick = async () => {
81385
- if (busy2 || !ready || abort.signal.aborted) return;
81497
+ if (busy2 || !ready2 || abort.signal.aborted) return;
81386
81498
  busy2 = true;
81387
81499
  try {
81388
81500
  if (first || pending3.length === 0) {
@@ -81521,7 +81633,7 @@ function transcriptStreams(ctx) {
81521
81633
  stop();
81522
81634
  return;
81523
81635
  }
81524
- ready = true;
81636
+ ready2 = true;
81525
81637
  timer = setInterval(() => {
81526
81638
  countTick(url2.pathname === "/v1/transcripts" ? "stream-transcripts" : "stream-status");
81527
81639
  void tick();
@@ -82700,7 +82812,7 @@ async function main() {
82700
82812
  return askpass2(args[1]);
82701
82813
  }
82702
82814
  const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
82703
- return runBridge2(args, "0.3.61");
82815
+ return runBridge2(args, "0.3.63");
82704
82816
  }
82705
82817
  main().then((code) => {
82706
82818
  process.exitCode = code;
@@ -89,7 +89,7 @@ export const BUILTIN_MODULES = [
89
89
  ...routes("POST", [
90
90
  "/v1/push/register", "/v1/push/answer", "/v1/push/target", "/v1/push/presence", "/v1/files", "/v1/files/delete", "/v1/projects/add", "/v1/simulators/action",
91
91
  "/v1/workspaces/launch", "/v1/workspaces/create", "/v1/workspaces/focus", "/v1/workspaces/rename",
92
- "/v1/workspaces/close", "/v1/sessions/rename", "/v1/sessions/move", "/v1/accounts/claude/add", "/v1/accounts/claude/settings", "/v1/accounts/allowed-pools", "/v1/sessions/move/abort", "/v1/sessions/move/launch", "/v1/prompt", "/v1/prompt/status", "/v1/model", "/v1/settings", "/v1/agents/permission-mode", "/v1/side-question/dismiss", "/v1/keys", "/v1/secret", "/v1/upload",
92
+ "/v1/workspaces/close", "/v1/sessions/rename", "/v1/sessions/move", "/v1/accounts/claude/add", "/v1/accounts/claude/settings", "/v1/accounts/allowed-pools", "/v1/sessions/move/abort", "/v1/sessions/move/launch", "/v1/prompt", "/v1/prompt/status", "/v1/prompt/queue", "/v1/model", "/v1/settings", "/v1/agents/permission-mode", "/v1/side-question/dismiss", "/v1/keys", "/v1/secret", "/v1/upload",
93
93
  "/v1/approvals/answer", "/v1/questions/answer", "/v1/subagents/resume", "/v1/subagents/archive-finished", "/v1/canary",
94
94
  "/v1/speech", "/v1/sudo/answer", "/v1/jobs/cleanup",
95
95
  ]),
@@ -98,7 +98,7 @@ export const BUILTIN_MODULES = [
98
98
  capabilities: [
99
99
  "hook", "transcript", "progress", "images", "prompt", "stop", "terminal", "shell", "paneTerminal", "paneLayout", "deskPresence", "herdr",
100
100
  "webServers", "webPreview", "activity", "approvals", "questions", "accountUsage", "providers",
101
- "files", "repositoryFiles", "fileResolution", "subagents", "sideQuestions", "approvalPush", "simulators", "simulatorStream", "simulatorDevices", "simulatorDrag", "overviewStream", "speech", "speechTimestamps", "speechTimestampStream", "speechLive", "speechVoices", "speechFormats", "transcribe", "promptOnce", "promptStatus", "deliveryFrames", "resources", "sessionRename", "sudo", "sudoOutcome", "previewDeltas", "quickChat", "agentFolder", "launchPermissionMode", "sessionMove", "moveNewChat", "moveConductor", "moveToComputer", "moveResume", "moveSummaryByTarget", "moveConversationCopy", "claudeAccountAdd", "accountPools", "workerRelocation",
101
+ "files", "repositoryFiles", "fileResolution", "subagents", "sideQuestions", "approvalPush", "simulators", "simulatorStream", "simulatorDevices", "simulatorDrag", "overviewStream", "speech", "speechTimestamps", "speechTimestampStream", "speechLive", "speechVoices", "speechFormats", "transcribe", "promptOnce", "promptStatus", "queuedMessageActions", "deliveryFrames", "resources", "sessionRename", "sudo", "sudoOutcome", "previewDeltas", "quickChat", "agentFolder", "launchPermissionMode", "sessionMove", "moveNewChat", "moveConductor", "moveToComputer", "moveResume", "moveSummaryByTarget", "moveConversationCopy", "claudeAccountAdd", "accountPools", "workerRelocation",
102
102
  ],
103
103
  storeFiles: [".runtime/sessions/opencode-*.events.jsonl", ".runtime/approvals/opencode-*.json"],
104
104
  localFiles: ["<bridge>/gitboy-webhooks.json", "<bridge>/installed.json", "<bridge>/versions/**", "<bridge>/current", "<bridge>/dispatch", "<bridge>/askpass", "<bridge>/computer-id", "<bridge>/move-intents/*.json", "<bridge>/move-intents/*.conversation.md", "<bridge>/canary.json", "<bridge>/canary-daily", "<bridge>/moves/*.json", "<bridge>/move-launches/*.json"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.3.61",
3
+ "version": "0.3.63",
4
4
  "description": "Knowledge layer for AI agents - CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {