@standardagents/builder 0.37.3 → 0.37.5
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 +178 -81
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-BhuT3pIF.js → ApiKeysView-Pk5oljVU.js} +1 -1
- package/dist/client/CenteredContentView-HGpMGAQj.js +1 -0
- package/dist/client/CompositionView-DN8dTOCO.js +32 -0
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-BqwwsXWJ.js → ConfirmDialog.vue_vue_type_script_setup_true_lang--j_hnMZ0.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-Cqm3Vt3E.js → CopyButton.vue_vue_type_script_setup_true_lang-CpJDcbZx.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-CA5qgsty.js → DataTable.vue_vue_type_script_setup_true_lang-unLrY-PY.js} +1 -1
- package/dist/client/{JsonViewer-ByQKCShF.js → JsonViewer-BYj_yrGB.js} +1 -1
- package/dist/client/{LoginView-J4qtHbQK.js → LoginView-CfVqItZV.js} +1 -1
- package/dist/client/{MarketplaceView-CshdWDqp.js → MarketplaceView-Cidt0nLf.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-DKdB9A8Z.js → Modal.vue_vue_type_script_setup_true_lang-C1dmm1HX.js} +1 -1
- package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang-DIKLuPXT.js +1 -0
- package/dist/client/{ModelsView-B_n306yk.js → ModelsView-DH6wNe38.js} +1 -1
- package/dist/client/{PromptEditView-C85qRgsE.js → PromptEditView-D_VjoAa-.js} +1 -1
- package/dist/client/{PromptModal-PNpoJfqD.js → PromptModal-a9LTOWNt.js} +1 -1
- package/dist/client/{PromptsView-BKnfThIF.js → PromptsView-BCCCryKR.js} +1 -1
- package/dist/client/{ProvidersView-Df41VhHD.js → ProvidersView-CF4x5F6G.js} +2 -2
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-D5VDoQiK.js +22 -0
- package/dist/client/ThreadsView-BzscU1l2.js +1 -0
- package/dist/client/{ToolsView-C0MH9x3N.js → ToolsView-CeEtxDZV.js} +1 -1
- package/dist/client/{UiCodeBlock.vue_vue_type_script_setup_true_lang-DjDQOYjB.js → UiCodeBlock.vue_vue_type_script_setup_true_lang-BdyzSxZZ.js} +1 -1
- package/dist/client/{UsersView--TQiJYP7.js → UsersView-Di5cmUYL.js} +1 -1
- package/dist/client/{VariablesView-BO3UljZu.js → VariablesView-CXUr05jD.js} +1 -1
- package/dist/client/assets/{CompositionView-nJBKoNx4.css → CompositionView-0qQUWuc1.css} +1 -1
- package/dist/client/{check-DeHZQcv4.js → check-YKi1o6p6.js} +1 -1
- package/dist/client/{chevron-right-C8Mb0B59.js → chevron-right-T0zzq_GX.js} +1 -1
- package/dist/client/{copy-BxJsl-KZ.js → copy-C_gUGAj1.js} +1 -1
- package/dist/client/{formkit-0eyyCEP_.js → formkit-CE26dtFp.js} +1 -1
- package/dist/client/index-BMqXblce.js +6 -0
- package/dist/client/index.html +3 -3
- package/dist/client/{package-B9czwyIu.js → package-B70IFSDB.js} +1 -1
- package/dist/client/{plus-DqtuqJFm.js → plus-BN9IHYdt.js} +1 -1
- package/dist/client/{timeAgo-CDt-vAhI.js → timeAgo-G1ovbWPH.js} +1 -1
- package/dist/client/{useActionFeedback-B6UfBJ7l.js → useActionFeedback-7pfPjKMi.js} +1 -1
- package/dist/client/{vue-Dw7WLX4c.js → vue-CZ-ORfS3.js} +1 -1
- package/dist/{index-DceFbLG9.d.ts → index-Lfan8QMN.d.ts} +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +297 -25
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +6 -0
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +45 -5
- package/dist/runtime.js +291 -25
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client/CenteredContentView-CfgX3Ao3.js +0 -1
- package/dist/client/CompositionView-B9FfWMHd.js +0 -32
- package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang-BAxaBZsx.js +0 -1
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CtIBWHUR.js +0 -22
- package/dist/client/ThreadsView-sjo5Rrcm.js +0 -1
- package/dist/client/index-BgZnQr8X.js +0 -6
package/dist/built-in-routes.js
CHANGED
|
@@ -9983,10 +9983,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9983
9983
|
const mimeType = match2[1];
|
|
9984
9984
|
const base64Data = match2[2];
|
|
9985
9985
|
const ext = mimeType.split("/")[1] || "png";
|
|
9986
|
+
if (base64Data.length < 64) {
|
|
9987
|
+
console.error("[FlowEngine] Generated image payload is empty/truncated, skipping");
|
|
9988
|
+
continue;
|
|
9989
|
+
}
|
|
9986
9990
|
const attachmentId = crypto.randomUUID();
|
|
9987
9991
|
const path10 = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
|
|
9988
9992
|
try {
|
|
9989
|
-
await state.thread.instance.writeFile(path10, base64Data, mimeType);
|
|
9993
|
+
const written = await state.thread.instance.writeFile(path10, base64Data, mimeType);
|
|
9994
|
+
if (written && written.success === false) {
|
|
9995
|
+
console.error("[FlowEngine] Generated image write failed:", written.error);
|
|
9996
|
+
continue;
|
|
9997
|
+
}
|
|
9990
9998
|
if (image.id) {
|
|
9991
9999
|
imagePathMap.set(image.id, path10);
|
|
9992
10000
|
}
|
|
@@ -10053,10 +10061,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
10053
10061
|
const mimeType = imageUrl.slice(dataPrefix.length, base64Index);
|
|
10054
10062
|
const base64Data = imageUrl.slice(base64Index + base64Marker.length);
|
|
10055
10063
|
const ext = mimeType.split("/")[1] || "png";
|
|
10064
|
+
if (base64Data.length < 64) {
|
|
10065
|
+
console.error(`[FlowEngine] ${toolName} image payload is empty/truncated, skipping`);
|
|
10066
|
+
continue;
|
|
10067
|
+
}
|
|
10056
10068
|
const attachmentId = crypto.randomUUID();
|
|
10057
10069
|
const path10 = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
|
|
10058
10070
|
try {
|
|
10059
|
-
await state.thread.instance.writeFile(path10, base64Data, mimeType);
|
|
10071
|
+
const written = await state.thread.instance.writeFile(path10, base64Data, mimeType);
|
|
10072
|
+
if (written && written.success === false) {
|
|
10073
|
+
console.error(`[FlowEngine] ${toolName} image write failed:`, written.error);
|
|
10074
|
+
continue;
|
|
10075
|
+
}
|
|
10060
10076
|
const attachmentRef = {
|
|
10061
10077
|
id: attachmentId,
|
|
10062
10078
|
type: "file",
|
|
@@ -13304,8 +13320,25 @@ var init_ThreadStateImpl = __esm({
|
|
|
13304
13320
|
const mustParkForApproval = await this.forwardedCallNeedsApproval(request);
|
|
13305
13321
|
if (mustParkForApproval && canPark && toolCallId && typeof instance.hasBridge === "function" && await instance.hasBridge()) {
|
|
13306
13322
|
await instance.dispatchClientTool(request, toolCallId, side);
|
|
13307
|
-
const
|
|
13308
|
-
if (typeof
|
|
13323
|
+
const withDelivery = instance;
|
|
13324
|
+
if (typeof withDelivery.awaitDeliveredClientToolResult === "function") {
|
|
13325
|
+
try {
|
|
13326
|
+
const delivered = await withDelivery.awaitDeliveredClientToolResult.call(
|
|
13327
|
+
instance,
|
|
13328
|
+
toolCallId,
|
|
13329
|
+
4e3
|
|
13330
|
+
);
|
|
13331
|
+
if (delivered) {
|
|
13332
|
+
return {
|
|
13333
|
+
ok: delivered.toolStatus !== "error",
|
|
13334
|
+
result: delivered.content,
|
|
13335
|
+
data: { toolCallId }
|
|
13336
|
+
};
|
|
13337
|
+
}
|
|
13338
|
+
} catch {
|
|
13339
|
+
}
|
|
13340
|
+
} else if (typeof withDelivery.getDeliveredClientToolResult === "function") {
|
|
13341
|
+
const getDelivered = withDelivery.getDeliveredClientToolResult;
|
|
13309
13342
|
const graceDeadline = Date.now() + 4e3;
|
|
13310
13343
|
while (Date.now() < graceDeadline) {
|
|
13311
13344
|
await new Promise((r) => setTimeout(r, 150));
|
|
@@ -13395,7 +13428,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
13395
13428
|
if (typeof stub.proxyStreamOpen === "function") {
|
|
13396
13429
|
const opened = await stub.proxyStreamOpen(withWake(parentId));
|
|
13397
13430
|
if (opened.ok && opened.id) {
|
|
13398
|
-
return {
|
|
13431
|
+
return {
|
|
13432
|
+
ok: true,
|
|
13433
|
+
duplex: this.buildProxyDuplex(
|
|
13434
|
+
stub,
|
|
13435
|
+
opened.id,
|
|
13436
|
+
opened.parkedPull === true
|
|
13437
|
+
)
|
|
13438
|
+
};
|
|
13399
13439
|
}
|
|
13400
13440
|
if (opened.error && !opened.noClient) {
|
|
13401
13441
|
return {
|
|
@@ -13413,11 +13453,15 @@ var init_ThreadStateImpl = __esm({
|
|
|
13413
13453
|
}
|
|
13414
13454
|
/**
|
|
13415
13455
|
* Build a client duplex that bridges to a stream opened on an ancestor DO
|
|
13416
|
-
* (the bridge holder) via chunk-pull RPCs. `readable`
|
|
13417
|
-
*
|
|
13456
|
+
* (the bridge holder) via chunk-pull RPCs. `readable` issues PARKED pulls —
|
|
13457
|
+
* a current ancestor holds one `proxyStreamPull` until bytes, completion,
|
|
13458
|
+
* error, or abort, so an idle open stream performs zero repeated pulls.
|
|
13459
|
+
* Older ancestors use the bounded long-pull compatibility path. `writable`
|
|
13460
|
+
* forwards each chunk with `proxyStreamWrite`; teardown calls
|
|
13418
13461
|
* `proxyStreamAbort`.
|
|
13419
13462
|
*/
|
|
13420
|
-
|
|
13463
|
+
static PROXY_PULL_MAX_WAIT_MS = 2e4;
|
|
13464
|
+
buildProxyDuplex(stub, id, supportsParkedPull = false) {
|
|
13421
13465
|
let settleDone;
|
|
13422
13466
|
const done = new Promise((r) => settleDone = r);
|
|
13423
13467
|
let closed = false;
|
|
@@ -13430,9 +13474,13 @@ var init_ThreadStateImpl = __esm({
|
|
|
13430
13474
|
const readable = new ReadableStream({
|
|
13431
13475
|
async pull(controller) {
|
|
13432
13476
|
while (!closed) {
|
|
13477
|
+
const pullStartedAt = Date.now();
|
|
13433
13478
|
let res;
|
|
13434
13479
|
try {
|
|
13435
|
-
res = await stub.proxyStreamPull(
|
|
13480
|
+
res = await stub.proxyStreamPull(
|
|
13481
|
+
id,
|
|
13482
|
+
supportsParkedPull ? void 0 : _ThreadStateImpl.PROXY_PULL_MAX_WAIT_MS
|
|
13483
|
+
);
|
|
13436
13484
|
} catch (error) {
|
|
13437
13485
|
controller.error(error instanceof Error ? error : new Error(String(error)));
|
|
13438
13486
|
settle({ ok: false, error: "proxy stream pull failed" });
|
|
@@ -13447,7 +13495,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
13447
13495
|
return;
|
|
13448
13496
|
}
|
|
13449
13497
|
if (res.chunks.length > 0) return;
|
|
13450
|
-
|
|
13498
|
+
if (supportsParkedPull) {
|
|
13499
|
+
controller.error(new Error("parked proxy pull returned without data"));
|
|
13500
|
+
settle({ ok: false, error: "parked proxy pull returned without data" });
|
|
13501
|
+
return;
|
|
13502
|
+
}
|
|
13503
|
+
if (Date.now() - pullStartedAt < 250) {
|
|
13504
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
13505
|
+
}
|
|
13451
13506
|
}
|
|
13452
13507
|
},
|
|
13453
13508
|
cancel() {
|
|
@@ -67912,7 +67967,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
|
|
|
67912
67967
|
});
|
|
67913
67968
|
|
|
67914
67969
|
// src/version.ts
|
|
67915
|
-
var BUILDER_VERSION = "0.37.
|
|
67970
|
+
var BUILDER_VERSION = "0.37.5".length > 0 ? "0.37.5" : "dev";
|
|
67916
67971
|
|
|
67917
67972
|
// src/api/diagnostics.get.ts
|
|
67918
67973
|
init_LLMRequest();
|
|
@@ -70302,6 +70357,33 @@ var id_patch_default = defineController2(async ({ req, env: env2, params }) => {
|
|
|
70302
70357
|
}
|
|
70303
70358
|
});
|
|
70304
70359
|
|
|
70360
|
+
// src/middleware/request-auth.ts
|
|
70361
|
+
async function resolveRequestAuth(context) {
|
|
70362
|
+
if (context.auth) return context.auth;
|
|
70363
|
+
return requireAuth(context.req, context.env);
|
|
70364
|
+
}
|
|
70365
|
+
async function resolveOptionalRequestAuth(context) {
|
|
70366
|
+
if (context.auth) return context.auth;
|
|
70367
|
+
return authenticate(context.req, context.env);
|
|
70368
|
+
}
|
|
70369
|
+
async function resolveRequestPermission(context, permission) {
|
|
70370
|
+
if (context.auth) {
|
|
70371
|
+
if (!hasPermission(context.auth.user, permission)) {
|
|
70372
|
+
return Response.json(
|
|
70373
|
+
{ error: `Forbidden: '${permission}' access required` },
|
|
70374
|
+
{ status: 403 }
|
|
70375
|
+
);
|
|
70376
|
+
}
|
|
70377
|
+
return context.auth;
|
|
70378
|
+
}
|
|
70379
|
+
return requirePermission(context.req, context.env, permission);
|
|
70380
|
+
}
|
|
70381
|
+
function routerAuthorizedThread(context, threadId) {
|
|
70382
|
+
const access = context.threadAccess;
|
|
70383
|
+
if (!access || !threadId) return null;
|
|
70384
|
+
return access.threadId === threadId ? access.thread : null;
|
|
70385
|
+
}
|
|
70386
|
+
|
|
70305
70387
|
// src/api/threads/[id].ts
|
|
70306
70388
|
function resolveIconUrl2(icon, origin) {
|
|
70307
70389
|
if (!icon) return void 0;
|
|
@@ -70313,8 +70395,9 @@ function resolveIconUrl2(icon, origin) {
|
|
|
70313
70395
|
}
|
|
70314
70396
|
return icon;
|
|
70315
70397
|
}
|
|
70316
|
-
var id_default = defineController2(async (
|
|
70317
|
-
const
|
|
70398
|
+
var id_default = defineController2(async (context) => {
|
|
70399
|
+
const { req, params, env: env2 } = context;
|
|
70400
|
+
const authResult = await resolveRequestAuth(context);
|
|
70318
70401
|
if (authResult instanceof Response) {
|
|
70319
70402
|
return authResult;
|
|
70320
70403
|
}
|
|
@@ -70324,20 +70407,22 @@ var id_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
70324
70407
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
70325
70408
|
}
|
|
70326
70409
|
try {
|
|
70327
|
-
|
|
70328
|
-
|
|
70329
|
-
|
|
70330
|
-
|
|
70331
|
-
|
|
70332
|
-
|
|
70333
|
-
|
|
70334
|
-
|
|
70335
|
-
|
|
70336
|
-
|
|
70337
|
-
|
|
70338
|
-
|
|
70339
|
-
|
|
70340
|
-
|
|
70410
|
+
if (!routerAuthorizedThread(context, threadId)) {
|
|
70411
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
70412
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
70413
|
+
const thread = await agentBuilder.getThread(threadId);
|
|
70414
|
+
if (!thread) {
|
|
70415
|
+
return Response.json(
|
|
70416
|
+
{ error: `Thread not found: ${threadId}` },
|
|
70417
|
+
{ status: 404 }
|
|
70418
|
+
);
|
|
70419
|
+
}
|
|
70420
|
+
if (!canAccessThread(auth, thread)) {
|
|
70421
|
+
return Response.json(
|
|
70422
|
+
{ error: "Forbidden: You don't have access to this thread" },
|
|
70423
|
+
{ status: 403 }
|
|
70424
|
+
);
|
|
70425
|
+
}
|
|
70341
70426
|
}
|
|
70342
70427
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
70343
70428
|
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73443,31 +73528,34 @@ var diagnostics_get_default2 = defineController2(async ({ req, params, env: env2
|
|
|
73443
73528
|
});
|
|
73444
73529
|
|
|
73445
73530
|
// src/api/threads/[id]/effects.get.ts
|
|
73446
|
-
async function getAuthorizedThreadStub(
|
|
73447
|
-
const
|
|
73531
|
+
async function getAuthorizedThreadStub(context, threadId) {
|
|
73532
|
+
const { env: env2 } = context;
|
|
73533
|
+
const authResult = await resolveRequestAuth(context);
|
|
73448
73534
|
if (authResult instanceof Response) {
|
|
73449
73535
|
return authResult;
|
|
73450
73536
|
}
|
|
73451
|
-
|
|
73452
|
-
|
|
73453
|
-
|
|
73454
|
-
|
|
73455
|
-
|
|
73456
|
-
|
|
73457
|
-
|
|
73458
|
-
|
|
73459
|
-
|
|
73460
|
-
|
|
73461
|
-
|
|
73462
|
-
|
|
73463
|
-
|
|
73464
|
-
|
|
73465
|
-
|
|
73466
|
-
|
|
73467
|
-
|
|
73468
|
-
|
|
73469
|
-
|
|
73470
|
-
|
|
73537
|
+
if (!routerAuthorizedThread(context, threadId)) {
|
|
73538
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
73539
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
73540
|
+
if (typeof agentBuilder.getThread !== "function") {
|
|
73541
|
+
return Response.json(
|
|
73542
|
+
{ error: "Thread lookup is not supported by this runtime" },
|
|
73543
|
+
{ status: 500 }
|
|
73544
|
+
);
|
|
73545
|
+
}
|
|
73546
|
+
const thread = await agentBuilder.getThread(threadId);
|
|
73547
|
+
if (!thread) {
|
|
73548
|
+
return Response.json(
|
|
73549
|
+
{ error: `Thread not found: ${threadId}` },
|
|
73550
|
+
{ status: 404 }
|
|
73551
|
+
);
|
|
73552
|
+
}
|
|
73553
|
+
if (!canAccessThread(authResult, thread)) {
|
|
73554
|
+
return Response.json(
|
|
73555
|
+
{ error: "Forbidden: You don't have access to this thread" },
|
|
73556
|
+
{ status: 403 }
|
|
73557
|
+
);
|
|
73558
|
+
}
|
|
73471
73559
|
}
|
|
73472
73560
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
73473
73561
|
return env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73476,13 +73564,14 @@ function parseInteger(value, fallback) {
|
|
|
73476
73564
|
const parsed = value ? Number.parseInt(value, 10) : Number.NaN;
|
|
73477
73565
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
73478
73566
|
}
|
|
73479
|
-
var effects_get_default = defineController2(async (
|
|
73567
|
+
var effects_get_default = defineController2(async (context) => {
|
|
73568
|
+
const { params, url } = context;
|
|
73480
73569
|
const threadId = params.id;
|
|
73481
73570
|
if (!threadId) {
|
|
73482
73571
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73483
73572
|
}
|
|
73484
73573
|
try {
|
|
73485
|
-
const stub = await getAuthorizedThreadStub(
|
|
73574
|
+
const stub = await getAuthorizedThreadStub(context, threadId);
|
|
73486
73575
|
if (stub instanceof Response) return stub;
|
|
73487
73576
|
if (typeof stub.listEffectRuns !== "function") {
|
|
73488
73577
|
return Response.json(
|
|
@@ -73566,31 +73655,34 @@ var fs_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
73566
73655
|
});
|
|
73567
73656
|
|
|
73568
73657
|
// src/api/threads/[id]/kv/index.ts
|
|
73569
|
-
async function getAuthorizedThreadStub2(
|
|
73570
|
-
const
|
|
73658
|
+
async function getAuthorizedThreadStub2(context, threadId) {
|
|
73659
|
+
const { env: env2 } = context;
|
|
73660
|
+
const authResult = await resolveRequestAuth(context);
|
|
73571
73661
|
if (authResult instanceof Response) {
|
|
73572
73662
|
return authResult;
|
|
73573
73663
|
}
|
|
73574
|
-
|
|
73575
|
-
|
|
73576
|
-
|
|
73577
|
-
|
|
73578
|
-
|
|
73579
|
-
|
|
73580
|
-
|
|
73581
|
-
|
|
73582
|
-
|
|
73583
|
-
|
|
73584
|
-
|
|
73585
|
-
|
|
73586
|
-
|
|
73587
|
-
|
|
73588
|
-
|
|
73589
|
-
|
|
73590
|
-
|
|
73591
|
-
|
|
73592
|
-
|
|
73593
|
-
|
|
73664
|
+
if (!routerAuthorizedThread(context, threadId)) {
|
|
73665
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
73666
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
73667
|
+
if (typeof agentBuilder.getThread !== "function") {
|
|
73668
|
+
return Response.json(
|
|
73669
|
+
{ error: "Thread lookup is not supported by this runtime" },
|
|
73670
|
+
{ status: 500 }
|
|
73671
|
+
);
|
|
73672
|
+
}
|
|
73673
|
+
const thread = await agentBuilder.getThread(threadId);
|
|
73674
|
+
if (!thread) {
|
|
73675
|
+
return Response.json(
|
|
73676
|
+
{ error: `Thread not found: ${threadId}` },
|
|
73677
|
+
{ status: 404 }
|
|
73678
|
+
);
|
|
73679
|
+
}
|
|
73680
|
+
if (!canAccessThread(authResult, thread)) {
|
|
73681
|
+
return Response.json(
|
|
73682
|
+
{ error: "Forbidden: You don't have access to this thread" },
|
|
73683
|
+
{ status: 403 }
|
|
73684
|
+
);
|
|
73685
|
+
}
|
|
73594
73686
|
}
|
|
73595
73687
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
73596
73688
|
return env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73688,13 +73780,14 @@ async function handleDelete(stub, req, url) {
|
|
|
73688
73780
|
await stub.setValue(key, null);
|
|
73689
73781
|
return new Response(null, { status: 204 });
|
|
73690
73782
|
}
|
|
73691
|
-
var kv_default = defineController2(async (
|
|
73783
|
+
var kv_default = defineController2(async (context) => {
|
|
73784
|
+
const { req, params, url } = context;
|
|
73692
73785
|
const threadId = params.id;
|
|
73693
73786
|
if (!threadId) {
|
|
73694
73787
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73695
73788
|
}
|
|
73696
73789
|
try {
|
|
73697
|
-
const stub = await getAuthorizedThreadStub2(
|
|
73790
|
+
const stub = await getAuthorizedThreadStub2(context, threadId);
|
|
73698
73791
|
if (stub instanceof Response) return stub;
|
|
73699
73792
|
switch (req.method) {
|
|
73700
73793
|
case "GET":
|
|
@@ -73719,14 +73812,15 @@ var kv_default = defineController2(async ({ req, params, env: env2, url }) => {
|
|
|
73719
73812
|
});
|
|
73720
73813
|
|
|
73721
73814
|
// src/api/threads/[id]/logs.get.ts
|
|
73722
|
-
var logs_get_default = defineController2(async (
|
|
73815
|
+
var logs_get_default = defineController2(async (context) => {
|
|
73816
|
+
const { req, params, env: env2 } = context;
|
|
73723
73817
|
if (isPlatformHosted(env2)) {
|
|
73724
|
-
const authResult = await
|
|
73818
|
+
const authResult = await resolveRequestPermission(context, "logs");
|
|
73725
73819
|
if (authResult instanceof Response) {
|
|
73726
73820
|
return authResult;
|
|
73727
73821
|
}
|
|
73728
73822
|
} else {
|
|
73729
|
-
const authContext = await
|
|
73823
|
+
const authContext = await resolveOptionalRequestAuth(context);
|
|
73730
73824
|
if (authContext && !hasPermission(authContext.user, "logs")) {
|
|
73731
73825
|
return Response.json(
|
|
73732
73826
|
{ error: "Forbidden: 'logs' access required" },
|
|
@@ -73740,9 +73834,12 @@ var logs_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
73740
73834
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73741
73835
|
}
|
|
73742
73836
|
try {
|
|
73743
|
-
|
|
73744
|
-
|
|
73745
|
-
|
|
73837
|
+
let thread = routerAuthorizedThread(context, threadId);
|
|
73838
|
+
if (!thread) {
|
|
73839
|
+
const agentBuilderId = env2.AGENT_BUILDER.idFromName("singleton");
|
|
73840
|
+
const agentBuilder = env2.AGENT_BUILDER.get(agentBuilderId);
|
|
73841
|
+
thread = await agentBuilder.getThread(threadId);
|
|
73842
|
+
}
|
|
73746
73843
|
if (!thread) {
|
|
73747
73844
|
return Response.json(
|
|
73748
73845
|
{ error: `Thread not found: ${threadId}` },
|