@standardagents/builder 0.10.1-next.9e1860c → 0.11.0-next.0fa8695
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 +50 -88
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +23 -26
- package/dist/client/vendor.js +1 -1
- package/dist/client/vue.js +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.js +18 -107
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +7 -71
- package/dist/plugin.js.map +1 -1
- package/package.json +6 -8
- package/dist/sip.wasm +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AgentPluginOptions, agentbuilder } from './plugin.js';
|
|
2
2
|
import { DurableObjectStorage } from '@cloudflare/workers-types';
|
|
3
3
|
import { ZodObject, ZodRawShape } from 'zod';
|
|
4
|
-
import { ToolResult as ToolResult$1, HookSignatures,
|
|
4
|
+
import { ToolResult as ToolResult$1, HookSignatures, ControllerContext, Controller, ModelDefinition as ModelDefinition$1, ToolArgs, PromptTextPart, SubpromptConfig as SubpromptConfig$2, ReasoningConfig, SideConfig as SideConfig$1 } from '@standardagents/spec';
|
|
5
5
|
export { AgentType, HookSignatures, ImageContent, ModelCapabilities, ModelProvider, PromptInput, PromptTextPart, ReasoningConfig, StructuredPrompt, TextContent, Tool, ToolArgs, ToolArgsNode, ToolArgsRawShape, ToolContent, defineAgent, defineHook, defineModel, definePrompt, defineThreadEndpoint, defineTool } from '@standardagents/spec';
|
|
6
6
|
import { DurableObject } from 'cloudflare:workers';
|
|
7
7
|
import 'vite';
|
|
@@ -785,6 +785,20 @@ interface LogEntry {
|
|
|
785
785
|
created_at: number;
|
|
786
786
|
request_body: string | null;
|
|
787
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* Agent definition returned from loadAgent()
|
|
790
|
+
*/
|
|
791
|
+
interface AgentDefinition$1 {
|
|
792
|
+
name: string;
|
|
793
|
+
title?: string;
|
|
794
|
+
type?: string;
|
|
795
|
+
description?: string;
|
|
796
|
+
icon?: string;
|
|
797
|
+
defaultPrompt?: string;
|
|
798
|
+
defaultModel?: string;
|
|
799
|
+
tools?: string[];
|
|
800
|
+
[key: string]: unknown;
|
|
801
|
+
}
|
|
788
802
|
/**
|
|
789
803
|
* Response from getThreadMeta()
|
|
790
804
|
*/
|
|
@@ -847,9 +861,6 @@ interface DurableAgentBuilderRpc {
|
|
|
847
861
|
listThreads(params?: {
|
|
848
862
|
agent_name?: string;
|
|
849
863
|
user_id?: string;
|
|
850
|
-
search?: string;
|
|
851
|
-
startDate?: number;
|
|
852
|
-
endDate?: number;
|
|
853
864
|
limit?: number;
|
|
854
865
|
offset?: number;
|
|
855
866
|
}): Promise<{
|
|
@@ -1843,9 +1854,6 @@ declare class DurableAgentBuilder<Env extends AgentBuilderEnv = AgentBuilderEnv>
|
|
|
1843
1854
|
listThreads(params?: {
|
|
1844
1855
|
agent_name?: string;
|
|
1845
1856
|
user_id?: string;
|
|
1846
|
-
search?: string;
|
|
1847
|
-
startDate?: number;
|
|
1848
|
-
endDate?: number;
|
|
1849
1857
|
limit?: number;
|
|
1850
1858
|
offset?: number;
|
|
1851
1859
|
}): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -621,7 +621,6 @@ var init_OpenRouterProvider = __esm({
|
|
|
621
621
|
);
|
|
622
622
|
let content = "";
|
|
623
623
|
let reasoning_content = "";
|
|
624
|
-
let hasReasoningField = false;
|
|
625
624
|
let reasoning_details = [];
|
|
626
625
|
const toolCallsMap = /* @__PURE__ */ new Map();
|
|
627
626
|
let finishReason = "";
|
|
@@ -648,16 +647,12 @@ var init_OpenRouterProvider = __esm({
|
|
|
648
647
|
}
|
|
649
648
|
if (choice.delta?.reasoning) {
|
|
650
649
|
reasoning_content += choice.delta.reasoning;
|
|
651
|
-
hasReasoningField = true;
|
|
652
650
|
}
|
|
653
651
|
if (choice.delta?.reasoning_details) {
|
|
654
652
|
const details = choice.delta.reasoning_details;
|
|
655
653
|
for (const item of details) {
|
|
656
654
|
if (item.type === "reasoning.text") {
|
|
657
|
-
|
|
658
|
-
reasoning_content += item.text || "";
|
|
659
|
-
}
|
|
660
|
-
reasoning_details.push(item);
|
|
655
|
+
reasoning_content += item.text || "";
|
|
661
656
|
} else {
|
|
662
657
|
reasoning_details.push(item);
|
|
663
658
|
}
|
|
@@ -2000,7 +1995,7 @@ async function getMessages(flow, limit = 100, offset = 0, order = "asc") {
|
|
|
2000
1995
|
parent_id,
|
|
2001
1996
|
depth
|
|
2002
1997
|
FROM messages
|
|
2003
|
-
ORDER BY created_at ${orderClause}
|
|
1998
|
+
ORDER BY created_at ${orderClause}
|
|
2004
1999
|
LIMIT ? OFFSET ?`,
|
|
2005
2000
|
limit,
|
|
2006
2001
|
offset
|
|
@@ -4509,7 +4504,7 @@ var init_FlowEngine = __esm({
|
|
|
4509
4504
|
}
|
|
4510
4505
|
const maxSteps = state.currentSide === "a" ? state.agentConfig.side_a_max_steps : state.agentConfig.side_b_max_steps;
|
|
4511
4506
|
const currentSideStepCount = state.currentSide === "a" ? state.sideAStepCount : state.sideBStepCount;
|
|
4512
|
-
if (
|
|
4507
|
+
if (maxSteps !== null && currentSideStepCount >= maxSteps) {
|
|
4513
4508
|
state.stopped = true;
|
|
4514
4509
|
state.stoppedBy = state.currentSide;
|
|
4515
4510
|
state.emitTelemetry?.({
|
|
@@ -4520,7 +4515,7 @@ var init_FlowEngine = __esm({
|
|
|
4520
4515
|
});
|
|
4521
4516
|
return;
|
|
4522
4517
|
}
|
|
4523
|
-
if (state.agentConfig.type === "dual_ai" &&
|
|
4518
|
+
if (state.agentConfig.type === "dual_ai" && state.agentConfig.max_session_turns !== null) {
|
|
4524
4519
|
const completedExchanges = Math.min(state.sideAStepCount, state.sideBStepCount);
|
|
4525
4520
|
if (completedExchanges >= state.agentConfig.max_session_turns) {
|
|
4526
4521
|
state.stopped = true;
|
|
@@ -4837,7 +4832,7 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
4837
4832
|
}
|
|
4838
4833
|
}
|
|
4839
4834
|
const maxSteps = state.currentSide === "a" ? state.agentConfig.side_a_max_steps : state.agentConfig.side_b_max_steps;
|
|
4840
|
-
if (
|
|
4835
|
+
if (maxSteps !== null) {
|
|
4841
4836
|
const currentSideStepCount = state.currentSide === "a" ? state.sideAStepCount : state.sideBStepCount;
|
|
4842
4837
|
const stepsRemaining = maxSteps - currentSideStepCount;
|
|
4843
4838
|
let budgetMessage;
|
|
@@ -5838,14 +5833,14 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
5838
5833
|
${columns.join(", ")}
|
|
5839
5834
|
FROM messages
|
|
5840
5835
|
WHERE parent_id IS NULL
|
|
5841
|
-
ORDER BY created_at ASC
|
|
5836
|
+
ORDER BY created_at ASC
|
|
5842
5837
|
`;
|
|
5843
5838
|
const cursor = await storage.sql.exec(query);
|
|
5844
5839
|
rows = cursor.toArray();
|
|
5845
5840
|
}
|
|
5846
5841
|
if (state.extraMessages && state.extraMessages.length > 0) {
|
|
5847
5842
|
rows.push(...state.extraMessages);
|
|
5848
|
-
rows.sort((a, b) => a.created_at - b.created_at
|
|
5843
|
+
rows.sort((a, b) => a.created_at - b.created_at);
|
|
5849
5844
|
}
|
|
5850
5845
|
const messages = rows.map((row) => ({
|
|
5851
5846
|
id: row.id,
|
|
@@ -6483,9 +6478,6 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
6483
6478
|
listThreads(params?: {
|
|
6484
6479
|
agent_name?: string;
|
|
6485
6480
|
user_id?: string;
|
|
6486
|
-
search?: string;
|
|
6487
|
-
startDate?: number;
|
|
6488
|
-
endDate?: number;
|
|
6489
6481
|
limit?: number;
|
|
6490
6482
|
offset?: number;
|
|
6491
6483
|
}): Promise<{ threads: ThreadRegistryEntry[]; total: number }>;
|
|
@@ -8319,48 +8311,6 @@ function isPublicRoute(routePath) {
|
|
|
8319
8311
|
return false;
|
|
8320
8312
|
}
|
|
8321
8313
|
|
|
8322
|
-
// CORS headers for API responses
|
|
8323
|
-
const CORS_HEADERS = {
|
|
8324
|
-
"Access-Control-Allow-Origin": "*",
|
|
8325
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
8326
|
-
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
|
8327
|
-
"Access-Control-Max-Age": "86400",
|
|
8328
|
-
};
|
|
8329
|
-
|
|
8330
|
-
// Helper to create headers with CORS
|
|
8331
|
-
function corsHeaders(contentType) {
|
|
8332
|
-
return {
|
|
8333
|
-
"Content-Type": contentType,
|
|
8334
|
-
...CORS_HEADERS,
|
|
8335
|
-
};
|
|
8336
|
-
}
|
|
8337
|
-
|
|
8338
|
-
// Helper to add CORS headers to any Response without touching the body
|
|
8339
|
-
function addCorsHeaders(response) {
|
|
8340
|
-
// Skip WebSocket upgrade responses - they can't be wrapped
|
|
8341
|
-
if (response.status === 101) {
|
|
8342
|
-
return response;
|
|
8343
|
-
}
|
|
8344
|
-
|
|
8345
|
-
// Skip if already has CORS headers
|
|
8346
|
-
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
8347
|
-
return response;
|
|
8348
|
-
}
|
|
8349
|
-
|
|
8350
|
-
// Create new headers with CORS added
|
|
8351
|
-
const newHeaders = new Headers(response.headers);
|
|
8352
|
-
for (const [key, value] of Object.entries(CORS_HEADERS)) {
|
|
8353
|
-
newHeaders.set(key, value);
|
|
8354
|
-
}
|
|
8355
|
-
|
|
8356
|
-
// Return new Response with same body stream (not cloned, just transferred)
|
|
8357
|
-
return new Response(response.body, {
|
|
8358
|
-
status: response.status,
|
|
8359
|
-
statusText: response.statusText,
|
|
8360
|
-
headers: newHeaders,
|
|
8361
|
-
});
|
|
8362
|
-
}
|
|
8363
|
-
|
|
8364
8314
|
export async function router(request, env) {
|
|
8365
8315
|
const url = new URL(request.url);
|
|
8366
8316
|
const pathname = url.pathname;
|
|
@@ -8370,14 +8320,6 @@ export async function router(request, env) {
|
|
|
8370
8320
|
return null;
|
|
8371
8321
|
}
|
|
8372
8322
|
|
|
8373
|
-
// Handle CORS preflight requests
|
|
8374
|
-
if (request.method === "OPTIONS") {
|
|
8375
|
-
return new Response(null, {
|
|
8376
|
-
status: 204,
|
|
8377
|
-
headers: CORS_HEADERS,
|
|
8378
|
-
});
|
|
8379
|
-
}
|
|
8380
|
-
|
|
8381
8323
|
// Strip mount point prefix for route matching, ensuring we keep the leading slash
|
|
8382
8324
|
let routePath = pathname.slice(MOUNT_POINT.length) || "/";
|
|
8383
8325
|
if (!routePath.startsWith('/')) {
|
|
@@ -8412,7 +8354,7 @@ ${threadRouteCode}
|
|
|
8412
8354
|
|
|
8413
8355
|
// If requireAuth returns a Response, it's an error (401)
|
|
8414
8356
|
if (authResult instanceof Response) {
|
|
8415
|
-
return
|
|
8357
|
+
return authResult;
|
|
8416
8358
|
}
|
|
8417
8359
|
|
|
8418
8360
|
authContext = authResult;
|
|
@@ -8431,17 +8373,16 @@ ${threadRouteCode}
|
|
|
8431
8373
|
const result = await controller(context);
|
|
8432
8374
|
|
|
8433
8375
|
if (result instanceof Response) {
|
|
8434
|
-
return
|
|
8376
|
+
return result;
|
|
8435
8377
|
}
|
|
8436
8378
|
if (typeof result === "string") {
|
|
8437
8379
|
return new Response(result, {
|
|
8438
|
-
headers:
|
|
8380
|
+
headers: {
|
|
8381
|
+
"Content-Type": "text/plain",
|
|
8382
|
+
},
|
|
8439
8383
|
});
|
|
8440
8384
|
}
|
|
8441
|
-
|
|
8442
|
-
return new Response(JSON.stringify(result), {
|
|
8443
|
-
headers: corsHeaders("application/json"),
|
|
8444
|
-
});
|
|
8385
|
+
return Response.json(result);
|
|
8445
8386
|
}
|
|
8446
8387
|
|
|
8447
8388
|
// Serve UI for all other routes (SPA fallback)
|
|
@@ -8749,8 +8690,7 @@ import { DurableAgentBuilder as _BaseDurableAgentBuilder } from '@standardagents
|
|
|
8749
8690
|
|
|
8750
8691
|
// Import sip WASM module and initializer
|
|
8751
8692
|
// Static import allows workerd to pre-compile the WASM at bundle time
|
|
8752
|
-
|
|
8753
|
-
import _sipWasm from '@standardagents/builder/dist/sip.wasm';
|
|
8693
|
+
import _sipWasm from '@standardagents/sip/dist/sip.wasm';
|
|
8754
8694
|
import { initWithWasmModule as _initSipWasm } from '@standardagents/sip';
|
|
8755
8695
|
|
|
8756
8696
|
// Re-export router from virtual:@standardagents-routes
|
|
@@ -9305,13 +9245,6 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
9305
9245
|
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
9306
9246
|
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
9307
9247
|
};
|
|
9308
|
-
const getSidePrompt = (c, side) => {
|
|
9309
|
-
const sideRegex = new RegExp(`${side}:\\s*\\{([^}]+)\\}`, "s");
|
|
9310
|
-
const sideMatch = c.match(sideRegex);
|
|
9311
|
-
if (!sideMatch) return null;
|
|
9312
|
-
const promptMatch = sideMatch[1].match(/prompt:\s*['"]([^'"]+)['"]/);
|
|
9313
|
-
return promptMatch ? promptMatch[1] : null;
|
|
9314
|
-
};
|
|
9315
9248
|
const name = getName(content);
|
|
9316
9249
|
if (!name) return null;
|
|
9317
9250
|
return {
|
|
@@ -9322,8 +9255,6 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
9322
9255
|
default_prompt: getDefaultPrompt(content) || "",
|
|
9323
9256
|
default_model: getDefaultModel(content) || "",
|
|
9324
9257
|
tools: getTools(content),
|
|
9325
|
-
side_a_agent_prompt: getSidePrompt(content, "sideA"),
|
|
9326
|
-
side_b_agent_prompt: getSidePrompt(content, "sideB"),
|
|
9327
9258
|
created_at: Math.floor(Date.now() / 1e3)
|
|
9328
9259
|
};
|
|
9329
9260
|
} catch (error) {
|
|
@@ -9640,12 +9571,6 @@ function base64ToBuffer(base64) {
|
|
|
9640
9571
|
}
|
|
9641
9572
|
|
|
9642
9573
|
// src/middleware/auth.ts
|
|
9643
|
-
var CORS_HEADERS = {
|
|
9644
|
-
"Access-Control-Allow-Origin": "*",
|
|
9645
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
9646
|
-
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
|
9647
|
-
"Access-Control-Max-Age": "86400"
|
|
9648
|
-
};
|
|
9649
9574
|
function extractBearerToken(request) {
|
|
9650
9575
|
const authHeader = request.headers.get("Authorization");
|
|
9651
9576
|
if (authHeader && authHeader.startsWith("Bearer ")) {
|
|
@@ -9734,7 +9659,7 @@ async function requireAuth(request, env) {
|
|
|
9734
9659
|
if (!authContext) {
|
|
9735
9660
|
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
|
9736
9661
|
status: 401,
|
|
9737
|
-
headers: { "Content-Type": "application/json"
|
|
9662
|
+
headers: { "Content-Type": "application/json" }
|
|
9738
9663
|
});
|
|
9739
9664
|
}
|
|
9740
9665
|
return authContext;
|
|
@@ -9749,7 +9674,7 @@ async function requireAdmin(request, env) {
|
|
|
9749
9674
|
JSON.stringify({ error: "Forbidden: Admin access required" }),
|
|
9750
9675
|
{
|
|
9751
9676
|
status: 403,
|
|
9752
|
-
headers: { "Content-Type": "application/json"
|
|
9677
|
+
headers: { "Content-Type": "application/json" }
|
|
9753
9678
|
}
|
|
9754
9679
|
);
|
|
9755
9680
|
}
|
|
@@ -11145,7 +11070,7 @@ var DurableThread = class extends DurableObject {
|
|
|
11145
11070
|
SELECT id, role, content, name, tool_calls, tool_call_id, tool_status, log_id, created_at, silent, parent_id, depth, status, reasoning_content, reasoning_details, attachments
|
|
11146
11071
|
FROM messages
|
|
11147
11072
|
${whereClause}
|
|
11148
|
-
ORDER BY created_at ${order === "ASC" ? "ASC" : "DESC"}
|
|
11073
|
+
ORDER BY created_at ${order === "ASC" ? "ASC" : "DESC"}
|
|
11149
11074
|
LIMIT ? OFFSET ?
|
|
11150
11075
|
`,
|
|
11151
11076
|
limit,
|
|
@@ -11986,7 +11911,6 @@ var DurableThread = class extends DurableObject {
|
|
|
11986
11911
|
message.attachments,
|
|
11987
11912
|
message.created_at
|
|
11988
11913
|
);
|
|
11989
|
-
await FlowEngine2.runAfterCreateMessageHook(state, message);
|
|
11990
11914
|
this.broadcastMessage({
|
|
11991
11915
|
id: message.id,
|
|
11992
11916
|
role: message.role,
|
|
@@ -12886,19 +12810,6 @@ var DurableAgentBuilder = class extends DurableObject {
|
|
|
12886
12810
|
whereClauses.push("user_id = ?");
|
|
12887
12811
|
args.push(params.user_id);
|
|
12888
12812
|
}
|
|
12889
|
-
if (params?.search) {
|
|
12890
|
-
const searchTerm = `%${params.search.toLowerCase()}%`;
|
|
12891
|
-
whereClauses.push("(LOWER(id) LIKE ? OR LOWER(tags) LIKE ?)");
|
|
12892
|
-
args.push(searchTerm, searchTerm);
|
|
12893
|
-
}
|
|
12894
|
-
if (params?.startDate) {
|
|
12895
|
-
whereClauses.push("created_at >= ?");
|
|
12896
|
-
args.push(params.startDate);
|
|
12897
|
-
}
|
|
12898
|
-
if (params?.endDate) {
|
|
12899
|
-
whereClauses.push("created_at <= ?");
|
|
12900
|
-
args.push(params.endDate);
|
|
12901
|
-
}
|
|
12902
12813
|
const whereClause = whereClauses.length > 0 ? `WHERE ${whereClauses.join(" AND ")}` : "";
|
|
12903
12814
|
const countCursor = await this.ctx.storage.sql.exec(
|
|
12904
12815
|
`SELECT COUNT(*) as count FROM threads ${whereClause}`,
|
|
@@ -13715,7 +13626,7 @@ var FlowStateSdk = class _FlowStateSdk {
|
|
|
13715
13626
|
parent_id,
|
|
13716
13627
|
depth
|
|
13717
13628
|
FROM messages
|
|
13718
|
-
ORDER BY created_at ${orderClause}
|
|
13629
|
+
ORDER BY created_at ${orderClause}
|
|
13719
13630
|
LIMIT ? OFFSET ?`,
|
|
13720
13631
|
limit,
|
|
13721
13632
|
offset
|