openclaw-openviking-setup-helper 0.2.7 → 0.2.9

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 +47 -51
  2. package/package.json +2 -2
package/install.js CHANGED
@@ -32,7 +32,7 @@ import { fileURLToPath } from "node:url";
32
32
  const __dirname = dirname(fileURLToPath(import.meta.url));
33
33
 
34
34
  const REPO = process.env.REPO || "volcengine/OpenViking";
35
- const BRANCH = process.env.BRANCH || "publish";
35
+ const BRANCH = process.env.BRANCH || "main";
36
36
  const GH_RAW = `https://raw.githubusercontent.com/${REPO}/${BRANCH}`;
37
37
  const NPM_REGISTRY = process.env.NPM_REGISTRY || "https://registry.npmmirror.com";
38
38
  const PIP_INDEX_URL = process.env.PIP_INDEX_URL || "https://pypi.tuna.tsinghua.edu.cn/simple";
@@ -42,7 +42,7 @@ const HOME = process.env.HOME || process.env.USERPROFILE || "";
42
42
 
43
43
  const DEFAULT_OPENCLAW_DIR = join(HOME, ".openclaw");
44
44
  let OPENCLAW_DIR = DEFAULT_OPENCLAW_DIR;
45
- let PLUGIN_DEST = join(OPENCLAW_DIR, "extensions", "memory-openviking");
45
+ let PLUGIN_DEST = join(OPENCLAW_DIR, "extensions", "openviking");
46
46
 
47
47
  const OPENVIKING_DIR = join(HOME, ".openviking");
48
48
 
@@ -52,19 +52,20 @@ const DEFAULT_VLM_MODEL = "doubao-seed-2-0-pro-260215";
52
52
  const DEFAULT_EMBED_MODEL = "doubao-embedding-vision-251215";
53
53
 
54
54
  const REQUIRED_PLUGIN_FILES = [
55
- "examples/openclaw-memory-plugin/index.ts",
56
- "examples/openclaw-memory-plugin/config.ts",
57
- "examples/openclaw-memory-plugin/openclaw.plugin.json",
58
- "examples/openclaw-memory-plugin/package.json",
59
- "examples/openclaw-memory-plugin/package-lock.json",
60
- "examples/openclaw-memory-plugin/.gitignore",
55
+ "examples/openclaw-plugin/index.ts",
56
+ "examples/openclaw-plugin/context-engine.ts",
57
+ "examples/openclaw-plugin/config.ts",
58
+ "examples/openclaw-plugin/openclaw.plugin.json",
59
+ "examples/openclaw-plugin/package.json",
60
+ "examples/openclaw-plugin/package-lock.json",
61
+ "examples/openclaw-plugin/.gitignore",
61
62
  ];
62
63
 
63
64
  const OPTIONAL_PLUGIN_FILES = [
64
- "examples/openclaw-memory-plugin/client.ts",
65
- "examples/openclaw-memory-plugin/process-manager.ts",
66
- "examples/openclaw-memory-plugin/memory-ranking.ts",
67
- "examples/openclaw-memory-plugin/text-utils.ts",
65
+ "examples/openclaw-plugin/client.ts",
66
+ "examples/openclaw-plugin/process-manager.ts",
67
+ "examples/openclaw-plugin/memory-ranking.ts",
68
+ "examples/openclaw-plugin/text-utils.ts",
68
69
  ];
69
70
 
70
71
  let installYes = process.env.OPENVIKING_INSTALL_YES === "1";
@@ -120,7 +121,7 @@ const OPENVIKING_PIP_SPEC = openvikingVersion ? `openviking==${openvikingVersion
120
121
 
121
122
  function setOpenClawDir(dir) {
122
123
  OPENCLAW_DIR = dir;
123
- PLUGIN_DEST = join(OPENCLAW_DIR, "extensions", "memory-openviking");
124
+ PLUGIN_DEST = join(OPENCLAW_DIR, "extensions", "openviking");
124
125
  }
125
126
 
126
127
  function printHelp() {
@@ -549,6 +550,14 @@ async function configureOvConf() {
549
550
  vectordb: { name: "context", backend: "local", project: "default" },
550
551
  agfs: { port: agfsPortNum, log_level: "warn", backend: "local", timeout: 10, retry_times: 3 },
551
552
  },
553
+ log: {
554
+ level: "WARNING",
555
+ format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
556
+ output: "file",
557
+ rotation: true,
558
+ rotation_days: 3,
559
+ rotation_interval: "midnight",
560
+ },
552
561
  embedding: {
553
562
  dense: {
554
563
  backend: "volcengine",
@@ -619,7 +628,7 @@ async function downloadPlugin() {
619
628
  ...OPTIONAL_PLUGIN_FILES.map((relPath) => ({ relPath, required: false })),
620
629
  ];
621
630
 
622
- info(tr(`Downloading memory-openviking plugin from ${REPO}@${BRANCH}...`, `正在从 ${REPO}@${BRANCH} 下载 memory-openviking 插件...`));
631
+ info(tr(`Downloading openviking plugin from ${REPO}@${BRANCH}...`, `正在从 ${REPO}@${BRANCH} 下载 openviking 插件...`));
623
632
  for (let i = 0; i < files.length; i++) {
624
633
  const file = files[i];
625
634
  await downloadPluginFile(file.relPath, file.required, i + 1, files.length);
@@ -633,51 +642,38 @@ async function downloadPlugin() {
633
642
  async function configureOpenClawPlugin(pluginPath = PLUGIN_DEST) {
634
643
  info(tr("Configuring OpenClaw plugin...", "正在配置 OpenClaw 插件..."));
635
644
 
636
- const configPath = join(OPENCLAW_DIR, "openclaw.json");
637
- let config = {};
638
-
639
- if (existsSync(configPath)) {
640
- try {
641
- const raw = await readFile(configPath, "utf8");
642
- if (raw.trim()) config = JSON.parse(raw);
643
- } catch {
644
- warn(tr("Existing openclaw.json invalid. Rebuilding required sections.", "已有 openclaw.json 非法,将重建相关配置节点。"));
645
- }
645
+ const ocEnv = { ...process.env };
646
+ if (OPENCLAW_DIR !== DEFAULT_OPENCLAW_DIR) {
647
+ ocEnv.OPENCLAW_STATE_DIR = OPENCLAW_DIR;
646
648
  }
647
649
 
648
- if (!config.plugins) config.plugins = {};
649
- if (!config.gateway) config.gateway = {};
650
- if (!config.plugins.slots) config.plugins.slots = {};
651
- if (!config.plugins.load) config.plugins.load = {};
652
- if (!config.plugins.entries) config.plugins.entries = {};
650
+ const oc = (args) => runCapture("openclaw", args, { env: ocEnv, shell: IS_WIN });
653
651
 
654
- const existingPaths = Array.isArray(config.plugins.load.paths) ? config.plugins.load.paths : [];
655
- config.plugins.enabled = true;
656
- config.plugins.allow = ["memory-openviking"];
657
- config.plugins.slots.memory = "memory-openviking";
658
- config.plugins.load.paths = [...new Set([...existingPaths, pluginPath])];
652
+ // Enable plugin (files already deployed to extensions dir by deployPlugin)
653
+ const enableResult = await oc(["plugins", "enable", "openviking"]);
654
+ if (enableResult.code !== 0) throw new Error(`openclaw plugins enable failed (exit code ${enableResult.code})`);
655
+ await oc(["config", "set", "plugins.slots.contextEngine", "openviking"]);
659
656
 
660
- const pluginConfig = {
661
- mode: selectedMode,
662
- targetUri: "viking://user/memories",
663
- autoRecall: true,
664
- autoCapture: true,
665
- };
657
+ // Set gateway mode
658
+ await oc(["config", "set", "gateway.mode", "local"]);
666
659
 
660
+ // Set plugin config for the selected mode
667
661
  if (selectedMode === "local") {
668
- pluginConfig.configPath = join(OPENVIKING_DIR, "ov.conf");
669
- pluginConfig.port = selectedServerPort;
662
+ const ovConfPath = join(OPENVIKING_DIR, "ov.conf");
663
+ await oc(["config", "set", "plugins.entries.openviking.config.mode", "local"]);
664
+ await oc(["config", "set", "plugins.entries.openviking.config.configPath", ovConfPath]);
665
+ await oc(["config", "set", "plugins.entries.openviking.config.port", String(selectedServerPort)]);
670
666
  } else {
671
- pluginConfig.baseUrl = remoteBaseUrl;
672
- if (remoteApiKey) pluginConfig.apiKey = remoteApiKey;
673
- if (remoteAgentId) pluginConfig.agentId = remoteAgentId;
667
+ await oc(["config", "set", "plugins.entries.openviking.config.mode", "remote"]);
668
+ await oc(["config", "set", "plugins.entries.openviking.config.baseUrl", remoteBaseUrl]);
669
+ if (remoteApiKey) {
670
+ await oc(["config", "set", "plugins.entries.openviking.config.apiKey", remoteApiKey]);
671
+ }
672
+ if (remoteAgentId) {
673
+ await oc(["config", "set", "plugins.entries.openviking.config.agentId", remoteAgentId]);
674
+ }
674
675
  }
675
676
 
676
- config.plugins.entries["memory-openviking"] = { config: pluginConfig };
677
- config.gateway.mode = "local";
678
-
679
- await mkdir(OPENCLAW_DIR, { recursive: true });
680
- await writeFile(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
681
677
  info(tr("OpenClaw plugin configured", "OpenClaw 插件配置完成"));
682
678
  }
683
679
 
@@ -767,7 +763,7 @@ async function main() {
767
763
  }
768
764
 
769
765
  let pluginPath;
770
- const localPluginDir = openvikingRepo ? join(openvikingRepo, "examples", "openclaw-memory-plugin") : "";
766
+ const localPluginDir = openvikingRepo ? join(openvikingRepo, "examples", "openclaw-plugin") : "";
771
767
  if (openvikingRepo && existsSync(join(localPluginDir, "index.ts"))) {
772
768
  pluginPath = localPluginDir;
773
769
  info(tr(`Using local plugin from repo: ${pluginPath}`, `使用仓库内插件: ${pluginPath}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-openviking-setup-helper",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Setup helper for installing OpenViking memory plugin into OpenClaw",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/volcengine/OpenViking.git",
24
- "directory": "examples/openclaw-memory-plugin/setup-helper"
24
+ "directory": "examples/openclaw-plugin/setup-helper"
25
25
  },
26
26
  "files": [
27
27
  "install.js"