@standardagents/builder 0.11.6 → 0.11.8
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 +165 -41
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/index.js +18 -18
- package/dist/index.d.ts +8 -3
- package/dist/index.js +302 -72
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +102 -2
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/plugin.js
CHANGED
|
@@ -17,6 +17,74 @@ var TSCONFIG_CONTENT = `{
|
|
|
17
17
|
"include": ["types.d.ts", "virtual-module.d.ts"]
|
|
18
18
|
}
|
|
19
19
|
`;
|
|
20
|
+
function extractSchemaFields(content) {
|
|
21
|
+
const fields = [];
|
|
22
|
+
const schemaMatch = content.match(/requiredSchema:\s*z\.object\(\s*\{([^}]+)\}/s);
|
|
23
|
+
if (!schemaMatch) {
|
|
24
|
+
return fields;
|
|
25
|
+
}
|
|
26
|
+
const schemaContent = schemaMatch[1];
|
|
27
|
+
const fieldMatches = schemaContent.matchAll(/(?:['"]([^'"]+)['"]|(\w+))\s*:/g);
|
|
28
|
+
for (const match of fieldMatches) {
|
|
29
|
+
const fieldName = match[1] || match[2];
|
|
30
|
+
if (fieldName && !fieldName.startsWith("z.")) {
|
|
31
|
+
fields.push(fieldName);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return fields;
|
|
35
|
+
}
|
|
36
|
+
function scanPromptsWithSchemas(dir) {
|
|
37
|
+
const results = [];
|
|
38
|
+
if (!fs2.existsSync(dir)) {
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
if (entry.isFile() && entry.name.endsWith(".ts")) {
|
|
45
|
+
const filePath = path3.join(dir, entry.name);
|
|
46
|
+
const content = fs2.readFileSync(filePath, "utf-8");
|
|
47
|
+
const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/);
|
|
48
|
+
if (nameMatch) {
|
|
49
|
+
const name = nameMatch[1];
|
|
50
|
+
const schemaFields = extractSchemaFields(content);
|
|
51
|
+
results.push({ name, schemaFields });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(`Error scanning prompts directory ${dir}:`, error);
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
function scanAgentsWithSideA(dir) {
|
|
61
|
+
const results = [];
|
|
62
|
+
if (!fs2.existsSync(dir)) {
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (entry.isFile() && entry.name.endsWith(".ts")) {
|
|
69
|
+
const filePath = path3.join(dir, entry.name);
|
|
70
|
+
const content = fs2.readFileSync(filePath, "utf-8");
|
|
71
|
+
const nameMatch = content.match(/name:\s*['"]([^'"]+)['"]/);
|
|
72
|
+
if (nameMatch) {
|
|
73
|
+
const name = nameMatch[1];
|
|
74
|
+
let sideAPrompt = null;
|
|
75
|
+
const sideAMatch = content.match(/sideA:\s*\{[^}]*prompt:\s*['"]([^'"]+)['"]/);
|
|
76
|
+
if (sideAMatch) {
|
|
77
|
+
sideAPrompt = sideAMatch[1];
|
|
78
|
+
}
|
|
79
|
+
results.push({ name, sideAPrompt });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(`Error scanning agents directory ${dir}:`, error);
|
|
85
|
+
}
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
20
88
|
function scanForNames(dir, useFilename = false) {
|
|
21
89
|
const names = [];
|
|
22
90
|
if (!fs2.existsSync(dir)) {
|
|
@@ -52,11 +120,38 @@ function generateRegistryProperties(names) {
|
|
|
52
120
|
}
|
|
53
121
|
return names.map((n) => `'${n}': true;`).join("\n ");
|
|
54
122
|
}
|
|
123
|
+
function generateSchemaRegistryProperties(promptResults, agentResults) {
|
|
124
|
+
const entries = [];
|
|
125
|
+
const promptSchemaMap = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const prompt of promptResults) {
|
|
127
|
+
if (prompt.schemaFields.length > 0) {
|
|
128
|
+
promptSchemaMap.set(prompt.name, prompt.schemaFields);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const prompt of promptResults) {
|
|
132
|
+
if (prompt.schemaFields.length > 0) {
|
|
133
|
+
const fieldsUnion = prompt.schemaFields.map((f) => `'${f}'`).join(" | ");
|
|
134
|
+
entries.push(`'${prompt.name}': ${fieldsUnion};`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const agent of agentResults) {
|
|
138
|
+
if (agent.sideAPrompt) {
|
|
139
|
+
const schemaFields = promptSchemaMap.get(agent.sideAPrompt);
|
|
140
|
+
if (schemaFields && schemaFields.length > 0) {
|
|
141
|
+
const fieldsUnion = schemaFields.map((f) => `'${f}'`).join(" | ");
|
|
142
|
+
entries.push(`'${agent.name}': ${fieldsUnion};`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return entries.join("\n ");
|
|
147
|
+
}
|
|
55
148
|
function generateTypesContent(config) {
|
|
56
149
|
const models = scanForNames(config.modelsDir);
|
|
57
|
-
const
|
|
58
|
-
const
|
|
150
|
+
const promptResults = scanPromptsWithSchemas(config.promptsDir);
|
|
151
|
+
const agentResults = scanAgentsWithSideA(config.agentsDir);
|
|
59
152
|
const tools = scanForNames(config.toolsDir, true);
|
|
153
|
+
const prompts = promptResults.map((p) => p.name);
|
|
154
|
+
const agents = agentResults.map((a) => a.name);
|
|
60
155
|
const callables = [...prompts, ...agents, ...tools];
|
|
61
156
|
return `// Auto-generated by @standardagents/builder - DO NOT EDIT
|
|
62
157
|
// Generated at: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
@@ -97,6 +192,11 @@ declare global {
|
|
|
97
192
|
interface CallableRegistry {
|
|
98
193
|
${generateRegistryProperties(callables)}
|
|
99
194
|
}
|
|
195
|
+
|
|
196
|
+
/** Schema field names for prompts and agents (used for initUserMessageProperty autocomplete) */
|
|
197
|
+
interface PromptSchemaRegistry {
|
|
198
|
+
${generateSchemaRegistryProperties(promptResults, agentResults)}
|
|
199
|
+
}
|
|
100
200
|
}
|
|
101
201
|
}
|
|
102
202
|
|