@copilotkit/web-inspector 1.62.1 → 1.62.2-canary.1783457132

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
@@ -191,7 +191,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
191
191
 
192
192
  //#endregion
193
193
  //#region package.json
194
- var version = "1.62.1";
194
+ var version = "1.62.2-canary.1783457132";
195
195
 
196
196
  //#endregion
197
197
  //#region src/lib/telemetry.ts
@@ -204,7 +204,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
204
204
  threadsTalkToEngineerClicked: "oss.inspector.threads_talk_to_engineer_clicked",
205
205
  talkToEngineerClicked: "oss.inspector.talk_to_engineer_clicked",
206
206
  threadsEmptyEnabledViewed: "oss.inspector.threads_empty_enabled_viewed",
207
- threadsEnabledViewed: "oss.inspector.threads_enabled_viewed"
207
+ threadsEnabledViewed: "oss.inspector.threads_enabled_viewed",
208
+ memoriesTabClicked: "oss.inspector.memories_tab_clicked"
208
209
  };
209
210
  const TELEMETRY_INGEST_URL = "https://telemetry.copilotkit.ai/ingest";
210
211
  const TELEMETRY_DOCS_URL = "https://docs.copilotkit.ai/telemetry";
@@ -212,7 +213,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
212
213
  const PACKAGE_VERSION = version;
213
214
  const FETCH_TIMEOUT_MS = 3e3;
214
215
  function isThreadsTelemetryEvent(event) {
215
- return event === TELEMETRY_EVENTS.threadsTabClicked || event === TELEMETRY_EVENTS.threadsLockedViewed || event === TELEMETRY_EVENTS.threadsIntelligenceSignupClicked || event === TELEMETRY_EVENTS.threadsTalkToEngineerClicked || event === TELEMETRY_EVENTS.talkToEngineerClicked || event === TELEMETRY_EVENTS.threadsEmptyEnabledViewed || event === TELEMETRY_EVENTS.threadsEnabledViewed;
216
+ return event === TELEMETRY_EVENTS.threadsTabClicked || event === TELEMETRY_EVENTS.threadsLockedViewed || event === TELEMETRY_EVENTS.threadsIntelligenceSignupClicked || event === TELEMETRY_EVENTS.threadsTalkToEngineerClicked || event === TELEMETRY_EVENTS.talkToEngineerClicked || event === TELEMETRY_EVENTS.threadsEmptyEnabledViewed || event === TELEMETRY_EVENTS.threadsEnabledViewed || event === TELEMETRY_EVENTS.memoriesTabClicked;
216
217
  }
217
218
  function getRuntimeUrlType(runtimeUrl) {
218
219
  if (!runtimeUrl) return "missing";
@@ -291,6 +292,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
291
292
  function trackThreadsEnabledViewed(props) {
292
293
  track(TELEMETRY_EVENTS.threadsEnabledViewed, props);
293
294
  }
295
+ function trackMemoriesTabClicked(props = {}) {
296
+ track(TELEMETRY_EVENTS.memoriesTabClicked, props);
297
+ }
294
298
  /**
295
299
  * Returns the inspector's anonymous distinct-ID for cross-domain
296
300
  * propagation onto outbound banner-CTA links, or `null` when the user
@@ -772,6 +776,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
772
776
  this._stateError = null;
773
777
  this._expandedTools = /* @__PURE__ */ new Set();
774
778
  this._expandedMessages = /* @__PURE__ */ new Set();
779
+ this._expandedTimelineDetails = /* @__PURE__ */ new Set();
780
+ this._expandedRawEvents = /* @__PURE__ */ new Set();
775
781
  this._showDetailPanel = false;
776
782
  this._detailPanelWidth = 250;
777
783
  this._eventsNotAvailable = false;
@@ -920,6 +926,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
920
926
  this._liveEventsWithSourceIndexCache = null;
921
927
  this._expandedTools = /* @__PURE__ */ new Set();
922
928
  this._expandedMessages = /* @__PURE__ */ new Set();
929
+ this._expandedTimelineDetails = /* @__PURE__ */ new Set();
930
+ this._expandedRawEvents = /* @__PURE__ */ new Set();
923
931
  (_this$_metadataAbort = this._metadataAbort) === null || _this$_metadataAbort === void 0 || _this$_metadataAbort.abort();
924
932
  this._metadataAbort = null;
925
933
  (_this$_messagesAbort2 = this._messagesAbort) === null || _this$_messagesAbort2 === void 0 || _this$_messagesAbort2.abort();
@@ -1474,10 +1482,42 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1474
1482
  else next.add(id);
1475
1483
  this._expandedMessages = next;
1476
1484
  }
1485
+ toggleTimelineDetails(id) {
1486
+ const next = new Set(this._expandedTimelineDetails);
1487
+ if (next.has(id)) next.delete(id);
1488
+ else next.add(id);
1489
+ this._expandedTimelineDetails = next;
1490
+ }
1491
+ expandTimelineDetails(ids) {
1492
+ this._expandedTimelineDetails = new Set([...this._expandedTimelineDetails, ...ids]);
1493
+ }
1494
+ collapseTimelineDetails(ids) {
1495
+ const next = new Set(this._expandedTimelineDetails);
1496
+ for (const id of ids) next.delete(id);
1497
+ this._expandedTimelineDetails = next;
1498
+ }
1499
+ toggleRawEventDetails(id) {
1500
+ const next = new Set(this._expandedRawEvents);
1501
+ if (next.has(id)) next.delete(id);
1502
+ else next.add(id);
1503
+ this._expandedRawEvents = next;
1504
+ }
1505
+ expandRawEventDetails(ids) {
1506
+ this._expandedRawEvents = new Set([...this._expandedRawEvents, ...ids]);
1507
+ }
1508
+ collapseRawEventDetails(ids) {
1509
+ const next = new Set(this._expandedRawEvents);
1510
+ for (const id of ids) next.delete(id);
1511
+ this._expandedRawEvents = next;
1512
+ }
1513
+ rawEventId(event) {
1514
+ var _ref, _event$sourceIndex2;
1515
+ return `raw-event-${(_ref = (_event$sourceIndex2 = event.sourceIndex) !== null && _event$sourceIndex2 !== void 0 ? _event$sourceIndex2 : event.timestamp) !== null && _ref !== void 0 ? _ref : event.type}`;
1516
+ }
1477
1517
  get activeEvents() {
1478
- var _ref, _this$_fetchedEvents, _this$_liveEventsWith;
1518
+ var _ref2, _this$_fetchedEvents, _this$_liveEventsWith;
1479
1519
  if (this._eventsNotAvailable) return [];
1480
- const events = (_ref = (_this$_fetchedEvents = this._fetchedEvents) !== null && _this$_fetchedEvents !== void 0 ? _this$_fetchedEvents : this.agentEventsInput) !== null && _ref !== void 0 ? _ref : [];
1520
+ const events = (_ref2 = (_this$_fetchedEvents = this._fetchedEvents) !== null && _this$_fetchedEvents !== void 0 ? _this$_fetchedEvents : this.agentEventsInput) !== null && _ref2 !== void 0 ? _ref2 : [];
1481
1521
  if (events.every((event) => event.sourceIndex != null)) return events;
1482
1522
  if (((_this$_liveEventsWith = this._liveEventsWithSourceIndexCache) === null || _this$_liveEventsWith === void 0 ? void 0 : _this$_liveEventsWith.events) === events) return this._liveEventsWithSourceIndexCache.indexedEvents;
1483
1523
  const indexedEvents = events.map((event, index) => event.sourceIndex == null ? {
@@ -1491,9 +1531,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1491
1531
  return indexedEvents;
1492
1532
  }
1493
1533
  get activeState() {
1494
- var _ref2, _this$_fetchedState;
1534
+ var _ref3, _this$_fetchedState;
1495
1535
  if (this._stateNotAvailable) return null;
1496
- return (_ref2 = (_this$_fetchedState = this._fetchedState) !== null && _this$_fetchedState !== void 0 ? _this$_fetchedState : this.agentStateInput) !== null && _ref2 !== void 0 ? _ref2 : null;
1536
+ return (_ref3 = (_this$_fetchedState = this._fetchedState) !== null && _this$_fetchedState !== void 0 ? _this$_fetchedState : this.agentStateInput) !== null && _ref3 !== void 0 ? _ref3 : null;
1497
1537
  }
1498
1538
  hasRenderableState() {
1499
1539
  const s = this.activeState;
@@ -1504,8 +1544,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1504
1544
  return id.length > 20 ? id.slice(0, 8) + "…" : id;
1505
1545
  }
1506
1546
  get metadata() {
1507
- var _ref3, _this$_fetchedMetadat;
1508
- return (_ref3 = (_this$_fetchedMetadat = this._fetchedMetadata) !== null && _this$_fetchedMetadat !== void 0 ? _this$_fetchedMetadat : this.thread) !== null && _ref3 !== void 0 ? _ref3 : null;
1547
+ var _ref4, _this$_fetchedMetadat;
1548
+ return (_ref4 = (_this$_fetchedMetadat = this._fetchedMetadata) !== null && _this$_fetchedMetadat !== void 0 ? _this$_fetchedMetadat : this.thread) !== null && _ref4 !== void 0 ? _ref4 : null;
1509
1549
  }
1510
1550
  fmtTime(dateStr) {
1511
1551
  if (!dateStr) return "—";
@@ -1601,22 +1641,73 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1601
1641
  value: metadata === null || metadata === void 0 ? void 0 : metadata.status
1602
1642
  }
1603
1643
  ].filter((pill) => pill.value != null && pill.value !== "");
1604
- if (pills.length === 0) return lit.nothing;
1644
+ const bulkControls = this.renderActiveBulkControls();
1645
+ if (pills.length === 0 && bulkControls === lit.nothing) return lit.nothing;
1605
1646
  return lit.html`
1606
1647
  <div class="cpk-td__metadata-strip" aria-label="Thread metadata">
1607
- ${pills.map((pill) => {
1648
+ <div class="cpk-td__metadata-pills">
1649
+ ${pills.map((pill) => {
1608
1650
  var _pill$value;
1609
1651
  return lit.html`
1610
- <span class="cpk-td__metadata-pill" title=${(_pill$value = pill.value) !== null && _pill$value !== void 0 ? _pill$value : ""}>
1611
- <span class="cpk-td__metadata-label">${pill.label}</span>
1612
- <span class="cpk-td__metadata-value"
1613
- >${this.shortId(pill.value)}</span
1614
- >
1615
- </span>
1616
- `;
1652
+ <span class="cpk-td__metadata-pill" title=${(_pill$value = pill.value) !== null && _pill$value !== void 0 ? _pill$value : ""}>
1653
+ <span class="cpk-td__metadata-label">${pill.label}</span>
1654
+ <span class="cpk-td__metadata-value"
1655
+ >${this.shortId(pill.value)}</span
1656
+ >
1657
+ </span>
1658
+ `;
1617
1659
  })}
1660
+ </div>
1661
+ ${bulkControls}
1618
1662
  </div>
1619
1663
  `;
1664
+ }
1665
+ renderActiveBulkControls() {
1666
+ if (this._eventsNotAvailable) return lit.nothing;
1667
+ if (this._tab === "raw-events") return this.renderRawEventBulkControls();
1668
+ if (this._tab !== "timeline") return lit.nothing;
1669
+ const detailIds = this.timelineItemsForEvents(this.activeEvents).filter((item) => item.details).map((item) => item.id);
1670
+ if (detailIds.length <= 1) return lit.nothing;
1671
+ return lit.html`<div class="cpk-td__timeline-toolbar">
1672
+ <button
1673
+ type="button"
1674
+ class="cpk-td__timeline-bulk-toggle"
1675
+ ?disabled=${detailIds.every((id) => this._expandedTimelineDetails.has(id))}
1676
+ @click=${() => this.expandTimelineDetails(detailIds)}
1677
+ >
1678
+ Expand all
1679
+ </button>
1680
+ <button
1681
+ type="button"
1682
+ class="cpk-td__timeline-bulk-toggle"
1683
+ ?disabled=${detailIds.every((id) => !this._expandedTimelineDetails.has(id))}
1684
+ @click=${() => this.collapseTimelineDetails(detailIds)}
1685
+ >
1686
+ Collapse all
1687
+ </button>
1688
+ </div>`;
1689
+ }
1690
+ renderRawEventBulkControls() {
1691
+ const eventIds = this.activeEvents.map((event) => this.rawEventId(event));
1692
+ if (eventIds.length <= 1) return lit.nothing;
1693
+ return lit.html`<div class="cpk-td__timeline-toolbar">
1694
+ <button
1695
+ type="button"
1696
+ class="cpk-td__timeline-bulk-toggle"
1697
+ ?disabled=${eventIds.every((id) => this._expandedRawEvents.has(id))}
1698
+ @click=${() => this.expandRawEventDetails(eventIds)}
1699
+ >
1700
+ Expand all
1701
+ </button>
1702
+ <button
1703
+ type="button"
1704
+ class="cpk-td__timeline-bulk-toggle"
1705
+ ?disabled=${eventIds.every((id) => !this._expandedRawEvents.has(id))}
1706
+ @click=${() => this.collapseRawEventDetails(eventIds)}
1707
+ >
1708
+ Collapse all
1709
+ </button>
1710
+ </div>`;
1620
1711
  }
1621
1712
  revealSourceEvent(sourceIndex) {
1622
1713
  this._activatedTabs = new Set([...this._activatedTabs, "raw-events"]);
@@ -1649,7 +1740,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1649
1740
  `;
1650
1741
  }
1651
1742
  const events = this.activeEvents;
1652
- const cachedTimeline = this.getCachedPanelTpl("timeline", [events]);
1743
+ const cachedTimeline = this.getCachedPanelTpl("timeline", [events, this._expandedTimelineDetails]);
1653
1744
  if (cachedTimeline) return cachedTimeline;
1654
1745
  const timelineItems = this.timelineItemsForEvents(events);
1655
1746
  if (timelineItems.length === 0) {
@@ -1665,14 +1756,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1665
1756
  </div>
1666
1757
  `;
1667
1758
  }
1668
- return this.cachedPanelTpl("timeline", [events], () => {
1669
- return lit.html`${timelineItems.map((item) => this.renderTimelineItem(item))}`;
1670
- });
1759
+ return this.cachedPanelTpl("timeline", [events, this._expandedTimelineDetails], () => lit.html`${timelineItems.map((item) => this.renderTimelineItem(item))}`);
1671
1760
  }
1672
1761
  renderTimelineItem(item) {
1762
+ const isWarning = item.kind === "warning";
1763
+ const detailsExpanded = this._expandedTimelineDetails.has(item.id);
1673
1764
  return lit.html`
1674
1765
  <div
1675
- class="cpk-td__timeline-item ${item.kind === "warning" ? "cpk-td__timeline-item--warning" : ""}"
1766
+ class="cpk-td__timeline-item ${isWarning ? "cpk-td__timeline-item--warning" : ""}"
1676
1767
  >
1677
1768
  <div class="cpk-td__timeline-header">
1678
1769
  <span class="cpk-td__timeline-kind"
@@ -1690,9 +1781,39 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1690
1781
  >${formatTimestamp(item.timestamp)}</span
1691
1782
  >
1692
1783
  </div>
1693
- ${item.body ? lit.html`<div class="cpk-td__timeline-body">${item.body}</div>` : item.details ? lit.html`<pre class="cpk-td__timeline-body">
1694
- ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.details))}</pre
1695
- >` : lit.nothing}
1784
+ ${item.details ? lit.html`<button
1785
+ type="button"
1786
+ class="cpk-td__timeline-details-toggle"
1787
+ aria-expanded=${detailsExpanded ? "true" : "false"}
1788
+ @click=${() => this.toggleTimelineDetails(item.id)}
1789
+ >
1790
+ ${detailsExpanded ? lit.html`
1791
+ <svg
1792
+ aria-hidden="true"
1793
+ viewBox="0 0 24 24"
1794
+ fill="none"
1795
+ stroke="currentColor"
1796
+ stroke-linecap="round"
1797
+ stroke-linejoin="round"
1798
+ >
1799
+ <path d="m6 9 6 6 6-6" />
1800
+ </svg>
1801
+ ` : lit.html`
1802
+ <svg
1803
+ aria-hidden="true"
1804
+ viewBox="0 0 24 24"
1805
+ fill="none"
1806
+ stroke="currentColor"
1807
+ stroke-linecap="round"
1808
+ stroke-linejoin="round"
1809
+ >
1810
+ <path d="m9 18 6-6-6-6" />
1811
+ </svg>
1812
+ `}
1813
+ <span>${detailsExpanded ? "Hide details" : "Show details"}</span>
1814
+ </button>` : lit.nothing}
1815
+ ${item.body ? lit.html`<div class="cpk-td__timeline-body">${item.body}</div>` : lit.nothing}
1816
+ ${item.details && detailsExpanded ? lit.html`<pre class="cpk-td__timeline-body">${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.details))}</pre>` : lit.nothing}
1696
1817
  </div>
1697
1818
  `;
1698
1819
  }
@@ -1949,10 +2070,12 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
1949
2070
  >
1950
2071
  </div>
1951
2072
  `;
1952
- return this.cachedPanelTpl("raw-events", [events], () => {
2073
+ return this.cachedPanelTpl("raw-events", [events, this._expandedRawEvents], () => {
1953
2074
  return lit.html`${events.map((event) => {
1954
2075
  var _event$rawEvent;
1955
2076
  const { bg, fg } = eventColors(event.type);
2077
+ const eventId = this.rawEventId(event);
2078
+ const detailsExpanded = this._expandedRawEvents.has(eventId);
1956
2079
  return lit.html`
1957
2080
  <div class="cpk-td__event" data-source-index=${event.sourceIndex}>
1958
2081
  <div class="cpk-td__event-header" style="background:${bg}">
@@ -1963,9 +2086,38 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
1963
2086
  >${formatTimestamp(event.timestamp)}</span
1964
2087
  >
1965
2088
  </div>
1966
- <pre class="cpk-td__event-payload">
1967
- ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent = event.rawEvent) !== null && _event$rawEvent !== void 0 ? _event$rawEvent : event))}</pre
2089
+ <button
2090
+ type="button"
2091
+ class="cpk-td__timeline-details-toggle"
2092
+ aria-expanded=${detailsExpanded ? "true" : "false"}
2093
+ @click=${() => this.toggleRawEventDetails(eventId)}
1968
2094
  >
2095
+ ${detailsExpanded ? lit.html`
2096
+ <svg
2097
+ aria-hidden="true"
2098
+ viewBox="0 0 24 24"
2099
+ fill="none"
2100
+ stroke="currentColor"
2101
+ stroke-linecap="round"
2102
+ stroke-linejoin="round"
2103
+ >
2104
+ <path d="m6 9 6 6 6-6" />
2105
+ </svg>
2106
+ ` : lit.html`
2107
+ <svg
2108
+ aria-hidden="true"
2109
+ viewBox="0 0 24 24"
2110
+ fill="none"
2111
+ stroke="currentColor"
2112
+ stroke-linecap="round"
2113
+ stroke-linejoin="round"
2114
+ >
2115
+ <path d="m9 18 6-6-6-6" />
2116
+ </svg>
2117
+ `}
2118
+ <span>${detailsExpanded ? "Hide details" : "Show details"}</span>
2119
+ </button>
2120
+ ${detailsExpanded ? lit.html`<pre class="cpk-td__event-payload">${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent = event.rawEvent) !== null && _event$rawEvent !== void 0 ? _event$rawEvent : event))}</pre>` : lit.nothing}
1969
2121
  </div>
1970
2122
  `;
1971
2123
  })}`;
@@ -2098,6 +2250,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2098
2250
  _stateError: { state: true },
2099
2251
  _expandedTools: { state: true },
2100
2252
  _expandedMessages: { state: true },
2253
+ _expandedTimelineDetails: { state: true },
2254
+ _expandedRawEvents: { state: true },
2101
2255
  _showDetailPanel: { state: true },
2102
2256
  _detailPanelWidth: { state: true },
2103
2257
  _eventsNotAvailable: { state: true },
@@ -2250,6 +2404,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2250
2404
 
2251
2405
  .cpk-td__metadata-strip {
2252
2406
  display: flex;
2407
+ align-items: center;
2253
2408
  gap: 6px;
2254
2409
  flex-wrap: wrap;
2255
2410
  padding: 10px 16px;
@@ -2258,6 +2413,14 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2258
2413
  flex-shrink: 0;
2259
2414
  }
2260
2415
 
2416
+ .cpk-td__metadata-pills {
2417
+ display: flex;
2418
+ gap: 6px;
2419
+ flex: 1;
2420
+ flex-wrap: wrap;
2421
+ min-width: 0;
2422
+ }
2423
+
2261
2424
  .cpk-td__metadata-pill {
2262
2425
  display: inline-flex;
2263
2426
  align-items: center;
@@ -2552,13 +2715,44 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2552
2715
  }
2553
2716
 
2554
2717
  .cpk-td__timeline-body {
2555
- padding: 9px 10px;
2718
+ margin: 0;
2719
+ padding: 0 10px 9px;
2556
2720
  font-size: 12px;
2557
2721
  line-height: 1.55;
2558
2722
  color: #57575b;
2559
2723
  white-space: pre-wrap;
2560
2724
  word-break: break-word;
2561
- border-top: 1px solid #e9e9ef;
2725
+ }
2726
+
2727
+ .cpk-td__timeline-toolbar {
2728
+ display: flex;
2729
+ gap: 6px;
2730
+ margin-left: auto;
2731
+ }
2732
+
2733
+ .cpk-td__timeline-bulk-toggle {
2734
+ margin: 0;
2735
+ padding: 4px 8px;
2736
+ border: 1px solid #dcdce8;
2737
+ border-radius: 6px;
2738
+ background: #ffffff;
2739
+ color: #36363a;
2740
+ cursor: pointer;
2741
+ font-family: "Inter", sans-serif;
2742
+ font-size: 11px;
2743
+ font-weight: 600;
2744
+ line-height: 1.2;
2745
+ }
2746
+
2747
+ .cpk-td__timeline-bulk-toggle:hover {
2748
+ border-color: rgba(85, 88, 178, 0.38);
2749
+ background: #f7f7ff;
2750
+ color: #010507;
2751
+ }
2752
+
2753
+ .cpk-td__timeline-bulk-toggle:disabled {
2754
+ cursor: not-allowed;
2755
+ opacity: 0.45;
2562
2756
  }
2563
2757
 
2564
2758
  .cpk-td__source-link {
@@ -2579,6 +2773,34 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2579
2773
  color: #010507;
2580
2774
  }
2581
2775
 
2776
+ .cpk-td__timeline-details-toggle {
2777
+ margin: 0;
2778
+ padding: 5px 10px;
2779
+ border: none;
2780
+ background: #ffffff;
2781
+ color: #5558b2;
2782
+ cursor: pointer;
2783
+ display: inline-flex;
2784
+ align-items: center;
2785
+ gap: 5px;
2786
+ font-family: "Inter", sans-serif;
2787
+ font-size: 12px;
2788
+ font-weight: 600;
2789
+ line-height: 1.2;
2790
+ width: 100%;
2791
+ }
2792
+
2793
+ .cpk-td__timeline-details-toggle:hover {
2794
+ background: #f7f7ff;
2795
+ color: #010507;
2796
+ }
2797
+
2798
+ .cpk-td__timeline-details-toggle svg {
2799
+ width: 12px;
2800
+ height: 12px;
2801
+ stroke-width: 2;
2802
+ }
2803
+
2582
2804
  /* ── Generative UI ──────────────────────────────────────────────── */
2583
2805
  @keyframes cpk-genui-enter {
2584
2806
  from {
@@ -2785,17 +3007,362 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
2785
3007
  word-break: break-all;
2786
3008
  text-align: right;
2787
3009
  }
3010
+ `;
3011
+ var CpkMemoryList = class extends lit.LitElement {
3012
+ constructor(..._args3) {
3013
+ super(..._args3);
3014
+ this.memories = [];
3015
+ this.search = "";
3016
+ this.kind = "all";
3017
+ this.onSearchInput = (event) => {
3018
+ this.search = event.target.value;
3019
+ };
3020
+ this.onKindClick = (event) => {
3021
+ const seg = event.target.closest("[data-kind]");
3022
+ if (!seg) return;
3023
+ this.kind = seg.dataset["kind"];
3024
+ };
3025
+ }
3026
+ /** Memories that pass the current text search (before kind filter). */
3027
+ get searchFiltered() {
3028
+ const q = this.search.trim().toLowerCase();
3029
+ if (!q) return this.memories;
3030
+ return this.memories.filter((m) => m.content.toLowerCase().includes(q));
3031
+ }
3032
+ /** Memories that pass both search and kind filter. */
3033
+ get filtered() {
3034
+ const searched = this.searchFiltered;
3035
+ if (this.kind === "all") return searched;
3036
+ return searched.filter((m) => m.kind === this.kind);
3037
+ }
3038
+ /** Count of search-filtered memories for a given kind (for segment labels). */
3039
+ countForKind(kind) {
3040
+ return this.searchFiltered.filter((m) => m.kind === kind).length;
3041
+ }
3042
+ /** Truncate an id to first-4…last-4 characters. */
3043
+ shortId(id) {
3044
+ if (id.length <= 12) return id;
3045
+ return `${id.slice(0, 4)}…${id.slice(-4)}`;
3046
+ }
3047
+ renderKindBadge(kind) {
3048
+ return lit.html`<span class="cpk-ml__kind-badge cpk-ml__kind-badge--${kind}"
3049
+ >${kind}</span
3050
+ >`;
3051
+ }
3052
+ renderEmpty() {
3053
+ const q = this.search.trim();
3054
+ if (this.memories.length === 0) return lit.html`
3055
+ <div class="cpk-ml__empty">
3056
+ <svg
3057
+ width="24"
3058
+ height="24"
3059
+ viewBox="0 0 24 24"
3060
+ fill="none"
3061
+ stroke="currentColor"
3062
+ stroke-width="1.5"
3063
+ stroke-linecap="round"
3064
+ stroke-linejoin="round"
3065
+ class="cpk-ml__empty-icon"
3066
+ >
3067
+ <ellipse cx="12" cy="5" rx="9" ry="3" />
3068
+ <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" />
3069
+ <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" />
3070
+ </svg>
3071
+ No memories yet — tell the agent a durable fact and watch it appear.
3072
+ </div>
3073
+ `;
3074
+ if (q) return lit.html`
3075
+ <div class="cpk-ml__empty">
3076
+ No memories match &ldquo;${q}&rdquo;.
3077
+ </div>
3078
+ `;
3079
+ return lit.html`
3080
+ <div class="cpk-ml__empty">No ${this.kind} memories yet.</div>
3081
+ `;
3082
+ }
3083
+ render() {
3084
+ const filtered = this.filtered;
3085
+ return lit.html`
3086
+ <div class="cpk-ml">
3087
+ <!-- Search -->
3088
+ <div class="cpk-ml__search">
3089
+ <input
3090
+ type="text"
3091
+ placeholder="Search memories…"
3092
+ .value=${this.search}
3093
+ @input=${this.onSearchInput}
3094
+ class="cpk-ml__search-input"
3095
+ />
3096
+ </div>
3097
+
3098
+ <!-- Kind filter -->
3099
+ <div class="cpk-ml__filter" @click=${this.onKindClick}>
3100
+ <button
3101
+ class="cpk-ml__filter-seg ${this.kind === "all" ? "cpk-ml__filter-seg--active" : ""}"
3102
+ data-kind="all"
3103
+ >
3104
+ All<span class="cpk-ml__filter-count">${this.searchFiltered.length}</span>
3105
+ </button>
3106
+ ${[
3107
+ "topical",
3108
+ "episodic",
3109
+ "operational"
3110
+ ].map((k) => lit.html`
3111
+ <button
3112
+ class="cpk-ml__filter-seg ${this.kind === k ? "cpk-ml__filter-seg--active" : ""}"
3113
+ data-kind="${k}"
3114
+ >
3115
+ ${k}<span class="cpk-ml__filter-count">${this.countForKind(k)}</span>
3116
+ </button>
3117
+ `)}
3118
+ </div>
3119
+
3120
+ <!-- Memory list -->
3121
+ <div class="cpk-ml__list">
3122
+ ${filtered.map((m) => lit.html`
3123
+ <div class="cpk-ml__card">
3124
+ <div class="cpk-ml__card-badges">
3125
+ ${this.renderKindBadge(m.kind)}
3126
+ <span class="cpk-ml__scope-badge">${m.scope}</span>
3127
+ </div>
3128
+ <div class="cpk-ml__content">${m.content}</div>
3129
+ <div class="cpk-ml__footer">
3130
+ <span class="cpk-ml__footer-threads"
3131
+ >${m.sourceThreadIds.length} source thread${m.sourceThreadIds.length === 1 ? "" : "s"}</span
3132
+ >
3133
+ <span class="cpk-ml__footer-id">${this.shortId(m.id)}</span>
3134
+ </div>
3135
+ </div>
3136
+ `)}
3137
+ ${filtered.length === 0 ? this.renderEmpty() : lit.nothing}
3138
+ </div>
3139
+ </div>
3140
+ `;
3141
+ }
3142
+ };
3143
+ CpkMemoryList.properties = {
3144
+ memories: { attribute: false },
3145
+ search: { state: true },
3146
+ kind: { state: true }
3147
+ };
3148
+ CpkMemoryList.styles = lit.css`
3149
+ @import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&family=Spline+Sans+Mono:wght@400;500&display=swap");
3150
+
3151
+ :host {
3152
+ display: flex;
3153
+ flex-direction: column;
3154
+ height: 100%;
3155
+ overflow: hidden;
3156
+ }
3157
+
3158
+ .cpk-ml {
3159
+ font-family: "Plus Jakarta Sans", sans-serif;
3160
+ display: flex;
3161
+ flex-direction: column;
3162
+ height: 100%;
3163
+ overflow: hidden;
3164
+ background: #f7f7f9;
3165
+ }
3166
+
3167
+ /* ── Search ── */
3168
+ .cpk-ml__search {
3169
+ padding: 10px 12px;
3170
+ border-bottom: 1px solid #dbdbe5;
3171
+ flex-shrink: 0;
3172
+ }
3173
+
3174
+ .cpk-ml__search-input {
3175
+ width: 100%;
3176
+ box-sizing: border-box;
3177
+ font-family: "Plus Jakarta Sans", sans-serif;
3178
+ font-size: 12px;
3179
+ padding: 7px 10px;
3180
+ border-radius: 6px;
3181
+ border: 1px solid #dbdbe5;
3182
+ background: #ffffff;
3183
+ color: #010507;
3184
+ outline: none;
3185
+ transition: border-color 0.15s;
3186
+ }
3187
+
3188
+ .cpk-ml__search-input:focus {
3189
+ border-color: #bec2ff;
3190
+ }
3191
+
3192
+ /* ── Kind filter ── */
3193
+ .cpk-ml__filter {
3194
+ display: flex;
3195
+ gap: 4px;
3196
+ padding: 8px 12px;
3197
+ border-bottom: 1px solid #dbdbe5;
3198
+ flex-shrink: 0;
3199
+ flex-wrap: wrap;
3200
+ }
3201
+
3202
+ .cpk-ml__filter-seg {
3203
+ font-family: "Plus Jakarta Sans", sans-serif;
3204
+ font-size: 11px;
3205
+ font-weight: 500;
3206
+ padding: 3px 9px;
3207
+ border-radius: 5px;
3208
+ border: 1px solid #dbdbe5;
3209
+ background: #ffffff;
3210
+ color: #57575b;
3211
+ cursor: pointer;
3212
+ transition:
3213
+ background 0.1s,
3214
+ border-color 0.1s,
3215
+ color 0.1s;
3216
+ user-select: none;
3217
+ }
3218
+
3219
+ .cpk-ml__filter-seg:hover {
3220
+ background: #f0f0f5;
3221
+ }
3222
+
3223
+ .cpk-ml__filter-seg--active {
3224
+ background: #bec2ff1a;
3225
+ border-color: #bec2ff;
3226
+ color: #010507;
3227
+ }
3228
+
3229
+ .cpk-ml__filter-count {
3230
+ font-family: "Spline Sans Mono", monospace;
3231
+ font-size: 9px;
3232
+ margin-left: 4px;
3233
+ color: #838389;
3234
+ }
3235
+
3236
+ /* ── List ── */
3237
+ .cpk-ml__list {
3238
+ flex: 1;
3239
+ overflow-y: auto;
3240
+ padding: 8px 12px;
3241
+ display: flex;
3242
+ flex-direction: column;
3243
+ gap: 8px;
3244
+ }
3245
+
3246
+ /* ── Card ── */
3247
+ .cpk-ml__card {
3248
+ background: #ffffff;
3249
+ border: 1px solid #e9e9ef;
3250
+ border-radius: 8px;
3251
+ padding: 10px 12px;
3252
+ display: flex;
3253
+ flex-direction: column;
3254
+ gap: 6px;
3255
+ }
3256
+
3257
+ .cpk-ml__card-badges {
3258
+ display: flex;
3259
+ gap: 6px;
3260
+ align-items: center;
3261
+ flex-wrap: wrap;
3262
+ }
3263
+
3264
+ /* Kind badge — color per kind */
3265
+ .cpk-ml__kind-badge {
3266
+ font-family: "Spline Sans Mono", monospace;
3267
+ font-size: 9px;
3268
+ padding: 1px 7px;
3269
+ border-radius: 4px;
3270
+ text-transform: uppercase;
3271
+ font-weight: 500;
3272
+ white-space: nowrap;
3273
+ }
3274
+
3275
+ .cpk-ml__kind-badge--topical {
3276
+ background: #eee6fe;
3277
+ color: #57575b;
3278
+ }
3279
+
3280
+ .cpk-ml__kind-badge--episodic {
3281
+ background: #e6f4fe;
3282
+ color: #2d5f80;
3283
+ }
3284
+
3285
+ .cpk-ml__kind-badge--operational {
3286
+ background: #e6feee;
3287
+ color: #2d6645;
3288
+ }
3289
+
3290
+ /* Scope badge */
3291
+ .cpk-ml__scope-badge {
3292
+ font-family: "Spline Sans Mono", monospace;
3293
+ font-size: 9px;
3294
+ padding: 1px 7px;
3295
+ border-radius: 4px;
3296
+ text-transform: uppercase;
3297
+ font-weight: 500;
3298
+ white-space: nowrap;
3299
+ background: #f0f0f5;
3300
+ color: #838389;
3301
+ }
3302
+
3303
+ /* Content */
3304
+ .cpk-ml__content {
3305
+ font-size: 12px;
3306
+ color: #010507;
3307
+ line-height: 1.5;
3308
+ word-break: break-word;
3309
+ }
3310
+
3311
+ /* Footer */
3312
+ .cpk-ml__footer {
3313
+ display: flex;
3314
+ align-items: center;
3315
+ justify-content: space-between;
3316
+ gap: 8px;
3317
+ margin-top: 2px;
3318
+ }
3319
+
3320
+ .cpk-ml__footer-threads {
3321
+ font-size: 10px;
3322
+ color: #838389;
3323
+ }
3324
+
3325
+ .cpk-ml__footer-id {
3326
+ font-family: "Spline Sans Mono", monospace;
3327
+ font-size: 9px;
3328
+ color: #c0c0c8;
3329
+ }
3330
+
3331
+ /* ── Empty state ── */
3332
+ .cpk-ml__empty {
3333
+ padding: 32px 16px;
3334
+ text-align: center;
3335
+ color: #838389;
3336
+ font-size: 12px;
3337
+ display: flex;
3338
+ flex-direction: column;
3339
+ align-items: center;
3340
+ gap: 8px;
3341
+ }
3342
+
3343
+ .cpk-ml__empty-icon {
3344
+ color: #c0c0c8;
3345
+ }
2788
3346
  `;
2789
3347
  var ɵCpkThreadDetails = class extends CpkThreadInspector {};
2790
3348
  if (!customElements.get("cpk-thread-list")) customElements.define("cpk-thread-list", CpkThreadList);
2791
3349
  if (!customElements.get(THREAD_INSPECTOR_TAG)) customElements.define(THREAD_INSPECTOR_TAG, CpkThreadInspector);
2792
3350
  if (!customElements.get("cpk-thread-details")) customElements.define("cpk-thread-details", ɵCpkThreadDetails);
3351
+ if (!customElements.get("cpk-memory-list")) customElements.define("cpk-memory-list", CpkMemoryList);
2793
3352
  var WebInspectorElement = class extends lit.LitElement {
2794
- constructor(..._args3) {
2795
- super(..._args3);
3353
+ constructor(..._args4) {
3354
+ super(..._args4);
2796
3355
  this._core = null;
2797
3356
  this.coreSubscriber = null;
2798
3357
  this.coreUnsubscribe = null;
3358
+ this._memories = [];
3359
+ this._memoriesLoading = false;
3360
+ this._memoriesError = null;
3361
+ this._memoriesAvailable = true;
3362
+ this._memoriesRealtimeStatus = "connecting";
3363
+ this._memoryUnsub = null;
3364
+ this._memorySubscribed = false;
3365
+ this._memoryStoreUnsupported = false;
2799
3366
  this.runtimeStatus = null;
2800
3367
  this.coreProperties = {};
2801
3368
  this.lastCoreError = null;
@@ -3213,6 +3780,11 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3213
3780
  key: "threads",
3214
3781
  label: "Threads",
3215
3782
  icon: "MessageSquare"
3783
+ },
3784
+ {
3785
+ key: "memories",
3786
+ label: "Learning",
3787
+ icon: "Brain"
3216
3788
  }
3217
3789
  ];
3218
3790
  }
@@ -3240,6 +3812,15 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3240
3812
  ...extra
3241
3813
  };
3242
3814
  }
3815
+ getMemoriesTelemetryProps() {
3816
+ var _this$core9;
3817
+ const distinctId = !((_this$core9 = this.core) === null || _this$core9 === void 0 ? void 0 : _this$core9.telemetryDisabled) ? getTelemetryDistinctIdForUrl() : null;
3818
+ return {
3819
+ posthog_distinct_id: distinctId !== null && distinctId !== void 0 ? distinctId : void 0,
3820
+ memory_count: this._memories.length,
3821
+ available: this._memoriesAvailable
3822
+ };
3823
+ }
3243
3824
  getIntelligenceSignupUrl() {
3244
3825
  return this.appendRefParam(INTELLIGENCE_SIGNUP_URL, "cpk-inspector");
3245
3826
  }
@@ -3284,9 +3865,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3284
3865
  this._threads = [];
3285
3866
  }
3286
3867
  ensureOwnedThreadStore(agentId) {
3287
- var _this$core9, _core$intelligence;
3868
+ var _this$core10, _core$intelligence;
3288
3869
  if (this._ownedThreadStores.has(agentId)) return;
3289
- if ((_this$core9 = this.core) === null || _this$core9 === void 0 ? void 0 : _this$core9.getThreadStore(agentId)) return;
3870
+ if ((_this$core10 = this.core) === null || _this$core10 === void 0 ? void 0 : _this$core10.getThreadStore(agentId)) return;
3290
3871
  const core = this.core;
3291
3872
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
3292
3873
  if (!this.areThreadEndpointsAvailable()) return;
@@ -3321,18 +3902,18 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3321
3902
  }
3322
3903
  }
3323
3904
  removeOwnedThreadStore(agentId) {
3324
- var _this$core10;
3905
+ var _this$core11;
3325
3906
  const store = this._ownedThreadStores.get(agentId);
3326
3907
  if (!store) return;
3327
3908
  store.stop();
3328
- (_this$core10 = this.core) === null || _this$core10 === void 0 || _this$core10.unregisterThreadStore(agentId);
3909
+ (_this$core11 = this.core) === null || _this$core11 === void 0 || _this$core11.unregisterThreadStore(agentId);
3329
3910
  this._ownedThreadStores.delete(agentId);
3330
3911
  }
3331
3912
  teardownOwnedThreadStores() {
3332
3913
  for (const [agentId, store] of this._ownedThreadStores) {
3333
- var _this$core11;
3914
+ var _this$core12;
3334
3915
  store.stop();
3335
- (_this$core11 = this.core) === null || _this$core11 === void 0 || _this$core11.unregisterThreadStore(agentId);
3916
+ (_this$core12 = this.core) === null || _this$core12 === void 0 || _this$core12.unregisterThreadStore(agentId);
3336
3917
  }
3337
3918
  this._ownedThreadStores.clear();
3338
3919
  }
@@ -3410,12 +3991,76 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3410
3991
  const threadStores = typeof core.getThreadStores === "function" ? core.getThreadStores() : {};
3411
3992
  for (const [agentId, store] of Object.entries(threadStores)) this.subscribeToThreadStore(agentId, store);
3412
3993
  if (core.context) this.contextStore = this.normalizeContextStore(core.context);
3994
+ if (this.selectedMenu === "memories") this.ensureMemorySubscription();
3995
+ }
3996
+ /**
3997
+ * Lazily subscribes to the singleton memory store the first time the user
3998
+ * activates the Memories tab. This is deferred out of `attachToCore` because
3999
+ * `core.getMemoryStore()` is what creates + starts the store and opens
4000
+ * realtime — doing it on attach would start memory for apps that never use
4001
+ * it. Idempotent: repeated tab activations are guarded by
4002
+ * `_memorySubscribed`. On an older @copilotkit/core without `getMemoryStore`,
4003
+ * records the unsupported state so the teaser can guide an SDK upgrade.
4004
+ */
4005
+ ensureMemorySubscription() {
4006
+ if (this._memorySubscribed) return;
4007
+ const core = this._core;
4008
+ if (!core) return;
4009
+ if (typeof core.getMemoryStore !== "function") {
4010
+ this._memoryStoreUnsupported = true;
4011
+ this._memoriesAvailable = false;
4012
+ this.requestUpdate();
4013
+ return;
4014
+ }
4015
+ this._memorySubscribed = true;
4016
+ this._memoryStoreUnsupported = false;
4017
+ const memoryStore = core.getMemoryStore();
4018
+ const ms = memoryStore.getState();
4019
+ this._memories = (0, _copilotkit_core.ɵselectMemories)(ms);
4020
+ this._memoriesLoading = (0, _copilotkit_core.ɵselectMemoriesIsLoading)(ms);
4021
+ this._memoriesError = (0, _copilotkit_core.ɵselectMemoriesError)(ms);
4022
+ this._memoriesAvailable = (0, _copilotkit_core.ɵselectMemoriesAvailable)(ms);
4023
+ this._memoriesRealtimeStatus = (0, _copilotkit_core.ɵselectMemoriesRealtimeStatus)(ms);
4024
+ const memSubs = [
4025
+ memoryStore.select(_copilotkit_core.ɵselectMemories).subscribe((v) => {
4026
+ this._memories = v;
4027
+ this.requestUpdate();
4028
+ }),
4029
+ memoryStore.select(_copilotkit_core.ɵselectMemoriesIsLoading).subscribe((v) => {
4030
+ this._memoriesLoading = v;
4031
+ this.requestUpdate();
4032
+ }),
4033
+ memoryStore.select(_copilotkit_core.ɵselectMemoriesError).subscribe((v) => {
4034
+ this._memoriesError = v;
4035
+ this.requestUpdate();
4036
+ }),
4037
+ memoryStore.select(_copilotkit_core.ɵselectMemoriesAvailable).subscribe((v) => {
4038
+ this._memoriesAvailable = v;
4039
+ this.requestUpdate();
4040
+ }),
4041
+ memoryStore.select(_copilotkit_core.ɵselectMemoriesRealtimeStatus).subscribe((v) => {
4042
+ this._memoriesRealtimeStatus = v;
4043
+ this.requestUpdate();
4044
+ })
4045
+ ];
4046
+ this._memoryUnsub = () => memSubs.forEach((s) => s.unsubscribe());
4047
+ this.requestUpdate();
3413
4048
  }
3414
4049
  detachFromCore() {
4050
+ var _this$_memoryUnsub;
3415
4051
  if (this.coreUnsubscribe) {
3416
4052
  this.coreUnsubscribe();
3417
4053
  this.coreUnsubscribe = null;
3418
4054
  }
4055
+ (_this$_memoryUnsub = this._memoryUnsub) === null || _this$_memoryUnsub === void 0 || _this$_memoryUnsub.call(this);
4056
+ this._memoryUnsub = null;
4057
+ this._memories = [];
4058
+ this._memoriesLoading = false;
4059
+ this._memoriesError = null;
4060
+ this._memoriesAvailable = true;
4061
+ this._memoriesRealtimeStatus = "connecting";
4062
+ this._memorySubscribed = false;
4063
+ this._memoryStoreUnsupported = false;
3419
4064
  this.coreSubscriber = null;
3420
4065
  this.runtimeStatus = null;
3421
4066
  this.lastCoreError = null;
@@ -3765,8 +4410,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent
3765
4410
  return lit.html`
3766
4411
  <div class="mt-2 space-y-2">
3767
4412
  ${toolCalls.map((call, index) => {
3768
- var _ref4, _call$function$name, _call$function, _call$function2;
3769
- const functionName = (_ref4 = (_call$function$name = (_call$function = call.function) === null || _call$function === void 0 ? void 0 : _call$function.name) !== null && _call$function$name !== void 0 ? _call$function$name : call.toolName) !== null && _ref4 !== void 0 ? _ref4 : "Unknown function";
4413
+ var _ref5, _call$function$name, _call$function, _call$function2;
4414
+ const functionName = (_ref5 = (_call$function$name = (_call$function = call.function) === null || _call$function === void 0 ? void 0 : _call$function.name) !== null && _call$function$name !== void 0 ? _call$function$name : call.toolName) !== null && _ref5 !== void 0 ? _ref5 : "Unknown function";
3770
4415
  const callId = typeof (call === null || call === void 0 ? void 0 : call.id) === "string" ? call.id : `tool-call-${index + 1}`;
3771
4416
  const argsString = this.formatToolCallArguments((_call$function2 = call.function) === null || _call$function2 === void 0 ? void 0 : _call$function2.arguments);
3772
4417
  return lit.html`
@@ -3930,6 +4575,7 @@ ${argsString}</pre
3930
4575
  y: EDGE_MARGIN
3931
4576
  };
3932
4577
  this.hydrateStateFromStorage();
4578
+ if (this.selectedMenu === "memories") this.ensureMemorySubscription();
3933
4579
  if (this.isOpen && this.dockMode !== "floating") this.applyDockStyles(true);
3934
4580
  this.applyAnchorPosition("button");
3935
4581
  if (this.dockMode === "floating") if (this.hasCustomPosition.window) this.applyAnchorPosition("window");
@@ -4628,12 +5274,13 @@ ${argsString}</pre
4628
5274
  if (this.selectedMenu === "frontend-tools") return this.renderToolsView();
4629
5275
  if (this.selectedMenu === "agent-context") return this.renderContextView();
4630
5276
  if (this.selectedMenu === "threads") return this.renderThreadsView();
5277
+ if (this.selectedMenu === "memories") return this.renderMemoriesView();
4631
5278
  if (this.selectedMenu === "settings") return this.renderSettingsPanel();
4632
5279
  return lit.nothing;
4633
5280
  }
4634
5281
  renderSettingsPanel() {
4635
- var _this$core$telemetryD2, _this$core12;
4636
- const optedOut = (_this$core$telemetryD2 = (_this$core12 = this.core) === null || _this$core12 === void 0 ? void 0 : _this$core12.telemetryDisabled) !== null && _this$core$telemetryD2 !== void 0 ? _this$core$telemetryD2 : false;
5282
+ var _this$core$telemetryD2, _this$core13;
5283
+ const optedOut = (_this$core$telemetryD2 = (_this$core13 = this.core) === null || _this$core13 === void 0 ? void 0 : _this$core13.telemetryDisabled) !== null && _this$core$telemetryD2 !== void 0 ? _this$core$telemetryD2 : false;
4637
5284
  return lit.html`
4638
5285
  <div class="flex h-full flex-col overflow-hidden">
4639
5286
  <div class="overflow-auto p-4">
@@ -4666,8 +5313,8 @@ ${argsString}</pre
4666
5313
  `;
4667
5314
  }
4668
5315
  trackBannerClickedOnce(opts) {
4669
- var _this$core13, _this$announcementCta;
4670
- if ((_this$core13 = this.core) === null || _this$core13 === void 0 ? void 0 : _this$core13.telemetryDisabled) return;
5316
+ var _this$core14, _this$announcementCta;
5317
+ if ((_this$core14 = this.core) === null || _this$core14 === void 0 ? void 0 : _this$core14.telemetryDisabled) return;
4671
5318
  const id = this.announcementTimestamp;
4672
5319
  if (!id) return;
4673
5320
  const key = `${id}:${opts.cta}`;
@@ -4680,8 +5327,8 @@ ${argsString}</pre
4680
5327
  });
4681
5328
  }
4682
5329
  trackThreadsViewStateOnce(state, threadCount) {
4683
- var _this$core14;
4684
- if ((_this$core14 = this.core) === null || _this$core14 === void 0 ? void 0 : _this$core14.telemetryDisabled) return;
5330
+ var _this$core15;
5331
+ if ((_this$core15 = this.core) === null || _this$core15 === void 0 ? void 0 : _this$core15.telemetryDisabled) return;
4685
5332
  const key = `${state}:${this.getThreadServiceStatus()}`;
4686
5333
  if (this.viewedThreadsTelemetryStates.has(key)) return;
4687
5334
  this.viewedThreadsTelemetryStates.add(key);
@@ -4982,6 +5629,311 @@ ${argsString}</pre
4982
5629
  </div>
4983
5630
  </div>
4984
5631
  </div>
5632
+ `;
5633
+ }
5634
+ /**
5635
+ * Renders the realtime-connection indicator in the memory-store header.
5636
+ * Only `"connected"` shows the live (green-dot) state; `"connecting"` shows a
5637
+ * muted amber "reconnecting" and `"unavailable"` a muted grey "offline", so
5638
+ * the indicator never claims "live" over a frozen snapshot once the realtime
5639
+ * socket has permanently given up.
5640
+ */
5641
+ renderMemoryRealtimeIndicator() {
5642
+ const status = this._memoriesRealtimeStatus;
5643
+ const connected = status === "connected";
5644
+ return lit.html`
5645
+ <span
5646
+ style="
5647
+ display: inline-flex;
5648
+ align-items: center;
5649
+ gap: 4px;
5650
+ font-size: 10px;
5651
+ font-weight: 500;
5652
+ color: ${connected ? "#57575b" : "#838389"};
5653
+ "
5654
+ >
5655
+ <span
5656
+ style="
5657
+ display: inline-block;
5658
+ width: 6px;
5659
+ height: 6px;
5660
+ border-radius: 50%;
5661
+ background: ${connected ? "#22c55e" : status === "connecting" ? "#f59e0b" : "#9ca3af"};
5662
+ "
5663
+ ></span>
5664
+ ${status === "connected" ? "live" : status === "connecting" ? "reconnecting" : "offline"}
5665
+ </span>
5666
+ `;
5667
+ }
5668
+ renderMemoriesView() {
5669
+ var _this$core16;
5670
+ if (!((_this$core16 = this.core) === null || _this$core16 === void 0 ? void 0 : _this$core16.intelligence) || !this._memoriesAvailable) return lit.html`
5671
+ <div
5672
+ style="
5673
+ position: relative;
5674
+ height: 100%;
5675
+ display: flex;
5676
+ align-items: center;
5677
+ justify-content: center;
5678
+ padding: 32px;
5679
+ overflow: hidden;
5680
+ background: #ffffff;
5681
+ "
5682
+ >
5683
+ ${this.renderThreadsLockedBackgroundMockup()}
5684
+ <div
5685
+ aria-hidden="true"
5686
+ style="
5687
+ position: absolute;
5688
+ inset: 0;
5689
+ pointer-events: none;
5690
+ background:
5691
+ radial-gradient(circle at center, rgba(255,255,255,0.9) 0, rgba(255,255,255,0.78) 24%, rgba(255,255,255,0.34) 48%, rgba(255,255,255,0.56) 100%);
5692
+ "
5693
+ ></div>
5694
+ <div
5695
+ style="
5696
+ position: relative;
5697
+ z-index: 1;
5698
+ max-width: 440px;
5699
+ text-align: center;
5700
+ color: #57575b;
5701
+ "
5702
+ >
5703
+ <div
5704
+ aria-hidden="true"
5705
+ style="
5706
+ margin: 0 auto 18px;
5707
+ display: flex;
5708
+ justify-content: center;
5709
+ "
5710
+ >
5711
+ <div
5712
+ style="
5713
+ display: flex;
5714
+ height: 44px;
5715
+ width: 44px;
5716
+ align-items: center;
5717
+ justify-content: center;
5718
+ border: 1px solid #dfd6fb;
5719
+ border-radius: 8px;
5720
+ background: #eee6fe;
5721
+ color: #57575b;
5722
+ box-shadow: 0 8px 18px rgba(87, 87, 91, 0.14);
5723
+ "
5724
+ >
5725
+ ${this.renderIcon("Lock")}
5726
+ </div>
5727
+ </div>
5728
+ <h2
5729
+ style="
5730
+ margin: 0 0 8px;
5731
+ font-size: 16px;
5732
+ line-height: 1.35;
5733
+ font-weight: 600;
5734
+ color: #010507;
5735
+ "
5736
+ >
5737
+ Long-term memory
5738
+ </h2>
5739
+ <p
5740
+ style="
5741
+ margin: 0 auto 18px;
5742
+ max-width: 380px;
5743
+ font-size: 13px;
5744
+ line-height: 1.55;
5745
+ color: #57575b;
5746
+ "
5747
+ >
5748
+ ${this._memoryStoreUnsupported ? "Long-term memory isn't available in this version of the @copilotkit SDK. Upgrade @copilotkit/core (and @copilotkit/react) to a version that supports memory." : "Long-term memory isn't enabled on this deployment."}
5749
+ </p>
5750
+ <div
5751
+ style="
5752
+ display: flex;
5753
+ flex-wrap: wrap;
5754
+ justify-content: center;
5755
+ gap: 8px;
5756
+ "
5757
+ >
5758
+ <a
5759
+ href=${this.getTalkToEngineerUrl()}
5760
+ target="_blank"
5761
+ rel="noopener"
5762
+ style="
5763
+ display: inline-flex;
5764
+ min-height: 34px;
5765
+ align-items: center;
5766
+ justify-content: center;
5767
+ gap: 6px;
5768
+ border-radius: 6px;
5769
+ background: #010507;
5770
+ padding: 8px 12px;
5771
+ font-size: 12px;
5772
+ font-weight: 600;
5773
+ color: #ffffff;
5774
+ text-decoration: none;
5775
+ "
5776
+ @click=${this.handleThreadsTalkToEngineerClick}
5777
+ >
5778
+ Talk to an Engineer
5779
+ </a>
5780
+ <a
5781
+ href=${this.getIntelligenceSignupUrl()}
5782
+ target="_blank"
5783
+ rel="noopener"
5784
+ style="
5785
+ display: inline-flex;
5786
+ min-height: 34px;
5787
+ align-items: center;
5788
+ justify-content: center;
5789
+ gap: 6px;
5790
+ border-radius: 6px;
5791
+ border: 1px solid #dbdbe5;
5792
+ background: #ffffff;
5793
+ padding: 8px 12px;
5794
+ font-size: 12px;
5795
+ font-weight: 600;
5796
+ color: #57575b;
5797
+ text-decoration: none;
5798
+ "
5799
+ @click=${this.handleThreadsIntelligenceSignupClick}
5800
+ >
5801
+ Sign up for Intelligence
5802
+ </a>
5803
+ </div>
5804
+ </div>
5805
+ </div>
5806
+ `;
5807
+ if (this._memoriesError && this._memories.length === 0) return lit.html`
5808
+ <div
5809
+ style="
5810
+ display: flex;
5811
+ height: 100%;
5812
+ flex-direction: column;
5813
+ align-items: center;
5814
+ justify-content: center;
5815
+ gap: 8px;
5816
+ color: #838389;
5817
+ "
5818
+ >
5819
+ <svg
5820
+ width="24"
5821
+ height="24"
5822
+ viewBox="0 0 24 24"
5823
+ fill="none"
5824
+ stroke="#c0333a"
5825
+ stroke-width="1.5"
5826
+ stroke-linecap="round"
5827
+ stroke-linejoin="round"
5828
+ >
5829
+ <circle cx="12" cy="12" r="10" />
5830
+ <line x1="12" y1="8" x2="12" y2="12" />
5831
+ <line x1="12" y1="16" x2="12.01" y2="16" />
5832
+ </svg>
5833
+ <span style="font-size: 13px; color: #c0333a;">
5834
+ Failed to load memories
5835
+ </span>
5836
+ <span
5837
+ style="
5838
+ max-width: 320px;
5839
+ text-align: center;
5840
+ font-size: 11px;
5841
+ line-height: 1.5;
5842
+ color: #c0333a;
5843
+ "
5844
+ >
5845
+ ${this._memoriesError.message}
5846
+ </span>
5847
+ </div>
5848
+ `;
5849
+ if (this._memoriesLoading && this._memories.length === 0) return lit.html`
5850
+ <div
5851
+ style="
5852
+ display: flex;
5853
+ height: 100%;
5854
+ flex-direction: column;
5855
+ align-items: center;
5856
+ justify-content: center;
5857
+ gap: 8px;
5858
+ color: #838389;
5859
+ "
5860
+ >
5861
+ <svg
5862
+ width="24"
5863
+ height="24"
5864
+ viewBox="0 0 24 24"
5865
+ fill="none"
5866
+ stroke="#c0c0c8"
5867
+ stroke-width="1.5"
5868
+ stroke-linecap="round"
5869
+ stroke-linejoin="round"
5870
+ >
5871
+ <path d="M21 12a9 9 0 1 1-6.219-8.56" />
5872
+ </svg>
5873
+ <span style="font-size: 13px">Loading memories…</span>
5874
+ </div>
5875
+ `;
5876
+ return lit.html`
5877
+ <div style="display:flex;height:100%;overflow:hidden;flex-direction:column;">
5878
+ <div class="cpk-section-header" style="display:flex;align-items:center;justify-content:space-between;">
5879
+ <h4>Learning</h4>
5880
+ <div style="display:flex;align-items:center;gap:6px;">
5881
+ ${this.renderMemoryRealtimeIndicator()}
5882
+ <span
5883
+ style="
5884
+ font-size: 11px;
5885
+ font-weight: 500;
5886
+ color: #57575b;
5887
+ background: rgba(0,0,0,0.07);
5888
+ border-radius: 9999px;
5889
+ padding: 1px 7px;
5890
+ "
5891
+ >
5892
+ ${this._memories.length}
5893
+ </span>
5894
+ </div>
5895
+ </div>
5896
+ ${this._memoriesError ? lit.html`
5897
+ <div
5898
+ role="alert"
5899
+ style="
5900
+ display: flex;
5901
+ align-items: flex-start;
5902
+ gap: 8px;
5903
+ flex-shrink: 0;
5904
+ border-bottom: 1px solid #f1c7c9;
5905
+ background: #fdf3f3;
5906
+ padding: 8px 12px;
5907
+ color: #c0333a;
5908
+ font-size: 12px;
5909
+ line-height: 1.45;
5910
+ "
5911
+ >
5912
+ <svg
5913
+ width="16"
5914
+ height="16"
5915
+ viewBox="0 0 24 24"
5916
+ fill="none"
5917
+ stroke="#c0333a"
5918
+ stroke-width="1.5"
5919
+ stroke-linecap="round"
5920
+ stroke-linejoin="round"
5921
+ style="flex-shrink:0;margin-top:1px;"
5922
+ >
5923
+ <circle cx="12" cy="12" r="10" />
5924
+ <line x1="12" y1="8" x2="12" y2="12" />
5925
+ <line x1="12" y1="16" x2="12.01" y2="16" />
5926
+ </svg>
5927
+ <span>Action failed: ${this._memoriesError.message}</span>
5928
+ </div>
5929
+ ` : lit.nothing}
5930
+ <div style="flex:1;min-height:0;overflow:hidden;">
5931
+ <cpk-memory-list
5932
+ style="height:100%;"
5933
+ .memories=${this._memories}
5934
+ ></cpk-memory-list>
5935
+ </div>
5936
+ </div>
4985
5937
  `;
4986
5938
  }
4987
5939
  renderThreadsView() {
@@ -5612,10 +6564,15 @@ ${prettyEvent}</pre
5612
6564
  if (this.contextOptions.filter((opt) => opt.key !== "all-agents").length > 1) this.selectedContext = "all-agents";
5613
6565
  }
5614
6566
  if (key === "threads") {
5615
- var _this$core15;
5616
- if (previousMenu !== "threads" && !((_this$core15 = this.core) === null || _this$core15 === void 0 ? void 0 : _this$core15.telemetryDisabled)) trackThreadsTabClicked(this.getThreadsTelemetryProps());
6567
+ var _this$core17;
6568
+ if (previousMenu !== "threads" && !((_this$core17 = this.core) === null || _this$core17 === void 0 ? void 0 : _this$core17.telemetryDisabled)) trackThreadsTabClicked(this.getThreadsTelemetryProps());
5617
6569
  this.autoSelectLatestThread();
5618
6570
  }
6571
+ if (key === "memories") {
6572
+ var _this$core18;
6573
+ this.ensureMemorySubscription();
6574
+ if (previousMenu !== "memories" && !((_this$core18 = this.core) === null || _this$core18 === void 0 ? void 0 : _this$core18.telemetryDisabled)) trackMemoriesTabClicked(this.getMemoriesTelemetryProps());
6575
+ }
5619
6576
  if (key === "ag-ui-events" || key === "agents") requestAnimationFrame(() => {
5620
6577
  var _this$shadowRoot2;
5621
6578
  const scroller = (_this$shadowRoot2 = this.shadowRoot) === null || _this$shadowRoot2 === void 0 ? void 0 : _this$shadowRoot2.getElementById("cpk-main-scroll");
@@ -5918,9 +6875,9 @@ ${prettyEvent}</pre
5918
6875
  let currentSchema = schema;
5919
6876
  let def = currentSchema._def;
5920
6877
  while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
5921
- var _ref5;
6878
+ var _ref6;
5922
6879
  if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
5923
- currentSchema = (_ref5 = def.innerType) !== null && _ref5 !== void 0 ? _ref5 : currentSchema;
6880
+ currentSchema = (_ref6 = def.innerType) !== null && _ref6 !== void 0 ? _ref6 : currentSchema;
5924
6881
  if (!(currentSchema === null || currentSchema === void 0 ? void 0 : currentSchema._def)) break;
5925
6882
  def = currentSchema._def;
5926
6883
  }
@@ -6185,8 +7142,8 @@ ${prettyEvent}</pre
6185
7142
  </div>`;
6186
7143
  }
6187
7144
  flushPendingBannerViewed() {
6188
- var _this$core16;
6189
- if (!this.pendingBannerViewed || ((_this$core16 = this.core) === null || _this$core16 === void 0 ? void 0 : _this$core16.telemetryDisabled)) {
7145
+ var _this$core19;
7146
+ if (!this.pendingBannerViewed || ((_this$core19 = this.core) === null || _this$core19 === void 0 ? void 0 : _this$core19.telemetryDisabled)) {
6190
7147
  this.pendingBannerViewed = null;
6191
7148
  return;
6192
7149
  }
@@ -6294,11 +7251,11 @@ ${prettyEvent}</pre
6294
7251
  }
6295
7252
  appendRefParam(href, ref = "cpk-inspector") {
6296
7253
  try {
6297
- var _this$core17;
7254
+ var _this$core20;
6298
7255
  const isRootRelative = href.startsWith("/") && !href.startsWith("//");
6299
7256
  const url = new URL(href, typeof window !== "undefined" ? window.location.href : "https://copilotkit.ai");
6300
7257
  if (!url.searchParams.has("ref")) url.searchParams.append("ref", ref);
6301
- if (!url.searchParams.has("posthog_distinct_id") && !((_this$core17 = this.core) === null || _this$core17 === void 0 ? void 0 : _this$core17.telemetryDisabled) && this.isCopilotKitDestination(url)) {
7258
+ if (!url.searchParams.has("posthog_distinct_id") && !((_this$core20 = this.core) === null || _this$core20 === void 0 ? void 0 : _this$core20.telemetryDisabled) && this.isCopilotKitDestination(url)) {
6302
7259
  const distinctId = getTelemetryDistinctIdForUrl();
6303
7260
  if (distinctId) url.searchParams.append("posthog_distinct_id", distinctId);
6304
7261
  }