@standardagents/builder 0.35.2 → 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-DGx6_bEs.js → ApiKeysView-5EM1pB60.js} +1 -1
- package/dist/client/{CenteredContentView-D5F7SPrW.js → CenteredContentView-CV8QAco9.js} +1 -1
- package/dist/client/{CompositionView-DcHmU0Xx.js → CompositionView-D_M-Eajw.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-Cbt8QWB_.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-COlMI9pk.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-CIjLN-g1.js → CopyButton.vue_vue_type_script_setup_true_lang-BuKxnIzL.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-9jrq2R2O.js → DataTable.vue_vue_type_script_setup_true_lang-B4G2YHdb.js} +1 -1
- package/dist/client/{JsonViewer-C9m0kcer.js → JsonViewer-BZ7Aadme.js} +1 -1
- package/dist/client/{LoginView-nlDWkIgv.js → LoginView-CyuV4gke.js} +1 -1
- package/dist/client/{MarketplaceView-Duwr4O70.js → MarketplaceView-CoHrzmNk.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-CZYHYNj5.js → Modal.vue_vue_type_script_setup_true_lang-DSajL5Fd.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-CLLmtmqe.js → ModelModal.vue_vue_type_script_setup_true_lang-6UIPVigs.js} +1 -1
- package/dist/client/{ModelsView-BDeaRSvY.js → ModelsView-DFGteAQS.js} +1 -1
- package/dist/client/{PromptEditView-BGsDTcdf.js → PromptEditView-BRSrC8Jp.js} +1 -1
- package/dist/client/{PromptModal-DVrarqHx.js → PromptModal-BxITA4l1.js} +1 -1
- package/dist/client/{PromptsView-PMR9Bb_o.js → PromptsView-C7-GT7uq.js} +1 -1
- package/dist/client/{ProvidersView-qFTEWTGT.js → ProvidersView-DnRgjgqa.js} +1 -1
- package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DUKzYNBw.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CE6qD6Zb.js} +8 -8
- package/dist/client/{ThreadsView-BJocnJh4.js → ThreadsView-TVOJzvJ4.js} +1 -1
- package/dist/client/{ToolsView-BfYsknYW.js → ToolsView-C2UrMMOe.js} +1 -1
- package/dist/client/{UsersView-CJv-DRVL.js → UsersView-C3_SvVDT.js} +1 -1
- package/dist/client/{VariablesView-17_Cv8Du.js → VariablesView-crHzb8II.js} +1 -1
- package/dist/client/{index-Bm0uFcPf.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/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-
|
|
2
|
-
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
1
|
+
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-DP9GxPHu.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, 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';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, CredentialGrant, SkillMetadata, SkillFileInput, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, PromptEnvPart, VariableDefinition, SubpromptConfig as SubpromptConfig$1, PromptToolConfig as PromptToolConfig$1, SubagentToolConfig as SubagentToolConfig$1, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, ThreadState, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
|
|
4
4
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ModelCapabilities as ProviderModelCapabilities, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel } from '@standardagents/spec';
|
|
5
5
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
@@ -792,7 +792,6 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
792
792
|
total_tokens: number | null;
|
|
793
793
|
is_complete: boolean;
|
|
794
794
|
created_at: number;
|
|
795
|
-
request_body: string | null;
|
|
796
795
|
}[];
|
|
797
796
|
total: number;
|
|
798
797
|
hasMore: boolean;
|
|
@@ -841,7 +840,6 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
841
840
|
cost_total: number | null;
|
|
842
841
|
is_complete: boolean;
|
|
843
842
|
created_at: number;
|
|
844
|
-
request_body: string | null;
|
|
845
843
|
}[];
|
|
846
844
|
total: number;
|
|
847
845
|
hasMore: boolean;
|
|
@@ -868,16 +866,41 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
868
866
|
cost_total: number | null;
|
|
869
867
|
is_complete: boolean;
|
|
870
868
|
created_at: number;
|
|
871
|
-
request_body: string | null;
|
|
872
869
|
}[];
|
|
873
870
|
total: number;
|
|
874
871
|
hasMore: boolean;
|
|
875
872
|
}>;
|
|
876
873
|
/**
|
|
877
|
-
*
|
|
878
|
-
*
|
|
874
|
+
* Scalar (non-heavy) log-detail fields plus joined source-message scalars
|
|
875
|
+
* and scheduled-effect provenance. The multi-MB TEXT columns are read one
|
|
876
|
+
* at a time via readLogDetailHeavyField so no caller ever holds them all
|
|
877
|
+
* in memory at once.
|
|
878
|
+
*/
|
|
879
|
+
private readLogDetailScalars;
|
|
880
|
+
/**
|
|
881
|
+
* Single-column reads for the multi-MB log-detail TEXT columns. Static SQL
|
|
882
|
+
* per field (never interpolated), keyed by the shared heavy-field list the
|
|
883
|
+
* streamed serializer iterates.
|
|
884
|
+
*/
|
|
885
|
+
private static readonly LOG_DETAIL_HEAVY_FIELD_SQL;
|
|
886
|
+
private readLogDetailHeavyField;
|
|
887
|
+
/**
|
|
888
|
+
* Get detailed information for a single log (RPC method).
|
|
889
|
+
*
|
|
890
|
+
* Kept for RPC compatibility; HTTP routes use the streamed
|
|
891
|
+
* `/internal/logs/:logId/details` fetch transport instead, because an
|
|
892
|
+
* assembled detail object can approach the 32MiB RPC serialization cap.
|
|
893
|
+
* `message_history` is no longer returned — it was byte-for-byte
|
|
894
|
+
* `request_body.messages`; clients derive it from request_body.
|
|
879
895
|
*/
|
|
880
896
|
getLogDetails(logId: string): Promise<{
|
|
897
|
+
request_body: string | null;
|
|
898
|
+
response_body: string | null;
|
|
899
|
+
tools_schema: string | null;
|
|
900
|
+
system_prompt: string | null;
|
|
901
|
+
tool_results: string | null;
|
|
902
|
+
reasoning_content: string | null;
|
|
903
|
+
source_message_content: string | null;
|
|
881
904
|
id: string;
|
|
882
905
|
message_id: string;
|
|
883
906
|
provider: string;
|
|
@@ -886,12 +909,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
886
909
|
model: string;
|
|
887
910
|
model_name: string | null;
|
|
888
911
|
endpoint: string | null;
|
|
889
|
-
request_body: string | null;
|
|
890
912
|
request_headers: string | null;
|
|
891
|
-
response_body: string | null;
|
|
892
913
|
response_headers: string | null;
|
|
893
914
|
status_code: number | null;
|
|
894
|
-
reasoning_content: string | null;
|
|
895
915
|
input_tokens: number | null;
|
|
896
916
|
cached_tokens: number | null;
|
|
897
917
|
output_tokens: number | null;
|
|
@@ -916,20 +936,22 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
916
936
|
queued_tools: string | null;
|
|
917
937
|
provider_tools: string | null;
|
|
918
938
|
parent_log_id: string | null;
|
|
919
|
-
tools_schema: string | null;
|
|
920
|
-
message_history: string | null;
|
|
921
|
-
system_prompt: string | null;
|
|
922
939
|
errors: string | null;
|
|
923
940
|
retry_of_log_id: string | null;
|
|
924
|
-
tool_results: string | null;
|
|
925
941
|
is_complete: boolean;
|
|
926
942
|
created_at: number;
|
|
927
943
|
source_message_role: string | null;
|
|
928
|
-
source_message_content: string | null;
|
|
929
944
|
source_message_created_at: number | null;
|
|
930
945
|
source_message_metadata: string | null;
|
|
931
946
|
scheduled_effects: string;
|
|
932
947
|
} | null>;
|
|
948
|
+
/**
|
|
949
|
+
* Streamed transport for log details: same JSON shape as getLogDetails but
|
|
950
|
+
* served as a fetch Response (no 32MiB RPC cap) whose body is written
|
|
951
|
+
* field-by-field with backpressure, so the full multi-MB detail object is
|
|
952
|
+
* never buffered in this DO.
|
|
953
|
+
*/
|
|
954
|
+
private streamLogDetails;
|
|
933
955
|
/**
|
|
934
956
|
* Get thread metadata (RPC method)
|
|
935
957
|
*/
|
package/dist/runtime.js
CHANGED
|
@@ -461,6 +461,56 @@ var init_toolProgress = __esm({
|
|
|
461
461
|
PROGRESS_ARG_SCAN_CAP = 8192;
|
|
462
462
|
}
|
|
463
463
|
});
|
|
464
|
+
|
|
465
|
+
// src/agents/logBroadcast.ts
|
|
466
|
+
function toLogListItem(logData) {
|
|
467
|
+
const slim = { id: logData.id };
|
|
468
|
+
for (const field of LOG_BROADCAST_FIELDS) {
|
|
469
|
+
if (field === "id" || !(field in logData)) continue;
|
|
470
|
+
slim[field] = logData[field];
|
|
471
|
+
}
|
|
472
|
+
return slim;
|
|
473
|
+
}
|
|
474
|
+
var LOG_BROADCAST_FIELDS;
|
|
475
|
+
var init_logBroadcast = __esm({
|
|
476
|
+
"src/agents/logBroadcast.ts"() {
|
|
477
|
+
LOG_BROADCAST_FIELDS = [
|
|
478
|
+
"id",
|
|
479
|
+
"message_id",
|
|
480
|
+
"provider",
|
|
481
|
+
"actual_provider",
|
|
482
|
+
"model",
|
|
483
|
+
"model_name",
|
|
484
|
+
"prompt_name",
|
|
485
|
+
"tools_called",
|
|
486
|
+
"queued_tools",
|
|
487
|
+
"provider_tools",
|
|
488
|
+
"parent_log_id",
|
|
489
|
+
"retry_of_log_id",
|
|
490
|
+
"error",
|
|
491
|
+
"error_type",
|
|
492
|
+
"finish_reason",
|
|
493
|
+
"cost_total",
|
|
494
|
+
"cost_input",
|
|
495
|
+
"cost_cached",
|
|
496
|
+
"cost_output",
|
|
497
|
+
"cost_router_fee",
|
|
498
|
+
"router_fee_percent",
|
|
499
|
+
"input_tokens",
|
|
500
|
+
"cached_tokens",
|
|
501
|
+
"output_tokens",
|
|
502
|
+
"reasoning_tokens",
|
|
503
|
+
"total_tokens",
|
|
504
|
+
"latency_ms",
|
|
505
|
+
"time_to_first_token_ms",
|
|
506
|
+
"generation_ms",
|
|
507
|
+
"content",
|
|
508
|
+
"reasoning_content",
|
|
509
|
+
"is_complete",
|
|
510
|
+
"created_at"
|
|
511
|
+
];
|
|
512
|
+
}
|
|
513
|
+
});
|
|
464
514
|
var init_types2 = __esm({
|
|
465
515
|
"src/agents/providers/types.ts"() {
|
|
466
516
|
}
|
|
@@ -1746,6 +1796,7 @@ var init_LLMRequest = __esm({
|
|
|
1746
1796
|
init_types();
|
|
1747
1797
|
init_FlowEngine();
|
|
1748
1798
|
init_toolProgress();
|
|
1799
|
+
init_logBroadcast();
|
|
1749
1800
|
NON_VISION_PLACEHOLDER_TEXT = "[Image omitted: model does not support vision]";
|
|
1750
1801
|
STREAM_FIRST_CHUNK_TIMEOUT_MS = 12e4;
|
|
1751
1802
|
STREAM_STALL_TIMEOUT_MS = 45e3;
|
|
@@ -1997,7 +2048,7 @@ var init_LLMRequest = __esm({
|
|
|
1997
2048
|
state.emitLog({
|
|
1998
2049
|
type: "log_data",
|
|
1999
2050
|
log_id: logData.id,
|
|
2000
|
-
data: logData
|
|
2051
|
+
data: toLogListItem(logData)
|
|
2001
2052
|
});
|
|
2002
2053
|
}
|
|
2003
2054
|
return id;
|
|
@@ -2596,7 +2647,7 @@ var init_LLMRequest = __esm({
|
|
|
2596
2647
|
state.emitLog({
|
|
2597
2648
|
type: "log_data",
|
|
2598
2649
|
log_id: logData.id,
|
|
2599
|
-
data: logData
|
|
2650
|
+
data: toLogListItem(logData)
|
|
2600
2651
|
});
|
|
2601
2652
|
}
|
|
2602
2653
|
} catch (error) {
|
|
@@ -2641,13 +2692,6 @@ var init_LLMRequest = __esm({
|
|
|
2641
2692
|
JSON.stringify(transformedResponse),
|
|
2642
2693
|
logId
|
|
2643
2694
|
);
|
|
2644
|
-
if (state.emitLog) {
|
|
2645
|
-
state.emitLog({
|
|
2646
|
-
type: "log_data",
|
|
2647
|
-
log_id: logId,
|
|
2648
|
-
data: { id: logId, response_body: JSON.stringify(transformedResponse) }
|
|
2649
|
-
});
|
|
2650
|
-
}
|
|
2651
2695
|
} catch (error) {
|
|
2652
2696
|
console.error("Failed to update response body in log (non-fatal):", error);
|
|
2653
2697
|
}
|
|
@@ -2866,7 +2910,7 @@ ${errorStack}` : ""}${errorDetails}`;
|
|
|
2866
2910
|
state.emitLog({
|
|
2867
2911
|
type: "log_data",
|
|
2868
2912
|
log_id: logData.id,
|
|
2869
|
-
data: logData
|
|
2913
|
+
data: toLogListItem(logData)
|
|
2870
2914
|
});
|
|
2871
2915
|
}
|
|
2872
2916
|
if (errorObj && !errorObj._loggedId) {
|
|
@@ -16337,6 +16381,30 @@ function isQualifiedName(name) {
|
|
|
16337
16381
|
return name.includes("/");
|
|
16338
16382
|
}
|
|
16339
16383
|
|
|
16384
|
+
// src/durable-objects/logDetailStream.ts
|
|
16385
|
+
var LOG_DETAIL_HEAVY_FIELDS = [
|
|
16386
|
+
"request_body",
|
|
16387
|
+
"response_body",
|
|
16388
|
+
"tools_schema",
|
|
16389
|
+
"system_prompt",
|
|
16390
|
+
"tool_results",
|
|
16391
|
+
"reasoning_content",
|
|
16392
|
+
"source_message_content"
|
|
16393
|
+
];
|
|
16394
|
+
async function* serializeLogDetailChunks(scalars, readField) {
|
|
16395
|
+
const head2 = JSON.stringify(scalars);
|
|
16396
|
+
const hasScalarKeys = head2 !== "{}";
|
|
16397
|
+
yield hasScalarKeys ? head2.slice(0, -1) : "{";
|
|
16398
|
+
let needsComma = hasScalarKeys;
|
|
16399
|
+
for (const field of LOG_DETAIL_HEAVY_FIELDS) {
|
|
16400
|
+
const value = await readField(field);
|
|
16401
|
+
const encoded = value === null || value === void 0 ? "null" : JSON.stringify(value);
|
|
16402
|
+
yield `${needsComma ? "," : ""}${JSON.stringify(field)}:${encoded}`;
|
|
16403
|
+
needsComma = true;
|
|
16404
|
+
}
|
|
16405
|
+
yield "}";
|
|
16406
|
+
}
|
|
16407
|
+
|
|
16340
16408
|
// src/durable-objects/DurableThread.ts
|
|
16341
16409
|
init_client_forwarding();
|
|
16342
16410
|
init_sessionTools();
|
|
@@ -17818,15 +17886,20 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
17818
17886
|
}
|
|
17819
17887
|
const upgradeHeader = request.headers.get("Upgrade");
|
|
17820
17888
|
if (upgradeHeader?.toLowerCase() === "websocket") {
|
|
17821
|
-
const
|
|
17822
|
-
if (
|
|
17889
|
+
const url2 = new URL(request.url);
|
|
17890
|
+
if (url2.pathname.includes("/bridge")) {
|
|
17823
17891
|
return this.handleBridgeWebSocketUpgrade(request);
|
|
17824
|
-
} else if (
|
|
17892
|
+
} else if (url2.pathname.includes("/stream")) {
|
|
17825
17893
|
return this.handleMessagesWebSocketUpgrade(request);
|
|
17826
17894
|
} else {
|
|
17827
17895
|
return this.handleLogsWebSocketUpgrade(request);
|
|
17828
17896
|
}
|
|
17829
17897
|
}
|
|
17898
|
+
const url = new URL(request.url);
|
|
17899
|
+
const logDetailMatch = url.pathname.match(/\/internal\/logs\/([^/]+)\/details$/);
|
|
17900
|
+
if (logDetailMatch && request.method === "GET") {
|
|
17901
|
+
return this.streamLogDetails(decodeURIComponent(logDetailMatch[1]));
|
|
17902
|
+
}
|
|
17830
17903
|
return new Response("Use RPC methods instead of fetch", { status: 400 });
|
|
17831
17904
|
}
|
|
17832
17905
|
registerCodeExecutionBridge(runId, bridge) {
|
|
@@ -19280,7 +19353,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19280
19353
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
19281
19354
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19282
19355
|
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
19283
|
-
is_complete, created_at
|
|
19356
|
+
is_complete, created_at
|
|
19284
19357
|
FROM logs
|
|
19285
19358
|
ORDER BY created_at ${order}
|
|
19286
19359
|
LIMIT ? OFFSET ?
|
|
@@ -19309,8 +19382,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19309
19382
|
output_tokens: row.output_tokens,
|
|
19310
19383
|
total_tokens: row.total_tokens,
|
|
19311
19384
|
is_complete: row.is_complete === 1,
|
|
19312
|
-
created_at: row.created_at
|
|
19313
|
-
request_body: row.request_body
|
|
19385
|
+
created_at: row.created_at
|
|
19314
19386
|
}));
|
|
19315
19387
|
const hasMore = offset + logs.length < total;
|
|
19316
19388
|
return { logs, total, hasMore };
|
|
@@ -19415,7 +19487,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19415
19487
|
SELECT
|
|
19416
19488
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
19417
19489
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19418
|
-
is_complete, created_at
|
|
19490
|
+
is_complete, created_at
|
|
19419
19491
|
FROM logs
|
|
19420
19492
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
19421
19493
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -19423,7 +19495,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19423
19495
|
SELECT
|
|
19424
19496
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
19425
19497
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19426
|
-
is_complete, created_at
|
|
19498
|
+
is_complete, created_at
|
|
19427
19499
|
FROM logs
|
|
19428
19500
|
WHERE id IN (${placeholders})
|
|
19429
19501
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -19445,8 +19517,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19445
19517
|
error: row.error,
|
|
19446
19518
|
cost_total: row.cost_total,
|
|
19447
19519
|
is_complete: row.is_complete === 1,
|
|
19448
|
-
created_at: row.created_at
|
|
19449
|
-
request_body: row.request_body
|
|
19520
|
+
created_at: row.created_at
|
|
19450
19521
|
}));
|
|
19451
19522
|
return { logs, total: logs.length, hasMore: false };
|
|
19452
19523
|
}
|
|
@@ -19531,7 +19602,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19531
19602
|
rowid AS row_index,
|
|
19532
19603
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
19533
19604
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19534
|
-
is_complete, created_at
|
|
19605
|
+
is_complete, created_at
|
|
19535
19606
|
FROM logs
|
|
19536
19607
|
WHERE id IN (SELECT id FROM selected_logs)
|
|
19537
19608
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -19540,7 +19611,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19540
19611
|
rowid AS row_index,
|
|
19541
19612
|
id, message_id, provider, actual_provider, model, model_name, prompt_name,
|
|
19542
19613
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
19543
|
-
is_complete, created_at
|
|
19614
|
+
is_complete, created_at
|
|
19544
19615
|
FROM logs
|
|
19545
19616
|
WHERE message_id IN (${placeholders})
|
|
19546
19617
|
ORDER BY created_at ${order}, rowid ${order}
|
|
@@ -19571,31 +19642,30 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19571
19642
|
error: row.error,
|
|
19572
19643
|
cost_total: row.cost_total,
|
|
19573
19644
|
is_complete: row.is_complete === 1,
|
|
19574
|
-
created_at: row.created_at
|
|
19575
|
-
request_body: row.request_body
|
|
19645
|
+
created_at: row.created_at
|
|
19576
19646
|
}));
|
|
19577
19647
|
return { logs, total: logs.length, hasMore: false };
|
|
19578
19648
|
}
|
|
19579
19649
|
/**
|
|
19580
|
-
*
|
|
19581
|
-
*
|
|
19650
|
+
* Scalar (non-heavy) log-detail fields plus joined source-message scalars
|
|
19651
|
+
* and scheduled-effect provenance. The multi-MB TEXT columns are read one
|
|
19652
|
+
* at a time via readLogDetailHeavyField so no caller ever holds them all
|
|
19653
|
+
* in memory at once.
|
|
19582
19654
|
*/
|
|
19583
|
-
async
|
|
19584
|
-
await this.ensureMigrated();
|
|
19655
|
+
async readLogDetailScalars(logId) {
|
|
19585
19656
|
try {
|
|
19586
19657
|
const result = await this.ctx.storage.sql.exec(
|
|
19587
19658
|
`
|
|
19588
19659
|
SELECT
|
|
19589
19660
|
l.id, l.message_id, l.provider, l.actual_provider, l.standard_agents_router_used, l.model, l.model_name, l.endpoint,
|
|
19590
|
-
l.
|
|
19591
|
-
l.
|
|
19661
|
+
l.request_headers, l.response_headers, l.status_code,
|
|
19662
|
+
l.input_tokens, l.cached_tokens, l.output_tokens,
|
|
19592
19663
|
l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
|
|
19593
19664
|
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,
|
|
19594
19665
|
l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
|
|
19595
|
-
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
19596
|
-
l.errors, l.retry_of_log_id, l.
|
|
19666
|
+
l.queued_tools, l.provider_tools, l.parent_log_id,
|
|
19667
|
+
l.errors, l.retry_of_log_id, l.is_complete, l.created_at,
|
|
19597
19668
|
m.role as source_message_role,
|
|
19598
|
-
m.content as source_message_content,
|
|
19599
19669
|
m.created_at as source_message_created_at,
|
|
19600
19670
|
m.metadata as source_message_metadata
|
|
19601
19671
|
FROM logs l
|
|
@@ -19642,17 +19712,6 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19642
19712
|
replayedFrom: effectRow.replayed_from
|
|
19643
19713
|
};
|
|
19644
19714
|
});
|
|
19645
|
-
let messageHistory = null;
|
|
19646
|
-
if (row.request_body) {
|
|
19647
|
-
try {
|
|
19648
|
-
const requestBody = JSON.parse(row.request_body);
|
|
19649
|
-
if (requestBody.messages) {
|
|
19650
|
-
messageHistory = JSON.stringify(requestBody.messages);
|
|
19651
|
-
}
|
|
19652
|
-
} catch (e) {
|
|
19653
|
-
console.error("Failed to parse request_body to extract message_history:", e);
|
|
19654
|
-
}
|
|
19655
|
-
}
|
|
19656
19715
|
return {
|
|
19657
19716
|
id: row.id,
|
|
19658
19717
|
message_id: row.message_id,
|
|
@@ -19662,12 +19721,9 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19662
19721
|
model: row.model,
|
|
19663
19722
|
model_name: row.model_name,
|
|
19664
19723
|
endpoint: row.endpoint,
|
|
19665
|
-
request_body: row.request_body,
|
|
19666
19724
|
request_headers: row.request_headers,
|
|
19667
|
-
response_body: row.response_body,
|
|
19668
19725
|
response_headers: row.response_headers,
|
|
19669
19726
|
status_code: row.status_code,
|
|
19670
|
-
reasoning_content: row.reasoning_content,
|
|
19671
19727
|
input_tokens: row.input_tokens,
|
|
19672
19728
|
cached_tokens: row.cached_tokens,
|
|
19673
19729
|
output_tokens: row.output_tokens,
|
|
@@ -19692,26 +19748,110 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19692
19748
|
queued_tools: row.queued_tools,
|
|
19693
19749
|
provider_tools: row.provider_tools,
|
|
19694
19750
|
parent_log_id: row.parent_log_id,
|
|
19695
|
-
tools_schema: row.tools_schema,
|
|
19696
|
-
message_history: messageHistory,
|
|
19697
|
-
// Extracted from request_body
|
|
19698
|
-
system_prompt: row.system_prompt,
|
|
19699
19751
|
errors: row.errors,
|
|
19700
19752
|
retry_of_log_id: row.retry_of_log_id,
|
|
19701
|
-
tool_results: row.tool_results,
|
|
19702
19753
|
is_complete: row.is_complete === 1,
|
|
19703
19754
|
created_at: row.created_at,
|
|
19704
19755
|
source_message_role: row.source_message_role,
|
|
19705
|
-
source_message_content: row.source_message_content,
|
|
19706
19756
|
source_message_created_at: row.source_message_created_at,
|
|
19707
19757
|
source_message_metadata: row.source_message_metadata,
|
|
19708
19758
|
scheduled_effects: JSON.stringify(scheduledEffects)
|
|
19709
19759
|
};
|
|
19760
|
+
} catch (error) {
|
|
19761
|
+
console.error("Error reading log detail scalars:", error);
|
|
19762
|
+
throw error;
|
|
19763
|
+
}
|
|
19764
|
+
}
|
|
19765
|
+
/**
|
|
19766
|
+
* Single-column reads for the multi-MB log-detail TEXT columns. Static SQL
|
|
19767
|
+
* per field (never interpolated), keyed by the shared heavy-field list the
|
|
19768
|
+
* streamed serializer iterates.
|
|
19769
|
+
*/
|
|
19770
|
+
static LOG_DETAIL_HEAVY_FIELD_SQL = {
|
|
19771
|
+
request_body: "SELECT request_body AS value FROM logs WHERE id = ?",
|
|
19772
|
+
response_body: "SELECT response_body AS value FROM logs WHERE id = ?",
|
|
19773
|
+
tools_schema: "SELECT tools_schema AS value FROM logs WHERE id = ?",
|
|
19774
|
+
system_prompt: "SELECT system_prompt AS value FROM logs WHERE id = ?",
|
|
19775
|
+
tool_results: "SELECT tool_results AS value FROM logs WHERE id = ?",
|
|
19776
|
+
reasoning_content: "SELECT reasoning_content AS value FROM logs WHERE id = ?",
|
|
19777
|
+
source_message_content: "SELECT m.content AS value FROM logs l LEFT JOIN messages m ON m.id = l.message_id WHERE l.id = ?"
|
|
19778
|
+
};
|
|
19779
|
+
async readLogDetailHeavyField(logId, field) {
|
|
19780
|
+
const result = await this.ctx.storage.sql.exec(
|
|
19781
|
+
_DurableThread.LOG_DETAIL_HEAVY_FIELD_SQL[field],
|
|
19782
|
+
logId
|
|
19783
|
+
);
|
|
19784
|
+
return result.toArray()[0]?.value ?? null;
|
|
19785
|
+
}
|
|
19786
|
+
/**
|
|
19787
|
+
* Get detailed information for a single log (RPC method).
|
|
19788
|
+
*
|
|
19789
|
+
* Kept for RPC compatibility; HTTP routes use the streamed
|
|
19790
|
+
* `/internal/logs/:logId/details` fetch transport instead, because an
|
|
19791
|
+
* assembled detail object can approach the 32MiB RPC serialization cap.
|
|
19792
|
+
* `message_history` is no longer returned — it was byte-for-byte
|
|
19793
|
+
* `request_body.messages`; clients derive it from request_body.
|
|
19794
|
+
*/
|
|
19795
|
+
async getLogDetails(logId) {
|
|
19796
|
+
await this.ensureMigrated();
|
|
19797
|
+
try {
|
|
19798
|
+
const scalars = await this.readLogDetailScalars(logId);
|
|
19799
|
+
if (!scalars) {
|
|
19800
|
+
return null;
|
|
19801
|
+
}
|
|
19802
|
+
return {
|
|
19803
|
+
...scalars,
|
|
19804
|
+
request_body: await this.readLogDetailHeavyField(logId, "request_body"),
|
|
19805
|
+
response_body: await this.readLogDetailHeavyField(logId, "response_body"),
|
|
19806
|
+
tools_schema: await this.readLogDetailHeavyField(logId, "tools_schema"),
|
|
19807
|
+
system_prompt: await this.readLogDetailHeavyField(logId, "system_prompt"),
|
|
19808
|
+
tool_results: await this.readLogDetailHeavyField(logId, "tool_results"),
|
|
19809
|
+
reasoning_content: await this.readLogDetailHeavyField(logId, "reasoning_content"),
|
|
19810
|
+
source_message_content: await this.readLogDetailHeavyField(
|
|
19811
|
+
logId,
|
|
19812
|
+
"source_message_content"
|
|
19813
|
+
)
|
|
19814
|
+
};
|
|
19710
19815
|
} catch (error) {
|
|
19711
19816
|
console.error("Error in getLogDetails:", error);
|
|
19712
19817
|
throw error;
|
|
19713
19818
|
}
|
|
19714
19819
|
}
|
|
19820
|
+
/**
|
|
19821
|
+
* Streamed transport for log details: same JSON shape as getLogDetails but
|
|
19822
|
+
* served as a fetch Response (no 32MiB RPC cap) whose body is written
|
|
19823
|
+
* field-by-field with backpressure, so the full multi-MB detail object is
|
|
19824
|
+
* never buffered in this DO.
|
|
19825
|
+
*/
|
|
19826
|
+
async streamLogDetails(logId) {
|
|
19827
|
+
await this.ensureMigrated();
|
|
19828
|
+
const scalars = await this.readLogDetailScalars(logId);
|
|
19829
|
+
if (!scalars) {
|
|
19830
|
+
return Response.json({ error: `Log not found: ${logId}` }, { status: 404 });
|
|
19831
|
+
}
|
|
19832
|
+
const { readable, writable } = new TransformStream();
|
|
19833
|
+
const writer = writable.getWriter();
|
|
19834
|
+
const encoder = new TextEncoder();
|
|
19835
|
+
const pump = async () => {
|
|
19836
|
+
try {
|
|
19837
|
+
for await (const chunk of serializeLogDetailChunks(
|
|
19838
|
+
scalars,
|
|
19839
|
+
(field) => this.readLogDetailHeavyField(logId, field)
|
|
19840
|
+
)) {
|
|
19841
|
+
await writer.write(encoder.encode(chunk));
|
|
19842
|
+
}
|
|
19843
|
+
await writer.close();
|
|
19844
|
+
} catch (error) {
|
|
19845
|
+
console.error("Error streaming log details:", error);
|
|
19846
|
+
await writer.abort(error).catch(() => {
|
|
19847
|
+
});
|
|
19848
|
+
}
|
|
19849
|
+
};
|
|
19850
|
+
void pump();
|
|
19851
|
+
return new Response(readable, {
|
|
19852
|
+
headers: { "Content-Type": "application/json; charset=utf-8" }
|
|
19853
|
+
});
|
|
19854
|
+
}
|
|
19715
19855
|
/**
|
|
19716
19856
|
* Get thread metadata (RPC method)
|
|
19717
19857
|
*/
|