@mcp-use/inspector 0.9.0-canary.1 → 0.9.0-canary.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,23 @@
1
- import { _ as __name } from "./index-B6TgCktd.js";
1
+ import { bi as getDefaultExportFromCjs } from "./index-DlUHZ9Rv.js";
2
+ function _mergeNamespaces(n, m) {
3
+ for (var i = 0; i < m.length; i++) {
4
+ const e = m[i];
5
+ if (typeof e !== "string" && !Array.isArray(e)) {
6
+ for (const k in e) {
7
+ if (k !== "default" && !(k in n)) {
8
+ const d = Object.getOwnPropertyDescriptor(e, k);
9
+ if (d) {
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
20
+ }
2
21
  var core;
3
22
  var hasRequiredCore;
4
23
  function requireCore() {
@@ -257,10 +276,10 @@ function requireCore() {
257
276
  const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
258
277
  function join(regexps, separator = "|") {
259
278
  let numCaptures = 0;
260
- return regexps.map((regex2) => {
279
+ return regexps.map((regex) => {
261
280
  numCaptures += 1;
262
281
  const offset = numCaptures;
263
- let re = source2(regex2);
282
+ let re = source2(regex);
264
283
  let out = "";
265
284
  while (re.length > 0) {
266
285
  const match = BACKREF_RE.exec(re);
@@ -584,12 +603,12 @@ function requireCore() {
584
603
  this.regexIndex = 0;
585
604
  }
586
605
  // @ts-ignore
587
- getMatcher(index) {
588
- if (this.multiRegexes[index]) return this.multiRegexes[index];
606
+ getMatcher(index2) {
607
+ if (this.multiRegexes[index2]) return this.multiRegexes[index2];
589
608
  const matcher = new MultiRegex();
590
- this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
609
+ this.rules.slice(index2).forEach(([re, opts]) => matcher.addRule(re, opts));
591
610
  matcher.compile();
592
- this.multiRegexes[index] = matcher;
611
+ this.multiRegexes[index2] = matcher;
593
612
  return matcher;
594
613
  }
595
614
  resumingScanAtSamePosition() {
@@ -1179,7 +1198,7 @@ function requireCore() {
1179
1198
  processContinuations();
1180
1199
  let modeBuffer = "";
1181
1200
  let relevance = 0;
1182
- let index = 0;
1201
+ let index2 = 0;
1183
1202
  let iterations = 0;
1184
1203
  let resumeScanAtSamePosition = false;
1185
1204
  try {
@@ -1191,14 +1210,14 @@ function requireCore() {
1191
1210
  } else {
1192
1211
  top.matcher.considerAll();
1193
1212
  }
1194
- top.matcher.lastIndex = index;
1213
+ top.matcher.lastIndex = index2;
1195
1214
  const match = top.matcher.exec(codeToHighlight);
1196
1215
  if (!match) break;
1197
- const beforeMatch = codeToHighlight.substring(index, match.index);
1216
+ const beforeMatch = codeToHighlight.substring(index2, match.index);
1198
1217
  const processedCount = processLexeme(beforeMatch, match);
1199
- index = match.index + processedCount;
1218
+ index2 = match.index + processedCount;
1200
1219
  }
1201
- processLexeme(codeToHighlight.substr(index));
1220
+ processLexeme(codeToHighlight.substr(index2));
1202
1221
  emitter.closeAllNodes();
1203
1222
  emitter.finalize();
1204
1223
  result = emitter.toHTML();
@@ -1218,7 +1237,7 @@ function requireCore() {
1218
1237
  illegal: true,
1219
1238
  illegalBy: {
1220
1239
  msg: err.message,
1221
- context: codeToHighlight.slice(index - 100, index + 100),
1240
+ context: codeToHighlight.slice(index2 - 100, index2 + 100),
1222
1241
  mode: err.mode
1223
1242
  },
1224
1243
  sofar: result,
@@ -34838,383 +34857,6 @@ function requireZephir() {
34838
34857
  zephir_1 = zephir;
34839
34858
  return zephir_1;
34840
34859
  }
34841
- const ANSI_BACKGROUND_OFFSET = 10;
34842
- const wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
34843
- const wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
34844
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
34845
- const styles$1 = {
34846
- modifier: {
34847
- reset: [0, 0],
34848
- // 21 isn't widely supported and 22 does the same thing
34849
- bold: [1, 22],
34850
- dim: [2, 22],
34851
- italic: [3, 23],
34852
- underline: [4, 24],
34853
- overline: [53, 55],
34854
- inverse: [7, 27],
34855
- hidden: [8, 28],
34856
- strikethrough: [9, 29]
34857
- },
34858
- color: {
34859
- black: [30, 39],
34860
- red: [31, 39],
34861
- green: [32, 39],
34862
- yellow: [33, 39],
34863
- blue: [34, 39],
34864
- magenta: [35, 39],
34865
- cyan: [36, 39],
34866
- white: [37, 39],
34867
- // Bright color
34868
- blackBright: [90, 39],
34869
- gray: [90, 39],
34870
- // Alias of `blackBright`
34871
- grey: [90, 39],
34872
- // Alias of `blackBright`
34873
- redBright: [91, 39],
34874
- greenBright: [92, 39],
34875
- yellowBright: [93, 39],
34876
- blueBright: [94, 39],
34877
- magentaBright: [95, 39],
34878
- cyanBright: [96, 39],
34879
- whiteBright: [97, 39]
34880
- },
34881
- bgColor: {
34882
- bgBlack: [40, 49],
34883
- bgRed: [41, 49],
34884
- bgGreen: [42, 49],
34885
- bgYellow: [43, 49],
34886
- bgBlue: [44, 49],
34887
- bgMagenta: [45, 49],
34888
- bgCyan: [46, 49],
34889
- bgWhite: [47, 49],
34890
- // Bright color
34891
- bgBlackBright: [100, 49],
34892
- bgGray: [100, 49],
34893
- // Alias of `bgBlackBright`
34894
- bgGrey: [100, 49],
34895
- // Alias of `bgBlackBright`
34896
- bgRedBright: [101, 49],
34897
- bgGreenBright: [102, 49],
34898
- bgYellowBright: [103, 49],
34899
- bgBlueBright: [104, 49],
34900
- bgMagentaBright: [105, 49],
34901
- bgCyanBright: [106, 49],
34902
- bgWhiteBright: [107, 49]
34903
- }
34904
- };
34905
- Object.keys(styles$1.modifier);
34906
- const foregroundColorNames = Object.keys(styles$1.color);
34907
- const backgroundColorNames = Object.keys(styles$1.bgColor);
34908
- [...foregroundColorNames, ...backgroundColorNames];
34909
- function assembleStyles() {
34910
- const codes = /* @__PURE__ */ new Map();
34911
- for (const [groupName, group] of Object.entries(styles$1)) {
34912
- for (const [styleName, style] of Object.entries(group)) {
34913
- styles$1[styleName] = {
34914
- open: `\x1B[${style[0]}m`,
34915
- close: `\x1B[${style[1]}m`
34916
- };
34917
- group[styleName] = styles$1[styleName];
34918
- codes.set(style[0], style[1]);
34919
- }
34920
- Object.defineProperty(styles$1, groupName, {
34921
- value: group,
34922
- enumerable: false
34923
- });
34924
- }
34925
- Object.defineProperty(styles$1, "codes", {
34926
- value: codes,
34927
- enumerable: false
34928
- });
34929
- styles$1.color.close = "\x1B[39m";
34930
- styles$1.bgColor.close = "\x1B[49m";
34931
- styles$1.color.ansi = wrapAnsi16();
34932
- styles$1.color.ansi256 = wrapAnsi256();
34933
- styles$1.color.ansi16m = wrapAnsi16m();
34934
- styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
34935
- styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
34936
- styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
34937
- Object.defineProperties(styles$1, {
34938
- rgbToAnsi256: {
34939
- value(red, green, blue) {
34940
- if (red === green && green === blue) {
34941
- if (red < 8) {
34942
- return 16;
34943
- }
34944
- if (red > 248) {
34945
- return 231;
34946
- }
34947
- return Math.round((red - 8) / 247 * 24) + 232;
34948
- }
34949
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
34950
- },
34951
- enumerable: false
34952
- },
34953
- hexToRgb: {
34954
- value(hex) {
34955
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
34956
- if (!matches) {
34957
- return [0, 0, 0];
34958
- }
34959
- let [colorString] = matches;
34960
- if (colorString.length === 3) {
34961
- colorString = [...colorString].map((character) => character + character).join("");
34962
- }
34963
- const integer = Number.parseInt(colorString, 16);
34964
- return [
34965
- /* eslint-disable no-bitwise */
34966
- integer >> 16 & 255,
34967
- integer >> 8 & 255,
34968
- integer & 255
34969
- /* eslint-enable no-bitwise */
34970
- ];
34971
- },
34972
- enumerable: false
34973
- },
34974
- hexToAnsi256: {
34975
- value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
34976
- enumerable: false
34977
- },
34978
- ansi256ToAnsi: {
34979
- value(code) {
34980
- if (code < 8) {
34981
- return 30 + code;
34982
- }
34983
- if (code < 16) {
34984
- return 90 + (code - 8);
34985
- }
34986
- let red;
34987
- let green;
34988
- let blue;
34989
- if (code >= 232) {
34990
- red = ((code - 232) * 10 + 8) / 255;
34991
- green = red;
34992
- blue = red;
34993
- } else {
34994
- code -= 16;
34995
- const remainder = code % 36;
34996
- red = Math.floor(code / 36) / 5;
34997
- green = Math.floor(remainder / 6) / 5;
34998
- blue = remainder % 6 / 5;
34999
- }
35000
- const value = Math.max(red, green, blue) * 2;
35001
- if (value === 0) {
35002
- return 30;
35003
- }
35004
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
35005
- if (value === 2) {
35006
- result += 60;
35007
- }
35008
- return result;
35009
- },
35010
- enumerable: false
35011
- },
35012
- rgbToAnsi: {
35013
- value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
35014
- enumerable: false
35015
- },
35016
- hexToAnsi: {
35017
- value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
35018
- enumerable: false
35019
- }
35020
- });
35021
- return styles$1;
35022
- }
35023
- const ansiStyles$1 = assembleStyles();
35024
- const level = (() => {
35025
- if (!("navigator" in globalThis)) {
35026
- return 0;
35027
- }
35028
- if (globalThis.navigator.userAgentData) {
35029
- const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
35030
- if (brand && brand.version > 93) {
35031
- return 3;
35032
- }
35033
- }
35034
- if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
35035
- return 1;
35036
- }
35037
- return 0;
35038
- })();
35039
- const colorSupport = level !== 0 && {
35040
- level
35041
- };
35042
- const supportsColor = {
35043
- stdout: colorSupport,
35044
- stderr: colorSupport
35045
- };
35046
- function stringReplaceAll(string, substring, replacer) {
35047
- let index = string.indexOf(substring);
35048
- if (index === -1) {
35049
- return string;
35050
- }
35051
- const substringLength = substring.length;
35052
- let endIndex = 0;
35053
- let returnValue = "";
35054
- do {
35055
- returnValue += string.slice(endIndex, index) + substring + replacer;
35056
- endIndex = index + substringLength;
35057
- index = string.indexOf(substring, endIndex);
35058
- } while (index !== -1);
35059
- returnValue += string.slice(endIndex);
35060
- return returnValue;
35061
- }
35062
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
35063
- let endIndex = 0;
35064
- let returnValue = "";
35065
- do {
35066
- const gotCR = string[index - 1] === "\r";
35067
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
35068
- endIndex = index + 1;
35069
- index = string.indexOf("\n", endIndex);
35070
- } while (index !== -1);
35071
- returnValue += string.slice(endIndex);
35072
- return returnValue;
35073
- }
35074
- const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
35075
- const GENERATOR = Symbol("GENERATOR");
35076
- const STYLER = Symbol("STYLER");
35077
- const IS_EMPTY = Symbol("IS_EMPTY");
35078
- const levelMapping = [
35079
- "ansi",
35080
- "ansi",
35081
- "ansi256",
35082
- "ansi16m"
35083
- ];
35084
- const styles = /* @__PURE__ */ Object.create(null);
35085
- const applyOptions = (object, options = {}) => {
35086
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
35087
- throw new Error("The `level` option should be an integer from 0 to 3");
35088
- }
35089
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
35090
- object.level = options.level === void 0 ? colorLevel : options.level;
35091
- };
35092
- const chalkFactory = (options) => {
35093
- const chalk2 = (...strings) => strings.join(" ");
35094
- applyOptions(chalk2, options);
35095
- Object.setPrototypeOf(chalk2, createChalk.prototype);
35096
- return chalk2;
35097
- };
35098
- function createChalk(options) {
35099
- return chalkFactory(options);
35100
- }
35101
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
35102
- for (const [styleName, style] of Object.entries(ansiStyles$1)) {
35103
- styles[styleName] = {
35104
- get() {
35105
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
35106
- Object.defineProperty(this, styleName, { value: builder });
35107
- return builder;
35108
- }
35109
- };
35110
- }
35111
- styles.visible = {
35112
- get() {
35113
- const builder = createBuilder(this, this[STYLER], true);
35114
- Object.defineProperty(this, "visible", { value: builder });
35115
- return builder;
35116
- }
35117
- };
35118
- const getModelAnsi = (model, level2, type, ...arguments_) => {
35119
- if (model === "rgb") {
35120
- if (level2 === "ansi16m") {
35121
- return ansiStyles$1[type].ansi16m(...arguments_);
35122
- }
35123
- if (level2 === "ansi256") {
35124
- return ansiStyles$1[type].ansi256(ansiStyles$1.rgbToAnsi256(...arguments_));
35125
- }
35126
- return ansiStyles$1[type].ansi(ansiStyles$1.rgbToAnsi(...arguments_));
35127
- }
35128
- if (model === "hex") {
35129
- return getModelAnsi("rgb", level2, type, ...ansiStyles$1.hexToRgb(...arguments_));
35130
- }
35131
- return ansiStyles$1[type][model](...arguments_);
35132
- };
35133
- const usedModels = ["rgb", "hex", "ansi256"];
35134
- for (const model of usedModels) {
35135
- styles[model] = {
35136
- get() {
35137
- const { level: level2 } = this;
35138
- return function(...arguments_) {
35139
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansiStyles$1.color.close, this[STYLER]);
35140
- return createBuilder(this, styler, this[IS_EMPTY]);
35141
- };
35142
- }
35143
- };
35144
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
35145
- styles[bgModel] = {
35146
- get() {
35147
- const { level: level2 } = this;
35148
- return function(...arguments_) {
35149
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansiStyles$1.bgColor.close, this[STYLER]);
35150
- return createBuilder(this, styler, this[IS_EMPTY]);
35151
- };
35152
- }
35153
- };
35154
- }
35155
- const proto = Object.defineProperties(() => {
35156
- }, {
35157
- ...styles,
35158
- level: {
35159
- enumerable: true,
35160
- get() {
35161
- return this[GENERATOR].level;
35162
- },
35163
- set(level2) {
35164
- this[GENERATOR].level = level2;
35165
- }
35166
- }
35167
- });
35168
- const createStyler = (open, close, parent) => {
35169
- let openAll;
35170
- let closeAll;
35171
- if (parent === void 0) {
35172
- openAll = open;
35173
- closeAll = close;
35174
- } else {
35175
- openAll = parent.openAll + open;
35176
- closeAll = close + parent.closeAll;
35177
- }
35178
- return {
35179
- open,
35180
- close,
35181
- openAll,
35182
- closeAll,
35183
- parent
35184
- };
35185
- };
35186
- const createBuilder = (self, _styler, _isEmpty) => {
35187
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
35188
- Object.setPrototypeOf(builder, proto);
35189
- builder[GENERATOR] = self;
35190
- builder[STYLER] = _styler;
35191
- builder[IS_EMPTY] = _isEmpty;
35192
- return builder;
35193
- };
35194
- const applyStyle = (self, string) => {
35195
- if (self.level <= 0 || !string) {
35196
- return self[IS_EMPTY] ? "" : string;
35197
- }
35198
- let styler = self[STYLER];
35199
- if (styler === void 0) {
35200
- return string;
35201
- }
35202
- const { openAll, closeAll } = styler;
35203
- if (string.includes("\x1B")) {
35204
- while (styler !== void 0) {
35205
- string = stringReplaceAll(string, styler.close, styler.open);
35206
- styler = styler.parent;
35207
- }
35208
- }
35209
- const lfIndex = string.indexOf("\n");
35210
- if (lfIndex !== -1) {
35211
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
35212
- }
35213
- return openAll + string + closeAll;
35214
- };
35215
- Object.defineProperties(createChalk.prototype, styles);
35216
- const chalk = createChalk();
35217
- createChalk({ level: stderrColor ? stderrColor.level : 0 });
35218
34860
  var dist = {};
35219
34861
  var lib$2;
35220
34862
  var hasRequiredLib$2;
@@ -43503,15 +43145,15 @@ function requireAnsiStyles() {
43503
43145
  if (hasRequiredAnsiStyles) return ansiStyles.exports;
43504
43146
  hasRequiredAnsiStyles = 1;
43505
43147
  (function(module) {
43506
- const wrapAnsi162 = (fn, offset) => (...args) => {
43148
+ const wrapAnsi16 = (fn, offset) => (...args) => {
43507
43149
  const code = fn(...args);
43508
43150
  return `\x1B[${code + offset}m`;
43509
43151
  };
43510
- const wrapAnsi2562 = (fn, offset) => (...args) => {
43152
+ const wrapAnsi256 = (fn, offset) => (...args) => {
43511
43153
  const code = fn(...args);
43512
43154
  return `\x1B[${38 + offset};5;${code}m`;
43513
43155
  };
43514
- const wrapAnsi16m2 = (fn, offset) => (...args) => {
43156
+ const wrapAnsi16m = (fn, offset) => (...args) => {
43515
43157
  const rgb = fn(...args);
43516
43158
  return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
43517
43159
  };
@@ -43538,20 +43180,20 @@ function requireAnsiStyles() {
43538
43180
  colorConvert2 = requireColorConvert();
43539
43181
  }
43540
43182
  const offset = isBackground ? 10 : 0;
43541
- const styles2 = {};
43183
+ const styles = {};
43542
43184
  for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
43543
43185
  const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
43544
43186
  if (sourceSpace === targetSpace) {
43545
- styles2[name] = wrap(identity, offset);
43187
+ styles[name] = wrap(identity, offset);
43546
43188
  } else if (typeof suite === "object") {
43547
- styles2[name] = wrap(suite[targetSpace], offset);
43189
+ styles[name] = wrap(suite[targetSpace], offset);
43548
43190
  }
43549
43191
  }
43550
- return styles2;
43192
+ return styles;
43551
43193
  };
43552
- function assembleStyles2() {
43194
+ function assembleStyles() {
43553
43195
  const codes = /* @__PURE__ */ new Map();
43554
- const styles2 = {
43196
+ const styles = {
43555
43197
  modifier: {
43556
43198
  reset: [0, 0],
43557
43199
  // 21 isn't widely supported and 22 does the same thing
@@ -43602,41 +43244,41 @@ function requireAnsiStyles() {
43602
43244
  bgWhiteBright: [107, 49]
43603
43245
  }
43604
43246
  };
43605
- styles2.color.gray = styles2.color.blackBright;
43606
- styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
43607
- styles2.color.grey = styles2.color.blackBright;
43608
- styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
43609
- for (const [groupName, group] of Object.entries(styles2)) {
43247
+ styles.color.gray = styles.color.blackBright;
43248
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
43249
+ styles.color.grey = styles.color.blackBright;
43250
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
43251
+ for (const [groupName, group] of Object.entries(styles)) {
43610
43252
  for (const [styleName, style] of Object.entries(group)) {
43611
- styles2[styleName] = {
43253
+ styles[styleName] = {
43612
43254
  open: `\x1B[${style[0]}m`,
43613
43255
  close: `\x1B[${style[1]}m`
43614
43256
  };
43615
- group[styleName] = styles2[styleName];
43257
+ group[styleName] = styles[styleName];
43616
43258
  codes.set(style[0], style[1]);
43617
43259
  }
43618
- Object.defineProperty(styles2, groupName, {
43260
+ Object.defineProperty(styles, groupName, {
43619
43261
  value: group,
43620
43262
  enumerable: false
43621
43263
  });
43622
43264
  }
43623
- Object.defineProperty(styles2, "codes", {
43265
+ Object.defineProperty(styles, "codes", {
43624
43266
  value: codes,
43625
43267
  enumerable: false
43626
43268
  });
43627
- styles2.color.close = "\x1B[39m";
43628
- styles2.bgColor.close = "\x1B[49m";
43629
- setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi162, "ansi16", ansi2ansi, false));
43630
- setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi2562, "ansi256", ansi2ansi, false));
43631
- setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m2, "rgb", rgb2rgb, false));
43632
- setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi162, "ansi16", ansi2ansi, true));
43633
- setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi2562, "ansi256", ansi2ansi, true));
43634
- setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m2, "rgb", rgb2rgb, true));
43635
- return styles2;
43269
+ styles.color.close = "\x1B[39m";
43270
+ styles.bgColor.close = "\x1B[49m";
43271
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
43272
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
43273
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
43274
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
43275
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
43276
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
43277
+ return styles;
43636
43278
  }
43637
43279
  Object.defineProperty(module, "exports", {
43638
43280
  enumerable: true,
43639
- get: assembleStyles2
43281
+ get: assembleStyles
43640
43282
  });
43641
43283
  })(ansiStyles);
43642
43284
  return ansiStyles.exports;
@@ -43657,37 +43299,37 @@ var hasRequiredUtil;
43657
43299
  function requireUtil() {
43658
43300
  if (hasRequiredUtil) return util;
43659
43301
  hasRequiredUtil = 1;
43660
- const stringReplaceAll2 = (string, substring, replacer) => {
43661
- let index = string.indexOf(substring);
43662
- if (index === -1) {
43302
+ const stringReplaceAll = (string, substring, replacer) => {
43303
+ let index2 = string.indexOf(substring);
43304
+ if (index2 === -1) {
43663
43305
  return string;
43664
43306
  }
43665
43307
  const substringLength = substring.length;
43666
43308
  let endIndex = 0;
43667
43309
  let returnValue = "";
43668
43310
  do {
43669
- returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
43670
- endIndex = index + substringLength;
43671
- index = string.indexOf(substring, endIndex);
43672
- } while (index !== -1);
43311
+ returnValue += string.substr(endIndex, index2 - endIndex) + substring + replacer;
43312
+ endIndex = index2 + substringLength;
43313
+ index2 = string.indexOf(substring, endIndex);
43314
+ } while (index2 !== -1);
43673
43315
  returnValue += string.substr(endIndex);
43674
43316
  return returnValue;
43675
43317
  };
43676
- const stringEncaseCRLFWithFirstIndex2 = (string, prefix, postfix, index) => {
43318
+ const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index2) => {
43677
43319
  let endIndex = 0;
43678
43320
  let returnValue = "";
43679
43321
  do {
43680
- const gotCR = string[index - 1] === "\r";
43681
- returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
43682
- endIndex = index + 1;
43683
- index = string.indexOf("\n", endIndex);
43684
- } while (index !== -1);
43322
+ const gotCR = string[index2 - 1] === "\r";
43323
+ returnValue += string.substr(endIndex, (gotCR ? index2 - 1 : index2) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
43324
+ endIndex = index2 + 1;
43325
+ index2 = string.indexOf("\n", endIndex);
43326
+ } while (index2 !== -1);
43685
43327
  returnValue += string.substr(endIndex);
43686
43328
  return returnValue;
43687
43329
  };
43688
43330
  util = {
43689
- stringReplaceAll: stringReplaceAll2,
43690
- stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex2
43331
+ stringReplaceAll,
43332
+ stringEncaseCRLFWithFirstIndex
43691
43333
  };
43692
43334
  return util;
43693
43335
  }
@@ -43754,27 +43396,27 @@ function requireTemplates() {
43754
43396
  }
43755
43397
  return results;
43756
43398
  }
43757
- function buildStyle(chalk2, styles2) {
43399
+ function buildStyle(chalk, styles) {
43758
43400
  const enabled = {};
43759
- for (const layer of styles2) {
43401
+ for (const layer of styles) {
43760
43402
  for (const style of layer.styles) {
43761
43403
  enabled[style[0]] = layer.inverse ? null : style.slice(1);
43762
43404
  }
43763
43405
  }
43764
- let current = chalk2;
43765
- for (const [styleName, styles3] of Object.entries(enabled)) {
43766
- if (!Array.isArray(styles3)) {
43406
+ let current = chalk;
43407
+ for (const [styleName, styles2] of Object.entries(enabled)) {
43408
+ if (!Array.isArray(styles2)) {
43767
43409
  continue;
43768
43410
  }
43769
43411
  if (!(styleName in current)) {
43770
43412
  throw new Error(`Unknown Chalk style: ${styleName}`);
43771
43413
  }
43772
- current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
43414
+ current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
43773
43415
  }
43774
43416
  return current;
43775
43417
  }
43776
- templates = (chalk2, temporary) => {
43777
- const styles2 = [];
43418
+ templates = (chalk, temporary) => {
43419
+ const styles = [];
43778
43420
  const chunks = [];
43779
43421
  let chunk = [];
43780
43422
  temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
@@ -43783,22 +43425,22 @@ function requireTemplates() {
43783
43425
  } else if (style) {
43784
43426
  const string = chunk.join("");
43785
43427
  chunk = [];
43786
- chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
43787
- styles2.push({ inverse, styles: parseStyle(style) });
43428
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
43429
+ styles.push({ inverse, styles: parseStyle(style) });
43788
43430
  } else if (close) {
43789
- if (styles2.length === 0) {
43431
+ if (styles.length === 0) {
43790
43432
  throw new Error("Found extraneous } in Chalk template literal");
43791
43433
  }
43792
- chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
43434
+ chunks.push(buildStyle(chalk, styles)(chunk.join("")));
43793
43435
  chunk = [];
43794
- styles2.pop();
43436
+ styles.pop();
43795
43437
  } else {
43796
43438
  chunk.push(character);
43797
43439
  }
43798
43440
  });
43799
43441
  chunks.push(chunk.join(""));
43800
- if (styles2.length > 0) {
43801
- const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
43442
+ if (styles.length > 0) {
43443
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
43802
43444
  throw new Error(errMessage);
43803
43445
  }
43804
43446
  return chunks.join("");
@@ -43811,100 +43453,100 @@ function requireSource() {
43811
43453
  if (hasRequiredSource) return source;
43812
43454
  hasRequiredSource = 1;
43813
43455
  const ansiStyles2 = requireAnsiStyles();
43814
- const { stdout: stdoutColor2, stderr: stderrColor2 } = requireBrowser();
43456
+ const { stdout: stdoutColor, stderr: stderrColor } = requireBrowser();
43815
43457
  const {
43816
- stringReplaceAll: stringReplaceAll2,
43817
- stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex2
43458
+ stringReplaceAll,
43459
+ stringEncaseCRLFWithFirstIndex
43818
43460
  } = requireUtil();
43819
43461
  const { isArray } = Array;
43820
- const levelMapping2 = [
43462
+ const levelMapping = [
43821
43463
  "ansi",
43822
43464
  "ansi",
43823
43465
  "ansi256",
43824
43466
  "ansi16m"
43825
43467
  ];
43826
- const styles2 = /* @__PURE__ */ Object.create(null);
43827
- const applyOptions2 = (object, options = {}) => {
43468
+ const styles = /* @__PURE__ */ Object.create(null);
43469
+ const applyOptions = (object, options = {}) => {
43828
43470
  if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
43829
43471
  throw new Error("The `level` option should be an integer from 0 to 3");
43830
43472
  }
43831
- const colorLevel = stdoutColor2 ? stdoutColor2.level : 0;
43473
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
43832
43474
  object.level = options.level === void 0 ? colorLevel : options.level;
43833
43475
  };
43834
43476
  class ChalkClass {
43835
43477
  constructor(options) {
43836
- return chalkFactory2(options);
43478
+ return chalkFactory(options);
43837
43479
  }
43838
43480
  }
43839
- const chalkFactory2 = (options) => {
43840
- const chalk3 = {};
43841
- applyOptions2(chalk3, options);
43842
- chalk3.template = (...arguments_) => chalkTag(chalk3.template, ...arguments_);
43843
- Object.setPrototypeOf(chalk3, Chalk.prototype);
43844
- Object.setPrototypeOf(chalk3.template, chalk3);
43845
- chalk3.template.constructor = () => {
43481
+ const chalkFactory = (options) => {
43482
+ const chalk2 = {};
43483
+ applyOptions(chalk2, options);
43484
+ chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
43485
+ Object.setPrototypeOf(chalk2, Chalk.prototype);
43486
+ Object.setPrototypeOf(chalk2.template, chalk2);
43487
+ chalk2.template.constructor = () => {
43846
43488
  throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
43847
43489
  };
43848
- chalk3.template.Instance = ChalkClass;
43849
- return chalk3.template;
43490
+ chalk2.template.Instance = ChalkClass;
43491
+ return chalk2.template;
43850
43492
  };
43851
43493
  function Chalk(options) {
43852
- return chalkFactory2(options);
43494
+ return chalkFactory(options);
43853
43495
  }
43854
43496
  for (const [styleName, style] of Object.entries(ansiStyles2)) {
43855
- styles2[styleName] = {
43497
+ styles[styleName] = {
43856
43498
  get() {
43857
- const builder = createBuilder2(this, createStyler2(style.open, style.close, this._styler), this._isEmpty);
43499
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
43858
43500
  Object.defineProperty(this, styleName, { value: builder });
43859
43501
  return builder;
43860
43502
  }
43861
43503
  };
43862
43504
  }
43863
- styles2.visible = {
43505
+ styles.visible = {
43864
43506
  get() {
43865
- const builder = createBuilder2(this, this._styler, true);
43507
+ const builder = createBuilder(this, this._styler, true);
43866
43508
  Object.defineProperty(this, "visible", { value: builder });
43867
43509
  return builder;
43868
43510
  }
43869
43511
  };
43870
- const usedModels2 = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
43871
- for (const model of usedModels2) {
43872
- styles2[model] = {
43512
+ const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
43513
+ for (const model of usedModels) {
43514
+ styles[model] = {
43873
43515
  get() {
43874
- const { level: level2 } = this;
43516
+ const { level } = this;
43875
43517
  return function(...arguments_) {
43876
- const styler = createStyler2(ansiStyles2.color[levelMapping2[level2]][model](...arguments_), ansiStyles2.color.close, this._styler);
43877
- return createBuilder2(this, styler, this._isEmpty);
43518
+ const styler = createStyler(ansiStyles2.color[levelMapping[level]][model](...arguments_), ansiStyles2.color.close, this._styler);
43519
+ return createBuilder(this, styler, this._isEmpty);
43878
43520
  };
43879
43521
  }
43880
43522
  };
43881
43523
  }
43882
- for (const model of usedModels2) {
43524
+ for (const model of usedModels) {
43883
43525
  const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
43884
- styles2[bgModel] = {
43526
+ styles[bgModel] = {
43885
43527
  get() {
43886
- const { level: level2 } = this;
43528
+ const { level } = this;
43887
43529
  return function(...arguments_) {
43888
- const styler = createStyler2(ansiStyles2.bgColor[levelMapping2[level2]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
43889
- return createBuilder2(this, styler, this._isEmpty);
43530
+ const styler = createStyler(ansiStyles2.bgColor[levelMapping[level]][model](...arguments_), ansiStyles2.bgColor.close, this._styler);
43531
+ return createBuilder(this, styler, this._isEmpty);
43890
43532
  };
43891
43533
  }
43892
43534
  };
43893
43535
  }
43894
- const proto2 = Object.defineProperties(() => {
43536
+ const proto = Object.defineProperties(() => {
43895
43537
  }, {
43896
- ...styles2,
43538
+ ...styles,
43897
43539
  level: {
43898
43540
  enumerable: true,
43899
43541
  get() {
43900
43542
  return this._generator.level;
43901
43543
  },
43902
- set(level2) {
43903
- this._generator.level = level2;
43544
+ set(level) {
43545
+ this._generator.level = level;
43904
43546
  }
43905
43547
  }
43906
43548
  });
43907
- const createStyler2 = (open, close, parent) => {
43549
+ const createStyler = (open, close, parent) => {
43908
43550
  let openAll;
43909
43551
  let closeAll;
43910
43552
  if (parent === void 0) {
@@ -43922,20 +43564,20 @@ function requireSource() {
43922
43564
  parent
43923
43565
  };
43924
43566
  };
43925
- const createBuilder2 = (self, _styler, _isEmpty) => {
43567
+ const createBuilder = (self, _styler, _isEmpty) => {
43926
43568
  const builder = (...arguments_) => {
43927
43569
  if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
43928
- return applyStyle2(builder, chalkTag(builder, ...arguments_));
43570
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
43929
43571
  }
43930
- return applyStyle2(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
43572
+ return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
43931
43573
  };
43932
- Object.setPrototypeOf(builder, proto2);
43574
+ Object.setPrototypeOf(builder, proto);
43933
43575
  builder._generator = self;
43934
43576
  builder._styler = _styler;
43935
43577
  builder._isEmpty = _isEmpty;
43936
43578
  return builder;
43937
43579
  };
43938
- const applyStyle2 = (self, string) => {
43580
+ const applyStyle = (self, string) => {
43939
43581
  if (self.level <= 0 || !string) {
43940
43582
  return self._isEmpty ? "" : string;
43941
43583
  }
@@ -43946,18 +43588,18 @@ function requireSource() {
43946
43588
  const { openAll, closeAll } = styler;
43947
43589
  if (string.indexOf("\x1B") !== -1) {
43948
43590
  while (styler !== void 0) {
43949
- string = stringReplaceAll2(string, styler.close, styler.open);
43591
+ string = stringReplaceAll(string, styler.close, styler.open);
43950
43592
  styler = styler.parent;
43951
43593
  }
43952
43594
  }
43953
43595
  const lfIndex = string.indexOf("\n");
43954
43596
  if (lfIndex !== -1) {
43955
- string = stringEncaseCRLFWithFirstIndex2(string, closeAll, openAll, lfIndex);
43597
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
43956
43598
  }
43957
43599
  return openAll + string + closeAll;
43958
43600
  };
43959
43601
  let template;
43960
- const chalkTag = (chalk3, ...strings) => {
43602
+ const chalkTag = (chalk2, ...strings) => {
43961
43603
  const [firstString] = strings;
43962
43604
  if (!isArray(firstString) || !isArray(firstString.raw)) {
43963
43605
  return strings.join(" ");
@@ -43973,14 +43615,14 @@ function requireSource() {
43973
43615
  if (template === void 0) {
43974
43616
  template = requireTemplates();
43975
43617
  }
43976
- return template(chalk3, parts.join(""));
43618
+ return template(chalk2, parts.join(""));
43977
43619
  };
43978
- Object.defineProperties(Chalk.prototype, styles2);
43979
- const chalk2 = Chalk();
43980
- chalk2.supportsColor = stdoutColor2;
43981
- chalk2.stderr = Chalk({ level: stderrColor2 ? stderrColor2.level : 0 });
43982
- chalk2.stderr.supportsColor = stderrColor2;
43983
- source = chalk2;
43620
+ Object.defineProperties(Chalk.prototype, styles);
43621
+ const chalk = Chalk();
43622
+ chalk.supportsColor = stdoutColor;
43623
+ chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
43624
+ chalk.stderr.supportsColor = stderrColor;
43625
+ source = chalk;
43984
43626
  return source;
43985
43627
  }
43986
43628
  var hasRequiredTheme;
@@ -44313,430 +43955,11 @@ function requireDist() {
44313
43955
  return dist;
44314
43956
  }
44315
43957
  var distExports = requireDist();
44316
- function ansiRegex({ onlyFirst = false } = {}) {
44317
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
44318
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
44319
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
44320
- const pattern = `${osc}|${csi}`;
44321
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
44322
- }
44323
- const regex = ansiRegex();
44324
- function stripAnsi$1(string) {
44325
- if (typeof string !== "string") {
44326
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
44327
- }
44328
- return string.replace(regex, "");
44329
- }
44330
- var TERMINAL_WIDTH = process.stdout.columns || 120;
44331
- function stripAnsi(str) {
44332
- return stripAnsi$1(str);
44333
- }
44334
- __name(stripAnsi, "stripAnsi");
44335
- function wrapAnsiLine(line, maxWidth) {
44336
- const stripped = stripAnsi(line);
44337
- if (stripped.length <= maxWidth) return [line];
44338
- const result = [];
44339
- let visibleCount = 0;
44340
- let current = "";
44341
- let i = 0;
44342
- while (i < line.length) {
44343
- const char = line[i];
44344
- if (char === "\x1B") {
44345
- let sequence = char;
44346
- i++;
44347
- while (i < line.length) {
44348
- const nextChar = line[i];
44349
- sequence += nextChar;
44350
- i++;
44351
- if (nextChar === "m") break;
44352
- }
44353
- current += sequence;
44354
- continue;
44355
- }
44356
- current += char;
44357
- visibleCount++;
44358
- i++;
44359
- if (visibleCount >= maxWidth) {
44360
- result.push(current);
44361
- current = "";
44362
- visibleCount = 0;
44363
- }
44364
- }
44365
- if (current) result.push(current);
44366
- return result;
44367
- }
44368
- __name(wrapAnsiLine, "wrapAnsiLine");
44369
- function printBox(content, title, language, bgColor = false) {
44370
- const width = TERMINAL_WIDTH;
44371
- let displayContent = content;
44372
- if (language) {
44373
- try {
44374
- displayContent = distExports.highlight(content, { language, ignoreIllegals: true });
44375
- } catch {
44376
- }
44377
- }
44378
- const lines = displayContent.split("\n").flatMap((line) => wrapAnsiLine(line, width - 4));
44379
- console.log(chalk.gray("┌" + "─".repeat(width - 2) + "┐"));
44380
- if (title) {
44381
- const stripped = stripAnsi(title);
44382
- const lineText = `${title} `;
44383
- const padding = Math.max(0, width - 4 - stripped.length - 2);
44384
- console.log(
44385
- chalk.gray("│ ") + chalk.bold.white(lineText) + " ".repeat(padding) + chalk.gray(" │")
44386
- );
44387
- console.log(chalk.gray("├" + "─".repeat(width - 2) + "┤"));
44388
- }
44389
- lines.forEach((line) => {
44390
- const stripped = stripAnsi(line);
44391
- const padding = Math.max(0, width - 4 - stripped.length);
44392
- const finalLine = bgColor ? chalk.bgGray(line + " ".repeat(padding)) : line + " ".repeat(padding);
44393
- console.log(chalk.gray("│ ") + finalLine + chalk.gray(" │"));
44394
- });
44395
- console.log(chalk.gray("└" + "─".repeat(width - 2) + "┘"));
44396
- }
44397
- __name(printBox, "printBox");
44398
- function extractCodeFromToolInput(input) {
44399
- if (typeof input === "object" && input !== null && "code" in input) {
44400
- const inputObj = input;
44401
- return typeof inputObj.code === "string" ? inputObj.code : null;
44402
- }
44403
- return null;
44404
- }
44405
- __name(extractCodeFromToolInput, "extractCodeFromToolInput");
44406
- function isExecuteCodeResult(obj) {
44407
- if (typeof obj !== "object" || obj === null) return false;
44408
- const result = obj;
44409
- return "result" in result && "logs" in result && Array.isArray(result.logs) && "execution_time" in result && typeof result.execution_time === "number" && "error" in result && (typeof result.error === "string" || result.error === null);
44410
- }
44411
- __name(isExecuteCodeResult, "isExecuteCodeResult");
44412
- function parseExecuteCodeResult(output) {
44413
- try {
44414
- if (typeof output === "string") {
44415
- const parsed = JSON.parse(output);
44416
- if (isExecuteCodeResult(parsed)) {
44417
- return parsed;
44418
- }
44419
- }
44420
- if (isExecuteCodeResult(output)) {
44421
- return output;
44422
- }
44423
- } catch (e) {
44424
- }
44425
- return null;
44426
- }
44427
- __name(parseExecuteCodeResult, "parseExecuteCodeResult");
44428
- function renderContent(content) {
44429
- if (content === null || content === void 0) {
44430
- return "null";
44431
- }
44432
- if (typeof content === "object") {
44433
- return JSON.stringify(content, null, 2);
44434
- }
44435
- return String(content);
44436
- }
44437
- __name(renderContent, "renderContent");
44438
- function unwrapToolInput(input) {
44439
- if (typeof input === "object" && input !== null && "input" in input) {
44440
- const inputObj = input;
44441
- if (typeof inputObj.input === "string") {
44442
- try {
44443
- return JSON.parse(inputObj.input);
44444
- } catch (e) {
44445
- return inputObj.input;
44446
- }
44447
- }
44448
- }
44449
- return input;
44450
- }
44451
- __name(unwrapToolInput, "unwrapToolInput");
44452
- function handleToolStart(event) {
44453
- const toolName = event.name || "unknown";
44454
- let input = event.data?.input || {};
44455
- input = unwrapToolInput(input);
44456
- const code = extractCodeFromToolInput(input);
44457
- if (code) {
44458
- printBox(code, `${toolName} - input`, "javascript", false);
44459
- const otherParams = { ...input };
44460
- delete otherParams.code;
44461
- if (Object.keys(otherParams).length > 0) {
44462
- printBox(renderContent(otherParams), "Other Parameters", "json", false);
44463
- }
44464
- } else {
44465
- printBox(renderContent(input), `${toolName} - input`, "json", false);
44466
- }
44467
- }
44468
- __name(handleToolStart, "handleToolStart");
44469
- function extractToolMessageContent(output) {
44470
- try {
44471
- if (typeof output === "object" && output !== null && "name" in output && "content" in output) {
44472
- const outputObj = output;
44473
- const toolName = (typeof outputObj.name === "string" ? outputObj.name : null) || "unknown";
44474
- const lcKwargs = outputObj.lc_kwargs;
44475
- const status = lcKwargs?.status || outputObj.status || "unknown";
44476
- let content = outputObj.content;
44477
- if (typeof content === "string") {
44478
- try {
44479
- content = JSON.parse(content);
44480
- } catch (e) {
44481
- }
44482
- }
44483
- return { toolName, status, content };
44484
- }
44485
- } catch (e) {
44486
- }
44487
- return null;
44488
- }
44489
- __name(extractToolMessageContent, "extractToolMessageContent");
44490
- function formatSearchToolsAsTree(tools, meta, query) {
44491
- const metaLines = [];
44492
- if (meta) {
44493
- if (meta.total_tools !== void 0) {
44494
- metaLines.push(`Total tools: ${meta.total_tools}`);
44495
- }
44496
- if (meta.namespaces && meta.namespaces.length > 0) {
44497
- metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
44498
- }
44499
- if (meta.result_count !== void 0) {
44500
- metaLines.push(`Results: ${meta.result_count}`);
44501
- }
44502
- }
44503
- if (!Array.isArray(tools) || tools.length === 0) {
44504
- const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
44505
- if (metaLines.length > 0) {
44506
- return `${metaLines.join("\n")}
44507
-
44508
- ${noResultsMsg}`;
44509
- }
44510
- return noResultsMsg;
44511
- }
44512
- const toolsByServer = {};
44513
- for (const tool of tools) {
44514
- const server = tool.server || "unknown";
44515
- if (!toolsByServer[server]) {
44516
- toolsByServer[server] = [];
44517
- }
44518
- toolsByServer[server].push(tool);
44519
- }
44520
- const lines = [];
44521
- if (meta) {
44522
- if (meta.total_tools !== void 0) {
44523
- lines.push(`Total tools: ${meta.total_tools}`);
44524
- }
44525
- if (meta.namespaces && meta.namespaces.length > 0) {
44526
- lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
44527
- }
44528
- if (meta.result_count !== void 0) {
44529
- lines.push(`Results: ${meta.result_count}`);
44530
- }
44531
- if (lines.length > 0) {
44532
- lines.push("");
44533
- }
44534
- }
44535
- const servers = Object.keys(toolsByServer).sort();
44536
- for (let i = 0; i < servers.length; i++) {
44537
- const server = servers[i];
44538
- const serverTools = toolsByServer[server];
44539
- const isLastServer = i === servers.length - 1;
44540
- const serverPrefix = isLastServer ? "└─" : "├─";
44541
- lines.push(
44542
- `${serverPrefix} ${chalk.cyan(server)} (${serverTools.length} tools)`
44543
- );
44544
- for (let j = 0; j < serverTools.length; j++) {
44545
- const tool = serverTools[j];
44546
- const isLastTool = j === serverTools.length - 1;
44547
- const indent = isLastServer ? " " : "│ ";
44548
- const toolPrefix = isLastTool ? "└─" : "├─";
44549
- const toolLine = `${indent}${toolPrefix} ${tool.name}`;
44550
- lines.push(toolLine);
44551
- if (tool.description) {
44552
- const descAlign = isLastTool ? " " : "│ ";
44553
- const descriptionIndent = `${indent}${descAlign}`;
44554
- const indentLength = stripAnsi(descriptionIndent).length;
44555
- const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
44556
- const words = tool.description.split(/(\s+)/);
44557
- const wrappedLines = [];
44558
- let currentLine = "";
44559
- for (const word of words) {
44560
- const testLine = currentLine + word;
44561
- if (stripAnsi(testLine).length <= availableWidth) {
44562
- currentLine = testLine;
44563
- } else {
44564
- if (currentLine) {
44565
- wrappedLines.push(currentLine.trimEnd());
44566
- }
44567
- currentLine = word.trimStart();
44568
- }
44569
- }
44570
- if (currentLine) {
44571
- wrappedLines.push(currentLine.trimEnd());
44572
- }
44573
- for (const descLine of wrappedLines) {
44574
- lines.push(`${descriptionIndent}${chalk.dim(descLine)}`);
44575
- }
44576
- }
44577
- }
44578
- }
44579
- return lines.join("\n");
44580
- }
44581
- __name(formatSearchToolsAsTree, "formatSearchToolsAsTree");
44582
- function handleToolEnd(event) {
44583
- const output = event.data?.output;
44584
- const toolMessage = extractToolMessageContent(output);
44585
- if (toolMessage) {
44586
- const { toolName, status, content } = toolMessage;
44587
- if (toolName === "execute_code") {
44588
- let actualContent = content;
44589
- if (typeof content === "object" && content !== null && "content" in content) {
44590
- const innerContent = content.content;
44591
- if (Array.isArray(innerContent) && innerContent.length > 0) {
44592
- if (innerContent[0].type === "text" && innerContent[0].text) {
44593
- actualContent = innerContent[0].text;
44594
- }
44595
- }
44596
- }
44597
- const execResult2 = parseExecuteCodeResult(actualContent);
44598
- if (execResult2) {
44599
- const timeMs = execResult2.execution_time ? Math.round(execResult2.execution_time * 1e3) : 0;
44600
- const timeStr = `${timeMs}ms`;
44601
- const isError2 = execResult2.error !== null && execResult2.error !== void 0 && execResult2.error !== "";
44602
- const statusText = isError2 ? chalk.red("error") : chalk.green("success");
44603
- const title2 = `${toolName} - ${statusText} - ${timeStr}`;
44604
- if (execResult2.result !== null && execResult2.result !== void 0) {
44605
- const resultStr = renderContent(execResult2.result);
44606
- const language3 = typeof execResult2.result === "object" ? "json" : void 0;
44607
- printBox(resultStr, title2, language3, false);
44608
- } else {
44609
- printBox("(no result)", title2, void 0, false);
44610
- }
44611
- if (execResult2.logs && execResult2.logs.length > 0) {
44612
- printBox(execResult2.logs.join("\n"), `Logs`, void 0, false);
44613
- }
44614
- if (execResult2.error) {
44615
- printBox(execResult2.error, chalk.red("Error"), void 0, false);
44616
- }
44617
- return;
44618
- }
44619
- }
44620
- if (toolName === "search_tools") {
44621
- const toolInput = event.data?.input;
44622
- const query = toolInput?.query;
44623
- let actualContent = content;
44624
- if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
44625
- const innerContent = content.content;
44626
- if (Array.isArray(innerContent) && innerContent.length > 0) {
44627
- if (innerContent[0].type === "text" && innerContent[0].text) {
44628
- try {
44629
- actualContent = JSON.parse(innerContent[0].text);
44630
- } catch (e) {
44631
- actualContent = innerContent[0].text;
44632
- }
44633
- }
44634
- }
44635
- }
44636
- if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
44637
- const results = actualContent.results;
44638
- const contentWithMeta = actualContent;
44639
- const meta = contentWithMeta.meta;
44640
- const treeStr = formatSearchToolsAsTree(results, meta, query);
44641
- const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
44642
- const title2 = `${statusText}: ${toolName} - Result`;
44643
- printBox(treeStr, title2, void 0, false);
44644
- return;
44645
- }
44646
- if (Array.isArray(actualContent)) {
44647
- const treeStr = formatSearchToolsAsTree(
44648
- actualContent,
44649
- void 0,
44650
- query
44651
- );
44652
- const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
44653
- const title2 = `${statusText}: ${toolName} - Result`;
44654
- printBox(treeStr, title2, void 0, false);
44655
- return;
44656
- }
44657
- }
44658
- const contentObj = typeof content === "object" && content !== null ? content : null;
44659
- const isError = contentObj && "isError" in contentObj && contentObj.isError === true || status === "error";
44660
- let displayContent = content;
44661
- if (typeof content === "object" && content !== null && "content" in content) {
44662
- displayContent = content.content;
44663
- if (Array.isArray(displayContent) && displayContent.length > 0) {
44664
- if (displayContent[0].type === "text" && displayContent[0].text) {
44665
- displayContent = displayContent[0].text;
44666
- }
44667
- }
44668
- }
44669
- const contentStr = renderContent(displayContent);
44670
- const language2 = typeof displayContent === "object" ? "json" : void 0;
44671
- const statusLabel = status === "success" ? chalk.green("Success") : isError ? chalk.red("Error") : "Result";
44672
- const title = `${statusLabel}: ${toolName} - Result`;
44673
- printBox(contentStr, title, language2, false);
44674
- return;
44675
- }
44676
- const execResult = parseExecuteCodeResult(output);
44677
- if (execResult) {
44678
- const timeMs = execResult.execution_time ? Math.round(execResult.execution_time * 1e3) : 0;
44679
- const timeStr = `${timeMs}ms`;
44680
- if (execResult.result !== null && execResult.result !== void 0) {
44681
- const resultStr = renderContent(execResult.result);
44682
- const language2 = typeof execResult.result === "object" ? "json" : void 0;
44683
- printBox(resultStr, `Result - ${timeStr}`, language2, false);
44684
- }
44685
- if (execResult.logs && execResult.logs.length > 0) {
44686
- printBox(execResult.logs.join("\n"), `Logs`, void 0, false);
44687
- }
44688
- if (execResult.error) {
44689
- printBox(execResult.error, chalk.red("Error"), void 0, false);
44690
- }
44691
- return;
44692
- }
44693
- const outputStr = renderContent(output);
44694
- const language = typeof output === "object" ? "json" : void 0;
44695
- printBox(outputStr, "Result", language, false);
44696
- }
44697
- __name(handleToolEnd, "handleToolEnd");
44698
- async function* prettyStreamEvents(streamEventsGenerator) {
44699
- let finalResponse = "";
44700
- let isFirstTextChunk = true;
44701
- let hasStreamedText = false;
44702
- for await (const event of streamEventsGenerator) {
44703
- if (event.event === "on_tool_start") {
44704
- if (hasStreamedText) {
44705
- process.stdout.write("\n");
44706
- hasStreamedText = false;
44707
- isFirstTextChunk = true;
44708
- }
44709
- handleToolStart(event);
44710
- } else if (event.event === "on_tool_end") {
44711
- handleToolEnd(event);
44712
- } else if (event.event === "on_chat_model_stream") {
44713
- if (event.data?.chunk?.text) {
44714
- const text = event.data.chunk.text;
44715
- if (typeof text === "string" && text.length > 0) {
44716
- if (isFirstTextChunk) {
44717
- process.stdout.write("\n🤖 ");
44718
- isFirstTextChunk = false;
44719
- }
44720
- process.stdout.write(text);
44721
- finalResponse += text;
44722
- hasStreamedText = true;
44723
- }
44724
- }
44725
- }
44726
- yield;
44727
- }
44728
- return finalResponse;
44729
- }
44730
- __name(prettyStreamEvents, "prettyStreamEvents");
43958
+ const index = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
43959
+ const index$1 = /* @__PURE__ */ _mergeNamespaces({
43960
+ __proto__: null,
43961
+ default: index
43962
+ }, [distExports]);
44731
43963
  export {
44732
- extractCodeFromToolInput,
44733
- extractToolMessageContent,
44734
- formatSearchToolsAsTree,
44735
- handleToolEnd,
44736
- handleToolStart,
44737
- parseExecuteCodeResult,
44738
- prettyStreamEvents,
44739
- printBox,
44740
- renderContent,
44741
- unwrapToolInput
43964
+ index$1 as i
44742
43965
  };