@phren/cli 0.3.9 → 0.3.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.
- package/dist/bridge/transcript-codex.d.ts +20 -0
- package/dist/bridge/transcript-codex.js +177 -2
- package/dist/bridge/transcripts.js +6 -1
- package/dist/bridge-hook.mjs +160 -9
- package/package.json +1 -1
- package/starter/global/skills/conductor/SKILL.md +4 -0
- package/starter/global/skills/fanout/SKILL.md +6 -0
|
@@ -8,6 +8,26 @@ export declare function childTranscriptBelongsTo(file: string, parent: string):
|
|
|
8
8
|
/** Codex rows the phone may see: public messages, tool calls and their
|
|
9
9
|
* outputs, the answering model, and turn/usage events. */
|
|
10
10
|
export declare function visibleCodexEvent(raw: Json): Json | undefined;
|
|
11
|
+
export interface CodeModeWrapper {
|
|
12
|
+
callId: string;
|
|
13
|
+
images: string[];
|
|
14
|
+
}
|
|
15
|
+
/** A numbered rollout's code-mode `exec` call whose every tool call is
|
|
16
|
+
* recorded as an item. A script that calls anything else stays as it is. */
|
|
17
|
+
export declare function codeModeWrapper(raw: Json): CodeModeWrapper | undefined;
|
|
18
|
+
/** The wrapper a numbered rollout's code-mode result answers, by call id. */
|
|
19
|
+
export declare function codeModeOutputCall(raw: Json): string | undefined;
|
|
20
|
+
/** A covered wrapper's result: an image viewer keeps only its pictures, a
|
|
21
|
+
* "Script completed"/"Script running" status is hidden (the items carry the
|
|
22
|
+
* actions), and a failure or abort is listed with the script it ended, whose
|
|
23
|
+
* own row was hidden, so the phone draws the pair. */
|
|
24
|
+
export declare function projectCodeModeOutput(raw: Json, call: Json | undefined): Json | undefined;
|
|
25
|
+
/** The wrapper call a result answers, found within the rows just before it
|
|
26
|
+
* (a script's own items sit between the two; 32 rows apart at most seen). */
|
|
27
|
+
export declare function findCodeModeCall(rows: (before: number, after: number) => AsyncIterable<{
|
|
28
|
+
line: number;
|
|
29
|
+
bytes?: Buffer;
|
|
30
|
+
}>, line: number, callId: string): Promise<Json | undefined>;
|
|
11
31
|
/** Codex 0.155 code mode: the model calls one generic tool whose input is
|
|
12
32
|
* JavaScript, and that source invokes `tools.apply_patch`/`tools.shell`/
|
|
13
33
|
* `tools.read`. The Hook resolves each invocation into the ordinary call the
|
|
@@ -90,8 +90,13 @@ export function visibleCodexEvent(raw) {
|
|
|
90
90
|
payload: { type: "error", ...(typeof p.message === "string" ? { message: p.message } : {}) } };
|
|
91
91
|
if (raw.type === "event_msg" && ["token_count", "task_started", "task_complete", "task_completed", "turn_aborted", "task_aborted", "error"].includes(String(p.type)))
|
|
92
92
|
return raw;
|
|
93
|
+
if (raw.type === "event_msg" && p.type === "item_completed")
|
|
94
|
+
return itemCall(raw, object(p.item));
|
|
93
95
|
if (raw.type !== "response_item")
|
|
94
96
|
return undefined;
|
|
97
|
+
const wrapper = codeModeWrapper(raw);
|
|
98
|
+
if (wrapper)
|
|
99
|
+
return wrapper.images.length ? imageCall(raw, wrapper) : undefined;
|
|
95
100
|
if (p.type === "message" && ["user", "assistant"].includes(String(p.role)) && p.channel !== "analysis") {
|
|
96
101
|
const text = typeof p.content === "string" ? p.content : objects(p.content).map(b => typeof b.text === "string" ? b.text : "").join("\n");
|
|
97
102
|
return p.role === "user" && harnessPreamble(text) ? undefined : raw;
|
|
@@ -100,6 +105,162 @@ export function visibleCodexEvent(raw) {
|
|
|
100
105
|
return raw;
|
|
101
106
|
return undefined;
|
|
102
107
|
}
|
|
108
|
+
/** Codex 0.155.1 and later number their rollout rows (`ordinal`) and record
|
|
109
|
+
* each action a code-mode script runs as its own `item_completed` row: the
|
|
110
|
+
* command and its output, the patch, the MCP call. The `exec` call wrapping
|
|
111
|
+
* those actions in JavaScript and its "Script completed" result only repeat
|
|
112
|
+
* them, so the phone reads the items as the ordinary calls it already draws. */
|
|
113
|
+
const OUTPUT_TAIL = 4_000, MCP_OUTPUT = 65_536, PATCH_FILE = 200_000, COMMAND = 16_384;
|
|
114
|
+
const WRAPPED_TOOL = /\btools\s*\.\s*([A-Za-z_$][\w$]*)\s*\(/g;
|
|
115
|
+
const VIEW_IMAGE = /\btools\s*\.\s*view_image\s*\(/g;
|
|
116
|
+
/** Tools whose every call Codex records as an item (`write_stdin` finishes
|
|
117
|
+
* the command it feeds; `view_image` has only a path item, so its picture is
|
|
118
|
+
* taken from the wrapper's own result). */
|
|
119
|
+
const ITEM_TOOLS = new Set(["exec_command", "write_stdin", "apply_patch", "view_image"]);
|
|
120
|
+
/** A numbered rollout's code-mode `exec` call whose every tool call is
|
|
121
|
+
* recorded as an item. A script that calls anything else stays as it is. */
|
|
122
|
+
export function codeModeWrapper(raw) {
|
|
123
|
+
const p = object(raw.payload), source = p.input, callId = p.call_id;
|
|
124
|
+
if (typeof raw.ordinal !== "number" || raw.type !== "response_item" || p.type !== "custom_tool_call" || p.name !== "exec")
|
|
125
|
+
return undefined;
|
|
126
|
+
if (typeof source !== "string" || typeof callId !== "string" || !callId || source.trimStart().startsWith("*** Begin Patch"))
|
|
127
|
+
return undefined;
|
|
128
|
+
const tools = [...source.matchAll(WRAPPED_TOOL)].map(match => match[1]);
|
|
129
|
+
if (!tools.length || !tools.every(tool => ITEM_TOOLS.has(tool) || /^mcp__\w+$/.test(tool)))
|
|
130
|
+
return undefined;
|
|
131
|
+
const images = [...source.matchAll(VIEW_IMAGE)].map(match => {
|
|
132
|
+
const args = callArguments(source, (match.index ?? 0) + match[0].length - 1);
|
|
133
|
+
return (args === undefined ? undefined : argumentString(args, source, ["path"])) ?? "";
|
|
134
|
+
});
|
|
135
|
+
return { callId, images };
|
|
136
|
+
}
|
|
137
|
+
/** A wrapper that viewed an image becomes the `view_image` call its result
|
|
138
|
+
* (the picture) pairs with; the ImageView item names only the path. */
|
|
139
|
+
function imageCall(raw, wrapper) {
|
|
140
|
+
const file = wrapper.images.find(Boolean);
|
|
141
|
+
return { type: "response_item", ...(raw.timestamp !== undefined ? { timestamp: raw.timestamp } : {}),
|
|
142
|
+
payload: { type: "function_call", name: "view_image", call_id: wrapper.callId, arguments: JSON.stringify(file ? { path: file.slice(0, 4_096) } : {}) } };
|
|
143
|
+
}
|
|
144
|
+
/** The wrapper a numbered rollout's code-mode result answers, by call id. */
|
|
145
|
+
export function codeModeOutputCall(raw) {
|
|
146
|
+
const p = object(raw.payload);
|
|
147
|
+
return typeof raw.ordinal === "number" && raw.type === "response_item" && p.type === "custom_tool_call_output"
|
|
148
|
+
&& typeof p.call_id === "string" && p.call_id ? p.call_id : undefined;
|
|
149
|
+
}
|
|
150
|
+
/** A covered wrapper's result: an image viewer keeps only its pictures, a
|
|
151
|
+
* "Script completed"/"Script running" status is hidden (the items carry the
|
|
152
|
+
* actions), and a failure or abort is listed with the script it ended, whose
|
|
153
|
+
* own row was hidden, so the phone draws the pair. */
|
|
154
|
+
export function projectCodeModeOutput(raw, call) {
|
|
155
|
+
const wrapper = call && codeModeWrapper(call);
|
|
156
|
+
if (!call || !wrapper)
|
|
157
|
+
return raw;
|
|
158
|
+
const p = object(raw.payload), blocks = Array.isArray(p.output) ? objects(p.output) : [];
|
|
159
|
+
const images = blocks.filter(block => ["input_image", "image"].includes(String(block.type)));
|
|
160
|
+
// The view_image call is already listed on the script's own row.
|
|
161
|
+
if (wrapper.images.length)
|
|
162
|
+
return images.length ? { ...raw, payload: { ...p, output: images } } : raw;
|
|
163
|
+
const text = typeof p.output === "string" ? p.output : blocks.map(block => typeof block.text === "string" ? block.text : "").join("\n");
|
|
164
|
+
if (/^Script (completed|running)\b/.test(text))
|
|
165
|
+
return undefined;
|
|
166
|
+
return { type: "response_item", ...(call.timestamp !== undefined ? { timestamp: call.timestamp } : {}),
|
|
167
|
+
payload: { type: "custom_tool_call", name: "exec", call_id: wrapper.callId, input: object(call.payload).input }, phren_item_output: raw };
|
|
168
|
+
}
|
|
169
|
+
/** The wrapper call a result answers, found within the rows just before it
|
|
170
|
+
* (a script's own items sit between the two; 32 rows apart at most seen). */
|
|
171
|
+
export async function findCodeModeCall(rows, line, callId) {
|
|
172
|
+
const needle = Buffer.from(JSON.stringify(callId));
|
|
173
|
+
for await (const row of rows(line, Math.max(0, line - 256))) {
|
|
174
|
+
if (!row.bytes?.includes(needle))
|
|
175
|
+
continue;
|
|
176
|
+
try {
|
|
177
|
+
const raw = object(JSON.parse(row.bytes.toString())), p = object(raw.payload);
|
|
178
|
+
if (raw.type === "response_item" && p.type === "custom_tool_call" && p.call_id === callId)
|
|
179
|
+
return raw;
|
|
180
|
+
}
|
|
181
|
+
catch { /* Not the call. */ }
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
/** A shell command as the terminal shows it: the script a `sh -lc` runs. */
|
|
186
|
+
function commandText(value) {
|
|
187
|
+
if (typeof value === "string")
|
|
188
|
+
return value;
|
|
189
|
+
const parts = Array.isArray(value) ? value.filter((part) => typeof part === "string") : [];
|
|
190
|
+
if (parts.length === 3 && ["-lc", "-c"].includes(parts[1]) && /(^|\/)(ba|z|da|fi|k)?sh$/.test(parts[0]))
|
|
191
|
+
return parts[2];
|
|
192
|
+
return parts.join(" ");
|
|
193
|
+
}
|
|
194
|
+
function localPath(value) {
|
|
195
|
+
if (typeof value !== "string" || !value)
|
|
196
|
+
return undefined;
|
|
197
|
+
// The URL names a path on the computer Codex ran on, which may not follow
|
|
198
|
+
// this platform's rules (fileURLToPath refuses `file:///work` on Windows).
|
|
199
|
+
if (value.startsWith("file://")) {
|
|
200
|
+
try {
|
|
201
|
+
const url = new URL(value);
|
|
202
|
+
if (url.host)
|
|
203
|
+
return undefined;
|
|
204
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
205
|
+
return /^\/[A-Za-z]:\//.test(pathname) ? pathname.slice(1) : pathname;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return value.startsWith("/") ? value : undefined;
|
|
212
|
+
}
|
|
213
|
+
/** A FileChange's files as the apply_patch text the patch card draws. */
|
|
214
|
+
function changePatch(changes) {
|
|
215
|
+
const sections = Object.entries(object(changes)).slice(0, 50).map(([file, value]) => {
|
|
216
|
+
const change = object(value), kind = String(change.type ?? "update");
|
|
217
|
+
if (kind === "add") {
|
|
218
|
+
const content = typeof change.content === "string" ? change.content.slice(0, PATCH_FILE).replace(/\n$/, "") : "";
|
|
219
|
+
return `*** Add File: ${file}\n` + content.split("\n").map(line => "+" + line).join("\n");
|
|
220
|
+
}
|
|
221
|
+
if (kind === "delete")
|
|
222
|
+
return `*** Delete File: ${file}`;
|
|
223
|
+
const moved = typeof change.move_path === "string" && change.move_path ? `\n*** Move to: ${change.move_path}` : "";
|
|
224
|
+
const diff = typeof change.unified_diff === "string" ? change.unified_diff.slice(0, PATCH_FILE).replace(/\n$/, "") : "";
|
|
225
|
+
return `*** Update File: ${file}${moved}${diff ? "\n" + diff : ""}`;
|
|
226
|
+
});
|
|
227
|
+
return ["*** Begin Patch", ...sections, "*** End Patch"].join("\n");
|
|
228
|
+
}
|
|
229
|
+
/** An action item as the call the phone draws, carrying its result under
|
|
230
|
+
* `phren_item_output` for the reader to list right after it. Reasoning,
|
|
231
|
+
* messages (already rows of their own) and bookkeeping items stay hidden. */
|
|
232
|
+
function itemCall(raw, item) {
|
|
233
|
+
const id = typeof item.id === "string" && item.id ? item.id.slice(0, 200) : "";
|
|
234
|
+
if (!id)
|
|
235
|
+
return undefined;
|
|
236
|
+
const stamp = raw.timestamp !== undefined ? { timestamp: raw.timestamp } : {};
|
|
237
|
+
const row = (call, output) => ({ type: "response_item", ...stamp, payload: { ...call, call_id: id },
|
|
238
|
+
phren_item_output: { type: "response_item", ...stamp, payload: { ...output, call_id: id } } });
|
|
239
|
+
const status = typeof item.status === "string" ? item.status : "completed";
|
|
240
|
+
switch (item.type) {
|
|
241
|
+
case "CommandExecution": {
|
|
242
|
+
const workdir = localPath(item.cwd);
|
|
243
|
+
const text = [item.aggregated_output, item.formatted_output].find(v => typeof v === "string")
|
|
244
|
+
?? [item.stdout, item.stderr].filter(v => typeof v === "string").join("");
|
|
245
|
+
const tail = text.slice(-OUTPUT_TAIL);
|
|
246
|
+
const output = typeof item.exit_code === "number" ? JSON.stringify({ output: tail, exit_code: item.exit_code })
|
|
247
|
+
: `${tail}${tail && !tail.endsWith("\n") ? "\n" : ""}[${status}]`;
|
|
248
|
+
return row({ type: "function_call", name: "exec_command", arguments: JSON.stringify({ cmd: commandText(item.command).slice(0, COMMAND), ...(workdir ? { workdir } : {}) }) }, { type: "function_call_output", output });
|
|
249
|
+
}
|
|
250
|
+
case "FileChange": {
|
|
251
|
+
const said = [status === "completed" ? item.stdout : item.stderr, item.stdout, item.stderr].find(v => typeof v === "string" && v.trim());
|
|
252
|
+
return row({ type: "custom_tool_call", name: "apply_patch", input: changePatch(item.changes) }, { type: "custom_tool_call_output", output: (said ?? status).slice(-OUTPUT_TAIL) });
|
|
253
|
+
}
|
|
254
|
+
case "McpToolCall": {
|
|
255
|
+
const result = object(item.result), ok = object(result.Ok ?? result), error = result.Err ?? item.error;
|
|
256
|
+
const text = objects(ok.content).filter(block => block.type === "text" && typeof block.text === "string").map(block => String(block.text)).join("\n");
|
|
257
|
+
const output = text || (error !== undefined && error !== null ? (typeof error === "string" ? error : JSON.stringify(error)) : status);
|
|
258
|
+
const args = typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {});
|
|
259
|
+
return row({ type: "function_call", name: `mcp__${String(item.server ?? "mcp")}__${String(item.tool ?? "tool")}`, arguments: args.slice(0, 262_144) }, { type: "function_call_output", output: output.slice(0, MCP_OUTPUT) });
|
|
260
|
+
}
|
|
261
|
+
default: return undefined;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
103
264
|
const CODE_TOOL_CALL = /\btools\s*\.\s*(apply_patch|shell|read)\s*\(/g;
|
|
104
265
|
const JS_ESCAPES = { n: "\n", r: "\r", t: "\t", b: "\b", f: "\f", v: "\v", "0": "\0", "'": "'", '"': '"', "\\": "\\", "/": "/" };
|
|
105
266
|
function unescapeJs(value) {
|
|
@@ -167,7 +328,9 @@ function callArguments(source, open) {
|
|
|
167
328
|
}
|
|
168
329
|
return undefined;
|
|
169
330
|
}
|
|
170
|
-
|
|
331
|
+
/** A string argument: a literal, a string identifier, or one of `keys` in an
|
|
332
|
+
* object literal. */
|
|
333
|
+
function argumentString(expression, source, keys) {
|
|
171
334
|
const inline = resolveString(expression, source);
|
|
172
335
|
if (inline !== undefined)
|
|
173
336
|
return inline;
|
|
@@ -177,9 +340,12 @@ function shellCommand(expression, source) {
|
|
|
177
340
|
const body = inner.trim();
|
|
178
341
|
if (/^[A-Za-z_$][\w$]*$/.test(body))
|
|
179
342
|
return resolveString(body, source);
|
|
180
|
-
const property =
|
|
343
|
+
const property = new RegExp(`(?:^|[,{])\\s*(?:${keys.join("|")})\\s*:\\s*("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|[A-Za-z_$][\\w$]*)`).exec(body);
|
|
181
344
|
return property ? resolveString(property[1], source) : undefined;
|
|
182
345
|
}
|
|
346
|
+
function shellCommand(expression, source) {
|
|
347
|
+
return argumentString(expression, source, ["command", "cmd"]);
|
|
348
|
+
}
|
|
183
349
|
/** Every recognized invocation in a code-mode source, in the order written. */
|
|
184
350
|
export function codeToolCalls(source) {
|
|
185
351
|
const calls = [], original = source.slice(0, 262_144);
|
|
@@ -253,6 +419,15 @@ function renameProjectedChanges(raw, base) {
|
|
|
253
419
|
export function projectCodexRow(raw) {
|
|
254
420
|
if (raw.type !== "response_item")
|
|
255
421
|
return { rows: [raw] };
|
|
422
|
+
if (raw.phren_item_output !== undefined) {
|
|
423
|
+
// An item's call and result, or a failed script listed with its result.
|
|
424
|
+
// Only the script is source to project; an item's patch text is not.
|
|
425
|
+
const { phren_item_output: output, ...call } = raw, result = object(output);
|
|
426
|
+
const expanded = object(call.payload).name === "exec" ? projectCodexRow(call) : { rows: [call] };
|
|
427
|
+
if (!expanded.base)
|
|
428
|
+
return { rows: [...expanded.rows, result] };
|
|
429
|
+
return { rows: [...expanded.rows, { ...result, payload: { ...object(result.payload), call_id: `${expanded.base}:1` } }] };
|
|
430
|
+
}
|
|
256
431
|
const payload = object(raw.payload), type = String(payload.type), callId = typeof payload.call_id === "string" ? payload.call_id : "";
|
|
257
432
|
if (type === "custom_tool_call" || type === "function_call") {
|
|
258
433
|
const source = codeToolSource(payload.input ?? payload.arguments);
|
|
@@ -9,7 +9,7 @@ import { materializeCodexThread, materializedRoot } from "./codex-threads.js";
|
|
|
9
9
|
import { namedPaths, SHELL_TOOLS, outputCallIds } from "./changes.js";
|
|
10
10
|
import { fanoutChildren } from "./fanouts.js";
|
|
11
11
|
import { claudeChildAgents, visibleClaudeEvent } from "./transcript-claude.js";
|
|
12
|
-
import { childTranscriptBelongsTo, directChildAgents, projectCodexRow, rewriteProjectedOutput, visibleCodexEvent } from "./transcript-codex.js";
|
|
12
|
+
import { childTranscriptBelongsTo, codeModeOutputCall, directChildAgents, findCodeModeCall, projectCodeModeOutput, projectCodexRow, rewriteProjectedOutput, visibleCodexEvent } from "./transcript-codex.js";
|
|
13
13
|
import { visibleCopilotEvent } from "./transcript-copilot.js";
|
|
14
14
|
import { visibleOpencodeEvent } from "./transcript-opencode.js";
|
|
15
15
|
export { isNarration, unwrapPastedContent } from "./transcript-claude.js";
|
|
@@ -285,6 +285,11 @@ export class TranscriptReader {
|
|
|
285
285
|
const { isSidechain: _sidechain, ...own } = raw;
|
|
286
286
|
raw = own;
|
|
287
287
|
}
|
|
288
|
+
// A code-mode script's result follows from the script it answers,
|
|
289
|
+
// a few rows earlier: hidden when its items carry the actions.
|
|
290
|
+
const codeModeCall = raw && this.source === "codex" ? codeModeOutputCall(raw) : undefined;
|
|
291
|
+
if (raw && codeModeCall)
|
|
292
|
+
raw = projectCodeModeOutput(raw, await findCodeModeCall((upper, lower) => index.rows(handle, upper, lower, signal), row.line, codeModeCall));
|
|
288
293
|
if (raw) {
|
|
289
294
|
if (this.changes && this.imageLine === undefined) {
|
|
290
295
|
// A shell call's output carries what it changed on disk. While
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -22096,7 +22096,10 @@ function visibleCodexEvent(raw) {
|
|
|
22096
22096
|
payload: { type: "error", ...typeof p.message === "string" ? { message: p.message } : {} }
|
|
22097
22097
|
};
|
|
22098
22098
|
if (raw.type === "event_msg" && ["token_count", "task_started", "task_complete", "task_completed", "turn_aborted", "task_aborted", "error"].includes(String(p.type))) return raw;
|
|
22099
|
+
if (raw.type === "event_msg" && p.type === "item_completed") return itemCall(raw, object2(p.item));
|
|
22099
22100
|
if (raw.type !== "response_item") return void 0;
|
|
22101
|
+
const wrapper = codeModeWrapper(raw);
|
|
22102
|
+
if (wrapper) return wrapper.images.length ? imageCall(raw, wrapper) : void 0;
|
|
22100
22103
|
if (p.type === "message" && ["user", "assistant"].includes(String(p.role)) && p.channel !== "analysis") {
|
|
22101
22104
|
const text4 = typeof p.content === "string" ? p.content : objects(p.content).map((b) => typeof b.text === "string" ? b.text : "").join("\n");
|
|
22102
22105
|
return p.role === "user" && harnessPreamble(text4) ? void 0 : raw;
|
|
@@ -22104,6 +22107,136 @@ function visibleCodexEvent(raw) {
|
|
|
22104
22107
|
if (["function_call", "custom_tool_call", "function_call_output", "custom_tool_call_output"].includes(String(p.type))) return raw;
|
|
22105
22108
|
return void 0;
|
|
22106
22109
|
}
|
|
22110
|
+
function codeModeWrapper(raw) {
|
|
22111
|
+
const p = object2(raw.payload), source = p.input, callId = p.call_id;
|
|
22112
|
+
if (typeof raw.ordinal !== "number" || raw.type !== "response_item" || p.type !== "custom_tool_call" || p.name !== "exec") return void 0;
|
|
22113
|
+
if (typeof source !== "string" || typeof callId !== "string" || !callId || source.trimStart().startsWith("*** Begin Patch")) return void 0;
|
|
22114
|
+
const tools = [...source.matchAll(WRAPPED_TOOL)].map((match) => match[1]);
|
|
22115
|
+
if (!tools.length || !tools.every((tool) => ITEM_TOOLS.has(tool) || /^mcp__\w+$/.test(tool))) return void 0;
|
|
22116
|
+
const images = [...source.matchAll(VIEW_IMAGE)].map((match) => {
|
|
22117
|
+
const args = callArguments(source, (match.index ?? 0) + match[0].length - 1);
|
|
22118
|
+
return (args === void 0 ? void 0 : argumentString(args, source, ["path"])) ?? "";
|
|
22119
|
+
});
|
|
22120
|
+
return { callId, images };
|
|
22121
|
+
}
|
|
22122
|
+
function imageCall(raw, wrapper) {
|
|
22123
|
+
const file2 = wrapper.images.find(Boolean);
|
|
22124
|
+
return {
|
|
22125
|
+
type: "response_item",
|
|
22126
|
+
...raw.timestamp !== void 0 ? { timestamp: raw.timestamp } : {},
|
|
22127
|
+
payload: { type: "function_call", name: "view_image", call_id: wrapper.callId, arguments: JSON.stringify(file2 ? { path: file2.slice(0, 4096) } : {}) }
|
|
22128
|
+
};
|
|
22129
|
+
}
|
|
22130
|
+
function codeModeOutputCall(raw) {
|
|
22131
|
+
const p = object2(raw.payload);
|
|
22132
|
+
return typeof raw.ordinal === "number" && raw.type === "response_item" && p.type === "custom_tool_call_output" && typeof p.call_id === "string" && p.call_id ? p.call_id : void 0;
|
|
22133
|
+
}
|
|
22134
|
+
function projectCodeModeOutput(raw, call) {
|
|
22135
|
+
const wrapper = call && codeModeWrapper(call);
|
|
22136
|
+
if (!call || !wrapper) return raw;
|
|
22137
|
+
const p = object2(raw.payload), blocks = Array.isArray(p.output) ? objects(p.output) : [];
|
|
22138
|
+
const images = blocks.filter((block) => ["input_image", "image"].includes(String(block.type)));
|
|
22139
|
+
if (wrapper.images.length) return images.length ? { ...raw, payload: { ...p, output: images } } : raw;
|
|
22140
|
+
const text4 = typeof p.output === "string" ? p.output : blocks.map((block) => typeof block.text === "string" ? block.text : "").join("\n");
|
|
22141
|
+
if (/^Script (completed|running)\b/.test(text4)) return void 0;
|
|
22142
|
+
return {
|
|
22143
|
+
type: "response_item",
|
|
22144
|
+
...call.timestamp !== void 0 ? { timestamp: call.timestamp } : {},
|
|
22145
|
+
payload: { type: "custom_tool_call", name: "exec", call_id: wrapper.callId, input: object2(call.payload).input },
|
|
22146
|
+
phren_item_output: raw
|
|
22147
|
+
};
|
|
22148
|
+
}
|
|
22149
|
+
async function findCodeModeCall(rows, line, callId) {
|
|
22150
|
+
const needle = Buffer.from(JSON.stringify(callId));
|
|
22151
|
+
for await (const row of rows(line, Math.max(0, line - 256))) {
|
|
22152
|
+
if (!row.bytes?.includes(needle)) continue;
|
|
22153
|
+
try {
|
|
22154
|
+
const raw = object2(JSON.parse(row.bytes.toString())), p = object2(raw.payload);
|
|
22155
|
+
if (raw.type === "response_item" && p.type === "custom_tool_call" && p.call_id === callId) return raw;
|
|
22156
|
+
} catch {
|
|
22157
|
+
}
|
|
22158
|
+
}
|
|
22159
|
+
return void 0;
|
|
22160
|
+
}
|
|
22161
|
+
function commandText(value2) {
|
|
22162
|
+
if (typeof value2 === "string") return value2;
|
|
22163
|
+
const parts = Array.isArray(value2) ? value2.filter((part) => typeof part === "string") : [];
|
|
22164
|
+
if (parts.length === 3 && ["-lc", "-c"].includes(parts[1]) && /(^|\/)(ba|z|da|fi|k)?sh$/.test(parts[0])) return parts[2];
|
|
22165
|
+
return parts.join(" ");
|
|
22166
|
+
}
|
|
22167
|
+
function localPath(value2) {
|
|
22168
|
+
if (typeof value2 !== "string" || !value2) return void 0;
|
|
22169
|
+
if (value2.startsWith("file://")) {
|
|
22170
|
+
try {
|
|
22171
|
+
const url2 = new URL(value2);
|
|
22172
|
+
if (url2.host) return void 0;
|
|
22173
|
+
const pathname = decodeURIComponent(url2.pathname);
|
|
22174
|
+
return /^\/[A-Za-z]:\//.test(pathname) ? pathname.slice(1) : pathname;
|
|
22175
|
+
} catch {
|
|
22176
|
+
return void 0;
|
|
22177
|
+
}
|
|
22178
|
+
}
|
|
22179
|
+
return value2.startsWith("/") ? value2 : void 0;
|
|
22180
|
+
}
|
|
22181
|
+
function changePatch(changes) {
|
|
22182
|
+
const sections = Object.entries(object2(changes)).slice(0, 50).map(([file2, value2]) => {
|
|
22183
|
+
const change = object2(value2), kind = String(change.type ?? "update");
|
|
22184
|
+
if (kind === "add") {
|
|
22185
|
+
const content = typeof change.content === "string" ? change.content.slice(0, PATCH_FILE).replace(/\n$/, "") : "";
|
|
22186
|
+
return `*** Add File: ${file2}
|
|
22187
|
+
` + content.split("\n").map((line) => "+" + line).join("\n");
|
|
22188
|
+
}
|
|
22189
|
+
if (kind === "delete") return `*** Delete File: ${file2}`;
|
|
22190
|
+
const moved = typeof change.move_path === "string" && change.move_path ? `
|
|
22191
|
+
*** Move to: ${change.move_path}` : "";
|
|
22192
|
+
const diff = typeof change.unified_diff === "string" ? change.unified_diff.slice(0, PATCH_FILE).replace(/\n$/, "") : "";
|
|
22193
|
+
return `*** Update File: ${file2}${moved}${diff ? "\n" + diff : ""}`;
|
|
22194
|
+
});
|
|
22195
|
+
return ["*** Begin Patch", ...sections, "*** End Patch"].join("\n");
|
|
22196
|
+
}
|
|
22197
|
+
function itemCall(raw, item) {
|
|
22198
|
+
const id2 = typeof item.id === "string" && item.id ? item.id.slice(0, 200) : "";
|
|
22199
|
+
if (!id2) return void 0;
|
|
22200
|
+
const stamp = raw.timestamp !== void 0 ? { timestamp: raw.timestamp } : {};
|
|
22201
|
+
const row = (call, output2) => ({
|
|
22202
|
+
type: "response_item",
|
|
22203
|
+
...stamp,
|
|
22204
|
+
payload: { ...call, call_id: id2 },
|
|
22205
|
+
phren_item_output: { type: "response_item", ...stamp, payload: { ...output2, call_id: id2 } }
|
|
22206
|
+
});
|
|
22207
|
+
const status = typeof item.status === "string" ? item.status : "completed";
|
|
22208
|
+
switch (item.type) {
|
|
22209
|
+
case "CommandExecution": {
|
|
22210
|
+
const workdir = localPath(item.cwd);
|
|
22211
|
+
const text4 = [item.aggregated_output, item.formatted_output].find((v) => typeof v === "string") ?? [item.stdout, item.stderr].filter((v) => typeof v === "string").join("");
|
|
22212
|
+
const tail = text4.slice(-OUTPUT_TAIL2);
|
|
22213
|
+
const output2 = typeof item.exit_code === "number" ? JSON.stringify({ output: tail, exit_code: item.exit_code }) : `${tail}${tail && !tail.endsWith("\n") ? "\n" : ""}[${status}]`;
|
|
22214
|
+
return row(
|
|
22215
|
+
{ type: "function_call", name: "exec_command", arguments: JSON.stringify({ cmd: commandText(item.command).slice(0, COMMAND), ...workdir ? { workdir } : {} }) },
|
|
22216
|
+
{ type: "function_call_output", output: output2 }
|
|
22217
|
+
);
|
|
22218
|
+
}
|
|
22219
|
+
case "FileChange": {
|
|
22220
|
+
const said = [status === "completed" ? item.stdout : item.stderr, item.stdout, item.stderr].find((v) => typeof v === "string" && v.trim());
|
|
22221
|
+
return row(
|
|
22222
|
+
{ type: "custom_tool_call", name: "apply_patch", input: changePatch(item.changes) },
|
|
22223
|
+
{ type: "custom_tool_call_output", output: (said ?? status).slice(-OUTPUT_TAIL2) }
|
|
22224
|
+
);
|
|
22225
|
+
}
|
|
22226
|
+
case "McpToolCall": {
|
|
22227
|
+
const result = object2(item.result), ok = object2(result.Ok ?? result), error62 = result.Err ?? item.error;
|
|
22228
|
+
const text4 = objects(ok.content).filter((block) => block.type === "text" && typeof block.text === "string").map((block) => String(block.text)).join("\n");
|
|
22229
|
+
const output2 = text4 || (error62 !== void 0 && error62 !== null ? typeof error62 === "string" ? error62 : JSON.stringify(error62) : status);
|
|
22230
|
+
const args = typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {});
|
|
22231
|
+
return row(
|
|
22232
|
+
{ type: "function_call", name: `mcp__${String(item.server ?? "mcp")}__${String(item.tool ?? "tool")}`, arguments: args.slice(0, 262144) },
|
|
22233
|
+
{ type: "function_call_output", output: output2.slice(0, MCP_OUTPUT) }
|
|
22234
|
+
);
|
|
22235
|
+
}
|
|
22236
|
+
default:
|
|
22237
|
+
return void 0;
|
|
22238
|
+
}
|
|
22239
|
+
}
|
|
22107
22240
|
function unescapeJs(value2) {
|
|
22108
22241
|
return value2.replace(/\\(u\{[0-9a-fA-F]{1,6}\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[\s\S])/g, (_match, escape) => {
|
|
22109
22242
|
if (escape[0] === "u") {
|
|
@@ -22157,16 +22290,19 @@ function callArguments(source, open17) {
|
|
|
22157
22290
|
}
|
|
22158
22291
|
return void 0;
|
|
22159
22292
|
}
|
|
22160
|
-
function
|
|
22293
|
+
function argumentString(expression, source, keys) {
|
|
22161
22294
|
const inline = resolveString(expression, source);
|
|
22162
22295
|
if (inline !== void 0) return inline;
|
|
22163
22296
|
const inner = /^\{([\s\S]*)\}$/.exec(expression.trim())?.[1];
|
|
22164
22297
|
if (inner === void 0) return void 0;
|
|
22165
22298
|
const body2 = inner.trim();
|
|
22166
22299
|
if (/^[A-Za-z_$][\w$]*$/.test(body2)) return resolveString(body2, source);
|
|
22167
|
-
const property =
|
|
22300
|
+
const property = new RegExp(`(?:^|[,{])\\s*(?:${keys.join("|")})\\s*:\\s*("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|[A-Za-z_$][\\w$]*)`).exec(body2);
|
|
22168
22301
|
return property ? resolveString(property[1], source) : void 0;
|
|
22169
22302
|
}
|
|
22303
|
+
function shellCommand(expression, source) {
|
|
22304
|
+
return argumentString(expression, source, ["command", "cmd"]);
|
|
22305
|
+
}
|
|
22170
22306
|
function codeToolCalls(source) {
|
|
22171
22307
|
const calls = [], original = source.slice(0, 262144);
|
|
22172
22308
|
for (const match of source.matchAll(CODE_TOOL_CALL)) {
|
|
@@ -22216,6 +22352,12 @@ function renameProjectedChanges(raw, base) {
|
|
|
22216
22352
|
}
|
|
22217
22353
|
function projectCodexRow(raw) {
|
|
22218
22354
|
if (raw.type !== "response_item") return { rows: [raw] };
|
|
22355
|
+
if (raw.phren_item_output !== void 0) {
|
|
22356
|
+
const { phren_item_output: output2, ...call } = raw, result = object2(output2);
|
|
22357
|
+
const expanded = object2(call.payload).name === "exec" ? projectCodexRow(call) : { rows: [call] };
|
|
22358
|
+
if (!expanded.base) return { rows: [...expanded.rows, result] };
|
|
22359
|
+
return { rows: [...expanded.rows, { ...result, payload: { ...object2(result.payload), call_id: `${expanded.base}:1` } }] };
|
|
22360
|
+
}
|
|
22219
22361
|
const payload = object2(raw.payload), type = String(payload.type), callId = typeof payload.call_id === "string" ? payload.call_id : "";
|
|
22220
22362
|
if (type === "custom_tool_call" || type === "function_call") {
|
|
22221
22363
|
const source = codeToolSource(payload.input ?? payload.arguments);
|
|
@@ -22242,7 +22384,7 @@ function rewriteProjectedOutput(entries2, base) {
|
|
|
22242
22384
|
entry.raw = { ...renameProjectedChanges(entry.raw, base), payload: { ...payload, call_id: `${base}:1` } };
|
|
22243
22385
|
}
|
|
22244
22386
|
}
|
|
22245
|
-
var childRelationCache, CODE_TOOL_CALL, JS_ESCAPES, projectedCodeCalls;
|
|
22387
|
+
var childRelationCache, OUTPUT_TAIL2, MCP_OUTPUT, PATCH_FILE, COMMAND, WRAPPED_TOOL, VIEW_IMAGE, ITEM_TOOLS, CODE_TOOL_CALL, JS_ESCAPES, projectedCodeCalls;
|
|
22246
22388
|
var init_transcript_codex = __esm({
|
|
22247
22389
|
"src/bridge/transcript-codex.ts"() {
|
|
22248
22390
|
"use strict";
|
|
@@ -22250,6 +22392,13 @@ var init_transcript_codex = __esm({
|
|
|
22250
22392
|
init_fanouts();
|
|
22251
22393
|
init_transcript_claude();
|
|
22252
22394
|
childRelationCache = /* @__PURE__ */ new Map();
|
|
22395
|
+
OUTPUT_TAIL2 = 4e3;
|
|
22396
|
+
MCP_OUTPUT = 65536;
|
|
22397
|
+
PATCH_FILE = 2e5;
|
|
22398
|
+
COMMAND = 16384;
|
|
22399
|
+
WRAPPED_TOOL = /\btools\s*\.\s*([A-Za-z_$][\w$]*)\s*\(/g;
|
|
22400
|
+
VIEW_IMAGE = /\btools\s*\.\s*view_image\s*\(/g;
|
|
22401
|
+
ITEM_TOOLS = /* @__PURE__ */ new Set(["exec_command", "write_stdin", "apply_patch", "view_image"]);
|
|
22253
22402
|
CODE_TOOL_CALL = /\btools\s*\.\s*(apply_patch|shell|read)\s*\(/g;
|
|
22254
22403
|
JS_ESCAPES = { n: "\n", r: "\r", t: " ", b: "\b", f: "\f", v: "\v", "0": "\0", "'": "'", '"': '"', "\\": "\\", "/": "/" };
|
|
22255
22404
|
projectedCodeCalls = /* @__PURE__ */ new Set();
|
|
@@ -22585,6 +22734,8 @@ var init_transcripts = __esm({
|
|
|
22585
22734
|
const { isSidechain: _sidechain, ...own2 } = raw;
|
|
22586
22735
|
raw = own2;
|
|
22587
22736
|
}
|
|
22737
|
+
const codeModeCall = raw && this.source === "codex" ? codeModeOutputCall(raw) : void 0;
|
|
22738
|
+
if (raw && codeModeCall) raw = projectCodeModeOutput(raw, await findCodeModeCall((upper, lower2) => index2.rows(handle, upper, lower2, signal), row.line, codeModeCall));
|
|
22588
22739
|
if (raw) {
|
|
22589
22740
|
if (this.changes && this.imageLine === void 0) {
|
|
22590
22741
|
const ids = outputCallIds(raw, this.source);
|
|
@@ -28317,7 +28468,7 @@ var init_package_metadata = __esm({
|
|
|
28317
28468
|
__dirname = path24.dirname(fileURLToPath2(import.meta.url));
|
|
28318
28469
|
ROOT = path24.join(__dirname, "..");
|
|
28319
28470
|
PACKAGE_JSON_PATH = path24.join(ROOT, "package.json");
|
|
28320
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
28471
|
+
BUNDLED_VERSION = true ? "0.3.10" : "0.0.0";
|
|
28321
28472
|
PACKAGE_JSON = readPackageJson();
|
|
28322
28473
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
28323
28474
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -32704,7 +32855,7 @@ function choiceKey(value2) {
|
|
|
32704
32855
|
if (text4 === "up" || text4 === "down" || text4 === "tab") return text4[0].toUpperCase() + text4.slice(1);
|
|
32705
32856
|
return choiceKeys.has(text4) ? text4 : void 0;
|
|
32706
32857
|
}
|
|
32707
|
-
function
|
|
32858
|
+
function commandText2(value2) {
|
|
32708
32859
|
if (typeof value2 === "string" && value2.trim()) return value2.trim();
|
|
32709
32860
|
if (Array.isArray(value2)) {
|
|
32710
32861
|
const parts = value2.filter((part) => typeof part === "string" && !!part.trim());
|
|
@@ -32853,7 +33004,7 @@ function numberedDialog(text4) {
|
|
|
32853
33004
|
return { title: title.slice(0, 4e3), options: options.slice(0, 12) };
|
|
32854
33005
|
}
|
|
32855
33006
|
function terminalChoice(input2) {
|
|
32856
|
-
const fields = object2(input2), command =
|
|
33007
|
+
const fields = object2(input2), command = commandText2(fields.command ?? fields.cmd);
|
|
32857
33008
|
let options = [fields.options, fields.choices, fields.actions, fields.answers].map(structuredOptions).find((list) => list.length >= 2) ?? [];
|
|
32858
33009
|
if (options.length < 2) {
|
|
32859
33010
|
const text4 = [fields.question, fields.description, fields.justification, fields.prompt, fields.message, fields.text, fields.content, fields.display].filter((value2) => typeof value2 === "string").join("\n");
|
|
@@ -32878,7 +33029,7 @@ function permissionTitle(tool, input2) {
|
|
|
32878
33029
|
function samePermission(choice, title, tool, input2) {
|
|
32879
33030
|
const text4 = choice.title?.toLowerCase() ?? "";
|
|
32880
33031
|
if (title && text4.includes(title.toLowerCase())) return true;
|
|
32881
|
-
const command =
|
|
33032
|
+
const command = commandText2(object2(input2).command ?? object2(input2).cmd);
|
|
32882
33033
|
if (command && text4.includes(command.toLowerCase())) return true;
|
|
32883
33034
|
const name = tool.split("__").pop();
|
|
32884
33035
|
return !!name && name !== "action" && text4.includes(name.toLowerCase());
|
|
@@ -48768,7 +48919,7 @@ var launchKinds = ["codex", "claude", "copilot", "opencode"];
|
|
|
48768
48919
|
var plainText = (max) => external_exports.string().min(1).max(max).refine((t) => !/[\x00-\x1f\x7f]/.test(t));
|
|
48769
48920
|
async function conductorBrief() {
|
|
48770
48921
|
let source;
|
|
48771
|
-
if (true) source = "---\nname: conductor\ndescription: Coordinate independent Phren tasks across every project in the store and every enrolled computer, supervise their local agent fanout, and integrate verified returns in a concise dispatcher voice.\n---\n\n# Conductor\n\nYou are the owner's dispatcher for the whole store, not one project. You start\nin the phren store itself; that folder is not a project and not your work.\n\nFirst, before trusting your tools, check which phren you are running:\n`phren --version` and `command -v phren`. If the version is older than the one\nthe store or the owner expects, or the path is not the install you expect (a\nstale global package, an old checkout), tell the owner in one line and say\nwhich tools may be missing or behave differently.\n\nThen read the relevant projects' summaries and Phren tasks\n(`get_project_summary`, `get_tasks`) before selecting work.\n\nYour tools, use these instead of exploring the CLI or the Hook's files:\n\n- `live_sessions` (CLI `phren dispatch sessions`): every live agent on this\n computer and each enrolled one, with project, harness, status, `idleFor`\n (seconds since it last changed) and the target `hand_off` takes. Start here\n when asked what is running. Computers it could not reach are listed; say so\n rather than guessing. Computers in `notLinked` are registered in the store\n but have no Hook link here: say they were not checked, never that nothing is\n running there.\n- `hand_off`: send a prompt to one of those sessions.\n- `dispatch`: start a new worker on a computer (or `anywhere`).\n- `dispatch_returns` (CLI `phren dispatch returns`): what your workers sent\n back since you last asked: done with the final reply, needs-you with the\n question, failed with the error (a usage limit), blocked, or gone. Reading them marks them read. In core use\n `phren_admin(action: \"dispatch_returns\")`.\n- `phren dispatch status`: receipts of what you dispatched.\n- `get_tasks`, `get_project_summary`, `search_knowledge`: the store's memory.\n\nKeep engineering detail in worker briefs, Phren tasks and findings, and review\nartifacts, not in the owner's chat.\n\n## Voice and pace\n\nThe owner talks to you from the phone, often in talk mode, where your replies\nare read aloud in their voice. Sound like a good dispatcher: short, quick and\nconversational.\n\n- Lead with the outcome in one sentence. Keep the whole reply to one to four\n short sentences unless the owner asks for detail.\n- No tables, file paths, SHAs, PR numbers or run IDs in a reply unless the\n owner asks for them. Record them in Phren tasks and findings instead.\n- One short line per dispatch or return: who, what, result. A routine watcher\n or monitor event where nothing changed gets silence or a single line.\n- When the owner gives you a task, dispatch an engineer for it right away and\n say so in one line. That is the owner's standing rule; do not ask first.\n- Ask at most one question at a time, and name the options.\n- Delegate reading and analysis to workers instead of running long\n investigations yourself, so your own turns stay fast.\n- A message that begins with `[voice]` was spoken in talk mode, and your reply\n will be read aloud. Answer in one or two spoken sentences with no markdown,\n lists, symbols or code, written to sound natural read aloud: \"back in about\n twenty minutes\", not \"ETA ~20m\".\n\n```text\nLinuxbox has the parser checks on Codex, back around two twenty.\nDesk finished the navigation checks: tests passed, not merged yet.\n```\n\nIf a result or return time is unknown, say so. Surface a worker's question in\nthe same short voice, with the worker's own choices.\n\n## Dispatching\n\nPick five to ten independent tasks when that many are available and capacity\npermits. Do not manufacture tasks to fill the batch. Separate dependencies and\nfile ownership; give each remote lead a base revision, acceptance checks, local\nfanout limit, report time and integration instructions. Every brief repeats the\nowner's repository constraints, including any prohibition on commits, pushes,\nbranches or particular tests. Dispatch never expands the owner's authorization.\n\nYou are the one conductor for this computer and every computer linked with\nit; a second conductor in the group is refused at launch. Conductors on\ncomputers that are not linked share only the store, so claim a task before you\ndispatch it: `claim_task` (in core, `manage_task` with `action: \"claim\"`).\nSkip tasks marked `[claimed: <computer>]` by another computer. A claim that\ncomes back not claimed, with `heldBy`, means another conductor got there first:\nmove on. Completing a task clears its claim; release one you will not do. Start\nworkers with `dispatch` or `hand_off`, never as tabs in your own Herdr\nworkspace. When a computer shows up in `notLinked`, tell the owner that\n`phren bridge link <host>` can link it; never link a computer yourself.\n\nPrefer Codex. Use OpenCode Go when its account and harness are connected. Use\nOpenRouter only when the owner explicitly requests it; an unavailable account\ndoes not authorize another paid provider. Name an explicit model when instructed,\notherwise use and report the remote configured default. Each remote lead owns\nits local checkouts, fanout and provider rate limits. Where installed, local\nworkers use the fanout wrapper's `scripts/run.sh --provider codex|opencode\n--label --worktree [--model] [--mode]` contract and parent-bound manifests.\n\nPrefer handing work to a session that already owns the project and is idle or\ndoing related work; call `hand_off` in full or `phren_admin(action: \"hand_off\",\ncomputer?, target|session, text)` in core. Otherwise dispatch a new worker.\nWrite one short line either way. Call `dispatch` in full or\n`phren_admin(action: \"dispatch\", computer, project, harness, model?, prompt, label)`\nin core. The CLI equivalent is `phren dispatch <computer|anywhere> <project>\n--harness <harness> --label <label> --prompt <brief> [--model <model>]`.\n`anywhere` chooses the connected computer with the fewest working agents. Place\nbriefs sequentially, respecting busy/rate-limit responses. Keep their dispatch\nIDs. Do not send local filesystem paths as remote project names.\n\n`accepted` on a receipt is prompt acceptance, not worker completion. Returns\narrive on their own: the Hook follows every worker you dispatch, and when you\nare idle it types one line into this session, such as `Return: Linuxbox parser\nchecks done, tests passed (dispatch <id>). Call dispatch_returns.` When you see\none, call `dispatch_returns` and report each return in one short line. You may\nalso call it whenever you want the current state; do not poll it in a loop, and\ndo not read remote transcripts by hand to learn whether a worker finished. Tell\nthe owner a return time as an expectation, not a promise.\n\nFor a `needs-you` return, surface the worker's question in the owner's chat\nwith its choices as the worker wrote them; do not rewrite or answer it for the\nowner unless the owner already decided. Send the answer back with `hand_off`\nto the row's `target`. A `blocked` worker waits on terminal input, such as a\npermission prompt: say so and point the owner to the phone or the terminal. A\n`gone` worker's pane closed or was taken over: say so, and decide with the\nowner before giving its work to another agent. A `done` reply is the worker's\nown account; check its evidence before saying tests passed or work merged.\n\nAn uncertain delivery is never retried automatically. Inspect its known target\nor status before deciding with the owner whether a replacement is needed. Keep\nunavailable workers visible instead of giving their work to another agent\nwhile the original may still be running.\n\nIntegrate returned changes in dependency order within the owner's allowed\nworkflow. Run a cleanup pass across the combined result and the affected checks.\nRequire evidence before saying tests passed or merged. Ship only within existing\nauthorization; if publication is not authorized, return the reviewable result.\nUpdate Phren tasks when verified complete and save durable decisions. A worker's\nfinished turn alone does not complete the owner's task.\n";
|
|
48922
|
+
if (true) source = "---\nname: conductor\ndescription: Coordinate independent Phren tasks across every project in the store and every enrolled computer, supervise their local agent fanout, and integrate verified returns in a concise dispatcher voice.\n---\n\n# Conductor\n\nYou are the owner's dispatcher for the whole store, not one project. You start\nin the phren store itself; that folder is not a project and not your work.\n\nFirst, before trusting your tools, check which phren you are running:\n`phren --version` and `command -v phren`. If the version is older than the one\nthe store or the owner expects, or the path is not the install you expect (a\nstale global package, an old checkout), tell the owner in one line and say\nwhich tools may be missing or behave differently.\n\nThen read the relevant projects' summaries and Phren tasks\n(`get_project_summary`, `get_tasks`) before selecting work.\n\nYour tools, use these instead of exploring the CLI or the Hook's files:\n\n- `live_sessions` (CLI `phren dispatch sessions`): every live agent on this\n computer and each enrolled one, with project, harness, status, `idleFor`\n (seconds since it last changed) and the target `hand_off` takes. Start here\n when asked what is running. Computers it could not reach are listed; say so\n rather than guessing. Computers in `notLinked` are registered in the store\n but have no Hook link here: say they were not checked, never that nothing is\n running there.\n- `hand_off`: send a prompt to one of those sessions.\n- `dispatch`: start a new worker on a computer (or `anywhere`).\n- `dispatch_returns` (CLI `phren dispatch returns`): what your workers sent\n back since you last asked: done with the final reply, needs-you with the\n question, failed with the error (a usage limit), blocked, or gone. Reading them marks them read. In core use\n `phren_admin(action: \"dispatch_returns\")`.\n- `phren dispatch status`: receipts of what you dispatched.\n- `get_tasks`, `get_project_summary`, `search_knowledge`: the store's memory.\n\nKeep engineering detail in worker briefs, Phren tasks and findings, and review\nartifacts, not in the owner's chat.\n\n## Voice and pace\n\nThe owner talks to you from the phone, often in talk mode, where your replies\nare read aloud in their voice. Sound like a good dispatcher: short, quick and\nconversational.\n\n- Lead with the outcome in one sentence. Keep the whole reply to one to four\n short sentences unless the owner asks for detail.\n- No tables, file paths, SHAs, PR numbers or run IDs in a reply unless the\n owner asks for them. Record them in Phren tasks and findings instead.\n- One short line per dispatch or return: who, what, result. A routine watcher\n or monitor event where nothing changed gets silence or a single line.\n- When the owner gives you a task, dispatch an engineer for it right away and\n say so in one line. That is the owner's standing rule; do not ask first.\n- Ask at most one question at a time, and name the options.\n- Delegate reading and analysis to workers instead of running long\n investigations yourself, so your own turns stay fast.\n- A message that begins with `[voice]` was spoken in talk mode, and your reply\n will be read aloud. Answer in one or two spoken sentences with no markdown,\n lists, symbols or code, written to sound natural read aloud: \"back in about\n twenty minutes\", not \"ETA ~20m\".\n\n```text\nLinuxbox has the parser checks on Codex, back around two twenty.\nDesk finished the navigation checks: tests passed, not merged yet.\n```\n\nIf a result or return time is unknown, say so. Surface a worker's question in\nthe same short voice, with the worker's own choices.\n\n## Dispatching\n\nPick five to ten independent tasks when that many are available and capacity\npermits. Do not manufacture tasks to fill the batch. Separate dependencies and\nfile ownership; give each remote lead a base revision, acceptance checks, local\nfanout limit, report time and integration instructions. Every brief repeats the\nowner's repository constraints, including any prohibition on commits, pushes,\nbranches or particular tests. Dispatch never expands the owner's authorization.\n\nYou are the one conductor for this computer and every computer linked with\nit; a second conductor in the group is refused at launch. Conductors on\ncomputers that are not linked share only the store, so claim a task before you\ndispatch it: `claim_task` (in core, `manage_task` with `action: \"claim\"`).\nSkip tasks marked `[claimed: <computer>]` by another computer. A claim that\ncomes back not claimed, with `heldBy`, means another conductor got there first:\nmove on. Completing a task clears its claim; release one you will not do. Start\nworkers with `dispatch` or `hand_off`, never as tabs in your own Herdr\nworkspace. When a computer shows up in `notLinked`, tell the owner that\n`phren bridge link <host>` can link it; never link a computer yourself.\n\nPrefer Codex. Use OpenCode Go when its account and harness are connected. Use\nOpenRouter only when the owner explicitly requests it; an unavailable account\ndoes not authorize another paid provider. Name an explicit model when instructed,\notherwise use and report the remote configured default. Each remote lead owns\nits local checkouts, fanout and provider rate limits. Where installed, local\nworkers use the fanout wrapper's `scripts/run.sh --provider codex|opencode\n--label --worktree [--model] [--mode]` contract and parent-bound manifests.\nTell every lead the same: a worker started any other way (its own `opencode\nrun` or `codex exec`, a launch script, nohup) has no manifest, so the phone and\nyou cannot see, resume or review it. Workers that exist only as processes do\nnot count as dispatched.\n\nPrefer handing work to a session that already owns the project and is idle or\ndoing related work; call `hand_off` in full or `phren_admin(action: \"hand_off\",\ncomputer?, target|session, text)` in core. Otherwise dispatch a new worker.\nWrite one short line either way. Call `dispatch` in full or\n`phren_admin(action: \"dispatch\", computer, project, harness, model?, prompt, label)`\nin core. The CLI equivalent is `phren dispatch <computer|anywhere> <project>\n--harness <harness> --label <label> --prompt <brief> [--model <model>]`.\n`anywhere` chooses the connected computer with the fewest working agents. Place\nbriefs sequentially, respecting busy/rate-limit responses. Keep their dispatch\nIDs. Do not send local filesystem paths as remote project names.\n\n`accepted` on a receipt is prompt acceptance, not worker completion. Returns\narrive on their own: the Hook follows every worker you dispatch, and when you\nare idle it types one line into this session, such as `Return: Linuxbox parser\nchecks done, tests passed (dispatch <id>). Call dispatch_returns.` When you see\none, call `dispatch_returns` and report each return in one short line. You may\nalso call it whenever you want the current state; do not poll it in a loop, and\ndo not read remote transcripts by hand to learn whether a worker finished. Tell\nthe owner a return time as an expectation, not a promise.\n\nFor a `needs-you` return, surface the worker's question in the owner's chat\nwith its choices as the worker wrote them; do not rewrite or answer it for the\nowner unless the owner already decided. Send the answer back with `hand_off`\nto the row's `target`. A `blocked` worker waits on terminal input, such as a\npermission prompt: say so and point the owner to the phone or the terminal. A\n`gone` worker's pane closed or was taken over: say so, and decide with the\nowner before giving its work to another agent. A `done` reply is the worker's\nown account; check its evidence before saying tests passed or work merged.\n\nAn uncertain delivery is never retried automatically. Inspect its known target\nor status before deciding with the owner whether a replacement is needed. Keep\nunavailable workers visible instead of giving their work to another agent\nwhile the original may still be running.\n\nIntegrate returned changes in dependency order within the owner's allowed\nworkflow. Run a cleanup pass across the combined result and the affected checks.\nRequire evidence before saying tests passed or merged. Ship only within existing\nauthorization; if publication is not authorized, return the reviewable result.\nUpdate Phren tasks when verified complete and save durable decisions. A worker's\nfinished turn alone does not complete the owner's task.\n";
|
|
48772
48923
|
else {
|
|
48773
48924
|
const here = path82.dirname(fileURLToPath(import.meta.url));
|
|
48774
48925
|
for (const candidate of [
|
|
@@ -50795,7 +50946,7 @@ async function readSecret(prompt) {
|
|
|
50795
50946
|
// src/bridge/hook-main.ts
|
|
50796
50947
|
init_utils_helpers();
|
|
50797
50948
|
Object.assign(process.env, nonInteractiveGitEnv());
|
|
50798
|
-
runBridge(process.argv.slice(2), "0.3.
|
|
50949
|
+
runBridge(process.argv.slice(2), "0.3.10").then((code) => {
|
|
50799
50950
|
process.exitCode = code;
|
|
50800
50951
|
}).catch((error62) => {
|
|
50801
50952
|
console.error(error62 instanceof Error ? error62.message : "Phren Hook failed.");
|
package/package.json
CHANGED
|
@@ -95,6 +95,10 @@ otherwise use and report the remote configured default. Each remote lead owns
|
|
|
95
95
|
its local checkouts, fanout and provider rate limits. Where installed, local
|
|
96
96
|
workers use the fanout wrapper's `scripts/run.sh --provider codex|opencode
|
|
97
97
|
--label --worktree [--model] [--mode]` contract and parent-bound manifests.
|
|
98
|
+
Tell every lead the same: a worker started any other way (its own `opencode
|
|
99
|
+
run` or `codex exec`, a launch script, nohup) has no manifest, so the phone and
|
|
100
|
+
you cannot see, resume or review it. Workers that exist only as processes do
|
|
101
|
+
not count as dispatched.
|
|
98
102
|
|
|
99
103
|
Prefer handing work to a session that already owns the project and is idle or
|
|
100
104
|
doing related work; call `hand_off` in full or `phren_admin(action: "hand_off",
|
|
@@ -8,6 +8,12 @@ Give each writer a separate worktree and a concrete output to validate. A brief
|
|
|
8
8
|
should name the goal, owned files, constraints, tests, and completion report.
|
|
9
9
|
Include relevant findings and exact review issues; avoid sending the whole chat.
|
|
10
10
|
|
|
11
|
+
Start every worker through `phren fanout run`, never with `opencode run`,
|
|
12
|
+
`codex exec` or `claude -p` of your own (directly, in a loop, or from a script
|
|
13
|
+
with nohup). `phren fanout run` writes the job manifest that ties the worker to
|
|
14
|
+
your conversation; a worker without one is invisible to the phone, the
|
|
15
|
+
conductor and `phren fanout list`, and nothing can resume, review or archive it.
|
|
16
|
+
|
|
11
17
|
Enable Hook and fanout, then use `phren fanout run --tier narrow|wide|review
|
|
12
18
|
--label LABEL --worktree PATH < brief.txt`. The command chooses an eligible
|
|
13
19
|
provider using current usage, errors and concurrency. Use `phren fanout usage`
|