ai 4.1.57 → 4.1.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6628,6 +6628,79 @@ function tool(tool2) {
6628
6628
  return tool2;
6629
6629
  }
6630
6630
 
6631
+ // core/tool/mcp/create-child-process.ts
6632
+ async function createChildProcess(config, signal) {
6633
+ var _a17, _b, _c;
6634
+ const runtime = detectRuntime();
6635
+ if (runtime !== "node") {
6636
+ throw new MCPClientError({
6637
+ message: "Attempted to use child_process module outside of Node.js environment"
6638
+ });
6639
+ }
6640
+ let childProcess;
6641
+ try {
6642
+ childProcess = await import("child_process");
6643
+ } catch (error) {
6644
+ try {
6645
+ childProcess = __require("child_process");
6646
+ } catch (innerError) {
6647
+ throw new MCPClientError({
6648
+ message: "Failed to load child_process module dynamically",
6649
+ cause: innerError
6650
+ });
6651
+ }
6652
+ }
6653
+ const { spawn } = childProcess;
6654
+ return spawn(config.command, (_a17 = config.args) != null ? _a17 : [], {
6655
+ env: (_b = config.env) != null ? _b : getDefaultEnvironment(),
6656
+ stdio: ["pipe", "pipe", (_c = config.stderr) != null ? _c : "inherit"],
6657
+ shell: false,
6658
+ signal,
6659
+ windowsHide: globalThis.process.platform === "win32" && isElectron(),
6660
+ cwd: config.cwd
6661
+ });
6662
+ }
6663
+ function detectRuntime() {
6664
+ var _a17, _b;
6665
+ if (typeof window !== "undefined") {
6666
+ return "browser";
6667
+ }
6668
+ if (((_b = (_a17 = globalThis.process) == null ? void 0 : _a17.release) == null ? void 0 : _b.name) === "node") {
6669
+ return "node";
6670
+ }
6671
+ return null;
6672
+ }
6673
+ function getDefaultEnvironment() {
6674
+ const DEFAULT_INHERITED_ENV_VARS = globalThis.process.platform === "win32" ? [
6675
+ "APPDATA",
6676
+ "HOMEDRIVE",
6677
+ "HOMEPATH",
6678
+ "LOCALAPPDATA",
6679
+ "PATH",
6680
+ "PROCESSOR_ARCHITECTURE",
6681
+ "SYSTEMDRIVE",
6682
+ "SYSTEMROOT",
6683
+ "TEMP",
6684
+ "USERNAME",
6685
+ "USERPROFILE"
6686
+ ] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
6687
+ const env = {};
6688
+ for (const key of DEFAULT_INHERITED_ENV_VARS) {
6689
+ const value = globalThis.process.env[key];
6690
+ if (value === void 0) {
6691
+ continue;
6692
+ }
6693
+ if (value.startsWith("()")) {
6694
+ continue;
6695
+ }
6696
+ env[key] = value;
6697
+ }
6698
+ return env;
6699
+ }
6700
+ function isElectron() {
6701
+ return "type" in globalThis.process;
6702
+ }
6703
+
6631
6704
  // core/tool/mcp/types.ts
6632
6705
  import { z as z8 } from "zod";
6633
6706
  var LATEST_PROTOCOL_VERSION = "2024-11-05";
@@ -6760,79 +6833,6 @@ var CallToolResultSchema = ResultSchema.extend({
6760
6833
  })
6761
6834
  );
6762
6835
 
6763
- // core/tool/mcp/utils.ts
6764
- function detectRuntime() {
6765
- var _a17, _b;
6766
- if (typeof window !== "undefined") {
6767
- return "browser";
6768
- }
6769
- if (((_b = (_a17 = globalThis.process) == null ? void 0 : _a17.release) == null ? void 0 : _b.name) === "node") {
6770
- return "node";
6771
- }
6772
- return null;
6773
- }
6774
- async function createChildProcess(config, signal) {
6775
- var _a17, _b, _c;
6776
- const runtime = detectRuntime();
6777
- if (runtime !== "node") {
6778
- throw new MCPClientError({
6779
- message: "Attempted to use child_process module outside of Node.js environment"
6780
- });
6781
- }
6782
- let childProcess;
6783
- try {
6784
- childProcess = await import("child_process");
6785
- } catch (error) {
6786
- try {
6787
- childProcess = __require("child_process");
6788
- } catch (innerError) {
6789
- throw new MCPClientError({
6790
- message: "Failed to load child_process module dynamically",
6791
- cause: innerError
6792
- });
6793
- }
6794
- }
6795
- const { spawn } = childProcess;
6796
- return spawn(config.command, (_a17 = config.args) != null ? _a17 : [], {
6797
- env: (_b = config.env) != null ? _b : getDefaultEnvironment(),
6798
- stdio: ["pipe", "pipe", (_c = config.stderr) != null ? _c : "inherit"],
6799
- shell: false,
6800
- signal,
6801
- windowsHide: process.platform === "win32" && isElectron(),
6802
- cwd: config.cwd
6803
- });
6804
- }
6805
- var DEFAULT_INHERITED_ENV_VARS = process.platform === "win32" ? [
6806
- "APPDATA",
6807
- "HOMEDRIVE",
6808
- "HOMEPATH",
6809
- "LOCALAPPDATA",
6810
- "PATH",
6811
- "PROCESSOR_ARCHITECTURE",
6812
- "SYSTEMDRIVE",
6813
- "SYSTEMROOT",
6814
- "TEMP",
6815
- "USERNAME",
6816
- "USERPROFILE"
6817
- ] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
6818
- function getDefaultEnvironment() {
6819
- const env = {};
6820
- for (const key of DEFAULT_INHERITED_ENV_VARS) {
6821
- const value = process.env[key];
6822
- if (value === void 0) {
6823
- continue;
6824
- }
6825
- if (value.startsWith("()")) {
6826
- continue;
6827
- }
6828
- env[key] = value;
6829
- }
6830
- return env;
6831
- }
6832
- function isElectron() {
6833
- return "type" in process;
6834
- }
6835
-
6836
6836
  // core/tool/mcp/mcp-stdio-transport.ts
6837
6837
  var StdioClientTransport = class {
6838
6838
  constructor(server) {