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.
- package/dist/commands/browse.d.ts +11 -0
- package/dist/commands/browse.d.ts.map +1 -0
- package/dist/commands/browse.js +47 -0
- package/dist/commands/browse.js.map +1 -0
- package/dist/commands/delegate.d.ts +9 -0
- package/dist/commands/delegate.d.ts.map +1 -0
- package/dist/commands/delegate.js +44 -0
- package/dist/commands/delegate.js.map +1 -0
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/lookup.d.ts.map +1 -1
- package/dist/commands/lookup.js +6 -8
- package/dist/commands/lookup.js.map +1 -1
- package/dist/commands/profile-update.d.ts +10 -0
- package/dist/commands/profile-update.d.ts.map +1 -0
- package/dist/commands/profile-update.js +36 -0
- package/dist/commands/profile-update.js.map +1 -0
- package/dist/commands/register.js +1 -1
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/report.d.ts +8 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +41 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +2 -3
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +3 -5
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/stats.d.ts +7 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +35 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/verify-check.d.ts +7 -0
- package/dist/commands/verify-check.d.ts.map +1 -0
- package/dist/commands/verify-check.js +34 -0
- package/dist/commands/verify-check.js.map +1 -0
- package/dist/commands/verify-domain.d.ts +7 -0
- package/dist/commands/verify-domain.d.ts.map +1 -0
- package/dist/commands/verify-domain.js +36 -0
- package/dist/commands/verify-domain.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -3
- package/dist/config.js.map +1 -1
- package/dist/index.js +83 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/browse.ts +61 -0
- package/src/commands/delegate.ts +52 -0
- package/src/commands/init.ts +6 -4
- package/src/commands/lookup.ts +6 -8
- package/src/commands/profile-update.ts +47 -0
- package/src/commands/register.ts +1 -1
- package/src/commands/report.ts +49 -0
- package/src/commands/search.ts +3 -6
- package/src/commands/send.ts +4 -9
- package/src/commands/stats.ts +40 -0
- package/src/commands/verify-check.ts +41 -0
- package/src/commands/verify-domain.ts +42 -0
- package/src/config.ts +16 -5
- package/src/index.ts +91 -12
- package/tsconfig.json +7 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-domain.d.ts","sourceRoot":"","sources":["../../src/commands/verify-domain.ts"],"names":[],"mappings":"AAKA,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BjG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { BeamClient } from '@beam-protocol/sdk';
|
|
4
|
+
import { loadConfig } from '../config.js';
|
|
5
|
+
export async function cmdVerifyDomain(domain, options) {
|
|
6
|
+
const config = loadConfig();
|
|
7
|
+
const directoryUrl = options.directory ?? config.directoryUrl;
|
|
8
|
+
const spinner = ora(`Starting DNS verification for ${chalk.bold(domain)}...`).start();
|
|
9
|
+
try {
|
|
10
|
+
const client = new BeamClient({ identity: config.identity, directoryUrl });
|
|
11
|
+
const verification = await client.verifyDomain(domain);
|
|
12
|
+
spinner.stop();
|
|
13
|
+
if (options.json) {
|
|
14
|
+
console.log(JSON.stringify(verification, null, 2));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log(chalk.bold('๐ Domain verification started'));
|
|
19
|
+
console.log(chalk.dim('โ'.repeat(40)));
|
|
20
|
+
console.log(`${chalk.cyan('Domain:')} ${verification.domain}`);
|
|
21
|
+
console.log(`${chalk.cyan('Verified:')} ${verification.verified ? chalk.green('Yes') : chalk.yellow('Pending')}`);
|
|
22
|
+
if (verification.txtName)
|
|
23
|
+
console.log(`${chalk.cyan('TXT Name:')} ${verification.txtName}`);
|
|
24
|
+
if (verification.txtValue ?? verification.expected) {
|
|
25
|
+
console.log(`${chalk.cyan('TXT Value:')} ${verification.txtValue ?? verification.expected}`);
|
|
26
|
+
}
|
|
27
|
+
console.log('');
|
|
28
|
+
console.log(chalk.dim('After adding the TXT record, run: beam verify check'));
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
spinner.fail('Domain verification failed');
|
|
32
|
+
console.error(chalk.red(`โ ${err.message}`));
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=verify-domain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-domain.js","sourceRoot":"","sources":["../../src/commands/verify-domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAOzC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,OAA4B;IAChF,MAAM,MAAM,GAAG,UAAU,EAAE,CAAA;IAC3B,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,YAAY,CAAA;IAC7D,MAAM,OA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AAI,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC9F,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC,CAAA;IAC/E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;QAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -7,7 +7,10 @@ export interface BeamConfig {
|
|
|
7
7
|
export declare function getConfigDir(cwd?: string): string;
|
|
8
8
|
export declare function getConfigPath(cwd?: string): string;
|
|
9
9
|
export declare function configExists(cwd?: string): boolean;
|
|
10
|
+
export declare function loadOptionalConfig(cwd?: string): BeamConfig | null;
|
|
10
11
|
export declare function loadConfig(cwd?: string): BeamConfig;
|
|
12
|
+
export declare function resolveDirectoryUrl(override?: string, cwd?: string): string;
|
|
11
13
|
export declare function saveConfig(config: BeamConfig, cwd?: string): void;
|
|
12
14
|
export declare const DEFAULT_DIRECTORY_URL: string;
|
|
15
|
+
export declare const BEAM_ID_PATTERN: RegExp;
|
|
13
16
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,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 @@ export function getConfigPath(cwd = process.cwd()) {
|
|
|
9
9
|
export function configExists(cwd = process.cwd()) {
|
|
10
10
|
return existsSync(getConfigPath(cwd));
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
12
|
+
export function loadOptionalConfig(cwd = process.cwd()) {
|
|
13
13
|
const path = getConfigPath(cwd);
|
|
14
14
|
if (!existsSync(path)) {
|
|
15
|
-
|
|
15
|
+
return null;
|
|
16
16
|
}
|
|
17
17
|
const raw = readFileSync(path, 'utf8');
|
|
18
18
|
return JSON.parse(raw);
|
|
19
19
|
}
|
|
20
|
+
export function loadConfig(cwd = process.cwd()) {
|
|
21
|
+
const config = loadOptionalConfig(cwd);
|
|
22
|
+
if (!config) {
|
|
23
|
+
throw new Error(`No Beam identity found. Run 'beam init' first.`);
|
|
24
|
+
}
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
export function resolveDirectoryUrl(override, cwd = process.cwd()) {
|
|
28
|
+
return override ?? loadOptionalConfig(cwd)?.directoryUrl ?? DEFAULT_DIRECTORY_URL;
|
|
29
|
+
}
|
|
20
30
|
export function saveConfig(config, cwd = process.cwd()) {
|
|
21
31
|
const dir = getConfigDir(cwd);
|
|
22
32
|
mkdirSync(dir, { recursive: true });
|
|
23
33
|
writeFileSync(getConfigPath(cwd), JSON.stringify(config, null, 2), 'utf8');
|
|
24
34
|
}
|
|
25
|
-
export const DEFAULT_DIRECTORY_URL = process.env['BEAM_DIRECTORY_URL'] ?? '
|
|
35
|
+
export const DEFAULT_DIRECTORY_URL = process.env['BEAM_DIRECTORY_URL'] ?? 'https://api.beam.directory';
|
|
36
|
+
export const BEAM_ID_PATTERN = /^(?:[a-z0-9_-]+@beam\.directory|[a-z0-9_-]+@[a-z0-9_-]+\.beam\.directory)$/;
|
|
26
37
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[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AG,4EAA4E,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,24 +6,29 @@ 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
|
const program = new Command();
|
|
10
17
|
program
|
|
11
18
|
.name('beam')
|
|
12
19
|
.description(chalk.bold('Beam Protocol CLI') + '\n' +
|
|
13
20
|
chalk.dim('SMTP for AI Agents โ agent identity, registration & intent routing'))
|
|
14
|
-
.version('0.
|
|
15
|
-
// โโโ beam init โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
21
|
+
.version('0.5.0');
|
|
16
22
|
program
|
|
17
23
|
.command('init')
|
|
18
24
|
.description('Generate a new Beam identity (writes .beam/identity.json)')
|
|
19
25
|
.requiredOption('-a, --agent <name>', 'Agent name (e.g. jarvis)')
|
|
20
|
-
.
|
|
21
|
-
.option('-d, --directory <url>', 'Directory server URL', process.env['BEAM_DIRECTORY_URL'] ?? '
|
|
26
|
+
.option('-o, --org <name>', 'Organisation name (optional for consumer Beam-IDs)')
|
|
27
|
+
.option('-d, --directory <url>', 'Directory server URL', process.env['BEAM_DIRECTORY_URL'] ?? 'https://api.beam.directory')
|
|
22
28
|
.option('-f, --force', 'Overwrite existing identity')
|
|
23
29
|
.action(async (opts) => {
|
|
24
30
|
await cmdInit(opts);
|
|
25
31
|
});
|
|
26
|
-
// โโโ beam register โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
27
32
|
program
|
|
28
33
|
.command('register')
|
|
29
34
|
.description('Register this agent with a Beam directory')
|
|
@@ -33,7 +38,6 @@ program
|
|
|
33
38
|
.action(async (opts) => {
|
|
34
39
|
await cmdRegister(opts);
|
|
35
40
|
});
|
|
36
|
-
// โโโ beam lookup โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
37
41
|
program
|
|
38
42
|
.command('lookup <beamId>')
|
|
39
43
|
.description('Look up an agent by Beam ID')
|
|
@@ -42,7 +46,6 @@ program
|
|
|
42
46
|
.action(async (beamId, opts) => {
|
|
43
47
|
await cmdLookup(beamId, opts);
|
|
44
48
|
});
|
|
45
|
-
// โโโ beam search โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
46
49
|
program
|
|
47
50
|
.command('search')
|
|
48
51
|
.description('Search for agents in the directory')
|
|
@@ -55,7 +58,74 @@ program
|
|
|
55
58
|
.action(async (opts) => {
|
|
56
59
|
await cmdSearch(opts);
|
|
57
60
|
});
|
|
58
|
-
|
|
61
|
+
program
|
|
62
|
+
.command('browse')
|
|
63
|
+
.description('Browse paginated agent listings')
|
|
64
|
+
.option('--page <n>', 'Page number', '1')
|
|
65
|
+
.option('--capability <cap>', 'Filter by capability')
|
|
66
|
+
.option('--tier <tier>', 'Filter by verification tier')
|
|
67
|
+
.option('--verified-only', 'Only show verified agents')
|
|
68
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
69
|
+
.option('--json', 'Output raw JSON')
|
|
70
|
+
.action(async (opts) => {
|
|
71
|
+
await cmdBrowse(opts);
|
|
72
|
+
});
|
|
73
|
+
const profile = program.command('profile').description('Profile management commands');
|
|
74
|
+
profile
|
|
75
|
+
.command('update')
|
|
76
|
+
.description('Update your agent profile')
|
|
77
|
+
.option('--description <text>', 'Profile description')
|
|
78
|
+
.option('--logo-url <url>', 'Public logo URL')
|
|
79
|
+
.option('--website <url>', 'Public website URL')
|
|
80
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
81
|
+
.option('--json', 'Output raw JSON')
|
|
82
|
+
.action(async (opts) => {
|
|
83
|
+
await cmdProfileUpdate(opts);
|
|
84
|
+
});
|
|
85
|
+
const verify = program.command('verify').description('Verification commands');
|
|
86
|
+
verify
|
|
87
|
+
.command('domain <domain>')
|
|
88
|
+
.description('Initiate DNS verification for a domain')
|
|
89
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
90
|
+
.option('--json', 'Output raw JSON')
|
|
91
|
+
.action(async (domain, opts) => {
|
|
92
|
+
await cmdVerifyDomain(domain, opts);
|
|
93
|
+
});
|
|
94
|
+
verify
|
|
95
|
+
.command('check')
|
|
96
|
+
.description('Check current verification status')
|
|
97
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
98
|
+
.option('--json', 'Output raw JSON')
|
|
99
|
+
.action(async (opts) => {
|
|
100
|
+
await cmdVerifyCheck(opts);
|
|
101
|
+
});
|
|
102
|
+
program
|
|
103
|
+
.command('stats')
|
|
104
|
+
.description('Show directory statistics')
|
|
105
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
106
|
+
.option('--json', 'Output raw JSON')
|
|
107
|
+
.action(async (opts) => {
|
|
108
|
+
await cmdStats(opts);
|
|
109
|
+
});
|
|
110
|
+
program
|
|
111
|
+
.command('delegate <targetBeamId>')
|
|
112
|
+
.description('Create a delegation for another Beam agent')
|
|
113
|
+
.requiredOption('--scope <scope>', 'Delegation scope')
|
|
114
|
+
.option('--expires <hours>', 'Hours until delegation expiry')
|
|
115
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
116
|
+
.option('--json', 'Output raw JSON')
|
|
117
|
+
.action(async (targetBeamId, opts) => {
|
|
118
|
+
await cmdDelegate(targetBeamId, opts);
|
|
119
|
+
});
|
|
120
|
+
program
|
|
121
|
+
.command('report <targetBeamId>')
|
|
122
|
+
.description('Report an agent')
|
|
123
|
+
.requiredOption('--reason <reason>', 'Reason for the report')
|
|
124
|
+
.option('-d, --directory <url>', 'Override directory URL')
|
|
125
|
+
.option('--json', 'Output raw JSON')
|
|
126
|
+
.action(async (targetBeamId, opts) => {
|
|
127
|
+
await cmdReport(targetBeamId, opts);
|
|
128
|
+
});
|
|
59
129
|
program
|
|
60
130
|
.command('send <to> <intent> [params]')
|
|
61
131
|
.description('Send an intent to an agent and print the result')
|
|
@@ -65,9 +135,11 @@ program
|
|
|
65
135
|
.action(async (to, intent, params, opts) => {
|
|
66
136
|
await cmdSend(to, intent, params, opts);
|
|
67
137
|
});
|
|
68
|
-
// โโโ Error handling โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
69
138
|
program.configureOutput({
|
|
70
|
-
|
|
139
|
+
outputError: (str, write) => write(chalk.red(str))
|
|
140
|
+
});
|
|
141
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
142
|
+
console.error(chalk.red(`\nโ ${err.message}`));
|
|
143
|
+
process.exit(1);
|
|
71
144
|
});
|
|
72
|
-
program.parse();
|
|
73
145
|
//# sourceMappingURL=index.js.map
|
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,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,E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AAA;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beam-protocol-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Beam Protocol CLI
|
|
3
|
+
"version": "0.5.1",
|
|
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"
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
CHANGED
|
@@ -5,7 +5,7 @@ import { configExists, saveConfig, DEFAULT_DIRECTORY_URL } from '../config.js'
|
|
|
5
5
|
|
|
6
6
|
interface InitOptions {
|
|
7
7
|
agent: string
|
|
8
|
-
org
|
|
8
|
+
org?: string
|
|
9
9
|
force?: boolean
|
|
10
10
|
directory?: string
|
|
11
11
|
}
|
|
@@ -13,12 +13,11 @@ interface InitOptions {
|
|
|
13
13
|
export async function cmdInit(options: InitOptions): Promise<void> {
|
|
14
14
|
const { agent, org, force, directory = DEFAULT_DIRECTORY_URL } = options
|
|
15
15
|
|
|
16
|
-
// Validate inputs
|
|
17
16
|
if (!/^[a-z0-9_-]+$/.test(agent)) {
|
|
18
17
|
console.error(chalk.red('โ Agent name must match [a-z0-9_-]'))
|
|
19
18
|
process.exit(1)
|
|
20
19
|
}
|
|
21
|
-
if (!/^[a-z0-9_-]+$/.test(org)) {
|
|
20
|
+
if (org && !/^[a-z0-9_-]+$/.test(org)) {
|
|
22
21
|
console.error(chalk.red('โ Org name must match [a-z0-9_-]'))
|
|
23
22
|
process.exit(1)
|
|
24
23
|
}
|
|
@@ -55,5 +54,8 @@ export async function cmdInit(options: InitOptions): Promise<void> {
|
|
|
55
54
|
console.log(chalk.yellow('โ Keep .beam/identity.json secret โ it contains your private key!'))
|
|
56
55
|
console.log(chalk.dim(' Add .beam/ to your .gitignore'))
|
|
57
56
|
console.log('')
|
|
58
|
-
console.log(
|
|
57
|
+
console.log(
|
|
58
|
+
chalk.green('Next step:'),
|
|
59
|
+
`beam register --display-name "${org ? agent : 'My Consumer Agent'}" --capabilities "query,answer"`
|
|
60
|
+
)
|
|
59
61
|
}
|
package/src/commands/lookup.ts
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk'
|
|
|
2
2
|
import ora from 'ora'
|
|
3
3
|
import { BeamDirectory } from '@beam-protocol/sdk'
|
|
4
4
|
import type { BeamIdString } from '@beam-protocol/sdk'
|
|
5
|
-
import {
|
|
5
|
+
import { BEAM_ID_PATTERN, resolveDirectoryUrl } from '../config.js'
|
|
6
6
|
|
|
7
7
|
interface LookupOptions {
|
|
8
8
|
directory?: string
|
|
@@ -10,13 +10,11 @@ interface LookupOptions {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export async function cmdLookup(beamId: string, options: LookupOptions): Promise<void> {
|
|
13
|
-
const
|
|
14
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
13
|
+
const directoryUrl = resolveDirectoryUrl(options.directory)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
if (!beamId.match(/^[a-z0-9_-]+@[a-z0-9_-]+\.beam\.directory$/)) {
|
|
15
|
+
if (!BEAM_ID_PATTERN.test(beamId)) {
|
|
18
16
|
console.error(chalk.red(`โ Invalid Beam ID format: ${beamId}`))
|
|
19
|
-
console.error(chalk.dim(' Expected: agent@org.beam.directory'))
|
|
17
|
+
console.error(chalk.dim(' Expected: agent@beam.directory or agent@org.beam.directory'))
|
|
20
18
|
process.exit(1)
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -44,11 +42,11 @@ export async function cmdLookup(beamId: string, options: LookupOptions): Promise
|
|
|
44
42
|
console.log(chalk.bold(`๐ค ${record.displayName}`))
|
|
45
43
|
console.log(chalk.dim('โ'.repeat(40)))
|
|
46
44
|
console.log(`${chalk.cyan('Beam ID:')} ${chalk.bold(record.beamId)}`)
|
|
47
|
-
console.log(`${chalk.cyan('Org:')} ${record.org}`)
|
|
45
|
+
console.log(`${chalk.cyan('Org:')} ${record.org ?? chalk.dim('consumer')}`)
|
|
48
46
|
console.log(`${chalk.cyan('Trust Score:')} ${trustBar} ${(record.trustScore * 100).toFixed(0)}%`)
|
|
49
47
|
console.log(`${chalk.cyan('Verified:')} ${record.verified ? chalk.green('โ Verified') : chalk.yellow('Unverified')}`)
|
|
50
48
|
if (record.capabilities.length > 0) {
|
|
51
|
-
console.log(`${chalk.cyan('Capabilities:')} ${record.capabilities.map(
|
|
49
|
+
console.log(`${chalk.cyan('Capabilities:')} ${record.capabilities.map((capability: string) => chalk.blue(capability)).join(', ')}`)
|
|
52
50
|
}
|
|
53
51
|
console.log(`${chalk.cyan('Last Seen:')} ${new Date(record.lastSeen).toLocaleString()}`)
|
|
54
52
|
console.log(`${chalk.cyan('Registered:')} ${new Date(record.createdAt).toLocaleString()}`)
|
|
@@ -0,0 +1,47 @@
|
|
|
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
CHANGED
|
@@ -41,7 +41,7 @@ export async function cmdRegister(options: RegisterOptions): Promise<void> {
|
|
|
41
41
|
console.log(chalk.dim('โ'.repeat(40)))
|
|
42
42
|
console.log(`${chalk.cyan('Beam ID:')} ${chalk.bold(record.beamId)}`)
|
|
43
43
|
console.log(`${chalk.cyan('Display:')} ${record.displayName}`)
|
|
44
|
-
console.log(`${chalk.cyan('Org:')} ${record.org}`)
|
|
44
|
+
console.log(`${chalk.cyan('Org:')} ${record.org ?? chalk.dim('consumer')}`)
|
|
45
45
|
console.log(`${chalk.cyan('Trust Score:')} ${(record.trustScore * 100).toFixed(0)}%`)
|
|
46
46
|
console.log(`${chalk.cyan('Verified:')} ${record.verified ? chalk.green('Yes โ') : chalk.yellow('No')}`)
|
|
47
47
|
if (record.capabilities.length > 0) {
|
|
@@ -0,0 +1,49 @@
|
|
|
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import ora from 'ora'
|
|
3
3
|
import { BeamDirectory } from '@beam-protocol/sdk'
|
|
4
|
-
import {
|
|
4
|
+
import { resolveDirectoryUrl } from '../config.js'
|
|
5
5
|
|
|
6
6
|
interface SearchOptions {
|
|
7
7
|
org?: string
|
|
@@ -13,8 +13,7 @@ interface SearchOptions {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export async function cmdSearch(options: SearchOptions): Promise<void> {
|
|
16
|
-
const
|
|
17
|
-
const directoryUrl = options.directory ?? config.directoryUrl
|
|
16
|
+
const directoryUrl = resolveDirectoryUrl(options.directory)
|
|
18
17
|
|
|
19
18
|
const query = {
|
|
20
19
|
org: options.org,
|
|
@@ -57,9 +56,7 @@ export async function cmdSearch(options: SearchOptions): Promise<void> {
|
|
|
57
56
|
? chalk.dim(` [${agent.capabilities.join(', ')}]`)
|
|
58
57
|
: ''
|
|
59
58
|
|
|
60
|
-
console.log(
|
|
61
|
-
` ${verified} ${chalk.bold(agent.beamId)}${caps}`
|
|
62
|
-
)
|
|
59
|
+
console.log(` ${verified} ${chalk.bold(agent.beamId)}${caps}`)
|
|
63
60
|
console.log(
|
|
64
61
|
` ${chalk.dim(agent.displayName)} ยท Trust: ${getTrustColored(agent.trustScore, trustPct + '%')} ยท Last seen: ${formatRelative(agent.lastSeen)}`
|
|
65
62
|
)
|
package/src/commands/send.ts
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk'
|
|
|
2
2
|
import ora from 'ora'
|
|
3
3
|
import { BeamClient } from '@beam-protocol/sdk'
|
|
4
4
|
import type { BeamIdString } from '@beam-protocol/sdk'
|
|
5
|
-
import { loadConfig } from '../config.js'
|
|
5
|
+
import { BEAM_ID_PATTERN, loadConfig } from '../config.js'
|
|
6
6
|
|
|
7
7
|
interface SendOptions {
|
|
8
8
|
directory?: string
|
|
@@ -20,14 +20,12 @@ export async function cmdSend(
|
|
|
20
20
|
const directoryUrl = options.directory ?? config.directoryUrl
|
|
21
21
|
const timeoutMs = options.timeout ? parseInt(options.timeout, 10) * 1000 : 10000
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
if (!to.match(/^[a-z0-9_-]+@[a-z0-9_-]+\.beam\.directory$/)) {
|
|
23
|
+
if (!BEAM_ID_PATTERN.test(to)) {
|
|
25
24
|
console.error(chalk.red(`โ Invalid Beam ID: ${to}`))
|
|
26
|
-
console.error(chalk.dim(' Expected: agent@org.beam.directory'))
|
|
25
|
+
console.error(chalk.dim(' Expected: agent@beam.directory or agent@org.beam.directory'))
|
|
27
26
|
process.exit(1)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
// Parse params
|
|
31
29
|
let params: Record<string, unknown> = {}
|
|
32
30
|
if (paramsJson) {
|
|
33
31
|
try {
|
|
@@ -43,10 +41,7 @@ export async function cmdSend(
|
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
const spinner = ora(
|
|
47
|
-
`Sending ${chalk.bold(intent)} to ${chalk.bold(to)}...`
|
|
48
|
-
).start()
|
|
49
|
-
|
|
44
|
+
const spinner = ora(`Sending ${chalk.bold(intent)} to ${chalk.bold(to)}...`).start()
|
|
50
45
|
const startTime = Date.now()
|
|
51
46
|
|
|
52
47
|
try {
|