Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/codex-pi-coordination/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codex-pi-coordination",
"version": "0.1.1",
"version": "0.2.0",
"description": "Coordinate bounded implementation, research, review and validation tasks between Codex and Pi inside NVIDIA OpenShell.",
"author": {
"name": "Fakoli",
Expand Down
34 changes: 28 additions & 6 deletions plugins/codex-pi-coordination/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,29 @@ native Pi extension returns work; a stdlib runner records actual checks, source
changes and managed cleanup. Model selection is explicit and provider-neutral,
including configured GLM routes.

From the plugin directory, with an existing private runtime profile:
From the plugin directory, register an existing private runtime profile once,
then use the default for discovery and runs. Paths below are synthetic examples:

```sh
python3 scripts/coordinate.py configure --profile /path/to/private/profile.json
python3 scripts/coordinate.py capabilities --output /private/evidence/new-capabilities
python3 scripts/coordinate.py run task.json --output /private/evidence/new-run
```

`configure` validates and registers `~/.config/codex-pi-coordination/profile.json`.
Identical settings are a no-op; conflicting defaults and symlinks refuse. It
does not copy credentials or qualify the runtime. `capabilities` uses the owned
disposable sandbox with zero prompts, tools or extensions, returning available
provider/model IDs and the current runtime model's supported thinking levels.
It reports actual idle settings without applying profile model/thinking defaults.

Version-2 tasks may add `run_options`: an exact `provider`/`model` pair,
`thinking` alone, or both. Omitted options inherit the profile. `auto`, `dynamic`
and the literal `default` are refused; use omission for Default. Unsupported or
silently clamped selections fail before the task prompt, without fallback.
Version-1 task inputs remain readable. All new runs use bounded native RPC with
`--no-session`; saved-session continuation remains future work (P1b).

See the [skill](skills/codex-pi-coordination/SKILL.md) and
[task/profile contract](skills/codex-pi-coordination/references/task-contract.md).
Codex discovers the skill through the marketplace entry. The Pi package exposes
Expand All @@ -21,12 +38,17 @@ The extension provides `coordination_status`, `coordination_handoff` and
`/coordination-status`. File tools stay inside the assigned workspace, writes
name exact files, and tool/turn budgets stop further work. Declared verification
argv runs after Pi exits. Task policy is not an OS sandbox: OpenShell remains
the isolation and lifecycle owner. No background service, recursive Codex launch,
provider change or automatic patch application is installed.
the isolation and lifecycle owner. Selection is confined to the ephemeral Pi
child; global provider/model settings stay unchanged. No background service,
recursive Codex launch or automatic patch application is installed.

`delivery_valid` means a bounded handoff completed, not application acceptance,
latency qualification or deployment authority. Keep failed runs and actual
operator profiles/evidence outside public plugin source.
Inspect `rpc-configuration.json` and the worker receipt's `configuration` with
the existing changes/check evidence. They bind requested, inherited and
effective options, prompt admission, settlement and shutdown. `delivery_valid`
means a bounded handoff completed, not application acceptance, latency
qualification or deployment authority. `capabilities_valid` covers metadata
discovery and cleanup only. Keep failed runs and actual operator profiles and
evidence outside public plugin source.

On execution failure, nonzero worker exit or timeout, the runner immediately
enters managed OpenShell cleanup: verify identity, stop and record the readback.
Expand Down
43 changes: 39 additions & 4 deletions plugins/codex-pi-coordination/extensions/coordination.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,27 @@ export function loadTask(taskPath, cwd) {
fs.closeSync(descriptor);
}
const task = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(raw));
if (!task || typeof task !== "object" || Array.isArray(task) || task.version !== 1 || !taskKinds.has(task.kind)) {
fail("invalid_task", "Expected a version 1 coordination task and supported kind");
if (!task || typeof task !== "object" || Array.isArray(task) || ![1, 2].includes(task.version) || !taskKinds.has(task.kind)) {
fail("invalid_task", "Expected a supported versioned coordination task and kind");
}
for (const key of ["run_id", "task_id"]) {
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(boundedString(task[key], key, 128))) fail("invalid_task", `Invalid ${key}`);
const pattern = key === "task_id" && task.version === 1
? /^[A-Za-z0-9][A-Za-z0-9_.-]{0,79}$/
: /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
const value = boundedString(task[key], key, 128);
if (pattern.exec(value)?.[0] !== value) fail("invalid_task", `Invalid ${key}`);
}
if (task.version === 1 && "run_options" in task) fail("invalid_task", "Version 1 cannot contain run_options");
if (task.version === 2) {
const options = task.run_options;
const levels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
const identifierPattern = "[A-Za-z0-9][A-Za-z0-9_.:/-]{0,255}";
const matchesIdentifier = (value, pattern) => typeof value === "string" && !value.includes("://") && new RegExp(`^${pattern}$`).exec(value)?.[0] === value;
const identifier = (value) => matchesIdentifier(value, identifierPattern);
// Each component may contain slashes; only the exact runtime catalog picks a pair.
const qualifiedDefault = (value) => matchesIdentifier(value, `${identifierPattern}/${identifierPattern}`);
if (!options || typeof options !== "object" || Array.isArray(options) || Object.keys(options).some((key) => !["provider", "model", "thinking"].includes(key)) || (("provider" in options) !== ("model" in options)) || ("provider" in options && (!identifier(options.provider) || !identifier(options.model))) || ("thinking" in options && !levels.includes(options.thinking))) fail("invalid_task", "Invalid version 2 run options");
if (task.operation !== "run" || !task.runtime_defaults || Object.keys(task.runtime_defaults).sort().join(",") !== "model,thinking" || !qualifiedDefault(task.runtime_defaults.model) || !levels.includes(task.runtime_defaults.thinking)) fail("invalid_task", "Invalid version 2 runtime defaults");
}
boundedString(task.instructions, "instructions", 48000);
for (const key of ["workspace", "output_directory"]) {
Expand Down Expand Up @@ -141,6 +157,7 @@ export default function coordinationExtension(pi) {
let toolCalls = 0;
let turns = 0;
let handedOff = false;
let configurationRecorded = false;
const requested = () => pi.getFlag("coordination-task");
const status = () => ({ active: Boolean(loaded), run_id: loaded?.task.run_id, task_id: loaded?.task.task_id, task_sha256: loaded?.taskSha256, tool_calls: toolCalls, turns, handed_off: handedOff, failure });
const record = (type, fields = {}) => {
Expand All @@ -154,7 +171,7 @@ export default function coordinationExtension(pi) {
return { block: true, reason: `${code}: ${message}` };
};

pi.registerFlag("coordination-task", { type: "string", description: "Absolute path to an external coordinator's version 1 task manifest" });
pi.registerFlag("coordination-task", { type: "string", description: "Absolute path to an external coordinator's versioned task manifest" });
pi.registerCommand("coordination-status", {
description: "Show the current delegated task and bounds",
handler: async (_args, ctx) => { if (ctx.hasUI) ctx.ui.notify(JSON.stringify(status()), "info"); },
Expand Down Expand Up @@ -213,6 +230,24 @@ export default function coordinationExtension(pi) {
stop(ctx, "task_unavailable", "Coordination task is unavailable or already handed off");
return;
}
if (loaded.task.version === 2 && !configurationRecorded) {
const configuration = { provider: ctx.model?.provider, model: ctx.model?.id, thinking: pi.getThinkingLevel() };
if (!configuration.provider || !configuration.model || !["off", "minimal", "low", "medium", "high", "xhigh", "max"].includes(configuration.thinking)) {
stop(ctx, "configuration_unavailable", "Pi did not expose an effective run configuration");
return;
}
const options = loaded.task.run_options;
const selectedModelMatches = options.provider
? configuration.provider === options.provider && configuration.model === options.model
: `${configuration.provider}/${configuration.model}` === loaded.task.runtime_defaults.model;
const selectedThinking = options.thinking ?? loaded.task.runtime_defaults.thinking;
if (!selectedModelMatches || configuration.thinking !== selectedThinking) {
stop(ctx, "configuration_mismatch", "Effective Pi options differ from the approved task");
return;
}
record("run_configuration", { configuration });
configurationRecorded = true;
}
return { systemPrompt: `${event.systemPrompt}\n\nExternal coordinator task:\n${JSON.stringify({ run_id: loaded.task.run_id, task_id: loaded.task.task_id, kind: loaded.task.kind, instructions: loaded.task.instructions, source: loaded.sourceSummary, writable_paths: loaded.task.writable_paths, max_tool_calls: loaded.task.max_tool_calls, max_turns: loaded.task.max_turns })}\nWork only inside the assigned workspace and declared writable files. Shell execution is unavailable; the coordinator runs declared verification commands after Pi exits. Before the tool budget ends, call coordination_handoff exactly once with an honest self-report. Do not claim acceptance or verification from your report. Tool/path guards are task policy; the external runner owns OS isolation and custody.` };
});
pi.on("turn_start", async (_event, ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/codex-pi-coordination/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codex-pi-coordination",
"version": "0.1.1",
"version": "0.2.0",
"description": "Bounded Pi task handoff for an external Codex coordinator",
"type": "module",
"license": "MIT",
Expand Down
Loading
Loading