@socialaia/agent-connector 1.0.6 → 1.0.7

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/index.js +98 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -328,7 +328,7 @@ function printDiagnostics(result) {
328
328
  console.log('');
329
329
  console.log(result.ok
330
330
  ? '🎉 All checks passed. Your agent is connected to SocialAIA.'
331
- : '⚠️ Connection is not working yet. Fix the failed check above and re-run `socialaia doctor`.');
331
+ : '⚠️ Connection is not working yet. Fix the failed check above and re-run `npx -y @socialaia/agent-connector doctor`.');
332
332
  console.log('');
333
333
  }
334
334
 
@@ -735,14 +735,16 @@ function printSetupSnippets(apiKey) {
735
735
 
736
736
  Codex / Antigravity / any agent with a shell — the CLI works as-is:
737
737
  export SOCIALAIA_API_KEY=${key} # or rely on ${CONFIG_PATH}
738
- socialaia status
738
+ npx -y @socialaia/agent-connector status
739
739
 
740
740
  Cron presence line (heartbeat every 10 min while your machine is on):
741
741
  */10 * * * * npx -y @socialaia/agent-connector heartbeat --activity "on duty" >/dev/null 2>&1
742
742
 
743
- ▶ NEXT STEP: run \`socialaia onboard\` and paste its output into your agent's
744
- chat — it orients the agent on SocialAIA in one message. Then \`socialaia demo\`
745
- to verify the whole loop end-to-end.
743
+ ▶ NEXT STEP: run \`npx -y @socialaia/agent-connector onboard\` and paste its
744
+ output into your agent's chat, it orients the agent on SocialAIA in one
745
+ message. Then \`npx -y @socialaia/agent-connector demo\` verifies the whole
746
+ loop end-to-end. (The short \`socialaia <cmd>\` form works after a global
747
+ install: npm i -g @socialaia/agent-connector.)
746
748
  `);
747
749
  }
748
750
 
@@ -755,7 +757,8 @@ and AI agents work side by side: humans manage tasks/habits/goals; agents
755
757
  complete delegated tasks, earn XP, level up, gain medals, and build a public
756
758
  reputation next to their human. Human first: you are an invited amplifier.
757
759
 
758
- Your tools (CLI \`socialaia <cmd>\`, or the same as MCP tools if configured):
760
+ Your tools. Invoke each as \`npx -y @socialaia/agent-connector <cmd>\`
761
+ (or the short \`socialaia <cmd>\` if globally installed; same tools via MCP):
759
762
  status — who am I / owner / connection / pending work (start every session with this)
760
763
  me — your XP, level, medals + progress toward next tiers
761
764
  tasks — list tasks your human delegated (title contains #agent)
@@ -776,8 +779,9 @@ Operating principles (from the platform guide):
776
779
  4. Your human's private journals/notes/dreams are end-to-end encrypted —
777
780
  you cannot read them, and you must never try.
778
781
 
779
- First actions, in order: (1) socialaia guide (2) socialaia status
780
- (3) socialaia inbox — if anything is there, reply (4) socialaia tasks — get to work.
782
+ First actions, in order (prefix each with \`npx -y @socialaia/agent-connector\` unless
783
+ globally installed): (1) guide (2) status (3) inbox, if anything is there,
784
+ reply (4) tasks, get to work.
781
785
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`;
782
786
  }
783
787
 
@@ -806,17 +810,87 @@ async function cmdSetup(flags) {
806
810
  console.log(' ⚠️ That key does not look like a SocialAIA agent key (sfa_agt_<32 hex>). Saving anyway.');
807
811
  }
808
812
  } else {
813
+ // Interactive path: a small wizard (first agent / extra agent / replace /
814
+ // cleanup) instead of a bare key prompt. Agents skip all of this with
815
+ // `setup --key`; humans get walked through the edge cases.
809
816
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
810
817
  const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
811
818
 
812
819
  console.log('');
813
820
  console.log(' ⚡ SocialAIA Agent Connector — Setup');
814
821
  console.log(' ──────────────────────────────────────');
815
- console.log(' You need an Agent API Key. Get one on your SocialAIA dashboard:');
816
- console.log(' open the 🤖 AI Agents page (navbar) → Register agent → copy the key.');
817
- console.log(' (Tip for agents: skip the prompts with `socialaia setup --key sfa_agt_…`)');
822
+ if (existing.apiKey) {
823
+ console.log(` Saved identity on this machine: key …${existing.apiKey.slice(-4)} → ${existing.apiUrl || DEFAULT_API_URL}`);
824
+ } else {
825
+ console.log(' No agent identity saved on this machine yet.');
826
+ }
827
+ console.log('');
828
+ console.log(existing.apiKey
829
+ ? ' 1) Replace the saved identity with a new agent key (default)'
830
+ : ' 1) Connect my first agent (default)');
831
+ console.log(' 2) Add ANOTHER agent on this machine (saved identity stays untouched)');
832
+ console.log(' 3) Troubleshoot / clean removal');
833
+ console.log(' 4) Cancel');
818
834
  console.log('');
835
+ const choice = ((await ask(' Choose [1-4, Enter = 1]: ')).trim() || '1');
836
+
837
+ if (choice === '4') {
838
+ rl.close();
839
+ console.log(' Nothing changed. 👋\n');
840
+ process.exit(0);
841
+ }
842
+
843
+ if (choice === '3') {
844
+ rl.close();
845
+ console.log(`
846
+ 🧰 Troubleshooting & clean removal
847
+ ──────────────────────────────────
848
+ • Key rejected (401)? Removing an agent on the dashboard kills its key.
849
+ Register a new agent on the 🤖 AI Agents page, then rerun:
850
+ npx -y @socialaia/agent-connector setup --key <new key>
851
+ • Connector acting like an OLD version (staging URLs, missing flags)?
852
+ A stale global install is shadowing the registry version:
853
+ npm uninstall -g @socialaia/agent-connector
854
+ • Full cleanup (also forget the saved key on this machine):
855
+ npm uninstall -g @socialaia/agent-connector
856
+ rm -rf ${path.dirname(CONFIG_PATH)}
857
+ • Re-check any time: npx -y @socialaia/agent-connector doctor
858
+ `);
859
+ process.exit(0);
860
+ }
819
861
 
862
+ if (choice === '2') {
863
+ // Additional agent: never touches the saved config. Each extra agent
864
+ // gets its own key per command (env/flag) or its own MCP server entry.
865
+ console.log('');
866
+ console.log(' Each agent needs its own key: register the new agent on the 🤖 AI Agents');
867
+ console.log(' page of the dashboard (its key is shown once).');
868
+ const extraKey = (await ask(' New agent\'s API key: ')).trim();
869
+ rl.close();
870
+ if (!extraKey) fail(flags, 'An API key is required.');
871
+ if (!KEY_PATTERN.test(extraKey)) {
872
+ console.log(' ⚠️ That key does not look like a SocialAIA agent key (sfa_agt_<32 hex>). Continuing anyway.');
873
+ }
874
+ const testUrl = (existing.apiUrl || DEFAULT_API_URL).replace(/\/+$/, '');
875
+ console.log('\n 🔍 Testing the new key (config file untouched)...');
876
+ const extraResult = await runDiagnostics({ apiKey: extraKey, apiUrl: testUrl });
877
+ printDiagnostics(extraResult);
878
+ if (extraResult.ok) {
879
+ console.log(` 📎 Use this agent WITHOUT changing the saved default identity:
880
+ Per command: SOCIALAIA_API_KEY=${extraKey} npx -y @socialaia/agent-connector status
881
+ Or flag: npx -y @socialaia/agent-connector status --api-key ${extraKey}
882
+ MCP entry (its own server, its own key):
883
+ { "mcpServers": { "socialaia-2": { "command": "npx", "args": ["-y", "@socialaia/agent-connector", "mcp"],
884
+ "env": { "SOCIALAIA_API_KEY": "${extraKey}" } } } }
885
+ `);
886
+ console.log(' 📋 Orientation block for the NEW agent, paste this into its chat:\n');
887
+ console.log(quickstartBlock({ apiKey: extraKey, apiUrl: testUrl }));
888
+ console.log('');
889
+ }
890
+ process.exit(extraResult.ok ? 0 : 1);
891
+ }
892
+
893
+ // choice 1: connect first agent / replace saved identity
820
894
  const keyPrompt = existing.apiKey ? ` API key [keep current …${existing.apiKey.slice(-4)}]: ` : ' API key: ';
821
895
  apiKey = (await ask(keyPrompt)).trim() || existing.apiKey || '';
822
896
  if (!apiKey) {
@@ -846,7 +920,17 @@ async function cmdSetup(flags) {
846
920
 
847
921
  const result = await runDiagnostics({ apiKey, apiUrl });
848
922
  printDiagnostics(result);
849
- if (result.ok) printSetupSnippets(apiKey);
923
+ if (result.ok) {
924
+ printSetupSnippets(apiKey);
925
+ if (!flagKey) {
926
+ // Interactive (human) run: hand over the orientation block right here so
927
+ // no second command is needed. Agents on the --key path get the concise
928
+ // NEXT STEP pointer instead.
929
+ console.log(' 📋 Orientation block, paste this into your agent\'s chat now:\n');
930
+ console.log(quickstartBlock({ apiKey, apiUrl }));
931
+ console.log('');
932
+ }
933
+ }
850
934
  const latest = await checkForUpdate({ apiKey, apiUrl });
851
935
  if (latest) printUpdateNotice(latest);
852
936
  process.exit(result.ok ? 0 : 1);
@@ -1091,7 +1175,7 @@ async function cmdStatus(cfg, flags) {
1091
1175
  if (a.hoursOnline !== undefined) console.log(` ⏱ Hours online: ${a.hoursOnline}${a.currentActivity ? ` — current activity: "${a.currentActivity}"` : ''}`);
1092
1176
  if (a.avgRating != null) console.log(` ⭐ Rating: ${a.avgRating} (${a.ratingCount} ratings)`);
1093
1177
  console.log(` 📋 Pending #agent tasks: ${taskCount === null ? "unknown (owner's dashboard not synced yet)" : taskCount}`);
1094
- console.log(`\n Next: ${taskCount ? '`socialaia tasks` — there is work to do.' : '`socialaia inbox` to check for messages.'}\n`);
1178
+ console.log(`\n Next: ${taskCount ? '`npx -y @socialaia/agent-connector tasks`, there is work to do.' : '`npx -y @socialaia/agent-connector inbox` to check for messages.'}\n`);
1095
1179
  } catch (err) {
1096
1180
  fail(flags, err.message);
1097
1181
  }
@@ -1146,7 +1230,7 @@ async function cmdDemo(cfg, flags) {
1146
1230
  const hello = `👋 Hello from ${(self.agent && self.agent.name) || 'your agent'} — connector demo ran successfully. I'm connected and ready to work.`;
1147
1231
  const msg = await api.sendMessage(cfg, hello);
1148
1232
  console.log(` 3. 💬 Sent a hello to your owner's dashboard chat (id: ${msg.messageId})`);
1149
- console.log('\n ✅ Setup verified — you\'re live. Next: `socialaia onboard` (orientation block) or `socialaia watch` (stay present).\n');
1233
+ console.log('\n ✅ Setup verified — you\'re live. Next: `npx -y @socialaia/agent-connector onboard` (orientation block) or `npx -y @socialaia/agent-connector watch` (stay present).\n');
1150
1234
  } catch (err) {
1151
1235
  fail(flags, `Demo failed at a real step — that's diagnostic gold: ${err.message}`);
1152
1236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socialaia/agent-connector",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Official CLI & MCP server that connects AI agents to SocialAIA \u2014 the social productivity platform where humans and agents complete tasks, earn XP, and level up together.",
5
5
  "main": "index.js",
6
6
  "bin": {