@copilotkitnext/web-inspector 0.0.0-max-changeset-20260109174803
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/.turbo/turbo-build$colon$css.log +7 -0
- package/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/dist/index.d.mts +205 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +3098 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3073 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +52 -0
- package/src/__tests__/web-inspector.spec.ts +171 -0
- package/src/assets/inspector-logo-icon.svg +8 -0
- package/src/assets/inspector-logo.svg +40 -0
- package/src/components.d.ts +24 -0
- package/src/index.ts +3659 -0
- package/src/lib/context-helpers.ts +125 -0
- package/src/lib/persistence.ts +104 -0
- package/src/lib/types.ts +19 -0
- package/src/styles/generated.css +2 -0
- package/src/styles/tailwind.css +23 -0
- package/src/types/css.d.ts +4 -0
- package/src/types/svg.d.ts +4 -0
- package/tsconfig.json +14 -0
- package/tsup.config.ts +15 -0
- package/vitest.config.ts +8 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3098 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
WEB_INSPECTOR_TAG: () => WEB_INSPECTOR_TAG,
|
|
24
|
+
WebInspectorElement: () => WebInspectorElement,
|
|
25
|
+
defineWebInspector: () => defineWebInspector
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var import_lit = require("lit");
|
|
29
|
+
var import_style_map = require("lit/directives/style-map.js");
|
|
30
|
+
|
|
31
|
+
// src/styles/generated.css
|
|
32
|
+
var generated_default = '/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-sky-50:oklch(97.7% .013 236.62);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-700:oklch(50% .134 242.749);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-800:oklch(42.4% .199 265.638);--color-violet-50:oklch(96.9% .016 293.756);--color-violet-200:oklch(89.4% .057 293.283);--color-violet-700:oklch(49.1% .27 292.581);--color-purple-50:oklch(97.7% .014 308.299);--color-purple-200:oklch(90.2% .063 306.703);--color-purple-700:oklch(49.6% .265 301.924);--color-rose-50:oklch(96.9% .015 12.422);--color-rose-200:oklch(89.2% .058 10.001);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-rose-700:oklch(51.4% .222 16.935);--color-rose-800:oklch(45.5% .188 13.697);--color-rose-900:oklch(41% .159 10.272);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-md:28rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--font-weight-medium:500;--font-weight-semibold:600;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-md:12px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}:host{font-family:var(--font-sans);color:var(--color-slate-900);background-color:#0000;display:block}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.top-0{top:calc(var(--spacing)*0)}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.bottom-1{bottom:calc(var(--spacing)*1)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.m-0{margin:calc(var(--spacing)*0)}.mx-4{margin-inline:calc(var(--spacing)*4)}.my-1{margin-block:calc(var(--spacing)*1)}.my-3{margin-block:calc(var(--spacing)*3)}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.grid{display:grid}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.h-1\\.5{height:calc(var(--spacing)*1.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-40{height:calc(var(--spacing)*40)}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-96{max-height:calc(var(--spacing)*96)}.w-1\\.5{width:calc(var(--spacing)*1.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\\.5{width:calc(var(--spacing)*3.5)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-40{width:calc(var(--spacing)*40)}.w-auto{width:auto}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\\[240px\\]{max-width:240px}.max-w-md{max-width:var(--container-md)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-\\[160px\\]{min-width:160px}.min-w-\\[200px\\]{min-width:200px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.-translate-y-\\[2px\\]{--tw-translate-y:calc(2px*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-nwse-resize{cursor:nwse-resize}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-gray-200>:not(:last-child)){border-color:var(--color-gray-200)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-blue-200{border-color:var(--color-blue-200)}.border-emerald-200{border-color:var(--color-emerald-200)}.border-gray-100{border-color:var(--color-gray-100)}.border-gray-200{border-color:var(--color-gray-200)}.border-purple-200{border-color:var(--color-purple-200)}.border-rose-200{border-color:var(--color-rose-200)}.border-sky-200{border-color:var(--color-sky-200)}.border-slate-200{border-color:var(--color-slate-200)}.border-violet-200{border-color:var(--color-violet-200)}.border-white\\/20{border-color:#fff3}@supports (color:color-mix(in lab, red, red)){.border-white\\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-500{background-color:var(--color-emerald-500)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-50\\/50{background-color:#f9fafb80}@supports (color:color-mix(in lab, red, red)){.bg-gray-50\\/50{background-color:color-mix(in oklab,var(--color-gray-50)50%,transparent)}}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-purple-50{background-color:var(--color-purple-50)}.bg-rose-50{background-color:var(--color-rose-50)}.bg-rose-500{background-color:var(--color-rose-500)}.bg-rose-600{background-color:var(--color-rose-600)}.bg-sky-50{background-color:var(--color-sky-50)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-slate-950\\/95{background-color:#020618f2}@supports (color:color-mix(in lab, red, red)){.bg-slate-950\\/95{background-color:color-mix(in oklab,var(--color-slate-950)95%,transparent)}}.bg-violet-50{background-color:var(--color-violet-50)}.bg-white{background-color:var(--color-white)}.bg-white\\/60{background-color:#fff9}@supports (color:color-mix(in lab, red, red)){.bg-white\\/60{background-color:color-mix(in oklab,var(--color-white)60%,transparent)}}.bg-white\\/95{background-color:#fffffff2}@supports (color:color-mix(in lab, red, red)){.bg-white\\/95{background-color:color-mix(in oklab,var(--color-white)95%,transparent)}}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-8{padding-block:calc(var(--spacing)*8)}.text-center{text-align:center}.text-left{text-align:left}.align-middle{vertical-align:middle}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-blue-800{color:var(--color-blue-800)}.text-emerald-700{color:var(--color-emerald-700)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-700{color:var(--color-green-700)}.text-green-800{color:var(--color-green-800)}.text-purple-700{color:var(--color-purple-700)}.text-rose-700{color:var(--color-rose-700)}.text-rose-800{color:var(--color-rose-800)}.text-rose-900{color:var(--color-rose-900)}.text-sky-700{color:var(--color-sky-700)}.text-slate-800{color:var(--color-slate-800)}.text-slate-900{color:var(--color-slate-900)}.text-violet-700{color:var(--color-violet-700)}.text-white{color:var(--color-white)}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-80{opacity:.8}.shadow-\\[0_12px_30px_rgba\\(15\\,23\\,42\\,0\\.12\\)\\]{--tw-shadow:0 12px 30px var(--tw-shadow-color,#0f172a1f);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-black\\/5{--tw-ring-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.ring-black\\/5{--tw-ring-color:color-mix(in oklab,var(--color-black)5%,transparent)}}.ring-transparent{--tw-ring-color:transparent}.ring-white\\/10{--tw-ring-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.ring-white\\/10{--tw-ring-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}.hover\\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\\:border-gray-300:hover{border-color:var(--color-gray-300)}.hover\\:border-white\\/30:hover{border-color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.hover\\:border-white\\/30:hover{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.hover\\:bg-blue-50\\/50:hover{background-color:#eff6ff80}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-blue-50\\/50:hover{background-color:color-mix(in oklab,var(--color-blue-50)50%,transparent)}}.hover\\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\\:bg-slate-900\\/95:hover{background-color:#0f172bf2}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-slate-900\\/95:hover{background-color:color-mix(in oklab,var(--color-slate-900)95%,transparent)}}.hover\\:text-gray-600:hover{color:var(--color-gray-600)}.hover\\:text-gray-900:hover{color:var(--color-gray-900)}}.focus\\:border-gray-300:focus{border-color:var(--color-gray-300)}.focus\\:bg-gray-50:focus{background-color:var(--color-gray-50)}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-gray-200:focus{--tw-ring-color:var(--color-gray-200)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-gray-300:focus-visible{outline-color:var(--color-gray-300)}.focus-visible\\:outline-gray-400:focus-visible{outline-color:var(--color-gray-400)}.focus-visible\\:outline-rose-500:focus-visible{outline-color:var(--color-rose-500)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}@media (min-width:48rem){.md\\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\\[\\&\\>svg\\]\\:\\!h-8>svg{height:calc(var(--spacing)*8)!important}.\\[\\&\\>svg\\]\\:\\!w-8>svg{width:calc(var(--spacing)*8)!important}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@keyframes pulse{50%{opacity:.5}}';
|
|
33
|
+
|
|
34
|
+
// src/assets/inspector-logo.svg
|
|
35
|
+
var inspector_logo_default = 'data:image/svg+xml,<svg width="136" height="26" viewBox="0 0 136 26" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<path d="M15.5253 11.0828H11.2602C11.2299 10.7299 11.1492 10.4097 11.0181 10.1224C10.8921 9.83503 10.7157 9.588 10.4888 9.38129C10.267 9.16958 9.99725 9.00818 9.67964 8.89733C9.36202 8.78136 9.00155 8.72338 8.59823 8.72338C7.89242 8.72338 7.29501 8.89477 6.80598 9.23756C6.322 9.58045 5.95397 10.072 5.70189 10.7122C5.45486 11.3524 5.33134 12.1213 5.33134 13.0187C5.33134 13.9665 5.45738 14.7606 5.70946 15.4008C5.96657 16.0361 6.33712 16.515 6.82111 16.8376C7.30509 17.1553 7.88739 17.314 8.56798 17.314C8.95618 17.314 9.30404 17.2662 9.61158 17.1704C9.91911 17.0695 10.1863 16.9259 10.4132 16.7393C10.64 16.5528 10.8241 16.3284 10.9653 16.0663C11.1114 15.7991 11.2097 15.4991 11.2602 15.1664L15.5253 15.1967C15.4748 15.852 15.2908 16.52 14.9732 17.2006C14.6556 17.8762 14.2044 18.5013 13.6195 19.076C13.0398 19.6457 12.3214 20.1046 11.4643 20.4524C10.6073 20.8003 9.61158 20.9742 8.47724 20.9742C7.05554 20.9742 5.78004 20.6692 4.65074 20.0592C3.52649 19.4491 2.63667 18.5517 1.98126 17.367C1.33091 16.1823 1.00574 14.7328 1.00574 13.0187C1.00574 11.2946 1.33848 9.84259 2.00396 8.66285C2.66944 7.47811 3.56682 6.58324 4.69611 5.97827C5.82541 5.36825 7.08578 5.06323 8.47724 5.06323C9.45528 5.06323 10.3552 5.19683 11.177 5.46403C11.9987 5.73123 12.7196 6.12194 13.3397 6.63618C13.9599 7.14537 14.4589 7.77302 14.8371 8.51922C15.2152 9.26533 15.4446 10.1198 15.5253 11.0828Z" fill="%23010507"/>%0A<path d="M23.0894 20.9742C21.829 20.9742 20.7501 20.7246 19.8527 20.2256C18.9553 19.7214 18.2672 19.0206 17.7883 18.1232C17.3093 17.2208 17.0698 16.1747 17.0698 14.9849C17.0698 13.7951 17.3093 12.7516 17.7883 11.8542C18.2672 10.9517 18.9553 10.2509 19.8527 9.75184C20.7501 9.24767 21.829 8.99564 23.0894 8.99564C24.3498 8.99564 25.4286 9.24767 26.326 9.75184C27.2234 10.2509 27.9115 10.9517 28.3905 11.8542C28.8695 12.7516 29.1089 13.7951 29.1089 14.9849C29.1089 16.1747 28.8695 17.2208 28.3905 18.1232C27.9115 19.0206 27.2234 19.7214 26.326 20.2256C25.4286 20.7246 24.3498 20.9742 23.0894 20.9742ZM23.1196 17.8888C23.4726 17.8888 23.7776 17.7703 24.0346 17.5334C24.2918 17.2965 24.4909 16.9587 24.6321 16.5201C24.7733 16.0814 24.8438 15.5597 24.8438 14.9547C24.8438 14.3446 24.7733 13.8228 24.6321 13.3893C24.4909 12.9506 24.2918 12.6128 24.0346 12.3759C23.7776 12.139 23.4726 12.0205 23.1196 12.0205C22.7466 12.0205 22.4265 12.139 22.1592 12.3759C21.8921 12.6128 21.6878 12.9506 21.5466 13.3893C21.4056 13.8228 21.3349 14.3446 21.3349 14.9547C21.3349 15.5597 21.4056 16.0814 21.5466 16.5201C21.6878 16.9587 21.8921 17.2965 22.1592 17.5334C22.4265 17.7703 22.7466 17.8888 23.1196 17.8888Z" fill="%23010507"/>%0A<path d="M30.8029 25.1184V9.14681H34.947V11.1735H35.0377C35.189 10.7803 35.4109 10.4199 35.7032 10.0922C35.9957 9.7594 36.3587 9.4947 36.7922 9.2981C37.2257 9.09639 37.7299 8.99564 38.3046 8.99564C39.0709 8.99564 39.7995 9.19979 40.4901 9.60811C41.1858 10.0165 41.7505 10.6593 42.1841 11.5365C42.6227 12.4138 42.842 13.5531 42.842 14.9547C42.842 16.2957 42.6328 17.4073 42.2143 18.2896C41.801 19.1719 41.2464 19.8298 40.5506 20.2633C39.8599 20.697 39.1011 20.9137 38.2744 20.9137C37.7299 20.9137 37.2434 20.8255 36.8149 20.649C36.3914 20.4675 36.0284 20.223 35.7259 19.9155C35.4285 19.6029 35.199 19.25 35.0377 18.8568H34.9772V25.1184H30.8029ZM34.8865 14.9547C34.8865 15.5193 34.9596 16.0083 35.1058 16.4218C35.257 16.8301 35.4688 17.1477 35.7411 17.3746C36.0183 17.5964 36.3486 17.7073 36.7317 17.7073C37.1149 17.7073 37.44 17.5989 37.7072 17.3821C37.9795 17.1603 38.1862 16.8452 38.3273 16.4369C38.4736 16.0234 38.5466 15.5294 38.5466 14.9547C38.5466 14.3799 38.4736 13.8884 38.3273 13.48C38.1862 13.0666 37.9795 12.7516 37.7072 12.5347C37.44 12.3129 37.1149 12.202 36.7317 12.202C36.3486 12.202 36.0183 12.3129 35.7411 12.5347C35.4688 12.7516 35.257 13.0666 35.1058 13.48C34.9596 13.8884 34.8865 14.3799 34.8865 14.9547Z" fill="%23010507"/>%0A<path d="M44.5908 20.7625V9.14678H48.7652V20.7625H44.5908ZM46.6779 7.93683C46.1133 7.93683 45.6294 7.75033 45.2261 7.37726C44.8227 7.00419 44.621 6.55549 44.621 6.03118C44.621 5.50686 44.8227 5.05816 45.2261 4.68509C45.6294 4.31202 46.1133 4.12549 46.6779 4.12549C47.2477 4.12549 47.7316 4.31202 48.1299 4.68509C48.5332 5.05816 48.7349 5.50686 48.7349 6.03118C48.7349 6.55549 48.5332 7.00419 48.1299 7.37726C47.7316 7.75033 47.2477 7.93683 46.6779 7.93683Z" fill="%23010507"/>%0A<path d="M55.0664 5.27496V20.7625H50.892V5.27496H55.0664Z" fill="%23010507"/>%0A<path d="M62.7893 20.9742C61.5289 20.9742 60.4501 20.7246 59.5527 20.2256C58.6553 19.7214 57.9671 19.0206 57.4881 18.1232C57.0093 17.2208 56.7698 16.1747 56.7698 14.9849C56.7698 13.7951 57.0093 12.7516 57.4881 11.8542C57.9671 10.9517 58.6553 10.2509 59.5527 9.75184C60.4501 9.24767 61.5289 8.99564 62.7893 8.99564C64.0497 8.99564 65.1286 9.24767 66.026 9.75184C66.9234 10.2509 67.6115 10.9517 68.0904 11.8542C68.5694 12.7516 68.8089 13.7951 68.8089 14.9849C68.8089 16.1747 68.5694 17.2208 68.0904 18.1232C67.6115 19.0206 66.9234 19.7214 66.026 20.2256C65.1286 20.7246 64.0497 20.9742 62.7893 20.9742ZM62.8195 17.8888C63.1724 17.8888 63.4775 17.7703 63.7346 17.5334C63.9917 17.2965 64.1908 16.9587 64.332 16.5201C64.4731 16.0814 64.5438 15.5597 64.5438 14.9547C64.5438 14.3446 64.4731 13.8228 64.332 13.3893C64.1908 12.9506 63.9917 12.6128 63.7346 12.3759C63.4775 12.139 63.1724 12.0205 62.8195 12.0205C62.4464 12.0205 62.1263 12.139 61.8592 12.3759C61.5919 12.6128 61.3878 12.9506 61.2466 13.3893C61.1054 13.8228 61.0349 14.3446 61.0349 14.9547C61.0349 15.5597 61.1054 16.0814 61.2466 16.5201C61.3878 16.9587 61.5919 17.2965 61.8592 17.5334C62.1263 17.7703 62.4464 17.8888 62.8195 17.8888Z" fill="%23010507"/>%0A<path d="M77.4298 9.1468V12.1717H69.7769V9.1468H77.4298ZM71.2591 6.36392H75.4334V17.0267C75.4334 17.188 75.4612 17.3241 75.5166 17.4351C75.572 17.5409 75.6578 17.6216 75.7738 17.677C75.8897 17.7274 76.0384 17.7527 76.2199 17.7527C76.3459 17.7527 76.4921 17.7375 76.6585 17.7073C76.8299 17.677 76.9559 17.6518 77.0366 17.6317L77.6416 20.5659C77.4551 20.6213 77.1879 20.6894 76.84 20.77C76.4972 20.8507 76.0888 20.9037 75.6149 20.9288C74.657 20.9792 73.8529 20.8809 73.2026 20.6339C72.5522 20.3818 72.0631 19.9861 71.7355 19.4466C71.4078 18.9072 71.249 18.2316 71.2591 17.42V6.36392Z" fill="%23010507"/>%0A<path d="M79.3223 20.7625V5.27496H83.5268V11.5365H83.7385L88.397 5.27496H93.2973L88.0642 12.1717L93.4183 20.7625H88.397L84.9183 14.9546L83.5268 16.7696V20.7625H79.3223Z" fill="%23010507"/>%0A<path d="M95.3334 20.7625V9.14678H99.5077V20.7625H95.3334ZM97.4206 7.93683C96.8559 7.93683 96.3719 7.75033 95.9686 7.37726C95.5653 7.00419 95.3637 6.55549 95.3637 6.03118C95.3637 5.50686 95.5653 5.05816 95.9686 4.68509C96.3719 4.31202 96.8559 4.12549 97.4206 4.12549C97.9902 4.12549 98.4743 4.31202 98.8725 4.68509C99.2758 5.05816 99.4775 5.50686 99.4775 6.03118C99.4775 6.55549 99.2758 7.00419 98.8725 7.37726C98.4743 7.75033 97.9902 7.93683 97.4206 7.93683Z" fill="%23010507"/>%0A<path d="M108.562 9.1468V12.1717H100.909V9.1468H108.562ZM102.391 6.36392H106.565V17.0267C106.565 17.188 106.593 17.3241 106.648 17.4351C106.704 17.5409 106.789 17.6216 106.905 17.677C107.021 17.7274 107.17 17.7527 107.352 17.7527C107.478 17.7527 107.623 17.7375 107.791 17.7073C107.962 17.677 108.087 17.6518 108.168 17.6317L108.774 20.5659C108.587 20.6213 108.319 20.6894 107.971 20.77C107.629 20.8507 107.22 20.9037 106.747 20.9288C105.789 20.9792 104.985 20.8809 104.334 20.6339C103.684 20.3818 103.195 19.9861 102.867 19.4466C102.54 18.9072 102.381 18.2316 102.391 17.42V6.36392Z" fill="%23010507"/>%0A<path d="M119.539 8.67678C121.648 5.91866 123.398 3.19128 124.071 0.988777C124.089 0.928849 124.159 0.90339 124.212 0.937987C126.553 2.48864 130.818 3.50932 134.591 3.53328C134.656 3.53369 134.7 3.59769 134.677 3.65822C133.423 6.84039 131.891 12.5423 131.831 19.0536C131.831 19.1503 131.695 19.185 131.647 19.1009C129.5 15.3438 122.623 10.0644 119.574 8.81838C119.518 8.79519 119.502 8.7255 119.539 8.67678Z" fill="url(%23paint0_linear_8010_10612)"/>%0A<path d="M126.653 6.98969C123.357 8.03321 120.345 8.61334 119.626 8.74516C119.58 8.75356 119.571 8.81686 119.614 8.83473C122.687 10.1121 129.53 15.3761 131.657 19.118C131.661 19.1262 131.671 19.1292 131.68 19.1255C131.688 19.1214 131.693 19.1108 131.69 19.1016L126.653 6.98969Z" fill="url(%23paint1_linear_8010_10612)"/>%0A<path d="M124.221 0.931179C127.043 2.4702 130.303 3.16142 134.629 3.52564C134.656 3.52796 134.665 3.56437 134.641 3.57702C134.088 3.86136 130.918 5.47409 128.565 6.33784C127.934 6.56926 127.3 6.78394 126.676 6.982C126.662 6.98633 126.647 6.97951 126.641 6.96631L124.156 0.989469C124.139 0.949222 124.183 0.910305 124.221 0.931179Z" fill="url(%23paint2_linear_8010_10612)"/>%0A<path d="M124.171 1.02203L131.742 19.082" stroke="%23513C9F" stroke-width="0.183881" stroke-linecap="round"/>%0A<path d="M119.628 8.74279C119.628 8.74279 123.809 7.99233 127.739 6.63677C131.668 5.28124 134.594 3.6214 134.594 3.6214" stroke="%23513C9F" stroke-width="0.183881" stroke-linecap="round"/>%0A<path d="M125.209 3.30383L122.405 12.6358M122.405 12.6358H129.07M122.405 12.6358L111.874 25.0383" stroke="%23ABABAB" stroke-width="0.321797" stroke-linecap="round"/>%0A<path d="M119.181 22.485L117.94 22.6596C118.584 24.3618 119.904 25.1053 121.479 25.1053C125.341 25.1053 124.163 20.7382 126.4 20.7382C128.023 20.7382 127.364 24.2778 130.857 24.2778C132.989 24.2778 133.201 22.1301 132.837 21.2061C132.835 21.2005 132.833 21.1953 132.83 21.1902L132.259 20.3154C132.222 20.2572 132.131 20.2791 132.125 20.3483L132.018 21.4087C132.011 21.4824 132.013 21.5559 132.021 21.6295C132.109 22.3621 132.165 24.14 130.857 24.14C129.477 24.14 129.145 20.6462 126.4 20.6462C123.181 20.6462 123.594 24.9675 121.618 24.9675C120.313 24.9675 119.319 23.4964 119.181 22.485Z" fill="url(%23paint3_linear_8010_10612)"/>%0A<defs>%0A<linearGradient id="paint0_linear_8010_10612" x1="129.301" y1="2.33848" x2="125.623" y2="12.452" gradientUnits="userSpaceOnUse">%0A<stop stop-color="%236430AB"/>%0A<stop offset="1" stop-color="%23AA89D8"/>%0A</linearGradient>%0A<linearGradient id="paint1_linear_8010_10612" x1="126.451" y1="8.03874" x2="121.717" y2="17.1869" gradientUnits="userSpaceOnUse">%0A<stop stop-color="%23005DBB"/>%0A<stop offset="1" stop-color="%233D92E8"/>%0A</linearGradient>%0A<linearGradient id="paint2_linear_8010_10612" x1="128.565" y1="2.33842" x2="127.139" y2="6.79755" gradientUnits="userSpaceOnUse">%0A<stop stop-color="%231B70C4"/>%0A<stop offset="1" stop-color="%2354A4F2"/>%0A</linearGradient>%0A<linearGradient id="paint3_linear_8010_10612" x1="117.94" y1="22.7838" x2="132.981" y2="22.7838" gradientUnits="userSpaceOnUse">%0A<stop stop-color="%234497EA"/>%0A<stop offset="0.254755" stop-color="%231463B2"/>%0A<stop offset="0.498725" stop-color="%230A437D"/>%0A<stop offset="0.666667" stop-color="%232476C8"/>%0A<stop offset="0.972542" stop-color="%230C549A"/>%0A</linearGradient>%0A</defs>%0A</svg>%0A';
|
|
36
|
+
|
|
37
|
+
// src/assets/inspector-logo-icon.svg
|
|
38
|
+
var inspector_logo_icon_default = 'data:image/svg+xml,<?xml version="1.0" encoding="utf-8"?>%0A<svg xmlns="http://www.w3.org/2000/svg" width="55" height="60" viewBox="0 0 55 60" fill="none">%0A <g stroke="%23FFFFFF" stroke-width="3.3125" stroke-linejoin="round">%0A <path d="M0 21.9336L16.5449 0C40.8483 5.37332 53 8.05998 53 8.05998L43.123 56L0 21.9336Z" />%0A <line x1="16.5828" y1="0" x2="43.2454" y2="56" />%0A <line x1="0" y1="21.9336" x2="53" y2="8.48421" />%0A </g>%0A</svg>%0A';
|
|
39
|
+
|
|
40
|
+
// src/index.ts
|
|
41
|
+
var import_unsafe_html = require("lit/directives/unsafe-html.js");
|
|
42
|
+
var import_marked = require("marked");
|
|
43
|
+
var import_lucide = require("lucide");
|
|
44
|
+
var import_core = require("@copilotkitnext/core");
|
|
45
|
+
|
|
46
|
+
// src/lib/context-helpers.ts
|
|
47
|
+
function updateSizeFromElement(state, element, fallback) {
|
|
48
|
+
const rect = element.getBoundingClientRect();
|
|
49
|
+
state.size = {
|
|
50
|
+
width: rect.width || fallback.width,
|
|
51
|
+
height: rect.height || fallback.height
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function clampSize(size, viewport, edgeMargin, minWidth, minHeight) {
|
|
55
|
+
const maxWidth = Math.max(minWidth, viewport.width - edgeMargin * 2);
|
|
56
|
+
const maxHeight = Math.max(minHeight, viewport.height - edgeMargin * 2);
|
|
57
|
+
return {
|
|
58
|
+
width: clamp(size.width, minWidth, maxWidth),
|
|
59
|
+
height: clamp(size.height, minHeight, maxHeight)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function constrainToViewport(state, position, viewport, edgeMargin) {
|
|
63
|
+
const maxX = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
64
|
+
const maxY = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
65
|
+
return {
|
|
66
|
+
x: clamp(position.x, edgeMargin, maxX),
|
|
67
|
+
y: clamp(position.y, edgeMargin, maxY)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function keepPositionWithinViewport(state, viewport, edgeMargin) {
|
|
71
|
+
state.position = constrainToViewport(state, state.position, viewport, edgeMargin);
|
|
72
|
+
}
|
|
73
|
+
function centerContext(state, viewport, edgeMargin) {
|
|
74
|
+
const centered = {
|
|
75
|
+
x: Math.round((viewport.width - state.size.width) / 2),
|
|
76
|
+
y: Math.round((viewport.height - state.size.height) / 2)
|
|
77
|
+
};
|
|
78
|
+
state.position = constrainToViewport(state, centered, viewport, edgeMargin);
|
|
79
|
+
updateAnchorFromPosition(state, viewport, edgeMargin);
|
|
80
|
+
return state.position;
|
|
81
|
+
}
|
|
82
|
+
function updateAnchorFromPosition(state, viewport, edgeMargin) {
|
|
83
|
+
const centerX = state.position.x + state.size.width / 2;
|
|
84
|
+
const centerY = state.position.y + state.size.height / 2;
|
|
85
|
+
const horizontal = centerX < viewport.width / 2 ? "left" : "right";
|
|
86
|
+
const vertical = centerY < viewport.height / 2 ? "top" : "bottom";
|
|
87
|
+
state.anchor = { horizontal, vertical };
|
|
88
|
+
const maxHorizontalOffset = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
89
|
+
const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
90
|
+
state.anchorOffset = {
|
|
91
|
+
x: horizontal === "left" ? clamp(state.position.x, edgeMargin, maxHorizontalOffset) : clamp(viewport.width - state.position.x - state.size.width, edgeMargin, maxHorizontalOffset),
|
|
92
|
+
y: vertical === "top" ? clamp(state.position.y, edgeMargin, maxVerticalOffset) : clamp(viewport.height - state.position.y - state.size.height, edgeMargin, maxVerticalOffset)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function applyAnchorPosition(state, viewport, edgeMargin) {
|
|
96
|
+
const maxHorizontalOffset = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
97
|
+
const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
98
|
+
const horizontalOffset = clamp(state.anchorOffset.x, edgeMargin, maxHorizontalOffset);
|
|
99
|
+
const verticalOffset = clamp(state.anchorOffset.y, edgeMargin, maxVerticalOffset);
|
|
100
|
+
const x = state.anchor.horizontal === "left" ? horizontalOffset : viewport.width - state.size.width - horizontalOffset;
|
|
101
|
+
const y = state.anchor.vertical === "top" ? verticalOffset : viewport.height - state.size.height - verticalOffset;
|
|
102
|
+
state.anchorOffset = { x: horizontalOffset, y: verticalOffset };
|
|
103
|
+
state.position = constrainToViewport(state, { x, y }, viewport, edgeMargin);
|
|
104
|
+
return state.position;
|
|
105
|
+
}
|
|
106
|
+
function clamp(value, min, max) {
|
|
107
|
+
return Math.min(Math.max(min, value), max);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/lib/persistence.ts
|
|
111
|
+
function loadInspectorState(storageKey) {
|
|
112
|
+
if (typeof window === "undefined") {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
116
|
+
if (raw) {
|
|
117
|
+
try {
|
|
118
|
+
const parsed = JSON.parse(raw);
|
|
119
|
+
if (parsed && typeof parsed === "object") {
|
|
120
|
+
return parsed;
|
|
121
|
+
}
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (typeof document !== "undefined") {
|
|
126
|
+
const prefix = `${storageKey}=`;
|
|
127
|
+
const entry = document.cookie.split("; ").find((cookie) => cookie.startsWith(prefix));
|
|
128
|
+
if (entry) {
|
|
129
|
+
const legacyRaw = entry.substring(prefix.length);
|
|
130
|
+
try {
|
|
131
|
+
const parsed = JSON.parse(decodeURIComponent(legacyRaw));
|
|
132
|
+
if (parsed && typeof parsed === "object") {
|
|
133
|
+
return parsed;
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function saveInspectorState(storageKey, state) {
|
|
143
|
+
if (typeof window === "undefined") {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
window.localStorage.setItem(storageKey, JSON.stringify(state));
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.warn("Failed to persist inspector state", error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function isValidAnchor(value) {
|
|
153
|
+
if (!value || typeof value !== "object") {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const candidate = value;
|
|
157
|
+
return (candidate.horizontal === "left" || candidate.horizontal === "right") && (candidate.vertical === "top" || candidate.vertical === "bottom");
|
|
158
|
+
}
|
|
159
|
+
function isValidPosition(value) {
|
|
160
|
+
if (!value || typeof value !== "object") {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const candidate = value;
|
|
164
|
+
return isFiniteNumber(candidate.x) && isFiniteNumber(candidate.y);
|
|
165
|
+
}
|
|
166
|
+
function isValidSize(value) {
|
|
167
|
+
if (!value || typeof value !== "object") {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
const candidate = value;
|
|
171
|
+
return isFiniteNumber(candidate.width) && isFiniteNumber(candidate.height);
|
|
172
|
+
}
|
|
173
|
+
function isFiniteNumber(value) {
|
|
174
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
175
|
+
}
|
|
176
|
+
function isValidDockMode(value) {
|
|
177
|
+
return value === "floating" || value === "docked-left";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/index.ts
|
|
181
|
+
var WEB_INSPECTOR_TAG = "cpk-web-inspector";
|
|
182
|
+
var EDGE_MARGIN = 16;
|
|
183
|
+
var DRAG_THRESHOLD = 6;
|
|
184
|
+
var MIN_WINDOW_WIDTH = 600;
|
|
185
|
+
var MIN_WINDOW_WIDTH_DOCKED_LEFT = 420;
|
|
186
|
+
var MIN_WINDOW_HEIGHT = 200;
|
|
187
|
+
var INSPECTOR_STORAGE_KEY = "cpk:inspector:state";
|
|
188
|
+
var ANNOUNCEMENT_STORAGE_KEY = "cpk:inspector:announcements";
|
|
189
|
+
var ANNOUNCEMENT_URL = "https://cdn.copilotkit.ai/announcements.json";
|
|
190
|
+
var DEFAULT_BUTTON_SIZE = { width: 48, height: 48 };
|
|
191
|
+
var DEFAULT_WINDOW_SIZE = { width: 840, height: 560 };
|
|
192
|
+
var DOCKED_LEFT_WIDTH = 500;
|
|
193
|
+
var MAX_AGENT_EVENTS = 200;
|
|
194
|
+
var MAX_TOTAL_EVENTS = 500;
|
|
195
|
+
var AGENT_EVENT_TYPES = [
|
|
196
|
+
"RUN_STARTED",
|
|
197
|
+
"RUN_FINISHED",
|
|
198
|
+
"RUN_ERROR",
|
|
199
|
+
"TEXT_MESSAGE_START",
|
|
200
|
+
"TEXT_MESSAGE_CONTENT",
|
|
201
|
+
"TEXT_MESSAGE_END",
|
|
202
|
+
"TOOL_CALL_START",
|
|
203
|
+
"TOOL_CALL_ARGS",
|
|
204
|
+
"TOOL_CALL_END",
|
|
205
|
+
"TOOL_CALL_RESULT",
|
|
206
|
+
"STATE_SNAPSHOT",
|
|
207
|
+
"STATE_DELTA",
|
|
208
|
+
"MESSAGES_SNAPSHOT",
|
|
209
|
+
"RAW_EVENT",
|
|
210
|
+
"CUSTOM_EVENT"
|
|
211
|
+
];
|
|
212
|
+
var WebInspectorElement = class extends import_lit.LitElement {
|
|
213
|
+
constructor() {
|
|
214
|
+
super(...arguments);
|
|
215
|
+
this._core = null;
|
|
216
|
+
this.coreSubscriber = null;
|
|
217
|
+
this.coreUnsubscribe = null;
|
|
218
|
+
this.runtimeStatus = null;
|
|
219
|
+
this.coreProperties = {};
|
|
220
|
+
this.lastCoreError = null;
|
|
221
|
+
this.agentSubscriptions = /* @__PURE__ */ new Map();
|
|
222
|
+
this.agentEvents = /* @__PURE__ */ new Map();
|
|
223
|
+
this.agentMessages = /* @__PURE__ */ new Map();
|
|
224
|
+
this.agentStates = /* @__PURE__ */ new Map();
|
|
225
|
+
this.flattenedEvents = [];
|
|
226
|
+
this.eventCounter = 0;
|
|
227
|
+
this.contextStore = {};
|
|
228
|
+
this.pointerId = null;
|
|
229
|
+
this.dragStart = null;
|
|
230
|
+
this.dragOffset = { x: 0, y: 0 };
|
|
231
|
+
this.isDragging = false;
|
|
232
|
+
this.pointerContext = null;
|
|
233
|
+
this.isOpen = false;
|
|
234
|
+
this.draggedDuringInteraction = false;
|
|
235
|
+
this.ignoreNextButtonClick = false;
|
|
236
|
+
this.selectedMenu = "ag-ui-events";
|
|
237
|
+
this.contextMenuOpen = false;
|
|
238
|
+
this.dockMode = "floating";
|
|
239
|
+
this.previousBodyMargins = null;
|
|
240
|
+
this.transitionTimeoutId = null;
|
|
241
|
+
this.pendingSelectedContext = null;
|
|
242
|
+
this.autoAttachCore = true;
|
|
243
|
+
this.attemptedAutoAttach = false;
|
|
244
|
+
this.cachedTools = [];
|
|
245
|
+
this.toolSignature = "";
|
|
246
|
+
this.eventFilterText = "";
|
|
247
|
+
this.eventTypeFilter = "all";
|
|
248
|
+
this.announcementMarkdown = null;
|
|
249
|
+
this.announcementHtml = null;
|
|
250
|
+
this.announcementTimestamp = null;
|
|
251
|
+
this.announcementPreviewText = null;
|
|
252
|
+
this.hasUnseenAnnouncement = false;
|
|
253
|
+
this.announcementLoaded = false;
|
|
254
|
+
this.announcementLoadError = null;
|
|
255
|
+
this.announcementPromise = null;
|
|
256
|
+
this.showAnnouncementPreview = true;
|
|
257
|
+
this.contextState = {
|
|
258
|
+
button: {
|
|
259
|
+
position: { x: EDGE_MARGIN, y: EDGE_MARGIN },
|
|
260
|
+
size: { ...DEFAULT_BUTTON_SIZE },
|
|
261
|
+
anchor: { horizontal: "right", vertical: "top" },
|
|
262
|
+
anchorOffset: { x: EDGE_MARGIN, y: EDGE_MARGIN }
|
|
263
|
+
},
|
|
264
|
+
window: {
|
|
265
|
+
position: { x: EDGE_MARGIN, y: EDGE_MARGIN },
|
|
266
|
+
size: { ...DEFAULT_WINDOW_SIZE },
|
|
267
|
+
anchor: { horizontal: "right", vertical: "top" },
|
|
268
|
+
anchorOffset: { x: EDGE_MARGIN, y: EDGE_MARGIN }
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
this.hasCustomPosition = {
|
|
272
|
+
button: false,
|
|
273
|
+
window: false
|
|
274
|
+
};
|
|
275
|
+
this.resizePointerId = null;
|
|
276
|
+
this.resizeStart = null;
|
|
277
|
+
this.resizeInitialSize = null;
|
|
278
|
+
this.isResizing = false;
|
|
279
|
+
this.menuItems = [
|
|
280
|
+
{ key: "ag-ui-events", label: "AG-UI Events", icon: "Zap" },
|
|
281
|
+
{ key: "agents", label: "Agent", icon: "Bot" },
|
|
282
|
+
{ key: "frontend-tools", label: "Frontend Tools", icon: "Hammer" },
|
|
283
|
+
{ key: "agent-context", label: "Context", icon: "FileText" }
|
|
284
|
+
];
|
|
285
|
+
this.handlePointerDown = (event) => {
|
|
286
|
+
if (this.dockMode !== "floating" && this.isOpen) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const target = event.currentTarget;
|
|
290
|
+
const contextAttr = target?.dataset.dragContext;
|
|
291
|
+
const context = contextAttr === "window" ? "window" : "button";
|
|
292
|
+
const eventTarget = event.target;
|
|
293
|
+
if (context === "window" && eventTarget?.closest("button")) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
this.pointerContext = context;
|
|
297
|
+
this.measureContext(context);
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
this.pointerId = event.pointerId;
|
|
300
|
+
this.dragStart = { x: event.clientX, y: event.clientY };
|
|
301
|
+
const state = this.contextState[context];
|
|
302
|
+
this.dragOffset = {
|
|
303
|
+
x: event.clientX - state.position.x,
|
|
304
|
+
y: event.clientY - state.position.y
|
|
305
|
+
};
|
|
306
|
+
this.isDragging = false;
|
|
307
|
+
this.draggedDuringInteraction = false;
|
|
308
|
+
this.ignoreNextButtonClick = false;
|
|
309
|
+
target?.setPointerCapture?.(this.pointerId);
|
|
310
|
+
};
|
|
311
|
+
this.handlePointerMove = (event) => {
|
|
312
|
+
if (this.pointerId !== event.pointerId || !this.dragStart || !this.pointerContext) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const distance = Math.hypot(event.clientX - this.dragStart.x, event.clientY - this.dragStart.y);
|
|
316
|
+
if (!this.isDragging && distance < DRAG_THRESHOLD) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
this.setDragging(true);
|
|
321
|
+
this.draggedDuringInteraction = true;
|
|
322
|
+
const desired = {
|
|
323
|
+
x: event.clientX - this.dragOffset.x,
|
|
324
|
+
y: event.clientY - this.dragOffset.y
|
|
325
|
+
};
|
|
326
|
+
const constrained = this.constrainToViewport(desired, this.pointerContext);
|
|
327
|
+
this.contextState[this.pointerContext].position = constrained;
|
|
328
|
+
this.updateHostTransform(this.pointerContext);
|
|
329
|
+
};
|
|
330
|
+
this.handlePointerUp = (event) => {
|
|
331
|
+
if (this.pointerId !== event.pointerId) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const target = event.currentTarget;
|
|
335
|
+
if (target?.hasPointerCapture(this.pointerId)) {
|
|
336
|
+
target.releasePointerCapture(this.pointerId);
|
|
337
|
+
}
|
|
338
|
+
const context = this.pointerContext ?? this.activeContext;
|
|
339
|
+
if (this.isDragging && this.pointerContext) {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
this.setDragging(false);
|
|
342
|
+
if (this.pointerContext === "window") {
|
|
343
|
+
this.updateAnchorFromPosition(this.pointerContext);
|
|
344
|
+
this.hasCustomPosition.window = true;
|
|
345
|
+
this.applyAnchorPosition(this.pointerContext);
|
|
346
|
+
} else if (this.pointerContext === "button") {
|
|
347
|
+
this.snapButtonToCorner();
|
|
348
|
+
this.hasCustomPosition.button = true;
|
|
349
|
+
if (this.draggedDuringInteraction) {
|
|
350
|
+
this.ignoreNextButtonClick = true;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} else if (context === "button" && !this.isOpen && !this.draggedDuringInteraction) {
|
|
354
|
+
this.openInspector();
|
|
355
|
+
}
|
|
356
|
+
this.resetPointerTracking();
|
|
357
|
+
};
|
|
358
|
+
this.handlePointerCancel = (event) => {
|
|
359
|
+
if (this.pointerId !== event.pointerId) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const target = event.currentTarget;
|
|
363
|
+
if (target?.hasPointerCapture(this.pointerId)) {
|
|
364
|
+
target.releasePointerCapture(this.pointerId);
|
|
365
|
+
}
|
|
366
|
+
this.resetPointerTracking();
|
|
367
|
+
};
|
|
368
|
+
this.handleButtonClick = (event) => {
|
|
369
|
+
if (this.isDragging) {
|
|
370
|
+
event.preventDefault();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (this.ignoreNextButtonClick) {
|
|
374
|
+
event.preventDefault();
|
|
375
|
+
this.ignoreNextButtonClick = false;
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (!this.isOpen) {
|
|
379
|
+
event.preventDefault();
|
|
380
|
+
this.openInspector();
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
this.handleClosePointerDown = (event) => {
|
|
384
|
+
event.stopPropagation();
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
};
|
|
387
|
+
this.handleCloseClick = () => {
|
|
388
|
+
this.closeInspector();
|
|
389
|
+
};
|
|
390
|
+
this.handleResizePointerDown = (event) => {
|
|
391
|
+
event.stopPropagation();
|
|
392
|
+
event.preventDefault();
|
|
393
|
+
this.hasCustomPosition.window = true;
|
|
394
|
+
this.isResizing = true;
|
|
395
|
+
this.resizePointerId = event.pointerId;
|
|
396
|
+
this.resizeStart = { x: event.clientX, y: event.clientY };
|
|
397
|
+
this.resizeInitialSize = { ...this.contextState.window.size };
|
|
398
|
+
if (document.body && this.dockMode !== "floating") {
|
|
399
|
+
document.body.style.transition = "";
|
|
400
|
+
}
|
|
401
|
+
const target = event.currentTarget;
|
|
402
|
+
target?.setPointerCapture?.(event.pointerId);
|
|
403
|
+
};
|
|
404
|
+
this.handleResizePointerMove = (event) => {
|
|
405
|
+
if (!this.isResizing || this.resizePointerId !== event.pointerId || !this.resizeStart || !this.resizeInitialSize) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
event.preventDefault();
|
|
409
|
+
const deltaX = event.clientX - this.resizeStart.x;
|
|
410
|
+
const deltaY = event.clientY - this.resizeStart.y;
|
|
411
|
+
const state = this.contextState.window;
|
|
412
|
+
if (this.dockMode === "docked-left") {
|
|
413
|
+
state.size = this.clampWindowSize({
|
|
414
|
+
width: this.resizeInitialSize.width + deltaX,
|
|
415
|
+
height: state.size.height
|
|
416
|
+
});
|
|
417
|
+
if (document.body) {
|
|
418
|
+
document.body.style.marginLeft = `${state.size.width}px`;
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
state.size = this.clampWindowSize({
|
|
422
|
+
width: this.resizeInitialSize.width + deltaX,
|
|
423
|
+
height: this.resizeInitialSize.height + deltaY
|
|
424
|
+
});
|
|
425
|
+
this.keepPositionWithinViewport("window");
|
|
426
|
+
this.updateAnchorFromPosition("window");
|
|
427
|
+
}
|
|
428
|
+
this.requestUpdate();
|
|
429
|
+
this.updateHostTransform("window");
|
|
430
|
+
};
|
|
431
|
+
this.handleResizePointerUp = (event) => {
|
|
432
|
+
if (this.resizePointerId !== event.pointerId) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const target = event.currentTarget;
|
|
436
|
+
if (target?.hasPointerCapture(this.resizePointerId)) {
|
|
437
|
+
target.releasePointerCapture(this.resizePointerId);
|
|
438
|
+
}
|
|
439
|
+
if (this.dockMode === "floating") {
|
|
440
|
+
this.updateAnchorFromPosition("window");
|
|
441
|
+
this.applyAnchorPosition("window");
|
|
442
|
+
}
|
|
443
|
+
this.persistState();
|
|
444
|
+
this.resetResizeTracking();
|
|
445
|
+
};
|
|
446
|
+
this.handleResizePointerCancel = (event) => {
|
|
447
|
+
if (this.resizePointerId !== event.pointerId) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const target = event.currentTarget;
|
|
451
|
+
if (target?.hasPointerCapture(this.resizePointerId)) {
|
|
452
|
+
target.releasePointerCapture(this.resizePointerId);
|
|
453
|
+
}
|
|
454
|
+
if (this.dockMode === "floating") {
|
|
455
|
+
this.updateAnchorFromPosition("window");
|
|
456
|
+
this.applyAnchorPosition("window");
|
|
457
|
+
}
|
|
458
|
+
this.persistState();
|
|
459
|
+
this.resetResizeTracking();
|
|
460
|
+
};
|
|
461
|
+
this.handleResize = () => {
|
|
462
|
+
this.measureContext("button");
|
|
463
|
+
this.applyAnchorPosition("button");
|
|
464
|
+
this.measureContext("window");
|
|
465
|
+
if (this.hasCustomPosition.window) {
|
|
466
|
+
this.applyAnchorPosition("window");
|
|
467
|
+
} else {
|
|
468
|
+
this.centerContext("window");
|
|
469
|
+
}
|
|
470
|
+
this.updateHostTransform();
|
|
471
|
+
};
|
|
472
|
+
this.contextOptions = [
|
|
473
|
+
{ key: "all-agents", label: "All Agents" }
|
|
474
|
+
];
|
|
475
|
+
this.selectedContext = "all-agents";
|
|
476
|
+
this.expandedRows = /* @__PURE__ */ new Set();
|
|
477
|
+
this.copiedEvents = /* @__PURE__ */ new Set();
|
|
478
|
+
this.expandedTools = /* @__PURE__ */ new Set();
|
|
479
|
+
this.expandedContextItems = /* @__PURE__ */ new Set();
|
|
480
|
+
this.copiedContextItems = /* @__PURE__ */ new Set();
|
|
481
|
+
this.handleClearEvents = () => {
|
|
482
|
+
if (this.selectedContext === "all-agents") {
|
|
483
|
+
this.agentEvents.clear();
|
|
484
|
+
this.flattenedEvents = [];
|
|
485
|
+
} else {
|
|
486
|
+
this.agentEvents.delete(this.selectedContext);
|
|
487
|
+
this.flattenedEvents = this.flattenedEvents.filter((event) => event.agentId !== this.selectedContext);
|
|
488
|
+
}
|
|
489
|
+
this.expandedRows.clear();
|
|
490
|
+
this.copiedEvents.clear();
|
|
491
|
+
this.requestUpdate();
|
|
492
|
+
};
|
|
493
|
+
this.handleGlobalPointerDown = (event) => {
|
|
494
|
+
if (!this.contextMenuOpen) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const clickedDropdown = event.composedPath().some((node) => {
|
|
498
|
+
return node instanceof HTMLElement && node.dataset?.contextDropdownRoot === "true";
|
|
499
|
+
});
|
|
500
|
+
if (!clickedDropdown) {
|
|
501
|
+
this.contextMenuOpen = false;
|
|
502
|
+
this.requestUpdate();
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
this.handleDismissAnnouncement = () => {
|
|
506
|
+
this.markAnnouncementSeen();
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
static {
|
|
510
|
+
this.properties = {
|
|
511
|
+
core: { attribute: false },
|
|
512
|
+
autoAttachCore: { type: Boolean, attribute: "auto-attach-core" }
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
get core() {
|
|
516
|
+
return this._core;
|
|
517
|
+
}
|
|
518
|
+
set core(value) {
|
|
519
|
+
const oldValue = this._core;
|
|
520
|
+
if (oldValue === value) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
this.detachFromCore();
|
|
524
|
+
this._core = value ?? null;
|
|
525
|
+
this.requestUpdate("core", oldValue);
|
|
526
|
+
if (this._core) {
|
|
527
|
+
this.attachToCore(this._core);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
attachToCore(core) {
|
|
531
|
+
this.runtimeStatus = core.runtimeConnectionStatus;
|
|
532
|
+
this.coreProperties = core.properties;
|
|
533
|
+
this.lastCoreError = null;
|
|
534
|
+
this.coreSubscriber = {
|
|
535
|
+
onRuntimeConnectionStatusChanged: ({ status }) => {
|
|
536
|
+
this.runtimeStatus = status;
|
|
537
|
+
this.requestUpdate();
|
|
538
|
+
},
|
|
539
|
+
onPropertiesChanged: ({ properties }) => {
|
|
540
|
+
this.coreProperties = properties;
|
|
541
|
+
this.requestUpdate();
|
|
542
|
+
},
|
|
543
|
+
onError: ({ code, error }) => {
|
|
544
|
+
this.lastCoreError = { code, message: error.message };
|
|
545
|
+
this.requestUpdate();
|
|
546
|
+
},
|
|
547
|
+
onAgentsChanged: ({ agents }) => {
|
|
548
|
+
this.processAgentsChanged(agents);
|
|
549
|
+
},
|
|
550
|
+
onContextChanged: ({ context }) => {
|
|
551
|
+
this.contextStore = this.normalizeContextStore(context);
|
|
552
|
+
this.requestUpdate();
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
this.coreUnsubscribe = core.subscribe(this.coreSubscriber).unsubscribe;
|
|
556
|
+
this.processAgentsChanged(core.agents);
|
|
557
|
+
if (core.context) {
|
|
558
|
+
this.contextStore = this.normalizeContextStore(core.context);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
detachFromCore() {
|
|
562
|
+
if (this.coreUnsubscribe) {
|
|
563
|
+
this.coreUnsubscribe();
|
|
564
|
+
this.coreUnsubscribe = null;
|
|
565
|
+
}
|
|
566
|
+
this.coreSubscriber = null;
|
|
567
|
+
this.runtimeStatus = null;
|
|
568
|
+
this.lastCoreError = null;
|
|
569
|
+
this.coreProperties = {};
|
|
570
|
+
this.cachedTools = [];
|
|
571
|
+
this.toolSignature = "";
|
|
572
|
+
this.teardownAgentSubscriptions();
|
|
573
|
+
}
|
|
574
|
+
teardownAgentSubscriptions() {
|
|
575
|
+
for (const unsubscribe of this.agentSubscriptions.values()) {
|
|
576
|
+
unsubscribe();
|
|
577
|
+
}
|
|
578
|
+
this.agentSubscriptions.clear();
|
|
579
|
+
this.agentEvents.clear();
|
|
580
|
+
this.agentMessages.clear();
|
|
581
|
+
this.agentStates.clear();
|
|
582
|
+
this.flattenedEvents = [];
|
|
583
|
+
this.eventCounter = 0;
|
|
584
|
+
}
|
|
585
|
+
processAgentsChanged(agents) {
|
|
586
|
+
const seenAgentIds = /* @__PURE__ */ new Set();
|
|
587
|
+
for (const agent of Object.values(agents)) {
|
|
588
|
+
if (!agent?.agentId) {
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
seenAgentIds.add(agent.agentId);
|
|
592
|
+
this.subscribeToAgent(agent);
|
|
593
|
+
}
|
|
594
|
+
for (const agentId of Array.from(this.agentSubscriptions.keys())) {
|
|
595
|
+
if (!seenAgentIds.has(agentId)) {
|
|
596
|
+
this.unsubscribeFromAgent(agentId);
|
|
597
|
+
this.agentEvents.delete(agentId);
|
|
598
|
+
this.agentMessages.delete(agentId);
|
|
599
|
+
this.agentStates.delete(agentId);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
this.updateContextOptions(seenAgentIds);
|
|
603
|
+
this.refreshToolsSnapshot();
|
|
604
|
+
this.requestUpdate();
|
|
605
|
+
}
|
|
606
|
+
refreshToolsSnapshot() {
|
|
607
|
+
if (!this._core) {
|
|
608
|
+
if (this.cachedTools.length > 0) {
|
|
609
|
+
this.cachedTools = [];
|
|
610
|
+
this.toolSignature = "";
|
|
611
|
+
this.requestUpdate();
|
|
612
|
+
}
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const tools = this.extractToolsFromAgents();
|
|
616
|
+
const signature = JSON.stringify(
|
|
617
|
+
tools.map((tool) => ({
|
|
618
|
+
agentId: tool.agentId,
|
|
619
|
+
name: tool.name,
|
|
620
|
+
type: tool.type,
|
|
621
|
+
hasDescription: Boolean(tool.description),
|
|
622
|
+
hasParameters: Boolean(tool.parameters)
|
|
623
|
+
}))
|
|
624
|
+
);
|
|
625
|
+
if (signature !== this.toolSignature) {
|
|
626
|
+
this.toolSignature = signature;
|
|
627
|
+
this.cachedTools = tools;
|
|
628
|
+
this.requestUpdate();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
tryAutoAttachCore() {
|
|
632
|
+
if (this.attemptedAutoAttach || this._core || !this.autoAttachCore || typeof window === "undefined") {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
this.attemptedAutoAttach = true;
|
|
636
|
+
const globalWindow = window;
|
|
637
|
+
const globalCandidates = [
|
|
638
|
+
// Common app-level globals used during development
|
|
639
|
+
globalWindow.__COPILOTKIT_CORE__,
|
|
640
|
+
globalWindow.copilotkit?.core,
|
|
641
|
+
globalWindow.copilotkitCore
|
|
642
|
+
];
|
|
643
|
+
const foundCore = globalCandidates.find(
|
|
644
|
+
(candidate) => !!candidate && typeof candidate === "object"
|
|
645
|
+
);
|
|
646
|
+
if (foundCore) {
|
|
647
|
+
this.core = foundCore;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
subscribeToAgent(agent) {
|
|
651
|
+
if (!agent.agentId) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const agentId = agent.agentId;
|
|
655
|
+
this.unsubscribeFromAgent(agentId);
|
|
656
|
+
const subscriber = {
|
|
657
|
+
onRunStartedEvent: ({ event }) => {
|
|
658
|
+
this.recordAgentEvent(agentId, "RUN_STARTED", event);
|
|
659
|
+
},
|
|
660
|
+
onRunFinishedEvent: ({ event, result }) => {
|
|
661
|
+
this.recordAgentEvent(agentId, "RUN_FINISHED", { event, result });
|
|
662
|
+
},
|
|
663
|
+
onRunErrorEvent: ({ event }) => {
|
|
664
|
+
this.recordAgentEvent(agentId, "RUN_ERROR", event);
|
|
665
|
+
},
|
|
666
|
+
onTextMessageStartEvent: ({ event }) => {
|
|
667
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_START", event);
|
|
668
|
+
},
|
|
669
|
+
onTextMessageContentEvent: ({ event, textMessageBuffer }) => {
|
|
670
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_CONTENT", { event, textMessageBuffer });
|
|
671
|
+
},
|
|
672
|
+
onTextMessageEndEvent: ({ event, textMessageBuffer }) => {
|
|
673
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_END", { event, textMessageBuffer });
|
|
674
|
+
},
|
|
675
|
+
onToolCallStartEvent: ({ event }) => {
|
|
676
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_START", event);
|
|
677
|
+
},
|
|
678
|
+
onToolCallArgsEvent: ({ event, toolCallBuffer, toolCallName, partialToolCallArgs }) => {
|
|
679
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_ARGS", { event, toolCallBuffer, toolCallName, partialToolCallArgs });
|
|
680
|
+
},
|
|
681
|
+
onToolCallEndEvent: ({ event, toolCallArgs, toolCallName }) => {
|
|
682
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_END", { event, toolCallArgs, toolCallName });
|
|
683
|
+
},
|
|
684
|
+
onToolCallResultEvent: ({ event }) => {
|
|
685
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_RESULT", event);
|
|
686
|
+
},
|
|
687
|
+
onStateSnapshotEvent: ({ event }) => {
|
|
688
|
+
this.recordAgentEvent(agentId, "STATE_SNAPSHOT", event);
|
|
689
|
+
this.syncAgentState(agent);
|
|
690
|
+
},
|
|
691
|
+
onStateDeltaEvent: ({ event }) => {
|
|
692
|
+
this.recordAgentEvent(agentId, "STATE_DELTA", event);
|
|
693
|
+
this.syncAgentState(agent);
|
|
694
|
+
},
|
|
695
|
+
onMessagesSnapshotEvent: ({ event }) => {
|
|
696
|
+
this.recordAgentEvent(agentId, "MESSAGES_SNAPSHOT", event);
|
|
697
|
+
this.syncAgentMessages(agent);
|
|
698
|
+
},
|
|
699
|
+
onMessagesChanged: () => {
|
|
700
|
+
this.syncAgentMessages(agent);
|
|
701
|
+
},
|
|
702
|
+
onRawEvent: ({ event }) => {
|
|
703
|
+
this.recordAgentEvent(agentId, "RAW_EVENT", event);
|
|
704
|
+
},
|
|
705
|
+
onCustomEvent: ({ event }) => {
|
|
706
|
+
this.recordAgentEvent(agentId, "CUSTOM_EVENT", event);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
710
|
+
this.agentSubscriptions.set(agentId, unsubscribe);
|
|
711
|
+
this.syncAgentMessages(agent);
|
|
712
|
+
this.syncAgentState(agent);
|
|
713
|
+
if (!this.agentEvents.has(agentId)) {
|
|
714
|
+
this.agentEvents.set(agentId, []);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
unsubscribeFromAgent(agentId) {
|
|
718
|
+
const unsubscribe = this.agentSubscriptions.get(agentId);
|
|
719
|
+
if (unsubscribe) {
|
|
720
|
+
unsubscribe();
|
|
721
|
+
this.agentSubscriptions.delete(agentId);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
recordAgentEvent(agentId, type, payload) {
|
|
725
|
+
const eventId = `${agentId}:${++this.eventCounter}`;
|
|
726
|
+
const normalizedPayload = this.normalizeEventPayload(type, payload);
|
|
727
|
+
const event = {
|
|
728
|
+
id: eventId,
|
|
729
|
+
agentId,
|
|
730
|
+
type,
|
|
731
|
+
timestamp: Date.now(),
|
|
732
|
+
payload: normalizedPayload
|
|
733
|
+
};
|
|
734
|
+
const currentAgentEvents = this.agentEvents.get(agentId) ?? [];
|
|
735
|
+
const nextAgentEvents = [event, ...currentAgentEvents].slice(0, MAX_AGENT_EVENTS);
|
|
736
|
+
this.agentEvents.set(agentId, nextAgentEvents);
|
|
737
|
+
this.flattenedEvents = [event, ...this.flattenedEvents].slice(0, MAX_TOTAL_EVENTS);
|
|
738
|
+
this.refreshToolsSnapshot();
|
|
739
|
+
this.requestUpdate();
|
|
740
|
+
}
|
|
741
|
+
syncAgentMessages(agent) {
|
|
742
|
+
if (!agent?.agentId) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const messages = this.normalizeAgentMessages(agent.messages);
|
|
746
|
+
if (messages) {
|
|
747
|
+
this.agentMessages.set(agent.agentId, messages);
|
|
748
|
+
} else {
|
|
749
|
+
this.agentMessages.delete(agent.agentId);
|
|
750
|
+
}
|
|
751
|
+
this.requestUpdate();
|
|
752
|
+
}
|
|
753
|
+
syncAgentState(agent) {
|
|
754
|
+
if (!agent?.agentId) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const state = agent.state;
|
|
758
|
+
if (state === void 0 || state === null) {
|
|
759
|
+
this.agentStates.delete(agent.agentId);
|
|
760
|
+
} else {
|
|
761
|
+
this.agentStates.set(agent.agentId, this.sanitizeForLogging(state));
|
|
762
|
+
}
|
|
763
|
+
this.requestUpdate();
|
|
764
|
+
}
|
|
765
|
+
updateContextOptions(agentIds) {
|
|
766
|
+
const nextOptions = [
|
|
767
|
+
{ key: "all-agents", label: "All Agents" },
|
|
768
|
+
...Array.from(agentIds).sort((a, b) => a.localeCompare(b)).map((id) => ({ key: id, label: id }))
|
|
769
|
+
];
|
|
770
|
+
const optionsChanged = this.contextOptions.length !== nextOptions.length || this.contextOptions.some((option, index) => option.key !== nextOptions[index]?.key);
|
|
771
|
+
if (optionsChanged) {
|
|
772
|
+
this.contextOptions = nextOptions;
|
|
773
|
+
}
|
|
774
|
+
const pendingContext = this.pendingSelectedContext;
|
|
775
|
+
if (pendingContext) {
|
|
776
|
+
const isPendingAvailable = pendingContext === "all-agents" || agentIds.has(pendingContext);
|
|
777
|
+
if (isPendingAvailable) {
|
|
778
|
+
if (this.selectedContext !== pendingContext) {
|
|
779
|
+
this.selectedContext = pendingContext;
|
|
780
|
+
this.expandedRows.clear();
|
|
781
|
+
}
|
|
782
|
+
this.pendingSelectedContext = null;
|
|
783
|
+
} else if (agentIds.size > 0) {
|
|
784
|
+
this.pendingSelectedContext = null;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const hasSelectedContext = nextOptions.some((option) => option.key === this.selectedContext);
|
|
788
|
+
if (!hasSelectedContext && this.pendingSelectedContext === null) {
|
|
789
|
+
let nextSelected = "all-agents";
|
|
790
|
+
if (agentIds.has("default")) {
|
|
791
|
+
nextSelected = "default";
|
|
792
|
+
} else if (agentIds.size > 0) {
|
|
793
|
+
nextSelected = Array.from(agentIds).sort((a, b) => a.localeCompare(b))[0];
|
|
794
|
+
}
|
|
795
|
+
if (this.selectedContext !== nextSelected) {
|
|
796
|
+
this.selectedContext = nextSelected;
|
|
797
|
+
this.expandedRows.clear();
|
|
798
|
+
this.persistState();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
getEventsForSelectedContext() {
|
|
803
|
+
if (this.selectedContext === "all-agents") {
|
|
804
|
+
return this.flattenedEvents;
|
|
805
|
+
}
|
|
806
|
+
return this.agentEvents.get(this.selectedContext) ?? [];
|
|
807
|
+
}
|
|
808
|
+
filterEvents(events) {
|
|
809
|
+
const query = this.eventFilterText.trim().toLowerCase();
|
|
810
|
+
return events.filter((event) => {
|
|
811
|
+
if (this.eventTypeFilter !== "all" && event.type !== this.eventTypeFilter) {
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
if (!query) {
|
|
815
|
+
return true;
|
|
816
|
+
}
|
|
817
|
+
const payloadText = this.stringifyPayload(event.payload, false).toLowerCase();
|
|
818
|
+
return event.type.toLowerCase().includes(query) || event.agentId.toLowerCase().includes(query) || payloadText.includes(query);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
getLatestStateForAgent(agentId) {
|
|
822
|
+
if (this.agentStates.has(agentId)) {
|
|
823
|
+
const value = this.agentStates.get(agentId);
|
|
824
|
+
return value === void 0 ? null : value;
|
|
825
|
+
}
|
|
826
|
+
const events = this.agentEvents.get(agentId) ?? [];
|
|
827
|
+
const stateEvent = events.find((e) => e.type === "STATE_SNAPSHOT");
|
|
828
|
+
if (!stateEvent) {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
return stateEvent.payload;
|
|
832
|
+
}
|
|
833
|
+
getLatestMessagesForAgent(agentId) {
|
|
834
|
+
const messages = this.agentMessages.get(agentId);
|
|
835
|
+
return messages ?? null;
|
|
836
|
+
}
|
|
837
|
+
getAgentStatus(agentId) {
|
|
838
|
+
const events = this.agentEvents.get(agentId) ?? [];
|
|
839
|
+
if (events.length === 0) {
|
|
840
|
+
return "idle";
|
|
841
|
+
}
|
|
842
|
+
const runEvent = events.find((e) => e.type === "RUN_STARTED" || e.type === "RUN_FINISHED" || e.type === "RUN_ERROR");
|
|
843
|
+
if (!runEvent) {
|
|
844
|
+
return "idle";
|
|
845
|
+
}
|
|
846
|
+
if (runEvent.type === "RUN_ERROR") {
|
|
847
|
+
return "error";
|
|
848
|
+
}
|
|
849
|
+
if (runEvent.type === "RUN_STARTED") {
|
|
850
|
+
const finishedAfter = events.find(
|
|
851
|
+
(e) => e.type === "RUN_FINISHED" && e.timestamp > runEvent.timestamp
|
|
852
|
+
);
|
|
853
|
+
return finishedAfter ? "idle" : "running";
|
|
854
|
+
}
|
|
855
|
+
return "idle";
|
|
856
|
+
}
|
|
857
|
+
getAgentStats(agentId) {
|
|
858
|
+
const events = this.agentEvents.get(agentId) ?? [];
|
|
859
|
+
const messages = this.agentMessages.get(agentId);
|
|
860
|
+
const toolCallCount = messages ? messages.reduce((count, message) => count + (message.toolCalls?.length ?? 0), 0) : events.filter((e) => e.type === "TOOL_CALL_END").length;
|
|
861
|
+
const messageCount = messages?.length ?? 0;
|
|
862
|
+
return {
|
|
863
|
+
totalEvents: events.length,
|
|
864
|
+
lastActivity: events[0]?.timestamp ?? null,
|
|
865
|
+
messages: messageCount,
|
|
866
|
+
toolCalls: toolCallCount,
|
|
867
|
+
errors: events.filter((e) => e.type === "RUN_ERROR").length
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
renderToolCallDetails(toolCalls) {
|
|
871
|
+
if (!Array.isArray(toolCalls) || toolCalls.length === 0) {
|
|
872
|
+
return import_lit.nothing;
|
|
873
|
+
}
|
|
874
|
+
return import_lit.html`
|
|
875
|
+
<div class="mt-2 space-y-2">
|
|
876
|
+
${toolCalls.map((call, index) => {
|
|
877
|
+
const functionName = call.function?.name ?? call.toolName ?? "Unknown function";
|
|
878
|
+
const callId = typeof call?.id === "string" ? call.id : `tool-call-${index + 1}`;
|
|
879
|
+
const argsString = this.formatToolCallArguments(call.function?.arguments);
|
|
880
|
+
return import_lit.html`
|
|
881
|
+
<div class="rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-700">
|
|
882
|
+
<div class="flex flex-wrap items-center justify-between gap-1 font-medium text-gray-900">
|
|
883
|
+
<span>${functionName}</span>
|
|
884
|
+
<span class="text-[10px] text-gray-500">ID: ${callId}</span>
|
|
885
|
+
</div>
|
|
886
|
+
${argsString ? import_lit.html`<pre class="mt-2 overflow-auto rounded bg-white p-2 text-[11px] leading-relaxed text-gray-800">${argsString}</pre>` : import_lit.nothing}
|
|
887
|
+
</div>
|
|
888
|
+
`;
|
|
889
|
+
})}
|
|
890
|
+
</div>
|
|
891
|
+
`;
|
|
892
|
+
}
|
|
893
|
+
formatToolCallArguments(args) {
|
|
894
|
+
if (args === void 0 || args === null || args === "") {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
if (typeof args === "string") {
|
|
898
|
+
try {
|
|
899
|
+
const parsed = JSON.parse(args);
|
|
900
|
+
return JSON.stringify(parsed, null, 2);
|
|
901
|
+
} catch {
|
|
902
|
+
return args;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
if (typeof args === "object") {
|
|
906
|
+
try {
|
|
907
|
+
return JSON.stringify(args, null, 2);
|
|
908
|
+
} catch {
|
|
909
|
+
return String(args);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return String(args);
|
|
913
|
+
}
|
|
914
|
+
hasRenderableState(state) {
|
|
915
|
+
if (state === null || state === void 0) {
|
|
916
|
+
return false;
|
|
917
|
+
}
|
|
918
|
+
if (Array.isArray(state)) {
|
|
919
|
+
return state.length > 0;
|
|
920
|
+
}
|
|
921
|
+
if (typeof state === "object") {
|
|
922
|
+
return Object.keys(state).length > 0;
|
|
923
|
+
}
|
|
924
|
+
if (typeof state === "string") {
|
|
925
|
+
const trimmed = state.trim();
|
|
926
|
+
return trimmed.length > 0 && trimmed !== "{}";
|
|
927
|
+
}
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
930
|
+
formatStateForDisplay(state) {
|
|
931
|
+
if (state === null || state === void 0) {
|
|
932
|
+
return "";
|
|
933
|
+
}
|
|
934
|
+
if (typeof state === "string") {
|
|
935
|
+
const trimmed = state.trim();
|
|
936
|
+
if (trimmed.length === 0) {
|
|
937
|
+
return "";
|
|
938
|
+
}
|
|
939
|
+
try {
|
|
940
|
+
const parsed = JSON.parse(trimmed);
|
|
941
|
+
return JSON.stringify(parsed, null, 2);
|
|
942
|
+
} catch {
|
|
943
|
+
return state;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
if (typeof state === "object") {
|
|
947
|
+
try {
|
|
948
|
+
return JSON.stringify(state, null, 2);
|
|
949
|
+
} catch {
|
|
950
|
+
return String(state);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
return String(state);
|
|
954
|
+
}
|
|
955
|
+
getEventBadgeClasses(type) {
|
|
956
|
+
const base = "font-mono text-[10px] font-medium inline-flex items-center rounded-sm px-1.5 py-0.5 border";
|
|
957
|
+
if (type.startsWith("RUN_")) {
|
|
958
|
+
return `${base} bg-blue-50 text-blue-700 border-blue-200`;
|
|
959
|
+
}
|
|
960
|
+
if (type.startsWith("TEXT_MESSAGE")) {
|
|
961
|
+
return `${base} bg-emerald-50 text-emerald-700 border-emerald-200`;
|
|
962
|
+
}
|
|
963
|
+
if (type.startsWith("TOOL_CALL")) {
|
|
964
|
+
return `${base} bg-amber-50 text-amber-700 border-amber-200`;
|
|
965
|
+
}
|
|
966
|
+
if (type.startsWith("STATE")) {
|
|
967
|
+
return `${base} bg-violet-50 text-violet-700 border-violet-200`;
|
|
968
|
+
}
|
|
969
|
+
if (type.startsWith("MESSAGES")) {
|
|
970
|
+
return `${base} bg-sky-50 text-sky-700 border-sky-200`;
|
|
971
|
+
}
|
|
972
|
+
if (type === "RUN_ERROR") {
|
|
973
|
+
return `${base} bg-rose-50 text-rose-700 border-rose-200`;
|
|
974
|
+
}
|
|
975
|
+
return `${base} bg-gray-100 text-gray-600 border-gray-200`;
|
|
976
|
+
}
|
|
977
|
+
stringifyPayload(payload, pretty) {
|
|
978
|
+
try {
|
|
979
|
+
if (payload === void 0) {
|
|
980
|
+
return pretty ? "undefined" : "undefined";
|
|
981
|
+
}
|
|
982
|
+
if (typeof payload === "string") {
|
|
983
|
+
return payload;
|
|
984
|
+
}
|
|
985
|
+
return JSON.stringify(payload, null, pretty ? 2 : 0) ?? "";
|
|
986
|
+
} catch (error) {
|
|
987
|
+
console.warn("Failed to stringify inspector payload", error);
|
|
988
|
+
return String(payload);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
extractEventFromPayload(payload) {
|
|
992
|
+
if (payload && typeof payload === "object" && "event" in payload) {
|
|
993
|
+
return payload.event;
|
|
994
|
+
}
|
|
995
|
+
return payload;
|
|
996
|
+
}
|
|
997
|
+
async copyToClipboard(text, eventId) {
|
|
998
|
+
try {
|
|
999
|
+
await navigator.clipboard.writeText(text);
|
|
1000
|
+
this.copiedEvents.add(eventId);
|
|
1001
|
+
this.requestUpdate();
|
|
1002
|
+
setTimeout(() => {
|
|
1003
|
+
this.copiedEvents.delete(eventId);
|
|
1004
|
+
this.requestUpdate();
|
|
1005
|
+
}, 2e3);
|
|
1006
|
+
} catch (err) {
|
|
1007
|
+
console.error("Failed to copy to clipboard:", err);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
static {
|
|
1011
|
+
this.styles = [
|
|
1012
|
+
(0, import_lit.unsafeCSS)(generated_default),
|
|
1013
|
+
import_lit.css`
|
|
1014
|
+
:host {
|
|
1015
|
+
position: fixed;
|
|
1016
|
+
top: 0;
|
|
1017
|
+
left: 0;
|
|
1018
|
+
z-index: 2147483646;
|
|
1019
|
+
display: block;
|
|
1020
|
+
will-change: transform;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
:host([data-transitioning="true"]) {
|
|
1024
|
+
transition: transform 300ms ease;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
.console-button {
|
|
1028
|
+
transition:
|
|
1029
|
+
transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
1030
|
+
opacity 160ms ease;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
.console-button[data-dragging="true"] {
|
|
1034
|
+
transition: opacity 160ms ease;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.inspector-window[data-transitioning="true"] {
|
|
1038
|
+
transition: width 300ms ease, height 300ms ease;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
.inspector-window[data-docked="true"] {
|
|
1042
|
+
border-radius: 0 !important;
|
|
1043
|
+
box-shadow: none !important;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
.resize-handle {
|
|
1047
|
+
touch-action: none;
|
|
1048
|
+
user-select: none;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
.dock-resize-handle {
|
|
1052
|
+
position: absolute;
|
|
1053
|
+
top: 0;
|
|
1054
|
+
right: 0;
|
|
1055
|
+
width: 10px;
|
|
1056
|
+
height: 100%;
|
|
1057
|
+
cursor: ew-resize;
|
|
1058
|
+
touch-action: none;
|
|
1059
|
+
z-index: 50;
|
|
1060
|
+
background: transparent;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.tooltip-target {
|
|
1064
|
+
position: relative;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
.tooltip-target::after {
|
|
1068
|
+
content: attr(data-tooltip);
|
|
1069
|
+
position: absolute;
|
|
1070
|
+
top: calc(100% + 6px);
|
|
1071
|
+
left: 50%;
|
|
1072
|
+
transform: translateX(-50%) translateY(-4px);
|
|
1073
|
+
white-space: nowrap;
|
|
1074
|
+
background: rgba(17, 24, 39, 0.95);
|
|
1075
|
+
color: white;
|
|
1076
|
+
padding: 4px 8px;
|
|
1077
|
+
border-radius: 6px;
|
|
1078
|
+
font-size: 10px;
|
|
1079
|
+
line-height: 1.2;
|
|
1080
|
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
|
|
1081
|
+
opacity: 0;
|
|
1082
|
+
pointer-events: none;
|
|
1083
|
+
transition: opacity 120ms ease, transform 120ms ease;
|
|
1084
|
+
z-index: 4000;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
.tooltip-target:hover::after {
|
|
1088
|
+
opacity: 1;
|
|
1089
|
+
transform: translateX(-50%) translateY(0);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
.announcement-preview {
|
|
1093
|
+
position: absolute;
|
|
1094
|
+
top: 50%;
|
|
1095
|
+
transform: translateY(-50%);
|
|
1096
|
+
min-width: 300px;
|
|
1097
|
+
max-width: 300px;
|
|
1098
|
+
background: white;
|
|
1099
|
+
color: #111827;
|
|
1100
|
+
font-size: 13px;
|
|
1101
|
+
line-height: 1.4;
|
|
1102
|
+
border-radius: 12px;
|
|
1103
|
+
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
|
|
1104
|
+
padding: 10px 12px;
|
|
1105
|
+
display: inline-flex;
|
|
1106
|
+
align-items: flex-start;
|
|
1107
|
+
gap: 8px;
|
|
1108
|
+
z-index: 4500;
|
|
1109
|
+
animation: fade-slide-in 160ms ease;
|
|
1110
|
+
border: 1px solid rgba(148, 163, 184, 0.35);
|
|
1111
|
+
white-space: normal;
|
|
1112
|
+
word-break: break-word;
|
|
1113
|
+
text-align: left;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
.announcement-preview[data-side="left"] {
|
|
1117
|
+
right: 100%;
|
|
1118
|
+
margin-right: 10px;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
.announcement-preview[data-side="right"] {
|
|
1122
|
+
left: 100%;
|
|
1123
|
+
margin-left: 10px;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
.announcement-preview__arrow {
|
|
1127
|
+
position: absolute;
|
|
1128
|
+
width: 10px;
|
|
1129
|
+
height: 10px;
|
|
1130
|
+
background: white;
|
|
1131
|
+
border: 1px solid rgba(148, 163, 184, 0.35);
|
|
1132
|
+
transform: rotate(45deg);
|
|
1133
|
+
top: 50%;
|
|
1134
|
+
margin-top: -5px;
|
|
1135
|
+
z-index: -1;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
.announcement-preview[data-side="left"] .announcement-preview__arrow {
|
|
1139
|
+
right: -5px;
|
|
1140
|
+
box-shadow: 6px -6px 10px rgba(15, 23, 42, 0.12);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
.announcement-preview[data-side="right"] .announcement-preview__arrow {
|
|
1144
|
+
left: -5px;
|
|
1145
|
+
box-shadow: -6px 6px 10px rgba(15, 23, 42, 0.12);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
.announcement-dismiss {
|
|
1149
|
+
color: #6b7280;
|
|
1150
|
+
font-size: 12px;
|
|
1151
|
+
padding: 2px 8px;
|
|
1152
|
+
border-radius: 8px;
|
|
1153
|
+
border: 1px solid rgba(148, 163, 184, 0.5);
|
|
1154
|
+
background: rgba(248, 250, 252, 0.9);
|
|
1155
|
+
transition: background 120ms ease, color 120ms ease;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.announcement-dismiss:hover {
|
|
1159
|
+
background: rgba(241, 245, 249, 1);
|
|
1160
|
+
color: #111827;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
.announcement-content {
|
|
1164
|
+
color: #111827;
|
|
1165
|
+
font-size: 14px;
|
|
1166
|
+
line-height: 1.6;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
.announcement-content h1,
|
|
1170
|
+
.announcement-content h2,
|
|
1171
|
+
.announcement-content h3 {
|
|
1172
|
+
font-weight: 700;
|
|
1173
|
+
margin: 0.4rem 0 0.2rem;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
.announcement-content h1 {
|
|
1177
|
+
font-size: 1.1rem;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.announcement-content h2 {
|
|
1181
|
+
font-size: 1rem;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.announcement-content h3 {
|
|
1185
|
+
font-size: 0.95rem;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
.announcement-content p {
|
|
1189
|
+
margin: 0.25rem 0;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
.announcement-content ul {
|
|
1193
|
+
list-style: disc;
|
|
1194
|
+
padding-left: 1.25rem;
|
|
1195
|
+
margin: 0.3rem 0;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
.announcement-content ol {
|
|
1199
|
+
list-style: decimal;
|
|
1200
|
+
padding-left: 1.25rem;
|
|
1201
|
+
margin: 0.3rem 0;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
.announcement-content a {
|
|
1205
|
+
color: #0f766e;
|
|
1206
|
+
text-decoration: underline;
|
|
1207
|
+
}
|
|
1208
|
+
`
|
|
1209
|
+
];
|
|
1210
|
+
}
|
|
1211
|
+
connectedCallback() {
|
|
1212
|
+
super.connectedCallback();
|
|
1213
|
+
if (typeof window !== "undefined") {
|
|
1214
|
+
window.addEventListener("resize", this.handleResize);
|
|
1215
|
+
window.addEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
1216
|
+
this.hydrateStateFromStorageEarly();
|
|
1217
|
+
this.tryAutoAttachCore();
|
|
1218
|
+
this.ensureAnnouncementLoading();
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
disconnectedCallback() {
|
|
1222
|
+
super.disconnectedCallback();
|
|
1223
|
+
if (typeof window !== "undefined") {
|
|
1224
|
+
window.removeEventListener("resize", this.handleResize);
|
|
1225
|
+
window.removeEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
1226
|
+
}
|
|
1227
|
+
this.removeDockStyles();
|
|
1228
|
+
this.detachFromCore();
|
|
1229
|
+
}
|
|
1230
|
+
firstUpdated() {
|
|
1231
|
+
if (typeof window === "undefined") {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
if (!this._core) {
|
|
1235
|
+
this.tryAutoAttachCore();
|
|
1236
|
+
}
|
|
1237
|
+
this.measureContext("button");
|
|
1238
|
+
this.measureContext("window");
|
|
1239
|
+
this.contextState.button.anchor = { horizontal: "right", vertical: "top" };
|
|
1240
|
+
this.contextState.button.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
1241
|
+
this.contextState.window.anchor = { horizontal: "right", vertical: "top" };
|
|
1242
|
+
this.contextState.window.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
1243
|
+
this.hydrateStateFromStorage();
|
|
1244
|
+
if (this.isOpen && this.dockMode !== "floating") {
|
|
1245
|
+
this.applyDockStyles(true);
|
|
1246
|
+
}
|
|
1247
|
+
this.applyAnchorPosition("button");
|
|
1248
|
+
if (this.dockMode === "floating") {
|
|
1249
|
+
if (this.hasCustomPosition.window) {
|
|
1250
|
+
this.applyAnchorPosition("window");
|
|
1251
|
+
} else {
|
|
1252
|
+
this.centerContext("window");
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
this.ensureAnnouncementLoading();
|
|
1256
|
+
this.updateHostTransform(this.isOpen ? "window" : "button");
|
|
1257
|
+
}
|
|
1258
|
+
render() {
|
|
1259
|
+
return this.isOpen ? this.renderWindow() : this.renderButton();
|
|
1260
|
+
}
|
|
1261
|
+
renderButton() {
|
|
1262
|
+
const buttonClasses = [
|
|
1263
|
+
"console-button",
|
|
1264
|
+
"group",
|
|
1265
|
+
"relative",
|
|
1266
|
+
"pointer-events-auto",
|
|
1267
|
+
"inline-flex",
|
|
1268
|
+
"h-12",
|
|
1269
|
+
"w-12",
|
|
1270
|
+
"items-center",
|
|
1271
|
+
"justify-center",
|
|
1272
|
+
"rounded-full",
|
|
1273
|
+
"border",
|
|
1274
|
+
"border-white/20",
|
|
1275
|
+
"bg-slate-950/95",
|
|
1276
|
+
"text-xs",
|
|
1277
|
+
"font-medium",
|
|
1278
|
+
"text-white",
|
|
1279
|
+
"ring-1",
|
|
1280
|
+
"ring-white/10",
|
|
1281
|
+
"backdrop-blur-md",
|
|
1282
|
+
"transition",
|
|
1283
|
+
"hover:border-white/30",
|
|
1284
|
+
"hover:bg-slate-900/95",
|
|
1285
|
+
"hover:scale-105",
|
|
1286
|
+
"focus-visible:outline",
|
|
1287
|
+
"focus-visible:outline-2",
|
|
1288
|
+
"focus-visible:outline-offset-2",
|
|
1289
|
+
"focus-visible:outline-rose-500",
|
|
1290
|
+
"touch-none",
|
|
1291
|
+
"select-none",
|
|
1292
|
+
this.isDragging ? "cursor-grabbing" : "cursor-grab"
|
|
1293
|
+
].join(" ");
|
|
1294
|
+
return import_lit.html`
|
|
1295
|
+
<button
|
|
1296
|
+
class=${buttonClasses}
|
|
1297
|
+
type="button"
|
|
1298
|
+
aria-label="Web Inspector"
|
|
1299
|
+
data-drag-context="button"
|
|
1300
|
+
data-dragging=${this.isDragging && this.pointerContext === "button" ? "true" : "false"}
|
|
1301
|
+
@pointerdown=${this.handlePointerDown}
|
|
1302
|
+
@pointermove=${this.handlePointerMove}
|
|
1303
|
+
@pointerup=${this.handlePointerUp}
|
|
1304
|
+
@pointercancel=${this.handlePointerCancel}
|
|
1305
|
+
@click=${this.handleButtonClick}
|
|
1306
|
+
>
|
|
1307
|
+
${this.renderAnnouncementPreview()}
|
|
1308
|
+
<img src=${inspector_logo_icon_default} alt="Inspector logo" class="h-5 w-auto" loading="lazy" />
|
|
1309
|
+
</button>
|
|
1310
|
+
`;
|
|
1311
|
+
}
|
|
1312
|
+
renderWindow() {
|
|
1313
|
+
const windowState = this.contextState.window;
|
|
1314
|
+
const isDocked = this.dockMode !== "floating";
|
|
1315
|
+
const isTransitioning = this.hasAttribute("data-transitioning");
|
|
1316
|
+
const windowStyles = isDocked ? this.getDockedWindowStyles() : {
|
|
1317
|
+
width: `${Math.round(windowState.size.width)}px`,
|
|
1318
|
+
height: `${Math.round(windowState.size.height)}px`,
|
|
1319
|
+
minWidth: `${MIN_WINDOW_WIDTH}px`,
|
|
1320
|
+
minHeight: `${MIN_WINDOW_HEIGHT}px`
|
|
1321
|
+
};
|
|
1322
|
+
const hasContextDropdown = this.contextOptions.length > 0;
|
|
1323
|
+
const contextDropdown = hasContextDropdown ? this.renderContextDropdown() : import_lit.nothing;
|
|
1324
|
+
const coreStatus = this.getCoreStatusSummary();
|
|
1325
|
+
const agentSelector = hasContextDropdown ? contextDropdown : import_lit.html`
|
|
1326
|
+
<div class="flex items-center gap-2 rounded-md border border-dashed border-gray-200 px-2 py-1 text-xs text-gray-400">
|
|
1327
|
+
<span>${this.renderIcon("Bot")}</span>
|
|
1328
|
+
<span class="truncate">No agents available</span>
|
|
1329
|
+
</div>
|
|
1330
|
+
`;
|
|
1331
|
+
return import_lit.html`
|
|
1332
|
+
<section
|
|
1333
|
+
class="inspector-window pointer-events-auto relative flex flex-col overflow-hidden rounded-xl border border-gray-200 bg-white text-gray-900 shadow-lg"
|
|
1334
|
+
style=${(0, import_style_map.styleMap)(windowStyles)}
|
|
1335
|
+
data-docked=${isDocked}
|
|
1336
|
+
data-transitioning=${isTransitioning}
|
|
1337
|
+
>
|
|
1338
|
+
${isDocked ? import_lit.html`
|
|
1339
|
+
<div
|
|
1340
|
+
class="dock-resize-handle pointer-events-auto"
|
|
1341
|
+
role="presentation"
|
|
1342
|
+
aria-hidden="true"
|
|
1343
|
+
@pointerdown=${this.handleResizePointerDown}
|
|
1344
|
+
@pointermove=${this.handleResizePointerMove}
|
|
1345
|
+
@pointerup=${this.handleResizePointerUp}
|
|
1346
|
+
@pointercancel=${this.handleResizePointerCancel}
|
|
1347
|
+
></div>
|
|
1348
|
+
` : import_lit.nothing}
|
|
1349
|
+
<div class="flex flex-1 flex-col overflow-hidden bg-white text-gray-800">
|
|
1350
|
+
<div
|
|
1351
|
+
class="drag-handle relative z-30 flex flex-col border-b border-gray-200 bg-white/95 backdrop-blur-sm ${isDocked ? "" : this.isDragging && this.pointerContext === "window" ? "cursor-grabbing" : "cursor-grab"}"
|
|
1352
|
+
data-drag-context="window"
|
|
1353
|
+
@pointerdown=${isDocked ? void 0 : this.handlePointerDown}
|
|
1354
|
+
@pointermove=${isDocked ? void 0 : this.handlePointerMove}
|
|
1355
|
+
@pointerup=${isDocked ? void 0 : this.handlePointerUp}
|
|
1356
|
+
@pointercancel=${isDocked ? void 0 : this.handlePointerCancel}
|
|
1357
|
+
>
|
|
1358
|
+
<div class="flex flex-wrap items-center gap-3 px-4 py-3">
|
|
1359
|
+
<div class="flex items-center min-w-0">
|
|
1360
|
+
<img src=${inspector_logo_default} alt="Inspector logo" class="h-6 w-auto" loading="lazy" />
|
|
1361
|
+
</div>
|
|
1362
|
+
<div class="ml-auto flex min-w-0 items-center gap-2">
|
|
1363
|
+
<div class="min-w-[160px] max-w-xs">
|
|
1364
|
+
${agentSelector}
|
|
1365
|
+
</div>
|
|
1366
|
+
<div class="flex items-center gap-1">
|
|
1367
|
+
${this.renderDockControls()}
|
|
1368
|
+
<button
|
|
1369
|
+
class="flex h-8 w-8 items-center justify-center rounded-md text-gray-400 transition hover:bg-gray-100 hover:text-gray-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-400"
|
|
1370
|
+
type="button"
|
|
1371
|
+
aria-label="Close Web Inspector"
|
|
1372
|
+
@pointerdown=${this.handleClosePointerDown}
|
|
1373
|
+
@click=${this.handleCloseClick}
|
|
1374
|
+
>
|
|
1375
|
+
${this.renderIcon("X")}
|
|
1376
|
+
</button>
|
|
1377
|
+
</div>
|
|
1378
|
+
</div>
|
|
1379
|
+
</div>
|
|
1380
|
+
<div class="flex flex-wrap items-center gap-2 border-t border-gray-100 px-3 py-2 text-xs">
|
|
1381
|
+
${this.menuItems.map(({ key, label, icon }) => {
|
|
1382
|
+
const isSelected = this.selectedMenu === key;
|
|
1383
|
+
const tabClasses = [
|
|
1384
|
+
"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",
|
|
1385
|
+
isSelected ? "bg-gray-900 text-white shadow-sm" : "text-gray-600 hover:bg-gray-100 hover:text-gray-900"
|
|
1386
|
+
].join(" ");
|
|
1387
|
+
return import_lit.html`
|
|
1388
|
+
<button
|
|
1389
|
+
type="button"
|
|
1390
|
+
class=${tabClasses}
|
|
1391
|
+
aria-pressed=${isSelected}
|
|
1392
|
+
@click=${() => this.handleMenuSelect(key)}
|
|
1393
|
+
>
|
|
1394
|
+
<span class="text-gray-400 ${isSelected ? "text-white" : ""}">
|
|
1395
|
+
${this.renderIcon(icon)}
|
|
1396
|
+
</span>
|
|
1397
|
+
<span>${label}</span>
|
|
1398
|
+
</button>
|
|
1399
|
+
`;
|
|
1400
|
+
})}
|
|
1401
|
+
</div>
|
|
1402
|
+
</div>
|
|
1403
|
+
<div class="flex flex-1 flex-col overflow-hidden">
|
|
1404
|
+
<div class="flex-1 overflow-auto">
|
|
1405
|
+
${this.renderAnnouncementPanel()}
|
|
1406
|
+
${this.renderCoreWarningBanner()}
|
|
1407
|
+
${this.renderMainContent()}
|
|
1408
|
+
<slot></slot>
|
|
1409
|
+
</div>
|
|
1410
|
+
<div class="border-t border-gray-200 bg-gray-50 px-4 py-2">
|
|
1411
|
+
<div
|
|
1412
|
+
class="flex items-center gap-2 rounded-md px-3 py-2 text-xs ${coreStatus.tone} w-full overflow-hidden my-1"
|
|
1413
|
+
title=${coreStatus.description}
|
|
1414
|
+
>
|
|
1415
|
+
<span class="flex h-6 w-6 items-center justify-center rounded bg-white/60">
|
|
1416
|
+
${this.renderIcon("Activity")}
|
|
1417
|
+
</span>
|
|
1418
|
+
<span class="font-medium">${coreStatus.label}</span>
|
|
1419
|
+
<span class="truncate text-[11px] opacity-80">${coreStatus.description}</span>
|
|
1420
|
+
</div>
|
|
1421
|
+
</div>
|
|
1422
|
+
</div>
|
|
1423
|
+
</div>
|
|
1424
|
+
<div
|
|
1425
|
+
class="resize-handle pointer-events-auto absolute bottom-1 right-1 flex h-5 w-5 cursor-nwse-resize items-center justify-center text-gray-400 transition hover:text-gray-600"
|
|
1426
|
+
role="presentation"
|
|
1427
|
+
aria-hidden="true"
|
|
1428
|
+
@pointerdown=${this.handleResizePointerDown}
|
|
1429
|
+
@pointermove=${this.handleResizePointerMove}
|
|
1430
|
+
@pointerup=${this.handleResizePointerUp}
|
|
1431
|
+
@pointercancel=${this.handleResizePointerCancel}
|
|
1432
|
+
>
|
|
1433
|
+
<svg
|
|
1434
|
+
class="h-3 w-3"
|
|
1435
|
+
viewBox="0 0 16 16"
|
|
1436
|
+
fill="none"
|
|
1437
|
+
stroke="currentColor"
|
|
1438
|
+
stroke-linecap="round"
|
|
1439
|
+
stroke-width="1.5"
|
|
1440
|
+
>
|
|
1441
|
+
<path d="M5 15L15 5" />
|
|
1442
|
+
<path d="M9 15L15 9" />
|
|
1443
|
+
</svg>
|
|
1444
|
+
</div>
|
|
1445
|
+
</section>
|
|
1446
|
+
`;
|
|
1447
|
+
}
|
|
1448
|
+
hydrateStateFromStorageEarly() {
|
|
1449
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
const persisted = loadInspectorState(INSPECTOR_STORAGE_KEY);
|
|
1453
|
+
if (!persisted) {
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
if (typeof persisted.isOpen === "boolean") {
|
|
1457
|
+
this.isOpen = persisted.isOpen;
|
|
1458
|
+
}
|
|
1459
|
+
if (isValidDockMode(persisted.dockMode)) {
|
|
1460
|
+
this.dockMode = persisted.dockMode;
|
|
1461
|
+
}
|
|
1462
|
+
if (typeof persisted.selectedMenu === "string") {
|
|
1463
|
+
const validMenu = this.menuItems.find((item) => item.key === persisted.selectedMenu);
|
|
1464
|
+
if (validMenu) {
|
|
1465
|
+
this.selectedMenu = validMenu.key;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if (typeof persisted.selectedContext === "string") {
|
|
1469
|
+
this.selectedContext = persisted.selectedContext;
|
|
1470
|
+
this.pendingSelectedContext = persisted.selectedContext;
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
hydrateStateFromStorage() {
|
|
1474
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const persisted = loadInspectorState(INSPECTOR_STORAGE_KEY);
|
|
1478
|
+
if (!persisted) {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
const persistedButton = persisted.button;
|
|
1482
|
+
if (persistedButton) {
|
|
1483
|
+
if (isValidAnchor(persistedButton.anchor)) {
|
|
1484
|
+
this.contextState.button.anchor = persistedButton.anchor;
|
|
1485
|
+
}
|
|
1486
|
+
if (isValidPosition(persistedButton.anchorOffset)) {
|
|
1487
|
+
this.contextState.button.anchorOffset = persistedButton.anchorOffset;
|
|
1488
|
+
}
|
|
1489
|
+
if (typeof persistedButton.hasCustomPosition === "boolean") {
|
|
1490
|
+
this.hasCustomPosition.button = persistedButton.hasCustomPosition;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
const persistedWindow = persisted.window;
|
|
1494
|
+
if (persistedWindow) {
|
|
1495
|
+
if (isValidAnchor(persistedWindow.anchor)) {
|
|
1496
|
+
this.contextState.window.anchor = persistedWindow.anchor;
|
|
1497
|
+
}
|
|
1498
|
+
if (isValidPosition(persistedWindow.anchorOffset)) {
|
|
1499
|
+
this.contextState.window.anchorOffset = persistedWindow.anchorOffset;
|
|
1500
|
+
}
|
|
1501
|
+
if (isValidSize(persistedWindow.size)) {
|
|
1502
|
+
this.contextState.window.size = this.clampWindowSize(persistedWindow.size);
|
|
1503
|
+
}
|
|
1504
|
+
if (typeof persistedWindow.hasCustomPosition === "boolean") {
|
|
1505
|
+
this.hasCustomPosition.window = persistedWindow.hasCustomPosition;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
if (typeof persisted.selectedContext === "string") {
|
|
1509
|
+
this.selectedContext = persisted.selectedContext;
|
|
1510
|
+
this.pendingSelectedContext = persisted.selectedContext;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
get activeContext() {
|
|
1514
|
+
return this.isOpen ? "window" : "button";
|
|
1515
|
+
}
|
|
1516
|
+
measureContext(context) {
|
|
1517
|
+
const selector = context === "window" ? ".inspector-window" : ".console-button";
|
|
1518
|
+
const element = this.renderRoot?.querySelector(selector);
|
|
1519
|
+
if (!element) {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
const fallback = context === "window" ? DEFAULT_WINDOW_SIZE : DEFAULT_BUTTON_SIZE;
|
|
1523
|
+
updateSizeFromElement(this.contextState[context], element, fallback);
|
|
1524
|
+
}
|
|
1525
|
+
centerContext(context) {
|
|
1526
|
+
if (typeof window === "undefined") {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
const viewport = this.getViewportSize();
|
|
1530
|
+
centerContext(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1531
|
+
if (context === this.activeContext) {
|
|
1532
|
+
this.updateHostTransform(context);
|
|
1533
|
+
}
|
|
1534
|
+
this.hasCustomPosition[context] = false;
|
|
1535
|
+
this.persistState();
|
|
1536
|
+
}
|
|
1537
|
+
ensureWindowPlacement() {
|
|
1538
|
+
if (typeof window === "undefined") {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (!this.hasCustomPosition.window) {
|
|
1542
|
+
this.centerContext("window");
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
const viewport = this.getViewportSize();
|
|
1546
|
+
keepPositionWithinViewport(this.contextState.window, viewport, EDGE_MARGIN);
|
|
1547
|
+
updateAnchorFromPosition(this.contextState.window, viewport, EDGE_MARGIN);
|
|
1548
|
+
this.updateHostTransform("window");
|
|
1549
|
+
this.persistState();
|
|
1550
|
+
}
|
|
1551
|
+
constrainToViewport(position, context) {
|
|
1552
|
+
if (typeof window === "undefined") {
|
|
1553
|
+
return position;
|
|
1554
|
+
}
|
|
1555
|
+
const viewport = this.getViewportSize();
|
|
1556
|
+
return constrainToViewport(this.contextState[context], position, viewport, EDGE_MARGIN);
|
|
1557
|
+
}
|
|
1558
|
+
keepPositionWithinViewport(context) {
|
|
1559
|
+
if (typeof window === "undefined") {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const viewport = this.getViewportSize();
|
|
1563
|
+
keepPositionWithinViewport(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1564
|
+
}
|
|
1565
|
+
getViewportSize() {
|
|
1566
|
+
if (typeof window === "undefined") {
|
|
1567
|
+
return { ...DEFAULT_WINDOW_SIZE };
|
|
1568
|
+
}
|
|
1569
|
+
return { width: window.innerWidth, height: window.innerHeight };
|
|
1570
|
+
}
|
|
1571
|
+
persistState() {
|
|
1572
|
+
const state = {
|
|
1573
|
+
button: {
|
|
1574
|
+
anchor: this.contextState.button.anchor,
|
|
1575
|
+
anchorOffset: this.contextState.button.anchorOffset,
|
|
1576
|
+
hasCustomPosition: this.hasCustomPosition.button
|
|
1577
|
+
},
|
|
1578
|
+
window: {
|
|
1579
|
+
anchor: this.contextState.window.anchor,
|
|
1580
|
+
anchorOffset: this.contextState.window.anchorOffset,
|
|
1581
|
+
size: {
|
|
1582
|
+
width: Math.round(this.contextState.window.size.width),
|
|
1583
|
+
height: Math.round(this.contextState.window.size.height)
|
|
1584
|
+
},
|
|
1585
|
+
hasCustomPosition: this.hasCustomPosition.window
|
|
1586
|
+
},
|
|
1587
|
+
isOpen: this.isOpen,
|
|
1588
|
+
dockMode: this.dockMode,
|
|
1589
|
+
selectedMenu: this.selectedMenu,
|
|
1590
|
+
selectedContext: this.selectedContext
|
|
1591
|
+
};
|
|
1592
|
+
saveInspectorState(INSPECTOR_STORAGE_KEY, state);
|
|
1593
|
+
this.pendingSelectedContext = state.selectedContext ?? null;
|
|
1594
|
+
}
|
|
1595
|
+
clampWindowSize(size) {
|
|
1596
|
+
const minWidth = this.dockMode === "docked-left" ? MIN_WINDOW_WIDTH_DOCKED_LEFT : MIN_WINDOW_WIDTH;
|
|
1597
|
+
if (typeof window === "undefined") {
|
|
1598
|
+
return {
|
|
1599
|
+
width: Math.max(minWidth, size.width),
|
|
1600
|
+
height: Math.max(MIN_WINDOW_HEIGHT, size.height)
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
const viewport = this.getViewportSize();
|
|
1604
|
+
return clampSize(size, viewport, EDGE_MARGIN, minWidth, MIN_WINDOW_HEIGHT);
|
|
1605
|
+
}
|
|
1606
|
+
setDockMode(mode) {
|
|
1607
|
+
if (this.dockMode === mode) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
this.startHostTransition();
|
|
1611
|
+
this.removeDockStyles();
|
|
1612
|
+
this.dockMode = mode;
|
|
1613
|
+
if (mode !== "floating") {
|
|
1614
|
+
if (mode === "docked-left") {
|
|
1615
|
+
this.contextState.window.size.width = DOCKED_LEFT_WIDTH;
|
|
1616
|
+
}
|
|
1617
|
+
this.applyDockStyles();
|
|
1618
|
+
} else {
|
|
1619
|
+
this.contextState.window.size = { ...DEFAULT_WINDOW_SIZE };
|
|
1620
|
+
this.centerContext("window");
|
|
1621
|
+
}
|
|
1622
|
+
this.persistState();
|
|
1623
|
+
this.requestUpdate();
|
|
1624
|
+
this.updateHostTransform("window");
|
|
1625
|
+
}
|
|
1626
|
+
startHostTransition(duration = 300) {
|
|
1627
|
+
this.setAttribute("data-transitioning", "true");
|
|
1628
|
+
if (this.transitionTimeoutId !== null) {
|
|
1629
|
+
clearTimeout(this.transitionTimeoutId);
|
|
1630
|
+
}
|
|
1631
|
+
this.transitionTimeoutId = setTimeout(() => {
|
|
1632
|
+
this.removeAttribute("data-transitioning");
|
|
1633
|
+
this.transitionTimeoutId = null;
|
|
1634
|
+
}, duration);
|
|
1635
|
+
}
|
|
1636
|
+
applyDockStyles(skipTransition = false) {
|
|
1637
|
+
if (typeof document === "undefined" || !document.body) {
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
const computedStyle = window.getComputedStyle(document.body);
|
|
1641
|
+
this.previousBodyMargins = {
|
|
1642
|
+
left: computedStyle.marginLeft,
|
|
1643
|
+
bottom: computedStyle.marginBottom
|
|
1644
|
+
};
|
|
1645
|
+
if (!this.isResizing && !skipTransition) {
|
|
1646
|
+
document.body.style.transition = "margin 300ms ease";
|
|
1647
|
+
}
|
|
1648
|
+
if (this.dockMode === "docked-left") {
|
|
1649
|
+
document.body.style.marginLeft = `${this.contextState.window.size.width}px`;
|
|
1650
|
+
}
|
|
1651
|
+
if (!this.isResizing && !skipTransition) {
|
|
1652
|
+
setTimeout(() => {
|
|
1653
|
+
if (document.body) {
|
|
1654
|
+
document.body.style.transition = "";
|
|
1655
|
+
}
|
|
1656
|
+
}, 300);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
removeDockStyles() {
|
|
1660
|
+
if (typeof document === "undefined" || !document.body) {
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
if (!this.isResizing) {
|
|
1664
|
+
document.body.style.transition = "margin 300ms ease";
|
|
1665
|
+
}
|
|
1666
|
+
if (this.previousBodyMargins) {
|
|
1667
|
+
document.body.style.marginLeft = this.previousBodyMargins.left;
|
|
1668
|
+
document.body.style.marginBottom = this.previousBodyMargins.bottom;
|
|
1669
|
+
this.previousBodyMargins = null;
|
|
1670
|
+
} else {
|
|
1671
|
+
document.body.style.marginLeft = "";
|
|
1672
|
+
document.body.style.marginBottom = "";
|
|
1673
|
+
}
|
|
1674
|
+
setTimeout(() => {
|
|
1675
|
+
if (document.body) {
|
|
1676
|
+
document.body.style.transition = "";
|
|
1677
|
+
}
|
|
1678
|
+
}, 300);
|
|
1679
|
+
}
|
|
1680
|
+
updateHostTransform(context = this.activeContext) {
|
|
1681
|
+
if (context !== this.activeContext) {
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
if (this.isOpen && this.dockMode === "docked-left") {
|
|
1685
|
+
this.style.transform = `translate3d(0, 0, 0)`;
|
|
1686
|
+
} else {
|
|
1687
|
+
const { position } = this.contextState[context];
|
|
1688
|
+
this.style.transform = `translate3d(${position.x}px, ${position.y}px, 0)`;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
setDragging(value) {
|
|
1692
|
+
if (this.isDragging !== value) {
|
|
1693
|
+
this.isDragging = value;
|
|
1694
|
+
this.requestUpdate();
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
updateAnchorFromPosition(context) {
|
|
1698
|
+
if (typeof window === "undefined") {
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
const viewport = this.getViewportSize();
|
|
1702
|
+
updateAnchorFromPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1703
|
+
}
|
|
1704
|
+
snapButtonToCorner() {
|
|
1705
|
+
if (typeof window === "undefined") {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const viewport = this.getViewportSize();
|
|
1709
|
+
const state = this.contextState.button;
|
|
1710
|
+
const centerX = state.position.x + state.size.width / 2;
|
|
1711
|
+
const centerY = state.position.y + state.size.height / 2;
|
|
1712
|
+
const horizontal = centerX < viewport.width / 2 ? "left" : "right";
|
|
1713
|
+
const vertical = centerY < viewport.height / 2 ? "top" : "bottom";
|
|
1714
|
+
state.anchor = { horizontal, vertical };
|
|
1715
|
+
state.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
1716
|
+
this.startHostTransition();
|
|
1717
|
+
this.applyAnchorPosition("button");
|
|
1718
|
+
}
|
|
1719
|
+
applyAnchorPosition(context) {
|
|
1720
|
+
if (typeof window === "undefined") {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
const viewport = this.getViewportSize();
|
|
1724
|
+
applyAnchorPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1725
|
+
this.updateHostTransform(context);
|
|
1726
|
+
this.persistState();
|
|
1727
|
+
}
|
|
1728
|
+
resetResizeTracking() {
|
|
1729
|
+
this.resizePointerId = null;
|
|
1730
|
+
this.resizeStart = null;
|
|
1731
|
+
this.resizeInitialSize = null;
|
|
1732
|
+
this.isResizing = false;
|
|
1733
|
+
}
|
|
1734
|
+
resetPointerTracking() {
|
|
1735
|
+
this.pointerId = null;
|
|
1736
|
+
this.dragStart = null;
|
|
1737
|
+
this.pointerContext = null;
|
|
1738
|
+
this.setDragging(false);
|
|
1739
|
+
this.draggedDuringInteraction = false;
|
|
1740
|
+
}
|
|
1741
|
+
openInspector() {
|
|
1742
|
+
if (this.isOpen) {
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1745
|
+
this.showAnnouncementPreview = false;
|
|
1746
|
+
this.ensureAnnouncementLoading();
|
|
1747
|
+
this.isOpen = true;
|
|
1748
|
+
this.persistState();
|
|
1749
|
+
if (this.dockMode !== "floating") {
|
|
1750
|
+
this.applyDockStyles();
|
|
1751
|
+
}
|
|
1752
|
+
this.ensureWindowPlacement();
|
|
1753
|
+
this.requestUpdate();
|
|
1754
|
+
void this.updateComplete.then(() => {
|
|
1755
|
+
this.measureContext("window");
|
|
1756
|
+
if (this.dockMode === "floating") {
|
|
1757
|
+
if (this.hasCustomPosition.window) {
|
|
1758
|
+
this.applyAnchorPosition("window");
|
|
1759
|
+
} else {
|
|
1760
|
+
this.centerContext("window");
|
|
1761
|
+
}
|
|
1762
|
+
} else {
|
|
1763
|
+
this.updateHostTransform("window");
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
closeInspector() {
|
|
1768
|
+
if (!this.isOpen) {
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
this.isOpen = false;
|
|
1772
|
+
if (this.dockMode !== "floating") {
|
|
1773
|
+
this.removeDockStyles();
|
|
1774
|
+
}
|
|
1775
|
+
this.persistState();
|
|
1776
|
+
this.updateHostTransform("button");
|
|
1777
|
+
this.requestUpdate();
|
|
1778
|
+
void this.updateComplete.then(() => {
|
|
1779
|
+
this.measureContext("button");
|
|
1780
|
+
this.applyAnchorPosition("button");
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
renderIcon(name) {
|
|
1784
|
+
const iconNode = import_lucide.icons[name];
|
|
1785
|
+
if (!iconNode) {
|
|
1786
|
+
return import_lit.nothing;
|
|
1787
|
+
}
|
|
1788
|
+
const svgAttrs = {
|
|
1789
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1790
|
+
viewBox: "0 0 24 24",
|
|
1791
|
+
fill: "none",
|
|
1792
|
+
stroke: "currentColor",
|
|
1793
|
+
"stroke-width": "1.5",
|
|
1794
|
+
"stroke-linecap": "round",
|
|
1795
|
+
"stroke-linejoin": "round",
|
|
1796
|
+
class: "h-3.5 w-3.5"
|
|
1797
|
+
};
|
|
1798
|
+
const svgMarkup = `<svg ${this.serializeAttributes(svgAttrs)}>${iconNode.map(([tag, attrs]) => `<${tag} ${this.serializeAttributes(attrs)} />`).join("")}</svg>`;
|
|
1799
|
+
return (0, import_unsafe_html.unsafeHTML)(svgMarkup);
|
|
1800
|
+
}
|
|
1801
|
+
renderDockControls() {
|
|
1802
|
+
if (this.dockMode === "floating") {
|
|
1803
|
+
return import_lit.html`
|
|
1804
|
+
<button
|
|
1805
|
+
class="flex h-8 w-8 items-center justify-center rounded-md text-gray-400 transition hover:bg-gray-100 hover:text-gray-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-400"
|
|
1806
|
+
type="button"
|
|
1807
|
+
aria-label="Dock to left"
|
|
1808
|
+
title="Dock Left"
|
|
1809
|
+
@click=${() => this.handleDockClick("docked-left")}
|
|
1810
|
+
>
|
|
1811
|
+
${this.renderIcon("PanelLeft")}
|
|
1812
|
+
</button>
|
|
1813
|
+
`;
|
|
1814
|
+
} else {
|
|
1815
|
+
return import_lit.html`
|
|
1816
|
+
<button
|
|
1817
|
+
class="flex h-8 w-8 items-center justify-center rounded-md text-gray-400 transition hover:bg-gray-100 hover:text-gray-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-400"
|
|
1818
|
+
type="button"
|
|
1819
|
+
aria-label="Float window"
|
|
1820
|
+
title="Float"
|
|
1821
|
+
@click=${() => this.handleDockClick("floating")}
|
|
1822
|
+
>
|
|
1823
|
+
${this.renderIcon("Maximize2")}
|
|
1824
|
+
</button>
|
|
1825
|
+
`;
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
getDockedWindowStyles() {
|
|
1829
|
+
if (this.dockMode === "docked-left") {
|
|
1830
|
+
return {
|
|
1831
|
+
position: "fixed",
|
|
1832
|
+
top: "0",
|
|
1833
|
+
left: "0",
|
|
1834
|
+
bottom: "0",
|
|
1835
|
+
width: `${Math.round(this.contextState.window.size.width)}px`,
|
|
1836
|
+
height: "100vh",
|
|
1837
|
+
minWidth: `${MIN_WINDOW_WIDTH_DOCKED_LEFT}px`,
|
|
1838
|
+
borderRadius: "0"
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
return {
|
|
1842
|
+
width: `${Math.round(this.contextState.window.size.width)}px`,
|
|
1843
|
+
height: `${Math.round(this.contextState.window.size.height)}px`,
|
|
1844
|
+
minWidth: `${MIN_WINDOW_WIDTH}px`,
|
|
1845
|
+
minHeight: `${MIN_WINDOW_HEIGHT}px`
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
handleDockClick(mode) {
|
|
1849
|
+
this.setDockMode(mode);
|
|
1850
|
+
}
|
|
1851
|
+
serializeAttributes(attributes) {
|
|
1852
|
+
return Object.entries(attributes).filter(([key, value]) => key !== "key" && value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key}="${String(value).replace(/"/g, """)}"`).join(" ");
|
|
1853
|
+
}
|
|
1854
|
+
sanitizeForLogging(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1855
|
+
if (value === void 0) {
|
|
1856
|
+
return "[undefined]";
|
|
1857
|
+
}
|
|
1858
|
+
if (value === null || typeof value === "number" || typeof value === "boolean") {
|
|
1859
|
+
return value;
|
|
1860
|
+
}
|
|
1861
|
+
if (typeof value === "string") {
|
|
1862
|
+
return value;
|
|
1863
|
+
}
|
|
1864
|
+
if (typeof value === "bigint" || typeof value === "symbol" || typeof value === "function") {
|
|
1865
|
+
return String(value);
|
|
1866
|
+
}
|
|
1867
|
+
if (value instanceof Date) {
|
|
1868
|
+
return value.toISOString();
|
|
1869
|
+
}
|
|
1870
|
+
if (Array.isArray(value)) {
|
|
1871
|
+
if (depth >= 4) {
|
|
1872
|
+
return "[Truncated depth]";
|
|
1873
|
+
}
|
|
1874
|
+
return value.map((item) => this.sanitizeForLogging(item, depth + 1, seen));
|
|
1875
|
+
}
|
|
1876
|
+
if (typeof value === "object") {
|
|
1877
|
+
if (seen.has(value)) {
|
|
1878
|
+
return "[Circular]";
|
|
1879
|
+
}
|
|
1880
|
+
seen.add(value);
|
|
1881
|
+
if (depth >= 4) {
|
|
1882
|
+
return "[Truncated depth]";
|
|
1883
|
+
}
|
|
1884
|
+
const result = {};
|
|
1885
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
1886
|
+
result[key] = this.sanitizeForLogging(entry, depth + 1, seen);
|
|
1887
|
+
}
|
|
1888
|
+
return result;
|
|
1889
|
+
}
|
|
1890
|
+
return String(value);
|
|
1891
|
+
}
|
|
1892
|
+
normalizeEventPayload(_type, payload) {
|
|
1893
|
+
if (payload && typeof payload === "object" && "event" in payload) {
|
|
1894
|
+
const { event, ...rest } = payload;
|
|
1895
|
+
const cleaned = Object.keys(rest).length === 0 ? event : { event, ...rest };
|
|
1896
|
+
return this.sanitizeForLogging(cleaned);
|
|
1897
|
+
}
|
|
1898
|
+
return this.sanitizeForLogging(payload);
|
|
1899
|
+
}
|
|
1900
|
+
normalizeMessageContent(content) {
|
|
1901
|
+
if (typeof content === "string") {
|
|
1902
|
+
return content;
|
|
1903
|
+
}
|
|
1904
|
+
if (content && typeof content === "object" && "text" in content) {
|
|
1905
|
+
const maybeText = content.text;
|
|
1906
|
+
if (typeof maybeText === "string") {
|
|
1907
|
+
return maybeText;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
if (content === null || content === void 0) {
|
|
1911
|
+
return "";
|
|
1912
|
+
}
|
|
1913
|
+
if (typeof content === "object") {
|
|
1914
|
+
try {
|
|
1915
|
+
return JSON.stringify(this.sanitizeForLogging(content));
|
|
1916
|
+
} catch {
|
|
1917
|
+
return "";
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
return String(content);
|
|
1921
|
+
}
|
|
1922
|
+
normalizeToolCalls(raw) {
|
|
1923
|
+
if (!Array.isArray(raw)) {
|
|
1924
|
+
return [];
|
|
1925
|
+
}
|
|
1926
|
+
return raw.map((entry) => {
|
|
1927
|
+
if (!entry || typeof entry !== "object") {
|
|
1928
|
+
return null;
|
|
1929
|
+
}
|
|
1930
|
+
const call = entry;
|
|
1931
|
+
const fn = call.function;
|
|
1932
|
+
const functionName = typeof fn?.name === "string" ? fn.name : typeof call.toolName === "string" ? call.toolName : void 0;
|
|
1933
|
+
const args = fn && "arguments" in fn ? fn.arguments : call.arguments;
|
|
1934
|
+
const normalized = {
|
|
1935
|
+
id: typeof call.id === "string" ? call.id : void 0,
|
|
1936
|
+
toolName: typeof call.toolName === "string" ? call.toolName : functionName,
|
|
1937
|
+
status: typeof call.status === "string" ? call.status : void 0
|
|
1938
|
+
};
|
|
1939
|
+
if (functionName) {
|
|
1940
|
+
normalized.function = {
|
|
1941
|
+
name: functionName,
|
|
1942
|
+
arguments: this.sanitizeForLogging(args)
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
return normalized;
|
|
1946
|
+
}).filter((call) => Boolean(call));
|
|
1947
|
+
}
|
|
1948
|
+
normalizeAgentMessage(message) {
|
|
1949
|
+
if (!message || typeof message !== "object") {
|
|
1950
|
+
return null;
|
|
1951
|
+
}
|
|
1952
|
+
const raw = message;
|
|
1953
|
+
const role = typeof raw.role === "string" ? raw.role : "unknown";
|
|
1954
|
+
const contentText = this.normalizeMessageContent(raw.content);
|
|
1955
|
+
const toolCalls = this.normalizeToolCalls(raw.toolCalls);
|
|
1956
|
+
return {
|
|
1957
|
+
id: typeof raw.id === "string" ? raw.id : void 0,
|
|
1958
|
+
role,
|
|
1959
|
+
contentText,
|
|
1960
|
+
contentRaw: raw.content !== void 0 ? this.sanitizeForLogging(raw.content) : void 0,
|
|
1961
|
+
toolCalls
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
normalizeAgentMessages(messages) {
|
|
1965
|
+
if (!Array.isArray(messages)) {
|
|
1966
|
+
return null;
|
|
1967
|
+
}
|
|
1968
|
+
const normalized = messages.map((message) => this.normalizeAgentMessage(message)).filter((msg) => msg !== null);
|
|
1969
|
+
return normalized;
|
|
1970
|
+
}
|
|
1971
|
+
normalizeContextStore(context) {
|
|
1972
|
+
if (!context || typeof context !== "object") {
|
|
1973
|
+
return {};
|
|
1974
|
+
}
|
|
1975
|
+
const normalized = {};
|
|
1976
|
+
for (const [key, entry] of Object.entries(context)) {
|
|
1977
|
+
if (entry && typeof entry === "object" && "value" in entry) {
|
|
1978
|
+
const candidate = entry;
|
|
1979
|
+
const description = typeof candidate.description === "string" && candidate.description.trim().length > 0 ? candidate.description : void 0;
|
|
1980
|
+
normalized[key] = { description, value: candidate.value };
|
|
1981
|
+
} else {
|
|
1982
|
+
normalized[key] = { value: entry };
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return normalized;
|
|
1986
|
+
}
|
|
1987
|
+
getSelectedMenu() {
|
|
1988
|
+
const found = this.menuItems.find((item) => item.key === this.selectedMenu);
|
|
1989
|
+
return found ?? this.menuItems[0];
|
|
1990
|
+
}
|
|
1991
|
+
renderCoreWarningBanner() {
|
|
1992
|
+
if (this._core) {
|
|
1993
|
+
return import_lit.nothing;
|
|
1994
|
+
}
|
|
1995
|
+
return import_lit.html`
|
|
1996
|
+
<div class="mx-4 my-3 flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800">
|
|
1997
|
+
<span class="mt-0.5 shrink-0 text-amber-600">${this.renderIcon("AlertTriangle")}</span>
|
|
1998
|
+
<div class="space-y-1">
|
|
1999
|
+
<div class="font-semibold text-amber-900">CopilotKit core not attached</div>
|
|
2000
|
+
<p class="text-[11px] leading-snug text-amber-800">
|
|
2001
|
+
Pass a live <code>CopilotKitCore</code> instance to <code><cpk-web-inspector></code> or expose it on
|
|
2002
|
+
<code>window.__COPILOTKIT_CORE__</code> for auto-attach.
|
|
2003
|
+
</p>
|
|
2004
|
+
</div>
|
|
2005
|
+
</div>
|
|
2006
|
+
`;
|
|
2007
|
+
}
|
|
2008
|
+
getCoreStatusSummary() {
|
|
2009
|
+
if (!this._core) {
|
|
2010
|
+
return {
|
|
2011
|
+
label: "Core not attached",
|
|
2012
|
+
tone: "border border-amber-200 bg-amber-50 text-amber-800",
|
|
2013
|
+
description: "Pass a CopilotKitCore instance to <cpk-web-inspector> or enable auto-attach."
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
const status = this.runtimeStatus ?? import_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
2017
|
+
const lastErrorMessage = this.lastCoreError?.message;
|
|
2018
|
+
if (status === import_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
2019
|
+
return {
|
|
2020
|
+
label: "Runtime error",
|
|
2021
|
+
tone: "border border-rose-200 bg-rose-50 text-rose-700",
|
|
2022
|
+
description: lastErrorMessage ?? "CopilotKit runtime reported an error."
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
if (status === import_core.CopilotKitCoreRuntimeConnectionStatus.Connecting) {
|
|
2026
|
+
return {
|
|
2027
|
+
label: "Connecting",
|
|
2028
|
+
tone: "border border-amber-200 bg-amber-50 text-amber-800",
|
|
2029
|
+
description: "Waiting for CopilotKit runtime to finish connecting."
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
if (status === import_core.CopilotKitCoreRuntimeConnectionStatus.Connected) {
|
|
2033
|
+
return {
|
|
2034
|
+
label: "Connected",
|
|
2035
|
+
tone: "border border-emerald-200 bg-emerald-50 text-emerald-700",
|
|
2036
|
+
description: "Live runtime connection established."
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
return {
|
|
2040
|
+
label: "Disconnected",
|
|
2041
|
+
tone: "border border-gray-200 bg-gray-50 text-gray-700",
|
|
2042
|
+
description: lastErrorMessage ?? "Waiting for CopilotKit runtime to connect."
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
renderMainContent() {
|
|
2046
|
+
if (this.selectedMenu === "ag-ui-events") {
|
|
2047
|
+
return this.renderEventsTable();
|
|
2048
|
+
}
|
|
2049
|
+
if (this.selectedMenu === "agents") {
|
|
2050
|
+
return this.renderAgentsView();
|
|
2051
|
+
}
|
|
2052
|
+
if (this.selectedMenu === "frontend-tools") {
|
|
2053
|
+
return this.renderToolsView();
|
|
2054
|
+
}
|
|
2055
|
+
if (this.selectedMenu === "agent-context") {
|
|
2056
|
+
return this.renderContextView();
|
|
2057
|
+
}
|
|
2058
|
+
return import_lit.nothing;
|
|
2059
|
+
}
|
|
2060
|
+
renderEventsTable() {
|
|
2061
|
+
const events = this.getEventsForSelectedContext();
|
|
2062
|
+
const filteredEvents = this.filterEvents(events);
|
|
2063
|
+
const selectedLabel = this.selectedContext === "all-agents" ? "all agents" : `agent ${this.selectedContext}`;
|
|
2064
|
+
if (events.length === 0) {
|
|
2065
|
+
return import_lit.html`
|
|
2066
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-center">
|
|
2067
|
+
<div class="max-w-md">
|
|
2068
|
+
<div class="mb-3 flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
|
|
2069
|
+
${this.renderIcon("Zap")}
|
|
2070
|
+
</div>
|
|
2071
|
+
<p class="text-sm text-gray-600">No events yet</p>
|
|
2072
|
+
<p class="mt-2 text-xs text-gray-500">Trigger an agent run to see live activity.</p>
|
|
2073
|
+
</div>
|
|
2074
|
+
</div>
|
|
2075
|
+
`;
|
|
2076
|
+
}
|
|
2077
|
+
if (filteredEvents.length === 0) {
|
|
2078
|
+
return import_lit.html`
|
|
2079
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-center">
|
|
2080
|
+
<div class="max-w-md space-y-3">
|
|
2081
|
+
<div class="flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
|
|
2082
|
+
${this.renderIcon("Filter")}
|
|
2083
|
+
</div>
|
|
2084
|
+
<p class="text-sm text-gray-600">No events match the current filters.</p>
|
|
2085
|
+
<div>
|
|
2086
|
+
<button
|
|
2087
|
+
type="button"
|
|
2088
|
+
class="inline-flex items-center gap-1 rounded-md bg-gray-900 px-3 py-1.5 text-[11px] font-medium text-white transition hover:bg-gray-800"
|
|
2089
|
+
@click=${this.resetEventFilters}
|
|
2090
|
+
>
|
|
2091
|
+
${this.renderIcon("RefreshCw")}
|
|
2092
|
+
<span>Reset filters</span>
|
|
2093
|
+
</button>
|
|
2094
|
+
</div>
|
|
2095
|
+
</div>
|
|
2096
|
+
</div>
|
|
2097
|
+
`;
|
|
2098
|
+
}
|
|
2099
|
+
return import_lit.html`
|
|
2100
|
+
<div class="flex h-full flex-col">
|
|
2101
|
+
<div class="flex flex-col gap-1.5 border-b border-gray-200 bg-white px-4 py-2.5">
|
|
2102
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
2103
|
+
<div class="relative min-w-[200px] flex-1">
|
|
2104
|
+
<input
|
|
2105
|
+
type="search"
|
|
2106
|
+
class="w-full rounded-md border border-gray-200 px-3 py-1.5 text-[11px] text-gray-700 shadow-sm outline-none ring-1 ring-transparent transition focus:border-gray-300 focus:ring-gray-200"
|
|
2107
|
+
placeholder="Search agent, type, payload"
|
|
2108
|
+
.value=${this.eventFilterText}
|
|
2109
|
+
@input=${this.handleEventFilterInput}
|
|
2110
|
+
/>
|
|
2111
|
+
</div>
|
|
2112
|
+
<select
|
|
2113
|
+
class="w-40 rounded-md border border-gray-200 bg-white px-2 py-1.5 text-[11px] text-gray-700 shadow-sm outline-none transition focus:border-gray-300 focus:ring-2 focus:ring-gray-200"
|
|
2114
|
+
.value=${this.eventTypeFilter}
|
|
2115
|
+
@change=${this.handleEventTypeChange}
|
|
2116
|
+
>
|
|
2117
|
+
<option value="all">All event types</option>
|
|
2118
|
+
${AGENT_EVENT_TYPES.map(
|
|
2119
|
+
(type) => import_lit.html`<option value=${type}>${type.toLowerCase().replace(/_/g, " ")}</option>`
|
|
2120
|
+
)}
|
|
2121
|
+
</select>
|
|
2122
|
+
<div class="flex items-center gap-1 text-[11px]">
|
|
2123
|
+
<button
|
|
2124
|
+
type="button"
|
|
2125
|
+
class="tooltip-target flex h-8 w-8 items-center justify-center rounded-md border border-gray-200 bg-white text-gray-600 transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50"
|
|
2126
|
+
title="Reset filters"
|
|
2127
|
+
data-tooltip="Reset filters"
|
|
2128
|
+
aria-label="Reset filters"
|
|
2129
|
+
@click=${this.resetEventFilters}
|
|
2130
|
+
?disabled=${!this.eventFilterText && this.eventTypeFilter === "all"}
|
|
2131
|
+
>
|
|
2132
|
+
${this.renderIcon("RotateCw")}
|
|
2133
|
+
</button>
|
|
2134
|
+
<button
|
|
2135
|
+
type="button"
|
|
2136
|
+
class="tooltip-target flex h-8 w-8 items-center justify-center rounded-md border border-gray-200 bg-white text-gray-600 transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50"
|
|
2137
|
+
title="Export JSON"
|
|
2138
|
+
data-tooltip="Export JSON"
|
|
2139
|
+
aria-label="Export JSON"
|
|
2140
|
+
@click=${() => this.exportEvents(filteredEvents)}
|
|
2141
|
+
?disabled=${filteredEvents.length === 0}
|
|
2142
|
+
>
|
|
2143
|
+
${this.renderIcon("Download")}
|
|
2144
|
+
</button>
|
|
2145
|
+
<button
|
|
2146
|
+
type="button"
|
|
2147
|
+
class="tooltip-target flex h-8 w-8 items-center justify-center rounded-md border border-gray-200 bg-white text-gray-600 transition hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50"
|
|
2148
|
+
title="Clear events"
|
|
2149
|
+
data-tooltip="Clear events"
|
|
2150
|
+
aria-label="Clear events"
|
|
2151
|
+
@click=${this.handleClearEvents}
|
|
2152
|
+
?disabled=${events.length === 0}
|
|
2153
|
+
>
|
|
2154
|
+
${this.renderIcon("Trash2")}
|
|
2155
|
+
</button>
|
|
2156
|
+
</div>
|
|
2157
|
+
</div>
|
|
2158
|
+
<div class="text-[11px] text-gray-500">
|
|
2159
|
+
Showing ${filteredEvents.length} of ${events.length}${this.selectedContext === "all-agents" ? "" : ` for ${selectedLabel}`}
|
|
2160
|
+
</div>
|
|
2161
|
+
</div>
|
|
2162
|
+
<div class="relative h-full w-full overflow-y-auto overflow-x-hidden">
|
|
2163
|
+
<table class="w-full table-fixed border-collapse text-xs box-border">
|
|
2164
|
+
<thead class="sticky top-0 z-10">
|
|
2165
|
+
<tr class="bg-white">
|
|
2166
|
+
<th class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
2167
|
+
Agent
|
|
2168
|
+
</th>
|
|
2169
|
+
<th class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
2170
|
+
Time
|
|
2171
|
+
</th>
|
|
2172
|
+
<th class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
2173
|
+
Event Type
|
|
2174
|
+
</th>
|
|
2175
|
+
<th class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
2176
|
+
AG-UI Event
|
|
2177
|
+
</th>
|
|
2178
|
+
</tr>
|
|
2179
|
+
</thead>
|
|
2180
|
+
<tbody>
|
|
2181
|
+
${filteredEvents.map((event, index) => {
|
|
2182
|
+
const rowBg = index % 2 === 0 ? "bg-white" : "bg-gray-50/50";
|
|
2183
|
+
const badgeClasses = this.getEventBadgeClasses(event.type);
|
|
2184
|
+
const extractedEvent = this.extractEventFromPayload(event.payload);
|
|
2185
|
+
const inlineEvent = this.stringifyPayload(extractedEvent, false) || "\u2014";
|
|
2186
|
+
const prettyEvent = this.stringifyPayload(extractedEvent, true) || inlineEvent;
|
|
2187
|
+
const isExpanded = this.expandedRows.has(event.id);
|
|
2188
|
+
return import_lit.html`
|
|
2189
|
+
<tr
|
|
2190
|
+
class="${rowBg} cursor-pointer transition hover:bg-blue-50/50"
|
|
2191
|
+
@click=${() => this.toggleRowExpansion(event.id)}
|
|
2192
|
+
>
|
|
2193
|
+
<td class="border-l border-r border-b border-gray-200 px-3 py-2">
|
|
2194
|
+
<span class="font-mono text-[11px] text-gray-600">${event.agentId}</span>
|
|
2195
|
+
</td>
|
|
2196
|
+
<td class="border-r border-b border-gray-200 px-3 py-2 font-mono text-[11px] text-gray-600">
|
|
2197
|
+
<span title=${new Date(event.timestamp).toLocaleString()}>
|
|
2198
|
+
${new Date(event.timestamp).toLocaleTimeString()}
|
|
2199
|
+
</span>
|
|
2200
|
+
</td>
|
|
2201
|
+
<td class="border-r border-b border-gray-200 px-3 py-2">
|
|
2202
|
+
<span class=${badgeClasses}>${event.type}</span>
|
|
2203
|
+
</td>
|
|
2204
|
+
<td class="border-r border-b border-gray-200 px-3 py-2 font-mono text-[10px] text-gray-600 ${isExpanded ? "" : "truncate max-w-xs"}">
|
|
2205
|
+
${isExpanded ? import_lit.html`
|
|
2206
|
+
<div class="group relative">
|
|
2207
|
+
<pre class="m-0 whitespace-pre-wrap break-words text-[10px] font-mono text-gray-600">${prettyEvent}</pre>
|
|
2208
|
+
<button
|
|
2209
|
+
class="absolute right-0 top-0 cursor-pointer rounded px-2 py-1 text-[10px] opacity-0 transition group-hover:opacity-100 ${this.copiedEvents.has(event.id) ? "bg-green-100 text-green-700" : "bg-gray-100 text-gray-600 hover:bg-gray-200 hover:text-gray-900"}"
|
|
2210
|
+
@click=${(e) => {
|
|
2211
|
+
e.stopPropagation();
|
|
2212
|
+
this.copyToClipboard(prettyEvent, event.id);
|
|
2213
|
+
}}
|
|
2214
|
+
>
|
|
2215
|
+
${this.copiedEvents.has(event.id) ? import_lit.html`<span>✓ Copied</span>` : import_lit.html`<span>Copy</span>`}
|
|
2216
|
+
</button>
|
|
2217
|
+
</div>
|
|
2218
|
+
` : inlineEvent}
|
|
2219
|
+
</td>
|
|
2220
|
+
</tr>
|
|
2221
|
+
`;
|
|
2222
|
+
})}
|
|
2223
|
+
</tbody>
|
|
2224
|
+
</table>
|
|
2225
|
+
</div>
|
|
2226
|
+
</div>
|
|
2227
|
+
`;
|
|
2228
|
+
}
|
|
2229
|
+
handleEventFilterInput(event) {
|
|
2230
|
+
const target = event.target;
|
|
2231
|
+
this.eventFilterText = target?.value ?? "";
|
|
2232
|
+
this.requestUpdate();
|
|
2233
|
+
}
|
|
2234
|
+
handleEventTypeChange(event) {
|
|
2235
|
+
const target = event.target;
|
|
2236
|
+
const value = target?.value;
|
|
2237
|
+
if (!value) {
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
this.eventTypeFilter = value;
|
|
2241
|
+
this.requestUpdate();
|
|
2242
|
+
}
|
|
2243
|
+
resetEventFilters() {
|
|
2244
|
+
this.eventFilterText = "";
|
|
2245
|
+
this.eventTypeFilter = "all";
|
|
2246
|
+
this.requestUpdate();
|
|
2247
|
+
}
|
|
2248
|
+
exportEvents(events) {
|
|
2249
|
+
try {
|
|
2250
|
+
const payload = JSON.stringify(events, null, 2);
|
|
2251
|
+
const blob = new Blob([payload], { type: "application/json" });
|
|
2252
|
+
const url = URL.createObjectURL(blob);
|
|
2253
|
+
const anchor = document.createElement("a");
|
|
2254
|
+
anchor.href = url;
|
|
2255
|
+
anchor.download = `copilotkit-events-${Date.now()}.json`;
|
|
2256
|
+
anchor.click();
|
|
2257
|
+
URL.revokeObjectURL(url);
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
console.error("Failed to export events", error);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
renderAgentsView() {
|
|
2263
|
+
if (this.selectedContext === "all-agents") {
|
|
2264
|
+
return import_lit.html`
|
|
2265
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-center">
|
|
2266
|
+
<div class="max-w-md">
|
|
2267
|
+
<div class="mb-3 flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
|
|
2268
|
+
${this.renderIcon("Bot")}
|
|
2269
|
+
</div>
|
|
2270
|
+
<p class="text-sm text-gray-600">No agent selected</p>
|
|
2271
|
+
<p class="mt-2 text-xs text-gray-500">Select an agent from the dropdown above to view details.</p>
|
|
2272
|
+
</div>
|
|
2273
|
+
</div>
|
|
2274
|
+
`;
|
|
2275
|
+
}
|
|
2276
|
+
const agentId = this.selectedContext;
|
|
2277
|
+
const status = this.getAgentStatus(agentId);
|
|
2278
|
+
const stats = this.getAgentStats(agentId);
|
|
2279
|
+
const state = this.getLatestStateForAgent(agentId);
|
|
2280
|
+
const messages = this.getLatestMessagesForAgent(agentId);
|
|
2281
|
+
const statusColors = {
|
|
2282
|
+
running: "bg-emerald-50 text-emerald-700",
|
|
2283
|
+
idle: "bg-gray-100 text-gray-600",
|
|
2284
|
+
error: "bg-rose-50 text-rose-700"
|
|
2285
|
+
};
|
|
2286
|
+
return import_lit.html`
|
|
2287
|
+
<div class="flex flex-col gap-4 p-4 overflow-auto">
|
|
2288
|
+
<!-- Agent Overview Card -->
|
|
2289
|
+
<div class="rounded-lg border border-gray-200 bg-white p-4">
|
|
2290
|
+
<div class="flex items-start justify-between mb-4">
|
|
2291
|
+
<div class="flex items-center gap-3">
|
|
2292
|
+
<div class="flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 text-blue-600">
|
|
2293
|
+
${this.renderIcon("Bot")}
|
|
2294
|
+
</div>
|
|
2295
|
+
<div>
|
|
2296
|
+
<h3 class="font-semibold text-sm text-gray-900">${agentId}</h3>
|
|
2297
|
+
<span class="inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${statusColors[status]} relative -translate-y-[2px]">
|
|
2298
|
+
<span class="h-1.5 w-1.5 rounded-full ${status === "running" ? "bg-emerald-500 animate-pulse" : status === "error" ? "bg-rose-500" : "bg-gray-400"}"></span>
|
|
2299
|
+
${status.charAt(0).toUpperCase() + status.slice(1)}
|
|
2300
|
+
</span>
|
|
2301
|
+
</div>
|
|
2302
|
+
</div>
|
|
2303
|
+
${stats.lastActivity ? import_lit.html`<span class="text-xs text-gray-500">Last activity: ${new Date(stats.lastActivity).toLocaleTimeString()}</span>` : import_lit.nothing}
|
|
2304
|
+
</div>
|
|
2305
|
+
<div class="grid grid-cols-2 gap-4 md:grid-cols-4">
|
|
2306
|
+
<button
|
|
2307
|
+
type="button"
|
|
2308
|
+
class="rounded-md bg-gray-50 px-3 py-2 text-left transition hover:bg-gray-100 cursor-pointer overflow-hidden"
|
|
2309
|
+
@click=${() => this.handleMenuSelect("ag-ui-events")}
|
|
2310
|
+
title="View all events in AG-UI Events"
|
|
2311
|
+
>
|
|
2312
|
+
<div class="truncate whitespace-nowrap text-xs text-gray-600">Total Events</div>
|
|
2313
|
+
<div class="text-lg font-semibold text-gray-900">${stats.totalEvents}</div>
|
|
2314
|
+
</button>
|
|
2315
|
+
<div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
|
|
2316
|
+
<div class="truncate whitespace-nowrap text-xs text-gray-600">Messages</div>
|
|
2317
|
+
<div class="text-lg font-semibold text-gray-900">${stats.messages}</div>
|
|
2318
|
+
</div>
|
|
2319
|
+
<div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
|
|
2320
|
+
<div class="truncate whitespace-nowrap text-xs text-gray-600">Tool Calls</div>
|
|
2321
|
+
<div class="text-lg font-semibold text-gray-900">${stats.toolCalls}</div>
|
|
2322
|
+
</div>
|
|
2323
|
+
<div class="rounded-md bg-gray-50 px-3 py-2 overflow-hidden">
|
|
2324
|
+
<div class="truncate whitespace-nowrap text-xs text-gray-600">Errors</div>
|
|
2325
|
+
<div class="text-lg font-semibold text-gray-900">${stats.errors}</div>
|
|
2326
|
+
</div>
|
|
2327
|
+
</div>
|
|
2328
|
+
</div>
|
|
2329
|
+
|
|
2330
|
+
<!-- Current State Section -->
|
|
2331
|
+
<div class="rounded-lg border border-gray-200 bg-white">
|
|
2332
|
+
<div class="border-b border-gray-200 px-4 py-3">
|
|
2333
|
+
<h4 class="text-sm font-semibold text-gray-900">Current State</h4>
|
|
2334
|
+
</div>
|
|
2335
|
+
<div class="overflow-auto p-4">
|
|
2336
|
+
${this.hasRenderableState(state) ? import_lit.html`
|
|
2337
|
+
<pre class="overflow-auto rounded-md bg-gray-50 p-3 text-xs text-gray-800 max-h-64"><code>${this.formatStateForDisplay(state)}</code></pre>
|
|
2338
|
+
` : import_lit.html`
|
|
2339
|
+
<div class="flex h-40 items-center justify-center text-xs text-gray-500">
|
|
2340
|
+
<div class="flex items-center gap-2 text-gray-500">
|
|
2341
|
+
<span class="text-lg text-gray-400">${this.renderIcon("Database")}</span>
|
|
2342
|
+
<span>State is empty</span>
|
|
2343
|
+
</div>
|
|
2344
|
+
</div>
|
|
2345
|
+
`}
|
|
2346
|
+
</div>
|
|
2347
|
+
</div>
|
|
2348
|
+
|
|
2349
|
+
<!-- Current Messages Section -->
|
|
2350
|
+
<div class="rounded-lg border border-gray-200 bg-white">
|
|
2351
|
+
<div class="border-b border-gray-200 px-4 py-3">
|
|
2352
|
+
<h4 class="text-sm font-semibold text-gray-900">Current Messages</h4>
|
|
2353
|
+
</div>
|
|
2354
|
+
<div class="overflow-auto">
|
|
2355
|
+
${messages && messages.length > 0 ? import_lit.html`
|
|
2356
|
+
<table class="w-full text-xs">
|
|
2357
|
+
<thead class="bg-gray-50">
|
|
2358
|
+
<tr>
|
|
2359
|
+
<th class="px-4 py-2 text-left font-medium text-gray-700">Role</th>
|
|
2360
|
+
<th class="px-4 py-2 text-left font-medium text-gray-700">Content</th>
|
|
2361
|
+
</tr>
|
|
2362
|
+
</thead>
|
|
2363
|
+
<tbody class="divide-y divide-gray-200">
|
|
2364
|
+
${messages.map((msg) => {
|
|
2365
|
+
const role = msg.role || "unknown";
|
|
2366
|
+
const roleColors = {
|
|
2367
|
+
user: "bg-blue-100 text-blue-800",
|
|
2368
|
+
assistant: "bg-green-100 text-green-800",
|
|
2369
|
+
system: "bg-gray-100 text-gray-800",
|
|
2370
|
+
tool: "bg-amber-100 text-amber-800",
|
|
2371
|
+
unknown: "bg-gray-100 text-gray-600"
|
|
2372
|
+
};
|
|
2373
|
+
const rawContent = msg.contentText ?? "";
|
|
2374
|
+
const toolCalls = msg.toolCalls ?? [];
|
|
2375
|
+
const hasContent = rawContent.trim().length > 0;
|
|
2376
|
+
const contentFallback = toolCalls.length > 0 ? "Invoked tool call" : "\u2014";
|
|
2377
|
+
return import_lit.html`
|
|
2378
|
+
<tr>
|
|
2379
|
+
<td class="px-4 py-2 align-top">
|
|
2380
|
+
<span class="inline-flex rounded px-2 py-0.5 text-[10px] font-medium ${roleColors[role] || roleColors.unknown}">
|
|
2381
|
+
${role}
|
|
2382
|
+
</span>
|
|
2383
|
+
</td>
|
|
2384
|
+
<td class="px-4 py-2">
|
|
2385
|
+
${hasContent ? import_lit.html`<div class="max-w-2xl whitespace-pre-wrap break-words text-gray-700">${rawContent}</div>` : import_lit.html`<div class="text-xs italic text-gray-400">${contentFallback}</div>`}
|
|
2386
|
+
${role === "assistant" && toolCalls.length > 0 ? this.renderToolCallDetails(toolCalls) : import_lit.nothing}
|
|
2387
|
+
</td>
|
|
2388
|
+
</tr>
|
|
2389
|
+
`;
|
|
2390
|
+
})}
|
|
2391
|
+
</tbody>
|
|
2392
|
+
</table>
|
|
2393
|
+
` : import_lit.html`
|
|
2394
|
+
<div class="flex h-40 items-center justify-center text-xs text-gray-500">
|
|
2395
|
+
<div class="flex items-center gap-2 text-gray-500">
|
|
2396
|
+
<span class="text-lg text-gray-400">${this.renderIcon("MessageSquare")}</span>
|
|
2397
|
+
<span>No messages available</span>
|
|
2398
|
+
</div>
|
|
2399
|
+
</div>
|
|
2400
|
+
`}
|
|
2401
|
+
</div>
|
|
2402
|
+
</div>
|
|
2403
|
+
</div>
|
|
2404
|
+
`;
|
|
2405
|
+
}
|
|
2406
|
+
renderContextDropdown() {
|
|
2407
|
+
const filteredOptions = this.selectedMenu === "agents" ? this.contextOptions.filter((opt) => opt.key !== "all-agents") : this.contextOptions;
|
|
2408
|
+
const selectedLabel = filteredOptions.find((opt) => opt.key === this.selectedContext)?.label ?? "";
|
|
2409
|
+
return import_lit.html`
|
|
2410
|
+
<div class="relative z-40 min-w-0 flex-1" data-context-dropdown-root="true">
|
|
2411
|
+
<button
|
|
2412
|
+
type="button"
|
|
2413
|
+
class="relative z-40 flex w-full min-w-0 max-w-[240px] items-center gap-1.5 rounded-md border border-gray-200 px-2 py-1 text-xs font-medium text-gray-700 transition hover:border-gray-300 hover:bg-gray-50"
|
|
2414
|
+
@pointerdown=${this.handleContextDropdownToggle}
|
|
2415
|
+
>
|
|
2416
|
+
<span class="truncate flex-1 text-left">${selectedLabel}</span>
|
|
2417
|
+
<span class="shrink-0 text-gray-400">${this.renderIcon("ChevronDown")}</span>
|
|
2418
|
+
</button>
|
|
2419
|
+
${this.contextMenuOpen ? import_lit.html`
|
|
2420
|
+
<div
|
|
2421
|
+
class="absolute left-0 z-50 mt-1.5 w-40 rounded-md border border-gray-200 bg-white py-1 shadow-md ring-1 ring-black/5"
|
|
2422
|
+
data-context-dropdown-root="true"
|
|
2423
|
+
>
|
|
2424
|
+
${filteredOptions.map(
|
|
2425
|
+
(option) => import_lit.html`
|
|
2426
|
+
<button
|
|
2427
|
+
type="button"
|
|
2428
|
+
class="flex w-full items-center justify-between px-3 py-1.5 text-left text-xs transition hover:bg-gray-50 focus:bg-gray-50 focus:outline-none"
|
|
2429
|
+
data-context-dropdown-root="true"
|
|
2430
|
+
@click=${() => this.handleContextOptionSelect(option.key)}
|
|
2431
|
+
>
|
|
2432
|
+
<span class="truncate ${option.key === this.selectedContext ? "text-gray-900 font-medium" : "text-gray-600"}">${option.label}</span>
|
|
2433
|
+
${option.key === this.selectedContext ? import_lit.html`<span class="text-gray-500">${this.renderIcon("Check")}</span>` : import_lit.nothing}
|
|
2434
|
+
</button>
|
|
2435
|
+
`
|
|
2436
|
+
)}
|
|
2437
|
+
</div>
|
|
2438
|
+
` : import_lit.nothing}
|
|
2439
|
+
</div>
|
|
2440
|
+
`;
|
|
2441
|
+
}
|
|
2442
|
+
handleMenuSelect(key) {
|
|
2443
|
+
if (!this.menuItems.some((item) => item.key === key)) {
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
this.selectedMenu = key;
|
|
2447
|
+
if (key === "agents" && this.selectedContext === "all-agents") {
|
|
2448
|
+
const agentOptions = this.contextOptions.filter((opt) => opt.key !== "all-agents");
|
|
2449
|
+
if (agentOptions.length > 0) {
|
|
2450
|
+
const defaultAgent = agentOptions.find((opt) => opt.key === "default");
|
|
2451
|
+
this.selectedContext = defaultAgent ? defaultAgent.key : agentOptions[0].key;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
this.contextMenuOpen = false;
|
|
2455
|
+
this.persistState();
|
|
2456
|
+
this.requestUpdate();
|
|
2457
|
+
}
|
|
2458
|
+
handleContextDropdownToggle(event) {
|
|
2459
|
+
event.preventDefault();
|
|
2460
|
+
event.stopPropagation();
|
|
2461
|
+
this.contextMenuOpen = !this.contextMenuOpen;
|
|
2462
|
+
this.requestUpdate();
|
|
2463
|
+
}
|
|
2464
|
+
handleContextOptionSelect(key) {
|
|
2465
|
+
if (!this.contextOptions.some((option) => option.key === key)) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
if (this.selectedContext !== key) {
|
|
2469
|
+
this.selectedContext = key;
|
|
2470
|
+
this.expandedRows.clear();
|
|
2471
|
+
}
|
|
2472
|
+
this.contextMenuOpen = false;
|
|
2473
|
+
this.persistState();
|
|
2474
|
+
this.requestUpdate();
|
|
2475
|
+
}
|
|
2476
|
+
renderToolsView() {
|
|
2477
|
+
if (!this._core) {
|
|
2478
|
+
return import_lit.html`
|
|
2479
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-xs text-gray-500">
|
|
2480
|
+
No core instance available
|
|
2481
|
+
</div>
|
|
2482
|
+
`;
|
|
2483
|
+
}
|
|
2484
|
+
this.refreshToolsSnapshot();
|
|
2485
|
+
const allTools = this.cachedTools;
|
|
2486
|
+
if (allTools.length === 0) {
|
|
2487
|
+
return import_lit.html`
|
|
2488
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-center">
|
|
2489
|
+
<div class="max-w-md">
|
|
2490
|
+
<div class="mb-3 flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
|
|
2491
|
+
${this.renderIcon("Hammer")}
|
|
2492
|
+
</div>
|
|
2493
|
+
<p class="text-sm text-gray-600">No tools available</p>
|
|
2494
|
+
<p class="mt-2 text-xs text-gray-500">Tools will appear here once agents are configured with tool handlers or renderers.</p>
|
|
2495
|
+
</div>
|
|
2496
|
+
</div>
|
|
2497
|
+
`;
|
|
2498
|
+
}
|
|
2499
|
+
const filteredTools = this.selectedContext === "all-agents" ? allTools : allTools.filter((tool) => !tool.agentId || tool.agentId === this.selectedContext);
|
|
2500
|
+
return import_lit.html`
|
|
2501
|
+
<div class="flex h-full flex-col overflow-hidden">
|
|
2502
|
+
<div class="overflow-auto p-4">
|
|
2503
|
+
<div class="space-y-3">
|
|
2504
|
+
${filteredTools.map((tool) => this.renderToolCard(tool))}
|
|
2505
|
+
</div>
|
|
2506
|
+
</div>
|
|
2507
|
+
</div>
|
|
2508
|
+
`;
|
|
2509
|
+
}
|
|
2510
|
+
extractToolsFromAgents() {
|
|
2511
|
+
if (!this._core) {
|
|
2512
|
+
return [];
|
|
2513
|
+
}
|
|
2514
|
+
const tools = [];
|
|
2515
|
+
for (const coreTool of this._core.tools ?? []) {
|
|
2516
|
+
tools.push({
|
|
2517
|
+
agentId: coreTool.agentId ?? "",
|
|
2518
|
+
name: coreTool.name,
|
|
2519
|
+
description: coreTool.description,
|
|
2520
|
+
parameters: coreTool.parameters,
|
|
2521
|
+
type: "handler"
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
for (const [agentId, agent] of Object.entries(this._core.agents)) {
|
|
2525
|
+
if (!agent) continue;
|
|
2526
|
+
const handlers = agent.toolHandlers;
|
|
2527
|
+
if (handlers && typeof handlers === "object") {
|
|
2528
|
+
for (const [toolName, handler] of Object.entries(handlers)) {
|
|
2529
|
+
if (handler && typeof handler === "object") {
|
|
2530
|
+
const handlerObj = handler;
|
|
2531
|
+
tools.push({
|
|
2532
|
+
agentId,
|
|
2533
|
+
name: toolName,
|
|
2534
|
+
description: typeof handlerObj.description === "string" && handlerObj.description || handlerObj.tool?.description,
|
|
2535
|
+
parameters: handlerObj.parameters ?? handlerObj.tool?.parameters,
|
|
2536
|
+
type: "handler"
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
const renderers = agent.toolRenderers;
|
|
2542
|
+
if (renderers && typeof renderers === "object") {
|
|
2543
|
+
for (const [toolName, renderer] of Object.entries(renderers)) {
|
|
2544
|
+
if (!tools.some((t) => t.agentId === agentId && t.name === toolName)) {
|
|
2545
|
+
if (renderer && typeof renderer === "object") {
|
|
2546
|
+
const rendererObj = renderer;
|
|
2547
|
+
tools.push({
|
|
2548
|
+
agentId,
|
|
2549
|
+
name: toolName,
|
|
2550
|
+
description: typeof rendererObj.description === "string" && rendererObj.description || rendererObj.tool?.description,
|
|
2551
|
+
parameters: rendererObj.parameters ?? rendererObj.tool?.parameters,
|
|
2552
|
+
type: "renderer"
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return tools.sort((a, b) => {
|
|
2560
|
+
const agentCompare = a.agentId.localeCompare(b.agentId);
|
|
2561
|
+
if (agentCompare !== 0) return agentCompare;
|
|
2562
|
+
return a.name.localeCompare(b.name);
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
renderToolCard(tool) {
|
|
2566
|
+
const isExpanded = this.expandedTools.has(`${tool.agentId}:${tool.name}`);
|
|
2567
|
+
const schema = this.extractSchemaInfo(tool.parameters);
|
|
2568
|
+
const typeColors = {
|
|
2569
|
+
handler: "bg-blue-50 text-blue-700 border-blue-200",
|
|
2570
|
+
renderer: "bg-purple-50 text-purple-700 border-purple-200"
|
|
2571
|
+
};
|
|
2572
|
+
return import_lit.html`
|
|
2573
|
+
<div class="rounded-lg border border-gray-200 bg-white overflow-hidden">
|
|
2574
|
+
<button
|
|
2575
|
+
type="button"
|
|
2576
|
+
class="w-full px-4 py-3 text-left transition hover:bg-gray-50"
|
|
2577
|
+
@click=${() => this.toggleToolExpansion(`${tool.agentId}:${tool.name}`)}
|
|
2578
|
+
>
|
|
2579
|
+
<div class="flex items-start justify-between gap-3">
|
|
2580
|
+
<div class="flex-1 min-w-0">
|
|
2581
|
+
<div class="flex items-center gap-2 mb-1">
|
|
2582
|
+
<span class="font-mono text-sm font-semibold text-gray-900">${tool.name}</span>
|
|
2583
|
+
<span class="inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[10px] font-medium ${typeColors[tool.type]}">
|
|
2584
|
+
${tool.type}
|
|
2585
|
+
</span>
|
|
2586
|
+
</div>
|
|
2587
|
+
<div class="flex items-center gap-2 text-xs text-gray-500">
|
|
2588
|
+
<span class="flex items-center gap-1">
|
|
2589
|
+
${this.renderIcon("Bot")}
|
|
2590
|
+
<span class="font-mono">${tool.agentId}</span>
|
|
2591
|
+
</span>
|
|
2592
|
+
${schema.properties.length > 0 ? import_lit.html`
|
|
2593
|
+
<span class="text-gray-300">•</span>
|
|
2594
|
+
<span>${schema.properties.length} parameter${schema.properties.length !== 1 ? "s" : ""}</span>
|
|
2595
|
+
` : import_lit.nothing}
|
|
2596
|
+
</div>
|
|
2597
|
+
${tool.description ? import_lit.html`<p class="mt-2 text-xs text-gray-600">${tool.description}</p>` : import_lit.nothing}
|
|
2598
|
+
</div>
|
|
2599
|
+
<span class="shrink-0 text-gray-400 transition ${isExpanded ? "rotate-180" : ""}">
|
|
2600
|
+
${this.renderIcon("ChevronDown")}
|
|
2601
|
+
</span>
|
|
2602
|
+
</div>
|
|
2603
|
+
</button>
|
|
2604
|
+
|
|
2605
|
+
${isExpanded ? import_lit.html`
|
|
2606
|
+
<div class="border-t border-gray-200 bg-gray-50/50 px-4 py-3">
|
|
2607
|
+
${schema.properties.length > 0 ? import_lit.html`
|
|
2608
|
+
<h5 class="mb-3 text-xs font-semibold text-gray-700">Parameters</h5>
|
|
2609
|
+
<div class="space-y-3">
|
|
2610
|
+
${schema.properties.map((prop) => import_lit.html`
|
|
2611
|
+
<div class="rounded-md border border-gray-200 bg-white p-3">
|
|
2612
|
+
<div class="flex items-start justify-between gap-2 mb-1">
|
|
2613
|
+
<span class="font-mono text-xs font-medium text-gray-900">${prop.name}</span>
|
|
2614
|
+
<div class="flex items-center gap-1.5 shrink-0">
|
|
2615
|
+
${prop.required ? import_lit.html`<span class="text-[9px] rounded border border-rose-200 bg-rose-50 px-1 py-0.5 font-medium text-rose-700">required</span>` : import_lit.html`<span class="text-[9px] rounded border border-gray-200 bg-gray-50 px-1 py-0.5 font-medium text-gray-600">optional</span>`}
|
|
2616
|
+
${prop.type ? import_lit.html`<span class="text-[9px] rounded border border-gray-200 bg-gray-50 px-1 py-0.5 font-mono text-gray-600">${prop.type}</span>` : import_lit.nothing}
|
|
2617
|
+
</div>
|
|
2618
|
+
</div>
|
|
2619
|
+
${prop.description ? import_lit.html`<p class="mt-1 text-xs text-gray-600">${prop.description}</p>` : import_lit.nothing}
|
|
2620
|
+
${prop.defaultValue !== void 0 ? import_lit.html`
|
|
2621
|
+
<div class="mt-2 flex items-center gap-1.5 text-[10px] text-gray-500">
|
|
2622
|
+
<span>Default:</span>
|
|
2623
|
+
<code class="rounded bg-gray-100 px-1 py-0.5 font-mono">${JSON.stringify(prop.defaultValue)}</code>
|
|
2624
|
+
</div>
|
|
2625
|
+
` : import_lit.nothing}
|
|
2626
|
+
${prop.enum && prop.enum.length > 0 ? import_lit.html`
|
|
2627
|
+
<div class="mt-2">
|
|
2628
|
+
<span class="text-[10px] text-gray-500">Allowed values:</span>
|
|
2629
|
+
<div class="mt-1 flex flex-wrap gap-1">
|
|
2630
|
+
${prop.enum.map((val) => import_lit.html`
|
|
2631
|
+
<code class="rounded border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[10px] font-mono text-gray-700">${JSON.stringify(val)}</code>
|
|
2632
|
+
`)}
|
|
2633
|
+
</div>
|
|
2634
|
+
</div>
|
|
2635
|
+
` : import_lit.nothing}
|
|
2636
|
+
</div>
|
|
2637
|
+
`)}
|
|
2638
|
+
</div>
|
|
2639
|
+
` : import_lit.html`
|
|
2640
|
+
<div class="flex items-center justify-center py-4 text-xs text-gray-500">
|
|
2641
|
+
<span>No parameters defined</span>
|
|
2642
|
+
</div>
|
|
2643
|
+
`}
|
|
2644
|
+
</div>
|
|
2645
|
+
` : import_lit.nothing}
|
|
2646
|
+
</div>
|
|
2647
|
+
`;
|
|
2648
|
+
}
|
|
2649
|
+
extractSchemaInfo(parameters) {
|
|
2650
|
+
const result = { properties: [] };
|
|
2651
|
+
if (!parameters || typeof parameters !== "object") {
|
|
2652
|
+
return result;
|
|
2653
|
+
}
|
|
2654
|
+
const zodDef = parameters._def;
|
|
2655
|
+
if (zodDef && typeof zodDef === "object") {
|
|
2656
|
+
if (zodDef.typeName === "ZodObject") {
|
|
2657
|
+
const rawShape = zodDef.shape;
|
|
2658
|
+
const shape = typeof rawShape === "function" ? rawShape() : rawShape;
|
|
2659
|
+
if (!shape || typeof shape !== "object") {
|
|
2660
|
+
return result;
|
|
2661
|
+
}
|
|
2662
|
+
const requiredKeys = /* @__PURE__ */ new Set();
|
|
2663
|
+
if (zodDef.unknownKeys === "strict" || !zodDef.catchall) {
|
|
2664
|
+
Object.keys(shape || {}).forEach((key) => {
|
|
2665
|
+
const candidate = shape[key];
|
|
2666
|
+
const fieldDef = candidate?._def;
|
|
2667
|
+
if (fieldDef && !this.isZodOptional(candidate)) {
|
|
2668
|
+
requiredKeys.add(key);
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
for (const [key, value] of Object.entries(shape || {})) {
|
|
2673
|
+
const fieldInfo = this.extractZodFieldInfo(value);
|
|
2674
|
+
result.properties.push({
|
|
2675
|
+
name: key,
|
|
2676
|
+
type: fieldInfo.type,
|
|
2677
|
+
description: fieldInfo.description,
|
|
2678
|
+
required: requiredKeys.has(key),
|
|
2679
|
+
defaultValue: fieldInfo.defaultValue,
|
|
2680
|
+
enum: fieldInfo.enum
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
} else if (parameters.type === "object" && parameters.properties) {
|
|
2685
|
+
const props = parameters.properties;
|
|
2686
|
+
const required = new Set(
|
|
2687
|
+
Array.isArray(parameters.required) ? parameters.required : []
|
|
2688
|
+
);
|
|
2689
|
+
for (const [key, value] of Object.entries(props ?? {})) {
|
|
2690
|
+
const prop = value;
|
|
2691
|
+
result.properties.push({
|
|
2692
|
+
name: key,
|
|
2693
|
+
type: prop.type,
|
|
2694
|
+
description: typeof prop.description === "string" ? prop.description : void 0,
|
|
2695
|
+
required: required.has(key),
|
|
2696
|
+
defaultValue: prop.default,
|
|
2697
|
+
enum: Array.isArray(prop.enum) ? prop.enum : void 0
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
return result;
|
|
2702
|
+
}
|
|
2703
|
+
isZodOptional(zodSchema) {
|
|
2704
|
+
const schema = zodSchema;
|
|
2705
|
+
if (!schema?._def) return false;
|
|
2706
|
+
const def = schema._def;
|
|
2707
|
+
if (def.typeName === "ZodOptional" || def.typeName === "ZodNullable") {
|
|
2708
|
+
return true;
|
|
2709
|
+
}
|
|
2710
|
+
if (def.defaultValue !== void 0) {
|
|
2711
|
+
return true;
|
|
2712
|
+
}
|
|
2713
|
+
return false;
|
|
2714
|
+
}
|
|
2715
|
+
extractZodFieldInfo(zodSchema) {
|
|
2716
|
+
const info = {};
|
|
2717
|
+
const schema = zodSchema;
|
|
2718
|
+
if (!schema?._def) return info;
|
|
2719
|
+
let currentSchema = schema;
|
|
2720
|
+
let def = currentSchema._def;
|
|
2721
|
+
while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
|
|
2722
|
+
if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) {
|
|
2723
|
+
info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
2724
|
+
}
|
|
2725
|
+
currentSchema = def.innerType ?? currentSchema;
|
|
2726
|
+
if (!currentSchema?._def) break;
|
|
2727
|
+
def = currentSchema._def;
|
|
2728
|
+
}
|
|
2729
|
+
info.description = typeof def.description === "string" ? def.description : void 0;
|
|
2730
|
+
const typeName = typeof def.typeName === "string" ? def.typeName : void 0;
|
|
2731
|
+
const typeMap = {
|
|
2732
|
+
ZodString: "string",
|
|
2733
|
+
ZodNumber: "number",
|
|
2734
|
+
ZodBoolean: "boolean",
|
|
2735
|
+
ZodArray: "array",
|
|
2736
|
+
ZodObject: "object",
|
|
2737
|
+
ZodEnum: "enum",
|
|
2738
|
+
ZodLiteral: "literal",
|
|
2739
|
+
ZodUnion: "union",
|
|
2740
|
+
ZodAny: "any",
|
|
2741
|
+
ZodUnknown: "unknown"
|
|
2742
|
+
};
|
|
2743
|
+
info.type = typeName ? typeMap[typeName] || typeName.replace("Zod", "").toLowerCase() : void 0;
|
|
2744
|
+
if (typeName === "ZodEnum" && Array.isArray(def.values)) {
|
|
2745
|
+
info.enum = def.values;
|
|
2746
|
+
} else if (typeName === "ZodLiteral" && def.value !== void 0) {
|
|
2747
|
+
info.enum = [def.value];
|
|
2748
|
+
}
|
|
2749
|
+
return info;
|
|
2750
|
+
}
|
|
2751
|
+
toggleToolExpansion(toolId) {
|
|
2752
|
+
if (this.expandedTools.has(toolId)) {
|
|
2753
|
+
this.expandedTools.delete(toolId);
|
|
2754
|
+
} else {
|
|
2755
|
+
this.expandedTools.add(toolId);
|
|
2756
|
+
}
|
|
2757
|
+
this.requestUpdate();
|
|
2758
|
+
}
|
|
2759
|
+
renderContextView() {
|
|
2760
|
+
const contextEntries = Object.entries(this.contextStore);
|
|
2761
|
+
if (contextEntries.length === 0) {
|
|
2762
|
+
return import_lit.html`
|
|
2763
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-center">
|
|
2764
|
+
<div class="max-w-md">
|
|
2765
|
+
<div class="mb-3 flex justify-center text-gray-300 [&>svg]:!h-8 [&>svg]:!w-8">
|
|
2766
|
+
${this.renderIcon("FileText")}
|
|
2767
|
+
</div>
|
|
2768
|
+
<p class="text-sm text-gray-600">No context available</p>
|
|
2769
|
+
<p class="mt-2 text-xs text-gray-500">Context will appear here once added to CopilotKit.</p>
|
|
2770
|
+
</div>
|
|
2771
|
+
</div>
|
|
2772
|
+
`;
|
|
2773
|
+
}
|
|
2774
|
+
return import_lit.html`
|
|
2775
|
+
<div class="flex h-full flex-col overflow-hidden">
|
|
2776
|
+
<div class="overflow-auto p-4">
|
|
2777
|
+
<div class="space-y-3">
|
|
2778
|
+
${contextEntries.map(([id, context]) => this.renderContextCard(id, context))}
|
|
2779
|
+
</div>
|
|
2780
|
+
</div>
|
|
2781
|
+
</div>
|
|
2782
|
+
`;
|
|
2783
|
+
}
|
|
2784
|
+
renderContextCard(id, context) {
|
|
2785
|
+
const isExpanded = this.expandedContextItems.has(id);
|
|
2786
|
+
const valuePreview = this.getContextValuePreview(context.value);
|
|
2787
|
+
const hasValue = context.value !== void 0 && context.value !== null;
|
|
2788
|
+
const title = context.description?.trim() || id;
|
|
2789
|
+
return import_lit.html`
|
|
2790
|
+
<div class="rounded-lg border border-gray-200 bg-white overflow-hidden">
|
|
2791
|
+
<button
|
|
2792
|
+
type="button"
|
|
2793
|
+
class="w-full px-4 py-3 text-left transition hover:bg-gray-50"
|
|
2794
|
+
@click=${() => this.toggleContextExpansion(id)}
|
|
2795
|
+
>
|
|
2796
|
+
<div class="flex items-start justify-between gap-3">
|
|
2797
|
+
<div class="flex-1 min-w-0">
|
|
2798
|
+
<p class="text-sm font-medium text-gray-900 mb-1">${title}</p>
|
|
2799
|
+
<div class="flex items-center gap-2 text-xs text-gray-500">
|
|
2800
|
+
<span class="font-mono truncate inline-block align-middle" style="max-width: 180px;">${id}</span>
|
|
2801
|
+
${hasValue ? import_lit.html`
|
|
2802
|
+
<span class="text-gray-300">•</span>
|
|
2803
|
+
<span class="truncate">${valuePreview}</span>
|
|
2804
|
+
` : import_lit.nothing}
|
|
2805
|
+
</div>
|
|
2806
|
+
</div>
|
|
2807
|
+
<span class="shrink-0 text-gray-400 transition ${isExpanded ? "rotate-180" : ""}">
|
|
2808
|
+
${this.renderIcon("ChevronDown")}
|
|
2809
|
+
</span>
|
|
2810
|
+
</div>
|
|
2811
|
+
</button>
|
|
2812
|
+
|
|
2813
|
+
${isExpanded ? import_lit.html`
|
|
2814
|
+
<div class="border-t border-gray-200 bg-gray-50/50 px-4 py-3">
|
|
2815
|
+
<div class="mb-3">
|
|
2816
|
+
<h5 class="mb-1 text-xs font-semibold text-gray-700">ID</h5>
|
|
2817
|
+
<code class="block rounded bg-white border border-gray-200 px-2 py-1 text-[10px] font-mono text-gray-600">${id}</code>
|
|
2818
|
+
</div>
|
|
2819
|
+
${hasValue ? import_lit.html`
|
|
2820
|
+
<div class="mb-2 flex items-center justify-between gap-2">
|
|
2821
|
+
<h5 class="text-xs font-semibold text-gray-700">Value</h5>
|
|
2822
|
+
<button
|
|
2823
|
+
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"
|
|
2824
|
+
type="button"
|
|
2825
|
+
@click=${(e) => {
|
|
2826
|
+
e.stopPropagation();
|
|
2827
|
+
void this.copyContextValue(context.value, id);
|
|
2828
|
+
}}
|
|
2829
|
+
>
|
|
2830
|
+
${this.copiedContextItems.has(id) ? "Copied" : "Copy JSON"}
|
|
2831
|
+
</button>
|
|
2832
|
+
</div>
|
|
2833
|
+
<div class="rounded-md border border-gray-200 bg-white p-3">
|
|
2834
|
+
<pre class="overflow-auto text-xs text-gray-800 max-h-96"><code>${this.formatContextValue(context.value)}</code></pre>
|
|
2835
|
+
</div>
|
|
2836
|
+
` : import_lit.html`
|
|
2837
|
+
<div class="flex items-center justify-center py-4 text-xs text-gray-500">
|
|
2838
|
+
<span>No value available</span>
|
|
2839
|
+
</div>
|
|
2840
|
+
`}
|
|
2841
|
+
</div>
|
|
2842
|
+
` : import_lit.nothing}
|
|
2843
|
+
</div>
|
|
2844
|
+
`;
|
|
2845
|
+
}
|
|
2846
|
+
getContextValuePreview(value) {
|
|
2847
|
+
if (value === void 0 || value === null) {
|
|
2848
|
+
return "\u2014";
|
|
2849
|
+
}
|
|
2850
|
+
if (typeof value === "string") {
|
|
2851
|
+
return value.length > 50 ? `${value.substring(0, 50)}...` : value;
|
|
2852
|
+
}
|
|
2853
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
2854
|
+
return String(value);
|
|
2855
|
+
}
|
|
2856
|
+
if (Array.isArray(value)) {
|
|
2857
|
+
return `Array(${value.length})`;
|
|
2858
|
+
}
|
|
2859
|
+
if (typeof value === "object") {
|
|
2860
|
+
const keys = Object.keys(value);
|
|
2861
|
+
return `Object with ${keys.length} key${keys.length !== 1 ? "s" : ""}`;
|
|
2862
|
+
}
|
|
2863
|
+
if (typeof value === "function") {
|
|
2864
|
+
return "Function";
|
|
2865
|
+
}
|
|
2866
|
+
return String(value);
|
|
2867
|
+
}
|
|
2868
|
+
formatContextValue(value) {
|
|
2869
|
+
if (value === void 0) {
|
|
2870
|
+
return "undefined";
|
|
2871
|
+
}
|
|
2872
|
+
if (value === null) {
|
|
2873
|
+
return "null";
|
|
2874
|
+
}
|
|
2875
|
+
if (typeof value === "function") {
|
|
2876
|
+
return value.toString();
|
|
2877
|
+
}
|
|
2878
|
+
try {
|
|
2879
|
+
return JSON.stringify(value, null, 2);
|
|
2880
|
+
} catch {
|
|
2881
|
+
return String(value);
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
async copyContextValue(value, contextId) {
|
|
2885
|
+
if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
|
|
2886
|
+
console.warn("Clipboard API is not available in this environment.");
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
const serialized = this.formatContextValue(value);
|
|
2890
|
+
try {
|
|
2891
|
+
await navigator.clipboard.writeText(serialized);
|
|
2892
|
+
this.copiedContextItems.add(contextId);
|
|
2893
|
+
this.requestUpdate();
|
|
2894
|
+
setTimeout(() => {
|
|
2895
|
+
this.copiedContextItems.delete(contextId);
|
|
2896
|
+
this.requestUpdate();
|
|
2897
|
+
}, 1500);
|
|
2898
|
+
} catch (error) {
|
|
2899
|
+
console.error("Failed to copy context value:", error);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
toggleContextExpansion(contextId) {
|
|
2903
|
+
if (this.expandedContextItems.has(contextId)) {
|
|
2904
|
+
this.expandedContextItems.delete(contextId);
|
|
2905
|
+
} else {
|
|
2906
|
+
this.expandedContextItems.add(contextId);
|
|
2907
|
+
}
|
|
2908
|
+
this.requestUpdate();
|
|
2909
|
+
}
|
|
2910
|
+
toggleRowExpansion(eventId) {
|
|
2911
|
+
const selection = window.getSelection();
|
|
2912
|
+
if (selection && selection.toString().length > 0) {
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
if (this.expandedRows.has(eventId)) {
|
|
2916
|
+
this.expandedRows.delete(eventId);
|
|
2917
|
+
} else {
|
|
2918
|
+
this.expandedRows.add(eventId);
|
|
2919
|
+
}
|
|
2920
|
+
this.requestUpdate();
|
|
2921
|
+
}
|
|
2922
|
+
renderAnnouncementPanel() {
|
|
2923
|
+
if (!this.isOpen) {
|
|
2924
|
+
return import_lit.nothing;
|
|
2925
|
+
}
|
|
2926
|
+
this.ensureAnnouncementLoading();
|
|
2927
|
+
if (!this.hasUnseenAnnouncement) {
|
|
2928
|
+
return import_lit.nothing;
|
|
2929
|
+
}
|
|
2930
|
+
if (!this.announcementLoaded && !this.announcementMarkdown) {
|
|
2931
|
+
return import_lit.html`<div 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)]">
|
|
2932
|
+
<div class="flex items-center gap-2 font-semibold">
|
|
2933
|
+
<span class="inline-flex h-6 w-6 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm">
|
|
2934
|
+
${this.renderIcon("Megaphone")}
|
|
2935
|
+
</span>
|
|
2936
|
+
<span>Loading latest announcement…</span>
|
|
2937
|
+
</div>
|
|
2938
|
+
</div>`;
|
|
2939
|
+
}
|
|
2940
|
+
if (this.announcementLoadError) {
|
|
2941
|
+
return import_lit.html`<div 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)]">
|
|
2942
|
+
<div class="flex items-center gap-2 font-semibold">
|
|
2943
|
+
<span class="inline-flex h-6 w-6 items-center justify-center rounded-md bg-rose-600 text-white shadow-sm">
|
|
2944
|
+
${this.renderIcon("Megaphone")}
|
|
2945
|
+
</span>
|
|
2946
|
+
<span>Announcement unavailable</span>
|
|
2947
|
+
</div>
|
|
2948
|
+
<p class="mt-2 text-xs text-rose-800">We couldn’t load the latest notice. Please try opening the inspector again.</p>
|
|
2949
|
+
</div>`;
|
|
2950
|
+
}
|
|
2951
|
+
if (!this.announcementMarkdown) {
|
|
2952
|
+
return import_lit.nothing;
|
|
2953
|
+
}
|
|
2954
|
+
const content = this.announcementHtml ? (0, import_unsafe_html.unsafeHTML)(this.announcementHtml) : import_lit.html`<pre class="whitespace-pre-wrap text-sm text-gray-900">${this.announcementMarkdown}</pre>`;
|
|
2955
|
+
return import_lit.html`<div 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)]">
|
|
2956
|
+
<div class="mb-3 flex items-center gap-2 text-sm font-semibold text-slate-900">
|
|
2957
|
+
<span class="inline-flex h-7 w-7 items-center justify-center rounded-md bg-slate-900 text-white shadow-sm">
|
|
2958
|
+
${this.renderIcon("Megaphone")}
|
|
2959
|
+
</span>
|
|
2960
|
+
<span>Announcement</span>
|
|
2961
|
+
<button class="announcement-dismiss ml-auto" type="button" @click=${this.handleDismissAnnouncement} aria-label="Dismiss announcement">
|
|
2962
|
+
Dismiss
|
|
2963
|
+
</button>
|
|
2964
|
+
</div>
|
|
2965
|
+
<div class="announcement-content text-sm leading-relaxed text-gray-900">${content}</div>
|
|
2966
|
+
</div>`;
|
|
2967
|
+
}
|
|
2968
|
+
ensureAnnouncementLoading() {
|
|
2969
|
+
if (this.announcementPromise || typeof window === "undefined" || typeof fetch === "undefined") {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
this.announcementPromise = this.fetchAnnouncement();
|
|
2973
|
+
}
|
|
2974
|
+
renderAnnouncementPreview() {
|
|
2975
|
+
if (!this.hasUnseenAnnouncement || !this.showAnnouncementPreview || !this.announcementPreviewText) {
|
|
2976
|
+
return import_lit.nothing;
|
|
2977
|
+
}
|
|
2978
|
+
const side = this.contextState.button.anchor.horizontal === "left" ? "right" : "left";
|
|
2979
|
+
return import_lit.html`<div
|
|
2980
|
+
class="announcement-preview"
|
|
2981
|
+
data-side=${side}
|
|
2982
|
+
role="note"
|
|
2983
|
+
@click=${() => this.handleAnnouncementPreviewClick()}
|
|
2984
|
+
>
|
|
2985
|
+
<span>${this.announcementPreviewText}</span>
|
|
2986
|
+
<span class="announcement-preview__arrow"></span>
|
|
2987
|
+
</div>`;
|
|
2988
|
+
}
|
|
2989
|
+
handleAnnouncementPreviewClick() {
|
|
2990
|
+
this.showAnnouncementPreview = false;
|
|
2991
|
+
this.openInspector();
|
|
2992
|
+
}
|
|
2993
|
+
async fetchAnnouncement() {
|
|
2994
|
+
try {
|
|
2995
|
+
const response = await fetch(ANNOUNCEMENT_URL, { cache: "no-cache" });
|
|
2996
|
+
if (!response.ok) {
|
|
2997
|
+
throw new Error(`Failed to load announcement (${response.status})`);
|
|
2998
|
+
}
|
|
2999
|
+
const data = await response.json();
|
|
3000
|
+
const timestamp = typeof data?.timestamp === "string" ? data.timestamp : null;
|
|
3001
|
+
const previewText = typeof data?.previewText === "string" ? data.previewText : null;
|
|
3002
|
+
const markdown = typeof data?.announcement === "string" ? data.announcement : null;
|
|
3003
|
+
if (!timestamp || !markdown) {
|
|
3004
|
+
throw new Error("Malformed announcement payload");
|
|
3005
|
+
}
|
|
3006
|
+
const storedTimestamp = this.loadStoredAnnouncementTimestamp();
|
|
3007
|
+
this.announcementTimestamp = timestamp;
|
|
3008
|
+
this.announcementPreviewText = previewText ?? "";
|
|
3009
|
+
this.announcementMarkdown = markdown;
|
|
3010
|
+
this.hasUnseenAnnouncement = (!storedTimestamp || storedTimestamp !== timestamp) && !!this.announcementPreviewText;
|
|
3011
|
+
this.showAnnouncementPreview = this.hasUnseenAnnouncement;
|
|
3012
|
+
this.announcementHtml = await this.convertMarkdownToHtml(markdown);
|
|
3013
|
+
this.announcementLoaded = true;
|
|
3014
|
+
this.requestUpdate();
|
|
3015
|
+
} catch (error) {
|
|
3016
|
+
this.announcementLoadError = error;
|
|
3017
|
+
this.announcementLoaded = true;
|
|
3018
|
+
this.requestUpdate();
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
async convertMarkdownToHtml(markdown) {
|
|
3022
|
+
const renderer = new import_marked.marked.Renderer();
|
|
3023
|
+
renderer.link = (href, title, text) => {
|
|
3024
|
+
const safeHref = this.escapeHtmlAttr(this.appendRefParam(href ?? ""));
|
|
3025
|
+
const titleAttr = title ? ` title="${this.escapeHtmlAttr(title)}"` : "";
|
|
3026
|
+
return `<a href="${safeHref}" target="_blank" rel="noopener"${titleAttr}>${text}</a>`;
|
|
3027
|
+
};
|
|
3028
|
+
return import_marked.marked.parse(markdown, { renderer });
|
|
3029
|
+
}
|
|
3030
|
+
appendRefParam(href) {
|
|
3031
|
+
try {
|
|
3032
|
+
const url = new URL(href, typeof window !== "undefined" ? window.location.href : "https://copilotkit.ai");
|
|
3033
|
+
if (!url.searchParams.has("ref")) {
|
|
3034
|
+
url.searchParams.append("ref", "cpk-inspector");
|
|
3035
|
+
}
|
|
3036
|
+
return url.toString();
|
|
3037
|
+
} catch {
|
|
3038
|
+
return href;
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
escapeHtmlAttr(value) {
|
|
3042
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """).replace(/'/g, "'");
|
|
3043
|
+
}
|
|
3044
|
+
loadStoredAnnouncementTimestamp() {
|
|
3045
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
3046
|
+
return null;
|
|
3047
|
+
}
|
|
3048
|
+
try {
|
|
3049
|
+
const raw = window.localStorage.getItem(ANNOUNCEMENT_STORAGE_KEY);
|
|
3050
|
+
if (!raw) {
|
|
3051
|
+
return null;
|
|
3052
|
+
}
|
|
3053
|
+
const parsed = JSON.parse(raw);
|
|
3054
|
+
if (parsed && typeof parsed.timestamp === "string") {
|
|
3055
|
+
return parsed.timestamp;
|
|
3056
|
+
}
|
|
3057
|
+
return null;
|
|
3058
|
+
} catch {
|
|
3059
|
+
}
|
|
3060
|
+
return null;
|
|
3061
|
+
}
|
|
3062
|
+
persistAnnouncementTimestamp(timestamp) {
|
|
3063
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
3064
|
+
return;
|
|
3065
|
+
}
|
|
3066
|
+
try {
|
|
3067
|
+
const payload = JSON.stringify({ timestamp });
|
|
3068
|
+
window.localStorage.setItem(ANNOUNCEMENT_STORAGE_KEY, payload);
|
|
3069
|
+
} catch {
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
markAnnouncementSeen() {
|
|
3073
|
+
this.hasUnseenAnnouncement = false;
|
|
3074
|
+
this.showAnnouncementPreview = false;
|
|
3075
|
+
if (!this.announcementTimestamp) {
|
|
3076
|
+
if (this.announcementPromise && !this.announcementLoaded) {
|
|
3077
|
+
void this.announcementPromise.then(() => this.markAnnouncementSeen()).catch(() => void 0);
|
|
3078
|
+
}
|
|
3079
|
+
this.requestUpdate();
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
this.persistAnnouncementTimestamp(this.announcementTimestamp);
|
|
3083
|
+
this.requestUpdate();
|
|
3084
|
+
}
|
|
3085
|
+
};
|
|
3086
|
+
function defineWebInspector() {
|
|
3087
|
+
if (!customElements.get(WEB_INSPECTOR_TAG)) {
|
|
3088
|
+
customElements.define(WEB_INSPECTOR_TAG, WebInspectorElement);
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
defineWebInspector();
|
|
3092
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3093
|
+
0 && (module.exports = {
|
|
3094
|
+
WEB_INSPECTOR_TAG,
|
|
3095
|
+
WebInspectorElement,
|
|
3096
|
+
defineWebInspector
|
|
3097
|
+
});
|
|
3098
|
+
//# sourceMappingURL=index.js.map
|