@nylorun/core 0.1.1-beta → 0.2.0-beta
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/CHANGELOG.md +6 -0
- package/dist/contracts.d.ts +86 -2
- package/dist/contracts.js +183 -21
- package/dist/define.d.ts +3 -2
- package/dist/definition/assemble.d.ts +6 -3
- package/dist/definition/assemble.js +72 -2
- package/dist/definition/bind-agent.js +4 -3
- package/dist/definition/bound.d.ts +14 -0
- package/dist/definition/builder.d.ts +8 -5
- package/dist/definition/builder.js +7 -4
- package/dist/definition/declaration.js +23 -0
- package/dist/definition/from.d.ts +8 -1
- package/dist/definition/from.js +180 -21
- package/dist/definition/helpers.d.ts +2 -0
- package/dist/definition/helpers.js +4 -0
- package/dist/definition/manifest.d.ts +6 -2
- package/dist/definition/manifest.js +18 -15
- package/dist/definition/schema.js +6 -3
- package/dist/definition/skill-tools.d.ts +3 -0
- package/dist/definition/skill-tools.js +56 -0
- package/dist/types/agent.d.ts +1 -3
- package/dist/types/manifest.d.ts +39 -16
- package/dist/types/middleware.d.ts +19 -1
- package/dist/types/tool.d.ts +10 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.2.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a88f51: Ship Agent-Plugins (`plugin()` / `loadPlugin`), Skills (`load_skill` / skill resources), Runtime MCP pool + vault credentials, and manifest v3 capability fields. Validate completed tool `output` against the tool output schema so ordinary tools with `outputSchema` no longer false-fail as `tool.invalid-output`.
|
|
8
|
+
|
|
3
9
|
## 0.1.1-beta
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/contracts.d.ts
CHANGED
|
@@ -10,15 +10,96 @@ export declare const PutAgentRequestSchema: z.ZodObject<{
|
|
|
10
10
|
requestId: z.ZodString;
|
|
11
11
|
manifest: z.ZodType<AgentManifest, unknown, z.core.$ZodTypeInternals<AgentManifest, unknown>>;
|
|
12
12
|
implementationVersion: z.ZodString;
|
|
13
|
+
pluginRoots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
13
14
|
}, z.core.$strict>;
|
|
14
15
|
export type PutAgentRequest = z.infer<typeof PutAgentRequestSchema>;
|
|
16
|
+
export declare const CredentialSelectionSchema: z.ZodObject<{
|
|
17
|
+
serverName: z.ZodString;
|
|
18
|
+
credentialId: z.ZodString;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type CredentialSelection = z.infer<typeof CredentialSelectionSchema>;
|
|
15
21
|
export declare const PutSessionRequestSchema: z.ZodObject<{
|
|
16
22
|
requestId: z.ZodString;
|
|
17
23
|
agentId: z.ZodString;
|
|
18
24
|
ownerUserId: z.ZodString;
|
|
19
25
|
info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
vaultIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
credentialSelections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
28
|
+
serverName: z.ZodString;
|
|
29
|
+
credentialId: z.ZodString;
|
|
30
|
+
}, z.core.$strict>>>;
|
|
20
31
|
}, z.core.$strict>;
|
|
21
32
|
export type PutSessionRequest = z.infer<typeof PutSessionRequestSchema>;
|
|
33
|
+
export declare const CreateVaultRequestSchema: z.ZodObject<{
|
|
34
|
+
requestId: z.ZodString;
|
|
35
|
+
idempotencyKey: z.ZodString;
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
ownerUserId: z.ZodString;
|
|
38
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export type CreateVaultRequest = z.infer<typeof CreateVaultRequestSchema>;
|
|
41
|
+
export declare const CreateCredentialRequestSchema: z.ZodObject<{
|
|
42
|
+
requestId: z.ZodString;
|
|
43
|
+
idempotencyKey: z.ZodString;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"bearer">;
|
|
47
|
+
url: z.ZodString;
|
|
48
|
+
token: z.ZodString;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"oauth">;
|
|
51
|
+
url: z.ZodString;
|
|
52
|
+
accessToken: z.ZodString;
|
|
53
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
refresh: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
tokenEndpoint: z.ZodString;
|
|
56
|
+
clientId: z.ZodString;
|
|
57
|
+
refreshToken: z.ZodString;
|
|
58
|
+
tokenEndpointAuth: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"none">;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"client_secret_basic">;
|
|
62
|
+
clientSecret: z.ZodString;
|
|
63
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<"client_secret_post">;
|
|
65
|
+
clientSecret: z.ZodString;
|
|
66
|
+
}, z.core.$strict>], "type">;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
}, z.core.$strict>], "type">;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type CreateCredentialRequest = z.infer<typeof CreateCredentialRequestSchema>;
|
|
71
|
+
export declare const RotateCredentialRequestSchema: z.ZodObject<{
|
|
72
|
+
requestId: z.ZodString;
|
|
73
|
+
idempotencyKey: z.ZodString;
|
|
74
|
+
auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
75
|
+
type: z.ZodLiteral<"bearer">;
|
|
76
|
+
token: z.ZodString;
|
|
77
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
78
|
+
type: z.ZodLiteral<"oauth">;
|
|
79
|
+
accessToken: z.ZodString;
|
|
80
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
81
|
+
}, z.core.$strict>], "type">;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
export type RotateCredentialRequest = z.infer<typeof RotateCredentialRequestSchema>;
|
|
84
|
+
export interface VaultInfo {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly name: string;
|
|
87
|
+
readonly ownerUserId: string;
|
|
88
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
89
|
+
readonly createdAt: string;
|
|
90
|
+
}
|
|
91
|
+
export interface CredentialInfo {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly vaultId: string;
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly type: "bearer" | "oauth";
|
|
96
|
+
readonly binding: {
|
|
97
|
+
readonly url: string;
|
|
98
|
+
};
|
|
99
|
+
readonly expiresAt?: string;
|
|
100
|
+
readonly createdAt: string;
|
|
101
|
+
readonly rotatedAt?: string;
|
|
102
|
+
}
|
|
22
103
|
export declare const MessageEventBodySchema: z.ZodObject<{
|
|
23
104
|
requestId: z.ZodString;
|
|
24
105
|
idempotencyKey: z.ZodString;
|
|
@@ -165,6 +246,8 @@ export declare const ActionSchema: z.ZodObject<{
|
|
|
165
246
|
}>;
|
|
166
247
|
capabilityId: z.ZodString;
|
|
167
248
|
toolName: z.ZodOptional<z.ZodString>;
|
|
249
|
+
inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
250
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
168
251
|
input: z.ZodUnknown;
|
|
169
252
|
context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
170
253
|
status: z.ZodEnum<{
|
|
@@ -181,7 +264,6 @@ export declare const ActionSchema: z.ZodObject<{
|
|
|
181
264
|
export type Action = z.infer<typeof ActionSchema>;
|
|
182
265
|
export declare const ActionClaimRequestSchema: z.ZodObject<{
|
|
183
266
|
requestId: z.ZodString;
|
|
184
|
-
manifestHash: z.ZodString;
|
|
185
267
|
implementationVersion: z.ZodString;
|
|
186
268
|
}, z.core.$strict>;
|
|
187
269
|
export declare const ActionHeartbeatRequestSchema: z.ZodObject<{
|
|
@@ -204,6 +286,8 @@ export declare const ActionClaimResponseSchema: z.ZodObject<{
|
|
|
204
286
|
}>;
|
|
205
287
|
capabilityId: z.ZodString;
|
|
206
288
|
toolName: z.ZodOptional<z.ZodString>;
|
|
289
|
+
inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
290
|
+
outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
207
291
|
input: z.ZodUnknown;
|
|
208
292
|
context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
209
293
|
status: z.ZodEnum<{
|
|
@@ -224,7 +308,7 @@ export declare const ActionClaimResponseSchema: z.ZodObject<{
|
|
|
224
308
|
export type ActionClaim = z.infer<typeof ActionClaimResponseSchema>;
|
|
225
309
|
export interface ExecutorScope {
|
|
226
310
|
readonly agentId: string;
|
|
227
|
-
readonly manifestHash
|
|
311
|
+
readonly manifestHash?: string;
|
|
228
312
|
readonly implementationVersion: string;
|
|
229
313
|
}
|
|
230
314
|
export declare const ExecutorNotificationSchema: z.ZodObject<{
|
package/dist/contracts.js
CHANGED
|
@@ -4,47 +4,83 @@ export const PROTOCOL_VERSION = 1;
|
|
|
4
4
|
export const RequestIdSchema = z.string().min(1);
|
|
5
5
|
export const IdempotencyKeySchema = z.string().min(1).max(256);
|
|
6
6
|
const jsonObject = z.record(z.string(), z.unknown());
|
|
7
|
+
const mcpServerSchema = z.discriminatedUnion("type", [
|
|
8
|
+
z
|
|
9
|
+
.object({
|
|
10
|
+
name: z.string().min(1),
|
|
11
|
+
type: z.literal("stdio"),
|
|
12
|
+
command: z.string().min(1),
|
|
13
|
+
args: z.array(z.string()).optional(),
|
|
14
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
15
|
+
cwd: z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict(),
|
|
18
|
+
z
|
|
19
|
+
.object({
|
|
20
|
+
name: z.string().min(1),
|
|
21
|
+
type: z.literal("streamable-http"),
|
|
22
|
+
url: z.string().min(1),
|
|
23
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
24
|
+
})
|
|
25
|
+
.strict(),
|
|
26
|
+
z
|
|
27
|
+
.object({
|
|
28
|
+
name: z.string().min(1),
|
|
29
|
+
type: z.literal("sse"),
|
|
30
|
+
url: z.string().min(1),
|
|
31
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
32
|
+
})
|
|
33
|
+
.strict(),
|
|
34
|
+
]);
|
|
35
|
+
const skillManifestSchema = z
|
|
36
|
+
.object({
|
|
37
|
+
name: z.string().min(1),
|
|
38
|
+
description: z.string().min(1),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
const toolManifestSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
name: z.string().min(1),
|
|
44
|
+
description: z.string().optional(),
|
|
45
|
+
inputSchema: jsonObject,
|
|
46
|
+
outputSchema: jsonObject.optional(),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
7
49
|
export const AgentManifestSchema = z
|
|
8
50
|
.object({
|
|
9
|
-
|
|
51
|
+
manifestSchemaVersion: z.literal(3),
|
|
10
52
|
id: z.string().min(1),
|
|
11
|
-
name: z.string().min(1),
|
|
53
|
+
name: z.string().min(1).optional(),
|
|
54
|
+
description: z.string().optional(),
|
|
55
|
+
metadata: jsonObject.optional(),
|
|
12
56
|
outputSchema: jsonObject.optional(),
|
|
13
57
|
capabilities: z.array(z
|
|
14
58
|
.object({
|
|
15
59
|
id: z.string().min(1),
|
|
16
|
-
|
|
17
|
-
|
|
60
|
+
type: z.enum(["agent", "agent-plugin"]),
|
|
61
|
+
name: z.string().min(1).optional(),
|
|
62
|
+
description: z.string().optional(),
|
|
63
|
+
metadata: jsonObject.optional(),
|
|
18
64
|
instructions: z.array(z.string()).optional(),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
name: z.string().min(1),
|
|
23
|
-
description: z.string().optional(),
|
|
24
|
-
inputSchema: jsonObject,
|
|
25
|
-
outputSchema: jsonObject.optional(),
|
|
26
|
-
})
|
|
27
|
-
.strict())
|
|
28
|
-
.optional(),
|
|
65
|
+
skills: z.record(z.string(), skillManifestSchema).optional(),
|
|
66
|
+
tools: z.array(toolManifestSchema).optional(),
|
|
67
|
+
mcpServers: z.record(z.string(), mcpServerSchema).optional(),
|
|
29
68
|
beforeModelCall: z.boolean().optional(),
|
|
30
69
|
afterModelCall: z.boolean().optional(),
|
|
31
70
|
})
|
|
32
71
|
.strict()),
|
|
72
|
+
runtime: z.object({}).strict().optional(),
|
|
33
73
|
})
|
|
34
74
|
.strict()
|
|
35
75
|
.superRefine((manifest, ctx) => {
|
|
36
76
|
const ids = new Set();
|
|
37
77
|
const names = new Set();
|
|
78
|
+
const servers = new Set();
|
|
79
|
+
const skills = new Set();
|
|
38
80
|
for (const capability of manifest.capabilities) {
|
|
39
81
|
if (ids.has(capability.id))
|
|
40
82
|
ctx.addIssue({ code: "custom", message: "Duplicate capability id" });
|
|
41
83
|
ids.add(capability.id);
|
|
42
|
-
// Arbitrary middleware closures cannot be transported. Hooks are explicit remote actions.
|
|
43
|
-
if (capability.hasMiddleware)
|
|
44
|
-
ctx.addIssue({
|
|
45
|
-
code: "custom",
|
|
46
|
-
message: "Hosted definitions support declarative capabilities and before/after hooks, not middleware closures",
|
|
47
|
-
});
|
|
48
84
|
for (const tool of capability.tools ?? []) {
|
|
49
85
|
if (names.has(tool.name))
|
|
50
86
|
ctx.addIssue({
|
|
@@ -53,13 +89,57 @@ export const AgentManifestSchema = z
|
|
|
53
89
|
});
|
|
54
90
|
names.add(tool.name);
|
|
55
91
|
}
|
|
92
|
+
if (capability.skills && Object.keys(capability.skills).length === 0)
|
|
93
|
+
ctx.addIssue({
|
|
94
|
+
code: "custom",
|
|
95
|
+
message: "skills must be omitted when a capability declares no skills",
|
|
96
|
+
});
|
|
97
|
+
for (const [key, skill] of Object.entries(capability.skills ?? {})) {
|
|
98
|
+
if (key !== skill.name)
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
message: `skills key '${key}' must equal the skill name`,
|
|
102
|
+
});
|
|
103
|
+
if (skills.has(skill.name))
|
|
104
|
+
ctx.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
message: `Duplicate skill '${skill.name}'`,
|
|
107
|
+
});
|
|
108
|
+
skills.add(skill.name);
|
|
109
|
+
}
|
|
110
|
+
if (capability.mcpServers && Object.keys(capability.mcpServers).length === 0)
|
|
111
|
+
ctx.addIssue({
|
|
112
|
+
code: "custom",
|
|
113
|
+
message: "mcpServers must be omitted when a capability declares no servers",
|
|
114
|
+
});
|
|
115
|
+
for (const [key, server] of Object.entries(capability.mcpServers ?? {})) {
|
|
116
|
+
if (key !== server.name)
|
|
117
|
+
ctx.addIssue({
|
|
118
|
+
code: "custom",
|
|
119
|
+
message: `mcpServers key '${key}' must equal the server name`,
|
|
120
|
+
});
|
|
121
|
+
if (servers.has(server.name))
|
|
122
|
+
ctx.addIssue({
|
|
123
|
+
code: "custom",
|
|
124
|
+
message: `Duplicate MCP server '${server.name}'`,
|
|
125
|
+
});
|
|
126
|
+
servers.add(server.name);
|
|
127
|
+
}
|
|
56
128
|
}
|
|
57
129
|
});
|
|
130
|
+
const absolutePath = z.string().min(1).refine((value) => value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value), { message: "plugin root must be an absolute path" });
|
|
58
131
|
export const PutAgentRequestSchema = z
|
|
59
132
|
.object({
|
|
60
133
|
requestId: RequestIdSchema,
|
|
61
134
|
manifest: AgentManifestSchema,
|
|
62
135
|
implementationVersion: z.string().min(1),
|
|
136
|
+
pluginRoots: z.record(z.string(), absolutePath).optional(),
|
|
137
|
+
})
|
|
138
|
+
.strict();
|
|
139
|
+
export const CredentialSelectionSchema = z
|
|
140
|
+
.object({
|
|
141
|
+
serverName: z.string().min(1),
|
|
142
|
+
credentialId: z.string().min(1),
|
|
63
143
|
})
|
|
64
144
|
.strict();
|
|
65
145
|
export const PutSessionRequestSchema = z
|
|
@@ -68,6 +148,87 @@ export const PutSessionRequestSchema = z
|
|
|
68
148
|
agentId: z.string().min(1),
|
|
69
149
|
ownerUserId: z.string().min(1),
|
|
70
150
|
info: jsonObject.optional(),
|
|
151
|
+
vaultIds: z.array(z.string().min(1)).optional(),
|
|
152
|
+
credentialSelections: z.array(CredentialSelectionSchema).optional(),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
155
|
+
const vaultWriteBase = {
|
|
156
|
+
requestId: RequestIdSchema,
|
|
157
|
+
idempotencyKey: IdempotencyKeySchema,
|
|
158
|
+
};
|
|
159
|
+
const tokenEndpointAuthSchema = z.discriminatedUnion("type", [
|
|
160
|
+
z.object({ type: z.literal("none") }).strict(),
|
|
161
|
+
z
|
|
162
|
+
.object({
|
|
163
|
+
type: z.literal("client_secret_basic"),
|
|
164
|
+
clientSecret: z.string().min(1),
|
|
165
|
+
})
|
|
166
|
+
.strict(),
|
|
167
|
+
z
|
|
168
|
+
.object({
|
|
169
|
+
type: z.literal("client_secret_post"),
|
|
170
|
+
clientSecret: z.string().min(1),
|
|
171
|
+
})
|
|
172
|
+
.strict(),
|
|
173
|
+
]);
|
|
174
|
+
const oauthRefreshSchema = z
|
|
175
|
+
.object({
|
|
176
|
+
tokenEndpoint: z.string().min(1),
|
|
177
|
+
clientId: z.string().min(1),
|
|
178
|
+
refreshToken: z.string().min(1),
|
|
179
|
+
tokenEndpointAuth: tokenEndpointAuthSchema,
|
|
180
|
+
})
|
|
181
|
+
.strict();
|
|
182
|
+
export const CreateVaultRequestSchema = z
|
|
183
|
+
.object({
|
|
184
|
+
...vaultWriteBase,
|
|
185
|
+
name: z.string().min(1),
|
|
186
|
+
ownerUserId: z.string().min(1),
|
|
187
|
+
metadata: z.record(z.string(), z.string()).optional(),
|
|
188
|
+
})
|
|
189
|
+
.strict();
|
|
190
|
+
export const CreateCredentialRequestSchema = z
|
|
191
|
+
.object({
|
|
192
|
+
...vaultWriteBase,
|
|
193
|
+
name: z.string().min(1),
|
|
194
|
+
auth: z.discriminatedUnion("type", [
|
|
195
|
+
z
|
|
196
|
+
.object({
|
|
197
|
+
type: z.literal("bearer"),
|
|
198
|
+
url: z.string().min(1),
|
|
199
|
+
token: z.string().min(1),
|
|
200
|
+
})
|
|
201
|
+
.strict(),
|
|
202
|
+
z
|
|
203
|
+
.object({
|
|
204
|
+
type: z.literal("oauth"),
|
|
205
|
+
url: z.string().min(1),
|
|
206
|
+
accessToken: z.string().min(1),
|
|
207
|
+
expiresAt: z.string().min(1).nullable().optional(),
|
|
208
|
+
refresh: oauthRefreshSchema.optional(),
|
|
209
|
+
})
|
|
210
|
+
.strict(),
|
|
211
|
+
]),
|
|
212
|
+
})
|
|
213
|
+
.strict();
|
|
214
|
+
export const RotateCredentialRequestSchema = z
|
|
215
|
+
.object({
|
|
216
|
+
...vaultWriteBase,
|
|
217
|
+
auth: z.discriminatedUnion("type", [
|
|
218
|
+
z
|
|
219
|
+
.object({
|
|
220
|
+
type: z.literal("bearer"),
|
|
221
|
+
token: z.string().min(1),
|
|
222
|
+
})
|
|
223
|
+
.strict(),
|
|
224
|
+
z
|
|
225
|
+
.object({
|
|
226
|
+
type: z.literal("oauth"),
|
|
227
|
+
accessToken: z.string().min(1),
|
|
228
|
+
expiresAt: z.string().min(1).nullable().optional(),
|
|
229
|
+
})
|
|
230
|
+
.strict(),
|
|
231
|
+
]),
|
|
71
232
|
})
|
|
72
233
|
.strict();
|
|
73
234
|
const commandBase = {
|
|
@@ -163,6 +324,8 @@ export const ActionSchema = z.object({
|
|
|
163
324
|
kind: z.enum(["tool", "beforeModelCall", "afterModelCall"]),
|
|
164
325
|
capabilityId: z.string(),
|
|
165
326
|
toolName: z.string().optional(),
|
|
327
|
+
inputSchema: jsonObject.optional(),
|
|
328
|
+
outputSchema: jsonObject.optional(),
|
|
166
329
|
input: z.unknown(),
|
|
167
330
|
context: jsonObject,
|
|
168
331
|
status: z.enum(["pending", "claimed", "completed", "uncertain", "cancelled"]),
|
|
@@ -173,7 +336,6 @@ export const ActionSchema = z.object({
|
|
|
173
336
|
export const ActionClaimRequestSchema = z
|
|
174
337
|
.object({
|
|
175
338
|
requestId: RequestIdSchema,
|
|
176
|
-
manifestHash: z.string().min(1),
|
|
177
339
|
implementationVersion: z.string().min(1),
|
|
178
340
|
})
|
|
179
341
|
.strict();
|
package/dist/define.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export { ToolError, isToolError } from "./definition/tool-error.js";
|
|
|
8
8
|
export { defineSchema } from "./definition/schema.js";
|
|
9
9
|
export { hashManifest } from "./utils/hash.js";
|
|
10
10
|
export type { Implementations } from "./definition/implementations.js";
|
|
11
|
-
export type { AgentManifest, CapabilityManifest,
|
|
12
|
-
export type { CapabilityDeclaration, CapabilityItems, MiddlewareContributions, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
|
|
11
|
+
export type { AgentManifest, CapabilityManifest, McpServerManifest, RuntimeManifest, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
|
|
12
|
+
export type { CapabilityDeclaration, CapabilityItems, MiddlewareContributions, SkillRecord, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
|
|
13
13
|
export type { Patch, Decision, BeforeModelCallFn, AfterModelCallFn, } from "./types/dynamics.js";
|
|
14
14
|
export type { ModelCandidate, ModelControls, ModelDirective, ModelEvidence, ModelFinishReason, ModelAdapter, ModelAdapterContext, ModelPreparedCall, ContextContributor, ContextMutationOptions, ContextSnapshot, ModelCall, ModelCallTool, ModelOutputBlock, PromptContentPart, PromptItem, ModelConfigurationContributor, ModelConfigurationInstruction, ModelConfigurationMutationOptions, ModelConfigurationSnapshot, ModelConfigurationTool, ModelRequest, ModelToolCall, ModelUsage, } from "./types/model.js";
|
|
15
15
|
export type { BuildDiagnostic, ContextItem, DeferredOutcome, JsonObject, JsonPrimitive, JsonValue, Tripwire, } from "./types/shared.js";
|
|
@@ -24,6 +24,7 @@ export { bindTool } from "./definition/bind-tool.js";
|
|
|
24
24
|
export { bindOutputContract } from "./definition/output-contract.js";
|
|
25
25
|
export type { TurnOutputContract } from "./definition/output-contract.js";
|
|
26
26
|
export { agentFrom } from "./definition/from.js";
|
|
27
|
+
export type { SessionToolRef } from "./definition/from.js";
|
|
27
28
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
|
28
29
|
export { normalizeSchema } from "./definition/schema.js";
|
|
29
30
|
export * from "./utils/immutable.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BoundMiddleware } from "./bound.js";
|
|
2
2
|
import type { BuiltAgent } from "../types/agent.js";
|
|
3
|
-
import type { AgentManifest } from "../types/manifest.js";
|
|
4
|
-
import type { BuildDiagnostic } from "../types/shared.js";
|
|
3
|
+
import type { AgentManifest, RuntimeManifest } from "../types/manifest.js";
|
|
4
|
+
import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
|
|
5
5
|
import type { ToolSchemaSource } from "../types/tool.js";
|
|
6
6
|
import type { AfterModelCallFn, BeforeModelCallFn } from "../types/dynamics.js";
|
|
7
7
|
import type { StepMiddleware } from "../types/middleware.js";
|
|
@@ -20,7 +20,10 @@ export interface CapabilityDynamics {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function assembleAgent(middleware: readonly BoundMiddleware[], identity: Readonly<{
|
|
22
22
|
id: string;
|
|
23
|
-
name
|
|
23
|
+
name?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
metadata?: JsonObject;
|
|
24
26
|
outputSchema?: ToolSchemaSource;
|
|
27
|
+
runtime?: RuntimeManifest;
|
|
25
28
|
}>, dynamics?: ReadonlyMap<string, CapabilityDynamics>): BuildResult<BuiltAgent>;
|
|
26
29
|
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { bindAgent } from "./bind-agent.js";
|
|
2
2
|
import { createManifest } from "./manifest.js";
|
|
3
|
+
import { createSkillTools } from "./skill-tools.js";
|
|
3
4
|
const diagnostic = (code, message, extra = {}) => Object.freeze({ code, message, ...extra });
|
|
4
5
|
export function assembleAgent(middleware, identity, dynamics = new Map()) {
|
|
5
6
|
const diagnostics = [];
|
|
6
7
|
if (typeof identity.id !== "string" || identity.id.length === 0) {
|
|
7
8
|
diagnostics.push(diagnostic("agent.invalid-id", "Agent id must be a non-empty string"));
|
|
8
9
|
}
|
|
9
|
-
if (
|
|
10
|
+
if (identity.name !== undefined &&
|
|
11
|
+
(typeof identity.name !== "string" || identity.name.length === 0)) {
|
|
10
12
|
diagnostics.push(diagnostic("agent.invalid-name", "Agent name must be a non-empty string"));
|
|
11
13
|
}
|
|
12
14
|
const middlewareIds = new Set();
|
|
@@ -18,10 +20,16 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
|
|
|
18
20
|
diagnostics.push(diagnostic("middleware.duplicate-id", `Duplicate middleware id '${item.id}'`));
|
|
19
21
|
else if (typeof item.handle !== "function")
|
|
20
22
|
diagnostics.push(diagnostic("middleware.invalid", `Middleware '${item.id}' must provide a function`));
|
|
23
|
+
else if (item.name !== undefined && item.name.length === 0)
|
|
24
|
+
diagnostics.push(diagnostic("middleware.invalid", `Capability '${item.id}' name must be a non-empty string`));
|
|
21
25
|
else {
|
|
22
26
|
middlewareIds.add(item.id);
|
|
23
27
|
frozen.push(Object.freeze({
|
|
24
28
|
id: item.id,
|
|
29
|
+
...(item.name === undefined ? {} : { name: item.name }),
|
|
30
|
+
...(item.description === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { description: item.description }),
|
|
25
33
|
handle: item.handle,
|
|
26
34
|
hasMiddleware: item.hasMiddleware,
|
|
27
35
|
...(item.tools === undefined ? {} : { tools: item.tools }),
|
|
@@ -30,21 +38,83 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
|
|
|
30
38
|
: { contributions: item.contributions }),
|
|
31
39
|
...(item.beforeModelCall ? { beforeModelCall: true } : {}),
|
|
32
40
|
...(item.afterModelCall ? { afterModelCall: true } : {}),
|
|
41
|
+
...(item.manifestType === undefined
|
|
42
|
+
? {}
|
|
43
|
+
: { manifestType: item.manifestType }),
|
|
44
|
+
...(item.metadata === undefined ? {} : { metadata: item.metadata }),
|
|
45
|
+
...(item.mcpServers === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: { mcpServers: item.mcpServers }),
|
|
48
|
+
...(item.skills === undefined ? {} : { skills: item.skills }),
|
|
49
|
+
...(item.skillRecords === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: { skillRecords: item.skillRecords }),
|
|
52
|
+
...(item.sessionTools === undefined
|
|
53
|
+
? {}
|
|
54
|
+
: { sessionTools: item.sessionTools }),
|
|
55
|
+
...(item.pluginRoot === undefined ? {} : { pluginRoot: item.pluginRoot }),
|
|
33
56
|
}));
|
|
34
57
|
}
|
|
35
58
|
}
|
|
59
|
+
const skilled = attachSkillTools(frozen);
|
|
60
|
+
diagnostics.push(...skilled.diagnostics);
|
|
36
61
|
if (diagnostics.length)
|
|
37
62
|
return Object.freeze({
|
|
38
63
|
ok: false,
|
|
39
64
|
diagnostics: Object.freeze(diagnostics),
|
|
40
65
|
});
|
|
41
|
-
const frozenMiddleware = Object.freeze(
|
|
66
|
+
const frozenMiddleware = Object.freeze(skilled.items.map((item) => Object.freeze(item)));
|
|
42
67
|
const manifest = createManifest({
|
|
43
68
|
id: identity.id,
|
|
44
69
|
name: identity.name,
|
|
70
|
+
description: identity.description,
|
|
71
|
+
metadata: identity.metadata,
|
|
45
72
|
outputSchema: identity.outputSchema,
|
|
73
|
+
runtime: identity.runtime,
|
|
46
74
|
middleware: frozenMiddleware,
|
|
47
75
|
});
|
|
48
76
|
const agent = bindAgent(frozenMiddleware, manifest, identity, dynamics);
|
|
49
77
|
return Object.freeze({ ok: true, agent, manifest });
|
|
50
78
|
}
|
|
79
|
+
const SKILL_TOOL_NAMES = new Set(["load_skill", "read_skill_resource"]);
|
|
80
|
+
function attachSkillTools(items) {
|
|
81
|
+
const skills = new Map();
|
|
82
|
+
const diagnostics = [];
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
let ownerId;
|
|
85
|
+
for (const item of items) {
|
|
86
|
+
for (const [key, skill] of Object.entries(item.skills ?? {})) {
|
|
87
|
+
if (key !== skill.name || seen.has(skill.name)) {
|
|
88
|
+
diagnostics.push(diagnostic("skill.duplicate-name", `Duplicate skill '${skill.name}' on capability '${item.id}'`));
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
seen.add(skill.name);
|
|
92
|
+
}
|
|
93
|
+
for (const [key, skill] of Object.entries(item.skillRecords ?? {})) {
|
|
94
|
+
if (key !== skill.name || skills.has(skill.name)) {
|
|
95
|
+
diagnostics.push(diagnostic("skill.duplicate-name", `Duplicate skill '${skill.name}' on capability '${item.id}'`));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
skills.set(skill.name, skill);
|
|
99
|
+
ownerId ??= item.id;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (diagnostics.length > 0 || ownerId === undefined)
|
|
103
|
+
return { items: [...items], diagnostics };
|
|
104
|
+
const skillTools = createSkillTools(skills);
|
|
105
|
+
const next = items.map((item) => {
|
|
106
|
+
if (item.id !== ownerId)
|
|
107
|
+
return item;
|
|
108
|
+
const tools = [
|
|
109
|
+
...(item.tools ?? []).filter((entry) => !SKILL_TOOL_NAMES.has(entry.name)),
|
|
110
|
+
...skillTools,
|
|
111
|
+
];
|
|
112
|
+
const advertised = [...tools, ...(item.sessionTools ?? [])];
|
|
113
|
+
const handle = async (request, next) => item.handle(request, async () => {
|
|
114
|
+
request.configuration.tools.set(item.id, advertised);
|
|
115
|
+
return next();
|
|
116
|
+
});
|
|
117
|
+
return { ...item, tools, handle };
|
|
118
|
+
});
|
|
119
|
+
return { items: next, diagnostics };
|
|
120
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { bindTool } from "./bind-tool.js";
|
|
2
2
|
import { HarnessError } from "../errors.js";
|
|
3
3
|
import { bindOutputContract } from "./output-contract.js";
|
|
4
|
-
import { hashManifest } from "../utils/hash.js";
|
|
5
4
|
export function bindAgent(middleware, manifest, options = {}, dynamics = new Map()) {
|
|
6
5
|
const seen = new Set();
|
|
7
6
|
const keys = new Set();
|
|
8
7
|
const tools = [];
|
|
9
8
|
for (const declaration of middleware)
|
|
10
|
-
for (const tool of
|
|
9
|
+
for (const tool of [
|
|
10
|
+
...(declaration.tools ?? []),
|
|
11
|
+
...(declaration.sessionTools ?? []),
|
|
12
|
+
]) {
|
|
11
13
|
const key = JSON.stringify([declaration.id, tool.name]);
|
|
12
14
|
if (seen.has(tool) || keys.has(key))
|
|
13
15
|
throw new HarnessError("tool.invalid", `Duplicate registered tool '${tool.name}' in '${declaration.id}'`);
|
|
@@ -32,7 +34,6 @@ export function bindAgent(middleware, manifest, options = {}, dynamics = new Map
|
|
|
32
34
|
id: manifest.id,
|
|
33
35
|
name: manifest.name,
|
|
34
36
|
manifest,
|
|
35
|
-
hash: hashManifest(manifest),
|
|
36
37
|
toJSON: () => manifest,
|
|
37
38
|
};
|
|
38
39
|
Object.defineProperty(agent, "getBinding", {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { JsonObject } from "../types/shared.js";
|
|
2
|
+
import type { McpServerManifest, SkillManifest } from "../types/manifest.js";
|
|
3
|
+
import type { SkillRecord } from "../types/middleware.js";
|
|
1
4
|
import type { MiddlewareContributions, StepMiddleware } from "../types/middleware.js";
|
|
2
5
|
import type { ToolApproval, ToolDefinition, ToolEffects, ToolExecutionContext, ToolInputSchema, ToolOutputSchema, ToolOwner, ToolRunResult, ToolSchema } from "../types/tool.js";
|
|
3
6
|
export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition<ToolInputSchema, Info, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute" | "run" | "input" | "output"> {
|
|
@@ -11,10 +14,21 @@ export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition
|
|
|
11
14
|
}
|
|
12
15
|
export interface BoundMiddleware {
|
|
13
16
|
readonly id: string;
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
readonly description?: string;
|
|
14
19
|
readonly handle: StepMiddleware;
|
|
15
20
|
readonly hasMiddleware: boolean;
|
|
16
21
|
readonly tools?: readonly ToolDefinition<any, any, any>[];
|
|
22
|
+
/** Execution-only tools. Advertised for this run and omitted from the manifest. */
|
|
23
|
+
readonly sessionTools?: readonly ToolDefinition<any, any, any>[];
|
|
17
24
|
readonly contributions?: MiddlewareContributions;
|
|
18
25
|
readonly beforeModelCall?: boolean;
|
|
19
26
|
readonly afterModelCall?: boolean;
|
|
27
|
+
readonly manifestType?: "agent" | "agent-plugin";
|
|
28
|
+
readonly metadata?: JsonObject;
|
|
29
|
+
readonly skills?: Readonly<Record<string, SkillManifest>>;
|
|
30
|
+
readonly skillRecords?: Readonly<Record<string, SkillRecord>>;
|
|
31
|
+
readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
|
|
32
|
+
/** Package directory for a plugin capability. Not a manifest field. */
|
|
33
|
+
readonly pluginRoot?: string;
|
|
20
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BoundMiddleware } from "./bound.js";
|
|
2
2
|
import type { CapabilityDeclaration, StepMiddleware } from "../types/middleware.js";
|
|
3
|
-
import type { BuildDiagnostic } from "../types/shared.js";
|
|
3
|
+
import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
|
|
4
4
|
import { HarnessError } from "../errors.js";
|
|
5
5
|
import type { ToolDefinition, ToolSchemaSource, SchemaOutput } from "../types/tool.js";
|
|
6
6
|
import type { BuiltAgent } from "../types/agent.js";
|
|
@@ -11,14 +11,18 @@ import { type CapabilityDynamics } from "./assemble.js";
|
|
|
11
11
|
export interface AgentOptions<Schema extends ToolSchemaSource | undefined = undefined> {
|
|
12
12
|
readonly outputSchema?: Schema;
|
|
13
13
|
readonly id: string;
|
|
14
|
-
readonly name
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly metadata?: JsonObject;
|
|
15
17
|
readonly instructions?: string | readonly string[];
|
|
16
18
|
/** Top-level tools (H2). Composed as capability id `"agent"`. */
|
|
17
19
|
readonly tools?: readonly ToolDefinition<any, any, any>[];
|
|
18
20
|
}
|
|
19
21
|
interface BuilderSnapshot {
|
|
20
22
|
readonly id: string;
|
|
21
|
-
readonly name
|
|
23
|
+
readonly name?: string;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
readonly metadata?: JsonObject;
|
|
22
26
|
readonly outputSchema?: ToolSchemaSource;
|
|
23
27
|
readonly entries: readonly BoundMiddleware[];
|
|
24
28
|
readonly dynamics: ReadonlyMap<string, CapabilityDynamics>;
|
|
@@ -47,9 +51,8 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
|
|
|
47
51
|
private static withSnapshot;
|
|
48
52
|
/** Compose-time identity — available before `.build()`. */
|
|
49
53
|
get id(): string;
|
|
50
|
-
get name(): string;
|
|
54
|
+
get name(): string | undefined;
|
|
51
55
|
get manifest(): AgentManifest;
|
|
52
|
-
get hash(): string;
|
|
53
56
|
toJSON(): AgentManifest;
|
|
54
57
|
use(middleware: StepMiddleware<Info>): AgentBuilder<Info, Schema>;
|
|
55
58
|
use(id: string, middleware: StepMiddleware<Info>): AgentBuilder<Info, Schema>;
|