@standardagents/builder 0.11.0-next.22e39d0 → 0.11.0-next.24f9ff1
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 +22754 -6950
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/assets/index.css +1 -1
- package/dist/client/index.js +26 -23
- package/dist/client/vendor.js +1 -1
- package/dist/client/vue.js +1 -1
- package/dist/index.d.ts +224 -26
- package/dist/index.js +3119 -1240
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +238 -56
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
- package/dist/client/assets/img/meta.svg +0 -19
- package/dist/client/assets/img/moonshotai.svg +0 -4
- package/dist/client/assets/img/zai.svg +0 -219
package/dist/plugin.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ interface AgentPluginOptions {
|
|
|
9
9
|
promptsDir?: string;
|
|
10
10
|
agentsDir?: string;
|
|
11
11
|
effectsDir?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Additional provider packages to expose in the UI.
|
|
14
|
+
* First-party providers (@standardagents/openai, @standardagents/openrouter) are always included.
|
|
15
|
+
* @example ['my-custom-provider', '@company/custom-openai']
|
|
16
|
+
*/
|
|
17
|
+
providers?: string[];
|
|
12
18
|
}
|
|
13
19
|
declare function agentbuilder(options?: AgentPluginOptions): Plugin;
|
|
14
20
|
|
package/dist/plugin.js
CHANGED
|
@@ -397,6 +397,9 @@ declare module 'virtual:@standardagents/builder' {
|
|
|
397
397
|
listThreads(params?: {
|
|
398
398
|
agent_name?: string;
|
|
399
399
|
user_id?: string;
|
|
400
|
+
search?: string;
|
|
401
|
+
startDate?: number;
|
|
402
|
+
endDate?: number;
|
|
400
403
|
limit?: number;
|
|
401
404
|
offset?: number;
|
|
402
405
|
}): Promise<{ threads: ThreadRegistryEntry[]; total: number }>;
|
|
@@ -578,14 +581,91 @@ function needsRegeneration(config) {
|
|
|
578
581
|
return false;
|
|
579
582
|
}
|
|
580
583
|
|
|
584
|
+
// src/utils/model-parser.ts
|
|
585
|
+
function getName(content) {
|
|
586
|
+
return content.match(/name:\s*['"]([^'"]+)['"]/)?.[1];
|
|
587
|
+
}
|
|
588
|
+
function getProvider(content) {
|
|
589
|
+
const stringMatch = content.match(/provider:\s*['"]([^'"]+)['"]/)?.[1];
|
|
590
|
+
if (stringMatch) return stringMatch;
|
|
591
|
+
const refMatch = content.match(/provider:\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*[,\n}]/)?.[1];
|
|
592
|
+
return refMatch || void 0;
|
|
593
|
+
}
|
|
594
|
+
function getModel(content) {
|
|
595
|
+
return content.match(/model:\s*['"]([^'"]+)['"]/)?.[1];
|
|
596
|
+
}
|
|
597
|
+
function getInputPrice(content) {
|
|
598
|
+
const match = content.match(/inputPrice:\s*([\d.]+)/);
|
|
599
|
+
return match ? parseFloat(match[1]) : void 0;
|
|
600
|
+
}
|
|
601
|
+
function getOutputPrice(content) {
|
|
602
|
+
const match = content.match(/outputPrice:\s*([\d.]+)/);
|
|
603
|
+
return match ? parseFloat(match[1]) : void 0;
|
|
604
|
+
}
|
|
605
|
+
function getCachedPrice(content) {
|
|
606
|
+
const match = content.match(/cachedPrice:\s*([\d.]+)/);
|
|
607
|
+
return match ? parseFloat(match[1]) : void 0;
|
|
608
|
+
}
|
|
609
|
+
function getIncludedProviders(content) {
|
|
610
|
+
const match = content.match(/includedProviders:\s*\[([^\]]*)\]/);
|
|
611
|
+
if (!match) return void 0;
|
|
612
|
+
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
613
|
+
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
614
|
+
}
|
|
615
|
+
function getFallbacks(content) {
|
|
616
|
+
const match = content.match(/fallbacks:\s*\[([^\]]*)\]/);
|
|
617
|
+
if (!match) return [];
|
|
618
|
+
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
619
|
+
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
620
|
+
}
|
|
621
|
+
function getProviderTools(content) {
|
|
622
|
+
const match = content.match(/providerTools:\s*\[([^\]]*)\]/);
|
|
623
|
+
if (!match) return [];
|
|
624
|
+
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
625
|
+
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
626
|
+
}
|
|
627
|
+
function getCapabilities(content) {
|
|
628
|
+
const match = content.match(/capabilities:\s*\{([^}]*)\}/s);
|
|
629
|
+
if (!match) return void 0;
|
|
630
|
+
const inner = match[1];
|
|
631
|
+
const caps = {};
|
|
632
|
+
const boolMatches = inner.matchAll(/(\w+):\s*(true|false)/g);
|
|
633
|
+
for (const m of boolMatches) {
|
|
634
|
+
caps[m[1]] = m[2] === "true";
|
|
635
|
+
}
|
|
636
|
+
const numMatches = inner.matchAll(/(\w+):\s*(\d+)/g);
|
|
637
|
+
for (const m of numMatches) {
|
|
638
|
+
caps[m[1]] = parseInt(m[2], 10);
|
|
639
|
+
}
|
|
640
|
+
return Object.keys(caps).length > 0 ? caps : void 0;
|
|
641
|
+
}
|
|
642
|
+
function parseModelFile(content) {
|
|
643
|
+
const name = getName(content);
|
|
644
|
+
if (!name) return null;
|
|
645
|
+
return {
|
|
646
|
+
name,
|
|
647
|
+
provider: getProvider(content),
|
|
648
|
+
model: getModel(content),
|
|
649
|
+
inputPrice: getInputPrice(content),
|
|
650
|
+
outputPrice: getOutputPrice(content),
|
|
651
|
+
cachedPrice: getCachedPrice(content),
|
|
652
|
+
includedProviders: getIncludedProviders(content),
|
|
653
|
+
fallbacks: getFallbacks(content),
|
|
654
|
+
providerTools: getProviderTools(content),
|
|
655
|
+
capabilities: getCapabilities(content)
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
581
659
|
// src/sdk/generators/generateModelFile.ts
|
|
582
|
-
function generateModelFile(data) {
|
|
660
|
+
function generateModelFile(data, options) {
|
|
661
|
+
const { providerName, providerPackage } = options;
|
|
583
662
|
const lines = [
|
|
584
663
|
`import { defineModel } from '@standardagents/builder';`,
|
|
664
|
+
`import { ${providerName} } from '${providerPackage}';`,
|
|
585
665
|
"",
|
|
586
666
|
`export default defineModel({`,
|
|
587
667
|
` name: '${escapeString(data.name)}',`,
|
|
588
|
-
` provider:
|
|
668
|
+
` provider: ${providerName},`,
|
|
589
669
|
` model: '${escapeString(data.model)}',`
|
|
590
670
|
];
|
|
591
671
|
if (data.includedProviders && data.includedProviders.length > 0) {
|
|
@@ -594,6 +674,9 @@ function generateModelFile(data) {
|
|
|
594
674
|
if (data.fallbacks && data.fallbacks.length > 0) {
|
|
595
675
|
lines.push(` fallbacks: ${JSON.stringify(data.fallbacks)},`);
|
|
596
676
|
}
|
|
677
|
+
if (data.providerTools && data.providerTools.length > 0) {
|
|
678
|
+
lines.push(` providerTools: ${JSON.stringify(data.providerTools)},`);
|
|
679
|
+
}
|
|
597
680
|
if (data.inputPrice !== void 0) {
|
|
598
681
|
lines.push(` inputPrice: ${data.inputPrice},`);
|
|
599
682
|
}
|
|
@@ -603,6 +686,36 @@ function generateModelFile(data) {
|
|
|
603
686
|
if (data.cachedPrice !== void 0) {
|
|
604
687
|
lines.push(` cachedPrice: ${data.cachedPrice},`);
|
|
605
688
|
}
|
|
689
|
+
if (data.capabilities && Object.keys(data.capabilities).length > 0) {
|
|
690
|
+
const caps = data.capabilities;
|
|
691
|
+
const capLines = [];
|
|
692
|
+
if (caps.supportsImages !== void 0) {
|
|
693
|
+
capLines.push(` supportsImages: ${caps.supportsImages},`);
|
|
694
|
+
}
|
|
695
|
+
if (caps.supportsToolCalls !== void 0) {
|
|
696
|
+
capLines.push(` supportsToolCalls: ${caps.supportsToolCalls},`);
|
|
697
|
+
}
|
|
698
|
+
if (caps.supportsStreaming !== void 0) {
|
|
699
|
+
capLines.push(` supportsStreaming: ${caps.supportsStreaming},`);
|
|
700
|
+
}
|
|
701
|
+
if (caps.supportsJsonMode !== void 0) {
|
|
702
|
+
capLines.push(` supportsJsonMode: ${caps.supportsJsonMode},`);
|
|
703
|
+
}
|
|
704
|
+
if (caps.maxContextTokens !== void 0) {
|
|
705
|
+
capLines.push(` maxContextTokens: ${caps.maxContextTokens},`);
|
|
706
|
+
}
|
|
707
|
+
if (caps.maxOutputTokens !== void 0) {
|
|
708
|
+
capLines.push(` maxOutputTokens: ${caps.maxOutputTokens},`);
|
|
709
|
+
}
|
|
710
|
+
if (caps.reasoningLevels !== void 0) {
|
|
711
|
+
capLines.push(` reasoningLevels: ${JSON.stringify(caps.reasoningLevels)},`);
|
|
712
|
+
}
|
|
713
|
+
if (capLines.length > 0) {
|
|
714
|
+
lines.push(` capabilities: {`);
|
|
715
|
+
lines.push(...capLines);
|
|
716
|
+
lines.push(` },`);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
606
719
|
lines.push(`});`);
|
|
607
720
|
lines.push("");
|
|
608
721
|
return lines.join("\n");
|
|
@@ -857,6 +970,12 @@ function formatToolConfig(config) {
|
|
|
857
970
|
if (config.init_user_message_property !== void 0 && config.init_user_message_property !== null) {
|
|
858
971
|
parts.push(`initUserMessageProperty: '${escapeString2(config.init_user_message_property)}'`);
|
|
859
972
|
}
|
|
973
|
+
if (config.init_attachments_property !== void 0 && config.init_attachments_property !== null) {
|
|
974
|
+
parts.push(`initAttachmentsProperty: '${escapeString2(config.init_attachments_property)}'`);
|
|
975
|
+
}
|
|
976
|
+
if (config.tenvs && Object.keys(config.tenvs).length > 0) {
|
|
977
|
+
parts.push(`tenvs: ${JSON.stringify(config.tenvs)}`);
|
|
978
|
+
}
|
|
860
979
|
return `{ ${parts.join(", ")} }`;
|
|
861
980
|
}
|
|
862
981
|
function formatReasoningConfig(reasoning) {
|
|
@@ -989,6 +1108,9 @@ function generateAgentFile(data) {
|
|
|
989
1108
|
if (data.toolDescription) {
|
|
990
1109
|
lines.push(` toolDescription: '${escapeString3(data.toolDescription)}',`);
|
|
991
1110
|
}
|
|
1111
|
+
if (data.tenvs && Object.keys(data.tenvs).length > 0) {
|
|
1112
|
+
lines.push(` tenvs: ${JSON.stringify(data.tenvs)},`);
|
|
1113
|
+
}
|
|
992
1114
|
lines.push(`});`);
|
|
993
1115
|
lines.push("");
|
|
994
1116
|
return lines.join("\n");
|
|
@@ -1025,8 +1147,15 @@ function escapeString3(str) {
|
|
|
1025
1147
|
}
|
|
1026
1148
|
|
|
1027
1149
|
// src/sdk/persistence/index.ts
|
|
1150
|
+
var PROVIDER_PACKAGE_MAP = {
|
|
1151
|
+
openai: { name: "openai", package: "@standardagents/openai" },
|
|
1152
|
+
openrouter: { name: "openrouter", package: "@standardagents/openrouter" },
|
|
1153
|
+
anthropic: { name: "anthropic", package: "@standardagents/anthropic" },
|
|
1154
|
+
google: { name: "google", package: "@standardagents/google" },
|
|
1155
|
+
test: { name: "test", package: "@standardagents/builder/test" }
|
|
1156
|
+
};
|
|
1028
1157
|
function nameToFilename(name) {
|
|
1029
|
-
return name.replace(/[/\\]/g, "__").replace(/[:*?"
|
|
1158
|
+
return name.replace(/[/\\]/g, "__").replace(/[:*?"<>|.]/g, "_").replace(/-/g, "_");
|
|
1030
1159
|
}
|
|
1031
1160
|
function getModelFilePath(modelsDir, name) {
|
|
1032
1161
|
const filename = nameToFilename(name);
|
|
@@ -1048,7 +1177,17 @@ async function saveModel(modelsDir, data, overwrite = false) {
|
|
|
1048
1177
|
error: `Model file already exists: ${filePath}. Use update to modify existing models.`
|
|
1049
1178
|
};
|
|
1050
1179
|
}
|
|
1051
|
-
const
|
|
1180
|
+
const providerInfo = PROVIDER_PACKAGE_MAP[data.provider];
|
|
1181
|
+
if (!providerInfo) {
|
|
1182
|
+
return {
|
|
1183
|
+
success: false,
|
|
1184
|
+
error: `Unknown provider '${data.provider}'. Must be one of: ${Object.keys(PROVIDER_PACKAGE_MAP).join(", ")}`
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
const content = generateModelFile(data, {
|
|
1188
|
+
providerName: providerInfo.name,
|
|
1189
|
+
providerPackage: providerInfo.package
|
|
1190
|
+
});
|
|
1052
1191
|
await fs2.promises.writeFile(filePath, content, "utf-8");
|
|
1053
1192
|
return {
|
|
1054
1193
|
success: true,
|
|
@@ -1112,7 +1251,7 @@ function validateModelData(data) {
|
|
|
1112
1251
|
if (!data.provider || typeof data.provider !== "string") {
|
|
1113
1252
|
return "Model provider is required and must be a string";
|
|
1114
1253
|
}
|
|
1115
|
-
const validProviders =
|
|
1254
|
+
const validProviders = Object.keys(PROVIDER_PACKAGE_MAP);
|
|
1116
1255
|
if (!validProviders.includes(data.provider)) {
|
|
1117
1256
|
return `Invalid provider '${data.provider}'. Must be one of: ${validProviders.join(", ")}`;
|
|
1118
1257
|
}
|
|
@@ -1636,6 +1775,8 @@ var VIRTUAL_AGENTS_ID = "virtual:@standardagents-agents";
|
|
|
1636
1775
|
var RESOLVED_VIRTUAL_AGENTS_ID = "\0" + VIRTUAL_AGENTS_ID;
|
|
1637
1776
|
var VIRTUAL_EFFECTS_ID = "virtual:@standardagents-effects";
|
|
1638
1777
|
var RESOLVED_VIRTUAL_EFFECTS_ID = "\0" + VIRTUAL_EFFECTS_ID;
|
|
1778
|
+
var VIRTUAL_PROVIDERS_ID = "virtual:@standardagents-providers";
|
|
1779
|
+
var RESOLVED_VIRTUAL_PROVIDERS_ID = "\0" + VIRTUAL_PROVIDERS_ID;
|
|
1639
1780
|
var VIRTUAL_BUILDER_ID = "virtual:@standardagents/builder";
|
|
1640
1781
|
var RESOLVED_VIRTUAL_BUILDER_ID = "\0" + VIRTUAL_BUILDER_ID;
|
|
1641
1782
|
function scanApiDirectory(dir, baseRoute = "") {
|
|
@@ -2112,6 +2253,9 @@ function agentbuilder(options = {}) {
|
|
|
2112
2253
|
];
|
|
2113
2254
|
const depsToInclude = [
|
|
2114
2255
|
"zod",
|
|
2256
|
+
"zod/v3",
|
|
2257
|
+
"zod/v4",
|
|
2258
|
+
"zod/v4/core",
|
|
2115
2259
|
"openai"
|
|
2116
2260
|
];
|
|
2117
2261
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
@@ -2152,6 +2296,9 @@ function agentbuilder(options = {}) {
|
|
|
2152
2296
|
if (id === VIRTUAL_EFFECTS_ID) {
|
|
2153
2297
|
return RESOLVED_VIRTUAL_EFFECTS_ID;
|
|
2154
2298
|
}
|
|
2299
|
+
if (id === VIRTUAL_PROVIDERS_ID) {
|
|
2300
|
+
return RESOLVED_VIRTUAL_PROVIDERS_ID;
|
|
2301
|
+
}
|
|
2155
2302
|
if (id === VIRTUAL_BUILDER_ID) {
|
|
2156
2303
|
return RESOLVED_VIRTUAL_BUILDER_ID;
|
|
2157
2304
|
}
|
|
@@ -2227,6 +2374,11 @@ function isPublicRoute(routePath) {
|
|
|
2227
2374
|
return true;
|
|
2228
2375
|
}
|
|
2229
2376
|
|
|
2377
|
+
// Provider icon routes are public (used by <img src>)
|
|
2378
|
+
if (routePath.startsWith('/api/providers/') && routePath.includes('/icon')) {
|
|
2379
|
+
return true;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2230
2382
|
return false;
|
|
2231
2383
|
}
|
|
2232
2384
|
|
|
@@ -2246,6 +2398,32 @@ function corsHeaders(contentType) {
|
|
|
2246
2398
|
};
|
|
2247
2399
|
}
|
|
2248
2400
|
|
|
2401
|
+
// Helper to add CORS headers to any Response without touching the body
|
|
2402
|
+
function addCorsHeaders(response) {
|
|
2403
|
+
// Skip WebSocket upgrade responses - they can't be wrapped
|
|
2404
|
+
if (response.status === 101) {
|
|
2405
|
+
return response;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
// Skip if already has CORS headers
|
|
2409
|
+
if (response.headers.has("Access-Control-Allow-Origin")) {
|
|
2410
|
+
return response;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
// Create new headers with CORS added
|
|
2414
|
+
const newHeaders = new Headers(response.headers);
|
|
2415
|
+
for (const [key, value] of Object.entries(CORS_HEADERS)) {
|
|
2416
|
+
newHeaders.set(key, value);
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
// Return new Response with same body stream (not cloned, just transferred)
|
|
2420
|
+
return new Response(response.body, {
|
|
2421
|
+
status: response.status,
|
|
2422
|
+
statusText: response.statusText,
|
|
2423
|
+
headers: newHeaders,
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2249
2427
|
export async function router(request, env) {
|
|
2250
2428
|
const url = new URL(request.url);
|
|
2251
2429
|
const pathname = url.pathname;
|
|
@@ -2297,7 +2475,7 @@ ${threadRouteCode}
|
|
|
2297
2475
|
|
|
2298
2476
|
// If requireAuth returns a Response, it's an error (401)
|
|
2299
2477
|
if (authResult instanceof Response) {
|
|
2300
|
-
return authResult;
|
|
2478
|
+
return addCorsHeaders(authResult);
|
|
2301
2479
|
}
|
|
2302
2480
|
|
|
2303
2481
|
authContext = authResult;
|
|
@@ -2316,11 +2494,7 @@ ${threadRouteCode}
|
|
|
2316
2494
|
const result = await controller(context);
|
|
2317
2495
|
|
|
2318
2496
|
if (result instanceof Response) {
|
|
2319
|
-
|
|
2320
|
-
// to Response objects in the workerd environment without issues.
|
|
2321
|
-
// Controllers that return streaming/binary responses should add
|
|
2322
|
-
// CORS headers themselves if needed.
|
|
2323
|
-
return result;
|
|
2497
|
+
return addCorsHeaders(result);
|
|
2324
2498
|
}
|
|
2325
2499
|
if (typeof result === "string") {
|
|
2326
2500
|
return new Response(result, {
|
|
@@ -2525,6 +2699,30 @@ ${effectsCode}
|
|
|
2525
2699
|
};
|
|
2526
2700
|
|
|
2527
2701
|
export const effectNames = ${JSON.stringify(effects.filter((e) => !e.error).map((e) => e.name))};
|
|
2702
|
+
`;
|
|
2703
|
+
}
|
|
2704
|
+
if (id === RESOLVED_VIRTUAL_PROVIDERS_ID) {
|
|
2705
|
+
const firstPartyProviders = [
|
|
2706
|
+
{ name: "openai", package: "@standardagents/openai", label: "OpenAI", envKey: "OPENAI_API_KEY" },
|
|
2707
|
+
{ name: "openrouter", package: "@standardagents/openrouter", label: "OpenRouter", envKey: "OPENROUTER_API_KEY" }
|
|
2708
|
+
];
|
|
2709
|
+
const customProviders = (options.providers || []).map((pkg) => ({
|
|
2710
|
+
name: pkg.split("/").pop() || pkg,
|
|
2711
|
+
package: pkg,
|
|
2712
|
+
label: pkg.split("/").pop() || pkg,
|
|
2713
|
+
envKey: `${(pkg.split("/").pop() || pkg).toUpperCase().replace(/-/g, "_")}_API_KEY`,
|
|
2714
|
+
isCustom: true
|
|
2715
|
+
}));
|
|
2716
|
+
const allProviders = [...firstPartyProviders, ...customProviders];
|
|
2717
|
+
return `// Virtual providers module - lists available LLM provider packages
|
|
2718
|
+
export const providers = ${JSON.stringify(allProviders, null, 2)};
|
|
2719
|
+
|
|
2720
|
+
export const providerNames = ${JSON.stringify(allProviders.map((p) => p.name))};
|
|
2721
|
+
|
|
2722
|
+
// Provider factories - dynamic imports for code splitting
|
|
2723
|
+
export const providerFactories = {
|
|
2724
|
+
${allProviders.map((p) => ` "${p.name}": async () => (await import("${p.package}")).${p.name},`).join("\n")}
|
|
2725
|
+
};
|
|
2528
2726
|
`;
|
|
2529
2727
|
}
|
|
2530
2728
|
if (id === RESOLVED_VIRTUAL_BUILDER_ID) {
|
|
@@ -2778,51 +2976,26 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
2778
2976
|
try {
|
|
2779
2977
|
const filePath = path3.join(modelsDir, file);
|
|
2780
2978
|
const content = fs4.readFileSync(filePath, "utf-8");
|
|
2781
|
-
const
|
|
2782
|
-
|
|
2783
|
-
const
|
|
2784
|
-
const getInputPrice = (c) => {
|
|
2785
|
-
const match = c.match(/inputPrice:\s*([\d.]+)/);
|
|
2786
|
-
return match ? parseFloat(match[1]) : void 0;
|
|
2787
|
-
};
|
|
2788
|
-
const getOutputPrice = (c) => {
|
|
2789
|
-
const match = c.match(/outputPrice:\s*([\d.]+)/);
|
|
2790
|
-
return match ? parseFloat(match[1]) : void 0;
|
|
2791
|
-
};
|
|
2792
|
-
const getCachedPrice = (c) => {
|
|
2793
|
-
const match = c.match(/cachedPrice:\s*([\d.]+)/);
|
|
2794
|
-
return match ? parseFloat(match[1]) : void 0;
|
|
2795
|
-
};
|
|
2796
|
-
const getIncludedProviders = (c) => {
|
|
2797
|
-
const match = c.match(/includedProviders:\s*\[([^\]]*)\]/);
|
|
2798
|
-
if (!match) return void 0;
|
|
2799
|
-
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
2800
|
-
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
2801
|
-
};
|
|
2802
|
-
const getFallbacks = (c) => {
|
|
2803
|
-
const match = c.match(/fallbacks:\s*\[([^\]]*)\]/);
|
|
2804
|
-
if (!match) return [];
|
|
2805
|
-
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
2806
|
-
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
2807
|
-
};
|
|
2808
|
-
const name = getName(content);
|
|
2809
|
-
if (!name) return null;
|
|
2810
|
-
const fallbacks = getFallbacks(content);
|
|
2811
|
-
const fallbackObjects = fallbacks.map((fallbackName, index) => ({
|
|
2979
|
+
const parsed = parseModelFile(content);
|
|
2980
|
+
if (!parsed || !parsed.name) return null;
|
|
2981
|
+
const fallbackObjects = parsed.fallbacks.map((fallbackName, index) => ({
|
|
2812
2982
|
id: fallbackName,
|
|
2813
2983
|
name: fallbackName,
|
|
2814
2984
|
order: index
|
|
2815
2985
|
}));
|
|
2816
2986
|
return {
|
|
2817
|
-
id: name,
|
|
2818
|
-
name,
|
|
2819
|
-
provider:
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2987
|
+
id: parsed.name,
|
|
2988
|
+
name: parsed.name,
|
|
2989
|
+
provider: parsed.provider,
|
|
2990
|
+
provider_id: parsed.provider,
|
|
2991
|
+
model: parsed.model,
|
|
2992
|
+
input_price: parsed.inputPrice,
|
|
2993
|
+
output_price: parsed.outputPrice,
|
|
2994
|
+
cached_price: parsed.cachedPrice,
|
|
2995
|
+
included_providers: parsed.includedProviders,
|
|
2825
2996
|
fallbacks: fallbackObjects,
|
|
2997
|
+
providerTools: parsed.providerTools,
|
|
2998
|
+
capabilities: parsed.capabilities,
|
|
2826
2999
|
created_at: Math.floor(Date.now() / 1e3)
|
|
2827
3000
|
};
|
|
2828
3001
|
} catch (error) {
|
|
@@ -2988,9 +3161,9 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
2988
3161
|
try {
|
|
2989
3162
|
const filePath = path3.join(promptsDir, file);
|
|
2990
3163
|
const content = fs4.readFileSync(filePath, "utf-8");
|
|
2991
|
-
const
|
|
3164
|
+
const getName2 = (c) => c.match(/name:\s*['"]([^'"]+)['"]/)?.[1];
|
|
2992
3165
|
const getToolDescription = (c) => c.match(/toolDescription:\s*['"]([^'"]+)['"]/)?.[1];
|
|
2993
|
-
const
|
|
3166
|
+
const getModel2 = (c) => c.match(/model:\s*['"]([^'"]+)['"]/)?.[1];
|
|
2994
3167
|
const getIncludeChat = (c) => c.match(/includeChat:\s*(true|false)/)?.[1] === "true";
|
|
2995
3168
|
const getIncludePastTools = (c) => c.match(/includePastTools:\s*(true|false)/)?.[1] === "true";
|
|
2996
3169
|
const getParallelToolCalls = (c) => c.match(/parallelToolCalls:\s*(true|false)/)?.[1] === "true";
|
|
@@ -3010,9 +3183,9 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3010
3183
|
if (arrayMatch) return arrayMatch[1];
|
|
3011
3184
|
return "";
|
|
3012
3185
|
};
|
|
3013
|
-
const name =
|
|
3186
|
+
const name = getName2(content);
|
|
3014
3187
|
if (!name) return null;
|
|
3015
|
-
const modelId =
|
|
3188
|
+
const modelId = getModel2(content);
|
|
3016
3189
|
const modelDef = modelId ? modelMap[modelId] : null;
|
|
3017
3190
|
return {
|
|
3018
3191
|
id: name,
|
|
@@ -3183,7 +3356,7 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3183
3356
|
try {
|
|
3184
3357
|
const filePath = path3.join(agentsDir, file);
|
|
3185
3358
|
const content = fs4.readFileSync(filePath, "utf-8");
|
|
3186
|
-
const
|
|
3359
|
+
const getName2 = (c) => c.match(/name:\s*['"]([^'"]+)['"]/)?.[1];
|
|
3187
3360
|
const getTitle = (c) => c.match(/title:\s*['"]([^'"]+)['"]/)?.[1];
|
|
3188
3361
|
const getType = (c) => c.match(/type:\s*['"]([^'"]+)['"]/)?.[1];
|
|
3189
3362
|
const getDefaultPrompt = (c) => c.match(/defaultPrompt:\s*['"]([^'"]+)['"]/)?.[1];
|
|
@@ -3194,7 +3367,14 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3194
3367
|
const items = match[1].match(/['"]([^'"]+)['"]/g);
|
|
3195
3368
|
return items ? items.map((s) => s.replace(/['"]/g, "")) : [];
|
|
3196
3369
|
};
|
|
3197
|
-
const
|
|
3370
|
+
const getSidePrompt = (c, side) => {
|
|
3371
|
+
const sideRegex = new RegExp(`${side}:\\s*\\{([^}]+)\\}`, "s");
|
|
3372
|
+
const sideMatch = c.match(sideRegex);
|
|
3373
|
+
if (!sideMatch) return null;
|
|
3374
|
+
const promptMatch = sideMatch[1].match(/prompt:\s*['"]([^'"]+)['"]/);
|
|
3375
|
+
return promptMatch ? promptMatch[1] : null;
|
|
3376
|
+
};
|
|
3377
|
+
const name = getName2(content);
|
|
3198
3378
|
if (!name) return null;
|
|
3199
3379
|
return {
|
|
3200
3380
|
id: name,
|
|
@@ -3204,6 +3384,8 @@ export class DurableAgentBuilder extends _BaseDurableAgentBuilder {
|
|
|
3204
3384
|
default_prompt: getDefaultPrompt(content) || "",
|
|
3205
3385
|
default_model: getDefaultModel(content) || "",
|
|
3206
3386
|
tools: getTools(content),
|
|
3387
|
+
side_a_agent_prompt: getSidePrompt(content, "sideA"),
|
|
3388
|
+
side_b_agent_prompt: getSidePrompt(content, "sideB"),
|
|
3207
3389
|
created_at: Math.floor(Date.now() / 1e3)
|
|
3208
3390
|
};
|
|
3209
3391
|
} catch (error) {
|