@standardagents/builder 0.28.1 → 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 +66 -12
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-BzXyIJPA.d.ts → index-BNLDsLsL.d.ts} +22 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +151 -28
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +18 -2
- package/dist/runtime.js +151 -28
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
package/dist/built-in-routes.js
CHANGED
|
@@ -49,6 +49,39 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
49
49
|
));
|
|
50
50
|
|
|
51
51
|
// src/agents/client-forwarding.ts
|
|
52
|
+
function createRuntimeStreams(openClientStream) {
|
|
53
|
+
return {
|
|
54
|
+
async open(request) {
|
|
55
|
+
const opened = await openClientStream({
|
|
56
|
+
tool: request.capability,
|
|
57
|
+
meta: request.metadata,
|
|
58
|
+
timeoutMs: request.timeoutMs
|
|
59
|
+
});
|
|
60
|
+
if (!opened.ok) {
|
|
61
|
+
const failureData = opened.data;
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
error: opened.error,
|
|
65
|
+
code: failureData?.code
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
let closed = false;
|
|
69
|
+
return {
|
|
70
|
+
ok: true,
|
|
71
|
+
stream: {
|
|
72
|
+
readable: opened.duplex.readable,
|
|
73
|
+
writable: opened.duplex.writable,
|
|
74
|
+
closed: opened.duplex.done,
|
|
75
|
+
close: (reason) => {
|
|
76
|
+
if (closed) return;
|
|
77
|
+
closed = true;
|
|
78
|
+
opened.duplex.close(reason);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
52
85
|
function encodeStreamChunk(bytes) {
|
|
53
86
|
let binary = "";
|
|
54
87
|
const step = 32768;
|
|
@@ -12544,6 +12577,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
12544
12577
|
}
|
|
12545
12578
|
return this.getMetadataArguments();
|
|
12546
12579
|
}
|
|
12580
|
+
/**
|
|
12581
|
+
* Optional spec byte streams backed by the execution owner's existing
|
|
12582
|
+
* bridge. Streams are live resources: they proxy through ancestors when a
|
|
12583
|
+
* subagent opens one, but they never park or outlive a bridge disconnect.
|
|
12584
|
+
*/
|
|
12585
|
+
get runtimeStreams() {
|
|
12586
|
+
return createRuntimeStreams((request) => this.callClientStream(request));
|
|
12587
|
+
}
|
|
12547
12588
|
getMetadataArguments() {
|
|
12548
12589
|
const value = this._metadata.properties?.[SUBAGENT_INITIAL_ARGUMENTS_THREAD_PROPERTY];
|
|
12549
12590
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -13120,11 +13161,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
13120
13161
|
return local;
|
|
13121
13162
|
}
|
|
13122
13163
|
/**
|
|
13123
|
-
*
|
|
13124
|
-
*
|
|
13125
|
-
*
|
|
13126
|
-
* is attached. Subagents must not call this directly; they proxy whole
|
|
13127
|
-
* requests up to the root thread instead (request-up / stream-down).
|
|
13164
|
+
* Legacy bridge implementation used by `runtimeStreams`. Streams require a
|
|
13165
|
+
* live execution owner and never park. A child thread proxies the complete
|
|
13166
|
+
* request to the nearest bridge-holding ancestor (request-up/stream-down).
|
|
13128
13167
|
*/
|
|
13129
13168
|
async callClientStream(request) {
|
|
13130
13169
|
const instance = this._threadInstance;
|
|
@@ -13134,7 +13173,9 @@ var init_ThreadStateImpl = __esm({
|
|
|
13134
13173
|
error: "This thread runtime cannot open client streams. Client streaming requires the DurableThread bridge."
|
|
13135
13174
|
};
|
|
13136
13175
|
}
|
|
13137
|
-
const
|
|
13176
|
+
const wakeUserId = this._metadata.user_id ?? null;
|
|
13177
|
+
const withWake = (threadId) => wakeUserId ? { ...request, wake: { threadId, userId: wakeUserId } } : request;
|
|
13178
|
+
const local = await instance.openClientStream(withWake(this._metadata.id));
|
|
13138
13179
|
if (local.ok || !this.isNoClient(local)) return local;
|
|
13139
13180
|
const env2 = this._threadInstance.env;
|
|
13140
13181
|
if (!env2?.AGENT_BUILDER_THREAD) return local;
|
|
@@ -13145,12 +13186,16 @@ var init_ThreadStateImpl = __esm({
|
|
|
13145
13186
|
try {
|
|
13146
13187
|
const stub = env2.AGENT_BUILDER_THREAD.get(env2.AGENT_BUILDER_THREAD.idFromName(parentId));
|
|
13147
13188
|
if (typeof stub.proxyStreamOpen === "function") {
|
|
13148
|
-
const opened = await stub.proxyStreamOpen(
|
|
13189
|
+
const opened = await stub.proxyStreamOpen(withWake(parentId));
|
|
13149
13190
|
if (opened.ok && opened.id) {
|
|
13150
13191
|
return { ok: true, duplex: this.buildProxyDuplex(stub, opened.id) };
|
|
13151
13192
|
}
|
|
13152
13193
|
if (opened.error && !opened.noClient) {
|
|
13153
|
-
return {
|
|
13194
|
+
return {
|
|
13195
|
+
ok: false,
|
|
13196
|
+
error: opened.error,
|
|
13197
|
+
data: opened.code ? { code: opened.code } : void 0
|
|
13198
|
+
};
|
|
13154
13199
|
}
|
|
13155
13200
|
}
|
|
13156
13201
|
} catch {
|
|
@@ -13169,6 +13214,12 @@ var init_ThreadStateImpl = __esm({
|
|
|
13169
13214
|
let settleDone;
|
|
13170
13215
|
const done = new Promise((r) => settleDone = r);
|
|
13171
13216
|
let closed = false;
|
|
13217
|
+
let settled = false;
|
|
13218
|
+
const settle = (result) => {
|
|
13219
|
+
if (settled) return;
|
|
13220
|
+
settled = true;
|
|
13221
|
+
settleDone(result);
|
|
13222
|
+
};
|
|
13172
13223
|
const readable = new ReadableStream({
|
|
13173
13224
|
async pull(controller) {
|
|
13174
13225
|
while (!closed) {
|
|
@@ -13177,7 +13228,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13177
13228
|
res = await stub.proxyStreamPull(id);
|
|
13178
13229
|
} catch (error) {
|
|
13179
13230
|
controller.error(error instanceof Error ? error : new Error(String(error)));
|
|
13180
|
-
|
|
13231
|
+
settle({ ok: false, error: "proxy stream pull failed" });
|
|
13181
13232
|
return;
|
|
13182
13233
|
}
|
|
13183
13234
|
for (const chunk of res.chunks) {
|
|
@@ -13185,7 +13236,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13185
13236
|
}
|
|
13186
13237
|
if (res.done) {
|
|
13187
13238
|
controller.close();
|
|
13188
|
-
|
|
13239
|
+
settle(res.error ? { ok: false, error: res.error } : { ok: true });
|
|
13189
13240
|
return;
|
|
13190
13241
|
}
|
|
13191
13242
|
if (res.chunks.length > 0) return;
|
|
@@ -13196,6 +13247,7 @@ var init_ThreadStateImpl = __esm({
|
|
|
13196
13247
|
closed = true;
|
|
13197
13248
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13198
13249
|
});
|
|
13250
|
+
settle({ ok: false, error: "proxy stream reader canceled" });
|
|
13199
13251
|
}
|
|
13200
13252
|
});
|
|
13201
13253
|
const writable = new WritableStream({
|
|
@@ -13210,16 +13262,18 @@ var init_ThreadStateImpl = __esm({
|
|
|
13210
13262
|
closed = true;
|
|
13211
13263
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13212
13264
|
});
|
|
13265
|
+
settle({ ok: false, error: "proxy stream writer aborted" });
|
|
13213
13266
|
}
|
|
13214
13267
|
});
|
|
13215
13268
|
return {
|
|
13216
13269
|
readable,
|
|
13217
13270
|
writable,
|
|
13218
13271
|
close: (error) => {
|
|
13272
|
+
if (closed) return;
|
|
13219
13273
|
closed = true;
|
|
13220
13274
|
void stub.proxyStreamAbort(id).catch(() => {
|
|
13221
13275
|
});
|
|
13222
|
-
|
|
13276
|
+
settle(error ? { ok: false, error } : { ok: true });
|
|
13223
13277
|
},
|
|
13224
13278
|
done
|
|
13225
13279
|
};
|
|
@@ -66504,7 +66558,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
|
|
|
66504
66558
|
});
|
|
66505
66559
|
|
|
66506
66560
|
// src/version.ts
|
|
66507
|
-
var BUILDER_VERSION = "0.
|
|
66561
|
+
var BUILDER_VERSION = "0.29.1".length > 0 ? "0.29.1" : "dev";
|
|
66508
66562
|
|
|
66509
66563
|
// src/api/diagnostics.get.ts
|
|
66510
66564
|
init_LLMRequest();
|