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
errors.ts2.1 KB
// What the app-server's error replies mean for the Codex provider.
import * as z from "zod";
import { TransportFailed } from "../sdk/effect.ts";
import { RpcError } from "../sdk/jsonrpc.ts";
import { ProviderError, errorMessage } from "../sdk/errors.ts";
// These native JSON-RPC validation/precondition replies prove no admission.
// INTERNAL_ERROR is also used for locally lost writes/timeouts: never replay it.
export function nativeRejection(error: unknown) {
const wrapped = z.object({ cause: z.unknown() }).safeParse(error);
const cause = wrapped.success ? wrapped.data.cause : null;
return cause instanceof RpcError && [-32600, -32601, -32602].includes(cause.code);
}
/// Codex has neither a record of `thread` nor the thread loaded.
export function threadGone(thread: string, error: unknown) {
return (
error instanceof TransportFailed &&
error.cause instanceof RpcError &&
error.cause.code === -32600 &&
error.cause.message === `thread/read failed: thread not loaded: ${thread}`
);
}
/// Why `thread/resume` of `thread` failed. Another program writing the
/// thread is a state the user can end, so it is said in their words.
export function resumeFailure(thread: string, error: unknown) {
if (
error instanceof TransportFailed &&
error.cause instanceof RpcError &&
error.cause.message.endsWith(`thread ${thread} already has an active writer`)
)
return new ProviderError({
message:
"Another Codex program, such as the Codex app or the CLI, has this conversation open, and Codex lets only one program continue a conversation at a time. Close it there, then send again.",
});
return new ProviderError({ message: `thread/resume failed: ${errorMessage(error)}` });
}
/// A newly started thread has no native turns until its first user message.
export function threadUnmaterialized(thread: string, error: unknown) {
return error instanceof TransportFailed && error.cause instanceof RpcError && error.cause.code === -32600 &&
error.cause.message === `thread/turns/list failed: thread ${thread} is not materialized yet; thread/turns/list is unavailable before first user message`;
}
No comments yet.