@meshagent/meshagent 0.23.0 → 0.24.0

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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.24.0]
2
+ - Breaking: removed `AgentsClient.ask` and `listAgents` from the TypeScript SDK.
3
+ - Breaking: renamed `AgentCallContext` to `TaskContext` and removed RemoteTaskRunner agent ask handler registration.
4
+
1
5
  ## [0.23.0]
2
6
  - Stability
3
7
 
@@ -1,7 +1,5 @@
1
1
  import { RoomClient } from "./room-client";
2
- import { Response, JsonResponse } from "./response";
3
- import { RemoteParticipant } from "./participant";
4
- import { Requirement } from "./requirement";
2
+ import { Response } from "./response";
5
3
  export declare class AgentDescription {
6
4
  readonly name: string;
7
5
  readonly title: string;
@@ -78,14 +76,7 @@ export declare class AgentsClient {
78
76
  url: string;
79
77
  arguments: Record<string, any>;
80
78
  }): Promise<void>;
81
- ask(params: {
82
- agent: string;
83
- arguments: Record<string, any>;
84
- onBehalfOf?: RemoteParticipant;
85
- requires?: Requirement[];
86
- }): Promise<JsonResponse>;
87
79
  listToolkits(): Promise<ToolkitDescription[]>;
88
- listAgents(): Promise<AgentDescription[]>;
89
80
  invokeTool(params: {
90
81
  toolkit: string;
91
82
  tool: string;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentsClient = exports.ToolkitConfiguration = exports.ToolkitDescription = exports.ToolDescription = exports.AgentDescription = void 0;
4
- const response_1 = require("./response");
5
4
  class AgentDescription {
6
5
  constructor({ name, title, description, outputSchema, inputSchema, labels, supportsTools, }) {
7
6
  this.name = name;
@@ -159,22 +158,6 @@ class AgentsClient {
159
158
  async call(params) {
160
159
  await this.client.sendRequest("agent.call", params);
161
160
  }
162
- async ask(params) {
163
- const { agent, arguments: args, onBehalfOf, requires } = params;
164
- const payload = {
165
- agent,
166
- arguments: args,
167
- };
168
- if (onBehalfOf) {
169
- payload["on_behalf_of_id"] = onBehalfOf.id;
170
- }
171
- if (requires && requires.length > 0) {
172
- payload["requires"] = requires.map((req) => req.toJson());
173
- }
174
- const result = (await this.client.sendRequest("agent.ask", payload));
175
- const answer = (result.json["answer"] ?? {});
176
- return new response_1.JsonResponse({ json: answer });
177
- }
178
161
  async listToolkits() {
179
162
  const result = (await this.client.sendRequest("agent.list_toolkits", {}));
180
163
  const tools = result.json["tools"];
@@ -185,10 +168,6 @@ class AgentsClient {
185
168
  }
186
169
  return toolkits;
187
170
  }
188
- async listAgents() {
189
- const result = (await this.client.sendRequest("agent.list_agents", {}));
190
- return (result.json["agents"] || []).map(AgentDescription.fromJson);
191
- }
192
171
  async invokeTool(params) {
193
172
  return await this.client.sendRequest("agent.invoke_tool", params);
194
173
  }
@@ -15,7 +15,7 @@ export declare class AgentChatContext {
15
15
  toJson(): Record<string, any>;
16
16
  static fromJson(json: Record<string, any>): AgentChatContext;
17
17
  }
18
- export declare class AgentCallContext {
18
+ export declare class TaskContext {
19
19
  private readonly _jwt;
20
20
  private readonly _chat;
21
21
  private readonly _apiUrl;
@@ -96,8 +96,5 @@ export declare abstract class RemoteTaskRunner {
96
96
  });
97
97
  start(): Promise<void>;
98
98
  stop(): Promise<void>;
99
- protected _register(): Promise<void>;
100
- protected _unregister(): Promise<void>;
101
- abstract ask(context: AgentCallContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
102
- private _ask;
99
+ abstract ask(context: TaskContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
103
100
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteTaskRunner = exports.RemoteToolkit = exports.Toolkit = exports.Tool = exports.AgentCallContext = exports.AgentChatContext = void 0;
3
+ exports.RemoteTaskRunner = exports.RemoteToolkit = exports.Toolkit = exports.Tool = exports.TaskContext = exports.AgentChatContext = void 0;
4
4
  const response_1 = require("./response");
5
5
  const utils_1 = require("./utils");
6
6
  class AgentChatContext {
@@ -55,7 +55,7 @@ class AgentChatContext {
55
55
  }
56
56
  }
57
57
  exports.AgentChatContext = AgentChatContext;
58
- class AgentCallContext {
58
+ class TaskContext {
59
59
  constructor({ chat, jwt, api_url }) {
60
60
  this._jwt = jwt;
61
61
  this._chat = chat;
@@ -71,7 +71,7 @@ class AgentCallContext {
71
71
  return this._apiUrl;
72
72
  }
73
73
  }
74
- exports.AgentCallContext = AgentCallContext;
74
+ exports.TaskContext = TaskContext;
75
75
  class Tool {
76
76
  constructor({ name, description, title, inputSchema, thumbnailUrl }) {
77
77
  this.name = name;
@@ -172,56 +172,9 @@ class RemoteTaskRunner {
172
172
  this.required = required;
173
173
  }
174
174
  async start() {
175
- const handler = this._ask.bind(this);
176
- this.client.protocol.addHandler("agent.ask", handler);
177
- await this._register();
178
175
  }
179
176
  async stop() {
180
- await this._unregister();
181
177
  this.client.protocol.removeHandler("agent.ask");
182
178
  }
183
- async _register() {
184
- const res = await this.client.sendRequest("agent.register_agent", {
185
- name: this.name,
186
- description: this.description,
187
- input_schema: this.inputSchema,
188
- output_schema: this.outputSchema,
189
- supports_tools: this.supportsTools,
190
- requires: this.required.map((r) => ({
191
- toolkit: r.name,
192
- tools: r.tools,
193
- })),
194
- });
195
- this._registrationId = res.json["id"];
196
- }
197
- async _unregister() {
198
- if (!this._registrationId)
199
- return;
200
- await this.client.sendRequest("agent.unregister_agent", { id: this._registrationId });
201
- }
202
- async _ask(protocol, messageId, msgType, data) {
203
- console.info("_ask handler invoked with data", data);
204
- try {
205
- const [message, _] = (0, utils_1.unpackMessage)(data);
206
- console.info("got message", message);
207
- const jwt = message["jwt"];
208
- const args = message["arguments"];
209
- const task_id = message["task_id"];
210
- const context_json = message["context"];
211
- const api_url = message["api_url"];
212
- const chat = AgentChatContext.fromJson(context_json);
213
- const callContext = new AgentCallContext({ chat, jwt, api_url });
214
- const answer = await this.ask(callContext, args);
215
- const encoded = (0, utils_1.packMessage)({ task_id, answer });
216
- await protocol.send("agent.ask_response", encoded);
217
- }
218
- catch (e) {
219
- const rawError = {
220
- task_id: "",
221
- error: String(e),
222
- };
223
- await protocol.send("agent.ask_response", (0, utils_1.packMessage)(rawError));
224
- }
225
- }
226
179
  }
227
180
  exports.RemoteTaskRunner = RemoteTaskRunner;
@@ -1,7 +1,5 @@
1
1
  import { RoomClient } from "./room-client";
2
- import { Response, JsonResponse } from "./response";
3
- import { RemoteParticipant } from "./participant";
4
- import { Requirement } from "./requirement";
2
+ import { Response } from "./response";
5
3
  export declare class AgentDescription {
6
4
  readonly name: string;
7
5
  readonly title: string;
@@ -78,14 +76,7 @@ export declare class AgentsClient {
78
76
  url: string;
79
77
  arguments: Record<string, any>;
80
78
  }): Promise<void>;
81
- ask(params: {
82
- agent: string;
83
- arguments: Record<string, any>;
84
- onBehalfOf?: RemoteParticipant;
85
- requires?: Requirement[];
86
- }): Promise<JsonResponse>;
87
79
  listToolkits(): Promise<ToolkitDescription[]>;
88
- listAgents(): Promise<AgentDescription[]>;
89
80
  invokeTool(params: {
90
81
  toolkit: string;
91
82
  tool: string;
@@ -1,4 +1,3 @@
1
- import { JsonResponse } from "./response";
2
1
  export class AgentDescription {
3
2
  constructor({ name, title, description, outputSchema, inputSchema, labels, supportsTools, }) {
4
3
  this.name = name;
@@ -152,22 +151,6 @@ export class AgentsClient {
152
151
  async call(params) {
153
152
  await this.client.sendRequest("agent.call", params);
154
153
  }
155
- async ask(params) {
156
- const { agent, arguments: args, onBehalfOf, requires } = params;
157
- const payload = {
158
- agent,
159
- arguments: args,
160
- };
161
- if (onBehalfOf) {
162
- payload["on_behalf_of_id"] = onBehalfOf.id;
163
- }
164
- if (requires && requires.length > 0) {
165
- payload["requires"] = requires.map((req) => req.toJson());
166
- }
167
- const result = (await this.client.sendRequest("agent.ask", payload));
168
- const answer = (result.json["answer"] ?? {});
169
- return new JsonResponse({ json: answer });
170
- }
171
154
  async listToolkits() {
172
155
  const result = (await this.client.sendRequest("agent.list_toolkits", {}));
173
156
  const tools = result.json["tools"];
@@ -178,10 +161,6 @@ export class AgentsClient {
178
161
  }
179
162
  return toolkits;
180
163
  }
181
- async listAgents() {
182
- const result = (await this.client.sendRequest("agent.list_agents", {}));
183
- return (result.json["agents"] || []).map(AgentDescription.fromJson);
184
- }
185
164
  async invokeTool(params) {
186
165
  return await this.client.sendRequest("agent.invoke_tool", params);
187
166
  }
@@ -15,7 +15,7 @@ export declare class AgentChatContext {
15
15
  toJson(): Record<string, any>;
16
16
  static fromJson(json: Record<string, any>): AgentChatContext;
17
17
  }
18
- export declare class AgentCallContext {
18
+ export declare class TaskContext {
19
19
  private readonly _jwt;
20
20
  private readonly _chat;
21
21
  private readonly _apiUrl;
@@ -96,8 +96,5 @@ export declare abstract class RemoteTaskRunner {
96
96
  });
97
97
  start(): Promise<void>;
98
98
  stop(): Promise<void>;
99
- protected _register(): Promise<void>;
100
- protected _unregister(): Promise<void>;
101
- abstract ask(context: AgentCallContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
102
- private _ask;
99
+ abstract ask(context: TaskContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
103
100
  }
package/dist/esm/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ErrorResponse } from "./response";
2
- import { packMessage, unpackMessage } from "./utils";
2
+ import { unpackMessage } from "./utils";
3
3
  export class AgentChatContext {
4
4
  constructor({ messages, systemRole = "system" }) {
5
5
  this.messages = messages ? [...messages] : [];
@@ -51,7 +51,7 @@ export class AgentChatContext {
51
51
  });
52
52
  }
53
53
  }
54
- export class AgentCallContext {
54
+ export class TaskContext {
55
55
  constructor({ chat, jwt, api_url }) {
56
56
  this._jwt = jwt;
57
57
  this._chat = chat;
@@ -164,55 +164,8 @@ export class RemoteTaskRunner {
164
164
  this.required = required;
165
165
  }
166
166
  async start() {
167
- const handler = this._ask.bind(this);
168
- this.client.protocol.addHandler("agent.ask", handler);
169
- await this._register();
170
167
  }
171
168
  async stop() {
172
- await this._unregister();
173
169
  this.client.protocol.removeHandler("agent.ask");
174
170
  }
175
- async _register() {
176
- const res = await this.client.sendRequest("agent.register_agent", {
177
- name: this.name,
178
- description: this.description,
179
- input_schema: this.inputSchema,
180
- output_schema: this.outputSchema,
181
- supports_tools: this.supportsTools,
182
- requires: this.required.map((r) => ({
183
- toolkit: r.name,
184
- tools: r.tools,
185
- })),
186
- });
187
- this._registrationId = res.json["id"];
188
- }
189
- async _unregister() {
190
- if (!this._registrationId)
191
- return;
192
- await this.client.sendRequest("agent.unregister_agent", { id: this._registrationId });
193
- }
194
- async _ask(protocol, messageId, msgType, data) {
195
- console.info("_ask handler invoked with data", data);
196
- try {
197
- const [message, _] = unpackMessage(data);
198
- console.info("got message", message);
199
- const jwt = message["jwt"];
200
- const args = message["arguments"];
201
- const task_id = message["task_id"];
202
- const context_json = message["context"];
203
- const api_url = message["api_url"];
204
- const chat = AgentChatContext.fromJson(context_json);
205
- const callContext = new AgentCallContext({ chat, jwt, api_url });
206
- const answer = await this.ask(callContext, args);
207
- const encoded = packMessage({ task_id, answer });
208
- await protocol.send("agent.ask_response", encoded);
209
- }
210
- catch (e) {
211
- const rawError = {
212
- task_id: "",
213
- error: String(e),
214
- };
215
- await protocol.send("agent.ask_response", packMessage(rawError));
216
- }
217
- }
218
171
  }
@@ -1,7 +1,5 @@
1
1
  import { RoomClient } from "./room-client";
2
- import { Response, JsonResponse } from "./response";
3
- import { RemoteParticipant } from "./participant";
4
- import { Requirement } from "./requirement";
2
+ import { Response } from "./response";
5
3
  export declare class AgentDescription {
6
4
  readonly name: string;
7
5
  readonly title: string;
@@ -78,14 +76,7 @@ export declare class AgentsClient {
78
76
  url: string;
79
77
  arguments: Record<string, any>;
80
78
  }): Promise<void>;
81
- ask(params: {
82
- agent: string;
83
- arguments: Record<string, any>;
84
- onBehalfOf?: RemoteParticipant;
85
- requires?: Requirement[];
86
- }): Promise<JsonResponse>;
87
79
  listToolkits(): Promise<ToolkitDescription[]>;
88
- listAgents(): Promise<AgentDescription[]>;
89
80
  invokeTool(params: {
90
81
  toolkit: string;
91
82
  tool: string;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentsClient = exports.ToolkitConfiguration = exports.ToolkitDescription = exports.ToolDescription = exports.AgentDescription = void 0;
4
- const response_1 = require("./response");
5
4
  class AgentDescription {
6
5
  constructor({ name, title, description, outputSchema, inputSchema, labels, supportsTools, }) {
7
6
  this.name = name;
@@ -159,22 +158,6 @@ class AgentsClient {
159
158
  async call(params) {
160
159
  await this.client.sendRequest("agent.call", params);
161
160
  }
162
- async ask(params) {
163
- const { agent, arguments: args, onBehalfOf, requires } = params;
164
- const payload = {
165
- agent,
166
- arguments: args,
167
- };
168
- if (onBehalfOf) {
169
- payload["on_behalf_of_id"] = onBehalfOf.id;
170
- }
171
- if (requires && requires.length > 0) {
172
- payload["requires"] = requires.map((req) => req.toJson());
173
- }
174
- const result = (await this.client.sendRequest("agent.ask", payload));
175
- const answer = (result.json["answer"] ?? {});
176
- return new response_1.JsonResponse({ json: answer });
177
- }
178
161
  async listToolkits() {
179
162
  const result = (await this.client.sendRequest("agent.list_toolkits", {}));
180
163
  const tools = result.json["tools"];
@@ -185,10 +168,6 @@ class AgentsClient {
185
168
  }
186
169
  return toolkits;
187
170
  }
188
- async listAgents() {
189
- const result = (await this.client.sendRequest("agent.list_agents", {}));
190
- return (result.json["agents"] || []).map(AgentDescription.fromJson);
191
- }
192
171
  async invokeTool(params) {
193
172
  return await this.client.sendRequest("agent.invoke_tool", params);
194
173
  }
@@ -15,7 +15,7 @@ export declare class AgentChatContext {
15
15
  toJson(): Record<string, any>;
16
16
  static fromJson(json: Record<string, any>): AgentChatContext;
17
17
  }
18
- export declare class AgentCallContext {
18
+ export declare class TaskContext {
19
19
  private readonly _jwt;
20
20
  private readonly _chat;
21
21
  private readonly _apiUrl;
@@ -96,8 +96,5 @@ export declare abstract class RemoteTaskRunner {
96
96
  });
97
97
  start(): Promise<void>;
98
98
  stop(): Promise<void>;
99
- protected _register(): Promise<void>;
100
- protected _unregister(): Promise<void>;
101
- abstract ask(context: AgentCallContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
102
- private _ask;
99
+ abstract ask(context: TaskContext, arguments_: Record<string, any>): Promise<Record<string, any>>;
103
100
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteTaskRunner = exports.RemoteToolkit = exports.Toolkit = exports.Tool = exports.AgentCallContext = exports.AgentChatContext = void 0;
3
+ exports.RemoteTaskRunner = exports.RemoteToolkit = exports.Toolkit = exports.Tool = exports.TaskContext = exports.AgentChatContext = void 0;
4
4
  const response_1 = require("./response");
5
5
  const utils_1 = require("./utils");
6
6
  class AgentChatContext {
@@ -55,7 +55,7 @@ class AgentChatContext {
55
55
  }
56
56
  }
57
57
  exports.AgentChatContext = AgentChatContext;
58
- class AgentCallContext {
58
+ class TaskContext {
59
59
  constructor({ chat, jwt, api_url }) {
60
60
  this._jwt = jwt;
61
61
  this._chat = chat;
@@ -71,7 +71,7 @@ class AgentCallContext {
71
71
  return this._apiUrl;
72
72
  }
73
73
  }
74
- exports.AgentCallContext = AgentCallContext;
74
+ exports.TaskContext = TaskContext;
75
75
  class Tool {
76
76
  constructor({ name, description, title, inputSchema, thumbnailUrl }) {
77
77
  this.name = name;
@@ -172,56 +172,9 @@ class RemoteTaskRunner {
172
172
  this.required = required;
173
173
  }
174
174
  async start() {
175
- const handler = this._ask.bind(this);
176
- this.client.protocol.addHandler("agent.ask", handler);
177
- await this._register();
178
175
  }
179
176
  async stop() {
180
- await this._unregister();
181
177
  this.client.protocol.removeHandler("agent.ask");
182
178
  }
183
- async _register() {
184
- const res = await this.client.sendRequest("agent.register_agent", {
185
- name: this.name,
186
- description: this.description,
187
- input_schema: this.inputSchema,
188
- output_schema: this.outputSchema,
189
- supports_tools: this.supportsTools,
190
- requires: this.required.map((r) => ({
191
- toolkit: r.name,
192
- tools: r.tools,
193
- })),
194
- });
195
- this._registrationId = res.json["id"];
196
- }
197
- async _unregister() {
198
- if (!this._registrationId)
199
- return;
200
- await this.client.sendRequest("agent.unregister_agent", { id: this._registrationId });
201
- }
202
- async _ask(protocol, messageId, msgType, data) {
203
- console.info("_ask handler invoked with data", data);
204
- try {
205
- const [message, _] = (0, utils_1.unpackMessage)(data);
206
- console.info("got message", message);
207
- const jwt = message["jwt"];
208
- const args = message["arguments"];
209
- const task_id = message["task_id"];
210
- const context_json = message["context"];
211
- const api_url = message["api_url"];
212
- const chat = AgentChatContext.fromJson(context_json);
213
- const callContext = new AgentCallContext({ chat, jwt, api_url });
214
- const answer = await this.ask(callContext, args);
215
- const encoded = (0, utils_1.packMessage)({ task_id, answer });
216
- await protocol.send("agent.ask_response", encoded);
217
- }
218
- catch (e) {
219
- const rawError = {
220
- task_id: "",
221
- error: String(e),
222
- };
223
- await protocol.send("agent.ask_response", (0, utils_1.packMessage)(rawError));
224
- }
225
- }
226
179
  }
227
180
  exports.RemoteTaskRunner = RemoteTaskRunner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshagent/meshagent",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Meshagent Client",
5
5
  "homepage": "https://github.com/meshagent/meshagent-ts",
6
6
  "scripts": {