@standardagents/builder 0.37.8 → 0.38.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 +106 -177
- package/dist/built-in-routes.js.map +1 -1
- package/dist/{index-Lfan8QMN.d.ts → index-BBu-Osn5.d.ts} +10 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +98 -60
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +29 -4
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.js +69 -56
- 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
|
@@ -67050,111 +67050,6 @@ function getParamRegexp(segment) {
|
|
|
67050
67050
|
|
|
67051
67051
|
// src/router/index.ts
|
|
67052
67052
|
init_ThreadStateImpl();
|
|
67053
|
-
function defineController2(controller) {
|
|
67054
|
-
return controller;
|
|
67055
|
-
}
|
|
67056
|
-
|
|
67057
|
-
// src/api/index.post.ts
|
|
67058
|
-
var index_post_default = defineController2(() => {
|
|
67059
|
-
const stream = new ReadableStream({
|
|
67060
|
-
start(controller) {
|
|
67061
|
-
const text2 = "hello world";
|
|
67062
|
-
let index = 0;
|
|
67063
|
-
const next = () => {
|
|
67064
|
-
if (index < text2.length) {
|
|
67065
|
-
controller.enqueue(new TextEncoder().encode(text2[index]));
|
|
67066
|
-
index++;
|
|
67067
|
-
setTimeout(next, 100);
|
|
67068
|
-
} else {
|
|
67069
|
-
controller.close();
|
|
67070
|
-
}
|
|
67071
|
-
};
|
|
67072
|
-
next();
|
|
67073
|
-
}
|
|
67074
|
-
});
|
|
67075
|
-
return new Response(stream);
|
|
67076
|
-
});
|
|
67077
|
-
|
|
67078
|
-
// src/api/agents.get.ts
|
|
67079
|
-
var agents_get_default = defineController2(async ({ agents, agentNames, registry, auth }) => {
|
|
67080
|
-
const includeAuthoringDetails = auth?.user.role === "admin";
|
|
67081
|
-
const agentList = [];
|
|
67082
|
-
console.log("[agents.get] Registry packages:", registry?.packages ? Object.keys(registry.packages) : "undefined");
|
|
67083
|
-
if (agents && agentNames) {
|
|
67084
|
-
const globalAgents = await Promise.all(
|
|
67085
|
-
agentNames.map(async (name15) => {
|
|
67086
|
-
try {
|
|
67087
|
-
const loader = agents[name15];
|
|
67088
|
-
if (!loader) {
|
|
67089
|
-
return null;
|
|
67090
|
-
}
|
|
67091
|
-
const definition = await loader();
|
|
67092
|
-
return {
|
|
67093
|
-
id: definition.name,
|
|
67094
|
-
name: definition.name,
|
|
67095
|
-
title: definition.title || definition.name,
|
|
67096
|
-
type: definition.type || "ai_human",
|
|
67097
|
-
description: definition.description || null,
|
|
67098
|
-
icon: definition.icon || null,
|
|
67099
|
-
primary: definition.primary !== false,
|
|
67100
|
-
...includeAuthoringDetails ? {
|
|
67101
|
-
default_prompt: definition.sideA?.prompt || "",
|
|
67102
|
-
default_model: "",
|
|
67103
|
-
tools: [],
|
|
67104
|
-
side_a_label: definition.sideA?.label || null,
|
|
67105
|
-
side_a_agent_prompt: definition.sideA?.prompt || null,
|
|
67106
|
-
side_b_label: definition.sideB?.label || null,
|
|
67107
|
-
side_b_agent_prompt: definition.sideB?.prompt || null,
|
|
67108
|
-
env: definition.env || null
|
|
67109
|
-
} : {},
|
|
67110
|
-
created_at: Math.floor(Date.now() / 1e3),
|
|
67111
|
-
packed: false
|
|
67112
|
-
};
|
|
67113
|
-
} catch (error) {
|
|
67114
|
-
console.error(`Error loading agent ${name15}:`, error);
|
|
67115
|
-
return null;
|
|
67116
|
-
}
|
|
67117
|
-
})
|
|
67118
|
-
);
|
|
67119
|
-
agentList.push(...globalAgents);
|
|
67120
|
-
}
|
|
67121
|
-
if (registry?.packages) {
|
|
67122
|
-
for (const [packageId, pkg] of Object.entries(registry.packages)) {
|
|
67123
|
-
const packageData = pkg;
|
|
67124
|
-
for (const agentName of packageData.entryAgents) {
|
|
67125
|
-
try {
|
|
67126
|
-
const loader = packageData.agents[agentName];
|
|
67127
|
-
if (!loader) continue;
|
|
67128
|
-
const definition = await loader();
|
|
67129
|
-
agentList.push({
|
|
67130
|
-
id: `${packageId}/${definition.name}`,
|
|
67131
|
-
name: definition.name,
|
|
67132
|
-
title: definition.title || definition.name,
|
|
67133
|
-
type: definition.type || "ai_human",
|
|
67134
|
-
description: definition.description || null,
|
|
67135
|
-
icon: definition.icon || null,
|
|
67136
|
-
primary: definition.primary !== false,
|
|
67137
|
-
...includeAuthoringDetails ? {
|
|
67138
|
-
default_prompt: definition.sideA?.prompt || "",
|
|
67139
|
-
default_model: "",
|
|
67140
|
-
tools: [],
|
|
67141
|
-
side_a_agent_prompt: definition.sideA?.prompt ? definition.sideA.prompt.includes("/") ? definition.sideA.prompt : `${packageId}/${definition.sideA.prompt}` : null,
|
|
67142
|
-
side_b_agent_prompt: definition.sideB?.prompt ? definition.sideB.prompt.includes("/") ? definition.sideB.prompt : `${packageId}/${definition.sideB.prompt}` : null
|
|
67143
|
-
} : {},
|
|
67144
|
-
created_at: Math.floor(Date.now() / 1e3),
|
|
67145
|
-
packed: true,
|
|
67146
|
-
packageId,
|
|
67147
|
-
source: packageData.signature.source
|
|
67148
|
-
});
|
|
67149
|
-
} catch (error) {
|
|
67150
|
-
console.error(`Error loading packed agent ${agentName} from ${packageId}:`, error);
|
|
67151
|
-
}
|
|
67152
|
-
}
|
|
67153
|
-
}
|
|
67154
|
-
}
|
|
67155
|
-
const validAgents = agentList.filter(Boolean);
|
|
67156
|
-
return Response.json({ agents: validAgents });
|
|
67157
|
-
});
|
|
67158
67053
|
|
|
67159
67054
|
// src/utils/auth.ts
|
|
67160
67055
|
function generateSecureToken(length = 32) {
|
|
@@ -67525,6 +67420,111 @@ async function requireAdmin(request, env2) {
|
|
|
67525
67420
|
}
|
|
67526
67421
|
return result;
|
|
67527
67422
|
}
|
|
67423
|
+
function defineController2(controller) {
|
|
67424
|
+
return controller;
|
|
67425
|
+
}
|
|
67426
|
+
|
|
67427
|
+
// src/api/index.post.ts
|
|
67428
|
+
var index_post_default = defineController2(() => {
|
|
67429
|
+
const stream = new ReadableStream({
|
|
67430
|
+
start(controller) {
|
|
67431
|
+
const text2 = "hello world";
|
|
67432
|
+
let index = 0;
|
|
67433
|
+
const next = () => {
|
|
67434
|
+
if (index < text2.length) {
|
|
67435
|
+
controller.enqueue(new TextEncoder().encode(text2[index]));
|
|
67436
|
+
index++;
|
|
67437
|
+
setTimeout(next, 100);
|
|
67438
|
+
} else {
|
|
67439
|
+
controller.close();
|
|
67440
|
+
}
|
|
67441
|
+
};
|
|
67442
|
+
next();
|
|
67443
|
+
}
|
|
67444
|
+
});
|
|
67445
|
+
return new Response(stream);
|
|
67446
|
+
});
|
|
67447
|
+
|
|
67448
|
+
// src/api/agents.get.ts
|
|
67449
|
+
var agents_get_default = defineController2(async ({ agents, agentNames, registry, auth }) => {
|
|
67450
|
+
const includeAuthoringDetails = auth?.user.role === "admin";
|
|
67451
|
+
const agentList = [];
|
|
67452
|
+
console.log("[agents.get] Registry packages:", registry?.packages ? Object.keys(registry.packages) : "undefined");
|
|
67453
|
+
if (agents && agentNames) {
|
|
67454
|
+
const globalAgents = await Promise.all(
|
|
67455
|
+
agentNames.map(async (name15) => {
|
|
67456
|
+
try {
|
|
67457
|
+
const loader = agents[name15];
|
|
67458
|
+
if (!loader) {
|
|
67459
|
+
return null;
|
|
67460
|
+
}
|
|
67461
|
+
const definition = await loader();
|
|
67462
|
+
return {
|
|
67463
|
+
id: definition.name,
|
|
67464
|
+
name: definition.name,
|
|
67465
|
+
title: definition.title || definition.name,
|
|
67466
|
+
type: definition.type || "ai_human",
|
|
67467
|
+
description: definition.description || null,
|
|
67468
|
+
icon: definition.icon || null,
|
|
67469
|
+
primary: definition.primary !== false,
|
|
67470
|
+
...includeAuthoringDetails ? {
|
|
67471
|
+
default_prompt: definition.sideA?.prompt || "",
|
|
67472
|
+
default_model: "",
|
|
67473
|
+
tools: [],
|
|
67474
|
+
side_a_label: definition.sideA?.label || null,
|
|
67475
|
+
side_a_agent_prompt: definition.sideA?.prompt || null,
|
|
67476
|
+
side_b_label: definition.sideB?.label || null,
|
|
67477
|
+
side_b_agent_prompt: definition.sideB?.prompt || null,
|
|
67478
|
+
env: definition.env || null
|
|
67479
|
+
} : {},
|
|
67480
|
+
created_at: Math.floor(Date.now() / 1e3),
|
|
67481
|
+
packed: false
|
|
67482
|
+
};
|
|
67483
|
+
} catch (error) {
|
|
67484
|
+
console.error(`Error loading agent ${name15}:`, error);
|
|
67485
|
+
return null;
|
|
67486
|
+
}
|
|
67487
|
+
})
|
|
67488
|
+
);
|
|
67489
|
+
agentList.push(...globalAgents);
|
|
67490
|
+
}
|
|
67491
|
+
if (registry?.packages) {
|
|
67492
|
+
for (const [packageId, pkg] of Object.entries(registry.packages)) {
|
|
67493
|
+
const packageData = pkg;
|
|
67494
|
+
for (const agentName of packageData.entryAgents) {
|
|
67495
|
+
try {
|
|
67496
|
+
const loader = packageData.agents[agentName];
|
|
67497
|
+
if (!loader) continue;
|
|
67498
|
+
const definition = await loader();
|
|
67499
|
+
agentList.push({
|
|
67500
|
+
id: `${packageId}/${definition.name}`,
|
|
67501
|
+
name: definition.name,
|
|
67502
|
+
title: definition.title || definition.name,
|
|
67503
|
+
type: definition.type || "ai_human",
|
|
67504
|
+
description: definition.description || null,
|
|
67505
|
+
icon: definition.icon || null,
|
|
67506
|
+
primary: definition.primary !== false,
|
|
67507
|
+
...includeAuthoringDetails ? {
|
|
67508
|
+
default_prompt: definition.sideA?.prompt || "",
|
|
67509
|
+
default_model: "",
|
|
67510
|
+
tools: [],
|
|
67511
|
+
side_a_agent_prompt: definition.sideA?.prompt ? definition.sideA.prompt.includes("/") ? definition.sideA.prompt : `${packageId}/${definition.sideA.prompt}` : null,
|
|
67512
|
+
side_b_agent_prompt: definition.sideB?.prompt ? definition.sideB.prompt.includes("/") ? definition.sideB.prompt : `${packageId}/${definition.sideB.prompt}` : null
|
|
67513
|
+
} : {},
|
|
67514
|
+
created_at: Math.floor(Date.now() / 1e3),
|
|
67515
|
+
packed: true,
|
|
67516
|
+
packageId,
|
|
67517
|
+
source: packageData.signature.source
|
|
67518
|
+
});
|
|
67519
|
+
} catch (error) {
|
|
67520
|
+
console.error(`Error loading packed agent ${agentName} from ${packageId}:`, error);
|
|
67521
|
+
}
|
|
67522
|
+
}
|
|
67523
|
+
}
|
|
67524
|
+
}
|
|
67525
|
+
const validAgents = agentList.filter(Boolean);
|
|
67526
|
+
return Response.json({ agents: validAgents });
|
|
67527
|
+
});
|
|
67528
67528
|
|
|
67529
67529
|
// src/routing/access-policy.ts
|
|
67530
67530
|
function isHostedInstance(env2) {
|
|
@@ -68031,7 +68031,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
|
|
|
68031
68031
|
});
|
|
68032
68032
|
|
|
68033
68033
|
// src/version.ts
|
|
68034
|
-
var BUILDER_VERSION = "0.
|
|
68034
|
+
var BUILDER_VERSION = "0.38.0".length > 0 ? "0.38.0" : "dev";
|
|
68035
68035
|
|
|
68036
68036
|
// src/api/diagnostics.get.ts
|
|
68037
68037
|
init_LLMRequest();
|
|
@@ -75649,76 +75649,6 @@ var messageId_patch_default = defineController2(async ({ req, params, env: env2
|
|
|
75649
75649
|
}
|
|
75650
75650
|
});
|
|
75651
75651
|
|
|
75652
|
-
// src/api/threads/[id]/public/[...path].ts
|
|
75653
|
-
var path_default4 = defineController2(async ({ req, params, env: env2 }) => {
|
|
75654
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
75655
|
-
return Response.json({ error: "Method not allowed" }, { status: 405 });
|
|
75656
|
-
}
|
|
75657
|
-
const threadId = params.id;
|
|
75658
|
-
if (!threadId) {
|
|
75659
|
-
return Response.json({ error: "Thread ID required" }, { status: 400 });
|
|
75660
|
-
}
|
|
75661
|
-
const rawPathParam = params._ || params.path || params["*"] || "";
|
|
75662
|
-
const relative4 = rawPathParam === "public" ? "" : rawPathParam.replace(/^\/?public\//, "");
|
|
75663
|
-
const segments = [];
|
|
75664
|
-
for (const part of relative4.replace(/\\/g, "/").split("/")) {
|
|
75665
|
-
if (!part || part === ".") continue;
|
|
75666
|
-
if (part === "..") return notFound();
|
|
75667
|
-
segments.push(part);
|
|
75668
|
-
}
|
|
75669
|
-
if (segments.length === 0) return notFound();
|
|
75670
|
-
const path10 = `/public/${segments.join("/")}`;
|
|
75671
|
-
try {
|
|
75672
|
-
const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
|
|
75673
|
-
const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
|
|
75674
|
-
const statResult = await stub.statFile(path10);
|
|
75675
|
-
if (!statResult?.success) return notFound();
|
|
75676
|
-
const file = statResult.file;
|
|
75677
|
-
if (!file || file.isDirectory || file.storage !== "local") return notFound();
|
|
75678
|
-
const headers = {
|
|
75679
|
-
"Content-Type": file.mimeType || "application/octet-stream",
|
|
75680
|
-
"Content-Length": String(file.size),
|
|
75681
|
-
"Content-Disposition": `inline; filename="${file.name}"`,
|
|
75682
|
-
// Public files are mutable (unlike content-addressed assets): cache
|
|
75683
|
-
// briefly so shares are fast without pinning stale content for a year.
|
|
75684
|
-
"Cache-Control": "public, max-age=300"
|
|
75685
|
-
};
|
|
75686
|
-
if (req.method === "HEAD") return new Response(null, { headers });
|
|
75687
|
-
if (file.isChunked && file.chunkCount) {
|
|
75688
|
-
const { readable, writable } = new TransformStream();
|
|
75689
|
-
const writer = writable.getWriter();
|
|
75690
|
-
(async () => {
|
|
75691
|
-
try {
|
|
75692
|
-
for (let i = 0; i < file.chunkCount; i++) {
|
|
75693
|
-
const chunk = await stub.readFileChunk(path10, i);
|
|
75694
|
-
if (!chunk?.success) break;
|
|
75695
|
-
const binary2 = atob(chunk.data);
|
|
75696
|
-
const bytes2 = new Uint8Array(binary2.length);
|
|
75697
|
-
for (let j = 0; j < binary2.length; j++) bytes2[j] = binary2.charCodeAt(j);
|
|
75698
|
-
await writer.write(bytes2);
|
|
75699
|
-
}
|
|
75700
|
-
} finally {
|
|
75701
|
-
await writer.close().catch(() => {
|
|
75702
|
-
});
|
|
75703
|
-
}
|
|
75704
|
-
})();
|
|
75705
|
-
return new Response(readable, { headers });
|
|
75706
|
-
}
|
|
75707
|
-
const result = await stub.readFile(path10);
|
|
75708
|
-
if (!result?.success) return notFound();
|
|
75709
|
-
const binary = atob(result.data);
|
|
75710
|
-
const bytes = new Uint8Array(binary.length);
|
|
75711
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
75712
|
-
return new Response(bytes, { headers });
|
|
75713
|
-
} catch (error) {
|
|
75714
|
-
console.error(`Error serving public file for thread ${threadId}:`, error);
|
|
75715
|
-
return notFound();
|
|
75716
|
-
}
|
|
75717
|
-
});
|
|
75718
|
-
function notFound() {
|
|
75719
|
-
return Response.json({ error: "Not found" }, { status: 404 });
|
|
75720
|
-
}
|
|
75721
|
-
|
|
75722
75652
|
// src/api/threads/[id]/variables/[requestId].get.ts
|
|
75723
75653
|
var requestId_get_default = defineController2(async ({ req, params, env: env2 }) => {
|
|
75724
75654
|
const authResult = await requireAuth(req, env2);
|
|
@@ -76363,7 +76293,6 @@ var routeHandlers = {
|
|
|
76363
76293
|
"GET:/threads/:id/logs/:logId": logId_get_default,
|
|
76364
76294
|
"DELETE:/threads/:id/messages/:messageId": messageId_delete_default,
|
|
76365
76295
|
"PATCH:/threads/:id/messages/:messageId": messageId_patch_default,
|
|
76366
|
-
"GET:/threads/:id/public/**": path_default4,
|
|
76367
76296
|
"GET:/threads/:id/variables/:requestId": requestId_get_default,
|
|
76368
76297
|
"POST:/threads/:id/variables/:requestId": requestId_post_default,
|
|
76369
76298
|
"POST:/threads/:id/effects/:effectId/cancel": cancel_post_default,
|