@copilotkit/web-inspector 1.77.2 → 1.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -3064,7 +3064,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3064
3064
 
3065
3065
  //#endregion
3066
3066
  //#region package.json
3067
- var version = "1.77.2";
3067
+ var version = "1.79.0";
3068
3068
 
3069
3069
  //#endregion
3070
3070
  //#region src/lib/telemetry.ts
@@ -3672,6 +3672,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3672
3672
  //#endregion
3673
3673
  //#region src/index.ts
3674
3674
  var _globalThis$HTMLEleme;
3675
+ /**
3676
+ * Resolve the attached core's request headers at send time. A core released
3677
+ * before `resolveHeaders()` existed has only the static `headers` map, so an
3678
+ * inspector attached to it falls back to a copy of that map.
3679
+ */
3680
+ function resolveAttachedCoreHeaders(core) {
3681
+ return typeof core.resolveHeaders === "function" ? core.resolveHeaders() : { ...core.headers };
3682
+ }
3675
3683
  const WEB_INSPECTOR_TAG = "cpk-web-inspector";
3676
3684
  const THREAD_INSPECTOR_TAG = "cpk-thread-inspector";
3677
3685
  /**
@@ -4996,6 +5004,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
4996
5004
  this.thread = null;
4997
5005
  this.runtimeUrl = "";
4998
5006
  this.headers = {};
5007
+ this.resolveHeaders = CpkThreadInspector.ɵdefaultResolveHeaders;
5008
+ this.headersGeneration = 0;
4999
5009
  this.threadInspectionAvailable = false;
5000
5010
  this.agentStateInput = null;
5001
5011
  this.agentEventsInput = [];
@@ -5095,14 +5105,6 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5095
5105
  provider.getState ? "state:1" : "state:0"
5096
5106
  ].join("|");
5097
5107
  }
5098
- /**
5099
- * Build a deterministic signature for runtime fetch headers so auth/CSRF
5100
- * changes invalidate cached thread data even when the selected thread is
5101
- * otherwise unchanged.
5102
- */
5103
- static headersLoadKey(headers) {
5104
- return JSON.stringify(Object.entries(headers).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
5105
- }
5106
5108
  renderConversationActions() {
5107
5109
  return lit.html`<div class="cpk-td__timeline-toolbar">
5108
5110
  <button type="button" class="cpk-td__timeline-bulk-toggle" aria-pressed=${this._showEventTimeline} @click=${() => {
@@ -5248,7 +5250,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5248
5250
  (_this$threadId = this.threadId) !== null && _this$threadId !== void 0 ? _this$threadId : "thread:none",
5249
5251
  CpkThreadInspector.providerLoadKey(this.provider),
5250
5252
  `runtime:${this.runtimeUrl}`,
5251
- `headers:${CpkThreadInspector.headersLoadKey(this.headers)}`,
5253
+ `headersGen:${this.headersGeneration}`,
5252
5254
  `inspect:${this.threadInspectionAvailable ? "1" : "0"}`
5253
5255
  ].join("||");
5254
5256
  }
@@ -5411,9 +5413,16 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5411
5413
  if (!controller.signal.aborted && this.threadId === threadId) this._loadingState = false;
5412
5414
  }
5413
5415
  }
5416
+ /**
5417
+ * `resolveHeaders` when a host actually set it; otherwise the deprecated
5418
+ * `headers` fallback. Never both — see the `headers` field's doc.
5419
+ */
5420
+ ɵresolveInspectorHeaders() {
5421
+ return this.resolveHeaders === CpkThreadInspector.ɵdefaultResolveHeaders ? this.headers : this.resolveHeaders();
5422
+ }
5414
5423
  async fetchRuntimeMessages(threadId, signal) {
5415
5424
  const res = await fetch(this.getThreadInspectionUrl(threadId, "messages"), {
5416
- headers: { ...this.headers },
5425
+ headers: { ...await this.ɵresolveInspectorHeaders() },
5417
5426
  signal
5418
5427
  });
5419
5428
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -5421,7 +5430,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5421
5430
  }
5422
5431
  async fetchRuntimeEvents(threadId, signal) {
5423
5432
  const res = await fetch(this.getThreadInspectionUrl(threadId, "events"), {
5424
- headers: { ...this.headers },
5433
+ headers: { ...await this.ɵresolveInspectorHeaders() },
5425
5434
  signal
5426
5435
  });
5427
5436
  if (res.status === 501) return { status: "not-available" };
@@ -5434,7 +5443,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
5434
5443
  async fetchRuntimeState(threadId, signal) {
5435
5444
  var _data$state;
5436
5445
  const res = await fetch(this.getThreadInspectionUrl(threadId, "state"), {
5437
- headers: { ...this.headers },
5446
+ headers: { ...await this.ɵresolveInspectorHeaders() },
5438
5447
  signal
5439
5448
  });
5440
5449
  if (res.status === 501) return { status: "not-available" };
@@ -6777,6 +6786,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
6777
6786
  thread: { attribute: false },
6778
6787
  runtimeUrl: { attribute: false },
6779
6788
  headers: { attribute: false },
6789
+ resolveHeaders: { attribute: false },
6790
+ headersGeneration: { attribute: false },
6780
6791
  threadInspectionAvailable: { attribute: false },
6781
6792
  agentStateInput: { attribute: false },
6782
6793
  agentEventsInput: { attribute: false },
@@ -6813,6 +6824,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
6813
6824
  _activatedTabs: { state: true }
6814
6825
  };
6815
6826
  CpkThreadInspector.nextDomId = 1;
6827
+ CpkThreadInspector.ɵdefaultResolveHeaders = () => ({});
6816
6828
  CpkThreadInspector.COLLAPSE_THRESHOLD = 800;
6817
6829
  CpkThreadInspector.TAB_LIST = [
6818
6830
  {
@@ -8838,6 +8850,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
8838
8850
  constructor(..._args5) {
8839
8851
  super(..._args5);
8840
8852
  this._core = null;
8853
+ this.resolveCoreHeaders = () => this._core ? resolveAttachedCoreHeaders(this._core) : {};
8841
8854
  this.coreSubscriber = null;
8842
8855
  this.coreUnsubscribe = null;
8843
8856
  this._memories = [];
@@ -9157,7 +9170,6 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
9157
9170
  insightsPage: (_ref7 = (_options$insightsPage = options.insightsPage) !== null && _options$insightsPage !== void 0 ? _options$insightsPage : (_this$learningSnapsho2 = this.learningSnapshot) === null || _this$learningSnapsho2 === void 0 ? void 0 : _this$learningSnapsho2.insightsPage.page) !== null && _ref7 !== void 0 ? _ref7 : 1
9158
9171
  },
9159
9172
  fetch: core.ɵruntimeFetch,
9160
- headers: core.headers,
9161
9173
  credentials: core.credentials,
9162
9174
  signal: controller.signal
9163
9175
  });
@@ -10424,11 +10436,12 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
10424
10436
  if ((_this$core15 = this.core) === null || _this$core15 === void 0 ? void 0 : _this$core15.getThreadStore(agentId)) return;
10425
10437
  const core = this.core;
10426
10438
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
10427
- const store = (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: typeof core.ɵruntimeFetch === "function" ? core.ɵruntimeFetch : globalThis.fetch });
10439
+ const hasRuntimeFetch = typeof core.ɵruntimeFetch === "function";
10440
+ const store = (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: hasRuntimeFetch ? core.ɵruntimeFetch : globalThis.fetch });
10428
10441
  store.start();
10429
10442
  store.setContext({
10430
10443
  runtimeUrl: core.runtimeUrl,
10431
- headers: { ...core.headers },
10444
+ ...hasRuntimeFetch ? {} : { headers: { ...core.headers } },
10432
10445
  wsUrl: (_core$intelligence = core.intelligence) === null || _core$intelligence === void 0 ? void 0 : _core$intelligence.wsUrl,
10433
10446
  agentId
10434
10447
  });
@@ -10467,11 +10480,12 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
10467
10480
  if (!this.areThreadEndpointsAvailable()) return;
10468
10481
  const core = this.core;
10469
10482
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
10483
+ const hasRuntimeFetch = typeof core.ɵruntimeFetch === "function";
10470
10484
  for (const [agentId, store] of this._ownedThreadStores) {
10471
10485
  var _core$intelligence2;
10472
10486
  store.setContext({
10473
10487
  runtimeUrl: core.runtimeUrl,
10474
- headers: { ...headers },
10488
+ ...hasRuntimeFetch ? {} : { headers: { ...headers } },
10475
10489
  wsUrl: (_core$intelligence2 = core.intelligence) === null || _core$intelligence2 === void 0 ? void 0 : _core$intelligence2.wsUrl,
10476
10490
  agentId
10477
10491
  });
@@ -14318,7 +14332,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
14318
14332
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) throw new Error("Failed to load thread.");
14319
14333
  const baseUrl = core.runtimeUrl.replace(/\/+$/, "");
14320
14334
  const encodedThreadId = encodeURIComponent(thread.id);
14321
- const [messagesResponse, stateResponse] = await Promise.all([fetch(`${baseUrl}/threads/${encodedThreadId}/messages`, { headers: { ...core.headers } }), fetch(`${baseUrl}/threads/${encodedThreadId}/state`, { headers: { ...core.headers } })]);
14335
+ const headers = { ...await resolveAttachedCoreHeaders(core) };
14336
+ const [messagesResponse, stateResponse] = await Promise.all([fetch(`${baseUrl}/threads/${encodedThreadId}/messages`, { headers }), fetch(`${baseUrl}/threads/${encodedThreadId}/state`, { headers })]);
14322
14337
  if (!messagesResponse.ok) throw new Error(`Failed to load thread (HTTP ${messagesResponse.status}).`);
14323
14338
  const messagesBody = await messagesResponse.json();
14324
14339
  const stateBody = stateResponse.ok ? await stateResponse.json() : { state: {} };
@@ -15912,7 +15927,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
15912
15927
  `;
15913
15928
  }
15914
15929
  renderThreadsView() {
15915
- var _this$_core20, _visibleThreads$find, _this$_core$runtimeUr2, _this$_core21, _this$_core$headers, _this$_core22, _this$_core23, _this$liveMessageVers2, _this$agentEvents$get6, _this$_core24;
15930
+ var _this$_core20, _visibleThreads$find, _this$_core$runtimeUr2, _this$_core21, _this$_core$ɵheaders, _this$_core22, _this$_core23, _this$liveMessageVers2, _this$agentEvents$get6, _this$_core24;
15916
15931
  const { displayThreads, threadsErrorMessage, threadsLoading } = this.getActiveThreadsState();
15917
15932
  const ephemeral = !((_this$_core20 = this._core) === null || _this$_core20 === void 0 ? void 0 : _this$_core20.intelligence);
15918
15933
  const available = this.areThreadEndpointsAvailable();
@@ -16053,7 +16068,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
16053
16068
  .thread=${selectedThread}
16054
16069
  .provider=${selectedThreadIsLocalExample ? this.getExampleThreadProvider(selectedThread.id) : null}
16055
16070
  .runtimeUrl=${selectedThreadIsLocalExample ? "" : (_this$_core$runtimeUr2 = (_this$_core21 = this._core) === null || _this$_core21 === void 0 ? void 0 : _this$_core21.runtimeUrl) !== null && _this$_core$runtimeUr2 !== void 0 ? _this$_core$runtimeUr2 : ""}
16056
- .headers=${(_this$_core$headers = (_this$_core22 = this._core) === null || _this$_core22 === void 0 ? void 0 : _this$_core22.headers) !== null && _this$_core$headers !== void 0 ? _this$_core$headers : {}}
16071
+ .resolveHeaders=${this.resolveCoreHeaders}
16072
+ .headersGeneration=${(_this$_core$ɵheaders = (_this$_core22 = this._core) === null || _this$_core22 === void 0 ? void 0 : _this$_core22.ɵheadersGeneration) !== null && _this$_core$ɵheaders !== void 0 ? _this$_core$ɵheaders : 0}
16057
16073
  .threadInspectionAvailable=${selectedThreadIsLocalExample || this.areThreadEndpointsAvailable() && ((_this$_core23 = this._core) === null || _this$_core23 === void 0 || (_this$_core23 = _this$_core23.threadEndpoints) === null || _this$_core23 === void 0 ? void 0 : _this$_core23.inspect) !== false}
16058
16074
  .liveMessageVersion=${(_this$liveMessageVers2 = this.liveMessageVersion.get(selectedThread.id)) !== null && _this$liveMessageVers2 !== void 0 ? _this$liveMessageVers2 : 0}
16059
16075
  .viewInAppMode=${this.getViewInAppMode(selectedThread, selectedThreadIsLocalExample)}