@phren/cli 0.3.44 → 0.3.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/bridge/agent-hook-asks.d.ts +34 -0
  2. package/dist/bridge/agent-hook-asks.js +72 -0
  3. package/dist/bridge/agent-hook-callback.d.ts +22 -0
  4. package/dist/bridge/agent-hook-callback.js +114 -0
  5. package/dist/bridge/agent-hooks.d.ts +7 -74
  6. package/dist/bridge/agent-hooks.js +22 -186
  7. package/dist/bridge/claude-question-dialog.d.ts +6 -0
  8. package/dist/bridge/claude-question-dialog.js +29 -7
  9. package/dist/bridge/codex-app-server.d.ts +5 -0
  10. package/dist/bridge/codex-app-server.js +15 -0
  11. package/dist/bridge/codex-auth-refresh.js +7 -0
  12. package/dist/bridge/dispatch-command.js +7 -1
  13. package/dist/bridge/file-write.js +3 -1
  14. package/dist/bridge/git-host-auth.d.ts +6 -0
  15. package/dist/bridge/git-host-auth.js +45 -0
  16. package/dist/bridge/git-publish.d.ts +1 -1
  17. package/dist/bridge/git-publish.js +75 -8
  18. package/dist/bridge/git-review.js +23 -2
  19. package/dist/bridge/git.d.ts +5 -1
  20. package/dist/bridge/git.js +103 -8
  21. package/dist/bridge/health.d.ts +1 -0
  22. package/dist/bridge/health.js +8 -5
  23. package/dist/bridge/lookup-cache.d.ts +17 -0
  24. package/dist/bridge/lookup-cache.js +70 -0
  25. package/dist/bridge/memory-store.js +40 -14
  26. package/dist/bridge/pair.js +4 -0
  27. package/dist/bridge/peers.js +36 -0
  28. package/dist/bridge/projects.d.ts +14 -0
  29. package/dist/bridge/projects.js +48 -1
  30. package/dist/bridge/prompt-deliveries.d.ts +38 -3
  31. package/dist/bridge/prompt-deliveries.js +196 -36
  32. package/dist/bridge/schedule-format.d.ts +4 -0
  33. package/dist/bridge/schedule-format.js +34 -0
  34. package/dist/bridge/schedule-problems.js +4 -0
  35. package/dist/bridge/scoped-gateway.d.ts +1 -0
  36. package/dist/bridge/scoped-gateway.js +10 -1
  37. package/dist/bridge/server-launch.js +6 -2
  38. package/dist/bridge/server-routes.js +5 -1
  39. package/dist/bridge/session-activity.d.ts +10 -0
  40. package/dist/bridge/session-activity.js +25 -0
  41. package/dist/bridge/session-servers.js +3 -0
  42. package/dist/bridge/{codex-thread-origin.d.ts → thread-origin.d.ts} +8 -0
  43. package/dist/bridge/{codex-thread-origin.js → thread-origin.js} +24 -6
  44. package/dist/bridge/usage.d.ts +4 -0
  45. package/dist/bridge/usage.js +22 -8
  46. package/dist/bridge-hook.mjs +1149 -469
  47. package/dist/cli/namespaces-tasks.js +19 -5
  48. package/dist/cli/ops.d.ts +1 -1
  49. package/dist/cli/ops.js +2 -2
  50. package/dist/cli/schedules.js +16 -9
  51. package/dist/content/summarize.js +46 -6
  52. package/dist/content/validate.d.ts +3 -1
  53. package/dist/content/validate.js +33 -4
  54. package/dist/data/access.d.ts +8 -1
  55. package/dist/data/access.js +27 -9
  56. package/dist/data/notes.d.ts +2 -0
  57. package/dist/data/notes.js +2 -1
  58. package/dist/entrypoint.js +2 -1
  59. package/dist/generated/memory-ui-graph.browser.js +1 -1
  60. package/dist/governance/locks.js +17 -1
  61. package/dist/governance/policy.js +37 -23
  62. package/dist/link/link.js +6 -1
  63. package/dist/memory-ui-graph.runtime.js +1 -1
  64. package/dist/sync/conflict-resolve.d.ts +1 -1
  65. package/dist/sync/conflict-resolve.js +91 -8
  66. package/dist/task/lifecycle.js +2 -1
  67. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ import { type Json } from "./protocol.js";
2
+ import type { PendingServerRequest } from "./codex-app-server.js";
3
+ /** Pure translations between the harnesses' permission asks and the Hook's
4
+ * approval cards (agent-hooks.ts holds and answers them). */
5
+ /** A conductor `dispatch` or `hand_off` ask, with the fields a standing grant matches on. */
6
+ export type ConductorCall = {
7
+ action: "dispatch" | "hand_off";
8
+ project?: string;
9
+ computer?: string;
10
+ };
11
+ /** The approval card's tool and input for an app-server request, in the
12
+ * shapes `approvalSummary` and the phone already read for Codex's hook.
13
+ * Undefined for questions (`item/tool/requestUserInput`) and MCP
14
+ * elicitations, which stay in the pane. */
15
+ export declare function appServerApproval(request: PendingServerRequest): {
16
+ tool: string;
17
+ input: Json;
18
+ } | undefined;
19
+ /** The app-server's answer for the phone's allow or deny (T3's
20
+ * CodexSessionRuntime shapes: accept / decline, a permission grant or none). */
21
+ export declare function appServerDecision(request: PendingServerRequest, allow: boolean): Json;
22
+ /** A conductor `dispatch` or `hand_off` permission ask the Hook can answer
23
+ * itself under a standing grant, or offer the phone two grant-writing answers. */
24
+ export declare function conductorCall(tool: string, input: unknown): ConductorCall | undefined;
25
+ /** The decisions an OpenCode permission ask offers the phone. OpenCode's
26
+ * `always` covers the current session, so both grant answers reply `always`;
27
+ * `allow-everywhere` additionally writes an allow rule into the user's
28
+ * OpenCode config. Advertised as the approval card's `options`, the same
29
+ * shape the phone already renders for a provider-supplied option list. */
30
+ export declare const OPENCODE_APPROVAL_OPTIONS: Json[];
31
+ /** The OpenCode permission reply a card decision maps to: both grant scopes
32
+ * are `always`, a plain approve is `once`, a deny is `reject`. Undefined for
33
+ * anything else. */
34
+ export declare function opencodePermissionReply(decision: unknown): "once" | "always" | "reject" | undefined;
@@ -0,0 +1,72 @@
1
+ import { object, objects } from "./protocol.js";
2
+ /** The approval card's tool and input for an app-server request, in the
3
+ * shapes `approvalSummary` and the phone already read for Codex's hook.
4
+ * Undefined for questions (`item/tool/requestUserInput`) and MCP
5
+ * elicitations, which stay in the pane. */
6
+ export function appServerApproval(request) {
7
+ const params = request.params;
8
+ const reason = typeof params.reason === "string" && params.reason ? { reason: params.reason } : {};
9
+ if (request.method === "item/commandExecution/requestApproval") {
10
+ return { tool: "Bash", input: { ...(typeof params.command === "string" ? { command: params.command } : {}),
11
+ ...(typeof params.cwd === "string" ? { cwd: params.cwd } : {}), ...reason } };
12
+ }
13
+ if (request.method === "item/fileChange/requestApproval") {
14
+ const changes = objects(params.changes);
15
+ const verb = (change) => object(change.kind).type === "add" ? "Add" : object(change.kind).type === "delete" ? "Delete" : "Update";
16
+ const patch = changes.filter(change => typeof change.path === "string").map(change => `*** ${verb(change)} File: ${change.path}`).join("\n");
17
+ return { tool: "apply_patch", input: { ...(patch ? { patch } : {}), ...(typeof params.grantRoot === "string" ? { grantRoot: params.grantRoot } : {}), ...reason } };
18
+ }
19
+ if (request.method === "item/permissions/requestApproval")
20
+ return { tool: "Permissions", input: { permissions: params.permissions ?? {}, ...reason } };
21
+ return undefined;
22
+ }
23
+ /** The app-server's answer for the phone's allow or deny (T3's
24
+ * CodexSessionRuntime shapes: accept / decline, a permission grant or none). */
25
+ export function appServerDecision(request, allow) {
26
+ if (request.method === "item/permissions/requestApproval")
27
+ return { permissions: allow ? object(request.params.permissions) : {}, scope: "turn" };
28
+ return { decision: allow ? "accept" : "decline" };
29
+ }
30
+ /** A conductor `dispatch` or `hand_off` permission ask the Hook can answer
31
+ * itself under a standing grant, or offer the phone two grant-writing answers. */
32
+ export function conductorCall(tool, input) {
33
+ // MCP tool names vary by harness: `dispatch`, `phren.dispatch`,
34
+ // `mcp__phren__dispatch`; phren_admin carries the action in its fields.
35
+ const tail = /(?:^|[.:/]|__)(dispatch|hand_off|phren_admin)$/.exec(tool.replace(/^mcp_phren_/, ""))?.[1];
36
+ const fields = object(input);
37
+ let action;
38
+ if (tail === "dispatch")
39
+ action = "dispatch";
40
+ else if (tail === "hand_off")
41
+ action = "hand_off";
42
+ else if (tail === "phren_admin" && (fields.action === "dispatch" || fields.action === "hand_off"))
43
+ action = fields.action;
44
+ if (!action)
45
+ return undefined;
46
+ const project = typeof fields.project === "string" ? fields.project : undefined;
47
+ const computer = typeof fields.computer === "string" ? fields.computer : undefined;
48
+ return { action, ...(project ? { project } : {}), ...(computer ? { computer } : {}) };
49
+ }
50
+ /** The decisions an OpenCode permission ask offers the phone. OpenCode's
51
+ * `always` covers the current session, so both grant answers reply `always`;
52
+ * `allow-everywhere` additionally writes an allow rule into the user's
53
+ * OpenCode config. Advertised as the approval card's `options`, the same
54
+ * shape the phone already renders for a provider-supplied option list. */
55
+ export const OPENCODE_APPROVAL_OPTIONS = [
56
+ { label: "Allow once", decision: "approve" },
57
+ { label: "Allow for this project", decision: "allow-project" },
58
+ { label: "Allow everywhere", decision: "allow-everywhere" },
59
+ { label: "Deny", decision: "deny" },
60
+ ];
61
+ /** The OpenCode permission reply a card decision maps to: both grant scopes
62
+ * are `always`, a plain approve is `once`, a deny is `reject`. Undefined for
63
+ * anything else. */
64
+ export function opencodePermissionReply(decision) {
65
+ if (decision === "approve")
66
+ return "once";
67
+ if (decision === "deny")
68
+ return "reject";
69
+ if (decision === "allow-project" || decision === "allow-everywhere")
70
+ return "always";
71
+ return undefined;
72
+ }
@@ -0,0 +1,22 @@
1
+ import { type Json, type Provider } from "./protocol.js";
2
+ /** The agent side of the Hook's callbacks: `hook <source>` reads the agent's
3
+ * payload and posts it to the daemon's local socket (agent-hooks.ts). */
4
+ /** What a Stop payload says about the turn it ends: the harness's last
5
+ * assistant message (Claude, Codex) and, from Claude Code, the background
6
+ * tasks still in flight, which will wake the conversation again when they
7
+ * finish. Absent fields are left out, so the Hook falls back to the transcript. */
8
+ export declare function stopFacts(value: Json): {
9
+ background?: number;
10
+ reply?: string;
11
+ };
12
+ /** One agent callback, run as `hook <source>`. Resolves "abandoned" when a
13
+ * tool call's callback ran out of its budget: the caller then exits at once,
14
+ * since a socket or a process read still pending would hold the agent. */
15
+ export declare function agentHook(source: Provider, elapsed?: () => number): Promise<void | "abandoned">;
16
+ /**
17
+ * Runs a callback's work. A PreToolUse or PostToolUse callback gets what is
18
+ * left of TOOL_HOOK_BUDGET_MS since its process started (hook-fast.ts says
19
+ * why): "abandoned" once that runs out, and the caller exits without an
20
+ * answer so the tool runs. Every other event runs to its own timeouts.
21
+ */
22
+ export declare function withinToolBudget<T>(event: string, work: (left: () => number) => Promise<T>, elapsed?: () => number, budgetMs?: number): Promise<T | "abandoned">;
@@ -0,0 +1,114 @@
1
+ import { request } from "node:http";
2
+ import { defaultPhrenPath } from "../shared.js";
3
+ import { activateModules as moduleSnapshot } from "../modules/runtime.js";
4
+ import { object, provider, targetSchema } from "./protocol.js";
5
+ import { hookOutput, TOOL_HOOK_BUDGET_MS } from "./hook-fast.js";
6
+ import { underCodexDaemon } from "./codex-daemon.js";
7
+ import { codexAutoReview } from "./codex-review-mode.js";
8
+ import { claudeHeadlessThread, codexForeignThread } from "./thread-origin.js";
9
+ import { terminalPaneFromEnv } from "./terminal.js";
10
+ import { briefId, DISPATCH_ID_ENV } from "./launch-brief.js";
11
+ import { CODEX_SERVER_ENV, codexServerId } from "./codex-servers.js";
12
+ import { localSocket } from "./agent-hook-stores.js";
13
+ /** The agent side of the Hook's callbacks: `hook <source>` reads the agent's
14
+ * payload and posts it to the daemon's local socket (agent-hooks.ts). */
15
+ /** What a Stop payload says about the turn it ends: the harness's last
16
+ * assistant message (Claude, Codex) and, from Claude Code, the background
17
+ * tasks still in flight, which will wake the conversation again when they
18
+ * finish. Absent fields are left out, so the Hook falls back to the transcript. */
19
+ export function stopFacts(value) {
20
+ const tasks = Array.isArray(value.background_tasks)
21
+ ? value.background_tasks.filter(task => !["completed", "failed", "killed", "stopped"].includes(String(object(task).status))) : undefined;
22
+ return { ...(tasks ? { background: tasks.length } : {}),
23
+ ...(typeof value.last_assistant_message === "string" && value.last_assistant_message.trim() ? { reply: value.last_assistant_message.slice(0, 16_384) } : {}) };
24
+ }
25
+ /** One agent callback, run as `hook <source>`. Resolves "abandoned" when a
26
+ * tool call's callback ran out of its budget: the caller then exits at once,
27
+ * since a socket or a process read still pending would hold the agent. */
28
+ export async function agentHook(source, elapsed = () => performance.now()) {
29
+ provider.parse(source);
30
+ // A missing helper must never prevent the coding agent from running.
31
+ // Inside Herdr only Herdr's pane counts; elsewhere a tmux pane does.
32
+ const place = await terminalPaneFromEnv();
33
+ if (!place)
34
+ return;
35
+ let input = "";
36
+ for await (const chunk of process.stdin) {
37
+ input += chunk.toString();
38
+ if (input.length > 1_048_576)
39
+ return;
40
+ }
41
+ const value = object(JSON.parse(input));
42
+ if (value.agent_id || value.agentId || value.isSidechain || value.is_sidechain)
43
+ return;
44
+ // A `codex exec` or a subagent inside a Codex pane is not the pane's conversation.
45
+ if (source === "codex" && await codexForeignThread(value.transcript_path).catch(() => false))
46
+ return;
47
+ // So is a headless `claude -p` run inside a Claude pane.
48
+ if (source === "claude" && await claudeHeadlessThread(value.transcript_path).catch(() => false))
49
+ return;
50
+ const target = targetSchema.parse({ server: place.server, workspace: place.workspace, tab: place.tab,
51
+ pane: place.pane, source, session: value.session_id || value.sessionId });
52
+ const event = String(value.hook_event_name || "SessionStart");
53
+ return withinToolBudget(event, left => forwardHook(source, target, event, value, left), elapsed);
54
+ }
55
+ /**
56
+ * Runs a callback's work. A PreToolUse or PostToolUse callback gets what is
57
+ * left of TOOL_HOOK_BUDGET_MS since its process started (hook-fast.ts says
58
+ * why): "abandoned" once that runs out, and the caller exits without an
59
+ * answer so the tool runs. Every other event runs to its own timeouts.
60
+ */
61
+ export async function withinToolBudget(event, work, elapsed = () => performance.now(), budgetMs = TOOL_HOOK_BUDGET_MS) {
62
+ if (!event.endsWith("ToolUse"))
63
+ return work(() => Infinity);
64
+ const left = () => Math.floor(budgetMs - elapsed());
65
+ if (left() <= 0)
66
+ return "abandoned";
67
+ let timer;
68
+ const expired = new Promise(resolve => { timer = setTimeout(() => resolve("abandoned"), left()); });
69
+ try {
70
+ return await Promise.race([work(left), expired]);
71
+ }
72
+ finally {
73
+ clearTimeout(timer);
74
+ }
75
+ }
76
+ async function forwardHook(source, target, event, value, left) {
77
+ const modules = moduleSnapshot(defaultPhrenPath(), undefined, true);
78
+ if (!modules.has("hook") || (event.endsWith("ToolUse") && !modules.has("git")))
79
+ return;
80
+ // Codex 0.157 runs hooks inside its shared app-server daemon, whose pane
81
+ // variables belong to whichever pane first started it.
82
+ // The Hook's own per-pane app-server (codex-servers.ts) runs its hooks
83
+ // with that pane's variables, so they are trusted like a pane's own.
84
+ const ownServer = source === "codex" && codexServerId.safeParse(process.env[CODEX_SERVER_ENV]).success;
85
+ const daemon = source === "codex" && !ownServer && await underCodexDaemon().catch(() => false);
86
+ // Codex asks this hook before its automatic reviewer: say when that
87
+ // reviewer, not the owner, will decide.
88
+ const autoReview = source === "codex" && event === "PermissionRequest" && await codexAutoReview(value.transcript_path);
89
+ // A worker the Hook launched with its brief carries that dispatch's id. A
90
+ // daemon's variables belong to another pane, so it sends none.
91
+ const dispatchId = !daemon && (event === "SessionStart" || event === "UserPromptSubmit") && briefId.safeParse(process.env[DISPATCH_ID_ENV]).success
92
+ ? process.env[DISPATCH_ID_ENV] : undefined;
93
+ const data = JSON.stringify({ target, event, ...(daemon ? { daemon: true } : {}), ...(autoReview ? { autoReview: true } : {}), ...(dispatchId ? { dispatchId } : {}),
94
+ ...(source === "claude" && typeof value.transcript_path === "string" ? { transcript: value.transcript_path.slice(0, 4096) } : {}),
95
+ tool: value.tool_name, input: value.tool_input, toolUseId: value.tool_use_id, cwd: value.cwd,
96
+ ...(event === "UserPromptSubmit" && typeof value.prompt === "string" ? { prompt: value.prompt.slice(0, 65_536) } : {}),
97
+ ...(event === "Stop" ? stopFacts(value) : {}) });
98
+ await new Promise(resolve => {
99
+ const req = request({ socketPath: localSocket(), path: "/hook", method: "POST", timeout: event === "PermissionRequest" ? 58_000 : event.endsWith("ToolUse") ? Math.max(1, left()) : 12_000,
100
+ headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(data) } }, res => {
101
+ let result = "";
102
+ res.on("data", chunk => { result += chunk.toString(); if (result.length > 16_384)
103
+ req.destroy(); });
104
+ // Forward approval/refusal decisions and validated turn context.
105
+ // Tool callbacks stay silent, and an empty reply says nothing.
106
+ res.on("end", () => { if (res.statusCode === 200)
107
+ process.stdout.write(hookOutput(event, result)); resolve(); });
108
+ res.on("error", () => resolve());
109
+ });
110
+ req.on("error", () => resolve());
111
+ req.on("timeout", () => { req.destroy(); resolve(); });
112
+ req.end(data);
113
+ });
114
+ }
@@ -1,6 +1,6 @@
1
- import { type ModuleSnapshot } from "../modules/runtime.js";
1
+ import type { ModuleSnapshot } from "../modules/runtime.js";
2
2
  import { type ServerResponse } from "node:http";
3
- import { type Json, type Provider, type Target } from "./protocol.js";
3
+ import { type Json, type Target } from "./protocol.js";
4
4
  import { ToolChanges } from "./changes.js";
5
5
  import { ApprovalPushService } from "./push.js";
6
6
  import { type RequestKind } from "./approval-summary.js";
@@ -8,11 +8,14 @@ import { type DialogAnswer, type DialogQuestion } from "./claude-question-dialog
8
8
  import { type TerminalChoice } from "./terminal-choice.js";
9
9
  import { ApprovalWatchLeases } from "./agent-hook-stores.js";
10
10
  import { PromptDeliveries } from "./prompt-deliveries.js";
11
+ import { type ConductorCall } from "./agent-hook-asks.js";
11
12
  import { SudoBroker } from "./sudo.js";
12
13
  import type { AppServerRequestId, PendingServerRequest } from "./codex-app-server.js";
13
14
  import { PaneServerWatcher, type PaneAsks } from "./opencode-panes.js";
14
15
  import type { PaneClient, PaneServerEntry } from "./opencode-pane-server.js";
15
16
  export { permissionPrompt, terminalChoice, visibleTerminalChoice, type TerminalChoice, type TerminalQuestion } from "./terminal-choice.js";
17
+ export { appServerApproval, appServerDecision, conductorCall, OPENCODE_APPROVAL_OPTIONS, opencodePermissionReply } from "./agent-hook-asks.js";
18
+ export { agentHook, stopFacts, withinToolBudget } from "./agent-hook-callback.js";
16
19
  export { ApprovalWatchLeases, PushBindingStore, recordedSession } from "./agent-hook-stores.js";
17
20
  /** Where a held request's answer goes: the callback's HTTP response, or the
18
21
  * reply to a Codex app-server request (codex-servers.ts). Either takes the
@@ -21,44 +24,6 @@ export { ApprovalWatchLeases, PushBindingStore, recordedSession } from "./agent-
21
24
  * `req.destroyed`: a request body read to its end is destroyed on every
22
25
  * Node this supports, so that read as a hang-up on each normal callback. */
23
26
  export declare function watchHangUp(res: ServerResponse): () => boolean;
24
- interface HeldReply {
25
- end(body: string): unknown;
26
- readonly destroyed: boolean;
27
- }
28
- interface Pending {
29
- target: Target;
30
- response: HeldReply;
31
- tool: string;
32
- input: unknown;
33
- message: string;
34
- request: string;
35
- requestKind: RequestKind;
36
- title?: string;
37
- choice?: TerminalChoice;
38
- expiresAt: string;
39
- timer?: NodeJS.Timeout;
40
- conductor?: {
41
- action: "dispatch" | "hand_off";
42
- project?: string;
43
- computer?: string;
44
- };
45
- /** A server request of the Hook's own Codex app-server: answered over RPC, never held on a timer. */
46
- appServer?: {
47
- requestId: AppServerRequestId;
48
- answer: (result: Json) => void;
49
- };
50
- }
51
- /** The approval card's tool and input for an app-server request, in the
52
- * shapes `approvalSummary` and the phone already read for Codex's hook.
53
- * Undefined for questions (`item/tool/requestUserInput`) and MCP
54
- * elicitations, which stay in the pane. */
55
- export declare function appServerApproval(request: PendingServerRequest): {
56
- tool: string;
57
- input: Json;
58
- } | undefined;
59
- /** The app-server's answer for the phone's allow or deny (T3's
60
- * CodexSessionRuntime shapes: accept / decline, a permission grant or none). */
61
- export declare function appServerDecision(request: PendingServerRequest, allow: boolean): Json;
62
27
  /** What a dispatched worker's Hook tells the dispatching Hook it is waiting on:
63
28
  * a card without the request's full message or details, which can run to 32 KB
64
29
  * and cross SSH on every poll. */
@@ -71,23 +36,10 @@ export interface ForwardedApproval {
71
36
  expiresAt?: string;
72
37
  /** The pane is drawing this as a terminal dialog; the answer types its keys. */
73
38
  terminal?: true;
74
- conductor?: Pending["conductor"];
39
+ conductor?: ConductorCall;
75
40
  /** This Hook already pushed the request to a phone, so the dispatching Hook does not push it again. */
76
41
  pushed?: true;
77
42
  }
78
- /** A conductor `dispatch` or `hand_off` permission ask the Hook can answer
79
- * itself under a standing grant, or offer the phone two grant-writing answers. */
80
- export declare function conductorCall(tool: string, input: unknown): Pending["conductor"] | undefined;
81
- /** The decisions an OpenCode permission ask offers the phone. OpenCode's
82
- * `always` covers the current session, so both grant answers reply `always`;
83
- * `allow-everywhere` additionally writes an allow rule into the user's
84
- * OpenCode config. Advertised as the approval card's `options`, the same
85
- * shape the phone already renders for a provider-supplied option list. */
86
- export declare const OPENCODE_APPROVAL_OPTIONS: Json[];
87
- /** The OpenCode permission reply a card decision maps to: both grant scopes
88
- * are `always`, a plain approve is `once`, a deny is `reject`. Undefined for
89
- * anything else. */
90
- export declare function opencodePermissionReply(decision: unknown): "once" | "always" | "reject" | undefined;
91
43
  export declare class AgentHooks {
92
44
  readonly push: ApprovalPushService;
93
45
  private modules?;
@@ -256,7 +208,7 @@ export declare class AgentHooks {
256
208
  /** The pane with its colors, for dialogs whose cursor is only a color. */
257
209
  paneAnsi(target: Target): Promise<string>;
258
210
  /** Read what the pane draws, stripping ANSI unless placeholder styling is needed. */
259
- paneLines(target: Target, stripAnsi?: boolean): Promise<string>;
211
+ paneLines(target: Target, stripAnsi?: boolean, lines?: number): Promise<string>;
260
212
  /** After the phone walks Codex's /permissions menu onto Full Access, the
261
213
  * agent draws a second "Enable full access?" confirmation. Watch the pane's
262
214
  * terminal lines for it, answer with its own numbered choice, and only then
@@ -352,22 +304,3 @@ export declare class AgentHooks {
352
304
  start(): Promise<void>;
353
305
  close(): void;
354
306
  }
355
- /** What a Stop payload says about the turn it ends: the harness's last
356
- * assistant message (Claude, Codex) and, from Claude Code, the background
357
- * tasks still in flight, which will wake the conversation again when they
358
- * finish. Absent fields are left out, so the Hook falls back to the transcript. */
359
- export declare function stopFacts(value: Json): {
360
- background?: number;
361
- reply?: string;
362
- };
363
- /** One agent callback, run as `hook <source>`. Resolves "abandoned" when a
364
- * tool call's callback ran out of its budget: the caller then exits at once,
365
- * since a socket or a process read still pending would hold the agent. */
366
- export declare function agentHook(source: Provider, elapsed?: () => number): Promise<void | "abandoned">;
367
- /**
368
- * Runs a callback's work. A PreToolUse or PostToolUse callback gets what is
369
- * left of TOOL_HOOK_BUDGET_MS since its process started (hook-fast.ts says
370
- * why): "abandoned" once that runs out, and the caller exits without an
371
- * answer so the tool runs. Every other event runs to its own timeouts.
372
- */
373
- export declare function withinToolBudget<T>(event: string, work: (left: () => number) => Promise<T>, elapsed?: () => number, budgetMs?: number): Promise<T | "abandoned">;