@standardagents/builder 0.27.13 → 0.28.0
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 +262 -19
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-DReIS8eP.d.ts → index-BzXyIJPA.d.ts} +163 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +898 -36
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +24 -2
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +127 -5
- package/dist/runtime.js +844 -34
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as ThreadEnv, A as Agent,
|
|
2
|
-
export { f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext,
|
|
3
|
-
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput,
|
|
1
|
+
import { e as ThreadEnv, A as Agent, r as ThreadMetadata, t as ToolResult, M as Message, k as ClientToolRequest, l as ClientToolResponse, m as ClientStreamRequest, n as ClientStreamResponse, w as FileRecord, F as FlowState, y as FileStats, G as GrepResult, x as AttachmentRef, J as MessageContent, E as Env, q as ThreadInstance } from './index-BzXyIJPA.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, B as Controller, a as ControllerContext, u as FlowResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, T as ToolCall, c as createThreadEndpointHandler, d as defineController } from './index-BzXyIJPA.js';
|
|
3
|
+
import { CodeExecutionOptions, CodeExecutionResult, SubagentRegistryEntry, InjectMessageInput, QueueMessageInput, SkillMetadata, SkillFileInput, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, PromptEnvPart, VariableDefinition, SubpromptConfig as SubpromptConfig$1, PromptToolConfig as PromptToolConfig$1, SubagentToolConfig as SubagentToolConfig$1, ReasoningConfig, SideConfig as SideConfig$1, LLMProviderInterface, ContentPart, TextPart, ImagePart, FilePart, ThreadState, NamespaceContext, DefinitionLoader } from '@standardagents/spec';
|
|
4
4
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, 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, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel } from '@standardagents/spec';
|
|
5
5
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
6
6
|
import { N as NamespacedRegistry } from './types-Bpe7IANZ.js';
|
|
@@ -207,6 +207,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
207
207
|
private bridgeClientInfo;
|
|
208
208
|
private executionOwnerCache;
|
|
209
209
|
private pendingClientCalls;
|
|
210
|
+
private clientStreams;
|
|
210
211
|
private alarmQueue;
|
|
211
212
|
private alarmQueueRearmed;
|
|
212
213
|
private currentAbortController;
|
|
@@ -605,6 +606,22 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
605
606
|
* Stop the currently executing thread (RPC method)
|
|
606
607
|
* Simple "off" switch - stops turns, only cleared by user messages
|
|
607
608
|
*/
|
|
609
|
+
/**
|
|
610
|
+
* Flip every still-`pending` message to `failed` and broadcast the change to
|
|
611
|
+
* all connected heads. This is THE settle path for any terminal condition
|
|
612
|
+
* that leaves a turn half-open — user stop, lost execution, terminal
|
|
613
|
+
* execution failure, and expired parked forwarded calls — so no head is
|
|
614
|
+
* left rendering a stuck "Working" state. Returns the failure timestamp.
|
|
615
|
+
*/
|
|
616
|
+
failPendingMessagesAndBroadcast(): Promise<number>;
|
|
617
|
+
/**
|
|
618
|
+
* A terminal failure ended a turn without a normal assistant reply: settle
|
|
619
|
+
* every pending message and persist a durable `failed` assistant message so
|
|
620
|
+
* all connected heads land on a real, visible end state — never a stuck
|
|
621
|
+
* "Working" spinner. Used by the FlowEngine's terminal catch and the parked
|
|
622
|
+
* forwarded-call TTL.
|
|
623
|
+
*/
|
|
624
|
+
settleTerminalFailure(errorMessage: string): Promise<void>;
|
|
608
625
|
stop(): Promise<Response>;
|
|
609
626
|
/**
|
|
610
627
|
* Continue execution from where it stopped (RPC method)
|
|
@@ -1093,6 +1110,50 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1093
1110
|
deliverClientToolResult(toolCallId: string, ok: boolean, result?: string, error?: string, deliveredByClientId?: string, deliveredGeneration?: number): Promise<{
|
|
1094
1111
|
side: "a" | "b";
|
|
1095
1112
|
} | null>;
|
|
1113
|
+
/** Default time to wait for the client to accept a stream open. */
|
|
1114
|
+
private static readonly CLIENT_STREAM_OPEN_TIMEOUT_MS;
|
|
1115
|
+
/** Open a bidirectional byte stream to the connected owner client. */
|
|
1116
|
+
openClientStream(request: ClientStreamRequest): Promise<ClientStreamResponse>;
|
|
1117
|
+
private proxyStreams;
|
|
1118
|
+
proxyStreamOpen(request: ClientStreamRequest): Promise<{
|
|
1119
|
+
ok: boolean;
|
|
1120
|
+
id?: string;
|
|
1121
|
+
error?: string;
|
|
1122
|
+
noClient?: boolean;
|
|
1123
|
+
}>;
|
|
1124
|
+
proxyStreamWrite(id: string, dataB64: string): Promise<void>;
|
|
1125
|
+
proxyStreamPull(id: string): Promise<{
|
|
1126
|
+
chunks: string[];
|
|
1127
|
+
done: boolean;
|
|
1128
|
+
error?: string;
|
|
1129
|
+
}>;
|
|
1130
|
+
proxyStreamEnd(id: string): Promise<void>;
|
|
1131
|
+
proxyStreamAbort(id: string): Promise<void>;
|
|
1132
|
+
/** Settle and remove a client stream exactly once. */
|
|
1133
|
+
private settleClientStream;
|
|
1134
|
+
/** Abort a stream from the Worker side, telling the client to tear down. */
|
|
1135
|
+
private abortClientStream;
|
|
1136
|
+
/** Handle an incoming stream_* frame from a bridge client. */
|
|
1137
|
+
private handleClientStreamFrame;
|
|
1138
|
+
/** Fail every stream bound to a socket that closed or died. */
|
|
1139
|
+
private failClientStreamsForSocket;
|
|
1140
|
+
/** How long a parked forwarded call waits for a client before failing visibly. */
|
|
1141
|
+
private static readonly CLIENT_PARK_TTL_MS;
|
|
1142
|
+
/**
|
|
1143
|
+
* A forwarded call parked with NO client attached: ask the user's hub to
|
|
1144
|
+
* summon the owning machine's daemon to this thread, and arm the bounded
|
|
1145
|
+
* park TTL that turns an unreachable host into a visible durable failure
|
|
1146
|
+
* instead of a silent hang.
|
|
1147
|
+
*/
|
|
1148
|
+
notifyClientWaiting(toolCallId: string, threadId: string, userId: string | null): Promise<void>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Park TTL expired: if the call is still pending, settle it as a durable,
|
|
1151
|
+
* VISIBLE failure — rewrite the waiting placeholder, mark the pending row
|
|
1152
|
+
* failed, fail any still-pending assistant messages, and persist a durable
|
|
1153
|
+
* failed assistant message so every connected head settles instead of
|
|
1154
|
+
* showing "Working" forever.
|
|
1155
|
+
*/
|
|
1156
|
+
private failParkedClientCall;
|
|
1096
1157
|
/**
|
|
1097
1158
|
* Broadcast a log record to all connected WebSocket clients
|
|
1098
1159
|
*/
|
|
@@ -1590,6 +1651,59 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1590
1651
|
}>;
|
|
1591
1652
|
}
|
|
1592
1653
|
|
|
1654
|
+
interface DurableUserHubEnv {
|
|
1655
|
+
[key: string]: unknown;
|
|
1656
|
+
}
|
|
1657
|
+
interface HubClientInfo {
|
|
1658
|
+
clientId: string | null;
|
|
1659
|
+
clientName: string | null;
|
|
1660
|
+
clientKind: string | null;
|
|
1661
|
+
}
|
|
1662
|
+
declare class DurableUserHub extends DurableObject<DurableUserHubEnv> {
|
|
1663
|
+
/** Persistent client (daemon) sockets, restored across hibernation. */
|
|
1664
|
+
private clientSockets;
|
|
1665
|
+
private clientInfo;
|
|
1666
|
+
private migrated;
|
|
1667
|
+
constructor(ctx: DurableObjectState, env: DurableUserHubEnv);
|
|
1668
|
+
private ensureMigrated;
|
|
1669
|
+
/**
|
|
1670
|
+
* Accept the user's persistent client (daemon) WebSocket. The daemon holds
|
|
1671
|
+
* this ONE socket for its whole lifetime; per-thread bridge sockets are
|
|
1672
|
+
* opened separately and only while a thread is active.
|
|
1673
|
+
*/
|
|
1674
|
+
fetch(request: Request): Promise<Response>;
|
|
1675
|
+
webSocketMessage(ws: WebSocket, _message: string | ArrayBuffer): Promise<void>;
|
|
1676
|
+
webSocketClose(ws: WebSocket): Promise<void>;
|
|
1677
|
+
webSocketError(ws: WebSocket): Promise<void>;
|
|
1678
|
+
/** Whether a persistent client (daemon) is connected right now. */
|
|
1679
|
+
hasClient(): Promise<boolean>;
|
|
1680
|
+
/**
|
|
1681
|
+
* Signal the connected daemon to attach a bridge to `threadId`. Called by a
|
|
1682
|
+
* cold thread DO that parked a forwarded call with no client attached. The
|
|
1683
|
+
* daemon reacts by opening a per-thread bridge socket, which triggers the
|
|
1684
|
+
* thread's drain-on-attach. Returns whether a daemon was reachable.
|
|
1685
|
+
*/
|
|
1686
|
+
requestWake(threadId: string): Promise<{
|
|
1687
|
+
delivered: boolean;
|
|
1688
|
+
}>;
|
|
1689
|
+
getUserValue(userId: string, key: string): Promise<unknown | null>;
|
|
1690
|
+
setUserValue(userId: string, key: string, value: unknown): Promise<void>;
|
|
1691
|
+
listUserValues(userId: string, options?: {
|
|
1692
|
+
prefix?: string | null;
|
|
1693
|
+
limit?: number;
|
|
1694
|
+
offset?: number;
|
|
1695
|
+
}): Promise<{
|
|
1696
|
+
entries: Array<{
|
|
1697
|
+
key: string;
|
|
1698
|
+
value: unknown;
|
|
1699
|
+
updated_at: number;
|
|
1700
|
+
}>;
|
|
1701
|
+
total: number;
|
|
1702
|
+
limit: number;
|
|
1703
|
+
offset: number;
|
|
1704
|
+
}>;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1593
1707
|
type EnvValueType = 'text' | 'secret';
|
|
1594
1708
|
/**
|
|
1595
1709
|
* Environment type for DurableAgentBuilder.
|
|
@@ -1598,6 +1712,7 @@ type EnvValueType = 'text' | 'secret';
|
|
|
1598
1712
|
interface AgentBuilderEnv {
|
|
1599
1713
|
AGENT_BUILDER: DurableObjectNamespace<DurableAgentBuilder>;
|
|
1600
1714
|
AGENT_BUILDER_THREAD: DurableObjectNamespace;
|
|
1715
|
+
AGENT_BUILDER_USER_HUB?: DurableObjectNamespace<DurableUserHub>;
|
|
1601
1716
|
ENCRYPTION_KEY?: string;
|
|
1602
1717
|
}
|
|
1603
1718
|
/**
|
|
@@ -1898,6 +2013,13 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1898
2013
|
}): Promise<void>;
|
|
1899
2014
|
private assertValidUserValueKey;
|
|
1900
2015
|
private assertValidUserValueUserId;
|
|
2016
|
+
/**
|
|
2017
|
+
* The per-user hub is the sharded home for account-wide KV. When the binding
|
|
2018
|
+
* exists, the singleton delegates so the global object is no longer a
|
|
2019
|
+
* per-user bottleneck; without it (pre-hub deploys, unit tests) it keeps the
|
|
2020
|
+
* local `user_values` table.
|
|
2021
|
+
*/
|
|
2022
|
+
private userHub;
|
|
1901
2023
|
/** Read one JSON value from a user's account-wide key-value store. */
|
|
1902
2024
|
getUserValue(userId: string, key: string): Promise<unknown | null>;
|
|
1903
2025
|
/** Write one JSON value to a user's account-wide store; null/undefined deletes. */
|
|
@@ -3642,7 +3764,7 @@ declare class ProviderRegistryImpl {
|
|
|
3642
3764
|
* @param thread - Thread instance for loading model from virtual modules
|
|
3643
3765
|
* @returns Provider and model definition
|
|
3644
3766
|
*/
|
|
3645
|
-
getProvider(modelName: string, env: Env, thread?: ThreadInstance): Promise<ProviderLookupResult>;
|
|
3767
|
+
getProvider(modelName: string, env: Env, thread?: ThreadInstance, getState?: () => Promise<ThreadState>): Promise<ProviderLookupResult>;
|
|
3646
3768
|
private buildResult;
|
|
3647
3769
|
private cacheAndReturn;
|
|
3648
3770
|
private getProviderFingerprint;
|
|
@@ -3805,4 +3927,4 @@ declare function createNamespaceContext(agentDef: {
|
|
|
3805
3927
|
*/
|
|
3806
3928
|
declare function isQualifiedName(name: string): boolean;
|
|
3807
3929
|
|
|
3808
|
-
export { Agent, type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, Env, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GrepResult, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type PromptToolConfig, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, ProviderRegistry, type ProviderTextPart, type SessionToolBinding, type SessionToolConfig, type SideConfig, type SubagentToolConfig, type SubpromptConfig, ThreadEnv, ThreadInstance, ThreadMetadata, type ThreadRegistryEntry, ThreadWatchdog, type ThreadWatchdogState, type ToolConfig, ToolResult, type UpdateThreadParams, type User, type WatchdogCheckin, type WatchdogProbeResult, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
|
3930
|
+
export { Agent, type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, Env, FileRecord, FileStats, FlowState, FlowStateSdk, type FlowStateWithSdk, GrepResult, type HubClientInfo, type ImageContextConfig, type InjectMessageOptions$1 as InjectMessageOptions, type Provider as LLMProviderInterface, Message, MessageContent, type ModelDefinition, NamespaceResolutionError, NamespacedRegistry, type PromptContent, type PromptDefinition, type PromptIncludePart, type PromptPart, type PromptToolConfig, type Provider$1 as Provider, type ProviderContentPart, type ProviderFilePart, type ProviderImagePart, ProviderRegistry, type ProviderTextPart, type SessionToolBinding, type SessionToolConfig, type SideConfig, type SubagentToolConfig, type SubpromptConfig, ThreadEnv, ThreadInstance, ThreadMetadata, type ThreadRegistryEntry, ThreadWatchdog, type ThreadWatchdogState, type ToolConfig, ToolResult, type UpdateThreadParams, type User, type WatchdogCheckin, type WatchdogProbeResult, authenticate, buildImageDescription, cat, createNamespaceContext, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|