limits-openclaw 0.0.9 → 0.0.12

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/README.md CHANGED
@@ -46,10 +46,30 @@ Then register the plugin with OpenClaw:
46
46
 
47
47
  ```bash
48
48
  openclaw plugins install ./node_modules/limits-openclaw
49
- openclaw plugins enable "limits-openclaw"
50
49
  openclaw gateway restart
51
50
  ```
52
51
 
52
+ **Add `limits-openclaw` to the Plugin Allowlist** (required before enabling):
53
+
54
+ **Option A — Dashboard:**
55
+
56
+ 1. Open the OpenClaw dashboard and go to **Config → Plugins → Plugin Allowlist**.
57
+ 2. Click **Add** and type `limits-openclaw`, then save and apply.
58
+
59
+ **Option B — CLI:**
60
+
61
+ ```bash
62
+ current=$(openclaw config get plugins.allow 2>/dev/null | grep -v '^\[.\+\] ')
63
+ updated=$(echo "${current:-[]}" | jq -c '(. // []) + ["limits-openclaw"] | unique')
64
+ openclaw config set plugins.allow "$updated" --json
65
+ ```
66
+
67
+ Then enable the plugin:
68
+
69
+ ```bash
70
+ openclaw plugins enable "limits-openclaw"
71
+ ```
72
+
53
73
  ---
54
74
 
55
75
  ## Quick Start
@@ -1,5 +1,4 @@
1
1
  import { createInterface } from "node:readline";
2
- import { spawn } from "node:child_process";
3
2
  import { dirname, join } from "node:path";
4
3
  import { fileURLToPath } from "node:url";
5
4
  import fs from "node:fs";
@@ -31,6 +30,71 @@ function copySkillToWorkspace() {
31
30
  console.error("\nFailed to copy skill:", err instanceof Error ? err.message : String(err));
32
31
  }
33
32
  }
33
+ function getConfigFilePath() {
34
+ return process.env.OPENCLAW_CONFIG || join(os.homedir(), ".openclaw", "openclaw.json");
35
+ }
36
+ function readConfigFile() {
37
+ try {
38
+ return JSON.parse(fs.readFileSync(getConfigFilePath(), "utf8"));
39
+ }
40
+ catch {
41
+ return {};
42
+ }
43
+ }
44
+ function writeConfigFile(cfg) {
45
+ fs.writeFileSync(getConfigFilePath(), JSON.stringify(cfg, null, 2) + "\n", "utf8");
46
+ }
47
+ function parseConfigPath(path) {
48
+ const segments = [];
49
+ const re = /\[["']([^"']+)["']\]|\.?([^.[\]]+)/g;
50
+ let m;
51
+ while ((m = re.exec(path)) !== null) {
52
+ const seg = m[1] ?? m[2];
53
+ if (seg)
54
+ segments.push(seg);
55
+ }
56
+ return segments;
57
+ }
58
+ function configGet(cfg, path) {
59
+ let cur = cfg;
60
+ for (const seg of parseConfigPath(path)) {
61
+ if (cur == null || typeof cur !== "object")
62
+ return undefined;
63
+ cur = cur[seg];
64
+ }
65
+ return cur;
66
+ }
67
+ function configSet(cfg, path, value) {
68
+ const segments = parseConfigPath(path);
69
+ let cur = cfg;
70
+ for (let i = 0; i < segments.length - 1; i++) {
71
+ const seg = segments[i];
72
+ if (cur[seg] == null || typeof cur[seg] !== "object")
73
+ cur[seg] = {};
74
+ cur = cur[seg];
75
+ }
76
+ cur[segments[segments.length - 1]] = value;
77
+ }
78
+ function runConfigSet(key, jsonValue) {
79
+ const fullKey = `${CONFIG_PREFIX}.${key}`;
80
+ const cfg = readConfigFile();
81
+ configSet(cfg, fullKey, JSON.parse(jsonValue));
82
+ writeConfigFile(cfg);
83
+ console.log(`Updated ${fullKey}.`);
84
+ return Promise.resolve();
85
+ }
86
+ function runConfigGet(fullKey) {
87
+ const cfg = readConfigFile();
88
+ const val = configGet(cfg, fullKey);
89
+ return Promise.resolve(val !== undefined ? JSON.stringify(val) : "");
90
+ }
91
+ function runConfigSetFull(fullKey, jsonValue) {
92
+ const cfg = readConfigFile();
93
+ configSet(cfg, fullKey, JSON.parse(jsonValue));
94
+ writeConfigFile(cfg);
95
+ console.log(`Updated ${fullKey}.`);
96
+ return Promise.resolve();
97
+ }
34
98
  export function ask(rl, question, defaultValue = "") {
35
99
  const prompt = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;
36
100
  return new Promise((resolve) => {
@@ -39,41 +103,8 @@ export function ask(rl, question, defaultValue = "") {
39
103
  });
40
104
  });
41
105
  }
42
- function runConfigSet(key, value) {
43
- return new Promise((resolve, reject) => {
44
- const fullKey = `${CONFIG_PREFIX}.${key}`;
45
- const child = spawn("openclaw", ["config", "set", fullKey, value], {
46
- stdio: "inherit",
47
- shell: true,
48
- });
49
- child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`openclaw config set exited ${code}`)));
50
- child.on("error", reject);
51
- });
52
- }
53
- function runConfigGet(fullKey) {
54
- return new Promise((resolve) => {
55
- const child = spawn("openclaw", ["config", "get", fullKey], {
56
- stdio: ["inherit", "pipe", "inherit"],
57
- shell: true,
58
- });
59
- let out = "";
60
- child.stdout?.on("data", (d) => (out += d.toString()));
61
- child.on("close", () => resolve(out.trim()));
62
- child.on("error", () => resolve(""));
63
- });
64
- }
65
- function runConfigSetFull(fullKey, value) {
66
- return new Promise((resolve, reject) => {
67
- const child = spawn("openclaw", ["config", "set", fullKey, value], {
68
- stdio: "inherit",
69
- shell: true,
70
- });
71
- child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`openclaw config set exited ${code}`)));
72
- child.on("error", reject);
73
- });
74
- }
75
106
  /**
76
- * Run the configure wizard (interactive prompts, then openclaw config set).
107
+ * Run the configure wizard (interactive prompts, then direct config file write).
77
108
  * Call this when the user runs `openclaw limits configure` or after link.
78
109
  */
79
110
  export async function runConfigureWizard() {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "limits-openclaw",
3
- "name": "limits-openclaw",
3
+ "name": "@limits/openclaw ",
4
4
  "description": "Delegates policy enforcement to the Limits platform before and after every tool call. Optional policy-generator tools for creating/updating policies from natural language.",
5
5
  "version": "0.0.8",
6
6
  "main": "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limits-openclaw",
3
- "version": "0.0.9",
3
+ "version": "0.0.12",
4
4
  "description": "Delegates policy enforcement to the Limits platform before and after every tool call.",
5
5
  "keywords": [
6
6
  "openclaw",