agentdex-cli 0.3.1 → 0.3.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.
package/dist/cli.js CHANGED
@@ -5,14 +5,19 @@ import ora from 'ora';
5
5
  import inquirer from 'inquirer';
6
6
  import qrcode from 'qrcode-terminal';
7
7
  import { readFileSync } from 'fs';
8
+ import { fileURLToPath } from 'url';
9
+ import { dirname, join } from 'path';
8
10
  import { AgentdexClient } from './client.js';
9
11
  import { parseSecretKey, getNpub, getPubkeyHex, createProfileEvent, createKind0Event, publishToRelays, createNote, generateAndSaveKeypair } from './nostr.js';
10
12
  import { payInvoice } from './nwc.js';
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
11
16
  const program = new Command();
12
17
  program
13
18
  .name('agentdex')
14
19
  .description('CLI for the agentdex AI agent directory')
15
- .version('0.2.0');
20
+ .version(pkg.version);
16
21
  /**
17
22
  * Resolve secret key from flags, env, or key file
18
23
  */
@@ -227,6 +232,7 @@ program
227
232
  }
228
233
  console.log(chalk.gray(' Next: Claim a NIP-05 name to get verified (first 100 free, then 5000 sats).'));
229
234
  }
235
+ process.exit(0);
230
236
  }
231
237
  catch (err) {
232
238
  const apiErr = err;
package/dist/nostr.d.ts CHANGED
@@ -53,7 +53,7 @@ export declare function createProfileEvent(sk: Uint8Array, profile: AgentProfile
53
53
  /**
54
54
  * Publish an event to Nostr relays
55
55
  */
56
- export declare function publishToRelays(event: object, relays?: string[]): Promise<string[]>;
56
+ export declare function publishToRelays(event: object, relays?: string[], timeoutMs?: number): Promise<string[]>;
57
57
  /**
58
58
  * Fetch existing kind 0, merge new fields, and republish.
59
59
  * Used to set lud16 (lightning address) during registration.
package/dist/nostr.js CHANGED
@@ -125,12 +125,15 @@ export function createProfileEvent(sk, profile) {
125
125
  /**
126
126
  * Publish an event to Nostr relays
127
127
  */
128
- export async function publishToRelays(event, relays = DEFAULT_RELAYS) {
128
+ export async function publishToRelays(event, relays = DEFAULT_RELAYS, timeoutMs = 10000) {
129
129
  const pool = new SimplePool();
130
130
  const published = [];
131
131
  try {
132
132
  const results = await Promise.allSettled(relays.map(async (relay) => {
133
- await pool.publish([relay], event);
133
+ await Promise.race([
134
+ pool.publish([relay], event),
135
+ new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeoutMs)),
136
+ ]);
134
137
  return relay;
135
138
  }));
136
139
  for (const result of results) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentdex-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "CLI and SDK for the agentdex AI agent directory",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -6,16 +6,22 @@ import ora from 'ora';
6
6
  import inquirer from 'inquirer';
7
7
  import qrcode from 'qrcode-terminal';
8
8
  import { readFileSync } from 'fs';
9
+ import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
9
11
  import { AgentdexClient } from './client.js';
10
12
  import { parseSecretKey, getNpub, getPubkeyHex, createProfileEvent, createKind0Event, publishToRelays, createNote, updateKind0, generateAndSaveKeypair } from './nostr.js';
11
13
  import { payInvoice } from './nwc.js';
12
14
 
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = dirname(__filename);
17
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
18
+
13
19
  const program = new Command();
14
20
 
15
21
  program
16
22
  .name('agentdex')
17
23
  .description('CLI for the agentdex AI agent directory')
18
- .version('0.2.0');
24
+ .version(pkg.version);
19
25
 
20
26
  /**
21
27
  * Resolve secret key from flags, env, or key file
@@ -248,6 +254,7 @@ program
248
254
 
249
255
  console.log(chalk.gray(' Next: Claim a NIP-05 name to get verified (first 100 free, then 5000 sats).'));
250
256
  }
257
+ process.exit(0);
251
258
  } catch (err) {
252
259
  const apiErr = err as any;
253
260
  if (apiErr.status === 503) {
package/src/nostr.ts CHANGED
@@ -149,14 +149,17 @@ export function createProfileEvent(sk: Uint8Array, profile: AgentProfile) {
149
149
  /**
150
150
  * Publish an event to Nostr relays
151
151
  */
152
- export async function publishToRelays(event: object, relays: string[] = DEFAULT_RELAYS): Promise<string[]> {
152
+ export async function publishToRelays(event: object, relays: string[] = DEFAULT_RELAYS, timeoutMs = 10000): Promise<string[]> {
153
153
  const pool = new SimplePool();
154
154
  const published: string[] = [];
155
155
 
156
156
  try {
157
157
  const results = await Promise.allSettled(
158
158
  relays.map(async (relay) => {
159
- await pool.publish([relay], event as any);
159
+ await Promise.race([
160
+ pool.publish([relay], event as any),
161
+ new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeoutMs)),
162
+ ]);
160
163
  return relay;
161
164
  })
162
165
  );