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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-command-worker-config-pass — the ADR-0054 M4-E DEEP config validation pass
|
|
3
|
+
* the dispatch worker runs against a tool's OWN config schema.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `tool-command-worker-entry.ts` to keep that file within the
|
|
6
|
+
* file-length budget. The host coarse pass (pre-fork) validated only the
|
|
7
|
+
* serializable manifest descriptor shape; this is the semantic, authoritative
|
|
8
|
+
* validation the host (which must not import the tool's Zod) could not perform —
|
|
9
|
+
* legitimate HERE, inside the worker isolation boundary, where the runtime is
|
|
10
|
+
* already loaded.
|
|
11
|
+
*/
|
|
12
|
+
import { type Tool } from '@opensip-cli/core';
|
|
13
|
+
/**
|
|
14
|
+
* Run the dispatched tool's OWN config schema against its coarse-validated config
|
|
15
|
+
* namespace block.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` on success (or when there is nothing to validate); returns a
|
|
18
|
+
* human-readable `Invalid configuration …` MESSAGE on a schema failure. The caller
|
|
19
|
+
* (the worker entry) wraps the message in a `config-invalid` IPC error message —
|
|
20
|
+
* the worker does NOT throw/crash; the supervisor maps it to the SAME typed config
|
|
21
|
+
* error + exit code the host coarse pass uses (single config-error contract).
|
|
22
|
+
*/
|
|
23
|
+
export declare function runDeepConfigPass(tool: Tool, config: unknown): string | undefined;
|
|
24
|
+
//# sourceMappingURL=tool-command-worker-config-pass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-config-pass.d.ts","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-config-pass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAoB,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAqBhE;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAwBjF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-command-worker-config-pass — the ADR-0054 M4-E DEEP config validation pass
|
|
3
|
+
* the dispatch worker runs against a tool's OWN config schema.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `tool-command-worker-entry.ts` to keep that file within the
|
|
6
|
+
* file-length budget. The host coarse pass (pre-fork) validated only the
|
|
7
|
+
* serializable manifest descriptor shape; this is the semantic, authoritative
|
|
8
|
+
* validation the host (which must not import the tool's Zod) could not perform —
|
|
9
|
+
* legitimate HERE, inside the worker isolation boundary, where the runtime is
|
|
10
|
+
* already loaded.
|
|
11
|
+
*/
|
|
12
|
+
import { resolveToolHooks } from '@opensip-cli/core';
|
|
13
|
+
/** Structural guard: the loaded tool's config schema exposes a `safeParse` method. */
|
|
14
|
+
function isSafeParseable(value) {
|
|
15
|
+
return (typeof value === 'object' &&
|
|
16
|
+
value !== null &&
|
|
17
|
+
typeof value.safeParse === 'function');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run the dispatched tool's OWN config schema against its coarse-validated config
|
|
21
|
+
* namespace block.
|
|
22
|
+
*
|
|
23
|
+
* Returns `undefined` on success (or when there is nothing to validate); returns a
|
|
24
|
+
* human-readable `Invalid configuration …` MESSAGE on a schema failure. The caller
|
|
25
|
+
* (the worker entry) wraps the message in a `config-invalid` IPC error message —
|
|
26
|
+
* the worker does NOT throw/crash; the supervisor maps it to the SAME typed config
|
|
27
|
+
* error + exit code the host coarse pass uses (single config-error contract).
|
|
28
|
+
*/
|
|
29
|
+
export function runDeepConfigPass(tool, config) {
|
|
30
|
+
// No config block in the document for this tool's namespace → nothing to
|
|
31
|
+
// deep-validate (the host coarse pass already accepted its absence).
|
|
32
|
+
if (config === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
const declaration = resolveToolHooks(tool).config;
|
|
35
|
+
// No Zod declaration on the runtime → defer to the coarse pass's verdict (the
|
|
36
|
+
// host already accepted the block as an opaque object); nothing deeper to run.
|
|
37
|
+
if (declaration === undefined || !isSafeParseable(declaration.schema))
|
|
38
|
+
return undefined;
|
|
39
|
+
const result = declaration.schema.safeParse(config);
|
|
40
|
+
if (result.success)
|
|
41
|
+
return undefined;
|
|
42
|
+
const summary = (result.error?.issues ?? [])
|
|
43
|
+
.map((issue) => {
|
|
44
|
+
const path = issue.path !== undefined && issue.path.length > 0
|
|
45
|
+
? issue.path.join('.')
|
|
46
|
+
: declaration.namespace;
|
|
47
|
+
return `${declaration.namespace}.${path}: ${issue.message}`;
|
|
48
|
+
})
|
|
49
|
+
.join('; ');
|
|
50
|
+
return `Invalid configuration for '${tool.metadata.name ?? tool.metadata.id}': ${summary.length > 0 ? summary : 'config did not satisfy the tool schema'}`;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=tool-command-worker-config-pass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-config-pass.js","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-config-pass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAa,MAAM,mBAAmB,CAAC;AAYhE,sFAAsF;AACtF,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAiC,CAAC,SAAS,KAAK,UAAU,CACnE,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAU,EAAE,MAAe;IAC3D,yEAAyE;IACzE,qEAAqE;IACrE,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAClD,8EAA8E;IAC9E,+EAA+E;IAC/E,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAExF,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAErC,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC;SACzC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,IAAI,GACR,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAC/C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YACtB,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC;QAC5B,OAAO,GAAG,WAAW,CAAC,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9D,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,8BAA8B,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,MACzE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,wCACjC,EAAE,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-command-worker-context — the WORKER-side {@link ToolCliContext} shim for
|
|
3
|
+
* the ADR-0054 out-of-process dispatch plane (increments M4-C / M4-D).
|
|
4
|
+
*
|
|
5
|
+
* Each seam the worker exposes to the dispatched handler is implemented per its
|
|
6
|
+
* transport strategy from ADR-0054's M4-C mapping table:
|
|
7
|
+
*
|
|
8
|
+
* - final-result-return (FRR): `render` / `emitJson` / `emitEnvelope` /
|
|
9
|
+
* `emitRaw` / `emitError` / `setExitCode` record into a {@link
|
|
10
|
+
* ResultAccumulator} drained into a `ToolCommandResult` after the handler
|
|
11
|
+
* resolves; the host replays them through the real seams.
|
|
12
|
+
* - host-RPC (RPC): `deliverSignals` / `writeSarif` / the four baseline seams
|
|
13
|
+
* / `toolState.*` / `hostPlanes.*` / `maybeOpenReport` / `getExitCode` issue
|
|
14
|
+
* a typed {@link HostRpcRequest} via the {@link WorkerRpcClient} and await
|
|
15
|
+
* the host's reply — the HOST performs the privileged effect (datastore /
|
|
16
|
+
* egress / FS / process exit) and returns the result.
|
|
17
|
+
* - host-only (fail loud): the live-view seams (`registerLiveView` /
|
|
18
|
+
* `renderLive`) throw {@link UnsupportedSeamError} — Ink/TTY rendering
|
|
19
|
+
* cannot leave the host (documented as a later increment).
|
|
20
|
+
*
|
|
21
|
+
* `scope` / `runSession` / `logger` are backed by the worker's own minimal
|
|
22
|
+
* {@link RunScope} + run timer (the worker re-bootstraps its own scope; it never
|
|
23
|
+
* ships a live `RunScope` across IPC).
|
|
24
|
+
*/
|
|
25
|
+
import { type RunScope, type RunTimer, type ToolCliContext } from '@opensip-cli/core';
|
|
26
|
+
import type { ToolCommandFailureClass, ToolCommandResult } from './tool-command-dispatch-types.js';
|
|
27
|
+
import type { WorkerRpcClient } from './tool-command-worker-rpc.js';
|
|
28
|
+
/**
|
|
29
|
+
* A loud, marked failure for a seam the worker shim cannot marshal (the
|
|
30
|
+
* live-view seams). Carries the {@link ToolCommandFailureClass} so the
|
|
31
|
+
* supervisor can triage; the worker catch turns it into an `error` IPC message.
|
|
32
|
+
*/
|
|
33
|
+
export declare class UnsupportedSeamError extends Error {
|
|
34
|
+
readonly failureClass: ToolCommandFailureClass;
|
|
35
|
+
constructor(seam: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The mutable accumulator the worker-side context shim records final-result
|
|
39
|
+
* seam calls into. Drained into a {@link ToolCommandResult} after the handler
|
|
40
|
+
* resolves.
|
|
41
|
+
*/
|
|
42
|
+
export interface ResultAccumulator {
|
|
43
|
+
render?: unknown;
|
|
44
|
+
envelope?: unknown;
|
|
45
|
+
json?: unknown;
|
|
46
|
+
raw?: unknown;
|
|
47
|
+
error?: ToolCommandResult['error'];
|
|
48
|
+
exitCode?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build the worker-side {@link ToolCliContext} shim. FRR seams record into
|
|
52
|
+
* `acc`; RPC seams upcall via `rpcClient`; the live-view seams fail loud.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildWorkerContext(scope: RunScope, timing: RunTimer, acc: ResultAccumulator, rpcClient: WorkerRpcClient): ToolCliContext;
|
|
55
|
+
//# sourceMappingURL=tool-command-worker-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-context.d.ts","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAKL,KAAK,QAAQ,EACb,KAAK,QAAQ,EAEb,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAGV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAsB;gBACxD,IAAI,EAAE,MAAM;CAQzB;AAgBD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA2DD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,iBAAiB,EACtB,SAAS,EAAE,eAAe,GACzB,cAAc,CA+DhB"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-command-worker-context — the WORKER-side {@link ToolCliContext} shim for
|
|
3
|
+
* the ADR-0054 out-of-process dispatch plane (increments M4-C / M4-D).
|
|
4
|
+
*
|
|
5
|
+
* Each seam the worker exposes to the dispatched handler is implemented per its
|
|
6
|
+
* transport strategy from ADR-0054's M4-C mapping table:
|
|
7
|
+
*
|
|
8
|
+
* - final-result-return (FRR): `render` / `emitJson` / `emitEnvelope` /
|
|
9
|
+
* `emitRaw` / `emitError` / `setExitCode` record into a {@link
|
|
10
|
+
* ResultAccumulator} drained into a `ToolCommandResult` after the handler
|
|
11
|
+
* resolves; the host replays them through the real seams.
|
|
12
|
+
* - host-RPC (RPC): `deliverSignals` / `writeSarif` / the four baseline seams
|
|
13
|
+
* / `toolState.*` / `hostPlanes.*` / `maybeOpenReport` / `getExitCode` issue
|
|
14
|
+
* a typed {@link HostRpcRequest} via the {@link WorkerRpcClient} and await
|
|
15
|
+
* the host's reply — the HOST performs the privileged effect (datastore /
|
|
16
|
+
* egress / FS / process exit) and returns the result.
|
|
17
|
+
* - host-only (fail loud): the live-view seams (`registerLiveView` /
|
|
18
|
+
* `renderLive`) throw {@link UnsupportedSeamError} — Ink/TTY rendering
|
|
19
|
+
* cannot leave the host (documented as a later increment).
|
|
20
|
+
*
|
|
21
|
+
* `scope` / `runSession` / `logger` are backed by the worker's own minimal
|
|
22
|
+
* {@link RunScope} + run timer (the worker re-bootstraps its own scope; it never
|
|
23
|
+
* ships a live `RunScope` across IPC).
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* A loud, marked failure for a seam the worker shim cannot marshal (the
|
|
27
|
+
* live-view seams). Carries the {@link ToolCommandFailureClass} so the
|
|
28
|
+
* supervisor can triage; the worker catch turns it into an `error` IPC message.
|
|
29
|
+
*/
|
|
30
|
+
export class UnsupportedSeamError extends Error {
|
|
31
|
+
failureClass = 'unsupported-seam';
|
|
32
|
+
constructor(seam) {
|
|
33
|
+
super(`tool command worker: seam '${seam}' cannot be marshalled across the ADR-0054 ` +
|
|
34
|
+
'dispatch boundary (Ink/TTY rendering stays host-side). The external command ' +
|
|
35
|
+
'attempted a live-view effect the worker cannot perform.');
|
|
36
|
+
this.name = 'UnsupportedSeamError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a host-only seam stub that fails loudly when an external handler calls a
|
|
41
|
+
* seam the worker cannot marshal (the live-view seams).
|
|
42
|
+
*
|
|
43
|
+
* @throws {UnsupportedSeamError} always — that is the point: an unmarshallable
|
|
44
|
+
* seam must surface as a structured failure, never a silent no-op.
|
|
45
|
+
*/
|
|
46
|
+
function unsupported(seam) {
|
|
47
|
+
// @fitness-ignore-next-line throws-documentation -- the throw is documented on the enclosing `unsupported` factory's @throws above; this is the one-line closure it returns.
|
|
48
|
+
return () => {
|
|
49
|
+
throw new UnsupportedSeamError(seam);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Issue one RPC upcall and cast the host's reply to the seam's return type. */
|
|
53
|
+
function rpc(client, request) {
|
|
54
|
+
return client.call(request);
|
|
55
|
+
}
|
|
56
|
+
/** Build the RPC-backed `toolState` member (ADR-0042 datastore-backed). */
|
|
57
|
+
function buildToolStateRpc(client) {
|
|
58
|
+
return {
|
|
59
|
+
get: (tool, key) => rpc(client, { seam: 'toolState.get', tool, key }),
|
|
60
|
+
put: (tool, key, payload) => rpc(client, { seam: 'toolState.put', tool, key, payload }),
|
|
61
|
+
delete: (tool, key) => rpc(client, { seam: 'toolState.delete', tool, key }),
|
|
62
|
+
list: (tool) => rpc(client, { seam: 'toolState.list', tool }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Make one host-plane method into a generic `hostPlane` upcall
|
|
67
|
+
* (`plane`/`method`/`args`). The host dispatches to the real plane impl by name;
|
|
68
|
+
* the worker never holds a plane handle.
|
|
69
|
+
*/
|
|
70
|
+
function planeMethod(client, plane, method) {
|
|
71
|
+
return (...args) => rpc(client, { seam: 'hostPlane', plane, method, args });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the RPC-backed `hostPlanes` bag (governance / audit / entitlements).
|
|
75
|
+
* Each plane's methods are enumerated explicitly (rather than via a Proxy) so
|
|
76
|
+
* the shim conforms to the core host-plane interfaces structurally — every
|
|
77
|
+
* method routes through {@link planeMethod} to a generic `hostPlane` upcall.
|
|
78
|
+
*/
|
|
79
|
+
function buildHostPlanesRpc(client) {
|
|
80
|
+
const governance = {
|
|
81
|
+
getGovernanceState: planeMethod(client, 'governance', 'getGovernanceState'),
|
|
82
|
+
listForProject: planeMethod(client, 'governance', 'listForProject'),
|
|
83
|
+
queryAudit: planeMethod(client, 'governance', 'queryAudit'),
|
|
84
|
+
recordInstallation: planeMethod(client, 'governance', 'recordInstallation'),
|
|
85
|
+
recordApprovalDecision: planeMethod(client, 'governance', 'recordApprovalDecision'),
|
|
86
|
+
setBlock: planeMethod(client, 'governance', 'setBlock'),
|
|
87
|
+
checkAllowed: planeMethod(client, 'governance', 'checkAllowed'),
|
|
88
|
+
};
|
|
89
|
+
const audit = {
|
|
90
|
+
append: planeMethod(client, 'audit', 'append'),
|
|
91
|
+
query: planeMethod(client, 'audit', 'query'),
|
|
92
|
+
exportForCloud: planeMethod(client, 'audit', 'exportForCloud'),
|
|
93
|
+
};
|
|
94
|
+
const entitlements = {
|
|
95
|
+
check: planeMethod(client, 'entitlements', 'check'),
|
|
96
|
+
recordUsage: planeMethod(client, 'entitlements', 'recordUsage'),
|
|
97
|
+
getLicenseState: planeMethod(client, 'entitlements', 'getLicenseState'),
|
|
98
|
+
};
|
|
99
|
+
return { governance, audit, entitlements };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Build the worker-side {@link ToolCliContext} shim. FRR seams record into
|
|
103
|
+
* `acc`; RPC seams upcall via `rpcClient`; the live-view seams fail loud.
|
|
104
|
+
*/
|
|
105
|
+
export function buildWorkerContext(scope, timing, acc, rpcClient) {
|
|
106
|
+
return {
|
|
107
|
+
scope,
|
|
108
|
+
runSession: { timing },
|
|
109
|
+
logger: scope.logger,
|
|
110
|
+
// ── Final-result-return seams (recorded, replayed host-side) ──────────
|
|
111
|
+
render: (result) => {
|
|
112
|
+
acc.render = result;
|
|
113
|
+
return Promise.resolve();
|
|
114
|
+
},
|
|
115
|
+
emitJson: (value) => {
|
|
116
|
+
acc.json = value;
|
|
117
|
+
},
|
|
118
|
+
emitEnvelope: (envelope) => {
|
|
119
|
+
acc.envelope = envelope;
|
|
120
|
+
},
|
|
121
|
+
emitRaw: (value) => {
|
|
122
|
+
acc.raw = value;
|
|
123
|
+
},
|
|
124
|
+
emitError: (detail) => {
|
|
125
|
+
acc.error = {
|
|
126
|
+
message: detail.message,
|
|
127
|
+
exitCode: detail.exitCode,
|
|
128
|
+
...(detail.suggestion === undefined ? {} : { suggestion: detail.suggestion }),
|
|
129
|
+
...(detail.code === undefined ? {} : { code: detail.code }),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
setExitCode: (code) => {
|
|
133
|
+
acc.exitCode = code;
|
|
134
|
+
},
|
|
135
|
+
// ── Host-RPC seams (M4-C upcalls — host performs the effect) ──────────
|
|
136
|
+
getExitCode: () => acc.exitCode,
|
|
137
|
+
deliverSignals: (envelope, opts) => rpc(rpcClient, {
|
|
138
|
+
seam: 'deliverSignals',
|
|
139
|
+
envelope,
|
|
140
|
+
opts: {
|
|
141
|
+
cwd: opts.cwd,
|
|
142
|
+
...(opts.reportTo === undefined ? {} : { reportTo: opts.reportTo }),
|
|
143
|
+
...(opts.apiKey === undefined ? {} : { apiKey: opts.apiKey }),
|
|
144
|
+
...(opts.runFailed === undefined ? {} : { runFailed: opts.runFailed }),
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
writeSarif: (envelope, path) => rpc(rpcClient, { seam: 'writeSarif', envelope, path }),
|
|
148
|
+
saveBaseline: (tool, envelope) => rpc(rpcClient, { seam: 'saveBaseline', tool, envelope }),
|
|
149
|
+
compareBaseline: (tool, envelope) => rpc(rpcClient, { seam: 'compareBaseline', tool, envelope }),
|
|
150
|
+
exportBaselineSarif: (tool, path) => rpc(rpcClient, { seam: 'exportBaselineSarif', tool, path }),
|
|
151
|
+
exportBaselineFingerprints: (tool, path) => rpc(rpcClient, { seam: 'exportBaselineFingerprints', tool, path }),
|
|
152
|
+
maybeOpenReport: (opts) => rpc(rpcClient, {
|
|
153
|
+
seam: 'maybeOpenReport',
|
|
154
|
+
opts: { openRequested: opts.openRequested, jsonOutput: opts.jsonOutput },
|
|
155
|
+
}),
|
|
156
|
+
toolState: buildToolStateRpc(rpcClient),
|
|
157
|
+
hostPlanes: buildHostPlanesRpc(rpcClient),
|
|
158
|
+
// ── Live-view seams (host-only — fail loud) ───────────────────────────
|
|
159
|
+
registerLiveView: unsupported('registerLiveView'),
|
|
160
|
+
renderLive: unsupported('renderLive'),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=tool-command-worker-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-context.js","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAqBH;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,YAAY,GAA4B,kBAAkB,CAAC;IACpE,YAAY,IAAY;QACtB,KAAK,CACH,8BAA8B,IAAI,6CAA6C;YAC7E,8EAA8E;YAC9E,yDAAyD,CAC5D,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,6KAA6K;IAC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,SAAS,EAAE;YACnB,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;SACzE,CAAC;QACJ,SAAS,EAAE,iBAAiB,CAAC,SAAS,CAAC;QACvC,UAAU,EAAE,kBAAkB,CAAC,SAAS,CAAC;QACzC,yEAAyE;QACzE,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC;QACjD,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-command-worker-entry — the WORKER side of the out-of-process external
|
|
3
|
+
* tool command dispatch plane (ADR-0054, increments M4-C / M4-D / M4-E).
|
|
4
|
+
*
|
|
5
|
+
* This is a HOST internal `CommandSpec` (`__tool-command-worker`), forked by the
|
|
6
|
+
* supervisor as `node <cliScript> __tool-command-worker <specPath> --cwd <cwd>`.
|
|
7
|
+
* Forking the CLI binary as a subcommand (the SAME pattern graph's
|
|
8
|
+
* `graph-run-worker` uses) means the FULL CLI bootstrap runs first: the preAction
|
|
9
|
+
* hook discovers + imports the external tool runtime IN THE WORKER, registers it,
|
|
10
|
+
* runs its `contributeScope`, composes + validates config, and builds the full
|
|
11
|
+
* per-run scope — so by the time this handler runs, `currentScope()` carries the
|
|
12
|
+
* tool's subscope (`scope.fitness`/…), the check/recipe registries, project
|
|
13
|
+
* context, and `toolConfig` exactly as an in-process run (ADR-0054 M4-C `scope`
|
|
14
|
+
* mapping: "the worker re-bootstraps its OWN scope … exactly like graph's
|
|
15
|
+
* worker"). This is the isolation move — the untrusted runtime loads HERE, in the
|
|
16
|
+
* worker, never in the host.
|
|
17
|
+
*
|
|
18
|
+
* The handler then resolves the dispatched tool from the re-bootstrapped registry
|
|
19
|
+
* and runs ITS command handler against the WORKER-side `ToolCliContext` shim
|
|
20
|
+
* (`tool-command-worker-context.ts`): FRR seams (render/json/envelope/raw/error/
|
|
21
|
+
* exit) record the value and return it once in the {@link ToolCommandResult}; the
|
|
22
|
+
* host-RPC seams (datastore / egress / SARIF / baselines / toolState / hostPlanes
|
|
23
|
+
* / report-open / exit-code re-affirm) UPCALL the host over the rpc-reply channel
|
|
24
|
+
* (the host performs the privileged effect — datastore/network/FS/exit stay
|
|
25
|
+
* host-owned). Only the live-view seams fail loud (`unsupported-seam`).
|
|
26
|
+
*
|
|
27
|
+
* A handler that calls `process.exit`, throws, crashes the native layer, or spins
|
|
28
|
+
* the event loop is contained: the supervisor turns a premature child exit /
|
|
29
|
+
* timeout / `error` message into a structured parent-side failure, and the host
|
|
30
|
+
* process survives.
|
|
31
|
+
*/
|
|
32
|
+
import { type CommandSpec, type WorkerMessage } from '@opensip-cli/core';
|
|
33
|
+
import { type CliCommandsContext } from '../commands/shared.js';
|
|
34
|
+
import type { HostRpcRequest, ToolCommandResult } from './tool-command-dispatch-types.js';
|
|
35
|
+
/**
|
|
36
|
+
* The worker's IPC message type binding: host-RPC requests stream on the
|
|
37
|
+
* `progress` arm; the final {@link ToolCommandResult} settles `result`.
|
|
38
|
+
*/
|
|
39
|
+
type DispatchWorkerMessage = WorkerMessage<HostRpcRequest, ToolCommandResult>;
|
|
40
|
+
/**
|
|
41
|
+
* The testable core: produce the {@link DispatchWorkerMessage} the worker would
|
|
42
|
+
* post, without touching `process.send`. Never throws — every failure becomes a
|
|
43
|
+
* structured `error` message (the supervisor rejects on it). Must run inside an
|
|
44
|
+
* entered scope (the bootstrap enters it for the real subcommand; unit tests wrap
|
|
45
|
+
* it in `runWithScope`).
|
|
46
|
+
*/
|
|
47
|
+
export declare function runToolCommandWorker(specPath: string): Promise<DispatchWorkerMessage>;
|
|
48
|
+
/**
|
|
49
|
+
* Run one external tool command headless in this worker and post the slim
|
|
50
|
+
* {@link ToolCommandResult} (or a structured `error`) over IPC. Never throws to
|
|
51
|
+
* the caller — every failure becomes an `error` IPC message so the supervisor
|
|
52
|
+
* rejects cleanly. This is the host CommandSpec handler's body.
|
|
53
|
+
*/
|
|
54
|
+
export declare function executeToolCommandWorker(specPath: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* `__tool-command-worker <specPath>` — the [internal] host subcommand the
|
|
57
|
+
* dispatch supervisor forks. Mirrors `graphRunWorkerCommandSpec`: `raw-stream`
|
|
58
|
+
* (it owns its own IPC output surface), `scope: 'project'` (the full bootstrap
|
|
59
|
+
* runs first), `visibility: 'internal'`. The supervisor passes `--cwd` so the
|
|
60
|
+
* bootstrap targets the right project. The handler ignores the host `ctx` it is
|
|
61
|
+
* given (the worker builds its OWN context shim over the bootstrapped scope) and
|
|
62
|
+
* posts the result over the IPC channel.
|
|
63
|
+
*/
|
|
64
|
+
export declare const toolCommandWorkerCommandSpec: CommandSpec<unknown, CliCommandsContext>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=tool-command-worker-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-entry.d.ts","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EAKL,KAAK,WAAW,EAKhB,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAUhE,OAAO,KAAK,EACV,cAAc,EAEd,iBAAiB,EAElB,MAAM,kCAAkC,CAAC;AAE1C;;;GAGG;AACH,KAAK,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAuQ9E;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAY3F;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAkBhF,CAAC"}
|