executor 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/executor.mjs CHANGED
@@ -305367,8 +305367,8 @@ var require_client_interceptors = __commonJS((exports) => {
305367
305367
  this.start = start4;
305368
305368
  return this;
305369
305369
  }
305370
- withSendMessage(sendMessage) {
305371
- this.message = sendMessage;
305370
+ withSendMessage(sendMessage2) {
305371
+ this.message = sendMessage2;
305372
305372
  return this;
305373
305373
  }
305374
305374
  withHalfClose(halfClose) {
@@ -320673,8 +320673,8 @@ var require_server_interceptors = __commonJS((exports) => {
320673
320673
  this.metadata = sendMetadata;
320674
320674
  return this;
320675
320675
  }
320676
- withSendMessage(sendMessage) {
320677
- this.message = sendMessage;
320676
+ withSendMessage(sendMessage2) {
320677
+ this.message = sendMessage2;
320678
320678
  return this;
320679
320679
  }
320680
320680
  withSendStatus(sendStatus) {
@@ -334088,12 +334088,12 @@ var require_src18 = __commonJS((exports) => {
334088
334088
  });
334089
334089
 
334090
334090
  // apps/executor/src/cli/main.ts
334091
- import { existsSync as existsSync8, readFileSync as readFileSync3 } from "node:fs";
334091
+ import { existsSync as existsSync9, readFileSync as readFileSync3 } from "node:fs";
334092
334092
  import { mkdir as mkdir5, open as open3, readFile as readFile6, rm as rm5 } from "node:fs/promises";
334093
- import { spawn as spawn2 } from "node:child_process";
334093
+ import { spawn as spawn3 } from "node:child_process";
334094
334094
  import { dirname as dirname10, resolve as resolve11 } from "node:path";
334095
334095
  import { createInterface } from "node:readline/promises";
334096
- import { fileURLToPath as fileURLToPath8 } from "node:url";
334096
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
334097
334097
 
334098
334098
  // node_modules/@effect/cli/dist/esm/Args.js
334099
334099
  var exports_Args = {};
@@ -375146,6 +375146,7 @@ var LocalInstallationSchema = Struct({
375146
375146
  });
375147
375147
  var LocalInstallationUpdateSchema = partial2(LocalInstallationSchema);
375148
375148
  // packages/control-plane/src/schema/models/local-config.ts
375149
+ var LocalExecutorRuntimeSchema = exports_Schema.Literal("quickjs", "ses", "deno");
375149
375150
  var LocalConfigSecretProviderSourceSchema = exports_Schema.Literal("env", "file", "exec", "params");
375150
375151
  var LocalConfigEnvSecretProviderSchema = exports_Schema.Struct({
375151
375152
  source: exports_Schema.Literal("env")
@@ -375241,6 +375242,7 @@ var LocalConfigWorkspaceSchema = exports_Schema.Struct({
375241
375242
  name: exports_Schema.optional(exports_Schema.String)
375242
375243
  });
375243
375244
  var LocalExecutorConfigSchema = exports_Schema.Struct({
375245
+ runtime: exports_Schema.optional(LocalExecutorRuntimeSchema),
375244
375246
  workspace: exports_Schema.optional(LocalConfigWorkspaceSchema),
375245
375247
  sources: exports_Schema.optional(exports_Schema.Record({
375246
375248
  key: exports_Schema.String,
@@ -382319,13 +382321,47 @@ var googleDiscoveryCatalogOperationFromDefinition = (input) => {
382319
382321
  providerData: presentation.providerData
382320
382322
  };
382321
382323
  };
382324
+ var computeMaximalScopes = (manifest) => {
382325
+ const topLevelScopes = Object.keys(manifest.oauthScopes ?? {});
382326
+ if (topLevelScopes.length === 0)
382327
+ return [];
382328
+ const scopeToMethods = new Map;
382329
+ for (const scope4 of topLevelScopes) {
382330
+ scopeToMethods.set(scope4, new Set);
382331
+ }
382332
+ for (const method of manifest.methods) {
382333
+ for (const scope4 of method.scopes) {
382334
+ scopeToMethods.get(scope4)?.add(method.methodId);
382335
+ }
382336
+ }
382337
+ const maximal = topLevelScopes.filter((scope4) => {
382338
+ const methods = scopeToMethods.get(scope4);
382339
+ if (!methods || methods.size === 0)
382340
+ return true;
382341
+ return !topLevelScopes.some((other) => {
382342
+ if (other === scope4)
382343
+ return false;
382344
+ const otherMethods = scopeToMethods.get(other);
382345
+ if (!otherMethods || otherMethods.size <= methods.size)
382346
+ return false;
382347
+ for (const m of methods) {
382348
+ if (!otherMethods.has(m))
382349
+ return false;
382350
+ }
382351
+ return true;
382352
+ });
382353
+ });
382354
+ return maximal;
382355
+ };
382322
382356
  var googleDiscoveryOauth2SetupConfig = (source2) => gen2(function* () {
382323
382357
  const bindingConfig = yield* googleDiscoveryBindingConfigFromSource(source2);
382324
382358
  const configuredScopes = bindingConfig.scopes ?? [];
382325
- const scopes = configuredScopes.length > 0 ? configuredScopes : yield* fetchGoogleDiscoveryDocumentWithHeaders({
382359
+ const manifest = yield* fetchGoogleDiscoveryDocumentWithHeaders({
382326
382360
  url: bindingConfig.discoveryUrl,
382327
382361
  headers: bindingConfig.defaultHeaders ?? undefined
382328
- }).pipe(flatMap10((document2) => extractGoogleDiscoveryManifest(source2.name, document2)), map16((manifest) => Object.keys(manifest.oauthScopes ?? {})));
382362
+ }).pipe(flatMap10((document2) => extractGoogleDiscoveryManifest(source2.name, document2)), catchAll2(() => succeed8(null)));
382363
+ const discoveryScopes = manifest ? computeMaximalScopes(manifest) : [];
382364
+ const scopes = discoveryScopes.length > 0 ? [...new Set([...discoveryScopes, ...configuredScopes])] : configuredScopes;
382329
382365
  if (scopes.length === 0) {
382330
382366
  return null;
382331
382367
  }
@@ -408418,6 +408454,280 @@ var asOperationErrors = (errors4) => typeof errors4 === "string" ? operationErro
408418
408454
  class ControlPlaneStore extends Tag2("#runtime/ControlPlaneStore")() {
408419
408455
  }
408420
408456
 
408457
+ // packages/runtime-deno-subprocess/src/index.ts
408458
+ import { existsSync } from "node:fs";
408459
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
408460
+
408461
+ // packages/runtime-deno-subprocess/src/deno-worker-process.ts
408462
+ import { spawn } from "node:child_process";
408463
+ var normalizeError = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
408464
+ var buildPermissionArgs = (permissions) => {
408465
+ if (!permissions) {
408466
+ return [
408467
+ "--deny-net",
408468
+ "--deny-read",
408469
+ "--deny-write",
408470
+ "--deny-env",
408471
+ "--deny-run",
408472
+ "--deny-ffi"
408473
+ ];
408474
+ }
408475
+ const args3 = [];
408476
+ const addPermission = (flag, value7) => {
408477
+ if (value7 === true) {
408478
+ args3.push(`--allow-${flag}`);
408479
+ } else if (Array.isArray(value7) && value7.length > 0) {
408480
+ args3.push(`--allow-${flag}=${value7.join(",")}`);
408481
+ } else {
408482
+ args3.push(`--deny-${flag}`);
408483
+ }
408484
+ };
408485
+ addPermission("net", permissions.allowNet);
408486
+ addPermission("read", permissions.allowRead);
408487
+ addPermission("write", permissions.allowWrite);
408488
+ addPermission("env", permissions.allowEnv);
408489
+ addPermission("run", permissions.allowRun);
408490
+ addPermission("ffi", permissions.allowFfi);
408491
+ return args3;
408492
+ };
408493
+ var spawnDenoWorkerProcess = (input, callbacks) => {
408494
+ const permissionArgs = buildPermissionArgs(input.permissions);
408495
+ const child = spawn(input.executable, [
408496
+ "run",
408497
+ "--quiet",
408498
+ "--no-prompt",
408499
+ "--no-check",
408500
+ ...permissionArgs,
408501
+ input.scriptPath
408502
+ ], {
408503
+ stdio: ["pipe", "pipe", "pipe"]
408504
+ });
408505
+ if (!child.stdin || !child.stdout || !child.stderr) {
408506
+ throw new Error("Failed to create piped stdio for Deno worker subprocess");
408507
+ }
408508
+ child.stdout.setEncoding("utf8");
408509
+ child.stderr.setEncoding("utf8");
408510
+ let stdoutBuffer = "";
408511
+ const onStdoutData = (chunk4) => {
408512
+ stdoutBuffer += chunk4;
408513
+ while (true) {
408514
+ const newlineIndex = stdoutBuffer.indexOf(`
408515
+ `);
408516
+ if (newlineIndex === -1) {
408517
+ break;
408518
+ }
408519
+ const line4 = stdoutBuffer.slice(0, newlineIndex);
408520
+ stdoutBuffer = stdoutBuffer.slice(newlineIndex + 1);
408521
+ callbacks.onStdoutLine(line4);
408522
+ }
408523
+ };
408524
+ const onStderrData = (chunk4) => {
408525
+ callbacks.onStderr(chunk4);
408526
+ };
408527
+ const onError4 = (cause2) => {
408528
+ callbacks.onError(normalizeError(cause2));
408529
+ };
408530
+ const onExit4 = (code2, signal) => {
408531
+ callbacks.onExit(code2, signal);
408532
+ };
408533
+ child.stdout.on("data", onStdoutData);
408534
+ child.stderr.on("data", onStderrData);
408535
+ child.on("error", onError4);
408536
+ child.on("exit", onExit4);
408537
+ let disposed = false;
408538
+ const dispose = () => {
408539
+ if (disposed) {
408540
+ return;
408541
+ }
408542
+ disposed = true;
408543
+ child.stdout.removeListener("data", onStdoutData);
408544
+ child.stderr.removeListener("data", onStderrData);
408545
+ child.removeListener("error", onError4);
408546
+ child.removeListener("exit", onExit4);
408547
+ if (!child.killed) {
408548
+ child.kill("SIGKILL");
408549
+ }
408550
+ };
408551
+ return {
408552
+ stdin: child.stdin,
408553
+ dispose
408554
+ };
408555
+ };
408556
+
408557
+ // packages/runtime-deno-subprocess/src/index.ts
408558
+ var IPC_PREFIX = "@@executor-ipc@@";
408559
+ var DEFAULT_TIMEOUT_MS = 5 * 60000;
408560
+ var defaultDenoExecutable = () => {
408561
+ const configured = process.env.DENO_BIN?.trim();
408562
+ if (configured) {
408563
+ return configured;
408564
+ }
408565
+ const home = process.env.HOME?.trim();
408566
+ if (home) {
408567
+ const installedPath = `${home}/.deno/bin/deno`;
408568
+ if (existsSync(installedPath)) {
408569
+ return installedPath;
408570
+ }
408571
+ }
408572
+ return "deno";
408573
+ };
408574
+ var formatDenoSpawnError = (cause2, executable) => {
408575
+ const code2 = typeof cause2 === "object" && cause2 !== null && "code" in cause2 ? String(cause2.code) : null;
408576
+ if (code2 === "ENOENT") {
408577
+ return `Failed to spawn Deno subprocess: Deno executable "${executable}" was not found. Install Deno or set DENO_BIN.`;
408578
+ }
408579
+ return `Failed to spawn Deno subprocess: ${cause2 instanceof Error ? cause2.message : String(cause2)}`;
408580
+ };
408581
+ var resolveWorkerScriptPath = () => {
408582
+ const moduleUrl = String(import.meta.url);
408583
+ if (moduleUrl.startsWith("/")) {
408584
+ return moduleUrl;
408585
+ }
408586
+ try {
408587
+ const workerUrl = new URL("./deno-subprocess-worker.mjs", moduleUrl);
408588
+ if (workerUrl.protocol === "file:") {
408589
+ return fileURLToPath2(workerUrl);
408590
+ }
408591
+ return workerUrl.pathname.length > 0 ? workerUrl.pathname : workerUrl.toString();
408592
+ } catch {
408593
+ return moduleUrl;
408594
+ }
408595
+ };
408596
+ var cachedWorkerScriptPath;
408597
+ var workerScriptPath = () => {
408598
+ if (!cachedWorkerScriptPath) {
408599
+ cachedWorkerScriptPath = resolveWorkerScriptPath();
408600
+ }
408601
+ return cachedWorkerScriptPath;
408602
+ };
408603
+ var writeMessage = (stdin, message) => {
408604
+ stdin.write(`${JSON.stringify(message)}
408605
+ `);
408606
+ };
408607
+ var isWorkerMessage = (value7) => typeof value7 === "object" && value7 !== null && ("type" in value7) && typeof value7.type === "string";
408608
+ var executeInDeno = (code2, toolInvoker, options9) => gen2(function* () {
408609
+ const denoExecutable = options9.denoExecutable ?? defaultDenoExecutable();
408610
+ const timeoutMs = Math.max(100, options9.timeoutMs ?? DEFAULT_TIMEOUT_MS);
408611
+ const result = yield* async((resume2) => {
408612
+ let settled = false;
408613
+ let stderrBuffer = "";
408614
+ let worker = null;
408615
+ const finish = (executeResult) => {
408616
+ if (settled) {
408617
+ return;
408618
+ }
408619
+ settled = true;
408620
+ clearTimeout(timeout3);
408621
+ worker?.dispose();
408622
+ resume2(succeed8(executeResult));
408623
+ };
408624
+ const fail19 = (error51, logs) => {
408625
+ finish({
408626
+ result: null,
408627
+ error: error51,
408628
+ logs
408629
+ });
408630
+ };
408631
+ const timeout3 = setTimeout(() => {
408632
+ fail19(`Deno subprocess execution timed out after ${timeoutMs}ms`);
408633
+ }, timeoutMs);
408634
+ const handleStdoutLine = (rawLine) => {
408635
+ const line4 = rawLine.trim();
408636
+ if (line4.length === 0 || !line4.startsWith(IPC_PREFIX)) {
408637
+ return;
408638
+ }
408639
+ const payload = line4.slice(IPC_PREFIX.length);
408640
+ let message;
408641
+ try {
408642
+ const parsed = JSON.parse(payload);
408643
+ if (!isWorkerMessage(parsed)) {
408644
+ fail19(`Invalid worker message: ${payload}`);
408645
+ return;
408646
+ }
408647
+ message = parsed;
408648
+ } catch (cause2) {
408649
+ fail19(`Failed to decode worker message: ${payload}
408650
+ ${String(cause2)}`);
408651
+ return;
408652
+ }
408653
+ if (message.type === "tool_call") {
408654
+ if (!worker) {
408655
+ fail19("Deno subprocess unavailable while handling worker tool_call");
408656
+ return;
408657
+ }
408658
+ const currentWorker = worker;
408659
+ runPromise(match12(tryPromise2({
408660
+ try: () => runPromise(toolInvoker.invoke({
408661
+ path: message.toolPath,
408662
+ args: message.args
408663
+ })),
408664
+ catch: (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2))
408665
+ }), {
408666
+ onSuccess: (value7) => {
408667
+ writeMessage(currentWorker.stdin, {
408668
+ type: "tool_result",
408669
+ requestId: message.requestId,
408670
+ ok: true,
408671
+ value: value7
408672
+ });
408673
+ },
408674
+ onFailure: (error51) => {
408675
+ writeMessage(currentWorker.stdin, {
408676
+ type: "tool_result",
408677
+ requestId: message.requestId,
408678
+ ok: false,
408679
+ error: error51.message
408680
+ });
408681
+ }
408682
+ })).catch((cause2) => {
408683
+ fail19(`Failed handling worker tool_call: ${String(cause2)}`);
408684
+ });
408685
+ return;
408686
+ }
408687
+ if (message.type === "completed") {
408688
+ finish({
408689
+ result: message.result,
408690
+ logs: message.logs
408691
+ });
408692
+ return;
408693
+ }
408694
+ fail19(message.error, message.logs);
408695
+ };
408696
+ try {
408697
+ worker = spawnDenoWorkerProcess({
408698
+ executable: denoExecutable,
408699
+ scriptPath: workerScriptPath(),
408700
+ permissions: options9.permissions
408701
+ }, {
408702
+ onStdoutLine: handleStdoutLine,
408703
+ onStderr: (chunk4) => {
408704
+ stderrBuffer += chunk4;
408705
+ },
408706
+ onError: (cause2) => {
408707
+ fail19(formatDenoSpawnError(cause2, denoExecutable));
408708
+ },
408709
+ onExit: (exitCode, signal) => {
408710
+ if (settled) {
408711
+ return;
408712
+ }
408713
+ fail19(`Deno subprocess exited before returning terminal message (code=${String(exitCode)} signal=${String(signal)} stderr=${stderrBuffer})`);
408714
+ }
408715
+ });
408716
+ } catch (cause2) {
408717
+ fail19(formatDenoSpawnError(cause2, denoExecutable));
408718
+ return;
408719
+ }
408720
+ writeMessage(worker.stdin, {
408721
+ type: "start",
408722
+ code: code2
408723
+ });
408724
+ });
408725
+ return result;
408726
+ });
408727
+ var makeDenoSubprocessExecutor = (options9 = {}) => ({
408728
+ execute: (code2, toolInvoker) => executeInDeno(code2, toolInvoker, options9)
408729
+ });
408730
+
408421
408731
  // node_modules/quickjs-emscripten-core/dist/index.mjs
408422
408732
  init_dist();
408423
408733
  async function newQuickJSWASMModuleFromVariant(variantOrPromise) {
@@ -408453,7 +408763,7 @@ async function getQuickJS() {
408453
408763
  }
408454
408764
 
408455
408765
  // packages/runtime-quickjs/src/index.ts
408456
- var DEFAULT_TIMEOUT_MS = 5 * 60000;
408766
+ var DEFAULT_TIMEOUT_MS2 = 5 * 60000;
408457
408767
  var EXECUTION_FILENAME = "executor-quickjs-runtime.js";
408458
408768
  var toError2 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
408459
408769
  var toErrorMessage = (cause2) => {
@@ -408628,7 +408938,7 @@ var drainAsync = async (context7, runtime5, pendingDeferreds, deadlineMs, timeou
408628
408938
  drainJobs(context7, runtime5, deadlineMs, timeoutMs);
408629
408939
  };
408630
408940
  var evaluateInQuickJs = async (options9, code2, toolInvoker) => {
408631
- const timeoutMs = Math.max(100, options9.timeoutMs ?? DEFAULT_TIMEOUT_MS);
408941
+ const timeoutMs = Math.max(100, options9.timeoutMs ?? DEFAULT_TIMEOUT_MS2);
408632
408942
  const deadlineMs = Date.now() + timeoutMs;
408633
408943
  const logs = [];
408634
408944
  const pendingDeferreds = new Set;
@@ -408724,6 +409034,151 @@ var makeQuickJsExecutor = (options9 = {}) => ({
408724
409034
  execute: (code2, toolInvoker) => runInQuickJs(options9, code2, toolInvoker)
408725
409035
  });
408726
409036
 
409037
+ // packages/runtime-ses/src/index.ts
409038
+ import { fork as fork3 } from "node:child_process";
409039
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
409040
+ var DEFAULT_TIMEOUT_MS3 = 5 * 60000;
409041
+ var DEFAULT_EVALUATION_ID = "evaluation";
409042
+ var WORKER_PATH = fileURLToPath3(new URL("./sandbox-worker.mjs", import.meta.url));
409043
+ var toError3 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
409044
+ var createSandboxWorker = () => fork3(WORKER_PATH, [], { silent: true });
409045
+ var describeWorkerExit = (code2, signal, stderr) => {
409046
+ const stderrSuffix = stderr.trim().length > 0 ? `
409047
+ ${stderr.trim()}` : "";
409048
+ if (signal) {
409049
+ return new Error(`SES worker exited from signal ${signal}${stderrSuffix}`);
409050
+ }
409051
+ if (typeof code2 === "number") {
409052
+ return new Error(`SES worker exited with code ${code2}${stderrSuffix}`);
409053
+ }
409054
+ return new Error(`SES worker exited before returning a result${stderrSuffix}`);
409055
+ };
409056
+ var sendMessage = (child, message) => {
409057
+ if (typeof child.send !== "function") {
409058
+ throw new Error("SES worker IPC channel is unavailable");
409059
+ }
409060
+ child.send(message);
409061
+ };
409062
+ var evaluateInSandbox = async (options9, code2, toolInvoker) => {
409063
+ const child = createSandboxWorker();
409064
+ const timeoutMs = options9.timeoutMs ?? DEFAULT_TIMEOUT_MS3;
409065
+ const stderrChunks = [];
409066
+ if (child.stderr) {
409067
+ child.stderr.on("data", (chunk4) => {
409068
+ stderrChunks.push(chunk4.toString());
409069
+ });
409070
+ }
409071
+ return new Promise((resolve3, reject) => {
409072
+ let settled = false;
409073
+ let timeoutHandle;
409074
+ const cleanup = () => {
409075
+ if (timeoutHandle) {
409076
+ clearTimeout(timeoutHandle);
409077
+ timeoutHandle = undefined;
409078
+ }
409079
+ child.off("error", onError4);
409080
+ child.off("exit", onExit4);
409081
+ child.off("message", onMessage);
409082
+ if (!child.killed) {
409083
+ child.kill();
409084
+ }
409085
+ };
409086
+ const settle = (effect3) => {
409087
+ if (settled) {
409088
+ return;
409089
+ }
409090
+ settled = true;
409091
+ cleanup();
409092
+ effect3();
409093
+ };
409094
+ const resetTimeout = () => {
409095
+ if (timeoutHandle) {
409096
+ clearTimeout(timeoutHandle);
409097
+ }
409098
+ timeoutHandle = setTimeout(() => {
409099
+ settle(() => {
409100
+ reject(new Error(`Execution timed out after ${timeoutMs}ms`));
409101
+ });
409102
+ }, timeoutMs);
409103
+ };
409104
+ const onError4 = (error51) => {
409105
+ settle(() => {
409106
+ reject(error51);
409107
+ });
409108
+ };
409109
+ const onExit4 = (code3, signal) => {
409110
+ settle(() => {
409111
+ reject(describeWorkerExit(code3, signal, stderrChunks.join("")));
409112
+ });
409113
+ };
409114
+ const onMessage = (message) => {
409115
+ if (message.type === "ready") {
409116
+ resetTimeout();
409117
+ sendMessage(child, {
409118
+ type: "evaluate",
409119
+ id: DEFAULT_EVALUATION_ID,
409120
+ code: code2,
409121
+ allowFetch: options9.allowFetch === true
409122
+ });
409123
+ return;
409124
+ }
409125
+ if (message.type === "tool-call") {
409126
+ resetTimeout();
409127
+ runPromise(toolInvoker.invoke({ path: message.path, args: message.args })).then((value7) => {
409128
+ if (settled) {
409129
+ return;
409130
+ }
409131
+ resetTimeout();
409132
+ sendMessage(child, {
409133
+ type: "tool-response",
409134
+ callId: message.callId,
409135
+ value: value7
409136
+ });
409137
+ }).catch((cause2) => {
409138
+ if (settled) {
409139
+ return;
409140
+ }
409141
+ resetTimeout();
409142
+ const error51 = toError3(cause2);
409143
+ sendMessage(child, {
409144
+ type: "tool-response",
409145
+ callId: message.callId,
409146
+ error: error51.stack ?? error51.message
409147
+ });
409148
+ });
409149
+ return;
409150
+ }
409151
+ if (message.type === "result") {
409152
+ settle(() => {
409153
+ if (message.error) {
409154
+ resolve3({
409155
+ result: null,
409156
+ error: message.error,
409157
+ logs: message.logs ?? []
409158
+ });
409159
+ return;
409160
+ }
409161
+ resolve3({
409162
+ result: message.value,
409163
+ logs: message.logs ?? []
409164
+ });
409165
+ });
409166
+ }
409167
+ };
409168
+ child.on("error", onError4);
409169
+ child.on("exit", onExit4);
409170
+ child.on("message", onMessage);
409171
+ resetTimeout();
409172
+ });
409173
+ };
409174
+ var runInSes = (options9, code2, toolInvoker) => tryPromise2({
409175
+ try: () => evaluateInSandbox(options9, code2, toolInvoker),
409176
+ catch: toError3
409177
+ });
409178
+ var makeSesExecutor = (options9 = {}) => ({
409179
+ execute: (code2, toolInvoker) => runInSes(options9, code2, toolInvoker)
409180
+ });
409181
+
408727
409182
  // packages/control-plane/src/runtime/local-config.ts
408728
409183
  import { homedir } from "node:os";
408729
409184
  import { basename, dirname as dirname2, isAbsolute, join as join5, resolve as resolve3 } from "node:path";
@@ -409721,6 +410176,7 @@ var mergeLocalExecutorConfigs = (base, extra) => {
409721
410176
  return null;
409722
410177
  }
409723
410178
  return decodeLocalExecutorConfig({
410179
+ runtime: extra?.runtime ?? base?.runtime,
409724
410180
  workspace: {
409725
410181
  ...base?.workspace ?? {},
409726
410182
  ...extra?.workspace ?? {}
@@ -411090,7 +411546,7 @@ var createExecutorToolMap = (input) => ({
411090
411546
  });
411091
411547
 
411092
411548
  // packages/control-plane/src/runtime/mcp-oauth.ts
411093
- var toError3 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
411549
+ var toError4 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
411094
411550
  var toJsonObject = (value7) => value7 !== null && value7 !== undefined && typeof value7 === "object" && !Array.isArray(value7) ? value7 : null;
411095
411551
  var createClientMetadata = (redirectUrl) => ({
411096
411552
  redirect_uris: [redirectUrl],
@@ -411140,7 +411596,7 @@ var startMcpOAuthAuthorization = (input) => gen2(function* () {
411140
411596
  try: () => auth2(provider, {
411141
411597
  serverUrl: input.endpoint
411142
411598
  }),
411143
- catch: toError3
411599
+ catch: toError4
411144
411600
  });
411145
411601
  if (result !== "REDIRECT" || !captured.authorizationUrl || !captured.codeVerifier) {
411146
411602
  return yield* fail8(new Error("OAuth flow did not produce an authorization redirect"));
@@ -411199,7 +411655,7 @@ var exchangeMcpOAuthAuthorizationCode = (input) => gen2(function* () {
411199
411655
  serverUrl: input.session.endpoint,
411200
411656
  authorizationCode: input.code
411201
411657
  }),
411202
- catch: toError3
411658
+ catch: toError4
411203
411659
  });
411204
411660
  if (result !== "AUTHORIZED" || !captured.tokens) {
411205
411661
  return yield* fail8(new Error("OAuth redirect did not complete MCP OAuth setup"));
@@ -411216,7 +411672,7 @@ var exchangeMcpOAuthAuthorizationCode = (input) => gen2(function* () {
411216
411672
 
411217
411673
  // packages/control-plane/src/runtime/secret-material-providers.ts
411218
411674
  import { randomUUID } from "node:crypto";
411219
- import { spawn } from "node:child_process";
411675
+ import { spawn as spawn2 } from "node:child_process";
411220
411676
  import { promises as fs2 } from "node:fs";
411221
411677
  import { lstatSync, realpathSync } from "node:fs";
411222
411678
  import { isAbsolute as isAbsolute2 } from "node:path";
@@ -411294,7 +411750,7 @@ var keychainCommandForPlatform = (platform = process.platform) => {
411294
411750
  };
411295
411751
  var runCommand = (input) => tryPromise2({
411296
411752
  try: () => new Promise((resolve4, reject) => {
411297
- const child = spawn(input.command, [...input.args], {
411753
+ const child = spawn2(input.command, [...input.args], {
411298
411754
  stdio: "pipe",
411299
411755
  env: input.env
411300
411756
  });
@@ -411361,7 +411817,7 @@ var commandExists = (command) => tryPromise2({
411361
411817
  return cached5;
411362
411818
  }
411363
411819
  const probe = new Promise((resolve4) => {
411364
- const child = spawn(command, ["--help"], {
411820
+ const child = spawn2(command, ["--help"], {
411365
411821
  stdio: "ignore"
411366
411822
  });
411367
411823
  const timeout3 = setTimeout(() => {
@@ -412227,6 +412683,9 @@ var refreshOAuth2AccessToken = (input) => gen2(function* () {
412227
412683
  if (input.clientAuthentication === "client_secret_post" && input.clientSecret) {
412228
412684
  body2.set("client_secret", input.clientSecret);
412229
412685
  }
412686
+ if (input.scopes && input.scopes.length > 0) {
412687
+ body2.set("scope", input.scopes.join(" "));
412688
+ }
412230
412689
  return yield* postFormToOAuth2TokenEndpoint({
412231
412690
  tokenEndpoint: input.tokenEndpoint,
412232
412691
  body: body2
@@ -412362,7 +412821,8 @@ var refreshProviderGrantRefArtifact = (input) => gen2(function* () {
412362
412821
  clientId: oauthClient.clientId,
412363
412822
  clientAuthentication: grant.clientAuthentication,
412364
412823
  clientSecret,
412365
- refreshToken
412824
+ refreshToken,
412825
+ scopes: config3.requiredScopes.length > 0 ? config3.requiredScopes : null
412366
412826
  });
412367
412827
  const storeSecretMaterial = createDefaultSecretMaterialStorer({
412368
412828
  rows: input.rows
@@ -417885,9 +418345,9 @@ var removePolicy = (input) => gen2(function* () {
417885
418345
 
417886
418346
  // packages/control-plane/src/runtime/local-tools.ts
417887
418347
  import { createHash as createHash5 } from "node:crypto";
417888
- import { existsSync } from "node:fs";
418348
+ import { existsSync as existsSync2 } from "node:fs";
417889
418349
  import { dirname as dirname3, extname, join as join9, relative, resolve as resolve4, sep } from "node:path";
417890
- import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
418350
+ import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL2 } from "node:url";
417891
418351
  var ts = __toESM(require_typescript(), 1);
417892
418352
  var SUPPORTED_LOCAL_TOOL_EXTENSIONS = new Set([".ts", ".js", ".mjs"]);
417893
418353
  var LOCAL_TOOLS_DIRECTORY = "tools";
@@ -418032,10 +418492,10 @@ var transpileSourceFile = (input) => gen2(function* () {
418032
418492
  return rewriteRelativeImportSpecifiers(transpiled.outputText);
418033
418493
  });
418034
418494
  var resolveExecutorNodeModulesDirectory = () => {
418035
- let current = dirname3(fileURLToPath2(import.meta.url));
418495
+ let current = dirname3(fileURLToPath4(import.meta.url));
418036
418496
  while (true) {
418037
418497
  const candidate = join9(current, "node_modules");
418038
- if (existsSync(candidate)) {
418498
+ if (existsSync2(candidate)) {
418039
418499
  return candidate;
418040
418500
  }
418041
418501
  const parent = dirname3(current);
@@ -418209,6 +418669,19 @@ var LocalToolRuntimeLoaderLive = effect(LocalToolRuntimeLoaderService, gen2(func
418209
418669
 
418210
418670
  // packages/control-plane/src/runtime/workspace-execution-environment.ts
418211
418671
  var asToolPath4 = (value7) => value7;
418672
+ var DEFAULT_EXECUTION_RUNTIME = "quickjs";
418673
+ var resolveConfiguredExecutionRuntime = (config3) => config3?.runtime ?? DEFAULT_EXECUTION_RUNTIME;
418674
+ var createCodeExecutorForRuntime = (runtime5) => {
418675
+ switch (runtime5) {
418676
+ case "deno":
418677
+ return makeDenoSubprocessExecutor();
418678
+ case "ses":
418679
+ return makeSesExecutor();
418680
+ case "quickjs":
418681
+ default:
418682
+ return makeQuickJsExecutor();
418683
+ }
418684
+ };
418212
418685
  var tokenize2 = (value7) => value7.trim().toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
418213
418686
  var LOW_SIGNAL_QUERY_TOKENS = new Set([
418214
418687
  "a",
@@ -418549,6 +419022,7 @@ var createWorkspaceToolInvoker = (input) => {
418549
419022
  };
418550
419023
  var createWorkspaceExecutionEnvironmentResolver = (input) => ({ workspaceId, accountId, onElicitation }) => gen2(function* () {
418551
419024
  const runtimeLocalWorkspace = yield* getRuntimeLocalWorkspaceOption();
419025
+ const loadedConfig = runtimeLocalWorkspace === null ? null : yield* input.workspaceConfigStore.load(runtimeLocalWorkspace.context);
418552
419026
  const localToolRuntime = runtimeLocalWorkspace === null ? {
418553
419027
  tools: {},
418554
419028
  catalog: createToolCatalogFromTools({ tools: {} }),
@@ -418568,7 +419042,7 @@ var createWorkspaceExecutionEnvironmentResolver = (input) => ({ workspaceId, acc
418568
419042
  localToolRuntime,
418569
419043
  onElicitation
418570
419044
  });
418571
- const executor = makeQuickJsExecutor();
419045
+ const executor = createCodeExecutorForRuntime(resolveConfiguredExecutionRuntime(loadedConfig?.config));
418572
419046
  return {
418573
419047
  executor,
418574
419048
  toolInvoker,
@@ -419837,7 +420311,7 @@ import { pathToFileURL as pathToFileURL4 } from "url";
419837
420311
  import assert32 from "assert";
419838
420312
  import { statSync, realpathSync as realpathSync2 } from "fs";
419839
420313
  import process4 from "process";
419840
- import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "url";
420314
+ import { fileURLToPath as fileURLToPath42, pathToFileURL as pathToFileURL3 } from "url";
419841
420315
  import path7 from "path";
419842
420316
  import { builtinModules } from "module";
419843
420317
  import { fileURLToPath as fileURLToPath32 } from "url";
@@ -421083,7 +421557,7 @@ var utils = {
421083
421557
  // node_modules/prettier/index.mjs
421084
421558
  import { equal, ok, strictEqual } from "assert";
421085
421559
  import path11 from "path";
421086
- import { fileURLToPath as fileURLToPath5 } from "url";
421560
+ import { fileURLToPath as fileURLToPath52 } from "url";
421087
421561
  import path13 from "path";
421088
421562
  import { pathToFileURL as pathToFileURL5 } from "url";
421089
421563
  import path12 from "path";
@@ -433602,9 +434076,9 @@ function emitInvalidSegmentDeprecation(target, request, match18, packageJsonUrl,
433602
434076
  if (process4.noDeprecation) {
433603
434077
  return;
433604
434078
  }
433605
- const pjsonPath = fileURLToPath4(packageJsonUrl);
434079
+ const pjsonPath = fileURLToPath42(packageJsonUrl);
433606
434080
  const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
433607
- process4.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match18 ? "" : `matched to "${match18}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath4(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
434081
+ process4.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match18 ? "" : `matched to "${match18}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath42(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
433608
434082
  }
433609
434083
  function emitLegacyIndexDeprecation(url32, packageJsonUrl, base, main) {
433610
434084
  if (process4.noDeprecation) {
@@ -433613,9 +434087,9 @@ function emitLegacyIndexDeprecation(url32, packageJsonUrl, base, main) {
433613
434087
  const format32 = defaultGetFormatWithoutErrors(url32, { parentURL: base.href });
433614
434088
  if (format32 !== "module")
433615
434089
  return;
433616
- const urlPath = fileURLToPath4(url32.href);
433617
- const packagePath = fileURLToPath4(new URL(".", packageJsonUrl));
433618
- const basePath = fileURLToPath4(base);
434090
+ const urlPath = fileURLToPath42(url32.href);
434091
+ const packagePath = fileURLToPath42(new URL(".", packageJsonUrl));
434092
+ const basePath = fileURLToPath42(base);
433619
434093
  if (!main) {
433620
434094
  process4.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.
433621
434095
  Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
@@ -433672,15 +434146,15 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
433672
434146
  emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
433673
434147
  return guess;
433674
434148
  }
433675
- throw new ERR_MODULE_NOT_FOUND(fileURLToPath4(new URL(".", packageJsonUrl)), fileURLToPath4(base));
434149
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath42(new URL(".", packageJsonUrl)), fileURLToPath42(base));
433676
434150
  }
433677
434151
  function finalizeResolution(resolved, base, preserveSymlinks) {
433678
434152
  if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
433679
- throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath4(base));
434153
+ throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath42(base));
433680
434154
  }
433681
434155
  let filePath;
433682
434156
  try {
433683
- filePath = fileURLToPath4(resolved);
434157
+ filePath = fileURLToPath42(resolved);
433684
434158
  } catch (error51) {
433685
434159
  const cause2 = error51;
433686
434160
  Object.defineProperty(cause2, "input", { value: String(resolved) });
@@ -433689,12 +434163,12 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
433689
434163
  }
433690
434164
  const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
433691
434165
  if (stats && stats.isDirectory()) {
433692
- const error51 = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath4(base));
434166
+ const error51 = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath42(base));
433693
434167
  error51.url = String(resolved);
433694
434168
  throw error51;
433695
434169
  }
433696
434170
  if (!stats || !stats.isFile()) {
433697
- const error51 = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath4(base), true);
434171
+ const error51 = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath42(base), true);
433698
434172
  error51.url = String(resolved);
433699
434173
  throw error51;
433700
434174
  }
@@ -433708,18 +434182,18 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
433708
434182
  return resolved;
433709
434183
  }
433710
434184
  function importNotDefined(specifier, packageJsonUrl, base) {
433711
- return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath4(new URL(".", packageJsonUrl)), fileURLToPath4(base));
434185
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath42(new URL(".", packageJsonUrl)), fileURLToPath42(base));
433712
434186
  }
433713
434187
  function exportsNotFound(subpath, packageJsonUrl, base) {
433714
- return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath4(new URL(".", packageJsonUrl)), subpath, base && fileURLToPath4(base));
434188
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath42(new URL(".", packageJsonUrl)), subpath, base && fileURLToPath42(base));
433715
434189
  }
433716
434190
  function throwInvalidSubpath(request, match18, packageJsonUrl, internal, base) {
433717
- const reason = `request is not a valid match in pattern "${match18}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath4(packageJsonUrl)}`;
433718
- throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && fileURLToPath4(base));
434191
+ const reason = `request is not a valid match in pattern "${match18}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath42(packageJsonUrl)}`;
434192
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && fileURLToPath42(base));
433719
434193
  }
433720
434194
  function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
433721
434195
  target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
433722
- return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath4(new URL(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath4(base));
434196
+ return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath42(new URL(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath42(base));
433723
434197
  }
433724
434198
  function resolvePackageTargetString(target, subpath, match18, packageJsonUrl, base, pattern2, internal, isPathMap, conditions) {
433725
434199
  if (subpath !== "" && !pattern2 && target[target.length - 1] !== "/")
@@ -433819,7 +434293,7 @@ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, b
433819
434293
  while (++i5 < keys6.length) {
433820
434294
  const key2 = keys6[i5];
433821
434295
  if (isArrayIndex(key2)) {
433822
- throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath4(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
434296
+ throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath42(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
433823
434297
  }
433824
434298
  }
433825
434299
  i5 = -1;
@@ -433855,7 +434329,7 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
433855
434329
  if (i5++ === 0) {
433856
434330
  isConditionalSugar = currentIsConditionalSugar;
433857
434331
  } else if (isConditionalSugar !== currentIsConditionalSugar) {
433858
- throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath4(packageJsonUrl), base, `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`);
434332
+ throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath42(packageJsonUrl), base, `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`);
433859
434333
  }
433860
434334
  }
433861
434335
  return isConditionalSugar;
@@ -433864,11 +434338,11 @@ function emitTrailingSlashPatternDeprecation(match18, pjsonUrl, base) {
433864
434338
  if (process4.noDeprecation) {
433865
434339
  return;
433866
434340
  }
433867
- const pjsonPath = fileURLToPath4(pjsonUrl);
434341
+ const pjsonPath = fileURLToPath42(pjsonUrl);
433868
434342
  if (emittedPackageWarnings.has(pjsonPath + "|" + match18))
433869
434343
  return;
433870
434344
  emittedPackageWarnings.add(pjsonPath + "|" + match18);
433871
- process4.emitWarning(`Use of deprecated trailing slash pattern mapping "${match18}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath4(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
434345
+ process4.emitWarning(`Use of deprecated trailing slash pattern mapping "${match18}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath42(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
433872
434346
  }
433873
434347
  function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
433874
434348
  let exports = packageConfig.exports;
@@ -433933,7 +434407,7 @@ function patternKeyCompare(a5, b5) {
433933
434407
  function packageImportsResolve(name2, base, conditions) {
433934
434408
  if (name2 === "#" || name2.startsWith("#/") || name2.endsWith("/")) {
433935
434409
  const reason = "is not a valid internal imports specifier name";
433936
- throw new ERR_INVALID_MODULE_SPECIFIER(name2, reason, fileURLToPath4(base));
434410
+ throw new ERR_INVALID_MODULE_SPECIFIER(name2, reason, fileURLToPath42(base));
433937
434411
  }
433938
434412
  let packageJsonUrl;
433939
434413
  const packageConfig = getPackageScopeConfig(base);
@@ -433991,7 +434465,7 @@ function parsePackageName(specifier, base) {
433991
434465
  validPackageName = false;
433992
434466
  }
433993
434467
  if (!validPackageName) {
433994
- throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath4(base));
434468
+ throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath42(base));
433995
434469
  }
433996
434470
  const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
433997
434471
  return { packageName, packageSubpath, isScoped };
@@ -434009,14 +434483,14 @@ function packageResolve(specifier, base, conditions) {
434009
434483
  }
434010
434484
  }
434011
434485
  let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
434012
- let packageJsonPath = fileURLToPath4(packageJsonUrl);
434486
+ let packageJsonPath = fileURLToPath42(packageJsonUrl);
434013
434487
  let lastPath;
434014
434488
  do {
434015
434489
  const stat22 = tryStatSync(packageJsonPath.slice(0, -13));
434016
434490
  if (!stat22 || !stat22.isDirectory()) {
434017
434491
  lastPath = packageJsonPath;
434018
434492
  packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
434019
- packageJsonPath = fileURLToPath4(packageJsonUrl);
434493
+ packageJsonPath = fileURLToPath42(packageJsonUrl);
434020
434494
  continue;
434021
434495
  }
434022
434496
  const packageConfig2 = read22(packageJsonPath, { base, specifier });
@@ -434028,7 +434502,7 @@ function packageResolve(specifier, base, conditions) {
434028
434502
  }
434029
434503
  return new URL(packageSubpath, packageJsonUrl);
434030
434504
  } while (packageJsonPath.length !== lastPath.length);
434031
- throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath4(base), false);
434505
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath42(base), false);
434032
434506
  }
434033
434507
  function isRelativeSpecifier(specifier) {
434034
434508
  if (specifier[0] === ".") {
@@ -435721,7 +436195,7 @@ function getLanguageByIsSupported(languages2, file10) {
435721
436195
  }
435722
436196
  if (isUrl(file10)) {
435723
436197
  try {
435724
- file10 = fileURLToPath5(file10);
436198
+ file10 = fileURLToPath52(file10);
435725
436199
  } catch {
435726
436200
  return;
435727
436201
  }
@@ -440147,7 +440621,7 @@ var ControlPlaneApiLive = exports_HttpApiBuilder.api(ControlPlaneApi).pipe(provi
440147
440621
  var createControlPlaneApiLayer = (runtimeLayer) => ControlPlaneApiLive.pipe(provide3(runtimeLayer));
440148
440622
  // packages/control-plane/src/runtime/local-control-plane-store.ts
440149
440623
  import { randomUUID as randomUUID2 } from "node:crypto";
440150
- import { existsSync as existsSync2 } from "node:fs";
440624
+ import { existsSync as existsSync3 } from "node:fs";
440151
440625
  import { mkdir as mkdir2, readFile as readFile4, rename as rename5, writeFile as writeFile3 } from "node:fs/promises";
440152
440626
  import { dirname as dirname6, join as join12 } from "node:path";
440153
440627
  var LOCAL_CONTROL_PLANE_STATE_VERSION = 1;
@@ -440213,7 +440687,7 @@ var sortByUpdatedAtAndIdDesc = (values4) => [...values4].sort((left3, right3) =>
440213
440687
  var localControlPlaneStatePath = (context7) => join12(context7.homeStateDirectory, "workspaces", deriveLocalInstallation(context7).workspaceId, LOCAL_CONTROL_PLANE_STATE_BASENAME);
440214
440688
  var readStateFromDisk = async (context7) => {
440215
440689
  const path15 = localControlPlaneStatePath(context7);
440216
- if (!existsSync2(path15)) {
440690
+ if (!existsSync3(path15)) {
440217
440691
  return defaultLocalControlPlaneState();
440218
440692
  }
440219
440693
  const content = await readFile4(path15, "utf8");
@@ -440674,7 +441148,7 @@ var createLocalControlPlanePersistence = (context7) => ({
440674
441148
  });
440675
441149
 
440676
441150
  // packages/control-plane/src/runtime/legacy-postgres-migration.ts
440677
- import { existsSync as existsSync4, readFileSync } from "node:fs";
441151
+ import { existsSync as existsSync5, readFileSync } from "node:fs";
440678
441152
  import { mkdir as mkdir3, rename as rename6, unlink } from "node:fs/promises";
440679
441153
  import { join as join14, resolve as resolve7 } from "node:path";
440680
441154
 
@@ -448268,7 +448742,7 @@ var trimOrNull8 = (value7) => {
448268
448742
  const trimmed2 = value7.trim();
448269
448743
  return trimmed2.length > 0 ? trimmed2 : null;
448270
448744
  };
448271
- var toError4 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
448745
+ var toError5 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
448272
448746
  var asRecord7 = (value7) => value7 !== null && typeof value7 === "object" && !Array.isArray(value7) ? value7 : {};
448273
448747
  var asString8 = (value7) => {
448274
448748
  const trimmed2 = trimOrNull8(value7);
@@ -448492,7 +448966,7 @@ var isPostgresUrl = (value7) => {
448492
448966
  };
448493
448967
  var cleanupStalePGliteLock = async (dataDir) => {
448494
448968
  const lockPath = join14(dataDir, "postmaster.pid");
448495
- if (!existsSync4(lockPath)) {
448969
+ if (!existsSync5(lockPath)) {
448496
448970
  return;
448497
448971
  }
448498
448972
  try {
@@ -448512,7 +448986,7 @@ var openLegacyPGliteClient = async (localDataDir) => {
448512
448986
  return null;
448513
448987
  }
448514
448988
  const resolvedDataDir = resolve7(localDataDir);
448515
- if (!existsSync4(resolvedDataDir)) {
448989
+ if (!existsSync5(resolvedDataDir)) {
448516
448990
  return null;
448517
448991
  }
448518
448992
  await mkdir3(resolvedDataDir, { recursive: true });
@@ -448613,7 +449087,7 @@ var backupLegacyPGliteDataDir = async (localDataDir) => {
448613
449087
  return null;
448614
449088
  }
448615
449089
  const resolvedDataDir = resolve7(localDataDir);
448616
- if (!existsSync4(resolvedDataDir)) {
449090
+ if (!existsSync5(resolvedDataDir)) {
448617
449091
  return null;
448618
449092
  }
448619
449093
  const backupPath = `${resolvedDataDir}.migrated-backup-${Date.now()}`;
@@ -448670,7 +449144,7 @@ var tryLoadLegacyWorkspaceSnapshot = async (input) => {
448670
449144
  };
448671
449145
  var targetControlPlaneStatePath = (context7) => join14(context7.homeStateDirectory, "workspaces", deriveLocalInstallation(context7).workspaceId, LOCAL_CONTROL_PLANE_STATE_BASENAME2);
448672
449146
  var targetWorkspaceStatePath = (context7) => join14(context7.stateDirectory, WORKSPACE_STATE_BASENAME2);
448673
- var workspaceAlreadyInitialized = (context7) => existsSync4(context7.projectConfigPath) || existsSync4(targetWorkspaceStatePath(context7)) || existsSync4(targetControlPlaneStatePath(context7));
449147
+ var workspaceAlreadyInitialized = (context7) => existsSync5(context7.projectConfigPath) || existsSync5(targetWorkspaceStatePath(context7)) || existsSync5(targetControlPlaneStatePath(context7));
448674
449148
  var mapLegacySecretRef = (input) => ({
448675
449149
  providerId: input.providerId === LEGACY_POSTGRES_SECRET_PROVIDER_ID ? LOCAL_SECRET_PROVIDER_ID2 : input.providerId,
448676
449150
  handle: input.handle
@@ -449221,7 +449695,7 @@ var migrateLegacyPostgresWorkspaceIfNeeded = (input) => gen2(function* () {
449221
449695
  localDataDir: input.legacyLocalDataDir,
449222
449696
  databaseUrl: input.legacyDatabaseUrl
449223
449697
  }),
449224
- catch: toError4
449698
+ catch: toError5
449225
449699
  });
449226
449700
  if (loadedSnapshot === null) {
449227
449701
  return;
@@ -449231,7 +449705,7 @@ var migrateLegacyPostgresWorkspaceIfNeeded = (input) => gen2(function* () {
449231
449705
  context: input.context,
449232
449706
  snapshot: loadedSnapshot.snapshot
449233
449707
  }),
449234
- catch: toError4
449708
+ catch: toError5
449235
449709
  });
449236
449710
  yield* writeProjectLocalExecutorConfig({
449237
449711
  context: input.context,
@@ -449254,7 +449728,7 @@ var migrateLegacyPostgresWorkspaceIfNeeded = (input) => gen2(function* () {
449254
449728
  const legacyLocalDataDir = loadedSnapshot.source.localDataDir;
449255
449729
  const backupExit = yield* exit2(tryPromise2({
449256
449730
  try: () => backupLegacyPGliteDataDir(legacyLocalDataDir),
449257
- catch: toError4
449731
+ catch: toError5
449258
449732
  }));
449259
449733
  yield* sync3(() => {
449260
449734
  if (backupExit._tag === "Success" && backupExit.value !== null) {
@@ -449359,7 +449833,7 @@ var createControlPlaneClient = (input) => exports_HttpApiClient.make(ControlPlan
449359
449833
  baseUrl: input.baseUrl
449360
449834
  }).pipe(provide2(exports_FetchHttpClient.layer));
449361
449835
  // packages/server/src/index.ts
449362
- import { existsSync as existsSync6 } from "node:fs";
449836
+ import { existsSync as existsSync7 } from "node:fs";
449363
449837
  import { mkdir as mkdir4, readFile as readFile5, rename as rename7, rm as rm4, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
449364
449838
  import {
449365
449839
  createServer as createNodeServer
@@ -451589,7 +452063,7 @@ import { homedir as homedir2 } from "node:os";
451589
452063
  import { join as join16 } from "node:path";
451590
452064
 
451591
452065
  // packages/server/src/env.ts
451592
- import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
452066
+ import { existsSync as existsSync6, readFileSync as readFileSync2 } from "node:fs";
451593
452067
  import { dirname as dirname7, join as join15, resolve as resolve8 } from "node:path";
451594
452068
  var parseEnvFile = (content) => {
451595
452069
  const values5 = {};
@@ -451621,7 +452095,7 @@ var parseEnvFile = (content) => {
451621
452095
  };
451622
452096
  var isWorkspaceRoot = (directory5) => {
451623
452097
  const packageJsonPath = join15(directory5, "package.json");
451624
- if (!existsSync5(packageJsonPath)) {
452098
+ if (!existsSync6(packageJsonPath)) {
451625
452099
  return false;
451626
452100
  }
451627
452101
  try {
@@ -451658,7 +452132,7 @@ var loadMonorepoRootEnv = (options10 = {}) => {
451658
452132
  const loadedFiles = [];
451659
452133
  for (const fileName of [".env", ".env.local"]) {
451660
452134
  const filePath = join15(rootDir, fileName);
451661
- if (!existsSync5(filePath)) {
452135
+ if (!existsSync6(filePath)) {
451662
452136
  continue;
451663
452137
  }
451664
452138
  const parsed = parseEnvFile(readFileSync2(filePath, "utf8"));
@@ -452320,7 +452794,7 @@ var createRuntime = (localDataDir, getLocalServerBaseUrl, options10) => createCo
452320
452794
  var moveLegacyLocalDataDir = (legacyLocalDataDir, requestedLocalDataDir) => tryPromise2({
452321
452795
  try: async () => {
452322
452796
  await mkdir4(dirname8(requestedLocalDataDir), { recursive: true });
452323
- if (existsSync6(requestedLocalDataDir)) {
452797
+ if (existsSync7(requestedLocalDataDir)) {
452324
452798
  const backupPath = `${requestedLocalDataDir}.backup-${Date.now()}`;
452325
452799
  await rename7(requestedLocalDataDir, backupPath);
452326
452800
  console.warn(`[executor] Backed up unreadable local data dir to: ${backupPath}`);
@@ -452331,7 +452805,7 @@ var moveLegacyLocalDataDir = (legacyLocalDataDir, requestedLocalDataDir) => tryP
452331
452805
  catch: (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2))
452332
452806
  });
452333
452807
  var createRuntimeWithLegacyMigration = (requestedLocalDataDir, legacyLocalDataDirs, getLocalServerBaseUrl, options10) => gen2(function* () {
452334
- if (requestedLocalDataDir !== ":memory:" && !existsSync6(requestedLocalDataDir) && legacyLocalDataDirs.length > 0) {
452808
+ if (requestedLocalDataDir !== ":memory:" && !existsSync7(requestedLocalDataDir) && legacyLocalDataDirs.length > 0) {
452335
452809
  for (const legacyLocalDataDir of legacyLocalDataDirs) {
452336
452810
  const legacyExit = yield* exit2(createRuntime(legacyLocalDataDir, getLocalServerBaseUrl, options10));
452337
452811
  if (isFailure(legacyExit)) {
@@ -452491,7 +452965,7 @@ var isApiRequest = (request) => {
452491
452965
  };
452492
452966
  var createLocalExecutorRequestHandler = (options10 = {}) => gen2(function* () {
452493
452967
  const requestedLocalDataDir = options10.localDataDir ?? DEFAULT_LOCAL_DATA_DIR;
452494
- const legacyLocalDataDirs = options10.localDataDir === undefined ? DEFAULT_LEGACY_LOCAL_DATA_DIRS.filter((candidate) => existsSync6(candidate)) : [];
452968
+ const legacyLocalDataDirs = options10.localDataDir === undefined ? DEFAULT_LEGACY_LOCAL_DATA_DIRS.filter((candidate) => existsSync7(candidate)) : [];
452495
452969
  if (requestedLocalDataDir !== ":memory:") {
452496
452970
  yield* tryPromise2({
452497
452971
  try: () => mkdir4(dirname8(requestedLocalDataDir), { recursive: true }),
@@ -452763,7 +453237,7 @@ var seedGithubOpenApiSourceInWorkspace = (input) => gen2(function* () {
452763
453237
  });
452764
453238
 
452765
453239
  // apps/executor/src/cli/runtime-paths.ts
452766
- import { existsSync as existsSync7 } from "node:fs";
453240
+ import { existsSync as existsSync8 } from "node:fs";
452767
453241
  import { dirname as dirname9, extname as extname4, resolve as resolve10 } from "node:path";
452768
453242
  import { fileURLToPath as fileURLToPath6 } from "node:url";
452769
453243
  var sourceDir = dirname9(fileURLToPath6(import.meta.url));
@@ -452777,7 +453251,7 @@ var resolveIfExists = (value7) => {
452777
453251
  return null;
452778
453252
  }
452779
453253
  const resolved = resolve10(candidate);
452780
- return existsSync7(resolved) ? resolved : null;
453254
+ return existsSync8(resolved) ? resolved : null;
452781
453255
  };
452782
453256
  var getSourceEntrypoint = () => {
452783
453257
  const candidate = trim4(process.argv[1]);
@@ -452790,21 +453264,21 @@ var getSourceEntrypoint = () => {
452790
453264
  };
452791
453265
  var resolveBundledNodeLauncher = () => {
452792
453266
  const candidate = resolve10(sourceDir, "executor.js");
452793
- return existsSync7(candidate) ? candidate : null;
453267
+ return existsSync8(candidate) ? candidate : null;
452794
453268
  };
452795
453269
  var resolveRuntimeResourcesRoot = () => {
452796
453270
  const compiledCandidate = resolve10(dirname9(process.execPath), "../resources");
452797
- if (existsSync7(compiledCandidate)) {
453271
+ if (existsSync8(compiledCandidate)) {
452798
453272
  return compiledCandidate;
452799
453273
  }
452800
453274
  const bundledCandidateFromModule = resolve10(sourceDir, "../resources");
452801
- if (existsSync7(bundledCandidateFromModule)) {
453275
+ if (existsSync8(bundledCandidateFromModule)) {
452802
453276
  return bundledCandidateFromModule;
452803
453277
  }
452804
453278
  const sourceEntrypoint = getSourceEntrypoint();
452805
453279
  if (sourceEntrypoint) {
452806
453280
  const bundledCandidate = resolve10(dirname9(sourceEntrypoint), "../resources");
452807
- if (existsSync7(bundledCandidate)) {
453281
+ if (existsSync8(bundledCandidate)) {
452808
453282
  return bundledCandidate;
452809
453283
  }
452810
453284
  }
@@ -452923,12 +453397,12 @@ var decideInteractionHandling = (input) => {
452923
453397
  };
452924
453398
 
452925
453399
  // apps/executor/src/cli/main.ts
452926
- var toError5 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
453400
+ var toError6 = (cause2) => cause2 instanceof Error ? cause2 : new Error(String(cause2));
452927
453401
  var sleep6 = (ms8) => promise2(() => new Promise((resolve12) => setTimeout(resolve12, ms8)));
452928
453402
  var openUrlInBrowser = (url4) => sync3(() => {
452929
453403
  const cmd = process.platform === "darwin" ? ["open", url4] : process.platform === "win32" ? ["cmd", "/c", "start", "", url4] : ["xdg-open", url4];
452930
453404
  try {
452931
- const child = spawn2(cmd[0], cmd.slice(1), {
453405
+ const child = spawn3(cmd[0], cmd.slice(1), {
452932
453406
  detached: true,
452933
453407
  stdio: "ignore"
452934
453408
  });
@@ -452950,7 +453424,7 @@ var promptLine = (prompt4) => tryPromise2({
452950
453424
  rl5.close();
452951
453425
  }
452952
453426
  },
452953
- catch: toError5
453427
+ catch: toError6
452954
453428
  });
452955
453429
  var readStdin = () => tryPromise2({
452956
453430
  try: async () => {
@@ -452961,7 +453435,7 @@ var readStdin = () => tryPromise2({
452961
453435
  }
452962
453436
  return contents;
452963
453437
  },
452964
- catch: toError5
453438
+ catch: toError6
452965
453439
  });
452966
453440
  var readCode = (input) => gen2(function* () {
452967
453441
  if (input.code && input.code.trim().length > 0) {
@@ -452970,7 +453444,7 @@ var readCode = (input) => gen2(function* () {
452970
453444
  if (input.file && input.file.trim().length > 0) {
452971
453445
  const contents = yield* tryPromise2({
452972
453446
  try: () => readFile6(input.file, "utf8"),
452973
- catch: toError5
453447
+ catch: toError6
452974
453448
  });
452975
453449
  if (contents.trim().length > 0) {
452976
453450
  return contents;
@@ -452987,7 +453461,7 @@ var readCode = (input) => gen2(function* () {
452987
453461
  });
452988
453462
  var getBootstrapClient = (baseUrl2 = DEFAULT_SERVER_BASE_URL) => createControlPlaneClient({ baseUrl: baseUrl2 });
452989
453463
  var decodeExecutionId = decodeUnknown2(ExecutionIdSchema);
452990
- var cliSourceDir = dirname10(fileURLToPath8(import.meta.url));
453464
+ var cliSourceDir = dirname10(fileURLToPath7(import.meta.url));
452991
453465
  var CLI_NAME = "executor";
452992
453466
  var CLI_VERSION = (() => {
452993
453467
  const candidatePaths = [
@@ -452995,7 +453469,7 @@ var CLI_VERSION = (() => {
452995
453469
  resolve11(cliSourceDir, "../../package.json")
452996
453470
  ];
452997
453471
  for (const candidatePath of candidatePaths) {
452998
- if (!existsSync8(candidatePath)) {
453472
+ if (!existsSync9(candidatePath)) {
452999
453473
  continue;
453000
453474
  }
453001
453475
  try {
@@ -453063,17 +453537,17 @@ var formatCatalogUnavailableMessage = (cause2) => {
453063
453537
  };
453064
453538
  var closeRuntime = (runtime6) => tryPromise2({
453065
453539
  try: () => runtime6.close(),
453066
- catch: toError5
453540
+ catch: toError6
453067
453541
  }).pipe(catchAll2(() => _void));
453068
453542
  var buildRunWorkflowText = (catalog2) => {
453069
453543
  if (!catalog2) {
453070
453544
  return succeed8(DEFAULT_RUN_WORKFLOW);
453071
453545
  }
453072
- return catalog2.listNamespaces({ limit: 200 }).pipe(map16((namespaces) => buildWorkflowText(namespaces.length > 0 ? namespaces.map((namespace) => namespace.displayName ?? namespace.namespace) : ["none discovered yet"])), mapError2(toError5));
453546
+ return catalog2.listNamespaces({ limit: 200 }).pipe(map16((namespaces) => buildWorkflowText(namespaces.length > 0 ? namespaces.map((namespace) => namespace.displayName ?? namespace.namespace) : ["none discovered yet"])), mapError2(toError6));
453073
453547
  };
453074
453548
  var loadRunWorkflowText = () => acquireUseRelease2(createControlPlaneRuntime({
453075
453549
  localDataDir: DEFAULT_LOCAL_DATA_DIR
453076
- }).pipe(mapError2(toError5)), (runtime6) => gen2(function* () {
453550
+ }).pipe(mapError2(toError6)), (runtime6) => gen2(function* () {
453077
453551
  const environment2 = yield* gen2(function* () {
453078
453552
  const resolveExecutionEnvironment = yield* RuntimeExecutionResolverService;
453079
453553
  return yield* resolveExecutionEnvironment({
@@ -453081,7 +453555,7 @@ var loadRunWorkflowText = () => acquireUseRelease2(createControlPlaneRuntime({
453081
453555
  accountId: runtime6.localInstallation.accountId,
453082
453556
  executionId: ExecutionIdSchema.make("exec_help")
453083
453557
  });
453084
- }).pipe(provide2(runtime6.runtimeLayer), mapError2(toError5));
453558
+ }).pipe(provide2(runtime6.runtimeLayer), mapError2(toError6));
453085
453559
  return yield* buildRunWorkflowText(environment2.catalog);
453086
453560
  }), closeRuntime).pipe(catchAllCause2((cause2) => succeed8([
453087
453561
  DEFAULT_RUN_WORKFLOW,
@@ -453196,7 +453670,7 @@ var startServerInBackground = (port2) => tryPromise2({
453196
453670
  await mkdir5(dirname10(DEFAULT_SERVER_LOG_FILE), { recursive: true });
453197
453671
  const logHandle = await open3(DEFAULT_SERVER_LOG_FILE, "a");
453198
453672
  try {
453199
- const child = spawn2(command[0], command.slice(1), {
453673
+ const child = spawn3(command[0], command.slice(1), {
453200
453674
  detached: true,
453201
453675
  stdio: ["ignore", logHandle.fd, logHandle.fd]
453202
453676
  });
@@ -453205,7 +453679,7 @@ var startServerInBackground = (port2) => tryPromise2({
453205
453679
  await logHandle.close();
453206
453680
  }
453207
453681
  },
453208
- catch: toError5
453682
+ catch: toError6
453209
453683
  });
453210
453684
  var readPidRecord = () => tryPromise2({
453211
453685
  try: async () => {
@@ -453258,7 +453732,7 @@ var waitForReachability = (baseUrl2, expected) => gen2(function* () {
453258
453732
  }
453259
453733
  const error51 = yield* tryPromise2({
453260
453734
  try: () => buildReachabilityTimeoutError(baseUrl2, expected),
453261
- catch: toError5
453735
+ catch: toError6
453262
453736
  });
453263
453737
  return yield* fail8(error51);
453264
453738
  });
@@ -453691,8 +454165,8 @@ var doctorCommand = exports_Command.make("doctor", {
453691
454165
  `))))).pipe(exports_Command.withDescription("Check local executor install and daemon health"));
453692
454166
  var getDenoVersion = () => tryPromise2({
453693
454167
  try: () => new Promise((resolve12) => {
453694
- const denoExecutable = process.env.DENO_BIN?.trim() || (process.env.HOME && existsSync8(`${process.env.HOME}/.deno/bin/deno`) ? `${process.env.HOME}/.deno/bin/deno` : "deno");
453695
- const child = spawn2(denoExecutable, ["--version"], {
454168
+ const denoExecutable = process.env.DENO_BIN?.trim() || (process.env.HOME && existsSync9(`${process.env.HOME}/.deno/bin/deno`) ? `${process.env.HOME}/.deno/bin/deno` : "deno");
454169
+ const child = spawn3(denoExecutable, ["--version"], {
453696
454170
  stdio: ["ignore", "pipe", "ignore"],
453697
454171
  timeout: 5000
453698
454172
  });
@@ -453771,7 +454245,7 @@ var resumeCommand = exports_Command.make("resume", {
453771
454245
  }, ({ executionId, baseUrl: baseUrl2, noOpen }) => gen2(function* () {
453772
454246
  yield* ensureServer(baseUrl2);
453773
454247
  const { installation, client: client2 } = yield* getLocalAuthedClient(baseUrl2);
453774
- const decodedExecutionId = yield* decodeExecutionId(executionId).pipe(mapError2((cause2) => toError5(cause2)));
454248
+ const decodedExecutionId = yield* decodeExecutionId(executionId).pipe(mapError2((cause2) => toError6(cause2)));
453775
454249
  const execution2 = yield* client2.executions.get({
453776
454250
  path: {
453777
454251
  workspaceId: installation.workspaceId,
@@ -453841,7 +454315,7 @@ var hiddenServer = () => {
453841
454315
  ...getDefaultServerOptions(Number.isInteger(port2) && port2 > 0 ? port2 : DEFAULT_SERVER_PORT)
453842
454316
  });
453843
454317
  };
453844
- var program = (hiddenServer() ?? helpOverride() ?? runCli(toEffectCliArgv(getCliArgs())).pipe(mapError2(toError5))).pipe(provide2(exports_NodeFileSystem.layer)).pipe(provide2(exports_NodePath.layer)).pipe(catchAllCause2((cause2) => sync3(() => {
454318
+ var program = (hiddenServer() ?? helpOverride() ?? runCli(toEffectCliArgv(getCliArgs())).pipe(mapError2(toError6))).pipe(provide2(exports_NodeFileSystem.layer)).pipe(provide2(exports_NodePath.layer)).pipe(catchAllCause2((cause2) => sync3(() => {
453845
454319
  console.error(pretty2(cause2));
453846
454320
  process.exitCode = 1;
453847
454321
  })));