@lerianstudio/matcher-mcp 5.0.0-beta.13 → 5.0.0-beta.131

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 (273) hide show
  1. package/README.md +28 -13
  2. package/dist/auth/request-token.js +11 -69
  3. package/dist/auth/request-token.js.map +1 -1
  4. package/dist/config.js +6 -21
  5. package/dist/config.js.map +1 -1
  6. package/dist/copilot/agent.js +5 -9
  7. package/dist/copilot/agent.js.map +1 -1
  8. package/dist/copilot/provider-anthropic.js +75 -23
  9. package/dist/copilot/provider-anthropic.js.map +1 -1
  10. package/dist/copilot/provider-openrouter.js +5 -18
  11. package/dist/copilot/provider-openrouter.js.map +1 -1
  12. package/dist/copilot/provider-shared.js +11 -0
  13. package/dist/copilot/provider-shared.js.map +1 -1
  14. package/dist/copilot/speech-provider.js +84 -0
  15. package/dist/copilot/speech-provider.js.map +1 -0
  16. package/dist/copilot/sse.js +5 -0
  17. package/dist/copilot/sse.js.map +1 -1
  18. package/dist/copilot/system-prompt.js +6 -2
  19. package/dist/copilot/system-prompt.js.map +1 -1
  20. package/dist/copilot/tools.js +14 -65
  21. package/dist/copilot/tools.js.map +1 -1
  22. package/dist/copilot/transcribe-handler.js +8 -93
  23. package/dist/copilot/transcribe-handler.js.map +1 -1
  24. package/dist/copilot/turn-request.js +76 -0
  25. package/dist/copilot/turn-request.js.map +1 -0
  26. package/dist/copilot/turns-handler.js +11 -102
  27. package/dist/copilot/turns-handler.js.map +1 -1
  28. package/dist/matcher/client.js +14 -0
  29. package/dist/matcher/client.js.map +1 -1
  30. package/dist/matcher/idempotency.js +94 -0
  31. package/dist/matcher/idempotency.js.map +1 -0
  32. package/dist/observability/otel.js +7 -29
  33. package/dist/observability/otel.js.map +1 -1
  34. package/dist/server.js +12 -81
  35. package/dist/server.js.map +1 -1
  36. package/dist/spec/curated-operations.js +111 -95
  37. package/dist/spec/curated-operations.js.map +1 -1
  38. package/dist/spec/enum-policy.js +21 -26
  39. package/dist/spec/enum-policy.js.map +1 -1
  40. package/dist/spec/openapi.yaml +875 -64
  41. package/dist/spec/schema-parity.js +23 -28
  42. package/dist/spec/schema-parity.js.map +1 -1
  43. package/dist/tools/context/create.js +14 -3
  44. package/dist/tools/context/create.js.map +1 -1
  45. package/dist/tools/context/index.js +137 -17
  46. package/dist/tools/context/index.js.map +1 -1
  47. package/dist/tools/context/list.js +9 -35
  48. package/dist/tools/context/list.js.map +1 -1
  49. package/dist/tools/context/setup-progress.js +3 -2
  50. package/dist/tools/context/setup-progress.js.map +1 -1
  51. package/dist/tools/context/shared.js +7 -48
  52. package/dist/tools/context/shared.js.map +1 -1
  53. package/dist/tools/context/update.js +15 -7
  54. package/dist/tools/context/update.js.map +1 -1
  55. package/dist/tools/curated-tool.js +39 -0
  56. package/dist/tools/curated-tool.js.map +1 -0
  57. package/dist/tools/dashboard/index.js +124 -19
  58. package/dist/tools/dashboard/index.js.map +1 -1
  59. package/dist/tools/dashboard/shared.js +9 -68
  60. package/dist/tools/dashboard/shared.js.map +1 -1
  61. package/dist/tools/dispute/close.js +5 -5
  62. package/dist/tools/dispute/close.js.map +1 -1
  63. package/dist/tools/dispute/index.js +34 -6
  64. package/dist/tools/dispute/index.js.map +1 -1
  65. package/dist/tools/dispute/list.js +18 -47
  66. package/dist/tools/dispute/list.js.map +1 -1
  67. package/dist/tools/dispute/shared.js +4 -43
  68. package/dist/tools/dispute/shared.js.map +1 -1
  69. package/dist/tools/dispute/submit-evidence.js +5 -5
  70. package/dist/tools/dispute/submit-evidence.js.map +1 -1
  71. package/dist/tools/exception/add-comment.js +3 -2
  72. package/dist/tools/exception/add-comment.js.map +1 -1
  73. package/dist/tools/exception/adjust-entry.js +5 -5
  74. package/dist/tools/exception/adjust-entry.js.map +1 -1
  75. package/dist/tools/exception/bulk-assign.js +3 -2
  76. package/dist/tools/exception/bulk-assign.js.map +1 -1
  77. package/dist/tools/exception/bulk-dispatch.js +12 -4
  78. package/dist/tools/exception/bulk-dispatch.js.map +1 -1
  79. package/dist/tools/exception/bulk-resolve.js +3 -2
  80. package/dist/tools/exception/bulk-resolve.js.map +1 -1
  81. package/dist/tools/exception/dispatch.js +13 -5
  82. package/dist/tools/exception/dispatch.js.map +1 -1
  83. package/dist/tools/exception/force-match.js +3 -2
  84. package/dist/tools/exception/force-match.js.map +1 -1
  85. package/dist/tools/exception/history.js +8 -24
  86. package/dist/tools/exception/history.js.map +1 -1
  87. package/dist/tools/exception/index.js +88 -18
  88. package/dist/tools/exception/index.js.map +1 -1
  89. package/dist/tools/exception/list.js +14 -57
  90. package/dist/tools/exception/list.js.map +1 -1
  91. package/dist/tools/exception/open-dispute.js +3 -2
  92. package/dist/tools/exception/open-dispute.js.map +1 -1
  93. package/dist/tools/exception/shared.js +10 -46
  94. package/dist/tools/exception/shared.js.map +1 -1
  95. package/dist/tools/fee-rule/create.js +5 -5
  96. package/dist/tools/fee-rule/create.js.map +1 -1
  97. package/dist/tools/fee-rule/index.js +50 -8
  98. package/dist/tools/fee-rule/index.js.map +1 -1
  99. package/dist/tools/fee-rule/list.js +9 -29
  100. package/dist/tools/fee-rule/list.js.map +1 -1
  101. package/dist/tools/fee-rule/shared.js +5 -47
  102. package/dist/tools/fee-rule/shared.js.map +1 -1
  103. package/dist/tools/fee-rule/update.js +5 -5
  104. package/dist/tools/fee-rule/update.js.map +1 -1
  105. package/dist/tools/fee-schedule/create.js +8 -3
  106. package/dist/tools/fee-schedule/create.js.map +1 -1
  107. package/dist/tools/fee-schedule/index.js +62 -11
  108. package/dist/tools/fee-schedule/index.js.map +1 -1
  109. package/dist/tools/fee-schedule/list.js +8 -24
  110. package/dist/tools/fee-schedule/list.js.map +1 -1
  111. package/dist/tools/fee-schedule/shared.js +5 -44
  112. package/dist/tools/fee-schedule/shared.js.map +1 -1
  113. package/dist/tools/fee-schedule/simulate.js +5 -5
  114. package/dist/tools/fee-schedule/simulate.js.map +1 -1
  115. package/dist/tools/fee-schedule/update.js +5 -5
  116. package/dist/tools/fee-schedule/update.js.map +1 -1
  117. package/dist/tools/field-map/create.js +3 -2
  118. package/dist/tools/field-map/create.js.map +1 -1
  119. package/dist/tools/field-map/index.js +65 -11
  120. package/dist/tools/field-map/index.js.map +1 -1
  121. package/dist/tools/field-map/list.js +9 -29
  122. package/dist/tools/field-map/list.js.map +1 -1
  123. package/dist/tools/field-map/shared.js +6 -42
  124. package/dist/tools/field-map/shared.js.map +1 -1
  125. package/dist/tools/field-map/update.js +3 -2
  126. package/dist/tools/field-map/update.js.map +1 -1
  127. package/dist/tools/generic/invoke.js +16 -39
  128. package/dist/tools/generic/invoke.js.map +1 -1
  129. package/dist/tools/ingestion/index.js +100 -12
  130. package/dist/tools/ingestion/index.js.map +1 -1
  131. package/dist/tools/ingestion/job-transactions-list.js +10 -40
  132. package/dist/tools/ingestion/job-transactions-list.js.map +1 -1
  133. package/dist/tools/ingestion/jobs-list.js +9 -35
  134. package/dist/tools/ingestion/jobs-list.js.map +1 -1
  135. package/dist/tools/ingestion/shared.js +4 -41
  136. package/dist/tools/ingestion/shared.js.map +1 -1
  137. package/dist/tools/ingestion/transactions-search.js +9 -44
  138. package/dist/tools/ingestion/transactions-search.js.map +1 -1
  139. package/dist/tools/ingestion/upload.js +3 -2
  140. package/dist/tools/ingestion/upload.js.map +1 -1
  141. package/dist/tools/input-fields.js +51 -0
  142. package/dist/tools/input-fields.js.map +1 -0
  143. package/dist/tools/match-rule/index.js +130 -13
  144. package/dist/tools/match-rule/index.js.map +1 -1
  145. package/dist/tools/match-rule/list.js +9 -33
  146. package/dist/tools/match-rule/list.js.map +1 -1
  147. package/dist/tools/match-rule/shared.js +16 -46
  148. package/dist/tools/match-rule/shared.js.map +1 -1
  149. package/dist/tools/match-rule/update.js +7 -11
  150. package/dist/tools/match-rule/update.js.map +1 -1
  151. package/dist/tools/matching/get.js +5 -5
  152. package/dist/tools/matching/get.js.map +1 -1
  153. package/dist/tools/matching/groups.js +6 -14
  154. package/dist/tools/matching/groups.js.map +1 -1
  155. package/dist/tools/matching/index.js +77 -5
  156. package/dist/tools/matching/index.js.map +1 -1
  157. package/dist/tools/matching/list.js +9 -32
  158. package/dist/tools/matching/list.js.map +1 -1
  159. package/dist/tools/matching/shared.js +5 -46
  160. package/dist/tools/matching/shared.js.map +1 -1
  161. package/dist/tools/query-handler.js +9 -0
  162. package/dist/tools/query-handler.js.map +1 -0
  163. package/dist/tools/report/index.js +260 -30
  164. package/dist/tools/report/index.js.map +1 -1
  165. package/dist/tools/report/shared.js +24 -98
  166. package/dist/tools/report/shared.js.map +1 -1
  167. package/dist/tools/request-fields.js +17 -0
  168. package/dist/tools/request-fields.js.map +1 -0
  169. package/dist/tools/shared-dispatch.js +38 -0
  170. package/dist/tools/shared-dispatch.js.map +1 -0
  171. package/dist/tools/source/create.js +146 -23
  172. package/dist/tools/source/create.js.map +1 -1
  173. package/dist/tools/source/index.js +101 -13
  174. package/dist/tools/source/index.js.map +1 -1
  175. package/dist/tools/source/list.js +9 -32
  176. package/dist/tools/source/list.js.map +1 -1
  177. package/dist/tools/source/shared.js +5 -42
  178. package/dist/tools/source/shared.js.map +1 -1
  179. package/dist/tools/source/update.js +16 -33
  180. package/dist/tools/source/update.js.map +1 -1
  181. package/dist/tools/workspace/usage.js +27 -41
  182. package/dist/tools/workspace/usage.js.map +1 -1
  183. package/package.json +4 -4
  184. package/dist/tools/context/archive.js +0 -37
  185. package/dist/tools/context/archive.js.map +0 -1
  186. package/dist/tools/context/get.js +0 -31
  187. package/dist/tools/context/get.js.map +0 -1
  188. package/dist/tools/context/next-step.js +0 -99
  189. package/dist/tools/context/next-step.js.map +0 -1
  190. package/dist/tools/context/restore.js +0 -34
  191. package/dist/tools/context/restore.js.map +0 -1
  192. package/dist/tools/dashboard/aggregates.js +0 -37
  193. package/dist/tools/dashboard/aggregates.js.map +0 -1
  194. package/dist/tools/dashboard/cash-impact.js +0 -37
  195. package/dist/tools/dashboard/cash-impact.js.map +0 -1
  196. package/dist/tools/dashboard/match-rate.js +0 -37
  197. package/dist/tools/dashboard/match-rate.js.map +0 -1
  198. package/dist/tools/dashboard/metrics.js +0 -37
  199. package/dist/tools/dashboard/metrics.js.map +0 -1
  200. package/dist/tools/dashboard/sla.js +0 -34
  201. package/dist/tools/dashboard/sla.js.map +0 -1
  202. package/dist/tools/dashboard/source-breakdown.js +0 -37
  203. package/dist/tools/dashboard/source-breakdown.js.map +0 -1
  204. package/dist/tools/dashboard/volume.js +0 -37
  205. package/dist/tools/dashboard/volume.js.map +0 -1
  206. package/dist/tools/dispute/get.js +0 -27
  207. package/dist/tools/dispute/get.js.map +0 -1
  208. package/dist/tools/exception/delete-comment.js +0 -40
  209. package/dist/tools/exception/delete-comment.js.map +0 -1
  210. package/dist/tools/exception/get.js +0 -34
  211. package/dist/tools/exception/get.js.map +0 -1
  212. package/dist/tools/exception/list-comments.js +0 -35
  213. package/dist/tools/exception/list-comments.js.map +0 -1
  214. package/dist/tools/fee-rule/delete.js +0 -27
  215. package/dist/tools/fee-rule/delete.js.map +0 -1
  216. package/dist/tools/fee-rule/get.js +0 -27
  217. package/dist/tools/fee-rule/get.js.map +0 -1
  218. package/dist/tools/fee-schedule/delete.js +0 -32
  219. package/dist/tools/fee-schedule/delete.js.map +0 -1
  220. package/dist/tools/fee-schedule/get.js +0 -30
  221. package/dist/tools/fee-schedule/get.js.map +0 -1
  222. package/dist/tools/field-map/delete.js +0 -37
  223. package/dist/tools/field-map/delete.js.map +0 -1
  224. package/dist/tools/field-map/get.js +0 -43
  225. package/dist/tools/field-map/get.js.map +0 -1
  226. package/dist/tools/ingestion/job-errors-list.js +0 -45
  227. package/dist/tools/ingestion/job-errors-list.js.map +0 -1
  228. package/dist/tools/ingestion/job-get.js +0 -42
  229. package/dist/tools/ingestion/job-get.js.map +0 -1
  230. package/dist/tools/ingestion/transaction-ignore.js +0 -51
  231. package/dist/tools/ingestion/transaction-ignore.js.map +0 -1
  232. package/dist/tools/match-rule/create.js +0 -67
  233. package/dist/tools/match-rule/create.js.map +0 -1
  234. package/dist/tools/match-rule/delete.js +0 -35
  235. package/dist/tools/match-rule/delete.js.map +0 -1
  236. package/dist/tools/match-rule/get.js +0 -32
  237. package/dist/tools/match-rule/get.js.map +0 -1
  238. package/dist/tools/match-rule/reorder.js +0 -45
  239. package/dist/tools/match-rule/reorder.js.map +0 -1
  240. package/dist/tools/matching/start.js +0 -81
  241. package/dist/tools/matching/start.js.map +0 -1
  242. package/dist/tools/report/count-exceptions.js +0 -46
  243. package/dist/tools/report/count-exceptions.js.map +0 -1
  244. package/dist/tools/report/count-matched.js +0 -47
  245. package/dist/tools/report/count-matched.js.map +0 -1
  246. package/dist/tools/report/count-transactions.js +0 -45
  247. package/dist/tools/report/count-transactions.js.map +0 -1
  248. package/dist/tools/report/count-unmatched.js +0 -45
  249. package/dist/tools/report/count-unmatched.js.map +0 -1
  250. package/dist/tools/report/export-exceptions.js +0 -48
  251. package/dist/tools/report/export-exceptions.js.map +0 -1
  252. package/dist/tools/report/export-matched.js +0 -49
  253. package/dist/tools/report/export-matched.js.map +0 -1
  254. package/dist/tools/report/export-summary.js +0 -49
  255. package/dist/tools/report/export-summary.js.map +0 -1
  256. package/dist/tools/report/export-unmatched.js +0 -49
  257. package/dist/tools/report/export-unmatched.js.map +0 -1
  258. package/dist/tools/report/export-variance.js +0 -48
  259. package/dist/tools/report/export-variance.js.map +0 -1
  260. package/dist/tools/report/matched.js +0 -48
  261. package/dist/tools/report/matched.js.map +0 -1
  262. package/dist/tools/report/summary.js +0 -43
  263. package/dist/tools/report/summary.js.map +0 -1
  264. package/dist/tools/report/unmatched.js +0 -48
  265. package/dist/tools/report/unmatched.js.map +0 -1
  266. package/dist/tools/report/variance.js +0 -48
  267. package/dist/tools/report/variance.js.map +0 -1
  268. package/dist/tools/source/archive.js +0 -46
  269. package/dist/tools/source/archive.js.map +0 -1
  270. package/dist/tools/source/get.js +0 -57
  271. package/dist/tools/source/get.js.map +0 -1
  272. package/dist/tools/source/restore.js +0 -39
  273. package/dist/tools/source/restore.js.map +0 -1
@@ -7,8 +7,12 @@
7
7
  // tenant-scoped by the relayed token; contextId is a routing path param, not a
8
8
  // tenant field, and no tenant field is accepted.
9
9
  import { z } from 'zod';
10
+ import { nextCursor, pageLimit } from '../input-fields.js';
11
+ import { queryHandler } from '../query-handler.js';
12
+ import { pickQuery } from '../request-fields.js';
10
13
  import { SOURCE_TYPES } from './create.js';
11
- import { contextSourcesPath, dispatchSource } from './shared.js';
14
+ import { dispatchToolRequest } from '../shared-dispatch.js';
15
+ import { contextSourcesPath } from './shared.js';
12
16
  /** Zod raw shape for `source_list` input — contextId path + type filter + pagination. */
13
17
  export const listSourcesInputShape = {
14
18
  contextId: z
@@ -20,32 +24,12 @@ export const listSourcesInputShape = {
20
24
  .enum(SOURCE_TYPES)
21
25
  .optional()
22
26
  .describe('Optional filter by source type (LEDGER|BANK|GATEWAY|CUSTOM|FETCHER).'),
23
- limit: z
24
- .number()
25
- .int()
26
- .min(1)
27
- .max(200)
28
- .optional()
29
- .describe('Maximum number of records to return (1–200, default 20).'),
30
- cursor: z
31
- .string()
32
- .optional()
33
- .describe('Opaque pagination cursor from a prior response. Re-call with the ' +
34
- 'returned nextCursor to page forward (there is no auto-pagination).'),
27
+ limit: pageLimit,
28
+ cursor: nextCursor,
35
29
  };
36
30
  /** Build the list query, omitting unset knobs so the request stays minimal. */
37
31
  function buildListQuery(args) {
38
- const query = {};
39
- if (args.type !== undefined) {
40
- query.type = args.type;
41
- }
42
- if (args.limit !== undefined) {
43
- query.limit = args.limit;
44
- }
45
- if (args.cursor !== undefined) {
46
- query.cursor = args.cursor;
47
- }
48
- return Object.keys(query).length > 0 ? query : undefined;
32
+ return pickQuery(args, ['type', 'limit', 'cursor']);
49
33
  }
50
34
  /**
51
35
  * Register `source_list`. Passes type/limit/cursor through and returns matcher's
@@ -60,13 +44,6 @@ export function registerSourceListTool(server) {
60
44
  'The response carries { items, nextCursor } — paginate by re-calling ' +
61
45
  'with the returned nextCursor. No tenant field is accepted.',
62
46
  inputSchema: listSourcesInputShape,
63
- }, async (args, extra) => {
64
- const query = buildListQuery(args);
65
- return dispatchSource({
66
- method: 'GET',
67
- path: contextSourcesPath(args.contextId),
68
- ...(query !== undefined ? { query } : {}),
69
- }, extra);
70
- });
47
+ }, queryHandler(buildListQuery, (args) => contextSourcesPath(args.contextId), dispatchToolRequest));
71
48
  }
72
49
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/tools/source/list.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,6EAA6E;AAC7E,wEAAwE;AACxE,+EAA+E;AAC/E,iDAAiD;AAEjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEhE,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,2EAA2E;QACzE,4BAA4B,CAC/B;IACH,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,YAAY,CAAC;SAClB,QAAQ,EAAE;SACV,QAAQ,CACP,sEAAsE,CACvE;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,0DAA0D,CAAC;IACvE,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,mEAAmE;QACjE,oEAAoE,CACvE;CACJ,CAAA;AAKD,+EAA+E;AAC/E,SAAS,cAAc,CAAC,IAAsB;IAC5C,MAAM,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AAmB,CACpB,CACF,CAAA;AACH,CAAC"}
@@ -4,18 +4,17 @@
4
4
  // fee-rules' hybrid path, EVERY source op is fully context-nested: create/list
5
5
  // hang off /v1/contexts/{contextId}/sources and get/update/delete off
6
6
  // /v1/contexts/{contextId}/sources/{sourceId} — single-resource ops KEEP the
7
- // contextId. This module factors the two path helpers plus the relay boilerplate
8
- // exactly once so the five tools stay thin (just "build the request") and so
9
- // curated + generic surfaces map matcher errors through the identical path
10
- // (toToolError).
7
+ // contextId. This module holds the two path helpers and nothing else, factored
8
+ // exactly once so the three table rows in index.ts and the three tools that
9
+ // keep their own file address the same URLs. The relay itself lives in
10
+ // shared-dispatch.ts, so curated and generic surfaces map matcher errors
11
+ // through the identical path (toToolError).
11
12
  //
12
13
  // Security: the bearer token is never read here directly — requireMatcherClient
13
14
  // owns the request-scoped relay and fails closed when no usable credential was
14
15
  // provided. The contextId path param is a routing identifier (matcher validates
15
16
  // the context belongs to the relayed token's tenant); no tenant identifier is
16
17
  // ever read or injected, and no source tool input carries one.
17
- import { requireMatcherClient, UnauthenticatedError, } from '../../auth/request-token.js';
18
- import { isMatcherApiError, toToolError } from '../tool-error.js';
19
18
  /** Build the context-scoped sources collection path (create/list). */
20
19
  export function contextSourcesPath(contextId) {
21
20
  return `/v1/contexts/${encodeURIComponent(contextId)}/sources`;
@@ -24,40 +23,4 @@ export function contextSourcesPath(contextId) {
24
23
  export function contextSourcePath(contextId, sourceId) {
25
24
  return `${contextSourcesPath(contextId)}/${encodeURIComponent(sourceId)}`;
26
25
  }
27
- /**
28
- * Run one assembled request through the relay: fail-closed auth, dispatch, and
29
- * RFC 9457 → tool-error mapping — identical to the generic invoke's dispatch so
30
- * both surfaces produce the same structured error shape.
31
- *
32
- * `clientFor` is injectable for tests; production callers pass nothing and get
33
- * the request-scoped, fail-closed `requireMatcherClient`.
34
- */
35
- export async function dispatchSource(request, extra, clientFor = requireMatcherClient) {
36
- let client;
37
- try {
38
- // Fail-closed on a missing / empty / non-Bearer credential.
39
- client = clientFor(extra);
40
- }
41
- catch (err) {
42
- if (err instanceof UnauthenticatedError) {
43
- return { isError: true, content: [{ type: 'text', text: err.message }] };
44
- }
45
- throw err;
46
- }
47
- try {
48
- const result = await client.request(request);
49
- // Success → matcher's JSON returned as-is (incl. pagination envelopes and
50
- // 204 → null for delete).
51
- return { content: [{ type: 'text', text: JSON.stringify(result ?? null) }] };
52
- }
53
- catch (err) {
54
- // RFC 9457 problem → the SHARED structured tool error (status/title/detail/
55
- // code preserved). A non-matcher error is a bug, not a matcher failure, and
56
- // is re-thrown rather than masqueraded as one.
57
- if (isMatcherApiError(err)) {
58
- return toToolError(err);
59
- }
60
- throw err;
61
- }
62
- }
63
26
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/source/shared.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,uEAAuE;AACvE,+EAA+E;AAC/E,sEAAsE;AACtE,6EAA6E;AAC7E,iFAAiF;AACjF,6EAA6E;AAC7E,2EAA2E;AAC3E,iBAAiB;AACjB,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,+DAA+D;AAI/D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEjE,sEAAsE;AACtE,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,OAAO,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,UAAU,CAAA;AAChE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,QAAgB;IACnE,OAAO,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,M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;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,+DAA+D;AAE/D,sEAAsE;AACtE,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAClD,OAAO,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,UAAU,CAAA;AAChE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,QAAgB;IACnE,OAAO,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3E,CAAC"}
@@ -6,15 +6,14 @@
6
6
  // single-resource ops); no tenant field is accepted (matcher scopes to the
7
7
  // relayed token's tenant).
8
8
  import { z } from 'zod';
9
- import { SOURCE_SIDES, SOURCE_TYPES } from './create.js';
10
- import { contextSourcePath, dispatchSource } from './shared.js';
9
+ import { contextRoutingId } from '../input-fields.js';
10
+ import { bodyWithout } from '../request-fields.js';
11
+ import { SOURCE_SIDES, SOURCE_TYPES, sourceConfigSchema } from './create.js';
12
+ import { dispatchToolRequest } from '../shared-dispatch.js';
13
+ import { contextSourcePath } from './shared.js';
11
14
  /** Zod raw shape for `source_update` input — path ids + optional body fields. */
12
15
  export const updateSourceInputShape = {
13
- contextId: z
14
- .string()
15
- .min(1)
16
- .describe('The reconciliation context id (UUID). Routing path param, not a tenant ' +
17
- 'field.'),
16
+ contextId: contextRoutingId,
18
17
  sourceId: z
19
18
  .string()
20
19
  .min(1)
@@ -33,38 +32,22 @@ export const updateSourceInputShape = {
33
32
  .enum(SOURCE_SIDES)
34
33
  .optional()
35
34
  .describe('Matching side this source feeds (LEFT|RIGHT).'),
36
- config: z
37
- .record(z.string(), z.unknown())
35
+ config: sourceConfigSchema
38
36
  .optional()
39
- .describe('Source-specific configuration object (validated server-side). ' +
40
- 'Reserved key duplicate_key: the ordered list of mapped fields that ' +
41
- 'make two rows the same row (any of external_id, amount, currency, ' +
42
- 'date, description, fee_amount, fee_currency); a config without it ' +
43
- 'deduplicates on external_id alone. Editing it governs later imports ' +
44
- 'only; rows already imported keep the key they were deduplicated ' +
45
- 'under, and duplicate_key_changed_at (server-set, read-only) records ' +
46
- 'the moment detection last changed meaning — this list changing, or ' +
47
- 'the field map remapping the column a declared field reads. ' +
48
- 'A source bound to an aggregator connection (reserved key ' +
49
- 'connection_config_name) cannot carry a duplicate key of its own — ' +
50
- 'the aggregator retracts a movement by naming its external id, so ' +
51
- 'that id has to stay the row identity; a config holding both is ' +
52
- 'refused, so drop duplicate_key or disconnect the aggregator first. ' +
53
- 'Reserved key duplicate_policy: what happens ' +
54
- 'to a row repeating that key — FLAG_AS_EXCEPTION (the default: the ' +
55
- 'repeat is kept out of the import and raised as a duplicate exception ' +
56
- 'on the row it repeated), KEEP_FIRST (dropped, nothing raised) or ' +
57
- 'REJECT (counted as an import error).'),
37
+ .describe('Source-specific configuration object. Sent whole: the config you supply ' +
38
+ 'REPLACES the stored one, so include the reserved keys you want to keep. ' +
39
+ 'The seven reserved keys are validated here AND server-side; any other key ' +
40
+ '(connector settings, connection_config_name for an aggregator-backed ' +
41
+ 'source) is passed through untouched. Editing duplicate_key governs later ' +
42
+ 'imports only — rows already imported keep the key they were deduplicated ' +
43
+ 'under, and the server stamps duplicate_key_changed_at itself.'),
58
44
  };
59
45
  /**
60
46
  * Build the PATCH body from the input minus the path-only ids. Only the fields
61
47
  * the caller actually set are sent — matcher treats absent fields as unchanged.
62
48
  */
63
49
  export function buildUpdateBody(args) {
64
- const { contextId: _contextId, sourceId: _sourceId, ...body } = args;
65
- void _contextId;
66
- void _sourceId;
67
- return body;
50
+ return bodyWithout(args, ['contextId', 'sourceId']);
68
51
  }
69
52
  /**
70
53
  * Register `source_update`. Splits the path ids from the body fields, dispatches
@@ -81,7 +64,7 @@ export function registerSourceUpdateTool(server) {
81
64
  'RFC 9457 error.',
82
65
  inputSchema: updateSourceInputShape,
83
66
  }, async (args, extra) => {
84
- return dispatchSource({
67
+ return dispatchToolRequest({
85
68
  method: 'PATCH',
86
69
  path: contextSourcePath(args.contextId, args.sourceId),
87
70
  body: buildUpdateBody(args),
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/tools/source/update.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,2BAA2B;AAE3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE/D,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,QAAQ,CACX;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,gDAAgD,CAAC;IAC7D,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,EAAE,CAAC;SACP,QAAQ,EAAE;SACV,QAAQ,CAAC,qDAAqD,CAAC;IAClE,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,YAAY,CAAC;SAClB,QAAQ,EAAE;SACV,QAAQ,CACP,iEAAiE,CAClE;IACH,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,YAAY,CAAC;SAClB,QAAQ,EAAE;SACV,QAAQ,CAAC,+CAA+C,CAAC;IAC5D,MAAM,EAAE,CAAC;SACN,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,QAAQ,EAAE;SACV,QAAQ,CACP,gEAAgE;QAC9D,qEAAqE;QACrE,oEAAoE;QACpE,oEAAoE;QACpE,sEAAsE;QACtE,kEAAkE;QAClE,sEAAsE;QACtE,qEAAqE;QACrE,6DAA6D;QAC7D,2DAA2D;QAC3D,oEAAoE;QACpE,mEAAmE;QACnE,iEAAiE;QACjE,qEAAqE;QACrE,8CAA8C;QAC9C,oEAAoE;QACpE,uEAAuE;QACvE,mEAAmE;QACnE,sCAAsC,CACzC;CACJ,CAAA;AAOD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAuB;IAEvB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;IACpE,KAAK,UAAU,CAAA;IACf,KAAK,SAAS,CAAA;IACd,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAiB;IACxD,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,WAAW,EACT,0EAA0E;YAC1E,yEAAyE;YACzE,kEAAkE;YAClE,sEAAsE;YACtE,wEAAwE;YACxE,iBAAiB;QACnB,WAAW,EAAE,sBAAsB;KACpC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,cAAc,CACnB;YACE,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;YACtD,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;SAC5B,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/tools/source/update.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,2BAA2B;AAE3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE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;QACE,WAAW,EACT,0EAA0E;YAC1E,yEAAyE;YACzE,kEAAkE;YAClE,sEAAsE;YACtE,wEAAwE;YACxE,iBAAiB;QACnB,WAAW,EAAE,sBAAsB;KACpC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,mBAAmB,CACxB;YACE,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;YACtD,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;SAC5B,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -14,8 +14,7 @@
14
14
  //
15
15
  // There is no input at all: the tenant comes from the relayed token's claims, so
16
16
  // there is nothing for a caller to pass — and nothing that could be spoofed.
17
- import { requireMatcherClient, UnauthenticatedError, } from '../../auth/request-token.js';
18
- import { isMatcherApiError, toToolError } from '../tool-error.js';
17
+ import { dispatchToolRequest } from '../shared-dispatch.js';
19
18
  /** The billing read path (tenant-scoped; tenant resolved from the token, not the path). */
20
19
  const WORKSPACE_BILLING_PATH = '/v1/workspace/billing';
21
20
  /**
@@ -51,7 +50,10 @@ export function usedPercent(body) {
51
50
  }
52
51
  /**
53
52
  * Register `workspace_usage`. Reads the caller's own commercial state through the
54
- * fail-closed relay and returns it verbatim plus `usedPercent`. A matcher error
53
+ * SHARED fail-closed relay — the additive percent rides its success-body
54
+ * transform, so the credential refusal and the RFC 9457 mapping are the shared
55
+ * ones rather than a local copy (that copy was BUG-06) — and returns the body
56
+ * verbatim plus `usedPercent`. A matcher error
55
57
  * (404 for a tenant with no self-serve workspace, 403 MTCH-0021 for a
56
58
  * billing-suspended one) surfaces via the shared toToolError, so the model can
57
59
  * branch on `status`/`code` exactly as it does on every other tool.
@@ -83,43 +85,27 @@ export function registerWorkspaceUsageTool(server) {
83
85
  'incurred that the credit did not cover — what the workspace OWES). ' +
84
86
  'The second is a receivable, not a negative balance: a new billing ' +
85
87
  'period does not clear it, so never tell a customer a rollover settled ' +
86
- 'it, and never report it as a credit.',
87
- }, async (extra) => {
88
- let client;
89
- try {
90
- // Fail-closed on a missing / empty / non-Bearer credential.
91
- client = requireMatcherClient(extra);
92
- }
93
- catch (err) {
94
- if (err instanceof UnauthenticatedError) {
95
- return { isError: true, content: [{ type: 'text', text: err.message }] };
96
- }
97
- throw err;
98
- }
99
- try {
100
- const body = await client.request({
101
- method: 'GET',
102
- path: WORKSPACE_BILLING_PATH,
103
- });
104
- // Spread, don't rebuild: the backend's fields are relayed unchanged and
105
- // the derived percent is purely additive.
106
- return {
107
- content: [
108
- {
109
- type: 'text',
110
- text: JSON.stringify({ ...body, usedPercent: usedPercent(body) }),
111
- },
112
- ],
113
- };
114
- }
115
- catch (err) {
116
- // RFC 9457 problem → the SHARED structured tool error. A non-matcher
117
- // error is a bug, not a matcher failure, and is re-thrown.
118
- if (isMatcherApiError(err)) {
119
- return toToolError(err);
120
- }
121
- throw err;
122
- }
123
- });
88
+ 'it, and never report it as a credit. ' +
89
+ 'When a commercial ACTION on this workspace is refused, the refusal ' +
90
+ 'carries a code from onboarding\'s own MTCH-08xx family and the code is ' +
91
+ 'the answer, not the sentence: 0801 no payment processor is configured ' +
92
+ '(retrying never clears it) vs 0802 the processor could not be asked ' +
93
+ '(retry) — both arrive as a 503 whose detail is scrubbed to "internal ' +
94
+ 'error"; 0803 a subscription the processor can still bill; 0804 only ' +
95
+ 'the enterprise plan is operator-assigned; 0805 the billing status ' +
96
+ 'forbids the change; 0806 the plan is set by contract, so nothing ' +
97
+ 'self-serve applies; 0807 already subscribed; 0808 a checkout is open ' +
98
+ 'for a different plan or interval; 0809 a checkout is being opened ' +
99
+ 'right now; 0810 no billing account yet; 0811 a billing event id was ' +
100
+ 'replayed with different content; 0812 the workspace exists and may be ' +
101
+ 'the caller\'s own; 0813 the name belongs to another account; 0814 the ' +
102
+ 'plan is not sold self-serve; 0815 the credit amount is out of range.',
103
+ }, async (extra) => dispatchToolRequest({ method: 'GET', path: WORKSPACE_BILLING_PATH }, extra, undefined,
104
+ // Spread, don't rebuild: the backend's fields are relayed unchanged and
105
+ // the derived percent is purely additive.
106
+ (billing) => ({
107
+ ...billing,
108
+ usedPercent: usedPercent(billing),
109
+ })));
124
110
  }
125
111
  //# sourceMappingURL=usage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/tools/workspace/usage.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4DAA4D;AAC5D,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,6EAA6E;AAC7E,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,6EAA6E;AAI7E,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEjE,2FAA2F;AAC3F,MAAM,sBAAsB,GAAG,uBAAuB,CAAA;AAatD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CACzB,IAAsC;IAEtC,IAAI,IAAI,EAAE,aAAa,KAAK,UAAU,EAAE,CAAC;QACvC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAA;IAC/C,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QAC7E,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,qEAAqE;IACrE,kDAAkD;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,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,kDAAkD;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAClE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,WAAW,EACT,gEAAgE;YAChE,sEAAsE;YACtE,iEAAiE;YACjE,kEAAkE;YAClE,uEAAuE;YACvE,0DAA0D;YAC1D,wEAAwE;YACxE,uEAAuE;YACvE,yEAAyE;YACzE,uEAAuE;YACvE,oEAAoE;YACpE,yEAAyE;YACzE,iBAAiB;YACjB,wEAAwE;YACxE,sEAAsE;YACtE,sEAAsE;YACtE,kEAAkE;YAClE,yEAAyE;YACzE,gEAAgE;YAChE,sEAAsE;YACtE,mEAAmE;YACnE,mEAAmE;YACnE,qEAAqE;YACrE,oEAAoE;YACpE,wEAAwE;YACxE,uCAAuC;YACvC,qEAAqE;YACrE,yEAAyE;YACzE,wEAAwE;YACxE,sEAAsE;YACtE,uEAAuE;YACvE,sEAAsE;YACtE,oEAAoE;YACpE,mEAAmE;YACnE,uEAAuE;YACvE,oEAAoE;YACpE,sEAAsE;YACtE,wEAAwE;YACxE,wEAAwE;YACxE,sEAAsE;KACzE,EACD,KAAK,EAAE,KAAK,EAAE,EAAE,CACd,mBAAmB,CACjB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,EAAE,EAC/C,KAAK,EACL,SAAS;IACT,wEAAwE;IACxE,0CAA0C;IAC1C,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACZ,GAAI,OAA4C;QAChD,WAAW,EAAE,WAAW,CAAC,OAA2C,CAAC;KACtE,CAAC,CACH,CACJ,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerianstudio/matcher-mcp",
3
- "version": "5.0.0-beta.13",
3
+ "version": "5.0.0-beta.131",
4
4
  "type": "module",
5
5
  "description": "Model Context Protocol server for the Matcher reconciliation engine",
6
6
  "license": "Apache-2.0",
@@ -37,8 +37,8 @@
37
37
  "vendor-spec": "node scripts/vendor-spec.mjs",
38
38
  "predev": "node scripts/vendor-spec.mjs",
39
39
  "dev": "node --watch --experimental-strip-types src/server.ts",
40
- "prebuild": "node scripts/vendor-spec.mjs",
41
- "build": "tsc",
40
+ "prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && node scripts/vendor-spec.mjs",
41
+ "build": "tsc -p tsconfig.build.json && node scripts/check-dist-clean.mjs",
42
42
  "postbuild": "node scripts/vendor-spec.mjs",
43
43
  "typecheck": "tsc --noEmit",
44
44
  "pretest": "node scripts/vendor-spec.mjs",
@@ -66,6 +66,6 @@
66
66
  "eslint": "^10.4.1",
67
67
  "typescript": "^6.0.2",
68
68
  "typescript-eslint": "^8.60.1",
69
- "vitest": "^4.1.5"
69
+ "vitest": "^4.1.11"
70
70
  }
71
71
  }
@@ -1,37 +0,0 @@
1
- // `context_archive` — curated POST /v1/contexts/{contextId}/archive.
2
- //
3
- // Soft-deletes a reconciliation context: it flips to ARCHIVED in place and its
4
- // reconciled financial history is never erased. Archived contexts drop out of
5
- // the default listing but the name stays reserved until restored (the F12 trap
6
- // made explicit — you cannot create a new context reusing an archived name).
7
- // contextId is the only input (a UUID path param); no tenant field is accepted
8
- // (contextId is a routing param, not a tenant identifier).
9
- import { z } from 'zod';
10
- import { contextPath, dispatchContext } from './shared.js';
11
- /** Zod raw shape for `context_archive` input — just the context id. */
12
- export const archiveContextInputShape = {
13
- contextId: z
14
- .string()
15
- .min(1)
16
- .describe('The reconciliation context id (UUID) to archive.'),
17
- };
18
- /**
19
- * Register `context_archive`. Substitutes the id into the path and dispatches a
20
- * POST through the shared fail-closed relay; a matcher error surfaces via the
21
- * shared toToolError.
22
- */
23
- export function registerContextArchiveTool(server) {
24
- server.registerTool('context_archive', {
25
- description: 'Archive (soft-delete) a reconciliation context by id (UUID). Archiving ' +
26
- 'flips the context to ARCHIVED in place — it never erases the reconciled ' +
27
- 'financial history (an archived context with children is valid) — and ' +
28
- 'excludes it from the default listing. The archived name stays reserved ' +
29
- 'until you restore it, so you cannot create a new context reusing that ' +
30
- 'name. Provide only contextId; no tenant field is accepted. Returns no ' +
31
- 'content (204), or a structured RFC 9457 error.',
32
- inputSchema: archiveContextInputShape,
33
- }, async (args, extra) => {
34
- return dispatchContext({ method: 'POST', path: `${contextPath(args.contextId)}/archive` }, extra);
35
- });
36
- }
37
- //# sourceMappingURL=archive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../../src/tools/context/archive.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,2DAA2D;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,kDAAkD,CAAC;CAChE,CAAA;AAOD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,WAAW,EACT,yEAAyE;YACzE,0EAA0E;YAC1E,uEAAuE;YACvE,yEAAyE;YACzE,wEAAwE;YACxE,wEAAwE;YACxE,gDAAgD;QAClD,WAAW,EAAE,wBAAwB;KACtC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,eAAe,CACpB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAClE,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -1,31 +0,0 @@
1
- // `context_get` — curated GET /v1/contexts/{contextId}.
2
- //
3
- // Reads one reconciliation context by id. contextId is the only input (a UUID
4
- // path param). The context must belong to the relayed token's tenant — matcher
5
- // enforces that; no tenant field is accepted (contextId is a routing param, not
6
- // a tenant identifier).
7
- import { z } from 'zod';
8
- import { contextPath, dispatchContext } from './shared.js';
9
- /** Zod raw shape for `context_get` input — just the context id. */
10
- export const getContextInputShape = {
11
- contextId: z
12
- .string()
13
- .min(1)
14
- .describe('The reconciliation context id (UUID) to fetch.'),
15
- };
16
- /**
17
- * Register `context_get`. Substitutes the id into the path and dispatches a GET
18
- * through the shared fail-closed relay; a matcher error (e.g. 404) surfaces via
19
- * the shared toToolError.
20
- */
21
- export function registerContextGetTool(server) {
22
- server.registerTool('context_get', {
23
- description: 'Fetch a single reconciliation context by id (UUID). The context must ' +
24
- "belong to your token's tenant. Returns the context, or a structured " +
25
- 'RFC 9457 error (e.g. 404 if it does not exist or is not yours).',
26
- inputSchema: getContextInputShape,
27
- }, async (args, extra) => {
28
- return dispatchContext({ method: 'GET', path: contextPath(args.contextId) }, extra);
29
- });
30
- }
31
- //# sourceMappingURL=get.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/tools/context/get.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,wBAAwB;AAExB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,gDAAgD,CAAC;CAC9D,CAAA;AAKD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,WAAW,EACT,uEAAuE;YACvE,sEAAsE;YACtE,iEAAiE;QACnE,WAAW,EAAE,oBAAoB;KAClC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,eAAe,CACpB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EACpD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -1,99 +0,0 @@
1
- // `next_step` — curated GET /v1/contexts/{contextId}/setup-progress projected
2
- // to the ONE thing an operator-driving LLM needs to advance setup:
3
- // `{ ready, next, thenCall }`.
4
- //
5
- // `context_setup_progress` already relays the FULL setup-progress blob (counts,
6
- // last-run, readiness, next), so this tool's value is NOT "make `next` visible"
7
- // — it is the focused shape plus the auto-conduction (`thenCall`) that tells the
8
- // caller to loop. The auto-conduction is the only agent-specific knowledge here
9
- // and it is STATIC (no per-context values are ever invented): the deterministic
10
- // `next` action itself comes verbatim from the backend readiness gate (Phase 1).
11
- //
12
- // Because it projects, it does NOT use the shared dispatchContext stringify-
13
- // everything path; it resolves the client the same fail-closed way
14
- // (requireMatcherClient) and maps a matcher error through the SAME toToolError as
15
- // its siblings. contextId is the only input (a UUID path param); no tenant field
16
- // is accepted (matcher scopes to the relayed token's tenant).
17
- import { z } from 'zod';
18
- import { requireMatcherClient, UnauthenticatedError, } from '../../auth/request-token.js';
19
- import { isMatcherApiError, toToolError } from '../tool-error.js';
20
- import { contextSetupProgressPath } from './setup-progress.js';
21
- /**
22
- * Static auto-conduction string returned alongside a non-null `next`. It never
23
- * carries per-context values — just the loop instruction. The concrete action to
24
- * take is the backend `next`, not this string.
25
- */
26
- export const NEXT_STEP_CONDUCTION = 'After applying this action, call next_step again with the same contextId to ' +
27
- 'get the following step. Repeat until ready is true.';
28
- /** Zod raw shape for `next_step` input — just the context id. */
29
- export const nextStepInputShape = {
30
- contextId: z
31
- .string()
32
- .min(1)
33
- .describe('The reconciliation context id (UUID) to get the next setup step for.'),
34
- };
35
- /**
36
- * Register `next_step`. Fetches setup-progress through the fail-closed relay and
37
- * projects it to `{ ready, next, thenCall }`. A matcher error (e.g. 404) surfaces
38
- * via the shared toToolError; a missing credential fails closed identically to
39
- * the sibling context tools.
40
- */
41
- export function registerContextNextStepTool(server) {
42
- server.registerTool('next_step', {
43
- description: 'Get the deterministic next setup action for a context, projected from ' +
44
- 'its readiness gate. Provide contextId (UUID path param, not a tenant ' +
45
- 'field). Returns { ready, next, thenCall }: ready is true only when the ' +
46
- 'context satisfies every activation requirement; next is the exact ' +
47
- 'action to take (requirementId — one of the FIVE public ' +
48
- 'context.activation.requirement.* identifiers: left-source, ' +
49
- 'right-source, source-mapping, match-rule, fee-rule; the sixth, ' +
50
- 'context.activation.requirement.unknown, never reaches next — the ' +
51
- "backend returns a null next for an unmapped slug — it appears only in " +
52
- 'context_setup_progress readiness.missing[]; operationId, method, ' +
53
- 'path, requiredFields — field NAMES only, never values; you supply the ' +
54
- 'values), or null when ready; thenCall instructs you to apply next and ' +
55
- 'call next_step again with the same contextId, repeating until ready is ' +
56
- 'true (null when ready). Prefer this over context_setup_progress when ' +
57
- 'you just need the next action to advance setup. Returns a structured ' +
58
- 'RFC 9457 error on failure (e.g. 404 if the context does not exist or ' +
59
- 'is not yours).',
60
- inputSchema: nextStepInputShape,
61
- }, async (args, extra) => {
62
- let client;
63
- try {
64
- // Fail-closed on a missing / empty / non-Bearer credential.
65
- client = requireMatcherClient(extra);
66
- }
67
- catch (err) {
68
- if (err instanceof UnauthenticatedError) {
69
- return { isError: true, content: [{ type: 'text', text: err.message }] };
70
- }
71
- throw err;
72
- }
73
- try {
74
- const body = await client.request({
75
- method: 'GET',
76
- path: contextSetupProgressPath(args.contextId),
77
- });
78
- // Nil-safe projection: a malformed body (missing readiness) defaults to
79
- // not-ready rather than throwing. `next` is relayed verbatim.
80
- const ready = body?.readiness?.ready ?? false;
81
- const next = body?.next ?? null;
82
- const thenCall = next ? NEXT_STEP_CONDUCTION : null;
83
- return {
84
- content: [
85
- { type: 'text', text: JSON.stringify({ ready, next, thenCall }) },
86
- ],
87
- };
88
- }
89
- catch (err) {
90
- // RFC 9457 problem → the SHARED structured tool error. A non-matcher
91
- // error is a bug, not a matcher failure, and is re-thrown.
92
- if (isMatcherApiError(err)) {
93
- return toToolError(err);
94
- }
95
- throw err;
96
- }
97
- });
98
- }
99
- //# sourceMappingURL=next-step.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-step.js","sourceRoot":"","sources":["../../../src/tools/context/next-step.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mEAAmE;AACnE,+BAA+B;AAC/B,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,EAAE;AACF,6EAA6E;AAC7E,mEAAmE;AACnE,kFAAkF;AAClF,iFAAiF;AACjF,8DAA8D;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,8EAA8E;IAC9E,qDAAqD,CAAA;AAEvD,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,sEAAsE,CAAC;CAC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CAAC,IAAI,CAAA;YACnD,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE;iBAClE;aACF,CAAA;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,qEAAqE;YACrE,2DAA2D;YAC3D,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAA;YACzB,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -1,34 +0,0 @@
1
- // `context_restore` — curated POST /v1/contexts/{contextId}/restore.
2
- //
3
- // Reverses an archive: it returns the context to DRAFT so it can be re-validated
4
- // and re-activated. Restoring never auto-resumes matching, and restoring a
5
- // context that is not archived is rejected with a 409 invalid-state. contextId
6
- // is the only input (a UUID path param); no tenant field is accepted (contextId
7
- // is a routing param, not a tenant identifier).
8
- import { z } from 'zod';
9
- import { contextPath, dispatchContext } from './shared.js';
10
- /** Zod raw shape for `context_restore` input — just the context id. */
11
- export const restoreContextInputShape = {
12
- contextId: z
13
- .string()
14
- .min(1)
15
- .describe('The archived reconciliation context id (UUID) to restore.'),
16
- };
17
- /**
18
- * Register `context_restore`. Substitutes the id into the path and dispatches a
19
- * POST through the shared fail-closed relay; a matcher error surfaces via the
20
- * shared toToolError.
21
- */
22
- export function registerContextRestoreTool(server) {
23
- server.registerTool('context_restore', {
24
- description: 'Restore an archived reconciliation context by id (UUID) back to DRAFT ' +
25
- 'so it can be re-validated and re-activated. Restoring never auto-resumes ' +
26
- 'matching. Restoring a context that is not archived returns a 409 ' +
27
- 'invalid-state. Provide only contextId; no tenant field is accepted. ' +
28
- 'Returns no content (204), or a structured RFC 9457 error.',
29
- inputSchema: restoreContextInputShape,
30
- }, async (args, extra) => {
31
- return dispatchContext({ method: 'POST', path: `${contextPath(args.contextId)}/restore` }, extra);
32
- });
33
- }
34
- //# sourceMappingURL=restore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/tools/context/restore.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,iFAAiF;AACjF,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,gDAAgD;AAEhD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,2DAA2D,CAAC;CACzE,CAAA;AAOD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAC1D,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,WAAW,EACT,wEAAwE;YACxE,2EAA2E;YAC3E,mEAAmE;YACnE,sEAAsE;YACtE,2DAA2D;QAC7D,WAAW,EAAE,wBAAwB;KACtC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,eAAe,CACpB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAClE,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}