agent-exchange 0.0.1 → 0.0.3

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/index.mjs +19 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -30,7 +30,10 @@ function connectWS() {
30
30
  type: "register",
31
31
  name,
32
32
  capabilities,
33
- tools: tools.length ? tools : [{ name: "ask", description: "Ask this agent a question" }],
33
+ tools: tools.length ? tools : [
34
+ { name: "ask", description: "Ask this agent a question" },
35
+ { name: "ping", description: "Instant ping (no LLM, for testing)" }
36
+ ],
34
37
  }));
35
38
  });
36
39
 
@@ -73,6 +76,11 @@ async function handleInboundCall(msg) {
73
76
  const { call_id, tool, args: callArgs } = msg;
74
77
  log(`Inbound call: ${tool}(${JSON.stringify(callArgs)})`);
75
78
 
79
+ if (tool === "ping") {
80
+ ws.send(JSON.stringify({ type: "result", call_id, result: { pong: true, timestamp: new Date().toISOString() } }));
81
+ return;
82
+ }
83
+
76
84
  try {
77
85
  let prompt;
78
86
  if (tool === "ask" && callArgs?.question) {
@@ -84,15 +92,19 @@ async function handleInboundCall(msg) {
84
92
  const result = await runClaude(prompt);
85
93
  ws.send(JSON.stringify({ type: "result", call_id, result: JSON.parse(JSON.stringify(result)) }));
86
94
  } catch (err) {
95
+ log(`Error handling call: ${err.message}`);
87
96
  ws.send(JSON.stringify({ type: "result", call_id, error: err.message }));
88
97
  }
89
98
  }
90
99
 
91
100
  function runClaude(prompt) {
92
101
  return new Promise((resolve, reject) => {
93
- const proc = spawn("claude", ["-p", prompt, "--output-format", "json"], {
102
+ const claudePath = process.env.CLAUDE_PATH || "claude";
103
+ log(`Spawning: ${claudePath} -p "${prompt.substring(0, 80)}..."`);
104
+ const proc = spawn(claudePath, ["-p", prompt, "--output-format", "json"], {
94
105
  stdio: ["pipe", "pipe", "pipe"],
95
106
  timeout: 300000,
107
+ shell: true,
96
108
  });
97
109
 
98
110
  let stdout = "";
@@ -101,6 +113,7 @@ function runClaude(prompt) {
101
113
  proc.stderr.on("data", (d) => stderr += d);
102
114
 
103
115
  proc.on("close", (code) => {
116
+ log(`claude exited with code ${code}`);
104
117
  if (code !== 0) {
105
118
  reject(new Error(stderr || `claude exited with code ${code}`));
106
119
  return;
@@ -113,7 +126,10 @@ function runClaude(prompt) {
113
126
  }
114
127
  });
115
128
 
116
- proc.on("error", (err) => reject(err));
129
+ proc.on("error", (err) => {
130
+ log(`spawn error: ${err.message}`);
131
+ reject(err);
132
+ });
117
133
  });
118
134
  }
119
135
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-exchange",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Connect your agent to the Agent Exchange — discover and call other agents via MCP",
5
5
  "bin": {
6
6
  "agent-exchange": "./index.mjs"