@standardagents/builder 0.12.5 → 0.12.7
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 +3792 -3710
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +93 -59
- package/dist/index.js.map +1 -1
- package/dist/packing.d.ts +3 -3
- package/dist/packing.js +67 -52
- package/dist/packing.js.map +1 -1
- package/dist/plugin.js +93 -59
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import fs2__default from 'fs';
|
|
|
7
7
|
import * as path8 from 'path';
|
|
8
8
|
import path8__default from 'path';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
|
-
import * as ts from 'typescript';
|
|
11
10
|
import MagicString from 'magic-string';
|
|
12
11
|
import { exec } from 'child_process';
|
|
13
12
|
import { promisify } from 'util';
|
|
@@ -10024,7 +10023,13 @@ var MetadataService = class {
|
|
|
10024
10023
|
return path8.join(this.metadataDir, `${agentName}.json`);
|
|
10025
10024
|
}
|
|
10026
10025
|
};
|
|
10027
|
-
|
|
10026
|
+
var _ts;
|
|
10027
|
+
async function loadTypeScript() {
|
|
10028
|
+
if (!_ts) _ts = await import('typescript');
|
|
10029
|
+
return _ts;
|
|
10030
|
+
}
|
|
10031
|
+
async function extractToolUses(sourceCode) {
|
|
10032
|
+
const ts = await loadTypeScript();
|
|
10028
10033
|
const sourceFile = ts.createSourceFile(
|
|
10029
10034
|
"tool.ts",
|
|
10030
10035
|
sourceCode,
|
|
@@ -10055,7 +10060,8 @@ function extractToolUses(sourceCode) {
|
|
|
10055
10060
|
visit(sourceFile);
|
|
10056
10061
|
return result;
|
|
10057
10062
|
}
|
|
10058
|
-
function extractPromptTools(sourceCode) {
|
|
10063
|
+
async function extractPromptTools(sourceCode) {
|
|
10064
|
+
const ts = await loadTypeScript();
|
|
10059
10065
|
const sourceFile = ts.createSourceFile(
|
|
10060
10066
|
"prompt.ts",
|
|
10061
10067
|
sourceCode,
|
|
@@ -10091,7 +10097,8 @@ function extractPromptTools(sourceCode) {
|
|
|
10091
10097
|
visit(sourceFile);
|
|
10092
10098
|
return result;
|
|
10093
10099
|
}
|
|
10094
|
-
function extractPromptModel(sourceCode) {
|
|
10100
|
+
async function extractPromptModel(sourceCode) {
|
|
10101
|
+
const ts = await loadTypeScript();
|
|
10095
10102
|
const sourceFile = ts.createSourceFile(
|
|
10096
10103
|
"prompt.ts",
|
|
10097
10104
|
sourceCode,
|
|
@@ -10113,7 +10120,8 @@ function extractPromptModel(sourceCode) {
|
|
|
10113
10120
|
visit(sourceFile);
|
|
10114
10121
|
return model;
|
|
10115
10122
|
}
|
|
10116
|
-
function extractPromptIncludes(sourceCode) {
|
|
10123
|
+
async function extractPromptIncludes(sourceCode) {
|
|
10124
|
+
const ts = await loadTypeScript();
|
|
10117
10125
|
const sourceFile = ts.createSourceFile(
|
|
10118
10126
|
"prompt.ts",
|
|
10119
10127
|
sourceCode,
|
|
@@ -10165,7 +10173,8 @@ function extractPromptIncludes(sourceCode) {
|
|
|
10165
10173
|
visit(sourceFile);
|
|
10166
10174
|
return includes;
|
|
10167
10175
|
}
|
|
10168
|
-
function extractAgentPrompts(sourceCode) {
|
|
10176
|
+
async function extractAgentPrompts(sourceCode) {
|
|
10177
|
+
const ts = await loadTypeScript();
|
|
10169
10178
|
const sourceFile = ts.createSourceFile(
|
|
10170
10179
|
"agent.ts",
|
|
10171
10180
|
sourceCode,
|
|
@@ -10200,7 +10209,8 @@ function extractAgentPrompts(sourceCode) {
|
|
|
10200
10209
|
visit(sourceFile);
|
|
10201
10210
|
return result;
|
|
10202
10211
|
}
|
|
10203
|
-
function extractAgentDescription(sourceCode) {
|
|
10212
|
+
async function extractAgentDescription(sourceCode) {
|
|
10213
|
+
const ts = await loadTypeScript();
|
|
10204
10214
|
const sourceFile = ts.createSourceFile(
|
|
10205
10215
|
"agent.ts",
|
|
10206
10216
|
sourceCode,
|
|
@@ -10222,7 +10232,8 @@ function extractAgentDescription(sourceCode) {
|
|
|
10222
10232
|
visit(sourceFile);
|
|
10223
10233
|
return description;
|
|
10224
10234
|
}
|
|
10225
|
-
function extractDefinitionName(sourceCode) {
|
|
10235
|
+
async function extractDefinitionName(sourceCode) {
|
|
10236
|
+
const ts = await loadTypeScript();
|
|
10226
10237
|
const sourceFile = ts.createSourceFile(
|
|
10227
10238
|
"def.ts",
|
|
10228
10239
|
sourceCode,
|
|
@@ -10244,7 +10255,8 @@ function extractDefinitionName(sourceCode) {
|
|
|
10244
10255
|
visit(sourceFile);
|
|
10245
10256
|
return name;
|
|
10246
10257
|
}
|
|
10247
|
-
function extractModelFallbacks(sourceCode) {
|
|
10258
|
+
async function extractModelFallbacks(sourceCode) {
|
|
10259
|
+
const ts = await loadTypeScript();
|
|
10248
10260
|
const sourceFile = ts.createSourceFile(
|
|
10249
10261
|
"model.ts",
|
|
10250
10262
|
sourceCode,
|
|
@@ -10270,7 +10282,8 @@ function extractModelFallbacks(sourceCode) {
|
|
|
10270
10282
|
visit(sourceFile);
|
|
10271
10283
|
return fallbacks;
|
|
10272
10284
|
}
|
|
10273
|
-
function transformBundledJs(code) {
|
|
10285
|
+
async function transformBundledJs(code) {
|
|
10286
|
+
const ts = await loadTypeScript();
|
|
10274
10287
|
const s = new MagicString(code);
|
|
10275
10288
|
const sourceFile = ts.createSourceFile(
|
|
10276
10289
|
"file.js",
|
|
@@ -10316,10 +10329,11 @@ function transformBundledJs(code) {
|
|
|
10316
10329
|
}
|
|
10317
10330
|
return s.toString().trim() + "\n";
|
|
10318
10331
|
}
|
|
10319
|
-
function injectAgentMetadata(tsCode, metadata) {
|
|
10332
|
+
async function injectAgentMetadata(tsCode, metadata) {
|
|
10320
10333
|
if (!metadata.packageName && !metadata.version && !metadata.author && !metadata.license) {
|
|
10321
10334
|
return tsCode;
|
|
10322
10335
|
}
|
|
10336
|
+
const ts = await loadTypeScript();
|
|
10323
10337
|
const s = new MagicString(tsCode);
|
|
10324
10338
|
const sourceFile = ts.createSourceFile(
|
|
10325
10339
|
"agent.ts",
|
|
@@ -10417,7 +10431,7 @@ var PackingService = class {
|
|
|
10417
10431
|
warnings: [],
|
|
10418
10432
|
errors: []
|
|
10419
10433
|
};
|
|
10420
|
-
const agentFilePath = this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10434
|
+
const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10421
10435
|
if (!agentFilePath) {
|
|
10422
10436
|
analysis.errors.push(`Agent file not found: ${agentName}`);
|
|
10423
10437
|
return analysis;
|
|
@@ -10429,7 +10443,7 @@ var PackingService = class {
|
|
|
10429
10443
|
sharedWith: []
|
|
10430
10444
|
});
|
|
10431
10445
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
10432
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
10446
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
10433
10447
|
if (agentPrompts.sideA) {
|
|
10434
10448
|
analysis.primaryPrompt = agentPrompts.sideA;
|
|
10435
10449
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, /* @__PURE__ */ new Set(), `agent:${agentName}`);
|
|
@@ -10450,7 +10464,7 @@ var PackingService = class {
|
|
|
10450
10464
|
* @param rootDir - Root directory of the project
|
|
10451
10465
|
* @returns Object with generatedReadme and agentDescription
|
|
10452
10466
|
*/
|
|
10453
|
-
generateReadmeForAnalysis(analysis, rootDir) {
|
|
10467
|
+
async generateReadmeForAnalysis(analysis, rootDir) {
|
|
10454
10468
|
const agentsDir = path8.join(rootDir, "agents");
|
|
10455
10469
|
const metadataService = new MetadataService(agentsDir);
|
|
10456
10470
|
let agentDescription;
|
|
@@ -10458,7 +10472,7 @@ var PackingService = class {
|
|
|
10458
10472
|
if (agentItem?.filePath) {
|
|
10459
10473
|
try {
|
|
10460
10474
|
const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
|
|
10461
|
-
agentDescription = extractAgentDescription(agentSource) || void 0;
|
|
10475
|
+
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
10462
10476
|
} catch {
|
|
10463
10477
|
}
|
|
10464
10478
|
}
|
|
@@ -10478,7 +10492,7 @@ var PackingService = class {
|
|
|
10478
10492
|
* Recursively analyze a prompt and its dependencies.
|
|
10479
10493
|
*/
|
|
10480
10494
|
async analyzePrompt(promptName, agentsDir, analysis, visited, parentKey) {
|
|
10481
|
-
const promptFilePath = this.findFile(path8.join(agentsDir, "prompts"), promptName);
|
|
10495
|
+
const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), promptName);
|
|
10482
10496
|
if (!promptFilePath) {
|
|
10483
10497
|
analysis.warnings.push(`Prompt file not found: ${promptName}`);
|
|
10484
10498
|
return;
|
|
@@ -10498,15 +10512,15 @@ var PackingService = class {
|
|
|
10498
10512
|
}
|
|
10499
10513
|
visited.add(`prompt:${promptName}`);
|
|
10500
10514
|
const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
|
|
10501
|
-
const modelName = extractPromptModel(promptSource);
|
|
10515
|
+
const modelName = await extractPromptModel(promptSource);
|
|
10502
10516
|
if (modelName) {
|
|
10503
10517
|
await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
|
|
10504
10518
|
}
|
|
10505
|
-
const { tools: toolNames } = extractPromptTools(promptSource);
|
|
10519
|
+
const { tools: toolNames } = await extractPromptTools(promptSource);
|
|
10506
10520
|
for (const toolName of toolNames) {
|
|
10507
10521
|
await this.analyzeTool(toolName, agentsDir, analysis, visited, "prompt-tools", thisKey);
|
|
10508
10522
|
}
|
|
10509
|
-
const includedPrompts = extractPromptIncludes(promptSource);
|
|
10523
|
+
const includedPrompts = await extractPromptIncludes(promptSource);
|
|
10510
10524
|
for (const includedPrompt of includedPrompts) {
|
|
10511
10525
|
const item = analysis.constituents.prompts.find((p) => p.name === includedPrompt);
|
|
10512
10526
|
if (item) {
|
|
@@ -10523,17 +10537,17 @@ var PackingService = class {
|
|
|
10523
10537
|
*/
|
|
10524
10538
|
async analyzeTool(toolName, agentsDir, analysis, visited, discoveredVia, parentKey) {
|
|
10525
10539
|
const thisKey = `tool:${toolName}`;
|
|
10526
|
-
const promptFilePath = this.findFile(path8.join(agentsDir, "prompts"), toolName);
|
|
10540
|
+
const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), toolName);
|
|
10527
10541
|
if (promptFilePath) {
|
|
10528
10542
|
await this.analyzePrompt(toolName, agentsDir, analysis, visited, parentKey);
|
|
10529
10543
|
return;
|
|
10530
10544
|
}
|
|
10531
|
-
const agentFilePath = this.findFile(path8.join(agentsDir, "agents"), toolName);
|
|
10545
|
+
const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), toolName);
|
|
10532
10546
|
if (agentFilePath) {
|
|
10533
10547
|
await this.analyzeNestedAgent(toolName, agentsDir, analysis, visited, parentKey);
|
|
10534
10548
|
return;
|
|
10535
10549
|
}
|
|
10536
|
-
const toolFilePath = this.findFile(path8.join(agentsDir, "tools"), toolName);
|
|
10550
|
+
const toolFilePath = await this.findFile(path8.join(agentsDir, "tools"), toolName);
|
|
10537
10551
|
if (!toolFilePath) {
|
|
10538
10552
|
analysis.warnings.push(`Tool file not found: ${toolName}`);
|
|
10539
10553
|
return;
|
|
@@ -10552,7 +10566,7 @@ var PackingService = class {
|
|
|
10552
10566
|
}
|
|
10553
10567
|
visited.add(`tool:${toolName}`);
|
|
10554
10568
|
const toolSource = fs2.readFileSync(toolFilePath, "utf-8");
|
|
10555
|
-
const { uses } = extractToolUses(toolSource);
|
|
10569
|
+
const { uses } = await extractToolUses(toolSource);
|
|
10556
10570
|
for (const usedItem of uses) {
|
|
10557
10571
|
await this.analyzeTool(usedItem, agentsDir, analysis, visited, "uses", thisKey);
|
|
10558
10572
|
}
|
|
@@ -10561,7 +10575,7 @@ var PackingService = class {
|
|
|
10561
10575
|
* Analyze a nested agent (used as a handoff target).
|
|
10562
10576
|
*/
|
|
10563
10577
|
async analyzeNestedAgent(agentName, agentsDir, analysis, visited, parentKey) {
|
|
10564
|
-
const agentFilePath = this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10578
|
+
const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10565
10579
|
if (!agentFilePath) {
|
|
10566
10580
|
analysis.warnings.push(`Agent file not found: ${agentName}`);
|
|
10567
10581
|
return;
|
|
@@ -10581,7 +10595,7 @@ var PackingService = class {
|
|
|
10581
10595
|
}
|
|
10582
10596
|
visited.add(`agent:${agentName}`);
|
|
10583
10597
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
10584
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
10598
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
10585
10599
|
if (agentPrompts.sideA) {
|
|
10586
10600
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
|
|
10587
10601
|
}
|
|
@@ -10593,7 +10607,7 @@ var PackingService = class {
|
|
|
10593
10607
|
* Analyze a model and its fallbacks.
|
|
10594
10608
|
*/
|
|
10595
10609
|
async analyzeModel(modelName, agentsDir, analysis, visited, parentKey) {
|
|
10596
|
-
const modelFilePath = this.findFile(path8.join(agentsDir, "models"), modelName);
|
|
10610
|
+
const modelFilePath = await this.findFile(path8.join(agentsDir, "models"), modelName);
|
|
10597
10611
|
if (!modelFilePath) {
|
|
10598
10612
|
analysis.warnings.push(`Model file not found: ${modelName}`);
|
|
10599
10613
|
return;
|
|
@@ -10613,7 +10627,7 @@ var PackingService = class {
|
|
|
10613
10627
|
}
|
|
10614
10628
|
visited.add(`model:${modelName}`);
|
|
10615
10629
|
const modelSource = fs2.readFileSync(modelFilePath, "utf-8");
|
|
10616
|
-
const fallbacks = extractModelFallbacks(modelSource);
|
|
10630
|
+
const fallbacks = await extractModelFallbacks(modelSource);
|
|
10617
10631
|
for (const fallbackName of fallbacks) {
|
|
10618
10632
|
await this.analyzeModel(fallbackName, agentsDir, analysis, visited, thisKey);
|
|
10619
10633
|
}
|
|
@@ -10662,34 +10676,34 @@ var PackingService = class {
|
|
|
10662
10676
|
const result = { prompts: [], tools: [], models: [] };
|
|
10663
10677
|
const agentsDir = path8.join(rootDir, "agents");
|
|
10664
10678
|
const visited = /* @__PURE__ */ new Set();
|
|
10665
|
-
const agentFilePath = this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10679
|
+
const agentFilePath = await this.findFile(path8.join(agentsDir, "agents"), agentName);
|
|
10666
10680
|
if (!agentFilePath) return result;
|
|
10667
10681
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
10668
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
10669
|
-
const analyzePromptLight = (promptName) => {
|
|
10682
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
10683
|
+
const analyzePromptLight = async (promptName) => {
|
|
10670
10684
|
if (visited.has(promptName)) return;
|
|
10671
10685
|
visited.add(promptName);
|
|
10672
10686
|
result.prompts.push(promptName);
|
|
10673
|
-
const promptFilePath = this.findFile(path8.join(agentsDir, "prompts"), promptName);
|
|
10687
|
+
const promptFilePath = await this.findFile(path8.join(agentsDir, "prompts"), promptName);
|
|
10674
10688
|
if (!promptFilePath) return;
|
|
10675
10689
|
const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
|
|
10676
|
-
const modelName = extractPromptModel(promptSource);
|
|
10690
|
+
const modelName = await extractPromptModel(promptSource);
|
|
10677
10691
|
if (modelName && !result.models.includes(modelName)) {
|
|
10678
10692
|
result.models.push(modelName);
|
|
10679
10693
|
}
|
|
10680
|
-
const { tools } = extractPromptTools(promptSource);
|
|
10694
|
+
const { tools } = await extractPromptTools(promptSource);
|
|
10681
10695
|
for (const tool of tools) {
|
|
10682
10696
|
if (!result.tools.includes(tool)) {
|
|
10683
10697
|
result.tools.push(tool);
|
|
10684
10698
|
}
|
|
10685
10699
|
}
|
|
10686
|
-
const includes = extractPromptIncludes(promptSource);
|
|
10700
|
+
const includes = await extractPromptIncludes(promptSource);
|
|
10687
10701
|
for (const inc of includes) {
|
|
10688
|
-
analyzePromptLight(inc);
|
|
10702
|
+
await analyzePromptLight(inc);
|
|
10689
10703
|
}
|
|
10690
10704
|
};
|
|
10691
|
-
if (agentPrompts.sideA) analyzePromptLight(agentPrompts.sideA);
|
|
10692
|
-
if (agentPrompts.sideB) analyzePromptLight(agentPrompts.sideB);
|
|
10705
|
+
if (agentPrompts.sideA) await analyzePromptLight(agentPrompts.sideA);
|
|
10706
|
+
if (agentPrompts.sideB) await analyzePromptLight(agentPrompts.sideB);
|
|
10693
10707
|
return result;
|
|
10694
10708
|
}
|
|
10695
10709
|
/**
|
|
@@ -10834,7 +10848,7 @@ var PackingService = class {
|
|
|
10834
10848
|
let agentDescription;
|
|
10835
10849
|
if (agentItem?.filePath) {
|
|
10836
10850
|
const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
|
|
10837
|
-
agentDescription = extractAgentDescription(agentSource) || void 0;
|
|
10851
|
+
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
10838
10852
|
}
|
|
10839
10853
|
readmeContent = this.generateReadme(
|
|
10840
10854
|
finalPackageName,
|
|
@@ -11434,7 +11448,7 @@ ${license || "See LICENSE file"}
|
|
|
11434
11448
|
/**
|
|
11435
11449
|
* Find a file by name in a directory.
|
|
11436
11450
|
*/
|
|
11437
|
-
findFile(dir, name) {
|
|
11451
|
+
async findFile(dir, name) {
|
|
11438
11452
|
if (!fs2.existsSync(dir)) {
|
|
11439
11453
|
return null;
|
|
11440
11454
|
}
|
|
@@ -11446,7 +11460,7 @@ ${license || "See LICENSE file"}
|
|
|
11446
11460
|
for (const file of files) {
|
|
11447
11461
|
const filePath = path8.join(dir, file);
|
|
11448
11462
|
const source = fs2.readFileSync(filePath, "utf-8");
|
|
11449
|
-
const extractedName = extractDefinitionName(source);
|
|
11463
|
+
const extractedName = await extractDefinitionName(source);
|
|
11450
11464
|
if (extractedName === name) {
|
|
11451
11465
|
return filePath;
|
|
11452
11466
|
}
|
|
@@ -11456,7 +11470,7 @@ ${license || "See LICENSE file"}
|
|
|
11456
11470
|
/**
|
|
11457
11471
|
* List all agents in the workspace.
|
|
11458
11472
|
*/
|
|
11459
|
-
listAgents(rootDir) {
|
|
11473
|
+
async listAgents(rootDir) {
|
|
11460
11474
|
const agentsDir = path8.join(rootDir, "agents", "agents");
|
|
11461
11475
|
if (!fs2.existsSync(agentsDir)) {
|
|
11462
11476
|
return [];
|
|
@@ -11466,7 +11480,7 @@ ${license || "See LICENSE file"}
|
|
|
11466
11480
|
for (const file of files) {
|
|
11467
11481
|
const filePath = path8.join(agentsDir, file);
|
|
11468
11482
|
const source = fs2.readFileSync(filePath, "utf-8");
|
|
11469
|
-
const name = extractDefinitionName(source);
|
|
11483
|
+
const name = await extractDefinitionName(source);
|
|
11470
11484
|
if (name) {
|
|
11471
11485
|
agents.push(name);
|
|
11472
11486
|
} else {
|
|
@@ -11734,7 +11748,7 @@ var UnpackingService = class {
|
|
|
11734
11748
|
return analysis;
|
|
11735
11749
|
}
|
|
11736
11750
|
const indexContent = fs2.readFileSync(indexPath, "utf-8");
|
|
11737
|
-
const registryItems = this.parseIndexExports(indexContent);
|
|
11751
|
+
const registryItems = await this.parseIndexExports(indexContent);
|
|
11738
11752
|
const availableItems = /* @__PURE__ */ new Map();
|
|
11739
11753
|
for (const item of registryItems) {
|
|
11740
11754
|
availableItems.set(`${item.type}:${item.name}`, item);
|
|
@@ -11751,7 +11765,7 @@ var UnpackingService = class {
|
|
|
11751
11765
|
continue;
|
|
11752
11766
|
}
|
|
11753
11767
|
const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
|
|
11754
|
-
const children = this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
|
|
11768
|
+
const children = await this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
|
|
11755
11769
|
itemsWithRelations.push({
|
|
11756
11770
|
name: item.name,
|
|
11757
11771
|
type: item.type,
|
|
@@ -11792,10 +11806,10 @@ var UnpackingService = class {
|
|
|
11792
11806
|
* Discover relationships from a bundled file.
|
|
11793
11807
|
* Returns child items that this item references.
|
|
11794
11808
|
*/
|
|
11795
|
-
discoverRelationships(type, name, bundledCode, availableItems) {
|
|
11809
|
+
async discoverRelationships(type, name, bundledCode, availableItems) {
|
|
11796
11810
|
const children = [];
|
|
11797
11811
|
if (type === "agent") {
|
|
11798
|
-
const prompts = extractAgentPrompts(bundledCode);
|
|
11812
|
+
const prompts = await extractAgentPrompts(bundledCode);
|
|
11799
11813
|
if (prompts.sideA && availableItems.has(`prompt:${prompts.sideA}`)) {
|
|
11800
11814
|
children.push({ type: "prompt", name: prompts.sideA });
|
|
11801
11815
|
}
|
|
@@ -11803,7 +11817,7 @@ var UnpackingService = class {
|
|
|
11803
11817
|
children.push({ type: "prompt", name: prompts.sideB });
|
|
11804
11818
|
}
|
|
11805
11819
|
} else if (type === "prompt") {
|
|
11806
|
-
const toolsResult = extractPromptTools(bundledCode);
|
|
11820
|
+
const toolsResult = await extractPromptTools(bundledCode);
|
|
11807
11821
|
for (const toolName of toolsResult.tools) {
|
|
11808
11822
|
if (availableItems.has(`tool:${toolName}`)) {
|
|
11809
11823
|
children.push({ type: "tool", name: toolName });
|
|
@@ -11811,12 +11825,12 @@ var UnpackingService = class {
|
|
|
11811
11825
|
children.push({ type: "agent", name: toolName });
|
|
11812
11826
|
}
|
|
11813
11827
|
}
|
|
11814
|
-
const model = extractPromptModel(bundledCode);
|
|
11828
|
+
const model = await extractPromptModel(bundledCode);
|
|
11815
11829
|
if (model && availableItems.has(`model:${model}`)) {
|
|
11816
11830
|
children.push({ type: "model", name: model });
|
|
11817
11831
|
}
|
|
11818
11832
|
} else if (type === "tool") {
|
|
11819
|
-
const usesResult = extractToolUses(bundledCode);
|
|
11833
|
+
const usesResult = await extractToolUses(bundledCode);
|
|
11820
11834
|
for (const useName of usesResult.uses) {
|
|
11821
11835
|
const colonIndex = useName.indexOf(":");
|
|
11822
11836
|
if (colonIndex > 0) {
|
|
@@ -11894,9 +11908,9 @@ var UnpackingService = class {
|
|
|
11894
11908
|
try {
|
|
11895
11909
|
const sourcePath = path8.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
|
|
11896
11910
|
const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
|
|
11897
|
-
let tsCode = transformBundledJs(bundledCode);
|
|
11911
|
+
let tsCode = await transformBundledJs(bundledCode);
|
|
11898
11912
|
if (item.type === "agent") {
|
|
11899
|
-
tsCode = injectAgentMetadata(tsCode, agentMetadata);
|
|
11913
|
+
tsCode = await injectAgentMetadata(tsCode, agentMetadata);
|
|
11900
11914
|
}
|
|
11901
11915
|
const dir = path8.dirname(item.targetPath);
|
|
11902
11916
|
if (!fs2.existsSync(dir)) {
|
|
@@ -11938,7 +11952,8 @@ var UnpackingService = class {
|
|
|
11938
11952
|
* };
|
|
11939
11953
|
* ```
|
|
11940
11954
|
*/
|
|
11941
|
-
parseIndexExports(indexContent) {
|
|
11955
|
+
async parseIndexExports(indexContent) {
|
|
11956
|
+
const ts = await loadTypeScript();
|
|
11942
11957
|
const sourceFile = ts.createSourceFile(
|
|
11943
11958
|
"index.js",
|
|
11944
11959
|
indexContent,
|
|
@@ -12887,10 +12902,19 @@ function agentbuilder(options = {}) {
|
|
|
12887
12902
|
publicDir: fs2__default.existsSync(builderClientDir) ? builderClientDir : void 0,
|
|
12888
12903
|
build: {
|
|
12889
12904
|
rollupOptions: {
|
|
12890
|
-
//
|
|
12891
|
-
//
|
|
12892
|
-
//
|
|
12893
|
-
|
|
12905
|
+
// The packing system dynamically imports rollup, typescript, and related
|
|
12906
|
+
// plugins for the CLI `pack` command. These are never needed at runtime
|
|
12907
|
+
// in Cloudflare Workers and must be externalized:
|
|
12908
|
+
// - rollup/typescript/fsevents contain Node.js-only APIs (__filename, fs)
|
|
12909
|
+
// - fsevents is macOS-only and doesn't exist on Linux CI
|
|
12910
|
+
external: [
|
|
12911
|
+
"rollup",
|
|
12912
|
+
"@rollup/plugin-commonjs",
|
|
12913
|
+
"@rollup/plugin-node-resolve",
|
|
12914
|
+
"rollup-plugin-esbuild",
|
|
12915
|
+
"fsevents",
|
|
12916
|
+
"typescript"
|
|
12917
|
+
]
|
|
12894
12918
|
}
|
|
12895
12919
|
},
|
|
12896
12920
|
optimizeDeps: {
|
|
@@ -12958,15 +12982,25 @@ function agentbuilder(options = {}) {
|
|
|
12958
12982
|
...config.optimizeDeps.include || [],
|
|
12959
12983
|
...depsToInclude.filter((dep) => !config.optimizeDeps?.include?.includes(dep))
|
|
12960
12984
|
];
|
|
12985
|
+
const packingDeps = [
|
|
12986
|
+
"rollup",
|
|
12987
|
+
"@rollup/plugin-commonjs",
|
|
12988
|
+
"@rollup/plugin-node-resolve",
|
|
12989
|
+
"rollup-plugin-esbuild",
|
|
12990
|
+
"fsevents",
|
|
12991
|
+
"typescript"
|
|
12992
|
+
];
|
|
12961
12993
|
config.build = config.build || {};
|
|
12962
12994
|
config.build.rollupOptions = config.build.rollupOptions || {};
|
|
12963
12995
|
const existing = config.build.rollupOptions.external;
|
|
12964
12996
|
if (Array.isArray(existing)) {
|
|
12965
|
-
|
|
12997
|
+
for (const dep of packingDeps) {
|
|
12998
|
+
if (!existing.includes(dep)) existing.push(dep);
|
|
12999
|
+
}
|
|
12966
13000
|
} else if (typeof existing === "string") {
|
|
12967
|
-
config.build.rollupOptions.external = [existing,
|
|
13001
|
+
config.build.rollupOptions.external = [existing, ...packingDeps];
|
|
12968
13002
|
} else if (!existing) {
|
|
12969
|
-
config.build.rollupOptions.external = [
|
|
13003
|
+
config.build.rollupOptions.external = [...packingDeps];
|
|
12970
13004
|
}
|
|
12971
13005
|
},
|
|
12972
13006
|
resolveId(id) {
|