@standardagents/builder 0.15.3 → 0.17.0-next.a4b7340

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.
Files changed (38) hide show
  1. package/dist/built-in-routes.js +362 -281
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/ApiKeysView.js +1 -1
  4. package/dist/client/CenteredContentView.js +1 -1
  5. package/dist/client/CompositionView.js +1 -1
  6. package/dist/client/ConfirmDialog.vue_vue_type_script_setup_true_lang.js +1 -1
  7. package/dist/client/CopyButton.vue_vue_type_script_setup_true_lang.js +1 -1
  8. package/dist/client/DataTable.vue_vue_type_script_setup_true_lang.js +1 -1
  9. package/dist/client/JsonViewer.js +1 -1
  10. package/dist/client/LoginView.js +1 -1
  11. package/dist/client/Modal.vue_vue_type_script_setup_true_lang.js +1 -1
  12. package/dist/client/ModelModal.vue_vue_type_script_setup_true_lang.js +1 -1
  13. package/dist/client/ModelsView.js +1 -1
  14. package/dist/client/PromptEditView.js +1 -1
  15. package/dist/client/PromptModal.js +1 -1
  16. package/dist/client/PromptsView.js +1 -1
  17. package/dist/client/ProvidersView.js +2 -2
  18. package/dist/client/ThreadInspectorPane.vue_vue_type_script_setup_true_lang.js +1 -1
  19. package/dist/client/ToolsView.js +1 -1
  20. package/dist/client/UsersView.js +1 -1
  21. package/dist/client/VariablesView.js +1 -1
  22. package/dist/client/assets/index.css +1 -1
  23. package/dist/client/index.js +3 -3
  24. package/dist/{discovery-DVviz3By.d.ts → discovery-DiMJWisl.d.ts} +1 -1
  25. package/dist/{index-BwqQtJ4r.d.ts → index-EaxysUHv.d.ts} +2 -5
  26. package/dist/index.d.ts +116 -3402
  27. package/dist/index.js +190 -324
  28. package/dist/index.js.map +1 -1
  29. package/dist/packing.d.ts +3 -3
  30. package/dist/plugin.d.ts +5 -4
  31. package/dist/plugin.js +143 -78
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/runtime.d.ts +3124 -0
  34. package/dist/runtime.js +21218 -0
  35. package/dist/runtime.js.map +1 -0
  36. package/dist/test.d.ts +2 -2
  37. package/dist/{types-DH3Egc5l.d.ts → types-Bpe7IANZ.d.ts} +1 -1
  38. package/package.json +10 -9
package/dist/packing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { P as PackingAnalysis, a as PackingOptions, b as PackingResult, d as UnpackAnalysis, U as UnpackOptions, c as UnpackResult } from './types-DH3Egc5l.js';
2
- export { D as DiscoveredPackage } from './types-DH3Egc5l.js';
3
- export { P as PackageDiscoveryService, d as discoverPackages } from './discovery-DVviz3By.js';
1
+ import { P as PackingAnalysis, a as PackingOptions, b as PackingResult, U as UnpackAnalysis, c as UnpackOptions, d as UnpackResult } from './types-Bpe7IANZ.js';
2
+ export { D as DiscoveredPackage } from './types-Bpe7IANZ.js';
3
+ export { P as PackageDiscoveryService, d as discoverPackages } from './discovery-DiMJWisl.js';
4
4
  import '@standardagents/spec';
5
5
 
6
6
  /**
package/dist/plugin.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Plugin } from 'vite';
1
+ import { PluginOption } from 'vite';
2
2
 
3
3
  interface AgentPluginOptions {
4
- mountPoint?: string;
4
+ compatibilityDate?: string;
5
5
  toolsDir?: string;
6
6
  hooksDir?: string;
7
7
  apiDir?: string;
@@ -16,6 +16,7 @@ interface AgentPluginOptions {
16
16
  */
17
17
  providers?: string[];
18
18
  }
19
- declare function agentbuilder(options?: AgentPluginOptions): Plugin;
19
+ declare function agentbuilder(options?: AgentPluginOptions): PluginOption[];
20
+ declare const builder: typeof agentbuilder;
20
21
 
21
- export { type AgentPluginOptions, agentbuilder };
22
+ export { type AgentPluginOptions, agentbuilder, builder };
package/dist/plugin.js CHANGED
@@ -6,6 +6,7 @@ import { fileURLToPath } from 'url';
6
6
  import MagicString from 'magic-string';
7
7
  import { exec } from 'child_process';
8
8
  import { promisify } from 'util';
9
+ import { cloudflare } from '@cloudflare/vite-plugin';
9
10
 
10
11
  // src/plugin.ts
11
12
  var TSCONFIG_CONTENT = `{
@@ -373,14 +374,9 @@ declare module 'virtual:@standardagents/builder' {
373
374
 
374
375
  /**
375
376
  * DurableThread with all virtual module methods pre-implemented.
376
- * Extend this class in your agents/Thread.ts file.
377
- *
378
- * @example
379
- * \`\`\`typescript
380
- * import { DurableThread } from 'virtual:@standardagents/builder'
381
- *
382
- * export class Thread extends DurableThread {}
383
- * \`\`\`
377
+ * The generated AgentBuilder Worker entry exports this class automatically;
378
+ * projects should not create agents/Thread.ts unless they are intentionally
379
+ * taking over the Worker surface.
384
380
  */
385
381
  export class DurableThread extends BaseDurableThread {
386
382
  // Virtual module registry methods
@@ -551,14 +547,9 @@ declare module 'virtual:@standardagents/builder' {
551
547
 
552
548
  /**
553
549
  * DurableAgentBuilder with all virtual module methods pre-implemented.
554
- * Extend this class in your agents/AgentBuilder.ts file.
555
- *
556
- * @example
557
- * \`\`\`typescript
558
- * import { DurableAgentBuilder } from 'virtual:@standardagents/builder'
559
- *
560
- * export class AgentBuilder extends DurableAgentBuilder {}
561
- * \`\`\`
550
+ * The generated AgentBuilder Worker entry exports this class automatically;
551
+ * projects should not create agents/AgentBuilder.ts unless they are
552
+ * intentionally taking over the Worker surface.
562
553
  */
563
554
  export class DurableAgentBuilder extends BaseDurableAgentBuilder {
564
555
  // Virtual module registry methods
@@ -716,7 +707,7 @@ declare module 'virtual:@standardagents/builder' {
716
707
  providerUserId: string
717
708
  ): Promise<User | null>;
718
709
 
719
- // Edit lock methods (for GitHub integration)
710
+ // Edit lock methods
720
711
  acquireEditLock(params: {
721
712
  locked_by: string;
722
713
  lock_reason: string;
@@ -6542,14 +6533,12 @@ function readRawRequestBody(req) {
6542
6533
  req.on("error", reject);
6543
6534
  });
6544
6535
  }
6545
- function injectUiConfigIntoHtml(htmlContent, mountPoint) {
6546
- const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}", devMode: true };</script>`;
6547
- const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
6548
- return htmlContent.replace(/\/agents\//g, assetPrefix).replace("</head>", `${configScript}</head>`);
6536
+ function injectUiConfigIntoHtml(htmlContent) {
6537
+ const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { devMode: true };</script>`;
6538
+ return htmlContent.replace(/\/agents\//g, "/").replace("</head>", `${configScript}</head>`);
6549
6539
  }
6550
6540
  function createDevMiddleware(server, context) {
6551
6541
  const {
6552
- mountPoint,
6553
6542
  toolsDir,
6554
6543
  hooksDir,
6555
6544
  modelsDir,
@@ -6569,17 +6558,14 @@ function createDevMiddleware(server, context) {
6569
6558
  });
6570
6559
  server.middlewares.use(async (req, res, next) => {
6571
6560
  const url = req.url;
6572
- if (!url || !url.startsWith(mountPoint)) {
6561
+ if (!url || !url.startsWith("/")) {
6573
6562
  next();
6574
6563
  return;
6575
6564
  }
6576
- let pathWithoutMount = url.slice(mountPoint.length) || "/";
6577
- if (!pathWithoutMount.startsWith("/")) {
6578
- pathWithoutMount = "/" + pathWithoutMount;
6579
- }
6565
+ let pathWithoutMount = url;
6580
6566
  const method = req.method?.toUpperCase();
6581
6567
  const legacyMountPoint = "/agentbuilder";
6582
- if (mountPoint === "/" && (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`))) {
6568
+ if (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`)) {
6583
6569
  const normalizedPath = pathWithoutMount.slice(legacyMountPoint.length) || "/";
6584
6570
  if (normalizedPath.startsWith("/api/")) {
6585
6571
  req.url = normalizedPath;
@@ -6664,7 +6650,7 @@ function createDevMiddleware(server, context) {
6664
6650
  const contentType = proxyRes.headers.get("content-type") || "";
6665
6651
  if (contentType.includes("text/html")) {
6666
6652
  const htmlBody = await proxyRes.text();
6667
- const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody, mountPoint));
6653
+ const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody));
6668
6654
  res.setHeader("content-length", String(injectedHtml.byteLength));
6669
6655
  res.end(injectedHtml);
6670
6656
  return;
@@ -6676,7 +6662,7 @@ function createDevMiddleware(server, context) {
6676
6662
  console.error("[agentbuilder] Failed to proxy to UI dev server:", error);
6677
6663
  }
6678
6664
  }
6679
- const clientPath = mountPoint === "/" && pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
6665
+ const clientPath = pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
6680
6666
  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)$/);
6681
6667
  {
6682
6668
  const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
@@ -6698,7 +6684,7 @@ function createDevMiddleware(server, context) {
6698
6684
  const ext = path8__default.extname(filePath).toLowerCase();
6699
6685
  if (ext === ".html") {
6700
6686
  content = Buffer.from(
6701
- injectUiConfigIntoHtml(content.toString(), mountPoint)
6687
+ injectUiConfigIntoHtml(content.toString())
6702
6688
  );
6703
6689
  }
6704
6690
  const mimeTypes = {
@@ -6874,7 +6860,8 @@ ${effectsCode}
6874
6860
 
6875
6861
  /**
6876
6862
  * DurableThread with all virtual module methods already implemented.
6877
- * Simply extend this class in your agents/Thread.ts file.
6863
+ * Exported by the generated AgentBuilder Worker entry; user projects do not
6864
+ * need an agents/Thread.ts file for the standard hosted/runtime path.
6878
6865
  */
6879
6866
  export class DurableThread extends _BaseDurableThread {
6880
6867
  constructor(ctx, env) {
@@ -6918,7 +6905,8 @@ export class DurableThread extends _BaseDurableThread {
6918
6905
 
6919
6906
  /**
6920
6907
  * DurableAgentBuilder with all virtual module methods already implemented.
6921
- * Simply extend this class in your agents/AgentBuilder.ts file.
6908
+ * Exported by the generated AgentBuilder Worker entry; user projects do not
6909
+ * need an agents/AgentBuilder.ts file for the standard hosted/runtime path.
6922
6910
  */
6923
6911
  export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
6924
6912
  tools() {
@@ -7124,7 +7112,7 @@ export function getVisibleToolNames() {
7124
7112
  `;
7125
7113
  }
7126
7114
  async function loadRoutesVirtualModule(context) {
7127
- const { mountPoint, threadApiDir, rou3Code, hmr } = context;
7115
+ const { threadApiDir, rou3Code, hmr } = context;
7128
7116
  const threadRoutes = scanApiDirectory(threadApiDir);
7129
7117
  const toAbsolutePath = (inputPath) => path8__default.resolve(process.cwd(), inputPath).replace(/\\/g, "/");
7130
7118
  const threadRouteCode = threadRoutes.map(({ method, route, importPath }) => {
@@ -7186,8 +7174,6 @@ import { registry } from "virtual:@standardagents-registry";
7186
7174
  import { requireAuth, createThreadEndpointHandler } from "@standardagents/builder/runtime";
7187
7175
  import { isThreadEndpoint } from "@standardagents/spec";
7188
7176
 
7189
- const MOUNT_POINT = "${mountPoint}";
7190
-
7191
7177
  // Routes that don't require authentication
7192
7178
  const PUBLIC_ROUTES = [
7193
7179
  '/api/auth/bootstrap',
@@ -7286,11 +7272,6 @@ export async function router(request, env) {
7286
7272
  const url = new URL(request.url);
7287
7273
  const pathname = url.pathname;
7288
7274
 
7289
- // Check if request is under mount point
7290
- if (!pathname.startsWith(MOUNT_POINT)) {
7291
- return null;
7292
- }
7293
-
7294
7275
  // Handle CORS preflight requests
7295
7276
  if (request.method === "OPTIONS") {
7296
7277
  return new Response(null, {
@@ -7299,11 +7280,7 @@ export async function router(request, env) {
7299
7280
  });
7300
7281
  }
7301
7282
 
7302
- // Strip mount point prefix for route matching, ensuring we keep the leading slash
7303
- let routePath = pathname.slice(MOUNT_POINT.length) || "/";
7304
- if (!routePath.startsWith('/')) {
7305
- routePath = '/' + routePath;
7306
- }
7283
+ const routePath = pathname || "/";
7307
7284
 
7308
7285
  // Handle API routes
7309
7286
  const router = createRouter();
@@ -7381,32 +7358,29 @@ ${packedThreadRouteCode}
7381
7358
 
7382
7359
  async function serveUI(pathname, env) {
7383
7360
  try {
7384
- const clientPath =
7385
- MOUNT_POINT === "/" && pathname.startsWith("/agents/")
7386
- ? pathname.slice("/agents".length) || "/"
7387
- : pathname;
7361
+ const clientPath = pathname.startsWith("/agents/")
7362
+ ? pathname.slice("/agents".length) || "/"
7363
+ : pathname;
7388
7364
 
7389
- // Use Cloudflare Workers Assets binding (automatically created from wrangler assets config)
7365
+ // Use the Cloudflare Workers Assets binding created by builder()'s generated
7366
+ // Cloudflare Vite plugin config.
7390
7367
  if (env.ASSETS) {
7391
7368
  try {
7392
7369
  // Create a proper request for the asset path
7393
7370
  // Use a dummy origin since we only care about the path
7394
- // Re-add mount point since pathname was stripped by router
7395
- // Handle root mountPoint "/" specially to avoid double slashes
7396
- const mountPrefix = MOUNT_POINT === "/" ? "" : MOUNT_POINT;
7397
- const assetUrl = \`http://localhost\${mountPrefix}\${clientPath}\`;
7371
+ const assetUrl = \`http://localhost\${clientPath}\`;
7398
7372
  let response = await env.ASSETS.fetch(assetUrl);
7399
7373
 
7400
7374
  // If not found, fall back to index.html for SPA routing
7401
7375
  const isIndexHtml = response.status === 404 || clientPath === "/" || !clientPath.includes(".");
7402
7376
  if (isIndexHtml) {
7403
- response = await env.ASSETS.fetch(\`http://localhost\${mountPrefix}/index.html\`);
7377
+ response = await env.ASSETS.fetch(\`http://localhost/index.html\`);
7404
7378
 
7405
- // Transform HTML to use configured mount point
7379
+ // Transform standalone UI asset URLs to root. AgentBuilder owns the
7380
+ // entire Worker surface and has no configurable mount point.
7406
7381
  if (response.status === 200) {
7407
7382
  const html = await response.text();
7408
- // Replace default /agents/ paths with configured mount point
7409
- const modifiedHtml = html.replace(/\\/agents\\//g, \`\${MOUNT_POINT}/\`);
7383
+ const modifiedHtml = html.replace(/\\/agents\\//g, "/");
7410
7384
  return new Response(modifiedHtml, {
7411
7385
  headers: {
7412
7386
  "Content-Type": "text/html; charset=utf-8",
@@ -7443,7 +7417,6 @@ async function serveUI(pathname, env) {
7443
7417
  // src/plugin/virtual-modules.ts
7444
7418
  async function loadVirtualModule(id, context) {
7445
7419
  const {
7446
- mountPoint,
7447
7420
  toolsDir,
7448
7421
  hooksDir,
7449
7422
  threadApiDir,
@@ -7515,7 +7488,6 @@ export const config = {
7515
7488
  modelsDir: "${relativeModelsDir}",
7516
7489
  promptsDir: "${relativePromptsDir}",
7517
7490
  agentsDir: "${relativeAgentsDir}",
7518
- mountPoint: "${mountPoint}",
7519
7491
  };`;
7520
7492
  }
7521
7493
  if (id === RESOLVED_VIRTUAL_MODELS_ID) {
@@ -7640,6 +7612,7 @@ ${allProviders.map((p) => ` "${p.name}": async () => (await import("${p.package
7640
7612
  return loadBuilderVirtualModule(context);
7641
7613
  }
7642
7614
  }
7615
+ var DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE = "2025-08-13";
7643
7616
  var depsToExclude = [
7644
7617
  "@standardagents/builder",
7645
7618
  "@standardagents/builder/runtime",
@@ -7707,6 +7680,77 @@ function createPluginViteConfig(pluginModuleUrl) {
7707
7680
  }
7708
7681
  };
7709
7682
  }
7683
+ function createAgentBuilderWorkerConfig(options) {
7684
+ const compatibilityDate = options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE;
7685
+ return {
7686
+ // This object is the generated Cloudflare Worker config for customer apps.
7687
+ // Future agents: update this instead of reintroducing wrangler.jsonc in the
7688
+ // generated project template. Customer repos should only need builder()
7689
+ // in vite.config.ts plus their agents/ source tree.
7690
+ main: options.workerEntry,
7691
+ compatibility_date: compatibilityDate,
7692
+ compatibility_flags: ["nodejs_compat", "enable_ctx_exports"],
7693
+ observability: {
7694
+ enabled: true
7695
+ },
7696
+ worker_loaders: [
7697
+ {
7698
+ binding: "AGENT_BUILDER_CODE_LOADER"
7699
+ }
7700
+ ],
7701
+ vars: {
7702
+ // Future agents: keep this aligned with compatibility_date unless code
7703
+ // execution needs a deliberately different Dynamic Worker date.
7704
+ AGENT_BUILDER_CODE_COMPATIBILITY_DATE: compatibilityDate
7705
+ },
7706
+ assets: {
7707
+ // The builder's client UI is emitted as Vite assets and then wrapped by
7708
+ // the hosted platform when deploying through Workers for Platforms.
7709
+ directory: "dist/client",
7710
+ not_found_handling: "single-page-application",
7711
+ binding: "ASSETS",
7712
+ run_worker_first: ["/**"]
7713
+ },
7714
+ durable_objects: {
7715
+ bindings: [
7716
+ {
7717
+ name: "AGENT_BUILDER_THREAD",
7718
+ class_name: "DurableThread"
7719
+ },
7720
+ {
7721
+ name: "AGENT_BUILDER",
7722
+ class_name: "DurableAgentBuilder"
7723
+ }
7724
+ ]
7725
+ },
7726
+ migrations: [
7727
+ {
7728
+ tag: "v1",
7729
+ new_sqlite_classes: ["DurableThread"]
7730
+ },
7731
+ {
7732
+ tag: "v2",
7733
+ new_sqlite_classes: ["DurableAgentBuilder"]
7734
+ }
7735
+ ]
7736
+ };
7737
+ }
7738
+ function applyAgentBuilderWorkerConfig(config, options) {
7739
+ const generated = createAgentBuilderWorkerConfig(options);
7740
+ const existingVars = config.vars && typeof config.vars === "object" ? config.vars : {};
7741
+ Object.assign(config, generated);
7742
+ config.vars = {
7743
+ ...existingVars,
7744
+ ...generated.vars ?? {}
7745
+ };
7746
+ }
7747
+ function createAgentBuilderCloudflarePlugins(options) {
7748
+ return cloudflare({
7749
+ config(config) {
7750
+ applyAgentBuilderWorkerConfig(config, options);
7751
+ }
7752
+ });
7753
+ }
7710
7754
  function applyPluginEnvironmentConfig(config) {
7711
7755
  config.optimizeDeps = config.optimizeDeps || {};
7712
7756
  config.optimizeDeps.exclude = [
@@ -7733,13 +7777,6 @@ function applyPluginEnvironmentConfig(config) {
7733
7777
 
7734
7778
  // src/plugin.ts
7735
7779
  function agentbuilder(options = {}) {
7736
- let mountPoint = options.mountPoint || "/agents";
7737
- if (!mountPoint.startsWith("/")) {
7738
- mountPoint = "/" + mountPoint;
7739
- }
7740
- if (mountPoint.endsWith("/") && mountPoint.length > 1) {
7741
- mountPoint = mountPoint.slice(0, -1);
7742
- }
7743
7780
  const toolsDir = options.toolsDir ? path8__default.resolve(process.cwd(), options.toolsDir) : path8__default.resolve(process.cwd(), "agents/tools");
7744
7781
  const hooksDir = options.hooksDir ? path8__default.resolve(process.cwd(), options.hooksDir) : path8__default.resolve(process.cwd(), "agents/hooks");
7745
7782
  const threadApiDir = options.apiDir ? path8__default.resolve(process.cwd(), options.apiDir) : path8__default.resolve(process.cwd(), "agents/api");
@@ -7748,6 +7785,7 @@ function agentbuilder(options = {}) {
7748
7785
  const agentsDir = options.agentsDir ? path8__default.resolve(process.cwd(), options.agentsDir) : path8__default.resolve(process.cwd(), "agents/agents");
7749
7786
  const effectsDir = options.effectsDir ? path8__default.resolve(process.cwd(), options.effectsDir) : path8__default.resolve(process.cwd(), "agents/effects");
7750
7787
  const outputDir = path8__default.resolve(process.cwd(), ".agents");
7788
+ const generatedWorkerEntry = path8__default.join(outputDir, "worker.ts");
7751
7789
  const installedProviders = buildInstalledProviderCatalog(options.providers || []);
7752
7790
  const installedProviderPackageMap = buildProviderPackageMap(options.providers || []);
7753
7791
  const typeGenConfig = {
@@ -7763,6 +7801,25 @@ function agentbuilder(options = {}) {
7763
7801
  generateTypes(typeGenConfig);
7764
7802
  }
7765
7803
  }
7804
+ function writeGeneratedWorkerEntry() {
7805
+ const content = `// Generated by @standardagents/builder.
7806
+ // Future agents: update builder/src/plugin.ts when changing this entrypoint.
7807
+ import { CodeExecutionBridge, DurableAgentBuilder, DurableThread, router } from "virtual:@standardagents/builder";
7808
+
7809
+ export default {
7810
+ async fetch(request: Request, env: Parameters<typeof router>[1]) {
7811
+ const response = await router(request, env);
7812
+ return response ?? new Response(null, { status: 404 });
7813
+ },
7814
+ };
7815
+
7816
+ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread };
7817
+ `;
7818
+ fs8__default.mkdirSync(outputDir, { recursive: true });
7819
+ if (!fs8__default.existsSync(generatedWorkerEntry) || fs8__default.readFileSync(generatedWorkerEntry, "utf-8") !== content) {
7820
+ fs8__default.writeFileSync(generatedWorkerEntry, content);
7821
+ }
7822
+ }
7766
7823
  const __filename = fileURLToPath(import.meta.url);
7767
7824
  const __dirname = path8__default.dirname(__filename);
7768
7825
  const rou3Path = path8__default.join(__dirname, "../dist/rou3.js");
@@ -7783,7 +7840,6 @@ function agentbuilder(options = {}) {
7783
7840
  effectsDir
7784
7841
  };
7785
7842
  const virtualModuleContext = {
7786
- mountPoint,
7787
7843
  toolsDir,
7788
7844
  hooksDir,
7789
7845
  threadApiDir,
@@ -7796,7 +7852,6 @@ function agentbuilder(options = {}) {
7796
7852
  hmr
7797
7853
  };
7798
7854
  const devMiddlewareContext = {
7799
- mountPoint,
7800
7855
  toolsDir,
7801
7856
  hooksDir,
7802
7857
  modelsDir,
@@ -7808,11 +7863,14 @@ function agentbuilder(options = {}) {
7808
7863
  sourceDirs,
7809
7864
  regenerateTypes
7810
7865
  };
7811
- return {
7866
+ const workerEntry = path8__default.relative(process.cwd(), generatedWorkerEntry).split(path8__default.sep).join("/");
7867
+ const corePlugin = {
7812
7868
  name: "vite-plugin-agent",
7813
7869
  enforce: "pre",
7814
7870
  config() {
7815
- return createPluginViteConfig(import.meta.url);
7871
+ writeGeneratedWorkerEntry();
7872
+ const viteConfig = createPluginViteConfig(import.meta.url);
7873
+ return viteConfig;
7816
7874
  },
7817
7875
  // Apply exclusions and inclusions to ALL environments including Cloudflare worker
7818
7876
  configEnvironment(_name, config) {
@@ -7860,6 +7918,7 @@ function agentbuilder(options = {}) {
7860
7918
  return loadVirtualModule(id, virtualModuleContext);
7861
7919
  },
7862
7920
  buildStart() {
7921
+ writeGeneratedWorkerEntry();
7863
7922
  regenerateTypes();
7864
7923
  this.addWatchFile(toolsDir);
7865
7924
  this.addWatchFile(threadApiDir);
@@ -7877,8 +7936,7 @@ function agentbuilder(options = {}) {
7877
7936
  },
7878
7937
  writeBundle(options2, bundle) {
7879
7938
  const outDir = options2.dir || "dist";
7880
- const mountPath = mountPoint.slice(1);
7881
- const mountDir = mountPath ? path8__default.join(outDir, "../client", mountPath) : path8__default.join(outDir, "../client");
7939
+ const mountDir = path8__default.join(outDir, "../client");
7882
7940
  const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
7883
7941
  const isInDist = currentDir.endsWith("dist");
7884
7942
  const clientDir = path8__default.resolve(
@@ -7901,10 +7959,9 @@ function agentbuilder(options = {}) {
7901
7959
  } else {
7902
7960
  let content = fs8__default.readFileSync(srcPath);
7903
7961
  if (entry.name === "index.html") {
7904
- const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}" };</script>`;
7962
+ const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = {};</script>`;
7905
7963
  let htmlContent = content.toString();
7906
- const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
7907
- htmlContent = htmlContent.replace(/\/agents\//g, assetPrefix);
7964
+ htmlContent = htmlContent.replace(/\/agents\//g, "/");
7908
7965
  htmlContent = htmlContent.replace("</head>", `${configScript}</head>`);
7909
7966
  content = Buffer.from(htmlContent);
7910
7967
  }
@@ -7915,8 +7972,16 @@ function agentbuilder(options = {}) {
7915
7972
  copyRecursive(clientDir, mountDir);
7916
7973
  }
7917
7974
  };
7975
+ return [
7976
+ corePlugin,
7977
+ ...createAgentBuilderCloudflarePlugins({
7978
+ workerEntry,
7979
+ compatibilityDate: options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE
7980
+ })
7981
+ ];
7918
7982
  }
7983
+ var builder = agentbuilder;
7919
7984
 
7920
- export { agentbuilder };
7985
+ export { agentbuilder, builder };
7921
7986
  //# sourceMappingURL=plugin.js.map
7922
7987
  //# sourceMappingURL=plugin.js.map