Skip to content
Merged
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
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"dependencies": {
"@agentclientprotocol/sdk": "^1.2.1",
"@openai/codex": "^0.144.6",
"@openai/codex": "^0.145.0",
"diff": "^9.0.0",
"open": "^11.0.0",
"vscode-jsonrpc": "^9.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ export class CodexEventHandler {
return this.createTerminalInteractionEvent(notification.params);
// ignored events
case "thread/deleted":
case "thread/environment/connected":
case "thread/environment/disconnected":
case "command/exec/outputDelta":
case "hook/started":
case "hook/completed":
Expand Down Expand Up @@ -219,6 +221,7 @@ export class CodexEventHandler {
case "mcpServer/oauthLogin/completed":
case "externalAgentConfig/import/completed":
case "rawResponseItem/completed":
case "rawResponse/completed":
case "thread/started":
case "item/plan/delta":
case "remoteControl/status/changed":
Expand Down
13 changes: 11 additions & 2 deletions src/CodexToolCallMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export function createWebSearchStartUpdate(
kind: "search",
title: formatWebSearchTitle(item),
status: "in_progress",
rawInput: item,
rawInput: createWebSearchRawInput(item),
};
}

Expand All @@ -399,7 +399,16 @@ export function createWebSearchCompleteUpdate(
toolCallId: item.id,
title: formatWebSearchTitle(item),
status: "completed",
rawInput: item,
rawInput: createWebSearchRawInput(item),
};
}

function createWebSearchRawInput(item: WebSearchItem): Record<string, JsonValue> {
return {
type: item.type,
id: item.id,
query: item.query,
action: item.action,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/CodexACPAgent/CodexAcpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
secondary: null,
credits: null,
individualLimit: null,
spendControlReached: null,
planType: null,
rateLimitReachedType: null,
}
Expand All @@ -3354,6 +3355,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
secondary: null,
credits: null,
individualLimit: null,
spendControlReached: null,
planType: null,
rateLimitReachedType: null,
}
Expand Down
34 changes: 20 additions & 14 deletions src/__tests__/CodexACPAgent/token-usage-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ describe('Token Usage Events', () => {
totalTokens: 5000,
inputTokens: 4000,
cachedInputTokens: 1000,
cacheWriteInputTokens: 0,
outputTokens: 900,
reasoningOutputTokens: 100,
},
last: {
totalTokens: 2500,
inputTokens: 2000,
cachedInputTokens: 500,
cacheWriteInputTokens: 0,
outputTokens: 450,
reasoningOutputTokens: 50,
},
Expand All @@ -91,13 +93,15 @@ describe('Token Usage Events', () => {
totalTokens: 3000,
inputTokens: 2500,
cachedInputTokens: 0,
cacheWriteInputTokens: 0,
outputTokens: 500,
reasoningOutputTokens: 0,
},
last: {
totalTokens: 1500,
inputTokens: 1200,
cachedInputTokens: 0,
cacheWriteInputTokens: 0,
outputTokens: 300,
reasoningOutputTokens: 0,
},
Expand Down Expand Up @@ -132,18 +136,18 @@ describe('Token Usage Events', () => {
it('should use last token usage from multiple updates', async () => {
const notifications: ServerNotification[] = [
createTokenUsageNotification(sessionId, {
total: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
total: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
modelContextWindow: 128000,
}),
createTokenUsageNotification(sessionId, {
total: { totalTokens: 2000, inputTokens: 1600, cachedInputTokens: 0, outputTokens: 400, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
total: { totalTokens: 2000, inputTokens: 1600, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 400, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
modelContextWindow: 128000,
}),
createTokenUsageNotification(sessionId, {
total: { totalTokens: 3500, inputTokens: 2800, cachedInputTokens: 500, outputTokens: 600, reasoningOutputTokens: 100 },
last: { totalTokens: 1500, inputTokens: 1200, cachedInputTokens: 500, outputTokens: 200, reasoningOutputTokens: 100 },
total: { totalTokens: 3500, inputTokens: 2800, cachedInputTokens: 500, cacheWriteInputTokens: 0, outputTokens: 600, reasoningOutputTokens: 100 },
last: { totalTokens: 1500, inputTokens: 1200, cachedInputTokens: 500, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 100 },
modelContextWindow: 128000,
}),
];
Expand Down Expand Up @@ -197,13 +201,15 @@ describe('Token Usage Events', () => {
totalTokens: 5000,
inputTokens: 4000,
cachedInputTokens: 1000,
cacheWriteInputTokens: 0,
outputTokens: 900,
reasoningOutputTokens: 100,
},
last: {
totalTokens: 2500,
inputTokens: 2000,
cachedInputTokens: 500,
cacheWriteInputTokens: 0,
outputTokens: 450,
reasoningOutputTokens: 50,
},
Expand All @@ -217,18 +223,18 @@ describe('Token Usage Events', () => {
it('should emit latest turn usage from multiple updates', async () => {
const events = await setupPromptAndReturnEvents([
createTokenUsageNotification(sessionId, {
total: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
total: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
modelContextWindow: 128000,
}),
createTokenUsageNotification(sessionId, {
total: { totalTokens: 2000, inputTokens: 1600, cachedInputTokens: 0, outputTokens: 400, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
total: { totalTokens: 2000, inputTokens: 1600, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 400, reasoningOutputTokens: 0 },
last: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
modelContextWindow: 128000,
}),
createTokenUsageNotification(sessionId, {
total: { totalTokens: 3500, inputTokens: 2800, cachedInputTokens: 500, outputTokens: 600, reasoningOutputTokens: 100 },
last: { totalTokens: 1500, inputTokens: 1200, cachedInputTokens: 500, outputTokens: 200, reasoningOutputTokens: 100 },
total: { totalTokens: 3500, inputTokens: 2800, cachedInputTokens: 500, cacheWriteInputTokens: 0, outputTokens: 600, reasoningOutputTokens: 100 },
last: { totalTokens: 1500, inputTokens: 1200, cachedInputTokens: 500, cacheWriteInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 100 },
modelContextWindow: 128000,
}),
])();
Expand All @@ -239,8 +245,8 @@ describe('Token Usage Events', () => {
it('should skip usage_update when model context window is unavailable', async () => {
const events = await setupPromptAndReturnEvents([
createTokenUsageNotification(sessionId, {
total: { totalTokens: 5000, inputTokens: 4000, cachedInputTokens: 1000, outputTokens: 900, reasoningOutputTokens: 100 },
last: { totalTokens: 2500, inputTokens: 2000, cachedInputTokens: 500, outputTokens: 450, reasoningOutputTokens: 50 },
total: { totalTokens: 5000, inputTokens: 4000, cachedInputTokens: 1000, cacheWriteInputTokens: 0, outputTokens: 900, reasoningOutputTokens: 100 },
last: { totalTokens: 2500, inputTokens: 2000, cachedInputTokens: 500, cacheWriteInputTokens: 0, outputTokens: 450, reasoningOutputTokens: 50 },
modelContextWindow: null,
}),
])();
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/CodexACPAgent/web-search-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe("CodexEventHandler - web search events", () => {
type: "webSearch",
id: "web-search-1",
query: "agent client protocol",
results: null,
action: {
type: "search",
query: "agent client protocol",
Expand All @@ -54,6 +55,7 @@ describe("CodexEventHandler - web search events", () => {
type: "webSearch",
id: "web-search-1",
query: "agent client protocol",
results: null,
action: {
type: "search",
query: "agent client protocol",
Expand Down Expand Up @@ -83,6 +85,7 @@ describe("CodexEventHandler - web search events", () => {
type: "webSearch",
id: "web-open-1",
query: "https://agentclientprotocol.com",
results: null,
action: {
type: "openPage",
url: "https://agentclientprotocol.com",
Expand All @@ -100,6 +103,7 @@ describe("CodexEventHandler - web search events", () => {
type: "webSearch",
id: "web-find-1",
query: "protocol",
results: null,
action: {
type: "findInPage",
url: "https://agentclientprotocol.com/protocol",
Expand Down
Loading