@standardagents/builder 0.17.0-next.a4b7340 → 0.17.0

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.
@@ -648,6 +648,8 @@ interface LLMResponse {
648
648
  };
649
649
  /** @internal Provider instance reference for async metadata fetching */
650
650
  _provider?: unknown;
651
+ /** @internal True when the request routed through the Standard Agents platform passthrough */
652
+ _viaPlatform?: boolean;
651
653
  /** @internal Provider response ID for async metadata fetching */
652
654
  _providerResponseId?: string;
653
655
  /** @internal Aggregate response for logging */
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, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, 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-EaxysUHv.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-BnrKzXpJ.js';
5
5
  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';
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
@@ -204,6 +204,16 @@ function getGoogleFallbackPricing(modelId) {
204
204
  if (prefixMatch) return { ...prefixMatch.pricing, source: "google-static" };
205
205
  return null;
206
206
  }
207
+ function getAnthropicFallbackPricing(modelId) {
208
+ const normalized = normalizeModelId(modelId);
209
+ let best = null;
210
+ for (const entry of ANTHROPIC_MODEL_PRICING_PREFIXES) {
211
+ if (normalized.startsWith(entry.prefix) && (!best || entry.prefix.length > best.prefix.length)) {
212
+ best = entry;
213
+ }
214
+ }
215
+ return best ? { ...best.pricing, source: "anthropic-static" } : null;
216
+ }
207
217
  function getGroqFallbackPricing(modelId) {
208
218
  const pricing = GROQ_MODEL_PRICING[normalizeModelId(modelId)];
209
219
  return pricing ? { ...pricing, source: "groq-static" } : null;
@@ -234,6 +244,9 @@ function resolveModelPricing(modelDef, providerName) {
234
244
  source: "model"
235
245
  };
236
246
  }
247
+ if (providerName === "anthropic") {
248
+ return getAnthropicFallbackPricing(modelDef.model);
249
+ }
237
250
  if (providerName === "cerebras") {
238
251
  return getCerebrasFallbackPricing(modelDef.model);
239
252
  }
@@ -269,10 +282,29 @@ function calculateUsageCost(usage, pricing) {
269
282
  costTotal: roundCost(costInput + costOutput)
270
283
  };
271
284
  }
272
- var TOKENS_PER_MILLION, CEREBRAS_MODEL_PRICING, GOOGLE_MODEL_PRICING, GOOGLE_MODEL_PRICING_PREFIXES, GROQ_MODEL_PRICING, XAI_MODEL_PRICING;
285
+ var TOKENS_PER_MILLION, ANTHROPIC_MODEL_PRICING_PREFIXES, CEREBRAS_MODEL_PRICING, GOOGLE_MODEL_PRICING, GOOGLE_MODEL_PRICING_PREFIXES, GROQ_MODEL_PRICING, XAI_MODEL_PRICING;
273
286
  var init_pricing = __esm({
274
287
  "src/agents/pricing.ts"() {
275
288
  TOKENS_PER_MILLION = 1e6;
289
+ ANTHROPIC_MODEL_PRICING_PREFIXES = [
290
+ { prefix: "claude-fable-5", pricing: { inputPrice: 10, outputPrice: 50, cachedPrice: 1 } },
291
+ { prefix: "claude-mythos", pricing: { inputPrice: 10, outputPrice: 50, cachedPrice: 1 } },
292
+ { prefix: "claude-opus-4-8", pricing: { inputPrice: 5, outputPrice: 25, cachedPrice: 0.5 } },
293
+ { prefix: "claude-opus-4-7", pricing: { inputPrice: 5, outputPrice: 25, cachedPrice: 0.5 } },
294
+ { prefix: "claude-opus-4-6", pricing: { inputPrice: 5, outputPrice: 25, cachedPrice: 0.5 } },
295
+ { prefix: "claude-opus-4-5", pricing: { inputPrice: 5, outputPrice: 25, cachedPrice: 0.5 } },
296
+ { prefix: "claude-opus-4-1", pricing: { inputPrice: 15, outputPrice: 75, cachedPrice: 1.5 } },
297
+ { prefix: "claude-opus-4", pricing: { inputPrice: 15, outputPrice: 75, cachedPrice: 1.5 } },
298
+ { prefix: "claude-sonnet-4-6", pricing: { inputPrice: 3, outputPrice: 15, cachedPrice: 0.3 } },
299
+ { prefix: "claude-sonnet-4-5", pricing: { inputPrice: 3, outputPrice: 15, cachedPrice: 0.3 } },
300
+ { prefix: "claude-sonnet-4", pricing: { inputPrice: 3, outputPrice: 15, cachedPrice: 0.3 } },
301
+ { prefix: "claude-haiku-4-5", pricing: { inputPrice: 1, outputPrice: 5, cachedPrice: 0.1 } },
302
+ { prefix: "claude-3-7-sonnet", pricing: { inputPrice: 3, outputPrice: 15, cachedPrice: 0.3 } },
303
+ { prefix: "claude-3-5-sonnet", pricing: { inputPrice: 3, outputPrice: 15, cachedPrice: 0.3 } },
304
+ { prefix: "claude-3-5-haiku", pricing: { inputPrice: 0.8, outputPrice: 4, cachedPrice: 0.08 } },
305
+ { prefix: "claude-3-opus", pricing: { inputPrice: 15, outputPrice: 75, cachedPrice: 1.5 } },
306
+ { prefix: "claude-3-haiku", pricing: { inputPrice: 0.25, outputPrice: 1.25, cachedPrice: 0.03 } }
307
+ ];
276
308
  CEREBRAS_MODEL_PRICING = {
277
309
  "zai-glm-4.7": {
278
310
  inputPrice: 2.25,
@@ -935,9 +967,9 @@ var init_ProviderRegistry = __esm({
935
967
  const fingerprint = this.getProviderFingerprint(providerName, modelDef);
936
968
  const cached = this.providerCache.get(modelName);
937
969
  if (cached?.fingerprint === fingerprint) {
938
- return this.buildResult(cached.provider, modelDef);
970
+ return this.buildResult(cached.provider, modelDef, false);
939
971
  }
940
- return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint);
972
+ return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint, false);
941
973
  }
942
974
  const apiKey = this.getApiKeyForProvider(providerName, env);
943
975
  if (apiKey) {
@@ -954,19 +986,19 @@ var init_ProviderRegistry = __esm({
954
986
  const fingerprint = this.getProviderFingerprint(providerName, modelDef, config);
955
987
  const cached = this.providerCache.get(modelName);
956
988
  if (cached?.fingerprint === fingerprint) {
957
- return this.buildResult(cached.provider, modelDef);
989
+ return this.buildResult(cached.provider, modelDef, false);
958
990
  }
959
- return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
991
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, false);
960
992
  }
961
993
  if (this.providerOverrideFn) {
962
994
  const overrideFingerprint = this.getProviderFingerprint(`override:${this.providerOverrideRevision}`, modelDef);
963
995
  const overrideCached = this.providerCache.get(modelName);
964
996
  if (overrideCached?.fingerprint === overrideFingerprint) {
965
- return this.buildResult(overrideCached.provider, modelDef);
997
+ return this.buildResult(overrideCached.provider, modelDef, true);
966
998
  }
967
999
  const overrideProvider = this.providerOverrideFn(modelName, modelDef, env);
968
1000
  if (overrideProvider) {
969
- return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
1001
+ return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint, true);
970
1002
  }
971
1003
  }
972
1004
  const routing = resolvePlatformRouting(providerName, env);
@@ -978,18 +1010,18 @@ var init_ProviderRegistry = __esm({
978
1010
  const fingerprint = this.getProviderFingerprint(`platform:${providerName}`, modelDef, config);
979
1011
  const cached = this.providerCache.get(modelName);
980
1012
  if (cached?.fingerprint === fingerprint) {
981
- return this.buildResult(cached.provider, modelDef);
1013
+ return this.buildResult(cached.provider, modelDef, true);
982
1014
  }
983
- return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
1015
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, true);
984
1016
  }
985
1017
  throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
986
1018
  }
987
- buildResult(provider, modelDef) {
988
- return { provider, modelName: modelDef.model, modelDef };
1019
+ buildResult(provider, modelDef, viaPlatform) {
1020
+ return { provider, modelName: modelDef.model, modelDef, viaPlatform };
989
1021
  }
990
- cacheAndReturn(modelName, provider, modelDef, fingerprint) {
991
- this.providerCache.set(modelName, { provider, fingerprint });
992
- return this.buildResult(provider, modelDef);
1022
+ cacheAndReturn(modelName, provider, modelDef, fingerprint, viaPlatform) {
1023
+ this.providerCache.set(modelName, { provider, fingerprint, viaPlatform });
1024
+ return this.buildResult(provider, modelDef, viaPlatform);
993
1025
  }
994
1026
  getProviderFingerprint(providerName, modelDef, config) {
995
1027
  return JSON.stringify({
@@ -1670,7 +1702,7 @@ var init_LLMRequest = __esm({
1670
1702
  */
1671
1703
  static async callModel(modelId, context, state, logId) {
1672
1704
  const { ProviderRegistry: ProviderRegistry2 } = await Promise.resolve().then(() => (init_providers(), providers_exports));
1673
- const { provider, modelName, modelDef } = await ProviderRegistry2.getProvider(
1705
+ const { provider, modelName, modelDef, viaPlatform } = await ProviderRegistry2.getProvider(
1674
1706
  modelId,
1675
1707
  state.env,
1676
1708
  state.thread.instance
@@ -1804,6 +1836,7 @@ var init_LLMRequest = __esm({
1804
1836
  }
1805
1837
  };
1806
1838
  response._provider = provider;
1839
+ response._viaPlatform = viaPlatform;
1807
1840
  response._providerResponseId = providerResponseId;
1808
1841
  response._aggregate_response = {
1809
1842
  id: responseId,
@@ -1881,7 +1914,7 @@ var init_LLMRequest = __esm({
1881
1914
  try {
1882
1915
  const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
1883
1916
  const providerName = response._provider?.name;
1884
- const standardAgentsRouterUsed = providerName === "platform";
1917
+ const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
1885
1918
  const resolvedPricing = resolveModelPricing(modelDef, providerName);
1886
1919
  const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
1887
1920
  const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
@@ -5986,7 +6019,7 @@ var init_FlowEngine = __esm({
5986
6019
  max_session_turns: newAgentDef.maxSessionTurns ?? null,
5987
6020
  side_a_label: newAgentDef.sideA?.label ?? null,
5988
6021
  side_a_agent_prompt: newAgentDef.sideA?.prompt ?? null,
5989
- side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? false,
6022
+ side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? true,
5990
6023
  side_a_stop_tool: newAgentDef.sideA?.stopTool ?? null,
5991
6024
  side_a_stop_tool_response_property: newAgentDef.sideA?.stopToolResponseProperty ?? null,
5992
6025
  side_a_max_steps: newAgentDef.sideA?.maxSteps ?? null,
@@ -6001,7 +6034,7 @@ var init_FlowEngine = __esm({
6001
6034
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
6002
6035
  side_b_label: newAgentDef.sideB?.label ?? null,
6003
6036
  side_b_agent_prompt: newAgentDef.sideB?.prompt ?? null,
6004
- side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? false,
6037
+ side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? true,
6005
6038
  side_b_stop_tool: newAgentDef.sideB?.stopTool ?? null,
6006
6039
  side_b_stop_tool_response_property: newAgentDef.sideB?.stopToolResponseProperty ?? null,
6007
6040
  side_b_max_steps: newAgentDef.sideB?.maxSteps ?? null,
@@ -13130,6 +13163,12 @@ function needsRegeneration(config) {
13130
13163
 
13131
13164
  // src/providers/catalog.ts
13132
13165
  var FIRST_PARTY_PROVIDERS = [
13166
+ {
13167
+ name: "anthropic",
13168
+ package: "@standardagents/anthropic",
13169
+ label: "Anthropic",
13170
+ envKeys: ["ANTHROPIC_API_KEY"]
13171
+ },
13133
13172
  {
13134
13173
  name: "cloudflare",
13135
13174
  package: "@standardagents/cloudflare",
@@ -19947,6 +19986,7 @@ var depsToInclude = [
19947
19986
  "zod/v4",
19948
19987
  "zod/v4/core",
19949
19988
  "openai",
19989
+ "@anthropic-ai/sdk",
19950
19990
  "magic-string",
19951
19991
  "@standardagents/spec"
19952
19992
  ];
@@ -25458,7 +25498,7 @@ ${resultContent}${attachmentSummary}`;
25458
25498
  max_session_turns: agentDef.maxSessionTurns,
25459
25499
  side_a_label: agentDef.sideA?.label,
25460
25500
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25461
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25501
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25462
25502
  side_a_stop_tool: agentDef.sideA?.stopTool,
25463
25503
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25464
25504
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25473,7 +25513,7 @@ ${resultContent}${attachmentSummary}`;
25473
25513
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25474
25514
  side_b_label: agentDef.sideB?.label,
25475
25515
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25476
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25516
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25477
25517
  side_b_stop_tool: agentDef.sideB?.stopTool,
25478
25518
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25479
25519
  side_b_max_steps: agentDef.sideB?.maxSteps,
@@ -25651,7 +25691,7 @@ ${resultContent}${attachmentSummary}`;
25651
25691
  max_session_turns: agentDef.maxSessionTurns,
25652
25692
  side_a_label: agentDef.sideA?.label,
25653
25693
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25654
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25694
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25655
25695
  side_a_stop_tool: agentDef.sideA?.stopTool,
25656
25696
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25657
25697
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25666,7 +25706,7 @@ ${resultContent}${attachmentSummary}`;
25666
25706
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25667
25707
  side_b_label: agentDef.sideB?.label,
25668
25708
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25669
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25709
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25670
25710
  side_b_stop_tool: agentDef.sideB?.stopTool,
25671
25711
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25672
25712
  side_b_max_steps: agentDef.sideB?.maxSteps,
@@ -25797,7 +25837,7 @@ ${resultContent}${attachmentSummary}`;
25797
25837
  max_session_turns: agentDef.maxSessionTurns,
25798
25838
  side_a_label: agentDef.sideA?.label,
25799
25839
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25800
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25840
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25801
25841
  side_a_stop_tool: agentDef.sideA?.stopTool,
25802
25842
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25803
25843
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25812,7 +25852,7 @@ ${resultContent}${attachmentSummary}`;
25812
25852
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25813
25853
  side_b_label: agentDef.sideB?.label,
25814
25854
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25815
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25855
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25816
25856
  side_b_stop_tool: agentDef.sideB?.stopTool,
25817
25857
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25818
25858
  side_b_max_steps: agentDef.sideB?.maxSteps,