@standardagents/builder 0.15.3 → 0.16.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 +290 -270
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/ApiKeysView.js +1 -1
- package/dist/client/CenteredContentView.js +1 -1
- package/dist/client/CompositionView.js +1 -1
- package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/JsonViewer.js +1 -1
- package/dist/client/LoginView.js +1 -1
- package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ModelsView.js +1 -1
- package/dist/client/PromptEditView.js +1 -1
- package/dist/client/PromptModal.js +1 -1
- package/dist/client/PromptsView.js +1 -1
- package/dist/client/ProvidersView.js +2 -2
- package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/client/ToolsView.js +1 -1
- package/dist/client/UsersView.js +1 -1
- package/dist/client/VariablesView.js +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +3 -3
- package/dist/{discovery-DVviz3By.d.ts → discovery-DiMJWisl.d.ts} +1 -1
- package/dist/{index-BwqQtJ4r.d.ts → index-EaxysUHv.d.ts} +2 -5
- package/dist/index.d.ts +116 -3402
- package/dist/index.js +149 -323
- package/dist/index.js.map +1 -1
- package/dist/packing.d.ts +3 -3
- package/dist/plugin.d.ts +5 -4
- package/dist/plugin.js +143 -78
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +3124 -0
- package/dist/runtime.js +21178 -0
- package/dist/runtime.js.map +1 -0
- package/dist/test.d.ts +2 -2
- package/dist/{types-DH3Egc5l.d.ts → types-Bpe7IANZ.d.ts} +1 -1
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { fileURLToPath } from 'url';
|
|
|
10
10
|
import MagicString from 'magic-string';
|
|
11
11
|
import { exec } from 'child_process';
|
|
12
12
|
import { promisify } from 'util';
|
|
13
|
+
import { cloudflare } from '@cloudflare/vite-plugin';
|
|
13
14
|
import { DurableObject, WorkerEntrypoint } from 'cloudflare:workers';
|
|
14
15
|
|
|
15
16
|
var __defProp = Object.defineProperty;
|
|
@@ -9506,7 +9507,7 @@ function runCodeInDynamicWorker(params) {
|
|
|
9506
9507
|
durationMs: Date.now() - startedAt,
|
|
9507
9508
|
error: {
|
|
9508
9509
|
name: "MissingWorkerLoader",
|
|
9509
|
-
message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or
|
|
9510
|
+
message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or use builder(), which injects the worker_loaders binding.`
|
|
9510
9511
|
}
|
|
9511
9512
|
};
|
|
9512
9513
|
}
|
|
@@ -12639,14 +12640,9 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
12639
12640
|
|
|
12640
12641
|
/**
|
|
12641
12642
|
* DurableThread with all virtual module methods pre-implemented.
|
|
12642
|
-
*
|
|
12643
|
-
*
|
|
12644
|
-
*
|
|
12645
|
-
* \`\`\`typescript
|
|
12646
|
-
* import { DurableThread } from 'virtual:@standardagents/builder'
|
|
12647
|
-
*
|
|
12648
|
-
* export class Thread extends DurableThread {}
|
|
12649
|
-
* \`\`\`
|
|
12643
|
+
* The generated AgentBuilder Worker entry exports this class automatically;
|
|
12644
|
+
* projects should not create agents/Thread.ts unless they are intentionally
|
|
12645
|
+
* taking over the Worker surface.
|
|
12650
12646
|
*/
|
|
12651
12647
|
export class DurableThread extends BaseDurableThread {
|
|
12652
12648
|
// Virtual module registry methods
|
|
@@ -12817,14 +12813,9 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
12817
12813
|
|
|
12818
12814
|
/**
|
|
12819
12815
|
* DurableAgentBuilder with all virtual module methods pre-implemented.
|
|
12820
|
-
*
|
|
12821
|
-
*
|
|
12822
|
-
*
|
|
12823
|
-
* \`\`\`typescript
|
|
12824
|
-
* import { DurableAgentBuilder } from 'virtual:@standardagents/builder'
|
|
12825
|
-
*
|
|
12826
|
-
* export class AgentBuilder extends DurableAgentBuilder {}
|
|
12827
|
-
* \`\`\`
|
|
12816
|
+
* The generated AgentBuilder Worker entry exports this class automatically;
|
|
12817
|
+
* projects should not create agents/AgentBuilder.ts unless they are
|
|
12818
|
+
* intentionally taking over the Worker surface.
|
|
12828
12819
|
*/
|
|
12829
12820
|
export class DurableAgentBuilder extends BaseDurableAgentBuilder {
|
|
12830
12821
|
// Virtual module registry methods
|
|
@@ -12982,7 +12973,7 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
12982
12973
|
providerUserId: string
|
|
12983
12974
|
): Promise<User | null>;
|
|
12984
12975
|
|
|
12985
|
-
// Edit lock methods
|
|
12976
|
+
// Edit lock methods
|
|
12986
12977
|
acquireEditLock(params: {
|
|
12987
12978
|
locked_by: string;
|
|
12988
12979
|
lock_reason: string;
|
|
@@ -18812,14 +18803,12 @@ function readRawRequestBody(req) {
|
|
|
18812
18803
|
req.on("error", reject);
|
|
18813
18804
|
});
|
|
18814
18805
|
}
|
|
18815
|
-
function injectUiConfigIntoHtml(htmlContent
|
|
18816
|
-
const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = {
|
|
18817
|
-
|
|
18818
|
-
return htmlContent.replace(/\/agents\//g, assetPrefix).replace("</head>", `${configScript}</head>`);
|
|
18806
|
+
function injectUiConfigIntoHtml(htmlContent) {
|
|
18807
|
+
const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { devMode: true };</script>`;
|
|
18808
|
+
return htmlContent.replace(/\/agents\//g, "/").replace("</head>", `${configScript}</head>`);
|
|
18819
18809
|
}
|
|
18820
18810
|
function createDevMiddleware(server, context) {
|
|
18821
18811
|
const {
|
|
18822
|
-
mountPoint,
|
|
18823
18812
|
toolsDir,
|
|
18824
18813
|
hooksDir,
|
|
18825
18814
|
modelsDir,
|
|
@@ -18839,17 +18828,14 @@ function createDevMiddleware(server, context) {
|
|
|
18839
18828
|
});
|
|
18840
18829
|
server.middlewares.use(async (req, res, next) => {
|
|
18841
18830
|
const url = req.url;
|
|
18842
|
-
if (!url || !url.startsWith(
|
|
18831
|
+
if (!url || !url.startsWith("/")) {
|
|
18843
18832
|
next();
|
|
18844
18833
|
return;
|
|
18845
18834
|
}
|
|
18846
|
-
let pathWithoutMount = url
|
|
18847
|
-
if (!pathWithoutMount.startsWith("/")) {
|
|
18848
|
-
pathWithoutMount = "/" + pathWithoutMount;
|
|
18849
|
-
}
|
|
18835
|
+
let pathWithoutMount = url;
|
|
18850
18836
|
const method = req.method?.toUpperCase();
|
|
18851
18837
|
const legacyMountPoint = "/agentbuilder";
|
|
18852
|
-
if (
|
|
18838
|
+
if (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`)) {
|
|
18853
18839
|
const normalizedPath = pathWithoutMount.slice(legacyMountPoint.length) || "/";
|
|
18854
18840
|
if (normalizedPath.startsWith("/api/")) {
|
|
18855
18841
|
req.url = normalizedPath;
|
|
@@ -18934,7 +18920,7 @@ function createDevMiddleware(server, context) {
|
|
|
18934
18920
|
const contentType = proxyRes.headers.get("content-type") || "";
|
|
18935
18921
|
if (contentType.includes("text/html")) {
|
|
18936
18922
|
const htmlBody = await proxyRes.text();
|
|
18937
|
-
const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody
|
|
18923
|
+
const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody));
|
|
18938
18924
|
res.setHeader("content-length", String(injectedHtml.byteLength));
|
|
18939
18925
|
res.end(injectedHtml);
|
|
18940
18926
|
return;
|
|
@@ -18946,7 +18932,7 @@ function createDevMiddleware(server, context) {
|
|
|
18946
18932
|
console.error("[agentbuilder] Failed to proxy to UI dev server:", error);
|
|
18947
18933
|
}
|
|
18948
18934
|
}
|
|
18949
|
-
const clientPath =
|
|
18935
|
+
const clientPath = pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
|
|
18950
18936
|
const isStaticAsset = clientPath.startsWith("/assets/") || clientPath.startsWith("/vendor.js") || clientPath.startsWith("/vue.js") || clientPath.startsWith("/monaco.js") || clientPath.startsWith("/index.js") || clientPath.startsWith("/index.css") || clientPath.match(/\.(js|css|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot|ico)$/);
|
|
18951
18937
|
{
|
|
18952
18938
|
const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
|
|
@@ -18968,7 +18954,7 @@ function createDevMiddleware(server, context) {
|
|
|
18968
18954
|
const ext = path8__default.extname(filePath).toLowerCase();
|
|
18969
18955
|
if (ext === ".html") {
|
|
18970
18956
|
content = Buffer.from(
|
|
18971
|
-
injectUiConfigIntoHtml(content.toString()
|
|
18957
|
+
injectUiConfigIntoHtml(content.toString())
|
|
18972
18958
|
);
|
|
18973
18959
|
}
|
|
18974
18960
|
const mimeTypes = {
|
|
@@ -19144,7 +19130,8 @@ ${effectsCode}
|
|
|
19144
19130
|
|
|
19145
19131
|
/**
|
|
19146
19132
|
* DurableThread with all virtual module methods already implemented.
|
|
19147
|
-
*
|
|
19133
|
+
* Exported by the generated AgentBuilder Worker entry; user projects do not
|
|
19134
|
+
* need an agents/Thread.ts file for the standard hosted/runtime path.
|
|
19148
19135
|
*/
|
|
19149
19136
|
export class DurableThread extends _BaseDurableThread {
|
|
19150
19137
|
constructor(ctx, env) {
|
|
@@ -19188,7 +19175,8 @@ export class DurableThread extends _BaseDurableThread {
|
|
|
19188
19175
|
|
|
19189
19176
|
/**
|
|
19190
19177
|
* DurableAgentBuilder with all virtual module methods already implemented.
|
|
19191
|
-
*
|
|
19178
|
+
* Exported by the generated AgentBuilder Worker entry; user projects do not
|
|
19179
|
+
* need an agents/AgentBuilder.ts file for the standard hosted/runtime path.
|
|
19192
19180
|
*/
|
|
19193
19181
|
export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
19194
19182
|
tools() {
|
|
@@ -19394,7 +19382,7 @@ export function getVisibleToolNames() {
|
|
|
19394
19382
|
`;
|
|
19395
19383
|
}
|
|
19396
19384
|
async function loadRoutesVirtualModule(context) {
|
|
19397
|
-
const {
|
|
19385
|
+
const { threadApiDir, rou3Code, hmr } = context;
|
|
19398
19386
|
const threadRoutes = scanApiDirectory(threadApiDir);
|
|
19399
19387
|
const toAbsolutePath = (inputPath) => path8__default.resolve(process.cwd(), inputPath).replace(/\\/g, "/");
|
|
19400
19388
|
const threadRouteCode = threadRoutes.map(({ method, route, importPath }) => {
|
|
@@ -19456,8 +19444,6 @@ import { registry } from "virtual:@standardagents-registry";
|
|
|
19456
19444
|
import { requireAuth, createThreadEndpointHandler } from "@standardagents/builder/runtime";
|
|
19457
19445
|
import { isThreadEndpoint } from "@standardagents/spec";
|
|
19458
19446
|
|
|
19459
|
-
const MOUNT_POINT = "${mountPoint}";
|
|
19460
|
-
|
|
19461
19447
|
// Routes that don't require authentication
|
|
19462
19448
|
const PUBLIC_ROUTES = [
|
|
19463
19449
|
'/api/auth/bootstrap',
|
|
@@ -19556,11 +19542,6 @@ export async function router(request, env) {
|
|
|
19556
19542
|
const url = new URL(request.url);
|
|
19557
19543
|
const pathname = url.pathname;
|
|
19558
19544
|
|
|
19559
|
-
// Check if request is under mount point
|
|
19560
|
-
if (!pathname.startsWith(MOUNT_POINT)) {
|
|
19561
|
-
return null;
|
|
19562
|
-
}
|
|
19563
|
-
|
|
19564
19545
|
// Handle CORS preflight requests
|
|
19565
19546
|
if (request.method === "OPTIONS") {
|
|
19566
19547
|
return new Response(null, {
|
|
@@ -19569,11 +19550,7 @@ export async function router(request, env) {
|
|
|
19569
19550
|
});
|
|
19570
19551
|
}
|
|
19571
19552
|
|
|
19572
|
-
|
|
19573
|
-
let routePath = pathname.slice(MOUNT_POINT.length) || "/";
|
|
19574
|
-
if (!routePath.startsWith('/')) {
|
|
19575
|
-
routePath = '/' + routePath;
|
|
19576
|
-
}
|
|
19553
|
+
const routePath = pathname || "/";
|
|
19577
19554
|
|
|
19578
19555
|
// Handle API routes
|
|
19579
19556
|
const router = createRouter();
|
|
@@ -19651,32 +19628,29 @@ ${packedThreadRouteCode}
|
|
|
19651
19628
|
|
|
19652
19629
|
async function serveUI(pathname, env) {
|
|
19653
19630
|
try {
|
|
19654
|
-
const clientPath =
|
|
19655
|
-
|
|
19656
|
-
|
|
19657
|
-
: pathname;
|
|
19631
|
+
const clientPath = pathname.startsWith("/agents/")
|
|
19632
|
+
? pathname.slice("/agents".length) || "/"
|
|
19633
|
+
: pathname;
|
|
19658
19634
|
|
|
19659
|
-
// Use Cloudflare Workers Assets binding
|
|
19635
|
+
// Use the Cloudflare Workers Assets binding created by builder()'s generated
|
|
19636
|
+
// Cloudflare Vite plugin config.
|
|
19660
19637
|
if (env.ASSETS) {
|
|
19661
19638
|
try {
|
|
19662
19639
|
// Create a proper request for the asset path
|
|
19663
19640
|
// Use a dummy origin since we only care about the path
|
|
19664
|
-
|
|
19665
|
-
// Handle root mountPoint "/" specially to avoid double slashes
|
|
19666
|
-
const mountPrefix = MOUNT_POINT === "/" ? "" : MOUNT_POINT;
|
|
19667
|
-
const assetUrl = \`http://localhost\${mountPrefix}\${clientPath}\`;
|
|
19641
|
+
const assetUrl = \`http://localhost\${clientPath}\`;
|
|
19668
19642
|
let response = await env.ASSETS.fetch(assetUrl);
|
|
19669
19643
|
|
|
19670
19644
|
// If not found, fall back to index.html for SPA routing
|
|
19671
19645
|
const isIndexHtml = response.status === 404 || clientPath === "/" || !clientPath.includes(".");
|
|
19672
19646
|
if (isIndexHtml) {
|
|
19673
|
-
response = await env.ASSETS.fetch(\`http://localhost
|
|
19647
|
+
response = await env.ASSETS.fetch(\`http://localhost/index.html\`);
|
|
19674
19648
|
|
|
19675
|
-
// Transform
|
|
19649
|
+
// Transform standalone UI asset URLs to root. AgentBuilder owns the
|
|
19650
|
+
// entire Worker surface and has no configurable mount point.
|
|
19676
19651
|
if (response.status === 200) {
|
|
19677
19652
|
const html = await response.text();
|
|
19678
|
-
|
|
19679
|
-
const modifiedHtml = html.replace(/\\/agents\\//g, \`\${MOUNT_POINT}/\`);
|
|
19653
|
+
const modifiedHtml = html.replace(/\\/agents\\//g, "/");
|
|
19680
19654
|
return new Response(modifiedHtml, {
|
|
19681
19655
|
headers: {
|
|
19682
19656
|
"Content-Type": "text/html; charset=utf-8",
|
|
@@ -19713,7 +19687,6 @@ async function serveUI(pathname, env) {
|
|
|
19713
19687
|
// src/plugin/virtual-modules.ts
|
|
19714
19688
|
async function loadVirtualModule(id, context) {
|
|
19715
19689
|
const {
|
|
19716
|
-
mountPoint,
|
|
19717
19690
|
toolsDir,
|
|
19718
19691
|
hooksDir,
|
|
19719
19692
|
threadApiDir,
|
|
@@ -19785,7 +19758,6 @@ export const config = {
|
|
|
19785
19758
|
modelsDir: "${relativeModelsDir}",
|
|
19786
19759
|
promptsDir: "${relativePromptsDir}",
|
|
19787
19760
|
agentsDir: "${relativeAgentsDir}",
|
|
19788
|
-
mountPoint: "${mountPoint}",
|
|
19789
19761
|
};`;
|
|
19790
19762
|
}
|
|
19791
19763
|
if (id === RESOLVED_VIRTUAL_MODELS_ID) {
|
|
@@ -19910,6 +19882,7 @@ ${allProviders.map((p) => ` "${p.name}": async () => (await import("${p.package
|
|
|
19910
19882
|
return loadBuilderVirtualModule(context);
|
|
19911
19883
|
}
|
|
19912
19884
|
}
|
|
19885
|
+
var DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE = "2025-08-13";
|
|
19913
19886
|
var depsToExclude = [
|
|
19914
19887
|
"@standardagents/builder",
|
|
19915
19888
|
"@standardagents/builder/runtime",
|
|
@@ -19977,6 +19950,77 @@ function createPluginViteConfig(pluginModuleUrl) {
|
|
|
19977
19950
|
}
|
|
19978
19951
|
};
|
|
19979
19952
|
}
|
|
19953
|
+
function createAgentBuilderWorkerConfig(options) {
|
|
19954
|
+
const compatibilityDate = options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE;
|
|
19955
|
+
return {
|
|
19956
|
+
// This object is the generated Cloudflare Worker config for customer apps.
|
|
19957
|
+
// Future agents: update this instead of reintroducing wrangler.jsonc in the
|
|
19958
|
+
// generated project template. Customer repos should only need builder()
|
|
19959
|
+
// in vite.config.ts plus their agents/ source tree.
|
|
19960
|
+
main: options.workerEntry,
|
|
19961
|
+
compatibility_date: compatibilityDate,
|
|
19962
|
+
compatibility_flags: ["nodejs_compat", "enable_ctx_exports"],
|
|
19963
|
+
observability: {
|
|
19964
|
+
enabled: true
|
|
19965
|
+
},
|
|
19966
|
+
worker_loaders: [
|
|
19967
|
+
{
|
|
19968
|
+
binding: "AGENT_BUILDER_CODE_LOADER"
|
|
19969
|
+
}
|
|
19970
|
+
],
|
|
19971
|
+
vars: {
|
|
19972
|
+
// Future agents: keep this aligned with compatibility_date unless code
|
|
19973
|
+
// execution needs a deliberately different Dynamic Worker date.
|
|
19974
|
+
AGENT_BUILDER_CODE_COMPATIBILITY_DATE: compatibilityDate
|
|
19975
|
+
},
|
|
19976
|
+
assets: {
|
|
19977
|
+
// The builder's client UI is emitted as Vite assets and then wrapped by
|
|
19978
|
+
// the hosted platform when deploying through Workers for Platforms.
|
|
19979
|
+
directory: "dist/client",
|
|
19980
|
+
not_found_handling: "single-page-application",
|
|
19981
|
+
binding: "ASSETS",
|
|
19982
|
+
run_worker_first: ["/**"]
|
|
19983
|
+
},
|
|
19984
|
+
durable_objects: {
|
|
19985
|
+
bindings: [
|
|
19986
|
+
{
|
|
19987
|
+
name: "AGENT_BUILDER_THREAD",
|
|
19988
|
+
class_name: "DurableThread"
|
|
19989
|
+
},
|
|
19990
|
+
{
|
|
19991
|
+
name: "AGENT_BUILDER",
|
|
19992
|
+
class_name: "DurableAgentBuilder"
|
|
19993
|
+
}
|
|
19994
|
+
]
|
|
19995
|
+
},
|
|
19996
|
+
migrations: [
|
|
19997
|
+
{
|
|
19998
|
+
tag: "v1",
|
|
19999
|
+
new_sqlite_classes: ["DurableThread"]
|
|
20000
|
+
},
|
|
20001
|
+
{
|
|
20002
|
+
tag: "v2",
|
|
20003
|
+
new_sqlite_classes: ["DurableAgentBuilder"]
|
|
20004
|
+
}
|
|
20005
|
+
]
|
|
20006
|
+
};
|
|
20007
|
+
}
|
|
20008
|
+
function applyAgentBuilderWorkerConfig(config, options) {
|
|
20009
|
+
const generated = createAgentBuilderWorkerConfig(options);
|
|
20010
|
+
const existingVars = config.vars && typeof config.vars === "object" ? config.vars : {};
|
|
20011
|
+
Object.assign(config, generated);
|
|
20012
|
+
config.vars = {
|
|
20013
|
+
...existingVars,
|
|
20014
|
+
...generated.vars ?? {}
|
|
20015
|
+
};
|
|
20016
|
+
}
|
|
20017
|
+
function createAgentBuilderCloudflarePlugins(options) {
|
|
20018
|
+
return cloudflare({
|
|
20019
|
+
config(config) {
|
|
20020
|
+
applyAgentBuilderWorkerConfig(config, options);
|
|
20021
|
+
}
|
|
20022
|
+
});
|
|
20023
|
+
}
|
|
19980
20024
|
function applyPluginEnvironmentConfig(config) {
|
|
19981
20025
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
19982
20026
|
config.optimizeDeps.exclude = [
|
|
@@ -20003,13 +20047,6 @@ function applyPluginEnvironmentConfig(config) {
|
|
|
20003
20047
|
|
|
20004
20048
|
// src/plugin.ts
|
|
20005
20049
|
function agentbuilder(options = {}) {
|
|
20006
|
-
let mountPoint = options.mountPoint || "/agents";
|
|
20007
|
-
if (!mountPoint.startsWith("/")) {
|
|
20008
|
-
mountPoint = "/" + mountPoint;
|
|
20009
|
-
}
|
|
20010
|
-
if (mountPoint.endsWith("/") && mountPoint.length > 1) {
|
|
20011
|
-
mountPoint = mountPoint.slice(0, -1);
|
|
20012
|
-
}
|
|
20013
20050
|
const toolsDir = options.toolsDir ? path8__default.resolve(process.cwd(), options.toolsDir) : path8__default.resolve(process.cwd(), "agents/tools");
|
|
20014
20051
|
const hooksDir = options.hooksDir ? path8__default.resolve(process.cwd(), options.hooksDir) : path8__default.resolve(process.cwd(), "agents/hooks");
|
|
20015
20052
|
const threadApiDir = options.apiDir ? path8__default.resolve(process.cwd(), options.apiDir) : path8__default.resolve(process.cwd(), "agents/api");
|
|
@@ -20018,6 +20055,7 @@ function agentbuilder(options = {}) {
|
|
|
20018
20055
|
const agentsDir = options.agentsDir ? path8__default.resolve(process.cwd(), options.agentsDir) : path8__default.resolve(process.cwd(), "agents/agents");
|
|
20019
20056
|
const effectsDir = options.effectsDir ? path8__default.resolve(process.cwd(), options.effectsDir) : path8__default.resolve(process.cwd(), "agents/effects");
|
|
20020
20057
|
const outputDir = path8__default.resolve(process.cwd(), ".agents");
|
|
20058
|
+
const generatedWorkerEntry = path8__default.join(outputDir, "worker.ts");
|
|
20021
20059
|
const installedProviders = buildInstalledProviderCatalog(options.providers || []);
|
|
20022
20060
|
const installedProviderPackageMap = buildProviderPackageMap(options.providers || []);
|
|
20023
20061
|
const typeGenConfig = {
|
|
@@ -20033,6 +20071,25 @@ function agentbuilder(options = {}) {
|
|
|
20033
20071
|
generateTypes(typeGenConfig);
|
|
20034
20072
|
}
|
|
20035
20073
|
}
|
|
20074
|
+
function writeGeneratedWorkerEntry() {
|
|
20075
|
+
const content = `// Generated by @standardagents/builder.
|
|
20076
|
+
// Future agents: update builder/src/plugin.ts when changing this entrypoint.
|
|
20077
|
+
import { CodeExecutionBridge, DurableAgentBuilder, DurableThread, router } from "virtual:@standardagents/builder";
|
|
20078
|
+
|
|
20079
|
+
export default {
|
|
20080
|
+
async fetch(request: Request, env: Parameters<typeof router>[1]) {
|
|
20081
|
+
const response = await router(request, env);
|
|
20082
|
+
return response ?? new Response(null, { status: 404 });
|
|
20083
|
+
},
|
|
20084
|
+
};
|
|
20085
|
+
|
|
20086
|
+
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread };
|
|
20087
|
+
`;
|
|
20088
|
+
fs8__default.mkdirSync(outputDir, { recursive: true });
|
|
20089
|
+
if (!fs8__default.existsSync(generatedWorkerEntry) || fs8__default.readFileSync(generatedWorkerEntry, "utf-8") !== content) {
|
|
20090
|
+
fs8__default.writeFileSync(generatedWorkerEntry, content);
|
|
20091
|
+
}
|
|
20092
|
+
}
|
|
20036
20093
|
const __filename = fileURLToPath(import.meta.url);
|
|
20037
20094
|
const __dirname = path8__default.dirname(__filename);
|
|
20038
20095
|
const rou3Path = path8__default.join(__dirname, "../dist/rou3.js");
|
|
@@ -20053,7 +20110,6 @@ function agentbuilder(options = {}) {
|
|
|
20053
20110
|
effectsDir
|
|
20054
20111
|
};
|
|
20055
20112
|
const virtualModuleContext = {
|
|
20056
|
-
mountPoint,
|
|
20057
20113
|
toolsDir,
|
|
20058
20114
|
hooksDir,
|
|
20059
20115
|
threadApiDir,
|
|
@@ -20066,7 +20122,6 @@ function agentbuilder(options = {}) {
|
|
|
20066
20122
|
hmr
|
|
20067
20123
|
};
|
|
20068
20124
|
const devMiddlewareContext = {
|
|
20069
|
-
mountPoint,
|
|
20070
20125
|
toolsDir,
|
|
20071
20126
|
hooksDir,
|
|
20072
20127
|
modelsDir,
|
|
@@ -20078,11 +20133,14 @@ function agentbuilder(options = {}) {
|
|
|
20078
20133
|
sourceDirs,
|
|
20079
20134
|
regenerateTypes
|
|
20080
20135
|
};
|
|
20081
|
-
|
|
20136
|
+
const workerEntry = path8__default.relative(process.cwd(), generatedWorkerEntry).split(path8__default.sep).join("/");
|
|
20137
|
+
const corePlugin = {
|
|
20082
20138
|
name: "vite-plugin-agent",
|
|
20083
20139
|
enforce: "pre",
|
|
20084
20140
|
config() {
|
|
20085
|
-
|
|
20141
|
+
writeGeneratedWorkerEntry();
|
|
20142
|
+
const viteConfig = createPluginViteConfig(import.meta.url);
|
|
20143
|
+
return viteConfig;
|
|
20086
20144
|
},
|
|
20087
20145
|
// Apply exclusions and inclusions to ALL environments including Cloudflare worker
|
|
20088
20146
|
configEnvironment(_name, config) {
|
|
@@ -20130,6 +20188,7 @@ function agentbuilder(options = {}) {
|
|
|
20130
20188
|
return loadVirtualModule(id, virtualModuleContext);
|
|
20131
20189
|
},
|
|
20132
20190
|
buildStart() {
|
|
20191
|
+
writeGeneratedWorkerEntry();
|
|
20133
20192
|
regenerateTypes();
|
|
20134
20193
|
this.addWatchFile(toolsDir);
|
|
20135
20194
|
this.addWatchFile(threadApiDir);
|
|
@@ -20147,8 +20206,7 @@ function agentbuilder(options = {}) {
|
|
|
20147
20206
|
},
|
|
20148
20207
|
writeBundle(options2, bundle) {
|
|
20149
20208
|
const outDir = options2.dir || "dist";
|
|
20150
|
-
const
|
|
20151
|
-
const mountDir = mountPath ? path8__default.join(outDir, "../client", mountPath) : path8__default.join(outDir, "../client");
|
|
20209
|
+
const mountDir = path8__default.join(outDir, "../client");
|
|
20152
20210
|
const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
|
|
20153
20211
|
const isInDist = currentDir.endsWith("dist");
|
|
20154
20212
|
const clientDir = path8__default.resolve(
|
|
@@ -20171,10 +20229,9 @@ function agentbuilder(options = {}) {
|
|
|
20171
20229
|
} else {
|
|
20172
20230
|
let content = fs8__default.readFileSync(srcPath);
|
|
20173
20231
|
if (entry.name === "index.html") {
|
|
20174
|
-
const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = {
|
|
20232
|
+
const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = {};</script>`;
|
|
20175
20233
|
let htmlContent = content.toString();
|
|
20176
|
-
|
|
20177
|
-
htmlContent = htmlContent.replace(/\/agents\//g, assetPrefix);
|
|
20234
|
+
htmlContent = htmlContent.replace(/\/agents\//g, "/");
|
|
20178
20235
|
htmlContent = htmlContent.replace("</head>", `${configScript}</head>`);
|
|
20179
20236
|
content = Buffer.from(htmlContent);
|
|
20180
20237
|
}
|
|
@@ -20185,7 +20242,15 @@ function agentbuilder(options = {}) {
|
|
|
20185
20242
|
copyRecursive(clientDir, mountDir);
|
|
20186
20243
|
}
|
|
20187
20244
|
};
|
|
20245
|
+
return [
|
|
20246
|
+
corePlugin,
|
|
20247
|
+
...createAgentBuilderCloudflarePlugins({
|
|
20248
|
+
workerEntry,
|
|
20249
|
+
compatibilityDate: options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE
|
|
20250
|
+
})
|
|
20251
|
+
];
|
|
20188
20252
|
}
|
|
20253
|
+
var builder = agentbuilder;
|
|
20189
20254
|
|
|
20190
20255
|
// src/router/index.ts
|
|
20191
20256
|
init_ThreadStateImpl();
|
|
@@ -22846,14 +22911,14 @@ var DurableThread = class extends DurableObject {
|
|
|
22846
22911
|
}
|
|
22847
22912
|
try {
|
|
22848
22913
|
const builderId = this.env.AGENT_BUILDER.idFromName("singleton");
|
|
22849
|
-
const
|
|
22850
|
-
if (typeof
|
|
22914
|
+
const builder2 = this.env.AGENT_BUILDER.get(builderId);
|
|
22915
|
+
if (typeof builder2.getThread !== "function") {
|
|
22851
22916
|
return projections;
|
|
22852
22917
|
}
|
|
22853
22918
|
await Promise.all(
|
|
22854
22919
|
unresolved.map(async (subagentId) => {
|
|
22855
22920
|
try {
|
|
22856
|
-
const thread = await
|
|
22921
|
+
const thread = await builder2.getThread(subagentId);
|
|
22857
22922
|
if (!thread) {
|
|
22858
22923
|
return;
|
|
22859
22924
|
}
|
|
@@ -28560,10 +28625,10 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
28560
28625
|
return this.getUserById(rows[0].user_id);
|
|
28561
28626
|
}
|
|
28562
28627
|
// ============================================================
|
|
28563
|
-
// Edit Lock Methods
|
|
28628
|
+
// Edit Lock Methods
|
|
28564
28629
|
// ============================================================
|
|
28565
28630
|
/**
|
|
28566
|
-
* Acquire edit lock for
|
|
28631
|
+
* Acquire edit lock for coordinated edits.
|
|
28567
28632
|
*/
|
|
28568
28633
|
async acquireEditLock(params) {
|
|
28569
28634
|
await this.ensureMigrated();
|
|
@@ -29090,248 +29155,9 @@ function enhanceFlowState(flow) {
|
|
|
29090
29155
|
|
|
29091
29156
|
// src/index.ts
|
|
29092
29157
|
init_context();
|
|
29093
|
-
|
|
29094
|
-
// src/github/GitHubClient.ts
|
|
29095
|
-
var GITHUB_API_BASE = "https://api.github.com";
|
|
29096
|
-
var GitHubClient = class _GitHubClient {
|
|
29097
|
-
config;
|
|
29098
|
-
constructor(config) {
|
|
29099
|
-
this.config = config;
|
|
29100
|
-
}
|
|
29101
|
-
/**
|
|
29102
|
-
* Create a GitHubClient from environment variables.
|
|
29103
|
-
* Returns null if required env vars are missing.
|
|
29104
|
-
*/
|
|
29105
|
-
static fromEnv(env) {
|
|
29106
|
-
const token = env.GITHUB_TOKEN;
|
|
29107
|
-
const repo = env.GITHUB_REPO;
|
|
29108
|
-
const branch = env.GITHUB_BRANCH || "main";
|
|
29109
|
-
if (!token || !repo) {
|
|
29110
|
-
return null;
|
|
29111
|
-
}
|
|
29112
|
-
const parts = repo.split("/");
|
|
29113
|
-
if (parts.length !== 2) {
|
|
29114
|
-
console.error('GITHUB_REPO must be in format "owner/repo"');
|
|
29115
|
-
return null;
|
|
29116
|
-
}
|
|
29117
|
-
return new _GitHubClient({
|
|
29118
|
-
token,
|
|
29119
|
-
owner: parts[0],
|
|
29120
|
-
repo: parts[1],
|
|
29121
|
-
branch
|
|
29122
|
-
});
|
|
29123
|
-
}
|
|
29124
|
-
/**
|
|
29125
|
-
* Check if GitHub integration is properly configured.
|
|
29126
|
-
*/
|
|
29127
|
-
isConfigured() {
|
|
29128
|
-
return !!(this.config.token && this.config.owner && this.config.repo && this.config.branch);
|
|
29129
|
-
}
|
|
29130
|
-
/**
|
|
29131
|
-
* Make an authenticated request to GitHub API.
|
|
29132
|
-
*/
|
|
29133
|
-
async request(method, path20, body) {
|
|
29134
|
-
const url = `${GITHUB_API_BASE}${path20}`;
|
|
29135
|
-
const response = await fetch(url, {
|
|
29136
|
-
method,
|
|
29137
|
-
headers: {
|
|
29138
|
-
Authorization: `Bearer ${this.config.token}`,
|
|
29139
|
-
Accept: "application/vnd.github+json",
|
|
29140
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
29141
|
-
"Content-Type": "application/json",
|
|
29142
|
-
"User-Agent": "AgentBuilder/1.0"
|
|
29143
|
-
},
|
|
29144
|
-
body: body ? JSON.stringify(body) : void 0
|
|
29145
|
-
});
|
|
29146
|
-
if (!response.ok) {
|
|
29147
|
-
const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
|
|
29148
|
-
throw new GitHubApiError(
|
|
29149
|
-
errorData.message || `GitHub API error: ${response.status}`,
|
|
29150
|
-
response.status,
|
|
29151
|
-
errorData
|
|
29152
|
-
);
|
|
29153
|
-
}
|
|
29154
|
-
return response.json();
|
|
29155
|
-
}
|
|
29156
|
-
/**
|
|
29157
|
-
* Get the current branch reference.
|
|
29158
|
-
*/
|
|
29159
|
-
async getBranchRef() {
|
|
29160
|
-
return this.request(
|
|
29161
|
-
"GET",
|
|
29162
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/ref/heads/${this.config.branch}`
|
|
29163
|
-
);
|
|
29164
|
-
}
|
|
29165
|
-
/**
|
|
29166
|
-
* Get a commit by SHA.
|
|
29167
|
-
*/
|
|
29168
|
-
async getCommit(sha) {
|
|
29169
|
-
return this.request(
|
|
29170
|
-
"GET",
|
|
29171
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/commits/${sha}`
|
|
29172
|
-
);
|
|
29173
|
-
}
|
|
29174
|
-
/**
|
|
29175
|
-
* Get a tree by SHA.
|
|
29176
|
-
*/
|
|
29177
|
-
async getTree(sha) {
|
|
29178
|
-
return this.request(
|
|
29179
|
-
"GET",
|
|
29180
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/trees/${sha}`
|
|
29181
|
-
);
|
|
29182
|
-
}
|
|
29183
|
-
/**
|
|
29184
|
-
* Create a blob (file content).
|
|
29185
|
-
*/
|
|
29186
|
-
async createBlob(content) {
|
|
29187
|
-
return this.request(
|
|
29188
|
-
"POST",
|
|
29189
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/blobs`,
|
|
29190
|
-
{
|
|
29191
|
-
content: btoa(content),
|
|
29192
|
-
// Base64 encode
|
|
29193
|
-
encoding: "base64"
|
|
29194
|
-
}
|
|
29195
|
-
);
|
|
29196
|
-
}
|
|
29197
|
-
/**
|
|
29198
|
-
* Create a tree with file changes.
|
|
29199
|
-
*/
|
|
29200
|
-
async createTree(baseTreeSha, files) {
|
|
29201
|
-
return this.request(
|
|
29202
|
-
"POST",
|
|
29203
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/trees`,
|
|
29204
|
-
{
|
|
29205
|
-
base_tree: baseTreeSha,
|
|
29206
|
-
tree: files.map((f) => ({
|
|
29207
|
-
path: f.path,
|
|
29208
|
-
mode: f.mode,
|
|
29209
|
-
type: "blob",
|
|
29210
|
-
sha: f.sha
|
|
29211
|
-
}))
|
|
29212
|
-
}
|
|
29213
|
-
);
|
|
29214
|
-
}
|
|
29215
|
-
/**
|
|
29216
|
-
* Create a commit.
|
|
29217
|
-
*/
|
|
29218
|
-
async createCommit(message, treeSha, parentSha) {
|
|
29219
|
-
return this.request(
|
|
29220
|
-
"POST",
|
|
29221
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/commits`,
|
|
29222
|
-
{
|
|
29223
|
-
message,
|
|
29224
|
-
tree: treeSha,
|
|
29225
|
-
parents: [parentSha]
|
|
29226
|
-
}
|
|
29227
|
-
);
|
|
29228
|
-
}
|
|
29229
|
-
/**
|
|
29230
|
-
* Update a branch reference to point to a new commit.
|
|
29231
|
-
*/
|
|
29232
|
-
async updateRef(sha) {
|
|
29233
|
-
return this.request(
|
|
29234
|
-
"PATCH",
|
|
29235
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/refs/heads/${this.config.branch}`,
|
|
29236
|
-
{
|
|
29237
|
-
sha,
|
|
29238
|
-
force: false
|
|
29239
|
-
}
|
|
29240
|
-
);
|
|
29241
|
-
}
|
|
29242
|
-
/**
|
|
29243
|
-
* Commit multiple file changes atomically.
|
|
29244
|
-
*
|
|
29245
|
-
* @param message - Commit message
|
|
29246
|
-
* @param files - Array of files to add/modify
|
|
29247
|
-
* @returns The commit result with SHA
|
|
29248
|
-
*/
|
|
29249
|
-
async commitFiles(message, files) {
|
|
29250
|
-
if (files.length === 0) {
|
|
29251
|
-
throw new Error("No files to commit");
|
|
29252
|
-
}
|
|
29253
|
-
const branchRef = await this.getBranchRef();
|
|
29254
|
-
const headSha = branchRef.object.sha;
|
|
29255
|
-
const headCommit = await this.getCommit(headSha);
|
|
29256
|
-
const baseTreeSha = headCommit.tree.sha;
|
|
29257
|
-
const blobPromises = files.map(async (file) => {
|
|
29258
|
-
const blob = await this.createBlob(file.content);
|
|
29259
|
-
return {
|
|
29260
|
-
path: file.path,
|
|
29261
|
-
sha: blob.sha,
|
|
29262
|
-
mode: file.mode || "100644"
|
|
29263
|
-
};
|
|
29264
|
-
});
|
|
29265
|
-
const blobs = await Promise.all(blobPromises);
|
|
29266
|
-
const newTree = await this.createTree(baseTreeSha, blobs);
|
|
29267
|
-
const commit = await this.createCommit(message, newTree.sha, headSha);
|
|
29268
|
-
await this.updateRef(commit.sha);
|
|
29269
|
-
return {
|
|
29270
|
-
sha: commit.sha,
|
|
29271
|
-
url: commit.html_url,
|
|
29272
|
-
message: commit.message
|
|
29273
|
-
};
|
|
29274
|
-
}
|
|
29275
|
-
/**
|
|
29276
|
-
* Delete files from the repository.
|
|
29277
|
-
*
|
|
29278
|
-
* @param message - Commit message
|
|
29279
|
-
* @param paths - Array of file paths to delete
|
|
29280
|
-
* @returns The commit result with SHA
|
|
29281
|
-
*/
|
|
29282
|
-
async deleteFiles(message, paths) {
|
|
29283
|
-
if (paths.length === 0) {
|
|
29284
|
-
throw new Error("No files to delete");
|
|
29285
|
-
}
|
|
29286
|
-
const branchRef = await this.getBranchRef();
|
|
29287
|
-
const headSha = branchRef.object.sha;
|
|
29288
|
-
const headCommit = await this.getCommit(headSha);
|
|
29289
|
-
const baseTreeSha = headCommit.tree.sha;
|
|
29290
|
-
const tree = paths.map((path20) => ({
|
|
29291
|
-
path: path20,
|
|
29292
|
-
mode: "100644",
|
|
29293
|
-
type: "blob",
|
|
29294
|
-
sha: null
|
|
29295
|
-
}));
|
|
29296
|
-
const newTree = await this.request(
|
|
29297
|
-
"POST",
|
|
29298
|
-
`/repos/${this.config.owner}/${this.config.repo}/git/trees`,
|
|
29299
|
-
{
|
|
29300
|
-
base_tree: baseTreeSha,
|
|
29301
|
-
tree
|
|
29302
|
-
}
|
|
29303
|
-
);
|
|
29304
|
-
const commit = await this.createCommit(message, newTree.sha, headSha);
|
|
29305
|
-
await this.updateRef(commit.sha);
|
|
29306
|
-
return {
|
|
29307
|
-
sha: commit.sha,
|
|
29308
|
-
url: commit.html_url,
|
|
29309
|
-
message: commit.message
|
|
29310
|
-
};
|
|
29311
|
-
}
|
|
29312
|
-
/**
|
|
29313
|
-
* Get the current HEAD commit SHA.
|
|
29314
|
-
*/
|
|
29315
|
-
async getHeadSha() {
|
|
29316
|
-
const ref = await this.getBranchRef();
|
|
29317
|
-
return ref.object.sha;
|
|
29318
|
-
}
|
|
29319
|
-
};
|
|
29320
|
-
var GitHubApiError = class extends Error {
|
|
29321
|
-
status;
|
|
29322
|
-
details;
|
|
29323
|
-
constructor(message, status, details) {
|
|
29324
|
-
super(message);
|
|
29325
|
-
this.name = "GitHubApiError";
|
|
29326
|
-
this.status = status;
|
|
29327
|
-
this.details = details;
|
|
29328
|
-
}
|
|
29329
|
-
};
|
|
29330
|
-
|
|
29331
|
-
// src/index.ts
|
|
29332
29158
|
init_ProviderRegistry();
|
|
29333
29159
|
init_types2();
|
|
29334
29160
|
|
|
29335
|
-
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, FlowStateSdk,
|
|
29161
|
+
export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, FlowStateSdk, NamespaceResolutionError, PackageDiscoveryService, ProviderRegistry, agentbuilder, authenticate, buildImageDescription, builder, cat, createNamespaceContext, createThreadEndpointHandler, defineController2 as defineController, discoverPackages, emitThreadEvent, enhanceFlowState, exists, find, forceTurn, generateAgentFile, generateImageDescription, generateModelFile, generatePromptFile, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isQualifiedName, linkFile, mkdir, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, stat, tail, unlink, updateThread, writeFile, writeImage };
|
|
29336
29162
|
//# sourceMappingURL=index.js.map
|
|
29337
29163
|
//# sourceMappingURL=index.js.map
|