@standardagents/builder 0.11.0-next.730b472 → 0.11.0-next.80cee2e
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 +46 -19
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +2 -2
- package/dist/index.d.ts +15 -1
- package/dist/index.js +14 -89
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +7 -76
- package/dist/plugin.js.map +1 -1
- package/package.json +6 -8
- package/dist/sip.wasm +0 -0
package/dist/plugin.js
CHANGED
|
@@ -2068,15 +2068,7 @@ function agentbuilder(options = {}) {
|
|
|
2068
2068
|
"zod",
|
|
2069
2069
|
"openai"
|
|
2070
2070
|
];
|
|
2071
|
-
const currentDir = path3.dirname(fileURLToPath(import.meta.url));
|
|
2072
|
-
const isInDist = currentDir.endsWith("dist");
|
|
2073
|
-
const builderClientDir = path3.resolve(
|
|
2074
|
-
currentDir,
|
|
2075
|
-
isInDist ? "./client" : "../dist/client"
|
|
2076
|
-
);
|
|
2077
2071
|
return {
|
|
2078
|
-
// Set publicDir to builder's client assets so Cloudflare plugin preserves assets config
|
|
2079
|
-
publicDir: fs2.existsSync(builderClientDir) ? builderClientDir : void 0,
|
|
2080
2072
|
optimizeDeps: {
|
|
2081
2073
|
// Exclude our packages from pre-bundling - they contain cloudflare:workers imports
|
|
2082
2074
|
// that cannot be resolved during dependency optimization
|
|
@@ -2230,48 +2222,6 @@ function isPublicRoute(routePath) {
|
|
|
2230
2222
|
return false;
|
|
2231
2223
|
}
|
|
2232
2224
|
|
|
2233
|
-
// CORS headers for API responses
|
|
2234
|
-
const CORS_HEADERS = {
|
|
2235
|
-
"Access-Control-Allow-Origin": "*",
|
|
2236
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
2237
|
-
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
|
2238
|
-
"Access-Control-Max-Age": "86400",
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
// Helper to create headers with CORS
|
|
2242
|
-
function corsHeaders(contentType) {
|
|
2243
|
-
return {
|
|
2244
|
-
"Content-Type": contentType,
|
|
2245
|
-
...CORS_HEADERS,
|
|
2246
|
-
};
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
// Helper to add CORS headers to any Response without touching the body
|
|
2250
|
-
function addCorsHeaders(response) {
|
|
2251
|
-
// Skip WebSocket upgrade responses - they can't be wrapped
|
|
2252
|
-
if (response.status === 101) {
|
|
2253
|
-
return response;
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
// Skip if already has CORS headers
|
|
2257
|
-
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
2258
|
-
return response;
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
// Create new headers with CORS added
|
|
2262
|
-
const newHeaders = new Headers(response.headers);
|
|
2263
|
-
for (const [key, value] of Object.entries(CORS_HEADERS)) {
|
|
2264
|
-
newHeaders.set(key, value);
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
// Return new Response with same body stream (not cloned, just transferred)
|
|
2268
|
-
return new Response(response.body, {
|
|
2269
|
-
status: response.status,
|
|
2270
|
-
statusText: response.statusText,
|
|
2271
|
-
headers: newHeaders,
|
|
2272
|
-
});
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
2225
|
export async function router(request, env) {
|
|
2276
2226
|
const url = new URL(request.url);
|
|
2277
2227
|
const pathname = url.pathname;
|
|
@@ -2281,14 +2231,6 @@ export async function router(request, env) {
|
|
|
2281
2231
|
return null;
|
|
2282
2232
|
}
|
|
2283
2233
|
|
|
2284
|
-
// Handle CORS preflight requests
|
|
2285
|
-
if (request.method === "OPTIONS") {
|
|
2286
|
-
return new Response(null, {
|
|
2287
|
-
status: 204,
|
|
2288
|
-
headers: CORS_HEADERS,
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
2234
|
// Strip mount point prefix for route matching, ensuring we keep the leading slash
|
|
2293
2235
|
let routePath = pathname.slice(MOUNT_POINT.length) || "/";
|
|
2294
2236
|
if (!routePath.startsWith('/')) {
|
|
@@ -2323,7 +2265,7 @@ ${threadRouteCode}
|
|
|
2323
2265
|
|
|
2324
2266
|
// If requireAuth returns a Response, it's an error (401)
|
|
2325
2267
|
if (authResult instanceof Response) {
|
|
2326
|
-
return
|
|
2268
|
+
return authResult;
|
|
2327
2269
|
}
|
|
2328
2270
|
|
|
2329
2271
|
authContext = authResult;
|
|
@@ -2342,17 +2284,16 @@ ${threadRouteCode}
|
|
|
2342
2284
|
const result = await controller(context);
|
|
2343
2285
|
|
|
2344
2286
|
if (result instanceof Response) {
|
|
2345
|
-
return
|
|
2287
|
+
return result;
|
|
2346
2288
|
}
|
|
2347
2289
|
if (typeof result === "string") {
|
|
2348
2290
|
return new Response(result, {
|
|
2349
|
-
headers:
|
|
2291
|
+
headers: {
|
|
2292
|
+
"Content-Type": "text/plain",
|
|
2293
|
+
},
|
|
2350
2294
|
});
|
|
2351
2295
|
}
|
|
2352
|
-
|
|
2353
|
-
return new Response(JSON.stringify(result), {
|
|
2354
|
-
headers: corsHeaders("application/json"),
|
|
2355
|
-
});
|
|
2296
|
+
return Response.json(result);
|
|
2356
2297
|
}
|
|
2357
2298
|
|
|
2358
2299
|
// Serve UI for all other routes (SPA fallback)
|
|
@@ -2660,8 +2601,7 @@ import { DurableAgentBuilder as _BaseDurableAgentBuilder } from '@standardagents
|
|
|
2660
2601
|
|
|
2661
2602
|
// Import sip WASM module and initializer
|
|
2662
2603
|
// Static import allows workerd to pre-compile the WASM at bundle time
|
|
2663
|
-
|
|
2664
|
-
import _sipWasm from '@standardagents/builder/dist/sip.wasm';
|
|
2604
|
+
import _sipWasm from '@standardagents/sip/dist/sip.wasm';
|
|
2665
2605
|
import { initWithWasmModule as _initSipWasm } from '@standardagents/sip';
|
|
2666
2606
|
|
|
2667
2607
|
// Re-export router from virtual:@standardagents-routes
|
|
@@ -3216,13 +3156,6 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3216
3156
|
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
3217
3157
|
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
3218
3158
|
};
|
|
3219
|
-
const getSidePrompt = (c, side) => {
|
|
3220
|
-
const sideRegex = new RegExp(`${side}:\\s*\\{([^}]+)\\}`, "s");
|
|
3221
|
-
const sideMatch = c.match(sideRegex);
|
|
3222
|
-
if (!sideMatch) return null;
|
|
3223
|
-
const promptMatch = sideMatch[1].match(/prompt:\s*['"]([^'"]+)['"]/);
|
|
3224
|
-
return promptMatch ? promptMatch[1] : null;
|
|
3225
|
-
};
|
|
3226
3159
|
const name = getName(content);
|
|
3227
3160
|
if (!name) return null;
|
|
3228
3161
|
return {
|
|
@@ -3233,8 +3166,6 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3233
3166
|
default_prompt: getDefaultPrompt(content) || "",
|
|
3234
3167
|
default_model: getDefaultModel(content) || "",
|
|
3235
3168
|
tools: getTools(content),
|
|
3236
|
-
side_a_agent_prompt: getSidePrompt(content, "sideA"),
|
|
3237
|
-
side_b_agent_prompt: getSidePrompt(content, "sideB"),
|
|
3238
3169
|
created_at: Math.floor(Date.now() / 1e3)
|
|
3239
3170
|
};
|
|
3240
3171
|
} catch (error) {
|