Official
codex
Codex agent provider: runs the Codex CLI's app-server for each account.
The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/codex@0.2.4
Permissions in 0.2.4
Files
items.ts2.3 KB
// Additional native display items use the same rows in live events and history.
import * as z from "zod";
import type { Item } from "./wire.ts";
import type { ToolCall, ToolContent } from "./types.ts";
export function referencedImage(fileId: unknown): ToolContent[] {
return typeof fileId === "string" ? [{ type: "text", text: `Image attachment: ${fileId}. This image is unavailable in this client.` }] : [];
}
export function itemNotice(item: Item): string | null {
if (item.type === "hookPrompt") {
const fragments = z.array(z.object({ text: z.string(), hookRunId: z.string() })).parse(item.fragments);
return fragments.map((fragment) => fragment.text).join("\n\n");
}
if (item.type === "enteredReviewMode") return `Entered review mode: ${String(item.review ?? "")}`;
if (item.type === "exitedReviewMode") return String(item.review ?? "") || "Exited review mode.";
return null;
}
const outputPart = z.looseObject({ type: z.string(), text: z.string().optional(), image_url: z.string().optional(), file_id: z.string().optional() });
function outputContent(output: unknown): ToolContent[] {
if (typeof output === "string") return [{ type: "text", text: output }];
return z.array(outputPart).parse(output).flatMap((part): ToolContent[] => {
if (part.type === "input_text") return [{ type: "text", text: part.text ?? "" }];
if (part.type === "input_image") {
if (part.file_id) return referencedImage(part.file_id);
const match = /^data:([^;]+);base64,(.*)$/s.exec(part.image_url ?? "");
return match ? [{ type: "image", mimeType: match[1]!, data: match[2]! }] : [{ type: "text", text: part.image_url ?? "" }];
}
return part.type === "input_audio" ? [{ type: "text", text: "Codex returned audio output, which tool rows cannot play." }] : [];
});
}
export function extraTool(item: Item): ToolCall | null {
if (item.type === "sleep") return {
id: item.id ?? "", name: "clock.sleep", kind: "other", title: `Sleep for ${Number(item.durationMs) / 1000} seconds`,
status: "completed", input: { durationMs: item.durationMs }, content: [], locations: [],
};
if (item.type !== "functionCallOutput") return null;
const name = [item.namespace, item.name].filter(Boolean).join(".");
return { id: item.id ?? "", name, kind: "other", title: name, status: "completed", input: null, content: outputContent(item.output), locations: [] };
}
No comments yet.