@standardagents/builder 0.40.10 → 0.40.12
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/dist/built-in-routes.js +462 -318
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-DW_rcgbf.js → ApiKeysView-CLJcSURO.js} +1 -1
- package/dist/client/{CenteredContentView-BwxhThjf.js → CenteredContentView-Doo-25XV.js} +1 -1
- package/dist/client/{CompositionView-DQQloYHA.js → CompositionView-DkL-88Do.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-DCZCVtJJ.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-DX3R4n1_.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-DPaK8ZgZ.js → CopyButton.vue_vue_type_script_setup_true_lang-DdUwJPW0.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-oU3rezOQ.js → DataTable.vue_vue_type_script_setup_true_lang-DKoKf8B6.js} +1 -1
- package/dist/client/{JsonViewer-Dd0PDdAu.js → JsonViewer-jsOg5DGq.js} +1 -1
- package/dist/client/{LoginView-BoUWDaYZ.js → LoginView-BNjka0iU.js} +1 -1
- package/dist/client/{MarketplaceView-Dq3arYjz.js → MarketplaceView-3UAub3nO.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-CwLmWuhx.js → Modal.vue_vue_type_script_setup_true_lang-qePAuq2r.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-ByVG_rEF.js → ModelModal.vue_vue_type_script_setup_true_lang-C5XxfCnh.js} +1 -1
- package/dist/client/{ModelsView-CNxZxuMY.js → ModelsView-Bud7F6og.js} +1 -1
- package/dist/client/{PromptEditView-CdALsRZ0.js → PromptEditView-Bjk45d3C.js} +1 -1
- package/dist/client/{PromptModal-Bg9-3prv.js → PromptModal-B9vO98yn.js} +1 -1
- package/dist/client/{PromptsView-BgumN2bU.js → PromptsView-BxllDChd.js} +1 -1
- package/dist/client/{ProvidersView-C9UvETp8.js → ProvidersView-DdwP0tM3.js} +1 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CpDJMTFJ.js +22 -0
- package/dist/client/{ThreadsView-G7WPUvXx.js → ThreadsView-R3VsT9cU.js} +1 -1
- package/dist/client/{ToolsView-VXM-IHXM.js → ToolsView-DfLtZHdm.js} +1 -1
- package/dist/client/{UsersView-C_LlI9x0.js → UsersView-9oV0DT6V.js} +1 -1
- package/dist/client/{VariablesView-BlsswVjj.js → VariablesView-Dg1ysfpJ.js} +1 -1
- package/dist/client/assets/{ThreadInspectorPane-CKH1L6Sn.css → ThreadInspectorPane-D5-ZEb8g.css} +1 -1
- package/dist/client/assets/index-kdYdNUXS.css +1 -0
- package/dist/client/{index-CRZrWTvf.js → index-CtrlevjG.js} +2 -2
- package/dist/client/index.html +2 -2
- package/dist/{index-DYhbT5Eq.d.ts → index-sEfQVa91.d.ts} +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +529 -359
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +4 -0
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +10 -2
- package/dist/runtime.js +525 -359
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-BNKZouHJ.js +0 -22
- package/dist/client/assets/index-DAABRRAA.css +0 -1
package/dist/runtime.js
CHANGED
|
@@ -489,6 +489,7 @@ var init_logBroadcast = __esm({
|
|
|
489
489
|
"message_id",
|
|
490
490
|
"provider",
|
|
491
491
|
"actual_provider",
|
|
492
|
+
"standard_agents_router_used",
|
|
492
493
|
"model",
|
|
493
494
|
"model_name",
|
|
494
495
|
"prompt_name",
|
|
@@ -499,6 +500,7 @@ var init_logBroadcast = __esm({
|
|
|
499
500
|
"retry_of_log_id",
|
|
500
501
|
"error",
|
|
501
502
|
"error_type",
|
|
503
|
+
"error_origin",
|
|
502
504
|
"finish_reason",
|
|
503
505
|
"cost_total",
|
|
504
506
|
"cost_input",
|
|
@@ -521,6 +523,71 @@ var init_logBroadcast = __esm({
|
|
|
521
523
|
];
|
|
522
524
|
}
|
|
523
525
|
});
|
|
526
|
+
|
|
527
|
+
// src/agents/errorOrigin.ts
|
|
528
|
+
function normalizedOrigin(value) {
|
|
529
|
+
if (typeof value !== "string") return void 0;
|
|
530
|
+
const origin = value.trim();
|
|
531
|
+
return ERROR_ORIGIN_PATTERN.test(origin) ? origin : void 0;
|
|
532
|
+
}
|
|
533
|
+
function normalizedUpstream(value) {
|
|
534
|
+
if (typeof value !== "string") return void 0;
|
|
535
|
+
const upstream = value.trim();
|
|
536
|
+
return upstream.length > 0 ? upstream : void 0;
|
|
537
|
+
}
|
|
538
|
+
function errorObject(error) {
|
|
539
|
+
return error !== null && (typeof error === "object" || typeof error === "function") ? error : null;
|
|
540
|
+
}
|
|
541
|
+
function resolveErrorAttribution(error, context = {}) {
|
|
542
|
+
const object = errorObject(error);
|
|
543
|
+
const stored = object?.[ATTRIBUTION];
|
|
544
|
+
if (stored) return stored;
|
|
545
|
+
const taggedOrigin = normalizedOrigin(object?.origin);
|
|
546
|
+
const provider = normalizedUpstream(object?.upstream) ?? normalizedUpstream(context.provider);
|
|
547
|
+
const standardAgentsRouterUsed = context.viaPlatform === true;
|
|
548
|
+
if (taggedOrigin) {
|
|
549
|
+
return {
|
|
550
|
+
origin: taggedOrigin,
|
|
551
|
+
...provider ? { upstream: provider } : {},
|
|
552
|
+
standardAgentsRouterUsed
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
if (provider) {
|
|
556
|
+
return {
|
|
557
|
+
origin: standardAgentsRouterUsed ? "platform-router" : `provider:${provider}`,
|
|
558
|
+
upstream: provider,
|
|
559
|
+
standardAgentsRouterUsed
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return {
|
|
563
|
+
origin: context.fallback ?? "runtime",
|
|
564
|
+
standardAgentsRouterUsed
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
function attributeThrownError(error, context) {
|
|
568
|
+
const attributed = errorObject(error) ?? new Error(String(error));
|
|
569
|
+
const attribution = resolveErrorAttribution(attributed, context);
|
|
570
|
+
try {
|
|
571
|
+
Object.defineProperty(attributed, ATTRIBUTION, {
|
|
572
|
+
configurable: true,
|
|
573
|
+
value: attribution
|
|
574
|
+
});
|
|
575
|
+
return attributed;
|
|
576
|
+
} catch {
|
|
577
|
+
const wrapped = new Error(error instanceof Error ? error.message : String(error), {
|
|
578
|
+
cause: error
|
|
579
|
+
});
|
|
580
|
+
Object.defineProperty(wrapped, ATTRIBUTION, { value: attribution });
|
|
581
|
+
return wrapped;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
var ATTRIBUTION, ERROR_ORIGIN_PATTERN;
|
|
585
|
+
var init_errorOrigin = __esm({
|
|
586
|
+
"src/agents/errorOrigin.ts"() {
|
|
587
|
+
ATTRIBUTION = Symbol("standard-agents-error-attribution");
|
|
588
|
+
ERROR_ORIGIN_PATTERN = /^(?:platform-router|runtime|(?:provider|tool|hook):[A-Za-z0-9._/@-]+)$/;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
524
591
|
var init_types2 = __esm({
|
|
525
592
|
"src/agents/providers/types.ts"() {
|
|
526
593
|
}
|
|
@@ -1821,6 +1888,7 @@ var init_LLMRequest = __esm({
|
|
|
1821
1888
|
init_FlowEngine();
|
|
1822
1889
|
init_toolProgress();
|
|
1823
1890
|
init_logBroadcast();
|
|
1891
|
+
init_errorOrigin();
|
|
1824
1892
|
NON_VISION_PLACEHOLDER_TEXT = "[Image omitted: model does not support vision]";
|
|
1825
1893
|
STREAM_FIRST_CHUNK_TIMEOUT_MS = 12e4;
|
|
1826
1894
|
STREAM_STALL_TIMEOUT_MS = 45e3;
|
|
@@ -2118,6 +2186,7 @@ var init_LLMRequest = __esm({
|
|
|
2118
2186
|
state.thread.instance,
|
|
2119
2187
|
getThreadState
|
|
2120
2188
|
);
|
|
2189
|
+
await this.logProviderRoute(state, logId, provider.name, viaPlatform);
|
|
2121
2190
|
const streamAbort = new AbortController();
|
|
2122
2191
|
const parentSignal = state.abortController?.signal;
|
|
2123
2192
|
let onParentAbort;
|
|
@@ -2131,332 +2200,370 @@ var init_LLMRequest = __esm({
|
|
|
2131
2200
|
}
|
|
2132
2201
|
const request = buildProviderRequest(context, modelDef, streamAbort.signal, state.threadId);
|
|
2133
2202
|
let response;
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
lastEmittedChars
|
|
2203
|
+
try {
|
|
2204
|
+
await state.stream.waitFor(
|
|
2205
|
+
async () => {
|
|
2206
|
+
const requestSentAt = Date.now();
|
|
2207
|
+
const firstChunkTimeoutMs = resolveStreamTimeoutMs(
|
|
2208
|
+
state.env,
|
|
2209
|
+
"STANDARD_AGENTS_STREAM_FIRST_CHUNK_TIMEOUT_MS",
|
|
2210
|
+
STREAM_FIRST_CHUNK_TIMEOUT_MS
|
|
2211
|
+
);
|
|
2212
|
+
const stallTimeoutMs = resolveStreamTimeoutMs(
|
|
2213
|
+
state.env,
|
|
2214
|
+
"STANDARD_AGENTS_STREAM_STALL_TIMEOUT_MS",
|
|
2215
|
+
STREAM_STALL_TIMEOUT_MS
|
|
2216
|
+
);
|
|
2217
|
+
let stalled = false;
|
|
2218
|
+
const stallError = (budgetMs) => new ProviderError(
|
|
2219
|
+
`Provider sent no chunk for ${Math.round(budgetMs / 1e3)}s`,
|
|
2220
|
+
"timeout"
|
|
2221
|
+
);
|
|
2222
|
+
const awaitWithStallGuard = (work, budgetMs) => {
|
|
2223
|
+
let timer;
|
|
2224
|
+
work.catch(() => {
|
|
2225
|
+
});
|
|
2226
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
2227
|
+
timer = setTimeout(() => {
|
|
2228
|
+
stalled = true;
|
|
2229
|
+
reject(stallError(budgetMs));
|
|
2230
|
+
streamAbort.abort();
|
|
2231
|
+
}, budgetMs);
|
|
2232
|
+
});
|
|
2233
|
+
return Promise.race([work, timeout]).finally(() => {
|
|
2234
|
+
if (timer) clearTimeout(timer);
|
|
2235
|
+
});
|
|
2236
|
+
};
|
|
2237
|
+
const stream = await awaitWithStallGuard(provider.stream(request), firstChunkTimeoutMs);
|
|
2238
|
+
let content = "";
|
|
2239
|
+
let reasoning = "";
|
|
2240
|
+
let outputChars = 0;
|
|
2241
|
+
let lastEmittedChars = 0;
|
|
2242
|
+
const GEN_EMIT_STEP = 80;
|
|
2243
|
+
const maybeEmitGeneration = () => {
|
|
2244
|
+
if (outputChars - lastEmittedChars >= GEN_EMIT_STEP) {
|
|
2245
|
+
lastEmittedChars = outputChars;
|
|
2246
|
+
try {
|
|
2247
|
+
state.emitEvent?.("generation", { outputTokens: Math.ceil(outputChars / 4) });
|
|
2248
|
+
} catch {
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
const toolCallsMap = /* @__PURE__ */ new Map();
|
|
2253
|
+
const images = [];
|
|
2254
|
+
const webSearches = [];
|
|
2255
|
+
const providerToolCalls = [];
|
|
2256
|
+
let finishReason = "stop";
|
|
2257
|
+
let usage;
|
|
2258
|
+
let reasoningDetails;
|
|
2259
|
+
let actualProvider;
|
|
2260
|
+
let providerResponseId;
|
|
2261
|
+
let firstChunkAt = 0;
|
|
2262
|
+
let firstTokenAt = 0;
|
|
2263
|
+
let lastTokenAt = 0;
|
|
2264
|
+
const noteToken = () => {
|
|
2265
|
+
const now = Date.now();
|
|
2266
|
+
if (firstTokenAt === 0) firstTokenAt = now;
|
|
2267
|
+
lastTokenAt = now;
|
|
2268
|
+
};
|
|
2269
|
+
const emitLogPatch = (data) => {
|
|
2176
2270
|
try {
|
|
2177
|
-
state.
|
|
2271
|
+
state.emitLog?.({ type: "log_data", log_id: logId, data: { id: logId, ...data } });
|
|
2178
2272
|
} catch {
|
|
2179
2273
|
}
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
const now = Date.now();
|
|
2195
|
-
if (firstTokenAt === 0) firstTokenAt = now;
|
|
2196
|
-
lastTokenAt = now;
|
|
2197
|
-
};
|
|
2198
|
-
const emitLogPatch = (data) => {
|
|
2274
|
+
};
|
|
2275
|
+
const streamedToolNames = [];
|
|
2276
|
+
let lastPreviewChars = 0;
|
|
2277
|
+
const PREVIEW_EMIT_STEP = 80;
|
|
2278
|
+
const maybeEmitPreview = () => {
|
|
2279
|
+
if (outputChars - lastPreviewChars >= PREVIEW_EMIT_STEP) {
|
|
2280
|
+
lastPreviewChars = outputChars;
|
|
2281
|
+
emitLogPatch({
|
|
2282
|
+
content: content || null,
|
|
2283
|
+
reasoning_content: reasoning || null
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
const iterator = stream[Symbol.asyncIterator]();
|
|
2199
2288
|
try {
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
};
|
|
2216
|
-
const iterator = stream[Symbol.asyncIterator]();
|
|
2217
|
-
try {
|
|
2218
|
-
while (true) {
|
|
2219
|
-
if (state.abortController?.signal?.aborted) break;
|
|
2220
|
-
if (await state.thread.instance.shouldStop()) break;
|
|
2221
|
-
let next;
|
|
2222
|
-
try {
|
|
2223
|
-
next = await awaitWithStallGuard(
|
|
2224
|
-
iterator.next(),
|
|
2225
|
-
firstChunkAt === 0 ? firstChunkTimeoutMs : stallTimeoutMs
|
|
2226
|
-
);
|
|
2227
|
-
} catch (streamErr) {
|
|
2228
|
-
if (stalled) throw streamErr;
|
|
2229
|
-
if (state.abortController?.signal?.aborted || await state.thread.instance.shouldStop()) {
|
|
2230
|
-
break;
|
|
2289
|
+
while (true) {
|
|
2290
|
+
if (state.abortController?.signal?.aborted) break;
|
|
2291
|
+
if (await state.thread.instance.shouldStop()) break;
|
|
2292
|
+
let next;
|
|
2293
|
+
try {
|
|
2294
|
+
next = await awaitWithStallGuard(
|
|
2295
|
+
iterator.next(),
|
|
2296
|
+
firstChunkAt === 0 ? firstChunkTimeoutMs : stallTimeoutMs
|
|
2297
|
+
);
|
|
2298
|
+
} catch (streamErr) {
|
|
2299
|
+
if (stalled) throw streamErr;
|
|
2300
|
+
if (state.abortController?.signal?.aborted || await state.thread.instance.shouldStop()) {
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
throw streamErr;
|
|
2231
2304
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
this.emitContentChunk(chunk.delta, state);
|
|
2246
|
-
outputChars += chunk.delta.length;
|
|
2247
|
-
noteToken();
|
|
2248
|
-
maybeEmitGeneration();
|
|
2249
|
-
maybeEmitPreview();
|
|
2250
|
-
break;
|
|
2251
|
-
case "reasoning-delta":
|
|
2252
|
-
reasoning += chunk.delta;
|
|
2253
|
-
this.emitReasoningChunk(chunk.delta, state);
|
|
2254
|
-
outputChars += chunk.delta.length;
|
|
2255
|
-
noteToken();
|
|
2256
|
-
maybeEmitGeneration();
|
|
2257
|
-
maybeEmitPreview();
|
|
2258
|
-
break;
|
|
2259
|
-
case "tool-call-start":
|
|
2260
|
-
{
|
|
2305
|
+
if (next.done) break;
|
|
2306
|
+
const chunk = next.value;
|
|
2307
|
+
state.thread.instance.noteExecutionProgress?.();
|
|
2308
|
+
if (firstChunkAt === 0 && chunkCarriesPayload(chunk)) {
|
|
2309
|
+
firstChunkAt = Date.now();
|
|
2310
|
+
emitLogPatch({ time_to_first_token_ms: firstChunkAt - requestSentAt });
|
|
2311
|
+
}
|
|
2312
|
+
switch (chunk.type) {
|
|
2313
|
+
case "content-delta":
|
|
2314
|
+
content += chunk.delta;
|
|
2315
|
+
state.stream.sendContent(chunk.delta);
|
|
2316
|
+
this.emitContentChunk(chunk.delta, state);
|
|
2317
|
+
outputChars += chunk.delta.length;
|
|
2261
2318
|
noteToken();
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
const progressArg = await this.resolveProgressArgument(state, chunk.name);
|
|
2276
|
-
if (progressArg) {
|
|
2277
|
-
entry.progressArg = progressArg;
|
|
2278
|
-
} else {
|
|
2279
|
-
await this.fireToolCallStarted(state, entry, void 0);
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
break;
|
|
2283
|
-
case "tool-call-delta":
|
|
2284
|
-
{
|
|
2285
|
-
const tc = toolCallsMap.get(chunk.id);
|
|
2286
|
-
if (tc) {
|
|
2287
|
-
tc.argumentsDelta += chunk.argumentsDelta;
|
|
2288
|
-
outputChars += chunk.argumentsDelta.length;
|
|
2319
|
+
maybeEmitGeneration();
|
|
2320
|
+
maybeEmitPreview();
|
|
2321
|
+
break;
|
|
2322
|
+
case "reasoning-delta":
|
|
2323
|
+
reasoning += chunk.delta;
|
|
2324
|
+
this.emitReasoningChunk(chunk.delta, state);
|
|
2325
|
+
outputChars += chunk.delta.length;
|
|
2326
|
+
noteToken();
|
|
2327
|
+
maybeEmitGeneration();
|
|
2328
|
+
maybeEmitPreview();
|
|
2329
|
+
break;
|
|
2330
|
+
case "tool-call-start":
|
|
2331
|
+
{
|
|
2289
2332
|
noteToken();
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2333
|
+
const entry = {
|
|
2334
|
+
id: chunk.id,
|
|
2335
|
+
name: chunk.name,
|
|
2336
|
+
argumentsDelta: "",
|
|
2337
|
+
extraContent: chunk.extraContent,
|
|
2338
|
+
startedFired: false,
|
|
2339
|
+
progressArg: void 0
|
|
2340
|
+
};
|
|
2341
|
+
toolCallsMap.set(chunk.id, entry);
|
|
2342
|
+
if (chunk.name) {
|
|
2343
|
+
streamedToolNames.push(chunk.name);
|
|
2344
|
+
emitLogPatch({ tools_called: JSON.stringify(streamedToolNames) });
|
|
2345
|
+
}
|
|
2346
|
+
const progressArg = await this.resolveProgressArgument(state, chunk.name);
|
|
2347
|
+
if (progressArg) {
|
|
2348
|
+
entry.progressArg = progressArg;
|
|
2349
|
+
} else {
|
|
2350
|
+
await this.fireToolCallStarted(state, entry, void 0);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
break;
|
|
2354
|
+
case "tool-call-delta":
|
|
2355
|
+
{
|
|
2356
|
+
const tc = toolCallsMap.get(chunk.id);
|
|
2357
|
+
if (tc) {
|
|
2358
|
+
tc.argumentsDelta += chunk.argumentsDelta;
|
|
2359
|
+
outputChars += chunk.argumentsDelta.length;
|
|
2360
|
+
noteToken();
|
|
2361
|
+
maybeEmitGeneration();
|
|
2362
|
+
if (tc.progressArg && !tc.startedFired && tc.argumentsDelta.length <= PROGRESS_ARG_SCAN_CAP) {
|
|
2363
|
+
const value = await readCompletedArg(tc.argumentsDelta, tc.progressArg);
|
|
2364
|
+
if (value !== void 0) {
|
|
2365
|
+
await this.fireToolCallStarted(state, tc, value);
|
|
2366
|
+
}
|
|
2295
2367
|
}
|
|
2296
2368
|
}
|
|
2297
2369
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2370
|
+
break;
|
|
2371
|
+
case "tool-call-done":
|
|
2372
|
+
{
|
|
2373
|
+
const existing = toolCallsMap.get(chunk.id);
|
|
2374
|
+
toolCallsMap.set(chunk.id, {
|
|
2375
|
+
...existing,
|
|
2376
|
+
id: chunk.id,
|
|
2377
|
+
name: existing?.name ?? "",
|
|
2378
|
+
argumentsDelta: JSON.stringify(chunk.arguments),
|
|
2379
|
+
extraContent: chunk.extraContent ?? existing?.extraContent
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
break;
|
|
2383
|
+
case "finish":
|
|
2384
|
+
finishReason = chunk.finishReason;
|
|
2385
|
+
usage = chunk.usage;
|
|
2386
|
+
reasoningDetails = chunk.reasoningDetails;
|
|
2387
|
+
providerResponseId = chunk.responseId;
|
|
2388
|
+
break;
|
|
2389
|
+
case "image-done":
|
|
2390
|
+
images.push({
|
|
2391
|
+
id: chunk.image.id,
|
|
2392
|
+
toolName: chunk.image.toolName,
|
|
2393
|
+
data: chunk.image.data,
|
|
2394
|
+
mediaType: chunk.image.mediaType,
|
|
2395
|
+
revisedPrompt: chunk.image.revisedPrompt
|
|
2309
2396
|
});
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
chunk.error,
|
|
2336
|
-
chunk.code || "unknown"
|
|
2397
|
+
break;
|
|
2398
|
+
case "web-search-done":
|
|
2399
|
+
webSearches.push(chunk.result);
|
|
2400
|
+
break;
|
|
2401
|
+
case "provider-tool-done":
|
|
2402
|
+
providerToolCalls.push(chunk.tool);
|
|
2403
|
+
break;
|
|
2404
|
+
case "error":
|
|
2405
|
+
throw new ProviderError(
|
|
2406
|
+
chunk.error,
|
|
2407
|
+
chunk.code || "unknown"
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
} finally {
|
|
2412
|
+
if (onParentAbort && parentSignal) {
|
|
2413
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
2414
|
+
}
|
|
2415
|
+
try {
|
|
2416
|
+
const cleanup = iterator.return?.();
|
|
2417
|
+
if (cleanup) {
|
|
2418
|
+
await awaitBounded(
|
|
2419
|
+
Promise.resolve(cleanup),
|
|
2420
|
+
STREAM_CLEANUP_BUDGET_MS,
|
|
2421
|
+
"stream iterator cleanup"
|
|
2337
2422
|
);
|
|
2423
|
+
}
|
|
2424
|
+
} catch {
|
|
2338
2425
|
}
|
|
2339
2426
|
}
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
try {
|
|
2345
|
-
const cleanup = iterator.return?.();
|
|
2346
|
-
if (cleanup) {
|
|
2347
|
-
await awaitBounded(
|
|
2348
|
-
Promise.resolve(cleanup),
|
|
2349
|
-
STREAM_CLEANUP_BUDGET_MS,
|
|
2350
|
-
"stream iterator cleanup"
|
|
2351
|
-
);
|
|
2427
|
+
for (const tc of toolCallsMap.values()) {
|
|
2428
|
+
if (!tc.startedFired) {
|
|
2429
|
+
const progress = tc.progressArg ? await readCompletedArg(tc.argumentsDelta, tc.progressArg) : void 0;
|
|
2430
|
+
await this.fireToolCallStarted(state, tc, progress);
|
|
2352
2431
|
}
|
|
2353
|
-
} catch {
|
|
2354
2432
|
}
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
toolCalls.push({
|
|
2373
|
-
id: tc.id,
|
|
2374
|
-
name: tc.name,
|
|
2375
|
-
arguments: {},
|
|
2376
|
-
extraContent: tc.extraContent
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
const responseId = `res_${crypto.randomUUID().substring(0, 12)}`;
|
|
2381
|
-
const responseImages = images.length > 0 ? images.map((img) => ({
|
|
2382
|
-
type: "image_url",
|
|
2383
|
-
id: img.id,
|
|
2384
|
-
toolName: img.toolName,
|
|
2385
|
-
image_url: {
|
|
2386
|
-
url: img.data.startsWith("data:") ? img.data : `data:${img.mediaType};base64,${img.data}`
|
|
2387
|
-
}
|
|
2388
|
-
})) : void 0;
|
|
2389
|
-
response = {
|
|
2390
|
-
id: responseId,
|
|
2391
|
-
model: modelName,
|
|
2392
|
-
content: content || null,
|
|
2393
|
-
reasoning_content: reasoning || null,
|
|
2394
|
-
reasoning_details: reasoningDetails,
|
|
2395
|
-
// Include reasoning details for multi-turn context
|
|
2396
|
-
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2397
|
-
images: responseImages,
|
|
2398
|
-
finish_reason: finishReason,
|
|
2399
|
-
usage: usage ? convertUsage(usage) : {
|
|
2400
|
-
prompt_tokens: 0,
|
|
2401
|
-
completion_tokens: 0,
|
|
2402
|
-
total_tokens: 0
|
|
2433
|
+
const toolCalls = [];
|
|
2434
|
+
for (const tc of toolCallsMap.values()) {
|
|
2435
|
+
try {
|
|
2436
|
+
toolCalls.push({
|
|
2437
|
+
id: tc.id,
|
|
2438
|
+
name: tc.name,
|
|
2439
|
+
arguments: JSON.parse(tc.argumentsDelta || "{}"),
|
|
2440
|
+
extraContent: tc.extraContent
|
|
2441
|
+
});
|
|
2442
|
+
} catch {
|
|
2443
|
+
toolCalls.push({
|
|
2444
|
+
id: tc.id,
|
|
2445
|
+
name: tc.name,
|
|
2446
|
+
arguments: {},
|
|
2447
|
+
extraContent: tc.extraContent
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2403
2450
|
}
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2451
|
+
const responseId = `res_${crypto.randomUUID().substring(0, 12)}`;
|
|
2452
|
+
const responseImages = images.length > 0 ? images.map((img) => ({
|
|
2453
|
+
type: "image_url",
|
|
2454
|
+
id: img.id,
|
|
2455
|
+
toolName: img.toolName,
|
|
2456
|
+
image_url: {
|
|
2457
|
+
url: img.data.startsWith("data:") ? img.data : `data:${img.mediaType};base64,${img.data}`
|
|
2458
|
+
}
|
|
2459
|
+
})) : void 0;
|
|
2460
|
+
response = {
|
|
2461
|
+
id: responseId,
|
|
2462
|
+
model: modelName,
|
|
2463
|
+
content: content || null,
|
|
2464
|
+
reasoning_content: reasoning || null,
|
|
2465
|
+
reasoning_details: reasoningDetails,
|
|
2466
|
+
// Include reasoning details for multi-turn context
|
|
2467
|
+
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2468
|
+
images: responseImages,
|
|
2469
|
+
finish_reason: finishReason,
|
|
2470
|
+
usage: usage ? convertUsage(usage) : {
|
|
2471
|
+
prompt_tokens: 0,
|
|
2472
|
+
completion_tokens: 0,
|
|
2473
|
+
total_tokens: 0
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
response._provider = provider;
|
|
2477
|
+
response._viaPlatform = viaPlatform;
|
|
2478
|
+
if (platformProxyOrigin) {
|
|
2479
|
+
const feePercent = getObservedRouterFeePercent(platformProxyOrigin);
|
|
2480
|
+
if (feePercent !== null) {
|
|
2481
|
+
response._routerFeePercent = feePercent;
|
|
2482
|
+
}
|
|
2411
2483
|
}
|
|
2484
|
+
response._providerResponseId = providerResponseId;
|
|
2485
|
+
response._timing = {
|
|
2486
|
+
latencyMs: firstChunkAt > 0 ? firstChunkAt - requestSentAt : null,
|
|
2487
|
+
generationMs: firstTokenAt > 0 ? Math.max(0, lastTokenAt - firstTokenAt) : null
|
|
2488
|
+
};
|
|
2489
|
+
response._aggregate_response = {
|
|
2490
|
+
id: responseId,
|
|
2491
|
+
model: modelName,
|
|
2492
|
+
choices: [
|
|
2493
|
+
{
|
|
2494
|
+
index: 0,
|
|
2495
|
+
message: {
|
|
2496
|
+
role: "assistant",
|
|
2497
|
+
content: content || null,
|
|
2498
|
+
reasoning_content: reasoning || null,
|
|
2499
|
+
reasoning_details: reasoningDetails,
|
|
2500
|
+
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2501
|
+
// Include generated images in the aggregate response
|
|
2502
|
+
// Store ID for mapping to file paths later (don't store base64 data)
|
|
2503
|
+
images: images.length > 0 ? images.map((img) => ({
|
|
2504
|
+
type: "image_url",
|
|
2505
|
+
_id: img.id,
|
|
2506
|
+
// For path lookup
|
|
2507
|
+
image_url: {
|
|
2508
|
+
url: `[image:${img.id}]`
|
|
2509
|
+
// Placeholder, will be replaced with path
|
|
2510
|
+
}
|
|
2511
|
+
})) : void 0
|
|
2512
|
+
},
|
|
2513
|
+
finish_reason: finishReason
|
|
2514
|
+
}
|
|
2515
|
+
],
|
|
2516
|
+
usage: response.usage,
|
|
2517
|
+
// Also store image count for quick reference
|
|
2518
|
+
image_count: images.length,
|
|
2519
|
+
// Store web search results for logging
|
|
2520
|
+
web_searches: webSearches.length > 0 ? webSearches : void 0,
|
|
2521
|
+
// Store generic provider-executed tools for logging
|
|
2522
|
+
provider_tools: providerToolCalls.length > 0 ? providerToolCalls : void 0
|
|
2523
|
+
};
|
|
2412
2524
|
}
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
};
|
|
2418
|
-
response._aggregate_response = {
|
|
2419
|
-
id: responseId,
|
|
2420
|
-
model: modelName,
|
|
2421
|
-
choices: [
|
|
2422
|
-
{
|
|
2423
|
-
index: 0,
|
|
2424
|
-
message: {
|
|
2425
|
-
role: "assistant",
|
|
2426
|
-
content: content || null,
|
|
2427
|
-
reasoning_content: reasoning || null,
|
|
2428
|
-
reasoning_details: reasoningDetails,
|
|
2429
|
-
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2430
|
-
// Include generated images in the aggregate response
|
|
2431
|
-
// Store ID for mapping to file paths later (don't store base64 data)
|
|
2432
|
-
images: images.length > 0 ? images.map((img) => ({
|
|
2433
|
-
type: "image_url",
|
|
2434
|
-
_id: img.id,
|
|
2435
|
-
// For path lookup
|
|
2436
|
-
image_url: {
|
|
2437
|
-
url: `[image:${img.id}]`
|
|
2438
|
-
// Placeholder, will be replaced with path
|
|
2439
|
-
}
|
|
2440
|
-
})) : void 0
|
|
2441
|
-
},
|
|
2442
|
-
finish_reason: finishReason
|
|
2443
|
-
}
|
|
2444
|
-
],
|
|
2445
|
-
usage: response.usage,
|
|
2446
|
-
// Also store image count for quick reference
|
|
2447
|
-
image_count: images.length,
|
|
2448
|
-
// Store web search results for logging
|
|
2449
|
-
web_searches: webSearches.length > 0 ? webSearches : void 0,
|
|
2450
|
-
// Store generic provider-executed tools for logging
|
|
2451
|
-
provider_tools: providerToolCalls.length > 0 ? providerToolCalls : void 0
|
|
2452
|
-
};
|
|
2525
|
+
);
|
|
2526
|
+
} catch (error) {
|
|
2527
|
+
if (onParentAbort && parentSignal) {
|
|
2528
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
2453
2529
|
}
|
|
2454
|
-
|
|
2530
|
+
throw attributeThrownError(error, {
|
|
2531
|
+
provider: provider.name,
|
|
2532
|
+
viaPlatform
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2455
2535
|
if (!response) {
|
|
2456
2536
|
throw new Error("Provider stream returned no response");
|
|
2457
2537
|
}
|
|
2458
2538
|
return response;
|
|
2459
2539
|
}
|
|
2540
|
+
/** Persist and broadcast provider-route attribution before any response. */
|
|
2541
|
+
static async logProviderRoute(state, logId, providerName, viaPlatform) {
|
|
2542
|
+
try {
|
|
2543
|
+
if (!state.storage?.sql) return;
|
|
2544
|
+
const upstream = viaPlatform ? providerName : null;
|
|
2545
|
+
await state.storage.sql.exec(
|
|
2546
|
+
`UPDATE logs
|
|
2547
|
+
SET standard_agents_router_used = ?1,
|
|
2548
|
+
actual_provider = COALESCE(actual_provider, ?2)
|
|
2549
|
+
WHERE id = ?3`,
|
|
2550
|
+
viaPlatform ? 1 : 0,
|
|
2551
|
+
upstream,
|
|
2552
|
+
logId
|
|
2553
|
+
);
|
|
2554
|
+
state.emitLog?.({
|
|
2555
|
+
type: "log_data",
|
|
2556
|
+
log_id: logId,
|
|
2557
|
+
data: {
|
|
2558
|
+
id: logId,
|
|
2559
|
+
standard_agents_router_used: viaPlatform,
|
|
2560
|
+
...upstream ? { actual_provider: upstream } : {}
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
} catch (error) {
|
|
2564
|
+
console.error("Failed to update provider route attribution (non-fatal):", error);
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2460
2567
|
/**
|
|
2461
2568
|
* Emit content chunk to WebSocket for real-time UI updates
|
|
2462
2569
|
*/
|
|
@@ -2777,6 +2884,7 @@ var init_LLMRequest = __esm({
|
|
|
2777
2884
|
*/
|
|
2778
2885
|
static async logError(state, error, errorType, modelId, startTime, existingLogId) {
|
|
2779
2886
|
try {
|
|
2887
|
+
const attribution = resolveErrorAttribution(error);
|
|
2780
2888
|
let rawErrorMessage = error instanceof Error ? error.message : String(error);
|
|
2781
2889
|
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
2782
2890
|
if (error instanceof Error && error.name === "AbortError" && /operation was aborted/i.test(rawErrorMessage)) {
|
|
@@ -2818,8 +2926,12 @@ var init_LLMRequest = __esm({
|
|
|
2818
2926
|
// Parameter that caused error
|
|
2819
2927
|
"user_id",
|
|
2820
2928
|
// User context
|
|
2821
|
-
"response"
|
|
2929
|
+
"response",
|
|
2822
2930
|
// Raw response
|
|
2931
|
+
"origin",
|
|
2932
|
+
// Structured error origin from ProviderError/custom providers
|
|
2933
|
+
"upstream"
|
|
2934
|
+
// Actual upstream behind an adapter/router
|
|
2823
2935
|
];
|
|
2824
2936
|
const metadata = {};
|
|
2825
2937
|
for (const field of relevantFields) {
|
|
@@ -2870,6 +2982,7 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2870
2982
|
errorsArray.push({
|
|
2871
2983
|
message: truncatedError,
|
|
2872
2984
|
type: errorType,
|
|
2985
|
+
origin: attribution.origin,
|
|
2873
2986
|
timestamp: Date.now()
|
|
2874
2987
|
});
|
|
2875
2988
|
await state.storage.sql.exec(
|
|
@@ -2877,20 +2990,29 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2877
2990
|
UPDATE logs SET
|
|
2878
2991
|
error = ?1,
|
|
2879
2992
|
error_type = ?2,
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2993
|
+
error_origin = ?3,
|
|
2994
|
+
errors = ?4,
|
|
2995
|
+
latency_ms = ?5,
|
|
2996
|
+
is_complete = ?6,
|
|
2997
|
+
actual_provider = COALESCE(actual_provider, ?7),
|
|
2998
|
+
standard_agents_router_used = CASE
|
|
2999
|
+
WHEN ?8 = 1 THEN 1
|
|
3000
|
+
ELSE standard_agents_router_used
|
|
3001
|
+
END
|
|
3002
|
+
WHERE id = ?9
|
|
2884
3003
|
`,
|
|
2885
3004
|
truncatedError,
|
|
2886
3005
|
// Keep last error in error field for backwards compatibility
|
|
2887
3006
|
errorType,
|
|
2888
3007
|
// Keep last error type
|
|
3008
|
+
attribution.origin,
|
|
2889
3009
|
JSON.stringify(errorsArray),
|
|
2890
3010
|
// All errors in array
|
|
2891
3011
|
Date.now() - startTime,
|
|
2892
3012
|
1,
|
|
2893
3013
|
// is_complete = true
|
|
3014
|
+
attribution.upstream ?? null,
|
|
3015
|
+
attribution.standardAgentsRouterUsed ? 1 : 0,
|
|
2894
3016
|
trackedLogId
|
|
2895
3017
|
);
|
|
2896
3018
|
}
|
|
@@ -2903,6 +3025,9 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2903
3025
|
id: trackedLogId,
|
|
2904
3026
|
error: truncatedError,
|
|
2905
3027
|
error_type: errorType,
|
|
3028
|
+
error_origin: attribution.origin,
|
|
3029
|
+
...attribution.upstream ? { actual_provider: attribution.upstream } : {},
|
|
3030
|
+
...attribution.standardAgentsRouterUsed ? { standard_agents_router_used: true } : {},
|
|
2906
3031
|
latency_ms: Date.now() - startTime,
|
|
2907
3032
|
is_complete: true
|
|
2908
3033
|
}
|
|
@@ -2919,9 +3044,12 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2919
3044
|
id,
|
|
2920
3045
|
message_id: messageId || "00000000-0000-0000-0000-000000000000",
|
|
2921
3046
|
provider: this.getProviderFromModel(modelId),
|
|
3047
|
+
actual_provider: attribution.upstream ?? null,
|
|
3048
|
+
standard_agents_router_used: attribution.standardAgentsRouterUsed,
|
|
2922
3049
|
model: modelId,
|
|
2923
3050
|
error: truncatedError,
|
|
2924
3051
|
error_type: errorType,
|
|
3052
|
+
error_origin: attribution.origin,
|
|
2925
3053
|
latency_ms: Date.now() - startTime,
|
|
2926
3054
|
is_complete: true,
|
|
2927
3055
|
created_at: Date.now() * TIMESTAMP_MULTIPLIER
|
|
@@ -2932,16 +3060,19 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2932
3060
|
await state.storage.sql.exec(
|
|
2933
3061
|
`
|
|
2934
3062
|
INSERT INTO logs (
|
|
2935
|
-
id, message_id, provider, model,
|
|
2936
|
-
error, error_type, latency_ms, is_complete, created_at
|
|
2937
|
-
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)
|
|
3063
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model,
|
|
3064
|
+
error, error_type, error_origin, latency_ms, is_complete, created_at
|
|
3065
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)
|
|
2938
3066
|
`,
|
|
2939
3067
|
logData.id,
|
|
2940
3068
|
messageId,
|
|
2941
3069
|
logData.provider,
|
|
3070
|
+
logData.actual_provider,
|
|
3071
|
+
logData.standard_agents_router_used ? 1 : 0,
|
|
2942
3072
|
logData.model,
|
|
2943
3073
|
logData.error,
|
|
2944
3074
|
logData.error_type,
|
|
3075
|
+
logData.error_origin,
|
|
2945
3076
|
logData.latency_ms,
|
|
2946
3077
|
1,
|
|
2947
3078
|
logData.created_at
|
|
@@ -6524,11 +6655,13 @@ ${errorStack}` : ""}`;
|
|
|
6524
6655
|
UPDATE logs
|
|
6525
6656
|
SET
|
|
6526
6657
|
error = ?1,
|
|
6527
|
-
error_type = ?2
|
|
6528
|
-
|
|
6658
|
+
error_type = ?2,
|
|
6659
|
+
error_origin = ?3
|
|
6660
|
+
WHERE id = ?4
|
|
6529
6661
|
`,
|
|
6530
6662
|
fullError,
|
|
6531
6663
|
"tool_execution_error",
|
|
6664
|
+
`tool:${toolName}`,
|
|
6532
6665
|
parentLogId
|
|
6533
6666
|
);
|
|
6534
6667
|
if (state.emitLog) {
|
|
@@ -6538,7 +6671,8 @@ ${errorStack}` : ""}`;
|
|
|
6538
6671
|
data: {
|
|
6539
6672
|
id: parentLogId,
|
|
6540
6673
|
error: fullError,
|
|
6541
|
-
error_type: "tool_execution_error"
|
|
6674
|
+
error_type: "tool_execution_error",
|
|
6675
|
+
error_origin: `tool:${toolName}`
|
|
6542
6676
|
}
|
|
6543
6677
|
});
|
|
6544
6678
|
}
|
|
@@ -7420,7 +7554,7 @@ var init_FlowEngine = __esm({
|
|
|
7420
7554
|
const error = "Request did not complete \u2014 the response was interrupted (the worker was evicted or the provider stalled) before it finished.";
|
|
7421
7555
|
const errorType = "interrupted_incomplete";
|
|
7422
7556
|
await state.storage.sql.exec(
|
|
7423
|
-
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2 WHERE is_complete = 0`,
|
|
7557
|
+
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2, error_origin = 'runtime' WHERE is_complete = 0`,
|
|
7424
7558
|
error,
|
|
7425
7559
|
errorType
|
|
7426
7560
|
);
|
|
@@ -7428,7 +7562,7 @@ var init_FlowEngine = __esm({
|
|
|
7428
7562
|
state.emitLog?.({
|
|
7429
7563
|
type: "log_data",
|
|
7430
7564
|
log_id: row.id,
|
|
7431
|
-
data: { id: row.id, is_complete: true, error, error_type: errorType }
|
|
7565
|
+
data: { id: row.id, is_complete: true, error, error_type: errorType, error_origin: "runtime" }
|
|
7432
7566
|
});
|
|
7433
7567
|
}
|
|
7434
7568
|
console.warn(
|
|
@@ -7964,7 +8098,7 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
7964
8098
|
pendingMessageId
|
|
7965
8099
|
);
|
|
7966
8100
|
await state.storage.sql.exec(
|
|
7967
|
-
`UPDATE logs SET error = ?, error_type =
|
|
8101
|
+
`UPDATE logs SET error = ?, error_type = ?, error_origin = 'runtime' WHERE id = ?`,
|
|
7968
8102
|
"Interrupted by user",
|
|
7969
8103
|
"user_interrupted",
|
|
7970
8104
|
logId
|
|
@@ -11507,8 +11641,8 @@ ${errorStack}` : ""}`;
|
|
|
11507
11641
|
`
|
|
11508
11642
|
INSERT INTO logs (
|
|
11509
11643
|
id, message_id, provider, model,
|
|
11510
|
-
error, error_type, created_at
|
|
11511
|
-
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)
|
|
11644
|
+
error, error_type, error_origin, created_at
|
|
11645
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, 'runtime', ?7)
|
|
11512
11646
|
`,
|
|
11513
11647
|
crypto.randomUUID(),
|
|
11514
11648
|
messageId,
|
|
@@ -17033,8 +17167,32 @@ var migration36 = {
|
|
|
17033
17167
|
}
|
|
17034
17168
|
};
|
|
17035
17169
|
|
|
17170
|
+
// src/durable-objects/migrations/037_add_error_origin.ts
|
|
17171
|
+
var migration37 = {
|
|
17172
|
+
version: 37,
|
|
17173
|
+
name: "add_error_origin",
|
|
17174
|
+
async up(sql) {
|
|
17175
|
+
const columns = sql.exec(`PRAGMA table_info(logs)`).toArray();
|
|
17176
|
+
if (!columns.some((column) => column.name === "error_origin")) {
|
|
17177
|
+
sql.exec(`ALTER TABLE logs ADD COLUMN error_origin TEXT`);
|
|
17178
|
+
}
|
|
17179
|
+
sql.exec(`
|
|
17180
|
+
UPDATE logs
|
|
17181
|
+
SET error_origin = CASE
|
|
17182
|
+
WHEN error_type = 'tool_execution_error' THEN 'tool:unknown'
|
|
17183
|
+
WHEN standard_agents_router_used = 1 THEN 'platform-router'
|
|
17184
|
+
WHEN provider IS NOT NULL AND provider NOT IN ('system', 'runtime')
|
|
17185
|
+
THEN 'provider:' || provider
|
|
17186
|
+
ELSE 'runtime'
|
|
17187
|
+
END
|
|
17188
|
+
WHERE error IS NOT NULL AND error_origin IS NULL
|
|
17189
|
+
`);
|
|
17190
|
+
sql.exec(`UPDATE _metadata SET value = '37' WHERE key = 'schema_version'`);
|
|
17191
|
+
}
|
|
17192
|
+
};
|
|
17193
|
+
|
|
17036
17194
|
// src/durable-objects/migrations/index.ts
|
|
17037
|
-
var migrations = [migration, migration2, migration3, migration4, migration5, migration6, migration7, migration8, migration9, migration10, migration11, migration12, migration13, migration14, migration15, migration16, migration17, migration18, migration19, migration20, migration21, migration22, migration23, migration24, migration25, migration26, migration27, migration28, migration29, migration30, migration31, migration32, migration33, migration34, migration35, migration36];
|
|
17195
|
+
var migrations = [migration, migration2, migration3, migration4, migration5, migration6, migration7, migration8, migration9, migration10, migration11, migration12, migration13, migration14, migration15, migration16, migration17, migration18, migration19, migration20, migration21, migration22, migration23, migration24, migration25, migration26, migration27, migration28, migration29, migration30, migration31, migration32, migration33, migration34, migration35, migration36, migration37];
|
|
17038
17196
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
17039
17197
|
|
|
17040
17198
|
// src/durable-objects/subagent-reconcile.ts
|
|
@@ -17870,7 +18028,7 @@ function eventSocketCanReceive(attachment, ownerUserId) {
|
|
|
17870
18028
|
}
|
|
17871
18029
|
|
|
17872
18030
|
// src/durable-objects/agentbuilder-migrations/0001_initial.ts
|
|
17873
|
-
var
|
|
18031
|
+
var migration38 = {
|
|
17874
18032
|
version: 1,
|
|
17875
18033
|
async up(sql) {
|
|
17876
18034
|
sql.exec(`
|
|
@@ -17969,7 +18127,7 @@ var migration37 = {
|
|
|
17969
18127
|
};
|
|
17970
18128
|
|
|
17971
18129
|
// src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
|
|
17972
|
-
var
|
|
18130
|
+
var migration39 = {
|
|
17973
18131
|
version: 2,
|
|
17974
18132
|
async up(sql) {
|
|
17975
18133
|
sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
|
|
@@ -17981,7 +18139,7 @@ var migration38 = {
|
|
|
17981
18139
|
};
|
|
17982
18140
|
|
|
17983
18141
|
// src/durable-objects/agentbuilder-migrations/0003_add_parent_and_terminated.ts
|
|
17984
|
-
var
|
|
18142
|
+
var migration40 = {
|
|
17985
18143
|
version: 3,
|
|
17986
18144
|
async up(sql) {
|
|
17987
18145
|
sql.exec(`ALTER TABLE threads ADD COLUMN parent TEXT REFERENCES threads(id)`);
|
|
@@ -17994,7 +18152,7 @@ var migration39 = {
|
|
|
17994
18152
|
};
|
|
17995
18153
|
|
|
17996
18154
|
// src/durable-objects/agentbuilder-migrations/0004_add_env_tables.ts
|
|
17997
|
-
var
|
|
18155
|
+
var migration41 = {
|
|
17998
18156
|
version: 4,
|
|
17999
18157
|
async up(sql) {
|
|
18000
18158
|
sql.exec(`ALTER TABLE threads ADD COLUMN env TEXT`);
|
|
@@ -18018,7 +18176,7 @@ var migration40 = {
|
|
|
18018
18176
|
};
|
|
18019
18177
|
|
|
18020
18178
|
// src/durable-objects/agentbuilder-migrations/0005_add_pending_subagent_env_requests.ts
|
|
18021
|
-
var
|
|
18179
|
+
var migration42 = {
|
|
18022
18180
|
version: 5,
|
|
18023
18181
|
async up(sql) {
|
|
18024
18182
|
sql.exec(`
|
|
@@ -18044,7 +18202,7 @@ var migration41 = {
|
|
|
18044
18202
|
};
|
|
18045
18203
|
|
|
18046
18204
|
// src/durable-objects/agentbuilder-migrations/0006_add_env_value_types.ts
|
|
18047
|
-
var
|
|
18205
|
+
var migration43 = {
|
|
18048
18206
|
version: 6,
|
|
18049
18207
|
async up(sql) {
|
|
18050
18208
|
sql.exec(
|
|
@@ -18059,7 +18217,7 @@ var migration42 = {
|
|
|
18059
18217
|
};
|
|
18060
18218
|
|
|
18061
18219
|
// src/durable-objects/agentbuilder-migrations/0007_platform_identity_replica.ts
|
|
18062
|
-
var
|
|
18220
|
+
var migration44 = {
|
|
18063
18221
|
version: 7,
|
|
18064
18222
|
async up(sql) {
|
|
18065
18223
|
sql.exec(`ALTER TABLE users ADD COLUMN platform_user_id TEXT`);
|
|
@@ -18088,7 +18246,7 @@ var migration43 = {
|
|
|
18088
18246
|
};
|
|
18089
18247
|
|
|
18090
18248
|
// src/durable-objects/agentbuilder-migrations/0008_add_skills.ts
|
|
18091
|
-
var
|
|
18249
|
+
var migration45 = {
|
|
18092
18250
|
version: 8,
|
|
18093
18251
|
async up(sql) {
|
|
18094
18252
|
sql.exec(`
|
|
@@ -18119,7 +18277,7 @@ var migration44 = {
|
|
|
18119
18277
|
};
|
|
18120
18278
|
|
|
18121
18279
|
// src/durable-objects/agentbuilder-migrations/0009_add_user_permissions.ts
|
|
18122
|
-
var
|
|
18280
|
+
var migration46 = {
|
|
18123
18281
|
version: 9,
|
|
18124
18282
|
async up(sql) {
|
|
18125
18283
|
sql.exec(`ALTER TABLE users ADD COLUMN permissions TEXT`);
|
|
@@ -18130,7 +18288,7 @@ var migration45 = {
|
|
|
18130
18288
|
};
|
|
18131
18289
|
|
|
18132
18290
|
// src/durable-objects/agentbuilder-migrations/0010_add_device_logins.ts
|
|
18133
|
-
var
|
|
18291
|
+
var migration47 = {
|
|
18134
18292
|
version: 10,
|
|
18135
18293
|
async up(sql) {
|
|
18136
18294
|
sql.exec(`
|
|
@@ -18150,7 +18308,7 @@ var migration46 = {
|
|
|
18150
18308
|
};
|
|
18151
18309
|
|
|
18152
18310
|
// src/durable-objects/agentbuilder-migrations/0011_add_user_values.ts
|
|
18153
|
-
var
|
|
18311
|
+
var migration48 = {
|
|
18154
18312
|
version: 11,
|
|
18155
18313
|
async up(sql) {
|
|
18156
18314
|
sql.exec(`
|
|
@@ -18173,7 +18331,7 @@ var migration47 = {
|
|
|
18173
18331
|
};
|
|
18174
18332
|
|
|
18175
18333
|
// src/durable-objects/agentbuilder-migrations/0012_allow_api_instance_role.ts
|
|
18176
|
-
var
|
|
18334
|
+
var migration49 = {
|
|
18177
18335
|
version: 12,
|
|
18178
18336
|
async up(sql) {
|
|
18179
18337
|
sql.exec(`CREATE TABLE oauth_accounts_0012_backup AS SELECT * FROM oauth_accounts`);
|
|
@@ -18283,7 +18441,7 @@ var migration48 = {
|
|
|
18283
18441
|
};
|
|
18284
18442
|
|
|
18285
18443
|
// src/durable-objects/agentbuilder-migrations/0013_add_thread_activity.ts
|
|
18286
|
-
var
|
|
18444
|
+
var migration50 = {
|
|
18287
18445
|
version: 13,
|
|
18288
18446
|
async up(sql) {
|
|
18289
18447
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_activity_at INTEGER`);
|
|
@@ -18299,7 +18457,7 @@ var migration49 = {
|
|
|
18299
18457
|
};
|
|
18300
18458
|
|
|
18301
18459
|
// src/durable-objects/agentbuilder-migrations/0014_thread_activity_scale.ts
|
|
18302
|
-
var
|
|
18460
|
+
var migration51 = {
|
|
18303
18461
|
version: 14,
|
|
18304
18462
|
async up(sql) {
|
|
18305
18463
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_preview TEXT`);
|
|
@@ -18317,7 +18475,7 @@ var migration50 = {
|
|
|
18317
18475
|
};
|
|
18318
18476
|
|
|
18319
18477
|
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
18320
|
-
var
|
|
18478
|
+
var migration52 = {
|
|
18321
18479
|
version: 15,
|
|
18322
18480
|
async up(sql) {
|
|
18323
18481
|
sql.exec(
|
|
@@ -18331,7 +18489,7 @@ var migration51 = {
|
|
|
18331
18489
|
};
|
|
18332
18490
|
|
|
18333
18491
|
// src/durable-objects/agentbuilder-migrations/0016_add_origin_agent.ts
|
|
18334
|
-
var
|
|
18492
|
+
var migration53 = {
|
|
18335
18493
|
version: 16,
|
|
18336
18494
|
async up(sql) {
|
|
18337
18495
|
sql.exec(`ALTER TABLE threads ADD COLUMN origin_agent_name TEXT`);
|
|
@@ -18346,7 +18504,7 @@ var migration52 = {
|
|
|
18346
18504
|
};
|
|
18347
18505
|
|
|
18348
18506
|
// src/durable-objects/agentbuilder-migrations/0017_add_thread_message_recency.ts
|
|
18349
|
-
var
|
|
18507
|
+
var migration54 = {
|
|
18350
18508
|
version: 17,
|
|
18351
18509
|
async up(sql) {
|
|
18352
18510
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_at INTEGER`);
|
|
@@ -18358,7 +18516,7 @@ var migration53 = {
|
|
|
18358
18516
|
};
|
|
18359
18517
|
|
|
18360
18518
|
// src/durable-objects/agentbuilder-migrations/0018_auth_security.ts
|
|
18361
|
-
var
|
|
18519
|
+
var migration55 = {
|
|
18362
18520
|
version: 18,
|
|
18363
18521
|
async up(sql) {
|
|
18364
18522
|
sql.exec(`
|
|
@@ -18390,7 +18548,7 @@ var migration54 = {
|
|
|
18390
18548
|
};
|
|
18391
18549
|
|
|
18392
18550
|
// src/durable-objects/agentbuilder-migrations/0019_scope_skills.ts
|
|
18393
|
-
var
|
|
18551
|
+
var migration56 = {
|
|
18394
18552
|
version: 19,
|
|
18395
18553
|
async up(sql) {
|
|
18396
18554
|
sql.exec(`
|
|
@@ -18440,7 +18598,7 @@ var migration55 = {
|
|
|
18440
18598
|
};
|
|
18441
18599
|
|
|
18442
18600
|
// src/durable-objects/agentbuilder-migrations/0020_websocket_tickets.ts
|
|
18443
|
-
var
|
|
18601
|
+
var migration57 = {
|
|
18444
18602
|
version: 20,
|
|
18445
18603
|
async up(sql) {
|
|
18446
18604
|
sql.exec(`
|
|
@@ -18461,7 +18619,7 @@ var migration56 = {
|
|
|
18461
18619
|
};
|
|
18462
18620
|
|
|
18463
18621
|
// src/durable-objects/agentbuilder-migrations/0021_platform_handoff_jtis.ts
|
|
18464
|
-
var
|
|
18622
|
+
var migration58 = {
|
|
18465
18623
|
version: 21,
|
|
18466
18624
|
async up(sql) {
|
|
18467
18625
|
sql.exec(`
|
|
@@ -18480,9 +18638,9 @@ var migration57 = {
|
|
|
18480
18638
|
};
|
|
18481
18639
|
|
|
18482
18640
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
18483
|
-
var migrations2 = [
|
|
18641
|
+
var migrations2 = [migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49, migration50, migration51, migration52, migration53, migration54, migration55, migration56, migration57, migration58];
|
|
18484
18642
|
var LATEST_SCHEMA_VERSION2 = migrations2.reduce(
|
|
18485
|
-
(max,
|
|
18643
|
+
(max, migration59) => Math.max(max, migration59.version),
|
|
18486
18644
|
0
|
|
18487
18645
|
);
|
|
18488
18646
|
|
|
@@ -19268,9 +19426,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
19268
19426
|
}
|
|
19269
19427
|
}
|
|
19270
19428
|
async runMigrations(fromVersion) {
|
|
19271
|
-
for (const
|
|
19272
|
-
if (
|
|
19273
|
-
await
|
|
19429
|
+
for (const migration59 of migrations2) {
|
|
19430
|
+
if (migration59.version > fromVersion) {
|
|
19431
|
+
await migration59.up(this.ctx.storage.sql);
|
|
19274
19432
|
}
|
|
19275
19433
|
}
|
|
19276
19434
|
}
|
|
@@ -23654,9 +23812,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
23654
23812
|
* Each migration is run in order, starting from the current version + 1.
|
|
23655
23813
|
*/
|
|
23656
23814
|
async runMigrations(fromVersion) {
|
|
23657
|
-
for (const
|
|
23658
|
-
if (
|
|
23659
|
-
await
|
|
23815
|
+
for (const migration59 of migrations) {
|
|
23816
|
+
if (migration59.version > fromVersion) {
|
|
23817
|
+
await migration59.up(this.ctx.storage.sql);
|
|
23660
23818
|
}
|
|
23661
23819
|
}
|
|
23662
23820
|
}
|
|
@@ -25178,7 +25336,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25178
25336
|
`
|
|
25179
25337
|
SELECT
|
|
25180
25338
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
25181
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, cost_total,
|
|
25339
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
25182
25340
|
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
25183
25341
|
is_complete, created_at
|
|
25184
25342
|
FROM logs
|
|
@@ -25204,6 +25362,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25204
25362
|
retry_of_log_id: row.retry_of_log_id,
|
|
25205
25363
|
error: row.error,
|
|
25206
25364
|
error_type: row.error_type,
|
|
25365
|
+
error_origin: row.error_origin,
|
|
25207
25366
|
cost_total: row.cost_total,
|
|
25208
25367
|
input_tokens: row.input_tokens,
|
|
25209
25368
|
cached_tokens: row.cached_tokens,
|
|
@@ -25313,16 +25472,16 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25313
25472
|
WHERE logs.parent_log_id IS NOT NULL
|
|
25314
25473
|
)
|
|
25315
25474
|
SELECT
|
|
25316
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
25317
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
25475
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
25476
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
25318
25477
|
is_complete, created_at
|
|
25319
25478
|
FROM logs
|
|
25320
25479
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
25321
25480
|
ORDER BY created_at ${order}, rowid ${order}
|
|
25322
25481
|
` : `
|
|
25323
25482
|
SELECT
|
|
25324
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
25325
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
25483
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
25484
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
25326
25485
|
is_complete, created_at
|
|
25327
25486
|
FROM logs
|
|
25328
25487
|
WHERE id IN (${placeholders})
|
|
@@ -25334,6 +25493,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25334
25493
|
message_id: row.message_id,
|
|
25335
25494
|
provider: row.provider,
|
|
25336
25495
|
actual_provider: row.actual_provider,
|
|
25496
|
+
standard_agents_router_used: row.standard_agents_router_used === 1,
|
|
25337
25497
|
model: row.model,
|
|
25338
25498
|
model_name: row.model_name,
|
|
25339
25499
|
prompt_name: row.prompt_name,
|
|
@@ -25343,6 +25503,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25343
25503
|
parent_log_id: row.parent_log_id,
|
|
25344
25504
|
retry_of_log_id: row.retry_of_log_id,
|
|
25345
25505
|
error: row.error,
|
|
25506
|
+
error_type: row.error_type,
|
|
25507
|
+
error_origin: row.error_origin,
|
|
25346
25508
|
cost_total: row.cost_total,
|
|
25347
25509
|
is_complete: row.is_complete === 1,
|
|
25348
25510
|
created_at: row.created_at
|
|
@@ -25428,8 +25590,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25428
25590
|
)
|
|
25429
25591
|
SELECT
|
|
25430
25592
|
rowid AS row_index,
|
|
25431
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
25432
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
25593
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
25594
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
25433
25595
|
is_complete, created_at
|
|
25434
25596
|
FROM logs
|
|
25435
25597
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
@@ -25437,8 +25599,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25437
25599
|
` : `
|
|
25438
25600
|
SELECT
|
|
25439
25601
|
rowid AS row_index,
|
|
25440
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
25441
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
25602
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
25603
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
25442
25604
|
is_complete, created_at
|
|
25443
25605
|
FROM logs
|
|
25444
25606
|
WHERE message_id IN (${placeholders})
|
|
@@ -25459,6 +25621,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25459
25621
|
message_id: row.message_id,
|
|
25460
25622
|
provider: row.provider,
|
|
25461
25623
|
actual_provider: row.actual_provider,
|
|
25624
|
+
standard_agents_router_used: row.standard_agents_router_used === 1,
|
|
25462
25625
|
model: row.model,
|
|
25463
25626
|
model_name: row.model_name,
|
|
25464
25627
|
prompt_name: row.prompt_name,
|
|
@@ -25468,6 +25631,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25468
25631
|
parent_log_id: row.parent_log_id,
|
|
25469
25632
|
retry_of_log_id: row.retry_of_log_id,
|
|
25470
25633
|
error: row.error,
|
|
25634
|
+
error_type: row.error_type,
|
|
25635
|
+
error_origin: row.error_origin,
|
|
25471
25636
|
cost_total: row.cost_total,
|
|
25472
25637
|
is_complete: row.is_complete === 1,
|
|
25473
25638
|
created_at: row.created_at
|
|
@@ -25489,7 +25654,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25489
25654
|
l.request_headers, l.response_headers, l.status_code,
|
|
25490
25655
|
l.input_tokens, l.cached_tokens, l.output_tokens,
|
|
25491
25656
|
l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
|
|
25492
|
-
l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_cached, l.cost_output, l.cost_router_fee, l.router_fee_percent, l.cost_total,
|
|
25657
|
+
l.finish_reason, l.error, l.error_type, l.error_origin, l.cost_input, l.cost_cached, l.cost_output, l.cost_router_fee, l.router_fee_percent, l.cost_total,
|
|
25493
25658
|
l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
|
|
25494
25659
|
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
25495
25660
|
l.errors, l.retry_of_log_id, l.is_complete, l.created_at,
|
|
@@ -25563,6 +25728,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
25563
25728
|
finish_reason: row.finish_reason,
|
|
25564
25729
|
error: row.error,
|
|
25565
25730
|
error_type: row.error_type,
|
|
25731
|
+
error_origin: row.error_origin,
|
|
25566
25732
|
cost_input: row.cost_input,
|
|
25567
25733
|
cost_cached: row.cost_cached,
|
|
25568
25734
|
cost_output: row.cost_output,
|
|
@@ -27809,7 +27975,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27809
27975
|
const error = "Request lost \u2014 the executor restarted (deploy or eviction) or hung before finishing. The thread watchdog finalized it.";
|
|
27810
27976
|
const errorType = "execution_lost";
|
|
27811
27977
|
await this.ctx.storage.sql.exec(
|
|
27812
|
-
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2 WHERE is_complete = 0`,
|
|
27978
|
+
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2, error_origin = 'runtime' WHERE is_complete = 0`,
|
|
27813
27979
|
error,
|
|
27814
27980
|
errorType
|
|
27815
27981
|
);
|
|
@@ -27817,7 +27983,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27817
27983
|
this.broadcastLog({
|
|
27818
27984
|
type: "log_data",
|
|
27819
27985
|
log_id: id,
|
|
27820
|
-
data: { id, is_complete: true, error, error_type: errorType }
|
|
27986
|
+
data: { id, is_complete: true, error, error_type: errorType, error_origin: "runtime" }
|
|
27821
27987
|
});
|
|
27822
27988
|
}
|
|
27823
27989
|
try {
|