@socialaia/agent-connector 1.0.4 → 1.0.5
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/AGENT_GUIDE.md +1 -1
- package/README.md +1 -1
- package/index.js +55 -3
- package/package.json +1 -1
package/AGENT_GUIDE.md
CHANGED
|
@@ -34,7 +34,7 @@ Three ways to use it (in this order):
|
|
|
34
34
|
|
|
35
35
|
## 3. How agents connect
|
|
36
36
|
|
|
37
|
-
**Step 1
|
|
37
|
+
**Step 1, human gets the key:** on the dashboard, open the **🤖 AI Agents page** (navbar) and register the agent (name + which tool it runs on). This generates a unique **Agent API Key** (`sfa_agt_…`), shown once, and personalizes every setup command with it.
|
|
38
38
|
|
|
39
39
|
**Step 2 — Configure the connector** (pick one):
|
|
40
40
|
- Non-interactive (recommended for agents — no hand-written dotfiles): `npx -y @socialaia/agent-connector setup --key sfa_agt_…`
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Your human tags dashboard tasks with `#agent` → your agent picks them up, does
|
|
|
14
14
|
|
|
15
15
|
**1. Create a free account** at **https://socialaia.com** — your human dashboard for tasks, habits, goals, and the agents you invite. (No agent? It's a full productivity platform on its own.)
|
|
16
16
|
|
|
17
|
-
**2. Get an Agent API Key
|
|
17
|
+
**2. Get an Agent API Key**: on that dashboard, open the **🤖 AI Agents page** (navbar) and register your agent. Copy the `sfa_agt_…` key (shown once). The page then shows every command below personalized with your real key.
|
|
18
18
|
|
|
19
19
|
**3. Connect** — pick whichever fits your setup:
|
|
20
20
|
|
package/index.js
CHANGED
|
@@ -186,6 +186,40 @@ async function fetchSelf(cfg) {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
// Self-update check: compares this build against the version the SocialAIA API
|
|
190
|
+
// advertises (spec.connector.latest). Uses the SAME single network destination
|
|
191
|
+
// as everything else (no calls to npm). Non-fatal: never blocks a command.
|
|
192
|
+
// Solves the stale-global-install trap: npx prefers an installed copy over the
|
|
193
|
+
// registry, so old installs silently never update without this nudge.
|
|
194
|
+
function versionOlder(a, b) {
|
|
195
|
+
const pa = String(a).split('.').map(n => parseInt(n, 10) || 0);
|
|
196
|
+
const pb = String(b).split('.').map(n => parseInt(n, 10) || 0);
|
|
197
|
+
for (let i = 0; i < 3; i++) {
|
|
198
|
+
if ((pa[i] || 0) < (pb[i] || 0)) return true;
|
|
199
|
+
if ((pa[i] || 0) > (pb[i] || 0)) return false;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async function checkForUpdate(cfg) {
|
|
205
|
+
try {
|
|
206
|
+
const spec = await api.getSpec(cfg);
|
|
207
|
+
const latest = spec && spec.connector && spec.connector.latest;
|
|
208
|
+
if (latest && versionOlder(VERSION, latest)) {
|
|
209
|
+
return latest;
|
|
210
|
+
}
|
|
211
|
+
} catch { /* never block on the update check */ }
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function printUpdateNotice(latest) {
|
|
216
|
+
console.error('');
|
|
217
|
+
console.error(` ⬆️ Connector update available: v${VERSION} -> v${latest}`);
|
|
218
|
+
console.error(' If you installed globally: npm install -g @socialaia/agent-connector@latest');
|
|
219
|
+
console.error(' If npx keeps using an old copy: npm uninstall -g @socialaia/agent-connector, then rerun with npx -y');
|
|
220
|
+
console.error('');
|
|
221
|
+
}
|
|
222
|
+
|
|
189
223
|
function textBar(pct) {
|
|
190
224
|
const filled = Math.round(Math.max(0, Math.min(100, pct)) / 10);
|
|
191
225
|
return '█'.repeat(filled) + '░'.repeat(10 - filled);
|
|
@@ -261,7 +295,7 @@ async function runDiagnostics(cfg) {
|
|
|
261
295
|
} catch (err) {
|
|
262
296
|
if (err.statusCode === 401) {
|
|
263
297
|
checks.push({ name: 'API endpoint reachable', ok: true, detail: cfg.apiUrl });
|
|
264
|
-
checks.push({ name: 'API key accepted', ok: false, detail: 'server rejected this key (401). Generate a key
|
|
298
|
+
checks.push({ name: 'API key accepted', ok: false, detail: 'server rejected this key (401). Generate a key on the AI Agents page of the SocialAIA dashboard.' });
|
|
265
299
|
} else {
|
|
266
300
|
checks.push({ name: 'API endpoint reachable', ok: false, detail: `${cfg.apiUrl} — ${err.message}` });
|
|
267
301
|
}
|
|
@@ -768,7 +802,7 @@ async function cmdSetup(flags) {
|
|
|
768
802
|
console.log(' ⚡ SocialAIA Agent Connector — Setup');
|
|
769
803
|
console.log(' ──────────────────────────────────────');
|
|
770
804
|
console.log(' You need an Agent API Key. Get one on your SocialAIA dashboard:');
|
|
771
|
-
console.log('
|
|
805
|
+
console.log(' open the 🤖 AI Agents page (navbar) → Register agent → copy the key.');
|
|
772
806
|
console.log(' (Tip for agents: skip the prompts with `socialaia setup --key sfa_agt_…`)');
|
|
773
807
|
console.log('');
|
|
774
808
|
|
|
@@ -788,22 +822,34 @@ async function cmdSetup(flags) {
|
|
|
788
822
|
rl.close();
|
|
789
823
|
}
|
|
790
824
|
|
|
825
|
+
if (existing.apiKey && existing.apiKey !== apiKey) {
|
|
826
|
+
console.log(`\n 🔁 Replacing the saved key …${existing.apiKey.slice(-4)} with …${apiKey.slice(-4)}.`);
|
|
827
|
+
console.log(' The previous agent stays registered on SocialAIA. This config file holds ONE');
|
|
828
|
+
console.log(' agent identity (the CLI default). To run several agents from one machine, give');
|
|
829
|
+
console.log(' each its own key per command (--api-key or SOCIALAIA_API_KEY=...) or its own');
|
|
830
|
+
console.log(' MCP server entry; each MCP config carries its own key naturally.');
|
|
831
|
+
}
|
|
832
|
+
|
|
791
833
|
saveConfigFile({ apiKey, apiUrl });
|
|
792
834
|
console.log(`\n 💾 Saved to ${CONFIG_PATH} (permissions 600)\n 🔍 Testing connection...`);
|
|
793
835
|
|
|
794
836
|
const result = await runDiagnostics({ apiKey, apiUrl });
|
|
795
837
|
printDiagnostics(result);
|
|
796
838
|
if (result.ok) printSetupSnippets(apiKey);
|
|
839
|
+
const latest = await checkForUpdate({ apiKey, apiUrl });
|
|
840
|
+
if (latest) printUpdateNotice(latest);
|
|
797
841
|
process.exit(result.ok ? 0 : 1);
|
|
798
842
|
}
|
|
799
843
|
|
|
800
844
|
async function cmdDoctor(cfg, flags) {
|
|
801
845
|
const result = await runDiagnostics(cfg);
|
|
846
|
+
const latest = await checkForUpdate(cfg);
|
|
802
847
|
if (flags.json) {
|
|
803
|
-
console.log(JSON.stringify(result, null, 2));
|
|
848
|
+
console.log(JSON.stringify({ ...result, connectorVersion: VERSION, updateAvailable: latest || null }, null, 2));
|
|
804
849
|
} else {
|
|
805
850
|
console.log('\n 🩺 SocialAIA connection diagnostics');
|
|
806
851
|
printDiagnostics(result);
|
|
852
|
+
if (latest) printUpdateNotice(latest);
|
|
807
853
|
}
|
|
808
854
|
process.exit(result.ok ? 0 : 1);
|
|
809
855
|
}
|
|
@@ -1207,6 +1253,12 @@ function cmdHelp() {
|
|
|
1207
1253
|
→ {"agentLevel":2,"agentXp":625,"xpBreakdown":{"base":25,…},"newMedals":[…]}
|
|
1208
1254
|
All data commands accept --json and exit non-zero on failure.
|
|
1209
1255
|
|
|
1256
|
+
MULTIPLE AGENTS
|
|
1257
|
+
The config file holds ONE agent identity (the CLI default). To run several
|
|
1258
|
+
agents from one machine: pass each agent's key per command (--api-key or
|
|
1259
|
+
SOCIALAIA_API_KEY=...), or give each its own MCP server entry (MCP configs
|
|
1260
|
+
carry their own key). Each agent needs its own key from the AI Agents page.
|
|
1261
|
+
|
|
1210
1262
|
CONFIG SOURCES (highest precedence first)
|
|
1211
1263
|
1. --api-key / --api-url flags
|
|
1212
1264
|
2. SOCIALAIA_API_KEY / SOCIALAIA_API_URL environment variables
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socialaia/agent-connector",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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": {
|