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.3
Permissions in 0.2.3
Files
children.ts2.5 KB
// What the Codex provider keeps about a subagent: its task, filled from its
// spawn call and its own thread record.
import type * as wire from "./wire.ts";
import type { Child, Facts } from "./types.ts";
import * as map from "./map.ts";
/// Moves a subagent's task to `status`, stamping the end of its work.
/// Returns whether anything changed.
export function setStatus(child: Child, status: import("divergence/protocol").TaskStatus) {
if (child.task.status === status) return false;
child.task.status = status;
if (map.isLive(status)) {
delete child.task.endedAt;
} else {
delete child.task.activity;
child.task.endedAt = new Date().toISOString();
}
return true;
}
/// The thread that started a subagent.
export function parentOf(child: Child) {
return child.task.parentTaskId ?? child.root;
}
/// What a subagent's own thread record says about it.
export function factsOfThread(thread: wire.Thread | null | undefined): Facts {
const created =
typeof thread?.createdAt === "number" && thread.createdAt > 0 ? map.timestamp(thread.createdAt) : null;
return {
prompt: typeof thread?.preview === "string" && thread.preview.trim() ? thread.preview : null,
taskName: map.threadTaskName(thread),
name: map.threadNickname(thread) ?? map.threadRole(thread),
model: typeof thread?.model === "string" ? thread.model : null,
effort: typeof thread?.reasoningEffort === "string" ? thread.reasoningEffort : null,
startedAt: created,
};
}
/// Adds what is known about a subagent to its snapshot. Every field fills
/// only what the snapshot does not have yet, except the name, which a
/// later `thread/started` knows better than a spawn path.
export function applyFacts(facts: Facts, child: Child) {
const task = child.task;
const fill = (key: "toolCallId" | "prompt" | "model" | "effort", value: string | null | undefined) => {
if ((task[key] === undefined || task[key] === null) && typeof value === "string" && value) task[key] = value;
};
fill("toolCallId", facts.toolCallId);
fill("prompt", facts.prompt);
fill("model", facts.model);
fill("effort", facts.effort);
if (!child.taskName && typeof facts.taskName === "string" && facts.taskName) child.taskName = facts.taskName;
if (typeof facts.name === "string" && facts.name) task.name = facts.name;
if (facts.startedAt) {
task.startedAt =
task.startedAt && Date.parse(task.startedAt) <= Date.parse(facts.startedAt) ? task.startedAt : facts.startedAt;
}
task.title = map.taskTitle(task.prompt ?? null, child.taskName, task.name ?? null);
}
No comments yet.