opensip-cli 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/bootstrap/admit-tool-package.d.ts +51 -11
  2. package/dist/bootstrap/admit-tool-package.d.ts.map +1 -1
  3. package/dist/bootstrap/admit-tool-package.js +46 -12
  4. package/dist/bootstrap/admit-tool-package.js.map +1 -1
  5. package/dist/bootstrap/baseline-seams.js +1 -1
  6. package/dist/bootstrap/baseline-seams.js.map +1 -1
  7. package/dist/bootstrap/bind-external-dispatch.d.ts +36 -0
  8. package/dist/bootstrap/bind-external-dispatch.d.ts.map +1 -0
  9. package/dist/bootstrap/bind-external-dispatch.js +81 -0
  10. package/dist/bootstrap/bind-external-dispatch.js.map +1 -0
  11. package/dist/bootstrap/build-command-registration-input.d.ts +13 -2
  12. package/dist/bootstrap/build-command-registration-input.d.ts.map +1 -1
  13. package/dist/bootstrap/build-command-registration-input.js +29 -2
  14. package/dist/bootstrap/build-command-registration-input.js.map +1 -1
  15. package/dist/bootstrap/build-per-run-scope.d.ts.map +1 -1
  16. package/dist/bootstrap/build-per-run-scope.js +19 -2
  17. package/dist/bootstrap/build-per-run-scope.js.map +1 -1
  18. package/dist/bootstrap/config-and-capabilities.d.ts +21 -6
  19. package/dist/bootstrap/config-and-capabilities.d.ts.map +1 -1
  20. package/dist/bootstrap/config-and-capabilities.js +79 -23
  21. package/dist/bootstrap/config-and-capabilities.js.map +1 -1
  22. package/dist/bootstrap/dispatch-external-tool-command.d.ts +67 -0
  23. package/dist/bootstrap/dispatch-external-tool-command.d.ts.map +1 -0
  24. package/dist/bootstrap/dispatch-external-tool-command.js +79 -0
  25. package/dist/bootstrap/dispatch-external-tool-command.js.map +1 -0
  26. package/dist/bootstrap/dispatch-external-tool-hook.d.ts +47 -0
  27. package/dist/bootstrap/dispatch-external-tool-hook.d.ts.map +1 -0
  28. package/dist/bootstrap/dispatch-external-tool-hook.js +49 -0
  29. package/dist/bootstrap/dispatch-external-tool-hook.js.map +1 -0
  30. package/dist/bootstrap/dispatch-fork-core.d.ts +48 -0
  31. package/dist/bootstrap/dispatch-fork-core.d.ts.map +1 -0
  32. package/dist/bootstrap/dispatch-fork-core.js +214 -0
  33. package/dist/bootstrap/dispatch-fork-core.js.map +1 -0
  34. package/dist/bootstrap/dispatch-host-rpc-handler.d.ts +27 -0
  35. package/dist/bootstrap/dispatch-host-rpc-handler.d.ts.map +1 -0
  36. package/dist/bootstrap/dispatch-host-rpc-handler.js +175 -0
  37. package/dist/bootstrap/dispatch-host-rpc-handler.js.map +1 -0
  38. package/dist/bootstrap/dispatch-replay-result.d.ts +51 -0
  39. package/dist/bootstrap/dispatch-replay-result.d.ts.map +1 -0
  40. package/dist/bootstrap/dispatch-replay-result.js +76 -0
  41. package/dist/bootstrap/dispatch-replay-result.js.map +1 -0
  42. package/dist/bootstrap/execute-post-bailout-bootstrap.d.ts.map +1 -1
  43. package/dist/bootstrap/execute-post-bailout-bootstrap.js +3 -1
  44. package/dist/bootstrap/execute-post-bailout-bootstrap.js.map +1 -1
  45. package/dist/bootstrap/owning-tool-init.d.ts +8 -2
  46. package/dist/bootstrap/owning-tool-init.d.ts.map +1 -1
  47. package/dist/bootstrap/owning-tool-init.js +11 -1
  48. package/dist/bootstrap/owning-tool-init.js.map +1 -1
  49. package/dist/bootstrap/register-authored-tools.d.ts +49 -0
  50. package/dist/bootstrap/register-authored-tools.d.ts.map +1 -0
  51. package/dist/bootstrap/register-authored-tools.js +132 -0
  52. package/dist/bootstrap/register-authored-tools.js.map +1 -0
  53. package/dist/bootstrap/register-tools-discovery.d.ts +0 -32
  54. package/dist/bootstrap/register-tools-discovery.d.ts.map +1 -1
  55. package/dist/bootstrap/register-tools-discovery.js +36 -100
  56. package/dist/bootstrap/register-tools-discovery.js.map +1 -1
  57. package/dist/bootstrap/register-tools-mount.d.ts.map +1 -1
  58. package/dist/bootstrap/register-tools-mount.js +20 -44
  59. package/dist/bootstrap/register-tools-mount.js.map +1 -1
  60. package/dist/bootstrap/register-tools.d.ts +2 -1
  61. package/dist/bootstrap/register-tools.d.ts.map +1 -1
  62. package/dist/bootstrap/register-tools.js +2 -1
  63. package/dist/bootstrap/register-tools.js.map +1 -1
  64. package/dist/bootstrap/run-plane.d.ts +11 -0
  65. package/dist/bootstrap/run-plane.d.ts.map +1 -1
  66. package/dist/bootstrap/run-plane.js.map +1 -1
  67. package/dist/bootstrap/synthesize-external-tool.d.ts +45 -0
  68. package/dist/bootstrap/synthesize-external-tool.d.ts.map +1 -0
  69. package/dist/bootstrap/synthesize-external-tool.js +112 -0
  70. package/dist/bootstrap/synthesize-external-tool.js.map +1 -0
  71. package/dist/bootstrap/tool-command-dispatch-types.d.ts +280 -0
  72. package/dist/bootstrap/tool-command-dispatch-types.d.ts.map +1 -0
  73. package/dist/bootstrap/tool-command-dispatch-types.js +34 -0
  74. package/dist/bootstrap/tool-command-dispatch-types.js.map +1 -0
  75. package/dist/bootstrap/tool-command-worker-config-pass.d.ts +24 -0
  76. package/dist/bootstrap/tool-command-worker-config-pass.d.ts.map +1 -0
  77. package/dist/bootstrap/tool-command-worker-config-pass.js +52 -0
  78. package/dist/bootstrap/tool-command-worker-config-pass.js.map +1 -0
  79. package/dist/bootstrap/tool-command-worker-context.d.ts +55 -0
  80. package/dist/bootstrap/tool-command-worker-context.d.ts.map +1 -0
  81. package/dist/bootstrap/tool-command-worker-context.js +163 -0
  82. package/dist/bootstrap/tool-command-worker-context.js.map +1 -0
  83. package/dist/bootstrap/tool-command-worker-entry.d.ts +66 -0
  84. package/dist/bootstrap/tool-command-worker-entry.d.ts.map +1 -0
  85. package/dist/bootstrap/tool-command-worker-entry.js +298 -0
  86. package/dist/bootstrap/tool-command-worker-entry.js.map +1 -0
  87. package/dist/bootstrap/tool-command-worker-rpc.d.ts +53 -0
  88. package/dist/bootstrap/tool-command-worker-rpc.d.ts.map +1 -0
  89. package/dist/bootstrap/tool-command-worker-rpc.js +78 -0
  90. package/dist/bootstrap/tool-command-worker-rpc.js.map +1 -0
  91. package/dist/bootstrap/tool-provenance.d.ts +85 -0
  92. package/dist/bootstrap/tool-provenance.d.ts.map +1 -0
  93. package/dist/bootstrap/tool-provenance.js +101 -0
  94. package/dist/bootstrap/tool-provenance.js.map +1 -0
  95. package/dist/cli-context.d.ts +17 -0
  96. package/dist/cli-context.d.ts.map +1 -1
  97. package/dist/cli-context.js +62 -1
  98. package/dist/cli-context.js.map +1 -1
  99. package/dist/commands/completion.d.ts.map +1 -1
  100. package/dist/commands/completion.js +3 -0
  101. package/dist/commands/completion.js.map +1 -1
  102. package/dist/commands/host-command-specs.d.ts +13 -15
  103. package/dist/commands/host-command-specs.d.ts.map +1 -1
  104. package/dist/commands/host-command-specs.js +27 -27
  105. package/dist/commands/host-command-specs.js.map +1 -1
  106. package/dist/commands/host-subcommand-groups.d.ts.map +1 -1
  107. package/dist/commands/host-subcommand-groups.js +63 -5
  108. package/dist/commands/host-subcommand-groups.js.map +1 -1
  109. package/dist/commands/internal-command-visibility.d.ts +13 -4
  110. package/dist/commands/internal-command-visibility.d.ts.map +1 -1
  111. package/dist/commands/internal-command-visibility.js +14 -5
  112. package/dist/commands/internal-command-visibility.js.map +1 -1
  113. package/dist/commands/mount-command-spec.d.ts.map +1 -1
  114. package/dist/commands/mount-command-spec.js +31 -0
  115. package/dist/commands/mount-command-spec.js.map +1 -1
  116. package/dist/commands/session-show.d.ts.map +1 -1
  117. package/dist/commands/session-show.js +4 -1
  118. package/dist/commands/session-show.js.map +1 -1
  119. package/dist/commands/tools/data-purge.js +2 -2
  120. package/dist/commands/tools/data-purge.js.map +1 -1
  121. package/dist/commands/tools/validate.js +1 -1
  122. package/dist/env/host-env-specs.d.ts.map +1 -1
  123. package/dist/env/host-env-specs.js +6 -0
  124. package/dist/env/host-env-specs.js.map +1 -1
  125. package/dist/index.js +6 -1
  126. package/dist/index.js.map +1 -1
  127. package/dist/report-compose.d.ts.map +1 -1
  128. package/dist/report-compose.js +85 -19
  129. package/dist/report-compose.js.map +1 -1
  130. package/dist/session-replay-registry.d.ts +33 -6
  131. package/dist/session-replay-registry.d.ts.map +1 -1
  132. package/dist/session-replay-registry.js +43 -6
  133. package/dist/session-replay-registry.js.map +1 -1
  134. package/dist/telemetry/profiling.d.ts +30 -0
  135. package/dist/telemetry/profiling.d.ts.map +1 -1
  136. package/dist/telemetry/profiling.js +16 -1
  137. package/dist/telemetry/profiling.js.map +1 -1
  138. package/package.json +32 -32
@@ -0,0 +1,214 @@
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 { fork } from 'node:child_process';
25
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
26
+ import { tmpdir } from 'node:os';
27
+ import { join } from 'node:path';
28
+ import { ConfigurationError, currentScope, SystemError, } from '@opensip-cli/core';
29
+ import { BOOTSTRAP_MODULE } from './constants.js';
30
+ import { handleHostRpc } from './dispatch-host-rpc-handler.js';
31
+ import { IN_TOOL_WORKER_ENV } from './tool-provenance.js';
32
+ /** Default supervisor wall-clock timeout for one forked worker run (ms). */
33
+ export const DEFAULT_DISPATCH_TIMEOUT_MS = 120_000;
34
+ /** The internal worker subcommand the supervisor forks the CLI binary into. */
35
+ export const WORKER_SUBCOMMAND = '__tool-command-worker';
36
+ /** Resolve the package dir for an external tool, or fail with a structured error. */
37
+ export function requirePackageDir(provenance) {
38
+ const dir = provenance.resolvedPath;
39
+ if (dir === undefined || dir.length === 0) {
40
+ throw new SystemError(`external tool '${provenance.id}' has no resolved package path to dispatch from`, { code: 'SYSTEM.DISPATCH.NO_PACKAGE_DIR' });
41
+ }
42
+ return dir;
43
+ }
44
+ /**
45
+ * Marshal a worker spec to a temp file, fork the worker, enforce the timeout, and
46
+ * resolve the worker's {@link ToolCommandResult}. The temp dir is always cleaned
47
+ * up. `cliScript` defaults to the running CLI entry; tests point it at the dist
48
+ * entry. `cwd` defaults to the spec's `opts.cwd` (or `process.cwd()`).
49
+ */
50
+ export async function runWorkerSpec(args) {
51
+ const dir = mkdtempSync(join(tmpdir(), 'opensip-tool-dispatch-'));
52
+ const specPath = join(dir, 'spec.json');
53
+ writeFileSync(specPath, JSON.stringify(args.spec), 'utf8');
54
+ const cliScript = args.cliScript ?? process.argv[1] ?? '';
55
+ const timeoutMs = args.timeoutMs ?? DEFAULT_DISPATCH_TIMEOUT_MS;
56
+ try {
57
+ return await forkAndAwait(cliScript, specPath, args.cwd, args.spec, timeoutMs, args.ctx);
58
+ }
59
+ finally {
60
+ rmSync(dir, { recursive: true, force: true });
61
+ }
62
+ }
63
+ /**
64
+ * The low-level fork + IPC settle. Mirrors the shared subprocess transport's
65
+ * single-settle / kill-on-settle discipline, but adds a supervisor timeout, the
66
+ * M4-C host-RPC reply channel, and binds the COMMAND result/error shapes. Kept
67
+ * self-contained (not routed through `createSubprocessProgressRun`) because this
68
+ * path needs the rpc-reply direction (`child.send`) the fire-and-forget transport
69
+ * does not have, plus an owned timeout + correlation env injection symmetric to
70
+ * the transport.
71
+ *
72
+ * The wall-clock timeout is a HARD cap on the WHOLE run (resource control,
73
+ * ADR-0054 Consequences) — it is deliberately NOT reset on each RPC, so a runaway
74
+ * upcall loop is still SIGKILLed rather than extending the budget indefinitely.
75
+ */
76
+ function forkAndAwait(cliScript, specPath, cwd, spec, timeoutMs, ctx) {
77
+ return new Promise((resolve, reject) => {
78
+ const runId = currentScope()?.runId;
79
+ // ADR-0054 M4-F: the child IS the isolation boundary. OPENSIP_CLI_IN_TOOL_WORKER
80
+ // tells the worker bootstrap to RUN the dispatched external tool's lifecycle
81
+ // hooks worker-local (the host-skip is disabled there). OPENSIP_RUN_ID stitches
82
+ // the worker's logs to the parent run. fork() with `env` set REPLACES the child
83
+ // env, so the parent env is spread in first to preserve PATH/HOME/etc.
84
+ // @fitness-ignore-next-line env-secret-exposure -- spreading process.env preserves PATH/HOME for the child; only OPENSIP_RUN_ID (no secret) + the OPENSIP_CLI_IN_TOOL_WORKER marker are added; this object is passed to fork, never logged (parity with subprocess-transport's childEnv).
85
+ const childEnv = { ...process.env, [IN_TOOL_WORKER_ENV]: '1' };
86
+ if (runId !== undefined && runId.length > 0)
87
+ childEnv.OPENSIP_RUN_ID = runId;
88
+ // Fork the CLI binary into the internal worker subcommand. The full bootstrap
89
+ // (preAction) re-builds the per-run scope in the worker before the worker
90
+ // handler runs.
91
+ //
92
+ // `cwd` is set on the CHILD PROCESS (not only passed as `--cwd`): the CLI
93
+ // bootstrap anchors TOOL DISCOVERY on `process.cwd()`, while the `--cwd` flag
94
+ // only steers later PROJECT resolution in the pre-action hook. Pinning the
95
+ // child cwd to the same project keeps discovery and project resolution
96
+ // coherent — the worker bootstraps exactly as an in-project invocation would.
97
+ const child = fork(cliScript, [WORKER_SUBCOMMAND, specPath, '--cwd', cwd], {
98
+ cwd,
99
+ stdio: ['ignore', 'ignore', 'inherit', 'ipc'],
100
+ serialization: 'advanced',
101
+ env: childEnv,
102
+ });
103
+ let settled = false;
104
+ const done = (apply) => {
105
+ if (settled)
106
+ return;
107
+ settled = true;
108
+ clearTimeout(timer);
109
+ apply();
110
+ child.kill();
111
+ };
112
+ const timer = setTimeout(() => {
113
+ done(() => {
114
+ child.kill('SIGKILL');
115
+ reject(dispatchError(spec, `worker timed out after ${String(timeoutMs)}ms`, 'timeout'));
116
+ });
117
+ }, timeoutMs);
118
+ timer.unref?.();
119
+ // M4-C: serve one host-RPC upcall against the REAL host ctx and reply. A
120
+ // host-side fault is folded into a structured `{ ok: false }` reply by
121
+ // handleHostRpc — never an unhandled host crash. If the child has already
122
+ // settled (raced a result/exit), the reply is dropped (the worker is gone).
123
+ const serveRpc = (request) => {
124
+ void handleHostRpc(request, ctx).then((reply) => {
125
+ if (!settled)
126
+ sendRpcReply(child, reply, spec);
127
+ });
128
+ };
129
+ child.on('message', (msg) => {
130
+ if (msg.kind === 'progress') {
131
+ serveRpc(msg.event);
132
+ }
133
+ else if (msg.kind === 'result') {
134
+ done(() => {
135
+ resolve(msg.value);
136
+ });
137
+ }
138
+ else {
139
+ done(() => {
140
+ reject(workerErrorToToolError(spec, msg));
141
+ });
142
+ }
143
+ });
144
+ /* 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. */
145
+ child.on('error', (err) => {
146
+ done(() => {
147
+ reject(dispatchError(spec, `cannot isolate external tool '${spec.toolId}' (worker fork failed: ${err.message}); ` +
148
+ 'refusing to run it in-process', 'spawn'));
149
+ });
150
+ });
151
+ child.on('exit', (code) => {
152
+ done(() => {
153
+ reject(dispatchError(spec, `worker exited (code ${code ?? 'null'}) before producing a result`, 'exit_nonzero'));
154
+ });
155
+ });
156
+ });
157
+ }
158
+ /**
159
+ * Post one host-RPC {@link RpcReply} back to the worker, only while the child is
160
+ * still attached: a settle (result/exit/timeout) kills it, after which
161
+ * `child.send` would write to a closed channel. The send callback swallows a
162
+ * racing EPIPE so a reply to a departing worker never surfaces as a spurious
163
+ * dispatch failure — a dropped reply is logged at debug and otherwise ignored.
164
+ */
165
+ function sendRpcReply(child, reply, spec) {
166
+ if (!child.connected)
167
+ return;
168
+ child.send(reply, (err) => {
169
+ if (err === null)
170
+ return;
171
+ /* v8 ignore next 6 -- defensive race arm: the channel can close between the `connected` check and the async `child.send` write (the child settled/exited concurrently). The dropped-reply debug log is only reachable via that microtask-level race, not deterministically testable; a dropped reply to a departing worker is harmless (the worker is gone). */
172
+ currentScope()?.logger.debug({
173
+ evt: 'cli.tool.dispatch_rpc_reply_dropped',
174
+ module: BOOTSTRAP_MODULE,
175
+ toolId: spec.toolId,
176
+ command: spec.commandName ?? spec.hook ?? 'unknown',
177
+ });
178
+ });
179
+ }
180
+ /**
181
+ * The human label for the dispatched unit — the command name, or (hook mode) the
182
+ * hook name. A valid spec always names one; the final fallback is defensive.
183
+ */
184
+ function specLabel(spec) {
185
+ /* v8 ignore next -- defensive: a valid spec always carries a commandName OR a hook (the worker entry rejects one that has neither as bad-spec); the 'unknown' fallback is structurally unreachable. */
186
+ return spec.commandName ?? spec.hook ?? 'unknown';
187
+ }
188
+ /** Build a structured supervisor-side dispatch error, logged with its failure class. */
189
+ export function dispatchError(spec, message, failureClass) {
190
+ const label = specLabel(spec);
191
+ currentScope()?.logger.error({
192
+ evt: 'cli.tool.dispatch_failed',
193
+ module: BOOTSTRAP_MODULE,
194
+ toolId: spec.toolId,
195
+ command: label,
196
+ failureClass,
197
+ });
198
+ // ADR-0054 M4-E single config-error contract: a worker DEEP-pass config failure
199
+ // (`config-invalid`) maps to the SAME typed error + exit code (ConfigurationError
200
+ // → CONFIGURATION_ERROR, exit 2) the host COARSE pass throws, so the user sees a
201
+ // consistent "Invalid configuration …" regardless of which pass caught it.
202
+ if (failureClass === 'config-invalid') {
203
+ return new ConfigurationError(message, { code: 'CONFIGURATION_ERROR', failureClass });
204
+ }
205
+ return new SystemError(`external tool '${spec.toolId}' ${label} failed: ${message}`, {
206
+ code: 'SYSTEM.DISPATCH.WORKER_FAILED',
207
+ failureClass,
208
+ });
209
+ }
210
+ /** Convert a worker `error` IPC message into a logged, structured {@link ToolError}. */
211
+ function workerErrorToToolError(spec, msg) {
212
+ return dispatchError(spec, msg.message, msg.failureClass ?? 'ipc_error');
213
+ }
214
+ //# sourceMappingURL=dispatch-fork-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-fork-core.js","sourceRoot":"","sources":["../../src/bootstrap/dispatch-fork-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,GAIZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS1D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,u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AC;IAC9B,YAAY,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC;QAC3B,GAAG,EAAE,0BAA0B;QAC/B,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,KAAK;QACd,YAAY;KACb,CAAC,CAAC;IACH,gFAAgF;IAChF,kFAAkF;IAClF,iFAAiF;IACjF,2EAA2E;IAC3E,IAAI,YAAY,KAAK,gBAAgB,EAAE,CAAC;QACtC,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,kBAAkB,IAAI,CAAC,MAAM,KAAK,KAAK,YAAY,OAAO,EAAE,EAAE;QACnF,IAAI,EAAE,+BAA+B;QACrC,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAED,wFAAwF;AACxF,SAAS,sBAAsB,CAAC,IAA2B,EAAE,GAAwB;IACnF,OAAO,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,YAAY,IAAI,WAAW,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * dispatch-host-rpc-handler — the HOST side of the ADR-0054 host-RPC upcall
3
+ * channel (increment M4-C).
4
+ *
5
+ * The supervisor (`dispatch-external-tool-command.ts`) receives a worker-streamed
6
+ * {@link HostRpcRequest} (on the transport's `progress` arm) and calls
7
+ * {@link handleHostRpc}. This module performs the requested privileged effect
8
+ * through the REAL host {@link ToolCliContext} — the SAME context the in-process
9
+ * path uses (datastore via the host scope, cloud egress, FS, BaselineRepo,
10
+ * ToolStateRepo, host planes) — and returns an {@link RpcReply} the supervisor
11
+ * posts back to the worker via `child.send`.
12
+ *
13
+ * The host remains the ONLY process that performs the privileged effect. A
14
+ * host-side fault is CAUGHT and crosses back as a structured `{ ok: false }`
15
+ * reply (the worker shim re-throws it into the handler) — never an unhandled
16
+ * host crash, never a silent no-op.
17
+ */
18
+ import type { HostRpcRequest, RpcReply } from './tool-command-dispatch-types.js';
19
+ import type { ToolCliContext } from '@opensip-cli/core';
20
+ /**
21
+ * Handle one worker-streamed {@link HostRpcRequest} against the real host
22
+ * {@link ToolCliContext} and produce the {@link RpcReply} to send back. A
23
+ * host-side fault is caught and returned as a structured `{ ok: false }` reply
24
+ * (the supervisor sends it; the worker shim re-throws it into the handler).
25
+ */
26
+ export declare function handleHostRpc(request: HostRpcRequest, ctx: ToolCliContext): Promise<RpcReply>;
27
+ //# sourceMappingURL=dispatch-host-rpc-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-host-rpc-handler.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-host-rpc-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAIV,cAAc,EACd,QAAQ,EACT,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA6IxD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,QAAQ,CAAC,CAwBnB"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * dispatch-host-rpc-handler — the HOST side of the ADR-0054 host-RPC upcall
3
+ * channel (increment M4-C).
4
+ *
5
+ * The supervisor (`dispatch-external-tool-command.ts`) receives a worker-streamed
6
+ * {@link HostRpcRequest} (on the transport's `progress` arm) and calls
7
+ * {@link handleHostRpc}. This module performs the requested privileged effect
8
+ * through the REAL host {@link ToolCliContext} — the SAME context the in-process
9
+ * path uses (datastore via the host scope, cloud egress, FS, BaselineRepo,
10
+ * ToolStateRepo, host planes) — and returns an {@link RpcReply} the supervisor
11
+ * posts back to the worker via `child.send`.
12
+ *
13
+ * The host remains the ONLY process that performs the privileged effect. A
14
+ * host-side fault is CAUGHT and crosses back as a structured `{ ok: false }`
15
+ * reply (the worker shim re-throws it into the handler) — never an unhandled
16
+ * host crash, never a silent no-op.
17
+ */
18
+ /**
19
+ * The closed set of seam names the host will dispatch. The IPC `request` crosses
20
+ * a trust boundary (it arrives over the worker's IPC channel), so the host
21
+ * validates it against this allowlist BEFORE dispatching — an unrecognized seam
22
+ * (e.g. a version-skewed worker) fails loud rather than silently no-op'ing. Kept
23
+ * in sync with the {@link HostRpcCall} union by the `satisfies` assertion below.
24
+ */
25
+ const RECOGNIZED_SEAMS = new Set([
26
+ 'deliverSignals',
27
+ 'writeSarif',
28
+ 'saveBaseline',
29
+ 'compareBaseline',
30
+ 'exportBaselineSarif',
31
+ 'exportBaselineFingerprints',
32
+ 'toolState.get',
33
+ 'toolState.put',
34
+ 'toolState.delete',
35
+ 'toolState.list',
36
+ 'maybeOpenReport',
37
+ 'getExitCode',
38
+ 'hostPlane',
39
+ ]);
40
+ /**
41
+ * Validate an inbound IPC {@link HostRpcRequest} against the recognized-seam
42
+ * allowlist before it is dispatched.
43
+ *
44
+ * @throws {TypeError} when the request shape is malformed or names a seam the
45
+ * host does not recognize — the host fails loud (the structured error crosses
46
+ * back to the worker) instead of silently ignoring an unknown upcall.
47
+ */
48
+ function validateHostRpcRequest(request) {
49
+ if (typeof request !== 'object' || typeof request.rpcId !== 'number') {
50
+ throw new TypeError('host-RPC: malformed request (missing numeric rpcId)');
51
+ }
52
+ if (!RECOGNIZED_SEAMS.has(request.seam)) {
53
+ throw new TypeError(`host-RPC: unrecognized seam '${String(request.seam)}'`);
54
+ }
55
+ }
56
+ /**
57
+ * Resolve the named host plane from the context's `hostPlanes` bag. A plane
58
+ * absent on an OSS host is an explicit, structured failure — not a silent no-op.
59
+ *
60
+ * @throws {Error} when the host provides no impl for the requested plane (the
61
+ * worker re-throws it into the handler as a normal thrown error).
62
+ */
63
+ function resolvePlane(ctx, plane) {
64
+ const impl = ctx.hostPlanes?.[plane];
65
+ if (impl === undefined) {
66
+ throw new Error(`host-RPC: hostPlanes.${plane} is not provided by this host`);
67
+ }
68
+ return impl;
69
+ }
70
+ /**
71
+ * Invoke `hostPlanes.<plane>.<method>(...args)`.
72
+ *
73
+ * @throws {Error} when the requested plane is not provided by the host
74
+ * (via {@link resolvePlane}).
75
+ * @throws {TypeError} when the named method is absent on the resolved plane —
76
+ * the worker re-throws it into the handler as a normal thrown error.
77
+ */
78
+ function callHostPlane(ctx, plane, method, args) {
79
+ const impl = resolvePlane(ctx, plane);
80
+ const fn = impl[method];
81
+ if (typeof fn !== 'function') {
82
+ throw new TypeError(`host-RPC: hostPlanes.${plane}.${method} is not a function on this host`);
83
+ }
84
+ return fn(...args);
85
+ }
86
+ /** Narrow the serializable wire opts to the real `deliverSignals` opts shape. */
87
+ function deliverOpts(opts) {
88
+ return {
89
+ cwd: opts.cwd,
90
+ ...(opts.reportTo === undefined ? {} : { reportTo: opts.reportTo }),
91
+ ...(opts.apiKey === undefined ? {} : { apiKey: opts.apiKey }),
92
+ ...(opts.runFailed === undefined ? {} : { runFailed: opts.runFailed }),
93
+ };
94
+ }
95
+ /**
96
+ * Perform ONE host-RPC request through the real `ctx` and return its value.
97
+ * Pure dispatch — validation + the try/catch + reply wrapping live in
98
+ * {@link handleHostRpc}.
99
+ */
100
+ async function performHostRpc(request, ctx) {
101
+ switch (request.seam) {
102
+ case 'deliverSignals': {
103
+ return ctx.deliverSignals(request.envelope, deliverOpts(request.opts));
104
+ }
105
+ case 'writeSarif': {
106
+ return ctx.writeSarif(request.envelope, request.path);
107
+ }
108
+ case 'saveBaseline': {
109
+ return ctx.saveBaseline(request.tool, request.envelope);
110
+ }
111
+ case 'compareBaseline': {
112
+ return ctx.compareBaseline(request.tool, request.envelope);
113
+ }
114
+ case 'exportBaselineSarif': {
115
+ return ctx.exportBaselineSarif(request.tool, request.path);
116
+ }
117
+ case 'exportBaselineFingerprints': {
118
+ return ctx.exportBaselineFingerprints(request.tool, request.path);
119
+ }
120
+ case 'toolState.get': {
121
+ return ctx.toolState.get(request.tool, request.key);
122
+ }
123
+ case 'toolState.put': {
124
+ return ctx.toolState.put(request.tool, request.key, request.payload);
125
+ }
126
+ case 'toolState.delete': {
127
+ return ctx.toolState.delete(request.tool, request.key);
128
+ }
129
+ case 'toolState.list': {
130
+ return ctx.toolState.list(request.tool);
131
+ }
132
+ case 'maybeOpenReport': {
133
+ return ctx.maybeOpenReport(request.opts);
134
+ }
135
+ case 'getExitCode': {
136
+ return ctx.getExitCode?.();
137
+ }
138
+ case 'hostPlane': {
139
+ return callHostPlane(ctx, request.plane, request.method, request.args);
140
+ }
141
+ }
142
+ }
143
+ /**
144
+ * Handle one worker-streamed {@link HostRpcRequest} against the real host
145
+ * {@link ToolCliContext} and produce the {@link RpcReply} to send back. A
146
+ * host-side fault is caught and returned as a structured `{ ok: false }` reply
147
+ * (the supervisor sends it; the worker shim re-throws it into the handler).
148
+ */
149
+ export async function handleHostRpc(request, ctx) {
150
+ try {
151
+ // Validate the inbound IPC request against the recognized-seam allowlist
152
+ // before dispatching (defense-in-depth for the trust boundary; fail loud on
153
+ // a malformed or version-skewed upcall rather than silently no-op'ing).
154
+ // @fitness-ignore-next-line detached-promises -- validateHostRpcRequest is a synchronous void validator (it throws or returns); the name-based heuristic misfires on a bare call statement.
155
+ validateHostRpcRequest(request);
156
+ const value = await performHostRpc(request, ctx);
157
+ return { kind: 'rpc-reply', rpcId: request.rpcId, ok: true, value };
158
+ }
159
+ catch (error) {
160
+ return {
161
+ kind: 'rpc-reply',
162
+ rpcId: request.rpcId,
163
+ ok: false,
164
+ error: {
165
+ message: error instanceof Error ? error.message : String(error),
166
+ ...(error.code !== undefined &&
167
+ typeof error.code === 'string'
168
+ ? { code: error.code }
169
+ : {}),
170
+ ...(error instanceof Error && error.stack !== undefined ? { stack: error.stack } : {}),
171
+ },
172
+ };
173
+ }
174
+ }
175
+ //# sourceMappingURL=dispatch-host-rpc-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d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AAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACvF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * dispatch-replay-result — replay one worker {@link ToolCommandResult} through the
3
+ * REAL host {@link ToolCliContext} seams (ADR-0054 dispatch plane).
4
+ *
5
+ * Split out of `dispatch-external-tool-command.ts` (the fork/IPC supervisor) so
6
+ * the replay concern — turning the slim serialized result the worker posted back
7
+ * into host-side output + persistence — lives on its own seam. The host is the
8
+ * only process that performs the privileged effect (render / stdout / exit code /
9
+ * session persist).
10
+ */
11
+ import { type ToolCliContext } from '@opensip-cli/core';
12
+ import { type RunActionHooks } from './run-plane.js';
13
+ import type { ToolCommandResult } from './tool-command-dispatch-types.js';
14
+ /**
15
+ * The host context the supervisor replays through: the full `ToolCliContext` plus
16
+ * the run-action hooks (`completeRun` persists the worker's returned session —
17
+ * host-owned-run-timing). `completeRun` is optional (a lean context carries no run
18
+ * plane), so a test ctx without it is still valid.
19
+ */
20
+ export type DispatchHostCtx = ToolCliContext & Partial<RunActionHooks>;
21
+ /** The invocation context {@link replayResult} needs to route the handler's return. */
22
+ export interface ReplayContext {
23
+ readonly commandName: string;
24
+ /** Parsed opts (with `_args`) — carries `--json`, which `dispatchOutput` reads. */
25
+ readonly opts: Record<string, unknown>;
26
+ readonly positionals: readonly unknown[];
27
+ }
28
+ /**
29
+ * Replay the worker's slim {@link ToolCommandResult} through the REAL host
30
+ * {@link ToolCliContext} seams. Two output channels are replayed, exactly
31
+ * mirroring the in-process path:
32
+ *
33
+ * - The handler's RETURN value (`result.returned`) for the return-valued modes
34
+ * (`command-result` / `signal-envelope`) is routed through the SAME
35
+ * {@link dispatchOutput} seam the in-process action uses, so the `--json`
36
+ * short-circuit vs. human `render` decision is byte-identical regardless of
37
+ * whether the command ran in-process or in the worker (ADR-0027 parity). This
38
+ * is the fix for the worker-by-default flip silently dropping a
39
+ * `command-result` handler's output (e.g. `fit list`): the FRR seam replay
40
+ * below never captured it, because those handlers RETURN, they do not `ctx.*`.
41
+ * - The FRR seam fields (`render`/`envelope`/`json`/`raw`/`error`) capture
42
+ * EXPLICIT `ctx.*` emitter calls a handler made; replayed through their host
43
+ * counterparts. Populated only for handlers that emit via seams (e.g. an
44
+ * envelope handler calling `ctx.emitEnvelope`), never together with `returned`
45
+ * for the same payload.
46
+ *
47
+ * The exit code is applied LAST so it is the final word (matching the in-process
48
+ * `setExitCode` semantics).
49
+ */
50
+ export declare function replayResult(result: ToolCommandResult, ctx: DispatchHostCtx, invocation: ReplayContext): Promise<void>;
51
+ //# sourceMappingURL=dispatch-replay-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-replay-result.d.ts","sourceRoot":"","sources":["../../src/bootstrap/dispatch-replay-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAI1E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEvE,uFAAuF;AACvF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,IAAI,CAAC,CAyCf"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * dispatch-replay-result — replay one worker {@link ToolCommandResult} through the
3
+ * REAL host {@link ToolCliContext} seams (ADR-0054 dispatch plane).
4
+ *
5
+ * Split out of `dispatch-external-tool-command.ts` (the fork/IPC supervisor) so
6
+ * the replay concern — turning the slim serialized result the worker posted back
7
+ * into host-side output + persistence — lives on its own seam. The host is the
8
+ * only process that performs the privileged effect (render / stdout / exit code /
9
+ * session persist).
10
+ */
11
+ import { dispatchOutput } from '../commands/mount-command-spec.js';
12
+ /**
13
+ * Replay the worker's slim {@link ToolCommandResult} through the REAL host
14
+ * {@link ToolCliContext} seams. Two output channels are replayed, exactly
15
+ * mirroring the in-process path:
16
+ *
17
+ * - The handler's RETURN value (`result.returned`) for the return-valued modes
18
+ * (`command-result` / `signal-envelope`) is routed through the SAME
19
+ * {@link dispatchOutput} seam the in-process action uses, so the `--json`
20
+ * short-circuit vs. human `render` decision is byte-identical regardless of
21
+ * whether the command ran in-process or in the worker (ADR-0027 parity). This
22
+ * is the fix for the worker-by-default flip silently dropping a
23
+ * `command-result` handler's output (e.g. `fit list`): the FRR seam replay
24
+ * below never captured it, because those handlers RETURN, they do not `ctx.*`.
25
+ * - The FRR seam fields (`render`/`envelope`/`json`/`raw`/`error`) capture
26
+ * EXPLICIT `ctx.*` emitter calls a handler made; replayed through their host
27
+ * counterparts. Populated only for handlers that emit via seams (e.g. an
28
+ * envelope handler calling `ctx.emitEnvelope`), never together with `returned`
29
+ * for the same payload.
30
+ *
31
+ * The exit code is applied LAST so it is the final word (matching the in-process
32
+ * `setExitCode` semantics).
33
+ */
34
+ export async function replayResult(result, ctx, invocation) {
35
+ if (result.error !== undefined) {
36
+ ctx.emitError(result.error);
37
+ }
38
+ // Return-valued modes: route the raw return through the shared dispatch seam so
39
+ // the host applies the identical `--json`/render routing the in-process path
40
+ // would. A synthetic spec carries just what `dispatchOutput` reads (name +
41
+ // output mode).
42
+ if (result.returned !== undefined) {
43
+ const replaySpec = {
44
+ name: invocation.commandName,
45
+ output: result.output,
46
+ };
47
+ // Replay is the OUTPUT leg of dispatch; the lifecycle events (dispatch start +
48
+ // worker-resolved) are emitted by the caller (dispatchExternalToolCommand), so
49
+ // a duplicate emit here would be noise.
50
+ await dispatchOutput(result.returned, replaySpec, invocation.opts, invocation.positionals, ctx); // observability-ok
51
+ }
52
+ if (result.render !== undefined) {
53
+ await ctx.render(result.render);
54
+ }
55
+ if (result.envelope !== undefined) {
56
+ ctx.emitEnvelope(result.envelope);
57
+ }
58
+ if (result.json !== undefined) {
59
+ ctx.emitJson(result.json);
60
+ }
61
+ if (result.raw !== undefined) {
62
+ ctx.emitRaw(result.raw);
63
+ }
64
+ if (result.exitCode !== undefined) {
65
+ ctx.setExitCode(result.exitCode);
66
+ }
67
+ // host-owned-run-timing: the worker handler RETURNED a session contribution;
68
+ // the HOST persists it (the host owns the generic row + its timing). The mount
69
+ // action took the early-return dispatch branch, so it did NOT call completeRun —
70
+ // the supervisor drives it here with the worker's session.
71
+ if (result.session !== undefined) {
72
+ // @fitness-ignore-next-line detached-promises -- RunActionHooks.completeRun returns void (run-plane.ts:95; freezes + persists synchronously); the name-based heuristic misfires on the optional-chain call.
73
+ ctx.completeRun?.({ session: result.session });
74
+ }
75
+ }
76
+ //# sourceMappingURL=dispatch-replay-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-replay-result.js","sourceRoot":"","sources":["../../src/bootstrap/dispatch-replay-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAsBnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAyB,EACzB,GAAoB,EACpB,UAAyB;IAEzB,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,gFAAgF;IAChF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0B,CAAC,CA8GrC"}
@@ -104,7 +104,9 @@ export async function executePostBailoutBootstrap(input, deps = {}) {
104
104
  }
105
105
  d.startProfiling(scope, plan.commandName);
106
106
  record(PRE_ACTION_PHASES.toolPreflight);
107
- await d.maybeInitializeOwningTool(tools, plan.commandName, plan.runId);
107
+ // ADR-0054 M4-F: pass provenance so an EXTERNAL owning tool's initialize is
108
+ // skipped in-host (it runs worker-side under dispatch); bundled runs in-host.
109
+ await d.maybeInitializeOwningTool(tools, plan.commandName, plan.runId, provenance);
108
110
  const driven = await d.loadOwningToolCapabilities({
109
111
  owningTool: d.resolveOwningTool(tools, plan.commandName),
110
112
  projectDir: plan.project.projectRoot,
@@ -1 +1 @@
1
- {"version":3,"file":"execute-post-bailout-bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/execute-post-bailout-bootstrap.ts"],"names":[],"mappings":"AAAA,qLAAqL;AACrL;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAKrE,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,SAAS,eAAe;IACtB,gEAAgE;AAClE,CAAC;AA+BD,MAAM,WAAW,GAab;IACF,eAAe;IACf,gBAAgB;IAChB,UAAU;IACV,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,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OAAO,CAAC,WAAW;QACpC,aAAa,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,IAAI,EAAE;KACnD,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,KAAK,CAAC,WAAW,CAAC,KAAK,CACrB,MAAM,EACN,OAAO,EACP,SAAS,MAAM,CAAC,MAAM,CAAC,oHAAoH,CAC5I,CAAC;QACF,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
1
+ {"version":3,"file":"execute-post-bailout-bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap/execute-post-bailout-bootstrap.ts"],"names":[],"mappings":"AAAA,qLAAqL;AACrL;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,WAAW,GAGZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAKrE,MAAM,UAAU,GAAG,eAAe,CAAC;AACnC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,SAAS,eAAe;IACtB,gEAAgE;AAClE,CAAC;AA+BD,MAAM,WAAW,GAab;IACF,eAAe;IACf,gBAAgB;IAChB,UAAU;IACV,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,KAAK,SAAS;IAClD,cAAc;IACd,c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