agentbnb 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli/index.js +18 -22
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -2905,6 +2905,22 @@ async function confirm(question) {
2905
2905
  rl.close();
2906
2906
  }
2907
2907
  }
2908
+ function loadIdentityAuth(owner) {
2909
+ const configDir = getConfigDir();
2910
+ let keys;
2911
+ try {
2912
+ keys = loadKeyPair(configDir);
2913
+ } catch {
2914
+ keys = generateKeyPair();
2915
+ saveKeyPair(configDir, keys);
2916
+ }
2917
+ const identity = ensureIdentity(configDir, owner);
2918
+ return {
2919
+ agentId: identity.agent_id,
2920
+ publicKey: identity.public_key,
2921
+ privateKey: keys.privateKey
2922
+ };
2923
+ }
2908
2924
  function getLanIp() {
2909
2925
  const nets = networkInterfaces();
2910
2926
  for (const ifaces of Object.values(nets)) {
@@ -3450,16 +3466,7 @@ program.command("request [card-id]").description("Request a capability from anot
3450
3466
  gatewayUrl = peer.url;
3451
3467
  token = peer.token;
3452
3468
  isRemoteRequest = true;
3453
- const configDir = getConfigDir();
3454
- const agentIdentity = loadIdentity(configDir);
3455
- if (agentIdentity) {
3456
- const keys = loadKeyPair(configDir);
3457
- identityAuth = {
3458
- agentId: agentIdentity.agent_id,
3459
- publicKey: agentIdentity.public_key,
3460
- privateKey: keys.privateKey
3461
- };
3462
- }
3469
+ identityAuth = loadIdentityAuth(config.owner);
3463
3470
  } else {
3464
3471
  const db = openDatabase(config.db_path);
3465
3472
  let localCard;
@@ -3498,18 +3505,7 @@ program.command("request [card-id]").description("Request a capability from anot
3498
3505
  gatewayUrl = remoteCard.gateway_url;
3499
3506
  token = "";
3500
3507
  isRemoteRequest = true;
3501
- const configDir = getConfigDir();
3502
- const agentIdentity = loadIdentity(configDir);
3503
- if (!agentIdentity) {
3504
- console.error("Error: no agent identity found. Run `agentbnb init` first.");
3505
- process.exit(1);
3506
- }
3507
- const keys = loadKeyPair(configDir);
3508
- identityAuth = {
3509
- agentId: agentIdentity.agent_id,
3510
- publicKey: agentIdentity.public_key,
3511
- privateKey: keys.privateKey
3512
- };
3508
+ identityAuth = loadIdentityAuth(config.owner);
3513
3509
  if (!opts.json) {
3514
3510
  const displayName = remoteCard.name ?? remoteCard.agent_name ?? cardId;
3515
3511
  console.log(`Found remote card: ${displayName} @ ${gatewayUrl}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbnb",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "P2P Agent Capability Sharing Protocol — Airbnb for AI agent pipelines",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",