@lerianstudio/matcher-mcp 5.0.0-beta.14 → 5.0.0-beta.140
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 +29 -14
- package/dist/auth/request-token.js +11 -69
- package/dist/auth/request-token.js.map +1 -1
- package/dist/config.js +19 -85
- 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/system-prompt.js +17 -2
- package/dist/copilot/system-prompt.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 +1 -1
- package/dist/matcher/client.js.map +1 -1
- package/dist/matcher/idempotency.js +1 -1
- package/dist/matcher/idempotency.js.map +1 -1
- package/dist/observability/otel.js +86 -125
- 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 +114 -98
- 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/index.js +1 -1
- package/dist/spec/index.js.map +1 -1
- package/dist/spec/openapi.yaml +901 -74
- package/dist/spec/schema-parity.js +25 -30
- package/dist/spec/schema-parity.js.map +1 -1
- package/dist/tools/context/create.js +16 -5
- 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 +10 -36
- package/dist/tools/context/list.js.map +1 -1
- package/dist/tools/context/setup-progress.js +4 -3
- package/dist/tools/context/setup-progress.js.map +1 -1
- package/dist/tools/context/shared.js +5 -53
- package/dist/tools/context/shared.js.map +1 -1
- package/dist/tools/context/update.js +15 -7
- package/dist/tools/context/update.js.map +1 -1
- package/dist/tools/curated-tool.js +37 -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 -76
- 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 +19 -48
- package/dist/tools/dispute/list.js.map +1 -1
- package/dist/tools/dispute/shared.js +4 -50
- 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 +3 -2
- 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 +3 -2
- 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 +10 -26
- 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 +17 -60
- 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 +3 -51
- 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 +10 -30
- package/dist/tools/fee-rule/list.js.map +1 -1
- package/dist/tools/fee-rule/shared.js +3 -53
- 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 +9 -4
- 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 +9 -25
- package/dist/tools/fee-schedule/list.js.map +1 -1
- package/dist/tools/fee-schedule/shared.js +4 -50
- 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 +4 -3
- 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 +10 -30
- package/dist/tools/field-map/list.js.map +1 -1
- package/dist/tools/field-map/shared.js +21 -73
- package/dist/tools/field-map/shared.js.map +1 -1
- package/dist/tools/field-map/update.js +6 -4
- package/dist/tools/field-map/update.js.map +1 -1
- package/dist/tools/generic/describe-operation.js +2 -8
- package/dist/tools/generic/describe-operation.js.map +1 -1
- package/dist/tools/generic/invoke.js +5 -40
- package/dist/tools/generic/invoke.js.map +1 -1
- package/dist/tools/generic/list-operations.js +1 -1
- package/dist/tools/generic/list-operations.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 +12 -42
- package/dist/tools/ingestion/job-transactions-list.js.map +1 -1
- package/dist/tools/ingestion/jobs-list.js +11 -37
- package/dist/tools/ingestion/jobs-list.js.map +1 -1
- package/dist/tools/ingestion/shared.js +3 -49
- package/dist/tools/ingestion/shared.js.map +1 -1
- package/dist/tools/ingestion/transactions-search.js +11 -46
- package/dist/tools/ingestion/transactions-search.js.map +1 -1
- package/dist/tools/ingestion/upload-begin.js +1 -1
- 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 +10 -34
- package/dist/tools/match-rule/list.js.map +1 -1
- package/dist/tools/match-rule/shared.js +14 -53
- 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 +6 -6
- package/dist/tools/matching/get.js.map +1 -1
- package/dist/tools/matching/groups.js +7 -15
- 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 +10 -33
- package/dist/tools/matching/list.js.map +1 -1
- package/dist/tools/matching/shared.js +3 -52
- 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 +264 -30
- package/dist/tools/report/index.js.map +1 -1
- package/dist/tools/report/shared.js +21 -106
- 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 +42 -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 +10 -33
- package/dist/tools/source/list.js.map +1 -1
- package/dist/tools/source/shared.js +3 -48
- 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 +27 -41
- package/dist/tools/workspace/usage.js.map +1 -1
- package/dist/transport/body-limit.js +1 -6
- package/dist/transport/body-limit.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
package/README.md
CHANGED
|
@@ -44,13 +44,16 @@ as the matcher app, which also pins the embedded OpenAPI spec to the matched
|
|
|
44
44
|
matcher version. The bearer token the relay forwards is never baked into the
|
|
45
45
|
image.
|
|
46
46
|
|
|
47
|
-
It speaks **Streamable HTTP** and binds `MCP_PORT` (default `4019`)
|
|
48
|
-
|
|
47
|
+
It speaks **Streamable HTTP** and binds `MCP_PORT` (default `4019`). The server
|
|
48
|
+
also hosts the optional console copilot and voice routes:
|
|
49
49
|
|
|
50
50
|
| Method | Path | Purpose |
|
|
51
51
|
|--------|------------|--------------------------------------------------|
|
|
52
52
|
| `GET` | `/healthz` | Plain liveness probe. |
|
|
53
53
|
| `POST` | `/mcp` | The Streamable HTTP MCP endpoint clients connect to. |
|
|
54
|
+
| `POST` | `/agent/turns` | Stream an authenticated copilot turn when a provider is configured. |
|
|
55
|
+
| `GET` | `/agent/transcribe` | Report voice-transcription availability for the authenticated caller. |
|
|
56
|
+
| `POST` | `/agent/transcribe` | Transcribe an authenticated voice recording when configured. |
|
|
54
57
|
|
|
55
58
|
Point any Streamable-HTTP MCP client at `POST /mcp` and send the matcher bearer
|
|
56
59
|
token as the `Authorization` header.
|
|
@@ -73,6 +76,9 @@ Three options for `<mcp-url>`:
|
|
|
73
76
|
- **Local matcher dev (repo clone).** `make up` brings the relay up as a compose
|
|
74
77
|
service on `:4019` alongside the rest of the stack (`restart: unless-stopped`,
|
|
75
78
|
so it stays up — no separate process to babysit). Use `http://localhost:4019/mcp`.
|
|
79
|
+
If Matcher runs on the host, stop both Compose `app` and `mcp` first and start
|
|
80
|
+
the host relay with `MATCHER_API_URL=http://localhost:4018`; the Compose relay
|
|
81
|
+
targets the Docker-only name `app:4018`. See [`../docs/development.md`](../docs/development.md).
|
|
76
82
|
- **Run it standalone with `npx`.** `@lerianstudio/matcher-mcp` is a **public**
|
|
77
83
|
package (Apache-2.0) — no registry auth needed. Start the relay (binds `:4019`)
|
|
78
84
|
pointed at your Matcher API:
|
|
@@ -186,7 +192,7 @@ degrading to a default. Env names mirror the matcher Go service.
|
|
|
186
192
|
| `MCP_PORT` | `4019` | Port the Streamable HTTP server binds (4018 is matcher, so this avoids a dev collision). |
|
|
187
193
|
| `MATCHER_API_URL` | `http://localhost:4018` | Base URL the relay's own HTTP client calls for every proxied tool. In cluster deployments this is normally an internal service DNS name. Trailing slashes are trimmed. |
|
|
188
194
|
| `MATCHER_PUBLIC_API_URL` | same as `MATCHER_API_URL` | Base URL handed back to the client's own Claude as the upload target by `ingestion_upload_begin`. MUST be client-reachable. Set this separately from `MATCHER_API_URL` when the relay's internal address isn't reachable from outside the cluster (hairpin NAT). Trailing slashes are trimmed. |
|
|
189
|
-
| `MATCHER_TIMEOUT_MS` | `30000` | Per-request timeout the matcher HTTP client enforces via `AbortController`, matching matcher's 30s transaction timeout. |
|
|
195
|
+
| `MATCHER_TIMEOUT_MS` | `30000` | Per-request timeout the matcher HTTP client enforces via `AbortController`, matching matcher's 30s transaction timeout. Integer `1..2147483647`, the Node timer ceiling. |
|
|
190
196
|
| `MAX_BODY_BYTES` | `1048576` (1 MiB) | Maximum accepted inbound request body size; the transport rejects an over-limit body with `413` before parsing, so an unbounded read cannot exhaust memory. |
|
|
191
197
|
| `ENABLE_TELEMETRY` | `false` | Whether OpenTelemetry traces + metrics are exported. **Off** by default. |
|
|
192
198
|
| `OTEL_EXPORTER_OTLP_ENDPOINT` | _(SDK default)_ | OTLP HTTP endpoint traces + metrics export to when telemetry is enabled. When unset, the OTel SDK falls back to its own default (`localhost:4318`). |
|
|
@@ -215,7 +221,7 @@ read server-side only, never sent to the browser.
|
|
|
215
221
|
| `OPENROUTER_API_KEY` | _(unset)_ | OpenRouter API key. Required when `COPILOT_PROVIDER=openrouter`. Never logged, never returned. |
|
|
216
222
|
| `COPILOT_MODEL` | _(provider default)_ | Model id passed to the selected provider. Anthropic falls back to its own default when unset; OpenRouter has **no** safe default and requires `COPILOT_MODEL` to be set explicitly (an Anthropic id 404s there), otherwise provider construction raises `CopilotModelRequiredError`. |
|
|
217
223
|
| `COPILOT_MAX_TOOL_ITERATIONS` | `8` | Max read-tool rounds the agent loop runs before forcing a stop. Integer `1..20`. |
|
|
218
|
-
| `COPILOT_MAX_TURN_TOKENS` | `
|
|
224
|
+
| `COPILOT_MAX_TURN_TOKENS` | `400000` | Per-turn ceiling on accumulated input+output; the loop truncates between rounds once crossed. Sized to clear a full 8-round turn at the measured ~39.7k tokens/round (2026-09-08), so `COPILOT_MAX_TOOL_ITERATIONS` is what stops a turn. Not a reservation and not a context-window limit — it is compared against usage already billed, so raising it costs nothing on a turn that ends normally. |
|
|
219
225
|
| `COPILOT_RATE_LIMIT_PER_MIN` | `60` | Per-tenant token-bucket refill rate (turns/min). Per-tenant-overridable. |
|
|
220
226
|
| `COPILOT_RATE_LIMIT_BURST` | `20` | Per-tenant token-bucket burst capacity. Per-tenant-overridable. |
|
|
221
227
|
| `COPILOT_TENANT_CONFIG_PATH` | _(unset)_ | Path to a JSON file mapping `tenantId → { provider, model?, apiKey, maxTurnTokens?, rateLimitPerMin?, rateLimitBurst? }` for per-tenant provider/key overrides. Unset = one global config (BYOC single-tenant). |
|
|
@@ -264,13 +270,14 @@ full embedded OpenAPI spec.
|
|
|
264
270
|
| `fee_schedule_*` | Manage fee schedules — create, list, get, update, delete, and simulate. |
|
|
265
271
|
| `fee_rule_*` | Manage fee rules attached to schedules — create, list, get, update, delete. |
|
|
266
272
|
| `match_rule_*` | Manage a context's match rules — create, list, get, update, delete, reorder. |
|
|
267
|
-
| `context_*` | Manage reconciliation contexts — create, list, get, update,
|
|
268
|
-
| `source_*` | Manage a context's data sources — create, list, get, update,
|
|
273
|
+
| `context_*` | Manage reconciliation contexts — create, list, get, update, archive, restore, setup progress, and next-step guidance. |
|
|
274
|
+
| `source_*` | Manage a context's data sources — create, list, get, update, archive, and restore. |
|
|
275
|
+
| `field_map_*` | Manage field maps — create, list by context, get by source, update, and delete. |
|
|
269
276
|
| `match_run_*` | Drive reconciliation runs — start a run, list runs, get a run, inspect match groups. |
|
|
270
277
|
| `exception_*` | Work reconciliation exceptions — list/get, history and comments (list/add/delete), per-exception action verbs (dispatch, open-dispute, force-match, adjust-entry), and cross-exception bulk actions (assign/resolve/dispatch). |
|
|
271
278
|
| `dispute_*` | Manage the dispute lifecycle — list, get, close, submit evidence. |
|
|
272
|
-
| `ingestion_*` | Inspect a context's import lifecycle — list jobs, get a job, list a job's per-row errors and transactions, search transactions, ignore a transaction
|
|
273
|
-
| `dashboard_*` | Read
|
|
279
|
+
| `ingestion_*` | Inspect a context's import lifecycle — list jobs, get a job, list a job's per-row errors and transactions, search transactions, ignore a transaction, and upload files through `ingestion_upload` or `ingestion_upload_begin`. |
|
|
280
|
+
| `dashboard_*` | Read combined aggregates and focused slices (cash-impact, match-rate, metrics, SLA, source-breakdown, volume). The console uses the aggregate for volume, match rate and SLA, plus separate metrics, source-breakdown and cash-impact queries. Only standalone volume, match-rate and SLA reads have no console consumer. |
|
|
274
281
|
| `report_*` | Pull a context's reports — paginated matched/unmatched/variance reads, the summary read, four counts (exceptions/matched/unmatched/transactions), and five base64 exports (exceptions/matched/summary/unmatched/variance). |
|
|
275
282
|
| `workspace_usage` | Read the caller's own commercial state and free-tier consumption — plan, billing status, both trial axes (days remaining, matched lines against the cap), the expiry verdict, and the derived percentage consumed. Takes no arguments; the workspace comes from the relayed credential. |
|
|
276
283
|
|
|
@@ -288,11 +295,16 @@ HTTP client and a single token relay, so both surfaces map matcher errors
|
|
|
288
295
|
|
|
289
296
|
### Intentionally not curated
|
|
290
297
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
298
|
+
`uploadFile` has curated replacements. Use `ingestion_upload` for a small
|
|
299
|
+
base64-in-JSON payload or `ingestion_upload_begin` for a real local file; the
|
|
300
|
+
relay rebuilds or brokers the multipart request. `matcher_invoke` cannot build
|
|
301
|
+
that binary body and points callers to the curated tools.
|
|
302
|
+
|
|
303
|
+
`extractDocument` accepts a raw document body and has no MCP path today; call
|
|
304
|
+
the Matcher HTTP API directly for that operation. Inbound callback and webhook
|
|
305
|
+
receivers (`processCallback`, aggregator webhooks, and hub events) stay
|
|
306
|
+
generic-only because they are machine- or hub-initiated deliveries rather than
|
|
307
|
+
operator actions.
|
|
296
308
|
|
|
297
309
|
## Project layout
|
|
298
310
|
|
|
@@ -309,7 +321,7 @@ mcp/
|
|
|
309
321
|
└── src/
|
|
310
322
|
├── server.ts # entry point: builds the per-request server, wires tools + telemetry
|
|
311
323
|
├── config.ts # frozen, fail-loud bootstrap config
|
|
312
|
-
├── transport/ #
|
|
324
|
+
├── transport/ # HTTP routing for /healthz, /mcp, /agent/turns and /agent/transcribe
|
|
313
325
|
├── auth/ # request-scoped fail-closed bearer-token relay
|
|
314
326
|
├── matcher/ # Matcher HTTP client
|
|
315
327
|
├── observability/ # OpenTelemetry init + token-free tool instrumentation
|
|
@@ -330,6 +342,9 @@ pnpm test # run vitest
|
|
|
330
342
|
pnpm dev # run with --watch
|
|
331
343
|
```
|
|
332
344
|
|
|
345
|
+
For the Compose and host-process topologies, including the `:4018`/`:4019`
|
|
346
|
+
proxy variables used by the UI, see [`../docs/development.md`](../docs/development.md).
|
|
347
|
+
|
|
333
348
|
## Toolchain
|
|
334
349
|
|
|
335
350
|
Mirrors the `ui/` sub-project: **pnpm** (`pnpm@11.5.2`), Node `>=22`, ESLint flat
|
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
// Request-scoped
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// owns that contract:
|
|
6
|
-
//
|
|
7
|
-
// - `runWithBearerToken(token, fn)` seeds an AsyncLocalStorage store at the
|
|
8
|
-
// HTTP boundary (transport/http.ts) so handlers can recover the token even
|
|
9
|
-
// when the SDK does not thread request headers through `extra`.
|
|
10
|
-
// - `getRequestBearerToken(extra?)` returns the current caller's token,
|
|
11
|
-
// preferring the SDK-native `extra.requestInfo.headers.authorization` when
|
|
12
|
-
// present and falling back to the ALS store seeded at the boundary.
|
|
13
|
-
// - `requireMatcherClient(extra?)` is the single chokepoint tools call: it
|
|
14
|
-
// reads the token, throws `UnauthenticatedError` when it is missing / empty
|
|
15
|
-
// / not a Bearer credential, and otherwise builds a per-request
|
|
16
|
-
// `MatcherClient` from it.
|
|
17
|
-
//
|
|
18
|
-
// Security invariants (asserted by tests):
|
|
19
|
-
// - The token is NEVER logged and NEVER placed in an error message.
|
|
20
|
-
// - The tenant id MAY be decoded from the relayed JWT (getRequestTenantId),
|
|
21
|
-
// but ONLY unverified and KEY-ONLY: used solely to SCOPE config, limits, and
|
|
22
|
-
// telemetry to an organization, NEVER as an authorization input. Matcher
|
|
23
|
-
// still owns enforcement via the verbatim relayed token, so the tenant
|
|
24
|
-
// third rail stays intact (the decode is not trusted for authz). The token
|
|
25
|
-
// and its decoded claims are never logged.
|
|
1
|
+
// Request-scoped caller-token relay; data tools fail closed without credentials.
|
|
2
|
+
// SDK request headers take precedence over the transport's AsyncLocalStorage.
|
|
3
|
+
// Never log tokens or claims. Unverified tenant claims scope config, limits and
|
|
4
|
+
// telemetry only; Matcher authorizes using the verbatim relayed bearer token.
|
|
26
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
27
6
|
import { loadConfig } from '../config.js';
|
|
28
7
|
import { createMatcherClient } from '../matcher/client.js';
|
|
29
8
|
const authStorage = new AsyncLocalStorage();
|
|
30
|
-
/**
|
|
31
|
-
* Operator-facing remediation text shown when the caller did not relay a usable
|
|
32
|
-
* bearer token. It deliberately contains no token material and no internal
|
|
33
|
-
* detail — just what the operator must do to fix their connection.
|
|
34
|
-
*/
|
|
9
|
+
/** Credential remediation without token material or internal details. */
|
|
35
10
|
export const UNAUTHENTICATED_REMEDIATION = 'No matcher credential was provided. Configure your MCP client to send an ' +
|
|
36
11
|
'`Authorization: Bearer <your-matcher-jwt>` header on each request, then ' +
|
|
37
12
|
'retry. This server holds no credentials of its own and relays yours verbatim.';
|
|
38
|
-
/**
|
|
39
|
-
* Thrown when a tool requires the caller's matcher credential but none was
|
|
40
|
-
* relayed (missing, empty, or not a Bearer credential). Carries only the
|
|
41
|
-
* operator remediation text — never any token material.
|
|
42
|
-
*/
|
|
13
|
+
/** Missing or unusable caller credential; contains remediation, never the token. */
|
|
43
14
|
export class UnauthenticatedError extends Error {
|
|
44
15
|
constructor(message = UNAUTHENTICATED_REMEDIATION) {
|
|
45
16
|
super(message);
|
|
@@ -84,17 +55,7 @@ function parseBearer(authorization) {
|
|
|
84
55
|
const token = match[1]?.trim();
|
|
85
56
|
return token && token.length > 0 ? token : undefined;
|
|
86
57
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Resolve the current caller's bearer token, request-scoped.
|
|
89
|
-
*
|
|
90
|
-
* Resolution order:
|
|
91
|
-
* 1. SDK-native `extra.requestInfo.headers.authorization`, when the handler
|
|
92
|
-
* was given an `extra` carrying request headers.
|
|
93
|
-
* 2. The ALS store seeded by `runWithBearerToken` at the HTTP boundary.
|
|
94
|
-
*
|
|
95
|
-
* Returns `undefined` when no usable Bearer credential is present (missing,
|
|
96
|
-
* empty, or non-Bearer scheme) — callers fail closed on that.
|
|
97
|
-
*/
|
|
58
|
+
/** Prefer a usable SDK bearer, then transport ALS; absent credentials fail closed. */
|
|
98
59
|
export function getRequestBearerToken(extra) {
|
|
99
60
|
const fromExtra = parseBearer(authorizationFromExtra(extra));
|
|
100
61
|
if (fromExtra) {
|
|
@@ -103,20 +64,9 @@ export function getRequestBearerToken(extra) {
|
|
|
103
64
|
return parseBearer(authStorage.getStore()?.authorization);
|
|
104
65
|
}
|
|
105
66
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* via the verbatim relayed token, so the tenant third rail stays intact even
|
|
110
|
-
* though this reads the claim.
|
|
111
|
-
*
|
|
112
|
-
* Reads the same request-scoped bearer `getRequestBearerToken` resolves, splits
|
|
113
|
-
* the JWT, base64url-decodes the payload segment (Node stdlib `Buffer` — NO JWT
|
|
114
|
-
* library), and reads the tenant claim. Matches the Go/lib-auth extraction order
|
|
115
|
-
* (`claimString(claims, "tenant_id", "tenantId")`): prefers `tenant_id`, then
|
|
116
|
-
* `tenantId`. Returns `undefined` on ANY malformed/absent token or a
|
|
117
|
-
* missing/non-string/empty claim, and NEVER throws — a decode failure fails open
|
|
118
|
-
* to the global-config path rather than breaking the turn. The token and its
|
|
119
|
-
* claims are never logged.
|
|
67
|
+
* Unverified tenant key for config, limits and telemetry — NEVER authorization.
|
|
68
|
+
* Prefers tenant_id to tenantId. Malformed/absent claims yield undefined and
|
|
69
|
+
* select global config; neither the token nor its claims may enter logs.
|
|
120
70
|
*/
|
|
121
71
|
export function getRequestTenantId(extra) {
|
|
122
72
|
const token = getRequestBearerToken(extra);
|
|
@@ -146,15 +96,7 @@ export function getRequestTenantId(extra) {
|
|
|
146
96
|
return undefined;
|
|
147
97
|
}
|
|
148
98
|
}
|
|
149
|
-
/**
|
|
150
|
-
* The single chokepoint every matcher-touching tool calls. Reads the caller's
|
|
151
|
-
* request-scoped token and, when present, returns a `MatcherClient` bound to it.
|
|
152
|
-
* Fails closed with `UnauthenticatedError` when the token is absent / empty /
|
|
153
|
-
* not a Bearer credential.
|
|
154
|
-
*
|
|
155
|
-
* `config` is injectable for tests; production callers pass nothing and get the
|
|
156
|
-
* process config.
|
|
157
|
-
*/
|
|
99
|
+
/** Build a caller-bound client or fail closed; config is injectable for tests. */
|
|
158
100
|
export function requireMatcherClient(extra, config = loadConfig()) {
|
|
159
101
|
const token = getRequestBearerToken(extra);
|
|
160
102
|
if (!token) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-token.js","sourceRoot":"","sources":["../../src/auth/request-token.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"request-token.js","sourceRoot":"","sources":["../../src/auth/request-token.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAsB,MAAM,sBAAsB,CAAA;AAQ9E,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAoB,CAAA;AAE7D,yEAAyE;AACzE,MAAM,CAAC,MAAM,2BAA2B,GACtC,2EAA2E;IAC3E,0EAA0E;IAC1E,+EAA+E,CAAA;AAEjF,oFAAoF;AACpF,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C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,CAAA;QAClD,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,8EAA8E;QAC9E,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,oBAAoB,CAClC,KAAwB,EACxB,SAAiB,UAAU,EAAE;IAE7B,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,oBAAoB,EAAE,CAAA;IAClC,CAAC;IACD,OAAO,mBAAmB,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;AACzD,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Values are read from the environment once and frozen into a typed object.
|
|
4
|
-
// Defaults are chosen to avoid collisions with matcher dev (matcher runs on
|
|
5
|
-
// 4018; this server defaults to 4019). The matcher base URL is surfaced here
|
|
6
|
-
// so the HTTP client (task 1.3.1) and the generic invoke / curated tools
|
|
7
|
-
// consume a single source of truth instead of reading process.env directly.
|
|
1
|
+
// Environment configuration is loaded once and frozen for all relay consumers.
|
|
8
2
|
import { loadTenantConfig } from './copilot/tenant-config.js';
|
|
9
3
|
const DEFAULT_PORT = 4019;
|
|
10
4
|
const DEFAULT_MATCHER_API_URL = 'http://localhost:4018';
|
|
@@ -13,52 +7,25 @@ const DEFAULT_MAX_BODY_BYTES = 1_048_576; // 1 MiB
|
|
|
13
7
|
const DEFAULT_OTEL_SERVICE_NAME = 'matcher-mcp';
|
|
14
8
|
const DEFAULT_COPILOT_PROVIDER = 'anthropic';
|
|
15
9
|
const DEFAULT_COPILOT_MAX_TOOL_ITERATIONS = 8;
|
|
16
|
-
const DEFAULT_COPILOT_MAX_TURN_TOKENS =
|
|
10
|
+
const DEFAULT_COPILOT_MAX_TURN_TOKENS = 400_000;
|
|
17
11
|
const DEFAULT_COPILOT_RATE_LIMIT_PER_MIN = 60;
|
|
18
12
|
const DEFAULT_COPILOT_RATE_LIMIT_BURST = 20;
|
|
19
13
|
const DEFAULT_SPEECH_TRANSCRIPTION_REGION = 'sa-east-1';
|
|
14
|
+
/** Node fires any timer longer than this after 1 ms instead of waiting. */
|
|
15
|
+
const MAX_TIMER_MS = 2_147_483_647;
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
17
|
+
* Default an unset integer; an explicitly-set value that is not a decimal
|
|
18
|
+
* integer in 1..max throws (fail-loud at boot). Exponent form is accepted:
|
|
19
|
+
* Helm renders an unquoted value of 1e6 or more as `2.097152e+06`.
|
|
24
20
|
*/
|
|
25
|
-
function
|
|
21
|
+
function parseBoundedInt(raw, fallback, key, expected, max = Number.MAX_SAFE_INTEGER) {
|
|
26
22
|
if (raw === undefined || raw === '') {
|
|
27
23
|
return fallback;
|
|
28
24
|
}
|
|
29
25
|
const value = Number(raw);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse a positive timeout (ms) from a raw env string, falling back to the
|
|
37
|
-
* default when unset. An explicitly-set but invalid value is a misconfiguration
|
|
38
|
-
* and throws, rather than silently degrading to the default (fail-loud at boot).
|
|
39
|
-
*/
|
|
40
|
-
function parseTimeoutMs(raw, fallback) {
|
|
41
|
-
if (raw === undefined || raw === '') {
|
|
42
|
-
return fallback;
|
|
43
|
-
}
|
|
44
|
-
const value = Number(raw);
|
|
45
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
46
|
-
throw new Error(`invalid MATCHER_TIMEOUT_MS: ${raw} (expected a positive integer of milliseconds)`);
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Parse a positive byte count from a raw env string, falling back to the default
|
|
52
|
-
* when unset. An explicitly-set but invalid value is a misconfiguration and
|
|
53
|
-
* throws, rather than silently degrading to the default (fail-loud at boot).
|
|
54
|
-
*/
|
|
55
|
-
function parseMaxBodyBytes(raw, fallback) {
|
|
56
|
-
if (raw === undefined || raw === '') {
|
|
57
|
-
return fallback;
|
|
58
|
-
}
|
|
59
|
-
const value = Number(raw);
|
|
60
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
61
|
-
throw new Error(`invalid MAX_BODY_BYTES: ${raw} (expected a positive integer of bytes)`);
|
|
26
|
+
const decimal = /^\d+(\.\d+)?(e\+?\d+)?$/.test(raw);
|
|
27
|
+
if (!decimal || !Number.isInteger(value) || value < 1 || value > max) {
|
|
28
|
+
throw new Error(`invalid ${key}: ${raw} (expected ${expected})`);
|
|
62
29
|
}
|
|
63
30
|
return value;
|
|
64
31
|
}
|
|
@@ -82,10 +49,7 @@ function parseBool(raw, fallback, key) {
|
|
|
82
49
|
throw new Error(`invalid ${key}: ${raw} (expected one of true, false, 1, 0)`);
|
|
83
50
|
}
|
|
84
51
|
/**
|
|
85
|
-
*
|
|
86
|
-
* when unset. Trimmed + case-insensitive. An explicitly-set but unrecognized
|
|
87
|
-
* value is a misconfiguration and throws, rather than silently coercing to a
|
|
88
|
-
* default (fail-loud at boot), mirroring parseBool.
|
|
52
|
+
* Default an unset provider; trim and case-fold explicit names, rejecting unknowns.
|
|
89
53
|
*/
|
|
90
54
|
function parseCopilotProvider(raw, fallback) {
|
|
91
55
|
if (raw === undefined || raw === '') {
|
|
@@ -97,36 +61,6 @@ function parseCopilotProvider(raw, fallback) {
|
|
|
97
61
|
}
|
|
98
62
|
throw new Error(`invalid COPILOT_PROVIDER: ${raw} (expected one of anthropic, openrouter)`);
|
|
99
63
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Parse the agent-loop iteration cap from a raw env string, falling back to the
|
|
102
|
-
* default when unset. Bounded to 1..20. An explicitly-set but out-of-range or
|
|
103
|
-
* non-integer value is a misconfiguration and throws (fail-loud at boot).
|
|
104
|
-
*/
|
|
105
|
-
function parseMaxToolIterations(raw, fallback) {
|
|
106
|
-
if (raw === undefined || raw === '') {
|
|
107
|
-
return fallback;
|
|
108
|
-
}
|
|
109
|
-
const value = Number(raw);
|
|
110
|
-
if (!Number.isInteger(value) || value < 1 || value > 20) {
|
|
111
|
-
throw new Error(`invalid COPILOT_MAX_TOOL_ITERATIONS: ${raw} (expected an integer in 1..20)`);
|
|
112
|
-
}
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Parse a positive integer from a raw env string, falling back to the default
|
|
117
|
-
* when unset. An explicitly-set non-positive or non-integer value is a
|
|
118
|
-
* misconfiguration and throws (fail-loud at boot), mirroring parseMaxBodyBytes.
|
|
119
|
-
*/
|
|
120
|
-
function parsePositiveInt(raw, fallback, key) {
|
|
121
|
-
if (raw === undefined || raw === '') {
|
|
122
|
-
return fallback;
|
|
123
|
-
}
|
|
124
|
-
const value = Number(raw);
|
|
125
|
-
if (!Number.isInteger(value) || value < 1) {
|
|
126
|
-
throw new Error(`invalid ${key}: ${raw} (expected a positive integer)`);
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
64
|
/**
|
|
131
65
|
* Parse the speech-transcription endpoint. Unset means the capability is absent
|
|
132
66
|
* (the shipping default, not an error). An explicitly-set value that is not an
|
|
@@ -162,11 +96,11 @@ export function loadConfig(env = process.env) {
|
|
|
162
96
|
const otelEndpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
|
|
163
97
|
const otelServiceName = env.OTEL_RESOURCE_SERVICE_NAME?.trim() || DEFAULT_OTEL_SERVICE_NAME;
|
|
164
98
|
return Object.freeze({
|
|
165
|
-
port:
|
|
99
|
+
port: parseBoundedInt(env.MCP_PORT, DEFAULT_PORT, 'MCP_PORT', 'an integer in 1..65535', 65535),
|
|
166
100
|
matcherApiUrl: matcherApiUrl.replace(/\/+$/, ''),
|
|
167
101
|
matcherPublicApiUrl: matcherPublicApiUrl.replace(/\/+$/, ''),
|
|
168
|
-
timeoutMs:
|
|
169
|
-
maxBodyBytes:
|
|
102
|
+
timeoutMs: parseBoundedInt(env.MATCHER_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, 'MATCHER_TIMEOUT_MS', 'an integer of milliseconds in 1..2147483647', MAX_TIMER_MS),
|
|
103
|
+
maxBodyBytes: parseBoundedInt(env.MAX_BODY_BYTES, DEFAULT_MAX_BODY_BYTES, 'MAX_BODY_BYTES', 'a positive integer of bytes'),
|
|
170
104
|
enableTelemetry: parseBool(env.ENABLE_TELEMETRY, false, 'ENABLE_TELEMETRY'),
|
|
171
105
|
otelExporterOtlpEndpoint: otelEndpoint || undefined,
|
|
172
106
|
otelServiceName,
|
|
@@ -174,10 +108,10 @@ export function loadConfig(env = process.env) {
|
|
|
174
108
|
openrouterApiKey: env.OPENROUTER_API_KEY?.trim() || undefined,
|
|
175
109
|
copilotProvider: parseCopilotProvider(env.COPILOT_PROVIDER, DEFAULT_COPILOT_PROVIDER),
|
|
176
110
|
copilotModel: env.COPILOT_MODEL?.trim() || undefined,
|
|
177
|
-
copilotMaxToolIterations:
|
|
178
|
-
copilotMaxTurnTokens:
|
|
179
|
-
copilotRateLimitPerMin:
|
|
180
|
-
copilotRateLimitBurst:
|
|
111
|
+
copilotMaxToolIterations: parseBoundedInt(env.COPILOT_MAX_TOOL_ITERATIONS, DEFAULT_COPILOT_MAX_TOOL_ITERATIONS, 'COPILOT_MAX_TOOL_ITERATIONS', 'an integer in 1..20', 20),
|
|
112
|
+
copilotMaxTurnTokens: parseBoundedInt(env.COPILOT_MAX_TURN_TOKENS, DEFAULT_COPILOT_MAX_TURN_TOKENS, 'COPILOT_MAX_TURN_TOKENS', 'a positive integer'),
|
|
113
|
+
copilotRateLimitPerMin: parseBoundedInt(env.COPILOT_RATE_LIMIT_PER_MIN, DEFAULT_COPILOT_RATE_LIMIT_PER_MIN, 'COPILOT_RATE_LIMIT_PER_MIN', 'a positive integer'),
|
|
114
|
+
copilotRateLimitBurst: parseBoundedInt(env.COPILOT_RATE_LIMIT_BURST, DEFAULT_COPILOT_RATE_LIMIT_BURST, 'COPILOT_RATE_LIMIT_BURST', 'a positive integer'),
|
|
181
115
|
speechTranscriptionEndpoint: parseSpeechEndpoint(env.SPEECH_TRANSCRIPTION_ENDPOINT),
|
|
182
116
|
speechTranscriptionRegion: env.SPEECH_TRANSCRIPTION_REGION?.trim() || DEFAULT_SPEECH_TRANSCRIPTION_REGION,
|
|
183
117
|
speechTranscriptionApiKey: env.SPEECH_TRANSCRIPTION_API_KEY?.trim() || undefined,
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,EAAE,gBAAgB,EAA+B,MAAM,4BAA4B,CAAA;AA+I1F,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,uBAAuB,GAAG,uBAAuB,CAAA;AACvD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,MAAM,sBAAsB,GAAG,SAAS,CAAA,CAAC,QAAQ;AACjD,MAAM,yBAAyB,GAAG,aAAa,CAAA;AAC/C,MAAM,wBAAwB,GAAG,WAAW,CAAA;AAC5C,MAAM,mCAAmC,GAAG,CAAC,CAAA;AAC7C,MAAM,+BAA+B,GAAG,OAAO,CAAA;AAC/C,MAAM,kCAAkC,GAAG,EAAE,CAAA;AAC7C,MAAM,gCAAgC,GAAG,EAAE,CAAA;AAC3C,MAAM,mCAAmC,GAAG,WAAW,CAAA;AAEvD,2EAA2E;AAC3E,MAAM,YAAY,GAAG,aAAa,CAAA;AAElC;;;;GAIG;AACH,SAAS,eAA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,CACrB;QACD,qBAAqB,EAAE,eAAe,CACpC,GAAG,CAAC,wBAAwB,EAC5B,gCAAgC,EAChC,0BAA0B,EAC1B,oBAAoB,CACrB;QACD,2BAA2B,EAAE,mBAAmB,CAAC,GAAG,CAAC,6BAA6B,CAAC;QACnF,yBAAyB,EACvB,GAAG,CAAC,2BAA2B,EAAE,IAAI,EAAE,IAAI,mCAAmC;QAChF,yBAAyB,EAAE,GAAG,CAAC,4BAA4B,EAAE,IAAI,EAAE,IAAI,SAAS;QAChF,mBAAmB,EAAE,gBAAgB,CAAC,GAAG,CAAC;KAC3C,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/copilot/agent.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// module — the request-scoped executor resolves it from the ALS store.
|
|
15
15
|
import { instrumentCopilotTool, instrumentCopilotTurn, instrumentProviderStream, recordCopilotTokens, } from '../observability/otel.js';
|
|
16
16
|
import { InvokeError, Invoker } from '../tools/generic/invoke.js';
|
|
17
|
+
import { finishWithError } from './sse.js';
|
|
17
18
|
import { executeReadTool, WRITE_ALLOWLIST } from './tools.js';
|
|
18
19
|
/**
|
|
19
20
|
* Sum a round's input+output tokens, failing open: `undefined` usage (a provider
|
|
@@ -66,8 +67,7 @@ function emitProposal(call, index, sink) {
|
|
|
66
67
|
// is latent; but a future one would execute WITHOUT it (a silently wrong
|
|
67
68
|
// write). Refuse loudly instead of minting a lossy proposal.
|
|
68
69
|
if (request.query !== undefined && Object.keys(request.query).length > 0) {
|
|
69
|
-
sink
|
|
70
|
-
sink.done('end');
|
|
70
|
+
finishWithError(sink, 'proposal_invalid', 'write proposals cannot carry query parameters');
|
|
71
71
|
return 'end';
|
|
72
72
|
}
|
|
73
73
|
const op = index.operations.get(call.name);
|
|
@@ -91,8 +91,7 @@ function emitProposal(call, index, sink) {
|
|
|
91
91
|
}
|
|
92
92
|
catch (err) {
|
|
93
93
|
const detail = err instanceof InvokeError ? err.message : 'failed to prepare the proposal';
|
|
94
|
-
sink
|
|
95
|
-
sink.done('end');
|
|
94
|
+
finishWithError(sink, 'proposal_invalid', detail);
|
|
96
95
|
return 'end';
|
|
97
96
|
}
|
|
98
97
|
}
|
|
@@ -145,9 +144,7 @@ export async function runAgentTurn(opts) {
|
|
|
145
144
|
// renders as an error, mirroring the iteration-cap path.
|
|
146
145
|
if (maxTurnTokens !== undefined && totalTokens >= maxTurnTokens) {
|
|
147
146
|
setStop('token_limit');
|
|
148
|
-
sink
|
|
149
|
-
sink.done('end');
|
|
150
|
-
return;
|
|
147
|
+
return finishWithError(sink, 'turn_token_limit', `reached the per-turn token limit (${maxTurnTokens})`);
|
|
151
148
|
}
|
|
152
149
|
// ponytail: sequential tool exec; parallelize only if a turn routinely
|
|
153
150
|
// fans out many reads. Matcher reads are cheap, so ordering keeps the SSE
|
|
@@ -174,8 +171,7 @@ export async function runAgentTurn(opts) {
|
|
|
174
171
|
}
|
|
175
172
|
// Ran `maxIterations` tool rounds and the model still wants more: hard stop.
|
|
176
173
|
setStop('iteration_limit');
|
|
177
|
-
sink
|
|
178
|
-
sink.done('end');
|
|
174
|
+
finishWithError(sink, 'tool_iteration_limit', `reached the tool-call limit (${maxIterations})`);
|
|
179
175
|
});
|
|
180
176
|
}
|
|
181
177
|
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/copilot/agent.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,yEAAyE;AACzE,0EAA0E;AAC1E,uCAAuC;AACvC,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,uEAAuE;AAEvE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,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