a2acalling 0.6.7 → 0.6.9

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/bin/cli.js CHANGED
@@ -81,7 +81,7 @@ function enforceOnboarding(command) {
81
81
  const cfg = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
82
82
  if (cfg.onboarding?.step === 'awaiting_disclosure') {
83
83
  console.log('\nA2A setup in progress. Disclosure topics not yet submitted.\n');
84
- console.log("Next: run `a2a onboard --submit '<json>'`\n");
84
+ console.log("Next: run `a2a quickstart --submit '<json>'` (or `a2a onboard --submit`)\n");
85
85
  process.exit(1);
86
86
  }
87
87
  } catch (e) {
@@ -210,6 +210,122 @@ async function promptYesNo(question) {
210
210
  });
211
211
  }
212
212
 
213
+ async function handleDisclosureSubmit(args, commandLabel = 'onboard') {
214
+ const submitRaw = args.flags.submit;
215
+ if (!submitRaw) return false;
216
+
217
+ const { A2AConfig } = require('../src/lib/config');
218
+ const {
219
+ validateDisclosureSubmission,
220
+ saveManifest,
221
+ MANIFEST_FILE
222
+ } = require('../src/lib/disclosure');
223
+
224
+ const config = new A2AConfig();
225
+ const submitCommand = commandLabel === 'quickstart'
226
+ ? 'a2a quickstart --submit'
227
+ : 'a2a onboard --submit';
228
+
229
+ let parsed;
230
+ try {
231
+ parsed = JSON.parse(String(submitRaw));
232
+ } catch (e) {
233
+ console.error('\nInvalid JSON in --submit flag.');
234
+ console.error(` Parse error: ${e.message}\n`);
235
+ process.exit(1);
236
+ }
237
+
238
+ const result = validateDisclosureSubmission(parsed);
239
+ if (!result.valid) {
240
+ console.error('\nDisclosure submission validation failed:\n');
241
+ result.errors.forEach(err => console.error(` - ${err}`));
242
+ console.error(`\nFix the errors above and resubmit with: ${submitCommand} '<json>'\n`);
243
+ process.exit(1);
244
+ }
245
+
246
+ saveManifest(result.manifest);
247
+ console.log('\nStep 3 of 4: Disclosure manifest saved.');
248
+ console.log(` Manifest: ${MANIFEST_FILE}`);
249
+
250
+ // Sync tier config from manifest
251
+ const manifest = result.manifest;
252
+ function flattenTopics(sections) {
253
+ const out = [];
254
+ for (const section of sections) {
255
+ for (const item of section) {
256
+ const t = String(item && item.topic || '').trim();
257
+ if (t && !out.includes(t)) out.push(t);
258
+ }
259
+ }
260
+ return out;
261
+ }
262
+
263
+ try {
264
+ config.setTier('public', {
265
+ topics: flattenTopics([manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect]),
266
+ disclosure: 'public'
267
+ });
268
+ config.setTier('friends', {
269
+ topics: flattenTopics([
270
+ manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect,
271
+ manifest.topics.friends.lead_with, manifest.topics.friends.discuss_freely, manifest.topics.friends.deflect
272
+ ]),
273
+ disclosure: 'minimal'
274
+ });
275
+ config.setTier('family', {
276
+ topics: flattenTopics([
277
+ manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect,
278
+ manifest.topics.friends.lead_with, manifest.topics.friends.discuss_freely, manifest.topics.friends.deflect,
279
+ manifest.topics.family.lead_with, manifest.topics.family.discuss_freely, manifest.topics.family.deflect
280
+ ]),
281
+ disclosure: 'minimal'
282
+ });
283
+ } catch (err) {
284
+ console.error(` Warning: could not sync tier config: ${err.message}`);
285
+ }
286
+
287
+ // If already onboarded, this is a topic update — no invite generation needed
288
+ if (config.isOnboarded()) {
289
+ console.log('\nDisclosure topics updated. Your agent will use these on the next inbound call.\n');
290
+ return true;
291
+ }
292
+
293
+ console.log('\nStep 4 of 4: Generating your first invite...\n');
294
+
295
+ const agentName = args.flags.name || config.getAgent().name || process.env.A2A_AGENT_NAME || 'my-agent';
296
+ const hostname = config.getAgent().hostname || process.env.A2A_HOSTNAME || 'localhost';
297
+ if (args.flags.name) config.setAgent({ name: agentName });
298
+
299
+ const publicTopics = flattenTopics([
300
+ manifest.topics.public.lead_with,
301
+ manifest.topics.public.discuss_freely
302
+ ]);
303
+
304
+ const { token } = store.create({
305
+ name: agentName,
306
+ owner: agentName,
307
+ permissions: 'public',
308
+ disclosure: 'minimal',
309
+ expires: 'never',
310
+ maxCalls: null,
311
+ allowedTopics: publicTopics,
312
+ allowedGoals: ['grow-network', 'find-collaborators', 'build-in-public'],
313
+ notify: 'all'
314
+ });
315
+
316
+ const inviteUrl = `a2a://${hostname}/${token}`;
317
+ console.log(` Invite URL: ${inviteUrl}`);
318
+ console.log(' Share this invite to let other agents call you.\n');
319
+
320
+ config.completeOnboarding();
321
+ console.log('Onboarding complete.\n');
322
+ console.log(` Config: ${CONFIG_PATH}`);
323
+ console.log(` Disclosure: ${MANIFEST_FILE}`);
324
+ console.log(` Invite: ${inviteUrl}\n`);
325
+
326
+ return true;
327
+ }
328
+
213
329
  async function resolveInviteHostname() {
214
330
  const { resolveInviteHost } = require('../src/lib/invite-host');
215
331
 
@@ -949,11 +1065,15 @@ https://github.com/onthegonow/a2a_calling`;
949
1065
  quickstart: async (args) => {
950
1066
  const { A2AConfig } = require('../src/lib/config');
951
1067
  const { tryBindPort, findAvailablePort, isPortListening } = require('../src/lib/port-scanner');
952
- const { buildExtractionPrompt, MANIFEST_FILE } = require('../src/lib/disclosure');
1068
+ const { buildExtractionPrompt } = require('../src/lib/disclosure');
953
1069
  const { getExternalIp } = require('../src/lib/external-ip');
954
1070
 
955
1071
  const config = new A2AConfig();
956
1072
 
1073
+ if (await handleDisclosureSubmit(args, 'quickstart')) {
1074
+ return;
1075
+ }
1076
+
957
1077
  if (args.flags.force) {
958
1078
  config.resetOnboarding();
959
1079
  }
@@ -979,7 +1099,7 @@ https://github.com/onthegonow/a2a_calling`;
979
1099
  console.log('Step 2 of 4: Configure disclosure topics\n');
980
1100
  console.log(buildExtractionPrompt());
981
1101
  console.log('\n Read your workspace files, extract topics, and present to your owner for review.');
982
- console.log(" Then submit with: a2a onboard --submit '<json>'\n");
1102
+ console.log(" Then submit with: a2a quickstart --submit '<json>'\n");
983
1103
  return;
984
1104
  }
985
1105
 
@@ -1141,7 +1261,7 @@ https://github.com/onthegonow/a2a_calling`;
1141
1261
  console.log('Step 2 of 4: Configure disclosure topics\n');
1142
1262
  console.log(buildExtractionPrompt());
1143
1263
  console.log('\n Read your workspace files, extract topics, and present to your owner for review.');
1144
- console.log(" Then submit with: a2a onboard --submit '<json>'\n");
1264
+ console.log(" Then submit with: a2a quickstart --submit '<json>'\n");
1145
1265
  },
1146
1266
 
1147
1267
 
@@ -1391,114 +1511,7 @@ https://github.com/onthegonow/a2a_calling`;
1391
1511
  },
1392
1512
 
1393
1513
  onboard: async (args) => {
1394
- const { A2AConfig } = require('../src/lib/config');
1395
- const {
1396
- validateDisclosureSubmission,
1397
- saveManifest,
1398
- MANIFEST_FILE
1399
- } = require('../src/lib/disclosure');
1400
- const config = new A2AConfig();
1401
-
1402
- // ── Submit mode: agent sends structured JSON ──────────────
1403
- const submitRaw = args.flags.submit;
1404
- if (submitRaw) {
1405
- let parsed;
1406
- try {
1407
- parsed = JSON.parse(String(submitRaw));
1408
- } catch (e) {
1409
- console.error('\nInvalid JSON in --submit flag.');
1410
- console.error(` Parse error: ${e.message}\n`);
1411
- process.exit(1);
1412
- }
1413
-
1414
- const result = validateDisclosureSubmission(parsed);
1415
- if (!result.valid) {
1416
- console.error('\nDisclosure submission validation failed:\n');
1417
- result.errors.forEach(err => console.error(` - ${err}`));
1418
- console.error("\nFix the errors above and resubmit with: a2a onboard --submit '<json>'\n");
1419
- process.exit(1);
1420
- }
1421
-
1422
- saveManifest(result.manifest);
1423
- console.log('\nStep 3 of 4: Disclosure manifest saved.');
1424
- console.log(` Manifest: ${MANIFEST_FILE}`);
1425
-
1426
- // Sync tier config from manifest
1427
- const manifest = result.manifest;
1428
- function flattenTopics(sections) {
1429
- const out = [];
1430
- for (const section of sections) {
1431
- for (const item of section) {
1432
- const t = String(item && item.topic || '').trim();
1433
- if (t && !out.includes(t)) out.push(t);
1434
- }
1435
- }
1436
- return out;
1437
- }
1438
-
1439
- try {
1440
- config.setTier('public', {
1441
- topics: flattenTopics([manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect]),
1442
- disclosure: 'public'
1443
- });
1444
- config.setTier('friends', {
1445
- topics: flattenTopics([
1446
- manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect,
1447
- manifest.topics.friends.lead_with, manifest.topics.friends.discuss_freely, manifest.topics.friends.deflect
1448
- ]),
1449
- disclosure: 'minimal'
1450
- });
1451
- config.setTier('family', {
1452
- topics: flattenTopics([
1453
- manifest.topics.public.lead_with, manifest.topics.public.discuss_freely, manifest.topics.public.deflect,
1454
- manifest.topics.friends.lead_with, manifest.topics.friends.discuss_freely, manifest.topics.friends.deflect,
1455
- manifest.topics.family.lead_with, manifest.topics.family.discuss_freely, manifest.topics.family.deflect
1456
- ]),
1457
- disclosure: 'minimal'
1458
- });
1459
- } catch (err) {
1460
- console.error(` Warning: could not sync tier config: ${err.message}`);
1461
- }
1462
-
1463
- // If already onboarded, this is a topic update — no invite generation needed
1464
- if (config.isOnboarded()) {
1465
- console.log('\nDisclosure topics updated. Your agent will use these on the next inbound call.\n');
1466
- return;
1467
- }
1468
-
1469
- // ── Step 4 of 4: Generate first invite and complete ─────
1470
- console.log('\nStep 4 of 4: Generating your first invite...\n');
1471
-
1472
- const agentName = args.flags.name || config.getAgent().name || process.env.A2A_AGENT_NAME || 'my-agent';
1473
- const hostname = config.getAgent().hostname || process.env.A2A_HOSTNAME || 'localhost';
1474
- if (args.flags.name) config.setAgent({ name: agentName });
1475
-
1476
- const publicTopics = flattenTopics([
1477
- manifest.topics.public.lead_with,
1478
- manifest.topics.public.discuss_freely
1479
- ]);
1480
-
1481
- const { token } = store.create({
1482
- name: agentName,
1483
- owner: agentName,
1484
- permissions: 'public',
1485
- disclosure: 'minimal',
1486
- expires: 'never',
1487
- maxCalls: null,
1488
- allowedTopics: publicTopics,
1489
- allowedGoals: ['grow-network', 'find-collaborators', 'build-in-public'],
1490
- notify: 'all'
1491
- });
1492
-
1493
- const inviteUrl = `a2a://${hostname}/${token}`;
1494
- console.log(` Invite URL: ${inviteUrl}`);
1495
- console.log(' Share this invite to let other agents call you.\n');
1496
-
1497
- config.completeOnboarding();
1498
- console.log('Onboarding complete.\n');
1499
- console.log(` Config: ${CONFIG_PATH}`);
1500
- console.log(` Disclosure: ${MANIFEST_FILE}`);
1501
- console.log(` Invite: ${inviteUrl}\n`);
1514
+ if (await handleDisclosureSubmit(args, 'onboard')) {
1502
1515
  return;
1503
1516
  }
1504
1517
 
@@ -1571,6 +1584,7 @@ Server:
1571
1584
 
1572
1585
  quickstart Set up A2A server and start onboarding
1573
1586
  --port, -p Preferred server port (default: 80, fallback: 3001+)
1587
+ --submit '<json>' Submit disclosure JSON (Step 3 of onboarding)
1574
1588
  --force Reset onboarding and re-run from scratch
1575
1589
 
1576
1590
  onboard Submit disclosure topics or resume quickstart
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a2acalling",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "description": "Agent-to-agent calling for OpenClaw - A2A agent communication",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -2,8 +2,25 @@
2
2
 
3
3
  // Only run for global installs; skip in CI, dev, and Docker builds.
4
4
  if (process.env.CI || process.env.CONTINUOUS_INTEGRATION) process.exit(0);
5
+ if (process.env.DOCKER) process.exit(0);
5
6
  if (process.env.npm_config_global !== 'true') process.exit(0);
6
7
 
7
- console.log('\n a2acalling installed successfully.\n');
8
- console.log(' To get started, run:\n');
9
- console.log(' a2a quickstart\n');
8
+ const { spawnSync } = require('child_process');
9
+
10
+ // Launch quickstart directly — stdio: 'inherit' forces foreground output
11
+ // even when npm v10+ suppresses postinstall stdout by default.
12
+ const result = spawnSync('a2a', ['quickstart'], {
13
+ stdio: 'inherit',
14
+ shell: true,
15
+ cwd: process.env.HOME || process.cwd()
16
+ });
17
+
18
+ if (result.error || result.status === 127) {
19
+ // spawn error or shell couldn't find the a2a binary
20
+ const reason = result.error ? result.error.message : 'a2a not found in PATH';
21
+ console.error('Could not auto-launch onboarding:', reason);
22
+ console.log('\nRun manually: a2a quickstart');
23
+ process.exit(0); // don't fail the install
24
+ }
25
+
26
+ process.exit(result.status || 0);