119 lines
2.9 KiB
TypeScript
119 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
|
|
import { Effect } from "effect";
|
|
import { describe, it } from "vitest";
|
|
|
|
import {
|
|
CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
|
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
|
} from "./CodexDeveloperInstructions.ts";
|
|
import { buildTurnStartParams } from "./CodexSessionRuntime.ts";
|
|
|
|
describe("buildTurnStartParams", () => {
|
|
it("includes plan collaboration mode when requested", () => {
|
|
const params = Effect.runSync(
|
|
buildTurnStartParams({
|
|
threadId: "provider-thread-1",
|
|
runtimeMode: "full-access",
|
|
prompt: "Make a plan",
|
|
model: "gpt-5.3-codex",
|
|
effort: "medium",
|
|
interactionMode: "plan",
|
|
}),
|
|
);
|
|
|
|
assert.deepStrictEqual(params, {
|
|
threadId: "provider-thread-1",
|
|
approvalPolicy: "never",
|
|
sandboxPolicy: {
|
|
type: "dangerFullAccess",
|
|
},
|
|
input: [
|
|
{
|
|
type: "text",
|
|
text: "Make a plan",
|
|
},
|
|
],
|
|
model: "gpt-5.3-codex",
|
|
effort: "medium",
|
|
collaborationMode: {
|
|
mode: "plan",
|
|
settings: {
|
|
model: "gpt-5.3-codex",
|
|
reasoning_effort: "medium",
|
|
developer_instructions: CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("includes default collaboration mode and image attachments", () => {
|
|
const params = Effect.runSync(
|
|
buildTurnStartParams({
|
|
threadId: "provider-thread-1",
|
|
runtimeMode: "auto-accept-edits",
|
|
prompt: "Implement it",
|
|
model: "gpt-5.3-codex",
|
|
interactionMode: "default",
|
|
attachments: [
|
|
{
|
|
type: "image",
|
|
url: "data:image/png;base64,abc",
|
|
},
|
|
],
|
|
}),
|
|
);
|
|
|
|
assert.deepStrictEqual(params, {
|
|
threadId: "provider-thread-1",
|
|
approvalPolicy: "on-request",
|
|
sandboxPolicy: {
|
|
type: "workspaceWrite",
|
|
},
|
|
input: [
|
|
{
|
|
type: "text",
|
|
text: "Implement it",
|
|
},
|
|
{
|
|
type: "image",
|
|
url: "data:image/png;base64,abc",
|
|
},
|
|
],
|
|
model: "gpt-5.3-codex",
|
|
collaborationMode: {
|
|
mode: "default",
|
|
settings: {
|
|
model: "gpt-5.3-codex",
|
|
reasoning_effort: "medium",
|
|
developer_instructions: CODEX_DEFAULT_MODE_DEVELOPER_INSTRUCTIONS,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("omits collaboration mode when interaction mode is absent", () => {
|
|
const params = Effect.runSync(
|
|
buildTurnStartParams({
|
|
threadId: "provider-thread-1",
|
|
runtimeMode: "approval-required",
|
|
prompt: "Review",
|
|
}),
|
|
);
|
|
|
|
assert.deepStrictEqual(params, {
|
|
threadId: "provider-thread-1",
|
|
approvalPolicy: "untrusted",
|
|
sandboxPolicy: {
|
|
type: "readOnly",
|
|
},
|
|
input: [
|
|
{
|
|
type: "text",
|
|
text: "Review",
|
|
},
|
|
],
|
|
});
|
|
});
|
|
});
|