@dahura/super-agent-kit 0.1.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/LICENSE +21 -0
- package/dist/define.d.ts +57 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +303 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs.d.ts +79 -0
- package/dist/inputs.d.ts.map +1 -0
- package/dist/inputs.js +17 -0
- package/dist/inputs.js.map +1 -0
- package/dist/provider.d.ts +181 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +159 -0
- package/dist/provider.js.map +1 -0
- package/dist/types.d.ts +376 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SuperAgent contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { InputsSchema } from "./inputs";
|
|
2
|
+
import type { AgentDefinition, AgentModule, WorkflowCadence, WorkflowDefinition, WorkflowDuration, WorkflowHostSchema, WorkflowModule } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Validation errors thrown synchronously when `defineAgent` is given an
|
|
5
|
+
* inconsistent definition. These should never reach end users — they fail
|
|
6
|
+
* fast at module-load time so the compiler refuses to bundle a broken agent.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AgentDefinitionError extends Error {
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class WorkflowDefinitionError extends Error {
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Match a single model identifier against a glob pattern.
|
|
16
|
+
* Supported wildcards: `*` (provider segment or any chars in model id),
|
|
17
|
+
* `**` (multi-segment / any chars).
|
|
18
|
+
*
|
|
19
|
+
* Model ids are `provider/model`. Some local OpenAI-compatible servers expose
|
|
20
|
+
* namespaced model ids like `local/qwen/qwen3.5-9b`, so the model portion is
|
|
21
|
+
* treated as an opaque identifier rather than a path with slash-separated
|
|
22
|
+
* segments.
|
|
23
|
+
*
|
|
24
|
+
* Examples:
|
|
25
|
+
* matchModelPattern('local/*', 'local/qwen3.5-2b') -> true
|
|
26
|
+
* matchModelPattern('local/*', 'openai/gpt-5.4') -> false
|
|
27
|
+
* matchModelPattern('openai/*', 'openai/gpt-5.4') -> true
|
|
28
|
+
*/
|
|
29
|
+
export declare function matchModelPattern(pattern: string, modelId: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The author-facing factory. Authors call this in their agent module's
|
|
32
|
+
* default export. TypeScript binds the inputs schema generic so the `run`
|
|
33
|
+
* function receives correctly-typed `inputs`.
|
|
34
|
+
*
|
|
35
|
+
* The returned `AgentModule` is a thin wrapper — the actual executable
|
|
36
|
+
* client is materialized by `@dahura/super-agent-runtime` when consumers import it.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* export default defineAgent({
|
|
40
|
+
* meta: { id: 'transcript-agent', exportName: 'transcriptAgent', version: '1.0.0', description: '...' },
|
|
41
|
+
* inputs: { audio: { max: 1, formats: ['wav', 'mp3'] } },
|
|
42
|
+
* output: { default: 'text' },
|
|
43
|
+
* model: { default: 'local/whisper-base', allow: ['local/*'] },
|
|
44
|
+
* async run({ inputs, query, model }) { ... },
|
|
45
|
+
* });
|
|
46
|
+
*/
|
|
47
|
+
export declare function defineAgent<TInputs extends InputsSchema, TOutput = unknown>(definition: AgentDefinition<TInputs, TOutput>): AgentModule<TInputs, TOutput>;
|
|
48
|
+
export declare const workflow: {
|
|
49
|
+
duration: {
|
|
50
|
+
milliseconds(value: number): WorkflowDuration;
|
|
51
|
+
seconds(value: number): WorkflowDuration;
|
|
52
|
+
minutes(value: number): WorkflowDuration;
|
|
53
|
+
};
|
|
54
|
+
cadence(input: WorkflowCadence): WorkflowCadence;
|
|
55
|
+
};
|
|
56
|
+
export declare function defineWorkflow<TEvents extends WorkflowDefinition["events"], THost extends WorkflowHostSchema | undefined = WorkflowHostSchema | undefined, TState = unknown>(definition: WorkflowDefinition<TEvents, THost, TState>): WorkflowModule<TEvents, THost, TState>;
|
|
57
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IACpC,IAAI,SAA0B;CACxC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IACvC,IAAI,SAA6B;CAC3C;AAyED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAiB3E;AAuMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,OAAO,SAAS,YAAY,EAC5B,OAAO,GAAG,OAAO,EAEjB,UAAU,EAAE,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,GAC5C,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAa/B;AAED,eAAO,MAAM,QAAQ;;4BAEG,MAAM,GAAG,gBAAgB;uBAG9B,MAAM,GAAG,gBAAgB;uBAGzB,MAAM,GAAG,gBAAgB;;mBAI3B,eAAe,GAAG,eAAe;CAIjD,CAAC;AAEF,wBAAgB,cAAc,CAC5B,OAAO,SAAS,kBAAkB,CAAC,QAAQ,CAAC,EAC5C,KAAK,SAAS,kBAAkB,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,EAC7E,MAAM,GAAG,OAAO,EAEhB,UAAU,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GACrD,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAaxC"}
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation errors thrown synchronously when `defineAgent` is given an
|
|
3
|
+
* inconsistent definition. These should never reach end users — they fail
|
|
4
|
+
* fast at module-load time so the compiler refuses to bundle a broken agent.
|
|
5
|
+
*/
|
|
6
|
+
export class AgentDefinitionError extends Error {
|
|
7
|
+
name = "AgentDefinitionError";
|
|
8
|
+
}
|
|
9
|
+
export class WorkflowDefinitionError extends Error {
|
|
10
|
+
name = "WorkflowDefinitionError";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Validate the meta section of an agent definition. Performs runtime checks
|
|
14
|
+
* that complement TypeScript's compile-time guarantees (e.g. a JS-valid
|
|
15
|
+
* camelCase identifier for the export name).
|
|
16
|
+
*/
|
|
17
|
+
function validateMeta(meta) {
|
|
18
|
+
if (!meta || typeof meta !== "object") {
|
|
19
|
+
throw new AgentDefinitionError("meta is required");
|
|
20
|
+
}
|
|
21
|
+
if (!meta.id || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(meta.id)) {
|
|
22
|
+
throw new AgentDefinitionError(`meta.id must be kebab-case (got: ${JSON.stringify(meta.id)})`);
|
|
23
|
+
}
|
|
24
|
+
if (!meta.exportName || !/^[a-z][a-zA-Z0-9]*$/.test(meta.exportName)) {
|
|
25
|
+
throw new AgentDefinitionError(`meta.exportName must be a camelCase JS identifier (got: ${JSON.stringify(meta.exportName)})`);
|
|
26
|
+
}
|
|
27
|
+
if (!meta.version || !/^\d+\.\d+\.\d+/.test(meta.version)) {
|
|
28
|
+
throw new AgentDefinitionError(`meta.version must be semver (got: ${JSON.stringify(meta.version)})`);
|
|
29
|
+
}
|
|
30
|
+
if (!meta.description || meta.description.length === 0) {
|
|
31
|
+
throw new AgentDefinitionError("meta.description is required");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function validateWorkflowMeta(meta) {
|
|
35
|
+
try {
|
|
36
|
+
validateMeta(meta);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new WorkflowDefinitionError(error instanceof Error ? error.message : String(error));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate that the model policy default is covered by the allow list.
|
|
44
|
+
*
|
|
45
|
+
* `allow` patterns use simple glob: `*` matches one path segment,
|
|
46
|
+
* `**` matches any chars. We compile to a RegExp here.
|
|
47
|
+
*/
|
|
48
|
+
function validateModelPolicy(model) {
|
|
49
|
+
if (!model || typeof model !== "object") {
|
|
50
|
+
throw new AgentDefinitionError("model policy is required");
|
|
51
|
+
}
|
|
52
|
+
if (!model.default) {
|
|
53
|
+
throw new AgentDefinitionError("model.default is required");
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(model.allow) || model.allow.length === 0) {
|
|
56
|
+
throw new AgentDefinitionError("model.allow must be a non-empty array (use ['<provider>/*'] for permissive)");
|
|
57
|
+
}
|
|
58
|
+
const matches = model.allow.some((pattern) => matchModelPattern(pattern, model.default));
|
|
59
|
+
if (!matches) {
|
|
60
|
+
throw new AgentDefinitionError(`model.default "${model.default}" is not covered by model.allow ${JSON.stringify(model.allow)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Match a single model identifier against a glob pattern.
|
|
65
|
+
* Supported wildcards: `*` (provider segment or any chars in model id),
|
|
66
|
+
* `**` (multi-segment / any chars).
|
|
67
|
+
*
|
|
68
|
+
* Model ids are `provider/model`. Some local OpenAI-compatible servers expose
|
|
69
|
+
* namespaced model ids like `local/qwen/qwen3.5-9b`, so the model portion is
|
|
70
|
+
* treated as an opaque identifier rather than a path with slash-separated
|
|
71
|
+
* segments.
|
|
72
|
+
*
|
|
73
|
+
* Examples:
|
|
74
|
+
* matchModelPattern('local/*', 'local/qwen3.5-2b') -> true
|
|
75
|
+
* matchModelPattern('local/*', 'openai/gpt-5.4') -> false
|
|
76
|
+
* matchModelPattern('openai/*', 'openai/gpt-5.4') -> true
|
|
77
|
+
*/
|
|
78
|
+
export function matchModelPattern(pattern, modelId) {
|
|
79
|
+
const patternSlash = pattern.indexOf("/");
|
|
80
|
+
const modelSlash = modelId.indexOf("/");
|
|
81
|
+
if (patternSlash === -1 || modelSlash === -1) {
|
|
82
|
+
return compileGlob(pattern, false).test(modelId);
|
|
83
|
+
}
|
|
84
|
+
const patternProvider = pattern.slice(0, patternSlash);
|
|
85
|
+
const patternModel = pattern.slice(patternSlash + 1);
|
|
86
|
+
const modelProvider = modelId.slice(0, modelSlash);
|
|
87
|
+
const concreteModel = modelId.slice(modelSlash + 1);
|
|
88
|
+
return (compileGlob(patternProvider, false).test(modelProvider) &&
|
|
89
|
+
compileGlob(patternModel, true).test(concreteModel));
|
|
90
|
+
}
|
|
91
|
+
function compileGlob(pattern, starMatchesSlash) {
|
|
92
|
+
const starPattern = starMatchesSlash ? ".*" : "[^/]+";
|
|
93
|
+
const regexSrc = pattern
|
|
94
|
+
.split("**")
|
|
95
|
+
.map((part) => part
|
|
96
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
97
|
+
.replace(/\*/g, starPattern))
|
|
98
|
+
.join(".*");
|
|
99
|
+
return new RegExp(`^${regexSrc}$`);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Validate the output declaration. For `default: 'json'` an explicit Zod
|
|
103
|
+
* schema is required; the compiler will serialize it to JSON Schema.
|
|
104
|
+
*/
|
|
105
|
+
function validateOutput(output) {
|
|
106
|
+
if (!output || typeof output !== "object") {
|
|
107
|
+
throw new AgentDefinitionError("output declaration is required");
|
|
108
|
+
}
|
|
109
|
+
if (output.default === "json") {
|
|
110
|
+
if (!("schema" in output) || !output.schema) {
|
|
111
|
+
throw new AgentDefinitionError("output.default = 'json' requires output.schema (a zod type)");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (output.default !== "text") {
|
|
115
|
+
throw new AgentDefinitionError(`output.default must be "text" or "json" (got: ${JSON.stringify(output.default)})`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function validateProcessors(processors) {
|
|
119
|
+
if (!processors)
|
|
120
|
+
return;
|
|
121
|
+
const seen = new Set();
|
|
122
|
+
for (const processor of processors) {
|
|
123
|
+
if (!processor.id || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(processor.id)) {
|
|
124
|
+
throw new AgentDefinitionError(`processor.id must be kebab-case (got: ${JSON.stringify(processor.id)})`);
|
|
125
|
+
}
|
|
126
|
+
if (!processor.description || processor.description.length === 0) {
|
|
127
|
+
throw new AgentDefinitionError(`processor "${processor.id}" must have a description`);
|
|
128
|
+
}
|
|
129
|
+
if (processor.phase !== "before" && processor.phase !== "after") {
|
|
130
|
+
throw new AgentDefinitionError(`processor "${processor.id}" phase must be "before" or "after"`);
|
|
131
|
+
}
|
|
132
|
+
if (seen.has(processor.id)) {
|
|
133
|
+
throw new AgentDefinitionError(`duplicate processor id "${processor.id}"`);
|
|
134
|
+
}
|
|
135
|
+
seen.add(processor.id);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function validateSubagents(subagents) {
|
|
139
|
+
if (!subagents)
|
|
140
|
+
return;
|
|
141
|
+
const seen = new Set();
|
|
142
|
+
for (const subagent of subagents) {
|
|
143
|
+
if (!subagent.id || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(subagent.id)) {
|
|
144
|
+
throw new AgentDefinitionError(`subagent.id must be kebab-case (got: ${JSON.stringify(subagent.id)})`);
|
|
145
|
+
}
|
|
146
|
+
if (!subagent.description || subagent.description.length === 0) {
|
|
147
|
+
throw new AgentDefinitionError(`subagent "${subagent.id}" must have a description`);
|
|
148
|
+
}
|
|
149
|
+
if (seen.has(subagent.id)) {
|
|
150
|
+
throw new AgentDefinitionError(`duplicate subagent id "${subagent.id}"`);
|
|
151
|
+
}
|
|
152
|
+
seen.add(subagent.id);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function validateWorkflowEvents(events) {
|
|
156
|
+
if (!events || typeof events !== "object" || Array.isArray(events)) {
|
|
157
|
+
throw new WorkflowDefinitionError("events must be an object map");
|
|
158
|
+
}
|
|
159
|
+
const entries = Object.entries(events);
|
|
160
|
+
if (entries.length === 0) {
|
|
161
|
+
throw new WorkflowDefinitionError("events must declare at least one event");
|
|
162
|
+
}
|
|
163
|
+
for (const [name, schema] of entries) {
|
|
164
|
+
if (!/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/.test(name)) {
|
|
165
|
+
throw new WorkflowDefinitionError(`workflow event "${name}" must use dot-separated lowercase segments`);
|
|
166
|
+
}
|
|
167
|
+
if (!schema || typeof schema !== "object") {
|
|
168
|
+
throw new WorkflowDefinitionError(`workflow event "${name}" must have a zod schema`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function validateWorkflowHost(host) {
|
|
173
|
+
if (!host)
|
|
174
|
+
return;
|
|
175
|
+
for (const [name, declaration] of Object.entries(host)) {
|
|
176
|
+
if (!/^[a-z][a-zA-Z0-9]*$/.test(name)) {
|
|
177
|
+
throw new WorkflowDefinitionError(`host adapter "${name}" must be a camelCase identifier`);
|
|
178
|
+
}
|
|
179
|
+
if (!declaration || typeof declaration !== "object") {
|
|
180
|
+
throw new WorkflowDefinitionError(`host adapter "${name}" must declare a zod function`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function validateWorkflowCadence(cadence) {
|
|
185
|
+
if (!cadence)
|
|
186
|
+
return;
|
|
187
|
+
if (!cadence.id || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(cadence.id)) {
|
|
188
|
+
throw new WorkflowDefinitionError(`workflow cadence id must be kebab-case (got: ${JSON.stringify(cadence.id)})`);
|
|
189
|
+
}
|
|
190
|
+
if (!cadence.description || cadence.description.length === 0) {
|
|
191
|
+
throw new WorkflowDefinitionError(`workflow cadence "${cadence.id}" must have a description`);
|
|
192
|
+
}
|
|
193
|
+
if (!cadence.every || typeof cadence.every.ms !== "number" || cadence.every.ms <= 0) {
|
|
194
|
+
throw new WorkflowDefinitionError(`workflow cadence "${cadence.id}" must declare a positive duration`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function validateWorkflowNodes(definition) {
|
|
198
|
+
if (!Array.isArray(definition.nodes) || definition.nodes.length === 0) {
|
|
199
|
+
throw new WorkflowDefinitionError("nodes must be a non-empty array");
|
|
200
|
+
}
|
|
201
|
+
const knownEvents = new Set(Object.keys(definition.events));
|
|
202
|
+
const seen = new Set();
|
|
203
|
+
for (const node of definition.nodes) {
|
|
204
|
+
if (!node.id || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(node.id)) {
|
|
205
|
+
throw new WorkflowDefinitionError(`workflow node id must be kebab-case (got: ${JSON.stringify(node.id)})`);
|
|
206
|
+
}
|
|
207
|
+
if (seen.has(node.id)) {
|
|
208
|
+
throw new WorkflowDefinitionError(`duplicate workflow node id "${node.id}"`);
|
|
209
|
+
}
|
|
210
|
+
seen.add(node.id);
|
|
211
|
+
const triggers = Array.isArray(node.on) ? node.on : [node.on];
|
|
212
|
+
if (triggers.length === 0) {
|
|
213
|
+
throw new WorkflowDefinitionError(`workflow node "${node.id}" must declare at least one trigger`);
|
|
214
|
+
}
|
|
215
|
+
for (const eventName of triggers) {
|
|
216
|
+
if (!knownEvents.has(eventName)) {
|
|
217
|
+
throw new WorkflowDefinitionError(`workflow node "${node.id}" references unknown trigger event "${eventName}"`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const emits = node.emits
|
|
221
|
+
? Array.isArray(node.emits)
|
|
222
|
+
? node.emits
|
|
223
|
+
: [node.emits]
|
|
224
|
+
: [];
|
|
225
|
+
for (const eventName of emits) {
|
|
226
|
+
if (!knownEvents.has(eventName)) {
|
|
227
|
+
throw new WorkflowDefinitionError(`workflow node "${node.id}" references unknown emitted event "${eventName}"`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
validateWorkflowCadence(node.policy?.cadence);
|
|
231
|
+
if (typeof node.run !== "function") {
|
|
232
|
+
throw new WorkflowDefinitionError(`workflow node "${node.id}" run must be a function`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function validateWorkflowOutput(output) {
|
|
237
|
+
if (typeof output !== "function") {
|
|
238
|
+
throw new WorkflowDefinitionError("workflow output must be a function");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The author-facing factory. Authors call this in their agent module's
|
|
243
|
+
* default export. TypeScript binds the inputs schema generic so the `run`
|
|
244
|
+
* function receives correctly-typed `inputs`.
|
|
245
|
+
*
|
|
246
|
+
* The returned `AgentModule` is a thin wrapper — the actual executable
|
|
247
|
+
* client is materialized by `@dahura/super-agent-runtime` when consumers import it.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* export default defineAgent({
|
|
251
|
+
* meta: { id: 'transcript-agent', exportName: 'transcriptAgent', version: '1.0.0', description: '...' },
|
|
252
|
+
* inputs: { audio: { max: 1, formats: ['wav', 'mp3'] } },
|
|
253
|
+
* output: { default: 'text' },
|
|
254
|
+
* model: { default: 'local/whisper-base', allow: ['local/*'] },
|
|
255
|
+
* async run({ inputs, query, model }) { ... },
|
|
256
|
+
* });
|
|
257
|
+
*/
|
|
258
|
+
export function defineAgent(definition) {
|
|
259
|
+
validateMeta(definition.meta);
|
|
260
|
+
validateModelPolicy(definition.model);
|
|
261
|
+
validateOutput(definition.output);
|
|
262
|
+
validateProcessors(definition.processors);
|
|
263
|
+
validateSubagents(definition.subagents);
|
|
264
|
+
if (typeof definition.run !== "function") {
|
|
265
|
+
throw new AgentDefinitionError("run must be a function");
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
__isAgent: true,
|
|
269
|
+
definition,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
export const workflow = {
|
|
273
|
+
duration: {
|
|
274
|
+
milliseconds(value) {
|
|
275
|
+
return { ms: value };
|
|
276
|
+
},
|
|
277
|
+
seconds(value) {
|
|
278
|
+
return { ms: value * 1000 };
|
|
279
|
+
},
|
|
280
|
+
minutes(value) {
|
|
281
|
+
return { ms: value * 60 * 1000 };
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
cadence(input) {
|
|
285
|
+
validateWorkflowCadence(input);
|
|
286
|
+
return input;
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
export function defineWorkflow(definition) {
|
|
290
|
+
validateWorkflowMeta(definition.meta);
|
|
291
|
+
validateWorkflowEvents(definition.events);
|
|
292
|
+
validateWorkflowHost(definition.host);
|
|
293
|
+
if (!definition.state || typeof definition.state.initial !== "function") {
|
|
294
|
+
throw new WorkflowDefinitionError("workflow state.initial must be a function");
|
|
295
|
+
}
|
|
296
|
+
validateWorkflowNodes(definition);
|
|
297
|
+
validateWorkflowOutput(definition.output);
|
|
298
|
+
return {
|
|
299
|
+
__isWorkflow: true,
|
|
300
|
+
definition,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,GAAG,sBAAsB,CAAC;CACxC;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACvC,IAAI,GAAG,yBAAyB,CAAC;CAC3C;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAA6B;IACjD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,oBAAoB,CAC5B,oCAAoC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI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AAC,UAAU,CAAC,CAAC;IAClC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,UAAU;KACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dahura/super-agent-kit — SDK for agent authors.
|
|
3
|
+
*
|
|
4
|
+
* Authors import `defineAgent` (typed factory) and `z` (zod re-export) from
|
|
5
|
+
* this package. They never need to depend on @dahura/super-agent-runtime directly —
|
|
6
|
+
* the runtime materializes their definitions on the consumer side.
|
|
7
|
+
*/
|
|
8
|
+
export { defineAgent, defineWorkflow, workflow, AgentDefinitionError, WorkflowDefinitionError, matchModelPattern, } from "./define";
|
|
9
|
+
export type { AgentDefinition, AgentMeta, AgentManifest, AgentModule, AgentRunContext, AgentLogger, AgentRequireRuntime, AiSdkModelRequirement, CustomModelRequirement, ProcessorDefinition, ProcessorPhase, ProcessorStep, ProcessorRuntime, ProcessorSelection, ProcessorMode, SubagentDefinition, SubagentMode, SubagentSelection, SubagentRuntime, SubagentStep, SubagentStepResult, SubagentTraceEntry, SubagentTraceChange, SubagentUsage, ModelPolicy, OutputDecl, FixtureEntry, FixtureInputs, WorkflowMeta, WorkflowEventSchemas, WorkflowHostSchema, WorkflowDuration, WorkflowCadence, WorkflowNodePolicy, WorkflowOutputSelector, WorkflowStateDecl, WorkflowEventEnvelope, WorkflowAskLike, WorkflowAgentLike, WorkflowNodeRunContext, WorkflowNode, WorkflowDefinition, WorkflowManifest, WorkflowModule, } from "./types";
|
|
10
|
+
export type { InputsSchema, ImageInputDecl, AudioInputDecl, TextInputDecl, FileInputDecl, InputItem, RuntimeInputs, } from "./inputs";
|
|
11
|
+
export { DEFAULT_IMAGE_FORMATS, DEFAULT_AUDIO_FORMATS, } from "./inputs";
|
|
12
|
+
export { defineProvider, isProviderModule, providerToManifest, ProviderDefinitionError, } from "./provider";
|
|
13
|
+
export type { ProviderKind, ProviderCapability, ProviderMeta, ProviderEnvVar, ProviderEnvSchema, ProviderModelDiscovery, ProviderProbeResult, ProviderConfig, ProviderDefinition, ProviderModule, ProviderManifest, } from "./provider";
|
|
14
|
+
export { z } from "zod";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,eAAe,EACf,SAAS,EACT,aAAa,EACb,WAAW,EACX,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,EACT,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dahura/super-agent-kit — SDK for agent authors.
|
|
3
|
+
*
|
|
4
|
+
* Authors import `defineAgent` (typed factory) and `z` (zod re-export) from
|
|
5
|
+
* this package. They never need to depend on @dahura/super-agent-runtime directly —
|
|
6
|
+
* the runtime materializes their definitions on the consumer side.
|
|
7
|
+
*/
|
|
8
|
+
export { defineAgent, defineWorkflow, workflow, AgentDefinitionError, WorkflowDefinitionError, matchModelPattern, } from "./define";
|
|
9
|
+
export { DEFAULT_IMAGE_FORMATS, DEFAULT_AUDIO_FORMATS, } from "./inputs";
|
|
10
|
+
// Provider definition types and factory
|
|
11
|
+
export { defineProvider, isProviderModule, providerToManifest, ProviderDefinitionError, } from "./provider";
|
|
12
|
+
// One source of truth for zod across kit, agents, and consumer code.
|
|
13
|
+
export { z } from "zod";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAwDlB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,wCAAwC;AACxC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAepB,qEAAqE;AACrE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/inputs.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input declarations for agents.
|
|
3
|
+
*
|
|
4
|
+
* Each agent declares which inputs it accepts. The shape of `inputs` in the
|
|
5
|
+
* agent definition drives:
|
|
6
|
+
* 1. Which `loadXxx()` methods are available on the agent client.
|
|
7
|
+
* 2. The maximum number of items per loader.
|
|
8
|
+
* 3. UI form generation in the Playground.
|
|
9
|
+
* 4. Runtime input validation at the boundary.
|
|
10
|
+
*/
|
|
11
|
+
export type ImageInputDecl = {
|
|
12
|
+
/** Maximum number of images allowed for a single ask. Defaults to 1. */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** Allowed file format extensions (lowercase, no dot). Defaults to png + jpeg. */
|
|
15
|
+
formats?: ReadonlyArray<"png" | "jpeg" | "jpg" | "webp" | "gif">;
|
|
16
|
+
};
|
|
17
|
+
export type AudioInputDecl = {
|
|
18
|
+
/** Maximum number of audio chunks allowed for a single ask. Defaults to 1. */
|
|
19
|
+
max?: number;
|
|
20
|
+
/** Allowed file format extensions. Defaults to wav + mp3 + m4a. */
|
|
21
|
+
formats?: ReadonlyArray<"wav" | "mp3" | "m4a" | "flac" | "ogg">;
|
|
22
|
+
/** Maximum duration per chunk in seconds. Optional. */
|
|
23
|
+
maxDurationSec?: number;
|
|
24
|
+
};
|
|
25
|
+
export type TextInputDecl = {
|
|
26
|
+
/** Whether the text input is required for any ask. Defaults to false. */
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** Soft maximum byte length of the text payload. Optional. */
|
|
29
|
+
maxBytes?: number;
|
|
30
|
+
};
|
|
31
|
+
export type FileInputDecl = {
|
|
32
|
+
/** Maximum number of files. Defaults to 1. */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** Allowed mime types as glob-like patterns (e.g. "application/json", "text/*"). */
|
|
35
|
+
mimeTypes?: ReadonlyArray<string>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The full inputs schema declared by an agent. All fields are optional;
|
|
39
|
+
* an agent that declares none is a "text-only" agent driven by the `query` only.
|
|
40
|
+
*/
|
|
41
|
+
export type InputsSchema = {
|
|
42
|
+
image?: ImageInputDecl;
|
|
43
|
+
audio?: AudioInputDecl;
|
|
44
|
+
text?: TextInputDecl;
|
|
45
|
+
file?: FileInputDecl;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A single normalized input item passed to the agent's `run` function at
|
|
49
|
+
* runtime. The runtime is responsible for reading file paths or URLs and
|
|
50
|
+
* producing this representation.
|
|
51
|
+
*/
|
|
52
|
+
export type InputItem<TKind extends "image" | "audio" | "text" | "file"> = {
|
|
53
|
+
kind: TKind;
|
|
54
|
+
/** Original source descriptor (file path, URL, or "<inline>" for buffers). */
|
|
55
|
+
source: string;
|
|
56
|
+
/** Inferred mime type. */
|
|
57
|
+
mime: string;
|
|
58
|
+
/** Binary payload for image/audio/file. Empty for text. */
|
|
59
|
+
data: Uint8Array;
|
|
60
|
+
/** Decoded UTF-8 text for text inputs (null otherwise). */
|
|
61
|
+
text: string | null;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The shape of `inputs` passed into agent.run() — keyed by input kind, with
|
|
65
|
+
* arrays of normalized items. Empty arrays mean "loader was not called".
|
|
66
|
+
*/
|
|
67
|
+
export type RuntimeInputs = {
|
|
68
|
+
image: ReadonlyArray<InputItem<"image">>;
|
|
69
|
+
audio: ReadonlyArray<InputItem<"audio">>;
|
|
70
|
+
text: ReadonlyArray<InputItem<"text">>;
|
|
71
|
+
file: ReadonlyArray<InputItem<"file">>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Default values for input declarations. Used by both manifest emission and
|
|
75
|
+
* runtime validation so the two cannot drift.
|
|
76
|
+
*/
|
|
77
|
+
export declare const DEFAULT_IMAGE_FORMATS: ReadonlyArray<string>;
|
|
78
|
+
export declare const DEFAULT_AUDIO_FORMATS: ReadonlyArray<string>;
|
|
79
|
+
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;CAClE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,CAAC,EAAE,aAAa,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;IAChE,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,IAAI;IACzE,IAAI,EAAE,KAAK,CAAC;IACZ,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,IAAI,EAAE,UAAU,CAAC;IACjB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAA0B,CAAC;AACnF,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAyB,CAAC"}
|
package/dist/inputs.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input declarations for agents.
|
|
3
|
+
*
|
|
4
|
+
* Each agent declares which inputs it accepts. The shape of `inputs` in the
|
|
5
|
+
* agent definition drives:
|
|
6
|
+
* 1. Which `loadXxx()` methods are available on the agent client.
|
|
7
|
+
* 2. The maximum number of items per loader.
|
|
8
|
+
* 3. UI form generation in the Playground.
|
|
9
|
+
* 4. Runtime input validation at the boundary.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Default values for input declarations. Used by both manifest emission and
|
|
13
|
+
* runtime validation so the two cannot drift.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_IMAGE_FORMATS = ["png", "jpeg", "jpg"];
|
|
16
|
+
export const DEFAULT_AUDIO_FORMATS = ["wav", "mp3", "m4a"];
|
|
17
|
+
//# sourceMappingURL=inputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.js","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuEH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC"}
|