akm-cli
Version:
akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur
36 lines (35 loc) • 1.85 kB
JavaScript
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
import { modelFromArgs, withoutLeading, withoutModelFlag, } from "../harness.js";
import { CodexProvider } from "./session-log.js";
export { CodexProvider } from "./session-log.js";
export class CodexHarness {
id = "codex";
displayName = "OpenAI Codex CLI";
// No `setupDetectionDir`: `~/.codex` holds credentials and session rollouts,
// not assets, so `akm setup` must not offer it as a stash source.
profile = { bin: "codex", args: [] };
// CODEX_SANDBOX is stamped only on processes codex itself spawns inside its sandbox, so it
// means "running under codex"; its value (e.g. "seatbelt") is a sandbox mode, not a session id.
presenceEnv = ["CODEX_SANDBOX"];
sessionLogProvider = () => new CodexProvider();
systemPrompt = false;
nativeAgent = false;
confinable = true;
build({ bin, args }, req) {
const authored = withoutLeading(args, "exec");
// Model work drops the config's args (a `--sandbox` among them would widen the policy), keeping the model they name.
const extra = req.modelWork ? [] : req.model ? withoutModelFlag(authored) : authored;
const model = req.model ?? (req.modelWork ? modelFromArgs(authored) : undefined);
const modelFlag = model ? ["--model", model] : [];
if (req.prompt === undefined)
return { argv: [bin, ...extra, ...modelFlag] };
const sandbox = req.modelWork ? ["--sandbox", "read-only"] : [];
return {
argv: [bin, "exec", ...extra, ...sandbox, "--skip-git-repo-check", ...modelFlag, "-"],
stdin: req.prompt,
failureStream: "stderr",
};
}
}