kfc-code-cli 0.0.1-alpha.18 → 0.0.1-alpha.19

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.
@@ -15,6 +15,7 @@ tools:
15
15
  - ReadMediaFile
16
16
  - SetTodoList
17
17
  - WebSearch
18
+ - Agent
18
19
  - FetchURL
19
20
  - AskUserQuestion
20
21
  - EnterPlanMode
package/dist/main.mjs CHANGED
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
5
5
  import { Command, Option } from "commander";
6
6
  import * as nodeFs from "node:fs";
7
7
  import Vt, { chmodSync, closeSync, constants, createReadStream, createWriteStream, existsSync, fsyncSync, mkdirSync, openSync, promises, readFileSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
8
- import fs, { access, appendFile, chmod, lstat, mkdir, mkdtemp, open, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
8
+ import jn, { access, appendFile, chmod, lstat, mkdir, mkdtemp, open, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
9
9
  import * as path$2 from "node:path";
10
10
  import path, { basename, dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep, win32 } from "node:path";
11
11
  import { finished, pipeline } from "node:stream/promises";
@@ -29,7 +29,7 @@ import * as ks from "zlib";
29
29
  import qr from "zlib";
30
30
  import so from "node:assert";
31
31
  import { parse as parse$1, stringify } from "smol-toml";
32
- import * as fs$2 from "fs/promises";
32
+ import * as fs$1 from "fs/promises";
33
33
  import { writeFile as writeFile$1 } from "fs/promises";
34
34
  import { AsyncLocalStorage } from "node:async_hooks";
35
35
  import { ZipFile } from "yazl";
@@ -5214,6 +5214,7 @@ var AgentTool = class {
5214
5214
  name = "Agent";
5215
5215
  description;
5216
5216
  inputSchema = AgentToolInputSchema;
5217
+ isConcurrencySafe = (_input) => true;
5217
5218
  constructor(subagentHost, parentAgentId, backgroundManager, typeRegistry) {
5218
5219
  this.subagentHost = subagentHost;
5219
5220
  this.parentAgentId = parentAgentId;
@@ -27313,7 +27314,7 @@ K(Un, Hn, Wn, Gn, (s, t) => {
27313
27314
  if (!t?.length) throw new TypeError("no paths specified to add to archive");
27314
27315
  });
27315
27316
  var fr = (process.env.__FAKE_PLATFORM__ || process.platform) === "win32", { O_CREAT: dr, O_NOFOLLOW: ar, O_TRUNC: ur, O_WRONLY: mr } = I.constants, pr = Number(process.env.__FAKE_FS_O_FILENAME__) || I.constants.UV_FS_O_FILEMAP || 0, Kn = fr && !!pr, Vn = 512 * 1024, $n = pr | ur | dr | mr, lr = !fr && typeof ar == "number" ? ar | ur | dr | mr : null, cs = lr !== null ? () => lr : Kn ? (s) => s < Vn ? $n : "w" : () => "w";
27316
- var fs$13 = (s, t, e) => {
27317
+ var fs$12 = (s, t, e) => {
27317
27318
  try {
27318
27319
  return Vt.lchownSync(s, t, e);
27319
27320
  } catch (i) {
@@ -27345,7 +27346,7 @@ var fs$13 = (s, t, e) => {
27345
27346
  for (let l of n) Xn(s, l, t, e, a);
27346
27347
  });
27347
27348
  }, qn = (s, t, e, i) => {
27348
- t.isDirectory() && us(path.resolve(s, t.name), e, i), fs$13(path.resolve(s, t.name), e, i);
27349
+ t.isDirectory() && us(path.resolve(s, t.name), e, i), fs$12(path.resolve(s, t.name), e, i);
27349
27350
  }, us = (s, t, e) => {
27350
27351
  let i;
27351
27352
  try {
@@ -27353,11 +27354,11 @@ var fs$13 = (s, t, e) => {
27353
27354
  } catch (r) {
27354
27355
  let n = r;
27355
27356
  if (n?.code === "ENOENT") return;
27356
- if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return fs$13(s, t, e);
27357
+ if (n?.code === "ENOTDIR" || n?.code === "ENOTSUP") return fs$12(s, t, e);
27357
27358
  throw n;
27358
27359
  }
27359
27360
  for (let r of i) qn(s, r, t, e);
27360
- return fs$13(s, t, e);
27361
+ return fs$12(s, t, e);
27361
27362
  };
27362
27363
  var we = class extends Error {
27363
27364
  path;
@@ -27392,7 +27393,7 @@ var Qn = (s, t) => {
27392
27393
  E ? e(E) : x && a ? ds(x, o, h, (xe) => S(xe)) : n ? Vt.chmod(s, r, e) : e();
27393
27394
  };
27394
27395
  if (s === d) return Qn(s, S);
27395
- if (l) return fs.mkdir(s, {
27396
+ if (l) return jn.mkdir(s, {
27396
27397
  mode: r,
27397
27398
  recursive: !0
27398
27399
  }).then((E) => S(null, E ?? void 0), S);
@@ -28151,7 +28152,7 @@ var require_pend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
28151
28152
  //#endregion
28152
28153
  //#region ../../node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/fd-slicer.js
28153
28154
  var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28154
- var fs$12 = __require("fs");
28155
+ var fs$11 = __require("fs");
28155
28156
  var util$7 = __require("util");
28156
28157
  var stream$4 = __require("stream");
28157
28158
  var Readable = stream$4.Readable;
@@ -28176,7 +28177,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28176
28177
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
28177
28178
  var self = this;
28178
28179
  self.pend.go(function(cb) {
28179
- fs$12.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
28180
+ fs$11.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
28180
28181
  cb();
28181
28182
  callback(err, bytesRead, buffer);
28182
28183
  });
@@ -28185,7 +28186,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28185
28186
  FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
28186
28187
  var self = this;
28187
28188
  self.pend.go(function(cb) {
28188
- fs$12.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
28189
+ fs$11.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
28189
28190
  cb();
28190
28191
  callback(err, written, buffer);
28191
28192
  });
@@ -28205,7 +28206,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28205
28206
  self.refCount -= 1;
28206
28207
  if (self.refCount > 0) return;
28207
28208
  if (self.refCount < 0) throw new Error("invalid unref");
28208
- if (self.autoClose) fs$12.close(self.fd, onCloseDone);
28209
+ if (self.autoClose) fs$11.close(self.fd, onCloseDone);
28209
28210
  function onCloseDone(err) {
28210
28211
  if (err) self.emit("error", err);
28211
28212
  else self.emit("close");
@@ -28236,7 +28237,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28236
28237
  self.context.pend.go(function(cb) {
28237
28238
  if (self.destroyed) return cb();
28238
28239
  var buffer = Buffer.allocUnsafe(toRead);
28239
- fs$12.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
28240
+ fs$11.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
28240
28241
  if (err) self.destroy(err);
28241
28242
  else if (bytesRead === 0) {
28242
28243
  self.destroyed = true;
@@ -28282,7 +28283,7 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
28282
28283
  }
28283
28284
  self.context.pend.go(function(cb) {
28284
28285
  if (self.destroyed) return cb();
28285
- fs$12.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
28286
+ fs$11.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
28286
28287
  if (err) {
28287
28288
  self.destroy();
28288
28289
  cb();
@@ -40102,7 +40103,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40102
40103
  };
40103
40104
  return _setPrototypeOf(o, p);
40104
40105
  }
40105
- var fs$10 = __require("fs");
40106
+ var fs$9 = __require("fs");
40106
40107
  var path$10 = __require("path");
40107
40108
  var Loader = require_loader();
40108
40109
  var PrecompiledLoader = require_precompiled_loader().PrecompiledLoader;
@@ -40126,7 +40127,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40126
40127
  } catch (e) {
40127
40128
  throw new Error("watch requires chokidar to be installed");
40128
40129
  }
40129
- var paths = _this.searchPaths.filter(fs$10.existsSync);
40130
+ var paths = _this.searchPaths.filter(fs$9.existsSync);
40130
40131
  var watcher = chokidar.watch(paths);
40131
40132
  watcher.on("all", function(event, fullname) {
40132
40133
  fullname = path$10.resolve(fullname);
@@ -40145,7 +40146,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40145
40146
  for (var i = 0; i < paths.length; i++) {
40146
40147
  var basePath = path$10.resolve(paths[i]);
40147
40148
  var p = path$10.resolve(paths[i], name);
40148
- if (p.indexOf(basePath) === 0 && fs$10.existsSync(p)) {
40149
+ if (p.indexOf(basePath) === 0 && fs$9.existsSync(p)) {
40149
40150
  fullpath = p;
40150
40151
  break;
40151
40152
  }
@@ -40153,7 +40154,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40153
40154
  if (!fullpath) return null;
40154
40155
  this.pathsToNames[fullpath] = name;
40155
40156
  var source = {
40156
- src: fs$10.readFileSync(fullpath, "utf-8"),
40157
+ src: fs$9.readFileSync(fullpath, "utf-8"),
40157
40158
  path: fullpath,
40158
40159
  noCache: this.noCache
40159
40160
  };
@@ -40201,7 +40202,7 @@ var require_node_loaders = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40201
40202
  }
40202
40203
  this.pathsToNames[fullpath] = name;
40203
40204
  var source = {
40204
- src: fs$10.readFileSync(fullpath, "utf-8"),
40205
+ src: fs$9.readFileSync(fullpath, "utf-8"),
40205
40206
  path: fullpath,
40206
40207
  noCache: this.noCache
40207
40208
  };
@@ -40945,7 +40946,7 @@ var require_precompile_global = /* @__PURE__ */ __commonJSMin(((exports, module)
40945
40946
  //#endregion
40946
40947
  //#region ../../node_modules/.pnpm/nunjucks@3.2.4/node_modules/nunjucks/src/precompile.js
40947
40948
  var require_precompile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40948
- var fs$9 = __require("fs");
40949
+ var fs$8 = __require("fs");
40949
40950
  var path$8 = __require("path");
40950
40951
  var _prettifyError = require_lib$1()._prettifyError;
40951
40952
  var compiler = require_compiler();
@@ -40970,27 +40971,27 @@ var require_precompile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
40970
40971
  var env = opts.env || new Environment([]);
40971
40972
  var wrapper = opts.wrapper || precompileGlobal;
40972
40973
  if (opts.isString) return precompileString(input, opts);
40973
- var pathStats = fs$9.existsSync(input) && fs$9.statSync(input);
40974
+ var pathStats = fs$8.existsSync(input) && fs$8.statSync(input);
40974
40975
  var precompiled = [];
40975
40976
  var templates = [];
40976
40977
  function addTemplates(dir) {
40977
- fs$9.readdirSync(dir).forEach(function(file) {
40978
+ fs$8.readdirSync(dir).forEach(function(file) {
40978
40979
  var filepath = path$8.join(dir, file);
40979
40980
  var subpath = filepath.substr(path$8.join(input, "/").length);
40980
- var stat = fs$9.statSync(filepath);
40981
+ var stat = fs$8.statSync(filepath);
40981
40982
  if (stat && stat.isDirectory()) {
40982
40983
  subpath += "/";
40983
40984
  if (!match(subpath, opts.exclude)) addTemplates(filepath);
40984
40985
  } else if (match(subpath, opts.include)) templates.push(filepath);
40985
40986
  });
40986
40987
  }
40987
- if (pathStats.isFile()) precompiled.push(_precompile(fs$9.readFileSync(input, "utf-8"), opts.name || input, env));
40988
+ if (pathStats.isFile()) precompiled.push(_precompile(fs$8.readFileSync(input, "utf-8"), opts.name || input, env));
40988
40989
  else if (pathStats.isDirectory()) {
40989
40990
  addTemplates(input);
40990
40991
  for (var i = 0; i < templates.length; i++) {
40991
40992
  var name = templates[i].replace(path$8.join(input, "/"), "");
40992
40993
  try {
40993
- precompiled.push(_precompile(fs$9.readFileSync(templates[i], "utf-8"), name, env));
40994
+ precompiled.push(_precompile(fs$8.readFileSync(templates[i], "utf-8"), name, env));
40994
40995
  } catch (e) {
40995
40996
  if (opts.force) console.error(e);
40996
40997
  else throw e;
@@ -52227,7 +52228,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
52227
52228
  exports.removeUndefinedValuesInObject = removeUndefinedValuesInObject;
52228
52229
  exports.isValidFile = isValidFile;
52229
52230
  exports.getWellKnownCertificateConfigFileLocation = getWellKnownCertificateConfigFileLocation;
52230
- const fs$8 = __require("fs");
52231
+ const fs$7 = __require("fs");
52231
52232
  const os$1 = __require("os");
52232
52233
  const path$6 = __require("path");
52233
52234
  const WELL_KNOWN_CERTIFICATE_CONFIG_FILE = "certificate_config.json";
@@ -52347,7 +52348,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
52347
52348
  */
52348
52349
  async function isValidFile(filePath) {
52349
52350
  try {
52350
- return (await fs$8.promises.lstat(filePath)).isFile();
52351
+ return (await fs$7.promises.lstat(filePath)).isFile();
52351
52352
  } catch (e) {
52352
52353
  return false;
52353
52354
  }
@@ -54060,10 +54061,10 @@ var require_getCredentials = /* @__PURE__ */ __commonJSMin(((exports) => {
54060
54061
  Object.defineProperty(exports, "__esModule", { value: true });
54061
54062
  exports.getCredentials = getCredentials;
54062
54063
  const path$5 = __require("path");
54063
- const fs$7 = __require("fs");
54064
+ const fs$6 = __require("fs");
54064
54065
  const util_1$1 = __require("util");
54065
54066
  const errorWithCode_1 = require_errorWithCode();
54066
- const readFile = fs$7.readFile ? (0, util_1$1.promisify)(fs$7.readFile) : async () => {
54067
+ const readFile = fs$6.readFile ? (0, util_1$1.promisify)(fs$6.readFile) : async () => {
54067
54068
  throw new errorWithCode_1.ErrorWithCode("use key rather than keyFile.", "MISSING_CREDENTIALS");
54068
54069
  };
54069
54070
  var ExtensionFiles;
@@ -55610,10 +55611,10 @@ var require_filesubjecttokensupplier = /* @__PURE__ */ __commonJSMin(((exports)
55610
55611
  Object.defineProperty(exports, "__esModule", { value: true });
55611
55612
  exports.FileSubjectTokenSupplier = void 0;
55612
55613
  const util_1 = __require("util");
55613
- const fs$6 = __require("fs");
55614
- const readFile = (0, util_1.promisify)(fs$6.readFile ?? (() => {}));
55615
- const realpath = (0, util_1.promisify)(fs$6.realpath ?? (() => {}));
55616
- const lstat = (0, util_1.promisify)(fs$6.lstat ?? (() => {}));
55614
+ const fs$5 = __require("fs");
55615
+ const readFile = (0, util_1.promisify)(fs$5.readFile ?? (() => {}));
55616
+ const realpath = (0, util_1.promisify)(fs$5.realpath ?? (() => {}));
55617
+ const lstat = (0, util_1.promisify)(fs$5.lstat ?? (() => {}));
55617
55618
  /**
55618
55619
  * Internal subject token supplier implementation used when a file location
55619
55620
  * is configured in the credential configuration used to build an {@link IdentityPoolClient}
@@ -55715,7 +55716,7 @@ var require_certificatesubjecttokensupplier = /* @__PURE__ */ __commonJSMin(((ex
55715
55716
  Object.defineProperty(exports, "__esModule", { value: true });
55716
55717
  exports.CertificateSubjectTokenSupplier = exports.InvalidConfigurationError = exports.CertificateSourceUnavailableError = exports.CERTIFICATE_CONFIGURATION_ENV_VARIABLE = void 0;
55717
55718
  const util_1 = require_util();
55718
- const fs$5 = __require("fs");
55719
+ const fs$4 = __require("fs");
55719
55720
  const crypto_1 = __require("crypto");
55720
55721
  const https$1 = __require("https");
55721
55722
  exports.CERTIFICATE_CONFIGURATION_ENV_VARIABLE = "GOOGLE_API_CERTIFICATE_CONFIG";
@@ -55810,7 +55811,7 @@ var require_certificatesubjecttokensupplier = /* @__PURE__ */ __commonJSMin(((ex
55810
55811
  const configPath = this.certificateConfigPath;
55811
55812
  let fileContents;
55812
55813
  try {
55813
- fileContents = await fs$5.promises.readFile(configPath, "utf8");
55814
+ fileContents = await fs$4.promises.readFile(configPath, "utf8");
55814
55815
  } catch (err) {
55815
55816
  throw new CertificateSourceUnavailableError(`Failed to read certificate config file at: ${configPath}`);
55816
55817
  }
@@ -55835,13 +55836,13 @@ var require_certificatesubjecttokensupplier = /* @__PURE__ */ __commonJSMin(((ex
55835
55836
  async #getKeyAndCert(certPath, keyPath) {
55836
55837
  let cert, key;
55837
55838
  try {
55838
- cert = await fs$5.promises.readFile(certPath);
55839
+ cert = await fs$4.promises.readFile(certPath);
55839
55840
  new crypto_1.X509Certificate(cert);
55840
55841
  } catch (err) {
55841
55842
  throw new CertificateSourceUnavailableError(`Failed to read certificate file at ${certPath}: ${err instanceof Error ? err.message : String(err)}`);
55842
55843
  }
55843
55844
  try {
55844
- key = await fs$5.promises.readFile(keyPath);
55845
+ key = await fs$4.promises.readFile(keyPath);
55845
55846
  (0, crypto_1.createPrivateKey)(key);
55846
55847
  } catch (err) {
55847
55848
  throw new CertificateSourceUnavailableError(`Failed to read private key file at ${keyPath}: ${err instanceof Error ? err.message : String(err)}`);
@@ -55860,7 +55861,7 @@ var require_certificatesubjecttokensupplier = /* @__PURE__ */ __commonJSMin(((ex
55860
55861
  const leafCert = new crypto_1.X509Certificate(leafCertBuffer);
55861
55862
  if (!this.trustChainPath) return JSON.stringify([leafCert.raw.toString("base64")]);
55862
55863
  try {
55863
- const chainCerts = ((await fs$5.promises.readFile(this.trustChainPath, "utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g) ?? []).map((pem, index) => {
55864
+ const chainCerts = ((await fs$4.promises.readFile(this.trustChainPath, "utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g) ?? []).map((pem, index) => {
55864
55865
  try {
55865
55866
  return new crypto_1.X509Certificate(pem);
55866
55867
  } catch (err) {
@@ -56520,7 +56521,7 @@ var require_pluggable_auth_handler = /* @__PURE__ */ __commonJSMin(((exports) =>
56520
56521
  exports.PluggableAuthHandler = exports.ExecutableError = void 0;
56521
56522
  const executable_response_1 = require_executable_response();
56522
56523
  const childProcess = __require("child_process");
56523
- const fs$4 = __require("fs");
56524
+ const fs$3 = __require("fs");
56524
56525
  /**
56525
56526
  * Error thrown from the executable run by PluggableAuthClient.
56526
56527
  */
@@ -56597,12 +56598,12 @@ var require_pluggable_auth_handler = /* @__PURE__ */ __commonJSMin(((exports) =>
56597
56598
  if (!this.outputFile || this.outputFile.length === 0) return;
56598
56599
  let filePath;
56599
56600
  try {
56600
- filePath = await fs$4.promises.realpath(this.outputFile);
56601
+ filePath = await fs$3.promises.realpath(this.outputFile);
56601
56602
  } catch {
56602
56603
  return;
56603
56604
  }
56604
- if (!(await fs$4.promises.lstat(filePath)).isFile()) return;
56605
- const responseString = await fs$4.promises.readFile(filePath, { encoding: "utf8" });
56605
+ if (!(await fs$3.promises.lstat(filePath)).isFile()) return;
56606
+ const responseString = await fs$3.promises.readFile(filePath, { encoding: "utf8" });
56606
56607
  if (responseString === "") return;
56607
56608
  try {
56608
56609
  const responseJson = JSON.parse(responseString);
@@ -57024,7 +57025,7 @@ var require_googleauth = /* @__PURE__ */ __commonJSMin(((exports) => {
57024
57025
  Object.defineProperty(exports, "__esModule", { value: true });
57025
57026
  exports.GoogleAuth = exports.GoogleAuthExceptionMessages = void 0;
57026
57027
  const child_process_1 = __require("child_process");
57027
- const fs$3 = __require("fs");
57028
+ const fs$2 = __require("fs");
57028
57029
  const gaxios_1 = require_src$3();
57029
57030
  const gcpMetadata = require_src$1();
57030
57031
  const os = __require("os");
@@ -57272,7 +57273,7 @@ var require_googleauth = /* @__PURE__ */ __commonJSMin(((exports) => {
57272
57273
  }
57273
57274
  if (location) {
57274
57275
  location = path$4.join(location, "gcloud", "application_default_credentials.json");
57275
- if (!fs$3.existsSync(location)) location = null;
57276
+ if (!fs$2.existsSync(location)) location = null;
57276
57277
  }
57277
57278
  if (!location) return null;
57278
57279
  return await this._getApplicationCredentialsFromFilePath(location, options);
@@ -57286,13 +57287,13 @@ var require_googleauth = /* @__PURE__ */ __commonJSMin(((exports) => {
57286
57287
  async _getApplicationCredentialsFromFilePath(filePath, options = {}) {
57287
57288
  if (!filePath || filePath.length === 0) throw new Error("The file path is invalid.");
57288
57289
  try {
57289
- filePath = fs$3.realpathSync(filePath);
57290
- if (!fs$3.lstatSync(filePath).isFile()) throw new Error();
57290
+ filePath = fs$2.realpathSync(filePath);
57291
+ if (!fs$2.lstatSync(filePath).isFile()) throw new Error();
57291
57292
  } catch (err) {
57292
57293
  if (err instanceof Error) err.message = `The file at ${filePath} does not exist, or it is not a file. ${err.message}`;
57293
57294
  throw err;
57294
57295
  }
57295
- const readStream = fs$3.createReadStream(filePath);
57296
+ const readStream = fs$2.createReadStream(filePath);
57296
57297
  return this.fromStream(readStream, options);
57297
57298
  }
57298
57299
  /**
@@ -57559,7 +57560,7 @@ var require_googleauth = /* @__PURE__ */ __commonJSMin(((exports) => {
57559
57560
  if (this.jsonContent) return this._cacheClientFromJSON(this.jsonContent, this.clientOptions);
57560
57561
  else if (this.keyFilename) {
57561
57562
  const filePath = path$4.resolve(this.keyFilename);
57562
- const stream = fs$3.createReadStream(filePath);
57563
+ const stream = fs$2.createReadStream(filePath);
57563
57564
  return await this.fromStreamAsync(stream, this.clientOptions);
57564
57565
  } else if (this.apiKey) {
57565
57566
  const client = await this.fromAPIKey(this.apiKey, this.clientOptions);
@@ -76069,7 +76070,7 @@ var NodeUploader = class {
76069
76070
  type: void 0
76070
76071
  };
76071
76072
  if (typeof file === "string") {
76072
- fileStat.size = (await fs$2.stat(file)).size;
76073
+ fileStat.size = (await fs$1.stat(file)).size;
76073
76074
  fileStat.type = this.inferMimeType(file);
76074
76075
  return fileStat;
76075
76076
  } else return await getBlobStat(file);
@@ -76202,7 +76203,7 @@ var NodeUploader = class {
76202
76203
  let fileHandle;
76203
76204
  const fileName = path$1$1.basename(file);
76204
76205
  try {
76205
- fileHandle = await fs$2.open(file, "r");
76206
+ fileHandle = await fs$1.open(file, "r");
76206
76207
  if (!fileHandle) throw new Error(`Failed to open file`);
76207
76208
  fileSize = (await fileHandle.stat()).size;
76208
76209
  while (offset < fileSize) {
@@ -92506,7 +92507,7 @@ var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92506
92507
  //#endregion
92507
92508
  //#region ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
92508
92509
  var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92509
- var fs$1 = __require("fs");
92510
+ var fs = __require("fs");
92510
92511
  var polyfills = require_polyfills();
92511
92512
  var legacy = require_legacy_streams();
92512
92513
  var clone = require_clone();
@@ -92535,36 +92536,36 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92535
92536
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
92536
92537
  console.error(m);
92537
92538
  };
92538
- if (!fs$1[gracefulQueue]) {
92539
- publishQueue(fs$1, global[gracefulQueue] || []);
92540
- fs$1.close = (function(fs$close) {
92539
+ if (!fs[gracefulQueue]) {
92540
+ publishQueue(fs, global[gracefulQueue] || []);
92541
+ fs.close = (function(fs$close) {
92541
92542
  function close(fd, cb) {
92542
- return fs$close.call(fs$1, fd, function(err) {
92543
+ return fs$close.call(fs, fd, function(err) {
92543
92544
  if (!err) resetQueue();
92544
92545
  if (typeof cb === "function") cb.apply(this, arguments);
92545
92546
  });
92546
92547
  }
92547
92548
  Object.defineProperty(close, previousSymbol, { value: fs$close });
92548
92549
  return close;
92549
- })(fs$1.close);
92550
- fs$1.closeSync = (function(fs$closeSync) {
92550
+ })(fs.close);
92551
+ fs.closeSync = (function(fs$closeSync) {
92551
92552
  function closeSync(fd) {
92552
- fs$closeSync.apply(fs$1, arguments);
92553
+ fs$closeSync.apply(fs, arguments);
92553
92554
  resetQueue();
92554
92555
  }
92555
92556
  Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
92556
92557
  return closeSync;
92557
- })(fs$1.closeSync);
92558
+ })(fs.closeSync);
92558
92559
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
92559
- debug(fs$1[gracefulQueue]);
92560
- __require("assert").equal(fs$1[gracefulQueue].length, 0);
92560
+ debug(fs[gracefulQueue]);
92561
+ __require("assert").equal(fs[gracefulQueue].length, 0);
92561
92562
  });
92562
92563
  }
92563
- if (!global[gracefulQueue]) publishQueue(global, fs$1[gracefulQueue]);
92564
- module.exports = patch(clone(fs$1));
92565
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$1.__patched) {
92566
- module.exports = patch(fs$1);
92567
- fs$1.__patched = true;
92564
+ if (!global[gracefulQueue]) publishQueue(global, fs[gracefulQueue]);
92565
+ module.exports = patch(clone(fs));
92566
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
92567
+ module.exports = patch(fs);
92568
+ fs.__patched = true;
92568
92569
  }
92569
92570
  function patch(fs) {
92570
92571
  polyfills(fs);
@@ -92819,23 +92820,23 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92819
92820
  }
92820
92821
  function enqueue(elem) {
92821
92822
  debug("ENQUEUE", elem[0].name, elem[1]);
92822
- fs$1[gracefulQueue].push(elem);
92823
+ fs[gracefulQueue].push(elem);
92823
92824
  retry();
92824
92825
  }
92825
92826
  var retryTimer;
92826
92827
  function resetQueue() {
92827
92828
  var now = Date.now();
92828
- for (var i = 0; i < fs$1[gracefulQueue].length; ++i) if (fs$1[gracefulQueue][i].length > 2) {
92829
- fs$1[gracefulQueue][i][3] = now;
92830
- fs$1[gracefulQueue][i][4] = now;
92829
+ for (var i = 0; i < fs[gracefulQueue].length; ++i) if (fs[gracefulQueue][i].length > 2) {
92830
+ fs[gracefulQueue][i][3] = now;
92831
+ fs[gracefulQueue][i][4] = now;
92831
92832
  }
92832
92833
  retry();
92833
92834
  }
92834
92835
  function retry() {
92835
92836
  clearTimeout(retryTimer);
92836
92837
  retryTimer = void 0;
92837
- if (fs$1[gracefulQueue].length === 0) return;
92838
- var elem = fs$1[gracefulQueue].shift();
92838
+ if (fs[gracefulQueue].length === 0) return;
92839
+ var elem = fs[gracefulQueue].shift();
92839
92840
  var fn = elem[0];
92840
92841
  var args = elem[1];
92841
92842
  var err = elem[2];
@@ -92854,7 +92855,7 @@ var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
92854
92855
  if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
92855
92856
  debug("RETRY", fn.name, args);
92856
92857
  fn.apply(null, args.concat([startTime]));
92857
- } else fs$1[gracefulQueue].push(elem);
92858
+ } else fs[gracefulQueue].push(elem);
92858
92859
  }
92859
92860
  if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
92860
92861
  }
@@ -95567,17 +95568,32 @@ const TuiThemeSchema = z.enum([
95567
95568
  "light",
95568
95569
  "auto"
95569
95570
  ]);
95571
+ const NotificationConditionSchema = z.enum(["unfocused", "always"]);
95572
+ const NotificationsConfigSchema = z.object({
95573
+ enabled: z.boolean(),
95574
+ condition: NotificationConditionSchema
95575
+ });
95570
95576
  const TuiConfigFileSchema = z.object({
95571
95577
  theme: TuiThemeSchema.optional(),
95572
- editor: z.object({ command: z.string().optional() }).optional()
95578
+ editor: z.object({ command: z.string().optional() }).optional(),
95579
+ notifications: z.object({
95580
+ enabled: z.boolean().optional(),
95581
+ notification_condition: NotificationConditionSchema.optional()
95582
+ }).optional()
95573
95583
  });
95574
95584
  const TuiConfigSchema = z.object({
95575
95585
  theme: TuiThemeSchema,
95576
- editorCommand: z.string().nullable()
95586
+ editorCommand: z.string().nullable(),
95587
+ notifications: NotificationsConfigSchema
95577
95588
  });
95589
+ const DEFAULT_NOTIFICATIONS_CONFIG = {
95590
+ enabled: true,
95591
+ condition: "unfocused"
95592
+ };
95578
95593
  const DEFAULT_TUI_CONFIG = TuiConfigSchema.parse({
95579
95594
  theme: "auto",
95580
- editorCommand: null
95595
+ editorCommand: null,
95596
+ notifications: DEFAULT_NOTIFICATIONS_CONFIG
95581
95597
  });
95582
95598
  /**
95583
95599
  * Thrown by `loadTuiConfig` when the on-disk TOML cannot be parsed.
@@ -95620,7 +95636,11 @@ function normalizeTuiConfig(config) {
95620
95636
  const command = config.editor?.command?.trim();
95621
95637
  return TuiConfigSchema.parse({
95622
95638
  theme: config.theme ?? DEFAULT_TUI_CONFIG.theme,
95623
- editorCommand: command === void 0 || command.length === 0 ? null : command
95639
+ editorCommand: command === void 0 || command.length === 0 ? null : command,
95640
+ notifications: {
95641
+ enabled: config.notifications?.enabled ?? DEFAULT_NOTIFICATIONS_CONFIG.enabled,
95642
+ condition: config.notifications?.notification_condition ?? DEFAULT_NOTIFICATIONS_CONFIG.condition
95643
+ }
95624
95644
  });
95625
95645
  }
95626
95646
  function renderTuiConfig(config) {
@@ -95632,6 +95652,10 @@ theme = "${config.theme}" # "auto" | "dark" | "light"
95632
95652
 
95633
95653
  [editor]
95634
95654
  command = "${escapeTomlBasicString(config.editorCommand ?? "")}" # Empty uses $VISUAL / $EDITOR
95655
+
95656
+ [notifications]
95657
+ enabled = ${String(config.notifications.enabled)} # true | false
95658
+ notification_condition = "${config.notifications.condition}" # "unfocused" | "always"
95635
95659
  `;
95636
95660
  }
95637
95661
  function escapeTomlBasicString(value) {
@@ -97433,6 +97457,82 @@ var WelcomeComponent = class {
97433
97457
  }
97434
97458
  };
97435
97459
  //#endregion
97460
+ //#region src/tui/utils/terminal-notification.ts
97461
+ const MAX_MESSAGE_LENGTH = 240;
97462
+ const ESC$1 = "\x1B";
97463
+ const BEL = "\x07";
97464
+ const ST = "\\";
97465
+ function notifyTerminalOnce(state, key, notification) {
97466
+ const { enabled, condition } = state.appState.notifications;
97467
+ if (!enabled) return;
97468
+ if (state.terminalNotificationKeys.has(key)) return;
97469
+ state.terminalNotificationKeys.add(key);
97470
+ if (condition === "unfocused" && state.terminalFocused) return;
97471
+ emitTerminalNotification(state.terminal, notification, {
97472
+ supportsOsc9: state.osc9Supported,
97473
+ insideTmux: state.insideTmux
97474
+ });
97475
+ }
97476
+ function emitTerminalNotification(terminal, notification, options = {}) {
97477
+ const sequences = buildTerminalNotificationSequences(notification, {
97478
+ supportsOsc9: options.supportsOsc9 ?? supportsOsc9Notification(),
97479
+ insideTmux: options.insideTmux ?? isInsideTmux()
97480
+ });
97481
+ for (const sequence of sequences) terminal.write(sequence);
97482
+ }
97483
+ function formatNotification(notification) {
97484
+ const title = sanitizeNotificationText(notification.title);
97485
+ const body = sanitizeNotificationText(notification.body ?? "");
97486
+ return (title.length > 0 && body.length > 0 ? `${title}: ${body}` : title.length > 0 ? title : body).slice(0, MAX_MESSAGE_LENGTH);
97487
+ }
97488
+ /**
97489
+ * Build the wire bytes for a terminal notification.
97490
+ *
97491
+ * - `supportsOsc9 === true`: emit a single OSC 9 sequence — the modern
97492
+ * desktop-notification path used by iTerm2, WezTerm, Kitty, Ghostty
97493
+ * and Warp.
97494
+ * - `supportsOsc9 === false`: fall back to a bare BEL so the user still
97495
+ * gets the system bell on terminals that don't recognize OSC 9.
97496
+ *
97497
+ * When `insideTmux === true` and we're emitting OSC 9, wrap the sequence
97498
+ * in a tmux DCS passthrough (`ESC P tmux ; <payload> ESC \`) and double
97499
+ * any `ESC` bytes inside the payload — otherwise tmux swallows the OSC.
97500
+ * BEL is single-byte and passes through tmux unchanged, so no wrap is
97501
+ * needed in the fallback path.
97502
+ */
97503
+ function buildTerminalNotificationSequences(notification, options) {
97504
+ const message = formatNotification(notification);
97505
+ if (message.length === 0) return [];
97506
+ if (!options.supportsOsc9) return [BEL];
97507
+ const osc9 = `${ESC$1}]9;${message}${BEL}`;
97508
+ if (options.insideTmux) return [`${ESC$1}Ptmux;${osc9.replaceAll(ESC$1, `${ESC$1}${ESC$1}`)}${ESC$1}${ST}`];
97509
+ return [osc9];
97510
+ }
97511
+ /**
97512
+ * Best-effort detection of OSC 9 desktop-notification support, driven
97513
+ * entirely off well-known environment variables. The allow-list mirrors
97514
+ * Codex's terminal-detection crate — it is intentionally short and
97515
+ * conservative because BEL is safe everywhere, while shipping OSC 9 to
97516
+ * a terminal that doesn't grok it would print escape garbage on screen.
97517
+ */
97518
+ function supportsOsc9Notification(env = process.env) {
97519
+ const termProgram = env.TERM_PROGRAM ?? "";
97520
+ if (termProgram === "iTerm.app" || termProgram === "WezTerm" || termProgram === "ghostty" || termProgram === "WarpTerminal") return true;
97521
+ const term = env.TERM ?? "";
97522
+ if (term === "xterm-kitty" || term === "xterm-ghostty") return true;
97523
+ return false;
97524
+ }
97525
+ function isInsideTmux(env = process.env) {
97526
+ return (env.TMUX ?? "").length > 0;
97527
+ }
97528
+ function sanitizeNotificationText(value) {
97529
+ return Array.from(value).map((ch) => isControlCharacter(ch) ? " " : ch).join("").replaceAll(/\s+/g, " ").trim();
97530
+ }
97531
+ function isControlCharacter(ch) {
97532
+ const code = ch.codePointAt(0) ?? 0;
97533
+ return code >= 0 && code <= 31 || code >= 127 && code <= 159;
97534
+ }
97535
+ //#endregion
97436
97536
  //#region src/tui/handlers/helpers.ts
97437
97537
  const TOAST_TTL_MS = 5e3;
97438
97538
  let transcriptIdCounter = 0;
@@ -97494,6 +97594,7 @@ function flushTurnBuffers(ectx, nextMode = "idle") {
97494
97594
  */
97495
97595
  function finalizeTurn(ectx, sendQueued) {
97496
97596
  if (!ectx.state.appState.isStreaming) return;
97597
+ const completedTurnKey = ectx.state.currentTurnId ?? `local:${String(ectx.state.appState.streamingStartTime)}`;
97497
97598
  flushTurnBuffers(ectx, "idle");
97498
97599
  ectx.state.activeToolCalls.clear();
97499
97600
  ectx.state.currentTurnId = void 0;
@@ -97505,7 +97606,9 @@ function finalizeTurn(ectx, sendQueued) {
97505
97606
  streamingPhase: "idle"
97506
97607
  });
97507
97608
  ectx.resetLivePane();
97508
- setTimeout(() => sendQueued(next), 0);
97609
+ if (next !== void 0) setTimeout(() => {
97610
+ sendQueued(next);
97611
+ }, 0);
97509
97612
  return;
97510
97613
  }
97511
97614
  ectx.setAppState({
@@ -97513,6 +97616,10 @@ function finalizeTurn(ectx, sendQueued) {
97513
97616
  streamingPhase: "idle"
97514
97617
  });
97515
97618
  ectx.resetLivePane();
97619
+ notifyTerminalOnce(ectx.state, `turn-complete:${completedTurnKey}`, {
97620
+ title: "Kimi Code task complete",
97621
+ body: ectx.state.appState.sessionTitle ?? void 0
97622
+ });
97516
97623
  }
97517
97624
  /** Push a toast into the live list and schedule auto-dismiss. */
97518
97625
  function pushToast(ectx, notification) {
@@ -99623,6 +99730,10 @@ function createTUIState(options) {
99623
99730
  livePane: { ...INITIAL_LIVE_PANE },
99624
99731
  transcriptEntries: [],
99625
99732
  toasts: [],
99733
+ terminalNotificationKeys: /* @__PURE__ */ new Set(),
99734
+ terminalFocused: true,
99735
+ osc9Supported: supportsOsc9Notification(),
99736
+ insideTmux: isInsideTmux(),
99626
99737
  loadingAnimation: void 0,
99627
99738
  phaseSpinner: void 0,
99628
99739
  activeThinkingComponent: void 0,
@@ -99631,6 +99742,7 @@ function createTUIState(options) {
99631
99742
  activeCompactionBlock: void 0,
99632
99743
  toolOutputExpanded: false,
99633
99744
  lastActivityMode: void 0,
99745
+ terminalProgressActive: false,
99634
99746
  lastHistoryContent: void 0,
99635
99747
  pendingToolComponents: /* @__PURE__ */ new Map(),
99636
99748
  pendingAgentGroup: null,
@@ -101388,7 +101500,8 @@ async function applyThemeChoice(state, theme, hooks) {
101388
101500
  try {
101389
101501
  await saveTuiConfig({
101390
101502
  theme,
101391
- editorCommand: state.appState.editorCommand
101503
+ editorCommand: state.appState.editorCommand,
101504
+ notifications: state.appState.notifications
101392
101505
  });
101393
101506
  } catch (error) {
101394
101507
  emitStatus(state, `Failed to save theme: ${error instanceof Error ? error.message : String(error)}`, state.colors.error);
@@ -101954,6 +102067,10 @@ function handleCompactionEnd(ectx, data, sendQueued) {
101954
102067
  //#region src/tui/handlers/notification.ts
101955
102068
  function handleNotification(ectx, data) {
101956
102069
  pushToast(ectx, data);
102070
+ notifyTerminalOnce(ectx.state, `wire:${data.id}`, {
102071
+ title: data.title,
102072
+ body: data.body
102073
+ });
101957
102074
  }
101958
102075
  //#endregion
101959
102076
  //#region src/tui/handlers/dispatch.ts
@@ -102089,7 +102206,8 @@ async function applyEditorChoice(state, value, hooks) {
102089
102206
  try {
102090
102207
  await saveTuiConfig({
102091
102208
  theme: state.appState.theme,
102092
- editorCommand
102209
+ editorCommand,
102210
+ notifications: state.appState.notifications
102093
102211
  });
102094
102212
  } catch (error) {
102095
102213
  emitStatus(state, `Failed to save editor: ${error instanceof Error ? error.message : String(error)}`, state.colors.error);
@@ -102722,7 +102840,8 @@ var MoonLoader = class extends Text {
102722
102840
  * progress across renders.
102723
102841
  */
102724
102842
  function updateActivityPane(state) {
102725
- const effectiveMode = state.showingSessionPicker ? "hidden" : state.livePane.pendingApproval !== null ? "hidden" : state.appState.isCompacting ? "hidden" : state.livePane.pendingQuestion !== null ? "hidden" : state.livePane.mode === "idle" && state.appState.streamingPhase === "composing" ? "composing" : state.livePane.mode;
102843
+ const effectiveMode = state.showingSessionPicker ? "hidden" : state.livePane.pendingApproval !== null ? "hidden" : state.appState.isCompacting ? "hidden" : state.livePane.pendingQuestion !== null ? "hidden" : state.livePane.mode === "idle" && isVisibleStreamingPhase(state.appState.streamingPhase) ? state.appState.streamingPhase : state.livePane.mode;
102844
+ syncTerminalProgress(state, shouldShowTerminalProgress(state, effectiveMode));
102726
102845
  if (effectiveMode === state.lastActivityMode && (effectiveMode === "waiting" || effectiveMode === "tool")) return;
102727
102846
  state.lastActivityMode = effectiveMode;
102728
102847
  mutateBottomSlot(state, state.activityContainer, () => {
@@ -102765,6 +102884,18 @@ function updateActivityPane(state) {
102765
102884
  }
102766
102885
  });
102767
102886
  }
102887
+ function shouldShowTerminalProgress(state, effectiveMode) {
102888
+ if (state.appState.isCompacting) return true;
102889
+ return effectiveMode === "waiting" || effectiveMode === "thinking" || effectiveMode === "composing" || effectiveMode === "tool";
102890
+ }
102891
+ function isVisibleStreamingPhase(phase) {
102892
+ return phase === "thinking" || phase === "composing";
102893
+ }
102894
+ function syncTerminalProgress(state, active) {
102895
+ if (state.terminalProgressActive === active) return;
102896
+ state.terminal.setProgress(active);
102897
+ state.terminalProgressActive = active;
102898
+ }
102768
102899
  function stopLoader(state) {
102769
102900
  if (state.loadingAnimation) {
102770
102901
  state.loadingAnimation.stop();
@@ -103355,6 +103486,10 @@ function buildNumericHint(count) {
103355
103486
  //#region src/tui/reverse-rpc/approval/ui.ts
103356
103487
  function showApprovalPanel(state, payload) {
103357
103488
  state.livePane.pendingApproval = { data: payload };
103489
+ notifyTerminalOnce(state, `approval:${payload.id}`, {
103490
+ title: "Kimi Code approval required",
103491
+ body: payload.tool_name
103492
+ });
103358
103493
  updateActivityPane(state);
103359
103494
  mountPanel(state, new ApprovalPanelComponent({ data: payload }, (response) => {
103360
103495
  state.approvalController.respond(adaptPanelResponse(response));
@@ -103936,6 +104071,10 @@ var QuestionDialogComponent = class extends Container {
103936
104071
  //#region src/tui/reverse-rpc/question/ui.ts
103937
104072
  function showQuestionDialog(state, payload) {
103938
104073
  state.livePane.pendingQuestion = { data: payload };
104074
+ notifyTerminalOnce(state, `question:${payload.id}`, {
104075
+ title: "Kimi Code needs your answer",
104076
+ body: payload.questions[0]?.question
104077
+ });
103939
104078
  updateActivityPane(state);
103940
104079
  mountPanel(state, new QuestionDialogComponent({ data: payload }, (answers) => {
103941
104080
  state.questionController.respond(answers);
@@ -104983,12 +105122,40 @@ async function loadPersistedInputHistory(state) {
104983
105122
  } catch {}
104984
105123
  }
104985
105124
  //#endregion
105125
+ //#region src/tui/utils/terminal-focus.ts
105126
+ const ESC = "\x1B";
105127
+ const TERMINAL_FOCUS_IN = `${ESC}[I`;
105128
+ const TERMINAL_FOCUS_OUT = `${ESC}[O`;
105129
+ const ENABLE_TERMINAL_FOCUS_REPORTING = `${ESC}[?1004h`;
105130
+ const DISABLE_TERMINAL_FOCUS_REPORTING = `${ESC}[?1004l`;
105131
+ function installTerminalFocusTracking(state) {
105132
+ state.terminalFocused = true;
105133
+ const disposeInputListener = state.ui.addInputListener((data) => handleTerminalFocusInput(state, data));
105134
+ state.terminal.write(ENABLE_TERMINAL_FOCUS_REPORTING);
105135
+ return () => {
105136
+ disposeInputListener();
105137
+ state.terminal.write(DISABLE_TERMINAL_FOCUS_REPORTING);
105138
+ state.terminalFocused = true;
105139
+ };
105140
+ }
105141
+ function handleTerminalFocusInput(state, data) {
105142
+ if (data === TERMINAL_FOCUS_IN) {
105143
+ state.terminalFocused = true;
105144
+ return { consume: true };
105145
+ }
105146
+ if (data === TERMINAL_FOCUS_OUT) {
105147
+ state.terminalFocused = false;
105148
+ return { consume: true };
105149
+ }
105150
+ }
105151
+ //#endregion
104986
105152
  //#region src/tui/kimi-tui.ts
104987
105153
  var KimiTUI = class {
104988
105154
  state;
104989
105155
  stateHooks;
104990
105156
  streamCallbacks;
104991
105157
  reverseRpcDisposers = [];
105158
+ terminalFocusTrackingDispose;
104992
105159
  onExit;
104993
105160
  constructor(client, initialState, options) {
104994
105161
  this.state = createTUIState({
@@ -105044,6 +105211,7 @@ var KimiTUI = class {
105044
105211
  this.state.editorContainer.addChild(this.state.editor);
105045
105212
  this.state.ui.setFocus(this.state.editor);
105046
105213
  this.state.ui.start();
105214
+ this.terminalFocusTrackingDispose = installTerminalFocusTracking(this.state);
105047
105215
  attachFooterFeed(this.state, buildFooterFeedHandlers(this.state));
105048
105216
  if (this.state.startupNotice !== void 0) {
105049
105217
  emitMuted(this.state, this.state.startupNotice);
@@ -105147,6 +105315,8 @@ var KimiTUI = class {
105147
105315
  this.reverseRpcDisposers.length = 0;
105148
105316
  this.state.approvalController.cancelAll("shutting down");
105149
105317
  this.state.questionController.cancelAll("shutting down");
105318
+ this.terminalFocusTrackingDispose?.();
105319
+ this.terminalFocusTrackingDispose = void 0;
105150
105320
  this.state.ui.stop();
105151
105321
  if (this.onExit) await this.onExit();
105152
105322
  }
@@ -105294,6 +105464,7 @@ async function runShell(opts, version) {
105294
105464
  theme: tuiConfig.theme,
105295
105465
  version,
105296
105466
  editorCommand: tuiConfig.editorCommand,
105467
+ notifications: tuiConfig.notifications,
105297
105468
  availableModels: ctx.availableModels,
105298
105469
  sessionTitle: null
105299
105470
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kfc-code-cli",
3
- "version": "0.0.1-alpha.18",
3
+ "version": "0.0.1-alpha.19",
4
4
  "description": "KFC crazy ",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@mariozechner/clipboard": "^0.3.2",
30
- "@mariozechner/pi-tui": "^0.67.68",
30
+ "@mariozechner/pi-tui": "^0.70.6",
31
31
  "chalk": "^5.4.1",
32
32
  "cli-highlight": "^2.1.11",
33
33
  "clipboardy": "^4.0.0",