opensip-cli 0.1.11 → 0.1.13
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/artifact-seams.d.ts +7 -0
- package/dist/bootstrap/artifact-seams.d.ts.map +1 -0
- package/dist/bootstrap/artifact-seams.js +53 -0
- package/dist/bootstrap/artifact-seams.js.map +1 -0
- package/dist/bootstrap/atomic-artifact-write.d.ts +19 -0
- package/dist/bootstrap/atomic-artifact-write.d.ts.map +1 -0
- package/dist/bootstrap/atomic-artifact-write.js +68 -0
- package/dist/bootstrap/atomic-artifact-write.js.map +1 -0
- package/dist/bootstrap/baseline-seams.d.ts.map +1 -1
- package/dist/bootstrap/baseline-seams.js +79 -27
- package/dist/bootstrap/baseline-seams.js.map +1 -1
- package/dist/bootstrap/build-external-worker-child-env.d.ts +25 -0
- package/dist/bootstrap/build-external-worker-child-env.d.ts.map +1 -0
- package/dist/bootstrap/build-external-worker-child-env.js +71 -0
- package/dist/bootstrap/build-external-worker-child-env.js.map +1 -0
- package/dist/bootstrap/build-per-run-scope.js +1 -1
- package/dist/bootstrap/build-per-run-scope.js.map +1 -1
- package/dist/bootstrap/build-targets.d.ts.map +1 -1
- package/dist/bootstrap/build-targets.js +2 -7
- package/dist/bootstrap/build-targets.js.map +1 -1
- package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/config-and-capabilities.js +15 -101
- package/dist/bootstrap/config-and-capabilities.js.map +1 -1
- package/dist/bootstrap/config-declarations.d.ts +23 -0
- package/dist/bootstrap/config-declarations.d.ts.map +1 -0
- package/dist/bootstrap/config-declarations.js +73 -0
- package/dist/bootstrap/config-declarations.js.map +1 -0
- package/dist/bootstrap/deliver-envelope.d.ts +4 -1
- package/dist/bootstrap/deliver-envelope.d.ts.map +1 -1
- package/dist/bootstrap/deliver-envelope.js +12 -5
- package/dist/bootstrap/deliver-envelope.js.map +1 -1
- package/dist/bootstrap/dispatch-fork-core.d.ts +1 -1
- package/dist/bootstrap/dispatch-fork-core.d.ts.map +1 -1
- package/dist/bootstrap/dispatch-fork-core.js +73 -75
- package/dist/bootstrap/dispatch-fork-core.js.map +1 -1
- package/dist/bootstrap/dispatch-host-rpc-handler.d.ts.map +1 -1
- package/dist/bootstrap/dispatch-host-rpc-handler.js +4 -0
- package/dist/bootstrap/dispatch-host-rpc-handler.js.map +1 -1
- package/dist/bootstrap/dispatch-replay-result.d.ts.map +1 -1
- package/dist/bootstrap/dispatch-replay-result.js +3 -0
- package/dist/bootstrap/dispatch-replay-result.js.map +1 -1
- package/dist/bootstrap/load-tool-capabilities.d.ts.map +1 -1
- package/dist/bootstrap/load-tool-capabilities.js +34 -3
- package/dist/bootstrap/load-tool-capabilities.js.map +1 -1
- package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
- package/dist/bootstrap/register-tools-discovery.js +2 -0
- package/dist/bootstrap/register-tools-discovery.js.map +1 -1
- package/dist/bootstrap/report-failure.d.ts +28 -0
- package/dist/bootstrap/report-failure.d.ts.map +1 -0
- package/dist/bootstrap/report-failure.js +135 -0
- package/dist/bootstrap/report-failure.js.map +1 -0
- package/dist/bootstrap/run-plane.d.ts.map +1 -1
- package/dist/bootstrap/run-plane.js +1 -0
- package/dist/bootstrap/run-plane.js.map +1 -1
- package/dist/bootstrap/scope-access.d.ts +1 -1
- package/dist/bootstrap/scope-access.d.ts.map +1 -1
- package/dist/bootstrap/scope-access.js +7 -2
- package/dist/bootstrap/scope-access.js.map +1 -1
- package/dist/bootstrap/state-lock-policy.d.ts +19 -0
- package/dist/bootstrap/state-lock-policy.d.ts.map +1 -0
- package/dist/bootstrap/state-lock-policy.js +86 -0
- package/dist/bootstrap/state-lock-policy.js.map +1 -0
- package/dist/bootstrap/synthesize-external-tool.d.ts.map +1 -1
- package/dist/bootstrap/synthesize-external-tool.js +11 -1
- package/dist/bootstrap/synthesize-external-tool.js.map +1 -1
- package/dist/bootstrap/tool-command-dispatch-types.d.ts +23 -2
- package/dist/bootstrap/tool-command-dispatch-types.d.ts.map +1 -1
- package/dist/bootstrap/tool-command-worker-context.d.ts +4 -3
- package/dist/bootstrap/tool-command-worker-context.d.ts.map +1 -1
- package/dist/bootstrap/tool-command-worker-context.js +28 -4
- package/dist/bootstrap/tool-command-worker-context.js.map +1 -1
- package/dist/bootstrap/tool-command-worker-entry.d.ts.map +1 -1
- package/dist/bootstrap/tool-command-worker-entry.js +38 -31
- package/dist/bootstrap/tool-command-worker-entry.js.map +1 -1
- package/dist/bootstrap/tool-command-worker-result.d.ts +25 -0
- package/dist/bootstrap/tool-command-worker-result.d.ts.map +1 -0
- package/dist/bootstrap/tool-command-worker-result.js +60 -0
- package/dist/bootstrap/tool-command-worker-result.js.map +1 -0
- package/dist/bootstrap/tool-trust.d.ts +12 -0
- package/dist/bootstrap/tool-trust.d.ts.map +1 -1
- package/dist/bootstrap/tool-trust.js +29 -5
- package/dist/bootstrap/tool-trust.js.map +1 -1
- package/dist/cli-context.d.ts.map +1 -1
- package/dist/cli-context.js +22 -3
- package/dist/cli-context.js.map +1 -1
- package/dist/commands/agent-catalog.d.ts +8 -7
- package/dist/commands/agent-catalog.d.ts.map +1 -1
- package/dist/commands/agent-catalog.js +108 -60
- package/dist/commands/agent-catalog.js.map +1 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +1 -0
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/config.d.ts +22 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +135 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/host-command-specs.d.ts.map +1 -1
- package/dist/commands/host-command-specs.js +8 -4
- package/dist/commands/host-command-specs.js.map +1 -1
- package/dist/commands/host-subcommand-config.d.ts +7 -0
- package/dist/commands/host-subcommand-config.d.ts.map +1 -0
- package/dist/commands/host-subcommand-config.js +75 -0
- package/dist/commands/host-subcommand-config.js.map +1 -0
- package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
- package/dist/commands/host-subcommand-groups.js +7 -1
- package/dist/commands/host-subcommand-groups.js.map +1 -1
- package/dist/commands/host-subcommand-plugins.d.ts.map +1 -1
- package/dist/commands/host-subcommand-plugins.js +11 -13
- package/dist/commands/host-subcommand-plugins.js.map +1 -1
- package/dist/commands/host-subcommand-sessions.d.ts.map +1 -1
- package/dist/commands/host-subcommand-sessions.js +3 -3
- package/dist/commands/host-subcommand-sessions.js.map +1 -1
- package/dist/commands/init/language-detection.d.ts.map +1 -1
- package/dist/commands/init/language-detection.js +3 -2
- package/dist/commands/init/language-detection.js.map +1 -1
- package/dist/commands/init/scaffold-writer.d.ts.map +1 -1
- package/dist/commands/init/scaffold-writer.js +0 -1
- package/dist/commands/init/scaffold-writer.js.map +1 -1
- package/dist/commands/init.d.ts +5 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +5 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mount-command-spec.d.ts +3 -1
- package/dist/commands/mount-command-spec.d.ts.map +1 -1
- package/dist/commands/mount-command-spec.js +27 -4
- package/dist/commands/mount-command-spec.js.map +1 -1
- package/dist/commands/plugin/config-edit.d.ts.map +1 -1
- package/dist/commands/plugin/config-edit.js +0 -1
- package/dist/commands/plugin/config-edit.js.map +1 -1
- package/dist/commands/plugin/host-dir.d.ts.map +1 -1
- package/dist/commands/plugin/host-dir.js +0 -1
- package/dist/commands/plugin/host-dir.js.map +1 -1
- package/dist/commands/shared.d.ts +5 -1
- package/dist/commands/shared.d.ts.map +1 -1
- package/dist/commands/tools/create-template-writer.d.ts +16 -0
- package/dist/commands/tools/create-template-writer.d.ts.map +1 -0
- package/dist/commands/tools/create-template-writer.js +39 -0
- package/dist/commands/tools/create-template-writer.js.map +1 -0
- package/dist/commands/tools/create-templates.d.ts +19 -0
- package/dist/commands/tools/create-templates.d.ts.map +1 -0
- package/dist/commands/tools/create-templates.js +228 -0
- package/dist/commands/tools/create-templates.js.map +1 -0
- package/dist/commands/tools/create.d.ts +4 -1
- package/dist/commands/tools/create.d.ts.map +1 -1
- package/dist/commands/tools/create.js +35 -50
- package/dist/commands/tools/create.js.map +1 -1
- package/dist/commands/tools/index.d.ts.map +1 -1
- package/dist/commands/tools/index.js +8 -0
- package/dist/commands/tools/index.js.map +1 -1
- package/dist/commands/tools/install.d.ts.map +1 -1
- package/dist/commands/tools/install.js +14 -1
- package/dist/commands/tools/install.js.map +1 -1
- package/dist/commands/tools/validate.d.ts.map +1 -1
- package/dist/commands/tools/validate.js +46 -5
- package/dist/commands/tools/validate.js.map +1 -1
- package/dist/commands/uninstall/targets.d.ts +1 -1
- package/dist/commands/uninstall/targets.d.ts.map +1 -1
- package/dist/commands/uninstall/targets.js +6 -14
- package/dist/commands/uninstall/targets.js.map +1 -1
- package/dist/env/host-env-specs.d.ts.map +1 -1
- package/dist/env/host-env-specs.js +63 -4
- package/dist/env/host-env-specs.js.map +1 -1
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/error-handler.js +28 -6
- package/dist/error-handler.js.map +1 -1
- package/dist/format-bytes.d.ts +2 -0
- package/dist/format-bytes.d.ts.map +1 -0
- package/dist/format-bytes.js +10 -0
- package/dist/format-bytes.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/report-compose.d.ts.map +1 -1
- package/dist/report-compose.js +21 -3
- package/dist/report-compose.js.map +1 -1
- package/dist/session-replay-registry.d.ts.map +1 -1
- package/dist/session-replay-registry.js +0 -1
- package/dist/session-replay-registry.js.map +1 -1
- package/dist/ui/result-to-view.d.ts.map +1 -1
- package/dist/ui/result-to-view.js +10 -1
- package/dist/ui/result-to-view.js.map +1 -1
- package/dist/ui/views/misc-views.d.ts +13 -0
- package/dist/ui/views/misc-views.d.ts.map +1 -1
- package/dist/ui/views/misc-views.js +54 -10
- package/dist/ui/views/misc-views.js.map +1 -1
- package/dist/ui/views/tools-views.d.ts.map +1 -1
- package/dist/ui/views/tools-views.js +8 -7
- package/dist/ui/views/tools-views.js.map +1 -1
- package/dist/update-notifier.d.ts +3 -0
- package/dist/update-notifier.d.ts.map +1 -1
- package/dist/update-notifier.js +3 -0
- package/dist/update-notifier.js.map +1 -1
- package/dist/update-state.d.ts.map +1 -1
- package/dist/update-state.js +0 -1
- package/dist/update-state.js.map +1 -1
- package/package.json +33 -33
|
@@ -26,88 +26,10 @@
|
|
|
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,
|
|
30
|
-
import { ConfigurationError, logger, readYamlFileOrThrow, resolveToolHooks, registerCapabilityDomainsFromManifest, } from '@opensip-cli/core';
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
function isPlainObject(value) {
|
|
34
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
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.
|
|
40
|
-
*/
|
|
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) {
|
|
66
|
-
const declarations = [];
|
|
67
|
-
for (const tool of tools.list()) {
|
|
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
|
-
});
|
|
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").
|
|
85
|
-
}
|
|
86
|
-
return declarations;
|
|
87
|
-
}
|
|
88
|
-
function addPluginConfigKey(keys, key, kind) {
|
|
89
|
-
if (key === undefined)
|
|
90
|
-
return;
|
|
91
|
-
const existing = keys.get(key);
|
|
92
|
-
if (existing !== undefined && existing !== kind) {
|
|
93
|
-
throw new ConfigurationError(`Plugin config key '${key}' is declared with conflicting value kinds (${existing}, ${kind}).`, { code: 'CONFIGURATION_ERROR', namespace: 'plugins' });
|
|
94
|
-
}
|
|
95
|
-
keys.set(key, kind);
|
|
96
|
-
}
|
|
97
|
-
function collectPluginConfigKeys(manifests) {
|
|
98
|
-
const keys = new Map();
|
|
99
|
-
for (const manifest of manifests) {
|
|
100
|
-
for (const capability of manifest.capabilities ?? []) {
|
|
101
|
-
const configKeys = capability.discovery?.configKeys;
|
|
102
|
-
if (configKeys === undefined)
|
|
103
|
-
continue;
|
|
104
|
-
addPluginConfigKey(keys, configKeys.packages, 'packages');
|
|
105
|
-
addPluginConfigKey(keys, configKeys.autoDiscover, 'autoDiscover');
|
|
106
|
-
addPluginConfigKey(keys, configKeys.scopes, 'scopes');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return [...keys.entries()].map(([key, kind]) => ({ key, kind }));
|
|
110
|
-
}
|
|
29
|
+
import { analyzeNamespaceClaims, composeConfigSchema, partitionUnclaimedNamespaces, resolveConfig, validateConfigDocument, } from '@opensip-cli/config';
|
|
30
|
+
import { ConfigurationError, isPlainRecord, logger, readYamlFileOrThrow, resolveToolHooks, registerCapabilityDomainsFromManifest, } from '@opensip-cli/core';
|
|
31
|
+
import { buildConfigDeclarations } from './config-declarations.js';
|
|
32
|
+
import { shouldRunHookInHost } from './tool-provenance.js';
|
|
111
33
|
/**
|
|
112
34
|
* Project the validated document's per-namespace blocks into the `file`
|
|
113
35
|
* precedence source (`namespace -> { key -> value }`). Only the declared
|
|
@@ -116,11 +38,11 @@ function collectPluginConfigKeys(manifests) {
|
|
|
116
38
|
*/
|
|
117
39
|
function fileBlocksFor(declarations, validated) {
|
|
118
40
|
const file = {};
|
|
119
|
-
if (!
|
|
41
|
+
if (!isPlainRecord(validated))
|
|
120
42
|
return file;
|
|
121
43
|
for (const decl of declarations) {
|
|
122
44
|
const block = validated[decl.namespace];
|
|
123
|
-
if (
|
|
45
|
+
if (isPlainRecord(block))
|
|
124
46
|
file[decl.namespace] = block;
|
|
125
47
|
}
|
|
126
48
|
return file;
|
|
@@ -150,25 +72,18 @@ export function composeAndValidateToolConfig(args) {
|
|
|
150
72
|
// host-side (trusted), external tools validate from their serializable
|
|
151
73
|
// manifest descriptor (coarse, NO Zod import); the deep Zod pass runs in the
|
|
152
74
|
// worker.
|
|
153
|
-
const
|
|
75
|
+
const { declarations, hasToolNamespaces } = buildConfigDeclarations({
|
|
76
|
+
tools,
|
|
77
|
+
manifests,
|
|
78
|
+
provenance,
|
|
79
|
+
});
|
|
154
80
|
// A run with no tools that declare config (e.g. a project-agnostic context)
|
|
155
81
|
// carries no toolConfig — tools fall back to their in-tool defaults. The host
|
|
156
82
|
// document-level blocks (cli/dashboard/schemaVersion) only need composing when
|
|
157
83
|
// there is a tool dispatch to validate the document for; the real CLI always
|
|
158
84
|
// registers fit/graph/sim, so they are always composed in practice.
|
|
159
|
-
if (
|
|
85
|
+
if (!hasToolNamespaces)
|
|
160
86
|
return { config: undefined, document: {} };
|
|
161
|
-
// Compose the host document-level declarations (cli/dashboard/schemaVersion,
|
|
162
|
-
// and from Phase 1 the targeting blocks) BESIDE the decorated tool
|
|
163
|
-
// declarations, so the whole document — not just the tool namespaces —
|
|
164
|
-
// validates STRICT through the one composed schema (ADR-0023, the launch seam).
|
|
165
|
-
// Gate keys are added only to tool namespaces; host blocks stay strict.
|
|
166
|
-
const declarations = [
|
|
167
|
-
...hostConfigDeclarations({
|
|
168
|
-
pluginConfigKeys: collectPluginConfigKeys(manifests),
|
|
169
|
-
}),
|
|
170
|
-
...toolDeclarations,
|
|
171
|
-
];
|
|
172
87
|
// When a configPath was resolved by the project context (i.e. a real
|
|
173
88
|
// opensip-cli.config.yml or a package.json pointer), read it *strictly*.
|
|
174
89
|
// Malformed YAML or unreadable file must fail before any dispatch (a
|
|
@@ -176,11 +91,10 @@ export function composeAndValidateToolConfig(args) {
|
|
|
176
91
|
// When no configPath, fall back to defaults only (permissive discovery
|
|
177
92
|
// paths elsewhere still use the non-throwing reader).
|
|
178
93
|
const raw = configPath === undefined ? {} : readYamlFileOrThrow(configPath, { loader: 'project-config' });
|
|
179
|
-
const document = isPlainObject(raw) ? raw : {};
|
|
180
94
|
const schema = composeConfigSchema(declarations);
|
|
181
95
|
// STRICT gate: a typo in any tool namespace throws ConfigurationError here,
|
|
182
96
|
// before dispatch. The CLI error boundary maps it to CONFIGURATION_ERROR.
|
|
183
|
-
const validated = validateConfigDocument(schema,
|
|
97
|
+
const validated = validateConfigDocument(schema, raw);
|
|
184
98
|
// ADR-0043: the composer TOLERATES unclaimed top-level namespaces (the
|
|
185
99
|
// uninstalled-tool forward-compat contract) — but never silently. Two cases:
|
|
186
100
|
// - the namespace equals a LOADED tool's id → that tool declares no
|
|
@@ -219,13 +133,13 @@ function reportUnclaimedNamespaces(args) {
|
|
|
219
133
|
if (report.unclaimed.length === 0)
|
|
220
134
|
return;
|
|
221
135
|
const loadedToolNames = new Set(args.tools.list().map((t) => t.metadata.name ?? t.metadata.id));
|
|
222
|
-
const toolBugs = report
|
|
136
|
+
const { toolBugs, benign } = partitionUnclaimedNamespaces(report, loadedToolNames);
|
|
223
137
|
if (toolBugs.length > 0) {
|
|
224
138
|
const names = toolBugs.map((u) => `'${u.namespace}'`).join(', ');
|
|
225
139
|
throw new ConfigurationError(`Config declares ${names} but the loaded tool(s) of the same id contribute no Tool.config — ` +
|
|
226
140
|
`the block can never apply. Remove the block or fix the tool's config contribution. (ADR-0043)`, { code: 'CONFIGURATION_ERROR' });
|
|
227
141
|
}
|
|
228
|
-
for (const u of
|
|
142
|
+
for (const u of benign) {
|
|
229
143
|
const didYouMean = u.suggestion === undefined ? '' : ` — did you mean '${u.suggestion}:'?`;
|
|
230
144
|
logger.warn({
|
|
231
145
|
evt: 'cli.config.unclaimed_namespace',
|
|
@@ -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,
|
|
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,4BAA4B,EAC5B,aAAa,EACb,sBAAsB,GAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,gBAAgB,EAKhB,qCAAqC,GACtC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;GAKG;AACH,SAAS,aAAa,CACpB,YAA8C,EAC9C,SAAkB;IAElB,MAAM,IAAI,GAA4C,EAAE,CAAC;IACzD,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,aAAa,CAAC,KAAK,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAO5C;IAIC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAC/F,wEAAwE;IACxE,uEAAuE;IACvE,6EAA6E;IAC7E,UAAU;IACV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;YACzB,OAAO,EACL,qBAAqB,CAAC,CAAC,SAAS,uCAAuC,UAAU,GAAG;gBACpF,0DAA0D;YAC5D,MAAM,EAAE,8CAA8C;SACvD,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAKtC;IACC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IAE7D,yEAAyE;IACzE,2DAA2D;IAC3D,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,qCAAqC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,8EAA8E;IAC9E,8EAA8E;IAC9E,4EAA4E;IAC5E,+EAA+E;IAC/E,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAChC,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC;YAAE,SAAS;QACrD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC;QAC/D,IAAI,UAAU,KAAK,SAAS;YAAE,SAAS;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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config-declarations — shared config declaration assembly for the dispatcher
|
|
3
|
+
* and `opensip config validate|schema` operator commands.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `config-and-capabilities.ts` so schema composition uses the
|
|
6
|
+
* same declaration set without duplicating provenance/manifest folding logic.
|
|
7
|
+
*/
|
|
8
|
+
import { type ToolConfigDeclaration } from '@opensip-cli/config';
|
|
9
|
+
import { type ToolPluginManifest, type ToolProvenance, type ToolRegistry } from '@opensip-cli/core';
|
|
10
|
+
export interface ConfigDeclarationBundle {
|
|
11
|
+
readonly declarations: readonly ToolConfigDeclaration[];
|
|
12
|
+
/** True when at least one registered tool contributed a config namespace. */
|
|
13
|
+
readonly hasToolNamespaces: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the ordered declaration array the dispatcher and config commands use.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildConfigDeclarations(args: {
|
|
19
|
+
readonly tools: ToolRegistry;
|
|
20
|
+
readonly manifests?: readonly ToolPluginManifest[];
|
|
21
|
+
readonly provenance?: readonly ToolProvenance[];
|
|
22
|
+
}): ConfigDeclarationBundle;
|
|
23
|
+
//# sourceMappingURL=config-declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-declarations.d.ts","sourceRoot":"","sources":["../../src/bootstrap/config-declarations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAuE3B,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACxD,6EAA6E;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,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;CACjD,GAAG,uBAAuB,CAY1B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config-declarations — shared config declaration assembly for the dispatcher
|
|
3
|
+
* and `opensip config validate|schema` operator commands.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `config-and-capabilities.ts` so schema composition uses the
|
|
6
|
+
* same declaration set without duplicating provenance/manifest folding logic.
|
|
7
|
+
*/
|
|
8
|
+
import { decorateToolConfigDeclarationsWithGateKeys, hostConfigDeclarations, jsonSchemaObjectToZod, } from '@opensip-cli/config';
|
|
9
|
+
import { ConfigurationError, resolveToolHooks, } from '@opensip-cli/core';
|
|
10
|
+
import { provenanceSourceFor } from './tool-provenance.js';
|
|
11
|
+
function manifestDescriptorFor(tool, manifests) {
|
|
12
|
+
const manifest = manifests.find((m) => m.stableId !== undefined && m.stableId === tool.metadata.id) ??
|
|
13
|
+
manifests.find((m) => m.id === tool.metadata.name);
|
|
14
|
+
return manifest?.config;
|
|
15
|
+
}
|
|
16
|
+
function collectDeclarations(tools, provenance, manifests) {
|
|
17
|
+
const declarations = [];
|
|
18
|
+
for (const tool of tools.list()) {
|
|
19
|
+
if (provenanceSourceFor(tool, provenance) === 'bundled') {
|
|
20
|
+
const config = resolveToolHooks(tool).config;
|
|
21
|
+
if (config !== undefined) {
|
|
22
|
+
declarations.push(config);
|
|
23
|
+
}
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const descriptor = manifestDescriptorFor(tool, manifests);
|
|
27
|
+
if (descriptor !== undefined) {
|
|
28
|
+
declarations.push({
|
|
29
|
+
namespace: descriptor.namespace,
|
|
30
|
+
schema: jsonSchemaObjectToZod(descriptor.schema),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return declarations;
|
|
35
|
+
}
|
|
36
|
+
function addPluginConfigKey(keys, key, kind) {
|
|
37
|
+
if (key === undefined)
|
|
38
|
+
return;
|
|
39
|
+
const existing = keys.get(key);
|
|
40
|
+
if (existing !== undefined && existing !== kind) {
|
|
41
|
+
throw new ConfigurationError(`Plugin config key '${key}' is declared with conflicting value kinds (${existing}, ${kind}).`, { code: 'CONFIGURATION_ERROR', namespace: 'plugins' });
|
|
42
|
+
}
|
|
43
|
+
keys.set(key, kind);
|
|
44
|
+
}
|
|
45
|
+
function collectPluginConfigKeys(manifests) {
|
|
46
|
+
const keys = new Map();
|
|
47
|
+
for (const manifest of manifests) {
|
|
48
|
+
for (const capability of manifest.capabilities ?? []) {
|
|
49
|
+
const configKeys = capability.discovery?.configKeys;
|
|
50
|
+
if (configKeys === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
addPluginConfigKey(keys, configKeys.packages, 'packages');
|
|
53
|
+
addPluginConfigKey(keys, configKeys.autoDiscover, 'autoDiscover');
|
|
54
|
+
addPluginConfigKey(keys, configKeys.scopes, 'scopes');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [...keys.entries()].map(([key, kind]) => ({ key, kind }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build the ordered declaration array the dispatcher and config commands use.
|
|
61
|
+
*/
|
|
62
|
+
export function buildConfigDeclarations(args) {
|
|
63
|
+
const { tools, manifests = [], provenance = [] } = args;
|
|
64
|
+
const toolDeclarations = decorateToolConfigDeclarationsWithGateKeys(collectDeclarations(tools, provenance, manifests));
|
|
65
|
+
const declarations = [
|
|
66
|
+
...hostConfigDeclarations({
|
|
67
|
+
pluginConfigKeys: collectPluginConfigKeys(manifests),
|
|
68
|
+
}),
|
|
69
|
+
...toolDeclarations,
|
|
70
|
+
];
|
|
71
|
+
return { declarations, hasToolNamespaces: toolDeclarations.length > 0 };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=config-declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-declarations.js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AAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACnE,CAAC;AAQD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAIvC;IACC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;IACxD,MAAM,gBAAgB,GAAG,0CAA0C,CACjE,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAClD,CAAC;IACF,MAAM,YAAY,GAAG;QACnB,GAAG,sBAAsB,CAAC;YACxB,gBAAgB,EAAE,uBAAuB,CAAC,SAAS,CAAC;SACrD,CAAC;QACF,GAAG,gBAAgB;KACpB,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* engines return envelopes, and the composition root owns formatting,
|
|
25
25
|
* delivery, and report-upload exit-code policy.
|
|
26
26
|
*/
|
|
27
|
+
import type { ArtifactWriteContext } from './atomic-artifact-write.js';
|
|
27
28
|
import type { SignalEnvelope } from '@opensip-cli/contracts';
|
|
28
29
|
import type { Logger, RepoIdentity, SignalBatch, SignalDeliveryResult } from '@opensip-cli/core';
|
|
29
30
|
/** Options the root supplies when delivering a tool's envelope. */
|
|
@@ -83,5 +84,7 @@ export declare function deliverEnvelope(envelope: SignalEnvelope, opts: DeliverE
|
|
|
83
84
|
* `@opensip-cli/output` itself. The formatter is pure; this function owns
|
|
84
85
|
* the effect (fs write).
|
|
85
86
|
*/
|
|
86
|
-
export declare function writeEnvelopeSarif(envelope: SignalEnvelope, path: string
|
|
87
|
+
export declare function writeEnvelopeSarif(envelope: SignalEnvelope, path: string, artifactCtx?: Partial<ArtifactWriteContext> & {
|
|
88
|
+
readonly logger?: ArtifactWriteContext['logger'];
|
|
89
|
+
}): Promise<void>;
|
|
87
90
|
//# sourceMappingURL=deliver-envelope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deliver-envelope.d.ts","sourceRoot":"","sources":["../../src/bootstrap/deliver-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAcH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIjG,mEAAmE;AACnE,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,CAS/F;AAmED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C;CACnC;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,WAAW,CAS/F;AAmED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,aAAa,EAAE,OAAO,EACtB,SAAS,EAAE,OAAO,GACjB,MAAM,GAAG,SAAS,CAMpB;AAyBD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,qBAAqB,CAAC,CA2EhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CAClD,GACA,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
* engines return envelopes, and the composition root owns formatting,
|
|
25
25
|
* delivery, and report-upload exit-code policy.
|
|
26
26
|
*/
|
|
27
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
28
|
-
import { dirname } from 'node:path';
|
|
29
27
|
import { EXIT_CODES } from '@opensip-cli/contracts';
|
|
30
28
|
import { buildSignalBatch, currentScope, logger as defaultLogger } from '@opensip-cli/core';
|
|
31
29
|
import { formatSignalSarif, postChunked, resolveRepoIdentity, } from '@opensip-cli/output';
|
|
30
|
+
import { writeArtifactAtomically } from './atomic-artifact-write.js';
|
|
31
|
+
import { resolveStateLockPolicy } from './state-lock-policy.js';
|
|
32
32
|
const MODULE_TAG = 'cli:bootstrap';
|
|
33
33
|
/**
|
|
34
34
|
* Map a {@link SignalEnvelope} to the cloud {@link SignalBatch} wire shape:
|
|
@@ -201,9 +201,16 @@ export async function deliverEnvelope(envelope, opts) {
|
|
|
201
201
|
* `@opensip-cli/output` itself. The formatter is pure; this function owns
|
|
202
202
|
* the effect (fs write).
|
|
203
203
|
*/
|
|
204
|
-
export
|
|
204
|
+
export function writeEnvelopeSarif(envelope, path, artifactCtx) {
|
|
205
205
|
const sarif = formatSignalSarif(envelope);
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
const ctx = {
|
|
207
|
+
policy: artifactCtx?.policy ?? resolveStateLockPolicy(),
|
|
208
|
+
logger: artifactCtx?.logger ?? defaultLogger,
|
|
209
|
+
runId: artifactCtx?.runId,
|
|
210
|
+
command: artifactCtx?.command,
|
|
211
|
+
cwdBasename: artifactCtx?.cwdBasename,
|
|
212
|
+
};
|
|
213
|
+
writeArtifactAtomically(path, sarif, ctx);
|
|
214
|
+
return Promise.resolve();
|
|
208
215
|
}
|
|
209
216
|
//# sourceMappingURL=deliver-envelope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deliver-envelope.js","sourceRoot":"","sources":["../../src/bootstrap/deliver-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deliver-envelope.js","sourceRoot":"","sources":["../../src/bootstrap/deliver-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,mBAAmB,GAEpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE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AAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAwB,EACxB,IAAY,EACZ,WAEC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAyB;QAChC,MAAM,EAAE,WAAW,EAAE,MAAM,IAAI,sBAAsB,EAAE;QACvD,MAAM,EAAE,WAAW,EAAE,MAAM,IAAI,aAAa;QAC5C,KAAK,EAAE,WAAW,EAAE,KAAK;QACzB,OAAO,EAAE,WAAW,EAAE,OAAO;QAC7B,WAAW,EAAE,WAAW,EAAE,WAAW;KACtC,CAAC;IACF,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -44,5 +44,5 @@ export declare function runWorkerSpec(args: {
|
|
|
44
44
|
readonly timeoutMs?: number;
|
|
45
45
|
}): Promise<ToolCommandResult>;
|
|
46
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;
|
|
47
|
+
export declare function dispatchError(spec: ToolCommandWorkerSpec, message: string, failureClass: string, stderrTail?: string): ToolError;
|
|
48
48
|
//# sourceMappingURL=dispatch-fork-core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-fork-core.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-fork-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,
|
|
1
|
+
{"version":3,"file":"dispatch-fork-core.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-fork-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,EAOL,KAAK,SAAS,EACd,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,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;AAqKD,wFAAwF;AACxF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,SAAS,CAqBX"}
|
|
@@ -21,14 +21,13 @@
|
|
|
21
21
|
* structured parent-side {@link ToolError} — the host never crashes and external
|
|
22
22
|
* runtime NEVER falls back to in-host execution (ADR-0054 trust tier).
|
|
23
23
|
*/
|
|
24
|
-
import { fork } from 'node:child_process';
|
|
25
24
|
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
26
25
|
import { tmpdir } from 'node:os';
|
|
27
26
|
import { join } from 'node:path';
|
|
28
|
-
import { ConfigurationError, currentScope, SystemError, } from '@opensip-cli/core';
|
|
27
|
+
import { ConfigurationError, currentScope, currentTraceparent, forkAndSettle, getWorkerLimits, SystemError, } from '@opensip-cli/core';
|
|
28
|
+
import { buildExternalWorkerChildEnv } from './build-external-worker-child-env.js';
|
|
29
29
|
import { BOOTSTRAP_MODULE } from './constants.js';
|
|
30
30
|
import { handleHostRpc } from './dispatch-host-rpc-handler.js';
|
|
31
|
-
import { IN_TOOL_WORKER_ENV } from './tool-provenance.js';
|
|
32
31
|
/** Default supervisor wall-clock timeout for one forked worker run (ms). */
|
|
33
32
|
export const DEFAULT_DISPATCH_TIMEOUT_MS = 120_000;
|
|
34
33
|
/** The internal worker subcommand the supervisor forks the CLI binary into. */
|
|
@@ -70,81 +69,79 @@ export async function runWorkerSpec(args) {
|
|
|
70
69
|
function forkAndAwait({ cliScript, specPath, cwd, spec, timeoutMs, ctx, }) {
|
|
71
70
|
return new Promise((resolve, reject) => {
|
|
72
71
|
const runId = currentScope()?.runId;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const childEnv = { ...process.env, [IN_TOOL_WORKER_ENV]: '1' };
|
|
80
|
-
if (runId !== undefined && runId.length > 0)
|
|
81
|
-
childEnv.OPENSIP_RUN_ID = runId;
|
|
82
|
-
// Fork the CLI binary into the internal worker subcommand. The full bootstrap
|
|
83
|
-
// (preAction) re-builds the per-run scope in the worker before the worker
|
|
84
|
-
// handler runs.
|
|
85
|
-
//
|
|
86
|
-
// `cwd` is set on the CHILD PROCESS (not only passed as `--cwd`): the CLI
|
|
87
|
-
// bootstrap anchors TOOL DISCOVERY on `process.cwd()`, while the `--cwd` flag
|
|
88
|
-
// only steers later PROJECT resolution in the pre-action hook. Pinning the
|
|
89
|
-
// child cwd to the same project keeps discovery and project resolution
|
|
90
|
-
// coherent — the worker bootstraps exactly as an in-project invocation would.
|
|
91
|
-
const child = fork(cliScript, [WORKER_SUBCOMMAND, specPath, '--cwd', cwd], {
|
|
72
|
+
const traceparent = currentTraceparent();
|
|
73
|
+
let inFlightRpc = 0;
|
|
74
|
+
let totalRpc = 0;
|
|
75
|
+
const handle = forkAndSettle({
|
|
76
|
+
command: cliScript,
|
|
77
|
+
argv: [WORKER_SUBCOMMAND, specPath, '--cwd', cwd],
|
|
92
78
|
cwd,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
79
|
+
timeoutMs,
|
|
80
|
+
enableHeartbeat: true,
|
|
81
|
+
enableSigintCancellation: true,
|
|
82
|
+
buildChildEnv: (parentEnv) => buildExternalWorkerChildEnv({ parentEnv, runId, traceparent }),
|
|
83
|
+
onMessage: (msg) => {
|
|
84
|
+
const typed = msg;
|
|
85
|
+
if (typed.kind === 'progress') {
|
|
86
|
+
serveRpc(typed.event);
|
|
87
|
+
}
|
|
88
|
+
else if (typed.kind === 'result') {
|
|
89
|
+
handle.done(() => {
|
|
90
|
+
resolve(typed.value);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else if (typed.kind === 'error') {
|
|
94
|
+
handle.done(() => {
|
|
95
|
+
reject(workerErrorToToolError(spec, typed, handle.getStderrTail()));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
onLimitFailure: (failureClass, detail) => {
|
|
100
|
+
reject(dispatchError(spec, detail === undefined
|
|
101
|
+
? `worker failed: ${failureClass}`
|
|
102
|
+
: `worker failed: ${failureClass} (${detail})`, failureClass, handle.getStderrTail()));
|
|
103
|
+
},
|
|
104
|
+
}, { runId });
|
|
117
105
|
const serveRpc = (request) => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (msg.kind === 'progress') {
|
|
125
|
-
serveRpc(msg.event);
|
|
126
|
-
}
|
|
127
|
-
else if (msg.kind === 'result') {
|
|
128
|
-
done(() => {
|
|
129
|
-
resolve(msg.value);
|
|
106
|
+
const workerLimits = getWorkerLimits();
|
|
107
|
+
totalRpc += 1;
|
|
108
|
+
if (totalRpc > workerLimits.maxTotalRpc) {
|
|
109
|
+
handle.killTree('SIGKILL');
|
|
110
|
+
handle.done(() => {
|
|
111
|
+
reject(dispatchError(spec, 'host-RPC upcall flood (total cap exceeded)', 'rpc_flood'));
|
|
130
112
|
});
|
|
113
|
+
return;
|
|
131
114
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
115
|
+
if (inFlightRpc >= workerLimits.maxConcurrentRpc) {
|
|
116
|
+
handle.killTree('SIGKILL');
|
|
117
|
+
handle.done(() => {
|
|
118
|
+
reject(dispatchError(spec, 'host-RPC upcall flood (concurrency cap exceeded)', 'rpc_flood'));
|
|
135
119
|
});
|
|
120
|
+
return;
|
|
136
121
|
}
|
|
137
|
-
|
|
122
|
+
inFlightRpc += 1;
|
|
123
|
+
void handleHostRpc(request, ctx)
|
|
124
|
+
.then((reply) => {
|
|
125
|
+
inFlightRpc -= 1;
|
|
126
|
+
if (!handle.isSettled())
|
|
127
|
+
sendRpcReply(handle.child, reply, spec);
|
|
128
|
+
})
|
|
129
|
+
.catch(() => {
|
|
130
|
+
inFlightRpc -= 1;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
138
133
|
/* v8 ignore next 16 -- defensive isolation-safety arm: `child.on('error')` fires only on a node-executable SPAWN failure (ENOENT on the runtime, EACCES), which is only reachable via impractical fault injection — node always exists in a normal run, so a bad worker entry surfaces via `child.on('exit')` (the covered sibling arm) instead. ADR-0054 trust tier: an external tool that cannot fork is a HARD error, NEVER an in-host fallback (that would run untrusted code in the kernel process). A future explicitly-named developer override (OPENSIP_CLI_DANGEROUSLY_RUN_EXTERNAL_IN_HOST) is reserved, not built. */
|
|
139
|
-
child.on('error', (err) => {
|
|
140
|
-
done(() => {
|
|
134
|
+
handle.child.on('error', (err) => {
|
|
135
|
+
handle.done(() => {
|
|
141
136
|
reject(dispatchError(spec, `cannot isolate external tool '${spec.toolId}' (worker fork failed: ${err.message}); ` +
|
|
142
137
|
'refusing to run it in-process', 'spawn'));
|
|
143
138
|
});
|
|
144
139
|
});
|
|
145
|
-
child.on('exit', (code) => {
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
handle.child.on('exit', (code) => {
|
|
141
|
+
if (handle.isSettled())
|
|
142
|
+
return;
|
|
143
|
+
handle.done(() => {
|
|
144
|
+
reject(dispatchError(spec, `worker exited (code ${code ?? 'null'}) before producing a result`, 'exit_nonzero', handle.getStderrTail()));
|
|
148
145
|
});
|
|
149
146
|
});
|
|
150
147
|
});
|
|
@@ -180,7 +177,7 @@ function specLabel(spec) {
|
|
|
180
177
|
return spec.commandName ?? spec.hook ?? 'unknown';
|
|
181
178
|
}
|
|
182
179
|
/** Build a structured supervisor-side dispatch error, logged with its failure class. */
|
|
183
|
-
export function dispatchError(spec, message, failureClass) {
|
|
180
|
+
export function dispatchError(spec, message, failureClass, stderrTail) {
|
|
184
181
|
const label = specLabel(spec);
|
|
185
182
|
currentScope()?.logger.error({
|
|
186
183
|
evt: 'cli.tool.dispatch_failed',
|
|
@@ -189,20 +186,21 @@ export function dispatchError(spec, message, failureClass) {
|
|
|
189
186
|
command: label,
|
|
190
187
|
failureClass,
|
|
191
188
|
});
|
|
192
|
-
// ADR-0054 M4-E single config-error contract: a worker DEEP-pass config failure
|
|
193
|
-
// (`config-invalid`) maps to the SAME typed error + exit code (ConfigurationError
|
|
194
|
-
// → CONFIGURATION_ERROR, exit 2) the host COARSE pass throws, so the user sees a
|
|
195
|
-
// consistent "Invalid configuration …" regardless of which pass caught it.
|
|
196
189
|
if (failureClass === 'config-invalid') {
|
|
197
|
-
return new ConfigurationError(message, {
|
|
190
|
+
return new ConfigurationError(message, {
|
|
191
|
+
code: 'CONFIGURATION_ERROR',
|
|
192
|
+
failureClass,
|
|
193
|
+
stderrTail,
|
|
194
|
+
});
|
|
198
195
|
}
|
|
199
196
|
return new SystemError(`external tool '${spec.toolId}' ${label} failed: ${message}`, {
|
|
200
197
|
code: 'SYSTEM.DISPATCH.WORKER_FAILED',
|
|
201
198
|
failureClass,
|
|
199
|
+
stderrTail,
|
|
202
200
|
});
|
|
203
201
|
}
|
|
204
202
|
/** Convert a worker `error` IPC message into a logged, structured {@link ToolError}. */
|
|
205
|
-
function workerErrorToToolError(spec, msg) {
|
|
206
|
-
return dispatchError(spec, msg.message, msg.failureClass ?? 'ipc_error');
|
|
203
|
+
function workerErrorToToolError(spec, msg, stderrTail) {
|
|
204
|
+
return dispatchError(spec, msg.message, msg.failureClass ?? 'ipc_error', stderrTail);
|
|
207
205
|
}
|
|
208
206
|
//# sourceMappingURL=dispatch-fork-core.js.map
|