@orygn/opa-mcp 0.1.8 → 0.1.9
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/CHANGELOG.md +45 -1
- package/README.md +31 -27
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/lib/opa-cli.d.ts +17 -17
- package/dist/lib/opa-cli.d.ts.map +1 -1
- package/dist/lib/opa-cli.js +37 -35
- package/dist/lib/opa-cli.js.map +1 -1
- package/dist/lib/opa-client.d.ts +5 -0
- package/dist/lib/opa-client.d.ts.map +1 -1
- package/dist/lib/opa-client.js +12 -1
- package/dist/lib/opa-client.js.map +1 -1
- package/dist/lib/regal-cli.d.ts +4 -4
- package/dist/lib/regal-cli.d.ts.map +1 -1
- package/dist/lib/regal-cli.js +10 -8
- package/dist/lib/regal-cli.js.map +1 -1
- package/dist/lib/subprocess.d.ts +4 -0
- package/dist/lib/subprocess.d.ts.map +1 -1
- package/dist/lib/subprocess.js +24 -3
- package/dist/lib/subprocess.js.map +1 -1
- package/dist/lib/tool-helpers.d.ts +13 -0
- package/dist/lib/tool-helpers.d.ts.map +1 -1
- package/dist/lib/tool-helpers.js +28 -0
- package/dist/lib/tool-helpers.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -3
- package/dist/server.js.map +1 -1
- package/dist/tools/authoring/capabilities.d.ts.map +1 -1
- package/dist/tools/authoring/capabilities.js +8 -2
- package/dist/tools/authoring/capabilities.js.map +1 -1
- package/dist/tools/authoring/check.d.ts.map +1 -1
- package/dist/tools/authoring/check.js +16 -4
- package/dist/tools/authoring/check.js.map +1 -1
- package/dist/tools/authoring/deps.d.ts.map +1 -1
- package/dist/tools/authoring/deps.js +8 -2
- package/dist/tools/authoring/deps.js.map +1 -1
- package/dist/tools/authoring/format.d.ts.map +1 -1
- package/dist/tools/authoring/format.js +8 -2
- package/dist/tools/authoring/format.js.map +1 -1
- package/dist/tools/authoring/inspect.d.ts.map +1 -1
- package/dist/tools/authoring/inspect.js +8 -2
- package/dist/tools/authoring/inspect.js.map +1 -1
- package/dist/tools/authoring/lint.d.ts.map +1 -1
- package/dist/tools/authoring/lint.js +11 -12
- package/dist/tools/authoring/lint.js.map +1 -1
- package/dist/tools/authoring/migrate-v1.d.ts.map +1 -1
- package/dist/tools/authoring/migrate-v1.js +15 -5
- package/dist/tools/authoring/migrate-v1.js.map +1 -1
- package/dist/tools/authoring/parse.d.ts.map +1 -1
- package/dist/tools/authoring/parse.js +8 -2
- package/dist/tools/authoring/parse.js.map +1 -1
- package/dist/tools/bundles/build.d.ts.map +1 -1
- package/dist/tools/bundles/build.js +8 -2
- package/dist/tools/bundles/build.js.map +1 -1
- package/dist/tools/bundles/sign.d.ts.map +1 -1
- package/dist/tools/bundles/sign.js +8 -2
- package/dist/tools/bundles/sign.js.map +1 -1
- package/dist/tools/bundles/verify.d.ts.map +1 -1
- package/dist/tools/bundles/verify.js +8 -2
- package/dist/tools/bundles/verify.js.map +1 -1
- package/dist/tools/evaluation/_shared.d.ts +1 -1
- package/dist/tools/evaluation/_shared.d.ts.map +1 -1
- package/dist/tools/evaluation/_shared.js +2 -2
- package/dist/tools/evaluation/_shared.js.map +1 -1
- package/dist/tools/evaluation/bench.d.ts.map +1 -1
- package/dist/tools/evaluation/bench.js +8 -2
- package/dist/tools/evaluation/bench.js.map +1 -1
- package/dist/tools/evaluation/compile.d.ts.map +1 -1
- package/dist/tools/evaluation/compile.js +8 -2
- package/dist/tools/evaluation/compile.js.map +1 -1
- package/dist/tools/evaluation/eval.d.ts.map +1 -1
- package/dist/tools/evaluation/eval.js +32 -8
- package/dist/tools/evaluation/eval.js.map +1 -1
- package/dist/tools/evaluation/exec.d.ts.map +1 -1
- package/dist/tools/evaluation/exec.js +8 -2
- package/dist/tools/evaluation/exec.js.map +1 -1
- package/dist/tools/evaluation/test.d.ts.map +1 -1
- package/dist/tools/evaluation/test.js +8 -2
- package/dist/tools/evaluation/test.js.map +1 -1
- package/dist/tools/helpers/coverage-gaps.d.ts.map +1 -1
- package/dist/tools/helpers/coverage-gaps.js +8 -2
- package/dist/tools/helpers/coverage-gaps.js.map +1 -1
- package/dist/tools/helpers/describe-policy.d.ts.map +1 -1
- package/dist/tools/helpers/describe-policy.js +8 -2
- package/dist/tools/helpers/describe-policy.js.map +1 -1
- package/dist/tools/helpers/explain-decision.d.ts.map +1 -1
- package/dist/tools/helpers/explain-decision.js +8 -2
- package/dist/tools/helpers/explain-decision.js.map +1 -1
- package/dist/tools/helpers/fix.d.ts.map +1 -1
- package/dist/tools/helpers/fix.js +8 -2
- package/dist/tools/helpers/fix.js.map +1 -1
- package/dist/tools/helpers/format-write.d.ts.map +1 -1
- package/dist/tools/helpers/format-write.js +9 -3
- package/dist/tools/helpers/format-write.js.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.d.ts.map +1 -1
- package/dist/tools/helpers/generate-test-skeleton.js +8 -2
- package/dist/tools/helpers/generate-test-skeleton.js.map +1 -1
- package/dist/tools/helpers/infer-input-schema.d.ts.map +1 -1
- package/dist/tools/helpers/infer-input-schema.js +9 -3
- package/dist/tools/helpers/infer-input-schema.js.map +1 -1
- package/dist/tools/helpers/policy-diff.d.ts.map +1 -1
- package/dist/tools/helpers/policy-diff.js +11 -2
- package/dist/tools/helpers/policy-diff.js.map +1 -1
- package/dist/tools/helpers/security-audit.d.ts.map +1 -1
- package/dist/tools/helpers/security-audit.js +8 -2
- package/dist/tools/helpers/security-audit.js.map +1 -1
- package/dist/tools/helpers/suggest-fix.d.ts.map +1 -1
- package/dist/tools/helpers/suggest-fix.js +6 -0
- package/dist/tools/helpers/suggest-fix.js.map +1 -1
- package/dist/tools/meta/server-info.d.ts.map +1 -1
- package/dist/tools/meta/server-info.js +9 -3
- package/dist/tools/meta/server-info.js.map +1 -1
- package/dist/tools/server-management/_shared.d.ts.map +1 -1
- package/dist/tools/server-management/_shared.js +4 -1
- package/dist/tools/server-management/_shared.js.map +1 -1
- package/dist/tools/server-management/data.d.ts.map +1 -1
- package/dist/tools/server-management/data.js +32 -4
- package/dist/tools/server-management/data.js.map +1 -1
- package/dist/tools/server-management/decisions.d.ts.map +1 -1
- package/dist/tools/server-management/decisions.js +16 -2
- package/dist/tools/server-management/decisions.js.map +1 -1
- package/dist/tools/server-management/policies.d.ts.map +1 -1
- package/dist/tools/server-management/policies.js +32 -4
- package/dist/tools/server-management/policies.js.map +1 -1
- package/dist/tools/server-management/status.d.ts.map +1 -1
- package/dist/tools/server-management/status.js +24 -4
- package/dist/tools/server-management/status.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,49 @@ not part of the public surface and may change in minor releases.
|
|
|
17
17
|
|
|
18
18
|
## [Unreleased]
|
|
19
19
|
|
|
20
|
+
## [0.1.9] - 2026-05-21
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **AbortSignal cancellation** -- all 43 tool handlers now wire the MCP SDK's
|
|
25
|
+
`extra.signal` into every subprocess spawn and OPA HTTP request. When a client
|
|
26
|
+
sends `notifications/cancelled`, in-flight work is actually terminated:
|
|
27
|
+
subprocess receives SIGTERM followed by SIGKILL escalation after 2 seconds;
|
|
28
|
+
HTTP fetches are aborted via `AbortSignal.any()` combining the existing
|
|
29
|
+
per-request timeout with the external client signal.
|
|
30
|
+
|
|
31
|
+
- **`CANCELLED` error code** -- added to `ToolErrorCode`. Returned to the caller
|
|
32
|
+
when a tool is interrupted mid-flight by client cancellation, rather than
|
|
33
|
+
surfacing a misleading `TIMEOUT` or `OPA_BINARY_NOT_FOUND` code.
|
|
34
|
+
|
|
35
|
+
- **`OpaCancelledError`** -- new error class in `OpaClient`. Thrown when a
|
|
36
|
+
fetch aborts because the client signal fired (not a network failure), so
|
|
37
|
+
`mapOpaClientError` can map it precisely to `CANCELLED`.
|
|
38
|
+
|
|
39
|
+
- **Tool annotations, instructions, and path sanitization (MCP spec 2025-11-25)**
|
|
40
|
+
-- all 43 tools now declare `readOnlyHint`, `destructiveHint`, `idempotentHint`,
|
|
41
|
+
and `openWorldHint` in their `annotations` block per the MCP spec. Server
|
|
42
|
+
registers `instructions` at startup describing the tool set. All file path
|
|
43
|
+
arguments validated through a hardened `validatePath` helper that normalises
|
|
44
|
+
Windows drive-letter casing and resolves symlinks before allow-list comparison,
|
|
45
|
+
closing a bypass that existed when a symlink target escaped the allowed root.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- **`@modelcontextprotocol/sdk` pinned to `^1.29.0`** -- the minimum version that
|
|
50
|
+
exposes `annotations` on `RegisteredTool` and passes `extra.signal` to handlers.
|
|
51
|
+
|
|
52
|
+
### Internal
|
|
53
|
+
|
|
54
|
+
- `subprocess.ts`: `SpawnResult` gains `aborted: boolean`; `SpawnOptions` gains
|
|
55
|
+
`signal?: AbortSignal`. Early-return path if signal is pre-aborted; abort
|
|
56
|
+
listener shares the SIGTERM->SIGKILL escalation helper with the timeout path.
|
|
57
|
+
- `tool-helpers.ts`: `mapSubprocessFailure` checks `result.aborted` before
|
|
58
|
+
`exitCode === null` so cancellation takes priority over binary-not-found.
|
|
59
|
+
- Tests: all mock `SpawnResult` objects updated to include `aborted: false`;
|
|
60
|
+
`callTool` helper passes `{ signal }` as second argument; two new deterministic
|
|
61
|
+
abort path tests in `subprocess.test.ts`.
|
|
62
|
+
|
|
20
63
|
## [0.1.8] - 2026-05-21
|
|
21
64
|
|
|
22
65
|
### Added
|
|
@@ -514,7 +557,8 @@ wrappers end-to-end. CI matrix: Ubuntu, macOS, and Windows on Node
|
|
|
514
557
|
20 and 22, plus CodeQL security scanning and weekly Dependabot updates
|
|
515
558
|
for npm, GitHub Actions, and Docker base images.
|
|
516
559
|
|
|
517
|
-
[Unreleased]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.
|
|
560
|
+
[Unreleased]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.9...HEAD
|
|
561
|
+
[0.1.9]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.8...v0.1.9
|
|
518
562
|
[0.1.8]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.7...v0.1.8
|
|
519
563
|
[0.1.7]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.6...v0.1.7
|
|
520
564
|
[0.1.6]: https://github.com/OrygnsCode/opa-mcp-server/compare/v0.1.5...v0.1.6
|
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ environment.
|
|
|
18
18
|
+--------------------+ MCP / stdio +-----------------+ spawn / HTTP +------------------+
|
|
19
19
|
| Claude · Cursor · | ------------> | @orygn/opa-mcp | -------------> | opa · regal · |
|
|
20
20
|
| VS Code · ... | <------------ | | <------------- | OPA REST API |
|
|
21
|
-
+--------------------+
|
|
21
|
+
+--------------------+ 43 tools +-----------------+ +------------------+
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
> **Status:** v0.1.
|
|
24
|
+
> **Status:** v0.1.8. Tool surface, error codes, and
|
|
25
25
|
> environment variables follow [SemVer](https://semver.org/) from
|
|
26
26
|
> v0.1.0 forward.
|
|
27
27
|
|
|
@@ -264,7 +264,7 @@ Every tool returns a JSON envelope:
|
|
|
264
264
|
Stable error codes: `INVALID_INPUT`, `INVALID_REGO`, `INVALID_BUNDLE`,
|
|
265
265
|
`EVAL_ERROR`, `OPA_BINARY_NOT_FOUND`, `REGAL_NOT_FOUND`,
|
|
266
266
|
`REGAL_VERSION_TOO_OLD`, `OPA_UNREACHABLE`, `OPA_AUTH_FAILED`,
|
|
267
|
-
`POLICY_NOT_FOUND`, `PATH_NOT_ALLOWED`, `PATH_NOT_FOUND`,
|
|
267
|
+
`POLICY_NOT_FOUND`, `DATA_NOT_FOUND`, `PATH_NOT_ALLOWED`, `PATH_NOT_FOUND`,
|
|
268
268
|
`DEPENDENCY_CONFLICT`, `NO_TESTS_FOUND`, `HTTP_SEND_BLOCKED`, `TIMEOUT`,
|
|
269
269
|
`UNKNOWN_ERROR`.
|
|
270
270
|
|
|
@@ -274,15 +274,16 @@ Operate on Rego source code without needing a running OPA server. Wrap
|
|
|
274
274
|
`opa fmt`, `opa parse`, `opa check`, `opa inspect`, `opa capabilities`,
|
|
275
275
|
`opa deps`, and `regal`.
|
|
276
276
|
|
|
277
|
-
| Tool | What it does
|
|
278
|
-
| ------------------- |
|
|
279
|
-
| `rego_format` | Format Rego source. Wraps `opa fmt`. Idempotent.
|
|
280
|
-
| `rego_check` | Type-check and validate Rego. Wraps `opa check`.
|
|
281
|
-
| `rego_lint` | Run Regal across a file or directory. Returns findings grouped by category. **Requires `regal` on `PATH` or `REGAL_BINARY` set.**
|
|
282
|
-
| `rego_parse_ast` | Parse Rego to AST JSON. Wraps `opa parse`.
|
|
283
|
-
| `rego_inspect` | Inspect a bundle or directory: packages, rules, annotations. Wraps `opa inspect`.
|
|
284
|
-
| `rego_capabilities` | Return the capabilities (built-ins, future keywords) understood by the bundled OPA.
|
|
285
|
-
| `rego_deps` | Static dependency analysis: rule-level data references and cross-package calls.
|
|
277
|
+
| Tool | What it does |
|
|
278
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
279
|
+
| `rego_format` | Format Rego source. Wraps `opa fmt`. Idempotent. |
|
|
280
|
+
| `rego_check` | Type-check and validate Rego. Wraps `opa check`. |
|
|
281
|
+
| `rego_lint` | Run Regal across a file or directory. Returns findings grouped by category. **Requires `regal` on `PATH` or `REGAL_BINARY` set.** |
|
|
282
|
+
| `rego_parse_ast` | Parse Rego to AST JSON. Wraps `opa parse`. |
|
|
283
|
+
| `rego_inspect` | Inspect a bundle or directory: packages, rules, annotations. Wraps `opa inspect`. |
|
|
284
|
+
| `rego_capabilities` | Return the capabilities (built-ins, future keywords) understood by the bundled OPA. |
|
|
285
|
+
| `rego_deps` | Static dependency analysis: rule-level data references and cross-package calls. |
|
|
286
|
+
| `rego_migrate_v1` | Migrate Rego v0 source to v1 syntax. Runs `opa fmt --rego-v1` then validates with `opa check --v1-compatible`. Returns `{ original, migrated, changed, valid, errors }`. |
|
|
286
287
|
|
|
287
288
|
#### Featured: `rego_format`
|
|
288
289
|
|
|
@@ -332,15 +333,16 @@ Operate on Rego source code without needing a running OPA server. Wrap
|
|
|
332
333
|
Run a query against a policy and input. Wrap `opa eval`, `opa test`, and
|
|
333
334
|
`opa bench`.
|
|
334
335
|
|
|
335
|
-
| Tool | What it does
|
|
336
|
-
| ------------------------- |
|
|
337
|
-
| `rego_eval` | Evaluate a query against a policy and input. The bread-and-butter tool.
|
|
338
|
-
| `rego_eval_with_explain` | Evaluate with `--explain=full` and return a structured trace.
|
|
339
|
-
| `rego_eval_with_profile` | Evaluate with `--profile` and return per-rule timing and evaluation counts.
|
|
340
|
-
| `rego_eval_with_coverage` | Evaluate with `--coverage` and return per-line coverage.
|
|
341
|
-
| `rego_test` | Run `opa test` over a directory. Returns pass/fail per test, with optional coverage.
|
|
342
|
-
| `rego_bench` | Run `opa bench` and return statistical timing data.
|
|
343
|
-
| `rego_compile_query` | Partially evaluate a query against a policy.
|
|
336
|
+
| Tool | What it does |
|
|
337
|
+
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
338
|
+
| `rego_eval` | Evaluate a query against a policy and input. The bread-and-butter tool. |
|
|
339
|
+
| `rego_eval_with_explain` | Evaluate with `--explain=full` and return a structured trace. |
|
|
340
|
+
| `rego_eval_with_profile` | Evaluate with `--profile` and return per-rule timing and evaluation counts. |
|
|
341
|
+
| `rego_eval_with_coverage` | Evaluate with `--coverage` and return per-line coverage. |
|
|
342
|
+
| `rego_test` | Run `opa test` over a directory. Returns pass/fail per test, with optional coverage. |
|
|
343
|
+
| `rego_bench` | Run `opa bench` and return statistical timing data. |
|
|
344
|
+
| `rego_compile_query` | Partially evaluate a query against a policy. |
|
|
345
|
+
| `opa_exec` | Batch-evaluate a decision against multiple input files. Returns per-file results with `successCount` and `errorCount`. |
|
|
344
346
|
|
|
345
347
|
#### Featured: `rego_eval`
|
|
346
348
|
|
|
@@ -365,10 +367,11 @@ Run a query against a policy and input. Wrap `opa eval`, `opa test`, and
|
|
|
365
367
|
|
|
366
368
|
Package and sign deployable bundles. Wrap `opa build` and `opa sign`.
|
|
367
369
|
|
|
368
|
-
| Tool
|
|
369
|
-
|
|
|
370
|
-
| `opa_bundle_build`
|
|
371
|
-
| `opa_bundle_sign`
|
|
370
|
+
| Tool | What it does |
|
|
371
|
+
| ------------------- | ------------------------------------------------------------------------------------------------- |
|
|
372
|
+
| `opa_bundle_build` | Build a `.tar.gz` bundle from a policy directory. Supports `optimize` and `revision`. |
|
|
373
|
+
| `opa_bundle_sign` | Sign a bundle with a private key. Returns `.signatures.json` content. |
|
|
374
|
+
| `opa_bundle_verify` | Verify the signature of a signed bundle using a public key. Returns `{ bundle, verified: true }`. |
|
|
372
375
|
|
|
373
376
|
### Category D: OPA server management
|
|
374
377
|
|
|
@@ -384,6 +387,7 @@ point at a reachable server.
|
|
|
384
387
|
| `opa_get_data` | Read a path from the data hierarchy. |
|
|
385
388
|
| `opa_put_data` | Write to a path in the data hierarchy. |
|
|
386
389
|
| `opa_patch_data` | Apply a JSON Patch to the data hierarchy. |
|
|
390
|
+
| `opa_delete_data` | Delete a document from the data hierarchy. |
|
|
387
391
|
| `opa_query_decision` | POST to a `/v1/data/...` decision endpoint with input. |
|
|
388
392
|
| `opa_compile_query` | Partially evaluate a query against the running server. |
|
|
389
393
|
| `opa_health` | Liveness / readiness check. |
|
|
@@ -416,7 +420,7 @@ the tasks agents are actually asked to do.
|
|
|
416
420
|
|
|
417
421
|
## Prompts
|
|
418
422
|
|
|
419
|
-
Three [MCP prompts](https://modelcontextprotocol.io/specification/server/prompts)
|
|
423
|
+
Three [MCP prompts](https://modelcontextprotocol.io/specification/2025-11-25/server/prompts)
|
|
420
424
|
ship with the server. Clients surface them as slash commands or workflow
|
|
421
425
|
templates.
|
|
422
426
|
|
|
@@ -428,7 +432,7 @@ templates.
|
|
|
428
432
|
|
|
429
433
|
## Resources
|
|
430
434
|
|
|
431
|
-
Three [MCP resources](https://modelcontextprotocol.io/specification/server/resources)
|
|
435
|
+
Three [MCP resources](https://modelcontextprotocol.io/specification/2025-11-25/server/resources)
|
|
432
436
|
expose curated reference data the agent can read at any time.
|
|
433
437
|
|
|
434
438
|
| Resource URI | What's there |
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/lib/opa-cli.d.ts
CHANGED
|
@@ -201,13 +201,13 @@ export declare class OpaCli {
|
|
|
201
201
|
* Verify the binary is present and report its version.
|
|
202
202
|
* Returns null if the binary is unreachable or output is malformed.
|
|
203
203
|
*/
|
|
204
|
-
version(): Promise<string | null>;
|
|
204
|
+
version(signal?: AbortSignal): Promise<string | null>;
|
|
205
205
|
/**
|
|
206
206
|
* Format Rego source. Stdout contains the formatted output. Reports
|
|
207
207
|
* `exitCode: 0` even when no changes are needed -- callers compare
|
|
208
208
|
* input vs output to detect a no-op.
|
|
209
209
|
*/
|
|
210
|
-
fmt(input: FmtInput): Promise<SpawnResult>;
|
|
210
|
+
fmt(input: FmtInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
211
211
|
/**
|
|
212
212
|
* List files that would be reformatted. Stdout is one absolute path per
|
|
213
213
|
* line for each file that is not already canonical. Exit 0 on success,
|
|
@@ -216,12 +216,12 @@ export declare class OpaCli {
|
|
|
216
216
|
* NOTE: --list and --write are mutually exclusive in OPA: passing both
|
|
217
217
|
* suppresses the write. Always use separate fmtList + fmtWrite calls.
|
|
218
218
|
*/
|
|
219
|
-
fmtList(input: FmtWriteInput): Promise<SpawnResult>;
|
|
219
|
+
fmtList(input: FmtWriteInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
220
220
|
/**
|
|
221
221
|
* Overwrite each file with its canonically formatted version. Exit 0 on
|
|
222
222
|
* success, non-zero (exit 2) if any file cannot be parsed.
|
|
223
223
|
*/
|
|
224
|
-
fmtWrite(input: FmtWriteInput): Promise<SpawnResult>;
|
|
224
|
+
fmtWrite(input: FmtWriteInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
225
225
|
/**
|
|
226
226
|
* Type-check Rego. Returns `exitCode: 0` and empty `stdout` when the
|
|
227
227
|
* policy is valid. On failure, `exitCode` is non-zero and the JSON
|
|
@@ -230,49 +230,49 @@ export declare class OpaCli {
|
|
|
230
230
|
* diagnostics). Either inline `source` or one or more `paths` must be
|
|
231
231
|
* provided.
|
|
232
232
|
*/
|
|
233
|
-
check(input: CheckInput): Promise<SpawnResult>;
|
|
233
|
+
check(input: CheckInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
234
234
|
/**
|
|
235
235
|
* Parse Rego source to a JSON AST. Stdout is the AST as JSON.
|
|
236
236
|
*/
|
|
237
|
-
parse(input: ParseInput): Promise<SpawnResult>;
|
|
237
|
+
parse(input: ParseInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
238
238
|
/**
|
|
239
239
|
* Inspect a bundle, directory, or single Rego file. Returns its
|
|
240
240
|
* packages, namespaces, manifest, and annotations as JSON on stdout.
|
|
241
241
|
*/
|
|
242
|
-
inspect(input: InspectInput): Promise<SpawnResult>;
|
|
242
|
+
inspect(input: InspectInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
243
243
|
/**
|
|
244
244
|
* Print available capabilities. With `current=true`, prints the
|
|
245
245
|
* capabilities of the running OPA. With a `version`, prints those of
|
|
246
246
|
* a specific named version. Without either, lists available named
|
|
247
247
|
* versions.
|
|
248
248
|
*/
|
|
249
|
-
capabilities(input?: CapabilitiesInput): Promise<SpawnResult>;
|
|
249
|
+
capabilities(input?: CapabilitiesInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
250
250
|
/**
|
|
251
251
|
* Static dependency analysis for a Rego ref. Stdout is JSON with the
|
|
252
252
|
* `base` and `virtual` document references the ref depends on.
|
|
253
253
|
*/
|
|
254
|
-
deps(input: DepsInput): Promise<SpawnResult>;
|
|
254
|
+
deps(input: DepsInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
255
255
|
/**
|
|
256
256
|
* Evaluate a query against a policy + input. Stdout is JSON with the
|
|
257
257
|
* standard `{result: [...]}` shape (plus optional explain, profile,
|
|
258
258
|
* coverage, and metrics sections).
|
|
259
259
|
*/
|
|
260
|
-
eval(input: EvalInput): Promise<SpawnResult>;
|
|
260
|
+
eval(input: EvalInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
261
261
|
/**
|
|
262
262
|
* Run Rego unit tests. Stdout is JSON with per-test pass/fail.
|
|
263
263
|
*/
|
|
264
|
-
test(input: TestInput): Promise<SpawnResult>;
|
|
264
|
+
test(input: TestInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
265
265
|
/**
|
|
266
266
|
* Benchmark a query. Stdout is JSON with iteration timing statistics.
|
|
267
267
|
*/
|
|
268
|
-
bench(input: BenchInput): Promise<SpawnResult>;
|
|
268
|
+
bench(input: BenchInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
269
269
|
/** Build a deployable bundle from policy + data paths. */
|
|
270
|
-
build(input: BuildInput): Promise<SpawnResult>;
|
|
270
|
+
build(input: BuildInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
271
271
|
/**
|
|
272
272
|
* Sign a bundle. Writes a `.signatures.json` next to the bundle
|
|
273
273
|
* directory.
|
|
274
274
|
*/
|
|
275
|
-
sign(input: SignInput): Promise<SpawnResult>;
|
|
275
|
+
sign(input: SignInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
276
276
|
/**
|
|
277
277
|
* Verify a signed bundle using `opa eval --bundle --verification-key`.
|
|
278
278
|
* OPA verifies the bundle signature before loading any policies; a
|
|
@@ -280,19 +280,19 @@ export declare class OpaCli {
|
|
|
280
280
|
* stderr. The trivial query `true` is used so the process exits
|
|
281
281
|
* immediately after verification without entering a REPL.
|
|
282
282
|
*/
|
|
283
|
-
bundleVerify(input: BundleVerifyInput): Promise<SpawnResult>;
|
|
283
|
+
bundleVerify(input: BundleVerifyInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
284
284
|
/**
|
|
285
285
|
* Batch-evaluate a policy decision against one or more input files using
|
|
286
286
|
* `opa exec`. Each input file is evaluated independently; results are
|
|
287
287
|
* returned as a JSON array with one entry per file.
|
|
288
288
|
*/
|
|
289
|
-
exec(input: ExecInput): Promise<SpawnResult>;
|
|
289
|
+
exec(input: ExecInput, signal?: AbortSignal): Promise<SpawnResult>;
|
|
290
290
|
/**
|
|
291
291
|
* Run `opa` with the given argv and optional stdin. Tools should
|
|
292
292
|
* prefer the typed methods above, but this exists for the rare cases
|
|
293
293
|
* the typed surface does not yet cover.
|
|
294
294
|
*/
|
|
295
|
-
run(args: string[], stdin?: string): Promise<SpawnResult>;
|
|
295
|
+
run(args: string[], stdin?: string, signal?: AbortSignal): Promise<SpawnResult>;
|
|
296
296
|
/**
|
|
297
297
|
* Write `source` to a uniquely named `.rego` file in the OS tmp dir,
|
|
298
298
|
* pass its path to `fn`, and remove it on completion (success or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opa-cli.d.ts","sourceRoot":"","sources":["../../src/lib/opa-cli.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,+BAA+B;AAC/B,MAAM,WAAW,QAAQ;IACvB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uFAAuF;IACvF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;A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AC,WAAW,CAAC;IASxF;;;;OAIG;IACG,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAaxE;;;;OAIG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAYrF;;;;;OAKG;YACW,cAAc;CAS7B"}
|
package/dist/lib/opa-cli.js
CHANGED
|
@@ -38,8 +38,8 @@ export class OpaCli {
|
|
|
38
38
|
* Verify the binary is present and report its version.
|
|
39
39
|
* Returns null if the binary is unreachable or output is malformed.
|
|
40
40
|
*/
|
|
41
|
-
async version() {
|
|
42
|
-
const result = await this.run(['version']);
|
|
41
|
+
async version(signal) {
|
|
42
|
+
const result = await this.run(['version'], undefined, signal);
|
|
43
43
|
if (result.exitCode !== 0)
|
|
44
44
|
return null;
|
|
45
45
|
const match = /Version:\s*(\S+)/i.exec(result.stdout);
|
|
@@ -51,11 +51,11 @@ export class OpaCli {
|
|
|
51
51
|
* `exitCode: 0` even when no changes are needed -- callers compare
|
|
52
52
|
* input vs output to detect a no-op.
|
|
53
53
|
*/
|
|
54
|
-
async fmt(input) {
|
|
54
|
+
async fmt(input, signal) {
|
|
55
55
|
const args = ['fmt'];
|
|
56
56
|
if (input.regoV1)
|
|
57
57
|
args.push('--rego-v1');
|
|
58
|
-
return this.withTempSource(input.source, (path) => this.run([...args, path]));
|
|
58
|
+
return this.withTempSource(input.source, (path) => this.run([...args, path], undefined, signal));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* List files that would be reformatted. Stdout is one absolute path per
|
|
@@ -65,7 +65,7 @@ export class OpaCli {
|
|
|
65
65
|
* NOTE: --list and --write are mutually exclusive in OPA: passing both
|
|
66
66
|
* suppresses the write. Always use separate fmtList + fmtWrite calls.
|
|
67
67
|
*/
|
|
68
|
-
async fmtList(input) {
|
|
68
|
+
async fmtList(input, signal) {
|
|
69
69
|
if (input.paths.length === 0) {
|
|
70
70
|
throw new Error('opa fmt requires at least one path');
|
|
71
71
|
}
|
|
@@ -77,13 +77,13 @@ export class OpaCli {
|
|
|
77
77
|
if (input.v1Compatible)
|
|
78
78
|
args.push('--v1-compatible');
|
|
79
79
|
args.push(...input.paths);
|
|
80
|
-
return this.run(args);
|
|
80
|
+
return this.run(args, undefined, signal);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Overwrite each file with its canonically formatted version. Exit 0 on
|
|
84
84
|
* success, non-zero (exit 2) if any file cannot be parsed.
|
|
85
85
|
*/
|
|
86
|
-
async fmtWrite(input) {
|
|
86
|
+
async fmtWrite(input, signal) {
|
|
87
87
|
if (input.paths.length === 0) {
|
|
88
88
|
throw new Error('opa fmt requires at least one path');
|
|
89
89
|
}
|
|
@@ -95,7 +95,7 @@ export class OpaCli {
|
|
|
95
95
|
if (input.v1Compatible)
|
|
96
96
|
args.push('--v1-compatible');
|
|
97
97
|
args.push(...input.paths);
|
|
98
|
-
return this.run(args);
|
|
98
|
+
return this.run(args, undefined, signal);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Type-check Rego. Returns `exitCode: 0` and empty `stdout` when the
|
|
@@ -105,7 +105,7 @@ export class OpaCli {
|
|
|
105
105
|
* diagnostics). Either inline `source` or one or more `paths` must be
|
|
106
106
|
* provided.
|
|
107
107
|
*/
|
|
108
|
-
async check(input) {
|
|
108
|
+
async check(input, signal) {
|
|
109
109
|
if (!input.source && !input.paths?.length) {
|
|
110
110
|
throw new Error('opa check requires either source or at least one path');
|
|
111
111
|
}
|
|
@@ -121,23 +121,23 @@ export class OpaCli {
|
|
|
121
121
|
if (input.schemaDir)
|
|
122
122
|
args.push('--schema', input.schemaDir);
|
|
123
123
|
if (input.source !== undefined) {
|
|
124
|
-
return this.withTempSource(input.source, (path) => this.run([...args, path]));
|
|
124
|
+
return this.withTempSource(input.source, (path) => this.run([...args, path], undefined, signal));
|
|
125
125
|
}
|
|
126
126
|
args.push(...(input.paths ?? []));
|
|
127
|
-
return this.run(args);
|
|
127
|
+
return this.run(args, undefined, signal);
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* Parse Rego source to a JSON AST. Stdout is the AST as JSON.
|
|
131
131
|
*/
|
|
132
|
-
async parse(input) {
|
|
133
|
-
return this.withTempSource(input.source, (path) => this.run(['parse', '--format=json', path]));
|
|
132
|
+
async parse(input, signal) {
|
|
133
|
+
return this.withTempSource(input.source, (path) => this.run(['parse', '--format=json', path], undefined, signal));
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Inspect a bundle, directory, or single Rego file. Returns its
|
|
137
137
|
* packages, namespaces, manifest, and annotations as JSON on stdout.
|
|
138
138
|
*/
|
|
139
|
-
async inspect(input) {
|
|
140
|
-
return this.run(['inspect', '--format=json', '--annotations', input.target]);
|
|
139
|
+
async inspect(input, signal) {
|
|
140
|
+
return this.run(['inspect', '--format=json', '--annotations', input.target], undefined, signal);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Print available capabilities. With `current=true`, prints the
|
|
@@ -145,19 +145,19 @@ export class OpaCli {
|
|
|
145
145
|
* a specific named version. Without either, lists available named
|
|
146
146
|
* versions.
|
|
147
147
|
*/
|
|
148
|
-
async capabilities(input = {}) {
|
|
148
|
+
async capabilities(input = {}, signal) {
|
|
149
149
|
const args = ['capabilities'];
|
|
150
150
|
if (input.current)
|
|
151
151
|
args.push('--current');
|
|
152
152
|
if (input.version)
|
|
153
153
|
args.push('--version', input.version);
|
|
154
|
-
return this.run(args);
|
|
154
|
+
return this.run(args, undefined, signal);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Static dependency analysis for a Rego ref. Stdout is JSON with the
|
|
158
158
|
* `base` and `virtual` document references the ref depends on.
|
|
159
159
|
*/
|
|
160
|
-
async deps(input) {
|
|
160
|
+
async deps(input, signal) {
|
|
161
161
|
if (input.paths.length === 0) {
|
|
162
162
|
throw new Error('opa deps requires at least one path');
|
|
163
163
|
}
|
|
@@ -166,7 +166,7 @@ export class OpaCli {
|
|
|
166
166
|
args.push('--data', path);
|
|
167
167
|
}
|
|
168
168
|
args.push(input.ref);
|
|
169
|
-
return this.run(args);
|
|
169
|
+
return this.run(args, undefined, signal);
|
|
170
170
|
}
|
|
171
171
|
// ─── Evaluation ──────────────────────────────────────────────────────
|
|
172
172
|
/**
|
|
@@ -174,7 +174,7 @@ export class OpaCli {
|
|
|
174
174
|
* standard `{result: [...]}` shape (plus optional explain, profile,
|
|
175
175
|
* coverage, and metrics sections).
|
|
176
176
|
*/
|
|
177
|
-
async eval(input) {
|
|
177
|
+
async eval(input, signal) {
|
|
178
178
|
// Inline source becomes a temp file added to --data.
|
|
179
179
|
if (input.source !== undefined) {
|
|
180
180
|
const { source, ...rest } = input;
|
|
@@ -182,7 +182,7 @@ export class OpaCli {
|
|
|
182
182
|
return this.withTempSource(input.source, (sourcePath) => this.eval({
|
|
183
183
|
...rest,
|
|
184
184
|
paths: [...(input.paths ?? []), sourcePath],
|
|
185
|
-
}));
|
|
185
|
+
}, signal));
|
|
186
186
|
}
|
|
187
187
|
const args = ['eval', '--format=json'];
|
|
188
188
|
for (const path of input.paths ?? [])
|
|
@@ -215,12 +215,12 @@ export class OpaCli {
|
|
|
215
215
|
stdin = JSON.stringify(input.input);
|
|
216
216
|
}
|
|
217
217
|
args.push(input.query);
|
|
218
|
-
return this.run(args, stdin);
|
|
218
|
+
return this.run(args, stdin, signal);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* Run Rego unit tests. Stdout is JSON with per-test pass/fail.
|
|
222
222
|
*/
|
|
223
|
-
async test(input) {
|
|
223
|
+
async test(input, signal) {
|
|
224
224
|
if (input.paths.length === 0) {
|
|
225
225
|
throw new Error('opa test requires at least one path');
|
|
226
226
|
}
|
|
@@ -234,12 +234,12 @@ export class OpaCli {
|
|
|
234
234
|
if (input.runPattern)
|
|
235
235
|
args.push('--run', input.runPattern);
|
|
236
236
|
args.push(...input.paths);
|
|
237
|
-
return this.run(args);
|
|
237
|
+
return this.run(args, undefined, signal);
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Benchmark a query. Stdout is JSON with iteration timing statistics.
|
|
241
241
|
*/
|
|
242
|
-
async bench(input) {
|
|
242
|
+
async bench(input, signal) {
|
|
243
243
|
const args = ['bench', '--format=json'];
|
|
244
244
|
for (const path of input.paths ?? [])
|
|
245
245
|
args.push('--data', path);
|
|
@@ -253,11 +253,11 @@ export class OpaCli {
|
|
|
253
253
|
stdin = JSON.stringify(input.input);
|
|
254
254
|
}
|
|
255
255
|
args.push(input.query);
|
|
256
|
-
return this.run(args, stdin);
|
|
256
|
+
return this.run(args, stdin, signal);
|
|
257
257
|
}
|
|
258
258
|
// ─── Bundles ─────────────────────────────────────────────────────────
|
|
259
259
|
/** Build a deployable bundle from policy + data paths. */
|
|
260
|
-
async build(input) {
|
|
260
|
+
async build(input, signal) {
|
|
261
261
|
if (input.paths.length === 0) {
|
|
262
262
|
throw new Error('opa build requires at least one input path');
|
|
263
263
|
}
|
|
@@ -279,20 +279,20 @@ export class OpaCli {
|
|
|
279
279
|
if (input.capabilities)
|
|
280
280
|
args.push('--capabilities', input.capabilities);
|
|
281
281
|
args.push(...input.paths);
|
|
282
|
-
return this.run(args);
|
|
282
|
+
return this.run(args, undefined, signal);
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Sign a bundle. Writes a `.signatures.json` next to the bundle
|
|
286
286
|
* directory.
|
|
287
287
|
*/
|
|
288
|
-
async sign(input) {
|
|
288
|
+
async sign(input, signal) {
|
|
289
289
|
const args = ['sign', '--signing-key', input.signingKey];
|
|
290
290
|
if (input.signingAlg)
|
|
291
291
|
args.push('--signing-alg', input.signingAlg);
|
|
292
292
|
if (input.claimsFile)
|
|
293
293
|
args.push('--claims-file', input.claimsFile);
|
|
294
294
|
args.push('--bundle', input.bundle);
|
|
295
|
-
return this.run(args);
|
|
295
|
+
return this.run(args, undefined, signal);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* Verify a signed bundle using `opa eval --bundle --verification-key`.
|
|
@@ -301,7 +301,7 @@ export class OpaCli {
|
|
|
301
301
|
* stderr. The trivial query `true` is used so the process exits
|
|
302
302
|
* immediately after verification without entering a REPL.
|
|
303
303
|
*/
|
|
304
|
-
async bundleVerify(input) {
|
|
304
|
+
async bundleVerify(input, signal) {
|
|
305
305
|
const args = ['eval', '--bundle', input.bundle, '--verification-key', input.verificationKey];
|
|
306
306
|
if (input.verificationKeyId)
|
|
307
307
|
args.push('--verification-key-id', input.verificationKeyId);
|
|
@@ -310,14 +310,14 @@ export class OpaCli {
|
|
|
310
310
|
if (input.scope)
|
|
311
311
|
args.push('--scope', input.scope);
|
|
312
312
|
args.push('true');
|
|
313
|
-
return this.run(args);
|
|
313
|
+
return this.run(args, undefined, signal);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
316
|
* Batch-evaluate a policy decision against one or more input files using
|
|
317
317
|
* `opa exec`. Each input file is evaluated independently; results are
|
|
318
318
|
* returned as a JSON array with one entry per file.
|
|
319
319
|
*/
|
|
320
|
-
async exec(input) {
|
|
320
|
+
async exec(input, signal) {
|
|
321
321
|
if (input.inputPaths.length === 0) {
|
|
322
322
|
throw new Error('opa exec requires at least one input path');
|
|
323
323
|
}
|
|
@@ -327,7 +327,7 @@ export class OpaCli {
|
|
|
327
327
|
for (const p of input.dataPaths ?? [])
|
|
328
328
|
args.push('--data', p);
|
|
329
329
|
args.push(...input.inputPaths);
|
|
330
|
-
return this.run(args);
|
|
330
|
+
return this.run(args, undefined, signal);
|
|
331
331
|
}
|
|
332
332
|
// ─── Low-level escape hatch ──────────────────────────────────────────
|
|
333
333
|
/**
|
|
@@ -335,13 +335,15 @@ export class OpaCli {
|
|
|
335
335
|
* prefer the typed methods above, but this exists for the rare cases
|
|
336
336
|
* the typed surface does not yet cover.
|
|
337
337
|
*/
|
|
338
|
-
async run(args, stdin) {
|
|
338
|
+
async run(args, stdin, signal) {
|
|
339
339
|
const opts = {
|
|
340
340
|
args,
|
|
341
341
|
timeoutMs: this.config.subprocessTimeoutMs,
|
|
342
342
|
};
|
|
343
343
|
if (stdin !== undefined)
|
|
344
344
|
opts.stdin = stdin;
|
|
345
|
+
if (signal !== undefined)
|
|
346
|
+
opts.signal = signal;
|
|
345
347
|
return runBinary(this.config.opaBinary, opts);
|
|
346
348
|
}
|
|
347
349
|
// ─── Internal: temp file management ──────────────────────────────────
|