@sourcegraph/cody-web 0.7.3 → 0.7.6

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.
@@ -1,7 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var _a2;
5
4
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6
5
  function getDefaultExportFromCjs(x3) {
7
6
  return x3 && x3.__esModule && Object.prototype.hasOwnProperty.call(x3, "default") ? x3["default"] : x3;
@@ -368,631 +367,1101 @@ var LIB;
368
367
  })(), LIB = n2;
369
368
  })();
370
369
  const { URI, Utils } = LIB;
371
- const defaultAuthStatus = {
372
- endpoint: "",
373
- isDotCom: true,
374
- isLoggedIn: false,
375
- isFireworksTracingEnabled: false,
376
- showInvalidAccessTokenError: false,
377
- authenticated: false,
378
- hasVerifiedEmail: false,
379
- requiresVerifiedEmail: false,
380
- siteHasCodyEnabled: false,
381
- siteVersion: "",
382
- userCanUpgrade: false,
383
- username: "",
384
- codyApiVersion: 0
385
- };
386
- const unauthenticatedStatus = {
387
- endpoint: "",
388
- isDotCom: true,
389
- isLoggedIn: false,
390
- isFireworksTracingEnabled: false,
391
- showInvalidAccessTokenError: true,
392
- authenticated: false,
393
- hasVerifiedEmail: false,
394
- requiresVerifiedEmail: false,
395
- siteHasCodyEnabled: false,
396
- siteVersion: "",
397
- userCanUpgrade: false,
398
- username: "",
399
- codyApiVersion: 0
400
- };
401
- const networkErrorAuthStatus = {
402
- isDotCom: false,
403
- showInvalidAccessTokenError: false,
404
- authenticated: false,
405
- isLoggedIn: false,
406
- isFireworksTracingEnabled: false,
407
- hasVerifiedEmail: false,
408
- showNetworkError: true,
409
- requiresVerifiedEmail: false,
410
- siteHasCodyEnabled: false,
411
- siteVersion: "",
412
- userCanUpgrade: false,
413
- username: "",
414
- codyApiVersion: 0
415
- };
416
- const offlineModeAuthStatus = {
417
- endpoint: "",
418
- isDotCom: true,
419
- isLoggedIn: true,
420
- isOfflineMode: true,
421
- isFireworksTracingEnabled: false,
422
- showInvalidAccessTokenError: false,
423
- authenticated: true,
424
- hasVerifiedEmail: true,
425
- requiresVerifiedEmail: true,
426
- siteHasCodyEnabled: true,
427
- siteVersion: "",
428
- userCanUpgrade: false,
429
- username: "offline",
430
- codyApiVersion: 0
431
- };
432
- function isCodyProUser(authStatus) {
433
- return authStatus.isDotCom && !authStatus.userCanUpgrade;
434
- }
435
- function isEnterpriseUser(authStatus) {
436
- return !authStatus.isDotCom;
437
- }
438
- const CONTEXT_SELECTION_ID = {
439
- none: 0,
440
- embeddings: 1,
441
- keyword: 2,
442
- blended: 10,
443
- unified: 11
444
- };
445
- var CodyIDE = /* @__PURE__ */ ((CodyIDE2) => {
446
- CodyIDE2["VSCode"] = "VSCode";
447
- CodyIDE2["JetBrains"] = "JetBrains";
448
- CodyIDE2["Neovim"] = "Neovim";
449
- CodyIDE2["Emacs"] = "Emacs";
450
- CodyIDE2["Web"] = "Web";
451
- CodyIDE2["VisualStudio"] = "VisualStudio";
452
- CodyIDE2["Eclipse"] = "Eclipse";
453
- return CodyIDE2;
454
- })(CodyIDE || {});
455
- var g$1 = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
456
- typeof global !== "undefined" && global || {};
457
- var support = {
458
- searchParams: "URLSearchParams" in g$1,
459
- iterable: "Symbol" in g$1 && "iterator" in Symbol,
460
- blob: "FileReader" in g$1 && "Blob" in g$1 && function() {
461
- try {
462
- new Blob();
463
- return true;
464
- } catch (e3) {
465
- return false;
466
- }
467
- }(),
468
- formData: "FormData" in g$1,
469
- arrayBuffer: "ArrayBuffer" in g$1
470
- };
471
- function isDataView(obj) {
472
- return obj && DataView.prototype.isPrototypeOf(obj);
473
- }
474
- if (support.arrayBuffer) {
475
- var viewClasses = [
476
- "[object Int8Array]",
477
- "[object Uint8Array]",
478
- "[object Uint8ClampedArray]",
479
- "[object Int16Array]",
480
- "[object Uint16Array]",
481
- "[object Int32Array]",
482
- "[object Uint32Array]",
483
- "[object Float32Array]",
484
- "[object Float64Array]"
485
- ];
486
- var isArrayBufferView = ArrayBuffer.isView || function(obj) {
487
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
488
- };
370
+ const hasSymbols = () => typeof Symbol === "function";
371
+ const hasSymbol = (name) => hasSymbols() && Boolean(Symbol[name]);
372
+ const getSymbol = (name) => hasSymbol(name) ? Symbol[name] : "@@" + name;
373
+ if (!hasSymbol("asyncIterator")) {
374
+ Symbol.asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");
489
375
  }
490
- function normalizeName(name) {
491
- if (typeof name !== "string") {
492
- name = String(name);
493
- }
494
- if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
495
- throw new TypeError('Invalid character in header field name: "' + name + '"');
376
+ const SymbolIterator = getSymbol("iterator");
377
+ const SymbolObservable = getSymbol("observable");
378
+ const SymbolSpecies = getSymbol("species");
379
+ function getMethod(obj, key) {
380
+ const value = obj[key];
381
+ if (value == null) {
382
+ return void 0;
496
383
  }
497
- return name.toLowerCase();
498
- }
499
- function normalizeValue(value) {
500
- if (typeof value !== "string") {
501
- value = String(value);
384
+ if (typeof value !== "function") {
385
+ throw new TypeError(value + " is not a function");
502
386
  }
503
387
  return value;
504
388
  }
505
- function iteratorFor(items) {
506
- var iterator2 = {
507
- next: function() {
508
- var value = items.shift();
509
- return { done: value === void 0, value };
389
+ function getSpecies(obj) {
390
+ let ctor = obj.constructor;
391
+ if (ctor !== void 0) {
392
+ ctor = ctor[SymbolSpecies];
393
+ if (ctor === null) {
394
+ ctor = void 0;
510
395
  }
511
- };
512
- if (support.iterable) {
513
- iterator2[Symbol.iterator] = function() {
514
- return iterator2;
515
- };
516
396
  }
517
- return iterator2;
397
+ return ctor !== void 0 ? ctor : Observable;
518
398
  }
519
- function Headers$1(headers) {
520
- this.map = {};
521
- if (headers instanceof Headers$1) {
522
- headers.forEach(function(value, name) {
523
- this.append(name, value);
524
- }, this);
525
- } else if (Array.isArray(headers)) {
526
- headers.forEach(function(header) {
527
- if (header.length != 2) {
528
- throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
529
- }
530
- this.append(header[0], header[1]);
531
- }, this);
532
- } else if (headers) {
533
- Object.getOwnPropertyNames(headers).forEach(function(name) {
534
- this.append(name, headers[name]);
535
- }, this);
399
+ function isObservable(x3) {
400
+ return x3 instanceof Observable;
401
+ }
402
+ function hostReportError(error2) {
403
+ if (hostReportError.log) {
404
+ hostReportError.log(error2);
405
+ } else {
406
+ setTimeout(() => {
407
+ throw error2;
408
+ }, 0);
536
409
  }
537
410
  }
538
- Headers$1.prototype.append = function(name, value) {
539
- name = normalizeName(name);
540
- value = normalizeValue(value);
541
- var oldValue = this.map[name];
542
- this.map[name] = oldValue ? oldValue + ", " + value : value;
543
- };
544
- Headers$1.prototype["delete"] = function(name) {
545
- delete this.map[normalizeName(name)];
546
- };
547
- Headers$1.prototype.get = function(name) {
548
- name = normalizeName(name);
549
- return this.has(name) ? this.map[name] : null;
550
- };
551
- Headers$1.prototype.has = function(name) {
552
- return this.map.hasOwnProperty(normalizeName(name));
553
- };
554
- Headers$1.prototype.set = function(name, value) {
555
- this.map[normalizeName(name)] = normalizeValue(value);
556
- };
557
- Headers$1.prototype.forEach = function(callback2, thisArg) {
558
- for (var name in this.map) {
559
- if (this.map.hasOwnProperty(name)) {
560
- callback2.call(thisArg, this.map[name], name, this);
411
+ function enqueue(fn) {
412
+ Promise.resolve().then(() => {
413
+ try {
414
+ fn();
415
+ } catch (e3) {
416
+ hostReportError(e3);
561
417
  }
562
- }
563
- };
564
- Headers$1.prototype.keys = function() {
565
- var items = [];
566
- this.forEach(function(value, name) {
567
- items.push(name);
568
- });
569
- return iteratorFor(items);
570
- };
571
- Headers$1.prototype.values = function() {
572
- var items = [];
573
- this.forEach(function(value) {
574
- items.push(value);
575
- });
576
- return iteratorFor(items);
577
- };
578
- Headers$1.prototype.entries = function() {
579
- var items = [];
580
- this.forEach(function(value, name) {
581
- items.push([name, value]);
582
418
  });
583
- return iteratorFor(items);
584
- };
585
- if (support.iterable) {
586
- Headers$1.prototype[Symbol.iterator] = Headers$1.prototype.entries;
587
419
  }
588
- function consumed(body) {
589
- if (body._noBody) return;
590
- if (body.bodyUsed) {
591
- return Promise.reject(new TypeError("Already read"));
420
+ function cleanupSubscription(subscription) {
421
+ const cleanup = subscription._cleanup;
422
+ if (cleanup === void 0) {
423
+ return;
424
+ }
425
+ subscription._cleanup = void 0;
426
+ if (!cleanup) {
427
+ return;
428
+ }
429
+ try {
430
+ if (typeof cleanup === "function") {
431
+ cleanup();
432
+ } else {
433
+ const unsubscribe2 = getMethod(cleanup, "unsubscribe");
434
+ if (unsubscribe2) {
435
+ unsubscribe2.call(cleanup);
436
+ }
437
+ }
438
+ } catch (e3) {
439
+ hostReportError(e3);
592
440
  }
593
- body.bodyUsed = true;
594
- }
595
- function fileReaderReady(reader) {
596
- return new Promise(function(resolve, reject) {
597
- reader.onload = function() {
598
- resolve(reader.result);
599
- };
600
- reader.onerror = function() {
601
- reject(reader.error);
602
- };
603
- });
604
- }
605
- function readBlobAsArrayBuffer(blob) {
606
- var reader = new FileReader();
607
- var promise = fileReaderReady(reader);
608
- reader.readAsArrayBuffer(blob);
609
- return promise;
610
441
  }
611
- function readBlobAsText(blob) {
612
- var reader = new FileReader();
613
- var promise = fileReaderReady(reader);
614
- var match2 = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
615
- var encoding = match2 ? match2[1] : "utf-8";
616
- reader.readAsText(blob, encoding);
617
- return promise;
442
+ function closeSubscription(subscription) {
443
+ subscription._observer = void 0;
444
+ subscription._queue = void 0;
445
+ subscription._state = "closed";
618
446
  }
619
- function readArrayBufferAsText(buf) {
620
- var view = new Uint8Array(buf);
621
- var chars = new Array(view.length);
622
- for (var i3 = 0; i3 < view.length; i3++) {
623
- chars[i3] = String.fromCharCode(view[i3]);
447
+ function flushSubscription(subscription) {
448
+ const queue = subscription._queue;
449
+ if (!queue) {
450
+ return;
624
451
  }
625
- return chars.join("");
626
- }
627
- function bufferClone(buf) {
628
- if (buf.slice) {
629
- return buf.slice(0);
630
- } else {
631
- var view = new Uint8Array(buf.byteLength);
632
- view.set(new Uint8Array(buf));
633
- return view.buffer;
452
+ subscription._queue = void 0;
453
+ subscription._state = "ready";
454
+ for (const item of queue) {
455
+ notifySubscription(subscription, item.type, item.value);
456
+ if (subscription._state === "closed") {
457
+ break;
458
+ }
634
459
  }
635
460
  }
636
- function Body() {
637
- this.bodyUsed = false;
638
- this._initBody = function(body) {
639
- this.bodyUsed = this.bodyUsed;
640
- this._bodyInit = body;
641
- if (!body) {
642
- this._noBody = true;
643
- this._bodyText = "";
644
- } else if (typeof body === "string") {
645
- this._bodyText = body;
646
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
647
- this._bodyBlob = body;
648
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
649
- this._bodyFormData = body;
650
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
651
- this._bodyText = body.toString();
652
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
653
- this._bodyArrayBuffer = bufferClone(body.buffer);
654
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
655
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
656
- this._bodyArrayBuffer = bufferClone(body);
657
- } else {
658
- this._bodyText = body = Object.prototype.toString.call(body);
659
- }
660
- if (!this.headers.get("content-type")) {
661
- if (typeof body === "string") {
662
- this.headers.set("content-type", "text/plain;charset=UTF-8");
663
- } else if (this._bodyBlob && this._bodyBlob.type) {
664
- this.headers.set("content-type", this._bodyBlob.type);
665
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
666
- this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
667
- }
461
+ function notifySubscription(subscription, type, value) {
462
+ subscription._state = "running";
463
+ const observer = subscription._observer;
464
+ try {
465
+ const m4 = observer ? getMethod(observer, type) : void 0;
466
+ switch (type) {
467
+ case "next":
468
+ if (m4)
469
+ m4.call(observer, value);
470
+ break;
471
+ case "error":
472
+ closeSubscription(subscription);
473
+ if (m4)
474
+ m4.call(observer, value);
475
+ else
476
+ throw value;
477
+ break;
478
+ case "complete":
479
+ closeSubscription(subscription);
480
+ if (m4)
481
+ m4.call(observer);
482
+ break;
668
483
  }
669
- };
670
- if (support.blob) {
671
- this.blob = function() {
672
- var rejected = consumed(this);
673
- if (rejected) {
674
- return rejected;
675
- }
676
- if (this._bodyBlob) {
677
- return Promise.resolve(this._bodyBlob);
678
- } else if (this._bodyArrayBuffer) {
679
- return Promise.resolve(new Blob([this._bodyArrayBuffer]));
680
- } else if (this._bodyFormData) {
681
- throw new Error("could not read FormData body as blob");
682
- } else {
683
- return Promise.resolve(new Blob([this._bodyText]));
684
- }
685
- };
484
+ } catch (e3) {
485
+ hostReportError(e3);
686
486
  }
687
- this.arrayBuffer = function() {
688
- if (this._bodyArrayBuffer) {
689
- var isConsumed = consumed(this);
690
- if (isConsumed) {
691
- return isConsumed;
692
- } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
693
- return Promise.resolve(
694
- this._bodyArrayBuffer.buffer.slice(
695
- this._bodyArrayBuffer.byteOffset,
696
- this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
697
- )
698
- );
699
- } else {
700
- return Promise.resolve(this._bodyArrayBuffer);
701
- }
702
- } else if (support.blob) {
703
- return this.blob().then(readBlobAsArrayBuffer);
704
- } else {
705
- throw new Error("could not read as ArrayBuffer");
706
- }
707
- };
708
- this.text = function() {
709
- var rejected = consumed(this);
710
- if (rejected) {
711
- return rejected;
712
- }
713
- if (this._bodyBlob) {
714
- return readBlobAsText(this._bodyBlob);
715
- } else if (this._bodyArrayBuffer) {
716
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
717
- } else if (this._bodyFormData) {
718
- throw new Error("could not read FormData body as text");
719
- } else {
720
- return Promise.resolve(this._bodyText);
721
- }
722
- };
723
- if (support.formData) {
724
- this.formData = function() {
725
- return this.text().then(decode);
726
- };
487
+ if (subscription._state === "closed") {
488
+ cleanupSubscription(subscription);
489
+ } else if (subscription._state === "running") {
490
+ subscription._state = "ready";
727
491
  }
728
- this.json = function() {
729
- return this.text().then(JSON.parse);
730
- };
731
- return this;
732
- }
733
- var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
734
- function normalizeMethod(method) {
735
- var upcased = method.toUpperCase();
736
- return methods.indexOf(upcased) > -1 ? upcased : method;
737
492
  }
738
- function Request(input, options) {
739
- if (!(this instanceof Request)) {
740
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
493
+ function onNotify(subscription, type, value) {
494
+ if (subscription._state === "closed") {
495
+ return;
741
496
  }
742
- options = options || {};
743
- var body = options.body;
744
- if (input instanceof Request) {
745
- if (input.bodyUsed) {
746
- throw new TypeError("Already read");
497
+ if (subscription._state === "buffering") {
498
+ subscription._queue = subscription._queue || [];
499
+ subscription._queue.push({ type, value });
500
+ return;
501
+ }
502
+ if (subscription._state !== "ready") {
503
+ subscription._state = "buffering";
504
+ subscription._queue = [{ type, value }];
505
+ enqueue(() => flushSubscription(subscription));
506
+ return;
507
+ }
508
+ notifySubscription(subscription, type, value);
509
+ }
510
+ class Subscription {
511
+ constructor(observer, subscriber) {
512
+ this._cleanup = void 0;
513
+ this._observer = observer;
514
+ this._queue = void 0;
515
+ this._state = "initializing";
516
+ const subscriptionObserver = new SubscriptionObserver(this);
517
+ try {
518
+ this._cleanup = subscriber.call(void 0, subscriptionObserver);
519
+ } catch (e3) {
520
+ subscriptionObserver.error(e3);
747
521
  }
748
- this.url = input.url;
749
- this.credentials = input.credentials;
750
- if (!options.headers) {
751
- this.headers = new Headers$1(input.headers);
522
+ if (this._state === "initializing") {
523
+ this._state = "ready";
752
524
  }
753
- this.method = input.method;
754
- this.mode = input.mode;
755
- this.signal = input.signal;
756
- if (!body && input._bodyInit != null) {
757
- body = input._bodyInit;
758
- input.bodyUsed = true;
525
+ }
526
+ get closed() {
527
+ return this._state === "closed";
528
+ }
529
+ unsubscribe() {
530
+ if (this._state !== "closed") {
531
+ closeSubscription(this);
532
+ cleanupSubscription(this);
759
533
  }
760
- } else {
761
- this.url = String(input);
762
534
  }
763
- this.credentials = options.credentials || this.credentials || "same-origin";
764
- if (options.headers || !this.headers) {
765
- this.headers = new Headers$1(options.headers);
535
+ }
536
+ class SubscriptionObserver {
537
+ constructor(subscription) {
538
+ this._subscription = subscription;
766
539
  }
767
- this.method = normalizeMethod(options.method || this.method || "GET");
768
- this.mode = options.mode || this.mode || null;
769
- this.signal = options.signal || this.signal || function() {
770
- if ("AbortController" in g$1) {
771
- var ctrl = new AbortController();
772
- return ctrl.signal;
540
+ get closed() {
541
+ return this._subscription._state === "closed";
542
+ }
543
+ next(value) {
544
+ onNotify(this._subscription, "next", value);
545
+ }
546
+ error(value) {
547
+ onNotify(this._subscription, "error", value);
548
+ }
549
+ complete() {
550
+ onNotify(this._subscription, "complete");
551
+ }
552
+ }
553
+ class Observable {
554
+ constructor(subscriber) {
555
+ if (!(this instanceof Observable)) {
556
+ throw new TypeError("Observable cannot be called as a function");
773
557
  }
774
- }();
775
- this.referrer = null;
776
- if ((this.method === "GET" || this.method === "HEAD") && body) {
777
- throw new TypeError("Body not allowed for GET or HEAD requests");
558
+ if (typeof subscriber !== "function") {
559
+ throw new TypeError("Observable initializer must be a function");
560
+ }
561
+ this._subscriber = subscriber;
778
562
  }
779
- this._initBody(body);
780
- if (this.method === "GET" || this.method === "HEAD") {
781
- if (options.cache === "no-store" || options.cache === "no-cache") {
782
- var reParamSearch = /([?&])_=[^&]*/;
783
- if (reParamSearch.test(this.url)) {
784
- this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
785
- } else {
786
- var reQueryString = /\?/;
787
- this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
788
- }
563
+ subscribe(nextOrObserver, onError, onComplete) {
564
+ if (typeof nextOrObserver !== "object" || nextOrObserver === null) {
565
+ nextOrObserver = {
566
+ next: nextOrObserver,
567
+ error: onError,
568
+ complete: onComplete
569
+ };
789
570
  }
571
+ return new Subscription(nextOrObserver, this._subscriber);
790
572
  }
791
- }
792
- Request.prototype.clone = function() {
793
- return new Request(this, { body: this._bodyInit });
794
- };
795
- function decode(body) {
796
- var form = new FormData();
797
- body.trim().split("&").forEach(function(bytes) {
798
- if (bytes) {
799
- var split = bytes.split("=");
800
- var name = split.shift().replace(/\+/g, " ");
801
- var value = split.join("=").replace(/\+/g, " ");
802
- form.append(decodeURIComponent(name), decodeURIComponent(value));
573
+ pipe(first, ...mappers) {
574
+ let intermediate = this;
575
+ for (const mapper of [first, ...mappers]) {
576
+ intermediate = mapper(intermediate);
803
577
  }
804
- });
805
- return form;
806
- }
807
- function parseHeaders(rawHeaders) {
808
- var headers = new Headers$1();
809
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
810
- preProcessedHeaders.split("\r").map(function(header) {
811
- return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
812
- }).forEach(function(line) {
813
- var parts = line.split(":");
814
- var key = parts.shift().trim();
815
- if (key) {
816
- var value = parts.join(":").trim();
817
- try {
818
- headers.append(key, value);
819
- } catch (error2) {
820
- console.warn("Response " + error2.message);
821
- }
822
- }
823
- });
824
- return headers;
825
- }
826
- Body.call(Request.prototype);
827
- function Response(bodyInit, options) {
828
- if (!(this instanceof Response)) {
829
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
830
- }
831
- if (!options) {
832
- options = {};
833
- }
834
- this.type = "default";
835
- this.status = options.status === void 0 ? 200 : options.status;
836
- if (this.status < 200 || this.status > 599) {
837
- throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
578
+ return intermediate;
838
579
  }
839
- this.ok = this.status >= 200 && this.status < 300;
840
- this.statusText = options.statusText === void 0 ? "" : "" + options.statusText;
841
- this.headers = new Headers$1(options.headers);
842
- this.url = options.url || "";
843
- this._initBody(bodyInit);
844
- }
845
- Body.call(Response.prototype);
846
- Response.prototype.clone = function() {
847
- return new Response(this._bodyInit, {
848
- status: this.status,
849
- statusText: this.statusText,
850
- headers: new Headers$1(this.headers),
851
- url: this.url
852
- });
853
- };
854
- Response.error = function() {
855
- var response = new Response(null, { status: 200, statusText: "" });
856
- response.ok = false;
857
- response.status = 0;
858
- response.type = "error";
859
- return response;
860
- };
861
- var redirectStatuses = [301, 302, 303, 307, 308];
862
- Response.redirect = function(url, status) {
863
- if (redirectStatuses.indexOf(status) === -1) {
864
- throw new RangeError("Invalid status code");
580
+ tap(nextOrObserver, onError, onComplete) {
581
+ const tapObserver = typeof nextOrObserver !== "object" || nextOrObserver === null ? {
582
+ next: nextOrObserver,
583
+ error: onError,
584
+ complete: onComplete
585
+ } : nextOrObserver;
586
+ return new Observable((observer) => {
587
+ return this.subscribe({
588
+ next(value) {
589
+ tapObserver.next && tapObserver.next(value);
590
+ observer.next(value);
591
+ },
592
+ error(error2) {
593
+ tapObserver.error && tapObserver.error(error2);
594
+ observer.error(error2);
595
+ },
596
+ complete() {
597
+ tapObserver.complete && tapObserver.complete();
598
+ observer.complete();
599
+ },
600
+ start(subscription) {
601
+ tapObserver.start && tapObserver.start(subscription);
602
+ }
603
+ });
604
+ });
865
605
  }
866
- return new Response(null, { status, headers: { location: url } });
867
- };
868
- var DOMException = g$1.DOMException;
869
- try {
870
- new DOMException();
871
- } catch (err) {
872
- DOMException = function(message, name) {
873
- this.message = message;
874
- this.name = name;
875
- var error2 = Error(message);
876
- this.stack = error2.stack;
877
- };
878
- DOMException.prototype = Object.create(Error.prototype);
879
- DOMException.prototype.constructor = DOMException;
880
- }
881
- function fetch$1(input, init) {
882
- return new Promise(function(resolve, reject) {
883
- var request = new Request(input, init);
884
- if (request.signal && request.signal.aborted) {
885
- return reject(new DOMException("Aborted", "AbortError"));
886
- }
887
- var xhr = new XMLHttpRequest();
888
- function abortXhr() {
889
- xhr.abort();
890
- }
891
- xhr.onload = function() {
892
- var options = {
893
- statusText: xhr.statusText,
894
- headers: parseHeaders(xhr.getAllResponseHeaders() || "")
895
- };
896
- if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
897
- options.status = 200;
898
- } else {
899
- options.status = xhr.status;
900
- }
901
- options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
902
- var body = "response" in xhr ? xhr.response : xhr.responseText;
903
- setTimeout(function() {
904
- resolve(new Response(body, options));
905
- }, 0);
906
- };
907
- xhr.onerror = function() {
908
- setTimeout(function() {
909
- reject(new TypeError("Network request failed"));
910
- }, 0);
911
- };
912
- xhr.ontimeout = function() {
913
- setTimeout(function() {
914
- reject(new TypeError("Network request timed out"));
915
- }, 0);
916
- };
917
- xhr.onabort = function() {
918
- setTimeout(function() {
919
- reject(new DOMException("Aborted", "AbortError"));
920
- }, 0);
921
- };
922
- function fixUrl(url) {
923
- try {
924
- return url === "" && g$1.location.href ? g$1.location.href : url;
925
- } catch (e3) {
926
- return url;
606
+ forEach(fn) {
607
+ return new Promise((resolve, reject) => {
608
+ if (typeof fn !== "function") {
609
+ reject(new TypeError(fn + " is not a function"));
610
+ return;
927
611
  }
928
- }
929
- xhr.open(request.method, fixUrl(request.url), true);
930
- if (request.credentials === "include") {
931
- xhr.withCredentials = true;
932
- } else if (request.credentials === "omit") {
933
- xhr.withCredentials = false;
934
- }
935
- if ("responseType" in xhr) {
936
- if (support.blob) {
937
- xhr.responseType = "blob";
938
- } else if (support.arrayBuffer) {
939
- xhr.responseType = "arraybuffer";
612
+ function done() {
613
+ subscription.unsubscribe();
614
+ resolve(void 0);
940
615
  }
941
- }
942
- if (init && typeof init.headers === "object" && !(init.headers instanceof Headers$1 || g$1.Headers && init.headers instanceof g$1.Headers)) {
943
- var names = [];
944
- Object.getOwnPropertyNames(init.headers).forEach(function(name) {
945
- names.push(normalizeName(name));
946
- xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
947
- });
948
- request.headers.forEach(function(value, name) {
949
- if (names.indexOf(name) === -1) {
950
- xhr.setRequestHeader(name, value);
616
+ const subscription = this.subscribe({
617
+ next(value) {
618
+ try {
619
+ fn(value, done);
620
+ } catch (e3) {
621
+ reject(e3);
622
+ subscription.unsubscribe();
623
+ }
624
+ },
625
+ error(error2) {
626
+ reject(error2);
627
+ },
628
+ complete() {
629
+ resolve(void 0);
951
630
  }
952
631
  });
953
- } else {
954
- request.headers.forEach(function(value, name) {
955
- xhr.setRequestHeader(name, value);
956
- });
632
+ });
633
+ }
634
+ map(fn) {
635
+ if (typeof fn !== "function") {
636
+ throw new TypeError(fn + " is not a function");
957
637
  }
958
- if (request.signal) {
959
- request.signal.addEventListener("abort", abortXhr);
960
- xhr.onreadystatechange = function() {
961
- if (xhr.readyState === 4) {
962
- request.signal.removeEventListener("abort", abortXhr);
638
+ const C2 = getSpecies(this);
639
+ return new C2((observer) => this.subscribe({
640
+ next(value) {
641
+ let propagatedValue = value;
642
+ try {
643
+ propagatedValue = fn(value);
644
+ } catch (e3) {
645
+ return observer.error(e3);
963
646
  }
964
- };
647
+ observer.next(propagatedValue);
648
+ },
649
+ error(e3) {
650
+ observer.error(e3);
651
+ },
652
+ complete() {
653
+ observer.complete();
654
+ }
655
+ }));
656
+ }
657
+ filter(fn) {
658
+ if (typeof fn !== "function") {
659
+ throw new TypeError(fn + " is not a function");
965
660
  }
966
- xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
967
- });
968
- }
969
- fetch$1.polyfill = true;
970
- if (!g$1.fetch) {
971
- g$1.fetch = fetch$1;
972
- g$1.Headers = Headers$1;
973
- g$1.Request = Request;
974
- g$1.Response = Response;
975
- }
976
- var lodash = { exports: {} };
977
- /**
978
- * @license
979
- * Lodash <https://lodash.com/>
980
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
981
- * Released under MIT license <https://lodash.com/license>
982
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
983
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
984
- */
985
- lodash.exports;
986
- (function(module, exports) {
987
- (function() {
988
- var undefined$1;
989
- var VERSION2 = "4.17.21";
990
- var LARGE_ARRAY_SIZE2 = 200;
991
- var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
992
- var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
993
- var MAX_MEMOIZE_SIZE = 500;
994
- var PLACEHOLDER = "__lodash_placeholder__";
995
- var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
661
+ const C2 = getSpecies(this);
662
+ return new C2((observer) => this.subscribe({
663
+ next(value) {
664
+ try {
665
+ if (!fn(value))
666
+ return;
667
+ } catch (e3) {
668
+ return observer.error(e3);
669
+ }
670
+ observer.next(value);
671
+ },
672
+ error(e3) {
673
+ observer.error(e3);
674
+ },
675
+ complete() {
676
+ observer.complete();
677
+ }
678
+ }));
679
+ }
680
+ reduce(fn, seed) {
681
+ if (typeof fn !== "function") {
682
+ throw new TypeError(fn + " is not a function");
683
+ }
684
+ const C2 = getSpecies(this);
685
+ const hasSeed = arguments.length > 1;
686
+ let hasValue = false;
687
+ let acc = seed;
688
+ return new C2((observer) => this.subscribe({
689
+ next(value) {
690
+ const first = !hasValue;
691
+ hasValue = true;
692
+ if (!first || hasSeed) {
693
+ try {
694
+ acc = fn(acc, value);
695
+ } catch (e3) {
696
+ return observer.error(e3);
697
+ }
698
+ } else {
699
+ acc = value;
700
+ }
701
+ },
702
+ error(e3) {
703
+ observer.error(e3);
704
+ },
705
+ complete() {
706
+ if (!hasValue && !hasSeed) {
707
+ return observer.error(new TypeError("Cannot reduce an empty sequence"));
708
+ }
709
+ observer.next(acc);
710
+ observer.complete();
711
+ }
712
+ }));
713
+ }
714
+ concat(...sources) {
715
+ const C2 = getSpecies(this);
716
+ return new C2((observer) => {
717
+ let subscription;
718
+ let index = 0;
719
+ function startNext(next) {
720
+ subscription = next.subscribe({
721
+ next(v2) {
722
+ observer.next(v2);
723
+ },
724
+ error(e3) {
725
+ observer.error(e3);
726
+ },
727
+ complete() {
728
+ if (index === sources.length) {
729
+ subscription = void 0;
730
+ observer.complete();
731
+ } else {
732
+ startNext(C2.from(sources[index++]));
733
+ }
734
+ }
735
+ });
736
+ }
737
+ startNext(this);
738
+ return () => {
739
+ if (subscription) {
740
+ subscription.unsubscribe();
741
+ subscription = void 0;
742
+ }
743
+ };
744
+ });
745
+ }
746
+ flatMap(fn) {
747
+ if (typeof fn !== "function") {
748
+ throw new TypeError(fn + " is not a function");
749
+ }
750
+ const C2 = getSpecies(this);
751
+ return new C2((observer) => {
752
+ const subscriptions = [];
753
+ const outer = this.subscribe({
754
+ next(value) {
755
+ let normalizedValue;
756
+ if (fn) {
757
+ try {
758
+ normalizedValue = fn(value);
759
+ } catch (e3) {
760
+ return observer.error(e3);
761
+ }
762
+ } else {
763
+ normalizedValue = value;
764
+ }
765
+ const inner = C2.from(normalizedValue).subscribe({
766
+ next(innerValue) {
767
+ observer.next(innerValue);
768
+ },
769
+ error(e3) {
770
+ observer.error(e3);
771
+ },
772
+ complete() {
773
+ const i3 = subscriptions.indexOf(inner);
774
+ if (i3 >= 0)
775
+ subscriptions.splice(i3, 1);
776
+ completeIfDone();
777
+ }
778
+ });
779
+ subscriptions.push(inner);
780
+ },
781
+ error(e3) {
782
+ observer.error(e3);
783
+ },
784
+ complete() {
785
+ completeIfDone();
786
+ }
787
+ });
788
+ function completeIfDone() {
789
+ if (outer.closed && subscriptions.length === 0) {
790
+ observer.complete();
791
+ }
792
+ }
793
+ return () => {
794
+ subscriptions.forEach((s4) => s4.unsubscribe());
795
+ outer.unsubscribe();
796
+ };
797
+ });
798
+ }
799
+ [SymbolObservable]() {
800
+ return this;
801
+ }
802
+ static from(x3) {
803
+ const C2 = typeof this === "function" ? this : Observable;
804
+ if (x3 == null) {
805
+ throw new TypeError(x3 + " is not an object");
806
+ }
807
+ const observableMethod = getMethod(x3, SymbolObservable);
808
+ if (observableMethod) {
809
+ const observable = observableMethod.call(x3);
810
+ if (Object(observable) !== observable) {
811
+ throw new TypeError(observable + " is not an object");
812
+ }
813
+ if (isObservable(observable) && observable.constructor === C2) {
814
+ return observable;
815
+ }
816
+ return new C2((observer) => observable.subscribe(observer));
817
+ }
818
+ if (hasSymbol("iterator")) {
819
+ const iteratorMethod = getMethod(x3, SymbolIterator);
820
+ if (iteratorMethod) {
821
+ return new C2((observer) => {
822
+ enqueue(() => {
823
+ if (observer.closed)
824
+ return;
825
+ for (const item of iteratorMethod.call(x3)) {
826
+ observer.next(item);
827
+ if (observer.closed)
828
+ return;
829
+ }
830
+ observer.complete();
831
+ });
832
+ });
833
+ }
834
+ }
835
+ if (Array.isArray(x3)) {
836
+ return new C2((observer) => {
837
+ enqueue(() => {
838
+ if (observer.closed)
839
+ return;
840
+ for (const item of x3) {
841
+ observer.next(item);
842
+ if (observer.closed)
843
+ return;
844
+ }
845
+ observer.complete();
846
+ });
847
+ });
848
+ }
849
+ throw new TypeError(x3 + " is not observable");
850
+ }
851
+ static of(...items) {
852
+ const C2 = typeof this === "function" ? this : Observable;
853
+ return new C2((observer) => {
854
+ enqueue(() => {
855
+ if (observer.closed)
856
+ return;
857
+ for (const item of items) {
858
+ observer.next(item);
859
+ if (observer.closed)
860
+ return;
861
+ }
862
+ observer.complete();
863
+ });
864
+ });
865
+ }
866
+ static get [SymbolSpecies]() {
867
+ return this;
868
+ }
869
+ }
870
+ if (hasSymbols()) {
871
+ Object.defineProperty(Observable, Symbol("extensions"), {
872
+ value: {
873
+ symbol: SymbolObservable,
874
+ hostReportError
875
+ },
876
+ configurable: true
877
+ });
878
+ }
879
+ function unsubscribe(subscription) {
880
+ if (typeof subscription === "function") {
881
+ subscription();
882
+ } else if (subscription && typeof subscription.unsubscribe === "function") {
883
+ subscription.unsubscribe();
884
+ }
885
+ }
886
+ var define_process_default$5 = { env: {} };
887
+ const DOTCOM_URL = new URL(
888
+ (typeof define_process_default$5 === "undefined" ? null : "https://sourcegraph.com") ?? "https://sourcegraph.com"
889
+ );
890
+ function isDotCom(arg) {
891
+ const url = typeof arg === "string" ? arg : arg == null ? void 0 : arg.endpoint;
892
+ if (url === void 0) {
893
+ return false;
894
+ }
895
+ try {
896
+ return new URL(url).origin === DOTCOM_URL.origin;
897
+ } catch {
898
+ return false;
899
+ }
900
+ }
901
+ function isCodyProUser(authStatus) {
902
+ return isDotCom(authStatus) && authStatus.authenticated && !authStatus.userCanUpgrade;
903
+ }
904
+ function isEnterpriseUser(authStatus) {
905
+ return !isDotCom(authStatus);
906
+ }
907
+ const CONTEXT_SELECTION_ID = {
908
+ none: 0,
909
+ embeddings: 1,
910
+ keyword: 2,
911
+ blended: 10,
912
+ unified: 11
913
+ };
914
+ var CodyIDE = /* @__PURE__ */ ((CodyIDE2) => {
915
+ CodyIDE2["VSCode"] = "VSCode";
916
+ CodyIDE2["JetBrains"] = "JetBrains";
917
+ CodyIDE2["Neovim"] = "Neovim";
918
+ CodyIDE2["Emacs"] = "Emacs";
919
+ CodyIDE2["Web"] = "Web";
920
+ CodyIDE2["VisualStudio"] = "VisualStudio";
921
+ CodyIDE2["Eclipse"] = "Eclipse";
922
+ return CodyIDE2;
923
+ })(CodyIDE || {});
924
+ var g$1 = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
925
+ typeof global !== "undefined" && global || {};
926
+ var support = {
927
+ searchParams: "URLSearchParams" in g$1,
928
+ iterable: "Symbol" in g$1 && "iterator" in Symbol,
929
+ blob: "FileReader" in g$1 && "Blob" in g$1 && function() {
930
+ try {
931
+ new Blob();
932
+ return true;
933
+ } catch (e3) {
934
+ return false;
935
+ }
936
+ }(),
937
+ formData: "FormData" in g$1,
938
+ arrayBuffer: "ArrayBuffer" in g$1
939
+ };
940
+ function isDataView(obj) {
941
+ return obj && DataView.prototype.isPrototypeOf(obj);
942
+ }
943
+ if (support.arrayBuffer) {
944
+ var viewClasses = [
945
+ "[object Int8Array]",
946
+ "[object Uint8Array]",
947
+ "[object Uint8ClampedArray]",
948
+ "[object Int16Array]",
949
+ "[object Uint16Array]",
950
+ "[object Int32Array]",
951
+ "[object Uint32Array]",
952
+ "[object Float32Array]",
953
+ "[object Float64Array]"
954
+ ];
955
+ var isArrayBufferView = ArrayBuffer.isView || function(obj) {
956
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
957
+ };
958
+ }
959
+ function normalizeName(name) {
960
+ if (typeof name !== "string") {
961
+ name = String(name);
962
+ }
963
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
964
+ throw new TypeError('Invalid character in header field name: "' + name + '"');
965
+ }
966
+ return name.toLowerCase();
967
+ }
968
+ function normalizeValue(value) {
969
+ if (typeof value !== "string") {
970
+ value = String(value);
971
+ }
972
+ return value;
973
+ }
974
+ function iteratorFor(items) {
975
+ var iterator2 = {
976
+ next: function() {
977
+ var value = items.shift();
978
+ return { done: value === void 0, value };
979
+ }
980
+ };
981
+ if (support.iterable) {
982
+ iterator2[Symbol.iterator] = function() {
983
+ return iterator2;
984
+ };
985
+ }
986
+ return iterator2;
987
+ }
988
+ function Headers$1(headers) {
989
+ this.map = {};
990
+ if (headers instanceof Headers$1) {
991
+ headers.forEach(function(value, name) {
992
+ this.append(name, value);
993
+ }, this);
994
+ } else if (Array.isArray(headers)) {
995
+ headers.forEach(function(header) {
996
+ if (header.length != 2) {
997
+ throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
998
+ }
999
+ this.append(header[0], header[1]);
1000
+ }, this);
1001
+ } else if (headers) {
1002
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
1003
+ this.append(name, headers[name]);
1004
+ }, this);
1005
+ }
1006
+ }
1007
+ Headers$1.prototype.append = function(name, value) {
1008
+ name = normalizeName(name);
1009
+ value = normalizeValue(value);
1010
+ var oldValue = this.map[name];
1011
+ this.map[name] = oldValue ? oldValue + ", " + value : value;
1012
+ };
1013
+ Headers$1.prototype["delete"] = function(name) {
1014
+ delete this.map[normalizeName(name)];
1015
+ };
1016
+ Headers$1.prototype.get = function(name) {
1017
+ name = normalizeName(name);
1018
+ return this.has(name) ? this.map[name] : null;
1019
+ };
1020
+ Headers$1.prototype.has = function(name) {
1021
+ return this.map.hasOwnProperty(normalizeName(name));
1022
+ };
1023
+ Headers$1.prototype.set = function(name, value) {
1024
+ this.map[normalizeName(name)] = normalizeValue(value);
1025
+ };
1026
+ Headers$1.prototype.forEach = function(callback2, thisArg) {
1027
+ for (var name in this.map) {
1028
+ if (this.map.hasOwnProperty(name)) {
1029
+ callback2.call(thisArg, this.map[name], name, this);
1030
+ }
1031
+ }
1032
+ };
1033
+ Headers$1.prototype.keys = function() {
1034
+ var items = [];
1035
+ this.forEach(function(value, name) {
1036
+ items.push(name);
1037
+ });
1038
+ return iteratorFor(items);
1039
+ };
1040
+ Headers$1.prototype.values = function() {
1041
+ var items = [];
1042
+ this.forEach(function(value) {
1043
+ items.push(value);
1044
+ });
1045
+ return iteratorFor(items);
1046
+ };
1047
+ Headers$1.prototype.entries = function() {
1048
+ var items = [];
1049
+ this.forEach(function(value, name) {
1050
+ items.push([name, value]);
1051
+ });
1052
+ return iteratorFor(items);
1053
+ };
1054
+ if (support.iterable) {
1055
+ Headers$1.prototype[Symbol.iterator] = Headers$1.prototype.entries;
1056
+ }
1057
+ function consumed(body) {
1058
+ if (body._noBody) return;
1059
+ if (body.bodyUsed) {
1060
+ return Promise.reject(new TypeError("Already read"));
1061
+ }
1062
+ body.bodyUsed = true;
1063
+ }
1064
+ function fileReaderReady(reader) {
1065
+ return new Promise(function(resolve, reject) {
1066
+ reader.onload = function() {
1067
+ resolve(reader.result);
1068
+ };
1069
+ reader.onerror = function() {
1070
+ reject(reader.error);
1071
+ };
1072
+ });
1073
+ }
1074
+ function readBlobAsArrayBuffer(blob) {
1075
+ var reader = new FileReader();
1076
+ var promise = fileReaderReady(reader);
1077
+ reader.readAsArrayBuffer(blob);
1078
+ return promise;
1079
+ }
1080
+ function readBlobAsText(blob) {
1081
+ var reader = new FileReader();
1082
+ var promise = fileReaderReady(reader);
1083
+ var match2 = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
1084
+ var encoding = match2 ? match2[1] : "utf-8";
1085
+ reader.readAsText(blob, encoding);
1086
+ return promise;
1087
+ }
1088
+ function readArrayBufferAsText(buf) {
1089
+ var view = new Uint8Array(buf);
1090
+ var chars = new Array(view.length);
1091
+ for (var i3 = 0; i3 < view.length; i3++) {
1092
+ chars[i3] = String.fromCharCode(view[i3]);
1093
+ }
1094
+ return chars.join("");
1095
+ }
1096
+ function bufferClone(buf) {
1097
+ if (buf.slice) {
1098
+ return buf.slice(0);
1099
+ } else {
1100
+ var view = new Uint8Array(buf.byteLength);
1101
+ view.set(new Uint8Array(buf));
1102
+ return view.buffer;
1103
+ }
1104
+ }
1105
+ function Body() {
1106
+ this.bodyUsed = false;
1107
+ this._initBody = function(body) {
1108
+ this.bodyUsed = this.bodyUsed;
1109
+ this._bodyInit = body;
1110
+ if (!body) {
1111
+ this._noBody = true;
1112
+ this._bodyText = "";
1113
+ } else if (typeof body === "string") {
1114
+ this._bodyText = body;
1115
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
1116
+ this._bodyBlob = body;
1117
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
1118
+ this._bodyFormData = body;
1119
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
1120
+ this._bodyText = body.toString();
1121
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
1122
+ this._bodyArrayBuffer = bufferClone(body.buffer);
1123
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
1124
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
1125
+ this._bodyArrayBuffer = bufferClone(body);
1126
+ } else {
1127
+ this._bodyText = body = Object.prototype.toString.call(body);
1128
+ }
1129
+ if (!this.headers.get("content-type")) {
1130
+ if (typeof body === "string") {
1131
+ this.headers.set("content-type", "text/plain;charset=UTF-8");
1132
+ } else if (this._bodyBlob && this._bodyBlob.type) {
1133
+ this.headers.set("content-type", this._bodyBlob.type);
1134
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
1135
+ this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
1136
+ }
1137
+ }
1138
+ };
1139
+ if (support.blob) {
1140
+ this.blob = function() {
1141
+ var rejected = consumed(this);
1142
+ if (rejected) {
1143
+ return rejected;
1144
+ }
1145
+ if (this._bodyBlob) {
1146
+ return Promise.resolve(this._bodyBlob);
1147
+ } else if (this._bodyArrayBuffer) {
1148
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
1149
+ } else if (this._bodyFormData) {
1150
+ throw new Error("could not read FormData body as blob");
1151
+ } else {
1152
+ return Promise.resolve(new Blob([this._bodyText]));
1153
+ }
1154
+ };
1155
+ }
1156
+ this.arrayBuffer = function() {
1157
+ if (this._bodyArrayBuffer) {
1158
+ var isConsumed = consumed(this);
1159
+ if (isConsumed) {
1160
+ return isConsumed;
1161
+ } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
1162
+ return Promise.resolve(
1163
+ this._bodyArrayBuffer.buffer.slice(
1164
+ this._bodyArrayBuffer.byteOffset,
1165
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
1166
+ )
1167
+ );
1168
+ } else {
1169
+ return Promise.resolve(this._bodyArrayBuffer);
1170
+ }
1171
+ } else if (support.blob) {
1172
+ return this.blob().then(readBlobAsArrayBuffer);
1173
+ } else {
1174
+ throw new Error("could not read as ArrayBuffer");
1175
+ }
1176
+ };
1177
+ this.text = function() {
1178
+ var rejected = consumed(this);
1179
+ if (rejected) {
1180
+ return rejected;
1181
+ }
1182
+ if (this._bodyBlob) {
1183
+ return readBlobAsText(this._bodyBlob);
1184
+ } else if (this._bodyArrayBuffer) {
1185
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
1186
+ } else if (this._bodyFormData) {
1187
+ throw new Error("could not read FormData body as text");
1188
+ } else {
1189
+ return Promise.resolve(this._bodyText);
1190
+ }
1191
+ };
1192
+ if (support.formData) {
1193
+ this.formData = function() {
1194
+ return this.text().then(decode);
1195
+ };
1196
+ }
1197
+ this.json = function() {
1198
+ return this.text().then(JSON.parse);
1199
+ };
1200
+ return this;
1201
+ }
1202
+ var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
1203
+ function normalizeMethod(method) {
1204
+ var upcased = method.toUpperCase();
1205
+ return methods.indexOf(upcased) > -1 ? upcased : method;
1206
+ }
1207
+ function Request(input, options) {
1208
+ if (!(this instanceof Request)) {
1209
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
1210
+ }
1211
+ options = options || {};
1212
+ var body = options.body;
1213
+ if (input instanceof Request) {
1214
+ if (input.bodyUsed) {
1215
+ throw new TypeError("Already read");
1216
+ }
1217
+ this.url = input.url;
1218
+ this.credentials = input.credentials;
1219
+ if (!options.headers) {
1220
+ this.headers = new Headers$1(input.headers);
1221
+ }
1222
+ this.method = input.method;
1223
+ this.mode = input.mode;
1224
+ this.signal = input.signal;
1225
+ if (!body && input._bodyInit != null) {
1226
+ body = input._bodyInit;
1227
+ input.bodyUsed = true;
1228
+ }
1229
+ } else {
1230
+ this.url = String(input);
1231
+ }
1232
+ this.credentials = options.credentials || this.credentials || "same-origin";
1233
+ if (options.headers || !this.headers) {
1234
+ this.headers = new Headers$1(options.headers);
1235
+ }
1236
+ this.method = normalizeMethod(options.method || this.method || "GET");
1237
+ this.mode = options.mode || this.mode || null;
1238
+ this.signal = options.signal || this.signal || function() {
1239
+ if ("AbortController" in g$1) {
1240
+ var ctrl = new AbortController();
1241
+ return ctrl.signal;
1242
+ }
1243
+ }();
1244
+ this.referrer = null;
1245
+ if ((this.method === "GET" || this.method === "HEAD") && body) {
1246
+ throw new TypeError("Body not allowed for GET or HEAD requests");
1247
+ }
1248
+ this._initBody(body);
1249
+ if (this.method === "GET" || this.method === "HEAD") {
1250
+ if (options.cache === "no-store" || options.cache === "no-cache") {
1251
+ var reParamSearch = /([?&])_=[^&]*/;
1252
+ if (reParamSearch.test(this.url)) {
1253
+ this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
1254
+ } else {
1255
+ var reQueryString = /\?/;
1256
+ this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ Request.prototype.clone = function() {
1262
+ return new Request(this, { body: this._bodyInit });
1263
+ };
1264
+ function decode(body) {
1265
+ var form = new FormData();
1266
+ body.trim().split("&").forEach(function(bytes) {
1267
+ if (bytes) {
1268
+ var split = bytes.split("=");
1269
+ var name = split.shift().replace(/\+/g, " ");
1270
+ var value = split.join("=").replace(/\+/g, " ");
1271
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
1272
+ }
1273
+ });
1274
+ return form;
1275
+ }
1276
+ function parseHeaders(rawHeaders) {
1277
+ var headers = new Headers$1();
1278
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
1279
+ preProcessedHeaders.split("\r").map(function(header) {
1280
+ return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
1281
+ }).forEach(function(line) {
1282
+ var parts = line.split(":");
1283
+ var key = parts.shift().trim();
1284
+ if (key) {
1285
+ var value = parts.join(":").trim();
1286
+ try {
1287
+ headers.append(key, value);
1288
+ } catch (error2) {
1289
+ console.warn("Response " + error2.message);
1290
+ }
1291
+ }
1292
+ });
1293
+ return headers;
1294
+ }
1295
+ Body.call(Request.prototype);
1296
+ function Response(bodyInit, options) {
1297
+ if (!(this instanceof Response)) {
1298
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
1299
+ }
1300
+ if (!options) {
1301
+ options = {};
1302
+ }
1303
+ this.type = "default";
1304
+ this.status = options.status === void 0 ? 200 : options.status;
1305
+ if (this.status < 200 || this.status > 599) {
1306
+ throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
1307
+ }
1308
+ this.ok = this.status >= 200 && this.status < 300;
1309
+ this.statusText = options.statusText === void 0 ? "" : "" + options.statusText;
1310
+ this.headers = new Headers$1(options.headers);
1311
+ this.url = options.url || "";
1312
+ this._initBody(bodyInit);
1313
+ }
1314
+ Body.call(Response.prototype);
1315
+ Response.prototype.clone = function() {
1316
+ return new Response(this._bodyInit, {
1317
+ status: this.status,
1318
+ statusText: this.statusText,
1319
+ headers: new Headers$1(this.headers),
1320
+ url: this.url
1321
+ });
1322
+ };
1323
+ Response.error = function() {
1324
+ var response = new Response(null, { status: 200, statusText: "" });
1325
+ response.ok = false;
1326
+ response.status = 0;
1327
+ response.type = "error";
1328
+ return response;
1329
+ };
1330
+ var redirectStatuses = [301, 302, 303, 307, 308];
1331
+ Response.redirect = function(url, status) {
1332
+ if (redirectStatuses.indexOf(status) === -1) {
1333
+ throw new RangeError("Invalid status code");
1334
+ }
1335
+ return new Response(null, { status, headers: { location: url } });
1336
+ };
1337
+ var DOMException = g$1.DOMException;
1338
+ try {
1339
+ new DOMException();
1340
+ } catch (err) {
1341
+ DOMException = function(message, name) {
1342
+ this.message = message;
1343
+ this.name = name;
1344
+ var error2 = Error(message);
1345
+ this.stack = error2.stack;
1346
+ };
1347
+ DOMException.prototype = Object.create(Error.prototype);
1348
+ DOMException.prototype.constructor = DOMException;
1349
+ }
1350
+ function fetch$1(input, init) {
1351
+ return new Promise(function(resolve, reject) {
1352
+ var request = new Request(input, init);
1353
+ if (request.signal && request.signal.aborted) {
1354
+ return reject(new DOMException("Aborted", "AbortError"));
1355
+ }
1356
+ var xhr = new XMLHttpRequest();
1357
+ function abortXhr() {
1358
+ xhr.abort();
1359
+ }
1360
+ xhr.onload = function() {
1361
+ var options = {
1362
+ statusText: xhr.statusText,
1363
+ headers: parseHeaders(xhr.getAllResponseHeaders() || "")
1364
+ };
1365
+ if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
1366
+ options.status = 200;
1367
+ } else {
1368
+ options.status = xhr.status;
1369
+ }
1370
+ options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
1371
+ var body = "response" in xhr ? xhr.response : xhr.responseText;
1372
+ setTimeout(function() {
1373
+ resolve(new Response(body, options));
1374
+ }, 0);
1375
+ };
1376
+ xhr.onerror = function() {
1377
+ setTimeout(function() {
1378
+ reject(new TypeError("Network request failed"));
1379
+ }, 0);
1380
+ };
1381
+ xhr.ontimeout = function() {
1382
+ setTimeout(function() {
1383
+ reject(new TypeError("Network request timed out"));
1384
+ }, 0);
1385
+ };
1386
+ xhr.onabort = function() {
1387
+ setTimeout(function() {
1388
+ reject(new DOMException("Aborted", "AbortError"));
1389
+ }, 0);
1390
+ };
1391
+ function fixUrl(url) {
1392
+ try {
1393
+ return url === "" && g$1.location.href ? g$1.location.href : url;
1394
+ } catch (e3) {
1395
+ return url;
1396
+ }
1397
+ }
1398
+ xhr.open(request.method, fixUrl(request.url), true);
1399
+ if (request.credentials === "include") {
1400
+ xhr.withCredentials = true;
1401
+ } else if (request.credentials === "omit") {
1402
+ xhr.withCredentials = false;
1403
+ }
1404
+ if ("responseType" in xhr) {
1405
+ if (support.blob) {
1406
+ xhr.responseType = "blob";
1407
+ } else if (support.arrayBuffer) {
1408
+ xhr.responseType = "arraybuffer";
1409
+ }
1410
+ }
1411
+ if (init && typeof init.headers === "object" && !(init.headers instanceof Headers$1 || g$1.Headers && init.headers instanceof g$1.Headers)) {
1412
+ var names = [];
1413
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
1414
+ names.push(normalizeName(name));
1415
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
1416
+ });
1417
+ request.headers.forEach(function(value, name) {
1418
+ if (names.indexOf(name) === -1) {
1419
+ xhr.setRequestHeader(name, value);
1420
+ }
1421
+ });
1422
+ } else {
1423
+ request.headers.forEach(function(value, name) {
1424
+ xhr.setRequestHeader(name, value);
1425
+ });
1426
+ }
1427
+ if (request.signal) {
1428
+ request.signal.addEventListener("abort", abortXhr);
1429
+ xhr.onreadystatechange = function() {
1430
+ if (xhr.readyState === 4) {
1431
+ request.signal.removeEventListener("abort", abortXhr);
1432
+ }
1433
+ };
1434
+ }
1435
+ xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
1436
+ });
1437
+ }
1438
+ fetch$1.polyfill = true;
1439
+ if (!g$1.fetch) {
1440
+ g$1.fetch = fetch$1;
1441
+ g$1.Headers = Headers$1;
1442
+ g$1.Request = Request;
1443
+ g$1.Response = Response;
1444
+ }
1445
+ var lodash = { exports: {} };
1446
+ /**
1447
+ * @license
1448
+ * Lodash <https://lodash.com/>
1449
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1450
+ * Released under MIT license <https://lodash.com/license>
1451
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1452
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1453
+ */
1454
+ lodash.exports;
1455
+ (function(module, exports) {
1456
+ (function() {
1457
+ var undefined$1;
1458
+ var VERSION2 = "4.17.21";
1459
+ var LARGE_ARRAY_SIZE2 = 200;
1460
+ var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
1461
+ var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
1462
+ var MAX_MEMOIZE_SIZE = 500;
1463
+ var PLACEHOLDER = "__lodash_placeholder__";
1464
+ var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
996
1465
  var COMPARE_PARTIAL_FLAG2 = 1, COMPARE_UNORDERED_FLAG2 = 2;
997
1466
  var WRAP_BIND_FLAG = 1, WRAP_BIND_KEY_FLAG = 2, WRAP_CURRY_BOUND_FLAG = 4, WRAP_CURRY_FLAG = 8, WRAP_CURRY_RIGHT_FLAG = 16, WRAP_PARTIAL_FLAG = 32, WRAP_PARTIAL_RIGHT_FLAG = 64, WRAP_ARY_FLAG = 128, WRAP_REARG_FLAG = 256, WRAP_FLIP_FLAG = 512;
998
1467
  var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "...";
@@ -6456,11 +6925,11 @@ lodash.exports;
6456
6925
  })(lodash, lodash.exports);
6457
6926
  var lodashExports = lodash.exports;
6458
6927
  const _$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodashExports);
6459
- var define_process_default$5 = { env: {} };
6928
+ var define_process_default$4 = { env: {} };
6460
6929
  function isWindows() {
6461
- if (typeof define_process_default$5 !== "undefined") {
6462
- if (define_process_default$5.platform) {
6463
- return define_process_default$5.platform.startsWith("win");
6930
+ if (typeof define_process_default$4 !== "undefined") {
6931
+ if (define_process_default$4.platform) {
6932
+ return define_process_default$4.platform.startsWith("win");
6464
6933
  }
6465
6934
  }
6466
6935
  if (typeof navigator === "object") {
@@ -6469,14 +6938,14 @@ function isWindows() {
6469
6938
  return false;
6470
6939
  }
6471
6940
  function isMacOS() {
6472
- var _a3;
6473
- if (typeof define_process_default$5 !== "undefined") {
6474
- if (define_process_default$5.platform) {
6475
- return define_process_default$5.platform === "darwin";
6941
+ var _a2;
6942
+ if (typeof define_process_default$4 !== "undefined") {
6943
+ if (define_process_default$4.platform) {
6944
+ return define_process_default$4.platform === "darwin";
6476
6945
  }
6477
6946
  }
6478
6947
  if (typeof navigator === "object") {
6479
- return (_a3 = navigator.userAgent) == null ? void 0 : _a3.includes("Mac");
6948
+ return (_a2 = navigator.userAgent) == null ? void 0 : _a2.includes("Mac");
6480
6949
  }
6481
6950
  return false;
6482
6951
  }
@@ -6680,8 +7149,8 @@ var constants$1 = {
6680
7149
  FLAG_INCLUDE_PRERELEASE: 1,
6681
7150
  FLAG_LOOSE: 2
6682
7151
  };
6683
- var define_process_default$4 = { env: {} };
6684
- const debug$1 = typeof define_process_default$4 === "object" && define_process_default$4.env && false ? (...args) => console.error("SEMVER", ...args) : () => {
7152
+ var define_process_default$3 = { env: {} };
7153
+ const debug$1 = typeof define_process_default$3 === "object" && define_process_default$3.env && false ? (...args) => console.error("SEMVER", ...args) : () => {
6685
7154
  };
6686
7155
  var debug_1 = debug$1;
6687
7156
  (function(module, exports) {
@@ -8919,11 +9388,11 @@ var major = VERSION.split(".")[0];
8919
9388
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
8920
9389
  var _global = _globalThis;
8921
9390
  function registerGlobal(type, instance, diag2, allowOverride) {
8922
- var _a3;
9391
+ var _a2;
8923
9392
  if (allowOverride === void 0) {
8924
9393
  allowOverride = false;
8925
9394
  }
8926
- var api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a3 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a3 !== void 0 ? _a3 : {
9395
+ var api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a2 !== void 0 ? _a2 : {
8927
9396
  version: VERSION
8928
9397
  };
8929
9398
  if (!allowOverride && api2[type]) {
@@ -8941,8 +9410,8 @@ function registerGlobal(type, instance, diag2, allowOverride) {
8941
9410
  return true;
8942
9411
  }
8943
9412
  function getGlobal(type) {
8944
- var _a3, _b;
8945
- var globalVersion = (_a3 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a3 === void 0 ? void 0 : _a3.version;
9413
+ var _a2, _b;
9414
+ var globalVersion = (_a2 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a2 === void 0 ? void 0 : _a2.version;
8946
9415
  if (!globalVersion || !isCompatible(globalVersion)) {
8947
9416
  return;
8948
9417
  }
@@ -9111,13 +9580,13 @@ var DiagAPI = (
9111
9580
  }
9112
9581
  var self2 = this;
9113
9582
  var setLogger2 = function(logger, optionsOrLogLevel) {
9114
- var _a3, _b, _c;
9583
+ var _a2, _b, _c;
9115
9584
  if (optionsOrLogLevel === void 0) {
9116
9585
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
9117
9586
  }
9118
9587
  if (logger === self2) {
9119
9588
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
9120
- self2.error((_a3 = err.stack) !== null && _a3 !== void 0 ? _a3 : err.message);
9589
+ self2.error((_a2 = err.stack) !== null && _a2 !== void 0 ? _a2 : err.message);
9121
9590
  return false;
9122
9591
  }
9123
9592
  if (typeof optionsOrLogLevel === "number") {
@@ -9198,8 +9667,8 @@ var BaggageImpl = (
9198
9667
  return Object.assign({}, entry);
9199
9668
  };
9200
9669
  BaggageImpl2.prototype.getAllEntries = function() {
9201
- return Array.from(this._entries.entries()).map(function(_a3) {
9202
- var _b = __read$2(_a3, 2), k3 = _b[0], v2 = _b[1];
9670
+ return Array.from(this._entries.entries()).map(function(_a2) {
9671
+ var _b = __read$2(_a2, 2), k3 = _b[0], v2 = _b[1];
9203
9672
  return [k3, v2];
9204
9673
  });
9205
9674
  };
@@ -9214,7 +9683,7 @@ var BaggageImpl = (
9214
9683
  return newBaggage;
9215
9684
  };
9216
9685
  BaggageImpl2.prototype.removeEntries = function() {
9217
- var e_1, _a3;
9686
+ var e_1, _a2;
9218
9687
  var keys2 = [];
9219
9688
  for (var _i2 = 0; _i2 < arguments.length; _i2++) {
9220
9689
  keys2[_i2] = arguments[_i2];
@@ -9229,7 +9698,7 @@ var BaggageImpl = (
9229
9698
  e_1 = { error: e_1_1 };
9230
9699
  } finally {
9231
9700
  try {
9232
- if (keys_1_1 && !keys_1_1.done && (_a3 = keys_12.return)) _a3.call(keys_12);
9701
+ if (keys_1_1 && !keys_1_1.done && (_a2 = keys_12.return)) _a2.call(keys_12);
9233
9702
  } finally {
9234
9703
  if (e_1) throw e_1.error;
9235
9704
  }
@@ -9539,12 +10008,12 @@ var ContextAPI = (
9539
10008
  return this._getContextManager().active();
9540
10009
  };
9541
10010
  ContextAPI2.prototype.with = function(context2, fn, thisArg) {
9542
- var _a3;
10011
+ var _a2;
9543
10012
  var args = [];
9544
10013
  for (var _i2 = 3; _i2 < arguments.length; _i2++) {
9545
10014
  args[_i2 - 3] = arguments[_i2];
9546
10015
  }
9547
- return (_a3 = this._getContextManager()).with.apply(_a3, __spreadArray([context2, fn, thisArg], __read(args), false));
10016
+ return (_a2 = this._getContextManager()).with.apply(_a2, __spreadArray([context2, fn, thisArg], __read(args), false));
9548
10017
  };
9549
10018
  ContextAPI2.prototype.bind = function(context2, target) {
9550
10019
  return this._getContextManager().bind(context2, target);
@@ -9625,8 +10094,8 @@ function setSpanContext(context2, spanContext) {
9625
10094
  return setSpan(context2, new NonRecordingSpan(spanContext));
9626
10095
  }
9627
10096
  function getSpanContext(context2) {
9628
- var _a3;
9629
- return (_a3 = getSpan(context2)) === null || _a3 === void 0 ? void 0 : _a3.spanContext();
10097
+ var _a2;
10098
+ return (_a2 = getSpan(context2)) === null || _a2 === void 0 ? void 0 : _a2.spanContext();
9630
10099
  }
9631
10100
  var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
9632
10101
  var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
@@ -9739,19 +10208,19 @@ var ProxyTracerProvider = (
9739
10208
  function ProxyTracerProvider2() {
9740
10209
  }
9741
10210
  ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
9742
- var _a3;
9743
- return (_a3 = this.getDelegateTracer(name, version, options)) !== null && _a3 !== void 0 ? _a3 : new ProxyTracer(this, name, version, options);
10211
+ var _a2;
10212
+ return (_a2 = this.getDelegateTracer(name, version, options)) !== null && _a2 !== void 0 ? _a2 : new ProxyTracer(this, name, version, options);
9744
10213
  };
9745
10214
  ProxyTracerProvider2.prototype.getDelegate = function() {
9746
- var _a3;
9747
- return (_a3 = this._delegate) !== null && _a3 !== void 0 ? _a3 : NOOP_TRACER_PROVIDER;
10215
+ var _a2;
10216
+ return (_a2 = this._delegate) !== null && _a2 !== void 0 ? _a2 : NOOP_TRACER_PROVIDER;
9748
10217
  };
9749
10218
  ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
9750
10219
  this._delegate = delegate;
9751
10220
  };
9752
10221
  ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
9753
- var _a3;
9754
- return (_a3 = this._delegate) === null || _a3 === void 0 ? void 0 : _a3.getTracer(name, version, options);
10222
+ var _a2;
10223
+ return (_a2 = this._delegate) === null || _a2 === void 0 ? void 0 : _a2.getTracer(name, version, options);
9755
10224
  };
9756
10225
  return ProxyTracerProvider2;
9757
10226
  }()
@@ -9993,7 +10462,7 @@ function recordErrorToSpan(span, error2) {
9993
10462
  }
9994
10463
  const isError = (value) => value instanceof Error;
9995
10464
  function convertGitCloneURLToCodebaseName(cloneURL) {
9996
- var _a3, _b;
10465
+ var _a2, _b;
9997
10466
  const result = convertGitCloneURLToCodebaseNameOrError(cloneURL);
9998
10467
  if (isError(result)) {
9999
10468
  if (result.message) {
@@ -10002,7 +10471,7 @@ function convertGitCloneURLToCodebaseName(cloneURL) {
10002
10471
  "convertGitCloneURLToCodebaseName",
10003
10472
  result.message,
10004
10473
  result.cause,
10005
- (_a3 = result.stack) == null ? void 0 : _a3.concat("\n")
10474
+ (_a2 = result.stack) == null ? void 0 : _a2.concat("\n")
10006
10475
  );
10007
10476
  } else {
10008
10477
  logError("convertGitCloneURLToCodebaseName", result.message, (_b = result.stack) == null ? void 0 : _b.concat("\n"));
@@ -10013,7 +10482,7 @@ function convertGitCloneURLToCodebaseName(cloneURL) {
10013
10482
  return result;
10014
10483
  }
10015
10484
  function convertGitCloneURLToCodebaseNameOrError(cloneURL) {
10016
- var _a3;
10485
+ var _a2;
10017
10486
  if (!cloneURL) {
10018
10487
  return new Error(
10019
10488
  `Unable to determine the git clone URL for this workspace.
@@ -10029,7 +10498,7 @@ git output: ${cloneURL}`
10029
10498
  return `${host}/${owner}/${repo}`;
10030
10499
  }
10031
10500
  const uri = new URL(cloneURL);
10032
- if (((_a3 = uri.hostname) == null ? void 0 : _a3.includes("dev.azure")) && uri.pathname) {
10501
+ if (((_a2 = uri.hostname) == null ? void 0 : _a2.includes("dev.azure")) && uri.pathname) {
10033
10502
  return `${uri.hostname}${uri.pathname.replace("/_git", "")}`;
10034
10503
  }
10035
10504
  if (uri.protocol.startsWith("github") || uri.href.startsWith("github")) {
@@ -10071,26 +10540,15 @@ var SemverString;
10071
10540
  ((SemverString2) => {
10072
10541
  const splitPrefixRegex = /^(?<prefix>.*)(?<version>\d+\.\d+\.\d+)$/;
10073
10542
  function forcePrefix(prefix, value) {
10074
- var _a3, _b;
10543
+ var _a2, _b;
10075
10544
  const match2 = splitPrefixRegex.exec(value);
10076
- if (!match2 || !((_a3 = match2.groups) == null ? void 0 : _a3.version)) {
10545
+ if (!match2 || !((_a2 = match2.groups) == null ? void 0 : _a2.version)) {
10077
10546
  throw new Error(`Invalid semver string: ${value}`);
10078
10547
  }
10079
10548
  return `${prefix}${(_b = match2.groups) == null ? void 0 : _b.version}`;
10080
10549
  }
10081
10550
  SemverString2.forcePrefix = forcePrefix;
10082
10551
  })(SemverString || (SemverString = {}));
10083
- var define_process_default$3 = { env: {} };
10084
- const DOTCOM_URL = new URL(
10085
- (typeof define_process_default$3 === "undefined" ? null : "https://sourcegraph.com") ?? "https://sourcegraph.com"
10086
- );
10087
- function isDotCom(url) {
10088
- try {
10089
- return new URL(url).origin === DOTCOM_URL.origin;
10090
- } catch {
10091
- return false;
10092
- }
10093
- }
10094
10552
  function _typeof$1(o2) {
10095
10553
  "@babel/helpers - typeof";
10096
10554
  return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
@@ -11865,6 +12323,10 @@ function isAbortErrorOrSocketHangUp(error2) {
11865
12323
  }
11866
12324
  class TimeoutError extends Error {
11867
12325
  }
12326
+ function isNetworkLikeError(error2) {
12327
+ const message = error2.message;
12328
+ return message.includes("ENOTFOUND") || message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("EHOSTUNREACH") || message.includes("ETIMEDOUT");
12329
+ }
11868
12330
  const CURRENT_USER_ID_QUERY = `
11869
12331
  query CurrentUser {
11870
12332
  currentUser {
@@ -12395,9 +12857,6 @@ class SourcegraphGraphQLAPIClient {
12395
12857
  setAnonymousUserID(anonymousUID) {
12396
12858
  this.anonymousUserID = anonymousUID;
12397
12859
  }
12398
- isDotCom() {
12399
- return isDotCom(this.config.serverEndpoint);
12400
- }
12401
12860
  // Gets the server endpoint for this client.
12402
12861
  get endpoint() {
12403
12862
  return this.config.serverEndpoint;
@@ -12410,8 +12869,8 @@ class SourcegraphGraphQLAPIClient {
12410
12869
  (response) => extractDataOrError(
12411
12870
  response,
12412
12871
  (data) => {
12413
- var _a3;
12414
- return ((_a3 = data.site) == null ? void 0 : _a3.productVersion) ?? new Error("site version not found");
12872
+ var _a2;
12873
+ return ((_a2 = data.site) == null ? void 0 : _a2.productVersion) ?? new Error("site version not found");
12415
12874
  }
12416
12875
  )
12417
12876
  );
@@ -12427,8 +12886,8 @@ class SourcegraphGraphQLAPIClient {
12427
12886
  (response) => extractDataOrError(
12428
12887
  response,
12429
12888
  (data) => {
12430
- var _a3;
12431
- return ((_a3 = data.search) == null ? void 0 : _a3.results.results) ?? new Error("no files found");
12889
+ var _a2;
12890
+ return ((_a2 = data.search) == null ? void 0 : _a2.results.results) ?? new Error("no files found");
12432
12891
  }
12433
12892
  )
12434
12893
  );
@@ -12440,8 +12899,8 @@ class SourcegraphGraphQLAPIClient {
12440
12899
  (response) => extractDataOrError(
12441
12900
  response,
12442
12901
  (data) => {
12443
- var _a3;
12444
- return ((_a3 = data.search) == null ? void 0 : _a3.results.results) ?? new Error("no symbols found");
12902
+ var _a2;
12903
+ return ((_a2 = data.search) == null ? void 0 : _a2.results.results) ?? new Error("no symbols found");
12445
12904
  }
12446
12905
  )
12447
12906
  );
@@ -12481,8 +12940,8 @@ class SourcegraphGraphQLAPIClient {
12481
12940
  return extractDataOrError(
12482
12941
  response,
12483
12942
  (data) => {
12484
- var _a3, _b, _c, _d, _e2, _f, _g, _h;
12485
- return ((_a3 = data.site) == null ? void 0 : _a3.siteID) ? ((_d = (_c = (_b = data.site) == null ? void 0 : _b.productSubscription) == null ? void 0 : _c.license) == null ? void 0 : _d.hashedKey) ? {
12943
+ var _a2, _b, _c, _d, _e2, _f, _g, _h;
12944
+ return ((_a2 = data.site) == null ? void 0 : _a2.siteID) ? ((_d = (_c = (_b = data.site) == null ? void 0 : _b.productSubscription) == null ? void 0 : _c.license) == null ? void 0 : _d.hashedKey) ? {
12486
12945
  siteid: (_e2 = data.site) == null ? void 0 : _e2.siteID,
12487
12946
  hashedLicenseKey: (_h = (_g = (_f = data.site) == null ? void 0 : _f.productSubscription) == null ? void 0 : _g.license) == null ? void 0 : _h.hashedKey
12488
12947
  } : new Error("site hashed license key not found") : new Error("site ID not found");
@@ -12497,8 +12956,8 @@ class SourcegraphGraphQLAPIClient {
12497
12956
  (response) => extractDataOrError(
12498
12957
  response,
12499
12958
  (data) => {
12500
- var _a3, _b;
12501
- return !!((_b = (_a3 = data.__type) == null ? void 0 : _a3.fields) == null ? void 0 : _b.find((field) => field.name === "isCodyEnabled"));
12959
+ var _a2, _b;
12960
+ return !!((_b = (_a2 = data.__type) == null ? void 0 : _a2.fields) == null ? void 0 : _b.find((field) => field.name === "isCodyEnabled"));
12502
12961
  }
12503
12962
  )
12504
12963
  );
@@ -12508,8 +12967,8 @@ class SourcegraphGraphQLAPIClient {
12508
12967
  CURRENT_SITE_HAS_CODY_ENABLED_QUERY,
12509
12968
  {}
12510
12969
  ).then((response) => extractDataOrError(response, (data) => {
12511
- var _a3;
12512
- return ((_a3 = data.site) == null ? void 0 : _a3.isCodyEnabled) ?? false;
12970
+ var _a2;
12971
+ return ((_a2 = data.site) == null ? void 0 : _a2.isCodyEnabled) ?? false;
12513
12972
  }));
12514
12973
  }
12515
12974
  async getCurrentUserId() {
@@ -12534,8 +12993,8 @@ class SourcegraphGraphQLAPIClient {
12534
12993
  {}
12535
12994
  ).then(
12536
12995
  (response) => extractDataOrError(response, (data) => {
12537
- var _a3;
12538
- return ((_a3 = data.currentUser) == null ? void 0 : _a3.codySubscription) ?? null;
12996
+ var _a2;
12997
+ return ((_a2 = data.currentUser) == null ? void 0 : _a2.codySubscription) ?? null;
12539
12998
  })
12540
12999
  );
12541
13000
  }
@@ -12558,8 +13017,8 @@ class SourcegraphGraphQLAPIClient {
12558
13017
  return extractDataOrError(
12559
13018
  response,
12560
13019
  (data) => {
12561
- var _a3;
12562
- return ((_a3 = data.site) == null ? void 0 : _a3.codyConfigFeatures) ?? new Error("cody config not found");
13020
+ var _a2;
13021
+ return ((_a2 = data.site) == null ? void 0 : _a2.codyConfigFeatures) ?? new Error("cody config not found");
12563
13022
  }
12564
13023
  );
12565
13024
  }
@@ -12576,8 +13035,8 @@ class SourcegraphGraphQLAPIClient {
12576
13035
  const config = extractDataOrError(
12577
13036
  configResponse,
12578
13037
  (data) => {
12579
- var _a3;
12580
- return ((_a3 = data.site) == null ? void 0 : _a3.codyLLMConfiguration) || void 0;
13038
+ var _a2;
13039
+ return ((_a2 = data.site) == null ? void 0 : _a2.codyLLMConfiguration) || void 0;
12581
13040
  }
12582
13041
  );
12583
13042
  if (!config || isError(config)) {
@@ -12587,8 +13046,8 @@ class SourcegraphGraphQLAPIClient {
12587
13046
  const llmProvider = extractDataOrError(
12588
13047
  providerResponse,
12589
13048
  (data) => {
12590
- var _a3, _b;
12591
- return (_b = (_a3 = data.site) == null ? void 0 : _a3.codyLLMConfiguration) == null ? void 0 : _b.provider;
13049
+ var _a2, _b;
13050
+ return (_b = (_a2 = data.site) == null ? void 0 : _a2.codyLLMConfiguration) == null ? void 0 : _b.provider;
12592
13051
  }
12593
13052
  );
12594
13053
  if (llmProvider && !isError(llmProvider)) {
@@ -12604,8 +13063,8 @@ class SourcegraphGraphQLAPIClient {
12604
13063
  const smartContextResponse = extractDataOrError(
12605
13064
  response,
12606
13065
  (data) => {
12607
- var _a3, _b;
12608
- return ((_b = (_a3 = data == null ? void 0 : data.site) == null ? void 0 : _a3.codyLLMConfiguration) == null ? void 0 : _b.smartContextWindow) ?? "";
13066
+ var _a2, _b;
13067
+ return ((_b = (_a2 = data == null ? void 0 : data.site) == null ? void 0 : _a2.codyLLMConfiguration) == null ? void 0 : _b.smartContextWindow) ?? "";
12609
13068
  }
12610
13069
  );
12611
13070
  if (isError(smartContextResponse)) {
@@ -12670,8 +13129,8 @@ class SourcegraphGraphQLAPIClient {
12670
13129
  },
12671
13130
  signal
12672
13131
  ).then((response) => extractDataOrError(response, (data) => {
12673
- var _a3;
12674
- return ((_a3 = data.repositories) == null ? void 0 : _a3.nodes) || [];
13132
+ var _a2;
13133
+ return ((_a2 = data.repositories) == null ? void 0 : _a2.nodes) || [];
12675
13134
  }));
12676
13135
  }
12677
13136
  async getRepoName(cloneURL) {
@@ -12682,8 +13141,8 @@ class SourcegraphGraphQLAPIClient {
12682
13141
  }
12683
13142
  );
12684
13143
  const result = extractDataOrError(response, (data) => {
12685
- var _a3;
12686
- return ((_a3 = data.repository) == null ? void 0 : _a3.name) ?? null;
13144
+ var _a2;
13145
+ return ((_a2 = data.repository) == null ? void 0 : _a2.name) ?? null;
12687
13146
  });
12688
13147
  return isError(result) ? null : result;
12689
13148
  }
@@ -12790,8 +13249,8 @@ class SourcegraphGraphQLAPIClient {
12790
13249
  CONTEXT_FILTERS_QUERY
12791
13250
  );
12792
13251
  const result = extractDataOrError(response, (data) => {
12793
- var _a3, _b, _c, _d;
12794
- if (((_b = (_a3 = data == null ? void 0 : data.site) == null ? void 0 : _a3.codyContextFilters) == null ? void 0 : _b.raw) === null) {
13252
+ var _a2, _b, _c, _d;
13253
+ if (((_b = (_a2 = data == null ? void 0 : data.site) == null ? void 0 : _a2.codyContextFilters) == null ? void 0 : _b.raw) === null) {
12795
13254
  return {
12796
13255
  filters: INCLUDE_EVERYTHING_CONTEXT_FILTERS,
12797
13256
  transient: false
@@ -12898,14 +13357,14 @@ class SourcegraphGraphQLAPIClient {
12898
13357
  * from '@sourcegraph/telemetry' instead.
12899
13358
  */
12900
13359
  async logEvent(event, mode) {
12901
- var _a3;
13360
+ var _a2;
12902
13361
  if (this.isAgentTesting) {
12903
13362
  return {};
12904
13363
  }
12905
- if (((_a3 = this.config) == null ? void 0 : _a3.telemetryLevel) === "off") {
13364
+ if (((_a2 = this.config) == null ? void 0 : _a2.telemetryLevel) === "off") {
12906
13365
  return {};
12907
13366
  }
12908
- if (this.isDotCom()) {
13367
+ if (isDotCom(this.config.serverEndpoint)) {
12909
13368
  return this.sendEventLogRequestToAPI(event);
12910
13369
  }
12911
13370
  switch (define_process_default$2.env.CODY_LOG_EVENT_MODE) {
@@ -13040,7 +13499,7 @@ class SourcegraphGraphQLAPIClient {
13040
13499
  return extractDataOrError(response, (data) => JSON.parse(data.viewerSettings.final));
13041
13500
  }
13042
13501
  async fetchSourcegraphAPI(query, variables = {}, signalOrTimeout) {
13043
- var _a3;
13502
+ var _a2;
13044
13503
  const headers = new Headers(this.config.customHeaders);
13045
13504
  headers.set("Content-Type", "application/json; charset=utf-8");
13046
13505
  if (this.config.accessToken) {
@@ -13051,7 +13510,7 @@ class SourcegraphGraphQLAPIClient {
13051
13510
  }
13052
13511
  addTraceparent(headers);
13053
13512
  addCustomUserAgent(headers);
13054
- const queryName = (_a3 = query.match(QUERY_TO_NAME_REGEXP)) == null ? void 0 : _a3[1];
13513
+ const queryName = (_a2 = query.match(QUERY_TO_NAME_REGEXP)) == null ? void 0 : _a2[1];
13055
13514
  const url = buildGraphQLUrl({
13056
13515
  request: query,
13057
13516
  baseUrl: this.config.serverEndpoint
@@ -13084,7 +13543,7 @@ class SourcegraphGraphQLAPIClient {
13084
13543
  }
13085
13544
  // make an anonymous request to the dotcom API
13086
13545
  fetchSourcegraphDotcomAPI(query, variables) {
13087
- var _a3;
13546
+ var _a2;
13088
13547
  const url = buildGraphQLUrl({
13089
13548
  request: query,
13090
13549
  baseUrl: this.dotcomUrl.href
@@ -13092,7 +13551,7 @@ class SourcegraphGraphQLAPIClient {
13092
13551
  const headers = new Headers();
13093
13552
  addCustomUserAgent(headers);
13094
13553
  addTraceparent(headers);
13095
- const queryName = (_a3 = query.match(QUERY_TO_NAME_REGEXP)) == null ? void 0 : _a3[1];
13554
+ const queryName = (_a2 = query.match(QUERY_TO_NAME_REGEXP)) == null ? void 0 : _a2[1];
13096
13555
  return wrapInActiveSpan(
13097
13556
  `graphql.dotcom.fetch${queryName ? `.${queryName}` : ""}`,
13098
13557
  () => fetch(url, {
@@ -13169,7 +13628,7 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
13169
13628
  return _ClientConfigSingleton.instance;
13170
13629
  }
13171
13630
  async setAuthStatus(authStatus) {
13172
- this.isSignedIn = authStatus.authenticated && authStatus.isLoggedIn;
13631
+ this.isSignedIn = authStatus.authenticated;
13173
13632
  if (this.isSignedIn) {
13174
13633
  await this.refreshConfig();
13175
13634
  } else {
@@ -13257,7 +13716,6 @@ const _ClientConfigSingleton = class _ClientConfigSingleton {
13257
13716
  const smartContextWindow = await graphqlClient.getCodyLLMConfigurationSmartContext();
13258
13717
  const features = await this.fetchConfigFeaturesLegacy(this.featuresLegacy);
13259
13718
  return graphqlClient.isCodyEnabled().then((isCodyEnabled) => ({
13260
- codyEnabled: isCodyEnabled.enabled,
13261
13719
  chatEnabled: features.chat,
13262
13720
  autoCompleteEnabled: features.autoComplete,
13263
13721
  customCommandsEnabled: features.commands,
@@ -14334,1221 +14792,775 @@ class GraphQLTelemetryExporter {
14334
14792
  if (this.exportMode === "legacy") {
14335
14793
  const resultOrError2 = await Promise.all(
14336
14794
  events2.map(
14337
- (event) => {
14338
- var _a3, _b, _c;
14339
- return graphqlClient.logEvent(
14340
- {
14341
- client: event.source.client,
14342
- event: `${event.feature}.${event.action}`,
14343
- source: "IDEEXTENSION",
14344
- // hardcoded in existing client
14345
- url: ((_a3 = event.marketingTracking) == null ? void 0 : _a3.url) || "",
14346
- publicArgument: () => {
14347
- var _a4;
14348
- return (_a4 = event.parameters.metadata) == null ? void 0 : _a4.reduce((acc, curr) => ({
14349
- // biome-ignore lint/performance/noAccumulatingSpread: TODO(sqs): this is a legit perf issue
14350
- ...acc,
14351
- [curr.key]: curr.value
14352
- }));
14353
- },
14354
- argument: JSON.stringify(event.parameters.privateMetadata),
14355
- userCookieID: this.anonymousUserID || "",
14356
- connectedSiteID: (_b = this.legacySiteIdentification) == null ? void 0 : _b.siteid,
14357
- hashedLicenseKey: (_c = this.legacySiteIdentification) == null ? void 0 : _c.hashedLicenseKey
14358
- },
14359
- this.legacyBackcompatLogEventMode
14360
- );
14361
- }
14362
- )
14363
- );
14364
- if (isError(resultOrError2)) {
14365
- logError(
14366
- "GraphQLTelemetryExporter",
14367
- "Error exporting telemetry events as legacy event logs:",
14368
- resultOrError2,
14369
- {
14370
- legacyBackcompatLogEventMode: this.legacyBackcompatLogEventMode
14371
- }
14372
- );
14373
- }
14374
- return;
14375
- }
14376
- if (this.exportMode) {
14377
- handleExportModeTransforms(this.exportMode, events2);
14378
- }
14379
- const resultOrError = await graphqlClient.recordTelemetryEvents(events2);
14380
- if (isError(resultOrError)) {
14381
- logError("GraphQLTelemetryExporter", "Error exporting telemetry events:", resultOrError);
14382
- }
14383
- }
14384
- }
14385
- function handleExportModeTransforms(exportMode, events2) {
14386
- if (exportMode === "legacy") {
14387
- throw new Error("legacy export mode should not publish new telemetry events");
14388
- }
14389
- if (exportMode === "5.2.0-5.2.1") {
14390
- for (const event of events2) {
14391
- if (event.parameters) {
14392
- event.parameters.privateMetadata = void 0;
14393
- }
14394
- }
14395
- }
14396
- if (exportMode === "5.2.0-5.2.1" || exportMode === "5.2.2-5.2.3") {
14397
- for (const event of events2) {
14398
- if (event.parameters) {
14399
- if (event.parameters.metadata) {
14400
- for (const entry of event.parameters.metadata) {
14401
- entry.value = Math.round(entry.value);
14402
- }
14403
- }
14404
- event.parameters.interactionID = void 0;
14405
- }
14406
- }
14407
- }
14408
- if (exportMode === "5.2.0-5.2.1" || exportMode === "5.2.2-5.2.3" || exportMode === "5.2.4") {
14409
- for (const event of events2) {
14410
- event.timestamp = void 0;
14411
- }
14412
- }
14413
- }
14414
- function getTier(authStatus) {
14415
- return !authStatus.isDotCom ? 2 : authStatus.userCanUpgrade ? 0 : 1;
14416
- }
14417
- class TelemetryRecorderProvider extends dist.TelemetryRecorderProvider {
14418
- constructor(extensionDetails, config, authStatusProvider, anonymousUserID, legacyBackcompatLogEventMode) {
14419
- graphqlClient.setConfig(config);
14420
- const clientName = extensionDetails.telemetryClientName ? extensionDetails.telemetryClientName : `${extensionDetails.ide || "unknown"}.Cody`;
14421
- super(
14422
- {
14423
- client: clientName,
14424
- clientVersion: extensionDetails.version
14425
- },
14426
- new GraphQLTelemetryExporter(anonymousUserID, legacyBackcompatLogEventMode),
14427
- [
14428
- new ConfigurationMetadataProcessor(config, authStatusProvider),
14429
- // Generate timestamps when recording events, instead of serverside
14430
- new TimestampTelemetryProcessor_1()
14431
- ],
14432
- {
14433
- ...dist.defaultEventRecordingOptions,
14434
- bufferTimeMs: 0
14435
- // disable buffering for now
14436
- }
14437
- );
14438
- }
14439
- }
14440
- class DelegateTelemetryExporter {
14441
- constructor(delegate) {
14442
- __publicField(this, "exportedEvents", []);
14443
- // default to unset to make it clear when it's not set
14444
- __publicField(this, "anonymousUserID", "unset");
14445
- this.delegate = delegate;
14446
- }
14447
- async exportEvents(events2) {
14448
- this.exportedEvents.push(
14449
- ...events2.map((event) => ({
14450
- ...event,
14451
- testOnlyAnonymousUserID: this.anonymousUserID
14452
- }))
14453
- );
14454
- await this.delegate.exportEvents(events2);
14455
- }
14456
- withAnonymousUserID(anonymousUserID) {
14457
- this.anonymousUserID = anonymousUserID;
14458
- return this;
14459
- }
14460
- getExported() {
14461
- return [...this.exportedEvents];
14462
- }
14463
- reset() {
14464
- this.exportedEvents = [];
14465
- }
14466
- }
14467
- const TESTING_TELEMETRY_EXPORTER = new DelegateTelemetryExporter(new dist.TestTelemetryExporter());
14468
- class NoOpTelemetryRecorderProvider extends dist.TelemetryRecorderProvider {
14469
- constructor(processors2) {
14470
- super({ client: "" }, new dist.NoOpTelemetryExporter(), processors2 || []);
14471
- }
14472
- }
14473
- new NoOpTelemetryRecorderProvider().getRecorder();
14474
- class ConfigurationMetadataProcessor {
14475
- constructor(config, authStatusProvider) {
14476
- this.config = config;
14477
- this.authStatusProvider = authStatusProvider;
14478
- }
14479
- processEvent(event) {
14480
- if (!event.parameters.metadata) {
14481
- event.parameters.metadata = [];
14482
- }
14483
- event.parameters.metadata.push(
14484
- {
14485
- key: "contextSelection",
14486
- value: CONTEXT_SELECTION_ID[this.config.useContext]
14487
- },
14488
- {
14489
- key: "tier",
14490
- value: getTier(this.authStatusProvider.getAuthStatus())
14491
- }
14492
- );
14493
- }
14494
- }
14495
- var define_process_default$1 = { env: {} };
14496
- const debugLogLabel = "telemetry-v2";
14497
- let telemetryRecorderProvider;
14498
- let telemetryRecorder = new NoOpTelemetryRecorderProvider().getRecorder([
14499
- new dist.CallbackTelemetryProcessor(() => {
14500
- if (!define_process_default$1.env.VITEST) {
14501
- throw new Error("telemetry-v2: recorder used before initialization");
14502
- }
14503
- })
14504
- ]);
14505
- function updateGlobalTelemetryInstances(updatedProvider) {
14506
- telemetryRecorderProvider == null ? void 0 : telemetryRecorderProvider.unsubscribe();
14507
- telemetryRecorderProvider = updatedProvider;
14508
- telemetryRecorder = updatedProvider.getRecorder([
14509
- // Log all events in debug for reference.
14510
- new dist.CallbackTelemetryProcessor((event) => {
14511
- logDebug(
14512
- debugLogLabel,
14513
- `recordEvent${updatedProvider.noOp ? " (no-op)" : ""}: ${event.feature}/${event.action}`,
14514
- {
14515
- verbose: {
14516
- parameters: event.parameters,
14517
- timestamp: event.timestamp
14518
- }
14519
- }
14520
- );
14521
- })
14522
- ]);
14523
- }
14524
- class PromptString {
14525
- /**
14526
- * @deprecated Do not use the constructor directly. Instead, use ps`...` or a
14527
- * PromptString helper to handle string data for prompts safely
14528
- *
14529
- * @param __debug The string that is wrapped by this PromptString. This is
14530
- * useful for debugging since it will be shown when `console.log()` is called
14531
- * with this prompt string.
14532
- */
14533
- // @ts-expect-error: We don't want anyone to read __debug. This is just a helper
14534
- // for console.log debugging so this error is expected.
14535
- constructor(__debug) {
14536
- this.__debug = __debug;
14537
- }
14538
- toString() {
14539
- return internal_toString(this);
14540
- }
14541
- /**
14542
- * Returns a string that is safe to use in a prompt that is sent to an LLM.
14543
- */
14544
- async toFilteredString(contextFilter) {
14545
- const references = internal_toReferences(this);
14546
- const checks = references.map(
14547
- async (reference) => [reference, await contextFilter.isUriIgnored(reference)]
14548
- );
14549
- const resolved = await Promise.all(checks);
14550
- let shouldThrow = false;
14551
- for (const [reference, reason] of resolved) {
14552
- if (reason) {
14553
- shouldThrow = true;
14554
- logDebug(
14555
- "PromptString",
14556
- "toFilteredString",
14557
- `${reference} is ignored by the current context filters. Reason: ${reason}`,
14558
- { verbose: contextFilter.toDebugObject() }
14559
- );
14560
- telemetryRecorder.recordEvent("contextFilters.promptString", "illegalReference", {
14561
- privateMetadata: {
14562
- scheme: reference.scheme,
14563
- reason
14795
+ (event) => {
14796
+ var _a2, _b, _c;
14797
+ return graphqlClient.logEvent(
14798
+ {
14799
+ client: event.source.client,
14800
+ event: `${event.feature}.${event.action}`,
14801
+ source: "IDEEXTENSION",
14802
+ // hardcoded in existing client
14803
+ url: ((_a2 = event.marketingTracking) == null ? void 0 : _a2.url) || "",
14804
+ publicArgument: () => {
14805
+ var _a3;
14806
+ return (_a3 = event.parameters.metadata) == null ? void 0 : _a3.reduce((acc, curr) => ({
14807
+ // biome-ignore lint/performance/noAccumulatingSpread: TODO(sqs): this is a legit perf issue
14808
+ ...acc,
14809
+ [curr.key]: curr.value
14810
+ }));
14811
+ },
14812
+ argument: JSON.stringify(event.parameters.privateMetadata),
14813
+ userCookieID: this.anonymousUserID || "",
14814
+ connectedSiteID: (_b = this.legacySiteIdentification) == null ? void 0 : _b.siteid,
14815
+ hashedLicenseKey: (_c = this.legacySiteIdentification) == null ? void 0 : _c.hashedLicenseKey
14816
+ },
14817
+ this.legacyBackcompatLogEventMode
14818
+ );
14564
14819
  }
14565
- });
14820
+ )
14821
+ );
14822
+ if (isError(resultOrError2)) {
14823
+ logError(
14824
+ "GraphQLTelemetryExporter",
14825
+ "Error exporting telemetry events as legacy event logs:",
14826
+ resultOrError2,
14827
+ {
14828
+ legacyBackcompatLogEventMode: this.legacyBackcompatLogEventMode
14829
+ }
14830
+ );
14566
14831
  }
14832
+ return;
14567
14833
  }
14568
- if (shouldThrow) {
14569
- throw new Error(
14570
- "The prompt contains a reference to a file that is not allowed by your current Cody policy."
14571
- );
14834
+ if (this.exportMode) {
14835
+ handleExportModeTransforms(this.exportMode, events2);
14572
14836
  }
14573
- return internal_toString(this);
14574
- }
14575
- getReferences() {
14576
- return internal_toReferences(this);
14577
- }
14578
- toJSON() {
14579
- return internal_toString(this);
14580
- }
14581
- get length() {
14582
- return internal_toString(this).length;
14583
- }
14584
- slice(start, end) {
14585
- return internal_createPromptString(
14586
- internal_toString(this).slice(start, end),
14587
- internal_toReferences(this)
14588
- );
14589
- }
14590
- trim() {
14591
- return internal_createPromptString(internal_toString(this).trim(), internal_toReferences(this));
14592
- }
14593
- trimEnd() {
14594
- return internal_createPromptString(
14595
- internal_toString(this).trimEnd(),
14596
- internal_toReferences(this)
14597
- );
14598
- }
14599
- indexOf(searchString, start) {
14600
- return this.toString().indexOf(searchString.toString(), start);
14601
- }
14602
- split(separator) {
14603
- const string2 = internal_toString(this);
14604
- const references = internal_toReferences(this);
14605
- const split = string2.split(separator);
14606
- const result = [];
14607
- for (const part of split) {
14608
- result.push(internal_createPromptString(part, references));
14837
+ const resultOrError = await graphqlClient.recordTelemetryEvents(events2);
14838
+ if (isError(resultOrError)) {
14839
+ logError("GraphQLTelemetryExporter", "Error exporting telemetry events:", resultOrError);
14609
14840
  }
14610
- return result;
14611
- }
14612
- toLocaleLowerCase() {
14613
- return internal_createPromptString(
14614
- internal_toString(this).toLocaleLowerCase(),
14615
- internal_toReferences(this)
14616
- );
14617
14841
  }
14618
- includes(searchString, position) {
14619
- return internal_toString(this).includes(
14620
- typeof searchString === "string" ? searchString : internal_toString(searchString),
14621
- position
14622
- );
14842
+ }
14843
+ function handleExportModeTransforms(exportMode, events2) {
14844
+ if (exportMode === "legacy") {
14845
+ throw new Error("legacy export mode should not publish new telemetry events");
14623
14846
  }
14624
- static join(promptStrings, boundary) {
14625
- const stringBoundary = internal_toString(boundary);
14626
- const buffer = [];
14627
- const references = new Set(internal_toReferences(boundary));
14628
- for (const promptString of promptStrings) {
14629
- if (!isValidPromptString(promptString)) {
14630
- throw new Error("Invalid prompt string");
14631
- }
14632
- buffer.push(internal_toString(promptString));
14633
- for (const reference of internal_toReferences(promptString)) {
14634
- references.add(reference);
14847
+ if (exportMode === "5.2.0-5.2.1") {
14848
+ for (const event of events2) {
14849
+ if (event.parameters) {
14850
+ event.parameters.privateMetadata = void 0;
14635
14851
  }
14636
14852
  }
14637
- return internal_createPromptString(buffer.join(stringBoundary), [...references]);
14638
14853
  }
14639
- concat(...promptStrings) {
14640
- const stringPromptString = [];
14641
- const references = [];
14642
- for (const promptString of promptStrings) {
14643
- stringPromptString.push(internal_toString(promptString));
14644
- references.push(internal_toReferences(promptString));
14854
+ if (exportMode === "5.2.0-5.2.1" || exportMode === "5.2.2-5.2.3") {
14855
+ for (const event of events2) {
14856
+ if (event.parameters) {
14857
+ if (event.parameters.metadata) {
14858
+ for (const entry of event.parameters.metadata) {
14859
+ entry.value = Math.round(entry.value);
14860
+ }
14861
+ }
14862
+ event.parameters.interactionID = void 0;
14863
+ }
14645
14864
  }
14646
- return internal_createPromptString(internal_toString(this).concat(...stringPromptString), [
14647
- ...internal_toReferences(this),
14648
- ...references.flat()
14649
- ]);
14650
14865
  }
14651
- replace(searchValue, replaceValue) {
14652
- const stringReplaceValue = internal_toString(replaceValue);
14653
- const references = internal_toReferences(replaceValue);
14654
- return internal_createPromptString(
14655
- internal_toString(this).replace(searchValue, stringReplaceValue),
14656
- [...internal_toReferences(this), ...references]
14657
- );
14866
+ if (exportMode === "5.2.0-5.2.1" || exportMode === "5.2.2-5.2.3" || exportMode === "5.2.4") {
14867
+ for (const event of events2) {
14868
+ event.timestamp = void 0;
14869
+ }
14658
14870
  }
14659
- replaceAll(searchValue, replaceValue) {
14660
- const stringReplaceValue = internal_toString(replaceValue);
14661
- const references = internal_toReferences(replaceValue);
14662
- return internal_createPromptString(
14663
- internal_toString(this).replaceAll(searchValue, stringReplaceValue),
14664
- [...internal_toReferences(this), ...references]
14871
+ }
14872
+ function getTier(authStatus) {
14873
+ return !authStatus.authenticated ? void 0 : !isDotCom(authStatus) ? 2 : authStatus.userCanUpgrade ? 0 : 1;
14874
+ }
14875
+ class TelemetryRecorderProvider extends dist.TelemetryRecorderProvider {
14876
+ constructor(extensionDetails, config, authStatusProvider, anonymousUserID, legacyBackcompatLogEventMode) {
14877
+ graphqlClient.setConfig(config);
14878
+ const clientName = extensionDetails.telemetryClientName ? extensionDetails.telemetryClientName : `${extensionDetails.ide || "unknown"}.Cody`;
14879
+ super(
14880
+ {
14881
+ client: clientName,
14882
+ clientVersion: extensionDetails.version
14883
+ },
14884
+ new GraphQLTelemetryExporter(anonymousUserID, legacyBackcompatLogEventMode),
14885
+ [
14886
+ new ConfigurationMetadataProcessor(config, authStatusProvider),
14887
+ // Generate timestamps when recording events, instead of serverside
14888
+ new TimestampTelemetryProcessor_1()
14889
+ ],
14890
+ {
14891
+ ...dist.defaultEventRecordingOptions,
14892
+ bufferTimeMs: 0
14893
+ // disable buffering for now
14894
+ }
14665
14895
  );
14666
14896
  }
14667
- // Use this function to create a user-generated PromptString from the VS Code
14668
- // configuration object.
14669
- static fromConfig(config, path, defaultValue) {
14670
- const raw = config.get(path, null);
14671
- const value = raw === null ? defaultValue : internal_createPromptString(raw, []);
14672
- return value;
14673
- }
14674
- static fromEditorIndentString(uri, workspace, window2) {
14675
- const insertSpaces = getEditorInsertSpaces(uri, workspace, window2);
14676
- const tabSize = getEditorTabSize(uri, workspace, window2);
14677
- const indentString = insertSpaces ? " ".repeat(tabSize) : " ";
14678
- return internal_createPromptString(indentString, []);
14679
- }
14680
- static fromDisplayPath(uri) {
14681
- return internal_createPromptString(displayPath(uri), [uri]);
14682
- }
14683
- static fromDisplayPathLineRange(uri, range2) {
14684
- const pathToDisplay = range2 ? displayPathWithLines(uri, range2) : displayPath(uri);
14685
- return internal_createPromptString(pathToDisplay, [uri]);
14686
- }
14687
- static fromDocumentText(document2, range2) {
14688
- return internal_createPromptString(document2.getText(range2), [document2.uri]);
14689
- }
14690
- static fromGitDiff(uri, oldContent, newContent) {
14691
- const diff3 = createGitDiff(displayPath(uri), oldContent, newContent);
14692
- return internal_createPromptString(diff3, [uri]);
14693
- }
14694
- // Replaces the following placeholder with data from the diagnostics:
14695
- // {type}, {filePath}, {prefix}, {message}, {languageID}, {code}
14696
- //
14697
- // TODO: This should probably take a vscode.Diagnostic object instead.
14698
- static fromTextEditorDiagnostic(diagnostic, uri) {
14699
- const ref = [uri];
14700
- return {
14701
- type: internal_createPromptString(diagnostic.type, ref),
14702
- text: internal_createPromptString(diagnostic.text, ref),
14703
- message: internal_createPromptString(diagnostic.message, ref)
14704
- };
14705
- }
14706
- static fromMarkdownCodeBlockLanguageIDForFilename(uri) {
14707
- return internal_createPromptString(markdownCodeBlockLanguageIDForFilename(uri), [uri]);
14708
- }
14709
- static fromDiagnostic(uri, diagnostic) {
14710
- const ref = [uri];
14711
- return {
14712
- message: internal_createPromptString(diagnostic.message, ref),
14713
- source: diagnostic.source ? internal_createPromptString(diagnostic.source, ref) : void 0,
14714
- relatedInformation: diagnostic.relatedInformation ? diagnostic.relatedInformation.map((info) => ({
14715
- message: internal_createPromptString(info.message, [uri, info.location.uri])
14716
- })) : void 0
14717
- };
14718
- }
14719
- static fromDocumentSymbol(uri, documentSymbol, SymbolKind) {
14720
- const symbolKind = documentSymbol.kind ? SymbolKind[documentSymbol.kind].toLowerCase() : "";
14721
- const symbolPrompt = documentSymbol.name ? `#${documentSymbol.name} (${symbolKind})` : "";
14722
- return internal_createPromptString(symbolPrompt, [uri]);
14723
- }
14724
- // TODO: Find a better way to handle this. Maybe we should migrate the default commands json to
14725
- // a TypesScript object?
14726
- static fromDefaultCommands(commands, name) {
14727
- const prompt = commands[name].prompt;
14728
- return internal_createPromptString(prompt, []);
14729
- }
14730
- // TODO: Need to check in the runtime if we have something we can append as an URI here
14731
- static fromTerminalOutputArguments(output) {
14732
- return {
14733
- name: internal_createPromptString(output.name, []),
14734
- selection: output.selection ? internal_createPromptString(output.selection, []) : void 0,
14735
- creationOptions: output.creationOptions ? internal_createPromptString(JSON.stringify(output.creationOptions), []) : void 0
14736
- };
14737
- }
14738
- static fromAutocompleteDocumentContext(docContext, uri) {
14739
- const ref = [uri];
14740
- return {
14741
- prefix: internal_createPromptString(docContext.prefix, ref),
14742
- suffix: internal_createPromptString(docContext.suffix, ref),
14743
- injectedPrefix: docContext.injectedPrefix ? internal_createPromptString(docContext.injectedPrefix, ref) : null
14744
- };
14745
- }
14746
- static fromAutocompleteContextSnippet(contextSnippet) {
14747
- const ref = [contextSnippet.uri];
14748
- return {
14749
- content: internal_createPromptString(contextSnippet.content, ref),
14750
- symbol: "symbol" in contextSnippet ? internal_createPromptString(contextSnippet.symbol, ref) : void 0
14751
- };
14897
+ }
14898
+ class DelegateTelemetryExporter {
14899
+ constructor(delegate) {
14900
+ __publicField(this, "exportedEvents", []);
14901
+ // default to unset to make it clear when it's not set
14902
+ __publicField(this, "anonymousUserID", "unset");
14903
+ this.delegate = delegate;
14752
14904
  }
14753
- static fromAutocompleteGitContext(gitContext, uri) {
14754
- const ref = [uri];
14755
- return {
14756
- repoName: internal_createPromptString(gitContext.repoName, ref)
14757
- };
14905
+ async exportEvents(events2) {
14906
+ this.exportedEvents.push(
14907
+ ...events2.map((event) => ({
14908
+ ...event,
14909
+ testOnlyAnonymousUserID: this.anonymousUserID
14910
+ }))
14911
+ );
14912
+ await this.delegate.exportEvents(events2);
14758
14913
  }
14759
- static fromContextItem(contextItem) {
14760
- const ref = [contextItem.uri];
14761
- return {
14762
- content: typeof contextItem.content === "string" ? internal_createPromptString(contextItem.content, ref) : void 0,
14763
- repoName: contextItem.repoName ? internal_createPromptString(contextItem.repoName, ref) : void 0,
14764
- title: contextItem.title ? internal_createPromptString(contextItem.title, ref) : void 0
14765
- };
14914
+ withAnonymousUserID(anonymousUserID) {
14915
+ this.anonymousUserID = anonymousUserID;
14916
+ return this;
14766
14917
  }
14767
- // 🚨 Use this function only for user-generated queries.
14768
- // TODO: Can we detect if the user is pasting in content from a document?
14769
- static unsafe_fromUserQuery(string2) {
14770
- return internal_createPromptString(string2, []);
14918
+ getExported() {
14919
+ return [...this.exportedEvents];
14771
14920
  }
14772
- // 🚨 Use this function only for LLM responses queries.
14773
- static unsafe_fromLLMResponse(string2) {
14774
- return internal_createPromptString(string2, []);
14921
+ reset() {
14922
+ this.exportedEvents = [];
14775
14923
  }
14776
- // 🚨 We slam chats in and out of storage quite a bit, so it seems weird to
14777
- // have references on a chat transcript, but closing and opening the chat
14778
- // panel or restarting the IDE makes those references evaporate.
14779
- //
14780
- // On the other hand, you might pull up an old chat transcript and all the
14781
- // file paths are different now because you moved a folder or something. We're
14782
- // thinking maybe we should have a concept of "resolved" references where we
14783
- // keep (repo, repo relative path) pairs for the serialized representation
14784
- // or something.
14785
- //
14786
- // Additionally, the serialized chat message format is also used when sending
14787
- // chat messages back to the Agent. Right now, however, when we send new
14788
- // messages, this is done via the `chat/submitMessage` notification which does
14789
- // not deserialize from chat message. To make sure we do not introduce places
14790
- // where we deserialize chat messages this way, the function is marked unsafe
14791
- // for now.
14792
- static unsafe_deserializeChatMessage(serializedMessage) {
14793
- return {
14794
- ...serializedMessage,
14795
- text: serializedMessage.text ? internal_createPromptString(serializedMessage.text, []) : void 0
14796
- };
14924
+ }
14925
+ const TESTING_TELEMETRY_EXPORTER = new DelegateTelemetryExporter(new dist.TestTelemetryExporter());
14926
+ class NoOpTelemetryRecorderProvider extends dist.TelemetryRecorderProvider {
14927
+ constructor(processors2) {
14928
+ super({ client: "" }, new dist.NoOpTelemetryExporter(), processors2 || []);
14797
14929
  }
14798
14930
  }
14799
- function ps$1(format2, ...args) {
14800
- if (!(Array.isArray(format2) && Object.isFrozen(format2) && format2.length > 0)) {
14801
- throw new Error("ps is only intended to be used in tagged template literals.");
14931
+ new NoOpTelemetryRecorderProvider().getRecorder();
14932
+ class ConfigurationMetadataProcessor {
14933
+ constructor(config, authStatusProvider) {
14934
+ this.config = config;
14935
+ this.authStatusProvider = authStatusProvider;
14802
14936
  }
14803
- const buffer = [];
14804
- const references = /* @__PURE__ */ new Set();
14805
- for (let i3 = 0; i3 < format2.length; i3++) {
14806
- buffer.push(format2[i3]);
14807
- if (i3 < args.length) {
14808
- const arg = args[i3];
14809
- if (typeof arg === "number") {
14810
- buffer.push(Number.prototype.toString.call(arg));
14811
- } else if (arg === "") ;
14812
- else if (arg instanceof PromptString) {
14813
- buffer.push(internal_toString(arg));
14814
- for (const ref of internal_toReferences(arg)) {
14815
- references.add(ref);
14937
+ processEvent(event) {
14938
+ if (!event.parameters.metadata) {
14939
+ event.parameters.metadata = [];
14940
+ }
14941
+ event.parameters.metadata.push({
14942
+ key: "contextSelection",
14943
+ value: CONTEXT_SELECTION_ID[this.config.useContext]
14944
+ });
14945
+ let authStatus;
14946
+ try {
14947
+ authStatus = this.authStatusProvider.status;
14948
+ } catch {
14949
+ }
14950
+ if (authStatus) {
14951
+ event.parameters.metadata.push({
14952
+ key: "tier",
14953
+ value: getTier(authStatus)
14954
+ });
14955
+ }
14956
+ }
14957
+ }
14958
+ var define_process_default$1 = { env: {} };
14959
+ const debugLogLabel = "telemetry-v2";
14960
+ let telemetryRecorderProvider;
14961
+ let telemetryRecorder = new NoOpTelemetryRecorderProvider().getRecorder([
14962
+ new dist.CallbackTelemetryProcessor(() => {
14963
+ if (!define_process_default$1.env.VITEST) {
14964
+ throw new Error("telemetry-v2: recorder used before initialization");
14965
+ }
14966
+ })
14967
+ ]);
14968
+ function updateGlobalTelemetryInstances(updatedProvider) {
14969
+ telemetryRecorderProvider == null ? void 0 : telemetryRecorderProvider.unsubscribe();
14970
+ telemetryRecorderProvider = updatedProvider;
14971
+ telemetryRecorder = updatedProvider.getRecorder([
14972
+ // Log all events in debug for reference.
14973
+ new dist.CallbackTelemetryProcessor((event) => {
14974
+ logDebug(
14975
+ debugLogLabel,
14976
+ `recordEvent${updatedProvider.noOp ? " (no-op)" : ""}: ${event.feature}/${event.action}`,
14977
+ {
14978
+ verbose: {
14979
+ parameters: event.parameters,
14980
+ timestamp: event.timestamp
14981
+ }
14816
14982
  }
14817
- } else {
14818
- throw new Error(
14819
- "Use ps`...` or a PromptString helper to handle string data for prompts safely."
14983
+ );
14984
+ })
14985
+ ]);
14986
+ }
14987
+ class PromptString {
14988
+ /**
14989
+ * @deprecated Do not use the constructor directly. Instead, use ps`...` or a
14990
+ * PromptString helper to handle string data for prompts safely
14991
+ *
14992
+ * @param __debug The string that is wrapped by this PromptString. This is
14993
+ * useful for debugging since it will be shown when `console.log()` is called
14994
+ * with this prompt string.
14995
+ */
14996
+ // @ts-expect-error: We don't want anyone to read __debug. This is just a helper
14997
+ // for console.log debugging so this error is expected.
14998
+ constructor(__debug) {
14999
+ this.__debug = __debug;
15000
+ }
15001
+ toString() {
15002
+ return internal_toString(this);
15003
+ }
15004
+ /**
15005
+ * Returns a string that is safe to use in a prompt that is sent to an LLM.
15006
+ */
15007
+ async toFilteredString(contextFilter) {
15008
+ const references = internal_toReferences(this);
15009
+ const checks = references.map(
15010
+ async (reference) => [reference, await contextFilter.isUriIgnored(reference)]
15011
+ );
15012
+ const resolved = await Promise.all(checks);
15013
+ let shouldThrow = false;
15014
+ for (const [reference, reason] of resolved) {
15015
+ if (reason) {
15016
+ shouldThrow = true;
15017
+ logDebug(
15018
+ "PromptString",
15019
+ "toFilteredString",
15020
+ `${reference} is ignored by the current context filters. Reason: ${reason}`,
15021
+ { verbose: contextFilter.toDebugObject() }
14820
15022
  );
15023
+ telemetryRecorder.recordEvent("contextFilters.promptString", "illegalReference", {
15024
+ privateMetadata: {
15025
+ scheme: reference.scheme,
15026
+ reason
15027
+ }
15028
+ });
14821
15029
  }
14822
15030
  }
15031
+ if (shouldThrow) {
15032
+ throw new Error(
15033
+ "The prompt contains a reference to a file that is not allowed by your current Cody policy."
15034
+ );
15035
+ }
15036
+ return internal_toString(this);
14823
15037
  }
14824
- return internal_createPromptString(buffer.join(""), [...references]);
14825
- }
14826
- function psDedent(format2, ...args) {
14827
- const promptString = ps$1(format2, ...args);
14828
- const dedented = dedent(internal_toString(promptString));
14829
- return internal_createPromptString(dedented, internal_toReferences(promptString));
14830
- }
14831
- const pocket = /* @__PURE__ */ new WeakMap();
14832
- class PromptStringPocket {
14833
- constructor(value, references) {
14834
- this.value = value;
14835
- this.references = references;
15038
+ getReferences() {
15039
+ return internal_toReferences(this);
14836
15040
  }
14837
- }
14838
- function internal_createPromptString(string2, references) {
14839
- const handle = new PromptString(string2);
14840
- pocket.set(handle, new PromptStringPocket(string2, new Set(references)));
14841
- return handle;
14842
- }
14843
- function internal_toString(s4) {
14844
- return pocket.get(s4).value;
14845
- }
14846
- function internal_toReferences(s4) {
14847
- return [...pocket.get(s4).references.values()];
14848
- }
14849
- function isValidPromptString(promptString) {
14850
- return pocket.has(promptString);
14851
- }
14852
- function toRangeData(range2) {
14853
- const data = Array.isArray(range2) ? { start: range2[0], end: range2[1] } : range2;
14854
- return data ? {
14855
- start: { line: data.start.line, character: data.start.character },
14856
- end: { line: data.end.line, character: data.end.character }
14857
- } : void 0;
14858
- }
14859
- function displayLineRange(range2) {
14860
- const lineRange = expandToLineRange(range2);
14861
- const startLine = lineRange.start.line + 1;
14862
- const endLine = lineRange.end.line;
14863
- if (endLine === startLine) {
14864
- return ps$1`${startLine}`;
15041
+ toJSON() {
15042
+ return internal_toString(this);
14865
15043
  }
14866
- return ps$1`${startLine}-${endLine}`;
14867
- }
14868
- function expandToLineRange(range2) {
14869
- const hasEndLineCharacters = range2.end.line === range2.start.line || range2.end.character !== 0;
14870
- const endLine = range2.end.line + (hasEndLineCharacters ? 1 : 0);
14871
- return {
14872
- start: { line: range2.start.line, character: 0 },
14873
- end: { line: endLine, character: 0 }
14874
- };
14875
- }
14876
- function displayPath(location) {
14877
- const result = _displayPath(location, checkEnvInfo());
14878
- return typeof result === "string" ? result : result.toString();
14879
- }
14880
- function displayPathWithLines(location, range2) {
14881
- return `${displayPath(location)}:${displayLineRange(range2)}`;
14882
- }
14883
- function displayPathDirname(location) {
14884
- const envInfo2 = checkEnvInfo();
14885
- const result = _displayPath(location, envInfo2);
14886
- if (typeof result === "string") {
14887
- return envInfo2.isWindows ? windowsFilePaths.dirname(result) : posixFilePaths.dirname(result);
15044
+ get length() {
15045
+ return internal_toString(this).length;
14888
15046
  }
14889
- const dirname = pathFunctionsForURI(location, envInfo2.isWindows).dirname;
14890
- return result.with({ path: dirname(result.path) }).toString();
14891
- }
14892
- function displayPathBasename(location) {
14893
- const envInfo2 = checkEnvInfo();
14894
- const result = _displayPath(location, envInfo2);
14895
- if (typeof result === "string") {
14896
- return envInfo2.isWindows ? windowsFilePaths.basename(result) : posixFilePaths.basename(result);
15047
+ slice(start, end) {
15048
+ return internal_createPromptString(
15049
+ internal_toString(this).slice(start, end),
15050
+ internal_toReferences(this)
15051
+ );
14897
15052
  }
14898
- return posixFilePaths.basename(result.path);
14899
- }
14900
- function checkEnvInfo() {
14901
- if (!envInfo) {
14902
- throw new Error(
14903
- "no environment info for displayPath function (call setDisplayPathEnvInfo; see displayPath docstring for more info)"
15053
+ trim() {
15054
+ return internal_createPromptString(internal_toString(this).trim(), internal_toReferences(this));
15055
+ }
15056
+ trimEnd() {
15057
+ return internal_createPromptString(
15058
+ internal_toString(this).trimEnd(),
15059
+ internal_toReferences(this)
14904
15060
  );
14905
15061
  }
14906
- return envInfo;
14907
- }
14908
- function _displayPath(location, { workspaceFolders, isWindows: isWindows2 }, includeWorkspaceFolderWhenMultiple = true) {
14909
- const uri = typeof location === "string" ? URI.parse(location) : URI.from(location);
14910
- const includeWorkspaceFolder = includeWorkspaceFolderWhenMultiple && workspaceFolders.length >= 2;
14911
- for (const folder of workspaceFolders) {
14912
- if (uriHasPrefix(uri, folder, isWindows2)) {
14913
- const pathFunctions2 = pathFunctionsForURI(folder);
14914
- const workspacePrefix = folder.path.endsWith("/") ? folder.path.slice(0, -1) : folder.path;
14915
- const workspaceDisplayPrefix = includeWorkspaceFolder ? pathFunctions2.basename(folder.path) + pathFunctions2.separator : "";
14916
- return fixPathSep(
14917
- workspaceDisplayPrefix + uri.path.slice(workspacePrefix.length + 1),
14918
- isWindows2,
14919
- uri.scheme
14920
- );
15062
+ indexOf(searchString, start) {
15063
+ return this.toString().indexOf(searchString.toString(), start);
15064
+ }
15065
+ split(separator) {
15066
+ const string2 = internal_toString(this);
15067
+ const references = internal_toReferences(this);
15068
+ const split = string2.split(separator);
15069
+ const result = [];
15070
+ for (const part of split) {
15071
+ result.push(internal_createPromptString(part, references));
14921
15072
  }
15073
+ return result;
14922
15074
  }
14923
- if (uri.scheme === "file") {
14924
- return fixPathSep(uri.fsPath, isWindows2, uri.scheme);
15075
+ toLocaleLowerCase() {
15076
+ return internal_createPromptString(
15077
+ internal_toString(this).toLocaleLowerCase(),
15078
+ internal_toReferences(this)
15079
+ );
14925
15080
  }
14926
- return uri;
14927
- }
14928
- function fixPathSep(fsPath, isWindows2, scheme) {
14929
- return isWindows2 && scheme === "file" ? fsPath.replaceAll("/", "\\") : fsPath;
14930
- }
14931
- function uriHasPrefix(uri, prefix, isWindows2) {
14932
- const uriPath = isWindows2 && uri.scheme === "file" ? uri.path.slice(0, 2).toUpperCase() + uri.path.slice(2) : uri.path;
14933
- const prefixPath = isWindows2 && prefix.scheme === "file" ? prefix.path.slice(0, 2).toUpperCase() + prefix.path.slice(2) : prefix.path;
14934
- return uri.scheme === prefix.scheme && (uri.authority ?? "") === (prefix.authority ?? "") && // different URI impls treat empty different
14935
- (uriPath === prefixPath || uriPath.startsWith(prefixPath.endsWith("/") ? prefixPath : `${prefixPath}/`) || prefixPath.endsWith("/") && uriPath === prefixPath.slice(0, -1));
14936
- }
14937
- let envInfo = null;
14938
- function setDisplayPathEnvInfo(newEnvInfo) {
14939
- const prev = envInfo;
14940
- envInfo = newEnvInfo;
14941
- return prev;
14942
- }
14943
- const CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID = "_cody.vscode.open";
14944
- function commandURIForVSCodeOpen(resource, range2) {
14945
- return `command:${CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID}?${encodeURIComponent(
14946
- JSON.stringify([
14947
- resource,
14948
- {
14949
- selection: range2,
14950
- preserveFocus: true,
14951
- background: false,
14952
- preview: true,
14953
- viewColumn: -2
14954
- }
14955
- ])
14956
- )}`;
14957
- }
14958
- function webviewOpenURIForContextItem(item) {
14959
- if (item.uri.scheme === "http" || item.uri.scheme === "https") {
14960
- return {
14961
- href: item.uri.toString(),
14962
- target: "_blank"
14963
- };
15081
+ includes(searchString, position) {
15082
+ return internal_toString(this).includes(
15083
+ typeof searchString === "string" ? searchString : internal_toString(searchString),
15084
+ position
15085
+ );
14964
15086
  }
14965
- return { href: commandURIForVSCodeOpen(item.uri, item.range), target: void 0 };
14966
- }
14967
- const STOP_SEQUENCE_REGEXP = /(H|Hu|Hum|Huma|Human|Human:)$/;
14968
- function reformatBotMessageForChat(text) {
14969
- let reformattedMessage = text.trimEnd();
14970
- const stopSequenceMatch = reformattedMessage.toString().match(STOP_SEQUENCE_REGEXP);
14971
- if (stopSequenceMatch) {
14972
- reformattedMessage = reformattedMessage.slice(0, stopSequenceMatch.index);
15087
+ static join(promptStrings, boundary) {
15088
+ const stringBoundary = internal_toString(boundary);
15089
+ const buffer = [];
15090
+ const references = new Set(internal_toReferences(boundary));
15091
+ for (const promptString of promptStrings) {
15092
+ if (!isValidPromptString(promptString)) {
15093
+ throw new Error("Invalid prompt string");
15094
+ }
15095
+ buffer.push(internal_toString(promptString));
15096
+ for (const reference of internal_toReferences(promptString)) {
15097
+ references.add(reference);
15098
+ }
15099
+ }
15100
+ return internal_createPromptString(buffer.join(stringBoundary), [...references]);
14973
15101
  }
14974
- return fixOpenMarkdownCodeBlock(reformattedMessage);
14975
- }
14976
- function fixOpenMarkdownCodeBlock(text) {
14977
- const occurrences = text.split("```").length - 1;
14978
- if (occurrences % 2 === 1) {
14979
- return text.concat(ps$1`\n\`\`\``);
15102
+ concat(...promptStrings) {
15103
+ const stringPromptString = [];
15104
+ const references = [];
15105
+ for (const promptString of promptStrings) {
15106
+ stringPromptString.push(internal_toString(promptString));
15107
+ references.push(internal_toReferences(promptString));
15108
+ }
15109
+ return internal_createPromptString(internal_toString(this).concat(...stringPromptString), [
15110
+ ...internal_toReferences(this),
15111
+ ...references.flat()
15112
+ ]);
14980
15113
  }
14981
- return text;
14982
- }
14983
- var ContextItemSource = /* @__PURE__ */ ((ContextItemSource2) => {
14984
- ContextItemSource2["Embeddings"] = "embeddings";
14985
- ContextItemSource2["User"] = "user";
14986
- ContextItemSource2["Editor"] = "editor";
14987
- ContextItemSource2["Search"] = "search";
14988
- ContextItemSource2["Initial"] = "initial";
14989
- ContextItemSource2["Unified"] = "unified";
14990
- ContextItemSource2["Selection"] = "selection";
14991
- ContextItemSource2["Terminal"] = "terminal";
14992
- ContextItemSource2["Uri"] = "uri";
14993
- ContextItemSource2["History"] = "history";
14994
- return ContextItemSource2;
14995
- })(ContextItemSource || {});
14996
- const GENERAL_HELP_LABEL = "Search for a file to include, or type # for symbols...";
14997
- const NO_SYMBOL_MATCHES_HELP_LABEL = " (language extensions may be loading)";
14998
- const FILE_RANGE_TOOLTIP_LABEL = "Type a line range to include, e.g. 5-10...";
14999
- const LARGE_FILE_WARNING_LABEL = "File too large. Add line range with : or use @# to choose a symbol";
15000
- const IGNORED_FILE_WARNING_LABEL = "File ignored by an admin setting.";
15001
- var DefaultChatCommands = /* @__PURE__ */ ((DefaultChatCommands2) => {
15002
- DefaultChatCommands2["Explain"] = "explain";
15003
- DefaultChatCommands2["Unit"] = "unit";
15004
- DefaultChatCommands2["Smell"] = "smell";
15005
- DefaultChatCommands2["Custom"] = "custom-chat";
15006
- return DefaultChatCommands2;
15007
- })(DefaultChatCommands || {});
15008
- var DefaultEditCommands = /* @__PURE__ */ ((DefaultEditCommands2) => {
15009
- DefaultEditCommands2["Test"] = "test";
15010
- DefaultEditCommands2["Doc"] = "doc";
15011
- DefaultEditCommands2["Edit"] = "edit";
15012
- DefaultEditCommands2["Custom"] = "custom-edit";
15013
- return DefaultEditCommands2;
15014
- })(DefaultEditCommands || {});
15015
- var CustomCommandType = /* @__PURE__ */ ((CustomCommandType2) => {
15016
- CustomCommandType2["Workspace"] = "workspace";
15017
- CustomCommandType2["User"] = "user";
15018
- return CustomCommandType2;
15019
- })(CustomCommandType || {});
15020
- function hydrateAfterPostMessage(value, hydrateUri) {
15021
- if (isDehydratedUri(value)) {
15022
- return hydrateUri(value);
15114
+ replace(searchValue, replaceValue) {
15115
+ const stringReplaceValue = internal_toString(replaceValue);
15116
+ const references = internal_toReferences(replaceValue);
15117
+ return internal_createPromptString(
15118
+ internal_toString(this).replace(searchValue, stringReplaceValue),
15119
+ [...internal_toReferences(this), ...references]
15120
+ );
15023
15121
  }
15024
- if (Array.isArray(value)) {
15025
- return value.map((e3) => hydrateAfterPostMessage(e3, hydrateUri));
15122
+ replaceAll(searchValue, replaceValue) {
15123
+ const stringReplaceValue = internal_toString(replaceValue);
15124
+ const references = internal_toReferences(replaceValue);
15125
+ return internal_createPromptString(
15126
+ internal_toString(this).replaceAll(searchValue, stringReplaceValue),
15127
+ [...internal_toReferences(this), ...references]
15128
+ );
15026
15129
  }
15027
- if (value instanceof Object) {
15028
- for (const key of Object.keys(value)) {
15029
- value[key] = hydrateAfterPostMessage(value[key], hydrateUri);
15030
- }
15130
+ // Use this function to create a user-generated PromptString from the VS Code
15131
+ // configuration object.
15132
+ static fromConfig(config, path, defaultValue) {
15133
+ const raw = config.get(path, null);
15134
+ const value = raw === null ? defaultValue : internal_createPromptString(raw, []);
15031
15135
  return value;
15032
15136
  }
15033
- return value;
15034
- }
15035
- function isDehydratedUri(value) {
15036
- return Boolean(value) && // vscode.Uri
15037
- (value.$mid !== void 0 && value.path !== void 0 && value.scheme !== void 0 || // vscode-uri.URI
15038
- value.authority !== void 0 && value.path !== void 0 && value.fragment !== void 0 && value.query !== void 0);
15039
- }
15040
- const hasSymbols = () => typeof Symbol === "function";
15041
- const hasSymbol = (name) => hasSymbols() && Boolean(Symbol[name]);
15042
- const getSymbol = (name) => hasSymbol(name) ? Symbol[name] : "@@" + name;
15043
- if (!hasSymbol("asyncIterator")) {
15044
- Symbol.asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");
15045
- }
15046
- const SymbolIterator = getSymbol("iterator");
15047
- const SymbolObservable = getSymbol("observable");
15048
- const SymbolSpecies = getSymbol("species");
15049
- function getMethod(obj, key) {
15050
- const value = obj[key];
15051
- if (value == null) {
15052
- return void 0;
15137
+ static fromEditorIndentString(uri, workspace, window2) {
15138
+ const insertSpaces = getEditorInsertSpaces(uri, workspace, window2);
15139
+ const tabSize = getEditorTabSize(uri, workspace, window2);
15140
+ const indentString = insertSpaces ? " ".repeat(tabSize) : " ";
15141
+ return internal_createPromptString(indentString, []);
15053
15142
  }
15054
- if (typeof value !== "function") {
15055
- throw new TypeError(value + " is not a function");
15143
+ static fromDisplayPath(uri) {
15144
+ return internal_createPromptString(displayPath(uri), [uri]);
15056
15145
  }
15057
- return value;
15058
- }
15059
- function getSpecies(obj) {
15060
- let ctor = obj.constructor;
15061
- if (ctor !== void 0) {
15062
- ctor = ctor[SymbolSpecies];
15063
- if (ctor === null) {
15064
- ctor = void 0;
15065
- }
15146
+ static fromDisplayPathLineRange(uri, range2) {
15147
+ const pathToDisplay = range2 ? displayPathWithLines(uri, range2) : displayPath(uri);
15148
+ return internal_createPromptString(pathToDisplay, [uri]);
15066
15149
  }
15067
- return ctor !== void 0 ? ctor : Observable;
15068
- }
15069
- function isObservable(x3) {
15070
- return x3 instanceof Observable;
15071
- }
15072
- function hostReportError(error2) {
15073
- if (hostReportError.log) {
15074
- hostReportError.log(error2);
15075
- } else {
15076
- setTimeout(() => {
15077
- throw error2;
15078
- }, 0);
15150
+ static fromDocumentText(document2, range2) {
15151
+ return internal_createPromptString(document2.getText(range2), [document2.uri]);
15079
15152
  }
15080
- }
15081
- function enqueue(fn) {
15082
- Promise.resolve().then(() => {
15083
- try {
15084
- fn();
15085
- } catch (e3) {
15086
- hostReportError(e3);
15087
- }
15088
- });
15089
- }
15090
- function cleanupSubscription(subscription) {
15091
- const cleanup = subscription._cleanup;
15092
- if (cleanup === void 0) {
15093
- return;
15153
+ static fromGitDiff(uri, oldContent, newContent) {
15154
+ const diff3 = createGitDiff(displayPath(uri), oldContent, newContent);
15155
+ return internal_createPromptString(diff3, [uri]);
15156
+ }
15157
+ // Replaces the following placeholder with data from the diagnostics:
15158
+ // {type}, {filePath}, {prefix}, {message}, {languageID}, {code}
15159
+ //
15160
+ // TODO: This should probably take a vscode.Diagnostic object instead.
15161
+ static fromTextEditorDiagnostic(diagnostic, uri) {
15162
+ const ref = [uri];
15163
+ return {
15164
+ type: internal_createPromptString(diagnostic.type, ref),
15165
+ text: internal_createPromptString(diagnostic.text, ref),
15166
+ message: internal_createPromptString(diagnostic.message, ref)
15167
+ };
15094
15168
  }
15095
- subscription._cleanup = void 0;
15096
- if (!cleanup) {
15097
- return;
15169
+ static fromMarkdownCodeBlockLanguageIDForFilename(uri) {
15170
+ return internal_createPromptString(markdownCodeBlockLanguageIDForFilename(uri), [uri]);
15098
15171
  }
15099
- try {
15100
- if (typeof cleanup === "function") {
15101
- cleanup();
15102
- } else {
15103
- const unsubscribe = getMethod(cleanup, "unsubscribe");
15104
- if (unsubscribe) {
15105
- unsubscribe.call(cleanup);
15106
- }
15107
- }
15108
- } catch (e3) {
15109
- hostReportError(e3);
15172
+ static fromDiagnostic(uri, diagnostic) {
15173
+ const ref = [uri];
15174
+ return {
15175
+ message: internal_createPromptString(diagnostic.message, ref),
15176
+ source: diagnostic.source ? internal_createPromptString(diagnostic.source, ref) : void 0,
15177
+ relatedInformation: diagnostic.relatedInformation ? diagnostic.relatedInformation.map((info) => ({
15178
+ message: internal_createPromptString(info.message, [uri, info.location.uri])
15179
+ })) : void 0
15180
+ };
15110
15181
  }
15111
- }
15112
- function closeSubscription(subscription) {
15113
- subscription._observer = void 0;
15114
- subscription._queue = void 0;
15115
- subscription._state = "closed";
15116
- }
15117
- function flushSubscription(subscription) {
15118
- const queue = subscription._queue;
15119
- if (!queue) {
15120
- return;
15182
+ static fromDocumentSymbol(uri, documentSymbol, SymbolKind) {
15183
+ const symbolKind = documentSymbol.kind ? SymbolKind[documentSymbol.kind].toLowerCase() : "";
15184
+ const symbolPrompt = documentSymbol.name ? `#${documentSymbol.name} (${symbolKind})` : "";
15185
+ return internal_createPromptString(symbolPrompt, [uri]);
15121
15186
  }
15122
- subscription._queue = void 0;
15123
- subscription._state = "ready";
15124
- for (const item of queue) {
15125
- notifySubscription(subscription, item.type, item.value);
15126
- if (subscription._state === "closed") {
15127
- break;
15128
- }
15187
+ // TODO: Find a better way to handle this. Maybe we should migrate the default commands json to
15188
+ // a TypesScript object?
15189
+ static fromDefaultCommands(commands, name) {
15190
+ const prompt = commands[name].prompt;
15191
+ return internal_createPromptString(prompt, []);
15129
15192
  }
15130
- }
15131
- function notifySubscription(subscription, type, value) {
15132
- subscription._state = "running";
15133
- const observer = subscription._observer;
15134
- try {
15135
- const m4 = observer ? getMethod(observer, type) : void 0;
15136
- switch (type) {
15137
- case "next":
15138
- if (m4)
15139
- m4.call(observer, value);
15140
- break;
15141
- case "error":
15142
- closeSubscription(subscription);
15143
- if (m4)
15144
- m4.call(observer, value);
15145
- else
15146
- throw value;
15147
- break;
15148
- case "complete":
15149
- closeSubscription(subscription);
15150
- if (m4)
15151
- m4.call(observer);
15152
- break;
15153
- }
15154
- } catch (e3) {
15155
- hostReportError(e3);
15193
+ // TODO: Need to check in the runtime if we have something we can append as an URI here
15194
+ static fromTerminalOutputArguments(output) {
15195
+ return {
15196
+ name: internal_createPromptString(output.name, []),
15197
+ selection: output.selection ? internal_createPromptString(output.selection, []) : void 0,
15198
+ creationOptions: output.creationOptions ? internal_createPromptString(JSON.stringify(output.creationOptions), []) : void 0
15199
+ };
15156
15200
  }
15157
- if (subscription._state === "closed") {
15158
- cleanupSubscription(subscription);
15159
- } else if (subscription._state === "running") {
15160
- subscription._state = "ready";
15201
+ static fromAutocompleteDocumentContext(docContext, uri) {
15202
+ const ref = [uri];
15203
+ return {
15204
+ prefix: internal_createPromptString(docContext.prefix, ref),
15205
+ suffix: internal_createPromptString(docContext.suffix, ref),
15206
+ injectedPrefix: docContext.injectedPrefix ? internal_createPromptString(docContext.injectedPrefix, ref) : null
15207
+ };
15161
15208
  }
15162
- }
15163
- function onNotify(subscription, type, value) {
15164
- if (subscription._state === "closed") {
15165
- return;
15209
+ static fromAutocompleteContextSnippet(contextSnippet) {
15210
+ const ref = [contextSnippet.uri];
15211
+ return {
15212
+ content: internal_createPromptString(contextSnippet.content, ref),
15213
+ symbol: "symbol" in contextSnippet ? internal_createPromptString(contextSnippet.symbol, ref) : void 0
15214
+ };
15166
15215
  }
15167
- if (subscription._state === "buffering") {
15168
- subscription._queue = subscription._queue || [];
15169
- subscription._queue.push({ type, value });
15170
- return;
15216
+ static fromAutocompleteGitContext(gitContext, uri) {
15217
+ const ref = [uri];
15218
+ return {
15219
+ repoName: internal_createPromptString(gitContext.repoName, ref)
15220
+ };
15171
15221
  }
15172
- if (subscription._state !== "ready") {
15173
- subscription._state = "buffering";
15174
- subscription._queue = [{ type, value }];
15175
- enqueue(() => flushSubscription(subscription));
15176
- return;
15222
+ static fromContextItem(contextItem) {
15223
+ const ref = [contextItem.uri];
15224
+ return {
15225
+ content: typeof contextItem.content === "string" ? internal_createPromptString(contextItem.content, ref) : void 0,
15226
+ repoName: contextItem.repoName ? internal_createPromptString(contextItem.repoName, ref) : void 0,
15227
+ title: contextItem.title ? internal_createPromptString(contextItem.title, ref) : void 0
15228
+ };
15177
15229
  }
15178
- notifySubscription(subscription, type, value);
15179
- }
15180
- class Subscription {
15181
- constructor(observer, subscriber) {
15182
- this._cleanup = void 0;
15183
- this._observer = observer;
15184
- this._queue = void 0;
15185
- this._state = "initializing";
15186
- const subscriptionObserver = new SubscriptionObserver(this);
15187
- try {
15188
- this._cleanup = subscriber.call(void 0, subscriptionObserver);
15189
- } catch (e3) {
15190
- subscriptionObserver.error(e3);
15191
- }
15192
- if (this._state === "initializing") {
15193
- this._state = "ready";
15194
- }
15230
+ // 🚨 Use this function only for user-generated queries.
15231
+ // TODO: Can we detect if the user is pasting in content from a document?
15232
+ static unsafe_fromUserQuery(string2) {
15233
+ return internal_createPromptString(string2, []);
15195
15234
  }
15196
- get closed() {
15197
- return this._state === "closed";
15235
+ // 🚨 Use this function only for LLM responses queries.
15236
+ static unsafe_fromLLMResponse(string2) {
15237
+ return internal_createPromptString(string2, []);
15198
15238
  }
15199
- unsubscribe() {
15200
- if (this._state !== "closed") {
15201
- closeSubscription(this);
15202
- cleanupSubscription(this);
15203
- }
15239
+ // 🚨 We slam chats in and out of storage quite a bit, so it seems weird to
15240
+ // have references on a chat transcript, but closing and opening the chat
15241
+ // panel or restarting the IDE makes those references evaporate.
15242
+ //
15243
+ // On the other hand, you might pull up an old chat transcript and all the
15244
+ // file paths are different now because you moved a folder or something. We're
15245
+ // thinking maybe we should have a concept of "resolved" references where we
15246
+ // keep (repo, repo relative path) pairs for the serialized representation
15247
+ // or something.
15248
+ //
15249
+ // Additionally, the serialized chat message format is also used when sending
15250
+ // chat messages back to the Agent. Right now, however, when we send new
15251
+ // messages, this is done via the `chat/submitMessage` notification which does
15252
+ // not deserialize from chat message. To make sure we do not introduce places
15253
+ // where we deserialize chat messages this way, the function is marked unsafe
15254
+ // for now.
15255
+ static unsafe_deserializeChatMessage(serializedMessage) {
15256
+ return {
15257
+ ...serializedMessage,
15258
+ text: serializedMessage.text ? internal_createPromptString(serializedMessage.text, []) : void 0
15259
+ };
15204
15260
  }
15205
15261
  }
15206
- class SubscriptionObserver {
15207
- constructor(subscription) {
15208
- this._subscription = subscription;
15209
- }
15210
- get closed() {
15211
- return this._subscription._state === "closed";
15262
+ function ps$1(format2, ...args) {
15263
+ if (!(Array.isArray(format2) && Object.isFrozen(format2) && format2.length > 0)) {
15264
+ throw new Error("ps is only intended to be used in tagged template literals.");
15212
15265
  }
15213
- next(value) {
15214
- onNotify(this._subscription, "next", value);
15266
+ const buffer = [];
15267
+ const references = /* @__PURE__ */ new Set();
15268
+ for (let i3 = 0; i3 < format2.length; i3++) {
15269
+ buffer.push(format2[i3]);
15270
+ if (i3 < args.length) {
15271
+ const arg = args[i3];
15272
+ if (typeof arg === "number") {
15273
+ buffer.push(Number.prototype.toString.call(arg));
15274
+ } else if (arg === "") ;
15275
+ else if (arg instanceof PromptString) {
15276
+ buffer.push(internal_toString(arg));
15277
+ for (const ref of internal_toReferences(arg)) {
15278
+ references.add(ref);
15279
+ }
15280
+ } else {
15281
+ throw new Error(
15282
+ "Use ps`...` or a PromptString helper to handle string data for prompts safely."
15283
+ );
15284
+ }
15285
+ }
15215
15286
  }
15216
- error(value) {
15217
- onNotify(this._subscription, "error", value);
15287
+ return internal_createPromptString(buffer.join(""), [...references]);
15288
+ }
15289
+ function psDedent(format2, ...args) {
15290
+ const promptString = ps$1(format2, ...args);
15291
+ const dedented = dedent(internal_toString(promptString));
15292
+ return internal_createPromptString(dedented, internal_toReferences(promptString));
15293
+ }
15294
+ const pocket = /* @__PURE__ */ new WeakMap();
15295
+ class PromptStringPocket {
15296
+ constructor(value, references) {
15297
+ this.value = value;
15298
+ this.references = references;
15218
15299
  }
15219
- complete() {
15220
- onNotify(this._subscription, "complete");
15300
+ }
15301
+ function internal_createPromptString(string2, references) {
15302
+ const handle = new PromptString(string2);
15303
+ pocket.set(handle, new PromptStringPocket(string2, new Set(references)));
15304
+ return handle;
15305
+ }
15306
+ function internal_toString(s4) {
15307
+ return pocket.get(s4).value;
15308
+ }
15309
+ function internal_toReferences(s4) {
15310
+ return [...pocket.get(s4).references.values()];
15311
+ }
15312
+ function isValidPromptString(promptString) {
15313
+ return pocket.has(promptString);
15314
+ }
15315
+ function toRangeData(range2) {
15316
+ const data = Array.isArray(range2) ? { start: range2[0], end: range2[1] } : range2;
15317
+ return data ? {
15318
+ start: { line: data.start.line, character: data.start.character },
15319
+ end: { line: data.end.line, character: data.end.character }
15320
+ } : void 0;
15321
+ }
15322
+ function displayLineRange(range2) {
15323
+ const lineRange = expandToLineRange(range2);
15324
+ const startLine = lineRange.start.line + 1;
15325
+ const endLine = lineRange.end.line;
15326
+ if (endLine === startLine) {
15327
+ return ps$1`${startLine}`;
15221
15328
  }
15329
+ return ps$1`${startLine}-${endLine}`;
15222
15330
  }
15223
- class Observable {
15224
- constructor(subscriber) {
15225
- if (!(this instanceof Observable)) {
15226
- throw new TypeError("Observable cannot be called as a function");
15227
- }
15228
- if (typeof subscriber !== "function") {
15229
- throw new TypeError("Observable initializer must be a function");
15230
- }
15231
- this._subscriber = subscriber;
15232
- }
15233
- subscribe(nextOrObserver, onError, onComplete) {
15234
- if (typeof nextOrObserver !== "object" || nextOrObserver === null) {
15235
- nextOrObserver = {
15236
- next: nextOrObserver,
15237
- error: onError,
15238
- complete: onComplete
15239
- };
15240
- }
15241
- return new Subscription(nextOrObserver, this._subscriber);
15242
- }
15243
- pipe(first, ...mappers) {
15244
- let intermediate = this;
15245
- for (const mapper of [first, ...mappers]) {
15246
- intermediate = mapper(intermediate);
15247
- }
15248
- return intermediate;
15249
- }
15250
- tap(nextOrObserver, onError, onComplete) {
15251
- const tapObserver = typeof nextOrObserver !== "object" || nextOrObserver === null ? {
15252
- next: nextOrObserver,
15253
- error: onError,
15254
- complete: onComplete
15255
- } : nextOrObserver;
15256
- return new Observable((observer) => {
15257
- return this.subscribe({
15258
- next(value) {
15259
- tapObserver.next && tapObserver.next(value);
15260
- observer.next(value);
15261
- },
15262
- error(error2) {
15263
- tapObserver.error && tapObserver.error(error2);
15264
- observer.error(error2);
15265
- },
15266
- complete() {
15267
- tapObserver.complete && tapObserver.complete();
15268
- observer.complete();
15269
- },
15270
- start(subscription) {
15271
- tapObserver.start && tapObserver.start(subscription);
15272
- }
15273
- });
15274
- });
15331
+ function expandToLineRange(range2) {
15332
+ const hasEndLineCharacters = range2.end.line === range2.start.line || range2.end.character !== 0;
15333
+ const endLine = range2.end.line + (hasEndLineCharacters ? 1 : 0);
15334
+ return {
15335
+ start: { line: range2.start.line, character: 0 },
15336
+ end: { line: endLine, character: 0 }
15337
+ };
15338
+ }
15339
+ function displayPath(location) {
15340
+ const result = _displayPath(location, checkEnvInfo());
15341
+ return typeof result === "string" ? result : result.toString();
15342
+ }
15343
+ function displayPathWithLines(location, range2) {
15344
+ return `${displayPath(location)}:${displayLineRange(range2)}`;
15345
+ }
15346
+ function displayPathDirname(location) {
15347
+ const envInfo2 = checkEnvInfo();
15348
+ const result = _displayPath(location, envInfo2);
15349
+ if (typeof result === "string") {
15350
+ return envInfo2.isWindows ? windowsFilePaths.dirname(result) : posixFilePaths.dirname(result);
15275
15351
  }
15276
- forEach(fn) {
15277
- return new Promise((resolve, reject) => {
15278
- if (typeof fn !== "function") {
15279
- reject(new TypeError(fn + " is not a function"));
15280
- return;
15281
- }
15282
- function done() {
15283
- subscription.unsubscribe();
15284
- resolve(void 0);
15285
- }
15286
- const subscription = this.subscribe({
15287
- next(value) {
15288
- try {
15289
- fn(value, done);
15290
- } catch (e3) {
15291
- reject(e3);
15292
- subscription.unsubscribe();
15293
- }
15294
- },
15295
- error(error2) {
15296
- reject(error2);
15297
- },
15298
- complete() {
15299
- resolve(void 0);
15300
- }
15301
- });
15302
- });
15352
+ const dirname = pathFunctionsForURI(location, envInfo2.isWindows).dirname;
15353
+ return result.with({ path: dirname(result.path) }).toString();
15354
+ }
15355
+ function displayPathBasename(location) {
15356
+ const envInfo2 = checkEnvInfo();
15357
+ const result = _displayPath(location, envInfo2);
15358
+ if (typeof result === "string") {
15359
+ return envInfo2.isWindows ? windowsFilePaths.basename(result) : posixFilePaths.basename(result);
15303
15360
  }
15304
- map(fn) {
15305
- if (typeof fn !== "function") {
15306
- throw new TypeError(fn + " is not a function");
15307
- }
15308
- const C2 = getSpecies(this);
15309
- return new C2((observer) => this.subscribe({
15310
- next(value) {
15311
- let propagatedValue = value;
15312
- try {
15313
- propagatedValue = fn(value);
15314
- } catch (e3) {
15315
- return observer.error(e3);
15316
- }
15317
- observer.next(propagatedValue);
15318
- },
15319
- error(e3) {
15320
- observer.error(e3);
15321
- },
15322
- complete() {
15323
- observer.complete();
15324
- }
15325
- }));
15361
+ return posixFilePaths.basename(result.path);
15362
+ }
15363
+ function checkEnvInfo() {
15364
+ if (!envInfo) {
15365
+ throw new Error(
15366
+ "no environment info for displayPath function (call setDisplayPathEnvInfo; see displayPath docstring for more info)"
15367
+ );
15326
15368
  }
15327
- filter(fn) {
15328
- if (typeof fn !== "function") {
15329
- throw new TypeError(fn + " is not a function");
15369
+ return envInfo;
15370
+ }
15371
+ function _displayPath(location, { workspaceFolders, isWindows: isWindows2 }, includeWorkspaceFolderWhenMultiple = true) {
15372
+ const uri = typeof location === "string" ? URI.parse(location) : URI.from(location);
15373
+ const includeWorkspaceFolder = includeWorkspaceFolderWhenMultiple && workspaceFolders.length >= 2;
15374
+ for (const folder of workspaceFolders) {
15375
+ if (uriHasPrefix(uri, folder, isWindows2)) {
15376
+ const pathFunctions2 = pathFunctionsForURI(folder);
15377
+ const workspacePrefix = folder.path.endsWith("/") ? folder.path.slice(0, -1) : folder.path;
15378
+ const workspaceDisplayPrefix = includeWorkspaceFolder ? pathFunctions2.basename(folder.path) + pathFunctions2.separator : "";
15379
+ return fixPathSep(
15380
+ workspaceDisplayPrefix + uri.path.slice(workspacePrefix.length + 1),
15381
+ isWindows2,
15382
+ uri.scheme
15383
+ );
15330
15384
  }
15331
- const C2 = getSpecies(this);
15332
- return new C2((observer) => this.subscribe({
15333
- next(value) {
15334
- try {
15335
- if (!fn(value))
15336
- return;
15337
- } catch (e3) {
15338
- return observer.error(e3);
15339
- }
15340
- observer.next(value);
15341
- },
15342
- error(e3) {
15343
- observer.error(e3);
15344
- },
15345
- complete() {
15346
- observer.complete();
15347
- }
15348
- }));
15349
15385
  }
15350
- reduce(fn, seed) {
15351
- if (typeof fn !== "function") {
15352
- throw new TypeError(fn + " is not a function");
15353
- }
15354
- const C2 = getSpecies(this);
15355
- const hasSeed = arguments.length > 1;
15356
- let hasValue = false;
15357
- let acc = seed;
15358
- return new C2((observer) => this.subscribe({
15359
- next(value) {
15360
- const first = !hasValue;
15361
- hasValue = true;
15362
- if (!first || hasSeed) {
15363
- try {
15364
- acc = fn(acc, value);
15365
- } catch (e3) {
15366
- return observer.error(e3);
15367
- }
15368
- } else {
15369
- acc = value;
15370
- }
15371
- },
15372
- error(e3) {
15373
- observer.error(e3);
15374
- },
15375
- complete() {
15376
- if (!hasValue && !hasSeed) {
15377
- return observer.error(new TypeError("Cannot reduce an empty sequence"));
15378
- }
15379
- observer.next(acc);
15380
- observer.complete();
15381
- }
15382
- }));
15386
+ if (uri.scheme === "file") {
15387
+ return fixPathSep(uri.fsPath, isWindows2, uri.scheme);
15383
15388
  }
15384
- concat(...sources) {
15385
- const C2 = getSpecies(this);
15386
- return new C2((observer) => {
15387
- let subscription;
15388
- let index = 0;
15389
- function startNext(next) {
15390
- subscription = next.subscribe({
15391
- next(v2) {
15392
- observer.next(v2);
15393
- },
15394
- error(e3) {
15395
- observer.error(e3);
15396
- },
15397
- complete() {
15398
- if (index === sources.length) {
15399
- subscription = void 0;
15400
- observer.complete();
15401
- } else {
15402
- startNext(C2.from(sources[index++]));
15403
- }
15404
- }
15405
- });
15389
+ return uri;
15390
+ }
15391
+ function fixPathSep(fsPath, isWindows2, scheme) {
15392
+ return isWindows2 && scheme === "file" ? fsPath.replaceAll("/", "\\") : fsPath;
15393
+ }
15394
+ function uriHasPrefix(uri, prefix, isWindows2) {
15395
+ const uriPath = isWindows2 && uri.scheme === "file" ? uri.path.slice(0, 2).toUpperCase() + uri.path.slice(2) : uri.path;
15396
+ const prefixPath = isWindows2 && prefix.scheme === "file" ? prefix.path.slice(0, 2).toUpperCase() + prefix.path.slice(2) : prefix.path;
15397
+ return uri.scheme === prefix.scheme && (uri.authority ?? "") === (prefix.authority ?? "") && // different URI impls treat empty different
15398
+ (uriPath === prefixPath || uriPath.startsWith(prefixPath.endsWith("/") ? prefixPath : `${prefixPath}/`) || prefixPath.endsWith("/") && uriPath === prefixPath.slice(0, -1));
15399
+ }
15400
+ let envInfo = null;
15401
+ function setDisplayPathEnvInfo(newEnvInfo) {
15402
+ const prev = envInfo;
15403
+ envInfo = newEnvInfo;
15404
+ return prev;
15405
+ }
15406
+ const CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID = "_cody.vscode.open";
15407
+ function commandURIForVSCodeOpen(resource, range2) {
15408
+ return `command:${CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID}?${encodeURIComponent(
15409
+ JSON.stringify([
15410
+ resource,
15411
+ {
15412
+ selection: range2,
15413
+ preserveFocus: true,
15414
+ background: false,
15415
+ preview: true,
15416
+ viewColumn: -2
15406
15417
  }
15407
- startNext(this);
15408
- return () => {
15409
- if (subscription) {
15410
- subscription.unsubscribe();
15411
- subscription = void 0;
15412
- }
15413
- };
15414
- });
15418
+ ])
15419
+ )}`;
15420
+ }
15421
+ function webviewOpenURIForContextItem(item) {
15422
+ if (item.uri.scheme === "http" || item.uri.scheme === "https") {
15423
+ return {
15424
+ href: item.uri.toString(),
15425
+ target: "_blank"
15426
+ };
15415
15427
  }
15416
- flatMap(fn) {
15417
- if (typeof fn !== "function") {
15418
- throw new TypeError(fn + " is not a function");
15419
- }
15420
- const C2 = getSpecies(this);
15421
- return new C2((observer) => {
15422
- const subscriptions = [];
15423
- const outer = this.subscribe({
15424
- next(value) {
15425
- let normalizedValue;
15426
- if (fn) {
15427
- try {
15428
- normalizedValue = fn(value);
15429
- } catch (e3) {
15430
- return observer.error(e3);
15431
- }
15432
- } else {
15433
- normalizedValue = value;
15434
- }
15435
- const inner = C2.from(normalizedValue).subscribe({
15436
- next(innerValue) {
15437
- observer.next(innerValue);
15438
- },
15439
- error(e3) {
15440
- observer.error(e3);
15441
- },
15442
- complete() {
15443
- const i3 = subscriptions.indexOf(inner);
15444
- if (i3 >= 0)
15445
- subscriptions.splice(i3, 1);
15446
- completeIfDone();
15447
- }
15448
- });
15449
- subscriptions.push(inner);
15450
- },
15451
- error(e3) {
15452
- observer.error(e3);
15453
- },
15454
- complete() {
15455
- completeIfDone();
15456
- }
15457
- });
15458
- function completeIfDone() {
15459
- if (outer.closed && subscriptions.length === 0) {
15460
- observer.complete();
15461
- }
15462
- }
15463
- return () => {
15464
- subscriptions.forEach((s4) => s4.unsubscribe());
15465
- outer.unsubscribe();
15466
- };
15467
- });
15428
+ return { href: commandURIForVSCodeOpen(item.uri, item.range), target: void 0 };
15429
+ }
15430
+ const STOP_SEQUENCE_REGEXP = /(H|Hu|Hum|Huma|Human|Human:)$/;
15431
+ function reformatBotMessageForChat(text) {
15432
+ let reformattedMessage = text.trimEnd();
15433
+ const stopSequenceMatch = reformattedMessage.toString().match(STOP_SEQUENCE_REGEXP);
15434
+ if (stopSequenceMatch) {
15435
+ reformattedMessage = reformattedMessage.slice(0, stopSequenceMatch.index);
15468
15436
  }
15469
- [SymbolObservable]() {
15470
- return this;
15437
+ return fixOpenMarkdownCodeBlock(reformattedMessage);
15438
+ }
15439
+ function fixOpenMarkdownCodeBlock(text) {
15440
+ const occurrences = text.split("```").length - 1;
15441
+ if (occurrences % 2 === 1) {
15442
+ return text.concat(ps$1`\n\`\`\``);
15471
15443
  }
15472
- static from(x3) {
15473
- const C2 = typeof this === "function" ? this : Observable;
15474
- if (x3 == null) {
15475
- throw new TypeError(x3 + " is not an object");
15444
+ return text;
15445
+ }
15446
+ var ContextItemSource = /* @__PURE__ */ ((ContextItemSource2) => {
15447
+ ContextItemSource2["Embeddings"] = "embeddings";
15448
+ ContextItemSource2["User"] = "user";
15449
+ ContextItemSource2["Editor"] = "editor";
15450
+ ContextItemSource2["Search"] = "search";
15451
+ ContextItemSource2["Initial"] = "initial";
15452
+ ContextItemSource2["Unified"] = "unified";
15453
+ ContextItemSource2["Selection"] = "selection";
15454
+ ContextItemSource2["Terminal"] = "terminal";
15455
+ ContextItemSource2["History"] = "history";
15456
+ return ContextItemSource2;
15457
+ })(ContextItemSource || {});
15458
+ const GENERAL_HELP_LABEL = "Search for a file to include, or type # for symbols...";
15459
+ const NO_SYMBOL_MATCHES_HELP_LABEL = " (language extensions may be loading)";
15460
+ const FILE_RANGE_TOOLTIP_LABEL = "Type a line range to include, e.g. 5-10...";
15461
+ const LARGE_FILE_WARNING_LABEL = "File too large. Add line range with : or use @# to choose a symbol";
15462
+ const IGNORED_FILE_WARNING_LABEL = "File ignored by an admin setting.";
15463
+ function hydrateAfterPostMessage(value, hydrateUri) {
15464
+ if (isDehydratedUri(value)) {
15465
+ return hydrateUri(value);
15466
+ }
15467
+ if (Array.isArray(value)) {
15468
+ return value.map((e3) => hydrateAfterPostMessage(e3, hydrateUri));
15469
+ }
15470
+ if (value instanceof Object) {
15471
+ for (const key of Object.keys(value)) {
15472
+ value[key] = hydrateAfterPostMessage(value[key], hydrateUri);
15476
15473
  }
15477
- const observableMethod = getMethod(x3, SymbolObservable);
15478
- if (observableMethod) {
15479
- const observable = observableMethod.call(x3);
15480
- if (Object(observable) !== observable) {
15481
- throw new TypeError(observable + " is not an object");
15482
- }
15483
- if (isObservable(observable) && observable.constructor === C2) {
15484
- return observable;
15474
+ return value;
15475
+ }
15476
+ return value;
15477
+ }
15478
+ function isDehydratedUri(value) {
15479
+ return Boolean(value) && // vscode.Uri
15480
+ (value.$mid !== void 0 && value.path !== void 0 && value.scheme !== void 0 || // vscode-uri.URI
15481
+ value.authority !== void 0 && value.path !== void 0 && value.fragment !== void 0 && value.query !== void 0);
15482
+ }
15483
+ var _scheduler = {};
15484
+ var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P2, generator) {
15485
+ function adopt(value) {
15486
+ return value instanceof P2 ? value : new P2(function(resolve) {
15487
+ resolve(value);
15488
+ });
15489
+ }
15490
+ return new (P2 || (P2 = Promise))(function(resolve, reject) {
15491
+ function fulfilled(value) {
15492
+ try {
15493
+ step(generator.next(value));
15494
+ } catch (e3) {
15495
+ reject(e3);
15485
15496
  }
15486
- return new C2((observer) => observable.subscribe(observer));
15487
15497
  }
15488
- if (hasSymbol("iterator")) {
15489
- const iteratorMethod = getMethod(x3, SymbolIterator);
15490
- if (iteratorMethod) {
15491
- return new C2((observer) => {
15492
- enqueue(() => {
15493
- if (observer.closed)
15494
- return;
15495
- for (const item of iteratorMethod.call(x3)) {
15496
- observer.next(item);
15497
- if (observer.closed)
15498
- return;
15499
- }
15500
- observer.complete();
15501
- });
15502
- });
15498
+ function rejected(value) {
15499
+ try {
15500
+ step(generator["throw"](value));
15501
+ } catch (e3) {
15502
+ reject(e3);
15503
15503
  }
15504
15504
  }
15505
- if (Array.isArray(x3)) {
15506
- return new C2((observer) => {
15507
- enqueue(() => {
15508
- if (observer.closed)
15509
- return;
15510
- for (const item of x3) {
15511
- observer.next(item);
15512
- if (observer.closed)
15513
- return;
15514
- }
15515
- observer.complete();
15516
- });
15517
- });
15505
+ function step(result) {
15506
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
15518
15507
  }
15519
- throw new TypeError(x3 + " is not observable");
15508
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15509
+ });
15510
+ };
15511
+ Object.defineProperty(_scheduler, "__esModule", { value: true });
15512
+ var AsyncSerialScheduler_1 = _scheduler.AsyncSerialScheduler = void 0;
15513
+ class AsyncSerialScheduler {
15514
+ constructor(observer) {
15515
+ this._baseObserver = observer;
15516
+ this._pendingPromises = /* @__PURE__ */ new Set();
15520
15517
  }
15521
- static of(...items) {
15522
- const C2 = typeof this === "function" ? this : Observable;
15523
- return new C2((observer) => {
15524
- enqueue(() => {
15525
- if (observer.closed)
15526
- return;
15527
- for (const item of items) {
15528
- observer.next(item);
15529
- if (observer.closed)
15530
- return;
15531
- }
15532
- observer.complete();
15533
- });
15518
+ complete() {
15519
+ Promise.all(this._pendingPromises).then(() => this._baseObserver.complete()).catch((error2) => this._baseObserver.error(error2));
15520
+ }
15521
+ error(error2) {
15522
+ this._baseObserver.error(error2);
15523
+ }
15524
+ schedule(task) {
15525
+ const prevPromisesCompletion = Promise.all(this._pendingPromises);
15526
+ const values = [];
15527
+ const next = (value) => values.push(value);
15528
+ const promise = Promise.resolve().then(() => __awaiter(this, void 0, void 0, function* () {
15529
+ yield prevPromisesCompletion;
15530
+ yield task(next);
15531
+ this._pendingPromises.delete(promise);
15532
+ for (const value of values) {
15533
+ this._baseObserver.next(value);
15534
+ }
15535
+ })).catch((error2) => {
15536
+ this._pendingPromises.delete(promise);
15537
+ this._baseObserver.error(error2);
15534
15538
  });
15535
- }
15536
- static get [SymbolSpecies]() {
15537
- return this;
15539
+ this._pendingPromises.add(promise);
15538
15540
  }
15539
15541
  }
15540
- if (hasSymbols()) {
15541
- Object.defineProperty(Observable, Symbol("extensions"), {
15542
- value: {
15543
- symbol: SymbolObservable,
15544
- hostReportError
15545
- },
15546
- configurable: true
15547
- });
15548
- }
15542
+ AsyncSerialScheduler_1 = _scheduler.AsyncSerialScheduler = AsyncSerialScheduler;
15549
15543
  function subscriptionDisposable(sub) {
15550
15544
  return { dispose: sub.unsubscribe.bind(sub) };
15551
15545
  }
15546
+ async function waitUntilComplete(observable) {
15547
+ return new Promise((resolve, reject) => {
15548
+ observable.subscribe({
15549
+ error: reject,
15550
+ complete: () => resolve()
15551
+ });
15552
+ });
15553
+ }
15554
+ function promiseToObservable(promise) {
15555
+ return new Observable((observer) => {
15556
+ promise.then((value) => {
15557
+ observer.next(value);
15558
+ observer.complete();
15559
+ }).catch((error2) => {
15560
+ observer.error(error2);
15561
+ });
15562
+ });
15563
+ }
15552
15564
  function promiseFactoryToObservable(factory) {
15553
15565
  return new Observable((observer) => {
15554
15566
  let unsubscribed = false;
@@ -15645,16 +15657,21 @@ function memoizeLastValue(factory, keyFn) {
15645
15657
  function fromRxJSObservable(rxjsObservable) {
15646
15658
  return Observable.from(rxjsObservable);
15647
15659
  }
15660
+ const NO_INITIAL_VALUE = Symbol("noInitialValue");
15648
15661
  function fromVSCodeEvent(event, getInitialValue) {
15649
15662
  return new Observable((observer) => {
15650
15663
  if (getInitialValue) {
15651
15664
  const initialValue = getInitialValue();
15652
15665
  if (initialValue instanceof Promise) {
15653
15666
  initialValue.then((value) => {
15654
- observer.next(value);
15667
+ if (value !== NO_INITIAL_VALUE) {
15668
+ observer.next(value);
15669
+ }
15655
15670
  });
15656
15671
  } else {
15657
- observer.next(initialValue);
15672
+ if (initialValue !== NO_INITIAL_VALUE) {
15673
+ observer.next(initialValue);
15674
+ }
15658
15675
  }
15659
15676
  }
15660
15677
  let disposed = false;
@@ -15670,99 +15687,162 @@ function fromVSCodeEvent(event, getInitialValue) {
15670
15687
  };
15671
15688
  });
15672
15689
  }
15673
- var base64Js = {};
15674
- base64Js.byteLength = byteLength;
15675
- base64Js.toByteArray = toByteArray;
15676
- base64Js.fromByteArray = fromByteArray;
15677
- var lookup = [];
15678
- var revLookup = [];
15679
- var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
15680
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15681
- for (var i$1 = 0, len = code.length; i$1 < len; ++i$1) {
15682
- lookup[i$1] = code[i$1];
15683
- revLookup[code.charCodeAt(i$1)] = i$1;
15684
- }
15685
- revLookup["-".charCodeAt(0)] = 62;
15686
- revLookup["_".charCodeAt(0)] = 63;
15687
- function getLens(b64) {
15688
- var len = b64.length;
15689
- if (len % 4 > 0) {
15690
- throw new Error("Invalid string. Length must be a multiple of 4");
15691
- }
15692
- var validLen = b64.indexOf("=");
15693
- if (validLen === -1) validLen = len;
15694
- var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
15695
- return [validLen, placeHoldersLen];
15696
- }
15697
- function byteLength(b64) {
15698
- var lens = getLens(b64);
15699
- var validLen = lens[0];
15700
- var placeHoldersLen = lens[1];
15701
- return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
15702
- }
15703
- function _byteLength(b64, validLen, placeHoldersLen) {
15704
- return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
15705
- }
15706
- function toByteArray(b64) {
15707
- var tmp;
15708
- var lens = getLens(b64);
15709
- var validLen = lens[0];
15710
- var placeHoldersLen = lens[1];
15711
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
15712
- var curByte = 0;
15713
- var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
15714
- var i3;
15715
- for (i3 = 0; i3 < len; i3 += 4) {
15716
- tmp = revLookup[b64.charCodeAt(i3)] << 18 | revLookup[b64.charCodeAt(i3 + 1)] << 12 | revLookup[b64.charCodeAt(i3 + 2)] << 6 | revLookup[b64.charCodeAt(i3 + 3)];
15717
- arr[curByte++] = tmp >> 16 & 255;
15718
- arr[curByte++] = tmp >> 8 & 255;
15719
- arr[curByte++] = tmp & 255;
15720
- }
15721
- if (placeHoldersLen === 2) {
15722
- tmp = revLookup[b64.charCodeAt(i3)] << 2 | revLookup[b64.charCodeAt(i3 + 1)] >> 4;
15723
- arr[curByte++] = tmp & 255;
15724
- }
15725
- if (placeHoldersLen === 1) {
15726
- tmp = revLookup[b64.charCodeAt(i3)] << 10 | revLookup[b64.charCodeAt(i3 + 1)] << 4 | revLookup[b64.charCodeAt(i3 + 2)] >> 2;
15727
- arr[curByte++] = tmp >> 8 & 255;
15728
- arr[curByte++] = tmp & 255;
15729
- }
15730
- return arr;
15690
+ function distinctUntilChanged(isEqualFn = isEqualJSON) {
15691
+ return (observable) => {
15692
+ return new Observable((observer) => {
15693
+ let lastInput = NO_VALUES_YET;
15694
+ const scheduler = new AsyncSerialScheduler_1(observer);
15695
+ const subscription = observable.subscribe({
15696
+ complete() {
15697
+ scheduler.complete();
15698
+ },
15699
+ error(error2) {
15700
+ scheduler.error(error2);
15701
+ },
15702
+ next(input) {
15703
+ scheduler.schedule(async (next) => {
15704
+ if (lastInput === NO_VALUES_YET || !isEqualFn(lastInput, input)) {
15705
+ lastInput = input;
15706
+ next(input);
15707
+ }
15708
+ });
15709
+ }
15710
+ });
15711
+ return () => unsubscribe(subscription);
15712
+ });
15713
+ };
15731
15714
  }
15732
- function tripletToBase64(num) {
15733
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
15734
- }
15735
- function encodeChunk(uint8, start, end) {
15736
- var tmp;
15737
- var output = [];
15738
- for (var i3 = start; i3 < end; i3 += 3) {
15739
- tmp = (uint8[i3] << 16 & 16711680) + (uint8[i3 + 1] << 8 & 65280) + (uint8[i3 + 2] & 255);
15740
- output.push(tripletToBase64(tmp));
15741
- }
15742
- return output.join("");
15743
- }
15744
- function fromByteArray(uint8) {
15745
- var tmp;
15746
- var len = uint8.length;
15747
- var extraBytes = len % 3;
15748
- var parts = [];
15749
- var maxChunkLength = 16383;
15750
- for (var i3 = 0, len2 = len - extraBytes; i3 < len2; i3 += maxChunkLength) {
15751
- parts.push(encodeChunk(uint8, i3, i3 + maxChunkLength > len2 ? len2 : i3 + maxChunkLength));
15752
- }
15753
- if (extraBytes === 1) {
15754
- tmp = uint8[len - 1];
15755
- parts.push(
15756
- lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
15757
- );
15758
- } else if (extraBytes === 2) {
15759
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
15760
- parts.push(
15761
- lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
15762
- );
15715
+ const NO_VALUES_YET = {};
15716
+ function isEqualJSON(a4, b3) {
15717
+ return JSON.stringify(a4) === JSON.stringify(b3);
15718
+ }
15719
+ function startWith(value) {
15720
+ return (source) => new Observable((observer) => {
15721
+ let sourceSubscription;
15722
+ try {
15723
+ observer.next(value);
15724
+ sourceSubscription = source.subscribe({
15725
+ next(val) {
15726
+ observer.next(val);
15727
+ },
15728
+ error(err) {
15729
+ observer.error(err);
15730
+ },
15731
+ complete() {
15732
+ observer.complete();
15733
+ }
15734
+ });
15735
+ } catch (err) {
15736
+ observer.error(err);
15737
+ }
15738
+ return () => {
15739
+ if (sourceSubscription) {
15740
+ unsubscribe(sourceSubscription);
15741
+ }
15742
+ };
15743
+ });
15744
+ }
15745
+ var base64Js = {};
15746
+ var hasRequiredBase64Js;
15747
+ function requireBase64Js() {
15748
+ if (hasRequiredBase64Js) return base64Js;
15749
+ hasRequiredBase64Js = 1;
15750
+ base64Js.byteLength = byteLength;
15751
+ base64Js.toByteArray = toByteArray;
15752
+ base64Js.fromByteArray = fromByteArray;
15753
+ var lookup = [];
15754
+ var revLookup = [];
15755
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
15756
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
15757
+ for (var i3 = 0, len = code.length; i3 < len; ++i3) {
15758
+ lookup[i3] = code[i3];
15759
+ revLookup[code.charCodeAt(i3)] = i3;
15760
+ }
15761
+ revLookup["-".charCodeAt(0)] = 62;
15762
+ revLookup["_".charCodeAt(0)] = 63;
15763
+ function getLens(b64) {
15764
+ var len2 = b64.length;
15765
+ if (len2 % 4 > 0) {
15766
+ throw new Error("Invalid string. Length must be a multiple of 4");
15767
+ }
15768
+ var validLen = b64.indexOf("=");
15769
+ if (validLen === -1) validLen = len2;
15770
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
15771
+ return [validLen, placeHoldersLen];
15772
+ }
15773
+ function byteLength(b64) {
15774
+ var lens = getLens(b64);
15775
+ var validLen = lens[0];
15776
+ var placeHoldersLen = lens[1];
15777
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
15778
+ }
15779
+ function _byteLength(b64, validLen, placeHoldersLen) {
15780
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
15781
+ }
15782
+ function toByteArray(b64) {
15783
+ var tmp;
15784
+ var lens = getLens(b64);
15785
+ var validLen = lens[0];
15786
+ var placeHoldersLen = lens[1];
15787
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
15788
+ var curByte = 0;
15789
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
15790
+ var i4;
15791
+ for (i4 = 0; i4 < len2; i4 += 4) {
15792
+ tmp = revLookup[b64.charCodeAt(i4)] << 18 | revLookup[b64.charCodeAt(i4 + 1)] << 12 | revLookup[b64.charCodeAt(i4 + 2)] << 6 | revLookup[b64.charCodeAt(i4 + 3)];
15793
+ arr[curByte++] = tmp >> 16 & 255;
15794
+ arr[curByte++] = tmp >> 8 & 255;
15795
+ arr[curByte++] = tmp & 255;
15796
+ }
15797
+ if (placeHoldersLen === 2) {
15798
+ tmp = revLookup[b64.charCodeAt(i4)] << 2 | revLookup[b64.charCodeAt(i4 + 1)] >> 4;
15799
+ arr[curByte++] = tmp & 255;
15800
+ }
15801
+ if (placeHoldersLen === 1) {
15802
+ tmp = revLookup[b64.charCodeAt(i4)] << 10 | revLookup[b64.charCodeAt(i4 + 1)] << 4 | revLookup[b64.charCodeAt(i4 + 2)] >> 2;
15803
+ arr[curByte++] = tmp >> 8 & 255;
15804
+ arr[curByte++] = tmp & 255;
15805
+ }
15806
+ return arr;
15807
+ }
15808
+ function tripletToBase64(num) {
15809
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
15810
+ }
15811
+ function encodeChunk(uint8, start, end) {
15812
+ var tmp;
15813
+ var output = [];
15814
+ for (var i4 = start; i4 < end; i4 += 3) {
15815
+ tmp = (uint8[i4] << 16 & 16711680) + (uint8[i4 + 1] << 8 & 65280) + (uint8[i4 + 2] & 255);
15816
+ output.push(tripletToBase64(tmp));
15817
+ }
15818
+ return output.join("");
15819
+ }
15820
+ function fromByteArray(uint8) {
15821
+ var tmp;
15822
+ var len2 = uint8.length;
15823
+ var extraBytes = len2 % 3;
15824
+ var parts = [];
15825
+ var maxChunkLength = 16383;
15826
+ for (var i4 = 0, len22 = len2 - extraBytes; i4 < len22; i4 += maxChunkLength) {
15827
+ parts.push(encodeChunk(uint8, i4, i4 + maxChunkLength > len22 ? len22 : i4 + maxChunkLength));
15828
+ }
15829
+ if (extraBytes === 1) {
15830
+ tmp = uint8[len2 - 1];
15831
+ parts.push(
15832
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
15833
+ );
15834
+ } else if (extraBytes === 2) {
15835
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
15836
+ parts.push(
15837
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
15838
+ );
15839
+ }
15840
+ return parts.join("");
15763
15841
  }
15764
- return parts.join("");
15842
+ return base64Js;
15765
15843
  }
15844
+ var base64JsExports = requireBase64Js();
15845
+ const base64 = /* @__PURE__ */ getDefaultExportFromCjs(base64JsExports);
15766
15846
  var __defProp2 = Object.defineProperty;
15767
15847
  var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15768
15848
  var __publicField2 = (obj, key, value) => {
@@ -15827,7 +15907,7 @@ var _Tiktoken = class {
15827
15907
  return memo;
15828
15908
  }, {});
15829
15909
  for (const [token, rank] of Object.entries(uncompressed)) {
15830
- const bytes = base64Js.toByteArray(token);
15910
+ const bytes = base64.toByteArray(token);
15831
15911
  this.rankMap.set(bytes.join(","), rank);
15832
15912
  this.textMap.set(rank, bytes);
15833
15913
  }
@@ -15978,9 +16058,9 @@ class TokenCounter {
15978
16058
  * NOTE: Used in remainingTokens for calculating the remaining token budget for each budget type.
15979
16059
  */
15980
16060
  __publicField(this, "shareChatAndUserBudget", true);
15981
- var _a3, _b;
16061
+ var _a2, _b;
15982
16062
  this.utils = utils;
15983
- this.shareChatAndUserBudget = !((_a3 = contextWindow.context) == null ? void 0 : _a3.user);
16063
+ this.shareChatAndUserBudget = !((_a2 = contextWindow.context) == null ? void 0 : _a2.user);
15984
16064
  this.maxChatTokens = contextWindow.input;
15985
16065
  this.maxContextTokens = {
15986
16066
  user: ((_b = contextWindow.context) == null ? void 0 : _b.user) ?? contextWindow.input,
@@ -16087,10 +16167,10 @@ class TokenCounter {
16087
16167
  }
16088
16168
  }
16089
16169
  async function truncatePromptString(text, maxTokens) {
16090
- var _a3;
16170
+ var _a2;
16091
16171
  const tokenCounterUtils = await getTokenCounterUtils();
16092
16172
  const encoded = tokenCounterUtils.encode(text.toString());
16093
- return encoded.length <= maxTokens ? text : text.slice(0, (_a3 = tokenCounterUtils.decode(encoded.slice(0, maxTokens))) == null ? void 0 : _a3.length).trim();
16173
+ return encoded.length <= maxTokens ? text : text.slice(0, (_a2 = tokenCounterUtils.decode(encoded.slice(0, maxTokens))) == null ? void 0 : _a2.length).trim();
16094
16174
  }
16095
16175
  function truncateTextNearestLine(text, maxBytes) {
16096
16176
  if (text.length <= maxBytes) {
@@ -22700,11 +22780,11 @@ function webMentionProvidersMetadata() {
22700
22780
  return openCtxMentionProviders().map((providers) => [SYMBOL_CONTEXT_MENTION_PROVIDER, ...providers]);
22701
22781
  }
22702
22782
  function openCtxProviderMetadata(meta) {
22703
- var _a3;
22783
+ var _a2;
22704
22784
  return {
22705
22785
  id: meta.providerUri,
22706
22786
  title: meta.name,
22707
- queryLabel: ((_a3 = meta.mentions) == null ? void 0 : _a3.label) ?? "Search...",
22787
+ queryLabel: ((_a2 = meta.mentions) == null ? void 0 : _a2.label) ?? "Search...",
22708
22788
  emptyLabel: "No results"
22709
22789
  };
22710
22790
  }
@@ -26720,8 +26800,8 @@ function isSerializedContextItemMentionNode(node) {
26720
26800
  return Boolean(node && node.type === CONTEXT_ITEM_MENTION_NODE_TYPE);
26721
26801
  }
26722
26802
  function contextItemMentionNodeDisplayText(contextItem) {
26723
- var _a3;
26724
- const rangeText = ((_a3 = contextItem.range) == null ? void 0 : _a3.start) ? `:${displayLineRange(contextItem.range)}` : "";
26803
+ var _a2;
26804
+ const rangeText = ((_a2 = contextItem.range) == null ? void 0 : _a2.start) ? `:${displayLineRange(contextItem.range)}` : "";
26725
26805
  switch (contextItem.type) {
26726
26806
  case "file":
26727
26807
  if (contextItem.provider && contextItem.title) {
@@ -27067,7 +27147,6 @@ function createMessageAPIForWebview(vscodeAPI) {
27067
27147
  }
27068
27148
  };
27069
27149
  }
27070
- const isWebview = Boolean(typeof window !== "undefined" && ((_a2 = window.document) == null ? void 0 : _a2.body));
27071
27150
  function callExtensionAPI(messageAPI, method, args) {
27072
27151
  return new Observable((observer) => {
27073
27152
  const streamId = generateStreamId();
@@ -27102,18 +27181,12 @@ function callExtensionAPI(messageAPI, method, args) {
27102
27181
  });
27103
27182
  }
27104
27183
  function proxyExtensionAPI(messageAPI, method) {
27105
- if (!isWebview) {
27106
- throw new Error("tried to call extension API function from extension itself");
27107
- }
27108
27184
  return (...args) => {
27109
27185
  logRPCMessage(`X->W: call method=${method} args=${JSON.stringify(args)}`);
27110
27186
  return callExtensionAPI(messageAPI, method, args);
27111
27187
  };
27112
27188
  }
27113
27189
  function addMessageListenersForExtensionAPI(messageAPI, api2) {
27114
- if (isWebview) {
27115
- throw new Error("must be called from extension");
27116
- }
27117
27190
  const activeListeners = [];
27118
27191
  function messageListener({ data }) {
27119
27192
  if (!("method" in data)) {
@@ -27195,6 +27268,15 @@ function logRPCMessage(msg, ...args) {
27195
27268
  logDebug("[RPC]", msg, ...args);
27196
27269
  }
27197
27270
  }
27271
+ function createExtensionAPI(messageAPI) {
27272
+ return {
27273
+ mentionMenuData: proxyExtensionAPI(messageAPI, "mentionMenuData"),
27274
+ evaluatedFeatureFlag: proxyExtensionAPI(messageAPI, "evaluatedFeatureFlag"),
27275
+ prompts: proxyExtensionAPI(messageAPI, "prompts"),
27276
+ models: proxyExtensionAPI(messageAPI, "models"),
27277
+ setChatModel: proxyExtensionAPI(messageAPI, "setChatModel")
27278
+ };
27279
+ }
27198
27280
  const CODY_DOC_URL = new URL("https://sourcegraph.com/docs/cody");
27199
27281
  const SG_BLOG_URL = new URL("https://sourcegraph.com/blog/");
27200
27282
  const DISCORD_URL = new URL("https://discord.gg/s2qDtYGnAE");
@@ -28171,9 +28253,9 @@ var ErrorCodes;
28171
28253
  ErrorCodes2.serverErrorEnd = -32e3;
28172
28254
  })(ErrorCodes || (messages.ErrorCodes = ErrorCodes = {}));
28173
28255
  class ResponseError extends Error {
28174
- constructor(code2, message, data) {
28256
+ constructor(code, message, data) {
28175
28257
  super(message);
28176
- this.code = is.number(code2) ? code2 : ErrorCodes.UnknownErrorCode;
28258
+ this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
28177
28259
  this.data = data;
28178
28260
  Object.setPrototypeOf(this, ResponseError.prototype);
28179
28261
  }
@@ -28415,12 +28497,12 @@ class LinkedMap {
28415
28497
  return this._size;
28416
28498
  }
28417
28499
  get first() {
28418
- var _a3;
28419
- return (_a3 = this._head) == null ? void 0 : _a3.value;
28500
+ var _a2;
28501
+ return (_a2 = this._head) == null ? void 0 : _a2.value;
28420
28502
  }
28421
28503
  get last() {
28422
- var _a3;
28423
- return (_a3 = this._tail) == null ? void 0 : _a3.value;
28504
+ var _a2;
28505
+ return (_a2 = this._tail) == null ? void 0 : _a2.value;
28424
28506
  }
28425
28507
  has(key) {
28426
28508
  return this._map.has(key);
@@ -29678,9 +29760,9 @@ var connection = {};
29678
29760
  ConnectionErrors2[ConnectionErrors2["AlreadyListening"] = 3] = "AlreadyListening";
29679
29761
  })(ConnectionErrors || (exports.ConnectionErrors = ConnectionErrors = {}));
29680
29762
  class ConnectionError extends Error {
29681
- constructor(code2, message) {
29763
+ constructor(code, message) {
29682
29764
  super(message);
29683
- this.code = code2;
29765
+ this.code = code;
29684
29766
  Object.setPrototypeOf(this, ConnectionError.prototype);
29685
29767
  }
29686
29768
  }
@@ -31150,7 +31232,7 @@ export {
31150
31232
  parseMentionQuery as aQ,
31151
31233
  NO_SYMBOL_MATCHES_HELP_LABEL as aR,
31152
31234
  FILE_RANGE_TOOLTIP_LABEL as aS,
31153
- proxyExtensionAPI as aT,
31235
+ createExtensionAPI as aT,
31154
31236
  createMessageAPIForWebview as aU,
31155
31237
  lodashExports as aV,
31156
31238
  memoizeLastValue as aW,
@@ -31185,7 +31267,7 @@ export {
31185
31267
  LARGE_FILE_WARNING_LABEL as ay,
31186
31268
  Ei as az,
31187
31269
  ds as b,
31188
- verifyResponseCode as b$,
31270
+ fetch as b$,
31189
31271
  ps as b0,
31190
31272
  hydrateAfterPostMessage as b1,
31191
31273
  isCodyProUser as b2,
@@ -31196,33 +31278,33 @@ export {
31196
31278
  cryptoJsExports as b7,
31197
31279
  isError as b8,
31198
31280
  RateLimitError as b9,
31199
- graphqlClient as bA,
31200
- logError as bB,
31201
- logDebug as bC,
31202
- isFileURI as bD,
31203
- INCLUDE_EVERYTHING_CONTEXT_FILTERS as bE,
31204
- EXCLUDE_EVERYTHING_CONTEXT_FILTERS as bF,
31205
- isAbortError as bG,
31206
- onAbort as bH,
31207
- CHAT_OUTPUT_TOKEN_BUDGET as bI,
31208
- isEnterpriseUser as bJ,
31209
- getModelInfo as bK,
31210
- EXTENDED_CHAT_INPUT_TOKEN_BUDGET as bL,
31211
- EXTENDED_USER_CONTEXT_TOKEN_BUDGET as bM,
31212
- pathFunctionsForURI as bN,
31213
- uriBasename as bO,
31214
- uriHasPrefix as bP,
31215
- isWindows as bQ,
31216
- Utils as bR,
31217
- Observable as bS,
31218
- fromVSCodeEvent as bT,
31219
- ClientConfigSingleton as bU,
31220
- isCustomModel as bV,
31221
- recordErrorToSpan as bW,
31222
- dependentAbortController as bX,
31223
- addCustomUserAgent as bY,
31224
- addTraceparent as bZ,
31225
- fetch as b_,
31281
+ createSubscriber as bA,
31282
+ graphqlClient as bB,
31283
+ logError as bC,
31284
+ logDebug as bD,
31285
+ isFileURI as bE,
31286
+ INCLUDE_EVERYTHING_CONTEXT_FILTERS as bF,
31287
+ isDotCom as bG,
31288
+ EXCLUDE_EVERYTHING_CONTEXT_FILTERS as bH,
31289
+ isAbortError as bI,
31290
+ onAbort as bJ,
31291
+ CHAT_OUTPUT_TOKEN_BUDGET as bK,
31292
+ isEnterpriseUser as bL,
31293
+ getModelInfo as bM,
31294
+ EXTENDED_CHAT_INPUT_TOKEN_BUDGET as bN,
31295
+ EXTENDED_USER_CONTEXT_TOKEN_BUDGET as bO,
31296
+ pathFunctionsForURI as bP,
31297
+ uriBasename as bQ,
31298
+ uriHasPrefix as bR,
31299
+ isWindows as bS,
31300
+ Utils as bT,
31301
+ fromVSCodeEvent as bU,
31302
+ ClientConfigSingleton as bV,
31303
+ isCustomModel as bW,
31304
+ recordErrorToSpan as bX,
31305
+ dependentAbortController as bY,
31306
+ addCustomUserAgent as bZ,
31307
+ addTraceparent as b_,
31226
31308
  CODY_FEEDBACK_URL as ba,
31227
31309
  isDefined as bb,
31228
31310
  reformatBotMessageForChat as bc,
@@ -31234,109 +31316,110 @@ export {
31234
31316
  pluralize as bi,
31235
31317
  isCodyProModel as bj,
31236
31318
  ModelTag as bk,
31237
- CustomCommandType as bl,
31238
- isMacOS as bm,
31239
- textContentFromSerializedLexicalNode as bn,
31240
- FAST_CHAT_INPUT_TOKEN_BUDGET as bo,
31241
- deserializeContextItem as bp,
31242
- View as bq,
31243
- truncateTextStart as br,
31244
- CHAT_INPUT_TOKEN_BUDGET as bs,
31245
- ACCOUNT_USAGE_URL as bt,
31246
- getRelativeChatPeriod as bu,
31247
- browser as bv,
31248
- isErrorLike as bw,
31249
- setDisplayPathEnvInfo as bx,
31250
- PromptString as by,
31251
- createSubscriber as bz,
31319
+ isMacOS as bl,
31320
+ textContentFromSerializedLexicalNode as bm,
31321
+ FAST_CHAT_INPUT_TOKEN_BUDGET as bn,
31322
+ deserializeContextItem as bo,
31323
+ View as bp,
31324
+ ACCOUNT_USAGE_URL as bq,
31325
+ getRelativeChatPeriod as br,
31326
+ truncateTextStart as bs,
31327
+ CHAT_INPUT_TOKEN_BUDGET as bt,
31328
+ browser as bu,
31329
+ isErrorLike as bv,
31330
+ setDisplayPathEnvInfo as bw,
31331
+ PromptString as bx,
31332
+ Observable as by,
31333
+ unsubscribe as bz,
31252
31334
  bs as c,
31253
- isNodeResponse as c$,
31254
- openCtx as c0,
31255
- extensionForLanguage as c1,
31256
- isSourcegraphToken as c2,
31257
- _$1 as c3,
31258
- toRangeData as c4,
31259
- DOTCOM_URL as c5,
31260
- base64Js as c6,
31261
- isDotCom as c7,
31262
- NetworkError as c8,
31263
- isRateLimitError as c9,
31264
- uriParseNameAndExtension as cA,
31265
- uriDirname as cB,
31266
- DefaultEditCommands as cC,
31267
- promiseFactoryToObservable as cD,
31268
- webMentionProvidersMetadata as cE,
31269
- allMentionProvidersMetadata as cF,
31270
- combineLatest as cG,
31271
- subscriptionDisposable as cH,
31272
- expandToLineRange as cI,
31273
- offlineModeAuthStatus as cJ,
31274
- unauthenticatedStatus as cK,
31275
- semver$1 as cL,
31276
- truncateTextNearestLine as cM,
31277
- TokenCounter as cN,
31278
- tracer as cO,
31279
- isContextWindowLimitError as cP,
31280
- truncatePromptString as cQ,
31281
- inputTextWithoutContextChipsFromPromptEditorState as cR,
31282
- addMessageListenersForExtensionAPI as cS,
31283
- createMessageAPIForExtension as cT,
31284
- CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID as cU,
31285
- editorStateFromPromptString as cV,
31286
- getEditorTabSize as cW,
31287
- AbortError as cX,
31288
- getEditorIndentString as cY,
31289
- logResponseHeadersToSpan as cZ,
31290
- TracedError as c_,
31291
- isAuthError as ca,
31292
- NoOpTelemetryRecorderProvider as cb,
31293
- TimestampTelemetryProcessor_1 as cc,
31294
- updateGlobalTelemetryInstances as cd,
31295
- TelemetryRecorderProvider as ce,
31296
- telemetryRecorderProvider as cf,
31297
- convertGitCloneURLToCodebaseName as cg,
31298
- uriExtname as ch,
31299
- SUPPORTED_URI_SCHEMAS as ci,
31300
- require$$1 as cj,
31301
- dedupeWith as ck,
31302
- getEditorInsertSpaces as cl,
31303
- TimeoutError as cm,
31304
- getActiveTraceAndSpanId as cn,
31305
- isNetworkError as co,
31306
- trace as cp,
31307
- getAugmentedNamespace as cq,
31308
- main as cr,
31309
- setUserAgent as cs,
31310
- TESTING_TELEMETRY_EXPORTER as ct,
31311
- dist as cu,
31312
- _root as cv,
31313
- _baseGetTag as cw,
31314
- isObjectLike_1 as cx,
31315
- isObject_1 as cy,
31316
- DefaultChatCommands as cz,
31335
+ AbortError as c$,
31336
+ verifyResponseCode as c0,
31337
+ openCtx as c1,
31338
+ AsyncSerialScheduler_1 as c2,
31339
+ extensionForLanguage as c3,
31340
+ isSourcegraphToken as c4,
31341
+ _$1 as c5,
31342
+ toRangeData as c6,
31343
+ DOTCOM_URL as c7,
31344
+ requireBase64Js as c8,
31345
+ NetworkError as c9,
31346
+ TESTING_TELEMETRY_EXPORTER as cA,
31347
+ dist as cB,
31348
+ waitUntilComplete as cC,
31349
+ _root as cD,
31350
+ _baseGetTag as cE,
31351
+ isObjectLike_1 as cF,
31352
+ isObject_1 as cG,
31353
+ uriParseNameAndExtension as cH,
31354
+ uriDirname as cI,
31355
+ promiseFactoryToObservable as cJ,
31356
+ webMentionProvidersMetadata as cK,
31357
+ allMentionProvidersMetadata as cL,
31358
+ combineLatest as cM,
31359
+ expandToLineRange as cN,
31360
+ truncateTextNearestLine as cO,
31361
+ TokenCounter as cP,
31362
+ tracer as cQ,
31363
+ isContextWindowLimitError as cR,
31364
+ truncatePromptString as cS,
31365
+ inputTextWithoutContextChipsFromPromptEditorState as cT,
31366
+ addMessageListenersForExtensionAPI as cU,
31367
+ createMessageAPIForExtension as cV,
31368
+ startWith as cW,
31369
+ promiseToObservable as cX,
31370
+ CODY_PASSTHROUGH_VSCODE_OPEN_COMMAND_ID as cY,
31371
+ editorStateFromPromptString as cZ,
31372
+ getEditorTabSize as c_,
31373
+ isRateLimitError as ca,
31374
+ isAuthError as cb,
31375
+ semver$1 as cc,
31376
+ NO_INITIAL_VALUE as cd,
31377
+ distinctUntilChanged as ce,
31378
+ SourcegraphGraphQLAPIClient as cf,
31379
+ isNetworkLikeError as cg,
31380
+ NoOpTelemetryRecorderProvider as ch,
31381
+ TimestampTelemetryProcessor_1 as ci,
31382
+ updateGlobalTelemetryInstances as cj,
31383
+ TelemetryRecorderProvider as ck,
31384
+ telemetryRecorderProvider as cl,
31385
+ convertGitCloneURLToCodebaseName as cm,
31386
+ subscriptionDisposable as cn,
31387
+ uriExtname as co,
31388
+ SUPPORTED_URI_SCHEMAS as cp,
31389
+ require$$1 as cq,
31390
+ dedupeWith as cr,
31391
+ getEditorInsertSpaces as cs,
31392
+ TimeoutError as ct,
31393
+ getActiveTraceAndSpanId as cu,
31394
+ isNetworkError as cv,
31395
+ trace as cw,
31396
+ getAugmentedNamespace as cx,
31397
+ main as cy,
31398
+ setUserAgent as cz,
31317
31399
  dedent as d,
31318
- SpanStatusCode as d0,
31319
- assertFileURI as d1,
31320
- setOpenCtx as d2,
31321
- GIT_OPENCTX_PROVIDER_URI as d3,
31322
- ACCOUNT_UPGRADE_URL as d4,
31323
- GENERAL_HELP_LABEL as d5,
31324
- diffLines as d6,
31325
- psDedent as d7,
31326
- defaultAuthStatus as d8,
31327
- SourcegraphGraphQLAPIClient as d9,
31328
- networkErrorAuthStatus as da,
31329
- languageFromFilename as db,
31330
- ProgrammingLanguage as dc,
31331
- truncatePromptStringStart as dd,
31332
- posixFilePaths as de,
31333
- CODY_DOC_URL as df,
31334
- DISCORD_URL as dg,
31335
- CODY_SUPPORT_URL as dh,
31336
- SG_BLOG_URL as di,
31337
- ACCOUNT_LIMITS_INFO_URL as dj,
31338
- setLogger as dk,
31339
- CODY_OLLAMA_DOCS_URL as dl,
31400
+ getEditorIndentString as d0,
31401
+ logResponseHeadersToSpan as d1,
31402
+ TracedError as d2,
31403
+ isNodeResponse as d3,
31404
+ SpanStatusCode as d4,
31405
+ assertFileURI as d5,
31406
+ setOpenCtx as d6,
31407
+ GIT_OPENCTX_PROVIDER_URI as d7,
31408
+ ACCOUNT_UPGRADE_URL as d8,
31409
+ GENERAL_HELP_LABEL as d9,
31410
+ diffLines as da,
31411
+ psDedent as db,
31412
+ languageFromFilename as dc,
31413
+ ProgrammingLanguage as dd,
31414
+ truncatePromptStringStart as de,
31415
+ posixFilePaths as df,
31416
+ CODY_DOC_URL as dg,
31417
+ DISCORD_URL as dh,
31418
+ CODY_SUPPORT_URL as di,
31419
+ SG_BLOG_URL as dj,
31420
+ ACCOUNT_LIMITS_INFO_URL as dk,
31421
+ setLogger as dl,
31422
+ CODY_OLLAMA_DOCS_URL as dm,
31340
31423
  ws as e,
31341
31424
  g as f,
31342
31425
  getDefaultExportFromCjs as g,