@ax-llm/ax 11.0.23 → 11.0.25

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/index.cjs CHANGED
@@ -93,6 +93,9 @@ __export(index_exports, {
93
93
  AxJSInterpreter: () => AxJSInterpreter,
94
94
  AxJSInterpreterPermission: () => AxJSInterpreterPermission,
95
95
  AxLLMRequestTypeValues: () => AxLLMRequestTypeValues,
96
+ AxMCPClient: () => AxMCPClient,
97
+ AxMCPHTTPTransport: () => AxMCPHTTPTransport,
98
+ AxMCPStdioTransport: () => AxMCPStdioTransport,
96
99
  AxMemory: () => AxMemory,
97
100
  AxMockAIService: () => AxMockAIService,
98
101
  AxMultiServiceRouter: () => AxMultiServiceRouter,
@@ -752,7 +755,8 @@ ${hideContent ? "" : colorLog.whiteBright(msg.content ?? "<empty>")}`;
752
755
  }
753
756
  };
754
757
  var logChatRequestMessage = (msg) => {
755
- process.stdout.write(formatChatMessage(msg) + "\n");
758
+ process.stdout.write(`${formatChatMessage(msg)}
759
+ `);
756
760
  process.stdout.write(colorLog.blueBright("\nAssistant:\n"));
757
761
  };
758
762
  var logChatRequest = (chatPrompt) => {
@@ -1070,7 +1074,7 @@ var AxBaseAI = class {
1070
1074
  return res2;
1071
1075
  };
1072
1076
  if (options?.debug ?? this.debug) {
1073
- logChatRequest(req["chatPrompt"]);
1077
+ logChatRequest(req.chatPrompt);
1074
1078
  }
1075
1079
  const rt = options?.rateLimiter ?? this.rt;
1076
1080
  const rv = rt ? await rt(fn, { modelUsage: this.modelUsage }) : await fn();
@@ -1736,6 +1740,7 @@ var AxAIOpenAIModel = /* @__PURE__ */ ((AxAIOpenAIModel2) => {
1736
1740
  AxAIOpenAIModel2["O1Mini"] = "o1-mini";
1737
1741
  AxAIOpenAIModel2["O3Mini"] = "o3-mini";
1738
1742
  AxAIOpenAIModel2["GPT4"] = "gpt-4";
1743
+ AxAIOpenAIModel2["GPT45"] = "gpt-4.5-preview";
1739
1744
  AxAIOpenAIModel2["GPT4O"] = "gpt-4o";
1740
1745
  AxAIOpenAIModel2["GPT4OMini"] = "gpt-4o-mini";
1741
1746
  AxAIOpenAIModel2["GPT4ChatGPT4O"] = "chatgpt-4o-latest";
@@ -1756,6 +1761,12 @@ var AxAIOpenAIEmbedModel = /* @__PURE__ */ ((AxAIOpenAIEmbedModel2) => {
1756
1761
 
1757
1762
  // ai/openai/info.ts
1758
1763
  var axModelInfoOpenAI = [
1764
+ {
1765
+ name: "gpt-4.5-preview" /* GPT45 */,
1766
+ currency: "usd",
1767
+ promptTokenCostPer1M: 75,
1768
+ completionTokenCostPer1M: 150
1769
+ },
1759
1770
  {
1760
1771
  name: "o1" /* O1 */,
1761
1772
  currency: "usd",
@@ -3764,7 +3775,7 @@ var AxAI = class {
3764
3775
 
3765
3776
  // dsp/generate.ts
3766
3777
  var import_web5 = require("stream/web");
3767
- var import_api22 = require("@opentelemetry/api");
3778
+ var import_api21 = require("@opentelemetry/api");
3768
3779
 
3769
3780
  // ai/util.ts
3770
3781
  function mergeFunctionCalls(functionCalls, functionCallDeltas) {
@@ -3857,7 +3868,7 @@ var MemoryImpl = class {
3857
3868
  }
3858
3869
  }
3859
3870
  if (this.debug) {
3860
- if (delta) {
3871
+ if (delta && typeof delta === "string") {
3861
3872
  debugResponseDelta(delta);
3862
3873
  } else if (lastItem) {
3863
3874
  debugResponse({ content, name, functionCalls });
@@ -3990,10 +4001,10 @@ var AxAssertionError = class extends Error {
3990
4001
  return extraFields;
3991
4002
  };
3992
4003
  };
3993
- var assertAssertions = (asserts, values) => {
4004
+ var assertAssertions = async (asserts, values) => {
3994
4005
  for (const assert of asserts) {
3995
4006
  const { fn, message } = assert;
3996
- const res = fn(values);
4007
+ const res = await fn(values);
3997
4008
  if (res === void 0) {
3998
4009
  continue;
3999
4010
  }
@@ -4005,7 +4016,7 @@ var assertAssertions = (asserts, values) => {
4005
4016
  }
4006
4017
  }
4007
4018
  };
4008
- var assertStreamingAssertions = (asserts, xstate, content, final = false) => {
4019
+ var assertStreamingAssertions = async (asserts, xstate, content, final = false) => {
4009
4020
  if (!xstate.currField || xstate.s === -1 || !asserts || asserts.length === 0) {
4010
4021
  return;
4011
4022
  }
@@ -4018,7 +4029,7 @@ var assertStreamingAssertions = (asserts, xstate, content, final = false) => {
4018
4029
  const currValue = content.substring(xstate.s);
4019
4030
  for (const assert of fieldAsserts) {
4020
4031
  const { message, fn } = assert;
4021
- const res = fn(currValue, final);
4032
+ const res = await fn(currValue, final);
4022
4033
  if (res === void 0) {
4023
4034
  continue;
4024
4035
  }
@@ -4031,9 +4042,6 @@ var assertStreamingAssertions = (asserts, xstate, content, final = false) => {
4031
4042
  // dsp/datetime.ts
4032
4043
  var import_moment_timezone = __toESM(require("moment-timezone"), 1);
4033
4044
 
4034
- // dsp/program.ts
4035
- var import_api21 = require("@opentelemetry/api");
4036
-
4037
4045
  // dsp/registry.ts
4038
4046
  var AxInstanceRegistry = class {
4039
4047
  reg;
@@ -4564,7 +4572,7 @@ function validateField(field) {
4564
4572
 
4565
4573
  // dsp/util.ts
4566
4574
  var colorLog3 = new ColorLog();
4567
- var updateProgressBar = (current, total, success, elapsedTime, progressBarWidth = 20, msg) => {
4575
+ var updateProgressBar = (current, total, success, elapsedTime, msg, progressBarWidth = 20) => {
4568
4576
  const percentage = (current / total * 100).toFixed(1);
4569
4577
  const filledBarLength = Math.round(progressBarWidth * current / total);
4570
4578
  const emptyBarLength = progressBarWidth - filledBarLength;
@@ -4811,6 +4819,7 @@ var AxProgramWithSignature = class {
4811
4819
  async forward(_ai, _values, _options) {
4812
4820
  throw new Error("forward() not implemented");
4813
4821
  }
4822
+ // biome-ignore lint/correctness/useYield: just a placeholder
4814
4823
  async *streamingForward(_ai, _values, _options) {
4815
4824
  throw new Error("streamingForward() not implemented");
4816
4825
  }
@@ -4908,6 +4917,7 @@ var AxProgram = class {
4908
4917
  async forward(_ai, _values, _options) {
4909
4918
  throw new Error("forward() not implemented");
4910
4919
  }
4920
+ // biome-ignore lint/correctness/useYield: just a placeholder
4911
4921
  async *streamingForward(_ai, _values, _options) {
4912
4922
  throw new Error("streamingForward() not implemented");
4913
4923
  }
@@ -4987,9 +4997,7 @@ var AxPromptTemplate = class {
4987
4997
  task.push(
4988
4998
  `You will be provided with the following fields: ${inArgs}. Your task is to generate new fields: ${outArgs}.`
4989
4999
  );
4990
- const funcs = functions?.map(
4991
- (f) => "toFunction" in f ? f.toFunction() : f
4992
- );
5000
+ const funcs = functions?.map((f) => "toFunction" in f ? f.toFunction() : f)?.flat();
4993
5001
  const funcList = funcs?.map((fn) => `- \`${fn.name}\`: ${formatDescription(fn.description)}`).join("\n");
4994
5002
  if (funcList && funcList.length > 0) {
4995
5003
  task.push(`## Available Functions
@@ -5888,10 +5896,10 @@ var AxFunctionProcessor = class {
5888
5896
  (v) => v.name.localeCompare(func.name) === 0
5889
5897
  );
5890
5898
  if (!fnSpec) {
5891
- throw new Error(`Function not found: ` + func.name);
5899
+ throw new Error(`Function not found: ${func.name}`);
5892
5900
  }
5893
5901
  if (!fnSpec.func) {
5894
- throw new Error("No handler for function: " + func.name);
5902
+ throw new Error(`No handler for function: ${func.name}`);
5895
5903
  }
5896
5904
  try {
5897
5905
  return await this.executeFunction(fnSpec, func, options);
@@ -5912,9 +5920,11 @@ var parseFunctions = (newFuncs, existingFuncs) => {
5912
5920
  return f.toFunction();
5913
5921
  }
5914
5922
  return f;
5915
- });
5923
+ }).flat();
5916
5924
  for (const fn of functions.filter((v) => v.parameters)) {
5917
- validateJSONSchema(fn.parameters);
5925
+ if (fn.parameters) {
5926
+ validateJSONSchema(fn.parameters);
5927
+ }
5918
5928
  }
5919
5929
  return [...existingFuncs ?? [], ...functions];
5920
5930
  };
@@ -5960,11 +5970,11 @@ ${result}
5960
5970
  return promise;
5961
5971
  });
5962
5972
  const results = await Promise.all(promises);
5963
- results.forEach((result) => {
5973
+ for (const result of results) {
5964
5974
  if (result) {
5965
5975
  mem.add(result, sessionId);
5966
5976
  }
5967
- });
5977
+ }
5968
5978
  return functionsExecuted;
5969
5979
  };
5970
5980
  function parseFunctionCalls(ai, functionCalls, values, model) {
@@ -6048,13 +6058,14 @@ var AxGen = class extends AxProgramWithSignature {
6048
6058
  model,
6049
6059
  rateLimiter,
6050
6060
  stream,
6051
- functions,
6061
+ functions: _functions,
6052
6062
  functionCall: _functionCall
6053
6063
  } = options ?? {};
6054
6064
  const chatPrompt = mem?.history(sessionId) ?? [];
6055
6065
  if (chatPrompt.length === 0) {
6056
6066
  throw new Error("No chat prompt found");
6057
6067
  }
6068
+ const functions = _functions?.map((f) => "toFunction" in f ? f.toFunction() : f)?.flat();
6058
6069
  const functionCall = _functionCall ?? this.options?.functionCall;
6059
6070
  const res = await ai.chat(
6060
6071
  {
@@ -6079,13 +6090,14 @@ var AxGen = class extends AxProgramWithSignature {
6079
6090
  mem,
6080
6091
  options
6081
6092
  }) {
6082
- const { sessionId, traceId, model, functions } = options ?? {};
6093
+ const { sessionId, traceId, model, functions: _functions } = options ?? {};
6083
6094
  const fastFail = options?.fastFail ?? this.options?.fastFail;
6084
6095
  const modelName = model ?? ai.getDefaultModels().model;
6085
6096
  const usageInfo = {
6086
6097
  ai: ai.getName(),
6087
6098
  model: modelName
6088
6099
  };
6100
+ const functions = _functions?.map((f) => "toFunction" in f ? f.toFunction() : f)?.flat();
6089
6101
  const res = await this.forwardSendRequest({
6090
6102
  ai,
6091
6103
  mem,
@@ -6169,7 +6181,11 @@ var AxGen = class extends AxProgramWithSignature {
6169
6181
  streamingValidation
6170
6182
  );
6171
6183
  if (this.streamingAsserts.length !== 0) {
6172
- assertStreamingAssertions(this.streamingAsserts, xstate, content);
6184
+ await assertStreamingAssertions(
6185
+ this.streamingAsserts,
6186
+ xstate,
6187
+ content
6188
+ );
6173
6189
  }
6174
6190
  if (this.streamingFieldProcessors.length !== 0) {
6175
6191
  await processStreamingFieldProcessors(
@@ -6185,7 +6201,7 @@ var AxGen = class extends AxProgramWithSignature {
6185
6201
  if (skip) {
6186
6202
  continue;
6187
6203
  }
6188
- assertAssertions(this.asserts, values);
6204
+ await assertAssertions(this.asserts, values);
6189
6205
  }
6190
6206
  if (result.finishReason === "length") {
6191
6207
  throw new Error("Max tokens reached before completion");
@@ -6207,8 +6223,13 @@ var AxGen = class extends AxProgramWithSignature {
6207
6223
  this.functionsExecuted = /* @__PURE__ */ new Set([...this.functionsExecuted, ...fx]);
6208
6224
  } else {
6209
6225
  streamingExtractFinalValue(this.signature, values, xstate, content);
6210
- assertStreamingAssertions(this.streamingAsserts, xstate, content, true);
6211
- assertAssertions(this.asserts, values);
6226
+ await assertStreamingAssertions(
6227
+ this.streamingAsserts,
6228
+ xstate,
6229
+ content,
6230
+ true
6231
+ );
6232
+ await assertAssertions(this.asserts, values);
6212
6233
  if (this.fieldProcessors.length) {
6213
6234
  await processFieldProcessors(
6214
6235
  this.fieldProcessors,
@@ -6268,7 +6289,7 @@ var AxGen = class extends AxProgramWithSignature {
6268
6289
  }
6269
6290
  } else if (result.content) {
6270
6291
  extractValues(this.signature, values, result.content);
6271
- assertAssertions(this.asserts, values);
6292
+ await assertAssertions(this.asserts, values);
6272
6293
  if (this.fieldProcessors.length) {
6273
6294
  await processFieldProcessors(
6274
6295
  this.fieldProcessors,
@@ -6386,11 +6407,11 @@ var AxGen = class extends AxProgramWithSignature {
6386
6407
  }
6387
6408
  const funcNames = functions?.map((f) => f.name).join(",");
6388
6409
  const attributes = {
6389
- ["generate.signature"]: this.signature.toString(),
6390
- ["generate.functions"]: funcNames ?? ""
6410
+ "generate.signature": this.signature.toString(),
6411
+ "generate.functions": funcNames ?? ""
6391
6412
  };
6392
6413
  const span = tracer.startSpan("Generate", {
6393
- kind: import_api22.SpanKind.SERVER,
6414
+ kind: import_api21.SpanKind.SERVER,
6394
6415
  attributes
6395
6416
  });
6396
6417
  try {
@@ -6433,7 +6454,7 @@ var AxGen = class extends AxProgramWithSignature {
6433
6454
 
6434
6455
  // prompts/agent.ts
6435
6456
  function processChildAgentFunction(childFunction, parentValues, parentInputKeys, modelList, options) {
6436
- let processedFunction = { ...childFunction };
6457
+ const processedFunction = { ...childFunction };
6437
6458
  if (processedFunction.parameters) {
6438
6459
  const childKeys = processedFunction.parameters.properties ? Object.keys(processedFunction.parameters.properties) : [];
6439
6460
  const commonKeys = parentInputKeys.filter((key) => childKeys.includes(key)).filter((key) => key !== "model");
@@ -6505,7 +6526,7 @@ var AxAgent = class {
6505
6526
  this.debug = debug;
6506
6527
  if (!name || name.length < 5) {
6507
6528
  throw new Error(
6508
- `Agent name must be at least 10 characters (more descriptive)`
6529
+ "Agent name must be at least 10 characters (more descriptive)"
6509
6530
  );
6510
6531
  }
6511
6532
  if (!description || description.length < 20) {
@@ -7067,8 +7088,8 @@ var AxBootstrapFewShot = class {
7067
7088
  total,
7068
7089
  this.traces.length,
7069
7090
  et,
7070
- 30,
7071
- "Tuning Prompt"
7091
+ "Tuning Prompt",
7092
+ 30
7072
7093
  );
7073
7094
  if (this.traces.length > maxDemos) {
7074
7095
  return;
@@ -7121,7 +7142,7 @@ var randomSample = (array, n) => {
7121
7142
  };
7122
7143
 
7123
7144
  // db/base.ts
7124
- var import_api23 = require("@opentelemetry/api");
7145
+ var import_api22 = require("@opentelemetry/api");
7125
7146
  var AxDBBase = class {
7126
7147
  name;
7127
7148
  fetch;
@@ -7148,7 +7169,7 @@ var AxDBBase = class {
7148
7169
  return await this.tracer?.startActiveSpan(
7149
7170
  "DB Upsert Request",
7150
7171
  {
7151
- kind: import_api23.SpanKind.SERVER,
7172
+ kind: import_api22.SpanKind.SERVER,
7152
7173
  attributes: {
7153
7174
  [axSpanAttributes.DB_SYSTEM]: this.name,
7154
7175
  [axSpanAttributes.DB_OPERATION_NAME]: "upsert",
@@ -7182,7 +7203,7 @@ var AxDBBase = class {
7182
7203
  return await this.tracer?.startActiveSpan(
7183
7204
  "DB Batch Upsert Request",
7184
7205
  {
7185
- kind: import_api23.SpanKind.SERVER,
7206
+ kind: import_api22.SpanKind.SERVER,
7186
7207
  attributes: {
7187
7208
  [axSpanAttributes.DB_SYSTEM]: this.name,
7188
7209
  [axSpanAttributes.DB_OPERATION_NAME]: "upsert",
@@ -7210,7 +7231,7 @@ var AxDBBase = class {
7210
7231
  return await this.tracer?.startActiveSpan(
7211
7232
  "DB Query Request",
7212
7233
  {
7213
- kind: import_api23.SpanKind.SERVER,
7234
+ kind: import_api22.SpanKind.SERVER,
7214
7235
  attributes: {
7215
7236
  [axSpanAttributes.DB_SYSTEM]: this.name,
7216
7237
  [axSpanAttributes.DB_OPERATION_NAME]: "upsert",
@@ -8162,12 +8183,12 @@ var AxHFDataLoader = class {
8162
8183
 
8163
8184
  // funcs/code.ts
8164
8185
  var _crypto = __toESM(require("crypto"), 1);
8186
+ var _fs = __toESM(require("fs"), 1);
8165
8187
  var _http = __toESM(require("http"), 1);
8166
8188
  var _https = __toESM(require("https"), 1);
8167
- var _fs = __toESM(require("fs"), 1);
8168
8189
  var _os = __toESM(require("os"), 1);
8169
8190
  var _process = __toESM(require("process"), 1);
8170
- var import_vm = require("vm");
8191
+ var import_node_vm = require("vm");
8171
8192
  var AxJSInterpreterPermission = /* @__PURE__ */ ((AxJSInterpreterPermission2) => {
8172
8193
  AxJSInterpreterPermission2["FS"] = "node:fs";
8173
8194
  AxJSInterpreterPermission2["NET"] = "net";
@@ -8201,7 +8222,7 @@ var AxJSInterpreter = class {
8201
8222
  if (this.permissions.includes("process" /* PROCESS */)) {
8202
8223
  context.process = _process;
8203
8224
  }
8204
- return (0, import_vm.runInNewContext)(`(function() { ${code} })()`, context);
8225
+ return (0, import_node_vm.runInNewContext)(`(function() { ${code} })()`, context);
8205
8226
  }
8206
8227
  toFunction() {
8207
8228
  return {
@@ -8438,7 +8459,7 @@ var AxTestPrompt = class {
8438
8459
  successCount++;
8439
8460
  }
8440
8461
  const et = (/* @__PURE__ */ new Date()).getTime() - st;
8441
- updateProgressBar(i, total, successCount, et, 30, "Testing Prompt");
8462
+ updateProgressBar(i, total, successCount, et, "Testing Prompt", 30);
8442
8463
  }
8443
8464
  console.log(
8444
8465
  "\nPerformance: ",
@@ -8604,6 +8625,213 @@ var AxEmbeddingAdapter = class {
8604
8625
  }
8605
8626
  };
8606
8627
 
8628
+ // mcp/client.ts
8629
+ var colorLog7 = new ColorLog();
8630
+ var AxMCPClient = class {
8631
+ constructor(transport, options = {}) {
8632
+ this.transport = transport;
8633
+ this.options = options;
8634
+ }
8635
+ functions = [];
8636
+ requestId = 0;
8637
+ capabilities = {};
8638
+ async init() {
8639
+ if ("connect" in this.transport) {
8640
+ await this.transport.connect?.();
8641
+ }
8642
+ const res = await this.sendRequest("initialize", {
8643
+ protocolVersion: "2024-11-05",
8644
+ capabilities: {
8645
+ roots: { listChanged: true },
8646
+ sampling: {}
8647
+ },
8648
+ clientInfo: {
8649
+ name: "AxMCPClient",
8650
+ version: "1.0.0"
8651
+ }
8652
+ });
8653
+ if (res.capabilities.tools) {
8654
+ this.capabilities.tools = true;
8655
+ }
8656
+ if (res.capabilities.resources) {
8657
+ this.capabilities.resources = true;
8658
+ }
8659
+ if (res.capabilities.prompts) {
8660
+ this.capabilities.prompts = true;
8661
+ }
8662
+ await this.sendNotification("initialized");
8663
+ await this.discoverFunctions();
8664
+ }
8665
+ async discoverFunctions() {
8666
+ if (!this.capabilities.tools) {
8667
+ throw new Error("Tools are not supported");
8668
+ }
8669
+ const res = await this.sendRequest(
8670
+ "tools/list"
8671
+ );
8672
+ this.functions = res.tools.map(
8673
+ (fn) => ({
8674
+ name: fn.name,
8675
+ description: fn.description,
8676
+ parameters: fn.inputSchema,
8677
+ func: async (args) => {
8678
+ const result = await this.sendRequest("tools/call", { name: fn.name, arguments: args });
8679
+ return result;
8680
+ }
8681
+ })
8682
+ );
8683
+ }
8684
+ async ping() {
8685
+ await this.sendRequest("ping");
8686
+ }
8687
+ toFunction() {
8688
+ return this.functions;
8689
+ }
8690
+ async sendRequest(method, params) {
8691
+ const request = {
8692
+ jsonrpc: "2.0",
8693
+ id: ++this.requestId,
8694
+ method,
8695
+ params
8696
+ };
8697
+ if (this.options.debug) {
8698
+ console.log(
8699
+ colorLog7.blueBright(
8700
+ `> Sending request:
8701
+ ${JSON.stringify(request, null, 2)}`
8702
+ )
8703
+ );
8704
+ }
8705
+ const res = await this.transport.send(request);
8706
+ if (this.options.debug) {
8707
+ console.log(
8708
+ colorLog7.greenBright(
8709
+ `> Received response:
8710
+ ${JSON.stringify(res, null, 2)}`
8711
+ )
8712
+ );
8713
+ }
8714
+ if ("error" in res) {
8715
+ throw new Error(`RPC Error ${res.error.code}: ${res.error.message}`);
8716
+ }
8717
+ if ("result" in res) {
8718
+ return res.result;
8719
+ }
8720
+ throw new Error("Invalid response no result or error");
8721
+ }
8722
+ async sendNotification(method, params) {
8723
+ const notification = {
8724
+ jsonrpc: "2.0",
8725
+ method,
8726
+ params
8727
+ };
8728
+ if (this.options.debug) {
8729
+ console.log(
8730
+ "\u27A1\uFE0F Sending notification:",
8731
+ JSON.stringify(notification, null, 2)
8732
+ );
8733
+ }
8734
+ await this.transport.sendNotification(notification);
8735
+ }
8736
+ };
8737
+
8738
+ // mcp/httpTransport.ts
8739
+ var AxMCPHTTPTransport = class {
8740
+ endpoint = null;
8741
+ sseUrl;
8742
+ eventSource;
8743
+ constructor(sseUrl) {
8744
+ this.sseUrl = sseUrl;
8745
+ }
8746
+ async connect() {
8747
+ return new Promise((resolve, reject) => {
8748
+ this.eventSource = new EventSource(this.sseUrl);
8749
+ this.eventSource.addEventListener("endpoint", (event) => {
8750
+ try {
8751
+ const messageEvent = event;
8752
+ const data = JSON.parse(messageEvent.data);
8753
+ if (!data.uri) {
8754
+ throw new Error("Endpoint URI missing in SSE event data");
8755
+ }
8756
+ this.endpoint = data.uri;
8757
+ resolve();
8758
+ } catch (error) {
8759
+ reject(error);
8760
+ }
8761
+ });
8762
+ this.eventSource.onerror = () => {
8763
+ reject(new Error("Failed to establish SSE connection"));
8764
+ };
8765
+ });
8766
+ }
8767
+ async send(message) {
8768
+ if (!this.endpoint) {
8769
+ throw new Error(
8770
+ "HTTPTransport endpoint is not initialized. Call connect() first."
8771
+ );
8772
+ }
8773
+ const res = await fetch(this.endpoint, {
8774
+ method: "POST",
8775
+ headers: { "Content-Type": "application/json" },
8776
+ body: JSON.stringify(message)
8777
+ });
8778
+ if (!res.ok) {
8779
+ throw new Error(`HTTP error ${res.status}: ${res.statusText}`);
8780
+ }
8781
+ return res.json();
8782
+ }
8783
+ async sendNotification(message) {
8784
+ if (!this.endpoint) {
8785
+ throw new Error(
8786
+ "HTTPTransport endpoint is not initialized. Call connect() first."
8787
+ );
8788
+ }
8789
+ await fetch(this.endpoint, {
8790
+ method: "POST",
8791
+ headers: { "Content-Type": "application/json" },
8792
+ body: JSON.stringify(message)
8793
+ });
8794
+ }
8795
+ };
8796
+
8797
+ // mcp/stdioTransport.ts
8798
+ var import_node_child_process = require("child_process");
8799
+ var import_node_readline = __toESM(require("readline"), 1);
8800
+ var AxMCPStdioTransport = class {
8801
+ process;
8802
+ rl;
8803
+ pendingResponses = /* @__PURE__ */ new Map();
8804
+ constructor(config) {
8805
+ this.process = (0, import_node_child_process.spawn)(config.command, config.args ?? [], {
8806
+ env: config.env ? { ...process.env, ...config.env } : process.env
8807
+ });
8808
+ this.rl = import_node_readline.default.createInterface({ input: this.process.stdout });
8809
+ this.rl.on("line", (line) => {
8810
+ const response = JSON.parse(line);
8811
+ const resolver = this.pendingResponses.get(response.id);
8812
+ if (resolver) {
8813
+ resolver(response);
8814
+ this.pendingResponses.delete(response.id);
8815
+ }
8816
+ });
8817
+ }
8818
+ async send(message) {
8819
+ return new Promise((resolve) => {
8820
+ this.pendingResponses.set(message.id, (res) => {
8821
+ resolve(res);
8822
+ });
8823
+ this.process.stdin.write(`${JSON.stringify(message)}
8824
+ `);
8825
+ });
8826
+ }
8827
+ async sendNotification(message) {
8828
+ this.process.stdin.write(`${JSON.stringify(message)}
8829
+ `);
8830
+ }
8831
+ async connect() {
8832
+ }
8833
+ };
8834
+
8607
8835
  // ai/multiservice.ts
8608
8836
  var AxMultiServiceRouter = class {
8609
8837
  services = /* @__PURE__ */ new Map();
@@ -8856,6 +9084,9 @@ var AxRAG = class extends AxChainOfThought {
8856
9084
  AxJSInterpreter,
8857
9085
  AxJSInterpreterPermission,
8858
9086
  AxLLMRequestTypeValues,
9087
+ AxMCPClient,
9088
+ AxMCPHTTPTransport,
9089
+ AxMCPStdioTransport,
8859
9090
  AxMemory,
8860
9091
  AxMockAIService,
8861
9092
  AxMultiServiceRouter,