opensip-cli 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap/admit-tool-package.d.ts +51 -11
- package/dist/bootstrap/admit-tool-package.d.ts.map +1 -1
- package/dist/bootstrap/admit-tool-package.js +46 -12
- package/dist/bootstrap/admit-tool-package.js.map +1 -1
- package/dist/bootstrap/baseline-seams.js +1 -1
- package/dist/bootstrap/baseline-seams.js.map +1 -1
- package/dist/bootstrap/bind-external-dispatch.d.ts +36 -0
- package/dist/bootstrap/bind-external-dispatch.d.ts.map +1 -0
- package/dist/bootstrap/bind-external-dispatch.js +81 -0
- package/dist/bootstrap/bind-external-dispatch.js.map +1 -0
- package/dist/bootstrap/build-command-registration-input.d.ts +13 -2
- package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -1
- package/dist/bootstrap/build-command-registration-input.js +29 -2
- package/dist/bootstrap/build-command-registration-input.js.map +1 -1
- package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
- package/dist/bootstrap/build-per-run-scope.js +19 -2
- package/dist/bootstrap/build-per-run-scope.js.map +1 -1
- package/dist/bootstrap/config-and-capabilities.d.ts +21 -6
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/config-and-capabilities.js +79 -23
- package/dist/bootstrap/config-and-capabilities.js.map +1 -1
- package/dist/bootstrap/dispatch-external-tool-command.d.ts +67 -0
- package/dist/bootstrap/dispatch-external-tool-command.d.ts.map +1 -0
- package/dist/bootstrap/dispatch-external-tool-command.js +79 -0
- package/dist/bootstrap/dispatch-external-tool-command.js.map +1 -0
- package/dist/bootstrap/dispatch-external-tool-hook.d.ts +47 -0
- package/dist/bootstrap/dispatch-external-tool-hook.d.ts.map +1 -0
- package/dist/bootstrap/dispatch-external-tool-hook.js +49 -0
- package/dist/bootstrap/dispatch-external-tool-hook.js.map +1 -0
- package/dist/bootstrap/dispatch-fork-core.d.ts +48 -0
- package/dist/bootstrap/dispatch-fork-core.d.ts.map +1 -0
- package/dist/bootstrap/dispatch-fork-core.js +214 -0
- package/dist/bootstrap/dispatch-fork-core.js.map +1 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.d.ts +27 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.d.ts.map +1 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.js +175 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.js.map +1 -0
- package/dist/bootstrap/dispatch-replay-result.d.ts +51 -0
- package/dist/bootstrap/dispatch-replay-result.d.ts.map +1 -0
- package/dist/bootstrap/dispatch-replay-result.js +76 -0
- package/dist/bootstrap/dispatch-replay-result.js.map +1 -0
- package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.js +3 -1
- package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -1
- package/dist/bootstrap/owning-tool-init.d.ts +8 -2
- package/dist/bootstrap/owning-tool-init.d.ts.map +1 -1
- package/dist/bootstrap/owning-tool-init.js +11 -1
- package/dist/bootstrap/owning-tool-init.js.map +1 -1
- package/dist/bootstrap/register-authored-tools.d.ts +49 -0
- package/dist/bootstrap/register-authored-tools.d.ts.map +1 -0
- package/dist/bootstrap/register-authored-tools.js +132 -0
- package/dist/bootstrap/register-authored-tools.js.map +1 -0
- package/dist/bootstrap/register-tools-discovery.d.ts +0 -32
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.js +36 -100
- package/dist/bootstrap/register-tools-discovery.js.map +1 -1
- package/dist/bootstrap/register-tools-mount.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-mount.js +20 -44
- package/dist/bootstrap/register-tools-mount.js.map +1 -1
- package/dist/bootstrap/register-tools.d.ts +2 -1
- package/dist/bootstrap/register-tools.d.ts.map +1 -1
- package/dist/bootstrap/register-tools.js +2 -1
- package/dist/bootstrap/register-tools.js.map +1 -1
- package/dist/bootstrap/run-plane.d.ts +11 -0
- package/dist/bootstrap/run-plane.d.ts.map +1 -1
- package/dist/bootstrap/run-plane.js.map +1 -1
- package/dist/bootstrap/synthesize-external-tool.d.ts +45 -0
- package/dist/bootstrap/synthesize-external-tool.d.ts.map +1 -0
- package/dist/bootstrap/synthesize-external-tool.js +112 -0
- package/dist/bootstrap/synthesize-external-tool.js.map +1 -0
- package/dist/bootstrap/tool-command-dispatch-types.d.ts +280 -0
- package/dist/bootstrap/tool-command-dispatch-types.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-dispatch-types.js +34 -0
- package/dist/bootstrap/tool-command-dispatch-types.js.map +1 -0
- package/dist/bootstrap/tool-command-worker-config-pass.d.ts +24 -0
- package/dist/bootstrap/tool-command-worker-config-pass.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-worker-config-pass.js +52 -0
- package/dist/bootstrap/tool-command-worker-config-pass.js.map +1 -0
- package/dist/bootstrap/tool-command-worker-context.d.ts +55 -0
- package/dist/bootstrap/tool-command-worker-context.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-worker-context.js +163 -0
- package/dist/bootstrap/tool-command-worker-context.js.map +1 -0
- package/dist/bootstrap/tool-command-worker-entry.d.ts +66 -0
- package/dist/bootstrap/tool-command-worker-entry.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-worker-entry.js +298 -0
- package/dist/bootstrap/tool-command-worker-entry.js.map +1 -0
- package/dist/bootstrap/tool-command-worker-rpc.d.ts +53 -0
- package/dist/bootstrap/tool-command-worker-rpc.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-worker-rpc.js +78 -0
- package/dist/bootstrap/tool-command-worker-rpc.js.map +1 -0
- package/dist/bootstrap/tool-provenance.d.ts +85 -0
- package/dist/bootstrap/tool-provenance.d.ts.map +1 -0
- package/dist/bootstrap/tool-provenance.js +101 -0
- package/dist/bootstrap/tool-provenance.js.map +1 -0
- package/dist/cli-context.d.ts +17 -0
- package/dist/cli-context.d.ts.map +1 -1
- package/dist/cli-context.js +62 -1
- package/dist/cli-context.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +3 -0
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/host-command-specs.d.ts +13 -15
- package/dist/commands/host-command-specs.d.ts.map +1 -1
- package/dist/commands/host-command-specs.js +27 -27
- package/dist/commands/host-command-specs.js.map +1 -1
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
- package/dist/commands/host-subcommand-groups.js +63 -5
- package/dist/commands/host-subcommand-groups.js.map +1 -1
- package/dist/commands/internal-command-visibility.d.ts +13 -4
- package/dist/commands/internal-command-visibility.d.ts.map +1 -1
- package/dist/commands/internal-command-visibility.js +14 -5
- package/dist/commands/internal-command-visibility.js.map +1 -1
- package/dist/commands/mount-command-spec.d.ts.map +1 -1
- package/dist/commands/mount-command-spec.js +31 -0
- package/dist/commands/mount-command-spec.js.map +1 -1
- package/dist/commands/session-show.d.ts.map +1 -1
- package/dist/commands/session-show.js +4 -1
- package/dist/commands/session-show.js.map +1 -1
- package/dist/commands/tools/data-purge.js +2 -2
- package/dist/commands/tools/data-purge.js.map +1 -1
- package/dist/commands/tools/validate.js +1 -1
- package/dist/env/host-env-specs.d.ts.map +1 -1
- package/dist/env/host-env-specs.js +6 -0
- package/dist/env/host-env-specs.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/report-compose.d.ts.map +1 -1
- package/dist/report-compose.js +85 -19
- package/dist/report-compose.js.map +1 -1
- package/dist/session-replay-registry.d.ts +33 -6
- package/dist/session-replay-registry.d.ts.map +1 -1
- package/dist/session-replay-registry.js +43 -6
- package/dist/session-replay-registry.js.map +1 -1
- package/dist/telemetry/profiling.d.ts +30 -0
- package/dist/telemetry/profiling.d.ts.map +1 -1
- package/dist/telemetry/profiling.js +16 -1
- package/dist/telemetry/profiling.js.map +1 -1
- package/package.json +32 -32
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* per-invocation SEQUENCER; the owning-tool resolution + fail-fast init
|
|
7
7
|
* semantics live here as a cohesive unit (see also `tool-lifecycle.ts`).
|
|
8
8
|
*/
|
|
9
|
-
import { type Tool, type ToolRegistry } from '@opensip-cli/core';
|
|
9
|
+
import { type Tool, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
|
|
10
10
|
/**
|
|
11
11
|
* Find the registered tool that owns the invoked subcommand, matching the
|
|
12
12
|
* descriptor's canonical name or any alias. Returns undefined for
|
|
@@ -25,8 +25,14 @@ export declare function resolveOwningTool(tools: ToolRegistry, cmdName: string):
|
|
|
25
25
|
* id is recorded only on success, so a transient failure can retry in a
|
|
26
26
|
* long-lived host.
|
|
27
27
|
*
|
|
28
|
+
* ADR-0054 M4-F: the host does NOT run an EXTERNAL owning tool's `initialize()`
|
|
29
|
+
* (executing untrusted runtime in the kernel is the load-time hole the ADR
|
|
30
|
+
* rejects). An external command dispatches to the worker (`maybeDispatchExternal`),
|
|
31
|
+
* and the worker entry runs the dispatched tool's `initialize()` there (the
|
|
32
|
+
* isolation boundary). Bundled owning tools initialize in-host exactly as before.
|
|
33
|
+
*
|
|
28
34
|
* @throws {BootstrapError} (exit 1) when the owning tool's initialize() throws —
|
|
29
35
|
* the top-level boundary renders it (human stderr / structured `--json`).
|
|
30
36
|
*/
|
|
31
|
-
export declare function maybeInitializeOwningTool(tools: ToolRegistry, cmdName: string, runId: string): Promise<void>;
|
|
37
|
+
export declare function maybeInitializeOwningTool(tools: ToolRegistry, cmdName: string, runId: string, provenance?: readonly ToolProvenance[]): Promise<void>;
|
|
32
38
|
//# sourceMappingURL=owning-tool-init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owning-tool-init.d.ts","sourceRoot":"","sources":["../../src/bootstrap/owning-tool-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"owning-tool-init.d.ts","sourceRoot":"","sources":["../../src/bootstrap/owning-tool-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAQ3B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAQxF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,SAAS,cAAc,EAAO,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { logger, resolveToolCommands, resolveToolHooks, } from '@opensip-cli/core';
|
|
10
10
|
import { BootstrapError } from './bootstrap-error.js';
|
|
11
11
|
import { initializedToolIds } from './process-idempotency.js';
|
|
12
|
+
import { shouldRunHookInHost } from './tool-provenance.js';
|
|
12
13
|
const MODULE_TAG = 'cli:bootstrap';
|
|
13
14
|
/**
|
|
14
15
|
* Find the registered tool that owns the invoked subcommand, matching the
|
|
@@ -32,13 +33,22 @@ export function resolveOwningTool(tools, cmdName) {
|
|
|
32
33
|
* id is recorded only on success, so a transient failure can retry in a
|
|
33
34
|
* long-lived host.
|
|
34
35
|
*
|
|
36
|
+
* ADR-0054 M4-F: the host does NOT run an EXTERNAL owning tool's `initialize()`
|
|
37
|
+
* (executing untrusted runtime in the kernel is the load-time hole the ADR
|
|
38
|
+
* rejects). An external command dispatches to the worker (`maybeDispatchExternal`),
|
|
39
|
+
* and the worker entry runs the dispatched tool's `initialize()` there (the
|
|
40
|
+
* isolation boundary). Bundled owning tools initialize in-host exactly as before.
|
|
41
|
+
*
|
|
35
42
|
* @throws {BootstrapError} (exit 1) when the owning tool's initialize() throws —
|
|
36
43
|
* the top-level boundary renders it (human stderr / structured `--json`).
|
|
37
44
|
*/
|
|
38
|
-
export async function maybeInitializeOwningTool(tools, cmdName, runId) {
|
|
45
|
+
export async function maybeInitializeOwningTool(tools, cmdName, runId, provenance = []) {
|
|
39
46
|
const owningTool = resolveOwningTool(tools, cmdName);
|
|
40
47
|
if (!owningTool)
|
|
41
48
|
return;
|
|
49
|
+
// M4-F: skip an external owning tool host-side — its initialize runs worker-side.
|
|
50
|
+
if (!shouldRunHookInHost(owningTool, provenance))
|
|
51
|
+
return;
|
|
42
52
|
const hooks = resolveToolHooks(owningTool);
|
|
43
53
|
if (!hooks.initialize)
|
|
44
54
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owning-tool-init.js","sourceRoot":"","sources":["../../src/bootstrap/owning-tool-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"owning-tool-init.js","sourceRoot":"","sources":["../../src/bootstrap/owning-tool-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,gBAAgB,GAIjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB,EAAE,OAAe;IACpE,OAAO,KAAK;SACT,IAAI,EAAE;SACN,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CACb,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,CAC5B,CAAC,CAAC,EAAE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QACH,wEAAwE;QACxE,wEAAwE;QACxE,MAAM,IAAI,cAAc,CAAC;YACvB,OAAO,EAAE,SAAS,WAAW,2BAA2B,GAAG,EAAE;YAC7D,YAAY,EAAE,WAAW,WAAW,2BAA2B,GAAG,EAAE;YACpE,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,CAAC;SACZ,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* register-authored-tools — admission + discovery for AUTHORED Tool sidecars
|
|
3
|
+
* (project-local + user-global), extracted from register-tools-discovery.ts so
|
|
4
|
+
* the installed-package discovery path stays a focused module under the
|
|
5
|
+
* file-length soft limit.
|
|
6
|
+
*
|
|
7
|
+
* Authored tools are authored CONTENT (a JSON sidecar, not an installed npm
|
|
8
|
+
* package): project-local is deny-by-default (allowlisted via
|
|
9
|
+
* `OPENSIP_CLI_ALLOW_PROJECT_TOOLS`), user-global is trusted-by-default. Both are
|
|
10
|
+
* EXTERNAL provenance, so ADR-0054 M4-G applies: in the HOST the registration
|
|
11
|
+
* registers a manifest-derived synthetic `Tool` (no runtime import); the dispatch
|
|
12
|
+
* WORKER (`OPENSIP_CLI_IN_TOOL_WORKER=1`) imports the real runtime.
|
|
13
|
+
*/
|
|
14
|
+
import { type ToolPluginManifest, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
|
|
15
|
+
import type { ToolAdmission } from './tool-admission-types.js';
|
|
16
|
+
export type AuthoredAdmission = ToolAdmission;
|
|
17
|
+
/**
|
|
18
|
+
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
19
|
+
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
20
|
+
* tool fails closed before any authored code can run.
|
|
21
|
+
*
|
|
22
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
23
|
+
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
24
|
+
*/
|
|
25
|
+
export declare function admitProjectLocalTool(args: {
|
|
26
|
+
readonly dir: string;
|
|
27
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
28
|
+
}): AuthoredAdmission;
|
|
29
|
+
/**
|
|
30
|
+
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
31
|
+
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
32
|
+
* incompatible manifest.
|
|
33
|
+
*/
|
|
34
|
+
export declare function admitUserGlobalTool(args: {
|
|
35
|
+
readonly dir: string;
|
|
36
|
+
}): AuthoredAdmission;
|
|
37
|
+
/**
|
|
38
|
+
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
39
|
+
* roots. ADR-0054 M4-G: authored tools are always EXTERNAL provenance, so the
|
|
40
|
+
* HOST registers a manifest-derived synthetic Tool (no runtime import); the
|
|
41
|
+
* dispatch WORKER (`OPENSIP_CLI_IN_TOOL_WORKER=1`) imports the real runtime via
|
|
42
|
+
* the shared `importToolRuntime` seam.
|
|
43
|
+
*/
|
|
44
|
+
export declare function discoverAndRegisterAuthoredTools(registry: ToolRegistry, opts: {
|
|
45
|
+
readonly projectAuthoredDir?: string;
|
|
46
|
+
readonly globalAuthoredDir: string;
|
|
47
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
48
|
+
}, builtInIds: ReadonlySet<string>, provenance?: ToolProvenance[], manifests?: ToolPluginManifest[]): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=register-authored-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-authored-tools.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-authored-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAsC9C;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC,GAAG,iBAAiB,CAgBpB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAErF;AAED;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE;IACJ,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC,EACD,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,UAAU,GAAE,cAAc,EAAO,EACjC,SAAS,GAAE,kBAAkB,EAAO,GACnC,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* register-authored-tools — admission + discovery for AUTHORED Tool sidecars
|
|
3
|
+
* (project-local + user-global), extracted from register-tools-discovery.ts so
|
|
4
|
+
* the installed-package discovery path stays a focused module under the
|
|
5
|
+
* file-length soft limit.
|
|
6
|
+
*
|
|
7
|
+
* Authored tools are authored CONTENT (a JSON sidecar, not an installed npm
|
|
8
|
+
* package): project-local is deny-by-default (allowlisted via
|
|
9
|
+
* `OPENSIP_CLI_ALLOW_PROJECT_TOOLS`), user-global is trusted-by-default. Both are
|
|
10
|
+
* EXTERNAL provenance, so ADR-0054 M4-G applies: in the HOST the registration
|
|
11
|
+
* registers a manifest-derived synthetic `Tool` (no runtime import); the dispatch
|
|
12
|
+
* WORKER (`OPENSIP_CLI_IN_TOOL_WORKER=1`) imports the real runtime.
|
|
13
|
+
*/
|
|
14
|
+
import { admitTool, assertManifestMatchesTool, discoverAuthoredToolSidecars, loadToolManifest, PluginIncompatibleError, PROJECT_LOCAL_MANIFEST_FILE, } from '@opensip-cli/core';
|
|
15
|
+
import { importToolRuntime, workerRuntimeImportPolicyFor } from './admit-tool-package.js';
|
|
16
|
+
import { synthesizeExternalTool } from './synthesize-external-tool.js';
|
|
17
|
+
import { isHostRuntimeImportForbidden } from './tool-provenance.js';
|
|
18
|
+
import { isProjectLocalToolTrusted } from './tool-trust.js';
|
|
19
|
+
/**
|
|
20
|
+
* The shared admission tail for both authored sources. When `preloadedManifest`
|
|
21
|
+
* is supplied we use that snapshot so the trust decision and compatibility gate
|
|
22
|
+
* see the identical declaration.
|
|
23
|
+
*
|
|
24
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
25
|
+
* malformed, or rejected by the compatibility gate.
|
|
26
|
+
*/
|
|
27
|
+
function admitAuthoredTool(source, dir, preloadedManifest) {
|
|
28
|
+
const rawManifest = preloadedManifest ?? loadToolManifest(source, dir);
|
|
29
|
+
if (rawManifest === undefined) {
|
|
30
|
+
throw new PluginIncompatibleError(`${source} tool at '${dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
31
|
+
}
|
|
32
|
+
const result = admitTool({
|
|
33
|
+
manifest: rawManifest,
|
|
34
|
+
source,
|
|
35
|
+
dir,
|
|
36
|
+
explicitlyRequested: true,
|
|
37
|
+
});
|
|
38
|
+
if (result.decision !== 'admit') {
|
|
39
|
+
throw new PluginIncompatibleError(`${source} tool '${rawManifest.id}' is incompatible: ${result.diagnostic ?? 'compatibility gate rejected it'}`, { diagnostic: result.diagnostic });
|
|
40
|
+
}
|
|
41
|
+
return { provenance: result.provenance, manifest: result.manifest };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
45
|
+
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
46
|
+
* tool fails closed before any authored code can run.
|
|
47
|
+
*
|
|
48
|
+
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
49
|
+
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
50
|
+
*/
|
|
51
|
+
export function admitProjectLocalTool(args) {
|
|
52
|
+
const manifest = loadToolManifest('project-local', args.dir);
|
|
53
|
+
if (manifest === undefined) {
|
|
54
|
+
throw new PluginIncompatibleError(`project-local tool at '${args.dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
55
|
+
}
|
|
56
|
+
if (!isProjectLocalToolTrusted(manifest.id, args.env)) {
|
|
57
|
+
throw new PluginIncompatibleError(`project-local tool '${manifest.id}' is not trusted to load (deny-by-default). ` +
|
|
58
|
+
`Allowlist it via OPENSIP_CLI_ALLOW_PROJECT_TOOLS='${manifest.id}' to admit it.`, { diagnostic: 'project-local tool not allowlisted (deny-by-default)' });
|
|
59
|
+
}
|
|
60
|
+
return admitAuthoredTool('project-local', args.dir, manifest);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
64
|
+
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
65
|
+
* incompatible manifest.
|
|
66
|
+
*/
|
|
67
|
+
export function admitUserGlobalTool(args) {
|
|
68
|
+
return admitAuthoredTool('user-global', args.dir);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
72
|
+
* roots. ADR-0054 M4-G: authored tools are always EXTERNAL provenance, so the
|
|
73
|
+
* HOST registers a manifest-derived synthetic Tool (no runtime import); the
|
|
74
|
+
* dispatch WORKER (`OPENSIP_CLI_IN_TOOL_WORKER=1`) imports the real runtime via
|
|
75
|
+
* the shared `importToolRuntime` seam.
|
|
76
|
+
*/
|
|
77
|
+
export async function discoverAndRegisterAuthoredTools(registry, opts, builtInIds, provenance = [], manifests = []) {
|
|
78
|
+
const env = opts.env ?? process.env;
|
|
79
|
+
for (const candidate of discoverAuthoredToolSidecars(opts.globalAuthoredDir)) {
|
|
80
|
+
await admitAndRegisterAuthored({
|
|
81
|
+
registry,
|
|
82
|
+
admission: admitUserGlobalTool({ dir: candidate.dir }),
|
|
83
|
+
dir: candidate.dir,
|
|
84
|
+
builtInIds,
|
|
85
|
+
provenance,
|
|
86
|
+
manifests,
|
|
87
|
+
env,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (opts.projectAuthoredDir !== undefined) {
|
|
91
|
+
for (const candidate of discoverAuthoredToolSidecars(opts.projectAuthoredDir)) {
|
|
92
|
+
await admitAndRegisterAuthored({
|
|
93
|
+
registry,
|
|
94
|
+
admission: admitProjectLocalTool({ dir: candidate.dir, env: opts.env }),
|
|
95
|
+
dir: candidate.dir,
|
|
96
|
+
builtInIds,
|
|
97
|
+
provenance,
|
|
98
|
+
manifests,
|
|
99
|
+
env,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** @throws {PluginIncompatibleError} When the authored tool runtime fails to load. */
|
|
105
|
+
async function admitAndRegisterAuthored(args) {
|
|
106
|
+
const { registry, admission, dir, builtInIds, provenance, manifests, env } = args;
|
|
107
|
+
const { provenance: prov, manifest } = admission;
|
|
108
|
+
if (builtInIds.has(prov.id))
|
|
109
|
+
return;
|
|
110
|
+
// ADR-0054 M4-G (capstone): authored tools are EXTERNAL. In the HOST, register
|
|
111
|
+
// a manifest-derived synthetic Tool — never import the untrusted runtime. The
|
|
112
|
+
// dispatch WORKER imports the real runtime (the isolation boundary). The trust
|
|
113
|
+
// gate already ran in `admitProjectLocalTool` (deny-by-default), so a
|
|
114
|
+
// non-allowlisted tool never reaches here.
|
|
115
|
+
if (isHostRuntimeImportForbidden(env)) {
|
|
116
|
+
const tool = synthesizeExternalTool(manifest);
|
|
117
|
+
registry.register(tool);
|
|
118
|
+
provenance.push(prov);
|
|
119
|
+
manifests.push(manifest);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const load = await importToolRuntime(dir, workerRuntimeImportPolicyFor(prov.source));
|
|
123
|
+
if (!load.ok) {
|
|
124
|
+
const detailSuffix = load.detail ? `: ${load.detail}` : '';
|
|
125
|
+
throw new PluginIncompatibleError(`${prov.source} tool '${prov.id}' failed to load via the plugin path (${load.reason}${detailSuffix})`, { diagnostic: `authored tool runtime load failed: ${load.reason}` });
|
|
126
|
+
}
|
|
127
|
+
assertManifestMatchesTool(manifest, load.tool);
|
|
128
|
+
registry.register(load.tool);
|
|
129
|
+
provenance.push(prov);
|
|
130
|
+
manifests.push(manifest);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=register-authored-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-authored-tools.js","sourceRoot":"","sources":["../../src/bootstrap/register-authored-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,GAK5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAM5D;;;;;;;GAOG;AACH,SAAS,iBAAiB,CACxB,MAAkB,EAClB,GAAW,EACX,iBAAuD;IAEvD,MAAM,WAAW,GAAG,iBAAiB,IAAI,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvE,IAAI,WAAW,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I,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -6,28 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ToolPluginManifest, type ToolProvenance, type ToolRegistry, type ToolDiscoverySource } from '@opensip-cli/core';
|
|
8
8
|
import { type ToolRuntimeLoad } from './admit-tool-package.js';
|
|
9
|
-
import type { ToolAdmission } from './tool-admission-types.js';
|
|
10
|
-
export type AuthoredAdmission = ToolAdmission;
|
|
11
|
-
/**
|
|
12
|
-
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
13
|
-
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
14
|
-
* tool fails closed before any authored code can run.
|
|
15
|
-
*
|
|
16
|
-
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
17
|
-
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
18
|
-
*/
|
|
19
|
-
export declare function admitProjectLocalTool(args: {
|
|
20
|
-
readonly dir: string;
|
|
21
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
22
|
-
}): AuthoredAdmission;
|
|
23
|
-
/**
|
|
24
|
-
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
25
|
-
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
26
|
-
* incompatible manifest.
|
|
27
|
-
*/
|
|
28
|
-
export declare function admitUserGlobalTool(args: {
|
|
29
|
-
readonly dir: string;
|
|
30
|
-
}): AuthoredAdmission;
|
|
31
9
|
/**
|
|
32
10
|
* Emit the best-effort stderr line + structured warning for a discovered
|
|
33
11
|
* INSTALLED tool whose runtime failed to load. Each failure reason maps to its
|
|
@@ -65,14 +43,4 @@ export interface DiscoveryOptions {
|
|
|
65
43
|
*/
|
|
66
44
|
export declare function buildToolDiscoverySources(cwd: string, cliInstallDir: string): ToolDiscoverySource[];
|
|
67
45
|
export declare function discoverAndRegisterToolPackages(registry: ToolRegistry, opts: DiscoveryOptions, builtInIds: ReadonlySet<string>, provenance?: ToolProvenance[], manifests?: ToolPluginManifest[]): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
70
|
-
* roots, then dynamic-import each admitted runtime through the shared
|
|
71
|
-
* `importToolRuntime` seam.
|
|
72
|
-
*/
|
|
73
|
-
export declare function discoverAndRegisterAuthoredTools(registry: ToolRegistry, opts: {
|
|
74
|
-
readonly projectAuthoredDir?: string;
|
|
75
|
-
readonly globalAuthoredDir: string;
|
|
76
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
77
|
-
}, builtInIds: ReadonlySet<string>, provenance?: ToolProvenance[], manifests?: ToolPluginManifest[]): Promise<void>;
|
|
78
46
|
//# sourceMappingURL=register-tools-discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-discovery.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"register-tools-discovery.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AA0CjC;;;;GAIG;AACH,mFAAmF;AACnF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,IAAI,CAaN;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,GAC5C,IAAI,CA0BN;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACjD,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,GACpB,mBAAmB,EAAE,CAqBvB;AAmGD,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,UAAU,GAAE,cAAc,EAAO,EACjC,SAAS,GAAE,kBAAkB,EAAO,GACnC,OAAO,CAAC,IAAI,CAAC,CAmCf"}
|
|
@@ -5,61 +5,12 @@
|
|
|
5
5
|
* Extracted from register-tools.ts so the bundled registration path stays a
|
|
6
6
|
* focused module under the file-length soft limit.
|
|
7
7
|
*/
|
|
8
|
-
import { admitTool, assertManifestMatchesTool,
|
|
9
|
-
import {
|
|
8
|
+
import { admitTool, assertManifestMatchesTool, discoverToolPackagesFromAnchors, logger, resolveProjectContext, resolveProjectPaths, resolveUserPaths, loadToolManifest, } from '@opensip-cli/core';
|
|
9
|
+
import { importToolRuntime, workerRuntimeImportPolicyFor, } from './admit-tool-package.js';
|
|
10
10
|
import { BOOTSTRAP_MODULE } from './constants.js';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* is supplied we use that snapshot so the trust decision and compatibility gate
|
|
15
|
-
* see the identical declaration.
|
|
16
|
-
*
|
|
17
|
-
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
18
|
-
* malformed, or rejected by the compatibility gate.
|
|
19
|
-
*/
|
|
20
|
-
function admitAuthoredTool(source, dir, preloadedManifest) {
|
|
21
|
-
const rawManifest = preloadedManifest ?? loadToolManifest(source, dir);
|
|
22
|
-
if (rawManifest === undefined) {
|
|
23
|
-
throw new PluginIncompatibleError(`${source} tool at '${dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
24
|
-
}
|
|
25
|
-
const result = admitTool({
|
|
26
|
-
manifest: rawManifest,
|
|
27
|
-
source,
|
|
28
|
-
dir,
|
|
29
|
-
explicitlyRequested: true,
|
|
30
|
-
});
|
|
31
|
-
if (result.decision !== 'admit') {
|
|
32
|
-
throw new PluginIncompatibleError(`${source} tool '${rawManifest.id}' is incompatible: ${result.diagnostic ?? 'compatibility gate rejected it'}`, { diagnostic: result.diagnostic });
|
|
33
|
-
}
|
|
34
|
-
return { provenance: result.provenance, manifest: result.manifest };
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Admit or reject a PROJECT-LOCAL authored tool under the deny-by-default trust
|
|
38
|
-
* policy. The trust decision always precedes module import; a non-allowlisted
|
|
39
|
-
* tool fails closed before any authored code can run.
|
|
40
|
-
*
|
|
41
|
-
* @throws {PluginIncompatibleError} When the sidecar manifest is missing,
|
|
42
|
-
* malformed, incompatible, or not trusted by the project-tool allowlist.
|
|
43
|
-
*/
|
|
44
|
-
export function admitProjectLocalTool(args) {
|
|
45
|
-
const manifest = loadToolManifest('project-local', args.dir);
|
|
46
|
-
if (manifest === undefined) {
|
|
47
|
-
throw new PluginIncompatibleError(`project-local tool at '${args.dir}' has no conformant ${PROJECT_LOCAL_MANIFEST_FILE} sidecar`, { diagnostic: 'manifest missing or malformed' });
|
|
48
|
-
}
|
|
49
|
-
if (!isProjectLocalToolTrusted(manifest.id, args.env)) {
|
|
50
|
-
throw new PluginIncompatibleError(`project-local tool '${manifest.id}' is not trusted to load (deny-by-default). ` +
|
|
51
|
-
`Allowlist it via OPENSIP_CLI_ALLOW_PROJECT_TOOLS='${manifest.id}' to admit it.`, { diagnostic: 'project-local tool not allowlisted (deny-by-default)' });
|
|
52
|
-
}
|
|
53
|
-
return admitAuthoredTool('project-local', args.dir, manifest);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Admit a USER-GLOBAL authored tool — trusted-by-default because the user placed
|
|
57
|
-
* it in their own home-dir tool host, but still fail-closed on a missing or
|
|
58
|
-
* incompatible manifest.
|
|
59
|
-
*/
|
|
60
|
-
export function admitUserGlobalTool(args) {
|
|
61
|
-
return admitAuthoredTool('user-global', args.dir);
|
|
62
|
-
}
|
|
11
|
+
import { synthesizeExternalTool } from './synthesize-external-tool.js';
|
|
12
|
+
import { isHostRuntimeImportForbidden } from './tool-provenance.js';
|
|
13
|
+
import { isInstalledToolTrusted } from './tool-trust.js';
|
|
63
14
|
/**
|
|
64
15
|
* Run the admission gate over a discovered INSTALLED tool package before its
|
|
65
16
|
* module is imported. Installed tools are best-effort: incompatible or malformed
|
|
@@ -191,7 +142,20 @@ async function registerDiscoveredInstalledPackage(pkg, args) {
|
|
|
191
142
|
emitInstalledTrustDenied(admission.manifest.id, pkg.name, pkg.packageDir);
|
|
192
143
|
return;
|
|
193
144
|
}
|
|
194
|
-
|
|
145
|
+
// ADR-0054 M4-G (capstone): in the HOST, NEVER import the external runtime —
|
|
146
|
+
// register a manifest-derived synthetic Tool (command shells from the static
|
|
147
|
+
// manifest; the worker imports the real runtime + runs the handler when a
|
|
148
|
+
// command dispatches). The drift guard does not run host-side (there is no
|
|
149
|
+
// runtime to compare; the manifest IS the host source of truth). Inside the
|
|
150
|
+
// dispatch WORKER (`OPENSIP_CLI_IN_TOOL_WORKER=1`) the import path runs — the
|
|
151
|
+
// isolation boundary where the untrusted runtime legitimately loads.
|
|
152
|
+
if (isHostRuntimeImportForbidden(args.env)) {
|
|
153
|
+
// Synchronous void registration (no import in the host); `void` marks the
|
|
154
|
+
// floating call as deliberately non-promise (the synthesize path never awaits).
|
|
155
|
+
void registerSyntheticExternalTool(args, admission, { sourcePackage: pkg.name });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const load = await importToolRuntime(pkg.packageDir, workerRuntimeImportPolicyFor('installed'));
|
|
195
159
|
if (!load.ok) {
|
|
196
160
|
emitInstalledLoadFailure(pkg.name, load);
|
|
197
161
|
return;
|
|
@@ -208,6 +172,23 @@ async function registerDiscoveredInstalledPackage(pkg, args) {
|
|
|
208
172
|
args.provenance.push(admission.provenance);
|
|
209
173
|
args.manifests.push(admission.manifest);
|
|
210
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* ADR-0054 M4-G host path: register the manifest-derived synthetic Tool for an
|
|
177
|
+
* admitted EXTERNAL tool. Honors the same stable-UUID collision + built-in skip
|
|
178
|
+
* the import path applies, keyed on the synthetic tool's `metadata.id`
|
|
179
|
+
* (`stableId ?? id`) so a re-discovered copy is deduped identically.
|
|
180
|
+
*/
|
|
181
|
+
function registerSyntheticExternalTool(args, admission, opts) {
|
|
182
|
+
const tool = synthesizeExternalTool(admission.manifest);
|
|
183
|
+
if (args.builtInIds.has(tool.metadata.name ?? tool.metadata.id))
|
|
184
|
+
return;
|
|
185
|
+
if (args.registeredStableIds.has(tool.metadata.id))
|
|
186
|
+
return;
|
|
187
|
+
// @fitness-ignore-next-line detached-promises -- ToolRegistry.register(...) returns void (registry.ts:46); the detached-promise heuristic misfires on the discarded non-promise call result.
|
|
188
|
+
args.registry.register(tool, opts?.sourcePackage === undefined ? undefined : opts);
|
|
189
|
+
args.provenance.push(admission.provenance);
|
|
190
|
+
args.manifests.push(admission.manifest);
|
|
191
|
+
}
|
|
211
192
|
export async function discoverAndRegisterToolPackages(registry, opts, builtInIds, provenance = [], manifests = []) {
|
|
212
193
|
const discovered = discoverToolPackagesFromAnchors(opts.sources);
|
|
213
194
|
// Stable-UUID collision guard (ADR-0048): a discovered package whose runtime
|
|
@@ -242,49 +223,4 @@ export async function discoverAndRegisterToolPackages(registry, opts, builtInIds
|
|
|
242
223
|
}
|
|
243
224
|
}
|
|
244
225
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Discover + admit + register AUTHORED Tool sidecars from the two authored
|
|
247
|
-
* roots, then dynamic-import each admitted runtime through the shared
|
|
248
|
-
* `importToolRuntime` seam.
|
|
249
|
-
*/
|
|
250
|
-
export async function discoverAndRegisterAuthoredTools(registry, opts, builtInIds, provenance = [], manifests = []) {
|
|
251
|
-
for (const candidate of discoverAuthoredToolSidecars(opts.globalAuthoredDir)) {
|
|
252
|
-
await admitAndRegisterAuthored({
|
|
253
|
-
registry,
|
|
254
|
-
admission: admitUserGlobalTool({ dir: candidate.dir }),
|
|
255
|
-
dir: candidate.dir,
|
|
256
|
-
builtInIds,
|
|
257
|
-
provenance,
|
|
258
|
-
manifests,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
if (opts.projectAuthoredDir !== undefined) {
|
|
262
|
-
for (const candidate of discoverAuthoredToolSidecars(opts.projectAuthoredDir)) {
|
|
263
|
-
await admitAndRegisterAuthored({
|
|
264
|
-
registry,
|
|
265
|
-
admission: admitProjectLocalTool({ dir: candidate.dir, env: opts.env }),
|
|
266
|
-
dir: candidate.dir,
|
|
267
|
-
builtInIds,
|
|
268
|
-
provenance,
|
|
269
|
-
manifests,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/** @throws {PluginIncompatibleError} When the authored tool runtime fails to load. */
|
|
275
|
-
async function admitAndRegisterAuthored(args) {
|
|
276
|
-
const { registry, admission, dir, builtInIds, provenance, manifests } = args;
|
|
277
|
-
const { provenance: prov, manifest } = admission;
|
|
278
|
-
if (builtInIds.has(prov.id))
|
|
279
|
-
return;
|
|
280
|
-
const load = await importToolRuntime(dir, hostRuntimeImportPolicyFor(prov.source));
|
|
281
|
-
if (!load.ok) {
|
|
282
|
-
const detailSuffix = load.detail ? `: ${load.detail}` : '';
|
|
283
|
-
throw new PluginIncompatibleError(`${prov.source} tool '${prov.id}' failed to load via the plugin path (${load.reason}${detailSuffix})`, { diagnostic: `authored tool runtime load failed: ${load.reason}` });
|
|
284
|
-
}
|
|
285
|
-
assertManifestMatchesTool(manifest, load.tool);
|
|
286
|
-
registry.register(load.tool);
|
|
287
|
-
provenance.push(prov);
|
|
288
|
-
manifests.push(manifest);
|
|
289
|
-
}
|
|
290
226
|
//# sourceMappingURL=register-tools-discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-discovery.js","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AAAA,2LAA2L;AAC3L;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB
|
|
1
|
+
{"version":3,"file":"register-tools-discovery.js","sourceRoot":"","sources":["../../src/bootstrap/register-tools-discovery.ts"],"names":[],"mappings":"AAAA,2LAA2L;AAC3L;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,+BAA+B,EAC/B,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GAKjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,iBAAiB,EACjB,4BAA4B,GAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAIzD;;;;GAIG;AACH,SAAS,kBAAkB,CACzB,GAA2D,EAC3D,UAA+B;IAE/B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yBAAyB,GAAG,CAAC,IAAI,oEAAoE,C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AAgB;gBACxB,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-tools-mount.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAU,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"register-tools-mount.d.ts","sourceRoot":"","sources":["../../src/bootstrap/register-tools-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAU,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAS9F;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,cAAc,GAClB,IAAI,CA6BN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAsCvF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { logger } from '@opensip-cli/core';
|
|
2
|
-
import { internalCommandNames, showInternalCommands, } from '../commands/internal-command-visibility.js';
|
|
3
2
|
import { mountCommandSpec } from '../commands/mount-command-spec.js';
|
|
3
|
+
import { buildMaybeDispatchExternal } from './bind-external-dispatch.js';
|
|
4
4
|
import { bindToolCliContext } from './bind-tool-context.js';
|
|
5
5
|
import { BOOTSTRAP_MODULE } from './constants.js';
|
|
6
6
|
import { decorateToolPrimary } from './decorate-tool-primary.js';
|
|
@@ -43,53 +43,19 @@ export function mountAllToolCommands(registry, program, ctx) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
46
|
+
// Tier-3 internal commands are hidden from `--help` self-enforced AT MOUNT by
|
|
47
|
+
// `mountCommandSpec` (it sets Commander's `_hidden` when a spec declares
|
|
48
|
+
// `visibility: 'internal'` and `OPENSIP_CLI_SHOW_INTERNAL` is not set). Doing it
|
|
49
|
+
// in the single mount plane — rather than a post-mount registry walk here — is
|
|
50
|
+
// order-independent: it covers tool workers AND host-mounted internal commands
|
|
51
|
+
// (the ADR-0054 M4-E `__tool-command-worker`, mounted later by
|
|
52
|
+
// `registerCliCommands`) without depending on mount order. `internalCommandNames`
|
|
53
|
+
// remains the descriptor-driven set the completion inventory filters on.
|
|
52
54
|
// ADR-0021: one shared help shape across every mounted command — uniform
|
|
53
55
|
// option/subcommand ordering and a docs footer — applied here (the single
|
|
54
56
|
// place that has walked every tool's commands) rather than per tool.
|
|
55
57
|
applySharedHelpConfiguration(program);
|
|
56
58
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Hide every mounted command the tools declared `visibility: 'internal'`
|
|
59
|
-
* (Tier-3) from `--help`, unless `OPENSIP_CLI_SHOW_INTERNAL=1`
|
|
60
|
-
* ({@link showInternalCommands}).
|
|
61
|
-
*
|
|
62
|
-
* Mechanism: Commander omits a command from help when its `_hidden` property is
|
|
63
|
-
* `true`; the command stays fully invocable (`opensip graph-shard-worker <spec>`
|
|
64
|
-
* still runs). That is the documented, minimal "keep the subcommand but hide it"
|
|
65
|
-
* mechanism — there is no post-hoc public `.command(name, desc, { hidden })`
|
|
66
|
-
* path, so we set the property Commander itself reads for help filtering.
|
|
67
|
-
*
|
|
68
|
-
* The internal-name set is descriptor-driven ({@link internalCommandNames}) — the
|
|
69
|
-
* SAME source the completion inventory filters on — so help and completion stay
|
|
70
|
-
* in lockstep. Walks the full command tree (including nested `<tool> <verb>`
|
|
71
|
-
* children) so a future internal nested command is hidden too.
|
|
72
|
-
*/
|
|
73
|
-
function hideInternalCommands(registry, program) {
|
|
74
|
-
if (showInternalCommands())
|
|
75
|
-
return; // reveal override — leave everything visible
|
|
76
|
-
const internal = internalCommandNames(registry);
|
|
77
|
-
if (internal.size === 0)
|
|
78
|
-
return;
|
|
79
|
-
const hide = (cmd) => {
|
|
80
|
-
for (const sub of cmd.commands) {
|
|
81
|
-
if (internal.has(sub.name())) {
|
|
82
|
-
// Commander 15 reads `_hidden` when filtering help; setting it true hides
|
|
83
|
-
// the command from `--help` while leaving it invocable. Typed via a
|
|
84
|
-
// narrow structural cast — `_hidden` is Commander-internal, not on the
|
|
85
|
-
// public `Command` type, but it is the property the help renderer reads.
|
|
86
|
-
sub._hidden = true;
|
|
87
|
-
}
|
|
88
|
-
hide(sub);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
hide(program);
|
|
92
|
-
}
|
|
93
59
|
/**
|
|
94
60
|
* Mount ONE tool's commands from its declared `commandSpecs` — the only command
|
|
95
61
|
* surface (public launch). Extracted so {@link mountAllToolCommands} keeps its
|
|
@@ -119,7 +85,17 @@ export function mountOneTool(program, tool, ctx) {
|
|
|
119
85
|
});
|
|
120
86
|
return;
|
|
121
87
|
}
|
|
122
|
-
|
|
88
|
+
// ADR-0054: the bound per-tool context carries the out-of-process dispatch
|
|
89
|
+
// hook. The action body calls `maybeDispatchExternal`; for an external-
|
|
90
|
+
// provenance tool it forks a worker (importing the untrusted runtime there)
|
|
91
|
+
// instead of running the handler in-host, then replays the worker's result
|
|
92
|
+
// through the SAME bound (tool-scoped) seams. Bundled tools fall through to
|
|
93
|
+
// the in-process path. Merged here so host commands (lean context) never
|
|
94
|
+
// carry it.
|
|
95
|
+
const boundCtx = bindToolCliContext(tool, ctx);
|
|
96
|
+
const toolCtx = Object.assign(boundCtx, {
|
|
97
|
+
maybeDispatchExternal: buildMaybeDispatchExternal(tool, boundCtx),
|
|
98
|
+
});
|
|
123
99
|
const mountedByName = mountFlatSpecs(program, tool, toolCtx);
|
|
124
100
|
// Host-owned uniform decoration of the tool PRIMARY (the flat run command
|
|
125
101
|
// whose name === metadata.name): per-tool `--version`, guaranteed
|