@standardagents/builder 0.41.22 → 0.41.26

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 (39) hide show
  1. package/dist/built-in-routes.js +387 -134
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-D4g6ZNWG.js → ApiKeysView-CJYLO_ua.js} +1 -1
  4. package/dist/client/{CenteredContentView-B3WUhJPU.js → CenteredContentView-V1sCsISI.js} +1 -1
  5. package/dist/client/{CompositionView-pL0H07yI.js → CompositionView-hqbZ8f7d.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-uehuZFVv.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-CYrgsA6b.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-vwNMv4kh.js → CopyButton.vue_vue_type_script_setup_true_lang-DFIJfKuD.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-lgIAQ4Oz.js → DataTable.vue_vue_type_script_setup_true_lang-IvRbPHup.js} +1 -1
  9. package/dist/client/{JsonViewer-BsC-w_01.js → JsonViewer-C6FsqOlJ.js} +1 -1
  10. package/dist/client/{LoginView-DriOurmS.js → LoginView-san5UrfX.js} +1 -1
  11. package/dist/client/{MarketplaceView-7pl01VFg.js → MarketplaceView-B89Shmm7.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-CQE6ME9a.js → Modal.vue_vue_type_script_setup_true_lang-BLzEXJtn.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-Dv-GVzNy.js → ModelModal.vue_vue_type_script_setup_true_lang-DTd4Jp3K.js} +1 -1
  14. package/dist/client/{ModelsView-BDxyu8pj.js → ModelsView-DWLrrwGf.js} +1 -1
  15. package/dist/client/{PromptEditView-Brn_lMum.js → PromptEditView-PHQ8rLZn.js} +1 -1
  16. package/dist/client/{PromptModal-BeqgBmpj.js → PromptModal-Bk5rLNB7.js} +1 -1
  17. package/dist/client/{PromptsView-Dgu1UMES.js → PromptsView-gugjlK3M.js} +1 -1
  18. package/dist/client/{ProvidersView-B3SPkaxt.js → ProvidersView-DVV8Q1Sw.js} +1 -1
  19. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-BvsyovVV.js +22 -0
  20. package/dist/client/{ThreadsView-D0hT0NXg.js → ThreadsView-Doxz0NfK.js} +1 -1
  21. package/dist/client/{ToolsView-BitH87Mf.js → ToolsView-BZfq0wpk.js} +1 -1
  22. package/dist/client/{UsersView-BArKqDfJ.js → UsersView-D5sXzAHz.js} +1 -1
  23. package/dist/client/{VariablesView-BJtT_XLQ.js → VariablesView-BlEY-E07.js} +1 -1
  24. package/dist/client/assets/{ThreadInspectorPane-C9Lp8kxl.css → ThreadInspectorPane-DczJCBBm.css} +1 -1
  25. package/dist/client/{index-CAiyJVjz.js → index-CdsRfG1j.js} +2 -2
  26. package/dist/client/index.html +1 -1
  27. package/dist/{index-BhIiPl8o.d.ts → index-Dn0rBA1H.d.ts} +4 -2
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +196 -35
  30. package/dist/index.js.map +1 -1
  31. package/dist/plugin.js +1 -1
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/{resolver-D30lNT4L.d.ts → resolver-C6zKX6kw.d.ts} +11 -5
  34. package/dist/runtime.d.ts +2 -2
  35. package/dist/runtime.js +195 -34
  36. package/dist/runtime.js.map +1 -1
  37. package/dist/test.d.ts +1 -1
  38. package/package.json +5 -5
  39. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DaArzwIz.js +0 -22
@@ -1,4 +1,4 @@
1
- import { i as AuthContext, b as ThreadEnv, v as Agent, x as ThreadMetadata, z as ToolResult, M as Message, n as ClientToolRequest, o as ClientToolResponse, V as ProxyStreamReceiver, W as ProxyStreamFrame, p as ClientStreamRequest, X as ProxyStreamTarget, q as ClientStreamResponse, Y as ProxyStreamOpenResult, H as FileRecord, Z as SkillStorageScope, F as FlowState, N as FileStats, K as GrepResult, J as AttachmentRef, U as MessageContent, G as Env, w as ThreadInstance } from './index-BhIiPl8o.js';
1
+ import { i as AuthContext, b as ThreadEnv, v as Agent, x as ThreadMetadata, z as ToolResult, M as Message, n as ClientToolRequest, o as ClientToolResponse, V as ProxyStreamReceiver, W as ProxyStreamFrame, p as ClientStreamRequest, X as ProxyStreamTarget, q as ClientStreamResponse, Y as ProxyStreamOpenResult, H as FileRecord, Z as SkillStorageScope, F as FlowState, N as FileStats, K as GrepResult, J as AttachmentRef, U as MessageContent, G as Env, w as ThreadInstance } from './index-Dn0rBA1H.js';
2
2
  import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
3
3
  import { ThreadStatus, ThreadLogEntry, CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, UserRoomConnection, CredentialGrant, SkillMetadata, SkillFileInput, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, PromptEnvPart, VariableDefinition, SubpromptConfig as SubpromptConfig$1, PromptToolConfig as PromptToolConfig$1, ReasoningConfig, HumanSide as HumanSide$1, SubagentRelationship as SubagentRelationship$1, ParentHookRequirement, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, ThreadState, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
4
4
  import { N as NamespacedRegistry } from './types-Dhd0M369.js';
@@ -930,13 +930,19 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
930
930
  hasMore: boolean;
931
931
  }>;
932
932
  /**
933
- * This thread's OWN request-log cost summary (no descendants), aggregated
934
- * in SQL so subtree cost reporting doesn't page full log rows out of every
935
- * thread in the tree. Used by GET /api/threads/:id/cost, which merges these
936
- * across the thread and all of its subagent descendants.
933
+ * This thread's OWN cost summary (no descendants), aggregated in SQL so
934
+ * subtree cost reporting doesn't page full log rows out of every thread in
935
+ * the tree. Used by GET /api/threads/:id/cost, which merges these across
936
+ * the thread and all of its subagent descendants.
937
+ *
938
+ * `totalCost` is everything the thread cost: LLM request rows (`cost_total`)
939
+ * plus application log rows (`kind = 'app'`, ThreadState.log() `cost`,
940
+ * stored as `app_cost`). `appCost` reports the application share apart;
941
+ * the per-model breakdown, component sums and `requestCount` stay LLM-only.
937
942
  */
938
943
  getCostSummary(): Promise<{
939
944
  totalCost: number;
945
+ appCost: number;
940
946
  inputCost: number;
941
947
  cachedCost: number;
942
948
  outputCost: number;
package/dist/runtime.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { m as AgentBuilderEnv, n as AgentBuilderEvent, A as AgentDefinition, ah as BroadcastOptions, C as CodeExecutionBridge, h as DurableAgentBuilder, D as DurableThread, l as DurableUserHub, af as FlowStateSdk, ai as FlowStateWithSdk, G as HandlerSide, H as HubClientInfo, E as HumanSide, aq as ImageContextConfig, ae as InjectMessageOptions, as as LLMProviderInterface, M as ModelDefinition, aL as NamespaceResolutionError, w as PromptContent, s as PromptDefinition, y as PromptIncludePart, x as PromptPart, F as PromptSide, t as PromptToolConfig, P as Provider, at as ProviderContentPart, aw as ProviderFilePart, av as ProviderImagePart, ar as ProviderRegistry, au as ProviderTextPart, B as SessionToolBinding, z as SessionToolConfig, I as SideConfig, J as SubagentRelationship, u as SubagentToolConfig, S as SubpromptConfig, o as ThreadEventPayload, p as ThreadRegistryEntry, T as ThreadWatchdog, j as ThreadWatchdogState, v as ToolConfig, U as UpdateThreadParams, q as User, k as WatchdogCheckin, W as WatchdogProbeResult, f as applyRuntimeCors, am as buildImageDescription, c as canAccessThread, a9 as cat, aJ as createNamespaceContext, Q as emitThreadEvent, ag as enhanceFlowState, a0 as exists, ad as find, R as forceTurn, ap as generateImageDescription, a7 as getFileStats, N as getMessages, al as getMessagesToSummarize, az as getShortName, a8 as getThumbnail, ak as getUnsummarizedImageAttachments, aG as getVisibleAgentNames, aI as getVisibleModelNames, aH as getVisiblePromptNames, aF as getVisibleToolNames, ac as grep, aj as hasImageAttachments, aa as head, L as injectMessage, d as isAdminOnlyApiRoute, i as isHostedInstance, b as isPublicApiRoute, aK as isQualifiedName, e as isSameOriginBrowserRequest, a as isTrustedLocalDevelopmentRequest, Z as linkFile, a2 as mkdir, a5 as move, ao as optimizeImageContext, ax as parseQualifiedName, ay as qualifyName, K as queueTool, _ as readFile, a3 as readdir, O as reloadHistory, a6 as rename, an as replaceImagesWithDescriptions, aD as resolveAgent, aE as resolveHook, aC as resolveModel, aB as resolvePrompt, aA as resolveTool, a4 as rmdir, r as runtimeCorsHeaders, g as runtimePreflightResponse, $ as stat, ab as tail, a1 as unlink, V as updateThread, X as writeFile, Y as writeImage } from './resolver-D30lNT4L.js';
2
- export { v as Agent, J as AttachmentRef, i as AuthContext, A as AuthUser, e as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, t as ClientDuplex, u as ClientForwarding, p as ClientStreamRequest, q as ClientStreamResponse, n as ClientToolRequest, o as ClientToolResponse, B as Controller, a as ControllerContext, G as Env, H as FileRecord, N as FileStats, D as FlowResult, F as FlowState, K as GrepResult, P as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, U as MessageContent, Q as MultimodalContent, R as RequestContext, S as StorageBackend, E as TelemetryEvent, O as TextContentPart, T as ThreadEndpointContext, b as ThreadEnv, w as ThreadInstance, x as ThreadMetadata, y as ToolCall, z as ToolResult, f as authenticate, j as callClient, k as callClientStream, c as createThreadEndpointHandler, m as decodeStreamChunk, d as defineController, l as encodeStreamChunk, h as endpointCallerFromAuth, g as requireAdmin, r as requireAuth, s as supportsClientForwarding } from './index-BhIiPl8o.js';
1
+ export { m as AgentBuilderEnv, n as AgentBuilderEvent, A as AgentDefinition, ah as BroadcastOptions, C as CodeExecutionBridge, h as DurableAgentBuilder, D as DurableThread, l as DurableUserHub, af as FlowStateSdk, ai as FlowStateWithSdk, G as HandlerSide, H as HubClientInfo, E as HumanSide, aq as ImageContextConfig, ae as InjectMessageOptions, as as LLMProviderInterface, M as ModelDefinition, aL as NamespaceResolutionError, w as PromptContent, s as PromptDefinition, y as PromptIncludePart, x as PromptPart, F as PromptSide, t as PromptToolConfig, P as Provider, at as ProviderContentPart, aw as ProviderFilePart, av as ProviderImagePart, ar as ProviderRegistry, au as ProviderTextPart, B as SessionToolBinding, z as SessionToolConfig, I as SideConfig, J as SubagentRelationship, u as SubagentToolConfig, S as SubpromptConfig, o as ThreadEventPayload, p as ThreadRegistryEntry, T as ThreadWatchdog, j as ThreadWatchdogState, v as ToolConfig, U as UpdateThreadParams, q as User, k as WatchdogCheckin, W as WatchdogProbeResult, f as applyRuntimeCors, am as buildImageDescription, c as canAccessThread, a9 as cat, aJ as createNamespaceContext, Q as emitThreadEvent, ag as enhanceFlowState, a0 as exists, ad as find, R as forceTurn, ap as generateImageDescription, a7 as getFileStats, N as getMessages, al as getMessagesToSummarize, az as getShortName, a8 as getThumbnail, ak as getUnsummarizedImageAttachments, aG as getVisibleAgentNames, aI as getVisibleModelNames, aH as getVisiblePromptNames, aF as getVisibleToolNames, ac as grep, aj as hasImageAttachments, aa as head, L as injectMessage, d as isAdminOnlyApiRoute, i as isHostedInstance, b as isPublicApiRoute, aK as isQualifiedName, e as isSameOriginBrowserRequest, a as isTrustedLocalDevelopmentRequest, Z as linkFile, a2 as mkdir, a5 as move, ao as optimizeImageContext, ax as parseQualifiedName, ay as qualifyName, K as queueTool, _ as readFile, a3 as readdir, O as reloadHistory, a6 as rename, an as replaceImagesWithDescriptions, aD as resolveAgent, aE as resolveHook, aC as resolveModel, aB as resolvePrompt, aA as resolveTool, a4 as rmdir, r as runtimeCorsHeaders, g as runtimePreflightResponse, $ as stat, ab as tail, a1 as unlink, V as updateThread, X as writeFile, Y as writeImage } from './resolver-C6zKX6kw.js';
2
+ export { v as Agent, J as AttachmentRef, i as AuthContext, A as AuthUser, e as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, t as ClientDuplex, u as ClientForwarding, p as ClientStreamRequest, q as ClientStreamResponse, n as ClientToolRequest, o as ClientToolResponse, B as Controller, a as ControllerContext, G as Env, H as FileRecord, N as FileStats, D as FlowResult, F as FlowState, K as GrepResult, P as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, U as MessageContent, Q as MultimodalContent, R as RequestContext, S as StorageBackend, E as TelemetryEvent, O as TextContentPart, T as ThreadEndpointContext, b as ThreadEnv, w as ThreadInstance, x as ThreadMetadata, y as ToolCall, z as ToolResult, f as authenticate, j as callClient, k as callClientStream, c as createThreadEndpointHandler, m as decodeStreamChunk, d as defineController, l as encodeStreamChunk, h as endpointCallerFromAuth, g as requireAdmin, r as requireAuth, s as supportsClientForwarding } from './index-Dn0rBA1H.js';
3
3
  export { AgentType, DefineHandlerOptions, DefinitionLoader, GlobalNamespaceContext, HANDLER_SYMBOL, HandlerDefinition, HookExecutionContext, HookExecutionSource, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, ParentHookRequirement, ParentHookStage, 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, ThreadHookName, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHandler, defineHook, defineModel, definePrompt, defineProvider, defineTool, isHandler, isPacked, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue } from '@standardagents/spec';
4
4
  export { N as NamespacedRegistry } from './types-Dhd0M369.js';
5
5
  import 'cloudflare:workers';
package/dist/runtime.js CHANGED
@@ -3435,6 +3435,153 @@ var init_remoteAttachment = __esm({
3435
3435
  }
3436
3436
  });
3437
3437
 
3438
+ // src/agents/strictToolSchema.ts
3439
+ function isRecord(value) {
3440
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3441
+ }
3442
+ function isObjectSchema(schema) {
3443
+ const type = schema.type;
3444
+ return type === "object" || Array.isArray(type) && type.includes("object") || type === void 0 && isRecord(schema.properties);
3445
+ }
3446
+ function acceptsNull(schema) {
3447
+ if (schema.type === "null") return true;
3448
+ if (Array.isArray(schema.type) && schema.type.includes("null")) return true;
3449
+ return Array.isArray(schema.anyOf) && schema.anyOf.some((v) => isRecord(v) && acceptsNull(v));
3450
+ }
3451
+ function nullableStrictSchema(schema) {
3452
+ if (acceptsNull(schema)) return schema;
3453
+ const { description, title, ...rest } = schema;
3454
+ const variants = Array.isArray(rest.anyOf) && Object.keys(rest).length === 1 ? [...rest.anyOf] : [rest];
3455
+ return {
3456
+ anyOf: [...variants, { type: "null" }],
3457
+ ...description !== void 0 ? { description } : {},
3458
+ ...title !== void 0 ? { title } : {}
3459
+ };
3460
+ }
3461
+ function toStrictSchema(value) {
3462
+ if (!isRecord(value)) return {};
3463
+ if (Array.isArray(value.anyOf)) {
3464
+ const node2 = { anyOf: value.anyOf.map((v) => toStrictSchema(v)) };
3465
+ if (typeof value.description === "string") node2.description = value.description;
3466
+ if (typeof value.title === "string") node2.title = value.title;
3467
+ return node2;
3468
+ }
3469
+ const node = {};
3470
+ for (const [key, child] of Object.entries(value)) {
3471
+ if (!SUPPORTED_KEYWORDS.has(key)) continue;
3472
+ if (key === "properties" || key === "required" || key === "additionalProperties") continue;
3473
+ if (key === "items") node.items = toStrictSchema(child);
3474
+ else if (key === "$defs" && isRecord(child)) {
3475
+ node.$defs = Object.fromEntries(
3476
+ Object.entries(child).map(([name, def]) => [name, toStrictSchema(def)])
3477
+ );
3478
+ } else node[key] = child;
3479
+ }
3480
+ if (isObjectSchema(value)) {
3481
+ const properties = isRecord(value.properties) ? value.properties : {};
3482
+ const required = new Set(
3483
+ Array.isArray(value.required) ? value.required.filter((item) => typeof item === "string") : []
3484
+ );
3485
+ node.type = "object";
3486
+ node.properties = Object.fromEntries(
3487
+ Object.entries(properties).map(([name, child]) => {
3488
+ const strict = toStrictSchema(child);
3489
+ return [name, required.has(name) ? strict : nullableStrictSchema(strict)];
3490
+ })
3491
+ );
3492
+ node.required = Object.keys(properties);
3493
+ node.additionalProperties = false;
3494
+ }
3495
+ return node;
3496
+ }
3497
+ function stripNullArguments(value) {
3498
+ if (Array.isArray(value)) {
3499
+ return value.map((item) => isRecord(item) ? stripNullArguments(item) : item);
3500
+ }
3501
+ if (!isRecord(value)) return value;
3502
+ const out = {};
3503
+ for (const [key, child] of Object.entries(value)) {
3504
+ if (child === null) continue;
3505
+ out[key] = stripNullArguments(child);
3506
+ }
3507
+ return out;
3508
+ }
3509
+ function buildSubagentArgumentsSchema(sources) {
3510
+ const merged = /* @__PURE__ */ new Map();
3511
+ for (const source of sources) {
3512
+ const schema = isRecord(source.argumentSchema) ? source.argumentSchema : {};
3513
+ const properties2 = isRecord(schema.properties) ? schema.properties : {};
3514
+ const required = new Set(
3515
+ Array.isArray(schema.required) ? schema.required.filter((item) => typeof item === "string") : []
3516
+ );
3517
+ for (const [prop, child] of Object.entries(properties2)) {
3518
+ const entry = merged.get(prop) ?? {
3519
+ variants: /* @__PURE__ */ new Map(),
3520
+ declaredBy: [],
3521
+ requiredBy: []
3522
+ };
3523
+ const strict = toStrictSchema(child);
3524
+ entry.variants.set(JSON.stringify(strict), strict);
3525
+ entry.declaredBy.push(source.name);
3526
+ if (required.has(prop)) entry.requiredBy.push(source.name);
3527
+ merged.set(prop, entry);
3528
+ }
3529
+ }
3530
+ const multiple = sources.length > 1;
3531
+ const properties = {};
3532
+ for (const [prop, entry] of merged) {
3533
+ const variants = [...entry.variants.values()];
3534
+ let schema = variants.length === 1 ? variants[0] : { anyOf: variants };
3535
+ if (multiple) {
3536
+ const usage = [`Used by: ${entry.declaredBy.join(", ")}.`];
3537
+ usage.push(
3538
+ entry.requiredBy.length === sources.length ? "Required." : entry.requiredBy.length > 0 ? `Required for: ${entry.requiredBy.join(", ")}; pass null for other agents.` : "Optional; pass null to omit."
3539
+ );
3540
+ const own = typeof schema.description === "string" ? `${schema.description} ` : "";
3541
+ schema = { ...schema, description: `${own}${usage.join(" ")}` };
3542
+ }
3543
+ const alwaysRequired = entry.variants.size === 1 && sources.every((source) => entry.requiredBy.includes(source.name));
3544
+ properties[prop] = alwaysRequired ? schema : nullableStrictSchema(schema);
3545
+ }
3546
+ return {
3547
+ type: "object",
3548
+ description: multiple ? "Initial arguments for the selected agent; they persist for the child thread lifetime. Fill the properties the selected agent uses and pass null for the rest." : `Initial arguments for ${sources[0]?.name ?? "the subagent"}; they persist for the child thread lifetime.`,
3549
+ properties,
3550
+ required: Object.keys(properties),
3551
+ additionalProperties: false
3552
+ };
3553
+ }
3554
+ var SUPPORTED_KEYWORDS;
3555
+ var init_strictToolSchema = __esm({
3556
+ "src/agents/strictToolSchema.ts"() {
3557
+ SUPPORTED_KEYWORDS = /* @__PURE__ */ new Set([
3558
+ "type",
3559
+ "properties",
3560
+ "required",
3561
+ "additionalProperties",
3562
+ "items",
3563
+ "enum",
3564
+ "const",
3565
+ "anyOf",
3566
+ "description",
3567
+ "title",
3568
+ "pattern",
3569
+ "format",
3570
+ "minLength",
3571
+ "maxLength",
3572
+ "minimum",
3573
+ "maximum",
3574
+ "exclusiveMinimum",
3575
+ "exclusiveMaximum",
3576
+ "multipleOf",
3577
+ "minItems",
3578
+ "maxItems",
3579
+ "$ref",
3580
+ "$defs"
3581
+ ]);
3582
+ }
3583
+ });
3584
+
3438
3585
  // src/durable-objects/files.ts
3439
3586
  var files_exports = {};
3440
3587
  __export(files_exports, {
@@ -4173,6 +4320,7 @@ var init_ToolExecutor = __esm({
4173
4320
  init_ThreadStateImpl();
4174
4321
  init_sessionTools();
4175
4322
  init_remoteAttachment();
4323
+ init_strictToolSchema();
4176
4324
  SUBAGENT_CREATE_TOOL = "subagent_create";
4177
4325
  SUBAGENT_MESSAGE_TOOL = "subagent_message";
4178
4326
  SUBAGENTS_LIST_TOOL = "subagents";
@@ -5093,16 +5241,26 @@ Message one with subagent_message(referenceId, message).`
5093
5241
  args,
5094
5242
  initAttachmentsProperty
5095
5243
  );
5096
- const initialArguments = builtinSubagentAction === "create" ? builtinCreateInitialArguments : args;
5097
- const argumentValidationError = await this.validateSubagentArguments(
5244
+ const validationOptions = { agentName, packageId };
5245
+ let initialArguments = builtinSubagentAction === "create" ? stripNullArguments(builtinCreateInitialArguments) : args;
5246
+ let argumentValidationError = await this.validateSubagentArguments(
5098
5247
  state,
5099
5248
  agentDef,
5100
5249
  initialArguments,
5101
- {
5102
- agentName,
5103
- packageId
5104
- }
5250
+ validationOptions
5105
5251
  );
5252
+ if (argumentValidationError && builtinSubagentAction === "create") {
5253
+ const rawError = await this.validateSubagentArguments(
5254
+ state,
5255
+ agentDef,
5256
+ builtinCreateInitialArguments,
5257
+ validationOptions
5258
+ );
5259
+ if (!rawError) {
5260
+ argumentValidationError = null;
5261
+ initialArguments = builtinCreateInitialArguments;
5262
+ }
5263
+ }
5106
5264
  if (argumentValidationError) {
5107
5265
  return argumentValidationError;
5108
5266
  }
@@ -5412,7 +5570,7 @@ Message one with subagent_message(referenceId, message).`
5412
5570
  error: `${SUBAGENT_CREATE_TOOL} requires agent.`
5413
5571
  };
5414
5572
  }
5415
- if (rawArguments !== void 0 && (typeof rawArguments !== "object" || rawArguments === null || Array.isArray(rawArguments))) {
5573
+ if (rawArguments !== void 0 && rawArguments !== null && (typeof rawArguments !== "object" || rawArguments === null || Array.isArray(rawArguments))) {
5416
5574
  return {
5417
5575
  agent,
5418
5576
  message,
@@ -19658,10 +19816,15 @@ ${resultContent}${attachmentSummary}`;
19658
19816
  }
19659
19817
  }
19660
19818
  /**
19661
- * This thread's OWN request-log cost summary (no descendants), aggregated
19662
- * in SQL so subtree cost reporting doesn't page full log rows out of every
19663
- * thread in the tree. Used by GET /api/threads/:id/cost, which merges these
19664
- * across the thread and all of its subagent descendants.
19819
+ * This thread's OWN cost summary (no descendants), aggregated in SQL so
19820
+ * subtree cost reporting doesn't page full log rows out of every thread in
19821
+ * the tree. Used by GET /api/threads/:id/cost, which merges these across
19822
+ * the thread and all of its subagent descendants.
19823
+ *
19824
+ * `totalCost` is everything the thread cost: LLM request rows (`cost_total`)
19825
+ * plus application log rows (`kind = 'app'`, ThreadState.log() `cost`,
19826
+ * stored as `app_cost`). `appCost` reports the application share apart;
19827
+ * the per-model breakdown, component sums and `requestCount` stay LLM-only.
19665
19828
  */
19666
19829
  async getCostSummary() {
19667
19830
  await this.ensureMigrated();
@@ -19682,7 +19845,7 @@ ${resultContent}${attachmentSummary}`;
19682
19845
  SUM(cost_router_fee) AS router_fee_cost,
19683
19846
  COUNT(*) AS request_count
19684
19847
  FROM logs
19685
- WHERE cost_total IS NOT NULL
19848
+ WHERE cost_total IS NOT NULL AND (kind IS NULL OR kind != '${APP_LOG_KIND}')
19686
19849
  GROUP BY model_key
19687
19850
  `
19688
19851
  );
@@ -19702,12 +19865,21 @@ ${resultContent}${attachmentSummary}`;
19702
19865
  routerFeeCost += row.router_fee_cost ?? 0;
19703
19866
  requestCount += row.request_count;
19704
19867
  }
19868
+ const appRow = await this.ctx.storage.sql.exec(
19869
+ `SELECT SUM(app_cost) AS app_cost FROM logs WHERE kind = ? AND app_cost IS NOT NULL`,
19870
+ APP_LOG_KIND
19871
+ );
19872
+ const appCost = appRow.one().app_cost ?? 0;
19873
+ totalCost += appCost;
19705
19874
  const messageRow = await this.ctx.storage.sql.exec(
19706
- `SELECT COUNT(DISTINCT message_id) AS message_count FROM logs WHERE cost_total IS NOT NULL`
19875
+ `SELECT COUNT(DISTINCT message_id) AS message_count FROM logs
19876
+ WHERE cost_total IS NOT NULL OR (kind = ? AND app_cost IS NOT NULL)`,
19877
+ APP_LOG_KIND
19707
19878
  );
19708
19879
  const messageCount = messageRow.one().message_count || 0;
19709
19880
  return {
19710
19881
  totalCost,
19882
+ appCost,
19711
19883
  inputCost,
19712
19884
  cachedCost,
19713
19885
  outputCost,
@@ -23465,6 +23637,7 @@ var init_FlowEngine = __esm({
23465
23637
  init_sessionTools();
23466
23638
  init_ThreadStateImpl();
23467
23639
  init_ParentHookResolver();
23640
+ init_strictToolSchema();
23468
23641
  IMMEDIATE_BOOTSTRAP_TOOL_NAME = "bootstrap_immediate_subagent";
23469
23642
  HookBlockedExecutionError = class extends Error {
23470
23643
  constructor(message) {
@@ -26237,22 +26410,6 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
26237
26410
  }
26238
26411
  return parts.length > 0 ? parts.join("; ") : "no extra initial arguments";
26239
26412
  }
26240
- static buildSubagentArgumentsSchema(sideSubagentDescriptors) {
26241
- const variants = sideSubagentDescriptors.map((entry) => ({
26242
- ...this.normalizeSubagentArgumentSchema(entry.argumentSchema),
26243
- title: `${entry.name} initial arguments`,
26244
- description: `Initial arguments for ${entry.name}. These values persist for the child thread lifetime.`
26245
- }));
26246
- if (variants.length === 1) {
26247
- return variants[0];
26248
- }
26249
- return {
26250
- type: "object",
26251
- description: "Agent-specific initial arguments for the selected subagent. Use the schema matching the selected agent.",
26252
- additionalProperties: false,
26253
- anyOf: variants
26254
- };
26255
- }
26256
26413
  static buildSubagentCreateTool(sideSubagentDescriptors) {
26257
26414
  const agentNames = sideSubagentDescriptors.map((entry) => entry.name);
26258
26415
  const descriptionLines = sideSubagentDescriptors.map((entry) => {
@@ -26269,7 +26426,7 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
26269
26426
  "Create and run a configured subagent. Every instance is a persistent, addressable thread.",
26270
26427
  "Available subagents:",
26271
26428
  ...descriptionLines,
26272
- "Provide any required invocation arguments via `arguments`; they persist for the life of the subagent thread.",
26429
+ "Provide the selected agent's invocation arguments via `arguments` (null for properties it does not use); they persist for the life of the subagent thread.",
26273
26430
  "Before creating a new instance, call `subagents` to check the status of instances you already have \u2014 an existing one may already cover the work, and instance caps count live children.",
26274
26431
  "Use subagent_message for follow-up communication with existing instances."
26275
26432
  ].join("\n"),
@@ -26296,10 +26453,14 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
26296
26453
  type: "string",
26297
26454
  description: "Required human-readable instance name for the spawned subagent thread. Use a concise stable label that identifies this child instance."
26298
26455
  },
26299
- arguments: this.buildSubagentArgumentsSchema(sideSubagentDescriptors)
26456
+ // One strict object (union of every relationship's arguments,
26457
+ // optional ones nullable) — see strictToolSchema.ts for the
26458
+ // provider rules this satisfies. Required like every property
26459
+ // under strict mode; the model passes {} when there are none.
26460
+ arguments: buildSubagentArgumentsSchema(sideSubagentDescriptors)
26300
26461
  },
26301
26462
  additionalProperties: false,
26302
- required: ["agent", "message", "attachments", "name"]
26463
+ required: ["agent", "message", "attachments", "name", "arguments"]
26303
26464
  }
26304
26465
  }
26305
26466
  };
@@ -26323,8 +26484,8 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
26323
26484
  sanitized[key] = this.sanitizeToolJsonSchema(child);
26324
26485
  }
26325
26486
  const type = sanitized.type;
26326
- const isObjectSchema = type === "object" || Array.isArray(type) && type.includes("object");
26327
- if (isObjectSchema) {
26487
+ const isObjectSchema2 = type === "object" || Array.isArray(type) && type.includes("object");
26488
+ if (isObjectSchema2) {
26328
26489
  sanitized.additionalProperties = false;
26329
26490
  }
26330
26491
  return sanitized;