@lushly-dev/afd-server 0.4.0 → 0.6.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/README.md +111 -0
- package/dist/bootstrap/afd-context.d.ts +56 -0
- package/dist/bootstrap/afd-context.d.ts.map +1 -0
- package/dist/bootstrap/afd-context.js +132 -0
- package/dist/bootstrap/afd-context.js.map +1 -0
- package/dist/bootstrap/afd-docs.d.ts +1 -5
- package/dist/bootstrap/afd-docs.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.d.ts +7 -9
- package/dist/bootstrap/afd-help.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.js +4 -1
- package/dist/bootstrap/afd-help.js.map +1 -1
- package/dist/bootstrap/afd-schema.d.ts +5 -6
- package/dist/bootstrap/afd-schema.d.ts.map +1 -1
- package/dist/bootstrap/index.d.ts +1 -0
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +1 -0
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/registry.d.ts +4 -0
- package/dist/bootstrap/registry.d.ts.map +1 -1
- package/dist/bootstrap/registry.js +8 -1
- package/dist/bootstrap/registry.js.map +1 -1
- package/dist/execution.d.ts +19 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +389 -0
- package/dist/execution.js.map +1 -0
- package/dist/handoff-schema.d.ts +9 -145
- package/dist/handoff-schema.d.ts.map +1 -1
- package/dist/handoff-schema.js +1 -1
- package/dist/handoff-schema.js.map +1 -1
- package/dist/http-handler.d.ts +28 -0
- package/dist/http-handler.d.ts.map +1 -0
- package/dist/http-handler.js +292 -0
- package/dist/http-handler.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lazy-tools.d.ts +64 -0
- package/dist/lazy-tools.d.ts.map +1 -0
- package/dist/lazy-tools.js +144 -0
- package/dist/lazy-tools.js.map +1 -0
- package/dist/schema.d.ts +29 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +21 -11
- package/dist/schema.js.map +1 -1
- package/dist/server-types.d.ts +138 -0
- package/dist/server-types.d.ts.map +1 -0
- package/dist/server-types.js +13 -0
- package/dist/server-types.js.map +1 -0
- package/dist/server.d.ts +6 -121
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +67 -1125
- package/dist/server.js.map +1 -1
- package/dist/tool-router.d.ts +36 -0
- package/dist/tool-router.d.ts.map +1 -0
- package/dist/tool-router.js +246 -0
- package/dist/tool-router.js.map +1 -0
- package/dist/tools.d.ts +428 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +244 -0
- package/dist/tools.js.map +1 -0
- package/dist/validation.d.ts +10 -37
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +8 -8
- package/dist/validation.js.map +1 -1
- package/package.json +9 -10
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MCP tool list generation — individual, grouped, and lazy strategies.
|
|
3
|
+
*/
|
|
4
|
+
import type { ZodCommandDefinition } from './schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Get the tools list based on toolStrategy.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getToolsList(commands: ZodCommandDefinition[], toolStrategy: 'individual' | 'grouped' | 'lazy', groupByFn?: (command: ZodCommandDefinition) => string | undefined, activeContext?: string | null): ({
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
commands: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
items: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: {
|
|
20
|
+
id: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
command: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
input: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
required: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
options: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
properties: {
|
|
40
|
+
stopOnError: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
timeout: {
|
|
45
|
+
type: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
required: string[];
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: "object";
|
|
58
|
+
properties: {
|
|
59
|
+
steps: {
|
|
60
|
+
type: string;
|
|
61
|
+
description: string;
|
|
62
|
+
items: {
|
|
63
|
+
type: string;
|
|
64
|
+
properties: {
|
|
65
|
+
command: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
input: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
as: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
when: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
required: string[];
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
options: {
|
|
86
|
+
type: string;
|
|
87
|
+
description: string;
|
|
88
|
+
properties: {
|
|
89
|
+
continueOnFailure: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
timeoutMs: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
required: string[];
|
|
101
|
+
};
|
|
102
|
+
} | {
|
|
103
|
+
name: string;
|
|
104
|
+
description: string;
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: "object";
|
|
107
|
+
properties: {
|
|
108
|
+
category: {
|
|
109
|
+
type: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
tag: {
|
|
113
|
+
type: string;
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
tagMode: {
|
|
117
|
+
type: string;
|
|
118
|
+
enum: string[];
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
search: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
includeMutation: {
|
|
126
|
+
type: string;
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
limit: {
|
|
130
|
+
type: string;
|
|
131
|
+
description: string;
|
|
132
|
+
};
|
|
133
|
+
offset: {
|
|
134
|
+
type: string;
|
|
135
|
+
description: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
} | {
|
|
140
|
+
name: string;
|
|
141
|
+
description: string;
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: "object";
|
|
144
|
+
properties: {
|
|
145
|
+
command: {
|
|
146
|
+
type: string;
|
|
147
|
+
description: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
required: string[];
|
|
151
|
+
};
|
|
152
|
+
})[] | ({
|
|
153
|
+
name: string;
|
|
154
|
+
description: string;
|
|
155
|
+
inputSchema: {
|
|
156
|
+
type: "object";
|
|
157
|
+
properties: {
|
|
158
|
+
commands: {
|
|
159
|
+
type: string;
|
|
160
|
+
description: string;
|
|
161
|
+
items: {
|
|
162
|
+
type: string;
|
|
163
|
+
properties: {
|
|
164
|
+
id: {
|
|
165
|
+
type: string;
|
|
166
|
+
description: string;
|
|
167
|
+
};
|
|
168
|
+
command: {
|
|
169
|
+
type: string;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
input: {
|
|
173
|
+
type: string;
|
|
174
|
+
description: string;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
required: string[];
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
options: {
|
|
181
|
+
type: string;
|
|
182
|
+
description: string;
|
|
183
|
+
properties: {
|
|
184
|
+
stopOnError: {
|
|
185
|
+
type: string;
|
|
186
|
+
description: string;
|
|
187
|
+
};
|
|
188
|
+
timeout: {
|
|
189
|
+
type: string;
|
|
190
|
+
description: string;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
required: string[];
|
|
196
|
+
};
|
|
197
|
+
} | {
|
|
198
|
+
name: string;
|
|
199
|
+
description: string;
|
|
200
|
+
inputSchema: {
|
|
201
|
+
type: "object";
|
|
202
|
+
properties: {
|
|
203
|
+
steps: {
|
|
204
|
+
type: string;
|
|
205
|
+
description: string;
|
|
206
|
+
items: {
|
|
207
|
+
type: string;
|
|
208
|
+
properties: {
|
|
209
|
+
command: {
|
|
210
|
+
type: string;
|
|
211
|
+
description: string;
|
|
212
|
+
};
|
|
213
|
+
input: {
|
|
214
|
+
type: string;
|
|
215
|
+
description: string;
|
|
216
|
+
};
|
|
217
|
+
as: {
|
|
218
|
+
type: string;
|
|
219
|
+
description: string;
|
|
220
|
+
};
|
|
221
|
+
when: {
|
|
222
|
+
type: string;
|
|
223
|
+
description: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
required: string[];
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
options: {
|
|
230
|
+
type: string;
|
|
231
|
+
description: string;
|
|
232
|
+
properties: {
|
|
233
|
+
continueOnFailure: {
|
|
234
|
+
type: string;
|
|
235
|
+
description: string;
|
|
236
|
+
};
|
|
237
|
+
timeoutMs: {
|
|
238
|
+
type: string;
|
|
239
|
+
description: string;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
required: string[];
|
|
245
|
+
};
|
|
246
|
+
} | {
|
|
247
|
+
name: string;
|
|
248
|
+
description: string;
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: "object";
|
|
251
|
+
properties: {
|
|
252
|
+
command: {
|
|
253
|
+
type: string;
|
|
254
|
+
description: string;
|
|
255
|
+
};
|
|
256
|
+
input: {
|
|
257
|
+
type: string;
|
|
258
|
+
description: string;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
required: string[];
|
|
262
|
+
};
|
|
263
|
+
} | {
|
|
264
|
+
_meta?: {
|
|
265
|
+
contexts?: string[] | undefined;
|
|
266
|
+
outputSchema?: import("@lushly-dev/afd-core").JsonSchema | undefined;
|
|
267
|
+
examples?: import("@lushly-dev/afd-core").CommandExample<unknown>[] | undefined;
|
|
268
|
+
mutation?: boolean | undefined;
|
|
269
|
+
requires?: string[] | undefined;
|
|
270
|
+
} | undefined;
|
|
271
|
+
name: string;
|
|
272
|
+
description: string;
|
|
273
|
+
inputSchema: {
|
|
274
|
+
description?: string;
|
|
275
|
+
required?: string[] | boolean;
|
|
276
|
+
default?: unknown;
|
|
277
|
+
enum?: unknown[];
|
|
278
|
+
items?: import("@lushly-dev/afd-core").JsonSchema;
|
|
279
|
+
properties?: Record<string, import("@lushly-dev/afd-core").JsonSchema>;
|
|
280
|
+
additionalProperties?: boolean | import("@lushly-dev/afd-core").JsonSchema;
|
|
281
|
+
minimum?: number;
|
|
282
|
+
maximum?: number;
|
|
283
|
+
exclusiveMinimum?: number;
|
|
284
|
+
exclusiveMaximum?: number;
|
|
285
|
+
minLength?: number;
|
|
286
|
+
maxLength?: number;
|
|
287
|
+
minItems?: number;
|
|
288
|
+
maxItems?: number;
|
|
289
|
+
pattern?: string;
|
|
290
|
+
format?: string;
|
|
291
|
+
oneOf?: import("@lushly-dev/afd-core").JsonSchema[];
|
|
292
|
+
anyOf?: import("@lushly-dev/afd-core").JsonSchema[];
|
|
293
|
+
allOf?: import("@lushly-dev/afd-core").JsonSchema[];
|
|
294
|
+
not?: import("@lushly-dev/afd-core").JsonSchema;
|
|
295
|
+
const?: unknown;
|
|
296
|
+
type: "object";
|
|
297
|
+
};
|
|
298
|
+
})[] | ({
|
|
299
|
+
name: string;
|
|
300
|
+
description: string;
|
|
301
|
+
inputSchema: {
|
|
302
|
+
type: "object";
|
|
303
|
+
properties: {
|
|
304
|
+
commands: {
|
|
305
|
+
type: string;
|
|
306
|
+
description: string;
|
|
307
|
+
items: {
|
|
308
|
+
type: string;
|
|
309
|
+
properties: {
|
|
310
|
+
id: {
|
|
311
|
+
type: string;
|
|
312
|
+
description: string;
|
|
313
|
+
};
|
|
314
|
+
command: {
|
|
315
|
+
type: string;
|
|
316
|
+
description: string;
|
|
317
|
+
};
|
|
318
|
+
input: {
|
|
319
|
+
type: string;
|
|
320
|
+
description: string;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
required: string[];
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
options: {
|
|
327
|
+
type: string;
|
|
328
|
+
description: string;
|
|
329
|
+
properties: {
|
|
330
|
+
stopOnError: {
|
|
331
|
+
type: string;
|
|
332
|
+
description: string;
|
|
333
|
+
};
|
|
334
|
+
timeout: {
|
|
335
|
+
type: string;
|
|
336
|
+
description: string;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
required: string[];
|
|
342
|
+
};
|
|
343
|
+
} | {
|
|
344
|
+
name: string;
|
|
345
|
+
description: string;
|
|
346
|
+
inputSchema: {
|
|
347
|
+
type: "object";
|
|
348
|
+
properties: {
|
|
349
|
+
steps: {
|
|
350
|
+
type: string;
|
|
351
|
+
description: string;
|
|
352
|
+
items: {
|
|
353
|
+
type: string;
|
|
354
|
+
properties: {
|
|
355
|
+
command: {
|
|
356
|
+
type: string;
|
|
357
|
+
description: string;
|
|
358
|
+
};
|
|
359
|
+
input: {
|
|
360
|
+
type: string;
|
|
361
|
+
description: string;
|
|
362
|
+
};
|
|
363
|
+
as: {
|
|
364
|
+
type: string;
|
|
365
|
+
description: string;
|
|
366
|
+
};
|
|
367
|
+
when: {
|
|
368
|
+
type: string;
|
|
369
|
+
description: string;
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
required: string[];
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
options: {
|
|
376
|
+
type: string;
|
|
377
|
+
description: string;
|
|
378
|
+
properties: {
|
|
379
|
+
continueOnFailure: {
|
|
380
|
+
type: string;
|
|
381
|
+
description: string;
|
|
382
|
+
};
|
|
383
|
+
timeoutMs: {
|
|
384
|
+
type: string;
|
|
385
|
+
description: string;
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
required: string[];
|
|
391
|
+
};
|
|
392
|
+
} | {
|
|
393
|
+
name: string;
|
|
394
|
+
description: string;
|
|
395
|
+
inputSchema: {
|
|
396
|
+
type: "object";
|
|
397
|
+
properties: {
|
|
398
|
+
command: {
|
|
399
|
+
type: string;
|
|
400
|
+
description: string;
|
|
401
|
+
};
|
|
402
|
+
input: {
|
|
403
|
+
type: string;
|
|
404
|
+
description: string;
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
required: string[];
|
|
408
|
+
};
|
|
409
|
+
} | {
|
|
410
|
+
name: string;
|
|
411
|
+
description: string;
|
|
412
|
+
inputSchema: {
|
|
413
|
+
type: "object";
|
|
414
|
+
properties: {
|
|
415
|
+
action: {
|
|
416
|
+
type: string;
|
|
417
|
+
enum: string[];
|
|
418
|
+
description: string;
|
|
419
|
+
};
|
|
420
|
+
params: {
|
|
421
|
+
type: string;
|
|
422
|
+
description: string;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
required: string[];
|
|
426
|
+
};
|
|
427
|
+
})[];
|
|
428
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA0KxD;;GAEG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,oBAAoB,EAAE,EAChC,YAAY,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,EAC/C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,EACjE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8F7B"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MCP tool list generation — individual, grouped, and lazy strategies.
|
|
3
|
+
*/
|
|
4
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
5
|
+
// BUILT-IN TOOL SCHEMAS
|
|
6
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
const batchToolSchema = {
|
|
8
|
+
name: 'afd-batch',
|
|
9
|
+
description: 'Execute multiple commands in a single batch request with partial success semantics',
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
commands: {
|
|
14
|
+
type: 'array',
|
|
15
|
+
description: 'Array of commands to execute',
|
|
16
|
+
items: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
id: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Optional client-provided ID for correlating results',
|
|
22
|
+
},
|
|
23
|
+
command: { type: 'string', description: 'The command name to execute' },
|
|
24
|
+
input: { type: 'object', description: 'Input parameters for the command' },
|
|
25
|
+
},
|
|
26
|
+
required: ['command'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
options: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
description: 'Batch execution options',
|
|
32
|
+
properties: {
|
|
33
|
+
stopOnError: { type: 'boolean', description: 'Stop execution on first error' },
|
|
34
|
+
timeout: {
|
|
35
|
+
type: 'number',
|
|
36
|
+
description: 'Timeout in milliseconds for entire batch',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ['commands'],
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const pipeToolSchema = {
|
|
45
|
+
name: 'afd-pipe',
|
|
46
|
+
description: 'Execute a pipeline of chained commands where the output of one becomes the input of the next',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
steps: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
description: 'Ordered list of pipeline steps to execute',
|
|
53
|
+
items: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
command: { type: 'string', description: 'Command name to execute' },
|
|
57
|
+
input: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
description: 'Input parameters, can reference $prev, $first, $steps[n], or $steps.alias',
|
|
60
|
+
},
|
|
61
|
+
as: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: "Optional alias for referencing this step's output",
|
|
64
|
+
},
|
|
65
|
+
when: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
description: "Optional condition for running this step (e.g., { $exists: '$prev.id' })",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ['command'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
options: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
description: 'Pipeline execution options',
|
|
76
|
+
properties: {
|
|
77
|
+
continueOnFailure: {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
description: 'Continue on failure or stop immediately',
|
|
80
|
+
},
|
|
81
|
+
timeoutMs: {
|
|
82
|
+
type: 'number',
|
|
83
|
+
description: 'Timeout for entire pipeline in milliseconds',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ['steps'],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const callToolSchema = {
|
|
92
|
+
name: 'afd-call',
|
|
93
|
+
description: 'Invoke any command by name with runtime input validation. Works in all server strategies.',
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
command: { type: 'string', description: 'Command name to invoke' },
|
|
98
|
+
input: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
description: "Command input (validated against the command's own schema at runtime)",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: ['command'],
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const discoverToolSchema = {
|
|
107
|
+
name: 'afd-discover',
|
|
108
|
+
description: 'List available commands with optional filtering by category, tag, or search text. Returns compact summaries.',
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: 'object',
|
|
111
|
+
properties: {
|
|
112
|
+
category: { type: 'string', description: 'Filter commands by category' },
|
|
113
|
+
tag: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Filter by tag(s). String for single, array for multiple.',
|
|
116
|
+
},
|
|
117
|
+
tagMode: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
enum: ['all', 'any'],
|
|
120
|
+
description: 'Tag matching mode (default: any)',
|
|
121
|
+
},
|
|
122
|
+
search: { type: 'string', description: 'Text search across names and descriptions' },
|
|
123
|
+
includeMutation: { type: 'boolean', description: 'Include mutation classification' },
|
|
124
|
+
limit: { type: 'number', description: 'Max results (1-200, default 50)' },
|
|
125
|
+
offset: { type: 'number', description: 'Results to skip for pagination' },
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
const detailToolSchema = {
|
|
130
|
+
name: 'afd-detail',
|
|
131
|
+
description: 'Get the full input schema and metadata for one or more commands by name.',
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
command: {
|
|
136
|
+
type: 'string',
|
|
137
|
+
description: 'Command name or names (exact match, kebab-case). String or array of strings (max 10).',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
required: ['command'],
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
144
|
+
// TOOLS LIST
|
|
145
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
146
|
+
/**
|
|
147
|
+
* Filter commands by active context.
|
|
148
|
+
* Includes commands whose `contexts` array includes the active context,
|
|
149
|
+
* plus commands with no `contexts` array (universal / backward compat).
|
|
150
|
+
*/
|
|
151
|
+
function filterByContext(commands, activeContext) {
|
|
152
|
+
if (!activeContext)
|
|
153
|
+
return commands;
|
|
154
|
+
return commands.filter((cmd) => !cmd.contexts?.length || cmd.contexts.includes(activeContext));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get the tools list based on toolStrategy.
|
|
158
|
+
*/
|
|
159
|
+
export function getToolsList(commands, toolStrategy, groupByFn, activeContext) {
|
|
160
|
+
const builtInTools = [batchToolSchema, pipeToolSchema, callToolSchema];
|
|
161
|
+
// Filter by active context before strategy-specific generation
|
|
162
|
+
const filtered = filterByContext(commands, activeContext);
|
|
163
|
+
// Lazy strategy: meta-tools + built-ins only
|
|
164
|
+
if (toolStrategy === 'lazy') {
|
|
165
|
+
return [discoverToolSchema, detailToolSchema, ...builtInTools];
|
|
166
|
+
}
|
|
167
|
+
// Individual strategy: each command is its own tool + built-ins
|
|
168
|
+
if (toolStrategy === 'individual') {
|
|
169
|
+
return [
|
|
170
|
+
...builtInTools,
|
|
171
|
+
...filtered.map((cmd) => {
|
|
172
|
+
const { type: _type, ...restSchema } = cmd.jsonSchema;
|
|
173
|
+
const hasMeta = (cmd.requires && cmd.requires.length > 0) ||
|
|
174
|
+
cmd.mutation != null ||
|
|
175
|
+
(cmd.examples && cmd.examples.length > 0) ||
|
|
176
|
+
cmd.outputJsonSchema != null ||
|
|
177
|
+
(cmd.contexts && cmd.contexts.length > 0);
|
|
178
|
+
return {
|
|
179
|
+
name: cmd.name,
|
|
180
|
+
description: cmd.description,
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: 'object',
|
|
183
|
+
...restSchema,
|
|
184
|
+
},
|
|
185
|
+
...(hasMeta && {
|
|
186
|
+
_meta: {
|
|
187
|
+
...(cmd.requires?.length && { requires: cmd.requires }),
|
|
188
|
+
...(cmd.mutation != null && { mutation: cmd.mutation }),
|
|
189
|
+
...(cmd.examples?.length && { examples: cmd.examples }),
|
|
190
|
+
...(cmd.outputJsonSchema && { outputSchema: cmd.outputJsonSchema }),
|
|
191
|
+
...(cmd.contexts?.length && { contexts: cmd.contexts }),
|
|
192
|
+
},
|
|
193
|
+
}),
|
|
194
|
+
};
|
|
195
|
+
}),
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
// Grouped strategy: commands grouped by category/entity
|
|
199
|
+
const defaultGroupFn = (cmd) => {
|
|
200
|
+
return cmd.category || cmd.name.split('-')[0] || 'general';
|
|
201
|
+
};
|
|
202
|
+
const getGroup = groupByFn || defaultGroupFn;
|
|
203
|
+
// Group commands by their group key
|
|
204
|
+
const groups = {};
|
|
205
|
+
for (const cmd of filtered) {
|
|
206
|
+
const group = getGroup(cmd) || 'general';
|
|
207
|
+
if (!groups[group]) {
|
|
208
|
+
groups[group] = [];
|
|
209
|
+
}
|
|
210
|
+
groups[group].push(cmd);
|
|
211
|
+
}
|
|
212
|
+
// Create a consolidated tool for each group
|
|
213
|
+
const groupedTools = Object.entries(groups).map(([groupName, groupCmds]) => {
|
|
214
|
+
// Build action enum from command names
|
|
215
|
+
const actions = groupCmds.map((cmd) => {
|
|
216
|
+
// Extract action from command name (e.g., "todo-create" -> "create")
|
|
217
|
+
const parts = cmd.name.split('-');
|
|
218
|
+
return parts.length > 1 ? parts.slice(1).join('-') : cmd.name;
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
name: groupName,
|
|
222
|
+
description: `${groupName} operations: ${actions.join(', ')}`,
|
|
223
|
+
inputSchema: {
|
|
224
|
+
type: 'object',
|
|
225
|
+
properties: {
|
|
226
|
+
action: {
|
|
227
|
+
type: 'string',
|
|
228
|
+
enum: actions,
|
|
229
|
+
description: `Action to perform: ${actions.join(' | ')}`,
|
|
230
|
+
},
|
|
231
|
+
// Note: Full discriminated union would require merging all command schemas
|
|
232
|
+
// For now, we use a generic "params" object
|
|
233
|
+
params: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
description: 'Parameters for the action (varies by action)',
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
required: ['action'],
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
return [...builtInTools, ...groupedTools];
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,kFAAkF;AAClF,wBAAwB;AACxB,kFAAkF;AAElF,MAAM,eAAe,GAAG;IACv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