@standardagents/builder 0.12.9 → 0.13.0-next.c55f029

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/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { AgentPluginOptions, agentbuilder } from './plugin.js';
2
- import { T as ThreadEnv, a as ThreadMetadata, F as FileRecord, b as FlowState, M as Message, c as FileStats, G as GrepResult, A as AttachmentRef, d as MessageContent } from './index-DkbUJ4MM.js';
3
- export { j as Agent, i as BuilderThreadEndpointHandler, B as Controller, g as ControllerContext, E as Env, n as FlowResult, q as ImageContentPart, I as ImageMetadata, L as LLMResponse, r as MultimodalContent, R as RequestContext, S as StorageBackend, o as TelemetryEvent, p as TextContentPart, h as ThreadEndpointContext, k as ThreadInstance, l as ToolCall, m as ToolResult, f as createThreadEndpointHandler, e as defineController } from './index-DkbUJ4MM.js';
4
- import { ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, SubpromptConfig as SubpromptConfig$1, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
2
+ import { T as ThreadEnv, a as ThreadMetadata, F as FileRecord, b as FlowState, M as Message, c as FileStats, G as GrepResult, A as AttachmentRef, d as MessageContent, E as Env, e as ThreadInstance } from './index-T0gR5l-G.js';
3
+ export { k as Agent, j as BuilderThreadEndpointHandler, B as Controller, h as ControllerContext, n as FlowResult, q as ImageContentPart, I as ImageMetadata, L as LLMResponse, r as MultimodalContent, R as RequestContext, S as StorageBackend, o as TelemetryEvent, p as TextContentPart, i as ThreadEndpointContext, l as ToolCall, m as ToolResult, g as createThreadEndpointHandler, f as defineController } from './index-T0gR5l-G.js';
4
+ import { SubagentRegistryEntry, QueueMessageInput, 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';
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
  import { DurableObject } from 'cloudflare:workers';
7
- import { N as NamespacedRegistry } from './types-pLkJx8vg.js';
8
- export { C as ConstituentItem, D as DiscoveredPackage, P as PackingAnalysis, a as PackingOptions, b as PackingResult, U as UnpackOptions, c as UnpackResult } from './types-pLkJx8vg.js';
9
- export { D as DiscoveryConfig, P as PackageDiscoveryService, d as discoverPackages } from './discovery-CpMs68Yx.js';
7
+ import { N as NamespacedRegistry } from './types-DH3Egc5l.js';
8
+ export { C as ConstituentItem, D as DiscoveredPackage, P as PackingAnalysis, a as PackingOptions, b as PackingResult, U as UnpackOptions, c as UnpackResult } from './types-DH3Egc5l.js';
9
+ export { D as DiscoveryConfig, P as PackageDiscoveryService, d as discoverPackages } from './discovery-DVviz3By.js';
10
10
  import 'vite';
11
11
  import '@cloudflare/workers-types';
12
12
  import 'zod';
@@ -268,6 +268,33 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
268
268
  * @param agentName - Name of the agent to run
269
269
  */
270
270
  runAgent(threadId: string, agentName: string): Promise<void>;
271
+ /**
272
+ * Get the persisted resumable-subagent registry for this thread.
273
+ */
274
+ getChildrenRegistry(_threadId: string): Promise<SubagentRegistryEntry[]>;
275
+ private setChildrenRegistry;
276
+ upsertChildRegistry(_threadId: string, entry: SubagentRegistryEntry): Promise<void>;
277
+ updateChildRegistryStatus(_threadId: string, reference: string, status: string): Promise<void>;
278
+ removeChildRegistry(_threadId: string, reference: string): Promise<void>;
279
+ private asOptionalString;
280
+ private asOptionalBoolean;
281
+ private getThreadNameFromTags;
282
+ private toSubagentProjection;
283
+ private resolveSubagentMessageProjections;
284
+ /**
285
+ * Queue a message for deferred delivery.
286
+ */
287
+ queueMessage(threadId: string, message: QueueMessageInput): Promise<void>;
288
+ private hasPendingTurnAlarm;
289
+ private ensureQueuedMessageExecution;
290
+ private ensureRootMessageId;
291
+ /**
292
+ * Soft-terminate this thread.
293
+ */
294
+ terminateThread(threadId: string): Promise<{
295
+ success: boolean;
296
+ terminated: number;
297
+ }>;
271
298
  /**
272
299
  * Schedule an effect for future execution.
273
300
  *
@@ -278,6 +305,10 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
278
305
  * @returns UUID of the scheduled effect
279
306
  */
280
307
  scheduleEffect(threadId: string, effectName: string, effectArgs: Record<string, unknown>, delayMs?: number): Promise<string>;
308
+ /**
309
+ * Check whether an effect loader exists in either global or packed registries.
310
+ */
311
+ private effectExists;
281
312
  /**
282
313
  * Get scheduled effects for this thread.
283
314
  *
@@ -328,6 +359,16 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
328
359
  * Enqueues the execution to be processed by the alarm handler
329
360
  */
330
361
  execute(threadId: string, agentId: string, initial_messages?: any[], data?: any): Promise<Response>;
362
+ /**
363
+ * Execute a flow synchronously and return the final top-level message content.
364
+ * Used by blocking subagent tool calls.
365
+ */
366
+ executeBlocking(threadId: string, agentId: string, initial_messages?: any[], data?: any): Promise<{
367
+ status: "success" | "error";
368
+ result?: string;
369
+ error?: string;
370
+ attachments?: unknown[];
371
+ }>;
331
372
  /**
332
373
  * Send a new message to the thread (RPC method)
333
374
  * Enqueues the message processing to be handled by the alarm handler
@@ -338,6 +379,28 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
338
379
  * Reads from SQLite for persistence across hibernation
339
380
  */
340
381
  shouldStop(): Promise<boolean>;
382
+ /**
383
+ * Returns the termination timestamp (microseconds) or null when active.
384
+ */
385
+ getTerminated(_threadId: string): Promise<number | null>;
386
+ private assertNotTerminated;
387
+ private getLatestTopLevelMessage;
388
+ private getTerminalSessionToolNames;
389
+ private parseAttachmentRefsJson;
390
+ private inferMimeTypeFromPath;
391
+ private extensionForMimeType;
392
+ private sanitizeFilename;
393
+ private splitFilename;
394
+ private resolveAttachmentMimeType;
395
+ private buildAttachmentTargetPath;
396
+ private copyAttachmentRefsToThread;
397
+ private readAttachmentDataFromSource;
398
+ private arrayBufferToBase64;
399
+ private formatSubagentAttachmentPathSummary;
400
+ private persistParentHandoffStatusMessage;
401
+ private buildMissingTerminalSessionFailure;
402
+ private deliverCompletionToParentIfNeeded;
403
+ private getParentCommunicationModeForChild;
341
404
  /**
342
405
  * Stop the currently executing thread (RPC method)
343
406
  * Simple "off" switch - stops turns, only cleared by user messages
@@ -389,6 +452,8 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
389
452
  reasoning_content: string | null;
390
453
  reasoning_details: string | null;
391
454
  attachments: any;
455
+ metadata: Record<string, unknown> | undefined;
456
+ subagent_id: string | null;
392
457
  }[];
393
458
  total: number;
394
459
  hasMore: boolean;
@@ -538,6 +603,8 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
538
603
  agent_id: any;
539
604
  user_id: any;
540
605
  tags: any;
606
+ parent: any;
607
+ terminated: any;
541
608
  created_at: any;
542
609
  };
543
610
  agent: {
@@ -562,6 +629,8 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
562
629
  agent_name?: string;
563
630
  user_id?: string | null;
564
631
  tags?: string[] | null;
632
+ env?: Record<string, string> | null;
633
+ tenvs?: Record<string, unknown> | null;
565
634
  }): Promise<{
566
635
  success: boolean;
567
636
  thread: {
@@ -604,6 +673,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
604
673
  * Filters silent messages based on each socket's includeSilent preference
605
674
  */
606
675
  private broadcastMessage;
676
+ private broadcastMessageWithSubagentProjection;
607
677
  /**
608
678
  * Broadcast a content chunk for real-time streaming
609
679
  * Does NOT update database - only broadcasts to connected clients
@@ -663,6 +733,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
663
733
  * This allows resuming FlowEngine execution from where it stopped.
664
734
  */
665
735
  private doContinueExecution;
736
+ private getLatestQueuedMessageSide;
666
737
  /**
667
738
  * TEST METHOD: Queue a test operation
668
739
  * Used for testing alarm queue ordering and timing
@@ -984,8 +1055,42 @@ interface ThreadRegistryEntry {
984
1055
  agent_name: string;
985
1056
  user_id: string | null;
986
1057
  tags: string[] | null;
1058
+ env: Record<string, string> | null;
1059
+ /** @deprecated Use env */
987
1060
  tenvs: Record<string, unknown> | null;
988
1061
  properties: Record<string, unknown> | null;
1062
+ parent: string | null;
1063
+ terminated: number | null;
1064
+ created_at: number;
1065
+ }
1066
+ interface PendingSubagentAttachmentRef {
1067
+ path: string;
1068
+ name?: string;
1069
+ mimeType?: string;
1070
+ size?: number;
1071
+ width?: number;
1072
+ height?: number;
1073
+ }
1074
+ interface PendingSubagentEnvRequestPayload {
1075
+ blocking: boolean;
1076
+ resumable: boolean;
1077
+ receives_messages: 'side_a' | 'side_b';
1078
+ parent_communication: 'implicit' | 'explicit';
1079
+ initial_message_content: string;
1080
+ initial_message_attachments: PendingSubagentAttachmentRef[];
1081
+ initial_agent_name?: string | null;
1082
+ agent_title?: string | null;
1083
+ agent_description?: string | null;
1084
+ spawn_group_id?: string | null;
1085
+ }
1086
+ interface PendingSubagentEnvRequest {
1087
+ request_id: string;
1088
+ parent_thread_id: string;
1089
+ agent_name: string;
1090
+ registry_agent_name: string;
1091
+ required: string[];
1092
+ missing: string[];
1093
+ payload: PendingSubagentEnvRequestPayload;
989
1094
  created_at: number;
990
1095
  }
991
1096
  /**
@@ -995,6 +1100,11 @@ interface UpdateThreadParams {
995
1100
  agent_name?: string;
996
1101
  user_id?: string | null;
997
1102
  tags?: string[] | null;
1103
+ env?: Record<string, string> | null;
1104
+ /** @deprecated Use env */
1105
+ tenvs?: Record<string, unknown> | null;
1106
+ parent?: string | null;
1107
+ terminated?: number | null;
998
1108
  }
999
1109
  /**
1000
1110
  * User record.
@@ -1019,6 +1129,27 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
1019
1129
  private migratedToVersion;
1020
1130
  private eventSockets;
1021
1131
  constructor(ctx: DurableObjectState, env: Env);
1132
+ private normalizeEnvRecord;
1133
+ private resolveRegistryKey;
1134
+ private extractScopedVariables;
1135
+ private filterScopedInheritedEnv;
1136
+ private collectScopedVariablesForAgent;
1137
+ private getScopedVariableNamesForAgent;
1138
+ private getRequiredScopedVariableNamesForAgent;
1139
+ private normalizeScopedVariableList;
1140
+ private normalizePendingAttachments;
1141
+ private sanitizeFilename;
1142
+ private inferMimeTypeFromPath;
1143
+ private extensionForMimeType;
1144
+ private buildAttachmentTargetPath;
1145
+ private formatSubagentAttachmentPathSummary;
1146
+ private formatSubagentTerminalMessage;
1147
+ private copyPendingAttachmentsBetweenThreads;
1148
+ private buildThreadNameTag;
1149
+ private encryptEnvRecord;
1150
+ private decryptEnvRecord;
1151
+ private listActiveDescendantThreadIds;
1152
+ private propagateThreadEnvToDescendants;
1022
1153
  /**
1023
1154
  * Returns the tools registry for lazy-loading tool definitions.
1024
1155
  * Must be overridden in a subclass.
@@ -1059,8 +1190,11 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
1059
1190
  agent_name: string;
1060
1191
  user_id?: string;
1061
1192
  tags?: string[];
1193
+ env?: Record<string, string>;
1194
+ /** @deprecated Use env */
1062
1195
  tenvs?: Record<string, unknown>;
1063
1196
  properties?: Record<string, unknown>;
1197
+ parent?: string;
1064
1198
  }): Promise<ThreadRegistryEntry>;
1065
1199
  /**
1066
1200
  * Get a thread by ID.
@@ -1087,6 +1221,13 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
1087
1221
  * Delete a thread from the registry.
1088
1222
  */
1089
1223
  deleteThread(id: string): Promise<boolean>;
1224
+ /**
1225
+ * Get a thread tree (root + all descendants) in child-first order.
1226
+ *
1227
+ * Child-first ordering allows callers to perform destructive operations
1228
+ * (like deletes) without leaving child rows referencing a deleted parent.
1229
+ */
1230
+ getThreadTreeIds(rootThreadId: string): Promise<string[]>;
1090
1231
  /**
1091
1232
  * Update a thread's agent_name (used during agent handoff).
1092
1233
  */
@@ -1095,6 +1236,45 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
1095
1236
  * Update a thread's metadata.
1096
1237
  */
1097
1238
  updateThread(id: string, params: UpdateThreadParams): Promise<ThreadRegistryEntry | null>;
1239
+ private getEncryptionKey;
1240
+ private encryptEnvValue;
1241
+ private decryptEnvValue;
1242
+ private listScopedEnv;
1243
+ private replaceScopedEnv;
1244
+ getInstanceEnv(): Promise<Record<string, string>>;
1245
+ setInstanceEnv(env: Record<string, string>): Promise<void>;
1246
+ getUserEnv(userId: string): Promise<Record<string, string>>;
1247
+ setUserEnv(userId: string, env: Record<string, string>): Promise<void>;
1248
+ getMissingRequiredScopedSubagentEnv(params: {
1249
+ parent_thread_id: string;
1250
+ agent_name: string;
1251
+ provided_env?: Record<string, string> | null;
1252
+ }): Promise<string[]>;
1253
+ createPendingSubagentEnvRequest(params: {
1254
+ parent_thread_id: string;
1255
+ agent_name: string;
1256
+ registry_agent_name: string;
1257
+ required_variables: string[];
1258
+ missing_variables: string[];
1259
+ payload: PendingSubagentEnvRequestPayload;
1260
+ }): Promise<PendingSubagentEnvRequest>;
1261
+ getPendingSubagentEnvRequest(parentThreadId: string, requestId: string): Promise<PendingSubagentEnvRequest | null>;
1262
+ private clearPendingSubagentEnvRequest;
1263
+ completePendingSubagentEnvRequest(params: {
1264
+ parent_thread_id: string;
1265
+ request_id: string;
1266
+ env: Record<string, string>;
1267
+ }): Promise<{
1268
+ request_id: string;
1269
+ child_thread_id: string;
1270
+ status: 'success';
1271
+ }>;
1272
+ resolveThreadEnv(params: {
1273
+ threadId: string;
1274
+ property: string;
1275
+ promptName?: string;
1276
+ }): Promise<string | null>;
1277
+ private toThreadEventPayload;
1098
1278
  /**
1099
1279
  * Load a model definition by name.
1100
1280
  */
@@ -1356,7 +1536,7 @@ interface PromptIncludePart {
1356
1536
  /**
1357
1537
  * A single part of a structured prompt.
1358
1538
  */
1359
- type PromptPart = PromptTextPart | PromptIncludePart;
1539
+ type PromptPart = PromptTextPart | PromptIncludePart | PromptEnvPart;
1360
1540
  /**
1361
1541
  * Prompt content can be a string or structured array with type-safe includes.
1362
1542
  */
@@ -1368,6 +1548,24 @@ interface SubpromptConfig<T extends string = AgentBuilder.Callables> extends Omi
1368
1548
  /** Name of the sub-prompt (type-safe with autocomplete) */
1369
1549
  name: T;
1370
1550
  }
1551
+ /**
1552
+ * Prompt tool configuration with static tenvs/options.
1553
+ */
1554
+ interface PromptToolConfig<T extends string = AgentBuilder.Callables> extends Omit<PromptToolConfig$1, 'name'> {
1555
+ /** Name of the callable tool/agent (type-safe with autocomplete). */
1556
+ name: T;
1557
+ /** Environment values scoped to this tool invocation. */
1558
+ env?: Record<string, string>;
1559
+ /** @deprecated Use env */
1560
+ tenvs?: Record<string, unknown>;
1561
+ }
1562
+ /**
1563
+ * Subagent tool configuration with type-safe name references.
1564
+ */
1565
+ interface SubagentToolConfig<T extends string = AgentBuilder.Callables> extends Omit<SubagentToolConfig$1<T>, 'name'> {
1566
+ /** Name of the callable dual_ai agent (type-safe with autocomplete). */
1567
+ name: T;
1568
+ }
1371
1569
  /**
1372
1570
  * @deprecated Use SubpromptConfig instead
1373
1571
  */
@@ -1405,8 +1603,14 @@ interface PromptDefinition<N extends string = string, S extends ToolArgs = ToolA
1405
1603
  toolChoice?: 'auto' | 'none' | 'required';
1406
1604
  /** Zod schema for validating inputs when called as a tool. */
1407
1605
  requiredSchema?: S;
1606
+ /** Variable declarations for this prompt. */
1607
+ variables?: VariableDefinition[];
1408
1608
  /** Tools available to this prompt (type-safe with autocomplete). To enable handoffs, include ai_human agent names. */
1409
- tools?: (AgentBuilder.Callables | SubpromptConfig)[];
1609
+ tools?: (AgentBuilder.Callables | SubpromptConfig | PromptToolConfig | SubagentToolConfig)[];
1610
+ /** Prompt-level environment values. */
1611
+ env?: Record<string, string>;
1612
+ /** @deprecated Use env */
1613
+ tenvs?: Record<string, unknown>;
1410
1614
  /** Reasoning configuration for extended thinking models. */
1411
1615
  reasoning?: ReasoningConfig;
1412
1616
  /** Number of recent messages to keep actual images for. @default 10 */
@@ -1428,7 +1632,25 @@ interface PromptDefinition<N extends string = string, S extends ToolArgs = ToolA
1428
1632
  * Side configuration with type-safe autocomplete.
1429
1633
  * Uses AgentBuilder.Prompts and AgentBuilder.Callables for type-safe references.
1430
1634
  */
1431
- interface SideConfig extends Omit<SideConfig$1, 'prompt' | 'stopTool' | 'endSessionTool'> {
1635
+ interface SessionToolConfig {
1636
+ /**
1637
+ * Tool name for this lifecycle binding.
1638
+ */
1639
+ name: AgentBuilder.Callables;
1640
+ /**
1641
+ * Optional tool-argument property used as message text.
1642
+ */
1643
+ messageProperty?: string;
1644
+ /**
1645
+ * Optional tool-argument property containing attachment path(s).
1646
+ */
1647
+ attachmentsProperty?: string;
1648
+ }
1649
+ /**
1650
+ * Session lifecycle binding (string shorthand or explicit object form).
1651
+ */
1652
+ type SessionToolBinding = AgentBuilder.Callables | SessionToolConfig;
1653
+ interface SideConfig extends Omit<SideConfig$1, 'prompt' | 'stopTool' | 'sessionStop' | 'sessionFail' | 'sessionStatus' | 'endSessionTool' | 'statusTool' | 'failSessionTool'> {
1432
1654
  /**
1433
1655
  * The prompt to use for this side (type-safe with autocomplete).
1434
1656
  * Must reference a prompt defined in agents/prompts/.
@@ -1441,11 +1663,32 @@ interface SideConfig extends Omit<SideConfig$1, 'prompt' | 'stopTool' | 'endSess
1441
1663
  */
1442
1664
  stopTool?: AgentBuilder.Callables;
1443
1665
  /**
1444
- * Tool that ends the entire session when called (type-safe with autocomplete).
1445
- * Different from stopTool - this ends the session for both sides,
1446
- * not just this side's turn.
1666
+ * Tool that ends the entire session when called.
1667
+ * Supports shorthand string or explicit message/attachment mapping object.
1668
+ */
1669
+ sessionStop?: SessionToolBinding;
1670
+ /**
1671
+ * Tool that fails the entire session when called.
1672
+ * Supports shorthand string or explicit message/attachment mapping object.
1673
+ */
1674
+ sessionFail?: SessionToolBinding;
1675
+ /**
1676
+ * Tool that publishes status updates to the parent thread when used as a subagent.
1677
+ * Supports shorthand string or explicit message/attachment mapping object.
1678
+ */
1679
+ sessionStatus?: SessionToolBinding;
1680
+ /**
1681
+ * @deprecated Use sessionStop instead.
1447
1682
  */
1448
1683
  endSessionTool?: AgentBuilder.Callables;
1684
+ /**
1685
+ * @deprecated Use sessionFail instead.
1686
+ */
1687
+ failSessionTool?: AgentBuilder.Callables;
1688
+ /**
1689
+ * @deprecated Use sessionStatus instead.
1690
+ */
1691
+ statusTool?: AgentBuilder.Callables;
1449
1692
  /**
1450
1693
  * Enable manual stop condition handling via hooks.
1451
1694
  * Builder-specific feature for custom stop logic.
@@ -1509,9 +1752,11 @@ interface AgentDefinition<N extends string = string> {
1509
1752
  /** Description shown when agent is used as a tool. */
1510
1753
  toolDescription?: string;
1511
1754
  /**
1512
- * Thread environment variables for this agent.
1513
- * Merged into thread tenvs at creation time.
1514
- * Later values (thread) override earlier ones (prompt -> agent).
1755
+ * Environment values provided by this agent.
1756
+ */
1757
+ env?: Record<string, string>;
1758
+ /**
1759
+ * @deprecated Use env
1515
1760
  */
1516
1761
  tenvs?: Record<string, unknown>;
1517
1762
  /** Brief description of what this agent does. */
@@ -1595,6 +1840,21 @@ interface ToolConfigInput {
1595
1840
  include_errors?: boolean;
1596
1841
  init_user_message_property?: string | null;
1597
1842
  init_attachments_property?: string | null;
1843
+ init_agent_name_property?: string | null;
1844
+ blocking?: boolean;
1845
+ optional?: string | null;
1846
+ immediate?: boolean | {
1847
+ name_env?: string | null;
1848
+ description_env?: string | null;
1849
+ scoped_env?: string[];
1850
+ };
1851
+ resumable?: false | {
1852
+ receives_messages: 'side_a' | 'side_b';
1853
+ max_instances?: number | null;
1854
+ parent_communication?: 'implicit' | 'explicit' | null;
1855
+ };
1856
+ env?: Record<string, string>;
1857
+ /** @deprecated Use env */
1598
1858
  tenvs?: Record<string, unknown>;
1599
1859
  }
1600
1860
  /**
@@ -1602,14 +1862,21 @@ interface ToolConfigInput {
1602
1862
  * Supports both new format (type: 'text'/'include') and legacy format (type: 'string'/'prompt')
1603
1863
  */
1604
1864
  interface PromptPartInput {
1605
- type: 'text' | 'include' | 'string' | 'prompt' | 'variable';
1865
+ type: 'text' | 'include' | 'env' | 'string' | 'prompt' | 'variable';
1606
1866
  content?: string;
1607
1867
  prompt?: string;
1868
+ property?: string;
1608
1869
  value?: string;
1609
1870
  id?: string;
1610
1871
  label?: string;
1611
1872
  schema?: any;
1612
1873
  }
1874
+ interface VariableDeclarationInput {
1875
+ name: string;
1876
+ type: 'text' | 'secret';
1877
+ required: boolean;
1878
+ description: string;
1879
+ }
1613
1880
  /**
1614
1881
  * Input data for generating a prompt file.
1615
1882
  * This can include JSON Schema for requiredSchema which will be converted to Zod.
@@ -1630,6 +1897,10 @@ interface PromptFileData {
1630
1897
  parallelToolCalls?: boolean;
1631
1898
  toolChoice?: 'auto' | 'none' | 'required';
1632
1899
  tools?: (string | ToolConfigInput)[];
1900
+ variables?: VariableDeclarationInput[];
1901
+ env?: Record<string, string>;
1902
+ /** @deprecated Use env */
1903
+ tenvs?: Record<string, unknown>;
1633
1904
  reasoning?: {
1634
1905
  effort?: 'low' | 'medium' | 'high';
1635
1906
  maxTokens?: number;
@@ -2733,6 +3004,56 @@ type ProviderImagePart = ImagePart;
2733
3004
  /** @public Alias for FilePart */
2734
3005
  type ProviderFilePart = FilePart;
2735
3006
 
3007
+ /**
3008
+ * Function that can intercept provider creation.
3009
+ * Returns a provider to override the default, or null to fall through.
3010
+ */
3011
+ type ProviderOverrideFn = (modelName: string, modelDef: ModelDefinition$1<string>, env: Env) => LLMProviderInterface | null;
3012
+ /**
3013
+ * Provider registry implementation
3014
+ *
3015
+ * Models must use ProviderFactory functions imported from provider packages
3016
+ * (e.g., @standardagents/openai, @standardagents/openrouter).
3017
+ *
3018
+ * Loads model configs from TypeScript virtual modules and
3019
+ * provider API keys from environment variables.
3020
+ */
3021
+ declare class ProviderRegistryImpl {
3022
+ private providerCache;
3023
+ private providerOverrideFn;
3024
+ setProviderOverride(fn: ProviderOverrideFn | null): void;
3025
+ /**
3026
+ * Get provider for a model.
3027
+ *
3028
+ * Models must use ProviderFactory functions (imported from provider packages).
3029
+ *
3030
+ * @param modelName - The model name (from TypeScript config)
3031
+ * @param env - Environment bindings
3032
+ * @param thread - Thread instance for loading model from virtual modules
3033
+ * @returns Provider and model definition
3034
+ */
3035
+ getProvider(modelName: string, env: Env, thread?: ThreadInstance): Promise<{
3036
+ provider: LLMProviderInterface;
3037
+ modelName: string;
3038
+ modelDef: ModelDefinition$1<string>;
3039
+ }>;
3040
+ private buildResult;
3041
+ private cacheAndReturn;
3042
+ /**
3043
+ * Get API key for a provider from environment variables.
3044
+ */
3045
+ private getApiKeyForProvider;
3046
+ /**
3047
+ * Clear the provider cache
3048
+ * Useful for testing or when configurations change
3049
+ */
3050
+ clearCache(): void;
3051
+ }
3052
+ /**
3053
+ * Singleton instance
3054
+ */
3055
+ declare const ProviderRegistry: ProviderRegistryImpl;
3056
+
2736
3057
  /**
2737
3058
  * Namespace-scoped resolution for the packing system.
2738
3059
  *
@@ -2877,4 +3198,4 @@ declare function createNamespaceContext(agentDef: {
2877
3198
  */
2878
3199
  declare function isQualifiedName(name: string): boolean;
2879
3200
 
2880
- export { type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, DurableAgentBuilder, DurableThread, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GitHubApiError, GitHubClient, type GitHubCommitResult, type GitHubConfig, type GitHubFileChange, GrepResult, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, type ProviderTextPart, type SideConfig, type SubpromptConfig, ThreadEnv, ThreadMetadata, type ThreadRegistryEntry, type ToolConfig, type UpdateThreadParams, type User, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateAgentFile, generateImageDescription, generateModelFile, generatePromptFile, 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 };
3201
+ export { type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, DurableAgentBuilder, DurableThread, Env, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GitHubApiError, GitHubClient, type GitHubCommitResult, type GitHubConfig, type GitHubFileChange, GrepResult, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type PromptToolConfig, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, ProviderRegistry, type ProviderTextPart, type SessionToolBinding, type SessionToolConfig, type SideConfig, type SubagentToolConfig, type SubpromptConfig, ThreadEnv, ThreadInstance, ThreadMetadata, type ThreadRegistryEntry, type ToolConfig, type UpdateThreadParams, type User, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateAgentFile, generateImageDescription, generateModelFile, generatePromptFile, 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 };