@copilotkit/web-inspector 1.61.0 → 1.61.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -687,6 +687,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
687
687
  this.thread = null;
688
688
  this.runtimeUrl = "";
689
689
  this.headers = {};
690
+ this.threadInspectionAvailable = false;
690
691
  this.agentStateInput = null;
691
692
  this.agentEventsInput = [];
692
693
  this.liveMessageVersion = 0;
@@ -809,7 +810,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
809
810
  * so users see an explicit loading indicator on first load.
810
811
  */
811
812
  async fetchMessages(threadId, silent = false) {
812
- if (!this.runtimeUrl) {
813
+ if (!this.runtimeUrl || !this.threadInspectionAvailable) {
813
814
  if (!silent) this._conversation = [];
814
815
  return;
815
816
  }
@@ -841,7 +842,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
841
842
  }
842
843
  async fetchEvents(threadId) {
843
844
  this._eventsNotAvailable = false;
844
- if (!this.runtimeUrl) {
845
+ if (!this.runtimeUrl || !this.threadInspectionAvailable) {
845
846
  this._fetchedEvents = null;
846
847
  return;
847
848
  }
@@ -875,7 +876,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
875
876
  }
876
877
  async fetchState(threadId) {
877
878
  this._stateNotAvailable = false;
878
- if (!this.runtimeUrl) {
879
+ if (!this.runtimeUrl || !this.threadInspectionAvailable) {
879
880
  this._fetchedState = null;
880
881
  return;
881
882
  }
@@ -1503,6 +1504,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
1503
1504
  thread: { attribute: false },
1504
1505
  runtimeUrl: { attribute: false },
1505
1506
  headers: { attribute: false },
1507
+ threadInspectionAvailable: { attribute: false },
1506
1508
  agentStateInput: { attribute: false },
1507
1509
  agentEventsInput: { attribute: false },
1508
1510
  liveMessageVersion: { attribute: false },
@@ -2533,16 +2535,18 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
2533
2535
  this._threads = [];
2534
2536
  }
2535
2537
  ensureOwnedThreadStore(agentId) {
2536
- var _this$core;
2538
+ var _this$core, _core$threadEndpoints, _core$intelligence;
2537
2539
  if (this._ownedThreadStores.has(agentId)) return;
2538
2540
  if ((_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.getThreadStore(agentId)) return;
2539
2541
  const core = this.core;
2540
2542
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
2543
+ if (((_core$threadEndpoints = core.threadEndpoints) === null || _core$threadEndpoints === void 0 ? void 0 : _core$threadEndpoints.list) === false) return;
2541
2544
  const store = (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: globalThis.fetch });
2542
2545
  store.start();
2543
2546
  store.setContext({
2544
2547
  runtimeUrl: core.runtimeUrl,
2545
- headers: {},
2548
+ headers: { ...core.headers },
2549
+ wsUrl: (_core$intelligence = core.intelligence) === null || _core$intelligence === void 0 ? void 0 : _core$intelligence.wsUrl,
2546
2550
  agentId
2547
2551
  });
2548
2552
  this._ownedThreadStores.set(agentId, store);
@@ -2554,6 +2558,15 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
2554
2558
  if (!store) return;
2555
2559
  store.refresh();
2556
2560
  }
2561
+ updateOwnedThreadStoreHeaders(headers) {
2562
+ const core = this.core;
2563
+ if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
2564
+ for (const [agentId, store] of this._ownedThreadStores) store.setContext({
2565
+ runtimeUrl: core.runtimeUrl,
2566
+ headers: { ...headers },
2567
+ agentId
2568
+ });
2569
+ }
2557
2570
  removeOwnedThreadStore(agentId) {
2558
2571
  var _this$core2;
2559
2572
  const store = this._ownedThreadStores.get(agentId);
@@ -2578,12 +2591,14 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
2578
2591
  onRuntimeConnectionStatusChanged: ({ status }) => {
2579
2592
  this.runtimeStatus = status;
2580
2593
  if (status === "connected") {
2594
+ var _core$threadEndpoints2;
2581
2595
  if (!core.telemetryDisabled) {
2582
2596
  ensureTelemetryDistinctId();
2583
2597
  maybeShowDisclosure();
2584
2598
  }
2585
2599
  this.flushPendingBannerViewed();
2586
- for (const agentId of this._ownedThreadStores.keys()) this.refreshOwnedThreadStore(agentId);
2600
+ if (((_core$threadEndpoints2 = core.threadEndpoints) === null || _core$threadEndpoints2 === void 0 ? void 0 : _core$threadEndpoints2.list) !== false) for (const agentId of this._ownedThreadStores.keys()) this.refreshOwnedThreadStore(agentId);
2601
+ else this.teardownOwnedThreadStores();
2587
2602
  } else {
2588
2603
  this._threadsByAgent.clear();
2589
2604
  this._threads = [];
@@ -2594,6 +2609,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
2594
2609
  this.coreProperties = properties;
2595
2610
  this.requestUpdate();
2596
2611
  },
2612
+ onHeadersChanged: ({ headers }) => {
2613
+ this.updateOwnedThreadStoreHeaders(headers);
2614
+ },
2597
2615
  onError: ({ code, error }) => {
2598
2616
  this.lastCoreError = {
2599
2617
  code,
@@ -3896,7 +3914,7 @@ ${argsString}</pre
3896
3914
  });
3897
3915
  }
3898
3916
  renderThreadsView() {
3899
- var _this$_threadsByAgent, _displayThreads$find, _this$_core$runtimeUr, _this$_core2, _this$_core$headers, _this$_core3, _this$liveMessageVers2, _this$agentEvents$get6;
3917
+ var _this$_threadsByAgent, _displayThreads$find, _this$_core$runtimeUr, _this$_core2, _this$_core$headers, _this$_core3, _this$_core4, _this$liveMessageVers2, _this$agentEvents$get6;
3900
3918
  const displayThreads = this.selectedContext === "all-agents" ? this._threads : (_this$_threadsByAgent = this._threadsByAgent.get(this.selectedContext)) !== null && _this$_threadsByAgent !== void 0 ? _this$_threadsByAgent : [];
3901
3919
  let threadsErrorMessage = null;
3902
3920
  if (this.selectedContext === "all-agents") {
@@ -3943,6 +3961,7 @@ ${argsString}</pre
3943
3961
  .thread=${selectedThread}
3944
3962
  .runtimeUrl=${(_this$_core$runtimeUr = (_this$_core2 = this._core) === null || _this$_core2 === void 0 ? void 0 : _this$_core2.runtimeUrl) !== null && _this$_core$runtimeUr !== void 0 ? _this$_core$runtimeUr : ""}
3945
3963
  .headers=${(_this$_core$headers = (_this$_core3 = this._core) === null || _this$_core3 === void 0 ? void 0 : _this$_core3.headers) !== null && _this$_core$headers !== void 0 ? _this$_core$headers : {}}
3964
+ .threadInspectionAvailable=${((_this$_core4 = this._core) === null || _this$_core4 === void 0 || (_this$_core4 = _this$_core4.threadEndpoints) === null || _this$_core4 === void 0 ? void 0 : _this$_core4.inspect) !== false}
3946
3965
  .liveMessageVersion=${this.selectedThreadId ? (_this$liveMessageVers2 = this.liveMessageVersion.get(this.selectedThreadId)) !== null && _this$liveMessageVers2 !== void 0 ? _this$liveMessageVers2 : 0 : 0}
3947
3966
  .agentStateInput=${selectedThread ? this.getLatestStateForAgent(selectedThread.agentId) : null}
3948
3967
  .agentEventsInput=${selectedThread ? (_this$agentEvents$get6 = this.agentEvents.get(selectedThread.agentId)) !== null && _this$agentEvents$get6 !== void 0 ? _this$agentEvents$get6 : [] : []}