@nemesis-oss/ollama-sdk 1.8.0 → 1.10.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/CHANGELOG.md +182 -0
- package/README.md +247 -11
- package/dist/{anthropic-B_UXplNF.d.ts → anthropic-CPaoxeLX.d.ts} +4 -2
- package/dist/{anthropic-CVDFy_a0.d.cts → anthropic-DuE8M6Tz.d.cts} +4 -2
- package/dist/{compose-DLStUfaF.d.ts → compose-BQYXdpar.d.ts} +1 -1
- package/dist/{compose-DS-UWFx8.d.cts → compose-lt-Qz3lI.d.cts} +1 -1
- package/dist/generated-api.cjs +42 -3
- package/dist/generated-api.cjs.map +1 -1
- package/dist/generated-api.d.cts +96 -6
- package/dist/generated-api.d.ts +96 -6
- package/dist/generated-api.js +41 -4
- package/dist/generated-api.js.map +1 -1
- package/dist/generated-models-schemas.cjs +62 -2
- package/dist/generated-models-schemas.cjs.map +1 -1
- package/dist/generated-models-schemas.d.cts +108 -3
- package/dist/generated-models-schemas.d.ts +108 -3
- package/dist/generated-models-schemas.js +56 -3
- package/dist/generated-models-schemas.js.map +1 -1
- package/dist/generated-runtime.cjs +105 -5
- package/dist/generated-runtime.cjs.map +1 -1
- package/dist/generated-runtime.d.cts +2 -2
- package/dist/generated-runtime.d.ts +2 -2
- package/dist/generated-runtime.js +105 -5
- package/dist/generated-runtime.js.map +1 -1
- package/dist/index.cjs +1644 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1506 -14
- package/dist/index.d.ts +1506 -14
- package/dist/index.js +1607 -55
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.json +43 -24
- package/dist/mcp-generated.cjs +43 -1
- package/dist/mcp-generated.cjs.map +1 -1
- package/dist/mcp-generated.d.cts +2 -2
- package/dist/mcp-generated.d.ts +2 -2
- package/dist/mcp-generated.js +43 -1
- package/dist/mcp-generated.js.map +1 -1
- package/dist/{runtime-C6UYtBRB.d.ts → runtime-BV9SK_cf.d.ts} +69 -2
- package/dist/{runtime-DTmUeU6K.d.cts → runtime-BsdBbuOv.d.cts} +69 -2
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.d.cts +3 -3
- package/dist/skills.d.ts +3 -3
- package/dist/skills.js.map +1 -1
- package/dist/{types-5PAjLoCp.d.cts → types-BtQexFpT.d.cts} +113 -10
- package/dist/{types-5PAjLoCp.d.ts → types-BtQexFpT.d.ts} +113 -10
- package/package.json +11 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-
|
|
1
|
+
export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-BsdBbuOv.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-BtQexFpT.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-
|
|
1
|
+
export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-BV9SK_cf.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-BtQexFpT.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* AUTO-GENERATED by `npm run contract:generate`. DO NOT EDIT.
|
|
@@ -63,6 +63,14 @@ var OllamaClientError = class extends Error {
|
|
|
63
63
|
this.response = options.response;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
+
var OllamaStreamError = class extends OllamaClientError {
|
|
67
|
+
/** Content accumulated before the in-band error frame, or '' if none. */
|
|
68
|
+
partialContent;
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super(message, { ...options, code: "stream_error", retryable: false });
|
|
71
|
+
this.partialContent = options?.partialContent ?? "";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
66
74
|
var OllamaRequestValidationError = class extends OllamaClientError {
|
|
67
75
|
operationId;
|
|
68
76
|
issues;
|
|
@@ -121,6 +129,12 @@ function disposableReader(reader) {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
// src/streaming/ndjson.ts
|
|
132
|
+
function isInBandErrorFrame(value) {
|
|
133
|
+
if (typeof value !== "object" || value === null) return false;
|
|
134
|
+
const record = value;
|
|
135
|
+
if (typeof record.error !== "string" || record.error.length === 0) return false;
|
|
136
|
+
return !("model" in record) && !("response" in record) && !("message" in record) && !("status" in record) && !("done" in record);
|
|
137
|
+
}
|
|
124
138
|
async function* parseNdjsonStream(stream) {
|
|
125
139
|
var _stack = [];
|
|
126
140
|
try {
|
|
@@ -137,17 +151,34 @@ async function* parseNdjsonStream(stream) {
|
|
|
137
151
|
for (const line of lines) {
|
|
138
152
|
const trimmed = line.trim();
|
|
139
153
|
if (!trimmed) continue;
|
|
154
|
+
let json;
|
|
140
155
|
try {
|
|
141
|
-
|
|
156
|
+
json = JSON.parse(trimmed);
|
|
142
157
|
} catch (err) {
|
|
143
158
|
throw new OllamaGenericClientError(`Failed to parse stream JSON chunk: ${trimmed}`, {
|
|
144
159
|
cause: err
|
|
145
160
|
});
|
|
146
161
|
}
|
|
162
|
+
if (isInBandErrorFrame(json)) {
|
|
163
|
+
throw new OllamaStreamError(json.error);
|
|
164
|
+
}
|
|
165
|
+
yield json;
|
|
147
166
|
}
|
|
148
167
|
}
|
|
149
168
|
if (buffer.trim()) {
|
|
150
|
-
|
|
169
|
+
const trimmed = buffer.trim();
|
|
170
|
+
let json;
|
|
171
|
+
try {
|
|
172
|
+
json = JSON.parse(trimmed);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
throw new OllamaGenericClientError(`Failed to parse stream JSON chunk: ${trimmed}`, {
|
|
175
|
+
cause: err
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (isInBandErrorFrame(json)) {
|
|
179
|
+
throw new OllamaStreamError(json.error);
|
|
180
|
+
}
|
|
181
|
+
yield json;
|
|
151
182
|
}
|
|
152
183
|
} catch (_) {
|
|
153
184
|
var _error = _, _hasError = true;
|
|
@@ -248,6 +279,32 @@ async function* parseSseStream(stream) {
|
|
|
248
279
|
_promise && await _promise;
|
|
249
280
|
}
|
|
250
281
|
}
|
|
282
|
+
var IncludedBalanceSchema = z.object({
|
|
283
|
+
balance_usd: z.number(),
|
|
284
|
+
allowance_usd: z.number(),
|
|
285
|
+
period: z.object({
|
|
286
|
+
from: z.string(),
|
|
287
|
+
until: z.string()
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
var LegacyBalanceLimitSchema = z.object({
|
|
291
|
+
remaining_percent: z.number().min(0).max(100),
|
|
292
|
+
resets_at: z.string()
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// src/generated/models/LegacyIncludedBalance.schema.ts
|
|
296
|
+
var LegacyIncludedBalanceSchema = z.object({
|
|
297
|
+
session: LegacyBalanceLimitSchema,
|
|
298
|
+
weekly: LegacyBalanceLimitSchema
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/generated/models/BalanceResponse.schema.ts
|
|
302
|
+
var BalanceResponseSchema = z.object({
|
|
303
|
+
included: z.union([IncludedBalanceSchema, LegacyIncludedBalanceSchema]),
|
|
304
|
+
purchased: z.object({
|
|
305
|
+
balance_usd: z.number()
|
|
306
|
+
})
|
|
307
|
+
});
|
|
251
308
|
var ToolCallSchema = z.object({
|
|
252
309
|
function: z.object({
|
|
253
310
|
name: z.string(),
|
|
@@ -351,6 +408,7 @@ var CreateRequestSchema = z.object({
|
|
|
351
408
|
quantize: z.string().optional(),
|
|
352
409
|
draft_quantize: z.string().optional(),
|
|
353
410
|
requires: z.string().optional(),
|
|
411
|
+
capabilities: z.array(z.string()).optional(),
|
|
354
412
|
stream: z.boolean().optional()
|
|
355
413
|
});
|
|
356
414
|
var DeleteRequestSchema = z.object({
|
|
@@ -413,7 +471,7 @@ var ModelSummarySchema = z.object({
|
|
|
413
471
|
details: z.object({
|
|
414
472
|
format: z.string().optional(),
|
|
415
473
|
family: z.string().optional(),
|
|
416
|
-
families: z.array(z.string()).optional(),
|
|
474
|
+
families: z.union([z.array(z.string()), z.null()]).optional(),
|
|
417
475
|
parameter_size: z.string().optional(),
|
|
418
476
|
quantization_level: z.string().optional()
|
|
419
477
|
}).optional()
|
|
@@ -548,6 +606,34 @@ var SystemOneResponseSchema = z.object({
|
|
|
548
606
|
output_tokens: z.number().min(0)
|
|
549
607
|
})
|
|
550
608
|
});
|
|
609
|
+
var UsageMetricsSchema = z.object({
|
|
610
|
+
request_count: z.number().min(0),
|
|
611
|
+
usage_usd: z.number().optional(),
|
|
612
|
+
input_tokens: z.number().optional(),
|
|
613
|
+
cached_input_tokens: z.number().optional(),
|
|
614
|
+
output_tokens: z.number().optional()
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
// src/generated/models/UsageBucket.schema.ts
|
|
618
|
+
var UsageBucketSchema = z.intersection(
|
|
619
|
+
UsageMetricsSchema,
|
|
620
|
+
z.object({
|
|
621
|
+
from: z.string(),
|
|
622
|
+
until: z.string(),
|
|
623
|
+
partial: z.boolean().optional()
|
|
624
|
+
})
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
// src/generated/models/UsageResponse.schema.ts
|
|
628
|
+
var UsageResponseSchema = z.object({
|
|
629
|
+
range: z.enum(["24h", "7d", "30d"]),
|
|
630
|
+
scope: z.enum(["self", "team"]),
|
|
631
|
+
granularity: z.enum(["hour", "day"]),
|
|
632
|
+
from: z.string(),
|
|
633
|
+
until: z.string(),
|
|
634
|
+
totals: UsageMetricsSchema,
|
|
635
|
+
buckets: z.array(UsageBucketSchema)
|
|
636
|
+
});
|
|
551
637
|
var VersionResponseSchema = z.object({
|
|
552
638
|
version: z.string().optional()
|
|
553
639
|
});
|
|
@@ -590,6 +676,7 @@ var requestSchemas = {
|
|
|
590
676
|
webSearch: WebSearchRequestSchema
|
|
591
677
|
};
|
|
592
678
|
var responseSchemas = {
|
|
679
|
+
balance: BalanceResponseSchema,
|
|
593
680
|
chat: ChatResponseSchema,
|
|
594
681
|
create: StatusResponseSchema,
|
|
595
682
|
embed: EmbedResponseSchema,
|
|
@@ -600,6 +687,7 @@ var responseSchemas = {
|
|
|
600
687
|
show: ShowResponseSchema,
|
|
601
688
|
systemOne: SystemOneResponseSchema,
|
|
602
689
|
tags: ListResponseSchema,
|
|
690
|
+
usage: UsageResponseSchema,
|
|
603
691
|
version: VersionResponseSchema,
|
|
604
692
|
webFetch: WebFetchResponseSchema,
|
|
605
693
|
webSearch: WebSearchResponseSchema
|
|
@@ -650,7 +738,6 @@ var OllamaRuntime = class {
|
|
|
650
738
|
constructor(options) {
|
|
651
739
|
this.options = options;
|
|
652
740
|
}
|
|
653
|
-
options;
|
|
654
741
|
/**
|
|
655
742
|
* Cached promise of the Ollama server version, populated lazily the first
|
|
656
743
|
* time a version-gated operation is invoked. `undefined` until then.
|
|
@@ -727,11 +814,19 @@ var OllamaRuntime = class {
|
|
|
727
814
|
}
|
|
728
815
|
const streaming = shouldStream(req);
|
|
729
816
|
const resolvedPath = resolvePathParams(req.operation.path, req.pathParams);
|
|
817
|
+
const pathWithQuery = applyQueryParams(resolvedPath, req.queryParams);
|
|
730
818
|
const model = req.model ?? extractModelFromBody(body);
|
|
819
|
+
const headers = {};
|
|
820
|
+
if (req.headerParams) {
|
|
821
|
+
for (const [key, value] of Object.entries(req.headerParams)) {
|
|
822
|
+
headers[key] = value;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
731
825
|
const httpReq = {
|
|
732
|
-
path:
|
|
826
|
+
path: pathWithQuery,
|
|
733
827
|
method: req.operation.method,
|
|
734
828
|
...body !== void 0 ? { body } : {},
|
|
829
|
+
...Object.keys(headers).length > 0 ? { headers } : {},
|
|
735
830
|
...req.signal !== void 0 ? { signal: req.signal } : {},
|
|
736
831
|
...streaming ? { raw: true } : {},
|
|
737
832
|
...model !== void 0 ? { model } : {}
|
|
@@ -872,6 +967,11 @@ function extractModelFromBody(body) {
|
|
|
872
967
|
const model = obj.model;
|
|
873
968
|
return typeof model === "string" ? model : void 0;
|
|
874
969
|
}
|
|
970
|
+
function applyQueryParams(path, queryParams) {
|
|
971
|
+
if (!queryParams || Object.keys(queryParams).length === 0) return path;
|
|
972
|
+
const pairs = Object.entries(queryParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
973
|
+
return `${path}?${pairs}`;
|
|
974
|
+
}
|
|
875
975
|
|
|
876
976
|
export { OllamaRuntime, getRequestSchema, getResponseSchema, requestSchemas, responseSchemas };
|
|
877
977
|
//# sourceMappingURL=generated-runtime.js.map
|