@standardagents/spec 0.12.9 → 0.13.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/index.d.ts +513 -53
- package/dist/index.js +56 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,16 +40,37 @@ function validateToolName(name) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function defineTool(options) {
|
|
43
|
+
const variables = (options.variables ?? extractVariablesFromTenvSchema(options.tenvs ?? null)).map((entry) => ({
|
|
44
|
+
name: entry.name,
|
|
45
|
+
type: entry.type === "secret" ? "secret" : "text",
|
|
46
|
+
required: !!entry.required,
|
|
47
|
+
description: typeof entry.description === "string" ? entry.description : ""
|
|
48
|
+
}));
|
|
43
49
|
return {
|
|
44
50
|
description: options.description,
|
|
45
51
|
args: options.args ?? null,
|
|
46
52
|
execute: options.execute,
|
|
53
|
+
variables,
|
|
47
54
|
tenvs: options.tenvs ?? null,
|
|
48
55
|
executionMode: options.executionMode,
|
|
49
56
|
executionProvider: options.executionProvider,
|
|
50
57
|
uses: options.uses
|
|
51
58
|
};
|
|
52
59
|
}
|
|
60
|
+
function extractVariablesFromTenvSchema(tenvSchema) {
|
|
61
|
+
if (!tenvSchema) return [];
|
|
62
|
+
const shape = tenvSchema.shape;
|
|
63
|
+
if (!shape) return [];
|
|
64
|
+
return Object.entries(shape).map(([name, fieldSchema]) => {
|
|
65
|
+
const zodSchema = fieldSchema;
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
type: "text",
|
|
69
|
+
required: !zodSchema.isOptional(),
|
|
70
|
+
description: zodSchema.description ?? ""
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
53
74
|
|
|
54
75
|
// src/prompts.ts
|
|
55
76
|
function definePrompt(options) {
|
|
@@ -91,7 +112,17 @@ function definePrompt(options) {
|
|
|
91
112
|
if (options.recentImageThreshold !== void 0 && (options.recentImageThreshold <= 0 || !Number.isInteger(options.recentImageThreshold))) {
|
|
92
113
|
throw new Error("recentImageThreshold must be a positive integer");
|
|
93
114
|
}
|
|
94
|
-
|
|
115
|
+
const normalizedVariables = Array.isArray(options.variables) ? options.variables.map((entry) => ({
|
|
116
|
+
name: entry.name,
|
|
117
|
+
type: entry.type === "secret" ? "secret" : "text",
|
|
118
|
+
required: !!entry.required,
|
|
119
|
+
scoped: !!entry.scoped,
|
|
120
|
+
description: typeof entry.description === "string" ? entry.description : ""
|
|
121
|
+
})) : void 0;
|
|
122
|
+
return {
|
|
123
|
+
...options,
|
|
124
|
+
...normalizedVariables ? { variables: normalizedVariables } : {}
|
|
125
|
+
};
|
|
95
126
|
}
|
|
96
127
|
|
|
97
128
|
// src/hooks.ts
|
|
@@ -145,6 +176,22 @@ function defineEffect(description, argsOrHandler, maybeHandler) {
|
|
|
145
176
|
|
|
146
177
|
// src/agents.ts
|
|
147
178
|
function defineAgent(options) {
|
|
179
|
+
const validateSessionBinding = (sideLabel, sessionKey, legacyKey) => {
|
|
180
|
+
const side = options[sideLabel];
|
|
181
|
+
if (!side) return;
|
|
182
|
+
const sessionBinding = side[sessionKey];
|
|
183
|
+
const legacyBinding = side[legacyKey];
|
|
184
|
+
if (typeof sessionBinding === "object" && sessionBinding !== null && !Array.isArray(sessionBinding)) {
|
|
185
|
+
if (!("name" in sessionBinding) || typeof sessionBinding.name !== "string" || !sessionBinding.name) {
|
|
186
|
+
throw new Error(`${sideLabel}.${sessionKey}.name is required when ${sideLabel}.${sessionKey} uses object form`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (typeof sessionBinding === "string" && typeof legacyBinding === "string" && sessionBinding !== legacyBinding) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
`${sideLabel}.${sessionKey} and ${sideLabel}.${legacyKey} conflict. Use only ${sessionKey} (preferred) or keep values identical.`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
148
195
|
if (!options.name) {
|
|
149
196
|
throw new Error("Agent name is required");
|
|
150
197
|
}
|
|
@@ -187,6 +234,14 @@ function defineAgent(options) {
|
|
|
187
234
|
if (!["ai_human", "dual_ai"].includes(type)) {
|
|
188
235
|
throw new Error(`Invalid type '${type}'. Must be one of: ai_human, dual_ai`);
|
|
189
236
|
}
|
|
237
|
+
validateSessionBinding("sideA", "sessionStop", "endSessionTool");
|
|
238
|
+
validateSessionBinding("sideA", "sessionFail", "failSessionTool");
|
|
239
|
+
validateSessionBinding("sideA", "sessionStatus", "statusTool");
|
|
240
|
+
if (options.sideB) {
|
|
241
|
+
validateSessionBinding("sideB", "sessionStop", "endSessionTool");
|
|
242
|
+
validateSessionBinding("sideB", "sessionFail", "failSessionTool");
|
|
243
|
+
validateSessionBinding("sideB", "sessionStatus", "statusTool");
|
|
244
|
+
}
|
|
190
245
|
return {
|
|
191
246
|
...options,
|
|
192
247
|
type
|