@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
@@ -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-TIntu1KJ.js"></script>
29
+ <script type="module" crossorigin src="/agents/index-DihZBCmQ.js"></script>
30
30
  <link rel="modulepreload" crossorigin href="/agents/formkit-DcuuXZjC.js">
31
31
  <link rel="modulepreload" crossorigin href="/agents/vendor-TPZjEwCU.js">
32
32
  <link rel="modulepreload" crossorigin href="/agents/syntax-D-ZcovVx.js">
@@ -845,6 +845,7 @@ interface LogData {
845
845
  error?: string;
846
846
  error_type?: string;
847
847
  cost_input?: number;
848
+ cost_cached?: number;
848
849
  cost_output?: number;
849
850
  cost_total?: number;
850
851
  message_history_length?: number;
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, FlowStateSdk, FlowStateWithSdk, ImageContextConfig, InjectMessageOptions, LLMProviderInterface, NamespaceResolutionError, PromptContent, PromptDefinition, PromptIncludePart, PromptPart, PromptToolConfig, Provider, ProviderContentPart, ProviderFilePart, ProviderImagePart, ProviderRegistry, ProviderTextPart, SessionToolBinding, SessionToolConfig, SideConfig, SubagentToolConfig, SubpromptConfig, ThreadRegistryEntry, ToolConfig, UpdateThreadParams, User, 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, m as AttachmentRef, f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, E as Env, l as FileRecord, n as FileStats, j as FlowResult, F as FlowState, G as GrepResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, r as MessageContent, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, g as ThreadInstance, h as ThreadMetadata, T as ToolCall, i as ToolResult, c as createThreadEndpointHandler, d as defineController } from './index-jDKWlMKG.js';
4
+ export { A as Agent, m as AttachmentRef, f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, E as Env, l as FileRecord, n as FileStats, j as FlowResult, F as FlowState, G as GrepResult, p as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, r as MessageContent, q as MultimodalContent, R as RequestContext, S as StorageBackend, k as TelemetryEvent, o as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, g as ThreadInstance, h as ThreadMetadata, T as ToolCall, i as ToolResult, c as createThreadEndpointHandler, d as defineController } from './index-D7KMmRgr.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
@@ -245,14 +245,14 @@ function calculateUsageCost(usage, pricing) {
245
245
  const inputPrice = useLongContext ? pricing.longInputPrice ?? pricing.inputPrice : pricing.inputPrice;
246
246
  const outputPrice = useLongContext ? pricing.longOutputPrice ?? pricing.outputPrice : pricing.outputPrice;
247
247
  const cachedTokenPrice = useLongContext ? pricing.longCachedPrice ?? pricing.cachedPrice ?? pricing.inputPrice : pricing.cachedPrice ?? pricing.inputPrice;
248
- const costInput = roundCost(
249
- (uncachedPromptTokens * inputPrice + cachedTokens * cachedTokenPrice) / TOKENS_PER_MILLION
250
- );
248
+ const costInput = roundCost(uncachedPromptTokens * inputPrice / TOKENS_PER_MILLION);
249
+ const costCached = roundCost(cachedTokens * cachedTokenPrice / TOKENS_PER_MILLION);
251
250
  const costOutput = roundCost(billableOutputTokens * outputPrice / TOKENS_PER_MILLION);
252
251
  return {
253
252
  costInput,
253
+ costCached,
254
254
  costOutput,
255
- costTotal: roundCost(costInput + costOutput)
255
+ costTotal: roundCost(costInput + costCached + costOutput)
256
256
  };
257
257
  }
258
258
  var TOKENS_PER_MILLION;
@@ -1307,10 +1307,14 @@ function buildRequestBody(context, modelDef) {
1307
1307
  visionFiltering
1308
1308
  };
1309
1309
  }
1310
- function buildProviderRequest(context, modelDef, signal) {
1310
+ function buildProviderRequest(context, modelDef, signal, user) {
1311
1311
  const { requestBody } = buildRequestBody(context, modelDef);
1312
1312
  return {
1313
1313
  ...requestBody,
1314
+ // Stable per-thread identity: providers that support it (OpenRouter's
1315
+ // provider-sticky routing) pin the thread to one upstream, which is what
1316
+ // makes prompt caching hit across consecutive steps.
1317
+ user,
1314
1318
  signal
1315
1319
  };
1316
1320
  }
@@ -1657,7 +1661,7 @@ var init_LLMRequest = __esm({
1657
1661
  parentSignal.addEventListener("abort", onParentAbort, { once: true });
1658
1662
  }
1659
1663
  }
1660
- const request = buildProviderRequest(context, modelDef, streamAbort.signal);
1664
+ const request = buildProviderRequest(context, modelDef, streamAbort.signal, state.threadId);
1661
1665
  let response;
1662
1666
  await state.stream.waitFor(
1663
1667
  async () => {
@@ -2116,6 +2120,7 @@ var init_LLMRequest = __esm({
2116
2120
  reasoning_tokens: response.usage.completion_tokens_details?.reasoning_tokens || 0,
2117
2121
  total_tokens: response.usage.total_tokens,
2118
2122
  cost_input: calculatedCost?.costInput,
2123
+ cost_cached: calculatedCost?.costCached,
2119
2124
  cost_output: calculatedCost?.costOutput,
2120
2125
  latency_ms: Date.now() - startTime,
2121
2126
  time_to_first_token_ms: timing?.latencyMs ?? void 0,
@@ -2145,19 +2150,20 @@ var init_LLMRequest = __esm({
2145
2150
  reasoning_tokens = ?5,
2146
2151
  total_tokens = ?6,
2147
2152
  cost_input = ?7,
2148
- cost_output = ?8,
2149
- latency_ms = ?9,
2150
- finish_reason = ?10,
2151
- tools_called = ?11,
2152
- cost_total = ?12,
2153
- is_complete = ?13,
2154
- reasoning_content = ?14,
2155
- provider_tools = ?15,
2156
- actual_provider = ?16,
2157
- standard_agents_router_used = ?17,
2158
- time_to_first_token_ms = ?18,
2159
- generation_ms = ?19
2160
- WHERE id = ?20
2153
+ cost_cached = ?8,
2154
+ cost_output = ?9,
2155
+ latency_ms = ?10,
2156
+ finish_reason = ?11,
2157
+ tools_called = ?12,
2158
+ cost_total = ?13,
2159
+ is_complete = ?14,
2160
+ reasoning_content = ?15,
2161
+ provider_tools = ?16,
2162
+ actual_provider = ?17,
2163
+ standard_agents_router_used = ?18,
2164
+ time_to_first_token_ms = ?19,
2165
+ generation_ms = ?20
2166
+ WHERE id = ?21
2161
2167
  `,
2162
2168
  logData.response_body,
2163
2169
  logData.input_tokens,
@@ -2166,6 +2172,7 @@ var init_LLMRequest = __esm({
2166
2172
  logData.reasoning_tokens,
2167
2173
  logData.total_tokens,
2168
2174
  logData.cost_input ?? null,
2175
+ logData.cost_cached ?? null,
2169
2176
  logData.cost_output ?? null,
2170
2177
  logData.latency_ms,
2171
2178
  logData.finish_reason,
@@ -22914,8 +22921,23 @@ var migration31 = {
22914
22921
  }
22915
22922
  };
22916
22923
 
22924
+ // src/durable-objects/migrations/032_add_cost_cached.ts
22925
+ var migration32 = {
22926
+ version: 32,
22927
+ name: "add_cost_cached",
22928
+ async up(sql) {
22929
+ const tableInfo = sql.exec(`PRAGMA table_info(logs)`).toArray();
22930
+ const hasCostCached = tableInfo.some((col) => col.name === "cost_cached");
22931
+ if (!hasCostCached) {
22932
+ await sql.exec(`
22933
+ ALTER TABLE logs ADD COLUMN cost_cached REAL;
22934
+ `);
22935
+ }
22936
+ }
22937
+ };
22938
+
22917
22939
  // src/durable-objects/migrations/index.ts
22918
- 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];
22940
+ 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];
22919
22941
  var LATEST_SCHEMA_VERSION = migrations.length;
22920
22942
 
22921
22943
  // src/durable-objects/DurableThread.ts
@@ -25031,9 +25053,9 @@ var DurableThread = class _DurableThread extends DurableObject {
25031
25053
  * Each migration is run in order, starting from the current version + 1.
25032
25054
  */
25033
25055
  async runMigrations(fromVersion) {
25034
- for (const migration42 of migrations) {
25035
- if (migration42.version > fromVersion) {
25036
- await migration42.up(this.ctx.storage.sql);
25056
+ for (const migration43 of migrations) {
25057
+ if (migration43.version > fromVersion) {
25058
+ await migration43.up(this.ctx.storage.sql);
25037
25059
  }
25038
25060
  }
25039
25061
  }
@@ -26749,7 +26771,7 @@ ${resultContent}${attachmentSummary}`;
26749
26771
  l.request_body, l.request_headers, l.response_body, l.response_headers,
26750
26772
  l.status_code, l.reasoning_content, l.input_tokens, l.cached_tokens, l.output_tokens,
26751
26773
  l.reasoning_tokens, l.total_tokens, l.latency_ms, l.time_to_first_token_ms, l.generation_ms,
26752
- l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_output, l.cost_total,
26774
+ l.finish_reason, l.error, l.error_type, l.cost_input, l.cost_cached, l.cost_output, l.cost_total,
26753
26775
  l.message_history_length, l.tools_available, l.prompt_name, l.tools_called,
26754
26776
  l.queued_tools, l.provider_tools, l.parent_log_id, l.tools_schema, l.system_prompt,
26755
26777
  l.errors, l.retry_of_log_id, l.tool_results, l.is_complete, l.created_at,
@@ -26839,6 +26861,7 @@ ${resultContent}${attachmentSummary}`;
26839
26861
  error: row.error,
26840
26862
  error_type: row.error_type,
26841
26863
  cost_input: row.cost_input,
26864
+ cost_cached: row.cost_cached,
26842
26865
  cost_output: row.cost_output,
26843
26866
  cost_total: row.cost_total,
26844
26867
  message_history_length: row.message_history_length,
@@ -28741,7 +28764,7 @@ ${resultContent}${attachmentSummary}`;
28741
28764
  };
28742
28765
 
28743
28766
  // src/durable-objects/agentbuilder-migrations/0001_initial.ts
28744
- var migration32 = {
28767
+ var migration33 = {
28745
28768
  version: 1,
28746
28769
  async up(sql) {
28747
28770
  sql.exec(`
@@ -28840,7 +28863,7 @@ var migration32 = {
28840
28863
  };
28841
28864
 
28842
28865
  // src/durable-objects/agentbuilder-migrations/0002_add_tenvs_properties.ts
28843
- var migration33 = {
28866
+ var migration34 = {
28844
28867
  version: 2,
28845
28868
  async up(sql) {
28846
28869
  sql.exec(`ALTER TABLE threads ADD COLUMN tenvs TEXT`);
@@ -28852,7 +28875,7 @@ var migration33 = {
28852
28875
  };
28853
28876
 
28854
28877
  // src/durable-objects/agentbuilder-migrations/0003_add_parent_and_terminated.ts
28855
- var migration34 = {
28878
+ var migration35 = {
28856
28879
  version: 3,
28857
28880
  async up(sql) {
28858
28881
  sql.exec(`ALTER TABLE threads ADD COLUMN parent TEXT REFERENCES threads(id)`);
@@ -28865,7 +28888,7 @@ var migration34 = {
28865
28888
  };
28866
28889
 
28867
28890
  // src/durable-objects/agentbuilder-migrations/0004_add_env_tables.ts
28868
- var migration35 = {
28891
+ var migration36 = {
28869
28892
  version: 4,
28870
28893
  async up(sql) {
28871
28894
  sql.exec(`ALTER TABLE threads ADD COLUMN env TEXT`);
@@ -28889,7 +28912,7 @@ var migration35 = {
28889
28912
  };
28890
28913
 
28891
28914
  // src/durable-objects/agentbuilder-migrations/0005_add_pending_subagent_env_requests.ts
28892
- var migration36 = {
28915
+ var migration37 = {
28893
28916
  version: 5,
28894
28917
  async up(sql) {
28895
28918
  sql.exec(`
@@ -28915,7 +28938,7 @@ var migration36 = {
28915
28938
  };
28916
28939
 
28917
28940
  // src/durable-objects/agentbuilder-migrations/0006_add_env_value_types.ts
28918
- var migration37 = {
28941
+ var migration38 = {
28919
28942
  version: 6,
28920
28943
  async up(sql) {
28921
28944
  sql.exec(
@@ -28930,7 +28953,7 @@ var migration37 = {
28930
28953
  };
28931
28954
 
28932
28955
  // src/durable-objects/agentbuilder-migrations/0007_platform_identity_replica.ts
28933
- var migration38 = {
28956
+ var migration39 = {
28934
28957
  version: 7,
28935
28958
  async up(sql) {
28936
28959
  sql.exec(`ALTER TABLE users ADD COLUMN platform_user_id TEXT`);
@@ -28959,7 +28982,7 @@ var migration38 = {
28959
28982
  };
28960
28983
 
28961
28984
  // src/durable-objects/agentbuilder-migrations/0008_add_skills.ts
28962
- var migration39 = {
28985
+ var migration40 = {
28963
28986
  version: 8,
28964
28987
  async up(sql) {
28965
28988
  sql.exec(`
@@ -28990,7 +29013,7 @@ var migration39 = {
28990
29013
  };
28991
29014
 
28992
29015
  // src/durable-objects/agentbuilder-migrations/0009_add_user_permissions.ts
28993
- var migration40 = {
29016
+ var migration41 = {
28994
29017
  version: 9,
28995
29018
  async up(sql) {
28996
29019
  sql.exec(`ALTER TABLE users ADD COLUMN permissions TEXT`);
@@ -29001,7 +29024,7 @@ var migration40 = {
29001
29024
  };
29002
29025
 
29003
29026
  // src/durable-objects/agentbuilder-migrations/0010_add_device_logins.ts
29004
- var migration41 = {
29027
+ var migration42 = {
29005
29028
  version: 10,
29006
29029
  async up(sql) {
29007
29030
  sql.exec(`
@@ -29021,7 +29044,7 @@ var migration41 = {
29021
29044
  };
29022
29045
 
29023
29046
  // src/durable-objects/agentbuilder-migrations/index.ts
29024
- var migrations2 = [migration32, migration33, migration34, migration35, migration36, migration37, migration38, migration39, migration40, migration41];
29047
+ var migrations2 = [migration33, migration34, migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42];
29025
29048
  var LATEST_SCHEMA_VERSION2 = 10;
29026
29049
 
29027
29050
  // src/utils/crypto.ts
@@ -29784,9 +29807,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
29784
29807
  }
29785
29808
  }
29786
29809
  async runMigrations(fromVersion) {
29787
- for (const migration42 of migrations2) {
29788
- if (migration42.version > fromVersion) {
29789
- await migration42.up(this.ctx.storage.sql);
29810
+ for (const migration43 of migrations2) {
29811
+ if (migration43.version > fromVersion) {
29812
+ await migration43.up(this.ctx.storage.sql);
29790
29813
  }
29791
29814
  }
29792
29815
  }