@standardagents/builder 0.35.1 → 0.35.3
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 +66 -21
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-Dmq8ljTo.js → ApiKeysView-5EM1pB60.js} +1 -1
- package/dist/client/{CenteredContentView-DM7LkIKF.js → CenteredContentView-CV8QAco9.js} +1 -1
- package/dist/client/CompositionView-D_M-Eajw.js +32 -0
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-Cfo-jqEF.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-COlMI9pk.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-C5aCLIhv.js → CopyButton.vue_vue_type_script_setup_true_lang-BuKxnIzL.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-deYaXdha.js → DataTable.vue_vue_type_script_setup_true_lang-B4G2YHdb.js} +1 -1
- package/dist/client/{JsonViewer-BCNJYUIz.js → JsonViewer-BZ7Aadme.js} +1 -1
- package/dist/client/{LoginView-BHA2IKoE.js → LoginView-CyuV4gke.js} +1 -1
- package/dist/client/{MarketplaceView-BaYCbQeY.js → MarketplaceView-CoHrzmNk.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-B1DUndvK.js → Modal.vue_vue_type_script_setup_true_lang-DSajL5Fd.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-BWl1Kknp.js → ModelModal.vue_vue_type_script_setup_true_lang-6UIPVigs.js} +1 -1
- package/dist/client/{ModelsView-CapeJwZE.js → ModelsView-DFGteAQS.js} +1 -1
- package/dist/client/{PromptEditView-DhGDru6i.js → PromptEditView-BRSrC8Jp.js} +1 -1
- package/dist/client/{PromptModal-Dy7ZLTrD.js → PromptModal-BxITA4l1.js} +1 -1
- package/dist/client/{PromptsView-DzyP3URp.js → PromptsView-C7-GT7uq.js} +1 -1
- package/dist/client/{ProvidersView-CEM2pkVl.js → ProvidersView-DnRgjgqa.js} +1 -1
- package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-TEAPHb0Y.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CE6qD6Zb.js} +8 -8
- package/dist/client/{ThreadsView-DeQ1mZp6.js → ThreadsView-TVOJzvJ4.js} +1 -1
- package/dist/client/{ToolsView--_ivoaJq.js → ToolsView-C2UrMMOe.js} +1 -1
- package/dist/client/{UsersView-CHVGj7RB.js → UsersView-C3_SvVDT.js} +1 -1
- package/dist/client/{VariablesView-Ey6egYHo.js → VariablesView-crHzb8II.js} +1 -1
- package/dist/client/assets/{CompositionView-eTR5Ewx2.css → CompositionView-nJBKoNx4.css} +1 -1
- package/dist/client/{index-oR3Tbjo6.js → index-CbuxomcU.js} +2 -2
- package/dist/client/index.html +1 -1
- package/dist/{index-D7luZUMB.d.ts → index-DP9GxPHu.d.ts} +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +194 -55
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +1 -2
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +37 -15
- package/dist/runtime.js +193 -53
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CompositionView-CCW3XCKA.js +0 -32
package/dist/client/index.html
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
27
27
|
<link rel="icon" type="image/svg+xml" href="/agents/assets/img/favicon-9uH1rb2F.svg">
|
|
28
28
|
<title>AgentBuilder Admin</title>
|
|
29
|
-
<script type="module" crossorigin src="/agents/index-
|
|
29
|
+
<script type="module" crossorigin src="/agents/index-CbuxomcU.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/agents/formkit-DcZQH9-p.js">
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/agents/vendor-TPZjEwCU.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="/agents/syntax-D-ZcovVx.js">
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModelDefinition, AgentDefinition } from './runtime.js';
|
|
2
2
|
export { AgentBuilderEnv, AuthContext, AuthUser, BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, FlowStateWithSdk, HubClientInfo, ImageContextConfig, InjectMessageOptions, LLMProviderInterface, NamespaceResolutionError, PromptContent, PromptDefinition, PromptIncludePart, PromptPart, PromptToolConfig, Provider, ProviderContentPart, ProviderFilePart, ProviderImagePart, ProviderRegistry, ProviderTextPart, SessionToolBinding, SessionToolConfig, SideConfig, SubagentToolConfig, SubpromptConfig, ThreadRegistryEntry, ThreadWatchdog, ThreadWatchdogState, ToolConfig, UpdateThreadParams, User, WatchdogCheckin, WatchdogProbeResult, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage } from './runtime.js';
|
|
3
3
|
export { AgentPluginOptions, agentbuilder, builder } from './plugin.js';
|
|
4
|
-
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
4
|
+
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-DP9GxPHu.js';
|
|
5
5
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderConfigSlot, ProviderConfigSlots, ProviderConfigValueSource, ProviderDefinition, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ProviderMethodOverrides, ModelCapabilities as ProviderModelCapabilities, ProviderOverride, ProviderOverrideContext, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSyncOverride, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineProvider, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue } from '@standardagents/spec';
|
|
6
6
|
export { C as ConstituentItem, D as DiscoveredPackage, N as NamespacedRegistry, P as PackingAnalysis, a as PackingOptions, b as PackingResult, c as UnpackOptions, d as UnpackResult } from './types-Bpe7IANZ.js';
|
|
7
7
|
export { D as DiscoveryConfig, P as PackageDiscoveryService, d as discoverPackages } from './discovery-DiMJWisl.js';
|
package/dist/index.js
CHANGED
|
@@ -470,6 +470,56 @@ var init_toolProgress = __esm({
|
|
|
470
470
|
PROGRESS_ARG_SCAN_CAP = 8192;
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
|
+
|
|
474
|
+
// src/agents/logBroadcast.ts
|
|
475
|
+
function toLogListItem(logData) {
|
|
476
|
+
const slim = { id: logData.id };
|
|
477
|
+
for (const field of LOG_BROADCAST_FIELDS) {
|
|
478
|
+
if (field === "id" || !(field in logData)) continue;
|
|
479
|
+
slim[field] = logData[field];
|
|
480
|
+
}
|
|
481
|
+
return slim;
|
|
482
|
+
}
|
|
483
|
+
var LOG_BROADCAST_FIELDS;
|
|
484
|
+
var init_logBroadcast = __esm({
|
|
485
|
+
"src/agents/logBroadcast.ts"() {
|
|
486
|
+
LOG_BROADCAST_FIELDS = [
|
|
487
|
+
"id",
|
|
488
|
+
"message_id",
|
|
489
|
+
"provider",
|
|
490
|
+
"actual_provider",
|
|
491
|
+
"model",
|
|
492
|
+
"model_name",
|
|
493
|
+
"prompt_name",
|
|
494
|
+
"tools_called",
|
|
495
|
+
"queued_tools",
|
|
496
|
+
"provider_tools",
|
|
497
|
+
"parent_log_id",
|
|
498
|
+
"retry_of_log_id",
|
|
499
|
+
"error",
|
|
500
|
+
"error_type",
|
|
501
|
+
"finish_reason",
|
|
502
|
+
"cost_total",
|
|
503
|
+
"cost_input",
|
|
504
|
+
"cost_cached",
|
|
505
|
+
"cost_output",
|
|
506
|
+
"cost_router_fee",
|
|
507
|
+
"router_fee_percent",
|
|
508
|
+
"input_tokens",
|
|
509
|
+
"cached_tokens",
|
|
510
|
+
"output_tokens",
|
|
511
|
+
"reasoning_tokens",
|
|
512
|
+
"total_tokens",
|
|
513
|
+
"latency_ms",
|
|
514
|
+
"time_to_first_token_ms",
|
|
515
|
+
"generation_ms",
|
|
516
|
+
"content",
|
|
517
|
+
"reasoning_content",
|
|
518
|
+
"is_complete",
|
|
519
|
+
"created_at"
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
473
523
|
var init_types2 = __esm({
|
|
474
524
|
"src/agents/providers/types.ts"() {
|
|
475
525
|
}
|
|
@@ -1755,6 +1805,7 @@ var init_LLMRequest = __esm({
|
|
|
1755
1805
|
init_types();
|
|
1756
1806
|
init_FlowEngine();
|
|
1757
1807
|
init_toolProgress();
|
|
1808
|
+
init_logBroadcast();
|
|
1758
1809
|
NON_VISION_PLACEHOLDER_TEXT = "[Image omitted: model does not support vision]";
|
|
1759
1810
|
STREAM_FIRST_CHUNK_TIMEOUT_MS = 12e4;
|
|
1760
1811
|
STREAM_STALL_TIMEOUT_MS = 45e3;
|
|
@@ -2006,7 +2057,7 @@ var init_LLMRequest = __esm({
|
|
|
2006
2057
|
state.emitLog({
|
|
2007
2058
|
type: "log_data",
|
|
2008
2059
|
log_id: logData.id,
|
|
2009
|
-
data: logData
|
|
2060
|
+
data: toLogListItem(logData)
|
|
2010
2061
|
});
|
|
2011
2062
|
}
|
|
2012
2063
|
return id;
|
|
@@ -2605,7 +2656,7 @@ var init_LLMRequest = __esm({
|
|
|
2605
2656
|
state.emitLog({
|
|
2606
2657
|
type: "log_data",
|
|
2607
2658
|
log_id: logData.id,
|
|
2608
|
-
data: logData
|
|
2659
|
+
data: toLogListItem(logData)
|
|
2609
2660
|
});
|
|
2610
2661
|
}
|
|
2611
2662
|
} catch (error) {
|
|
@@ -2650,13 +2701,6 @@ var init_LLMRequest = __esm({
|
|
|
2650
2701
|
JSON.stringify(transformedResponse),
|
|
2651
2702
|
logId
|
|
2652
2703
|
);
|
|
2653
|
-
if (state.emitLog) {
|
|
2654
|
-
state.emitLog({
|
|
2655
|
-
type: "log_data",
|
|
2656
|
-
log_id: logId,
|
|
2657
|
-
data: { id: logId, response_body: JSON.stringify(transformedResponse) }
|
|
2658
|
-
});
|
|
2659
|
-
}
|
|
2660
2704
|
} catch (error) {
|
|
2661
2705
|
console.error("Failed to update response body in log (non-fatal):", error);
|
|
2662
2706
|
}
|
|
@@ -2875,7 +2919,7 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2875
2919
|
state.emitLog({
|
|
2876
2920
|
type: "log_data",
|
|
2877
2921
|
log_id: logData.id,
|
|
2878
|
-
data: logData
|
|
2922
|
+
data: toLogListItem(logData)
|
|
2879
2923
|
});
|
|
2880
2924
|
}
|
|
2881
2925
|
if (errorObj && !errorObj._loggedId) {
|
|
@@ -14691,7 +14735,6 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
14691
14735
|
cost_total: number | null;
|
|
14692
14736
|
is_complete: boolean;
|
|
14693
14737
|
created_at: number;
|
|
14694
|
-
request_body: string | null;
|
|
14695
14738
|
}
|
|
14696
14739
|
|
|
14697
14740
|
export interface GetLogsResult {
|
|
@@ -14702,6 +14745,7 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
14702
14745
|
|
|
14703
14746
|
export interface ThreadLogDetails extends ThreadLog {
|
|
14704
14747
|
endpoint: string | null;
|
|
14748
|
+
request_body: string | null;
|
|
14705
14749
|
request_headers: string | null;
|
|
14706
14750
|
response_body: string | null;
|
|
14707
14751
|
response_headers: string | null;
|
|
@@ -14724,7 +14768,6 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
14724
14768
|
message_history_length: number | null;
|
|
14725
14769
|
tools_available: number | null;
|
|
14726
14770
|
tools_schema: string | null;
|
|
14727
|
-
message_history: string | null;
|
|
14728
14771
|
system_prompt: string | null;
|
|
14729
14772
|
errors: string | null;
|
|
14730
14773
|
tool_results: string | null;
|
|
@@ -24747,6 +24790,30 @@ function isQualifiedName(name) {
|
|
|
24747
24790
|
return name.includes("/");
|
|
24748
24791
|
}
|
|
24749
24792
|
|
|
24793
|
+
// src/durable-objects/logDetailStream.ts
|
|
24794
|
+
var LOG_DETAIL_HEAVY_FIELDS = [
|
|
24795
|
+
"request_body",
|
|
24796
|
+
"response_body",
|
|
24797
|
+
"tools_schema",
|
|
24798
|
+
"system_prompt",
|
|
24799
|
+
"tool_results",
|
|
24800
|
+
"reasoning_content",
|
|
24801
|
+
"source_message_content"
|
|
24802
|
+
];
|
|
24803
|
+
async function* serializeLogDetailChunks(scalars, readField) {
|
|
24804
|
+
const head2 = JSON.stringify(scalars);
|
|
24805
|
+
const hasScalarKeys = head2 !== "{}";
|
|
24806
|
+
yield hasScalarKeys ? head2.slice(0, -1) : "{";
|
|
24807
|
+
let needsComma = hasScalarKeys;
|
|
24808
|
+
for (const field of LOG_DETAIL_HEAVY_FIELDS) {
|
|
24809
|
+
const value = await readField(field);
|
|
24810
|
+
const encoded = value === null || value === void 0 ? "null" : JSON.stringify(value);
|
|
24811
|
+
yield `${needsComma ? "," : ""}${JSON.stringify(field)}:${encoded}`;
|
|
24812
|
+
needsComma = true;
|
|
24813
|
+
}
|
|
24814
|
+
yield "}";
|
|
24815
|
+
}
|
|
24816
|
+
|
|
24750
24817
|
// src/durable-objects/DurableThread.ts
|
|
24751
24818
|
init_client_forwarding();
|
|
24752
24819
|
init_sessionTools();
|
|
@@ -26228,15 +26295,20 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
26228
26295
|
}
|
|
26229
26296
|
const upgradeHeader = request.headers.get("Upgrade");
|
|
26230
26297
|
if (upgradeHeader?.toLowerCase() === "websocket") {
|
|
26231
|
-
const
|
|
26232
|
-
if (
|
|
26298
|
+
const url2 = new URL(request.url);
|
|
26299
|
+
if (url2.pathname.includes("/bridge")) {
|
|
26233
26300
|
return this.handleBridgeWebSocketUpgrade(request);
|
|
26234
|
-
} else if (
|
|
26301
|
+
} else if (url2.pathname.includes("/stream")) {
|
|
26235
26302
|
return this.handleMessagesWebSocketUpgrade(request);
|
|
26236
26303
|
} else {
|
|
26237
26304
|
return this.handleLogsWebSocketUpgrade(request);
|
|
26238
26305
|
}
|
|
26239
26306
|
}
|
|
26307
|
+
const url = new URL(request.url);
|
|
26308
|
+
const logDetailMatch = url.pathname.match(/\/internal\/logs\/([^/]+)\/details$/);
|
|
26309
|
+
if (logDetailMatch && request.method === "GET") {
|
|
26310
|
+
return this.streamLogDetails(decodeURIComponent(logDetailMatch[1]));
|
|
26311
|
+
}
|
|
26240
26312
|
return new Response("Use RPC methods instead of fetch", { status: 400 });
|
|
26241
26313
|
}
|
|
26242
26314
|
registerCodeExecutionBridge(runId, bridge) {
|
|
@@ -27690,7 +27762,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27690
27762
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
27691
27763
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
27692
27764
|
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
27693
|
-
is_complete, created_at
|
|
27765
|
+
is_complete, created_at
|
|
27694
27766
|
FROM logs
|
|
27695
27767
|
ORDER BY created_at ${order}
|
|
27696
27768
|
LIMIT ? OFFSET ?
|
|
@@ -27719,8 +27791,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27719
27791
|
output_tokens: row.output_tokens,
|
|
27720
27792
|
total_tokens: row.total_tokens,
|
|
27721
27793
|
is_complete: row.is_complete === 1,
|
|
27722
|
-
created_at: row.created_at
|
|
27723
|
-
request_body: row.request_body
|
|
27794
|
+
created_at: row.created_at
|
|
27724
27795
|
}));
|
|
27725
27796
|
const hasMore = offset + logs.length < total;
|
|
27726
27797
|
return { logs, total, hasMore };
|
|
@@ -27825,7 +27896,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27825
27896
|
SELECT
|
|
27826
27897
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
27827
27898
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
27828
|
-
is_complete, created_at
|
|
27899
|
+
is_complete, created_at
|
|
27829
27900
|
FROM logs
|
|
27830
27901
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
27831
27902
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -27833,7 +27904,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27833
27904
|
SELECT
|
|
27834
27905
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
27835
27906
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
27836
|
-
is_complete, created_at
|
|
27907
|
+
is_complete, created_at
|
|
27837
27908
|
FROM logs
|
|
27838
27909
|
WHERE id IN (${placeholders})
|
|
27839
27910
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -27855,8 +27926,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27855
27926
|
error: row.error,
|
|
27856
27927
|
cost_total: row.cost_total,
|
|
27857
27928
|
is_complete: row.is_complete === 1,
|
|
27858
|
-
created_at: row.created_at
|
|
27859
|
-
request_body: row.request_body
|
|
27929
|
+
created_at: row.created_at
|
|
27860
27930
|
}));
|
|
27861
27931
|
return { logs, total: logs.length, hasMore: false };
|
|
27862
27932
|
}
|
|
@@ -27941,7 +28011,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27941
28011
|
rowid AS row_index,
|
|
27942
28012
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
27943
28013
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
27944
|
-
is_complete, created_at
|
|
28014
|
+
is_complete, created_at
|
|
27945
28015
|
FROM logs
|
|
27946
28016
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
27947
28017
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -27950,7 +28020,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27950
28020
|
rowid AS row_index,
|
|
27951
28021
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
27952
28022
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
27953
|
-
is_complete, created_at
|
|
28023
|
+
is_complete, created_at
|
|
27954
28024
|
FROM logs
|
|
27955
28025
|
WHERE message_id IN (${placeholders})
|
|
27956
28026
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -27981,31 +28051,30 @@ ${resultContent}${attachmentSummary}`;
|
|
|
27981
28051
|
error: row.error,
|
|
27982
28052
|
cost_total: row.cost_total,
|
|
27983
28053
|
is_complete: row.is_complete === 1,
|
|
27984
|
-
created_at: row.created_at
|
|
27985
|
-
request_body: row.request_body
|
|
28054
|
+
created_at: row.created_at
|
|
27986
28055
|
}));
|
|
27987
28056
|
return { logs, total: logs.length, hasMore: false };
|
|
27988
28057
|
}
|
|
27989
28058
|
/**
|
|
27990
|
-
*
|
|
27991
|
-
*
|
|
28059
|
+
* Scalar (non-heavy) log-detail fields plus joined source-message scalars
|
|
28060
|
+
* and scheduled-effect provenance. The multi-MB TEXT columns are read one
|
|
28061
|
+
* at a time via readLogDetailHeavyField so no caller ever holds them all
|
|
28062
|
+
* in memory at once.
|
|
27992
28063
|
*/
|
|
27993
|
-
async
|
|
27994
|
-
await this.ensureMigrated();
|
|
28064
|
+
async readLogDetailScalars(logId) {
|
|
27995
28065
|
try {
|
|
27996
28066
|
const result = await this.ctx.storage.sql.exec(
|
|
27997
28067
|
`
|
|
27998
28068
|
SELECT
|
|
27999
28069
|
l.id, l.message_id, l.provider, l.actual_provider, l.standard_agents_router_used, l.model, l.model_name, l.endpoint,
|
|
28000
|
-
l.
|
|
28001
|
-
l.
|
|
28070
|
+
l.request_headers, l.response_headers, l.status_code,
|
|
28071
|
+
l.input_tokens, l.cached_tokens, l.output_tokens,
|
|
28002
28072
|
l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
|
|
28003
28073
|
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,
|
|
28004
28074
|
l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
|
|
28005
|
-
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
28006
|
-
l.errors, l.retry_of_log_id, l.
|
|
28075
|
+
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
28076
|
+
l.errors, l.retry_of_log_id, l.is_complete, l.created_at,
|
|
28007
28077
|
m.role as source_message_role,
|
|
28008
|
-
m.content as source_message_content,
|
|
28009
28078
|
m.created_at as source_message_created_at,
|
|
28010
28079
|
m.metadata as source_message_metadata
|
|
28011
28080
|
FROM logs l
|
|
@@ -28052,17 +28121,6 @@ ${resultContent}${attachmentSummary}`;
|
|
|
28052
28121
|
replayedFrom: effectRow.replayed_from
|
|
28053
28122
|
};
|
|
28054
28123
|
});
|
|
28055
|
-
let messageHistory = null;
|
|
28056
|
-
if (row.request_body) {
|
|
28057
|
-
try {
|
|
28058
|
-
const requestBody = JSON.parse(row.request_body);
|
|
28059
|
-
if (requestBody.messages) {
|
|
28060
|
-
messageHistory = JSON.stringify(requestBody.messages);
|
|
28061
|
-
}
|
|
28062
|
-
} catch (e) {
|
|
28063
|
-
console.error("Failed to parse request_body to extract message_history:", e);
|
|
28064
|
-
}
|
|
28065
|
-
}
|
|
28066
28124
|
return {
|
|
28067
28125
|
id: row.id,
|
|
28068
28126
|
message_id: row.message_id,
|
|
@@ -28072,12 +28130,9 @@ ${resultContent}${attachmentSummary}`;
|
|
|
28072
28130
|
model: row.model,
|
|
28073
28131
|
model_name: row.model_name,
|
|
28074
28132
|
endpoint: row.endpoint,
|
|
28075
|
-
request_body: row.request_body,
|
|
28076
28133
|
request_headers: row.request_headers,
|
|
28077
|
-
response_body: row.response_body,
|
|
28078
28134
|
response_headers: row.response_headers,
|
|
28079
28135
|
status_code: row.status_code,
|
|
28080
|
-
reasoning_content: row.reasoning_content,
|
|
28081
28136
|
input_tokens: row.input_tokens,
|
|
28082
28137
|
cached_tokens: row.cached_tokens,
|
|
28083
28138
|
output_tokens: row.output_tokens,
|
|
@@ -28102,26 +28157,110 @@ ${resultContent}${attachmentSummary}`;
|
|
|
28102
28157
|
queued_tools: row.queued_tools,
|
|
28103
28158
|
provider_tools: row.provider_tools,
|
|
28104
28159
|
parent_log_id: row.parent_log_id,
|
|
28105
|
-
tools_schema: row.tools_schema,
|
|
28106
|
-
message_history: messageHistory,
|
|
28107
|
-
// Extracted from request_body
|
|
28108
|
-
system_prompt: row.system_prompt,
|
|
28109
28160
|
errors: row.errors,
|
|
28110
28161
|
retry_of_log_id: row.retry_of_log_id,
|
|
28111
|
-
tool_results: row.tool_results,
|
|
28112
28162
|
is_complete: row.is_complete === 1,
|
|
28113
28163
|
created_at: row.created_at,
|
|
28114
28164
|
source_message_role: row.source_message_role,
|
|
28115
|
-
source_message_content: row.source_message_content,
|
|
28116
28165
|
source_message_created_at: row.source_message_created_at,
|
|
28117
28166
|
source_message_metadata: row.source_message_metadata,
|
|
28118
28167
|
scheduled_effects: JSON.stringify(scheduledEffects)
|
|
28119
28168
|
};
|
|
28169
|
+
} catch (error) {
|
|
28170
|
+
console.error("Error reading log detail scalars:", error);
|
|
28171
|
+
throw error;
|
|
28172
|
+
}
|
|
28173
|
+
}
|
|
28174
|
+
/**
|
|
28175
|
+
* Single-column reads for the multi-MB log-detail TEXT columns. Static SQL
|
|
28176
|
+
* per field (never interpolated), keyed by the shared heavy-field list the
|
|
28177
|
+
* streamed serializer iterates.
|
|
28178
|
+
*/
|
|
28179
|
+
static LOG_DETAIL_HEAVY_FIELD_SQL = {
|
|
28180
|
+
request_body: "SELECT request_body AS value FROM logs WHERE id = ?",
|
|
28181
|
+
response_body: "SELECT response_body AS value FROM logs WHERE id = ?",
|
|
28182
|
+
tools_schema: "SELECT tools_schema AS value FROM logs WHERE id = ?",
|
|
28183
|
+
system_prompt: "SELECT system_prompt AS value FROM logs WHERE id = ?",
|
|
28184
|
+
tool_results: "SELECT tool_results AS value FROM logs WHERE id = ?",
|
|
28185
|
+
reasoning_content: "SELECT reasoning_content AS value FROM logs WHERE id = ?",
|
|
28186
|
+
source_message_content: "SELECT m.content AS value FROM logs l LEFT JOIN messages m ON m.id = l.message_id WHERE l.id = ?"
|
|
28187
|
+
};
|
|
28188
|
+
async readLogDetailHeavyField(logId, field) {
|
|
28189
|
+
const result = await this.ctx.storage.sql.exec(
|
|
28190
|
+
_DurableThread.LOG_DETAIL_HEAVY_FIELD_SQL[field],
|
|
28191
|
+
logId
|
|
28192
|
+
);
|
|
28193
|
+
return result.toArray()[0]?.value ?? null;
|
|
28194
|
+
}
|
|
28195
|
+
/**
|
|
28196
|
+
* Get detailed information for a single log (RPC method).
|
|
28197
|
+
*
|
|
28198
|
+
* Kept for RPC compatibility; HTTP routes use the streamed
|
|
28199
|
+
* `/internal/logs/:logId/details` fetch transport instead, because an
|
|
28200
|
+
* assembled detail object can approach the 32MiB RPC serialization cap.
|
|
28201
|
+
* `message_history` is no longer returned — it was byte-for-byte
|
|
28202
|
+
* `request_body.messages`; clients derive it from request_body.
|
|
28203
|
+
*/
|
|
28204
|
+
async getLogDetails(logId) {
|
|
28205
|
+
await this.ensureMigrated();
|
|
28206
|
+
try {
|
|
28207
|
+
const scalars = await this.readLogDetailScalars(logId);
|
|
28208
|
+
if (!scalars) {
|
|
28209
|
+
return null;
|
|
28210
|
+
}
|
|
28211
|
+
return {
|
|
28212
|
+
...scalars,
|
|
28213
|
+
request_body: await this.readLogDetailHeavyField(logId, "request_body"),
|
|
28214
|
+
response_body: await this.readLogDetailHeavyField(logId, "response_body"),
|
|
28215
|
+
tools_schema: await this.readLogDetailHeavyField(logId, "tools_schema"),
|
|
28216
|
+
system_prompt: await this.readLogDetailHeavyField(logId, "system_prompt"),
|
|
28217
|
+
tool_results: await this.readLogDetailHeavyField(logId, "tool_results"),
|
|
28218
|
+
reasoning_content: await this.readLogDetailHeavyField(logId, "reasoning_content"),
|
|
28219
|
+
source_message_content: await this.readLogDetailHeavyField(
|
|
28220
|
+
logId,
|
|
28221
|
+
"source_message_content"
|
|
28222
|
+
)
|
|
28223
|
+
};
|
|
28120
28224
|
} catch (error) {
|
|
28121
28225
|
console.error("Error in getLogDetails:", error);
|
|
28122
28226
|
throw error;
|
|
28123
28227
|
}
|
|
28124
28228
|
}
|
|
28229
|
+
/**
|
|
28230
|
+
* Streamed transport for log details: same JSON shape as getLogDetails but
|
|
28231
|
+
* served as a fetch Response (no 32MiB RPC cap) whose body is written
|
|
28232
|
+
* field-by-field with backpressure, so the full multi-MB detail object is
|
|
28233
|
+
* never buffered in this DO.
|
|
28234
|
+
*/
|
|
28235
|
+
async streamLogDetails(logId) {
|
|
28236
|
+
await this.ensureMigrated();
|
|
28237
|
+
const scalars = await this.readLogDetailScalars(logId);
|
|
28238
|
+
if (!scalars) {
|
|
28239
|
+
return Response.json({ error: `Log not found: ${logId}` }, { status: 404 });
|
|
28240
|
+
}
|
|
28241
|
+
const { readable, writable } = new TransformStream();
|
|
28242
|
+
const writer = writable.getWriter();
|
|
28243
|
+
const encoder = new TextEncoder();
|
|
28244
|
+
const pump = async () => {
|
|
28245
|
+
try {
|
|
28246
|
+
for await (const chunk of serializeLogDetailChunks(
|
|
28247
|
+
scalars,
|
|
28248
|
+
(field) => this.readLogDetailHeavyField(logId, field)
|
|
28249
|
+
)) {
|
|
28250
|
+
await writer.write(encoder.encode(chunk));
|
|
28251
|
+
}
|
|
28252
|
+
await writer.close();
|
|
28253
|
+
} catch (error) {
|
|
28254
|
+
console.error("Error streaming log details:", error);
|
|
28255
|
+
await writer.abort(error).catch(() => {
|
|
28256
|
+
});
|
|
28257
|
+
}
|
|
28258
|
+
};
|
|
28259
|
+
void pump();
|
|
28260
|
+
return new Response(readable, {
|
|
28261
|
+
headers: { "Content-Type": "application/json; charset=utf-8" }
|
|
28262
|
+
});
|
|
28263
|
+
}
|
|
28125
28264
|
/**
|
|
28126
28265
|
* Get thread metadata (RPC method)
|
|
28127
28266
|
*/
|