@lerianstudio/matcher-mcp 5.0.0-beta.7 → 5.0.0-beta.71
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.
- package/README.md +28 -13
- package/dist/auth/request-token.js +11 -69
- package/dist/auth/request-token.js.map +1 -1
- package/dist/config.js +6 -21
- package/dist/config.js.map +1 -1
- package/dist/copilot/agent.js +5 -9
- package/dist/copilot/agent.js.map +1 -1
- package/dist/copilot/provider-anthropic.js +75 -23
- package/dist/copilot/provider-anthropic.js.map +1 -1
- package/dist/copilot/provider-openrouter.js +5 -18
- package/dist/copilot/provider-openrouter.js.map +1 -1
- package/dist/copilot/provider-shared.js +11 -0
- package/dist/copilot/provider-shared.js.map +1 -1
- package/dist/copilot/speech-provider.js +84 -0
- package/dist/copilot/speech-provider.js.map +1 -0
- package/dist/copilot/sse.js +5 -0
- package/dist/copilot/sse.js.map +1 -1
- package/dist/copilot/tools.js +14 -65
- package/dist/copilot/tools.js.map +1 -1
- package/dist/copilot/transcribe-handler.js +8 -93
- package/dist/copilot/transcribe-handler.js.map +1 -1
- package/dist/copilot/turn-request.js +76 -0
- package/dist/copilot/turn-request.js.map +1 -0
- package/dist/copilot/turns-handler.js +11 -102
- package/dist/copilot/turns-handler.js.map +1 -1
- package/dist/matcher/client.js +14 -0
- package/dist/matcher/client.js.map +1 -1
- package/dist/matcher/idempotency.js +94 -0
- package/dist/matcher/idempotency.js.map +1 -0
- package/dist/observability/otel.js +7 -29
- package/dist/observability/otel.js.map +1 -1
- package/dist/server.js +12 -81
- package/dist/server.js.map +1 -1
- package/dist/spec/curated-operations.js +111 -95
- package/dist/spec/curated-operations.js.map +1 -1
- package/dist/spec/enum-policy.js +21 -26
- package/dist/spec/enum-policy.js.map +1 -1
- package/dist/spec/openapi.yaml +841 -56
- package/dist/spec/schema-parity.js +23 -28
- package/dist/spec/schema-parity.js.map +1 -1
- package/dist/tools/context/create.js +3 -2
- package/dist/tools/context/create.js.map +1 -1
- package/dist/tools/context/index.js +137 -17
- package/dist/tools/context/index.js.map +1 -1
- package/dist/tools/context/list.js +9 -35
- package/dist/tools/context/list.js.map +1 -1
- package/dist/tools/context/setup-progress.js +3 -2
- package/dist/tools/context/setup-progress.js.map +1 -1
- package/dist/tools/context/shared.js +7 -48
- package/dist/tools/context/shared.js.map +1 -1
- package/dist/tools/context/update.js +5 -5
- package/dist/tools/context/update.js.map +1 -1
- package/dist/tools/curated-tool.js +39 -0
- package/dist/tools/curated-tool.js.map +1 -0
- package/dist/tools/dashboard/index.js +124 -19
- package/dist/tools/dashboard/index.js.map +1 -1
- package/dist/tools/dashboard/shared.js +9 -68
- package/dist/tools/dashboard/shared.js.map +1 -1
- package/dist/tools/dispute/close.js +5 -5
- package/dist/tools/dispute/close.js.map +1 -1
- package/dist/tools/dispute/index.js +34 -6
- package/dist/tools/dispute/index.js.map +1 -1
- package/dist/tools/dispute/list.js +18 -47
- package/dist/tools/dispute/list.js.map +1 -1
- package/dist/tools/dispute/shared.js +4 -43
- package/dist/tools/dispute/shared.js.map +1 -1
- package/dist/tools/dispute/submit-evidence.js +5 -5
- package/dist/tools/dispute/submit-evidence.js.map +1 -1
- package/dist/tools/exception/add-comment.js +3 -2
- package/dist/tools/exception/add-comment.js.map +1 -1
- package/dist/tools/exception/adjust-entry.js +5 -5
- package/dist/tools/exception/adjust-entry.js.map +1 -1
- package/dist/tools/exception/bulk-assign.js +3 -2
- package/dist/tools/exception/bulk-assign.js.map +1 -1
- package/dist/tools/exception/bulk-dispatch.js +12 -4
- package/dist/tools/exception/bulk-dispatch.js.map +1 -1
- package/dist/tools/exception/bulk-resolve.js +3 -2
- package/dist/tools/exception/bulk-resolve.js.map +1 -1
- package/dist/tools/exception/dispatch.js +13 -5
- package/dist/tools/exception/dispatch.js.map +1 -1
- package/dist/tools/exception/force-match.js +3 -2
- package/dist/tools/exception/force-match.js.map +1 -1
- package/dist/tools/exception/history.js +8 -24
- package/dist/tools/exception/history.js.map +1 -1
- package/dist/tools/exception/index.js +88 -18
- package/dist/tools/exception/index.js.map +1 -1
- package/dist/tools/exception/list.js +14 -57
- package/dist/tools/exception/list.js.map +1 -1
- package/dist/tools/exception/open-dispute.js +3 -2
- package/dist/tools/exception/open-dispute.js.map +1 -1
- package/dist/tools/exception/shared.js +10 -46
- package/dist/tools/exception/shared.js.map +1 -1
- package/dist/tools/fee-rule/create.js +5 -5
- package/dist/tools/fee-rule/create.js.map +1 -1
- package/dist/tools/fee-rule/index.js +50 -8
- package/dist/tools/fee-rule/index.js.map +1 -1
- package/dist/tools/fee-rule/list.js +9 -29
- package/dist/tools/fee-rule/list.js.map +1 -1
- package/dist/tools/fee-rule/shared.js +5 -47
- package/dist/tools/fee-rule/shared.js.map +1 -1
- package/dist/tools/fee-rule/update.js +5 -5
- package/dist/tools/fee-rule/update.js.map +1 -1
- package/dist/tools/fee-schedule/create.js +8 -3
- package/dist/tools/fee-schedule/create.js.map +1 -1
- package/dist/tools/fee-schedule/index.js +62 -11
- package/dist/tools/fee-schedule/index.js.map +1 -1
- package/dist/tools/fee-schedule/list.js +8 -24
- package/dist/tools/fee-schedule/list.js.map +1 -1
- package/dist/tools/fee-schedule/shared.js +5 -44
- package/dist/tools/fee-schedule/shared.js.map +1 -1
- package/dist/tools/fee-schedule/simulate.js +5 -5
- package/dist/tools/fee-schedule/simulate.js.map +1 -1
- package/dist/tools/fee-schedule/update.js +5 -5
- package/dist/tools/fee-schedule/update.js.map +1 -1
- package/dist/tools/field-map/create.js +3 -2
- package/dist/tools/field-map/create.js.map +1 -1
- package/dist/tools/field-map/index.js +65 -11
- package/dist/tools/field-map/index.js.map +1 -1
- package/dist/tools/field-map/list.js +9 -29
- package/dist/tools/field-map/list.js.map +1 -1
- package/dist/tools/field-map/shared.js +6 -42
- package/dist/tools/field-map/shared.js.map +1 -1
- package/dist/tools/field-map/update.js +3 -2
- package/dist/tools/field-map/update.js.map +1 -1
- package/dist/tools/generic/invoke.js +16 -39
- package/dist/tools/generic/invoke.js.map +1 -1
- package/dist/tools/ingestion/index.js +100 -12
- package/dist/tools/ingestion/index.js.map +1 -1
- package/dist/tools/ingestion/job-transactions-list.js +10 -40
- package/dist/tools/ingestion/job-transactions-list.js.map +1 -1
- package/dist/tools/ingestion/jobs-list.js +9 -35
- package/dist/tools/ingestion/jobs-list.js.map +1 -1
- package/dist/tools/ingestion/shared.js +4 -41
- package/dist/tools/ingestion/shared.js.map +1 -1
- package/dist/tools/ingestion/transactions-search.js +9 -44
- package/dist/tools/ingestion/transactions-search.js.map +1 -1
- package/dist/tools/ingestion/upload-begin.js +5 -2
- package/dist/tools/ingestion/upload-begin.js.map +1 -1
- package/dist/tools/ingestion/upload.js +3 -2
- package/dist/tools/ingestion/upload.js.map +1 -1
- package/dist/tools/input-fields.js +51 -0
- package/dist/tools/input-fields.js.map +1 -0
- package/dist/tools/match-rule/index.js +130 -13
- package/dist/tools/match-rule/index.js.map +1 -1
- package/dist/tools/match-rule/list.js +9 -33
- package/dist/tools/match-rule/list.js.map +1 -1
- package/dist/tools/match-rule/shared.js +16 -46
- package/dist/tools/match-rule/shared.js.map +1 -1
- package/dist/tools/match-rule/update.js +7 -11
- package/dist/tools/match-rule/update.js.map +1 -1
- package/dist/tools/matching/get.js +5 -5
- package/dist/tools/matching/get.js.map +1 -1
- package/dist/tools/matching/groups.js +6 -14
- package/dist/tools/matching/groups.js.map +1 -1
- package/dist/tools/matching/index.js +77 -5
- package/dist/tools/matching/index.js.map +1 -1
- package/dist/tools/matching/list.js +9 -32
- package/dist/tools/matching/list.js.map +1 -1
- package/dist/tools/matching/shared.js +5 -46
- package/dist/tools/matching/shared.js.map +1 -1
- package/dist/tools/query-handler.js +9 -0
- package/dist/tools/query-handler.js.map +1 -0
- package/dist/tools/report/index.js +260 -30
- package/dist/tools/report/index.js.map +1 -1
- package/dist/tools/report/shared.js +24 -98
- package/dist/tools/report/shared.js.map +1 -1
- package/dist/tools/request-fields.js +17 -0
- package/dist/tools/request-fields.js.map +1 -0
- package/dist/tools/shared-dispatch.js +38 -0
- package/dist/tools/shared-dispatch.js.map +1 -0
- package/dist/tools/source/create.js +146 -23
- package/dist/tools/source/create.js.map +1 -1
- package/dist/tools/source/index.js +101 -13
- package/dist/tools/source/index.js.map +1 -1
- package/dist/tools/source/list.js +9 -32
- package/dist/tools/source/list.js.map +1 -1
- package/dist/tools/source/shared.js +5 -42
- package/dist/tools/source/shared.js.map +1 -1
- package/dist/tools/source/update.js +16 -33
- package/dist/tools/source/update.js.map +1 -1
- package/dist/tools/workspace/usage.js +12 -40
- package/dist/tools/workspace/usage.js.map +1 -1
- package/package.json +4 -4
- package/dist/tools/context/archive.js +0 -37
- package/dist/tools/context/archive.js.map +0 -1
- package/dist/tools/context/get.js +0 -31
- package/dist/tools/context/get.js.map +0 -1
- package/dist/tools/context/next-step.js +0 -99
- package/dist/tools/context/next-step.js.map +0 -1
- package/dist/tools/context/restore.js +0 -34
- package/dist/tools/context/restore.js.map +0 -1
- package/dist/tools/dashboard/aggregates.js +0 -37
- package/dist/tools/dashboard/aggregates.js.map +0 -1
- package/dist/tools/dashboard/cash-impact.js +0 -37
- package/dist/tools/dashboard/cash-impact.js.map +0 -1
- package/dist/tools/dashboard/match-rate.js +0 -37
- package/dist/tools/dashboard/match-rate.js.map +0 -1
- package/dist/tools/dashboard/metrics.js +0 -37
- package/dist/tools/dashboard/metrics.js.map +0 -1
- package/dist/tools/dashboard/sla.js +0 -34
- package/dist/tools/dashboard/sla.js.map +0 -1
- package/dist/tools/dashboard/source-breakdown.js +0 -37
- package/dist/tools/dashboard/source-breakdown.js.map +0 -1
- package/dist/tools/dashboard/volume.js +0 -37
- package/dist/tools/dashboard/volume.js.map +0 -1
- package/dist/tools/dispute/get.js +0 -27
- package/dist/tools/dispute/get.js.map +0 -1
- package/dist/tools/exception/delete-comment.js +0 -40
- package/dist/tools/exception/delete-comment.js.map +0 -1
- package/dist/tools/exception/get.js +0 -34
- package/dist/tools/exception/get.js.map +0 -1
- package/dist/tools/exception/list-comments.js +0 -35
- package/dist/tools/exception/list-comments.js.map +0 -1
- package/dist/tools/fee-rule/delete.js +0 -27
- package/dist/tools/fee-rule/delete.js.map +0 -1
- package/dist/tools/fee-rule/get.js +0 -27
- package/dist/tools/fee-rule/get.js.map +0 -1
- package/dist/tools/fee-schedule/delete.js +0 -32
- package/dist/tools/fee-schedule/delete.js.map +0 -1
- package/dist/tools/fee-schedule/get.js +0 -30
- package/dist/tools/fee-schedule/get.js.map +0 -1
- package/dist/tools/field-map/delete.js +0 -37
- package/dist/tools/field-map/delete.js.map +0 -1
- package/dist/tools/field-map/get.js +0 -43
- package/dist/tools/field-map/get.js.map +0 -1
- package/dist/tools/ingestion/job-errors-list.js +0 -45
- package/dist/tools/ingestion/job-errors-list.js.map +0 -1
- package/dist/tools/ingestion/job-get.js +0 -42
- package/dist/tools/ingestion/job-get.js.map +0 -1
- package/dist/tools/ingestion/transaction-ignore.js +0 -51
- package/dist/tools/ingestion/transaction-ignore.js.map +0 -1
- package/dist/tools/match-rule/create.js +0 -67
- package/dist/tools/match-rule/create.js.map +0 -1
- package/dist/tools/match-rule/delete.js +0 -35
- package/dist/tools/match-rule/delete.js.map +0 -1
- package/dist/tools/match-rule/get.js +0 -32
- package/dist/tools/match-rule/get.js.map +0 -1
- package/dist/tools/match-rule/reorder.js +0 -45
- package/dist/tools/match-rule/reorder.js.map +0 -1
- package/dist/tools/matching/start.js +0 -81
- package/dist/tools/matching/start.js.map +0 -1
- package/dist/tools/report/count-exceptions.js +0 -46
- package/dist/tools/report/count-exceptions.js.map +0 -1
- package/dist/tools/report/count-matched.js +0 -47
- package/dist/tools/report/count-matched.js.map +0 -1
- package/dist/tools/report/count-transactions.js +0 -45
- package/dist/tools/report/count-transactions.js.map +0 -1
- package/dist/tools/report/count-unmatched.js +0 -45
- package/dist/tools/report/count-unmatched.js.map +0 -1
- package/dist/tools/report/export-exceptions.js +0 -48
- package/dist/tools/report/export-exceptions.js.map +0 -1
- package/dist/tools/report/export-matched.js +0 -49
- package/dist/tools/report/export-matched.js.map +0 -1
- package/dist/tools/report/export-summary.js +0 -49
- package/dist/tools/report/export-summary.js.map +0 -1
- package/dist/tools/report/export-unmatched.js +0 -49
- package/dist/tools/report/export-unmatched.js.map +0 -1
- package/dist/tools/report/export-variance.js +0 -48
- package/dist/tools/report/export-variance.js.map +0 -1
- package/dist/tools/report/matched.js +0 -48
- package/dist/tools/report/matched.js.map +0 -1
- package/dist/tools/report/summary.js +0 -43
- package/dist/tools/report/summary.js.map +0 -1
- package/dist/tools/report/unmatched.js +0 -48
- package/dist/tools/report/unmatched.js.map +0 -1
- package/dist/tools/report/variance.js +0 -48
- package/dist/tools/report/variance.js.map +0 -1
- package/dist/tools/source/archive.js +0 -46
- package/dist/tools/source/archive.js.map +0 -1
- package/dist/tools/source/get.js +0 -57
- package/dist/tools/source/get.js.map +0 -1
- package/dist/tools/source/restore.js +0 -39
- package/dist/tools/source/restore.js.map +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Common cursor-page fields; endpoints with different wording keep their own schemas. */
|
|
3
|
+
export const pageLimit = z
|
|
4
|
+
.number()
|
|
5
|
+
.int()
|
|
6
|
+
.min(1)
|
|
7
|
+
.max(200)
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('Maximum number of records to return (1–200, default 20).');
|
|
10
|
+
export const nextCursor = z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Opaque pagination cursor from a prior response. Re-call with the ' +
|
|
14
|
+
'returned nextCursor to page forward (there is no auto-pagination).');
|
|
15
|
+
/**
|
|
16
|
+
* Field names that would let a caller assert a tenant. THE one list: the
|
|
17
|
+
* `matcher_invoke` guardrail refuses these keys in pathParams, query and body,
|
|
18
|
+
* and every curated tool suite asserts no tool declares one (they read it as
|
|
19
|
+
* `TENANT_FIELD_NAMES`). Tenant identity comes solely from the relayed JWT.
|
|
20
|
+
*
|
|
21
|
+
* Order is load-bearing: the guardrail names the FIRST match, so appending is
|
|
22
|
+
* safe and reordering changes an operator-facing refusal message.
|
|
23
|
+
*/
|
|
24
|
+
export const FORBIDDEN_TENANT_KEYS = [
|
|
25
|
+
'tenant_id',
|
|
26
|
+
'tenantId',
|
|
27
|
+
'tenant',
|
|
28
|
+
'tenantSlug',
|
|
29
|
+
];
|
|
30
|
+
/** A context routing identifier, never a tenant selection input. */
|
|
31
|
+
export const contextRoutingId = z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1)
|
|
34
|
+
.describe('The reconciliation context id (UUID). Routing path param, not a tenant field.');
|
|
35
|
+
/** Matcher clips omitted date windows; preserve this warning on every analytics tool. */
|
|
36
|
+
export const reportDateFrom = z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe('Start date (YYYY-MM-DD), inclusive. Optional — if omitted (with ' +
|
|
40
|
+
'date_to), matcher defaults to the last ~30 days, SILENTLY EXCLUDING ' +
|
|
41
|
+
'everything older. A windowed result is NOT "the reconciliation ' +
|
|
42
|
+
'result" — for a complete picture, pass an explicit date_from/date_to ' +
|
|
43
|
+
'(max 90-day span).');
|
|
44
|
+
export const reportDateTo = z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('End date (YYYY-MM-DD), inclusive. Optional — if omitted, matcher ' +
|
|
48
|
+
'defaults to tomorrow (UTC). Combined with an omitted date_from this ' +
|
|
49
|
+
'silently clips the window to the last ~30 days; pass an explicit ' +
|
|
50
|
+
'date_from/date_to (max 90-day span) for the full picture.');
|
|
51
|
+
//# sourceMappingURL=input-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-fields.js","sourceRoot":"","sources":["../../src/tools/input-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,QAAQ,EAAE;KACV,QAAQ,CAAC,0DAA0D,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,QAAQ,CACP,mEAAmE;IACjE,oEAAoE,CACvE,CAAA;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW;IACX,UAAU;IACV,QAAQ;IACR,YAAY;CACJ,CAAA;AAEV,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,QAAQ,CACP,+EAA+E,CAChF,CAAA;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,QAAQ,CACP,kEAAkE;IAChE,sEAAsE;IACtE,iEAAiE;IACjE,uEAAuE;IACvE,oBAAoB,CACvB,CAAA;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,QAAQ,CACP,mEAAmE;IACjE,sEAAsE;IACtE,mEAAmE;IACnE,2DAA2D,CAC9D,CAAA"}
|
|
@@ -1,22 +1,139 @@
|
|
|
1
1
|
// Curated match-rule vertical (task 2.1.2): six typed tools over the matcher
|
|
2
2
|
// match-rule resource — create, list, get, update, delete, reorder. All ops are
|
|
3
3
|
// fully context-nested (/v1/contexts/{contextId}/rules[...]). Each tool shares
|
|
4
|
-
// the fail-closed relay (shared.ts) and the RFC 9457 → tool-error
|
|
5
|
-
// (toToolError) with the generic surface, so curated and generic map
|
|
6
|
-
// errors identically. No tool carries a tenant field.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
// the fail-closed relay (shared-dispatch.ts) and the RFC 9457 → tool-error
|
|
5
|
+
// mapping (toToolError) with the generic surface, so curated and generic map
|
|
6
|
+
// matcher errors identically. No tool carries a tenant field.
|
|
7
|
+
//
|
|
8
|
+
// create, get, delete and reorder are nothing but a rule path, a method, a
|
|
9
|
+
// body-from-args and a description, so they are declared as four rows and
|
|
10
|
+
// registered by the one shared loop; list and update carry query builders or
|
|
11
|
+
// partial-update composition and stay as files.
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { registerCuratedTools } from '../curated-tool.js';
|
|
14
|
+
import { contextRoutingId } from '../input-fields.js';
|
|
10
15
|
import { registerMatchRuleListTool } from './list.js';
|
|
11
|
-
import {
|
|
16
|
+
import { contextRulePath, contextRulesPath, contextRulesReorderPath, MATCH_RULE_TYPES, RULE_CONFIG_DESC_BODY, } from './shared.js';
|
|
12
17
|
import { registerMatchRuleUpdateTool } from './update.js';
|
|
18
|
+
/**
|
|
19
|
+
* Zod raw shape for `match_rule_create` input — mirrors CreateMatchRuleRequest.
|
|
20
|
+
* Exported because `spec/schema-parity.ts` diffs it against the vendored spec's
|
|
21
|
+
* request body; the row below is its only other consumer.
|
|
22
|
+
*/
|
|
23
|
+
export const createMatchRuleInputShape = {
|
|
24
|
+
contextId: z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.describe('The reconciliation context id (UUID) the rule belongs to. Routing path ' +
|
|
28
|
+
'param, not a tenant field — matcher validates the context is yours.'),
|
|
29
|
+
priority: z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.min(1)
|
|
33
|
+
.max(1000)
|
|
34
|
+
.describe('Execution priority (1–1000); lower numbers run first. Must be unique ' +
|
|
35
|
+
'within the context.'),
|
|
36
|
+
type: z
|
|
37
|
+
.enum(MATCH_RULE_TYPES)
|
|
38
|
+
.describe('Matching strategy. EXACT requires identical field values; TOLERANCE ' +
|
|
39
|
+
'allows configured numeric slack; DATE_LAG allows a configured date ' +
|
|
40
|
+
'offset between sides; FUZZY matches on normalized/similarity-scored ' +
|
|
41
|
+
'references (free-text memos, truncated refs) and ALWAYS proposes for ' +
|
|
42
|
+
'review — never auto-confirms.'),
|
|
43
|
+
config: z
|
|
44
|
+
.record(z.string(), z.unknown())
|
|
45
|
+
.describe('Rule-specific ' + RULE_CONFIG_DESC_BODY),
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Zod raw shape for `match_rule_reorder` input — context (path) + ordered
|
|
49
|
+
* ruleIds. Exported for the same parity diff as the create shape.
|
|
50
|
+
*/
|
|
51
|
+
export const reorderMatchRulesInputShape = {
|
|
52
|
+
contextId: z
|
|
53
|
+
.string()
|
|
54
|
+
.min(1)
|
|
55
|
+
.describe('The reconciliation context id (UUID) whose rules to reorder. Routing path ' +
|
|
56
|
+
'param, not a tenant field.'),
|
|
57
|
+
ruleIds: z
|
|
58
|
+
.array(z.string().min(1))
|
|
59
|
+
.min(1)
|
|
60
|
+
.max(100)
|
|
61
|
+
.describe('Ordered list of match rule UUIDs (1–100). Each rule’s new priority is ' +
|
|
62
|
+
'its position in this list: the first id runs first. Include every rule ' +
|
|
63
|
+
'you intend to reorder.'),
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The match-rule registration list, IN PUBLISHED ORDER: thin tools inline as data
|
|
67
|
+
* rows, the tools that still need their own file by their register function.
|
|
68
|
+
* This list is the order `tools/list` returns, so moving an entry moves what a
|
|
69
|
+
* client renders and what an agent prompt built from it reads first.
|
|
70
|
+
*
|
|
71
|
+
* Every description string is the hand-tuned LLM guidance a client sees
|
|
72
|
+
* verbatim; the published-surface golden is what proves an edit here dropped no
|
|
73
|
+
* character and moved no tool.
|
|
74
|
+
*/
|
|
75
|
+
const MATCH_RULE_TOOLS = [
|
|
76
|
+
{
|
|
77
|
+
name: 'match_rule_create',
|
|
78
|
+
description: 'Create a match rule within a reconciliation context. Provide contextId ' +
|
|
79
|
+
'(UUID path), priority (1–1000, unique within the context), type ' +
|
|
80
|
+
'(EXACT|TOLERANCE|DATE_LAG|FUZZY), and config (a type-specific object validated ' +
|
|
81
|
+
'server-side). No tenant field is accepted — the rule is created for your ' +
|
|
82
|
+
"token's tenant. Returns the created rule, or a structured RFC 9457 error.",
|
|
83
|
+
inputShape: createMatchRuleInputShape,
|
|
84
|
+
request: (args) => {
|
|
85
|
+
// contextId routes; every other validated field is the body.
|
|
86
|
+
const { contextId, ...body } = args;
|
|
87
|
+
return { method: 'POST', path: contextRulesPath(String(contextId)), body };
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
registerMatchRuleListTool,
|
|
91
|
+
{
|
|
92
|
+
name: 'match_rule_get',
|
|
93
|
+
description: 'Fetch a single match rule by id (UUID) within a context (UUID). Both ' +
|
|
94
|
+
'the rule and its context must belong to your token. Returns the rule, ' +
|
|
95
|
+
'or a structured RFC 9457 error (e.g. 404 if it does not exist or is not ' +
|
|
96
|
+
'yours).',
|
|
97
|
+
inputShape: {
|
|
98
|
+
contextId: contextRoutingId,
|
|
99
|
+
ruleId: z.string().min(1).describe('The match rule id (UUID) to fetch.'),
|
|
100
|
+
},
|
|
101
|
+
request: (args) => ({
|
|
102
|
+
method: 'GET',
|
|
103
|
+
path: contextRulePath(String(args.contextId), String(args.ruleId)),
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
registerMatchRuleUpdateTool,
|
|
107
|
+
{
|
|
108
|
+
name: 'match_rule_delete',
|
|
109
|
+
description: 'Delete a match rule by id (UUID) within a context (UUID). The rule and ' +
|
|
110
|
+
"its context must belong to your token's tenant (no tenant field is " +
|
|
111
|
+
'accepted). Returns no content on success, or a structured RFC 9457 error.',
|
|
112
|
+
inputShape: {
|
|
113
|
+
contextId: contextRoutingId,
|
|
114
|
+
ruleId: z.string().min(1).describe('The match rule id (UUID) to delete.'),
|
|
115
|
+
},
|
|
116
|
+
request: (args) => ({
|
|
117
|
+
method: 'DELETE',
|
|
118
|
+
path: contextRulePath(String(args.contextId), String(args.ruleId)),
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'match_rule_reorder',
|
|
123
|
+
description: 'Reorder the match rules of a reconciliation context. Provide contextId ' +
|
|
124
|
+
'(UUID path) and ruleIds, an ordered array of rule UUIDs whose position ' +
|
|
125
|
+
'becomes the new priority (first = runs first). No tenant field is ' +
|
|
126
|
+
'accepted. Returns no content on success, or a structured RFC 9457 error.',
|
|
127
|
+
inputShape: reorderMatchRulesInputShape,
|
|
128
|
+
request: (args) => ({
|
|
129
|
+
method: 'POST',
|
|
130
|
+
path: contextRulesReorderPath(String(args.contextId)),
|
|
131
|
+
body: { ruleIds: args.ruleIds },
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
];
|
|
13
135
|
/** Register all six curated match-rule tools on the given server. */
|
|
14
136
|
export function registerMatchRuleTools(server) {
|
|
15
|
-
|
|
16
|
-
registerMatchRuleListTool(server);
|
|
17
|
-
registerMatchRuleGetTool(server);
|
|
18
|
-
registerMatchRuleUpdateTool(server);
|
|
19
|
-
registerMatchRuleDeleteTool(server);
|
|
20
|
-
registerMatchRuleReorderTool(server);
|
|
137
|
+
registerCuratedTools(server, MATCH_RULE_TOOLS);
|
|
21
138
|
}
|
|
22
139
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/match-rule/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,0EAA0E;AAC1E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/match-rule/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,gDAAgD;AAEhD,OAAO,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3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC;SAC1E;QACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnE,CAAC;KACH;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EACT,yEAAyE;YACzE,yEAAyE;YACzE,oEAAoE;YACpE,0EAA0E;QAC5E,UAAU,EAAE,2BAA2B;QACvC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACrD,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;SAChC,CAAC;KACH;CACF,CAAA;AAED,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
// tenant-scoped by the relayed token; `contextId` is a routing path param and no
|
|
8
8
|
// tenant field is accepted.
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { nextCursor, pageLimit } from '../input-fields.js';
|
|
11
|
+
import { queryHandler } from '../query-handler.js';
|
|
12
|
+
import { pickQuery } from '../request-fields.js';
|
|
13
|
+
import { dispatchToolRequest } from '../shared-dispatch.js';
|
|
14
|
+
import { contextRulesPath, MATCH_RULE_TYPES } from './shared.js';
|
|
12
15
|
/** Zod raw shape for `match_rule_list` input — context, optional type filter, pagination. */
|
|
13
16
|
export const listMatchRulesInputShape = {
|
|
14
17
|
contextId: z
|
|
@@ -20,32 +23,12 @@ export const listMatchRulesInputShape = {
|
|
|
20
23
|
.enum(MATCH_RULE_TYPES)
|
|
21
24
|
.optional()
|
|
22
25
|
.describe('Optional filter by rule type (EXACT|TOLERANCE|DATE_LAG|FUZZY). Omit to list all.'),
|
|
23
|
-
limit:
|
|
24
|
-
|
|
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).'),
|
|
26
|
+
limit: pageLimit,
|
|
27
|
+
cursor: nextCursor,
|
|
35
28
|
};
|
|
36
29
|
/** Build the list query, omitting unset knobs so the request stays minimal. */
|
|
37
30
|
function buildListQuery(args) {
|
|
38
|
-
|
|
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;
|
|
31
|
+
return pickQuery(args, ['type', 'limit', 'cursor']);
|
|
49
32
|
}
|
|
50
33
|
/**
|
|
51
34
|
* Register `match_rule_list`. Passes type/limit/cursor through and returns
|
|
@@ -60,13 +43,6 @@ export function registerMatchRuleListTool(server) {
|
|
|
60
43
|
'response carries { items, nextCursor } — paginate by re-calling with the ' +
|
|
61
44
|
'returned nextCursor. No tenant field is accepted.',
|
|
62
45
|
inputSchema: listMatchRulesInputShape,
|
|
63
|
-
},
|
|
64
|
-
const query = buildListQuery(args);
|
|
65
|
-
return dispatchMatchRule({
|
|
66
|
-
method: 'GET',
|
|
67
|
-
path: contextRulesPath(args.contextId),
|
|
68
|
-
...(query !== undefined ? { query } : {}),
|
|
69
|
-
}, extra);
|
|
70
|
-
});
|
|
46
|
+
}, queryHandler(buildListQuery, (args) => contextRulesPath(args.contextId), dispatchToolRequest));
|
|
71
47
|
}
|
|
72
48
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/tools/match-rule/list.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,6EAA6E;AAC7E,wEAAwE;AACxE,iFAAiF;AACjF,4BAA4B;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/tools/match-rule/list.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,6EAA6E;AAC7E,wEAAwE;AACxE,iFAAiF;AACjF,4BAA4B;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEhE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,yEAAyE;QACvE,4BAA4B,CAC/B;IACH,IAAI,EAAE,CAAC;SACJ,IAAI,CAAC,gBAAgB,CAAC;SACtB,QAAQ,EAAE;SACV,QAAQ,CACP,kFAAkF,CACnF;IACH,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,UAAU;CACnB,CAAA;AAOD,+EAA+E;AAC/E,SAAS,cAAc,CAAC,IAAyB;IAC/C,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IACzD,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,WAAW,EACT,uEAAuE;YACvE,2DAA2D;YAC3D,6EAA6E;YAC7E,2EAA2E;YAC3E,mDAAmD;QACrD,WAAW,EAAE,wBAAwB;KACtC,EACD,YAAY,CACV,cAAc,EACd,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAC1C,mBAAmB,CACpB,CACF,CAAA;AACH,CAAC"}
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
// Match rules are fully context-nested: every op lives under
|
|
4
4
|
// /v1/contexts/{contextId}/rules (list/create), .../rules/{ruleId}
|
|
5
5
|
// (get/update/delete), and .../rules/reorder (the custom reorder action). This
|
|
6
|
-
// module
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// return matcher's JSON on success or the SHARED toToolError on a
|
|
12
|
-
// MatcherApiError. Curated and generic surfaces therefore map matcher errors
|
|
13
|
-
// through the same path.
|
|
6
|
+
// module holds the path construction and nothing else, factored exactly once so
|
|
7
|
+
// the four table rows in index.ts and the two tools that keep their own file
|
|
8
|
+
// address the same URLs. The relay itself lives in shared-dispatch.ts, so
|
|
9
|
+
// curated and generic surfaces map matcher errors through the identical path
|
|
10
|
+
// (toToolError).
|
|
14
11
|
//
|
|
15
12
|
// Security: the bearer token is never read here directly — requireMatcherClient
|
|
16
13
|
// owns the request-scoped relay and fails closed when no usable credential was
|
|
@@ -18,8 +15,6 @@
|
|
|
18
15
|
// tenant from the relayed JWT); no match-rule tool input carries one. The
|
|
19
16
|
// `contextId` segment is a routing path param — matcher validates that the
|
|
20
17
|
// context belongs to the token's tenant.
|
|
21
|
-
import { requireMatcherClient, UnauthenticatedError, } from '../../auth/request-token.js';
|
|
22
|
-
import { isMatcherApiError, toToolError } from '../tool-error.js';
|
|
23
18
|
/** Path for the match-rule collection under a context (list + create). */
|
|
24
19
|
export function contextRulesPath(contextId) {
|
|
25
20
|
return `/v1/contexts/${encodeURIComponent(contextId)}/rules`;
|
|
@@ -32,6 +27,17 @@ export function contextRulePath(contextId, ruleId) {
|
|
|
32
27
|
export function contextRulesReorderPath(contextId) {
|
|
33
28
|
return `${contextRulesPath(contextId)}/reorder`;
|
|
34
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Matching strategy vocabulary. EXACT / TOLERANCE / DATE_LAG / FUZZY (spec
|
|
32
|
+
* oneof), centralized here because create's input shape, list's filter and
|
|
33
|
+
* update's optional type all enumerate the same four values.
|
|
34
|
+
*/
|
|
35
|
+
export const MATCH_RULE_TYPES = [
|
|
36
|
+
'EXACT',
|
|
37
|
+
'TOLERANCE',
|
|
38
|
+
'DATE_LAG',
|
|
39
|
+
'FUZZY',
|
|
40
|
+
];
|
|
35
41
|
/**
|
|
36
42
|
* Shared body of the `config` field description, centralized so create and
|
|
37
43
|
* update stay in lockstep as the rule vocabulary grows. Callers prepend the
|
|
@@ -55,40 +61,4 @@ export const RULE_CONFIG_DESC_BODY = 'configuration object; shape depends on `ty
|
|
|
55
61
|
'tolerance? }]). Optional across types: timezone (IANA zone), calendar ' +
|
|
56
62
|
'(US_FED|BR_ANBIMA), businessDayMode (DATE_LAG only), and signMode ' +
|
|
57
63
|
'(same|opposite|ignore).';
|
|
58
|
-
/**
|
|
59
|
-
* Run one assembled request through the relay: fail-closed auth, dispatch, and
|
|
60
|
-
* RFC 9457 → tool-error mapping — identical to the generic invoke's dispatch so
|
|
61
|
-
* both surfaces produce the same structured error shape.
|
|
62
|
-
*
|
|
63
|
-
* `clientFor` is injectable for tests; production callers pass nothing and get
|
|
64
|
-
* the request-scoped, fail-closed `requireMatcherClient`.
|
|
65
|
-
*/
|
|
66
|
-
export async function dispatchMatchRule(request, extra, clientFor = requireMatcherClient) {
|
|
67
|
-
let client;
|
|
68
|
-
try {
|
|
69
|
-
// Fail-closed on a missing / empty / non-Bearer credential.
|
|
70
|
-
client = clientFor(extra);
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
if (err instanceof UnauthenticatedError) {
|
|
74
|
-
return { isError: true, content: [{ type: 'text', text: err.message }] };
|
|
75
|
-
}
|
|
76
|
-
throw err;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
const result = await client.request(request);
|
|
80
|
-
// Success → matcher's JSON returned as-is (incl. pagination envelopes and
|
|
81
|
-
// 204 → null for delete / reorder).
|
|
82
|
-
return { content: [{ type: 'text', text: JSON.stringify(result ?? null) }] };
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
// RFC 9457 problem → the SHARED structured tool error (status/title/detail/
|
|
86
|
-
// code preserved). A non-matcher error is a bug, not a matcher failure, and
|
|
87
|
-
// is re-thrown rather than masqueraded as one.
|
|
88
|
-
if (isMatcherApiError(err)) {
|
|
89
|
-
return toToolError(err);
|
|
90
|
-
}
|
|
91
|
-
throw err;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
64
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/match-rule/shared.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6DAA6D;AAC7D,mEAAmE;AACnE,+EAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/tools/match-rule/shared.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6DAA6D;AAC7D,mEAAmE;AACnE,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,iBAAiB;AACjB,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,0EAA0E;AAC1E,2EAA2E;AAC3E,yCAAyC;AAEzC,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAA;AAC9D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,MAAc;IAC/D,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAA;AACvE,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACvD,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAA;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO;IACP,WAAW;IACX,UAAU;IACV,OAAO;CACC,CAAA;AAEV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAChC,uDAAuD;IACvD,yEAAyE;IACzE,iEAAiE;IACjE,sEAAsE;IACtE,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,uEAAuE;IACvE,uEAAuE;IACvE,yEAAyE;IACzE,yEAAyE;IACzE,uEAAuE;IACvE,iEAAiE;IACjE,kEAAkE;IAClE,wEAAwE;IACxE,oEAAoE;IACpE,yBAAyB,CAAA"}
|
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
// contextId and ruleId are UUID path params; no tenant field is accepted
|
|
6
6
|
// (matcher scopes to the relayed token's tenant via the context).
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { contextRoutingId } from '../input-fields.js';
|
|
9
|
+
import { bodyWithout } from '../request-fields.js';
|
|
10
|
+
import { dispatchToolRequest } from '../shared-dispatch.js';
|
|
11
|
+
import { contextRulePath, MATCH_RULE_TYPES, RULE_CONFIG_DESC_BODY, } from './shared.js';
|
|
10
12
|
/** Zod raw shape for `match_rule_update` input — ids (path) + optional fields. */
|
|
11
13
|
export const updateMatchRuleInputShape = {
|
|
12
|
-
contextId:
|
|
13
|
-
.string()
|
|
14
|
-
.min(1)
|
|
15
|
-
.describe('The reconciliation context id (UUID). Routing path param, not a tenant field.'),
|
|
14
|
+
contextId: contextRoutingId,
|
|
16
15
|
ruleId: z.string().min(1).describe('The match rule id (UUID) to update.'),
|
|
17
16
|
priority: z
|
|
18
17
|
.number()
|
|
@@ -39,10 +38,7 @@ export const updateMatchRuleInputShape = {
|
|
|
39
38
|
* fields as unchanged.
|
|
40
39
|
*/
|
|
41
40
|
export function buildUpdateBody(args) {
|
|
42
|
-
|
|
43
|
-
void _contextId;
|
|
44
|
-
void _ruleId;
|
|
45
|
-
return body;
|
|
41
|
+
return bodyWithout(args, ['contextId', 'ruleId']);
|
|
46
42
|
}
|
|
47
43
|
/**
|
|
48
44
|
* Register `match_rule_update`. Splits the ids (path) from the body fields and
|
|
@@ -58,7 +54,7 @@ export function registerMatchRuleUpdateTool(server) {
|
|
|
58
54
|
'RFC 9457 error.',
|
|
59
55
|
inputSchema: updateMatchRuleInputShape,
|
|
60
56
|
}, async (args, extra) => {
|
|
61
|
-
return
|
|
57
|
+
return dispatchToolRequest({
|
|
62
58
|
method: 'PATCH',
|
|
63
59
|
path: contextRulePath(args.contextId, args.ruleId),
|
|
64
60
|
body: buildUpdateBody(args),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/tools/match-rule/update.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EA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CAC1D,CAAA;AAOD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA0B;IAE1B,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAA;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAiB;IAC3D,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,WAAW,EACT,2EAA2E;YAC3E,oDAAoD;YACpD,mFAAmF;YACnF,yEAAyE;YACzE,iBAAiB;QACnB,WAAW,EAAE,yBAAyB;KACvC,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpB,OAAO,mBAAmB,CACxB;YACE,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC;YAClD,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;SAC5B,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
// the right context. `contextId` is a routing param matcher validates ownership
|
|
18
18
|
// of, NOT a tenant field; no tenant field is accepted.
|
|
19
19
|
import { z } from 'zod';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { dispatchToolRequest } from '../shared-dispatch.js';
|
|
21
|
+
import { runPath, stripRuleStatKeys } from './shared.js';
|
|
22
22
|
/** Zod raw shape for `match_run_get` input — runId (path) + contextId (query, required). */
|
|
23
23
|
export const getMatchRunInputShape = {
|
|
24
24
|
runId: z
|
|
@@ -33,12 +33,12 @@ export const getMatchRunInputShape = {
|
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Fetch the run and return it with `stats` cleaned of the dynamic per-rule
|
|
36
|
-
* keys (see `stripRuleStatKeys`). Delegates to the shared `
|
|
36
|
+
* keys (see `stripRuleStatKeys`). Delegates to the shared `dispatchToolRequest`
|
|
37
37
|
* relay (fail-closed auth, RFC 9457 → tool-error mapping) and passes a
|
|
38
38
|
* success-body transform — the one matching read that post-processes the body.
|
|
39
39
|
*/
|
|
40
|
-
function fetchAndCleanRun(runId, contextId, extra
|
|
41
|
-
return
|
|
40
|
+
function fetchAndCleanRun(runId, contextId, extra) {
|
|
41
|
+
return dispatchToolRequest({ method: 'GET', path: runPath(runId), query: { contextId } }, extra, undefined, (run) => run !== undefined && run !== null
|
|
42
42
|
? {
|
|
43
43
|
...run,
|
|
44
44
|
stats: stripRuleStatKeys(run.stats),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/tools/matching/get.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,kEAAkE;AAClE,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,+CAA+C;AAC/C,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,uDAAuD;AAEvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/tools/matching/get.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,kEAAkE;AAClE,6EAA6E;AAC7E,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,+CAA+C;AAC/C,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,uDAAuD;AAEvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,E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,CAAA;AACH,CAAC"}
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
// is a REQUIRED QUERY param. `contextId` is a routing param matcher validates
|
|
11
11
|
// ownership of, NOT a tenant field; no tenant field is accepted.
|
|
12
12
|
import { z } from 'zod';
|
|
13
|
+
import { nextCursor, pageLimit } from '../input-fields.js';
|
|
13
14
|
import { SORT_ORDERS } from './list.js';
|
|
14
|
-
import {
|
|
15
|
+
import { dispatchToolRequest } from '../shared-dispatch.js';
|
|
16
|
+
import { runGroupsPath } from './shared.js';
|
|
15
17
|
/** Sort fields matcher accepts for the run-groups listing. */
|
|
16
18
|
export const GROUP_SORT_FIELDS = ['id', 'created_at', 'status'];
|
|
17
19
|
/**
|
|
@@ -28,18 +30,8 @@ export const getMatchRunGroupsInputShape = {
|
|
|
28
30
|
.min(1)
|
|
29
31
|
.describe('The reconciliation context id (UUID) the run belongs to. Sent as a query ' +
|
|
30
32
|
'param (required); routing param scoped to your token.'),
|
|
31
|
-
limit:
|
|
32
|
-
|
|
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).'),
|
|
33
|
+
limit: pageLimit,
|
|
34
|
+
cursor: nextCursor,
|
|
43
35
|
sort_order: z
|
|
44
36
|
.enum(SORT_ORDERS)
|
|
45
37
|
.optional()
|
|
@@ -88,7 +80,7 @@ export function registerMatchRunGroupsTool(server) {
|
|
|
88
80
|
'field is accepted.',
|
|
89
81
|
inputSchema: getMatchRunGroupsInputShape,
|
|
90
82
|
}, async (args, extra) => {
|
|
91
|
-
return
|
|
83
|
+
return dispatchToolRequest({
|
|
92
84
|
method: 'GET',
|
|
93
85
|
path: runGroupsPath(args.runId),
|
|
94
86
|
query: buildGroupsQuery(args),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../src/tools/matching/groups.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AACjD,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,iEAAiE;AAEjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../src/tools/matching/groups.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AACjD,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,iEAAiE;AAEjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAK1D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAA;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,+CAA+C,CAAC;IAC5D,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,2EAA2E;QACzE,uDAAuD,CAC1D;IACH,KAAK,E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EAAE,KAAK;YACb,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;YAC/B,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC;SAC9B,EACD,KAAK,CACN,CAAA;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -5,15 +5,87 @@
|
|
|
5
5
|
// RFC 9457 → tool-error mapping (toToolError) with every other curated surface,
|
|
6
6
|
// so they map matcher errors identically. No tool carries a tenant field;
|
|
7
7
|
// contextId is a routing param matcher validates ownership of.
|
|
8
|
+
//
|
|
9
|
+
// start is nothing but the context run path, a POST, a body built from the
|
|
10
|
+
// validated args and a description, so it is declared as one row; list, get and
|
|
11
|
+
// groups carry query builders or a result transform and stay as files. All four
|
|
12
|
+
// sit in ONE ordered list, because that list IS the order `tools/list` publishes.
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { registerCuratedTools } from '../curated-tool.js';
|
|
8
15
|
import { registerMatchRunGroupsTool } from './groups.js';
|
|
9
16
|
import { registerMatchRunGetTool } from './get.js';
|
|
10
17
|
import { registerMatchRunListTool } from './list.js';
|
|
11
|
-
import {
|
|
18
|
+
import { contextRunPath } from './shared.js';
|
|
19
|
+
/**
|
|
20
|
+
* Execution modes for a matching run.
|
|
21
|
+
* - DRY_RUN tests the context's rules and reports what WOULD match without
|
|
22
|
+
* committing any results.
|
|
23
|
+
* - COMMIT executes the rules and persists the resulting matches.
|
|
24
|
+
*/
|
|
25
|
+
const RUN_MODES = ['DRY_RUN', 'COMMIT'];
|
|
26
|
+
/**
|
|
27
|
+
* Zod raw shape for `match_run_start` input — contextId (path) + required mode.
|
|
28
|
+
* Exported because `spec/schema-parity.ts` diffs it against the vendored spec's
|
|
29
|
+
* RunMatchRequest; the row below is its only other consumer.
|
|
30
|
+
*/
|
|
31
|
+
export const startMatchRunInputShape = {
|
|
32
|
+
contextId: z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1)
|
|
35
|
+
.describe('The reconciliation context id (UUID) to run matching for. Routing param; ' +
|
|
36
|
+
'matcher validates it belongs to your tenant.'),
|
|
37
|
+
mode: z
|
|
38
|
+
.enum(RUN_MODES)
|
|
39
|
+
.describe('Execution mode. DRY_RUN tests the rules without committing any matches; ' +
|
|
40
|
+
'COMMIT executes the rules and persists the resulting matches.'),
|
|
41
|
+
async: z
|
|
42
|
+
.boolean()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe('Submit path (optional, default false). Both return 202 with ' +
|
|
45
|
+
'{ runId, status }; the status distinguishes them. Omit (or false) to ' +
|
|
46
|
+
'run in-request: the 202 carries the TERMINAL run (status COMPLETED or ' +
|
|
47
|
+
'FAILED). Set true to enqueue: the run is created QUEUED and a background ' +
|
|
48
|
+
'worker executes it — the 202 status is QUEUED and you poll match_run_get ' +
|
|
49
|
+
'with the runId until it reaches COMPLETED/FAILED.'),
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The family's four tools in published order: the one thin row, then the three
|
|
53
|
+
* that keep their own file. Every description string is the hand-tuned LLM
|
|
54
|
+
* guidance a client sees verbatim; the published-surface golden is what proves
|
|
55
|
+
* an edit here did not drop a character, or move a tool.
|
|
56
|
+
*/
|
|
57
|
+
const MATCHING_TOOLS = [
|
|
58
|
+
{
|
|
59
|
+
name: 'match_run_start',
|
|
60
|
+
description: 'Trigger a matching run for a reconciliation context. Both submit paths ' +
|
|
61
|
+
'return 202 with { runId, status }; the status distinguishes them. Omit ' +
|
|
62
|
+
'async (or set false) to run in-request: the 202 carries the TERMINAL run ' +
|
|
63
|
+
'(status COMPLETED or FAILED). Set async:true to enqueue: the run is ' +
|
|
64
|
+
'created QUEUED and a background worker executes it (202 status QUEUED) — ' +
|
|
65
|
+
'poll match_run_get with the runId to follow progress (this tool does not ' +
|
|
66
|
+
'auto-poll). mode is required: DRY_RUN tests rules without committing, ' +
|
|
67
|
+
'COMMIT persists the matches. contextId is a routing param scoped to your ' +
|
|
68
|
+
'token (no tenant field is accepted). Returns the acceptance body, or a ' +
|
|
69
|
+
'structured RFC 9457 error (e.g. 422 when the rule set is not ' +
|
|
70
|
+
'stream-bounded and cannot run at unbounded scale).',
|
|
71
|
+
inputShape: startMatchRunInputShape,
|
|
72
|
+
request: (args) => ({
|
|
73
|
+
method: 'POST',
|
|
74
|
+
path: contextRunPath(String(args.contextId)),
|
|
75
|
+
// `async` is omitted unless the caller set it — RunMatchRequest forbids
|
|
76
|
+
// unknown properties, so the body stays exactly what was asked for.
|
|
77
|
+
body: {
|
|
78
|
+
mode: args.mode,
|
|
79
|
+
...(args.async === undefined ? {} : { async: args.async }),
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
registerMatchRunListTool,
|
|
84
|
+
registerMatchRunGetTool,
|
|
85
|
+
registerMatchRunGroupsTool,
|
|
86
|
+
];
|
|
12
87
|
/** Register all four curated match-run tools on the given server. */
|
|
13
88
|
export function registerMatchingTools(server) {
|
|
14
|
-
|
|
15
|
-
registerMatchRunListTool(server);
|
|
16
|
-
registerMatchRunGetTool(server);
|
|
17
|
-
registerMatchRunGroupsTool(server);
|
|
89
|
+
registerCuratedTools(server, MATCHING_TOOLS);
|
|
18
90
|
}
|
|
19
91
|
//# sourceMappingURL=index.js.map
|