@phren/cli 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/agent-hook-stores.d.ts +3 -0
- package/dist/bridge/agent-hook-stores.js +5 -0
- package/dist/bridge/agent-hooks.d.ts +159 -5
- package/dist/bridge/agent-hooks.js +663 -49
- package/dist/bridge/approval-summary.d.ts +16 -0
- package/dist/bridge/approval-summary.js +133 -0
- package/dist/bridge/authority-command.d.ts +20 -0
- package/dist/bridge/authority-command.js +120 -0
- package/dist/bridge/authority.d.ts +223 -0
- package/dist/bridge/authority.js +231 -0
- package/dist/bridge/claude-account-setup.d.ts +14 -0
- package/dist/bridge/claude-account-setup.js +69 -0
- package/dist/bridge/claude-accounts.d.ts +49 -0
- package/dist/bridge/claude-accounts.js +195 -0
- package/dist/bridge/code-routes.js +2 -2
- package/dist/bridge/codex-app-server.d.ts +144 -0
- package/dist/bridge/codex-app-server.js +319 -0
- package/dist/bridge/codex-auth-refresh.d.ts +33 -0
- package/dist/bridge/codex-auth-refresh.js +71 -0
- package/dist/bridge/codex-question-reply.d.ts +16 -0
- package/dist/bridge/codex-question-reply.js +57 -0
- package/dist/bridge/codex-review-mode.d.ts +10 -0
- package/dist/bridge/codex-review-mode.js +74 -0
- package/dist/bridge/codex-servers.d.ts +217 -0
- package/dist/bridge/codex-servers.js +636 -0
- package/dist/bridge/command.js +94 -4
- package/dist/bridge/computer-identity.d.ts +75 -0
- package/dist/bridge/computer-identity.js +166 -0
- package/dist/bridge/conductor-group.d.ts +91 -8
- package/dist/bridge/conductor-group.js +105 -9
- package/dist/bridge/conductor-role.d.ts +94 -0
- package/dist/bridge/conductor-role.js +176 -0
- package/dist/bridge/conductor-sets.d.ts +20 -0
- package/dist/bridge/conductor-sets.js +59 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +75 -11
- package/dist/bridge/dispatch-returns.d.ts +123 -19
- package/dist/bridge/dispatch-returns.js +357 -50
- package/dist/bridge/dispatch.d.ts +103 -2
- package/dist/bridge/dispatch.js +272 -40
- package/dist/bridge/fanouts.d.ts +7 -1
- package/dist/bridge/fanouts.js +39 -4
- package/dist/bridge/folder-trust.d.ts +56 -0
- package/dist/bridge/folder-trust.js +195 -0
- package/dist/bridge/grants.d.ts +22 -1
- package/dist/bridge/grants.js +57 -9
- package/dist/bridge/hand-off.d.ts +21 -9
- package/dist/bridge/hand-off.js +58 -45
- package/dist/bridge/harness-status.d.ts +11 -0
- package/dist/bridge/harness-status.js +32 -0
- package/dist/bridge/harnesses.d.ts +39 -0
- package/dist/bridge/harnesses.js +65 -0
- package/dist/bridge/health.d.ts +2 -0
- package/dist/bridge/health.js +1 -1
- package/dist/bridge/herdr.d.ts +11 -2
- package/dist/bridge/herdr.js +98 -23
- package/dist/bridge/hook-fast.d.ts +4 -0
- package/dist/bridge/hook-fast.js +68 -0
- package/dist/bridge/install.d.ts +16 -1
- package/dist/bridge/install.js +88 -21
- package/dist/bridge/launch-brief.d.ts +96 -0
- package/dist/bridge/launch-brief.js +164 -0
- package/dist/bridge/model-switch.d.ts +3 -0
- package/dist/bridge/model-switch.js +17 -1
- package/dist/bridge/models.d.ts +8 -4
- package/dist/bridge/models.js +24 -8
- package/dist/bridge/mux-wire.d.ts +9 -0
- package/dist/bridge/mux-wire.js +19 -0
- package/dist/bridge/opencode-pane-server.d.ts +113 -0
- package/dist/bridge/opencode-pane-server.js +332 -0
- package/dist/bridge/opencode-panes.d.ts +111 -0
- package/dist/bridge/opencode-panes.js +295 -0
- package/dist/bridge/pane-accounts.d.ts +8 -0
- package/dist/bridge/pane-accounts.js +46 -0
- package/dist/bridge/prompt-startup.d.ts +5 -0
- package/dist/bridge/prompt-startup.js +24 -0
- package/dist/bridge/protocol.d.ts +5 -0
- package/dist/bridge/protocol.js +4 -0
- package/dist/bridge/push.d.ts +5 -4
- package/dist/bridge/push.js +6 -4
- package/dist/bridge/questions.d.ts +37 -2
- package/dist/bridge/questions.js +158 -15
- package/dist/bridge/resources.d.ts +9 -3
- package/dist/bridge/resources.js +24 -8
- package/dist/bridge/schedule-format.d.ts +2 -0
- package/dist/bridge/schedule-format.js +3 -0
- package/dist/bridge/schedule-launch.d.ts +2 -1
- package/dist/bridge/schedule-launch.js +23 -53
- package/dist/bridge/schedule-watch.d.ts +10 -1
- package/dist/bridge/schedule-watch.js +54 -2
- package/dist/bridge/server-launch.d.ts +22 -5
- package/dist/bridge/server-launch.js +225 -29
- package/dist/bridge/server-overview.d.ts +3 -3
- package/dist/bridge/server-overview.js +22 -14
- package/dist/bridge/server-pane-routes.d.ts +2 -0
- package/dist/bridge/server-pane-routes.js +145 -15
- package/dist/bridge/server-routes.d.ts +7 -0
- package/dist/bridge/server-routes.js +163 -35
- package/dist/bridge/server-stream.d.ts +2 -0
- package/dist/bridge/server-stream.js +22 -8
- package/dist/bridge/server.d.ts +6 -1
- package/dist/bridge/server.js +44 -12
- package/dist/bridge/session-activity.d.ts +81 -0
- package/dist/bridge/session-activity.js +117 -0
- package/dist/bridge/session-rename.d.ts +48 -0
- package/dist/bridge/session-rename.js +190 -0
- package/dist/bridge/session-servers.js +2 -2
- package/dist/bridge/settings-switch.d.ts +60 -0
- package/dist/bridge/settings-switch.js +287 -0
- package/dist/bridge/speech-voice.d.ts +55 -0
- package/dist/bridge/speech-voice.js +132 -0
- package/dist/bridge/speech.d.ts +70 -11
- package/dist/bridge/speech.js +169 -41
- package/dist/bridge/terminal-herdr.js +9 -3
- package/dist/bridge/terminal-tmux.d.ts +3 -3
- package/dist/bridge/terminal-tmux.js +24 -9
- package/dist/bridge/terminal.d.ts +27 -4
- package/dist/bridge/terminal.js +8 -1
- package/dist/bridge/transcript-claude.js +57 -12
- package/dist/bridge/transcript-codex.d.ts +0 -2
- package/dist/bridge/transcript-codex.js +29 -4
- package/dist/bridge/transcript-preview.d.ts +1 -0
- package/dist/bridge/transcript-preview.js +24 -4
- package/dist/bridge/transcripts.d.ts +15 -2
- package/dist/bridge/transcripts.js +47 -16
- package/dist/bridge/turn-records.d.ts +85 -0
- package/dist/bridge/turn-records.js +143 -0
- package/dist/bridge/uploads.d.ts +3 -0
- package/dist/bridge/uploads.js +14 -0
- package/dist/bridge/usage.d.ts +39 -10
- package/dist/bridge/usage.js +155 -44
- package/dist/bridge-hook.mjs +19169 -13176
- package/dist/cli/claude-unmanaged.d.ts +12 -0
- package/dist/cli/claude-unmanaged.js +105 -0
- package/dist/cli/schedules.js +2 -1
- package/dist/cli/session-start.js +10 -1
- package/dist/cli/session-stop.js +9 -1
- package/dist/cli-registry.js +24 -5
- package/dist/data/task-receipts.d.ts +19 -0
- package/dist/data/task-receipts.js +68 -0
- package/dist/data/tasks.js +4 -1
- package/dist/generated/memory-ui-graph.browser.js +63 -63
- package/dist/graph-core/model.js +24 -3
- package/dist/graph-core/types.d.ts +4 -1
- package/dist/graph-core/types.js +1 -0
- package/dist/init/init-preset.js +7 -3
- package/dist/init/init-uninstall.js +2 -11
- package/dist/init/teardown.d.ts +3 -0
- package/dist/init/teardown.js +47 -0
- package/dist/link/context.js +21 -9
- package/dist/mcp/plugin-mode.js +1 -1
- package/dist/memory-ui-graph.runtime.js +63 -63
- package/dist/modules/code-package.d.ts +1 -0
- package/dist/modules/code-package.js +36 -7
- package/dist/modules/registry.js +14 -13
- package/dist/profile-store.d.ts +6 -0
- package/dist/profile-store.js +25 -1
- package/dist/shell/graph/glyphs.js +4 -0
- package/dist/shell/graph/graph-view.js +2 -0
- package/dist/status.js +7 -1
- package/dist/sync/task-claim.js +3 -2
- package/dist/task/lifecycle.js +25 -4
- package/dist/test-global-setup.js +5 -0
- package/dist/tools/dispatch.js +35 -2
- package/dist/tools/tasks.js +10 -1
- package/package.json +1 -1
- package/plugins/opencode/phren-transcript.js +87 -4
- package/starter/global/skills/conductor/SKILL.md +17 -2
|
@@ -6,15 +6,19 @@ import { fanoutWorktrees } from "./fanouts.js";
|
|
|
6
6
|
import { gitWorktrees, resolveWorktree } from "./git-worktrees.js";
|
|
7
7
|
import { gitCommit, gitPullRequest, gitPush } from "./git-publish.js";
|
|
8
8
|
import { findPane, paneAgentName, paneChatState, paneIdentity, snapshot, startingPane, trustedDirectory, validateStartingTarget, validateTarget } from "./herdr.js";
|
|
9
|
-
import { terminalProvider } from "./terminal.js";
|
|
9
|
+
import { agentNotReady, terminalProvider } from "./terminal.js";
|
|
10
|
+
import { AppServerRpcError } from "./codex-app-server.js";
|
|
11
|
+
import { CodexServerUnavailable, codexServers } from "./codex-servers.js";
|
|
10
12
|
import { refuseWorkingSlash } from "./model-switch.js";
|
|
11
13
|
import { sessionWebServers } from "./session-servers.js";
|
|
12
14
|
import { repositoryDiff } from "./projects.js";
|
|
13
15
|
import { BridgeError, MAX_FRAME, object, objects, startingTargetSchema, targetSchema } from "./protocol.js";
|
|
14
|
-
import { childAgent, childAgentTree, conversationNamedPaths,
|
|
16
|
+
import { childAgent, childAgentTree, conversationNamedPaths, targetTranscriptPath } from "./transcripts.js";
|
|
15
17
|
import { sideQuestionText } from "./side-questions.js";
|
|
16
18
|
import { saveUpload } from "./uploads.js";
|
|
17
19
|
import { deliveryIdSchema, PromptOnce, promptScope } from "./prompt-once.js";
|
|
20
|
+
import { promptWithStartupRetry } from "./prompt-startup.js";
|
|
21
|
+
import { sendServedPrompt, servedPane } from "./opencode-panes.js";
|
|
18
22
|
export /** A file from the phone: a plain name and base64 bytes, bounded. */ function uploadBody(data) {
|
|
19
23
|
const name = z.string().regex(/^[A-Za-z0-9_][A-Za-z0-9_ .()-]{0,199}$/).refine(n => !n.includes("..")).parse(data.name);
|
|
20
24
|
const encoded = z.string().max(11_184_812).regex(/^[A-Za-z0-9+/]*={0,2}$/).parse(data.data);
|
|
@@ -225,6 +229,23 @@ async function typeSecret(server, pane, text) {
|
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
const promptOnce = new PromptOnce();
|
|
232
|
+
/** A prompt for an OpenCode pane the Hook started with its own server: sent
|
|
233
|
+
* over that API into the conversation the TUI shows (a new one, shown first,
|
|
234
|
+
* when it has none) and confirmed by the user turn appearing there. Undefined
|
|
235
|
+
* when the pane has no server entry, the text is a slash command (the TUI's
|
|
236
|
+
* own menus), or nothing reached OpenCode; the caller then types it. */
|
|
237
|
+
async function servedPrompt(target, session, text, typing) {
|
|
238
|
+
if (target.source !== "opencode" || text.trim().startsWith("/"))
|
|
239
|
+
return undefined;
|
|
240
|
+
const entry = servedPane(target.server, target.pane);
|
|
241
|
+
if (!entry)
|
|
242
|
+
return undefined;
|
|
243
|
+
typing();
|
|
244
|
+
const sent = await sendServedPrompt(entry, session, text);
|
|
245
|
+
if (!sent.sent)
|
|
246
|
+
return undefined;
|
|
247
|
+
return sent.delivered ? { ok: true, delivered: true } : { ok: true, deliveryUncertain: true };
|
|
248
|
+
}
|
|
228
249
|
export async function paneRoute(ctx, url, data, response) {
|
|
229
250
|
if (url.pathname !== "/v1/prompt")
|
|
230
251
|
return paneRouteOnce(ctx, url, data, response, () => { });
|
|
@@ -234,7 +255,7 @@ export async function paneRoute(ctx, url, data, response) {
|
|
|
234
255
|
return promptOnce.run(id, promptScope(object(data.target), String(data.text ?? "")), async (typing) => object(await paneRouteOnce(ctx, url, data, response, typing)));
|
|
235
256
|
}
|
|
236
257
|
async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
237
|
-
const { agentHooks, modelSwitcher, codexQuestions, sideQuestions } = ctx;
|
|
258
|
+
const { agentHooks, modelSwitcher, settingsSwitcher, codexQuestions, sideQuestions } = ctx;
|
|
238
259
|
let result;
|
|
239
260
|
if (url.pathname === "/v1/keys" && object(data.target).starting === true) {
|
|
240
261
|
// A folder-trust or login prompt comes before the agent has a
|
|
@@ -261,10 +282,30 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
261
282
|
else if (url.pathname === "/v1/prompt" && object(data.target).starting === true) {
|
|
262
283
|
const target = startingTargetSchema.parse(data.target);
|
|
263
284
|
const pane = await validateStartingTarget(target);
|
|
285
|
+
if (typeof pane.startingSession === "string") {
|
|
286
|
+
const resolved = { ...target, session: pane.startingSession };
|
|
287
|
+
modelSwitcher.assertAvailable(resolved);
|
|
288
|
+
settingsSwitcher.assertAvailable(resolved);
|
|
289
|
+
sideQuestions.assertAvailable(resolved);
|
|
290
|
+
}
|
|
264
291
|
const text = z.string().min(1).max(32768).refine(t => !/[\x00-\x08\x0b-\x1f\x7f]/.test(t)).parse(data.text);
|
|
265
292
|
refuseWorkingSlash(pane, text);
|
|
293
|
+
const served = await servedPrompt(target, undefined, text, typing);
|
|
294
|
+
if (served)
|
|
295
|
+
return served;
|
|
266
296
|
typing();
|
|
267
|
-
await terminalProvider().prompt(target.server, target.pane, text)
|
|
297
|
+
await promptWithStartupRetry(() => terminalProvider().prompt(target.server, target.pane, text), async () => {
|
|
298
|
+
const current = await validateStartingTarget(target);
|
|
299
|
+
if (current.terminal_id !== pane.terminal_id)
|
|
300
|
+
throw new BridgeError(409, "This agent pane changed. Reopen the chat.");
|
|
301
|
+
if (typeof current.startingSession === "string") {
|
|
302
|
+
const resolved = { ...target, session: current.startingSession };
|
|
303
|
+
modelSwitcher.assertAvailable(resolved);
|
|
304
|
+
settingsSwitcher.assertAvailable(resolved);
|
|
305
|
+
sideQuestions.assertAvailable(resolved);
|
|
306
|
+
}
|
|
307
|
+
refuseWorkingSlash(current, text);
|
|
308
|
+
});
|
|
268
309
|
// A dispatched worker's brief is often long enough for Claude Code to
|
|
269
310
|
// swallow the Enter; a slash command opens a menu an Enter would answer.
|
|
270
311
|
const submitted = target.source !== "claude" || text.trim().startsWith("/")
|
|
@@ -287,9 +328,10 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
287
328
|
const target = targetSchema.parse(data.target);
|
|
288
329
|
// Uploads store bytes without answering or interrupting the agent.
|
|
289
330
|
// They still require fresh identity, just like prompt mutations.
|
|
290
|
-
const sendsInput = ["/v1/prompt", "/v1/keys", "/v1/secret", "/v1/model"].includes(url.pathname);
|
|
331
|
+
const sendsInput = ["/v1/prompt", "/v1/keys", "/v1/secret", "/v1/model", "/v1/settings"].includes(url.pathname);
|
|
291
332
|
if (sendsInput) {
|
|
292
333
|
modelSwitcher.assertAvailable(target);
|
|
334
|
+
settingsSwitcher.assertAvailable(target);
|
|
293
335
|
sideQuestions.assertAvailable(target);
|
|
294
336
|
}
|
|
295
337
|
// A key press is how a prompt the agent draws in its terminal gets
|
|
@@ -298,6 +340,7 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
298
340
|
const pane = await validateTarget(target, false, sendsInput || url.pathname === "/v1/upload");
|
|
299
341
|
if (sendsInput) {
|
|
300
342
|
modelSwitcher.assertAvailable(target);
|
|
343
|
+
settingsSwitcher.assertAvailable(target);
|
|
301
344
|
sideQuestions.assertAvailable(target);
|
|
302
345
|
}
|
|
303
346
|
if (url.pathname === "/v1/prompt") {
|
|
@@ -305,9 +348,13 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
305
348
|
// is pending there: an approval the Hook holds or saw, or a
|
|
306
349
|
// status Herdr cannot read. Otherwise the answer keys are the way.
|
|
307
350
|
const status = String(pane.agent_status);
|
|
308
|
-
if (status === "unknown" || (["blocked", "waiting"].includes(status) && (agentHooks.approval(target) || agentHooks.terminalPrompt(target)))) {
|
|
351
|
+
if (status === "unknown" || (["blocked", "waiting"].includes(status) && (agentHooks.approval(target) || agentHooks.terminalPrompt(target) || agentHooks.servedQuestion(target)))) {
|
|
309
352
|
throw new BridgeError(409, "This agent needs input in the terminal first.");
|
|
310
353
|
}
|
|
354
|
+
const text = typeof data.text === "string" && data.text && data.text.length <= 32768 && !/[\x00-\x08\x0b-\x1f\x7f]/.test(data.text) ? data.text : undefined;
|
|
355
|
+
const served = text === undefined ? undefined : await servedPrompt(target, target.session, text, typing);
|
|
356
|
+
if (served)
|
|
357
|
+
return served;
|
|
311
358
|
}
|
|
312
359
|
if (url.pathname === "/v1/prompt") {
|
|
313
360
|
const text = z.string().min(1).max(32768).refine(t => !/[\x00-\x08\x0b-\x1f\x7f]/.test(t)).parse(data.text);
|
|
@@ -317,6 +364,9 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
317
364
|
// A working agent queues typed text and submits it when its turn
|
|
318
365
|
// ends, which can be minutes away; waiting for that only delays
|
|
319
366
|
// the phone. The record still guards the paste for ten minutes.
|
|
367
|
+
// Claude Code is the exception: it takes a message typed mid-turn at
|
|
368
|
+
// once and runs UserPromptSubmit about a third of a second later, so a
|
|
369
|
+
// busy Claude gets the idle wait and the phone a confirmed delivery.
|
|
320
370
|
refuseWorkingSlash(pane, text, target.source);
|
|
321
371
|
if (sideQuestionText(target.source, text) !== undefined) {
|
|
322
372
|
// Claude's `/btw` runs beside the turn and never reaches the transcript:
|
|
@@ -326,11 +376,51 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
326
376
|
}
|
|
327
377
|
if (target.source === "codex" && /^\s*\/model\s+\S/i.test(text))
|
|
328
378
|
throw new BridgeError(422, "Use the model picker to switch Codex models.");
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
379
|
+
// A Codex pane on the Hook's own app-server takes the prompt as a turn on
|
|
380
|
+
// its thread, acknowledged with the turn id; nothing is typed. A slash
|
|
381
|
+
// command is the TUI's own and is still typed. An unreachable server
|
|
382
|
+
// sent nothing, so the pane is typed into instead; a request that may
|
|
383
|
+
// have reached it is reported uncertain and never retried.
|
|
384
|
+
const owned = text.trim().startsWith("/") ? undefined : codexServers.forTarget(target);
|
|
385
|
+
if (owned) {
|
|
386
|
+
typing();
|
|
387
|
+
try {
|
|
388
|
+
const { turnId } = await codexServers.prompt(owned, text);
|
|
389
|
+
return { ok: true, delivered: true, turnId };
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
if (error instanceof AppServerRpcError)
|
|
393
|
+
throw new BridgeError(409, `Codex refused the message: ${error.message}`);
|
|
394
|
+
if (!(error instanceof CodexServerUnavailable))
|
|
395
|
+
return { ok: true, deliveryUncertain: true };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
let busy = String(pane.agent_status) === "working";
|
|
399
|
+
let outcome = await promptWithStartupRetry(async () => {
|
|
400
|
+
const refused = new AbortController();
|
|
401
|
+
const expected = agentHooks.expectDelivery(target, text, busy && target.source !== "claude" ? 300 : 1_500, refused.signal);
|
|
402
|
+
typing();
|
|
403
|
+
try {
|
|
404
|
+
await terminalProvider().prompt(target.server, target.pane, text);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
if (agentNotReady(error))
|
|
408
|
+
refused.abort();
|
|
409
|
+
throw error;
|
|
410
|
+
}
|
|
411
|
+
return expected;
|
|
412
|
+
}, async () => {
|
|
413
|
+
// The same conversation can move to another terminal instance. A
|
|
414
|
+
// retry must retain both bindings and all input reservations.
|
|
415
|
+
const current = await validateTarget(target, true, true);
|
|
416
|
+
if (current.terminal_id !== pane.terminal_id)
|
|
417
|
+
throw new BridgeError(409, "This agent pane changed. Reopen the chat.");
|
|
418
|
+
modelSwitcher.assertAvailable(target);
|
|
419
|
+
settingsSwitcher.assertAvailable(target);
|
|
420
|
+
sideQuestions.assertAvailable(target);
|
|
421
|
+
refuseWorkingSlash(current, text, target.source);
|
|
422
|
+
busy = String(current.agent_status) === "working";
|
|
423
|
+
});
|
|
334
424
|
// Only Claude confirms plain prompts through its hook, and a slash
|
|
335
425
|
// command opens a menu that a second Enter would answer.
|
|
336
426
|
if (outcome === "pending" && target.source === "claude" && !text.trim().startsWith("/")) {
|
|
@@ -346,8 +436,11 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
346
436
|
// along so a Codex /permissions walk can find its confirmation.
|
|
347
437
|
if (/^\/[a-z][a-z0-9_-]*$/i.test(text.trim()))
|
|
348
438
|
agentHooks.menuOpened(target, text.trim());
|
|
439
|
+
const deliveryId = deliveryIdSchema.parse(data.deliveryId);
|
|
349
440
|
if (outcome === "delivered") {
|
|
350
441
|
result = { ok: true, delivered: true };
|
|
442
|
+
if (deliveryId)
|
|
443
|
+
agentHooks.trackDelivery(deliveryId, target, text, "delivered");
|
|
351
444
|
}
|
|
352
445
|
else if (outcome === "unsubmitted") {
|
|
353
446
|
result = { ok: true, deliveryUncertain: true, unsubmitted: true };
|
|
@@ -355,22 +448,44 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
355
448
|
else {
|
|
356
449
|
// The agent has not submitted it yet (a busy agent queues typed
|
|
357
450
|
// input). Recheck fresh identity and never retry; a late
|
|
358
|
-
// submission to another conversation is still refused above.
|
|
451
|
+
// submission to another conversation is still refused above. A bare
|
|
452
|
+
// ok acknowledges transport only, even if this is still the same
|
|
453
|
+
// conversation. Callers needing a submitted turn require delivered.
|
|
359
454
|
let confirmed = false;
|
|
360
455
|
try {
|
|
361
456
|
const current = findPane(await snapshot(target.server), target);
|
|
362
457
|
confirmed = !!current && current.terminal_id === pane.terminal_id && await paneIdentity(target.server, current, true) === target.session;
|
|
363
458
|
}
|
|
364
459
|
catch { /* No reliable post-delivery identity. */ }
|
|
365
|
-
|
|
460
|
+
// Still this conversation, in the same terminal: the agent holds the
|
|
461
|
+
// message (a busy turn queues it) and its hook has not submitted it
|
|
462
|
+
// yet. Queued, not delivered; `/v1/prompt/status` says when it lands.
|
|
463
|
+
if (confirmed && deliveryId)
|
|
464
|
+
agentHooks.trackDelivery(deliveryId, target, text, "queued");
|
|
465
|
+
result = { ok: true, ...(!confirmed ? { deliveryUncertain: true } : { queued: true }) };
|
|
366
466
|
}
|
|
367
467
|
}
|
|
468
|
+
else if (url.pathname === "/v1/prompt/status") {
|
|
469
|
+
// Asked by the phone's own delivery id, so no text is matched again.
|
|
470
|
+
const id = deliveryIdSchema.parse(data.deliveryId);
|
|
471
|
+
if (!id)
|
|
472
|
+
throw new BridgeError(400, "Name the message by its deliveryId.");
|
|
473
|
+
result = { ok: true, state: agentHooks.deliveryState(id, target) };
|
|
474
|
+
}
|
|
368
475
|
else if (url.pathname === "/v1/side-question/dismiss") {
|
|
369
476
|
result = sideQuestions.dismiss(target, z.string().uuid().parse(data.id));
|
|
370
477
|
}
|
|
371
478
|
else if (url.pathname === "/v1/model") {
|
|
372
479
|
result = await modelSwitcher.switch(target, data);
|
|
373
480
|
}
|
|
481
|
+
else if (url.pathname === "/v1/settings") {
|
|
482
|
+
result = await settingsSwitcher.switch(target, data);
|
|
483
|
+
}
|
|
484
|
+
else if (url.pathname === "/v1/keys" && await agentHooks.servedKeys(target, z.array(z.enum(ANSWER_KEYS)).min(1).max(4).parse(data.keys), String(pane.agent_status))) {
|
|
485
|
+
// A served OpenCode pane: Esc aborts its turn or declines its question,
|
|
486
|
+
// a digit answers its question, over its own API.
|
|
487
|
+
result = { ok: true };
|
|
488
|
+
}
|
|
374
489
|
else if (url.pathname === "/v1/keys") {
|
|
375
490
|
const keys = z.array(z.enum(ANSWER_KEYS)).min(1).max(4).parse(data.keys);
|
|
376
491
|
const status = String(pane.agent_status), menu = agentHooks.menuOpen(target);
|
|
@@ -386,8 +501,15 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
386
501
|
if (!cancelled && !holding && (keys.every(key => key === "Escape") ? !["working", "blocked", "waiting", "unknown"].includes(status)
|
|
387
502
|
: !["blocked", "waiting", "unknown"].includes(status)))
|
|
388
503
|
throw new BridgeError(409, keys.every(key => key === "Escape") ? "This agent is no longer working." : "This agent is not waiting for an answer.");
|
|
504
|
+
// Esc on a working Codex pane the Hook runs on its own app-server:
|
|
505
|
+
// decline the thread's parked requests, then interrupt the turn.
|
|
506
|
+
const owned = !cancelled && !holding && keys.every(key => key === "Escape") ? codexServers.forTarget(target) : undefined;
|
|
389
507
|
if (cancelled) {
|
|
390
508
|
result = { ok: true };
|
|
509
|
+
}
|
|
510
|
+
else if (owned && await codexServers.interrupt(owned).catch(() => false)) {
|
|
511
|
+
agentHooks.clearTerminalPrompt(target);
|
|
512
|
+
result = { ok: true, interrupted: true };
|
|
391
513
|
// An older phone answers a released AskUserQuestion one question at
|
|
392
514
|
// a time with its digits; the Hook walks that question in the pane
|
|
393
515
|
// and submits the set after the last.
|
|
@@ -464,7 +586,7 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
464
586
|
const allowed = paths.length ? await agentHooks.changes.recordedPaths(`${target.source}:${target.session}`) : [];
|
|
465
587
|
if (paths.length) {
|
|
466
588
|
try {
|
|
467
|
-
allowed.push(...await conversationNamedPaths(await
|
|
589
|
+
allowed.push(...await conversationNamedPaths(await targetTranscriptPath(target), target.source, cwd, abort.signal));
|
|
468
590
|
}
|
|
469
591
|
catch {
|
|
470
592
|
abort.signal.throwIfAborted(); /* Missing transcripts grant no extra paths; recorded scope still works. */
|
|
@@ -507,11 +629,14 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
507
629
|
else if (url.pathname === "/v1/approvals/answer") {
|
|
508
630
|
const actionId = target.source === "opencode"
|
|
509
631
|
? z.string().regex(/^[A-Za-z0-9_]{1,200}$/).parse(data.actionId)
|
|
510
|
-
: z.string().uuid().parse(data.actionId);
|
|
632
|
+
: z.union([z.string().uuid(), z.string().regex(/^dialog-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)]).parse(data.actionId);
|
|
511
633
|
await agentHooks.answer(target, actionId, data.decision, data.updatedInput);
|
|
512
634
|
result = { ok: true };
|
|
513
635
|
}
|
|
514
636
|
else if (url.pathname === "/v1/questions/answer") {
|
|
637
|
+
// Only a Codex answer can carry the phone's uploads (codex-questions).
|
|
638
|
+
if (target.source !== "codex" && Array.isArray(data.attachments) && data.attachments.length)
|
|
639
|
+
throw new BridgeError(400, "This question takes no attachments.");
|
|
515
640
|
if (target.source === "claude") {
|
|
516
641
|
// Claude's AskUserQuestion, answered in its terminal dialog: the
|
|
517
642
|
// phone names the questions it shows, and the Hook answers only a
|
|
@@ -519,6 +644,11 @@ async function paneRouteOnce(ctx, url, data, response, typing) {
|
|
|
519
644
|
const { questions, answers } = claudeQuestionAnswer(data);
|
|
520
645
|
await agentHooks.answerClaudeQuestions(target, questions, answers);
|
|
521
646
|
}
|
|
647
|
+
else if (target.source === "opencode") {
|
|
648
|
+
// A served OpenCode pane's question, answered over its own API.
|
|
649
|
+
const { questions, answers } = claudeQuestionAnswer(data);
|
|
650
|
+
await agentHooks.answerServedQuestion(target, questions, answers);
|
|
651
|
+
}
|
|
522
652
|
else
|
|
523
653
|
await codexQuestions.answer(target, data);
|
|
524
654
|
result = { ok: true };
|
|
@@ -12,6 +12,7 @@ import type { CodexQuestions } from "./questions.js";
|
|
|
12
12
|
import type { TabActivityStore } from "./tab-activity.js";
|
|
13
13
|
import type { ModelCatalog } from "./models.js";
|
|
14
14
|
import type { ModelSwitcher } from "./model-switch.js";
|
|
15
|
+
import type { SettingsSwitcher } from "./settings-switch.js";
|
|
15
16
|
import type { SideQuestions } from "./side-questions.js";
|
|
16
17
|
import { type AccountUsageReader } from "./usage.js";
|
|
17
18
|
import type { ResourceMonitor } from "./resources.js";
|
|
@@ -55,6 +56,7 @@ export interface RouteContext {
|
|
|
55
56
|
contextUsage: WorkspaceContextUsage;
|
|
56
57
|
modelCatalog: ModelCatalog;
|
|
57
58
|
modelSwitcher: ModelSwitcher;
|
|
59
|
+
settingsSwitcher: SettingsSwitcher;
|
|
58
60
|
sideQuestions: SideQuestions;
|
|
59
61
|
accountUsage: AccountUsageReader;
|
|
60
62
|
resources: ResourceMonitor;
|
|
@@ -76,6 +78,7 @@ export declare const capabilities: {
|
|
|
76
78
|
terminal: string;
|
|
77
79
|
shell: string;
|
|
78
80
|
herdr: boolean;
|
|
81
|
+
sessionRename: boolean;
|
|
79
82
|
diff: boolean;
|
|
80
83
|
webServers: boolean;
|
|
81
84
|
webPreview: string;
|
|
@@ -89,15 +92,19 @@ export declare const capabilities: {
|
|
|
89
92
|
subagents: boolean;
|
|
90
93
|
sideQuestions: boolean;
|
|
91
94
|
dispatch: boolean;
|
|
95
|
+
conductorSets: boolean;
|
|
92
96
|
approvalPush: string;
|
|
93
97
|
simulators: boolean;
|
|
94
98
|
code: boolean;
|
|
95
99
|
overviewStream: boolean;
|
|
96
100
|
speech: boolean;
|
|
97
101
|
speechTimestamps: boolean;
|
|
102
|
+
speechVoices: boolean;
|
|
103
|
+
speechFormats: ("mp3_44100_192" | "pcm_24000" | "pcm_44100")[];
|
|
98
104
|
transcribe: boolean;
|
|
99
105
|
memoryStore: boolean;
|
|
100
106
|
promptOnce: boolean;
|
|
107
|
+
promptStatus: boolean;
|
|
101
108
|
resources: boolean;
|
|
102
109
|
};
|
|
103
110
|
export declare function capabilitiesForModules(snapshot: ModuleSnapshot): Record<string, unknown>;
|