openclaw-openviking-setup-helper 0.3.0-beta.5 → 0.3.0-beta.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.
- package/install.js +75 -23
- 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
|
-
|
|
878
|
-
|
|
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
|
}
|
|
@@ -1417,9 +1418,11 @@ async function configureOpenClawPlugin({
|
|
|
1417
1418
|
const pluginSlot = resolvedPluginSlot;
|
|
1418
1419
|
|
|
1419
1420
|
const ocEnv = getOpenClawEnv();
|
|
1421
|
+
const needWorkdirFlag = OPENCLAW_DIR !== DEFAULT_OPENCLAW_DIR;
|
|
1420
1422
|
|
|
1421
1423
|
const oc = async (args) => {
|
|
1422
|
-
const
|
|
1424
|
+
const fullArgs = needWorkdirFlag ? [...args, "--workdir", OPENCLAW_DIR] : args;
|
|
1425
|
+
const result = await runCapture("openclaw", fullArgs, { env: ocEnv, shell: IS_WIN });
|
|
1423
1426
|
if (result.code !== 0) {
|
|
1424
1427
|
const detail = result.err || result.out;
|
|
1425
1428
|
throw new Error(`openclaw ${args.join(" ")} failed (exit code ${result.code})${detail ? `: ${detail}` : ""}`);
|
|
@@ -1450,20 +1453,26 @@ async function configureOpenClawPlugin({
|
|
|
1450
1453
|
// Legacy (memory) plugins still use direct config set
|
|
1451
1454
|
if (resolvedPluginKind === "memory") {
|
|
1452
1455
|
if (claimSlot) {
|
|
1453
|
-
await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]);
|
|
1456
|
+
try { await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]); } catch (_e) {
|
|
1457
|
+
warn(tr("Could not activate slot for legacy plugin", "无法为旧版插件激活 slot"));
|
|
1458
|
+
}
|
|
1454
1459
|
}
|
|
1455
1460
|
const effectiveRuntimeConfig = runtimeConfig || {
|
|
1456
1461
|
baseUrl: remoteBaseUrl,
|
|
1457
1462
|
apiKey: remoteApiKey,
|
|
1458
1463
|
agent_prefix: remoteAgentPrefix,
|
|
1459
1464
|
};
|
|
1460
|
-
|
|
1465
|
+
const trySet = async (k, v) => {
|
|
1466
|
+
try { await oc(["config", "set", `plugins.entries.${pluginId}.config.${k}`, v]); }
|
|
1467
|
+
catch (_e) { warn(tr(`Could not set ${k} for legacy plugin`, `无法为旧版插件设置 ${k}`)); }
|
|
1468
|
+
};
|
|
1469
|
+
await trySet("baseUrl", effectiveRuntimeConfig.baseUrl || remoteBaseUrl);
|
|
1461
1470
|
if (effectiveRuntimeConfig.apiKey) {
|
|
1462
|
-
await
|
|
1471
|
+
await trySet("apiKey", effectiveRuntimeConfig.apiKey);
|
|
1463
1472
|
}
|
|
1464
|
-
await
|
|
1465
|
-
await oc(["config", "set", `plugins.entries.${pluginId}.config.autoRecall`, "true", "--json"]);
|
|
1466
|
-
await oc(["config", "set", `plugins.entries.${pluginId}.config.autoCapture`, "true", "--json"]);
|
|
1473
|
+
await trySet("targetUri", "viking://user/memories");
|
|
1474
|
+
try { await oc(["config", "set", `plugins.entries.${pluginId}.config.autoRecall`, "true", "--json"]); } catch (_e) { /* optional */ }
|
|
1475
|
+
try { await oc(["config", "set", `plugins.entries.${pluginId}.config.autoCapture`, "true", "--json"]); } catch (_e) { /* optional */ }
|
|
1467
1476
|
info(tr("OpenClaw plugin configured (legacy mode)", "OpenClaw 插件配置完成(旧版模式)"));
|
|
1468
1477
|
return;
|
|
1469
1478
|
}
|
|
@@ -1485,6 +1494,9 @@ async function configureOpenClawPlugin({
|
|
|
1485
1494
|
if (effectiveRuntimeConfig.apiKey) {
|
|
1486
1495
|
setupArgs.push("--api-key", effectiveRuntimeConfig.apiKey);
|
|
1487
1496
|
}
|
|
1497
|
+
if (effectiveRuntimeConfig.agent_prefix) {
|
|
1498
|
+
setupArgs.push("--agent-id", effectiveRuntimeConfig.agent_prefix);
|
|
1499
|
+
}
|
|
1488
1500
|
if (claimSlot) {
|
|
1489
1501
|
setupArgs.push("--force-slot");
|
|
1490
1502
|
}
|
|
@@ -1492,6 +1504,10 @@ async function configureOpenClawPlugin({
|
|
|
1492
1504
|
setupArgs.push("--allow-offline");
|
|
1493
1505
|
}
|
|
1494
1506
|
|
|
1507
|
+
if (needWorkdirFlag) {
|
|
1508
|
+
setupArgs.push("--workdir", OPENCLAW_DIR);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1495
1511
|
info(tr(
|
|
1496
1512
|
"Delegating configuration to: openclaw openviking setup --json",
|
|
1497
1513
|
"委托配置给: openclaw openviking setup --json",
|
|
@@ -1545,28 +1561,64 @@ async function configureOpenClawPlugin({
|
|
|
1545
1561
|
`openclaw openviking setup 退出码 ${setupResult.code},回退到直接配置。`,
|
|
1546
1562
|
));
|
|
1547
1563
|
// Fallback: direct config set (for backward compat if setup CLI not available)
|
|
1548
|
-
|
|
1564
|
+
// Each field is wrapped individually so one schema mismatch does not abort the rest.
|
|
1565
|
+
let fallbackOk = true;
|
|
1566
|
+
const tryConfigSet = async (key, value, altKey) => {
|
|
1567
|
+
try {
|
|
1568
|
+
await oc(["config", "set", `plugins.entries.${pluginId}.config.${key}`, value]);
|
|
1569
|
+
} catch (_e) {
|
|
1570
|
+
if (altKey) {
|
|
1571
|
+
try {
|
|
1572
|
+
await oc(["config", "set", `plugins.entries.${pluginId}.config.${altKey}`, value]);
|
|
1573
|
+
return;
|
|
1574
|
+
} catch (_e2) { /* fall through to warn */ }
|
|
1575
|
+
}
|
|
1576
|
+
fallbackOk = false;
|
|
1577
|
+
warn(tr(
|
|
1578
|
+
`Could not set config field "${key}": schema validation failed (plugin version may not support this field)`,
|
|
1579
|
+
`无法设置配置字段 "${key}":schema 校验失败(插件版本可能不支持此字段)`,
|
|
1580
|
+
));
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
await tryConfigSet("baseUrl", effectiveRuntimeConfig.baseUrl || remoteBaseUrl);
|
|
1549
1585
|
if (effectiveRuntimeConfig.apiKey) {
|
|
1550
|
-
await
|
|
1586
|
+
await tryConfigSet("apiKey", effectiveRuntimeConfig.apiKey);
|
|
1551
1587
|
}
|
|
1552
1588
|
if (effectiveRuntimeConfig.agent_prefix) {
|
|
1589
|
+
await tryConfigSet("agent_prefix", effectiveRuntimeConfig.agent_prefix, "agentId");
|
|
1590
|
+
}
|
|
1591
|
+
if (claimSlot) {
|
|
1553
1592
|
try {
|
|
1554
|
-
await oc(["config", "set", `plugins.
|
|
1593
|
+
await oc(["config", "set", `plugins.slots.${pluginSlot}`, pluginId]);
|
|
1555
1594
|
} catch (_e) {
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
`无法设置 agent prefix "${effectiveRuntimeConfig.agent_prefix}":配置 schema 可能不支持此字段`,
|
|
1562
|
-
));
|
|
1563
|
-
}
|
|
1595
|
+
fallbackOk = false;
|
|
1596
|
+
warn(tr(
|
|
1597
|
+
"Could not activate contextEngine slot",
|
|
1598
|
+
"无法激活 contextEngine slot",
|
|
1599
|
+
));
|
|
1564
1600
|
}
|
|
1565
1601
|
}
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1602
|
+
if (fallbackOk) {
|
|
1603
|
+
info(tr("OpenClaw plugin configured (fallback)", "OpenClaw 插件配置完成(回退模式)"));
|
|
1604
|
+
} else {
|
|
1605
|
+
warn(tr(
|
|
1606
|
+
"OpenClaw plugin partially configured (fallback). Some fields could not be set. Run `openclaw openviking setup` to complete configuration.",
|
|
1607
|
+
"OpenClaw 插件部分配置完成(回退模式)。部分字段未能设置,请运行 `openclaw openviking setup` 完善配置。",
|
|
1608
|
+
));
|
|
1609
|
+
}
|
|
1610
|
+
if (effectiveRuntimeConfig.apiKey) {
|
|
1611
|
+
warn(tr(
|
|
1612
|
+
"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.",
|
|
1613
|
+
"提示:Root API Key 检测、accountId/userId 租户上下文、服务端版本兼容性检查仅在 `openclaw openviking setup` 中可用。如果您使用的是 root API key,请升级插件后重新执行 setup。",
|
|
1614
|
+
));
|
|
1615
|
+
}
|
|
1616
|
+
if (effectiveRuntimeConfig.apiKey) {
|
|
1617
|
+
info(tr(
|
|
1618
|
+
"Note: If using a root API key, run `openclaw openviking setup` to configure accountId/userId (required for tenant isolation).",
|
|
1619
|
+
"提示:如果使用的是 root API key,请运行 `openclaw openviking setup` 配置 accountId/userId(多租户隔离必需)。",
|
|
1620
|
+
));
|
|
1568
1621
|
}
|
|
1569
|
-
info(tr("OpenClaw plugin configured (fallback)", "OpenClaw 插件配置完成(回退模式)"));
|
|
1570
1622
|
} else {
|
|
1571
1623
|
info(tr("OpenClaw plugin configured", "OpenClaw 插件配置完成"));
|
|
1572
1624
|
}
|