opensip-cli 0.1.7 → 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 +27 -3
- 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/index.d.ts +6 -0
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +14 -2
- package/dist/bootstrap/index.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/pre-action-hook.d.ts.map +1 -1
- package/dist/bootstrap/pre-action-hook.js +5 -0
- package/dist/bootstrap/pre-action-hook.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 +4 -52
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.js +82 -117
- 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/scope-access.d.ts +15 -1
- package/dist/bootstrap/scope-access.d.ts.map +1 -1
- package/dist/bootstrap/scope-access.js +12 -1
- package/dist/bootstrap/scope-access.js.map +1 -1
- package/dist/bootstrap/skip-installed-plugins.d.ts +23 -0
- package/dist/bootstrap/skip-installed-plugins.d.ts.map +1 -0
- package/dist/bootstrap/skip-installed-plugins.js +30 -0
- package/dist/bootstrap/skip-installed-plugins.js.map +1 -0
- 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/bootstrap/tool-trust.d.ts +22 -2
- package/dist/bootstrap/tool-trust.d.ts.map +1 -1
- package/dist/bootstrap/tool-trust.js +25 -2
- package/dist/bootstrap/tool-trust.js.map +1 -1
- 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 +28 -0
- package/dist/env/host-env-specs.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- 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/command-label.d.ts +19 -0
- package/dist/telemetry/command-label.d.ts.map +1 -0
- package/dist/telemetry/command-label.js +26 -0
- package/dist/telemetry/command-label.js.map +1 -0
- 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/dist/telemetry/sdk-init.d.ts +9 -0
- package/dist/telemetry/sdk-init.d.ts.map +1 -1
- package/dist/telemetry/sdk-init.js +32 -0
- package/dist/telemetry/sdk-init.js.map +1 -1
- package/dist/ui/views/tools-views.d.ts.map +1 -1
- package/dist/ui/views/tools-views.js +8 -0
- package/dist/ui/views/tools-views.js.map +1 -1
- package/package.json +32 -32
|
@@ -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,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AE,EAAE,CACzC,GAAG,CAAO,SAAS,EAAE,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC1E,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CACxB,GAAG,CAAO,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"}
|
|
@@ -0,0 +1,298 @@
|
|
|
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 { readFileSync } from 'node:fs';
|
|
33
|
+
import { createRunTimer, currentScope, defineCommand, resolveToolHooks, } from '@opensip-cli/core';
|
|
34
|
+
import { runDeepConfigPass } from './tool-command-worker-config-pass.js';
|
|
35
|
+
import { buildWorkerContext, UnsupportedSeamError, } from './tool-command-worker-context.js';
|
|
36
|
+
import { createWorkerRpcClient } from './tool-command-worker-rpc.js';
|
|
37
|
+
/** Post one IPC message to the parent (no-op when not forked — e.g. a unit call). */
|
|
38
|
+
function send(msg) {
|
|
39
|
+
process.send?.(msg);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the dispatched tool from the re-bootstrapped registry. The bootstrap
|
|
43
|
+
* already imported + registered it (the isolation import happened in this worker
|
|
44
|
+
* during preAction). Match by the registry's human key first, then by stable id /
|
|
45
|
+
* human name — symmetric to the host provenance/dispatch matchers.
|
|
46
|
+
*
|
|
47
|
+
* @throws {Error & {failureClass}} `runtime-load-failed` when the tool is not in
|
|
48
|
+
* the worker's registry (the bootstrap did not admit it — e.g. a trust-policy
|
|
49
|
+
* or discovery miss). Surfaces as a structured IPC error; the host survives.
|
|
50
|
+
*/
|
|
51
|
+
function resolveTool(spec) {
|
|
52
|
+
const tools = currentScope()?.tools;
|
|
53
|
+
const tool = tools?.get(spec.toolId) ??
|
|
54
|
+
tools?.list().find((t) => t.metadata.id === spec.toolId || t.metadata.name === spec.toolId);
|
|
55
|
+
if (tool === undefined) {
|
|
56
|
+
const err = new Error(`tool command worker: tool '${spec.toolId}' is not registered in the worker scope ` +
|
|
57
|
+
'(the bootstrap did not discover/admit it — check provenance/trust policy)');
|
|
58
|
+
err.failureClass = 'runtime-load-failed';
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
return tool;
|
|
62
|
+
}
|
|
63
|
+
/** Resolve the command spec the worker should run, or throw `command-not-found`. */
|
|
64
|
+
function findCommandSpec(tool, commandName) {
|
|
65
|
+
const spec = tool.commandSpecs?.find((s) => s.name === commandName);
|
|
66
|
+
if (spec === undefined) {
|
|
67
|
+
const err = new Error(`tool command worker: tool '${tool.metadata.id}' has no command '${commandName}'`);
|
|
68
|
+
err.failureClass = 'command-not-found';
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
71
|
+
return spec;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* ADR-0054 M4-F: run the dispatched tool's `initialize()` once, worker-side,
|
|
75
|
+
* before its handler. The host no longer runs an EXTERNAL owning tool's
|
|
76
|
+
* `initialize` (that would execute untrusted runtime in the kernel) — and the
|
|
77
|
+
* worker bootstraps the host `__tool-command-worker` subcommand (owned by NO
|
|
78
|
+
* tool), so the worker's own preflight never resolves the dispatched tool as the
|
|
79
|
+
* "owning tool". Running it here is the only place an external tool's
|
|
80
|
+
* `initialize` runs under worker dispatch. A throw propagates to
|
|
81
|
+
* {@link runToolCommandWorker}'s catch → structured `tool-handler-throw`; the
|
|
82
|
+
* host survives (fail loud, never a half-initialised silent run).
|
|
83
|
+
*/
|
|
84
|
+
async function runWorkerInitialize(tool) {
|
|
85
|
+
const initialize = resolveToolHooks(tool).initialize;
|
|
86
|
+
if (initialize === undefined)
|
|
87
|
+
return;
|
|
88
|
+
await initialize();
|
|
89
|
+
}
|
|
90
|
+
/** Build a structured `error` IPC message with a failure class (+ stack when present). */
|
|
91
|
+
function errorMessage(message, failureClass, stack) {
|
|
92
|
+
return {
|
|
93
|
+
kind: 'error',
|
|
94
|
+
message,
|
|
95
|
+
failureClass,
|
|
96
|
+
...(stack === undefined ? {} : { stack }),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Read + parse the worker spec file, or return a `bad-spec` error message. */
|
|
100
|
+
function readSpec(specPath) {
|
|
101
|
+
try {
|
|
102
|
+
return JSON.parse(readFileSync(specPath, 'utf8'));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return errorMessage(`tool command worker: unreadable spec at '${specPath}': ${error instanceof Error ? error.message : String(error)}`, 'bad-spec');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The output modes whose PAYLOAD is the handler's RETURN value (routed by the
|
|
110
|
+
* in-process `dispatchOutput`): `command-result` (a `CommandResult`) and
|
|
111
|
+
* `signal-envelope` (a `SignalEnvelope`). For these, the worker must carry the
|
|
112
|
+
* return back UNROUTED in `returned` so the supervisor replays it through the SAME
|
|
113
|
+
* `dispatchOutput`. `raw-stream` / `live-view` produce no routable return payload.
|
|
114
|
+
*/
|
|
115
|
+
function isReturnValuedOutput(output) {
|
|
116
|
+
return output === 'command-result' || output === 'signal-envelope';
|
|
117
|
+
}
|
|
118
|
+
/** Drain the accumulator + the handler's return into a serializable result. */
|
|
119
|
+
function toResult(output, acc, session, returned) {
|
|
120
|
+
return {
|
|
121
|
+
output,
|
|
122
|
+
...(acc.render === undefined ? {} : { render: acc.render }),
|
|
123
|
+
...(acc.envelope === undefined ? {} : { envelope: acc.envelope }),
|
|
124
|
+
...(acc.json === undefined ? {} : { json: acc.json }),
|
|
125
|
+
...(acc.raw === undefined ? {} : { raw: acc.raw }),
|
|
126
|
+
...(acc.error === undefined ? {} : { error: acc.error }),
|
|
127
|
+
...(acc.exitCode === undefined ? {} : { exitCode: acc.exitCode }),
|
|
128
|
+
...(session === undefined ? {} : { session }),
|
|
129
|
+
// Carry the handler's return for the return-valued modes so the supervisor
|
|
130
|
+
// routes it via the same `dispatchOutput` the in-process path uses (parity).
|
|
131
|
+
...(returned === undefined || !isReturnValuedOutput(output) ? {} : { returned }),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Map a thrown error to its structured failure class for the IPC `error` message. */
|
|
135
|
+
function classifyThrow(error) {
|
|
136
|
+
if (error instanceof UnsupportedSeamError)
|
|
137
|
+
return error.failureClass;
|
|
138
|
+
return error.failureClass ?? 'tool-handler-throw';
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve the dispatched tool from the re-bootstrapped scope, run the deep config
|
|
142
|
+
* pass, then run its command handler against the worker-side context shim, and
|
|
143
|
+
* build the result. Throws on a handler error (caught by
|
|
144
|
+
* {@link runToolCommandWorker}); returns an `error` message for the structured
|
|
145
|
+
* pre-handler failures (config-invalid; tool / command-not-found are thrown with
|
|
146
|
+
* a failureClass tag).
|
|
147
|
+
*
|
|
148
|
+
* `currentScope()` here is the FULL per-run scope the CLI bootstrap built for the
|
|
149
|
+
* `__tool-command-worker` subcommand (project/config/registries/contributeScope),
|
|
150
|
+
* so the handler reads `cli.scope.toolConfig`/`cli.scope.<subscope>`/checks
|
|
151
|
+
* worker-LOCAL while datastore/egress cross to the host via the RPC shim.
|
|
152
|
+
*/
|
|
153
|
+
async function runLoadedCommand(spec) {
|
|
154
|
+
const tool = resolveTool(spec);
|
|
155
|
+
// ADR-0054 M4-F hook mode: when the spec names a lifecycle HOOK (not a command),
|
|
156
|
+
// run that hook worker-side and return its plain-data result. This is how the
|
|
157
|
+
// host gathers an external tool's `collectReportData` / `sessionReplay` without
|
|
158
|
+
// executing the untrusted runtime in the kernel process.
|
|
159
|
+
if (spec.hook !== undefined) {
|
|
160
|
+
return await runLoadedHook(tool, spec);
|
|
161
|
+
}
|
|
162
|
+
if (spec.commandName === undefined) {
|
|
163
|
+
return errorMessage(`tool command worker: spec for tool '${spec.toolId}' names neither a command nor a hook`, 'bad-spec');
|
|
164
|
+
}
|
|
165
|
+
const commandSpec = findCommandSpec(tool, spec.commandName);
|
|
166
|
+
// ADR-0054 M4-E DEEP config pass: run the tool's REAL Zod against its config
|
|
167
|
+
// namespace IN THE WORKER (the host validated only the coarse manifest shape
|
|
168
|
+
// pre-fork). A failure crosses IPC as `config-invalid` — never a host crash —
|
|
169
|
+
// and the supervisor maps it to the SAME typed config error the host coarse
|
|
170
|
+
// pass uses. Runs BEFORE building the context: a config failure must
|
|
171
|
+
// short-circuit before any handler effect.
|
|
172
|
+
const configFailure = runDeepConfigPass(tool, spec.config);
|
|
173
|
+
if (configFailure !== undefined)
|
|
174
|
+
return errorMessage(configFailure, 'config-invalid');
|
|
175
|
+
// ADR-0054 M4-F: run the dispatched tool's `initialize()` worker-side before the
|
|
176
|
+
// handler (the host no longer runs an external owning tool's initialize). A
|
|
177
|
+
// throw becomes a structured `tool-handler-throw` via the outer catch.
|
|
178
|
+
await runWorkerInitialize(tool);
|
|
179
|
+
// The host-RPC upcall client over the live IPC channel (M4-C). `process` is the
|
|
180
|
+
// duplex: requests post via `process.send`; replies arrive on
|
|
181
|
+
// `process.on('message')`. Disposed in the finally so the listener is removed.
|
|
182
|
+
const rpcClient = createWorkerRpcClient(process);
|
|
183
|
+
// The handler runs against the bootstrapped scope (worker-local reads) but with
|
|
184
|
+
// the WORKER context shim (FRR records + RPC upcalls for privileged effects).
|
|
185
|
+
const scope = currentScope();
|
|
186
|
+
if (scope === undefined) {
|
|
187
|
+
return errorMessage('tool command worker: no scope is entered (bootstrap did not run before the worker handler)', 'runtime-load-failed');
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const acc = {};
|
|
191
|
+
const ctx = buildWorkerContext(scope, createRunTimer(), acc, rpcClient);
|
|
192
|
+
// Run the handler. A `process.exit` / crash / hang here is contained by the
|
|
193
|
+
// supervisor (premature-exit / timeout → structured parent failure); a throw
|
|
194
|
+
// propagates to runToolCommandWorker's catch and becomes a structured error.
|
|
195
|
+
// The handler's RETURN serves two roles: (1) for `command-result` /
|
|
196
|
+
// `signal-envelope` it IS the output payload (routed by `dispatchOutput`
|
|
197
|
+
// host-side); (2) it may carry a `session` leg (ToolRunCompletion) the host
|
|
198
|
+
// persists after the worker resolves (host-owned-run-timing). Capture it once.
|
|
199
|
+
const returned = (await commandSpec.handler({ ...spec.opts, _args: spec.positionals }, ctx));
|
|
200
|
+
return {
|
|
201
|
+
kind: 'result',
|
|
202
|
+
value: toResult(commandSpec.output, acc, returned?.session, returned),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
// @fitness-ignore-next-line detached-promises -- WorkerRpcClient.dispose() returns void (removes the reply listener + clears the pending map, synchronous); the name-based heuristic misfires inside this async fn.
|
|
207
|
+
rpcClient.dispose();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* ADR-0054 M4-F: run a dispatched tool's LIFECYCLE HOOK worker-side and return its
|
|
212
|
+
* plain-data result in `hookResult`. This is how the host gathers an EXTERNAL
|
|
213
|
+
* tool's `collectReportData` / `sessionReplay` data WITHOUT executing the
|
|
214
|
+
* untrusted runtime in the kernel process. The hook runs against the worker's own
|
|
215
|
+
* re-bootstrapped scope (`currentScope()`), exactly the contract the in-host path
|
|
216
|
+
* gives a bundled tool — just inside the isolation boundary. The host owns the
|
|
217
|
+
* merge/render/replay-emit (privileged effect). A throw propagates to
|
|
218
|
+
* {@link runToolCommandWorker}'s catch → structured failure; the host survives.
|
|
219
|
+
*
|
|
220
|
+
* The hook's runtime is resolved from the re-bootstrapped registry (the worker
|
|
221
|
+
* `initialize()` does NOT run for a hook-mode dispatch — hooks read data; an
|
|
222
|
+
* external tool that needs `initialize` for its report/replay should run it in
|
|
223
|
+
* the hook body, which is OUT of M4-F's first-party scope).
|
|
224
|
+
*/
|
|
225
|
+
async function runLoadedHook(tool, spec) {
|
|
226
|
+
const scope = currentScope();
|
|
227
|
+
if (scope === undefined) {
|
|
228
|
+
return errorMessage('tool command worker: no scope is entered for the hook run (bootstrap did not run)', 'runtime-load-failed');
|
|
229
|
+
}
|
|
230
|
+
const hooks = resolveToolHooks(tool);
|
|
231
|
+
// `collectReportData(scope)` takes the tool-facing ToolScope view; the worker
|
|
232
|
+
// RunScope IS a ToolScope (it extends it), so pass it directly — it returns a
|
|
233
|
+
// plain-data Record<string, unknown>. `sessionReplay` rebuilds the
|
|
234
|
+
// ToolSessionReplay from the stored row (`hookArg` is the serialized
|
|
235
|
+
// ToolSessionRecord the host read from the datastore).
|
|
236
|
+
const hookResult = spec.hook === 'collectReportData'
|
|
237
|
+
? await hooks.collectReportData?.(scope)
|
|
238
|
+
: hooks.sessionReplay?.replaySession(spec.hookArg);
|
|
239
|
+
return {
|
|
240
|
+
kind: 'result',
|
|
241
|
+
// `output` is required on the result; the host never replays output for a
|
|
242
|
+
// hook-mode dispatch (it reads `hookResult`), so a benign default suffices.
|
|
243
|
+
value: { output: 'command-result', ...(hookResult === undefined ? {} : { hookResult }) },
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The testable core: produce the {@link DispatchWorkerMessage} the worker would
|
|
248
|
+
* post, without touching `process.send`. Never throws — every failure becomes a
|
|
249
|
+
* structured `error` message (the supervisor rejects on it). Must run inside an
|
|
250
|
+
* entered scope (the bootstrap enters it for the real subcommand; unit tests wrap
|
|
251
|
+
* it in `runWithScope`).
|
|
252
|
+
*/
|
|
253
|
+
export async function runToolCommandWorker(specPath) {
|
|
254
|
+
const spec = readSpec(specPath);
|
|
255
|
+
if ('kind' in spec)
|
|
256
|
+
return spec; // bad-spec error message
|
|
257
|
+
try {
|
|
258
|
+
return await runLoadedCommand(spec);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
return errorMessage(error instanceof Error ? error.message : String(error), classifyThrow(error), error instanceof Error ? error.stack : undefined);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Run one external tool command headless in this worker and post the slim
|
|
266
|
+
* {@link ToolCommandResult} (or a structured `error`) over IPC. Never throws to
|
|
267
|
+
* the caller — every failure becomes an `error` IPC message so the supervisor
|
|
268
|
+
* rejects cleanly. This is the host CommandSpec handler's body.
|
|
269
|
+
*/
|
|
270
|
+
export async function executeToolCommandWorker(specPath) {
|
|
271
|
+
// @fitness-ignore-next-line detached-promises -- the promise IS awaited; `send(...)` is a synchronous void IPC post of the already-resolved value. The name-based heuristic misfires on `send(await ...)`.
|
|
272
|
+
send(await runToolCommandWorker(specPath));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* `__tool-command-worker <specPath>` — the [internal] host subcommand the
|
|
276
|
+
* dispatch supervisor forks. Mirrors `graphRunWorkerCommandSpec`: `raw-stream`
|
|
277
|
+
* (it owns its own IPC output surface), `scope: 'project'` (the full bootstrap
|
|
278
|
+
* runs first), `visibility: 'internal'`. The supervisor passes `--cwd` so the
|
|
279
|
+
* bootstrap targets the right project. The handler ignores the host `ctx` it is
|
|
280
|
+
* given (the worker builds its OWN context shim over the bootstrapped scope) and
|
|
281
|
+
* posts the result over the IPC channel.
|
|
282
|
+
*/
|
|
283
|
+
export const toolCommandWorkerCommandSpec = defineCommand({
|
|
284
|
+
name: '__tool-command-worker',
|
|
285
|
+
visibility: 'internal',
|
|
286
|
+
description: '[internal] Run one external tool command headless in a forked worker and stream the result over IPC (forked by the ADR-0054 dispatch supervisor)',
|
|
287
|
+
// The supervisor passes `--cwd`; bootstrap uses it to resolve the project.
|
|
288
|
+
commonFlags: ['cwd'],
|
|
289
|
+
args: [{ name: 'specPath', description: 'Path to the JSON tool-command worker spec file' }],
|
|
290
|
+
scope: 'project',
|
|
291
|
+
output: 'raw-stream',
|
|
292
|
+
rawStreamReason: 'worker-ipc',
|
|
293
|
+
handler: async (rawOpts) => {
|
|
294
|
+
const specPath = rawOpts._args?.[0] ?? '';
|
|
295
|
+
await executeToolCommandWorker(specPath);
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
//# sourceMappingURL=tool-command-worker-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-command-worker-entry.js","sourceRoot":"","sources":["../../src/bootstrap/tool-command-worker-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,GAOjB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAerE,qFAAqF;AACrF,SAAS,IAAI,CAAC,GAA0B;IACtC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,IAA2B;IAC9C,MAAM,KAAK,GAAG,YAAY,EAAE,EAAE,KAAK,CAAC;IACpC,MAAM,IAAI,GACR,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9F,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,8BAA8B,IAAI,CAAC,MAAM,0CAA0C;YACjF,2EAA2E,CAC9E,CAAC;QACD,GAAyD,CAAC,YAAY,GAAG,qBAAqB,CAAC;QAChG,MAAM,GAAG,CAAC;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