open-agents-ai 0.187.177 → 0.187.178

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.
Files changed (2) hide show
  1. package/dist/index.js +77 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -259602,9 +259602,13 @@ var init_transport5 = __esm({
259602
259602
  buffer = "";
259603
259603
  _connected = false;
259604
259604
  stderr = [];
259605
+ notificationHandlers = [];
259605
259606
  get connected() {
259606
259607
  return this._connected;
259607
259608
  }
259609
+ onNotification(handler) {
259610
+ this.notificationHandlers.push(handler);
259611
+ }
259608
259612
  async connect(config) {
259609
259613
  const env2 = { ...process.env, ...config.env };
259610
259614
  const args = config.args ?? [];
@@ -259628,6 +259632,13 @@ var init_transport5 = __esm({
259628
259632
  clearTimeout(p2.timer);
259629
259633
  this.pending.delete(msg.id);
259630
259634
  p2.resolve(msg);
259635
+ } else if ("method" in msg && msg.id == null) {
259636
+ for (const h of this.notificationHandlers) {
259637
+ try {
259638
+ h(msg);
259639
+ } catch {
259640
+ }
259641
+ }
259631
259642
  }
259632
259643
  } catch {
259633
259644
  }
@@ -259883,10 +259894,19 @@ var init_client3 = __esm({
259883
259894
  initResult = null;
259884
259895
  cachedTools = null;
259885
259896
  cachedResources = null;
259897
+ notificationHandlers = [];
259886
259898
  constructor(serverName, config) {
259887
259899
  this.serverName = serverName;
259888
259900
  this.config = config;
259889
259901
  }
259902
+ /**
259903
+ * Register a callback for server-sent JSON-RPC notifications.
259904
+ * Called for progress updates, log messages, list_changed events, etc.
259905
+ * Multiple handlers can be registered.
259906
+ */
259907
+ onNotification(handler) {
259908
+ this.notificationHandlers.push(handler);
259909
+ }
259890
259910
  /** Server name */
259891
259911
  get name() {
259892
259912
  return this.serverName;
@@ -259907,6 +259927,16 @@ var init_client3 = __esm({
259907
259927
  */
259908
259928
  async connect() {
259909
259929
  this.transport = await createTransport(this.config);
259930
+ if (typeof this.transport.onNotification === "function") {
259931
+ this.transport.onNotification((notif) => {
259932
+ for (const h of this.notificationHandlers) {
259933
+ try {
259934
+ h(notif.method, notif.params);
259935
+ } catch {
259936
+ }
259937
+ }
259938
+ });
259939
+ }
259910
259940
  const initReq = {
259911
259941
  jsonrpc: "2.0",
259912
259942
  id: nextId(),
@@ -259988,26 +260018,57 @@ var init_client3 = __esm({
259988
260018
  * @param toolName The tool name (as returned by listTools)
259989
260019
  * @param args Tool arguments matching the tool's inputSchema
259990
260020
  * @param timeoutMs Request timeout (default: 60s for tool calls)
260021
+ * @param options Optional: progressToken to opt-in to progress notifications,
260022
+ * onProgress callback receives every notifications/progress
260023
+ * event whose progressToken matches.
259991
260024
  */
259992
- async callTool(toolName, args, timeoutMs = 6e4) {
260025
+ async callTool(toolName, args, timeoutMs = 6e4, options2) {
259993
260026
  this.ensureConnected();
259994
- const resp = await this.transport.request({
259995
- jsonrpc: "2.0",
259996
- id: nextId(),
259997
- method: "tools/call",
259998
- params: {
259999
- name: toolName,
260000
- arguments: args
260001
- }
260002
- }, timeoutMs);
260003
- if (resp.error) {
260004
- return {
260005
- content: [{ type: "text", text: `MCP error: ${resp.error.message}` }],
260006
- isError: true
260027
+ let unsubscribe = null;
260028
+ if (options2?.progressToken !== void 0 && options2.onProgress) {
260029
+ const wantedToken = options2.progressToken;
260030
+ const handler = (method, params) => {
260031
+ if (method === "notifications/progress" && params?.progressToken === wantedToken) {
260032
+ options2.onProgress({
260033
+ progress: params.progress,
260034
+ total: params.total,
260035
+ message: params.message
260036
+ });
260037
+ }
260038
+ };
260039
+ this.notificationHandlers.push(handler);
260040
+ unsubscribe = () => {
260041
+ const idx = this.notificationHandlers.indexOf(handler);
260042
+ if (idx >= 0)
260043
+ this.notificationHandlers.splice(idx, 1);
260007
260044
  };
260008
260045
  }
260009
- const result = resp.result;
260010
- return result;
260046
+ const reqParams = {
260047
+ name: toolName,
260048
+ arguments: args
260049
+ };
260050
+ if (options2?.progressToken !== void 0) {
260051
+ reqParams._meta = { progressToken: options2.progressToken };
260052
+ }
260053
+ try {
260054
+ const resp = await this.transport.request({
260055
+ jsonrpc: "2.0",
260056
+ id: nextId(),
260057
+ method: "tools/call",
260058
+ params: reqParams
260059
+ }, timeoutMs);
260060
+ if (resp.error) {
260061
+ return {
260062
+ content: [{ type: "text", text: `MCP error: ${resp.error.message}` }],
260063
+ isError: true
260064
+ };
260065
+ }
260066
+ const result = resp.result;
260067
+ return result;
260068
+ } finally {
260069
+ if (unsubscribe)
260070
+ unsubscribe();
260071
+ }
260011
260072
  }
260012
260073
  // ─────────────────────────────────────────────────────────
260013
260074
  // Resource Operations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.177",
3
+ "version": "0.187.178",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",