@copilotkit/web-inspector 1.62.2 → 1.62.3

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.2";
194
+ var version = "1.62.3";
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
@@ -3003,17 +3007,362 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3003
3007
  word-break: break-all;
3004
3008
  text-align: right;
3005
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
+ }
3006
3346
  `;
3007
3347
  var ɵCpkThreadDetails = class extends CpkThreadInspector {};
3008
3348
  if (!customElements.get("cpk-thread-list")) customElements.define("cpk-thread-list", CpkThreadList);
3009
3349
  if (!customElements.get(THREAD_INSPECTOR_TAG)) customElements.define(THREAD_INSPECTOR_TAG, CpkThreadInspector);
3010
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);
3011
3352
  var WebInspectorElement = class extends lit.LitElement {
3012
- constructor(..._args3) {
3013
- super(..._args3);
3353
+ constructor(..._args4) {
3354
+ super(..._args4);
3014
3355
  this._core = null;
3015
3356
  this.coreSubscriber = null;
3016
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;
3017
3366
  this.runtimeStatus = null;
3018
3367
  this.coreProperties = {};
3019
3368
  this.lastCoreError = null;
@@ -3431,6 +3780,11 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3431
3780
  key: "threads",
3432
3781
  label: "Threads",
3433
3782
  icon: "MessageSquare"
3783
+ },
3784
+ {
3785
+ key: "memories",
3786
+ label: "Learning",
3787
+ icon: "Brain"
3434
3788
  }
3435
3789
  ];
3436
3790
  }
@@ -3458,6 +3812,15 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3458
3812
  ...extra
3459
3813
  };
3460
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
+ }
3461
3824
  getIntelligenceSignupUrl() {
3462
3825
  return this.appendRefParam(INTELLIGENCE_SIGNUP_URL, "cpk-inspector");
3463
3826
  }
@@ -3502,9 +3865,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3502
3865
  this._threads = [];
3503
3866
  }
3504
3867
  ensureOwnedThreadStore(agentId) {
3505
- var _this$core9, _core$intelligence;
3868
+ var _this$core10, _core$intelligence;
3506
3869
  if (this._ownedThreadStores.has(agentId)) return;
3507
- 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;
3508
3871
  const core = this.core;
3509
3872
  if (!(core === null || core === void 0 ? void 0 : core.runtimeUrl)) return;
3510
3873
  if (!this.areThreadEndpointsAvailable()) return;
@@ -3539,18 +3902,18 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3539
3902
  }
3540
3903
  }
3541
3904
  removeOwnedThreadStore(agentId) {
3542
- var _this$core10;
3905
+ var _this$core11;
3543
3906
  const store = this._ownedThreadStores.get(agentId);
3544
3907
  if (!store) return;
3545
3908
  store.stop();
3546
- (_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);
3547
3910
  this._ownedThreadStores.delete(agentId);
3548
3911
  }
3549
3912
  teardownOwnedThreadStores() {
3550
3913
  for (const [agentId, store] of this._ownedThreadStores) {
3551
- var _this$core11;
3914
+ var _this$core12;
3552
3915
  store.stop();
3553
- (_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);
3554
3917
  }
3555
3918
  this._ownedThreadStores.clear();
3556
3919
  }
@@ -3628,12 +3991,76 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
3628
3991
  const threadStores = typeof core.getThreadStores === "function" ? core.getThreadStores() : {};
3629
3992
  for (const [agentId, store] of Object.entries(threadStores)) this.subscribeToThreadStore(agentId, store);
3630
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();
3631
4048
  }
3632
4049
  detachFromCore() {
4050
+ var _this$_memoryUnsub;
3633
4051
  if (this.coreUnsubscribe) {
3634
4052
  this.coreUnsubscribe();
3635
4053
  this.coreUnsubscribe = null;
3636
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;
3637
4064
  this.coreSubscriber = null;
3638
4065
  this.runtimeStatus = null;
3639
4066
  this.lastCoreError = null;
@@ -4148,6 +4575,7 @@ ${argsString}</pre
4148
4575
  y: EDGE_MARGIN
4149
4576
  };
4150
4577
  this.hydrateStateFromStorage();
4578
+ if (this.selectedMenu === "memories") this.ensureMemorySubscription();
4151
4579
  if (this.isOpen && this.dockMode !== "floating") this.applyDockStyles(true);
4152
4580
  this.applyAnchorPosition("button");
4153
4581
  if (this.dockMode === "floating") if (this.hasCustomPosition.window) this.applyAnchorPosition("window");
@@ -4846,12 +5274,13 @@ ${argsString}</pre
4846
5274
  if (this.selectedMenu === "frontend-tools") return this.renderToolsView();
4847
5275
  if (this.selectedMenu === "agent-context") return this.renderContextView();
4848
5276
  if (this.selectedMenu === "threads") return this.renderThreadsView();
5277
+ if (this.selectedMenu === "memories") return this.renderMemoriesView();
4849
5278
  if (this.selectedMenu === "settings") return this.renderSettingsPanel();
4850
5279
  return lit.nothing;
4851
5280
  }
4852
5281
  renderSettingsPanel() {
4853
- var _this$core$telemetryD2, _this$core12;
4854
- 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;
4855
5284
  return lit.html`
4856
5285
  <div class="flex h-full flex-col overflow-hidden">
4857
5286
  <div class="overflow-auto p-4">
@@ -4884,8 +5313,8 @@ ${argsString}</pre
4884
5313
  `;
4885
5314
  }
4886
5315
  trackBannerClickedOnce(opts) {
4887
- var _this$core13, _this$announcementCta;
4888
- 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;
4889
5318
  const id = this.announcementTimestamp;
4890
5319
  if (!id) return;
4891
5320
  const key = `${id}:${opts.cta}`;
@@ -4898,8 +5327,8 @@ ${argsString}</pre
4898
5327
  });
4899
5328
  }
4900
5329
  trackThreadsViewStateOnce(state, threadCount) {
4901
- var _this$core14;
4902
- 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;
4903
5332
  const key = `${state}:${this.getThreadServiceStatus()}`;
4904
5333
  if (this.viewedThreadsTelemetryStates.has(key)) return;
4905
5334
  this.viewedThreadsTelemetryStates.add(key);
@@ -5200,6 +5629,311 @@ ${argsString}</pre
5200
5629
  </div>
5201
5630
  </div>
5202
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>
5203
5937
  `;
5204
5938
  }
5205
5939
  renderThreadsView() {
@@ -5830,10 +6564,15 @@ ${prettyEvent}</pre
5830
6564
  if (this.contextOptions.filter((opt) => opt.key !== "all-agents").length > 1) this.selectedContext = "all-agents";
5831
6565
  }
5832
6566
  if (key === "threads") {
5833
- var _this$core15;
5834
- 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());
5835
6569
  this.autoSelectLatestThread();
5836
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
+ }
5837
6576
  if (key === "ag-ui-events" || key === "agents") requestAnimationFrame(() => {
5838
6577
  var _this$shadowRoot2;
5839
6578
  const scroller = (_this$shadowRoot2 = this.shadowRoot) === null || _this$shadowRoot2 === void 0 ? void 0 : _this$shadowRoot2.getElementById("cpk-main-scroll");
@@ -6403,8 +7142,8 @@ ${prettyEvent}</pre
6403
7142
  </div>`;
6404
7143
  }
6405
7144
  flushPendingBannerViewed() {
6406
- var _this$core16;
6407
- 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)) {
6408
7147
  this.pendingBannerViewed = null;
6409
7148
  return;
6410
7149
  }
@@ -6512,11 +7251,11 @@ ${prettyEvent}</pre
6512
7251
  }
6513
7252
  appendRefParam(href, ref = "cpk-inspector") {
6514
7253
  try {
6515
- var _this$core17;
7254
+ var _this$core20;
6516
7255
  const isRootRelative = href.startsWith("/") && !href.startsWith("//");
6517
7256
  const url = new URL(href, typeof window !== "undefined" ? window.location.href : "https://copilotkit.ai");
6518
7257
  if (!url.searchParams.has("ref")) url.searchParams.append("ref", ref);
6519
- 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)) {
6520
7259
  const distinctId = getTelemetryDistinctIdForUrl();
6521
7260
  if (distinctId) url.searchParams.append("posthog_distinct_id", distinctId);
6522
7261
  }