@vibecheck-ai/mcp 24.6.8 → 24.6.11

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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/APITruthEngine-IZRR3NT5-LPFUOMLD.js +9 -0
  3. package/dist/CredentialsEngine-B66ANCBB-HY5ZQTSX.js +9 -0
  4. package/dist/EnvVarEngine-ZFNW2XKP-6HRTZULP.js +9 -0
  5. package/dist/ErrorHandlingEngine-VAHVDVFG-3GDGRN3U.js +11 -0
  6. package/dist/FrameworkPackEngine-RRBJW4MC-KH7WRXXS.js +12 -0
  7. package/dist/GhostRouteEngine-UMYBCOCL-MSZOPVZY.js +9 -0
  8. package/dist/LogicGapEngine-OK5UKZQ5-YGXZDERB.js +11 -0
  9. package/dist/PhantomDepEngine-HQEXAS25-TRVEXBMF.js +10 -0
  10. package/dist/SecurityEngine-MVMRPKLH-BNP7IC46.js +9 -0
  11. package/dist/VersionHallucinationEngine-673DJ26J-BD4SK6JX.js +9 -0
  12. package/dist/chokidar-CI5VJY5M.js +2414 -0
  13. package/dist/chunk-43XAAYST.js +863 -0
  14. package/dist/chunk-5DADZJ3D.js +650 -0
  15. package/dist/chunk-DDTUTWRY.js +605 -0
  16. package/dist/chunk-DGNNNAVK.js +304 -0
  17. package/dist/chunk-F34MHA6A.js +772 -0
  18. package/dist/chunk-FGMVY5QW.js +42 -0
  19. package/dist/chunk-G3FQJC2H.js +1968 -0
  20. package/dist/chunk-J52EUKKW.js +196 -0
  21. package/dist/chunk-JZSHXEYP.js +915 -0
  22. package/dist/chunk-LQSBUKYZ.js +551 -0
  23. package/dist/chunk-MUP4JXOF.js +219 -0
  24. package/dist/chunk-NR36RTVO.js +152 -0
  25. package/dist/chunk-QFDZMUGO.js +213300 -0
  26. package/dist/chunk-QGPX6H6L.js +3044 -0
  27. package/dist/chunk-QYXENOVK.js +499 -0
  28. package/dist/chunk-RNFMO5GH.js +8861 -0
  29. package/dist/chunk-RR5ETBSV.js +66 -0
  30. package/dist/chunk-YWUMPN4Z.js +53 -0
  31. package/dist/dist-HFMJ3GIR.js +1091 -0
  32. package/dist/dist-JUOVMQEA.js +9 -0
  33. package/dist/dist-NXITTS32-O3XLWR6T.js +386 -0
  34. package/dist/dist-OUJKMVTB.js +22 -0
  35. package/dist/fingerprint-NOJ7TDB6-K6SB7LCZ.js +9 -0
  36. package/dist/index.js +4735 -3577
  37. package/dist/semantic-WW6XVII4.js +8544 -0
  38. package/dist/transformers.node-K4WKH4PR.js +45809 -0
  39. package/dist/tree-sitter-AGICL65I.js +1412 -0
  40. package/dist/tree-sitter-H5E7LKR4-MKO3NNLJ.js +9 -0
  41. package/package.json +7 -6
@@ -0,0 +1,1091 @@
1
+ import { createRequire } from 'module';
2
+ import { fileURLToPath } from 'url';
3
+ import { dirname, resolve } from 'path';
4
+ import './chunk-YWUMPN4Z.js';
5
+ import fs, { promises } from 'fs';
6
+
7
+ createRequire(import.meta.url);
8
+ const __filename$1 = fileURLToPath(import.meta.url);
9
+ dirname(__filename$1);
10
+
11
+ // ../../node_modules/.pnpm/whatwg-fetch@3.6.20/node_modules/whatwg-fetch/fetch.js
12
+ var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
13
+ typeof global !== "undefined" && global || {};
14
+ var support = {
15
+ searchParams: "URLSearchParams" in g,
16
+ iterable: "Symbol" in g && "iterator" in Symbol,
17
+ blob: "FileReader" in g && "Blob" in g && (function() {
18
+ try {
19
+ new Blob();
20
+ return true;
21
+ } catch (e) {
22
+ return false;
23
+ }
24
+ })(),
25
+ formData: "FormData" in g,
26
+ arrayBuffer: "ArrayBuffer" in g
27
+ };
28
+ function isDataView(obj) {
29
+ return obj && DataView.prototype.isPrototypeOf(obj);
30
+ }
31
+ if (support.arrayBuffer) {
32
+ viewClasses = [
33
+ "[object Int8Array]",
34
+ "[object Uint8Array]",
35
+ "[object Uint8ClampedArray]",
36
+ "[object Int16Array]",
37
+ "[object Uint16Array]",
38
+ "[object Int32Array]",
39
+ "[object Uint32Array]",
40
+ "[object Float32Array]",
41
+ "[object Float64Array]"
42
+ ];
43
+ isArrayBufferView = ArrayBuffer.isView || function(obj) {
44
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
45
+ };
46
+ }
47
+ var viewClasses;
48
+ var isArrayBufferView;
49
+ function normalizeName(name) {
50
+ if (typeof name !== "string") {
51
+ name = String(name);
52
+ }
53
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
54
+ throw new TypeError('Invalid character in header field name: "' + name + '"');
55
+ }
56
+ return name.toLowerCase();
57
+ }
58
+ function normalizeValue(value) {
59
+ if (typeof value !== "string") {
60
+ value = String(value);
61
+ }
62
+ return value;
63
+ }
64
+ function iteratorFor(items) {
65
+ var iterator = {
66
+ next: function() {
67
+ var value = items.shift();
68
+ return { done: value === void 0, value };
69
+ }
70
+ };
71
+ if (support.iterable) {
72
+ iterator[Symbol.iterator] = function() {
73
+ return iterator;
74
+ };
75
+ }
76
+ return iterator;
77
+ }
78
+ function Headers2(headers) {
79
+ this.map = {};
80
+ if (headers instanceof Headers2) {
81
+ headers.forEach(function(value, name) {
82
+ this.append(name, value);
83
+ }, this);
84
+ } else if (Array.isArray(headers)) {
85
+ headers.forEach(function(header) {
86
+ if (header.length != 2) {
87
+ throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
88
+ }
89
+ this.append(header[0], header[1]);
90
+ }, this);
91
+ } else if (headers) {
92
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
93
+ this.append(name, headers[name]);
94
+ }, this);
95
+ }
96
+ }
97
+ Headers2.prototype.append = function(name, value) {
98
+ name = normalizeName(name);
99
+ value = normalizeValue(value);
100
+ var oldValue = this.map[name];
101
+ this.map[name] = oldValue ? oldValue + ", " + value : value;
102
+ };
103
+ Headers2.prototype["delete"] = function(name) {
104
+ delete this.map[normalizeName(name)];
105
+ };
106
+ Headers2.prototype.get = function(name) {
107
+ name = normalizeName(name);
108
+ return this.has(name) ? this.map[name] : null;
109
+ };
110
+ Headers2.prototype.has = function(name) {
111
+ return this.map.hasOwnProperty(normalizeName(name));
112
+ };
113
+ Headers2.prototype.set = function(name, value) {
114
+ this.map[normalizeName(name)] = normalizeValue(value);
115
+ };
116
+ Headers2.prototype.forEach = function(callback, thisArg) {
117
+ for (var name in this.map) {
118
+ if (this.map.hasOwnProperty(name)) {
119
+ callback.call(thisArg, this.map[name], name, this);
120
+ }
121
+ }
122
+ };
123
+ Headers2.prototype.keys = function() {
124
+ var items = [];
125
+ this.forEach(function(value, name) {
126
+ items.push(name);
127
+ });
128
+ return iteratorFor(items);
129
+ };
130
+ Headers2.prototype.values = function() {
131
+ var items = [];
132
+ this.forEach(function(value) {
133
+ items.push(value);
134
+ });
135
+ return iteratorFor(items);
136
+ };
137
+ Headers2.prototype.entries = function() {
138
+ var items = [];
139
+ this.forEach(function(value, name) {
140
+ items.push([name, value]);
141
+ });
142
+ return iteratorFor(items);
143
+ };
144
+ if (support.iterable) {
145
+ Headers2.prototype[Symbol.iterator] = Headers2.prototype.entries;
146
+ }
147
+ function consumed(body) {
148
+ if (body._noBody) return;
149
+ if (body.bodyUsed) {
150
+ return Promise.reject(new TypeError("Already read"));
151
+ }
152
+ body.bodyUsed = true;
153
+ }
154
+ function fileReaderReady(reader) {
155
+ return new Promise(function(resolve2, reject) {
156
+ reader.onload = function() {
157
+ resolve2(reader.result);
158
+ };
159
+ reader.onerror = function() {
160
+ reject(reader.error);
161
+ };
162
+ });
163
+ }
164
+ function readBlobAsArrayBuffer(blob) {
165
+ var reader = new FileReader();
166
+ var promise = fileReaderReady(reader);
167
+ reader.readAsArrayBuffer(blob);
168
+ return promise;
169
+ }
170
+ function readBlobAsText(blob) {
171
+ var reader = new FileReader();
172
+ var promise = fileReaderReady(reader);
173
+ var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
174
+ var encoding = match ? match[1] : "utf-8";
175
+ reader.readAsText(blob, encoding);
176
+ return promise;
177
+ }
178
+ function readArrayBufferAsText(buf) {
179
+ var view = new Uint8Array(buf);
180
+ var chars = new Array(view.length);
181
+ for (var i = 0; i < view.length; i++) {
182
+ chars[i] = String.fromCharCode(view[i]);
183
+ }
184
+ return chars.join("");
185
+ }
186
+ function bufferClone(buf) {
187
+ if (buf.slice) {
188
+ return buf.slice(0);
189
+ } else {
190
+ var view = new Uint8Array(buf.byteLength);
191
+ view.set(new Uint8Array(buf));
192
+ return view.buffer;
193
+ }
194
+ }
195
+ function Body() {
196
+ this.bodyUsed = false;
197
+ this._initBody = function(body) {
198
+ this.bodyUsed = this.bodyUsed;
199
+ this._bodyInit = body;
200
+ if (!body) {
201
+ this._noBody = true;
202
+ this._bodyText = "";
203
+ } else if (typeof body === "string") {
204
+ this._bodyText = body;
205
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
206
+ this._bodyBlob = body;
207
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
208
+ this._bodyFormData = body;
209
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
210
+ this._bodyText = body.toString();
211
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
212
+ this._bodyArrayBuffer = bufferClone(body.buffer);
213
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
214
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
215
+ this._bodyArrayBuffer = bufferClone(body);
216
+ } else {
217
+ this._bodyText = body = Object.prototype.toString.call(body);
218
+ }
219
+ if (!this.headers.get("content-type")) {
220
+ if (typeof body === "string") {
221
+ this.headers.set("content-type", "text/plain;charset=UTF-8");
222
+ } else if (this._bodyBlob && this._bodyBlob.type) {
223
+ this.headers.set("content-type", this._bodyBlob.type);
224
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
225
+ this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
226
+ }
227
+ }
228
+ };
229
+ if (support.blob) {
230
+ this.blob = function() {
231
+ var rejected = consumed(this);
232
+ if (rejected) {
233
+ return rejected;
234
+ }
235
+ if (this._bodyBlob) {
236
+ return Promise.resolve(this._bodyBlob);
237
+ } else if (this._bodyArrayBuffer) {
238
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
239
+ } else if (this._bodyFormData) {
240
+ throw new Error("could not read FormData body as blob");
241
+ } else {
242
+ return Promise.resolve(new Blob([this._bodyText]));
243
+ }
244
+ };
245
+ }
246
+ this.arrayBuffer = function() {
247
+ if (this._bodyArrayBuffer) {
248
+ var isConsumed = consumed(this);
249
+ if (isConsumed) {
250
+ return isConsumed;
251
+ } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
252
+ return Promise.resolve(
253
+ this._bodyArrayBuffer.buffer.slice(
254
+ this._bodyArrayBuffer.byteOffset,
255
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
256
+ )
257
+ );
258
+ } else {
259
+ return Promise.resolve(this._bodyArrayBuffer);
260
+ }
261
+ } else if (support.blob) {
262
+ return this.blob().then(readBlobAsArrayBuffer);
263
+ } else {
264
+ throw new Error("could not read as ArrayBuffer");
265
+ }
266
+ };
267
+ this.text = function() {
268
+ var rejected = consumed(this);
269
+ if (rejected) {
270
+ return rejected;
271
+ }
272
+ if (this._bodyBlob) {
273
+ return readBlobAsText(this._bodyBlob);
274
+ } else if (this._bodyArrayBuffer) {
275
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
276
+ } else if (this._bodyFormData) {
277
+ throw new Error("could not read FormData body as text");
278
+ } else {
279
+ return Promise.resolve(this._bodyText);
280
+ }
281
+ };
282
+ if (support.formData) {
283
+ this.formData = function() {
284
+ return this.text().then(decode);
285
+ };
286
+ }
287
+ this.json = function() {
288
+ return this.text().then(JSON.parse);
289
+ };
290
+ return this;
291
+ }
292
+ var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
293
+ function normalizeMethod(method) {
294
+ var upcased = method.toUpperCase();
295
+ return methods.indexOf(upcased) > -1 ? upcased : method;
296
+ }
297
+ function Request(input, options) {
298
+ if (!(this instanceof Request)) {
299
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
300
+ }
301
+ options = options || {};
302
+ var body = options.body;
303
+ if (input instanceof Request) {
304
+ if (input.bodyUsed) {
305
+ throw new TypeError("Already read");
306
+ }
307
+ this.url = input.url;
308
+ this.credentials = input.credentials;
309
+ if (!options.headers) {
310
+ this.headers = new Headers2(input.headers);
311
+ }
312
+ this.method = input.method;
313
+ this.mode = input.mode;
314
+ this.signal = input.signal;
315
+ if (!body && input._bodyInit != null) {
316
+ body = input._bodyInit;
317
+ input.bodyUsed = true;
318
+ }
319
+ } else {
320
+ this.url = String(input);
321
+ }
322
+ this.credentials = options.credentials || this.credentials || "same-origin";
323
+ if (options.headers || !this.headers) {
324
+ this.headers = new Headers2(options.headers);
325
+ }
326
+ this.method = normalizeMethod(options.method || this.method || "GET");
327
+ this.mode = options.mode || this.mode || null;
328
+ this.signal = options.signal || this.signal || (function() {
329
+ if ("AbortController" in g) {
330
+ var ctrl = new AbortController();
331
+ return ctrl.signal;
332
+ }
333
+ })();
334
+ this.referrer = null;
335
+ if ((this.method === "GET" || this.method === "HEAD") && body) {
336
+ throw new TypeError("Body not allowed for GET or HEAD requests");
337
+ }
338
+ this._initBody(body);
339
+ if (this.method === "GET" || this.method === "HEAD") {
340
+ if (options.cache === "no-store" || options.cache === "no-cache") {
341
+ var reParamSearch = /([?&])_=[^&]*/;
342
+ if (reParamSearch.test(this.url)) {
343
+ this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
344
+ } else {
345
+ var reQueryString = /\?/;
346
+ this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
347
+ }
348
+ }
349
+ }
350
+ }
351
+ Request.prototype.clone = function() {
352
+ return new Request(this, { body: this._bodyInit });
353
+ };
354
+ function decode(body) {
355
+ var form = new FormData();
356
+ body.trim().split("&").forEach(function(bytes) {
357
+ if (bytes) {
358
+ var split = bytes.split("=");
359
+ var name = split.shift().replace(/\+/g, " ");
360
+ var value = split.join("=").replace(/\+/g, " ");
361
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
362
+ }
363
+ });
364
+ return form;
365
+ }
366
+ function parseHeaders(rawHeaders) {
367
+ var headers = new Headers2();
368
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
369
+ preProcessedHeaders.split("\r").map(function(header) {
370
+ return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
371
+ }).forEach(function(line) {
372
+ var parts = line.split(":");
373
+ var key = parts.shift().trim();
374
+ if (key) {
375
+ var value = parts.join(":").trim();
376
+ try {
377
+ headers.append(key, value);
378
+ } catch (error) {
379
+ console.warn("Response " + error.message);
380
+ }
381
+ }
382
+ });
383
+ return headers;
384
+ }
385
+ Body.call(Request.prototype);
386
+ function Response(bodyInit, options) {
387
+ if (!(this instanceof Response)) {
388
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
389
+ }
390
+ if (!options) {
391
+ options = {};
392
+ }
393
+ this.type = "default";
394
+ this.status = options.status === void 0 ? 200 : options.status;
395
+ if (this.status < 200 || this.status > 599) {
396
+ throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
397
+ }
398
+ this.ok = this.status >= 200 && this.status < 300;
399
+ this.statusText = options.statusText === void 0 ? "" : "" + options.statusText;
400
+ this.headers = new Headers2(options.headers);
401
+ this.url = options.url || "";
402
+ this._initBody(bodyInit);
403
+ }
404
+ Body.call(Response.prototype);
405
+ Response.prototype.clone = function() {
406
+ return new Response(this._bodyInit, {
407
+ status: this.status,
408
+ statusText: this.statusText,
409
+ headers: new Headers2(this.headers),
410
+ url: this.url
411
+ });
412
+ };
413
+ Response.error = function() {
414
+ var response = new Response(null, { status: 200, statusText: "" });
415
+ response.ok = false;
416
+ response.status = 0;
417
+ response.type = "error";
418
+ return response;
419
+ };
420
+ var redirectStatuses = [301, 302, 303, 307, 308];
421
+ Response.redirect = function(url, status) {
422
+ if (redirectStatuses.indexOf(status) === -1) {
423
+ throw new RangeError("Invalid status code");
424
+ }
425
+ return new Response(null, { status, headers: { location: url } });
426
+ };
427
+ var DOMException = g.DOMException;
428
+ try {
429
+ new DOMException();
430
+ } catch (err) {
431
+ DOMException = function(message, name) {
432
+ this.message = message;
433
+ this.name = name;
434
+ var error = Error(message);
435
+ this.stack = error.stack;
436
+ };
437
+ DOMException.prototype = Object.create(Error.prototype);
438
+ DOMException.prototype.constructor = DOMException;
439
+ }
440
+ function fetch2(input, init) {
441
+ return new Promise(function(resolve2, reject) {
442
+ var request = new Request(input, init);
443
+ if (request.signal && request.signal.aborted) {
444
+ return reject(new DOMException("Aborted", "AbortError"));
445
+ }
446
+ var xhr = new XMLHttpRequest();
447
+ function abortXhr() {
448
+ xhr.abort();
449
+ }
450
+ xhr.onload = function() {
451
+ var options = {
452
+ statusText: xhr.statusText,
453
+ headers: parseHeaders(xhr.getAllResponseHeaders() || "")
454
+ };
455
+ if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
456
+ options.status = 200;
457
+ } else {
458
+ options.status = xhr.status;
459
+ }
460
+ options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
461
+ var body = "response" in xhr ? xhr.response : xhr.responseText;
462
+ setTimeout(function() {
463
+ resolve2(new Response(body, options));
464
+ }, 0);
465
+ };
466
+ xhr.onerror = function() {
467
+ setTimeout(function() {
468
+ reject(new TypeError("Network request failed"));
469
+ }, 0);
470
+ };
471
+ xhr.ontimeout = function() {
472
+ setTimeout(function() {
473
+ reject(new TypeError("Network request timed out"));
474
+ }, 0);
475
+ };
476
+ xhr.onabort = function() {
477
+ setTimeout(function() {
478
+ reject(new DOMException("Aborted", "AbortError"));
479
+ }, 0);
480
+ };
481
+ function fixUrl(url) {
482
+ try {
483
+ return url === "" && g.location.href ? g.location.href : url;
484
+ } catch (e) {
485
+ return url;
486
+ }
487
+ }
488
+ xhr.open(request.method, fixUrl(request.url), true);
489
+ if (request.credentials === "include") {
490
+ xhr.withCredentials = true;
491
+ } else if (request.credentials === "omit") {
492
+ xhr.withCredentials = false;
493
+ }
494
+ if ("responseType" in xhr) {
495
+ if (support.blob) {
496
+ xhr.responseType = "blob";
497
+ } else if (support.arrayBuffer) {
498
+ xhr.responseType = "arraybuffer";
499
+ }
500
+ }
501
+ if (init && typeof init.headers === "object" && !(init.headers instanceof Headers2 || g.Headers && init.headers instanceof g.Headers)) {
502
+ var names = [];
503
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
504
+ names.push(normalizeName(name));
505
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
506
+ });
507
+ request.headers.forEach(function(value, name) {
508
+ if (names.indexOf(name) === -1) {
509
+ xhr.setRequestHeader(name, value);
510
+ }
511
+ });
512
+ } else {
513
+ request.headers.forEach(function(value, name) {
514
+ xhr.setRequestHeader(name, value);
515
+ });
516
+ }
517
+ if (request.signal) {
518
+ request.signal.addEventListener("abort", abortXhr);
519
+ xhr.onreadystatechange = function() {
520
+ if (xhr.readyState === 4) {
521
+ request.signal.removeEventListener("abort", abortXhr);
522
+ }
523
+ };
524
+ }
525
+ xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
526
+ });
527
+ }
528
+ fetch2.polyfill = true;
529
+ if (!g.fetch) {
530
+ g.fetch = fetch2;
531
+ g.Headers = Headers2;
532
+ g.Request = Request;
533
+ g.Response = Response;
534
+ }
535
+
536
+ // ../../node_modules/.pnpm/ollama@0.6.3/node_modules/ollama/dist/browser.mjs
537
+ var defaultPort = "11434";
538
+ var defaultHost = `http://127.0.0.1:${defaultPort}`;
539
+ var version = "0.6.3";
540
+ var __defProp$1 = Object.defineProperty;
541
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
542
+ var __publicField$1 = (obj, key, value) => {
543
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
544
+ return value;
545
+ };
546
+ var ResponseError = class _ResponseError extends Error {
547
+ constructor(error, status_code) {
548
+ super(error);
549
+ this.error = error;
550
+ this.status_code = status_code;
551
+ this.name = "ResponseError";
552
+ if (Error.captureStackTrace) {
553
+ Error.captureStackTrace(this, _ResponseError);
554
+ }
555
+ }
556
+ };
557
+ var AbortableAsyncIterator = class {
558
+ constructor(abortController, itr, doneCallback) {
559
+ __publicField$1(this, "abortController");
560
+ __publicField$1(this, "itr");
561
+ __publicField$1(this, "doneCallback");
562
+ this.abortController = abortController;
563
+ this.itr = itr;
564
+ this.doneCallback = doneCallback;
565
+ }
566
+ abort() {
567
+ this.abortController.abort();
568
+ }
569
+ async *[Symbol.asyncIterator]() {
570
+ for await (const message of this.itr) {
571
+ if ("error" in message) {
572
+ throw new Error(message.error);
573
+ }
574
+ yield message;
575
+ if (message.done || message.status === "success") {
576
+ this.doneCallback();
577
+ return;
578
+ }
579
+ }
580
+ throw new Error("Did not receive done or success response in stream.");
581
+ }
582
+ };
583
+ var checkOk = async (response) => {
584
+ if (response.ok) {
585
+ return;
586
+ }
587
+ let message = `Error ${response.status}: ${response.statusText}`;
588
+ let errorData = null;
589
+ if (response.headers.get("content-type")?.includes("application/json")) {
590
+ try {
591
+ errorData = await response.json();
592
+ message = errorData.error || message;
593
+ } catch (error) {
594
+ console.log("Failed to parse error response as JSON");
595
+ }
596
+ } else {
597
+ try {
598
+ console.log("Getting text from response");
599
+ const textResponse = await response.text();
600
+ message = textResponse || message;
601
+ } catch (error) {
602
+ console.log("Failed to get text from error response");
603
+ }
604
+ }
605
+ throw new ResponseError(message, response.status);
606
+ };
607
+ function getPlatform() {
608
+ if (typeof window !== "undefined" && window.navigator) {
609
+ const nav = navigator;
610
+ if ("userAgentData" in nav && nav.userAgentData?.platform) {
611
+ return `${nav.userAgentData.platform.toLowerCase()} Browser/${navigator.userAgent};`;
612
+ }
613
+ if (navigator.platform) {
614
+ return `${navigator.platform.toLowerCase()} Browser/${navigator.userAgent};`;
615
+ }
616
+ return `unknown Browser/${navigator.userAgent};`;
617
+ } else if (typeof process !== "undefined") {
618
+ return `${process.arch} ${process.platform} Node.js/${process.version}`;
619
+ }
620
+ return "";
621
+ }
622
+ function normalizeHeaders(headers) {
623
+ if (headers instanceof Headers) {
624
+ const obj = {};
625
+ headers.forEach((value, key) => {
626
+ obj[key] = value;
627
+ });
628
+ return obj;
629
+ } else if (Array.isArray(headers)) {
630
+ return Object.fromEntries(headers);
631
+ } else {
632
+ return headers || {};
633
+ }
634
+ }
635
+ var readEnvVar = (obj, key) => {
636
+ return obj[key];
637
+ };
638
+ var fetchWithHeaders = async (fetch3, url, options = {}) => {
639
+ const defaultHeaders = {
640
+ "Content-Type": "application/json",
641
+ Accept: "application/json",
642
+ "User-Agent": `ollama-js/${version} (${getPlatform()})`
643
+ };
644
+ options.headers = normalizeHeaders(options.headers);
645
+ try {
646
+ const parsed = new URL(url);
647
+ if (parsed.protocol === "https:" && parsed.hostname === "ollama.com") {
648
+ const apiKey = typeof process === "object" && process !== null && typeof process.env === "object" && process.env !== null ? readEnvVar(process.env, "OLLAMA_API_KEY") : void 0;
649
+ const authorization = options.headers["authorization"] || options.headers["Authorization"];
650
+ if (!authorization && apiKey) {
651
+ options.headers["Authorization"] = `Bearer ${apiKey}`;
652
+ }
653
+ }
654
+ } catch (error) {
655
+ console.error("error parsing url", error);
656
+ }
657
+ const customHeaders = Object.fromEntries(
658
+ Object.entries(options.headers).filter(
659
+ ([key]) => !Object.keys(defaultHeaders).some(
660
+ (defaultKey) => defaultKey.toLowerCase() === key.toLowerCase()
661
+ )
662
+ )
663
+ );
664
+ options.headers = {
665
+ ...defaultHeaders,
666
+ ...customHeaders
667
+ };
668
+ return fetch3(url, options);
669
+ };
670
+ var get = async (fetch3, host, options) => {
671
+ const response = await fetchWithHeaders(fetch3, host, {
672
+ headers: options?.headers
673
+ });
674
+ await checkOk(response);
675
+ return response;
676
+ };
677
+ var post = async (fetch3, host, data, options) => {
678
+ const isRecord = (input) => {
679
+ return input !== null && typeof input === "object" && !Array.isArray(input);
680
+ };
681
+ const formattedData = isRecord(data) ? JSON.stringify(data) : data;
682
+ const response = await fetchWithHeaders(fetch3, host, {
683
+ method: "POST",
684
+ body: formattedData,
685
+ signal: options?.signal,
686
+ headers: options?.headers
687
+ });
688
+ await checkOk(response);
689
+ return response;
690
+ };
691
+ var del = async (fetch3, host, data, options) => {
692
+ const response = await fetchWithHeaders(fetch3, host, {
693
+ method: "DELETE",
694
+ body: JSON.stringify(data),
695
+ headers: options?.headers
696
+ });
697
+ await checkOk(response);
698
+ return response;
699
+ };
700
+ var parseJSON = async function* (itr) {
701
+ const decoder = new TextDecoder("utf-8");
702
+ let buffer = "";
703
+ const reader = itr.getReader();
704
+ while (true) {
705
+ const { done, value: chunk } = await reader.read();
706
+ if (done) {
707
+ break;
708
+ }
709
+ buffer += decoder.decode(chunk, { stream: true });
710
+ const parts = buffer.split("\n");
711
+ buffer = parts.pop() ?? "";
712
+ for (const part of parts) {
713
+ try {
714
+ yield JSON.parse(part);
715
+ } catch (error) {
716
+ console.warn("invalid json: ", part);
717
+ }
718
+ }
719
+ }
720
+ buffer += decoder.decode();
721
+ for (const part of buffer.split("\n").filter((p) => p !== "")) {
722
+ try {
723
+ yield JSON.parse(part);
724
+ } catch (error) {
725
+ console.warn("invalid json: ", part);
726
+ }
727
+ }
728
+ };
729
+ var formatHost = (host) => {
730
+ if (!host) {
731
+ return defaultHost;
732
+ }
733
+ let isExplicitProtocol = host.includes("://");
734
+ if (host.startsWith(":")) {
735
+ host = `http://127.0.0.1${host}`;
736
+ isExplicitProtocol = true;
737
+ }
738
+ if (!isExplicitProtocol) {
739
+ host = `http://${host}`;
740
+ }
741
+ const url = new URL(host);
742
+ let port = url.port;
743
+ if (!port) {
744
+ if (!isExplicitProtocol) {
745
+ port = defaultPort;
746
+ } else {
747
+ port = url.protocol === "https:" ? "443" : "80";
748
+ }
749
+ }
750
+ let auth = "";
751
+ if (url.username) {
752
+ auth = url.username;
753
+ if (url.password) {
754
+ auth += `:${url.password}`;
755
+ }
756
+ auth += "@";
757
+ }
758
+ let formattedHost = `${url.protocol}//${auth}${url.hostname}:${port}${url.pathname}`;
759
+ if (formattedHost.endsWith("/")) {
760
+ formattedHost = formattedHost.slice(0, -1);
761
+ }
762
+ return formattedHost;
763
+ };
764
+ var __defProp = Object.defineProperty;
765
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
766
+ var __publicField = (obj, key, value) => {
767
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
768
+ return value;
769
+ };
770
+ var Ollama$1 = class Ollama {
771
+ constructor(config) {
772
+ __publicField(this, "config");
773
+ __publicField(this, "fetch");
774
+ __publicField(this, "ongoingStreamedRequests", []);
775
+ this.config = {
776
+ host: "",
777
+ headers: config?.headers
778
+ };
779
+ if (!config?.proxy) {
780
+ this.config.host = formatHost(config?.host ?? defaultHost);
781
+ }
782
+ this.fetch = config?.fetch ?? fetch;
783
+ }
784
+ // Abort any ongoing streamed requests to Ollama
785
+ abort() {
786
+ for (const request of this.ongoingStreamedRequests) {
787
+ request.abort();
788
+ }
789
+ this.ongoingStreamedRequests.length = 0;
790
+ }
791
+ /**
792
+ * Processes a request to the Ollama server. If the request is streamable, it will return a
793
+ * AbortableAsyncIterator that yields the response messages. Otherwise, it will return the response
794
+ * object.
795
+ * @param endpoint {string} - The endpoint to send the request to.
796
+ * @param request {object} - The request object to send to the endpoint.
797
+ * @protected {T | AbortableAsyncIterator<T>} - The response object or a AbortableAsyncIterator that yields
798
+ * response messages.
799
+ * @throws {Error} - If the response body is missing or if the response is an error.
800
+ * @returns {Promise<T | AbortableAsyncIterator<T>>} - The response object or a AbortableAsyncIterator that yields the streamed response.
801
+ */
802
+ async processStreamableRequest(endpoint, request) {
803
+ request.stream = request.stream ?? false;
804
+ const host = `${this.config.host}/api/${endpoint}`;
805
+ if (request.stream) {
806
+ const abortController = new AbortController();
807
+ const response2 = await post(this.fetch, host, request, {
808
+ signal: abortController.signal,
809
+ headers: this.config.headers
810
+ });
811
+ if (!response2.body) {
812
+ throw new Error("Missing body");
813
+ }
814
+ const itr = parseJSON(response2.body);
815
+ const abortableAsyncIterator = new AbortableAsyncIterator(
816
+ abortController,
817
+ itr,
818
+ () => {
819
+ const i = this.ongoingStreamedRequests.indexOf(abortableAsyncIterator);
820
+ if (i > -1) {
821
+ this.ongoingStreamedRequests.splice(i, 1);
822
+ }
823
+ }
824
+ );
825
+ this.ongoingStreamedRequests.push(abortableAsyncIterator);
826
+ return abortableAsyncIterator;
827
+ }
828
+ const response = await post(this.fetch, host, request, {
829
+ headers: this.config.headers
830
+ });
831
+ return await response.json();
832
+ }
833
+ /**
834
+ * Encodes an image to base64 if it is a Uint8Array.
835
+ * @param image {Uint8Array | string} - The image to encode.
836
+ * @returns {Promise<string>} - The base64 encoded image.
837
+ */
838
+ async encodeImage(image) {
839
+ if (typeof image !== "string") {
840
+ const uint8Array = new Uint8Array(image);
841
+ let byteString = "";
842
+ const len = uint8Array.byteLength;
843
+ for (let i = 0; i < len; i++) {
844
+ byteString += String.fromCharCode(uint8Array[i]);
845
+ }
846
+ return btoa(byteString);
847
+ }
848
+ return image;
849
+ }
850
+ /**
851
+ * Generates a response from a text prompt.
852
+ * @param request {GenerateRequest} - The request object.
853
+ * @returns {Promise<GenerateResponse | AbortableAsyncIterator<GenerateResponse>>} - The response object or
854
+ * an AbortableAsyncIterator that yields response messages.
855
+ */
856
+ async generate(request) {
857
+ if (request.images) {
858
+ request.images = await Promise.all(request.images.map(this.encodeImage.bind(this)));
859
+ }
860
+ return this.processStreamableRequest("generate", request);
861
+ }
862
+ /**
863
+ * Chats with the model. The request object can contain messages with images that are either
864
+ * Uint8Arrays or base64 encoded strings. The images will be base64 encoded before sending the
865
+ * request.
866
+ * @param request {ChatRequest} - The request object.
867
+ * @returns {Promise<ChatResponse | AbortableAsyncIterator<ChatResponse>>} - The response object or an
868
+ * AbortableAsyncIterator that yields response messages.
869
+ */
870
+ async chat(request) {
871
+ if (request.messages) {
872
+ for (const message of request.messages) {
873
+ if (message.images) {
874
+ message.images = await Promise.all(
875
+ message.images.map(this.encodeImage.bind(this))
876
+ );
877
+ }
878
+ }
879
+ }
880
+ return this.processStreamableRequest("chat", request);
881
+ }
882
+ /**
883
+ * Creates a new model from a stream of data.
884
+ * @param request {CreateRequest} - The request object.
885
+ * @returns {Promise<ProgressResponse | AbortableAsyncIterator<ProgressResponse>>} - The response object or a stream of progress responses.
886
+ */
887
+ async create(request) {
888
+ return this.processStreamableRequest("create", {
889
+ ...request
890
+ });
891
+ }
892
+ /**
893
+ * Pulls a model from the Ollama registry. The request object can contain a stream flag to indicate if the
894
+ * response should be streamed.
895
+ * @param request {PullRequest} - The request object.
896
+ * @returns {Promise<ProgressResponse | AbortableAsyncIterator<ProgressResponse>>} - The response object or
897
+ * an AbortableAsyncIterator that yields response messages.
898
+ */
899
+ async pull(request) {
900
+ return this.processStreamableRequest("pull", {
901
+ name: request.model,
902
+ stream: request.stream,
903
+ insecure: request.insecure
904
+ });
905
+ }
906
+ /**
907
+ * Pushes a model to the Ollama registry. The request object can contain a stream flag to indicate if the
908
+ * response should be streamed.
909
+ * @param request {PushRequest} - The request object.
910
+ * @returns {Promise<ProgressResponse | AbortableAsyncIterator<ProgressResponse>>} - The response object or
911
+ * an AbortableAsyncIterator that yields response messages.
912
+ */
913
+ async push(request) {
914
+ return this.processStreamableRequest("push", {
915
+ name: request.model,
916
+ stream: request.stream,
917
+ insecure: request.insecure
918
+ });
919
+ }
920
+ /**
921
+ * Deletes a model from the server. The request object should contain the name of the model to
922
+ * delete.
923
+ * @param request {DeleteRequest} - The request object.
924
+ * @returns {Promise<StatusResponse>} - The response object.
925
+ */
926
+ async delete(request) {
927
+ await del(
928
+ this.fetch,
929
+ `${this.config.host}/api/delete`,
930
+ { name: request.model },
931
+ { headers: this.config.headers }
932
+ );
933
+ return { status: "success" };
934
+ }
935
+ /**
936
+ * Copies a model from one name to another. The request object should contain the name of the
937
+ * model to copy and the new name.
938
+ * @param request {CopyRequest} - The request object.
939
+ * @returns {Promise<StatusResponse>} - The response object.
940
+ */
941
+ async copy(request) {
942
+ await post(this.fetch, `${this.config.host}/api/copy`, { ...request }, {
943
+ headers: this.config.headers
944
+ });
945
+ return { status: "success" };
946
+ }
947
+ /**
948
+ * Lists the models on the server.
949
+ * @returns {Promise<ListResponse>} - The response object.
950
+ * @throws {Error} - If the response body is missing.
951
+ */
952
+ async list() {
953
+ const response = await get(this.fetch, `${this.config.host}/api/tags`, {
954
+ headers: this.config.headers
955
+ });
956
+ return await response.json();
957
+ }
958
+ /**
959
+ * Shows the metadata of a model. The request object should contain the name of the model.
960
+ * @param request {ShowRequest} - The request object.
961
+ * @returns {Promise<ShowResponse>} - The response object.
962
+ */
963
+ async show(request) {
964
+ const response = await post(this.fetch, `${this.config.host}/api/show`, {
965
+ ...request
966
+ }, {
967
+ headers: this.config.headers
968
+ });
969
+ return await response.json();
970
+ }
971
+ /**
972
+ * Embeds text input into vectors.
973
+ * @param request {EmbedRequest} - The request object.
974
+ * @returns {Promise<EmbedResponse>} - The response object.
975
+ */
976
+ async embed(request) {
977
+ const response = await post(this.fetch, `${this.config.host}/api/embed`, {
978
+ ...request
979
+ }, {
980
+ headers: this.config.headers
981
+ });
982
+ return await response.json();
983
+ }
984
+ /**
985
+ * Embeds a text prompt into a vector.
986
+ * @param request {EmbeddingsRequest} - The request object.
987
+ * @returns {Promise<EmbeddingsResponse>} - The response object.
988
+ */
989
+ async embeddings(request) {
990
+ const response = await post(this.fetch, `${this.config.host}/api/embeddings`, {
991
+ ...request
992
+ }, {
993
+ headers: this.config.headers
994
+ });
995
+ return await response.json();
996
+ }
997
+ /**
998
+ * Lists the running models on the server
999
+ * @returns {Promise<ListResponse>} - The response object.
1000
+ * @throws {Error} - If the response body is missing.
1001
+ */
1002
+ async ps() {
1003
+ const response = await get(this.fetch, `${this.config.host}/api/ps`, {
1004
+ headers: this.config.headers
1005
+ });
1006
+ return await response.json();
1007
+ }
1008
+ /**
1009
+ * Returns the Ollama server version.
1010
+ * @returns {Promise<VersionResponse>} - The server version object.
1011
+ */
1012
+ async version() {
1013
+ const response = await get(this.fetch, `${this.config.host}/api/version`, {
1014
+ headers: this.config.headers
1015
+ });
1016
+ return await response.json();
1017
+ }
1018
+ /**
1019
+ * Performs web search using the Ollama web search API
1020
+ * @param request {WebSearchRequest} - The search request containing query and options
1021
+ * @returns {Promise<WebSearchResponse>} - The search results
1022
+ * @throws {Error} - If the request is invalid or the server returns an error
1023
+ */
1024
+ async webSearch(request) {
1025
+ if (!request.query || request.query.length === 0) {
1026
+ throw new Error("Query is required");
1027
+ }
1028
+ const response = await post(this.fetch, `https://ollama.com/api/web_search`, { ...request }, {
1029
+ headers: this.config.headers
1030
+ });
1031
+ return await response.json();
1032
+ }
1033
+ /**
1034
+ * Fetches a single page using the Ollama web fetch API
1035
+ * @param request {WebFetchRequest} - The fetch request containing a URL
1036
+ * @returns {Promise<WebFetchResponse>} - The fetch result
1037
+ * @throws {Error} - If the request is invalid or the server returns an error
1038
+ */
1039
+ async webFetch(request) {
1040
+ if (!request.url || request.url.length === 0) {
1041
+ throw new Error("URL is required");
1042
+ }
1043
+ const response = await post(this.fetch, `https://ollama.com/api/web_fetch`, { ...request }, { headers: this.config.headers });
1044
+ return await response.json();
1045
+ }
1046
+ };
1047
+ new Ollama$1();
1048
+
1049
+ // ../../node_modules/.pnpm/ollama@0.6.3/node_modules/ollama/dist/index.mjs
1050
+ var Ollama2 = class extends Ollama$1 {
1051
+ async encodeImage(image) {
1052
+ if (typeof image !== "string") {
1053
+ return Buffer.from(image).toString("base64");
1054
+ }
1055
+ try {
1056
+ if (fs.existsSync(image)) {
1057
+ const fileBuffer = await promises.readFile(resolve(image));
1058
+ return Buffer.from(fileBuffer).toString("base64");
1059
+ }
1060
+ } catch {
1061
+ }
1062
+ return image;
1063
+ }
1064
+ /**
1065
+ * checks if a file exists
1066
+ * @param path {string} - The path to the file
1067
+ * @private @internal
1068
+ * @returns {Promise<boolean>} - Whether the file exists or not
1069
+ */
1070
+ async fileExists(path) {
1071
+ try {
1072
+ await promises.access(path);
1073
+ return true;
1074
+ } catch {
1075
+ return false;
1076
+ }
1077
+ }
1078
+ async create(request) {
1079
+ if (request.from && await this.fileExists(resolve(request.from))) {
1080
+ throw Error("Creating with a local path is not currently supported from ollama-js");
1081
+ }
1082
+ if (request.stream) {
1083
+ return super.create(request);
1084
+ } else {
1085
+ return super.create(request);
1086
+ }
1087
+ }
1088
+ };
1089
+ var index = new Ollama2();
1090
+
1091
+ export { Ollama2 as Ollama, index as default };