nexgenr 1.0.1 → 1.0.2
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/dist/main.mjs +4 -162
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -62532,19 +62532,7 @@ var init_open_platform = __esmMin((() => {
|
|
|
62532
62532
|
init_identity();
|
|
62533
62533
|
init_managed_nexgenr();
|
|
62534
62534
|
init_model_alias_merge();
|
|
62535
|
-
OPEN_PLATFORMS = [
|
|
62536
|
-
id: "nexgen-cn",
|
|
62537
|
-
name: "Nexgen Platform (API key · platform.nexgenr.com)",
|
|
62538
|
-
baseUrl: "https://ia.nexgen.systems/v1",
|
|
62539
|
-
consoleUrl: "https://ia.nexgen.systems",
|
|
62540
|
-
allowedPrefixes: ["nexgenr-k"]
|
|
62541
|
-
}, {
|
|
62542
|
-
id: "nexgen-ai",
|
|
62543
|
-
name: "Nexgen Platform (API key · platform.nexgenr.ai)",
|
|
62544
|
-
baseUrl: "https://ia.nexgen.systems/v1",
|
|
62545
|
-
consoleUrl: "https://ia.nexgen.systems",
|
|
62546
|
-
allowedPrefixes: ["nexgenr-k"]
|
|
62547
|
-
}];
|
|
62535
|
+
OPEN_PLATFORMS = [];
|
|
62548
62536
|
OpenPlatformApiError = class extends Error {
|
|
62549
62537
|
status;
|
|
62550
62538
|
constructor(message, status) {
|
|
@@ -63043,6 +63031,8 @@ var init_custom_registry = __esmMin((() => {
|
|
|
63043
63031
|
RESERVED_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
63044
63032
|
NEXGENR_PLATFORM_ID,
|
|
63045
63033
|
NEXGENR_PROVIDER_NAME,
|
|
63034
|
+
"nexgen-cn",
|
|
63035
|
+
"nexgen-ai",
|
|
63046
63036
|
...OPEN_PLATFORMS.map((platform) => platform.id)
|
|
63047
63037
|
]);
|
|
63048
63038
|
CustomRegistryApiError = class extends Error {
|
|
@@ -463649,51 +463639,7 @@ var init_model_selector = __esmMin((() => {
|
|
|
463649
463639
|
}
|
|
463650
463640
|
};
|
|
463651
463641
|
}));
|
|
463652
|
-
// src/tui/components/dialogs/platform-selector.ts
|
|
463653
|
-
function platformOptions() {
|
|
463654
|
-
return [NEXGENR_REDTEAM_OPTION, ...OPEN_PLATFORMS.map((platform) => ({
|
|
463655
|
-
value: platform.id,
|
|
463656
|
-
label: platform.name
|
|
463657
|
-
}))];
|
|
463658
|
-
}
|
|
463659
|
-
var NEXGENR_REDTEAM_OPTION, PlatformSelectorComponent;
|
|
463660
|
-
var init_platform_selector = __esmMin((() => {
|
|
463661
|
-
init_src$13();
|
|
463662
|
-
init_choice_picker();
|
|
463663
|
-
NEXGENR_REDTEAM_OPTION = {
|
|
463664
|
-
value: "nexgenr",
|
|
463665
|
-
label: "NexgenR (red-team)",
|
|
463666
|
-
description: "Sign in to redteam.nexgen.systems with an API key"
|
|
463667
|
-
};
|
|
463668
|
-
PlatformSelectorComponent = class extends ChoicePickerComponent {
|
|
463669
|
-
constructor(opts) {
|
|
463670
|
-
super({
|
|
463671
|
-
title: "Select a platform",
|
|
463672
|
-
options: [...platformOptions()],
|
|
463673
|
-
onSelect: opts.onSelect,
|
|
463674
|
-
onCancel: opts.onCancel
|
|
463675
|
-
});
|
|
463676
|
-
}
|
|
463677
|
-
};
|
|
463678
|
-
}));
|
|
463679
463642
|
// src/tui/commands/prompts.ts
|
|
463680
|
-
function promptPlatformSelection(host) {
|
|
463681
|
-
return new Promise((resolve) => {
|
|
463682
|
-
const selector = new PlatformSelectorComponent({
|
|
463683
|
-
onSelect: (platformId) => {
|
|
463684
|
-
host.restoreEditor();
|
|
463685
|
-
resolve(platformId);
|
|
463686
|
-
},
|
|
463687
|
-
onCancel: () => {
|
|
463688
|
-
host.restoreEditor();
|
|
463689
|
-
resolve(void 0);
|
|
463690
|
-
}
|
|
463691
|
-
});
|
|
463692
|
-
host.mountEditorReplacement(selector, void 0, () => {
|
|
463693
|
-
resolve(void 0);
|
|
463694
|
-
});
|
|
463695
|
-
});
|
|
463696
|
-
}
|
|
463697
463643
|
function promptLogoutProviderSelection(host, options, currentValue) {
|
|
463698
463644
|
return new Promise((resolve) => {
|
|
463699
463645
|
const picker = new ChoicePickerComponent({
|
|
@@ -463797,57 +463743,13 @@ function promptCatalogProviderSelection(host, catalog) {
|
|
|
463797
463743
|
host.mountEditorReplacement(picker);
|
|
463798
463744
|
});
|
|
463799
463745
|
}
|
|
463800
|
-
async function promptModelSelectionForOpenPlatform(host, models, platform) {
|
|
463801
|
-
const modelDict = {};
|
|
463802
|
-
for (const m of models) modelDict[`${platform.id}/${m.id}`] = {
|
|
463803
|
-
provider: platform.id,
|
|
463804
|
-
model: m.id,
|
|
463805
|
-
maxContextSize: m.contextLength,
|
|
463806
|
-
capabilities: capabilitiesForModel(m),
|
|
463807
|
-
displayName: m.displayName
|
|
463808
|
-
};
|
|
463809
|
-
const selection = await runModelSelector(host, modelDict);
|
|
463810
|
-
if (selection === void 0) return void 0;
|
|
463811
|
-
const model = models.find((m) => `${platform.id}/${m.id}` === selection.alias);
|
|
463812
|
-
return model ? {
|
|
463813
|
-
model,
|
|
463814
|
-
thinking: selection.thinking
|
|
463815
|
-
} : void 0;
|
|
463816
|
-
}
|
|
463817
|
-
function runModelSelector(host, modelDict) {
|
|
463818
|
-
return new Promise((resolve) => {
|
|
463819
|
-
const firstAlias = Object.keys(modelDict)[0] ?? "";
|
|
463820
|
-
const caps = modelDict[firstAlias]?.capabilities ?? [];
|
|
463821
|
-
const initialThinking = caps.includes("always_thinking") || caps.includes("thinking");
|
|
463822
|
-
const selector = new ModelSelectorComponent({
|
|
463823
|
-
models: modelDict,
|
|
463824
|
-
currentValue: firstAlias,
|
|
463825
|
-
currentThinkingEffort: initialThinking ? "on" : "off",
|
|
463826
|
-
searchable: true,
|
|
463827
|
-
onSelect: ({ alias, thinking }) => {
|
|
463828
|
-
host.restoreEditor();
|
|
463829
|
-
resolve({
|
|
463830
|
-
alias,
|
|
463831
|
-
thinking
|
|
463832
|
-
});
|
|
463833
|
-
},
|
|
463834
|
-
onCancel: () => {
|
|
463835
|
-
host.restoreEditor();
|
|
463836
|
-
resolve(void 0);
|
|
463837
|
-
}
|
|
463838
|
-
});
|
|
463839
|
-
host.mountEditorReplacement(selector);
|
|
463840
|
-
});
|
|
463841
|
-
}
|
|
463842
463746
|
var FEEDBACK_ATTACHMENT_OPTIONS;
|
|
463843
463747
|
var init_prompts = __esmMin((() => {
|
|
463844
463748
|
init_src$8();
|
|
463845
|
-
init_src$13();
|
|
463846
463749
|
init_api_key_input_dialog();
|
|
463847
463750
|
init_choice_picker();
|
|
463848
463751
|
init_feedback_input_dialog();
|
|
463849
463752
|
init_model_selector();
|
|
463850
|
-
init_platform_selector();
|
|
463851
463753
|
FEEDBACK_ATTACHMENT_OPTIONS = [
|
|
463852
463754
|
{
|
|
463853
463755
|
value: "none",
|
|
@@ -463871,15 +463773,7 @@ var init_prompts = __esmMin((() => {
|
|
|
463871
463773
|
async function handleLoginCommand(host) {
|
|
463872
463774
|
const releaseAuthBlock = host.beginAuthBlock();
|
|
463873
463775
|
try {
|
|
463874
|
-
|
|
463875
|
-
if (platformId === void 0) return;
|
|
463876
|
-
if (platformId === "nexgenr" || platformId === "nexgenr-global") {
|
|
463877
|
-
await handleRedteamLogin(host);
|
|
463878
|
-
return;
|
|
463879
|
-
}
|
|
463880
|
-
const platform = getOpenPlatformById(platformId);
|
|
463881
|
-
if (platform === void 0) return;
|
|
463882
|
-
await handleOpenPlatformLogin(host, platform);
|
|
463776
|
+
await handleRedteamLogin(host);
|
|
463883
463777
|
} finally {
|
|
463884
463778
|
releaseAuthBlock();
|
|
463885
463779
|
}
|
|
@@ -463938,57 +463832,6 @@ async function writeRedteamMcp(host, apiKey) {
|
|
|
463938
463832
|
return;
|
|
463939
463833
|
}
|
|
463940
463834
|
}
|
|
463941
|
-
async function handleOpenPlatformLogin(host, platform) {
|
|
463942
|
-
const consoleHost = platform.consoleUrl?.replace(/^https?:\/\//, "") ?? "";
|
|
463943
|
-
const apiKey = await promptApiKey(host, consoleHost.length > 0 ? `Nexgen Platform (${consoleHost})` : "Nexgen Platform", [`${"base_url".padEnd(12)}${platform.baseUrl}`, `${"saved to".padEnd(12)}~/.nexgenr/config.toml`]);
|
|
463944
|
-
if (apiKey === void 0) return;
|
|
463945
|
-
const controller = new AbortController();
|
|
463946
|
-
const cancelLogin = () => {
|
|
463947
|
-
controller.abort();
|
|
463948
|
-
};
|
|
463949
|
-
host.cancelInFlight = cancelLogin;
|
|
463950
|
-
let models;
|
|
463951
|
-
try {
|
|
463952
|
-
models = await fetchOpenPlatformModels(platform, apiKey, fetch, controller.signal);
|
|
463953
|
-
models = filterModelsByPrefix(models, platform);
|
|
463954
|
-
} catch (error) {
|
|
463955
|
-
if (controller.signal.aborted) return;
|
|
463956
|
-
const msg = formatErrorMessage$2(error);
|
|
463957
|
-
host.showError(`Failed to verify API key: ${msg}`);
|
|
463958
|
-
if (error instanceof OpenPlatformApiError && error.status === 401) host.showStatus("Hint: If your API key was obtained from NexgenR, please select \"NexgenR\" instead.");
|
|
463959
|
-
return;
|
|
463960
|
-
} finally {
|
|
463961
|
-
if (host.cancelInFlight === cancelLogin) host.cancelInFlight = void 0;
|
|
463962
|
-
}
|
|
463963
|
-
if (models.length === 0) {
|
|
463964
|
-
host.showError("No models available for this platform.");
|
|
463965
|
-
return;
|
|
463966
|
-
}
|
|
463967
|
-
const selection = await promptModelSelectionForOpenPlatform(host, models, platform);
|
|
463968
|
-
if (selection === void 0) return;
|
|
463969
|
-
if ((await host.harness.getConfig()).providers[platform.id] !== void 0) await host.harness.removeProvider(platform.id);
|
|
463970
|
-
const config = await host.harness.getConfig();
|
|
463971
|
-
applyOpenPlatformConfig(config, {
|
|
463972
|
-
platform,
|
|
463973
|
-
models,
|
|
463974
|
-
selectedModel: selection.model,
|
|
463975
|
-
thinking: selection.thinking !== "off",
|
|
463976
|
-
effort: selection.thinking !== "off" && selection.thinking !== "on" ? selection.thinking : void 0,
|
|
463977
|
-
credential: { apiKey }
|
|
463978
|
-
});
|
|
463979
|
-
await host.harness.setConfig({
|
|
463980
|
-
providers: config.providers,
|
|
463981
|
-
models: config.models,
|
|
463982
|
-
defaultModel: config.defaultModel,
|
|
463983
|
-
thinking: config.thinking
|
|
463984
|
-
});
|
|
463985
|
-
await host.authFlow.refreshConfigAfterLogin();
|
|
463986
|
-
host.track("login", {
|
|
463987
|
-
provider: platform.id,
|
|
463988
|
-
method: "api_key"
|
|
463989
|
-
});
|
|
463990
|
-
host.showStatus(`Setup complete: ${platform.name} · ${selection.model.id}`);
|
|
463991
|
-
}
|
|
463992
463835
|
async function handleLogoutCommand(host) {
|
|
463993
463836
|
const hasOAuthToken = (await host.harness.auth.status(DEFAULT_OAUTH_PROVIDER_NAME)).providers.some((p) => p.providerName === "managed:nexgenr" && p.hasToken);
|
|
463994
463837
|
const config = await host.harness.getConfig();
|
|
@@ -464032,7 +463875,6 @@ async function handleLogoutCommand(host) {
|
|
|
464032
463875
|
host.showStatus(`Logged out from ${label}.`);
|
|
464033
463876
|
}
|
|
464034
463877
|
var init_auth = __esmMin((() => {
|
|
464035
|
-
init_src$13();
|
|
464036
463878
|
init_src$8();
|
|
464037
463879
|
init_mcp_provision();
|
|
464038
463880
|
init_provision();
|