ai 4.1.57 → 4.1.59
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +74 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs +1 -3
- package/rsc/dist/rsc-shared.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -6628,6 +6628,80 @@ 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
|
+
const nodePrefix = "node:";
|
6642
|
+
try {
|
6643
|
+
childProcess = await import(`${nodePrefix}child_process`);
|
6644
|
+
} catch (error) {
|
6645
|
+
try {
|
6646
|
+
childProcess = __require(`${nodePrefix}child_process`);
|
6647
|
+
} catch (innerError) {
|
6648
|
+
throw new MCPClientError({
|
6649
|
+
message: "Failed to load child_process module dynamically",
|
6650
|
+
cause: innerError
|
6651
|
+
});
|
6652
|
+
}
|
6653
|
+
}
|
6654
|
+
const { spawn } = childProcess;
|
6655
|
+
return spawn(config.command, (_a17 = config.args) != null ? _a17 : [], {
|
6656
|
+
env: (_b = config.env) != null ? _b : getDefaultEnvironment(),
|
6657
|
+
stdio: ["pipe", "pipe", (_c = config.stderr) != null ? _c : "inherit"],
|
6658
|
+
shell: false,
|
6659
|
+
signal,
|
6660
|
+
windowsHide: globalThis.process.platform === "win32" && isElectron(),
|
6661
|
+
cwd: config.cwd
|
6662
|
+
});
|
6663
|
+
}
|
6664
|
+
function detectRuntime() {
|
6665
|
+
var _a17, _b;
|
6666
|
+
if (typeof window !== "undefined") {
|
6667
|
+
return "browser";
|
6668
|
+
}
|
6669
|
+
if (((_b = (_a17 = globalThis.process) == null ? void 0 : _a17.release) == null ? void 0 : _b.name) === "node") {
|
6670
|
+
return "node";
|
6671
|
+
}
|
6672
|
+
return null;
|
6673
|
+
}
|
6674
|
+
function getDefaultEnvironment() {
|
6675
|
+
const DEFAULT_INHERITED_ENV_VARS = globalThis.process.platform === "win32" ? [
|
6676
|
+
"APPDATA",
|
6677
|
+
"HOMEDRIVE",
|
6678
|
+
"HOMEPATH",
|
6679
|
+
"LOCALAPPDATA",
|
6680
|
+
"PATH",
|
6681
|
+
"PROCESSOR_ARCHITECTURE",
|
6682
|
+
"SYSTEMDRIVE",
|
6683
|
+
"SYSTEMROOT",
|
6684
|
+
"TEMP",
|
6685
|
+
"USERNAME",
|
6686
|
+
"USERPROFILE"
|
6687
|
+
] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
|
6688
|
+
const env = {};
|
6689
|
+
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
6690
|
+
const value = globalThis.process.env[key];
|
6691
|
+
if (value === void 0) {
|
6692
|
+
continue;
|
6693
|
+
}
|
6694
|
+
if (value.startsWith("()")) {
|
6695
|
+
continue;
|
6696
|
+
}
|
6697
|
+
env[key] = value;
|
6698
|
+
}
|
6699
|
+
return env;
|
6700
|
+
}
|
6701
|
+
function isElectron() {
|
6702
|
+
return "type" in globalThis.process;
|
6703
|
+
}
|
6704
|
+
|
6631
6705
|
// core/tool/mcp/types.ts
|
6632
6706
|
import { z as z8 } from "zod";
|
6633
6707
|
var LATEST_PROTOCOL_VERSION = "2024-11-05";
|
@@ -6760,79 +6834,6 @@ var CallToolResultSchema = ResultSchema.extend({
|
|
6760
6834
|
})
|
6761
6835
|
);
|
6762
6836
|
|
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
6837
|
// core/tool/mcp/mcp-stdio-transport.ts
|
6837
6838
|
var StdioClientTransport = class {
|
6838
6839
|
constructor(server) {
|