@kb-labs/mcp-app 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 +796 -308
  2. package/dist/bin.cjs.map +1 -1
  3. package/package.json +17 -17
package/dist/bin.cjs CHANGED
@@ -2230,8 +2230,8 @@ var init_dist3 = __esm({
2230
2230
  totalTime: 0
2231
2231
  });
2232
2232
  }
2233
- const registered = this.resources.get(request.resource);
2234
- if (!registered) {
2233
+ const registered2 = this.resources.get(request.resource);
2234
+ if (!registered2) {
2235
2235
  return Promise.resolve({
2236
2236
  success: false,
2237
2237
  error: new Error(`Resource not registered: ${request.resource}`),
@@ -2241,7 +2241,7 @@ var init_dist3 = __esm({
2241
2241
  totalTime: 0
2242
2242
  });
2243
2243
  }
2244
- if (registered.limitOnly) {
2244
+ if (registered2.limitOnly) {
2245
2245
  return Promise.resolve({
2246
2246
  success: false,
2247
2247
  error: new Error(
@@ -2257,8 +2257,8 @@ var init_dist3 = __esm({
2257
2257
  ...request,
2258
2258
  id: crypto4.randomUUID(),
2259
2259
  createdAt: Date.now(),
2260
- timeout: request.timeout ?? registered.config.timeout ?? 6e4,
2261
- maxRetries: request.maxRetries ?? registered.config.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries
2260
+ timeout: request.timeout ?? registered2.config.timeout ?? 6e4,
2261
+ maxRetries: request.maxRetries ?? registered2.config.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries
2262
2262
  };
2263
2263
  return new Promise((resolve9, reject) => {
2264
2264
  const item = {
@@ -2268,7 +2268,7 @@ var init_dist3 = __esm({
2268
2268
  enqueuedAt: Date.now()
2269
2269
  };
2270
2270
  this.queue.enqueue(item);
2271
- registered.stats.totalRequests++;
2271
+ registered2.stats.totalRequests++;
2272
2272
  this.processQueue();
2273
2273
  });
2274
2274
  }
@@ -2293,15 +2293,15 @@ var init_dist3 = __esm({
2293
2293
  release: noopRelease
2294
2294
  };
2295
2295
  }
2296
- const registered = this.resources.get(resource);
2297
- if (!registered) {
2296
+ const registered2 = this.resources.get(resource);
2297
+ if (!registered2) {
2298
2298
  throw new Error(`Resource not registered: ${resource}`);
2299
2299
  }
2300
2300
  const tokens = opts?.tokens ?? 0;
2301
2301
  const result = await this.rateLimitBackend.acquire(
2302
2302
  resource,
2303
2303
  tokens,
2304
- registered.rateLimits
2304
+ registered2.rateLimits
2305
2305
  );
2306
2306
  if (!result.allowed) {
2307
2307
  return { ...result, release: noopRelease };
@@ -2334,8 +2334,8 @@ var init_dist3 = __esm({
2334
2334
  if (!item) {
2335
2335
  break;
2336
2336
  }
2337
- const registered = this.resources.get(item.request.resource);
2338
- if (!registered) {
2337
+ const registered2 = this.resources.get(item.request.resource);
2338
+ if (!registered2) {
2339
2339
  this.queue.dequeue();
2340
2340
  item.reject(new Error(`Resource not registered: ${item.request.resource}`));
2341
2341
  continue;
@@ -2344,7 +2344,7 @@ var init_dist3 = __esm({
2344
2344
  const acquireResult = await this.rateLimitBackend.acquire(
2345
2345
  item.request.resource,
2346
2346
  tokens,
2347
- registered.rateLimits
2347
+ registered2.rateLimits
2348
2348
  );
2349
2349
  if (!acquireResult.allowed) {
2350
2350
  await sleep(acquireResult.waitTimeMs ?? 100);
@@ -2353,7 +2353,7 @@ var init_dist3 = __esm({
2353
2353
  this.queue.dequeue();
2354
2354
  const currentActive = this.activeProcessing.get(item.request.resource) ?? 0;
2355
2355
  this.activeProcessing.set(item.request.resource, currentActive + 1);
2356
- this.executeItem(item, registered).catch(() => {
2356
+ this.executeItem(item, registered2).catch(() => {
2357
2357
  });
2358
2358
  }
2359
2359
  } finally {
@@ -2366,15 +2366,15 @@ var init_dist3 = __esm({
2366
2366
  /**
2367
2367
  * Execute a single queue item with retry logic.
2368
2368
  */
2369
- async executeItem(item, registered) {
2369
+ async executeItem(item, registered2) {
2370
2370
  const startTime = Date.now();
2371
2371
  const waitTime = startTime - item.enqueuedAt;
2372
2372
  let retries = 0;
2373
2373
  let lastError;
2374
2374
  const retryConfig = {
2375
2375
  maxRetries: item.request.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries,
2376
- baseDelay: registered.config.baseDelay ?? DEFAULT_RETRY_CONFIG.baseDelay,
2377
- maxDelay: registered.config.maxDelay ?? DEFAULT_RETRY_CONFIG.maxDelay,
2376
+ baseDelay: registered2.config.baseDelay ?? DEFAULT_RETRY_CONFIG.baseDelay,
2377
+ maxDelay: registered2.config.maxDelay ?? DEFAULT_RETRY_CONFIG.maxDelay,
2378
2378
  jitter: DEFAULT_RETRY_CONFIG.jitter,
2379
2379
  retryableErrors: DEFAULT_RETRY_CONFIG.retryableErrors
2380
2380
  };
@@ -2385,16 +2385,16 @@ var init_dist3 = __esm({
2385
2385
  const timeoutPromise = new Promise((_, reject) => {
2386
2386
  setTimeout(() => reject(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
2387
2387
  });
2388
- const executionPromise = registered.config.executor(
2388
+ const executionPromise = registered2.config.executor(
2389
2389
  item.request.operation,
2390
2390
  item.request.args
2391
2391
  );
2392
2392
  const result = await Promise.race([executionPromise, timeoutPromise]);
2393
2393
  const endTime2 = Date.now();
2394
2394
  const processingTime2 = endTime2 - startTime;
2395
- registered.stats.totalSuccess++;
2396
- registered.stats.totalWaitTime += waitTime;
2397
- registered.stats.totalProcessingTime += processingTime2;
2395
+ registered2.stats.totalSuccess++;
2396
+ registered2.stats.totalWaitTime += waitTime;
2397
+ registered2.stats.totalProcessingTime += processingTime2;
2398
2398
  item.resolve({
2399
2399
  success: true,
2400
2400
  data: result,
@@ -2416,7 +2416,7 @@ var init_dist3 = __esm({
2416
2416
  const acquireResult = await this.rateLimitBackend.acquire(
2417
2417
  item.request.resource,
2418
2418
  tokens,
2419
- registered.rateLimits
2419
+ registered2.rateLimits
2420
2420
  );
2421
2421
  if (!acquireResult.allowed && acquireResult.waitTimeMs) {
2422
2422
  await sleep(acquireResult.waitTimeMs);
@@ -2425,9 +2425,9 @@ var init_dist3 = __esm({
2425
2425
  }
2426
2426
  const endTime = Date.now();
2427
2427
  const processingTime = endTime - startTime;
2428
- registered.stats.totalErrors++;
2429
- registered.stats.totalWaitTime += waitTime;
2430
- registered.stats.totalProcessingTime += processingTime;
2428
+ registered2.stats.totalErrors++;
2429
+ registered2.stats.totalWaitTime += waitTime;
2430
+ registered2.stats.totalProcessingTime += processingTime;
2431
2431
  item.resolve({
2432
2432
  success: false,
2433
2433
  error: lastError,
@@ -2450,7 +2450,7 @@ var init_dist3 = __esm({
2450
2450
  let totalRequests = 0;
2451
2451
  let totalSuccess = 0;
2452
2452
  let totalErrors = 0;
2453
- for (const [resourceName, registered] of this.resources) {
2453
+ for (const [resourceName, registered2] of this.resources) {
2454
2454
  const queueByPriority = this.queue.sizeByPriority();
2455
2455
  const queueSize = this.queue.sizeByResource(resourceName);
2456
2456
  const activeRequests = this.activeProcessing.get(resourceName) ?? 0;
@@ -2460,26 +2460,26 @@ var init_dist3 = __esm({
2460
2460
  requestsThisMinute: 0,
2461
2461
  requestsThisSecond: 0,
2462
2462
  activeRequests,
2463
- totalRequests: registered.stats.totalRequests,
2463
+ totalRequests: registered2.stats.totalRequests,
2464
2464
  totalTokens: 0,
2465
2465
  waitCount: 0,
2466
- totalWaitTime: registered.stats.totalWaitTime
2466
+ totalWaitTime: registered2.stats.totalWaitTime
2467
2467
  };
2468
- const avgWaitTime = registered.stats.totalRequests > 0 ? registered.stats.totalWaitTime / registered.stats.totalRequests : 0;
2469
- const avgProcessingTime = registered.stats.totalRequests > 0 ? registered.stats.totalProcessingTime / registered.stats.totalRequests : 0;
2468
+ const avgWaitTime = registered2.stats.totalRequests > 0 ? registered2.stats.totalWaitTime / registered2.stats.totalRequests : 0;
2469
+ const avgProcessingTime = registered2.stats.totalRequests > 0 ? registered2.stats.totalProcessingTime / registered2.stats.totalRequests : 0;
2470
2470
  resources[resourceName] = {
2471
2471
  rateLimits: rateLimitStats,
2472
2472
  queueSize,
2473
2473
  queueByPriority,
2474
- totalRequests: registered.stats.totalRequests,
2475
- totalSuccess: registered.stats.totalSuccess,
2476
- totalErrors: registered.stats.totalErrors,
2474
+ totalRequests: registered2.stats.totalRequests,
2475
+ totalSuccess: registered2.stats.totalSuccess,
2476
+ totalErrors: registered2.stats.totalErrors,
2477
2477
  avgWaitTime,
2478
2478
  avgProcessingTime
2479
2479
  };
2480
- totalRequests += registered.stats.totalRequests;
2481
- totalSuccess += registered.stats.totalSuccess;
2482
- totalErrors += registered.stats.totalErrors;
2480
+ totalRequests += registered2.stats.totalRequests;
2481
+ totalSuccess += registered2.stats.totalSuccess;
2482
+ totalErrors += registered2.stats.totalErrors;
2483
2483
  }
2484
2484
  return {
2485
2485
  resources,
@@ -3567,6 +3567,7 @@ __export(dist_exports, {
3567
3567
  KVStoreProxy: () => KVStoreProxy,
3568
3568
  LLMProxy: () => LLMProxy,
3569
3569
  OPERATION_TIMEOUTS: () => OPERATION_TIMEOUTS,
3570
+ ProcessExecutorProxy: () => ProcessExecutorProxy,
3570
3571
  RemoteAdapter: () => RemoteAdapter,
3571
3572
  StorageProxy: () => StorageProxy,
3572
3573
  TimeoutError: () => TimeoutError,
@@ -3648,6 +3649,7 @@ function isPlainObject(value) {
3648
3649
  function createProxyPlatform(options) {
3649
3650
  const { transport } = options;
3650
3651
  const logger2 = options.logger ?? new LoggerProxy(transport);
3652
+ const processExecutor = new ProcessExecutorProxy(transport);
3651
3653
  const cache = new CacheProxy(transport);
3652
3654
  const llm = new LLMProxy(transport);
3653
3655
  const embeddings = new EmbeddingsProxy(transport);
@@ -3691,10 +3693,11 @@ function createProxyPlatform(options) {
3691
3693
  invoke,
3692
3694
  documentDatabase,
3693
3695
  kvStore,
3694
- logs
3696
+ logs,
3697
+ processExecutor
3695
3698
  };
3696
3699
  }
3697
- 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;
3700
+ 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;
3698
3701
  var init_dist5 = __esm({
3699
3702
  "../../../core/ipc/dist/index.js"() {
3700
3703
  init_serializable();
@@ -4010,11 +4013,16 @@ var init_dist5 = __esm({
4010
4013
  return this.platform.analytics;
4011
4014
  case "eventBus":
4012
4015
  return this.platform.eventBus;
4016
+ case "processExecutor":
4017
+ if (!this.platform.processExecutor) {
4018
+ throw new Error("Governed process executor is not configured on execution host");
4019
+ }
4020
+ return this.platform.processExecutor;
4013
4021
  case "invoke":
4014
4022
  return this.platform.invoke;
4015
4023
  default:
4016
4024
  throw new Error(
4017
- `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, config, llm, embeddings, storage, logger, analytics, eventBus, invoke`
4025
+ `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, config, llm, embeddings, storage, logger, analytics, eventBus, invoke, processExecutor`
4018
4026
  );
4019
4027
  }
4020
4028
  }
@@ -4186,9 +4194,14 @@ var init_dist5 = __esm({
4186
4194
  return this.platform.eventBus;
4187
4195
  case "invoke":
4188
4196
  return this.platform.invoke;
4197
+ case "processExecutor":
4198
+ if (!this.platform.processExecutor) {
4199
+ throw new Error("Governed process executor is not configured on execution host");
4200
+ }
4201
+ return this.platform.processExecutor;
4189
4202
  default:
4190
4203
  throw new Error(
4191
- `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, llm, embeddings, storage, logger, analytics, eventBus, invoke`
4204
+ `Unknown adapter: '${name}'. Valid adapters: vectorStore, cache, llm, embeddings, storage, logger, analytics, eventBus, invoke, processExecutor`
4192
4205
  );
4193
4206
  }
4194
4207
  }
@@ -5528,6 +5541,52 @@ Caused by: ${cause.stack}`;
5528
5541
  return new _LoggerProxy(this.proxyTransport, { ...this.boundContext, ...bindings });
5529
5542
  }
5530
5543
  };
5544
+ PROCESS_RPC_GRACE_MS = 5e3;
5545
+ CONTROL_RPC_TIMEOUT_MS = 5e3;
5546
+ MAX_TIMER_MS = 2147483647;
5547
+ ProcessExecutorProxy = class extends RemoteAdapter {
5548
+ constructor(transport) {
5549
+ super("processExecutor", transport);
5550
+ }
5551
+ capabilities() {
5552
+ return {
5553
+ platform: "other",
5554
+ processGroups: false,
5555
+ hardMemoryLimit: false,
5556
+ hardCpuLimit: false,
5557
+ processTreeAccounting: false,
5558
+ maxProcesses: false
5559
+ };
5560
+ }
5561
+ async execute(request) {
5562
+ const processId = request.processId ?? crypto4.randomUUID();
5563
+ const { signal, ...serializableRequest } = request;
5564
+ let cancelled = false;
5565
+ const onAbort = () => {
5566
+ cancelled = true;
5567
+ void this.cancel(processId, "cancelled");
5568
+ };
5569
+ signal?.addEventListener("abort", onAbort, { once: true });
5570
+ try {
5571
+ const processTimeout = request.limits.timeoutMs + (request.limits.graceMs ?? 1e3);
5572
+ const rpcTimeout = Math.min(MAX_TIMER_MS, processTimeout + PROCESS_RPC_GRACE_MS);
5573
+ return await this.callRemote("execute", [{ ...serializableRequest, processId }], rpcTimeout);
5574
+ } catch (error2) {
5575
+ void this.cancel(processId, "cancelled").catch(() => void 0);
5576
+ throw error2;
5577
+ } finally {
5578
+ if (!cancelled) {
5579
+ signal?.removeEventListener("abort", onAbort);
5580
+ }
5581
+ }
5582
+ }
5583
+ async cancel(processId, reason = "cancelled") {
5584
+ await this.callRemote("cancel", [processId, reason], CONTROL_RPC_TIMEOUT_MS);
5585
+ }
5586
+ async shutdown() {
5587
+ await this.callRemote("shutdown", [], CONTROL_RPC_TIMEOUT_MS);
5588
+ }
5589
+ };
5531
5590
  }
5532
5591
  });
5533
5592
  function getLoggerMetadataFromHost(hostContext) {
@@ -6014,77 +6073,66 @@ function createShellAPI(options) {
6014
6073
  const { permissions, cwd } = options;
6015
6074
  const allowedCommands = permissions.shell?.allow ?? [];
6016
6075
  if (allowedCommands.length === 0) {
6017
- return {
6018
- async exec() {
6019
- throw new PermissionError("Shell execution not allowed");
6020
- }
6021
- };
6076
+ return { async exec() {
6077
+ throw new PermissionError("Shell execution not allowed");
6078
+ } };
6022
6079
  }
6080
+ const executor = options.processExecutor;
6081
+ if (!executor) {
6082
+ throw new Error("Governed process executor is unavailable in this execution host");
6083
+ }
6084
+ const identity = options.processIdentity ?? {
6085
+ executionId: "unknown-execution",
6086
+ requestId: "unknown-request",
6087
+ pluginId: "unknown-plugin"
6088
+ };
6089
+ const quotas = permissions.quotas ?? {};
6023
6090
  return {
6024
6091
  async exec(command, args = [], execOptions) {
6025
6092
  const fullCommand = `${command} ${args.join(" ")}`;
6026
6093
  for (const blocked of BLOCKED_COMMANDS) {
6027
6094
  if (fullCommand.includes(blocked)) {
6028
- throw new PermissionError(`Dangerous command blocked`, {
6029
- command: fullCommand,
6030
- blocked
6031
- });
6095
+ throw new PermissionError("Dangerous command blocked", { command: fullCommand, blocked });
6032
6096
  }
6033
6097
  }
6034
6098
  if (!allowedCommands.includes(command) && !allowedCommands.includes(path13.basename(command)) && !allowedCommands.includes("*")) {
6035
- throw new PermissionError(`Command not in whitelist`, {
6036
- command,
6037
- allowedCommands
6038
- });
6039
- }
6040
- const workingDir = execOptions?.cwd ?? cwd;
6041
- const timeout = execOptions?.timeout ?? 3e4;
6042
- const throwOnError = execOptions?.throwOnError ?? false;
6043
- return new Promise((resolve32, reject) => {
6044
- const child = child_process.spawn(command, args, {
6045
- cwd: workingDir,
6046
- env: {
6047
- ...process.env,
6048
- ...execOptions?.env
6049
- }
6050
- });
6051
- let stdout = "";
6052
- let stderr = "";
6053
- let timedOut = false;
6054
- const timeoutId = setTimeout(() => {
6055
- timedOut = true;
6056
- child.kill("SIGKILL");
6057
- }, timeout);
6058
- child.stdout?.on("data", (data) => {
6059
- stdout += data.toString();
6060
- });
6061
- child.stderr?.on("data", (data) => {
6062
- stderr += data.toString();
6063
- });
6064
- child.on("close", (code) => {
6065
- clearTimeout(timeoutId);
6066
- if (timedOut) {
6067
- reject(new Error(`Command timed out after ${timeout}ms`));
6068
- return;
6069
- }
6070
- const exitCode = code ?? 0;
6071
- const result = {
6072
- code: exitCode,
6073
- stdout,
6074
- stderr,
6075
- ok: exitCode === 0
6076
- };
6077
- if (throwOnError && exitCode !== 0) {
6078
- reject(new Error(`Command failed with code ${exitCode}: ${stderr}`));
6079
- } else {
6080
- resolve32(result);
6081
- }
6082
- });
6083
- child.on("error", (error2) => {
6084
- clearTimeout(timeoutId);
6085
- reject(error2);
6086
- });
6099
+ throw new PermissionError("Command not in whitelist", { command, allowedCommands });
6100
+ }
6101
+ const requestedTimeout = execOptions?.timeout ?? quotas.timeoutMs ?? 3e4;
6102
+ const timeoutMs = Math.min(requestedTimeout, quotas.timeoutMs ?? requestedTimeout);
6103
+ const result = await executor.execute({
6104
+ identity,
6105
+ command,
6106
+ args,
6107
+ cwd: execOptions?.cwd ?? cwd,
6108
+ env: execOptions?.env,
6109
+ signal: execOptions?.signal ?? options.signal,
6110
+ retry: execOptions?.retry,
6111
+ limits: {
6112
+ timeoutMs,
6113
+ cpuMs: quotas.cpuMs,
6114
+ memoryMb: quotas.memoryMb,
6115
+ maxProcesses: quotas.maxProcesses,
6116
+ maxConcurrent: permissions.shell?.maxConcurrent,
6117
+ maxOutputBytes: execOptions?.maxOutputBytes ?? quotas.maxOutputBytes
6118
+ }
6087
6119
  });
6120
+ const output = {
6121
+ code: result.code ?? -1,
6122
+ stdout: result.stdout,
6123
+ stderr: result.stderr,
6124
+ ok: result.ok,
6125
+ processId: result.processId,
6126
+ terminationReason: result.terminationReason,
6127
+ usage: result.usage,
6128
+ attempts: result.attempts
6129
+ };
6130
+ if (execOptions?.throwOnError && !output.ok) {
6131
+ const error2 = new Error(`Command failed with code ${output.code}: ${output.stderr}`);
6132
+ Object.assign(error2, { code: "PROCESS_EXIT_NON_ZERO", result: output });
6133
+ throw error2;
6134
+ }
6135
+ return output;
6088
6136
  }
6089
6137
  };
6090
6138
  }
@@ -6906,6 +6954,9 @@ function createPluginAPI(options) {
6906
6954
  cwd,
6907
6955
  outdir,
6908
6956
  permissions,
6957
+ processExecutor,
6958
+ processIdentity,
6959
+ signal,
6909
6960
  cache,
6910
6961
  eventEmitter,
6911
6962
  pluginInvoker,
@@ -6923,7 +6974,7 @@ function createPluginAPI(options) {
6923
6974
  lifecycle: createLifecycleAPI(cleanupStack),
6924
6975
  state: createStateAPI({ pluginId, tenantId, cache }),
6925
6976
  artifacts: createArtifactsAPI({ outdir }),
6926
- shell: createShellAPI({ permissions, cwd }),
6977
+ shell: createShellAPI({ permissions, cwd, processExecutor, processIdentity, signal }),
6927
6978
  events: eventEmitter ? createEventsAPI({ pluginId, emitter: eventEmitter }) : createNoopEventsAPI(),
6928
6979
  invoke: pluginInvoker ? createInvokeAPI({
6929
6980
  permissions,
@@ -7459,6 +7510,15 @@ function createPluginContextV3(options) {
7459
7510
  cwd,
7460
7511
  outdir: finalOutdir,
7461
7512
  permissions: descriptor.permissions,
7513
+ processExecutor: extendedPlatform.processExecutor,
7514
+ processIdentity: {
7515
+ executionId: executionId ?? requestId,
7516
+ requestId,
7517
+ pluginId: descriptor.pluginId,
7518
+ handlerId: descriptor.handlerId,
7519
+ tenantId: descriptor.tenantId
7520
+ },
7521
+ signal,
7462
7522
  cache: enrichedPlatform.cache,
7463
7523
  // Use governed cache, not raw
7464
7524
  eventEmitter,
@@ -7714,6 +7774,29 @@ ${possiblePaths.join("\n")}`
7714
7774
  });
7715
7775
  });
7716
7776
  }
7777
+ function killTree(child, signal) {
7778
+ if (!child.pid) {
7779
+ return;
7780
+ }
7781
+ try {
7782
+ if (process.platform === "darwin" || process.platform === "linux") {
7783
+ process.kill(-child.pid, signal);
7784
+ } else {
7785
+ child.kill(signal);
7786
+ }
7787
+ } catch {
7788
+ try {
7789
+ child.kill(signal);
7790
+ } catch {
7791
+ }
7792
+ }
7793
+ }
7794
+ function createDefaultProcessExecutor(logger2) {
7795
+ if (process.platform === "darwin") {
7796
+ return new DarwinProcessBackend(logger2);
7797
+ }
7798
+ return new LinuxProcessBackend(logger2);
7799
+ }
7717
7800
  async function resolveAdapterMiddlewares(rawDecls, logger2) {
7718
7801
  const result = [];
7719
7802
  for (const { pkgRoot, decl } of rawDecls) {
@@ -7793,7 +7876,7 @@ function wrapCliResult(runResult, descriptor) {
7793
7876
  meta: standardMeta
7794
7877
  };
7795
7878
  }
7796
- 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;
7879
+ 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;
7797
7880
  var init_dist6 = __esm({
7798
7881
  "../../../core/plugin-runtime/dist/index.js"() {
7799
7882
  init_dist();
@@ -7888,7 +7971,6 @@ var init_dist6 = __esm({
7888
7971
  "mkfs",
7889
7972
  "dd if=",
7890
7973
  ":(){:|:&};:",
7891
- // Fork bomb
7892
7974
  "chmod -R 777 /",
7893
7975
  "chown -R",
7894
7976
  "> /dev/sda",
@@ -8262,6 +8344,434 @@ var init_dist6 = __esm({
8262
8344
  }
8263
8345
  };
8264
8346
  ANSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
8347
+ GovernedProcessError = class extends Error {
8348
+ code;
8349
+ details;
8350
+ constructor(code, message2, details = {}) {
8351
+ super(message2);
8352
+ this.name = "GovernedProcessError";
8353
+ this.code = code;
8354
+ this.details = details;
8355
+ }
8356
+ };
8357
+ NodeProcessBackend = class {
8358
+ constructor(logger2) {
8359
+ this.logger = logger2;
8360
+ }
8361
+ logger;
8362
+ active = /* @__PURE__ */ new Set();
8363
+ cancellers = /* @__PURE__ */ new Map();
8364
+ shuttingDown = false;
8365
+ configureProcess(_pid, _request) {
8366
+ return () => {
8367
+ };
8368
+ }
8369
+ treePids(rootPid) {
8370
+ if (process.platform !== "linux") {
8371
+ return [rootPid];
8372
+ }
8373
+ const children = /* @__PURE__ */ new Map();
8374
+ let entries;
8375
+ try {
8376
+ entries = fs5.readdirSync("/proc").filter((entry) => /^\d+$/.test(entry));
8377
+ } catch {
8378
+ return [rootPid];
8379
+ }
8380
+ for (const entry of entries) {
8381
+ const pid = Number(entry);
8382
+ try {
8383
+ const stat3 = fs5.readFileSync(`/proc/${pid}/stat`, "utf8");
8384
+ const close = stat3.lastIndexOf(")");
8385
+ const ppid = Number(stat3.slice(close + 2).split(" ")[1]);
8386
+ const list = children.get(ppid) ?? [];
8387
+ list.push(pid);
8388
+ children.set(ppid, list);
8389
+ } catch {
8390
+ }
8391
+ }
8392
+ const result = [rootPid];
8393
+ for (let i = 0; i < result.length; i++) {
8394
+ result.push(...children.get(result[i]) ?? []);
8395
+ }
8396
+ return result;
8397
+ }
8398
+ snapshot(pid) {
8399
+ const pids = this.treePids(pid);
8400
+ let memoryMb = 0;
8401
+ let cpuMs = 0;
8402
+ for (const current of pids) {
8403
+ if (process.platform !== "linux") {
8404
+ continue;
8405
+ }
8406
+ try {
8407
+ const status = fs5.readFileSync(`/proc/${current}/status`, "utf8");
8408
+ const rss = /^VmRSS:\s+(\d+)\s+kB$/m.exec(status);
8409
+ memoryMb += rss ? Number(rss[1]) / 1024 : 0;
8410
+ const stat3 = fs5.readFileSync(`/proc/${current}/stat`, "utf8");
8411
+ const close = stat3.lastIndexOf(")");
8412
+ const fields = stat3.slice(close + 2).split(" ");
8413
+ const ticks = Number(fields[11]) + Number(fields[12]);
8414
+ cpuMs += ticks / 100 * 1e3;
8415
+ } catch {
8416
+ }
8417
+ }
8418
+ return { cpuMs, memoryMb, processCount: pids.length };
8419
+ }
8420
+ async execute(request) {
8421
+ if (this.shuttingDown) {
8422
+ throw new GovernedProcessError("PROCESS_CANCELLED", "Process backend is shutting down");
8423
+ }
8424
+ const attempts = request.retry?.maxAttempts ?? 1;
8425
+ if (attempts > 1 && !request.retry?.idempotent) {
8426
+ throw new GovernedProcessError("PROCESS_SPAWN_FAILED", "Retrying shell commands requires idempotent=true");
8427
+ }
8428
+ let lastError;
8429
+ for (let attempt = 1; attempt <= attempts; attempt++) {
8430
+ try {
8431
+ return await this.runOnce(request, attempt);
8432
+ } catch (error2) {
8433
+ lastError = error2;
8434
+ if (attempt === attempts) {
8435
+ break;
8436
+ }
8437
+ if (!(error2 instanceof GovernedProcessError) || error2.code !== "PROCESS_SPAWN_FAILED") {
8438
+ break;
8439
+ }
8440
+ const base2 = request.retry?.initialDelayMs ?? 250;
8441
+ const max = request.retry?.maxDelayMs ?? 5e3;
8442
+ const jitter = request.retry?.jitter ?? 0.1;
8443
+ const delay = Math.min(max, base2 * 2 ** (attempt - 1));
8444
+ await new Promise((resolve32) => {
8445
+ setTimeout(resolve32, Math.floor(delay * (1 + Math.random() * jitter)));
8446
+ });
8447
+ }
8448
+ }
8449
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
8450
+ }
8451
+ runOnce(request, attempt) {
8452
+ const started = Date.now();
8453
+ const processId = request.processId ?? crypto4.randomUUID();
8454
+ this.logger?.info("process.execution.started", {
8455
+ component: "process-executor",
8456
+ operation: "execute",
8457
+ processId,
8458
+ executionId: request.identity.executionId,
8459
+ requestId: request.identity.requestId,
8460
+ pluginId: request.identity.pluginId,
8461
+ handlerId: request.identity.handlerId,
8462
+ command: request.command,
8463
+ argCount: request.args.length,
8464
+ cwd: request.cwd,
8465
+ attempt,
8466
+ limits: request.limits
8467
+ });
8468
+ const maxOutput = request.limits.maxOutputBytes ?? 8 * 1024 * 1024;
8469
+ const graceMs = request.limits.graceMs ?? 1e3;
8470
+ return new Promise((resolve32, reject) => {
8471
+ let child;
8472
+ try {
8473
+ child = child_process.spawn(request.command, request.args, {
8474
+ cwd: request.cwd,
8475
+ env: { ...process.env, ...request.env },
8476
+ detached: process.platform === "darwin" || process.platform === "linux",
8477
+ shell: false,
8478
+ stdio: ["ignore", "pipe", "pipe"]
8479
+ });
8480
+ } catch (error2) {
8481
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", `Failed to spawn ${request.command}`, { cause: String(error2) }));
8482
+ return;
8483
+ }
8484
+ child.once("error", (error2) => {
8485
+ if (!child.pid) {
8486
+ this.logger?.error("process.execution.failed", error2, {
8487
+ component: "process-executor",
8488
+ operation: "execute",
8489
+ executionId: request.identity.executionId,
8490
+ requestId: request.identity.requestId,
8491
+ pluginId: request.identity.pluginId,
8492
+ command: request.command
8493
+ });
8494
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", error2.message));
8495
+ }
8496
+ });
8497
+ if (!child.pid) {
8498
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", "Process did not receive a PID"));
8499
+ return;
8500
+ }
8501
+ const pid = child.pid;
8502
+ this.active.add(pid);
8503
+ let cleanupProcessConfig = () => {
8504
+ };
8505
+ try {
8506
+ cleanupProcessConfig = this.configureProcess(pid, request);
8507
+ } catch (error2) {
8508
+ killTree(child, "SIGKILL");
8509
+ this.active.delete(pid);
8510
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", "Unable to apply process limits", { cause: String(error2) }));
8511
+ return;
8512
+ }
8513
+ let stdout = "";
8514
+ let stderr = "";
8515
+ let stdoutBytes = 0;
8516
+ let stderrBytes = 0;
8517
+ let reason = "completed";
8518
+ let peakMemoryMb = 0;
8519
+ let peakCpuMs = 0;
8520
+ let peakProcessCount = 1;
8521
+ let settled = false;
8522
+ const finish = (code, signal) => {
8523
+ if (settled) {
8524
+ return;
8525
+ }
8526
+ settled = true;
8527
+ this.active.delete(pid);
8528
+ this.cancellers.delete(processId);
8529
+ cleanupProcessConfig();
8530
+ clearTimeout(timeout);
8531
+ clearInterval(monitor);
8532
+ const usage = {
8533
+ wallTimeMs: Date.now() - started,
8534
+ cpuMs: peakCpuMs,
8535
+ peakMemoryMb,
8536
+ processCount: peakProcessCount,
8537
+ stdoutBytes,
8538
+ stderrBytes
8539
+ };
8540
+ const result = {
8541
+ processId,
8542
+ code,
8543
+ signal: signal ?? void 0,
8544
+ stdout,
8545
+ stderr,
8546
+ ok: reason === "completed" && code === 0,
8547
+ terminationReason: reason,
8548
+ usage,
8549
+ attempts: attempt
8550
+ };
8551
+ this.logger?.info("process.execution.finished", {
8552
+ component: "process-executor",
8553
+ operation: "execute",
8554
+ processId,
8555
+ executionId: request.identity.executionId,
8556
+ requestId: request.identity.requestId,
8557
+ pluginId: request.identity.pluginId,
8558
+ command: request.command,
8559
+ ok: result.ok,
8560
+ code: result.code,
8561
+ terminationReason: result.terminationReason,
8562
+ usage: result.usage,
8563
+ attempts: result.attempts
8564
+ });
8565
+ if (reason === "completed") {
8566
+ resolve32(result);
8567
+ return;
8568
+ }
8569
+ const codes = {
8570
+ timeout: "PROCESS_TIMEOUT",
8571
+ cancelled: "PROCESS_CANCELLED",
8572
+ memory_limit: "PROCESS_MEMORY_LIMIT",
8573
+ cpu_limit: "PROCESS_CPU_LIMIT",
8574
+ process_limit: "PROCESS_LIMIT",
8575
+ output_limit: "PROCESS_OUTPUT_LIMIT",
8576
+ shutdown: "PROCESS_CANCELLED"
8577
+ };
8578
+ const governedError = new GovernedProcessError(codes[reason], `Process terminated: ${reason}`, { result });
8579
+ this.logger?.warn("process.execution.terminated", {
8580
+ component: "process-executor",
8581
+ operation: "execute",
8582
+ processId,
8583
+ executionId: request.identity.executionId,
8584
+ requestId: request.identity.requestId,
8585
+ pluginId: request.identity.pluginId,
8586
+ terminationReason: reason,
8587
+ usage
8588
+ });
8589
+ reject(governedError);
8590
+ };
8591
+ const terminate = (next) => {
8592
+ if (settled) {
8593
+ return;
8594
+ }
8595
+ reason = next;
8596
+ killTree(child, "SIGTERM");
8597
+ setTimeout(() => killTree(child, "SIGKILL"), graceMs);
8598
+ };
8599
+ this.cancellers.set(processId, terminate);
8600
+ const timeout = setTimeout(() => terminate("timeout"), request.limits.timeoutMs);
8601
+ const monitor = setInterval(() => {
8602
+ const sample = this.snapshot(pid);
8603
+ peakMemoryMb = Math.max(peakMemoryMb, sample.memoryMb);
8604
+ peakCpuMs = Math.max(peakCpuMs, sample.cpuMs);
8605
+ peakProcessCount = Math.max(peakProcessCount, sample.processCount);
8606
+ if (request.limits.memoryMb && sample.memoryMb > request.limits.memoryMb) {
8607
+ terminate("memory_limit");
8608
+ } else if (request.limits.cpuMs && sample.cpuMs > request.limits.cpuMs) {
8609
+ terminate("cpu_limit");
8610
+ } else if (request.limits.maxProcesses && sample.processCount > request.limits.maxProcesses) {
8611
+ terminate("process_limit");
8612
+ }
8613
+ }, 50);
8614
+ const abort = () => terminate("cancelled");
8615
+ request.signal?.addEventListener("abort", abort, { once: true });
8616
+ const append = (stream2, chunk) => {
8617
+ if (stream2 === "stdout") {
8618
+ stdoutBytes += chunk.byteLength;
8619
+ stdout += chunk.toString();
8620
+ } else {
8621
+ stderrBytes += chunk.byteLength;
8622
+ stderr += chunk.toString();
8623
+ }
8624
+ if (stdoutBytes + stderrBytes > maxOutput) {
8625
+ terminate("output_limit");
8626
+ }
8627
+ };
8628
+ child.stdout?.on("data", (chunk) => append("stdout", chunk));
8629
+ child.stderr?.on("data", (chunk) => append("stderr", chunk));
8630
+ child.once("error", (error2) => {
8631
+ if (!settled) {
8632
+ this.logger?.error("process.execution.failed", error2, {
8633
+ component: "process-executor",
8634
+ operation: "execute",
8635
+ processId,
8636
+ executionId: request.identity.executionId,
8637
+ requestId: request.identity.requestId,
8638
+ pluginId: request.identity.pluginId,
8639
+ command: request.command
8640
+ });
8641
+ reject(new GovernedProcessError("PROCESS_SPAWN_FAILED", error2.message));
8642
+ }
8643
+ });
8644
+ child.once("close", (code, signal) => {
8645
+ request.signal?.removeEventListener("abort", abort);
8646
+ finish(code, signal);
8647
+ });
8648
+ });
8649
+ }
8650
+ async cancel(processId, reason = "cancelled") {
8651
+ const cancel = this.cancellers.get(processId);
8652
+ if (cancel) {
8653
+ cancel(reason);
8654
+ }
8655
+ if (reason === "shutdown") {
8656
+ this.cancellers.delete(processId);
8657
+ }
8658
+ }
8659
+ async shutdown() {
8660
+ this.shuttingDown = true;
8661
+ for (const cancel of this.cancellers.values()) {
8662
+ cancel("shutdown");
8663
+ }
8664
+ for (const pid of this.active) {
8665
+ try {
8666
+ process.kill(-pid, "SIGTERM");
8667
+ } catch {
8668
+ }
8669
+ }
8670
+ this.active.clear();
8671
+ this.cancellers.clear();
8672
+ }
8673
+ };
8674
+ DarwinProcessBackend = class extends NodeProcessBackend {
8675
+ capabilities() {
8676
+ return { platform: "darwin", processGroups: true, hardMemoryLimit: false, hardCpuLimit: false, processTreeAccounting: false, maxProcesses: false };
8677
+ }
8678
+ };
8679
+ LinuxProcessBackend = class extends NodeProcessBackend {
8680
+ cgroupRoot = "/sys/fs/cgroup";
8681
+ cgroupAvailable() {
8682
+ try {
8683
+ return fs5.existsSync(path13.join(this.cgroupRoot, "cgroup.controllers")) && fs5.existsSync(path13.join(this.cgroupRoot, "cgroup.procs")) && fs5.accessSync(this.cgroupRoot, fs5.constants.W_OK) === void 0;
8684
+ } catch {
8685
+ return false;
8686
+ }
8687
+ }
8688
+ capabilities() {
8689
+ const cgroup = this.cgroupAvailable();
8690
+ return { platform: "linux", processGroups: true, hardMemoryLimit: cgroup, hardCpuLimit: false, processTreeAccounting: true, maxProcesses: cgroup };
8691
+ }
8692
+ configureProcess(pid, request) {
8693
+ if (!this.cgroupAvailable()) {
8694
+ return () => {
8695
+ };
8696
+ }
8697
+ const group = path13.join(this.cgroupRoot, `kb-plugin-${pid}`);
8698
+ fs5.mkdirSync(group);
8699
+ if (request.limits.memoryMb) {
8700
+ fs5.writeFileSync(path13.join(group, "memory.max"), String(Math.floor(request.limits.memoryMb * 1024 * 1024)));
8701
+ }
8702
+ if (request.limits.maxProcesses) {
8703
+ fs5.writeFileSync(path13.join(group, "pids.max"), String(Math.floor(request.limits.maxProcesses)));
8704
+ }
8705
+ fs5.writeFileSync(path13.join(group, "cgroup.procs"), String(pid));
8706
+ return () => {
8707
+ try {
8708
+ fs5.readFileSync(path13.join(group, "cgroup.procs"), "utf8");
8709
+ fs5.rmSync(group, { recursive: true, force: true });
8710
+ } catch {
8711
+ }
8712
+ };
8713
+ }
8714
+ };
8715
+ registered = /* @__PURE__ */ new WeakMap();
8716
+ BrokeredProcessExecutor = class {
8717
+ constructor(broker, delegate, logger2) {
8718
+ this.broker = broker;
8719
+ this.delegate = delegate;
8720
+ this.logger = logger2;
8721
+ }
8722
+ broker;
8723
+ delegate;
8724
+ logger;
8725
+ capabilities() {
8726
+ return this.delegate.capabilities();
8727
+ }
8728
+ async execute(request) {
8729
+ const resource = `process:shell:${request.identity.pluginId}`;
8730
+ const resources = registered.get(this.broker) ?? /* @__PURE__ */ new Set();
8731
+ if (!resources.has(resource)) {
8732
+ this.broker.registerLimit(resource, { maxConcurrentRequests: request.limits.maxConcurrent ?? 1 });
8733
+ resources.add(resource);
8734
+ registered.set(this.broker, resources);
8735
+ }
8736
+ const deadline = Date.now() + request.limits.timeoutMs;
8737
+ let lastWait = 25;
8738
+ while (Date.now() < deadline) {
8739
+ if (request.signal?.aborted) {
8740
+ throw new GovernedProcessError("PROCESS_CANCELLED", "Shell admission was cancelled");
8741
+ }
8742
+ const acquired = await this.broker.tryAcquire(resource);
8743
+ if (acquired.allowed) {
8744
+ this.logger?.debug("process.execution.admitted", {
8745
+ component: "process-executor",
8746
+ operation: "admission",
8747
+ resource,
8748
+ executionId: request.identity.executionId,
8749
+ requestId: request.identity.requestId,
8750
+ pluginId: request.identity.pluginId
8751
+ });
8752
+ try {
8753
+ return await this.delegate.execute(request);
8754
+ } finally {
8755
+ await acquired.release();
8756
+ }
8757
+ }
8758
+ await new Promise((resolve32) => {
8759
+ setTimeout(resolve32, Math.min(lastWait, acquired.waitTimeMs ?? lastWait));
8760
+ });
8761
+ lastWait = Math.min(lastWait * 2, 500);
8762
+ }
8763
+ throw new GovernedProcessError("PROCESS_ADMISSION_TIMEOUT", "Shell capacity was not available before execution deadline", {
8764
+ resource,
8765
+ timeoutMs: request.limits.timeoutMs
8766
+ });
8767
+ }
8768
+ async shutdown() {
8769
+ await this.delegate.shutdown();
8770
+ }
8771
+ async cancel(processId, reason) {
8772
+ await this.delegate.cancel(processId, reason);
8773
+ }
8774
+ };
8265
8775
  }
8266
8776
  });
8267
8777
 
@@ -19974,11 +20484,11 @@ var require_codegen = __commonJS({
19974
20484
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
19975
20485
  return `${varKind} ${this.name}${rhs};` + _n;
19976
20486
  }
19977
- optimizeNames(names, constants4) {
20487
+ optimizeNames(names, constants5) {
19978
20488
  if (!names[this.name.str])
19979
20489
  return;
19980
20490
  if (this.rhs)
19981
- this.rhs = optimizeExpr(this.rhs, names, constants4);
20491
+ this.rhs = optimizeExpr(this.rhs, names, constants5);
19982
20492
  return this;
19983
20493
  }
19984
20494
  get names() {
@@ -19995,10 +20505,10 @@ var require_codegen = __commonJS({
19995
20505
  render({ _n }) {
19996
20506
  return `${this.lhs} = ${this.rhs};` + _n;
19997
20507
  }
19998
- optimizeNames(names, constants4) {
20508
+ optimizeNames(names, constants5) {
19999
20509
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
20000
20510
  return;
20001
- this.rhs = optimizeExpr(this.rhs, names, constants4);
20511
+ this.rhs = optimizeExpr(this.rhs, names, constants5);
20002
20512
  return this;
20003
20513
  }
20004
20514
  get names() {
@@ -20059,8 +20569,8 @@ var require_codegen = __commonJS({
20059
20569
  optimizeNodes() {
20060
20570
  return `${this.code}` ? this : void 0;
20061
20571
  }
20062
- optimizeNames(names, constants4) {
20063
- this.code = optimizeExpr(this.code, names, constants4);
20572
+ optimizeNames(names, constants5) {
20573
+ this.code = optimizeExpr(this.code, names, constants5);
20064
20574
  return this;
20065
20575
  }
20066
20576
  get names() {
@@ -20089,12 +20599,12 @@ var require_codegen = __commonJS({
20089
20599
  }
20090
20600
  return nodes.length > 0 ? this : void 0;
20091
20601
  }
20092
- optimizeNames(names, constants4) {
20602
+ optimizeNames(names, constants5) {
20093
20603
  const { nodes } = this;
20094
20604
  let i = nodes.length;
20095
20605
  while (i--) {
20096
20606
  const n = nodes[i];
20097
- if (n.optimizeNames(names, constants4))
20607
+ if (n.optimizeNames(names, constants5))
20098
20608
  continue;
20099
20609
  subtractNames(names, n.names);
20100
20610
  nodes.splice(i, 1);
@@ -20147,12 +20657,12 @@ var require_codegen = __commonJS({
20147
20657
  return void 0;
20148
20658
  return this;
20149
20659
  }
20150
- optimizeNames(names, constants4) {
20660
+ optimizeNames(names, constants5) {
20151
20661
  var _a3;
20152
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants4);
20153
- if (!(super.optimizeNames(names, constants4) || this.else))
20662
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants5);
20663
+ if (!(super.optimizeNames(names, constants5) || this.else))
20154
20664
  return;
20155
- this.condition = optimizeExpr(this.condition, names, constants4);
20665
+ this.condition = optimizeExpr(this.condition, names, constants5);
20156
20666
  return this;
20157
20667
  }
20158
20668
  get names() {
@@ -20175,10 +20685,10 @@ var require_codegen = __commonJS({
20175
20685
  render(opts) {
20176
20686
  return `for(${this.iteration})` + super.render(opts);
20177
20687
  }
20178
- optimizeNames(names, constants4) {
20179
- if (!super.optimizeNames(names, constants4))
20688
+ optimizeNames(names, constants5) {
20689
+ if (!super.optimizeNames(names, constants5))
20180
20690
  return;
20181
- this.iteration = optimizeExpr(this.iteration, names, constants4);
20691
+ this.iteration = optimizeExpr(this.iteration, names, constants5);
20182
20692
  return this;
20183
20693
  }
20184
20694
  get names() {
@@ -20214,10 +20724,10 @@ var require_codegen = __commonJS({
20214
20724
  render(opts) {
20215
20725
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
20216
20726
  }
20217
- optimizeNames(names, constants4) {
20218
- if (!super.optimizeNames(names, constants4))
20727
+ optimizeNames(names, constants5) {
20728
+ if (!super.optimizeNames(names, constants5))
20219
20729
  return;
20220
- this.iterable = optimizeExpr(this.iterable, names, constants4);
20730
+ this.iterable = optimizeExpr(this.iterable, names, constants5);
20221
20731
  return this;
20222
20732
  }
20223
20733
  get names() {
@@ -20259,11 +20769,11 @@ var require_codegen = __commonJS({
20259
20769
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
20260
20770
  return this;
20261
20771
  }
20262
- optimizeNames(names, constants4) {
20772
+ optimizeNames(names, constants5) {
20263
20773
  var _a3, _b;
20264
- super.optimizeNames(names, constants4);
20265
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants4);
20266
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants4);
20774
+ super.optimizeNames(names, constants5);
20775
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants5);
20776
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants5);
20267
20777
  return this;
20268
20778
  }
20269
20779
  get names() {
@@ -20564,7 +21074,7 @@ var require_codegen = __commonJS({
20564
21074
  function addExprNames(names, from) {
20565
21075
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
20566
21076
  }
20567
- function optimizeExpr(expr, names, constants4) {
21077
+ function optimizeExpr(expr, names, constants5) {
20568
21078
  if (expr instanceof code_1.Name)
20569
21079
  return replaceName(expr);
20570
21080
  if (!canOptimize(expr))
@@ -20579,14 +21089,14 @@ var require_codegen = __commonJS({
20579
21089
  return items;
20580
21090
  }, []));
20581
21091
  function replaceName(n) {
20582
- const c = constants4[n.str];
21092
+ const c = constants5[n.str];
20583
21093
  if (c === void 0 || names[n.str] !== 1)
20584
21094
  return n;
20585
21095
  delete names[n.str];
20586
21096
  return c;
20587
21097
  }
20588
21098
  function canOptimize(e) {
20589
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants4[c.str] !== void 0);
21099
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants5[c.str] !== void 0);
20590
21100
  }
20591
21101
  }
20592
21102
  function subtractNames(names, from) {
@@ -22648,15 +23158,14 @@ var require_data = __commonJS({
22648
23158
  }
22649
23159
  });
22650
23160
 
22651
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js
23161
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js
22652
23162
  var require_utils = __commonJS({
22653
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
23163
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js"(exports$1, module) {
22654
23164
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
22655
23165
  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);
22656
23166
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
22657
23167
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
22658
23168
  var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
22659
- var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/?]$/iu);
22660
23169
  function stringArrayToHexStripped(input) {
22661
23170
  let acc = "";
22662
23171
  let code = 0;
@@ -22799,7 +23308,7 @@ var require_utils = __commonJS({
22799
23308
  continue;
22800
23309
  }
22801
23310
  } else if (input[0] === "/") {
22802
- if (input[1] === ".") {
23311
+ if (input[1] === "." || input[1] === "/") {
22803
23312
  output.push("/");
22804
23313
  break;
22805
23314
  }
@@ -22881,30 +23390,10 @@ var require_utils = __commonJS({
22881
23390
  }
22882
23391
  return output;
22883
23392
  }
22884
- var BYTE_HEX = new Array(256);
22885
- {
22886
- const HEX_DIGITS = "0123456789ABCDEF";
22887
- for (let i = 0; i < 256; i++) {
22888
- BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
22889
- }
22890
- }
22891
- function isEscapeSafe(cp2) {
22892
- 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;
22893
- }
22894
- function percentEncodeNonAscii(cp2) {
22895
- if (cp2 < 2048) {
22896
- return BYTE_HEX[192 | cp2 >> 6] + BYTE_HEX[128 | cp2 & 63];
22897
- }
22898
- if (cp2 < 65536) {
22899
- return BYTE_HEX[224 | cp2 >> 12] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
22900
- }
22901
- return BYTE_HEX[240 | cp2 >> 18] + BYTE_HEX[128 | cp2 >> 12 & 63] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
22902
- }
22903
23393
  function normalizePathEncoding(input) {
22904
23394
  let output = "";
22905
23395
  for (let i = 0; i < input.length; i++) {
22906
- const ch = input[i];
22907
- if (ch === "%" && i + 2 < input.length) {
23396
+ if (input[i] === "%" && i + 2 < input.length) {
22908
23397
  const hex3 = input.slice(i + 1, i + 3);
22909
23398
  if (isHexPair(hex3)) {
22910
23399
  const normalizedHex = hex3.toUpperCase();
@@ -22918,66 +23407,10 @@ var require_utils = __commonJS({
22918
23407
  continue;
22919
23408
  }
22920
23409
  }
22921
- if (isPathCharacter(ch)) {
22922
- output += ch;
23410
+ if (isPathCharacter(input[i])) {
23411
+ output += input[i];
22923
23412
  } else {
22924
- const code = input.charCodeAt(i);
22925
- if (code < 128) {
22926
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
22927
- } else if (code < 55296 || code > 57343) {
22928
- output += percentEncodeNonAscii(code);
22929
- } else if (code <= 56319 && i + 1 < input.length) {
22930
- const low = input.charCodeAt(i + 1);
22931
- if (low >= 56320 && low <= 57343) {
22932
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
22933
- i++;
22934
- } else {
22935
- output += percentEncodeNonAscii(65533);
22936
- }
22937
- } else {
22938
- output += percentEncodeNonAscii(65533);
22939
- }
22940
- }
22941
- }
22942
- return output;
22943
- }
22944
- function normalizeQueryFragmentEncoding(input) {
22945
- let output = "";
22946
- for (let i = 0; i < input.length; i++) {
22947
- const ch = input[i];
22948
- if (ch === "%" && i + 2 < input.length) {
22949
- const hex3 = input.slice(i + 1, i + 3);
22950
- if (isHexPair(hex3)) {
22951
- const normalizedHex = hex3.toUpperCase();
22952
- const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
22953
- if (isUnreserved(decoded)) {
22954
- output += decoded;
22955
- } else {
22956
- output += "%" + normalizedHex;
22957
- }
22958
- i += 2;
22959
- continue;
22960
- }
22961
- }
22962
- if (isQueryFragmentCharacter(ch)) {
22963
- output += ch;
22964
- } else {
22965
- const code = input.charCodeAt(i);
22966
- if (code < 128) {
22967
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
22968
- } else if (code < 55296 || code > 57343) {
22969
- output += percentEncodeNonAscii(code);
22970
- } else if (code <= 56319 && i + 1 < input.length) {
22971
- const low = input.charCodeAt(i + 1);
22972
- if (low >= 56320 && low <= 57343) {
22973
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
22974
- i++;
22975
- } else {
22976
- output += percentEncodeNonAscii(65533);
22977
- }
22978
- } else {
22979
- output += percentEncodeNonAscii(65533);
22980
- }
23413
+ output += escape(input[i]);
22981
23414
  }
22982
23415
  }
22983
23416
  return output;
@@ -22985,8 +23418,7 @@ var require_utils = __commonJS({
22985
23418
  function escapePreservingEscapes(input) {
22986
23419
  let output = "";
22987
23420
  for (let i = 0; i < input.length; i++) {
22988
- const ch = input[i];
22989
- if (ch === "%" && i + 2 < input.length) {
23421
+ if (input[i] === "%" && i + 2 < input.length) {
22990
23422
  const hex3 = input.slice(i + 1, i + 3);
22991
23423
  if (isHexPair(hex3)) {
22992
23424
  output += "%" + hex3.toUpperCase();
@@ -22994,22 +23426,7 @@ var require_utils = __commonJS({
22994
23426
  continue;
22995
23427
  }
22996
23428
  }
22997
- const code = input.charCodeAt(i);
22998
- if (code < 128) {
22999
- output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
23000
- } else if (code < 55296 || code > 57343) {
23001
- output += percentEncodeNonAscii(code);
23002
- } else if (code <= 56319 && i + 1 < input.length) {
23003
- const low = input.charCodeAt(i + 1);
23004
- if (low >= 56320 && low <= 57343) {
23005
- output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
23006
- i++;
23007
- } else {
23008
- output += percentEncodeNonAscii(65533);
23009
- }
23010
- } else {
23011
- output += percentEncodeNonAscii(65533);
23012
- }
23429
+ output += escape(input[i]);
23013
23430
  }
23014
23431
  return output;
23015
23432
  }
@@ -23043,7 +23460,6 @@ var require_utils = __commonJS({
23043
23460
  reescapeHostDelimiters,
23044
23461
  normalizePercentEncoding,
23045
23462
  normalizePathEncoding,
23046
- normalizeQueryFragmentEncoding,
23047
23463
  escapePreservingEscapes,
23048
23464
  removeDotSegments,
23049
23465
  isIPv4,
@@ -23054,9 +23470,9 @@ var require_utils = __commonJS({
23054
23470
  }
23055
23471
  });
23056
23472
 
23057
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js
23473
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js
23058
23474
  var require_schemes = __commonJS({
23059
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
23475
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js"(exports$1, module) {
23060
23476
  var { isUUID } = require_utils();
23061
23477
  var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
23062
23478
  var supportedSchemeNames = (
@@ -23263,10 +23679,10 @@ var require_schemes = __commonJS({
23263
23679
  }
23264
23680
  });
23265
23681
 
23266
- // ../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js
23682
+ // ../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js
23267
23683
  var require_fast_uri = __commonJS({
23268
- "../../../node_modules/.pnpm/fast-uri@4.1.1/node_modules/fast-uri/index.js"(exports$1, module) {
23269
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, normalizeQueryFragmentEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
23684
+ "../../../node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js"(exports$1, module) {
23685
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
23270
23686
  var { SCHEMES, getSchemeHandler } = require_schemes();
23271
23687
  function normalize4(uri, options) {
23272
23688
  if (typeof uri === "string") {
@@ -23280,7 +23696,12 @@ var require_fast_uri = __commonJS({
23280
23696
  }
23281
23697
  function resolve9(baseURI, relativeURI, options) {
23282
23698
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
23283
- const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
23699
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
23700
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
23701
+ if (baseMalformed || relativeMalformed) {
23702
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
23703
+ }
23704
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
23284
23705
  schemelessOptions.skipEscape = true;
23285
23706
  return serialize2(resolved, schemelessOptions);
23286
23707
  }
@@ -23406,6 +23827,7 @@ var require_fast_uri = __commonJS({
23406
23827
  }
23407
23828
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
23408
23829
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
23830
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
23409
23831
  function getParseError(parsed, matches) {
23410
23832
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
23411
23833
  return 'URI path must start with "/" when authority is present.';
@@ -23440,9 +23862,23 @@ var require_fast_uri = __commonJS({
23440
23862
  parsed.error = "URI authority must not contain a literal backslash.";
23441
23863
  malformedAuthorityOrPort = true;
23442
23864
  }
23865
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
23866
+ if (introducerMatch !== null) {
23867
+ const region = introducerMatch[1];
23868
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
23869
+ if (normalizedRegion.length >= 2) {
23870
+ if (normalizedRegion.slice(0, 2) !== "//") {
23871
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
23872
+ malformedAuthorityOrPort = true;
23873
+ } else if (region.length !== normalizedRegion.length) {
23874
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
23875
+ malformedAuthorityOrPort = true;
23876
+ }
23877
+ }
23878
+ }
23443
23879
  const matches = uri.match(URI_PARSE);
23444
23880
  if (matches) {
23445
- parsed.scheme = matches[1] === void 0 ? void 0 : matches[1].toLowerCase();
23881
+ parsed.scheme = matches[1];
23446
23882
  parsed.userinfo = matches[3];
23447
23883
  parsed.host = matches[4];
23448
23884
  parsed.port = parseInt(matches[5], 10);
@@ -23501,11 +23937,12 @@ var require_fast_uri = __commonJS({
23501
23937
  if (parsed.path) {
23502
23938
  parsed.path = normalizePathEncoding(parsed.path);
23503
23939
  }
23504
- if (parsed.query) {
23505
- parsed.query = normalizeQueryFragmentEncoding(parsed.query);
23506
- }
23507
23940
  if (parsed.fragment) {
23508
- parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
23941
+ try {
23942
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
23943
+ } catch {
23944
+ parsed.error = parsed.error || "URI malformed";
23945
+ }
23509
23946
  }
23510
23947
  }
23511
23948
  if (schemeHandler && schemeHandler.parse) {
@@ -27159,6 +27596,7 @@ __export(dist_exports2, {
27159
27596
  createExecutionId: () => createExecutionId,
27160
27597
  createIsolatedExecutionBackend: () => createIsolatedExecutionBackend,
27161
27598
  createTimeoutPromise: () => createTimeoutPromise,
27599
+ ensureHostProcessExecutor: () => ensureHostProcessExecutor,
27162
27600
  isExecutionLayerError: () => isExecutionLayerError,
27163
27601
  isKnownErrorCode: () => isKnownErrorCode,
27164
27602
  localWorkspaceManager: () => localWorkspaceManager,
@@ -27339,7 +27777,19 @@ function createDefaultIPCServerFactory() {
27339
27777
  }
27340
27778
  };
27341
27779
  }
27780
+ function ensureHostProcessExecutor(platform2) {
27781
+ const host = platform2;
27782
+ if (host.processExecutor || !host.setAdapter || host.hasResourceBroker !== true || !host.resourceBroker) {
27783
+ return;
27784
+ }
27785
+ host.setAdapter("processExecutor", new BrokeredProcessExecutor(
27786
+ host.resourceBroker,
27787
+ createDefaultProcessExecutor(host.logger),
27788
+ host.logger
27789
+ ));
27790
+ }
27342
27791
  function createExecutionBackend(options) {
27792
+ ensureHostProcessExecutor(options.platform);
27343
27793
  const mode = options.mode === "auto" || !options.mode ? detectMode() : options.mode;
27344
27794
  switch (mode) {
27345
27795
  case "in-process":
@@ -27777,7 +28227,9 @@ var init_dist9 = __esm({
27777
28227
  }
27778
28228
  } : void 0;
27779
28229
  const loggerOverride = requestToExecute.context?.loggerOverride;
27780
- const effectivePlatform = loggerOverride ? { ...this.platform, logger: loggerOverride } : this.platform;
28230
+ const effectivePlatform = loggerOverride ? Object.create(this.platform, {
28231
+ logger: { value: loggerOverride, enumerable: true, configurable: true }
28232
+ }) : this.platform;
27781
28233
  const adapterMiddlewares = await this.getMiddlewares();
27782
28234
  const runResult = await runInProcess({
27783
28235
  descriptor: requestToExecute.descriptor,
@@ -37159,7 +37611,7 @@ var require_thread_stream = __commonJS({
37159
37611
  var { version: version3 } = require_package();
37160
37612
  var { EventEmitter: EventEmitter3 } = __require("events");
37161
37613
  var { Worker: Worker2 } = __require("worker_threads");
37162
- var { join: join11 } = __require("path");
37614
+ var { join: join12 } = __require("path");
37163
37615
  var { pathToFileURL: pathToFileURL4 } = __require("url");
37164
37616
  var { wait } = require_wait();
37165
37617
  var {
@@ -37195,7 +37647,7 @@ var require_thread_stream = __commonJS({
37195
37647
  function createWorker(stream2, opts) {
37196
37648
  const { filename, workerData } = opts;
37197
37649
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
37198
- const toExecute = bundlerOverrides["thread-stream-worker"] || join11(__dirname, "lib", "worker.js");
37650
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join12(__dirname, "lib", "worker.js");
37199
37651
  const worker = new Worker2(toExecute, {
37200
37652
  ...opts.workerOpts,
37201
37653
  trackUnmanagedFds: false,
@@ -37583,9 +38035,9 @@ var require_thread_stream = __commonJS({
37583
38035
  var require_transport = __commonJS({
37584
38036
  "../../../node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports$1, module) {
37585
38037
  var { createRequire: createRequire4 } = __require("module");
37586
- var { existsSync: existsSync10 } = __require("fs");
38038
+ var { existsSync: existsSync11 } = __require("fs");
37587
38039
  var getCallers = require_caller();
37588
- var { join: join11, isAbsolute, sep: sep3 } = __require("path");
38040
+ var { join: join12, isAbsolute, sep: sep3 } = __require("path");
37589
38041
  var { fileURLToPath: fileURLToPath6 } = __require("url");
37590
38042
  var sleep3 = require_atomic_sleep();
37591
38043
  var onExit = require_on_exit_leak_free();
@@ -37657,7 +38109,7 @@ var require_transport = __commonJS({
37657
38109
  return false;
37658
38110
  }
37659
38111
  }
37660
- return isAbsolute(path15) && !existsSync10(path15);
38112
+ return isAbsolute(path15) && !existsSync11(path15);
37661
38113
  }
37662
38114
  function stripQuotes(value) {
37663
38115
  const first = value[0];
@@ -37738,7 +38190,7 @@ var require_transport = __commonJS({
37738
38190
  throw new Error("only one of target or targets can be specified");
37739
38191
  }
37740
38192
  if (targets) {
37741
- target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
38193
+ target = bundlerOverrides["pino-worker"] || join12(__dirname, "worker.js");
37742
38194
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
37743
38195
  return {
37744
38196
  ...dest,
@@ -37756,7 +38208,7 @@ var require_transport = __commonJS({
37756
38208
  });
37757
38209
  });
37758
38210
  } else if (pipeline) {
37759
- target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
38211
+ target = bundlerOverrides["pino-worker"] || join12(__dirname, "worker.js");
37760
38212
  options.pipelines = [pipeline.map((dest) => {
37761
38213
  return {
37762
38214
  ...dest,
@@ -37779,7 +38231,7 @@ var require_transport = __commonJS({
37779
38231
  return origin;
37780
38232
  }
37781
38233
  if (origin === "pino/file") {
37782
- return join11(__dirname, "..", "file.js");
38234
+ return join12(__dirname, "..", "file.js");
37783
38235
  }
37784
38236
  let fixTarget2;
37785
38237
  for (const filePath of callers) {
@@ -38754,7 +39206,7 @@ var require_safe_stable_stringify = __commonJS({
38754
39206
  return circularValue;
38755
39207
  }
38756
39208
  let res = "";
38757
- let join11 = ",";
39209
+ let join12 = ",";
38758
39210
  const originalIndentation = indentation;
38759
39211
  if (Array.isArray(value)) {
38760
39212
  if (value.length === 0) {
@@ -38768,7 +39220,7 @@ var require_safe_stable_stringify = __commonJS({
38768
39220
  indentation += spacer;
38769
39221
  res += `
38770
39222
  ${indentation}`;
38771
- join11 = `,
39223
+ join12 = `,
38772
39224
  ${indentation}`;
38773
39225
  }
38774
39226
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -38776,13 +39228,13 @@ ${indentation}`;
38776
39228
  for (; i < maximumValuesToStringify - 1; i++) {
38777
39229
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
38778
39230
  res += tmp2 !== void 0 ? tmp2 : "null";
38779
- res += join11;
39231
+ res += join12;
38780
39232
  }
38781
39233
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
38782
39234
  res += tmp !== void 0 ? tmp : "null";
38783
39235
  if (value.length - 1 > maximumBreadth) {
38784
39236
  const removedKeys = value.length - maximumBreadth - 1;
38785
- res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
39237
+ res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
38786
39238
  }
38787
39239
  if (spacer !== "") {
38788
39240
  res += `
@@ -38803,7 +39255,7 @@ ${originalIndentation}`;
38803
39255
  let separator = "";
38804
39256
  if (spacer !== "") {
38805
39257
  indentation += spacer;
38806
- join11 = `,
39258
+ join12 = `,
38807
39259
  ${indentation}`;
38808
39260
  whitespace = " ";
38809
39261
  }
@@ -38817,13 +39269,13 @@ ${indentation}`;
38817
39269
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
38818
39270
  if (tmp !== void 0) {
38819
39271
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
38820
- separator = join11;
39272
+ separator = join12;
38821
39273
  }
38822
39274
  }
38823
39275
  if (keyLength > maximumBreadth) {
38824
39276
  const removedKeys = keyLength - maximumBreadth;
38825
39277
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
38826
- separator = join11;
39278
+ separator = join12;
38827
39279
  }
38828
39280
  if (spacer !== "" && separator.length > 1) {
38829
39281
  res = `
@@ -38864,7 +39316,7 @@ ${originalIndentation}`;
38864
39316
  }
38865
39317
  const originalIndentation = indentation;
38866
39318
  let res = "";
38867
- let join11 = ",";
39319
+ let join12 = ",";
38868
39320
  if (Array.isArray(value)) {
38869
39321
  if (value.length === 0) {
38870
39322
  return "[]";
@@ -38877,7 +39329,7 @@ ${originalIndentation}`;
38877
39329
  indentation += spacer;
38878
39330
  res += `
38879
39331
  ${indentation}`;
38880
- join11 = `,
39332
+ join12 = `,
38881
39333
  ${indentation}`;
38882
39334
  }
38883
39335
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -38885,13 +39337,13 @@ ${indentation}`;
38885
39337
  for (; i < maximumValuesToStringify - 1; i++) {
38886
39338
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
38887
39339
  res += tmp2 !== void 0 ? tmp2 : "null";
38888
- res += join11;
39340
+ res += join12;
38889
39341
  }
38890
39342
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
38891
39343
  res += tmp !== void 0 ? tmp : "null";
38892
39344
  if (value.length - 1 > maximumBreadth) {
38893
39345
  const removedKeys = value.length - maximumBreadth - 1;
38894
- res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
39346
+ res += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
38895
39347
  }
38896
39348
  if (spacer !== "") {
38897
39349
  res += `
@@ -38904,7 +39356,7 @@ ${originalIndentation}`;
38904
39356
  let whitespace = "";
38905
39357
  if (spacer !== "") {
38906
39358
  indentation += spacer;
38907
- join11 = `,
39359
+ join12 = `,
38908
39360
  ${indentation}`;
38909
39361
  whitespace = " ";
38910
39362
  }
@@ -38913,7 +39365,7 @@ ${indentation}`;
38913
39365
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
38914
39366
  if (tmp !== void 0) {
38915
39367
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
38916
- separator = join11;
39368
+ separator = join12;
38917
39369
  }
38918
39370
  }
38919
39371
  if (spacer !== "" && separator.length > 1) {
@@ -38971,20 +39423,20 @@ ${originalIndentation}`;
38971
39423
  indentation += spacer;
38972
39424
  let res2 = `
38973
39425
  ${indentation}`;
38974
- const join12 = `,
39426
+ const join13 = `,
38975
39427
  ${indentation}`;
38976
39428
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
38977
39429
  let i = 0;
38978
39430
  for (; i < maximumValuesToStringify - 1; i++) {
38979
39431
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
38980
39432
  res2 += tmp2 !== void 0 ? tmp2 : "null";
38981
- res2 += join12;
39433
+ res2 += join13;
38982
39434
  }
38983
39435
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
38984
39436
  res2 += tmp !== void 0 ? tmp : "null";
38985
39437
  if (value.length - 1 > maximumBreadth) {
38986
39438
  const removedKeys = value.length - maximumBreadth - 1;
38987
- res2 += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
39439
+ res2 += `${join13}"... ${getItemCount(removedKeys)} not stringified"`;
38988
39440
  }
38989
39441
  res2 += `
38990
39442
  ${originalIndentation}`;
@@ -39000,16 +39452,16 @@ ${originalIndentation}`;
39000
39452
  return '"[Object]"';
39001
39453
  }
39002
39454
  indentation += spacer;
39003
- const join11 = `,
39455
+ const join12 = `,
39004
39456
  ${indentation}`;
39005
39457
  let res = "";
39006
39458
  let separator = "";
39007
39459
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
39008
39460
  if (isTypedArrayWithEntries(value)) {
39009
- res += stringifyTypedArray(value, join11, maximumBreadth);
39461
+ res += stringifyTypedArray(value, join12, maximumBreadth);
39010
39462
  keys = keys.slice(value.length);
39011
39463
  maximumPropertiesToStringify -= value.length;
39012
- separator = join11;
39464
+ separator = join12;
39013
39465
  }
39014
39466
  if (deterministic) {
39015
39467
  keys = sort(keys, comparator);
@@ -39020,13 +39472,13 @@ ${indentation}`;
39020
39472
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
39021
39473
  if (tmp !== void 0) {
39022
39474
  res += `${separator}${strEscape(key2)}: ${tmp}`;
39023
- separator = join11;
39475
+ separator = join12;
39024
39476
  }
39025
39477
  }
39026
39478
  if (keyLength > maximumBreadth) {
39027
39479
  const removedKeys = keyLength - maximumBreadth;
39028
39480
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
39029
- separator = join11;
39481
+ separator = join12;
39030
39482
  }
39031
39483
  if (separator !== "") {
39032
39484
  res = `
@@ -50873,7 +51325,7 @@ var require_subset = __commonJS({
50873
51325
  var require_semver2 = __commonJS({
50874
51326
  "../../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports$1, module) {
50875
51327
  var internalRe = require_re();
50876
- var constants4 = require_constants2();
51328
+ var constants5 = require_constants2();
50877
51329
  var SemVer = require_semver();
50878
51330
  var identifiers = require_identifiers();
50879
51331
  var parse5 = require_parse2();
@@ -50955,8 +51407,8 @@ var require_semver2 = __commonJS({
50955
51407
  re: internalRe.re,
50956
51408
  src: internalRe.src,
50957
51409
  tokens: internalRe.t,
50958
- SEMVER_SPEC_VERSION: constants4.SEMVER_SPEC_VERSION,
50959
- RELEASE_TYPES: constants4.RELEASE_TYPES,
51410
+ SEMVER_SPEC_VERSION: constants5.SEMVER_SPEC_VERSION,
51411
+ RELEASE_TYPES: constants5.RELEASE_TYPES,
50960
51412
  compareIdentifiers: identifiers.compareIdentifiers,
50961
51413
  rcompareIdentifiers: identifiers.rcompareIdentifiers
50962
51414
  };
@@ -56593,7 +57045,7 @@ var require_parse_url = __commonJS({
56593
57045
  // ../../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js
56594
57046
  var require_form_data = __commonJS({
56595
57047
  "../../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js"(exports$1, module) {
56596
- var { randomUUID: randomUUID11 } = __require("crypto");
57048
+ var { randomUUID: randomUUID12 } = __require("crypto");
56597
57049
  var { Readable: Readable2 } = __require("stream");
56598
57050
  var textEncoder;
56599
57051
  function isFormDataLike(payload) {
@@ -56601,23 +57053,23 @@ var require_form_data = __commonJS({
56601
57053
  }
56602
57054
  function formDataToStream(formdata) {
56603
57055
  textEncoder = textEncoder ?? new TextEncoder();
56604
- const boundary = `----formdata-${randomUUID11()}`;
57056
+ const boundary = `----formdata-${randomUUID12()}`;
56605
57057
  const prefix = `--${boundary}\r
56606
57058
  Content-Disposition: form-data`;
56607
- const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
57059
+ const escape3 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
56608
57060
  const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
56609
57061
  const linebreak = new Uint8Array([13, 10]);
56610
57062
  async function* asyncIterator() {
56611
57063
  for (const [name, value] of formdata) {
56612
57064
  if (typeof value === "string") {
56613
- yield textEncoder.encode(`${prefix}; name="${escape2(normalizeLinefeeds(name))}"\r
57065
+ yield textEncoder.encode(`${prefix}; name="${escape3(normalizeLinefeeds(name))}"\r
56614
57066
  \r
56615
57067
  `);
56616
57068
  yield textEncoder.encode(`${normalizeLinefeeds(value)}\r
56617
57069
  `);
56618
57070
  } else {
56619
- let header = `${prefix}; name="${escape2(normalizeLinefeeds(name))}"`;
56620
- value.name && (header += `; filename="${escape2(value.name)}"`);
57071
+ let header = `${prefix}; name="${escape3(normalizeLinefeeds(name))}"`;
57072
+ value.name && (header += `; filename="${escape3(value.name)}"`);
56621
57073
  header += `\r
56622
57074
  Content-Type: ${value.type || "application/octet-stream"}\r
56623
57075
  \r
@@ -70669,26 +71121,26 @@ var require_escape_html = __commonJS({
70669
71121
  if (!match2) {
70670
71122
  return str;
70671
71123
  }
70672
- var escape2;
71124
+ var escape3;
70673
71125
  var html = "";
70674
71126
  var index = 0;
70675
71127
  var lastIndex = 0;
70676
71128
  for (index = match2.index; index < str.length; index++) {
70677
71129
  switch (str.charCodeAt(index)) {
70678
71130
  case 34:
70679
- escape2 = "&quot;";
71131
+ escape3 = "&quot;";
70680
71132
  break;
70681
71133
  case 38:
70682
- escape2 = "&amp;";
71134
+ escape3 = "&amp;";
70683
71135
  break;
70684
71136
  case 39:
70685
- escape2 = "&#39;";
71137
+ escape3 = "&#39;";
70686
71138
  break;
70687
71139
  case 60:
70688
- escape2 = "&lt;";
71140
+ escape3 = "&lt;";
70689
71141
  break;
70690
71142
  case 62:
70691
- escape2 = "&gt;";
71143
+ escape3 = "&gt;";
70692
71144
  break;
70693
71145
  default:
70694
71146
  continue;
@@ -70697,7 +71149,7 @@ var require_escape_html = __commonJS({
70697
71149
  html += str.substring(lastIndex, index);
70698
71150
  }
70699
71151
  lastIndex = index + 1;
70700
- html += escape2;
71152
+ html += escape3;
70701
71153
  }
70702
71154
  return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
70703
71155
  }
@@ -71656,7 +72108,7 @@ var require_send = __commonJS({
71656
72108
  var { parseTokenList } = require_parseTokenList();
71657
72109
  var { createHttpError } = require_createHttpError();
71658
72110
  var extname3 = path15.extname;
71659
- var join11 = path15.join;
72111
+ var join12 = path15.join;
71660
72112
  var normalize4 = path15.normalize;
71661
72113
  var resolve9 = path15.resolve;
71662
72114
  var sep3 = path15.sep;
@@ -71743,7 +72195,7 @@ var require_send = __commonJS({
71743
72195
  return { statusCode: 403 };
71744
72196
  }
71745
72197
  parts = path16.split(sep3);
71746
- path16 = normalize4(join11(root, path16));
72198
+ path16 = normalize4(join12(root, path16));
71747
72199
  } else {
71748
72200
  if (UP_PATH_REGEXP.test(path16)) {
71749
72201
  debug('malicious path "%s"', path16);
@@ -72026,7 +72478,7 @@ var require_send = __commonJS({
72026
72478
  let err;
72027
72479
  for (let i = 0; i < options.index.length; i++) {
72028
72480
  const index = options.index[i];
72029
- const p = join11(path16, index);
72481
+ const p = join12(path16, index);
72030
72482
  const { error: error2, stat: stat2 } = await tryStat(p);
72031
72483
  if (error2) {
72032
72484
  err = error2;
@@ -79613,6 +80065,10 @@ var init_container = __esm3({
79613
80065
  get hasResourceBroker() {
79614
80066
  return this._resourceBroker !== void 0;
79615
80067
  }
80068
+ /** Platform-owned process executor. Never exposed through governed plugin adapters. */
80069
+ get processExecutor() {
80070
+ return this.getAdapter("processExecutor");
80071
+ }
79616
80072
  /**
79617
80073
  * Initialize core features.
79618
80074
  * Called internally by initPlatform().
@@ -84277,6 +84733,16 @@ async function initPlatform(config2 = {}, cwd = process.cwd(), uiProvider, platf
84277
84733
  error: error2 instanceof Error ? error2.message : String(error2)
84278
84734
  });
84279
84735
  }
84736
+ if (_assemblyBroker && !platform.processExecutor) {
84737
+ try {
84738
+ const { ensureHostProcessExecutor: ensureHostProcessExecutor2 } = await Promise.resolve().then(() => (init_dist9(), dist_exports2));
84739
+ ensureHostProcessExecutor2(platform);
84740
+ } catch (error2) {
84741
+ platform.logger.warn("Failed to initialize governed process executor", {
84742
+ error: error2 instanceof Error ? error2.message : String(error2)
84743
+ });
84744
+ }
84745
+ }
84280
84746
  if (assemblyHook && _assemblyBroker) {
84281
84747
  const llmOptions = adapterOptions.llm ?? {};
84282
84748
  const executionDefaults = llmOptions.executionDefaults;
@@ -85097,6 +85563,7 @@ init_llm_proxy();
85097
85563
  init_embeddings_proxy();
85098
85564
  init_vector_store_proxy();
85099
85565
  init_storage_proxy();
85566
+ init_remote_adapter();
85100
85567
  init_container();
85101
85568
  init_adapter_status();
85102
85569
 
@@ -97337,10 +97804,10 @@ var Server = class extends Protocol {
97337
97804
  }
97338
97805
  };
97339
97806
 
97340
- // ../../../node_modules/.pnpm/@hono+node-server@2.0.11_hono@4.12.32/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
97807
+ // ../../../node_modules/.pnpm/@hono+node-server@2.0.11_hono@4.13.0/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
97341
97808
  var X_ALREADY_SENT = "x-hono-already-sent";
97342
97809
 
97343
- // ../../../node_modules/.pnpm/@hono+node-server@2.0.11_hono@4.12.32/node_modules/@hono/node-server/dist/index.mjs
97810
+ // ../../../node_modules/.pnpm/@hono+node-server@2.0.11_hono@4.13.0/node_modules/@hono/node-server/dist/index.mjs
97344
97811
  var RequestError = class extends Error {
97345
97812
  constructor(message2, options) {
97346
97813
  super(message2, options);
@@ -101470,7 +101937,7 @@ var range = (a, b, str) => {
101470
101937
  return result;
101471
101938
  };
101472
101939
 
101473
- // ../../../node_modules/.pnpm/brace-expansion@5.0.8/node_modules/brace-expansion/dist/esm/index.js
101940
+ // ../../../node_modules/.pnpm/brace-expansion@5.0.9/node_modules/brace-expansion/dist/esm/index.js
101474
101941
  var escSlash = "\0SLASH" + Math.random() + "\0";
101475
101942
  var escOpen = "\0OPEN" + Math.random() + "\0";
101476
101943
  var escClose = "\0CLOSE" + Math.random() + "\0";
@@ -101557,7 +102024,7 @@ function combine(acc, pre, values, max, maxLength, dropEmpties) {
101557
102024
  }
101558
102025
  return out;
101559
102026
  }
101560
- function expandSequence(body, isAlphaSequence, max) {
102027
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
101561
102028
  const n = body.split(/\.\./);
101562
102029
  const N = [];
101563
102030
  if (n[0] === void 0 || n[1] === void 0) {
@@ -101574,6 +102041,7 @@ function expandSequence(body, isAlphaSequence, max) {
101574
102041
  test = gte;
101575
102042
  }
101576
102043
  const pad = n.some(isPadded);
102044
+ let length = 0;
101577
102045
  for (let i = x; test(i, y) && N.length < max; i += incr) {
101578
102046
  let c;
101579
102047
  if (isAlphaSequence) {
@@ -101595,7 +102063,10 @@ function expandSequence(body, isAlphaSequence, max) {
101595
102063
  }
101596
102064
  }
101597
102065
  }
102066
+ if (length + c.length > maxLength)
102067
+ break;
101598
102068
  N.push(c);
102069
+ length += c.length;
101599
102070
  }
101600
102071
  return N;
101601
102072
  }
@@ -101635,7 +102106,7 @@ function expand_(str, max, maxLength, isTop) {
101635
102106
  }
101636
102107
  let values;
101637
102108
  if (isSequence) {
101638
- values = expandSequence(m.body, isAlphaSequence, max);
102109
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
101639
102110
  } else {
101640
102111
  let n = parseCommaParts(m.body);
101641
102112
  if (n.length === 1 && n[0] !== void 0) {
@@ -101648,9 +102119,26 @@ function expand_(str, max, maxLength, isTop) {
101648
102119
  continue;
101649
102120
  }
101650
102121
  }
102122
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
102123
+ for (let d = 0; dropsEmpties && d < acc.length; d++) {
102124
+ if (acc[d]) {
102125
+ dropsEmpties = false;
102126
+ }
102127
+ }
101651
102128
  values = [];
101652
- for (let j2 = 0; j2 < n.length; j2++) {
101653
- values.push.apply(values, expand_(n[j2], max, maxLength, false));
102129
+ let valuesLength = 0;
102130
+ outer: for (let j2 = 0; j2 < n.length; j2++) {
102131
+ const expanded = expand_(n[j2], max, maxLength, false);
102132
+ for (let k = 0; k < expanded.length; k++) {
102133
+ const v = expanded[k];
102134
+ if (dropsEmpties && !v)
102135
+ continue;
102136
+ if (values.length >= max || valuesLength + v.length > maxLength) {
102137
+ break outer;
102138
+ }
102139
+ values.push(v);
102140
+ valuesLength += v.length;
102141
+ }
101654
102142
  }
101655
102143
  }
101656
102144
  acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
@@ -102434,7 +102922,7 @@ var AST = class {
102434
102922
  _a2 = AST;
102435
102923
 
102436
102924
  // ../../../node_modules/.pnpm/minimatch@10.2.5/node_modules/minimatch/dist/esm/escape.js
102437
- var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
102925
+ var escape2 = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
102438
102926
  if (magicalBraces) {
102439
102927
  return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
102440
102928
  }
@@ -103247,7 +103735,7 @@ var Minimatch = class {
103247
103735
  };
103248
103736
  minimatch.AST = AST;
103249
103737
  minimatch.Minimatch = Minimatch;
103250
- minimatch.escape = escape;
103738
+ minimatch.escape = escape2;
103251
103739
  minimatch.unescape = unescape2;
103252
103740
  var S = diagnostics_channel.channel("lru-cache:metrics");
103253
103741
  var W = diagnostics_channel.tracingChannel("lru-cache");
@@ -107486,7 +107974,7 @@ var glob = Object.assign(glob_, {
107486
107974
  iterateSync,
107487
107975
  Glob,
107488
107976
  hasMagic,
107489
- escape,
107977
+ escape: escape2,
107490
107978
  unescape: unescape2
107491
107979
  });
107492
107980
  glob.glob = glob;
@@ -109329,7 +109817,7 @@ var init_discover = __esm5({
109329
109817
  init_path();
109330
109818
  init_schema();
109331
109819
  DISCOVERY_VERSION = 2;
109332
- DEBUG_MODE = process.env.DEBUG_SANDBOX === "1" || process.env.NODE_ENV === "development";
109820
+ DEBUG_MODE = process.env.DEBUG_SANDBOX === "1" || process.env.KB_DISCOVERY_DEBUG === "1";
109333
109821
  log = (level, message2, fields) => {
109334
109822
  if (!DEBUG_MODE) {
109335
109823
  return;
@@ -109539,16 +110027,16 @@ var TrieRouter = class {
109539
110027
  const tok = tokens[i];
109540
110028
  const child = node.children.get(tok);
109541
110029
  if (!child) {
110030
+ if (node.command && i > 0) {
110031
+ return { type: "command", command: node.command, rest: tokens.slice(i) };
110032
+ }
110033
+ if (node.systemCommand && i > 0) {
110034
+ return { type: "system-cmd", cmd: node.systemCommand, rest: tokens.slice(i) };
110035
+ }
109542
110036
  return this._notFound(node, tokens, i);
109543
110037
  }
109544
110038
  node = child;
109545
110039
  i++;
109546
- if (node.command && i < tokens.length) {
109547
- return { type: "command", command: node.command, rest: tokens.slice(i) };
109548
- }
109549
- if (node.systemCommand && i < tokens.length) {
109550
- return { type: "system-cmd", cmd: node.systemCommand, rest: tokens.slice(i) };
109551
- }
109552
110040
  }
109553
110041
  if (node.command) {
109554
110042
  return { type: "command", command: node.command, rest: [] };