@lushly-dev/afd-server 0.4.0 → 0.5.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.
Files changed (55) hide show
  1. package/README.md +110 -0
  2. package/dist/bootstrap/afd-context.d.ts +60 -0
  3. package/dist/bootstrap/afd-context.d.ts.map +1 -0
  4. package/dist/bootstrap/afd-context.js +132 -0
  5. package/dist/bootstrap/afd-context.js.map +1 -0
  6. package/dist/bootstrap/afd-help.d.ts +2 -1
  7. package/dist/bootstrap/afd-help.d.ts.map +1 -1
  8. package/dist/bootstrap/afd-help.js +4 -1
  9. package/dist/bootstrap/afd-help.js.map +1 -1
  10. package/dist/bootstrap/index.d.ts +1 -0
  11. package/dist/bootstrap/index.d.ts.map +1 -1
  12. package/dist/bootstrap/index.js +1 -0
  13. package/dist/bootstrap/index.js.map +1 -1
  14. package/dist/bootstrap/registry.d.ts +4 -0
  15. package/dist/bootstrap/registry.d.ts.map +1 -1
  16. package/dist/bootstrap/registry.js +8 -1
  17. package/dist/bootstrap/registry.js.map +1 -1
  18. package/dist/execution.d.ts +19 -0
  19. package/dist/execution.d.ts.map +1 -0
  20. package/dist/execution.js +389 -0
  21. package/dist/execution.js.map +1 -0
  22. package/dist/handoff-schema.d.ts +14 -14
  23. package/dist/http-handler.d.ts +28 -0
  24. package/dist/http-handler.d.ts.map +1 -0
  25. package/dist/http-handler.js +292 -0
  26. package/dist/http-handler.js.map +1 -0
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/lazy-tools.d.ts +64 -0
  32. package/dist/lazy-tools.d.ts.map +1 -0
  33. package/dist/lazy-tools.js +144 -0
  34. package/dist/lazy-tools.js.map +1 -0
  35. package/dist/schema.d.ts +25 -1
  36. package/dist/schema.d.ts.map +1 -1
  37. package/dist/schema.js +20 -1
  38. package/dist/schema.js.map +1 -1
  39. package/dist/server-types.d.ts +138 -0
  40. package/dist/server-types.d.ts.map +1 -0
  41. package/dist/server-types.js +13 -0
  42. package/dist/server-types.js.map +1 -0
  43. package/dist/server.d.ts +6 -121
  44. package/dist/server.d.ts.map +1 -1
  45. package/dist/server.js +67 -1125
  46. package/dist/server.js.map +1 -1
  47. package/dist/tool-router.d.ts +36 -0
  48. package/dist/tool-router.d.ts.map +1 -0
  49. package/dist/tool-router.js +246 -0
  50. package/dist/tool-router.js.map +1 -0
  51. package/dist/tools.d.ts +428 -0
  52. package/dist/tools.d.ts.map +1 -0
  53. package/dist/tools.js +244 -0
  54. package/dist/tools.js.map +1 -0
  55. package/package.json +3 -3
package/README.md CHANGED
@@ -18,6 +18,7 @@ pnpm add @lushly-dev/afd-server
18
18
  - **Auto Transport Detection** - Automatically selects the right transport based on environment
19
19
  - **Built-in Validation** - Automatic input validation before handler execution
20
20
  - **Middleware System** - Logging, tracing, rate limiting, and custom middleware
21
+ - **Command Prerequisites** - Declare `requires` dependencies so agents can plan execution order
21
22
  - **Full TypeScript Support** - Complete type inference from Zod schemas
22
23
 
23
24
  ## Quick Start
@@ -187,6 +188,64 @@ const getUser = defineCommand({
187
188
  });
188
189
  ```
189
190
 
191
+ ### Command with Prerequisites
192
+
193
+ ```typescript
194
+ const secretData = defineCommand({
195
+ name: 'secret-data',
196
+ description: 'Return sensitive data for the authenticated user',
197
+ requires: ['auth-sign-in'], // Agent sees this before calling
198
+ input: z.object({}),
199
+
200
+ async handler(input, context) {
201
+ return success({ secret: '...' });
202
+ },
203
+ });
204
+ ```
205
+
206
+ Prerequisites are metadata — they tell agents what to call first but are not enforced at runtime (middleware handles enforcement). They appear in MCP tool `_meta` and `afd-help` output.
207
+
208
+ ### Command with Output Schema
209
+
210
+ Declare what a command returns so agents know the response shape before calling:
211
+
212
+ ```typescript
213
+ const Todo = z.object({
214
+ id: z.string(),
215
+ title: z.string(),
216
+ done: z.boolean(),
217
+ });
218
+
219
+ const listTodos = defineCommand({
220
+ name: 'todo-list',
221
+ description: 'List all todo items',
222
+ input: z.object({ filter: z.enum(['all', 'active', 'done']).optional() }),
223
+ output: Todo.array(), // Agents see this in _meta.outputSchema and afd-detail
224
+ async handler(input) {
225
+ const todos = await store.list(input.filter);
226
+ return success(todos, { reasoning: `Found ${todos.length} todos` });
227
+ },
228
+ });
229
+ ```
230
+
231
+ Output schemas are optional (backward compatible). They describe the shape of `CommandResult.data`, not the full envelope. No runtime output validation is performed.
232
+
233
+ ### Command with Context Scoping
234
+
235
+ Restrict commands to specific contexts for large command sets:
236
+
237
+ ```typescript
238
+ const formatDoc = defineCommand({
239
+ name: 'doc-format',
240
+ description: 'Format the current document',
241
+ contexts: ['editing'], // Only visible when 'editing' context is active
242
+ input: z.object({ style: z.string() }),
243
+ async handler(input) { ... },
244
+ });
245
+ ```
246
+
247
+ Commands without `contexts` are universal (always visible). See "Context Management" below for server-level context configuration.
248
+
190
249
  ## Server Configuration
191
250
 
192
251
  ```typescript
@@ -358,6 +417,8 @@ Create a command definition with Zod schema.
358
417
  | `mutation` | boolean | No | Whether command has side effects |
359
418
  | `version` | string | No | Command version |
360
419
  | `tags` | string[] | No | Additional tags |
420
+ | `output` | ZodType | No | Output schema — declares response `data` shape for agent introspection |
421
+ | `contexts` | string[] | No | Restrict command to specific contexts (omit for universal) |
361
422
  | `requires` | string[] | No | Commands that should be called before this one (metadata only) |
362
423
  | `errors` | string[] | No | Possible error codes |
363
424
 
@@ -373,6 +434,8 @@ Create an MCP server from commands.
373
434
  | `transport` | `'stdio' \| 'http' \| 'auto'` | No | Transport protocol (default: `'auto'`) |
374
435
  | `port` | number | No | Port for HTTP transport (default: 3100) |
375
436
  | `host` | string | No | Host for HTTP transport (default: localhost) |
437
+ | `toolStrategy` | `'individual' \| 'grouped' \| 'lazy'` | No | How commands appear as MCP tools (default: `'grouped'`) |
438
+ | `contexts` | `{ name, description }[]` | No | Context scopes for dynamic tool filtering |
376
439
  | `devMode` | boolean | No | Enable development mode (default: false) |
377
440
  | `cors` | boolean | No | Enable CORS for HTTP transport (default: follows devMode) |
378
441
  | `middleware` | array | No | Middleware functions |
@@ -467,6 +530,53 @@ const server = createMcpServer({
467
530
  });
468
531
  ```
469
532
 
533
+ ## Lazy Strategy
534
+
535
+ For servers with many commands, the `lazy` strategy exposes 5 meta-tools instead of listing all commands:
536
+
537
+ ```typescript
538
+ const server = createMcpServer({
539
+ name: 'my-server',
540
+ version: '1.0.0',
541
+ commands: allCommands,
542
+ toolStrategy: 'lazy',
543
+ });
544
+ ```
545
+
546
+ Agents discover commands at runtime: `afd-discover` (filter/list) → `afd-detail` (get schemas) → `afd-call` (execute).
547
+
548
+ | Meta-Tool | Description |
549
+ |-----------|-------------|
550
+ | `afd-discover` | List commands by category, tag, or search (paginated, max 200) |
551
+ | `afd-detail` | Get full schema for 1–10 commands by name |
552
+ | `afd-call` | Universal dispatcher — available in all strategies |
553
+ | `afd-batch` | Execute multiple commands in one call |
554
+ | `afd-pipe` | Pipeline execution with step references |
555
+
556
+ ## Context Management
557
+
558
+ Dynamic context scoping filters which commands are visible:
559
+
560
+ ```typescript
561
+ const server = createMcpServer({
562
+ name: 'my-server',
563
+ version: '1.0.0',
564
+ commands: allCommands,
565
+ contexts: [
566
+ { name: 'editing', description: 'Document editing tools' },
567
+ { name: 'reviewing', description: 'Review and approval tools' },
568
+ ],
569
+ });
570
+ ```
571
+
572
+ When contexts are configured, the server registers three additional bootstrap commands:
573
+
574
+ - **`afd-context-list`** — Lists all contexts and the active context
575
+ - **`afd-context-enter`** — Pushes a context onto the stack (filters visible tools)
576
+ - **`afd-context-exit`** — Pops the current context (restores previous)
577
+
578
+ Commands without `contexts` are always visible. Context commands themselves are always visible.
579
+
470
580
  ## Related
471
581
 
472
582
  - [@lushly-dev/afd-core](../core) - Core types and helpers
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @fileoverview afd-context bootstrap commands
3
+ *
4
+ * Context management commands for dynamic tool scoping.
5
+ * Always available regardless of active context (universal tools).
6
+ */
7
+ import type { CommandDefinition } from '@lushly-dev/afd-core';
8
+ import { z } from 'zod';
9
+ import type { ContextConfig } from '../server-types.js';
10
+ export interface ContextState {
11
+ stack: string[];
12
+ getActive(): string | null;
13
+ enter(name: string): void;
14
+ exit(): string | null;
15
+ }
16
+ /**
17
+ * Create a shared context state manager.
18
+ */
19
+ export declare function createContextState(): ContextState;
20
+ declare const listInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
21
+ interface ContextInfo {
22
+ name: string;
23
+ description?: string;
24
+ triggers?: string[];
25
+ priority?: number;
26
+ }
27
+ interface ContextListOutput {
28
+ contexts: ContextInfo[];
29
+ activeContext: string | null;
30
+ }
31
+ /**
32
+ * Create the afd-context-list bootstrap command.
33
+ */
34
+ export declare function createAfdContextListCommand(getContexts: () => ContextConfig[], contextState: ContextState): CommandDefinition<z.infer<typeof listInputSchema>, ContextListOutput>;
35
+ declare const enterInputSchema: z.ZodObject<{
36
+ context: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ context: string;
39
+ }, {
40
+ context: string;
41
+ }>;
42
+ interface ContextEnterOutput {
43
+ entered: string;
44
+ previous: string | null;
45
+ }
46
+ /**
47
+ * Create the afd-context-enter bootstrap command.
48
+ */
49
+ export declare function createAfdContextEnterCommand(getContexts: () => ContextConfig[], contextState: ContextState): CommandDefinition<z.infer<typeof enterInputSchema>, ContextEnterOutput>;
50
+ declare const exitInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
51
+ interface ContextExitOutput {
52
+ exited: string | null;
53
+ current: string | null;
54
+ }
55
+ /**
56
+ * Create the afd-context-exit bootstrap command.
57
+ */
58
+ export declare function createAfdContextExitCommand(contextState: ContextState): CommandDefinition<z.infer<typeof exitInputSchema>, ContextExitOutput>;
59
+ export {};
60
+ //# sourceMappingURL=afd-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afd-context.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-context.ts"],"names":[],"mappings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OAAO,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,CAsCzE;AAMD,QAAA,MAAM,eAAe,gDAAe,CAAC;AAErC,UAAU,iBAAiB;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,YAAY,EAAE,YAAY,GACxB,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,EAAE,iBAAiB,CAAC,CAyBvE"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @fileoverview afd-context bootstrap commands
3
+ *
4
+ * Context management commands for dynamic tool scoping.
5
+ * Always available regardless of active context (universal tools).
6
+ */
7
+ import { failure, success } from '@lushly-dev/afd-core';
8
+ import { z } from 'zod';
9
+ /**
10
+ * Create a shared context state manager.
11
+ */
12
+ export function createContextState() {
13
+ const stack = [];
14
+ return {
15
+ stack,
16
+ getActive() {
17
+ return stack.length > 0 ? (stack[stack.length - 1] ?? null) : null;
18
+ },
19
+ enter(name) {
20
+ stack.push(name);
21
+ },
22
+ exit() {
23
+ return stack.pop() ?? null;
24
+ },
25
+ };
26
+ }
27
+ // ═══════════════════════════════════════════════════════════════════════════════
28
+ // afd-context-list
29
+ // ═══════════════════════════════════════════════════════════════════════════════
30
+ const listInputSchema = z.object({});
31
+ /**
32
+ * Create the afd-context-list bootstrap command.
33
+ */
34
+ export function createAfdContextListCommand(getContexts, contextState) {
35
+ return {
36
+ name: 'afd-context-list',
37
+ description: 'List all configured contexts with descriptions, priorities, and triggers',
38
+ category: 'bootstrap',
39
+ tags: ['bootstrap', 'read', 'safe', 'context'],
40
+ mutation: false,
41
+ version: '1.0.0',
42
+ parameters: [],
43
+ async handler() {
44
+ const configs = getContexts();
45
+ const contexts = configs
46
+ .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
47
+ .map((c) => ({
48
+ name: c.name,
49
+ ...(c.description && { description: c.description }),
50
+ ...(c.triggers?.length && { triggers: c.triggers }),
51
+ ...(c.priority != null && { priority: c.priority }),
52
+ }));
53
+ return success({
54
+ contexts,
55
+ activeContext: contextState.getActive(),
56
+ }, {
57
+ reasoning: `Found ${contexts.length} configured contexts. Active: ${contextState.getActive() ?? 'none'}`,
58
+ confidence: 1.0,
59
+ });
60
+ },
61
+ };
62
+ }
63
+ // ═══════════════════════════════════════════════════════════════════════════════
64
+ // afd-context-enter
65
+ // ═══════════════════════════════════════════════════════════════════════════════
66
+ const enterInputSchema = z.object({
67
+ context: z.string().min(1).describe('Context name to enter'),
68
+ });
69
+ /**
70
+ * Create the afd-context-enter bootstrap command.
71
+ */
72
+ export function createAfdContextEnterCommand(getContexts, contextState) {
73
+ return {
74
+ name: 'afd-context-enter',
75
+ description: 'Enter a context to scope available tools',
76
+ category: 'bootstrap',
77
+ tags: ['bootstrap', 'write', 'context'],
78
+ mutation: true,
79
+ version: '1.0.0',
80
+ parameters: [
81
+ { name: 'context', type: 'string', required: true, description: 'Context name to enter' },
82
+ ],
83
+ async handler(input) {
84
+ const configs = getContexts();
85
+ const contextName = input.context;
86
+ const exists = configs.some((c) => c.name === contextName);
87
+ if (!exists) {
88
+ const available = configs.map((c) => c.name).join(', ');
89
+ return failure({
90
+ code: 'CONTEXT_NOT_FOUND',
91
+ message: `Context '${contextName}' is not configured`,
92
+ suggestion: `Available contexts: ${available}. Use afd-context-list to see all contexts.`,
93
+ });
94
+ }
95
+ const previous = contextState.getActive();
96
+ contextState.enter(contextName);
97
+ return success({ entered: contextName, previous }, {
98
+ reasoning: `Entered context '${contextName}'${previous ? ` (was '${previous}')` : ''}`,
99
+ confidence: 1.0,
100
+ });
101
+ },
102
+ };
103
+ }
104
+ // ═══════════════════════════════════════════════════════════════════════════════
105
+ // afd-context-exit
106
+ // ═══════════════════════════════════════════════════════════════════════════════
107
+ const exitInputSchema = z.object({});
108
+ /**
109
+ * Create the afd-context-exit bootstrap command.
110
+ */
111
+ export function createAfdContextExitCommand(contextState) {
112
+ return {
113
+ name: 'afd-context-exit',
114
+ description: 'Exit the current context, popping back to the previous one',
115
+ category: 'bootstrap',
116
+ tags: ['bootstrap', 'write', 'context'],
117
+ mutation: true,
118
+ version: '1.0.0',
119
+ parameters: [],
120
+ async handler() {
121
+ const exited = contextState.exit();
122
+ const current = contextState.getActive();
123
+ return success({ exited, current }, {
124
+ reasoning: exited
125
+ ? `Exited context '${exited}'${current ? `, now in '${current}'` : ', no active context'}`
126
+ : 'No active context to exit',
127
+ confidence: 1.0,
128
+ });
129
+ },
130
+ };
131
+ }
132
+ //# sourceMappingURL=afd-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afd-context.js","sourceRoot":"","sources":["../../src/bootstrap/afd-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB;;GAEG;AACH,MAAM,UAAU,kBAAkB;IACjC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,OAAO;QACN,KAAK;QACL,SAAS;YACR,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,CAAC;QACD,KAAK,CAAC,IAAY;YACjB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QACD,IAAI;YACH,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC;QAC5B,CAAC;KACD,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,mBAAmB;AACnB,kFAAkF;AAElF,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAcrC;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAC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C,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAEhC,OAAO,OAAO,CACb,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,EAClC;gBACC,SAAS,EAAE,oBAAoB,WAAW,IAAI,QAAQ,CAAC,CAAC,CAAC,UAAU,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACtF,UAAU,EAAE,GAAG;aACf,CACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,mBAAmB;AACnB,kFAAkF;AAElF,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAOrC;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAC1C,YAA0B;IAE1B,OAAO;QACN,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,4DAA4D;QACzE,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC;QACvC,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,EAAE;QAEd,KAAK,CAAC,OAAO;YACZ,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;YAEzC,OAAO,OAAO,CACb,EAAE,MAAM,EAAE,OAAO,EAAE,EACnB;gBACC,SAAS,EAAE,MAAM;oBAChB,CAAC,CAAC,mBAAmB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,aAAa,OAAO,GAAG,CAAC,CAAC,CAAC,qBAAqB,EAAE;oBAC1F,CAAC,CAAC,2BAA2B;gBAC9B,UAAU,EAAE,GAAG;aACf,CACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * List all available commands with tags and grouping.
5
5
  */
6
- import type { CommandDefinition } from '@lushly-dev/afd-core';
6
+ import type { CommandDefinition, CommandExample } from '@lushly-dev/afd-core';
7
7
  import { z } from 'zod';
8
8
  declare const inputSchema: z.ZodObject<{
9
9
  filter: z.ZodOptional<z.ZodString>;
@@ -23,6 +23,7 @@ interface CommandInfo {
23
23
  tags?: string[];
24
24
  mutation?: boolean;
25
25
  requires?: string[];
26
+ examples?: CommandExample[];
26
27
  }
27
28
  interface HelpOutput {
28
29
  commands: CommandInfo[];
@@ -1 +1 @@
1
- {"version":3,"file":"afd-help.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAEH,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE7C,UAAU,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,UAAU,UAAU;IACnB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,iBAAiB,EAAE,GACpC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAwE1C"}
1
+ {"version":3,"file":"afd-help.d.ts","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAEH,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE7C,UAAU,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,UAAU,UAAU;IACnB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,iBAAiB,EAAE,GACpC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CA4E1C"}
@@ -43,11 +43,14 @@ export function createAfdHelpCommand(getCommands) {
43
43
  name: cmd.name,
44
44
  description: cmd.description,
45
45
  };
46
+ if (cmd.requires?.length) {
47
+ info.requires = cmd.requires;
48
+ }
46
49
  if (input.format === 'full') {
47
50
  info.category = cmd.category;
48
51
  info.tags = cmd.tags;
49
52
  info.mutation = cmd.mutation;
50
- info.requires = cmd.requires;
53
+ info.examples = cmd.examples;
51
54
  }
52
55
  return info;
53
56
  });
@@ -1 +1 @@
1
- {"version":3,"file":"afd-help.js","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts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*/
7
+ export { type ContextState, createAfdContextEnterCommand, createAfdContextExitCommand, createAfdContextListCommand, createContextState, } from './afd-context.js';
7
8
  export { createAfdDocsCommand } from './afd-docs.js';
8
9
  export { createAfdHelpCommand } from './afd-help.js';
9
10
  export { createAfdSchemaCommand } from './afd-schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,KAAK,YAAY,EACjB,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
@@ -4,6 +4,7 @@
4
4
  * These tools are automatically added to every AFD MCP server to enable
5
5
  * agent discovery and onboarding.
6
6
  */
7
+ export { createAfdContextEnterCommand, createAfdContextExitCommand, createAfdContextListCommand, createContextState, } from './afd-context.js';
7
8
  export { createAfdDocsCommand } from './afd-docs.js';
8
9
  export { createAfdHelpCommand } from './afd-help.js';
9
10
  export { createAfdSchemaCommand } from './afd-schema.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEN,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
@@ -4,6 +4,8 @@
4
4
  * Provides a function to get all bootstrap commands for an AFD server.
5
5
  */
6
6
  import type { CommandDefinition } from '@lushly-dev/afd-core';
7
+ import type { ContextConfig } from '../server-types.js';
8
+ import { type ContextState } from './afd-context.js';
7
9
  /**
8
10
  * Get all bootstrap commands for an AFD server.
9
11
  *
@@ -13,5 +15,7 @@ import type { CommandDefinition } from '@lushly-dev/afd-core';
13
15
  */
14
16
  export declare function getBootstrapCommands(getCommands: () => CommandDefinition[], options?: {
15
17
  getJsonSchema?: (cmd: CommandDefinition) => Record<string, unknown>;
18
+ contexts?: ContextConfig[];
19
+ contextState?: ContextState;
16
20
  }): CommandDefinition[];
17
21
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAK9D;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,iBAAiB,EAAE,EACtC,OAAO,CAAC,EAAE;IACT,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpE,GACC,iBAAiB,EAAE,CAQrB"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,KAAK,YAAY,EAIjB,MAAM,kBAAkB,CAAC;AAK1B;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,iBAAiB,EAAE,EACtC,OAAO,CAAC,EAAE;IACT,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B,GACC,iBAAiB,EAAE,CA0BrB"}
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Provides a function to get all bootstrap commands for an AFD server.
5
5
  */
6
+ import { createAfdContextEnterCommand, createAfdContextExitCommand, createAfdContextListCommand, } from './afd-context.js';
6
7
  import { createAfdDocsCommand } from './afd-docs.js';
7
8
  import { createAfdHelpCommand } from './afd-help.js';
8
9
  import { createAfdSchemaCommand } from './afd-schema.js';
@@ -16,10 +17,16 @@ import { createAfdSchemaCommand } from './afd-schema.js';
16
17
  export function getBootstrapCommands(getCommands, options) {
17
18
  // SAFETY: Each creator returns CommandDefinition<SpecificInput, SpecificOutput>, which is structurally
18
19
  // compatible with CommandDefinition but TypeScript's invariant generics require the double cast.
19
- return [
20
+ const cmds = [
20
21
  createAfdHelpCommand(getCommands),
21
22
  createAfdDocsCommand(getCommands),
22
23
  createAfdSchemaCommand(getCommands, options?.getJsonSchema),
23
24
  ];
25
+ // Add context commands when contexts are configured
26
+ if (options?.contexts?.length && options.contextState) {
27
+ const getContexts = () => options.contexts ?? [];
28
+ cmds.push(createAfdContextListCommand(getContexts, options.contextState), createAfdContextEnterCommand(getContexts, options.contextState), createAfdContextExitCommand(options.contextState));
29
+ }
30
+ return cmds;
24
31
  }
25
32
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,WAAsC,EACtC,OAEC;IAED,uGAAuG;IACvG,iGAAiG;IACjG,OAAO;QACN,oBAAoB,CAAC,WAAW,CAAiC;QACjE,oBAAoB,CAAC,WAAW,CAAiC;QACjE,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,CAAiC;KAC3F,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAEN,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,WAAsC,EACtC,OAIC;IAED,uGAAuG;IACvG,iGAAiG;IACjG,MAAM,IAAI,GAAwB;QACjC,oBAAoB,CAAC,WAAW,CAAiC;QACjE,oBAAoB,CAAC,WAAW,CAAiC;QACjE,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,aAAa,CAAiC;KAC3F,CAAC;IAEF,oDAAoD;IACpD,IAAI,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CACR,2BAA2B,CAC1B,WAAW,EACX,OAAO,CAAC,YAAY,CACY,EACjC,4BAA4B,CAC3B,WAAW,EACX,OAAO,CAAC,YAAY,CACY,EACjC,2BAA2B,CAAC,OAAO,CAAC,YAAY,CAAiC,CACjF,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @fileoverview Command execution engine — single, batch, pipeline, and streaming execution.
3
+ */
4
+ import type { BatchRequest, BatchResult, CommandContext, CommandMiddleware, CommandResult, PipelineRequest, PipelineResult, StreamChunk } from '@lushly-dev/afd-core';
5
+ import type { ZodCommandDefinition } from './schema.js';
6
+ export interface ExecutionDeps {
7
+ commandMap: Map<string, ZodCommandDefinition>;
8
+ middleware: CommandMiddleware[];
9
+ devMode: boolean;
10
+ onCommand?: (command: string, input: unknown, result: CommandResult) => void;
11
+ onError?: (error: Error) => void;
12
+ }
13
+ export declare function createExecutionEngine(deps: ExecutionDeps): {
14
+ executeCommand: (commandName: string, input: unknown, context?: CommandContext) => Promise<CommandResult>;
15
+ executeBatch: (request: BatchRequest, context?: CommandContext) => Promise<BatchResult>;
16
+ executePipeline: (request: PipelineRequest, context?: CommandContext) => Promise<PipelineResult>;
17
+ executeStream: (commandName: string, input: unknown, context?: CommandContext) => AsyncGenerator<StreamChunk, void, unknown>;
18
+ };
19
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAEX,YAAY,EACZ,WAAW,EAEX,cAAc,EACd,iBAAiB,EACjB,aAAa,EAGb,eAAe,EACf,cAAc,EAEd,WAAW,EACX,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAOxD,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC9C,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAMD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa;kCAO1C,MAAM,SACZ,OAAO,YACL,cAAc,KACrB,OAAO,CAAC,aAAa,CAAC;4BAiFf,YAAY,YACZ,cAAc,KACrB,OAAO,CAAC,WAAW,CAAC;+BAwGb,eAAe,YACf,cAAc,KACrB,OAAO,CAAC,cAAc,CAAC;iCA8KZ,MAAM,SACZ,OAAO,YACL,cAAc,KACrB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;EA+D7C"}