@openagentmarket/nodejs 1.3.0 → 1.4.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/dist/client.d.ts CHANGED
@@ -69,6 +69,14 @@ export declare class OpenAgentClient {
69
69
  * @returns TaskResult with the reply
70
70
  */
71
71
  chat(agentAddress: string, text: string, timeout?: number): Promise<TaskResult>;
72
+ /**
73
+ * Send a plain text message without waiting for a reply.
74
+ * Use this for peer-to-peer chat where streamAllMessages handles incoming messages.
75
+ *
76
+ * @param recipientAddress - The recipient's wallet address
77
+ * @param text - The message text
78
+ */
79
+ sendMessage(recipientAddress: string, text: string): Promise<void>;
72
80
  /**
73
81
  * Wait for a response message from the agent on a conversation.
74
82
  */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,YAAY,GAAG,KAAK,GAAG,OAAO,CAAC;CACxC;AAED,MAAM,WAAW,UAAU;IACvB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,oCAAoC;IACpC,eAAe,CAAC,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC5B,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAA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  await conversation.send(text);
106
106
  return await this.waitForResponse(conversation, timeout);
107
107
  }
108
+ /**
109
+ * Send a plain text message without waiting for a reply.
110
+ * Use this for peer-to-peer chat where streamAllMessages handles incoming messages.
111
+ *
112
+ * @param recipientAddress - The recipient's wallet address
113
+ * @param text - The message text
114
+ */
115
+ async sendMessage(recipientAddress, text) {
116
+ const conversation = await this.client.conversations.newDmWithIdentifier({
117
+ identifier: recipientAddress,
118
+ identifierKind: 0
119
+ });
120
+ await conversation.send(text);
121
+ }
108
122
  /**
109
123
  * Wait for a response message from the agent on a conversation.
110
124
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagentmarket/nodejs",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "OpenAgent Market Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/client.ts CHANGED
@@ -161,6 +161,25 @@ export class OpenAgentClient {
161
161
  return await this.waitForResponse(conversation, timeout);
162
162
  }
163
163
 
164
+ /**
165
+ * Send a plain text message without waiting for a reply.
166
+ * Use this for peer-to-peer chat where streamAllMessages handles incoming messages.
167
+ *
168
+ * @param recipientAddress - The recipient's wallet address
169
+ * @param text - The message text
170
+ */
171
+ public async sendMessage(
172
+ recipientAddress: string,
173
+ text: string
174
+ ): Promise<void> {
175
+ const conversation = await this.client.conversations.newDmWithIdentifier({
176
+ identifier: recipientAddress,
177
+ identifierKind: 0
178
+ });
179
+
180
+ await conversation.send(text);
181
+ }
182
+
164
183
  /**
165
184
  * Wait for a response message from the agent on a conversation.
166
185
  */
@@ -1,40 +0,0 @@
1
- # OpenAgent Hirer CLI
2
-
3
- A persistent XMTP chat CLI for hiring agents on [OpenAgent Market](https://openagent.market).
4
-
5
- ## Getting Started
6
-
7
- ```bash
8
- npm install
9
- npm start
10
- ```
11
-
12
- ## Commands
13
-
14
- | Command | Description |
15
- |---------|-------------|
16
- | `/discover` | Browse available agents from the marketplace |
17
- | `/chat <address> <message>` | Send a plain text message to an agent |
18
- | `/task <address> <method> [json]` | Send a JSON-RPC task to an agent |
19
- | `/help` | Show available commands |
20
- | `/quit` | Exit the CLI |
21
-
22
- ## Examples
23
-
24
- ```
25
- > /discover
26
- > /chat 0xAgentAddr What can you do?
27
- > /task 0xAgentAddr say_hello {"name": "World"}
28
- ```
29
-
30
- ## Environment Variables
31
-
32
- | Variable | Description |
33
- |----------|-------------|
34
- | `MNEMONIC` | Wallet seed phrase (auto-generated for you) |
35
-
36
- ## Resources
37
-
38
- - [Discover API](https://openagent.market/discover?protocol=openagentmarket)
39
- - [SDK Docs](https://www.npmjs.com/package/@openagentmarket/nodejs)
40
- - [Explorer](https://8004agents.ai)
package/my-hirer/index.ts DELETED
@@ -1,142 +0,0 @@
1
- import { OpenAgentClient } from '@openagentmarket/nodejs';
2
- import * as readline from 'node:readline';
3
- import 'dotenv/config';
4
-
5
- const DISCOVER_URL = "https://openagent.market/discover?protocol=openagentmarket";
6
-
7
- async function main() {
8
- const client = await OpenAgentClient.create({
9
- mnemonic: process.env.MNEMONIC,
10
- env: "production"
11
- });
12
-
13
- console.log("");
14
- console.log("✅ Connected to XMTP");
15
- console.log(" Wallet: " + client.getAddress());
16
- console.log("");
17
- printHelp();
18
-
19
- // ── Start REPL ──
20
- const rl = readline.createInterface({
21
- input: process.stdin,
22
- output: process.stdout,
23
- prompt: "\n> "
24
- });
25
-
26
- // ── Background message listener ──
27
- await client.streamAllMessages((sender, content, convId) => {
28
- console.log("\n📨 [" + sender.slice(0, 10) + "...] " + content);
29
- rl.prompt();
30
- });
31
-
32
- rl.prompt();
33
-
34
- rl.on("line", async (line: string) => {
35
- const input = line.trim();
36
- if (!input) { rl.prompt(); return; }
37
-
38
- try {
39
- if (input === "/help") {
40
- printHelp();
41
- }
42
- else if (input === "/discover") {
43
- await discoverAgents();
44
- }
45
- else if (input.startsWith("/chat ")) {
46
- const parts = input.slice(6).trim().split(" ");
47
- const address = parts[0];
48
- const message = parts.slice(1).join(" ");
49
- if (!address || !message) {
50
- console.log("Usage: /chat <agent-address> <message>");
51
- } else {
52
- console.log("📤 Sending to " + address + "...");
53
- const reply = await client.chat(address, message);
54
- if (reply.success) {
55
- console.log("📩 Reply:", reply.result ?? reply.raw ?? "(empty)");
56
- } else {
57
- console.log("❌ Error:", reply.error ?? "Unknown error");
58
- }
59
- }
60
- }
61
- else if (input.startsWith("/task ")) {
62
- const parts = input.slice(6).trim().split(" ");
63
- const address = parts[0];
64
- const method = parts[1];
65
- const paramsStr = parts.slice(2).join(" ") || "{}";
66
- if (!address || !method) {
67
- console.log("Usage: /task <agent-address> <method> [json-params]");
68
- } else {
69
- let params: any = {};
70
- try { params = JSON.parse(paramsStr); } catch { params = { input: paramsStr }; }
71
- console.log("📤 Sending task '" + method + "' to " + address + "...");
72
- const result = await client.sendTask(address, method, params);
73
- if (result.paymentRequired) {
74
- console.log("💰 Payment required:", result.paymentRequired);
75
- } else if (result.success) {
76
- console.log("✅ Result:", JSON.stringify(result.result, null, 2));
77
- } else {
78
- console.log("❌ Error:", result.error);
79
- }
80
- }
81
- }
82
- else if (input === "/quit" || input === "/exit") {
83
- console.log("Bye! 👋");
84
- process.exit(0);
85
- }
86
- else {
87
- console.log("Unknown command. Type /help for available commands.");
88
- }
89
- } catch (err: any) {
90
- console.error("❌ Error:", err.message || err);
91
- }
92
-
93
- rl.prompt();
94
- });
95
-
96
- rl.on("close", () => {
97
- console.log("\nBye! 👋");
98
- process.exit(0);
99
- });
100
- }
101
-
102
- function printHelp() {
103
- console.log("📖 Commands:");
104
- console.log(" /discover — Browse available agents");
105
- console.log(" /chat <agent-address> <message> — Send a chat message");
106
- console.log(" /task <agent-address> <method> [params] — Send a task (params as JSON)");
107
- console.log(" /help — Show this help");
108
- console.log(" /quit — Exit");
109
- }
110
-
111
- async function discoverAgents() {
112
- console.log("🔍 Fetching agents from OpenAgent Market...\n");
113
- try {
114
- const res = await fetch(DISCOVER_URL);
115
- const data = await res.json() as any;
116
- if (!data.success || !data.items?.length) {
117
- console.log("No agents found.");
118
- return;
119
- }
120
- for (const item of data.items) {
121
- const reg = item.registrationFile || {};
122
- const name = reg.name || "Unknown";
123
- const desc = reg.description || "";
124
- // Find xmtpAddress from metadata array
125
- const meta = item.metadata || [];
126
- let addr = item.owner || "?";
127
- const walletMeta = meta.find((m: any) => m.key === "agentWallet");
128
- if (walletMeta) addr = walletMeta.value;
129
- const agentId = item.agentId || "";
130
- console.log(" 🤖 " + name + (agentId ? " (#" + agentId + ")" : ""));
131
- if (desc) console.log(" " + desc.slice(0, 120) + (desc.length > 120 ? "..." : ""));
132
- console.log(" Address: " + addr);
133
- console.log("");
134
- }
135
- console.log("Total: " + data.items.length + " agent(s)");
136
- if (data.hasMore) console.log("(more agents available)");
137
- } catch (err: any) {
138
- console.error("Failed to fetch agents:", err.message);
139
- }
140
- }
141
-
142
- main().catch(console.error);