@standardagents/builder 0.11.0-next.41deba4 → 0.11.0-next.56def20
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 +239 -26
- package/dist/index.js +3184 -1230
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +281 -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,7 @@ interface ThreadInstance {
|
|
|
264
293
|
data?: string;
|
|
265
294
|
error?: string;
|
|
266
295
|
}>;
|
|
296
|
+
runAgent(threadId: string, agentName: string): Promise<void>;
|
|
267
297
|
scheduleEffect(threadId: string, effectName: string, effectArgs: Record<string, unknown>, delayMs?: number): Promise<string>;
|
|
268
298
|
getScheduledEffects(name?: string): Promise<Array<{
|
|
269
299
|
id: string;
|
|
@@ -311,6 +341,7 @@ type FlowCallWithRetries = FlowCall & {
|
|
|
311
341
|
interface SubpromptConfig$1 {
|
|
312
342
|
name: string;
|
|
313
343
|
initUserMessageProperty?: string;
|
|
344
|
+
initAttachmentsProperty?: string;
|
|
314
345
|
includeTextResponse?: boolean;
|
|
315
346
|
includeToolCalls?: boolean;
|
|
316
347
|
includeErrors?: boolean;
|
|
@@ -401,6 +432,7 @@ interface FlowState {
|
|
|
401
432
|
depth: number;
|
|
402
433
|
pendingMessageId?: string;
|
|
403
434
|
allowedTools?: ToolDefinition[];
|
|
435
|
+
pendingMetadataPromises?: Promise<void>[];
|
|
404
436
|
}
|
|
405
437
|
/**
|
|
406
438
|
* Text content part for multimodal messages
|
|
@@ -437,6 +469,10 @@ interface RequestContext {
|
|
|
437
469
|
tool_calls?: ToolCall[];
|
|
438
470
|
tool_call_id?: string;
|
|
439
471
|
name?: string;
|
|
472
|
+
reasoning_content?: string;
|
|
473
|
+
reasoning_details?: any[];
|
|
474
|
+
attachments?: any[];
|
|
475
|
+
toolName?: string;
|
|
440
476
|
}>;
|
|
441
477
|
model: string;
|
|
442
478
|
tools?: ToolDefinition[];
|
|
@@ -468,6 +504,17 @@ interface ToolDefinition {
|
|
|
468
504
|
description: string;
|
|
469
505
|
parameters?: Record<string, any>;
|
|
470
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;
|
|
471
518
|
}
|
|
472
519
|
/**
|
|
473
520
|
* Image returned by an LLM response (e.g., from image generation models)
|
|
@@ -475,6 +522,12 @@ interface ToolDefinition {
|
|
|
475
522
|
*/
|
|
476
523
|
interface LLMResponseImage {
|
|
477
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;
|
|
478
531
|
image_url: {
|
|
479
532
|
url: string;
|
|
480
533
|
};
|
|
@@ -504,6 +557,12 @@ interface LLMResponse {
|
|
|
504
557
|
cost?: number;
|
|
505
558
|
provider?: string;
|
|
506
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;
|
|
507
566
|
}
|
|
508
567
|
/**
|
|
509
568
|
* Attachment returned by a tool (e.g., generated images)
|
|
@@ -636,6 +695,7 @@ interface LogData {
|
|
|
636
695
|
tools_available?: number;
|
|
637
696
|
prompt_name?: string;
|
|
638
697
|
tools_called?: string;
|
|
698
|
+
actual_provider?: string | null;
|
|
639
699
|
parent_log_id?: string | null;
|
|
640
700
|
tools_schema?: string | null;
|
|
641
701
|
message_history?: string | null;
|
|
@@ -780,20 +840,6 @@ interface LogEntry {
|
|
|
780
840
|
created_at: number;
|
|
781
841
|
request_body: string | null;
|
|
782
842
|
}
|
|
783
|
-
/**
|
|
784
|
-
* Agent definition returned from loadAgent()
|
|
785
|
-
*/
|
|
786
|
-
interface AgentDefinition$1 {
|
|
787
|
-
name: string;
|
|
788
|
-
title?: string;
|
|
789
|
-
type?: string;
|
|
790
|
-
description?: string;
|
|
791
|
-
icon?: string;
|
|
792
|
-
defaultPrompt?: string;
|
|
793
|
-
defaultModel?: string;
|
|
794
|
-
tools?: string[];
|
|
795
|
-
[key: string]: unknown;
|
|
796
|
-
}
|
|
797
843
|
/**
|
|
798
844
|
* Response from getThreadMeta()
|
|
799
845
|
*/
|
|
@@ -806,6 +852,50 @@ interface ThreadMetaResponse {
|
|
|
806
852
|
lastActivity: number | null;
|
|
807
853
|
};
|
|
808
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
|
+
}
|
|
809
899
|
/**
|
|
810
900
|
* RPC methods exposed by DurableThread for external callers.
|
|
811
901
|
*/
|
|
@@ -829,9 +919,14 @@ interface DurableThreadRpc {
|
|
|
829
919
|
total: number;
|
|
830
920
|
hasMore: boolean;
|
|
831
921
|
}>;
|
|
832
|
-
getLogDetails(logId: string): Promise<
|
|
922
|
+
getLogDetails(logId: string): Promise<LogDetails | null>;
|
|
833
923
|
getThreadMeta(threadId: string): Promise<ThreadMetaResponse | null>;
|
|
834
924
|
deleteThread(): Promise<void>;
|
|
925
|
+
readFile(path: string): Promise<{
|
|
926
|
+
success: boolean;
|
|
927
|
+
data?: string;
|
|
928
|
+
error?: string;
|
|
929
|
+
}>;
|
|
835
930
|
}
|
|
836
931
|
/**
|
|
837
932
|
* Thread registry entry from DurableAgentBuilder.
|
|
@@ -851,11 +946,16 @@ interface DurableAgentBuilderRpc {
|
|
|
851
946
|
agent_name: string;
|
|
852
947
|
user_id?: string;
|
|
853
948
|
tags?: string[];
|
|
949
|
+
tenvs?: Record<string, unknown>;
|
|
950
|
+
properties?: Record<string, unknown>;
|
|
854
951
|
}): Promise<ThreadRegistryEntry$1>;
|
|
855
952
|
getThread(threadId: string): Promise<ThreadRegistryEntry$1 | null>;
|
|
856
953
|
listThreads(params?: {
|
|
857
954
|
agent_name?: string;
|
|
858
955
|
user_id?: string;
|
|
956
|
+
search?: string;
|
|
957
|
+
startDate?: number;
|
|
958
|
+
endDate?: number;
|
|
859
959
|
limit?: number;
|
|
860
960
|
offset?: number;
|
|
861
961
|
}): Promise<{
|
|
@@ -905,6 +1005,49 @@ interface ThreadEndpointContext {
|
|
|
905
1005
|
metadata: ThreadMetadata;
|
|
906
1006
|
};
|
|
907
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;
|
|
908
1051
|
|
|
909
1052
|
/**
|
|
910
1053
|
* Define a controller with typed Cloudflare environment bindings.
|
|
@@ -1066,6 +1209,16 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1066
1209
|
* Used for creating ThreadState outside of flow execution.
|
|
1067
1210
|
*/
|
|
1068
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>;
|
|
1069
1222
|
/**
|
|
1070
1223
|
* Schedule an effect for future execution.
|
|
1071
1224
|
*
|
|
@@ -1141,6 +1294,15 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1141
1294
|
* Simple "off" switch - stops turns, only cleared by user messages
|
|
1142
1295
|
*/
|
|
1143
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>;
|
|
1144
1306
|
/**
|
|
1145
1307
|
* Get message history (RPC method)
|
|
1146
1308
|
*
|
|
@@ -1253,10 +1415,12 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1253
1415
|
id: string;
|
|
1254
1416
|
message_id: string;
|
|
1255
1417
|
provider: string;
|
|
1418
|
+
actual_provider: string | null;
|
|
1256
1419
|
model: string;
|
|
1257
1420
|
model_name: string | null;
|
|
1258
1421
|
prompt_name: string | null;
|
|
1259
1422
|
tools_called: string | null;
|
|
1423
|
+
provider_tools: string | null;
|
|
1260
1424
|
parent_log_id: string | null;
|
|
1261
1425
|
retry_of_log_id: string | null;
|
|
1262
1426
|
error: string | null;
|
|
@@ -1276,6 +1440,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1276
1440
|
id: string;
|
|
1277
1441
|
message_id: string;
|
|
1278
1442
|
provider: string;
|
|
1443
|
+
actual_provider: string | null;
|
|
1279
1444
|
model: string;
|
|
1280
1445
|
model_name: string | null;
|
|
1281
1446
|
endpoint: string | null;
|
|
@@ -1302,6 +1467,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1302
1467
|
tools_available: number | null;
|
|
1303
1468
|
prompt_name: string | null;
|
|
1304
1469
|
tools_called: string | null;
|
|
1470
|
+
provider_tools: string | null;
|
|
1305
1471
|
parent_log_id: string | null;
|
|
1306
1472
|
tools_schema: string | null;
|
|
1307
1473
|
message_history: string | null;
|
|
@@ -1410,8 +1576,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1410
1576
|
/**
|
|
1411
1577
|
* WebSocket Hibernation API handler for connection close
|
|
1412
1578
|
* Called when a WebSocket connection is closed
|
|
1579
|
+
* Note: Do NOT call ws.close() here - the connection is already closed
|
|
1413
1580
|
*/
|
|
1414
|
-
webSocketClose(ws: WebSocket,
|
|
1581
|
+
webSocketClose(ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
|
|
1415
1582
|
/**
|
|
1416
1583
|
* WebSocket Hibernation API handler for errors
|
|
1417
1584
|
* Called when a WebSocket encounters an error
|
|
@@ -1440,6 +1607,11 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1440
1607
|
* This is the actual message processing logic, separate from the public sendMessage() RPC method
|
|
1441
1608
|
*/
|
|
1442
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;
|
|
1443
1615
|
/**
|
|
1444
1616
|
* TEST METHOD: Queue a test operation
|
|
1445
1617
|
* Used for testing alarm queue ordering and timing
|
|
@@ -1751,6 +1923,7 @@ interface AgentBuilderEnv {
|
|
|
1751
1923
|
GITHUB_TOKEN?: string;
|
|
1752
1924
|
GITHUB_REPO?: string;
|
|
1753
1925
|
GITHUB_BRANCH?: string;
|
|
1926
|
+
ENCRYPTION_KEY?: string;
|
|
1754
1927
|
}
|
|
1755
1928
|
/**
|
|
1756
1929
|
* Thread metadata stored in the registry.
|
|
@@ -1760,6 +1933,8 @@ interface ThreadRegistryEntry {
|
|
|
1760
1933
|
agent_name: string;
|
|
1761
1934
|
user_id: string | null;
|
|
1762
1935
|
tags: string[] | null;
|
|
1936
|
+
tenvs: Record<string, unknown> | null;
|
|
1937
|
+
properties: Record<string, unknown> | null;
|
|
1763
1938
|
created_at: number;
|
|
1764
1939
|
}
|
|
1765
1940
|
/**
|
|
@@ -1784,7 +1959,7 @@ interface User {
|
|
|
1784
1959
|
/**
|
|
1785
1960
|
* Provider credentials.
|
|
1786
1961
|
*/
|
|
1787
|
-
interface Provider {
|
|
1962
|
+
interface Provider$1 {
|
|
1788
1963
|
name: string;
|
|
1789
1964
|
sdk: string;
|
|
1790
1965
|
api_key: string;
|
|
@@ -1828,6 +2003,8 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1828
2003
|
agent_name: string;
|
|
1829
2004
|
user_id?: string;
|
|
1830
2005
|
tags?: string[];
|
|
2006
|
+
tenvs?: Record<string, unknown>;
|
|
2007
|
+
properties?: Record<string, unknown>;
|
|
1831
2008
|
}): Promise<ThreadRegistryEntry>;
|
|
1832
2009
|
/**
|
|
1833
2010
|
* Get a thread by ID.
|
|
@@ -1835,10 +2012,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1835
2012
|
getThread(id: string): Promise<ThreadRegistryEntry | null>;
|
|
1836
2013
|
/**
|
|
1837
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.
|
|
1838
2017
|
*/
|
|
1839
2018
|
listThreads(params?: {
|
|
1840
2019
|
agent_name?: string;
|
|
1841
2020
|
user_id?: string;
|
|
2021
|
+
search?: string;
|
|
2022
|
+
startDate?: number;
|
|
2023
|
+
endDate?: number;
|
|
1842
2024
|
limit?: number;
|
|
1843
2025
|
offset?: number;
|
|
1844
2026
|
}): Promise<{
|
|
@@ -1884,15 +2066,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1884
2066
|
/**
|
|
1885
2067
|
* Get a provider's credentials.
|
|
1886
2068
|
*/
|
|
1887
|
-
getProvider(name: string): Promise<Provider | null>;
|
|
2069
|
+
getProvider(name: string): Promise<Provider$1 | null>;
|
|
1888
2070
|
/**
|
|
1889
2071
|
* Set a provider's credentials.
|
|
1890
2072
|
*/
|
|
1891
|
-
setProvider(provider: Provider): Promise<void>;
|
|
2073
|
+
setProvider(provider: Provider$1): Promise<void>;
|
|
1892
2074
|
/**
|
|
1893
2075
|
* List all providers.
|
|
1894
2076
|
*/
|
|
1895
|
-
listProviders(): Promise<Provider[]>;
|
|
2077
|
+
listProviders(): Promise<Provider$1[]>;
|
|
1896
2078
|
/**
|
|
1897
2079
|
* Delete a provider.
|
|
1898
2080
|
*/
|
|
@@ -2266,16 +2448,34 @@ interface AgentDefinition<N extends string = string> {
|
|
|
2266
2448
|
exposeAsTool?: boolean;
|
|
2267
2449
|
/** Description shown when agent is used as a tool. */
|
|
2268
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>;
|
|
2269
2457
|
/** Brief description of what this agent does. */
|
|
2270
2458
|
description?: string;
|
|
2271
2459
|
/** Icon URL or absolute path for the agent. */
|
|
2272
2460
|
icon?: string;
|
|
2273
2461
|
}
|
|
2274
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
|
+
}
|
|
2275
2472
|
/**
|
|
2276
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)
|
|
2277
2477
|
*/
|
|
2278
|
-
declare function generateModelFile(data: ModelDefinition): string;
|
|
2478
|
+
declare function generateModelFile(data: ModelDefinition, options: GenerateModelFileOptions): string;
|
|
2279
2479
|
|
|
2280
2480
|
/**
|
|
2281
2481
|
* Converts JSON Schema to Zod code string.
|
|
@@ -2314,6 +2514,8 @@ interface ToolConfigInput {
|
|
|
2314
2514
|
include_tool_calls?: boolean;
|
|
2315
2515
|
include_errors?: boolean;
|
|
2316
2516
|
init_user_message_property?: string | null;
|
|
2517
|
+
init_attachments_property?: string | null;
|
|
2518
|
+
tenvs?: Record<string, unknown>;
|
|
2317
2519
|
}
|
|
2318
2520
|
/**
|
|
2319
2521
|
* Prompt part as it comes from the UI/API.
|
|
@@ -3432,4 +3634,15 @@ declare class GitHubApiError extends Error {
|
|
|
3432
3634
|
constructor(message: string, status: number, details?: unknown);
|
|
3433
3635
|
}
|
|
3434
3636
|
|
|
3435
|
-
|
|
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 };
|