@wootsup/yt-builder-mcp 0.2.0-alpha.2

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 (299) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -0
  3. package/bin/yt-builder-mcp.js +59 -0
  4. package/dist/auth.d.ts +39 -0
  5. package/dist/auth.d.ts.map +1 -0
  6. package/dist/auth.js +93 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/client.d.ts +84 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +151 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/clients/claude-code.d.ts +18 -0
  13. package/dist/clients/claude-code.d.ts.map +1 -0
  14. package/dist/clients/claude-code.js +53 -0
  15. package/dist/clients/claude-code.js.map +1 -0
  16. package/dist/clients/claude-desktop.d.ts +19 -0
  17. package/dist/clients/claude-desktop.d.ts.map +1 -0
  18. package/dist/clients/claude-desktop.js +56 -0
  19. package/dist/clients/claude-desktop.js.map +1 -0
  20. package/dist/clients/cline.d.ts +26 -0
  21. package/dist/clients/cline.d.ts.map +1 -0
  22. package/dist/clients/cline.js +80 -0
  23. package/dist/clients/cline.js.map +1 -0
  24. package/dist/clients/codex-cli.d.ts +42 -0
  25. package/dist/clients/codex-cli.d.ts.map +1 -0
  26. package/dist/clients/codex-cli.js +194 -0
  27. package/dist/clients/codex-cli.js.map +1 -0
  28. package/dist/clients/continue.d.ts +13 -0
  29. package/dist/clients/continue.d.ts.map +1 -0
  30. package/dist/clients/continue.js +52 -0
  31. package/dist/clients/continue.js.map +1 -0
  32. package/dist/clients/cursor.d.ts +12 -0
  33. package/dist/clients/cursor.d.ts.map +1 -0
  34. package/dist/clients/cursor.js +38 -0
  35. package/dist/clients/cursor.js.map +1 -0
  36. package/dist/clients/gemini-cli.d.ts +18 -0
  37. package/dist/clients/gemini-cli.d.ts.map +1 -0
  38. package/dist/clients/gemini-cli.js +44 -0
  39. package/dist/clients/gemini-cli.js.map +1 -0
  40. package/dist/clients/home.d.ts +14 -0
  41. package/dist/clients/home.d.ts.map +1 -0
  42. package/dist/clients/home.js +20 -0
  43. package/dist/clients/home.js.map +1 -0
  44. package/dist/clients/index.d.ts +52 -0
  45. package/dist/clients/index.d.ts.map +1 -0
  46. package/dist/clients/index.js +72 -0
  47. package/dist/clients/index.js.map +1 -0
  48. package/dist/clients/roo-code.d.ts +23 -0
  49. package/dist/clients/roo-code.d.ts.map +1 -0
  50. package/dist/clients/roo-code.js +69 -0
  51. package/dist/clients/roo-code.js.map +1 -0
  52. package/dist/clients/zed.d.ts +12 -0
  53. package/dist/clients/zed.d.ts.map +1 -0
  54. package/dist/clients/zed.js +41 -0
  55. package/dist/clients/zed.js.map +1 -0
  56. package/dist/errors/hints.d.ts +51 -0
  57. package/dist/errors/hints.d.ts.map +1 -0
  58. package/dist/errors/hints.js +95 -0
  59. package/dist/errors/hints.js.map +1 -0
  60. package/dist/errors/mask.d.ts +35 -0
  61. package/dist/errors/mask.d.ts.map +1 -0
  62. package/dist/errors/mask.js +49 -0
  63. package/dist/errors/mask.js.map +1 -0
  64. package/dist/errors/sanitize.d.ts +31 -0
  65. package/dist/errors/sanitize.d.ts.map +1 -0
  66. package/dist/errors/sanitize.js +90 -0
  67. package/dist/errors/sanitize.js.map +1 -0
  68. package/dist/errors.d.ts +42 -0
  69. package/dist/errors.d.ts.map +1 -0
  70. package/dist/errors.js +61 -0
  71. package/dist/errors.js.map +1 -0
  72. package/dist/gateway/advanced-tool/discovery.d.ts +19 -0
  73. package/dist/gateway/advanced-tool/discovery.d.ts.map +1 -0
  74. package/dist/gateway/advanced-tool/discovery.js +53 -0
  75. package/dist/gateway/advanced-tool/discovery.js.map +1 -0
  76. package/dist/gateway/advanced-tool/domains.d.ts +42 -0
  77. package/dist/gateway/advanced-tool/domains.d.ts.map +1 -0
  78. package/dist/gateway/advanced-tool/domains.js +88 -0
  79. package/dist/gateway/advanced-tool/domains.js.map +1 -0
  80. package/dist/gateway/advanced-tool/execute.d.ts +29 -0
  81. package/dist/gateway/advanced-tool/execute.d.ts.map +1 -0
  82. package/dist/gateway/advanced-tool/execute.js +54 -0
  83. package/dist/gateway/advanced-tool/execute.js.map +1 -0
  84. package/dist/gateway/advanced-tool/index.d.ts +36 -0
  85. package/dist/gateway/advanced-tool/index.d.ts.map +1 -0
  86. package/dist/gateway/advanced-tool/index.js +39 -0
  87. package/dist/gateway/advanced-tool/index.js.map +1 -0
  88. package/dist/gateway/advanced-tool/register.d.ts +18 -0
  89. package/dist/gateway/advanced-tool/register.d.ts.map +1 -0
  90. package/dist/gateway/advanced-tool/register.js +62 -0
  91. package/dist/gateway/advanced-tool/register.js.map +1 -0
  92. package/dist/gateway/advanced-tool.d.ts +13 -0
  93. package/dist/gateway/advanced-tool.d.ts.map +1 -0
  94. package/dist/gateway/advanced-tool.js +13 -0
  95. package/dist/gateway/advanced-tool.js.map +1 -0
  96. package/dist/gateway/capturing-server.d.ts +117 -0
  97. package/dist/gateway/capturing-server.d.ts.map +1 -0
  98. package/dist/gateway/capturing-server.js +103 -0
  99. package/dist/gateway/capturing-server.js.map +1 -0
  100. package/dist/gateway/essentials.d.ts +49 -0
  101. package/dist/gateway/essentials.d.ts.map +1 -0
  102. package/dist/gateway/essentials.js +62 -0
  103. package/dist/gateway/essentials.js.map +1 -0
  104. package/dist/gateway/test-support.d.ts +41 -0
  105. package/dist/gateway/test-support.d.ts.map +1 -0
  106. package/dist/gateway/test-support.js +60 -0
  107. package/dist/gateway/test-support.js.map +1 -0
  108. package/dist/index.d.ts +25 -0
  109. package/dist/index.d.ts.map +1 -0
  110. package/dist/index.js +77 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/install-skill.d.ts +35 -0
  113. package/dist/install-skill.d.ts.map +1 -0
  114. package/dist/install-skill.js +107 -0
  115. package/dist/install-skill.js.map +1 -0
  116. package/dist/platform/index.d.ts +49 -0
  117. package/dist/platform/index.d.ts.map +1 -0
  118. package/dist/platform/index.js +38 -0
  119. package/dist/platform/index.js.map +1 -0
  120. package/dist/server.d.ts +50 -0
  121. package/dist/server.d.ts.map +1 -0
  122. package/dist/server.js +117 -0
  123. package/dist/server.js.map +1 -0
  124. package/dist/setup-cli.d.ts +100 -0
  125. package/dist/setup-cli.d.ts.map +1 -0
  126. package/dist/setup-cli.js +355 -0
  127. package/dist/setup-cli.js.map +1 -0
  128. package/dist/setup-prompts.d.ts +41 -0
  129. package/dist/setup-prompts.d.ts.map +1 -0
  130. package/dist/setup-prompts.js +142 -0
  131. package/dist/setup-prompts.js.map +1 -0
  132. package/dist/setup-token.d.ts +38 -0
  133. package/dist/setup-token.d.ts.map +1 -0
  134. package/dist/setup-token.js +106 -0
  135. package/dist/setup-token.js.map +1 -0
  136. package/dist/setup-wizard-defaults.d.ts +43 -0
  137. package/dist/setup-wizard-defaults.d.ts.map +1 -0
  138. package/dist/setup-wizard-defaults.js +160 -0
  139. package/dist/setup-wizard-defaults.js.map +1 -0
  140. package/dist/setup-wizard-handshake.d.ts +25 -0
  141. package/dist/setup-wizard-handshake.d.ts.map +1 -0
  142. package/dist/setup-wizard-handshake.js +103 -0
  143. package/dist/setup-wizard-handshake.js.map +1 -0
  144. package/dist/setup-wizard-types.d.ts +148 -0
  145. package/dist/setup-wizard-types.d.ts.map +1 -0
  146. package/dist/setup-wizard-types.js +11 -0
  147. package/dist/setup-wizard-types.js.map +1 -0
  148. package/dist/setup-wizard.d.ts +33 -0
  149. package/dist/setup-wizard.d.ts.map +1 -0
  150. package/dist/setup-wizard.js +166 -0
  151. package/dist/setup-wizard.js.map +1 -0
  152. package/dist/setup.d.ts +17 -0
  153. package/dist/setup.d.ts.map +1 -0
  154. package/dist/setup.js +33 -0
  155. package/dist/setup.js.map +1 -0
  156. package/dist/tools/elements/builders.d.ts +24 -0
  157. package/dist/tools/elements/builders.d.ts.map +1 -0
  158. package/dist/tools/elements/builders.js +150 -0
  159. package/dist/tools/elements/builders.js.map +1 -0
  160. package/dist/tools/elements/handlers-write.d.ts +48 -0
  161. package/dist/tools/elements/handlers-write.d.ts.map +1 -0
  162. package/dist/tools/elements/handlers-write.js +141 -0
  163. package/dist/tools/elements/handlers-write.js.map +1 -0
  164. package/dist/tools/elements/handlers.d.ts +56 -0
  165. package/dist/tools/elements/handlers.d.ts.map +1 -0
  166. package/dist/tools/elements/handlers.js +113 -0
  167. package/dist/tools/elements/handlers.js.map +1 -0
  168. package/dist/tools/elements/index.d.ts +28 -0
  169. package/dist/tools/elements/index.d.ts.map +1 -0
  170. package/dist/tools/elements/index.js +27 -0
  171. package/dist/tools/elements/index.js.map +1 -0
  172. package/dist/tools/elements.d.ts +13 -0
  173. package/dist/tools/elements.d.ts.map +1 -0
  174. package/dist/tools/elements.js +13 -0
  175. package/dist/tools/elements.js.map +1 -0
  176. package/dist/tools/elicitation.d.ts +87 -0
  177. package/dist/tools/elicitation.d.ts.map +1 -0
  178. package/dist/tools/elicitation.js +100 -0
  179. package/dist/tools/elicitation.js.map +1 -0
  180. package/dist/tools/format/elements-format.d.ts +34 -0
  181. package/dist/tools/format/elements-format.d.ts.map +1 -0
  182. package/dist/tools/format/elements-format.js +112 -0
  183. package/dist/tools/format/elements-format.js.map +1 -0
  184. package/dist/tools/format/health-format.d.ts +73 -0
  185. package/dist/tools/format/health-format.d.ts.map +1 -0
  186. package/dist/tools/format/health-format.js +178 -0
  187. package/dist/tools/format/health-format.js.map +1 -0
  188. package/dist/tools/format/inspection-format.d.ts +45 -0
  189. package/dist/tools/format/inspection-format.d.ts.map +1 -0
  190. package/dist/tools/format/inspection-format.js +125 -0
  191. package/dist/tools/format/inspection-format.js.map +1 -0
  192. package/dist/tools/format/pages-format.d.ts +39 -0
  193. package/dist/tools/format/pages-format.d.ts.map +1 -0
  194. package/dist/tools/format/pages-format.js +110 -0
  195. package/dist/tools/format/pages-format.js.map +1 -0
  196. package/dist/tools/format/sources-format.d.ts +25 -0
  197. package/dist/tools/format/sources-format.d.ts.map +1 -0
  198. package/dist/tools/format/sources-format.js +113 -0
  199. package/dist/tools/format/sources-format.js.map +1 -0
  200. package/dist/tools/health.d.ts +22 -0
  201. package/dist/tools/health.d.ts.map +1 -0
  202. package/dist/tools/health.js +147 -0
  203. package/dist/tools/health.js.map +1 -0
  204. package/dist/tools/index.d.ts +23 -0
  205. package/dist/tools/index.d.ts.map +1 -0
  206. package/dist/tools/index.js +23 -0
  207. package/dist/tools/index.js.map +1 -0
  208. package/dist/tools/inspection.d.ts +14 -0
  209. package/dist/tools/inspection.d.ts.map +1 -0
  210. package/dist/tools/inspection.js +115 -0
  211. package/dist/tools/inspection.js.map +1 -0
  212. package/dist/tools/layout-flatten.d.ts +63 -0
  213. package/dist/tools/layout-flatten.d.ts.map +1 -0
  214. package/dist/tools/layout-flatten.js +95 -0
  215. package/dist/tools/layout-flatten.js.map +1 -0
  216. package/dist/tools/pages/builders.d.ts +14 -0
  217. package/dist/tools/pages/builders.d.ts.map +1 -0
  218. package/dist/tools/pages/builders.js +97 -0
  219. package/dist/tools/pages/builders.js.map +1 -0
  220. package/dist/tools/pages/handlers-read.d.ts +24 -0
  221. package/dist/tools/pages/handlers-read.d.ts.map +1 -0
  222. package/dist/tools/pages/handlers-read.js +141 -0
  223. package/dist/tools/pages/handlers-read.js.map +1 -0
  224. package/dist/tools/pages/handlers-write.d.ts +21 -0
  225. package/dist/tools/pages/handlers-write.d.ts.map +1 -0
  226. package/dist/tools/pages/handlers-write.js +52 -0
  227. package/dist/tools/pages/handlers-write.js.map +1 -0
  228. package/dist/tools/pages/index.d.ts +17 -0
  229. package/dist/tools/pages/index.d.ts.map +1 -0
  230. package/dist/tools/pages/index.js +17 -0
  231. package/dist/tools/pages/index.js.map +1 -0
  232. package/dist/tools/pages/schemas.d.ts +30 -0
  233. package/dist/tools/pages/schemas.d.ts.map +1 -0
  234. package/dist/tools/pages/schemas.js +30 -0
  235. package/dist/tools/pages/schemas.js.map +1 -0
  236. package/dist/tools/pages.d.ts +13 -0
  237. package/dist/tools/pages.d.ts.map +1 -0
  238. package/dist/tools/pages.js +13 -0
  239. package/dist/tools/pages.js.map +1 -0
  240. package/dist/tools/progress-phases.d.ts +46 -0
  241. package/dist/tools/progress-phases.d.ts.map +1 -0
  242. package/dist/tools/progress-phases.js +48 -0
  243. package/dist/tools/progress-phases.js.map +1 -0
  244. package/dist/tools/shared-schemas.d.ts +15 -0
  245. package/dist/tools/shared-schemas.d.ts.map +1 -0
  246. package/dist/tools/shared-schemas.js +30 -0
  247. package/dist/tools/shared-schemas.js.map +1 -0
  248. package/dist/tools/sources/builders.d.ts +13 -0
  249. package/dist/tools/sources/builders.d.ts.map +1 -0
  250. package/dist/tools/sources/builders.js +88 -0
  251. package/dist/tools/sources/builders.js.map +1 -0
  252. package/dist/tools/sources/handlers-bind.d.ts +26 -0
  253. package/dist/tools/sources/handlers-bind.d.ts.map +1 -0
  254. package/dist/tools/sources/handlers-bind.js +123 -0
  255. package/dist/tools/sources/handlers-bind.js.map +1 -0
  256. package/dist/tools/sources/handlers.d.ts +45 -0
  257. package/dist/tools/sources/handlers.d.ts.map +1 -0
  258. package/dist/tools/sources/handlers.js +84 -0
  259. package/dist/tools/sources/handlers.js.map +1 -0
  260. package/dist/tools/sources/index.d.ts +19 -0
  261. package/dist/tools/sources/index.d.ts.map +1 -0
  262. package/dist/tools/sources/index.js +18 -0
  263. package/dist/tools/sources/index.js.map +1 -0
  264. package/dist/tools/sources.d.ts +14 -0
  265. package/dist/tools/sources.d.ts.map +1 -0
  266. package/dist/tools/sources.js +14 -0
  267. package/dist/tools/sources.js.map +1 -0
  268. package/dist/tools/sparse-fields.d.ts +80 -0
  269. package/dist/tools/sparse-fields.d.ts.map +1 -0
  270. package/dist/tools/sparse-fields.js +144 -0
  271. package/dist/tools/sparse-fields.js.map +1 -0
  272. package/dist/tools/tool-builder/annotations.d.ts +22 -0
  273. package/dist/tools/tool-builder/annotations.d.ts.map +1 -0
  274. package/dist/tools/tool-builder/annotations.js +35 -0
  275. package/dist/tools/tool-builder/annotations.js.map +1 -0
  276. package/dist/tools/tool-builder/define.d.ts +31 -0
  277. package/dist/tools/tool-builder/define.d.ts.map +1 -0
  278. package/dist/tools/tool-builder/define.js +31 -0
  279. package/dist/tools/tool-builder/define.js.map +1 -0
  280. package/dist/tools/tool-builder/index.d.ts +28 -0
  281. package/dist/tools/tool-builder/index.d.ts.map +1 -0
  282. package/dist/tools/tool-builder/index.js +27 -0
  283. package/dist/tools/tool-builder/index.js.map +1 -0
  284. package/dist/tools/tool-builder/results.d.ts +59 -0
  285. package/dist/tools/tool-builder/results.d.ts.map +1 -0
  286. package/dist/tools/tool-builder/results.js +125 -0
  287. package/dist/tools/tool-builder/results.js.map +1 -0
  288. package/dist/tools/tool-builder/types.d.ts +82 -0
  289. package/dist/tools/tool-builder/types.d.ts.map +1 -0
  290. package/dist/tools/tool-builder/types.js +9 -0
  291. package/dist/tools/tool-builder/types.js.map +1 -0
  292. package/dist/tools/tool-builder.d.ts +16 -0
  293. package/dist/tools/tool-builder.d.ts.map +1 -0
  294. package/dist/tools/tool-builder.js +16 -0
  295. package/dist/tools/tool-builder.js.map +1 -0
  296. package/icon.png +0 -0
  297. package/manifest.json +63 -0
  298. package/package.json +81 -0
  299. package/skills/yootheme-builder/SKILL.md +582 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../src/tools/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Backwards-compatible re-export shim.
3
+ *
4
+ * Wave G.4.0b split the original 228-LoC `sources.ts` into
5
+ * `./sources/{index, handlers, builders}.ts` after Wave G.4.2/G.4.3
6
+ * added elicitation + ambiguity-resolution logic that pushed it well
7
+ * over the 200-LoC budget. This shim keeps the legacy import path
8
+ * (`from '../tools/sources.js'`) working for downstream callers and
9
+ * tests. New code should import from `./sources/index.js` directly.
10
+ *
11
+ * @license MIT
12
+ */
13
+ export { buildSourcesTools } from './sources/index.js';
14
+ //# sourceMappingURL=sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/tools/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Sparse-fields helper — projects per-item field whitelists onto tool
3
+ * responses and exposes per-tool default-sets that the AI client can rely
4
+ * on when calling read tools without a `fields` parameter.
5
+ *
6
+ * Design references:
7
+ *
8
+ * - §3.5 Sparse-Fields Adaption: 4 read tools opt-in to `fields[]`;
9
+ * the toolkit's `pickFields` is used directly; `projected_fields` is
10
+ * echoed in the result envelope so the LLM can confirm exactly which
11
+ * keys were kept.
12
+ * - §4.4.1 — when used together with `flat: true` projection runs
13
+ * AFTER the depth-first walk so paths are stable before narrowing.
14
+ *
15
+ * Reference implementation pattern: `connections.ts:721, 779-792, 810`
16
+ * in `@wootsup/apimapper-mcp`.
17
+ *
18
+ * The defaults are pure constants so they can be imported, exported, and
19
+ * asserted against in tests without any side-effects.
20
+ *
21
+ * @license MIT
22
+ */
23
+ import { z } from 'zod';
24
+ /**
25
+ * Optional whitelist of fields. Per Design §3.5 the cap is 40 to stop
26
+ * runaway prompts from blowing up the request size; nested paths
27
+ * (`props.title`) are supported by the toolkit's `pickFields`.
28
+ */
29
+ export declare const FIELDS: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ /**
31
+ * Flag enabling client-side flattening on `page_get_layout`. When true
32
+ * the response shape switches from `{layout, etag}` to
33
+ * `{elements: [...], etag}` and `fields[]` projection becomes meaningful.
34
+ */
35
+ export declare const FLAT: z.ZodDefault<z.ZodBoolean>;
36
+ /**
37
+ * Default fields echoed when the caller omits `fields`. Following the
38
+ * apimapper-mcp convention these are **echo-only** — projection itself
39
+ * is skipped (default-all preserved) but `projected_fields` still
40
+ * surfaces the implicit compact set so the AI can plan future requests.
41
+ */
42
+ export declare const DEFAULT_FIELDS_PAGES_LIST: readonly string[];
43
+ export declare const DEFAULT_FIELDS_ELEMENT_LIST: readonly string[];
44
+ export declare const DEFAULT_FIELDS_SCHEMA: readonly string[];
45
+ export declare const DEFAULT_FIELDS_SOURCES_LIST: readonly string[];
46
+ export declare const DEFAULT_FIELDS_TYPES_LIST: readonly string[];
47
+ /**
48
+ * element_get defaults to "all" because the AI often needs the full
49
+ * props payload for follow-up edits; sparse projection here is opt-in
50
+ * with nested-path support.
51
+ */
52
+ export declare const DEFAULT_FIELDS_ELEMENT_GET: readonly string[] | undefined;
53
+ /**
54
+ * Project an array of items to the requested fields. Returns items
55
+ * unchanged when `fields` is undefined (default-all). Skips non-object
56
+ * entries without crashing (they pass through as-is).
57
+ *
58
+ * @param items - The items to project.
59
+ * @param fields - The whitelist; `undefined` skips projection.
60
+ * @param _defaults - Per-tool default set, accepted for interface symmetry
61
+ * with `projectedFieldsEcho` (unused for actual projection — default-all
62
+ * semantics matches the apimapper-mcp reference, see `connections.ts:789`).
63
+ */
64
+ export declare function projectFields<T extends Record<string, unknown>>(items: readonly T[], fields: readonly string[] | undefined, _defaults: readonly string[]): T[];
65
+ /**
66
+ * Project a single object via the same `pickFields` rules. Returns the
67
+ * object unchanged when `fields` is undefined.
68
+ */
69
+ export declare function projectFieldsSingle<T extends Record<string, unknown>>(obj: T, fields: readonly string[] | undefined, _defaults: readonly string[] | undefined): T;
70
+ /**
71
+ * Compute the `projected_fields` echo. Returns the caller-requested
72
+ * fields when provided; otherwise returns the per-tool default set so
73
+ * the AI client knows exactly which compact view it implicitly opted into.
74
+ *
75
+ * @returns `undefined` only when neither `requested` nor `defaults` was set
76
+ * (e.g. `element_get` with no opt-in) — callers should omit
77
+ * `projected_fields` from the structuredContent in that case.
78
+ */
79
+ export declare function projectedFieldsEcho(requested: readonly string[] | undefined, defaults: readonly string[] | undefined): readonly string[] | undefined;
80
+ //# sourceMappingURL=sparse-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparse-fields.d.ts","sourceRoot":"","sources":["../../src/tools/sparse-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,MAAM,wCASd,CAAC;AAEN;;;;GAIG;AACH,eAAO,MAAM,IAAI,4BAMZ,CAAC;AAIN;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAMtD,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EAIxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAIlD,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EAKxD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAKtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAE,GAAG,SAAqB,CAAC;AAInF;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACrC,SAAS,EAAE,SAAS,MAAM,EAAE,GAC7B,CAAC,EAAE,CAWL;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACrC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,CAAC,CAQH;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAC/B,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACxC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACxC,SAAS,MAAM,EAAE,GAAG,SAAS,CAI/B"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Sparse-fields helper — projects per-item field whitelists onto tool
3
+ * responses and exposes per-tool default-sets that the AI client can rely
4
+ * on when calling read tools without a `fields` parameter.
5
+ *
6
+ * Design references:
7
+ *
8
+ * - §3.5 Sparse-Fields Adaption: 4 read tools opt-in to `fields[]`;
9
+ * the toolkit's `pickFields` is used directly; `projected_fields` is
10
+ * echoed in the result envelope so the LLM can confirm exactly which
11
+ * keys were kept.
12
+ * - §4.4.1 — when used together with `flat: true` projection runs
13
+ * AFTER the depth-first walk so paths are stable before narrowing.
14
+ *
15
+ * Reference implementation pattern: `connections.ts:721, 779-792, 810`
16
+ * in `@wootsup/apimapper-mcp`.
17
+ *
18
+ * The defaults are pure constants so they can be imported, exported, and
19
+ * asserted against in tests without any side-effects.
20
+ *
21
+ * @license MIT
22
+ */
23
+ import { pickFields } from '@getimo/mcp-toolkit';
24
+ import { z } from 'zod';
25
+ // ─── Schema ──────────────────────────────────────────────────────────
26
+ /**
27
+ * Optional whitelist of fields. Per Design §3.5 the cap is 40 to stop
28
+ * runaway prompts from blowing up the request size; nested paths
29
+ * (`props.title`) are supported by the toolkit's `pickFields`.
30
+ */
31
+ export const FIELDS = z
32
+ .array(z.string().min(1))
33
+ .max(40)
34
+ .optional()
35
+ .describe('Optional whitelist of fields to keep per item (supports nested paths like ' +
36
+ '"props.title"). Default: tool-specific compact set (echoed in projected_fields). ' +
37
+ 'Cuts response size — e.g. fields:["path","element_type","label"] for a minimal ' +
38
+ 'navigation view.');
39
+ /**
40
+ * Flag enabling client-side flattening on `page_get_layout`. When true
41
+ * the response shape switches from `{layout, etag}` to
42
+ * `{elements: [...], etag}` and `fields[]` projection becomes meaningful.
43
+ */
44
+ export const FLAT = z
45
+ .boolean()
46
+ .default(false)
47
+ .describe('When true, response is a flat [{path, element_type, ...}] array. Enables ' +
48
+ 'fields[] projection. Default: false (nested layout, no projection).');
49
+ // ─── Default field-sets per tool ─────────────────────────────────────
50
+ /**
51
+ * Default fields echoed when the caller omits `fields`. Following the
52
+ * apimapper-mcp convention these are **echo-only** — projection itself
53
+ * is skipped (default-all preserved) but `projected_fields` still
54
+ * surfaces the implicit compact set so the AI can plan future requests.
55
+ */
56
+ export const DEFAULT_FIELDS_PAGES_LIST = [
57
+ 'id',
58
+ 'label',
59
+ 'type',
60
+ 'elements_count',
61
+ 'modified_at',
62
+ ];
63
+ export const DEFAULT_FIELDS_ELEMENT_LIST = [
64
+ 'path',
65
+ 'element_type',
66
+ 'label',
67
+ ];
68
+ export const DEFAULT_FIELDS_SCHEMA = [
69
+ 'path',
70
+ 'element_type',
71
+ 'label',
72
+ ];
73
+ export const DEFAULT_FIELDS_SOURCES_LIST = [
74
+ 'name',
75
+ 'label',
76
+ 'origin',
77
+ 'kind',
78
+ ];
79
+ export const DEFAULT_FIELDS_TYPES_LIST = [
80
+ 'name',
81
+ 'label',
82
+ 'origin',
83
+ 'has_children_support',
84
+ ];
85
+ /**
86
+ * element_get defaults to "all" because the AI often needs the full
87
+ * props payload for follow-up edits; sparse projection here is opt-in
88
+ * with nested-path support.
89
+ */
90
+ export const DEFAULT_FIELDS_ELEMENT_GET = undefined;
91
+ // ─── Pure projection helpers ─────────────────────────────────────────
92
+ /**
93
+ * Project an array of items to the requested fields. Returns items
94
+ * unchanged when `fields` is undefined (default-all). Skips non-object
95
+ * entries without crashing (they pass through as-is).
96
+ *
97
+ * @param items - The items to project.
98
+ * @param fields - The whitelist; `undefined` skips projection.
99
+ * @param _defaults - Per-tool default set, accepted for interface symmetry
100
+ * with `projectedFieldsEcho` (unused for actual projection — default-all
101
+ * semantics matches the apimapper-mcp reference, see `connections.ts:789`).
102
+ */
103
+ export function projectFields(items, fields, _defaults) {
104
+ if (fields === undefined) {
105
+ return [...items];
106
+ }
107
+ const mutable = [...fields];
108
+ return items.map((item) => {
109
+ if (item === null || typeof item !== 'object' || Array.isArray(item)) {
110
+ return item;
111
+ }
112
+ return pickFields(item, mutable);
113
+ });
114
+ }
115
+ /**
116
+ * Project a single object via the same `pickFields` rules. Returns the
117
+ * object unchanged when `fields` is undefined.
118
+ */
119
+ export function projectFieldsSingle(obj, fields, _defaults) {
120
+ if (fields === undefined) {
121
+ return obj;
122
+ }
123
+ if (obj === null || typeof obj !== 'object' || Array.isArray(obj)) {
124
+ return obj;
125
+ }
126
+ return pickFields(obj, [...fields]);
127
+ }
128
+ /**
129
+ * Compute the `projected_fields` echo. Returns the caller-requested
130
+ * fields when provided; otherwise returns the per-tool default set so
131
+ * the AI client knows exactly which compact view it implicitly opted into.
132
+ *
133
+ * @returns `undefined` only when neither `requested` nor `defaults` was set
134
+ * (e.g. `element_get` with no opt-in) — callers should omit
135
+ * `projected_fields` from the structuredContent in that case.
136
+ */
137
+ export function projectedFieldsEcho(requested, defaults) {
138
+ if (requested !== undefined)
139
+ return requested;
140
+ if (defaults !== undefined)
141
+ return defaults;
142
+ return undefined;
143
+ }
144
+ //# sourceMappingURL=sparse-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparse-fields.js","sourceRoot":"","sources":["../../src/tools/sparse-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wEAAwE;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC;KAClB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACxB,GAAG,CAAC,EAAE,CAAC;KACP,QAAQ,EAAE;KACV,QAAQ,CACL,4EAA4E;IACxE,mFAAmF;IACnF,iFAAiF;IACjF,kBAAkB,CACzB,CAAC;AAEN;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC;KAChB,OAAO,EAAE;KACT,OAAO,CAAC,KAAK,CAAC;KACd,QAAQ,CACL,2EAA2E;IACvE,qEAAqE,CAC5E,CAAC;AAEN,wEAAwE;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IACxD,IAAI;IACJ,OAAO;IACP,MAAM;IACN,gBAAgB;IAChB,aAAa;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC1D,MAAM;IACN,cAAc;IACd,OAAO;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACpD,MAAM;IACN,cAAc;IACd,OAAO;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC1D,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;CACT,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IACxD,MAAM;IACN,OAAO;IACP,QAAQ;IACR,sBAAsB;CACzB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAkC,SAAS,CAAC;AAEnF,wEAAwE;AAExE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CACzB,KAAmB,EACnB,MAAqC,EACrC,SAA4B;IAE5B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnE,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAM,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAC/B,GAAM,EACN,MAAqC,EACrC,SAAwC;IAExC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAChE,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,CAAM,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAC/B,SAAwC,EACxC,QAAuC;IAEvC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `tool-builder/annotations` — annotation builders that produce the
3
+ * MCP `ToolAnnotations` shape. Each helper encodes a verified
4
+ * read/write/destructive policy so call-sites in domain tools (pages,
5
+ * elements, sources, …) get a single one-liner instead of repeating
6
+ * the four-flag pattern verbatim.
7
+ *
8
+ * Split from `tool-builder.ts` in Round-1.5 — see `index.ts` for
9
+ * the cohesion rationale.
10
+ *
11
+ * @license MIT
12
+ */
13
+ import type { ToolAnnotations } from './types.js';
14
+ /** Build a `readOnly` annotation. */
15
+ export declare function readOnly(title?: string): ToolAnnotations;
16
+ /** Build a `mutating` annotation for idempotent updates (PUT). */
17
+ export declare function mutating(title?: string): ToolAnnotations;
18
+ /** Build a `creating` annotation for non-idempotent creates (POST). */
19
+ export declare function creating(title?: string): ToolAnnotations;
20
+ /** Build a `destructive` annotation. Callers MUST also expose a `confirm` param. */
21
+ export declare function destructive(title?: string): ToolAnnotations;
22
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../src/tools/tool-builder/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,qCAAqC;AACrC,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAExD;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAExD;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAExD;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAQ3D"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `tool-builder/annotations` — annotation builders that produce the
3
+ * MCP `ToolAnnotations` shape. Each helper encodes a verified
4
+ * read/write/destructive policy so call-sites in domain tools (pages,
5
+ * elements, sources, …) get a single one-liner instead of repeating
6
+ * the four-flag pattern verbatim.
7
+ *
8
+ * Split from `tool-builder.ts` in Round-1.5 — see `index.ts` for
9
+ * the cohesion rationale.
10
+ *
11
+ * @license MIT
12
+ */
13
+ /** Build a `readOnly` annotation. */
14
+ export function readOnly(title) {
15
+ return { title, readOnlyHint: true, openWorldHint: true };
16
+ }
17
+ /** Build a `mutating` annotation for idempotent updates (PUT). */
18
+ export function mutating(title) {
19
+ return { title, readOnlyHint: false, openWorldHint: true, idempotentHint: true };
20
+ }
21
+ /** Build a `creating` annotation for non-idempotent creates (POST). */
22
+ export function creating(title) {
23
+ return { title, readOnlyHint: false, openWorldHint: true, idempotentHint: false };
24
+ }
25
+ /** Build a `destructive` annotation. Callers MUST also expose a `confirm` param. */
26
+ export function destructive(title) {
27
+ return {
28
+ title,
29
+ readOnlyHint: false,
30
+ destructiveHint: true,
31
+ openWorldHint: true,
32
+ idempotentHint: false,
33
+ };
34
+ }
35
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../../src/tools/tool-builder/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,qCAAqC;AACrC,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;AACrF,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AACtF,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,OAAO;QACH,KAAK;QACL,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,IAAI;QACrB,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,KAAK;KACxB,CAAC;AACN,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `tool-builder/define` — the `defineTool` identity helper plus the
3
+ * progress-reporter re-export.
4
+ *
5
+ * `defineTool` is intentionally trivial at runtime (returns its
6
+ * argument verbatim) — its only job is to preserve the inferred Zod
7
+ * schema shape so each tool's handler is fully type-checked against
8
+ * its inputSchema. The wrapping/sanitising work happens in
9
+ * `results.ts`.
10
+ *
11
+ * Split from `tool-builder.ts` in Round-1.5 — see `index.ts` for
12
+ * the cohesion rationale.
13
+ *
14
+ * @license MIT
15
+ */
16
+ import { createProgressReporter as toolkitCreateProgressReporter } from '@getimo/mcp-toolkit';
17
+ import type { ZodRawShape } from 'zod';
18
+ import type { ToolDefinition } from './types.js';
19
+ /**
20
+ * Re-export the toolkit's `createProgressReporter` under a stable
21
+ * local symbol so every write-handler in this package depends on a
22
+ * single import path. Returns `null` when the caller sent no
23
+ * `progressToken` — handlers then no-op via `progress?.report(...)`.
24
+ */
25
+ export declare const createProgressReporter: typeof toolkitCreateProgressReporter;
26
+ /**
27
+ * `defineTool` — preserves the inferred Zod-schema shape so each
28
+ * tool's handler is fully type-checked against its inputSchema.
29
+ */
30
+ export declare function defineTool<TSchema extends ZodRawShape>(def: ToolDefinition<TSchema>): ToolDefinition<TSchema>;
31
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/tools/tool-builder/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,sCAAgC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,WAAW,EAClD,GAAG,EAAE,cAAc,CAAC,OAAO,CAAC,GAC7B,cAAc,CAAC,OAAO,CAAC,CAEzB"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `tool-builder/define` — the `defineTool` identity helper plus the
3
+ * progress-reporter re-export.
4
+ *
5
+ * `defineTool` is intentionally trivial at runtime (returns its
6
+ * argument verbatim) — its only job is to preserve the inferred Zod
7
+ * schema shape so each tool's handler is fully type-checked against
8
+ * its inputSchema. The wrapping/sanitising work happens in
9
+ * `results.ts`.
10
+ *
11
+ * Split from `tool-builder.ts` in Round-1.5 — see `index.ts` for
12
+ * the cohesion rationale.
13
+ *
14
+ * @license MIT
15
+ */
16
+ import { createProgressReporter as toolkitCreateProgressReporter } from '@getimo/mcp-toolkit';
17
+ /**
18
+ * Re-export the toolkit's `createProgressReporter` under a stable
19
+ * local symbol so every write-handler in this package depends on a
20
+ * single import path. Returns `null` when the caller sent no
21
+ * `progressToken` — handlers then no-op via `progress?.report(...)`.
22
+ */
23
+ export const createProgressReporter = toolkitCreateProgressReporter;
24
+ /**
25
+ * `defineTool` — preserves the inferred Zod-schema shape so each
26
+ * tool's handler is fully type-checked against its inputSchema.
27
+ */
28
+ export function defineTool(def) {
29
+ return def;
30
+ }
31
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/tools/tool-builder/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAI9F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,UAAU,CACtB,GAA4B;IAE5B,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `tool-builder/index` — barrel re-export for the split
3
+ * tool-definition system.
4
+ *
5
+ * Round-1.5: structural split of the former monolithic
6
+ * `tool-builder.ts` (320 LoC). Cohesion is preserved by topic:
7
+ *
8
+ * - `types.ts` — pure type declarations (no runtime imports
9
+ * beyond type-only `zod` + SDK notifications)
10
+ * - `annotations.ts` — `readOnly` / `mutating` / `creating` /
11
+ * `destructive` annotation builders
12
+ * - `results.ts` — `jsonResult` / `errorResult` /
13
+ * `structuredResult` / `confirmGuard` envelope
14
+ * builders + the shared `sanitizeContentItem`
15
+ * helper (single LLM-boundary mask)
16
+ * - `define.ts` — `defineTool` identity helper + progress-
17
+ * reporter re-export
18
+ *
19
+ * The parent file `../tool-builder.ts` re-exports this barrel so
20
+ * existing `./tool-builder.js` imports keep working without churn.
21
+ *
22
+ * @license MIT
23
+ */
24
+ export type { AnyToolDefinition, HandlerExtra, ToolAnnotations, ToolContent, ToolDefinition, ToolHandler, ToolResult, } from './types.js';
25
+ export { creating, destructive, mutating, readOnly, } from './annotations.js';
26
+ export { confirmGuard, errorResult, jsonResult, structuredResult, } from './results.js';
27
+ export { createProgressReporter, defineTool } from './define.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/tool-builder/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,YAAY,EACR,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `tool-builder/index` — barrel re-export for the split
3
+ * tool-definition system.
4
+ *
5
+ * Round-1.5: structural split of the former monolithic
6
+ * `tool-builder.ts` (320 LoC). Cohesion is preserved by topic:
7
+ *
8
+ * - `types.ts` — pure type declarations (no runtime imports
9
+ * beyond type-only `zod` + SDK notifications)
10
+ * - `annotations.ts` — `readOnly` / `mutating` / `creating` /
11
+ * `destructive` annotation builders
12
+ * - `results.ts` — `jsonResult` / `errorResult` /
13
+ * `structuredResult` / `confirmGuard` envelope
14
+ * builders + the shared `sanitizeContentItem`
15
+ * helper (single LLM-boundary mask)
16
+ * - `define.ts` — `defineTool` identity helper + progress-
17
+ * reporter re-export
18
+ *
19
+ * The parent file `../tool-builder.ts` re-exports this barrel so
20
+ * existing `./tool-builder.js` imports keep working without churn.
21
+ *
22
+ * @license MIT
23
+ */
24
+ export { creating, destructive, mutating, readOnly, } from './annotations.js';
25
+ export { confirmGuard, errorResult, jsonResult, structuredResult, } from './results.js';
26
+ export { createProgressReporter, defineTool } from './define.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/tool-builder/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAWH,OAAO,EACH,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `tool-builder/results` — envelope builders (`jsonResult`,
3
+ * `errorResult`, `structuredResult`, `confirmGuard`) + the shared
4
+ * `sanitizeContentItem` helper. Every payload accepted here runs
5
+ * through the `sanitizeSecrets` / `sanitizeForLogs` boundary so an
6
+ * upstream regression can never land in the LLM context. The mask
7
+ * is concentrated here — `define.ts` and call-sites do not re-mask.
8
+ *
9
+ * Split from `tool-builder.ts` in Round-1.5.
10
+ *
11
+ * @license MIT
12
+ */
13
+ import type { ToolContent, ToolResult } from './types.js';
14
+ /**
15
+ * Convert any JSON-serializable value into the MCP content envelope
16
+ * (2-space JSON). Wave G.6.4b: every payload is deep-walked through
17
+ * `sanitizeSecrets` before stringification so an upstream regression
18
+ * (REST handler surfacing `oauth_refresh_token`, `auth_data`, etc.)
19
+ * can never land in the LLM context.
20
+ */
21
+ export declare function jsonResult(payload: unknown, options?: {
22
+ isError?: boolean;
23
+ }): ToolResult;
24
+ /**
25
+ * Render a structured error result with `context` (echoed input) and a
26
+ * recovery `hint`. Wave G.6.3 defense-in-depth: message is
27
+ * mask-and-truncate'd; context is deep-walked so an input param that
28
+ * accidentally echoed a secret-bearing value cannot leak.
29
+ */
30
+ export declare function errorResult(opts: {
31
+ error: unknown;
32
+ context: Record<string, unknown>;
33
+ hint: string;
34
+ }): ToolResult;
35
+ /**
36
+ * Confirm-guard preview helper for destructive tools. Returns the
37
+ * preview `ToolResult` when `confirm` is false; callers `return` it
38
+ * before executing the destructive REST call.
39
+ */
40
+ export declare function confirmGuard(opts: {
41
+ operation: string;
42
+ details: Record<string, unknown>;
43
+ }): ToolResult;
44
+ /**
45
+ * Merge a toolkit `StructuredCallToolResult` (carries `content[0].text`
46
+ * + `_meta.ui`) with a domain-typed `structuredContent` payload. The
47
+ * result satisfies both Rich-Card hosts (read `_meta.ui`) AND
48
+ * structured-output hosts (read `structuredContent`, may validate
49
+ * against `outputSchema`). Single envelope-merger from every migrated
50
+ * tool's handler — toolkit builders are wrapped, not modified.
51
+ */
52
+ export declare function structuredResult(toolkitResult: {
53
+ content: ToolContent[];
54
+ _meta?: {
55
+ ui?: unknown;
56
+ } & Record<string, unknown>;
57
+ isError?: boolean;
58
+ }, structuredContent: Record<string, unknown>): ToolResult;
59
+ //# sourceMappingURL=results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../src/tools/tool-builder/results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAU1D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,UAAU,CAM5F;AAaD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,UAAU,CAYb;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GAAG,UAAU,CAQb;AAuBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,aAAa,EAAE;IACX,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,EACD,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3C,UAAU,CAgBZ"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * `tool-builder/results` — envelope builders (`jsonResult`,
3
+ * `errorResult`, `structuredResult`, `confirmGuard`) + the shared
4
+ * `sanitizeContentItem` helper. Every payload accepted here runs
5
+ * through the `sanitizeSecrets` / `sanitizeForLogs` boundary so an
6
+ * upstream regression can never land in the LLM context. The mask
7
+ * is concentrated here — `define.ts` and call-sites do not re-mask.
8
+ *
9
+ * Split from `tool-builder.ts` in Round-1.5.
10
+ *
11
+ * @license MIT
12
+ */
13
+ import { NetworkError, RestError } from '../../errors.js';
14
+ import { sanitizeForLogs } from '../../errors/mask.js';
15
+ import { sanitizeSecrets } from '../../errors/sanitize.js';
16
+ function stringify(value) {
17
+ try {
18
+ return JSON.stringify(value, null, 2);
19
+ }
20
+ catch {
21
+ return String(value);
22
+ }
23
+ }
24
+ /**
25
+ * Convert any JSON-serializable value into the MCP content envelope
26
+ * (2-space JSON). Wave G.6.4b: every payload is deep-walked through
27
+ * `sanitizeSecrets` before stringification so an upstream regression
28
+ * (REST handler surfacing `oauth_refresh_token`, `auth_data`, etc.)
29
+ * can never land in the LLM context.
30
+ */
31
+ export function jsonResult(payload, options = {}) {
32
+ const safe = sanitizeSecrets(payload);
33
+ return {
34
+ content: [{ type: 'text', text: stringify(safe) }],
35
+ ...(options.isError === true ? { isError: true } : {}),
36
+ };
37
+ }
38
+ /** Extract `(message, status?, code?)` from any thrown value, honouring
39
+ * `RestError` / `NetworkError` shape distinctions. */
40
+ function describeError(e) {
41
+ if (e instanceof RestError)
42
+ return { message: e.message, status: e.status, code: e.code };
43
+ if (e instanceof NetworkError)
44
+ return { message: e.message };
45
+ if (e instanceof Error)
46
+ return { message: e.message };
47
+ return { message: stringify(e) };
48
+ }
49
+ /**
50
+ * Render a structured error result with `context` (echoed input) and a
51
+ * recovery `hint`. Wave G.6.3 defense-in-depth: message is
52
+ * mask-and-truncate'd; context is deep-walked so an input param that
53
+ * accidentally echoed a secret-bearing value cannot leak.
54
+ */
55
+ export function errorResult(opts) {
56
+ const { message, status, code } = describeError(opts.error);
57
+ return jsonResult({
58
+ error: sanitizeForLogs(message),
59
+ ...(status !== undefined ? { status } : {}),
60
+ ...(code !== undefined ? { code } : {}),
61
+ context: sanitizeSecrets(opts.context),
62
+ hint: opts.hint,
63
+ }, { isError: true });
64
+ }
65
+ /**
66
+ * Confirm-guard preview helper for destructive tools. Returns the
67
+ * preview `ToolResult` when `confirm` is false; callers `return` it
68
+ * before executing the destructive REST call.
69
+ */
70
+ export function confirmGuard(opts) {
71
+ return jsonResult({
72
+ preview: true,
73
+ warning: 'DESTRUCTIVE — Confirmation required',
74
+ operation: opts.operation,
75
+ details: opts.details,
76
+ instruction: 'Ask the user to confirm, then call again with `confirm: true`.',
77
+ });
78
+ }
79
+ /**
80
+ * Sanitise a single content item from a toolkit builder. Text items
81
+ * frequently embed a JSON-stringified payload — if it parses, deep-walk
82
+ * and re-stringify; otherwise leave as-is (toolkit-rendered tables /
83
+ * details are already domain-mapped at the call site).
84
+ */
85
+ function sanitizeContentItem(item) {
86
+ if (item.type !== 'text' || typeof item.text !== 'string')
87
+ return item;
88
+ const text = item.text;
89
+ try {
90
+ const parsed = JSON.parse(text);
91
+ const safe = sanitizeSecrets(parsed);
92
+ return { ...item, text: stringify(safe) };
93
+ }
94
+ catch {
95
+ // Not JSON — toolkit-rendered text. No structural redaction
96
+ // possible without false-positives; the caller has already
97
+ // mapped raw secrets out via field-projection helpers.
98
+ return item;
99
+ }
100
+ }
101
+ /**
102
+ * Merge a toolkit `StructuredCallToolResult` (carries `content[0].text`
103
+ * + `_meta.ui`) with a domain-typed `structuredContent` payload. The
104
+ * result satisfies both Rich-Card hosts (read `_meta.ui`) AND
105
+ * structured-output hosts (read `structuredContent`, may validate
106
+ * against `outputSchema`). Single envelope-merger from every migrated
107
+ * tool's handler — toolkit builders are wrapped, not modified.
108
+ */
109
+ export function structuredResult(toolkitResult, structuredContent) {
110
+ // Wave G.6.4b — deep-walk-sanitise all three legs (text content,
111
+ // _meta.ui, structuredContent) so regressing sources never bypass
112
+ // the LLM-boundary mask.
113
+ const safeContent = toolkitResult.content.map(sanitizeContentItem);
114
+ const safeStructured = sanitizeSecrets(structuredContent);
115
+ const safeMeta = toolkitResult._meta !== undefined
116
+ ? sanitizeSecrets(toolkitResult._meta)
117
+ : undefined;
118
+ return {
119
+ content: safeContent,
120
+ ...(safeMeta !== undefined ? { _meta: safeMeta } : {}),
121
+ ...(toolkitResult.isError === true ? { isError: true } : {}),
122
+ structuredContent: safeStructured,
123
+ };
124
+ }
125
+ //# sourceMappingURL=results.js.map