@ory/openclaw 1.9.2 → 1.10.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.
- package/README.md +76 -11
- package/dist/cli/assets.d.ts +13 -8
- package/dist/cli/assets.js +26 -73
- package/dist/cli/installer.d.ts +53 -0
- package/dist/cli/installer.js +249 -0
- package/dist/cli/main.d.ts +7 -4
- package/dist/cli/main.js +66 -164
- package/dist/cli/openclaw-config.d.ts +40 -0
- package/dist/cli/openclaw-config.js +125 -0
- package/dist/cli/plugin-config.d.ts +32 -5
- package/dist/cli/plugin-config.js +118 -10
- package/dist/cli/setup.d.ts +4 -2
- package/dist/cli/setup.js +39 -51
- package/dist/plugin.d.ts +10 -0
- package/dist/plugin.js +166 -56
- package/dist/types.d.ts +80 -21
- package/openclaw.plugin.json +5 -2
- package/package.json +13 -2
package/dist/cli/main.js
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* Main CLI for @ory/openclaw.
|
|
5
5
|
*
|
|
6
6
|
* Usage:
|
|
7
|
-
* npx ory-openclaw install
|
|
8
|
-
* npx ory-openclaw uninstall
|
|
9
|
-
* npx ory-openclaw configure
|
|
10
|
-
* npx ory-openclaw status
|
|
7
|
+
* npx ory-openclaw install Register the plugin in OpenClaw's config
|
|
8
|
+
* npx ory-openclaw uninstall Remove the plugin from OpenClaw's config
|
|
9
|
+
* npx ory-openclaw configure Set or view Ory project URL and API key
|
|
10
|
+
* npx ory-openclaw status Show plugin status
|
|
11
|
+
*
|
|
12
|
+
* OpenClaw's config is `OPENCLAW_CONFIG_PATH`, else
|
|
13
|
+
* `$OPENCLAW_STATE_DIR/openclaw.json`, else `~/.openclaw/openclaw.json`.
|
|
11
14
|
*/
|
|
12
15
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
16
|
if (k2 === undefined) k2 = k;
|
|
@@ -44,174 +47,58 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
47
|
})();
|
|
45
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
49
|
const path = __importStar(require("node:path"));
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const assets_js_1 = require("./assets.js");
|
|
50
|
+
const cli_1 = require("@ory/argus/cli");
|
|
51
|
+
const openclaw_config_js_1 = require("./openclaw-config.js");
|
|
50
52
|
const plugin_config_js_1 = require("./plugin-config.js");
|
|
51
|
-
const
|
|
53
|
+
const installer_js_1 = require("./installer.js");
|
|
52
54
|
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if ((0, argus_1.shouldPrintHelp)(command, args))
|
|
59
|
-
return help();
|
|
60
|
-
switch (command) {
|
|
61
|
-
case "install":
|
|
62
|
-
if (args.includes("--print")) {
|
|
63
|
-
process.argv = ["node", "setup.js", ...args];
|
|
64
|
-
require("./setup.js");
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
(0, argus_1.beginDeferNextSteps)();
|
|
68
|
-
install(args);
|
|
69
|
-
(0, argus_1.runPostInstall)("ory-openclaw", "openclaw", args).then(() => process.exit(0), (err) => {
|
|
70
|
-
console.error(err.message ?? err);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
});
|
|
73
|
-
break;
|
|
74
|
-
case "uninstall":
|
|
75
|
-
uninstall(args);
|
|
76
|
-
(0, argus_1.clearCredentialsForUninstall)({
|
|
77
|
-
harness: "openclaw",
|
|
78
|
-
purge: args.includes("--purge"),
|
|
79
|
-
}).then(() => process.exit(0), (err) => {
|
|
80
|
-
console.error(err.message ?? err);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
});
|
|
83
|
-
break;
|
|
84
|
-
case "configure":
|
|
85
|
-
(0, argus_1.runConfigureCommand)("ory-openclaw", args);
|
|
86
|
-
break;
|
|
87
|
-
case "agent":
|
|
88
|
-
(0, argus_1.runAgentCommand)("ory-openclaw", "openclaw", args).then((code) => process.exit(code), (err) => {
|
|
89
|
-
console.error(err.message ?? err);
|
|
90
|
-
process.exit(1);
|
|
91
|
-
});
|
|
92
|
-
break;
|
|
93
|
-
case "permissions":
|
|
94
|
-
(0, argus_1.runPermissionsCommand)("ory-openclaw", "openclaw", args).then((code) => process.exit(code), (err) => {
|
|
95
|
-
console.error(err.message ?? err);
|
|
96
|
-
process.exit(1);
|
|
97
|
-
});
|
|
98
|
-
break;
|
|
99
|
-
case "status":
|
|
100
|
-
status(args).then(() => process.exit(0), (err) => {
|
|
101
|
-
console.error(err.message ?? err);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
});
|
|
104
|
-
break;
|
|
105
|
-
case "watch":
|
|
106
|
-
(0, argus_1.runWatchCommand)("ory-openclaw", "openclaw", args).then((code) => process.exit(code), (err) => { console.error(err.message ?? err); process.exit(1); });
|
|
107
|
-
break;
|
|
108
|
-
case "local":
|
|
109
|
-
(0, argus_1.runLocalCommand)("ory-openclaw", args).catch((err) => {
|
|
110
|
-
console.error(err.message ?? err);
|
|
111
|
-
process.exit(1);
|
|
112
|
-
});
|
|
113
|
-
break;
|
|
114
|
-
case "version":
|
|
115
|
-
case "--version":
|
|
116
|
-
case "-v":
|
|
117
|
-
process.exit((0, argus_1.runVersionCommand)("ory-openclaw", args, { packageRoot: PACKAGE_ROOT }));
|
|
118
|
-
break;
|
|
119
|
-
case "help":
|
|
120
|
-
case "--help":
|
|
121
|
-
case "-h":
|
|
122
|
-
case undefined:
|
|
123
|
-
help();
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
console.error(`Unknown command: ${command}`);
|
|
127
|
-
help();
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function parseProjectDir(args) {
|
|
132
|
-
const idx = args.indexOf("--project-dir");
|
|
133
|
-
if (idx !== -1 && args[idx + 1])
|
|
134
|
-
return args[idx + 1];
|
|
135
|
-
return process.cwd();
|
|
136
|
-
}
|
|
137
|
-
function getOpenClawConfigPath(projectDir) {
|
|
138
|
-
return path.join(projectDir, CONFIG_DIR, "config.json");
|
|
139
|
-
}
|
|
140
|
-
function ensureConfigDir(projectDir) {
|
|
141
|
-
const dir = path.join(projectDir, CONFIG_DIR);
|
|
142
|
-
if (!fs.existsSync(dir)) {
|
|
143
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
55
|
+
/** A read-only OpenClaw config is an operator choice, not a bug: one line, exit 1. */
|
|
56
|
+
function exitOnReadOnlyConfig(err) {
|
|
57
|
+
if (err instanceof openclaw_config_js_1.OpenClawConfigReadOnlyError) {
|
|
58
|
+
console.error(err.message);
|
|
59
|
+
process.exit(1);
|
|
144
60
|
}
|
|
61
|
+
throw err;
|
|
145
62
|
}
|
|
146
63
|
function install(args) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
packageRoot: PACKAGE_ROOT,
|
|
158
|
-
installCommand: "npx -y -p @ory/openclaw ory-openclaw install",
|
|
159
|
-
args,
|
|
160
|
-
entryRelPath: "dist/index.js",
|
|
161
|
-
inProcess: true,
|
|
162
|
-
});
|
|
163
|
-
console.log(runtime.target.kind === "linked"
|
|
164
|
-
? `Runtime: linked to ${runtime.target.packageDir} (dev)`
|
|
165
|
-
: `Runtime: ${runtime.target.packageName}@${runtime.target.version} in ${runtime.target.storeDir}`);
|
|
166
|
-
for (const pruned of runtime.prunedStores) {
|
|
167
|
-
console.log(` Removed stale runtime: ${pruned}`);
|
|
64
|
+
try {
|
|
65
|
+
const result = (0, installer_js_1.installOpenclaw)({ args, packageRoot: PACKAGE_ROOT });
|
|
66
|
+
console.log(`Ory plugin registered in ${result.configPath}`);
|
|
67
|
+
console.log(` Plugin id: ${plugin_config_js_1.PLUGIN_ID}`);
|
|
68
|
+
console.log(` Loads from: ${result.pluginDir}`);
|
|
69
|
+
console.log(` Skills installed under ${result.skillsDir}`);
|
|
70
|
+
console.log(result.mcpRegistered
|
|
71
|
+
? " Ory MCP server registered under mcp.servers.ory"
|
|
72
|
+
: " Ory MCP server not registered: its package is not in this runtime");
|
|
73
|
+
console.log(" Restart the OpenClaw Gateway if it does not pick up the change.");
|
|
168
74
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
merged = (0, argus_1.mergeMcpServer)(merged, runtime.mcpServer);
|
|
75
|
+
catch (err) {
|
|
76
|
+
exitOnReadOnlyConfig(err);
|
|
172
77
|
}
|
|
173
|
-
|
|
174
|
-
(0, assets_js_1.installOpenclawOryAssets)(projectDir);
|
|
175
|
-
console.log(`Ory plugin registered in ${configPath}`);
|
|
176
|
-
console.log(` Plugin id: ${plugin_config_js_1.PLUGIN_ID}`);
|
|
177
|
-
console.log(` Loads from: ${runtime.target.packageDir}`);
|
|
178
|
-
console.log(` Skills + commands installed under ${path.join(projectDir, CONFIG_DIR, "skills")}`);
|
|
179
|
-
(0, argus_1.printEnvHelp)("ory-openclaw");
|
|
78
|
+
(0, cli_1.printEnvHelp)("ory-openclaw");
|
|
180
79
|
}
|
|
181
80
|
function uninstall(args) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
81
|
+
try {
|
|
82
|
+
const result = (0, installer_js_1.uninstallOpenclaw)({ args });
|
|
83
|
+
console.log(result.configChanged
|
|
84
|
+
? `Ory plugin, MCP server, and skills removed from ${result.configPath}`
|
|
85
|
+
: `No Ory entries found in ${result.configPath}.`);
|
|
187
86
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
let updated = (0, plugin_config_js_1.unregisterPluginFromConfig)(config);
|
|
191
|
-
updated = (0, argus_1.removeMcpServer)(updated);
|
|
192
|
-
fs.writeFileSync(configPath, JSON.stringify(updated, null, 2) + "\n");
|
|
193
|
-
console.log(`Ory plugin and skills removed from ${configPath}`);
|
|
194
|
-
(0, argus_1.removeRuntimeWiring)("openclaw");
|
|
195
|
-
for (const pruned of (0, argus_1.pruneRuntimeStores)()) {
|
|
196
|
-
console.log(` Removed runtime: ${pruned}`);
|
|
87
|
+
catch (err) {
|
|
88
|
+
exitOnReadOnlyConfig(err);
|
|
197
89
|
}
|
|
198
90
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
91
|
+
/** `install --print`: let the setup writer describe the install without changing anything. */
|
|
92
|
+
function printSetupPlan(args) {
|
|
93
|
+
process.argv = ["node", "setup.js", ...args];
|
|
94
|
+
require("./setup.js");
|
|
95
|
+
}
|
|
96
|
+
async function status() {
|
|
97
|
+
await (0, cli_1.runStatusCommand)("ory-openclaw", "openclaw", {
|
|
203
98
|
title: "OpenClaw",
|
|
204
99
|
printPluginSection: () => {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
console.log("Hooks & plugin:");
|
|
208
|
-
console.log(` Config file: ${configPath}`);
|
|
209
|
-
console.log(` Plugin registered: ${registered ? "yes" : "NO"}`);
|
|
210
|
-
if (registered) {
|
|
211
|
-
console.log(` Plugin id: ${plugin_config_js_1.PLUGIN_ID}`);
|
|
212
|
-
}
|
|
213
|
-
console.log(` Blocking support: yes (before_tool_call can deny tool execution)`);
|
|
214
|
-
console.log(` Hooks registered: session_start, before_tool_call, after_tool_call`);
|
|
100
|
+
for (const line of (0, installer_js_1.openclawPluginStatusLines)())
|
|
101
|
+
console.log(line);
|
|
215
102
|
},
|
|
216
103
|
});
|
|
217
104
|
}
|
|
@@ -223,26 +110,41 @@ Usage:
|
|
|
223
110
|
npx -y -p @ory/openclaw ory-openclaw <command> [options]
|
|
224
111
|
|
|
225
112
|
Commands:
|
|
226
|
-
install
|
|
227
|
-
uninstall
|
|
113
|
+
install Register the Ory plugin in OpenClaw's config
|
|
114
|
+
uninstall Remove the Ory plugin from OpenClaw's config
|
|
228
115
|
configure Set or view Ory project URL and API key
|
|
229
116
|
agent <cmd> Inspect runtime status or clear legacy OAuth state
|
|
230
117
|
permissions Show live mode and native allowed/blocked state
|
|
231
|
-
status
|
|
118
|
+
status Show plugin configuration and status
|
|
232
119
|
watch [--json] [--lines <count>] Follow the live activity/debug log
|
|
233
120
|
version Show version and the ory-agent-plugins build commit
|
|
234
121
|
local <cmd> Manage local Ory dev environment (up, down, status, seed, ...)
|
|
235
122
|
|
|
123
|
+
install and uninstall edit the config OpenClaw loads: OPENCLAW_CONFIG_PATH,
|
|
124
|
+
else $OPENCLAW_STATE_DIR/openclaw.json, else ~/.openclaw/openclaw.json.
|
|
125
|
+
|
|
236
126
|
After installing, the plugin hooks into these OpenClaw lifecycle events:
|
|
237
|
-
session_start
|
|
127
|
+
session_start Sign in and set up the agent identity (never blocks)
|
|
128
|
+
before_agent_run Refresh the sign-in before each turn (never blocks)
|
|
238
129
|
before_tool_call Check tool permissions via Ory Permissions (can block)
|
|
239
130
|
after_tool_call Record tool completion activity
|
|
131
|
+
subagent_spawned Register the sub-agent identity
|
|
132
|
+
subagent_ended Record sub-agent termination
|
|
240
133
|
|
|
241
134
|
Examples:
|
|
242
|
-
npx -y -p @ory/openclaw ory-openclaw install # Register in
|
|
135
|
+
npx -y -p @ory/openclaw ory-openclaw install # Register in OpenClaw's config
|
|
243
136
|
npx -y -p @ory/openclaw ory-openclaw configure --project-url https://my.oryapis.com --agent-security-url https://agents.console.ory.com
|
|
244
137
|
npx -y -p @ory/openclaw ory-openclaw status # Check configuration
|
|
245
138
|
npx -y -p @ory/openclaw ory-openclaw uninstall # Remove plugin
|
|
246
139
|
`);
|
|
247
140
|
}
|
|
248
|
-
|
|
141
|
+
(0, cli_1.runHarnessCli)({
|
|
142
|
+
bin: "ory-openclaw",
|
|
143
|
+
harness: "openclaw",
|
|
144
|
+
packageRoot: PACKAGE_ROOT,
|
|
145
|
+
help,
|
|
146
|
+
install,
|
|
147
|
+
printInstallPlan: printSetupPlan,
|
|
148
|
+
uninstall,
|
|
149
|
+
status,
|
|
150
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locate the config file OpenClaw actually loads.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors OpenClaw's own resolution (`src/config/paths.ts`,
|
|
5
|
+
* `src/config/state-dir.ts`, `src/infra/home-dir.ts` at v2026.11.3):
|
|
6
|
+
*
|
|
7
|
+
* 1. `OPENCLAW_CONFIG_PATH`, when set
|
|
8
|
+
* 2. `$OPENCLAW_STATE_DIR/openclaw.json`, when the state dir is set
|
|
9
|
+
* 3. `~/.openclaw/openclaw.json`
|
|
10
|
+
*
|
|
11
|
+
* `~` and the default state dir resolve against `OPENCLAW_HOME` when it is
|
|
12
|
+
* set, otherwise the OS home. OpenClaw has no project-level config file:
|
|
13
|
+
* `<project>/.openclaw/config.json`, which earlier versions of this installer
|
|
14
|
+
* wrote, is never read.
|
|
15
|
+
*
|
|
16
|
+
* `openclaw --profile <name>` selects `~/.openclaw-<name>` inside the OpenClaw
|
|
17
|
+
* process by setting `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH` there.
|
|
18
|
+
* This installer runs outside that process, so a profile install needs one of
|
|
19
|
+
* those two variables set explicitly.
|
|
20
|
+
*/
|
|
21
|
+
export declare const OPENCLAW_CONFIG_FILENAME = "openclaw.json";
|
|
22
|
+
type Env = NodeJS.ProcessEnv;
|
|
23
|
+
/** The home OpenClaw resolves `~` and its default state dir against. */
|
|
24
|
+
export declare function resolveOpenClawHome(env?: Env, homedir?: () => string): string;
|
|
25
|
+
/** OpenClaw's state directory: `OPENCLAW_STATE_DIR`, else `~/.openclaw`. */
|
|
26
|
+
export declare function resolveOpenClawStateDir(env?: Env, homedir?: () => string): string;
|
|
27
|
+
/** The config file OpenClaw loads for this environment. */
|
|
28
|
+
export declare function resolveOpenClawConfigPath(env?: Env, homedir?: () => string): string;
|
|
29
|
+
/**
|
|
30
|
+
* OpenClaw refuses to mutate its config when `OPENCLAW_CONFIG_READONLY=1` or
|
|
31
|
+
* `OPENCLAW_NIX_MODE=1` (the file is managed declaratively). Returns the
|
|
32
|
+
* variable that makes it read-only, or undefined when it is writable.
|
|
33
|
+
*/
|
|
34
|
+
export declare function openClawConfigReadOnlyReason(env?: Env): string | undefined;
|
|
35
|
+
/** Raised when the OpenClaw config is declared read-only by the environment. */
|
|
36
|
+
export declare class OpenClawConfigReadOnlyError extends Error {
|
|
37
|
+
readonly configPath: string;
|
|
38
|
+
constructor(configPath: string, reason: string);
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Locate the config file OpenClaw actually loads.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors OpenClaw's own resolution (`src/config/paths.ts`,
|
|
6
|
+
* `src/config/state-dir.ts`, `src/infra/home-dir.ts` at v2026.11.3):
|
|
7
|
+
*
|
|
8
|
+
* 1. `OPENCLAW_CONFIG_PATH`, when set
|
|
9
|
+
* 2. `$OPENCLAW_STATE_DIR/openclaw.json`, when the state dir is set
|
|
10
|
+
* 3. `~/.openclaw/openclaw.json`
|
|
11
|
+
*
|
|
12
|
+
* `~` and the default state dir resolve against `OPENCLAW_HOME` when it is
|
|
13
|
+
* set, otherwise the OS home. OpenClaw has no project-level config file:
|
|
14
|
+
* `<project>/.openclaw/config.json`, which earlier versions of this installer
|
|
15
|
+
* wrote, is never read.
|
|
16
|
+
*
|
|
17
|
+
* `openclaw --profile <name>` selects `~/.openclaw-<name>` inside the OpenClaw
|
|
18
|
+
* process by setting `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH` there.
|
|
19
|
+
* This installer runs outside that process, so a profile install needs one of
|
|
20
|
+
* those two variables set explicitly.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.OpenClawConfigReadOnlyError = exports.OPENCLAW_CONFIG_FILENAME = void 0;
|
|
57
|
+
exports.resolveOpenClawHome = resolveOpenClawHome;
|
|
58
|
+
exports.resolveOpenClawStateDir = resolveOpenClawStateDir;
|
|
59
|
+
exports.resolveOpenClawConfigPath = resolveOpenClawConfigPath;
|
|
60
|
+
exports.openClawConfigReadOnlyReason = openClawConfigReadOnlyReason;
|
|
61
|
+
const os = __importStar(require("node:os"));
|
|
62
|
+
const path = __importStar(require("node:path"));
|
|
63
|
+
exports.OPENCLAW_CONFIG_FILENAME = "openclaw.json";
|
|
64
|
+
const OPENCLAW_STATE_DIRNAME = ".openclaw";
|
|
65
|
+
/** OpenClaw treats the literal strings `undefined` and `null` as unset. */
|
|
66
|
+
function envValue(value) {
|
|
67
|
+
const trimmed = value?.trim();
|
|
68
|
+
return trimmed && trimmed !== "undefined" && trimmed !== "null" ? trimmed : undefined;
|
|
69
|
+
}
|
|
70
|
+
function osHomeDir(env, homedir) {
|
|
71
|
+
return path.resolve(envValue(env.HOME) ?? envValue(env.USERPROFILE) ?? homedir());
|
|
72
|
+
}
|
|
73
|
+
/** The home OpenClaw resolves `~` and its default state dir against. */
|
|
74
|
+
function resolveOpenClawHome(env = process.env, homedir = os.homedir) {
|
|
75
|
+
const explicit = envValue(env.OPENCLAW_HOME);
|
|
76
|
+
if (!explicit)
|
|
77
|
+
return osHomeDir(env, homedir);
|
|
78
|
+
if (explicit === "~" || explicit.startsWith("~/") || explicit.startsWith("~\\")) {
|
|
79
|
+
return path.resolve(explicit.replace(/^~(?=$|[\\/])/, () => osHomeDir(env, homedir)));
|
|
80
|
+
}
|
|
81
|
+
return path.resolve(explicit);
|
|
82
|
+
}
|
|
83
|
+
function resolveUserPath(input, env, homedir) {
|
|
84
|
+
const expanded = input.startsWith("~")
|
|
85
|
+
? input.replace(/^~(?=$|[\\/])/, () => resolveOpenClawHome(env, homedir))
|
|
86
|
+
: input;
|
|
87
|
+
return path.resolve(expanded);
|
|
88
|
+
}
|
|
89
|
+
/** OpenClaw's state directory: `OPENCLAW_STATE_DIR`, else `~/.openclaw`. */
|
|
90
|
+
function resolveOpenClawStateDir(env = process.env, homedir = os.homedir) {
|
|
91
|
+
const override = envValue(env.OPENCLAW_STATE_DIR);
|
|
92
|
+
if (override)
|
|
93
|
+
return resolveUserPath(override, env, homedir);
|
|
94
|
+
return path.join(resolveOpenClawHome(env, homedir), OPENCLAW_STATE_DIRNAME);
|
|
95
|
+
}
|
|
96
|
+
/** The config file OpenClaw loads for this environment. */
|
|
97
|
+
function resolveOpenClawConfigPath(env = process.env, homedir = os.homedir) {
|
|
98
|
+
const override = envValue(env.OPENCLAW_CONFIG_PATH);
|
|
99
|
+
if (override)
|
|
100
|
+
return resolveUserPath(override, env, homedir);
|
|
101
|
+
return path.join(resolveOpenClawStateDir(env, homedir), exports.OPENCLAW_CONFIG_FILENAME);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* OpenClaw refuses to mutate its config when `OPENCLAW_CONFIG_READONLY=1` or
|
|
105
|
+
* `OPENCLAW_NIX_MODE=1` (the file is managed declaratively). Returns the
|
|
106
|
+
* variable that makes it read-only, or undefined when it is writable.
|
|
107
|
+
*/
|
|
108
|
+
function openClawConfigReadOnlyReason(env = process.env) {
|
|
109
|
+
if (env.OPENCLAW_CONFIG_READONLY === "1")
|
|
110
|
+
return "OPENCLAW_CONFIG_READONLY=1";
|
|
111
|
+
if (env.OPENCLAW_NIX_MODE === "1")
|
|
112
|
+
return "OPENCLAW_NIX_MODE=1";
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
/** Raised when the OpenClaw config is declared read-only by the environment. */
|
|
116
|
+
class OpenClawConfigReadOnlyError extends Error {
|
|
117
|
+
configPath;
|
|
118
|
+
constructor(configPath, reason) {
|
|
119
|
+
super(`OpenClaw's config is read-only (${reason}), so ${configPath} was left unchanged. ` +
|
|
120
|
+
`Add the Ory plugin through the configuration that manages that file.`);
|
|
121
|
+
this.configPath = configPath;
|
|
122
|
+
this.name = "OpenClawConfigReadOnlyError";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.OpenClawConfigReadOnlyError = OpenClawConfigReadOnlyError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Pure transforms for the Ory entries in OpenClaw's config (`openclaw.json`;
|
|
3
|
+
* see `openclaw-config.ts` for where that file lives).
|
|
4
4
|
*
|
|
5
5
|
* Current OpenClaw addresses plugins by their **manifest id** (ours is
|
|
6
6
|
* `ory-agent-security`, from `openclaw.plugin.json`) under a nested
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
* `openclaw plugins install` + `openclaw plugins enable` pair:
|
|
11
11
|
*
|
|
12
12
|
* 1. Discovery — the plugin's package directory (the one holding
|
|
13
|
-
* `openclaw.plugin.json`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* `openclaw.plugin.json` and the `package.json` whose
|
|
14
|
+
* `openclaw.extensions` names the entry) is added to `plugins.load.paths`.
|
|
15
|
+
* OpenClaw only scans its bundled dir, `~/.openclaw/extensions`,
|
|
16
|
+
* `<ws>/.openclaw/extensions`, and configured `load.paths`; it does *not*
|
|
17
|
+
* auto-scan `node_modules`.
|
|
16
18
|
* 2. Enablement — `plugins.entries["ory-agent-security"].enabled = true`,
|
|
17
19
|
* byte-for-byte what `openclaw plugins enable` writes.
|
|
18
20
|
*
|
|
@@ -20,11 +22,19 @@
|
|
|
20
22
|
* present and non-empty, OpenClaw loads *only* the listed ids, so writing one
|
|
21
23
|
* onto a config that didn't have it would silently disable every other
|
|
22
24
|
* plugin. We only append our id to an allowlist that already exists.
|
|
25
|
+
*
|
|
26
|
+
* OpenClaw validates the root config as a strict object, so every key written
|
|
27
|
+
* here must exist in its schema: `plugins.*`, `mcp.servers.*`, and
|
|
28
|
+
* `skills.load.extraDirs`. A root `mcpServers` key (which earlier versions of
|
|
29
|
+
* this installer wrote) is not in the schema and makes the Gateway refuse to
|
|
30
|
+
* start, so it is removed wherever it is found.
|
|
23
31
|
*/
|
|
24
32
|
/** Plugin manifest id (from `openclaw.plugin.json`). */
|
|
25
33
|
export declare const PLUGIN_ID = "ory-agent-security";
|
|
26
34
|
/** npm module name — used only to migrate away the legacy flat-array shape. */
|
|
27
35
|
export declare const PLUGIN_MODULE = "@ory/openclaw";
|
|
36
|
+
/** Name of the Ory MCP server under `mcp.servers`. */
|
|
37
|
+
export declare const MCP_SERVER_NAME = "ory";
|
|
28
38
|
type Rec = Record<string, unknown>;
|
|
29
39
|
/**
|
|
30
40
|
* Resolve the directory that contains the plugin's `openclaw.plugin.json`
|
|
@@ -53,4 +63,21 @@ export declare function registerPluginInConfig(config: Rec, runtimeDir?: string)
|
|
|
53
63
|
export declare function unregisterPluginFromConfig(config: Rec, runtimeDir?: string): Rec;
|
|
54
64
|
/** True when the plugin is enabled under the current nested schema. */
|
|
55
65
|
export declare function isPluginRegistered(config: Rec): boolean;
|
|
66
|
+
/** The registered load path that holds this plugin's manifest, if any. */
|
|
67
|
+
export declare function registeredPluginDir(config: Rec): string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Register the Ory MCP server under `mcp.servers`, the key OpenClaw reads
|
|
70
|
+
* (`McpConfigSchema`), keeping other servers and other `mcp.*` settings. Also
|
|
71
|
+
* drops the root `mcpServers.ory` earlier installer versions wrote.
|
|
72
|
+
*/
|
|
73
|
+
export declare function mergeOpenClawMcpServer(config: Rec, cmd: {
|
|
74
|
+
command: string;
|
|
75
|
+
args: string[];
|
|
76
|
+
}): Rec;
|
|
77
|
+
/** Remove the Ory MCP server, pruning `mcp.servers` and `mcp` only when empty. */
|
|
78
|
+
export declare function removeOpenClawMcpServer(config: Rec): Rec;
|
|
79
|
+
/** Add a skills directory to `skills.load.extraDirs` unless it is already listed. */
|
|
80
|
+
export declare function addSkillsExtraDir(config: Rec, absDir: string): Rec;
|
|
81
|
+
/** Remove a skills directory from `skills.load.extraDirs`, pruning empties. */
|
|
82
|
+
export declare function removeSkillsExtraDir(config: Rec, absDir: string): Rec;
|
|
56
83
|
export {};
|