@wootsup/yt-builder-mcp 1.0.0 → 1.0.1

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 (319) hide show
  1. package/manifest.json +1 -1
  2. package/package.json +1 -1
  3. package/skills/{yootheme-builder → yt-builder-mcp}/SKILL.md +1 -1
  4. package/dist/auth.d.ts +0 -39
  5. package/dist/auth.d.ts.map +0 -1
  6. package/dist/auth.js +0 -93
  7. package/dist/auth.js.map +0 -1
  8. package/dist/client.d.ts +0 -84
  9. package/dist/client.d.ts.map +0 -1
  10. package/dist/client.js +0 -151
  11. package/dist/client.js.map +0 -1
  12. package/dist/clients/claude-code.d.ts +0 -18
  13. package/dist/clients/claude-code.d.ts.map +0 -1
  14. package/dist/clients/claude-code.js +0 -53
  15. package/dist/clients/claude-code.js.map +0 -1
  16. package/dist/clients/claude-desktop.d.ts +0 -19
  17. package/dist/clients/claude-desktop.d.ts.map +0 -1
  18. package/dist/clients/claude-desktop.js +0 -56
  19. package/dist/clients/claude-desktop.js.map +0 -1
  20. package/dist/clients/cline.d.ts +0 -26
  21. package/dist/clients/cline.d.ts.map +0 -1
  22. package/dist/clients/cline.js +0 -80
  23. package/dist/clients/cline.js.map +0 -1
  24. package/dist/clients/codex-cli.d.ts +0 -42
  25. package/dist/clients/codex-cli.d.ts.map +0 -1
  26. package/dist/clients/codex-cli.js +0 -194
  27. package/dist/clients/codex-cli.js.map +0 -1
  28. package/dist/clients/continue.d.ts +0 -13
  29. package/dist/clients/continue.d.ts.map +0 -1
  30. package/dist/clients/continue.js +0 -52
  31. package/dist/clients/continue.js.map +0 -1
  32. package/dist/clients/cursor.d.ts +0 -12
  33. package/dist/clients/cursor.d.ts.map +0 -1
  34. package/dist/clients/cursor.js +0 -38
  35. package/dist/clients/cursor.js.map +0 -1
  36. package/dist/clients/gemini-cli.d.ts +0 -18
  37. package/dist/clients/gemini-cli.d.ts.map +0 -1
  38. package/dist/clients/gemini-cli.js +0 -44
  39. package/dist/clients/gemini-cli.js.map +0 -1
  40. package/dist/clients/home.d.ts +0 -14
  41. package/dist/clients/home.d.ts.map +0 -1
  42. package/dist/clients/home.js +0 -20
  43. package/dist/clients/home.js.map +0 -1
  44. package/dist/clients/index.d.ts +0 -52
  45. package/dist/clients/index.d.ts.map +0 -1
  46. package/dist/clients/index.js +0 -72
  47. package/dist/clients/index.js.map +0 -1
  48. package/dist/clients/roo-code.d.ts +0 -23
  49. package/dist/clients/roo-code.d.ts.map +0 -1
  50. package/dist/clients/roo-code.js +0 -69
  51. package/dist/clients/roo-code.js.map +0 -1
  52. package/dist/clients/zed.d.ts +0 -12
  53. package/dist/clients/zed.d.ts.map +0 -1
  54. package/dist/clients/zed.js +0 -41
  55. package/dist/clients/zed.js.map +0 -1
  56. package/dist/errors/hints.d.ts +0 -51
  57. package/dist/errors/hints.d.ts.map +0 -1
  58. package/dist/errors/hints.js +0 -95
  59. package/dist/errors/hints.js.map +0 -1
  60. package/dist/errors/mask.d.ts +0 -35
  61. package/dist/errors/mask.d.ts.map +0 -1
  62. package/dist/errors/mask.js +0 -49
  63. package/dist/errors/mask.js.map +0 -1
  64. package/dist/errors/sanitize.d.ts +0 -31
  65. package/dist/errors/sanitize.d.ts.map +0 -1
  66. package/dist/errors/sanitize.js +0 -90
  67. package/dist/errors/sanitize.js.map +0 -1
  68. package/dist/errors.d.ts +0 -42
  69. package/dist/errors.d.ts.map +0 -1
  70. package/dist/errors.js +0 -61
  71. package/dist/errors.js.map +0 -1
  72. package/dist/gateway/advanced-tool/discovery.d.ts +0 -19
  73. package/dist/gateway/advanced-tool/discovery.d.ts.map +0 -1
  74. package/dist/gateway/advanced-tool/discovery.js +0 -53
  75. package/dist/gateway/advanced-tool/discovery.js.map +0 -1
  76. package/dist/gateway/advanced-tool/domains.d.ts +0 -47
  77. package/dist/gateway/advanced-tool/domains.d.ts.map +0 -1
  78. package/dist/gateway/advanced-tool/domains.js +0 -94
  79. package/dist/gateway/advanced-tool/domains.js.map +0 -1
  80. package/dist/gateway/advanced-tool/execute.d.ts +0 -29
  81. package/dist/gateway/advanced-tool/execute.d.ts.map +0 -1
  82. package/dist/gateway/advanced-tool/execute.js +0 -54
  83. package/dist/gateway/advanced-tool/execute.js.map +0 -1
  84. package/dist/gateway/advanced-tool/index.d.ts +0 -36
  85. package/dist/gateway/advanced-tool/index.d.ts.map +0 -1
  86. package/dist/gateway/advanced-tool/index.js +0 -39
  87. package/dist/gateway/advanced-tool/index.js.map +0 -1
  88. package/dist/gateway/advanced-tool/register.d.ts +0 -18
  89. package/dist/gateway/advanced-tool/register.d.ts.map +0 -1
  90. package/dist/gateway/advanced-tool/register.js +0 -69
  91. package/dist/gateway/advanced-tool/register.js.map +0 -1
  92. package/dist/gateway/advanced-tool.d.ts +0 -13
  93. package/dist/gateway/advanced-tool.d.ts.map +0 -1
  94. package/dist/gateway/advanced-tool.js +0 -13
  95. package/dist/gateway/advanced-tool.js.map +0 -1
  96. package/dist/gateway/capturing-server.d.ts +0 -117
  97. package/dist/gateway/capturing-server.d.ts.map +0 -1
  98. package/dist/gateway/capturing-server.js +0 -103
  99. package/dist/gateway/capturing-server.js.map +0 -1
  100. package/dist/gateway/essentials.d.ts +0 -49
  101. package/dist/gateway/essentials.d.ts.map +0 -1
  102. package/dist/gateway/essentials.js +0 -79
  103. package/dist/gateway/essentials.js.map +0 -1
  104. package/dist/gateway/test-support.d.ts +0 -41
  105. package/dist/gateway/test-support.d.ts.map +0 -1
  106. package/dist/gateway/test-support.js +0 -60
  107. package/dist/gateway/test-support.js.map +0 -1
  108. package/dist/index.d.ts +0 -25
  109. package/dist/index.d.ts.map +0 -1
  110. package/dist/index.js +0 -77
  111. package/dist/index.js.map +0 -1
  112. package/dist/install-skill.d.ts +0 -35
  113. package/dist/install-skill.d.ts.map +0 -1
  114. package/dist/install-skill.js +0 -107
  115. package/dist/install-skill.js.map +0 -1
  116. package/dist/platform/index.d.ts +0 -49
  117. package/dist/platform/index.d.ts.map +0 -1
  118. package/dist/platform/index.js +0 -38
  119. package/dist/platform/index.js.map +0 -1
  120. package/dist/server.d.ts +0 -50
  121. package/dist/server.d.ts.map +0 -1
  122. package/dist/server.js +0 -153
  123. package/dist/server.js.map +0 -1
  124. package/dist/setup-cli.d.ts +0 -100
  125. package/dist/setup-cli.d.ts.map +0 -1
  126. package/dist/setup-cli.js +0 -355
  127. package/dist/setup-cli.js.map +0 -1
  128. package/dist/setup-prompts.d.ts +0 -41
  129. package/dist/setup-prompts.d.ts.map +0 -1
  130. package/dist/setup-prompts.js +0 -142
  131. package/dist/setup-prompts.js.map +0 -1
  132. package/dist/setup-token.d.ts +0 -38
  133. package/dist/setup-token.d.ts.map +0 -1
  134. package/dist/setup-token.js +0 -106
  135. package/dist/setup-token.js.map +0 -1
  136. package/dist/setup-wizard-defaults.d.ts +0 -43
  137. package/dist/setup-wizard-defaults.d.ts.map +0 -1
  138. package/dist/setup-wizard-defaults.js +0 -160
  139. package/dist/setup-wizard-defaults.js.map +0 -1
  140. package/dist/setup-wizard-handshake.d.ts +0 -25
  141. package/dist/setup-wizard-handshake.d.ts.map +0 -1
  142. package/dist/setup-wizard-handshake.js +0 -103
  143. package/dist/setup-wizard-handshake.js.map +0 -1
  144. package/dist/setup-wizard-types.d.ts +0 -148
  145. package/dist/setup-wizard-types.d.ts.map +0 -1
  146. package/dist/setup-wizard-types.js +0 -11
  147. package/dist/setup-wizard-types.js.map +0 -1
  148. package/dist/setup-wizard.d.ts +0 -33
  149. package/dist/setup-wizard.d.ts.map +0 -1
  150. package/dist/setup-wizard.js +0 -166
  151. package/dist/setup-wizard.js.map +0 -1
  152. package/dist/setup.d.ts +0 -17
  153. package/dist/setup.d.ts.map +0 -1
  154. package/dist/setup.js +0 -33
  155. package/dist/setup.js.map +0 -1
  156. package/dist/skill-loader.d.ts +0 -51
  157. package/dist/skill-loader.d.ts.map +0 -1
  158. package/dist/skill-loader.js +0 -78
  159. package/dist/skill-loader.js.map +0 -1
  160. package/dist/tools/elements/builders.d.ts +0 -24
  161. package/dist/tools/elements/builders.d.ts.map +0 -1
  162. package/dist/tools/elements/builders.js +0 -177
  163. package/dist/tools/elements/builders.js.map +0 -1
  164. package/dist/tools/elements/handlers-write.d.ts +0 -49
  165. package/dist/tools/elements/handlers-write.d.ts.map +0 -1
  166. package/dist/tools/elements/handlers-write.js +0 -148
  167. package/dist/tools/elements/handlers-write.js.map +0 -1
  168. package/dist/tools/elements/handlers.d.ts +0 -61
  169. package/dist/tools/elements/handlers.d.ts.map +0 -1
  170. package/dist/tools/elements/handlers.js +0 -170
  171. package/dist/tools/elements/handlers.js.map +0 -1
  172. package/dist/tools/elements/index.d.ts +0 -28
  173. package/dist/tools/elements/index.d.ts.map +0 -1
  174. package/dist/tools/elements/index.js +0 -27
  175. package/dist/tools/elements/index.js.map +0 -1
  176. package/dist/tools/elements.d.ts +0 -13
  177. package/dist/tools/elements.d.ts.map +0 -1
  178. package/dist/tools/elements.js +0 -13
  179. package/dist/tools/elements.js.map +0 -1
  180. package/dist/tools/elicitation.d.ts +0 -87
  181. package/dist/tools/elicitation.d.ts.map +0 -1
  182. package/dist/tools/elicitation.js +0 -100
  183. package/dist/tools/elicitation.js.map +0 -1
  184. package/dist/tools/format/elements-format.d.ts +0 -40
  185. package/dist/tools/format/elements-format.d.ts.map +0 -1
  186. package/dist/tools/format/elements-format.js +0 -194
  187. package/dist/tools/format/elements-format.js.map +0 -1
  188. package/dist/tools/format/health-format.d.ts +0 -73
  189. package/dist/tools/format/health-format.d.ts.map +0 -1
  190. package/dist/tools/format/health-format.js +0 -178
  191. package/dist/tools/format/health-format.js.map +0 -1
  192. package/dist/tools/format/inspection-format.d.ts +0 -58
  193. package/dist/tools/format/inspection-format.d.ts.map +0 -1
  194. package/dist/tools/format/inspection-format.js +0 -164
  195. package/dist/tools/format/inspection-format.js.map +0 -1
  196. package/dist/tools/format/pages-format.d.ts +0 -42
  197. package/dist/tools/format/pages-format.d.ts.map +0 -1
  198. package/dist/tools/format/pages-format.js +0 -113
  199. package/dist/tools/format/pages-format.js.map +0 -1
  200. package/dist/tools/format/sources-format.d.ts +0 -25
  201. package/dist/tools/format/sources-format.d.ts.map +0 -1
  202. package/dist/tools/format/sources-format.js +0 -208
  203. package/dist/tools/format/sources-format.js.map +0 -1
  204. package/dist/tools/health.d.ts +0 -22
  205. package/dist/tools/health.d.ts.map +0 -1
  206. package/dist/tools/health.js +0 -147
  207. package/dist/tools/health.js.map +0 -1
  208. package/dist/tools/index.d.ts +0 -23
  209. package/dist/tools/index.d.ts.map +0 -1
  210. package/dist/tools/index.js +0 -25
  211. package/dist/tools/index.js.map +0 -1
  212. package/dist/tools/inspection.d.ts +0 -14
  213. package/dist/tools/inspection.d.ts.map +0 -1
  214. package/dist/tools/inspection.js +0 -125
  215. package/dist/tools/inspection.js.map +0 -1
  216. package/dist/tools/layout-flatten.d.ts +0 -75
  217. package/dist/tools/layout-flatten.d.ts.map +0 -1
  218. package/dist/tools/layout-flatten.js +0 -107
  219. package/dist/tools/layout-flatten.js.map +0 -1
  220. package/dist/tools/multi-items/builders.d.ts +0 -23
  221. package/dist/tools/multi-items/builders.d.ts.map +0 -1
  222. package/dist/tools/multi-items/builders.js +0 -56
  223. package/dist/tools/multi-items/builders.js.map +0 -1
  224. package/dist/tools/multi-items/clean-implode-handler.d.ts +0 -28
  225. package/dist/tools/multi-items/clean-implode-handler.d.ts.map +0 -1
  226. package/dist/tools/multi-items/clean-implode-handler.js +0 -40
  227. package/dist/tools/multi-items/clean-implode-handler.js.map +0 -1
  228. package/dist/tools/multi-items/index.d.ts +0 -18
  229. package/dist/tools/multi-items/index.d.ts.map +0 -1
  230. package/dist/tools/multi-items/index.js +0 -18
  231. package/dist/tools/multi-items/index.js.map +0 -1
  232. package/dist/tools/multi-items/inspect-handler.d.ts +0 -41
  233. package/dist/tools/multi-items/inspect-handler.d.ts.map +0 -1
  234. package/dist/tools/multi-items/inspect-handler.js +0 -50
  235. package/dist/tools/multi-items/inspect-handler.js.map +0 -1
  236. package/dist/tools/multi-items/item-container-map.d.ts +0 -41
  237. package/dist/tools/multi-items/item-container-map.d.ts.map +0 -1
  238. package/dist/tools/multi-items/item-container-map.js +0 -73
  239. package/dist/tools/multi-items/item-container-map.js.map +0 -1
  240. package/dist/tools/pages/builders.d.ts +0 -14
  241. package/dist/tools/pages/builders.d.ts.map +0 -1
  242. package/dist/tools/pages/builders.js +0 -115
  243. package/dist/tools/pages/builders.js.map +0 -1
  244. package/dist/tools/pages/handlers-read.d.ts +0 -33
  245. package/dist/tools/pages/handlers-read.d.ts.map +0 -1
  246. package/dist/tools/pages/handlers-read.js +0 -161
  247. package/dist/tools/pages/handlers-read.js.map +0 -1
  248. package/dist/tools/pages/handlers-write.d.ts +0 -21
  249. package/dist/tools/pages/handlers-write.d.ts.map +0 -1
  250. package/dist/tools/pages/handlers-write.js +0 -52
  251. package/dist/tools/pages/handlers-write.js.map +0 -1
  252. package/dist/tools/pages/index.d.ts +0 -17
  253. package/dist/tools/pages/index.d.ts.map +0 -1
  254. package/dist/tools/pages/index.js +0 -17
  255. package/dist/tools/pages/index.js.map +0 -1
  256. package/dist/tools/pages/schemas.d.ts +0 -30
  257. package/dist/tools/pages/schemas.d.ts.map +0 -1
  258. package/dist/tools/pages/schemas.js +0 -30
  259. package/dist/tools/pages/schemas.js.map +0 -1
  260. package/dist/tools/pages.d.ts +0 -13
  261. package/dist/tools/pages.d.ts.map +0 -1
  262. package/dist/tools/pages.js +0 -13
  263. package/dist/tools/pages.js.map +0 -1
  264. package/dist/tools/progress-phases.d.ts +0 -46
  265. package/dist/tools/progress-phases.d.ts.map +0 -1
  266. package/dist/tools/progress-phases.js +0 -48
  267. package/dist/tools/progress-phases.js.map +0 -1
  268. package/dist/tools/shared-schemas.d.ts +0 -15
  269. package/dist/tools/shared-schemas.d.ts.map +0 -1
  270. package/dist/tools/shared-schemas.js +0 -30
  271. package/dist/tools/shared-schemas.js.map +0 -1
  272. package/dist/tools/sources/builders.d.ts +0 -13
  273. package/dist/tools/sources/builders.d.ts.map +0 -1
  274. package/dist/tools/sources/builders.js +0 -103
  275. package/dist/tools/sources/builders.js.map +0 -1
  276. package/dist/tools/sources/handlers-bind.d.ts +0 -28
  277. package/dist/tools/sources/handlers-bind.d.ts.map +0 -1
  278. package/dist/tools/sources/handlers-bind.js +0 -129
  279. package/dist/tools/sources/handlers-bind.js.map +0 -1
  280. package/dist/tools/sources/handlers.d.ts +0 -45
  281. package/dist/tools/sources/handlers.d.ts.map +0 -1
  282. package/dist/tools/sources/handlers.js +0 -91
  283. package/dist/tools/sources/handlers.js.map +0 -1
  284. package/dist/tools/sources/index.d.ts +0 -19
  285. package/dist/tools/sources/index.d.ts.map +0 -1
  286. package/dist/tools/sources/index.js +0 -18
  287. package/dist/tools/sources/index.js.map +0 -1
  288. package/dist/tools/sources.d.ts +0 -14
  289. package/dist/tools/sources.d.ts.map +0 -1
  290. package/dist/tools/sources.js +0 -14
  291. package/dist/tools/sources.js.map +0 -1
  292. package/dist/tools/sparse-fields.d.ts +0 -80
  293. package/dist/tools/sparse-fields.d.ts.map +0 -1
  294. package/dist/tools/sparse-fields.js +0 -144
  295. package/dist/tools/sparse-fields.js.map +0 -1
  296. package/dist/tools/tool-builder/annotations.d.ts +0 -55
  297. package/dist/tools/tool-builder/annotations.d.ts.map +0 -1
  298. package/dist/tools/tool-builder/annotations.js +0 -86
  299. package/dist/tools/tool-builder/annotations.js.map +0 -1
  300. package/dist/tools/tool-builder/define.d.ts +0 -31
  301. package/dist/tools/tool-builder/define.d.ts.map +0 -1
  302. package/dist/tools/tool-builder/define.js +0 -31
  303. package/dist/tools/tool-builder/define.js.map +0 -1
  304. package/dist/tools/tool-builder/index.d.ts +0 -28
  305. package/dist/tools/tool-builder/index.d.ts.map +0 -1
  306. package/dist/tools/tool-builder/index.js +0 -27
  307. package/dist/tools/tool-builder/index.js.map +0 -1
  308. package/dist/tools/tool-builder/results.d.ts +0 -59
  309. package/dist/tools/tool-builder/results.d.ts.map +0 -1
  310. package/dist/tools/tool-builder/results.js +0 -125
  311. package/dist/tools/tool-builder/results.js.map +0 -1
  312. package/dist/tools/tool-builder/types.d.ts +0 -82
  313. package/dist/tools/tool-builder/types.d.ts.map +0 -1
  314. package/dist/tools/tool-builder/types.js +0 -9
  315. package/dist/tools/tool-builder/types.js.map +0 -1
  316. package/dist/tools/tool-builder.d.ts +0 -16
  317. package/dist/tools/tool-builder.d.ts.map +0 -1
  318. package/dist/tools/tool-builder.js +0 -16
  319. package/dist/tools/tool-builder.js.map +0 -1
@@ -1,144 +0,0 @@
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
@@ -1 +0,0 @@
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;IAC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AAU,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"}
@@ -1,55 +0,0 @@
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
- * Audit-v3 / Stream D3 T3 (2026-05-22) — per Anthropic MCP spec
12
- * 2026-03-16 "Tool Annotations", every registered tool MUST advertise
13
- * the full 4-tuple `{readOnlyHint, destructiveHint, idempotentHint,
14
- * openWorldHint}`. Hosts treat `undefined` hints as "potentially
15
- * destructive" — defaulting `destructiveHint:false` and
16
- * `idempotentHint:true/false` explicitly removes that ambiguity for
17
- * read-only and additive tools.
18
- *
19
- * `openWorldHint:false` reflects the closed Builder domain: the REST
20
- * surface writes to a single local `wp_option('yootheme')` blob —
21
- * there is no external network side-effect or world-modifying action.
22
- * The gateway (`yootheme_builder_advanced`) is the exception (its
23
- * effective behaviour is dynamic, decided at call-time).
24
- *
25
- * @license MIT
26
- */
27
- import type { ToolAnnotations } from './types.js';
28
- /**
29
- * Build a `readOnly` annotation.
30
- *
31
- * Reads are idempotent by definition — repeating a read returns the
32
- * same data (modulo concurrent writes). Setting `idempotentHint:true`
33
- * is informative for hosts that surface a "safe-to-retry" badge.
34
- */
35
- export declare function readOnly(title?: string): ToolAnnotations;
36
- /**
37
- * Build a `mutating` annotation for idempotent updates (PUT-style
38
- * writes — full replacement semantics where repeating the call with
39
- * the same inputs yields the same end-state).
40
- */
41
- export declare function mutating(title?: string): ToolAnnotations;
42
- /**
43
- * Build a `creating` annotation for non-idempotent creates (POST-style
44
- * writes — repeating the call produces additional elements / new IDs).
45
- */
46
- export declare function creating(title?: string): ToolAnnotations;
47
- /**
48
- * Build a `destructive` annotation. Callers MUST also expose a
49
- * `confirm` param + preview guard (see annotations-pin.test.ts).
50
- *
51
- * Destructive ops are inherently non-idempotent (the first call
52
- * removes data; the second call hits a 404 / already-gone state).
53
- */
54
- export declare function destructive(title?: string): ToolAnnotations;
55
- //# sourceMappingURL=annotations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../src/tools/tool-builder/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAQxD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAQxD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAQxD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,CAQ3D"}
@@ -1,86 +0,0 @@
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
- * Audit-v3 / Stream D3 T3 (2026-05-22) — per Anthropic MCP spec
12
- * 2026-03-16 "Tool Annotations", every registered tool MUST advertise
13
- * the full 4-tuple `{readOnlyHint, destructiveHint, idempotentHint,
14
- * openWorldHint}`. Hosts treat `undefined` hints as "potentially
15
- * destructive" — defaulting `destructiveHint:false` and
16
- * `idempotentHint:true/false` explicitly removes that ambiguity for
17
- * read-only and additive tools.
18
- *
19
- * `openWorldHint:false` reflects the closed Builder domain: the REST
20
- * surface writes to a single local `wp_option('yootheme')` blob —
21
- * there is no external network side-effect or world-modifying action.
22
- * The gateway (`yootheme_builder_advanced`) is the exception (its
23
- * effective behaviour is dynamic, decided at call-time).
24
- *
25
- * @license MIT
26
- */
27
- /**
28
- * Build a `readOnly` annotation.
29
- *
30
- * Reads are idempotent by definition — repeating a read returns the
31
- * same data (modulo concurrent writes). Setting `idempotentHint:true`
32
- * is informative for hosts that surface a "safe-to-retry" badge.
33
- */
34
- export function readOnly(title) {
35
- return {
36
- title,
37
- readOnlyHint: true,
38
- destructiveHint: false,
39
- idempotentHint: true,
40
- openWorldHint: false,
41
- };
42
- }
43
- /**
44
- * Build a `mutating` annotation for idempotent updates (PUT-style
45
- * writes — full replacement semantics where repeating the call with
46
- * the same inputs yields the same end-state).
47
- */
48
- export function mutating(title) {
49
- return {
50
- title,
51
- readOnlyHint: false,
52
- destructiveHint: false,
53
- idempotentHint: true,
54
- openWorldHint: false,
55
- };
56
- }
57
- /**
58
- * Build a `creating` annotation for non-idempotent creates (POST-style
59
- * writes — repeating the call produces additional elements / new IDs).
60
- */
61
- export function creating(title) {
62
- return {
63
- title,
64
- readOnlyHint: false,
65
- destructiveHint: false,
66
- idempotentHint: false,
67
- openWorldHint: false,
68
- };
69
- }
70
- /**
71
- * Build a `destructive` annotation. Callers MUST also expose a
72
- * `confirm` param + preview guard (see annotations-pin.test.ts).
73
- *
74
- * Destructive ops are inherently non-idempotent (the first call
75
- * removes data; the second call hits a 404 / already-gone state).
76
- */
77
- export function destructive(title) {
78
- return {
79
- title,
80
- readOnlyHint: false,
81
- destructiveHint: true,
82
- idempotentHint: false,
83
- openWorldHint: false,
84
- };
85
- }
86
- //# sourceMappingURL=annotations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../../src/tools/tool-builder/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO;QACH,KAAK;QACL,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO;QACH,KAAK;QACL,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO;QACH,KAAK;QACL,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,KAAK;KACvB,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACtC,OAAO;QACH,KAAK;QACL,YAAY,EAAE,KAAK;QACnB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,KAAK;QACrB,aAAa,EAAE,KAAK;KACvB,CAAC;AACN,CAAC"}
@@ -1,31 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,31 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,27 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,59 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,125 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"results.js","sourceRoot":"","sources":["../../../src/tools/tool-builder/results.ts"],"names":[],"mappings":"AAAA;;;;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