ai 4.1.56 → 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
@@ -5994,6 +5994,62 @@ var DefaultStreamTextResult = class {
5994
5994
  }
5995
5995
  };
5996
5996
 
5997
+ // core/util/merge-objects.ts
5998
+ function mergeObjects(target, source) {
5999
+ if (target === void 0 && source === void 0) {
6000
+ return void 0;
6001
+ }
6002
+ if (target === void 0) {
6003
+ return source;
6004
+ }
6005
+ if (source === void 0) {
6006
+ return target;
6007
+ }
6008
+ const result = { ...target };
6009
+ for (const key in source) {
6010
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6011
+ const sourceValue = source[key];
6012
+ if (sourceValue === void 0)
6013
+ continue;
6014
+ const targetValue = key in target ? target[key] : void 0;
6015
+ const isSourceObject = sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && !(sourceValue instanceof Date) && !(sourceValue instanceof RegExp);
6016
+ const isTargetObject = targetValue !== null && targetValue !== void 0 && typeof targetValue === "object" && !Array.isArray(targetValue) && !(targetValue instanceof Date) && !(targetValue instanceof RegExp);
6017
+ if (isSourceObject && isTargetObject) {
6018
+ result[key] = mergeObjects(
6019
+ targetValue,
6020
+ sourceValue
6021
+ );
6022
+ } else {
6023
+ result[key] = sourceValue;
6024
+ }
6025
+ }
6026
+ }
6027
+ return result;
6028
+ }
6029
+
6030
+ // core/middleware/default-settings-middleware.ts
6031
+ function defaultSettingsMiddleware({
6032
+ settings
6033
+ }) {
6034
+ return {
6035
+ middlewareVersion: "v1",
6036
+ transformParams: async ({ params }) => {
6037
+ var _a17;
6038
+ return {
6039
+ ...settings,
6040
+ ...params,
6041
+ providerMetadata: mergeObjects(
6042
+ settings.providerMetadata,
6043
+ params.providerMetadata
6044
+ ),
6045
+ // special case for temperature 0
6046
+ // TODO remove when temperature defaults to undefined
6047
+ temperature: params.temperature === 0 || params.temperature == null ? (_a17 = settings.temperature) != null ? _a17 : 0 : params.temperature
6048
+ };
6049
+ }
6050
+ };
6051
+ }
6052
+
5997
6053
  // core/util/get-potential-start-index.ts
5998
6054
  function getPotentialStartIndex(text2, searchedText) {
5999
6055
  if (searchedText.length === 0) {
@@ -6572,6 +6628,79 @@ function tool(tool2) {
6572
6628
  return tool2;
6573
6629
  }
6574
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
+
6575
6704
  // core/tool/mcp/types.ts
6576
6705
  import { z as z8 } from "zod";
6577
6706
  var LATEST_PROTOCOL_VERSION = "2024-11-05";
@@ -6704,79 +6833,6 @@ var CallToolResultSchema = ResultSchema.extend({
6704
6833
  })
6705
6834
  );
6706
6835
 
6707
- // core/tool/mcp/utils.ts
6708
- function detectRuntime() {
6709
- var _a17, _b;
6710
- if (typeof window !== "undefined") {
6711
- return "browser";
6712
- }
6713
- if (((_b = (_a17 = globalThis.process) == null ? void 0 : _a17.release) == null ? void 0 : _b.name) === "node") {
6714
- return "node";
6715
- }
6716
- return null;
6717
- }
6718
- async function createChildProcess(config, signal) {
6719
- var _a17, _b, _c;
6720
- const runtime = detectRuntime();
6721
- if (runtime !== "node") {
6722
- throw new MCPClientError({
6723
- message: "Attempted to use child_process module outside of Node.js environment"
6724
- });
6725
- }
6726
- let childProcess;
6727
- try {
6728
- childProcess = await import("child_process");
6729
- } catch (error) {
6730
- try {
6731
- childProcess = __require("child_process");
6732
- } catch (innerError) {
6733
- throw new MCPClientError({
6734
- message: "Failed to load child_process module dynamically",
6735
- cause: innerError
6736
- });
6737
- }
6738
- }
6739
- const { spawn } = childProcess;
6740
- return spawn(config.command, (_a17 = config.args) != null ? _a17 : [], {
6741
- env: (_b = config.env) != null ? _b : getDefaultEnvironment(),
6742
- stdio: ["pipe", "pipe", (_c = config.stderr) != null ? _c : "inherit"],
6743
- shell: false,
6744
- signal,
6745
- windowsHide: process.platform === "win32" && isElectron(),
6746
- cwd: config.cwd
6747
- });
6748
- }
6749
- var DEFAULT_INHERITED_ENV_VARS = process.platform === "win32" ? [
6750
- "APPDATA",
6751
- "HOMEDRIVE",
6752
- "HOMEPATH",
6753
- "LOCALAPPDATA",
6754
- "PATH",
6755
- "PROCESSOR_ARCHITECTURE",
6756
- "SYSTEMDRIVE",
6757
- "SYSTEMROOT",
6758
- "TEMP",
6759
- "USERNAME",
6760
- "USERPROFILE"
6761
- ] : ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
6762
- function getDefaultEnvironment() {
6763
- const env = {};
6764
- for (const key of DEFAULT_INHERITED_ENV_VARS) {
6765
- const value = process.env[key];
6766
- if (value === void 0) {
6767
- continue;
6768
- }
6769
- if (value.startsWith("()")) {
6770
- continue;
6771
- }
6772
- env[key] = value;
6773
- }
6774
- return env;
6775
- }
6776
- function isElectron() {
6777
- return "type" in process;
6778
- }
6779
-
6780
6836
  // core/tool/mcp/mcp-stdio-transport.ts
6781
6837
  var StdioClientTransport = class {
6782
6838
  constructor(server) {
@@ -7722,6 +7778,7 @@ export {
7722
7778
  createDataStreamResponse,
7723
7779
  createIdGenerator5 as createIdGenerator,
7724
7780
  customProvider,
7781
+ defaultSettingsMiddleware,
7725
7782
  embed,
7726
7783
  embedMany,
7727
7784
  createMCPClient as experimental_createMCPClient,