@openagentmarket/nodejs 1.2.0 → 1.3.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.
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "my-hirer",
3
+ "version": "1.0.0",
4
+ "description": "Hire agents on OpenAgent Market",
5
+ "type": "module",
6
+ "scripts": {
7
+ "start": "tsx index.ts",
8
+ "dev": "tsx watch index.ts"
9
+ },
10
+ "dependencies": {
11
+ "@openagentmarket/nodejs": "^1.0.0",
12
+ "ethers": "^6.10.0",
13
+ "dotenv": "^16.4.0"
14
+ },
15
+ "devDependencies": {
16
+ "tsx": "^4.7.0",
17
+ "typescript": "^5.3.3",
18
+ "@types/node": "^20.11.0"
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagentmarket/nodejs",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "OpenAgent Market Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client } from '@xmtp/node-sdk';
1
+ import { Client, ConsentState } from '@xmtp/node-sdk';
2
2
  import { type Signer, Wallet, HDNodeWallet, getBytes } from 'ethers';
3
3
 
4
4
  export interface OpenAgentClientConfig {
@@ -243,4 +243,40 @@ export class OpenAgentClient {
243
243
  }
244
244
  });
245
245
  }
246
+
247
+ /**
248
+ * Stream all incoming messages across all conversations.
249
+ * Calls the callback for each incoming message (skips own messages).
250
+ * Runs in the background — returns immediately.
251
+ *
252
+ * @param onMessage - Callback receiving (senderAddress, content, conversationId)
253
+ */
254
+ public async streamAllMessages(
255
+ onMessage: (senderAddress: string, content: string, conversationId: string) => void
256
+ ): Promise<void> {
257
+ // Sync all conversations and messages first
258
+ await this.client.conversations.syncAll();
259
+
260
+ const stream = await this.client.conversations.streamAllMessages({
261
+ consentStates: [ConsentState.Allowed, ConsentState.Unknown, ConsentState.Denied]
262
+ });
263
+
264
+ // Run in background (don't await)
265
+ (async () => {
266
+ try {
267
+ for await (const message of stream) {
268
+ // Skip our own messages
269
+ if ((message as any).senderInboxId === this.client.inboxId) continue;
270
+
271
+ const content = (message as any).content;
272
+ const conversationId = (message as any).conversationId || '';
273
+ const senderAddress = (message as any).senderInboxId || 'unknown';
274
+
275
+ onMessage(senderAddress, String(content), conversationId);
276
+ }
277
+ } catch (err: any) {
278
+ console.error('[OpenAgentClient] Stream error:', err.message);
279
+ }
280
+ })();
281
+ }
246
282
  }