@annals/agent-mesh 0.15.1 → 0.16.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.
Files changed (2) hide show
  1. package/dist/index.js +89 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2919,6 +2919,12 @@ async function asyncChat(opts) {
2919
2919
  process.stderr.write(` done
2920
2920
  `);
2921
2921
  process.stdout.write((task.result || "") + "\n");
2922
+ if (task.attachments?.length) {
2923
+ for (const att of task.attachments) {
2924
+ process.stdout.write(`${GRAY}[file: ${att.name} -> ${att.url}]${RESET}
2925
+ `);
2926
+ }
2927
+ }
2922
2928
  return;
2923
2929
  }
2924
2930
  if (task.status === "failed") {
@@ -3806,6 +3812,25 @@ function registerDiscoverCommand(program2) {
3806
3812
  // src/commands/call.ts
3807
3813
  import { readFileSync, writeFileSync as writeFileSync2 } from "fs";
3808
3814
  var DEFAULT_BASE_URL4 = "https://agents.hot";
3815
+ async function submitRating(baseUrl, token, agentId, callId, rating) {
3816
+ const res = await fetch(`${baseUrl}/api/agents/${agentId}/rate`, {
3817
+ method: "POST",
3818
+ headers: {
3819
+ Authorization: `Bearer ${token}`,
3820
+ "Content-Type": "application/json"
3821
+ },
3822
+ body: JSON.stringify({ call_id: callId, rating })
3823
+ });
3824
+ if (!res.ok) {
3825
+ let msg = `HTTP ${res.status}`;
3826
+ try {
3827
+ const body = await res.json();
3828
+ msg = body.message || body.error || msg;
3829
+ } catch {
3830
+ }
3831
+ throw new Error(msg);
3832
+ }
3833
+ }
3809
3834
  function sleep5(ms) {
3810
3835
  return new Promise((resolve2) => setTimeout(resolve2, ms));
3811
3836
  }
@@ -3878,15 +3903,30 @@ async function asyncCall(opts) {
3878
3903
  }
3879
3904
  const result = task.result || "";
3880
3905
  if (opts.json) {
3881
- console.log(JSON.stringify({ call_id, request_id, status: "completed", result }));
3906
+ console.log(JSON.stringify({
3907
+ call_id,
3908
+ request_id,
3909
+ status: "completed",
3910
+ result,
3911
+ ...task.attachments?.length ? { attachments: task.attachments } : {},
3912
+ rate_hint: `POST /api/agents/${opts.id}/rate body: { call_id: "${call_id}", rating: 1-5 }`
3913
+ }));
3882
3914
  } else {
3883
3915
  process.stdout.write(result + "\n");
3916
+ if (task.attachments?.length) {
3917
+ for (const att of task.attachments) {
3918
+ log.info(` ${GRAY}File:${RESET} ${att.name} ${GRAY}${att.url}${RESET}`);
3919
+ }
3920
+ }
3884
3921
  }
3885
3922
  if (opts.outputFile && result) {
3886
3923
  writeFileSync2(opts.outputFile, result);
3887
3924
  if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
3888
3925
  }
3889
- return;
3926
+ if (!opts.json) {
3927
+ log.info(`${GRAY}Rate this call: agent-mesh rate ${call_id} <1-5> --agent ${opts.id}${RESET}`);
3928
+ }
3929
+ return { callId: call_id };
3890
3930
  }
3891
3931
  if (task.status === "failed") {
3892
3932
  if (!opts.json) {
@@ -3965,6 +4005,7 @@ async function streamCall(opts) {
3965
4005
  let buffer = "";
3966
4006
  let outputBuffer = "";
3967
4007
  let inThinkingBlock = false;
4008
+ let callId = res.headers.get("X-Call-Id") || "";
3968
4009
  while (true) {
3969
4010
  const { done, value } = await reader.read();
3970
4011
  if (done) break;
@@ -3975,6 +4016,9 @@ async function streamCall(opts) {
3975
4016
  if (data === "[DONE]") continue;
3976
4017
  try {
3977
4018
  const event = JSON.parse(data);
4019
+ if (event.type === "start" && event.call_id) {
4020
+ callId = event.call_id;
4021
+ }
3978
4022
  if (opts.json) {
3979
4023
  console.log(JSON.stringify(event));
3980
4024
  } else {
@@ -4035,10 +4079,14 @@ Error: ${event.message}
4035
4079
  if (!opts.json) {
4036
4080
  console.log("\n");
4037
4081
  log.success("Call completed");
4082
+ if (callId) {
4083
+ log.info(`${GRAY}Rate this call: agent-mesh rate ${callId} <1-5> --agent ${opts.id}${RESET}`);
4084
+ }
4038
4085
  }
4086
+ return { callId };
4039
4087
  }
4040
4088
  function registerCallCommand(program2) {
4041
- program2.command("call <agent>").description("Call an agent on the A2A network (default: async polling)").requiredOption("--task <description>", "Task description").option("--input-file <path>", "Read file and append to task description").option("--output-file <path>", "Save response text to file").option("--stream", "Use SSE streaming instead of async polling").option("--json", "Output JSONL events").option("--timeout <seconds>", "Timeout in seconds", "300").action(async (agentInput, opts) => {
4089
+ program2.command("call <agent>").description("Call an agent on the A2A network (default: async polling)").requiredOption("--task <description>", "Task description").option("--input-file <path>", "Read file and append to task description").option("--output-file <path>", "Save response text to file").option("--stream", "Use SSE streaming instead of async polling").option("--json", "Output JSONL events").option("--timeout <seconds>", "Timeout in seconds", "300").option("--rate <rating>", "Rate the agent after call (1-5)", parseInt).action(async (agentInput, opts) => {
4042
4090
  try {
4043
4091
  const token = loadToken();
4044
4092
  if (!token) {
@@ -4069,12 +4117,23 @@ ${content}`;
4069
4117
  outputFile: opts.outputFile,
4070
4118
  signal: abortController.signal
4071
4119
  };
4120
+ let result;
4072
4121
  if (opts.stream) {
4073
- await streamCall(callOpts);
4122
+ result = await streamCall(callOpts);
4074
4123
  } else {
4075
- await asyncCall(callOpts);
4124
+ result = await asyncCall(callOpts);
4076
4125
  }
4077
4126
  clearTimeout(timer);
4127
+ if (opts.rate && result.callId) {
4128
+ try {
4129
+ await submitRating(DEFAULT_BASE_URL4, token, id, result.callId, opts.rate);
4130
+ if (!opts.json) {
4131
+ log.success(`Rated ${opts.rate}/5`);
4132
+ }
4133
+ } catch (rateErr) {
4134
+ log.warn(`Rating failed: ${rateErr.message}`);
4135
+ }
4136
+ }
4078
4137
  } catch (err) {
4079
4138
  if (err.name === "AbortError") {
4080
4139
  log.error("Call timed out");
@@ -4374,6 +4433,30 @@ function registerRegisterCommand(program2) {
4374
4433
  });
4375
4434
  }
4376
4435
 
4436
+ // src/commands/rate.ts
4437
+ var DEFAULT_BASE_URL6 = "https://agents.hot";
4438
+ function registerRateCommand(program2) {
4439
+ program2.command("rate <call-id> <rating>").description("Rate a completed A2A call (1-5)").requiredOption("--agent <agent-id>", "Agent UUID that was called").action(async (callId, ratingStr, opts) => {
4440
+ const token = loadToken();
4441
+ if (!token) {
4442
+ log.error("Not authenticated. Run `agent-mesh login` first.");
4443
+ process.exit(1);
4444
+ }
4445
+ const rating = parseInt(ratingStr, 10);
4446
+ if (isNaN(rating) || rating < 1 || rating > 5) {
4447
+ log.error("Rating must be an integer between 1 and 5");
4448
+ process.exit(1);
4449
+ }
4450
+ try {
4451
+ await submitRating(DEFAULT_BASE_URL6, token, opts.agent, callId, rating);
4452
+ log.success(`Rated ${rating}/5 for call ${callId.slice(0, 8)}...`);
4453
+ } catch (err) {
4454
+ log.error(err.message);
4455
+ process.exit(1);
4456
+ }
4457
+ });
4458
+ }
4459
+
4377
4460
  // src/index.ts
4378
4461
  var require2 = createRequire(import.meta.url);
4379
4462
  var { version } = require2("../package.json");
@@ -4402,4 +4485,5 @@ registerConfigCommand(program);
4402
4485
  registerStatsCommand(program);
4403
4486
  registerSubscribeCommand(program);
4404
4487
  registerRegisterCommand(program);
4488
+ registerRateCommand(program);
4405
4489
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@annals/agent-mesh",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "CLI bridge connecting local AI agents to the Agents.Hot platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "main": "./dist/index.js",
10
10
  "dependencies": {
11
- "@annals/bridge-protocol": "^0.1.0",
11
+ "@annals/bridge-protocol": "^0.2.0",
12
12
  "commander": "^13.0.0",
13
13
  "ws": "^8.18.0"
14
14
  },