@socialaia/agent-connector 1.4.4-openclaw.0 → 1.4.4-openclaw.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.
Files changed (2) hide show
  1. package/index.js +50 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1520,6 +1520,42 @@ function runOpenClawCli(binary, args, env = process.env) {
1520
1520
  };
1521
1521
  }
1522
1522
 
1523
+ function evaluateOpenClawModelStatus(commandResult) {
1524
+ let parsed;
1525
+ try { parsed = JSON.parse(String(commandResult?.stdout || '')); }
1526
+ catch {
1527
+ return {
1528
+ ok: false,
1529
+ reason: commandResult?.error
1530
+ ? 'OpenClaw model status could not be executed.'
1531
+ : `OpenClaw model status was not valid JSON${Number.isInteger(commandResult?.status) ? ` (exit ${commandResult.status})` : ''}.`
1532
+ };
1533
+ }
1534
+ const defaultModel = String(parsed.resolvedDefault || parsed.defaultModel || '');
1535
+ if (!defaultModel || !defaultModel.includes('/')) return { ok: false, reason: 'OpenClaw has no resolved default model.' };
1536
+ const defaultProvider = defaultModel.split('/')[0];
1537
+ const auth = parsed.auth && typeof parsed.auth === 'object' ? parsed.auth : {};
1538
+ const missing = Array.isArray(auth.missingProvidersInUse) ? auth.missingProvidersInUse
1539
+ : Array.isArray(parsed.missingProvidersInUse) ? parsed.missingProvidersInUse : [];
1540
+ if (missing.some(item => String(item?.provider || item) === defaultProvider)) {
1541
+ return { ok: false, defaultModel, reason: `The active OpenClaw model provider (${defaultProvider}) has no usable authentication.` };
1542
+ }
1543
+ const unusable = Array.isArray(auth.unusableProfiles) ? auth.unusableProfiles
1544
+ : Array.isArray(parsed.unusableProfiles) ? parsed.unusableProfiles : [];
1545
+ if (unusable.some(item => String(item?.provider || '').toLowerCase() === defaultProvider.toLowerCase())) {
1546
+ return { ok: false, defaultModel, reason: `The active OpenClaw model provider (${defaultProvider}) has an unusable authentication profile.` };
1547
+ }
1548
+ const providerState = (Array.isArray(auth.oauth?.providers) ? auth.oauth.providers : [])
1549
+ .find(item => String(item?.provider || '') === defaultProvider);
1550
+ if (providerState && ['expired', 'missing', 'invalid', 'error'].includes(String(providerState.status || '').toLowerCase())) {
1551
+ return { ok: false, defaultModel, reason: `The active OpenClaw model provider (${defaultProvider}) reports ${providerState.status}.` };
1552
+ }
1553
+ // Older OpenClaw versions make `models status --check` fail when any unused
1554
+ // OAuth profile is expired. Readiness is scoped to the resolved default
1555
+ // provider instead: unrelated stale profiles must not block this runtime.
1556
+ return { ok: true, defaultModel, defaultProvider };
1557
+ }
1558
+
1523
1559
  function requireOpenClawDefaultIdentity(cfg, flags) {
1524
1560
  const saved = readConfigFile();
1525
1561
  if (!saved.apiKey || saved.apiKey !== cfg.apiKey) {
@@ -1550,18 +1586,25 @@ async function cmdOpenClaw(cfg, flags, positional) {
1550
1586
  if (!configured.ok) fail(flags, `OpenClaw MCP configuration failed: ${configured.stderr || configured.error || 'unknown error'}`);
1551
1587
  }
1552
1588
 
1553
- const model = runOpenClawCli(binary, ['models', 'status', '--agent', agent, '--check', '--json']);
1554
- const probe = runOpenClawCli(binary, ['mcp', 'probe', mcpName, '--json']);
1589
+ const model = runOpenClawCli(binary, ['models', 'status', '--agent', agent, '--json']);
1590
+ const modelReadiness = evaluateOpenClawModelStatus(model);
1591
+ // OpenClaw 2026.5.x supports named MCP probes but not the later --json flag.
1592
+ // Exit status is the compatibility contract we need; never return raw probe
1593
+ // output because a host/plugin may include private configuration details.
1594
+ const probe = runOpenClawCli(binary, ['mcp', 'probe', mcpName]);
1555
1595
  const result = {
1556
- ok: model.ok && probe.ok,
1596
+ ok: modelReadiness.ok && probe.ok,
1557
1597
  openclawVersion: versionCheck.stdout || versionCheck.stderr,
1558
1598
  agent,
1559
1599
  mcpServer: mcpName,
1560
1600
  socialaiaRealtime: 'hibernating-websocket-with-d1-gap-fill',
1561
- modelAuth: model.ok ? 'ready' : 'not-ready',
1601
+ modelAuth: modelReadiness.ok ? 'ready' : 'not-ready',
1602
+ defaultModel: modelReadiness.defaultModel,
1562
1603
  mcpProbe: probe.ok ? 'ready' : 'not-ready',
1563
- modelDetail: model.ok ? undefined : (model.stderr || model.stdout || model.error),
1564
- mcpDetail: probe.ok ? undefined : (probe.stderr || probe.stdout || probe.error)
1604
+ modelDetail: modelReadiness.ok ? undefined : modelReadiness.reason,
1605
+ mcpDetail: probe.ok ? undefined
1606
+ : probe.error ? 'OpenClaw MCP probe could not be executed.'
1607
+ : `OpenClaw MCP probe exited with status ${Number.isInteger(probe.status) ? probe.status : 'unknown'}. Run it locally for private diagnostics; do not paste credential-bearing output.`
1565
1608
  };
1566
1609
  if (!result.ok) fail(flags, 'OpenClaw is installed, but model authentication or the SocialAIA MCP probe is not ready.', result);
1567
1610
 
@@ -3189,6 +3232,7 @@ module.exports.__transportTest = {
3189
3232
  describeOpenClawWakeEvent,
3190
3233
  buildOpenClawWakePrompt,
3191
3234
  openClawRuntimeStatePath,
3235
+ evaluateOpenClawModelStatus,
3192
3236
  mcpRealtimeNotification,
3193
3237
  normalizeLoopbackWakeUrl,
3194
3238
  normalizeWakeControllerId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socialaia/agent-connector",
3
- "version": "1.4.4-openclaw.0",
3
+ "version": "1.4.4-openclaw.1",
4
4
  "description": "Official CLI & MCP server that connects AI agents to SocialAIA, the social productivity platform where humans and agents complete tasks, earn XP, and level up together.",
5
5
  "main": "index.js",
6
6
  "bin": {