beam-protocol-cli 0.5.1 → 0.6.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.
- package/README.md +154 -0
- package/dist/commands/browse.js +1 -1
- package/dist/commands/browse.js.map +1 -1
- package/dist/commands/delegate.js +1 -1
- package/dist/commands/delegate.js.map +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys-list.d.ts +7 -0
- package/dist/commands/keys-list.d.ts.map +1 -0
- package/dist/commands/keys-list.js +33 -0
- package/dist/commands/keys-list.js.map +1 -0
- package/dist/commands/keys-revoke.d.ts +7 -0
- package/dist/commands/keys-revoke.d.ts.map +1 -0
- package/dist/commands/keys-revoke.js +36 -0
- package/dist/commands/keys-revoke.js.map +1 -0
- package/dist/commands/keys-rotate.d.ts +7 -0
- package/dist/commands/keys-rotate.d.ts.map +1 -0
- package/dist/commands/keys-rotate.js +48 -0
- package/dist/commands/keys-rotate.js.map +1 -0
- package/dist/commands/lookup.js +1 -1
- package/dist/commands/lookup.js.map +1 -1
- package/dist/commands/profile-update.js +1 -1
- package/dist/commands/profile-update.js.map +1 -1
- package/dist/commands/register.js +1 -1
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/report.js +1 -1
- package/dist/commands/report.js.map +1 -1
- package/dist/commands/search.js +1 -1
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/send.js +1 -1
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/stats.js +1 -1
- package/dist/commands/stats.js.map +1 -1
- package/dist/commands/talk.d.ts +10 -0
- package/dist/commands/talk.d.ts.map +1 -0
- package/dist/commands/talk.js +80 -0
- package/dist/commands/talk.js.map +1 -0
- package/dist/commands/verify-check.js +1 -1
- package/dist/commands/verify-check.js.map +1 -1
- package/dist/commands/verify-domain.js +1 -1
- package/dist/commands/verify-domain.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +57 -4
- package/dist/index.js.map +1 -1
- package/package.json +15 -3
- package/src/commands/browse.ts +0 -61
- package/src/commands/delegate.ts +0 -52
- package/src/commands/init.ts +0 -61
- package/src/commands/lookup.ts +0 -68
- package/src/commands/profile-update.ts +0 -47
- package/src/commands/register.ts +0 -58
- package/src/commands/report.ts +0 -49
- package/src/commands/search.ts +0 -87
- package/src/commands/send.ts +0 -92
- package/src/commands/stats.ts +0 -40
- package/src/commands/verify-check.ts +0 -41
- package/src/commands/verify-domain.ts +0 -42
- package/src/config.ts +0 -51
- package/src/index.ts +0 -162
- package/tsconfig.json +0 -23
package/src/commands/register.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamClient, BeamIdentity } from '@beam-protocol/sdk'
|
|
4
|
-
import { loadConfig } from '../config.js'
|
|
5
|
-
|
|
6
|
-
interface RegisterOptions {
|
|
7
|
-
displayName?: string
|
|
8
|
-
capabilities?: string
|
|
9
|
-
directory?: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function cmdRegister(options: RegisterOptions): Promise<void> {
|
|
13
|
-
const config = loadConfig()
|
|
14
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
15
|
-
|
|
16
|
-
const parsed = BeamIdentity.parseBeamId(config.identity.beamId)
|
|
17
|
-
if (!parsed) {
|
|
18
|
-
console.error(chalk.red('✖ Invalid Beam ID in config'))
|
|
19
|
-
process.exit(1)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const displayName = options.displayName ?? parsed.agent
|
|
23
|
-
const capabilities = options.capabilities
|
|
24
|
-
? options.capabilities.split(',').map(c => c.trim()).filter(Boolean)
|
|
25
|
-
: []
|
|
26
|
-
|
|
27
|
-
const spinner = ora(`Registering ${chalk.bold(config.identity.beamId)}...`).start()
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const client = new BeamClient({
|
|
31
|
-
identity: config.identity,
|
|
32
|
-
directoryUrl
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const record = await client.register(displayName, capabilities)
|
|
36
|
-
|
|
37
|
-
spinner.succeed('Agent registered successfully')
|
|
38
|
-
|
|
39
|
-
console.log('')
|
|
40
|
-
console.log(chalk.bold('✅ Registration Complete'))
|
|
41
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
42
|
-
console.log(`${chalk.cyan('Beam ID:')} ${chalk.bold(record.beamId)}`)
|
|
43
|
-
console.log(`${chalk.cyan('Display:')} ${record.displayName}`)
|
|
44
|
-
console.log(`${chalk.cyan('Org:')} ${record.org ?? chalk.dim('consumer')}`)
|
|
45
|
-
console.log(`${chalk.cyan('Trust Score:')} ${(record.trustScore * 100).toFixed(0)}%`)
|
|
46
|
-
console.log(`${chalk.cyan('Verified:')} ${record.verified ? chalk.green('Yes ✓') : chalk.yellow('No')}`)
|
|
47
|
-
if (record.capabilities.length > 0) {
|
|
48
|
-
console.log(`${chalk.cyan('Capabilities:')} ${record.capabilities.join(', ')}`)
|
|
49
|
-
}
|
|
50
|
-
console.log(`${chalk.cyan('Registered:')} ${new Date(record.createdAt).toLocaleString()}`)
|
|
51
|
-
console.log('')
|
|
52
|
-
console.log(chalk.green('Next step:'), `beam lookup ${record.beamId}`)
|
|
53
|
-
} catch (err) {
|
|
54
|
-
spinner.fail('Registration failed')
|
|
55
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
56
|
-
process.exit(1)
|
|
57
|
-
}
|
|
58
|
-
}
|
package/src/commands/report.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamClient } from '@beam-protocol/sdk'
|
|
4
|
-
import { BEAM_ID_PATTERN, loadConfig } from '../config.js'
|
|
5
|
-
|
|
6
|
-
interface ReportOptions {
|
|
7
|
-
reason?: string
|
|
8
|
-
directory?: string
|
|
9
|
-
json?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function cmdReport(targetBeamId: string, options: ReportOptions): Promise<void> {
|
|
13
|
-
if (!BEAM_ID_PATTERN.test(targetBeamId)) {
|
|
14
|
-
console.error(chalk.red(`✖ Invalid Beam ID: ${targetBeamId}`))
|
|
15
|
-
process.exit(1)
|
|
16
|
-
}
|
|
17
|
-
if (!options.reason) {
|
|
18
|
-
console.error(chalk.red('✖ Missing required --reason value'))
|
|
19
|
-
process.exit(1)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const config = loadConfig()
|
|
23
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
24
|
-
const spinner = ora(`Submitting report for ${chalk.bold(targetBeamId)}...`).start()
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
const client = new BeamClient({ identity: config.identity, directoryUrl })
|
|
28
|
-
const report = await client.report(targetBeamId, options.reason)
|
|
29
|
-
spinner.stop()
|
|
30
|
-
|
|
31
|
-
if (options.json) {
|
|
32
|
-
console.log(JSON.stringify(report, null, 2))
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
console.log('')
|
|
37
|
-
console.log(chalk.bold.yellow('⚠ Agent reported'))
|
|
38
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
39
|
-
console.log(`${chalk.cyan('Reporter:')} ${report.reporterBeamId}`)
|
|
40
|
-
console.log(`${chalk.cyan('Target:')} ${report.targetBeamId}`)
|
|
41
|
-
console.log(`${chalk.cyan('Reason:')} ${report.reason}`)
|
|
42
|
-
if (report.status) console.log(`${chalk.cyan('Status:')} ${report.status}`)
|
|
43
|
-
console.log('')
|
|
44
|
-
} catch (err) {
|
|
45
|
-
spinner.fail('Report failed')
|
|
46
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
47
|
-
process.exit(1)
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/commands/search.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamDirectory } from '@beam-protocol/sdk'
|
|
4
|
-
import { resolveDirectoryUrl } from '../config.js'
|
|
5
|
-
|
|
6
|
-
interface SearchOptions {
|
|
7
|
-
org?: string
|
|
8
|
-
capability?: string
|
|
9
|
-
minTrust?: string
|
|
10
|
-
limit?: string
|
|
11
|
-
directory?: string
|
|
12
|
-
json?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function cmdSearch(options: SearchOptions): Promise<void> {
|
|
16
|
-
const directoryUrl = resolveDirectoryUrl(options.directory)
|
|
17
|
-
|
|
18
|
-
const query = {
|
|
19
|
-
org: options.org,
|
|
20
|
-
capabilities: options.capability ? [options.capability] : undefined,
|
|
21
|
-
minTrustScore: options.minTrust ? parseFloat(options.minTrust) : undefined,
|
|
22
|
-
limit: options.limit ? parseInt(options.limit, 10) : 20
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const parts = []
|
|
26
|
-
if (query.org) parts.push(`org=${query.org}`)
|
|
27
|
-
if (query.capabilities) parts.push(`capability=${query.capabilities[0]}`)
|
|
28
|
-
const label = parts.length ? parts.join(', ') : 'all agents'
|
|
29
|
-
|
|
30
|
-
const spinner = ora(`Searching ${label}...`).start()
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const directory = new BeamDirectory({ baseUrl: directoryUrl })
|
|
34
|
-
const agents = await directory.search(query)
|
|
35
|
-
|
|
36
|
-
spinner.stop()
|
|
37
|
-
|
|
38
|
-
if (options.json) {
|
|
39
|
-
console.log(JSON.stringify(agents, null, 2))
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (agents.length === 0) {
|
|
44
|
-
console.log(chalk.yellow(`\n No agents found matching your query.\n`))
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
console.log('')
|
|
49
|
-
console.log(chalk.bold(`🔍 Found ${agents.length} agent${agents.length !== 1 ? 's' : ''}`))
|
|
50
|
-
console.log(chalk.dim('─'.repeat(60)))
|
|
51
|
-
|
|
52
|
-
for (const agent of agents) {
|
|
53
|
-
const trustPct = (agent.trustScore * 100).toFixed(0)
|
|
54
|
-
const verified = agent.verified ? chalk.green('✓') : chalk.dim('○')
|
|
55
|
-
const caps = agent.capabilities.length > 0
|
|
56
|
-
? chalk.dim(` [${agent.capabilities.join(', ')}]`)
|
|
57
|
-
: ''
|
|
58
|
-
|
|
59
|
-
console.log(` ${verified} ${chalk.bold(agent.beamId)}${caps}`)
|
|
60
|
-
console.log(
|
|
61
|
-
` ${chalk.dim(agent.displayName)} · Trust: ${getTrustColored(agent.trustScore, trustPct + '%')} · Last seen: ${formatRelative(agent.lastSeen)}`
|
|
62
|
-
)
|
|
63
|
-
console.log('')
|
|
64
|
-
}
|
|
65
|
-
} catch (err) {
|
|
66
|
-
spinner.fail('Search failed')
|
|
67
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
68
|
-
process.exit(1)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getTrustColored(score: number, label: string): string {
|
|
73
|
-
if (score >= 0.8) return chalk.green(label)
|
|
74
|
-
if (score >= 0.5) return chalk.yellow(label)
|
|
75
|
-
return chalk.red(label)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function formatRelative(iso: string): string {
|
|
79
|
-
const ms = Date.now() - new Date(iso).getTime()
|
|
80
|
-
const minutes = Math.floor(ms / 60000)
|
|
81
|
-
if (minutes < 1) return chalk.dim('just now')
|
|
82
|
-
if (minutes < 60) return chalk.dim(`${minutes}m ago`)
|
|
83
|
-
const hours = Math.floor(minutes / 60)
|
|
84
|
-
if (hours < 24) return chalk.dim(`${hours}h ago`)
|
|
85
|
-
const days = Math.floor(hours / 24)
|
|
86
|
-
return chalk.dim(`${days}d ago`)
|
|
87
|
-
}
|
package/src/commands/send.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamClient } from '@beam-protocol/sdk'
|
|
4
|
-
import type { BeamIdString } from '@beam-protocol/sdk'
|
|
5
|
-
import { BEAM_ID_PATTERN, loadConfig } from '../config.js'
|
|
6
|
-
|
|
7
|
-
interface SendOptions {
|
|
8
|
-
directory?: string
|
|
9
|
-
timeout?: string
|
|
10
|
-
json?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function cmdSend(
|
|
14
|
-
to: string,
|
|
15
|
-
intent: string,
|
|
16
|
-
paramsJson: string | undefined,
|
|
17
|
-
options: SendOptions
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const config = loadConfig()
|
|
20
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
21
|
-
const timeoutMs = options.timeout ? parseInt(options.timeout, 10) * 1000 : 10000
|
|
22
|
-
|
|
23
|
-
if (!BEAM_ID_PATTERN.test(to)) {
|
|
24
|
-
console.error(chalk.red(`✖ Invalid Beam ID: ${to}`))
|
|
25
|
-
console.error(chalk.dim(' Expected: agent@beam.directory or agent@org.beam.directory'))
|
|
26
|
-
process.exit(1)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let params: Record<string, unknown> = {}
|
|
30
|
-
if (paramsJson) {
|
|
31
|
-
try {
|
|
32
|
-
const parsed: unknown = JSON.parse(paramsJson)
|
|
33
|
-
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
34
|
-
params = parsed as Record<string, unknown>
|
|
35
|
-
} else {
|
|
36
|
-
throw new Error('Params must be a JSON object')
|
|
37
|
-
}
|
|
38
|
-
} catch (err) {
|
|
39
|
-
console.error(chalk.red(`✖ Invalid params JSON: ${(err as Error).message}`))
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const spinner = ora(`Sending ${chalk.bold(intent)} to ${chalk.bold(to)}...`).start()
|
|
45
|
-
const startTime = Date.now()
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
const client = new BeamClient({
|
|
49
|
-
identity: config.identity,
|
|
50
|
-
directoryUrl
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
const result = await client.send(to as BeamIdString, intent, params, timeoutMs)
|
|
54
|
-
const elapsed = Date.now() - startTime
|
|
55
|
-
|
|
56
|
-
spinner.stop()
|
|
57
|
-
|
|
58
|
-
if (options.json) {
|
|
59
|
-
console.log(JSON.stringify(result, null, 2))
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (result.success) {
|
|
64
|
-
console.log('')
|
|
65
|
-
console.log(chalk.bold.green('✅ Intent delivered successfully'))
|
|
66
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
67
|
-
console.log(`${chalk.cyan('From:')} ${config.identity.beamId}`)
|
|
68
|
-
console.log(`${chalk.cyan('To:')} ${to}`)
|
|
69
|
-
console.log(`${chalk.cyan('Intent:')} ${intent}`)
|
|
70
|
-
console.log(`${chalk.cyan('Latency:')} ${elapsed}ms`)
|
|
71
|
-
if (result.payload && Object.keys(result.payload).length > 0) {
|
|
72
|
-
console.log('')
|
|
73
|
-
console.log(chalk.bold('📦 Result Payload:'))
|
|
74
|
-
console.log(JSON.stringify(result.payload, null, 2))
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
console.log('')
|
|
78
|
-
console.log(chalk.bold.red('✖ Intent failed'))
|
|
79
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
80
|
-
console.log(`${chalk.cyan('Error:')} ${result.error ?? 'Unknown error'}`)
|
|
81
|
-
if (result.errorCode) {
|
|
82
|
-
console.log(`${chalk.cyan('Code:')} ${result.errorCode}`)
|
|
83
|
-
}
|
|
84
|
-
console.log(`${chalk.cyan('Latency:')} ${elapsed}ms`)
|
|
85
|
-
}
|
|
86
|
-
console.log('')
|
|
87
|
-
} catch (err) {
|
|
88
|
-
spinner.fail('Send failed')
|
|
89
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
90
|
-
process.exit(1)
|
|
91
|
-
}
|
|
92
|
-
}
|
package/src/commands/stats.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'
|
|
2
|
-
import { join } from 'node:path'
|
|
3
|
-
import type { BeamIdentityData } from '@beam-protocol/sdk'
|
|
4
|
-
|
|
5
|
-
export interface BeamConfig {
|
|
6
|
-
identity: BeamIdentityData
|
|
7
|
-
directoryUrl: string
|
|
8
|
-
createdAt: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getConfigDir(cwd = process.cwd()): string {
|
|
12
|
-
return join(cwd, '.beam')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getConfigPath(cwd = process.cwd()): string {
|
|
16
|
-
return join(getConfigDir(cwd), 'identity.json')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function configExists(cwd = process.cwd()): boolean {
|
|
20
|
-
return existsSync(getConfigPath(cwd))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function loadOptionalConfig(cwd = process.cwd()): BeamConfig | null {
|
|
24
|
-
const path = getConfigPath(cwd)
|
|
25
|
-
if (!existsSync(path)) {
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
const raw = readFileSync(path, 'utf8')
|
|
29
|
-
return JSON.parse(raw) as BeamConfig
|
|
30
|
-
}
|
|
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
|
-
|
|
44
|
-
export function saveConfig(config: BeamConfig, cwd = process.cwd()): void {
|
|
45
|
-
const dir = getConfigDir(cwd)
|
|
46
|
-
mkdirSync(dir, { recursive: true })
|
|
47
|
-
writeFileSync(getConfigPath(cwd), JSON.stringify(config, null, 2), 'utf8')
|
|
48
|
-
}
|
|
49
|
-
|
|
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
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from 'commander'
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
import { cmdInit } from './commands/init.js'
|
|
5
|
-
import { cmdRegister } from './commands/register.js'
|
|
6
|
-
import { cmdLookup } from './commands/lookup.js'
|
|
7
|
-
import { cmdSearch } from './commands/search.js'
|
|
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'
|
|
16
|
-
|
|
17
|
-
const program = new Command()
|
|
18
|
-
|
|
19
|
-
program
|
|
20
|
-
.name('beam')
|
|
21
|
-
.description(
|
|
22
|
-
chalk.bold('Beam Protocol CLI') + '\n' +
|
|
23
|
-
chalk.dim('SMTP for AI Agents — agent identity, registration & intent routing')
|
|
24
|
-
)
|
|
25
|
-
.version('0.5.0')
|
|
26
|
-
|
|
27
|
-
program
|
|
28
|
-
.command('init')
|
|
29
|
-
.description('Generate a new Beam identity (writes .beam/identity.json)')
|
|
30
|
-
.requiredOption('-a, --agent <name>', 'Agent name (e.g. jarvis)')
|
|
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')
|
|
33
|
-
.option('-f, --force', 'Overwrite existing identity')
|
|
34
|
-
.action(async (opts: { agent: string; org?: string; directory?: string; force?: boolean }) => {
|
|
35
|
-
await cmdInit(opts)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
program
|
|
39
|
-
.command('register')
|
|
40
|
-
.description('Register this agent with a Beam directory')
|
|
41
|
-
.option('-n, --display-name <name>', 'Human-readable display name')
|
|
42
|
-
.option('-c, --capabilities <list>', 'Comma-separated capabilities (e.g. query,answer,write)')
|
|
43
|
-
.option('-d, --directory <url>', 'Override directory URL')
|
|
44
|
-
.action(async (opts: { displayName?: string; capabilities?: string; directory?: string }) => {
|
|
45
|
-
await cmdRegister(opts)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
program
|
|
49
|
-
.command('lookup <beamId>')
|
|
50
|
-
.description('Look up an agent by Beam ID')
|
|
51
|
-
.option('-d, --directory <url>', 'Override directory URL')
|
|
52
|
-
.option('--json', 'Output raw JSON')
|
|
53
|
-
.action(async (beamId: string, opts: { directory?: string; json?: boolean }) => {
|
|
54
|
-
await cmdLookup(beamId, opts)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
program
|
|
58
|
-
.command('search')
|
|
59
|
-
.description('Search for agents in the directory')
|
|
60
|
-
.option('--org <org>', 'Filter by organisation')
|
|
61
|
-
.option('--capability <cap>', 'Filter by capability')
|
|
62
|
-
.option('--min-trust <score>', 'Minimum trust score (0.0-1.0)')
|
|
63
|
-
.option('--limit <n>', 'Max results', '20')
|
|
64
|
-
.option('-d, --directory <url>', 'Override directory URL')
|
|
65
|
-
.option('--json', 'Output raw JSON')
|
|
66
|
-
.action(async (opts: { org?: string; capability?: string; minTrust?: string; limit?: string; directory?: string; json?: boolean }) => {
|
|
67
|
-
await cmdSearch(opts)
|
|
68
|
-
})
|
|
69
|
-
|
|
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
|
-
|
|
145
|
-
program
|
|
146
|
-
.command('send <to> <intent> [params]')
|
|
147
|
-
.description('Send an intent to an agent and print the result')
|
|
148
|
-
.option('-d, --directory <url>', 'Override directory URL')
|
|
149
|
-
.option('-t, --timeout <seconds>', 'Timeout in seconds', '10')
|
|
150
|
-
.option('--json', 'Output raw JSON')
|
|
151
|
-
.action(async (to: string, intent: string, params: string | undefined, opts: { directory?: string; timeout?: string; json?: boolean }) => {
|
|
152
|
-
await cmdSend(to, intent, params, opts)
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
program.configureOutput({
|
|
156
|
-
outputError: (str, write) => write(chalk.red(str))
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
program.parseAsync(process.argv).catch((err: Error) => {
|
|
160
|
-
console.error(chalk.red(`\n✖ ${err.message}`))
|
|
161
|
-
process.exit(1)
|
|
162
|
-
})
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationMap": true,
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"resolveJsonModule": true
|
|
15
|
-
},
|
|
16
|
-
"include": [
|
|
17
|
-
"src/**/*"
|
|
18
|
-
],
|
|
19
|
-
"exclude": [
|
|
20
|
-
"node_modules",
|
|
21
|
-
"dist"
|
|
22
|
-
]
|
|
23
|
-
}
|