opensip-cli 0.1.0
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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +51 -0
- package/dist/api.d.ts +17 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +16 -0
- package/dist/api.js.map +1 -0
- package/dist/bootstrap/admit-tool-package.d.ts +117 -0
- package/dist/bootstrap/admit-tool-package.d.ts.map +1 -0
- package/dist/bootstrap/admit-tool-package.js +170 -0
- package/dist/bootstrap/admit-tool-package.js.map +1 -0
- package/dist/bootstrap/baseline-seams.d.ts +30 -0
- package/dist/bootstrap/baseline-seams.d.ts.map +1 -0
- package/dist/bootstrap/baseline-seams.js +156 -0
- package/dist/bootstrap/baseline-seams.js.map +1 -0
- package/dist/bootstrap/bootstrap-error.d.ts +41 -0
- package/dist/bootstrap/bootstrap-error.d.ts.map +1 -0
- package/dist/bootstrap/bootstrap-error.js +33 -0
- package/dist/bootstrap/bootstrap-error.js.map +1 -0
- package/dist/bootstrap/build-command-registration-input.d.ts +34 -0
- package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -0
- package/dist/bootstrap/build-command-registration-input.js +73 -0
- package/dist/bootstrap/build-command-registration-input.js.map +1 -0
- package/dist/bootstrap/build-per-run-scope.d.ts +62 -0
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -0
- package/dist/bootstrap/build-per-run-scope.js +152 -0
- package/dist/bootstrap/build-per-run-scope.js.map +1 -0
- package/dist/bootstrap/build-targets.d.ts +42 -0
- package/dist/bootstrap/build-targets.d.ts.map +1 -0
- package/dist/bootstrap/build-targets.js +117 -0
- package/dist/bootstrap/build-targets.js.map +1 -0
- package/dist/bootstrap/cli-defaults.d.ts +35 -0
- package/dist/bootstrap/cli-defaults.d.ts.map +1 -0
- package/dist/bootstrap/cli-defaults.js +65 -0
- package/dist/bootstrap/cli-defaults.js.map +1 -0
- package/dist/bootstrap/config-and-capabilities.d.ts +74 -0
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -0
- package/dist/bootstrap/config-and-capabilities.js +224 -0
- package/dist/bootstrap/config-and-capabilities.js.map +1 -0
- package/dist/bootstrap/deliver-envelope.d.ts +80 -0
- package/dist/bootstrap/deliver-envelope.d.ts.map +1 -0
- package/dist/bootstrap/deliver-envelope.js +195 -0
- package/dist/bootstrap/deliver-envelope.js.map +1 -0
- package/dist/bootstrap/egress-plane.d.ts +22 -0
- package/dist/bootstrap/egress-plane.d.ts.map +1 -0
- package/dist/bootstrap/egress-plane.js +37 -0
- package/dist/bootstrap/egress-plane.js.map +1 -0
- package/dist/bootstrap/host-planes.d.ts +28 -0
- package/dist/bootstrap/host-planes.d.ts.map +1 -0
- package/dist/bootstrap/host-planes.js +152 -0
- package/dist/bootstrap/host-planes.js.map +1 -0
- package/dist/bootstrap/index.d.ts +76 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +109 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/live-plane.d.ts +51 -0
- package/dist/bootstrap/live-plane.d.ts.map +1 -0
- package/dist/bootstrap/live-plane.js +72 -0
- package/dist/bootstrap/live-plane.js.map +1 -0
- package/dist/bootstrap/load-tool-capabilities.d.ts +42 -0
- package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -0
- package/dist/bootstrap/load-tool-capabilities.js +76 -0
- package/dist/bootstrap/load-tool-capabilities.js.map +1 -0
- package/dist/bootstrap/output-plane.d.ts +37 -0
- package/dist/bootstrap/output-plane.d.ts.map +1 -0
- package/dist/bootstrap/output-plane.js +114 -0
- package/dist/bootstrap/output-plane.js.map +1 -0
- package/dist/bootstrap/owning-tool-init.d.ts +32 -0
- package/dist/bootstrap/owning-tool-init.d.ts.map +1 -0
- package/dist/bootstrap/owning-tool-init.js +69 -0
- package/dist/bootstrap/owning-tool-init.js.map +1 -0
- package/dist/bootstrap/pre-action-guards.d.ts +44 -0
- package/dist/bootstrap/pre-action-guards.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-guards.js +136 -0
- package/dist/bootstrap/pre-action-guards.js.map +1 -0
- package/dist/bootstrap/pre-action-hook.d.ts +68 -0
- package/dist/bootstrap/pre-action-hook.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-hook.js +289 -0
- package/dist/bootstrap/pre-action-hook.js.map +1 -0
- package/dist/bootstrap/pre-action-messages.d.ts +32 -0
- package/dist/bootstrap/pre-action-messages.d.ts.map +1 -0
- package/dist/bootstrap/pre-action-messages.js +49 -0
- package/dist/bootstrap/pre-action-messages.js.map +1 -0
- package/dist/bootstrap/process-idempotency.d.ts +17 -0
- package/dist/bootstrap/process-idempotency.d.ts.map +1 -0
- package/dist/bootstrap/process-idempotency.js +20 -0
- package/dist/bootstrap/process-idempotency.js.map +1 -0
- package/dist/bootstrap/register-language-adapters.d.ts +23 -0
- package/dist/bootstrap/register-language-adapters.d.ts.map +1 -0
- package/dist/bootstrap/register-language-adapters.js +35 -0
- package/dist/bootstrap/register-language-adapters.js.map +1 -0
- package/dist/bootstrap/register-tools.d.ts +228 -0
- package/dist/bootstrap/register-tools.d.ts.map +1 -0
- package/dist/bootstrap/register-tools.js +696 -0
- package/dist/bootstrap/register-tools.js.map +1 -0
- package/dist/bootstrap/render.d.ts +27 -0
- package/dist/bootstrap/render.d.ts.map +1 -0
- package/dist/bootstrap/render.js +53 -0
- package/dist/bootstrap/render.js.map +1 -0
- package/dist/bootstrap/report.d.ts +34 -0
- package/dist/bootstrap/report.d.ts.map +1 -0
- package/dist/bootstrap/report.js +47 -0
- package/dist/bootstrap/report.js.map +1 -0
- package/dist/bootstrap/run-plane.d.ts +105 -0
- package/dist/bootstrap/run-plane.d.ts.map +1 -0
- package/dist/bootstrap/run-plane.js +190 -0
- package/dist/bootstrap/run-plane.js.map +1 -0
- package/dist/bootstrap/scope-access.d.ts +68 -0
- package/dist/bootstrap/scope-access.d.ts.map +1 -0
- package/dist/bootstrap/scope-access.js +115 -0
- package/dist/bootstrap/scope-access.js.map +1 -0
- package/dist/bootstrap/state-seams.d.ts +14 -0
- package/dist/bootstrap/state-seams.d.ts.map +1 -0
- package/dist/bootstrap/state-seams.js +26 -0
- package/dist/bootstrap/state-seams.js.map +1 -0
- package/dist/bootstrap/tool-lifecycle.d.ts +102 -0
- package/dist/bootstrap/tool-lifecycle.d.ts.map +1 -0
- package/dist/bootstrap/tool-lifecycle.js +103 -0
- package/dist/bootstrap/tool-lifecycle.js.map +1 -0
- package/dist/bootstrap/tool-trust.d.ts +49 -0
- package/dist/bootstrap/tool-trust.d.ts.map +1 -0
- package/dist/bootstrap/tool-trust.js +65 -0
- package/dist/bootstrap/tool-trust.js.map +1 -0
- package/dist/bootstrap/validate-tool.d.ts +22 -0
- package/dist/bootstrap/validate-tool.d.ts.map +1 -0
- package/dist/bootstrap/validate-tool.js +38 -0
- package/dist/bootstrap/validate-tool.js.map +1 -0
- package/dist/cli-context.d.ts +38 -0
- package/dist/cli-context.d.ts.map +1 -0
- package/dist/cli-context.js +134 -0
- package/dist/cli-context.js.map +1 -0
- package/dist/commands/agent-catalog.d.ts +45 -0
- package/dist/commands/agent-catalog.d.ts.map +1 -0
- package/dist/commands/agent-catalog.js +115 -0
- package/dist/commands/agent-catalog.js.map +1 -0
- package/dist/commands/assemble-outcome.d.ts +69 -0
- package/dist/commands/assemble-outcome.d.ts.map +1 -0
- package/dist/commands/assemble-outcome.js +121 -0
- package/dist/commands/assemble-outcome.js.map +1 -0
- package/dist/commands/clear.d.ts +32 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +73 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/completion.d.ts +90 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +233 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/configure.d.ts +32 -0
- package/dist/commands/configure.d.ts.map +1 -0
- package/dist/commands/configure.js +94 -0
- package/dist/commands/configure.js.map +1 -0
- package/dist/commands/history.d.ts +18 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +48 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/host-command-specs.d.ts +49 -0
- package/dist/commands/host-command-specs.d.ts.map +1 -0
- package/dist/commands/host-command-specs.js +331 -0
- package/dist/commands/host-command-specs.js.map +1 -0
- package/dist/commands/host-subcommand-groups.d.ts +69 -0
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -0
- package/dist/commands/host-subcommand-groups.js +374 -0
- package/dist/commands/host-subcommand-groups.js.map +1 -0
- package/dist/commands/index.d.ts +36 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +36 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init/config-templates.d.ts +16 -0
- package/dist/commands/init/config-templates.d.ts.map +1 -0
- package/dist/commands/init/config-templates.js +108 -0
- package/dist/commands/init/config-templates.js.map +1 -0
- package/dist/commands/init/file-classifier.d.ts +40 -0
- package/dist/commands/init/file-classifier.d.ts.map +1 -0
- package/dist/commands/init/file-classifier.js +155 -0
- package/dist/commands/init/file-classifier.js.map +1 -0
- package/dist/commands/init/language-detection.d.ts +44 -0
- package/dist/commands/init/language-detection.d.ts.map +1 -0
- package/dist/commands/init/language-detection.js +124 -0
- package/dist/commands/init/language-detection.js.map +1 -0
- package/dist/commands/init/scaffold-writer.d.ts +26 -0
- package/dist/commands/init/scaffold-writer.d.ts.map +1 -0
- package/dist/commands/init/scaffold-writer.js +102 -0
- package/dist/commands/init/scaffold-writer.js.map +1 -0
- package/dist/commands/init/state-machine.d.ts +32 -0
- package/dist/commands/init/state-machine.d.ts.map +1 -0
- package/dist/commands/init/state-machine.js +105 -0
- package/dist/commands/init/state-machine.js.map +1 -0
- package/dist/commands/init.d.ts +95 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +209 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mount-command-spec.d.ts +106 -0
- package/dist/commands/mount-command-spec.d.ts.map +1 -0
- package/dist/commands/mount-command-spec.js +313 -0
- package/dist/commands/mount-command-spec.js.map +1 -0
- package/dist/commands/mount-result-command.d.ts +71 -0
- package/dist/commands/mount-result-command.d.ts.map +1 -0
- package/dist/commands/mount-result-command.js +76 -0
- package/dist/commands/mount-result-command.js.map +1 -0
- package/dist/commands/plugin/config-edit.d.ts +20 -0
- package/dist/commands/plugin/config-edit.d.ts.map +1 -0
- package/dist/commands/plugin/config-edit.js +102 -0
- package/dist/commands/plugin/config-edit.js.map +1 -0
- package/dist/commands/plugin/domain-resolution.d.ts +38 -0
- package/dist/commands/plugin/domain-resolution.d.ts.map +1 -0
- package/dist/commands/plugin/domain-resolution.js +98 -0
- package/dist/commands/plugin/domain-resolution.js.map +1 -0
- package/dist/commands/plugin/host-dir.d.ts +42 -0
- package/dist/commands/plugin/host-dir.d.ts.map +1 -0
- package/dist/commands/plugin/host-dir.js +168 -0
- package/dist/commands/plugin/host-dir.js.map +1 -0
- package/dist/commands/plugin-host-ops.d.ts +41 -0
- package/dist/commands/plugin-host-ops.d.ts.map +1 -0
- package/dist/commands/plugin-host-ops.js +114 -0
- package/dist/commands/plugin-host-ops.js.map +1 -0
- package/dist/commands/plugin.d.ts +81 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +287 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/render-outcome.d.ts +52 -0
- package/dist/commands/render-outcome.d.ts.map +1 -0
- package/dist/commands/render-outcome.js +55 -0
- package/dist/commands/render-outcome.js.map +1 -0
- package/dist/commands/session-show.d.ts +27 -0
- package/dist/commands/session-show.d.ts.map +1 -0
- package/dist/commands/session-show.js +166 -0
- package/dist/commands/session-show.js.map +1 -0
- package/dist/commands/shared.d.ts +107 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +13 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/tools/data-purge.d.ts +20 -0
- package/dist/commands/tools/data-purge.d.ts.map +1 -0
- package/dist/commands/tools/data-purge.js +59 -0
- package/dist/commands/tools/data-purge.js.map +1 -0
- package/dist/commands/tools/index.d.ts +16 -0
- package/dist/commands/tools/index.d.ts.map +1 -0
- package/dist/commands/tools/index.js +213 -0
- package/dist/commands/tools/index.js.map +1 -0
- package/dist/commands/tools/install.d.ts +24 -0
- package/dist/commands/tools/install.d.ts.map +1 -0
- package/dist/commands/tools/install.js +83 -0
- package/dist/commands/tools/install.js.map +1 -0
- package/dist/commands/tools/list.d.ts +41 -0
- package/dist/commands/tools/list.d.ts.map +1 -0
- package/dist/commands/tools/list.js +103 -0
- package/dist/commands/tools/list.js.map +1 -0
- package/dist/commands/tools/runtime-probe-entry.d.ts +14 -0
- package/dist/commands/tools/runtime-probe-entry.d.ts.map +1 -0
- package/dist/commands/tools/runtime-probe-entry.js +36 -0
- package/dist/commands/tools/runtime-probe-entry.js.map +1 -0
- package/dist/commands/tools/runtime-probe.d.ts +29 -0
- package/dist/commands/tools/runtime-probe.d.ts.map +1 -0
- package/dist/commands/tools/runtime-probe.js +66 -0
- package/dist/commands/tools/runtime-probe.js.map +1 -0
- package/dist/commands/tools/storage-contract-checks.d.ts +37 -0
- package/dist/commands/tools/storage-contract-checks.d.ts.map +1 -0
- package/dist/commands/tools/storage-contract-checks.js +91 -0
- package/dist/commands/tools/storage-contract-checks.js.map +1 -0
- package/dist/commands/tools/uninstall.d.ts +29 -0
- package/dist/commands/tools/uninstall.d.ts.map +1 -0
- package/dist/commands/tools/uninstall.js +77 -0
- package/dist/commands/tools/uninstall.js.map +1 -0
- package/dist/commands/tools/validate.d.ts +44 -0
- package/dist/commands/tools/validate.d.ts.map +1 -0
- package/dist/commands/tools/validate.js +202 -0
- package/dist/commands/tools/validate.js.map +1 -0
- package/dist/commands/uninstall/targets.d.ts +53 -0
- package/dist/commands/uninstall/targets.d.ts.map +1 -0
- package/dist/commands/uninstall/targets.js +205 -0
- package/dist/commands/uninstall/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +88 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +184 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/env/host-env-specs.d.ts +52 -0
- package/dist/env/host-env-specs.d.ts.map +1 -0
- package/dist/env/host-env-specs.js +129 -0
- package/dist/env/host-env-specs.js.map +1 -0
- package/dist/error-handler.d.ts +64 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +180 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/open-report.d.ts +40 -0
- package/dist/open-report.d.ts.map +1 -0
- package/dist/open-report.js +54 -0
- package/dist/open-report.js.map +1 -0
- package/dist/report-compose.d.ts +35 -0
- package/dist/report-compose.d.ts.map +1 -0
- package/dist/report-compose.js +103 -0
- package/dist/report-compose.js.map +1 -0
- package/dist/session-replay-registry.d.ts +20 -0
- package/dist/session-replay-registry.d.ts.map +1 -0
- package/dist/session-replay-registry.js +38 -0
- package/dist/session-replay-registry.js.map +1 -0
- package/dist/telemetry/profiling.d.ts +42 -0
- package/dist/telemetry/profiling.d.ts.map +1 -0
- package/dist/telemetry/profiling.js +160 -0
- package/dist/telemetry/profiling.js.map +1 -0
- package/dist/telemetry/sdk-init.d.ts +87 -0
- package/dist/telemetry/sdk-init.d.ts.map +1 -0
- package/dist/telemetry/sdk-init.js +235 -0
- package/dist/telemetry/sdk-init.js.map +1 -0
- package/dist/ui/App.d.ts +32 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +35 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/render.d.ts +15 -0
- package/dist/ui/render.d.ts.map +1 -0
- package/dist/ui/render.js +21 -0
- package/dist/ui/render.js.map +1 -0
- package/dist/ui/result-to-view.d.ts +40 -0
- package/dist/ui/result-to-view.d.ts.map +1 -0
- package/dist/ui/result-to-view.js +389 -0
- package/dist/ui/result-to-view.js.map +1 -0
- package/dist/ui/views/init-view.d.ts +9 -0
- package/dist/ui/views/init-view.d.ts.map +1 -0
- package/dist/ui/views/init-view.js +119 -0
- package/dist/ui/views/init-view.js.map +1 -0
- package/dist/ui/views/misc-views.d.ts +18 -0
- package/dist/ui/views/misc-views.d.ts.map +1 -0
- package/dist/ui/views/misc-views.js +244 -0
- package/dist/ui/views/misc-views.js.map +1 -0
- package/dist/ui/views/plugin-view.d.ts +8 -0
- package/dist/ui/views/plugin-view.d.ts.map +1 -0
- package/dist/ui/views/plugin-view.js +135 -0
- package/dist/ui/views/plugin-view.js.map +1 -0
- package/dist/ui/views/tools-views.d.ts +12 -0
- package/dist/ui/views/tools-views.d.ts.map +1 -0
- package/dist/ui/views/tools-views.js +152 -0
- package/dist/ui/views/tools-views.js.map +1 -0
- package/dist/update-notifier.d.ts +108 -0
- package/dist/update-notifier.d.ts.map +1 -0
- package/dist/update-notifier.js +188 -0
- package/dist/update-notifier.js.map +1 -0
- package/dist/update-state.d.ts +40 -0
- package/dist/update-state.d.ts.map +1 -0
- package/dist/update-state.js +81 -0
- package/dist/update-state.js.map +1 -0
- package/dist/welcome.d.ts +53 -0
- package/dist/welcome.d.ts.map +1 -0
- package/dist/welcome.js +89 -0
- package/dist/welcome.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// @fitness-ignore-file error-handling-quality -- best-effort cloud egress (ADR-0008): repo-identity detection and signal emission degrade silently (no git, network error). A cloud failure never blocks, slows, or fails the user's run.
|
|
2
|
+
/**
|
|
3
|
+
* deliver-envelope — the composition root's signal-delivery step (ADR-0011,
|
|
4
|
+
* Phase 3).
|
|
5
|
+
*
|
|
6
|
+
* After a tool returns its {@link SignalEnvelope}, the root — not the tool —
|
|
7
|
+
* delivers it to the effectful sinks:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Cloud sync (best-effort).** Map the envelope → `SignalBatch`
|
|
10
|
+
* (`@opensip-cli/core` `buildSignalBatch`, adding repo identity and
|
|
11
|
+
* preserving the envelope's `runId`/`createdAt`; dropping `verdict`/`units`
|
|
12
|
+
* — the cloud wire shape stays `schemaVersion: 1`) and emit it through the
|
|
13
|
+
* run's `scope.signalSink`. The sink is a no-op for the keyless / not-
|
|
14
|
+
* entitled majority. NEVER throws, NEVER affects the exit code (ADR-0008).
|
|
15
|
+
* Ships the envelope's signals as-is — **no SARIF detour** on this path.
|
|
16
|
+
*
|
|
17
|
+
* 2. **`--report-to` (owns exit code 4).** When `reportTo` is set, format the
|
|
18
|
+
* envelope to SARIF via the single shared `formatSignalSarif` formatter and
|
|
19
|
+
* POST it through the shared chunked transport (`postChunked`). An upload
|
|
20
|
+
* failure exits `EXIT_CODES.REPORT_FAILED` (4) — but only when the run
|
|
21
|
+
* otherwise passed; a real check/gate failure (`runFailed`) dominates and
|
|
22
|
+
* is never masked by a reporting failure (ADR-0008).
|
|
23
|
+
*
|
|
24
|
+
* This is the seam that keeps tool engines free of `@opensip-cli/output`:
|
|
25
|
+
* engines return envelopes, and the composition root owns formatting,
|
|
26
|
+
* delivery, and report-upload exit-code policy.
|
|
27
|
+
*/
|
|
28
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
29
|
+
import { dirname } from 'node:path';
|
|
30
|
+
import { EXIT_CODES } from '@opensip-cli/contracts';
|
|
31
|
+
import { buildSignalBatch, currentScope, logger as defaultLogger } from '@opensip-cli/core';
|
|
32
|
+
import { formatSignalSarif, postChunked, resolveRepoIdentity, } from '@opensip-cli/output';
|
|
33
|
+
const MODULE_TAG = 'cli:bootstrap';
|
|
34
|
+
/**
|
|
35
|
+
* Map a {@link SignalEnvelope} to the cloud {@link SignalBatch} wire shape:
|
|
36
|
+
* add repo identity, preserve the run identity, drop `verdict`/`units`.
|
|
37
|
+
*/
|
|
38
|
+
export function envelopeToSignalBatch(envelope, repo) {
|
|
39
|
+
return buildSignalBatch({
|
|
40
|
+
tool: envelope.tool,
|
|
41
|
+
recipe: envelope.recipe,
|
|
42
|
+
repo,
|
|
43
|
+
signals: envelope.signals,
|
|
44
|
+
runId: envelope.runId,
|
|
45
|
+
createdAt: envelope.createdAt,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Best-effort cloud emit through the run's selected signal sink. Never throws.
|
|
50
|
+
*
|
|
51
|
+
* Best-effort ≠ silent: when the user CONFIGURED cloud sync (an active, non-noop
|
|
52
|
+
* sink) and the run had signals to ship but none were accepted, a one-line
|
|
53
|
+
* stderr notice says so — otherwise the user reasonably believes their signals
|
|
54
|
+
* shipped. The keyless / opted-out majority (no sink or the no-op sink) stays
|
|
55
|
+
* silent: there, nothing-shipped is exactly what they asked for. Exit code is
|
|
56
|
+
* never affected (ADR-0008).
|
|
57
|
+
*/
|
|
58
|
+
async function emitToCloud(envelope, repo, log) {
|
|
59
|
+
try {
|
|
60
|
+
const scope = currentScope();
|
|
61
|
+
if (!scope) {
|
|
62
|
+
log.warn({
|
|
63
|
+
evt: 'cli.deliver.no_scope',
|
|
64
|
+
module: MODULE_TAG,
|
|
65
|
+
});
|
|
66
|
+
return { accepted: 0, skippedReason: 'error' };
|
|
67
|
+
}
|
|
68
|
+
const sink = scope.signalSink;
|
|
69
|
+
// Behavioral discriminator, not identity: ANY no-op sink (a host's own
|
|
70
|
+
// included) means "the user asked for no delivery" → stay silent.
|
|
71
|
+
if (!sink || sink.noop === true)
|
|
72
|
+
return { accepted: 0 };
|
|
73
|
+
const batch = envelopeToSignalBatch(envelope, repo);
|
|
74
|
+
const result = await sink.emit(batch);
|
|
75
|
+
if (result.accepted > 0) {
|
|
76
|
+
const noun = result.accepted === 1 ? 'signal' : 'signals';
|
|
77
|
+
process.stderr.write(`✓ Sent ${result.accepted} ${noun} to OpenSIP Cloud\n`);
|
|
78
|
+
return { accepted: result.accepted };
|
|
79
|
+
}
|
|
80
|
+
if (batch.signals.length === 0)
|
|
81
|
+
return { accepted: 0 };
|
|
82
|
+
const skippedReason = result.skippedReason ?? 'error';
|
|
83
|
+
// Only surface a human stderr notice for transient upload errors.
|
|
84
|
+
// "unentitled" is a steady-state property of the key/plan (configure already
|
|
85
|
+
// warned the user, and local results are always unaffected per ADR-0008).
|
|
86
|
+
// The Deliver result still carries cloudSkippedReason for hosts/observability.
|
|
87
|
+
if (skippedReason === 'error') {
|
|
88
|
+
process.stderr.write(`opensip: cloud sync skipped — the upload failed (see the run log); ` +
|
|
89
|
+
`${batch.signals.length} signal(s) were NOT uploaded. ` +
|
|
90
|
+
`Local results are unaffected (silence this with --no-cloud).\n`);
|
|
91
|
+
}
|
|
92
|
+
return { accepted: 0, skippedReason };
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
log.warn({
|
|
96
|
+
evt: 'cli.signal-egress.error',
|
|
97
|
+
module: MODULE_TAG,
|
|
98
|
+
error: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
100
|
+
return { accepted: 0, skippedReason: 'error' };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** POST the envelope's SARIF to a `--report-to` receiver via the chunked transport. */
|
|
104
|
+
async function reportSarif(envelope, url, apiKey, fetchImpl) {
|
|
105
|
+
const sarif = formatSignalSarif(envelope);
|
|
106
|
+
// The receiver accepts a SARIF body at `<url>/sarif`; one chunk (the whole
|
|
107
|
+
// SARIF log) — the envelope is already capped upstream.
|
|
108
|
+
const target = url.endsWith('/sarif') ? url : `${url}/sarif`;
|
|
109
|
+
return postChunked({
|
|
110
|
+
url: target,
|
|
111
|
+
apiKey,
|
|
112
|
+
chunks: [JSON.parse(sarif)],
|
|
113
|
+
idempotencyKeyFor: (i) => `${envelope.runId}:report:${i}`,
|
|
114
|
+
timeoutFor: () => Math.min(300_000, 60_000 + envelope.signals.length * 100),
|
|
115
|
+
policy: { maxAttempts: 3, overallDeadlineMs: 300_000, honorRetryAfter: true },
|
|
116
|
+
evtPrefix: 'cli.report',
|
|
117
|
+
fetchImpl,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The root's post-run signal-delivery step. Emits the envelope to the cloud
|
|
122
|
+
* sink (best-effort) and, when `--report-to` is set, uploads its SARIF
|
|
123
|
+
* (owning exit code 4). Never throws.
|
|
124
|
+
*/
|
|
125
|
+
export async function deliverEnvelope(envelope, opts) {
|
|
126
|
+
const log = opts.logger ?? defaultLogger;
|
|
127
|
+
const repo = opts.repo ?? resolveRepoIdentity(opts.cwd);
|
|
128
|
+
const scope = currentScope();
|
|
129
|
+
if (!scope) {
|
|
130
|
+
log.warn({
|
|
131
|
+
evt: 'cli.deliver.no_scope',
|
|
132
|
+
module: MODULE_TAG,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// Record delivery start on the scope diagnostics (if any) so the 'deliver' phase
|
|
136
|
+
// of the uniform lifecycle is visible in CommandOutcome for --json consumers.
|
|
137
|
+
// This improves observability of the root-owned egress path (architecture review).
|
|
138
|
+
void scope?.diagnostics.event('deliver', 'debug', `deliver start for ${envelope.tool}`, {
|
|
139
|
+
tool: envelope.tool,
|
|
140
|
+
recipe: envelope.recipe,
|
|
141
|
+
signalCount: envelope.signals.length,
|
|
142
|
+
reportTo: !!opts.reportTo,
|
|
143
|
+
});
|
|
144
|
+
// ADR-0035: the host owns the findings exit code. For a normal run it is a pure
|
|
145
|
+
// function of the run's single verdict — `envelope.verdict.passed` — so no tool
|
|
146
|
+
// computes its own exit; gate-compare overrides with its baseline-diff verdict.
|
|
147
|
+
// Set RUNTIME_ERROR first; the `--report-to` exit-4 below only applies when the
|
|
148
|
+
// run otherwise passed, so a real failure always dominates (last-write-wins).
|
|
149
|
+
const runFailed = opts.runFailed ?? !envelope.verdict.passed;
|
|
150
|
+
if (runFailed)
|
|
151
|
+
opts.setExitCode?.(EXIT_CODES.RUNTIME_ERROR);
|
|
152
|
+
const cloud = await emitToCloud(envelope, repo, log);
|
|
153
|
+
const cloudAccepted = cloud.accepted;
|
|
154
|
+
const cloudLeg = {
|
|
155
|
+
cloudAccepted,
|
|
156
|
+
...(cloud.skippedReason === undefined ? {} : { cloudSkippedReason: cloud.skippedReason }),
|
|
157
|
+
};
|
|
158
|
+
const cloudSuffix = cloud.skippedReason ? ` (skipped:${cloud.skippedReason})` : '';
|
|
159
|
+
void scope?.diagnostics.event('deliver', 'debug', `cloud egress: accepted=${cloudAccepted}${cloudSuffix}`);
|
|
160
|
+
if (opts.reportTo === undefined || opts.reportTo.length === 0) {
|
|
161
|
+
return cloudLeg;
|
|
162
|
+
}
|
|
163
|
+
const result = await reportSarif(envelope, opts.reportTo, opts.apiKey, opts.fetchImpl);
|
|
164
|
+
const reportSuccess = result.outcome === 'ok';
|
|
165
|
+
if (!reportSuccess) {
|
|
166
|
+
process.stderr.write(`opensip: --report-to failed (${opts.reportTo}): ` +
|
|
167
|
+
`${result.errors.length > 0 ? result.errors.join('; ') : 'unknown error'}\n`);
|
|
168
|
+
}
|
|
169
|
+
// Exit-code contract (ADR-0008): a report-upload failure exits 4 — but only
|
|
170
|
+
// when the run otherwise passed; a real failure (`runFailed`, derived from the
|
|
171
|
+
// verdict above) dominates.
|
|
172
|
+
if (!reportSuccess && !runFailed) {
|
|
173
|
+
opts.setExitCode?.(EXIT_CODES.REPORT_FAILED);
|
|
174
|
+
}
|
|
175
|
+
void scope?.diagnostics.event('deliver', reportSuccess ? 'info' : 'warn', `report-to ${reportSuccess ? 'succeeded' : 'failed'}`, {
|
|
176
|
+
url: opts.reportTo,
|
|
177
|
+
success: reportSuccess,
|
|
178
|
+
});
|
|
179
|
+
return { ...cloudLeg, reportSuccess, reportUrl: opts.reportTo };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Root-owned SARIF-**file** sink (ADR-0011): format the envelope to SARIF via
|
|
183
|
+
* the single shared `formatSignalSarif` formatter and write the bytes to
|
|
184
|
+
* `path`, creating parent directories as needed. This is the seam behind
|
|
185
|
+
* `ToolCliContext.writeSarif` — a tool that exports SARIF to a file (e.g.
|
|
186
|
+
* `graph sarif-export`) routes through it instead of importing
|
|
187
|
+
* `@opensip-cli/output` itself. The formatter is pure; this function owns
|
|
188
|
+
* the effect (fs write).
|
|
189
|
+
*/
|
|
190
|
+
export async function writeEnvelopeSarif(envelope, path) {
|
|
191
|
+
const sarif = formatSignalSarif(envelope);
|
|
192
|
+
await mkdir(dirname(path), { recursive: true });
|
|
193
|
+
await writeFile(path, sarif);
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=deliver-envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliver-envelope.js","sourceRoot":"","sources":["../../src/bootstrap/deliver-envelope.ts"],"names":[],"mappings":"AAAA,0OAA0O;AAC1O;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,mBAAmB,GAEpB,MAAM,qBAAqB,CAAC;AAK7B,MAAM,UAAU,GAAG,eAAe,CAAC;AAkCnC;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAwB,EAAE,IAAkB;IAChF,OAAO,gBAAgB,CAAC;QACtB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI;QACJ,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;KAC9B,CAAC,CAAC;AACL,CAAC;AAQD;;;;;;;;;GASG;AACH,KAAK,UAAU,WAAW,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AAE,CAAC;QACjC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,KAAK,EAAE,WAAW,CAAC,KAAK,CAC3B,SAAS,EACT,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAC/B,aAAa,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,EACrD;QACE,GAAG,EAAE,IAAI,CAAC,QAAQ;QAClB,OAAO,EAAE,aAAa;KACvB,CACF,CAAC;IAEF,OAAO,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAwB,EAAE,IAAY;IAC7E,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* egress-plane — the host's effectful-egress plane
|
|
3
|
+
* (host-owned-run-timing Phase 6 §6.1).
|
|
4
|
+
*
|
|
5
|
+
* The composition root owns all outbound delivery (ADR-0011 / ADR-0008): cloud
|
|
6
|
+
* sync via the run's signal sink + `--report-to` SARIF upload, and the
|
|
7
|
+
* SARIF-file sink. Tools never import `@opensip-cli/output`; they call these two
|
|
8
|
+
* `ToolCliContext` seams, which delegate to the existing `deliver-envelope`
|
|
9
|
+
* implementation. Extracted from `buildToolCliContext` so the egress concern has
|
|
10
|
+
* its own narrow, testable home.
|
|
11
|
+
*/
|
|
12
|
+
import { type Logger, type ToolCliContext } from '@opensip-cli/core';
|
|
13
|
+
/** Stable dependencies the egress plane captures. */
|
|
14
|
+
export interface EgressPlaneDeps {
|
|
15
|
+
/** The single exit-code write path (from the output plane) — threaded into delivery. */
|
|
16
|
+
readonly setExitCode: (code: number) => void;
|
|
17
|
+
readonly logger?: Logger;
|
|
18
|
+
}
|
|
19
|
+
/** The egress plane's public surface (the two `ToolCliContext` egress seams). */
|
|
20
|
+
export type EgressPlane = Pick<ToolCliContext, 'deliverSignals' | 'writeSarif'>;
|
|
21
|
+
export declare function createEgressPlane(deps: EgressPlaneDeps): EgressPlane;
|
|
22
|
+
//# sourceMappingURL=egress-plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"egress-plane.d.ts","sourceRoot":"","sources":["../../src/bootstrap/egress-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA2B,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAM9F,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,YAAY,CAAC,CAAC;AAEhF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAuBpE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* egress-plane — the host's effectful-egress plane
|
|
3
|
+
* (host-owned-run-timing Phase 6 §6.1).
|
|
4
|
+
*
|
|
5
|
+
* The composition root owns all outbound delivery (ADR-0011 / ADR-0008): cloud
|
|
6
|
+
* sync via the run's signal sink + `--report-to` SARIF upload, and the
|
|
7
|
+
* SARIF-file sink. Tools never import `@opensip-cli/output`; they call these two
|
|
8
|
+
* `ToolCliContext` seams, which delegate to the existing `deliver-envelope`
|
|
9
|
+
* implementation. Extracted from `buildToolCliContext` so the egress concern has
|
|
10
|
+
* its own narrow, testable home.
|
|
11
|
+
*/
|
|
12
|
+
import { logger as defaultLogger } from '@opensip-cli/core';
|
|
13
|
+
import { deliverEnvelope, writeEnvelopeSarif } from './deliver-envelope.js';
|
|
14
|
+
export function createEgressPlane(deps) {
|
|
15
|
+
const log = deps.logger ?? defaultLogger;
|
|
16
|
+
return {
|
|
17
|
+
// The root owns all effectful egress (ADR-0011 / ADR-0008): cloud sync via
|
|
18
|
+
// the run's signal sink + `--report-to` SARIF upload. Tools call this once
|
|
19
|
+
// per run; `setExitCode` is threaded so a `--report-to` failure on an
|
|
20
|
+
// otherwise-passing run can claim exit 4. The delivery result (what actually
|
|
21
|
+
// shipped / why a leg was skipped) flows back to the caller — the root has
|
|
22
|
+
// already printed any user-facing notice, so callers may ignore it.
|
|
23
|
+
deliverSignals: (envelope, deliverOpts) => deliverEnvelope(envelope, {
|
|
24
|
+
cwd: deliverOpts.cwd,
|
|
25
|
+
reportTo: deliverOpts.reportTo,
|
|
26
|
+
apiKey: deliverOpts.apiKey,
|
|
27
|
+
runFailed: deliverOpts.runFailed,
|
|
28
|
+
setExitCode: deps.setExitCode,
|
|
29
|
+
logger: log,
|
|
30
|
+
}),
|
|
31
|
+
// Root-owned SARIF-file sink (ADR-0011): the one place that formats an
|
|
32
|
+
// envelope to SARIF and writes it to disk, so tools that export SARIF to a
|
|
33
|
+
// file (e.g. `graph sarif-export`) never import `@opensip-cli/output`.
|
|
34
|
+
writeSarif: (envelope, path) => writeEnvelopeSarif(envelope, path),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=egress-plane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"egress-plane.js","sourceRoot":"","sources":["../../src/bootstrap/egress-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,IAAI,aAAa,EAAoC,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAc5E,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC;IACzC,OAAO;QACL,2EAA2E;QAC3E,2EAA2E;QAC3E,sEAAsE;QACtE,6EAA6E;QAC7E,2EAA2E;QAC3E,oEAAoE;QACpE,cAAc,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CACxC,eAAe,CAAC,QAA0B,EAAE;YAC1C,GAAG,EAAE,WAAW,CAAC,GAAG;YACpB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,MAAM,EAAE,GAAG;SACZ,CAAC;QACJ,uEAAuE;QACvE,2EAA2E;QAC3E,uEAAuE;QACvE,UAAU,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,QAA0B,EAAE,IAAI,CAAC;KACrF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* host-planes — builder for the `hostPlanes` evolution bag on ToolCliContext.
|
|
3
|
+
*
|
|
4
|
+
* This wires the combined Host-Owned Governance, Entitlements, and Audit Plane.
|
|
5
|
+
* Storage is delegated to the existing toolState seam / ToolStateRepo (namespaced
|
|
6
|
+
* keys under the single host-owned `tool_state` table per ADR-0042).
|
|
7
|
+
*
|
|
8
|
+
* The builder is intentionally small and host-owned (cli package). Core only
|
|
9
|
+
* defines the shape in ToolCliContext.
|
|
10
|
+
*
|
|
11
|
+
* Real method bodies for governance/audit/entitlements land in subsequent phases.
|
|
12
|
+
* This phase only ensures the bag is constructed and attached so the type is
|
|
13
|
+
* satisfied and the surface exists for tools + host commands.
|
|
14
|
+
*/
|
|
15
|
+
import { type DataStore } from '@opensip-cli/datastore';
|
|
16
|
+
import type { Logger, ToolCliContext } from '@opensip-cli/core';
|
|
17
|
+
/**
|
|
18
|
+
* Build the hostPlanes bag.
|
|
19
|
+
*
|
|
20
|
+
* Real implementations for the three sub-planes. Storage uses namespaced keys
|
|
21
|
+
* over the existing host-owned `tool_state` table (via ToolStateRepo).
|
|
22
|
+
* See the governing spec and plan for key conventions and rationale.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildHostPlanes(opts: {
|
|
25
|
+
getDatastore: () => DataStore;
|
|
26
|
+
logger?: Logger;
|
|
27
|
+
}): ToolCliContext['hostPlanes'];
|
|
28
|
+
//# sourceMappingURL=host-planes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-planes.d.ts","sourceRoot":"","sources":["../../src/bootstrap/host-planes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,KAAK,EAIV,MAAM,EACN,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,YAAY,EAAE,MAAM,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,cAAc,CAAC,YAAY,CAAC,CAqI/B"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* host-planes — builder for the `hostPlanes` evolution bag on ToolCliContext.
|
|
3
|
+
*
|
|
4
|
+
* This wires the combined Host-Owned Governance, Entitlements, and Audit Plane.
|
|
5
|
+
* Storage is delegated to the existing toolState seam / ToolStateRepo (namespaced
|
|
6
|
+
* keys under the single host-owned `tool_state` table per ADR-0042).
|
|
7
|
+
*
|
|
8
|
+
* The builder is intentionally small and host-owned (cli package). Core only
|
|
9
|
+
* defines the shape in ToolCliContext.
|
|
10
|
+
*
|
|
11
|
+
* Real method bodies for governance/audit/entitlements land in subsequent phases.
|
|
12
|
+
* This phase only ensures the bag is constructed and attached so the type is
|
|
13
|
+
* satisfied and the surface exists for tools + host commands.
|
|
14
|
+
*/
|
|
15
|
+
import { ToolStateRepo } from '@opensip-cli/datastore';
|
|
16
|
+
/**
|
|
17
|
+
* Build the hostPlanes bag.
|
|
18
|
+
*
|
|
19
|
+
* Real implementations for the three sub-planes. Storage uses namespaced keys
|
|
20
|
+
* over the existing host-owned `tool_state` table (via ToolStateRepo).
|
|
21
|
+
* See the governing spec and plan for key conventions and rationale.
|
|
22
|
+
*/
|
|
23
|
+
export function buildHostPlanes(opts) {
|
|
24
|
+
const log = opts.logger;
|
|
25
|
+
let repo;
|
|
26
|
+
const getRepo = () => {
|
|
27
|
+
if (!repo) {
|
|
28
|
+
const ds = opts.getDatastore();
|
|
29
|
+
repo = new ToolStateRepo(ds);
|
|
30
|
+
}
|
|
31
|
+
return repo;
|
|
32
|
+
};
|
|
33
|
+
// Simple read-modify-write helpers for object blobs under a top-level key.
|
|
34
|
+
// For production audit volume we would chunk (see spec), but this satisfies
|
|
35
|
+
// the first-cut contract and respects the 256 KiB per-payload cap.
|
|
36
|
+
const readBlob = (toolId, key) => {
|
|
37
|
+
return getRepo().get(toolId, key);
|
|
38
|
+
};
|
|
39
|
+
const writeBlob = (toolId, key, value) => {
|
|
40
|
+
getRepo().put(toolId, key, value);
|
|
41
|
+
};
|
|
42
|
+
const governanceImpl = {
|
|
43
|
+
async getGovernanceState(toolId) {
|
|
44
|
+
await Promise.resolve();
|
|
45
|
+
return readBlob(toolId, 'governance');
|
|
46
|
+
},
|
|
47
|
+
async listForProject(_projectRoot) {
|
|
48
|
+
await Promise.resolve();
|
|
49
|
+
// First-cut: the host (or future Cloud) would index; here we return empty.
|
|
50
|
+
// Real listing can be added by scanning known tools or a meta index key.
|
|
51
|
+
return [];
|
|
52
|
+
},
|
|
53
|
+
async queryAudit(toolId, _filter) {
|
|
54
|
+
await Promise.resolve();
|
|
55
|
+
const entries = readBlob(toolId, 'audit') ?? [];
|
|
56
|
+
return entries;
|
|
57
|
+
},
|
|
58
|
+
async recordInstallation(toolId, record) {
|
|
59
|
+
const current = readBlob(toolId, 'governance') ?? {};
|
|
60
|
+
writeBlob(toolId, 'governance', {
|
|
61
|
+
...current,
|
|
62
|
+
installed: true,
|
|
63
|
+
lastInstallation: record,
|
|
64
|
+
updatedAt: Date.now(),
|
|
65
|
+
});
|
|
66
|
+
if (log)
|
|
67
|
+
log.debug({ evt: 'cli.governance.install-recorded', tool: toolId });
|
|
68
|
+
await Promise.resolve();
|
|
69
|
+
},
|
|
70
|
+
async recordApprovalDecision(toolId, decision) {
|
|
71
|
+
const current = readBlob(toolId, 'governance') ?? {};
|
|
72
|
+
const approvals = current.approvals ?? [];
|
|
73
|
+
writeBlob(toolId, 'governance', {
|
|
74
|
+
...current,
|
|
75
|
+
approvals: [...approvals, decision],
|
|
76
|
+
updatedAt: Date.now(),
|
|
77
|
+
});
|
|
78
|
+
await Promise.resolve();
|
|
79
|
+
},
|
|
80
|
+
async setBlock(toolId, blocked, reason) {
|
|
81
|
+
const current = readBlob(toolId, 'governance') ?? {};
|
|
82
|
+
writeBlob(toolId, 'governance', {
|
|
83
|
+
...current,
|
|
84
|
+
blocked,
|
|
85
|
+
blockReason: reason,
|
|
86
|
+
updatedAt: Date.now(),
|
|
87
|
+
});
|
|
88
|
+
await Promise.resolve();
|
|
89
|
+
},
|
|
90
|
+
async checkAllowed(toolId, _action) {
|
|
91
|
+
await Promise.resolve();
|
|
92
|
+
const state = readBlob(toolId, 'governance') ?? {};
|
|
93
|
+
// Default allow for tools without explicit governance record (additive).
|
|
94
|
+
return !state.blocked;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
const auditImpl = {
|
|
98
|
+
async append(toolId, entry) {
|
|
99
|
+
const current = readBlob(toolId, 'audit') ?? [];
|
|
100
|
+
const withTs = { ...entry, ts: Date.now() };
|
|
101
|
+
const next = [...current, withTs];
|
|
102
|
+
// Simple (no chunking yet). If over cap the underlying repo will throw
|
|
103
|
+
// ValidationError — matches the spec's "chunk if needed" escape hatch.
|
|
104
|
+
writeBlob(toolId, 'audit', next);
|
|
105
|
+
if (log)
|
|
106
|
+
log.debug({ evt: 'cli.audit.append', tool: toolId });
|
|
107
|
+
await Promise.resolve();
|
|
108
|
+
},
|
|
109
|
+
async query(toolId, _filter) {
|
|
110
|
+
await Promise.resolve();
|
|
111
|
+
return readBlob(toolId, 'audit') ?? [];
|
|
112
|
+
},
|
|
113
|
+
async exportForCloud(..._args) {
|
|
114
|
+
await Promise.resolve();
|
|
115
|
+
// Best-effort hook. Real Cloud sync will use existing deliverSignals
|
|
116
|
+
// or a dedicated path. For now just return the current log.
|
|
117
|
+
const entries = readBlob(_args[0] || '', 'audit') ?? [];
|
|
118
|
+
return { entries };
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const entitlementsImpl = {
|
|
122
|
+
async check(toolId, _action) {
|
|
123
|
+
await Promise.resolve();
|
|
124
|
+
const state = readBlob(toolId, 'entitlements') ?? {};
|
|
125
|
+
// Default entitled for anything not explicitly recorded (GA additive).
|
|
126
|
+
if (!state || Object.keys(state).length === 0) {
|
|
127
|
+
return { entitled: true, source: 'default' };
|
|
128
|
+
}
|
|
129
|
+
return state;
|
|
130
|
+
},
|
|
131
|
+
async recordUsage(toolId, usage) {
|
|
132
|
+
const current = readBlob(toolId, 'entitlements') ?? {};
|
|
133
|
+
writeBlob(toolId, 'entitlements', {
|
|
134
|
+
...current,
|
|
135
|
+
lastUsage: usage,
|
|
136
|
+
updatedAt: Date.now(),
|
|
137
|
+
});
|
|
138
|
+
await Promise.resolve();
|
|
139
|
+
},
|
|
140
|
+
async getLicenseState(toolId) {
|
|
141
|
+
await Promise.resolve();
|
|
142
|
+
const state = readBlob(toolId, 'entitlements') ?? {};
|
|
143
|
+
return state.license;
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
governance: governanceImpl,
|
|
148
|
+
audit: auditImpl,
|
|
149
|
+
entitlements: entitlementsImpl,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=host-planes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-planes.js","sourceRoot":"","sources":["../../src/bootstrap/host-planes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,aAAa,EAAkB,MAAM,wBAAwB,CAAC;AAUvE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAG/B;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,IAAI,IAA+B,CAAC;IAEpC,MAAM,OAAO,GAAG,GAAkB,EAAE;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC/B,IAAI,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,2EAA2E;IAC3E,4EAA4E;IAC5E,mEAAmE;IACnE,MAAM,QAAQ,GAAG,CAAI,MAAc,EAAE,GAAW,EAAiB,EAAE;QACjE,OAAO,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAkB,CAAC;IACrD,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,KAAc,EAAE,EAAE;QAChE,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,cAAc,GAAmB;QACrC,KAAK,CAAC,kBAAkB,CAAC,MAAc;YACrC,MAAM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AG,EAAE;aACtB,CAAC,CAAC;YACH,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,MAAc;YAClC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,QAAQ,CAA0B,MAAM,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC;YAC9E,OAAO,KAAK,CAAC,OAA8C,CAAC;QAC9D,CAAC;KACF,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,cAAc;QAC1B,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,gBAAgB;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bootstrap — performs the one-time (per-process) STARTUP phase registrations
|
|
3
|
+
* (language adapters + tool admission via the uniform dynamic path) and
|
|
4
|
+
* returns the populated registries + provenance/manifests to the composition
|
|
5
|
+
* root.
|
|
6
|
+
*
|
|
7
|
+
* The full 10-step canonical lifecycle (including the PER-RUN steps that
|
|
8
|
+
* happen later in the preAction hook) is documented in `tool-lifecycle.ts`.
|
|
9
|
+
* This module owns steps 1-4 (discover/compat/trust/import for bundled +
|
|
10
|
+
* installed + authored) plus the mount seam re-export.
|
|
11
|
+
*
|
|
12
|
+
* See tool-lifecycle.ts for the ordered steps and phase split.
|
|
13
|
+
*/
|
|
14
|
+
import { type LanguageRegistry, type ToolPluginManifest, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
|
|
15
|
+
export { mountAllToolCommands, EXPECTED_SCAFFOLDING_TOOL_IDS } from './register-tools.js';
|
|
16
|
+
export { admitToolPackage, importToolRuntime, type AdmissionReport, type AdmissionSection, type AdmissionSectionResult, type AdmitToolPackageOptions, } from './admit-tool-package.js';
|
|
17
|
+
export { mountToolCommands } from './tool-lifecycle.js';
|
|
18
|
+
export { renderResult } from './render.js';
|
|
19
|
+
export { maybeOpenReport } from './report.js';
|
|
20
|
+
export { installPreActionHook } from './pre-action-hook.js';
|
|
21
|
+
export { buildCommandRegistrationInput } from './build-command-registration-input.js';
|
|
22
|
+
export { buildHostPlanes } from './host-planes.js';
|
|
23
|
+
export interface BootstrapOptions {
|
|
24
|
+
readonly langRegistry: LanguageRegistry;
|
|
25
|
+
readonly toolRegistry: ToolRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* The CLI's own install directory. Anchors discovery of graph adapters
|
|
28
|
+
* and of tools installed as siblings of a global `opensip-cli`.
|
|
29
|
+
*/
|
|
30
|
+
readonly projectDir: string;
|
|
31
|
+
/**
|
|
32
|
+
* The user's working directory (process.cwd()). Anchors project-local
|
|
33
|
+
* and user-global tool discovery (a plain `npm install @tool`, the
|
|
34
|
+
* project's `.runtime/plugins/tool`, and `~/.opensip-cli/plugins/tool`).
|
|
35
|
+
*/
|
|
36
|
+
readonly cwd: string;
|
|
37
|
+
/**
|
|
38
|
+
* `import.meta.url` of the CLI entry. Used to init telemetry as early as
|
|
39
|
+
* possible (reads the CLI package version for the `service.version` resource
|
|
40
|
+
* attribute). Telemetry init is a no-op unless `OTEL_EXPORTER_OTLP_ENDPOINT`
|
|
41
|
+
* is set, so this is inert for standalone runs.
|
|
42
|
+
*/
|
|
43
|
+
readonly cliEntryUrl: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One-shot bootstrap: register language adapters, register the first-
|
|
47
|
+
* party tools, and discover-and-register every third-party tool +
|
|
48
|
+
* @opensip-cli/graph-* adapter pack. Datastore is NOT opened here —
|
|
49
|
+
* it's a lazy getter on ToolCliContext (cli-context.ts), so dry-runs
|
|
50
|
+
* and error paths that never read `cli.datastore` don't materialise
|
|
51
|
+
* `.runtime/datastore.sqlite`.
|
|
52
|
+
*
|
|
53
|
+
* Graph adapter discovery runs BEFORE `mountAllToolCommands`: the
|
|
54
|
+
* graph tool's `register()` method assumes adapters are already
|
|
55
|
+
* available so its lang-adapter registry isn't empty when the first
|
|
56
|
+
* `pickAdapter()` lands during a real run. PR 1a of plan
|
|
57
|
+
* docs/plans/architecture/2026-05-23-plan-graph-adapter-package-split.md.
|
|
58
|
+
*/
|
|
59
|
+
export declare function bootstrapCli(opts: BootstrapOptions): Promise<BootstrapResult>;
|
|
60
|
+
/** What {@link bootstrapCli} hands back to the composition root. */
|
|
61
|
+
export interface BootstrapResult {
|
|
62
|
+
/**
|
|
63
|
+
* Provenance for every tool admitted through the compatibility gate
|
|
64
|
+
* (bundled + installed), in registration order. Reachable by `plugin
|
|
65
|
+
* list` (Phase 4) via the cli-context per-run holder.
|
|
66
|
+
*/
|
|
67
|
+
readonly provenance: readonly ToolProvenance[];
|
|
68
|
+
/**
|
|
69
|
+
* Manifests for every tool admitted through the compatibility gate
|
|
70
|
+
* (bundled + installed), in registration order. The composition root
|
|
71
|
+
* seeds the per-run capability registry from these (§5.3) via the
|
|
72
|
+
* cli-context per-run holder.
|
|
73
|
+
*/
|
|
74
|
+
readonly manifests: readonly ToolPluginManifest[];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAkB3B,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAI1F,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO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