claude-scionos 4.1.6 → 4.1.8
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 +1 -1
- package/src/routerlab.js +27 -5
package/package.json
CHANGED
package/src/routerlab.js
CHANGED
|
@@ -207,6 +207,10 @@ function hasNonEmptyWindowsTokenFile(tokenFile) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
function encodeTokenForPowerShell(token) {
|
|
211
|
+
return Buffer.from(token, 'utf8').toString('base64');
|
|
212
|
+
}
|
|
213
|
+
|
|
210
214
|
function getServiceStrategies(serviceValue = DEFAULT_SERVICE) {
|
|
211
215
|
const service = getServiceConfig(serviceValue);
|
|
212
216
|
if (!service?.strategyValues?.length) {
|
|
@@ -230,6 +234,23 @@ function hasVerifiedModelIds(modelIds) {
|
|
|
230
234
|
return Array.isArray(modelIds) && modelIds.length > 0;
|
|
231
235
|
}
|
|
232
236
|
|
|
237
|
+
function hasExploitableModelIds(modelIds, serviceValue = DEFAULT_SERVICE) {
|
|
238
|
+
if (!hasVerifiedModelIds(modelIds)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const serviceStrategies = getServiceStrategies(serviceValue);
|
|
243
|
+
const knownModelIds = new Set(
|
|
244
|
+
serviceStrategies.flatMap((strategy) => getRequiredModels(strategy)),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
if (knownModelIds.size === 0) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return modelIds.some((modelId) => knownModelIds.has(modelId));
|
|
252
|
+
}
|
|
253
|
+
|
|
233
254
|
function assessStrategy(strategyValue, modelIds = [], serviceValue = DEFAULT_SERVICE) {
|
|
234
255
|
const serviceLabel = getServiceLabel(serviceValue);
|
|
235
256
|
const strategy = findStrategy(strategyValue, serviceValue);
|
|
@@ -252,7 +273,7 @@ function assessStrategy(strategyValue, modelIds = [], serviceValue = DEFAULT_SER
|
|
|
252
273
|
};
|
|
253
274
|
}
|
|
254
275
|
|
|
255
|
-
if (!
|
|
276
|
+
if (!hasExploitableModelIds(modelIds, serviceValue)) {
|
|
256
277
|
return {
|
|
257
278
|
available: true,
|
|
258
279
|
level: 'unknown',
|
|
@@ -312,7 +333,7 @@ function assessStrategyLaunch(strategyValue, modelIds = [], serviceValue = DEFAU
|
|
|
312
333
|
};
|
|
313
334
|
}
|
|
314
335
|
|
|
315
|
-
if (!requiredModels.length || !
|
|
336
|
+
if (!requiredModels.length || !hasExploitableModelIds(modelIds, serviceValue)) {
|
|
316
337
|
return {
|
|
317
338
|
ready: availability.level !== 'unavailable',
|
|
318
339
|
note: availability.note,
|
|
@@ -347,7 +368,7 @@ function assessStrategyLaunch(strategyValue, modelIds = [], serviceValue = DEFAU
|
|
|
347
368
|
}
|
|
348
369
|
|
|
349
370
|
function getFallbackStrategy(strategyValue, modelIds = [], serviceValue = DEFAULT_SERVICE) {
|
|
350
|
-
if (
|
|
371
|
+
if (hasExploitableModelIds(modelIds, serviceValue)) {
|
|
351
372
|
return assessStrategyLaunch(strategyValue, modelIds, serviceValue).ready ? strategyValue : null;
|
|
352
373
|
}
|
|
353
374
|
|
|
@@ -442,14 +463,14 @@ function storeToken(token, serviceValue = DEFAULT_SERVICE) {
|
|
|
442
463
|
|
|
443
464
|
if (process.platform === 'win32') {
|
|
444
465
|
const tokenFile = getWindowsTokenFile(service.value);
|
|
466
|
+
const encodedToken = encodeTokenForPowerShell(token);
|
|
445
467
|
fs.mkdirSync(path.dirname(tokenFile), {recursive: true});
|
|
446
468
|
runPowerShell(
|
|
447
|
-
|
|
469
|
+
`$token = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${encodedToken}')); if ([string]::IsNullOrEmpty($token)) { throw "Token input is empty" }; $secure = ConvertTo-SecureString $token -AsPlainText -Force; $encrypted = ConvertFrom-SecureString $secure; Set-Content -Path $env:SCIONOS_TOKEN_FILE -Value $encrypted -NoNewline`,
|
|
448
470
|
{
|
|
449
471
|
env: {
|
|
450
472
|
SCIONOS_TOKEN_FILE: tokenFile,
|
|
451
473
|
},
|
|
452
|
-
input: token,
|
|
453
474
|
},
|
|
454
475
|
);
|
|
455
476
|
|
|
@@ -624,6 +645,7 @@ export {
|
|
|
624
645
|
getServiceStrategies,
|
|
625
646
|
getStoredToken,
|
|
626
647
|
getStoredTokenStatus,
|
|
648
|
+
hasExploitableModelIds,
|
|
627
649
|
getStrategyChoices,
|
|
628
650
|
hasVerifiedModelIds,
|
|
629
651
|
listStrategies,
|