@standardagents/spec 0.39.1 → 0.40.1
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/index.d.ts +1235 -1156
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -337,6 +337,38 @@ function defineAgent(options) {
|
|
|
337
337
|
if (!["ai_human", "dual_ai"].includes(type)) {
|
|
338
338
|
throw new Error(`Invalid type '${type}'. Must be one of: ai_human, dual_ai`);
|
|
339
339
|
}
|
|
340
|
+
if (options.parentHooks !== void 0) {
|
|
341
|
+
if (!Array.isArray(options.parentHooks)) {
|
|
342
|
+
throw new Error("parentHooks must be an array");
|
|
343
|
+
}
|
|
344
|
+
if (type !== "dual_ai") {
|
|
345
|
+
throw new Error("parentHooks may only be declared by dual_ai agents");
|
|
346
|
+
}
|
|
347
|
+
if (!options.exposeAsTool) {
|
|
348
|
+
throw new Error("parentHooks requires exposeAsTool: true");
|
|
349
|
+
}
|
|
350
|
+
const seenParentHooks = /* @__PURE__ */ new Set();
|
|
351
|
+
for (const requirement of options.parentHooks) {
|
|
352
|
+
if (!requirement || typeof requirement !== "object") {
|
|
353
|
+
throw new Error("parentHooks entries must be objects");
|
|
354
|
+
}
|
|
355
|
+
if (!requirement.hook || typeof requirement.hook !== "string") {
|
|
356
|
+
throw new Error("parentHooks[].hook is required");
|
|
357
|
+
}
|
|
358
|
+
if (typeof requirement.reason !== "string" || !requirement.reason.trim()) {
|
|
359
|
+
throw new Error(`parentHooks reason is required for hook '${requirement.hook}'`);
|
|
360
|
+
}
|
|
361
|
+
if (requirement.stage !== void 0 && requirement.stage !== "before_parent" && requirement.stage !== "after_parent") {
|
|
362
|
+
throw new Error(
|
|
363
|
+
`Invalid parentHooks stage '${requirement.stage}' for hook '${requirement.hook}'`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
if (seenParentHooks.has(requirement.hook)) {
|
|
367
|
+
throw new Error(`Duplicate parentHooks hook '${requirement.hook}'`);
|
|
368
|
+
}
|
|
369
|
+
seenParentHooks.add(requirement.hook);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
340
372
|
validateSessionBinding("sideA", "sessionStop");
|
|
341
373
|
validateSessionBinding("sideA", "sessionFail");
|
|
342
374
|
validateSessionBinding("sideA", "sessionStatus");
|