@standardagents/builder 0.10.0 → 0.10.1-dev.616ec2e

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";
@@ -2063,13 +2065,21 @@ function agentbuilder(options = {}) {
2063
2065
  "@cf-wasm/photon/workerd",
2064
2066
  "@jsquash/avif",
2065
2067
  "@jsquash/jpeg",
2066
- "@jsquash/png"
2068
+ "@jsquash/png",
2069
+ "@jsquash/webp",
2070
+ "@standardagents/sip"
2071
+ ];
2072
+ const depsToInclude = [
2073
+ "zod",
2074
+ "openai"
2067
2075
  ];
2068
2076
  return {
2069
2077
  optimizeDeps: {
2070
2078
  // Exclude our packages from pre-bundling - they contain cloudflare:workers imports
2071
2079
  // that cannot be resolved during dependency optimization
2072
- exclude: depsToExclude
2080
+ exclude: depsToExclude,
2081
+ // Include common deps upfront to prevent re-optimization during dev
2082
+ include: depsToInclude
2073
2083
  },
2074
2084
  ssr: {
2075
2085
  // noExternal ensures Vite transforms these instead of leaving as external
@@ -2082,7 +2092,7 @@ function agentbuilder(options = {}) {
2082
2092
  }
2083
2093
  };
2084
2094
  },
2085
- // Apply exclusions to ALL environments including Cloudflare worker
2095
+ // Apply exclusions and inclusions to ALL environments including Cloudflare worker
2086
2096
  configEnvironment(name, config) {
2087
2097
  const depsToExclude = [
2088
2098
  "@standardagents/builder",
@@ -2094,13 +2104,23 @@ function agentbuilder(options = {}) {
2094
2104
  "@cf-wasm/photon/workerd",
2095
2105
  "@jsquash/avif",
2096
2106
  "@jsquash/jpeg",
2097
- "@jsquash/png"
2107
+ "@jsquash/png",
2108
+ "@jsquash/webp",
2109
+ "@standardagents/sip"
2110
+ ];
2111
+ const depsToInclude = [
2112
+ "zod",
2113
+ "openai"
2098
2114
  ];
2099
2115
  config.optimizeDeps = config.optimizeDeps || {};
2100
2116
  config.optimizeDeps.exclude = [
2101
2117
  ...config.optimizeDeps.exclude || [],
2102
2118
  ...depsToExclude.filter((dep) => !config.optimizeDeps?.exclude?.includes(dep))
2103
2119
  ];
2120
+ config.optimizeDeps.include = [
2121
+ ...config.optimizeDeps.include || [],
2122
+ ...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
2123
+ ];
2104
2124
  },
2105
2125
  resolveId(id) {
2106
2126
  if (id === VIRTUAL_TOOLS_ID) {
@@ -2538,6 +2558,11 @@ export const agentNames = ${JSON.stringify(agents.filter((a) => !a.error).map((a
2538
2558
  import { DurableThread as _BaseDurableThread } from '@standardagents/builder/runtime';
2539
2559
  import { DurableAgentBuilder as _BaseDurableAgentBuilder } from '@standardagents/builder/runtime';
2540
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
+
2541
2566
  // Re-export router from virtual:@standardagents-routes
2542
2567
  export { router } from 'virtual:@standardagents-routes';
2543
2568
 
@@ -2567,6 +2592,16 @@ ${agentsCode}
2567
2592
  * Simply extend this class in your agents/Thread.ts file.
2568
2593
  */
2569
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
+
2570
2605
  tools() {
2571
2606
  return _tools;
2572
2607
  }