@letta-ai/letta-code 0.29.13 → 0.30.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.
package/letta.js CHANGED
@@ -5462,7 +5462,7 @@ var package_default;
5462
5462
  var init_package = __esm(() => {
5463
5463
  package_default = {
5464
5464
  name: "@letta-ai/letta-code",
5465
- version: "0.29.13",
5465
+ version: "0.30.0",
5466
5466
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5467
5467
  type: "module",
5468
5468
  packageManager: "bun@1.3.0",
@@ -5563,6 +5563,7 @@ var init_package = __esm(() => {
5563
5563
  "@modelcontextprotocol/sdk": "1.30.0",
5564
5564
  "@pierre/diffs": "1.2.2",
5565
5565
  "@scarf/scarf": "^1.4.0",
5566
+ "cross-spawn": "^7.0.6",
5566
5567
  "cron-parser": "^5.6.1",
5567
5568
  glob: "^13.0.0",
5568
5569
  "ink-link": "^5.0.0",
@@ -5581,6 +5582,7 @@ var init_package = __esm(() => {
5581
5582
  "@modelcontextprotocol/server-everything": "^2026.7.4",
5582
5583
  "@slack/bolt": "^4.7.0",
5583
5584
  "@types/bun": "^1.3.7",
5585
+ "@types/cross-spawn": "^6.0.6",
5584
5586
  "@types/diff": "^8.0.0",
5585
5587
  "@types/picomatch": "^4.0.2",
5586
5588
  "@types/react": "^19.2.9",
@@ -147033,6 +147035,487 @@ var init_auto_update = __esm(() => {
147033
147035
  VALID_PACKAGE_MANAGERS = new Set(Object.keys(INSTALL_ARG_PREFIX));
147034
147036
  });
147035
147037
 
147038
+ // node_modules/isexe/windows.js
147039
+ var require_windows = __commonJS((exports, module3) => {
147040
+ module3.exports = isexe;
147041
+ isexe.sync = sync;
147042
+ var fs3 = __require("fs");
147043
+ function checkPathExt(path5, options3) {
147044
+ var pathext = options3.pathExt !== undefined ? options3.pathExt : process.env.PATHEXT;
147045
+ if (!pathext) {
147046
+ return true;
147047
+ }
147048
+ pathext = pathext.split(";");
147049
+ if (pathext.indexOf("") !== -1) {
147050
+ return true;
147051
+ }
147052
+ for (var i2 = 0;i2 < pathext.length; i2++) {
147053
+ var p = pathext[i2].toLowerCase();
147054
+ if (p && path5.substr(-p.length).toLowerCase() === p) {
147055
+ return true;
147056
+ }
147057
+ }
147058
+ return false;
147059
+ }
147060
+ function checkStat(stat3, path5, options3) {
147061
+ if (!stat3.isSymbolicLink() && !stat3.isFile()) {
147062
+ return false;
147063
+ }
147064
+ return checkPathExt(path5, options3);
147065
+ }
147066
+ function isexe(path5, options3, cb) {
147067
+ fs3.stat(path5, function(er, stat3) {
147068
+ cb(er, er ? false : checkStat(stat3, path5, options3));
147069
+ });
147070
+ }
147071
+ function sync(path5, options3) {
147072
+ return checkStat(fs3.statSync(path5), path5, options3);
147073
+ }
147074
+ });
147075
+
147076
+ // node_modules/isexe/mode.js
147077
+ var require_mode = __commonJS((exports, module3) => {
147078
+ module3.exports = isexe;
147079
+ isexe.sync = sync;
147080
+ var fs3 = __require("fs");
147081
+ function isexe(path5, options3, cb) {
147082
+ fs3.stat(path5, function(er, stat3) {
147083
+ cb(er, er ? false : checkStat(stat3, options3));
147084
+ });
147085
+ }
147086
+ function sync(path5, options3) {
147087
+ return checkStat(fs3.statSync(path5), options3);
147088
+ }
147089
+ function checkStat(stat3, options3) {
147090
+ return stat3.isFile() && checkMode(stat3, options3);
147091
+ }
147092
+ function checkMode(stat3, options3) {
147093
+ var mod = stat3.mode;
147094
+ var uid = stat3.uid;
147095
+ var gid = stat3.gid;
147096
+ var myUid = options3.uid !== undefined ? options3.uid : process.getuid && process.getuid();
147097
+ var myGid = options3.gid !== undefined ? options3.gid : process.getgid && process.getgid();
147098
+ var u = parseInt("100", 8);
147099
+ var g = parseInt("010", 8);
147100
+ var o = parseInt("001", 8);
147101
+ var ug = u | g;
147102
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
147103
+ return ret;
147104
+ }
147105
+ });
147106
+
147107
+ // node_modules/isexe/index.js
147108
+ var require_isexe = __commonJS((exports, module3) => {
147109
+ var fs3 = __require("fs");
147110
+ var core2;
147111
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
147112
+ core2 = require_windows();
147113
+ } else {
147114
+ core2 = require_mode();
147115
+ }
147116
+ module3.exports = isexe;
147117
+ isexe.sync = sync;
147118
+ function isexe(path5, options3, cb) {
147119
+ if (typeof options3 === "function") {
147120
+ cb = options3;
147121
+ options3 = {};
147122
+ }
147123
+ if (!cb) {
147124
+ if (typeof Promise !== "function") {
147125
+ throw new TypeError("callback not provided");
147126
+ }
147127
+ return new Promise(function(resolve3, reject) {
147128
+ isexe(path5, options3 || {}, function(er, is) {
147129
+ if (er) {
147130
+ reject(er);
147131
+ } else {
147132
+ resolve3(is);
147133
+ }
147134
+ });
147135
+ });
147136
+ }
147137
+ core2(path5, options3 || {}, function(er, is) {
147138
+ if (er) {
147139
+ if (er.code === "EACCES" || options3 && options3.ignoreErrors) {
147140
+ er = null;
147141
+ is = false;
147142
+ }
147143
+ }
147144
+ cb(er, is);
147145
+ });
147146
+ }
147147
+ function sync(path5, options3) {
147148
+ try {
147149
+ return core2.sync(path5, options3 || {});
147150
+ } catch (er) {
147151
+ if (options3 && options3.ignoreErrors || er.code === "EACCES") {
147152
+ return false;
147153
+ } else {
147154
+ throw er;
147155
+ }
147156
+ }
147157
+ }
147158
+ });
147159
+
147160
+ // node_modules/which/which.js
147161
+ var require_which = __commonJS((exports, module3) => {
147162
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
147163
+ var path5 = __require("path");
147164
+ var COLON2 = isWindows ? ";" : ":";
147165
+ var isexe = require_isexe();
147166
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
147167
+ var getPathInfo = (cmd, opt) => {
147168
+ const colon = opt.colon || COLON2;
147169
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
147170
+ ...isWindows ? [process.cwd()] : [],
147171
+ ...(opt.path || process.env.PATH || "").split(colon)
147172
+ ];
147173
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
147174
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
147175
+ if (isWindows) {
147176
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
147177
+ pathExt.unshift("");
147178
+ }
147179
+ return {
147180
+ pathEnv,
147181
+ pathExt,
147182
+ pathExtExe
147183
+ };
147184
+ };
147185
+ var which = (cmd, opt, cb) => {
147186
+ if (typeof opt === "function") {
147187
+ cb = opt;
147188
+ opt = {};
147189
+ }
147190
+ if (!opt)
147191
+ opt = {};
147192
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
147193
+ const found = [];
147194
+ const step = (i2) => new Promise((resolve3, reject) => {
147195
+ if (i2 === pathEnv.length)
147196
+ return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
147197
+ const ppRaw = pathEnv[i2];
147198
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
147199
+ const pCmd = path5.join(pathPart, cmd);
147200
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
147201
+ resolve3(subStep(p, i2, 0));
147202
+ });
147203
+ const subStep = (p, i2, ii) => new Promise((resolve3, reject) => {
147204
+ if (ii === pathExt.length)
147205
+ return resolve3(step(i2 + 1));
147206
+ const ext = pathExt[ii];
147207
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
147208
+ if (!er && is) {
147209
+ if (opt.all)
147210
+ found.push(p + ext);
147211
+ else
147212
+ return resolve3(p + ext);
147213
+ }
147214
+ return resolve3(subStep(p, i2, ii + 1));
147215
+ });
147216
+ });
147217
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
147218
+ };
147219
+ var whichSync = (cmd, opt) => {
147220
+ opt = opt || {};
147221
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
147222
+ const found = [];
147223
+ for (let i2 = 0;i2 < pathEnv.length; i2++) {
147224
+ const ppRaw = pathEnv[i2];
147225
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
147226
+ const pCmd = path5.join(pathPart, cmd);
147227
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
147228
+ for (let j = 0;j < pathExt.length; j++) {
147229
+ const cur = p + pathExt[j];
147230
+ try {
147231
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
147232
+ if (is) {
147233
+ if (opt.all)
147234
+ found.push(cur);
147235
+ else
147236
+ return cur;
147237
+ }
147238
+ } catch (ex) {}
147239
+ }
147240
+ }
147241
+ if (opt.all && found.length)
147242
+ return found;
147243
+ if (opt.nothrow)
147244
+ return null;
147245
+ throw getNotFoundError(cmd);
147246
+ };
147247
+ module3.exports = which;
147248
+ which.sync = whichSync;
147249
+ });
147250
+
147251
+ // node_modules/path-key/index.js
147252
+ var require_path_key = __commonJS((exports, module3) => {
147253
+ var pathKey = (options3 = {}) => {
147254
+ const environment2 = options3.env || process.env;
147255
+ const platform = options3.platform || process.platform;
147256
+ if (platform !== "win32") {
147257
+ return "PATH";
147258
+ }
147259
+ return Object.keys(environment2).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
147260
+ };
147261
+ module3.exports = pathKey;
147262
+ module3.exports.default = pathKey;
147263
+ });
147264
+
147265
+ // node_modules/cross-spawn/lib/util/resolveCommand.js
147266
+ var require_resolveCommand = __commonJS((exports, module3) => {
147267
+ var path5 = __require("path");
147268
+ var which = require_which();
147269
+ var getPathKey = require_path_key();
147270
+ function resolveCommandAttempt(parsed, withoutPathExt) {
147271
+ const env3 = parsed.options.env || process.env;
147272
+ const cwd = process.cwd();
147273
+ const hasCustomCwd = parsed.options.cwd != null;
147274
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
147275
+ if (shouldSwitchCwd) {
147276
+ try {
147277
+ process.chdir(parsed.options.cwd);
147278
+ } catch (err) {}
147279
+ }
147280
+ let resolved;
147281
+ try {
147282
+ resolved = which.sync(parsed.command, {
147283
+ path: env3[getPathKey({ env: env3 })],
147284
+ pathExt: withoutPathExt ? path5.delimiter : undefined
147285
+ });
147286
+ } catch (e2) {} finally {
147287
+ if (shouldSwitchCwd) {
147288
+ process.chdir(cwd);
147289
+ }
147290
+ }
147291
+ if (resolved) {
147292
+ resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
147293
+ }
147294
+ return resolved;
147295
+ }
147296
+ function resolveCommand(parsed) {
147297
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
147298
+ }
147299
+ module3.exports = resolveCommand;
147300
+ });
147301
+
147302
+ // node_modules/cross-spawn/lib/util/escape.js
147303
+ var require_escape = __commonJS((exports, module3) => {
147304
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
147305
+ function escapeCommand(arg) {
147306
+ arg = arg.replace(metaCharsRegExp, "^$1");
147307
+ return arg;
147308
+ }
147309
+ function escapeArgument(arg, doubleEscapeMetaChars) {
147310
+ arg = `${arg}`;
147311
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
147312
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
147313
+ arg = `"${arg}"`;
147314
+ arg = arg.replace(metaCharsRegExp, "^$1");
147315
+ if (doubleEscapeMetaChars) {
147316
+ arg = arg.replace(metaCharsRegExp, "^$1");
147317
+ }
147318
+ return arg;
147319
+ }
147320
+ exports.command = escapeCommand;
147321
+ exports.argument = escapeArgument;
147322
+ });
147323
+
147324
+ // node_modules/shebang-regex/index.js
147325
+ var require_shebang_regex = __commonJS((exports, module3) => {
147326
+ module3.exports = /^#!(.*)/;
147327
+ });
147328
+
147329
+ // node_modules/shebang-command/index.js
147330
+ var require_shebang_command = __commonJS((exports, module3) => {
147331
+ var shebangRegex = require_shebang_regex();
147332
+ module3.exports = (string7 = "") => {
147333
+ const match2 = string7.match(shebangRegex);
147334
+ if (!match2) {
147335
+ return null;
147336
+ }
147337
+ const [path5, argument] = match2[0].replace(/#! ?/, "").split(" ");
147338
+ const binary = path5.split("/").pop();
147339
+ if (binary === "env") {
147340
+ return argument;
147341
+ }
147342
+ return argument ? `${binary} ${argument}` : binary;
147343
+ };
147344
+ });
147345
+
147346
+ // node_modules/cross-spawn/lib/util/readShebang.js
147347
+ var require_readShebang = __commonJS((exports, module3) => {
147348
+ var fs3 = __require("fs");
147349
+ var shebangCommand = require_shebang_command();
147350
+ function readShebang(command) {
147351
+ const size = 150;
147352
+ const buffer = Buffer.alloc(size);
147353
+ let fd;
147354
+ try {
147355
+ fd = fs3.openSync(command, "r");
147356
+ fs3.readSync(fd, buffer, 0, size, 0);
147357
+ fs3.closeSync(fd);
147358
+ } catch (e2) {}
147359
+ return shebangCommand(buffer.toString());
147360
+ }
147361
+ module3.exports = readShebang;
147362
+ });
147363
+
147364
+ // node_modules/cross-spawn/lib/parse.js
147365
+ var require_parse2 = __commonJS((exports, module3) => {
147366
+ var path5 = __require("path");
147367
+ var resolveCommand = require_resolveCommand();
147368
+ var escape2 = require_escape();
147369
+ var readShebang = require_readShebang();
147370
+ var isWin = process.platform === "win32";
147371
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
147372
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
147373
+ function detectShebang(parsed) {
147374
+ parsed.file = resolveCommand(parsed);
147375
+ const shebang = parsed.file && readShebang(parsed.file);
147376
+ if (shebang) {
147377
+ parsed.args.unshift(parsed.file);
147378
+ parsed.command = shebang;
147379
+ return resolveCommand(parsed);
147380
+ }
147381
+ return parsed.file;
147382
+ }
147383
+ function parseNonShell(parsed) {
147384
+ if (!isWin) {
147385
+ return parsed;
147386
+ }
147387
+ const commandFile = detectShebang(parsed);
147388
+ const needsShell = !isExecutableRegExp.test(commandFile);
147389
+ if (parsed.options.forceShell || needsShell) {
147390
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
147391
+ parsed.command = path5.normalize(parsed.command);
147392
+ parsed.command = escape2.command(parsed.command);
147393
+ parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
147394
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
147395
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
147396
+ parsed.command = process.env.comspec || "cmd.exe";
147397
+ parsed.options.windowsVerbatimArguments = true;
147398
+ }
147399
+ return parsed;
147400
+ }
147401
+ function parse8(command, args, options3) {
147402
+ if (args && !Array.isArray(args)) {
147403
+ options3 = args;
147404
+ args = null;
147405
+ }
147406
+ args = args ? args.slice(0) : [];
147407
+ options3 = Object.assign({}, options3);
147408
+ const parsed = {
147409
+ command,
147410
+ args,
147411
+ options: options3,
147412
+ file: undefined,
147413
+ original: {
147414
+ command,
147415
+ args
147416
+ }
147417
+ };
147418
+ return options3.shell ? parsed : parseNonShell(parsed);
147419
+ }
147420
+ module3.exports = parse8;
147421
+ });
147422
+
147423
+ // node_modules/cross-spawn/lib/enoent.js
147424
+ var require_enoent = __commonJS((exports, module3) => {
147425
+ var isWin = process.platform === "win32";
147426
+ function notFoundError(original, syscall) {
147427
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
147428
+ code: "ENOENT",
147429
+ errno: "ENOENT",
147430
+ syscall: `${syscall} ${original.command}`,
147431
+ path: original.command,
147432
+ spawnargs: original.args
147433
+ });
147434
+ }
147435
+ function hookChildProcess(cp, parsed) {
147436
+ if (!isWin) {
147437
+ return;
147438
+ }
147439
+ const originalEmit = cp.emit;
147440
+ cp.emit = function(name, arg1) {
147441
+ if (name === "exit") {
147442
+ const err = verifyENOENT(arg1, parsed);
147443
+ if (err) {
147444
+ return originalEmit.call(cp, "error", err);
147445
+ }
147446
+ }
147447
+ return originalEmit.apply(cp, arguments);
147448
+ };
147449
+ }
147450
+ function verifyENOENT(status, parsed) {
147451
+ if (isWin && status === 1 && !parsed.file) {
147452
+ return notFoundError(parsed.original, "spawn");
147453
+ }
147454
+ return null;
147455
+ }
147456
+ function verifyENOENTSync(status, parsed) {
147457
+ if (isWin && status === 1 && !parsed.file) {
147458
+ return notFoundError(parsed.original, "spawnSync");
147459
+ }
147460
+ return null;
147461
+ }
147462
+ module3.exports = {
147463
+ hookChildProcess,
147464
+ verifyENOENT,
147465
+ verifyENOENTSync,
147466
+ notFoundError
147467
+ };
147468
+ });
147469
+
147470
+ // node_modules/cross-spawn/index.js
147471
+ var require_cross_spawn = __commonJS((exports, module3) => {
147472
+ var cp = __require("child_process");
147473
+ var parse8 = require_parse2();
147474
+ var enoent = require_enoent();
147475
+ function spawn(command, args, options3) {
147476
+ const parsed = parse8(command, args, options3);
147477
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
147478
+ enoent.hookChildProcess(spawned, parsed);
147479
+ return spawned;
147480
+ }
147481
+ function spawnSync(command, args, options3) {
147482
+ const parsed = parse8(command, args, options3);
147483
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
147484
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
147485
+ return result;
147486
+ }
147487
+ module3.exports = spawn;
147488
+ module3.exports.spawn = spawn;
147489
+ module3.exports.sync = spawnSync;
147490
+ module3.exports._parse = parse8;
147491
+ module3.exports._enoent = enoent;
147492
+ });
147493
+
147494
+ // src/utils/package-manager-spawn.ts
147495
+ import {
147496
+ spawn
147497
+ } from "node:child_process";
147498
+ function isWindowsCommandShim(command) {
147499
+ return /\.(?:cmd|bat)$/i.test(command);
147500
+ }
147501
+ function getPackageManagerProcessFactory({
147502
+ nativeSpawn = spawn,
147503
+ platform = process.platform,
147504
+ windowsSpawn = import_cross_spawn.default
147505
+ } = {}) {
147506
+ if (platform !== "win32") {
147507
+ return nativeSpawn;
147508
+ }
147509
+ return (command, args, options3) => {
147510
+ const spawnImpl = isWindowsCommandShim(command) ? windowsSpawn : nativeSpawn;
147511
+ return spawnImpl(command, args, options3);
147512
+ };
147513
+ }
147514
+ var import_cross_spawn;
147515
+ var init_package_manager_spawn = __esm(() => {
147516
+ import_cross_spawn = __toESM(require_cross_spawn(), 1);
147517
+ });
147518
+
147036
147519
  // src/channels/runtime-deps.ts
147037
147520
  var exports_runtime_deps = {};
147038
147521
  __export(exports_runtime_deps, {
@@ -147049,7 +147532,6 @@ __export(exports_runtime_deps, {
147049
147532
  __testOverrideChannelRuntimeDeps: () => __testOverrideChannelRuntimeDeps,
147050
147533
  CHANNEL_RUNTIME_ROOT_ENV: () => CHANNEL_RUNTIME_ROOT_ENV
147051
147534
  });
147052
- import { spawn } from "node:child_process";
147053
147535
  import { existsSync as existsSync7 } from "node:fs";
147054
147536
  import { mkdir as mkdir2, symlink, writeFile as writeFile4 } from "node:fs/promises";
147055
147537
  import { createRequire as createRequire2 } from "node:module";
@@ -147182,6 +147664,7 @@ async function installChannelRuntime(channelId) {
147182
147664
  const packageManager = resolveInstallPackageManager();
147183
147665
  const command = getPackageManagerExecutable(packageManager);
147184
147666
  const args = getInstallArgs(packageManager, spec.runtimePackages);
147667
+ const spawnInstallProcess = spawnInstallProcessOverride ?? getPackageManagerProcessFactory({ platform: resolveInstallPlatform() });
147185
147668
  await new Promise((resolve3, reject) => {
147186
147669
  const proc = spawnInstallProcess(command, args, {
147187
147670
  cwd: getChannelRuntimeDir(channelId),
@@ -147224,16 +147707,16 @@ async function loadChannelRuntimeModule(channelId, moduleName) {
147224
147707
  function __testOverrideChannelRuntimeDeps(overrides) {
147225
147708
  userRuntimeRootOverride = overrides?.runtimeRoot ?? null;
147226
147709
  bundledRuntimeRootOverride = overrides ? overrides.bundledRuntimeRoot ?? null : undefined;
147227
- spawnInstallProcess = overrides?.spawnImpl ?? spawn;
147710
+ spawnInstallProcessOverride = overrides?.spawnImpl ?? null;
147228
147711
  packageManagerOverride = overrides?.packageManager ?? null;
147229
147712
  platformOverride = overrides?.platform ?? null;
147230
147713
  }
147231
- var CHANNEL_RUNTIME_ROOT_ENV = "LETTA_CHANNEL_RUNTIME_ROOT", spawnInstallProcess, userRuntimeRootOverride = null, bundledRuntimeRootOverride, packageManagerOverride = null, platformOverride = null;
147714
+ var CHANNEL_RUNTIME_ROOT_ENV = "LETTA_CHANNEL_RUNTIME_ROOT", spawnInstallProcessOverride = null, userRuntimeRootOverride = null, bundledRuntimeRootOverride, packageManagerOverride = null, platformOverride = null;
147232
147715
  var init_runtime_deps = __esm(() => {
147233
147716
  init_auto_update();
147717
+ init_package_manager_spawn();
147234
147718
  init_config2();
147235
147719
  init_plugin_registry();
147236
- spawnInstallProcess = spawn;
147237
147720
  });
147238
147721
 
147239
147722
  // src/channels/telegram/runtime.ts
@@ -173976,7 +174459,7 @@ var init_channel_turn_session = __esm(() => {
173976
174459
  });
173977
174460
 
173978
174461
  // src/websocket/listener/constants.ts
173979
- var MAX_RETRY_DURATION_MS, INITIAL_RETRY_DELAY_MS2 = 1000, MAX_RETRY_DELAY_MS = 30000, LISTENER_HEARTBEAT_INTERVAL_MS = 30000, LISTENER_PONG_TIMEOUT_MS = 90000, SYSTEM_REMINDER_RE, LLM_API_ERROR_MAX_RETRIES = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, MAX_PRE_STREAM_RECOVERY = 2, MAX_POST_STOP_APPROVAL_RECOVERY = 2, PROVIDER_FALLBACK_MAP, PROVIDER_FALLBACK_NOTICE = "Anthropic API error; falling back to Bedrock...";
174462
+ var MAX_RETRY_DURATION_MS, INITIAL_RETRY_DELAY_MS2 = 1000, MAX_RETRY_DELAY_MS = 30000, LISTENER_STREAM_OPEN_TIMEOUT_MS = 30000, LISTENER_HEARTBEAT_INTERVAL_MS = 30000, LISTENER_PONG_TIMEOUT_MS = 90000, SYSTEM_REMINDER_RE, LLM_API_ERROR_MAX_RETRIES = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, MAX_PRE_STREAM_RECOVERY = 2, MAX_POST_STOP_APPROVAL_RECOVERY = 2, PROVIDER_FALLBACK_MAP, PROVIDER_FALLBACK_NOTICE = "Anthropic API error; falling back to Bedrock...";
173980
174463
  var init_constants3 = __esm(() => {
173981
174464
  MAX_RETRY_DURATION_MS = 5 * 60 * 1000;
173982
174465
  SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
@@ -350930,7 +351413,7 @@ var require_scan = __commonJS((exports, module3) => {
350930
351413
  });
350931
351414
 
350932
351415
  // node_modules/picomatch/lib/parse.js
350933
- var require_parse2 = __commonJS((exports, module3) => {
351416
+ var require_parse3 = __commonJS((exports, module3) => {
350934
351417
  var constants3 = require_constants();
350935
351418
  var utils = require_utils3();
350936
351419
  var {
@@ -351711,7 +352194,7 @@ var require_parse2 = __commonJS((exports, module3) => {
351711
352194
  var require_picomatch = __commonJS((exports, module3) => {
351712
352195
  var path27 = __require("path");
351713
352196
  var scan = require_scan();
351714
- var parse8 = require_parse2();
352197
+ var parse8 = require_parse3();
351715
352198
  var utils = require_utils3();
351716
352199
  var constants3 = require_constants();
351717
352200
  var isObject3 = (val) => val && typeof val === "object" && !Array.isArray(val);
@@ -354390,6 +354873,7 @@ var init_client6 = __esm(() => {
354390
354873
  // src/lsp/servers/python.ts
354391
354874
  var PythonServer;
354392
354875
  var init_python = __esm(() => {
354876
+ init_package_manager_spawn();
354393
354877
  PythonServer = {
354394
354878
  id: "python",
354395
354879
  extensions: [".py", ".pyi"],
@@ -354420,11 +354904,12 @@ var init_python = __esm(() => {
354420
354904
  throw new Error("LSP auto-download is disabled. Please install pyright manually: npm install -g pyright");
354421
354905
  }
354422
354906
  console.log("[LSP] Installing pyright...");
354423
- const { spawn: spawn9 } = await import("node:child_process");
354907
+ const platform3 = process.platform;
354908
+ const command = platform3 === "win32" ? "npm.cmd" : "npm";
354909
+ const spawnPackageManager = getPackageManagerProcessFactory({ platform: platform3 });
354424
354910
  return new Promise((resolve20, reject) => {
354425
- const proc = spawn9("npm", ["install", "-g", "pyright"], {
354426
- stdio: "inherit"
354427
- });
354911
+ const proc = spawnPackageManager(command, ["install", "-g", "pyright"], { stdio: "inherit" });
354912
+ proc.on("error", reject);
354428
354913
  proc.on("exit", (code2) => {
354429
354914
  if (code2 === 0) {
354430
354915
  console.log("[LSP] Successfully installed pyright");
@@ -370426,10 +370911,6 @@ async function resolveBaseToolNamesForModel(modelIdentifier, options3) {
370426
370911
  } else {
370427
370912
  baseToolNames = TOOL_NAMES;
370428
370913
  }
370429
- if (options3?.exclude && options3.exclude.length > 0) {
370430
- const excludeSet = new Set(options3.exclude);
370431
- baseToolNames = baseToolNames.filter((name) => !excludeSet.has(name));
370432
- }
370433
370914
  if (options3?.include && options3.include.length > 0) {
370434
370915
  const seen = new Set(baseToolNames);
370435
370916
  for (const name of options3.include) {
@@ -370439,6 +370920,10 @@ async function resolveBaseToolNamesForModel(modelIdentifier, options3) {
370439
370920
  }
370440
370921
  }
370441
370922
  }
370923
+ if (options3?.exclude && options3.exclude.length > 0) {
370924
+ const excludeSet = new Set(options3.exclude);
370925
+ baseToolNames = baseToolNames.filter((name) => !excludeSet.has(name));
370926
+ }
370442
370927
  baseToolNames = filterWorktreeTools(baseToolNames);
370443
370928
  baseToolNames = resolveArtifactToolNames(baseToolNames);
370444
370929
  baseToolNames = maybeAppendChannelTools(baseToolNames, options3?.channelToolScope);
@@ -371630,6 +372115,28 @@ function appendArtifactToolsIfEnabled(toolNames) {
371630
372115
  }
371631
372116
  return [...withoutArtifactTools, ...ARTIFACT_TOOL_NAMES2];
371632
372117
  }
372118
+ function resolveIncludedToolNames(toolNames) {
372119
+ if (!toolNames)
372120
+ return [];
372121
+ return toolNames.map((toolName) => {
372122
+ const internalName = getInternalToolName(toolName);
372123
+ if (!Object.hasOwn(TOOL_DEFINITIONS, internalName)) {
372124
+ throw new Error(`Unknown bundled client tool: ${toolName}`);
372125
+ }
372126
+ return internalName;
372127
+ });
372128
+ }
372129
+ function appendUniqueToolNames(baseToolNames, includedToolNames) {
372130
+ const result = [...baseToolNames];
372131
+ const seen = new Set(result);
372132
+ for (const toolName of includedToolNames) {
372133
+ if (!seen.has(toolName)) {
372134
+ result.push(toolName);
372135
+ seen.add(toolName);
372136
+ }
372137
+ }
372138
+ return result;
372139
+ }
371633
372140
  function deriveToolsetFromModel(modelIdentifier, providerType) {
371634
372141
  if (providerType === "chatgpt_oauth" || providerType === "openai-codex") {
371635
372142
  return "codex";
@@ -371700,6 +372207,7 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
371700
372207
  providerType,
371701
372208
  conversationId,
371702
372209
  toolsetPreference,
372210
+ clientToolset,
371703
372211
  exclude: exclude3,
371704
372212
  clientToolAllowlist,
371705
372213
  externalToolScopeIds,
@@ -371713,7 +372221,9 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
371713
372221
  agent: agent2
371714
372222
  } = params;
371715
372223
  const effectiveModel = modelIdentifier && modelIdentifier.length > 0 ? resolveModel(modelIdentifier) ?? modelIdentifier : null;
371716
- if (toolsetPreference === "auto") {
372224
+ const effectiveToolsetPreference = clientToolset?.base ?? toolsetPreference;
372225
+ const includedToolNames = resolveIncludedToolNames(clientToolset?.include);
372226
+ if (effectiveToolsetPreference === "auto") {
371717
372227
  const derivedToolset = effectiveModel ? deriveToolsetFromModel(effectiveModel, providerType) : "default";
371718
372228
  const scopedModContext2 = buildModInvocationContext({
371719
372229
  agent: agent2,
@@ -371727,6 +372237,7 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
371727
372237
  const modCapabilities2 = mergeModAdapterCapabilities(modAdapters, scopedModContext2);
371728
372238
  const preparedToolContext2 = await prepareToolExecutionContextForModel(effectiveModel ?? undefined, {
371729
372239
  exclude: exclude3,
372240
+ include: includedToolNames,
371730
372241
  clientToolAllowlist,
371731
372242
  externalToolScopeIds,
371732
372243
  workingDirectory,
@@ -371752,11 +372263,11 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
371752
372263
  conversationId,
371753
372264
  modelIdentifier: effectiveModel,
371754
372265
  permissionMode: permissionModeState?.mode ?? runtimeContext?.permissionMode ?? null,
371755
- toolset: toolsetPreference,
372266
+ toolset: effectiveToolsetPreference,
371756
372267
  workingDirectory
371757
372268
  });
371758
372269
  const modCapabilities = mergeModAdapterCapabilities(modAdapters, scopedModContext);
371759
- const preparedToolContext = await prepareToolExecutionContextForSpecificTools(filterBuiltInToolNamesByClientAllowlist(getToolNamesForToolset(toolsetPreference, channelToolScope).filter((toolName) => exclude3 ? !exclude3.includes(toolName) : true), clientToolAllowlist), {
372270
+ const preparedToolContext = await prepareToolExecutionContextForSpecificTools(filterBuiltInToolNamesByClientAllowlist(appendUniqueToolNames(getToolNamesForToolset(effectiveToolsetPreference, channelToolScope), includedToolNames).filter((toolName) => exclude3 ? !exclude3.includes(toolName) : true), clientToolAllowlist), {
371760
372271
  clientToolAllowlist,
371761
372272
  externalToolScopeIds,
371762
372273
  workingDirectory,
@@ -371770,7 +372281,7 @@ async function prepareToolExecutionContextForResolvedTarget(params) {
371770
372281
  });
371771
372282
  return {
371772
372283
  preparedToolContext,
371773
- toolset: toolsetPreference,
372284
+ toolset: effectiveToolsetPreference,
371774
372285
  toolsetPreference,
371775
372286
  effectiveModel,
371776
372287
  agent: null
@@ -371881,6 +372392,7 @@ async function prepareToolExecutionContextForScope(params) {
371881
372392
  overrideProviderType,
371882
372393
  cachedEffectiveModel,
371883
372394
  exclude: exclude3,
372395
+ clientToolset,
371884
372396
  clientToolAllowlist,
371885
372397
  externalToolScopeIds,
371886
372398
  workingDirectory,
@@ -371927,6 +372439,7 @@ async function prepareToolExecutionContextForScope(params) {
371927
372439
  providerType: effectiveProviderType,
371928
372440
  conversationId: conversationId ?? undefined,
371929
372441
  toolsetPreference,
372442
+ clientToolset,
371930
372443
  exclude: exclude3,
371931
372444
  clientToolAllowlist,
371932
372445
  externalToolScopeIds,
@@ -372100,7 +372613,10 @@ var init_toolset = __esm(async () => {
372100
372613
  init_runtime_context();
372101
372614
  init_settings_manager();
372102
372615
  init_filter();
372103
- await init_manager4();
372616
+ await __promiseAll([
372617
+ init_manager4(),
372618
+ init_tool_definitions()
372619
+ ]);
372104
372620
  ARTIFACT_TOOL_NAMES2 = [
372105
372621
  "read_artifact_file",
372106
372622
  "write_artifact_file"
@@ -424009,6 +424525,17 @@ function validateRegistryHandleOrThrow(handle2) {
424009
424525
  }
424010
424526
  }
424011
424527
 
424528
+ // src/cli/startup-mode.ts
424529
+ function isHeadlessStartup(flags, stdinIsTTY, firstPositional) {
424530
+ if (flags.prompt || flags.run) {
424531
+ return true;
424532
+ }
424533
+ if (firstPositional) {
424534
+ return false;
424535
+ }
424536
+ return stdinIsTTY !== true;
424537
+ }
424538
+
424012
424539
  // src/cli/helpers/shared-agent-listing.ts
424013
424540
  function buildListSharedAgentsQuery(params) {
424014
424541
  return {
@@ -446426,6 +446953,11 @@ function isExperimentId(value) {
446426
446953
  function isStringArray6(value) {
446427
446954
  return Array.isArray(value) && value.every((item) => typeof item === "string");
446428
446955
  }
446956
+ function isClientToolsetConfig(value) {
446957
+ if (!isObjectRecord2(value))
446958
+ return false;
446959
+ return (value.base === undefined || typeof value.base === "string" && TOOLSET_PREFERENCES.has(value.base)) && (value.include === undefined || isStringArray6(value.include));
446960
+ }
446429
446961
  function isStringRecord2(value) {
446430
446962
  return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
446431
446963
  }
@@ -446452,7 +446984,7 @@ function isInputCommand(value) {
446452
446984
  }
446453
446985
  const payload = candidate.payload;
446454
446986
  if (payload.kind === "create_message") {
446455
- return Array.isArray(payload.messages) && (payload.client_tool_allowlist === undefined || isStringArray6(payload.client_tool_allowlist)) && (payload.external_tool_scope_ids === undefined || isStringArray6(payload.external_tool_scope_ids)) && (payload.exclude_interactive_tools === undefined || typeof payload.exclude_interactive_tools === "boolean");
446987
+ return Array.isArray(payload.messages) && (payload.client_tool_allowlist === undefined || isStringArray6(payload.client_tool_allowlist)) && (payload.client_toolset === undefined || isClientToolsetConfig(payload.client_toolset)) && (payload.external_tool_scope_ids === undefined || isStringArray6(payload.external_tool_scope_ids)) && (payload.exclude_interactive_tools === undefined || typeof payload.exclude_interactive_tools === "boolean");
446456
446988
  }
446457
446989
  if (payload.kind === "approval_response") {
446458
446990
  return isValidApprovalResponseBody(payload);
@@ -446478,6 +447010,7 @@ function legacyEnvironmentMessageToInputCommand(value) {
446478
447010
  kind: "create_message",
446479
447011
  messages: candidate.messages,
446480
447012
  client_tool_allowlist: isStringArray6(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
447013
+ client_toolset: isClientToolsetConfig(candidate.clientToolset) ? candidate.clientToolset : undefined,
446481
447014
  external_tool_scope_ids: isStringArray6(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
446482
447015
  }
446483
447016
  };
@@ -446510,6 +447043,12 @@ function getInvalidInputReason(value) {
446510
447043
  reason: "Protocol violation: input.payload.client_tool_allowlist must be string[]"
446511
447044
  };
446512
447045
  }
447046
+ if (payload.client_toolset !== undefined && !isClientToolsetConfig(payload.client_toolset)) {
447047
+ return {
447048
+ runtime: candidate.runtime,
447049
+ reason: "Protocol violation: input.payload.client_toolset must contain an optional valid base and string[] include"
447050
+ };
447051
+ }
446513
447052
  if (payload.exclude_interactive_tools !== undefined && typeof payload.exclude_interactive_tools !== "boolean") {
446514
447053
  return {
446515
447054
  runtime: candidate.runtime,
@@ -447222,7 +447761,7 @@ function parseServerMessage(data) {
447222
447761
  return null;
447223
447762
  }
447224
447763
  }
447225
- var EXPERIMENT_IDS, CHANNEL_ACCOUNT_CREATE_FIELDS, CHANNEL_ACCOUNT_UPDATE_FIELDS, CHANNEL_SET_CONFIG_FIELDS;
447764
+ var EXPERIMENT_IDS, TOOLSET_PREFERENCES, CHANNEL_ACCOUNT_CREATE_FIELDS, CHANNEL_ACCOUNT_UPDATE_FIELDS, CHANNEL_SET_CONFIG_FIELDS;
447226
447765
  var init_protocol_inbound = __esm(async () => {
447227
447766
  init_skill_sources();
447228
447767
  init_account_config7();
@@ -447233,6 +447772,15 @@ var init_protocol_inbound = __esm(async () => {
447233
447772
  "desktop_conversation_bootstrap",
447234
447773
  "tui_cron"
447235
447774
  ]);
447775
+ TOOLSET_PREFERENCES = new Set([
447776
+ "auto",
447777
+ "codex",
447778
+ "codex_snake",
447779
+ "default",
447780
+ "gemini",
447781
+ "gemini_snake",
447782
+ "none"
447783
+ ]);
447236
447784
  CHANNEL_ACCOUNT_CREATE_FIELDS = new Set([
447237
447785
  "account_id",
447238
447786
  "display_name",
@@ -459722,6 +460270,7 @@ async function prepareListenerTurn(params) {
459722
460270
  connectionId,
459723
460271
  agentId,
459724
460272
  conversationId,
460273
+ clientToolset: msg.clientToolset,
459725
460274
  clientToolAllowlist: msg.clientToolAllowlist,
459726
460275
  ...msg.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
459727
460276
  externalToolScopeIds: msg.externalToolScopeIds,
@@ -464512,6 +465061,10 @@ function summarizeInputPayload(payload) {
464512
465061
  if (payload.kind === "create_message") {
464513
465062
  pushField(fields, "messages", payload.messages);
464514
465063
  pushField(fields, "client_tool_allowlist", payload.client_tool_allowlist);
465064
+ if (isRecord10(payload.client_toolset)) {
465065
+ pushField(fields, "client_toolset.base", payload.client_toolset.base);
465066
+ pushField(fields, "client_toolset.include", payload.client_toolset.include);
465067
+ }
464515
465068
  pushField(fields, "external_tool_scope_ids", payload.external_tool_scope_ids);
464516
465069
  pushField(fields, "exclude_interactive_tools", payload.exclude_interactive_tools);
464517
465070
  } else if (payload.kind === "approval_response") {
@@ -464798,6 +465351,7 @@ function createListenerMessageHandler(params) {
464798
465351
  agentId: parsed.runtime.agent_id,
464799
465352
  conversationId: parsed.runtime.conversation_id,
464800
465353
  clientToolAllowlist: inputPayload.client_tool_allowlist,
465354
+ clientToolset: inputPayload.client_toolset,
464801
465355
  externalToolScopeIds: inputPayload.external_tool_scope_ids,
464802
465356
  excludeInteractiveTools: inputPayload.exclude_interactive_tools,
464803
465357
  messages: inputPayload.messages
@@ -465197,8 +465751,143 @@ var init_process_services = __esm(async () => {
465197
465751
  ]);
465198
465752
  });
465199
465753
 
465754
+ // src/websocket/listener/split-stream-lifecycle.ts
465755
+ import { WebSocket as WebSocket6 } from "ws";
465756
+ function terminateSocketIfOpenOrConnecting(socket) {
465757
+ if (socket && (socket.readyState === WebSocket6.OPEN || socket.readyState === WebSocket6.CONNECTING)) {
465758
+ socket.terminate();
465759
+ }
465760
+ }
465761
+ function isCurrentSocketPair(runtime, controlSocket, streamSocket) {
465762
+ return runtime === getActiveRuntime() && !runtime.intentionallyClosed && runtime.socket === controlSocket && runtime.streamSocket === streamSocket;
465763
+ }
465764
+ function shouldHandleControlSocketClose(runtime, controlSocket, connectionId) {
465765
+ return runtime === getActiveRuntime() && (runtime.socket === controlSocket || runtime.connections.get(connectionId)?.writer === controlSocket);
465766
+ }
465767
+ function terminateCurrentSocketPair(runtime, controlSocket, streamSocket) {
465768
+ if (!isCurrentSocketPair(runtime, controlSocket, streamSocket)) {
465769
+ return;
465770
+ }
465771
+ runtime.streamTransport = null;
465772
+ terminateSocketIfOpenOrConnecting(streamSocket);
465773
+ terminateSocketIfOpenOrConnecting(controlSocket);
465774
+ }
465775
+ function terminateControlAfterStreamClose(runtime, streamSocket, code2, reason) {
465776
+ if (runtime.streamSocket !== streamSocket) {
465777
+ return;
465778
+ }
465779
+ if (code2 === 1000 && reason.toString() === "Replaced by new connection") {
465780
+ runtime.intentionallyClosed = true;
465781
+ }
465782
+ runtime.streamSocket = null;
465783
+ runtime.streamTransport = null;
465784
+ terminateSocketIfOpenOrConnecting(runtime.socket);
465785
+ }
465786
+ function getStreamOpenTimeoutMs() {
465787
+ const override = process.env.LETTA_LISTENER_STREAM_OPEN_TIMEOUT_MS;
465788
+ if (override !== undefined) {
465789
+ const parsed = Number(override);
465790
+ if (Number.isFinite(parsed) && parsed > 0) {
465791
+ return parsed;
465792
+ }
465793
+ }
465794
+ return LISTENER_STREAM_OPEN_TIMEOUT_MS;
465795
+ }
465796
+ async function waitForStreamSocketOpen(streamSocket) {
465797
+ if (streamSocket.readyState === WebSocket6.OPEN) {
465798
+ return { status: "open", transport: streamSocket };
465799
+ }
465800
+ if (streamSocket.readyState === WebSocket6.CLOSING || streamSocket.readyState === WebSocket6.CLOSED) {
465801
+ return { status: "closed" };
465802
+ }
465803
+ const timeoutMs = getStreamOpenTimeoutMs();
465804
+ return await new Promise((resolve32) => {
465805
+ let timeout = null;
465806
+ let settled = false;
465807
+ function cleanup() {
465808
+ streamSocket.off("open", handleOpen);
465809
+ streamSocket.off("error", handleFailure);
465810
+ streamSocket.off("close", handleFailure);
465811
+ if (timeout) {
465812
+ clearTimeout(timeout);
465813
+ timeout = null;
465814
+ }
465815
+ }
465816
+ function settle(result) {
465817
+ if (settled) {
465818
+ return;
465819
+ }
465820
+ settled = true;
465821
+ cleanup();
465822
+ resolve32(result);
465823
+ }
465824
+ function handleOpen() {
465825
+ settle({ status: "open", transport: streamSocket });
465826
+ }
465827
+ function handleFailure() {
465828
+ settle({ status: "closed" });
465829
+ }
465830
+ timeout = setTimeout(() => {
465831
+ settle({ status: "timed_out", timeoutMs });
465832
+ }, timeoutMs);
465833
+ timeout.unref?.();
465834
+ streamSocket.once("open", handleOpen);
465835
+ streamSocket.once("error", handleFailure);
465836
+ streamSocket.once("close", handleFailure);
465837
+ });
465838
+ }
465839
+ async function prepareSplitStreamTransport({
465840
+ runtime,
465841
+ controlSocket,
465842
+ streamSocket,
465843
+ trackListenerError: trackListenerError4
465844
+ }) {
465845
+ if (!isCurrentSocketPair(runtime, controlSocket, streamSocket)) {
465846
+ return { kind: "stale" };
465847
+ }
465848
+ if (!streamSocket) {
465849
+ return { kind: "ready", transport: null };
465850
+ }
465851
+ const result = await waitForStreamSocketOpen(streamSocket);
465852
+ if (!isCurrentSocketPair(runtime, controlSocket, streamSocket)) {
465853
+ return { kind: "stale" };
465854
+ }
465855
+ if (result.status !== "open") {
465856
+ const message = result.status === "timed_out" ? `Stream WebSocket did not open within ${result.timeoutMs}ms; reconnecting paired listener sockets` : "Stream WebSocket closed before the paired listener sockets finished opening; reconnecting paired listener sockets";
465857
+ trackListenerError4(result.status === "timed_out" ? "listener_stream_open_timeout" : "listener_stream_open_failed", new Error(message), "listener_stream_socket_open");
465858
+ if (isDebugEnabled()) {
465859
+ console.error(`[Listen] ${message}`);
465860
+ }
465861
+ terminateCurrentSocketPair(runtime, controlSocket, streamSocket);
465862
+ return { kind: "stale" };
465863
+ }
465864
+ runtime.streamTransport = result.transport;
465865
+ return { kind: "ready", transport: result.transport };
465866
+ }
465867
+ function handleListenerSocketOpenFailure({
465868
+ runtime,
465869
+ controlSocket,
465870
+ streamSocket,
465871
+ error: error54,
465872
+ trackListenerError: trackListenerError4
465873
+ }) {
465874
+ if (!isCurrentSocketPair(runtime, controlSocket, streamSocket)) {
465875
+ return;
465876
+ }
465877
+ trackListenerError4("listener_open_handler_failed", error54, "listener_socket_open");
465878
+ if (isDebugEnabled()) {
465879
+ console.error("[Listen] WebSocket open handler failed:", error54);
465880
+ }
465881
+ terminateCurrentSocketPair(runtime, controlSocket, streamSocket);
465882
+ }
465883
+ var init_split_stream_lifecycle = __esm(() => {
465884
+ init_debug();
465885
+ init_constants3();
465886
+ init_runtime6();
465887
+ });
465888
+
465200
465889
  // src/websocket/listener/lifecycle.ts
465201
- import WebSocket6 from "ws";
465890
+ import WebSocket7 from "ws";
465202
465891
  function trackListenerError4(errorType, error54, context3) {
465203
465892
  trackBoundaryError({
465204
465893
  errorType,
@@ -465207,7 +465896,7 @@ function trackListenerError4(errorType, error54, context3) {
465207
465896
  });
465208
465897
  }
465209
465898
  function safeSocketSend(socket, payload, errorType, context3) {
465210
- if (socket.readyState !== WebSocket6.OPEN) {
465899
+ if (socket.readyState !== WebSocket7.OPEN) {
465211
465900
  return false;
465212
465901
  }
465213
465902
  try {
@@ -465344,48 +466033,6 @@ function getParsedRuntimeScope(parsed) {
465344
466033
  conversation_id: typeof runtime.conversation_id === "string" ? runtime.conversation_id : "default"
465345
466034
  };
465346
466035
  }
465347
- function terminateControlAfterStreamClose(runtime, streamSocket, code2, reason) {
465348
- if (runtime.streamSocket !== streamSocket) {
465349
- return;
465350
- }
465351
- if (code2 === 1000 && reason.toString() === "Replaced by new connection") {
465352
- runtime.intentionallyClosed = true;
465353
- }
465354
- runtime.streamSocket = null;
465355
- runtime.streamTransport = null;
465356
- const controlSocket = runtime.socket;
465357
- if (controlSocket && (controlSocket.readyState === WebSocket6.OPEN || controlSocket.readyState === WebSocket6.CONNECTING)) {
465358
- controlSocket.terminate();
465359
- }
465360
- }
465361
- async function waitForStreamSocketOpen(streamSocket, runtime) {
465362
- if (streamSocket.readyState === WebSocket6.OPEN) {
465363
- runtime.streamTransport = streamSocket;
465364
- return streamSocket;
465365
- }
465366
- if (streamSocket.readyState === WebSocket6.CLOSING || streamSocket.readyState === WebSocket6.CLOSED) {
465367
- return null;
465368
- }
465369
- return await new Promise((resolve32) => {
465370
- const handleOpen = () => {
465371
- cleanup();
465372
- runtime.streamTransport = streamSocket;
465373
- resolve32(streamSocket);
465374
- };
465375
- const handleFailure = () => {
465376
- cleanup();
465377
- resolve32(null);
465378
- };
465379
- const cleanup = () => {
465380
- streamSocket.off("open", handleOpen);
465381
- streamSocket.off("error", handleFailure);
465382
- streamSocket.off("close", handleFailure);
465383
- };
465384
- streamSocket.once("open", handleOpen);
465385
- streamSocket.once("error", handleFailure);
465386
- streamSocket.once("close", handleFailure);
465387
- });
465388
- }
465389
466036
  async function wireChannelIngress(listener, socket, opts, processQueuedTurn) {
465390
466037
  const registry2 = getChannelRegistry();
465391
466038
  if (!registry2)
@@ -465867,7 +466514,7 @@ async function attachOpenListenerSocket(runtime, socket, opts, options3 = {}) {
465867
466514
  });
465868
466515
  });
465869
466516
  socket.on("close", (code2, reason) => {
465870
- if (runtime !== getActiveRuntime()) {
466517
+ if (runtime !== getActiveRuntime() || runtime.connections.get(opts.connectionId) !== connection) {
465871
466518
  return;
465872
466519
  }
465873
466520
  const reasonText = reason.toString();
@@ -465908,7 +466555,7 @@ async function attachOpenListenerSocket(runtime, socket, opts, options3 = {}) {
465908
466555
  if (connection.cancellation.signal.aborted || runtime.connections.get(opts.connectionId) !== connection) {
465909
466556
  return;
465910
466557
  }
465911
- const streamTransport = streamSocket?.readyState === WebSocket6.OPEN ? streamSocket : null;
466558
+ const streamTransport = streamSocket?.readyState === WebSocket7.OPEN ? streamSocket : null;
465912
466559
  await startConnectedListenerRuntime(runtime, transport, opts, processQueuedTurn, {
465913
466560
  startHeartbeat: options3.startHeartbeat ?? false,
465914
466561
  startCronScheduler: options3.startCronScheduler ?? true,
@@ -466018,12 +466665,12 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
466018
466665
  streamUrl.searchParams.set("connectionName", opts.connectionName);
466019
466666
  streamUrl.searchParams.set("channel", "stream");
466020
466667
  }
466021
- const socket = new WebSocket6(url2.toString(), {
466668
+ const socket = new WebSocket7(url2.toString(), {
466022
466669
  headers: {
466023
466670
  Authorization: `Bearer ${apiKey}`
466024
466671
  }
466025
466672
  });
466026
- const streamSocket = streamUrl ? new WebSocket6(streamUrl.toString(), {
466673
+ const streamSocket = streamUrl ? new WebSocket7(streamUrl.toString(), {
466027
466674
  headers: {
466028
466675
  Authorization: `Bearer ${apiKey}`
466029
466676
  }
@@ -466037,22 +466684,41 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
466037
466684
  runtime.streamSocket = streamSocket;
466038
466685
  const transport = socket;
466039
466686
  const processQueuedTurn = createConnectionTurnProcessor(runtime);
466040
- socket.on("open", async () => {
466041
- let streamTransport = null;
466042
- if (streamSocket) {
466043
- streamTransport = await waitForStreamSocketOpen(streamSocket, runtime);
466044
- }
466045
- openListenerConnection({
466046
- runtime,
466047
- connectionId: opts.connectionId,
466048
- writer: socket,
466049
- streamWriter: streamTransport,
466050
- options: opts
466051
- });
466052
- await startConnectedListenerRuntime(runtime, transport, opts, processQueuedTurn, {
466053
- startHeartbeat: true,
466054
- startCronScheduler: true,
466055
- streamTransport
466687
+ socket.on("open", () => {
466688
+ (async () => {
466689
+ const streamOpen = await prepareSplitStreamTransport({
466690
+ runtime,
466691
+ controlSocket: socket,
466692
+ streamSocket,
466693
+ trackListenerError: trackListenerError4
466694
+ });
466695
+ if (streamOpen.kind !== "ready") {
466696
+ return;
466697
+ }
466698
+ const streamTransport = streamOpen.transport;
466699
+ if (!isCurrentSocketPair(runtime, socket, streamSocket)) {
466700
+ return;
466701
+ }
466702
+ openListenerConnection({
466703
+ runtime,
466704
+ connectionId: opts.connectionId,
466705
+ writer: socket,
466706
+ streamWriter: streamTransport,
466707
+ options: opts
466708
+ });
466709
+ await startConnectedListenerRuntime(runtime, transport, opts, processQueuedTurn, {
466710
+ startHeartbeat: true,
466711
+ startCronScheduler: true,
466712
+ streamTransport
466713
+ });
466714
+ })().catch((error54) => {
466715
+ handleListenerSocketOpenFailure({
466716
+ runtime,
466717
+ controlSocket: socket,
466718
+ streamSocket,
466719
+ error: error54,
466720
+ trackListenerError: trackListenerError4
466721
+ });
466056
466722
  });
466057
466723
  });
466058
466724
  socket.on("message", createListenerMessageHandler({
@@ -466075,7 +466741,7 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
466075
466741
  wireChannelIngress
466076
466742
  }));
466077
466743
  socket.on("close", (code2, reason) => {
466078
- if (runtime !== getActiveRuntime()) {
466744
+ if (!shouldHandleControlSocketClose(runtime, socket, opts.connectionId)) {
466079
466745
  return;
466080
466746
  }
466081
466747
  safeEmitWsEvent("recv", "lifecycle", {
@@ -466100,7 +466766,7 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
466100
466766
  clearListenerWarmState(runtime);
466101
466767
  if (streamSocket) {
466102
466768
  streamSocket.removeAllListeners();
466103
- if (streamSocket.readyState === WebSocket6.OPEN || streamSocket.readyState === WebSocket6.CONNECTING) {
466769
+ if (streamSocket.readyState === WebSocket7.OPEN || streamSocket.readyState === WebSocket7.CONNECTING) {
466104
466770
  streamSocket.close();
466105
466771
  }
466106
466772
  }
@@ -466190,6 +466856,7 @@ var init_lifecycle = __esm(async () => {
466190
466856
  init_heartbeat();
466191
466857
  init_permission_mode();
466192
466858
  init_runtime6();
466859
+ init_split_stream_lifecycle();
466193
466860
  init_transport();
466194
466861
  await __promiseAll([
466195
466862
  init_scheduler(),
@@ -468718,9 +469385,7 @@ var init_messages10 = __esm(() => {
468718
469385
  });
468719
469386
 
468720
469387
  // src/mods/package-installer.ts
468721
- import {
468722
- spawn as spawn13
468723
- } from "node:child_process";
469388
+ import { spawn as spawn13 } from "node:child_process";
468724
469389
  import {
468725
469390
  copyFileSync as copyFileSync4,
468726
469391
  existsSync as existsSync56,
@@ -469113,7 +469778,9 @@ async function runNpmInstall(params) {
469113
469778
  args: getNpmInstallArgs(params.installSpec),
469114
469779
  command: getNpmExecutable(),
469115
469780
  cwd: params.tempRoot,
469116
- spawnImpl: spawnNpmInstallProcess
469781
+ spawnImpl: spawnNpmInstallProcessOverride ?? getPackageManagerProcessFactory({
469782
+ platform: platformOverride2 ?? process.platform
469783
+ })
469117
469784
  });
469118
469785
  } catch (error54) {
469119
469786
  const message = error54 instanceof Error ? error54.message : String(error54);
@@ -469569,13 +470236,13 @@ async function updateGitManagedModPackage(params) {
469569
470236
  rmSync13(tempRoot, { force: true, recursive: true });
469570
470237
  }
469571
470238
  }
469572
- var SKIPPED_PACKAGE_COPY_NAMES, spawnNpmInstallProcess, spawnGitInstallProcess, platformOverride2 = null;
470239
+ var SKIPPED_PACKAGE_COPY_NAMES, spawnNpmInstallProcessOverride = null, spawnGitInstallProcess, platformOverride2 = null;
469573
470240
  var init_package_installer = __esm(() => {
469574
470241
  init_file_extensions();
469575
470242
  init_package_manifest();
469576
470243
  init_package_registry();
470244
+ init_package_manager_spawn();
469577
470245
  SKIPPED_PACKAGE_COPY_NAMES = new Set([".git", "node_modules"]);
469578
- spawnNpmInstallProcess = spawn13;
469579
470246
  spawnGitInstallProcess = spawn13;
469580
470247
  });
469581
470248
 
@@ -471781,7 +472448,7 @@ var init_app_server_openai = __esm(async () => {
471781
472448
  // src/websocket/app-server.ts
471782
472449
  import { createServer as createServer2 } from "node:http";
471783
472450
  import { hostname as hostname6 } from "node:os";
471784
- import WebSocket7, { WebSocketServer } from "ws";
472451
+ import WebSocket8, { WebSocketServer } from "ws";
471785
472452
  function getRequiredAddressInfo(server2) {
471786
472453
  const address = server2.address();
471787
472454
  if (!address || typeof address === "string") {
@@ -471797,12 +472464,12 @@ function getWebSocketUrl(baseUrl, path43) {
471797
472464
  function closeSocket(socket, code2 = 1001, reason = "closing") {
471798
472465
  if (!socket)
471799
472466
  return;
471800
- if (socket.readyState === WebSocket7.OPEN || socket.readyState === WebSocket7.CONNECTING) {
472467
+ if (socket.readyState === WebSocket8.OPEN || socket.readyState === WebSocket8.CONNECTING) {
471801
472468
  socket.close(code2, reason);
471802
472469
  }
471803
472470
  }
471804
472471
  function terminateSocket(socket) {
471805
- if (!socket || socket.readyState === WebSocket7.CLOSED)
472472
+ if (!socket || socket.readyState === WebSocket8.CLOSED)
471806
472473
  return;
471807
472474
  socket.terminate();
471808
472475
  }
@@ -471980,7 +472647,7 @@ async function startAppServer(options3 = {}) {
471980
472647
  client.terminate();
471981
472648
  continue;
471982
472649
  }
471983
- if (client.readyState === WebSocket7.OPEN) {
472650
+ if (client.readyState === WebSocket8.OPEN) {
471984
472651
  client.ping();
471985
472652
  }
471986
472653
  }
@@ -473019,6 +473686,12 @@ function truncateAgentId(id2, availableWidth) {
473019
473686
  const suffixLen = availableWidth - 3 - prefixLen;
473020
473687
  return `${id2.slice(0, prefixLen)}...${id2.slice(-suffixLen)}`;
473021
473688
  }
473689
+ function formatAgentMemoryBlockCount(blockCount) {
473690
+ if (blockCount === null || blockCount === undefined || blockCount <= 0) {
473691
+ return null;
473692
+ }
473693
+ return `${blockCount} memory block${blockCount === 1 ? "" : "s"}`;
473694
+ }
473022
473695
  function formatAgentModel(agent2) {
473023
473696
  let handle2 = null;
473024
473697
  if (agent2.model) {
@@ -473808,11 +474481,13 @@ function AgentSelector({
473808
474481
  const isCurrent = agent2.id === currentAgentId;
473809
474482
  const isLocalAgent2 = isLocalAgentId(agent2.id);
473810
474483
  const relativeTime = formatRelativeTime3(agent2.last_run_completion);
473811
- const blockCount = agent2.blocks?.length ?? 0;
474484
+ const blockCountText = formatAgentMemoryBlockCount(agent2.blocks?.length);
473812
474485
  const modelStr = formatAgentModel(agent2);
473813
474486
  const metadataParts = [relativeTime];
473814
474487
  if (!isLocalAgent2 && extra?.backend !== "shared") {
473815
- metadataParts.push(`${blockCount} memory block${blockCount === 1 ? "" : "s"}`);
474488
+ if (blockCountText) {
474489
+ metadataParts.push(blockCountText);
474490
+ }
473816
474491
  metadataParts.push(modelStr);
473817
474492
  }
473818
474493
  if (extra?.backend === "shared" && agent2.creator?.name) {
@@ -486998,462 +487673,6 @@ var init_sse = __esm(() => {
486998
487673
  };
486999
487674
  });
487000
487675
 
487001
- // node_modules/isexe/windows.js
487002
- var require_windows = __commonJS((exports, module3) => {
487003
- module3.exports = isexe;
487004
- isexe.sync = sync2;
487005
- var fs15 = __require("fs");
487006
- function checkPathExt(path43, options3) {
487007
- var pathext = options3.pathExt !== undefined ? options3.pathExt : process.env.PATHEXT;
487008
- if (!pathext) {
487009
- return true;
487010
- }
487011
- pathext = pathext.split(";");
487012
- if (pathext.indexOf("") !== -1) {
487013
- return true;
487014
- }
487015
- for (var i4 = 0;i4 < pathext.length; i4++) {
487016
- var p2 = pathext[i4].toLowerCase();
487017
- if (p2 && path43.substr(-p2.length).toLowerCase() === p2) {
487018
- return true;
487019
- }
487020
- }
487021
- return false;
487022
- }
487023
- function checkStat(stat17, path43, options3) {
487024
- if (!stat17.isSymbolicLink() && !stat17.isFile()) {
487025
- return false;
487026
- }
487027
- return checkPathExt(path43, options3);
487028
- }
487029
- function isexe(path43, options3, cb) {
487030
- fs15.stat(path43, function(er, stat17) {
487031
- cb(er, er ? false : checkStat(stat17, path43, options3));
487032
- });
487033
- }
487034
- function sync2(path43, options3) {
487035
- return checkStat(fs15.statSync(path43), path43, options3);
487036
- }
487037
- });
487038
-
487039
- // node_modules/isexe/mode.js
487040
- var require_mode = __commonJS((exports, module3) => {
487041
- module3.exports = isexe;
487042
- isexe.sync = sync2;
487043
- var fs15 = __require("fs");
487044
- function isexe(path43, options3, cb) {
487045
- fs15.stat(path43, function(er, stat17) {
487046
- cb(er, er ? false : checkStat(stat17, options3));
487047
- });
487048
- }
487049
- function sync2(path43, options3) {
487050
- return checkStat(fs15.statSync(path43), options3);
487051
- }
487052
- function checkStat(stat17, options3) {
487053
- return stat17.isFile() && checkMode(stat17, options3);
487054
- }
487055
- function checkMode(stat17, options3) {
487056
- var mod = stat17.mode;
487057
- var uid = stat17.uid;
487058
- var gid = stat17.gid;
487059
- var myUid = options3.uid !== undefined ? options3.uid : process.getuid && process.getuid();
487060
- var myGid = options3.gid !== undefined ? options3.gid : process.getgid && process.getgid();
487061
- var u2 = parseInt("100", 8);
487062
- var g = parseInt("010", 8);
487063
- var o3 = parseInt("001", 8);
487064
- var ug = u2 | g;
487065
- var ret = mod & o3 || mod & g && gid === myGid || mod & u2 && uid === myUid || mod & ug && myUid === 0;
487066
- return ret;
487067
- }
487068
- });
487069
-
487070
- // node_modules/isexe/index.js
487071
- var require_isexe = __commonJS((exports, module3) => {
487072
- var fs15 = __require("fs");
487073
- var core4;
487074
- if (process.platform === "win32" || global.TESTING_WINDOWS) {
487075
- core4 = require_windows();
487076
- } else {
487077
- core4 = require_mode();
487078
- }
487079
- module3.exports = isexe;
487080
- isexe.sync = sync2;
487081
- function isexe(path43, options3, cb) {
487082
- if (typeof options3 === "function") {
487083
- cb = options3;
487084
- options3 = {};
487085
- }
487086
- if (!cb) {
487087
- if (typeof Promise !== "function") {
487088
- throw new TypeError("callback not provided");
487089
- }
487090
- return new Promise(function(resolve34, reject) {
487091
- isexe(path43, options3 || {}, function(er, is) {
487092
- if (er) {
487093
- reject(er);
487094
- } else {
487095
- resolve34(is);
487096
- }
487097
- });
487098
- });
487099
- }
487100
- core4(path43, options3 || {}, function(er, is) {
487101
- if (er) {
487102
- if (er.code === "EACCES" || options3 && options3.ignoreErrors) {
487103
- er = null;
487104
- is = false;
487105
- }
487106
- }
487107
- cb(er, is);
487108
- });
487109
- }
487110
- function sync2(path43, options3) {
487111
- try {
487112
- return core4.sync(path43, options3 || {});
487113
- } catch (er) {
487114
- if (options3 && options3.ignoreErrors || er.code === "EACCES") {
487115
- return false;
487116
- } else {
487117
- throw er;
487118
- }
487119
- }
487120
- }
487121
- });
487122
-
487123
- // node_modules/which/which.js
487124
- var require_which = __commonJS((exports, module3) => {
487125
- var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
487126
- var path43 = __require("path");
487127
- var COLON2 = isWindows3 ? ";" : ":";
487128
- var isexe = require_isexe();
487129
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
487130
- var getPathInfo = (cmd, opt) => {
487131
- const colon = opt.colon || COLON2;
487132
- const pathEnv = cmd.match(/\//) || isWindows3 && cmd.match(/\\/) ? [""] : [
487133
- ...isWindows3 ? [process.cwd()] : [],
487134
- ...(opt.path || process.env.PATH || "").split(colon)
487135
- ];
487136
- const pathExtExe = isWindows3 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
487137
- const pathExt = isWindows3 ? pathExtExe.split(colon) : [""];
487138
- if (isWindows3) {
487139
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
487140
- pathExt.unshift("");
487141
- }
487142
- return {
487143
- pathEnv,
487144
- pathExt,
487145
- pathExtExe
487146
- };
487147
- };
487148
- var which = (cmd, opt, cb) => {
487149
- if (typeof opt === "function") {
487150
- cb = opt;
487151
- opt = {};
487152
- }
487153
- if (!opt)
487154
- opt = {};
487155
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
487156
- const found = [];
487157
- const step = (i4) => new Promise((resolve34, reject) => {
487158
- if (i4 === pathEnv.length)
487159
- return opt.all && found.length ? resolve34(found) : reject(getNotFoundError(cmd));
487160
- const ppRaw = pathEnv[i4];
487161
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
487162
- const pCmd = path43.join(pathPart, cmd);
487163
- const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
487164
- resolve34(subStep(p2, i4, 0));
487165
- });
487166
- const subStep = (p2, i4, ii) => new Promise((resolve34, reject) => {
487167
- if (ii === pathExt.length)
487168
- return resolve34(step(i4 + 1));
487169
- const ext3 = pathExt[ii];
487170
- isexe(p2 + ext3, { pathExt: pathExtExe }, (er, is) => {
487171
- if (!er && is) {
487172
- if (opt.all)
487173
- found.push(p2 + ext3);
487174
- else
487175
- return resolve34(p2 + ext3);
487176
- }
487177
- return resolve34(subStep(p2, i4, ii + 1));
487178
- });
487179
- });
487180
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
487181
- };
487182
- var whichSync = (cmd, opt) => {
487183
- opt = opt || {};
487184
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
487185
- const found = [];
487186
- for (let i4 = 0;i4 < pathEnv.length; i4++) {
487187
- const ppRaw = pathEnv[i4];
487188
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
487189
- const pCmd = path43.join(pathPart, cmd);
487190
- const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
487191
- for (let j2 = 0;j2 < pathExt.length; j2++) {
487192
- const cur = p2 + pathExt[j2];
487193
- try {
487194
- const is = isexe.sync(cur, { pathExt: pathExtExe });
487195
- if (is) {
487196
- if (opt.all)
487197
- found.push(cur);
487198
- else
487199
- return cur;
487200
- }
487201
- } catch (ex) {}
487202
- }
487203
- }
487204
- if (opt.all && found.length)
487205
- return found;
487206
- if (opt.nothrow)
487207
- return null;
487208
- throw getNotFoundError(cmd);
487209
- };
487210
- module3.exports = which;
487211
- which.sync = whichSync;
487212
- });
487213
-
487214
- // node_modules/path-key/index.js
487215
- var require_path_key = __commonJS((exports, module3) => {
487216
- var pathKey = (options3 = {}) => {
487217
- const environment2 = options3.env || process.env;
487218
- const platform10 = options3.platform || process.platform;
487219
- if (platform10 !== "win32") {
487220
- return "PATH";
487221
- }
487222
- return Object.keys(environment2).reverse().find((key2) => key2.toUpperCase() === "PATH") || "Path";
487223
- };
487224
- module3.exports = pathKey;
487225
- module3.exports.default = pathKey;
487226
- });
487227
-
487228
- // node_modules/cross-spawn/lib/util/resolveCommand.js
487229
- var require_resolveCommand = __commonJS((exports, module3) => {
487230
- var path43 = __require("path");
487231
- var which = require_which();
487232
- var getPathKey = require_path_key();
487233
- function resolveCommandAttempt(parsed, withoutPathExt) {
487234
- const env5 = parsed.options.env || process.env;
487235
- const cwd2 = process.cwd();
487236
- const hasCustomCwd = parsed.options.cwd != null;
487237
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
487238
- if (shouldSwitchCwd) {
487239
- try {
487240
- process.chdir(parsed.options.cwd);
487241
- } catch (err) {}
487242
- }
487243
- let resolved;
487244
- try {
487245
- resolved = which.sync(parsed.command, {
487246
- path: env5[getPathKey({ env: env5 })],
487247
- pathExt: withoutPathExt ? path43.delimiter : undefined
487248
- });
487249
- } catch (e2) {} finally {
487250
- if (shouldSwitchCwd) {
487251
- process.chdir(cwd2);
487252
- }
487253
- }
487254
- if (resolved) {
487255
- resolved = path43.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
487256
- }
487257
- return resolved;
487258
- }
487259
- function resolveCommand(parsed) {
487260
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
487261
- }
487262
- module3.exports = resolveCommand;
487263
- });
487264
-
487265
- // node_modules/cross-spawn/lib/util/escape.js
487266
- var require_escape = __commonJS((exports, module3) => {
487267
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
487268
- function escapeCommand(arg) {
487269
- arg = arg.replace(metaCharsRegExp, "^$1");
487270
- return arg;
487271
- }
487272
- function escapeArgument(arg, doubleEscapeMetaChars) {
487273
- arg = `${arg}`;
487274
- arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
487275
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
487276
- arg = `"${arg}"`;
487277
- arg = arg.replace(metaCharsRegExp, "^$1");
487278
- if (doubleEscapeMetaChars) {
487279
- arg = arg.replace(metaCharsRegExp, "^$1");
487280
- }
487281
- return arg;
487282
- }
487283
- exports.command = escapeCommand;
487284
- exports.argument = escapeArgument;
487285
- });
487286
-
487287
- // node_modules/shebang-regex/index.js
487288
- var require_shebang_regex = __commonJS((exports, module3) => {
487289
- module3.exports = /^#!(.*)/;
487290
- });
487291
-
487292
- // node_modules/shebang-command/index.js
487293
- var require_shebang_command = __commonJS((exports, module3) => {
487294
- var shebangRegex = require_shebang_regex();
487295
- module3.exports = (string7 = "") => {
487296
- const match4 = string7.match(shebangRegex);
487297
- if (!match4) {
487298
- return null;
487299
- }
487300
- const [path43, argument] = match4[0].replace(/#! ?/, "").split(" ");
487301
- const binary = path43.split("/").pop();
487302
- if (binary === "env") {
487303
- return argument;
487304
- }
487305
- return argument ? `${binary} ${argument}` : binary;
487306
- };
487307
- });
487308
-
487309
- // node_modules/cross-spawn/lib/util/readShebang.js
487310
- var require_readShebang = __commonJS((exports, module3) => {
487311
- var fs15 = __require("fs");
487312
- var shebangCommand = require_shebang_command();
487313
- function readShebang(command) {
487314
- const size = 150;
487315
- const buffer = Buffer.alloc(size);
487316
- let fd;
487317
- try {
487318
- fd = fs15.openSync(command, "r");
487319
- fs15.readSync(fd, buffer, 0, size, 0);
487320
- fs15.closeSync(fd);
487321
- } catch (e2) {}
487322
- return shebangCommand(buffer.toString());
487323
- }
487324
- module3.exports = readShebang;
487325
- });
487326
-
487327
- // node_modules/cross-spawn/lib/parse.js
487328
- var require_parse3 = __commonJS((exports, module3) => {
487329
- var path43 = __require("path");
487330
- var resolveCommand = require_resolveCommand();
487331
- var escape4 = require_escape();
487332
- var readShebang = require_readShebang();
487333
- var isWin2 = process.platform === "win32";
487334
- var isExecutableRegExp = /\.(?:com|exe)$/i;
487335
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
487336
- function detectShebang(parsed) {
487337
- parsed.file = resolveCommand(parsed);
487338
- const shebang = parsed.file && readShebang(parsed.file);
487339
- if (shebang) {
487340
- parsed.args.unshift(parsed.file);
487341
- parsed.command = shebang;
487342
- return resolveCommand(parsed);
487343
- }
487344
- return parsed.file;
487345
- }
487346
- function parseNonShell(parsed) {
487347
- if (!isWin2) {
487348
- return parsed;
487349
- }
487350
- const commandFile = detectShebang(parsed);
487351
- const needsShell = !isExecutableRegExp.test(commandFile);
487352
- if (parsed.options.forceShell || needsShell) {
487353
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
487354
- parsed.command = path43.normalize(parsed.command);
487355
- parsed.command = escape4.command(parsed.command);
487356
- parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
487357
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
487358
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
487359
- parsed.command = process.env.comspec || "cmd.exe";
487360
- parsed.options.windowsVerbatimArguments = true;
487361
- }
487362
- return parsed;
487363
- }
487364
- function parse9(command, args, options3) {
487365
- if (args && !Array.isArray(args)) {
487366
- options3 = args;
487367
- args = null;
487368
- }
487369
- args = args ? args.slice(0) : [];
487370
- options3 = Object.assign({}, options3);
487371
- const parsed = {
487372
- command,
487373
- args,
487374
- options: options3,
487375
- file: undefined,
487376
- original: {
487377
- command,
487378
- args
487379
- }
487380
- };
487381
- return options3.shell ? parsed : parseNonShell(parsed);
487382
- }
487383
- module3.exports = parse9;
487384
- });
487385
-
487386
- // node_modules/cross-spawn/lib/enoent.js
487387
- var require_enoent = __commonJS((exports, module3) => {
487388
- var isWin2 = process.platform === "win32";
487389
- function notFoundError(original, syscall) {
487390
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
487391
- code: "ENOENT",
487392
- errno: "ENOENT",
487393
- syscall: `${syscall} ${original.command}`,
487394
- path: original.command,
487395
- spawnargs: original.args
487396
- });
487397
- }
487398
- function hookChildProcess(cp2, parsed) {
487399
- if (!isWin2) {
487400
- return;
487401
- }
487402
- const originalEmit = cp2.emit;
487403
- cp2.emit = function(name, arg1) {
487404
- if (name === "exit") {
487405
- const err = verifyENOENT(arg1, parsed);
487406
- if (err) {
487407
- return originalEmit.call(cp2, "error", err);
487408
- }
487409
- }
487410
- return originalEmit.apply(cp2, arguments);
487411
- };
487412
- }
487413
- function verifyENOENT(status, parsed) {
487414
- if (isWin2 && status === 1 && !parsed.file) {
487415
- return notFoundError(parsed.original, "spawn");
487416
- }
487417
- return null;
487418
- }
487419
- function verifyENOENTSync(status, parsed) {
487420
- if (isWin2 && status === 1 && !parsed.file) {
487421
- return notFoundError(parsed.original, "spawnSync");
487422
- }
487423
- return null;
487424
- }
487425
- module3.exports = {
487426
- hookChildProcess,
487427
- verifyENOENT,
487428
- verifyENOENTSync,
487429
- notFoundError
487430
- };
487431
- });
487432
-
487433
- // node_modules/cross-spawn/index.js
487434
- var require_cross_spawn = __commonJS((exports, module3) => {
487435
- var cp2 = __require("child_process");
487436
- var parse9 = require_parse3();
487437
- var enoent = require_enoent();
487438
- function spawn14(command, args, options3) {
487439
- const parsed = parse9(command, args, options3);
487440
- const spawned = cp2.spawn(parsed.command, parsed.args, parsed.options);
487441
- enoent.hookChildProcess(spawned, parsed);
487442
- return spawned;
487443
- }
487444
- function spawnSync4(command, args, options3) {
487445
- const parsed = parse9(command, args, options3);
487446
- const result = cp2.spawnSync(parsed.command, parsed.args, parsed.options);
487447
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
487448
- return result;
487449
- }
487450
- module3.exports = spawn14;
487451
- module3.exports.spawn = spawn14;
487452
- module3.exports.sync = spawnSync4;
487453
- module3.exports._parse = parse9;
487454
- module3.exports._enoent = enoent;
487455
- });
487456
-
487457
487676
  // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
487458
487677
  class ReadBuffer {
487459
487678
  constructor(options3) {
@@ -487529,7 +487748,7 @@ class StdioClientTransport {
487529
487748
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
487530
487749
  }
487531
487750
  return new Promise((resolve34, reject) => {
487532
- this._process = import_cross_spawn.default(this._serverParams.command, this._serverParams.args ?? [], {
487751
+ this._process = import_cross_spawn2.default(this._serverParams.command, this._serverParams.args ?? [], {
487533
487752
  env: {
487534
487753
  ...getDefaultEnvironment(),
487535
487754
  ...this._serverParams.env
@@ -487633,10 +487852,10 @@ class StdioClientTransport {
487633
487852
  });
487634
487853
  }
487635
487854
  }
487636
- var import_cross_spawn, DEFAULT_INHERITED_ENV_VARS;
487855
+ var import_cross_spawn2, DEFAULT_INHERITED_ENV_VARS;
487637
487856
  var init_stdio2 = __esm(() => {
487638
487857
  init_stdio();
487639
- import_cross_spawn = __toESM(require_cross_spawn(), 1);
487858
+ import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
487640
487859
  DEFAULT_INHERITED_ENV_VARS = process20.platform === "win32" ? [
487641
487860
  "APPDATA",
487642
487861
  "HOMEDRIVE",
@@ -488304,7 +488523,7 @@ var init_mcp_client = __esm(() => {
488304
488523
  init_streamableHttp();
488305
488524
  DEFAULT_CLIENT_INFO = {
488306
488525
  name: "letta-code",
488307
- version: "0.29.13"
488526
+ version: "0.30.0"
488308
488527
  };
488309
488528
  });
488310
488529
 
@@ -552022,7 +552241,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
552022
552241
  importFlagValue: values2.import,
552023
552242
  fromAfFlagValue: values2["from-af"]
552024
552243
  });
552025
- const isHeadless = values2.prompt || values2.run || !process.stdin.isTTY;
552244
+ const isHeadless = isHeadlessStartup(values2, process.stdin.isTTY, command);
552026
552245
  const terminalThemePromise = !isHeadless ? initTerminalTheme().catch(() => {
552027
552246
  return;
552028
552247
  }) : Promise.resolve(undefined);
@@ -555327,4 +555546,4 @@ function registerBunOAuthFlows() {
555327
555546
  registerBunOAuthFlows();
555328
555547
  await init_src5().then(() => exports_src2);
555329
555548
 
555330
- //# debugId=891005FA529AE42B64756E2164756E21
555549
+ //# debugId=B9D60EB55EA6EE2C64756E2164756E21