@standardagents/builder 0.39.0 → 0.40.0
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 +671 -144
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-AH5i-H6j.js → ApiKeysView-DoYvZZ7e.js} +1 -1
- package/dist/client/{CenteredContentView-DaBp0K-A.js → CenteredContentView-53PY0cqY.js} +1 -1
- package/dist/client/{CompositionView-yY1Q4M23.js → CompositionView-fp-0YnPt.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-Bwo5CJzF.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-Cvcagja2.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-D0WYwWyA.js → CopyButton.vue_vue_type_script_setup_true_lang-jYvO2v1K.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-1wwPn2aY.js → DataTable.vue_vue_type_script_setup_true_lang-DQ3Ufa7y.js} +1 -1
- package/dist/client/{JsonViewer-Bi8Zdmir.js → JsonViewer-6aaGzutE.js} +1 -1
- package/dist/client/{LoginView-BIKahEU6.js → LoginView-DwpCmNw9.js} +1 -1
- package/dist/client/{MarketplaceView-DPDPVH68.js → MarketplaceView-Da02L0J5.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-D1_rfOsy.js → Modal.vue_vue_type_script_setup_true_lang-Bi8OjiBf.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-DSLeOdxr.js → ModelModal.vue_vue_type_script_setup_true_lang-cYZLOYY7.js} +1 -1
- package/dist/client/{ModelsView-Q2WXu1Gw.js → ModelsView-BLlHO9Ud.js} +1 -1
- package/dist/client/{PromptEditView-BzA-3n1w.js → PromptEditView-EeNwTDtT.js} +1 -1
- package/dist/client/{PromptModal-CJWh_cru.js → PromptModal-BkwrKJ2d.js} +1 -1
- package/dist/client/{PromptsView-BezNl-Et.js → PromptsView-D1r7tsLu.js} +1 -1
- package/dist/client/{ProvidersView-BuzSKxuT.js → ProvidersView-CmUDl5nM.js} +1 -1
- package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DOxNp_3C.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-cRs3tApQ.js} +1 -1
- package/dist/client/{ThreadsView-DPCpZA4J.js → ThreadsView-Bl5fSIO1.js} +1 -1
- package/dist/client/{ToolsView-DMjFMAhH.js → ToolsView-DlVEF8-7.js} +1 -1
- package/dist/client/{UsersView-B7jXLNQs.js → UsersView-CGlA7a7R.js} +1 -1
- package/dist/client/{VariablesView-CF7x0G8g.js → VariablesView-BpYmJL4V.js} +1 -1
- package/dist/client/index-CKtIkI0N.js +6 -0
- package/dist/client/index.html +1 -1
- package/dist/{discovery-DiMJWisl.d.ts → discovery-DZ7fv-b4.d.ts} +3 -2
- package/dist/{index-yIcqf7DC.d.ts → index-9MaIifn3.d.ts} +7 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1170 -563
- package/dist/index.js.map +1 -1
- package/dist/packing.d.ts +5 -3
- package/dist/packing.js +180 -5
- package/dist/packing.js.map +1 -1
- package/dist/plugin.js +252 -17
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +25 -38
- package/dist/runtime.js +1328 -958
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/{types-Bpe7IANZ.d.ts → types-BMnBYNwn.d.ts} +3 -1
- package/package.json +5 -5
- package/dist/client/index-eGECJFYe.js +0 -6
package/dist/plugin.js
CHANGED
|
@@ -1866,6 +1866,10 @@ function generateAgentFile(data) {
|
|
|
1866
1866
|
if (data.toolDescription) {
|
|
1867
1867
|
lines.push(` toolDescription: '${escapeString3(data.toolDescription)}',`);
|
|
1868
1868
|
}
|
|
1869
|
+
if (data.parentHooks && data.parentHooks.length > 0) {
|
|
1870
|
+
const serialized = JSON.stringify(data.parentHooks, null, 2).split("\n").map((line, index) => index === 0 ? line : ` ${line}`).join("\n");
|
|
1871
|
+
lines.push(` parentHooks: ${serialized},`);
|
|
1872
|
+
}
|
|
1869
1873
|
const env = data.env ?? (data.tenvs || void 0);
|
|
1870
1874
|
if (env && Object.keys(env).length > 0) {
|
|
1871
1875
|
lines.push(` env: ${JSON.stringify(env)},`);
|
|
@@ -2635,6 +2639,9 @@ function transformAgentData(data) {
|
|
|
2635
2639
|
if (data.tool_description) {
|
|
2636
2640
|
transformed.toolDescription = data.tool_description;
|
|
2637
2641
|
}
|
|
2642
|
+
if (data.parent_hooks !== void 0 || data.parentHooks !== void 0) {
|
|
2643
|
+
transformed.parentHooks = data.parent_hooks ?? data.parentHooks;
|
|
2644
|
+
}
|
|
2638
2645
|
if (data.env !== void 0 || data.tenvs !== void 0) {
|
|
2639
2646
|
transformed.env = normalizeStringEnvRecord(data.env ?? data.tenvs) ?? {};
|
|
2640
2647
|
}
|
|
@@ -2880,6 +2887,22 @@ function validateAgentData(data) {
|
|
|
2880
2887
|
if (data.exposeAsTool && !data.toolDescription) {
|
|
2881
2888
|
errors["tool_description"] = "Tool description is required when expose as tool is enabled";
|
|
2882
2889
|
}
|
|
2890
|
+
if (data.parentHooks !== void 0) {
|
|
2891
|
+
if (!Array.isArray(data.parentHooks)) {
|
|
2892
|
+
errors["parent_hooks"] = "Parent hooks must be an array";
|
|
2893
|
+
} else if (data.type !== "dual_ai" || !data.exposeAsTool) {
|
|
2894
|
+
errors["parent_hooks"] = "Parent hooks require an exposed dual_ai agent";
|
|
2895
|
+
} else {
|
|
2896
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2897
|
+
for (const requirement of data.parentHooks) {
|
|
2898
|
+
if (!requirement || typeof requirement !== "object" || typeof requirement.hook !== "string" || !requirement.hook || typeof requirement.reason !== "string" || !requirement.reason.trim() || requirement.stage !== void 0 && requirement.stage !== "before_parent" && requirement.stage !== "after_parent" || seen.has(requirement.hook)) {
|
|
2899
|
+
errors["parent_hooks"] = "Parent hook entries require a unique hook, reason, and valid stage";
|
|
2900
|
+
break;
|
|
2901
|
+
}
|
|
2902
|
+
seen.add(requirement.hook);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2883
2906
|
if (data.maxSessionTurns !== void 0 && data.maxSessionTurns !== null) {
|
|
2884
2907
|
if (typeof data.maxSessionTurns !== "number" || data.maxSessionTurns <= 0) {
|
|
2885
2908
|
errors["max_session_turns"] = "Max session turns must be a positive number";
|
|
@@ -3025,6 +3048,44 @@ function discoverPackedPackageDirectories(packedDir) {
|
|
|
3025
3048
|
}
|
|
3026
3049
|
return packageDirs;
|
|
3027
3050
|
}
|
|
3051
|
+
function discoverStandardAgentPackageDirectories(rootDir) {
|
|
3052
|
+
const packages = /* @__PURE__ */ new Map();
|
|
3053
|
+
const addPackage = (packagePath, source) => {
|
|
3054
|
+
const packageJsonPath = path9__default.join(packagePath, "package.json");
|
|
3055
|
+
if (!fs9__default.existsSync(packageJsonPath)) return;
|
|
3056
|
+
try {
|
|
3057
|
+
const packageJson = JSON.parse(fs9__default.readFileSync(packageJsonPath, "utf8"));
|
|
3058
|
+
if (typeof packageJson.name !== "string" || !Array.isArray(packageJson.standardagent?.entryAgents)) {
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
packages.set(packageJson.name, { path: packagePath, source });
|
|
3062
|
+
} catch {
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
const nodeModulesDir = path9__default.join(rootDir, "node_modules");
|
|
3066
|
+
if (fs9__default.existsSync(nodeModulesDir)) {
|
|
3067
|
+
for (const entry of fs9__default.readdirSync(nodeModulesDir, { withFileTypes: true })) {
|
|
3068
|
+
if (entry.name.startsWith(".")) continue;
|
|
3069
|
+
const entryPath = path9__default.join(nodeModulesDir, entry.name);
|
|
3070
|
+
if (entry.name.startsWith("@")) {
|
|
3071
|
+
if (!fs9__default.existsSync(entryPath)) continue;
|
|
3072
|
+
for (const scopedEntry of fs9__default.readdirSync(entryPath, { withFileTypes: true })) {
|
|
3073
|
+
if (!scopedEntry.name.startsWith(".")) {
|
|
3074
|
+
addPackage(path9__default.join(entryPath, scopedEntry.name), "npm");
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
} else {
|
|
3078
|
+
addPackage(entryPath, "npm");
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
for (const packagePath of discoverPackedPackageDirectories(
|
|
3083
|
+
path9__default.join(rootDir, "agents", "packed")
|
|
3084
|
+
)) {
|
|
3085
|
+
addPackage(packagePath, "local");
|
|
3086
|
+
}
|
|
3087
|
+
return [...packages.values()];
|
|
3088
|
+
}
|
|
3028
3089
|
function scanPackedDistDirectory(packagePath, outputDir, subDir) {
|
|
3029
3090
|
const fullPath = path9__default.join(packagePath, outputDir, subDir);
|
|
3030
3091
|
if (!fs9__default.existsSync(fullPath)) {
|
|
@@ -3968,11 +4029,19 @@ async function extractPromptTools(sourceCode) {
|
|
|
3968
4029
|
result.tools.push(element.text);
|
|
3969
4030
|
} else if (ts.isObjectLiteralExpression(element)) {
|
|
3970
4031
|
result.hasSubpromptConfigs = true;
|
|
4032
|
+
let configuredName;
|
|
4033
|
+
let implementingAgent;
|
|
3971
4034
|
for (const objProp of element.properties) {
|
|
3972
|
-
if (ts.isPropertyAssignment(objProp) && ts.isIdentifier(objProp.name) &&
|
|
3973
|
-
|
|
4035
|
+
if (ts.isPropertyAssignment(objProp) && ts.isIdentifier(objProp.name) && ts.isStringLiteral(objProp.initializer)) {
|
|
4036
|
+
if (objProp.name.text === "name") {
|
|
4037
|
+
configuredName = objProp.initializer.text;
|
|
4038
|
+
} else if (objProp.name.text === "agent") {
|
|
4039
|
+
implementingAgent = objProp.initializer.text;
|
|
4040
|
+
}
|
|
3974
4041
|
}
|
|
3975
4042
|
}
|
|
4043
|
+
const dependencyName = implementingAgent ?? configuredName;
|
|
4044
|
+
if (dependencyName) result.tools.push(dependencyName);
|
|
3976
4045
|
}
|
|
3977
4046
|
}
|
|
3978
4047
|
}
|
|
@@ -4095,6 +4164,106 @@ async function extractAgentPrompts(sourceCode) {
|
|
|
4095
4164
|
visit(sourceFile);
|
|
4096
4165
|
return result;
|
|
4097
4166
|
}
|
|
4167
|
+
async function extractAgentHooks(sourceCode) {
|
|
4168
|
+
const ts = await loadTypeScript();
|
|
4169
|
+
const sourceFile = ts.createSourceFile(
|
|
4170
|
+
"agent.ts",
|
|
4171
|
+
sourceCode,
|
|
4172
|
+
ts.ScriptTarget.ESNext,
|
|
4173
|
+
true
|
|
4174
|
+
);
|
|
4175
|
+
const arrays = /* @__PURE__ */ new Map();
|
|
4176
|
+
const result = {
|
|
4177
|
+
hooks: [],
|
|
4178
|
+
parentHooks: [],
|
|
4179
|
+
parentHookRequirements: []
|
|
4180
|
+
};
|
|
4181
|
+
const unwrapArray = (expression) => {
|
|
4182
|
+
let current = expression;
|
|
4183
|
+
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current)) {
|
|
4184
|
+
current = current.expression;
|
|
4185
|
+
}
|
|
4186
|
+
if (ts.isArrayLiteralExpression(current)) return current;
|
|
4187
|
+
if (ts.isIdentifier(current)) return arrays.get(current.text) ?? null;
|
|
4188
|
+
return null;
|
|
4189
|
+
};
|
|
4190
|
+
for (const statement of sourceFile.statements) {
|
|
4191
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
4192
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
4193
|
+
if (ts.isIdentifier(declaration.name) && declaration.initializer) {
|
|
4194
|
+
const array = unwrapArray(declaration.initializer);
|
|
4195
|
+
if (array) arrays.set(declaration.name.text, array);
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4199
|
+
const pushUnique = (target, value) => {
|
|
4200
|
+
if (!target.includes(value)) target.push(value);
|
|
4201
|
+
};
|
|
4202
|
+
function visit(node) {
|
|
4203
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "defineAgent" && node.arguments.length > 0 && ts.isObjectLiteralExpression(node.arguments[0])) {
|
|
4204
|
+
for (const property of node.arguments[0].properties) {
|
|
4205
|
+
if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) continue;
|
|
4206
|
+
const array = unwrapArray(property.initializer);
|
|
4207
|
+
if (!array) continue;
|
|
4208
|
+
if (property.name.text === "hooks") {
|
|
4209
|
+
for (const element of array.elements) {
|
|
4210
|
+
if (ts.isStringLiteral(element)) pushUnique(result.hooks, element.text);
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
if (property.name.text === "parentHooks") {
|
|
4214
|
+
for (const element of array.elements) {
|
|
4215
|
+
if (!ts.isObjectLiteralExpression(element)) continue;
|
|
4216
|
+
let hook;
|
|
4217
|
+
let reason;
|
|
4218
|
+
let stage;
|
|
4219
|
+
for (const requirement of element.properties) {
|
|
4220
|
+
if (ts.isPropertyAssignment(requirement) && ts.isIdentifier(requirement.name) && ts.isStringLiteral(requirement.initializer)) {
|
|
4221
|
+
if (requirement.name.text === "hook") hook = requirement.initializer.text;
|
|
4222
|
+
if (requirement.name.text === "reason") reason = requirement.initializer.text;
|
|
4223
|
+
if (requirement.name.text === "stage" && (requirement.initializer.text === "before_parent" || requirement.initializer.text === "after_parent")) {
|
|
4224
|
+
stage = requirement.initializer.text;
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
}
|
|
4228
|
+
if (hook) {
|
|
4229
|
+
pushUnique(result.parentHooks, hook);
|
|
4230
|
+
if (reason) result.parentHookRequirements.push({ hook, reason, stage });
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
ts.forEachChild(node, visit);
|
|
4237
|
+
}
|
|
4238
|
+
visit(sourceFile);
|
|
4239
|
+
return result;
|
|
4240
|
+
}
|
|
4241
|
+
async function extractPromptHooks(sourceCode) {
|
|
4242
|
+
const ts = await loadTypeScript();
|
|
4243
|
+
const sourceFile = ts.createSourceFile(
|
|
4244
|
+
"prompt.ts",
|
|
4245
|
+
sourceCode,
|
|
4246
|
+
ts.ScriptTarget.ESNext,
|
|
4247
|
+
true
|
|
4248
|
+
);
|
|
4249
|
+
const hooks = [];
|
|
4250
|
+
function visit(node) {
|
|
4251
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "definePrompt" && node.arguments.length > 0 && ts.isObjectLiteralExpression(node.arguments[0])) {
|
|
4252
|
+
for (const property of node.arguments[0].properties) {
|
|
4253
|
+
if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name) && property.name.text === "hooks" && ts.isArrayLiteralExpression(property.initializer)) {
|
|
4254
|
+
for (const element of property.initializer.elements) {
|
|
4255
|
+
if (ts.isStringLiteral(element) && !hooks.includes(element.text)) {
|
|
4256
|
+
hooks.push(element.text);
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
ts.forEachChild(node, visit);
|
|
4263
|
+
}
|
|
4264
|
+
visit(sourceFile);
|
|
4265
|
+
return hooks;
|
|
4266
|
+
}
|
|
4098
4267
|
async function extractAgentDescription(sourceCode) {
|
|
4099
4268
|
const ts = await loadTypeScript();
|
|
4100
4269
|
const sourceFile = ts.createSourceFile(
|
|
@@ -4334,6 +4503,13 @@ var PackingService = class {
|
|
|
4334
4503
|
});
|
|
4335
4504
|
const agentSource = fs9.readFileSync(agentFilePath, "utf-8");
|
|
4336
4505
|
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
4506
|
+
const agentHooks = await extractAgentHooks(agentSource);
|
|
4507
|
+
for (const hookId of agentHooks.hooks) {
|
|
4508
|
+
await this.analyzeHook(hookId, agentsDir, analysis, false, `agent:${agentName}`);
|
|
4509
|
+
}
|
|
4510
|
+
for (const hookId of agentHooks.parentHooks) {
|
|
4511
|
+
await this.analyzeHook(hookId, agentsDir, analysis, true, `agent:${agentName}`);
|
|
4512
|
+
}
|
|
4337
4513
|
if (agentPrompts.sideA) {
|
|
4338
4514
|
analysis.primaryPrompt = agentPrompts.sideA;
|
|
4339
4515
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, /* @__PURE__ */ new Set(), `agent:${agentName}`);
|
|
@@ -4536,6 +4712,9 @@ var PackingService = class {
|
|
|
4536
4712
|
}
|
|
4537
4713
|
visited.add(`prompt:${promptName}`);
|
|
4538
4714
|
const promptSource = fs9.readFileSync(promptFilePath, "utf-8");
|
|
4715
|
+
for (const hookId of await extractPromptHooks(promptSource)) {
|
|
4716
|
+
await this.analyzeHook(hookId, agentsDir, analysis, false, thisKey);
|
|
4717
|
+
}
|
|
4539
4718
|
const modelName = await extractPromptModel(promptSource);
|
|
4540
4719
|
if (modelName) {
|
|
4541
4720
|
await this.analyzeModel(modelName, agentsDir, analysis, visited, thisKey);
|
|
@@ -4620,6 +4799,13 @@ var PackingService = class {
|
|
|
4620
4799
|
visited.add(`agent:${agentName}`);
|
|
4621
4800
|
const agentSource = fs9.readFileSync(agentFilePath, "utf-8");
|
|
4622
4801
|
const agentPrompts = await extractAgentPrompts(agentSource);
|
|
4802
|
+
const agentHooks = await extractAgentHooks(agentSource);
|
|
4803
|
+
for (const hookId of agentHooks.hooks) {
|
|
4804
|
+
await this.analyzeHook(hookId, agentsDir, analysis, false, thisKey);
|
|
4805
|
+
}
|
|
4806
|
+
for (const hookId of agentHooks.parentHooks) {
|
|
4807
|
+
await this.analyzeHook(hookId, agentsDir, analysis, true, thisKey);
|
|
4808
|
+
}
|
|
4623
4809
|
if (agentPrompts.sideA) {
|
|
4624
4810
|
await this.analyzePrompt(agentPrompts.sideA, agentsDir, analysis, visited, thisKey);
|
|
4625
4811
|
}
|
|
@@ -4627,6 +4813,27 @@ var PackingService = class {
|
|
|
4627
4813
|
await this.analyzePrompt(agentPrompts.sideB, agentsDir, analysis, visited, thisKey);
|
|
4628
4814
|
}
|
|
4629
4815
|
}
|
|
4816
|
+
/** Add a hook referenced by an agent or prompt to the packed graph. */
|
|
4817
|
+
async analyzeHook(hookId, agentsDir, analysis, required, parentKey) {
|
|
4818
|
+
const hookFilePath = await this.findFile(path9.join(agentsDir, "hooks"), hookId);
|
|
4819
|
+
if (!hookFilePath) {
|
|
4820
|
+
const message = `Hook file not found for ID: ${hookId}`;
|
|
4821
|
+
if (required) analysis.errors.push(message);
|
|
4822
|
+
else analysis.warnings.push(message);
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4825
|
+
if (!analysis.constituents.hooks.some(
|
|
4826
|
+
(hook) => hook.name === hookId && hook.parentKey === parentKey
|
|
4827
|
+
)) {
|
|
4828
|
+
analysis.constituents.hooks.push({
|
|
4829
|
+
name: hookId,
|
|
4830
|
+
filePath: hookFilePath,
|
|
4831
|
+
discoveredVia: "static",
|
|
4832
|
+
sharedWith: [],
|
|
4833
|
+
parentKey
|
|
4834
|
+
});
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4630
4837
|
/**
|
|
4631
4838
|
* Analyze a model and its fallbacks.
|
|
4632
4839
|
*/
|
|
@@ -4761,11 +4968,17 @@ var PackingService = class {
|
|
|
4761
4968
|
} = options;
|
|
4762
4969
|
const finalPackageName = packageName || packageId;
|
|
4763
4970
|
const packedAt = Date.now();
|
|
4971
|
+
const entryAgentFile = await this.findFile(
|
|
4972
|
+
path9.join(rootDir, "agents", "agents"),
|
|
4973
|
+
agentName
|
|
4974
|
+
);
|
|
4975
|
+
const entryParentHooks = entryAgentFile ? (await extractAgentHooks(fs9.readFileSync(entryAgentFile, "utf-8"))).parentHookRequirements : [];
|
|
4764
4976
|
const meta = {
|
|
4765
4977
|
packageId,
|
|
4766
4978
|
version,
|
|
4767
4979
|
entryAgents: [agentName],
|
|
4768
|
-
packedAt
|
|
4980
|
+
packedAt,
|
|
4981
|
+
...entryParentHooks.length > 0 ? { parentHooks: { [agentName]: entryParentHooks } } : {}
|
|
4769
4982
|
};
|
|
4770
4983
|
const result = {
|
|
4771
4984
|
success: false,
|
|
@@ -4874,6 +5087,7 @@ var PackingService = class {
|
|
|
4874
5087
|
agentName,
|
|
4875
5088
|
this.deduplicateConstituents(analysis).effects.map((effect) => effect.name),
|
|
4876
5089
|
this.deduplicateConstituents(analysis).threadEndpoints.map((endpoint) => endpoint.name),
|
|
5090
|
+
meta.parentHooks,
|
|
4877
5091
|
externalDeps,
|
|
4878
5092
|
rootDir,
|
|
4879
5093
|
license,
|
|
@@ -5265,7 +5479,7 @@ var PackingService = class {
|
|
|
5265
5479
|
/**
|
|
5266
5480
|
* Generate the package.json file with dependencies.
|
|
5267
5481
|
*/
|
|
5268
|
-
generatePackageJson(packageName, version, agentName, effects, threadEndpoints, externalDeps, rootDir, license, licenseOwner) {
|
|
5482
|
+
generatePackageJson(packageName, version, agentName, effects, threadEndpoints, parentHooks, externalDeps, rootDir, license, licenseOwner) {
|
|
5269
5483
|
const dependencies = {
|
|
5270
5484
|
"@standardagents/spec": this.resolvePackageVersion("@standardagents/spec", rootDir)
|
|
5271
5485
|
};
|
|
@@ -5287,6 +5501,7 @@ var PackingService = class {
|
|
|
5287
5501
|
keywords: ["standardagent"],
|
|
5288
5502
|
standardagent: {
|
|
5289
5503
|
entryAgents: [agentName],
|
|
5504
|
+
...parentHooks ? { parentHooks } : {},
|
|
5290
5505
|
...effects.length > 0 ? { effects } : {},
|
|
5291
5506
|
...threadEndpoints.length > 0 ? { threadEndpoints } : {}
|
|
5292
5507
|
},
|
|
@@ -5580,6 +5795,22 @@ ${license || "See LICENSE file"}
|
|
|
5580
5795
|
return agents;
|
|
5581
5796
|
}
|
|
5582
5797
|
};
|
|
5798
|
+
function validParentHooks(value) {
|
|
5799
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
5800
|
+
return Object.values(value).every((requirements) => {
|
|
5801
|
+
if (!Array.isArray(requirements)) return false;
|
|
5802
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5803
|
+
return requirements.every((requirement) => {
|
|
5804
|
+
if (typeof requirement !== "object" || requirement === null) return false;
|
|
5805
|
+
const item = requirement;
|
|
5806
|
+
if (typeof item.hook !== "string" || !item.hook.trim() || typeof item.reason !== "string" || !item.reason.trim() || item.stage !== void 0 && item.stage !== "before_parent" && item.stage !== "after_parent" || seen.has(item.hook)) {
|
|
5807
|
+
return false;
|
|
5808
|
+
}
|
|
5809
|
+
seen.add(item.hook);
|
|
5810
|
+
return true;
|
|
5811
|
+
});
|
|
5812
|
+
});
|
|
5813
|
+
}
|
|
5583
5814
|
var PackageDiscoveryService = class {
|
|
5584
5815
|
config;
|
|
5585
5816
|
constructor(config) {
|
|
@@ -5675,6 +5906,7 @@ var PackageDiscoveryService = class {
|
|
|
5675
5906
|
}
|
|
5676
5907
|
const effects = Array.isArray(pkgJson.standardagent.effects) && pkgJson.standardagent.effects.every((effectName) => typeof effectName === "string") ? pkgJson.standardagent.effects : void 0;
|
|
5677
5908
|
const threadEndpoints = Array.isArray(pkgJson.standardagent.threadEndpoints) && pkgJson.standardagent.threadEndpoints.every((endpoint) => typeof endpoint === "string") ? pkgJson.standardagent.threadEndpoints : void 0;
|
|
5909
|
+
const parentHooks = validParentHooks(pkgJson.standardagent.parentHooks) ? pkgJson.standardagent.parentHooks : void 0;
|
|
5678
5910
|
return {
|
|
5679
5911
|
packageId: pkgJson.name || pkgName,
|
|
5680
5912
|
version: pkgJson.version || "0.0.0",
|
|
@@ -5683,6 +5915,7 @@ var PackageDiscoveryService = class {
|
|
|
5683
5915
|
entryAgents: pkgJson.standardagent.entryAgents,
|
|
5684
5916
|
...effects ? { effects } : {},
|
|
5685
5917
|
...threadEndpoints ? { threadEndpoints } : {},
|
|
5918
|
+
...parentHooks ? { parentHooks } : {},
|
|
5686
5919
|
description: pkgJson.description
|
|
5687
5920
|
};
|
|
5688
5921
|
} catch (error) {
|
|
@@ -5744,6 +5977,7 @@ var PackageDiscoveryService = class {
|
|
|
5744
5977
|
}
|
|
5745
5978
|
const effects = Array.isArray(pkgJson.standardagent.effects) && pkgJson.standardagent.effects.every((effectName) => typeof effectName === "string") ? pkgJson.standardagent.effects : void 0;
|
|
5746
5979
|
const threadEndpoints = Array.isArray(pkgJson.standardagent.threadEndpoints) && pkgJson.standardagent.threadEndpoints.every((endpoint) => typeof endpoint === "string") ? pkgJson.standardagent.threadEndpoints : void 0;
|
|
5980
|
+
const parentHooks = validParentHooks(pkgJson.standardagent.parentHooks) ? pkgJson.standardagent.parentHooks : void 0;
|
|
5747
5981
|
return {
|
|
5748
5982
|
packageId: pkgJson.name || dirName,
|
|
5749
5983
|
version: pkgJson.version || "0.0.0",
|
|
@@ -5752,6 +5986,7 @@ var PackageDiscoveryService = class {
|
|
|
5752
5986
|
entryAgents: pkgJson.standardagent.entryAgents,
|
|
5753
5987
|
...effects ? { effects } : {},
|
|
5754
5988
|
...threadEndpoints ? { threadEndpoints } : {},
|
|
5989
|
+
...parentHooks ? { parentHooks } : {},
|
|
5755
5990
|
description: pkgJson.description
|
|
5756
5991
|
};
|
|
5757
5992
|
} catch (error) {
|
|
@@ -5780,7 +6015,8 @@ var PackageDiscoveryService = class {
|
|
|
5780
6015
|
const hasValidEntryAgents = Array.isArray(f.entryAgents) && f.entryAgents.length > 0 && f.entryAgents.every((e) => typeof e === "string");
|
|
5781
6016
|
const hasValidEffects = f.effects === void 0 || Array.isArray(f.effects) && f.effects.every((effectName) => typeof effectName === "string");
|
|
5782
6017
|
const hasValidThreadEndpoints = f.threadEndpoints === void 0 || Array.isArray(f.threadEndpoints) && f.threadEndpoints.every((endpoint) => typeof endpoint === "string");
|
|
5783
|
-
|
|
6018
|
+
const hasValidParentHooks = f.parentHooks === void 0 || validParentHooks(f.parentHooks);
|
|
6019
|
+
return hasValidEntryAgents && hasValidEffects && hasValidThreadEndpoints && hasValidParentHooks;
|
|
5784
6020
|
}
|
|
5785
6021
|
/**
|
|
5786
6022
|
* Get a package by ID.
|
|
@@ -7335,13 +7571,13 @@ async function loadRegistryVirtualModule(context) {
|
|
|
7335
7571
|
const absPath = toAbsolutePath(importPath);
|
|
7336
7572
|
return ` "${name}": async () => (await import("${absPath}")).default,`;
|
|
7337
7573
|
}).join("\n");
|
|
7338
|
-
const
|
|
7574
|
+
const projectRoot = process.cwd();
|
|
7339
7575
|
const packedPackages = [];
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7576
|
+
{
|
|
7577
|
+
const packageDirs = discoverStandardAgentPackageDirectories(projectRoot);
|
|
7578
|
+
console.log(`[vite-plugin-agent] Found Standard Agent package dirs: ${packageDirs.map((pkg) => pkg.path).join(", ")}`);
|
|
7579
|
+
for (const discovered of packageDirs) {
|
|
7580
|
+
const pkgPath = discovered.path;
|
|
7345
7581
|
const pkgJsonPath = path9__default.join(pkgPath, "package.json");
|
|
7346
7582
|
if (fs9__default.existsSync(pkgJsonPath)) {
|
|
7347
7583
|
try {
|
|
@@ -7355,6 +7591,7 @@ async function loadRegistryVirtualModule(context) {
|
|
|
7355
7591
|
const pkg = {
|
|
7356
7592
|
packageId: pkgJson.name,
|
|
7357
7593
|
version: pkgJson.version,
|
|
7594
|
+
source: discovered.source,
|
|
7358
7595
|
entryAgents: pkgJson.standardagent.entryAgents || [],
|
|
7359
7596
|
items: {
|
|
7360
7597
|
agents: scanPackedDistDirectory(pkgPath, outputDir, "agents"),
|
|
@@ -7373,15 +7610,13 @@ async function loadRegistryVirtualModule(context) {
|
|
|
7373
7610
|
}
|
|
7374
7611
|
}
|
|
7375
7612
|
}
|
|
7376
|
-
} else {
|
|
7377
|
-
console.log(`[vite-plugin-agent] Packed directory does not exist: ${packedDir}`);
|
|
7378
7613
|
}
|
|
7379
7614
|
console.log(`[vite-plugin-agent] Total packed packages found: ${packedPackages.length}`);
|
|
7380
7615
|
const packagesCode = packedPackages.map((pkg) => {
|
|
7381
7616
|
const signature = JSON.stringify({
|
|
7382
7617
|
packageId: pkg.packageId,
|
|
7383
7618
|
version: pkg.version,
|
|
7384
|
-
source:
|
|
7619
|
+
source: pkg.source,
|
|
7385
7620
|
packedAt: Date.now()
|
|
7386
7621
|
});
|
|
7387
7622
|
const genLoaders = (items) => items.map(
|
|
@@ -7480,9 +7715,9 @@ async function loadRoutesVirtualModule(context) {
|
|
|
7480
7715
|
);`;
|
|
7481
7716
|
}).join("\n");
|
|
7482
7717
|
const packedThreadRoutes = [];
|
|
7483
|
-
const
|
|
7484
|
-
const
|
|
7485
|
-
|
|
7718
|
+
const packedPackageDirs = discoverStandardAgentPackageDirectories(process.cwd());
|
|
7719
|
+
for (const discovered of packedPackageDirs) {
|
|
7720
|
+
const packagePath = discovered.path;
|
|
7486
7721
|
const packageJsonPath = path9__default.join(packagePath, "package.json");
|
|
7487
7722
|
if (!fs9__default.existsSync(packageJsonPath)) {
|
|
7488
7723
|
continue;
|