beam-protocol-cli 0.3.0 → 0.5.1

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 (65) hide show
  1. package/dist/commands/browse.d.ts +11 -0
  2. package/dist/commands/browse.d.ts.map +1 -0
  3. package/dist/commands/browse.js +47 -0
  4. package/dist/commands/browse.js.map +1 -0
  5. package/dist/commands/delegate.d.ts +9 -0
  6. package/dist/commands/delegate.d.ts.map +1 -0
  7. package/dist/commands/delegate.js +44 -0
  8. package/dist/commands/delegate.js.map +1 -0
  9. package/dist/commands/init.d.ts +1 -1
  10. package/dist/commands/init.d.ts.map +1 -1
  11. package/dist/commands/init.js +2 -3
  12. package/dist/commands/init.js.map +1 -1
  13. package/dist/commands/lookup.d.ts.map +1 -1
  14. package/dist/commands/lookup.js +6 -8
  15. package/dist/commands/lookup.js.map +1 -1
  16. package/dist/commands/profile-update.d.ts +10 -0
  17. package/dist/commands/profile-update.d.ts.map +1 -0
  18. package/dist/commands/profile-update.js +36 -0
  19. package/dist/commands/profile-update.js.map +1 -0
  20. package/dist/commands/register.js +1 -1
  21. package/dist/commands/register.js.map +1 -1
  22. package/dist/commands/report.d.ts +8 -0
  23. package/dist/commands/report.d.ts.map +1 -0
  24. package/dist/commands/report.js +41 -0
  25. package/dist/commands/report.js.map +1 -0
  26. package/dist/commands/search.d.ts.map +1 -1
  27. package/dist/commands/search.js +2 -3
  28. package/dist/commands/search.js.map +1 -1
  29. package/dist/commands/send.d.ts.map +1 -1
  30. package/dist/commands/send.js +3 -5
  31. package/dist/commands/send.js.map +1 -1
  32. package/dist/commands/stats.d.ts +7 -0
  33. package/dist/commands/stats.d.ts.map +1 -0
  34. package/dist/commands/stats.js +35 -0
  35. package/dist/commands/stats.js.map +1 -0
  36. package/dist/commands/verify-check.d.ts +7 -0
  37. package/dist/commands/verify-check.d.ts.map +1 -0
  38. package/dist/commands/verify-check.js +34 -0
  39. package/dist/commands/verify-check.js.map +1 -0
  40. package/dist/commands/verify-domain.d.ts +7 -0
  41. package/dist/commands/verify-domain.d.ts.map +1 -0
  42. package/dist/commands/verify-domain.js +36 -0
  43. package/dist/commands/verify-domain.js.map +1 -0
  44. package/dist/config.d.ts +3 -0
  45. package/dist/config.d.ts.map +1 -1
  46. package/dist/config.js +14 -3
  47. package/dist/config.js.map +1 -1
  48. package/dist/index.js +83 -11
  49. package/dist/index.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/commands/browse.ts +61 -0
  52. package/src/commands/delegate.ts +52 -0
  53. package/src/commands/init.ts +6 -4
  54. package/src/commands/lookup.ts +6 -8
  55. package/src/commands/profile-update.ts +47 -0
  56. package/src/commands/register.ts +1 -1
  57. package/src/commands/report.ts +49 -0
  58. package/src/commands/search.ts +3 -6
  59. package/src/commands/send.ts +4 -9
  60. package/src/commands/stats.ts +40 -0
  61. package/src/commands/verify-check.ts +41 -0
  62. package/src/commands/verify-domain.ts +42 -0
  63. package/src/config.ts +16 -5
  64. package/src/index.ts +91 -12
  65. package/tsconfig.json +7 -2
@@ -0,0 +1,40 @@
1
+ import chalk from 'chalk'
2
+ import ora from 'ora'
3
+ import { BeamClient } from '@beam-protocol/sdk'
4
+ import { loadConfig } from '../config.js'
5
+
6
+ interface StatsOptions {
7
+ directory?: string
8
+ json?: boolean
9
+ }
10
+
11
+ export async function cmdStats(options: StatsOptions): Promise<void> {
12
+ const config = loadConfig()
13
+ const directoryUrl = options.directory ?? config.directoryUrl
14
+ const spinner = ora('Fetching directory statistics...').start()
15
+
16
+ try {
17
+ const client = new BeamClient({ identity: config.identity, directoryUrl })
18
+ const stats = await client.getStats()
19
+ spinner.stop()
20
+
21
+ if (options.json) {
22
+ console.log(JSON.stringify(stats, null, 2))
23
+ return
24
+ }
25
+
26
+ console.log('')
27
+ console.log(chalk.bold('šŸ“ˆ Directory statistics'))
28
+ console.log(chalk.dim('─'.repeat(40)))
29
+ console.log(`${chalk.cyan('Total agents:')} ${stats.totalAgents}`)
30
+ console.log(`${chalk.cyan('Verified:')} ${stats.verifiedAgents}`)
31
+ console.log(`${chalk.cyan('Intents:')} ${stats.intentsProcessed}`)
32
+ if (stats.consumerAgents !== undefined) console.log(`${chalk.cyan('Consumers:')} ${stats.consumerAgents}`)
33
+ if (stats.version) console.log(`${chalk.cyan('Version:')} ${stats.version}`)
34
+ console.log('')
35
+ } catch (err) {
36
+ spinner.fail('Stats failed')
37
+ console.error(chalk.red(`āœ– ${(err as Error).message}`))
38
+ process.exit(1)
39
+ }
40
+ }
@@ -0,0 +1,41 @@
1
+ import chalk from 'chalk'
2
+ import ora from 'ora'
3
+ import { BeamClient } from '@beam-protocol/sdk'
4
+ import { loadConfig } from '../config.js'
5
+
6
+ interface VerifyCheckOptions {
7
+ directory?: string
8
+ json?: boolean
9
+ }
10
+
11
+ export async function cmdVerifyCheck(options: VerifyCheckOptions): Promise<void> {
12
+ const config = loadConfig()
13
+ const directoryUrl = options.directory ?? config.directoryUrl
14
+ const spinner = ora('Checking verification status...').start()
15
+
16
+ try {
17
+ const client = new BeamClient({ identity: config.identity, directoryUrl })
18
+ const verification = await client.checkDomainVerification()
19
+ spinner.stop()
20
+
21
+ if (options.json) {
22
+ console.log(JSON.stringify(verification, null, 2))
23
+ return
24
+ }
25
+
26
+ console.log('')
27
+ console.log(chalk.bold('šŸ”Ž Verification status'))
28
+ console.log(chalk.dim('─'.repeat(40)))
29
+ console.log(`${chalk.cyan('Domain:')} ${verification.domain || chalk.dim('—')}`)
30
+ console.log(`${chalk.cyan('Verified:')} ${verification.verified ? chalk.green('Yes āœ“') : chalk.yellow('Pending')}`)
31
+ console.log(`${chalk.cyan('Status:')} ${verification.status ?? chalk.dim('—')}`)
32
+ if (verification.tier) {
33
+ console.log(`${chalk.cyan('Tier:')} ${verification.tier}`)
34
+ }
35
+ console.log('')
36
+ } catch (err) {
37
+ spinner.fail('Verification check failed')
38
+ console.error(chalk.red(`āœ– ${(err as Error).message}`))
39
+ process.exit(1)
40
+ }
41
+ }
@@ -0,0 +1,42 @@
1
+ import chalk from 'chalk'
2
+ import ora from 'ora'
3
+ import { BeamClient } from '@beam-protocol/sdk'
4
+ import { loadConfig } from '../config.js'
5
+
6
+ interface VerifyDomainOptions {
7
+ directory?: string
8
+ json?: boolean
9
+ }
10
+
11
+ export async function cmdVerifyDomain(domain: string, options: VerifyDomainOptions): Promise<void> {
12
+ const config = loadConfig()
13
+ const directoryUrl = options.directory ?? config.directoryUrl
14
+ const spinner = ora(`Starting DNS verification for ${chalk.bold(domain)}...`).start()
15
+
16
+ try {
17
+ const client = new BeamClient({ identity: config.identity, directoryUrl })
18
+ const verification = await client.verifyDomain(domain)
19
+ spinner.stop()
20
+
21
+ if (options.json) {
22
+ console.log(JSON.stringify(verification, null, 2))
23
+ return
24
+ }
25
+
26
+ console.log('')
27
+ console.log(chalk.bold('🌐 Domain verification started'))
28
+ console.log(chalk.dim('─'.repeat(40)))
29
+ console.log(`${chalk.cyan('Domain:')} ${verification.domain}`)
30
+ console.log(`${chalk.cyan('Verified:')} ${verification.verified ? chalk.green('Yes') : chalk.yellow('Pending')}`)
31
+ if (verification.txtName) console.log(`${chalk.cyan('TXT Name:')} ${verification.txtName}`)
32
+ if (verification.txtValue ?? verification.expected) {
33
+ console.log(`${chalk.cyan('TXT Value:')} ${verification.txtValue ?? verification.expected}`)
34
+ }
35
+ console.log('')
36
+ console.log(chalk.dim('After adding the TXT record, run: beam verify check'))
37
+ } catch (err) {
38
+ spinner.fail('Domain verification failed')
39
+ console.error(chalk.red(`āœ– ${(err as Error).message}`))
40
+ process.exit(1)
41
+ }
42
+ }
package/src/config.ts CHANGED
@@ -20,21 +20,32 @@ export function configExists(cwd = process.cwd()): boolean {
20
20
  return existsSync(getConfigPath(cwd))
21
21
  }
22
22
 
23
- export function loadConfig(cwd = process.cwd()): BeamConfig {
23
+ export function loadOptionalConfig(cwd = process.cwd()): BeamConfig | null {
24
24
  const path = getConfigPath(cwd)
25
25
  if (!existsSync(path)) {
26
- throw new Error(
27
- `No Beam identity found. Run 'beam init' first.`
28
- )
26
+ return null
29
27
  }
30
28
  const raw = readFileSync(path, 'utf8')
31
29
  return JSON.parse(raw) as BeamConfig
32
30
  }
33
31
 
32
+ export function loadConfig(cwd = process.cwd()): BeamConfig {
33
+ const config = loadOptionalConfig(cwd)
34
+ if (!config) {
35
+ throw new Error(`No Beam identity found. Run 'beam init' first.`)
36
+ }
37
+ return config
38
+ }
39
+
40
+ export function resolveDirectoryUrl(override?: string, cwd = process.cwd()): string {
41
+ return override ?? loadOptionalConfig(cwd)?.directoryUrl ?? DEFAULT_DIRECTORY_URL
42
+ }
43
+
34
44
  export function saveConfig(config: BeamConfig, cwd = process.cwd()): void {
35
45
  const dir = getConfigDir(cwd)
36
46
  mkdirSync(dir, { recursive: true })
37
47
  writeFileSync(getConfigPath(cwd), JSON.stringify(config, null, 2), 'utf8')
38
48
  }
39
49
 
40
- export const DEFAULT_DIRECTORY_URL = process.env['BEAM_DIRECTORY_URL'] ?? 'http://localhost:3100'
50
+ export const DEFAULT_DIRECTORY_URL = process.env['BEAM_DIRECTORY_URL'] ?? 'https://api.beam.directory'
51
+ export const BEAM_ID_PATTERN = /^(?:[a-z0-9_-]+@beam\.directory|[a-z0-9_-]+@[a-z0-9_-]+\.beam\.directory)$/
package/src/index.ts CHANGED
@@ -6,6 +6,13 @@ import { cmdRegister } from './commands/register.js'
6
6
  import { cmdLookup } from './commands/lookup.js'
7
7
  import { cmdSearch } from './commands/search.js'
8
8
  import { cmdSend } from './commands/send.js'
9
+ import { cmdBrowse } from './commands/browse.js'
10
+ import { cmdProfileUpdate } from './commands/profile-update.js'
11
+ import { cmdVerifyDomain } from './commands/verify-domain.js'
12
+ import { cmdVerifyCheck } from './commands/verify-check.js'
13
+ import { cmdStats } from './commands/stats.js'
14
+ import { cmdDelegate } from './commands/delegate.js'
15
+ import { cmdReport } from './commands/report.js'
9
16
 
10
17
  const program = new Command()
11
18
 
@@ -15,21 +22,19 @@ program
15
22
  chalk.bold('Beam Protocol CLI') + '\n' +
16
23
  chalk.dim('SMTP for AI Agents — agent identity, registration & intent routing')
17
24
  )
18
- .version('0.1.0')
25
+ .version('0.5.0')
19
26
 
20
- // ─── beam init ────────────────────────────────────────────────────────────────
21
27
  program
22
28
  .command('init')
23
29
  .description('Generate a new Beam identity (writes .beam/identity.json)')
24
30
  .requiredOption('-a, --agent <name>', 'Agent name (e.g. jarvis)')
25
- .requiredOption('-o, --org <name>', 'Organisation name (e.g. coppen)')
26
- .option('-d, --directory <url>', 'Directory server URL', process.env['BEAM_DIRECTORY_URL'] ?? 'http://localhost:3100')
31
+ .option('-o, --org <name>', 'Organisation name (optional for consumer Beam-IDs)')
32
+ .option('-d, --directory <url>', 'Directory server URL', process.env['BEAM_DIRECTORY_URL'] ?? 'https://api.beam.directory')
27
33
  .option('-f, --force', 'Overwrite existing identity')
28
- .action(async (opts: { agent: string; org: string; directory?: string; force?: boolean }) => {
34
+ .action(async (opts: { agent: string; org?: string; directory?: string; force?: boolean }) => {
29
35
  await cmdInit(opts)
30
36
  })
31
37
 
32
- // ─── beam register ────────────────────────────────────────────────────────────
33
38
  program
34
39
  .command('register')
35
40
  .description('Register this agent with a Beam directory')
@@ -40,7 +45,6 @@ program
40
45
  await cmdRegister(opts)
41
46
  })
42
47
 
43
- // ─── beam lookup ──────────────────────────────────────────────────────────────
44
48
  program
45
49
  .command('lookup <beamId>')
46
50
  .description('Look up an agent by Beam ID')
@@ -50,7 +54,6 @@ program
50
54
  await cmdLookup(beamId, opts)
51
55
  })
52
56
 
53
- // ─── beam search ──────────────────────────────────────────────────────────────
54
57
  program
55
58
  .command('search')
56
59
  .description('Search for agents in the directory')
@@ -64,7 +67,81 @@ program
64
67
  await cmdSearch(opts)
65
68
  })
66
69
 
67
- // ─── beam send ────────────────────────────────────────────────────────────────
70
+ program
71
+ .command('browse')
72
+ .description('Browse paginated agent listings')
73
+ .option('--page <n>', 'Page number', '1')
74
+ .option('--capability <cap>', 'Filter by capability')
75
+ .option('--tier <tier>', 'Filter by verification tier')
76
+ .option('--verified-only', 'Only show verified agents')
77
+ .option('-d, --directory <url>', 'Override directory URL')
78
+ .option('--json', 'Output raw JSON')
79
+ .action(async (opts: { page?: string; capability?: string; tier?: string; verifiedOnly?: boolean; directory?: string; json?: boolean }) => {
80
+ await cmdBrowse(opts)
81
+ })
82
+
83
+ const profile = program.command('profile').description('Profile management commands')
84
+ profile
85
+ .command('update')
86
+ .description('Update your agent profile')
87
+ .option('--description <text>', 'Profile description')
88
+ .option('--logo-url <url>', 'Public logo URL')
89
+ .option('--website <url>', 'Public website URL')
90
+ .option('-d, --directory <url>', 'Override directory URL')
91
+ .option('--json', 'Output raw JSON')
92
+ .action(async (opts: { description?: string; logoUrl?: string; website?: string; directory?: string; json?: boolean }) => {
93
+ await cmdProfileUpdate(opts)
94
+ })
95
+
96
+ const verify = program.command('verify').description('Verification commands')
97
+ verify
98
+ .command('domain <domain>')
99
+ .description('Initiate DNS verification for a domain')
100
+ .option('-d, --directory <url>', 'Override directory URL')
101
+ .option('--json', 'Output raw JSON')
102
+ .action(async (domain: string, opts: { directory?: string; json?: boolean }) => {
103
+ await cmdVerifyDomain(domain, opts)
104
+ })
105
+
106
+ verify
107
+ .command('check')
108
+ .description('Check current verification status')
109
+ .option('-d, --directory <url>', 'Override directory URL')
110
+ .option('--json', 'Output raw JSON')
111
+ .action(async (opts: { directory?: string; json?: boolean }) => {
112
+ await cmdVerifyCheck(opts)
113
+ })
114
+
115
+ program
116
+ .command('stats')
117
+ .description('Show directory statistics')
118
+ .option('-d, --directory <url>', 'Override directory URL')
119
+ .option('--json', 'Output raw JSON')
120
+ .action(async (opts: { directory?: string; json?: boolean }) => {
121
+ await cmdStats(opts)
122
+ })
123
+
124
+ program
125
+ .command('delegate <targetBeamId>')
126
+ .description('Create a delegation for another Beam agent')
127
+ .requiredOption('--scope <scope>', 'Delegation scope')
128
+ .option('--expires <hours>', 'Hours until delegation expiry')
129
+ .option('-d, --directory <url>', 'Override directory URL')
130
+ .option('--json', 'Output raw JSON')
131
+ .action(async (targetBeamId: string, opts: { scope?: string; expires?: string; directory?: string; json?: boolean }) => {
132
+ await cmdDelegate(targetBeamId, opts)
133
+ })
134
+
135
+ program
136
+ .command('report <targetBeamId>')
137
+ .description('Report an agent')
138
+ .requiredOption('--reason <reason>', 'Reason for the report')
139
+ .option('-d, --directory <url>', 'Override directory URL')
140
+ .option('--json', 'Output raw JSON')
141
+ .action(async (targetBeamId: string, opts: { reason?: string; directory?: string; json?: boolean }) => {
142
+ await cmdReport(targetBeamId, opts)
143
+ })
144
+
68
145
  program
69
146
  .command('send <to> <intent> [params]')
70
147
  .description('Send an intent to an agent and print the result')
@@ -75,9 +152,11 @@ program
75
152
  await cmdSend(to, intent, params, opts)
76
153
  })
77
154
 
78
- // ─── Error handling ───────────────────────────────────────────────────────────
79
155
  program.configureOutput({
80
- writeErr: str => process.stderr.write(chalk.red(str))
156
+ outputError: (str, write) => write(chalk.red(str))
81
157
  })
82
158
 
83
- program.parse()
159
+ program.parseAsync(process.argv).catch((err: Error) => {
160
+ console.error(chalk.red(`\nāœ– ${err.message}`))
161
+ process.exit(1)
162
+ })
package/tsconfig.json CHANGED
@@ -13,6 +13,11 @@
13
13
  "skipLibCheck": true,
14
14
  "resolveJsonModule": true
15
15
  },
16
- "include": ["src/**/*"],
17
- "exclude": ["node_modules", "dist"]
16
+ "include": [
17
+ "src/**/*"
18
+ ],
19
+ "exclude": [
20
+ "node_modules",
21
+ "dist"
22
+ ]
18
23
  }