@standardagents/builder 0.28.0 → 0.29.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 +62 -10
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-BzXyIJPA.d.ts → index-Cp_Zcrhy.d.ts} +10 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +111 -25
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +4 -3
- package/dist/runtime.js +142 -26
- 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,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-Cp_Zcrhy.js';
|
|
2
|
+
export { f as BuilderThreadEndpointHandler, C as CLIENT_STREAM_CHUNK_BYTES, o as ClientDuplex, p as ClientForwarding, 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, g as callClient, h as callClientStream, c as createThreadEndpointHandler, j as decodeStreamChunk, d as defineController, i as encodeStreamChunk, s as supportsClientForwarding } from './index-Cp_Zcrhy.js';
|
|
3
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';
|
|
@@ -1120,6 +1120,7 @@ declare class DurableThread<Env extends ThreadEnv = ThreadEnv> extends DurableOb
|
|
|
1120
1120
|
id?: string;
|
|
1121
1121
|
error?: string;
|
|
1122
1122
|
noClient?: boolean;
|
|
1123
|
+
code?: 'unsupported' | 'unavailable' | 'refused' | 'timeout';
|
|
1123
1124
|
}>;
|
|
1124
1125
|
proxyStreamWrite(id: string, dataB64: string): Promise<void>;
|
|
1125
1126
|
proxyStreamPull(id: string): Promise<{
|
|
@@ -3927,4 +3928,4 @@ declare function createNamespaceContext(agentDef: {
|
|
|
3927
3928
|
*/
|
|
3928
3929
|
declare function isQualifiedName(name: string): boolean;
|
|
3929
3930
|
|
|
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 };
|
|
3931
|
+
export { Agent, type AgentBuilderEnv, type AgentDefinition, AttachmentRef, type AuthContext, type AuthUser, type BroadcastOptions, ClientStreamRequest, ClientStreamResponse, ClientToolRequest, ClientToolResponse, 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 };
|
package/dist/runtime.js
CHANGED
|
@@ -29,6 +29,90 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
|
|
31
31
|
// src/agents/client-forwarding.ts
|
|
32
|
+
function asForwarding(state) {
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
function supportsClientForwarding(state) {
|
|
36
|
+
const s = asForwarding(state);
|
|
37
|
+
return typeof s.callClient === "function" && typeof s.callClientStream === "function";
|
|
38
|
+
}
|
|
39
|
+
function callClient(state, request) {
|
|
40
|
+
const s = asForwarding(state);
|
|
41
|
+
if (typeof s.callClient !== "function") {
|
|
42
|
+
return Promise.resolve({
|
|
43
|
+
ok: false,
|
|
44
|
+
error: "This thread runtime cannot forward tools to a client. Client forwarding requires the DurableThread bridge."
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return s.callClient(request);
|
|
48
|
+
}
|
|
49
|
+
function callClientStream(state, request) {
|
|
50
|
+
if (state.runtimeStreams) {
|
|
51
|
+
return state.runtimeStreams.open({
|
|
52
|
+
capability: request.tool,
|
|
53
|
+
metadata: request.meta,
|
|
54
|
+
timeoutMs: request.timeoutMs
|
|
55
|
+
}).then(
|
|
56
|
+
(opened) => opened.ok ? {
|
|
57
|
+
ok: true,
|
|
58
|
+
duplex: {
|
|
59
|
+
readable: opened.stream.readable,
|
|
60
|
+
writable: opened.stream.writable,
|
|
61
|
+
close: (reason) => opened.stream.close(reason),
|
|
62
|
+
done: opened.stream.closed
|
|
63
|
+
}
|
|
64
|
+
} : {
|
|
65
|
+
ok: false,
|
|
66
|
+
error: opened.error,
|
|
67
|
+
data: opened.code ? {
|
|
68
|
+
code: opened.code,
|
|
69
|
+
noClient: opened.code === "unavailable" ? true : void 0
|
|
70
|
+
} : void 0
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const s = asForwarding(state);
|
|
75
|
+
if (typeof s.callClientStream !== "function") {
|
|
76
|
+
return Promise.resolve({
|
|
77
|
+
ok: false,
|
|
78
|
+
error: "This thread runtime cannot open client streams. Client streaming requires the DurableThread bridge."
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return s.callClientStream(request);
|
|
82
|
+
}
|
|
83
|
+
function createRuntimeStreams(openClientStream) {
|
|
84
|
+
return {
|
|
85
|
+
async open(request) {
|
|
86
|
+
const opened = await openClientStream({
|
|
87
|
+
tool: request.capability,
|
|
88
|
+
meta: request.metadata,
|
|
89
|
+
timeoutMs: request.timeoutMs
|
|
90
|
+
});
|
|
91
|
+
if (!opened.ok) {
|
|
92
|
+
const failureData = opened.data;
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
error: opened.error,
|
|
96
|
+
code: failureData?.code
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let closed = false;
|
|
100
|
+
return {
|
|
101
|
+
ok: true,
|
|
102
|
+
stream: {
|
|
103
|
+
readable: opened.duplex.readable,
|
|
104
|
+
writable: opened.duplex.writable,
|
|
105
|
+
closed: opened.duplex.done,
|
|
106
|
+
close: (reason) => {
|
|
107
|
+
if (closed) return;
|
|
108
|
+
closed = true;
|
|
109
|
+
opened.duplex.close(reason);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
32
116
|
function encodeStreamChunk(bytes) {
|
|
33
117
|
let binary = "";
|
|
34
118
|
const step = 32768;
|
|
@@ -12903,6 +12987,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
12903
12987
|
}
|
|
12904
12988
|
return this.getMetadataArguments();
|
|
12905
12989
|
}
|
|
12990
|
+
/**
|
|
12991
|
+
* Optional spec byte streams backed by the execution owner's existing
|
|
12992
|
+
* bridge. Streams are live resources: they proxy through ancestors when a
|
|
12993
|
+
* subagent opens one, but they never park or outlive a bridge disconnect.
|
|
12994
|
+
*/
|
|
12995
|
+
get runtimeStreams() {
|
|
12996
|
+
return createRuntimeStreams((request) => this.callClientStream(request));
|
|
12997
|
+
}
|
|
12906
12998
|
getMetadataArguments() {
|
|
12907
12999
|
const value = this._metadata.properties?.[SUBAGENT_INITIAL_ARGUMENTS_THREAD_PROPERTY];
|
|
12908
13000
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -13479,11 +13571,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
13479
13571
|
return local;
|
|
13480
13572
|
}
|
|
13481
13573
|
/**
|
|
13482
|
-
*
|
|
13483
|
-
*
|
|
13484
|
-
*
|
|
13485
|
-
* is attached. Subagents must not call this directly; they proxy whole
|
|
13486
|
-
* requests up to the root thread instead (request-up / stream-down).
|
|
13574
|
+
* Legacy bridge implementation used by `runtimeStreams`. Streams require a
|
|
13575
|
+
* live execution owner and never park. A child thread proxies the complete
|
|
13576
|
+
* request to the nearest bridge-holding ancestor (request-up/stream-down).
|
|
13487
13577
|
*/
|
|
13488
13578
|
async callClientStream(request) {
|
|
13489
13579
|
const instance = this._threadInstance;
|
|
@@ -13509,7 +13599,11 @@ var init_ThreadStateImpl = __esm({
|
|
|
13509
13599
|
return { ok: true, duplex: this.buildProxyDuplex(stub, opened.id) };
|
|
13510
13600
|
}
|
|
13511
13601
|
if (opened.error && !opened.noClient) {
|
|
13512
|
-
return {
|
|
13602
|
+
return {
|
|
13603
|
+
ok: false,
|
|
13604
|
+
error: opened.error,
|
|
13605
|
+
data: opened.code ? { code: opened.code } : void 0
|
|
13606
|
+
};
|
|
13513
13607
|
}
|
|
13514
13608
|
}
|
|
13515
13609
|
} catch {
|
|
@@ -13528,6 +13622,12 @@ var init_ThreadStateImpl = __esm({
|
|
|
13528
13622
|
let settleDone;
|
|
13529
13623
|
const done = new Promise((r) => settleDone = r);
|
|
13530
13624
|
let closed = false;
|
|
13625
|
+
let settled = false;
|
|
13626
|
+
const settle = (result) => {
|
|
13627
|
+
if (settled) return;
|
|
13628
|
+
settled = true;
|
|
13629
|
+
settleDone(result);
|
|
13630
|
+
};
|
|
13531
13631
|
const readable = new ReadableStream({
|
|
13532
13632
|
async pull(controller) {
|
|
13533
13633
|
while (!closed) {
|
|
@@ -13536,7 +13636,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13536
13636
|
res = await stub.proxyStreamPull(id);
|
|
13537
13637
|
} catch (error) {
|
|
13538
13638
|
controller.error(error instanceof Error ? error : new Error(String(error)));
|
|
13539
|
-
|
|
13639
|
+
settle({ ok: false, error: "proxy stream pull failed" });
|
|
13540
13640
|
return;
|
|
13541
13641
|
}
|
|
13542
13642
|
for (const chunk of res.chunks) {
|
|
@@ -13544,7 +13644,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13544
13644
|
}
|
|
13545
13645
|
if (res.done) {
|
|
13546
13646
|
controller.close();
|
|
13547
|
-
|
|
13647
|
+
settle(res.error ? { ok: false, error: res.error } : { ok: true });
|
|
13548
13648
|
return;
|
|
13549
13649
|
}
|
|
13550
13650
|
if (res.chunks.length > 0) return;
|
|
@@ -13555,6 +13655,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13555
13655
|
closed = true;
|
|
13556
13656
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13557
13657
|
});
|
|
13658
|
+
settle({ ok: false, error: "proxy stream reader canceled" });
|
|
13558
13659
|
}
|
|
13559
13660
|
});
|
|
13560
13661
|
const writable = new WritableStream({
|
|
@@ -13569,16 +13670,18 @@ var init_ThreadStateImpl = __esm({
|
|
|
13569
13670
|
closed = true;
|
|
13570
13671
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13571
13672
|
});
|
|
13673
|
+
settle({ ok: false, error: "proxy stream writer aborted" });
|
|
13572
13674
|
}
|
|
13573
13675
|
});
|
|
13574
13676
|
return {
|
|
13575
13677
|
readable,
|
|
13576
13678
|
writable,
|
|
13577
13679
|
close: (error) => {
|
|
13680
|
+
if (closed) return;
|
|
13578
13681
|
closed = true;
|
|
13579
13682
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13580
13683
|
});
|
|
13581
|
-
|
|
13684
|
+
settle(error ? { ok: false, error } : { ok: true });
|
|
13582
13685
|
},
|
|
13583
13686
|
done
|
|
13584
13687
|
};
|
|
@@ -14456,6 +14559,9 @@ async function requireAdmin(request, env) {
|
|
|
14456
14559
|
return result;
|
|
14457
14560
|
}
|
|
14458
14561
|
|
|
14562
|
+
// src/runtime.ts
|
|
14563
|
+
init_client_forwarding();
|
|
14564
|
+
|
|
14459
14565
|
// src/durable-objects/migrations/001_initial.ts
|
|
14460
14566
|
var migration = {
|
|
14461
14567
|
version: 1,
|
|
@@ -20217,12 +20323,10 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20217
20323
|
}
|
|
20218
20324
|
return { side };
|
|
20219
20325
|
}
|
|
20220
|
-
// ───
|
|
20221
|
-
//
|
|
20222
|
-
//
|
|
20223
|
-
//
|
|
20224
|
-
// duplex), so the client only ever relays ciphertext. Streams are bound to a
|
|
20225
|
-
// live socket and never park.
|
|
20326
|
+
// ─── Runtime byte streams ──────────────────────────────────────────────────
|
|
20327
|
+
// The existing bridge frames carry opaque capability metadata and bytes
|
|
20328
|
+
// between the runtime and its execution owner. Streams are live resources:
|
|
20329
|
+
// they are bound to one bridge socket and never park.
|
|
20226
20330
|
/** Default time to wait for the client to accept a stream open. */
|
|
20227
20331
|
static CLIENT_STREAM_OPEN_TIMEOUT_MS = 3e4;
|
|
20228
20332
|
/** Open a bidirectional byte stream to the connected owner client. */
|
|
@@ -20233,7 +20337,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20233
20337
|
return {
|
|
20234
20338
|
ok: false,
|
|
20235
20339
|
error: "The workspace is not available right now. Try again in a moment.",
|
|
20236
|
-
data: { noClient: true }
|
|
20340
|
+
data: { noClient: true, code: "unavailable" }
|
|
20237
20341
|
};
|
|
20238
20342
|
}
|
|
20239
20343
|
const id = crypto.randomUUID();
|
|
@@ -20266,7 +20370,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20266
20370
|
state.openTimer = setTimeout(() => {
|
|
20267
20371
|
resolve({
|
|
20268
20372
|
ok: false,
|
|
20269
|
-
error: `The client did not accept the ${request.tool} stream within ${Math.round(timeoutMs / 1e3)}s
|
|
20373
|
+
error: `The client did not accept the ${request.tool} stream within ${Math.round(timeoutMs / 1e3)}s.`,
|
|
20374
|
+
code: "timeout"
|
|
20270
20375
|
});
|
|
20271
20376
|
}, timeoutMs);
|
|
20272
20377
|
try {
|
|
@@ -20281,7 +20386,8 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20281
20386
|
} catch (error) {
|
|
20282
20387
|
resolve({
|
|
20283
20388
|
ok: false,
|
|
20284
|
-
error: `Failed to reach the client: ${error instanceof Error ? error.message : String(error)}
|
|
20389
|
+
error: `Failed to reach the client: ${error instanceof Error ? error.message : String(error)}`,
|
|
20390
|
+
code: "unavailable"
|
|
20285
20391
|
});
|
|
20286
20392
|
}
|
|
20287
20393
|
});
|
|
@@ -20294,7 +20400,11 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20294
20400
|
this.clientStreams.delete(id);
|
|
20295
20401
|
state.settled = true;
|
|
20296
20402
|
settleDone({ ok: false, error: openResult.error });
|
|
20297
|
-
return {
|
|
20403
|
+
return {
|
|
20404
|
+
ok: false,
|
|
20405
|
+
error: openResult.error ?? "Stream open failed.",
|
|
20406
|
+
data: openResult.code ? { code: openResult.code } : void 0
|
|
20407
|
+
};
|
|
20298
20408
|
}
|
|
20299
20409
|
const sendChunked = (bytes) => {
|
|
20300
20410
|
for (let i = 0; i < bytes.length; i += CLIENT_STREAM_CHUNK_BYTES) {
|
|
@@ -20338,8 +20448,14 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20338
20448
|
async proxyStreamOpen(request) {
|
|
20339
20449
|
const opened = await this.openClientStream(request);
|
|
20340
20450
|
if (!opened.ok) {
|
|
20341
|
-
const
|
|
20342
|
-
|
|
20451
|
+
const failureData = opened.data;
|
|
20452
|
+
const noClient = failureData?.noClient === true;
|
|
20453
|
+
return {
|
|
20454
|
+
ok: false,
|
|
20455
|
+
error: opened.error,
|
|
20456
|
+
noClient,
|
|
20457
|
+
code: failureData?.code
|
|
20458
|
+
};
|
|
20343
20459
|
}
|
|
20344
20460
|
const id = crypto.randomUUID();
|
|
20345
20461
|
const duplex = opened.duplex;
|
|
@@ -20410,12 +20526,12 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20410
20526
|
}
|
|
20411
20527
|
}
|
|
20412
20528
|
/** Settle and remove a client stream exactly once. */
|
|
20413
|
-
settleClientStream(id, result) {
|
|
20529
|
+
settleClientStream(id, result, openCode) {
|
|
20414
20530
|
const state = this.clientStreams.get(id);
|
|
20415
20531
|
if (!state) return;
|
|
20416
20532
|
this.clientStreams.delete(id);
|
|
20417
20533
|
if (state.openTimer) clearTimeout(state.openTimer);
|
|
20418
|
-
if (state.opened) state.opened({ ok: false, error: result.error ?? "Stream closed." });
|
|
20534
|
+
if (state.opened) state.opened({ ok: false, error: result.error ?? "Stream closed.", code: openCode });
|
|
20419
20535
|
if (!state.settled) {
|
|
20420
20536
|
state.settled = true;
|
|
20421
20537
|
try {
|
|
@@ -20459,7 +20575,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20459
20575
|
}
|
|
20460
20576
|
case "stream_error": {
|
|
20461
20577
|
const error = typeof parsed.error === "string" ? parsed.error : "Client stream error.";
|
|
20462
|
-
this.settleClientStream(id, { ok: false, error });
|
|
20578
|
+
this.settleClientStream(id, { ok: false, error }, "refused");
|
|
20463
20579
|
return;
|
|
20464
20580
|
}
|
|
20465
20581
|
case "stream_data": {
|
|
@@ -20486,7 +20602,7 @@ ${resultContent}${attachmentSummary}`;
|
|
|
20486
20602
|
failClientStreamsForSocket(ws) {
|
|
20487
20603
|
for (const [id, state] of Array.from(this.clientStreams.entries())) {
|
|
20488
20604
|
if (state.socket === ws) {
|
|
20489
|
-
this.settleClientStream(id, { ok: false, error: "The client connection was lost." });
|
|
20605
|
+
this.settleClientStream(id, { ok: false, error: "The client connection was lost." }, "unavailable");
|
|
20490
20606
|
}
|
|
20491
20607
|
}
|
|
20492
20608
|
}
|
|
@@ -26513,6 +26629,6 @@ init_context();
|
|
|
26513
26629
|
init_ProviderRegistry();
|
|
26514
26630
|
init_types2();
|
|
26515
26631
|
|
|
26516
|
-
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, NamespaceResolutionError, ProviderRegistry, ThreadWatchdog, authenticate, buildImageDescription, cat, createNamespaceContext, createThreadEndpointHandler, defineController2 as defineController, 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 };
|
|
26632
|
+
export { CLIENT_STREAM_CHUNK_BYTES, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, NamespaceResolutionError, ProviderRegistry, ThreadWatchdog, authenticate, buildImageDescription, callClient, callClientStream, cat, createNamespaceContext, createThreadEndpointHandler, decodeStreamChunk, defineController2 as defineController, emitThreadEvent, encodeStreamChunk, 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, supportsClientForwarding, tail, unlink, updateThread, writeFile, writeImage };
|
|
26517
26633
|
//# sourceMappingURL=runtime.js.map
|
|
26518
26634
|
//# sourceMappingURL=runtime.js.map
|