@standardagents/builder 0.9.13 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { AgentPluginOptions, agentbuilder } from './plugin.js';
2
2
  import { DurableObjectStorage } from '@cloudflare/workers-types';
3
- import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
4
3
  import { z, ZodString, ZodNumber, ZodBoolean, ZodNull, ZodLiteral, ZodEnum, ZodOptional, ZodNullable, ZodDefault, ZodArray, ZodObject, ZodRecord, ZodUnion } from 'zod';
5
4
  import { DurableObject } from 'cloudflare:workers';
6
5
  import 'vite';
@@ -145,6 +144,19 @@ declare class StreamManager {
145
144
  forceClose(): void;
146
145
  }
147
146
 
147
+ /**
148
+ * Content item types that can be returned by tools
149
+ */
150
+ interface TextContent {
151
+ type: "text";
152
+ text: string;
153
+ }
154
+ interface ImageContent {
155
+ type: "image";
156
+ data: string;
157
+ mimeType: string;
158
+ }
159
+ type ToolContent = TextContent | ImageContent;
148
160
  /** Decrement helper to stop recursion at depth 0 */
149
161
  type Dec<N extends number> = N extends 10 ? 9 : N extends 9 ? 8 : N extends 8 ? 7 : N extends 7 ? 6 : N extends 6 ? 5 : N extends 5 ? 4 : N extends 4 ? 3 : N extends 3 ? 2 : N extends 2 ? 1 : N extends 1 ? 0 : 0;
150
162
  /**
@@ -168,7 +180,7 @@ type StructuredToolReturn = ToolArgs;
168
180
  /**
169
181
  * Defines a tool function. Tools accept the current flow state as well as the arguments being passed to them.
170
182
  */
171
- type Tool<Args extends ToolArgs | null = null> = Args extends ToolArgs ? (flow: FlowState, args: z.infer<Args>) => Promise<CallToolResult> : (flow: FlowState) => Promise<CallToolResult>;
183
+ type Tool<Args extends ToolArgs | null = null> = Args extends ToolArgs ? (flow: FlowState, args: z.infer<Args>) => Promise<ToolResult> : (flow: FlowState) => Promise<ToolResult>;
172
184
  /**
173
185
  * @param toolDescription - Description of what the tool does.
174
186
  * @param args - The arguments for the tool.
@@ -338,6 +350,11 @@ interface ThreadInstance {
338
350
  shouldStop(): Promise<boolean>;
339
351
  tools(): Record<string, () => Promise<ReturnType<typeof defineTool>>>;
340
352
  hooks(): HookRegistry;
353
+ loadModel(name: string): Promise<any>;
354
+ loadPrompt(name: string): Promise<any>;
355
+ loadAgent(name: string): Promise<any>;
356
+ getPromptNames(): string[];
357
+ getAgentNames(): string[];
341
358
  }
342
359
  /**
343
360
  * Tool call for internal flow management
@@ -659,12 +676,31 @@ interface LogData {
659
676
  interface ThreadEnv {
660
677
  AGENT_BUILDER_THREAD: DurableObjectNamespace<Rpc.DurableObjectBranded>;
661
678
  AGENT_BUILDER: DurableObjectNamespace<Rpc.DurableObjectBranded>;
679
+ [key: string]: unknown;
662
680
  }
681
+ /**
682
+ * Virtual module registry types (injected at runtime by plugin)
683
+ */
684
+ type VirtualModuleLoader<T> = () => Promise<T>;
685
+ type VirtualModuleRegistry<T> = Record<string, VirtualModuleLoader<T>>;
686
+ /**
687
+ * Controller context passed to route handlers.
688
+ * Includes optional virtual module registries that are injected at runtime.
689
+ */
663
690
  interface ControllerContext<Env = any> {
664
691
  req: Request;
665
692
  params: Record<string, string>;
666
693
  env: Env;
667
694
  url: URL;
695
+ agents?: VirtualModuleRegistry<unknown>;
696
+ agentNames?: string[];
697
+ prompts?: VirtualModuleRegistry<unknown>;
698
+ promptNames?: string[];
699
+ models?: VirtualModuleRegistry<unknown>;
700
+ modelNames?: string[];
701
+ tools?: VirtualModuleRegistry<unknown>;
702
+ hooks?: VirtualModuleRegistry<unknown>;
703
+ config?: Record<string, unknown>;
668
704
  }
669
705
  type Controller<Env = any> = (context: ControllerContext<Env>) => string | Promise<string> | Response | Promise<Response> | ReadableStream | Promise<ReadableStream> | null | Promise<null> | void | Promise<void> | Promise<object> | object;
670
706
  interface ThreadEndpointContext {
@@ -1518,8 +1554,9 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
1518
1554
  * - `openrouter` → `OPENROUTER_API_KEY`
1519
1555
  * - `anthropic` → `ANTHROPIC_API_KEY`
1520
1556
  * - `google` → `GOOGLE_API_KEY`
1557
+ * - `test` → No API key required (for testing with scripted responses)
1521
1558
  */
1522
- type ModelProvider = 'openai' | 'openrouter' | 'anthropic' | 'google';
1559
+ type ModelProvider = 'openai' | 'openrouter' | 'anthropic' | 'google' | 'test';
1523
1560
  /**
1524
1561
  * Model definition configuration.
1525
1562
  *
@@ -2985,4 +3022,4 @@ declare class GitHubApiError extends Error {
2985
3022
  constructor(message: string, status: number, details?: unknown);
2986
3023
  }
2987
3024
 
2988
- export { type Agent, type AgentBuilderEnv, type AgentDefinition, type AgentType, type AuthContext, type AuthUser, type BroadcastOptions, type Controller, type ControllerContext, DurableAgentBuilder, DurableThread, type FlowResult, type FlowState, FlowStateSdk, type FlowStateWithSdk, GitHubApiError, GitHubClient, type GitHubCommitResult, type GitHubConfig, type GitHubFileChange, type HookSignatures, type InjectMessageOptions$1 as InjectMessageOptions, type LLMResponse, type Message, type ModelDefinition, type ModelProvider, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptInput, type PromptPart, type PromptTextPart, type Provider, type ReasoningConfig, type RequestContext, type SideConfig, type StructuredPrompt, type StructuredToolReturn, type TelemetryEvent, type ThreadEndpointContext, type ThreadEnv, type ThreadInstance, type ThreadMetadata, type ThreadRegistryEntry, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolCall, type ToolConfig, type ToolResult, type UpdateThreadParams, type User, authenticate, defineAgent, defineController, defineHook, defineModel, definePrompt, defineThreadEndpoint, defineTool, emitThreadEvent, enhanceFlowState, forceTurn, generateAgentFile, generateModelFile, generatePromptFile, getMessages, injectMessage, queueTool, reloadHistory, requireAdmin, requireAuth, updateThread };
3025
+ export { type Agent, type AgentBuilderEnv, type AgentDefinition, type AgentType, type AuthContext, type AuthUser, type BroadcastOptions, type Controller, type ControllerContext, DurableAgentBuilder, DurableThread, type FlowResult, type FlowState, FlowStateSdk, type FlowStateWithSdk, GitHubApiError, GitHubClient, type GitHubCommitResult, type GitHubConfig, type GitHubFileChange, type HookSignatures, type ImageContent, type InjectMessageOptions$1 as InjectMessageOptions, type LLMResponse, type Message, type ModelDefinition, type ModelProvider, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptInput, type PromptPart, type PromptTextPart, type Provider, type ReasoningConfig, type RequestContext, type SideConfig, type StructuredPrompt, type StructuredToolReturn, type TelemetryEvent, type TextContent, type ThreadEndpointContext, type ThreadEnv, type ThreadInstance, type ThreadMetadata, type ThreadRegistryEntry, type Tool, type ToolArgs, type ToolArgsNode, type ToolArgsRawShape, type ToolCall, type ToolConfig, type ToolContent, type ToolResult, type UpdateThreadParams, type User, authenticate, defineAgent, defineController, defineHook, defineModel, definePrompt, defineThreadEndpoint, defineTool, emitThreadEvent, enhanceFlowState, forceTurn, generateAgentFile, generateModelFile, generatePromptFile, getMessages, injectMessage, queueTool, reloadHistory, requireAdmin, requireAuth, updateThread };