beam-protocol-cli 0.5.1 → 0.5.2
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 +150 -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/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 +29 -4
- package/dist/index.js.map +1 -1
- package/package.json +14 -2
- 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/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { Command } from 'commander';
|
|
3
4
|
import chalk from 'chalk';
|
|
4
5
|
import { cmdInit } from './commands/init.js';
|
|
@@ -13,30 +14,43 @@ import { cmdVerifyCheck } from './commands/verify-check.js';
|
|
|
13
14
|
import { cmdStats } from './commands/stats.js';
|
|
14
15
|
import { cmdDelegate } from './commands/delegate.js';
|
|
15
16
|
import { cmdReport } from './commands/report.js';
|
|
17
|
+
import { cmdTalk } from './commands/talk.js';
|
|
18
|
+
const require = createRequire(import.meta.url);
|
|
19
|
+
const { version } = require('../package.json');
|
|
16
20
|
const program = new Command();
|
|
17
21
|
program
|
|
18
22
|
.name('beam')
|
|
19
23
|
.description(chalk.bold('Beam Protocol CLI') + '\n' +
|
|
20
24
|
chalk.dim('SMTP for AI Agents — agent identity, registration & intent routing'))
|
|
21
|
-
.version(
|
|
25
|
+
.version(version);
|
|
22
26
|
program
|
|
23
27
|
.command('init')
|
|
24
28
|
.description('Generate a new Beam identity (writes .beam/identity.json)')
|
|
25
|
-
.
|
|
29
|
+
.option('-a, --agent <name>', 'Agent name (e.g. jarvis)')
|
|
30
|
+
.option('-n, --name <name>', 'Alias for --agent')
|
|
26
31
|
.option('-o, --org <name>', 'Organisation name (optional for consumer Beam-IDs)')
|
|
27
32
|
.option('-d, --directory <url>', 'Directory server URL', process.env['BEAM_DIRECTORY_URL'] ?? 'https://api.beam.directory')
|
|
28
33
|
.option('-f, --force', 'Overwrite existing identity')
|
|
29
34
|
.action(async (opts) => {
|
|
30
|
-
|
|
35
|
+
const agent = opts.agent ?? opts.name;
|
|
36
|
+
if (!agent) {
|
|
37
|
+
throw new Error('init requires --agent <name>');
|
|
38
|
+
}
|
|
39
|
+
await cmdInit({ agent, org: opts.org, directory: opts.directory, force: opts.force });
|
|
31
40
|
});
|
|
32
41
|
program
|
|
33
42
|
.command('register')
|
|
34
43
|
.description('Register this agent with a Beam directory')
|
|
35
44
|
.option('-n, --display-name <name>', 'Human-readable display name')
|
|
45
|
+
.option('--name <name>', 'Alias for --display-name')
|
|
36
46
|
.option('-c, --capabilities <list>', 'Comma-separated capabilities (e.g. query,answer,write)')
|
|
37
47
|
.option('-d, --directory <url>', 'Override directory URL')
|
|
38
48
|
.action(async (opts) => {
|
|
39
|
-
await cmdRegister(
|
|
49
|
+
await cmdRegister({
|
|
50
|
+
displayName: opts.displayName ?? opts.name,
|
|
51
|
+
capabilities: opts.capabilities,
|
|
52
|
+
directory: opts.directory,
|
|
53
|
+
});
|
|
40
54
|
});
|
|
41
55
|
program
|
|
42
56
|
.command('lookup <beamId>')
|
|
@@ -135,6 +149,17 @@ program
|
|
|
135
149
|
.action(async (to, intent, params, opts) => {
|
|
136
150
|
await cmdSend(to, intent, params, opts);
|
|
137
151
|
});
|
|
152
|
+
program
|
|
153
|
+
.command('talk <to> <message>')
|
|
154
|
+
.description('Send a natural-language message via conversation.message')
|
|
155
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
156
|
+
.option('-t, --timeout <seconds>', 'Timeout in seconds', '60')
|
|
157
|
+
.option('-l, --language <language>', 'Language hint, e.g. en or de')
|
|
158
|
+
.option('-c, --context <json>', 'Optional context JSON object')
|
|
159
|
+
.option('--json', 'Output raw JSON')
|
|
160
|
+
.action(async (to, message, opts) => {
|
|
161
|
+
await cmdTalk(to, message, opts);
|
|
162
|
+
});
|
|
138
163
|
program.configureOutput({
|
|
139
164
|
outputError: (str, write) => write(chalk.red(str))
|
|
140
165
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAA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,CAAC;KAC9D,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;KACnC,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,OAAe,EAAE,IAAmG,EAAE,EAAE;IACjJ,MAAM,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC,CAAC,CAAA;AAEJ,OAAO,CAAC,eAAe,CAAC;IACtB,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnD,CAAC,CAAA;AAEF,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;IACpD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beam-protocol-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Beam Protocol CLI — manage Beam identities, register agents, send intents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"beam": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"scripts": {
|
|
11
12
|
"build": "tsc",
|
|
12
13
|
"dev": "node --watch dist/index.js",
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
"start": "node dist/index.js"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
+
"beam-protocol-sdk": "^0.5.2",
|
|
18
19
|
"chalk": "^5.3.0",
|
|
19
20
|
"commander": "^12.0.0",
|
|
20
21
|
"inquirer": "^9.2.15",
|
|
@@ -27,6 +28,17 @@
|
|
|
27
28
|
"engines": {
|
|
28
29
|
"node": ">=18.0.0"
|
|
29
30
|
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/Beam-directory/beam-protocol.git",
|
|
39
|
+
"directory": "packages/cli"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://beam.directory",
|
|
30
42
|
"license": "Apache-2.0",
|
|
31
43
|
"keywords": [
|
|
32
44
|
"beam-protocol",
|
package/src/commands/browse.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamClient } from '@beam-protocol/sdk'
|
|
4
|
-
import type { BrowseFilters } from '@beam-protocol/sdk'
|
|
5
|
-
import { loadConfig } from '../config.js'
|
|
6
|
-
|
|
7
|
-
interface BrowseOptions {
|
|
8
|
-
page?: string
|
|
9
|
-
capability?: string
|
|
10
|
-
tier?: string
|
|
11
|
-
verifiedOnly?: boolean
|
|
12
|
-
directory?: string
|
|
13
|
-
json?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function cmdBrowse(options: BrowseOptions): Promise<void> {
|
|
17
|
-
const config = loadConfig()
|
|
18
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
19
|
-
const page = options.page ? parseInt(options.page, 10) : 1
|
|
20
|
-
const filters: BrowseFilters = {
|
|
21
|
-
capability: options.capability,
|
|
22
|
-
tier: options.tier as BrowseFilters['tier'],
|
|
23
|
-
verified_only: options.verifiedOnly,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const spinner = ora(`Browsing directory page ${page}...`).start()
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const client = new BeamClient({ identity: config.identity, directoryUrl })
|
|
30
|
-
const result = await client.browse(page, filters)
|
|
31
|
-
spinner.stop()
|
|
32
|
-
|
|
33
|
-
if (options.json) {
|
|
34
|
-
console.log(JSON.stringify(result, null, 2))
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log('')
|
|
39
|
-
console.log(chalk.bold(`📚 Directory Page ${result.page}`))
|
|
40
|
-
console.log(chalk.dim(`Showing ${result.agents.length} of ${result.total} agents`))
|
|
41
|
-
console.log(chalk.dim('─'.repeat(72)))
|
|
42
|
-
|
|
43
|
-
for (const agent of result.agents) {
|
|
44
|
-
const badge = agent.verified ? chalk.green('✓') : chalk.dim('○')
|
|
45
|
-
const tier = agent.verificationTier ? chalk.magenta(agent.verificationTier) : chalk.dim('basic')
|
|
46
|
-
console.log(` ${badge} ${chalk.bold(agent.beamId)} ${chalk.dim(`(${tier})`)}`)
|
|
47
|
-
console.log(` ${agent.displayName}${agent.description ? chalk.dim(` — ${agent.description}`) : ''}`)
|
|
48
|
-
if (agent.capabilities.length > 0) {
|
|
49
|
-
console.log(` ${chalk.cyan('Capabilities:')} ${agent.capabilities.join(', ')}`)
|
|
50
|
-
}
|
|
51
|
-
if (agent.website) {
|
|
52
|
-
console.log(` ${chalk.cyan('Website:')} ${agent.website}`)
|
|
53
|
-
}
|
|
54
|
-
console.log('')
|
|
55
|
-
}
|
|
56
|
-
} catch (err) {
|
|
57
|
-
spinner.fail('Browse failed')
|
|
58
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
59
|
-
process.exit(1)
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/commands/delegate.ts
DELETED
|
@@ -1,52 +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 DelegateOptions {
|
|
7
|
-
scope?: string
|
|
8
|
-
expires?: string
|
|
9
|
-
directory?: string
|
|
10
|
-
json?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function cmdDelegate(targetBeamId: string, options: DelegateOptions): Promise<void> {
|
|
14
|
-
if (!BEAM_ID_PATTERN.test(targetBeamId)) {
|
|
15
|
-
console.error(chalk.red(`✖ Invalid Beam ID: ${targetBeamId}`))
|
|
16
|
-
process.exit(1)
|
|
17
|
-
}
|
|
18
|
-
if (!options.scope) {
|
|
19
|
-
console.error(chalk.red('✖ Missing required --scope value'))
|
|
20
|
-
process.exit(1)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const config = loadConfig()
|
|
24
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
25
|
-
const expiresIn = options.expires ? parseInt(options.expires, 10) : undefined
|
|
26
|
-
const spinner = ora(`Creating delegation for ${chalk.bold(targetBeamId)}...`).start()
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const client = new BeamClient({ identity: config.identity, directoryUrl })
|
|
30
|
-
const delegation = await client.delegate(targetBeamId, options.scope, expiresIn)
|
|
31
|
-
spinner.stop()
|
|
32
|
-
|
|
33
|
-
if (options.json) {
|
|
34
|
-
console.log(JSON.stringify(delegation, null, 2))
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log('')
|
|
39
|
-
console.log(chalk.bold.green('✅ Delegation created'))
|
|
40
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
41
|
-
console.log(`${chalk.cyan('From:')} ${delegation.sourceBeamId}`)
|
|
42
|
-
console.log(`${chalk.cyan('To:')} ${delegation.targetBeamId}`)
|
|
43
|
-
console.log(`${chalk.cyan('Scope:')} ${delegation.scope}`)
|
|
44
|
-
if (delegation.expiresAt) console.log(`${chalk.cyan('Expires:')} ${delegation.expiresAt}`)
|
|
45
|
-
if (delegation.status) console.log(`${chalk.cyan('Status:')} ${delegation.status}`)
|
|
46
|
-
console.log('')
|
|
47
|
-
} catch (err) {
|
|
48
|
-
spinner.fail('Delegation failed')
|
|
49
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
50
|
-
process.exit(1)
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/commands/init.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamIdentity } from '@beam-protocol/sdk'
|
|
4
|
-
import { configExists, saveConfig, DEFAULT_DIRECTORY_URL } from '../config.js'
|
|
5
|
-
|
|
6
|
-
interface InitOptions {
|
|
7
|
-
agent: string
|
|
8
|
-
org?: string
|
|
9
|
-
force?: boolean
|
|
10
|
-
directory?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function cmdInit(options: InitOptions): Promise<void> {
|
|
14
|
-
const { agent, org, force, directory = DEFAULT_DIRECTORY_URL } = options
|
|
15
|
-
|
|
16
|
-
if (!/^[a-z0-9_-]+$/.test(agent)) {
|
|
17
|
-
console.error(chalk.red('✖ Agent name must match [a-z0-9_-]'))
|
|
18
|
-
process.exit(1)
|
|
19
|
-
}
|
|
20
|
-
if (org && !/^[a-z0-9_-]+$/.test(org)) {
|
|
21
|
-
console.error(chalk.red('✖ Org name must match [a-z0-9_-]'))
|
|
22
|
-
process.exit(1)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (configExists() && !force) {
|
|
26
|
-
console.error(chalk.yellow('⚠ Identity already exists at .beam/identity.json'))
|
|
27
|
-
console.error(chalk.dim(' Use --force to overwrite'))
|
|
28
|
-
process.exit(1)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const spinner = ora('Generating Ed25519 keypair...').start()
|
|
32
|
-
|
|
33
|
-
const identity = BeamIdentity.generate({ agentName: agent, orgName: org })
|
|
34
|
-
const identityData = identity.export()
|
|
35
|
-
|
|
36
|
-
saveConfig({
|
|
37
|
-
identity: identityData,
|
|
38
|
-
directoryUrl: directory,
|
|
39
|
-
createdAt: new Date().toISOString()
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
spinner.succeed('Identity generated')
|
|
43
|
-
|
|
44
|
-
console.log('')
|
|
45
|
-
console.log(chalk.bold('🔑 Beam Identity Created'))
|
|
46
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
47
|
-
console.log(`${chalk.cyan('Beam ID:')} ${chalk.bold(identityData.beamId)}`)
|
|
48
|
-
console.log(`${chalk.cyan('Directory:')} ${directory}`)
|
|
49
|
-
console.log(`${chalk.cyan('Config:')} ${process.cwd()}/.beam/identity.json`)
|
|
50
|
-
console.log('')
|
|
51
|
-
console.log(chalk.dim('Public key (SPKI/DER/base64):'))
|
|
52
|
-
console.log(chalk.dim(identityData.publicKeyBase64.substring(0, 64) + '...'))
|
|
53
|
-
console.log('')
|
|
54
|
-
console.log(chalk.yellow('⚠ Keep .beam/identity.json secret — it contains your private key!'))
|
|
55
|
-
console.log(chalk.dim(' Add .beam/ to your .gitignore'))
|
|
56
|
-
console.log('')
|
|
57
|
-
console.log(
|
|
58
|
-
chalk.green('Next step:'),
|
|
59
|
-
`beam register --display-name "${org ? agent : 'My Consumer Agent'}" --capabilities "query,answer"`
|
|
60
|
-
)
|
|
61
|
-
}
|
package/src/commands/lookup.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import ora from 'ora'
|
|
3
|
-
import { BeamDirectory } from '@beam-protocol/sdk'
|
|
4
|
-
import type { BeamIdString } from '@beam-protocol/sdk'
|
|
5
|
-
import { BEAM_ID_PATTERN, resolveDirectoryUrl } from '../config.js'
|
|
6
|
-
|
|
7
|
-
interface LookupOptions {
|
|
8
|
-
directory?: string
|
|
9
|
-
json?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function cmdLookup(beamId: string, options: LookupOptions): Promise<void> {
|
|
13
|
-
const directoryUrl = resolveDirectoryUrl(options.directory)
|
|
14
|
-
|
|
15
|
-
if (!BEAM_ID_PATTERN.test(beamId)) {
|
|
16
|
-
console.error(chalk.red(`✖ Invalid Beam ID format: ${beamId}`))
|
|
17
|
-
console.error(chalk.dim(' Expected: agent@beam.directory or agent@org.beam.directory'))
|
|
18
|
-
process.exit(1)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const spinner = ora(`Looking up ${chalk.bold(beamId)}...`).start()
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const directory = new BeamDirectory({ baseUrl: directoryUrl })
|
|
25
|
-
const record = await directory.lookup(beamId as BeamIdString)
|
|
26
|
-
|
|
27
|
-
if (!record) {
|
|
28
|
-
spinner.fail(`Agent not found: ${beamId}`)
|
|
29
|
-
process.exit(1)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
spinner.stop()
|
|
33
|
-
|
|
34
|
-
if (options.json) {
|
|
35
|
-
console.log(JSON.stringify(record, null, 2))
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const trustBar = getTrustBar(record.trustScore)
|
|
40
|
-
|
|
41
|
-
console.log('')
|
|
42
|
-
console.log(chalk.bold(`🤖 ${record.displayName}`))
|
|
43
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
44
|
-
console.log(`${chalk.cyan('Beam ID:')} ${chalk.bold(record.beamId)}`)
|
|
45
|
-
console.log(`${chalk.cyan('Org:')} ${record.org ?? chalk.dim('consumer')}`)
|
|
46
|
-
console.log(`${chalk.cyan('Trust Score:')} ${trustBar} ${(record.trustScore * 100).toFixed(0)}%`)
|
|
47
|
-
console.log(`${chalk.cyan('Verified:')} ${record.verified ? chalk.green('✓ Verified') : chalk.yellow('Unverified')}`)
|
|
48
|
-
if (record.capabilities.length > 0) {
|
|
49
|
-
console.log(`${chalk.cyan('Capabilities:')} ${record.capabilities.map((capability: string) => chalk.blue(capability)).join(', ')}`)
|
|
50
|
-
}
|
|
51
|
-
console.log(`${chalk.cyan('Last Seen:')} ${new Date(record.lastSeen).toLocaleString()}`)
|
|
52
|
-
console.log(`${chalk.cyan('Registered:')} ${new Date(record.createdAt).toLocaleString()}`)
|
|
53
|
-
console.log('')
|
|
54
|
-
} catch (err) {
|
|
55
|
-
spinner.fail('Lookup failed')
|
|
56
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
57
|
-
process.exit(1)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getTrustBar(score: number): string {
|
|
62
|
-
const filled = Math.round(score * 10)
|
|
63
|
-
const empty = 10 - filled
|
|
64
|
-
const bar = '█'.repeat(filled) + '░'.repeat(empty)
|
|
65
|
-
if (score >= 0.8) return chalk.green(bar)
|
|
66
|
-
if (score >= 0.5) return chalk.yellow(bar)
|
|
67
|
-
return chalk.red(bar)
|
|
68
|
-
}
|
|
@@ -1,47 +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 ProfileUpdateOptions {
|
|
7
|
-
description?: string
|
|
8
|
-
logoUrl?: string
|
|
9
|
-
website?: string
|
|
10
|
-
directory?: string
|
|
11
|
-
json?: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function cmdProfileUpdate(options: ProfileUpdateOptions): Promise<void> {
|
|
15
|
-
const config = loadConfig()
|
|
16
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
17
|
-
const spinner = ora(`Updating profile for ${chalk.bold(config.identity.beamId)}...`).start()
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const client = new BeamClient({ identity: config.identity, directoryUrl })
|
|
21
|
-
const profile = await client.updateProfile({
|
|
22
|
-
description: options.description,
|
|
23
|
-
logo_url: options.logoUrl,
|
|
24
|
-
website: options.website,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
spinner.stop()
|
|
28
|
-
|
|
29
|
-
if (options.json) {
|
|
30
|
-
console.log(JSON.stringify(profile, null, 2))
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
console.log('')
|
|
35
|
-
console.log(chalk.bold.green('✅ Profile updated'))
|
|
36
|
-
console.log(chalk.dim('─'.repeat(40)))
|
|
37
|
-
console.log(`${chalk.cyan('Beam ID:')} ${profile.beamId}`)
|
|
38
|
-
console.log(`${chalk.cyan('Description:')} ${profile.description ?? chalk.dim('—')}`)
|
|
39
|
-
console.log(`${chalk.cyan('Logo URL:')} ${profile.logoUrl ?? chalk.dim('—')}`)
|
|
40
|
-
console.log(`${chalk.cyan('Website:')} ${profile.website ?? chalk.dim('—')}`)
|
|
41
|
-
console.log('')
|
|
42
|
-
} catch (err) {
|
|
43
|
-
spinner.fail('Profile update failed')
|
|
44
|
-
console.error(chalk.red(`✖ ${(err as Error).message}`))
|
|
45
|
-
process.exit(1)
|
|
46
|
-
}
|
|
47
|
-
}
|
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
|
-
}
|