openclaw-openviking-setup-helper 0.3.0-beta.4 → 0.3.0-beta.6

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/install.js +70 -13
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -874,8 +874,9 @@ function extractRuntimeConfigFromPluginEntry(entryConfig) {
874
874
  if (typeof entryConfig.apiKey === "string" && entryConfig.apiKey.trim()) {
875
875
  runtime.apiKey = entryConfig.apiKey;
876
876
  }
877
- if (typeof entryConfig.agent_prefix === "string" && entryConfig.agent_prefix.trim()) {
878
- runtime.agent_prefix = entryConfig.agent_prefix.trim();
877
+ const prefix = entryConfig.agent_prefix || entryConfig.agentId;
878
+ if (typeof prefix === "string" && prefix.trim()) {
879
+ runtime.agent_prefix = prefix.trim();
879
880
  }
880
881
  return runtime;
881
882
  }
@@ -1450,20 +1451,26 @@ async function configureOpenClawPlugin({
1450
1451
  // Legacy (memory) plugins still use direct config set
1451
1452
  if (resolvedPluginKind === "memory") {
1452
1453
  if (claimSlot) {
1453
- await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]);
1454
+ try { await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]); } catch (_e) {
1455
+ warn(tr("Could not activate slot for legacy plugin", "无法为旧版插件激活 slot"));
1456
+ }
1454
1457
  }
1455
1458
  const effectiveRuntimeConfig = runtimeConfig || {
1456
1459
  baseUrl: remoteBaseUrl,
1457
1460
  apiKey: remoteApiKey,
1458
1461
  agent_prefix: remoteAgentPrefix,
1459
1462
  };
1460
- await oc(["config", "set", `plugins.entries.${pluginId}.config.baseUrl`, effectiveRuntimeConfig.baseUrl || remoteBaseUrl]);
1463
+ const trySet = async (k, v) => {
1464
+ try { await oc(["config", "set", `plugins.entries.${pluginId}.config.${k}`, v]); }
1465
+ catch (_e) { warn(tr(`Could not set ${k} for legacy plugin`, `无法为旧版插件设置 ${k}`)); }
1466
+ };
1467
+ await trySet("baseUrl", effectiveRuntimeConfig.baseUrl || remoteBaseUrl);
1461
1468
  if (effectiveRuntimeConfig.apiKey) {
1462
- await oc(["config", "set", `plugins.entries.${pluginId}.config.apiKey`, effectiveRuntimeConfig.apiKey]);
1469
+ await trySet("apiKey", effectiveRuntimeConfig.apiKey);
1463
1470
  }
1464
- await oc(["config", "set", `plugins.entries.${pluginId}.config.targetUri`, "viking://user/memories"]);
1465
- await oc(["config", "set", `plugins.entries.${pluginId}.config.autoRecall`, "true", "--json"]);
1466
- await oc(["config", "set", `plugins.entries.${pluginId}.config.autoCapture`, "true", "--json"]);
1471
+ await trySet("targetUri", "viking://user/memories");
1472
+ try { await oc(["config", "set", `plugins.entries.${pluginId}.config.autoRecall`, "true", "--json"]); } catch (_e) { /* optional */ }
1473
+ try { await oc(["config", "set", `plugins.entries.${pluginId}.config.autoCapture`, "true", "--json"]); } catch (_e) { /* optional */ }
1467
1474
  info(tr("OpenClaw plugin configured (legacy mode)", "OpenClaw 插件配置完成(旧版模式)"));
1468
1475
  return;
1469
1476
  }
@@ -1485,6 +1492,9 @@ async function configureOpenClawPlugin({
1485
1492
  if (effectiveRuntimeConfig.apiKey) {
1486
1493
  setupArgs.push("--api-key", effectiveRuntimeConfig.apiKey);
1487
1494
  }
1495
+ if (effectiveRuntimeConfig.agent_prefix) {
1496
+ setupArgs.push("--agent-id", effectiveRuntimeConfig.agent_prefix);
1497
+ }
1488
1498
  if (claimSlot) {
1489
1499
  setupArgs.push("--force-slot");
1490
1500
  }
@@ -1545,17 +1555,64 @@ async function configureOpenClawPlugin({
1545
1555
  `openclaw openviking setup 退出码 ${setupResult.code},回退到直接配置。`,
1546
1556
  ));
1547
1557
  // Fallback: direct config set (for backward compat if setup CLI not available)
1548
- await oc(["config", "set", `plugins.entries.${pluginId}.config.baseUrl`, effectiveRuntimeConfig.baseUrl || remoteBaseUrl]);
1558
+ // Each field is wrapped individually so one schema mismatch does not abort the rest.
1559
+ let fallbackOk = true;
1560
+ const tryConfigSet = async (key, value, altKey) => {
1561
+ try {
1562
+ await oc(["config", "set", `plugins.entries.${pluginId}.config.${key}`, value]);
1563
+ } catch (_e) {
1564
+ if (altKey) {
1565
+ try {
1566
+ await oc(["config", "set", `plugins.entries.${pluginId}.config.${altKey}`, value]);
1567
+ return;
1568
+ } catch (_e2) { /* fall through to warn */ }
1569
+ }
1570
+ fallbackOk = false;
1571
+ warn(tr(
1572
+ `Could not set config field "${key}": schema validation failed (plugin version may not support this field)`,
1573
+ `无法设置配置字段 "${key}":schema 校验失败(插件版本可能不支持此字段)`,
1574
+ ));
1575
+ }
1576
+ };
1577
+
1578
+ await tryConfigSet("baseUrl", effectiveRuntimeConfig.baseUrl || remoteBaseUrl);
1549
1579
  if (effectiveRuntimeConfig.apiKey) {
1550
- await oc(["config", "set", `plugins.entries.${pluginId}.config.apiKey`, effectiveRuntimeConfig.apiKey]);
1580
+ await tryConfigSet("apiKey", effectiveRuntimeConfig.apiKey);
1551
1581
  }
1552
1582
  if (effectiveRuntimeConfig.agent_prefix) {
1553
- await oc(["config", "set", `plugins.entries.${pluginId}.config.agent_prefix`, effectiveRuntimeConfig.agent_prefix]);
1583
+ await tryConfigSet("agent_prefix", effectiveRuntimeConfig.agent_prefix, "agentId");
1554
1584
  }
1555
1585
  if (claimSlot) {
1556
- await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]);
1586
+ try {
1587
+ await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]);
1588
+ } catch (_e) {
1589
+ fallbackOk = false;
1590
+ warn(tr(
1591
+ "Could not activate contextEngine slot",
1592
+ "无法激活 contextEngine slot",
1593
+ ));
1594
+ }
1595
+ }
1596
+ if (fallbackOk) {
1597
+ info(tr("OpenClaw plugin configured (fallback)", "OpenClaw 插件配置完成(回退模式)"));
1598
+ } else {
1599
+ warn(tr(
1600
+ "OpenClaw plugin partially configured (fallback). Some fields could not be set. Run `openclaw openviking setup` to complete configuration.",
1601
+ "OpenClaw 插件部分配置完成(回退模式)。部分字段未能设置,请运行 `openclaw openviking setup` 完善配置。",
1602
+ ));
1603
+ }
1604
+ if (effectiveRuntimeConfig.apiKey) {
1605
+ warn(tr(
1606
+ "Note: Root API key detection, accountId/userId tenant context, and server version compatibility checks are only available via `openclaw openviking setup`. If you are using a root API key, please upgrade the plugin and re-run setup.",
1607
+ "提示:Root API Key 检测、accountId/userId 租户上下文、服务端版本兼容性检查仅在 `openclaw openviking setup` 中可用。如果您使用的是 root API key,请升级插件后重新执行 setup。",
1608
+ ));
1609
+ }
1610
+ if (effectiveRuntimeConfig.apiKey) {
1611
+ info(tr(
1612
+ "Note: If using a root API key, run `openclaw openviking setup` to configure accountId/userId (required for tenant isolation).",
1613
+ "提示:如果使用的是 root API key,请运行 `openclaw openviking setup` 配置 accountId/userId(多租户隔离必需)。",
1614
+ ));
1557
1615
  }
1558
- info(tr("OpenClaw plugin configured (fallback)", "OpenClaw 插件配置完成(回退模式)"));
1559
1616
  } else {
1560
1617
  info(tr("OpenClaw plugin configured", "OpenClaw 插件配置完成"));
1561
1618
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-openviking-setup-helper",
3
- "version": "0.3.0-beta.4",
3
+ "version": "0.3.0-beta.6",
4
4
  "description": "Setup helper for installing OpenViking memory plugin into OpenClaw",
5
5
  "type": "module",
6
6
  "bin": {