openclawmp 1.0.0-alpha.2 → 1.0.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.
Files changed (2) hide show
  1. package/lib/config.js +76 -75
  2. package/package.json +1 -1
package/lib/config.js CHANGED
@@ -4,129 +4,130 @@ const fs = require("node:fs");
4
4
  const path = require("node:path");
5
5
  const os = require("node:os");
6
6
 
7
- const DEFAULT_API_BASE_URL = "https://seafood.c.stepfun-inc.net";
7
+ // const DEFAULT_API_BASE_URL = "https://seafood.c.stepfun-inc.net";
8
+ const DEFAULT_API_BASE_URL = "https://openclawmp.stepfun.com/";
8
9
 
9
10
  const projectRoot = path.resolve(__dirname, "..");
10
11
  const repoRoot = path.resolve(projectRoot, "..");
11
12
  const INSTALL_ROOT_BY_TYPE = {
12
- skill: ["skills"],
13
- plugin: ["extensions"],
14
- channel: ["extensions"],
15
- trigger: ["triggers"],
16
- experience: ["experiences"],
17
- template: ["templates"]
13
+ skill: ["skills"],
14
+ plugin: ["extensions"],
15
+ channel: ["extensions"],
16
+ trigger: ["triggers"],
17
+ experience: ["experiences"],
18
+ template: ["templates"],
18
19
  };
19
20
 
20
21
  function parseEnvFile(content) {
21
- const result = {};
22
+ const result = {};
22
23
 
23
- content.split(/\r?\n/u).forEach(function eachLine(rawLine) {
24
- const line = rawLine.trim();
25
- if (!line || line.startsWith("#")) {
26
- return;
27
- }
24
+ content.split(/\r?\n/u).forEach(function eachLine(rawLine) {
25
+ const line = rawLine.trim();
26
+ if (!line || line.startsWith("#")) {
27
+ return;
28
+ }
28
29
 
29
- const separatorIndex = line.indexOf("=");
30
- if (separatorIndex <= 0) {
31
- return;
32
- }
30
+ const separatorIndex = line.indexOf("=");
31
+ if (separatorIndex <= 0) {
32
+ return;
33
+ }
33
34
 
34
- const key = line.slice(0, separatorIndex).trim();
35
- let value = line.slice(separatorIndex + 1).trim();
35
+ const key = line.slice(0, separatorIndex).trim();
36
+ let value = line.slice(separatorIndex + 1).trim();
36
37
 
37
- if (
38
- (value.startsWith("\"") && value.endsWith("\"")) ||
39
- (value.startsWith("'") && value.endsWith("'"))
40
- ) {
41
- value = value.slice(1, -1);
42
- }
38
+ if (
39
+ (value.startsWith('"') && value.endsWith('"')) ||
40
+ (value.startsWith("'") && value.endsWith("'"))
41
+ ) {
42
+ value = value.slice(1, -1);
43
+ }
43
44
 
44
- result[key] = value;
45
- });
45
+ result[key] = value;
46
+ });
46
47
 
47
- return result;
48
+ return result;
48
49
  }
49
50
 
50
51
  function readRepoEnv() {
51
- const env = {};
52
+ const env = {};
52
53
 
53
- [".env.local", ".env", ".env.prod"].forEach(function eachFile(fileName) {
54
- const filePath = path.join(repoRoot, fileName);
55
- if (!fs.existsSync(filePath)) {
56
- return;
57
- }
58
- Object.assign(env, parseEnvFile(fs.readFileSync(filePath, "utf8")));
59
- });
54
+ [".env.local", ".env", ".env.prod"].forEach(function eachFile(fileName) {
55
+ const filePath = path.join(repoRoot, fileName);
56
+ if (!fs.existsSync(filePath)) {
57
+ return;
58
+ }
59
+ Object.assign(env, parseEnvFile(fs.readFileSync(filePath, "utf8")));
60
+ });
60
61
 
61
- return env;
62
+ return env;
62
63
  }
63
64
 
64
65
  function firstDefined(values) {
65
- return values.find(function findValue(value) {
66
- return typeof value === "string" && value.trim();
67
- });
66
+ return values.find(function findValue(value) {
67
+ return typeof value === "string" && value.trim();
68
+ });
68
69
  }
69
70
 
70
71
  function normalizeBaseUrl(value) {
71
- return String(value)
72
- .trim()
73
- .replace(/\/api\/?$/u, "")
74
- .replace(/\/+$/u, "");
72
+ return String(value)
73
+ .trim()
74
+ .replace(/\/api\/?$/u, "")
75
+ .replace(/\/+$/u, "");
75
76
  }
76
77
 
77
78
  const repoEnv = readRepoEnv();
78
79
 
79
80
  function resolveApiBaseUrl(explicitValue) {
80
- const resolved = firstDefined([
81
- explicitValue,
82
- process.env.OPENCLAWMP_API_BASE_URL,
83
- process.env.OPENCLAWMP_BASE_URL,
84
- process.env.API_BASE_URL,
85
- process.env.NEXT_PUBLIC_API_BASE_URL,
86
- repoEnv.API_BASE_URL,
87
- repoEnv.NEXT_PUBLIC_API_BASE_URL,
88
- DEFAULT_API_BASE_URL
89
- ]);
90
-
91
- return normalizeBaseUrl(resolved || DEFAULT_API_BASE_URL);
81
+ const resolved = firstDefined([
82
+ explicitValue,
83
+ process.env.OPENCLAWMP_API_BASE_URL,
84
+ process.env.OPENCLAWMP_BASE_URL,
85
+ process.env.API_BASE_URL,
86
+ process.env.NEXT_PUBLIC_API_BASE_URL,
87
+ repoEnv.API_BASE_URL,
88
+ repoEnv.NEXT_PUBLIC_API_BASE_URL,
89
+ DEFAULT_API_BASE_URL,
90
+ ]);
91
+
92
+ return normalizeBaseUrl(resolved || DEFAULT_API_BASE_URL);
92
93
  }
93
94
 
94
95
  function resolveConnectBaseUrl(explicitValue) {
95
- return resolveApiBaseUrl(explicitValue) + "/api";
96
+ return resolveApiBaseUrl(explicitValue) + "/api";
96
97
  }
97
98
 
98
99
  function getOpenClawHome() {
99
- return path.join(os.homedir(), ".openclaw");
100
+ return path.join(os.homedir(), ".openclaw");
100
101
  }
101
102
 
102
103
  function defaultCredentialsPath() {
103
- return path.join(getOpenClawHome(), "hub-credentials.json");
104
+ return path.join(getOpenClawHome(), "hub-credentials.json");
104
105
  }
105
106
 
106
107
  function getLockfilePath() {
107
- return path.join(getOpenClawHome(), "hub-lock.json");
108
+ return path.join(getOpenClawHome(), "hub-lock.json");
108
109
  }
109
110
 
110
111
  function getManagedAssetsRoot() {
111
- return getOpenClawHome();
112
+ return getOpenClawHome();
112
113
  }
113
114
 
114
115
  function getInstallRoot(assetType) {
115
- const segments = INSTALL_ROOT_BY_TYPE[assetType];
116
- if (!segments) {
117
- throw new Error("未知资产类型: " + assetType);
118
- }
119
- return path.join.apply(path, [getManagedAssetsRoot()].concat(segments));
116
+ const segments = INSTALL_ROOT_BY_TYPE[assetType];
117
+ if (!segments) {
118
+ throw new Error("未知资产类型: " + assetType);
119
+ }
120
+ return path.join.apply(path, [getManagedAssetsRoot()].concat(segments));
120
121
  }
121
122
 
122
123
  module.exports = {
123
- projectRoot,
124
- repoRoot,
125
- resolveApiBaseUrl,
126
- resolveConnectBaseUrl,
127
- getOpenClawHome,
128
- defaultCredentialsPath,
129
- getLockfilePath,
130
- getManagedAssetsRoot,
131
- getInstallRoot
124
+ projectRoot,
125
+ repoRoot,
126
+ resolveApiBaseUrl,
127
+ resolveConnectBaseUrl,
128
+ getOpenClawHome,
129
+ defaultCredentialsPath,
130
+ getLockfilePath,
131
+ getManagedAssetsRoot,
132
+ getInstallRoot,
132
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawmp",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0",
4
4
  "description": "OpenClaw Marketplace CLI client",
5
5
  "bin": {
6
6
  "openclawmp": "bin/openclawmp.js"