@standardagents/builder 0.24.3 → 0.24.5

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.
Files changed (35) hide show
  1. package/dist/built-in-routes.js +32 -19
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-1m7uIS8S.js → ApiKeysView-CmObAp7n.js} +1 -1
  4. package/dist/client/{CenteredContentView-DJzHRMGj.js → CenteredContentView-gJXa9UHE.js} +1 -1
  5. package/dist/client/{CompositionView-nzqzVKAg.js → CompositionView-BohQwGLE.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-YX8WE_iB.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-A1C0eTY7.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-BpJt6BT0.js → CopyButton.vue_vue_type_script_setup_true_lang-D5q8qf4n.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-Dg3HMMJ0.js → DataTable.vue_vue_type_script_setup_true_lang-DzPpurCp.js} +1 -1
  9. package/dist/client/{JsonViewer-BdNA5OCG.js → JsonViewer-CKqMMqjU.js} +1 -1
  10. package/dist/client/{LoginView-BlF_2TtB.js → LoginView-BY2NMQQF.js} +1 -1
  11. package/dist/client/{MarketplaceView-DrlOb57k.js → MarketplaceView-DVEMUvDq.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-hkOmEwrb.js → Modal.vue_vue_type_script_setup_true_lang-1t6cxO9H.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-p3esoV-i.js → ModelModal.vue_vue_type_script_setup_true_lang-WFlATqyT.js} +1 -1
  14. package/dist/client/{ModelsView-CHBanMSH.js → ModelsView-_qZmXle8.js} +1 -1
  15. package/dist/client/{PromptEditView-b5B43l4Q.js → PromptEditView-DzY493YB.js} +1 -1
  16. package/dist/client/{PromptModal-BF5bdmNQ.js → PromptModal-BQYwnWKw.js} +1 -1
  17. package/dist/client/{PromptsView-6TfMOScI.js → PromptsView-DBiQ9X1g.js} +1 -1
  18. package/dist/client/{ProvidersView-CA5Yx2Fn.js → ProvidersView-DEH34_v0.js} +1 -1
  19. package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-ejyFhmNy.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-Dtd1VFrj.js} +2 -2
  20. package/dist/client/{ThreadsView-yJpVmf42.js → ThreadsView-m1CAq3Aw.js} +1 -1
  21. package/dist/client/{ToolsView-DE1TDnlU.js → ToolsView-D-qvyctb.js} +1 -1
  22. package/dist/client/{UsersView-BXDHjJLB.js → UsersView-DaXRB61v.js} +1 -1
  23. package/dist/client/{VariablesView-Bz-CbaEv.js → VariablesView-DDomn-IB.js} +1 -1
  24. package/dist/client/assets/{ThreadInspectorPane-DLSVKyBu.css → ThreadInspectorPane-CjK6SKEi.css} +1 -1
  25. package/dist/client/{index-TIntu1KJ.js → index-DihZBCmQ.js} +2 -2
  26. package/dist/client/index.html +1 -1
  27. package/dist/{index-jDKWlMKG.d.ts → index-D7KMmRgr.d.ts} +1 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +61 -38
  30. package/dist/index.js.map +1 -1
  31. package/dist/runtime.d.ts +3 -2
  32. package/dist/runtime.js +61 -38
  33. package/dist/runtime.js.map +1 -1
  34. package/dist/test.d.ts +1 -1
  35. package/package.json +5 -5
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-jDKWlMKG.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-jDKWlMKG.js';
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-D7KMmRgr.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-D7KMmRgr.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';
@@ -846,6 +846,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
846
846
  error: string | null;
847
847
  error_type: string | null;
848
848
  cost_input: number | null;
849
+ cost_cached: number | null;
849
850
  cost_output: number | null;
850
851
  cost_total: number | null;
851
852
  message_history_length: number | null;
package/dist/runtime.js CHANGED
@@ -236,14 +236,14 @@ function calculateUsageCost(usage, pricing) {
236
236
  const inputPrice = useLongContext ? pricing.longInputPrice ?? pricing.inputPrice : pricing.inputPrice;
237
237
  const outputPrice = useLongContext ? pricing.longOutputPrice ?? pricing.outputPrice : pricing.outputPrice;
238
238
  const cachedTokenPrice = useLongContext ? pricing.longCachedPrice ?? pricing.cachedPrice ?? pricing.inputPrice : pricing.cachedPrice ?? pricing.inputPrice;
239
- const costInput = roundCost(
240
- (uncachedPromptTokens * inputPrice + cachedTokens * cachedTokenPrice) / TOKENS_PER_MILLION
241
- );
239
+ const costInput = roundCost(uncachedPromptTokens * inputPrice / TOKENS_PER_MILLION);
240
+ const costCached = roundCost(cachedTokens * cachedTokenPrice / TOKENS_PER_MILLION);
242
241
  const costOutput = roundCost(billableOutputTokens * outputPrice / TOKENS_PER_MILLION);
243
242
  return {
244
243
  costInput,
244
+ costCached,
245
245
  costOutput,
246
- costTotal: roundCost(costInput + costOutput)
246
+ costTotal: roundCost(costInput + costCached + costOutput)
247
247
  };
248
248
  }
249
249
  var TOKENS_PER_MILLION;
@@ -1298,10 +1298,14 @@ function buildRequestBody(context, modelDef) {
1298
1298
  visionFiltering
1299
1299
  };
1300
1300
  }
1301
- function buildProviderRequest(context, modelDef, signal) {
1301
+ function buildProviderRequest(context, modelDef, signal, user) {
1302
1302
  const { requestBody } = buildRequestBody(context, modelDef);
1303
1303
  return {
1304
1304
  ...requestBody,
1305
+ // Stable per-thread identity: providers that support it (OpenRouter's
1306
+ // provider-sticky routing) pin the thread to one upstream, which is what
1307
+ // makes prompt caching hit across consecutive steps.
1308
+ user,
1305
1309
  signal
1306
1310
  };
1307
1311
  }
@@ -1648,7 +1652,7 @@ var init_LLMRequest = __esm({
1648
1652
  parentSignal.addEventListener("abort", onParentAbort, { once: true });
1649
1653
  }
1650
1654
  }
1651
- const request = buildProviderRequest(context, modelDef, streamAbort.signal);
1655
+ const request = buildProviderRequest(context, modelDef, streamAbort.signal, state.threadId);
1652
1656
  let response;
1653
1657
  await state.stream.waitFor(
1654
1658
  async () => {
@@ -2107,6 +2111,7 @@ var init_LLMRequest = __esm({
2107
2111
  reasoning_tokens: response.usage.completion_tokens_details?.reasoning_tokens || 0,
2108
2112
  total_tokens: response.usage.total_tokens,
2109
2113
  cost_input: calculatedCost?.costInput,
2114
+ cost_cached: calculatedCost?.costCached,
2110
2115
  cost_output: calculatedCost?.costOutput,
2111
2116
  latency_ms: Date.now() - startTime,
2112
2117
  time_to_first_token_ms: timing?.latencyMs ?? void 0,
@@ -2136,19 +2141,20 @@ var init_LLMRequest = __esm({
2136
2141
  reasoning_tokens = ?5,
2137
2142
  total_tokens = ?6,
2138
2143
  cost_input = ?7,
2139
- cost_output = ?8,
2140
- latency_ms = ?9,
2141
- finish_reason = ?10,
2142
- tools_called = ?11,
2143
- cost_total = ?12,
2144
- is_complete = ?13,
2145
- reasoning_content = ?14,
2146
- provider_tools = ?15,
2147
- actual_provider = ?16,
2148
- standard_agents_router_used = ?17,
2149
- time_to_first_token_ms = ?18,
2150
- generation_ms = ?19
2151
- WHERE id = ?20
2144
+ cost_cached = ?8,
2145
+ cost_output = ?9,
2146
+ latency_ms = ?10,
2147
+ finish_reason = ?11,
2148
+ tools_called = ?12,
2149
+ cost_total = ?13,
2150
+ is_complete = ?14,
2151
+ reasoning_content = ?15,
2152
+ provider_tools = ?16,
2153
+ actual_provider = ?17,
2154
+ standard_agents_router_used = ?18,
2155
+ time_to_first_token_ms = ?19,
2156
+ generation_ms = ?20
2157
+ WHERE id = ?21
2152
2158
  `,
2153
2159
  logData.response_body,
2154
2160
  logData.input_tokens,
@@ -2157,6 +2163,7 @@ var init_LLMRequest = __esm({
2157
2163
  logData.reasoning_tokens,
2158
2164
  logData.total_tokens,
2159
2165
  logData.cost_input ?? null,
2166
+ logData.cost_cached ?? null,
2160
2167
  logData.cost_output ?? null,
2161
2168
  logData.latency_ms,
2162
2169
  logData.finish_reason,
@@ -14667,8 +14674,23 @@ var migration31 = {
14667
14674
  }
14668
14675
  };
14669
14676
 
14677
+ // src/durable-objects/migrations/032_add_cost_cached.ts
14678
+ var migration32 = {
14679
+ version: 32,
14680
+ name: "add_cost_cached",
14681
+ async up(sql) {
14682
+ const tableInfo = sql.exec(`PRAGMA table_info(logs)`).toArray();
14683
+ const hasCostCached = tableInfo.some((col) => col.name === "cost_cached");
14684
+ if (!hasCostCached) {
14685
+ await sql.exec(`
14686
+ ALTER TABLE logs ADD COLUMN cost_cached REAL;
14687
+ `);
14688
+ }
14689
+ }
14690
+ };
14691
+
14670
14692
  // src/durable-objects/migrations/index.ts
14671
- 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];
14693
+ 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];
14672
14694
  var LATEST_SCHEMA_VERSION = migrations.length;
14673
14695
 
14674
14696
  // src/durable-objects/DurableThread.ts
@@ -16784,9 +16806,9 @@ var DurableThread = class _DurableThread extends DurableObject {
16784
16806
  * Each migration is run in order, starting from the current version + 1.
16785
16807
  */
16786
16808
  async runMigrations(fromVersion) {
16787
- for (const migration42 of migrations) {
16788
- if (migration42.version > fromVersion) {
16789
- await migration42.up(this.ctx.storage.sql);
16809
+ for (const migration43 of migrations) {
16810
+ if (migration43.version > fromVersion) {
16811
+ await migration43.up(this.ctx.storage.sql);
16790
16812
  }
16791
16813
  }
16792
16814
  }
@@ -18502,7 +18524,7 @@ ${resultContent}${attachmentSummary}`;
18502
18524
  l.request_body, l.request_headers, l.response_body, l.response_headers,
18503
18525
  l.status_code, l.reasoning_content, l.input_tokens, l.cached_tokens, l.output_tokens,
18504
18526
  l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
18505
- l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_output, l.cost_total,
18527
+ l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_cached, l.cost_output, l.cost_total,
18506
18528
  l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
18507
18529
  l.queued_tools, l.provider_tools, l.parent_log_id, l.tools_schema, l.system_prompt,
18508
18530
  l.errors, l.retry_of_log_id, l.tool_results, l.is_complete, l.created_at,
@@ -18592,6 +18614,7 @@ ${resultContent}${attachmentSummary}`;
18592
18614
  error: row.error,
18593
18615
  error_type: row.error_type,
18594
18616
  cost_input: row.cost_input,
18617
+ cost_cached: row.cost_cached,
18595
18618
  cost_output: row.cost_output,
18596
18619
  cost_total: row.cost_total,
18597
18620
  message_history_length: row.message_history_length,
@@ -20494,7 +20517,7 @@ ${resultContent}${attachmentSummary}`;
20494
20517
  };
20495
20518
 
20496
20519
  // src/durable-objects/agentbuilder-migrations/0001_initial.ts
20497
- var migration32 = {
20520
+ var migration33 = {
20498
20521
  version: 1,
20499
20522
  async up(sql) {
20500
20523
  sql.exec(`
@@ -20593,7 +20616,7 @@ var migration32 = {
20593
20616
  };
20594
20617
 
20595
20618
  // src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
20596
- var migration33 = {
20619
+ var migration34 = {
20597
20620
  version: 2,
20598
20621
  async up(sql) {
20599
20622
  sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
@@ -20605,7 +20628,7 @@ var migration33 = {
20605
20628
  };
20606
20629
 
20607
20630
  // src/durable-objects/agentbuilder-migrations/0003_add_parent_and_terminated.ts
20608
- var migration34 = {
20631
+ var migration35 = {
20609
20632
  version: 3,
20610
20633
  async up(sql) {
20611
20634
  sql.exec(`ALTER TABLE threads ADD COLUMN parent TEXT REFERENCES threads(id)`);
@@ -20618,7 +20641,7 @@ var migration34 = {
20618
20641
  };
20619
20642
 
20620
20643
  // src/durable-objects/agentbuilder-migrations/0004_add_env_tables.ts
20621
- var migration35 = {
20644
+ var migration36 = {
20622
20645
  version: 4,
20623
20646
  async up(sql) {
20624
20647
  sql.exec(`ALTER TABLE threads ADD COLUMN env TEXT`);
@@ -20642,7 +20665,7 @@ var migration35 = {
20642
20665
  };
20643
20666
 
20644
20667
  // src/durable-objects/agentbuilder-migrations/0005_add_pending_subagent_env_requests.ts
20645
- var migration36 = {
20668
+ var migration37 = {
20646
20669
  version: 5,
20647
20670
  async up(sql) {
20648
20671
  sql.exec(`
@@ -20668,7 +20691,7 @@ var migration36 = {
20668
20691
  };
20669
20692
 
20670
20693
  // src/durable-objects/agentbuilder-migrations/0006_add_env_value_types.ts
20671
- var migration37 = {
20694
+ var migration38 = {
20672
20695
  version: 6,
20673
20696
  async up(sql) {
20674
20697
  sql.exec(
@@ -20683,7 +20706,7 @@ var migration37 = {
20683
20706
  };
20684
20707
 
20685
20708
  // src/durable-objects/agentbuilder-migrations/0007_platform_identity_replica.ts
20686
- var migration38 = {
20709
+ var migration39 = {
20687
20710
  version: 7,
20688
20711
  async up(sql) {
20689
20712
  sql.exec(`ALTER TABLE users ADD COLUMN platform_user_id TEXT`);
@@ -20712,7 +20735,7 @@ var migration38 = {
20712
20735
  };
20713
20736
 
20714
20737
  // src/durable-objects/agentbuilder-migrations/0008_add_skills.ts
20715
- var migration39 = {
20738
+ var migration40 = {
20716
20739
  version: 8,
20717
20740
  async up(sql) {
20718
20741
  sql.exec(`
@@ -20743,7 +20766,7 @@ var migration39 = {
20743
20766
  };
20744
20767
 
20745
20768
  // src/durable-objects/agentbuilder-migrations/0009_add_user_permissions.ts
20746
- var migration40 = {
20769
+ var migration41 = {
20747
20770
  version: 9,
20748
20771
  async up(sql) {
20749
20772
  sql.exec(`ALTER TABLE users ADD COLUMN permissions TEXT`);
@@ -20754,7 +20777,7 @@ var migration40 = {
20754
20777
  };
20755
20778
 
20756
20779
  // src/durable-objects/agentbuilder-migrations/0010_add_device_logins.ts
20757
- var migration41 = {
20780
+ var migration42 = {
20758
20781
  version: 10,
20759
20782
  async up(sql) {
20760
20783
  sql.exec(`
@@ -20774,7 +20797,7 @@ var migration41 = {
20774
20797
  };
20775
20798
 
20776
20799
  // src/durable-objects/agentbuilder-migrations/index.ts
20777
- var migrations2 = [migration32, migration33, migration34, migration35, migration36, migration37, migration38, migration39, migration40, migration41];
20800
+ var migrations2 = [migration33, migration34, migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42];
20778
20801
  var LATEST_SCHEMA_VERSION2 = 10;
20779
20802
 
20780
20803
  // src/utils/crypto.ts
@@ -21537,9 +21560,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
21537
21560
  }
21538
21561
  }
21539
21562
  async runMigrations(fromVersion) {
21540
- for (const migration42 of migrations2) {
21541
- if (migration42.version > fromVersion) {
21542
- await migration42.up(this.ctx.storage.sql);
21563
+ for (const migration43 of migrations2) {
21564
+ if (migration43.version > fromVersion) {
21565
+ await migration43.up(this.ctx.storage.sql);
21543
21566
  }
21544
21567
  }
21545
21568
  }