@standardagents/builder 0.9.17 → 0.10.1-dev.114898

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/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs2 from 'fs';
2
2
  import path3 from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ import { createRequire } from 'module';
4
5
 
5
6
  // src/plugin.ts
6
7
  var TSCONFIG_CONTENT = `{
@@ -986,7 +987,7 @@ function generateAgentFile(data) {
986
987
  if (data.type && data.type !== "ai_human") {
987
988
  lines.push(` type: '${data.type}',`);
988
989
  }
989
- if (data.maxSessionTurns !== void 0) {
990
+ if (data.maxSessionTurns !== void 0 && data.maxSessionTurns !== null) {
990
991
  lines.push(` maxSessionTurns: ${data.maxSessionTurns},`);
991
992
  }
992
993
  lines.push(` sideA: ${formatSideConfig(data.sideA)},`);
@@ -1629,7 +1630,7 @@ function validateAgentData(data) {
1629
1630
  if (data.exposeAsTool && !data.toolDescription) {
1630
1631
  return "toolDescription is required when exposeAsTool is true";
1631
1632
  }
1632
- if (data.maxSessionTurns !== void 0) {
1633
+ if (data.maxSessionTurns !== void 0 && data.maxSessionTurns !== null) {
1633
1634
  if (typeof data.maxSessionTurns !== "number" || data.maxSessionTurns <= 0) {
1634
1635
  return "maxSessionTurns must be a positive number";
1635
1636
  }
@@ -1648,6 +1649,7 @@ function validateAgentData(data) {
1648
1649
  }
1649
1650
 
1650
1651
  // src/plugin.ts
1652
+ createRequire(import.meta.url);
1651
1653
  var VIRTUAL_TOOLS_ID = "virtual:@standardagents-tools";
1652
1654
  var RESOLVED_VIRTUAL_TOOLS_ID = "\0" + VIRTUAL_TOOLS_ID;
1653
1655
  var VIRTUAL_ROUTES_ID = "virtual:@standardagents-routes";
@@ -2056,13 +2058,28 @@ function agentbuilder(options = {}) {
2056
2058
  const depsToExclude = [
2057
2059
  "@standardagents/builder",
2058
2060
  "@standardagents/builder/runtime",
2059
- "@standardagents/builder/built-in-routes"
2061
+ "@standardagents/builder/built-in-routes",
2062
+ "@standardagents/builder/image-processing",
2063
+ // WASM image processing deps - must be excluded to avoid pre-bundle cache issues
2064
+ "@cf-wasm/photon",
2065
+ "@cf-wasm/photon/workerd",
2066
+ "@jsquash/avif",
2067
+ "@jsquash/jpeg",
2068
+ "@jsquash/png",
2069
+ "@jsquash/webp",
2070
+ "@standardagents/sip"
2071
+ ];
2072
+ const depsToInclude = [
2073
+ "zod",
2074
+ "openai"
2060
2075
  ];
2061
2076
  return {
2062
2077
  optimizeDeps: {
2063
2078
  // Exclude our packages from pre-bundling - they contain cloudflare:workers imports
2064
2079
  // that cannot be resolved during dependency optimization
2065
- exclude: depsToExclude
2080
+ exclude: depsToExclude,
2081
+ // Include common deps upfront to prevent re-optimization during dev
2082
+ include: depsToInclude
2066
2083
  },
2067
2084
  ssr: {
2068
2085
  // noExternal ensures Vite transforms these instead of leaving as external
@@ -2075,18 +2092,35 @@ function agentbuilder(options = {}) {
2075
2092
  }
2076
2093
  };
2077
2094
  },
2078
- // Apply exclusions to ALL environments including Cloudflare worker
2095
+ // Apply exclusions and inclusions to ALL environments including Cloudflare worker
2079
2096
  configEnvironment(name, config) {
2080
2097
  const depsToExclude = [
2081
2098
  "@standardagents/builder",
2082
2099
  "@standardagents/builder/runtime",
2083
- "@standardagents/builder/built-in-routes"
2100
+ "@standardagents/builder/built-in-routes",
2101
+ "@standardagents/builder/image-processing",
2102
+ // WASM image processing deps
2103
+ "@cf-wasm/photon",
2104
+ "@cf-wasm/photon/workerd",
2105
+ "@jsquash/avif",
2106
+ "@jsquash/jpeg",
2107
+ "@jsquash/png",
2108
+ "@jsquash/webp",
2109
+ "@standardagents/sip"
2110
+ ];
2111
+ const depsToInclude = [
2112
+ "zod",
2113
+ "openai"
2084
2114
  ];
2085
2115
  config.optimizeDeps = config.optimizeDeps || {};
2086
2116
  config.optimizeDeps.exclude = [
2087
2117
  ...config.optimizeDeps.exclude || [],
2088
2118
  ...depsToExclude.filter((dep) => !config.optimizeDeps?.exclude?.includes(dep))
2089
2119
  ];
2120
+ config.optimizeDeps.include = [
2121
+ ...config.optimizeDeps.include || [],
2122
+ ...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
2123
+ ];
2090
2124
  },
2091
2125
  resolveId(id) {
2092
2126
  if (id === VIRTUAL_TOOLS_ID) {
@@ -2524,6 +2558,11 @@ export const agentNames = ${JSON.stringify(agents.filter((a) => !a.error).map((a
2524
2558
  import { DurableThread as _BaseDurableThread } from '@standardagents/builder/runtime';
2525
2559
  import { DurableAgentBuilder as _BaseDurableAgentBuilder } from '@standardagents/builder/runtime';
2526
2560
 
2561
+ // Import sip WASM module and initializer
2562
+ // Static import allows workerd to pre-compile the WASM at bundle time
2563
+ import _sipWasm from '@standardagents/sip/dist/sip.wasm';
2564
+ import { initWithWasmModule as _initSipWasm } from '@standardagents/sip';
2565
+
2527
2566
  // Re-export router from virtual:@standardagents-routes
2528
2567
  export { router } from 'virtual:@standardagents-routes';
2529
2568
 
@@ -2553,6 +2592,16 @@ ${agentsCode}
2553
2592
  * Simply extend this class in your agents/Thread.ts file.
2554
2593
  */
2555
2594
  export class DurableThread extends _BaseDurableThread {
2595
+ constructor(ctx, env) {
2596
+ super(ctx, env);
2597
+ // Initialize sip WASM in DO constructor
2598
+ // blockConcurrencyWhile ensures WASM is ready before handling any requests
2599
+ // Pass the statically imported WASM module for workerd to pre-compile
2600
+ ctx.blockConcurrencyWhile(async () => {
2601
+ await _initSipWasm(_sipWasm);
2602
+ });
2603
+ }
2604
+
2556
2605
  tools() {
2557
2606
  return _tools;
2558
2607
  }