pi-nvidia-nim 1.1.17 → 1.1.18

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/index.ts +23 -1
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -636,6 +636,28 @@ async function fetchNimModels(apiKey: string): Promise<string[]> {
636
636
  // =============================================================================
637
637
 
638
638
  export default function (pi: ExtensionAPI) {
639
+ // Bail out cleanly if the user hasn't set up an API key yet. Without this
640
+ // guard, pi's flow can still route requests through this provider's
641
+ // streamSimple (e.g. when probing available providers, or when the
642
+ // configured default provider can't be resolved for any reason), which
643
+ // causes a fatal "NVIDIA_NIM_API_KEY environment variable is not set"
644
+ // error to be emitted on every `pi` invocation — even when the user
645
+ // never intended to use NVIDIA NIM. Skipping registration leaves the
646
+ // extension dormant: no NIM models appear in the picker, no provider is
647
+ // available to route to, and other providers (OpenAI, Anthropic, custom
648
+ // OpenAI-compatible endpoints in models.json, etc.) work normally.
649
+ //
650
+ // Re-enable by exporting the key:
651
+ // export NVIDIA_NIM_API_KEY=nvapi-...
652
+ if (!process.env[NVIDIA_NIM_API_KEY_ENV]) {
653
+ // One-line, stderr, only on first load. Not fatal.
654
+ console.error(
655
+ `pi-nvidia-nim: ${NVIDIA_NIM_API_KEY_ENV} not set — extension dormant. ` +
656
+ `Set the key (https://build.nvidia.com) and reload pi to enable NVIDIA NIM models.`
657
+ );
658
+ return;
659
+ }
660
+
639
661
  // Build the curated model list
640
662
  const modelMap = new Map<string, NimModelEntry>();
641
663
 
@@ -660,7 +682,7 @@ export default function (pi: ExtensionAPI) {
660
682
  // On session start, discover additional models from the API
661
683
  pi.on("session_start", async (_event: any, ctx: any) => {
662
684
  const apiKey = process.env[NVIDIA_NIM_API_KEY_ENV];
663
- if (!apiKey) return; // API key not available, skip model discovery
685
+ if (!apiKey) return; // belt-and-suspenders: skip if env was unset after load
664
686
 
665
687
  // Fetch live model list
666
688
  const liveModelIds = await fetchNimModels(apiKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-nvidia-nim",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "NVIDIA NIM API provider extension for pi coding agent — access 100+ models from build.nvidia.com",
5
5
  "type": "module",
6
6
  "files": [