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,109 @@
|
|
|
1
|
+
// @fitness-ignore-file detached-promises -- bootstrap calls the synchronous registerLanguageAdapters and awaits the async tool registration helpers (registerFirstPartyTools, discoverAndRegisterToolPackages) that the heuristic flags
|
|
2
|
+
/**
|
|
3
|
+
* bootstrap — performs the one-time (per-process) STARTUP phase registrations
|
|
4
|
+
* (language adapters + tool admission via the uniform dynamic path) and
|
|
5
|
+
* returns the populated registries + provenance/manifests to the composition
|
|
6
|
+
* root.
|
|
7
|
+
*
|
|
8
|
+
* The full 10-step canonical lifecycle (including the PER-RUN steps that
|
|
9
|
+
* happen later in the preAction hook) is documented in `tool-lifecycle.ts`.
|
|
10
|
+
* This module owns steps 1-4 (discover/compat/trust/import for bundled +
|
|
11
|
+
* installed + authored) plus the mount seam re-export.
|
|
12
|
+
*
|
|
13
|
+
* See tool-lifecycle.ts for the ordered steps and phase split.
|
|
14
|
+
*/
|
|
15
|
+
import { resolveProjectContext, resolveProjectPaths, resolveUserPaths, } from '@opensip-cli/core';
|
|
16
|
+
import { hostEnv } from '../env/host-env-specs.js';
|
|
17
|
+
import { initTelemetry } from '../telemetry/sdk-init.js';
|
|
18
|
+
import { registerLanguageAdapters } from './register-language-adapters.js';
|
|
19
|
+
import { BUNDLED_TOOL_PACKAGES, registerFirstPartyTools, discoverAndRegisterToolPackages, discoverAndRegisterAuthoredTools, buildToolDiscoverySources, } from './register-tools.js';
|
|
20
|
+
// Re-export only the symbols the CLI composition root (`index.ts`) consumes.
|
|
21
|
+
// `mountToolCommands` is the named step-8 seam of the tool lifecycle (release
|
|
22
|
+
// launch, §5.4); it delegates to `mountAllToolCommands` (kept exported for the
|
|
23
|
+
// existing direct unit tests).
|
|
24
|
+
export { mountAllToolCommands, EXPECTED_SCAFFOLDING_TOOL_IDS } from './register-tools.js';
|
|
25
|
+
// The shared admission callable (ADR-0041: one validator, four consumers) —
|
|
26
|
+
// consumed by the tools command group (validate/install) and the
|
|
27
|
+
// admission-parity / bundled-conformance tests.
|
|
28
|
+
export { admitToolPackage, importToolRuntime, } from './admit-tool-package.js';
|
|
29
|
+
export { mountToolCommands } from './tool-lifecycle.js';
|
|
30
|
+
export { renderResult } from './render.js';
|
|
31
|
+
export { maybeOpenReport } from './report.js';
|
|
32
|
+
export { installPreActionHook } from './pre-action-hook.js';
|
|
33
|
+
export { buildCommandRegistrationInput } from './build-command-registration-input.js';
|
|
34
|
+
export { buildHostPlanes } from './host-planes.js';
|
|
35
|
+
/**
|
|
36
|
+
* One-shot bootstrap: register language adapters, register the first-
|
|
37
|
+
* party tools, and discover-and-register every third-party tool +
|
|
38
|
+
* @opensip-cli/graph-* adapter pack. Datastore is NOT opened here —
|
|
39
|
+
* it's a lazy getter on ToolCliContext (cli-context.ts), so dry-runs
|
|
40
|
+
* and error paths that never read `cli.datastore` don't materialise
|
|
41
|
+
* `.runtime/datastore.sqlite`.
|
|
42
|
+
*
|
|
43
|
+
* Graph adapter discovery runs BEFORE `mountAllToolCommands`: the
|
|
44
|
+
* graph tool's `register()` method assumes adapters are already
|
|
45
|
+
* available so its lang-adapter registry isn't empty when the first
|
|
46
|
+
* `pickAdapter()` lands during a real run. PR 1a of plan
|
|
47
|
+
* docs/plans/architecture/2026-05-23-plan-graph-adapter-package-split.md.
|
|
48
|
+
*/
|
|
49
|
+
export async function bootstrapCli(opts) {
|
|
50
|
+
// Telemetry first — before any tool runs — so provider registration happens
|
|
51
|
+
// once per process ahead of the first stage span. Hard no-op unless the OTLP
|
|
52
|
+
// endpoint env var is set (see telemetry/sdk-init.ts), so standalone startup
|
|
53
|
+
// is byte-for-byte unaffected.
|
|
54
|
+
initTelemetry(opts.cliEntryUrl);
|
|
55
|
+
registerLanguageAdapters(opts.langRegistry);
|
|
56
|
+
// Launch: bundled + installed tools both flow through the shared
|
|
57
|
+
// `admitTool` gate (register-tools.ts) and contribute a `ToolProvenance`
|
|
58
|
+
// record into this collector. It's a plain array threaded by value — no
|
|
59
|
+
// module singleton — handed back to the composition root so Phase 4's
|
|
60
|
+
// `plugin list` can surface source / identity / manifestHash.
|
|
61
|
+
const provenance = [];
|
|
62
|
+
// §5.3 (launch): collect the admitted tools' manifests alongside provenance
|
|
63
|
+
// so the composition root can seed the per-run capability registry with each
|
|
64
|
+
// manifest's declared domains.
|
|
65
|
+
const manifests = [];
|
|
66
|
+
// Launch: bundled tools load through the same dynamic-import path as installed
|
|
67
|
+
// tools, so registration is async — awaited before discovery so the bundled
|
|
68
|
+
// manifests are loaded before we derive the built-in skip-set from them.
|
|
69
|
+
// A bundled tool listed in OPENSIP_CLI_SKIP_BUNDLED is NOT loaded as bundled,
|
|
70
|
+
// so an installed/project-local copy of the same id can take over — the
|
|
71
|
+
// install-source-independence escape hatch (the bundled tool is one provenance,
|
|
72
|
+
// not a privilege).
|
|
73
|
+
// `.get` returns the spec's `default: []` when unset, so the list is always an
|
|
74
|
+
// array (never undefined).
|
|
75
|
+
const skipBundled = new Set(hostEnv.get('OPENSIP_CLI_SKIP_BUNDLED'));
|
|
76
|
+
const bundledPackages = BUNDLED_TOOL_PACKAGES.filter((pkg) => !skipBundled.has(pkg.replace('@opensip-cli/', '')));
|
|
77
|
+
await registerFirstPartyTools(opts.toolRegistry, provenance, manifests, bundledPackages);
|
|
78
|
+
// The bundled-tool ids discovery must skip on a name collision, derived from
|
|
79
|
+
// the manifests just loaded (not from an imported tool runtime — the host
|
|
80
|
+
// holds none in the launch contract).
|
|
81
|
+
const builtInIds = new Set(manifests.map((m) => m.id));
|
|
82
|
+
await discoverAndRegisterToolPackages(opts.toolRegistry, { sources: buildToolDiscoverySources(opts.cwd, opts.projectDir) }, builtInIds, provenance, manifests);
|
|
83
|
+
// Authored Tool sidecars (ADR-0027 realization): global trusted-by-default +
|
|
84
|
+
// project deny-by-default. Resolve the two authored roots — the global root
|
|
85
|
+
// is always present; the project root is best-effort (an unresolvable
|
|
86
|
+
// context contributes no project authored leg, mirroring
|
|
87
|
+
// buildToolDiscoverySources). `builtInIds` stays the BUNDLED set (matching
|
|
88
|
+
// the installed leg's contract); the registry's first-writer-wins dedupes an
|
|
89
|
+
// authored-vs-installed same-id collision with a structured warning.
|
|
90
|
+
const globalAuthoredDir = resolveUserPaths().authoredToolsDir;
|
|
91
|
+
let projectAuthoredDir;
|
|
92
|
+
try {
|
|
93
|
+
const project = resolveProjectContext({ cwd: opts.cwd, cwdExplicit: false });
|
|
94
|
+
if (project.scope === 'project') {
|
|
95
|
+
projectAuthoredDir = resolveProjectPaths(project.projectRoot).authoredToolsDir;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// @swallow-ok no resolvable project context → no project authored leg
|
|
100
|
+
// (best-effort, same contract as buildToolDiscoverySources).
|
|
101
|
+
}
|
|
102
|
+
await discoverAndRegisterAuthoredTools(opts.toolRegistry, { projectAuthoredDir, globalAuthoredDir, env: process.env }, builtInIds, provenance, manifests);
|
|
103
|
+
// Graph adapters (and every other tool's capability domains) are no longer
|
|
104
|
+
// discovered here. The pre-action hook drives the generic capability loader
|
|
105
|
+
// per command for the invoked tool's declared domains (§5.3/§4.5) — no
|
|
106
|
+
// host-coupled, eager, per-tool discovery at bootstrap.
|
|
107
|
+
return { provenance, manifests };
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,wOAAwO;AACxO;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GAKjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,+BAA+B;AAC/B,OAAO,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAC1F,4EAA4E;AAC5E,iEAAiE;AACjE,gDAAgD;AAChD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAKlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAA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
*
|
|
5
|
+
* Two pieces:
|
|
6
|
+
* 1. {@link createLiveViewRegistry} — the pure key→renderer registry backing
|
|
7
|
+
* `cli.registerLiveView`. First-writer-wins on duplicate keys; an
|
|
8
|
+
* unregistered key throws {@link UnknownLiveViewError} rather than masking a
|
|
9
|
+
* mistyped key with a static render. The host builds ONE registry per
|
|
10
|
+
* invocation (in `main()`) and hands it to the context assembler.
|
|
11
|
+
* 2. {@link createLivePlane} — binds that registry to the run plane so the
|
|
12
|
+
* `cli.renderLive` seam owns the live run lifecycle (Phase 2): it times the
|
|
13
|
+
* TTY occupancy and persists the renderer's returned `session` contribution
|
|
14
|
+
* after `await render()`. The renderer no longer writes the session itself.
|
|
15
|
+
*
|
|
16
|
+
* The host ALWAYS supplies the {@link LiveViewContext} (carrying the run seam +
|
|
17
|
+
* timer) as the renderer's second argument, so tools that call `renderLive`
|
|
18
|
+
* directly (fit/sim/graph `runLiveMode`) get it without threading it themselves;
|
|
19
|
+
* a renderer that declares only one parameter simply ignores the extra arg.
|
|
20
|
+
*/
|
|
21
|
+
import { type LiveViewContext, type LiveViewRenderer, type Logger, type ToolRunCompletion, type ToolRunSessions } from '@opensip-cli/core';
|
|
22
|
+
import type { RunPlaneFactory } from './run-plane.js';
|
|
23
|
+
export interface LiveViewRegistry {
|
|
24
|
+
readonly register: (key: string, renderer: LiveViewRenderer) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Render the live view. The optional third parameter is the LiveViewContext
|
|
27
|
+
* (carrying runSession) to forward as the *second* argument to the renderer
|
|
28
|
+
* function itself. This lets the host dispatch site (mount) supply the
|
|
29
|
+
* shared run timer without changing the public ToolCliContext.renderLive
|
|
30
|
+
* (tools still call renderLive(key, args)).
|
|
31
|
+
*/
|
|
32
|
+
readonly render: (key: string, args: unknown, liveContext?: LiveViewContext) => Promise<ToolRunCompletion | void>;
|
|
33
|
+
readonly has: (key: string) => boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function createLiveViewRegistry(log?: Logger): LiveViewRegistry;
|
|
36
|
+
/** Stable dependencies the live plane binds together. */
|
|
37
|
+
export interface LivePlaneDeps {
|
|
38
|
+
/** The per-invocation registry built in `main()` and passed to the assembler. */
|
|
39
|
+
readonly liveViews: LiveViewRegistry;
|
|
40
|
+
/** The run plane — `renderLive` runs the render through its `completeLiveRender`. */
|
|
41
|
+
readonly runPlane: RunPlaneFactory;
|
|
42
|
+
/** The host run seam, used to build the default {@link LiveViewContext}. */
|
|
43
|
+
readonly runSession: ToolRunSessions;
|
|
44
|
+
}
|
|
45
|
+
/** The live plane's public surface (the two `ToolCliContext` live-view seams). */
|
|
46
|
+
export interface LivePlane {
|
|
47
|
+
readonly register: LiveViewRegistry['register'];
|
|
48
|
+
readonly renderLive: (key: string, args: unknown, liveContext?: LiveViewContext) => Promise<ToolRunCompletion | void>;
|
|
49
|
+
}
|
|
50
|
+
export declare function createLivePlane(deps: LivePlaneDeps): LivePlane;
|
|
51
|
+
//# sourceMappingURL=live-plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-plane.d.ts","sourceRoot":"","sources":["../../src/bootstrap/live-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrE;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,CACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,eAAe,KAC1B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACxC;AAED,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAsB,GAAG,gBAAgB,CAmCpF;AAED,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;CACtC;AAED,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,UAAU,EAAE,CACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,eAAe,KAC1B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CACxC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAgB9D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* live-plane — the host's interactive live-view plane
|
|
3
|
+
* (host-owned-run-timing Phase 6 §6.1).
|
|
4
|
+
*
|
|
5
|
+
* Two pieces:
|
|
6
|
+
* 1. {@link createLiveViewRegistry} — the pure key→renderer registry backing
|
|
7
|
+
* `cli.registerLiveView`. First-writer-wins on duplicate keys; an
|
|
8
|
+
* unregistered key throws {@link UnknownLiveViewError} rather than masking a
|
|
9
|
+
* mistyped key with a static render. The host builds ONE registry per
|
|
10
|
+
* invocation (in `main()`) and hands it to the context assembler.
|
|
11
|
+
* 2. {@link createLivePlane} — binds that registry to the run plane so the
|
|
12
|
+
* `cli.renderLive` seam owns the live run lifecycle (Phase 2): it times the
|
|
13
|
+
* TTY occupancy and persists the renderer's returned `session` contribution
|
|
14
|
+
* after `await render()`. The renderer no longer writes the session itself.
|
|
15
|
+
*
|
|
16
|
+
* The host ALWAYS supplies the {@link LiveViewContext} (carrying the run seam +
|
|
17
|
+
* timer) as the renderer's second argument, so tools that call `renderLive`
|
|
18
|
+
* directly (fit/sim/graph `runLiveMode`) get it without threading it themselves;
|
|
19
|
+
* a renderer that declares only one parameter simply ignores the extra arg.
|
|
20
|
+
*/
|
|
21
|
+
import { UnknownLiveViewError, logger as defaultLogger, } from '@opensip-cli/core';
|
|
22
|
+
export function createLiveViewRegistry(log = defaultLogger) {
|
|
23
|
+
const renderers = new Map();
|
|
24
|
+
return {
|
|
25
|
+
register(key, renderer) {
|
|
26
|
+
if (renderers.has(key)) {
|
|
27
|
+
log.warn({
|
|
28
|
+
evt: 'cli.live_view.duplicate',
|
|
29
|
+
module: 'cli:bootstrap',
|
|
30
|
+
key,
|
|
31
|
+
msg: `Duplicate live-view registration for key '${key}' — first registration wins.`,
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
renderers.set(key, renderer);
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* @throws {UnknownLiveViewError} When `key` has no registered live-view renderer.
|
|
39
|
+
*/
|
|
40
|
+
async render(key, args, liveContext) {
|
|
41
|
+
const renderer = renderers.get(key);
|
|
42
|
+
if (!renderer) {
|
|
43
|
+
// async so the throw surfaces as a rejected promise (the contract
|
|
44
|
+
// callers `await` / assert `.rejects` against).
|
|
45
|
+
throw new UnknownLiveViewError(key);
|
|
46
|
+
}
|
|
47
|
+
// Always pass the host-supplied LiveViewContext (host-owned-run-timing
|
|
48
|
+
// Phase 2): live tool commands receive it; JS safely ignores the extra arg
|
|
49
|
+
// for any renderer that declares only one parameter. Return the renderer's
|
|
50
|
+
// ToolRunCompletion so the host can complete the lifecycle + persist.
|
|
51
|
+
return renderer(args, liveContext);
|
|
52
|
+
},
|
|
53
|
+
has(key) {
|
|
54
|
+
return renderers.has(key);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function createLivePlane(deps) {
|
|
59
|
+
return {
|
|
60
|
+
register: deps.liveViews.register,
|
|
61
|
+
// Host owns the live run lifecycle (host-owned-run-timing Phase 2): time
|
|
62
|
+
// the TTY occupancy, then complete the lifecycle + persist the renderer's
|
|
63
|
+
// returned `session` contribution. The host always supplies the
|
|
64
|
+
// LiveViewContext (carrying the run seam + timer) so tools that call
|
|
65
|
+
// renderLive directly (fit/sim/graph runLiveMode) get it without passing
|
|
66
|
+
// it themselves. The renderer no longer writes the session itself.
|
|
67
|
+
renderLive: (key, args, liveContext) => deps.runPlane
|
|
68
|
+
.current()
|
|
69
|
+
.completeLiveRender(() => deps.liveViews.render(key, args, liveContext ?? { runSession: deps.runSession })),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=live-plane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-plane.js","sourceRoot":"","sources":["../../src/bootstrap/live-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,oBAAoB,EACpB,MAAM,IAAI,aAAa,GAMxB,MAAM,mBAAmB,CAAC;AAqB3B,MAAM,UAAU,sBAAsB,CAAC,MAAc,aAAa;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;IACtD,OAAO;QACL,QAAQ,CAAC,GAAG,EAAE,QAAQ;YACpB,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,GAAG,CAAC,IAAI,CAAC;oBACP,GAAG,EAAE,yBAAyB;oBAC9B,MAAM,EAAE,eAAe;oBACvB,GAAG;oBACH,GAAG,EAAE,6CAA6C,GAAG,8BAA8B;iBACpF,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC/B,CAAC;QACD;;WAEG;QACH,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW;YACjC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,kEAAkE;gBAClE,gDAAgD;gBAChD,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;YACD,uEAAuE;YACvE,2EAA2E;YAC3E,2EAA2E;YAC3E,sEAAsE;YACtE,OAAO,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACrC,CAAC;QACD,GAAG,CAAC,GAAG;YACL,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC;AAsBD,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ;QACjC,yEAAyE;QACzE,0EAA0E;QAC1E,gEAAgE;QAChE,qEAAqE;QACrE,yEAAyE;QACzE,mEAAmE;QACnE,UAAU,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CACrC,IAAI,CAAC,QAAQ;aACV,OAAO,EAAE;aACT,kBAAkB,CAAC,GAAG,EAAE,CACvB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CACjF;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* load-tool-capabilities — the composition-root seam that drives the generic
|
|
3
|
+
* capability loader (§5.3, §4.5) for the invoked tool's declared domains.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the host-coupled, eager `register-graph-adapters.ts` (which statically
|
|
6
|
+
* imported graph's discover functions + stashed adapters in a module global).
|
|
7
|
+
* Here the host stays tool-agnostic: for the tool that owns the running command,
|
|
8
|
+
* it reads each declared capability domain's discovery descriptor off the
|
|
9
|
+
* per-run capability registry, resolves that domain's preferences from the
|
|
10
|
+
* project config through the keys the descriptor declares, and calls the generic
|
|
11
|
+
* `loadCapabilityDomain` — which walks node_modules, imports each contributing
|
|
12
|
+
* package, and routes every contribution through the owner's registrar. No tool
|
|
13
|
+
* import; no module singleton; lazy per command (only the invoked tool's domains
|
|
14
|
+
* load, so `graph` does not load fit-packs).
|
|
15
|
+
*
|
|
16
|
+
* This module is one of the few places the CLI imports `@opensip-cli/config`
|
|
17
|
+
* (the preference resolver) — tools never do.
|
|
18
|
+
*/
|
|
19
|
+
import { type Tool } from '@opensip-cli/core';
|
|
20
|
+
/** Options for {@link loadOwningToolCapabilities}. */
|
|
21
|
+
export interface LoadOwningToolCapabilitiesOptions {
|
|
22
|
+
/** The tool that owns the invoked command (from `resolveOwningTool`); `undefined` for CLI-only commands. */
|
|
23
|
+
readonly owningTool: Tool | undefined;
|
|
24
|
+
/** Discovery anchor for consumer-owned packages (the project root). */
|
|
25
|
+
readonly projectDir: string;
|
|
26
|
+
/** The resolved project config path (for the `plugins` preference block), or `undefined`. */
|
|
27
|
+
readonly configPath: string | undefined;
|
|
28
|
+
/** Discovery anchor for built-in packs (those under a descriptor's `builtinScope`). */
|
|
29
|
+
readonly cliDir?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Discover + route every contribution for each capability domain the invoked
|
|
33
|
+
* tool declares, through the generic loader. Must run AFTER the scope is entered
|
|
34
|
+
* (the registrars register into the scope's registries) and the per-run
|
|
35
|
+
* capability registry is attached. A CLI-only command (no owning tool) loads
|
|
36
|
+
* nothing.
|
|
37
|
+
*
|
|
38
|
+
* Returns the number of domains driven (0 when the tool declares none / is
|
|
39
|
+
* CLI-only), for diagnostics.
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadOwningToolCapabilities(options: LoadOwningToolCapabilitiesOptions): Promise<number>;
|
|
42
|
+
//# sourceMappingURL=load-tool-capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-tool-capabilities.d.ts","sourceRoot":"","sources":["../../src/bootstrap/load-tool-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAIL,KAAK,IAAI,EACV,MAAM,mBAAmB,CAAC;AAqB3B,sDAAsD;AACtD,MAAM,WAAW,iCAAiC;IAChD,4GAA4G;IAC5G,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,CAAC;IACtC,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6FAA6F;IAC7F,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,uFAAuF;IACvF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* load-tool-capabilities — the composition-root seam that drives the generic
|
|
3
|
+
* capability loader (§5.3, §4.5) for the invoked tool's declared domains.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the host-coupled, eager `register-graph-adapters.ts` (which statically
|
|
6
|
+
* imported graph's discover functions + stashed adapters in a module global).
|
|
7
|
+
* Here the host stays tool-agnostic: for the tool that owns the running command,
|
|
8
|
+
* it reads each declared capability domain's discovery descriptor off the
|
|
9
|
+
* per-run capability registry, resolves that domain's preferences from the
|
|
10
|
+
* project config through the keys the descriptor declares, and calls the generic
|
|
11
|
+
* `loadCapabilityDomain` — which walks node_modules, imports each contributing
|
|
12
|
+
* package, and routes every contribution through the owner's registrar. No tool
|
|
13
|
+
* import; no module singleton; lazy per command (only the invoked tool's domains
|
|
14
|
+
* load, so `graph` does not load fit-packs).
|
|
15
|
+
*
|
|
16
|
+
* This module is one of the few places the CLI imports `@opensip-cli/config`
|
|
17
|
+
* (the preference resolver) — tools never do.
|
|
18
|
+
*/
|
|
19
|
+
import { dirname } from 'node:path';
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { resolveCapabilityPreferences } from '@opensip-cli/config';
|
|
22
|
+
import { currentCapabilityRegistry, loadCapabilityDomain, readYamlFile, } from '@opensip-cli/core';
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the directory the CLI was installed into. BUILT-IN capability packs
|
|
25
|
+
* (the bundled `@opensip-cli/*` check packs + graph adapters, declared as CLI
|
|
26
|
+
* dependencies) always resolve from here — a project never carries them, and a
|
|
27
|
+
* globally-installed CLI runs ITS OWN bundled packs. This file lives at
|
|
28
|
+
* `cli/dist/bootstrap/`, so the package root is three directories up.
|
|
29
|
+
*/
|
|
30
|
+
function cliInstallDir() {
|
|
31
|
+
return dirname(dirname(dirname(fileURLToPath(import.meta.url))));
|
|
32
|
+
}
|
|
33
|
+
/** Read the raw `plugins` block from a project config file (or `{}` when absent). */
|
|
34
|
+
function readPluginsBlock(configPath) {
|
|
35
|
+
if (configPath === undefined)
|
|
36
|
+
return {};
|
|
37
|
+
const doc = readYamlFile(configPath);
|
|
38
|
+
if (doc === null || typeof doc !== 'object')
|
|
39
|
+
return {};
|
|
40
|
+
return doc.plugins ?? {};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Discover + route every contribution for each capability domain the invoked
|
|
44
|
+
* tool declares, through the generic loader. Must run AFTER the scope is entered
|
|
45
|
+
* (the registrars register into the scope's registries) and the per-run
|
|
46
|
+
* capability registry is attached. A CLI-only command (no owning tool) loads
|
|
47
|
+
* nothing.
|
|
48
|
+
*
|
|
49
|
+
* Returns the number of domains driven (0 when the tool declares none / is
|
|
50
|
+
* CLI-only), for diagnostics.
|
|
51
|
+
*/
|
|
52
|
+
export async function loadOwningToolCapabilities(options) {
|
|
53
|
+
const { owningTool, projectDir, configPath } = options;
|
|
54
|
+
if (!owningTool)
|
|
55
|
+
return 0;
|
|
56
|
+
// Built-in packs (those under a descriptor's `builtinScope`, e.g. the bundled
|
|
57
|
+
// @opensip-cli/graph-* adapters) resolve from the CLI's own install tree.
|
|
58
|
+
const cliDir = options.cliDir ?? cliInstallDir();
|
|
59
|
+
// The per-run capability registry is read off the current scope (the loader's
|
|
60
|
+
// registrars register into this same scope's tool registries).
|
|
61
|
+
const registry = currentCapabilityRegistry();
|
|
62
|
+
const ownedDomains = registry
|
|
63
|
+
.listDomains()
|
|
64
|
+
.filter((d) => d.ownerToolId === owningTool.metadata.id);
|
|
65
|
+
const pluginsConfig = readPluginsBlock(configPath);
|
|
66
|
+
let driven = 0;
|
|
67
|
+
for (const domain of ownedDomains) {
|
|
68
|
+
if (domain.discovery === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
const preferences = resolveCapabilityPreferences(domain.discovery, pluginsConfig);
|
|
71
|
+
await loadCapabilityDomain({ registry, domainId: domain.id, projectDir, cliDir, preferences });
|
|
72
|
+
driven++;
|
|
73
|
+
}
|
|
74
|
+
return driven;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=load-tool-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-tool-capabilities.js","sourceRoot":"","sources":["../../src/bootstrap/load-tool-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,GAEb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC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,MAAM,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;QAC/F,MAAM,EAAE,CAAC;IACX,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* output-plane — the host's machine-output + exit-code plane
|
|
3
|
+
* (host-owned-run-timing Phase 6 §6.1).
|
|
4
|
+
*
|
|
5
|
+
* Owns:
|
|
6
|
+
* - the single `process.exitCode` write path (`setExitCode`) and the captured
|
|
7
|
+
* in-memory mirror (`getExitCode`), so the run's exit code has exactly one
|
|
8
|
+
* author;
|
|
9
|
+
* - the four `--json`-path emit seams (`emitJson`, `emitEnvelope`, `emitError`,
|
|
10
|
+
* `emitRaw`), each wrapping the tool's pure-domain payload in a
|
|
11
|
+
* `CommandOutcome` through the single {@link renderOutcome} serialization seam
|
|
12
|
+
* (launch §5.5) — except `emitRaw`, which deliberately writes the unwrapped
|
|
13
|
+
* payload via {@link renderRaw}.
|
|
14
|
+
*
|
|
15
|
+
* Extracted verbatim from `buildToolCliContext`: the behaviour (outcome
|
|
16
|
+
* builders, render-failure fallbacks, exit-code threading) is unchanged — this
|
|
17
|
+
* module just gives the concern its own home and a narrow, testable surface.
|
|
18
|
+
*/
|
|
19
|
+
import { type Logger, type ToolCliContext } from '@opensip-cli/core';
|
|
20
|
+
import type { CommandResult } from '@opensip-cli/contracts';
|
|
21
|
+
/** Stable dependencies the output plane captures. */
|
|
22
|
+
export interface OutputPlaneDeps {
|
|
23
|
+
/** The human renderer (Ink/text) the emit seams pass through on the non-JSON path. */
|
|
24
|
+
readonly render: (result: CommandResult) => Promise<void>;
|
|
25
|
+
readonly logger?: Logger;
|
|
26
|
+
}
|
|
27
|
+
/** The output plane's public surface. */
|
|
28
|
+
export interface OutputPlane {
|
|
29
|
+
/** The single `process.exitCode` write path (mirrors into the captured value). */
|
|
30
|
+
readonly setExitCode: (code: number) => void;
|
|
31
|
+
/** The captured exit code, or `undefined` if never set this run. */
|
|
32
|
+
readonly getExitCode: () => number | undefined;
|
|
33
|
+
/** The four `ToolCliContext` machine-output seams, ready to spread into the context. */
|
|
34
|
+
readonly emits: Pick<ToolCliContext, 'emitJson' | 'emitEnvelope' | 'emitError' | 'emitRaw'>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createOutputPlane(deps: OutputPlaneDeps): OutputPlane;
|
|
37
|
+
//# sourceMappingURL=output-plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-plane.d.ts","sourceRoot":"","sources":["../../src/bootstrap/output-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAA2B,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAS9F,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,wBAAwB,CAAC;AAK5E,qDAAqD;AACrD,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC/C,wFAAwF;IACxF,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC,CAAC;CAC7F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CA+FpE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* output-plane — the host's machine-output + exit-code plane
|
|
3
|
+
* (host-owned-run-timing Phase 6 §6.1).
|
|
4
|
+
*
|
|
5
|
+
* Owns:
|
|
6
|
+
* - the single `process.exitCode` write path (`setExitCode`) and the captured
|
|
7
|
+
* in-memory mirror (`getExitCode`), so the run's exit code has exactly one
|
|
8
|
+
* author;
|
|
9
|
+
* - the four `--json`-path emit seams (`emitJson`, `emitEnvelope`, `emitError`,
|
|
10
|
+
* `emitRaw`), each wrapping the tool's pure-domain payload in a
|
|
11
|
+
* `CommandOutcome` through the single {@link renderOutcome} serialization seam
|
|
12
|
+
* (launch §5.5) — except `emitRaw`, which deliberately writes the unwrapped
|
|
13
|
+
* payload via {@link renderRaw}.
|
|
14
|
+
*
|
|
15
|
+
* Extracted verbatim from `buildToolCliContext`: the behaviour (outcome
|
|
16
|
+
* builders, render-failure fallbacks, exit-code threading) is unchanged — this
|
|
17
|
+
* module just gives the concern its own home and a narrow, testable surface.
|
|
18
|
+
*/
|
|
19
|
+
import { logger as defaultLogger } from '@opensip-cli/core';
|
|
20
|
+
import { outcomeFromEnvelope, outcomeFromErrorMessage, outcomeFromResult, } from '../commands/assemble-outcome.js';
|
|
21
|
+
import { renderOutcome, renderRaw } from '../commands/render-outcome.js';
|
|
22
|
+
/** Structured-log `module` tag for the output plane. */
|
|
23
|
+
const MODULE_TAG = 'cli:output-plane';
|
|
24
|
+
export function createOutputPlane(deps) {
|
|
25
|
+
const log = deps.logger ?? defaultLogger;
|
|
26
|
+
let exitCode;
|
|
27
|
+
const setExitCode = (code) => {
|
|
28
|
+
exitCode = code;
|
|
29
|
+
process.exitCode = code;
|
|
30
|
+
};
|
|
31
|
+
const emits = {
|
|
32
|
+
// launch (§5.5): every machine output the host emits is wrapped in a
|
|
33
|
+
// `CommandOutcome` through the single `renderOutcome` seam — `emitJson`
|
|
34
|
+
// (general-purpose `.data`), `emitEnvelope` (run `.envelope`), and
|
|
35
|
+
// `emitError` (`status:'error'` `.errors`). The host STAMPS the outer
|
|
36
|
+
// currency; the tool only hands over its pure-domain payload. `--json` is
|
|
37
|
+
// implicit here: these seams are only ever called on the `--json` path, so
|
|
38
|
+
// they always serialize the outcome (the `render` arg is inert).
|
|
39
|
+
//
|
|
40
|
+
// Errors during renderOutcome are attached to a catch so they are not
|
|
41
|
+
// completely swallowed by the `void` (they surface in logs and as
|
|
42
|
+
// unhandled-rejection diagnostics instead of silent loss).
|
|
43
|
+
emitJson: (value) => {
|
|
44
|
+
renderOutcome(outcomeFromResult(value, exitCode ?? 0), {
|
|
45
|
+
jsonRequested: true,
|
|
46
|
+
render: deps.render,
|
|
47
|
+
}).catch((error) => {
|
|
48
|
+
// Primary machine output path failed — do not swallow silently.
|
|
49
|
+
// Only force a non-success exit if the primary run had not already
|
|
50
|
+
// decided on a failure code (preserve specific codes like REPORT_FAILED,
|
|
51
|
+
// RUNTIME_ERROR, etc.). Render failure of the outcome is secondary.
|
|
52
|
+
if ((exitCode ?? 0) === 0) {
|
|
53
|
+
setExitCode(1);
|
|
54
|
+
}
|
|
55
|
+
log.error({
|
|
56
|
+
evt: 'cli.emit_json.render_failed',
|
|
57
|
+
module: MODULE_TAG,
|
|
58
|
+
error: error instanceof Error ? error.message : String(error),
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
emitEnvelope: (envelope) => {
|
|
63
|
+
renderOutcome(outcomeFromEnvelope(envelope, exitCode ?? 0), {
|
|
64
|
+
jsonRequested: true,
|
|
65
|
+
render: deps.render,
|
|
66
|
+
}).catch((error) => {
|
|
67
|
+
if ((exitCode ?? 0) === 0) {
|
|
68
|
+
setExitCode(1);
|
|
69
|
+
}
|
|
70
|
+
log.error({
|
|
71
|
+
evt: 'cli.emit_envelope.render_failed',
|
|
72
|
+
module: MODULE_TAG,
|
|
73
|
+
error: error instanceof Error ? error.message : String(error),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
// Structured error machine-output (retires the bare `emitJson({ error })`
|
|
78
|
+
// shape the `one-outcome-shape` guardrail forbids). The handler hands a
|
|
79
|
+
// diagnosed failure (message + exit code, optional suggestion); the host
|
|
80
|
+
// wraps it as a `status:'error'` outcome. `exitCode` is also threaded to
|
|
81
|
+
// `setExitCode` so the process exit and the reported outcome agree.
|
|
82
|
+
emitError: (detail) => {
|
|
83
|
+
setExitCode(detail.exitCode);
|
|
84
|
+
renderOutcome(outcomeFromErrorMessage({
|
|
85
|
+
message: detail.message,
|
|
86
|
+
exitCode: detail.exitCode,
|
|
87
|
+
...(detail.suggestion === undefined ? {} : { suggestion: detail.suggestion }),
|
|
88
|
+
...(detail.code === undefined ? {} : { code: detail.code }),
|
|
89
|
+
}), { jsonRequested: true, render: deps.render }).catch((error) => {
|
|
90
|
+
// Even error emission failing is fatal for the json contract.
|
|
91
|
+
// Only force 1 if the error detail itself indicated success (edge).
|
|
92
|
+
if ((exitCode ?? 0) === 0) {
|
|
93
|
+
setExitCode(1);
|
|
94
|
+
}
|
|
95
|
+
log.error({
|
|
96
|
+
evt: 'cli.emit_error.render_failed',
|
|
97
|
+
module: MODULE_TAG,
|
|
98
|
+
error: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
// RAW_STREAM seam (§5.5): emit the bare, unwrapped value for a command that
|
|
103
|
+
// declares `output:'raw-stream'` (e.g. `sessions show --raw`). The single
|
|
104
|
+
// sanctioned write lives in `renderRaw` (the one stdout-JSON seam), so the
|
|
105
|
+
// command body never hand-rolls `process.stdout.write(JSON.stringify(...))`.
|
|
106
|
+
emitRaw: (value) => renderRaw(value),
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
setExitCode,
|
|
110
|
+
getExitCode: () => exitCode,
|
|
111
|
+
emits,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=output-plane.js.map
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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC7E,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;aAC5D,CAAC,EACF,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAC7C,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAChB,8DAA8D;gBAC9D,oEAAoE;gBACpE,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC1B,WAAW,CAAC,CAAC,CAAC,CAAC;gBACjB,CAAC;gBACD,GAAG,CAAC,KAAK,CAAC;oBACR,GAAG,EAAE,8BAA8B;oBACnC,MAAM,EAAE,UAAU;oBAClB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QACD,4EAA4E;QAC5E,0EAA0E;QAC1E,2EAA2E;QAC3E,6EAA6E;QAC7E,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;KACrC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ;QAC3B,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* owning-tool-init — resolve the tool that owns the invoked subcommand and run
|
|
3
|
+
* its lazy, once-per-process `Tool.initialize()`.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `pre-action-hook.ts` so that hook stays the high-level
|
|
6
|
+
* per-invocation SEQUENCER; the owning-tool resolution + fail-fast init
|
|
7
|
+
* semantics live here as a cohesive unit (see also `tool-lifecycle.ts`).
|
|
8
|
+
*/
|
|
9
|
+
import { type Tool, type ToolRegistry } from '@opensip-cli/core';
|
|
10
|
+
/**
|
|
11
|
+
* Find the registered tool that owns the invoked subcommand, matching the
|
|
12
|
+
* descriptor's canonical name or any alias. Returns undefined for
|
|
13
|
+
* CLI-only commands (init/sessions/configure/plugin/...) — they belong to
|
|
14
|
+
* no tool, so no `initialize()` runs for them.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveOwningTool(tools: ToolRegistry, cmdName: string): Tool | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Lazy, memoized Tool.initialize() (P1a). Resolve the tool owning the
|
|
19
|
+
* invoked subcommand and run its initialize() exactly once per process,
|
|
20
|
+
* after the scope is entered and immediately before the action body. Tools
|
|
21
|
+
* not invoked this run pay nothing; `--help`/welcome run no initialize().
|
|
22
|
+
*
|
|
23
|
+
* Fail-fast: a throwing initialize() fails the run closed rather than letting a
|
|
24
|
+
* half-initialised tool run its command and silently appear to work. The
|
|
25
|
+
* id is recorded only on success, so a transient failure can retry in a
|
|
26
|
+
* long-lived host.
|
|
27
|
+
*
|
|
28
|
+
* @throws {BootstrapError} (exit 1) when the owning tool's initialize() throws —
|
|
29
|
+
* the top-level boundary renders it (human stderr / structured `--json`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function maybeInitializeOwningTool(tools: ToolRegistry, cmdName: string, runId: string): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=owning-tool-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owning-tool-init.d.ts","sourceRoot":"","sources":["../../src/bootstrap/owning-tool-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAU,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOzE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAMxF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|