@lushly-dev/afd-server 2.2.1 → 2.4.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 (220) hide show
  1. package/README.md +468 -6
  2. package/dist/approval-crypto.d.ts +26 -4
  3. package/dist/approval-crypto.d.ts.map +1 -1
  4. package/dist/approval-crypto.js +90 -7
  5. package/dist/approval-crypto.js.map +1 -1
  6. package/dist/approval-relay.d.ts +5 -5
  7. package/dist/approval-relay.d.ts.map +1 -1
  8. package/dist/approval.d.ts +6 -1
  9. package/dist/approval.d.ts.map +1 -1
  10. package/dist/approval.js +43 -32
  11. package/dist/approval.js.map +1 -1
  12. package/dist/bootstrap/afd-context.d.ts +2 -27
  13. package/dist/bootstrap/afd-context.d.ts.map +1 -1
  14. package/dist/bootstrap/afd-context.js +6 -36
  15. package/dist/bootstrap/afd-context.js.map +1 -1
  16. package/dist/bootstrap/afd-help.d.ts +24 -2
  17. package/dist/bootstrap/afd-help.d.ts.map +1 -1
  18. package/dist/bootstrap/afd-help.js +17 -2
  19. package/dist/bootstrap/afd-help.js.map +1 -1
  20. package/dist/bootstrap/described-command.d.ts +1 -0
  21. package/dist/bootstrap/described-command.d.ts.map +1 -1
  22. package/dist/bootstrap/described-command.js.map +1 -1
  23. package/dist/bootstrap/registry.d.ts +13 -0
  24. package/dist/bootstrap/registry.d.ts.map +1 -1
  25. package/dist/bootstrap/registry.js +30 -1
  26. package/dist/bootstrap/registry.js.map +1 -1
  27. package/dist/command-allow.d.ts +31 -0
  28. package/dist/command-allow.d.ts.map +1 -0
  29. package/dist/command-allow.js +55 -0
  30. package/dist/command-allow.js.map +1 -0
  31. package/dist/command-names.d.ts +17 -0
  32. package/dist/command-names.d.ts.map +1 -1
  33. package/dist/command-names.js +55 -0
  34. package/dist/command-names.js.map +1 -1
  35. package/dist/command-routing.d.ts +10 -3
  36. package/dist/command-routing.d.ts.map +1 -1
  37. package/dist/command-routing.js +18 -7
  38. package/dist/command-routing.js.map +1 -1
  39. package/dist/confirmation-gate.d.ts +32 -0
  40. package/dist/confirmation-gate.d.ts.map +1 -0
  41. package/dist/confirmation-gate.js +140 -0
  42. package/dist/confirmation-gate.js.map +1 -0
  43. package/dist/confirmations.d.ts +15 -23
  44. package/dist/confirmations.d.ts.map +1 -1
  45. package/dist/confirmations.js +8 -127
  46. package/dist/confirmations.js.map +1 -1
  47. package/dist/context-fields-describe.d.ts +18 -0
  48. package/dist/context-fields-describe.d.ts.map +1 -0
  49. package/dist/context-fields-describe.js +17 -0
  50. package/dist/context-fields-describe.js.map +1 -0
  51. package/dist/context-fields.d.ts +50 -0
  52. package/dist/context-fields.d.ts.map +1 -0
  53. package/dist/context-fields.js +146 -0
  54. package/dist/context-fields.js.map +1 -0
  55. package/dist/context-scope.d.ts +29 -2
  56. package/dist/context-scope.d.ts.map +1 -1
  57. package/dist/context-scope.js +37 -1
  58. package/dist/context-scope.js.map +1 -1
  59. package/dist/credentials.d.ts +17 -0
  60. package/dist/credentials.d.ts.map +1 -0
  61. package/dist/credentials.js +16 -0
  62. package/dist/credentials.js.map +1 -0
  63. package/dist/define-core.d.ts +213 -0
  64. package/dist/define-core.d.ts.map +1 -0
  65. package/dist/define-core.js +161 -0
  66. package/dist/define-core.js.map +1 -0
  67. package/dist/define.d.ts +13 -8
  68. package/dist/define.d.ts.map +1 -1
  69. package/dist/define.js +13 -8
  70. package/dist/define.js.map +1 -1
  71. package/dist/direct-registry.d.ts +154 -7
  72. package/dist/direct-registry.d.ts.map +1 -1
  73. package/dist/direct-registry.js +111 -13
  74. package/dist/direct-registry.js.map +1 -1
  75. package/dist/direct-tool-surface.d.ts +66 -0
  76. package/dist/direct-tool-surface.d.ts.map +1 -0
  77. package/dist/direct-tool-surface.js +162 -0
  78. package/dist/direct-tool-surface.js.map +1 -0
  79. package/dist/direct.d.ts +68 -0
  80. package/dist/direct.d.ts.map +1 -0
  81. package/dist/direct.js +66 -0
  82. package/dist/direct.js.map +1 -0
  83. package/dist/execution.d.ts +11 -1
  84. package/dist/execution.d.ts.map +1 -1
  85. package/dist/execution.js +18 -4
  86. package/dist/execution.js.map +1 -1
  87. package/dist/frontmatter.d.ts +16 -0
  88. package/dist/frontmatter.d.ts.map +1 -0
  89. package/dist/frontmatter.js +111 -0
  90. package/dist/frontmatter.js.map +1 -0
  91. package/dist/http-handler.d.ts +11 -2
  92. package/dist/http-handler.d.ts.map +1 -1
  93. package/dist/http-handler.js +46 -15
  94. package/dist/http-handler.js.map +1 -1
  95. package/dist/http-security.d.ts.map +1 -1
  96. package/dist/http-security.js.map +1 -1
  97. package/dist/http-sessions.d.ts +12 -4
  98. package/dist/http-sessions.d.ts.map +1 -1
  99. package/dist/http-sessions.js +4 -4
  100. package/dist/http-sessions.js.map +1 -1
  101. package/dist/http-sse.js.map +1 -1
  102. package/dist/index.d.ts +16 -4
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +20 -4
  105. package/dist/index.js.map +1 -1
  106. package/dist/issue-message.d.ts +20 -0
  107. package/dist/issue-message.d.ts.map +1 -0
  108. package/dist/issue-message.js +55 -0
  109. package/dist/issue-message.js.map +1 -0
  110. package/dist/journal-replay.d.ts +7 -0
  111. package/dist/journal-replay.d.ts.map +1 -1
  112. package/dist/journal-replay.js +18 -1
  113. package/dist/journal-replay.js.map +1 -1
  114. package/dist/journal.d.ts +9 -1
  115. package/dist/journal.d.ts.map +1 -1
  116. package/dist/journal.js +44 -1
  117. package/dist/journal.js.map +1 -1
  118. package/dist/json-rpc.d.ts +2 -2
  119. package/dist/json-rpc.d.ts.map +1 -1
  120. package/dist/json-rpc.js.map +1 -1
  121. package/dist/json-schema.d.ts +30 -0
  122. package/dist/json-schema.d.ts.map +1 -0
  123. package/dist/json-schema.js +25 -0
  124. package/dist/json-schema.js.map +1 -0
  125. package/dist/lazy-tools.d.ts +3 -0
  126. package/dist/lazy-tools.d.ts.map +1 -1
  127. package/dist/lazy-tools.js +2 -0
  128. package/dist/lazy-tools.js.map +1 -1
  129. package/dist/mcp-auth-bearer.d.ts +23 -0
  130. package/dist/mcp-auth-bearer.d.ts.map +1 -0
  131. package/dist/mcp-auth-bearer.js +50 -0
  132. package/dist/mcp-auth-bearer.js.map +1 -0
  133. package/dist/mcp-auth-jwt.d.ts +178 -0
  134. package/dist/mcp-auth-jwt.d.ts.map +1 -0
  135. package/dist/mcp-auth-jwt.js +365 -0
  136. package/dist/mcp-auth-jwt.js.map +1 -0
  137. package/dist/mcp-auth-resource.d.ts +74 -0
  138. package/dist/mcp-auth-resource.d.ts.map +1 -0
  139. package/dist/mcp-auth-resource.js +196 -0
  140. package/dist/mcp-auth-resource.js.map +1 -0
  141. package/dist/mcp-auth-rules.d.ts +135 -0
  142. package/dist/mcp-auth-rules.d.ts.map +1 -0
  143. package/dist/mcp-auth-rules.js +306 -0
  144. package/dist/mcp-auth-rules.js.map +1 -0
  145. package/dist/mcp-auth.d.ts +81 -0
  146. package/dist/mcp-auth.d.ts.map +1 -0
  147. package/dist/mcp-auth.js +256 -0
  148. package/dist/mcp-auth.js.map +1 -0
  149. package/dist/mcp-modern.d.ts +29 -5
  150. package/dist/mcp-modern.d.ts.map +1 -1
  151. package/dist/mcp-modern.js +99 -19
  152. package/dist/mcp-modern.js.map +1 -1
  153. package/dist/meta-argument.d.ts +42 -0
  154. package/dist/meta-argument.d.ts.map +1 -0
  155. package/dist/meta-argument.js +102 -0
  156. package/dist/meta-argument.js.map +1 -0
  157. package/dist/meta-keys.d.ts +29 -0
  158. package/dist/meta-keys.d.ts.map +1 -0
  159. package/dist/meta-keys.js +90 -0
  160. package/dist/meta-keys.js.map +1 -0
  161. package/dist/meta-tools.d.ts +8 -1
  162. package/dist/meta-tools.d.ts.map +1 -1
  163. package/dist/meta-tools.js +17 -7
  164. package/dist/meta-tools.js.map +1 -1
  165. package/dist/middleware.d.ts.map +1 -1
  166. package/dist/middleware.js +0 -1
  167. package/dist/middleware.js.map +1 -1
  168. package/dist/patterns.d.ts +46 -0
  169. package/dist/patterns.d.ts.map +1 -0
  170. package/dist/patterns.js +38 -0
  171. package/dist/patterns.js.map +1 -0
  172. package/dist/principal-binding.d.ts +42 -0
  173. package/dist/principal-binding.d.ts.map +1 -0
  174. package/dist/principal-binding.js +70 -0
  175. package/dist/principal-binding.js.map +1 -0
  176. package/dist/request-context.d.ts +7 -1
  177. package/dist/request-context.d.ts.map +1 -1
  178. package/dist/request-context.js +14 -3
  179. package/dist/request-context.js.map +1 -1
  180. package/dist/resources.d.ts +122 -0
  181. package/dist/resources.d.ts.map +1 -0
  182. package/dist/resources.js +256 -0
  183. package/dist/resources.js.map +1 -0
  184. package/dist/schema.d.ts +7 -171
  185. package/dist/schema.d.ts.map +1 -1
  186. package/dist/schema.js +10 -135
  187. package/dist/schema.js.map +1 -1
  188. package/dist/server-types.d.ts +94 -7
  189. package/dist/server-types.d.ts.map +1 -1
  190. package/dist/server-types.js +2 -0
  191. package/dist/server-types.js.map +1 -1
  192. package/dist/server.d.ts +2 -2
  193. package/dist/server.d.ts.map +1 -1
  194. package/dist/server.js +45 -31
  195. package/dist/server.js.map +1 -1
  196. package/dist/skills.d.ts +95 -0
  197. package/dist/skills.d.ts.map +1 -0
  198. package/dist/skills.js +340 -0
  199. package/dist/skills.js.map +1 -0
  200. package/dist/strict-json.d.ts +17 -0
  201. package/dist/strict-json.d.ts.map +1 -0
  202. package/dist/strict-json.js +93 -0
  203. package/dist/strict-json.js.map +1 -0
  204. package/dist/tool-router.d.ts +13 -1
  205. package/dist/tool-router.d.ts.map +1 -1
  206. package/dist/tool-router.js +44 -10
  207. package/dist/tool-router.js.map +1 -1
  208. package/dist/tools.d.ts +10 -5
  209. package/dist/tools.d.ts.map +1 -1
  210. package/dist/tools.js +48 -22
  211. package/dist/tools.js.map +1 -1
  212. package/dist/validation.d.ts +6 -45
  213. package/dist/validation.d.ts.map +1 -1
  214. package/dist/validation.js +25 -58
  215. package/dist/validation.js.map +1 -1
  216. package/dist/verified-credentials.d.ts +34 -0
  217. package/dist/verified-credentials.d.ts.map +1 -0
  218. package/dist/verified-credentials.js +51 -0
  219. package/dist/verified-credentials.js.map +1 -0
  220. package/package.json +18 -6
@@ -5,7 +5,10 @@
5
5
  */
6
6
  import type { CommandExample } from '@lushly-dev/afd-core';
7
7
  import { z } from 'zod';
8
+ import type { ContextField } from '../context-fields.js';
9
+ import { type DescribedContextField } from '../context-fields-describe.js';
8
10
  import { type ZodCommandDefinition } from '../schema.js';
11
+ import type { ToolStrategy } from '../server-types.js';
9
12
  import { type GetDescribedCommands } from './described-command.js';
10
13
  declare const inputSchema: z.ZodObject<{
11
14
  filter: z.ZodOptional<z.ZodString>;
@@ -16,6 +19,7 @@ declare const inputSchema: z.ZodObject<{
16
19
  }, z.core.$strip>;
17
20
  interface CommandInfo {
18
21
  name: string;
22
+ title?: string;
19
23
  description: string;
20
24
  category?: string;
21
25
  tags?: string[];
@@ -24,23 +28,41 @@ interface CommandInfo {
24
28
  undoable?: boolean;
25
29
  requires?: string[];
26
30
  examples?: CommandExample[];
31
+ /** `true` for a first-class command of a hybrid server; omitted otherwise. */
32
+ firstClass?: true;
27
33
  }
28
34
  interface HelpOutput {
29
35
  /** The AFD contract version this server implements (`AFD_CONTRACT_VERSION`). */
30
36
  contractVersion: string;
37
+ /** How the server lists its tools; omitted when `afd-help` is not served by an MCP server. */
38
+ toolStrategy?: ToolStrategy;
39
+ /** The first-class command names in list order; hybrid servers only. */
40
+ firstClassTools?: string[];
41
+ /** The declared context fields and their `_meta` keys (`spec/context-fields.md`); omitted when none. */
42
+ contextFields?: DescribedContextField[];
31
43
  commands: CommandInfo[];
32
44
  total: number;
33
45
  filtered: boolean;
34
46
  groupedByCategory: Record<string, CommandInfo[]>;
35
47
  }
48
+ /** How the server lists its tools, which `afd-help` reports (`spec/tool-strategies.md`, H8). */
49
+ export interface ToolSurface {
50
+ toolStrategy: ToolStrategy;
51
+ /** The hybrid strategy's first-class command names, in list order. */
52
+ firstClassTools?: readonly string[];
53
+ /** The declared context fields, which `afd-help` lists so agents know what to send. */
54
+ contextFields?: readonly ContextField[];
55
+ }
36
56
  /**
37
57
  * Create the afd-help bootstrap command.
38
58
  *
39
59
  * Lists only MCP-exposed commands. `requires` is always included when set.
40
- * The output also carries the AFD contract version the server implements.
60
+ * The output also carries the AFD contract version the server implements, and, given
61
+ * `toolSurface`, the tool strategy (with the first-class set on a hybrid server).
41
62
  *
42
63
  * @param getCommands - Function to get all registered commands
64
+ * @param toolSurface - How the MCP server lists its tools; omit when not served by one
43
65
  */
44
- export declare function createAfdHelpCommand(getCommands: GetDescribedCommands): ZodCommandDefinition<typeof inputSchema, HelpOutput>;
66
+ export declare function createAfdHelpCommand(getCommands: GetDescribedCommands, toolSurface?: ToolSurface): ZodCommandDefinition<typeof inputSchema, HelpOutput>;
45
67
  export {};
46
68
  //# sourceMappingURL=afd-help.d.ts.map
@@ -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,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAExF,QAAA,MAAM,WAAW;;;;;;iBAGf,CAAC;AAEH,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,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAA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B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,UAAU,UAAU;IACnB,gFAAgF;IAChF,eAAe,EAAE,MAAM,CAAC;IACxB,8FAA8F;IAC9F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,wGAAwG;IACxG,aAAa,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACxC,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,gGAAgG;AAChG,MAAM,WAAW,WAAW;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,sEAAsE;IACtE,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,uFAAuF;IACvF,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,oBAAoB,EACjC,WAAW,CAAC,EAAE,WAAW,GACvB,oBAAoB,CAAC,OAAO,WAAW,EAAE,UAAU,CAAC,CA6FtD"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { AFD_CONTRACT_VERSION, success } from '@lushly-dev/afd-core';
7
7
  import { z } from 'zod';
8
+ import { describeContextFields } from '../context-fields-describe.js';
8
9
  import { defineCommand } from '../schema.js';
9
10
  import { describableCommands } from './described-command.js';
10
11
  const inputSchema = z.object({
@@ -15,11 +16,13 @@ const inputSchema = z.object({
15
16
  * Create the afd-help bootstrap command.
16
17
  *
17
18
  * Lists only MCP-exposed commands. `requires` is always included when set.
18
- * The output also carries the AFD contract version the server implements.
19
+ * The output also carries the AFD contract version the server implements, and, given
20
+ * `toolSurface`, the tool strategy (with the first-class set on a hybrid server).
19
21
  *
20
22
  * @param getCommands - Function to get all registered commands
23
+ * @param toolSurface - How the MCP server lists its tools; omit when not served by one
21
24
  */
22
- export function createAfdHelpCommand(getCommands) {
25
+ export function createAfdHelpCommand(getCommands, toolSurface) {
23
26
  return defineCommand({
24
27
  name: 'afd-help',
25
28
  description: 'List all available commands with tags and grouping',
@@ -40,6 +43,7 @@ export function createAfdHelpCommand(getCommands) {
40
43
  cmd.category?.toLowerCase().includes(filterTag) ||
41
44
  cmd.name.toLowerCase().includes(filterTag));
42
45
  }
46
+ const firstClass = new Set(toolSurface?.toolStrategy === 'hybrid' ? (toolSurface.firstClassTools ?? []) : []);
43
47
  // Map to output format
44
48
  const commandInfos = commands.map((cmd) => {
45
49
  const info = {
@@ -49,7 +53,11 @@ export function createAfdHelpCommand(getCommands) {
49
53
  if (cmd.requires?.length) {
50
54
  info.requires = cmd.requires;
51
55
  }
56
+ if (firstClass.has(cmd.name)) {
57
+ info.firstClass = true;
58
+ }
52
59
  if (input.format === 'full') {
60
+ info.title = cmd.title;
53
61
  info.category = cmd.category;
54
62
  info.tags = cmd.tags;
55
63
  info.mutation = cmd.mutation;
@@ -70,6 +78,13 @@ export function createAfdHelpCommand(getCommands) {
70
78
  }
71
79
  const output = {
72
80
  contractVersion: AFD_CONTRACT_VERSION,
81
+ ...(toolSurface && { toolStrategy: toolSurface.toolStrategy }),
82
+ ...(toolSurface?.toolStrategy === 'hybrid' && {
83
+ firstClassTools: [...(toolSurface.firstClassTools ?? [])],
84
+ }),
85
+ ...(toolSurface?.contextFields?.length && {
86
+ contextFields: describeContextFields(toolSurface.contextFields),
87
+ }),
73
88
  commands: commandInfos,
74
89
  total: commandInfos.length,
75
90
  filtered,
@@ -1 +1 @@
1
- {"version":3,"file":"afd-help.js","sourceRoot":"","sources":["../../src/bootstrap/afd-help.ts"],"names":[],"mappings":"AAAA;;;;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MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;gBAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,eAAe,CAAC;gBACjD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAClC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;gBAClC,CAAC;gBACD,iBAAiB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;YAED,MAAM,MAAM,GAAe;gBAC1B,eAAe,EAAE,oBAAoB;gBACrC,GAAG,CAAC,WAAW,IAAI,EAAE,YAAY,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC9D,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,QAAQ,IAAI;oBAC7C,eAAe,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;iBACzD,CAAC;gBACF,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,MAAM,IAAI;oBACzC,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC,aAAa,CAAC;iBAC/D,CAAC;gBACF,QAAQ,EAAE,YAAY;gBACtB,KAAK,EAAE,YAAY,CAAC,MAAM;gBAC1B,QAAQ;gBACR,iBAAiB;aACjB,CAAC;YAEF,OAAO,OAAO,CAAC,MAAM,EAAE;gBACtB,SAAS,EAAE,QAAQ;oBAClB,CAAC,CAAC,SAAS,YAAY,CAAC,MAAM,uBAAuB,KAAK,CAAC,MAAM,GAAG;oBACpE,CAAC,CAAC,eAAe,YAAY,CAAC,MAAM,qBAAqB;gBAC1D,UAAU,EAAE,GAAG;aACf,CAAC,CAAC;QACJ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -9,6 +9,7 @@ import type { ApprovalPolicy, CommandContext, CommandExample, CommandParameter,
9
9
  */
10
10
  export interface DescribedCommand {
11
11
  name: string;
12
+ title?: string;
12
13
  description: string;
13
14
  category?: string;
14
15
  tags?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"described-command.d.ts","sourceRoot":"","sources":["../../src/bootstrap/described-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,MAAM,sBAAsB,CAAC;AAG9B;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC,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,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,KAAK,SAAS,gBAAgB,EAAE,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE,cAAc,GACtB,gBAAgB,EAAE,CAEpB"}
1
+ {"version":3,"file":"described-command.d.ts","sourceRoot":"","sources":["../../src/bootstrap/described-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,U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xE,CAAC"}
1
+ {"version":3,"file":"described-command.js","sourceRoot":"","sources":["../../src/bootstrap/described-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AA+BpD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAClC,WAAiC,EACjC,OAAwB;IAExB,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC"}
@@ -3,14 +3,25 @@
3
3
  *
4
4
  * Provides a function to get all bootstrap commands for an AFD server.
5
5
  */
6
+ import type { ExposeOptions } from '@lushly-dev/afd-core';
6
7
  import { type ZodCommandDefinition } from '../schema.js';
7
8
  import type { ContextConfig } from '../server-types.js';
8
9
  import { type ContextState } from './afd-context.js';
10
+ import { type ToolSurface } from './afd-help.js';
9
11
  import type { DescribedCommand, GetDescribedCommands } from './described-command.js';
10
12
  /** Names of the discovery bootstrap tools registered by `createMcpServer({ bootstrap: true })`. */
11
13
  export declare const BOOTSTRAP_COMMAND_NAMES: readonly string[];
12
14
  /** Names of the context tools registered when `createMcpServer({ contexts })` is set. */
13
15
  export declare const CONTEXT_COMMAND_NAMES: readonly string[];
16
+ /**
17
+ * The context tools `createMcpServer({ contexts })` registers: `afd-context-list`,
18
+ * `afd-context-enter` and `afd-context-exit`, MCP-exposed. `createDirectToolSurface` registers
19
+ * the same commands, also exposed to the registry's interface, so both list equal tools.
20
+ *
21
+ * @param contextState - The state a call uses when none is bound to its context
22
+ * @param expose - The commands' exposure. Default: `{ mcp: true }`
23
+ */
24
+ export declare function createContextCommands(contexts: readonly ContextConfig[], contextState: ContextState, expose?: ExposeOptions): ZodCommandDefinition[];
14
25
  /**
15
26
  * Get all bootstrap commands for an AFD server: afd-help, afd-docs and afd-schema,
16
27
  * plus the afd-context-* commands when `contexts` and `contextState` are given.
@@ -28,5 +39,7 @@ export declare function getBootstrapCommands(getCommands: GetDescribedCommands,
28
39
  getJsonSchema?: (cmd: DescribedCommand) => Record<string, unknown>;
29
40
  contexts?: ContextConfig[];
30
41
  contextState?: ContextState;
42
+ /** How the MCP server lists its tools, reported by `afd-help`. */
43
+ toolSurface?: ToolSurface;
31
44
  }): ZodCommandDefinition[];
32
45
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,KAAK,YAAY,EAIjB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAErF,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAAgC,CAAC;AAEtF,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA8B,CAAC;AAElF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE;IACT,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B,GACC,oBAAoB,EAAE,CA+BxB"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,KAAK,YAAY,EAIjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAErF,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAAgC,CAAC;AAEtF,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA8B,CAAC;AAElF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,YAAY,EAAE,YAAY,EAC1B,MAAM,GAAE,aAA6B,GACnC,oBAAoB,EAAE,CAoBxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE;IACT,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kEAAkE;IAClE,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B,GACC,oBAAoB,EAAE,CA+BxB"}
@@ -14,6 +14,35 @@ import { createAfdSchemaCommand } from './afd-schema.js';
14
14
  export const BOOTSTRAP_COMMAND_NAMES = AFD_BOOTSTRAP_COMMAND_NAMES;
15
15
  /** Names of the context tools registered when `createMcpServer({ contexts })` is set. */
16
16
  export const CONTEXT_COMMAND_NAMES = AFD_CONTEXT_COMMAND_NAMES;
17
+ /**
18
+ * The context tools `createMcpServer({ contexts })` registers: `afd-context-list`,
19
+ * `afd-context-enter` and `afd-context-exit`, MCP-exposed. `createDirectToolSurface` registers
20
+ * the same commands, also exposed to the registry's interface, so both list equal tools.
21
+ *
22
+ * @param contextState - The state a call uses when none is bound to its context
23
+ * @param expose - The commands' exposure. Default: `{ mcp: true }`
24
+ */
25
+ export function createContextCommands(contexts, contextState, expose = { mcp: true }) {
26
+ // A copy per call: afd-context-list sorts what it gets.
27
+ const getContexts = () => [...contexts];
28
+ return [
29
+ defineCommand({
30
+ ...createAfdContextListCommand(getContexts, contextState),
31
+ input: z.object({}),
32
+ expose,
33
+ }),
34
+ defineCommand({
35
+ ...createAfdContextEnterCommand(getContexts, contextState),
36
+ input: z.object({ context: z.string().min(1) }),
37
+ expose,
38
+ }),
39
+ defineCommand({
40
+ ...createAfdContextExitCommand(contextState),
41
+ input: z.object({}),
42
+ expose,
43
+ }),
44
+ ];
45
+ }
17
46
  /**
18
47
  * Get all bootstrap commands for an AFD server: afd-help, afd-docs and afd-schema,
19
48
  * plus the afd-context-* commands when `contexts` and `contextState` are given.
@@ -29,7 +58,7 @@ export const CONTEXT_COMMAND_NAMES = AFD_CONTEXT_COMMAND_NAMES;
29
58
  */
30
59
  export function getBootstrapCommands(getCommands, options) {
31
60
  const cmds = [
32
- createAfdHelpCommand(getCommands),
61
+ createAfdHelpCommand(getCommands, options?.toolSurface),
33
62
  createAfdDocsCommand(getCommands),
34
63
  createAfdSchemaCommand(getCommands, options?.getJsonSchema),
35
64
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/bootstrap/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAA6B,MAAM,cAAc,CAAC;AAExE,OAAO,EAEN,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC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AC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;YACjF,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;SACrB,CAAC,EACF,aAAa,CAAC;YACb,GAAG,2BAA2B,CAAC,YAAY,CAAC;YAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;SACrB,CAAC,CACF,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview The `allow` call option of `createDirectRegistry`, bound to the command context of
3
+ * one call.
4
+ *
5
+ * `DirectClient` passes its `allow` predicate to the registry as a call option, beside
6
+ * `activeContext`. The registry binds it to the call's context under a private symbol, as it binds
7
+ * the context state (`context-scope.ts`), so the copies made for `afd-call`, batch items, pipeline
8
+ * steps and grouped tools all carry it, and the engine and the tool router check every command the
9
+ * call runs.
10
+ *
11
+ * The context holds an opaque frozen token, never the predicate: the predicate sits in a
12
+ * module-private `WeakMap`, so a handler that lists its context's symbols finds an empty object it
13
+ * cannot call, read or swap for another predicate (an unknown token denies everything). Tool
14
+ * arguments and `createContext` values are plain JSON and string keys, so they cannot carry one. A
15
+ * token handed back to `execute` (a handler passing its own context on) only narrows the next
16
+ * call, never widens it. Nothing binds a token on the MCP lanes, so they are unchanged.
17
+ */
18
+ import type { CommandContext } from '@lushly-dev/afd-core';
19
+ import { type DirectAllow } from '@lushly-dev/afd-core/internal/direct-allow';
20
+ /**
21
+ * Return `context` bound to `allow`, combined with any predicate it already carries: both must
22
+ * permit a name. Without either, `context` is returned unchanged.
23
+ */
24
+ export declare function bindCommandAllow(context: CommandContext, allow: DirectAllow | undefined): CommandContext;
25
+ /** Whether the predicate bound to `context`, if any, permits `name`. */
26
+ export declare function isCommandAllowed(context: CommandContext | undefined, name: string): boolean;
27
+ /** `items` without those whose name the predicate bound to `context` rejects. */
28
+ export declare function filterAllowed<T extends {
29
+ name: string;
30
+ }>(items: T[], context: CommandContext | undefined): T[];
31
+ //# sourceMappingURL=command-allow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-allow.d.ts","sourceRoot":"","sources":["../src/command-allow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,4CAA4C,CAAC;AAgB5F;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,WAAW,GAAG,SAAS,GAC5B,cAAc,CAWhB;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG3F;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACvD,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,EAAE,cAAc,GAAG,SAAS,GACjC,CAAC,EAAE,CAGL"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @fileoverview The `allow` call option of `createDirectRegistry`, bound to the command context of
3
+ * one call.
4
+ *
5
+ * `DirectClient` passes its `allow` predicate to the registry as a call option, beside
6
+ * `activeContext`. The registry binds it to the call's context under a private symbol, as it binds
7
+ * the context state (`context-scope.ts`), so the copies made for `afd-call`, batch items, pipeline
8
+ * steps and grouped tools all carry it, and the engine and the tool router check every command the
9
+ * call runs.
10
+ *
11
+ * The context holds an opaque frozen token, never the predicate: the predicate sits in a
12
+ * module-private `WeakMap`, so a handler that lists its context's symbols finds an empty object it
13
+ * cannot call, read or swap for another predicate (an unknown token denies everything). Tool
14
+ * arguments and `createContext` values are plain JSON and string keys, so they cannot carry one. A
15
+ * token handed back to `execute` (a handler passing its own context on) only narrows the next
16
+ * call, never widens it. Nothing binds a token on the MCP lanes, so they are unchanged.
17
+ */
18
+ import { directAllows } from '@lushly-dev/afd-core/internal/direct-allow';
19
+ const ALLOW = Symbol('afd.commandAllow');
20
+ /** Tokens the registry minted, and the predicate each stands for. */
21
+ const predicates = new WeakMap();
22
+ /** The predicate bound to `context`: none when nothing is bound, deny-all for a forged token. */
23
+ function boundAllow(context) {
24
+ if (!context || !(ALLOW in context))
25
+ return undefined;
26
+ const token = context[ALLOW];
27
+ return (token !== null && typeof token === 'object' && predicates.get(token)) || (() => false);
28
+ }
29
+ /**
30
+ * Return `context` bound to `allow`, combined with any predicate it already carries: both must
31
+ * permit a name. Without either, `context` is returned unchanged.
32
+ */
33
+ export function bindCommandAllow(context, allow) {
34
+ const carried = boundAllow(context);
35
+ if (!allow && !carried)
36
+ return context;
37
+ const combined = allow && carried
38
+ ? (name) => directAllows(carried, name) && directAllows(allow, name)
39
+ : (allow ?? carried);
40
+ const token = Object.freeze({});
41
+ predicates.set(token, combined);
42
+ const bound = { ...context, [ALLOW]: token };
43
+ return bound;
44
+ }
45
+ /** Whether the predicate bound to `context`, if any, permits `name`. */
46
+ export function isCommandAllowed(context, name) {
47
+ const allow = boundAllow(context);
48
+ return !allow || directAllows(allow, name);
49
+ }
50
+ /** `items` without those whose name the predicate bound to `context` rejects. */
51
+ export function filterAllowed(items, context) {
52
+ const allow = boundAllow(context);
53
+ return allow ? items.filter((item) => directAllows(allow, item.name)) : items;
54
+ }
55
+ //# sourceMappingURL=command-allow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-allow.js","sourceRoot":"","sources":["../src/command-allow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAoB,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE5F,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEzC,qEAAqE;AACrE,MAAM,UAAU,GAAG,IAAI,OAAO,EAAu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;AAC5C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAC5B,KAAU,EACV,OAAmC;IAEnC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/E,CAAC"}
@@ -2,6 +2,9 @@
2
2
  * @fileoverview Server-creation checks for command names: duplicates and names
3
3
  * that the tool router or a built-in command would shadow.
4
4
  */
5
+ import { type ExposeOptions } from '@lushly-dev/afd-core';
6
+ import type { ZodCommandDefinition } from './schema.js';
7
+ import { type ToolStrategy } from './server-types.js';
5
8
  /**
6
9
  * Throw if two commands share a name, or if a command uses a name the server
7
10
  * handles itself:
@@ -16,4 +19,18 @@ export declare function assertValidCommandNames(commands: ReadonlyArray<{
16
19
  bootstrap: boolean;
17
20
  contexts: boolean;
18
21
  }): void;
22
+ /**
23
+ * Throw unless the first-class set matches the tool strategy and, for `hybrid`, is a valid set
24
+ * (`spec/tool-strategies.md`, H1, H2 and H5). Every message names the offending entry or option.
25
+ *
26
+ * @param commands - Every registered command, built-ins included
27
+ * @param interface - The interface whose exposure a first-class command needs: `'mcp'` (the
28
+ * default) for the MCP server, the registry's own for `createDirectToolSurface`
29
+ */
30
+ export declare function assertValidFirstClassTools(options: {
31
+ toolStrategy: ToolStrategy;
32
+ firstClassTools: readonly string[] | undefined;
33
+ commands: ReadonlyArray<Pick<ZodCommandDefinition, 'name' | 'expose'>>;
34
+ interface?: keyof ExposeOptions;
35
+ }): void;
19
36
  //# sourceMappingURL=command-names.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-names.d.ts","sourceRoot":"","sources":["../src/command-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACzC,QAAQ,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACjD,IAAI,CAyBN"}
1
+ {"version":3,"file":"command-names.d.ts","sourceRoot":"","sources":["../src/command-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAe,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7E;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACzC,QAAQ,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACjD,IAAI,CAyBN;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IACnD,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/C,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC;IACvE,SAAS,CAAC,EAAE,MAAM,aAAa,CAAC;CAChC,GAAG,IAAI,CA4DP"}
@@ -2,8 +2,10 @@
2
2
  * @fileoverview Server-creation checks for command names: duplicates and names
3
3
  * that the tool router or a built-in command would shadow.
4
4
  */
5
+ import { isExposedTo } from '@lushly-dev/afd-core';
5
6
  import { BOOTSTRAP_COMMAND_NAMES, CONTEXT_COMMAND_NAMES } from './bootstrap/registry.js';
6
7
  import { META_TOOL_NAMES } from './meta-tools.js';
8
+ import { MAX_FIRST_CLASS_TOOLS } from './server-types.js';
7
9
  /**
8
10
  * Throw if two commands share a name, or if a command uses a name the server
9
11
  * handles itself:
@@ -30,4 +32,57 @@ export function assertValidCommandNames(commands, builtins) {
30
32
  seen.add(name);
31
33
  }
32
34
  }
35
+ /**
36
+ * Throw unless the first-class set matches the tool strategy and, for `hybrid`, is a valid set
37
+ * (`spec/tool-strategies.md`, H1, H2 and H5). Every message names the offending entry or option.
38
+ *
39
+ * @param commands - Every registered command, built-ins included
40
+ * @param interface - The interface whose exposure a first-class command needs: `'mcp'` (the
41
+ * default) for the MCP server, the registry's own for `createDirectToolSurface`
42
+ */
43
+ export function assertValidFirstClassTools(options) {
44
+ const { toolStrategy, firstClassTools, commands } = options;
45
+ const iface = options.interface ?? 'mcp';
46
+ if (toolStrategy !== 'hybrid') {
47
+ if (firstClassTools !== undefined) {
48
+ throw new Error(`[AFD] firstClassTools is only valid with toolStrategy: 'hybrid' (got '${toolStrategy}'). Set toolStrategy: 'hybrid', or remove firstClassTools.`);
49
+ }
50
+ return;
51
+ }
52
+ if (firstClassTools === undefined) {
53
+ throw new Error("[AFD] toolStrategy: 'hybrid' needs firstClassTools: the names of the commands to list as their own tools.");
54
+ }
55
+ if (!Array.isArray(firstClassTools) || firstClassTools.length === 0) {
56
+ throw new Error("[AFD] firstClassTools is empty. A hybrid server with no first-class tools is the lazy strategy: set toolStrategy: 'lazy', or name the commands to list.");
57
+ }
58
+ const byName = new Map(commands.map((command) => [command.name, command]));
59
+ const seen = new Set();
60
+ firstClassTools.forEach((entry, index) => {
61
+ const shown = typeof entry === 'string' ? `'${entry}'` : String(entry);
62
+ if (index >= MAX_FIRST_CLASS_TOOLS) {
63
+ throw new Error(`[AFD] firstClassTools entry ${shown} is beyond the cap of ${MAX_FIRST_CLASS_TOOLS} first-class tools. Remove it, or use the individual or grouped strategy to list more tools.`);
64
+ }
65
+ if (typeof entry !== 'string' || !entry) {
66
+ throw new Error(`[AFD] firstClassTools entry ${shown} is not a command name.`);
67
+ }
68
+ if (META_TOOL_NAMES.includes(entry) || CONTEXT_COMMAND_NAMES.includes(entry)) {
69
+ throw new Error(`[AFD] firstClassTools entry ${shown} is already listed by the hybrid strategy (meta-tools and context tools always are). Remove it.`);
70
+ }
71
+ if (seen.has(entry)) {
72
+ throw new Error(`[AFD] firstClassTools entry ${shown} appears more than once. Each tool is listed once.`);
73
+ }
74
+ seen.add(entry);
75
+ const command = byName.get(entry);
76
+ if (!command) {
77
+ const hint = BOOTSTRAP_COMMAND_NAMES.includes(entry)
78
+ ? ' Set bootstrap: true to register it.'
79
+ : '';
80
+ throw new Error(`[AFD] firstClassTools entry ${shown} is not a registered command.${hint} Register it in commands, or remove it.`);
81
+ }
82
+ if (!isExposedTo(command, iface)) {
83
+ const where = iface === 'mcp' ? 'over MCP' : `to ${iface}`;
84
+ throw new Error(`[AFD] firstClassTools entry ${shown} is not exposed ${where} (expose.${iface} is not true), so it cannot be listed. Expose it, or remove it.`);
85
+ }
86
+ });
87
+ }
33
88
  //# sourceMappingURL=command-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-names.js","sourceRoot":"","sources":["../src/command-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACtC,QAAyC,EACzC,QAAmD;IAEnD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,QAAQ,EAAE,CAAC;QACjC,IAAI,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACd,uBAAuB,IAAI,2CAA2C,IAAI,oEAAoE,CAC9I,CAAC;QACH,CAAC;QACD,IAAI,QAAQ,CAAC,SAAS,IAAI,uBAAuB,C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ACjH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CACd,+BAA+B,KAAK,mBAAmB,KAAK,YAAY,KAAK,iEAAiE,CAC9I,CAAC;QACH,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -39,9 +39,16 @@ export declare function filterByContext<T extends Contextual>(commands: T[], act
39
39
  *
40
40
  * @param commandName - The unknown name (untrusted; never echoed)
41
41
  * @param commandNames - Names the caller may call
42
+ * @param discover - Whether the caller can call `afd-discover`. Without it the suggestion ends
43
+ * as Rust's and C++'s do (`spec/error-codes.md`, "Suggestions name only tools the host provides")
42
44
  */
43
- export declare function notFoundSuggestion(commandName: string, commandNames: string[]): string;
44
- /** The `COMMAND_NOT_IN_CONTEXT` error for a command outside the active context. */
45
- export declare function notInContextError(commandName: string, activeContext: string): CommandError;
45
+ export declare function notFoundSuggestion(commandName: string, commandNames: string[], discover?: boolean): string;
46
+ /**
47
+ * The `COMMAND_NOT_IN_CONTEXT` error for a command outside the active context.
48
+ *
49
+ * @param belongsTo - The command's contexts, when the caller cannot call the `afd-context-*`
50
+ * tools: the suggestion then names them, as Rust's and C++'s do
51
+ */
52
+ export declare function notInContextError(commandName: string, activeContext: string, belongsTo?: readonly string[]): CommandError;
46
53
  export {};
47
54
  //# sourceMappingURL=command-routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-routing.d.ts","sourceRoot":"","sources":["../src/command-routing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,0FAA0F;AAC1F,MAA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AM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAC;AAE9E,uDAAuD;AACvD,KAAK,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,UAAU,CAAC,GACtD,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,CAEzF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG,MAAM,CAGjF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,OAAO,CAIT;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,CAAC,SAAS,UAAU,EACnD,QAAQ,EAAE,CAAC,EAAE,EACb,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,CAAC,EAAE,CAGL;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EAAE,EACtB,QAAQ,UAAO,GACb,MAAM,CAUR;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAC3B,YAAY,CAQd"}
@@ -53,23 +53,34 @@ const MAX_NOT_FOUND_MATCHES = 3;
53
53
  *
54
54
  * @param commandName - The unknown name (untrusted; never echoed)
55
55
  * @param commandNames - Names the caller may call
56
+ * @param discover - Whether the caller can call `afd-discover`. Without it the suggestion ends
57
+ * as Rust's and C++'s do (`spec/error-codes.md`, "Suggestions name only tools the host provides")
56
58
  */
57
- export function notFoundSuggestion(commandName, commandNames) {
58
- const discover = 'Use afd-discover to list all commands.';
59
+ export function notFoundSuggestion(commandName, commandNames, discover = true) {
60
+ const next = discover
61
+ ? 'Use afd-discover to list all commands.'
62
+ : 'Check the command name against the available commands.';
59
63
  const [best, ...others] = findSimilarTools(commandName, commandNames, MAX_NOT_FOUND_MATCHES);
60
64
  if (best === undefined)
61
- return discover;
65
+ return next;
62
66
  const alsoClose = others.length
63
67
  ? ` Other close matches: ${others.map((name) => `'${name}'`).join(', ')}.`
64
68
  : '';
65
- return `Did you mean '${best}'?${alsoClose} ${discover}`;
69
+ return `Did you mean '${best}'?${alsoClose} ${next}`;
66
70
  }
67
- /** The `COMMAND_NOT_IN_CONTEXT` error for a command outside the active context. */
68
- export function notInContextError(commandName, activeContext) {
71
+ /**
72
+ * The `COMMAND_NOT_IN_CONTEXT` error for a command outside the active context.
73
+ *
74
+ * @param belongsTo - The command's contexts, when the caller cannot call the `afd-context-*`
75
+ * tools: the suggestion then names them, as Rust's and C++'s do
76
+ */
77
+ export function notInContextError(commandName, activeContext, belongsTo) {
69
78
  return {
70
79
  code: 'COMMAND_NOT_IN_CONTEXT',
71
80
  message: `Command '${commandName}' is not available in context '${activeContext}'`,
72
- suggestion: 'Use afd-context-list to see available contexts, or afd-context-enter to switch.',
81
+ suggestion: belongsTo
82
+ ? `Switch to a context this command belongs to (${belongsTo.map((name) => `'${name}'`).join(', ')}), or call it with no active context.`
83
+ : 'Use afd-context-list to see available contexts, or afd-context-enter to switch.',
73
84
  };
74
85
  }
75
86
  //# sourceMappingURL=command-routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-routing.js","sourceRoot":"","sources":["../src/command-routing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AASxD;;;GAGG;AACH,MAAM,UAAU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,CAAC,CAAC;IAC7F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM;QAC9B,CAAC,CAAC,yBAAyB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC1E,CAAC,CAAC,EAAE,CAAC;IACN,OAAO,iBAAiB,IAAI,KAAK,SAAS,IAAI,IAAI,EAAE,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAChC,WAAmB,EACnB,aAAqB,EACrB,SAA6B;IAE7B,OAAO;QACN,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,YAAY,WAAW,kCAAkC,aAAa,GAAG;QAClF,UAAU,EAAE,SAAS;YACpB,CAAC,CAAC,gDAAgD,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,uCAAuC;YACxI,CAAC,CAAC,iFAAiF;KACpF,CAAC;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview The confirmation gate (`spec/command-metadata.md`, "Confirmations"): the check
3
+ * that decides whether a call to confirm-gated commands may run, its binding digest, and the
4
+ * check of the HTTP routes.
5
+ *
6
+ * Split from `confirmations.ts` because the binding digest uses `node:crypto`: only the MCP server
7
+ * (`server.ts`) and its HTTP handler import this module, so the tool router and the tool list stay
8
+ * free of Node.js built-ins for `createDirectToolSurface`. In-process calls are never gated.
9
+ */
10
+ import type { IncomingMessage } from 'node:http';
11
+ import type { CommandError } from '@lushly-dev/afd-core';
12
+ import { type ConfirmationGate, type ConfirmationMode, type ConfirmationStep } from './confirmations.js';
13
+ import type { ZodCommandDefinition } from './schema.js';
14
+ /**
15
+ * The binding of a confirmation: a digest of the gated commands and their input. The lane that
16
+ * mints the `requestState` binds the call's principal to the whole state (`mcp-modern.ts`), so
17
+ * this digest never needs to name the caller.
18
+ */
19
+ export declare function confirmationBinding(steps: readonly ConfirmationStep[]): string;
20
+ /**
21
+ * Create the gate for `commands` (the remotely callable ones). With mode `off` every call
22
+ * proceeds.
23
+ */
24
+ export declare function createConfirmationGate(mode: ConfirmationMode, commands: readonly ZodCommandDefinition[]): ConfirmationGate;
25
+ /** Header that acknowledges confirm-gated commands on the HTTP routes: their names, comma-separated. */
26
+ export declare const AFD_CONFIRM_HEADER = "afd-confirm";
27
+ /**
28
+ * The check of the HTTP routes (`/rpc`, `/batch`, `/stream`), which have no elicitation channel:
29
+ * the confirmation error for a request, or `undefined` when it may run.
30
+ */
31
+ export declare function createHttpConfirmationCheck(gate: ConfirmationGate | undefined): (req: IncomingMessage, steps: ConfirmationStep[]) => Promise<CommandError | undefined>;
32
+ //# sourceMappingURL=confirmation-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation-gate.d.ts","sourceRoot":"","sources":["../src/confirmation-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAI9E;AAkBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,SAAS,oBAAoB,EAAE,GACvC,gBAAgB,CAkElB;AAED,wGAAwG;AACxG,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAehD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,SAEvE,eAAe,SACb,gBAAgB,EAAE,KACvB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAWpC"}