@kb-labs/core-state-daemon 2.116.14 → 2.117.0

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 (3) hide show
  1. package/dist/bin.cjs +748 -281
  2. package/dist/bin.cjs.map +1 -1
  3. package/package.json +11 -11
package/dist/bin.cjs CHANGED
@@ -2217,8 +2217,8 @@ var init_dist3 = __esm({
2217
2217
  totalTime: 0
2218
2218
  });
2219
2219
  }
2220
- const registered = this.resources.get(request.resource);
2221
- if (!registered) {
2220
+ const registered2 = this.resources.get(request.resource);
2221
+ if (!registered2) {
2222
2222
  return Promise.resolve({
2223
2223
  success: false,
2224
2224
  error: new Error(`Resource not registered: ${request.resource}`),
@@ -2228,7 +2228,7 @@ var init_dist3 = __esm({
2228
2228
  totalTime: 0
2229
2229
  });
2230
2230
  }
2231
- if (registered.limitOnly) {
2231
+ if (registered2.limitOnly) {
2232
2232
  return Promise.resolve({
2233
2233
  success: false,
2234
2234
  error: new Error(
@@ -2244,8 +2244,8 @@ var init_dist3 = __esm({
2244
2244
  ...request,
2245
2245
  id: crypto.randomUUID(),
2246
2246
  createdAt: Date.now(),
2247
- timeout: request.timeout ?? registered.config.timeout ?? 6e4,
2248
- maxRetries: request.maxRetries ?? registered.config.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries
2247
+ timeout: request.timeout ?? registered2.config.timeout ?? 6e4,
2248
+ maxRetries: request.maxRetries ?? registered2.config.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries
2249
2249
  };
2250
2250
  return new Promise((resolve6, reject) => {
2251
2251
  const item = {
@@ -2255,7 +2255,7 @@ var init_dist3 = __esm({
2255
2255
  enqueuedAt: Date.now()
2256
2256
  };
2257
2257
  this.queue.enqueue(item);
2258
- registered.stats.totalRequests++;
2258
+ registered2.stats.totalRequests++;
2259
2259
  this.processQueue();
2260
2260
  });
2261
2261
  }
@@ -2280,15 +2280,15 @@ var init_dist3 = __esm({
2280
2280
  release: noopRelease
2281
2281
  };
2282
2282
  }
2283
- const registered = this.resources.get(resource);
2284
- if (!registered) {
2283
+ const registered2 = this.resources.get(resource);
2284
+ if (!registered2) {
2285
2285
  throw new Error(`Resource not registered: ${resource}`);
2286
2286
  }
2287
2287
  const tokens = opts?.tokens ?? 0;
2288
2288
  const result = await this.rateLimitBackend.acquire(
2289
2289
  resource,
2290
2290
  tokens,
2291
- registered.rateLimits
2291
+ registered2.rateLimits
2292
2292
  );
2293
2293
  if (!result.allowed) {
2294
2294
  return { ...result, release: noopRelease };
@@ -2321,8 +2321,8 @@ var init_dist3 = __esm({
2321
2321
  if (!item) {
2322
2322
  break;
2323
2323
  }
2324
- const registered = this.resources.get(item.request.resource);
2325
- if (!registered) {
2324
+ const registered2 = this.resources.get(item.request.resource);
2325
+ if (!registered2) {
2326
2326
  this.queue.dequeue();
2327
2327
  item.reject(new Error(`Resource not registered: ${item.request.resource}`));
2328
2328
  continue;
@@ -2331,7 +2331,7 @@ var init_dist3 = __esm({
2331
2331
  const acquireResult = await this.rateLimitBackend.acquire(
2332
2332
  item.request.resource,
2333
2333
  tokens,
2334
- registered.rateLimits
2334
+ registered2.rateLimits
2335
2335
  );
2336
2336
  if (!acquireResult.allowed) {
2337
2337
  await sleep(acquireResult.waitTimeMs ?? 100);
@@ -2340,7 +2340,7 @@ var init_dist3 = __esm({
2340
2340
  this.queue.dequeue();
2341
2341
  const currentActive = this.activeProcessing.get(item.request.resource) ?? 0;
2342
2342
  this.activeProcessing.set(item.request.resource, currentActive + 1);
2343
- this.executeItem(item, registered).catch(() => {
2343
+ this.executeItem(item, registered2).catch(() => {
2344
2344
  });
2345
2345
  }
2346
2346
  } finally {
@@ -2353,15 +2353,15 @@ var init_dist3 = __esm({
2353
2353
  /**
2354
2354
  * Execute a single queue item with retry logic.
2355
2355
  */
2356
- async executeItem(item, registered) {
2356
+ async executeItem(item, registered2) {
2357
2357
  const startTime = Date.now();
2358
2358
  const waitTime = startTime - item.enqueuedAt;
2359
2359
  let retries = 0;
2360
2360
  let lastError;
2361
2361
  const retryConfig = {
2362
2362
  maxRetries: item.request.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,
2363
- baseDelay: registered.config.baseDelay ?? DEFAULT_RETRY_CONFIG.baseDelay,
2364
- maxDelay: registered.config.maxDelay ?? DEFAULT_RETRY_CONFIG.maxDelay,
2363
+ baseDelay: registered2.config.baseDelay ?? DEFAULT_RETRY_CONFIG.baseDelay,
2364
+ maxDelay: registered2.config.maxDelay ?? DEFAULT_RETRY_CONFIG.maxDelay,
2365
2365
  jitter: DEFAULT_RETRY_CONFIG.jitter,
2366
2366
  retryableErrors: DEFAULT_RETRY_CONFIG.retryableErrors
2367
2367
  };
@@ -2372,16 +2372,16 @@ var init_dist3 = __esm({
2372
2372
  const timeoutPromise = new Promise((_, reject) => {
2373
2373
  setTimeout(() => reject(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
2374
2374
  });
2375
- const executionPromise = registered.config.executor(
2375
+ const executionPromise = registered2.config.executor(
2376
2376
  item.request.operation,
2377
2377
  item.request.args
2378
2378
  );
2379
2379
  const result = await Promise.race([executionPromise, timeoutPromise]);
2380
2380
  const endTime2 = Date.now();
2381
2381
  const processingTime2 = endTime2 - startTime;
2382
- registered.stats.totalSuccess++;
2383
- registered.stats.totalWaitTime += waitTime;
2384
- registered.stats.totalProcessingTime += processingTime2;
2382
+ registered2.stats.totalSuccess++;
2383
+ registered2.stats.totalWaitTime += waitTime;
2384
+ registered2.stats.totalProcessingTime += processingTime2;
2385
2385
  item.resolve({
2386
2386
  success: true,
2387
2387
  data: result,
@@ -2403,7 +2403,7 @@ var init_dist3 = __esm({
2403
2403
  const acquireResult = await this.rateLimitBackend.acquire(
2404
2404
  item.request.resource,
2405
2405
  tokens,
2406
- registered.rateLimits
2406
+ registered2.rateLimits
2407
2407
  );
2408
2408
  if (!acquireResult.allowed && acquireResult.waitTimeMs) {
2409
2409
  await sleep(acquireResult.waitTimeMs);
@@ -2412,9 +2412,9 @@ var init_dist3 = __esm({
2412
2412
  }
2413
2413
  const endTime = Date.now();
2414
2414
  const processingTime = endTime - startTime;
2415
- registered.stats.totalErrors++;
2416
- registered.stats.totalWaitTime += waitTime;
2417
- registered.stats.totalProcessingTime += processingTime;
2415
+ registered2.stats.totalErrors++;
2416
+ registered2.stats.totalWaitTime += waitTime;
2417
+ registered2.stats.totalProcessingTime += processingTime;
2418
2418
  item.resolve({
2419
2419
  success: false,
2420
2420
  error: lastError,
@@ -2437,7 +2437,7 @@ var init_dist3 = __esm({
2437
2437
  let totalRequests = 0;
2438
2438
  let totalSuccess = 0;
2439
2439
  let totalErrors = 0;
2440
- for (const [resourceName, registered] of this.resources) {
2440
+ for (const [resourceName, registered2] of this.resources) {
2441
2441
  const queueByPriority = this.queue.sizeByPriority();
2442
2442
  const queueSize = this.queue.sizeByResource(resourceName);
2443
2443
  const activeRequests = this.activeProcessing.get(resourceName) ?? 0;
@@ -2447,26 +2447,26 @@ var init_dist3 = __esm({
2447
2447
  requestsThisMinute: 0,
2448
2448
  requestsThisSecond: 0,
2449
2449
  activeRequests,
2450
- totalRequests: registered.stats.totalRequests,
2450
+ totalRequests: registered2.stats.totalRequests,
2451
2451
  totalTokens: 0,
2452
2452
  waitCount: 0,
2453
- totalWaitTime: registered.stats.totalWaitTime
2453
+ totalWaitTime: registered2.stats.totalWaitTime
2454
2454
  };
2455
- const avgWaitTime = registered.stats.totalRequests > 0 ? registered.stats.totalWaitTime / registered.stats.totalRequests : 0;
2456
- const avgProcessingTime = registered.stats.totalRequests > 0 ? registered.stats.totalProcessingTime / registered.stats.totalRequests : 0;
2455
+ const avgWaitTime = registered2.stats.totalRequests > 0 ? registered2.stats.totalWaitTime / registered2.stats.totalRequests : 0;
2456
+ const avgProcessingTime = registered2.stats.totalRequests > 0 ? registered2.stats.totalProcessingTime / registered2.stats.totalRequests : 0;
2457
2457
  resources[resourceName] = {
2458
2458
  rateLimits: rateLimitStats,
2459
2459
  queueSize,
2460
2460
  queueByPriority,
2461
- totalRequests: registered.stats.totalRequests,
2462
- totalSuccess: registered.stats.totalSuccess,
2463
- totalErrors: registered.stats.totalErrors,
2461
+ totalRequests: registered2.stats.totalRequests,
2462
+ totalSuccess: registered2.stats.totalSuccess,
2463
+ totalErrors: registered2.stats.totalErrors,
2464
2464
  avgWaitTime,
2465
2465
  avgProcessingTime
2466
2466
  };
2467
- totalRequests += registered.stats.totalRequests;
2468
- totalSuccess += registered.stats.totalSuccess;
2469
- totalErrors += registered.stats.totalErrors;
2467
+ totalRequests += registered2.stats.totalRequests;
2468
+ totalSuccess += registered2.stats.totalSuccess;
2469
+ totalErrors += registered2.stats.totalErrors;
2470
2470
  }
2471
2471
  return {
2472
2472
  resources,
@@ -3554,6 +3554,7 @@ __export(dist_exports, {
3554
3554
  KVStoreProxy: () => KVStoreProxy,
3555
3555
  LLMProxy: () => LLMProxy,
3556
3556
  OPERATION_TIMEOUTS: () => OPERATION_TIMEOUTS,
3557
+ ProcessExecutorProxy: () => ProcessExecutorProxy,
3557
3558
  RemoteAdapter: () => RemoteAdapter,
3558
3559
  StorageProxy: () => StorageProxy,
3559
3560
  TimeoutError: () => TimeoutError,
@@ -3635,6 +3636,7 @@ function isPlainObject(value) {
3635
3636
  function createProxyPlatform(options) {
3636
3637
  const { transport } = options;
3637
3638
  const logger = options.logger ?? new LoggerProxy(transport);
3639
+ const processExecutor = new ProcessExecutorProxy(transport);
3638
3640
  const cache = new CacheProxy(transport);
3639
3641
  const llm = new LLMProxy(transport);
3640
3642
  const embeddings = new EmbeddingsProxy(transport);
@@ -3678,10 +3680,11 @@ function createProxyPlatform(options) {
3678
3680
  invoke,
3679
3681
  documentDatabase,
3680
3682
  kvStore,
3681
- logs
3683
+ logs,
3684
+ processExecutor
3682
3685
  };
3683
3686
  }
3684
- var BulkTransferHelper, DEFAULT_SOCKET_PATH, UnixSocketServer, IPCServer, ChildIPCServer, TransportError, TimeoutError, CircuitOpenError, OPERATION_TIMEOUTS, IPCTransport, UnixSocketTransport, RemoteAdapter, CacheProxy, LLMProxy, EmbeddingsProxy, VectorStoreProxy, StorageProxy, DocumentDatabaseProxy, stripSignal, KVStoreProxy, stripSignal2, ConfigProxy, EventBusProxy, LoggerProxy;
3687
+ var BulkTransferHelper, DEFAULT_SOCKET_PATH, UnixSocketServer, IPCServer, ChildIPCServer, TransportError, TimeoutError, CircuitOpenError, OPERATION_TIMEOUTS, IPCTransport, UnixSocketTransport, RemoteAdapter, CacheProxy, LLMProxy, EmbeddingsProxy, VectorStoreProxy, StorageProxy, DocumentDatabaseProxy, stripSignal, KVStoreProxy, stripSignal2, ConfigProxy, EventBusProxy, LoggerProxy, PROCESS_RPC_GRACE_MS, CONTROL_RPC_TIMEOUT_MS, MAX_TIMER_MS, ProcessExecutorProxy;
3685
3688
  var init_dist5 = __esm({
3686
3689
  "../../../core/ipc/dist/index.js"() {
3687
3690
  init_serializable();
@@ -3997,11 +4000,16 @@ var init_dist5 = __esm({
3997
4000
  return this.platform.analytics;
3998
4001
  case "eventBus":
3999
4002
  return this.platform.eventBus;
4003
+ case "processExecutor":
4004
+ if (!this.platform.processExecutor) {
4005
+ throw new Error("Governed process executor is not configured on execution host");
4006
+ }
4007
+ return this.platform.processExecutor;
4000
4008
  case "invoke":
4001
4009
  return this.platform.invoke;
4002
4010
  default:
4003
4011
  throw new Error(
4004
- `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, config, llm, embeddings, storage, logger, analytics, eventBus, invoke`
4012
+ `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, config, llm, embeddings, storage, logger, analytics, eventBus, invoke, processExecutor`
4005
4013
  );
4006
4014
  }
4007
4015
  }
@@ -4173,9 +4181,14 @@ var init_dist5 = __esm({
4173
4181
  return this.platform.eventBus;
4174
4182
  case "invoke":
4175
4183
  return this.platform.invoke;
4184
+ case "processExecutor":
4185
+ if (!this.platform.processExecutor) {
4186
+ throw new Error("Governed process executor is not configured on execution host");
4187
+ }
4188
+ return this.platform.processExecutor;
4176
4189
  default:
4177
4190
  throw new Error(
4178
- `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, llm, embeddings, storage, logger, analytics, eventBus, invoke`
4191
+ `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, llm, embeddings, storage, logger, analytics, eventBus, invoke, processExecutor`
4179
4192
  );
4180
4193
  }
4181
4194
  }
@@ -5515,6 +5528,52 @@ Caused by: ${cause.stack}`;
5515
5528
  return new _LoggerProxy(this.proxyTransport, { ...this.boundContext, ...bindings });
5516
5529
  }
5517
5530
  };
5531
+ PROCESS_RPC_GRACE_MS = 5e3;
5532
+ CONTROL_RPC_TIMEOUT_MS = 5e3;
5533
+ MAX_TIMER_MS = 2147483647;
5534
+ ProcessExecutorProxy = class extends RemoteAdapter {
5535
+ constructor(transport) {
5536
+ super("processExecutor", transport);
5537
+ }
5538
+ capabilities() {
5539
+ return {
5540
+ platform: "other",
5541
+ processGroups: false,
5542
+ hardMemoryLimit: false,
5543
+ hardCpuLimit: false,
5544
+ processTreeAccounting: false,
5545
+ maxProcesses: false
5546
+ };
5547
+ }
5548
+ async execute(request) {
5549
+ const processId = request.processId ?? crypto.randomUUID();
5550
+ const { signal, ...serializableRequest } = request;
5551
+ let cancelled = false;
5552
+ const onAbort = () => {
5553
+ cancelled = true;
5554
+ void this.cancel(processId, "cancelled");
5555
+ };
5556
+ signal?.addEventListener("abort", onAbort, { once: true });
5557
+ try {
5558
+ const processTimeout = request.limits.timeoutMs + (request.limits.graceMs ?? 1e3);
5559
+ const rpcTimeout = Math.min(MAX_TIMER_MS, processTimeout + PROCESS_RPC_GRACE_MS);
5560
+ return await this.callRemote("execute", [{ ...serializableRequest, processId }], rpcTimeout);
5561
+ } catch (error) {
5562
+ void this.cancel(processId, "cancelled").catch(() => void 0);
5563
+ throw error;
5564
+ } finally {
5565
+ if (!cancelled) {
5566
+ signal?.removeEventListener("abort", onAbort);
5567
+ }
5568
+ }
5569
+ }
5570
+ async cancel(processId, reason = "cancelled") {
5571
+ await this.callRemote("cancel", [processId, reason], CONTROL_RPC_TIMEOUT_MS);
5572
+ }
5573
+ async shutdown() {
5574
+ await this.callRemote("shutdown", [], CONTROL_RPC_TIMEOUT_MS);
5575
+ }
5576
+ };
5518
5577
  }
5519
5578
  });
5520
5579
  function getLoggerMetadataFromHost(hostContext) {
@@ -6001,77 +6060,66 @@ function createShellAPI(options) {
6001
6060
  const { permissions, cwd } = options;
6002
6061
  const allowedCommands = permissions.shell?.allow ?? [];
6003
6062
  if (allowedCommands.length === 0) {
6004
- return {
6005
- async exec() {
6006
- throw new PermissionError("Shell execution not allowed");
6007
- }
6008
- };
6063
+ return { async exec() {
6064
+ throw new PermissionError("Shell execution not allowed");
6065
+ } };
6066
+ }
6067
+ const executor = options.processExecutor;
6068
+ if (!executor) {
6069
+ throw new Error("Governed process executor is unavailable in this execution host");
6009
6070
  }
6071
+ const identity = options.processIdentity ?? {
6072
+ executionId: "unknown-execution",
6073
+ requestId: "unknown-request",
6074
+ pluginId: "unknown-plugin"
6075
+ };
6076
+ const quotas = permissions.quotas ?? {};
6010
6077
  return {
6011
6078
  async exec(command, args = [], execOptions) {
6012
6079
  const fullCommand = `${command} ${args.join(" ")}`;
6013
6080
  for (const blocked of BLOCKED_COMMANDS) {
6014
6081
  if (fullCommand.includes(blocked)) {
6015
- throw new PermissionError(`Dangerous command blocked`, {
6016
- command: fullCommand,
6017
- blocked
6018
- });
6082
+ throw new PermissionError("Dangerous command blocked", { command: fullCommand, blocked });
6019
6083
  }
6020
6084
  }
6021
6085
  if (!allowedCommands.includes(command) && !allowedCommands.includes(path3__default.basename(command)) && !allowedCommands.includes("*")) {
6022
- throw new PermissionError(`Command not in whitelist`, {
6023
- command,
6024
- allowedCommands
6025
- });
6026
- }
6027
- const workingDir = execOptions?.cwd ?? cwd;
6028
- const timeout = execOptions?.timeout ?? 3e4;
6029
- const throwOnError = execOptions?.throwOnError ?? false;
6030
- return new Promise((resolve32, reject) => {
6031
- const child = child_process.spawn(command, args, {
6032
- cwd: workingDir,
6033
- env: {
6034
- ...process.env,
6035
- ...execOptions?.env
6036
- }
6037
- });
6038
- let stdout = "";
6039
- let stderr = "";
6040
- let timedOut = false;
6041
- const timeoutId = setTimeout(() => {
6042
- timedOut = true;
6043
- child.kill("SIGKILL");
6044
- }, timeout);
6045
- child.stdout?.on("data", (data) => {
6046
- stdout += data.toString();
6047
- });
6048
- child.stderr?.on("data", (data) => {
6049
- stderr += data.toString();
6050
- });
6051
- child.on("close", (code) => {
6052
- clearTimeout(timeoutId);
6053
- if (timedOut) {
6054
- reject(new Error(`Command timed out after ${timeout}ms`));
6055
- return;
6056
- }
6057
- const exitCode = code ?? 0;
6058
- const result = {
6059
- code: exitCode,
6060
- stdout,
6061
- stderr,
6062
- ok: exitCode === 0
6063
- };
6064
- if (throwOnError && exitCode !== 0) {
6065
- reject(new Error(`Command failed with code ${exitCode}: ${stderr}`));
6066
- } else {
6067
- resolve32(result);
6068
- }
6069
- });
6070
- child.on("error", (error) => {
6071
- clearTimeout(timeoutId);
6072
- reject(error);
6073
- });
6086
+ throw new PermissionError("Command not in whitelist", { command, allowedCommands });
6087
+ }
6088
+ const requestedTimeout = execOptions?.timeout ?? quotas.timeoutMs ?? 3e4;
6089
+ const timeoutMs = Math.min(requestedTimeout, quotas.timeoutMs ?? requestedTimeout);
6090
+ const result = await executor.execute({
6091
+ identity,
6092
+ command,
6093
+ args,
6094
+ cwd: execOptions?.cwd ?? cwd,
6095
+ env: execOptions?.env,
6096
+ signal: execOptions?.signal ?? options.signal,
6097
+ retry: execOptions?.retry,
6098
+ limits: {
6099
+ timeoutMs,
6100
+ cpuMs: quotas.cpuMs,
6101
+ memoryMb: quotas.memoryMb,
6102
+ maxProcesses: quotas.maxProcesses,
6103
+ maxConcurrent: permissions.shell?.maxConcurrent,
6104
+ maxOutputBytes: execOptions?.maxOutputBytes ?? quotas.maxOutputBytes
6105
+ }
6074
6106
  });
6107
+ const output = {
6108
+ code: result.code ?? -1,
6109
+ stdout: result.stdout,
6110
+ stderr: result.stderr,
6111
+ ok: result.ok,
6112
+ processId: result.processId,
6113
+ terminationReason: result.terminationReason,
6114
+ usage: result.usage,
6115
+ attempts: result.attempts
6116
+ };
6117
+ if (execOptions?.throwOnError && !output.ok) {
6118
+ const error = new Error(`Command failed with code ${output.code}: ${output.stderr}`);
6119
+ Object.assign(error, { code: "PROCESS_EXIT_NON_ZERO", result: output });
6120
+ throw error;
6121
+ }
6122
+ return output;
6075
6123
  }
6076
6124
  };
6077
6125
  }
@@ -6893,6 +6941,9 @@ function createPluginAPI(options) {
6893
6941
  cwd,
6894
6942
  outdir,
6895
6943
  permissions,
6944
+ processExecutor,
6945
+ processIdentity,
6946
+ signal,
6896
6947
  cache,
6897
6948
  eventEmitter,
6898
6949
  pluginInvoker,
@@ -6910,7 +6961,7 @@ function createPluginAPI(options) {
6910
6961
  lifecycle: createLifecycleAPI(cleanupStack),
6911
6962
  state: createStateAPI({ pluginId, tenantId, cache }),
6912
6963
  artifacts: createArtifactsAPI({ outdir }),
6913
- shell: createShellAPI({ permissions, cwd }),
6964
+ shell: createShellAPI({ permissions, cwd, processExecutor, processIdentity, signal }),
6914
6965
  events: eventEmitter ? createEventsAPI({ pluginId, emitter: eventEmitter }) : createNoopEventsAPI(),
6915
6966
  invoke: pluginInvoker ? createInvokeAPI({
6916
6967
  permissions,
@@ -7446,6 +7497,15 @@ function createPluginContextV3(options) {
7446
7497
  cwd,
7447
7498
  outdir: finalOutdir,
7448
7499
  permissions: descriptor.permissions,
7500
+ processExecutor: extendedPlatform.processExecutor,
7501
+ processIdentity: {
7502
+ executionId: executionId ?? requestId,
7503
+ requestId,
7504
+ pluginId: descriptor.pluginId,
7505
+ handlerId: descriptor.handlerId,
7506
+ tenantId: descriptor.tenantId
7507
+ },
7508
+ signal,
7449
7509
  cache: enrichedPlatform.cache,
7450
7510
  // Use governed cache, not raw
7451
7511
  eventEmitter,
@@ -7701,6 +7761,29 @@ ${possiblePaths.join("\n")}`
7701
7761
  });
7702
7762
  });
7703
7763
  }
7764
+ function killTree(child, signal) {
7765
+ if (!child.pid) {
7766
+ return;
7767
+ }
7768
+ try {
7769
+ if (process.platform === "darwin" || process.platform === "linux") {
7770
+ process.kill(-child.pid, signal);
7771
+ } else {
7772
+ child.kill(signal);
7773
+ }
7774
+ } catch {
7775
+ try {
7776
+ child.kill(signal);
7777
+ } catch {
7778
+ }
7779
+ }
7780
+ }
7781
+ function createDefaultProcessExecutor(logger) {
7782
+ if (process.platform === "darwin") {
7783
+ return new DarwinProcessBackend(logger);
7784
+ }
7785
+ return new LinuxProcessBackend(logger);
7786
+ }
7704
7787
  async function resolveAdapterMiddlewares(rawDecls, logger) {
7705
7788
  const result = [];
7706
7789
  for (const { pkgRoot, decl } of rawDecls) {
@@ -7734,7 +7817,7 @@ function makeAssemblyHook(getLogger) {
7734
7817
  getLogger?.()
7735
7818
  );
7736
7819
  }
7737
- var PluginError, PermissionError, TimeoutError2, AbortError, PLATFORM_CONTEXT_KEY, platformContext, RUNTIME_CONTEXT_KEY, runtimeContext, HARDCODED_DENIED_PATTERNS, ALWAYS_ALLOWED, BLOCKED_COMMANDS, ANALYTICS_EVENT, EVENT_BUS_TOPIC, NAMESPACE_SEPARATOR, KV_NAMESPACE_SEPARATOR, validateName, wrapLogger, wrapLlm, wrapEmbeddings, wrapVectorStore, wrapCache, wrapStorage, wrapNotifier, ADAPTER_REGISTRY, PIPELINE_SLOTS, SLOT_ORDER, NOOP_LIFECYCLE, ANSI_RE;
7820
+ var PluginError, PermissionError, TimeoutError2, AbortError, PLATFORM_CONTEXT_KEY, platformContext, RUNTIME_CONTEXT_KEY, runtimeContext, HARDCODED_DENIED_PATTERNS, ALWAYS_ALLOWED, BLOCKED_COMMANDS, ANALYTICS_EVENT, EVENT_BUS_TOPIC, NAMESPACE_SEPARATOR, KV_NAMESPACE_SEPARATOR, validateName, wrapLogger, wrapLlm, wrapEmbeddings, wrapVectorStore, wrapCache, wrapStorage, wrapNotifier, ADAPTER_REGISTRY, PIPELINE_SLOTS, SLOT_ORDER, NOOP_LIFECYCLE, ANSI_RE, GovernedProcessError, NodeProcessBackend, DarwinProcessBackend, LinuxProcessBackend, registered, BrokeredProcessExecutor;
7738
7821
  var init_dist6 = __esm({
7739
7822
  "../../../core/plugin-runtime/dist/index.js"() {
7740
7823
  init_dist();
@@ -7829,7 +7912,6 @@ var init_dist6 = __esm({
7829
7912
  "mkfs",
7830
7913
  "dd if=",
7831
7914
  ":(){:|:&};:",
7832
- // Fork bomb
7833
7915
  "chmod -R 777 /",
7834
7916
  "chown -R",
7835
7917
  "> /dev/sda",
@@ -8203,6 +8285,434 @@ var init_dist6 = __esm({
8203
8285
  }
8204
8286
  };
8205
8287
  ANSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
8288
+ GovernedProcessError = class extends Error {
8289
+ code;
8290
+ details;
8291
+ constructor(code, message, details = {}) {
8292
+ super(message);
8293
+ this.name = "GovernedProcessError";
8294
+ this.code = code;
8295
+ this.details = details;
8296
+ }
8297
+ };
8298
+ NodeProcessBackend = class {
8299
+ constructor(logger) {
8300
+ this.logger = logger;
8301
+ }
8302
+ logger;
8303
+ active = /* @__PURE__ */ new Set();
8304
+ cancellers = /* @__PURE__ */ new Map();
8305
+ shuttingDown = false;
8306
+ configureProcess(_pid, _request) {
8307
+ return () => {
8308
+ };
8309
+ }
8310
+ treePids(rootPid) {
8311
+ if (process.platform !== "linux") {
8312
+ return [rootPid];
8313
+ }
8314
+ const children = /* @__PURE__ */ new Map();
8315
+ let entries;
8316
+ try {
8317
+ entries = fs5.readdirSync("/proc").filter((entry) => /^\d+$/.test(entry));
8318
+ } catch {
8319
+ return [rootPid];
8320
+ }
8321
+ for (const entry of entries) {
8322
+ const pid = Number(entry);
8323
+ try {
8324
+ const stat3 = fs5.readFileSync(`/proc/${pid}/stat`, "utf8");
8325
+ const close = stat3.lastIndexOf(")");
8326
+ const ppid = Number(stat3.slice(close + 2).split(" ")[1]);
8327
+ const list = children.get(ppid) ?? [];
8328
+ list.push(pid);
8329
+ children.set(ppid, list);
8330
+ } catch {
8331
+ }
8332
+ }
8333
+ const result = [rootPid];
8334
+ for (let i = 0; i < result.length; i++) {
8335
+ result.push(...children.get(result[i]) ?? []);
8336
+ }
8337
+ return result;
8338
+ }
8339
+ snapshot(pid) {
8340
+ const pids = this.treePids(pid);
8341
+ let memoryMb = 0;
8342
+ let cpuMs = 0;
8343
+ for (const current of pids) {
8344
+ if (process.platform !== "linux") {
8345
+ continue;
8346
+ }
8347
+ try {
8348
+ const status = fs5.readFileSync(`/proc/${current}/status`, "utf8");
8349
+ const rss = /^VmRSS:\s+(\d+)\s+kB$/m.exec(status);
8350
+ memoryMb += rss ? Number(rss[1]) / 1024 : 0;
8351
+ const stat3 = fs5.readFileSync(`/proc/${current}/stat`, "utf8");
8352
+ const close = stat3.lastIndexOf(")");
8353
+ const fields = stat3.slice(close + 2).split(" ");
8354
+ const ticks = Number(fields[11]) + Number(fields[12]);
8355
+ cpuMs += ticks / 100 * 1e3;
8356
+ } catch {
8357
+ }
8358
+ }
8359
+ return { cpuMs, memoryMb, processCount: pids.length };
8360
+ }
8361
+ async execute(request) {
8362
+ if (this.shuttingDown) {
8363
+ throw new GovernedProcessError("PROCESS_CANCELLED", "Process backend is shutting down");
8364
+ }
8365
+ const attempts = request.retry?.maxAttempts ?? 1;
8366
+ if (attempts > 1 && !request.retry?.idempotent) {
8367
+ throw new GovernedProcessError("PROCESS_SPAWN_FAILED", "Retrying shell commands requires idempotent=true");
8368
+ }
8369
+ let lastError;
8370
+ for (let attempt = 1; attempt <= attempts; attempt++) {
8371
+ try {
8372
+ return await this.runOnce(request, attempt);
8373
+ } catch (error) {
8374
+ lastError = error;
8375
+ if (attempt === attempts) {
8376
+ break;
8377
+ }
8378
+ if (!(error instanceof GovernedProcessError) || error.code !== "PROCESS_SPAWN_FAILED") {
8379
+ break;
8380
+ }
8381
+ const base = request.retry?.initialDelayMs ?? 250;
8382
+ const max = request.retry?.maxDelayMs ?? 5e3;
8383
+ const jitter = request.retry?.jitter ?? 0.1;
8384
+ const delay = Math.min(max, base * 2 ** (attempt - 1));
8385
+ await new Promise((resolve32) => {
8386
+ setTimeout(resolve32, Math.floor(delay * (1 + Math.random() * jitter)));
8387
+ });
8388
+ }
8389
+ }
8390
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
8391
+ }
8392
+ runOnce(request, attempt) {
8393
+ const started = Date.now();
8394
+ const processId = request.processId ?? crypto.randomUUID();
8395
+ this.logger?.info("process.execution.started", {
8396
+ component: "process-executor",
8397
+ operation: "execute",
8398
+ processId,
8399
+ executionId: request.identity.executionId,
8400
+ requestId: request.identity.requestId,
8401
+ pluginId: request.identity.pluginId,
8402
+ handlerId: request.identity.handlerId,
8403
+ command: request.command,
8404
+ argCount: request.args.length,
8405
+ cwd: request.cwd,
8406
+ attempt,
8407
+ limits: request.limits
8408
+ });
8409
+ const maxOutput = request.limits.maxOutputBytes ?? 8 * 1024 * 1024;
8410
+ const graceMs = request.limits.graceMs ?? 1e3;
8411
+ return new Promise((resolve32, reject) => {
8412
+ let child;
8413
+ try {
8414
+ child = child_process.spawn(request.command, request.args, {
8415
+ cwd: request.cwd,
8416
+ env: { ...process.env, ...request.env },
8417
+ detached: process.platform === "darwin" || process.platform === "linux",
8418
+ shell: false,
8419
+ stdio: ["ignore", "pipe", "pipe"]
8420
+ });
8421
+ } catch (error) {
8422
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", `Failed to spawn ${request.command}`, { cause: String(error) }));
8423
+ return;
8424
+ }
8425
+ child.once("error", (error) => {
8426
+ if (!child.pid) {
8427
+ this.logger?.error("process.execution.failed", error, {
8428
+ component: "process-executor",
8429
+ operation: "execute",
8430
+ executionId: request.identity.executionId,
8431
+ requestId: request.identity.requestId,
8432
+ pluginId: request.identity.pluginId,
8433
+ command: request.command
8434
+ });
8435
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", error.message));
8436
+ }
8437
+ });
8438
+ if (!child.pid) {
8439
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", "Process did not receive a PID"));
8440
+ return;
8441
+ }
8442
+ const pid = child.pid;
8443
+ this.active.add(pid);
8444
+ let cleanupProcessConfig = () => {
8445
+ };
8446
+ try {
8447
+ cleanupProcessConfig = this.configureProcess(pid, request);
8448
+ } catch (error) {
8449
+ killTree(child, "SIGKILL");
8450
+ this.active.delete(pid);
8451
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", "Unable to apply process limits", { cause: String(error) }));
8452
+ return;
8453
+ }
8454
+ let stdout = "";
8455
+ let stderr = "";
8456
+ let stdoutBytes = 0;
8457
+ let stderrBytes = 0;
8458
+ let reason = "completed";
8459
+ let peakMemoryMb = 0;
8460
+ let peakCpuMs = 0;
8461
+ let peakProcessCount = 1;
8462
+ let settled = false;
8463
+ const finish = (code, signal) => {
8464
+ if (settled) {
8465
+ return;
8466
+ }
8467
+ settled = true;
8468
+ this.active.delete(pid);
8469
+ this.cancellers.delete(processId);
8470
+ cleanupProcessConfig();
8471
+ clearTimeout(timeout);
8472
+ clearInterval(monitor);
8473
+ const usage = {
8474
+ wallTimeMs: Date.now() - started,
8475
+ cpuMs: peakCpuMs,
8476
+ peakMemoryMb,
8477
+ processCount: peakProcessCount,
8478
+ stdoutBytes,
8479
+ stderrBytes
8480
+ };
8481
+ const result = {
8482
+ processId,
8483
+ code,
8484
+ signal: signal ?? void 0,
8485
+ stdout,
8486
+ stderr,
8487
+ ok: reason === "completed" && code === 0,
8488
+ terminationReason: reason,
8489
+ usage,
8490
+ attempts: attempt
8491
+ };
8492
+ this.logger?.info("process.execution.finished", {
8493
+ component: "process-executor",
8494
+ operation: "execute",
8495
+ processId,
8496
+ executionId: request.identity.executionId,
8497
+ requestId: request.identity.requestId,
8498
+ pluginId: request.identity.pluginId,
8499
+ command: request.command,
8500
+ ok: result.ok,
8501
+ code: result.code,
8502
+ terminationReason: result.terminationReason,
8503
+ usage: result.usage,
8504
+ attempts: result.attempts
8505
+ });
8506
+ if (reason === "completed") {
8507
+ resolve32(result);
8508
+ return;
8509
+ }
8510
+ const codes = {
8511
+ timeout: "PROCESS_TIMEOUT",
8512
+ cancelled: "PROCESS_CANCELLED",
8513
+ memory_limit: "PROCESS_MEMORY_LIMIT",
8514
+ cpu_limit: "PROCESS_CPU_LIMIT",
8515
+ process_limit: "PROCESS_LIMIT",
8516
+ output_limit: "PROCESS_OUTPUT_LIMIT",
8517
+ shutdown: "PROCESS_CANCELLED"
8518
+ };
8519
+ const governedError = new GovernedProcessError(codes[reason], `Process terminated: ${reason}`, { result });
8520
+ this.logger?.warn("process.execution.terminated", {
8521
+ component: "process-executor",
8522
+ operation: "execute",
8523
+ processId,
8524
+ executionId: request.identity.executionId,
8525
+ requestId: request.identity.requestId,
8526
+ pluginId: request.identity.pluginId,
8527
+ terminationReason: reason,
8528
+ usage
8529
+ });
8530
+ reject(governedError);
8531
+ };
8532
+ const terminate = (next) => {
8533
+ if (settled) {
8534
+ return;
8535
+ }
8536
+ reason = next;
8537
+ killTree(child, "SIGTERM");
8538
+ setTimeout(() => killTree(child, "SIGKILL"), graceMs);
8539
+ };
8540
+ this.cancellers.set(processId, terminate);
8541
+ const timeout = setTimeout(() => terminate("timeout"), request.limits.timeoutMs);
8542
+ const monitor = setInterval(() => {
8543
+ const sample = this.snapshot(pid);
8544
+ peakMemoryMb = Math.max(peakMemoryMb, sample.memoryMb);
8545
+ peakCpuMs = Math.max(peakCpuMs, sample.cpuMs);
8546
+ peakProcessCount = Math.max(peakProcessCount, sample.processCount);
8547
+ if (request.limits.memoryMb && sample.memoryMb > request.limits.memoryMb) {
8548
+ terminate("memory_limit");
8549
+ } else if (request.limits.cpuMs && sample.cpuMs > request.limits.cpuMs) {
8550
+ terminate("cpu_limit");
8551
+ } else if (request.limits.maxProcesses && sample.processCount > request.limits.maxProcesses) {
8552
+ terminate("process_limit");
8553
+ }
8554
+ }, 50);
8555
+ const abort = () => terminate("cancelled");
8556
+ request.signal?.addEventListener("abort", abort, { once: true });
8557
+ const append = (stream, chunk) => {
8558
+ if (stream === "stdout") {
8559
+ stdoutBytes += chunk.byteLength;
8560
+ stdout += chunk.toString();
8561
+ } else {
8562
+ stderrBytes += chunk.byteLength;
8563
+ stderr += chunk.toString();
8564
+ }
8565
+ if (stdoutBytes + stderrBytes > maxOutput) {
8566
+ terminate("output_limit");
8567
+ }
8568
+ };
8569
+ child.stdout?.on("data", (chunk) => append("stdout", chunk));
8570
+ child.stderr?.on("data", (chunk) => append("stderr", chunk));
8571
+ child.once("error", (error) => {
8572
+ if (!settled) {
8573
+ this.logger?.error("process.execution.failed", error, {
8574
+ component: "process-executor",
8575
+ operation: "execute",
8576
+ processId,
8577
+ executionId: request.identity.executionId,
8578
+ requestId: request.identity.requestId,
8579
+ pluginId: request.identity.pluginId,
8580
+ command: request.command
8581
+ });
8582
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", error.message));
8583
+ }
8584
+ });
8585
+ child.once("close", (code, signal) => {
8586
+ request.signal?.removeEventListener("abort", abort);
8587
+ finish(code, signal);
8588
+ });
8589
+ });
8590
+ }
8591
+ async cancel(processId, reason = "cancelled") {
8592
+ const cancel = this.cancellers.get(processId);
8593
+ if (cancel) {
8594
+ cancel(reason);
8595
+ }
8596
+ if (reason === "shutdown") {
8597
+ this.cancellers.delete(processId);
8598
+ }
8599
+ }
8600
+ async shutdown() {
8601
+ this.shuttingDown = true;
8602
+ for (const cancel of this.cancellers.values()) {
8603
+ cancel("shutdown");
8604
+ }
8605
+ for (const pid of this.active) {
8606
+ try {
8607
+ process.kill(-pid, "SIGTERM");
8608
+ } catch {
8609
+ }
8610
+ }
8611
+ this.active.clear();
8612
+ this.cancellers.clear();
8613
+ }
8614
+ };
8615
+ DarwinProcessBackend = class extends NodeProcessBackend {
8616
+ capabilities() {
8617
+ return { platform: "darwin", processGroups: true, hardMemoryLimit: false, hardCpuLimit: false, processTreeAccounting: false, maxProcesses: false };
8618
+ }
8619
+ };
8620
+ LinuxProcessBackend = class extends NodeProcessBackend {
8621
+ cgroupRoot = "/sys/fs/cgroup";
8622
+ cgroupAvailable() {
8623
+ try {
8624
+ return fs5.existsSync(path3__default.join(this.cgroupRoot, "cgroup.controllers")) && fs5.existsSync(path3__default.join(this.cgroupRoot, "cgroup.procs")) && fs5.accessSync(this.cgroupRoot, fs5.constants.W_OK) === void 0;
8625
+ } catch {
8626
+ return false;
8627
+ }
8628
+ }
8629
+ capabilities() {
8630
+ const cgroup = this.cgroupAvailable();
8631
+ return { platform: "linux", processGroups: true, hardMemoryLimit: cgroup, hardCpuLimit: false, processTreeAccounting: true, maxProcesses: cgroup };
8632
+ }
8633
+ configureProcess(pid, request) {
8634
+ if (!this.cgroupAvailable()) {
8635
+ return () => {
8636
+ };
8637
+ }
8638
+ const group = path3__default.join(this.cgroupRoot, `kb-plugin-${pid}`);
8639
+ fs5.mkdirSync(group);
8640
+ if (request.limits.memoryMb) {
8641
+ fs5.writeFileSync(path3__default.join(group, "memory.max"), String(Math.floor(request.limits.memoryMb * 1024 * 1024)));
8642
+ }
8643
+ if (request.limits.maxProcesses) {
8644
+ fs5.writeFileSync(path3__default.join(group, "pids.max"), String(Math.floor(request.limits.maxProcesses)));
8645
+ }
8646
+ fs5.writeFileSync(path3__default.join(group, "cgroup.procs"), String(pid));
8647
+ return () => {
8648
+ try {
8649
+ fs5.readFileSync(path3__default.join(group, "cgroup.procs"), "utf8");
8650
+ fs5.rmSync(group, { recursive: true, force: true });
8651
+ } catch {
8652
+ }
8653
+ };
8654
+ }
8655
+ };
8656
+ registered = /* @__PURE__ */ new WeakMap();
8657
+ BrokeredProcessExecutor = class {
8658
+ constructor(broker, delegate, logger) {
8659
+ this.broker = broker;
8660
+ this.delegate = delegate;
8661
+ this.logger = logger;
8662
+ }
8663
+ broker;
8664
+ delegate;
8665
+ logger;
8666
+ capabilities() {
8667
+ return this.delegate.capabilities();
8668
+ }
8669
+ async execute(request) {
8670
+ const resource = `process:shell:${request.identity.pluginId}`;
8671
+ const resources = registered.get(this.broker) ?? /* @__PURE__ */ new Set();
8672
+ if (!resources.has(resource)) {
8673
+ this.broker.registerLimit(resource, { maxConcurrentRequests: request.limits.maxConcurrent ?? 1 });
8674
+ resources.add(resource);
8675
+ registered.set(this.broker, resources);
8676
+ }
8677
+ const deadline = Date.now() + request.limits.timeoutMs;
8678
+ let lastWait = 25;
8679
+ while (Date.now() < deadline) {
8680
+ if (request.signal?.aborted) {
8681
+ throw new GovernedProcessError("PROCESS_CANCELLED", "Shell admission was cancelled");
8682
+ }
8683
+ const acquired = await this.broker.tryAcquire(resource);
8684
+ if (acquired.allowed) {
8685
+ this.logger?.debug("process.execution.admitted", {
8686
+ component: "process-executor",
8687
+ operation: "admission",
8688
+ resource,
8689
+ executionId: request.identity.executionId,
8690
+ requestId: request.identity.requestId,
8691
+ pluginId: request.identity.pluginId
8692
+ });
8693
+ try {
8694
+ return await this.delegate.execute(request);
8695
+ } finally {
8696
+ await acquired.release();
8697
+ }
8698
+ }
8699
+ await new Promise((resolve32) => {
8700
+ setTimeout(resolve32, Math.min(lastWait, acquired.waitTimeMs ?? lastWait));
8701
+ });
8702
+ lastWait = Math.min(lastWait * 2, 500);
8703
+ }
8704
+ throw new GovernedProcessError("PROCESS_ADMISSION_TIMEOUT", "Shell capacity was not available before execution deadline", {
8705
+ resource,
8706
+ timeoutMs: request.limits.timeoutMs
8707
+ });
8708
+ }
8709
+ async shutdown() {
8710
+ await this.delegate.shutdown();
8711
+ }
8712
+ async cancel(processId, reason) {
8713
+ await this.delegate.cancel(processId, reason);
8714
+ }
8715
+ };
8206
8716
  }
8207
8717
  });
8208
8718
  function getOrCreatePlatformContext2() {
@@ -15927,11 +16437,11 @@ var require_codegen = __commonJS({
15927
16437
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
15928
16438
  return `${varKind} ${this.name}${rhs};` + _n;
15929
16439
  }
15930
- optimizeNames(names, constants2) {
16440
+ optimizeNames(names, constants3) {
15931
16441
  if (!names[this.name.str])
15932
16442
  return;
15933
16443
  if (this.rhs)
15934
- this.rhs = optimizeExpr(this.rhs, names, constants2);
16444
+ this.rhs = optimizeExpr(this.rhs, names, constants3);
15935
16445
  return this;
15936
16446
  }
15937
16447
  get names() {
@@ -15948,10 +16458,10 @@ var require_codegen = __commonJS({
15948
16458
  render({ _n }) {
15949
16459
  return `${this.lhs} = ${this.rhs};` + _n;
15950
16460
  }
15951
- optimizeNames(names, constants2) {
16461
+ optimizeNames(names, constants3) {
15952
16462
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
15953
16463
  return;
15954
- this.rhs = optimizeExpr(this.rhs, names, constants2);
16464
+ this.rhs = optimizeExpr(this.rhs, names, constants3);
15955
16465
  return this;
15956
16466
  }
15957
16467
  get names() {
@@ -16012,8 +16522,8 @@ var require_codegen = __commonJS({
16012
16522
  optimizeNodes() {
16013
16523
  return `${this.code}` ? this : void 0;
16014
16524
  }
16015
- optimizeNames(names, constants2) {
16016
- this.code = optimizeExpr(this.code, names, constants2);
16525
+ optimizeNames(names, constants3) {
16526
+ this.code = optimizeExpr(this.code, names, constants3);
16017
16527
  return this;
16018
16528
  }
16019
16529
  get names() {
@@ -16042,12 +16552,12 @@ var require_codegen = __commonJS({
16042
16552
  }
16043
16553
  return nodes.length > 0 ? this : void 0;
16044
16554
  }
16045
- optimizeNames(names, constants2) {
16555
+ optimizeNames(names, constants3) {
16046
16556
  const { nodes } = this;
16047
16557
  let i = nodes.length;
16048
16558
  while (i--) {
16049
16559
  const n = nodes[i];
16050
- if (n.optimizeNames(names, constants2))
16560
+ if (n.optimizeNames(names, constants3))
16051
16561
  continue;
16052
16562
  subtractNames(names, n.names);
16053
16563
  nodes.splice(i, 1);
@@ -16100,12 +16610,12 @@ var require_codegen = __commonJS({
16100
16610
  return void 0;
16101
16611
  return this;
16102
16612
  }
16103
- optimizeNames(names, constants2) {
16613
+ optimizeNames(names, constants3) {
16104
16614
  var _a;
16105
- this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
16106
- if (!(super.optimizeNames(names, constants2) || this.else))
16615
+ this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants3);
16616
+ if (!(super.optimizeNames(names, constants3) || this.else))
16107
16617
  return;
16108
- this.condition = optimizeExpr(this.condition, names, constants2);
16618
+ this.condition = optimizeExpr(this.condition, names, constants3);
16109
16619
  return this;
16110
16620
  }
16111
16621
  get names() {
@@ -16128,10 +16638,10 @@ var require_codegen = __commonJS({
16128
16638
  render(opts) {
16129
16639
  return `for(${this.iteration})` + super.render(opts);
16130
16640
  }
16131
- optimizeNames(names, constants2) {
16132
- if (!super.optimizeNames(names, constants2))
16641
+ optimizeNames(names, constants3) {
16642
+ if (!super.optimizeNames(names, constants3))
16133
16643
  return;
16134
- this.iteration = optimizeExpr(this.iteration, names, constants2);
16644
+ this.iteration = optimizeExpr(this.iteration, names, constants3);
16135
16645
  return this;
16136
16646
  }
16137
16647
  get names() {
@@ -16167,10 +16677,10 @@ var require_codegen = __commonJS({
16167
16677
  render(opts) {
16168
16678
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
16169
16679
  }
16170
- optimizeNames(names, constants2) {
16171
- if (!super.optimizeNames(names, constants2))
16680
+ optimizeNames(names, constants3) {
16681
+ if (!super.optimizeNames(names, constants3))
16172
16682
  return;
16173
- this.iterable = optimizeExpr(this.iterable, names, constants2);
16683
+ this.iterable = optimizeExpr(this.iterable, names, constants3);
16174
16684
  return this;
16175
16685
  }
16176
16686
  get names() {
@@ -16212,11 +16722,11 @@ var require_codegen = __commonJS({
16212
16722
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
16213
16723
  return this;
16214
16724
  }
16215
- optimizeNames(names, constants2) {
16725
+ optimizeNames(names, constants3) {
16216
16726
  var _a, _b;
16217
- super.optimizeNames(names, constants2);
16218
- (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants2);
16219
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants2);
16727
+ super.optimizeNames(names, constants3);
16728
+ (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants3);
16729
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants3);
16220
16730
  return this;
16221
16731
  }
16222
16732
  get names() {
@@ -16517,7 +17027,7 @@ var require_codegen = __commonJS({
16517
17027
  function addExprNames(names, from) {
16518
17028
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
16519
17029
  }
16520
- function optimizeExpr(expr, names, constants2) {
17030
+ function optimizeExpr(expr, names, constants3) {
16521
17031
  if (expr instanceof code_1.Name)
16522
17032
  return replaceName(expr);
16523
17033
  if (!canOptimize(expr))
@@ -16532,14 +17042,14 @@ var require_codegen = __commonJS({
16532
17042
  return items;
16533
17043
  }, []));
16534
17044
  function replaceName(n) {
16535
- const c = constants2[n.str];
17045
+ const c = constants3[n.str];
16536
17046
  if (c === void 0 || names[n.str] !== 1)
16537
17047
  return n;
16538
17048
  delete names[n.str];
16539
17049
  return c;
16540
17050
  }
16541
17051
  function canOptimize(e) {
16542
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants2[c.str] !== void 0);
17052
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
16543
17053
  }
16544
17054
  }
16545
17055
  function subtractNames(names, from) {
@@ -18601,15 +19111,14 @@ var require_data = __commonJS({
18601
19111
  }
18602
19112
  });
18603
19113
 
18604
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js
19114
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js
18605
19115
  var require_utils = __commonJS({
18606
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
19116
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
18607
19117
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
18608
19118
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
18609
19119
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
18610
19120
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
18611
19121
  var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
18612
- var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/?]$/iu);
18613
19122
  function stringArrayToHexStripped(input) {
18614
19123
  let acc = "";
18615
19124
  let code = 0;
@@ -18752,7 +19261,7 @@ var require_utils = __commonJS({
18752
19261
  continue;
18753
19262
  }
18754
19263
  } else if (input[0] === "/") {
18755
- if (input[1] === ".") {
19264
+ if (input[1] === "." || input[1] === "/") {
18756
19265
  output.push("/");
18757
19266
  break;
18758
19267
  }
@@ -18834,30 +19343,10 @@ var require_utils = __commonJS({
18834
19343
  }
18835
19344
  return output;
18836
19345
  }
18837
- var BYTE_HEX = new Array(256);
18838
- {
18839
- const HEX_DIGITS = "0123456789ABCDEF";
18840
- for (let i = 0; i < 256; i++) {
18841
- BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
18842
- }
18843
- }
18844
- function isEscapeSafe(cp2) {
18845
- return cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 === 42 || cp2 === 43 || cp2 === 45 || cp2 === 46 || cp2 === 47 || cp2 === 64 || cp2 === 95;
18846
- }
18847
- function percentEncodeNonAscii(cp2) {
18848
- if (cp2 < 2048) {
18849
- return BYTE_HEX[192 | cp2 >> 6] + BYTE_HEX[128 | cp2 & 63];
18850
- }
18851
- if (cp2 < 65536) {
18852
- return BYTE_HEX[224 | cp2 >> 12] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
18853
- }
18854
- return BYTE_HEX[240 | cp2 >> 18] + BYTE_HEX[128 | cp2 >> 12 & 63] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
18855
- }
18856
19346
  function normalizePathEncoding(input) {
18857
19347
  let output = "";
18858
19348
  for (let i = 0; i < input.length; i++) {
18859
- const ch = input[i];
18860
- if (ch === "%" && i + 2 < input.length) {
19349
+ if (input[i] === "%" && i + 2 < input.length) {
18861
19350
  const hex = input.slice(i + 1, i + 3);
18862
19351
  if (isHexPair(hex)) {
18863
19352
  const normalizedHex = hex.toUpperCase();
@@ -18871,66 +19360,10 @@ var require_utils = __commonJS({
18871
19360
  continue;
18872
19361
  }
18873
19362
  }
18874
- if (isPathCharacter(ch)) {
18875
- output += ch;
19363
+ if (isPathCharacter(input[i])) {
19364
+ output += input[i];
18876
19365
  } else {
18877
- const code = input.charCodeAt(i);
18878
- if (code < 128) {
18879
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
18880
- } else if (code < 55296 || code > 57343) {
18881
- output += percentEncodeNonAscii(code);
18882
- } else if (code <= 56319 && i + 1 < input.length) {
18883
- const low = input.charCodeAt(i + 1);
18884
- if (low >= 56320 && low <= 57343) {
18885
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
18886
- i++;
18887
- } else {
18888
- output += percentEncodeNonAscii(65533);
18889
- }
18890
- } else {
18891
- output += percentEncodeNonAscii(65533);
18892
- }
18893
- }
18894
- }
18895
- return output;
18896
- }
18897
- function normalizeQueryFragmentEncoding(input) {
18898
- let output = "";
18899
- for (let i = 0; i < input.length; i++) {
18900
- const ch = input[i];
18901
- if (ch === "%" && i + 2 < input.length) {
18902
- const hex = input.slice(i + 1, i + 3);
18903
- if (isHexPair(hex)) {
18904
- const normalizedHex = hex.toUpperCase();
18905
- const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
18906
- if (isUnreserved(decoded)) {
18907
- output += decoded;
18908
- } else {
18909
- output += "%" + normalizedHex;
18910
- }
18911
- i += 2;
18912
- continue;
18913
- }
18914
- }
18915
- if (isQueryFragmentCharacter(ch)) {
18916
- output += ch;
18917
- } else {
18918
- const code = input.charCodeAt(i);
18919
- if (code < 128) {
18920
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
18921
- } else if (code < 55296 || code > 57343) {
18922
- output += percentEncodeNonAscii(code);
18923
- } else if (code <= 56319 && i + 1 < input.length) {
18924
- const low = input.charCodeAt(i + 1);
18925
- if (low >= 56320 && low <= 57343) {
18926
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
18927
- i++;
18928
- } else {
18929
- output += percentEncodeNonAscii(65533);
18930
- }
18931
- } else {
18932
- output += percentEncodeNonAscii(65533);
18933
- }
19366
+ output += escape(input[i]);
18934
19367
  }
18935
19368
  }
18936
19369
  return output;
@@ -18938,8 +19371,7 @@ var require_utils = __commonJS({
18938
19371
  function escapePreservingEscapes(input) {
18939
19372
  let output = "";
18940
19373
  for (let i = 0; i < input.length; i++) {
18941
- const ch = input[i];
18942
- if (ch === "%" && i + 2 < input.length) {
19374
+ if (input[i] === "%" && i + 2 < input.length) {
18943
19375
  const hex = input.slice(i + 1, i + 3);
18944
19376
  if (isHexPair(hex)) {
18945
19377
  output += "%" + hex.toUpperCase();
@@ -18947,22 +19379,7 @@ var require_utils = __commonJS({
18947
19379
  continue;
18948
19380
  }
18949
19381
  }
18950
- const code = input.charCodeAt(i);
18951
- if (code < 128) {
18952
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
18953
- } else if (code < 55296 || code > 57343) {
18954
- output += percentEncodeNonAscii(code);
18955
- } else if (code <= 56319 && i + 1 < input.length) {
18956
- const low = input.charCodeAt(i + 1);
18957
- if (low >= 56320 && low <= 57343) {
18958
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
18959
- i++;
18960
- } else {
18961
- output += percentEncodeNonAscii(65533);
18962
- }
18963
- } else {
18964
- output += percentEncodeNonAscii(65533);
18965
- }
19382
+ output += escape(input[i]);
18966
19383
  }
18967
19384
  return output;
18968
19385
  }
@@ -18996,7 +19413,6 @@ var require_utils = __commonJS({
18996
19413
  reescapeHostDelimiters,
18997
19414
  normalizePercentEncoding,
18998
19415
  normalizePathEncoding,
18999
- normalizeQueryFragmentEncoding,
19000
19416
  escapePreservingEscapes,
19001
19417
  removeDotSegments,
19002
19418
  isIPv4,
@@ -19007,9 +19423,9 @@ var require_utils = __commonJS({
19007
19423
  }
19008
19424
  });
19009
19425
 
19010
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js
19426
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js
19011
19427
  var require_schemes = __commonJS({
19012
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
19428
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
19013
19429
  var { isUUID } = require_utils();
19014
19430
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
19015
19431
  var supportedSchemeNames = (
@@ -19216,10 +19632,10 @@ var require_schemes = __commonJS({
19216
19632
  }
19217
19633
  });
19218
19634
 
19219
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js
19635
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js
19220
19636
  var require_fast_uri = __commonJS({
19221
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js"(exports$1, module) {
19222
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, normalizeQueryFragmentEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
19637
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js"(exports$1, module) {
19638
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
19223
19639
  var { SCHEMES, getSchemeHandler } = require_schemes();
19224
19640
  function normalize2(uri, options) {
19225
19641
  if (typeof uri === "string") {
@@ -19233,7 +19649,12 @@ var require_fast_uri = __commonJS({
19233
19649
  }
19234
19650
  function resolve6(baseURI, relativeURI, options) {
19235
19651
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
19236
- const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
19652
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
19653
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
19654
+ if (baseMalformed || relativeMalformed) {
19655
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
19656
+ }
19657
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
19237
19658
  schemelessOptions.skipEscape = true;
19238
19659
  return serialize2(resolved, schemelessOptions);
19239
19660
  }
@@ -19359,6 +19780,7 @@ var require_fast_uri = __commonJS({
19359
19780
  }
19360
19781
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
19361
19782
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
19783
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
19362
19784
  function getParseError(parsed, matches) {
19363
19785
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
19364
19786
  return 'URI path must start with "/" when authority is present.';
@@ -19393,9 +19815,23 @@ var require_fast_uri = __commonJS({
19393
19815
  parsed.error = "URI authority must not contain a literal backslash.";
19394
19816
  malformedAuthorityOrPort = true;
19395
19817
  }
19818
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
19819
+ if (introducerMatch !== null) {
19820
+ const region = introducerMatch[1];
19821
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
19822
+ if (normalizedRegion.length >= 2) {
19823
+ if (normalizedRegion.slice(0, 2) !== "//") {
19824
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
19825
+ malformedAuthorityOrPort = true;
19826
+ } else if (region.length !== normalizedRegion.length) {
19827
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
19828
+ malformedAuthorityOrPort = true;
19829
+ }
19830
+ }
19831
+ }
19396
19832
  const matches = uri.match(URI_PARSE);
19397
19833
  if (matches) {
19398
- parsed.scheme = matches[1] === void 0 ? void 0 : matches[1].toLowerCase();
19834
+ parsed.scheme = matches[1];
19399
19835
  parsed.userinfo = matches[3];
19400
19836
  parsed.host = matches[4];
19401
19837
  parsed.port = parseInt(matches[5], 10);
@@ -19454,11 +19890,12 @@ var require_fast_uri = __commonJS({
19454
19890
  if (parsed.path) {
19455
19891
  parsed.path = normalizePathEncoding(parsed.path);
19456
19892
  }
19457
- if (parsed.query) {
19458
- parsed.query = normalizeQueryFragmentEncoding(parsed.query);
19459
- }
19460
19893
  if (parsed.fragment) {
19461
- parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
19894
+ try {
19895
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
19896
+ } catch {
19897
+ parsed.error = parsed.error || "URI malformed";
19898
+ }
19462
19899
  }
19463
19900
  }
19464
19901
  if (schemeHandler && schemeHandler.parse) {
@@ -22465,6 +22902,7 @@ __export(dist_exports2, {
22465
22902
  createExecutionId: () => createExecutionId,
22466
22903
  createIsolatedExecutionBackend: () => createIsolatedExecutionBackend,
22467
22904
  createTimeoutPromise: () => createTimeoutPromise,
22905
+ ensureHostProcessExecutor: () => ensureHostProcessExecutor,
22468
22906
  isExecutionLayerError: () => isExecutionLayerError,
22469
22907
  isKnownErrorCode: () => isKnownErrorCode,
22470
22908
  localWorkspaceManager: () => localWorkspaceManager,
@@ -22645,7 +23083,19 @@ function createDefaultIPCServerFactory() {
22645
23083
  }
22646
23084
  };
22647
23085
  }
23086
+ function ensureHostProcessExecutor(platform2) {
23087
+ const host = platform2;
23088
+ if (host.processExecutor || !host.setAdapter || host.hasResourceBroker !== true || !host.resourceBroker) {
23089
+ return;
23090
+ }
23091
+ host.setAdapter("processExecutor", new BrokeredProcessExecutor(
23092
+ host.resourceBroker,
23093
+ createDefaultProcessExecutor(host.logger),
23094
+ host.logger
23095
+ ));
23096
+ }
22648
23097
  function createExecutionBackend(options) {
23098
+ ensureHostProcessExecutor(options.platform);
22649
23099
  const mode = options.mode === "auto" || !options.mode ? detectMode() : options.mode;
22650
23100
  switch (mode) {
22651
23101
  case "in-process":
@@ -23083,7 +23533,9 @@ var init_dist8 = __esm({
23083
23533
  }
23084
23534
  } : void 0;
23085
23535
  const loggerOverride = requestToExecute.context?.loggerOverride;
23086
- const effectivePlatform = loggerOverride ? { ...this.platform, logger: loggerOverride } : this.platform;
23536
+ const effectivePlatform = loggerOverride ? Object.create(this.platform, {
23537
+ logger: { value: loggerOverride, enumerable: true, configurable: true }
23538
+ }) : this.platform;
23087
23539
  const adapterMiddlewares = await this.getMiddlewares();
23088
23540
  const runResult = await runInProcess({
23089
23541
  descriptor: requestToExecute.descriptor,
@@ -30649,7 +31101,7 @@ var require_thread_stream = __commonJS({
30649
31101
  var { version } = require_package();
30650
31102
  var { EventEmitter: EventEmitter2 } = __require("events");
30651
31103
  var { Worker: Worker2 } = __require("worker_threads");
30652
- var { join: join7 } = __require("path");
31104
+ var { join: join8 } = __require("path");
30653
31105
  var { pathToFileURL: pathToFileURL3 } = __require("url");
30654
31106
  var { wait } = require_wait();
30655
31107
  var {
@@ -30685,7 +31137,7 @@ var require_thread_stream = __commonJS({
30685
31137
  function createWorker(stream, opts) {
30686
31138
  const { filename, workerData } = opts;
30687
31139
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
30688
- const toExecute = bundlerOverrides["thread-stream-worker"] || join7(__dirname, "lib", "worker.js");
31140
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join8(__dirname, "lib", "worker.js");
30689
31141
  const worker = new Worker2(toExecute, {
30690
31142
  ...opts.workerOpts,
30691
31143
  trackUnmanagedFds: false,
@@ -31073,9 +31525,9 @@ var require_thread_stream = __commonJS({
31073
31525
  var require_transport = __commonJS({
31074
31526
  "../../../node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports$1, module) {
31075
31527
  var { createRequire: createRequire3 } = __require("module");
31076
- var { existsSync: existsSync6 } = __require("fs");
31528
+ var { existsSync: existsSync7 } = __require("fs");
31077
31529
  var getCallers = require_caller();
31078
- var { join: join7, isAbsolute, sep: sep2 } = __require("path");
31530
+ var { join: join8, isAbsolute, sep: sep2 } = __require("path");
31079
31531
  var { fileURLToPath: fileURLToPath3 } = __require("url");
31080
31532
  var sleep3 = require_atomic_sleep();
31081
31533
  var onExit = require_on_exit_leak_free();
@@ -31147,7 +31599,7 @@ var require_transport = __commonJS({
31147
31599
  return false;
31148
31600
  }
31149
31601
  }
31150
- return isAbsolute(path5) && !existsSync6(path5);
31602
+ return isAbsolute(path5) && !existsSync7(path5);
31151
31603
  }
31152
31604
  function stripQuotes(value) {
31153
31605
  const first = value[0];
@@ -31228,7 +31680,7 @@ var require_transport = __commonJS({
31228
31680
  throw new Error("only one of target or targets can be specified");
31229
31681
  }
31230
31682
  if (targets) {
31231
- target = bundlerOverrides["pino-worker"] || join7(__dirname, "worker.js");
31683
+ target = bundlerOverrides["pino-worker"] || join8(__dirname, "worker.js");
31232
31684
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
31233
31685
  return {
31234
31686
  ...dest,
@@ -31246,7 +31698,7 @@ var require_transport = __commonJS({
31246
31698
  });
31247
31699
  });
31248
31700
  } else if (pipeline) {
31249
- target = bundlerOverrides["pino-worker"] || join7(__dirname, "worker.js");
31701
+ target = bundlerOverrides["pino-worker"] || join8(__dirname, "worker.js");
31250
31702
  options.pipelines = [pipeline.map((dest) => {
31251
31703
  return {
31252
31704
  ...dest,
@@ -31269,7 +31721,7 @@ var require_transport = __commonJS({
31269
31721
  return origin;
31270
31722
  }
31271
31723
  if (origin === "pino/file") {
31272
- return join7(__dirname, "..", "file.js");
31724
+ return join8(__dirname, "..", "file.js");
31273
31725
  }
31274
31726
  let fixTarget2;
31275
31727
  for (const filePath of callers) {
@@ -32244,7 +32696,7 @@ var require_safe_stable_stringify = __commonJS({
32244
32696
  return circularValue;
32245
32697
  }
32246
32698
  let res = "";
32247
- let join7 = ",";
32699
+ let join8 = ",";
32248
32700
  const originalIndentation = indentation;
32249
32701
  if (Array.isArray(value)) {
32250
32702
  if (value.length === 0) {
@@ -32258,7 +32710,7 @@ var require_safe_stable_stringify = __commonJS({
32258
32710
  indentation += spacer;
32259
32711
  res += `
32260
32712
  ${indentation}`;
32261
- join7 = `,
32713
+ join8 = `,
32262
32714
  ${indentation}`;
32263
32715
  }
32264
32716
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -32266,13 +32718,13 @@ ${indentation}`;
32266
32718
  for (; i < maximumValuesToStringify - 1; i++) {
32267
32719
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
32268
32720
  res += tmp2 !== void 0 ? tmp2 : "null";
32269
- res += join7;
32721
+ res += join8;
32270
32722
  }
32271
32723
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
32272
32724
  res += tmp !== void 0 ? tmp : "null";
32273
32725
  if (value.length - 1 > maximumBreadth) {
32274
32726
  const removedKeys = value.length - maximumBreadth - 1;
32275
- res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
32727
+ res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
32276
32728
  }
32277
32729
  if (spacer !== "") {
32278
32730
  res += `
@@ -32293,7 +32745,7 @@ ${originalIndentation}`;
32293
32745
  let separator = "";
32294
32746
  if (spacer !== "") {
32295
32747
  indentation += spacer;
32296
- join7 = `,
32748
+ join8 = `,
32297
32749
  ${indentation}`;
32298
32750
  whitespace = " ";
32299
32751
  }
@@ -32307,13 +32759,13 @@ ${indentation}`;
32307
32759
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
32308
32760
  if (tmp !== void 0) {
32309
32761
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
32310
- separator = join7;
32762
+ separator = join8;
32311
32763
  }
32312
32764
  }
32313
32765
  if (keyLength > maximumBreadth) {
32314
32766
  const removedKeys = keyLength - maximumBreadth;
32315
32767
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
32316
- separator = join7;
32768
+ separator = join8;
32317
32769
  }
32318
32770
  if (spacer !== "" && separator.length > 1) {
32319
32771
  res = `
@@ -32354,7 +32806,7 @@ ${originalIndentation}`;
32354
32806
  }
32355
32807
  const originalIndentation = indentation;
32356
32808
  let res = "";
32357
- let join7 = ",";
32809
+ let join8 = ",";
32358
32810
  if (Array.isArray(value)) {
32359
32811
  if (value.length === 0) {
32360
32812
  return "[]";
@@ -32367,7 +32819,7 @@ ${originalIndentation}`;
32367
32819
  indentation += spacer;
32368
32820
  res += `
32369
32821
  ${indentation}`;
32370
- join7 = `,
32822
+ join8 = `,
32371
32823
  ${indentation}`;
32372
32824
  }
32373
32825
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -32375,13 +32827,13 @@ ${indentation}`;
32375
32827
  for (; i < maximumValuesToStringify - 1; i++) {
32376
32828
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
32377
32829
  res += tmp2 !== void 0 ? tmp2 : "null";
32378
- res += join7;
32830
+ res += join8;
32379
32831
  }
32380
32832
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
32381
32833
  res += tmp !== void 0 ? tmp : "null";
32382
32834
  if (value.length - 1 > maximumBreadth) {
32383
32835
  const removedKeys = value.length - maximumBreadth - 1;
32384
- res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
32836
+ res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
32385
32837
  }
32386
32838
  if (spacer !== "") {
32387
32839
  res += `
@@ -32394,7 +32846,7 @@ ${originalIndentation}`;
32394
32846
  let whitespace = "";
32395
32847
  if (spacer !== "") {
32396
32848
  indentation += spacer;
32397
- join7 = `,
32849
+ join8 = `,
32398
32850
  ${indentation}`;
32399
32851
  whitespace = " ";
32400
32852
  }
@@ -32403,7 +32855,7 @@ ${indentation}`;
32403
32855
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
32404
32856
  if (tmp !== void 0) {
32405
32857
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
32406
- separator = join7;
32858
+ separator = join8;
32407
32859
  }
32408
32860
  }
32409
32861
  if (spacer !== "" && separator.length > 1) {
@@ -32461,20 +32913,20 @@ ${originalIndentation}`;
32461
32913
  indentation += spacer;
32462
32914
  let res2 = `
32463
32915
  ${indentation}`;
32464
- const join8 = `,
32916
+ const join9 = `,
32465
32917
  ${indentation}`;
32466
32918
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
32467
32919
  let i = 0;
32468
32920
  for (; i < maximumValuesToStringify - 1; i++) {
32469
32921
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
32470
32922
  res2 += tmp2 !== void 0 ? tmp2 : "null";
32471
- res2 += join8;
32923
+ res2 += join9;
32472
32924
  }
32473
32925
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
32474
32926
  res2 += tmp !== void 0 ? tmp : "null";
32475
32927
  if (value.length - 1 > maximumBreadth) {
32476
32928
  const removedKeys = value.length - maximumBreadth - 1;
32477
- res2 += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
32929
+ res2 += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
32478
32930
  }
32479
32931
  res2 += `
32480
32932
  ${originalIndentation}`;
@@ -32490,16 +32942,16 @@ ${originalIndentation}`;
32490
32942
  return '"[Object]"';
32491
32943
  }
32492
32944
  indentation += spacer;
32493
- const join7 = `,
32945
+ const join8 = `,
32494
32946
  ${indentation}`;
32495
32947
  let res = "";
32496
32948
  let separator = "";
32497
32949
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
32498
32950
  if (isTypedArrayWithEntries(value)) {
32499
- res += stringifyTypedArray(value, join7, maximumBreadth);
32951
+ res += stringifyTypedArray(value, join8, maximumBreadth);
32500
32952
  keys = keys.slice(value.length);
32501
32953
  maximumPropertiesToStringify -= value.length;
32502
- separator = join7;
32954
+ separator = join8;
32503
32955
  }
32504
32956
  if (deterministic) {
32505
32957
  keys = sort(keys, comparator);
@@ -32510,13 +32962,13 @@ ${indentation}`;
32510
32962
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
32511
32963
  if (tmp !== void 0) {
32512
32964
  res += `${separator}${strEscape(key2)}: ${tmp}`;
32513
- separator = join7;
32965
+ separator = join8;
32514
32966
  }
32515
32967
  }
32516
32968
  if (keyLength > maximumBreadth) {
32517
32969
  const removedKeys = keyLength - maximumBreadth;
32518
32970
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
32519
- separator = join7;
32971
+ separator = join8;
32520
32972
  }
32521
32973
  if (separator !== "") {
32522
32974
  res = `
@@ -44363,7 +44815,7 @@ var require_subset = __commonJS({
44363
44815
  var require_semver2 = __commonJS({
44364
44816
  "../../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports$1, module) {
44365
44817
  var internalRe = require_re();
44366
- var constants2 = require_constants2();
44818
+ var constants3 = require_constants2();
44367
44819
  var SemVer = require_semver();
44368
44820
  var identifiers = require_identifiers();
44369
44821
  var parse = require_parse2();
@@ -44445,8 +44897,8 @@ var require_semver2 = __commonJS({
44445
44897
  re: internalRe.re,
44446
44898
  src: internalRe.src,
44447
44899
  tokens: internalRe.t,
44448
- SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
44449
- RELEASE_TYPES: constants2.RELEASE_TYPES,
44900
+ SEMVER_SPEC_VERSION: constants3.SEMVER_SPEC_VERSION,
44901
+ RELEASE_TYPES: constants3.RELEASE_TYPES,
44450
44902
  compareIdentifiers: identifiers.compareIdentifiers,
44451
44903
  rcompareIdentifiers: identifiers.rcompareIdentifiers
44452
44904
  };
@@ -50083,7 +50535,7 @@ var require_parse_url = __commonJS({
50083
50535
  // ../../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js
50084
50536
  var require_form_data = __commonJS({
50085
50537
  "../../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js"(exports$1, module) {
50086
- var { randomUUID: randomUUID8 } = __require("crypto");
50538
+ var { randomUUID: randomUUID9 } = __require("crypto");
50087
50539
  var { Readable } = __require("stream");
50088
50540
  var textEncoder;
50089
50541
  function isFormDataLike(payload) {
@@ -50091,23 +50543,23 @@ var require_form_data = __commonJS({
50091
50543
  }
50092
50544
  function formDataToStream(formdata) {
50093
50545
  textEncoder = textEncoder ?? new TextEncoder();
50094
- const boundary = `----formdata-${randomUUID8()}`;
50546
+ const boundary = `----formdata-${randomUUID9()}`;
50095
50547
  const prefix = `--${boundary}\r
50096
50548
  Content-Disposition: form-data`;
50097
- const escape = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
50549
+ const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
50098
50550
  const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
50099
50551
  const linebreak = new Uint8Array([13, 10]);
50100
50552
  async function* asyncIterator() {
50101
50553
  for (const [name, value] of formdata) {
50102
50554
  if (typeof value === "string") {
50103
- yield textEncoder.encode(`${prefix}; name="${escape(normalizeLinefeeds(name))}"\r
50555
+ yield textEncoder.encode(`${prefix}; name="${escape2(normalizeLinefeeds(name))}"\r
50104
50556
  \r
50105
50557
  `);
50106
50558
  yield textEncoder.encode(`${normalizeLinefeeds(value)}\r
50107
50559
  `);
50108
50560
  } else {
50109
- let header = `${prefix}; name="${escape(normalizeLinefeeds(name))}"`;
50110
- value.name && (header += `; filename="${escape(value.name)}"`);
50561
+ let header = `${prefix}; name="${escape2(normalizeLinefeeds(name))}"`;
50562
+ value.name && (header += `; filename="${escape2(value.name)}"`);
50111
50563
  header += `\r
50112
50564
  Content-Type: ${value.type || "application/octet-stream"}\r
50113
50565
  \r
@@ -67802,6 +68254,10 @@ var init_container = __esm3({
67802
68254
  get hasResourceBroker() {
67803
68255
  return this._resourceBroker !== void 0;
67804
68256
  }
68257
+ /** Platform-owned process executor. Never exposed through governed plugin adapters. */
68258
+ get processExecutor() {
68259
+ return this.getAdapter("processExecutor");
68260
+ }
67805
68261
  /**
67806
68262
  * Initialize core features.
67807
68263
  * Called internally by initPlatform().
@@ -72466,6 +72922,16 @@ async function initPlatform(config = {}, cwd = process.cwd(), uiProvider, platfo
72466
72922
  error: error instanceof Error ? error.message : String(error)
72467
72923
  });
72468
72924
  }
72925
+ if (_assemblyBroker && !platform.processExecutor) {
72926
+ try {
72927
+ const { ensureHostProcessExecutor: ensureHostProcessExecutor2 } = await Promise.resolve().then(() => (init_dist8(), dist_exports2));
72928
+ ensureHostProcessExecutor2(platform);
72929
+ } catch (error) {
72930
+ platform.logger.warn("Failed to initialize governed process executor", {
72931
+ error: error instanceof Error ? error.message : String(error)
72932
+ });
72933
+ }
72934
+ }
72469
72935
  if (assemblyHook && _assemblyBroker) {
72470
72936
  const llmOptions = adapterOptions.llm ?? {};
72471
72937
  const executionDefaults = llmOptions.executionDefaults;
@@ -73094,6 +73560,7 @@ init_llm_proxy();
73094
73560
  init_embeddings_proxy();
73095
73561
  init_vector_store_proxy();
73096
73562
  init_storage_proxy();
73563
+ init_remote_adapter();
73097
73564
  init_container();
73098
73565
  init_adapter_status();
73099
73566