pi-ollama-cloud 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.3.1] - 2026-05-05
6
+
7
+ - Fix `OLLAMA_API_KEY` env var not being respected by `fetchModels` and web tools. pi-ai does not know about the `ollama-cloud` provider ID, so `AuthStorage.getApiKey()` alone misses the env var. Added explicit `process.env.OLLAMA_API_KEY` fallback.
8
+ - Switch web tools to `AuthStorage.create()` for API key lookup, matching the `models.ts` auth pattern from v0.2.1.
9
+ - Add null-safe access to `data.details?.family` in `resolveThinkingLevelMap`.
10
+ - Change `OLLAMA_BASE` from `export let` to `export const` to prevent accidental mutation.
11
+ - Fix fallback model IDs to use real Ollama Cloud identifiers (`glm-5.1`, `gemma4:31b`) instead of synthetic `:cloud` suffixes.
12
+ - Add smoke test workflow for CI.
13
+
5
14
  ## [0.3.0] - 2026-05-04
6
15
 
7
16
  - Derive `thinkingLevelMap` from pi's built-in model definitions instead of hardcoding model-family mappings. The extension now picks up thinking level metadata automatically when pi-mono adds or updates it for any model.
package/models.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { type ExtensionCommandContext, getAgentDir, type ProviderModelConfig } from "@mariozechner/pi-coding-agent";
4
- import { AuthStorage } from "@mariozechner/pi-coding-agent";
5
3
  import { getModels, getProviders } from "@mariozechner/pi-ai";
4
+ import {
5
+ AuthStorage,
6
+ type ExtensionCommandContext,
7
+ getAgentDir,
8
+ type ProviderModelConfig,
9
+ } from "@mariozechner/pi-coding-agent";
6
10
 
7
11
  // --- Constants ---
8
12
  const CACHE_DIR = join(getAgentDir(), "cache");
@@ -10,7 +14,7 @@ const CACHE_FILE = join(CACHE_DIR, "ollama-cloud-models.json");
10
14
  const FETCH_TIMEOUT_MS = 10000;
11
15
 
12
16
  // --- API fetch ---
13
- export let OLLAMA_BASE = (process.env.OLLAMA_API_BASE || "https://ollama.com").replace(/\/+$/, "");
17
+ export const OLLAMA_BASE = (process.env.OLLAMA_API_BASE || "https://ollama.com").replace(/\/+$/, "");
14
18
 
15
19
  // Initialize AuthStorage
16
20
  const authStorage = AuthStorage.create();
@@ -82,10 +86,12 @@ function resolveThinkingLevelMap(modelId: string, data: OllamaShowResponse): Pro
82
86
 
83
87
  // 2. Family-based fallback: match Ollama's details.family against pi model stems
84
88
  if (data.capabilities?.includes("thinking")) {
85
- const familyStem = data.details.family.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
86
- for (const [stem, tlm] of BUILTIN_FAMILY_ENTRIES) {
87
- if (stem.startsWith(familyStem)) {
88
- return tlm;
89
+ const familyStem = data.details?.family?.replace(/[^a-zA-Z0-9]/g, "").toLowerCase() ?? "";
90
+ if (familyStem) {
91
+ for (const [stem, tlm] of BUILTIN_FAMILY_ENTRIES) {
92
+ if (stem.startsWith(familyStem)) {
93
+ return tlm;
94
+ }
89
95
  }
90
96
  }
91
97
  }
@@ -111,18 +117,18 @@ export function assembleModels(raw: Record<string, OllamaShowResponse>): Provide
111
117
  // --- Fallback models (cold cache) ---
112
118
  export const FALLBACK_MODELS: ProviderModelConfig[] = [
113
119
  {
114
- id: "glm-5.1:cloud",
115
- name: "GLM 5.1 Cloud",
116
- reasoning: true,
120
+ id: "glm-5.1",
121
+ name: "GLM 5.1",
122
+ reasoning: false,
117
123
  input: ["text"],
118
124
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
119
125
  contextWindow: 202752,
120
126
  maxTokens: 32768,
121
127
  },
122
128
  {
123
- id: "gemma4:cloud",
124
- name: "Gemma 4 Cloud",
125
- reasoning: true,
129
+ id: "gemma4:31b",
130
+ name: "Gemma 4 31B",
131
+ reasoning: false,
126
132
  input: ["text"],
127
133
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
128
134
  contextWindow: 262144,
@@ -153,7 +159,7 @@ export function writeCache(models: Record<string, OllamaShowResponse>): void {
153
159
 
154
160
  // --- Fetch Models ---
155
161
  export async function fetchModels(ctx: ExtensionCommandContext): Promise<Record<string, OllamaShowResponse> | null> {
156
- const apiKey = await authStorage.getApiKey("ollama-cloud");
162
+ const apiKey = (await authStorage.getApiKey("ollama-cloud")) ?? process.env.OLLAMA_API_KEY;
157
163
 
158
164
  if (!apiKey) {
159
165
  ctx.ui.notify(
@@ -162,7 +168,7 @@ export async function fetchModels(ctx: ExtensionCommandContext): Promise<Record<
162
168
  "- auth.json file (at ~/.pi/agent/auth.json) under 'ollama-cloud' key,\n" +
163
169
  "- or via the CLI --api-key flag.\n" +
164
170
  "Example auth.json entry: \n" +
165
- '{ \"ollama-cloud\": { \"type\": \"api_key\", \"key\": \"YOUR_API_KEY\" } }',
171
+ '{ "ollama-cloud": { "type": "api_key", "key": "YOUR_API_KEY" } }',
166
172
  "error",
167
173
  );
168
174
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ollama-cloud",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "pi-package"
package/web-tools.ts CHANGED
@@ -1,9 +1,4 @@
1
- import {
2
- type ExtensionAPI,
3
- type ExtensionContext,
4
- keyHint,
5
- truncateToVisualLines,
6
- } from "@mariozechner/pi-coding-agent";
1
+ import { AuthStorage, type ExtensionAPI, keyHint, truncateToVisualLines } from "@mariozechner/pi-coding-agent";
7
2
  import { Text, truncateToWidth } from "@mariozechner/pi-tui";
8
3
  import { Type } from "@sinclair/typebox";
9
4
  import { OLLAMA_BASE } from "./models.ts";
@@ -26,8 +21,10 @@ interface FetchResponse {
26
21
 
27
22
  // --- Helpers ---
28
23
 
29
- async function getCloudApiKey(ctx: ExtensionContext): Promise<string | undefined> {
30
- return ctx.modelRegistry.getApiKeyForProvider("ollama-cloud");
24
+ const authStorage = AuthStorage.create();
25
+
26
+ async function getCloudApiKey(): Promise<string | undefined> {
27
+ return authStorage.getApiKey("ollama-cloud") ?? process.env.OLLAMA_API_KEY;
31
28
  }
32
29
 
33
30
  function noApiKeyError() {
@@ -121,8 +118,8 @@ export function registerWebSearchTool(pi: ExtensionAPI) {
121
118
  }),
122
119
  ),
123
120
  }),
124
- async execute(_toolCallId, params, signal, _onUpdate, ctx) {
125
- const apiKey = await getCloudApiKey(ctx);
121
+ async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
122
+ const apiKey = await getCloudApiKey();
126
123
  if (!apiKey) return noApiKeyError();
127
124
 
128
125
  try {
@@ -180,8 +177,8 @@ export function registerWebFetchTool(pi: ExtensionAPI) {
180
177
  parameters: Type.Object({
181
178
  url: Type.String({ description: "URL to fetch and extract content from", format: "uri" }),
182
179
  }),
183
- async execute(_toolCallId, params, signal, _onUpdate, ctx) {
184
- const apiKey = await getCloudApiKey(ctx);
180
+ async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
181
+ const apiKey = await getCloudApiKey();
185
182
  if (!apiKey) return noApiKeyError();
186
183
 
187
184
  try {