Skip to content
Open
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
444 changes: 444 additions & 0 deletions examples/steering.ts

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"declaration": false,
"declarationMap": false,
"sourceMap": false
},
"include": [
"steering.ts"
],
"exclude": []
}
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
"package:win-x64": "cd dist/bin && zip codex-acp-x64-windows.zip codex-acp-x64-windows.exe",
"package:win-arm64": "cd dist/bin && zip codex-acp-arm64-windows.zip codex-acp-arm64-windows.exe",
"start": "node --import tsx src/index.ts",
"example:steering": "node --import tsx examples/steering.ts",
"example:steering:multistep": "node --import tsx examples/steering.ts",
"generate-types": "./node_modules/.bin/codex app-server generate-ts --out src/app-server",
"test": "vitest run",
"test:e2e": "npm run build && RUN_E2E_TESTS=true vitest run src/__tests__/CodexACPAgent/e2e",
"test:watch": "vitest",
"typecheck": "tsc --noEmit",
"typecheck": "tsc --noEmit && tsc --noEmit -p examples/tsconfig.json",
"codex-test": "tsx .claude/skills/run-codex/scripts/run-codex-test.ts"
},
"homepage": "https://github.com/agentclientprotocol/codex-acp#readme",
Expand All @@ -62,7 +64,7 @@
},
"dependencies": {
"@agentclientprotocol/sdk": "^1.2.1",
"@openai/codex": "^0.144.4",
"@openai/codex": "^0.144.5",
"diff": "^9.0.0",
"open": "^11.0.0",
"vscode-jsonrpc": "^9.0.1",
Expand Down
27 changes: 26 additions & 1 deletion src/AcpExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type {
ClientContext,
ContentBlock,
LoadSessionResponse,
NewSessionResponse,
ResumeSessionResponse,
SessionId,
} from "@agentclientprotocol/sdk";

export const LEGACY_SET_SESSION_MODEL_METHOD = "session/set_model";
export const SESSION_STEERING_METHOD = "_session/steering";
export const GOAL_CONTROL_METHOD = "_codex/session/goal_control";

export type LegacySessionModel = {
Expand Down Expand Up @@ -43,13 +45,15 @@ export type ExtMethodRequest =
AuthenticationStatusRequest
| AuthenticationLogoutRequest
| LegacySetSessionModelExtRequest
| SessionSteeringExtRequest
| GoalControlExtRequest

export function isExtMethodRequest(request: { method: string, params: Record<string, unknown> }): request is ExtMethodRequest {
return request.method === "authentication/status"
|| request.method === "authentication/logout"
|| request.method === LEGACY_SET_SESSION_MODEL_METHOD
|| request.method === GOAL_CONTROL_METHOD;
|| request.method === GOAL_CONTROL_METHOD
|| request.method === SESSION_STEERING_METHOD;
}

export type AuthenticationStatusRequest = { method: "authentication/status", params: {} }
Expand Down Expand Up @@ -79,3 +83,24 @@ export async function legacySetSessionModel(
): Promise<LegacySetSessionModelResponse> {
return await connection.request<LegacySetSessionModelResponse, LegacySetSessionModelRequest>(LEGACY_SET_SESSION_MODEL_METHOD, params);
}

export type SessionSteerRequest = {
sessionId: SessionId;
prompt: ContentBlock[];
}

export type SessionSteeringResponse = {
outcome: "injected" | "startedNewTurn";
}

export type SessionSteeringExtRequest = {
method: typeof SESSION_STEERING_METHOD;
params: SessionSteerRequest;
}

export async function steerSessionWithFallback(
connection: Pick<ClientContext, "request">,
params: SessionSteerRequest,
): Promise<SessionSteeringResponse> {
return await connection.request<SessionSteeringResponse, SessionSteerRequest>(SESSION_STEERING_METHOD, params);
}
9 changes: 9 additions & 0 deletions src/CodexAcpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
ThreadGoalStatus,
ThreadSourceKind,
TurnCompletedNotification,
TurnSteerResponse,
UserInput,
} from "./app-server/v2";
import packageJson from "../package.json";
Expand Down Expand Up @@ -833,6 +834,14 @@ export class CodexAcpClient {
});
}

async steerTurn(params: { threadId: string, turnId: string, prompt: acp.ContentBlock[] }): Promise<TurnSteerResponse> {
return await this.codexClient.turnSteer({
threadId: params.threadId,
expectedTurnId: params.turnId,
input: buildPromptItems(params.prompt),
});
}

async fetchAvailableModels(): Promise<Model[]> {
const models: Model[] = [];
let cursor: string | null = null;
Expand Down
Loading