opensip-cli 0.1.8 → 0.1.10
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 +208 -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
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* config namespace (see `docs/public/10-concepts/03-modular-monolith.md`); at
|
|
27
27
|
* run time they read the validated namespace off `scope.toolConfig`.
|
|
28
28
|
*/
|
|
29
|
-
import { type CapabilityRegistry, type ResolvedToolConfig, type ToolPluginManifest, type ToolRegistry } from '@opensip-cli/core';
|
|
29
|
+
import { type CapabilityRegistry, type ResolvedToolConfig, type ToolPluginManifest, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
|
|
30
30
|
/**
|
|
31
31
|
* Compose + strict-validate the config document, then resolve precedence.
|
|
32
32
|
*
|
|
@@ -49,6 +49,7 @@ import { type CapabilityRegistry, type ResolvedToolConfig, type ToolPluginManife
|
|
|
49
49
|
export declare function composeAndValidateToolConfig(args: {
|
|
50
50
|
readonly tools: ToolRegistry;
|
|
51
51
|
readonly manifests?: readonly ToolPluginManifest[];
|
|
52
|
+
readonly provenance?: readonly ToolProvenance[];
|
|
52
53
|
readonly configPath: string | undefined;
|
|
53
54
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
54
55
|
}): {
|
|
@@ -58,19 +59,33 @@ export declare function composeAndValidateToolConfig(args: {
|
|
|
58
59
|
/**
|
|
59
60
|
* Construct + populate the per-run capability registry (§5.3, Phase 4).
|
|
60
61
|
*
|
|
61
|
-
*
|
|
62
|
-
* a deferred placeholder registrar)
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* Step 1 registers every admitted manifest's declared capability domains (each
|
|
63
|
+
* with a deferred placeholder registrar) — pure MANIFEST data: the manifest is
|
|
64
|
+
* serializable, the placeholder is a host-owned deferred stub (it throws if a
|
|
65
|
+
* domain is driven before a real registrar is installed); NO external runtime
|
|
66
|
+
* code runs here. Step 2 replaces each placeholder with the owning tool's REAL
|
|
67
|
+
* registrar from `tool.capabilityRegistrars`.
|
|
68
|
+
*
|
|
69
|
+
* ADR-0054 M4-F: step 2 is gated on {@link shouldRunHookInHost}. For an EXTERNAL
|
|
70
|
+
* tool in the HOST process the real registrar is NOT installed host-side (reading
|
|
71
|
+
* `tool.capabilityRegistrars` + invoking the registrar runs untrusted runtime
|
|
72
|
+
* code — the load-time hole the ADR rejects); the external domain keeps its
|
|
73
|
+
* deferred placeholder in the host registry. The real registrar is installed
|
|
74
|
+
* worker-side: the dispatch worker re-runs this SAME wiring with the host-skip
|
|
75
|
+
* INACTIVE, so the dispatched external tool's registrar IS installed there (the
|
|
76
|
+
* isolation boundary). Bundled tools install in-host exactly as before. A
|
|
77
|
+
* registrar whose domain id was not declared in any manifest is skipped
|
|
78
|
+
* (hasDomain false) — the host never invents a domain a tool didn't declare.
|
|
66
79
|
*
|
|
67
80
|
* @param tools The per-run tool registry (supplies each tool's real registrars).
|
|
68
81
|
* @param manifests The admitted manifests (supply the declared domains).
|
|
82
|
+
* @param provenance The per-run provenance (drives the M4-F host/external gate).
|
|
69
83
|
* @returns The populated registry, ready to attach to `scope.capabilities`.
|
|
70
84
|
*/
|
|
71
85
|
export declare function wireCapabilityRegistry(args: {
|
|
72
86
|
readonly tools: ToolRegistry;
|
|
73
87
|
readonly manifests: readonly ToolPluginManifest[];
|
|
74
88
|
readonly registry: CapabilityRegistry;
|
|
89
|
+
readonly provenance?: readonly ToolProvenance[];
|
|
75
90
|
}): CapabilityRegistry;
|
|
76
91
|
//# sourceMappingURL=config-and-capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-and-capabilities.d.ts","sourceRoot":"","sources":["../../src/bootstrap/config-and-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"config-and-capabilities.d.ts","sourceRoot":"","sources":["../../src/bootstrap/config-and-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAaH,OAAO,EACL,KAAK,kBAAkB,EAKvB,KAAK,kBAAkB,EAEvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AA0H3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CAC5D,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CA8DlF;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CACjD,GAAG,kBAAkB,CAyBrB"}
|
|
@@ -26,26 +26,62 @@
|
|
|
26
26
|
* config namespace (see `docs/public/10-concepts/03-modular-monolith.md`); at
|
|
27
27
|
* run time they read the validated namespace off `scope.toolConfig`.
|
|
28
28
|
*/
|
|
29
|
-
import { analyzeNamespaceClaims, composeConfigSchema, decorateToolConfigDeclarationsWithGateKeys, hostConfigDeclarations, resolveConfig, validateConfigDocument, } from '@opensip-cli/config';
|
|
29
|
+
import { analyzeNamespaceClaims, composeConfigSchema, decorateToolConfigDeclarationsWithGateKeys, hostConfigDeclarations, jsonSchemaObjectToZod, resolveConfig, validateConfigDocument, } from '@opensip-cli/config';
|
|
30
30
|
import { ConfigurationError, logger, readYamlFileOrThrow, resolveToolHooks, registerCapabilityDomainsFromManifest, } from '@opensip-cli/core';
|
|
31
|
+
import { provenanceSourceFor, shouldRunHookInHost } from './tool-provenance.js';
|
|
31
32
|
/** A plain-object guard that treats arrays and null as non-objects. */
|
|
32
33
|
function isPlainObject(value) {
|
|
33
34
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* kernel boundary, a Zod schema at the config layer), so narrowing it here —
|
|
40
|
-
* the composition root, which DOES import `@opensip-cli/config` — is sound.
|
|
37
|
+
* Find the manifest config descriptor for a tool, matching by stable id then by
|
|
38
|
+
* the manifest's human id. Returns `undefined` when no admitted manifest for the
|
|
39
|
+
* tool declares a `config` descriptor.
|
|
41
40
|
*/
|
|
42
|
-
function
|
|
41
|
+
function manifestDescriptorFor(tool, manifests) {
|
|
42
|
+
const manifest = manifests.find((m) => m.stableId !== undefined && m.stableId === tool.metadata.id) ??
|
|
43
|
+
manifests.find((m) => m.id === tool.metadata.name);
|
|
44
|
+
return manifest?.config;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Collect the contributed config declarations from the registered tools —
|
|
48
|
+
* provenance-aware (ADR-0054 M4-E Config two-pass).
|
|
49
|
+
*
|
|
50
|
+
* - **Bundled** (trusted computing base) → fold the tool's runtime Zod
|
|
51
|
+
* `config` declaration host-side, exactly as before. A bundled tool's
|
|
52
|
+
* `config` slot is the kernel-side `ToolConfigContribution` carrier,
|
|
53
|
+
* structurally a `ToolConfigDeclaration` (schema `unknown` at the kernel
|
|
54
|
+
* boundary, a Zod schema at the config layer), so narrowing it here — the
|
|
55
|
+
* composition root, which DOES import `@opensip-cli/config` — is sound.
|
|
56
|
+
* - **External** (installed / project-local / user-global) → NEVER import the
|
|
57
|
+
* tool's Zod (executable code — the ADR-0054 load-time hole). Instead derive
|
|
58
|
+
* a COARSE declaration from the tool's serializable manifest descriptor
|
|
59
|
+
* ({@link ToolConfigManifestDescriptor}); the host validates the namespace's
|
|
60
|
+
* top-level shape as pure data. An external tool that ships NO descriptor
|
|
61
|
+
* contributes no declaration — its namespace (if present) passes through the
|
|
62
|
+
* document catchall (rule-2) and ALL of its validation defers to the worker
|
|
63
|
+
* deep pass.
|
|
64
|
+
*/
|
|
65
|
+
function collectDeclarations(tools, provenance, manifests) {
|
|
43
66
|
const declarations = [];
|
|
44
67
|
for (const tool of tools.list()) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
if (provenanceSourceFor(tool, provenance) === 'bundled') {
|
|
69
|
+
const config = resolveToolHooks(tool).config;
|
|
70
|
+
if (config !== undefined) {
|
|
71
|
+
declarations.push(config);
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// External: coarse, manifest-descriptor-derived schema only — no Zod import.
|
|
76
|
+
const descriptor = manifestDescriptorFor(tool, manifests);
|
|
77
|
+
if (descriptor !== undefined) {
|
|
78
|
+
declarations.push({
|
|
79
|
+
namespace: descriptor.namespace,
|
|
80
|
+
schema: jsonSchemaObjectToZod(descriptor.schema),
|
|
81
|
+
});
|
|
48
82
|
}
|
|
83
|
+
// No descriptor → defer entirely to the worker deep pass (catchall passes
|
|
84
|
+
// any present namespace block through; do NOT host-import its Zod to "help").
|
|
49
85
|
}
|
|
50
86
|
return declarations;
|
|
51
87
|
}
|
|
@@ -109,8 +145,12 @@ function fileBlocksFor(declarations, validated) {
|
|
|
109
145
|
* strict validation in ANY tool namespace.
|
|
110
146
|
*/
|
|
111
147
|
export function composeAndValidateToolConfig(args) {
|
|
112
|
-
const { tools, configPath, env, manifests = [] } = args;
|
|
113
|
-
|
|
148
|
+
const { tools, configPath, env, manifests = [], provenance = [] } = args;
|
|
149
|
+
// ADR-0054 M4-E: provenance-aware fold — bundled tools' Zod is composed
|
|
150
|
+
// host-side (trusted), external tools validate from their serializable
|
|
151
|
+
// manifest descriptor (coarse, NO Zod import); the deep Zod pass runs in the
|
|
152
|
+
// worker.
|
|
153
|
+
const toolDeclarations = decorateToolConfigDeclarationsWithGateKeys(collectDeclarations(tools, provenance, manifests));
|
|
114
154
|
// A run with no tools that declare config (e.g. a project-agnostic context)
|
|
115
155
|
// carries no toolConfig — tools fall back to their in-tool defaults. The host
|
|
116
156
|
// document-level blocks (cli/dashboard/schemaVersion) only need composing when
|
|
@@ -193,27 +233,43 @@ function reportUnclaimedNamespaces(args) {
|
|
|
193
233
|
/**
|
|
194
234
|
* Construct + populate the per-run capability registry (§5.3, Phase 4).
|
|
195
235
|
*
|
|
196
|
-
*
|
|
197
|
-
* a deferred placeholder registrar)
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
236
|
+
* Step 1 registers every admitted manifest's declared capability domains (each
|
|
237
|
+
* with a deferred placeholder registrar) — pure MANIFEST data: the manifest is
|
|
238
|
+
* serializable, the placeholder is a host-owned deferred stub (it throws if a
|
|
239
|
+
* domain is driven before a real registrar is installed); NO external runtime
|
|
240
|
+
* code runs here. Step 2 replaces each placeholder with the owning tool's REAL
|
|
241
|
+
* registrar from `tool.capabilityRegistrars`.
|
|
242
|
+
*
|
|
243
|
+
* ADR-0054 M4-F: step 2 is gated on {@link shouldRunHookInHost}. For an EXTERNAL
|
|
244
|
+
* tool in the HOST process the real registrar is NOT installed host-side (reading
|
|
245
|
+
* `tool.capabilityRegistrars` + invoking the registrar runs untrusted runtime
|
|
246
|
+
* code — the load-time hole the ADR rejects); the external domain keeps its
|
|
247
|
+
* deferred placeholder in the host registry. The real registrar is installed
|
|
248
|
+
* worker-side: the dispatch worker re-runs this SAME wiring with the host-skip
|
|
249
|
+
* INACTIVE, so the dispatched external tool's registrar IS installed there (the
|
|
250
|
+
* isolation boundary). Bundled tools install in-host exactly as before. A
|
|
251
|
+
* registrar whose domain id was not declared in any manifest is skipped
|
|
252
|
+
* (hasDomain false) — the host never invents a domain a tool didn't declare.
|
|
201
253
|
*
|
|
202
254
|
* @param tools The per-run tool registry (supplies each tool's real registrars).
|
|
203
255
|
* @param manifests The admitted manifests (supply the declared domains).
|
|
256
|
+
* @param provenance The per-run provenance (drives the M4-F host/external gate).
|
|
204
257
|
* @returns The populated registry, ready to attach to `scope.capabilities`.
|
|
205
258
|
*/
|
|
206
259
|
export function wireCapabilityRegistry(args) {
|
|
207
|
-
const { tools, manifests, registry } = args;
|
|
208
|
-
// 1. Register every manifest-declared domain with a deferred placeholder
|
|
260
|
+
const { tools, manifests, registry, provenance = [] } = args;
|
|
261
|
+
// 1. Register every manifest-declared domain with a deferred placeholder
|
|
262
|
+
// (manifest data only — no external runtime code runs).
|
|
209
263
|
for (const manifest of manifests) {
|
|
210
264
|
registerCapabilityDomainsFromManifest(manifest, registry);
|
|
211
265
|
}
|
|
212
|
-
// 2. Replace each placeholder with the owning tool's real registrar
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
//
|
|
266
|
+
// 2. Replace each placeholder with the owning tool's real registrar — IN-HOST
|
|
267
|
+
// only for tools whose hooks may run in the host (bundled, or — inside the
|
|
268
|
+
// dispatch worker — the dispatched external tool). External tools in the
|
|
269
|
+
// host keep the deferred placeholder; their registrar installs worker-side.
|
|
216
270
|
for (const tool of tools.list()) {
|
|
271
|
+
if (!shouldRunHookInHost(tool, provenance))
|
|
272
|
+
continue;
|
|
217
273
|
const registrars = resolveToolHooks(tool).capabilityRegistrars;
|
|
218
274
|
if (registrars === undefined)
|
|
219
275
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-and-capabilities.js","sourceRoot":"","sources":["../../src/bootstrap/config-and-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,0CAA0C,EAC1C,sBAAs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AS;QACvC,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/D,IAAI,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-external-tool-command — the HOST supervisor for the out-of-process
|
|
3
|
+
* external tool COMMAND dispatch plane (ADR-0054, increments M4-C / M4-D / M4-E).
|
|
4
|
+
*
|
|
5
|
+
* For an EXTERNAL-provenance tool command (installed / project-local /
|
|
6
|
+
* user-global), the host forks the {@link executeToolCommandWorker} entry
|
|
7
|
+
* instead of importing + running the handler in-process. The worker imports the
|
|
8
|
+
* untrusted runtime and runs the handler; this supervisor:
|
|
9
|
+
*
|
|
10
|
+
* 1. marshals the minimal serializable {@link ToolCommandWorkerSpec} to a temp
|
|
11
|
+
* file and forks the worker entry via the shared {@link runWorkerSpec}
|
|
12
|
+
* fork/IPC core, which turns a child throw / `process.exit` / crash /
|
|
13
|
+
* premature-exit / fork-failure into a structured parent-side rejection,
|
|
14
|
+
* enforces the wall-clock timeout, serves the worker's host-RPC upcalls
|
|
15
|
+
* against the REAL host {@link ToolCliContext}, and inherits run correlation
|
|
16
|
+
* through the child env;
|
|
17
|
+
* 2. on success, replays the slim {@link ToolCommandResult} through the REAL
|
|
18
|
+
* host seams (`render` / `emitEnvelope` / `emitJson` / `emitRaw` /
|
|
19
|
+
* `emitError` / `setExitCode`) so the output contract stays byte-identical
|
|
20
|
+
* to the in-process path.
|
|
21
|
+
*
|
|
22
|
+
* Bundled first-party tools never reach here — they stay in-process (the trusted
|
|
23
|
+
* computing base). External tools have NO in-process fallback by trust tier
|
|
24
|
+
* (ADR-0054): a fork failure is a hard, structured error, not a silent in-host
|
|
25
|
+
* run.
|
|
26
|
+
*/
|
|
27
|
+
import { type ToolProvenance } from '@opensip-cli/core';
|
|
28
|
+
import { type DispatchHostCtx } from './dispatch-replay-result.js';
|
|
29
|
+
export interface DispatchExternalToolCommandArgs {
|
|
30
|
+
/** The external tool's provenance (source must NOT be `'bundled'`). */
|
|
31
|
+
readonly provenance: ToolProvenance;
|
|
32
|
+
/** Which command (by `CommandSpec.name`) to run in the worker. */
|
|
33
|
+
readonly commandName: string;
|
|
34
|
+
/** Parsed opts for this invocation (serializable). */
|
|
35
|
+
readonly opts: Record<string, unknown>;
|
|
36
|
+
/** Trailing positionals (`_args`) for this invocation (serializable). */
|
|
37
|
+
readonly positionals: readonly unknown[];
|
|
38
|
+
/**
|
|
39
|
+
* The tool's RAW config namespace block for the WORKER deep pass (ADR-0054
|
|
40
|
+
* M4-E Config two-pass). Forwarded into the spec so the worker runs the tool's
|
|
41
|
+
* real Zod after load. `undefined` when there is no block to validate.
|
|
42
|
+
*/
|
|
43
|
+
readonly config?: unknown;
|
|
44
|
+
/** The real host context the supervisor replays the worker result through. */
|
|
45
|
+
readonly ctx: DispatchHostCtx;
|
|
46
|
+
/** Override the wall-clock timeout (tests use a short one). */
|
|
47
|
+
readonly timeoutMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Override the CLI entry script the supervisor forks (defaults to
|
|
50
|
+
* `process.argv[1]`). The worker runs as `node <cliScript> __tool-command-worker
|
|
51
|
+
* <specPath> --cwd <cwd>`, going through the full bootstrap so the dispatched
|
|
52
|
+
* tool's scope (config/registries/subscope) is worker-local (ADR-0054 M4-E).
|
|
53
|
+
* Tests point this at the built CLI dist entry.
|
|
54
|
+
*/
|
|
55
|
+
readonly cliScript?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Fork the worker, await its slim {@link ToolCommandResult}, and replay it
|
|
59
|
+
* through the host seams. A worker fault (throw / `process.exit` / crash /
|
|
60
|
+
* timeout / fork failure) becomes a structured {@link ToolError} — the host never
|
|
61
|
+
* crashes.
|
|
62
|
+
*
|
|
63
|
+
* @throws {SystemError} when the external command's provenance is `'bundled'`
|
|
64
|
+
* (a misuse — bundled tools run in-process), or when the worker fails.
|
|
65
|
+
*/
|
|
66
|
+
export declare function dispatchExternalToolCommand(args: DispatchExternalToolCommandArgs): Promise<void>;
|
|
67
|
+
//# sourceMappingURL=dispatch-external-tool-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-external-tool-command.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-external-tool-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAA6B,KAAK,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AAOpG,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAIjF,MAAM,WAAW,+BAA+B;IAC9C,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-external-tool-command — the HOST supervisor for the out-of-process
|
|
3
|
+
* external tool COMMAND dispatch plane (ADR-0054, increments M4-C / M4-D / M4-E).
|
|
4
|
+
*
|
|
5
|
+
* For an EXTERNAL-provenance tool command (installed / project-local /
|
|
6
|
+
* user-global), the host forks the {@link executeToolCommandWorker} entry
|
|
7
|
+
* instead of importing + running the handler in-process. The worker imports the
|
|
8
|
+
* untrusted runtime and runs the handler; this supervisor:
|
|
9
|
+
*
|
|
10
|
+
* 1. marshals the minimal serializable {@link ToolCommandWorkerSpec} to a temp
|
|
11
|
+
* file and forks the worker entry via the shared {@link runWorkerSpec}
|
|
12
|
+
* fork/IPC core, which turns a child throw / `process.exit` / crash /
|
|
13
|
+
* premature-exit / fork-failure into a structured parent-side rejection,
|
|
14
|
+
* enforces the wall-clock timeout, serves the worker's host-RPC upcalls
|
|
15
|
+
* against the REAL host {@link ToolCliContext}, and inherits run correlation
|
|
16
|
+
* through the child env;
|
|
17
|
+
* 2. on success, replays the slim {@link ToolCommandResult} through the REAL
|
|
18
|
+
* host seams (`render` / `emitEnvelope` / `emitJson` / `emitRaw` /
|
|
19
|
+
* `emitError` / `setExitCode`) so the output contract stays byte-identical
|
|
20
|
+
* to the in-process path.
|
|
21
|
+
*
|
|
22
|
+
* Bundled first-party tools never reach here — they stay in-process (the trusted
|
|
23
|
+
* computing base). External tools have NO in-process fallback by trust tier
|
|
24
|
+
* (ADR-0054): a fork failure is a hard, structured error, not a silent in-host
|
|
25
|
+
* run.
|
|
26
|
+
*/
|
|
27
|
+
import { currentScope, SystemError } from '@opensip-cli/core';
|
|
28
|
+
import { DEFAULT_DISPATCH_TIMEOUT_MS, requirePackageDir, runWorkerSpec, } from './dispatch-fork-core.js';
|
|
29
|
+
import { replayResult } from './dispatch-replay-result.js';
|
|
30
|
+
/**
|
|
31
|
+
* Fork the worker, await its slim {@link ToolCommandResult}, and replay it
|
|
32
|
+
* through the host seams. A worker fault (throw / `process.exit` / crash /
|
|
33
|
+
* timeout / fork failure) becomes a structured {@link ToolError} — the host never
|
|
34
|
+
* crashes.
|
|
35
|
+
*
|
|
36
|
+
* @throws {SystemError} when the external command's provenance is `'bundled'`
|
|
37
|
+
* (a misuse — bundled tools run in-process), or when the worker fails.
|
|
38
|
+
*/
|
|
39
|
+
export async function dispatchExternalToolCommand(args) {
|
|
40
|
+
if (args.provenance.source === 'bundled') {
|
|
41
|
+
throw new SystemError('dispatchExternalToolCommand called for a bundled tool; bundled tools run in-process.', { code: 'SYSTEM.DISPATCH.BUNDLED_MISUSE' });
|
|
42
|
+
}
|
|
43
|
+
// Lifecycle observability: the out-of-process dispatch is a major run phase, so
|
|
44
|
+
// emit a structured event onto the scope DiagnosticsBus (the same bus the
|
|
45
|
+
// in-process action emits `execute` events onto). A `--json` consumer reads
|
|
46
|
+
// `outcome.diagnostics.events` for context even without full OTEL.
|
|
47
|
+
const diagnostics = currentScope()?.diagnostics;
|
|
48
|
+
diagnostics?.event('execute', 'debug', `dispatching external tool '${args.provenance.id}' command '${args.commandName}' out-of-process`);
|
|
49
|
+
const result = await runCommandWorker(args);
|
|
50
|
+
diagnostics?.event('execute', 'debug', `external tool '${args.provenance.id}' command '${args.commandName}' worker resolved`);
|
|
51
|
+
await replayResult(result, args.ctx, {
|
|
52
|
+
commandName: args.commandName,
|
|
53
|
+
opts: { ...args.opts, _args: args.positionals },
|
|
54
|
+
positionals: args.positionals,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Marshal the command spec + run it through the shared fork/IPC core. */
|
|
58
|
+
function runCommandWorker(args) {
|
|
59
|
+
const spec = {
|
|
60
|
+
toolId: args.provenance.id,
|
|
61
|
+
toolPackageDir: requirePackageDir(args.provenance),
|
|
62
|
+
source: args.provenance.source,
|
|
63
|
+
commandName: args.commandName,
|
|
64
|
+
opts: args.opts,
|
|
65
|
+
positionals: args.positionals,
|
|
66
|
+
// ADR-0054 M4-E: forward the coarse-validated config block so the worker can
|
|
67
|
+
// run the tool's real Zod deep pass after load. Omitted when no block exists.
|
|
68
|
+
...(args.config === undefined ? {} : { config: args.config }),
|
|
69
|
+
};
|
|
70
|
+
const cwd = typeof args.opts.cwd === 'string' ? args.opts.cwd : process.cwd();
|
|
71
|
+
return runWorkerSpec({
|
|
72
|
+
spec,
|
|
73
|
+
ctx: args.ctx,
|
|
74
|
+
cwd,
|
|
75
|
+
...(args.cliScript === undefined ? {} : { cliScript: args.cliScript }),
|
|
76
|
+
timeoutMs: args.timeoutMs ?? DEFAULT_DISPATCH_TIMEOUT_MS,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=dispatch-external-tool-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-external-tool-command.js","sourceRoot":"","sources":["../../src/bootstrap/dispatch-external-tool-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAwC,MAAM,mBAAmB,CAAC;AAEpG,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAwB,MAAM,6BAA6B,CAAC;AAiCjF;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,IAAqC;IAErC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,WAAW,CACnB,sFAAsF,EACtF,EAAE,IAAI,EAAE,gCAAgC,EAAE,CAC3C,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,0EAA0E;IAC1E,4EAA4E;IAC5E,mEAAmE;IACnE,MAAM,WAAW,GAAG,YAAY,EAAE,EAAE,WAAW,CAAC;IAChD,WAAW,EAAE,KAAK,C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,GAAG,EAAE,CAAC;IAC9E,OAAO,aAAa,CAAC;QACnB,IAAI;QACJ,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG;QACH,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACtE,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,2BAA2B;KACzD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-external-tool-hook — the HOST supervisor for running an EXTERNAL
|
|
3
|
+
* tool's LIFECYCLE HOOK out-of-process (ADR-0054 M4-F).
|
|
4
|
+
*
|
|
5
|
+
* After M4-F the host never executes an external-provenance tool's lifecycle
|
|
6
|
+
* hooks in-process. Two host-command hooks still need the tool's runtime to
|
|
7
|
+
* produce data: `collectReportData` (the `report` command + report auto-open) and
|
|
8
|
+
* `sessionReplay` (`sessions show`). For an external tool the host forks the SAME
|
|
9
|
+
* `__tool-command-worker` subcommand the command dispatch uses — but in HOOK mode
|
|
10
|
+
* (the spec sets `hook` instead of `commandName`). The worker imports the
|
|
11
|
+
* untrusted runtime, runs the named hook against its own re-bootstrapped scope,
|
|
12
|
+
* and returns the hook's plain-data result in {@link ToolCommandResult.hookResult}.
|
|
13
|
+
*
|
|
14
|
+
* The host gets the data WITHOUT executing the external runtime in the kernel
|
|
15
|
+
* process. A fork failure / throw / timeout is a structured {@link ToolError} —
|
|
16
|
+
* the host never crashes and never falls back to in-host execution.
|
|
17
|
+
*/
|
|
18
|
+
import { type ToolProvenance } from '@opensip-cli/core';
|
|
19
|
+
import { type DispatchHostCtx } from './dispatch-replay-result.js';
|
|
20
|
+
import type { ToolCommandWorkerSpec } from './tool-command-dispatch-types.js';
|
|
21
|
+
export interface DispatchExternalToolHookArgs {
|
|
22
|
+
/** The external tool's provenance (source must NOT be `'bundled'`). */
|
|
23
|
+
readonly provenance: ToolProvenance;
|
|
24
|
+
/** Which lifecycle hook to run in the worker. */
|
|
25
|
+
readonly hook: NonNullable<ToolCommandWorkerSpec['hook']>;
|
|
26
|
+
/** The serializable argument the hook needs (e.g. the stored session row). */
|
|
27
|
+
readonly hookArg?: unknown;
|
|
28
|
+
/** The project cwd the worker bootstraps against (steers discovery + project). */
|
|
29
|
+
readonly cwd: string;
|
|
30
|
+
/** The real host context the supervisor serves host-RPC upcalls through. */
|
|
31
|
+
readonly ctx: DispatchHostCtx;
|
|
32
|
+
/** Override the wall-clock timeout (tests use a short one). */
|
|
33
|
+
readonly timeoutMs?: number;
|
|
34
|
+
/** Override the CLI entry script the supervisor forks (defaults to argv[1]). */
|
|
35
|
+
readonly cliScript?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run one external tool lifecycle hook in a forked worker and return its
|
|
39
|
+
* plain-data result. A worker fault becomes a structured {@link ToolError} — the
|
|
40
|
+
* host never crashes; external runtime never falls back to in-host execution.
|
|
41
|
+
*
|
|
42
|
+
* @returns The hook's result (`hookResult`) — a `Record<string, unknown>` for
|
|
43
|
+
* `collectReportData`, a `ToolSessionReplay` for `sessionReplay`, or `undefined`
|
|
44
|
+
* when the worker tool declared no such hook.
|
|
45
|
+
*/
|
|
46
|
+
export declare function dispatchExternalToolHook(args: DispatchExternalToolHookArgs): Promise<unknown>;
|
|
47
|
+
//# sourceMappingURL=dispatch-external-tool-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-external-tool-hook.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-external-tool-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAmB,MAAM,mBAAmB,CAAC;AAOzE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E,MAAM,WAAW,4BAA4B;IAC3C,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-external-tool-hook — the HOST supervisor for running an EXTERNAL
|
|
3
|
+
* tool's LIFECYCLE HOOK out-of-process (ADR-0054 M4-F).
|
|
4
|
+
*
|
|
5
|
+
* After M4-F the host never executes an external-provenance tool's lifecycle
|
|
6
|
+
* hooks in-process. Two host-command hooks still need the tool's runtime to
|
|
7
|
+
* produce data: `collectReportData` (the `report` command + report auto-open) and
|
|
8
|
+
* `sessionReplay` (`sessions show`). For an external tool the host forks the SAME
|
|
9
|
+
* `__tool-command-worker` subcommand the command dispatch uses — but in HOOK mode
|
|
10
|
+
* (the spec sets `hook` instead of `commandName`). The worker imports the
|
|
11
|
+
* untrusted runtime, runs the named hook against its own re-bootstrapped scope,
|
|
12
|
+
* and returns the hook's plain-data result in {@link ToolCommandResult.hookResult}.
|
|
13
|
+
*
|
|
14
|
+
* The host gets the data WITHOUT executing the external runtime in the kernel
|
|
15
|
+
* process. A fork failure / throw / timeout is a structured {@link ToolError} —
|
|
16
|
+
* the host never crashes and never falls back to in-host execution.
|
|
17
|
+
*/
|
|
18
|
+
import { DEFAULT_DISPATCH_TIMEOUT_MS, requirePackageDir, runWorkerSpec, } from './dispatch-fork-core.js';
|
|
19
|
+
/**
|
|
20
|
+
* Run one external tool lifecycle hook in a forked worker and return its
|
|
21
|
+
* plain-data result. A worker fault becomes a structured {@link ToolError} — the
|
|
22
|
+
* host never crashes; external runtime never falls back to in-host execution.
|
|
23
|
+
*
|
|
24
|
+
* @returns The hook's result (`hookResult`) — a `Record<string, unknown>` for
|
|
25
|
+
* `collectReportData`, a `ToolSessionReplay` for `sessionReplay`, or `undefined`
|
|
26
|
+
* when the worker tool declared no such hook.
|
|
27
|
+
*/
|
|
28
|
+
export async function dispatchExternalToolHook(args) {
|
|
29
|
+
const spec = {
|
|
30
|
+
toolId: args.provenance.id,
|
|
31
|
+
toolPackageDir: requirePackageDir(args.provenance),
|
|
32
|
+
source: args.provenance.source,
|
|
33
|
+
hook: args.hook,
|
|
34
|
+
// The worker resolves the project cwd from the spec opts (symmetric to the
|
|
35
|
+
// command path). Hook mode carries no Commander opts/positionals.
|
|
36
|
+
opts: { cwd: args.cwd },
|
|
37
|
+
positionals: [],
|
|
38
|
+
...(args.hookArg === undefined ? {} : { hookArg: args.hookArg }),
|
|
39
|
+
};
|
|
40
|
+
const result = await runWorkerSpec({
|
|
41
|
+
spec,
|
|
42
|
+
ctx: args.ctx,
|
|
43
|
+
cwd: args.cwd,
|
|
44
|
+
...(args.cliScript === undefined ? {} : { cliScript: args.cliScript }),
|
|
45
|
+
timeoutMs: args.timeoutMs ?? DEFAULT_DISPATCH_TIMEOUT_MS,
|
|
46
|
+
});
|
|
47
|
+
return result.hookResult;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dispatch-external-tool-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-external-tool-hook.js","sourceRoot":"","sources":["../../src/bootstrap/dispatch-external-tool-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAsBjC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAAkC;IAElC,MAAM,IAAI,GAA0B;QAClC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE;QAC1B,cAAc,EAAE,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC;QAClD,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAwC;QAChE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,2EAA2E;QAC3E,kEAAkE;QAClE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;QACvB,WAAW,EAAE,EAAE;QACf,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;KACjE,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QACjC,IAAI;QACJ,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACtE,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,2BAA2B;KACzD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,UAAU,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch-fork-core — the shared fork + IPC settle + host-RPC supervisor for the
|
|
3
|
+
* ADR-0054 out-of-process external-tool worker (increments M4-C / M4-D / M4-F).
|
|
4
|
+
*
|
|
5
|
+
* Both supervisors fork the SAME internal `__tool-command-worker` subcommand and
|
|
6
|
+
* settle on the SAME `ToolCommandResult` shape:
|
|
7
|
+
* - `dispatch-external-tool-command.ts` runs an external tool's COMMAND;
|
|
8
|
+
* - `dispatch-external-tool-hook.ts` (M4-F) runs an external tool's LIFECYCLE
|
|
9
|
+
* HOOK (`collectReportData` / `sessionReplay`).
|
|
10
|
+
*
|
|
11
|
+
* They differ only in the {@link ToolCommandWorkerSpec} they marshal (a
|
|
12
|
+
* `commandName` vs a `hook`) and how they replay the result. This module owns the
|
|
13
|
+
* common machinery so neither duplicates it: marshal the spec to a temp file,
|
|
14
|
+
* fork the CLI binary as the worker subcommand (full bootstrap re-runs
|
|
15
|
+
* worker-local), enforce a wall-clock timeout, serve mid-run host-RPC upcalls
|
|
16
|
+
* against the REAL host `ToolCliContext`, and resolve the worker's
|
|
17
|
+
* {@link ToolCommandResult} (or reject with a structured {@link ToolError}).
|
|
18
|
+
*
|
|
19
|
+
* The host remains the ONLY process that performs the privileged effect; a worker
|
|
20
|
+
* fault (throw / `process.exit` / crash / timeout / fork failure) becomes a
|
|
21
|
+
* structured parent-side {@link ToolError} — the host never crashes and external
|
|
22
|
+
* runtime NEVER falls back to in-host execution (ADR-0054 trust tier).
|
|
23
|
+
*/
|
|
24
|
+
import { type ToolError, type ToolProvenance } from '@opensip-cli/core';
|
|
25
|
+
import { type DispatchHostCtx } from './dispatch-replay-result.js';
|
|
26
|
+
import type { ToolCommandResult, ToolCommandWorkerSpec } from './tool-command-dispatch-types.js';
|
|
27
|
+
/** Default supervisor wall-clock timeout for one forked worker run (ms). */
|
|
28
|
+
export declare const DEFAULT_DISPATCH_TIMEOUT_MS = 120000;
|
|
29
|
+
/** The internal worker subcommand the supervisor forks the CLI binary into. */
|
|
30
|
+
export declare const WORKER_SUBCOMMAND = "__tool-command-worker";
|
|
31
|
+
/** Resolve the package dir for an external tool, or fail with a structured error. */
|
|
32
|
+
export declare function requirePackageDir(provenance: ToolProvenance): string;
|
|
33
|
+
/**
|
|
34
|
+
* Marshal a worker spec to a temp file, fork the worker, enforce the timeout, and
|
|
35
|
+
* resolve the worker's {@link ToolCommandResult}. The temp dir is always cleaned
|
|
36
|
+
* up. `cliScript` defaults to the running CLI entry; tests point it at the dist
|
|
37
|
+
* entry. `cwd` defaults to the spec's `opts.cwd` (or `process.cwd()`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function runWorkerSpec(args: {
|
|
40
|
+
readonly spec: ToolCommandWorkerSpec;
|
|
41
|
+
readonly ctx: DispatchHostCtx;
|
|
42
|
+
readonly cwd: string;
|
|
43
|
+
readonly cliScript?: string;
|
|
44
|
+
readonly timeoutMs?: number;
|
|
45
|
+
}): Promise<ToolCommandResult>;
|
|
46
|
+
/** Build a structured supervisor-side dispatch error, logged with its failure class. */
|
|
47
|
+
export declare function dispatchError(spec: ToolCommandWorkerSpec, message: string, failureClass: string): ToolError;
|
|
48
|
+
//# sourceMappingURL=dispatch-fork-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-fork-core.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-fork-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EAGV,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAE1C,4EAA4E;AAC5E,eAAO,MAAM,2BAA2B,SAAU,CAAC;AAEnD,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAQzD,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CASpE;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoB7B;AA4JD,wFAAwF;AACxF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,SAAS,CAoBX"}
|