@standardagents/builder 0.11.0-next.5d2e71b → 0.11.0-next.7005954
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 +19607 -3767
- 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 +250 -44
- package/dist/index.js +3111 -1241
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +235 -62
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
- 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
|
|
|
@@ -13,63 +13,71 @@ import 'vite';
|
|
|
13
13
|
* Types are automatically populated when you run `pnpm dev` or `pnpm build`,
|
|
14
14
|
* which scans your `agentbuilder/` directories and generates types.
|
|
15
15
|
*
|
|
16
|
-
* The generated types are placed in `.
|
|
16
|
+
* The generated types are placed in `.agents/types.d.ts` and augment the
|
|
17
|
+
* StandardAgentSpec namespace from @standardagents/spec.
|
|
17
18
|
*
|
|
18
|
-
* Note:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Note: This namespace is provided for backward compatibility. New code should
|
|
20
|
+
* use StandardAgentSpec types directly, which are defined in @standardagents/spec.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use StandardAgentSpec namespace from @standardagents/spec instead
|
|
21
23
|
*/
|
|
22
24
|
declare global {
|
|
23
25
|
namespace AgentBuilder {
|
|
24
26
|
/**
|
|
25
27
|
* Interface for model type registration.
|
|
26
|
-
*
|
|
27
|
-
* This gives us: type Models = keyof ModelRegistry = 'gpt-4o' | 'claude-3'
|
|
28
|
+
* @deprecated Use StandardAgentSpec.ModelRegistry instead
|
|
28
29
|
*/
|
|
29
|
-
interface ModelRegistry {
|
|
30
|
+
interface ModelRegistry extends StandardAgentSpec.ModelRegistry {
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Interface for prompt type registration.
|
|
34
|
+
* @deprecated Use StandardAgentSpec.PromptRegistry instead
|
|
33
35
|
*/
|
|
34
|
-
interface PromptRegistry {
|
|
36
|
+
interface PromptRegistry extends StandardAgentSpec.PromptRegistry {
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Interface for agent type registration.
|
|
40
|
+
* @deprecated Use StandardAgentSpec.AgentRegistry instead
|
|
38
41
|
*/
|
|
39
|
-
interface AgentRegistry {
|
|
42
|
+
interface AgentRegistry extends StandardAgentSpec.AgentRegistry {
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
42
45
|
* Interface for tool type registration.
|
|
46
|
+
* @deprecated Use StandardAgentSpec.ToolRegistry instead
|
|
43
47
|
*/
|
|
44
|
-
interface ToolRegistry {
|
|
48
|
+
interface ToolRegistry extends StandardAgentSpec.ToolRegistry {
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Interface for callable type registration (prompts, agents, tools).
|
|
52
|
+
* @deprecated Use StandardAgentSpec.CallableRegistry instead
|
|
48
53
|
*/
|
|
49
|
-
interface CallableRegistry {
|
|
54
|
+
interface CallableRegistry extends StandardAgentSpec.CallableRegistry {
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
52
57
|
* Union type of all model names defined in agentbuilder/models/.
|
|
53
|
-
*
|
|
54
|
-
* When populated, it narrows to the specific model names.
|
|
58
|
+
* @deprecated Use StandardAgentSpec.Models instead
|
|
55
59
|
*/
|
|
56
|
-
type Models =
|
|
60
|
+
type Models = StandardAgentSpec.Models;
|
|
57
61
|
/**
|
|
58
62
|
* Union type of all prompt names defined in agentbuilder/prompts/.
|
|
63
|
+
* @deprecated Use StandardAgentSpec.Prompts instead
|
|
59
64
|
*/
|
|
60
|
-
type Prompts =
|
|
65
|
+
type Prompts = StandardAgentSpec.Prompts;
|
|
61
66
|
/**
|
|
62
67
|
* Union type of all agent names defined in agentbuilder/agents/.
|
|
68
|
+
* @deprecated Use StandardAgentSpec.Agents instead
|
|
63
69
|
*/
|
|
64
|
-
type Agents =
|
|
70
|
+
type Agents = StandardAgentSpec.Agents;
|
|
65
71
|
/**
|
|
66
72
|
* Union type of all tool names defined in agentbuilder/tools/.
|
|
73
|
+
* @deprecated Use StandardAgentSpec.Tools instead
|
|
67
74
|
*/
|
|
68
|
-
type Tools =
|
|
75
|
+
type Tools = StandardAgentSpec.Tools;
|
|
69
76
|
/**
|
|
70
77
|
* Union type of all callable items (prompts, agents, tools) that can be used as tools.
|
|
78
|
+
* @deprecated Use StandardAgentSpec.Callables instead
|
|
71
79
|
*/
|
|
72
|
-
type Callables =
|
|
80
|
+
type Callables = StandardAgentSpec.Callables;
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -213,6 +221,8 @@ interface ThreadMetadata {
|
|
|
213
221
|
id: string;
|
|
214
222
|
agent_id: string;
|
|
215
223
|
user_id: string | null;
|
|
224
|
+
tenvs: Record<string, unknown> | null;
|
|
225
|
+
properties: Record<string, unknown> | null;
|
|
216
226
|
created_at: number;
|
|
217
227
|
}
|
|
218
228
|
/**
|
|
@@ -226,7 +236,26 @@ type HookRegistry = {
|
|
|
226
236
|
* Tools can have args (with validation schema) or no args.
|
|
227
237
|
* Uses local Zod types for compatibility with z.toJSONSchema().
|
|
228
238
|
*/
|
|
229
|
-
|
|
239
|
+
interface NativeToolModule {
|
|
240
|
+
/** Description of what the tool does (shown to the LLM). */
|
|
241
|
+
description: string;
|
|
242
|
+
/** Zod schema for validating tool arguments, or null for no args. */
|
|
243
|
+
args: ZodObject<ZodRawShape> | null;
|
|
244
|
+
/** The tool implementation function. */
|
|
245
|
+
execute: ((state: any, args: Record<string, unknown>) => Promise<ToolResult$1>) | ((state: any) => Promise<ToolResult$1>);
|
|
246
|
+
/** Zod schema for thread environment variables, or null if none. */
|
|
247
|
+
tenvs?: ZodObject<ZodRawShape> | null;
|
|
248
|
+
/**
|
|
249
|
+
* Where this tool is executed:
|
|
250
|
+
* - 'local': Execute locally by the execution engine (default)
|
|
251
|
+
* - 'provider': Executed by the LLM provider, results come in response
|
|
252
|
+
*/
|
|
253
|
+
executionMode?: 'local' | 'provider';
|
|
254
|
+
/**
|
|
255
|
+
* Which provider executes this tool (when executionMode='provider').
|
|
256
|
+
*/
|
|
257
|
+
executionProvider?: string;
|
|
258
|
+
}
|
|
230
259
|
/**
|
|
231
260
|
* Thread instance (forward reference to avoid circular dependency)
|
|
232
261
|
*/
|
|
@@ -253,7 +282,11 @@ interface ThreadInstance {
|
|
|
253
282
|
getPromptNames(): string[];
|
|
254
283
|
getAgentNames(): string[];
|
|
255
284
|
writeFile(path: string, data: ArrayBuffer | string, mimeType: string, options?: Record<string, unknown>): Promise<any>;
|
|
256
|
-
readFile(path: string): Promise<
|
|
285
|
+
readFile(path: string): Promise<{
|
|
286
|
+
success: boolean;
|
|
287
|
+
data?: string;
|
|
288
|
+
error?: string;
|
|
289
|
+
}>;
|
|
257
290
|
statFile(path: string): Promise<any>;
|
|
258
291
|
readdirFile(path: string): Promise<any[]>;
|
|
259
292
|
unlinkFile(path: string): Promise<void>;
|
|
@@ -316,6 +349,7 @@ type FlowCallWithRetries = FlowCall & {
|
|
|
316
349
|
interface SubpromptConfig$1 {
|
|
317
350
|
name: string;
|
|
318
351
|
initUserMessageProperty?: string;
|
|
352
|
+
initAttachmentsProperty?: string;
|
|
319
353
|
includeTextResponse?: boolean;
|
|
320
354
|
includeToolCalls?: boolean;
|
|
321
355
|
includeErrors?: boolean;
|
|
@@ -406,6 +440,7 @@ interface FlowState {
|
|
|
406
440
|
depth: number;
|
|
407
441
|
pendingMessageId?: string;
|
|
408
442
|
allowedTools?: ToolDefinition[];
|
|
443
|
+
pendingMetadataPromises?: Promise<void>[];
|
|
409
444
|
}
|
|
410
445
|
/**
|
|
411
446
|
* Text content part for multimodal messages
|
|
@@ -442,6 +477,10 @@ interface RequestContext {
|
|
|
442
477
|
tool_calls?: ToolCall[];
|
|
443
478
|
tool_call_id?: string;
|
|
444
479
|
name?: string;
|
|
480
|
+
reasoning_content?: string;
|
|
481
|
+
reasoning_details?: any[];
|
|
482
|
+
attachments?: any[];
|
|
483
|
+
toolName?: string;
|
|
445
484
|
}>;
|
|
446
485
|
model: string;
|
|
447
486
|
tools?: ToolDefinition[];
|
|
@@ -473,6 +512,17 @@ interface ToolDefinition {
|
|
|
473
512
|
description: string;
|
|
474
513
|
parameters?: Record<string, any>;
|
|
475
514
|
};
|
|
515
|
+
/**
|
|
516
|
+
* Where this tool is executed:
|
|
517
|
+
* - 'local': Execute locally by the execution engine (default)
|
|
518
|
+
* - 'provider': Executed by the LLM provider, results come in response
|
|
519
|
+
*/
|
|
520
|
+
executionMode?: 'local' | 'provider';
|
|
521
|
+
/**
|
|
522
|
+
* Which provider executes this tool (when executionMode='provider')
|
|
523
|
+
* e.g., 'openai', 'anthropic'
|
|
524
|
+
*/
|
|
525
|
+
executionProvider?: string;
|
|
476
526
|
}
|
|
477
527
|
/**
|
|
478
528
|
* Image returned by an LLM response (e.g., from image generation models)
|
|
@@ -480,6 +530,12 @@ interface ToolDefinition {
|
|
|
480
530
|
*/
|
|
481
531
|
interface LLMResponseImage {
|
|
482
532
|
type: "image_url";
|
|
533
|
+
/** Unique ID for this generated image (used to link to tool call) */
|
|
534
|
+
id?: string;
|
|
535
|
+
/** Name of the tool that generated this image (e.g., 'image_generation') */
|
|
536
|
+
toolName?: string;
|
|
537
|
+
/** The revised/actual prompt used to generate the image (from OpenAI's image_generation) */
|
|
538
|
+
revisedPrompt?: string;
|
|
483
539
|
image_url: {
|
|
484
540
|
url: string;
|
|
485
541
|
};
|
|
@@ -509,6 +565,12 @@ interface LLMResponse {
|
|
|
509
565
|
cost?: number;
|
|
510
566
|
provider?: string;
|
|
511
567
|
};
|
|
568
|
+
/** @internal Provider instance reference for async metadata fetching */
|
|
569
|
+
_provider?: unknown;
|
|
570
|
+
/** @internal Provider response ID for async metadata fetching */
|
|
571
|
+
_providerResponseId?: string;
|
|
572
|
+
/** @internal Aggregate response for logging */
|
|
573
|
+
_aggregate_response?: unknown;
|
|
512
574
|
}
|
|
513
575
|
/**
|
|
514
576
|
* Attachment returned by a tool (e.g., generated images)
|
|
@@ -641,6 +703,7 @@ interface LogData {
|
|
|
641
703
|
tools_available?: number;
|
|
642
704
|
prompt_name?: string;
|
|
643
705
|
tools_called?: string;
|
|
706
|
+
actual_provider?: string | null;
|
|
644
707
|
parent_log_id?: string | null;
|
|
645
708
|
tools_schema?: string | null;
|
|
646
709
|
message_history?: string | null;
|
|
@@ -785,20 +848,6 @@ interface LogEntry {
|
|
|
785
848
|
created_at: number;
|
|
786
849
|
request_body: string | null;
|
|
787
850
|
}
|
|
788
|
-
/**
|
|
789
|
-
* Agent definition returned from loadAgent()
|
|
790
|
-
*/
|
|
791
|
-
interface AgentDefinition$1 {
|
|
792
|
-
name: string;
|
|
793
|
-
title?: string;
|
|
794
|
-
type?: string;
|
|
795
|
-
description?: string;
|
|
796
|
-
icon?: string;
|
|
797
|
-
defaultPrompt?: string;
|
|
798
|
-
defaultModel?: string;
|
|
799
|
-
tools?: string[];
|
|
800
|
-
[key: string]: unknown;
|
|
801
|
-
}
|
|
802
851
|
/**
|
|
803
852
|
* Response from getThreadMeta()
|
|
804
853
|
*/
|
|
@@ -811,6 +860,50 @@ interface ThreadMetaResponse {
|
|
|
811
860
|
lastActivity: number | null;
|
|
812
861
|
};
|
|
813
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Log details returned by getLogDetails
|
|
865
|
+
*/
|
|
866
|
+
interface LogDetails {
|
|
867
|
+
id: string;
|
|
868
|
+
message_id: string;
|
|
869
|
+
provider: string;
|
|
870
|
+
actual_provider: string | null;
|
|
871
|
+
model: string;
|
|
872
|
+
model_name: string | null;
|
|
873
|
+
endpoint: string | null;
|
|
874
|
+
request_body: string | null;
|
|
875
|
+
request_headers: string | null;
|
|
876
|
+
response_body: string | null;
|
|
877
|
+
response_headers: string | null;
|
|
878
|
+
status_code: number | null;
|
|
879
|
+
reasoning_content: string | null;
|
|
880
|
+
input_tokens: number | null;
|
|
881
|
+
cached_tokens: number | null;
|
|
882
|
+
output_tokens: number | null;
|
|
883
|
+
reasoning_tokens: number | null;
|
|
884
|
+
total_tokens: number | null;
|
|
885
|
+
latency_ms: number | null;
|
|
886
|
+
time_to_first_token_ms: number | null;
|
|
887
|
+
finish_reason: string | null;
|
|
888
|
+
error: string | null;
|
|
889
|
+
error_type: string | null;
|
|
890
|
+
cost_input: number | null;
|
|
891
|
+
cost_output: number | null;
|
|
892
|
+
cost_total: number | null;
|
|
893
|
+
message_history_length: number | null;
|
|
894
|
+
tools_available: number | null;
|
|
895
|
+
prompt_name: string | null;
|
|
896
|
+
tools_called: string | null;
|
|
897
|
+
provider_tools: string | null;
|
|
898
|
+
parent_log_id: string | null;
|
|
899
|
+
tools_schema: string | null;
|
|
900
|
+
system_prompt: string | null;
|
|
901
|
+
errors: string | null;
|
|
902
|
+
retry_of_log_id: string | null;
|
|
903
|
+
tool_results: string | null;
|
|
904
|
+
is_complete: number;
|
|
905
|
+
created_at: number;
|
|
906
|
+
}
|
|
814
907
|
/**
|
|
815
908
|
* RPC methods exposed by DurableThread for external callers.
|
|
816
909
|
*/
|
|
@@ -834,9 +927,14 @@ interface DurableThreadRpc {
|
|
|
834
927
|
total: number;
|
|
835
928
|
hasMore: boolean;
|
|
836
929
|
}>;
|
|
837
|
-
getLogDetails(logId: string): Promise<
|
|
930
|
+
getLogDetails(logId: string): Promise<LogDetails | null>;
|
|
838
931
|
getThreadMeta(threadId: string): Promise<ThreadMetaResponse | null>;
|
|
839
932
|
deleteThread(): Promise<void>;
|
|
933
|
+
readFile(path: string): Promise<{
|
|
934
|
+
success: boolean;
|
|
935
|
+
data?: string;
|
|
936
|
+
error?: string;
|
|
937
|
+
}>;
|
|
840
938
|
}
|
|
841
939
|
/**
|
|
842
940
|
* Thread registry entry from DurableAgentBuilder.
|
|
@@ -856,11 +954,16 @@ interface DurableAgentBuilderRpc {
|
|
|
856
954
|
agent_name: string;
|
|
857
955
|
user_id?: string;
|
|
858
956
|
tags?: string[];
|
|
957
|
+
tenvs?: Record<string, unknown>;
|
|
958
|
+
properties?: Record<string, unknown>;
|
|
859
959
|
}): Promise<ThreadRegistryEntry$1>;
|
|
860
960
|
getThread(threadId: string): Promise<ThreadRegistryEntry$1 | null>;
|
|
861
961
|
listThreads(params?: {
|
|
862
962
|
agent_name?: string;
|
|
863
963
|
user_id?: string;
|
|
964
|
+
search?: string;
|
|
965
|
+
startDate?: number;
|
|
966
|
+
endDate?: number;
|
|
864
967
|
limit?: number;
|
|
865
968
|
offset?: number;
|
|
866
969
|
}): Promise<{
|
|
@@ -910,6 +1013,49 @@ interface ThreadEndpointContext {
|
|
|
910
1013
|
metadata: ThreadMetadata;
|
|
911
1014
|
};
|
|
912
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Handler function for builder thread endpoints.
|
|
1018
|
+
*
|
|
1019
|
+
* Unlike the spec's ThreadEndpointHandler which receives ThreadState,
|
|
1020
|
+
* the builder's handler receives direct access to the Durable Object
|
|
1021
|
+
* instance and thread metadata. This allows for lower-level operations
|
|
1022
|
+
* like calling RPC methods directly on the instance.
|
|
1023
|
+
*/
|
|
1024
|
+
type BuilderThreadEndpointHandler = (req: Request, context: {
|
|
1025
|
+
instance: ThreadInstance;
|
|
1026
|
+
metadata: ThreadMetadata;
|
|
1027
|
+
}) => Response | Promise<Response>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Define a thread-specific endpoint with access to the Durable Object instance.
|
|
1030
|
+
*
|
|
1031
|
+
* This is the builder's version of defineThreadEndpoint. It provides direct
|
|
1032
|
+
* access to the thread's Durable Object instance and metadata, allowing
|
|
1033
|
+
* for lower-level operations like calling RPC methods directly.
|
|
1034
|
+
*
|
|
1035
|
+
* @param handler - Function that receives the request and thread context
|
|
1036
|
+
* @returns A Controller that can be used with the router
|
|
1037
|
+
*
|
|
1038
|
+
* @example
|
|
1039
|
+
* ```typescript
|
|
1040
|
+
* import { defineThreadEndpoint } from '@standardagents/builder';
|
|
1041
|
+
*
|
|
1042
|
+
* export default defineThreadEndpoint(async (req, { instance, metadata }) => {
|
|
1043
|
+
* // Access thread metadata
|
|
1044
|
+
* console.log('Thread ID:', metadata.id);
|
|
1045
|
+
* console.log('Agent ID:', metadata.agent_id);
|
|
1046
|
+
*
|
|
1047
|
+
* // Call RPC methods on the Durable Object instance
|
|
1048
|
+
* const messagesResult = await instance.getMessages();
|
|
1049
|
+
* const logs = await instance.getLogs();
|
|
1050
|
+
*
|
|
1051
|
+
* return Response.json({
|
|
1052
|
+
* messageCount: messagesResult.messages.length,
|
|
1053
|
+
* logCount: logs.length,
|
|
1054
|
+
* });
|
|
1055
|
+
* });
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
declare function defineThreadEndpoint(handler: BuilderThreadEndpointHandler): BuilderController;
|
|
913
1059
|
|
|
914
1060
|
/**
|
|
915
1061
|
* Define a controller with typed Cloudflare environment bindings.
|
|
@@ -1156,6 +1302,15 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1156
1302
|
* Simple "off" switch - stops turns, only cleared by user messages
|
|
1157
1303
|
*/
|
|
1158
1304
|
stop(): Promise<Response>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Continue execution from where it stopped (RPC method)
|
|
1307
|
+
* Useful for debugging - continues the FlowEngine with additional steps
|
|
1308
|
+
* without adding a new message.
|
|
1309
|
+
*
|
|
1310
|
+
* @param threadId The thread ID
|
|
1311
|
+
* @param side Which side to start from ('a' or 'b'), defaults to 'a'
|
|
1312
|
+
*/
|
|
1313
|
+
continueExecution(threadId: string, side?: 'a' | 'b'): Promise<Response>;
|
|
1159
1314
|
/**
|
|
1160
1315
|
* Get message history (RPC method)
|
|
1161
1316
|
*
|
|
@@ -1268,10 +1423,12 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1268
1423
|
id: string;
|
|
1269
1424
|
message_id: string;
|
|
1270
1425
|
provider: string;
|
|
1426
|
+
actual_provider: string | null;
|
|
1271
1427
|
model: string;
|
|
1272
1428
|
model_name: string | null;
|
|
1273
1429
|
prompt_name: string | null;
|
|
1274
1430
|
tools_called: string | null;
|
|
1431
|
+
provider_tools: string | null;
|
|
1275
1432
|
parent_log_id: string | null;
|
|
1276
1433
|
retry_of_log_id: string | null;
|
|
1277
1434
|
error: string | null;
|
|
@@ -1291,6 +1448,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1291
1448
|
id: string;
|
|
1292
1449
|
message_id: string;
|
|
1293
1450
|
provider: string;
|
|
1451
|
+
actual_provider: string | null;
|
|
1294
1452
|
model: string;
|
|
1295
1453
|
model_name: string | null;
|
|
1296
1454
|
endpoint: string | null;
|
|
@@ -1317,6 +1475,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1317
1475
|
tools_available: number | null;
|
|
1318
1476
|
prompt_name: string | null;
|
|
1319
1477
|
tools_called: string | null;
|
|
1478
|
+
provider_tools: string | null;
|
|
1320
1479
|
parent_log_id: string | null;
|
|
1321
1480
|
tools_schema: string | null;
|
|
1322
1481
|
message_history: string | null;
|
|
@@ -1425,8 +1584,9 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1425
1584
|
/**
|
|
1426
1585
|
* WebSocket Hibernation API handler for connection close
|
|
1427
1586
|
* Called when a WebSocket connection is closed
|
|
1587
|
+
* Note: Do NOT call ws.close() here - the connection is already closed
|
|
1428
1588
|
*/
|
|
1429
|
-
webSocketClose(ws: WebSocket,
|
|
1589
|
+
webSocketClose(ws: WebSocket, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
|
|
1430
1590
|
/**
|
|
1431
1591
|
* WebSocket Hibernation API handler for errors
|
|
1432
1592
|
* Called when a WebSocket encounters an error
|
|
@@ -1455,6 +1615,11 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1455
1615
|
* This is the actual message processing logic, separate from the public sendMessage() RPC method
|
|
1456
1616
|
*/
|
|
1457
1617
|
private processMessage;
|
|
1618
|
+
/**
|
|
1619
|
+
* Internal method: Continue execution without adding a message (called by alarm queue)
|
|
1620
|
+
* This allows resuming FlowEngine execution from where it stopped.
|
|
1621
|
+
*/
|
|
1622
|
+
private doContinueExecution;
|
|
1458
1623
|
/**
|
|
1459
1624
|
* TEST METHOD: Queue a test operation
|
|
1460
1625
|
* Used for testing alarm queue ordering and timing
|
|
@@ -1766,6 +1931,7 @@ interface AgentBuilderEnv {
|
|
|
1766
1931
|
GITHUB_TOKEN?: string;
|
|
1767
1932
|
GITHUB_REPO?: string;
|
|
1768
1933
|
GITHUB_BRANCH?: string;
|
|
1934
|
+
ENCRYPTION_KEY?: string;
|
|
1769
1935
|
}
|
|
1770
1936
|
/**
|
|
1771
1937
|
* Thread metadata stored in the registry.
|
|
@@ -1775,6 +1941,8 @@ interface ThreadRegistryEntry {
|
|
|
1775
1941
|
agent_name: string;
|
|
1776
1942
|
user_id: string | null;
|
|
1777
1943
|
tags: string[] | null;
|
|
1944
|
+
tenvs: Record<string, unknown> | null;
|
|
1945
|
+
properties: Record<string, unknown> | null;
|
|
1778
1946
|
created_at: number;
|
|
1779
1947
|
}
|
|
1780
1948
|
/**
|
|
@@ -1799,7 +1967,7 @@ interface User {
|
|
|
1799
1967
|
/**
|
|
1800
1968
|
* Provider credentials.
|
|
1801
1969
|
*/
|
|
1802
|
-
interface Provider {
|
|
1970
|
+
interface Provider$1 {
|
|
1803
1971
|
name: string;
|
|
1804
1972
|
sdk: string;
|
|
1805
1973
|
api_key: string;
|
|
@@ -1843,6 +2011,8 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1843
2011
|
agent_name: string;
|
|
1844
2012
|
user_id?: string;
|
|
1845
2013
|
tags?: string[];
|
|
2014
|
+
tenvs?: Record<string, unknown>;
|
|
2015
|
+
properties?: Record<string, unknown>;
|
|
1846
2016
|
}): Promise<ThreadRegistryEntry>;
|
|
1847
2017
|
/**
|
|
1848
2018
|
* Get a thread by ID.
|
|
@@ -1850,10 +2020,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1850
2020
|
getThread(id: string): Promise<ThreadRegistryEntry | null>;
|
|
1851
2021
|
/**
|
|
1852
2022
|
* List threads with optional filtering.
|
|
2023
|
+
* Note: tenvs are not decrypted in list operations for performance.
|
|
2024
|
+
* Use getThread() to retrieve a thread with decrypted tenvs.
|
|
1853
2025
|
*/
|
|
1854
2026
|
listThreads(params?: {
|
|
1855
2027
|
agent_name?: string;
|
|
1856
2028
|
user_id?: string;
|
|
2029
|
+
search?: string;
|
|
2030
|
+
startDate?: number;
|
|
2031
|
+
endDate?: number;
|
|
1857
2032
|
limit?: number;
|
|
1858
2033
|
offset?: number;
|
|
1859
2034
|
}): Promise<{
|
|
@@ -1899,15 +2074,15 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1899
2074
|
/**
|
|
1900
2075
|
* Get a provider's credentials.
|
|
1901
2076
|
*/
|
|
1902
|
-
getProvider(name: string): Promise<Provider | null>;
|
|
2077
|
+
getProvider(name: string): Promise<Provider$1 | null>;
|
|
1903
2078
|
/**
|
|
1904
2079
|
* Set a provider's credentials.
|
|
1905
2080
|
*/
|
|
1906
|
-
setProvider(provider: Provider): Promise<void>;
|
|
2081
|
+
setProvider(provider: Provider$1): Promise<void>;
|
|
1907
2082
|
/**
|
|
1908
2083
|
* List all providers.
|
|
1909
2084
|
*/
|
|
1910
|
-
listProviders(): Promise<Provider[]>;
|
|
2085
|
+
listProviders(): Promise<Provider$1[]>;
|
|
1911
2086
|
/**
|
|
1912
2087
|
* Delete a provider.
|
|
1913
2088
|
*/
|
|
@@ -2281,16 +2456,34 @@ interface AgentDefinition<N extends string = string> {
|
|
|
2281
2456
|
exposeAsTool?: boolean;
|
|
2282
2457
|
/** Description shown when agent is used as a tool. */
|
|
2283
2458
|
toolDescription?: string;
|
|
2459
|
+
/**
|
|
2460
|
+
* Thread environment variables for this agent.
|
|
2461
|
+
* Merged into thread tenvs at creation time.
|
|
2462
|
+
* Later values (thread) override earlier ones (prompt -> agent).
|
|
2463
|
+
*/
|
|
2464
|
+
tenvs?: Record<string, unknown>;
|
|
2284
2465
|
/** Brief description of what this agent does. */
|
|
2285
2466
|
description?: string;
|
|
2286
2467
|
/** Icon URL or absolute path for the agent. */
|
|
2287
2468
|
icon?: string;
|
|
2288
2469
|
}
|
|
2289
2470
|
|
|
2471
|
+
/**
|
|
2472
|
+
* Options for generating a model file.
|
|
2473
|
+
*/
|
|
2474
|
+
interface GenerateModelFileOptions {
|
|
2475
|
+
/** The provider export name (e.g., 'openai', 'openrouter') */
|
|
2476
|
+
providerName: string;
|
|
2477
|
+
/** The provider package (e.g., '@standardagents/openai') */
|
|
2478
|
+
providerPackage: string;
|
|
2479
|
+
}
|
|
2290
2480
|
/**
|
|
2291
2481
|
* Generate a TypeScript file for a model definition.
|
|
2482
|
+
*
|
|
2483
|
+
* @param data - The model definition data
|
|
2484
|
+
* @param options - Provider import options (required since providers are functions)
|
|
2292
2485
|
*/
|
|
2293
|
-
declare function generateModelFile(data: ModelDefinition): string;
|
|
2486
|
+
declare function generateModelFile(data: ModelDefinition, options: GenerateModelFileOptions): string;
|
|
2294
2487
|
|
|
2295
2488
|
/**
|
|
2296
2489
|
* Converts JSON Schema to Zod code string.
|
|
@@ -2329,6 +2522,8 @@ interface ToolConfigInput {
|
|
|
2329
2522
|
include_tool_calls?: boolean;
|
|
2330
2523
|
include_errors?: boolean;
|
|
2331
2524
|
init_user_message_property?: string | null;
|
|
2525
|
+
init_attachments_property?: string | null;
|
|
2526
|
+
tenvs?: Record<string, unknown>;
|
|
2332
2527
|
}
|
|
2333
2528
|
/**
|
|
2334
2529
|
* Prompt part as it comes from the UI/API.
|
|
@@ -3447,4 +3642,15 @@ declare class GitHubApiError extends Error {
|
|
|
3447
3642
|
constructor(message: string, status: number, details?: unknown);
|
|
3448
3643
|
}
|
|
3449
3644
|
|
|
3450
|
-
|
|
3645
|
+
/** @public Alias for LLMProviderInterface */
|
|
3646
|
+
type Provider = LLMProviderInterface;
|
|
3647
|
+
/** @public Alias for ContentPart */
|
|
3648
|
+
type ProviderContentPart = ContentPart;
|
|
3649
|
+
/** @public Alias for TextPart */
|
|
3650
|
+
type ProviderTextPart = TextPart;
|
|
3651
|
+
/** @public Alias for ImagePart */
|
|
3652
|
+
type ProviderImagePart = ImagePart;
|
|
3653
|
+
/** @public Alias for FilePart */
|
|
3654
|
+
type ProviderFilePart = FilePart;
|
|
3655
|
+
|
|
3656
|
+
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 };
|