@copilotkit/web-inspector 1.56.5 → 1.57.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.mjs CHANGED
@@ -4,11 +4,11 @@ import inspector_logo_icon_default from "./assets/inspector-logo-icon.mjs";
4
4
  import { applyAnchorPosition, centerContext, clampSize, constrainToViewport, keepPositionWithinViewport, updateAnchorFromPosition, updateSizeFromElement } from "./lib/context-helpers.mjs";
5
5
  import { isValidAnchor, isValidDockMode, isValidPosition, isValidSize, loadInspectorState, saveInspectorState } from "./lib/persistence.mjs";
6
6
  import { LitElement, css, html, nothing, unsafeCSS } from "lit";
7
+ import { marked } from "marked";
7
8
  import { styleMap } from "lit/directives/style-map.js";
8
9
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
9
- import { marked } from "marked";
10
10
  import { icons } from "lucide";
11
- import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
11
+ import { CopilotKitCoreRuntimeConnectionStatus, ɵcreateThreadStore, ɵselectThreads, ɵselectThreadsError } from "@copilotkit/core";
12
12
 
13
13
  //#region src/index.ts
14
14
  const WEB_INSPECTOR_TAG = "cpk-web-inspector";
@@ -26,7 +26,7 @@ const DEFAULT_BUTTON_SIZE = {
26
26
  };
27
27
  const DEFAULT_WINDOW_SIZE = {
28
28
  width: 840,
29
- height: 560
29
+ height: 700
30
30
  };
31
31
  const DOCKED_LEFT_WIDTH = 500;
32
32
  const MAX_AGENT_EVENTS = 200;
@@ -52,11 +52,1765 @@ const AGENT_EVENT_TYPES = [
52
52
  "REASONING_MESSAGE_CONTENT",
53
53
  "REASONING_MESSAGE_END",
54
54
  "REASONING_END",
55
- "REASONING_ENCRYPTED_VALUE"
55
+ "REASONING_ENCRYPTED_VALUE",
56
+ "ACTIVITY_SNAPSHOT",
57
+ "ACTIVITY_DELTA"
56
58
  ];
57
- var WebInspectorElement = class extends LitElement {
59
+ function escapeHtml(s) {
60
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
61
+ }
62
+ const highlightedJsonCache = /* @__PURE__ */ new WeakMap();
63
+ function highlightedJson(obj) {
64
+ if (typeof obj === "object" && obj !== null) {
65
+ const cached = highlightedJsonCache.get(obj);
66
+ if (cached !== void 0) return cached;
67
+ }
68
+ const colors = {
69
+ key: "#5558B2",
70
+ str: "#189370",
71
+ num: "#996300",
72
+ bool: "#c0333a",
73
+ nil: "#838389"
74
+ };
75
+ const json = JSON.stringify(obj, null, 2);
76
+ if (!json) return "";
77
+ const parts = [];
78
+ let lastIndex = 0;
79
+ const re = /("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\b(?:true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g;
80
+ let match;
81
+ while ((match = re.exec(json)) !== null) {
82
+ parts.push(escapeHtml(json.slice(lastIndex, match.index)));
83
+ const m = match[0];
84
+ let color = colors.num;
85
+ if (m.startsWith("\"")) color = m.trimEnd().endsWith(":") ? colors.key : colors.str;
86
+ else if (m === "true" || m === "false") color = colors.bool;
87
+ else if (m === "null") color = colors.nil;
88
+ parts.push(`<span style="color:${color}">${escapeHtml(m)}</span>`);
89
+ lastIndex = match.index + m.length;
90
+ }
91
+ parts.push(escapeHtml(json.slice(lastIndex)));
92
+ const result = parts.join("");
93
+ if (typeof obj === "object" && obj !== null) highlightedJsonCache.set(obj, result);
94
+ return result;
95
+ }
96
+ function eventColors(type) {
97
+ if (type.startsWith("TEXT_MESSAGE")) return {
98
+ bg: "#EEE6FE",
99
+ fg: "#57575B"
100
+ };
101
+ if (type.startsWith("TOOL_CALL")) return {
102
+ bg: "rgba(133,236,206,0.15)",
103
+ fg: "#189370"
104
+ };
105
+ if (type.startsWith("STATE")) return {
106
+ bg: "rgba(190,194,255,0.102)",
107
+ fg: "#5558B2"
108
+ };
109
+ if (type.startsWith("RUN_") || type.startsWith("STEP_")) return {
110
+ bg: "rgba(255,172,77,0.2)",
111
+ fg: "#996300"
112
+ };
113
+ if (type === "ERROR") return {
114
+ bg: "rgba(250,95,103,0.13)",
115
+ fg: "#c0333a"
116
+ };
117
+ return {
118
+ bg: "#F7F7F9",
119
+ fg: "#838389"
120
+ };
121
+ }
122
+ function formatTimestamp(ts) {
123
+ const date = typeof ts === "number" ? new Date(ts) : new Date(ts);
124
+ if (Number.isNaN(date.getTime())) return "";
125
+ const ms = date.getMilliseconds().toString().padStart(3, "0");
126
+ return date.toLocaleTimeString("en-US", {
127
+ hour: "2-digit",
128
+ minute: "2-digit",
129
+ second: "2-digit",
130
+ hour12: false
131
+ }) + "." + ms;
132
+ }
133
+ var CpkThreadList = class extends LitElement {
58
134
  constructor(..._args) {
59
135
  super(..._args);
136
+ this.threads = [];
137
+ this.selectedThreadId = null;
138
+ this.errorMessage = null;
139
+ this._query = "";
140
+ this.onSearchInput = (event) => {
141
+ this._query = event.target.value;
142
+ };
143
+ }
144
+ static {
145
+ this.properties = {
146
+ threads: { attribute: false },
147
+ selectedThreadId: { attribute: false },
148
+ errorMessage: { attribute: false },
149
+ _query: { state: true }
150
+ };
151
+ }
152
+ static {
153
+ this.styles = css`
154
+ @import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&family=Spline+Sans+Mono:wght@400;500&display=swap");
155
+
156
+ :host {
157
+ display: flex;
158
+ flex-direction: column;
159
+ height: 100%;
160
+ overflow: hidden;
161
+ }
162
+
163
+ .cpk-tl {
164
+ font-family: "Plus Jakarta Sans", sans-serif;
165
+ display: flex;
166
+ flex-direction: column;
167
+ height: 100%;
168
+ overflow: hidden;
169
+ background: #f7f7f9;
170
+ }
171
+
172
+ /* ── Search ── */
173
+ .cpk-tl__search {
174
+ padding: 10px 12px;
175
+ border-bottom: 1px solid #dbdbe5;
176
+ flex-shrink: 0;
177
+ }
178
+
179
+ .cpk-tl__search-input {
180
+ width: 100%;
181
+ box-sizing: border-box;
182
+ font-family: "Plus Jakarta Sans", sans-serif;
183
+ font-size: 12px;
184
+ padding: 7px 10px;
185
+ border-radius: 6px;
186
+ border: 1px solid #dbdbe5;
187
+ background: #ffffff;
188
+ color: #010507;
189
+ outline: none;
190
+ transition: border-color 0.15s;
191
+ }
192
+
193
+ .cpk-tl__search-input:focus {
194
+ border-color: #bec2ff;
195
+ }
196
+
197
+ /* ── List ── */
198
+ .cpk-tl__list {
199
+ flex: 1;
200
+ overflow-y: auto;
201
+ }
202
+
203
+ /* ── Thread item ── */
204
+ .cpk-tl__item {
205
+ padding: 11px 13px;
206
+ cursor: pointer;
207
+ border-bottom: 1px solid #e9e9ef;
208
+ border-left: 3px solid transparent;
209
+ transition: background 0.1s;
210
+ }
211
+
212
+ .cpk-tl__item:hover {
213
+ background: #ffffff;
214
+ }
215
+
216
+ .cpk-tl__item--active {
217
+ background: #bec2ff1a;
218
+ border-left-color: #bec2ff;
219
+ }
220
+
221
+ .cpk-tl__item--active:hover {
222
+ background: #bec2ff33;
223
+ }
224
+
225
+ .cpk-tl__row1 {
226
+ display: flex;
227
+ align-items: center;
228
+ gap: 8px;
229
+ margin-bottom: 3px;
230
+ }
231
+
232
+ .cpk-tl__name {
233
+ font-size: 12px;
234
+ font-weight: 500;
235
+ color: #010507;
236
+ flex: 1;
237
+ overflow: hidden;
238
+ text-overflow: ellipsis;
239
+ white-space: nowrap;
240
+ }
241
+
242
+ .cpk-tl__name--unnamed {
243
+ color: #838389;
244
+ font-style: italic;
245
+ font-weight: 400;
246
+ }
247
+
248
+ .cpk-tl__time {
249
+ font-family: "Spline Sans Mono", monospace;
250
+ font-size: 10px;
251
+ color: #838389;
252
+ flex-shrink: 0;
253
+ }
254
+
255
+ .cpk-tl__meta {
256
+ display: flex;
257
+ gap: 6px;
258
+ align-items: center;
259
+ flex-wrap: wrap;
260
+ }
261
+
262
+ .cpk-tl__pill {
263
+ font-family: "Spline Sans Mono", monospace;
264
+ font-size: 9px;
265
+ padding: 1px 7px;
266
+ border-radius: 4px;
267
+ text-transform: uppercase;
268
+ font-weight: 500;
269
+ white-space: nowrap;
270
+ background: #eee6fe;
271
+ color: #57575b;
272
+ }
273
+
274
+ /* ── Empty state ── */
275
+ .cpk-tl__empty {
276
+ padding: 32px 16px;
277
+ text-align: center;
278
+ color: #838389;
279
+ font-size: 12px;
280
+ display: flex;
281
+ flex-direction: column;
282
+ align-items: center;
283
+ gap: 8px;
284
+ }
285
+
286
+ .cpk-tl__empty-icon {
287
+ color: #c0c0c8;
288
+ }
289
+ `;
290
+ }
291
+ relativeTime(dateStr) {
292
+ const date = new Date(dateStr);
293
+ const diffMs = Date.now() - date.getTime();
294
+ const diffSec = Math.floor(diffMs / 1e3);
295
+ if (diffSec < 60) return `${diffSec}s ago`;
296
+ const diffMin = Math.floor(diffSec / 60);
297
+ if (diffMin < 60) return `${diffMin}m ago`;
298
+ const diffH = Math.floor(diffMin / 60);
299
+ if (diffH < 24) return `${diffH}h ago`;
300
+ return `${Math.floor(diffH / 24)}d ago`;
301
+ }
302
+ get filtered() {
303
+ const q = this._query.toLowerCase();
304
+ if (!q) return this.threads;
305
+ return this.threads.filter((t) => (t.name?.toLowerCase().includes(q) ?? false) || t.agentId.toLowerCase().includes(q) || t.id.toLowerCase().includes(q));
306
+ }
307
+ onThreadClick(threadId) {
308
+ this.dispatchEvent(new CustomEvent("threadSelected", {
309
+ detail: threadId,
310
+ bubbles: true,
311
+ composed: true
312
+ }));
313
+ }
314
+ render() {
315
+ const filtered = this.filtered;
316
+ return html`
317
+ <div class="cpk-tl">
318
+ <!-- Search -->
319
+ <div class="cpk-tl__search">
320
+ <input
321
+ type="text"
322
+ placeholder="Search threads…"
323
+ .value=${this._query}
324
+ @input=${this.onSearchInput}
325
+ class="cpk-tl__search-input"
326
+ />
327
+ </div>
328
+
329
+ <!-- Thread list -->
330
+ <div class="cpk-tl__list">
331
+ ${filtered.map((thread) => html`
332
+ <div
333
+ class="cpk-tl__item ${this.selectedThreadId === thread.id ? "cpk-tl__item--active" : ""}"
334
+ @click=${() => this.onThreadClick(thread.id)}
335
+ >
336
+ <div class="cpk-tl__row1">
337
+ <span
338
+ class="cpk-tl__name ${!thread.name ? "cpk-tl__name--unnamed" : ""}"
339
+ >${thread.name ?? "Untitled"}</span
340
+ >
341
+ <span class="cpk-tl__time"
342
+ >${this.relativeTime(thread.updatedAt)}</span
343
+ >
344
+ </div>
345
+ <div class="cpk-tl__meta">
346
+ <span class="cpk-tl__pill">${thread.agentId}</span>
347
+ </div>
348
+ </div>
349
+ `)}
350
+ ${filtered.length === 0 ? html`
351
+ <div class="cpk-tl__empty">
352
+ ${this.errorMessage ? html`
353
+ <svg
354
+ width="24"
355
+ height="24"
356
+ viewBox="0 0 24 24"
357
+ fill="none"
358
+ stroke="currentColor"
359
+ stroke-width="1.5"
360
+ stroke-linecap="round"
361
+ stroke-linejoin="round"
362
+ class="cpk-tl__empty-icon"
363
+ >
364
+ <circle cx="12" cy="12" r="10" />
365
+ <line x1="12" y1="8" x2="12" y2="12" />
366
+ <line x1="12" y1="16" x2="12.01" y2="16" />
367
+ </svg>
368
+ <div>
369
+ Failed to load threads
370
+ <div style="font-size:11px;margin-top:4px;color:#c0333a;">
371
+ ${this.errorMessage}
372
+ </div>
373
+ </div>
374
+ ` : this.threads.length === 0 ? html`
375
+ <svg
376
+ width="24"
377
+ height="24"
378
+ viewBox="0 0 24 24"
379
+ fill="none"
380
+ stroke="currentColor"
381
+ stroke-width="1.5"
382
+ stroke-linecap="round"
383
+ stroke-linejoin="round"
384
+ class="cpk-tl__empty-icon"
385
+ >
386
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
387
+ </svg>
388
+ No threads yet
389
+ ` : html`
390
+ No threads match your search.
391
+ `}
392
+ </div>
393
+ ` : nothing}
394
+ </div>
395
+ </div>
396
+ `;
397
+ }
398
+ };
399
+ var ɵCpkThreadDetails = class ɵCpkThreadDetails extends LitElement {
400
+ constructor(..._args2) {
401
+ super(..._args2);
402
+ this.threadId = null;
403
+ this.thread = null;
404
+ this.runtimeUrl = "";
405
+ this.headers = {};
406
+ this.agentStateInput = null;
407
+ this.agentEventsInput = [];
408
+ this.liveMessageVersion = 0;
409
+ this._tab = "conversation";
410
+ this._conversation = [];
411
+ this._fetchedEvents = null;
412
+ this._fetchedState = null;
413
+ this._loadingMessages = false;
414
+ this._loadingEvents = false;
415
+ this._loadingState = false;
416
+ this._messagesError = null;
417
+ this._eventsError = null;
418
+ this._stateError = null;
419
+ this._expandedTools = /* @__PURE__ */ new Set();
420
+ this._expandedMessages = /* @__PURE__ */ new Set();
421
+ this._showDetailPanel = false;
422
+ this._detailPanelWidth = 250;
423
+ this._eventsNotAvailable = false;
424
+ this._stateNotAvailable = false;
425
+ this._panelInitializing = false;
426
+ this._activatedTabs = new Set(["conversation"]);
427
+ this._panelTplCache = /* @__PURE__ */ new Map();
428
+ this._eventsFetched = false;
429
+ this._stateFetched = false;
430
+ this._lastFetchedThreadId = null;
431
+ this._lastSeenLiveMessageVersion = 0;
432
+ this._messagesAbort = null;
433
+ this._eventsAbort = null;
434
+ this._stateAbort = null;
435
+ this._dividerResizing = false;
436
+ this._dividerPointerId = -1;
437
+ this._dividerStartX = 0;
438
+ this._dividerStartWidth = 0;
439
+ this.onDetailDividerDown = (event) => {
440
+ this._dividerResizing = true;
441
+ this._dividerPointerId = event.pointerId;
442
+ this._dividerStartX = event.clientX;
443
+ this._dividerStartWidth = this._detailPanelWidth;
444
+ event.currentTarget.setPointerCapture(event.pointerId);
445
+ event.preventDefault();
446
+ };
447
+ this.onDetailDividerMove = (event) => {
448
+ if (!this._dividerResizing || this._dividerPointerId !== event.pointerId) return;
449
+ const delta = this._dividerStartX - event.clientX;
450
+ this._detailPanelWidth = Math.max(160, Math.min(400, this._dividerStartWidth + delta));
451
+ };
452
+ this.onDetailDividerUp = (event) => {
453
+ if (this._dividerPointerId !== event.pointerId) return;
454
+ const target = event.currentTarget;
455
+ if (target.hasPointerCapture(this._dividerPointerId)) target.releasePointerCapture(this._dividerPointerId);
456
+ this._dividerResizing = false;
457
+ };
458
+ }
459
+ static {
460
+ this.properties = {
461
+ threadId: { attribute: false },
462
+ thread: { attribute: false },
463
+ runtimeUrl: { attribute: false },
464
+ headers: { attribute: false },
465
+ agentStateInput: { attribute: false },
466
+ agentEventsInput: { attribute: false },
467
+ liveMessageVersion: { attribute: false },
468
+ _tab: { state: true },
469
+ _conversation: { state: true },
470
+ _fetchedEvents: { state: true },
471
+ _fetchedState: { state: true },
472
+ _loadingMessages: { state: true },
473
+ _loadingEvents: { state: true },
474
+ _loadingState: { state: true },
475
+ _messagesError: { state: true },
476
+ _eventsError: { state: true },
477
+ _stateError: { state: true },
478
+ _expandedTools: { state: true },
479
+ _expandedMessages: { state: true },
480
+ _showDetailPanel: { state: true },
481
+ _detailPanelWidth: { state: true },
482
+ _eventsNotAvailable: { state: true },
483
+ _stateNotAvailable: { state: true },
484
+ _panelInitializing: { state: true },
485
+ _activatedTabs: { state: true }
486
+ };
487
+ }
488
+ static {
489
+ this.COLLAPSE_THRESHOLD = 800;
490
+ }
491
+ static {
492
+ this.TAB_LIST = [
493
+ {
494
+ id: "conversation",
495
+ label: "Conversation"
496
+ },
497
+ {
498
+ id: "agent-state",
499
+ label: "Agent State"
500
+ },
501
+ {
502
+ id: "ag-ui-events",
503
+ label: "AG-UI Events"
504
+ }
505
+ ];
506
+ }
507
+ renderTabContent(id) {
508
+ if (id === "conversation") return this.renderConversation();
509
+ if (id === "agent-state") return this.renderState();
510
+ return this.renderEvents();
511
+ }
512
+ activateTab(id) {
513
+ if (this._tab === id) return;
514
+ const isFirstActivation = !this._activatedTabs.has(id);
515
+ this._tab = id;
516
+ if (isFirstActivation) {
517
+ this._panelInitializing = true;
518
+ requestAnimationFrame(() => {
519
+ this._activatedTabs = new Set([...this._activatedTabs, id]);
520
+ this._panelInitializing = false;
521
+ });
522
+ }
523
+ this.maybeFetchTabData(id);
524
+ }
525
+ maybeFetchTabData(id) {
526
+ if (!this.threadId) return;
527
+ if (id === "ag-ui-events" && !this._eventsFetched) {
528
+ this._eventsFetched = true;
529
+ this.fetchEvents(this.threadId);
530
+ } else if (id === "agent-state" && !this._stateFetched) {
531
+ this._stateFetched = true;
532
+ this.fetchState(this.threadId);
533
+ }
534
+ }
535
+ static {
536
+ this.styles = css`
537
+ @import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&family=Spline+Sans+Mono:wght@400;500&display=swap");
538
+
539
+ /* ── Root ────────────────────────────────────────────────────────── */
540
+ :host {
541
+ display: flex;
542
+ flex-direction: row;
543
+ overflow: hidden;
544
+ }
545
+
546
+ .cpk-td {
547
+ font-family: "Plus Jakarta Sans", sans-serif;
548
+ font-size: 13px;
549
+ display: flex;
550
+ flex-direction: row;
551
+ width: 100%;
552
+ height: 100%;
553
+ overflow: hidden;
554
+ background: #ffffff;
555
+ }
556
+
557
+ /* ── Left area ───────────────────────────────────────────────────── */
558
+ .cpk-td__left {
559
+ flex: 1;
560
+ min-width: 0;
561
+ display: flex;
562
+ flex-direction: column;
563
+ overflow: hidden;
564
+ }
565
+
566
+ /* ── Tab bar header ──────────────────────────────────────────────── */
567
+ .cpk-td__tabs-header {
568
+ /* No top/right padding so tabs and toggle sit flush against the
569
+ top and right edges of the inspector. */
570
+ padding: 0 0 0 12px;
571
+ border-bottom: 1px solid #dbdbe5;
572
+ flex-shrink: 0;
573
+ display: flex;
574
+ align-items: stretch;
575
+ }
576
+
577
+ .cpk-td__tab-group {
578
+ display: flex;
579
+ gap: 0;
580
+ margin-bottom: -1px;
581
+ /* Allow the tab list to shrink rather than pushing the panel-toggle
582
+ button past the right edge of the inspector when horizontal space
583
+ gets tight (the drawer being open eats noticeably into width). */
584
+ min-width: 0;
585
+ flex-shrink: 1;
586
+ overflow: hidden;
587
+ }
588
+
589
+ .cpk-td__tab {
590
+ font-family: "Plus Jakarta Sans", sans-serif;
591
+ font-size: 11px;
592
+ font-weight: 500;
593
+ padding: 10px 12px;
594
+ border: none;
595
+ border-bottom: 2px solid transparent;
596
+ cursor: pointer;
597
+ background: transparent;
598
+ color: #838389;
599
+ transition:
600
+ color 0.12s,
601
+ border-color 0.12s;
602
+ white-space: nowrap;
603
+ }
604
+
605
+ .cpk-td__tab:hover {
606
+ color: #010507;
607
+ }
608
+
609
+ .cpk-td__tab--active {
610
+ color: #010507;
611
+ border-bottom-color: #bec2ff;
612
+ }
613
+
614
+ /* Toggle is a separate control, not a tab — so it does NOT use the
615
+ tabs' bottom-border active indicator. Instead, a subtle filled
616
+ state communicates "the drawer is open," and a vertical separator
617
+ on the left visually divorces it from the tab group. */
618
+ .cpk-td__panel-toggle {
619
+ margin-left: auto;
620
+ align-self: stretch;
621
+ display: flex;
622
+ align-items: center;
623
+ justify-content: center;
624
+ padding: 0 12px;
625
+ border: none;
626
+ border-left: 1px solid #dbdbe5;
627
+ background: transparent;
628
+ color: #838389;
629
+ cursor: pointer;
630
+ flex-shrink: 0;
631
+ transition:
632
+ color 0.12s,
633
+ background 0.12s;
634
+ }
635
+ .cpk-td__panel-toggle:hover {
636
+ color: #010507;
637
+ background: #f4f4f9;
638
+ }
639
+ .cpk-td__panel-toggle--active {
640
+ color: #5558b2;
641
+ background: #eee6fe;
642
+ }
643
+ .cpk-td__panel-toggle--active:hover {
644
+ background: #e4d8fc;
645
+ }
646
+
647
+ /* ── Scrollable content ──────────────────────────────────────────── */
648
+ .cpk-td__content {
649
+ flex: 1;
650
+ overflow-y: auto;
651
+ padding: 16px;
652
+ display: flex;
653
+ flex-direction: column;
654
+ gap: 8px;
655
+ }
656
+
657
+ /* Pin direct children so expanded tool bodies don't get flex-shrunk. */
658
+ .cpk-td__content > * {
659
+ flex-shrink: 0;
660
+ }
661
+
662
+ /*
663
+ * Each tab's content is wrapped in this panel so the keep-mounted
664
+ * inactive panels can be hidden via display:none without disturbing
665
+ * the gap between visible siblings. The flex column + gap gives each
666
+ * conversation item / event row breathing room (the cpk-td__content
667
+ * rule above no longer reaches them now that they are nested inside
668
+ * the per-panel wrapper).
669
+ */
670
+ .cpk-td__panel {
671
+ display: flex;
672
+ flex-direction: column;
673
+ gap: 12px;
674
+ }
675
+ .cpk-td__panel > * {
676
+ flex-shrink: 0;
677
+ }
678
+
679
+ /* ── Empty state ─────────────────────────────────────────────────── */
680
+ .cpk-td__empty-state {
681
+ flex: 1;
682
+ display: flex;
683
+ flex-direction: column;
684
+ align-items: center;
685
+ justify-content: center;
686
+ gap: 8px;
687
+ color: #838389;
688
+ font-size: 13px;
689
+ padding: 40px 0;
690
+ }
691
+
692
+ .cpk-td__empty-hint {
693
+ font-size: 11px;
694
+ color: #838389;
695
+ text-align: center;
696
+ max-width: 220px;
697
+ line-height: 1.5;
698
+ }
699
+
700
+ /* ── Status messages ─────────────────────────────────────────────── */
701
+ .cpk-td__status {
702
+ padding: 16px;
703
+ font-size: 12px;
704
+ color: #838389;
705
+ text-align: center;
706
+ }
707
+
708
+ .cpk-td__status--error {
709
+ color: #c0333a;
710
+ }
711
+
712
+ /* ── Conversation bubbles ────────────────────────────────────────── */
713
+ .cpk-td__bubble {
714
+ display: flex;
715
+ margin-bottom: 2px;
716
+ }
717
+
718
+ .cpk-td__bubble--user {
719
+ justify-content: flex-end;
720
+ }
721
+
722
+ .cpk-td__bubble--assistant {
723
+ justify-content: flex-start;
724
+ }
725
+
726
+ .cpk-td__bubble-inner {
727
+ padding: 9px 14px;
728
+ max-width: 75%;
729
+ font-size: 13px;
730
+ line-height: 1.55;
731
+ }
732
+
733
+ .cpk-td__bubble-inner--user {
734
+ background: #eee6fe;
735
+ color: #57575b;
736
+ border-radius: 10px 10px 3px 10px;
737
+ }
738
+
739
+ .cpk-td__show-more {
740
+ display: inline-block;
741
+ margin-top: 4px;
742
+ font-size: 11px;
743
+ font-weight: 500;
744
+ color: #57575b;
745
+ cursor: pointer;
746
+ text-decoration: underline;
747
+ text-underline-offset: 2px;
748
+ }
749
+
750
+ .cpk-td__bubble-inner--assistant {
751
+ background: #f7f7f9;
752
+ color: #010507;
753
+ border-radius: 10px 10px 10px 3px;
754
+ border: 1px solid #e9e9ef;
755
+ }
756
+
757
+ /* ── Tool call blocks ────────────────────────────────────────────── */
758
+ .cpk-td__tool-block {
759
+ border: 1px solid #e9e9ef;
760
+ border-radius: 6px;
761
+ overflow: hidden;
762
+ }
763
+
764
+ .cpk-td__tool-header {
765
+ display: flex;
766
+ align-items: center;
767
+ gap: 6px;
768
+ padding: 6px 10px;
769
+ background: rgba(133, 236, 206, 0.15);
770
+ cursor: pointer;
771
+ font-size: 11px;
772
+ user-select: none;
773
+ }
774
+
775
+ .cpk-td__tool-header:hover {
776
+ background: rgba(133, 236, 206, 0.22);
777
+ }
778
+
779
+ .cpk-td__tool-name {
780
+ font-family: "Spline Sans Mono", monospace;
781
+ font-size: 10px;
782
+ font-weight: 500;
783
+ color: #189370;
784
+ text-transform: uppercase;
785
+ flex: 1;
786
+ }
787
+
788
+ .cpk-td__tool-status {
789
+ font-family: "Spline Sans Mono", monospace;
790
+ font-size: 9px;
791
+ text-transform: uppercase;
792
+ color: #189370;
793
+ }
794
+
795
+ .cpk-td__tool-status--pending {
796
+ color: #996300;
797
+ }
798
+
799
+ .cpk-td__tool-chevron {
800
+ color: #838389;
801
+ font-size: 10px;
802
+ }
803
+
804
+ .cpk-td__tool-body {
805
+ padding: 8px 10px;
806
+ border-top: 1px solid #e9e9ef;
807
+ background: #ffffff;
808
+ }
809
+
810
+ .cpk-td__tool-section-label {
811
+ font-family: "Spline Sans Mono", monospace;
812
+ font-size: 9px;
813
+ font-weight: 500;
814
+ color: #838389;
815
+ text-transform: uppercase;
816
+ margin-bottom: 4px;
817
+ letter-spacing: 0.3px;
818
+ }
819
+
820
+ .cpk-td__tool-pre {
821
+ margin: 0;
822
+ font-family: "Spline Sans Mono", monospace;
823
+ font-size: 10px;
824
+ background: #f7f7f9;
825
+ padding: 6px 8px;
826
+ border-radius: 4px;
827
+ overflow-x: auto;
828
+ white-space: pre-wrap;
829
+ word-break: break-all;
830
+ color: #010507;
831
+ line-height: 1.6;
832
+ }
833
+
834
+ /* ── Tool call group ─────────────────────────────────────────────── */
835
+ .cpk-td__tool-group {
836
+ border: 1px solid #e9e9ef;
837
+ border-radius: 6px;
838
+ overflow: hidden;
839
+ }
840
+
841
+ .cpk-td__tool-group-header {
842
+ padding: 5px 10px;
843
+ background: rgba(133, 236, 206, 0.15);
844
+ font-family: "Spline Sans Mono", monospace;
845
+ font-size: 10px;
846
+ color: #189370;
847
+ text-transform: uppercase;
848
+ font-weight: 500;
849
+ border-bottom: 1px solid #e9e9ef;
850
+ }
851
+
852
+ .cpk-td__tool-group .cpk-td__tool-block {
853
+ border: none;
854
+ border-bottom: 1px solid #e9e9ef;
855
+ border-radius: 0;
856
+ }
857
+
858
+ .cpk-td__tool-group .cpk-td__tool-block:last-child {
859
+ border-bottom: none;
860
+ }
861
+
862
+ /* ── Inline chips (reasoning / state update) ─────────────────────── */
863
+ .cpk-td__inline-chip {
864
+ display: flex;
865
+ align-items: center;
866
+ gap: 8px;
867
+ padding: 5px 0;
868
+ color: #838389;
869
+ font-family: "Spline Sans Mono", monospace;
870
+ font-size: 9px;
871
+ text-transform: uppercase;
872
+ }
873
+
874
+ .cpk-td__inline-chip::before,
875
+ .cpk-td__inline-chip::after {
876
+ content: "";
877
+ flex: 1;
878
+ height: 1px;
879
+ background: #e9e9ef;
880
+ }
881
+
882
+ /* ── Generative UI ──────────────────────────────────────────────── */
883
+ @keyframes cpk-genui-enter {
884
+ from {
885
+ opacity: 0;
886
+ transform: translateY(8px);
887
+ }
888
+ to {
889
+ opacity: 1;
890
+ transform: translateY(0);
891
+ }
892
+ }
893
+
894
+ .cpk-td__genui {
895
+ display: flex;
896
+ flex-direction: column;
897
+ gap: 6px;
898
+ padding: 4px 16px 8px;
899
+ animation: cpk-genui-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
900
+ }
901
+
902
+ .cpk-td__genui-badge {
903
+ display: inline-flex;
904
+ align-items: center;
905
+ gap: 4px;
906
+ padding: 2px 8px;
907
+ border-radius: 4px;
908
+ background: #eee6fe;
909
+ color: #57575b;
910
+ font-size: 10px;
911
+ font-weight: 600;
912
+ align-self: flex-start;
913
+ }
914
+
915
+ .cpk-td__genui-card {
916
+ overflow: hidden;
917
+ border-radius: 12px;
918
+ border: 1px solid #e2e8f0;
919
+ background: #fff;
920
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
921
+ }
922
+
923
+ .cpk-td__genui-placeholder {
924
+ padding: 8px 12px;
925
+ border-radius: 8px;
926
+ border: 1px solid #ede9fe;
927
+ background: #f5f3ff;
928
+ color: #7c3aed;
929
+ font-size: 11px;
930
+ }
931
+
932
+ /* ── AG-UI Events ────────────────────────────────────────────────── */
933
+ .cpk-td__event {
934
+ flex-shrink: 0;
935
+ border: 1px solid #e9e9ef;
936
+ border-radius: 6px;
937
+ overflow: hidden;
938
+ /*
939
+ * content-visibility: auto lets the browser skip layout + paint for
940
+ * off-screen events while keeping them in the DOM (so scroll size
941
+ * stays correct). Without this, switching back to AG-UI Events on a
942
+ * thread with hundreds of events triggers a full layout pass over
943
+ * every event row, which on Martha's intelligence-backed example
944
+ * shows up as a multi-second freeze each time the panel becomes
945
+ * visible. The intrinsic-size hint avoids the visible jump as the
946
+ * browser swaps in real heights when items scroll into view.
947
+ */
948
+ content-visibility: auto;
949
+ contain-intrinsic-size: 0 80px;
950
+ }
951
+
952
+ .cpk-td__event-header {
953
+ display: flex;
954
+ justify-content: space-between;
955
+ align-items: center;
956
+ padding: 5px 10px;
957
+ }
958
+
959
+ .cpk-td__event-type {
960
+ font-family: "Spline Sans Mono", monospace;
961
+ font-size: 9px;
962
+ font-weight: 500;
963
+ text-transform: uppercase;
964
+ }
965
+
966
+ .cpk-td__event-time {
967
+ font-family: "Spline Sans Mono", monospace;
968
+ font-size: 9px;
969
+ color: #838389;
970
+ }
971
+
972
+ .cpk-td__event-payload {
973
+ margin: 0;
974
+ font-family: "Spline Sans Mono", monospace;
975
+ font-size: 10px;
976
+ line-height: 1.6;
977
+ white-space: pre-wrap;
978
+ word-break: break-all;
979
+ color: #57575b;
980
+ padding: 8px 10px;
981
+ border-top: 1px solid #e9e9ef;
982
+ }
983
+
984
+ /* ── JSON block (agent state) ────────────────────────────────────── */
985
+ .cpk-td__json-block {
986
+ margin: 0;
987
+ font-family: "Spline Sans Mono", monospace;
988
+ font-size: 11px;
989
+ line-height: 1.8;
990
+ white-space: pre-wrap;
991
+ word-break: break-all;
992
+ color: #57575b;
993
+ }
994
+
995
+ /* ── Resize divider ──────────────────────────────────────────────── */
996
+ /* Floats over the drawer's left edge so the toggle and the drawer
997
+ touch directly without a 4px flex-gap between them. The hit zone
998
+ is wider than its visual hint to make it easy to grab. */
999
+ .cpk-td__detail-divider {
1000
+ position: absolute;
1001
+ top: 0;
1002
+ bottom: 0;
1003
+ left: -3px;
1004
+ width: 7px;
1005
+ cursor: col-resize;
1006
+ background: transparent;
1007
+ z-index: 5;
1008
+ }
1009
+
1010
+ .cpk-td__detail-divider:hover {
1011
+ background: rgba(190, 194, 255, 0.3);
1012
+ }
1013
+
1014
+ /* ── Right detail panel ──────────────────────────────────────────── */
1015
+ .cpk-td__detail {
1016
+ flex-shrink: 0;
1017
+ overflow: hidden;
1018
+ background: #f7f7f9;
1019
+ display: flex;
1020
+ flex-direction: column;
1021
+ gap: 0;
1022
+ padding: 0;
1023
+ box-sizing: border-box;
1024
+ position: relative;
1025
+ /* Slide open/closed via width + padding transition. When closed,
1026
+ width and padding are 0 so the drawer fully collapses. */
1027
+ transition:
1028
+ width 220ms cubic-bezier(0.4, 0, 0.2, 1),
1029
+ padding 220ms cubic-bezier(0.4, 0, 0.2, 1);
1030
+ }
1031
+
1032
+ .cpk-td__detail[data-open="true"] {
1033
+ overflow-y: auto;
1034
+ padding: 16px;
1035
+ }
1036
+
1037
+ .cpk-tdp__section-title {
1038
+ font-family: "Spline Sans Mono", monospace;
1039
+ font-size: 10px;
1040
+ font-weight: 500;
1041
+ color: #838389;
1042
+ text-transform: uppercase;
1043
+ letter-spacing: 0.6px;
1044
+ margin-bottom: 8px;
1045
+ }
1046
+
1047
+ .cpk-tdp__divider {
1048
+ height: 1px;
1049
+ background: #dbdbe5;
1050
+ margin: 14px 0;
1051
+ }
1052
+
1053
+ .cpk-tdp__row {
1054
+ display: flex;
1055
+ justify-content: space-between;
1056
+ align-items: flex-start;
1057
+ padding: 3px 0;
1058
+ gap: 8px;
1059
+ }
1060
+
1061
+ .cpk-tdp__label {
1062
+ color: #838389;
1063
+ font-size: 11px;
1064
+ white-space: nowrap;
1065
+ flex-shrink: 0;
1066
+ }
1067
+
1068
+ .cpk-tdp__value {
1069
+ color: #010507;
1070
+ font-family: "Spline Sans Mono", monospace;
1071
+ font-size: 11px;
1072
+ text-align: right;
1073
+ min-width: 0;
1074
+ }
1075
+
1076
+ .cpk-tdp__value--truncate {
1077
+ overflow: hidden;
1078
+ text-overflow: ellipsis;
1079
+ white-space: nowrap;
1080
+ max-width: 130px;
1081
+ }
1082
+
1083
+ .cpk-tdp__value--wrap {
1084
+ white-space: normal;
1085
+ word-break: break-all;
1086
+ text-align: right;
1087
+ }
1088
+ `;
1089
+ }
1090
+ updated(_changed) {
1091
+ if (this.threadId !== this._lastFetchedThreadId) {
1092
+ this._lastFetchedThreadId = this.threadId;
1093
+ this._lastSeenLiveMessageVersion = this.liveMessageVersion;
1094
+ this._tab = "conversation";
1095
+ this._activatedTabs = new Set(["conversation"]);
1096
+ this._panelTplCache = /* @__PURE__ */ new Map();
1097
+ this._expandedTools = /* @__PURE__ */ new Set();
1098
+ this._expandedMessages = /* @__PURE__ */ new Set();
1099
+ this._messagesAbort?.abort();
1100
+ this._messagesAbort = null;
1101
+ this._eventsAbort?.abort();
1102
+ this._eventsAbort = null;
1103
+ this._stateAbort?.abort();
1104
+ this._stateAbort = null;
1105
+ this._eventsFetched = false;
1106
+ this._stateFetched = false;
1107
+ this._fetchedEvents = null;
1108
+ this._fetchedState = null;
1109
+ if (this.threadId) this.fetchMessages(this.threadId);
1110
+ else this._conversation = [];
1111
+ } else if (this.threadId && this.liveMessageVersion !== this._lastSeenLiveMessageVersion) {
1112
+ this._lastSeenLiveMessageVersion = this.liveMessageVersion;
1113
+ this._messagesAbort?.abort();
1114
+ this._messagesAbort = null;
1115
+ this.fetchMessages(this.threadId, true);
1116
+ }
1117
+ }
1118
+ /**
1119
+ * Fetch the canonical conversation for `threadId` from the runtime.
1120
+ *
1121
+ * `silent` is true for live re-fetches triggered by `liveMessageVersion`
1122
+ * bumps during streaming. In that mode we never toggle the loading state
1123
+ * (which would flash "Loading messages…" between every message) and we
1124
+ * keep the previous conversation on transient errors instead of blanking
1125
+ * it. Initial threadId-change fetches use the default (`silent=false`)
1126
+ * so users see an explicit loading indicator on first load.
1127
+ */
1128
+ async fetchMessages(threadId, silent = false) {
1129
+ if (!this.runtimeUrl) {
1130
+ if (!silent) this._conversation = [];
1131
+ return;
1132
+ }
1133
+ const controller = new AbortController();
1134
+ this._messagesAbort = controller;
1135
+ if (!silent) {
1136
+ this._loadingMessages = true;
1137
+ this._messagesError = null;
1138
+ }
1139
+ try {
1140
+ const res = await fetch(`${this.runtimeUrl}/threads/${encodeURIComponent(threadId)}/messages`, {
1141
+ headers: { ...this.headers },
1142
+ signal: controller.signal
1143
+ });
1144
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1145
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
1146
+ const data = await res.json();
1147
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1148
+ this._conversation = this.mapMessages(data.messages);
1149
+ } catch (err) {
1150
+ if (err instanceof Error && err.name === "AbortError") return;
1151
+ if (!silent) {
1152
+ this._messagesError = err instanceof Error ? err.message : "Failed to load messages";
1153
+ this._conversation = [];
1154
+ }
1155
+ } finally {
1156
+ if (!silent && !controller.signal.aborted) this._loadingMessages = false;
1157
+ }
1158
+ }
1159
+ async fetchEvents(threadId) {
1160
+ this._eventsNotAvailable = false;
1161
+ if (!this.runtimeUrl) {
1162
+ this._fetchedEvents = null;
1163
+ return;
1164
+ }
1165
+ const controller = new AbortController();
1166
+ this._eventsAbort = controller;
1167
+ this._loadingEvents = true;
1168
+ this._eventsError = null;
1169
+ try {
1170
+ const res = await fetch(`${this.runtimeUrl}/threads/${encodeURIComponent(threadId)}/events`, {
1171
+ headers: { ...this.headers },
1172
+ signal: controller.signal
1173
+ });
1174
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1175
+ if (res.status === 501) {
1176
+ this._eventsNotAvailable = true;
1177
+ this._fetchedEvents = null;
1178
+ return;
1179
+ }
1180
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
1181
+ const data = await res.json();
1182
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1183
+ this._fetchedEvents = this.mapApiEvents(data.events);
1184
+ } catch (err) {
1185
+ if (err instanceof Error && err.name === "AbortError") return;
1186
+ if (this.threadId !== threadId) return;
1187
+ this._eventsError = err instanceof Error ? err.message : "Failed to load events";
1188
+ this._fetchedEvents = [];
1189
+ } finally {
1190
+ if (!controller.signal.aborted && this.threadId === threadId) this._loadingEvents = false;
1191
+ }
1192
+ }
1193
+ async fetchState(threadId) {
1194
+ this._stateNotAvailable = false;
1195
+ if (!this.runtimeUrl) {
1196
+ this._fetchedState = null;
1197
+ return;
1198
+ }
1199
+ const controller = new AbortController();
1200
+ this._stateAbort = controller;
1201
+ this._loadingState = true;
1202
+ this._stateError = null;
1203
+ try {
1204
+ const res = await fetch(`${this.runtimeUrl}/threads/${encodeURIComponent(threadId)}/state`, {
1205
+ headers: { ...this.headers },
1206
+ signal: controller.signal
1207
+ });
1208
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1209
+ if (res.status === 501) {
1210
+ this._stateNotAvailable = true;
1211
+ this._fetchedState = null;
1212
+ return;
1213
+ }
1214
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
1215
+ const data = await res.json();
1216
+ if (controller.signal.aborted || this.threadId !== threadId) return;
1217
+ this._fetchedState = data.state ?? null;
1218
+ } catch (err) {
1219
+ if (err instanceof Error && err.name === "AbortError") return;
1220
+ if (this.threadId !== threadId) return;
1221
+ this._stateError = err instanceof Error ? err.message : "Failed to load state";
1222
+ this._fetchedState = null;
1223
+ } finally {
1224
+ if (!controller.signal.aborted && this.threadId === threadId) this._loadingState = false;
1225
+ }
1226
+ }
1227
+ mapMessages(messages) {
1228
+ const items = [];
1229
+ const toolCallMap = /* @__PURE__ */ new Map();
1230
+ for (const msg of messages) if (msg.role === "user" && msg.content) items.push({
1231
+ id: msg.id,
1232
+ type: "user",
1233
+ content: msg.content,
1234
+ createdAt: ""
1235
+ });
1236
+ else if (msg.role === "assistant") {
1237
+ if (msg.toolCalls?.length) for (const tc of msg.toolCalls) {
1238
+ let args = {};
1239
+ try {
1240
+ args = JSON.parse(tc.args);
1241
+ } catch (err) {
1242
+ console.error("[CopilotKit Inspector] Failed to parse tool-call arguments", {
1243
+ toolCallId: tc.id,
1244
+ raw: tc.args,
1245
+ error: err
1246
+ });
1247
+ args = {
1248
+ __parseError: true,
1249
+ __raw: tc.args
1250
+ };
1251
+ }
1252
+ const item = {
1253
+ id: tc.id,
1254
+ type: "tool_call",
1255
+ toolName: tc.name,
1256
+ toolCallId: tc.id,
1257
+ arguments: args,
1258
+ result: null,
1259
+ createdAt: ""
1260
+ };
1261
+ toolCallMap.set(tc.id, item);
1262
+ items.push(item);
1263
+ }
1264
+ if (msg.content) items.push({
1265
+ id: msg.id,
1266
+ type: "assistant",
1267
+ content: msg.content,
1268
+ createdAt: ""
1269
+ });
1270
+ } else if (msg.role === "activity") items.push({
1271
+ id: msg.id,
1272
+ type: "generative-ui",
1273
+ activityType: msg.activityType ?? "unknown",
1274
+ createdAt: ""
1275
+ });
1276
+ else if (msg.role === "tool" && msg.toolCallId) {
1277
+ const tc = toolCallMap.get(msg.toolCallId);
1278
+ if (tc) try {
1279
+ tc.result = JSON.parse(msg.content ?? "{}");
1280
+ } catch (err) {
1281
+ console.error("[CopilotKit Inspector] Failed to parse tool-call result content", {
1282
+ toolCallId: msg.toolCallId,
1283
+ raw: msg.content,
1284
+ error: err
1285
+ });
1286
+ tc.result = {
1287
+ __parseError: true,
1288
+ __raw: msg.content ?? null
1289
+ };
1290
+ }
1291
+ }
1292
+ return items;
1293
+ }
1294
+ mapApiEvents(events) {
1295
+ return events.map((event) => {
1296
+ const { type, timestamp, ...rest } = event;
1297
+ return {
1298
+ type: typeof type === "string" ? type : "UNKNOWN",
1299
+ timestamp: typeof timestamp === "string" || typeof timestamp === "number" ? timestamp : Date.now(),
1300
+ payload: rest
1301
+ };
1302
+ });
1303
+ }
1304
+ get renderItems() {
1305
+ const items = this._conversation;
1306
+ const result = [];
1307
+ const seen = /* @__PURE__ */ new Set();
1308
+ for (const item of items) {
1309
+ if (item.type === "agent_responded") continue;
1310
+ if (item.type !== "tool_call" || !item.groupId) {
1311
+ result.push(item);
1312
+ continue;
1313
+ }
1314
+ if (seen.has(item.groupId)) continue;
1315
+ seen.add(item.groupId);
1316
+ const group = {
1317
+ type: "tool_call_group",
1318
+ id: item.groupId,
1319
+ items: items.filter((i) => i.type === "tool_call" && i.groupId === item.groupId)
1320
+ };
1321
+ result.push(group);
1322
+ }
1323
+ return result;
1324
+ }
1325
+ get activityCounts() {
1326
+ let messages = 0;
1327
+ let toolCalls = 0;
1328
+ let generativeUi = 0;
1329
+ for (const item of this._conversation) {
1330
+ if (item.type === "user" || item.type === "assistant") messages++;
1331
+ if (item.type === "tool_call") toolCalls++;
1332
+ if (item.type === "generative-ui") generativeUi++;
1333
+ }
1334
+ return {
1335
+ messages,
1336
+ toolCalls,
1337
+ generativeUi
1338
+ };
1339
+ }
1340
+ get duration() {
1341
+ const t = this.thread;
1342
+ if (!t?.createdAt || !t?.updatedAt) return "—";
1343
+ const ms = new Date(t.updatedAt).getTime() - new Date(t.createdAt).getTime();
1344
+ if (ms < 0) return "—";
1345
+ if (ms < 1e3) return `${ms}ms`;
1346
+ const s = Math.floor(ms / 1e3);
1347
+ if (s < 60) return `${s}s`;
1348
+ return `${Math.floor(s / 60)}m ${s % 60}s`;
1349
+ }
1350
+ toggleToolExpand(id) {
1351
+ const next = new Set(this._expandedTools);
1352
+ if (next.has(id)) next.delete(id);
1353
+ else next.add(id);
1354
+ this._expandedTools = next;
1355
+ }
1356
+ toggleMessageExpand(id) {
1357
+ const next = new Set(this._expandedMessages);
1358
+ if (next.has(id)) next.delete(id);
1359
+ else next.add(id);
1360
+ this._expandedMessages = next;
1361
+ }
1362
+ get activeEvents() {
1363
+ if (this._eventsNotAvailable) return [];
1364
+ return this._fetchedEvents ?? this.agentEventsInput ?? [];
1365
+ }
1366
+ get activeState() {
1367
+ if (this._stateNotAvailable) return null;
1368
+ return this._fetchedState ?? this.agentStateInput ?? null;
1369
+ }
1370
+ hasRenderableState() {
1371
+ const s = this.activeState;
1372
+ return !!s && typeof s === "object" && Object.keys(s).length > 0;
1373
+ }
1374
+ shortId(id) {
1375
+ if (!id) return "—";
1376
+ return id.length > 20 ? id.slice(0, 8) + "…" : id;
1377
+ }
1378
+ fmtTime(dateStr) {
1379
+ if (!dateStr) return "—";
1380
+ const d = new Date(dateStr);
1381
+ if (Number.isNaN(d.getTime())) return "—";
1382
+ return d.toLocaleTimeString("en-US", {
1383
+ hour: "2-digit",
1384
+ minute: "2-digit",
1385
+ second: "2-digit",
1386
+ hour12: false
1387
+ });
1388
+ }
1389
+ render() {
1390
+ return html`
1391
+ <div class="cpk-td">
1392
+ <!-- ── Left area: tabs + content ─────────────────────────────────── -->
1393
+ <div class="cpk-td__left">
1394
+ <!-- Tab bar -->
1395
+ <div class="cpk-td__tabs-header">
1396
+ <div class="cpk-td__tab-group" role="tablist">
1397
+ ${ɵCpkThreadDetails.TAB_LIST.map((tab) => html`
1398
+ <button
1399
+ role="tab"
1400
+ class="cpk-td__tab ${this._tab === tab.id ? "cpk-td__tab--active" : ""}"
1401
+ @click=${() => this.activateTab(tab.id)}
1402
+ >
1403
+ ${tab.label}
1404
+ </button>
1405
+ `)}
1406
+ </div>
1407
+ ${this.renderPanelToggle()}
1408
+ </div>
1409
+
1410
+ <!-- Scrollable content -->
1411
+ <div class="cpk-td__content">
1412
+ ${this._panelInitializing ? html`
1413
+ <div class="cpk-td__status">Loading…</div>
1414
+ ` : nothing}
1415
+ ${ɵCpkThreadDetails.TAB_LIST.map((tab) => this._activatedTabs.has(tab.id) ? html`<div
1416
+ class="cpk-td__panel"
1417
+ style=${this._tab === tab.id && !this._panelInitializing ? "" : "display:none"}
1418
+ >
1419
+ ${this.renderTabContent(tab.id)}
1420
+ </div>` : nothing)}
1421
+ </div>
1422
+ </div>
1423
+
1424
+ <!--
1425
+ Drawer always rendered so width animates between 0 and its
1426
+ target. Divider lives INSIDE the drawer and is absolutely
1427
+ positioned over its left edge so the toggle (rightmost of the
1428
+ tab row) and the drawer touch with no flex-gap between them.
1429
+ -->
1430
+ <div
1431
+ class="cpk-td__detail"
1432
+ data-open=${this._showDetailPanel ? "true" : "false"}
1433
+ style="width:${this._showDetailPanel ? this._detailPanelWidth : 0}px"
1434
+ aria-hidden=${this._showDetailPanel ? "false" : "true"}
1435
+ >
1436
+ ${this._showDetailPanel ? html`
1437
+ <div
1438
+ class="cpk-td__detail-divider"
1439
+ @pointerdown=${this.onDetailDividerDown}
1440
+ @pointermove=${this.onDetailDividerMove}
1441
+ @pointerup=${this.onDetailDividerUp}
1442
+ @pointercancel=${this.onDetailDividerUp}
1443
+ ></div>
1444
+ ` : nothing}
1445
+ ${this.renderDetailPanel()}
1446
+ </div>
1447
+ </div>
1448
+ `;
1449
+ }
1450
+ renderConversation() {
1451
+ if (this._loadingMessages) return html`
1452
+ <div class="cpk-td__status">Loading messages…</div>
1453
+ `;
1454
+ if (this._messagesError) return html`<div class="cpk-td__status cpk-td__status--error">
1455
+ ${this._messagesError}
1456
+ </div>`;
1457
+ if (this._conversation.length === 0) return html`
1458
+ <div class="cpk-td__empty-state">
1459
+ <svg
1460
+ width="28"
1461
+ height="28"
1462
+ viewBox="0 0 24 24"
1463
+ fill="none"
1464
+ stroke="currentColor"
1465
+ stroke-width="1.5"
1466
+ stroke-linecap="round"
1467
+ stroke-linejoin="round"
1468
+ >
1469
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
1470
+ </svg>
1471
+ <span>No messages yet</span>
1472
+ </div>
1473
+ `;
1474
+ return this.cachedPanelTpl("conversation", [
1475
+ this._conversation,
1476
+ this._expandedTools,
1477
+ this._expandedMessages
1478
+ ], () => {
1479
+ return html`${this.renderItems.map((item) => this.renderRenderItem(item))}`;
1480
+ });
1481
+ }
1482
+ /**
1483
+ * Memoize the rendered TemplateResult for `slot` keyed by tuple
1484
+ * element-wise reference equality. The hot path for tab switches: when
1485
+ * the underlying data hasn't changed, return the previously built
1486
+ * TemplateResult so Lit's diff short-circuits. Each panel's `key` is
1487
+ * the tuple of inputs the template reads — pass everything the template
1488
+ * depends on, or the cache will return stale output when those inputs
1489
+ * change without the listed key flipping.
1490
+ */
1491
+ cachedPanelTpl(slot, key, build) {
1492
+ const cached = this._panelTplCache.get(slot);
1493
+ if (cached && cached.key.length === key.length && cached.key.every((v, i) => v === key[i])) return cached.tpl;
1494
+ const tpl = build();
1495
+ this._panelTplCache.set(slot, {
1496
+ key,
1497
+ tpl
1498
+ });
1499
+ return tpl;
1500
+ }
1501
+ renderRenderItem(item) {
1502
+ switch (item.type) {
1503
+ case "user":
1504
+ case "assistant": return this.renderBubble(item);
1505
+ case "tool_call": return this.renderToolBlock(item);
1506
+ case "tool_call_group": return this.renderToolGroup(item);
1507
+ case "reasoning": return html`<div class="cpk-td__inline-chip">
1508
+ <span>Reasoned for ${item.duration}</span>
1509
+ </div>`;
1510
+ case "state_update": return html`
1511
+ <div class="cpk-td__inline-chip">
1512
+ <span>Updated agent state</span>
1513
+ </div>
1514
+ `;
1515
+ case "generative-ui": return this.renderGenerativeUI(item);
1516
+ case "agent_responded": return nothing;
1517
+ }
1518
+ }
1519
+ renderBubble(item) {
1520
+ const isUser = item.type === "user";
1521
+ const threshold = ɵCpkThreadDetails.COLLAPSE_THRESHOLD;
1522
+ const expanded = this._expandedMessages.has(item.id);
1523
+ const tooLong = item.content.length > threshold;
1524
+ const shown = tooLong && !expanded ? item.content.slice(0, threshold) + "…" : item.content;
1525
+ return html`
1526
+ <div
1527
+ class="cpk-td__bubble ${isUser ? "cpk-td__bubble--user" : "cpk-td__bubble--assistant"}"
1528
+ >
1529
+ <div
1530
+ class="cpk-td__bubble-inner ${isUser ? "cpk-td__bubble-inner--user" : "cpk-td__bubble-inner--assistant"}"
1531
+ >
1532
+ ${shown}
1533
+ ${tooLong ? html`<span
1534
+ class="cpk-td__show-more"
1535
+ @click=${() => this.toggleMessageExpand(item.id)}
1536
+ >${expanded ? "Show less" : "Show more"}</span
1537
+ >` : nothing}
1538
+ </div>
1539
+ </div>
1540
+ `;
1541
+ }
1542
+ renderToolBlock(item) {
1543
+ const expanded = this._expandedTools.has(item.id);
1544
+ return html`
1545
+ <div class="cpk-td__tool-block">
1546
+ <div
1547
+ class="cpk-td__tool-header"
1548
+ @click=${() => this.toggleToolExpand(item.id)}
1549
+ >
1550
+ <svg width="10" height="10" viewBox="0 0 10 10" fill="none">
1551
+ <path
1552
+ d="M1 9C1 9 2 7 5 7C8 7 9 9 9 9M5 1C5 1 7 2.5 7 4.5C7 6.5 5 7 5 7C5 7 3 6.5 3 4.5C3 2.5 5 1 5 1Z"
1553
+ stroke="#189370"
1554
+ stroke-width="1.2"
1555
+ stroke-linecap="round"
1556
+ stroke-linejoin="round"
1557
+ />
1558
+ </svg>
1559
+ <span class="cpk-td__tool-name">${item.toolName}</span>
1560
+ ${item.result || Object.keys(item.arguments).length > 0 ? html`
1561
+ <span class="cpk-td__tool-status">DONE</span>
1562
+ ` : html`
1563
+ <span class="cpk-td__tool-status cpk-td__tool-status--pending">PENDING</span>
1564
+ `}
1565
+ <span class="cpk-td__tool-chevron">${expanded ? "▾" : "▸"}</span>
1566
+ </div>
1567
+ ${expanded ? html`
1568
+ <div class="cpk-td__tool-body">
1569
+ <div class="cpk-td__tool-section-label">Arguments</div>
1570
+ <pre class="cpk-td__tool-pre">
1571
+ ${unsafeHTML(highlightedJson(item.arguments))}</pre
1572
+ >
1573
+ ${item.result ? html`
1574
+ <div
1575
+ class="cpk-td__tool-section-label"
1576
+ style="margin-top:8px"
1577
+ >
1578
+ Result
1579
+ </div>
1580
+ <pre class="cpk-td__tool-pre">
1581
+ ${unsafeHTML(highlightedJson(item.result))}</pre
1582
+ >
1583
+ ` : nothing}
1584
+ </div>
1585
+ ` : nothing}
1586
+ </div>
1587
+ `;
1588
+ }
1589
+ renderToolGroup(group) {
1590
+ return html`
1591
+ <div class="cpk-td__tool-group">
1592
+ <div class="cpk-td__tool-group-header">
1593
+ ${group.items.length} tool call${group.items.length !== 1 ? "s" : ""}
1594
+ </div>
1595
+ ${group.items.map((tc) => this.renderToolBlock(tc))}
1596
+ </div>
1597
+ `;
1598
+ }
1599
+ renderGenerativeUI(item) {
1600
+ return html`
1601
+ <div class="cpk-td__genui">
1602
+ <div class="cpk-td__genui-badge">
1603
+ <svg width="9" height="9" viewBox="0 0 24 24" fill="currentColor">
1604
+ <path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" />
1605
+ </svg>
1606
+ Generative UI
1607
+ </div>
1608
+ <div class="cpk-td__genui-placeholder">
1609
+ ${item.activityType} — rendered in chat
1610
+ </div>
1611
+ </div>
1612
+ `;
1613
+ }
1614
+ renderState() {
1615
+ if (this._loadingState) return html`
1616
+ <div class="cpk-td__status">Loading state…</div>
1617
+ `;
1618
+ if (this._stateError) return html`<div class="cpk-td__status cpk-td__status--error">
1619
+ ${this._stateError}
1620
+ </div>`;
1621
+ if (this._stateNotAvailable) return html`
1622
+ <div class="cpk-td__empty-state">
1623
+ <svg
1624
+ width="28"
1625
+ height="28"
1626
+ viewBox="0 0 24 24"
1627
+ fill="none"
1628
+ stroke="currentColor"
1629
+ stroke-width="1.5"
1630
+ stroke-linecap="round"
1631
+ stroke-linejoin="round"
1632
+ >
1633
+ <ellipse cx="12" cy="5" rx="9" ry="3" />
1634
+ <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" />
1635
+ <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" />
1636
+ </svg>
1637
+ <span>State history not available</span>
1638
+ <span class="cpk-td__empty-hint"
1639
+ >This runtime doesn't yet expose per-thread agent state. Available when
1640
+ running against the in-memory runner.</span
1641
+ >
1642
+ </div>
1643
+ `;
1644
+ if (!this.hasRenderableState()) return html`
1645
+ <div class="cpk-td__empty-state">
1646
+ <svg
1647
+ width="28"
1648
+ height="28"
1649
+ viewBox="0 0 24 24"
1650
+ fill="none"
1651
+ stroke="currentColor"
1652
+ stroke-width="1.5"
1653
+ stroke-linecap="round"
1654
+ stroke-linejoin="round"
1655
+ >
1656
+ <ellipse cx="12" cy="5" rx="9" ry="3" />
1657
+ <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" />
1658
+ <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" />
1659
+ </svg>
1660
+ <span>No state captured</span>
1661
+ <span class="cpk-td__empty-hint"
1662
+ >Emitted live from STATE_SNAPSHOT events.</span
1663
+ >
1664
+ </div>
1665
+ `;
1666
+ const stateValue = this.activeState;
1667
+ return this.cachedPanelTpl("agent-state", [stateValue], () => {
1668
+ return html`<pre class="cpk-td__json-block">
1669
+ ${unsafeHTML(highlightedJson(stateValue))}</pre
1670
+ >`;
1671
+ });
1672
+ }
1673
+ renderEvents() {
1674
+ if (this._loadingEvents) return html`
1675
+ <div class="cpk-td__status">Loading events…</div>
1676
+ `;
1677
+ if (this._eventsError) return html`<div class="cpk-td__status cpk-td__status--error">
1678
+ ${this._eventsError}
1679
+ </div>`;
1680
+ if (this._eventsNotAvailable) return html`
1681
+ <div class="cpk-td__empty-state">
1682
+ <span>Event history not available</span>
1683
+ <span class="cpk-td__empty-hint"
1684
+ >This runtime doesn't yet expose per-thread AG-UI events. Available when
1685
+ running against the in-memory runner.</span
1686
+ >
1687
+ </div>
1688
+ `;
1689
+ const events = this.activeEvents;
1690
+ if (events.length === 0) return html`
1691
+ <div class="cpk-td__empty-state">
1692
+ <span>No events captured</span>
1693
+ <span class="cpk-td__empty-hint"
1694
+ >Events are recorded live. Run the agent to see them here.</span
1695
+ >
1696
+ </div>
1697
+ `;
1698
+ return this.cachedPanelTpl("ag-ui-events", [events], () => {
1699
+ return html`${events.map((event) => {
1700
+ const { bg, fg } = eventColors(event.type);
1701
+ return html`
1702
+ <div class="cpk-td__event">
1703
+ <div class="cpk-td__event-header" style="background:${bg}">
1704
+ <span class="cpk-td__event-type" style="color:${fg}"
1705
+ >${event.type}</span
1706
+ >
1707
+ <span class="cpk-td__event-time"
1708
+ >${formatTimestamp(event.timestamp)}</span
1709
+ >
1710
+ </div>
1711
+ <pre class="cpk-td__event-payload">
1712
+ ${unsafeHTML(highlightedJson(event.payload))}</pre
1713
+ >
1714
+ </div>
1715
+ `;
1716
+ })}`;
1717
+ });
1718
+ }
1719
+ renderPanelToggle() {
1720
+ return html`
1721
+ <button
1722
+ class="cpk-td__panel-toggle ${this._showDetailPanel ? "cpk-td__panel-toggle--active" : ""}"
1723
+ @click=${() => {
1724
+ this._showDetailPanel = !this._showDetailPanel;
1725
+ }}
1726
+ title="Toggle thread details"
1727
+ type="button"
1728
+ >
1729
+ <svg
1730
+ width="14"
1731
+ height="14"
1732
+ viewBox="0 0 24 24"
1733
+ fill="none"
1734
+ stroke="currentColor"
1735
+ stroke-width="2"
1736
+ stroke-linecap="round"
1737
+ stroke-linejoin="round"
1738
+ >
1739
+ <rect x="3" y="3" width="18" height="18" rx="2" />
1740
+ <line x1="15" y1="3" x2="15" y2="21" />
1741
+ </svg>
1742
+ </button>
1743
+ `;
1744
+ }
1745
+ renderDetailPanel() {
1746
+ const counts = this.activityCounts;
1747
+ return html`
1748
+ <!-- Thread -->
1749
+ <div class="cpk-tdp__section-title">Thread</div>
1750
+ <div class="cpk-tdp__row">
1751
+ <span class="cpk-tdp__label">ID</span>
1752
+ <span class="cpk-tdp__value cpk-tdp__value--wrap"
1753
+ >${this.shortId(this.thread?.id)}</span
1754
+ >
1755
+ </div>
1756
+ <div class="cpk-tdp__row">
1757
+ <span class="cpk-tdp__label">Name</span>
1758
+ <span class="cpk-tdp__value">${this.thread?.name ?? "—"}</span>
1759
+ </div>
1760
+ <div class="cpk-tdp__row">
1761
+ <span class="cpk-tdp__label">Agent</span>
1762
+ <span class="cpk-tdp__value cpk-tdp__value--truncate"
1763
+ >${this.thread?.agentId ?? "—"}</span
1764
+ >
1765
+ </div>
1766
+ <div class="cpk-tdp__row">
1767
+ <span class="cpk-tdp__label">Created by</span>
1768
+ <span class="cpk-tdp__value cpk-tdp__value--truncate"
1769
+ >${this.thread?.createdById ?? "—"}</span
1770
+ >
1771
+ </div>
1772
+
1773
+ <div class="cpk-tdp__divider"></div>
1774
+
1775
+ <!-- Timestamps -->
1776
+ <div class="cpk-tdp__section-title">Timestamps</div>
1777
+ <div class="cpk-tdp__row">
1778
+ <span class="cpk-tdp__label">Created</span>
1779
+ <span class="cpk-tdp__value">${this.fmtTime(this.thread?.createdAt)}</span>
1780
+ </div>
1781
+ <div class="cpk-tdp__row">
1782
+ <span class="cpk-tdp__label">Updated</span>
1783
+ <span class="cpk-tdp__value">${this.fmtTime(this.thread?.updatedAt)}</span>
1784
+ </div>
1785
+ <div class="cpk-tdp__row">
1786
+ <span class="cpk-tdp__label">Duration</span>
1787
+ <span class="cpk-tdp__value">${this.duration}</span>
1788
+ </div>
1789
+
1790
+ <div class="cpk-tdp__divider"></div>
1791
+
1792
+ <!-- Activity -->
1793
+ <div class="cpk-tdp__section-title">Activity</div>
1794
+ <div class="cpk-tdp__row">
1795
+ <span class="cpk-tdp__label">Messages</span>
1796
+ <span class="cpk-tdp__value">${counts.messages}</span>
1797
+ </div>
1798
+ <div class="cpk-tdp__row">
1799
+ <span class="cpk-tdp__label">Tool calls</span>
1800
+ <span class="cpk-tdp__value">${counts.toolCalls}</span>
1801
+ </div>
1802
+ <div class="cpk-tdp__row">
1803
+ <span class="cpk-tdp__label">AG-UI events</span>
1804
+ <span class="cpk-tdp__value">${this.activeEvents.length}</span>
1805
+ </div>
1806
+ `;
1807
+ }
1808
+ };
1809
+ if (!customElements.get("cpk-thread-list")) customElements.define("cpk-thread-list", CpkThreadList);
1810
+ if (!customElements.get("cpk-thread-details")) customElements.define("cpk-thread-details", ɵCpkThreadDetails);
1811
+ var WebInspectorElement = class extends LitElement {
1812
+ constructor(..._args3) {
1813
+ super(..._args3);
60
1814
  this._core = null;
61
1815
  this.coreSubscriber = null;
62
1816
  this.coreUnsubscribe = null;
@@ -66,6 +1820,8 @@ var WebInspectorElement = class extends LitElement {
66
1820
  this.agentSubscriptions = /* @__PURE__ */ new Map();
67
1821
  this.agentEvents = /* @__PURE__ */ new Map();
68
1822
  this.agentMessages = /* @__PURE__ */ new Map();
1823
+ this.agentRunThreadId = /* @__PURE__ */ new Map();
1824
+ this.liveMessageVersion = /* @__PURE__ */ new Map();
69
1825
  this.agentStates = /* @__PURE__ */ new Map();
70
1826
  this.flattenedEvents = [];
71
1827
  this.eventCounter = 0;
@@ -82,6 +1838,17 @@ var WebInspectorElement = class extends LitElement {
82
1838
  this.draggedDuringInteraction = false;
83
1839
  this.ignoreNextButtonClick = false;
84
1840
  this.selectedMenu = "ag-ui-events";
1841
+ this.selectedThreadId = null;
1842
+ this.threadListWidth = 290;
1843
+ this.threadDividerResizing = false;
1844
+ this.threadDividerPointerId = -1;
1845
+ this.threadDividerStartX = 0;
1846
+ this.threadDividerStartWidth = 0;
1847
+ this._threads = [];
1848
+ this._threadStoreSubscriptions = /* @__PURE__ */ new Map();
1849
+ this._threadsByAgent = /* @__PURE__ */ new Map();
1850
+ this._threadsErrorByAgent = /* @__PURE__ */ new Map();
1851
+ this._ownedThreadStores = /* @__PURE__ */ new Map();
85
1852
  this.contextMenuOpen = false;
86
1853
  this.dockMode = "floating";
87
1854
  this.previousBodyMargins = null;
@@ -94,15 +1861,20 @@ var WebInspectorElement = class extends LitElement {
94
1861
  this.toolSignature = "";
95
1862
  this.eventFilterText = "";
96
1863
  this.eventTypeFilter = "all";
97
- this.announcementMarkdown = null;
1864
+ this.evtColWidths = [
1865
+ 100,
1866
+ 80,
1867
+ 150
1868
+ ];
1869
+ this._evtColResize = null;
98
1870
  this.announcementHtml = null;
99
1871
  this.announcementTimestamp = null;
100
1872
  this.announcementPreviewText = null;
101
1873
  this.hasUnseenAnnouncement = false;
102
1874
  this.announcementLoaded = false;
103
- this.announcementLoadError = null;
104
1875
  this.announcementPromise = null;
105
1876
  this.showAnnouncementPreview = true;
1877
+ this.announcementExpanded = false;
106
1878
  this.contextState = {
107
1879
  button: {
108
1880
  position: {
@@ -143,28 +1915,7 @@ var WebInspectorElement = class extends LitElement {
143
1915
  this.resizeStart = null;
144
1916
  this.resizeInitialSize = null;
145
1917
  this.isResizing = false;
146
- this.menuItems = [
147
- {
148
- key: "ag-ui-events",
149
- label: "AG-UI Events",
150
- icon: "Zap"
151
- },
152
- {
153
- key: "agents",
154
- label: "Agent",
155
- icon: "Bot"
156
- },
157
- {
158
- key: "frontend-tools",
159
- label: "Frontend Tools",
160
- icon: "Hammer"
161
- },
162
- {
163
- key: "agent-context",
164
- label: "Context",
165
- icon: "FileText"
166
- }
167
- ];
1918
+ this.customTabIcons = { threads: `<svg class="h-3.5 w-3.5" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.04167 15C8.29167 15 7.65972 14.7431 7.14583 14.2292C6.63194 13.7153 6.375 13.0972 6.375 12.375C6.375 11.3194 6.80208 10.3646 7.65625 9.51042C8.51042 8.65625 9.57639 8.125 10.8542 7.91667C10.8125 7.41667 10.6875 7.03819 10.4792 6.78125C10.2708 6.52431 9.98611 6.39583 9.625 6.39583C9.20833 6.39583 8.75694 6.56944 8.27083 6.91667C7.78472 7.26389 7.20833 7.83333 6.54167 8.625C5.45833 9.91667 4.66319 10.7569 4.15625 11.1458C3.64931 11.5347 3.10417 11.7292 2.52083 11.7292C1.8125 11.7292 1.21528 11.4653 0.729167 10.9375C0.243056 10.4097 0 9.77083 0 9.02083C0 8.27083 0.163194 7.50347 0.489583 6.71875C0.815972 5.93403 1.36806 4.99306 2.14583 3.89583C2.40972 3.53472 2.60417 3.22917 2.72917 2.97917C2.85417 2.72917 2.91667 2.52778 2.91667 2.375C2.91667 2.27778 2.89931 2.20486 2.86458 2.15625C2.82986 2.10764 2.77778 2.08333 2.70833 2.08333C2.56944 2.08333 2.39583 2.17014 2.1875 2.34375C1.97917 2.51736 1.73611 2.78472 1.45833 3.14583L0 1.66667C0.444444 1.125 0.895833 0.711806 1.35417 0.427083C1.8125 0.142361 2.26389 0 2.70833 0C3.34722 0 3.88889 0.222222 4.33333 0.666667C4.77778 1.11111 5 1.66667 5 2.33333C5 2.73611 4.89583 3.18056 4.6875 3.66667C4.47917 4.15278 4.13194 4.73611 3.64583 5.41667C3.11806 6.16667 2.72569 6.82639 2.46875 7.39583C2.21181 7.96528 2.08333 8.46528 2.08333 8.89583C2.08333 9.13194 2.12153 9.31597 2.19792 9.44792C2.27431 9.57986 2.38194 9.64583 2.52083 9.64583C2.65972 9.64583 2.78125 9.60764 2.88542 9.53125C2.98958 9.45486 3.18056 9.27083 3.45833 8.97917C3.63889 8.78472 3.85417 8.54514 4.10417 8.26042C4.35417 7.97569 4.65972 7.625 5.02083 7.20833C5.89583 6.16667 6.6875 5.42361 7.39583 4.97917C8.10417 4.53472 8.84722 4.3125 9.625 4.3125C10.5556 4.3125 11.3194 4.625 11.9167 5.25C12.5139 5.875 12.8542 6.72917 12.9375 7.8125H15V9.89583H12.9375C12.8264 11.4514 12.4201 12.691 11.7188 13.6146C11.0174 14.5382 10.125 15 9.04167 15ZM9.08333 12.9167C9.52778 12.9167 9.90278 12.6632 10.2083 12.1562C10.5139 11.6493 10.7222 10.9444 10.8333 10.0417C10.1944 10.1944 9.63889 10.4965 9.16667 10.9479C8.69444 11.3993 8.45833 11.8472 8.45833 12.2917C8.45833 12.4861 8.51389 12.6389 8.625 12.75C8.73611 12.8611 8.88889 12.9167 9.08333 12.9167Z" fill="currentColor"/></svg>` };
168
1919
  this.handlePointerDown = (event) => {
169
1920
  if (this.dockMode !== "floating" && this.isOpen) return;
170
1921
  const target = event.currentTarget;
@@ -329,6 +2080,26 @@ var WebInspectorElement = class extends LitElement {
329
2080
  this.expandedTools = /* @__PURE__ */ new Set();
330
2081
  this.expandedContextItems = /* @__PURE__ */ new Set();
331
2082
  this.copiedContextItems = /* @__PURE__ */ new Set();
2083
+ this.handleThreadDividerPointerDown = (event) => {
2084
+ this.threadDividerResizing = true;
2085
+ this.threadDividerPointerId = event.pointerId;
2086
+ this.threadDividerStartX = event.clientX;
2087
+ this.threadDividerStartWidth = this.threadListWidth;
2088
+ event.currentTarget.setPointerCapture(event.pointerId);
2089
+ event.preventDefault();
2090
+ };
2091
+ this.handleThreadDividerPointerMove = (event) => {
2092
+ if (!this.threadDividerResizing || this.threadDividerPointerId !== event.pointerId) return;
2093
+ const delta = event.clientX - this.threadDividerStartX;
2094
+ this.threadListWidth = Math.max(180, Math.min(480, this.threadDividerStartWidth + delta));
2095
+ this.requestUpdate();
2096
+ };
2097
+ this.handleThreadDividerPointerUp = (event) => {
2098
+ if (this.threadDividerPointerId !== event.pointerId) return;
2099
+ const target = event.currentTarget;
2100
+ if (target.hasPointerCapture(this.threadDividerPointerId)) target.releasePointerCapture(this.threadDividerPointerId);
2101
+ this.threadDividerResizing = false;
2102
+ };
332
2103
  this.handleClearEvents = () => {
333
2104
  if (this.selectedContext === "all-agents") {
334
2105
  this.agentEvents.clear();
@@ -353,6 +2124,31 @@ var WebInspectorElement = class extends LitElement {
353
2124
  this.handleDismissAnnouncement = () => {
354
2125
  this.markAnnouncementSeen();
355
2126
  };
2127
+ this.copyResetTimeouts = /* @__PURE__ */ new WeakMap();
2128
+ this.handleAnnouncementContentClick = (event) => {
2129
+ const button = (event.target instanceof HTMLElement ? event.target : null)?.closest(".announcement-code__copy");
2130
+ if (!(button instanceof HTMLButtonElement)) return;
2131
+ event.preventDefault();
2132
+ event.stopPropagation();
2133
+ const encoded = button.getAttribute("data-copy") ?? "";
2134
+ const code = this.decodeBase64(encoded);
2135
+ if (!code) return;
2136
+ const showCopied = () => {
2137
+ const existing = this.copyResetTimeouts.get(button);
2138
+ if (existing !== void 0) window.clearTimeout(existing);
2139
+ button.setAttribute("data-copied", "true");
2140
+ button.setAttribute("aria-label", "Code copied");
2141
+ button.textContent = "Copied";
2142
+ const id = window.setTimeout(() => {
2143
+ button.removeAttribute("data-copied");
2144
+ button.setAttribute("aria-label", "Copy code");
2145
+ button.textContent = "Copy";
2146
+ this.copyResetTimeouts.delete(button);
2147
+ }, 1500);
2148
+ this.copyResetTimeouts.set(button, id);
2149
+ };
2150
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) navigator.clipboard.writeText(code).then(showCopied, () => {});
2151
+ };
356
2152
  }
357
2153
  static {
358
2154
  this.properties = {
@@ -374,6 +2170,106 @@ var WebInspectorElement = class extends LitElement {
374
2170
  this.requestUpdate("core", oldValue);
375
2171
  if (this._core) this.attachToCore(this._core);
376
2172
  }
2173
+ get menuItems() {
2174
+ return [
2175
+ {
2176
+ key: "ag-ui-events",
2177
+ label: "AG-UI Events",
2178
+ icon: "Zap"
2179
+ },
2180
+ {
2181
+ key: "agents",
2182
+ label: "Agent",
2183
+ icon: "Bot"
2184
+ },
2185
+ ...(this._core?.tools?.length ?? 0) > 0 ? [{
2186
+ key: "frontend-tools",
2187
+ label: "Frontend Tools",
2188
+ icon: "Hammer"
2189
+ }] : [],
2190
+ {
2191
+ key: "agent-context",
2192
+ label: "Context",
2193
+ icon: "FileText"
2194
+ },
2195
+ {
2196
+ key: "threads",
2197
+ label: "Threads",
2198
+ icon: "MessageSquare"
2199
+ }
2200
+ ];
2201
+ }
2202
+ subscribeToThreadStore(agentId, store) {
2203
+ if (this._threadStoreSubscriptions.has(agentId)) return;
2204
+ const threadsSub = store.select(ɵselectThreads).subscribe((threads) => {
2205
+ this._threadsByAgent.set(agentId, threads);
2206
+ this._threads = Array.from(this._threadsByAgent.values()).flat();
2207
+ this.autoSelectLatestThread();
2208
+ this.requestUpdate();
2209
+ });
2210
+ const errorSub = store.select(ɵselectThreadsError).subscribe((error) => {
2211
+ if (error) this._threadsErrorByAgent.set(agentId, error);
2212
+ else this._threadsErrorByAgent.delete(agentId);
2213
+ this.requestUpdate();
2214
+ });
2215
+ this._threadStoreSubscriptions.set(agentId, () => {
2216
+ threadsSub.unsubscribe();
2217
+ errorSub.unsubscribe();
2218
+ });
2219
+ const initialState = store.getState();
2220
+ this._threadsByAgent.set(agentId, ɵselectThreads(initialState));
2221
+ const initialError = ɵselectThreadsError(initialState);
2222
+ if (initialError) this._threadsErrorByAgent.set(agentId, initialError);
2223
+ else this._threadsErrorByAgent.delete(agentId);
2224
+ this._threads = Array.from(this._threadsByAgent.values()).flat();
2225
+ this.autoSelectLatestThread();
2226
+ }
2227
+ autoSelectLatestThread() {
2228
+ if (this._threads.length === 0) return;
2229
+ if (!(this.selectedThreadId != null && this._threads.some((t) => t.id === this.selectedThreadId))) this.selectedThreadId = this._threads[0].id;
2230
+ }
2231
+ teardownThreadStoreSubscriptions() {
2232
+ for (const unsub of this._threadStoreSubscriptions.values()) unsub();
2233
+ this._threadStoreSubscriptions.clear();
2234
+ this._threadsByAgent.clear();
2235
+ this._threadsErrorByAgent.clear();
2236
+ this._threads = [];
2237
+ }
2238
+ ensureOwnedThreadStore(agentId) {
2239
+ if (this._ownedThreadStores.has(agentId)) return;
2240
+ if (this.core?.getThreadStore(agentId)) return;
2241
+ const core = this.core;
2242
+ if (!core?.runtimeUrl) return;
2243
+ const store = ɵcreateThreadStore({ fetch: globalThis.fetch });
2244
+ store.start();
2245
+ store.setContext({
2246
+ runtimeUrl: core.runtimeUrl,
2247
+ headers: {},
2248
+ agentId
2249
+ });
2250
+ this._ownedThreadStores.set(agentId, store);
2251
+ this.subscribeToThreadStore(agentId, store);
2252
+ core.registerThreadStore(agentId, store);
2253
+ }
2254
+ refreshOwnedThreadStore(agentId) {
2255
+ const store = this._ownedThreadStores.get(agentId);
2256
+ if (!store) return;
2257
+ store.refresh();
2258
+ }
2259
+ removeOwnedThreadStore(agentId) {
2260
+ const store = this._ownedThreadStores.get(agentId);
2261
+ if (!store) return;
2262
+ store.stop();
2263
+ this.core?.unregisterThreadStore(agentId);
2264
+ this._ownedThreadStores.delete(agentId);
2265
+ }
2266
+ teardownOwnedThreadStores() {
2267
+ for (const [agentId, store] of this._ownedThreadStores) {
2268
+ store.stop();
2269
+ this.core?.unregisterThreadStore(agentId);
2270
+ }
2271
+ this._ownedThreadStores.clear();
2272
+ }
377
2273
  attachToCore(core) {
378
2274
  this.runtimeStatus = core.runtimeConnectionStatus;
379
2275
  this.coreProperties = core.properties;
@@ -381,6 +2277,11 @@ var WebInspectorElement = class extends LitElement {
381
2277
  this.coreSubscriber = {
382
2278
  onRuntimeConnectionStatusChanged: ({ status }) => {
383
2279
  this.runtimeStatus = status;
2280
+ if (status === "connected") for (const agentId of this._ownedThreadStores.keys()) this.refreshOwnedThreadStore(agentId);
2281
+ else {
2282
+ this._threadsByAgent.clear();
2283
+ this._threads = [];
2284
+ }
384
2285
  this.requestUpdate();
385
2286
  },
386
2287
  onPropertiesChanged: ({ properties }) => {
@@ -397,16 +2298,36 @@ var WebInspectorElement = class extends LitElement {
397
2298
  onAgentsChanged: ({ agents }) => {
398
2299
  this.processAgentsChanged(agents);
399
2300
  },
2301
+ onContextChanged: ({ context }) => {
2302
+ this.contextStore = this.normalizeContextStore(context);
2303
+ this.requestUpdate();
2304
+ },
2305
+ onThreadStoreRegistered: ({ agentId, store }) => {
2306
+ this.subscribeToThreadStore(agentId, store);
2307
+ this.requestUpdate();
2308
+ },
2309
+ onThreadStoreUnregistered: ({ agentId }) => {
2310
+ const unsub = this._threadStoreSubscriptions.get(agentId);
2311
+ if (unsub) {
2312
+ unsub();
2313
+ this._threadStoreSubscriptions.delete(agentId);
2314
+ }
2315
+ this._threadsByAgent.delete(agentId);
2316
+ this._threadsErrorByAgent.delete(agentId);
2317
+ this._threads = Array.from(this._threadsByAgent.values()).flat();
2318
+ this.requestUpdate();
2319
+ },
400
2320
  onAgentRunStarted: ({ agent }) => {
401
- if (agent?.agentId) this.subscribeToAgent(agent);
402
- },
403
- onContextChanged: ({ context }) => {
404
- this.contextStore = this.normalizeContextStore(context);
2321
+ this.subscribeToAgent(agent);
2322
+ const runThreadId = agent.threadId;
2323
+ if (agent.agentId && runThreadId) this.agentRunThreadId.set(agent.agentId, runThreadId);
405
2324
  this.requestUpdate();
406
2325
  }
407
2326
  };
408
2327
  this.coreUnsubscribe = core.subscribe(this.coreSubscriber).unsubscribe;
409
2328
  this.processAgentsChanged(core.agents);
2329
+ const threadStores = typeof core.getThreadStores === "function" ? core.getThreadStores() : {};
2330
+ for (const [agentId, store] of Object.entries(threadStores)) this.subscribeToThreadStore(agentId, store);
410
2331
  if (core.context) this.contextStore = this.normalizeContextStore(core.context);
411
2332
  }
412
2333
  detachFromCore() {
@@ -421,6 +2342,8 @@ var WebInspectorElement = class extends LitElement {
421
2342
  this.cachedTools = [];
422
2343
  this.toolSignature = "";
423
2344
  this.teardownAgentSubscriptions();
2345
+ this.teardownThreadStoreSubscriptions();
2346
+ this.teardownOwnedThreadStores();
424
2347
  }
425
2348
  teardownAgentSubscriptions() {
426
2349
  for (const unsubscribe of this.agentSubscriptions.values()) unsubscribe();
@@ -437,6 +2360,7 @@ var WebInspectorElement = class extends LitElement {
437
2360
  if (!agent?.agentId) continue;
438
2361
  seenAgentIds.add(agent.agentId);
439
2362
  this.subscribeToAgent(agent);
2363
+ this.ensureOwnedThreadStore(agent.agentId);
440
2364
  }
441
2365
  for (const agentId of Array.from(this.agentSubscriptions.keys())) if (!seenAgentIds.has(agentId)) {
442
2366
  this.unsubscribeFromAgent(agentId);
@@ -495,6 +2419,7 @@ var WebInspectorElement = class extends LitElement {
495
2419
  event,
496
2420
  result
497
2421
  });
2422
+ this.refreshOwnedThreadStore(agentId);
498
2423
  },
499
2424
  onRunErrorEvent: ({ event }) => {
500
2425
  this.recordAgentEvent(agentId, "RUN_ERROR", event);
@@ -582,6 +2507,14 @@ var WebInspectorElement = class extends LitElement {
582
2507
  },
583
2508
  onReasoningEncryptedValueEvent: ({ event }) => {
584
2509
  this.recordAgentEvent(agentId, "REASONING_ENCRYPTED_VALUE", event);
2510
+ },
2511
+ onActivitySnapshotEvent: ({ event }) => {
2512
+ this.recordAgentEvent(agentId, "ACTIVITY_SNAPSHOT", event);
2513
+ this.syncAgentMessages(agent);
2514
+ },
2515
+ onActivityDeltaEvent: ({ event }) => {
2516
+ this.recordAgentEvent(agentId, "ACTIVITY_DELTA", event);
2517
+ this.syncAgentMessages(agent);
585
2518
  }
586
2519
  });
587
2520
  this.agentSubscriptions.set(agentId, unsubscribe);
@@ -596,6 +2529,15 @@ var WebInspectorElement = class extends LitElement {
596
2529
  this.agentSubscriptions.delete(agentId);
597
2530
  }
598
2531
  }
2532
+ mapMessagesToConversation(messages) {
2533
+ if (!messages) return null;
2534
+ return messages.filter((m) => m.role === "user" || m.role === "assistant" || m.role === "activity").map((m, i) => ({
2535
+ id: m.id ?? `msg-${i}`,
2536
+ type: m.role === "user" ? "user" : m.role === "activity" ? "generative-ui" : "assistant",
2537
+ content: m.role === "activity" ? m.activityType ?? "unknown" : m.contentText,
2538
+ createdAt: ""
2539
+ }));
2540
+ }
599
2541
  recordAgentEvent(agentId, type, payload) {
600
2542
  const eventId = `${agentId}:${++this.eventCounter}`;
601
2543
  const normalizedPayload = this.normalizeEventPayload(type, payload);
@@ -618,6 +2560,8 @@ var WebInspectorElement = class extends LitElement {
618
2560
  const messages = this.normalizeAgentMessages(agent.messages);
619
2561
  if (messages) this.agentMessages.set(agent.agentId, messages);
620
2562
  else this.agentMessages.delete(agent.agentId);
2563
+ const runThreadId = this.agentRunThreadId.get(agent.agentId);
2564
+ if (runThreadId) this.liveMessageVersion.set(runThreadId, (this.liveMessageVersion.get(runThreadId) ?? 0) + 1);
621
2565
  this.requestUpdate();
622
2566
  } catch (error) {
623
2567
  console.error(`[CopilotKit Inspector] Failed to sync messages for agent "${agent.agentId}":`, error);
@@ -645,18 +2589,23 @@ var WebInspectorElement = class extends LitElement {
645
2589
  if (this.contextOptions.length !== nextOptions.length || this.contextOptions.some((option, index) => option.key !== nextOptions[index]?.key)) this.contextOptions = nextOptions;
646
2590
  const pendingContext = this.pendingSelectedContext;
647
2591
  if (pendingContext) {
648
- if (pendingContext === "all-agents" || agentIds.has(pendingContext)) {
2592
+ if ((pendingContext === "all-agents" || agentIds.has(pendingContext)) && (pendingContext === "all-agents" || agentIds.size === 1)) {
649
2593
  if (this.selectedContext !== pendingContext) {
650
2594
  this.selectedContext = pendingContext;
651
2595
  this.expandedRows.clear();
652
2596
  }
653
2597
  this.pendingSelectedContext = null;
654
- } else if (agentIds.size > 0) this.pendingSelectedContext = null;
2598
+ } else if (agentIds.size > 0) {
2599
+ if (this.selectedContext !== "all-agents") {
2600
+ this.selectedContext = "all-agents";
2601
+ this.expandedRows.clear();
2602
+ }
2603
+ this.pendingSelectedContext = null;
2604
+ }
655
2605
  }
656
2606
  if (!nextOptions.some((option) => option.key === this.selectedContext) && this.pendingSelectedContext === null) {
657
2607
  let nextSelected = "all-agents";
658
- if (agentIds.has("default")) nextSelected = "default";
659
- else if (agentIds.size > 0) nextSelected = Array.from(agentIds).sort((a, b) => a.localeCompare(b))[0];
2608
+ if (agentIds.size === 1) nextSelected = Array.from(agentIds)[0];
660
2609
  if (this.selectedContext !== nextSelected) {
661
2610
  this.selectedContext = nextSelected;
662
2611
  this.expandedRows.clear();
@@ -831,6 +2780,7 @@ ${argsString}</pre
831
2780
  z-index: 2147483646;
832
2781
  display: block;
833
2782
  will-change: transform;
2783
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
834
2784
  }
835
2785
 
836
2786
  :host([data-transitioning="true"]) {
@@ -886,13 +2836,14 @@ ${argsString}</pre
886
2836
  left: 50%;
887
2837
  transform: translateX(-50%) translateY(-4px);
888
2838
  white-space: nowrap;
889
- background: rgba(17, 24, 39, 0.95);
2839
+ background: rgba(1, 5, 7, 0.95);
890
2840
  color: white;
891
2841
  padding: 4px 8px;
892
2842
  border-radius: 6px;
893
2843
  font-size: 10px;
2844
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
894
2845
  line-height: 1.2;
895
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
2846
+ box-shadow: 0 4px 10px rgba(1, 5, 7, 0.18);
896
2847
  opacity: 0;
897
2848
  pointer-events: none;
898
2849
  transition:
@@ -913,18 +2864,19 @@ ${argsString}</pre
913
2864
  min-width: 300px;
914
2865
  max-width: 300px;
915
2866
  background: white;
916
- color: #111827;
2867
+ color: #010507;
917
2868
  font-size: 13px;
2869
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
918
2870
  line-height: 1.4;
919
2871
  border-radius: 12px;
920
- box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
2872
+ box-shadow: 0 12px 28px rgba(1, 5, 7, 0.12);
921
2873
  padding: 10px 12px;
922
2874
  display: inline-flex;
923
2875
  align-items: flex-start;
924
2876
  gap: 8px;
925
2877
  z-index: 4500;
926
2878
  animation: fade-slide-in 160ms ease;
927
- border: 1px solid rgba(148, 163, 184, 0.35);
2879
+ border: 1px solid rgba(219, 219, 229, 0.4);
928
2880
  white-space: normal;
929
2881
  word-break: break-word;
930
2882
  text-align: left;
@@ -945,7 +2897,7 @@ ${argsString}</pre
945
2897
  width: 10px;
946
2898
  height: 10px;
947
2899
  background: white;
948
- border: 1px solid rgba(148, 163, 184, 0.35);
2900
+ border: 1px solid rgba(219, 219, 229, 0.4);
949
2901
  transform: rotate(45deg);
950
2902
  top: 50%;
951
2903
  margin-top: -5px;
@@ -954,81 +2906,564 @@ ${argsString}</pre
954
2906
 
955
2907
  .announcement-preview[data-side="left"] .announcement-preview__arrow {
956
2908
  right: -5px;
957
- box-shadow: 6px -6px 10px rgba(15, 23, 42, 0.12);
2909
+ box-shadow: 6px -6px 10px rgba(1, 5, 7, 0.08);
958
2910
  }
959
2911
 
960
2912
  .announcement-preview[data-side="right"] .announcement-preview__arrow {
961
2913
  left: -5px;
962
- box-shadow: -6px 6px 10px rgba(15, 23, 42, 0.12);
2914
+ box-shadow: -6px 6px 10px rgba(1, 5, 7, 0.08);
963
2915
  }
964
2916
 
965
2917
  .announcement-dismiss {
966
- color: #6b7280;
967
- font-size: 12px;
968
- padding: 2px 8px;
969
- border-radius: 8px;
970
- border: 1px solid rgba(148, 163, 184, 0.5);
971
- background: rgba(248, 250, 252, 0.9);
2918
+ background: none;
2919
+ border: none;
2920
+ cursor: pointer;
2921
+ color: #838389;
2922
+ width: 28px;
2923
+ height: 28px;
2924
+ display: flex;
2925
+ align-items: center;
2926
+ justify-content: center;
2927
+ border-radius: 6px;
2928
+ padding: 0;
972
2929
  transition:
973
2930
  background 120ms ease,
974
2931
  color 120ms ease;
975
2932
  }
976
2933
 
977
2934
  .announcement-dismiss:hover {
978
- background: rgba(241, 245, 249, 1);
979
- color: #111827;
2935
+ background: rgba(0, 0, 0, 0.06);
2936
+ color: #010507;
2937
+ }
2938
+
2939
+ /* ── Agent tab section cards ─────────────────────────────────────── */
2940
+ .cpk-section-card {
2941
+ border-radius: 8px;
2942
+ background: #ffffff;
2943
+ overflow: hidden;
2944
+ }
2945
+
2946
+ /* ── Agent icon bubble ───────────────────────────────────────────── */
2947
+ .cpk-agent-icon {
2948
+ background-color: #f0f0f4 !important;
2949
+ color: #57575b !important;
2950
+ }
2951
+
2952
+ /* ── Agent stat cards ────────────────────────────────────────────── */
2953
+ .cpk-stat-card {
2954
+ background-color: #ffffff !important;
2955
+ border: 1px solid #dbdbe5 !important;
2956
+ }
2957
+ button.cpk-stat-card:hover {
2958
+ background-color: #f7f7f9 !important;
2959
+ }
2960
+
2961
+ /* ── Circle chevron (Frontend Tools + Context) ──────────────────── */
2962
+ .cpk-chevron-circle {
2963
+ display: inline-flex;
2964
+ align-items: center;
2965
+ justify-content: center;
2966
+ width: 24px;
2967
+ height: 24px;
2968
+ border-radius: 50%;
2969
+ background-color: #f0f0f4;
2970
+ color: #838389;
2971
+ flex-shrink: 0;
2972
+ transition: transform 0.2s;
2973
+ }
2974
+ .cpk-chevron-circle svg {
2975
+ width: 14px !important;
2976
+ height: 14px !important;
2977
+ }
2978
+ .cpk-chevron-circle--open {
2979
+ transform: rotate(180deg);
2980
+ }
2981
+
2982
+ /* ── Inline copy button ─────────────────────────────────────────── */
2983
+ .cpk-copy-btn {
2984
+ font-size: 10px;
2985
+ font-weight: 500;
2986
+ color: #57575b;
2987
+ background: #ffffff;
2988
+ border: 1px solid #dbdbe5;
2989
+ cursor: pointer;
2990
+ padding: 2px 8px;
2991
+ border-radius: 4px;
2992
+ flex-shrink: 0;
2993
+ transition:
2994
+ background-color 0.15s,
2995
+ border-color 0.15s;
2996
+ }
2997
+ .cpk-copy-btn:hover {
2998
+ background-color: #f0f0f4;
2999
+ border-color: #afafb7;
3000
+ }
3001
+
3002
+ .cpk-section-header {
3003
+ background: #e8edf5;
3004
+ border-bottom: 1px solid rgba(0, 0, 0, 0.08);
3005
+ padding: 10px 16px;
3006
+ }
3007
+ .cpk-section-header h4 {
3008
+ font-size: 11px;
3009
+ font-weight: 600;
3010
+ color: #181c1f;
3011
+ margin: 0;
3012
+ }
3013
+
3014
+ /* Inputs/selects inside the lavender header need an explicit white bg */
3015
+ .cpk-section-header input,
3016
+ .cpk-section-header select {
3017
+ background-color: #ffffff !important;
3018
+ box-shadow: none !important;
3019
+ }
3020
+ .cpk-section-header select {
3021
+ padding-right: 24px !important;
3022
+ }
3023
+ /* Events table column headers */
3024
+ table thead th {
3025
+ font-weight: 600 !important;
980
3026
  }
981
3027
 
982
3028
  .announcement-content {
983
- color: #111827;
984
- font-size: 14px;
985
- line-height: 1.6;
3029
+ color: #1f2230;
3030
+ font-size: 13px;
3031
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
3032
+ line-height: 1.55;
986
3033
  }
987
3034
 
988
3035
  .announcement-content h1,
989
3036
  .announcement-content h2,
990
3037
  .announcement-content h3 {
3038
+ color: #010507;
991
3039
  font-weight: 700;
992
- margin: 0.4rem 0 0.2rem;
3040
+ line-height: 1.3;
3041
+ margin: 0.9rem 0 0.4rem;
3042
+ }
3043
+ .announcement-content > h1:first-child,
3044
+ .announcement-content > h2:first-child,
3045
+ .announcement-content > h3:first-child {
3046
+ margin-top: 0;
993
3047
  }
994
3048
 
995
3049
  .announcement-content h1 {
996
- font-size: 1.1rem;
3050
+ font-size: 1.15rem;
3051
+ letter-spacing: -0.01em;
997
3052
  }
998
-
999
3053
  .announcement-content h2 {
1000
3054
  font-size: 1rem;
1001
3055
  }
1002
-
1003
3056
  .announcement-content h3 {
1004
- font-size: 0.95rem;
3057
+ font-size: 0.9rem;
3058
+ text-transform: none;
1005
3059
  }
1006
3060
 
1007
3061
  .announcement-content p {
1008
- margin: 0.25rem 0;
3062
+ margin: 0.45rem 0;
3063
+ }
3064
+
3065
+ .announcement-content strong {
3066
+ color: #010507;
3067
+ font-weight: 700;
1009
3068
  }
1010
3069
 
1011
3070
  .announcement-content ul {
1012
3071
  list-style: disc;
1013
3072
  padding-left: 1.25rem;
1014
- margin: 0.3rem 0;
3073
+ margin: 0.45rem 0;
1015
3074
  }
1016
3075
 
1017
3076
  .announcement-content ol {
1018
3077
  list-style: decimal;
1019
3078
  padding-left: 1.25rem;
1020
- margin: 0.3rem 0;
3079
+ margin: 0.45rem 0;
3080
+ }
3081
+
3082
+ .announcement-content li + li {
3083
+ margin-top: 0.15rem;
1021
3084
  }
1022
3085
 
1023
3086
  .announcement-content a {
1024
- color: #0f766e;
3087
+ color: #757cf2;
1025
3088
  text-decoration: underline;
1026
3089
  }
3090
+
3091
+ .announcement-content :not(pre) > code {
3092
+ background: #f3f3f7;
3093
+ border: 1px solid #e4e4ec;
3094
+ border-radius: 4px;
3095
+ padding: 1px 5px;
3096
+ font-size: 0.85em;
3097
+ color: #4a3a8a;
3098
+ }
3099
+
3100
+ .announcement-code {
3101
+ position: relative;
3102
+ margin: 0.6rem 0;
3103
+ }
3104
+
3105
+ .announcement-code pre {
3106
+ background: #0f1117;
3107
+ color: #e6e8f2;
3108
+ border-radius: 8px;
3109
+ padding: 10px 12px;
3110
+ overflow-x: auto;
3111
+ font-size: 12px;
3112
+ line-height: 1.5;
3113
+ white-space: pre;
3114
+ }
3115
+
3116
+ .announcement-code pre code::after {
3117
+ content: "";
3118
+ display: inline-block;
3119
+ width: 80px;
3120
+ }
3121
+
3122
+ .announcement-code__copy-shield {
3123
+ position: absolute;
3124
+ top: 4px;
3125
+ right: 4px;
3126
+ padding: 4px 4px 4px 24px;
3127
+ border-top-right-radius: 8px;
3128
+ background: linear-gradient(
3129
+ to right,
3130
+ rgba(15, 17, 23, 0) 0%,
3131
+ rgba(15, 17, 23, 0.95) 40%,
3132
+ #0f1117 100%
3133
+ );
3134
+ pointer-events: none;
3135
+ }
3136
+
3137
+ .announcement-code pre code {
3138
+ background: transparent;
3139
+ border: none;
3140
+ padding: 0;
3141
+ color: inherit;
3142
+ font-size: inherit;
3143
+ }
3144
+
3145
+ .announcement-code pre::-webkit-scrollbar {
3146
+ height: 6px;
3147
+ }
3148
+ .announcement-code pre::-webkit-scrollbar-track {
3149
+ background: transparent;
3150
+ }
3151
+ .announcement-code pre::-webkit-scrollbar-thumb {
3152
+ background: rgba(255, 255, 255, 0.2);
3153
+ border-radius: 3px;
3154
+ }
3155
+
3156
+ .announcement-code__copy {
3157
+ position: relative;
3158
+ pointer-events: auto;
3159
+ padding: 3px 8px;
3160
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
3161
+ font-size: 11px;
3162
+ font-weight: 600;
3163
+ color: #e6e8f2;
3164
+ background: #1f222d;
3165
+ border: 1px solid rgba(255, 255, 255, 0.15);
3166
+ border-radius: 5px;
3167
+ cursor: pointer;
3168
+ transition:
3169
+ background 0.12s ease,
3170
+ color 0.12s ease;
3171
+ }
3172
+ .announcement-code__copy:hover {
3173
+ background: #2a2e3c;
3174
+ }
3175
+ .announcement-code__copy[data-copied="true"] {
3176
+ background: #eee6fe;
3177
+ color: #6430ab;
3178
+ border-color: transparent;
3179
+ }
3180
+
3181
+ .announcement-body {
3182
+ position: relative;
3183
+ overflow: hidden;
3184
+ transition: max-height 0.25s ease;
3185
+ }
3186
+ .announcement-body--collapsed {
3187
+ max-height: 72px;
3188
+ }
3189
+ .announcement-body--expanded {
3190
+ max-height: 2000px;
3191
+ }
3192
+ .announcement-fade {
3193
+ position: absolute;
3194
+ bottom: 0;
3195
+ left: 0;
3196
+ right: 0;
3197
+ height: 48px;
3198
+ background: linear-gradient(to bottom, transparent, #ffffff);
3199
+ pointer-events: none;
3200
+ }
3201
+ .announcement-toggle {
3202
+ display: block;
3203
+ width: 100%;
3204
+ margin-top: 6px;
3205
+ padding: 0;
3206
+ background: none;
3207
+ border: none;
3208
+ font-family: "Plus Jakarta Sans", system-ui, sans-serif;
3209
+ font-size: 12px;
3210
+ font-weight: 500;
3211
+ color: #757cf2;
3212
+ cursor: pointer;
3213
+ text-align: center;
3214
+ }
3215
+ .announcement-toggle:hover {
3216
+ color: #6430ab;
3217
+ }
3218
+
3219
+ /* ── Brand typography ────────────────────────────────────────── */
3220
+ /* Override Tailwind font-mono stack → Spline Sans Mono */
3221
+ .font-mono,
3222
+ pre,
3223
+ code {
3224
+ font-family: "Spline Sans Mono", ui-monospace, "Cascadia Code", monospace;
3225
+ }
3226
+
3227
+ /* ── Floating button ─────────────────────────────────────────── */
3228
+ .console-button {
3229
+ background-color: rgba(1, 5, 7, 0.95) !important;
3230
+ border-color: rgba(190, 194, 255, 0.25) !important;
3231
+ box-shadow:
3232
+ 0 0 0 1px rgba(190, 194, 255, 0.15),
3233
+ 0 4px 14px rgba(1, 5, 7, 0.28) !important;
3234
+ }
3235
+ .console-button:hover {
3236
+ background-color: rgba(1, 5, 7, 1) !important;
3237
+ border-color: rgba(190, 194, 255, 0.45) !important;
3238
+ }
3239
+ .console-button:focus-visible {
3240
+ outline-color: #bec2ff !important;
3241
+ }
3242
+
3243
+ /* ── Inspector window ────────────────────────────────────────── */
3244
+ .inspector-window {
3245
+ border-color: #dbdbe5 !important;
3246
+ box-shadow:
3247
+ 0 8px 32px rgba(1, 5, 7, 0.1),
3248
+ 0 2px 8px rgba(1, 5, 7, 0.06) !important;
3249
+ }
3250
+
3251
+ /* ── Header drag area ────────────────────────────────────────── */
3252
+ .drag-handle {
3253
+ border-bottom-color: #dbdbe5 !important;
3254
+ /* Subtle pale lavender gradient — brand "light, spacious" surface */
3255
+ background: linear-gradient(180deg, #f4f4fd 0%, #ffffff 100%) !important;
3256
+ }
3257
+
3258
+ /* Tab strip row: soft off-white, separated from content */
3259
+ .drag-handle > div:last-child {
3260
+ border-top-color: #e2e2ea !important;
3261
+ background-color: #fafafc !important;
3262
+ }
3263
+
3264
+ /* ── Tab buttons ─────────────────────────────────────────────── */
3265
+ /*
3266
+ * Named classes owned by this component — no Tailwind conflict.
3267
+ * Active: brand surface/surfaceContainerActive (lilac tint) +
3268
+ * border/borderActionEnabled underline.
3269
+ * Dark fill is for primary action buttons only, not nav tabs.
3270
+ */
3271
+ .cpk-tab-active {
3272
+ background-color: rgba(190, 194, 255, 0.18);
3273
+ color: #010507;
3274
+ font-weight: 600;
3275
+ }
3276
+ .cpk-tab-active .cpk-tab-icon {
3277
+ color: #757cf2;
3278
+ }
3279
+ .cpk-tab-inactive {
3280
+ background-color: transparent;
3281
+ color: #2b2b2b;
3282
+ }
3283
+ .cpk-tab-inactive .cpk-tab-icon {
3284
+ color: #838389;
3285
+ }
3286
+ .cpk-tab-inactive:hover {
3287
+ background-color: rgba(190, 194, 255, 0.08);
3288
+ color: #010507;
3289
+ cursor: pointer;
3290
+ }
3291
+ .cpk-tab-active {
3292
+ cursor: pointer;
3293
+ }
3294
+
3295
+ /* ── Header control buttons (dock, close) — first row only ───── */
3296
+ .drag-handle > div:first-child button {
3297
+ color: #838389 !important;
3298
+ }
3299
+ .drag-handle > div:first-child button:hover {
3300
+ background-color: #f0f0f4 !important;
3301
+ color: #57575b !important;
3302
+ }
3303
+ .drag-handle > div:first-child button:focus-visible {
3304
+ outline-color: #bec2ff !important;
3305
+ }
3306
+
3307
+ /* ── Agent/context dropdown ──────────────────────────────────── */
3308
+ [data-context-dropdown-root="true"] > button {
3309
+ border-color: #dbdbe5 !important;
3310
+ color: #010507 !important;
3311
+ }
3312
+ [data-context-dropdown-root="true"] > button:hover {
3313
+ border-color: #bec2ff !important;
3314
+ background-color: #f7f7f9 !important;
3315
+ }
3316
+ [data-context-dropdown-root="true"] > button > span:last-child {
3317
+ color: #838389 !important;
3318
+ }
3319
+ [data-context-dropdown-root="true"] > div {
3320
+ border-color: #dbdbe5 !important;
3321
+ box-shadow: 0 4px 12px rgba(1, 5, 7, 0.08) !important;
3322
+ }
3323
+ [data-context-dropdown-root="true"] > div button:hover,
3324
+ [data-context-dropdown-root="true"] > div button:focus {
3325
+ background-color: #f7f7f9 !important;
3326
+ }
3327
+
3328
+ /* ── Status bar (bottom chrome) ──────────────────────────────── */
3329
+ .inspector-window > div > div:last-child {
3330
+ border-top-color: #dbdbe5 !important;
3331
+ background-color: #f7f7f9 !important;
3332
+ }
3333
+
3334
+ /* ── Resize handle ───────────────────────────────────────────── */
3335
+ .resize-handle {
3336
+ color: #838389 !important;
3337
+ }
3338
+ .resize-handle:hover {
3339
+ color: #57575b !important;
3340
+ }
3341
+
3342
+ /* ── AG-UI Events tab ────────────────────────────────────────── */
3343
+ /* Row hover: replace blue tint with brand lilac */
3344
+ tr:hover td {
3345
+ background-color: rgba(190, 194, 255, 0.08) !important;
3346
+ }
3347
+ /* Reset/dark action button */
3348
+ button[class*="bg-gray-900"] {
3349
+ background-color: #010507 !important;
3350
+ }
3351
+ button[class*="bg-gray-800"] {
3352
+ background-color: #2b2b2b !important;
3353
+ }
3354
+ /* Copy "copied" state: generic green → brand mint */
3355
+ button[class*="bg-green-100"] {
3356
+ background-color: rgba(133, 236, 206, 0.2) !important;
3357
+ color: #189370 !important;
3358
+ }
3359
+
3360
+ /* ── Agents tab ──────────────────────────────────────────────── */
3361
+ /* Agent icon bubble: blue → lilac */
3362
+ span[class*="bg-blue-100"]:not([class*="text-blue-800"]) {
3363
+ background-color: rgba(190, 194, 255, 0.15) !important;
3364
+ }
3365
+ span[class*="text-blue-600"] {
3366
+ color: #757cf2 !important;
3367
+ }
3368
+ /* Running badge: emerald → mint */
3369
+ span[class*="bg-emerald-50"] {
3370
+ background-color: rgba(133, 236, 206, 0.15) !important;
3371
+ }
3372
+ span[class*="text-emerald-700"] {
3373
+ color: #189370 !important;
3374
+ }
3375
+ /* Running status dot */
3376
+ span[class*="bg-emerald-500"] {
3377
+ background-color: #85ecce !important;
3378
+ }
3379
+ /* Idle dot */
3380
+ span[class*="bg-gray-400"] {
3381
+ background-color: #afafb7 !important;
3382
+ }
3383
+ /* User role badge (blue → lilac) */
3384
+ span[class*="bg-blue-100"][class*="text-blue-800"] {
3385
+ background-color: rgba(190, 194, 255, 0.22) !important;
3386
+ border: 1px solid rgba(190, 194, 255, 0.45) !important;
3387
+ color: #57575b !important;
3388
+ }
3389
+ /* Assistant role badge (green → mint) */
3390
+ span[class*="bg-green-100"][class*="text-green-800"] {
3391
+ background-color: rgba(133, 236, 206, 0.18) !important;
3392
+ border: 1px solid rgba(133, 236, 206, 0.4) !important;
3393
+ color: #189370 !important;
3394
+ }
3395
+ /* Tool role badge (amber → orange brand) */
3396
+ span[class*="bg-amber-100"][class*="text-amber-800"] {
3397
+ background-color: rgba(255, 172, 77, 0.15) !important;
3398
+ color: #57575b !important;
3399
+ }
3400
+
3401
+ /* ── Frontend Tools tab ──────────────────────────────────────── */
3402
+ /* Handler badge (blue → lilac) */
3403
+ span[class*="bg-blue-50"][class*="text-blue-700"] {
3404
+ background-color: rgba(190, 194, 255, 0.12) !important;
3405
+ border-color: rgba(190, 194, 255, 0.3) !important;
3406
+ color: #010507 !important;
3407
+ }
3408
+ /* Renderer badge (purple → lilac-adjacent) */
3409
+ span[class*="bg-purple-50"][class*="text-purple-700"] {
3410
+ background-color: rgba(190, 194, 255, 0.12) !important;
3411
+ border-color: rgba(190, 194, 255, 0.3) !important;
3412
+ color: #57575b !important;
3413
+ }
3414
+ /* Required badge (rose → brand red) */
3415
+ span[class*="bg-rose-50"][class*="text-rose-700"] {
3416
+ background-color: rgba(250, 95, 103, 0.1) !important;
3417
+ border-color: rgba(250, 95, 103, 0.25) !important;
3418
+ color: #fa5f67 !important;
3419
+ }
3420
+ /* Code/default value blocks */
3421
+ code[class*="bg-gray-100"],
3422
+ span[class*="bg-gray-100"] {
3423
+ background-color: #f0f0f4 !important;
3424
+ }
3425
+
3426
+ /* ── Connected status bar: match threads header mint (#5BE4BB) ──── */
3427
+ /* Outer strip bg + top border + text when connected badge is present */
3428
+ .inspector-window
3429
+ > div
3430
+ > div:last-child
3431
+ > div:last-child:has(div[class*="bg-emerald-50"]) {
3432
+ background-color: rgba(91, 228, 187, 0.08) !important;
3433
+ border-top-color: rgba(91, 228, 187, 0.3) !important;
3434
+ color: #189370 !important;
3435
+ }
3436
+ /* Inner badge — slightly more opaque on the mint bg */
3437
+ div[class*="bg-emerald-50"][class*="border-emerald-200"] {
3438
+ background-color: rgba(91, 228, 187, 0.12) !important;
3439
+ border-color: rgba(91, 228, 187, 0.4) !important;
3440
+ color: #189370 !important;
3441
+ }
3442
+ /* Icon bubble inside connected badge → mint tint */
3443
+ div[class*="bg-emerald-50"] span[class*="bg-white"] {
3444
+ background-color: rgba(91, 228, 187, 0.3) !important;
3445
+ }
3446
+
3447
+ /* ── Announcement panel ──────────────────────────────────────── */
3448
+ div[class*="border-slate-200"][class*="bg-white"] {
3449
+ border-color: #dbdbe5 !important;
3450
+ }
3451
+ /* Announcement icon bubble: black → brand light lavender + lilac icon */
3452
+ span[class*="bg-slate-900"],
3453
+ div[class*="bg-slate-900"] {
3454
+ background-color: #eee6fe !important;
3455
+ color: #757cf2 !important;
3456
+ }
3457
+ span[class*="text-slate-800"],
3458
+ div[class*="text-slate-800"] {
3459
+ color: #010507 !important;
3460
+ }
1027
3461
  `];
1028
3462
  }
1029
3463
  connectedCallback() {
1030
3464
  super.connectedCallback();
1031
3465
  if (typeof window !== "undefined") {
3466
+ this.ensureBrandFonts();
1032
3467
  window.addEventListener("resize", this.handleResize);
1033
3468
  window.addEventListener("pointerdown", this.handleGlobalPointerDown);
1034
3469
  this.hydrateStateFromStorageEarly();
@@ -1036,6 +3471,15 @@ ${argsString}</pre
1036
3471
  this.ensureAnnouncementLoading();
1037
3472
  }
1038
3473
  }
3474
+ ensureBrandFonts() {
3475
+ const FONT_LINK_ID = "cpk-inspector-brand-fonts";
3476
+ if (document.getElementById(FONT_LINK_ID)) return;
3477
+ const link = document.createElement("link");
3478
+ link.id = FONT_LINK_ID;
3479
+ link.rel = "stylesheet";
3480
+ link.href = "https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600&family=Spline+Sans+Mono:wght@600&display=swap";
3481
+ document.head.appendChild(link);
3482
+ }
1039
3483
  disconnectedCallback() {
1040
3484
  super.disconnectedCallback();
1041
3485
  if (typeof window !== "undefined") {
@@ -1113,7 +3557,7 @@ ${argsString}</pre
1113
3557
  "focus-visible:outline",
1114
3558
  "focus-visible:outline-2",
1115
3559
  "focus-visible:outline-offset-2",
1116
- "focus-visible:outline-rose-500",
3560
+ "focus-visible:outline-[#BEC2FF]",
1117
3561
  "touch-none",
1118
3562
  "select-none",
1119
3563
  this.isDragging ? "cursor-grabbing" : "cursor-grab"
@@ -1221,14 +3665,12 @@ ${argsString}</pre
1221
3665
  return html`
1222
3666
  <button
1223
3667
  type="button"
1224
- class=${["inline-flex items-center gap-2 rounded-md px-3 py-2 transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300", isSelected ? "bg-gray-900 text-white shadow-sm" : "text-gray-600 hover:bg-gray-100 hover:text-gray-900"].join(" ")}
3668
+ class=${["inline-flex items-center gap-2 rounded-md px-3 py-2 transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300", isSelected ? "cpk-tab-active" : "cpk-tab-inactive"].join(" ")}
1225
3669
  aria-pressed=${isSelected}
1226
3670
  @click=${() => this.handleMenuSelect(key)}
1227
3671
  >
1228
- <span
1229
- class="text-gray-400 ${isSelected ? "text-white" : ""}"
1230
- >
1231
- ${this.renderIcon(icon)}
3672
+ <span class="cpk-tab-icon">
3673
+ ${key in this.customTabIcons ? unsafeHTML(this.customTabIcons[key]) : this.renderIcon(icon)}
1232
3674
  </span>
1233
3675
  <span>${label}</span>
1234
3676
  </button>
@@ -1237,8 +3679,8 @@ ${argsString}</pre
1237
3679
  </div>
1238
3680
  </div>
1239
3681
  <div class="flex flex-1 flex-col overflow-hidden">
1240
- <div class="flex-1 overflow-auto">
1241
- ${this.renderAnnouncementPanel()}
3682
+ <div id="cpk-main-scroll" class="flex-1 overflow-auto">
3683
+ ${this.renderAnnouncementBanner()}
1242
3684
  ${this.renderCoreWarningBanner()} ${this.renderMainContent()}
1243
3685
  <slot></slot>
1244
3686
  </div>
@@ -1682,7 +4124,8 @@ ${argsString}</pre
1682
4124
  role,
1683
4125
  contentText,
1684
4126
  contentRaw: raw.content !== void 0 ? this.sanitizeForLogging(raw.content) : void 0,
1685
- toolCalls
4127
+ toolCalls,
4128
+ activityType: typeof raw.activityType === "string" ? raw.activityType : void 0
1686
4129
  };
1687
4130
  }
1688
4131
  normalizeAgentMessages(messages) {
@@ -1701,9 +4144,6 @@ ${argsString}</pre
1701
4144
  } else normalized[key] = { value: entry };
1702
4145
  return normalized;
1703
4146
  }
1704
- getSelectedMenu() {
1705
- return this.menuItems.find((item) => item.key === this.selectedMenu) ?? this.menuItems[0];
1706
- }
1707
4147
  renderCoreWarningBanner() {
1708
4148
  if (this._core) return nothing;
1709
4149
  return html`
@@ -1760,27 +4200,99 @@ ${argsString}</pre
1760
4200
  if (this.selectedMenu === "agents") return this.renderAgentsView();
1761
4201
  if (this.selectedMenu === "frontend-tools") return this.renderToolsView();
1762
4202
  if (this.selectedMenu === "agent-context") return this.renderContextView();
4203
+ if (this.selectedMenu === "threads") return this.renderThreadsView();
1763
4204
  return nothing;
1764
4205
  }
4206
+ renderThreadsView() {
4207
+ const displayThreads = this.selectedContext === "all-agents" ? this._threads : this._threadsByAgent.get(this.selectedContext) ?? [];
4208
+ let threadsErrorMessage = null;
4209
+ if (this.selectedContext === "all-agents") threadsErrorMessage = this._threadsErrorByAgent.values().next().value?.message ?? null;
4210
+ else threadsErrorMessage = this._threadsErrorByAgent.get(this.selectedContext)?.message ?? null;
4211
+ const selectedThread = this.selectedThreadId != null ? displayThreads.find((t) => t.id === this.selectedThreadId) ?? null : null;
4212
+ return html`
4213
+ <div style="display:flex;height:100%;overflow:hidden;">
4214
+ <!-- Left sidebar: thread list -->
4215
+ <div
4216
+ style="width:${this.threadListWidth}px;flex-shrink:0;overflow:hidden;display:flex;flex-direction:column;border-right:1px solid #DBDBE5;"
4217
+ >
4218
+ <cpk-thread-list
4219
+ style="height:100%;"
4220
+ .threads=${displayThreads}
4221
+ .selectedThreadId=${this.selectedThreadId}
4222
+ .errorMessage=${threadsErrorMessage}
4223
+ @threadSelected=${(e) => {
4224
+ this.selectedThreadId = e.detail;
4225
+ this.requestUpdate();
4226
+ }}
4227
+ ></cpk-thread-list>
4228
+ </div>
4229
+
4230
+ <!-- Resize divider -->
4231
+ <div
4232
+ style="width:4px;flex-shrink:0;cursor:col-resize;background:transparent;position:relative;z-index:1;"
4233
+ @pointerdown=${this.handleThreadDividerPointerDown}
4234
+ @pointermove=${this.handleThreadDividerPointerMove}
4235
+ @pointerup=${this.handleThreadDividerPointerUp}
4236
+ @pointercancel=${this.handleThreadDividerPointerUp}
4237
+ ></div>
4238
+
4239
+ <!-- Center + right: thread details or empty state -->
4240
+ <div style="flex:1;min-width:0;overflow:hidden;display:flex;">
4241
+ ${this.selectedThreadId ? html`<cpk-thread-details
4242
+ style="flex:1;min-width:0;"
4243
+ .threadId=${this.selectedThreadId}
4244
+ .thread=${selectedThread}
4245
+ .runtimeUrl=${this._core?.runtimeUrl ?? ""}
4246
+ .headers=${this._core?.headers ?? {}}
4247
+ .liveMessageVersion=${this.selectedThreadId ? this.liveMessageVersion.get(this.selectedThreadId) ?? 0 : 0}
4248
+ .agentStateInput=${selectedThread ? this.getLatestStateForAgent(selectedThread.agentId) : null}
4249
+ .agentEventsInput=${selectedThread ? this.agentEvents.get(selectedThread.agentId) ?? [] : []}
4250
+ ></cpk-thread-details>` : html`
4251
+ <div
4252
+ style="
4253
+ flex: 1;
4254
+ display: flex;
4255
+ flex-direction: column;
4256
+ align-items: center;
4257
+ justify-content: center;
4258
+ gap: 8px;
4259
+ color: #838389;
4260
+ "
4261
+ >
4262
+ <svg
4263
+ width="32"
4264
+ height="32"
4265
+ viewBox="0 0 24 24"
4266
+ fill="none"
4267
+ stroke="#c0c0c8"
4268
+ stroke-width="1.5"
4269
+ stroke-linecap="round"
4270
+ stroke-linejoin="round"
4271
+ >
4272
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
4273
+ </svg>
4274
+ <span style="font-size: 13px">${displayThreads.length === 0 ? "No threads yet" : "Select a thread to inspect"}</span>
4275
+ </div>
4276
+ `}
4277
+ </div>
4278
+ </div>
4279
+ `;
4280
+ }
1765
4281
  renderEventsTable() {
1766
4282
  const events = this.getEventsForSelectedContext();
1767
4283
  const filteredEvents = this.filterEvents(events);
1768
4284
  const selectedLabel = this.selectedContext === "all-agents" ? "all agents" : `agent ${this.selectedContext}`;
1769
4285
  if (events.length === 0) return html`
1770
4286
  <div
1771
- class="flex h-full items-center justify-center px-4 py-8 text-center"
4287
+ class="flex h-full flex-col items-center justify-center gap-2 px-4 py-10 text-center"
1772
4288
  >
1773
- <div class="max-w-md">
1774
- <div
1775
- class="mb-3 flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8"
1776
- >
1777
- ${this.renderIcon("Zap")}
1778
- </div>
1779
- <p class="text-sm text-gray-600">No events yet</p>
1780
- <p class="mt-2 text-xs text-gray-500">
1781
- Trigger an agent run to see live activity.
1782
- </p>
4289
+ <div class="text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
4290
+ ${this.renderIcon("Zap")}
1783
4291
  </div>
4292
+ <span class="text-sm text-gray-600">No events yet</span>
4293
+ <span class="max-w-[240px] text-xs leading-snug text-gray-400"
4294
+ >Events are recorded live. Run the agent to see them here.</span
4295
+ >
1784
4296
  </div>
1785
4297
  `;
1786
4298
  if (filteredEvents.length === 0) return html`
@@ -1877,23 +4389,32 @@ ${argsString}</pre
1877
4389
  </div>
1878
4390
  <div class="relative h-full w-full overflow-y-auto overflow-x-hidden">
1879
4391
  <table class="w-full table-fixed border-collapse text-xs box-border">
4392
+ <colgroup>
4393
+ <col style="width:${this.evtColWidths[0]}px">
4394
+ <col style="width:${this.evtColWidths[1]}px">
4395
+ <col style="width:${this.evtColWidths[2]}px">
4396
+ <col>
4397
+ </colgroup>
1880
4398
  <thead class="sticky top-0 z-10">
1881
4399
  <tr class="bg-white">
4400
+ ${[
4401
+ "Agent",
4402
+ "Time",
4403
+ "Event Type"
4404
+ ].map((label, col) => html`
1882
4405
  <th
1883
4406
  class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
4407
+ style="position:relative;overflow:hidden;"
1884
4408
  >
1885
- Agent
1886
- </th>
1887
- <th
1888
- class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
1889
- >
1890
- Time
1891
- </th>
1892
- <th
1893
- class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
1894
- >
1895
- Event Type
1896
- </th>
4409
+ ${label}
4410
+ <div
4411
+ style="position:absolute;top:0;right:0;width:5px;height:100%;cursor:col-resize;user-select:none;background:transparent;"
4412
+ @pointerdown=${(e) => this._onEvtColResizeStart(e, col)}
4413
+ @pointermove=${(e) => this._onEvtColResizeMove(e)}
4414
+ @pointerup=${() => this._onEvtColResizeEnd()}
4415
+ @pointercancel=${() => this._onEvtColResizeEnd()}
4416
+ ></div>
4417
+ </th>`)}
1897
4418
  <th
1898
4419
  class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
1899
4420
  >
@@ -1981,6 +4502,25 @@ ${prettyEvent}</pre
1981
4502
  this.eventTypeFilter = "all";
1982
4503
  this.requestUpdate();
1983
4504
  }
4505
+ _onEvtColResizeStart(e, col) {
4506
+ e.preventDefault();
4507
+ e.stopPropagation();
4508
+ e.currentTarget.setPointerCapture(e.pointerId);
4509
+ this._evtColResize = {
4510
+ col,
4511
+ startX: e.clientX,
4512
+ startW: this.evtColWidths[col] ?? 0
4513
+ };
4514
+ }
4515
+ _onEvtColResizeMove(e) {
4516
+ if (!this._evtColResize) return;
4517
+ const { col, startX, startW } = this._evtColResize;
4518
+ this.evtColWidths = this.evtColWidths.map((w, i) => i === col ? Math.max(40, startW + (e.clientX - startX)) : w);
4519
+ this.requestUpdate();
4520
+ }
4521
+ _onEvtColResizeEnd() {
4522
+ this._evtColResize = null;
4523
+ }
1984
4524
  exportEvents(events) {
1985
4525
  try {
1986
4526
  const payload = JSON.stringify(events, null, 2);
@@ -2025,7 +4565,7 @@ ${prettyEvent}</pre
2025
4565
  <div class="flex items-start justify-between mb-4">
2026
4566
  <div class="flex items-center gap-3">
2027
4567
  <div
2028
- class="flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 text-blue-600"
4568
+ class="flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 text-blue-600 cpk-agent-icon"
2029
4569
  >
2030
4570
  ${this.renderIcon("Bot")}
2031
4571
  </div>
@@ -2053,7 +4593,7 @@ ${prettyEvent}</pre
2053
4593
  <div class="grid grid-cols-2 gap-4 md:grid-cols-4">
2054
4594
  <button
2055
4595
  type="button"
2056
- class="rounded-md bg-gray-50 px-3 py-2 text-left transition hover:bg-gray-100 cursor-pointer overflow-hidden"
4596
+ class="rounded-md bg-gray-50 px-3 py-2 text-left transition hover:bg-gray-100 cursor-pointer overflow-hidden cpk-stat-card"
2057
4597
  @click=${() => this.handleMenuSelect("ag-ui-events")}
2058
4598
  title="View all events in AG-UI Events"
2059
4599
  >
@@ -2064,7 +4604,9 @@ ${prettyEvent}</pre
2064
4604
  ${stats.totalEvents}
2065
4605
  </div>
2066
4606
  </button>
2067
- <div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
4607
+ <div
4608
+ class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden cpk-stat-card"
4609
+ >
2068
4610
  <div class="truncate whitespace-nowrap text-xs text-gray-600">
2069
4611
  Messages
2070
4612
  </div>
@@ -2072,7 +4614,9 @@ ${prettyEvent}</pre
2072
4614
  ${stats.messages}
2073
4615
  </div>
2074
4616
  </div>
2075
- <div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
4617
+ <div
4618
+ class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden cpk-stat-card"
4619
+ >
2076
4620
  <div class="truncate whitespace-nowrap text-xs text-gray-600">
2077
4621
  Tool Calls
2078
4622
  </div>
@@ -2080,7 +4624,9 @@ ${prettyEvent}</pre
2080
4624
  ${stats.toolCalls}
2081
4625
  </div>
2082
4626
  </div>
2083
- <div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
4627
+ <div
4628
+ class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden cpk-stat-card"
4629
+ >
2084
4630
  <div class="truncate whitespace-nowrap text-xs text-gray-600">
2085
4631
  Errors
2086
4632
  </div>
@@ -2092,9 +4638,9 @@ ${prettyEvent}</pre
2092
4638
  </div>
2093
4639
 
2094
4640
  <!-- Current State Section -->
2095
- <div class="rounded-lg border border-gray-200 bg-white">
2096
- <div class="border-b border-gray-200 px-4 py-3">
2097
- <h4 class="text-sm font-semibold text-gray-900">Current State</h4>
4641
+ <div class="cpk-section-card">
4642
+ <div class="cpk-section-header">
4643
+ <h4>Current State</h4>
2098
4644
  </div>
2099
4645
  <div class="overflow-auto p-4">
2100
4646
  ${this.hasRenderableState(state) ? html`
@@ -2103,7 +4649,7 @@ ${prettyEvent}</pre
2103
4649
  ><code>${this.formatStateForDisplay(state)}</code></pre>
2104
4650
  ` : html`
2105
4651
  <div
2106
- class="flex h-40 items-center justify-center text-xs text-gray-500"
4652
+ class="flex h-12 items-center justify-center text-xs text-gray-500"
2107
4653
  >
2108
4654
  <div class="flex items-center gap-2 text-gray-500">
2109
4655
  <span class="text-lg text-gray-400"
@@ -2117,30 +4663,18 @@ ${prettyEvent}</pre
2117
4663
  </div>
2118
4664
 
2119
4665
  <!-- Current Messages Section -->
2120
- <div class="rounded-lg border border-gray-200 bg-white">
2121
- <div class="border-b border-gray-200 px-4 py-3">
2122
- <h4 class="text-sm font-semibold text-gray-900">
2123
- Current Messages
2124
- </h4>
4666
+ <div class="cpk-section-card">
4667
+ <div class="cpk-section-header">
4668
+ <h4>Current Messages</h4>
2125
4669
  </div>
2126
4670
  <div class="overflow-auto">
2127
4671
  ${messages && messages.length > 0 ? html`
2128
- <table class="w-full text-xs">
2129
- <thead class="bg-gray-50">
2130
- <tr>
2131
- <th
2132
- class="px-4 py-2 text-left font-medium text-gray-700"
2133
- >
2134
- Role
2135
- </th>
2136
- <th
2137
- class="px-4 py-2 text-left font-medium text-gray-700"
2138
- >
2139
- Content
2140
- </th>
2141
- </tr>
2142
- </thead>
2143
- <tbody class="divide-y divide-gray-200">
4672
+ <div class="w-full text-xs">
4673
+ <div class="flex bg-gray-50">
4674
+ <div class="w-40 shrink-0 px-4 py-2 font-medium text-gray-700">Role</div>
4675
+ <div class="flex-1 px-4 py-2 font-medium text-gray-700">Content</div>
4676
+ </div>
4677
+ <div class="divide-y divide-gray-200">
2144
4678
  ${messages.map((msg) => {
2145
4679
  const role = msg.role || "unknown";
2146
4680
  const roleColors = {
@@ -2155,34 +4689,32 @@ ${prettyEvent}</pre
2155
4689
  const hasContent = rawContent.trim().length > 0;
2156
4690
  const contentFallback = toolCalls.length > 0 ? "Invoked tool call" : "—";
2157
4691
  return html`
2158
- <tr>
2159
- <td class="px-4 py-2 align-top">
4692
+ <div class="flex items-start">
4693
+ <div class="w-40 shrink-0 px-4 py-2">
2160
4694
  <span
2161
4695
  class="inline-flex rounded px-2 py-0.5 text-[10px] font-medium ${roleColors[role] || roleColors.unknown}"
2162
4696
  >
2163
4697
  ${role}
2164
4698
  </span>
2165
- </td>
2166
- <td class="px-4 py-2">
4699
+ </div>
4700
+ <div class="flex-1 px-4 py-2">
2167
4701
  ${hasContent ? html`<div
2168
- class="max-w-2xl whitespace-pre-wrap break-words text-gray-700"
4702
+ class="whitespace-pre-line break-words text-gray-700"
2169
4703
  >
2170
4704
  ${rawContent}
2171
- </div>` : html`<div
2172
- class="text-xs italic text-gray-400"
2173
- >
4705
+ </div>` : html`<div class="italic text-gray-400">
2174
4706
  ${contentFallback}
2175
4707
  </div>`}
2176
4708
  ${role === "assistant" && toolCalls.length > 0 ? this.renderToolCallDetails(toolCalls) : nothing}
2177
- </td>
2178
- </tr>
4709
+ </div>
4710
+ </div>
2179
4711
  `;
2180
4712
  })}
2181
- </tbody>
2182
- </table>
4713
+ </div>
4714
+ </div>
2183
4715
  ` : html`
2184
4716
  <div
2185
- class="flex h-40 items-center justify-center text-xs text-gray-500"
4717
+ class="flex h-12 items-center justify-center text-xs text-gray-500"
2186
4718
  >
2187
4719
  <div class="flex items-center gap-2 text-gray-500">
2188
4720
  <span class="text-lg text-gray-400"
@@ -2243,14 +4775,29 @@ ${prettyEvent}</pre
2243
4775
  }
2244
4776
  handleMenuSelect(key) {
2245
4777
  if (!this.menuItems.some((item) => item.key === key)) return;
4778
+ const previousMenu = this.selectedMenu;
2246
4779
  this.selectedMenu = key;
2247
4780
  if (key === "agents" && this.selectedContext === "all-agents") {
2248
4781
  const agentOptions = this.contextOptions.filter((opt) => opt.key !== "all-agents");
2249
4782
  if (agentOptions.length > 0) {
2250
- const defaultAgent = agentOptions.find((opt) => opt.key === "default");
2251
- this.selectedContext = defaultAgent ? defaultAgent.key : agentOptions[0].key;
4783
+ const mostRecent = agentOptions.reduce((best, opt) => {
4784
+ const ts = this.getAgentStats(opt.key).lastActivity ?? -1;
4785
+ return best === null || ts > best.ts ? {
4786
+ key: opt.key,
4787
+ ts
4788
+ } : best;
4789
+ }, null);
4790
+ this.selectedContext = mostRecent ? mostRecent.key : agentOptions[0].key;
2252
4791
  }
2253
4792
  }
4793
+ if (previousMenu === "agents" && key !== "agents") {
4794
+ if (this.contextOptions.filter((opt) => opt.key !== "all-agents").length > 1) this.selectedContext = "all-agents";
4795
+ }
4796
+ if (key === "threads") this.autoSelectLatestThread();
4797
+ if (key === "ag-ui-events" || key === "agents") requestAnimationFrame(() => {
4798
+ const scroller = this.shadowRoot?.getElementById("cpk-main-scroll");
4799
+ if (scroller) scroller.scrollTop = 0;
4800
+ });
2254
4801
  this.contextMenuOpen = false;
2255
4802
  this.persistState();
2256
4803
  this.requestUpdate();
@@ -2638,9 +5185,19 @@ ${prettyEvent}</pre
2638
5185
  <div class="mb-3">
2639
5186
  <h5 class="mb-1 text-xs font-semibold text-gray-700">ID</h5>
2640
5187
  <code
2641
- class="block rounded bg-white border border-gray-200 px-2 py-1 text-[10px] font-mono text-gray-600"
5188
+ class="font-mono text-xs font-medium text-gray-800 flex-1 truncate min-w-0"
2642
5189
  >${id}</code
2643
5190
  >
5191
+ <button
5192
+ type="button"
5193
+ class="cpk-copy-btn"
5194
+ @click=${(e) => {
5195
+ e.stopPropagation();
5196
+ this.copyContextValue(id, `${id}:id`);
5197
+ }}
5198
+ >
5199
+ ${this.copiedContextItems.has(`${id}:id`) ? "✓" : "Copy"}
5200
+ </button>
2644
5201
  </div>
2645
5202
  ${hasValue ? html`
2646
5203
  <div class="mb-2 flex items-center justify-between gap-2">
@@ -2648,8 +5205,8 @@ ${prettyEvent}</pre
2648
5205
  Value
2649
5206
  </h5>
2650
5207
  <button
2651
- class="flex items-center gap-1 rounded-md border border-gray-200 bg-white px-2 py-1 text-[10px] font-medium text-gray-700 transition hover:bg-gray-50"
2652
5208
  type="button"
5209
+ class="cpk-copy-btn"
2653
5210
  @click=${(e) => {
2654
5211
  e.stopPropagation();
2655
5212
  this.copyContextValue(context.value, id);
@@ -2658,13 +5215,6 @@ ${prettyEvent}</pre
2658
5215
  ${this.copiedContextItems.has(id) ? "Copied" : "Copy JSON"}
2659
5216
  </button>
2660
5217
  </div>
2661
- <div
2662
- class="rounded-md border border-gray-200 bg-white p-3"
2663
- >
2664
- <pre
2665
- class="overflow-auto text-xs text-gray-800 max-h-96"
2666
- ><code>${this.formatContextValue(context.value)}</code></pre>
2667
- </div>
2668
5218
  ` : html`
2669
5219
  <div class="flex items-center justify-center py-4 text-xs text-gray-500">
2670
5220
  <span>No value available</span>
@@ -2677,7 +5227,7 @@ ${prettyEvent}</pre
2677
5227
  }
2678
5228
  getContextValuePreview(value) {
2679
5229
  if (value === void 0 || value === null) return "—";
2680
- if (typeof value === "string") return value.length > 50 ? `${value.substring(0, 50)}...` : value;
5230
+ if (typeof value === "string") return value.length > 50 ? `${value.slice(0, 50)}...` : value;
2681
5231
  if (typeof value === "number" || typeof value === "boolean") return String(value);
2682
5232
  if (Array.isArray(value)) return `Array(${value.length})`;
2683
5233
  if (typeof value === "object") {
@@ -2727,50 +5277,25 @@ ${prettyEvent}</pre
2727
5277
  else this.expandedRows.add(eventId);
2728
5278
  this.requestUpdate();
2729
5279
  }
2730
- renderAnnouncementPanel() {
2731
- if (!this.isOpen) return nothing;
2732
- this.ensureAnnouncementLoading();
5280
+ renderAnnouncementBanner() {
2733
5281
  if (!this.hasUnseenAnnouncement) return nothing;
2734
- if (!this.announcementLoaded && !this.announcementMarkdown) return html`<div
2735
- class="mx-4 my-3 rounded-xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-800 shadow-[0_12px_30px_rgba(15,23,42,0.12)]"
2736
- >
2737
- <div class="flex items-center gap-2 font-semibold">
2738
- <span
2739
- class="inline-flex h-6 w-6 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm"
2740
- >
2741
- ${this.renderIcon("Megaphone")}
2742
- </span>
2743
- <span>Loading latest announcement…</span>
2744
- </div>
2745
- </div>`;
2746
- if (this.announcementLoadError) return html`<div
2747
- class="mx-4 my-3 rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-900 shadow-[0_12px_30px_rgba(15,23,42,0.12)]"
5282
+ if (!this.announcementLoaded && !this.announcementHtml) return html`<div
5283
+ class="flex items-center gap-2 px-4 py-3 text-sm font-semibold text-slate-800"
2748
5284
  >
2749
- <div class="flex items-center gap-2 font-semibold">
2750
- <span
2751
- class="inline-flex h-6 w-6 items-center justify-center rounded-md bg-rose-600 text-white shadow-sm"
2752
- >
2753
- ${this.renderIcon("Megaphone")}
2754
- </span>
2755
- <span>Announcement unavailable</span>
2756
- </div>
2757
- <p class="mt-2 text-xs text-rose-800">
2758
- We couldn’t load the latest notice. Please try opening the inspector
2759
- again.
2760
- </p>
5285
+ <span
5286
+ class="inline-flex h-6 w-6 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm"
5287
+ >
5288
+ ${this.renderIcon("Megaphone")}
5289
+ </span>
5290
+ <span>Loading latest announcement…</span>
2761
5291
  </div>`;
2762
- if (!this.announcementMarkdown) return nothing;
2763
- const content = this.announcementHtml ? unsafeHTML(this.announcementHtml) : html`<pre class="whitespace-pre-wrap text-sm text-gray-900">
2764
- ${this.announcementMarkdown}</pre
2765
- >`;
2766
- return html`<div
2767
- class="mx-4 my-3 rounded-xl border border-slate-200 bg-white px-4 py-4 shadow-[0_12px_30px_rgba(15,23,42,0.12)]"
2768
- >
5292
+ if (!this.announcementHtml) return nothing;
5293
+ return html`<div class="mx-4 mt-3 mb-3 rounded-xl border border-slate-200 bg-white px-4 py-3">
2769
5294
  <div
2770
- class="mb-3 flex items-center gap-2 text-sm font-semibold text-slate-900"
5295
+ class="mb-2 flex items-center gap-2 text-xs font-semibold text-slate-900"
2771
5296
  >
2772
5297
  <span
2773
- class="inline-flex h-7 w-7 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm"
5298
+ class="inline-flex h-5 w-5 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm"
2774
5299
  >
2775
5300
  ${this.renderIcon("Megaphone")}
2776
5301
  </span>
@@ -2781,12 +5306,30 @@ ${this.announcementMarkdown}</pre
2781
5306
  @click=${this.handleDismissAnnouncement}
2782
5307
  aria-label="Dismiss announcement"
2783
5308
  >
2784
- Dismiss
5309
+ ${this.renderIcon("X")}
2785
5310
  </button>
2786
5311
  </div>
2787
- <div class="announcement-content text-sm leading-relaxed text-gray-900">
2788
- ${content}
5312
+ <div class="announcement-body ${this.announcementExpanded ? "announcement-body--expanded" : "announcement-body--collapsed"}">
5313
+ <div
5314
+ class="announcement-content"
5315
+ @click=${this.handleAnnouncementContentClick}
5316
+ >
5317
+ ${unsafeHTML(this.announcementHtml)}
5318
+ </div>
5319
+ ${!this.announcementExpanded ? html`
5320
+ <div class="announcement-fade"></div>
5321
+ ` : nothing}
2789
5322
  </div>
5323
+ <button
5324
+ class="announcement-toggle"
5325
+ type="button"
5326
+ @click=${() => {
5327
+ this.announcementExpanded = !this.announcementExpanded;
5328
+ this.requestUpdate();
5329
+ }}
5330
+ >
5331
+ ${this.announcementExpanded ? "Show less ↑" : "Show more ↓"}
5332
+ </button>
2790
5333
  </div>`;
2791
5334
  }
2792
5335
  ensureAnnouncementLoading() {
@@ -2821,14 +5364,13 @@ ${this.announcementMarkdown}</pre
2821
5364
  const storedTimestamp = this.loadStoredAnnouncementTimestamp();
2822
5365
  this.announcementTimestamp = timestamp;
2823
5366
  this.announcementPreviewText = previewText ?? "";
2824
- this.announcementMarkdown = markdown;
2825
5367
  this.hasUnseenAnnouncement = (!storedTimestamp || storedTimestamp !== timestamp) && !!this.announcementPreviewText;
2826
5368
  this.showAnnouncementPreview = this.hasUnseenAnnouncement;
2827
5369
  this.announcementHtml = await this.convertMarkdownToHtml(markdown);
2828
5370
  this.announcementLoaded = true;
2829
5371
  this.requestUpdate();
2830
5372
  } catch (error) {
2831
- this.announcementLoadError = error;
5373
+ console.warn("[CopilotKit Inspector] Failed to load announcement", error);
2832
5374
  this.announcementLoaded = true;
2833
5375
  this.requestUpdate();
2834
5376
  }
@@ -2838,7 +5380,28 @@ ${this.announcementMarkdown}</pre
2838
5380
  renderer.link = (href, title, text) => {
2839
5381
  return `<a href="${this.escapeHtmlAttr(this.appendRefParam(href ?? ""))}" target="_blank" rel="noopener"${title ? ` title="${this.escapeHtmlAttr(title)}"` : ""}>${text}</a>`;
2840
5382
  };
2841
- return marked.parse(markdown, { renderer });
5383
+ renderer.code = (code, lang) => {
5384
+ const safeLang = (lang ?? "").replace(/[^a-z0-9-]/gi, "");
5385
+ return `<div class="announcement-code"><pre><code${safeLang ? ` class="language-${safeLang}"` : ""}>${escapeHtml(code)}</code></pre><div class="announcement-code__copy-shield"><button type="button" class="announcement-code__copy" data-copy="${this.encodeBase64(code)}" aria-label="Copy code">Copy</button></div></div>`;
5386
+ };
5387
+ return marked.parse(markdown, {
5388
+ renderer,
5389
+ async: false
5390
+ });
5391
+ }
5392
+ encodeBase64(value) {
5393
+ if (typeof window === "undefined" || typeof window.btoa !== "function") return "";
5394
+ const bytes = new TextEncoder().encode(value);
5395
+ let binary = "";
5396
+ for (const b of bytes) binary += String.fromCharCode(b);
5397
+ return window.btoa(binary);
5398
+ }
5399
+ decodeBase64(value) {
5400
+ if (typeof window === "undefined" || typeof window.atob !== "function") return "";
5401
+ const decoded = window.atob(value);
5402
+ const bytes = new Uint8Array(decoded.length);
5403
+ for (let i = 0; i < decoded.length; i++) bytes[i] = decoded.charCodeAt(i);
5404
+ return new TextDecoder().decode(bytes);
2842
5405
  }
2843
5406
  appendRefParam(href) {
2844
5407
  try {
@@ -2850,7 +5413,7 @@ ${this.announcementMarkdown}</pre
2850
5413
  }
2851
5414
  }
2852
5415
  escapeHtmlAttr(value) {
2853
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5416
+ return escapeHtml(value).replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2854
5417
  }
2855
5418
  loadStoredAnnouncementTimestamp() {
2856
5419
  if (typeof window === "undefined" || !window.localStorage) return null;
@@ -2888,5 +5451,5 @@ function defineWebInspector() {
2888
5451
  defineWebInspector();
2889
5452
 
2890
5453
  //#endregion
2891
- export { WEB_INSPECTOR_TAG, WebInspectorElement, defineWebInspector };
5454
+ export { WEB_INSPECTOR_TAG, WebInspectorElement, defineWebInspector, ɵCpkThreadDetails };
2892
5455
  //# sourceMappingURL=index.mjs.map