Skip to content

Commit 5f8a0a0

Browse files
committed
optional chain token usage
1 parent 9e98498 commit 5f8a0a0

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

agents/claude-code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
const sessionCache = new Map<string, string>();
1313

1414
export const models: string[] = [
15-
"claude-sonnet-4-5",
15+
// "claude-sonnet-4-5",
1616
// "claude-sonnet-4",
1717
// "claude-opus-4-1",
1818
// "claude-3-5-haiku",

agents/codex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const codexClient = new Codex();
2222
const threadCache = new Map<string, Thread>();
2323

2424
export const models: string[] = [
25-
"gpt-5-codex",
26-
"gpt-5.1-codex",
25+
// "gpt-5-codex",
26+
// "gpt-5.1-codex",
2727
// "gpt-5",
2828
// "o3",
2929
// "o4-mini"

agents/opencode.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ const opencode = await createOpencode({
5454
const sessionCache = new Map<string, string>();
5555

5656
export const models: string[] = [
57-
"opencode/gpt-5-codex",
58-
"opencode/gpt-5.1-codex",
59-
"opencode/claude-sonnet-4-5",
60-
"opencode/glm-4.6",
61-
"opencode/gemini-3-pro",
62-
"opencode/qwen3-coder",
57+
// "opencode/gpt-5-codex",
58+
// "opencode/gpt-5.1-codex",
59+
// "opencode/claude-sonnet-4-5",
60+
// "opencode/glm-4.6",
61+
// "opencode/gemini-3-pro",
62+
// "opencode/qwen3-coder",
6363
"opencode/kimi-k2",
64-
"opencode/grok-code",
64+
// "opencode/grok-code",
6565
];
6666

6767
function formatCommand(command: string, args: string[]): string {
@@ -191,14 +191,19 @@ const opencodeAgent: AgentDefinition = {
191191
throw error;
192192
}
193193

194-
usage.input = data.info.tokens.input || 0;
195-
usage.output = data.info.tokens.output || 0;
194+
const info = data.info;
195+
usage.input = info?.tokens?.input ?? 0;
196+
usage.output = info?.tokens?.output ?? 0;
196197

197-
actions.push(JSON.stringify(data.info));
198+
if (info) {
199+
actions.push(JSON.stringify(info));
200+
}
198201

199202
data.parts.forEach((part) => actions.push(JSON.stringify(part)));
200203

201-
logJson({ info: data.info }, options);
204+
if (info) {
205+
logJson({ info }, options);
206+
}
202207
data.parts.forEach((part) => logJson(part, options));
203208
} catch (error) {
204209
console.error(

0 commit comments

Comments
 (0)