@standardagents/builder 0.24.4 → 0.24.6
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 +173 -32
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-1m7uIS8S.js → ApiKeysView-CmZKVcOR.js} +1 -1
- package/dist/client/CenteredContentView-DK7rPUK2.js +1 -0
- package/dist/client/{CompositionView-nzqzVKAg.js → CompositionView-BvVMnyYP.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-YX8WE_iB.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-h7YuRPAr.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-BpJt6BT0.js → CopyButton.vue_vue_type_script_setup_true_lang-BpQ6CMUp.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-Dg3HMMJ0.js → DataTable.vue_vue_type_script_setup_true_lang-DCUZbvUM.js} +1 -1
- package/dist/client/{JsonViewer-BdNA5OCG.js → JsonViewer-CvwfQYW-.js} +1 -1
- package/dist/client/{LoginView-BlF_2TtB.js → LoginView-DnaG5knS.js} +1 -1
- package/dist/client/{MarketplaceView-DrlOb57k.js → MarketplaceView-fX_Juw54.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-hkOmEwrb.js → Modal.vue_vue_type_script_setup_true_lang-CFFVfl1g.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-p3esoV-i.js → ModelModal.vue_vue_type_script_setup_true_lang-B68s7Jo1.js} +1 -1
- package/dist/client/{ModelsView-CHBanMSH.js → ModelsView-lv4-IyA2.js} +1 -1
- package/dist/client/{PromptEditView-b5B43l4Q.js → PromptEditView-DGaxlMMx.js} +1 -1
- package/dist/client/{PromptModal-BF5bdmNQ.js → PromptModal-DaW1J_W6.js} +1 -1
- package/dist/client/{PromptsView-6TfMOScI.js → PromptsView-CdiBqZey.js} +1 -1
- package/dist/client/{ProvidersView-CA5Yx2Fn.js → ProvidersView-B37bgFKh.js} +1 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DHlNdv7o.js +22 -0
- package/dist/client/ThreadsView-BAfuNShv.js +1 -0
- package/dist/client/{ToolsView-DE1TDnlU.js → ToolsView-BMKgNq7O.js} +1 -1
- package/dist/client/{UiCodeBlock.vue_vue_type_script_setup_true_lang-BawOR_eB.js → UiCodeBlock.vue_vue_type_script_setup_true_lang-BH3WC9G_.js} +1 -1
- package/dist/client/{UsersView-BXDHjJLB.js → UsersView-BDKchqNQ.js} +1 -1
- package/dist/client/{VariablesView-Bz-CbaEv.js → VariablesView-BPioaCbu.js} +1 -1
- package/dist/client/assets/{ThreadInspectorPane-DLSVKyBu.css → ThreadInspectorPane-lJJckks4.css} +1 -1
- package/dist/client/assets/index-Djjx6d3k.css +1 -0
- package/dist/client/{check-DKLwABgc.js → check-Dkzs1C3V.js} +1 -1
- package/dist/client/{chevron-right-DJJGHNE5.js → chevron-right-BGirddPg.js} +1 -1
- package/dist/client/{copy-CLWiDcxB.js → copy-C08OR8rY.js} +1 -1
- package/dist/client/{formkit-DcuuXZjC.js → formkit-YJ1Z7D5r.js} +1 -1
- package/dist/client/{index-TIntu1KJ.js → index-BVfRoUms.js} +3 -3
- package/dist/client/index.html +4 -4
- package/dist/client/{package-CarOhnUs.js → package-guyzMTDG.js} +1 -1
- package/dist/client/{plus-zGapov7j.js → plus-DG3ZN5wg.js} +1 -1
- package/dist/client/{timeAgo-ASgzq6bq.js → timeAgo-D7V247YG.js} +1 -1
- package/dist/client/{useActionFeedback-uUrfjlCo.js → useActionFeedback-byARNQjQ.js} +1 -1
- package/dist/client/vue-BqC6IZDY.js +1 -0
- package/dist/{index-jDKWlMKG.d.ts → index-D3FNNQWC.d.ts} +8 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +102 -42
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +10 -2
- package/dist/runtime.js +102 -42
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CenteredContentView-DJzHRMGj.js +0 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-ejyFhmNy.js +0 -22
- package/dist/client/ThreadsView-yJpVmf42.js +0 -1
- package/dist/client/assets/index-V68N0r_5.css +0 -1
- package/dist/client/vue-2tGL2Ulx.js +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ThreadEnv, A as Agent, h as ThreadMetadata, i as ToolResult, M as Message, l as FileRecord, F as FlowState, n as FileStats, G as GrepResult, m as AttachmentRef, r as MessageContent, E as Env, g as ThreadInstance } from './index-
|
|
2
|
-
export { f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, j as FlowResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, T as ToolCall, c as createThreadEndpointHandler, d as defineController } from './index-
|
|
1
|
+
import { e as ThreadEnv, A as Agent, h as ThreadMetadata, i as ToolResult, M as Message, l as FileRecord, F as FlowState, n as FileStats, G as GrepResult, m as AttachmentRef, r as MessageContent, E as Env, g as ThreadInstance } from './index-D3FNNQWC.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, j as FlowResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, T as ToolCall, c as createThreadEndpointHandler, d as defineController } from './index-D3FNNQWC.js';
|
|
3
3
|
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, ClientToolRequest, ClientToolResponse, 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, 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';
|
|
@@ -738,6 +738,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
738
738
|
error: string | null;
|
|
739
739
|
cost_total: number | null;
|
|
740
740
|
input_tokens: number | null;
|
|
741
|
+
cached_tokens: number | null;
|
|
741
742
|
output_tokens: number | null;
|
|
742
743
|
total_tokens: number | null;
|
|
743
744
|
is_complete: boolean;
|
|
@@ -755,10 +756,16 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
755
756
|
*/
|
|
756
757
|
getCostSummary(): Promise<{
|
|
757
758
|
totalCost: number;
|
|
759
|
+
inputCost: number;
|
|
760
|
+
cachedCost: number;
|
|
761
|
+
outputCost: number;
|
|
758
762
|
requestCount: number;
|
|
759
763
|
messageCount: number;
|
|
760
764
|
byModel: Record<string, {
|
|
761
765
|
totalCost: number;
|
|
766
|
+
inputCost: number;
|
|
767
|
+
cachedCost: number;
|
|
768
|
+
outputCost: number;
|
|
762
769
|
count: number;
|
|
763
770
|
}>;
|
|
764
771
|
}>;
|
|
@@ -846,6 +853,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
846
853
|
error: string | null;
|
|
847
854
|
error_type: string | null;
|
|
848
855
|
cost_input: number | null;
|
|
856
|
+
cost_cached: number | null;
|
|
849
857
|
cost_output: number | null;
|
|
850
858
|
cost_total: number | null;
|
|
851
859
|
message_history_length: number | null;
|
package/dist/runtime.js
CHANGED
|
@@ -208,6 +208,18 @@ function getFallbackPricing(providerName, modelId) {
|
|
|
208
208
|
const pricing = getProviderModelPricing(providerName, modelId);
|
|
209
209
|
return pricing ? toResolvedModelPricing(pricing) : null;
|
|
210
210
|
}
|
|
211
|
+
function resolveUsageReportedPricing(usage) {
|
|
212
|
+
const pricing = usage.pricing;
|
|
213
|
+
if (!pricing || typeof pricing.inputPerMillion !== "number" || typeof pricing.outputPerMillion !== "number") {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
inputPrice: pricing.inputPerMillion,
|
|
218
|
+
outputPrice: pricing.outputPerMillion,
|
|
219
|
+
cachedPrice: pricing.cachedInputPerMillion,
|
|
220
|
+
source: "provider"
|
|
221
|
+
};
|
|
222
|
+
}
|
|
211
223
|
function resolveModelPricing(modelDef, providerName) {
|
|
212
224
|
if (typeof modelDef.inputPrice === "number" && typeof modelDef.outputPrice === "number") {
|
|
213
225
|
return {
|
|
@@ -236,14 +248,14 @@ function calculateUsageCost(usage, pricing) {
|
|
|
236
248
|
const inputPrice = useLongContext ? pricing.longInputPrice ?? pricing.inputPrice : pricing.inputPrice;
|
|
237
249
|
const outputPrice = useLongContext ? pricing.longOutputPrice ?? pricing.outputPrice : pricing.outputPrice;
|
|
238
250
|
const cachedTokenPrice = useLongContext ? pricing.longCachedPrice ?? pricing.cachedPrice ?? pricing.inputPrice : pricing.cachedPrice ?? pricing.inputPrice;
|
|
239
|
-
const costInput = roundCost(
|
|
240
|
-
|
|
241
|
-
);
|
|
251
|
+
const costInput = roundCost(uncachedPromptTokens * inputPrice / TOKENS_PER_MILLION);
|
|
252
|
+
const costCached = roundCost(cachedTokens * cachedTokenPrice / TOKENS_PER_MILLION);
|
|
242
253
|
const costOutput = roundCost(billableOutputTokens * outputPrice / TOKENS_PER_MILLION);
|
|
243
254
|
return {
|
|
244
255
|
costInput,
|
|
256
|
+
costCached,
|
|
245
257
|
costOutput,
|
|
246
|
-
costTotal: roundCost(costInput + costOutput)
|
|
258
|
+
costTotal: roundCost(costInput + costCached + costOutput)
|
|
247
259
|
};
|
|
248
260
|
}
|
|
249
261
|
var TOKENS_PER_MILLION;
|
|
@@ -1349,7 +1361,8 @@ function convertUsage(usage) {
|
|
|
1349
1361
|
prompt_tokens_details: usage.cachedTokens ? { cached_tokens: usage.cachedTokens } : void 0,
|
|
1350
1362
|
completion_tokens_details: usage.reasoningTokens ? { reasoning_tokens: usage.reasoningTokens } : void 0,
|
|
1351
1363
|
cost: usage.cost,
|
|
1352
|
-
provider: usage.provider
|
|
1364
|
+
provider: usage.provider,
|
|
1365
|
+
pricing: usage.pricing
|
|
1353
1366
|
};
|
|
1354
1367
|
}
|
|
1355
1368
|
function inferProviderFromModelId(model) {
|
|
@@ -2044,7 +2057,7 @@ var init_LLMRequest = __esm({
|
|
|
2044
2057
|
const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
|
|
2045
2058
|
const providerName = response._provider?.name;
|
|
2046
2059
|
const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
|
|
2047
|
-
const resolvedPricing = resolveModelPricing(modelDef, providerName);
|
|
2060
|
+
const resolvedPricing = resolveModelPricing(modelDef) ?? resolveUsageReportedPricing(response.usage) ?? resolveModelPricing(modelDef, providerName);
|
|
2048
2061
|
const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
|
|
2049
2062
|
const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
|
|
2050
2063
|
const cost_total = providerReportedCost != null && !Number.isNaN(providerReportedCost) ? providerReportedCost : calculatedCost?.costTotal ?? null;
|
|
@@ -2111,6 +2124,7 @@ var init_LLMRequest = __esm({
|
|
|
2111
2124
|
reasoning_tokens: response.usage.completion_tokens_details?.reasoning_tokens || 0,
|
|
2112
2125
|
total_tokens: response.usage.total_tokens,
|
|
2113
2126
|
cost_input: calculatedCost?.costInput,
|
|
2127
|
+
cost_cached: calculatedCost?.costCached,
|
|
2114
2128
|
cost_output: calculatedCost?.costOutput,
|
|
2115
2129
|
latency_ms: Date.now() - startTime,
|
|
2116
2130
|
time_to_first_token_ms: timing?.latencyMs ?? void 0,
|
|
@@ -2140,19 +2154,20 @@ var init_LLMRequest = __esm({
|
|
|
2140
2154
|
reasoning_tokens = ?5,
|
|
2141
2155
|
total_tokens = ?6,
|
|
2142
2156
|
cost_input = ?7,
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2157
|
+
cost_cached = ?8,
|
|
2158
|
+
cost_output = ?9,
|
|
2159
|
+
latency_ms = ?10,
|
|
2160
|
+
finish_reason = ?11,
|
|
2161
|
+
tools_called = ?12,
|
|
2162
|
+
cost_total = ?13,
|
|
2163
|
+
is_complete = ?14,
|
|
2164
|
+
reasoning_content = ?15,
|
|
2165
|
+
provider_tools = ?16,
|
|
2166
|
+
actual_provider = ?17,
|
|
2167
|
+
standard_agents_router_used = ?18,
|
|
2168
|
+
time_to_first_token_ms = ?19,
|
|
2169
|
+
generation_ms = ?20
|
|
2170
|
+
WHERE id = ?21
|
|
2156
2171
|
`,
|
|
2157
2172
|
logData.response_body,
|
|
2158
2173
|
logData.input_tokens,
|
|
@@ -2161,6 +2176,7 @@ var init_LLMRequest = __esm({
|
|
|
2161
2176
|
logData.reasoning_tokens,
|
|
2162
2177
|
logData.total_tokens,
|
|
2163
2178
|
logData.cost_input ?? null,
|
|
2179
|
+
logData.cost_cached ?? null,
|
|
2164
2180
|
logData.cost_output ?? null,
|
|
2165
2181
|
logData.latency_ms,
|
|
2166
2182
|
logData.finish_reason,
|
|
@@ -14671,8 +14687,23 @@ var migration31 = {
|
|
|
14671
14687
|
}
|
|
14672
14688
|
};
|
|
14673
14689
|
|
|
14690
|
+
// src/durable-objects/migrations/032_add_cost_cached.ts
|
|
14691
|
+
var migration32 = {
|
|
14692
|
+
version: 32,
|
|
14693
|
+
name: "add_cost_cached",
|
|
14694
|
+
async up(sql) {
|
|
14695
|
+
const tableInfo = sql.exec(`PRAGMA table_info(logs)`).toArray();
|
|
14696
|
+
const hasCostCached = tableInfo.some((col) => col.name === "cost_cached");
|
|
14697
|
+
if (!hasCostCached) {
|
|
14698
|
+
await sql.exec(`
|
|
14699
|
+
ALTER TABLE logs ADD COLUMN cost_cached REAL;
|
|
14700
|
+
`);
|
|
14701
|
+
}
|
|
14702
|
+
}
|
|
14703
|
+
};
|
|
14704
|
+
|
|
14674
14705
|
// src/durable-objects/migrations/index.ts
|
|
14675
|
-
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];
|
|
14706
|
+
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];
|
|
14676
14707
|
var LATEST_SCHEMA_VERSION = migrations.length;
|
|
14677
14708
|
|
|
14678
14709
|
// src/durable-objects/DurableThread.ts
|
|
@@ -16152,8 +16183,10 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
16152
16183
|
async setValue(key, value) {
|
|
16153
16184
|
await this.ensureMigrated();
|
|
16154
16185
|
this.assertValidThreadValueKey(key);
|
|
16186
|
+
const updatedAt = Date.now() * 1e3;
|
|
16155
16187
|
if (value === null || value === void 0) {
|
|
16156
16188
|
await this.ctx.storage.sql.exec(`DELETE FROM thread_values WHERE key = ?`, key);
|
|
16189
|
+
this.broadcastLog({ type: "kv_data", key, deleted: true, updated_at: updatedAt });
|
|
16157
16190
|
return;
|
|
16158
16191
|
}
|
|
16159
16192
|
const serialized = this.serializeThreadValue(value);
|
|
@@ -16167,8 +16200,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
16167
16200
|
`,
|
|
16168
16201
|
key,
|
|
16169
16202
|
serialized,
|
|
16170
|
-
|
|
16203
|
+
updatedAt
|
|
16171
16204
|
);
|
|
16205
|
+
this.broadcastLog({ type: "kv_data", key, deleted: false, updated_at: updatedAt });
|
|
16172
16206
|
}
|
|
16173
16207
|
async listValues(options = {}) {
|
|
16174
16208
|
await this.ensureMigrated();
|
|
@@ -16788,9 +16822,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
16788
16822
|
* Each migration is run in order, starting from the current version + 1.
|
|
16789
16823
|
*/
|
|
16790
16824
|
async runMigrations(fromVersion) {
|
|
16791
|
-
for (const
|
|
16792
|
-
if (
|
|
16793
|
-
await
|
|
16825
|
+
for (const migration43 of migrations) {
|
|
16826
|
+
if (migration43.version > fromVersion) {
|
|
16827
|
+
await migration43.up(this.ctx.storage.sql);
|
|
16794
16828
|
}
|
|
16795
16829
|
}
|
|
16796
16830
|
}
|
|
@@ -18224,7 +18258,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18224
18258
|
SELECT
|
|
18225
18259
|
id, message_id, provider, actual_provider, standard_agents_router_used, model, model_name, prompt_name,
|
|
18226
18260
|
tools_called, queued_tools, provider_tools, parent_log_id, retry_of_log_id, error, cost_total,
|
|
18227
|
-
input_tokens, output_tokens, total_tokens,
|
|
18261
|
+
input_tokens, cached_tokens, output_tokens, total_tokens,
|
|
18228
18262
|
is_complete, created_at, request_body
|
|
18229
18263
|
FROM logs
|
|
18230
18264
|
ORDER BY created_at ${order}
|
|
@@ -18250,6 +18284,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18250
18284
|
error: row.error,
|
|
18251
18285
|
cost_total: row.cost_total,
|
|
18252
18286
|
input_tokens: row.input_tokens,
|
|
18287
|
+
cached_tokens: row.cached_tokens,
|
|
18253
18288
|
output_tokens: row.output_tokens,
|
|
18254
18289
|
total_tokens: row.total_tokens,
|
|
18255
18290
|
is_complete: row.is_complete === 1,
|
|
@@ -18273,11 +18308,17 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18273
18308
|
await this.ensureMigrated();
|
|
18274
18309
|
const byModel = {};
|
|
18275
18310
|
let totalCost = 0;
|
|
18311
|
+
let inputCost = 0;
|
|
18312
|
+
let cachedCost = 0;
|
|
18313
|
+
let outputCost = 0;
|
|
18276
18314
|
let requestCount = 0;
|
|
18277
18315
|
const modelRows = await this.ctx.storage.sql.exec(
|
|
18278
18316
|
`
|
|
18279
18317
|
SELECT COALESCE(model_name, model, 'unknown') AS model_key,
|
|
18280
18318
|
SUM(cost_total) AS total_cost,
|
|
18319
|
+
SUM(CASE WHEN cost_cached IS NOT NULL THEN cost_input END) AS input_cost,
|
|
18320
|
+
SUM(cost_cached) AS cached_cost,
|
|
18321
|
+
SUM(cost_output) AS output_cost,
|
|
18281
18322
|
COUNT(*) AS request_count
|
|
18282
18323
|
FROM logs
|
|
18283
18324
|
WHERE cost_total IS NOT NULL
|
|
@@ -18285,15 +18326,32 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18285
18326
|
`
|
|
18286
18327
|
);
|
|
18287
18328
|
for (const row of modelRows.toArray()) {
|
|
18288
|
-
byModel[row.model_key] = {
|
|
18329
|
+
byModel[row.model_key] = {
|
|
18330
|
+
totalCost: row.total_cost,
|
|
18331
|
+
inputCost: row.input_cost ?? 0,
|
|
18332
|
+
cachedCost: row.cached_cost ?? 0,
|
|
18333
|
+
outputCost: row.output_cost ?? 0,
|
|
18334
|
+
count: row.request_count
|
|
18335
|
+
};
|
|
18289
18336
|
totalCost += row.total_cost;
|
|
18337
|
+
inputCost += row.input_cost ?? 0;
|
|
18338
|
+
cachedCost += row.cached_cost ?? 0;
|
|
18339
|
+
outputCost += row.output_cost ?? 0;
|
|
18290
18340
|
requestCount += row.request_count;
|
|
18291
18341
|
}
|
|
18292
18342
|
const messageRow = await this.ctx.storage.sql.exec(
|
|
18293
18343
|
`SELECT COUNT(DISTINCT message_id) AS message_count FROM logs WHERE cost_total IS NOT NULL`
|
|
18294
18344
|
);
|
|
18295
18345
|
const messageCount = messageRow.one().message_count || 0;
|
|
18296
|
-
return {
|
|
18346
|
+
return {
|
|
18347
|
+
totalCost,
|
|
18348
|
+
inputCost,
|
|
18349
|
+
cachedCost,
|
|
18350
|
+
outputCost,
|
|
18351
|
+
requestCount,
|
|
18352
|
+
messageCount,
|
|
18353
|
+
byModel
|
|
18354
|
+
};
|
|
18297
18355
|
}
|
|
18298
18356
|
/**
|
|
18299
18357
|
* Get specific logs, optionally including all descendant logs.
|
|
@@ -18506,7 +18564,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18506
18564
|
l.request_body, l.request_headers, l.response_body, l.response_headers,
|
|
18507
18565
|
l.status_code, l.reasoning_content, l.input_tokens, l.cached_tokens, l.output_tokens,
|
|
18508
18566
|
l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
|
|
18509
|
-
l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_output, l.cost_total,
|
|
18567
|
+
l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_cached, l.cost_output, l.cost_total,
|
|
18510
18568
|
l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
|
|
18511
18569
|
l.queued_tools, l.provider_tools, l.parent_log_id, l.tools_schema, l.system_prompt,
|
|
18512
18570
|
l.errors, l.retry_of_log_id, l.tool_results, l.is_complete, l.created_at,
|
|
@@ -18596,6 +18654,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
18596
18654
|
error: row.error,
|
|
18597
18655
|
error_type: row.error_type,
|
|
18598
18656
|
cost_input: row.cost_input,
|
|
18657
|
+
cost_cached: row.cost_cached,
|
|
18599
18658
|
cost_output: row.cost_output,
|
|
18600
18659
|
cost_total: row.cost_total,
|
|
18601
18660
|
message_history_length: row.message_history_length,
|
|
@@ -19095,6 +19154,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
19095
19154
|
* Broadcast a log record to all connected WebSocket clients
|
|
19096
19155
|
*/
|
|
19097
19156
|
broadcastLog(log) {
|
|
19157
|
+
if (!this.logSockets || this.logSockets.size === 0) return;
|
|
19098
19158
|
const payload = JSON.stringify(log);
|
|
19099
19159
|
for (const ws of Array.from(this.logSockets)) {
|
|
19100
19160
|
try {
|
|
@@ -20498,7 +20558,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20498
20558
|
};
|
|
20499
20559
|
|
|
20500
20560
|
// src/durable-objects/agentbuilder-migrations/0001_initial.ts
|
|
20501
|
-
var
|
|
20561
|
+
var migration33 = {
|
|
20502
20562
|
version: 1,
|
|
20503
20563
|
async up(sql) {
|
|
20504
20564
|
sql.exec(`
|
|
@@ -20597,7 +20657,7 @@ var migration32 = {
|
|
|
20597
20657
|
};
|
|
20598
20658
|
|
|
20599
20659
|
// src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
|
|
20600
|
-
var
|
|
20660
|
+
var migration34 = {
|
|
20601
20661
|
version: 2,
|
|
20602
20662
|
async up(sql) {
|
|
20603
20663
|
sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
|
|
@@ -20609,7 +20669,7 @@ var migration33 = {
|
|
|
20609
20669
|
};
|
|
20610
20670
|
|
|
20611
20671
|
// src/durable-objects/agentbuilder-migrations/0003_add_parent_and_terminated.ts
|
|
20612
|
-
var
|
|
20672
|
+
var migration35 = {
|
|
20613
20673
|
version: 3,
|
|
20614
20674
|
async up(sql) {
|
|
20615
20675
|
sql.exec(`ALTER TABLE threads ADD COLUMN parent TEXT REFERENCES threads(id)`);
|
|
@@ -20622,7 +20682,7 @@ var migration34 = {
|
|
|
20622
20682
|
};
|
|
20623
20683
|
|
|
20624
20684
|
// src/durable-objects/agentbuilder-migrations/0004_add_env_tables.ts
|
|
20625
|
-
var
|
|
20685
|
+
var migration36 = {
|
|
20626
20686
|
version: 4,
|
|
20627
20687
|
async up(sql) {
|
|
20628
20688
|
sql.exec(`ALTER TABLE threads ADD COLUMN env TEXT`);
|
|
@@ -20646,7 +20706,7 @@ var migration35 = {
|
|
|
20646
20706
|
};
|
|
20647
20707
|
|
|
20648
20708
|
// src/durable-objects/agentbuilder-migrations/0005_add_pending_subagent_env_requests.ts
|
|
20649
|
-
var
|
|
20709
|
+
var migration37 = {
|
|
20650
20710
|
version: 5,
|
|
20651
20711
|
async up(sql) {
|
|
20652
20712
|
sql.exec(`
|
|
@@ -20672,7 +20732,7 @@ var migration36 = {
|
|
|
20672
20732
|
};
|
|
20673
20733
|
|
|
20674
20734
|
// src/durable-objects/agentbuilder-migrations/0006_add_env_value_types.ts
|
|
20675
|
-
var
|
|
20735
|
+
var migration38 = {
|
|
20676
20736
|
version: 6,
|
|
20677
20737
|
async up(sql) {
|
|
20678
20738
|
sql.exec(
|
|
@@ -20687,7 +20747,7 @@ var migration37 = {
|
|
|
20687
20747
|
};
|
|
20688
20748
|
|
|
20689
20749
|
// src/durable-objects/agentbuilder-migrations/0007_platform_identity_replica.ts
|
|
20690
|
-
var
|
|
20750
|
+
var migration39 = {
|
|
20691
20751
|
version: 7,
|
|
20692
20752
|
async up(sql) {
|
|
20693
20753
|
sql.exec(`ALTER TABLE users ADD COLUMN platform_user_id TEXT`);
|
|
@@ -20716,7 +20776,7 @@ var migration38 = {
|
|
|
20716
20776
|
};
|
|
20717
20777
|
|
|
20718
20778
|
// src/durable-objects/agentbuilder-migrations/0008_add_skills.ts
|
|
20719
|
-
var
|
|
20779
|
+
var migration40 = {
|
|
20720
20780
|
version: 8,
|
|
20721
20781
|
async up(sql) {
|
|
20722
20782
|
sql.exec(`
|
|
@@ -20747,7 +20807,7 @@ var migration39 = {
|
|
|
20747
20807
|
};
|
|
20748
20808
|
|
|
20749
20809
|
// src/durable-objects/agentbuilder-migrations/0009_add_user_permissions.ts
|
|
20750
|
-
var
|
|
20810
|
+
var migration41 = {
|
|
20751
20811
|
version: 9,
|
|
20752
20812
|
async up(sql) {
|
|
20753
20813
|
sql.exec(`ALTER TABLE users ADD COLUMN permissions TEXT`);
|
|
@@ -20758,7 +20818,7 @@ var migration40 = {
|
|
|
20758
20818
|
};
|
|
20759
20819
|
|
|
20760
20820
|
// src/durable-objects/agentbuilder-migrations/0010_add_device_logins.ts
|
|
20761
|
-
var
|
|
20821
|
+
var migration42 = {
|
|
20762
20822
|
version: 10,
|
|
20763
20823
|
async up(sql) {
|
|
20764
20824
|
sql.exec(`
|
|
@@ -20778,7 +20838,7 @@ var migration41 = {
|
|
|
20778
20838
|
};
|
|
20779
20839
|
|
|
20780
20840
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
20781
|
-
var migrations2 = [
|
|
20841
|
+
var migrations2 = [migration33, migration34, migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42];
|
|
20782
20842
|
var LATEST_SCHEMA_VERSION2 = 10;
|
|
20783
20843
|
|
|
20784
20844
|
// src/utils/crypto.ts
|
|
@@ -21541,9 +21601,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
21541
21601
|
}
|
|
21542
21602
|
}
|
|
21543
21603
|
async runMigrations(fromVersion) {
|
|
21544
|
-
for (const
|
|
21545
|
-
if (
|
|
21546
|
-
await
|
|
21604
|
+
for (const migration43 of migrations2) {
|
|
21605
|
+
if (migration43.version > fromVersion) {
|
|
21606
|
+
await migration43.up(this.ctx.storage.sql);
|
|
21547
21607
|
}
|
|
21548
21608
|
}
|
|
21549
21609
|
}
|