@conveno/cli 0.2.0-rc.1 → 0.2.0-rc.10

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.
@@ -1,573 +1,3 @@
1
- import { Ft as relayPermission, Gt as startTurnContext, H as entriesNewestFirst, Ht as samePath, I as describeToolCall, Jt as tailJsonl, Mt as readTailLines, Ot as readHeadLine, Pt as recordCliInfo, V as endTurnContinuation, X as formatPermissionDecision, Zt as toIso, _ as asString, dt as notFound, it as isTranscriptPath, pt as parseCliVersion, qt as subdirsNewestFirst, rn as waitForWork, rt as isRecord, vt as pendingHookContext, yt as pickNewestSince } from "./dist-_qrCNXUP.js";
2
- import { isAbsolute, join } from "node:path";
3
- import { readFile, stat } from "node:fs/promises";
4
- import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
5
- // ../adapters/claude/dist/index.js
6
- const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
7
- /** Read a JSON object file. Missing or blank files give `{}`; anything else that is not a JSON object throws. */
8
- async function loadJson(path) {
9
- let raw;
10
- try {
11
- raw = await readFile(path, "utf8");
12
- } catch (err) {
13
- if (err.code === "ENOENT") raw = null;
14
- else throw new Error(`Cannot read ${path}: ${err.message}. Check its permissions.`);
15
- }
16
- if (raw === null || raw.trim() === "") return {
17
- raw,
18
- value: {},
19
- indent: 2,
20
- trailingNewline: true
21
- };
22
- let value;
23
- try {
24
- value = JSON.parse(raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw);
25
- } catch (err) {
26
- throw new Error(`${path} is not valid JSON (${err.message}). Fix or remove the file, then run the install again. Nothing was changed.`);
27
- }
28
- if (!isObject(value)) throw new Error(`${path} must contain a JSON object at the top level. Fix the file, then run the install again. Nothing was changed.`);
29
- return {
30
- raw,
31
- value,
32
- indent: detectIndent(raw),
33
- trailingNewline: raw.endsWith("\n")
34
- };
35
- }
36
- function detectIndent(raw) {
37
- const m = /^([ \t]+)\S/m.exec(raw);
38
- if (!m?.[1]) return 2;
39
- return m[1].startsWith(" ") ? " " : m[1].length;
40
- }
41
- /**
42
- * Apply edits to the file's own text. Only the touched keys change: other keys, duplicate keys,
43
- * escapes, key order and line endings stay as they were, byte for byte.
44
- */
45
- function editJson(file, edits) {
46
- const bom = file.raw?.charCodeAt(0) === 65279;
47
- let text = file.raw === null || file.raw.trim() === "" ? "{}\n" : file.raw;
48
- if (bom) text = text.slice(1);
49
- const eol = text.includes("\r\n") ? "\r\n" : "\n";
50
- const formattingOptions = {
51
- insertSpaces: file.indent !== " ",
52
- tabSize: typeof file.indent === "number" ? file.indent : 2,
53
- eol
54
- };
55
- for (const e of edits) text = applyEdits(text, modify(text, e.path, e.value, { formattingOptions }));
56
- return (bom ? "" : "") + text;
57
- }
58
- /**
59
- * EXPERIMENTAL permission relay for Claude Code. The `PermissionRequest` hook runs when Claude
60
- * Code is about to ask the user for permission; printing no decision leaves the normal prompt in
61
- * place, and printing `behavior: allow` or `deny` answers it. See
62
- * https://code.claude.com/docs/en/hooks#permissionrequest and its decision control section.
63
- */
64
- const PERMISSION_EVENT$1 = "PermissionRequest";
65
- /** Seconds, in the hook config: longer than the relay's own wait, so Claude never cuts it first. */
66
- const PERMISSION_TIMEOUT_SECONDS$1 = 100;
67
- const EMPTY$1$3 = {
68
- stdout: "",
69
- exitCode: 0
70
- };
71
- const asObject$2 = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
72
- const text$1 = (v) => typeof v === "string" && v ? v : void 0;
73
- /** Claude's tools that touch one file, and the `tool_input` field naming it. */
74
- const FILE_FIELD = {
75
- Edit: "file_path",
76
- Write: "file_path",
77
- MultiEdit: "file_path",
78
- NotebookEdit: "notebook_path"
79
- };
80
- /** The request in the shape the relay takes, or null when the hook input is not one. */
81
- function callFromInput$1(input) {
82
- const body = asObject$2(input);
83
- const tool = text$1(body.tool_name);
84
- if (!tool) return null;
85
- const toolInput = asObject$2(body.tool_input);
86
- const call = { tool };
87
- const command = text$1(toolInput.command);
88
- if (command) call.command = command;
89
- const file = text$1(toolInput[FILE_FIELD[tool] ?? ""]);
90
- if (file) call.paths = [file];
91
- const description = text$1(toolInput.description);
92
- if (description) call.description = description;
93
- const cwd = text$1(body.cwd);
94
- if (cwd) call.cwd = cwd;
95
- return call;
96
- }
97
- /** Never throws. No output means Claude Code shows its own prompt. */
98
- async function permissionHook$1(input, ctx) {
99
- const call = callFromInput$1(input);
100
- if (!call) return EMPTY$1$3;
101
- const decision = await relayPermission(ctx, call);
102
- if (!decision) return EMPTY$1$3;
103
- return {
104
- stdout: formatPermissionDecision(decision, PERMISSION_EVENT$1),
105
- exitCode: 0
106
- };
107
- }
108
- /**
109
- * Claude Code keeps each session as a JSONL file at `<config dir>/projects/<project>/<session-id>.jsonl`,
110
- * where `<project>` is the working directory with every character that is not a letter or digit
111
- * replaced by `-` (a longer name is cut and hashed; on Windows it can be a hash).
112
- * https://code.claude.com/docs/en/sessions (reference/docs/claude-code, "Where transcripts are stored")
113
- *
114
- * Hooks receive `session_id` and `transcript_path` (https://code.claude.com/docs/en/hooks, common
115
- * input fields), which is the exact file. The line format is internal to Claude Code and changes
116
- * between versions, so only the fields below are read and anything else is skipped.
117
- */
118
- /** Claude Code's project directory name for a working directory. */
119
- const projectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/g, "-");
120
- const configDir$1 = (env) => env.env.CLAUDE_CONFIG_DIR?.trim() || join(env.home, ".claude");
121
- const fileExists$1 = (p) => stat(p).then((s) => s.isFile(), () => false);
122
- /** Text of a user or tool_result content block list, without system reminders. */
123
- function blockText(content) {
124
- if (typeof content === "string") return content;
125
- if (!Array.isArray(content)) return "";
126
- const parts = [];
127
- for (const b of content) {
128
- if (!isRecord(b)) continue;
129
- if (b.type === "text" && typeof b.text === "string") parts.push(b.text);
130
- }
131
- return parts.join("\n");
132
- }
133
- const isReminder = (text) => text.trimStart().startsWith("<system-reminder>");
134
- /** Normalize one JSONL record. Exported for tests. */
135
- function parseClaudeLine(obj) {
136
- const type = obj.type;
137
- if (type !== "user" && type !== "assistant") return [];
138
- if (obj.isSidechain === true || obj.isMeta === true) return [];
139
- const message = obj.message;
140
- if (!isRecord(message)) return [];
141
- const at = toIso(obj.timestamp);
142
- const stamp = at ? { at } : {};
143
- const content = message.content;
144
- if (typeof content === "string") return content === "" || isReminder(content) ? [] : [{
145
- role: type,
146
- text: content,
147
- ...stamp
148
- }];
149
- if (!Array.isArray(content)) return [];
150
- const out = [];
151
- const text = [];
152
- for (const b of content) {
153
- if (!isRecord(b)) continue;
154
- if (b.type === "text" && typeof b.text === "string") {
155
- if (b.text !== "" && !isReminder(b.text)) text.push(b.text);
156
- } else if (b.type === "tool_use" && type === "assistant") {
157
- if (text.length > 0) out.push({
158
- role: "assistant",
159
- text: text.join("\n"),
160
- ...stamp
161
- });
162
- text.length = 0;
163
- out.push({
164
- role: "tool",
165
- text: describeToolCall(asString(b.name) ?? "tool", b.input),
166
- ...stamp
167
- });
168
- } else if (b.type === "tool_result" && type === "user") {
169
- const result = blockText(b.content);
170
- out.push({
171
- role: "tool",
172
- text: result === "" ? "(no output)" : result,
173
- ...stamp
174
- });
175
- }
176
- }
177
- if (text.length > 0) out.push({
178
- role: type,
179
- text: text.join("\n"),
180
- ...stamp
181
- });
182
- return out;
183
- }
184
- /** The `cwd` recorded in a transcript's records (each carries one), for directories whose name is a hash. */
185
- async function recordedCwd(path) {
186
- try {
187
- const { lines } = await readTailLines(path, () => true, 65536);
188
- for (const line of lines.slice(0, 40)) {
189
- const obj = JSON.parse(line);
190
- if (isRecord(obj) && typeof obj.cwd === "string") return obj.cwd;
191
- }
192
- } catch {}
193
- }
194
- async function jsonlIn(dir) {
195
- return (await entriesNewestFirst(dir)).filter((e) => !e.dir && e.name.endsWith(".jsonl"));
196
- }
197
- /** Find the transcript file for a session, or the reason there is none. */
198
- async function locateClaudeTranscript(q, env) {
199
- if (q.transcriptPath && isTranscriptPath(q.transcriptPath, ".jsonl")) {
200
- if (await fileExists$1(q.transcriptPath)) return { path: q.transcriptPath };
201
- }
202
- const projects = join(configDir$1(env), "projects");
203
- if (q.cliSessionId && /^[A-Za-z0-9_-]{1,200}$/.test(q.cliSessionId)) {
204
- const direct = join(projects, projectSlug(q.cwd), `${q.cliSessionId}.jsonl`);
205
- if (await fileExists$1(direct)) return { path: direct };
206
- for (const dir of await subdirsNewestFirst(projects)) {
207
- const p = join(dir, `${q.cliSessionId}.jsonl`);
208
- if (await fileExists$1(p)) return { path: p };
209
- }
210
- }
211
- const here = pickNewestSince(await jsonlIn(join(projects, projectSlug(q.cwd))), q.startedAt);
212
- if (here) return { path: here.path };
213
- for (const dir of await subdirsNewestFirst(projects)) {
214
- const newest = pickNewestSince(await jsonlIn(dir), q.startedAt);
215
- if (newest && await recordedCwd(newest.path) === q.cwd) return { path: newest.path };
216
- }
217
- return { error: "no transcript for this working directory since the session started" };
218
- }
219
- const claudeTranscript = { async read(q, env) {
220
- try {
221
- const found = await locateClaudeTranscript(q, env);
222
- if ("error" in found) return notFound("Claude Code", found.error);
223
- const { entries, more } = await tailJsonl(found.path, q.lastTurns, parseClaudeLine);
224
- return {
225
- ok: true,
226
- entries,
227
- more
228
- };
229
- } catch (e) {
230
- return notFound("Claude Code", e instanceof Error ? e.message : "read failed");
231
- }
232
- } };
233
- const SERVER_NAME$2 = "conveno";
234
- /** Claude Code events Conveno installs hooks for. */
235
- const HOOK_EVENTS$1 = [
236
- "SessionStart",
237
- "UserPromptSubmit",
238
- "Stop"
239
- ];
240
- /**
241
- * PermissionRequest is the experimental permission relay. It is planned only when asked for
242
- * (`conveno init --with-permission-relay`, or the first `conveno permissions relay on`), and does
243
- * nothing until a session turns the relay on. Uninstall always knows it.
244
- */
245
- const ALL_HOOK_EVENTS$1 = [...HOOK_EVENTS$1, PERMISSION_EVENT$1];
246
- /** The background listener's `conveno hook claude <arg>`. It is armed on SessionStart and Stop. */
247
- const LISTEN_EVENT = "Listen";
248
- /**
249
- * Seconds. Claude Code enforces `timeout` on an `asyncRewake` hook
250
- * (https://code.claude.com/docs/en/hooks, "Run hooks in the background"), so one armed listener
251
- * waits at most a day. Every SessionStart and Stop arms a fresh one, which replaces the old.
252
- */
253
- const LISTEN_TIMEOUT_SECONDS = 86400;
254
- /** The listener gives up on its own a few minutes before Claude Code's timeout, so it exits 0 instead of being killed. */
255
- const LISTEN_MAX_MS = 861e5;
256
- /** The handlers Conveno wants on each event, in order: the hook itself, then a listener where one is armed. */
257
- const HANDLERS = {
258
- SessionStart: ["SessionStart", LISTEN_EVENT],
259
- UserPromptSubmit: ["UserPromptSubmit"],
260
- Stop: ["Stop", LISTEN_EVENT],
261
- [PERMISSION_EVENT$1]: [PERMISSION_EVENT$1]
262
- };
263
- const EMPTY$4 = {
264
- stdout: "",
265
- exitCode: 0
266
- };
267
- /** `~/.claude.json` holds user-scope MCP servers; settings.json holds hooks. Both honor CLAUDE_CONFIG_DIR. */
268
- function paths(env) {
269
- const dir = env.env.CLAUDE_CONFIG_DIR;
270
- if (dir) return {
271
- mcp: join(dir, ".claude.json"),
272
- settings: join(dir, "settings.json")
273
- };
274
- return {
275
- mcp: join(env.home, ".claude.json"),
276
- settings: join(env.home, ".claude", "settings.json")
277
- };
278
- }
279
- /**
280
- * Quote one word of a hook command for the shell Claude Code runs it in. On Windows that is Git
281
- * Bash (PowerShell only when Git Bash is not installed), so the word is written for bash. Windows
282
- * paths use forward slashes there: bash would read `\P` inside double quotes as an escape, and
283
- * Windows accepts `/` in every API Node and Git Bash use, so `C:/Program Files/nodejs/node.exe`
284
- * means the same file and needs no escaping.
285
- */
286
- function quoteHookWord(arg, platform) {
287
- const word = platform === "win32" ? arg.replace(/\\/g, "/") : arg;
288
- return /^[A-Za-z0-9_@%+=:,./\\-]+$/.test(word) ? word : `"${word.replace(/(["\\$`])/g, "\\$1")}"`;
289
- }
290
- const hookCommand$1 = (env, event) => [
291
- ...env.conveno.command,
292
- "hook",
293
- "claude",
294
- event
295
- ].map((w) => quoteHookWord(w, env.platform)).join(" ");
296
- /** One hook handler as written to settings.json. The listener runs in the background (`asyncRewake`). */
297
- function handlerFor(env, arg) {
298
- const command = hookCommand$1(env, arg);
299
- return arg === "Listen" ? {
300
- type: "command",
301
- command,
302
- asyncRewake: true,
303
- timeout: LISTEN_TIMEOUT_SECONDS
304
- } : {
305
- type: "command",
306
- command,
307
- timeout: arg === "PermissionRequest" ? PERMISSION_TIMEOUT_SECONDS$1 : 5
308
- };
309
- }
310
- const mcpArgs = (env) => [
311
- ...env.conveno.command,
312
- "mcp",
313
- "--cli",
314
- "claude"
315
- ];
316
- const desiredServer = (env) => {
317
- const [command = "conveno", ...args] = mcpArgs(env);
318
- return {
319
- type: "stdio",
320
- command,
321
- args,
322
- env: {}
323
- };
324
- };
325
- /** Recognizes our hook command even if the conveno path changed since install. */
326
- const isOurHookCommand = (cmd) => typeof cmd === "string" && /(^|\s)hook claude (SessionStart|UserPromptSubmit|Stop|Listen|PermissionRequest)$/.test(cmd.trim());
327
- const sameJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
328
- function groupsOf(hooks, event) {
329
- const g = hooks[event];
330
- return Array.isArray(g) ? g : [];
331
- }
332
- function hasExactHook(hooks, event, handler) {
333
- return groupsOf(hooks, event).some((g) => isObject(g) && Array.isArray(g.hooks) && g.hooks.some((h) => sameJson(h, handler)));
334
- }
335
- /** Every handler Conveno wants on `event` is there, exactly. */
336
- const eventComplete = (env, hooks, event) => HANDLERS[event].every((arg) => hasExactHook(hooks, event, handlerFor(env, arg)));
337
- /** Drop our hook handlers (and groups left empty by that). */
338
- function stripOurHooks(groups) {
339
- const out = [];
340
- for (const g of groups) {
341
- if (!isObject(g) || !Array.isArray(g.hooks)) {
342
- out.push(g);
343
- continue;
344
- }
345
- const kept = g.hooks.filter((h) => !(isObject(h) && isOurHookCommand(h.command)));
346
- if (kept.length === g.hooks.length) out.push(g);
347
- else if (kept.length > 0) out.push({
348
- ...g,
349
- hooks: kept
350
- });
351
- }
352
- return out;
353
- }
354
- function hooksObject(settings, path) {
355
- const h = settings.hooks;
356
- if (h === void 0) return {};
357
- if (!isObject(h)) throw new Error(`"hooks" in ${path} must be an object. Fix the file, then run the install again. Nothing was changed.`);
358
- return h;
359
- }
360
- function mcpObject(config, path) {
361
- const s = config.mcpServers;
362
- if (s === void 0) return {};
363
- if (!isObject(s)) throw new Error(`"mcpServers" in ${path} must be an object. Fix the file, then run the install again. Nothing was changed.`);
364
- return s;
365
- }
366
- async function detect$2(env) {
367
- const p = paths(env);
368
- const configPaths = [p.mcp, p.settings];
369
- try {
370
- const r = await env.exec("claude", ["--version"]);
371
- if (r.code !== 0) return {
372
- installed: false,
373
- configPaths
374
- };
375
- const version = parseCliVersion(r.stdout);
376
- return {
377
- installed: true,
378
- binary: "claude",
379
- ...version ? { version } : {},
380
- configPaths
381
- };
382
- } catch {
383
- return {
384
- installed: false,
385
- configPaths
386
- };
387
- }
388
- }
389
- /** `A`, `A and B`, `A, B and C`. */
390
- const listed = (words) => words.length < 2 ? words[0] ?? "" : `${words.slice(0, -1).join(", ")} and ${words.at(-1)}`;
391
- async function plan$1(env) {
392
- const p = paths(env);
393
- const changes = [];
394
- const mcpFile = await loadJson(p.mcp);
395
- const servers = mcpObject(mcpFile.value, p.mcp);
396
- const want = desiredServer(env);
397
- if (!sameJson(servers["conveno"], want)) {
398
- const after = editJson(mcpFile, [{
399
- path: ["mcpServers", SERVER_NAME$2],
400
- value: want
401
- }]);
402
- changes.push({
403
- component: "mcp",
404
- kind: servers["conveno"] === void 0 ? "add" : "update",
405
- path: p.mcp,
406
- before: mcpFile.raw,
407
- after,
408
- description: `Register the "${SERVER_NAME$2}" MCP server at user scope (conveno mcp --cli claude).`,
409
- viaCommand: [
410
- "claude",
411
- "mcp",
412
- "add",
413
- "--scope",
414
- "user",
415
- SERVER_NAME$2,
416
- "--",
417
- ...mcpArgs(env)
418
- ]
419
- });
420
- }
421
- const setFile = await loadJson(p.settings);
422
- const hooks = hooksObject(setFile.value, p.settings);
423
- const missing = (env.permissionRelay ? ALL_HOOK_EVENTS$1 : HOOK_EVENTS$1).filter((e) => !eventComplete(env, hooks, e));
424
- if (missing.length > 0) {
425
- const next = { ...hooks };
426
- for (const e of missing) next[e] = [...stripOurHooks(groupsOf(hooks, e)), ...HANDLERS[e].map((arg) => ({ hooks: [handlerFor(env, arg)] }))];
427
- const installed = ALL_HOOK_EVENTS$1.some((e) => groupsOf(hooks, e).some((g) => isObject(g) && Array.isArray(g.hooks) && g.hooks.some((h) => isObject(h) && isOurHookCommand(h.command))));
428
- changes.push({
429
- component: "hooks",
430
- kind: installed ? "update" : "add",
431
- path: p.settings,
432
- before: setFile.raw,
433
- after: editJson(setFile, missing.map((e) => ({
434
- path: ["hooks", e],
435
- value: next[e]
436
- }))),
437
- description: `Add Conveno's ${listed(missing)} hooks to Claude Code. They deliver messages at the next prompt and, in auto mode, at the end of a turn or by waking an idle session through a background listener.${missing.includes("PermissionRequest") ? " PermissionRequest is the experimental permission relay and does nothing until you turn it on for a session." : ""}`
438
- });
439
- }
440
- return changes;
441
- }
442
- async function uninstallPlan$1(env) {
443
- const p = paths(env);
444
- const changes = [];
445
- const mcpFile = await loadJson(p.mcp);
446
- if ("conveno" in mcpObject(mcpFile.value, p.mcp)) changes.push({
447
- component: "mcp",
448
- kind: "remove",
449
- path: p.mcp,
450
- before: mcpFile.raw,
451
- after: editJson(mcpFile, [{
452
- path: ["mcpServers", SERVER_NAME$2],
453
- value: void 0
454
- }]),
455
- description: `Remove the "${SERVER_NAME$2}" MCP server from user scope.`,
456
- viaCommand: [
457
- "claude",
458
- "mcp",
459
- "remove",
460
- "--scope",
461
- "user",
462
- SERVER_NAME$2
463
- ]
464
- });
465
- const setFile = await loadJson(p.settings);
466
- const hooks = hooksObject(setFile.value, p.settings);
467
- const next = { ...hooks };
468
- const edits = [];
469
- for (const e of ALL_HOOK_EVENTS$1) {
470
- const groups = groupsOf(hooks, e);
471
- const stripped = stripOurHooks(groups);
472
- if (sameJson(groups, stripped)) continue;
473
- if (stripped.length > 0) next[e] = stripped;
474
- else delete next[e];
475
- edits.push({
476
- path: ["hooks", e],
477
- value: stripped.length > 0 ? stripped : void 0
478
- });
479
- }
480
- if (edits.length > 0) {
481
- if (Object.keys(next).length === 0) edits.push({
482
- path: ["hooks"],
483
- value: void 0
484
- });
485
- changes.push({
486
- component: "hooks",
487
- kind: "remove",
488
- path: p.settings,
489
- before: setFile.raw,
490
- after: editJson(setFile, edits),
491
- description: "Remove the Conveno SessionStart, UserPromptSubmit, Stop and PermissionRequest hooks and the listener."
492
- });
493
- }
494
- return changes;
495
- }
496
- /** `stop_hook_active` from the Stop input: Claude Code is already continuing because of a Stop hook. */
497
- const stopHookActive = (input) => isObject(input) && input.stop_hook_active === true;
498
- /**
499
- * Never throws: any failure means "deliver nothing this time".
500
- *
501
- * - SessionStart: waiting messages as `additionalContext`.
502
- * - UserPromptSubmit: the turn starts (the session is busy), waiting messages as `additionalContext`.
503
- * - Stop: in auto mode with messages waiting, `decision: "block"` with the framed messages as
504
- * `reason`, so Claude continues with them. When `stop_hook_active` is set (Claude is already
505
- * continuing because of a Stop hook) it never blocks; it only records that the turn ended, and the
506
- * listener armed on this Stop wakes the session with what waits, as a new turn.
507
- * - Listen: the background listener (`asyncRewake`). Waits for work and exits 2 with the framed
508
- * messages on stderr, which wakes Claude even when the session is idle. Exit 0, silent, when it
509
- * stops for any other reason.
510
- */
511
- async function hook$2(event, input, ctx) {
512
- switch (event) {
513
- case "SessionStart":
514
- case "UserPromptSubmit": {
515
- const [additionalContext] = await Promise.all([event === "SessionStart" ? pendingHookContext(ctx) : startTurnContext(ctx), recordCliInfo(ctx, input)]);
516
- if (additionalContext === null) return EMPTY$4;
517
- return {
518
- stdout: JSON.stringify({ hookSpecificOutput: {
519
- hookEventName: event,
520
- additionalContext
521
- } }),
522
- exitCode: 0
523
- };
524
- }
525
- case "Stop": {
526
- const reason = await endTurnContinuation(ctx, { allowContinue: !stopHookActive(input) });
527
- if (reason === null) return EMPTY$4;
528
- return {
529
- stdout: JSON.stringify({
530
- decision: "block",
531
- reason
532
- }),
533
- exitCode: 0
534
- };
535
- }
536
- case PERMISSION_EVENT$1: return permissionHook$1(input, ctx);
537
- case LISTEN_EVENT: {
538
- const text = await waitForWork(ctx, { maxMs: LISTEN_MAX_MS });
539
- return text === null ? EMPTY$4 : {
540
- stdout: "",
541
- stderr: text,
542
- exitCode: 2
543
- };
544
- }
545
- default: return EMPTY$4;
546
- }
547
- }
548
- /** Is our PermissionRequest hook in settings.json. */
549
- async function permissionHookInstalled$1(env) {
550
- const file = await loadJson(paths(env).settings);
551
- return groupsOf(isObject(file.value.hooks) ? file.value.hooks : {}, PERMISSION_EVENT$1).some((g) => isObject(g) && Array.isArray(g.hooks) && g.hooks.some((h) => isObject(h) && isOurHookCommand(h.command)));
552
- }
553
- const delivery$2 = () => ({
554
- nextTurn: true,
555
- endOfTurn: true,
556
- idleWake: true
557
- });
558
- const claudeAdapter = {
559
- cli: "claude",
560
- displayName: "Claude Code",
561
- deliveryTier: "next_turn",
562
- detect: detect$2,
563
- plan: plan$1,
564
- uninstallPlan: uninstallPlan$1,
565
- hook: hook$2,
566
- permissionHookInstalled: permissionHookInstalled$1,
567
- listenEvents: [LISTEN_EVENT],
568
- delivery: delivery$2,
569
- transcript: claudeTranscript
570
- };
571
1
  // ../../node_modules/.pnpm/@decimalturn+toml-patch@3.3.3/node_modules/@decimalturn/toml-patch/dist/toml-patch.js
572
2
  //! @decimalturn/toml-patch v3.3.3 - https://github.com/DecimalTurn/toml-patch - @license: MIT
573
3
  function e(e) {
@@ -3663,7 +3093,7 @@ function wi(e, t) {
3663
3093
  };
3664
3094
  n(e);
3665
3095
  }
3666
- function q$1(e, t = R.default(), n = 0, r = !1) {
3096
+ function q(e, t = R.default(), n = 0, r = !1) {
3667
3097
  e = Ai(e);
3668
3098
  let i = Nr();
3669
3099
  $n(i), Zn(i, t.indentWidth);
@@ -5340,7 +4770,7 @@ function eo(e) {
5340
4770
  }
5341
4771
  function to(e, t, n, r) {
5342
4772
  if (!F(t)) return t;
5343
- let i = Vi(q$1(e, L({
4773
+ let i = Vi(q(e, L({
5344
4774
  ...n,
5345
4775
  inlineTableStart: 0
5346
4776
  }, n)).items, ``, { temporal: r });
@@ -5396,7 +4826,7 @@ function ro(e, t, n, r = !1, i = !0, a = !1) {
5396
4826
  let f = n.inlineTableStart != null && n.inlineTableStart > 1 ? 1 : n.inlineTableStart, p = L({
5397
4827
  ...n,
5398
4828
  inlineTableStart: f
5399
- }, n), m = q$1(t, p), h = Vi(m.items, ``, { temporal: s }), g = n.updateOrder ? to(t, h, p, s) : h;
4829
+ }, n), m = q(t, p), h = Vi(m.items, ``, { temporal: s }), g = n.updateOrder ? to(t, h, p, s) : h;
5400
4830
  if (!n.updateOrder && io(u, g)) return {
5401
4831
  tomlString: Mi(o, n),
5402
4832
  document: d
@@ -5870,7 +5300,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
5870
5300
  trailingComma: y ? c.trailingComma : h,
5871
5301
  bracketSpacing: b ?? c.bracketSpacing,
5872
5302
  indentWidth: l
5873
- }, c), w = q$1({ tmp: i }, C, o + 1, s).items[0];
5303
+ }, c), w = q({ tmp: i }, C, o + 1, s).items[0];
5874
5304
  if (!w || !a(w)) return r;
5875
5305
  let T = w.value;
5876
5306
  if (x && (u(T) || f(T))) {
@@ -5897,7 +5327,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
5897
5327
  inlineTableStart: 0,
5898
5328
  [C]: !0,
5899
5329
  trailingComma: y ? c.trailingComma : !1
5900
- }, c), T = q$1({ tmp: o }, w, l + 1, p).items[0];
5330
+ }, c), T = q({ tmp: o }, w, l + 1, p).items[0];
5901
5331
  if (!T || !a(T)) return t;
5902
5332
  let E = T.value;
5903
5333
  if (u(E) || f(E)) {
@@ -5987,7 +5417,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
5987
5417
  let r = L({
5988
5418
  ...c,
5989
5419
  inlineTableStart: 0
5990
- }, c), i = e === void 0 ? void 0 : q$1({ tmp: e }, r), l = i == null ? void 0 : i.items[0];
5420
+ }, c), i = e === void 0 ? void 0 : q({ tmp: e }, r), l = i == null ? void 0 : i.items[0];
5991
5421
  if (l && a(l) && (o = K(l.value), _ = !1, d(o) && f(o.item) && o.item.items.length > 0)) {
5992
5422
  let e = o.item;
5993
5423
  if (!(e.items[0].loc.start.column - e.loc.start.column > 1)) {
@@ -6010,7 +5440,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
6010
5440
  let e = Ir(x, c.escapeSequenceUpperCase), n = O ? L({
6011
5441
  ...c,
6012
5442
  inlineTableStart: 0
6013
- }, c) : c, i = q$1(T, n);
5443
+ }, c) : c, i = q(T, n);
6014
5444
  for (let t of i.items) H(e, e, t, void 0);
6015
5445
  if (w && S) {
6016
5446
  let n = (i, o) => {
@@ -6109,7 +5539,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
6109
5539
  ...c,
6110
5540
  inlineTableStart: 0,
6111
5541
  trailingComma: e
6112
- }, c), i = t === void 0 ? void 0 : q$1({ tmp: t }, r).items[0];
5542
+ }, c), i = t === void 0 ? void 0 : q({ tmp: t }, r).items[0];
6113
5543
  if (i && a(i)) {
6114
5544
  let e = K(i.value);
6115
5545
  e.comma = n.comma, o = e;
@@ -6205,7 +5635,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
6205
5635
  let t = L({
6206
5636
  ...c,
6207
5637
  inlineTableStart: 0
6208
- }, c), n = q$1({ tmp: e }, t), r = n == null ? void 0 : n.items[0];
5638
+ }, c), n = q({ tmp: e }, t), r = n == null ? void 0 : n.items[0];
6209
5639
  r && a(r) && (h = K(r.value));
6210
5640
  }
6211
5641
  }
@@ -6346,7 +5776,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
6346
5776
  let e = (f ? $(n, o, f) : Z(n, o)).filter((e) => e !== p && (t(e) || r(e)));
6347
5777
  for (let t of e) X(n, d, t);
6348
5778
  }
6349
- let h = q$1({ [l[0]]: i }, c), _ = h.items[0];
5779
+ let h = q({ [l[0]]: i }, c), _ = h.items[0];
6350
5780
  if (a(_) && f && Q(u, f.key.item.value)) {
6351
5781
  let e = I(u, f.key.item.value) ? f : $(n, u, f).find((e) => t(e) && I(e.key.item.value, u));
6352
5782
  if (e) {
@@ -6387,7 +5817,7 @@ function So(n, i, s, c, l = !1, g = /* @__PURE__ */ new WeakSet(), _ = void 0, v
6387
5817
  let i = C, o = p.key.item.value, l = i, u = typeof s.path[s.path.length - 1] == `number` ? s.path.slice(0, -1) : s.path;
6388
5818
  for (let e of u) l = l == null ? void 0 : l[e];
6389
5819
  if (l !== void 0) {
6390
- let i = o.slice(-1), d = o.slice(0, -1), f = te(n, p) ?? la(n, s.path), m = Vo(n, u), h = q$1({ [i[0]]: l }, c).items[0];
5820
+ let i = o.slice(-1), d = o.slice(0, -1), f = te(n, p) ?? la(n, s.path), m = Vo(n, u), h = q({ [i[0]]: l }, c).items[0];
6391
5821
  if (Array.isArray(l) && !l.every((e) => F(e))) {
6392
5822
  let e = (m ? $(n, o, m) : Z(n, o)).filter((e) => e !== p && (t(e) || r(e)));
6393
5823
  for (let t of e) X(n, n, t);
@@ -6938,7 +6368,7 @@ function Oo(e, n, i, o, s, c, l) {
6938
6368
  _ = u;
6939
6369
  for (let e = i.path.length - 1; e > n; e--) _ = { [i.path[e]]: _ };
6940
6370
  }
6941
- let v = Mi(q$1(_, o).items, o), y = Array.from(N(v)), b = h >= 0 ? h : qo(e, l, Bo(e, l)), x = (t) => {
6371
+ let v = Mi(q(_, o).items, o), y = Array.from(N(v)), b = h >= 0 ? h : qo(e, l, Bo(e, l)), x = (t) => {
6942
6372
  let n = l.items.find((e) => a(e) && I(e.key.value, t.key.value));
6943
6373
  n ? V(e, l, n, t) : H(e, l, t, void 0);
6944
6374
  };
@@ -6969,7 +6399,7 @@ function Oo(e, n, i, o, s, c, l) {
6969
6399
  for (let e = i.path.length - 1; e >= 0; e--) p = { [i.path[e]]: p };
6970
6400
  let m = Z(e, i.path);
6971
6401
  for (let t of m) U(e, e, t);
6972
- let h = Mi(q$1(p, o).items, o), g = Array.from(N(h)), _ = To(e);
6402
+ let h = Mi(q(p, o).items, o), g = Array.from(N(h)), _ = To(e);
6973
6403
  _ !== void 0 && W(e);
6974
6404
  let v;
6975
6405
  for (let n = 0; n < g.length; n++) {
@@ -7110,7 +6540,7 @@ function Po(e, n, i) {
7110
6540
  if (o && r(o)) {
7111
6541
  let t = a[a.length - 1];
7112
6542
  if (typeof t != `string`) continue;
7113
- let n = q$1({ [t]: [] }, i), r = Rr([t], n.items[0].value);
6543
+ let n = q({ [t]: [] }, i), r = Rr([t], n.items[0].value);
7114
6544
  W(e), H(e, o, r);
7115
6545
  continue;
7116
6546
  }
@@ -7123,12 +6553,12 @@ function Po(e, n, i) {
7123
6553
  }
7124
6554
  }
7125
6555
  if (s) {
7126
- let t = a.filter((e) => typeof e == `string`).slice(s.key.item.value.length), n = Rr(t, q$1({ [t[t.length - 1]]: [] }, i).items[0].value);
6556
+ let t = a.filter((e) => typeof e == `string`).slice(s.key.item.value.length), n = Rr(t, q({ [t[t.length - 1]]: [] }, i).items[0].value);
7127
6557
  W(e), H(e, s, n);
7128
6558
  continue;
7129
6559
  }
7130
6560
  }
7131
- let n = a.filter((e) => typeof e == `string`), o = Rr(n, q$1({ [n[n.length - 1]]: [] }, i).items[0].value);
6561
+ let n = a.filter((e) => typeof e == `string`), o = Rr(n, q({ [n[n.length - 1]]: [] }, i).items[0].value);
7132
6562
  W(e), H(e, e, o, To(e));
7133
6563
  }
7134
6564
  W(e);
@@ -7161,7 +6591,7 @@ function Lo(e, n) {
7161
6591
  let r = L({
7162
6592
  ...n,
7163
6593
  inlineTableStart: 0
7164
- }, n), i = Mi(q$1({ __tmp__: e }, r).items, r), o = Array.from(N(i))[0];
6594
+ }, n), i = Mi(q({ __tmp__: e }, r).items, r), o = Array.from(N(i))[0];
7165
6595
  if (a(o)) return o.value;
7166
6596
  if (t(o) && o.items.length > 0 && a(o.items[0])) return o.items[0].value;
7167
6597
  }
@@ -7232,7 +6662,7 @@ function Wo(e, t, n) {
7232
6662
  let r = L({
7233
6663
  ...n,
7234
6664
  inlineTableStart: 0
7235
- }, n), i = q$1({ [e[e.length - 1]]: t }, r), o = Array.from(N(Mi(i.items, n)));
6665
+ }, n), i = q({ [e[e.length - 1]]: t }, r), o = Array.from(N(Mi(i.items, n)));
7236
6666
  if (o.length !== 1 || !a(o[0])) return;
7237
6667
  let s = o[0];
7238
6668
  return e.length > 1 && Go(s, e, n), s;
@@ -7270,7 +6700,7 @@ function Yo(e, n, i, o, s, c, l) {
7270
6700
  if (Ho(o)) {
7271
6701
  let d = n.items.filter((e) => a(e) && e.key.value[0] === u[0]);
7272
6702
  if (d.some((e) => !Q(e.key.value, u))) return !1;
7273
- let p = q$1({ [i[i.length - 1]]: o }, s), m = Array.from(N(Mi(p.items, s)));
6703
+ let p = q({ [i[i.length - 1]]: o }, s), m = Array.from(N(Mi(p.items, s)));
7274
6704
  if (!m.every((e) => t(e) || r(e))) return !1;
7275
6705
  let h = $(e, i, l), g = h.length > 0 ? e.items.indexOf(h[0]) : -1;
7276
6706
  for (let t of h) X(e, e, t);
@@ -7323,1303 +6753,4 @@ function cs(e, t) {
7323
6753
  temporal: (t == null ? void 0 : t.temporal) ?? !1
7324
6754
  });
7325
6755
  }
7326
- // ../adapters/codex/dist/index.js
7327
- /**
7328
- * EXPERIMENTAL permission relay for Codex. The `PermissionRequest` hook runs when Codex is about
7329
- * to ask for approval; printing no decision lets the normal approval prompt continue, and
7330
- * `behavior: allow` or `deny` decides it. Codex also reads `updatedInput`, `updatedPermissions`
7331
- * and `interrupt` as errors for this event, so the relay never prints them. See
7332
- * https://developers.openai.com/codex/hooks (PermissionRequest).
7333
- */
7334
- const PERMISSION_EVENT = "PermissionRequest";
7335
- /** Seconds, in the hook config: longer than the relay's own wait, so Codex never cuts it first. */
7336
- const PERMISSION_TIMEOUT_SECONDS = 100;
7337
- const EMPTY$1 = {
7338
- stdout: "",
7339
- exitCode: 0
7340
- };
7341
- const asObject$1 = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
7342
- const text = (v) => typeof v === "string" && v ? v : void 0;
7343
- /** Files an `apply_patch` envelope adds, updates, deletes or moves to. */
7344
- function patchPaths(patch) {
7345
- const paths = [];
7346
- for (const m of patch.matchAll(/^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+?)\s*$/gm)) if (m[1]) paths.push(m[1]);
7347
- return paths;
7348
- }
7349
- /** The request in the shape the relay takes, or null when the hook input is not one. */
7350
- function callFromInput(input) {
7351
- const body = asObject$1(input);
7352
- const tool = text(body.tool_name);
7353
- if (!tool) return null;
7354
- const toolInput = asObject$1(body.tool_input);
7355
- const call = { tool };
7356
- const command = text(toolInput.command);
7357
- if (tool === "apply_patch") call.paths = command ? patchPaths(command) : [];
7358
- else if (command) call.command = command;
7359
- const description = text(toolInput.description);
7360
- if (description) call.description = description;
7361
- const cwd = text(body.cwd);
7362
- if (cwd) call.cwd = cwd;
7363
- return call;
7364
- }
7365
- /** Never throws. No output means Codex shows its own approval prompt. */
7366
- async function permissionHook(input, ctx) {
7367
- const call = callFromInput(input);
7368
- if (!call) return EMPTY$1;
7369
- const decision = await relayPermission(ctx, call);
7370
- if (!decision) return EMPTY$1;
7371
- return {
7372
- stdout: `${formatPermissionDecision(decision, PERMISSION_EVENT)}\n`,
7373
- exitCode: 0
7374
- };
7375
- }
7376
- const SERVER_NAME$1 = "conveno";
7377
- var ConfigParseError = class extends Error {};
7378
- function parseToml(path, text) {
7379
- try {
7380
- return cs(text);
7381
- } catch (err) {
7382
- throw new ConfigParseError(`Cannot parse ${path} as TOML (${err instanceof Error ? err.message : String(err)}). Fix or move the file, then run conveno again. Conveno did not change it.`);
7383
- }
7384
- }
7385
- /** The approval mode Conveno asks for. A mode the user already set on the server is kept instead. */
7386
- const APPROVAL_MODE = "approve";
7387
- function serverOf(doc) {
7388
- const servers = doc.mcp_servers;
7389
- if (servers && typeof servers === "object") {
7390
- const ours = servers[SERVER_NAME$1];
7391
- if (ours && typeof ours === "object") return ours;
7392
- }
7393
- }
7394
- function matchesSpec(server, spec) {
7395
- return server !== void 0 && server.command === spec.command && JSON.stringify(server.args) === JSON.stringify(spec.args) && server.default_tools_approval_mode === spec.approval;
7396
- }
7397
- const eolOf = (text) => text.includes("\r\n") ? "\r\n" : "\n";
7398
- /** TOML basic strings use the same escapes as JSON for everything we write. */
7399
- const q = (s) => JSON.stringify(s);
7400
- function tableText(spec, eol) {
7401
- return [
7402
- `[mcp_servers.${SERVER_NAME$1}]`,
7403
- `command = ${q(spec.command)}`,
7404
- `args = [${spec.args.map(q).join(", ")}]`,
7405
- `default_tools_approval_mode = ${q(spec.approval)}`,
7406
- ""
7407
- ].join(eol);
7408
- }
7409
- /** Compare parsed data, treating a missing `mcp_servers` and an empty one as equal. */
7410
- const sameData = (a, b) => {
7411
- const norm = (t) => JSON.stringify(t, (k, v) => k === "mcp_servers" && v && Object.keys(v).length === 0 ? void 0 : v);
7412
- return norm(a) === norm(b);
7413
- };
7414
- /**
7415
- * Add our `[mcp_servers.conveno]` table. The file is left byte-for-byte intact: the table is
7416
- * appended as text. If the result does not parse to the expected data (for example the user
7417
- * already defines `mcp_servers.conveno` inline), fall back to a comment-preserving patch.
7418
- */
7419
- function addServer(path, before, spec) {
7420
- const doc = parseToml(path, before);
7421
- const expected = structuredClone(doc);
7422
- const servers = expected.mcp_servers ?? {};
7423
- servers[SERVER_NAME$1] = {
7424
- command: spec.command,
7425
- args: spec.args,
7426
- default_tools_approval_mode: spec.approval
7427
- };
7428
- expected.mcp_servers = servers;
7429
- const eol = eolOf(before);
7430
- const appended = before + (before === "" ? "" : before.endsWith("\n") ? eol : eol + eol) + tableText(spec, eol);
7431
- try {
7432
- if (sameData(cs(appended), expected)) return appended;
7433
- } catch {}
7434
- return Za(before, expected);
7435
- }
7436
- /** Remove our table and any `[mcp_servers.conveno.*]` subtables. */
7437
- function removeServer(path, before) {
7438
- const doc = parseToml(path, before);
7439
- const expected = structuredClone(doc);
7440
- const servers = expected.mcp_servers;
7441
- if (servers) delete servers[SERVER_NAME$1];
7442
- const eol = eolOf(before);
7443
- const lines = before.split(/\r?\n/);
7444
- const out = [];
7445
- let skipping = false;
7446
- for (const line of lines) {
7447
- const header = /^\s*\[\[?\s*([^\]]+?)\s*\]\]?\s*(?:#.*)?$/.exec(line);
7448
- if (header) {
7449
- const key = header[1].replace(/["'\s]/g, "");
7450
- const key0 = `mcp_servers.${SERVER_NAME$1}`;
7451
- skipping = key === key0 || key.startsWith(`${key0}.`);
7452
- }
7453
- if (!skipping) out.push(line);
7454
- }
7455
- let text = out.join(eol);
7456
- if (skipping) text = text.replace(/(\r?\n)+$/, "") + (text.trim() === "" ? "" : eol);
7457
- try {
7458
- if (sameData(cs(text), expected)) return text;
7459
- } catch {}
7460
- return Za(before, expected);
7461
- }
7462
- /**
7463
- * Codex writes one rollout file per session at
7464
- * `$CODEX_HOME/sessions/YYYY/MM/DD/rollout-<timestamp>-<thread id>.jsonl` (default `~/.codex`).
7465
- * reference/src/codex: codex-rs/rollout/src/recorder.rs (directory layout),
7466
- * codex-rs/rollout/src/rollout_file_name.rs (file name).
7467
- *
7468
- * Each line is `{ timestamp, type, payload }` (codex-rs/history/src/rollout_payload.rs). The first
7469
- * line is `session_meta` with the thread `id` and the `cwd`. Messages, tool calls and tool outputs
7470
- * are `response_item` lines (codex-rs/protocol/src/models.rs, `ResponseItem`). Hooks receive
7471
- * `session_id` and `transcript_path` (codex-rs/hooks/src/schema.rs). Old rollouts can be compressed
7472
- * to `.jsonl.zst`; those are not read (a running session's file is plain).
7473
- */
7474
- const codexHome = (env) => env.env.CODEX_HOME?.trim() || join(env.home, ".codex");
7475
- const fileExists = (p) => stat(p).then((s) => s.isFile(), () => false);
7476
- /** Text parts the CLI injects ahead of the user's own words (environment, instructions, reminders). */
7477
- const INJECTED = /^\s*(?:<environment_context>|<user_instructions>|<permissions|<turn_aborted>|<user_action>|# AGENTS\.md instructions|<INSTRUCTIONS>)/;
7478
- function contentText(content) {
7479
- if (typeof content === "string") return content;
7480
- if (!Array.isArray(content)) return "";
7481
- const parts = [];
7482
- for (const c of content) {
7483
- if (!isRecord(c)) continue;
7484
- const t = c.type;
7485
- if ((t === "input_text" || t === "output_text" || t === "text") && typeof c.text === "string") parts.push(c.text);
7486
- }
7487
- return parts.join("\n");
7488
- }
7489
- /** Output of a tool call: a string, or an object holding the text. */
7490
- function outputText(output) {
7491
- if (typeof output === "string") return output;
7492
- if (Array.isArray(output)) return contentText(output);
7493
- if (isRecord(output)) return asString(output.content) ?? asString(output.text) ?? contentText(output.content_items);
7494
- return "";
7495
- }
7496
- /** Normalize one rollout line. Exported for tests. */
7497
- function parseCodexLine(obj) {
7498
- if (obj.type !== "response_item") return [];
7499
- const p = obj.payload;
7500
- if (!isRecord(p)) return [];
7501
- const at = toIso(obj.timestamp);
7502
- const stamp = at ? { at } : {};
7503
- switch (p.type) {
7504
- case "message": {
7505
- if (p.role !== "user" && p.role !== "assistant") return [];
7506
- const text = contentText(p.content);
7507
- if (text === "" || p.role === "user" && INJECTED.test(text)) return [];
7508
- return [{
7509
- role: p.role,
7510
- text,
7511
- ...stamp
7512
- }];
7513
- }
7514
- case "function_call":
7515
- case "custom_tool_call": {
7516
- const name = asString(p.name) ?? "tool";
7517
- return [{
7518
- role: "tool",
7519
- text: describeToolCall(name, p.arguments ?? p.input),
7520
- ...stamp
7521
- }];
7522
- }
7523
- case "local_shell_call": {
7524
- const action = isRecord(p.action) ? p.action : {};
7525
- const command = Array.isArray(action.command) ? action.command.join(" ") : action.command;
7526
- return [{
7527
- role: "tool",
7528
- text: describeToolCall("shell", command),
7529
- ...stamp
7530
- }];
7531
- }
7532
- case "function_call_output":
7533
- case "custom_tool_call_output": {
7534
- const text = outputText(p.output);
7535
- return [{
7536
- role: "tool",
7537
- text: text === "" ? "(no output)" : text,
7538
- ...stamp
7539
- }];
7540
- }
7541
- default: return [];
7542
- }
7543
- }
7544
- const ROLLOUT = /^rollout-.*\.jsonl$/;
7545
- /** Day directories under `sessions/`, newest first, for the days from `startedAt` on. */
7546
- async function dayDirs(root, startedAt) {
7547
- const since = Date.parse(startedAt);
7548
- const floor = Number.isFinite(since) ? /* @__PURE__ */ new Date(since - 1296e5) : /* @__PURE__ */ new Date(0);
7549
- const out = [];
7550
- const years = (await subdirsNewestFirst(root)).sort().reverse();
7551
- for (const y of years) for (const m of (await subdirsNewestFirst(y)).sort().reverse()) for (const d of (await subdirsNewestFirst(m)).sort().reverse()) {
7552
- const key = `${y.split(/[\\/]/).pop()}-${m.split(/[\\/]/).pop()}-${d.split(/[\\/]/).pop()}`;
7553
- const day = Date.parse(`${key}T23:59:59Z`);
7554
- if (Number.isFinite(day) && day < floor.getTime()) return out;
7555
- out.push(d);
7556
- }
7557
- return out;
7558
- }
7559
- /** Find the rollout file for a session, or the reason there is none. */
7560
- async function locateCodexRollout(q, env) {
7561
- if (q.transcriptPath && isTranscriptPath(q.transcriptPath, ".jsonl")) {
7562
- if (await fileExists(q.transcriptPath)) return { path: q.transcriptPath };
7563
- }
7564
- const root = join(codexHome(env), "sessions");
7565
- const since = Date.parse(q.startedAt);
7566
- const floor = Number.isFinite(since) ? since - 5e3 : 0;
7567
- let best;
7568
- for (const dir of await dayDirs(root, q.cliSessionId ? "" : q.startedAt)) for (const f of await entriesNewestFirst(dir)) {
7569
- if (f.dir || !ROLLOUT.test(f.name)) continue;
7570
- if (q.cliSessionId) {
7571
- if (f.name.includes(q.cliSessionId)) return { path: f.path };
7572
- continue;
7573
- }
7574
- if (f.mtimeMs < floor) continue;
7575
- if (best && best.mtimeMs >= f.mtimeMs) continue;
7576
- let cwd;
7577
- try {
7578
- const head = await readHeadLine(f.path);
7579
- const meta = head ? JSON.parse(head) : null;
7580
- const payload = isRecord(meta) && meta.type === "session_meta" ? meta.payload : void 0;
7581
- cwd = isRecord(payload) ? asString(payload.cwd) : void 0;
7582
- } catch {
7583
- continue;
7584
- }
7585
- if (cwd !== void 0 && samePath(cwd, q.cwd, env.platform)) best = {
7586
- path: f.path,
7587
- mtimeMs: f.mtimeMs
7588
- };
7589
- }
7590
- if (best) return { path: best.path };
7591
- return { error: q.cliSessionId ? "no rollout file has that session id" : "no rollout for this working directory since the session started" };
7592
- }
7593
- const codexTranscript = { async read(q, env) {
7594
- try {
7595
- const found = await locateCodexRollout(q, env);
7596
- if ("error" in found) return notFound("Codex", found.error);
7597
- const { entries, more } = await tailJsonl(found.path, q.lastTurns, parseCodexLine);
7598
- return {
7599
- ok: true,
7600
- entries,
7601
- more
7602
- };
7603
- } catch (e) {
7604
- return notFound("Codex", e instanceof Error ? e.message : "read failed");
7605
- }
7606
- } };
7607
- const HOOK_EVENTS = [
7608
- "SessionStart",
7609
- "UserPromptSubmit",
7610
- "Stop"
7611
- ];
7612
- /**
7613
- * PermissionRequest is the experimental permission relay. It is planned only when asked for
7614
- * (`conveno init --with-permission-relay`, or the first `conveno permissions relay on`), and does
7615
- * nothing until a session turns the relay on. Uninstall always knows it.
7616
- */
7617
- const ALL_HOOK_EVENTS = [...HOOK_EVENTS, PERMISSION_EVENT];
7618
- /** Seconds. The hook gives up after 2 s on its own; this leaves room for Node startup. Same as Claude. */
7619
- const HOOK_TIMEOUT_SECONDS = 5;
7620
- const codexDir = (env) => env.env.CODEX_HOME || join(env.home, ".codex");
7621
- const configPath = (env) => join(codexDir(env), "config.toml");
7622
- const hooksPath = (env) => join(codexDir(env), "hooks.json");
7623
- async function readIfExists(path) {
7624
- try {
7625
- return await readFile(path, "utf8");
7626
- } catch (err) {
7627
- if (err.code === "ENOENT") return null;
7628
- throw err;
7629
- }
7630
- }
7631
- /**
7632
- * Quote one word of a hook command. Codex runs the command line with `$SHELL -lc` on Unix and with
7633
- * `%COMSPEC% /C "<line>"` (cmd.exe) on Windows, so Windows words are written for cmd.exe: double
7634
- * quotes, and forward slashes in paths. cmd.exe and every Windows API accept `/`, and it avoids
7635
- * any question of how `\` meets a quote.
7636
- */
7637
- function quoteArg(arg, platform) {
7638
- if (platform === "win32") {
7639
- const word = arg.replace(/\\/g, "/");
7640
- return /^[A-Za-z0-9_./:=@+,-]+$/.test(word) ? word : `"${word.replace(/"/g, "\"\"")}"`;
7641
- }
7642
- if (/^[A-Za-z0-9_./:=@%+,-]+$/.test(arg)) return arg;
7643
- return `'${arg.replace(/'/g, `'\\''`)}'`;
7644
- }
7645
- function hookCommand(env, event) {
7646
- return [
7647
- ...env.conveno.command,
7648
- "hook",
7649
- "codex",
7650
- event
7651
- ].map((a) => quoteArg(a, env.platform)).join(" ");
7652
- }
7653
- /** A handler is ours when it runs `... hook codex <event>`; this lets us find it after the command path changes. */
7654
- const isOurs = (command, event) => typeof command === "string" && new RegExp(`\\bhook codex ${event}\\s*$`).test(command);
7655
- function parseHooksJson(path, text) {
7656
- if (text === null || text.trim() === "") return {};
7657
- try {
7658
- const value = JSON.parse(text);
7659
- if (value && typeof value === "object" && !Array.isArray(value)) return value;
7660
- } catch {}
7661
- throw new ConfigParseError(`Cannot parse ${path} as a JSON object. Fix or move the file, then run conveno again. Conveno did not change it.`);
7662
- }
7663
- const asArray = (v) => Array.isArray(v) ? v : [];
7664
- const asObject = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
7665
- function handlersOf(group) {
7666
- return asArray(asObject(group).hooks);
7667
- }
7668
- /** Hook entries for one event with our handlers removed; empty groups are dropped. */
7669
- function withoutOurs(groups, event) {
7670
- const out = [];
7671
- for (const group of groups) {
7672
- const handlers = handlersOf(group);
7673
- const kept = handlers.filter((h) => !isOurs(asObject(h).command, event));
7674
- if (kept.length === handlers.length) out.push(group);
7675
- else if (kept.length > 0) out.push({
7676
- ...asObject(group),
7677
- hooks: kept
7678
- });
7679
- }
7680
- return out;
7681
- }
7682
- function hasOurs(groups, command) {
7683
- return groups.some((g) => handlersOf(g).some((h) => asObject(h).command === command));
7684
- }
7685
- const json$1 = (value) => `${JSON.stringify(value, null, 2)}\n`;
7686
- async function planHooks(env) {
7687
- const path = hooksPath(env);
7688
- const before = await readIfExists(path);
7689
- const doc = parseHooksJson(path, before);
7690
- const hooks = asObject(doc.hooks);
7691
- let changed = false;
7692
- const next = { ...hooks };
7693
- for (const event of env.permissionRelay ? ALL_HOOK_EVENTS : HOOK_EVENTS) {
7694
- const groups = asArray(hooks[event]);
7695
- const command = hookCommand(env, event);
7696
- if (hasOurs(groups, command)) continue;
7697
- changed = true;
7698
- next[event] = [...withoutOurs(groups, event), { hooks: [{
7699
- type: "command",
7700
- command,
7701
- timeout: event === "PermissionRequest" ? PERMISSION_TIMEOUT_SECONDS : HOOK_TIMEOUT_SECONDS
7702
- }] }];
7703
- }
7704
- if (!changed) return [];
7705
- return [{
7706
- component: "hooks",
7707
- kind: ALL_HOOK_EVENTS.some((event) => asArray(hooks[event]).some((g) => handlersOf(g).some((h) => isOurs(asObject(h).command, event)))) ? "update" : "add",
7708
- path,
7709
- before,
7710
- after: json$1({
7711
- ...doc,
7712
- hooks: next
7713
- }),
7714
- description: `Add ${env.permissionRelay ? "a PermissionRequest hook for the experimental permission relay (it does nothing until you turn the relay on for a session) and, if missing, " : ""}SessionStart, UserPromptSubmit and Stop hooks that deliver Conveno messages on the next turn and, in auto mode, at the end of a turn. Codex asks you to trust new hooks: review them with /hooks.`
7715
- }];
7716
- }
7717
- async function uninstallHooks(env) {
7718
- const path = hooksPath(env);
7719
- const before = await readIfExists(path);
7720
- if (before === null) return [];
7721
- const doc = parseHooksJson(path, before);
7722
- const hooks = asObject(doc.hooks);
7723
- const next = { ...hooks };
7724
- let changed = false;
7725
- for (const event of ALL_HOOK_EVENTS) {
7726
- const groups = asArray(hooks[event]);
7727
- const kept = withoutOurs(groups, event);
7728
- if (JSON.stringify(kept) === JSON.stringify(groups)) continue;
7729
- changed = true;
7730
- if (kept.length > 0) next[event] = kept;
7731
- else delete next[event];
7732
- }
7733
- if (!changed) return [];
7734
- const { hooks: _drop, ...rest } = doc;
7735
- const after = Object.keys(next).length > 0 ? {
7736
- ...rest,
7737
- hooks: next
7738
- } : rest;
7739
- return [{
7740
- component: "hooks",
7741
- kind: "remove",
7742
- path,
7743
- before,
7744
- after: json$1(after),
7745
- description: "Remove the Conveno SessionStart, UserPromptSubmit, Stop and PermissionRequest hooks."
7746
- }];
7747
- }
7748
- function serverSpec(env, existing) {
7749
- const [command, ...rest] = env.conveno.command;
7750
- if (!command) throw new Error("conveno command is empty; cannot build the Codex MCP entry.");
7751
- const chosen = existing?.default_tools_approval_mode;
7752
- return {
7753
- command,
7754
- args: [
7755
- ...rest,
7756
- "mcp",
7757
- "--cli",
7758
- "codex"
7759
- ],
7760
- approval: typeof chosen === "string" ? chosen : APPROVAL_MODE
7761
- };
7762
- }
7763
- async function planMcp$1(env) {
7764
- const path = configPath(env);
7765
- const before = await readIfExists(path);
7766
- const existing = serverOf(parseToml(path, before ?? ""));
7767
- const spec = serverSpec(env, existing);
7768
- if (matchesSpec(existing, spec)) return [];
7769
- return [{
7770
- component: "mcp",
7771
- kind: existing ? "update" : "add",
7772
- path,
7773
- before,
7774
- after: addServer(path, before ?? "", spec),
7775
- description: `${existing ? "Update" : "Add"} the "${SERVER_NAME$1}" MCP server in Codex config (mcp_servers.${SERVER_NAME$1}). It lets Codex call Conveno's own tools without asking each time (default_tools_approval_mode = "${spec.approval}", this server only).`
7776
- }];
7777
- }
7778
- async function uninstallMcp$1(env) {
7779
- const path = configPath(env);
7780
- const before = await readIfExists(path);
7781
- if (before === null || !serverOf(parseToml(path, before))) return [];
7782
- return [{
7783
- component: "mcp",
7784
- kind: "remove",
7785
- path,
7786
- before,
7787
- after: removeServer(path, before),
7788
- description: `Remove the "${SERVER_NAME$1}" MCP server from Codex config.`
7789
- }];
7790
- }
7791
- async function detect$1(env) {
7792
- const configPaths = [configPath(env), hooksPath(env)];
7793
- try {
7794
- const { code, stdout } = await env.exec("codex", ["--version"]);
7795
- if (code !== 0) return {
7796
- installed: false,
7797
- configPaths
7798
- };
7799
- const version = parseCliVersion(stdout);
7800
- return {
7801
- installed: true,
7802
- binary: "codex",
7803
- ...version ? { version } : {},
7804
- configPaths
7805
- };
7806
- } catch {
7807
- return {
7808
- installed: false,
7809
- configPaths
7810
- };
7811
- }
7812
- }
7813
- const EMPTY$2 = {
7814
- stdout: "",
7815
- exitCode: 0
7816
- };
7817
- /**
7818
- * - SessionStart, UserPromptSubmit: waiting messages as `additionalContext` (UserPromptSubmit also
7819
- * marks the turn started).
7820
- * - Stop: in auto mode with messages waiting, `decision: "block"` with the framed messages as
7821
- * `reason`, which Codex turns into a continuation prompt in the same turn. This also happens when
7822
- * `stop_hook_active` is set: Codex has no idle wake, so a message that arrives during a
7823
- * continuation would otherwise wait for the user. Conveno's auto-mode limit bounds the chain.
7824
- */
7825
- async function hook$1(event, input, ctx) {
7826
- if (event === "PermissionRequest") return permissionHook(input, ctx);
7827
- if (event === "Stop") {
7828
- const reason = await endTurnContinuation(ctx);
7829
- if (reason === null) return EMPTY$2;
7830
- return {
7831
- stdout: `${JSON.stringify({
7832
- decision: "block",
7833
- reason
7834
- })}\n`,
7835
- exitCode: 0
7836
- };
7837
- }
7838
- if (event !== "SessionStart" && event !== "UserPromptSubmit") return EMPTY$2;
7839
- const [additionalContext] = await Promise.all([event === "SessionStart" ? pendingHookContext(ctx) : startTurnContext(ctx), recordCliInfo(ctx, input)]);
7840
- if (additionalContext === null) return EMPTY$2;
7841
- return {
7842
- stdout: `${JSON.stringify({ hookSpecificOutput: {
7843
- hookEventName: event,
7844
- additionalContext
7845
- } })}\n`,
7846
- exitCode: 0
7847
- };
7848
- }
7849
- /** Is our PermissionRequest hook in hooks.json. */
7850
- async function permissionHookInstalled(env) {
7851
- const path = hooksPath(env);
7852
- const doc = parseHooksJson(path, await readIfExists(path));
7853
- return asArray(asObject(doc.hooks)[PERMISSION_EVENT]).some((g) => handlersOf(g).some((h) => isOurs(asObject(h).command, PERMISSION_EVENT)));
7854
- }
7855
- /** No idle wake: a Codex session in auto mode gets waiting messages when its current turn ends. */
7856
- const delivery$1 = () => ({
7857
- nextTurn: true,
7858
- endOfTurn: true,
7859
- idleWake: false
7860
- });
7861
- const codexAdapter = {
7862
- cli: "codex",
7863
- displayName: "Codex",
7864
- deliveryTier: "next_turn",
7865
- detect: detect$1,
7866
- async plan(env) {
7867
- return [...await planMcp$1(env), ...await planHooks(env)];
7868
- },
7869
- async uninstallPlan(env) {
7870
- return [...await uninstallMcp$1(env), ...await uninstallHooks(env)];
7871
- },
7872
- hook: hook$1,
7873
- permissionHookInstalled,
7874
- delivery: delivery$1,
7875
- transcript: codexTranscript
7876
- };
7877
- // ../adapters/opencode/dist/index.js
7878
- /**
7879
- * The OpenCode 1.x plugin Conveno installs as `<config dir>/plugins/conveno.js`. OpenCode 1.x loads
7880
- * every `.js` file in the global `plugins/` folder at startup (https://opencode.ai/docs/plugins/,
7881
- * "From local files") and calls each exported function with a context that holds an SDK `client`.
7882
- *
7883
- * The plugin does no Conveno work itself; it runs `conveno hook opencode <event>`, which finds the
7884
- * session by its host process (this OpenCode process) like every other hook:
7885
- *
7886
- * - On `session.idle` of a top-level session it runs `Idle`. In auto mode with messages waiting,
7887
- * that prints the continuation prompt, and the plugin sends it with `client.session.promptAsync`.
7888
- * - Otherwise it starts `Listen`, which waits in the background and prints a prompt when work
7889
- * arrives while the session is idle; the plugin sends that the same way.
7890
- * - When the session turns busy, the plugin is disposed, or a newer listener starts, the listener
7891
- * is stopped. It also stops by itself when OpenCode exits.
7892
- */
7893
- /** Start of the first line of every Conveno plugin file, whatever the OpenCode line it is for. */
7894
- const PLUGIN_MARKER_PREFIX = "// conveno-plugin:";
7895
- /** First line of the 1.x plugin. Uninstall and re-install recognise a plugin by the marker prefix. */
7896
- const PLUGIN_MARKER = `${PLUGIN_MARKER_PREFIX} 1`;
7897
- /**
7898
- * The part both plugins share: the import, the baked-in command, and `run`, which starts
7899
- * `conveno hook opencode <event>` and resolves with what it prints. Plain JavaScript source text.
7900
- */
7901
- function runHelper(command) {
7902
- return `import { spawn } from "node:child_process";
7903
-
7904
- const COMMAND = ${JSON.stringify(command)};
7905
- // A bare \`conveno\` on Windows is a .cmd shim, which only a shell can start. Every argument is a plain word.
7906
- const SHELL = process.platform === "win32" && !/\\.exe$/i.test(COMMAND[0]);
7907
-
7908
- function run(event, sessionID, directory) {
7909
- const [file, ...args] = COMMAND;
7910
- const child = spawn(file, [...args, "hook", "opencode", event], {
7911
- stdio: ["pipe", "pipe", "ignore"],
7912
- shell: SHELL,
7913
- windowsHide: true,
7914
- });
7915
- let out = "";
7916
- child.stdout.setEncoding("utf8");
7917
- child.stdout.on("data", (chunk) => {
7918
- out += chunk;
7919
- });
7920
- const done = new Promise((resolve) => {
7921
- child.once("error", () => resolve(""));
7922
- child.once("close", (code) => resolve(code === 0 ? out.trim() : ""));
7923
- });
7924
- child.stdin.on("error", () => {});
7925
- child.stdin.end(JSON.stringify({ hook_event_name: event, sessionID, directory }));
7926
- return { child, done };
7927
- }`;
7928
- }
7929
- /** The plugin source with the conveno command baked in. Plain JavaScript, no imports beyond Node built-ins. */
7930
- function pluginSource(command) {
7931
- return `${PLUGIN_MARKER}
7932
- // Conveno plugin for OpenCode. Written by \`conveno init\`; \`conveno uninstall\` removes it.
7933
- // It hands Conveno messages to an idle session in auto mode. See https://conveno.dev.
7934
- ${runHelper(command)}
7935
-
7936
- export const ConvenoPlugin = async ({ client }) => {
7937
- let listener;
7938
-
7939
- const stop = () => {
7940
- if (!listener) return;
7941
- listener.child.kill();
7942
- listener = undefined;
7943
- };
7944
-
7945
- const prompt = async (sessionID, text) => {
7946
- try {
7947
- await client.session.promptAsync({
7948
- path: { id: sessionID },
7949
- body: { parts: [{ type: "text", text }] },
7950
- });
7951
- } catch {
7952
- // The session is gone or busy again: the messages stay in the Conveno inbox.
7953
- }
7954
- };
7955
-
7956
- const topLevel = async (sessionID) => {
7957
- try {
7958
- const res = await client.session.get({ path: { id: sessionID } });
7959
- return !res?.data?.parentID;
7960
- } catch {
7961
- return false;
7962
- }
7963
- };
7964
-
7965
- const onIdle = async (sessionID) => {
7966
- if (!(await topLevel(sessionID))) return;
7967
- stop();
7968
- const now = await run("Idle", sessionID).done;
7969
- if (now) return prompt(sessionID, now);
7970
- const current = { ...run("Listen", sessionID), sessionID };
7971
- listener = current;
7972
- const text = await current.done;
7973
- if (listener === current) listener = undefined;
7974
- if (text) await prompt(sessionID, text);
7975
- };
7976
-
7977
- return {
7978
- event: async ({ event }) => {
7979
- if (event.type === "session.idle") void onIdle(event.properties.sessionID);
7980
- else if (
7981
- event.type === "session.status" &&
7982
- event.properties.status?.type === "busy" &&
7983
- event.properties.sessionID === listener?.sessionID
7984
- ) {
7985
- stop();
7986
- }
7987
- },
7988
- dispose: async () => stop(),
7989
- };
7990
- };
7991
- `;
7992
- }
7993
- /**
7994
- * The OpenCode 2.x plugin Conveno installs as `<config dir>/plugins/conveno.js`, the same path as
7995
- * the 1.x one. OpenCode 2.x loads every `.js` and `.ts` file in the global `plugins/` folder
7996
- * (https://opencode.ai/docs/plugins/, "Discover"; `packages/core/src/plugin/module.ts` at tag
7997
- * v2.4.3 accepts a standalone file whose default export is `{ id, setup }`, the object
7998
- * `Plugin.define` returns, so the file needs no import of `@opencode/plugin`).
7999
- *
8000
- * The plugin runs inside the OpenCode server process, which is also the parent of the MCP server
8001
- * it starts, so `conveno hook opencode <event>` finds the session by host process like every other
8002
- * hook. It does no Conveno work itself:
8003
- *
8004
- * - When an execution of a top-level session in this plugin's directory ends
8005
- * (`session.execution.succeeded`) it runs `Idle`. In auto mode with messages waiting, that prints
8006
- * the continuation prompt, and the plugin sends it with `ctx.session.prompt`
8007
- * (`POST /api/session/{id}/prompt`).
8008
- * - After a failed or interrupted execution it runs `Stopped`, which records the end without
8009
- * continuing. An execution that a newer one superseded, or that a shutdown cut off, does nothing.
8010
- * - Then it starts `Listen`, which waits in the background and prints a prompt when work arrives
8011
- * while the session is idle; the plugin sends that the same way.
8012
- * - `session.execution.started`, a newer listener, or unloading the plugin stops the listener.
8013
- *
8014
- * `session.status` and `session.idle` are not used: 2.4.3 does not deliver them to plugins.
8015
- */
8016
- /** First line of the 2.x plugin. */
8017
- const PLUGIN_MARKER_V2 = `${PLUGIN_MARKER_PREFIX} 2`;
8018
- /** The plugin source with the conveno command baked in. Plain JavaScript, no imports beyond Node built-ins. */
8019
- function pluginSourceV2(command) {
8020
- return `${PLUGIN_MARKER_V2}
8021
- // Conveno plugin for OpenCode 2.x. Written by \`conveno init\`; \`conveno uninstall\` removes it.
8022
- // It hands Conveno messages to an idle session in auto mode. See https://conveno.dev.
8023
- ${runHelper(command)}
8024
-
8025
- export default {
8026
- id: "conveno",
8027
- setup(ctx) {
8028
- const controller = new AbortController();
8029
- let listener;
8030
-
8031
- const stop = () => {
8032
- if (!listener) return;
8033
- listener.child.kill();
8034
- listener = undefined;
8035
- };
8036
-
8037
- const prompt = async (sessionID, text) => {
8038
- try {
8039
- await ctx.session.prompt({ sessionID, text });
8040
- } catch {
8041
- // The session is gone or busy again: the messages stay in the Conveno inbox.
8042
- }
8043
- };
8044
-
8045
- // The server sends every plugin the events of every location it serves. Only top-level
8046
- // sessions of this plugin's own directory are ours.
8047
- const ours = async (sessionID) => {
8048
- try {
8049
- const info = await ctx.session.get({ sessionID });
8050
- return !info.parentID && info.location.directory === ctx.location.directory;
8051
- } catch {
8052
- return false;
8053
- }
8054
- };
8055
-
8056
- const onEnd = async (sessionID, event) => {
8057
- if (!(await ours(sessionID))) return;
8058
- stop();
8059
- const now = await run(event, sessionID, ctx.location.directory).done;
8060
- if (now) return prompt(sessionID, now);
8061
- const current = { ...run("Listen", sessionID, ctx.location.directory), sessionID };
8062
- listener = current;
8063
- const text = await current.done;
8064
- if (listener === current) listener = undefined;
8065
- if (text) await prompt(sessionID, text);
8066
- };
8067
-
8068
- void (async () => {
8069
- try {
8070
- for await (const event of ctx.event.subscribe({
8071
- types: [
8072
- "session.execution.started",
8073
- "session.execution.succeeded",
8074
- "session.execution.failed",
8075
- "session.execution.interrupted",
8076
- ],
8077
- signal: controller.signal,
8078
- })) {
8079
- const { sessionID } = event.data;
8080
- if (event.type === "session.execution.started") {
8081
- if (sessionID === listener?.sessionID) stop();
8082
- } else if (event.type === "session.execution.succeeded") {
8083
- void onEnd(sessionID, "Idle");
8084
- } else if (
8085
- event.type === "session.execution.failed" ||
8086
- (event.type === "session.execution.interrupted" &&
8087
- (event.data.reason === "user" || event.data.reason === "inactivity"))
8088
- ) {
8089
- void onEnd(sessionID, "Stopped");
8090
- }
8091
- }
8092
- } catch {
8093
- // The subscription ended with the plugin.
8094
- }
8095
- })();
8096
-
8097
- return () => {
8098
- controller.abort();
8099
- stop();
8100
- };
8101
- },
8102
- };
8103
- `;
8104
- }
8105
- /**
8106
- * OpenCode keeps sessions in SQLite: `opencode.db` in the XDG data directory, `<data>/opencode/`
8107
- * (`~/.local/share/opencode` unless XDG_DATA_HOME is set; the same on every platform because it
8108
- * uses xdg-basedir). A build from a channel other than latest, beta or prod writes
8109
- * `opencode-<channel>.db`, and OPENCODE_DB overrides the file.
8110
- * reference/src/opencode/packages/core/src/database/database.ts (path),
8111
- * packages/core/src/global.ts (data directory).
8112
- *
8113
- * The tables are `session` (id, directory, parent_id, time_created, time_updated), `message` (id,
8114
- * session_id, time_created, data JSON with `role`) and `part` (id, message_id, data JSON with
8115
- * `type`: text, tool, reasoning, ...). packages/core/src/session/sql.ts, packages/schema/src/v1/session.ts.
8116
- *
8117
- * OpenCode 2.x writes the same file with different tables: `session_v2` (id, directory, parent_id,
8118
- * time_updated), `session_message` (id, session_id, type `user`, `assistant`, `synthetic`, `idle`, ...,
8119
- * time_created, data JSON) and `session_part` (message_id, ordinal, type `text`, `reasoning`, `tool`, data JSON),
8120
- * as `opencode.db` in the same directory on Linux, macOS and Windows (`packages/util/src/global-roots.ts` at
8121
- * v2.4.3: `XDG_DATA_HOME` or `~/.local/share`). A fresh 2.x database has no `session` table; one carried
8122
- * over from 1.x has both, so each file is tried as 2.x first, then as 1.x.
8123
- * reference/src/opencode (v2.4.3) packages/core/src/session/sql.ts, packages/schema/src/session-message.ts.
8124
- * The database is opened read-only and never written.
8125
- */
8126
- const dataDir = (env) => join(env.env.XDG_DATA_HOME?.trim() || join(env.home, ".local", "share"), "opencode");
8127
- /** Database files to try, the most recently written first (the write-ahead log counts as a write). */
8128
- async function openCodeDatabases(env) {
8129
- const override = env.env.OPENCODE_DB?.trim();
8130
- if (override && override !== ":memory:") return [isAbsolute(override) ? override : join(dataDir(env), override)];
8131
- const files = (await entriesNewestFirst(dataDir(env))).filter((e) => !e.dir && /^opencode(?:-[A-Za-z0-9._-]+)?\.db$/.test(e.name));
8132
- return (await Promise.all(files.map(async (f) => {
8133
- const wal = await stat(`${f.path}-wal`).then((s) => s.mtimeMs, () => 0);
8134
- return {
8135
- path: f.path,
8136
- mtimeMs: Math.max(f.mtimeMs, wal)
8137
- };
8138
- }))).sort((a, b) => b.mtimeMs - a.mtimeMs).map((f) => f.path);
8139
- }
8140
- const slash = (p) => p.replace(/\\/g, "/");
8141
- const sameDir = (a, b, platform) => {
8142
- const norm = (p) => {
8143
- const s = slash(p).replace(/\/+$/, "");
8144
- return platform === "win32" ? s.toLowerCase() : s;
8145
- };
8146
- return norm(a) === norm(b);
8147
- };
8148
- function json(v) {
8149
- if (typeof v !== "string") return void 0;
8150
- try {
8151
- const o = JSON.parse(v);
8152
- return isRecord(o) ? o : void 0;
8153
- } catch {
8154
- return;
8155
- }
8156
- }
8157
- /** Entries for one message: its role and its parts. Exported for tests. */
8158
- function messageEntries(role, createdMs, parts) {
8159
- if (role !== "user" && role !== "assistant") return [];
8160
- const at = toIso(createdMs);
8161
- const stamp = at ? { at } : {};
8162
- const out = [];
8163
- for (const p of parts) if (p.type === "text") {
8164
- if (p.synthetic === true || p.ignored === true) continue;
8165
- const text = asString(p.text);
8166
- if (text) out.push({
8167
- role,
8168
- text,
8169
- ...stamp
8170
- });
8171
- } else if (p.type === "tool") {
8172
- const state = isRecord(p.state) ? p.state : {};
8173
- out.push({
8174
- role: "tool",
8175
- text: describeToolCall(asString(p.tool) ?? "tool", state.input),
8176
- ...stamp
8177
- });
8178
- const result = asString(state.output) ?? asString(state.error);
8179
- if (result !== void 0 && result !== "") out.push({
8180
- role: "tool",
8181
- text: result,
8182
- ...stamp
8183
- });
8184
- }
8185
- return out;
8186
- }
8187
- async function openReadOnly(path) {
8188
- const { DatabaseSync } = await import("node:sqlite");
8189
- return new DatabaseSync(path, { readOnly: true });
8190
- }
8191
- function findSessionV1(db, q, platform) {
8192
- if (q.cliSessionId) {
8193
- const r = db.prepare("SELECT id FROM session WHERE id = ?").all(q.cliSessionId)[0];
8194
- return asString(r?.id);
8195
- }
8196
- const since = Date.parse(q.startedAt);
8197
- const floor = Number.isFinite(since) ? since - 5e3 : 0;
8198
- const rows = db.prepare("SELECT id, directory FROM session WHERE parent_id IS NULL AND time_updated >= ? ORDER BY time_updated DESC LIMIT 200").all(floor);
8199
- return asString(rows.find((r) => sameDir(asString(r.directory) ?? "", q.cwd, platform))?.id);
8200
- }
8201
- function readSessionV1(db, sessionId, n) {
8202
- const fetch = n * 4 + 20;
8203
- const messages = db.prepare("SELECT id, time_created, data FROM message WHERE session_id = ? ORDER BY time_created DESC, id DESC LIMIT ?").all(sessionId, fetch + 1).reverse();
8204
- const more = messages.length > fetch;
8205
- const used = more ? messages.slice(1) : messages;
8206
- const entries = [];
8207
- for (const m of used) {
8208
- const data = json(m.data);
8209
- const role = asString(data?.role);
8210
- if (!role) continue;
8211
- const parts = db.prepare("SELECT data FROM part WHERE message_id = ? ORDER BY id").all(asString(m.id) ?? "").map((p) => json(p.data)).filter((p) => p !== void 0);
8212
- entries.push(...messageEntries(role, m.time_created, parts));
8213
- }
8214
- return {
8215
- entries: entries.slice(-n),
8216
- more: more || entries.length > n
8217
- };
8218
- }
8219
- const hasTable = (db, name) => db.prepare("SELECT 1 AS x FROM sqlite_master WHERE type = 'table' AND name = ?").all(name).length > 0;
8220
- function findSessionV2(db, q, platform) {
8221
- if (q.cliSessionId) {
8222
- const r = db.prepare("SELECT id FROM session_v2 WHERE id = ?").all(q.cliSessionId)[0];
8223
- return asString(r?.id);
8224
- }
8225
- const since = Date.parse(q.startedAt);
8226
- const floor = Number.isFinite(since) ? since - 5e3 : 0;
8227
- const rows = db.prepare("SELECT id, directory FROM session_v2 WHERE parent_id IS NULL AND time_updated >= ? ORDER BY time_updated DESC LIMIT 200").all(floor);
8228
- return asString(rows.find((r) => sameDir(asString(r.directory) ?? "", q.cwd, platform))?.id);
8229
- }
8230
- /** Entries for one 2.x message: user text, or the text and tool parts of an assistant message. Exported for tests. */
8231
- function messageEntriesV2(type, createdMs, data, parts) {
8232
- const at = toIso(createdMs);
8233
- const stamp = at ? { at } : {};
8234
- if (type === "user") {
8235
- const text = asString(data?.text);
8236
- return text ? [{
8237
- role: "user",
8238
- text,
8239
- ...stamp
8240
- }] : [];
8241
- }
8242
- if (type !== "assistant") return [];
8243
- const out = [];
8244
- for (const p of parts) if (p.type === "text") {
8245
- const text = asString(p.text);
8246
- if (text) out.push({
8247
- role: "assistant",
8248
- text,
8249
- ...stamp
8250
- });
8251
- } else if (p.type === "tool") {
8252
- const state = isRecord(p.state) ? p.state : {};
8253
- out.push({
8254
- role: "tool",
8255
- text: describeToolCall(asString(p.name) ?? "tool", state.input),
8256
- ...stamp
8257
- });
8258
- const result = (Array.isArray(state.content) ? state.content : []).map((c) => isRecord(c) && c.type === "text" ? asString(c.text) : void 0).filter((t) => t !== void 0 && t !== "").join("\n") || (isRecord(state.error) ? asString(state.error.message) : void 0);
8259
- if (result) out.push({
8260
- role: "tool",
8261
- text: result,
8262
- ...stamp
8263
- });
8264
- }
8265
- return out;
8266
- }
8267
- function readSessionV2(db, sessionId, n) {
8268
- const fetch = n * 4 + 20;
8269
- const messages = db.prepare("SELECT id, type, time_created, data FROM session_message WHERE session_id = ? ORDER BY time_created DESC, id DESC LIMIT ?").all(sessionId, fetch + 1).reverse();
8270
- const more = messages.length > fetch;
8271
- const used = more ? messages.slice(1) : messages;
8272
- const entries = [];
8273
- for (const m of used) {
8274
- const type = asString(m.type);
8275
- if (!type) continue;
8276
- const parts = type === "assistant" ? db.prepare("SELECT data FROM session_part WHERE message_id = ? ORDER BY ordinal").all(asString(m.id) ?? "").map((p) => json(p.data)).filter((p) => p !== void 0) : [];
8277
- entries.push(...messageEntriesV2(type, m.time_created, json(m.data), parts));
8278
- }
8279
- return {
8280
- entries: entries.slice(-n),
8281
- more: more || entries.length > n
8282
- };
8283
- }
8284
- const openCodeTranscript = { async read(q, env) {
8285
- let dbs;
8286
- try {
8287
- dbs = await openCodeDatabases(env);
8288
- } catch {
8289
- dbs = [];
8290
- }
8291
- if (dbs.length === 0) return notFound("OpenCode", "no OpenCode database in the data directory");
8292
- for (const path of dbs) {
8293
- let db;
8294
- try {
8295
- db = await openReadOnly(path);
8296
- if (hasTable(db, "session_v2") && hasTable(db, "session_message")) {
8297
- const id2 = findSessionV2(db, q, env.platform);
8298
- if (id2 !== void 0) {
8299
- const { entries, more } = readSessionV2(db, id2, q.lastTurns);
8300
- return {
8301
- ok: true,
8302
- entries,
8303
- more
8304
- };
8305
- }
8306
- }
8307
- if (!hasTable(db, "session")) continue;
8308
- const id = findSessionV1(db, q, env.platform);
8309
- if (id === void 0) continue;
8310
- const { entries, more } = readSessionV1(db, id, q.lastTurns);
8311
- return {
8312
- ok: true,
8313
- entries,
8314
- more
8315
- };
8316
- } catch {} finally {
8317
- try {
8318
- db?.close();
8319
- } catch {}
8320
- }
8321
- }
8322
- return notFound("OpenCode", q.cliSessionId ? "no session with that id" : "no session for this working directory since it started");
8323
- } };
8324
- const SERVER_NAME = "conveno";
8325
- const FORMAT = {
8326
- insertSpaces: true,
8327
- tabSize: 2,
8328
- eol: "\n"
8329
- };
8330
- /** First OpenCode release that reads `mcp.servers`. There were no 2.0.x or 2.1.x releases. */
8331
- const V2_MIN = [
8332
- 2,
8333
- 2,
8334
- 0
8335
- ];
8336
- /** `$XDG_CONFIG_HOME/opencode` when XDG_CONFIG_HOME is an absolute path, else `~/.config/opencode`. */
8337
- function configDir(env) {
8338
- const xdg = env.env.XDG_CONFIG_HOME;
8339
- const base = xdg && isAbsolute(xdg) ? xdg : join(env.home, ".config");
8340
- return join(base, "opencode");
8341
- }
8342
- /** `OPENCODE_CONFIG` names one config file; when set it is the only file we touch. */
8343
- const customConfig = (env) => env.env.OPENCODE_CONFIG || void 0;
8344
- /**
8345
- * `OPENCODE_CONFIG` when set. Otherwise an existing opencode.jsonc, then opencode.json, else a
8346
- * new opencode.json in the config directory.
8347
- */
8348
- async function locateConfig(env) {
8349
- const custom = customConfig(env);
8350
- if (custom) try {
8351
- return {
8352
- path: custom,
8353
- text: await readFile(custom, "utf8")
8354
- };
8355
- } catch (err) {
8356
- if (err.code !== "ENOENT") throw err;
8357
- return {
8358
- path: custom,
8359
- text: null
8360
- };
8361
- }
8362
- const dir = configDir(env);
8363
- for (const name of ["opencode.jsonc", "opencode.json"]) {
8364
- const path = join(dir, name);
8365
- try {
8366
- return {
8367
- path,
8368
- text: await readFile(path, "utf8")
8369
- };
8370
- } catch (err) {
8371
- if (err.code !== "ENOENT") throw err;
8372
- }
8373
- }
8374
- return {
8375
- path: join(dir, "opencode.json"),
8376
- text: null
8377
- };
8378
- }
8379
- function parseConfig(file) {
8380
- if (file.text === null || file.text.trim() === "") return {};
8381
- const errors = [];
8382
- const value = parse(file.text, errors, { allowTrailingComma: true });
8383
- const first = errors[0];
8384
- if (first) throw new Error(`Cannot read ${file.path}: ${printParseErrorCode(first.error)} at offset ${first.offset}. Fix the syntax or move the file aside, then run conveno again. The file was not changed.`);
8385
- if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error(`Cannot read ${file.path}: the top level must be a JSON object. The file was not changed.`);
8386
- return value;
8387
- }
8388
- function serverEntry(env, shape) {
8389
- const command = [
8390
- ...env.conveno.command,
8391
- "mcp",
8392
- "--cli",
8393
- "opencode"
8394
- ];
8395
- return shape === "v1" ? {
8396
- type: "local",
8397
- command,
8398
- enabled: true
8399
- } : {
8400
- type: "local",
8401
- command
8402
- };
8403
- }
8404
- function parseVersion(text) {
8405
- const m = /(\d+)\.(\d+)\.(\d+)/.exec(text);
8406
- return m ? [
8407
- Number(m[1]),
8408
- Number(m[2]),
8409
- Number(m[3])
8410
- ] : void 0;
8411
- }
8412
- function isV2OrLater(v) {
8413
- for (let i = 0; i < 3; i++) if (v[i] !== V2_MIN[i]) return v[i] > V2_MIN[i];
8414
- return true;
8415
- }
8416
- async function installedVersion(env) {
8417
- try {
8418
- const res = await env.exec("opencode", ["--version"]);
8419
- return res.code === 0 ? parseVersion(res.stdout) : void 0;
8420
- } catch {
8421
- return;
8422
- }
8423
- }
8424
- async function chooseShape(config, version) {
8425
- if (version) return isV2OrLater(version) ? "v2" : "v1";
8426
- return servers(config) !== void 0 ? "v2" : "v1";
8427
- }
8428
- function v1Entry(config) {
8429
- const mcp = config.mcp;
8430
- if (mcp === null || typeof mcp !== "object" || Array.isArray(mcp)) return void 0;
8431
- return mcp[SERVER_NAME];
8432
- }
8433
- function pathFor(shape) {
8434
- return shape === "v1" ? ["mcp", SERVER_NAME] : [
8435
- "mcp",
8436
- "servers",
8437
- SERVER_NAME
8438
- ];
8439
- }
8440
- function sameEntry(found, want) {
8441
- if (found === null || typeof found !== "object") return false;
8442
- const f = found;
8443
- return f.type === want.type && f.disabled !== true && (want.enabled === void 0 || f.enabled === true) && Array.isArray(f.command) && f.command.length === want.command.length && f.command.every((c, i) => c === want.command[i]);
8444
- }
8445
- function servers(config) {
8446
- const mcp = config.mcp;
8447
- if (mcp === null || typeof mcp !== "object" || Array.isArray(mcp)) return void 0;
8448
- const s = mcp.servers;
8449
- if (s === null || typeof s !== "object" || Array.isArray(s)) return void 0;
8450
- return s;
8451
- }
8452
- async function detect(env) {
8453
- const custom = customConfig(env);
8454
- const configPaths = custom ? [custom] : [join(configDir(env), "opencode.jsonc"), join(configDir(env), "opencode.json")];
8455
- try {
8456
- const res = await env.exec("opencode", ["--version"]);
8457
- if (res.code !== 0) return {
8458
- installed: false,
8459
- configPaths
8460
- };
8461
- const version = parseCliVersion(res.stdout);
8462
- return {
8463
- installed: true,
8464
- binary: "opencode",
8465
- configPaths,
8466
- ...version ? { version } : {}
8467
- };
8468
- } catch {
8469
- return {
8470
- installed: false,
8471
- configPaths
8472
- };
8473
- }
8474
- }
8475
- /** `<config dir>/plugins/conveno.js`, the global plugin folder OpenCode 1.x and 2.x load. */
8476
- const pluginPath = (env) => join(configDir(env), "plugins", "conveno.js");
8477
- async function readText(path) {
8478
- try {
8479
- return await readFile(path, "utf8");
8480
- } catch (err) {
8481
- if (err.code === "ENOENT") return null;
8482
- throw err;
8483
- }
8484
- }
8485
- /**
8486
- * The plugin API differs between the lines (https://opencode.ai/docs/build/plugins/migrate-v1/), so
8487
- * each gets its own source at the same path. An unknown version gets nothing rather than a file
8488
- * that might not load.
8489
- */
8490
- const pluginFor = (env, version) => {
8491
- if (version === void 0) return void 0;
8492
- return isV2OrLater(version) ? pluginSourceV2(env.conveno.command) : pluginSource(env.conveno.command);
8493
- };
8494
- async function planPlugin(env, version) {
8495
- const want = pluginFor(env, version);
8496
- if (want === void 0) return [];
8497
- const path = pluginPath(env);
8498
- const before = await readText(path);
8499
- if (before === want) return [];
8500
- if (before !== null && !before.startsWith("// conveno-plugin:")) throw new Error(`${path} exists and was not written by Conveno. Move or rename it, then run conveno again. The file was not changed.`);
8501
- return [{
8502
- component: "hooks",
8503
- kind: before === null ? "add" : "update",
8504
- path,
8505
- before,
8506
- after: want,
8507
- description: `${before === null ? "Add" : "Update"} the Conveno plugin for OpenCode ${version && isV2OrLater(version) ? "2.x" : "1.x"}. In auto mode it hands waiting messages to a session when its turn ends or while it is idle.`
8508
- }];
8509
- }
8510
- async function uninstallPlugin(env) {
8511
- const path = pluginPath(env);
8512
- const before = await readText(path);
8513
- if (before === null || !before.startsWith("// conveno-plugin:")) return [];
8514
- return [{
8515
- component: "hooks",
8516
- kind: "remove",
8517
- path,
8518
- before,
8519
- after: "",
8520
- deleteFile: true,
8521
- description: "Remove the Conveno plugin for OpenCode."
8522
- }];
8523
- }
8524
- async function plan(env) {
8525
- const version = await installedVersion(env);
8526
- return [...await planMcp(env, version), ...await planPlugin(env, version)];
8527
- }
8528
- async function uninstallPlan(env) {
8529
- return [...await uninstallMcp(env), ...await uninstallPlugin(env)];
8530
- }
8531
- async function planMcp(env, version) {
8532
- const file = await locateConfig(env);
8533
- const config = parseConfig(file);
8534
- const shape = await chooseShape(config, version);
8535
- const want = serverEntry(env, shape);
8536
- const current = shape === "v1" ? v1Entry(config) : servers(config)?.[SERVER_NAME];
8537
- if (sameEntry(current, want)) return [];
8538
- let text = file.text === null || file.text.trim() === "" ? "{}\n" : file.text;
8539
- const otherShape = shape === "v1" ? "v2" : "v1";
8540
- const other = otherShape === "v1" ? v1Entry(config) : servers(config)?.[SERVER_NAME];
8541
- if (other !== void 0) text = applyEdits(text, modify(text, pathFor(otherShape), void 0, { formattingOptions: FORMAT }));
8542
- let after = applyEdits(text, modify(text, pathFor(shape), want, { formattingOptions: FORMAT }));
8543
- if (!after.endsWith("\n")) after += "\n";
8544
- const where = shape === "v1" ? `mcp.${SERVER_NAME}` : `mcp.servers.${SERVER_NAME}`;
8545
- return [{
8546
- component: "mcp",
8547
- kind: current !== void 0 || other !== void 0 ? "update" : "add",
8548
- path: file.path,
8549
- before: file.text,
8550
- after,
8551
- description: `Add the conveno MCP server (${where}) to the OpenCode global config`
8552
- }];
8553
- }
8554
- async function uninstallMcp(env) {
8555
- const file = await locateConfig(env);
8556
- if (file.text === null) return [];
8557
- const config = parseConfig(file);
8558
- let text = file.text;
8559
- const removed = [];
8560
- if (servers(config)?.[SERVER_NAME] !== void 0) {
8561
- text = applyEdits(text, modify(text, pathFor("v2"), void 0, { formattingOptions: FORMAT }));
8562
- removed.push(`mcp.servers.${SERVER_NAME}`);
8563
- }
8564
- if (v1Entry(config) !== void 0) {
8565
- text = applyEdits(text, modify(text, pathFor("v1"), void 0, { formattingOptions: FORMAT }));
8566
- removed.push(`mcp.${SERVER_NAME}`);
8567
- }
8568
- if (removed.length === 0) return [];
8569
- return [{
8570
- component: "mcp",
8571
- kind: "remove",
8572
- path: file.path,
8573
- before: file.text,
8574
- after: text,
8575
- description: `Remove the conveno MCP server (${removed.join(", ")}) from the OpenCode global config`
8576
- }];
8577
- }
8578
- const EMPTY = {
8579
- stdout: "",
8580
- exitCode: 0
8581
- };
8582
- /**
8583
- * Run by the plugin, never by OpenCode itself. Each prints the prompt to send as plain text, which
8584
- * the plugin sends to the session (1.x `client.session.promptAsync`, 2.x `ctx.session.prompt`).
8585
- * - Idle: the session's turn ended. In auto mode with messages waiting, the prompt to continue with.
8586
- * - Stopped: the turn failed or the user interrupted it. Records the end and never continues.
8587
- * - Listen: the background listener. Waits for work while the session is idle.
8588
- */
8589
- async function hook(event, input, ctx) {
8590
- const dir = typeof input === "object" && input !== null ? input.directory : void 0;
8591
- if (typeof dir === "string" && dir !== "") ctx = {
8592
- ...ctx,
8593
- cwd: dir
8594
- };
8595
- let text = null;
8596
- if (event === "Idle") text = await endTurnContinuation(ctx);
8597
- else if (event === "Stopped") await endTurnContinuation(ctx, { allowContinue: false });
8598
- else if (event === "Listen") text = await waitForWork(ctx);
8599
- return text === null ? EMPTY : {
8600
- stdout: text,
8601
- exitCode: 0
8602
- };
8603
- }
8604
- /** Only the plugin delivers, on 1.x and 2.x alike; it adds nothing to a prompt the user types. */
8605
- function delivery(detection) {
8606
- const supported = detection.version !== void 0 && parseVersion(detection.version) !== void 0;
8607
- return {
8608
- nextTurn: false,
8609
- endOfTurn: supported,
8610
- idleWake: supported
8611
- };
8612
- }
8613
- const opencodeAdapter = {
8614
- cli: "opencode",
8615
- displayName: "OpenCode",
8616
- deliveryTier: "inbox",
8617
- detect,
8618
- plan,
8619
- uninstallPlan,
8620
- hook,
8621
- listenEvents: ["Listen"],
8622
- delivery,
8623
- transcript: openCodeTranscript
8624
- };
8625
- export { Za as a, claudeTranscript as c, codexTranscript as i, opencodeAdapter as n, cs as o, codexAdapter as r, claudeAdapter as s, openCodeTranscript as t };
6756
+ export { cs as n, Za as t };