@afffun/codexbot 1.0.78 → 1.0.80

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afffun/codexbot",
3
- "version": "1.0.78",
3
+ "version": "1.0.80",
4
4
  "description": "Thin npm bootstrap CLI for installing and operating Codexbot nodes",
5
5
  "type": "module",
6
6
  "author": "john88188 <john88188@outlook.com>",
@@ -81,6 +81,30 @@ function buildClaimFailureMessage(error, claimUrl) {
81
81
  return lines.join('\n');
82
82
  }
83
83
 
84
+ function normalizeBaseUrl(value) {
85
+ const raw = trim(value);
86
+ if (!raw) return '';
87
+ try {
88
+ const url = new URL(raw);
89
+ url.pathname = '';
90
+ url.search = '';
91
+ url.hash = '';
92
+ return url.toString().replace(/\/+$/g, '');
93
+ } catch {
94
+ return raw.replace(/\/+$/g, '');
95
+ }
96
+ }
97
+
98
+ function resolveLicenseServerUrl({ claim = {}, claimUrl = '', installBaseUrl = '', licenseServerUrl = '' } = {}) {
99
+ const explicit = normalizeBaseUrl(licenseServerUrl);
100
+ if (explicit) return explicit;
101
+ const claimed = normalizeBaseUrl(claim?.licenseServerUrl);
102
+ if (claimed) return claimed;
103
+ const installBase = normalizeBaseUrl(installBaseUrl);
104
+ if (installBase) return installBase;
105
+ return normalizeBaseUrl(claimUrl);
106
+ }
107
+
84
108
  export function createNpmDistributionActivationService(deps = {}) {
85
109
  const fsPromises = deps.fsPromises || fs;
86
110
  const fsSync = deps.fsSync || fsSyncDefault;
@@ -176,7 +200,7 @@ export function createNpmDistributionActivationService(deps = {}) {
176
200
  };
177
201
  }
178
202
 
179
- async function runLocalActivationScript(layout, files) {
203
+ async function runLocalActivationScript(layout, files, options = {}) {
180
204
  const scriptPath = pathModule.join(layout.appDir, 'scripts', 'codexbot_activate.sh');
181
205
  const isRoot = typeof processImpl.getuid === 'function' ? processImpl.getuid() === 0 : false;
182
206
  const baseArgs = [
@@ -185,6 +209,7 @@ export function createNpmDistributionActivationService(deps = {}) {
185
209
  '--license-file', files.licenseFile,
186
210
  '--license-public-key-file', files.licensePublicKeyFile,
187
211
  '--license-server-public-key-file', files.licenseServerPublicKeyFile,
212
+ ...(trim(options.licenseServerUrl) ? ['--license-server-url', trim(options.licenseServerUrl)] : []),
188
213
  '--start',
189
214
  ];
190
215
  const command = isRoot ? 'bash' : 'sudo';
@@ -217,8 +242,14 @@ export function createNpmDistributionActivationService(deps = {}) {
217
242
  throw new Error('claim response is missing activation package files');
218
243
  }
219
244
  const files = await writeActivationPackage(tempDir, activation);
245
+ const licenseServerUrl = resolveLicenseServerUrl({
246
+ claim,
247
+ claimUrl,
248
+ installBaseUrl: options.installBaseUrl,
249
+ licenseServerUrl: options.licenseServerUrl,
250
+ });
220
251
  logger.log('==> Activate installed node');
221
- const exitCode = await runLocalActivationScript(layout, files);
252
+ const exitCode = await runLocalActivationScript(layout, files, { licenseServerUrl });
222
253
  if (exitCode !== 0) {
223
254
  throw new Error(`activation script exited with code ${exitCode}`);
224
255
  }