@standardagents/spec 0.11.11 → 0.12.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 +496 -48
- package/dist/index.js +64 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,9 @@ function defineModel(options) {
|
|
|
3
3
|
if (!options.name) {
|
|
4
4
|
throw new Error("Model name is required");
|
|
5
5
|
}
|
|
6
|
+
if (options.name.includes("/")) {
|
|
7
|
+
throw new Error(`Model name cannot contain '/'. Reserved for namespace qualification.`);
|
|
8
|
+
}
|
|
6
9
|
if (!options.provider) {
|
|
7
10
|
throw new Error("Model provider is required");
|
|
8
11
|
}
|
|
@@ -34,6 +37,11 @@ function defineModel(options) {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
// src/tools.ts
|
|
40
|
+
function validateToolName(name) {
|
|
41
|
+
if (name.includes("/")) {
|
|
42
|
+
throw new Error(`Tool name cannot contain '/'. Reserved for namespace qualification.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
function defineTool(options) {
|
|
38
46
|
return {
|
|
39
47
|
description: options.description,
|
|
@@ -41,7 +49,8 @@ function defineTool(options) {
|
|
|
41
49
|
execute: options.execute,
|
|
42
50
|
tenvs: options.tenvs ?? null,
|
|
43
51
|
executionMode: options.executionMode,
|
|
44
|
-
executionProvider: options.executionProvider
|
|
52
|
+
executionProvider: options.executionProvider,
|
|
53
|
+
uses: options.uses
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
56
|
|
|
@@ -50,6 +59,9 @@ function definePrompt(options) {
|
|
|
50
59
|
if (!options.name) {
|
|
51
60
|
throw new Error("Prompt name is required");
|
|
52
61
|
}
|
|
62
|
+
if (options.name.includes("/")) {
|
|
63
|
+
throw new Error(`Prompt name cannot contain '/'. Reserved for namespace qualification.`);
|
|
64
|
+
}
|
|
53
65
|
if (!options.toolDescription) {
|
|
54
66
|
throw new Error("Prompt toolDescription is required");
|
|
55
67
|
}
|
|
@@ -86,24 +98,36 @@ function definePrompt(options) {
|
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
// src/hooks.ts
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!
|
|
101
|
+
var VALID_HOOKS = [
|
|
102
|
+
"filter_messages",
|
|
103
|
+
"prefilter_llm_history",
|
|
104
|
+
"before_create_message",
|
|
105
|
+
"after_create_message",
|
|
106
|
+
"before_update_message",
|
|
107
|
+
"after_update_message",
|
|
108
|
+
"before_store_tool_result",
|
|
109
|
+
"after_tool_call_success",
|
|
110
|
+
"after_tool_call_failure"
|
|
111
|
+
];
|
|
112
|
+
function defineHook(options) {
|
|
113
|
+
if (!VALID_HOOKS.includes(options.hook)) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Invalid hook type '${options.hook}'. Valid hooks: ${VALID_HOOKS.join(", ")}`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
if (!options.id || typeof options.id !== "string") {
|
|
119
|
+
throw new Error("Hook id is required and must be a non-empty string");
|
|
120
|
+
}
|
|
121
|
+
if (!/^[a-z][a-z0-9_]*$/.test(options.id)) {
|
|
102
122
|
throw new Error(
|
|
103
|
-
`
|
|
123
|
+
`Hook id '${options.id}' must be snake_case (lowercase letters, numbers, underscores, starting with letter)`
|
|
104
124
|
);
|
|
105
125
|
}
|
|
106
|
-
return
|
|
126
|
+
return {
|
|
127
|
+
hook: options.hook,
|
|
128
|
+
id: options.id,
|
|
129
|
+
execute: options.execute
|
|
130
|
+
};
|
|
107
131
|
}
|
|
108
132
|
|
|
109
133
|
// src/effects.ts
|
|
@@ -127,6 +151,9 @@ function defineAgent(options) {
|
|
|
127
151
|
if (!options.name) {
|
|
128
152
|
throw new Error("Agent name is required");
|
|
129
153
|
}
|
|
154
|
+
if (options.name.includes("/")) {
|
|
155
|
+
throw new Error(`Agent name cannot contain '/'. Reserved for namespace qualification.`);
|
|
156
|
+
}
|
|
130
157
|
if (!options.sideA) {
|
|
131
158
|
throw new Error("Agent sideA configuration is required");
|
|
132
159
|
}
|
|
@@ -215,9 +242,26 @@ function mapReasoningLevel(level, reasoningLevels) {
|
|
|
215
242
|
}
|
|
216
243
|
return reasoningLevels[nearest];
|
|
217
244
|
}
|
|
245
|
+
|
|
246
|
+
// src/packing.ts
|
|
247
|
+
function isPacked(metadata) {
|
|
248
|
+
return !!metadata?.__package;
|
|
249
|
+
}
|
|
250
|
+
function belongsToPackage(metadata, packageId) {
|
|
251
|
+
return metadata?.__package?.packageId === packageId;
|
|
252
|
+
}
|
|
253
|
+
function isVisibleInNamespace(metadata, namespace, isEntryPoint = false) {
|
|
254
|
+
const hasPkg = isPacked(metadata);
|
|
255
|
+
if (namespace.type === "global") {
|
|
256
|
+
return !hasPkg || isEntryPoint;
|
|
257
|
+
}
|
|
258
|
+
const isOwnPackage = hasPkg && metadata.__package.packageId === namespace.packageId;
|
|
259
|
+
return isOwnPackage || hasPkg && isEntryPoint;
|
|
260
|
+
}
|
|
218
261
|
export {
|
|
219
262
|
ProviderError,
|
|
220
263
|
THREAD_ENDPOINT_SYMBOL,
|
|
264
|
+
belongsToPackage,
|
|
221
265
|
defineAgent,
|
|
222
266
|
defineController,
|
|
223
267
|
defineEffect,
|
|
@@ -226,7 +270,10 @@ export {
|
|
|
226
270
|
definePrompt,
|
|
227
271
|
defineThreadEndpoint,
|
|
228
272
|
defineTool,
|
|
273
|
+
isPacked,
|
|
229
274
|
isThreadEndpoint,
|
|
230
|
-
|
|
275
|
+
isVisibleInNamespace,
|
|
276
|
+
mapReasoningLevel,
|
|
277
|
+
validateToolName
|
|
231
278
|
};
|
|
232
279
|
//# sourceMappingURL=index.js.map
|