opensyn 0.1.0
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 +73 -0
- package/README.zh-CN.md +65 -0
- package/index.ts +3507 -0
- package/openclaw.plugin.json +173 -0
- package/package.json +33 -0
- package/runtime/bin/linux-x64/synapse-cli +0 -0
- package/runtime/bin/linux-x64/synapse-daemon +0 -0
- package/runtime/opensyn-cli +43 -0
- package/runtime/opensyn-daemon +43 -0
- package/runtime/opensyn-host-distiller.mjs +173 -0
- package/runtime/opensyn-ingest-command +124 -0
- package/runtime/opensyn-run +99 -0
- package/runtime/postinstall.mjs +85 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
const pluginId = "opensyn";
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const home = os.homedir();
|
|
9
|
+
const managedInstallRoot = path.join(home, ".openclaw", "extensions");
|
|
10
|
+
const transientOpenClawExtract = `${path.sep}openclaw-plugin-`;
|
|
11
|
+
const runtimeRoot = path.join(home, ".opensyn");
|
|
12
|
+
const runtimeDir = path.join(runtimeRoot, "runtime");
|
|
13
|
+
const cliBin = path.join(runtimeDir, "opensyn-cli");
|
|
14
|
+
|
|
15
|
+
if (!cwd.startsWith(managedInstallRoot) && !cwd.includes(transientOpenClawExtract)) {
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const packageRuntimeDir = path.join(cwd, "runtime");
|
|
20
|
+
if (fs.existsSync(packageRuntimeDir)) {
|
|
21
|
+
fs.mkdirSync(runtimeDir, { recursive: true });
|
|
22
|
+
fs.cpSync(packageRuntimeDir, runtimeDir, { recursive: true, force: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const configPath = path.join(home, ".openclaw", "openclaw.json");
|
|
26
|
+
let config = {};
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(configPath)) {
|
|
29
|
+
const raw = fs.readFileSync(configPath, "utf8").trim();
|
|
30
|
+
if (raw) {
|
|
31
|
+
config = JSON.parse(raw);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof config !== "object" || config === null) {
|
|
36
|
+
config = {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const plugins =
|
|
40
|
+
typeof config.plugins === "object" && config.plugins !== null ? config.plugins : {};
|
|
41
|
+
const allow = Array.isArray(plugins.allow) ? [...plugins.allow] : [];
|
|
42
|
+
if (!allow.includes(pluginId)) {
|
|
43
|
+
allow.push(pluginId);
|
|
44
|
+
}
|
|
45
|
+
const entries =
|
|
46
|
+
typeof plugins.entries === "object" && plugins.entries !== null ? plugins.entries : {};
|
|
47
|
+
const existingEntry =
|
|
48
|
+
typeof entries[pluginId] === "object" && entries[pluginId] !== null ? entries[pluginId] : {};
|
|
49
|
+
|
|
50
|
+
config.plugins = {
|
|
51
|
+
...plugins,
|
|
52
|
+
allow,
|
|
53
|
+
entries: {
|
|
54
|
+
...entries,
|
|
55
|
+
[pluginId]: {
|
|
56
|
+
...existingEntry,
|
|
57
|
+
enabled: true,
|
|
58
|
+
config: {
|
|
59
|
+
...(typeof existingEntry.config === "object" && existingEntry.config !== null
|
|
60
|
+
? existingEntry.config
|
|
61
|
+
: {}),
|
|
62
|
+
runtimeRoot,
|
|
63
|
+
dbPath: path.join(runtimeRoot, "opensyn.db"),
|
|
64
|
+
cliBin,
|
|
65
|
+
daemonBin: path.join(runtimeDir, "opensyn-daemon"),
|
|
66
|
+
helperPath: path.join(runtimeDir, "opensyn-ingest-command"),
|
|
67
|
+
runnerPath: path.join(runtimeDir, "opensyn-run"),
|
|
68
|
+
defaultShell:
|
|
69
|
+
path.basename(process.env.SHELL || "bash") || "bash",
|
|
70
|
+
projectionBundleRoot: path.join(home, ".openclaw", "workspace"),
|
|
71
|
+
projectionHost: "openclaw",
|
|
72
|
+
projectionAutoApplyApproved: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
79
|
+
fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
80
|
+
|
|
81
|
+
if (fs.existsSync(cliBin)) {
|
|
82
|
+
spawnSync(cliBin, ["init-db", "--db", path.join(runtimeRoot, "opensyn.db")], {
|
|
83
|
+
stdio: "ignore",
|
|
84
|
+
});
|
|
85
|
+
}
|