@standardagents/builder 0.12.8 → 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.
@@ -1,4 +1,4 @@
1
- import { D as DiscoveredPackage } from './types-pLkJx8vg.js';
1
+ import { D as DiscoveredPackage } from './types-DH3Egc5l.js';
2
2
  import { PackageSignature } from '@standardagents/spec';
3
3
 
4
4
  /**
@@ -76,6 +76,8 @@ declare class PackageDiscoveryService {
76
76
  */
77
77
  static validateStandardAgentField(field: unknown): field is {
78
78
  entryAgents: string[];
79
+ effects?: string[];
80
+ threadEndpoints?: string[];
79
81
  };
80
82
  /**
81
83
  * Get a package by ID.
@@ -1,7 +1,7 @@
1
1
  import { DurableObjectStorage } from '@cloudflare/workers-types';
2
2
  import { ZodObject, ZodRawShape } from 'zod';
3
- import { N as NamespacedRegistry } from './types-pLkJx8vg.js';
4
- import { ToolResult as ToolResult$1, HookName, HookSignatures, ThreadState, HookMessage, HookToolCall, HookToolResult, AgentDefinition, ControllerContext, Controller, ThreadEndpointHandler } from '@standardagents/spec';
3
+ import { N as NamespacedRegistry } from './types-DH3Egc5l.js';
4
+ import { ToolResult as ToolResult$1, VariableDefinition, HookName, HookSignatures, ThreadState, HookMessage, HookToolCall, HookToolResult, QueueMessageInput, SubagentRegistryEntry, AgentDefinition, ControllerContext, Controller, ThreadEndpointHandler } from '@standardagents/spec';
5
5
 
6
6
  /**
7
7
  * Callback function to execute before stream closes
@@ -92,6 +92,14 @@ interface Agent {
92
92
  side_a_stop_tool_response_property: string | null;
93
93
  side_a_max_steps: number | null;
94
94
  side_a_end_session_tool: string | null;
95
+ side_a_end_session_message_property: string | null;
96
+ side_a_end_session_attachments_property: string | null;
97
+ side_a_fail_session_tool: string | null;
98
+ side_a_fail_session_message_property: string | null;
99
+ side_a_fail_session_attachments_property: string | null;
100
+ side_a_status_tool: string | null;
101
+ side_a_status_message_property: string | null;
102
+ side_a_status_attachments_property: string | null;
95
103
  side_b_label: string | null;
96
104
  side_b_agent_prompt: string | null;
97
105
  side_b_stop_on_response: boolean;
@@ -99,6 +107,14 @@ interface Agent {
99
107
  side_b_stop_tool_response_property: string | null;
100
108
  side_b_max_steps: number | null;
101
109
  side_b_end_session_tool: string | null;
110
+ side_b_end_session_message_property: string | null;
111
+ side_b_end_session_attachments_property: string | null;
112
+ side_b_fail_session_tool: string | null;
113
+ side_b_fail_session_message_property: string | null;
114
+ side_b_fail_session_attachments_property: string | null;
115
+ side_b_status_tool: string | null;
116
+ side_b_status_message_property: string | null;
117
+ side_b_status_attachments_property: string | null;
102
118
  hooks?: string[];
103
119
  }
104
120
  /**
@@ -123,6 +139,16 @@ interface Message {
123
139
  parent_id?: string | null;
124
140
  depth?: number;
125
141
  attachments?: string | null;
142
+ metadata?: Record<string, unknown>;
143
+ subagent_id?: string | null;
144
+ subagent_name?: string | null;
145
+ subagent_title?: string | null;
146
+ subagent_description?: string | null;
147
+ subagent_status?: string | null;
148
+ subagent_resumable?: boolean | null;
149
+ subagent_blocking?: boolean | null;
150
+ subagent_thread_name?: string | null;
151
+ subagent_spawn_group_id?: string | null;
126
152
  }
127
153
  /**
128
154
  * Tool call from OpenAI format
@@ -145,8 +171,12 @@ interface ThreadMetadata {
145
171
  id: string;
146
172
  agent_id: string;
147
173
  user_id: string | null;
174
+ env: Record<string, string> | null;
175
+ /** @deprecated Use env */
148
176
  tenvs: Record<string, unknown> | null;
149
177
  properties: Record<string, unknown> | null;
178
+ parent?: string | null;
179
+ terminated?: number | null;
150
180
  created_at: number;
151
181
  }
152
182
  /**
@@ -187,6 +217,8 @@ interface NativeToolModule {
187
217
  args: ZodObject<ZodRawShape> | null;
188
218
  /** The tool implementation function. */
189
219
  execute: ((state: any, args: Record<string, unknown>) => Promise<ToolResult$1>) | ((state: any) => Promise<ToolResult$1>);
220
+ /** Declared variables for this tool. */
221
+ variables?: VariableDefinition[] | null;
190
222
  /** Zod schema for thread environment variables, or null if none. */
191
223
  tenvs?: ZodObject<ZodRawShape> | null;
192
224
  /**
@@ -226,6 +258,7 @@ interface ThreadInstance {
226
258
  loadTool(name: string): Promise<any>;
227
259
  getPromptNames(): string[];
228
260
  getAgentNames(): string[];
261
+ getModelNames?(): string[];
229
262
  writeFile(path: string, data: string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
230
263
  writeTextFile(path: string, content: string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
231
264
  readFile(path: string): Promise<{
@@ -248,6 +281,16 @@ interface ThreadInstance {
248
281
  error?: string;
249
282
  }>;
250
283
  runAgent(threadId: string, agentName: string): Promise<void>;
284
+ queueMessage?(threadId: string, message: QueueMessageInput): Promise<void>;
285
+ getChildrenRegistry?(threadId: string): Promise<SubagentRegistryEntry[]>;
286
+ upsertChildRegistry?(threadId: string, entry: SubagentRegistryEntry): Promise<void>;
287
+ updateChildRegistryStatus?(threadId: string, reference: string, status: string): Promise<void>;
288
+ removeChildRegistry?(threadId: string, reference: string): Promise<void>;
289
+ getTerminated?(threadId: string): Promise<number | null>;
290
+ terminateThread?(threadId: string): Promise<{
291
+ success: boolean;
292
+ terminated: number;
293
+ }>;
251
294
  scheduleEffect(threadId: string, effectName: string, effectArgs: Record<string, unknown>, delayMs?: number): Promise<string>;
252
295
  getScheduledEffects(name?: string): Promise<Array<{
253
296
  id: string;
@@ -300,6 +343,37 @@ interface SubpromptConfig {
300
343
  includeToolCalls?: boolean;
301
344
  includeErrors?: boolean;
302
345
  }
346
+ /**
347
+ * Prompt tool configuration with static tenvs/options.
348
+ */
349
+ interface PromptToolConfig {
350
+ name: string;
351
+ env?: Record<string, string>;
352
+ /** @deprecated Use env */
353
+ tenvs?: Record<string, unknown>;
354
+ options?: Record<string, unknown>;
355
+ }
356
+ /**
357
+ * Subagent tool configuration for dual_ai agent invocation.
358
+ */
359
+ interface SubagentToolConfig {
360
+ name: string;
361
+ blocking?: boolean;
362
+ initUserMessageProperty?: string;
363
+ initAttachmentsProperty?: string;
364
+ initAgentNameProperty?: string;
365
+ immediate?: boolean | {
366
+ nameEnv?: string;
367
+ descriptionEnv?: string;
368
+ scopedEnv?: string[];
369
+ };
370
+ optional?: string;
371
+ resumable?: false | {
372
+ receives_messages: "side_a" | "side_b";
373
+ maxInstances?: number;
374
+ parentCommunication?: "implicit" | "explicit";
375
+ };
376
+ }
303
377
  /**
304
378
  * Prompt configuration - now loaded from TypeScript virtual modules
305
379
  */
@@ -325,7 +399,9 @@ interface PromptData {
325
399
  reasoning_exclude: boolean;
326
400
  include_reasoning: boolean;
327
401
  recentImageThreshold: number | null;
328
- _tools?: (string | SubpromptConfig)[];
402
+ _tools?: (string | SubpromptConfig | PromptToolConfig | SubagentToolConfig)[];
403
+ _variables?: VariableDefinition[];
404
+ _env?: Record<string, string>;
329
405
  _requiredSchema?: unknown;
330
406
  _hooks?: string[];
331
407
  }
@@ -351,6 +427,8 @@ interface FlowState {
351
427
  sideBStepCount: number;
352
428
  stopped: boolean;
353
429
  stoppedBy?: "a" | "b";
430
+ stopReason?: string;
431
+ stopReasonCode?: string;
354
432
  forcedNextSide?: "side_a" | "side_b";
355
433
  pendingForceTurn?: "side_a" | "side_b";
356
434
  abortController?: AbortController;
@@ -414,6 +492,18 @@ interface FlowState {
414
492
  * Undefined means no restriction (global context or tool without uses).
415
493
  */
416
494
  currentToolUses?: string[];
495
+ /**
496
+ * Cached parent thread ID for this execution context.
497
+ */
498
+ parentThreadId?: string | null;
499
+ /**
500
+ * Prompt keys that have already executed immediate tools for this run.
501
+ */
502
+ immediatePromptRuns?: Set<string>;
503
+ /**
504
+ * Forces immediate tools on the next step after a handoff.
505
+ */
506
+ pendingImmediateAfterHandoff?: boolean;
417
507
  }
418
508
  /**
419
509
  * Text content part for multimodal messages
@@ -571,6 +661,8 @@ interface ToolResult {
571
661
  */
572
662
  result?: string;
573
663
  error?: string;
664
+ error_code?: string;
665
+ error_data?: Record<string, unknown>;
574
666
  stack?: string;
575
667
  /**
576
668
  * File attachments returned by the tool.
@@ -582,6 +674,11 @@ interface ToolResult {
582
674
  * New attachments are stored under /attachments/ directory.
583
675
  */
584
676
  attachments?: Array<ToolAttachment | AttachmentRef>;
677
+ /**
678
+ * Subagent reference to associate with the stored tool-result message.
679
+ * Used for subagent stream grouping.
680
+ */
681
+ subagent_id?: string;
585
682
  }
586
683
  /**
587
684
  * Flow execution result
@@ -590,6 +687,8 @@ interface FlowResult {
590
687
  messages: Message[];
591
688
  stopped: boolean;
592
689
  stoppedBy?: "a" | "b";
690
+ stopReason?: string;
691
+ stopReasonCode?: string;
593
692
  stepCount: number;
594
693
  stream: ReadableStream<Uint8Array>;
595
694
  }
@@ -884,6 +983,22 @@ interface LogDetails {
884
983
  */
885
984
  interface DurableThreadRpc {
886
985
  stop(): Promise<Response>;
986
+ executeBlocking?(threadId: string, agentId: string, initial_messages?: unknown[], data?: unknown): Promise<{
987
+ status: "success" | "error";
988
+ result?: string;
989
+ error?: string;
990
+ attachments?: unknown[];
991
+ }>;
992
+ terminateThread?(threadId: string): Promise<{
993
+ success: boolean;
994
+ terminated: number;
995
+ }>;
996
+ getTerminated?(threadId: string): Promise<number | null>;
997
+ queueMessage?(threadId: string, message: QueueMessageInput): Promise<void>;
998
+ getChildrenRegistry?(threadId: string): Promise<SubagentRegistryEntry[]>;
999
+ upsertChildRegistry?(threadId: string, entry: SubagentRegistryEntry): Promise<void>;
1000
+ updateChildRegistryStatus?(threadId: string, reference: string, status: string): Promise<void>;
1001
+ removeChildRegistry?(threadId: string, reference: string): Promise<void>;
887
1002
  getMessages(limit?: number, offset?: number, order?: "ASC" | "DESC", includeSilent?: boolean, maxDepth?: number): Promise<{
888
1003
  messages: unknown[];
889
1004
  total: number;
@@ -919,6 +1034,12 @@ interface ThreadRegistryEntry {
919
1034
  agent_name: string;
920
1035
  user_id: string | null;
921
1036
  tags: string[] | null;
1037
+ env?: Record<string, string> | null;
1038
+ /** @deprecated Use env */
1039
+ tenvs?: Record<string, unknown> | null;
1040
+ properties?: Record<string, unknown> | null;
1041
+ parent: string | null;
1042
+ terminated: number | null;
922
1043
  created_at: number;
923
1044
  }
924
1045
  /**
@@ -929,10 +1050,112 @@ interface DurableAgentBuilderRpc {
929
1050
  agent_name: string;
930
1051
  user_id?: string;
931
1052
  tags?: string[];
1053
+ env?: Record<string, string>;
1054
+ /** @deprecated Use env */
932
1055
  tenvs?: Record<string, unknown>;
933
1056
  properties?: Record<string, unknown>;
1057
+ parent?: string;
934
1058
  }): Promise<ThreadRegistryEntry>;
935
1059
  getThread(threadId: string): Promise<ThreadRegistryEntry | null>;
1060
+ resolveThreadEnv?(params: {
1061
+ threadId: string;
1062
+ property: string;
1063
+ promptName?: string;
1064
+ }): Promise<string | null>;
1065
+ getMissingRequiredScopedSubagentEnv?(params: {
1066
+ parent_thread_id: string;
1067
+ agent_name: string;
1068
+ provided_env?: Record<string, string> | null;
1069
+ }): Promise<string[]>;
1070
+ createPendingSubagentEnvRequest?(params: {
1071
+ parent_thread_id: string;
1072
+ agent_name: string;
1073
+ registry_agent_name: string;
1074
+ required_variables: string[];
1075
+ missing_variables: string[];
1076
+ payload: {
1077
+ blocking: boolean;
1078
+ resumable: boolean;
1079
+ receives_messages: "side_a" | "side_b";
1080
+ initial_message_content: string;
1081
+ initial_message_attachments: Array<{
1082
+ path: string;
1083
+ name?: string;
1084
+ mimeType?: string;
1085
+ size?: number;
1086
+ width?: number;
1087
+ height?: number;
1088
+ }>;
1089
+ initial_agent_name?: string | null;
1090
+ agent_title?: string | null;
1091
+ agent_description?: string | null;
1092
+ spawn_group_id?: string | null;
1093
+ };
1094
+ }): Promise<{
1095
+ request_id: string;
1096
+ parent_thread_id: string;
1097
+ agent_name: string;
1098
+ registry_agent_name: string;
1099
+ required: string[];
1100
+ missing: string[];
1101
+ payload: {
1102
+ blocking: boolean;
1103
+ resumable: boolean;
1104
+ receives_messages: "side_a" | "side_b";
1105
+ initial_message_content: string;
1106
+ initial_message_attachments: Array<{
1107
+ path: string;
1108
+ name?: string;
1109
+ mimeType?: string;
1110
+ size?: number;
1111
+ width?: number;
1112
+ height?: number;
1113
+ }>;
1114
+ initial_agent_name?: string | null;
1115
+ agent_title?: string | null;
1116
+ agent_description?: string | null;
1117
+ spawn_group_id?: string | null;
1118
+ };
1119
+ created_at: number;
1120
+ }>;
1121
+ getPendingSubagentEnvRequest?(parentThreadId: string, requestId: string): Promise<{
1122
+ request_id: string;
1123
+ parent_thread_id: string;
1124
+ agent_name: string;
1125
+ registry_agent_name: string;
1126
+ required: string[];
1127
+ missing: string[];
1128
+ payload: {
1129
+ blocking: boolean;
1130
+ resumable: boolean;
1131
+ receives_messages: "side_a" | "side_b";
1132
+ initial_message_content: string;
1133
+ initial_message_attachments: Array<{
1134
+ path: string;
1135
+ name?: string;
1136
+ mimeType?: string;
1137
+ size?: number;
1138
+ width?: number;
1139
+ height?: number;
1140
+ }>;
1141
+ initial_agent_name?: string | null;
1142
+ agent_title?: string | null;
1143
+ agent_description?: string | null;
1144
+ spawn_group_id?: string | null;
1145
+ };
1146
+ created_at: number;
1147
+ } | null>;
1148
+ completePendingSubagentEnvRequest?(params: {
1149
+ parent_thread_id: string;
1150
+ request_id: string;
1151
+ env: Record<string, string>;
1152
+ }): Promise<{
1153
+ request_id: string;
1154
+ child_thread_id: string;
1155
+ status: "success";
1156
+ }>;
1157
+ getInstanceEnv?(): Promise<Record<string, string>>;
1158
+ getUserEnv?(userId: string): Promise<Record<string, string>>;
936
1159
  listThreads(params?: {
937
1160
  agent_name?: string;
938
1161
  user_id?: string;
@@ -945,6 +1168,7 @@ interface DurableAgentBuilderRpc {
945
1168
  threads: ThreadRegistryEntry[];
946
1169
  total: number;
947
1170
  }>;
1171
+ getThreadTreeIds?(threadId: string): Promise<string[]>;
948
1172
  deleteThread(threadId: string): Promise<void>;
949
1173
  getUserByUsername(username: string): Promise<unknown>;
950
1174
  createSession(session: {
@@ -1040,4 +1264,4 @@ declare function defineController<Env extends ThreadEnv = ThreadEnv>(controller:
1040
1264
  */
1041
1265
  declare function createThreadEndpointHandler<Env extends ThreadEnv = ThreadEnv>(handler: ThreadEndpointHandler): BuilderController<Env>;
1042
1266
 
1043
- export { type AttachmentRef as A, type BuilderController as B, type Env as E, type FileRecord as F, type GrepResult as G, type ImageMetadata as I, type LLMResponse as L, type Message as M, type RequestContext as R, type StorageBackend as S, type ThreadEnv as T, type ThreadMetadata as a, type FlowState as b, type FileStats as c, type MessageContent as d, defineController as e, createThreadEndpointHandler as f, type BuilderControllerContext as g, type ThreadEndpointContext as h, type BuilderThreadEndpointHandler as i, type Agent as j, type ThreadInstance as k, type ToolCall as l, type ToolResult as m, type FlowResult as n, type TelemetryEvent as o, type TextContentPart as p, type ImageContentPart as q, type MultimodalContent as r };
1267
+ export { type AttachmentRef as A, type BuilderController as B, type Env as E, type FileRecord as F, type GrepResult as G, type ImageMetadata as I, type LLMResponse as L, type Message as M, type RequestContext as R, type StorageBackend as S, type ThreadEnv as T, type ThreadMetadata as a, type FlowState as b, type FileStats as c, type MessageContent as d, type ThreadInstance as e, defineController as f, createThreadEndpointHandler as g, type BuilderControllerContext as h, type ThreadEndpointContext as i, type BuilderThreadEndpointHandler as j, type Agent as k, type ToolCall as l, type ToolResult as m, type FlowResult as n, type TelemetryEvent as o, type TextContentPart as p, type ImageContentPart as q, type MultimodalContent as r };