ollama-models 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, [fullname]
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.ko.md ADDED
@@ -0,0 +1,76 @@
1
+ # ollama-models
2
+
3
+ [Ollama](https://ollama.com) 레지스트리에서 모델을 검색하고 나열하는 TypeScript/JavaScript 클라이언트.
4
+
5
+ English | **한국어**
6
+
7
+ ## 설치
8
+
9
+ ```bash
10
+ npm install ollama-models
11
+ # 또는
12
+ pnpm add ollama-models
13
+ ```
14
+
15
+ ## 사용법
16
+
17
+ ```typescript
18
+ import { OllamaModelsClient } from 'ollama-models';
19
+
20
+ // 기본 URL 불필요 — 공식 호스팅 인스턴스 사용
21
+ const client = new OllamaModelsClient();
22
+
23
+ // 자체 호스팅 API를 사용하는 경우에만 baseUrl 전달
24
+ // const client = new OllamaModelsClient('https://your-own-instance.workers.dev');
25
+
26
+ // 모델 검색
27
+ const result = await client.search('qwen3', 1);
28
+ result.pages.forEach(p => console.log(p.http_url));
29
+
30
+ // 모델의 모든 태그 조회
31
+ const model = await client.getModel('qwen3');
32
+ console.log(model.default_tag); // qwen3:latest
33
+ model.tags.forEach(t => console.log(t));
34
+ ```
35
+
36
+ ## API
37
+
38
+ ### `new OllamaModelsClient(baseUrl?)`
39
+
40
+ | 파라미터 | 타입 | 기본값 | 설명 |
41
+ |-----------|------|---------|-------------|
42
+ | `baseUrl` | `string` | `https://ollama.devcomfort.me/api` | ollama-models Workers API의 Base URL |
43
+
44
+ ### `client.search(keyword?, page?): Promise<SearchResult>`
45
+
46
+ | 파라미터 | 타입 | 기본값 | 설명 |
47
+ |-----------|------|---------|-------------|
48
+ | `keyword` | `string` | `""` | 검색어 |
49
+ | `page` | `number` | `1` | 페이지 번호 (1부터 시작) |
50
+
51
+ ### `client.getModel(name): Promise<ModelTags>`
52
+
53
+ | 파라미터 | 타입 | 설명 |
54
+ |-----------|------|-------------|
55
+ | `name` | `string` | 모델 식별자 (`qwen3`, `library/qwen3`, `User/model`, 또는 전체 URL) |
56
+
57
+ ## 타입
58
+
59
+ ```typescript
60
+ interface SearchResult {
61
+ pages: ModelPage[];
62
+ page_id: number;
63
+ keyword: string;
64
+ }
65
+
66
+ interface ModelTags {
67
+ page_url: string;
68
+ id: string; // 예: "library/qwen3"
69
+ tags: string[]; // 예: ["qwen3:latest", "qwen3:4b"]
70
+ default_tag: string | null;
71
+ }
72
+
73
+ interface ModelPage {
74
+ http_url: string;
75
+ }
76
+ ```
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # ollama-models
2
+
3
+ TypeScript/JavaScript client for searching and listing models from the [Ollama](https://ollama.com) registry.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install ollama-models
9
+ # or
10
+ pnpm add ollama-models
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { OllamaModelsClient } from 'ollama-models';
17
+
18
+ // No base URL needed — defaults to the official hosted instance
19
+ const client = new OllamaModelsClient();
20
+
21
+ // Pass a base URL only if you self-host the API
22
+ // const client = new OllamaModelsClient('https://your-own-instance.workers.dev');
23
+
24
+ // Search models
25
+ const result = await client.search('qwen3', 1);
26
+ result.pages.forEach(p => console.log(p.http_url));
27
+
28
+ // Get all tags for a model
29
+ const model = await client.getModel('qwen3');
30
+ console.log(model.default_tag); // qwen3:latest
31
+ model.tags.forEach(t => console.log(t));
32
+ ```
33
+
34
+ ## API
35
+
36
+ ### `new OllamaModelsClient(baseUrl?)`
37
+
38
+ | Parameter | Type | Default | Description |
39
+ |-----------|------|---------|-------------|
40
+ | `baseUrl` | `string` | `https://ollama.devcomfort.me/api` | Base URL of the ollama-models Workers API |
41
+
42
+ ### `client.search(keyword?, page?): Promise<SearchResult>`
43
+
44
+ | Parameter | Type | Default | Description |
45
+ |-----------|------|---------|-------------|
46
+ | `keyword` | `string` | `""` | Search term |
47
+ | `page` | `number` | `1` | Page number (1-based) |
48
+
49
+ ### `client.getModel(name): Promise<ModelTags>`
50
+
51
+ | Parameter | Type | Description |
52
+ |-----------|------|-------------|
53
+ | `name` | `string` | Model identifier (`qwen3`, `library/qwen3`, `User/model`, or full URL) |
54
+
55
+ ## Types
56
+
57
+ ```typescript
58
+ interface SearchResult {
59
+ pages: ModelPage[];
60
+ page_id: number;
61
+ keyword: string;
62
+ }
63
+
64
+ interface ModelTags {
65
+ page_url: string;
66
+ id: string; // e.g. "library/qwen3"
67
+ tags: string[]; // e.g. ["qwen3:latest", "qwen3:4b"]
68
+ default_tag: string | null;
69
+ }
70
+
71
+ interface ModelPage {
72
+ http_url: string;
73
+ }
74
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,188 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let es_toolkit_util = require("es-toolkit/util");
3
+ //#region src/schemas.ts
4
+ function isObject(val) {
5
+ return typeof val === "object" && val !== null && !Array.isArray(val);
6
+ }
7
+ /**
8
+ * Asserts that `data` conforms to the {@link ModelPage} shape.
9
+ *
10
+ * @param data - Unknown value to validate.
11
+ * @param context - Label used in error messages (defaults to `"ModelPage"`).
12
+ * @throws When any field is missing or has the wrong type.
13
+ */
14
+ function assertModelPage(data, context = "ModelPage") {
15
+ (0, es_toolkit_util.assert)(isObject(data), `${context}: expected object`);
16
+ (0, es_toolkit_util.assert)(typeof data["http_url"] === "string", `${context}.http_url: expected string`);
17
+ (0, es_toolkit_util.assert)(typeof data["model_id"] === "string", `${context}.model_id: expected string`);
18
+ }
19
+ /**
20
+ * Asserts that `data` conforms to the {@link SearchResult} shape.
21
+ *
22
+ * @param data - Unknown value to validate.
23
+ * @throws When any field is missing or has the wrong type.
24
+ */
25
+ function assertSearchResult(data) {
26
+ (0, es_toolkit_util.assert)(isObject(data), "SearchResult: expected object");
27
+ (0, es_toolkit_util.assert)(Array.isArray(data["pages"]), "SearchResult.pages: expected array");
28
+ data["pages"].forEach((p, i) => assertModelPage(p, `SearchResult.pages[${i}]`));
29
+ const pr = data["page_range"];
30
+ (0, es_toolkit_util.assert)(typeof pr === "number" || isObject(pr) && typeof pr["from"] === "number" && typeof pr["to"] === "number", "SearchResult.page_range: expected number or { from: number; to: number }");
31
+ (0, es_toolkit_util.assert)(typeof data["keyword"] === "string", "SearchResult.keyword: expected string");
32
+ }
33
+ /**
34
+ * Asserts that `data` conforms to the {@link ModelTags} shape.
35
+ *
36
+ * @param data - Unknown value to validate.
37
+ * @throws When any field is missing or has the wrong type.
38
+ */
39
+ function assertModelTags(data) {
40
+ (0, es_toolkit_util.assert)(isObject(data), "ModelTags: expected object");
41
+ (0, es_toolkit_util.assert)(typeof data["page_url"] === "string", "ModelTags.page_url: expected string");
42
+ (0, es_toolkit_util.assert)(typeof data["id"] === "string", "ModelTags.id: expected string");
43
+ (0, es_toolkit_util.assert)(Array.isArray(data["tags"]), "ModelTags.tags: expected array");
44
+ data["tags"].forEach((t, i) => (0, es_toolkit_util.assert)(typeof t === "string", `ModelTags.tags[${i}]: expected string`));
45
+ (0, es_toolkit_util.assert)(data["default_tag"] === null || typeof data["default_tag"] === "string", "ModelTags.default_tag: expected string or null");
46
+ }
47
+ /**
48
+ * Asserts that `data` conforms to the {@link CheckResult} shape.
49
+ *
50
+ * @param data - Unknown value to validate.
51
+ * @param context - Label used in error messages (defaults to `"CheckResult"`).
52
+ * @throws When any field is missing or has the wrong type.
53
+ */
54
+ function assertCheckResult(data, context = "CheckResult") {
55
+ (0, es_toolkit_util.assert)(isObject(data), `${context}: expected object`);
56
+ (0, es_toolkit_util.assert)(typeof data["ok"] === "boolean", `${context}.ok: expected boolean`);
57
+ if ("count" in data) (0, es_toolkit_util.assert)(typeof data["count"] === "number", `${context}.count: expected number`);
58
+ if ("error" in data) (0, es_toolkit_util.assert)(typeof data["error"] === "string", `${context}.error: expected string`);
59
+ }
60
+ /**
61
+ * Asserts that `data` conforms to the {@link HealthStatus} shape.
62
+ *
63
+ * @param data - Unknown value to validate.
64
+ * @throws When any field is missing or has the wrong type.
65
+ */
66
+ function assertHealthStatus(data) {
67
+ (0, es_toolkit_util.assert)(isObject(data), "HealthStatus: expected object");
68
+ (0, es_toolkit_util.assert)(typeof data["ok"] === "boolean", "HealthStatus.ok: expected boolean");
69
+ (0, es_toolkit_util.assert)(typeof data["timestamp"] === "string", "HealthStatus.timestamp: expected string");
70
+ (0, es_toolkit_util.assert)(isObject(data["checks"]), "HealthStatus.checks: expected object");
71
+ assertCheckResult(data["checks"]["search"], "HealthStatus.checks.search");
72
+ assertCheckResult(data["checks"]["model"], "HealthStatus.checks.model");
73
+ }
74
+ //#endregion
75
+ //#region src/client.ts
76
+ /**
77
+ * Base URL of the officially hosted ollama-models Workers API.
78
+ *
79
+ * Pass a different URL to {@link OllamaModelsClient} when self-hosting.
80
+ */
81
+ const DEFAULT_BASE_URL = "https://ollama.devcomfort.me/api";
82
+ /**
83
+ * HTTP client for the ollama-models Workers API.
84
+ *
85
+ * Provides a typed, promise-based interface over the `GET /search` and
86
+ * `GET /model` endpoints. Create one instance per application and reuse it.
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const client = new OllamaModelsClient();
91
+ *
92
+ * // Search for models
93
+ * const { pages } = await client.search('qwen3');
94
+ * console.log(pages[0].http_url);
95
+ *
96
+ * // Get all available tags
97
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
98
+ * console.log(default_tag); // 'qwen3:latest'
99
+ * ```
100
+ */
101
+ var OllamaModelsClient = class {
102
+ baseUrl;
103
+ /**
104
+ * @param baseUrl - Base URL of the deployed ollama-models Workers API.
105
+ * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).
106
+ * Trailing slashes are stripped automatically.
107
+ */
108
+ constructor(baseUrl = DEFAULT_BASE_URL) {
109
+ this.baseUrl = baseUrl.replace(/\/$/, "");
110
+ }
111
+ /**
112
+ * Search for models on Ollama.
113
+ *
114
+ * @param keyword - Search term. Pass an empty string to list all models.
115
+ * @param page - 1-based page number. Defaults to `1`.
116
+ * @returns A {@link SearchResult} containing matching model pages and
117
+ * metadata about the requested page.
118
+ * @throws {Error} When the API returns a non-2xx HTTP status.
119
+ * @example
120
+ * ```typescript
121
+ * const { pages, page_range, keyword } = await client.search('qwen3', 1);
122
+ * const firstUrl = pages[0].http_url;
123
+ * ```
124
+ */
125
+ async search(keyword = "", page = 1) {
126
+ const url = new URL(`${this.baseUrl}/search`);
127
+ if (keyword) url.searchParams.set("q", keyword);
128
+ url.searchParams.set("page", String(page));
129
+ const res = await fetch(url.toString());
130
+ if (!res.ok) throw new Error(`Search failed: HTTP ${res.status}`);
131
+ const data = await res.json();
132
+ assertSearchResult(data);
133
+ return data;
134
+ }
135
+ /**
136
+ * Retrieve all available tags (weights) for a model.
137
+ *
138
+ * @param name - Model identifier in `{profile}/{name}` format, e.g.:
139
+ * - `"library/qwen3"` — official Ollama library model
140
+ * - `"RogerBen/qwen3.5-35b-opus-distill"` — community model
141
+ * - `"https://ollama.com/library/qwen3"` — full URL
142
+ * @returns A {@link ModelTags} with all available weights.
143
+ * `default_tag` is `null` when the model has no `latest` tag.
144
+ * @throws {Error} When the API returns a non-2xx HTTP status.
145
+ * @example
146
+ * ```typescript
147
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
148
+ * // Pull the default weight: 'qwen3:latest'
149
+ * ```
150
+ */
151
+ async getModel(name) {
152
+ const url = new URL(`${this.baseUrl}/model`);
153
+ url.searchParams.set("name", name);
154
+ const res = await fetch(url.toString());
155
+ if (!res.ok) throw new Error(`Model fetch failed: HTTP ${res.status}`);
156
+ const data = await res.json();
157
+ assertModelTags(data);
158
+ return data;
159
+ }
160
+ /**
161
+ * Run a live health check against both scrapers.
162
+ *
163
+ * @returns A {@link HealthStatus} with per-scraper probe results and an
164
+ * aggregate `ok` flag.
165
+ * @throws {Error} When the API returns a non-2xx HTTP status.
166
+ * @example
167
+ * ```typescript
168
+ * const { ok, checks } = await client.health();
169
+ * if (!ok) console.error('search error:', checks.search.error);
170
+ * ```
171
+ */
172
+ async health() {
173
+ const res = await fetch(`${this.baseUrl}/health`);
174
+ if (!res.ok) throw new Error(`Health check failed: HTTP ${res.status}`);
175
+ const data = await res.json();
176
+ assertHealthStatus(data);
177
+ return data;
178
+ }
179
+ };
180
+ //#endregion
181
+ exports.OllamaModelsClient = OllamaModelsClient;
182
+ exports.assertCheckResult = assertCheckResult;
183
+ exports.assertHealthStatus = assertHealthStatus;
184
+ exports.assertModelPage = assertModelPage;
185
+ exports.assertModelTags = assertModelTags;
186
+ exports.assertSearchResult = assertSearchResult;
187
+
188
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/schemas.ts","../src/client.ts"],"sourcesContent":["import { assert } from 'es-toolkit/util';\nimport type { ModelTags, ModelPage, SearchResult, CheckResult, HealthStatus } from './types';\n\n// === helpers ===\n\nfunction isObject(val: unknown): val is Record<string, unknown> {\n return typeof val === 'object' && val !== null && !Array.isArray(val);\n}\n\n// === per-type assertions ===\n\n/**\n * Asserts that `data` conforms to the {@link ModelPage} shape.\n *\n * @param data - Unknown value to validate.\n * @param context - Label used in error messages (defaults to `\"ModelPage\"`).\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertModelPage(\n data: unknown,\n context = 'ModelPage',\n): asserts data is ModelPage {\n assert(isObject(data), `${context}: expected object`);\n assert(typeof data['http_url'] === 'string', `${context}.http_url: expected string`);\n assert(typeof data['model_id'] === 'string', `${context}.model_id: expected string`);\n}\n\n/**\n * Asserts that `data` conforms to the {@link SearchResult} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertSearchResult(data: unknown): asserts data is SearchResult {\n assert(isObject(data), 'SearchResult: expected object');\n assert(Array.isArray(data['pages']), 'SearchResult.pages: expected array');\n (data['pages'] as unknown[]).forEach((p, i) =>\n assertModelPage(p, `SearchResult.pages[${i}]`),\n );\n const pr = data['page_range'];\n assert(\n typeof pr === 'number' ||\n (isObject(pr) && typeof pr['from'] === 'number' && typeof pr['to'] === 'number'),\n 'SearchResult.page_range: expected number or { from: number; to: number }',\n );\n assert(typeof data['keyword'] === 'string', 'SearchResult.keyword: expected string');\n}\n\n/**\n * Asserts that `data` conforms to the {@link ModelTags} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertModelTags(data: unknown): asserts data is ModelTags {\n assert(isObject(data), 'ModelTags: expected object');\n assert(typeof data['page_url'] === 'string', 'ModelTags.page_url: expected string');\n assert(typeof data['id'] === 'string', 'ModelTags.id: expected string');\n assert(Array.isArray(data['tags']), 'ModelTags.tags: expected array');\n (data['tags'] as unknown[]).forEach((t, i) =>\n assert(typeof t === 'string', `ModelTags.tags[${i}]: expected string`),\n );\n assert(\n data['default_tag'] === null || typeof data['default_tag'] === 'string',\n 'ModelTags.default_tag: expected string or null',\n );\n}\n\n/**\n * Asserts that `data` conforms to the {@link CheckResult} shape.\n *\n * @param data - Unknown value to validate.\n * @param context - Label used in error messages (defaults to `\"CheckResult\"`).\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertCheckResult(\n data: unknown,\n context = 'CheckResult',\n): asserts data is CheckResult {\n assert(isObject(data), `${context}: expected object`);\n assert(typeof data['ok'] === 'boolean', `${context}.ok: expected boolean`);\n if ('count' in data) {\n assert(typeof data['count'] === 'number', `${context}.count: expected number`);\n }\n if ('error' in data) {\n assert(typeof data['error'] === 'string', `${context}.error: expected string`);\n }\n}\n\n/**\n * Asserts that `data` conforms to the {@link HealthStatus} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertHealthStatus(data: unknown): asserts data is HealthStatus {\n assert(isObject(data), 'HealthStatus: expected object');\n assert(typeof data['ok'] === 'boolean', 'HealthStatus.ok: expected boolean');\n assert(typeof data['timestamp'] === 'string', 'HealthStatus.timestamp: expected string');\n assert(isObject(data['checks']), 'HealthStatus.checks: expected object');\n assertCheckResult(data['checks']['search'], 'HealthStatus.checks.search');\n assertCheckResult(data['checks']['model'], 'HealthStatus.checks.model');\n}\n","import type { SearchResult, ModelTags, HealthStatus } from './types';\nimport { assertModelTags, assertSearchResult, assertHealthStatus } from './schemas';\n\n/**\n * Base URL of the officially hosted ollama-models Workers API.\n *\n * Pass a different URL to {@link OllamaModelsClient} when self-hosting.\n */\nexport const DEFAULT_BASE_URL = 'https://ollama.devcomfort.me/api';\n\n/**\n * HTTP client for the ollama-models Workers API.\n *\n * Provides a typed, promise-based interface over the `GET /search` and\n * `GET /model` endpoints. Create one instance per application and reuse it.\n *\n * @example\n * ```typescript\n * const client = new OllamaModelsClient();\n *\n * // Search for models\n * const { pages } = await client.search('qwen3');\n * console.log(pages[0].http_url);\n *\n * // Get all available tags\n * const { tags, default_tag } = await client.getModel('library/qwen3');\n * console.log(default_tag); // 'qwen3:latest'\n * ```\n */\nexport class OllamaModelsClient {\n private readonly baseUrl: string;\n\n /**\n * @param baseUrl - Base URL of the deployed ollama-models Workers API.\n * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).\n * Trailing slashes are stripped automatically.\n */\n constructor(baseUrl: string = DEFAULT_BASE_URL) {\n this.baseUrl = baseUrl.replace(/\\/$/, '');\n }\n\n /**\n * Search for models on Ollama.\n *\n * @param keyword - Search term. Pass an empty string to list all models.\n * @param page - 1-based page number. Defaults to `1`.\n * @returns A {@link SearchResult} containing matching model pages and\n * metadata about the requested page.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { pages, page_range, keyword } = await client.search('qwen3', 1);\n * const firstUrl = pages[0].http_url;\n * ```\n */\n async search(keyword = '', page = 1): Promise<SearchResult> {\n const url = new URL(`${this.baseUrl}/search`);\n if (keyword) url.searchParams.set('q', keyword);\n url.searchParams.set('page', String(page));\n\n const res = await fetch(url.toString());\n if (!res.ok) throw new Error(`Search failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertSearchResult(data);\n return data;\n }\n\n /**\n * Retrieve all available tags (weights) for a model.\n *\n * @param name - Model identifier in `{profile}/{name}` format, e.g.:\n * - `\"library/qwen3\"` — official Ollama library model\n * - `\"RogerBen/qwen3.5-35b-opus-distill\"` — community model\n * - `\"https://ollama.com/library/qwen3\"` — full URL\n * @returns A {@link ModelTags} with all available weights.\n * `default_tag` is `null` when the model has no `latest` tag.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { tags, default_tag } = await client.getModel('library/qwen3');\n * // Pull the default weight: 'qwen3:latest'\n * ```\n */\n async getModel(name: string): Promise<ModelTags> {\n const url = new URL(`${this.baseUrl}/model`);\n url.searchParams.set('name', name);\n\n const res = await fetch(url.toString());\n if (!res.ok) throw new Error(`Model fetch failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertModelTags(data);\n return data;\n }\n\n /**\n * Run a live health check against both scrapers.\n *\n * @returns A {@link HealthStatus} with per-scraper probe results and an\n * aggregate `ok` flag.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { ok, checks } = await client.health();\n * if (!ok) console.error('search error:', checks.search.error);\n * ```\n */\n async health(): Promise<HealthStatus> {\n const res = await fetch(`${this.baseUrl}/health`);\n if (!res.ok) throw new Error(`Health check failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertHealthStatus(data);\n return data;\n }\n}\n"],"mappings":";;;AAKA,SAAS,SAAS,KAA8C;AAC9D,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,IAAI;;;;;;;;;AAYvE,SAAgB,gBACd,MACA,UAAU,aACiB;AAC3B,EAAA,GAAA,gBAAA,QAAO,SAAS,KAAK,EAAE,GAAG,QAAQ,mBAAmB;AACrD,EAAA,GAAA,gBAAA,QAAO,OAAO,KAAK,gBAAgB,UAAU,GAAG,QAAQ,4BAA4B;AACpF,EAAA,GAAA,gBAAA,QAAO,OAAO,KAAK,gBAAgB,UAAU,GAAG,QAAQ,4BAA4B;;;;;;;;AAStF,SAAgB,mBAAmB,MAA6C;AAC9E,EAAA,GAAA,gBAAA,QAAO,SAAS,KAAK,EAAE,gCAAgC;AACvD,EAAA,GAAA,gBAAA,QAAO,MAAM,QAAQ,KAAK,SAAS,EAAE,qCAAqC;AACzE,MAAK,SAAuB,SAAS,GAAG,MACvC,gBAAgB,GAAG,sBAAsB,EAAE,G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jD,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,6BAA6B,IAAI,SAAS;EACvE,MAAM,OAAgB,MAAM,IAAI,MAAM;AACtC,qBAAmB,KAAK;AACxB,SAAO"}
@@ -0,0 +1,262 @@
1
+ //#region src/types.d.ts
2
+ /** A single 1-based page number, or an inclusive `{ from, to }` page range. */
3
+ type PageRange = number | {
4
+ from: number;
5
+ to: number;
6
+ };
7
+ /**
8
+ * A model page discovered from the Ollama search results.
9
+ *
10
+ * `model_id` is the full `{profile}/{name}` path. Ollama uses `library` as the
11
+ * fixed profile name for all officially maintained models, so a `library/`
12
+ * prefix always means an official model (e.g. `library/qwen3`). Any other
13
+ * prefix is a community publisher's username (e.g. `alibayram/smollm3`).
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Official library model — `library/` prefix identifies it as official.
18
+ * const official: ModelPage = {
19
+ * http_url: 'https://ollama.com/library/qwen3',
20
+ * model_id: 'library/qwen3',
21
+ * };
22
+ *
23
+ * // Community model — prefix is the publisher's username.
24
+ * const community: ModelPage = {
25
+ * http_url: 'https://ollama.com/alibayram/smollm3',
26
+ * model_id: 'alibayram/smollm3',
27
+ * };
28
+ * ```
29
+ */
30
+ interface ModelPage {
31
+ /** Absolute URL of the Ollama model page. */
32
+ http_url: string;
33
+ /**
34
+ * Full model path in `{profile}/{name}` form.
35
+ * `library/` as the profile means an officially maintained Ollama model;
36
+ * any other value is a community publisher's username.
37
+ */
38
+ model_id: string;
39
+ }
40
+ /**
41
+ * Response payload returned by the `GET /search` endpoint.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const result: SearchResult = {
46
+ * pages: [{ http_url: 'https://ollama.com/library/qwen3', model_id: 'library/qwen3' }],
47
+ * page_range: 1,
48
+ * keyword: 'qwen3',
49
+ * };
50
+ *
51
+ * // Multi-page result
52
+ * const multi: SearchResult = {
53
+ * pages: [...],
54
+ * page_range: { from: 1, to: 3 },
55
+ * keyword: 'qwen3',
56
+ * };
57
+ * ```
58
+ */
59
+ interface SearchResult {
60
+ /** Model pages found on the requested search results page. */
61
+ pages: ModelPage[];
62
+ /** The page or range of pages that was requested. */
63
+ page_range: PageRange;
64
+ /** Search keyword used for the request. */
65
+ keyword: string;
66
+ }
67
+ /**
68
+ * Response payload returned by the `GET /model` endpoint.
69
+ *
70
+ * All tags belong to the same model page (`page_url`). The `id` is the
71
+ * full `{profile}/{name}` path without a tag (e.g. `library/qwen3`). To build
72
+ * an Ollama-compatible pull identifier, combine `id` and a tag:
73
+ * `${id}:${tag}`.
74
+ *
75
+ * `default_tag` is `"latest"` when that tag exists on the page, otherwise
76
+ * `null` — in which case the caller must pick an explicit tag from `tags`.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const list: ModelTags = {
81
+ * page_url: 'https://ollama.com/library/qwen3',
82
+ * id: 'library/qwen3',
83
+ * tags: ['qwen3:latest', 'qwen3:4b', 'qwen3:8b'],
84
+ * default_tag: 'qwen3:latest',
85
+ * };
86
+ *
87
+ * // Tags are already pull-ready — use directly:
88
+ * // ollama pull qwen3:latest
89
+ * ```
90
+ */
91
+ interface ModelTags {
92
+ /** Absolute URL of the Ollama model page. */
93
+ page_url: string;
94
+ /**
95
+ * Full model path in `{profile}/{name}` form, without a tag.
96
+ * `library/` as the profile means an officially maintained Ollama model.
97
+ */
98
+ id: string;
99
+ /**
100
+ * Pull-ready identifiers for all available weights, e.g.
101
+ * `['qwen3:latest', 'qwen3:4b']`.
102
+ * Pass any entry directly to `ollama pull`.
103
+ */
104
+ tags: string[];
105
+ /**
106
+ * The pull-ready identifier whose tag is `latest`, e.g. `'qwen3:latest'`.
107
+ * `null` when the model has no `latest` tag — the caller must pick from `tags`.
108
+ */
109
+ default_tag: string | null;
110
+ }
111
+ /** Result of a single scraper probe returned inside {@link HealthStatus}. */
112
+ interface CheckResult {
113
+ /** `true` when the probe returned at least one result without throwing. */
114
+ ok: boolean;
115
+ /** Number of results returned by the probe when the check passed. */
116
+ count?: number;
117
+ /** Stringified error message when the check failed. */
118
+ error?: string;
119
+ }
120
+ /**
121
+ * Response payload returned by the `GET /health` endpoint.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const status: HealthStatus = {
126
+ * ok: true,
127
+ * timestamp: '2025-01-01T00:00:00.000Z',
128
+ * checks: {
129
+ * search: { ok: true, count: 20 },
130
+ * model: { ok: true, count: 15 },
131
+ * },
132
+ * };
133
+ * ```
134
+ */
135
+ interface HealthStatus {
136
+ /** `true` only when every individual check passed. */
137
+ ok: boolean;
138
+ /** ISO 8601 timestamp of when the health check was run. */
139
+ timestamp: string;
140
+ /** Per-scraper probe results. */
141
+ checks: {
142
+ search: CheckResult;
143
+ model: CheckResult;
144
+ };
145
+ }
146
+ //#endregion
147
+ //#region src/client.d.ts
148
+ /**
149
+ * HTTP client for the ollama-models Workers API.
150
+ *
151
+ * Provides a typed, promise-based interface over the `GET /search` and
152
+ * `GET /model` endpoints. Create one instance per application and reuse it.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const client = new OllamaModelsClient();
157
+ *
158
+ * // Search for models
159
+ * const { pages } = await client.search('qwen3');
160
+ * console.log(pages[0].http_url);
161
+ *
162
+ * // Get all available tags
163
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
164
+ * console.log(default_tag); // 'qwen3:latest'
165
+ * ```
166
+ */
167
+ declare class OllamaModelsClient {
168
+ private readonly baseUrl;
169
+ /**
170
+ * @param baseUrl - Base URL of the deployed ollama-models Workers API.
171
+ * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).
172
+ * Trailing slashes are stripped automatically.
173
+ */
174
+ constructor(baseUrl?: string);
175
+ /**
176
+ * Search for models on Ollama.
177
+ *
178
+ * @param keyword - Search term. Pass an empty string to list all models.
179
+ * @param page - 1-based page number. Defaults to `1`.
180
+ * @returns A {@link SearchResult} containing matching model pages and
181
+ * metadata about the requested page.
182
+ * @throws {Error} When the API returns a non-2xx HTTP status.
183
+ * @example
184
+ * ```typescript
185
+ * const { pages, page_range, keyword } = await client.search('qwen3', 1);
186
+ * const firstUrl = pages[0].http_url;
187
+ * ```
188
+ */
189
+ search(keyword?: string, page?: number): Promise<SearchResult>;
190
+ /**
191
+ * Retrieve all available tags (weights) for a model.
192
+ *
193
+ * @param name - Model identifier in `{profile}/{name}` format, e.g.:
194
+ * - `"library/qwen3"` — official Ollama library model
195
+ * - `"RogerBen/qwen3.5-35b-opus-distill"` — community model
196
+ * - `"https://ollama.com/library/qwen3"` — full URL
197
+ * @returns A {@link ModelTags} with all available weights.
198
+ * `default_tag` is `null` when the model has no `latest` tag.
199
+ * @throws {Error} When the API returns a non-2xx HTTP status.
200
+ * @example
201
+ * ```typescript
202
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
203
+ * // Pull the default weight: 'qwen3:latest'
204
+ * ```
205
+ */
206
+ getModel(name: string): Promise<ModelTags>;
207
+ /**
208
+ * Run a live health check against both scrapers.
209
+ *
210
+ * @returns A {@link HealthStatus} with per-scraper probe results and an
211
+ * aggregate `ok` flag.
212
+ * @throws {Error} When the API returns a non-2xx HTTP status.
213
+ * @example
214
+ * ```typescript
215
+ * const { ok, checks } = await client.health();
216
+ * if (!ok) console.error('search error:', checks.search.error);
217
+ * ```
218
+ */
219
+ health(): Promise<HealthStatus>;
220
+ }
221
+ //#endregion
222
+ //#region src/schemas.d.ts
223
+ /**
224
+ * Asserts that `data` conforms to the {@link ModelPage} shape.
225
+ *
226
+ * @param data - Unknown value to validate.
227
+ * @param context - Label used in error messages (defaults to `"ModelPage"`).
228
+ * @throws When any field is missing or has the wrong type.
229
+ */
230
+ declare function assertModelPage(data: unknown, context?: string): asserts data is ModelPage;
231
+ /**
232
+ * Asserts that `data` conforms to the {@link SearchResult} shape.
233
+ *
234
+ * @param data - Unknown value to validate.
235
+ * @throws When any field is missing or has the wrong type.
236
+ */
237
+ declare function assertSearchResult(data: unknown): asserts data is SearchResult;
238
+ /**
239
+ * Asserts that `data` conforms to the {@link ModelTags} shape.
240
+ *
241
+ * @param data - Unknown value to validate.
242
+ * @throws When any field is missing or has the wrong type.
243
+ */
244
+ declare function assertModelTags(data: unknown): asserts data is ModelTags;
245
+ /**
246
+ * Asserts that `data` conforms to the {@link CheckResult} shape.
247
+ *
248
+ * @param data - Unknown value to validate.
249
+ * @param context - Label used in error messages (defaults to `"CheckResult"`).
250
+ * @throws When any field is missing or has the wrong type.
251
+ */
252
+ declare function assertCheckResult(data: unknown, context?: string): asserts data is CheckResult;
253
+ /**
254
+ * Asserts that `data` conforms to the {@link HealthStatus} shape.
255
+ *
256
+ * @param data - Unknown value to validate.
257
+ * @throws When any field is missing or has the wrong type.
258
+ */
259
+ declare function assertHealthStatus(data: unknown): asserts data is HealthStatus;
260
+ //#endregion
261
+ export { type CheckResult, type HealthStatus, type ModelPage, type ModelTags, OllamaModelsClient, type PageRange, type SearchResult, assertCheckResult, assertHealthStatus, assertModelPage, assertModelTags, assertSearchResult };
262
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,262 @@
1
+ //#region src/types.d.ts
2
+ /** A single 1-based page number, or an inclusive `{ from, to }` page range. */
3
+ type PageRange = number | {
4
+ from: number;
5
+ to: number;
6
+ };
7
+ /**
8
+ * A model page discovered from the Ollama search results.
9
+ *
10
+ * `model_id` is the full `{profile}/{name}` path. Ollama uses `library` as the
11
+ * fixed profile name for all officially maintained models, so a `library/`
12
+ * prefix always means an official model (e.g. `library/qwen3`). Any other
13
+ * prefix is a community publisher's username (e.g. `alibayram/smollm3`).
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Official library model — `library/` prefix identifies it as official.
18
+ * const official: ModelPage = {
19
+ * http_url: 'https://ollama.com/library/qwen3',
20
+ * model_id: 'library/qwen3',
21
+ * };
22
+ *
23
+ * // Community model — prefix is the publisher's username.
24
+ * const community: ModelPage = {
25
+ * http_url: 'https://ollama.com/alibayram/smollm3',
26
+ * model_id: 'alibayram/smollm3',
27
+ * };
28
+ * ```
29
+ */
30
+ interface ModelPage {
31
+ /** Absolute URL of the Ollama model page. */
32
+ http_url: string;
33
+ /**
34
+ * Full model path in `{profile}/{name}` form.
35
+ * `library/` as the profile means an officially maintained Ollama model;
36
+ * any other value is a community publisher's username.
37
+ */
38
+ model_id: string;
39
+ }
40
+ /**
41
+ * Response payload returned by the `GET /search` endpoint.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const result: SearchResult = {
46
+ * pages: [{ http_url: 'https://ollama.com/library/qwen3', model_id: 'library/qwen3' }],
47
+ * page_range: 1,
48
+ * keyword: 'qwen3',
49
+ * };
50
+ *
51
+ * // Multi-page result
52
+ * const multi: SearchResult = {
53
+ * pages: [...],
54
+ * page_range: { from: 1, to: 3 },
55
+ * keyword: 'qwen3',
56
+ * };
57
+ * ```
58
+ */
59
+ interface SearchResult {
60
+ /** Model pages found on the requested search results page. */
61
+ pages: ModelPage[];
62
+ /** The page or range of pages that was requested. */
63
+ page_range: PageRange;
64
+ /** Search keyword used for the request. */
65
+ keyword: string;
66
+ }
67
+ /**
68
+ * Response payload returned by the `GET /model` endpoint.
69
+ *
70
+ * All tags belong to the same model page (`page_url`). The `id` is the
71
+ * full `{profile}/{name}` path without a tag (e.g. `library/qwen3`). To build
72
+ * an Ollama-compatible pull identifier, combine `id` and a tag:
73
+ * `${id}:${tag}`.
74
+ *
75
+ * `default_tag` is `"latest"` when that tag exists on the page, otherwise
76
+ * `null` — in which case the caller must pick an explicit tag from `tags`.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const list: ModelTags = {
81
+ * page_url: 'https://ollama.com/library/qwen3',
82
+ * id: 'library/qwen3',
83
+ * tags: ['qwen3:latest', 'qwen3:4b', 'qwen3:8b'],
84
+ * default_tag: 'qwen3:latest',
85
+ * };
86
+ *
87
+ * // Tags are already pull-ready — use directly:
88
+ * // ollama pull qwen3:latest
89
+ * ```
90
+ */
91
+ interface ModelTags {
92
+ /** Absolute URL of the Ollama model page. */
93
+ page_url: string;
94
+ /**
95
+ * Full model path in `{profile}/{name}` form, without a tag.
96
+ * `library/` as the profile means an officially maintained Ollama model.
97
+ */
98
+ id: string;
99
+ /**
100
+ * Pull-ready identifiers for all available weights, e.g.
101
+ * `['qwen3:latest', 'qwen3:4b']`.
102
+ * Pass any entry directly to `ollama pull`.
103
+ */
104
+ tags: string[];
105
+ /**
106
+ * The pull-ready identifier whose tag is `latest`, e.g. `'qwen3:latest'`.
107
+ * `null` when the model has no `latest` tag — the caller must pick from `tags`.
108
+ */
109
+ default_tag: string | null;
110
+ }
111
+ /** Result of a single scraper probe returned inside {@link HealthStatus}. */
112
+ interface CheckResult {
113
+ /** `true` when the probe returned at least one result without throwing. */
114
+ ok: boolean;
115
+ /** Number of results returned by the probe when the check passed. */
116
+ count?: number;
117
+ /** Stringified error message when the check failed. */
118
+ error?: string;
119
+ }
120
+ /**
121
+ * Response payload returned by the `GET /health` endpoint.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const status: HealthStatus = {
126
+ * ok: true,
127
+ * timestamp: '2025-01-01T00:00:00.000Z',
128
+ * checks: {
129
+ * search: { ok: true, count: 20 },
130
+ * model: { ok: true, count: 15 },
131
+ * },
132
+ * };
133
+ * ```
134
+ */
135
+ interface HealthStatus {
136
+ /** `true` only when every individual check passed. */
137
+ ok: boolean;
138
+ /** ISO 8601 timestamp of when the health check was run. */
139
+ timestamp: string;
140
+ /** Per-scraper probe results. */
141
+ checks: {
142
+ search: CheckResult;
143
+ model: CheckResult;
144
+ };
145
+ }
146
+ //#endregion
147
+ //#region src/client.d.ts
148
+ /**
149
+ * HTTP client for the ollama-models Workers API.
150
+ *
151
+ * Provides a typed, promise-based interface over the `GET /search` and
152
+ * `GET /model` endpoints. Create one instance per application and reuse it.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const client = new OllamaModelsClient();
157
+ *
158
+ * // Search for models
159
+ * const { pages } = await client.search('qwen3');
160
+ * console.log(pages[0].http_url);
161
+ *
162
+ * // Get all available tags
163
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
164
+ * console.log(default_tag); // 'qwen3:latest'
165
+ * ```
166
+ */
167
+ declare class OllamaModelsClient {
168
+ private readonly baseUrl;
169
+ /**
170
+ * @param baseUrl - Base URL of the deployed ollama-models Workers API.
171
+ * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).
172
+ * Trailing slashes are stripped automatically.
173
+ */
174
+ constructor(baseUrl?: string);
175
+ /**
176
+ * Search for models on Ollama.
177
+ *
178
+ * @param keyword - Search term. Pass an empty string to list all models.
179
+ * @param page - 1-based page number. Defaults to `1`.
180
+ * @returns A {@link SearchResult} containing matching model pages and
181
+ * metadata about the requested page.
182
+ * @throws {Error} When the API returns a non-2xx HTTP status.
183
+ * @example
184
+ * ```typescript
185
+ * const { pages, page_range, keyword } = await client.search('qwen3', 1);
186
+ * const firstUrl = pages[0].http_url;
187
+ * ```
188
+ */
189
+ search(keyword?: string, page?: number): Promise<SearchResult>;
190
+ /**
191
+ * Retrieve all available tags (weights) for a model.
192
+ *
193
+ * @param name - Model identifier in `{profile}/{name}` format, e.g.:
194
+ * - `"library/qwen3"` — official Ollama library model
195
+ * - `"RogerBen/qwen3.5-35b-opus-distill"` — community model
196
+ * - `"https://ollama.com/library/qwen3"` — full URL
197
+ * @returns A {@link ModelTags} with all available weights.
198
+ * `default_tag` is `null` when the model has no `latest` tag.
199
+ * @throws {Error} When the API returns a non-2xx HTTP status.
200
+ * @example
201
+ * ```typescript
202
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
203
+ * // Pull the default weight: 'qwen3:latest'
204
+ * ```
205
+ */
206
+ getModel(name: string): Promise<ModelTags>;
207
+ /**
208
+ * Run a live health check against both scrapers.
209
+ *
210
+ * @returns A {@link HealthStatus} with per-scraper probe results and an
211
+ * aggregate `ok` flag.
212
+ * @throws {Error} When the API returns a non-2xx HTTP status.
213
+ * @example
214
+ * ```typescript
215
+ * const { ok, checks } = await client.health();
216
+ * if (!ok) console.error('search error:', checks.search.error);
217
+ * ```
218
+ */
219
+ health(): Promise<HealthStatus>;
220
+ }
221
+ //#endregion
222
+ //#region src/schemas.d.ts
223
+ /**
224
+ * Asserts that `data` conforms to the {@link ModelPage} shape.
225
+ *
226
+ * @param data - Unknown value to validate.
227
+ * @param context - Label used in error messages (defaults to `"ModelPage"`).
228
+ * @throws When any field is missing or has the wrong type.
229
+ */
230
+ declare function assertModelPage(data: unknown, context?: string): asserts data is ModelPage;
231
+ /**
232
+ * Asserts that `data` conforms to the {@link SearchResult} shape.
233
+ *
234
+ * @param data - Unknown value to validate.
235
+ * @throws When any field is missing or has the wrong type.
236
+ */
237
+ declare function assertSearchResult(data: unknown): asserts data is SearchResult;
238
+ /**
239
+ * Asserts that `data` conforms to the {@link ModelTags} shape.
240
+ *
241
+ * @param data - Unknown value to validate.
242
+ * @throws When any field is missing or has the wrong type.
243
+ */
244
+ declare function assertModelTags(data: unknown): asserts data is ModelTags;
245
+ /**
246
+ * Asserts that `data` conforms to the {@link CheckResult} shape.
247
+ *
248
+ * @param data - Unknown value to validate.
249
+ * @param context - Label used in error messages (defaults to `"CheckResult"`).
250
+ * @throws When any field is missing or has the wrong type.
251
+ */
252
+ declare function assertCheckResult(data: unknown, context?: string): asserts data is CheckResult;
253
+ /**
254
+ * Asserts that `data` conforms to the {@link HealthStatus} shape.
255
+ *
256
+ * @param data - Unknown value to validate.
257
+ * @throws When any field is missing or has the wrong type.
258
+ */
259
+ declare function assertHealthStatus(data: unknown): asserts data is HealthStatus;
260
+ //#endregion
261
+ export { type CheckResult, type HealthStatus, type ModelPage, type ModelTags, OllamaModelsClient, type PageRange, type SearchResult, assertCheckResult, assertHealthStatus, assertModelPage, assertModelTags, assertSearchResult };
262
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,182 @@
1
+ import { assert } from "es-toolkit/util";
2
+ //#region src/schemas.ts
3
+ function isObject(val) {
4
+ return typeof val === "object" && val !== null && !Array.isArray(val);
5
+ }
6
+ /**
7
+ * Asserts that `data` conforms to the {@link ModelPage} shape.
8
+ *
9
+ * @param data - Unknown value to validate.
10
+ * @param context - Label used in error messages (defaults to `"ModelPage"`).
11
+ * @throws When any field is missing or has the wrong type.
12
+ */
13
+ function assertModelPage(data, context = "ModelPage") {
14
+ assert(isObject(data), `${context}: expected object`);
15
+ assert(typeof data["http_url"] === "string", `${context}.http_url: expected string`);
16
+ assert(typeof data["model_id"] === "string", `${context}.model_id: expected string`);
17
+ }
18
+ /**
19
+ * Asserts that `data` conforms to the {@link SearchResult} shape.
20
+ *
21
+ * @param data - Unknown value to validate.
22
+ * @throws When any field is missing or has the wrong type.
23
+ */
24
+ function assertSearchResult(data) {
25
+ assert(isObject(data), "SearchResult: expected object");
26
+ assert(Array.isArray(data["pages"]), "SearchResult.pages: expected array");
27
+ data["pages"].forEach((p, i) => assertModelPage(p, `SearchResult.pages[${i}]`));
28
+ const pr = data["page_range"];
29
+ assert(typeof pr === "number" || isObject(pr) && typeof pr["from"] === "number" && typeof pr["to"] === "number", "SearchResult.page_range: expected number or { from: number; to: number }");
30
+ assert(typeof data["keyword"] === "string", "SearchResult.keyword: expected string");
31
+ }
32
+ /**
33
+ * Asserts that `data` conforms to the {@link ModelTags} shape.
34
+ *
35
+ * @param data - Unknown value to validate.
36
+ * @throws When any field is missing or has the wrong type.
37
+ */
38
+ function assertModelTags(data) {
39
+ assert(isObject(data), "ModelTags: expected object");
40
+ assert(typeof data["page_url"] === "string", "ModelTags.page_url: expected string");
41
+ assert(typeof data["id"] === "string", "ModelTags.id: expected string");
42
+ assert(Array.isArray(data["tags"]), "ModelTags.tags: expected array");
43
+ data["tags"].forEach((t, i) => assert(typeof t === "string", `ModelTags.tags[${i}]: expected string`));
44
+ assert(data["default_tag"] === null || typeof data["default_tag"] === "string", "ModelTags.default_tag: expected string or null");
45
+ }
46
+ /**
47
+ * Asserts that `data` conforms to the {@link CheckResult} shape.
48
+ *
49
+ * @param data - Unknown value to validate.
50
+ * @param context - Label used in error messages (defaults to `"CheckResult"`).
51
+ * @throws When any field is missing or has the wrong type.
52
+ */
53
+ function assertCheckResult(data, context = "CheckResult") {
54
+ assert(isObject(data), `${context}: expected object`);
55
+ assert(typeof data["ok"] === "boolean", `${context}.ok: expected boolean`);
56
+ if ("count" in data) assert(typeof data["count"] === "number", `${context}.count: expected number`);
57
+ if ("error" in data) assert(typeof data["error"] === "string", `${context}.error: expected string`);
58
+ }
59
+ /**
60
+ * Asserts that `data` conforms to the {@link HealthStatus} shape.
61
+ *
62
+ * @param data - Unknown value to validate.
63
+ * @throws When any field is missing or has the wrong type.
64
+ */
65
+ function assertHealthStatus(data) {
66
+ assert(isObject(data), "HealthStatus: expected object");
67
+ assert(typeof data["ok"] === "boolean", "HealthStatus.ok: expected boolean");
68
+ assert(typeof data["timestamp"] === "string", "HealthStatus.timestamp: expected string");
69
+ assert(isObject(data["checks"]), "HealthStatus.checks: expected object");
70
+ assertCheckResult(data["checks"]["search"], "HealthStatus.checks.search");
71
+ assertCheckResult(data["checks"]["model"], "HealthStatus.checks.model");
72
+ }
73
+ //#endregion
74
+ //#region src/client.ts
75
+ /**
76
+ * Base URL of the officially hosted ollama-models Workers API.
77
+ *
78
+ * Pass a different URL to {@link OllamaModelsClient} when self-hosting.
79
+ */
80
+ const DEFAULT_BASE_URL = "https://ollama.devcomfort.me/api";
81
+ /**
82
+ * HTTP client for the ollama-models Workers API.
83
+ *
84
+ * Provides a typed, promise-based interface over the `GET /search` and
85
+ * `GET /model` endpoints. Create one instance per application and reuse it.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const client = new OllamaModelsClient();
90
+ *
91
+ * // Search for models
92
+ * const { pages } = await client.search('qwen3');
93
+ * console.log(pages[0].http_url);
94
+ *
95
+ * // Get all available tags
96
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
97
+ * console.log(default_tag); // 'qwen3:latest'
98
+ * ```
99
+ */
100
+ var OllamaModelsClient = class {
101
+ baseUrl;
102
+ /**
103
+ * @param baseUrl - Base URL of the deployed ollama-models Workers API.
104
+ * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).
105
+ * Trailing slashes are stripped automatically.
106
+ */
107
+ constructor(baseUrl = DEFAULT_BASE_URL) {
108
+ this.baseUrl = baseUrl.replace(/\/$/, "");
109
+ }
110
+ /**
111
+ * Search for models on Ollama.
112
+ *
113
+ * @param keyword - Search term. Pass an empty string to list all models.
114
+ * @param page - 1-based page number. Defaults to `1`.
115
+ * @returns A {@link SearchResult} containing matching model pages and
116
+ * metadata about the requested page.
117
+ * @throws {Error} When the API returns a non-2xx HTTP status.
118
+ * @example
119
+ * ```typescript
120
+ * const { pages, page_range, keyword } = await client.search('qwen3', 1);
121
+ * const firstUrl = pages[0].http_url;
122
+ * ```
123
+ */
124
+ async search(keyword = "", page = 1) {
125
+ const url = new URL(`${this.baseUrl}/search`);
126
+ if (keyword) url.searchParams.set("q", keyword);
127
+ url.searchParams.set("page", String(page));
128
+ const res = await fetch(url.toString());
129
+ if (!res.ok) throw new Error(`Search failed: HTTP ${res.status}`);
130
+ const data = await res.json();
131
+ assertSearchResult(data);
132
+ return data;
133
+ }
134
+ /**
135
+ * Retrieve all available tags (weights) for a model.
136
+ *
137
+ * @param name - Model identifier in `{profile}/{name}` format, e.g.:
138
+ * - `"library/qwen3"` — official Ollama library model
139
+ * - `"RogerBen/qwen3.5-35b-opus-distill"` — community model
140
+ * - `"https://ollama.com/library/qwen3"` — full URL
141
+ * @returns A {@link ModelTags} with all available weights.
142
+ * `default_tag` is `null` when the model has no `latest` tag.
143
+ * @throws {Error} When the API returns a non-2xx HTTP status.
144
+ * @example
145
+ * ```typescript
146
+ * const { tags, default_tag } = await client.getModel('library/qwen3');
147
+ * // Pull the default weight: 'qwen3:latest'
148
+ * ```
149
+ */
150
+ async getModel(name) {
151
+ const url = new URL(`${this.baseUrl}/model`);
152
+ url.searchParams.set("name", name);
153
+ const res = await fetch(url.toString());
154
+ if (!res.ok) throw new Error(`Model fetch failed: HTTP ${res.status}`);
155
+ const data = await res.json();
156
+ assertModelTags(data);
157
+ return data;
158
+ }
159
+ /**
160
+ * Run a live health check against both scrapers.
161
+ *
162
+ * @returns A {@link HealthStatus} with per-scraper probe results and an
163
+ * aggregate `ok` flag.
164
+ * @throws {Error} When the API returns a non-2xx HTTP status.
165
+ * @example
166
+ * ```typescript
167
+ * const { ok, checks } = await client.health();
168
+ * if (!ok) console.error('search error:', checks.search.error);
169
+ * ```
170
+ */
171
+ async health() {
172
+ const res = await fetch(`${this.baseUrl}/health`);
173
+ if (!res.ok) throw new Error(`Health check failed: HTTP ${res.status}`);
174
+ const data = await res.json();
175
+ assertHealthStatus(data);
176
+ return data;
177
+ }
178
+ };
179
+ //#endregion
180
+ export { OllamaModelsClient, assertCheckResult, assertHealthStatus, assertModelPage, assertModelTags, assertSearchResult };
181
+
182
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/schemas.ts","../src/client.ts"],"sourcesContent":["import { assert } from 'es-toolkit/util';\nimport type { ModelTags, ModelPage, SearchResult, CheckResult, HealthStatus } from './types';\n\n// === helpers ===\n\nfunction isObject(val: unknown): val is Record<string, unknown> {\n return typeof val === 'object' && val !== null && !Array.isArray(val);\n}\n\n// === per-type assertions ===\n\n/**\n * Asserts that `data` conforms to the {@link ModelPage} shape.\n *\n * @param data - Unknown value to validate.\n * @param context - Label used in error messages (defaults to `\"ModelPage\"`).\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertModelPage(\n data: unknown,\n context = 'ModelPage',\n): asserts data is ModelPage {\n assert(isObject(data), `${context}: expected object`);\n assert(typeof data['http_url'] === 'string', `${context}.http_url: expected string`);\n assert(typeof data['model_id'] === 'string', `${context}.model_id: expected string`);\n}\n\n/**\n * Asserts that `data` conforms to the {@link SearchResult} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertSearchResult(data: unknown): asserts data is SearchResult {\n assert(isObject(data), 'SearchResult: expected object');\n assert(Array.isArray(data['pages']), 'SearchResult.pages: expected array');\n (data['pages'] as unknown[]).forEach((p, i) =>\n assertModelPage(p, `SearchResult.pages[${i}]`),\n );\n const pr = data['page_range'];\n assert(\n typeof pr === 'number' ||\n (isObject(pr) && typeof pr['from'] === 'number' && typeof pr['to'] === 'number'),\n 'SearchResult.page_range: expected number or { from: number; to: number }',\n );\n assert(typeof data['keyword'] === 'string', 'SearchResult.keyword: expected string');\n}\n\n/**\n * Asserts that `data` conforms to the {@link ModelTags} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertModelTags(data: unknown): asserts data is ModelTags {\n assert(isObject(data), 'ModelTags: expected object');\n assert(typeof data['page_url'] === 'string', 'ModelTags.page_url: expected string');\n assert(typeof data['id'] === 'string', 'ModelTags.id: expected string');\n assert(Array.isArray(data['tags']), 'ModelTags.tags: expected array');\n (data['tags'] as unknown[]).forEach((t, i) =>\n assert(typeof t === 'string', `ModelTags.tags[${i}]: expected string`),\n );\n assert(\n data['default_tag'] === null || typeof data['default_tag'] === 'string',\n 'ModelTags.default_tag: expected string or null',\n );\n}\n\n/**\n * Asserts that `data` conforms to the {@link CheckResult} shape.\n *\n * @param data - Unknown value to validate.\n * @param context - Label used in error messages (defaults to `\"CheckResult\"`).\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertCheckResult(\n data: unknown,\n context = 'CheckResult',\n): asserts data is CheckResult {\n assert(isObject(data), `${context}: expected object`);\n assert(typeof data['ok'] === 'boolean', `${context}.ok: expected boolean`);\n if ('count' in data) {\n assert(typeof data['count'] === 'number', `${context}.count: expected number`);\n }\n if ('error' in data) {\n assert(typeof data['error'] === 'string', `${context}.error: expected string`);\n }\n}\n\n/**\n * Asserts that `data` conforms to the {@link HealthStatus} shape.\n *\n * @param data - Unknown value to validate.\n * @throws When any field is missing or has the wrong type.\n */\nexport function assertHealthStatus(data: unknown): asserts data is HealthStatus {\n assert(isObject(data), 'HealthStatus: expected object');\n assert(typeof data['ok'] === 'boolean', 'HealthStatus.ok: expected boolean');\n assert(typeof data['timestamp'] === 'string', 'HealthStatus.timestamp: expected string');\n assert(isObject(data['checks']), 'HealthStatus.checks: expected object');\n assertCheckResult(data['checks']['search'], 'HealthStatus.checks.search');\n assertCheckResult(data['checks']['model'], 'HealthStatus.checks.model');\n}\n","import type { SearchResult, ModelTags, HealthStatus } from './types';\nimport { assertModelTags, assertSearchResult, assertHealthStatus } from './schemas';\n\n/**\n * Base URL of the officially hosted ollama-models Workers API.\n *\n * Pass a different URL to {@link OllamaModelsClient} when self-hosting.\n */\nexport const DEFAULT_BASE_URL = 'https://ollama.devcomfort.me/api';\n\n/**\n * HTTP client for the ollama-models Workers API.\n *\n * Provides a typed, promise-based interface over the `GET /search` and\n * `GET /model` endpoints. Create one instance per application and reuse it.\n *\n * @example\n * ```typescript\n * const client = new OllamaModelsClient();\n *\n * // Search for models\n * const { pages } = await client.search('qwen3');\n * console.log(pages[0].http_url);\n *\n * // Get all available tags\n * const { tags, default_tag } = await client.getModel('library/qwen3');\n * console.log(default_tag); // 'qwen3:latest'\n * ```\n */\nexport class OllamaModelsClient {\n private readonly baseUrl: string;\n\n /**\n * @param baseUrl - Base URL of the deployed ollama-models Workers API.\n * Defaults to {@link DEFAULT_BASE_URL} (the official hosted instance).\n * Trailing slashes are stripped automatically.\n */\n constructor(baseUrl: string = DEFAULT_BASE_URL) {\n this.baseUrl = baseUrl.replace(/\\/$/, '');\n }\n\n /**\n * Search for models on Ollama.\n *\n * @param keyword - Search term. Pass an empty string to list all models.\n * @param page - 1-based page number. Defaults to `1`.\n * @returns A {@link SearchResult} containing matching model pages and\n * metadata about the requested page.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { pages, page_range, keyword } = await client.search('qwen3', 1);\n * const firstUrl = pages[0].http_url;\n * ```\n */\n async search(keyword = '', page = 1): Promise<SearchResult> {\n const url = new URL(`${this.baseUrl}/search`);\n if (keyword) url.searchParams.set('q', keyword);\n url.searchParams.set('page', String(page));\n\n const res = await fetch(url.toString());\n if (!res.ok) throw new Error(`Search failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertSearchResult(data);\n return data;\n }\n\n /**\n * Retrieve all available tags (weights) for a model.\n *\n * @param name - Model identifier in `{profile}/{name}` format, e.g.:\n * - `\"library/qwen3\"` — official Ollama library model\n * - `\"RogerBen/qwen3.5-35b-opus-distill\"` — community model\n * - `\"https://ollama.com/library/qwen3\"` — full URL\n * @returns A {@link ModelTags} with all available weights.\n * `default_tag` is `null` when the model has no `latest` tag.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { tags, default_tag } = await client.getModel('library/qwen3');\n * // Pull the default weight: 'qwen3:latest'\n * ```\n */\n async getModel(name: string): Promise<ModelTags> {\n const url = new URL(`${this.baseUrl}/model`);\n url.searchParams.set('name', name);\n\n const res = await fetch(url.toString());\n if (!res.ok) throw new Error(`Model fetch failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertModelTags(data);\n return data;\n }\n\n /**\n * Run a live health check against both scrapers.\n *\n * @returns A {@link HealthStatus} with per-scraper probe results and an\n * aggregate `ok` flag.\n * @throws {Error} When the API returns a non-2xx HTTP status.\n * @example\n * ```typescript\n * const { ok, checks } = await client.health();\n * if (!ok) console.error('search error:', checks.search.error);\n * ```\n */\n async health(): Promise<HealthStatus> {\n const res = await fetch(`${this.baseUrl}/health`);\n if (!res.ok) throw new Error(`Health check failed: HTTP ${res.status}`);\n const data: unknown = await res.json();\n assertHealthStatus(data);\n return data;\n }\n}\n"],"mappings":";;AAKA,SAAS,SAAS,KAA8C;AAC9D,QAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,IAAI;;;;;;;;;AAYvE,SAAgB,gBACd,MACA,UAAU,aACiB;AAC3B,QAAO,SAAS,KAAK,EAAE,GAAG,QAAQ,mBAAmB;AACrD,QAAO,OAAO,KAAK,gBAAgB,UAAU,GAAG,QAAQ,4BAA4B;AACpF,QAA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AI,SAAS;EACvE,MAAM,OAAgB,MAAM,IAAI,MAAM;AACtC,qBAAmB,KAAK;AACxB,SAAO"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "ollama-models",
3
+ "version": "0.2.0",
4
+ "description": "TypeScript/JavaScript client for searching and listing Ollama model weights",
5
+ "keywords": [
6
+ "ollama",
7
+ "llm",
8
+ "models",
9
+ "search",
10
+ "registry"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "devcomfort <im@devcomfort.me>",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/devcomfort/ollama-models"
17
+ },
18
+ "main": "dist/index.cjs",
19
+ "module": "dist/index.mjs",
20
+ "types": "dist/index.d.cts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.cts",
24
+ "import": "./dist/index.mjs",
25
+ "require": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "devDependencies": {
32
+ "tsdown": "^0.21.10",
33
+ "typescript": "^5.0.0",
34
+ "vitest": "^4.1.9"
35
+ },
36
+ "dependencies": {
37
+ "es-toolkit": "^1.45.1"
38
+ },
39
+ "scripts": {
40
+ "build": "tsdown",
41
+ "dev": "tsdown --watch",
42
+ "type-check": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "test:watch": "vitest"
45
+ }
46
+ }