@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/packing.d.ts
CHANGED
|
@@ -53,10 +53,10 @@ declare class PackingService {
|
|
|
53
53
|
* @param rootDir - Root directory of the project
|
|
54
54
|
* @returns Object with generatedReadme and agentDescription
|
|
55
55
|
*/
|
|
56
|
-
generateReadmeForAnalysis(analysis: PackingAnalysis, rootDir: string): {
|
|
56
|
+
generateReadmeForAnalysis(analysis: PackingAnalysis, rootDir: string): Promise<{
|
|
57
57
|
generatedReadme: string;
|
|
58
58
|
agentDescription?: string;
|
|
59
|
-
}
|
|
59
|
+
}>;
|
|
60
60
|
/**
|
|
61
61
|
* Recursively analyze a prompt and its dependencies.
|
|
62
62
|
*/
|
|
@@ -183,7 +183,7 @@ declare class PackingService {
|
|
|
183
183
|
/**
|
|
184
184
|
* List all agents in the workspace.
|
|
185
185
|
*/
|
|
186
|
-
listAgents(rootDir: string): string[]
|
|
186
|
+
listAgents(rootDir: string): Promise<string[]>;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/**
|
package/dist/packing.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as fs2 from 'fs';
|
|
2
2
|
import * as path2 from 'path';
|
|
3
|
-
import * as ts from 'typescript';
|
|
4
3
|
import MagicString from 'magic-string';
|
|
5
4
|
|
|
6
5
|
// src/packing/packing-service.ts
|
|
@@ -137,7 +136,13 @@ var MetadataService = class {
|
|
|
137
136
|
return path2.join(this.metadataDir, `${agentName}.json`);
|
|
138
137
|
}
|
|
139
138
|
};
|
|
140
|
-
|
|
139
|
+
var _ts;
|
|
140
|
+
async function loadTypeScript() {
|
|
141
|
+
if (!_ts) _ts = await import('typescript');
|
|
142
|
+
return _ts;
|
|
143
|
+
}
|
|
144
|
+
async function extractToolUses(sourceCode) {
|
|
145
|
+
const ts = await loadTypeScript();
|
|
141
146
|
const sourceFile = ts.createSourceFile(
|
|
142
147
|
"tool.ts",
|
|
143
148
|
sourceCode,
|
|
@@ -168,7 +173,8 @@ function extractToolUses(sourceCode) {
|
|
|
168
173
|
visit(sourceFile);
|
|
169
174
|
return result;
|
|
170
175
|
}
|
|
171
|
-
function extractPromptTools(sourceCode) {
|
|
176
|
+
async function extractPromptTools(sourceCode) {
|
|
177
|
+
const ts = await loadTypeScript();
|
|
172
178
|
const sourceFile = ts.createSourceFile(
|
|
173
179
|
"prompt.ts",
|
|
174
180
|
sourceCode,
|
|
@@ -204,7 +210,8 @@ function extractPromptTools(sourceCode) {
|
|
|
204
210
|
visit(sourceFile);
|
|
205
211
|
return result;
|
|
206
212
|
}
|
|
207
|
-
function extractPromptModel(sourceCode) {
|
|
213
|
+
async function extractPromptModel(sourceCode) {
|
|
214
|
+
const ts = await loadTypeScript();
|
|
208
215
|
const sourceFile = ts.createSourceFile(
|
|
209
216
|
"prompt.ts",
|
|
210
217
|
sourceCode,
|
|
@@ -226,7 +233,8 @@ function extractPromptModel(sourceCode) {
|
|
|
226
233
|
visit(sourceFile);
|
|
227
234
|
return model;
|
|
228
235
|
}
|
|
229
|
-
function extractPromptIncludes(sourceCode) {
|
|
236
|
+
async function extractPromptIncludes(sourceCode) {
|
|
237
|
+
const ts = await loadTypeScript();
|
|
230
238
|
const sourceFile = ts.createSourceFile(
|
|
231
239
|
"prompt.ts",
|
|
232
240
|
sourceCode,
|
|
@@ -278,7 +286,8 @@ function extractPromptIncludes(sourceCode) {
|
|
|
278
286
|
visit(sourceFile);
|
|
279
287
|
return includes;
|
|
280
288
|
}
|
|
281
|
-
function extractAgentPrompts(sourceCode) {
|
|
289
|
+
async function extractAgentPrompts(sourceCode) {
|
|
290
|
+
const ts = await loadTypeScript();
|
|
282
291
|
const sourceFile = ts.createSourceFile(
|
|
283
292
|
"agent.ts",
|
|
284
293
|
sourceCode,
|
|
@@ -313,7 +322,8 @@ function extractAgentPrompts(sourceCode) {
|
|
|
313
322
|
visit(sourceFile);
|
|
314
323
|
return result;
|
|
315
324
|
}
|
|
316
|
-
function extractAgentDescription(sourceCode) {
|
|
325
|
+
async function extractAgentDescription(sourceCode) {
|
|
326
|
+
const ts = await loadTypeScript();
|
|
317
327
|
const sourceFile = ts.createSourceFile(
|
|
318
328
|
"agent.ts",
|
|
319
329
|
sourceCode,
|
|
@@ -335,7 +345,8 @@ function extractAgentDescription(sourceCode) {
|
|
|
335
345
|
visit(sourceFile);
|
|
336
346
|
return description;
|
|
337
347
|
}
|
|
338
|
-
function extractDefinitionName(sourceCode) {
|
|
348
|
+
async function extractDefinitionName(sourceCode) {
|
|
349
|
+
const ts = await loadTypeScript();
|
|
339
350
|
const sourceFile = ts.createSourceFile(
|
|
340
351
|
"def.ts",
|
|
341
352
|
sourceCode,
|
|
@@ -357,7 +368,8 @@ function extractDefinitionName(sourceCode) {
|
|
|
357
368
|
visit(sourceFile);
|
|
358
369
|
return name;
|
|
359
370
|
}
|
|
360
|
-
function extractModelFallbacks(sourceCode) {
|
|
371
|
+
async function extractModelFallbacks(sourceCode) {
|
|
372
|
+
const ts = await loadTypeScript();
|
|
361
373
|
const sourceFile = ts.createSourceFile(
|
|
362
374
|
"model.ts",
|
|
363
375
|
sourceCode,
|
|
@@ -383,7 +395,8 @@ function extractModelFallbacks(sourceCode) {
|
|
|
383
395
|
visit(sourceFile);
|
|
384
396
|
return fallbacks;
|
|
385
397
|
}
|
|
386
|
-
function transformBundledJs(code) {
|
|
398
|
+
async function transformBundledJs(code) {
|
|
399
|
+
const ts = await loadTypeScript();
|
|
387
400
|
const s = new MagicString(code);
|
|
388
401
|
const sourceFile = ts.createSourceFile(
|
|
389
402
|
"file.js",
|
|
@@ -429,10 +442,11 @@ function transformBundledJs(code) {
|
|
|
429
442
|
}
|
|
430
443
|
return s.toString().trim() + "\n";
|
|
431
444
|
}
|
|
432
|
-
function injectAgentMetadata(tsCode, metadata) {
|
|
445
|
+
async function injectAgentMetadata(tsCode, metadata) {
|
|
433
446
|
if (!metadata.packageName && !metadata.version && !metadata.author && !metadata.license) {
|
|
434
447
|
return tsCode;
|
|
435
448
|
}
|
|
449
|
+
const ts = await loadTypeScript();
|
|
436
450
|
const s = new MagicString(tsCode);
|
|
437
451
|
const sourceFile = ts.createSourceFile(
|
|
438
452
|
"agent.ts",
|
|
@@ -530,7 +544,7 @@ var PackingService = class {
|
|
|
530
544
|
warnings: [],
|
|
531
545
|
errors: []
|
|
532
546
|
};
|
|
533
|
-
const agentFilePath = this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
547
|
+
const agentFilePath = await this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
534
548
|
if (!agentFilePath) {
|
|
535
549
|
analysis.errors.push(`Agent file not found: ${agentName}`);
|
|
536
550
|
return analysis;
|
|
@@ -542,7 +556,7 @@ var PackingService = class {
|
|
|
542
556
|
sharedWith: []
|
|
543
557
|
});
|
|
544
558
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
545
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
559
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
546
560
|
if (agentPrompts.sideA) {
|
|
547
561
|
analysis.primaryPrompt = agentPrompts.sideA;
|
|
548
562
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, /* @__PURE__ */ new Set(), `agent:${agentName}`);
|
|
@@ -563,7 +577,7 @@ var PackingService = class {
|
|
|
563
577
|
* @param rootDir - Root directory of the project
|
|
564
578
|
* @returns Object with generatedReadme and agentDescription
|
|
565
579
|
*/
|
|
566
|
-
generateReadmeForAnalysis(analysis, rootDir) {
|
|
580
|
+
async generateReadmeForAnalysis(analysis, rootDir) {
|
|
567
581
|
const agentsDir = path2.join(rootDir, "agents");
|
|
568
582
|
const metadataService = new MetadataService(agentsDir);
|
|
569
583
|
let agentDescription;
|
|
@@ -571,7 +585,7 @@ var PackingService = class {
|
|
|
571
585
|
if (agentItem?.filePath) {
|
|
572
586
|
try {
|
|
573
587
|
const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
|
|
574
|
-
agentDescription = extractAgentDescription(agentSource) || void 0;
|
|
588
|
+
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
575
589
|
} catch {
|
|
576
590
|
}
|
|
577
591
|
}
|
|
@@ -591,7 +605,7 @@ var PackingService = class {
|
|
|
591
605
|
* Recursively analyze a prompt and its dependencies.
|
|
592
606
|
*/
|
|
593
607
|
async analyzePrompt(promptName, agentsDir, analysis, visited, parentKey) {
|
|
594
|
-
const promptFilePath = this.findFile(path2.join(agentsDir, "prompts"), promptName);
|
|
608
|
+
const promptFilePath = await this.findFile(path2.join(agentsDir, "prompts"), promptName);
|
|
595
609
|
if (!promptFilePath) {
|
|
596
610
|
analysis.warnings.push(`Prompt file not found: ${promptName}`);
|
|
597
611
|
return;
|
|
@@ -611,15 +625,15 @@ var PackingService = class {
|
|
|
611
625
|
}
|
|
612
626
|
visited.add(`prompt:${promptName}`);
|
|
613
627
|
const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
|
|
614
|
-
const modelName = extractPromptModel(promptSource);
|
|
628
|
+
const modelName = await extractPromptModel(promptSource);
|
|
615
629
|
if (modelName) {
|
|
616
630
|
await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
|
|
617
631
|
}
|
|
618
|
-
const { tools: toolNames } = extractPromptTools(promptSource);
|
|
632
|
+
const { tools: toolNames } = await extractPromptTools(promptSource);
|
|
619
633
|
for (const toolName of toolNames) {
|
|
620
634
|
await this.analyzeTool(toolName, agentsDir, analysis, visited, "prompt-tools", thisKey);
|
|
621
635
|
}
|
|
622
|
-
const includedPrompts = extractPromptIncludes(promptSource);
|
|
636
|
+
const includedPrompts = await extractPromptIncludes(promptSource);
|
|
623
637
|
for (const includedPrompt of includedPrompts) {
|
|
624
638
|
const item = analysis.constituents.prompts.find((p) => p.name === includedPrompt);
|
|
625
639
|
if (item) {
|
|
@@ -636,17 +650,17 @@ var PackingService = class {
|
|
|
636
650
|
*/
|
|
637
651
|
async analyzeTool(toolName, agentsDir, analysis, visited, discoveredVia, parentKey) {
|
|
638
652
|
const thisKey = `tool:${toolName}`;
|
|
639
|
-
const promptFilePath = this.findFile(path2.join(agentsDir, "prompts"), toolName);
|
|
653
|
+
const promptFilePath = await this.findFile(path2.join(agentsDir, "prompts"), toolName);
|
|
640
654
|
if (promptFilePath) {
|
|
641
655
|
await this.analyzePrompt(toolName, agentsDir, analysis, visited, parentKey);
|
|
642
656
|
return;
|
|
643
657
|
}
|
|
644
|
-
const agentFilePath = this.findFile(path2.join(agentsDir, "agents"), toolName);
|
|
658
|
+
const agentFilePath = await this.findFile(path2.join(agentsDir, "agents"), toolName);
|
|
645
659
|
if (agentFilePath) {
|
|
646
660
|
await this.analyzeNestedAgent(toolName, agentsDir, analysis, visited, parentKey);
|
|
647
661
|
return;
|
|
648
662
|
}
|
|
649
|
-
const toolFilePath = this.findFile(path2.join(agentsDir, "tools"), toolName);
|
|
663
|
+
const toolFilePath = await this.findFile(path2.join(agentsDir, "tools"), toolName);
|
|
650
664
|
if (!toolFilePath) {
|
|
651
665
|
analysis.warnings.push(`Tool file not found: ${toolName}`);
|
|
652
666
|
return;
|
|
@@ -665,7 +679,7 @@ var PackingService = class {
|
|
|
665
679
|
}
|
|
666
680
|
visited.add(`tool:${toolName}`);
|
|
667
681
|
const toolSource = fs2.readFileSync(toolFilePath, "utf-8");
|
|
668
|
-
const { uses } = extractToolUses(toolSource);
|
|
682
|
+
const { uses } = await extractToolUses(toolSource);
|
|
669
683
|
for (const usedItem of uses) {
|
|
670
684
|
await this.analyzeTool(usedItem, agentsDir, analysis, visited, "uses", thisKey);
|
|
671
685
|
}
|
|
@@ -674,7 +688,7 @@ var PackingService = class {
|
|
|
674
688
|
* Analyze a nested agent (used as a handoff target).
|
|
675
689
|
*/
|
|
676
690
|
async analyzeNestedAgent(agentName, agentsDir, analysis, visited, parentKey) {
|
|
677
|
-
const agentFilePath = this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
691
|
+
const agentFilePath = await this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
678
692
|
if (!agentFilePath) {
|
|
679
693
|
analysis.warnings.push(`Agent file not found: ${agentName}`);
|
|
680
694
|
return;
|
|
@@ -694,7 +708,7 @@ var PackingService = class {
|
|
|
694
708
|
}
|
|
695
709
|
visited.add(`agent:${agentName}`);
|
|
696
710
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
697
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
711
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
698
712
|
if (agentPrompts.sideA) {
|
|
699
713
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
|
|
700
714
|
}
|
|
@@ -706,7 +720,7 @@ var PackingService = class {
|
|
|
706
720
|
* Analyze a model and its fallbacks.
|
|
707
721
|
*/
|
|
708
722
|
async analyzeModel(modelName, agentsDir, analysis, visited, parentKey) {
|
|
709
|
-
const modelFilePath = this.findFile(path2.join(agentsDir, "models"), modelName);
|
|
723
|
+
const modelFilePath = await this.findFile(path2.join(agentsDir, "models"), modelName);
|
|
710
724
|
if (!modelFilePath) {
|
|
711
725
|
analysis.warnings.push(`Model file not found: ${modelName}`);
|
|
712
726
|
return;
|
|
@@ -726,7 +740,7 @@ var PackingService = class {
|
|
|
726
740
|
}
|
|
727
741
|
visited.add(`model:${modelName}`);
|
|
728
742
|
const modelSource = fs2.readFileSync(modelFilePath, "utf-8");
|
|
729
|
-
const fallbacks = extractModelFallbacks(modelSource);
|
|
743
|
+
const fallbacks = await extractModelFallbacks(modelSource);
|
|
730
744
|
for (const fallbackName of fallbacks) {
|
|
731
745
|
await this.analyzeModel(fallbackName, agentsDir, analysis, visited, thisKey);
|
|
732
746
|
}
|
|
@@ -775,34 +789,34 @@ var PackingService = class {
|
|
|
775
789
|
const result = { prompts: [], tools: [], models: [] };
|
|
776
790
|
const agentsDir = path2.join(rootDir, "agents");
|
|
777
791
|
const visited = /* @__PURE__ */ new Set();
|
|
778
|
-
const agentFilePath = this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
792
|
+
const agentFilePath = await this.findFile(path2.join(agentsDir, "agents"), agentName);
|
|
779
793
|
if (!agentFilePath) return result;
|
|
780
794
|
const agentSource = fs2.readFileSync(agentFilePath, "utf-8");
|
|
781
|
-
const agentPrompts = extractAgentPrompts(agentSource);
|
|
782
|
-
const analyzePromptLight = (promptName) => {
|
|
795
|
+
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
796
|
+
const analyzePromptLight = async (promptName) => {
|
|
783
797
|
if (visited.has(promptName)) return;
|
|
784
798
|
visited.add(promptName);
|
|
785
799
|
result.prompts.push(promptName);
|
|
786
|
-
const promptFilePath = this.findFile(path2.join(agentsDir, "prompts"), promptName);
|
|
800
|
+
const promptFilePath = await this.findFile(path2.join(agentsDir, "prompts"), promptName);
|
|
787
801
|
if (!promptFilePath) return;
|
|
788
802
|
const promptSource = fs2.readFileSync(promptFilePath, "utf-8");
|
|
789
|
-
const modelName = extractPromptModel(promptSource);
|
|
803
|
+
const modelName = await extractPromptModel(promptSource);
|
|
790
804
|
if (modelName && !result.models.includes(modelName)) {
|
|
791
805
|
result.models.push(modelName);
|
|
792
806
|
}
|
|
793
|
-
const { tools } = extractPromptTools(promptSource);
|
|
807
|
+
const { tools } = await extractPromptTools(promptSource);
|
|
794
808
|
for (const tool of tools) {
|
|
795
809
|
if (!result.tools.includes(tool)) {
|
|
796
810
|
result.tools.push(tool);
|
|
797
811
|
}
|
|
798
812
|
}
|
|
799
|
-
const includes = extractPromptIncludes(promptSource);
|
|
813
|
+
const includes = await extractPromptIncludes(promptSource);
|
|
800
814
|
for (const inc of includes) {
|
|
801
|
-
analyzePromptLight(inc);
|
|
815
|
+
await analyzePromptLight(inc);
|
|
802
816
|
}
|
|
803
817
|
};
|
|
804
|
-
if (agentPrompts.sideA) analyzePromptLight(agentPrompts.sideA);
|
|
805
|
-
if (agentPrompts.sideB) analyzePromptLight(agentPrompts.sideB);
|
|
818
|
+
if (agentPrompts.sideA) await analyzePromptLight(agentPrompts.sideA);
|
|
819
|
+
if (agentPrompts.sideB) await analyzePromptLight(agentPrompts.sideB);
|
|
806
820
|
return result;
|
|
807
821
|
}
|
|
808
822
|
/**
|
|
@@ -947,7 +961,7 @@ var PackingService = class {
|
|
|
947
961
|
let agentDescription;
|
|
948
962
|
if (agentItem?.filePath) {
|
|
949
963
|
const agentSource = fs2.readFileSync(agentItem.filePath, "utf-8");
|
|
950
|
-
agentDescription = extractAgentDescription(agentSource) || void 0;
|
|
964
|
+
agentDescription = await extractAgentDescription(agentSource) || void 0;
|
|
951
965
|
}
|
|
952
966
|
readmeContent = this.generateReadme(
|
|
953
967
|
finalPackageName,
|
|
@@ -1547,7 +1561,7 @@ ${license || "See LICENSE file"}
|
|
|
1547
1561
|
/**
|
|
1548
1562
|
* Find a file by name in a directory.
|
|
1549
1563
|
*/
|
|
1550
|
-
findFile(dir, name) {
|
|
1564
|
+
async findFile(dir, name) {
|
|
1551
1565
|
if (!fs2.existsSync(dir)) {
|
|
1552
1566
|
return null;
|
|
1553
1567
|
}
|
|
@@ -1559,7 +1573,7 @@ ${license || "See LICENSE file"}
|
|
|
1559
1573
|
for (const file of files) {
|
|
1560
1574
|
const filePath = path2.join(dir, file);
|
|
1561
1575
|
const source = fs2.readFileSync(filePath, "utf-8");
|
|
1562
|
-
const extractedName = extractDefinitionName(source);
|
|
1576
|
+
const extractedName = await extractDefinitionName(source);
|
|
1563
1577
|
if (extractedName === name) {
|
|
1564
1578
|
return filePath;
|
|
1565
1579
|
}
|
|
@@ -1569,7 +1583,7 @@ ${license || "See LICENSE file"}
|
|
|
1569
1583
|
/**
|
|
1570
1584
|
* List all agents in the workspace.
|
|
1571
1585
|
*/
|
|
1572
|
-
listAgents(rootDir) {
|
|
1586
|
+
async listAgents(rootDir) {
|
|
1573
1587
|
const agentsDir = path2.join(rootDir, "agents", "agents");
|
|
1574
1588
|
if (!fs2.existsSync(agentsDir)) {
|
|
1575
1589
|
return [];
|
|
@@ -1579,7 +1593,7 @@ ${license || "See LICENSE file"}
|
|
|
1579
1593
|
for (const file of files) {
|
|
1580
1594
|
const filePath = path2.join(agentsDir, file);
|
|
1581
1595
|
const source = fs2.readFileSync(filePath, "utf-8");
|
|
1582
|
-
const name = extractDefinitionName(source);
|
|
1596
|
+
const name = await extractDefinitionName(source);
|
|
1583
1597
|
if (name) {
|
|
1584
1598
|
agents.push(name);
|
|
1585
1599
|
} else {
|
|
@@ -1847,7 +1861,7 @@ var UnpackingService = class {
|
|
|
1847
1861
|
return analysis;
|
|
1848
1862
|
}
|
|
1849
1863
|
const indexContent = fs2.readFileSync(indexPath, "utf-8");
|
|
1850
|
-
const registryItems = this.parseIndexExports(indexContent);
|
|
1864
|
+
const registryItems = await this.parseIndexExports(indexContent);
|
|
1851
1865
|
const availableItems = /* @__PURE__ */ new Map();
|
|
1852
1866
|
for (const item of registryItems) {
|
|
1853
1867
|
availableItems.set(`${item.type}:${item.name}`, item);
|
|
@@ -1864,7 +1878,7 @@ var UnpackingService = class {
|
|
|
1864
1878
|
continue;
|
|
1865
1879
|
}
|
|
1866
1880
|
const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
|
|
1867
|
-
const children = this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
|
|
1881
|
+
const children = await this.discoverRelationships(item.type, item.name, bundledCode, availableItems);
|
|
1868
1882
|
itemsWithRelations.push({
|
|
1869
1883
|
name: item.name,
|
|
1870
1884
|
type: item.type,
|
|
@@ -1905,10 +1919,10 @@ var UnpackingService = class {
|
|
|
1905
1919
|
* Discover relationships from a bundled file.
|
|
1906
1920
|
* Returns child items that this item references.
|
|
1907
1921
|
*/
|
|
1908
|
-
discoverRelationships(type, name, bundledCode, availableItems) {
|
|
1922
|
+
async discoverRelationships(type, name, bundledCode, availableItems) {
|
|
1909
1923
|
const children = [];
|
|
1910
1924
|
if (type === "agent") {
|
|
1911
|
-
const prompts = extractAgentPrompts(bundledCode);
|
|
1925
|
+
const prompts = await extractAgentPrompts(bundledCode);
|
|
1912
1926
|
if (prompts.sideA && availableItems.has(`prompt:${prompts.sideA}`)) {
|
|
1913
1927
|
children.push({ type: "prompt", name: prompts.sideA });
|
|
1914
1928
|
}
|
|
@@ -1916,7 +1930,7 @@ var UnpackingService = class {
|
|
|
1916
1930
|
children.push({ type: "prompt", name: prompts.sideB });
|
|
1917
1931
|
}
|
|
1918
1932
|
} else if (type === "prompt") {
|
|
1919
|
-
const toolsResult = extractPromptTools(bundledCode);
|
|
1933
|
+
const toolsResult = await extractPromptTools(bundledCode);
|
|
1920
1934
|
for (const toolName of toolsResult.tools) {
|
|
1921
1935
|
if (availableItems.has(`tool:${toolName}`)) {
|
|
1922
1936
|
children.push({ type: "tool", name: toolName });
|
|
@@ -1924,12 +1938,12 @@ var UnpackingService = class {
|
|
|
1924
1938
|
children.push({ type: "agent", name: toolName });
|
|
1925
1939
|
}
|
|
1926
1940
|
}
|
|
1927
|
-
const model = extractPromptModel(bundledCode);
|
|
1941
|
+
const model = await extractPromptModel(bundledCode);
|
|
1928
1942
|
if (model && availableItems.has(`model:${model}`)) {
|
|
1929
1943
|
children.push({ type: "model", name: model });
|
|
1930
1944
|
}
|
|
1931
1945
|
} else if (type === "tool") {
|
|
1932
|
-
const usesResult = extractToolUses(bundledCode);
|
|
1946
|
+
const usesResult = await extractToolUses(bundledCode);
|
|
1933
1947
|
for (const useName of usesResult.uses) {
|
|
1934
1948
|
const colonIndex = useName.indexOf(":");
|
|
1935
1949
|
if (colonIndex > 0) {
|
|
@@ -2007,9 +2021,9 @@ var UnpackingService = class {
|
|
|
2007
2021
|
try {
|
|
2008
2022
|
const sourcePath = path2.join(pkg.path, "dist", TYPE_TO_DIR[item.type], `${item.name}.js`);
|
|
2009
2023
|
const bundledCode = fs2.readFileSync(sourcePath, "utf-8");
|
|
2010
|
-
let tsCode = transformBundledJs(bundledCode);
|
|
2024
|
+
let tsCode = await transformBundledJs(bundledCode);
|
|
2011
2025
|
if (item.type === "agent") {
|
|
2012
|
-
tsCode = injectAgentMetadata(tsCode, agentMetadata);
|
|
2026
|
+
tsCode = await injectAgentMetadata(tsCode, agentMetadata);
|
|
2013
2027
|
}
|
|
2014
2028
|
const dir = path2.dirname(item.targetPath);
|
|
2015
2029
|
if (!fs2.existsSync(dir)) {
|
|
@@ -2051,7 +2065,8 @@ var UnpackingService = class {
|
|
|
2051
2065
|
* };
|
|
2052
2066
|
* ```
|
|
2053
2067
|
*/
|
|
2054
|
-
parseIndexExports(indexContent) {
|
|
2068
|
+
async parseIndexExports(indexContent) {
|
|
2069
|
+
const ts = await loadTypeScript();
|
|
2055
2070
|
const sourceFile = ts.createSourceFile(
|
|
2056
2071
|
"index.js",
|
|
2057
2072
|
indexContent,
|