@standardagents/builder 0.29.0 → 0.29.1
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 +5 -3
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-Cp_Zcrhy.d.ts → index-BNLDsLsL.d.ts} +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +17 -2
- package/dist/runtime.js +40 -3
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
|
@@ -131,6 +131,18 @@ interface ClientStreamRequest {
|
|
|
131
131
|
meta?: Record<string, unknown>;
|
|
132
132
|
/** Milliseconds to wait for the client to accept the stream. */
|
|
133
133
|
timeoutMs?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Builder-internal reconnect hint, never sent to the client: when the
|
|
136
|
+
* thread's elected execution owner has no live socket, ask this user's hub
|
|
137
|
+
* to summon the owning machine's daemon to `threadId` and wait for the
|
|
138
|
+
* bridge to re-attach before failing the open. Without it a transient
|
|
139
|
+
* disconnect (daemon restart, network blip) surfaces instantly as
|
|
140
|
+
* "workspace unavailable" mid-turn.
|
|
141
|
+
*/
|
|
142
|
+
wake?: {
|
|
143
|
+
threadId: string;
|
|
144
|
+
userId: string;
|
|
145
|
+
};
|
|
134
146
|
}
|
|
135
147
|
/**
|
|
136
148
|
* A live bidirectional byte pipe between the thread runtime and the client.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModelDefinition, AgentDefinition } from './runtime.js';
|
|
2
2
|
export { AgentBuilderEnv, AuthContext, AuthUser, BroadcastOptions, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, FlowStateWithSdk, HubClientInfo, ImageContextConfig, InjectMessageOptions, LLMProviderInterface, NamespaceResolutionError, PromptContent, PromptDefinition, PromptIncludePart, PromptPart, PromptToolConfig, Provider, ProviderContentPart, ProviderFilePart, ProviderImagePart, ProviderRegistry, ProviderTextPart, SessionToolBinding, SessionToolConfig, SideConfig, SubagentToolConfig, SubpromptConfig, ThreadRegistryEntry, ThreadWatchdog, ThreadWatchdogState, ToolConfig, UpdateThreadParams, User, WatchdogCheckin, 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 } from './runtime.js';
|
|
3
3
|
export { AgentPluginOptions, agentbuilder, builder } from './plugin.js';
|
|
4
|
-
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-
|
|
4
|
+
export { A as Agent, x as AttachmentRef, f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, m as ClientStreamRequest, n as ClientStreamResponse, k as ClientToolRequest, l as ClientToolResponse, B as Controller, a as ControllerContext, E as Env, w as FileRecord, y as FileStats, u as FlowResult, F as FlowState, G as GrepResult, D as ImageContentPart, I as ImageMetadata, L as LLMResponse, M as Message, J as MessageContent, H as MultimodalContent, R as RequestContext, S as StorageBackend, v as TelemetryEvent, z as TextContentPart, b as ThreadEndpointContext, e as ThreadEnv, q as ThreadInstance, r as ThreadMetadata, T as ToolCall, t as ToolResult, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-BNLDsLsL.js';
|
|
5
5
|
export { AgentType, DefinitionLoader, GlobalNamespaceContext, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, NamespaceContext, PackageSignature, PackedExports, PackedMeta, PackedMetadata, PackedNamespaceContext, PromptInput, PromptTextPart, ProviderAssistantMessage, ProviderConfigSlot, ProviderConfigSlots, ProviderConfigValueSource, ProviderDefinition, ProviderError, ProviderErrorCode, ProviderFactory, ProviderFactoryConfig, ProviderFinishReason, ProviderGeneratedImage, ProviderMessage, ProviderMessageContent, ProviderMethodOverrides, ModelCapabilities as ProviderModelCapabilities, ProviderOverride, ProviderOverrideContext, ProviderReasoningDetail, ProviderRequest, ProviderResponse, ProviderStreamChunk, ProviderSyncOverride, ProviderSystemMessage, ProviderTool, ProviderToolCallPart, ProviderToolMessage, ProviderToolResultContent, ProviderUsage, ProviderUserMessage, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, belongsToPackage, defineAgent, defineHook, defineModel, definePrompt, defineProvider, defineTool, isPacked, isVisibleInNamespace, mapReasoningLevel, providerConst, providerEnv, providerValue } from '@standardagents/spec';
|
|
6
6
|
export { C as ConstituentItem, D as DiscoveredPackage, N as NamespacedRegistry, P as PackingAnalysis, a as PackingOptions, b as PackingResult, c as UnpackOptions, d as UnpackResult } from './types-Bpe7IANZ.js';
|
|
7
7
|
export { D as DiscoveryConfig, P as PackageDiscoveryService, d as discoverPackages } from './discovery-DiMJWisl.js';
|
package/dist/index.js
CHANGED
|
@@ -13592,7 +13592,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
13592
13592
|
error: "This thread runtime cannot open client streams. Client streaming requires the DurableThread bridge."
|
|
13593
13593
|
};
|
|
13594
13594
|
}
|
|
13595
|
-
const
|
|
13595
|
+
const wakeUserId = this._metadata.user_id ?? null;
|
|
13596
|
+
const withWake = (threadId) => wakeUserId ? { ...request, wake: { threadId, userId: wakeUserId } } : request;
|
|
13597
|
+
const local = await instance.openClientStream(withWake(this._metadata.id));
|
|
13596
13598
|
if (local.ok || !this.isNoClient(local)) return local;
|
|
13597
13599
|
const env = this._threadInstance.env;
|
|
13598
13600
|
if (!env?.AGENT_BUILDER_THREAD) return local;
|
|
@@ -13603,7 +13605,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13603
13605
|
try {
|
|
13604
13606
|
const stub = env.AGENT_BUILDER_THREAD.get(env.AGENT_BUILDER_THREAD.idFromName(parentId));
|
|
13605
13607
|
if (typeof stub.proxyStreamOpen === "function") {
|
|
13606
|
-
const opened = await stub.proxyStreamOpen(
|
|
13608
|
+
const opened = await stub.proxyStreamOpen(withWake(parentId));
|
|
13607
13609
|
if (opened.ok && opened.id) {
|
|
13608
13610
|
return { ok: true, duplex: this.buildProxyDuplex(stub, opened.id) };
|
|
13609
13611
|
}
|
|
@@ -28670,10 +28672,40 @@ ${resultContent}${attachmentSummary}`;
|
|
|
28670
28672
|
// they are bound to one bridge socket and never park.
|
|
28671
28673
|
/** Default time to wait for the client to accept a stream open. */
|
|
28672
28674
|
static CLIENT_STREAM_OPEN_TIMEOUT_MS = 3e4;
|
|
28675
|
+
/** Poll cadence while waiting for a disconnected owner's bridge to return. */
|
|
28676
|
+
static OWNER_REATTACH_POLL_MS = 250;
|
|
28677
|
+
/**
|
|
28678
|
+
* The thread HAS an elected execution owner, but its bridge socket is gone
|
|
28679
|
+
* (daemon restart, network blip, DO handoff). Summon the owning machine
|
|
28680
|
+
* through the per-user hub and wait for a bridge to re-attach instead of
|
|
28681
|
+
* failing the stream open instantly — that instant failure is what ended
|
|
28682
|
+
* Sama One turns with "workspace unavailable" whenever a slow tool/approval
|
|
28683
|
+
* outlived the socket. Threads with NO recorded owner (subagent children)
|
|
28684
|
+
* still fail fast so ancestor walk-up routing stays immediate.
|
|
28685
|
+
*/
|
|
28686
|
+
async awaitOwnerBridgeSocket(request) {
|
|
28687
|
+
if (request.wake?.userId) {
|
|
28688
|
+
void this.requestHubWake(request.wake.userId, request.wake.threadId);
|
|
28689
|
+
}
|
|
28690
|
+
const timeoutMs = typeof request.timeoutMs === "number" && request.timeoutMs > 0 ? request.timeoutMs : _DurableThread.CLIENT_STREAM_OPEN_TIMEOUT_MS;
|
|
28691
|
+
const deadline = Date.now() + timeoutMs;
|
|
28692
|
+
while (Date.now() < deadline) {
|
|
28693
|
+
await new Promise(
|
|
28694
|
+
(resolve2) => setTimeout(resolve2, _DurableThread.OWNER_REATTACH_POLL_MS)
|
|
28695
|
+
);
|
|
28696
|
+
const owner = await this.getExecutionOwner();
|
|
28697
|
+
const socket = this.getOpenBridgeSocket(owner?.client_id ?? null);
|
|
28698
|
+
if (socket) return socket;
|
|
28699
|
+
}
|
|
28700
|
+
return null;
|
|
28701
|
+
}
|
|
28673
28702
|
/** Open a bidirectional byte stream to the connected owner client. */
|
|
28674
28703
|
async openClientStream(request) {
|
|
28675
28704
|
const owner = await this.getExecutionOwner();
|
|
28676
|
-
|
|
28705
|
+
let socket = this.getOpenBridgeSocket(owner?.client_id ?? null);
|
|
28706
|
+
if (!socket && owner) {
|
|
28707
|
+
socket = await this.awaitOwnerBridgeSocket(request);
|
|
28708
|
+
}
|
|
28677
28709
|
if (!socket) {
|
|
28678
28710
|
return {
|
|
28679
28711
|
ok: false,
|
|
@@ -28967,6 +28999,11 @@ ${resultContent}${attachmentSummary}`;
|
|
|
28967
28999
|
console.error("[DurableThread] Failed to arm park TTL (non-fatal):", error);
|
|
28968
29000
|
}
|
|
28969
29001
|
if (!userId) return;
|
|
29002
|
+
await this.requestHubWake(userId, threadId);
|
|
29003
|
+
}
|
|
29004
|
+
/** Ask the user's hub to summon the owning machine's daemon to a thread.
|
|
29005
|
+
* Best-effort: wake failure must never fail the caller's own path. */
|
|
29006
|
+
async requestHubWake(userId, threadId) {
|
|
28970
29007
|
try {
|
|
28971
29008
|
const namespace = this.env.AGENT_BUILDER_USER_HUB;
|
|
28972
29009
|
if (!namespace) return;
|