@kynver-app/openclaw-agent-os 0.1.19 → 0.1.20

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/package.json CHANGED
@@ -2,9 +2,12 @@
2
2
  "name": "@kynver-app/openclaw-agent-os",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.1.19",
5
+ "version": "0.1.20",
6
6
  "description": "OpenClaw plugin that exposes Kynver AgentOS as first-class agent tools",
7
7
  "main": "./dist/index.js",
8
+ "bin": {
9
+ "kynver-openclaw-agent-os-bootstrap": "./scripts/bootstrap-openclaw.mjs"
10
+ },
8
11
  "exports": {
9
12
  ".": {
10
13
  "import": "./dist/index.js",
@@ -29,6 +32,7 @@
29
32
  },
30
33
  "files": [
31
34
  "dist/**",
35
+ "scripts/**",
32
36
  "openclaw.plugin.json",
33
37
  "README.md",
34
38
  "SECURITY.md"
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+
4
+ const DEFAULT_PACKAGE = "@kynver-app/openclaw-agent-os@latest";
5
+ const PLUGIN_ID = "kynver-agent-os-tools";
6
+
7
+ function usage() {
8
+ console.log(`Usage: kynver-openclaw-agent-os-bootstrap [options]
9
+
10
+ Installs and configures the Kynver AgentOS OpenClaw plugin.
11
+
12
+ Options:
13
+ --api-url <url> Kynver API origin. Defaults to KYNVER_API_URL or https://www.kynver.com.
14
+ --api-key <key> Optional Kynver API key to write into plugin config. Prefer KYNVER_API_KEY in the gateway environment.
15
+ --harness-repo <path> Kynver repo path for kynver_harness_* tools. Defaults to KYNVER_HARNESS_REPO.
16
+ --no-harness Do not enable kynver_harness_* tools.
17
+ --package <spec> Plugin package spec to install. Defaults to ${DEFAULT_PACKAGE}.
18
+ --skip-install Only patch config, validate, restart, and inspect.
19
+ --skip-restart Do not restart the OpenClaw gateway.
20
+ --dry-run Print and validate the config patch without applying it.
21
+ --help Show this help.
22
+ `);
23
+ }
24
+
25
+ function parseArgs(argv) {
26
+ const opts = {
27
+ apiUrl: process.env.KYNVER_API_URL || "https://www.kynver.com",
28
+ apiKey: "",
29
+ harnessRepo: process.env.KYNVER_HARNESS_REPO || "",
30
+ enableHarness: true,
31
+ packageSpec: DEFAULT_PACKAGE,
32
+ skipInstall: false,
33
+ skipRestart: false,
34
+ dryRun: false,
35
+ };
36
+
37
+ for (let i = 0; i < argv.length; i += 1) {
38
+ const arg = argv[i];
39
+ const next = () => {
40
+ const value = argv[i + 1];
41
+ if (!value || value.startsWith("--")) throw new Error(`${arg} requires a value`);
42
+ i += 1;
43
+ return value;
44
+ };
45
+
46
+ if (arg === "--api-url") opts.apiUrl = next();
47
+ else if (arg === "--api-key") opts.apiKey = next();
48
+ else if (arg === "--harness-repo") opts.harnessRepo = next();
49
+ else if (arg === "--no-harness") opts.enableHarness = false;
50
+ else if (arg === "--package") opts.packageSpec = next();
51
+ else if (arg === "--skip-install") opts.skipInstall = true;
52
+ else if (arg === "--skip-restart") opts.skipRestart = true;
53
+ else if (arg === "--dry-run") opts.dryRun = true;
54
+ else if (arg === "--help" || arg === "-h") {
55
+ usage();
56
+ process.exit(0);
57
+ } else {
58
+ throw new Error(`Unknown option: ${arg}`);
59
+ }
60
+ }
61
+
62
+ opts.apiUrl = opts.apiUrl.replace(/\/$/, "");
63
+ return opts;
64
+ }
65
+
66
+ function run(command, args, { input, allowFailure = false } = {}) {
67
+ const shown = [command, ...args].join(" ");
68
+ console.error(`$ ${shown}`);
69
+ const result = spawnSync(command, args, {
70
+ input,
71
+ encoding: "utf8",
72
+ stdio: input === undefined ? "inherit" : ["pipe", "inherit", "inherit"],
73
+ });
74
+
75
+ if (result.error) throw result.error;
76
+ if (result.status !== 0 && !allowFailure) {
77
+ throw new Error(`${shown} failed with exit ${result.status}`);
78
+ }
79
+ return result;
80
+ }
81
+
82
+ function buildPatch(opts) {
83
+ const config = {
84
+ kynverApiUrl: opts.apiUrl,
85
+ enableDirectHttp: true,
86
+ enableSessionLifecycle: true,
87
+ enableRuntimeSkillManifest: true,
88
+ enableContinuityGuidance: true,
89
+ enableHarnessTools: Boolean(opts.enableHarness && opts.harnessRepo),
90
+ };
91
+
92
+ if (opts.apiKey) config.kynverApiKey = opts.apiKey;
93
+ if (opts.enableHarness && opts.harnessRepo) config.harnessRepo = opts.harnessRepo;
94
+
95
+ return {
96
+ plugins: {
97
+ entries: {
98
+ [PLUGIN_ID]: {
99
+ enabled: true,
100
+ config,
101
+ },
102
+ },
103
+ },
104
+ };
105
+ }
106
+
107
+ try {
108
+ const opts = parseArgs(process.argv.slice(2));
109
+
110
+ if (opts.enableHarness && !opts.harnessRepo) {
111
+ console.error("Harness tools will stay disabled because --harness-repo/KYNVER_HARNESS_REPO is not set.");
112
+ }
113
+ if (process.env.KYNVER_API_KEY && !opts.apiKey) {
114
+ console.error("KYNVER_API_KEY is set for this process. It will not be written to config; make sure the OpenClaw gateway service also has it.");
115
+ } else if (!opts.apiKey) {
116
+ console.error("KYNVER_API_KEY is not set. Direct HTTP tools need it in the OpenClaw gateway environment or pass --api-key to write it into plugin config.");
117
+ }
118
+
119
+ if (!opts.skipInstall && !opts.dryRun) {
120
+ run("openclaw", ["plugins", "install", opts.packageSpec, "--force"]);
121
+ }
122
+
123
+ const patch = JSON.stringify(buildPatch(opts), null, 2);
124
+ if (opts.dryRun) {
125
+ console.log(patch);
126
+ run("openclaw", ["config", "patch", "--stdin", "--dry-run"], { input: patch });
127
+ } else {
128
+ run("openclaw", ["config", "patch", "--stdin"], { input: patch });
129
+ run("openclaw", ["config", "validate"]);
130
+ if (!opts.skipRestart) run("openclaw", ["gateway", "restart"]);
131
+ run("openclaw", ["plugins", "inspect", PLUGIN_ID, "--runtime", "--json"], { allowFailure: true });
132
+ }
133
+ } catch (error) {
134
+ console.error(error instanceof Error ? error.message : String(error));
135
+ process.exit(1);
136
+ }