diff --git a/src/CodexAcpClient.ts b/src/CodexAcpClient.ts index 2997a0ec..95c4ee4d 100644 --- a/src/CodexAcpClient.ts +++ b/src/CodexAcpClient.ts @@ -117,11 +117,13 @@ export class CodexAcpClient { developerInstructions: null, experimentalRawEvents: false }); + const codexModels = await this.fetchAvailableModels(); if (codexModels.length === 0) { throw new Error("Codex did not return any models"); } const currentModelId = ModelId.fromThreadResponse(threadStartResponse).toString(); + return { sessionId: threadStartResponse.thread.id, currentModelId: currentModelId, diff --git a/src/ModelId.ts b/src/ModelId.ts index ab1abfc5..4618f2c3 100644 --- a/src/ModelId.ts +++ b/src/ModelId.ts @@ -16,17 +16,18 @@ export class ModelId { } static fromString(modelId: string): ModelId { - const parts = modelId.split("/"); - const model = parts[0]; - const effort = parts[1] ?? null; + const bracketMatch = modelId.match(/^(?[^\[]+?)(?:\[(?[^\]]+)\])?$/); + const model = bracketMatch?.groups?.["model"]; + const effort = bracketMatch?.groups?.["effort"] ?? null; - if (!model) { - throw new Error(`Invalid modelId format: ${modelId}`); + if (model) { + return new ModelId(model, effort); } - return new ModelId(model, effort); + + throw new Error(`Invalid modelId format: ${modelId}`); } toString(): string { - return this.effort ? `${this.model}/${this.effort}` : this.model; + return this.effort ? `${this.model}[${this.effort}]` : this.model; } -} \ No newline at end of file +} diff --git a/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts b/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts index b783cee6..edff6ab6 100644 --- a/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts +++ b/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts @@ -16,7 +16,7 @@ describe('ACP server test', { timeout: 40_000 }, () => { vi.clearAllMocks(); }); - const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "reasoningEffort", "conversationId"]; + const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "conversationId", "origins", "projects", "supportedReasoningEfforts", "reasoningEffort"]; it('should start conversation', async () => { const codexAcpAgent = fixture.getCodexAcpAgent(); diff --git a/src/__tests__/CodexACPAgent/data/auth-with-key.json b/src/__tests__/CodexACPAgent/data/auth-with-key.json index 327de680..1deef96a 100644 --- a/src/__tests__/CodexACPAgent/data/auth-with-key.json +++ b/src/__tests__/CodexACPAgent/data/auth-with-key.json @@ -88,24 +88,7 @@ "model": "gpt-5.1-codex-max", "displayName": "gpt-5.1-codex-max", "description": "Codex-optimized flagship for deep and fast reasoning.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Fast responses with lighter reasoning" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed and reasoning depth for everyday tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Greater reasoning depth for complex problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning depth for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": true }, @@ -114,16 +97,7 @@ "model": "gpt-5.1-codex-mini", "displayName": "gpt-5.1-codex-mini", "description": "Optimized for codex. Cheaper, faster, but less capable.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Dynamically adjusts reasoning based on the task" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false }, @@ -132,24 +106,7 @@ "model": "gpt-5.2", "displayName": "gpt-5.2", "description": "Latest frontier model with improvements across knowledge, reasoning and coding", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed with some reasoning; useful for straightforward queries and short explanations" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false } diff --git a/src/__tests__/CodexACPAgent/data/start-conversation.json b/src/__tests__/CodexACPAgent/data/start-conversation.json index e509a315..f45f7380 100644 --- a/src/__tests__/CodexACPAgent/data/start-conversation.json +++ b/src/__tests__/CodexACPAgent/data/start-conversation.json @@ -77,24 +77,7 @@ "model": "gpt-5.1-codex-max", "displayName": "gpt-5.1-codex-max", "description": "Codex-optimized flagship for deep and fast reasoning.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Fast responses with lighter reasoning" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed and reasoning depth for everyday tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Greater reasoning depth for complex problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning depth for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": true }, @@ -103,16 +86,7 @@ "model": "gpt-5.1-codex-mini", "displayName": "gpt-5.1-codex-mini", "description": "Optimized for codex. Cheaper, faster, but less capable.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Dynamically adjusts reasoning based on the task" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false }, @@ -121,24 +95,7 @@ "model": "gpt-5.2", "displayName": "gpt-5.2", "description": "Latest frontier model with improvements across knowledge, reasoning and coding", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed with some reasoning; useful for straightforward queries and short explanations" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false }