@lerianstudio/matcher-mcp 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +281 -0
  3. package/dist/auth/request-token.js +117 -0
  4. package/dist/auth/request-token.js.map +1 -0
  5. package/dist/config.js +95 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/matcher/client.js +168 -0
  8. package/dist/matcher/client.js.map +1 -0
  9. package/dist/observability/otel.js +223 -0
  10. package/dist/observability/otel.js.map +1 -0
  11. package/dist/server.js +245 -0
  12. package/dist/server.js.map +1 -0
  13. package/dist/spec/curated-operations.js +145 -0
  14. package/dist/spec/curated-operations.js.map +1 -0
  15. package/dist/spec/index.js +155 -0
  16. package/dist/spec/index.js.map +1 -0
  17. package/dist/spec/load.js +76 -0
  18. package/dist/spec/load.js.map +1 -0
  19. package/dist/spec/openapi.yaml +15217 -0
  20. package/dist/tools/context/create.js +100 -0
  21. package/dist/tools/context/create.js.map +1 -0
  22. package/dist/tools/context/get.js +31 -0
  23. package/dist/tools/context/get.js.map +1 -0
  24. package/dist/tools/context/index.js +21 -0
  25. package/dist/tools/context/index.js.map +1 -0
  26. package/dist/tools/context/list.js +78 -0
  27. package/dist/tools/context/list.js.map +1 -0
  28. package/dist/tools/context/shared.js +61 -0
  29. package/dist/tools/context/shared.js.map +1 -0
  30. package/dist/tools/context/update.js +105 -0
  31. package/dist/tools/context/update.js.map +1 -0
  32. package/dist/tools/dashboard/aggregates.js +34 -0
  33. package/dist/tools/dashboard/aggregates.js.map +1 -0
  34. package/dist/tools/dashboard/cash-impact.js +36 -0
  35. package/dist/tools/dashboard/cash-impact.js.map +1 -0
  36. package/dist/tools/dashboard/index.js +27 -0
  37. package/dist/tools/dashboard/index.js.map +1 -0
  38. package/dist/tools/dashboard/match-rate.js +35 -0
  39. package/dist/tools/dashboard/match-rate.js.map +1 -0
  40. package/dist/tools/dashboard/metrics.js +36 -0
  41. package/dist/tools/dashboard/metrics.js.map +1 -0
  42. package/dist/tools/dashboard/shared.js +122 -0
  43. package/dist/tools/dashboard/shared.js.map +1 -0
  44. package/dist/tools/dashboard/sla.js +33 -0
  45. package/dist/tools/dashboard/sla.js.map +1 -0
  46. package/dist/tools/dashboard/source-breakdown.js +36 -0
  47. package/dist/tools/dashboard/source-breakdown.js.map +1 -0
  48. package/dist/tools/dashboard/volume.js +35 -0
  49. package/dist/tools/dashboard/volume.js.map +1 -0
  50. package/dist/tools/dispute/close.js +49 -0
  51. package/dist/tools/dispute/close.js.map +1 -0
  52. package/dist/tools/dispute/get.js +27 -0
  53. package/dist/tools/dispute/get.js.map +1 -0
  54. package/dist/tools/dispute/index.js +17 -0
  55. package/dist/tools/dispute/index.js.map +1 -0
  56. package/dist/tools/dispute/list.js +137 -0
  57. package/dist/tools/dispute/list.js.map +1 -0
  58. package/dist/tools/dispute/shared.js +66 -0
  59. package/dist/tools/dispute/shared.js.map +1 -0
  60. package/dist/tools/dispute/submit-evidence.js +58 -0
  61. package/dist/tools/dispute/submit-evidence.js.map +1 -0
  62. package/dist/tools/exception/add-comment.js +50 -0
  63. package/dist/tools/exception/add-comment.js.map +1 -0
  64. package/dist/tools/exception/adjust-entry.js +71 -0
  65. package/dist/tools/exception/adjust-entry.js.map +1 -0
  66. package/dist/tools/exception/bulk-assign.js +47 -0
  67. package/dist/tools/exception/bulk-assign.js.map +1 -0
  68. package/dist/tools/exception/bulk-dispatch.js +69 -0
  69. package/dist/tools/exception/bulk-dispatch.js.map +1 -0
  70. package/dist/tools/exception/bulk-resolve.js +64 -0
  71. package/dist/tools/exception/bulk-resolve.js.map +1 -0
  72. package/dist/tools/exception/delete-comment.js +40 -0
  73. package/dist/tools/exception/delete-comment.js.map +1 -0
  74. package/dist/tools/exception/dispatch.js +64 -0
  75. package/dist/tools/exception/dispatch.js.map +1 -0
  76. package/dist/tools/exception/force-match.js +55 -0
  77. package/dist/tools/exception/force-match.js.map +1 -0
  78. package/dist/tools/exception/get.js +34 -0
  79. package/dist/tools/exception/get.js.map +1 -0
  80. package/dist/tools/exception/history.js +61 -0
  81. package/dist/tools/exception/history.js.map +1 -0
  82. package/dist/tools/exception/index.js +39 -0
  83. package/dist/tools/exception/index.js.map +1 -0
  84. package/dist/tools/exception/list-comments.js +35 -0
  85. package/dist/tools/exception/list-comments.js.map +1 -0
  86. package/dist/tools/exception/list.js +169 -0
  87. package/dist/tools/exception/list.js.map +1 -0
  88. package/dist/tools/exception/open-dispute.js +53 -0
  89. package/dist/tools/exception/open-dispute.js.map +1 -0
  90. package/dist/tools/exception/shared.js +98 -0
  91. package/dist/tools/exception/shared.js.map +1 -0
  92. package/dist/tools/fee-rule/create.js +106 -0
  93. package/dist/tools/fee-rule/create.js.map +1 -0
  94. package/dist/tools/fee-rule/delete.js +27 -0
  95. package/dist/tools/fee-rule/delete.js.map +1 -0
  96. package/dist/tools/fee-rule/get.js +27 -0
  97. package/dist/tools/fee-rule/get.js.map +1 -0
  98. package/dist/tools/fee-rule/index.js +21 -0
  99. package/dist/tools/fee-rule/index.js.map +1 -0
  100. package/dist/tools/fee-rule/list.js +64 -0
  101. package/dist/tools/fee-rule/list.js.map +1 -0
  102. package/dist/tools/fee-rule/shared.js +67 -0
  103. package/dist/tools/fee-rule/shared.js.map +1 -0
  104. package/dist/tools/fee-rule/update.js +70 -0
  105. package/dist/tools/fee-rule/update.js.map +1 -0
  106. package/dist/tools/fee-schedule/create.js +105 -0
  107. package/dist/tools/fee-schedule/create.js.map +1 -0
  108. package/dist/tools/fee-schedule/delete.js +32 -0
  109. package/dist/tools/fee-schedule/delete.js.map +1 -0
  110. package/dist/tools/fee-schedule/get.js +30 -0
  111. package/dist/tools/fee-schedule/get.js.map +1 -0
  112. package/dist/tools/fee-schedule/index.js +22 -0
  113. package/dist/tools/fee-schedule/index.js.map +1 -0
  114. package/dist/tools/fee-schedule/list.js +56 -0
  115. package/dist/tools/fee-schedule/list.js.map +1 -0
  116. package/dist/tools/fee-schedule/shared.js +58 -0
  117. package/dist/tools/fee-schedule/shared.js.map +1 -0
  118. package/dist/tools/fee-schedule/simulate.js +54 -0
  119. package/dist/tools/fee-schedule/simulate.js.map +1 -0
  120. package/dist/tools/fee-schedule/update.js +69 -0
  121. package/dist/tools/fee-schedule/update.js.map +1 -0
  122. package/dist/tools/generic/describe-operation.js +157 -0
  123. package/dist/tools/generic/describe-operation.js.map +1 -0
  124. package/dist/tools/generic/invoke.js +343 -0
  125. package/dist/tools/generic/invoke.js.map +1 -0
  126. package/dist/tools/generic/list-operations.js +73 -0
  127. package/dist/tools/generic/list-operations.js.map +1 -0
  128. package/dist/tools/ingestion/index.js +29 -0
  129. package/dist/tools/ingestion/index.js.map +1 -0
  130. package/dist/tools/ingestion/job-errors-list.js +45 -0
  131. package/dist/tools/ingestion/job-errors-list.js.map +1 -0
  132. package/dist/tools/ingestion/job-get.js +42 -0
  133. package/dist/tools/ingestion/job-get.js.map +1 -0
  134. package/dist/tools/ingestion/job-transactions-list.js +93 -0
  135. package/dist/tools/ingestion/job-transactions-list.js.map +1 -0
  136. package/dist/tools/ingestion/jobs-list.js +89 -0
  137. package/dist/tools/ingestion/jobs-list.js.map +1 -0
  138. package/dist/tools/ingestion/shared.js +84 -0
  139. package/dist/tools/ingestion/shared.js.map +1 -0
  140. package/dist/tools/ingestion/transaction-ignore.js +51 -0
  141. package/dist/tools/ingestion/transaction-ignore.js.map +1 -0
  142. package/dist/tools/ingestion/transactions-search.js +143 -0
  143. package/dist/tools/ingestion/transactions-search.js.map +1 -0
  144. package/dist/tools/match-rule/create.js +64 -0
  145. package/dist/tools/match-rule/create.js.map +1 -0
  146. package/dist/tools/match-rule/delete.js +35 -0
  147. package/dist/tools/match-rule/delete.js.map +1 -0
  148. package/dist/tools/match-rule/get.js +32 -0
  149. package/dist/tools/match-rule/get.js.map +1 -0
  150. package/dist/tools/match-rule/index.js +22 -0
  151. package/dist/tools/match-rule/index.js.map +1 -0
  152. package/dist/tools/match-rule/list.js +72 -0
  153. package/dist/tools/match-rule/list.js.map +1 -0
  154. package/dist/tools/match-rule/reorder.js +45 -0
  155. package/dist/tools/match-rule/reorder.js.map +1 -0
  156. package/dist/tools/match-rule/shared.js +71 -0
  157. package/dist/tools/match-rule/shared.js.map +1 -0
  158. package/dist/tools/match-rule/update.js +68 -0
  159. package/dist/tools/match-rule/update.js.map +1 -0
  160. package/dist/tools/matching/get.js +48 -0
  161. package/dist/tools/matching/get.js.map +1 -0
  162. package/dist/tools/matching/groups.js +98 -0
  163. package/dist/tools/matching/groups.js.map +1 -0
  164. package/dist/tools/matching/index.js +19 -0
  165. package/dist/tools/matching/index.js.map +1 -0
  166. package/dist/tools/matching/list.js +76 -0
  167. package/dist/tools/matching/list.js.map +1 -0
  168. package/dist/tools/matching/shared.js +77 -0
  169. package/dist/tools/matching/shared.js.map +1 -0
  170. package/dist/tools/matching/start.js +55 -0
  171. package/dist/tools/matching/start.js.map +1 -0
  172. package/dist/tools/report/count-exceptions.js +45 -0
  173. package/dist/tools/report/count-exceptions.js.map +1 -0
  174. package/dist/tools/report/count-matched.js +46 -0
  175. package/dist/tools/report/count-matched.js.map +1 -0
  176. package/dist/tools/report/count-transactions.js +44 -0
  177. package/dist/tools/report/count-transactions.js.map +1 -0
  178. package/dist/tools/report/count-unmatched.js +44 -0
  179. package/dist/tools/report/count-unmatched.js.map +1 -0
  180. package/dist/tools/report/export-exceptions.js +46 -0
  181. package/dist/tools/report/export-exceptions.js.map +1 -0
  182. package/dist/tools/report/export-matched.js +47 -0
  183. package/dist/tools/report/export-matched.js.map +1 -0
  184. package/dist/tools/report/export-summary.js +47 -0
  185. package/dist/tools/report/export-summary.js.map +1 -0
  186. package/dist/tools/report/export-unmatched.js +47 -0
  187. package/dist/tools/report/export-unmatched.js.map +1 -0
  188. package/dist/tools/report/export-variance.js +46 -0
  189. package/dist/tools/report/export-variance.js.map +1 -0
  190. package/dist/tools/report/index.js +40 -0
  191. package/dist/tools/report/index.js.map +1 -0
  192. package/dist/tools/report/matched.js +44 -0
  193. package/dist/tools/report/matched.js.map +1 -0
  194. package/dist/tools/report/shared.js +176 -0
  195. package/dist/tools/report/shared.js.map +1 -0
  196. package/dist/tools/report/summary.js +41 -0
  197. package/dist/tools/report/summary.js.map +1 -0
  198. package/dist/tools/report/unmatched.js +44 -0
  199. package/dist/tools/report/unmatched.js.map +1 -0
  200. package/dist/tools/report/variance.js +44 -0
  201. package/dist/tools/report/variance.js.map +1 -0
  202. package/dist/tools/source/create.js +84 -0
  203. package/dist/tools/source/create.js.map +1 -0
  204. package/dist/tools/source/get.js +41 -0
  205. package/dist/tools/source/get.js.map +1 -0
  206. package/dist/tools/source/index.js +22 -0
  207. package/dist/tools/source/index.js.map +1 -0
  208. package/dist/tools/source/list.js +72 -0
  209. package/dist/tools/source/list.js.map +1 -0
  210. package/dist/tools/source/shared.js +63 -0
  211. package/dist/tools/source/shared.js.map +1 -0
  212. package/dist/tools/source/update.js +73 -0
  213. package/dist/tools/source/update.js.map +1 -0
  214. package/dist/tools/tool-error.js +74 -0
  215. package/dist/tools/tool-error.js.map +1 -0
  216. package/dist/transport/body-limit.js +82 -0
  217. package/dist/transport/body-limit.js.map +1 -0
  218. package/dist/transport/http.js +154 -0
  219. package/dist/transport/http.js.map +1 -0
  220. package/package.json +68 -0
@@ -0,0 +1,73 @@
1
+ // `matcher_list_operations` — the first half of the generic discovery surface.
2
+ //
3
+ // A pure read over the in-memory operation index built at boot (spec/index.ts).
4
+ // It projects each indexed operation down to the lightweight shape the model
5
+ // scans to find what it wants: `{ operationId, method, path, summary, tag }`.
6
+ // An optional `tag` narrows to one of the 9 known matcher groups.
7
+ //
8
+ // No matcher call and no token: this describes the API contract, not tenant
9
+ // data, so it does NOT fail closed. (Contrast `matcher_invoke`, which relays the
10
+ // caller's token and fails closed without it.)
11
+ import { z } from 'zod';
12
+ /** The 9 known matcher tags (Huma operation groups), surfaced to the operator. */
13
+ export const KNOWN_TAGS = [
14
+ 'Configuration',
15
+ 'Reporting',
16
+ 'Exception',
17
+ 'Ingestion',
18
+ 'Discovery',
19
+ 'Matching',
20
+ 'Governance',
21
+ 'Export Jobs',
22
+ 'Health',
23
+ ];
24
+ /**
25
+ * Project the index to summaries, optionally filtered by tag. Insertion order of
26
+ * the index (spec declaration order) is preserved, so output is deterministic.
27
+ * Filtering is exact-match on the operation's first tag.
28
+ */
29
+ export function listOperations(index, input = {}) {
30
+ const rows = [];
31
+ for (const op of index.operations.values()) {
32
+ if (input.tag !== undefined && op.tag !== input.tag) {
33
+ continue;
34
+ }
35
+ rows.push({
36
+ operationId: op.operationId,
37
+ method: op.method,
38
+ path: op.path,
39
+ summary: op.summary,
40
+ tag: op.tag,
41
+ });
42
+ }
43
+ return rows;
44
+ }
45
+ /** Zod raw shape for the tool's input — `tag` is the only, optional, knob. */
46
+ export const listOperationsInputShape = {
47
+ tag: z
48
+ .string()
49
+ .optional()
50
+ .describe('Optional tag filter. Known tags: ' + KNOWN_TAGS.join(', ') + '.'),
51
+ };
52
+ /**
53
+ * Register `matcher_list_operations` on the given server, closed over the boot
54
+ * operation index. The handler is a pure read — it returns the projected rows as
55
+ * both structured JSON text and never touches the caller's token.
56
+ */
57
+ export function registerListOperationsTool(server, index) {
58
+ server.registerTool('matcher_list_operations', {
59
+ description: 'List matcher API operations as { operationId, method, path, summary, ' +
60
+ 'tag }. Optionally filter by tag (' +
61
+ KNOWN_TAGS.join(', ') +
62
+ '). Pure discovery over the embedded OpenAPI spec — no matcher call, no ' +
63
+ 'credential needed. Use it to find an operationId, then ' +
64
+ 'matcher_describe_operation to learn its exact shape.',
65
+ inputSchema: listOperationsInputShape,
66
+ }, (args) => {
67
+ const rows = listOperations(index, { tag: args.tag });
68
+ return {
69
+ content: [{ type: 'text', text: JSON.stringify(rows) }],
70
+ };
71
+ });
72
+ }
73
+ //# sourceMappingURL=list-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-operations.js","sourceRoot":"","sources":["../../../src/tools/generic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EACjB,KAAqB;IAErB,MAAM,CAAC,YAAY,CACjB,yBAAyB,EACzB;QACE,WAAW,EACT,uEAAuE;YACvE,mCAAmC;YACnC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;YACrB,yEAAyE;YACzE,yDAAyD;YACzD,sDAAsD;QACxD,WAAW,EAAE,wBAAwB;KACtC,EACD,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;QACrD,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;SACxD,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ // Curated ingestion vertical: six typed tools over the matcher import lifecycle
2
+ // of a reconciliation context — list jobs, get a job, list a job's per-row
3
+ // errors, list a job's transactions, search transactions, and ignore a
4
+ // transaction. Every op is fully context-nested under
5
+ // /v1/imports/contexts/{contextId}/... Each tool shares the fail-closed relay
6
+ // (shared.ts) and the RFC 9457 → tool-error mapping (toToolError) with the
7
+ // generic surface, so curated and generic map matcher errors identically. No
8
+ // tool carries a tenant field; contextId is a routing path param matcher
9
+ // validates against the relayed token's tenant.
10
+ //
11
+ // NOTE: uploadFile + extractDocument are intentionally NOT here — their
12
+ // multipart/form-data binary body cannot be expressed by a JSON tool, so they
13
+ // stay on the generic invoke surface.
14
+ import { registerIngestionJobErrorsListTool } from './job-errors-list.js';
15
+ import { registerIngestionJobGetTool } from './job-get.js';
16
+ import { registerIngestionJobTransactionsListTool } from './job-transactions-list.js';
17
+ import { registerIngestionJobsListTool } from './jobs-list.js';
18
+ import { registerIngestionTransactionIgnoreTool } from './transaction-ignore.js';
19
+ import { registerIngestionTransactionsSearchTool } from './transactions-search.js';
20
+ /** Register all six curated ingestion tools on the given server. */
21
+ export function registerIngestionTools(server) {
22
+ registerIngestionJobsListTool(server);
23
+ registerIngestionJobGetTool(server);
24
+ registerIngestionJobErrorsListTool(server);
25
+ registerIngestionJobTransactionsListTool(server);
26
+ registerIngestionTransactionsSearchTool(server);
27
+ registerIngestionTransactionIgnoreTool(server);
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/ingestion/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,uEAAuE;AACvE,sDAAsD;AACtD,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,gDAAgD;AAChD,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,sCAAsC;AAItC,OAAO,EAAE,kCAAkC,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,wCAAwC,EAAE,MAAM,4BAA4B,CAAA;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,sCAAsC,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAA;AAElF,oEAAoE;AACpE,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,6BAA6B,CAAC,MAAM,CAAC,CAAA;IACrC,2BAA2B,CAAC,MAAM,CAAC,CAAA;IACnC,kCAAkC,CAAC,MAAM,CAAC,CAAA;IAC1C,wCAAwC,CAAC,MAAM,CAAC,CAAA;IAChD,uCAAuC,CAAC,MAAM,CAAC,CAAA;IAC/C,sCAAsC,CAAC,MAAM,CAAC,CAAA;AAChD,CAAC"}
@@ -0,0 +1,45 @@
1
+ // `ingestion_job_errors_list` — curated GET
2
+ // /v1/imports/contexts/{contextId}/jobs/{jobId}/errors.
3
+ //
4
+ // Returns the stored per-row parse/normalization errors for an ingestion job
5
+ // (capped at 100 per job by matcher), with the uncapped failure total and
6
+ // truncation accounting, so a client can explain a failed or partially-failed
7
+ // import. No query params — just the two path ids. The job must belong to a
8
+ // context owned by the relayed token's tenant; no tenant field is accepted.
9
+ import { z } from 'zod';
10
+ import { contextJobErrorsPath, dispatchIngestion } from './shared.js';
11
+ /** Zod raw shape for `ingestion_job_errors_list` input — both path ids. */
12
+ export const listIngestionJobErrorsInputShape = {
13
+ contextId: z
14
+ .string()
15
+ .min(1)
16
+ .describe('The reconciliation context id (UUID). Routing path param, not a tenant ' +
17
+ 'field.'),
18
+ jobId: z
19
+ .string()
20
+ .min(1)
21
+ .describe('The ingestion job id (UUID) whose per-row errors to list.'),
22
+ };
23
+ /**
24
+ * Register `ingestion_job_errors_list`. Substitutes both ids into the path and
25
+ * dispatches a GET through the shared fail-closed relay; matcher returns the
26
+ * capped error list plus the uncapped total, and a matcher error surfaces via
27
+ * the shared toToolError.
28
+ */
29
+ export function registerIngestionJobErrorsListTool(server) {
30
+ server.registerTool('ingestion_job_errors_list', {
31
+ description: 'List the per-row parse/normalization errors for an ingestion job ' +
32
+ '(capped at 100 by matcher, with the uncapped failure total and ' +
33
+ 'truncation accounting) — use it to explain a failed or partially-failed ' +
34
+ 'import. Provide both contextId and jobId (path params; contextId is not ' +
35
+ 'a tenant field). No tenant field is accepted. Errors surface as ' +
36
+ 'structured RFC 9457 problems.',
37
+ inputSchema: listIngestionJobErrorsInputShape,
38
+ }, async (args, extra) => {
39
+ return dispatchIngestion({
40
+ method: 'GET',
41
+ path: contextJobErrorsPath(args.contextId, args.jobId),
42
+ }, extra);
43
+ });
44
+ }
45
+ //# sourceMappingURL=job-errors-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-errors-list.js","sourceRoot":"","sources":["../../../src/tools/ingestion/job-errors-list.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wDAAwD;AACxD,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAE5E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAErE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,QAAQ,CACX;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,2DAA2D,CAAC;CACzE,CAAA;AAOD;;;;;GAKG;AACH,MAAM,UAAU,kCAAkC,CAAC,MAAiB;IAClE,MAAM,CAAC,YAAY,CACjB,2BAA2B,EAC3B;QACE,WAAW,EACT,mEAAmE;YACnE,iEAAiE;YACjE,0EAA0E;YAC1E,0EAA0E;YAC1E,kEAAkE;YAClE,+BAA+B;QACjC,WAAW,EAAE,gCAAgC;KAC9C,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,iBAAiB,CACtB;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;SACvD,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ // `ingestion_job_get` — curated GET
2
+ // /v1/imports/contexts/{contextId}/jobs/{jobId}.
3
+ //
4
+ // Reads one ingestion job by id, including its progress metrics and error
5
+ // summary. Both contextId and jobId are path params; the job must belong to a
6
+ // context owned by the relayed token's tenant — matcher enforces that; no tenant
7
+ // field is accepted.
8
+ import { z } from 'zod';
9
+ import { contextJobPath, dispatchIngestion } from './shared.js';
10
+ /** Zod raw shape for `ingestion_job_get` input — both path ids. */
11
+ export const getIngestionJobInputShape = {
12
+ contextId: z
13
+ .string()
14
+ .min(1)
15
+ .describe('The reconciliation context id (UUID). Routing path param, not a tenant ' +
16
+ 'field.'),
17
+ jobId: z
18
+ .string()
19
+ .min(1)
20
+ .describe('The ingestion job id (UUID) to fetch.'),
21
+ };
22
+ /**
23
+ * Register `ingestion_job_get`. Substitutes both ids into the path and
24
+ * dispatches a GET through the shared fail-closed relay; a matcher error (e.g.
25
+ * 404) surfaces via the shared toToolError.
26
+ */
27
+ export function registerIngestionJobGetTool(server) {
28
+ server.registerTool('ingestion_job_get', {
29
+ description: 'Fetch a single ingestion job by id (UUID) within a context, including ' +
30
+ 'its status and progress metrics. Provide both contextId and jobId (path ' +
31
+ 'params; contextId is not a tenant field). The job must belong to your ' +
32
+ "token's tenant. Returns the job, or a structured RFC 9457 error (e.g. " +
33
+ '404 if it does not exist or is not yours).',
34
+ inputSchema: getIngestionJobInputShape,
35
+ }, async (args, extra) => {
36
+ return dispatchIngestion({
37
+ method: 'GET',
38
+ path: contextJobPath(args.contextId, args.jobId),
39
+ }, extra);
40
+ });
41
+ }
42
+ //# sourceMappingURL=job-get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-get.js","sourceRoot":"","sources":["../../../src/tools/ingestion/job-get.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,iDAAiD;AACjD,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,iFAAiF;AACjF,qBAAqB;AAErB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/D,mEAAmE;AACnE,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,QAAQ,CACX;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,uCAAuC,CAAC;CACrD,CAAA;AAOD;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,WAAW,EACT,wEAAwE;YACxE,0EAA0E;YAC1E,wEAAwE;YACxE,wEAAwE;YACxE,4CAA4C;QAC9C,WAAW,EAAE,yBAAyB;KACvC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,iBAAiB,CACtB;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;SACjD,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,93 @@
1
+ // `ingestion_job_transactions_list` — curated GET
2
+ // /v1/imports/contexts/{contextId}/jobs/{jobId}/transactions.
3
+ //
4
+ // Cursor-paginated list of the transactions a single ingestion job produced,
5
+ // optionally sorted. limit/cursor/sort_order/sort_by pass through untouched and
6
+ // matcher's { items, nextCursor, ... } envelope is returned as-is — no
7
+ // auto-pagination. Both contextId and jobId are path params; the job must belong
8
+ // to a context owned by the relayed token's tenant. No tenant field is accepted.
9
+ import { z } from 'zod';
10
+ import { contextJobTransactionsPath, dispatchIngestion } from './shared.js';
11
+ import { SORT_ORDERS } from './jobs-list.js';
12
+ /** Sort fields the matcher accepts for a job's transactions (spec enum). */
13
+ export const JOB_TRANSACTION_SORT_FIELDS = [
14
+ 'id',
15
+ 'created_at',
16
+ 'date',
17
+ 'status',
18
+ 'extraction_status',
19
+ ];
20
+ /** Zod raw shape for `ingestion_job_transactions_list` input — path ids + sort + pagination. */
21
+ export const listJobTransactionsInputShape = {
22
+ contextId: z
23
+ .string()
24
+ .min(1)
25
+ .describe('The reconciliation context id (UUID). Routing path param, not a tenant ' +
26
+ 'field.'),
27
+ jobId: z
28
+ .string()
29
+ .min(1)
30
+ .describe('The ingestion job id (UUID) whose transactions to list.'),
31
+ limit: z
32
+ .number()
33
+ .int()
34
+ .min(1)
35
+ .max(200)
36
+ .optional()
37
+ .describe('Maximum number of records to return (1–200, default 20).'),
38
+ cursor: z
39
+ .string()
40
+ .optional()
41
+ .describe('Opaque pagination cursor from a prior response. Re-call with the ' +
42
+ 'returned nextCursor to page forward (there is no auto-pagination).'),
43
+ sort_order: z
44
+ .enum(SORT_ORDERS)
45
+ .optional()
46
+ .describe('Sort order (asc|desc).'),
47
+ sort_by: z
48
+ .enum(JOB_TRANSACTION_SORT_FIELDS)
49
+ .optional()
50
+ .describe('Sort field (id|created_at|date|status|extraction_status).'),
51
+ };
52
+ /** Build the list query, omitting unset knobs so the request stays minimal. */
53
+ function buildListQuery(args) {
54
+ const query = {};
55
+ if (args.limit !== undefined) {
56
+ query.limit = args.limit;
57
+ }
58
+ if (args.cursor !== undefined) {
59
+ query.cursor = args.cursor;
60
+ }
61
+ if (args.sort_order !== undefined) {
62
+ query.sort_order = args.sort_order;
63
+ }
64
+ if (args.sort_by !== undefined) {
65
+ query.sort_by = args.sort_by;
66
+ }
67
+ return Object.keys(query).length > 0 ? query : undefined;
68
+ }
69
+ /**
70
+ * Register `ingestion_job_transactions_list`. Substitutes both ids into the
71
+ * path, passes limit/cursor/sort through, and returns matcher's pagination
72
+ * envelope verbatim; a matcher error surfaces via the shared toToolError.
73
+ */
74
+ export function registerIngestionJobTransactionsListTool(server) {
75
+ server.registerTool('ingestion_job_transactions_list', {
76
+ description: 'List the transactions extracted from a single ingestion job ' +
77
+ '(cursor-paginated). Provide contextId and jobId (path params; contextId ' +
78
+ 'is not a tenant field), and optionally limit (1–200), cursor, ' +
79
+ 'sort_order (asc|desc), and/or sort_by ' +
80
+ '(id|created_at|date|status|extraction_status). The response carries ' +
81
+ '{ items, nextCursor } — paginate by re-calling with the returned ' +
82
+ 'nextCursor. No tenant field is accepted.',
83
+ inputSchema: listJobTransactionsInputShape,
84
+ }, async (args, extra) => {
85
+ const query = buildListQuery(args);
86
+ return dispatchIngestion({
87
+ method: 'GET',
88
+ path: contextJobTransactionsPath(args.contextId, args.jobId),
89
+ ...(query !== undefined ? { query } : {}),
90
+ }, extra);
91
+ });
92
+ }
93
+ //# sourceMappingURL=job-transactions-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-transactions-list.js","sourceRoot":"","sources":["../../../src/tools/ingestion/job-transactions-list.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,uEAAuE;AACvE,iFAAiF;AACjF,iFAAiF;AAEjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI;IACJ,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,mBAAmB;CACX,CAAA;AAEV,gGAAgG;AAChG,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,QAAQ,CACX;IACH,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,yDAAyD,CAAC;IACtE,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;Q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EAAE,EAAE;QACpB,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,iBAAiB,CACtB;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,0BAA0B,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;YAC5D,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,89 @@
1
+ // `ingestion_jobs_list` — curated GET /v1/imports/contexts/{contextId}/jobs.
2
+ //
3
+ // Cursor-paginated list of a context's ingestion jobs (the parsed file imports),
4
+ // optionally sorted. limit/cursor/sort_order/sort_by pass through untouched and
5
+ // matcher's { items, nextCursor, ... } envelope is returned as-is — no
6
+ // auto-pagination (the model re-calls with the returned cursor). The list is
7
+ // implicitly tenant-scoped by the relayed token; contextId is a routing path
8
+ // param, not a tenant field, and no tenant field is accepted.
9
+ import { z } from 'zod';
10
+ import { contextJobsPath, dispatchIngestion } from './shared.js';
11
+ /** Sort fields the matcher accepts for the ingestion-jobs list (spec enum). */
12
+ export const JOB_SORT_FIELDS = [
13
+ 'id',
14
+ 'created_at',
15
+ 'started_at',
16
+ 'completed_at',
17
+ 'status',
18
+ ];
19
+ /** Sort orders the matcher accepts (spec enum). */
20
+ export const SORT_ORDERS = ['asc', 'desc'];
21
+ /** Zod raw shape for `ingestion_jobs_list` input — contextId path + sort + pagination. */
22
+ export const listIngestionJobsInputShape = {
23
+ contextId: z
24
+ .string()
25
+ .min(1)
26
+ .describe('The reconciliation context id (UUID) whose ingestion jobs to list. ' +
27
+ 'Routing path param, not a tenant field.'),
28
+ limit: z
29
+ .number()
30
+ .int()
31
+ .min(1)
32
+ .max(200)
33
+ .optional()
34
+ .describe('Maximum number of records to return (1–200, default 20).'),
35
+ cursor: z
36
+ .string()
37
+ .optional()
38
+ .describe('Opaque pagination cursor from a prior response. Re-call with the ' +
39
+ 'returned nextCursor to page forward (there is no auto-pagination).'),
40
+ sort_order: z
41
+ .enum(SORT_ORDERS)
42
+ .optional()
43
+ .describe('Sort order (asc|desc).'),
44
+ sort_by: z
45
+ .enum(JOB_SORT_FIELDS)
46
+ .optional()
47
+ .describe('Sort field (id|created_at|started_at|completed_at|status).'),
48
+ };
49
+ /** Build the list query, omitting unset knobs so the request stays minimal. */
50
+ function buildListQuery(args) {
51
+ const query = {};
52
+ if (args.limit !== undefined) {
53
+ query.limit = args.limit;
54
+ }
55
+ if (args.cursor !== undefined) {
56
+ query.cursor = args.cursor;
57
+ }
58
+ if (args.sort_order !== undefined) {
59
+ query.sort_order = args.sort_order;
60
+ }
61
+ if (args.sort_by !== undefined) {
62
+ query.sort_by = args.sort_by;
63
+ }
64
+ return Object.keys(query).length > 0 ? query : undefined;
65
+ }
66
+ /**
67
+ * Register `ingestion_jobs_list`. Passes limit/cursor/sort through and returns
68
+ * matcher's pagination envelope verbatim; a matcher error surfaces via the
69
+ * shared toToolError.
70
+ */
71
+ export function registerIngestionJobsListTool(server) {
72
+ server.registerTool('ingestion_jobs_list', {
73
+ description: 'List the ingestion jobs (file imports) under a context ' +
74
+ '(cursor-paginated). Pass contextId (UUID path param — not a tenant ' +
75
+ 'field), and optionally limit (1–200), cursor, sort_order (asc|desc), ' +
76
+ 'and/or sort_by (id|created_at|started_at|completed_at|status). The ' +
77
+ 'response carries { items, nextCursor } — paginate by re-calling with ' +
78
+ 'the returned nextCursor. No tenant field is accepted.',
79
+ inputSchema: listIngestionJobsInputShape,
80
+ }, async (args, extra) => {
81
+ const query = buildListQuery(args);
82
+ return dispatchIngestion({
83
+ method: 'GET',
84
+ path: contextJobsPath(args.contextId),
85
+ ...(query !== undefined ? { query } : {}),
86
+ }, extra);
87
+ });
88
+ }
89
+ //# sourceMappingURL=jobs-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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,CAAC"}
@@ -0,0 +1,84 @@
1
+ // Shared plumbing for the curated ingestion tools.
2
+ //
3
+ // Ingestion covers the import lifecycle of a reconciliation context: the jobs
4
+ // that parsed uploaded files, their per-row errors, the transactions they
5
+ // produced, a transaction search, and the "ignore" (Do Not Match) action. Every
6
+ // op is fully context-nested under /v1/imports/contexts/{contextId}/... — use
7
+ // source/ as the context-nested reference. This module factors the path helpers
8
+ // plus the relay boilerplate exactly once so the six tools stay thin (just
9
+ // "build the request") and so curated + generic surfaces map matcher errors
10
+ // through the identical path (toToolError).
11
+ //
12
+ // NOTE: uploadFile + extractDocument are NOT part of this family — they take a
13
+ // multipart/form-data binary body a JSON tool cannot express, so they stay on
14
+ // the generic invoke surface.
15
+ //
16
+ // Security: the bearer token is never read here directly — requireMatcherClient
17
+ // owns the request-scoped relay and fails closed when no usable credential was
18
+ // provided. The contextId/jobId/transactionId path params are routing
19
+ // identifiers (matcher validates the context belongs to the relayed token's
20
+ // tenant); no tenant identifier is ever read or injected, and no ingestion tool
21
+ // input carries one.
22
+ import { requireMatcherClient, UnauthenticatedError, } from '../../auth/request-token.js';
23
+ import { isMatcherApiError, toToolError } from '../tool-error.js';
24
+ /** Build the context-scoped jobs collection path (list jobs). */
25
+ export function contextJobsPath(contextId) {
26
+ return `/v1/imports/contexts/${encodeURIComponent(contextId)}/jobs`;
27
+ }
28
+ /** Build the single-job sub-path (get) — both ids encoded. */
29
+ export function contextJobPath(contextId, jobId) {
30
+ return `${contextJobsPath(contextId)}/${encodeURIComponent(jobId)}`;
31
+ }
32
+ /** Build a job's per-row errors sub-path (list errors). */
33
+ export function contextJobErrorsPath(contextId, jobId) {
34
+ return `${contextJobPath(contextId, jobId)}/errors`;
35
+ }
36
+ /** Build a job's transactions sub-path (list job transactions). */
37
+ export function contextJobTransactionsPath(contextId, jobId) {
38
+ return `${contextJobPath(contextId, jobId)}/transactions`;
39
+ }
40
+ /** Build the context-scoped transaction search path. */
41
+ export function contextTransactionsSearchPath(contextId) {
42
+ return `/v1/imports/contexts/${encodeURIComponent(contextId)}/transactions/search`;
43
+ }
44
+ /** Build a single transaction's ignore (Do Not Match) action path — both ids encoded. */
45
+ export function contextTransactionIgnorePath(contextId, transactionId) {
46
+ return `/v1/imports/contexts/${encodeURIComponent(contextId)}/transactions/${encodeURIComponent(transactionId)}/ignore`;
47
+ }
48
+ /**
49
+ * Run one assembled request through the relay: fail-closed auth, dispatch, and
50
+ * RFC 9457 → tool-error mapping — identical to the generic invoke's dispatch so
51
+ * both surfaces produce the same structured error shape.
52
+ *
53
+ * `clientFor` is injectable for tests; production callers pass nothing and get
54
+ * the request-scoped, fail-closed `requireMatcherClient`.
55
+ */
56
+ export async function dispatchIngestion(request, extra, clientFor = requireMatcherClient) {
57
+ let client;
58
+ try {
59
+ // Fail-closed on a missing / empty / non-Bearer credential.
60
+ client = clientFor(extra);
61
+ }
62
+ catch (err) {
63
+ if (err instanceof UnauthenticatedError) {
64
+ return { isError: true, content: [{ type: 'text', text: err.message }] };
65
+ }
66
+ throw err;
67
+ }
68
+ try {
69
+ const result = await client.request(request);
70
+ // Success → matcher's JSON returned as-is (incl. pagination envelopes and
71
+ // 204 → null where a matcher op returns no content).
72
+ return { content: [{ type: 'text', text: JSON.stringify(result ?? null) }] };
73
+ }
74
+ catch (err) {
75
+ // RFC 9457 problem → the SHARED structured tool error (status/title/detail/
76
+ // code preserved). A non-matcher error is a bug, not a matcher failure, and
77
+ // is re-thrown rather than masqueraded as one.
78
+ if (isMatcherApiError(err)) {
79
+ return toToolError(err);
80
+ }
81
+ throw err;
82
+ }
83
+ }
84
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/ingestion/shared.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,2EAA2E;AAC3E,4EAA4E;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,iBAAiB,CACrC,OAAuB,EACvB,KAAmC,EACnC,YAAyD,oBAAoB;IAE7E,IAAI,MAAqB,CAAA;IACzB,IAAI,CAAC;QACH,4DAA4D;QAC5D,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,oBAAoB,EAAE,CAAC;YACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAA;QAC1E,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC5C,0EAA0E;QAC1E,qDAAqD;QACrD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,CAAA;IAC9E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,4EAA4E;QAC5E,4EAA4E;QAC5E,+CAA+C;QAC/C,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ // `ingestion_transaction_ignore` — curated POST
2
+ // /v1/imports/contexts/{contextId}/transactions/{transactionId}/ignore.
3
+ //
4
+ // Marks a transaction as "Do Not Match" with a required reason. Only UNMATCHED
5
+ // transactions can be ignored (matcher rejects others). contextId and
6
+ // transactionId are routing path params; the reason is the only body field
7
+ // (required, non-empty, per the spec's IgnoreTransactionRequest). No tenant
8
+ // field is accepted — matcher scopes to the relayed token's tenant.
9
+ import { z } from 'zod';
10
+ import { contextTransactionIgnorePath, dispatchIngestion } from './shared.js';
11
+ /** Zod raw shape for `ingestion_transaction_ignore` input — path ids + reason body. */
12
+ export const ignoreTransactionInputShape = {
13
+ contextId: z
14
+ .string()
15
+ .min(1)
16
+ .describe('The reconciliation context id (UUID). Routing path param, not a tenant ' +
17
+ 'field.'),
18
+ transactionId: z
19
+ .string()
20
+ .min(1)
21
+ .describe('The transaction id (UUID) to ignore (mark "Do Not Match").'),
22
+ reason: z
23
+ .string()
24
+ .min(1)
25
+ .describe('Reason for ignoring the transaction (required, non-empty), e.g. ' +
26
+ '"Duplicate entry - already processed manually".'),
27
+ };
28
+ /**
29
+ * Register `ingestion_transaction_ignore`. Splits the routing ids (path) from
30
+ * the `reason` body and dispatches the POST through the shared fail-closed
31
+ * relay; a matcher error (e.g. 422 when the transaction is not UNMATCHED)
32
+ * surfaces via the shared toToolError.
33
+ */
34
+ export function registerIngestionTransactionIgnoreTool(server) {
35
+ server.registerTool('ingestion_transaction_ignore', {
36
+ description: 'Mark a transaction as "Do Not Match" with a required reason. Only ' +
37
+ 'UNMATCHED transactions can be ignored. Provide contextId and ' +
38
+ 'transactionId (UUID path params; contextId is not a tenant field) and a ' +
39
+ 'non-empty reason. No tenant field is accepted. Returns the updated ' +
40
+ 'transaction, or a structured RFC 9457 error (e.g. 422 if it is not ' +
41
+ 'UNMATCHED).',
42
+ inputSchema: ignoreTransactionInputShape,
43
+ }, async (args, extra) => {
44
+ return dispatchIngestion({
45
+ method: 'POST',
46
+ path: contextTransactionIgnorePath(args.contextId, args.transactionId),
47
+ body: { reason: args.reason },
48
+ }, extra);
49
+ });
50
+ }
51
+ //# sourceMappingURL=transaction-ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-ignore.js","sourceRoot":"","sources":["../../../src/tools/ingestion/transaction-ignore.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wEAAwE;AACxE,EAAE;AACF,+EAA+E;AAC/E,sEAAsE;AACtE,2EAA2E;AAC3E,4EAA4E;AAC5E,oEAAoE;AAEpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE7E,uFAAuF;AACvF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,QAAQ,CACX;IACH,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,4DAA4D,CAAC;IACzE,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,kEAAkE;QAChE,iDAAiD,CACpD;CACJ,CAAA;AAOD;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,CACpD,MAAiB;IAEjB,MAAM,CAAC,YAAY,CACjB,8BAA8B,EAC9B;QACE,WAAW,EACT,oEAAoE;YACpE,+DAA+D;YAC/D,0EAA0E;YAC1E,qEAAqE;YACrE,qEAAqE;YACrE,aAAa;QACf,WAAW,EAAE,2BAA2B;KACzC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,iBAAiB,CACtB;YACE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,4BAA4B,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC;YACtE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SAC9B,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}