@standardagents/builder 0.37.4 → 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 +160 -79
- 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 +279 -23
- 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 +273 -23
- 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
|
@@ -13320,8 +13320,25 @@ var init_ThreadStateImpl = __esm({
|
|
|
13320
13320
|
const mustParkForApproval = await this.forwardedCallNeedsApproval(request);
|
|
13321
13321
|
if (mustParkForApproval && canPark && toolCallId && typeof instance.hasBridge === "function" && await instance.hasBridge()) {
|
|
13322
13322
|
await instance.dispatchClientTool(request, toolCallId, side);
|
|
13323
|
-
const
|
|
13324
|
-
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;
|
|
13325
13342
|
const graceDeadline = Date.now() + 4e3;
|
|
13326
13343
|
while (Date.now() < graceDeadline) {
|
|
13327
13344
|
await new Promise((r) => setTimeout(r, 150));
|
|
@@ -13411,7 +13428,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
13411
13428
|
if (typeof stub.proxyStreamOpen === "function") {
|
|
13412
13429
|
const opened = await stub.proxyStreamOpen(withWake(parentId));
|
|
13413
13430
|
if (opened.ok && opened.id) {
|
|
13414
|
-
return {
|
|
13431
|
+
return {
|
|
13432
|
+
ok: true,
|
|
13433
|
+
duplex: this.buildProxyDuplex(
|
|
13434
|
+
stub,
|
|
13435
|
+
opened.id,
|
|
13436
|
+
opened.parkedPull === true
|
|
13437
|
+
)
|
|
13438
|
+
};
|
|
13415
13439
|
}
|
|
13416
13440
|
if (opened.error && !opened.noClient) {
|
|
13417
13441
|
return {
|
|
@@ -13429,11 +13453,15 @@ var init_ThreadStateImpl = __esm({
|
|
|
13429
13453
|
}
|
|
13430
13454
|
/**
|
|
13431
13455
|
* Build a client duplex that bridges to a stream opened on an ancestor DO
|
|
13432
|
-
* (the bridge holder) via chunk-pull RPCs. `readable`
|
|
13433
|
-
*
|
|
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
|
|
13434
13461
|
* `proxyStreamAbort`.
|
|
13435
13462
|
*/
|
|
13436
|
-
|
|
13463
|
+
static PROXY_PULL_MAX_WAIT_MS = 2e4;
|
|
13464
|
+
buildProxyDuplex(stub, id, supportsParkedPull = false) {
|
|
13437
13465
|
let settleDone;
|
|
13438
13466
|
const done = new Promise((r) => settleDone = r);
|
|
13439
13467
|
let closed = false;
|
|
@@ -13446,9 +13474,13 @@ var init_ThreadStateImpl = __esm({
|
|
|
13446
13474
|
const readable = new ReadableStream({
|
|
13447
13475
|
async pull(controller) {
|
|
13448
13476
|
while (!closed) {
|
|
13477
|
+
const pullStartedAt = Date.now();
|
|
13449
13478
|
let res;
|
|
13450
13479
|
try {
|
|
13451
|
-
res = await stub.proxyStreamPull(
|
|
13480
|
+
res = await stub.proxyStreamPull(
|
|
13481
|
+
id,
|
|
13482
|
+
supportsParkedPull ? void 0 : _ThreadStateImpl.PROXY_PULL_MAX_WAIT_MS
|
|
13483
|
+
);
|
|
13452
13484
|
} catch (error) {
|
|
13453
13485
|
controller.error(error instanceof Error ? error : new Error(String(error)));
|
|
13454
13486
|
settle({ ok: false, error: "proxy stream pull failed" });
|
|
@@ -13463,7 +13495,14 @@ var init_ThreadStateImpl = __esm({
|
|
|
13463
13495
|
return;
|
|
13464
13496
|
}
|
|
13465
13497
|
if (res.chunks.length > 0) return;
|
|
13466
|
-
|
|
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
|
+
}
|
|
13467
13506
|
}
|
|
13468
13507
|
},
|
|
13469
13508
|
cancel() {
|
|
@@ -67928,7 +67967,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
|
|
|
67928
67967
|
});
|
|
67929
67968
|
|
|
67930
67969
|
// src/version.ts
|
|
67931
|
-
var BUILDER_VERSION = "0.37.
|
|
67970
|
+
var BUILDER_VERSION = "0.37.5".length > 0 ? "0.37.5" : "dev";
|
|
67932
67971
|
|
|
67933
67972
|
// src/api/diagnostics.get.ts
|
|
67934
67973
|
init_LLMRequest();
|
|
@@ -70318,6 +70357,33 @@ var id_patch_default = defineController2(async ({ req, env: env2, params }) => {
|
|
|
70318
70357
|
}
|
|
70319
70358
|
});
|
|
70320
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
|
+
|
|
70321
70387
|
// src/api/threads/[id].ts
|
|
70322
70388
|
function resolveIconUrl2(icon, origin) {
|
|
70323
70389
|
if (!icon) return void 0;
|
|
@@ -70329,8 +70395,9 @@ function resolveIconUrl2(icon, origin) {
|
|
|
70329
70395
|
}
|
|
70330
70396
|
return icon;
|
|
70331
70397
|
}
|
|
70332
|
-
var id_default = defineController2(async (
|
|
70333
|
-
const
|
|
70398
|
+
var id_default = defineController2(async (context) => {
|
|
70399
|
+
const { req, params, env: env2 } = context;
|
|
70400
|
+
const authResult = await resolveRequestAuth(context);
|
|
70334
70401
|
if (authResult instanceof Response) {
|
|
70335
70402
|
return authResult;
|
|
70336
70403
|
}
|
|
@@ -70340,20 +70407,22 @@ var id_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
70340
70407
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
70341
70408
|
}
|
|
70342
70409
|
try {
|
|
70343
|
-
|
|
70344
|
-
|
|
70345
|
-
|
|
70346
|
-
|
|
70347
|
-
|
|
70348
|
-
|
|
70349
|
-
|
|
70350
|
-
|
|
70351
|
-
|
|
70352
|
-
|
|
70353
|
-
|
|
70354
|
-
|
|
70355
|
-
|
|
70356
|
-
|
|
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
|
+
}
|
|
70357
70426
|
}
|
|
70358
70427
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
70359
70428
|
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73459,31 +73528,34 @@ var diagnostics_get_default2 = defineController2(async ({ req, params, env: env2
|
|
|
73459
73528
|
});
|
|
73460
73529
|
|
|
73461
73530
|
// src/api/threads/[id]/effects.get.ts
|
|
73462
|
-
async function getAuthorizedThreadStub(
|
|
73463
|
-
const
|
|
73531
|
+
async function getAuthorizedThreadStub(context, threadId) {
|
|
73532
|
+
const { env: env2 } = context;
|
|
73533
|
+
const authResult = await resolveRequestAuth(context);
|
|
73464
73534
|
if (authResult instanceof Response) {
|
|
73465
73535
|
return authResult;
|
|
73466
73536
|
}
|
|
73467
|
-
|
|
73468
|
-
|
|
73469
|
-
|
|
73470
|
-
|
|
73471
|
-
|
|
73472
|
-
|
|
73473
|
-
|
|
73474
|
-
|
|
73475
|
-
|
|
73476
|
-
|
|
73477
|
-
|
|
73478
|
-
|
|
73479
|
-
|
|
73480
|
-
|
|
73481
|
-
|
|
73482
|
-
|
|
73483
|
-
|
|
73484
|
-
|
|
73485
|
-
|
|
73486
|
-
|
|
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
|
+
}
|
|
73487
73559
|
}
|
|
73488
73560
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
73489
73561
|
return env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73492,13 +73564,14 @@ function parseInteger(value, fallback) {
|
|
|
73492
73564
|
const parsed = value ? Number.parseInt(value, 10) : Number.NaN;
|
|
73493
73565
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
73494
73566
|
}
|
|
73495
|
-
var effects_get_default = defineController2(async (
|
|
73567
|
+
var effects_get_default = defineController2(async (context) => {
|
|
73568
|
+
const { params, url } = context;
|
|
73496
73569
|
const threadId = params.id;
|
|
73497
73570
|
if (!threadId) {
|
|
73498
73571
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73499
73572
|
}
|
|
73500
73573
|
try {
|
|
73501
|
-
const stub = await getAuthorizedThreadStub(
|
|
73574
|
+
const stub = await getAuthorizedThreadStub(context, threadId);
|
|
73502
73575
|
if (stub instanceof Response) return stub;
|
|
73503
73576
|
if (typeof stub.listEffectRuns !== "function") {
|
|
73504
73577
|
return Response.json(
|
|
@@ -73582,31 +73655,34 @@ var fs_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
73582
73655
|
});
|
|
73583
73656
|
|
|
73584
73657
|
// src/api/threads/[id]/kv/index.ts
|
|
73585
|
-
async function getAuthorizedThreadStub2(
|
|
73586
|
-
const
|
|
73658
|
+
async function getAuthorizedThreadStub2(context, threadId) {
|
|
73659
|
+
const { env: env2 } = context;
|
|
73660
|
+
const authResult = await resolveRequestAuth(context);
|
|
73587
73661
|
if (authResult instanceof Response) {
|
|
73588
73662
|
return authResult;
|
|
73589
73663
|
}
|
|
73590
|
-
|
|
73591
|
-
|
|
73592
|
-
|
|
73593
|
-
|
|
73594
|
-
|
|
73595
|
-
|
|
73596
|
-
|
|
73597
|
-
|
|
73598
|
-
|
|
73599
|
-
|
|
73600
|
-
|
|
73601
|
-
|
|
73602
|
-
|
|
73603
|
-
|
|
73604
|
-
|
|
73605
|
-
|
|
73606
|
-
|
|
73607
|
-
|
|
73608
|
-
|
|
73609
|
-
|
|
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
|
+
}
|
|
73610
73686
|
}
|
|
73611
73687
|
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
73612
73688
|
return env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
@@ -73704,13 +73780,14 @@ async function handleDelete(stub, req, url) {
|
|
|
73704
73780
|
await stub.setValue(key, null);
|
|
73705
73781
|
return new Response(null, { status: 204 });
|
|
73706
73782
|
}
|
|
73707
|
-
var kv_default = defineController2(async (
|
|
73783
|
+
var kv_default = defineController2(async (context) => {
|
|
73784
|
+
const { req, params, url } = context;
|
|
73708
73785
|
const threadId = params.id;
|
|
73709
73786
|
if (!threadId) {
|
|
73710
73787
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73711
73788
|
}
|
|
73712
73789
|
try {
|
|
73713
|
-
const stub = await getAuthorizedThreadStub2(
|
|
73790
|
+
const stub = await getAuthorizedThreadStub2(context, threadId);
|
|
73714
73791
|
if (stub instanceof Response) return stub;
|
|
73715
73792
|
switch (req.method) {
|
|
73716
73793
|
case "GET":
|
|
@@ -73735,14 +73812,15 @@ var kv_default = defineController2(async ({ req, params, env: env2, url }) => {
|
|
|
73735
73812
|
});
|
|
73736
73813
|
|
|
73737
73814
|
// src/api/threads/[id]/logs.get.ts
|
|
73738
|
-
var logs_get_default = defineController2(async (
|
|
73815
|
+
var logs_get_default = defineController2(async (context) => {
|
|
73816
|
+
const { req, params, env: env2 } = context;
|
|
73739
73817
|
if (isPlatformHosted(env2)) {
|
|
73740
|
-
const authResult = await
|
|
73818
|
+
const authResult = await resolveRequestPermission(context, "logs");
|
|
73741
73819
|
if (authResult instanceof Response) {
|
|
73742
73820
|
return authResult;
|
|
73743
73821
|
}
|
|
73744
73822
|
} else {
|
|
73745
|
-
const authContext = await
|
|
73823
|
+
const authContext = await resolveOptionalRequestAuth(context);
|
|
73746
73824
|
if (authContext && !hasPermission(authContext.user, "logs")) {
|
|
73747
73825
|
return Response.json(
|
|
73748
73826
|
{ error: "Forbidden: 'logs' access required" },
|
|
@@ -73756,9 +73834,12 @@ var logs_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
|
73756
73834
|
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
73757
73835
|
}
|
|
73758
73836
|
try {
|
|
73759
|
-
|
|
73760
|
-
|
|
73761
|
-
|
|
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
|
+
}
|
|
73762
73843
|
if (!thread) {
|
|
73763
73844
|
return Response.json(
|
|
73764
73845
|
{ error: `Thread not found: ${threadId}` },
|