@standardagents/builder 0.15.3 → 0.16.1-next.1e58032

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 +479 -412
  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-BnrKzXpJ.d.ts} +4 -5
  26. package/dist/index.d.ts +116 -3402
  27. package/dist/index.js +212 -345
  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 +3127 -0
  34. package/dist/runtime.js +21219 -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/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;
@@ -865,11 +866,38 @@ var init_TestProvider = __esm({
865
866
  }
866
867
  });
867
868
 
869
+ // src/agents/providers/platform-routing.ts
870
+ function stringEnv(value) {
871
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
872
+ }
873
+ function resolvePlatformRouting(providerName, env) {
874
+ const apiKey = stringEnv(env.STANDARD_AGENTS_API_KEY) ?? stringEnv(env.PLATFORM_API_KEY);
875
+ if (!apiKey) return null;
876
+ const origin = (stringEnv(env.STANDARD_AGENTS_PROXY_URL) ?? stringEnv(env.PLATFORM_ENDPOINT) ?? stringEnv(env.STANDARD_AGENTS_API_URL) ?? DEFAULT_PLATFORM_PROXY_ORIGIN).replace(/\/+$/, "");
877
+ const provider = providerName.toLowerCase();
878
+ const basePath = PROVIDER_BASE_PATHS[provider] ?? "";
879
+ return {
880
+ apiKey,
881
+ origin,
882
+ baseUrl: `${origin}/v1/proxy/${encodeURIComponent(provider)}${basePath}`
883
+ };
884
+ }
885
+ var DEFAULT_PLATFORM_PROXY_ORIGIN, PROVIDER_BASE_PATHS;
886
+ var init_platform_routing = __esm({
887
+ "src/agents/providers/platform-routing.ts"() {
888
+ DEFAULT_PLATFORM_PROXY_ORIGIN = "https://proxy.standardagents.ai";
889
+ PROVIDER_BASE_PATHS = {
890
+ cloudflare: "/ai/v1"
891
+ };
892
+ }
893
+ });
894
+
868
895
  // src/agents/providers/ProviderRegistry.ts
869
896
  var ProviderRegistryImpl, ProviderRegistry;
870
897
  var init_ProviderRegistry = __esm({
871
898
  "src/agents/providers/ProviderRegistry.ts"() {
872
899
  init_TestProvider();
900
+ init_platform_routing();
873
901
  ProviderRegistryImpl = class {
874
902
  providerCache = /* @__PURE__ */ new Map();
875
903
  providerOverrideFn = null;
@@ -907,9 +935,9 @@ var init_ProviderRegistry = __esm({
907
935
  const fingerprint = this.getProviderFingerprint(providerName, modelDef);
908
936
  const cached = this.providerCache.get(modelName);
909
937
  if (cached?.fingerprint === fingerprint) {
910
- return this.buildResult(cached.provider, modelDef);
938
+ return this.buildResult(cached.provider, modelDef, false);
911
939
  }
912
- return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint);
940
+ return this.cacheAndReturn(modelName, createTestProvider(), modelDef, fingerprint, false);
913
941
  }
914
942
  const apiKey = this.getApiKeyForProvider(providerName, env);
915
943
  if (apiKey) {
@@ -926,34 +954,47 @@ var init_ProviderRegistry = __esm({
926
954
  const fingerprint = this.getProviderFingerprint(providerName, modelDef, config);
927
955
  const cached = this.providerCache.get(modelName);
928
956
  if (cached?.fingerprint === fingerprint) {
929
- return this.buildResult(cached.provider, modelDef);
957
+ return this.buildResult(cached.provider, modelDef, false);
930
958
  }
931
- return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
959
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, false);
932
960
  }
933
961
  if (this.providerOverrideFn) {
934
962
  const overrideFingerprint = this.getProviderFingerprint(`override:${this.providerOverrideRevision}`, modelDef);
935
963
  const overrideCached = this.providerCache.get(modelName);
936
964
  if (overrideCached?.fingerprint === overrideFingerprint) {
937
- return this.buildResult(overrideCached.provider, modelDef);
965
+ return this.buildResult(overrideCached.provider, modelDef, true);
938
966
  }
939
967
  const overrideProvider = this.providerOverrideFn(modelName, modelDef, env);
940
968
  if (overrideProvider) {
941
- return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
969
+ return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint, true);
970
+ }
971
+ }
972
+ const routing = resolvePlatformRouting(providerName, env);
973
+ if (routing) {
974
+ const config = {
975
+ apiKey: routing.apiKey,
976
+ baseUrl: routing.baseUrl
977
+ };
978
+ const fingerprint = this.getProviderFingerprint(`platform:${providerName}`, modelDef, config);
979
+ const cached = this.providerCache.get(modelName);
980
+ if (cached?.fingerprint === fingerprint) {
981
+ return this.buildResult(cached.provider, modelDef, true);
942
982
  }
983
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint, true);
943
984
  }
944
985
  throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
945
986
  }
946
- buildResult(provider, modelDef) {
947
- return { provider, modelName: modelDef.model, modelDef };
987
+ buildResult(provider, modelDef, viaPlatform) {
988
+ return { provider, modelName: modelDef.model, modelDef, viaPlatform };
948
989
  }
949
- cacheAndReturn(modelName, provider, modelDef, fingerprint) {
950
- this.providerCache.set(modelName, { provider, fingerprint });
951
- return this.buildResult(provider, modelDef);
990
+ cacheAndReturn(modelName, provider, modelDef, fingerprint, viaPlatform) {
991
+ this.providerCache.set(modelName, { provider, fingerprint, viaPlatform });
992
+ return this.buildResult(provider, modelDef, viaPlatform);
952
993
  }
953
994
  getProviderFingerprint(providerName, modelDef, config) {
954
995
  return JSON.stringify({
955
996
  providerName,
956
- baseUrl: modelDef.providerOptions?.baseUrl ?? null,
997
+ baseUrl: config?.baseUrl ?? modelDef.providerOptions?.baseUrl ?? null,
957
998
  apiKey: config?.apiKey ?? null,
958
999
  accountId: config?.accountId ?? null
959
1000
  });
@@ -1629,7 +1670,7 @@ var init_LLMRequest = __esm({
1629
1670
  */
1630
1671
  static async callModel(modelId, context, state, logId) {
1631
1672
  const { ProviderRegistry: ProviderRegistry2 } = await Promise.resolve().then(() => (init_providers(), providers_exports));
1632
- const { provider, modelName, modelDef } = await ProviderRegistry2.getProvider(
1673
+ const { provider, modelName, modelDef, viaPlatform } = await ProviderRegistry2.getProvider(
1633
1674
  modelId,
1634
1675
  state.env,
1635
1676
  state.thread.instance
@@ -1763,6 +1804,7 @@ var init_LLMRequest = __esm({
1763
1804
  }
1764
1805
  };
1765
1806
  response._provider = provider;
1807
+ response._viaPlatform = viaPlatform;
1766
1808
  response._providerResponseId = providerResponseId;
1767
1809
  response._aggregate_response = {
1768
1810
  id: responseId,
@@ -1840,7 +1882,7 @@ var init_LLMRequest = __esm({
1840
1882
  try {
1841
1883
  const toolsCalled = response.tool_calls ? JSON.stringify(response.tool_calls.map((tc) => tc.function.name)) : null;
1842
1884
  const providerName = response._provider?.name;
1843
- const standardAgentsRouterUsed = providerName === "platform";
1885
+ const standardAgentsRouterUsed = response._viaPlatform === true || providerName === "platform";
1844
1886
  const resolvedPricing = resolveModelPricing(modelDef, providerName);
1845
1887
  const calculatedCost = calculateUsageCost(response.usage, resolvedPricing);
1846
1888
  const providerReportedCost = typeof response.usage.cost === "number" ? response.usage.cost : typeof response.usage.cost === "string" ? parseFloat(response.usage.cost) : null;
@@ -5945,7 +5987,7 @@ var init_FlowEngine = __esm({
5945
5987
  max_session_turns: newAgentDef.maxSessionTurns ?? null,
5946
5988
  side_a_label: newAgentDef.sideA?.label ?? null,
5947
5989
  side_a_agent_prompt: newAgentDef.sideA?.prompt ?? null,
5948
- side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? false,
5990
+ side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? true,
5949
5991
  side_a_stop_tool: newAgentDef.sideA?.stopTool ?? null,
5950
5992
  side_a_stop_tool_response_property: newAgentDef.sideA?.stopToolResponseProperty ?? null,
5951
5993
  side_a_max_steps: newAgentDef.sideA?.maxSteps ?? null,
@@ -5960,7 +6002,7 @@ var init_FlowEngine = __esm({
5960
6002
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
5961
6003
  side_b_label: newAgentDef.sideB?.label ?? null,
5962
6004
  side_b_agent_prompt: newAgentDef.sideB?.prompt ?? null,
5963
- side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? false,
6005
+ side_b_stop_on_response: newAgentDef.sideB?.stopOnResponse ?? true,
5964
6006
  side_b_stop_tool: newAgentDef.sideB?.stopTool ?? null,
5965
6007
  side_b_stop_tool_response_property: newAgentDef.sideB?.stopToolResponseProperty ?? null,
5966
6008
  side_b_max_steps: newAgentDef.sideB?.maxSteps ?? null,
@@ -9506,7 +9548,7 @@ function runCodeInDynamicWorker(params) {
9506
9548
  durationMs: Date.now() - startedAt,
9507
9549
  error: {
9508
9550
  name: "MissingWorkerLoader",
9509
- message: `ThreadState.runCode requires the ${WORKER_LOADER_BINDING} Worker Loader binding. Run the AgentBuilder scaffold/init step or add worker_loaders to wrangler config.`
9551
+ 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
9552
  }
9511
9553
  };
9512
9554
  }
@@ -12639,14 +12681,9 @@ declare module 'virtual:@standardagents/builder' {
12639
12681
 
12640
12682
  /**
12641
12683
  * DurableThread with all virtual module methods pre-implemented.
12642
- * Extend this class in your agents/Thread.ts file.
12643
- *
12644
- * @example
12645
- * \`\`\`typescript
12646
- * import { DurableThread } from 'virtual:@standardagents/builder'
12647
- *
12648
- * export class Thread extends DurableThread {}
12649
- * \`\`\`
12684
+ * The generated AgentBuilder Worker entry exports this class automatically;
12685
+ * projects should not create agents/Thread.ts unless they are intentionally
12686
+ * taking over the Worker surface.
12650
12687
  */
12651
12688
  export class DurableThread extends BaseDurableThread {
12652
12689
  // Virtual module registry methods
@@ -12817,14 +12854,9 @@ declare module 'virtual:@standardagents/builder' {
12817
12854
 
12818
12855
  /**
12819
12856
  * DurableAgentBuilder with all virtual module methods pre-implemented.
12820
- * Extend this class in your agents/AgentBuilder.ts file.
12821
- *
12822
- * @example
12823
- * \`\`\`typescript
12824
- * import { DurableAgentBuilder } from 'virtual:@standardagents/builder'
12825
- *
12826
- * export class AgentBuilder extends DurableAgentBuilder {}
12827
- * \`\`\`
12857
+ * The generated AgentBuilder Worker entry exports this class automatically;
12858
+ * projects should not create agents/AgentBuilder.ts unless they are
12859
+ * intentionally taking over the Worker surface.
12828
12860
  */
12829
12861
  export class DurableAgentBuilder extends BaseDurableAgentBuilder {
12830
12862
  // Virtual module registry methods
@@ -12982,7 +13014,7 @@ declare module 'virtual:@standardagents/builder' {
12982
13014
  providerUserId: string
12983
13015
  ): Promise<User | null>;
12984
13016
 
12985
- // Edit lock methods (for GitHub integration)
13017
+ // Edit lock methods
12986
13018
  acquireEditLock(params: {
12987
13019
  locked_by: string;
12988
13020
  lock_reason: string;
@@ -18812,14 +18844,12 @@ function readRawRequestBody(req) {
18812
18844
  req.on("error", reject);
18813
18845
  });
18814
18846
  }
18815
- function injectUiConfigIntoHtml(htmlContent, mountPoint) {
18816
- const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}", devMode: true };</script>`;
18817
- const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
18818
- return htmlContent.replace(/\/agents\//g, assetPrefix).replace("</head>", `${configScript}</head>`);
18847
+ function injectUiConfigIntoHtml(htmlContent) {
18848
+ const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { devMode: true };</script>`;
18849
+ return htmlContent.replace(/\/agents\//g, "/").replace("</head>", `${configScript}</head>`);
18819
18850
  }
18820
18851
  function createDevMiddleware(server, context) {
18821
18852
  const {
18822
- mountPoint,
18823
18853
  toolsDir,
18824
18854
  hooksDir,
18825
18855
  modelsDir,
@@ -18839,17 +18869,14 @@ function createDevMiddleware(server, context) {
18839
18869
  });
18840
18870
  server.middlewares.use(async (req, res, next) => {
18841
18871
  const url = req.url;
18842
- if (!url || !url.startsWith(mountPoint)) {
18872
+ if (!url || !url.startsWith("/")) {
18843
18873
  next();
18844
18874
  return;
18845
18875
  }
18846
- let pathWithoutMount = url.slice(mountPoint.length) || "/";
18847
- if (!pathWithoutMount.startsWith("/")) {
18848
- pathWithoutMount = "/" + pathWithoutMount;
18849
- }
18876
+ let pathWithoutMount = url;
18850
18877
  const method = req.method?.toUpperCase();
18851
18878
  const legacyMountPoint = "/agentbuilder";
18852
- if (mountPoint === "/" && (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`))) {
18879
+ if (pathWithoutMount === legacyMountPoint || pathWithoutMount.startsWith(`${legacyMountPoint}/`)) {
18853
18880
  const normalizedPath = pathWithoutMount.slice(legacyMountPoint.length) || "/";
18854
18881
  if (normalizedPath.startsWith("/api/")) {
18855
18882
  req.url = normalizedPath;
@@ -18934,7 +18961,7 @@ function createDevMiddleware(server, context) {
18934
18961
  const contentType = proxyRes.headers.get("content-type") || "";
18935
18962
  if (contentType.includes("text/html")) {
18936
18963
  const htmlBody = await proxyRes.text();
18937
- const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody, mountPoint));
18964
+ const injectedHtml = Buffer.from(injectUiConfigIntoHtml(htmlBody));
18938
18965
  res.setHeader("content-length", String(injectedHtml.byteLength));
18939
18966
  res.end(injectedHtml);
18940
18967
  return;
@@ -18946,7 +18973,7 @@ function createDevMiddleware(server, context) {
18946
18973
  console.error("[agentbuilder] Failed to proxy to UI dev server:", error);
18947
18974
  }
18948
18975
  }
18949
- const clientPath = mountPoint === "/" && pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
18976
+ const clientPath = pathWithoutMount.startsWith("/agents/") ? pathWithoutMount.slice("/agents".length) || "/" : pathWithoutMount;
18950
18977
  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
18978
  {
18952
18979
  const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
@@ -18968,7 +18995,7 @@ function createDevMiddleware(server, context) {
18968
18995
  const ext = path8__default.extname(filePath).toLowerCase();
18969
18996
  if (ext === ".html") {
18970
18997
  content = Buffer.from(
18971
- injectUiConfigIntoHtml(content.toString(), mountPoint)
18998
+ injectUiConfigIntoHtml(content.toString())
18972
18999
  );
18973
19000
  }
18974
19001
  const mimeTypes = {
@@ -19144,7 +19171,8 @@ ${effectsCode}
19144
19171
 
19145
19172
  /**
19146
19173
  * DurableThread with all virtual module methods already implemented.
19147
- * Simply extend this class in your agents/Thread.ts file.
19174
+ * Exported by the generated AgentBuilder Worker entry; user projects do not
19175
+ * need an agents/Thread.ts file for the standard hosted/runtime path.
19148
19176
  */
19149
19177
  export class DurableThread extends _BaseDurableThread {
19150
19178
  constructor(ctx, env) {
@@ -19188,7 +19216,8 @@ export class DurableThread extends _BaseDurableThread {
19188
19216
 
19189
19217
  /**
19190
19218
  * DurableAgentBuilder with all virtual module methods already implemented.
19191
- * Simply extend this class in your agents/AgentBuilder.ts file.
19219
+ * Exported by the generated AgentBuilder Worker entry; user projects do not
19220
+ * need an agents/AgentBuilder.ts file for the standard hosted/runtime path.
19192
19221
  */
19193
19222
  export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
19194
19223
  tools() {
@@ -19394,7 +19423,7 @@ export function getVisibleToolNames() {
19394
19423
  `;
19395
19424
  }
19396
19425
  async function loadRoutesVirtualModule(context) {
19397
- const { mountPoint, threadApiDir, rou3Code, hmr } = context;
19426
+ const { threadApiDir, rou3Code, hmr } = context;
19398
19427
  const threadRoutes = scanApiDirectory(threadApiDir);
19399
19428
  const toAbsolutePath = (inputPath) => path8__default.resolve(process.cwd(), inputPath).replace(/\\/g, "/");
19400
19429
  const threadRouteCode = threadRoutes.map(({ method, route, importPath }) => {
@@ -19456,8 +19485,6 @@ import { registry } from "virtual:@standardagents-registry";
19456
19485
  import { requireAuth, createThreadEndpointHandler } from "@standardagents/builder/runtime";
19457
19486
  import { isThreadEndpoint } from "@standardagents/spec";
19458
19487
 
19459
- const MOUNT_POINT = "${mountPoint}";
19460
-
19461
19488
  // Routes that don't require authentication
19462
19489
  const PUBLIC_ROUTES = [
19463
19490
  '/api/auth/bootstrap',
@@ -19556,11 +19583,6 @@ export async function router(request, env) {
19556
19583
  const url = new URL(request.url);
19557
19584
  const pathname = url.pathname;
19558
19585
 
19559
- // Check if request is under mount point
19560
- if (!pathname.startsWith(MOUNT_POINT)) {
19561
- return null;
19562
- }
19563
-
19564
19586
  // Handle CORS preflight requests
19565
19587
  if (request.method === "OPTIONS") {
19566
19588
  return new Response(null, {
@@ -19569,11 +19591,7 @@ export async function router(request, env) {
19569
19591
  });
19570
19592
  }
19571
19593
 
19572
- // Strip mount point prefix for route matching, ensuring we keep the leading slash
19573
- let routePath = pathname.slice(MOUNT_POINT.length) || "/";
19574
- if (!routePath.startsWith('/')) {
19575
- routePath = '/' + routePath;
19576
- }
19594
+ const routePath = pathname || "/";
19577
19595
 
19578
19596
  // Handle API routes
19579
19597
  const router = createRouter();
@@ -19651,32 +19669,29 @@ ${packedThreadRouteCode}
19651
19669
 
19652
19670
  async function serveUI(pathname, env) {
19653
19671
  try {
19654
- const clientPath =
19655
- MOUNT_POINT === "/" && pathname.startsWith("/agents/")
19656
- ? pathname.slice("/agents".length) || "/"
19657
- : pathname;
19672
+ const clientPath = pathname.startsWith("/agents/")
19673
+ ? pathname.slice("/agents".length) || "/"
19674
+ : pathname;
19658
19675
 
19659
- // Use Cloudflare Workers Assets binding (automatically created from wrangler assets config)
19676
+ // Use the Cloudflare Workers Assets binding created by builder()'s generated
19677
+ // Cloudflare Vite plugin config.
19660
19678
  if (env.ASSETS) {
19661
19679
  try {
19662
19680
  // Create a proper request for the asset path
19663
19681
  // Use a dummy origin since we only care about the path
19664
- // Re-add mount point since pathname was stripped by router
19665
- // Handle root mountPoint "/" specially to avoid double slashes
19666
- const mountPrefix = MOUNT_POINT === "/" ? "" : MOUNT_POINT;
19667
- const assetUrl = \`http://localhost\${mountPrefix}\${clientPath}\`;
19682
+ const assetUrl = \`http://localhost\${clientPath}\`;
19668
19683
  let response = await env.ASSETS.fetch(assetUrl);
19669
19684
 
19670
19685
  // If not found, fall back to index.html for SPA routing
19671
19686
  const isIndexHtml = response.status === 404 || clientPath === "/" || !clientPath.includes(".");
19672
19687
  if (isIndexHtml) {
19673
- response = await env.ASSETS.fetch(\`http://localhost\${mountPrefix}/index.html\`);
19688
+ response = await env.ASSETS.fetch(\`http://localhost/index.html\`);
19674
19689
 
19675
- // Transform HTML to use configured mount point
19690
+ // Transform standalone UI asset URLs to root. AgentBuilder owns the
19691
+ // entire Worker surface and has no configurable mount point.
19676
19692
  if (response.status === 200) {
19677
19693
  const html = await response.text();
19678
- // Replace default /agents/ paths with configured mount point
19679
- const modifiedHtml = html.replace(/\\/agents\\//g, \`\${MOUNT_POINT}/\`);
19694
+ const modifiedHtml = html.replace(/\\/agents\\//g, "/");
19680
19695
  return new Response(modifiedHtml, {
19681
19696
  headers: {
19682
19697
  "Content-Type": "text/html; charset=utf-8",
@@ -19713,7 +19728,6 @@ async function serveUI(pathname, env) {
19713
19728
  // src/plugin/virtual-modules.ts
19714
19729
  async function loadVirtualModule(id, context) {
19715
19730
  const {
19716
- mountPoint,
19717
19731
  toolsDir,
19718
19732
  hooksDir,
19719
19733
  threadApiDir,
@@ -19785,7 +19799,6 @@ export const config = {
19785
19799
  modelsDir: "${relativeModelsDir}",
19786
19800
  promptsDir: "${relativePromptsDir}",
19787
19801
  agentsDir: "${relativeAgentsDir}",
19788
- mountPoint: "${mountPoint}",
19789
19802
  };`;
19790
19803
  }
19791
19804
  if (id === RESOLVED_VIRTUAL_MODELS_ID) {
@@ -19910,6 +19923,7 @@ ${allProviders.map((p) => ` "${p.name}": async () => (await import("${p.package
19910
19923
  return loadBuilderVirtualModule(context);
19911
19924
  }
19912
19925
  }
19926
+ var DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE = "2025-08-13";
19913
19927
  var depsToExclude = [
19914
19928
  "@standardagents/builder",
19915
19929
  "@standardagents/builder/runtime",
@@ -19977,6 +19991,77 @@ function createPluginViteConfig(pluginModuleUrl) {
19977
19991
  }
19978
19992
  };
19979
19993
  }
19994
+ function createAgentBuilderWorkerConfig(options) {
19995
+ const compatibilityDate = options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE;
19996
+ return {
19997
+ // This object is the generated Cloudflare Worker config for customer apps.
19998
+ // Future agents: update this instead of reintroducing wrangler.jsonc in the
19999
+ // generated project template. Customer repos should only need builder()
20000
+ // in vite.config.ts plus their agents/ source tree.
20001
+ main: options.workerEntry,
20002
+ compatibility_date: compatibilityDate,
20003
+ compatibility_flags: ["nodejs_compat", "enable_ctx_exports"],
20004
+ observability: {
20005
+ enabled: true
20006
+ },
20007
+ worker_loaders: [
20008
+ {
20009
+ binding: "AGENT_BUILDER_CODE_LOADER"
20010
+ }
20011
+ ],
20012
+ vars: {
20013
+ // Future agents: keep this aligned with compatibility_date unless code
20014
+ // execution needs a deliberately different Dynamic Worker date.
20015
+ AGENT_BUILDER_CODE_COMPATIBILITY_DATE: compatibilityDate
20016
+ },
20017
+ assets: {
20018
+ // The builder's client UI is emitted as Vite assets and then wrapped by
20019
+ // the hosted platform when deploying through Workers for Platforms.
20020
+ directory: "dist/client",
20021
+ not_found_handling: "single-page-application",
20022
+ binding: "ASSETS",
20023
+ run_worker_first: ["/**"]
20024
+ },
20025
+ durable_objects: {
20026
+ bindings: [
20027
+ {
20028
+ name: "AGENT_BUILDER_THREAD",
20029
+ class_name: "DurableThread"
20030
+ },
20031
+ {
20032
+ name: "AGENT_BUILDER",
20033
+ class_name: "DurableAgentBuilder"
20034
+ }
20035
+ ]
20036
+ },
20037
+ migrations: [
20038
+ {
20039
+ tag: "v1",
20040
+ new_sqlite_classes: ["DurableThread"]
20041
+ },
20042
+ {
20043
+ tag: "v2",
20044
+ new_sqlite_classes: ["DurableAgentBuilder"]
20045
+ }
20046
+ ]
20047
+ };
20048
+ }
20049
+ function applyAgentBuilderWorkerConfig(config, options) {
20050
+ const generated = createAgentBuilderWorkerConfig(options);
20051
+ const existingVars = config.vars && typeof config.vars === "object" ? config.vars : {};
20052
+ Object.assign(config, generated);
20053
+ config.vars = {
20054
+ ...existingVars,
20055
+ ...generated.vars ?? {}
20056
+ };
20057
+ }
20058
+ function createAgentBuilderCloudflarePlugins(options) {
20059
+ return cloudflare({
20060
+ config(config) {
20061
+ applyAgentBuilderWorkerConfig(config, options);
20062
+ }
20063
+ });
20064
+ }
19980
20065
  function applyPluginEnvironmentConfig(config) {
19981
20066
  config.optimizeDeps = config.optimizeDeps || {};
19982
20067
  config.optimizeDeps.exclude = [
@@ -20003,13 +20088,6 @@ function applyPluginEnvironmentConfig(config) {
20003
20088
 
20004
20089
  // src/plugin.ts
20005
20090
  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
20091
  const toolsDir = options.toolsDir ? path8__default.resolve(process.cwd(), options.toolsDir) : path8__default.resolve(process.cwd(), "agents/tools");
20014
20092
  const hooksDir = options.hooksDir ? path8__default.resolve(process.cwd(), options.hooksDir) : path8__default.resolve(process.cwd(), "agents/hooks");
20015
20093
  const threadApiDir = options.apiDir ? path8__default.resolve(process.cwd(), options.apiDir) : path8__default.resolve(process.cwd(), "agents/api");
@@ -20018,6 +20096,7 @@ function agentbuilder(options = {}) {
20018
20096
  const agentsDir = options.agentsDir ? path8__default.resolve(process.cwd(), options.agentsDir) : path8__default.resolve(process.cwd(), "agents/agents");
20019
20097
  const effectsDir = options.effectsDir ? path8__default.resolve(process.cwd(), options.effectsDir) : path8__default.resolve(process.cwd(), "agents/effects");
20020
20098
  const outputDir = path8__default.resolve(process.cwd(), ".agents");
20099
+ const generatedWorkerEntry = path8__default.join(outputDir, "worker.ts");
20021
20100
  const installedProviders = buildInstalledProviderCatalog(options.providers || []);
20022
20101
  const installedProviderPackageMap = buildProviderPackageMap(options.providers || []);
20023
20102
  const typeGenConfig = {
@@ -20033,6 +20112,25 @@ function agentbuilder(options = {}) {
20033
20112
  generateTypes(typeGenConfig);
20034
20113
  }
20035
20114
  }
20115
+ function writeGeneratedWorkerEntry() {
20116
+ const content = `// Generated by @standardagents/builder.
20117
+ // Future agents: update builder/src/plugin.ts when changing this entrypoint.
20118
+ import { CodeExecutionBridge, DurableAgentBuilder, DurableThread, router } from "virtual:@standardagents/builder";
20119
+
20120
+ export default {
20121
+ async fetch(request: Request, env: Parameters<typeof router>[1]) {
20122
+ const response = await router(request, env);
20123
+ return response ?? new Response(null, { status: 404 });
20124
+ },
20125
+ };
20126
+
20127
+ export { CodeExecutionBridge, DurableAgentBuilder, DurableThread };
20128
+ `;
20129
+ fs8__default.mkdirSync(outputDir, { recursive: true });
20130
+ if (!fs8__default.existsSync(generatedWorkerEntry) || fs8__default.readFileSync(generatedWorkerEntry, "utf-8") !== content) {
20131
+ fs8__default.writeFileSync(generatedWorkerEntry, content);
20132
+ }
20133
+ }
20036
20134
  const __filename = fileURLToPath(import.meta.url);
20037
20135
  const __dirname = path8__default.dirname(__filename);
20038
20136
  const rou3Path = path8__default.join(__dirname, "../dist/rou3.js");
@@ -20053,7 +20151,6 @@ function agentbuilder(options = {}) {
20053
20151
  effectsDir
20054
20152
  };
20055
20153
  const virtualModuleContext = {
20056
- mountPoint,
20057
20154
  toolsDir,
20058
20155
  hooksDir,
20059
20156
  threadApiDir,
@@ -20066,7 +20163,6 @@ function agentbuilder(options = {}) {
20066
20163
  hmr
20067
20164
  };
20068
20165
  const devMiddlewareContext = {
20069
- mountPoint,
20070
20166
  toolsDir,
20071
20167
  hooksDir,
20072
20168
  modelsDir,
@@ -20078,11 +20174,14 @@ function agentbuilder(options = {}) {
20078
20174
  sourceDirs,
20079
20175
  regenerateTypes
20080
20176
  };
20081
- return {
20177
+ const workerEntry = path8__default.relative(process.cwd(), generatedWorkerEntry).split(path8__default.sep).join("/");
20178
+ const corePlugin = {
20082
20179
  name: "vite-plugin-agent",
20083
20180
  enforce: "pre",
20084
20181
  config() {
20085
- return createPluginViteConfig(import.meta.url);
20182
+ writeGeneratedWorkerEntry();
20183
+ const viteConfig = createPluginViteConfig(import.meta.url);
20184
+ return viteConfig;
20086
20185
  },
20087
20186
  // Apply exclusions and inclusions to ALL environments including Cloudflare worker
20088
20187
  configEnvironment(_name, config) {
@@ -20130,6 +20229,7 @@ function agentbuilder(options = {}) {
20130
20229
  return loadVirtualModule(id, virtualModuleContext);
20131
20230
  },
20132
20231
  buildStart() {
20232
+ writeGeneratedWorkerEntry();
20133
20233
  regenerateTypes();
20134
20234
  this.addWatchFile(toolsDir);
20135
20235
  this.addWatchFile(threadApiDir);
@@ -20147,8 +20247,7 @@ function agentbuilder(options = {}) {
20147
20247
  },
20148
20248
  writeBundle(options2, bundle) {
20149
20249
  const outDir = options2.dir || "dist";
20150
- const mountPath = mountPoint.slice(1);
20151
- const mountDir = mountPath ? path8__default.join(outDir, "../client", mountPath) : path8__default.join(outDir, "../client");
20250
+ const mountDir = path8__default.join(outDir, "../client");
20152
20251
  const currentDir = path8__default.dirname(fileURLToPath(import.meta.url));
20153
20252
  const isInDist = currentDir.endsWith("dist");
20154
20253
  const clientDir = path8__default.resolve(
@@ -20171,10 +20270,9 @@ function agentbuilder(options = {}) {
20171
20270
  } else {
20172
20271
  let content = fs8__default.readFileSync(srcPath);
20173
20272
  if (entry.name === "index.html") {
20174
- const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = { mountPoint: "${mountPoint}" };</script>`;
20273
+ const configScript = `<script>window.__AGENTBUILDER_CONFIG__ = {};</script>`;
20175
20274
  let htmlContent = content.toString();
20176
- const assetPrefix = mountPoint === "/" ? "/" : `${mountPoint}/`;
20177
- htmlContent = htmlContent.replace(/\/agents\//g, assetPrefix);
20275
+ htmlContent = htmlContent.replace(/\/agents\//g, "/");
20178
20276
  htmlContent = htmlContent.replace("</head>", `${configScript}</head>`);
20179
20277
  content = Buffer.from(htmlContent);
20180
20278
  }
@@ -20185,7 +20283,15 @@ function agentbuilder(options = {}) {
20185
20283
  copyRecursive(clientDir, mountDir);
20186
20284
  }
20187
20285
  };
20286
+ return [
20287
+ corePlugin,
20288
+ ...createAgentBuilderCloudflarePlugins({
20289
+ workerEntry,
20290
+ compatibilityDate: options.compatibilityDate ?? DEFAULT_AGENTBUILDER_COMPATIBILITY_DATE
20291
+ })
20292
+ ];
20188
20293
  }
20294
+ var builder = agentbuilder;
20189
20295
 
20190
20296
  // src/router/index.ts
20191
20297
  init_ThreadStateImpl();
@@ -22846,14 +22952,14 @@ var DurableThread = class extends DurableObject {
22846
22952
  }
22847
22953
  try {
22848
22954
  const builderId = this.env.AGENT_BUILDER.idFromName("singleton");
22849
- const builder = this.env.AGENT_BUILDER.get(builderId);
22850
- if (typeof builder.getThread !== "function") {
22955
+ const builder2 = this.env.AGENT_BUILDER.get(builderId);
22956
+ if (typeof builder2.getThread !== "function") {
22851
22957
  return projections;
22852
22958
  }
22853
22959
  await Promise.all(
22854
22960
  unresolved.map(async (subagentId) => {
22855
22961
  try {
22856
- const thread = await builder.getThread(subagentId);
22962
+ const thread = await builder2.getThread(subagentId);
22857
22963
  if (!thread) {
22858
22964
  return;
22859
22965
  }
@@ -25353,7 +25459,7 @@ ${resultContent}${attachmentSummary}`;
25353
25459
  max_session_turns: agentDef.maxSessionTurns,
25354
25460
  side_a_label: agentDef.sideA?.label,
25355
25461
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25356
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25462
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25357
25463
  side_a_stop_tool: agentDef.sideA?.stopTool,
25358
25464
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25359
25465
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25368,7 +25474,7 @@ ${resultContent}${attachmentSummary}`;
25368
25474
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25369
25475
  side_b_label: agentDef.sideB?.label,
25370
25476
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25371
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25477
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25372
25478
  side_b_stop_tool: agentDef.sideB?.stopTool,
25373
25479
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25374
25480
  side_b_max_steps: agentDef.sideB?.maxSteps,
@@ -25546,7 +25652,7 @@ ${resultContent}${attachmentSummary}`;
25546
25652
  max_session_turns: agentDef.maxSessionTurns,
25547
25653
  side_a_label: agentDef.sideA?.label,
25548
25654
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25549
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25655
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25550
25656
  side_a_stop_tool: agentDef.sideA?.stopTool,
25551
25657
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25552
25658
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25561,7 +25667,7 @@ ${resultContent}${attachmentSummary}`;
25561
25667
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25562
25668
  side_b_label: agentDef.sideB?.label,
25563
25669
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25564
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25670
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25565
25671
  side_b_stop_tool: agentDef.sideB?.stopTool,
25566
25672
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25567
25673
  side_b_max_steps: agentDef.sideB?.maxSteps,
@@ -25692,7 +25798,7 @@ ${resultContent}${attachmentSummary}`;
25692
25798
  max_session_turns: agentDef.maxSessionTurns,
25693
25799
  side_a_label: agentDef.sideA?.label,
25694
25800
  side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
25695
- side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? false,
25801
+ side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
25696
25802
  side_a_stop_tool: agentDef.sideA?.stopTool,
25697
25803
  side_a_stop_tool_response_property: agentDef.sideA?.stopToolResponseProperty,
25698
25804
  side_a_max_steps: agentDef.sideA?.maxSteps,
@@ -25707,7 +25813,7 @@ ${resultContent}${attachmentSummary}`;
25707
25813
  side_a_session_status_attachments_property: sideASession.status.attachmentsProperty,
25708
25814
  side_b_label: agentDef.sideB?.label,
25709
25815
  side_b_agent_prompt: qualifyPromptName(agentDef.sideB?.prompt),
25710
- side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? false,
25816
+ side_b_stop_on_response: agentDef.sideB?.stopOnResponse ?? true,
25711
25817
  side_b_stop_tool: agentDef.sideB?.stopTool,
25712
25818
  side_b_stop_tool_response_property: agentDef.sideB?.stopToolResponseProperty,
25713
25819
  side_b_max_steps: agentDef.sideB?.maxSteps,
@@ -28560,10 +28666,10 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
28560
28666
  return this.getUserById(rows[0].user_id);
28561
28667
  }
28562
28668
  // ============================================================
28563
- // Edit Lock Methods (for GitHub integration)
28669
+ // Edit Lock Methods
28564
28670
  // ============================================================
28565
28671
  /**
28566
- * Acquire edit lock for GitHub commits.
28672
+ * Acquire edit lock for coordinated edits.
28567
28673
  */
28568
28674
  async acquireEditLock(params) {
28569
28675
  await this.ensureMigrated();
@@ -29090,248 +29196,9 @@ function enhanceFlowState(flow) {
29090
29196
 
29091
29197
  // src/index.ts
29092
29198
  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
29199
  init_ProviderRegistry();
29333
29200
  init_types2();
29334
29201
 
29335
- export { CodeExecutionBridge, DurableAgentBuilder, DurableThread, FlowStateSdk, GitHubApiError, GitHubClient, NamespaceResolutionError, PackageDiscoveryService, ProviderRegistry, agentbuilder, authenticate, buildImageDescription, 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 };
29202
+ 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
29203
  //# sourceMappingURL=index.js.map
29337
29204
  //# sourceMappingURL=index.js.map