aglio-worker 0.80.1 → 0.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.js +333 -3
- package/package.json +1 -1
package/agent.js
CHANGED
|
@@ -71088,6 +71088,7 @@ var PROVIDERS = [
|
|
|
71088
71088
|
id: "anthropic",
|
|
71089
71089
|
label: "Anthropic Claude",
|
|
71090
71090
|
drivers: ["claude", "pi"],
|
|
71091
|
+
models: ["claude-sonnet-4-5", "claude-opus-4-1", "claude-haiku-4-5", "claude-sonnet-4", "claude-3-7-sonnet-latest"],
|
|
71091
71092
|
connection: { baseUrl: "https://api.anthropic.com/v1" },
|
|
71092
71093
|
authOptions: [
|
|
71093
71094
|
apiKey("ANTHROPIC_API_KEY", ["claude", "pi"]),
|
|
@@ -71104,6 +71105,7 @@ var PROVIDERS = [
|
|
|
71104
71105
|
id: "openai",
|
|
71105
71106
|
label: "OpenAI / Codex",
|
|
71106
71107
|
drivers: ["codex", "pi"],
|
|
71108
|
+
models: ["gpt-5", "gpt-5-codex", "gpt-5-mini", "gpt-4.1", "o3", "o4-mini"],
|
|
71107
71109
|
connection: { baseUrl: "https://api.openai.com/v1" },
|
|
71108
71110
|
authOptions: [
|
|
71109
71111
|
apiKey("OPENAI_API_KEY", ["codex", "pi"]),
|
|
@@ -71125,6 +71127,7 @@ var PROVIDERS = [
|
|
|
71125
71127
|
id: "google",
|
|
71126
71128
|
label: "Google Gemini",
|
|
71127
71129
|
drivers: ["gemini", "pi"],
|
|
71130
|
+
models: ["gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.0-flash"],
|
|
71128
71131
|
connection: { baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai" },
|
|
71129
71132
|
authOptions: [
|
|
71130
71133
|
apiKey("GEMINI_API_KEY", ["gemini", "pi"]),
|
|
@@ -71149,6 +71152,7 @@ var PROVIDERS = [
|
|
|
71149
71152
|
id: "cursor",
|
|
71150
71153
|
label: "Cursor",
|
|
71151
71154
|
drivers: ["cursor"],
|
|
71155
|
+
models: ["auto", "claude-sonnet-4-5", "gpt-5", "gemini-2.5-pro"],
|
|
71152
71156
|
authOptions: [
|
|
71153
71157
|
apiKey("CURSOR_API_KEY", ["cursor"]),
|
|
71154
71158
|
sessionBundle(
|
|
@@ -71170,6 +71174,7 @@ var PROVIDERS = [
|
|
|
71170
71174
|
id: "opencode",
|
|
71171
71175
|
label: "OpenCode",
|
|
71172
71176
|
drivers: ["opencode"],
|
|
71177
|
+
models: ["default", "anthropic/claude-sonnet-4-5", "openai/gpt-5", "google/gemini-2.5-pro"],
|
|
71173
71178
|
authOptions: [
|
|
71174
71179
|
sessionBundle(
|
|
71175
71180
|
".local/share/opencode/auth.json",
|
|
@@ -71211,6 +71216,7 @@ var PROVIDERS = [
|
|
|
71211
71216
|
id: "local",
|
|
71212
71217
|
label: "Local OpenAI-compatible server",
|
|
71213
71218
|
drivers: ["pi"],
|
|
71219
|
+
models: ["llama3.2", "qwen2.5-coder", "deepseek-r1", "mistral-small"],
|
|
71214
71220
|
authOptions: [
|
|
71215
71221
|
{
|
|
71216
71222
|
type: "api_key",
|
|
@@ -71226,6 +71232,7 @@ var PROVIDERS = [
|
|
|
71226
71232
|
id: "deepseek",
|
|
71227
71233
|
label: "DeepSeek",
|
|
71228
71234
|
drivers: ["pi"],
|
|
71235
|
+
models: ["deepseek-flash", "deepseek-chat", "deepseek-reasoner"],
|
|
71229
71236
|
connection: { baseUrl: "https://api.deepseek.com/v1" },
|
|
71230
71237
|
authOptions: [apiKey("DEEPSEEK_API_KEY", ["pi"])]
|
|
71231
71238
|
},
|
|
@@ -71233,6 +71240,7 @@ var PROVIDERS = [
|
|
|
71233
71240
|
id: "openrouter",
|
|
71234
71241
|
label: "OpenRouter",
|
|
71235
71242
|
drivers: ["pi"],
|
|
71243
|
+
models: ["openrouter/auto", "anthropic/claude-sonnet-4.5", "openai/gpt-5", "google/gemini-2.5-pro", "deepseek/deepseek-chat-v3.1"],
|
|
71236
71244
|
connection: { baseUrl: "https://openrouter.ai/api/v1" },
|
|
71237
71245
|
authOptions: [apiKey("OPENROUTER_API_KEY", ["pi"])]
|
|
71238
71246
|
},
|
|
@@ -71240,6 +71248,7 @@ var PROVIDERS = [
|
|
|
71240
71248
|
id: "xai",
|
|
71241
71249
|
label: "xAI",
|
|
71242
71250
|
drivers: ["pi"],
|
|
71251
|
+
models: ["grok-4", "grok-3", "grok-3-mini"],
|
|
71243
71252
|
connection: { baseUrl: "https://api.x.ai/v1" },
|
|
71244
71253
|
authOptions: [apiKey("XAI_API_KEY", ["pi"])]
|
|
71245
71254
|
},
|
|
@@ -71247,6 +71256,7 @@ var PROVIDERS = [
|
|
|
71247
71256
|
id: "groq",
|
|
71248
71257
|
label: "Groq",
|
|
71249
71258
|
drivers: ["pi"],
|
|
71259
|
+
models: ["llama-3.3-70b-versatile", "openai/gpt-oss-120b", "qwen/qwen3-32b"],
|
|
71250
71260
|
connection: { baseUrl: "https://api.groq.com/openai/v1" },
|
|
71251
71261
|
authOptions: [apiKey("GROQ_API_KEY", ["pi"])]
|
|
71252
71262
|
},
|
|
@@ -71254,6 +71264,7 @@ var PROVIDERS = [
|
|
|
71254
71264
|
id: "mistral",
|
|
71255
71265
|
label: "Mistral",
|
|
71256
71266
|
drivers: ["pi"],
|
|
71267
|
+
models: ["mistral-large-latest", "codestral-latest", "mistral-medium-latest"],
|
|
71257
71268
|
connection: { baseUrl: "https://api.mistral.ai/v1" },
|
|
71258
71269
|
authOptions: [apiKey("MISTRAL_API_KEY", ["pi"])]
|
|
71259
71270
|
},
|
|
@@ -71261,6 +71272,7 @@ var PROVIDERS = [
|
|
|
71261
71272
|
id: "cerebras",
|
|
71262
71273
|
label: "Cerebras",
|
|
71263
71274
|
drivers: ["pi"],
|
|
71275
|
+
models: ["qwen-3-coder-480b", "llama-3.3-70b", "gpt-oss-120b"],
|
|
71264
71276
|
connection: { baseUrl: "https://api.cerebras.ai/v1" },
|
|
71265
71277
|
authOptions: [apiKey("CEREBRAS_API_KEY", ["pi"])]
|
|
71266
71278
|
},
|
|
@@ -71268,6 +71280,7 @@ var PROVIDERS = [
|
|
|
71268
71280
|
id: "together",
|
|
71269
71281
|
label: "Together AI",
|
|
71270
71282
|
drivers: ["pi"],
|
|
71283
|
+
models: ["Qwen/Qwen3-Coder-480B-A35B-Instruct", "deepseek-ai/DeepSeek-V3", "meta-llama/Llama-3.3-70B-Instruct-Turbo"],
|
|
71271
71284
|
connection: { baseUrl: "https://api.together.xyz/v1" },
|
|
71272
71285
|
authOptions: [apiKey("TOGETHER_API_KEY", ["pi"])]
|
|
71273
71286
|
},
|
|
@@ -71275,6 +71288,7 @@ var PROVIDERS = [
|
|
|
71275
71288
|
id: "fireworks",
|
|
71276
71289
|
label: "Fireworks AI",
|
|
71277
71290
|
drivers: ["pi"],
|
|
71291
|
+
models: ["accounts/fireworks/models/kimi-k2-instruct", "accounts/fireworks/models/deepseek-v3", "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct"],
|
|
71278
71292
|
connection: { baseUrl: "https://api.fireworks.ai/inference/v1" },
|
|
71279
71293
|
authOptions: [apiKey("FIREWORKS_API_KEY", ["pi"])]
|
|
71280
71294
|
},
|
|
@@ -71282,6 +71296,7 @@ var PROVIDERS = [
|
|
|
71282
71296
|
id: "moonshot",
|
|
71283
71297
|
label: "Moonshot / Kimi",
|
|
71284
71298
|
drivers: ["pi"],
|
|
71299
|
+
models: ["kimi-k2-0905-preview", "kimi-k2-turbo-preview", "moonshot-v1-128k"],
|
|
71285
71300
|
connection: { baseUrl: "https://api.moonshot.ai/v1" },
|
|
71286
71301
|
authOptions: [apiKey("MOONSHOT_API_KEY", ["pi"])]
|
|
71287
71302
|
},
|
|
@@ -71289,6 +71304,7 @@ var PROVIDERS = [
|
|
|
71289
71304
|
id: "zai",
|
|
71290
71305
|
label: "Z.ai",
|
|
71291
71306
|
drivers: ["pi"],
|
|
71307
|
+
models: ["glm-4.6", "glm-4.5", "glm-4.5-air"],
|
|
71292
71308
|
connection: { baseUrl: "https://api.z.ai/api/paas/v4" },
|
|
71293
71309
|
authOptions: [apiKey("ZAI_API_KEY", ["pi"])]
|
|
71294
71310
|
}
|
|
@@ -73582,7 +73598,7 @@ function parseClaudeLine(raw) {
|
|
|
73582
73598
|
return {
|
|
73583
73599
|
type,
|
|
73584
73600
|
sessionId: raw.session_id ? String(raw.session_id) : void 0,
|
|
73585
|
-
|
|
73601
|
+
resultText: typeof raw.result === "string" ? raw.result : void 0,
|
|
73586
73602
|
error: isError2 ? typeof raw.result === "string" ? raw.result : `Claude run ended with ${String(raw.subtype ?? "error")}` : void 0,
|
|
73587
73603
|
at: timestampOf(raw.timestamp),
|
|
73588
73604
|
usage: usage || cost !== void 0 ? {
|
|
@@ -73593,11 +73609,299 @@ function parseClaudeLine(raw) {
|
|
|
73593
73609
|
cost
|
|
73594
73610
|
} : void 0,
|
|
73595
73611
|
done: true,
|
|
73612
|
+
final: true,
|
|
73596
73613
|
detail: raw.subtype ? String(raw.subtype) : void 0
|
|
73597
73614
|
};
|
|
73598
73615
|
}
|
|
73599
73616
|
return { type };
|
|
73600
73617
|
}
|
|
73618
|
+
function cursorToolCall(raw) {
|
|
73619
|
+
const call = asRecord(raw.tool_call) ?? asRecord(raw.toolCall) ?? asRecord(raw.call);
|
|
73620
|
+
const direct = call && Object.keys(call).some((candidate) => candidate.endsWith("ToolCall")) ? call : null;
|
|
73621
|
+
const tool = asRecord(call?.tool) ?? asRecord(raw.tool) ?? direct;
|
|
73622
|
+
let caseName;
|
|
73623
|
+
let value = null;
|
|
73624
|
+
if (tool) {
|
|
73625
|
+
if (typeof tool.case === "string") {
|
|
73626
|
+
caseName = tool.case;
|
|
73627
|
+
value = asRecord(tool.value);
|
|
73628
|
+
} else {
|
|
73629
|
+
const key = Object.keys(tool).find((candidate) => candidate.endsWith("ToolCall"));
|
|
73630
|
+
if (key) {
|
|
73631
|
+
caseName = key;
|
|
73632
|
+
value = asRecord(tool[key]);
|
|
73633
|
+
}
|
|
73634
|
+
}
|
|
73635
|
+
}
|
|
73636
|
+
const labels = {
|
|
73637
|
+
readToolCall: "read",
|
|
73638
|
+
editToolCall: "edit",
|
|
73639
|
+
deleteToolCall: "delete",
|
|
73640
|
+
lsToolCall: "ls",
|
|
73641
|
+
grepToolCall: "grep",
|
|
73642
|
+
globToolCall: "glob",
|
|
73643
|
+
shellToolCall: "shell",
|
|
73644
|
+
taskToolCall: "task",
|
|
73645
|
+
mcpToolCall: "mcp",
|
|
73646
|
+
awaitToolCall: "await",
|
|
73647
|
+
askQuestionToolCall: "question"
|
|
73648
|
+
};
|
|
73649
|
+
const result = value?.result ?? value?.output ?? value?.error;
|
|
73650
|
+
return {
|
|
73651
|
+
name: caseName ? labels[caseName] ?? caseName.replace(/ToolCall$/, "") : void 0,
|
|
73652
|
+
args: value?.args ?? value?.input ?? value?.parameters,
|
|
73653
|
+
detail: result === void 0 ? void 0 : toolDetailText(result),
|
|
73654
|
+
callId: typeof call?.callId === "string" && call.callId || typeof call?.toolCallId === "string" && call.toolCallId || toolCallIdOf(raw) || toolCallIdOf(call ?? {})
|
|
73655
|
+
};
|
|
73656
|
+
}
|
|
73657
|
+
function toolDetailText(value) {
|
|
73658
|
+
if (value === void 0 || value === null) return void 0;
|
|
73659
|
+
if (typeof value === "string") return capToolOutput(value) || void 0;
|
|
73660
|
+
const record2 = asRecord(value);
|
|
73661
|
+
if (record2) {
|
|
73662
|
+
for (const key of ["stdout", "output", "text", "message", "error", "stderr"]) {
|
|
73663
|
+
const found = record2[key];
|
|
73664
|
+
if (typeof found === "string" && found) return capToolOutput(found);
|
|
73665
|
+
}
|
|
73666
|
+
const nested = asRecord(record2.result);
|
|
73667
|
+
if (nested) {
|
|
73668
|
+
const found = toolDetailText(nested);
|
|
73669
|
+
if (found) return found;
|
|
73670
|
+
}
|
|
73671
|
+
}
|
|
73672
|
+
try {
|
|
73673
|
+
return capToolOutput(JSON.stringify(value));
|
|
73674
|
+
} catch {
|
|
73675
|
+
return void 0;
|
|
73676
|
+
}
|
|
73677
|
+
}
|
|
73678
|
+
function parseCursorLine(raw) {
|
|
73679
|
+
const type = String(raw.type ?? "");
|
|
73680
|
+
const at3 = timestampOf(raw.timestamp_ms) ?? timestampOf(raw.timestamp);
|
|
73681
|
+
if (type === "system") {
|
|
73682
|
+
return { type, sessionId: raw.session_id ? String(raw.session_id) : void 0, at: at3 };
|
|
73683
|
+
}
|
|
73684
|
+
if (type === "assistant") {
|
|
73685
|
+
const message = raw.message;
|
|
73686
|
+
const text = message?.content?.filter((item) => item.type === "text").map((item) => item.text ?? "").join("\n");
|
|
73687
|
+
return { type, assistantText: text || void 0, at: at3 };
|
|
73688
|
+
}
|
|
73689
|
+
if (type === "thinking") {
|
|
73690
|
+
const subtype = String(raw.subtype ?? "");
|
|
73691
|
+
if (subtype === "delta") {
|
|
73692
|
+
return { type, thinkingText: String(raw.text ?? ""), thinkingDelta: true, at: at3 };
|
|
73693
|
+
}
|
|
73694
|
+
if (subtype === "completed") return { type, thinkingEnd: true, at: at3 };
|
|
73695
|
+
return { type, at: at3 };
|
|
73696
|
+
}
|
|
73697
|
+
if (type === "tool_call") {
|
|
73698
|
+
const tool = cursorToolCall(raw);
|
|
73699
|
+
const subtype = String(raw.subtype ?? "");
|
|
73700
|
+
return {
|
|
73701
|
+
type,
|
|
73702
|
+
toolName: tool.name,
|
|
73703
|
+
toolArgs: tool.args,
|
|
73704
|
+
toolResult: raw.tool_call ?? raw.toolCall,
|
|
73705
|
+
detail: subtype === "completed" ? tool.detail : void 0,
|
|
73706
|
+
toolCallId: tool.callId,
|
|
73707
|
+
toolStart: subtype === "started",
|
|
73708
|
+
toolPartial: false,
|
|
73709
|
+
at: at3
|
|
73710
|
+
};
|
|
73711
|
+
}
|
|
73712
|
+
if (type === "usage") {
|
|
73713
|
+
return { type, usage: extractUsage(raw), at: at3 };
|
|
73714
|
+
}
|
|
73715
|
+
if (type === "result") {
|
|
73716
|
+
const isError2 = typeof raw.is_error === "boolean" ? raw.is_error : raw.subtype !== "success";
|
|
73717
|
+
return {
|
|
73718
|
+
type,
|
|
73719
|
+
sessionId: raw.session_id ? String(raw.session_id) : void 0,
|
|
73720
|
+
resultText: typeof raw.result === "string" ? raw.result : void 0,
|
|
73721
|
+
error: isError2 ? typeof raw.result === "string" ? raw.result : `Cursor run ended with ${String(raw.subtype ?? "error")}` : void 0,
|
|
73722
|
+
usage: extractUsage(raw),
|
|
73723
|
+
done: true,
|
|
73724
|
+
final: true,
|
|
73725
|
+
at: at3
|
|
73726
|
+
};
|
|
73727
|
+
}
|
|
73728
|
+
return { type, at: at3 };
|
|
73729
|
+
}
|
|
73730
|
+
function parseGeminiLine(raw) {
|
|
73731
|
+
const type = String(raw.type ?? "");
|
|
73732
|
+
const at3 = timestampOf(raw.timestamp);
|
|
73733
|
+
if (type === "init") {
|
|
73734
|
+
return { type, sessionId: raw.session_id ? String(raw.session_id) : void 0, at: at3 };
|
|
73735
|
+
}
|
|
73736
|
+
if (type === "message") {
|
|
73737
|
+
const role = String(raw.role ?? "");
|
|
73738
|
+
if (role !== "assistant") return { type, at: at3 };
|
|
73739
|
+
const text = typeof raw.content === "string" ? raw.content : void 0;
|
|
73740
|
+
return { type, assistantText: text || void 0, assistantDelta: raw.delta === true, at: at3 };
|
|
73741
|
+
}
|
|
73742
|
+
if (type === "tool_use") {
|
|
73743
|
+
return {
|
|
73744
|
+
type,
|
|
73745
|
+
toolName: typeof raw.tool_name === "string" ? raw.tool_name : "tool",
|
|
73746
|
+
toolArgs: raw.parameters,
|
|
73747
|
+
toolCallId: typeof raw.tool_id === "string" ? raw.tool_id : void 0,
|
|
73748
|
+
toolStart: true,
|
|
73749
|
+
toolPartial: false,
|
|
73750
|
+
at: at3
|
|
73751
|
+
};
|
|
73752
|
+
}
|
|
73753
|
+
if (type === "result") {
|
|
73754
|
+
const stats = asRecord(raw.stats);
|
|
73755
|
+
const status = String(raw.status ?? "");
|
|
73756
|
+
const error63 = asRecord(raw.error);
|
|
73757
|
+
const number4 = (value) => {
|
|
73758
|
+
const parsed = Number(value);
|
|
73759
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
73760
|
+
};
|
|
73761
|
+
const input2 = number4(stats?.input_tokens);
|
|
73762
|
+
const output2 = number4(stats?.output_tokens);
|
|
73763
|
+
const cacheRead = number4(stats?.cached);
|
|
73764
|
+
return {
|
|
73765
|
+
type,
|
|
73766
|
+
sessionId: raw.session_id ? String(raw.session_id) : void 0,
|
|
73767
|
+
error: status === "error" ? typeof error63?.message === "string" ? error63.message : "Gemini run ended with an error" : void 0,
|
|
73768
|
+
usage: input2 || output2 || cacheRead ? { input: input2, output: output2, cacheRead } : void 0,
|
|
73769
|
+
done: true,
|
|
73770
|
+
final: status === "success",
|
|
73771
|
+
at: at3
|
|
73772
|
+
};
|
|
73773
|
+
}
|
|
73774
|
+
if (type === "error") {
|
|
73775
|
+
if (String(raw.severity ?? "error") !== "error") return { type, at: at3 };
|
|
73776
|
+
return {
|
|
73777
|
+
type,
|
|
73778
|
+
error: typeof raw.message === "string" ? raw.message : "Gemini run ended with an error",
|
|
73779
|
+
at: at3
|
|
73780
|
+
};
|
|
73781
|
+
}
|
|
73782
|
+
return { type, at: at3 };
|
|
73783
|
+
}
|
|
73784
|
+
function codexTool(item) {
|
|
73785
|
+
const itemType = String(item.type ?? "");
|
|
73786
|
+
const names = {
|
|
73787
|
+
command_execution: "shell",
|
|
73788
|
+
local_shell_call: "shell",
|
|
73789
|
+
file_change: "edit",
|
|
73790
|
+
patch: "edit",
|
|
73791
|
+
mcp_tool_call: "mcp",
|
|
73792
|
+
web_search: "web_search",
|
|
73793
|
+
todo_list: "todos",
|
|
73794
|
+
custom_tool_call: "tool"
|
|
73795
|
+
};
|
|
73796
|
+
const args = item.command !== void 0 ? { command: item.command } : item.arguments ?? item.input ?? item.changes ?? item.action;
|
|
73797
|
+
const detail = toolDetailText(item.aggregated_output) ?? toolDetailText(item.output) ?? toolDetailText(item.result) ?? toolDetailText(item.error);
|
|
73798
|
+
return { name: names[itemType] ?? itemType, args, detail };
|
|
73799
|
+
}
|
|
73800
|
+
function parseCodexLine(raw) {
|
|
73801
|
+
const type = String(raw.type ?? "");
|
|
73802
|
+
const at3 = timestampOf(raw.timestamp);
|
|
73803
|
+
if (type === "thread.started") {
|
|
73804
|
+
return { type, sessionId: raw.thread_id ? String(raw.thread_id) : void 0, at: at3 };
|
|
73805
|
+
}
|
|
73806
|
+
if (type === "turn.completed" || type === "turn.failed") {
|
|
73807
|
+
return {
|
|
73808
|
+
type,
|
|
73809
|
+
error: type === "turn.failed" ? extractError(raw) : void 0,
|
|
73810
|
+
usage: extractUsage(raw),
|
|
73811
|
+
done: true,
|
|
73812
|
+
final: type === "turn.completed",
|
|
73813
|
+
at: at3
|
|
73814
|
+
};
|
|
73815
|
+
}
|
|
73816
|
+
if (type.startsWith("item.")) {
|
|
73817
|
+
const item = asRecord(raw.item);
|
|
73818
|
+
if (!item) return { type, at: at3 };
|
|
73819
|
+
const itemType = String(item.type ?? "");
|
|
73820
|
+
if (itemType === "reasoning") {
|
|
73821
|
+
if (type !== "item.completed") return { type, at: at3 };
|
|
73822
|
+
const text = typeof item.text === "string" ? item.text : void 0;
|
|
73823
|
+
return { type, thinkingText: text || void 0, thinkingEnd: true, at: at3 };
|
|
73824
|
+
}
|
|
73825
|
+
if (itemType === "agent_message") {
|
|
73826
|
+
if (type !== "item.completed") return { type, at: at3 };
|
|
73827
|
+
const text = typeof item.text === "string" ? item.text : void 0;
|
|
73828
|
+
return { type, assistantText: text || void 0, at: at3 };
|
|
73829
|
+
}
|
|
73830
|
+
if (itemType === "error") {
|
|
73831
|
+
const text = typeof item.message === "string" ? item.message : void 0;
|
|
73832
|
+
return { type, error: text, at: at3 };
|
|
73833
|
+
}
|
|
73834
|
+
const tool = codexTool(item);
|
|
73835
|
+
if (!tool.name) return { type, at: at3 };
|
|
73836
|
+
const completed = type === "item.completed";
|
|
73837
|
+
return {
|
|
73838
|
+
type,
|
|
73839
|
+
toolName: tool.name,
|
|
73840
|
+
toolArgs: tool.args,
|
|
73841
|
+
toolResult: item,
|
|
73842
|
+
detail: completed ? tool.detail : void 0,
|
|
73843
|
+
toolCallId: typeof item.id === "string" ? item.id : void 0,
|
|
73844
|
+
toolStart: type === "item.started",
|
|
73845
|
+
toolPartial: type === "item.updated",
|
|
73846
|
+
at: at3
|
|
73847
|
+
};
|
|
73848
|
+
}
|
|
73849
|
+
if (type === "error") {
|
|
73850
|
+
return { type, error: extractError(raw), at: at3 };
|
|
73851
|
+
}
|
|
73852
|
+
return { type, at: at3 };
|
|
73853
|
+
}
|
|
73854
|
+
function parseOpencodeLine(raw) {
|
|
73855
|
+
const type = String(raw.type ?? "");
|
|
73856
|
+
const at3 = timestampOf(raw.timestamp);
|
|
73857
|
+
const part = asRecord(raw.part);
|
|
73858
|
+
if (type === "text") {
|
|
73859
|
+
const text = typeof part?.text === "string" ? part.text : void 0;
|
|
73860
|
+
return { type, assistantText: text || void 0, at: at3 };
|
|
73861
|
+
}
|
|
73862
|
+
if (type === "reasoning") {
|
|
73863
|
+
const text = typeof part?.text === "string" ? part.text : void 0;
|
|
73864
|
+
return { type, thinkingText: text || void 0, thinkingEnd: true, at: at3 };
|
|
73865
|
+
}
|
|
73866
|
+
if (type === "tool_use") {
|
|
73867
|
+
const state2 = asRecord(part?.state);
|
|
73868
|
+
const name2 = typeof part?.tool === "string" ? part.tool : void 0;
|
|
73869
|
+
const error63 = state2?.error;
|
|
73870
|
+
return {
|
|
73871
|
+
type,
|
|
73872
|
+
toolName: name2,
|
|
73873
|
+
toolArgs: state2?.input,
|
|
73874
|
+
toolResult: state2,
|
|
73875
|
+
detail: toolDetailText(state2?.output) ?? toolDetailText(error63),
|
|
73876
|
+
toolCallId: typeof part?.callID === "string" && part.callID || typeof part?.id === "string" && part.id || void 0,
|
|
73877
|
+
toolStart: true,
|
|
73878
|
+
toolPartial: false,
|
|
73879
|
+
at: at3
|
|
73880
|
+
};
|
|
73881
|
+
}
|
|
73882
|
+
if (type === "step_finish") {
|
|
73883
|
+
const tokens3 = asRecord(part?.tokens) ?? asRecord(part?.token_usage);
|
|
73884
|
+
const number4 = (value) => {
|
|
73885
|
+
const parsed = Number(value);
|
|
73886
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
73887
|
+
};
|
|
73888
|
+
const cache = asRecord(tokens3?.cache);
|
|
73889
|
+
const input2 = number4(tokens3?.input);
|
|
73890
|
+
const output2 = number4(tokens3?.output);
|
|
73891
|
+
const cacheRead = number4(cache?.read);
|
|
73892
|
+
const cacheWrite = number4(cache?.write);
|
|
73893
|
+
const cost = number4(part?.cost);
|
|
73894
|
+
return {
|
|
73895
|
+
type,
|
|
73896
|
+
usage: input2 || output2 || cacheRead || cacheWrite || cost ? { input: input2, output: output2, cacheRead, cacheWrite, cost } : void 0,
|
|
73897
|
+
at: at3
|
|
73898
|
+
};
|
|
73899
|
+
}
|
|
73900
|
+
if (type === "error") {
|
|
73901
|
+
return { type, error: extractError(raw), at: at3 };
|
|
73902
|
+
}
|
|
73903
|
+
return { type, at: at3 };
|
|
73904
|
+
}
|
|
73601
73905
|
function asRecord(value) {
|
|
73602
73906
|
return value && typeof value === "object" ? value : null;
|
|
73603
73907
|
}
|
|
@@ -73675,9 +73979,17 @@ function extractUsage(raw) {
|
|
|
73675
73979
|
if (!usage) return void 0;
|
|
73676
73980
|
const input2 = Number(usage.input_tokens ?? usage.inputTokens ?? usage.prompt_tokens ?? usage.input ?? 0) || void 0;
|
|
73677
73981
|
const output2 = Number(usage.output_tokens ?? usage.outputTokens ?? usage.completion_tokens ?? usage.output ?? 0) || void 0;
|
|
73982
|
+
const cacheRead = Number(
|
|
73983
|
+
usage.cache_read_input_tokens ?? usage.cacheReadTokens ?? usage.cached_input_tokens ?? usage.cached_tokens ?? usage.cached ?? 0
|
|
73984
|
+
) || void 0;
|
|
73985
|
+
const cacheWrite = Number(
|
|
73986
|
+
usage.cache_creation_input_tokens ?? usage.cacheWriteTokens ?? usage.cache_write_tokens ?? 0
|
|
73987
|
+
) || void 0;
|
|
73678
73988
|
const cost = typeof usage.cost === "number" ? usage.cost : typeof usage.total_cost_usd === "number" ? usage.total_cost_usd : typeof raw.total_cost_usd === "number" ? raw.total_cost_usd : void 0;
|
|
73679
|
-
if (input2 === void 0 && output2 === void 0 &&
|
|
73680
|
-
|
|
73989
|
+
if (input2 === void 0 && output2 === void 0 && cacheRead === void 0 && cacheWrite === void 0 && cost === void 0) {
|
|
73990
|
+
return void 0;
|
|
73991
|
+
}
|
|
73992
|
+
return { input: input2, output: output2, cacheRead, cacheWrite, cost };
|
|
73681
73993
|
}
|
|
73682
73994
|
function parseStructuredLine(raw) {
|
|
73683
73995
|
const type = String(raw.type ?? raw.event ?? raw.kind ?? "");
|
|
@@ -73703,6 +74015,10 @@ function parseDriverLine(driver, line) {
|
|
|
73703
74015
|
}
|
|
73704
74016
|
if (driver === "pi") return parsePiLine(raw);
|
|
73705
74017
|
if (driver === "claude") return parseClaudeLine(raw);
|
|
74018
|
+
if (driver === "cursor") return parseCursorLine(raw);
|
|
74019
|
+
if (driver === "gemini") return parseGeminiLine(raw);
|
|
74020
|
+
if (driver === "codex") return parseCodexLine(raw);
|
|
74021
|
+
if (driver === "opencode") return parseOpencodeLine(raw);
|
|
73706
74022
|
return parseStructuredLine(raw);
|
|
73707
74023
|
}
|
|
73708
74024
|
|
|
@@ -85991,6 +86307,7 @@ async function runRemoteCardJob(deps) {
|
|
|
85991
86307
|
let lastThinkingFlushAt = 0;
|
|
85992
86308
|
let chatMessageId = null;
|
|
85993
86309
|
let finalMessage = "";
|
|
86310
|
+
let assistantTextSeen = false;
|
|
85994
86311
|
let toolCalls = 0;
|
|
85995
86312
|
const lastToolUpdateAt = /* @__PURE__ */ new Map();
|
|
85996
86313
|
let consumeQueue = Promise.resolve();
|
|
@@ -86089,6 +86406,18 @@ async function runRemoteCardJob(deps) {
|
|
|
86089
86406
|
await flushThinking(true);
|
|
86090
86407
|
thinkingText = "";
|
|
86091
86408
|
}
|
|
86409
|
+
if (parsed.resultText) {
|
|
86410
|
+
finalMessage = parsed.resultText;
|
|
86411
|
+
if (!assistantTextSeen) {
|
|
86412
|
+
await flushThinking(true);
|
|
86413
|
+
await flushAssistant(true);
|
|
86414
|
+
await emitLive([{ eventType: "assistant", text: parsed.resultText, messageId: messageSeq }]);
|
|
86415
|
+
await appendChat(parsed.resultText);
|
|
86416
|
+
chatMessageId = null;
|
|
86417
|
+
assistantTextSeen = true;
|
|
86418
|
+
messageSeq += 1;
|
|
86419
|
+
}
|
|
86420
|
+
}
|
|
86092
86421
|
if (parsed.assistantText) {
|
|
86093
86422
|
await flushThinking(true);
|
|
86094
86423
|
const text = parsed.assistantText;
|
|
@@ -86104,6 +86433,7 @@ async function runRemoteCardJob(deps) {
|
|
|
86104
86433
|
await appendChat(text);
|
|
86105
86434
|
chatMessageId = null;
|
|
86106
86435
|
}
|
|
86436
|
+
if (text.trim()) assistantTextSeen = true;
|
|
86107
86437
|
}
|
|
86108
86438
|
if (parsed.messageEnd) {
|
|
86109
86439
|
await flushAssistant(true);
|