Run fixed Zopu worktrees with Pi
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentos-software/codex": "0.0.0-agent-acp-codex-session-benchmark.fd745e7",
|
||||
"@agentos-software/pi": "0.2.7",
|
||||
"@agentos-software/git": "0.3.3",
|
||||
"@rivet-dev/agentos": "0.2.14",
|
||||
"effect": "catalog:"
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { codexSessionEnv, makeCodexAgentOsConfig } from "./agent-os";
|
||||
|
||||
describe("Codex agent-os config", () => {
|
||||
it("always includes the codex + git software bundle", () => {
|
||||
const config = makeCodexAgentOsConfig();
|
||||
expect(config.software).toHaveLength(2);
|
||||
expect(config.software?.[0]).toBeTypeOf("object");
|
||||
});
|
||||
|
||||
it("allows repository execution capabilities", () => {
|
||||
const config = makeCodexAgentOsConfig();
|
||||
expect(config.permissions?.network).toBe("allow");
|
||||
expect(config.permissions?.fs).toBe("allow");
|
||||
expect(config.permissions?.childProcess).toBe("allow");
|
||||
expect(config.permissions?.env).toBe("allow");
|
||||
expect(config.permissions?.process).toBe("allow");
|
||||
});
|
||||
|
||||
it("builds model-provider session env", () => {
|
||||
const env = codexSessionEnv(
|
||||
{
|
||||
apiKey: "sk-test",
|
||||
baseUrl: "https://ai.example.com/v1",
|
||||
model: "glm-5.2",
|
||||
},
|
||||
{ CODEX_MODEL: "glm-5.2" }
|
||||
);
|
||||
expect(env.OPENAI_API_KEY).toBe("sk-test");
|
||||
expect(env.OPENAI_BASE_URL).toBe("https://ai.example.com/v1");
|
||||
expect(env.CODEX_MODEL).toBe("glm-5.2");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable max-classes-per-file -- the AgentOS service and its tagged error form one adapter contract. */
|
||||
import codex from "@agentos-software/codex";
|
||||
import pi from "@agentos-software/pi";
|
||||
import { agentOS as createAgentOsActor } from "@rivet-dev/agentos";
|
||||
import type { AgentOSConfigInput } from "@rivet-dev/agentos";
|
||||
import { Context, Effect, Layer, Schema } from "effect";
|
||||
@@ -73,55 +73,86 @@ export const createAgentOsActorEffect = Effect.fn("createAgentOsActorEffect")(
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Codex harness configuration
|
||||
// Pi harness configuration
|
||||
//
|
||||
// The canonical execution registry runs exactly one AgentOS actor for the
|
||||
// puter/zopu-code repo, booted with the Codex CLI harness + git. The model
|
||||
// provider is injected as VM env (OpenAI-compatible base URL + key) so Codex
|
||||
// authenticates against the configured gateway without a second credentials
|
||||
// path. This is a pure config builder; the RivetKit registry/server that hosts
|
||||
// the actor lives in the agents package.
|
||||
// Slice 5 intentionally runs one harness against the server's fixed Zopu
|
||||
// checkout. Pi speaks ACP natively and reads its model gateway from a mounted
|
||||
// HOME, avoiding a second executable adapter or credentials path.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Software bundle for a Codex-capable VM: the Codex harness plus git. */
|
||||
export const codexSoftware = [...codex, getExecutableGitSoftware()] as const;
|
||||
/** Software bundle for a Pi-capable VM: the Pi ACP harness plus git. */
|
||||
export const piSoftware = [pi, getExecutableGitSoftware()] as const;
|
||||
|
||||
/** Model-provider env that Codex reads inside the VM. Pass this to the session's
|
||||
* `env` when opening a Codex session (`agent: "codex"`). */
|
||||
export interface CodexModelEnv {
|
||||
readonly apiKey: string;
|
||||
export interface PiModelConfig {
|
||||
readonly api: "openai-completions";
|
||||
readonly apiKeyEnvironmentVariable: string;
|
||||
readonly baseUrl: string;
|
||||
readonly contextWindow: number;
|
||||
readonly maxTokens: number;
|
||||
readonly model: string;
|
||||
readonly provider: string;
|
||||
}
|
||||
|
||||
/** Builds the VM env record Codex reads to authenticate against the model gateway. */
|
||||
export const codexSessionEnv = (
|
||||
model: CodexModelEnv,
|
||||
export interface PiHomeFiles {
|
||||
readonly models: string;
|
||||
readonly settings: string;
|
||||
}
|
||||
|
||||
/** Builds the two files Pi reads from ~/.pi/agent. */
|
||||
export const makePiHomeFiles = (model: PiModelConfig): PiHomeFiles => ({
|
||||
models: JSON.stringify(
|
||||
{
|
||||
providers: {
|
||||
[model.provider]: {
|
||||
api: model.api,
|
||||
apiKey: model.apiKeyEnvironmentVariable,
|
||||
authHeader: true,
|
||||
baseUrl: model.baseUrl,
|
||||
models: [
|
||||
{
|
||||
contextWindow: model.contextWindow,
|
||||
id: model.model,
|
||||
maxTokens: model.maxTokens,
|
||||
name: model.model,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
settings: JSON.stringify(
|
||||
{
|
||||
defaultModel: model.model,
|
||||
defaultProvider: model.provider,
|
||||
quietStartup: true,
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
});
|
||||
|
||||
/** Environment supplied to the Pi ACP session. */
|
||||
export const piSessionEnv = (
|
||||
apiKey: string,
|
||||
extra: Readonly<Record<string, string>> = {}
|
||||
): Record<string, string> => ({
|
||||
CODEX_HOME: "/tmp/codex-home",
|
||||
CODEX_MODEL: model.model,
|
||||
HOME: "/tmp",
|
||||
OPENAI_API_KEY: model.apiKey,
|
||||
OPENAI_BASE_URL: model.baseUrl,
|
||||
AGENT_MODEL_API_KEY: apiKey,
|
||||
HOME: "/home/zopu",
|
||||
PATH: "/opt/zopu-tools/bin:/usr/local/bin:/usr/bin:/bin",
|
||||
...extra,
|
||||
});
|
||||
|
||||
export interface CodexAgentOsConfigInput {
|
||||
/** Extra software merged after the Codex+git bundle. */
|
||||
export interface PiAgentOsConfigInput {
|
||||
/** Extra software merged after the Pi+git bundle. */
|
||||
readonly software?: NonNullable<AgentOSConfigInput<undefined>["software"]>;
|
||||
/** VM permission overrides merged over the execution policy. */
|
||||
readonly permissions?: AgentOSConfigInput<undefined>["permissions"];
|
||||
}
|
||||
|
||||
/**
|
||||
* are always present; software the caller passes is appended, never replacing
|
||||
* the harness or git. Filesystem, process execution, environment variables, and
|
||||
* outbound network access are enabled for repository and model-provider work.
|
||||
* Model-provider env is supplied per session via `codexSessionEnv`.
|
||||
*/
|
||||
export const makeCodexAgentOsConfig = (
|
||||
input: CodexAgentOsConfigInput = {}
|
||||
export const makePiAgentOsConfig = (
|
||||
input: PiAgentOsConfigInput = {}
|
||||
): AgentOSConfigInput<undefined> => ({
|
||||
permissions: {
|
||||
childProcess: "allow",
|
||||
@@ -131,5 +162,5 @@ export const makeCodexAgentOsConfig = (
|
||||
process: "allow",
|
||||
...input.permissions,
|
||||
},
|
||||
software: [...codexSoftware, ...(input.software ?? [])],
|
||||
software: [...piSoftware, ...(input.software ?? [])],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user