@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/index.js
CHANGED
|
@@ -496,6 +496,7 @@ var init_logBroadcast = __esm({
|
|
|
496
496
|
"message_id",
|
|
497
497
|
"provider",
|
|
498
498
|
"actual_provider",
|
|
499
|
+
"standard_agents_router_used",
|
|
499
500
|
"model",
|
|
500
501
|
"model_name",
|
|
501
502
|
"prompt_name",
|
|
@@ -506,6 +507,7 @@ var init_logBroadcast = __esm({
|
|
|
506
507
|
"retry_of_log_id",
|
|
507
508
|
"error",
|
|
508
509
|
"error_type",
|
|
510
|
+
"error_origin",
|
|
509
511
|
"finish_reason",
|
|
510
512
|
"cost_total",
|
|
511
513
|
"cost_input",
|
|
@@ -528,6 +530,71 @@ var init_logBroadcast = __esm({
|
|
|
528
530
|
];
|
|
529
531
|
}
|
|
530
532
|
});
|
|
533
|
+
|
|
534
|
+
// src/agents/errorOrigin.ts
|
|
535
|
+
function normalizedOrigin(value) {
|
|
536
|
+
if (typeof value !== "string") return void 0;
|
|
537
|
+
const origin = value.trim();
|
|
538
|
+
return ERROR_ORIGIN_PATTERN.test(origin) ? origin : void 0;
|
|
539
|
+
}
|
|
540
|
+
function normalizedUpstream(value) {
|
|
541
|
+
if (typeof value !== "string") return void 0;
|
|
542
|
+
const upstream = value.trim();
|
|
543
|
+
return upstream.length > 0 ? upstream : void 0;
|
|
544
|
+
}
|
|
545
|
+
function errorObject(error) {
|
|
546
|
+
return error !== null && (typeof error === "object" || typeof error === "function") ? error : null;
|
|
547
|
+
}
|
|
548
|
+
function resolveErrorAttribution(error, context = {}) {
|
|
549
|
+
const object = errorObject(error);
|
|
550
|
+
const stored = object?.[ATTRIBUTION];
|
|
551
|
+
if (stored) return stored;
|
|
552
|
+
const taggedOrigin = normalizedOrigin(object?.origin);
|
|
553
|
+
const provider = normalizedUpstream(object?.upstream) ?? normalizedUpstream(context.provider);
|
|
554
|
+
const standardAgentsRouterUsed = context.viaPlatform === true;
|
|
555
|
+
if (taggedOrigin) {
|
|
556
|
+
return {
|
|
557
|
+
origin: taggedOrigin,
|
|
558
|
+
...provider ? { upstream: provider } : {},
|
|
559
|
+
standardAgentsRouterUsed
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (provider) {
|
|
563
|
+
return {
|
|
564
|
+
origin: standardAgentsRouterUsed ? "platform-router" : `provider:${provider}`,
|
|
565
|
+
upstream: provider,
|
|
566
|
+
standardAgentsRouterUsed
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
return {
|
|
570
|
+
origin: context.fallback ?? "runtime",
|
|
571
|
+
standardAgentsRouterUsed
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function attributeThrownError(error, context) {
|
|
575
|
+
const attributed = errorObject(error) ?? new Error(String(error));
|
|
576
|
+
const attribution = resolveErrorAttribution(attributed, context);
|
|
577
|
+
try {
|
|
578
|
+
Object.defineProperty(attributed, ATTRIBUTION, {
|
|
579
|
+
configurable: true,
|
|
580
|
+
value: attribution
|
|
581
|
+
});
|
|
582
|
+
return attributed;
|
|
583
|
+
} catch {
|
|
584
|
+
const wrapped = new Error(error instanceof Error ? error.message : String(error), {
|
|
585
|
+
cause: error
|
|
586
|
+
});
|
|
587
|
+
Object.defineProperty(wrapped, ATTRIBUTION, { value: attribution });
|
|
588
|
+
return wrapped;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
var ATTRIBUTION, ERROR_ORIGIN_PATTERN;
|
|
592
|
+
var init_errorOrigin = __esm({
|
|
593
|
+
"src/agents/errorOrigin.ts"() {
|
|
594
|
+
ATTRIBUTION = Symbol("standard-agents-error-attribution");
|
|
595
|
+
ERROR_ORIGIN_PATTERN = /^(?:platform-router|runtime|(?:provider|tool|hook):[A-Za-z0-9._/@-]+)$/;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
531
598
|
var init_types2 = __esm({
|
|
532
599
|
"src/agents/providers/types.ts"() {
|
|
533
600
|
}
|
|
@@ -1828,6 +1895,7 @@ var init_LLMRequest = __esm({
|
|
|
1828
1895
|
init_FlowEngine();
|
|
1829
1896
|
init_toolProgress();
|
|
1830
1897
|
init_logBroadcast();
|
|
1898
|
+
init_errorOrigin();
|
|
1831
1899
|
NON_VISION_PLACEHOLDER_TEXT = "[Image omitted: model does not support vision]";
|
|
1832
1900
|
STREAM_FIRST_CHUNK_TIMEOUT_MS = 12e4;
|
|
1833
1901
|
STREAM_STALL_TIMEOUT_MS = 45e3;
|
|
@@ -2125,6 +2193,7 @@ var init_LLMRequest = __esm({
|
|
|
2125
2193
|
state.thread.instance,
|
|
2126
2194
|
getThreadState
|
|
2127
2195
|
);
|
|
2196
|
+
await this.logProviderRoute(state, logId, provider.name, viaPlatform);
|
|
2128
2197
|
const streamAbort = new AbortController();
|
|
2129
2198
|
const parentSignal = state.abortController?.signal;
|
|
2130
2199
|
let onParentAbort;
|
|
@@ -2138,332 +2207,370 @@ var init_LLMRequest = __esm({
|
|
|
2138
2207
|
}
|
|
2139
2208
|
const request = buildProviderRequest(context, modelDef, streamAbort.signal, state.threadId);
|
|
2140
2209
|
let response;
|
|
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
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
lastEmittedChars
|
|
2210
|
+
try {
|
|
2211
|
+
await state.stream.waitFor(
|
|
2212
|
+
async () => {
|
|
2213
|
+
const requestSentAt = Date.now();
|
|
2214
|
+
const firstChunkTimeoutMs = resolveStreamTimeoutMs(
|
|
2215
|
+
state.env,
|
|
2216
|
+
"STANDARD_AGENTS_STREAM_FIRST_CHUNK_TIMEOUT_MS",
|
|
2217
|
+
STREAM_FIRST_CHUNK_TIMEOUT_MS
|
|
2218
|
+
);
|
|
2219
|
+
const stallTimeoutMs = resolveStreamTimeoutMs(
|
|
2220
|
+
state.env,
|
|
2221
|
+
"STANDARD_AGENTS_STREAM_STALL_TIMEOUT_MS",
|
|
2222
|
+
STREAM_STALL_TIMEOUT_MS
|
|
2223
|
+
);
|
|
2224
|
+
let stalled = false;
|
|
2225
|
+
const stallError = (budgetMs) => new ProviderError(
|
|
2226
|
+
`Provider sent no chunk for ${Math.round(budgetMs / 1e3)}s`,
|
|
2227
|
+
"timeout"
|
|
2228
|
+
);
|
|
2229
|
+
const awaitWithStallGuard = (work, budgetMs) => {
|
|
2230
|
+
let timer;
|
|
2231
|
+
work.catch(() => {
|
|
2232
|
+
});
|
|
2233
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
2234
|
+
timer = setTimeout(() => {
|
|
2235
|
+
stalled = true;
|
|
2236
|
+
reject(stallError(budgetMs));
|
|
2237
|
+
streamAbort.abort();
|
|
2238
|
+
}, budgetMs);
|
|
2239
|
+
});
|
|
2240
|
+
return Promise.race([work, timeout]).finally(() => {
|
|
2241
|
+
if (timer) clearTimeout(timer);
|
|
2242
|
+
});
|
|
2243
|
+
};
|
|
2244
|
+
const stream = await awaitWithStallGuard(provider.stream(request), firstChunkTimeoutMs);
|
|
2245
|
+
let content = "";
|
|
2246
|
+
let reasoning = "";
|
|
2247
|
+
let outputChars = 0;
|
|
2248
|
+
let lastEmittedChars = 0;
|
|
2249
|
+
const GEN_EMIT_STEP = 80;
|
|
2250
|
+
const maybeEmitGeneration = () => {
|
|
2251
|
+
if (outputChars - lastEmittedChars >= GEN_EMIT_STEP) {
|
|
2252
|
+
lastEmittedChars = outputChars;
|
|
2253
|
+
try {
|
|
2254
|
+
state.emitEvent?.("generation", { outputTokens: Math.ceil(outputChars / 4) });
|
|
2255
|
+
} catch {
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
const toolCallsMap = /* @__PURE__ */ new Map();
|
|
2260
|
+
const images = [];
|
|
2261
|
+
const webSearches = [];
|
|
2262
|
+
const providerToolCalls = [];
|
|
2263
|
+
let finishReason = "stop";
|
|
2264
|
+
let usage;
|
|
2265
|
+
let reasoningDetails;
|
|
2266
|
+
let actualProvider;
|
|
2267
|
+
let providerResponseId;
|
|
2268
|
+
let firstChunkAt = 0;
|
|
2269
|
+
let firstTokenAt = 0;
|
|
2270
|
+
let lastTokenAt = 0;
|
|
2271
|
+
const noteToken = () => {
|
|
2272
|
+
const now = Date.now();
|
|
2273
|
+
if (firstTokenAt === 0) firstTokenAt = now;
|
|
2274
|
+
lastTokenAt = now;
|
|
2275
|
+
};
|
|
2276
|
+
const emitLogPatch = (data) => {
|
|
2183
2277
|
try {
|
|
2184
|
-
state.
|
|
2278
|
+
state.emitLog?.({ type: "log_data", log_id: logId, data: { id: logId, ...data } });
|
|
2185
2279
|
} catch {
|
|
2186
2280
|
}
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
const now = Date.now();
|
|
2202
|
-
if (firstTokenAt === 0) firstTokenAt = now;
|
|
2203
|
-
lastTokenAt = now;
|
|
2204
|
-
};
|
|
2205
|
-
const emitLogPatch = (data) => {
|
|
2281
|
+
};
|
|
2282
|
+
const streamedToolNames = [];
|
|
2283
|
+
let lastPreviewChars = 0;
|
|
2284
|
+
const PREVIEW_EMIT_STEP = 80;
|
|
2285
|
+
const maybeEmitPreview = () => {
|
|
2286
|
+
if (outputChars - lastPreviewChars >= PREVIEW_EMIT_STEP) {
|
|
2287
|
+
lastPreviewChars = outputChars;
|
|
2288
|
+
emitLogPatch({
|
|
2289
|
+
content: content || null,
|
|
2290
|
+
reasoning_content: reasoning || null
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2294
|
+
const iterator = stream[Symbol.asyncIterator]();
|
|
2206
2295
|
try {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
};
|
|
2223
|
-
const iterator = stream[Symbol.asyncIterator]();
|
|
2224
|
-
try {
|
|
2225
|
-
while (true) {
|
|
2226
|
-
if (state.abortController?.signal?.aborted) break;
|
|
2227
|
-
if (await state.thread.instance.shouldStop()) break;
|
|
2228
|
-
let next;
|
|
2229
|
-
try {
|
|
2230
|
-
next = await awaitWithStallGuard(
|
|
2231
|
-
iterator.next(),
|
|
2232
|
-
firstChunkAt === 0 ? firstChunkTimeoutMs : stallTimeoutMs
|
|
2233
|
-
);
|
|
2234
|
-
} catch (streamErr) {
|
|
2235
|
-
if (stalled) throw streamErr;
|
|
2236
|
-
if (state.abortController?.signal?.aborted || await state.thread.instance.shouldStop()) {
|
|
2237
|
-
break;
|
|
2296
|
+
while (true) {
|
|
2297
|
+
if (state.abortController?.signal?.aborted) break;
|
|
2298
|
+
if (await state.thread.instance.shouldStop()) break;
|
|
2299
|
+
let next;
|
|
2300
|
+
try {
|
|
2301
|
+
next = await awaitWithStallGuard(
|
|
2302
|
+
iterator.next(),
|
|
2303
|
+
firstChunkAt === 0 ? firstChunkTimeoutMs : stallTimeoutMs
|
|
2304
|
+
);
|
|
2305
|
+
} catch (streamErr) {
|
|
2306
|
+
if (stalled) throw streamErr;
|
|
2307
|
+
if (state.abortController?.signal?.aborted || await state.thread.instance.shouldStop()) {
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2310
|
+
throw streamErr;
|
|
2238
2311
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
this.emitContentChunk(chunk.delta, state);
|
|
2253
|
-
outputChars += chunk.delta.length;
|
|
2254
|
-
noteToken();
|
|
2255
|
-
maybeEmitGeneration();
|
|
2256
|
-
maybeEmitPreview();
|
|
2257
|
-
break;
|
|
2258
|
-
case "reasoning-delta":
|
|
2259
|
-
reasoning += chunk.delta;
|
|
2260
|
-
this.emitReasoningChunk(chunk.delta, state);
|
|
2261
|
-
outputChars += chunk.delta.length;
|
|
2262
|
-
noteToken();
|
|
2263
|
-
maybeEmitGeneration();
|
|
2264
|
-
maybeEmitPreview();
|
|
2265
|
-
break;
|
|
2266
|
-
case "tool-call-start":
|
|
2267
|
-
{
|
|
2312
|
+
if (next.done) break;
|
|
2313
|
+
const chunk = next.value;
|
|
2314
|
+
state.thread.instance.noteExecutionProgress?.();
|
|
2315
|
+
if (firstChunkAt === 0 && chunkCarriesPayload(chunk)) {
|
|
2316
|
+
firstChunkAt = Date.now();
|
|
2317
|
+
emitLogPatch({ time_to_first_token_ms: firstChunkAt - requestSentAt });
|
|
2318
|
+
}
|
|
2319
|
+
switch (chunk.type) {
|
|
2320
|
+
case "content-delta":
|
|
2321
|
+
content += chunk.delta;
|
|
2322
|
+
state.stream.sendContent(chunk.delta);
|
|
2323
|
+
this.emitContentChunk(chunk.delta, state);
|
|
2324
|
+
outputChars += chunk.delta.length;
|
|
2268
2325
|
noteToken();
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
const progressArg = await this.resolveProgressArgument(state, chunk.name);
|
|
2283
|
-
if (progressArg) {
|
|
2284
|
-
entry.progressArg = progressArg;
|
|
2285
|
-
} else {
|
|
2286
|
-
await this.fireToolCallStarted(state, entry, void 0);
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
break;
|
|
2290
|
-
case "tool-call-delta":
|
|
2291
|
-
{
|
|
2292
|
-
const tc = toolCallsMap.get(chunk.id);
|
|
2293
|
-
if (tc) {
|
|
2294
|
-
tc.argumentsDelta += chunk.argumentsDelta;
|
|
2295
|
-
outputChars += chunk.argumentsDelta.length;
|
|
2326
|
+
maybeEmitGeneration();
|
|
2327
|
+
maybeEmitPreview();
|
|
2328
|
+
break;
|
|
2329
|
+
case "reasoning-delta":
|
|
2330
|
+
reasoning += chunk.delta;
|
|
2331
|
+
this.emitReasoningChunk(chunk.delta, state);
|
|
2332
|
+
outputChars += chunk.delta.length;
|
|
2333
|
+
noteToken();
|
|
2334
|
+
maybeEmitGeneration();
|
|
2335
|
+
maybeEmitPreview();
|
|
2336
|
+
break;
|
|
2337
|
+
case "tool-call-start":
|
|
2338
|
+
{
|
|
2296
2339
|
noteToken();
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2340
|
+
const entry = {
|
|
2341
|
+
id: chunk.id,
|
|
2342
|
+
name: chunk.name,
|
|
2343
|
+
argumentsDelta: "",
|
|
2344
|
+
extraContent: chunk.extraContent,
|
|
2345
|
+
startedFired: false,
|
|
2346
|
+
progressArg: void 0
|
|
2347
|
+
};
|
|
2348
|
+
toolCallsMap.set(chunk.id, entry);
|
|
2349
|
+
if (chunk.name) {
|
|
2350
|
+
streamedToolNames.push(chunk.name);
|
|
2351
|
+
emitLogPatch({ tools_called: JSON.stringify(streamedToolNames) });
|
|
2352
|
+
}
|
|
2353
|
+
const progressArg = await this.resolveProgressArgument(state, chunk.name);
|
|
2354
|
+
if (progressArg) {
|
|
2355
|
+
entry.progressArg = progressArg;
|
|
2356
|
+
} else {
|
|
2357
|
+
await this.fireToolCallStarted(state, entry, void 0);
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
break;
|
|
2361
|
+
case "tool-call-delta":
|
|
2362
|
+
{
|
|
2363
|
+
const tc = toolCallsMap.get(chunk.id);
|
|
2364
|
+
if (tc) {
|
|
2365
|
+
tc.argumentsDelta += chunk.argumentsDelta;
|
|
2366
|
+
outputChars += chunk.argumentsDelta.length;
|
|
2367
|
+
noteToken();
|
|
2368
|
+
maybeEmitGeneration();
|
|
2369
|
+
if (tc.progressArg && !tc.startedFired && tc.argumentsDelta.length <= PROGRESS_ARG_SCAN_CAP) {
|
|
2370
|
+
const value = await readCompletedArg(tc.argumentsDelta, tc.progressArg);
|
|
2371
|
+
if (value !== void 0) {
|
|
2372
|
+
await this.fireToolCallStarted(state, tc, value);
|
|
2373
|
+
}
|
|
2302
2374
|
}
|
|
2303
2375
|
}
|
|
2304
2376
|
}
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2377
|
+
break;
|
|
2378
|
+
case "tool-call-done":
|
|
2379
|
+
{
|
|
2380
|
+
const existing = toolCallsMap.get(chunk.id);
|
|
2381
|
+
toolCallsMap.set(chunk.id, {
|
|
2382
|
+
...existing,
|
|
2383
|
+
id: chunk.id,
|
|
2384
|
+
name: existing?.name ?? "",
|
|
2385
|
+
argumentsDelta: JSON.stringify(chunk.arguments),
|
|
2386
|
+
extraContent: chunk.extraContent ?? existing?.extraContent
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
break;
|
|
2390
|
+
case "finish":
|
|
2391
|
+
finishReason = chunk.finishReason;
|
|
2392
|
+
usage = chunk.usage;
|
|
2393
|
+
reasoningDetails = chunk.reasoningDetails;
|
|
2394
|
+
providerResponseId = chunk.responseId;
|
|
2395
|
+
break;
|
|
2396
|
+
case "image-done":
|
|
2397
|
+
images.push({
|
|
2398
|
+
id: chunk.image.id,
|
|
2399
|
+
toolName: chunk.image.toolName,
|
|
2400
|
+
data: chunk.image.data,
|
|
2401
|
+
mediaType: chunk.image.mediaType,
|
|
2402
|
+
revisedPrompt: chunk.image.revisedPrompt
|
|
2316
2403
|
});
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
chunk.error,
|
|
2343
|
-
chunk.code || "unknown"
|
|
2404
|
+
break;
|
|
2405
|
+
case "web-search-done":
|
|
2406
|
+
webSearches.push(chunk.result);
|
|
2407
|
+
break;
|
|
2408
|
+
case "provider-tool-done":
|
|
2409
|
+
providerToolCalls.push(chunk.tool);
|
|
2410
|
+
break;
|
|
2411
|
+
case "error":
|
|
2412
|
+
throw new ProviderError(
|
|
2413
|
+
chunk.error,
|
|
2414
|
+
chunk.code || "unknown"
|
|
2415
|
+
);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
} finally {
|
|
2419
|
+
if (onParentAbort && parentSignal) {
|
|
2420
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
2421
|
+
}
|
|
2422
|
+
try {
|
|
2423
|
+
const cleanup = iterator.return?.();
|
|
2424
|
+
if (cleanup) {
|
|
2425
|
+
await awaitBounded(
|
|
2426
|
+
Promise.resolve(cleanup),
|
|
2427
|
+
STREAM_CLEANUP_BUDGET_MS,
|
|
2428
|
+
"stream iterator cleanup"
|
|
2344
2429
|
);
|
|
2430
|
+
}
|
|
2431
|
+
} catch {
|
|
2345
2432
|
}
|
|
2346
2433
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
try {
|
|
2352
|
-
const cleanup = iterator.return?.();
|
|
2353
|
-
if (cleanup) {
|
|
2354
|
-
await awaitBounded(
|
|
2355
|
-
Promise.resolve(cleanup),
|
|
2356
|
-
STREAM_CLEANUP_BUDGET_MS,
|
|
2357
|
-
"stream iterator cleanup"
|
|
2358
|
-
);
|
|
2434
|
+
for (const tc of toolCallsMap.values()) {
|
|
2435
|
+
if (!tc.startedFired) {
|
|
2436
|
+
const progress = tc.progressArg ? await readCompletedArg(tc.argumentsDelta, tc.progressArg) : void 0;
|
|
2437
|
+
await this.fireToolCallStarted(state, tc, progress);
|
|
2359
2438
|
}
|
|
2360
|
-
} catch {
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
for (const tc of toolCallsMap.values()) {
|
|
2364
|
-
if (!tc.startedFired) {
|
|
2365
|
-
const progress = tc.progressArg ? await readCompletedArg(tc.argumentsDelta, tc.progressArg) : void 0;
|
|
2366
|
-
await this.fireToolCallStarted(state, tc, progress);
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
const toolCalls = [];
|
|
2370
|
-
for (const tc of toolCallsMap.values()) {
|
|
2371
|
-
try {
|
|
2372
|
-
toolCalls.push({
|
|
2373
|
-
id: tc.id,
|
|
2374
|
-
name: tc.name,
|
|
2375
|
-
arguments: JSON.parse(tc.argumentsDelta || "{}"),
|
|
2376
|
-
extraContent: tc.extraContent
|
|
2377
|
-
});
|
|
2378
|
-
} catch {
|
|
2379
|
-
toolCalls.push({
|
|
2380
|
-
id: tc.id,
|
|
2381
|
-
name: tc.name,
|
|
2382
|
-
arguments: {},
|
|
2383
|
-
extraContent: tc.extraContent
|
|
2384
|
-
});
|
|
2385
2439
|
}
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2404
|
-
images: responseImages,
|
|
2405
|
-
finish_reason: finishReason,
|
|
2406
|
-
usage: usage ? convertUsage(usage) : {
|
|
2407
|
-
prompt_tokens: 0,
|
|
2408
|
-
completion_tokens: 0,
|
|
2409
|
-
total_tokens: 0
|
|
2440
|
+
const toolCalls = [];
|
|
2441
|
+
for (const tc of toolCallsMap.values()) {
|
|
2442
|
+
try {
|
|
2443
|
+
toolCalls.push({
|
|
2444
|
+
id: tc.id,
|
|
2445
|
+
name: tc.name,
|
|
2446
|
+
arguments: JSON.parse(tc.argumentsDelta || "{}"),
|
|
2447
|
+
extraContent: tc.extraContent
|
|
2448
|
+
});
|
|
2449
|
+
} catch {
|
|
2450
|
+
toolCalls.push({
|
|
2451
|
+
id: tc.id,
|
|
2452
|
+
name: tc.name,
|
|
2453
|
+
arguments: {},
|
|
2454
|
+
extraContent: tc.extraContent
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2410
2457
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2458
|
+
const responseId = `res_${crypto.randomUUID().substring(0, 12)}`;
|
|
2459
|
+
const responseImages = images.length > 0 ? images.map((img) => ({
|
|
2460
|
+
type: "image_url",
|
|
2461
|
+
id: img.id,
|
|
2462
|
+
toolName: img.toolName,
|
|
2463
|
+
image_url: {
|
|
2464
|
+
url: img.data.startsWith("data:") ? img.data : `data:${img.mediaType};base64,${img.data}`
|
|
2465
|
+
}
|
|
2466
|
+
})) : void 0;
|
|
2467
|
+
response = {
|
|
2468
|
+
id: responseId,
|
|
2469
|
+
model: modelName,
|
|
2470
|
+
content: content || null,
|
|
2471
|
+
reasoning_content: reasoning || null,
|
|
2472
|
+
reasoning_details: reasoningDetails,
|
|
2473
|
+
// Include reasoning details for multi-turn context
|
|
2474
|
+
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2475
|
+
images: responseImages,
|
|
2476
|
+
finish_reason: finishReason,
|
|
2477
|
+
usage: usage ? convertUsage(usage) : {
|
|
2478
|
+
prompt_tokens: 0,
|
|
2479
|
+
completion_tokens: 0,
|
|
2480
|
+
total_tokens: 0
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
response._provider = provider;
|
|
2484
|
+
response._viaPlatform = viaPlatform;
|
|
2485
|
+
if (platformProxyOrigin) {
|
|
2486
|
+
const feePercent = getObservedRouterFeePercent(platformProxyOrigin);
|
|
2487
|
+
if (feePercent !== null) {
|
|
2488
|
+
response._routerFeePercent = feePercent;
|
|
2489
|
+
}
|
|
2418
2490
|
}
|
|
2491
|
+
response._providerResponseId = providerResponseId;
|
|
2492
|
+
response._timing = {
|
|
2493
|
+
latencyMs: firstChunkAt > 0 ? firstChunkAt - requestSentAt : null,
|
|
2494
|
+
generationMs: firstTokenAt > 0 ? Math.max(0, lastTokenAt - firstTokenAt) : null
|
|
2495
|
+
};
|
|
2496
|
+
response._aggregate_response = {
|
|
2497
|
+
id: responseId,
|
|
2498
|
+
model: modelName,
|
|
2499
|
+
choices: [
|
|
2500
|
+
{
|
|
2501
|
+
index: 0,
|
|
2502
|
+
message: {
|
|
2503
|
+
role: "assistant",
|
|
2504
|
+
content: content || null,
|
|
2505
|
+
reasoning_content: reasoning || null,
|
|
2506
|
+
reasoning_details: reasoningDetails,
|
|
2507
|
+
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2508
|
+
// Include generated images in the aggregate response
|
|
2509
|
+
// Store ID for mapping to file paths later (don't store base64 data)
|
|
2510
|
+
images: images.length > 0 ? images.map((img) => ({
|
|
2511
|
+
type: "image_url",
|
|
2512
|
+
_id: img.id,
|
|
2513
|
+
// For path lookup
|
|
2514
|
+
image_url: {
|
|
2515
|
+
url: `[image:${img.id}]`
|
|
2516
|
+
// Placeholder, will be replaced with path
|
|
2517
|
+
}
|
|
2518
|
+
})) : void 0
|
|
2519
|
+
},
|
|
2520
|
+
finish_reason: finishReason
|
|
2521
|
+
}
|
|
2522
|
+
],
|
|
2523
|
+
usage: response.usage,
|
|
2524
|
+
// Also store image count for quick reference
|
|
2525
|
+
image_count: images.length,
|
|
2526
|
+
// Store web search results for logging
|
|
2527
|
+
web_searches: webSearches.length > 0 ? webSearches : void 0,
|
|
2528
|
+
// Store generic provider-executed tools for logging
|
|
2529
|
+
provider_tools: providerToolCalls.length > 0 ? providerToolCalls : void 0
|
|
2530
|
+
};
|
|
2419
2531
|
}
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
};
|
|
2425
|
-
response._aggregate_response = {
|
|
2426
|
-
id: responseId,
|
|
2427
|
-
model: modelName,
|
|
2428
|
-
choices: [
|
|
2429
|
-
{
|
|
2430
|
-
index: 0,
|
|
2431
|
-
message: {
|
|
2432
|
-
role: "assistant",
|
|
2433
|
-
content: content || null,
|
|
2434
|
-
reasoning_content: reasoning || null,
|
|
2435
|
-
reasoning_details: reasoningDetails,
|
|
2436
|
-
tool_calls: toolCalls.length > 0 ? convertToolCalls(toolCalls) : void 0,
|
|
2437
|
-
// Include generated images in the aggregate response
|
|
2438
|
-
// Store ID for mapping to file paths later (don't store base64 data)
|
|
2439
|
-
images: images.length > 0 ? images.map((img) => ({
|
|
2440
|
-
type: "image_url",
|
|
2441
|
-
_id: img.id,
|
|
2442
|
-
// For path lookup
|
|
2443
|
-
image_url: {
|
|
2444
|
-
url: `[image:${img.id}]`
|
|
2445
|
-
// Placeholder, will be replaced with path
|
|
2446
|
-
}
|
|
2447
|
-
})) : void 0
|
|
2448
|
-
},
|
|
2449
|
-
finish_reason: finishReason
|
|
2450
|
-
}
|
|
2451
|
-
],
|
|
2452
|
-
usage: response.usage,
|
|
2453
|
-
// Also store image count for quick reference
|
|
2454
|
-
image_count: images.length,
|
|
2455
|
-
// Store web search results for logging
|
|
2456
|
-
web_searches: webSearches.length > 0 ? webSearches : void 0,
|
|
2457
|
-
// Store generic provider-executed tools for logging
|
|
2458
|
-
provider_tools: providerToolCalls.length > 0 ? providerToolCalls : void 0
|
|
2459
|
-
};
|
|
2532
|
+
);
|
|
2533
|
+
} catch (error) {
|
|
2534
|
+
if (onParentAbort && parentSignal) {
|
|
2535
|
+
parentSignal.removeEventListener("abort", onParentAbort);
|
|
2460
2536
|
}
|
|
2461
|
-
|
|
2537
|
+
throw attributeThrownError(error, {
|
|
2538
|
+
provider: provider.name,
|
|
2539
|
+
viaPlatform
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2462
2542
|
if (!response) {
|
|
2463
2543
|
throw new Error("Provider stream returned no response");
|
|
2464
2544
|
}
|
|
2465
2545
|
return response;
|
|
2466
2546
|
}
|
|
2547
|
+
/** Persist and broadcast provider-route attribution before any response. */
|
|
2548
|
+
static async logProviderRoute(state, logId, providerName, viaPlatform) {
|
|
2549
|
+
try {
|
|
2550
|
+
if (!state.storage?.sql) return;
|
|
2551
|
+
const upstream = viaPlatform ? providerName : null;
|
|
2552
|
+
await state.storage.sql.exec(
|
|
2553
|
+
`UPDATE logs
|
|
2554
|
+
SET standard_agents_router_used = ?1,
|
|
2555
|
+
actual_provider = COALESCE(actual_provider, ?2)
|
|
2556
|
+
WHERE id = ?3`,
|
|
2557
|
+
viaPlatform ? 1 : 0,
|
|
2558
|
+
upstream,
|
|
2559
|
+
logId
|
|
2560
|
+
);
|
|
2561
|
+
state.emitLog?.({
|
|
2562
|
+
type: "log_data",
|
|
2563
|
+
log_id: logId,
|
|
2564
|
+
data: {
|
|
2565
|
+
id: logId,
|
|
2566
|
+
standard_agents_router_used: viaPlatform,
|
|
2567
|
+
...upstream ? { actual_provider: upstream } : {}
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
} catch (error) {
|
|
2571
|
+
console.error("Failed to update provider route attribution (non-fatal):", error);
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2467
2574
|
/**
|
|
2468
2575
|
* Emit content chunk to WebSocket for real-time UI updates
|
|
2469
2576
|
*/
|
|
@@ -2784,6 +2891,7 @@ var init_LLMRequest = __esm({
|
|
|
2784
2891
|
*/
|
|
2785
2892
|
static async logError(state, error, errorType, modelId, startTime, existingLogId) {
|
|
2786
2893
|
try {
|
|
2894
|
+
const attribution = resolveErrorAttribution(error);
|
|
2787
2895
|
let rawErrorMessage = error instanceof Error ? error.message : String(error);
|
|
2788
2896
|
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
2789
2897
|
if (error instanceof Error && error.name === "AbortError" && /operation was aborted/i.test(rawErrorMessage)) {
|
|
@@ -2825,8 +2933,12 @@ var init_LLMRequest = __esm({
|
|
|
2825
2933
|
// Parameter that caused error
|
|
2826
2934
|
"user_id",
|
|
2827
2935
|
// User context
|
|
2828
|
-
"response"
|
|
2936
|
+
"response",
|
|
2829
2937
|
// Raw response
|
|
2938
|
+
"origin",
|
|
2939
|
+
// Structured error origin from ProviderError/custom providers
|
|
2940
|
+
"upstream"
|
|
2941
|
+
// Actual upstream behind an adapter/router
|
|
2830
2942
|
];
|
|
2831
2943
|
const metadata = {};
|
|
2832
2944
|
for (const field of relevantFields) {
|
|
@@ -2877,6 +2989,7 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2877
2989
|
errorsArray.push({
|
|
2878
2990
|
message: truncatedError,
|
|
2879
2991
|
type: errorType,
|
|
2992
|
+
origin: attribution.origin,
|
|
2880
2993
|
timestamp: Date.now()
|
|
2881
2994
|
});
|
|
2882
2995
|
await state.storage.sql.exec(
|
|
@@ -2884,20 +2997,29 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2884
2997
|
UPDATE logs SET
|
|
2885
2998
|
error = ?1,
|
|
2886
2999
|
error_type = ?2,
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
3000
|
+
error_origin = ?3,
|
|
3001
|
+
errors = ?4,
|
|
3002
|
+
latency_ms = ?5,
|
|
3003
|
+
is_complete = ?6,
|
|
3004
|
+
actual_provider = COALESCE(actual_provider, ?7),
|
|
3005
|
+
standard_agents_router_used = CASE
|
|
3006
|
+
WHEN ?8 = 1 THEN 1
|
|
3007
|
+
ELSE standard_agents_router_used
|
|
3008
|
+
END
|
|
3009
|
+
WHERE id = ?9
|
|
2891
3010
|
`,
|
|
2892
3011
|
truncatedError,
|
|
2893
3012
|
// Keep last error in error field for backwards compatibility
|
|
2894
3013
|
errorType,
|
|
2895
3014
|
// Keep last error type
|
|
3015
|
+
attribution.origin,
|
|
2896
3016
|
JSON.stringify(errorsArray),
|
|
2897
3017
|
// All errors in array
|
|
2898
3018
|
Date.now() - startTime,
|
|
2899
3019
|
1,
|
|
2900
3020
|
// is_complete = true
|
|
3021
|
+
attribution.upstream ?? null,
|
|
3022
|
+
attribution.standardAgentsRouterUsed ? 1 : 0,
|
|
2901
3023
|
trackedLogId
|
|
2902
3024
|
);
|
|
2903
3025
|
}
|
|
@@ -2910,6 +3032,9 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2910
3032
|
id: trackedLogId,
|
|
2911
3033
|
error: truncatedError,
|
|
2912
3034
|
error_type: errorType,
|
|
3035
|
+
error_origin: attribution.origin,
|
|
3036
|
+
...attribution.upstream ? { actual_provider: attribution.upstream } : {},
|
|
3037
|
+
...attribution.standardAgentsRouterUsed ? { standard_agents_router_used: true } : {},
|
|
2913
3038
|
latency_ms: Date.now() - startTime,
|
|
2914
3039
|
is_complete: true
|
|
2915
3040
|
}
|
|
@@ -2926,9 +3051,12 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2926
3051
|
id,
|
|
2927
3052
|
message_id: messageId || "00000000-0000-0000-0000-000000000000",
|
|
2928
3053
|
provider: this.getProviderFromModel(modelId),
|
|
3054
|
+
actual_provider: attribution.upstream ?? null,
|
|
3055
|
+
standard_agents_router_used: attribution.standardAgentsRouterUsed,
|
|
2929
3056
|
model: modelId,
|
|
2930
3057
|
error: truncatedError,
|
|
2931
3058
|
error_type: errorType,
|
|
3059
|
+
error_origin: attribution.origin,
|
|
2932
3060
|
latency_ms: Date.now() - startTime,
|
|
2933
3061
|
is_complete: true,
|
|
2934
3062
|
created_at: Date.now() * TIMESTAMP_MULTIPLIER
|
|
@@ -2939,16 +3067,19 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2939
3067
|
await state.storage.sql.exec(
|
|
2940
3068
|
`
|
|
2941
3069
|
INSERT INTO logs (
|
|
2942
|
-
id, message_id, provider, model,
|
|
2943
|
-
error, error_type, latency_ms, is_complete, created_at
|
|
2944
|
-
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)
|
|
3070
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model,
|
|
3071
|
+
error, error_type, error_origin, latency_ms, is_complete, created_at
|
|
3072
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)
|
|
2945
3073
|
`,
|
|
2946
3074
|
logData.id,
|
|
2947
3075
|
messageId,
|
|
2948
3076
|
logData.provider,
|
|
3077
|
+
logData.actual_provider,
|
|
3078
|
+
logData.standard_agents_router_used ? 1 : 0,
|
|
2949
3079
|
logData.model,
|
|
2950
3080
|
logData.error,
|
|
2951
3081
|
logData.error_type,
|
|
3082
|
+
logData.error_origin,
|
|
2952
3083
|
logData.latency_ms,
|
|
2953
3084
|
1,
|
|
2954
3085
|
logData.created_at
|
|
@@ -6531,11 +6662,13 @@ ${errorStack}` : ""}`;
|
|
|
6531
6662
|
UPDATE logs
|
|
6532
6663
|
SET
|
|
6533
6664
|
error = ?1,
|
|
6534
|
-
error_type = ?2
|
|
6535
|
-
|
|
6665
|
+
error_type = ?2,
|
|
6666
|
+
error_origin = ?3
|
|
6667
|
+
WHERE id = ?4
|
|
6536
6668
|
`,
|
|
6537
6669
|
fullError,
|
|
6538
6670
|
"tool_execution_error",
|
|
6671
|
+
`tool:${toolName}`,
|
|
6539
6672
|
parentLogId
|
|
6540
6673
|
);
|
|
6541
6674
|
if (state.emitLog) {
|
|
@@ -6545,7 +6678,8 @@ ${errorStack}` : ""}`;
|
|
|
6545
6678
|
data: {
|
|
6546
6679
|
id: parentLogId,
|
|
6547
6680
|
error: fullError,
|
|
6548
|
-
error_type: "tool_execution_error"
|
|
6681
|
+
error_type: "tool_execution_error",
|
|
6682
|
+
error_origin: `tool:${toolName}`
|
|
6549
6683
|
}
|
|
6550
6684
|
});
|
|
6551
6685
|
}
|
|
@@ -7427,7 +7561,7 @@ var init_FlowEngine = __esm({
|
|
|
7427
7561
|
const error = "Request did not complete \u2014 the response was interrupted (the worker was evicted or the provider stalled) before it finished.";
|
|
7428
7562
|
const errorType = "interrupted_incomplete";
|
|
7429
7563
|
await state.storage.sql.exec(
|
|
7430
|
-
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2 WHERE is_complete = 0`,
|
|
7564
|
+
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2, error_origin = 'runtime' WHERE is_complete = 0`,
|
|
7431
7565
|
error,
|
|
7432
7566
|
errorType
|
|
7433
7567
|
);
|
|
@@ -7435,7 +7569,7 @@ var init_FlowEngine = __esm({
|
|
|
7435
7569
|
state.emitLog?.({
|
|
7436
7570
|
type: "log_data",
|
|
7437
7571
|
log_id: row.id,
|
|
7438
|
-
data: { id: row.id, is_complete: true, error, error_type: errorType }
|
|
7572
|
+
data: { id: row.id, is_complete: true, error, error_type: errorType, error_origin: "runtime" }
|
|
7439
7573
|
});
|
|
7440
7574
|
}
|
|
7441
7575
|
console.warn(
|
|
@@ -7971,7 +8105,7 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
7971
8105
|
pendingMessageId
|
|
7972
8106
|
);
|
|
7973
8107
|
await state.storage.sql.exec(
|
|
7974
|
-
`UPDATE logs SET error = ?, error_type =
|
|
8108
|
+
`UPDATE logs SET error = ?, error_type = ?, error_origin = 'runtime' WHERE id = ?`,
|
|
7975
8109
|
"Interrupted by user",
|
|
7976
8110
|
"user_interrupted",
|
|
7977
8111
|
logId
|
|
@@ -11514,8 +11648,8 @@ ${errorStack}` : ""}`;
|
|
|
11514
11648
|
`
|
|
11515
11649
|
INSERT INTO logs (
|
|
11516
11650
|
id, message_id, provider, model,
|
|
11517
|
-
error, error_type, created_at
|
|
11518
|
-
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)
|
|
11651
|
+
error, error_type, error_origin, created_at
|
|
11652
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, 'runtime', ?7)
|
|
11519
11653
|
`,
|
|
11520
11654
|
crypto.randomUUID(),
|
|
11521
11655
|
messageId,
|
|
@@ -15859,6 +15993,10 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
15859
15993
|
parent_log_id: string | null;
|
|
15860
15994
|
retry_of_log_id: string | null;
|
|
15861
15995
|
error: string | null;
|
|
15996
|
+
error_type: string | null;
|
|
15997
|
+
error_origin: import('@standardagents/spec').ErrorOrigin | null;
|
|
15998
|
+
actual_provider: string | null;
|
|
15999
|
+
standard_agents_router_used: boolean;
|
|
15862
16000
|
cost_total: number | null;
|
|
15863
16001
|
is_complete: boolean;
|
|
15864
16002
|
created_at: number;
|
|
@@ -25863,8 +26001,32 @@ var migration36 = {
|
|
|
25863
26001
|
}
|
|
25864
26002
|
};
|
|
25865
26003
|
|
|
26004
|
+
// src/durable-objects/migrations/037_add_error_origin.ts
|
|
26005
|
+
var migration37 = {
|
|
26006
|
+
version: 37,
|
|
26007
|
+
name: "add_error_origin",
|
|
26008
|
+
async up(sql) {
|
|
26009
|
+
const columns = sql.exec(`PRAGMA table_info(logs)`).toArray();
|
|
26010
|
+
if (!columns.some((column) => column.name === "error_origin")) {
|
|
26011
|
+
sql.exec(`ALTER TABLE logs ADD COLUMN error_origin TEXT`);
|
|
26012
|
+
}
|
|
26013
|
+
sql.exec(`
|
|
26014
|
+
UPDATE logs
|
|
26015
|
+
SET error_origin = CASE
|
|
26016
|
+
WHEN error_type = 'tool_execution_error' THEN 'tool:unknown'
|
|
26017
|
+
WHEN standard_agents_router_used = 1 THEN 'platform-router'
|
|
26018
|
+
WHEN provider IS NOT NULL AND provider NOT IN ('system', 'runtime')
|
|
26019
|
+
THEN 'provider:' || provider
|
|
26020
|
+
ELSE 'runtime'
|
|
26021
|
+
END
|
|
26022
|
+
WHERE error IS NOT NULL AND error_origin IS NULL
|
|
26023
|
+
`);
|
|
26024
|
+
sql.exec(`UPDATE _metadata SET value = '37' WHERE key = 'schema_version'`);
|
|
26025
|
+
}
|
|
26026
|
+
};
|
|
26027
|
+
|
|
25866
26028
|
// src/durable-objects/migrations/index.ts
|
|
25867
|
-
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];
|
|
26029
|
+
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];
|
|
25868
26030
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
25869
26031
|
|
|
25870
26032
|
// src/durable-objects/subagent-reconcile.ts
|
|
@@ -26700,7 +26862,7 @@ function eventSocketCanReceive(attachment, ownerUserId) {
|
|
|
26700
26862
|
}
|
|
26701
26863
|
|
|
26702
26864
|
// src/durable-objects/agentbuilder-migrations/0001_initial.ts
|
|
26703
|
-
var
|
|
26865
|
+
var migration38 = {
|
|
26704
26866
|
version: 1,
|
|
26705
26867
|
async up(sql) {
|
|
26706
26868
|
sql.exec(`
|
|
@@ -26799,7 +26961,7 @@ var migration37 = {
|
|
|
26799
26961
|
};
|
|
26800
26962
|
|
|
26801
26963
|
// src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
|
|
26802
|
-
var
|
|
26964
|
+
var migration39 = {
|
|
26803
26965
|
version: 2,
|
|
26804
26966
|
async up(sql) {
|
|
26805
26967
|
sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
|
|
@@ -26811,7 +26973,7 @@ var migration38 = {
|
|
|
26811
26973
|
};
|
|
26812
26974
|
|
|
26813
26975
|
// src/durable-objects/agentbuilder-migrations/0003_add_parent_and_terminated.ts
|
|
26814
|
-
var
|
|
26976
|
+
var migration40 = {
|
|
26815
26977
|
version: 3,
|
|
26816
26978
|
async up(sql) {
|
|
26817
26979
|
sql.exec(`ALTER TABLE threads ADD COLUMN parent TEXT REFERENCES threads(id)`);
|
|
@@ -26824,7 +26986,7 @@ var migration39 = {
|
|
|
26824
26986
|
};
|
|
26825
26987
|
|
|
26826
26988
|
// src/durable-objects/agentbuilder-migrations/0004_add_env_tables.ts
|
|
26827
|
-
var
|
|
26989
|
+
var migration41 = {
|
|
26828
26990
|
version: 4,
|
|
26829
26991
|
async up(sql) {
|
|
26830
26992
|
sql.exec(`ALTER TABLE threads ADD COLUMN env TEXT`);
|
|
@@ -26848,7 +27010,7 @@ var migration40 = {
|
|
|
26848
27010
|
};
|
|
26849
27011
|
|
|
26850
27012
|
// src/durable-objects/agentbuilder-migrations/0005_add_pending_subagent_env_requests.ts
|
|
26851
|
-
var
|
|
27013
|
+
var migration42 = {
|
|
26852
27014
|
version: 5,
|
|
26853
27015
|
async up(sql) {
|
|
26854
27016
|
sql.exec(`
|
|
@@ -26874,7 +27036,7 @@ var migration41 = {
|
|
|
26874
27036
|
};
|
|
26875
27037
|
|
|
26876
27038
|
// src/durable-objects/agentbuilder-migrations/0006_add_env_value_types.ts
|
|
26877
|
-
var
|
|
27039
|
+
var migration43 = {
|
|
26878
27040
|
version: 6,
|
|
26879
27041
|
async up(sql) {
|
|
26880
27042
|
sql.exec(
|
|
@@ -26889,7 +27051,7 @@ var migration42 = {
|
|
|
26889
27051
|
};
|
|
26890
27052
|
|
|
26891
27053
|
// src/durable-objects/agentbuilder-migrations/0007_platform_identity_replica.ts
|
|
26892
|
-
var
|
|
27054
|
+
var migration44 = {
|
|
26893
27055
|
version: 7,
|
|
26894
27056
|
async up(sql) {
|
|
26895
27057
|
sql.exec(`ALTER TABLE users ADD COLUMN platform_user_id TEXT`);
|
|
@@ -26918,7 +27080,7 @@ var migration43 = {
|
|
|
26918
27080
|
};
|
|
26919
27081
|
|
|
26920
27082
|
// src/durable-objects/agentbuilder-migrations/0008_add_skills.ts
|
|
26921
|
-
var
|
|
27083
|
+
var migration45 = {
|
|
26922
27084
|
version: 8,
|
|
26923
27085
|
async up(sql) {
|
|
26924
27086
|
sql.exec(`
|
|
@@ -26949,7 +27111,7 @@ var migration44 = {
|
|
|
26949
27111
|
};
|
|
26950
27112
|
|
|
26951
27113
|
// src/durable-objects/agentbuilder-migrations/0009_add_user_permissions.ts
|
|
26952
|
-
var
|
|
27114
|
+
var migration46 = {
|
|
26953
27115
|
version: 9,
|
|
26954
27116
|
async up(sql) {
|
|
26955
27117
|
sql.exec(`ALTER TABLE users ADD COLUMN permissions TEXT`);
|
|
@@ -26960,7 +27122,7 @@ var migration45 = {
|
|
|
26960
27122
|
};
|
|
26961
27123
|
|
|
26962
27124
|
// src/durable-objects/agentbuilder-migrations/0010_add_device_logins.ts
|
|
26963
|
-
var
|
|
27125
|
+
var migration47 = {
|
|
26964
27126
|
version: 10,
|
|
26965
27127
|
async up(sql) {
|
|
26966
27128
|
sql.exec(`
|
|
@@ -26980,7 +27142,7 @@ var migration46 = {
|
|
|
26980
27142
|
};
|
|
26981
27143
|
|
|
26982
27144
|
// src/durable-objects/agentbuilder-migrations/0011_add_user_values.ts
|
|
26983
|
-
var
|
|
27145
|
+
var migration48 = {
|
|
26984
27146
|
version: 11,
|
|
26985
27147
|
async up(sql) {
|
|
26986
27148
|
sql.exec(`
|
|
@@ -27003,7 +27165,7 @@ var migration47 = {
|
|
|
27003
27165
|
};
|
|
27004
27166
|
|
|
27005
27167
|
// src/durable-objects/agentbuilder-migrations/0012_allow_api_instance_role.ts
|
|
27006
|
-
var
|
|
27168
|
+
var migration49 = {
|
|
27007
27169
|
version: 12,
|
|
27008
27170
|
async up(sql) {
|
|
27009
27171
|
sql.exec(`CREATE TABLE oauth_accounts_0012_backup AS SELECT * FROM oauth_accounts`);
|
|
@@ -27113,7 +27275,7 @@ var migration48 = {
|
|
|
27113
27275
|
};
|
|
27114
27276
|
|
|
27115
27277
|
// src/durable-objects/agentbuilder-migrations/0013_add_thread_activity.ts
|
|
27116
|
-
var
|
|
27278
|
+
var migration50 = {
|
|
27117
27279
|
version: 13,
|
|
27118
27280
|
async up(sql) {
|
|
27119
27281
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_activity_at INTEGER`);
|
|
@@ -27129,7 +27291,7 @@ var migration49 = {
|
|
|
27129
27291
|
};
|
|
27130
27292
|
|
|
27131
27293
|
// src/durable-objects/agentbuilder-migrations/0014_thread_activity_scale.ts
|
|
27132
|
-
var
|
|
27294
|
+
var migration51 = {
|
|
27133
27295
|
version: 14,
|
|
27134
27296
|
async up(sql) {
|
|
27135
27297
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_preview TEXT`);
|
|
@@ -27147,7 +27309,7 @@ var migration50 = {
|
|
|
27147
27309
|
};
|
|
27148
27310
|
|
|
27149
27311
|
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
27150
|
-
var
|
|
27312
|
+
var migration52 = {
|
|
27151
27313
|
version: 15,
|
|
27152
27314
|
async up(sql) {
|
|
27153
27315
|
sql.exec(
|
|
@@ -27161,7 +27323,7 @@ var migration51 = {
|
|
|
27161
27323
|
};
|
|
27162
27324
|
|
|
27163
27325
|
// src/durable-objects/agentbuilder-migrations/0016_add_origin_agent.ts
|
|
27164
|
-
var
|
|
27326
|
+
var migration53 = {
|
|
27165
27327
|
version: 16,
|
|
27166
27328
|
async up(sql) {
|
|
27167
27329
|
sql.exec(`ALTER TABLE threads ADD COLUMN origin_agent_name TEXT`);
|
|
@@ -27176,7 +27338,7 @@ var migration52 = {
|
|
|
27176
27338
|
};
|
|
27177
27339
|
|
|
27178
27340
|
// src/durable-objects/agentbuilder-migrations/0017_add_thread_message_recency.ts
|
|
27179
|
-
var
|
|
27341
|
+
var migration54 = {
|
|
27180
27342
|
version: 17,
|
|
27181
27343
|
async up(sql) {
|
|
27182
27344
|
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_at INTEGER`);
|
|
@@ -27188,7 +27350,7 @@ var migration53 = {
|
|
|
27188
27350
|
};
|
|
27189
27351
|
|
|
27190
27352
|
// src/durable-objects/agentbuilder-migrations/0018_auth_security.ts
|
|
27191
|
-
var
|
|
27353
|
+
var migration55 = {
|
|
27192
27354
|
version: 18,
|
|
27193
27355
|
async up(sql) {
|
|
27194
27356
|
sql.exec(`
|
|
@@ -27220,7 +27382,7 @@ var migration54 = {
|
|
|
27220
27382
|
};
|
|
27221
27383
|
|
|
27222
27384
|
// src/durable-objects/agentbuilder-migrations/0019_scope_skills.ts
|
|
27223
|
-
var
|
|
27385
|
+
var migration56 = {
|
|
27224
27386
|
version: 19,
|
|
27225
27387
|
async up(sql) {
|
|
27226
27388
|
sql.exec(`
|
|
@@ -27270,7 +27432,7 @@ var migration55 = {
|
|
|
27270
27432
|
};
|
|
27271
27433
|
|
|
27272
27434
|
// src/durable-objects/agentbuilder-migrations/0020_websocket_tickets.ts
|
|
27273
|
-
var
|
|
27435
|
+
var migration57 = {
|
|
27274
27436
|
version: 20,
|
|
27275
27437
|
async up(sql) {
|
|
27276
27438
|
sql.exec(`
|
|
@@ -27291,7 +27453,7 @@ var migration56 = {
|
|
|
27291
27453
|
};
|
|
27292
27454
|
|
|
27293
27455
|
// src/durable-objects/agentbuilder-migrations/0021_platform_handoff_jtis.ts
|
|
27294
|
-
var
|
|
27456
|
+
var migration58 = {
|
|
27295
27457
|
version: 21,
|
|
27296
27458
|
async up(sql) {
|
|
27297
27459
|
sql.exec(`
|
|
@@ -27310,9 +27472,9 @@ var migration57 = {
|
|
|
27310
27472
|
};
|
|
27311
27473
|
|
|
27312
27474
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
27313
|
-
var migrations2 = [
|
|
27475
|
+
var migrations2 = [migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49, migration50, migration51, migration52, migration53, migration54, migration55, migration56, migration57, migration58];
|
|
27314
27476
|
var LATEST_SCHEMA_VERSION2 = migrations2.reduce(
|
|
27315
|
-
(max,
|
|
27477
|
+
(max, migration59) => Math.max(max, migration59.version),
|
|
27316
27478
|
0
|
|
27317
27479
|
);
|
|
27318
27480
|
|
|
@@ -28098,9 +28260,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
28098
28260
|
}
|
|
28099
28261
|
}
|
|
28100
28262
|
async runMigrations(fromVersion) {
|
|
28101
|
-
for (const
|
|
28102
|
-
if (
|
|
28103
|
-
await
|
|
28263
|
+
for (const migration59 of migrations2) {
|
|
28264
|
+
if (migration59.version > fromVersion) {
|
|
28265
|
+
await migration59.up(this.ctx.storage.sql);
|
|
28104
28266
|
}
|
|
28105
28267
|
}
|
|
28106
28268
|
}
|
|
@@ -32484,9 +32646,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
32484
32646
|
* Each migration is run in order, starting from the current version + 1.
|
|
32485
32647
|
*/
|
|
32486
32648
|
async runMigrations(fromVersion) {
|
|
32487
|
-
for (const
|
|
32488
|
-
if (
|
|
32489
|
-
await
|
|
32649
|
+
for (const migration59 of migrations) {
|
|
32650
|
+
if (migration59.version > fromVersion) {
|
|
32651
|
+
await migration59.up(this.ctx.storage.sql);
|
|
32490
32652
|
}
|
|
32491
32653
|
}
|
|
32492
32654
|
}
|
|
@@ -34008,7 +34170,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34008
34170
|
`
|
|
34009
34171
|
SELECT
|
|
34010
34172
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
34011
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, cost_total,
|
|
34173
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
34012
34174
|
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
34013
34175
|
is_complete, created_at
|
|
34014
34176
|
FROM logs
|
|
@@ -34034,6 +34196,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34034
34196
|
retry_of_log_id: row.retry_of_log_id,
|
|
34035
34197
|
error: row.error,
|
|
34036
34198
|
error_type: row.error_type,
|
|
34199
|
+
error_origin: row.error_origin,
|
|
34037
34200
|
cost_total: row.cost_total,
|
|
34038
34201
|
input_tokens: row.input_tokens,
|
|
34039
34202
|
cached_tokens: row.cached_tokens,
|
|
@@ -34143,16 +34306,16 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34143
34306
|
WHERE logs.parent_log_id IS NOT NULL
|
|
34144
34307
|
)
|
|
34145
34308
|
SELECT
|
|
34146
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
34147
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
34309
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
34310
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
34148
34311
|
is_complete, created_at
|
|
34149
34312
|
FROM logs
|
|
34150
34313
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
34151
34314
|
ORDER BY created_at ${order}, rowid ${order}
|
|
34152
34315
|
` : `
|
|
34153
34316
|
SELECT
|
|
34154
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
34155
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
34317
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
34318
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
34156
34319
|
is_complete, created_at
|
|
34157
34320
|
FROM logs
|
|
34158
34321
|
WHERE id IN (${placeholders})
|
|
@@ -34164,6 +34327,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34164
34327
|
message_id: row.message_id,
|
|
34165
34328
|
provider: row.provider,
|
|
34166
34329
|
actual_provider: row.actual_provider,
|
|
34330
|
+
standard_agents_router_used: row.standard_agents_router_used === 1,
|
|
34167
34331
|
model: row.model,
|
|
34168
34332
|
model_name: row.model_name,
|
|
34169
34333
|
prompt_name: row.prompt_name,
|
|
@@ -34173,6 +34337,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34173
34337
|
parent_log_id: row.parent_log_id,
|
|
34174
34338
|
retry_of_log_id: row.retry_of_log_id,
|
|
34175
34339
|
error: row.error,
|
|
34340
|
+
error_type: row.error_type,
|
|
34341
|
+
error_origin: row.error_origin,
|
|
34176
34342
|
cost_total: row.cost_total,
|
|
34177
34343
|
is_complete: row.is_complete === 1,
|
|
34178
34344
|
created_at: row.created_at
|
|
@@ -34258,8 +34424,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34258
34424
|
)
|
|
34259
34425
|
SELECT
|
|
34260
34426
|
rowid AS row_index,
|
|
34261
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
34262
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
34427
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
34428
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
34263
34429
|
is_complete, created_at
|
|
34264
34430
|
FROM logs
|
|
34265
34431
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
@@ -34267,8 +34433,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34267
34433
|
` : `
|
|
34268
34434
|
SELECT
|
|
34269
34435
|
rowid AS row_index,
|
|
34270
|
-
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
34271
|
-
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
34436
|
+
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
34437
|
+
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, error_type, error_origin, cost_total,
|
|
34272
34438
|
is_complete, created_at
|
|
34273
34439
|
FROM logs
|
|
34274
34440
|
WHERE message_id IN (${placeholders})
|
|
@@ -34289,6 +34455,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34289
34455
|
message_id: row.message_id,
|
|
34290
34456
|
provider: row.provider,
|
|
34291
34457
|
actual_provider: row.actual_provider,
|
|
34458
|
+
standard_agents_router_used: row.standard_agents_router_used === 1,
|
|
34292
34459
|
model: row.model,
|
|
34293
34460
|
model_name: row.model_name,
|
|
34294
34461
|
prompt_name: row.prompt_name,
|
|
@@ -34298,6 +34465,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34298
34465
|
parent_log_id: row.parent_log_id,
|
|
34299
34466
|
retry_of_log_id: row.retry_of_log_id,
|
|
34300
34467
|
error: row.error,
|
|
34468
|
+
error_type: row.error_type,
|
|
34469
|
+
error_origin: row.error_origin,
|
|
34301
34470
|
cost_total: row.cost_total,
|
|
34302
34471
|
is_complete: row.is_complete === 1,
|
|
34303
34472
|
created_at: row.created_at
|
|
@@ -34319,7 +34488,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34319
34488
|
l.request_headers, l.response_headers, l.status_code,
|
|
34320
34489
|
l.input_tokens, l.cached_tokens, l.output_tokens,
|
|
34321
34490
|
l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
|
|
34322
|
-
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,
|
|
34491
|
+
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,
|
|
34323
34492
|
l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
|
|
34324
34493
|
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
34325
34494
|
l.errors, l.retry_of_log_id, l.is_complete, l.created_at,
|
|
@@ -34393,6 +34562,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
34393
34562
|
finish_reason: row.finish_reason,
|
|
34394
34563
|
error: row.error,
|
|
34395
34564
|
error_type: row.error_type,
|
|
34565
|
+
error_origin: row.error_origin,
|
|
34396
34566
|
cost_input: row.cost_input,
|
|
34397
34567
|
cost_cached: row.cost_cached,
|
|
34398
34568
|
cost_output: row.cost_output,
|
|
@@ -36639,7 +36809,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
36639
36809
|
const error = "Request lost \u2014 the executor restarted (deploy or eviction) or hung before finishing. The thread watchdog finalized it.";
|
|
36640
36810
|
const errorType = "execution_lost";
|
|
36641
36811
|
await this.ctx.storage.sql.exec(
|
|
36642
|
-
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2 WHERE is_complete = 0`,
|
|
36812
|
+
`UPDATE logs SET is_complete = 1, error = ?1, error_type = ?2, error_origin = 'runtime' WHERE is_complete = 0`,
|
|
36643
36813
|
error,
|
|
36644
36814
|
errorType
|
|
36645
36815
|
);
|
|
@@ -36647,7 +36817,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
36647
36817
|
this.broadcastLog({
|
|
36648
36818
|
type: "log_data",
|
|
36649
36819
|
log_id: id,
|
|
36650
|
-
data: { id, is_complete: true, error, error_type: errorType }
|
|
36820
|
+
data: { id, is_complete: true, error, error_type: errorType, error_origin: "runtime" }
|
|
36651
36821
|
});
|
|
36652
36822
|
}
|
|
36653
36823
|
try {
|