@standardagents/builder 0.11.0-next.af971ae → 0.11.0-next.c3b4490
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/built-in-routes.js +21823 -317
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +26 -23
- package/dist/client/vendor.js +1 -1
- package/dist/client/vue.js +1 -1
- package/dist/index.d.ts +307 -26
- package/dist/index.js +3341 -1106
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.js +369 -61
- package/dist/plugin.js.map +1 -1
- package/dist/sip.wasm +0 -0
- package/package.json +8 -6
- package/dist/client/assets/img/meta.svg +0 -19
- package/dist/client/assets/img/moonshotai.svg +0 -4
- package/dist/client/assets/img/zai.svg +0 -219
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { AgentPluginOptions, agentbuilder } from './plugin.js';
|
|
2
2
|
import { DurableObjectStorage } from '@cloudflare/workers-types';
|
|
3
3
|
import { ZodObject, ZodRawShape } from 'zod';
|
|
4
|
-
import { ToolResult as ToolResult$1, HookSignatures, ControllerContext, Controller, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, SubpromptConfig as SubpromptConfig$2, ReasoningConfig, SideConfig as SideConfig$1 } from '@standardagents/spec';
|
|
5
|
-
export { AgentType, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, PromptInput, PromptTextPart, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, defineAgent, defineHook, defineModel, definePrompt,
|
|
4
|
+
import { ToolResult as ToolResult$1, HookSignatures, AgentDefinition as AgentDefinition$1, ControllerContext, Controller, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, SubpromptConfig as SubpromptConfig$2, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart } from '@standardagents/spec';
|
|
5
|
+
export { AgentType, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, 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, defineAgent, defineHook, defineModel, definePrompt, defineTool, mapReasoningLevel } from '@standardagents/spec';
|
|
6
6
|
import { DurableObject } from 'cloudflare:workers';
|
|
7
7
|
import 'vite';
|
|
8
8
|
|
|
@@ -213,6 +213,8 @@ interface ThreadMetadata {
|
|
|
213
213
|
id: string;
|
|
214
214
|
agent_id: string;
|
|
215
215
|
user_id: string | null;
|
|
216
|
+
tenvs: Record<string, unknown> | null;
|
|
217
|
+
properties: Record<string, unknown> | null;
|
|
216
218
|
created_at: number;
|
|
217
219
|
}
|
|
218
220
|
/**
|
|
@@ -226,7 +228,26 @@ type HookRegistry = {
|
|
|
226
228
|
* Tools can have args (with validation schema) or no args.
|
|
227
229
|
* Uses local Zod types for compatibility with z.toJSONSchema().
|
|
228
230
|
*/
|
|
229
|
-
|
|
231
|
+
interface NativeToolModule {
|
|
232
|
+
/** Description of what the tool does (shown to the LLM). */
|
|
233
|
+
description: string;
|
|
234
|
+
/** Zod schema for validating tool arguments, or null for no args. */
|
|
235
|
+
args: ZodObject<ZodRawShape> | null;
|
|
236
|
+
/** The tool implementation function. */
|
|
237
|
+
execute: ((state: any, args: Record<string, unknown>) => Promise<ToolResult$1>) | ((state: any) => Promise<ToolResult$1>);
|
|
238
|
+
/** Zod schema for thread environment variables, or null if none. */
|
|
239
|
+
tenvs?: ZodObject<ZodRawShape> | null;
|
|
240
|
+
/**
|
|
241
|
+
* Where this tool is executed:
|
|
242
|
+
* - 'local': Execute locally by the execution engine (default)
|
|
243
|
+
* - 'provider': Executed by the LLM provider, results come in response
|
|
244
|
+
*/
|
|
245
|
+
executionMode?: 'local' | 'provider';
|
|
246
|
+
/**
|
|
247
|
+
* Which provider executes this tool (when executionMode='provider').
|
|
248
|
+
*/
|
|
249
|
+
executionProvider?: string;
|
|
250
|
+
}
|
|
230
251
|
/**
|
|
231
252
|
* Thread instance (forward reference to avoid circular dependency)
|
|
232
253
|
*/
|
|
@@ -240,6 +261,10 @@ interface ThreadInstance {
|
|
|
240
261
|
}>;
|
|
241
262
|
getLogs(limit?: number, offset?: number, order?: "asc" | "desc"): Promise<LogData[]>;
|
|
242
263
|
getThreadMeta(threadId: string): Promise<ThreadMetadata | null>;
|
|
264
|
+
deleteMessage(messageId: string): Promise<{
|
|
265
|
+
success: boolean;
|
|
266
|
+
error?: string;
|
|
267
|
+
}>;
|
|
243
268
|
shouldStop(): Promise<boolean>;
|
|
244
269
|
tools(): Record<string, () => Promise<NativeToolModule>>;
|
|
245
270
|
hooks(): HookRegistry;
|
|
@@ -249,7 +274,11 @@ interface ThreadInstance {
|
|
|
249
274
|
getPromptNames(): string[];
|
|
250
275
|
getAgentNames(): string[];
|
|
251
276
|
writeFile(path: string, data: ArrayBuffer | string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
|
|
252
|
-
readFile(path: string): Promise<
|
|
277
|
+
readFile(path: string): Promise<{
|
|
278
|
+
success: boolean;
|
|
279
|
+
data?: string;
|
|
280
|
+
error?: string;
|
|
281
|
+
}>;
|
|
253
282
|
statFile(path: string): Promise<any>;
|
|
254
283
|
readdirFile(path: string): Promise<any[]>;
|
|
255
284
|
unlinkFile(path: string): Promise<void>;
|
|
@@ -264,6 +293,16 @@ interface ThreadInstance {
|
|
|
264
293
|
data?: string;
|
|
265
294
|
error?: string;
|
|
266
295
|
}>;
|
|
296
|
+
runAgent(threadId: string, agentName: string): Promise<void>;
|
|
297
|
+
scheduleEffect(threadId: string, effectName: string, effectArgs: Record<string, unknown>, delayMs?: number): Promise<string>;
|
|
298
|
+
getScheduledEffects(name?: string): Promise<Array<{
|
|
299
|
+
id: string;
|
|
300
|
+
name: string;
|
|
301
|
+
args: Record<string, unknown>;
|
|
302
|
+
scheduledAt: number;
|
|
303
|
+
createdAt: number;
|
|
304
|
+
}>>;
|
|
305
|
+
removeScheduledEffect(id: string): Promise<boolean>;
|
|
267
306
|
insertOrphanedToolCall(params: {
|
|
268
307
|
content?: string;
|
|
269
308
|
toolCallId: string;
|
|
@@ -302,6 +341,7 @@ type FlowCallWithRetries = FlowCall & {
|
|
|
302
341
|
interface SubpromptConfig$1 {
|
|
303
342
|
name: string;
|
|
304
343
|
initUserMessageProperty?: string;
|
|
344
|
+
initAttachmentsProperty?: string;
|
|
305
345
|
includeTextResponse?: boolean;
|
|
306
346
|
includeToolCalls?: boolean;
|
|
307
347
|
includeErrors?: boolean;
|
|
@@ -392,6 +432,7 @@ interface FlowState {
|
|
|
392
432
|
depth: number;
|
|
393
433
|
pendingMessageId?: string;
|
|
394
434
|
allowedTools?: ToolDefinition[];
|
|
435
|
+
pendingMetadataPromises?: Promise<void>[];
|
|
395
436
|
}
|
|
396
437
|
/**
|
|
397
438
|
* Text content part for multimodal messages
|
|
@@ -428,6 +469,10 @@ interface RequestContext {
|
|
|
428
469
|
tool_calls?: ToolCall[];
|
|
429
470
|
tool_call_id?: string;
|
|
430
471
|
name?: string;
|
|
472
|
+
reasoning_content?: string;
|
|
473
|
+
reasoning_details?: any[];
|
|
474
|
+
attachments?: any[];
|
|
475
|
+
toolName?: string;
|
|
431
476
|
}>;
|
|
432
477
|
model: string;
|
|
433
478
|
tools?: ToolDefinition[];
|
|
@@ -459,6 +504,17 @@ interface ToolDefinition {
|
|
|
459
504
|
description: string;
|
|
460
505
|
parameters?: Record<string, any>;
|
|
461
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Where this tool is executed:
|
|
509
|
+
* - 'local': Execute locally by the execution engine (default)
|
|
510
|
+
* - 'provider': Executed by the LLM provider, results come in response
|
|
511
|
+
*/
|
|
512
|
+
executionMode?: 'local' | 'provider';
|
|
513
|
+
/**
|
|
514
|
+
* Which provider executes this tool (when executionMode='provider')
|
|
515
|
+
* e.g., 'openai', 'anthropic'
|
|
516
|
+
*/
|
|
517
|
+
executionProvider?: string;
|
|
462
518
|
}
|
|
463
519
|
/**
|
|
464
520
|
* Image returned by an LLM response (e.g., from image generation models)
|
|
@@ -466,6 +522,12 @@ interface ToolDefinition {
|
|
|
466
522
|
*/
|
|
467
523
|
interface LLMResponseImage {
|
|
468
524
|
type: "image_url";
|
|
525
|
+
/** Unique ID for this generated image (used to link to tool call) */
|
|
526
|
+
id?: string;
|
|
527
|
+
/** Name of the tool that generated this image (e.g., 'image_generation') */
|
|
528
|
+
toolName?: string;
|
|
529
|
+
/** The revised/actual prompt used to generate the image (from OpenAI's image_generation) */
|
|
530
|
+
revisedPrompt?: string;
|
|
469
531
|
image_url: {
|
|
470
532
|
url: string;
|
|
471
533
|
};
|
|
@@ -495,6 +557,12 @@ interface LLMResponse {
|
|
|
495
557
|
cost?: number;
|
|
496
558
|
provider?: string;
|
|
497
559
|
};
|
|
560
|
+
/** @internal Provider instance reference for async metadata fetching */
|
|
561
|
+
_provider?: unknown;
|
|
562
|
+
/** @internal Provider response ID for async metadata fetching */
|
|
563
|
+
_providerResponseId?: string;
|
|
564
|
+
/** @internal Aggregate response for logging */
|
|
565
|
+
_aggregate_response?: unknown;
|
|
498
566
|
}
|
|
499
567
|
/**
|
|
500
568
|
* Attachment returned by a tool (e.g., generated images)
|
|
@@ -627,6 +695,7 @@ interface LogData {
|
|
|
627
695
|
tools_available?: number;
|
|
628
696
|
prompt_name?: string;
|
|
629
697
|
tools_called?: string;
|
|
698
|
+
actual_provider?: string | null;
|
|
630
699
|
parent_log_id?: string | null;
|
|
631
700
|
tools_schema?: string | null;
|
|
632
701
|
message_history?: string | null;
|
|
@@ -771,20 +840,6 @@ interface LogEntry {
|
|
|
771
840
|
created_at: number;
|
|
772
841
|
request_body: string | null;
|
|
773
842
|
}
|
|
774
|
-
/**
|
|
775
|
-
* Agent definition returned from loadAgent()
|
|
776
|
-
*/
|
|
777
|
-
interface AgentDefinition$1 {
|
|
778
|
-
name: string;
|
|
779
|
-
title?: string;
|
|
780
|
-
type?: string;
|
|
781
|
-
description?: string;
|
|
782
|
-
icon?: string;
|
|
783
|
-
defaultPrompt?: string;
|
|
784
|
-
defaultModel?: string;
|
|
785
|
-
tools?: string[];
|
|
786
|
-
[key: string]: unknown;
|
|
787
|
-
}
|
|
788
843
|
/**
|
|
789
844
|
* Response from getThreadMeta()
|
|
790
845
|
*/
|
|
@@ -797,6 +852,50 @@ interface ThreadMetaResponse {
|
|
|
797
852
|
lastActivity: number | null;
|
|
798
853
|
};
|
|
799
854
|
}
|
|
855
|
+
/**
|
|
856
|
+
* Log details returned by getLogDetails
|
|
857
|
+
*/
|
|
858
|
+
interface LogDetails {
|
|
859
|
+
id: string;
|
|
860
|
+
message_id: string;
|
|
861
|
+
provider: string;
|
|
862
|
+
actual_provider: string | null;
|
|
863
|
+
model: string;
|
|
864
|
+
model_name: string | null;
|
|
865
|
+
endpoint: string | null;
|
|
866
|
+
request_body: string | null;
|
|
867
|
+
request_headers: string | null;
|
|
868
|
+
response_body: string | null;
|
|
869
|
+
response_headers: string | null;
|
|
870
|
+
status_code: number | null;
|
|
871
|
+
reasoning_content: string | null;
|
|
872
|
+
input_tokens: number | null;
|
|
873
|
+
cached_tokens: number | null;
|
|
874
|
+
output_tokens: number | null;
|
|
875
|
+
reasoning_tokens: number | null;
|
|
876
|
+
total_tokens: number | null;
|
|
877
|
+
latency_ms: number | null;
|
|
878
|
+
time_to_first_token_ms: number | null;
|
|
879
|
+
finish_reason: string | null;
|
|
880
|
+
error: string | null;
|
|
881
|
+
error_type: string | null;
|
|
882
|
+
cost_input: number | null;
|
|
883
|
+
cost_output: number | null;
|
|
884
|
+
cost_total: number | null;
|
|
885
|
+
message_history_length: number | null;
|
|
886
|
+
tools_available: number | null;
|
|
887
|
+
prompt_name: string | null;
|
|
888
|
+
tools_called: string | null;
|
|
889
|
+
provider_tools: string | null;
|
|
890
|
+
parent_log_id: string | null;
|
|
891
|
+
tools_schema: string | null;
|
|
892
|
+
system_prompt: string | null;
|
|
893
|
+
errors: string | null;
|
|
894
|
+
retry_of_log_id: string | null;
|
|
895
|
+
tool_results: string | null;
|
|
896
|
+
is_complete: number;
|
|
897
|
+
created_at: number;
|
|
898
|
+
}
|
|
800
899
|
/**
|
|
801
900
|
* RPC methods exposed by DurableThread for external callers.
|
|
802
901
|
*/
|
|
@@ -820,9 +919,14 @@ interface DurableThreadRpc {
|
|
|
820
919
|
total: number;
|
|
821
920
|
hasMore: boolean;
|
|
822
921
|
}>;
|
|
823
|
-
getLogDetails(logId: string): Promise<
|
|
922
|
+
getLogDetails(logId: string): Promise<LogDetails | null>;
|
|
824
923
|
getThreadMeta(threadId: string): Promise<ThreadMetaResponse | null>;
|
|
825
924
|
deleteThread(): Promise<void>;
|
|
925
|
+
readFile(path: string): Promise<{
|
|
926
|
+
success: boolean;
|
|
927
|
+
data?: string;
|
|
928
|
+
error?: string;
|
|
929
|
+
}>;
|
|
826
930
|
}
|
|
827
931
|
/**
|
|
828
932
|
* Thread registry entry from DurableAgentBuilder.
|
|
@@ -842,11 +946,16 @@ interface DurableAgentBuilderRpc {
|
|
|
842
946
|
agent_name: string;
|
|
843
947
|
user_id?: string;
|
|
844
948
|
tags?: string[];
|
|
949
|
+
tenvs?: Record<string, unknown>;
|
|
950
|
+
properties?: Record<string, unknown>;
|
|
845
951
|
}): Promise<ThreadRegistryEntry$1>;
|
|
846
952
|
getThread(threadId: string): Promise<ThreadRegistryEntry$1 | null>;
|
|
847
953
|
listThreads(params?: {
|
|
848
954
|
agent_name?: string;
|
|
849
955
|
user_id?: string;
|
|
956
|
+
search?: string;
|
|
957
|
+
startDate?: number;
|
|
958
|
+
endDate?: number;
|
|
850
959
|
limit?: number;
|
|
851
960
|
offset?: number;
|
|
852
961
|
}): Promise<{
|
|
@@ -896,6 +1005,49 @@ interface ThreadEndpointContext {
|
|
|
896
1005
|
metadata: ThreadMetadata;
|
|
897
1006
|
};
|
|
898
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Handler function for builder thread endpoints.
|
|
1010
|
+
*
|
|
1011
|
+
* Unlike the spec's ThreadEndpointHandler which receives ThreadState,
|
|
1012
|
+
* the builder's handler receives direct access to the Durable Object
|
|
1013
|
+
* instance and thread metadata. This allows for lower-level operations
|
|
1014
|
+
* like calling RPC methods directly on the instance.
|
|
1015
|
+
*/
|
|
1016
|
+
type BuilderThreadEndpointHandler = (req: Request, context: {
|
|
1017
|
+
instance: ThreadInstance;
|
|
1018
|
+
metadata: ThreadMetadata;
|
|
1019
|
+
}) => Response | Promise<Response>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Define a thread-specific endpoint with access to the Durable Object instance.
|
|
1022
|
+
*
|
|
1023
|
+
* This is the builder's version of defineThreadEndpoint. It provides direct
|
|
1024
|
+
* access to the thread's Durable Object instance and metadata, allowing
|
|
1025
|
+
* for lower-level operations like calling RPC methods directly.
|
|
1026
|
+
*
|
|
1027
|
+
* @param handler - Function that receives the request and thread context
|
|
1028
|
+
* @returns A Controller that can be used with the router
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```typescript
|
|
1032
|
+
* import { defineThreadEndpoint } from '@standardagents/builder';
|
|
1033
|
+
*
|
|
1034
|
+
* export default defineThreadEndpoint(async (req, { instance, metadata }) => {
|
|
1035
|
+
* // Access thread metadata
|
|
1036
|
+
* console.log('Thread ID:', metadata.id);
|
|
1037
|
+
* console.log('Agent ID:', metadata.agent_id);
|
|
1038
|
+
*
|
|
1039
|
+
* // Call RPC methods on the Durable Object instance
|
|
1040
|
+
* const messagesResult = await instance.getMessages();
|
|
1041
|
+
* const logs = await instance.getLogs();
|
|
1042
|
+
*
|
|
1043
|
+
* return Response.json({
|
|
1044
|
+
* messageCount: messagesResult.messages.length,
|
|
1045
|
+
* logCount: logs.length,
|
|
1046
|
+
* });
|
|
1047
|
+
* });
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
1050
|
+
declare function defineThreadEndpoint(handler: BuilderThreadEndpointHandler): BuilderController;
|
|
899
1051
|
|
|
900
1052
|
/**
|
|
901
1053
|
* Define a controller with typed Cloudflare environment bindings.
|
|
@@ -1009,6 +1161,17 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1009
1161
|
* @returns Record of agent name to agent loader function
|
|
1010
1162
|
*/
|
|
1011
1163
|
agents(): Record<string, () => Promise<any>>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Returns the effects registry for lazy-loading effect definitions.
|
|
1166
|
+
* This method is implemented when you import DurableThread from 'virtual:@standardagents/builder'.
|
|
1167
|
+
*
|
|
1168
|
+
* Effects are scheduled operations that run outside the tool execution context,
|
|
1169
|
+
* ideal for delayed notifications, webhooks, and cleanup tasks.
|
|
1170
|
+
*
|
|
1171
|
+
* @throws Error if not implemented in a subclass
|
|
1172
|
+
* @returns Record of effect name to effect loader function
|
|
1173
|
+
*/
|
|
1174
|
+
effects(): Record<string, () => Promise<any>>;
|
|
1012
1175
|
/**
|
|
1013
1176
|
* Load a model definition by name.
|
|
1014
1177
|
*/
|
|
@@ -1033,6 +1196,59 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1033
1196
|
* List available agent names.
|
|
1034
1197
|
*/
|
|
1035
1198
|
getAgentNames(): string[];
|
|
1199
|
+
/**
|
|
1200
|
+
* Load an effect definition by name.
|
|
1201
|
+
*/
|
|
1202
|
+
loadEffect(name: string): Promise<any>;
|
|
1203
|
+
/**
|
|
1204
|
+
* List available effect names.
|
|
1205
|
+
*/
|
|
1206
|
+
getEffectNames(): string[];
|
|
1207
|
+
/**
|
|
1208
|
+
* Get thread metadata from DurableAgentBuilder.
|
|
1209
|
+
* Used for creating ThreadState outside of flow execution.
|
|
1210
|
+
*/
|
|
1211
|
+
getThreadMetadata(threadId: string): Promise<ThreadMetadata>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Trigger an agent to run on this thread.
|
|
1214
|
+
*
|
|
1215
|
+
* Queues an agent execution via the alarm queue. The execution
|
|
1216
|
+
* runs asynchronously in the background.
|
|
1217
|
+
*
|
|
1218
|
+
* @param threadId - Thread ID for the execution
|
|
1219
|
+
* @param agentName - Name of the agent to run
|
|
1220
|
+
*/
|
|
1221
|
+
runAgent(threadId: string, agentName: string): Promise<void>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Schedule an effect for future execution.
|
|
1224
|
+
*
|
|
1225
|
+
* @param threadId - Thread ID for the effect execution context
|
|
1226
|
+
* @param effectName - Name of the effect to schedule
|
|
1227
|
+
* @param effectArgs - Arguments to pass to the effect handler
|
|
1228
|
+
* @param delayMs - Delay in milliseconds before execution (default: 0)
|
|
1229
|
+
* @returns UUID of the scheduled effect
|
|
1230
|
+
*/
|
|
1231
|
+
scheduleEffect(threadId: string, effectName: string, effectArgs: Record<string, unknown>, delayMs?: number): Promise<string>;
|
|
1232
|
+
/**
|
|
1233
|
+
* Get scheduled effects for this thread.
|
|
1234
|
+
*
|
|
1235
|
+
* @param name - Optional effect name to filter by
|
|
1236
|
+
* @returns Array of scheduled effect records
|
|
1237
|
+
*/
|
|
1238
|
+
getScheduledEffects(name?: string): Promise<Array<{
|
|
1239
|
+
id: string;
|
|
1240
|
+
name: string;
|
|
1241
|
+
args: Record<string, unknown>;
|
|
1242
|
+
scheduledAt: number;
|
|
1243
|
+
createdAt: number;
|
|
1244
|
+
}>>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Remove a scheduled effect.
|
|
1247
|
+
*
|
|
1248
|
+
* @param id - The effect ID returned by scheduleEffect
|
|
1249
|
+
* @returns true if the effect was found and removed, false otherwise
|
|
1250
|
+
*/
|
|
1251
|
+
removeScheduledEffect(id: string): Promise<boolean>;
|
|
1036
1252
|
/**
|
|
1037
1253
|
* Ensures the database schema is up to date.
|
|
1038
1254
|
* This method is called on the first request to the Durable Object.
|
|
@@ -1078,6 +1294,15 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1078
1294
|
* Simple "off" switch - stops turns, only cleared by user messages
|
|
1079
1295
|
*/
|
|
1080
1296
|
stop(): Promise<Response>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Continue execution from where it stopped (RPC method)
|
|
1299
|
+
* Useful for debugging - continues the FlowEngine with additional steps
|
|
1300
|
+
* without adding a new message.
|
|
1301
|
+
*
|
|
1302
|
+
* @param threadId The thread ID
|
|
1303
|
+
* @param side Which side to start from ('a' or 'b'), defaults to 'a'
|
|
1304
|
+
*/
|
|
1305
|
+
continueExecution(threadId: string, side?: 'a' | 'b'): Promise<Response>;
|
|
1081
1306
|
/**
|
|
1082
1307
|
* Get message history (RPC method)
|
|
1083
1308
|
*
|
|
@@ -1190,10 +1415,12 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1190
1415
|
id: string;
|
|
1191
1416
|
message_id: string;
|
|
1192
1417
|
provider: string;
|
|
1418
|
+
actual_provider: string | null;
|
|
1193
1419
|
model: string;
|
|
1194
1420
|
model_name: string | null;
|
|
1195
1421
|
prompt_name: string | null;
|
|
1196
1422
|
tools_called: string | null;
|
|
1423
|
+
provider_tools: string | null;
|
|
1197
1424
|
parent_log_id: string | null;
|
|
1198
1425
|
retry_of_log_id: string | null;
|
|
1199
1426
|
error: string | null;
|
|
@@ -1213,6 +1440,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1213
1440
|
id: string;
|
|
1214
1441
|
message_id: string;
|
|
1215
1442
|
provider: string;
|
|
1443
|
+
actual_provider: string | null;
|
|
1216
1444
|
model: string;
|
|
1217
1445
|
model_name: string | null;
|
|
1218
1446
|
endpoint: string | null;
|
|
@@ -1239,6 +1467,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1239
1467
|
tools_available: number | null;
|
|
1240
1468
|
prompt_name: string | null;
|
|
1241
1469
|
tools_called: string | null;
|
|
1470
|
+
provider_tools: string | null;
|
|
1242
1471
|
parent_log_id: string | null;
|
|
1243
1472
|
tools_schema: string | null;
|
|
1244
1473
|
message_history: string | null;
|
|
@@ -1347,8 +1576,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1347
1576
|
/**
|
|
1348
1577
|
* WebSocket Hibernation API handler for connection close
|
|
1349
1578
|
* Called when a WebSocket connection is closed
|
|
1579
|
+
* Note: Do NOT call ws.close() here - the connection is already closed
|
|
1350
1580
|
*/
|
|
1351
|
-
webSocketClose(ws: WebSocket,
|
|
1581
|
+
webSocketClose(ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
|
|
1352
1582
|
/**
|
|
1353
1583
|
* WebSocket Hibernation API handler for errors
|
|
1354
1584
|
* Called when a WebSocket encounters an error
|
|
@@ -1367,11 +1597,21 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1367
1597
|
* This is the actual execution logic, separate from the public execute() RPC method
|
|
1368
1598
|
*/
|
|
1369
1599
|
private executeFlow;
|
|
1600
|
+
/**
|
|
1601
|
+
* Internal method: Execute an effect (called by alarm queue)
|
|
1602
|
+
* Effects run outside the tool execution context.
|
|
1603
|
+
*/
|
|
1604
|
+
private executeEffect;
|
|
1370
1605
|
/**
|
|
1371
1606
|
* Internal method: Process a message (called by alarm queue)
|
|
1372
1607
|
* This is the actual message processing logic, separate from the public sendMessage() RPC method
|
|
1373
1608
|
*/
|
|
1374
1609
|
private processMessage;
|
|
1610
|
+
/**
|
|
1611
|
+
* Internal method: Continue execution without adding a message (called by alarm queue)
|
|
1612
|
+
* This allows resuming FlowEngine execution from where it stopped.
|
|
1613
|
+
*/
|
|
1614
|
+
private doContinueExecution;
|
|
1375
1615
|
/**
|
|
1376
1616
|
* TEST METHOD: Queue a test operation
|
|
1377
1617
|
* Used for testing alarm queue ordering and timing
|
|
@@ -1683,6 +1923,7 @@ interface AgentBuilderEnv {
|
|
|
1683
1923
|
GITHUB_TOKEN?: string;
|
|
1684
1924
|
GITHUB_REPO?: string;
|
|
1685
1925
|
GITHUB_BRANCH?: string;
|
|
1926
|
+
ENCRYPTION_KEY?: string;
|
|
1686
1927
|
}
|
|
1687
1928
|
/**
|
|
1688
1929
|
* Thread metadata stored in the registry.
|
|
@@ -1692,6 +1933,8 @@ interface ThreadRegistryEntry {
|
|
|
1692
1933
|
agent_name: string;
|
|
1693
1934
|
user_id: string | null;
|
|
1694
1935
|
tags: string[] | null;
|
|
1936
|
+
tenvs: Record<string, unknown> | null;
|
|
1937
|
+
properties: Record<string, unknown> | null;
|
|
1695
1938
|
created_at: number;
|
|
1696
1939
|
}
|
|
1697
1940
|
/**
|
|
@@ -1716,7 +1959,7 @@ interface User {
|
|
|
1716
1959
|
/**
|
|
1717
1960
|
* Provider credentials.
|
|
1718
1961
|
*/
|
|
1719
|
-
interface Provider {
|
|
1962
|
+
interface Provider$1 {
|
|
1720
1963
|
name: string;
|
|
1721
1964
|
sdk: string;
|
|
1722
1965
|
api_key: string;
|
|
@@ -1760,6 +2003,8 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1760
2003
|
agent_name: string;
|
|
1761
2004
|
user_id?: string;
|
|
1762
2005
|
tags?: string[];
|
|
2006
|
+
tenvs?: Record<string, unknown>;
|
|
2007
|
+
properties?: Record<string, unknown>;
|
|
1763
2008
|
}): Promise<ThreadRegistryEntry>;
|
|
1764
2009
|
/**
|
|
1765
2010
|
* Get a thread by ID.
|
|
@@ -1767,10 +2012,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1767
2012
|
getThread(id: string): Promise<ThreadRegistryEntry | null>;
|
|
1768
2013
|
/**
|
|
1769
2014
|
* List threads with optional filtering.
|
|
2015
|
+
* Note: tenvs are not decrypted in list operations for performance.
|
|
2016
|
+
* Use getThread() to retrieve a thread with decrypted tenvs.
|
|
1770
2017
|
*/
|
|
1771
2018
|
listThreads(params?: {
|
|
1772
2019
|
agent_name?: string;
|
|
1773
2020
|
user_id?: string;
|
|
2021
|
+
search?: string;
|
|
2022
|
+
startDate?: number;
|
|
2023
|
+
endDate?: number;
|
|
1774
2024
|
limit?: number;
|
|
1775
2025
|
offset?: number;
|
|
1776
2026
|
}): Promise<{
|
|
@@ -1816,15 +2066,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1816
2066
|
/**
|
|
1817
2067
|
* Get a provider's credentials.
|
|
1818
2068
|
*/
|
|
1819
|
-
getProvider(name: string): Promise<Provider | null>;
|
|
2069
|
+
getProvider(name: string): Promise<Provider$1 | null>;
|
|
1820
2070
|
/**
|
|
1821
2071
|
* Set a provider's credentials.
|
|
1822
2072
|
*/
|
|
1823
|
-
setProvider(provider: Provider): Promise<void>;
|
|
2073
|
+
setProvider(provider: Provider$1): Promise<void>;
|
|
1824
2074
|
/**
|
|
1825
2075
|
* List all providers.
|
|
1826
2076
|
*/
|
|
1827
|
-
listProviders(): Promise<Provider[]>;
|
|
2077
|
+
listProviders(): Promise<Provider$1[]>;
|
|
1828
2078
|
/**
|
|
1829
2079
|
* Delete a provider.
|
|
1830
2080
|
*/
|
|
@@ -2198,16 +2448,34 @@ interface AgentDefinition<N extends string = string> {
|
|
|
2198
2448
|
exposeAsTool?: boolean;
|
|
2199
2449
|
/** Description shown when agent is used as a tool. */
|
|
2200
2450
|
toolDescription?: string;
|
|
2451
|
+
/**
|
|
2452
|
+
* Thread environment variables for this agent.
|
|
2453
|
+
* Merged into thread tenvs at creation time.
|
|
2454
|
+
* Later values (thread) override earlier ones (prompt -> agent).
|
|
2455
|
+
*/
|
|
2456
|
+
tenvs?: Record<string, unknown>;
|
|
2201
2457
|
/** Brief description of what this agent does. */
|
|
2202
2458
|
description?: string;
|
|
2203
2459
|
/** Icon URL or absolute path for the agent. */
|
|
2204
2460
|
icon?: string;
|
|
2205
2461
|
}
|
|
2206
2462
|
|
|
2463
|
+
/**
|
|
2464
|
+
* Options for generating a model file.
|
|
2465
|
+
*/
|
|
2466
|
+
interface GenerateModelFileOptions {
|
|
2467
|
+
/** The provider export name (e.g., 'openai', 'openrouter') */
|
|
2468
|
+
providerName: string;
|
|
2469
|
+
/** The provider package (e.g., '@standardagents/openai') */
|
|
2470
|
+
providerPackage: string;
|
|
2471
|
+
}
|
|
2207
2472
|
/**
|
|
2208
2473
|
* Generate a TypeScript file for a model definition.
|
|
2474
|
+
*
|
|
2475
|
+
* @param data - The model definition data
|
|
2476
|
+
* @param options - Provider import options (required since providers are functions)
|
|
2209
2477
|
*/
|
|
2210
|
-
declare function generateModelFile(data: ModelDefinition): string;
|
|
2478
|
+
declare function generateModelFile(data: ModelDefinition, options: GenerateModelFileOptions): string;
|
|
2211
2479
|
|
|
2212
2480
|
/**
|
|
2213
2481
|
* Converts JSON Schema to Zod code string.
|
|
@@ -2246,6 +2514,8 @@ interface ToolConfigInput {
|
|
|
2246
2514
|
include_tool_calls?: boolean;
|
|
2247
2515
|
include_errors?: boolean;
|
|
2248
2516
|
init_user_message_property?: string | null;
|
|
2517
|
+
init_attachments_property?: string | null;
|
|
2518
|
+
tenvs?: Record<string, unknown>;
|
|
2249
2519
|
}
|
|
2250
2520
|
/**
|
|
2251
2521
|
* Prompt part as it comes from the UI/API.
|
|
@@ -3364,4 +3634,15 @@ declare class GitHubApiError extends Error {
|
|
|
3364
3634
|
constructor(message: string, status: number, details?: unknown);
|
|
3365
3635
|
}
|
|
3366
3636
|
|
|
3367
|
-
|
|
3637
|
+
/** @public Alias for LLMProviderInterface */
|
|
3638
|
+
type Provider = LLMProviderInterface;
|
|
3639
|
+
/** @public Alias for ContentPart */
|
|
3640
|
+
type ProviderContentPart = ContentPart;
|
|
3641
|
+
/** @public Alias for TextPart */
|
|
3642
|
+
type ProviderTextPart = TextPart;
|
|
3643
|
+
/** @public Alias for ImagePart */
|
|
3644
|
+
type ProviderImagePart = ImagePart;
|
|
3645
|
+
/** @public Alias for FilePart */
|
|
3646
|
+
type ProviderFilePart = FilePart;
|
|
3647
|
+
|
|
3648
|
+
export { type Agent, type AgentBuilderEnv, type AgentDefinition, type AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, type BuilderThreadEndpointHandler, type BuilderController as Controller, type BuilderControllerContext as ControllerContext, DurableAgentBuilder, DurableThread, type Env, type FileRecord, type FileStats, type FlowResult, type FlowState, FlowStateSdk, type FlowStateWithSdk, GitHubApiError, GitHubClient, type GitHubCommitResult, type GitHubConfig, type GitHubFileChange, type GrepResult, type ImageContentPart, type ImageContextConfig, type ImageMetadata, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, type LLMResponse, type Message, type MessageContent, type ModelDefinition, type MultimodalContent, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, type ProviderTextPart, type RequestContext, type SideConfig, type StorageBackend, type SubpromptConfig, type TelemetryEvent, type TextContentPart, type ThreadEndpointContext, type ThreadEnv, type ThreadInstance, type ThreadMetadata, type ThreadRegistryEntry, type ToolCall, type ToolConfig, type ToolResult, type UpdateThreadParams, type User, authenticate, buildImageDescription, cat, defineController, defineThreadEndpoint, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateAgentFile, generateImageDescription, generateModelFile, generatePromptFile, getFileStats, getMessages, getMessagesToSummarize, getThumbnail, getUnsummarizedImageAttachments, grep, hasImageAttachments, head, injectMessage, linkFile, mkdir, optimizeImageContext, queueTool, readFile, readdir, reloadHistory, replaceImagesWithDescriptions, requireAdmin, requireAuth, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|