@copilotkitnext/web-inspector 0.0.13
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.log +29 -0
- package/LICENSE +11 -0
- package/dist/index.d.mts +108 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +1232 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1205 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +46 -0
- package/src/assets/logo-mark.svg +8 -0
- package/src/components.d.ts +24 -0
- package/src/index.ts +1300 -0
- package/src/lib/context-helpers.ts +125 -0
- package/src/lib/persistence.ts +88 -0
- package/src/lib/types.ts +17 -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/dist/index.js
ADDED
|
@@ -0,0 +1,1232 @@
|
|
|
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.11 | 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-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking: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-200:oklch(92.4% .12 95.746);--color-amber-700:oklch(55.5% .163 48.998);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-200:oklch(90.5% .093 164.15);--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-200:oklch(88.2% .059 254.128);--color-blue-700:oklch(48.8% .243 264.376);--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-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-700:oklch(51.4% .222 16.935);--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;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--font-weight-medium:500;--font-weight-semibold:600;--tracking-wider:.05em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--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}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.static{position:static}.right-1{right:calc(var(--spacing)*1)}.bottom-1{bottom:calc(var(--spacing)*1)}.left-0{left:calc(var(--spacing)*0)}.z-50{z-index:50}.m-0{margin:calc(var(--spacing)*0)}.mt-1\\.5{margin-top:calc(var(--spacing)*1.5)}.flex{display:flex}.inline-flex{display:inline-flex}.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-12{height:calc(var(--spacing)*12)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-full{height:100%}.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-12{width:calc(var(--spacing)*12)}.w-40{width:calc(var(--spacing)*40)}.w-56{width:calc(var(--spacing)*56)}.w-full{width:100%}.w-px{width:1px}.max-w-xs{max-width:var(--container-xs)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.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}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.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)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow: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-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-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-200{border-color:var(--color-gray-200)}.border-rose-200{border-color:var(--color-rose-200)}.border-sky-200{border-color:var(--color-sky-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-blue-50{background-color:var(--color-blue-50)}.bg-emerald-50{background-color:var(--color-emerald-50)}.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-200{background-color:var(--color-gray-200)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-rose-50{background-color:var(--color-rose-50)}.bg-sky-50{background-color:var(--color-sky-50)}.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)}.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-3{padding-block:calc(var(--spacing)*3)}.py-8{padding-block:calc(var(--spacing)*8)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pr-3{padding-right:calc(var(--spacing)*3)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pl-1{padding-left:calc(var(--spacing)*1)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-3{padding-left:calc(var(--spacing)*3)}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.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-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.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)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-700{color:var(--color-amber-700)}.text-blue-700{color:var(--color-blue-700)}.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-rose-700{color:var(--color-rose-700)}.text-sky-700{color:var(--color-sky-700)}.text-violet-700{color:var(--color-violet-700)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.opacity-60{opacity:.6}.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)}.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-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,)}.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,visibility,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))}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.group-hover\\:border-gray-300:is(:where(.group):hover *){border-color:var(--color-gray-300)}.group-hover\\:text-gray-700:is(:where(.group):hover *){color:var(--color-gray-700)}.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-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-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\\:bg-gray-50:focus{background-color:var(--color-gray-50)}.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)}.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-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-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{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}';
|
|
33
|
+
|
|
34
|
+
// src/assets/logo-mark.svg
|
|
35
|
+
var logo_mark_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';
|
|
36
|
+
|
|
37
|
+
// src/index.ts
|
|
38
|
+
var import_unsafe_html = require("lit/directives/unsafe-html.js");
|
|
39
|
+
var import_lucide = require("lucide");
|
|
40
|
+
|
|
41
|
+
// src/lib/context-helpers.ts
|
|
42
|
+
function updateSizeFromElement(state, element, fallback) {
|
|
43
|
+
const rect = element.getBoundingClientRect();
|
|
44
|
+
state.size = {
|
|
45
|
+
width: rect.width || fallback.width,
|
|
46
|
+
height: rect.height || fallback.height
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function clampSize(size, viewport, edgeMargin, minWidth, minHeight) {
|
|
50
|
+
const maxWidth = Math.max(minWidth, viewport.width - edgeMargin * 2);
|
|
51
|
+
const maxHeight = Math.max(minHeight, viewport.height - edgeMargin * 2);
|
|
52
|
+
return {
|
|
53
|
+
width: clamp(size.width, minWidth, maxWidth),
|
|
54
|
+
height: clamp(size.height, minHeight, maxHeight)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function constrainToViewport(state, position, viewport, edgeMargin) {
|
|
58
|
+
const maxX = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
59
|
+
const maxY = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
60
|
+
return {
|
|
61
|
+
x: clamp(position.x, edgeMargin, maxX),
|
|
62
|
+
y: clamp(position.y, edgeMargin, maxY)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function keepPositionWithinViewport(state, viewport, edgeMargin) {
|
|
66
|
+
state.position = constrainToViewport(state, state.position, viewport, edgeMargin);
|
|
67
|
+
}
|
|
68
|
+
function centerContext(state, viewport, edgeMargin) {
|
|
69
|
+
const centered = {
|
|
70
|
+
x: Math.round((viewport.width - state.size.width) / 2),
|
|
71
|
+
y: Math.round((viewport.height - state.size.height) / 2)
|
|
72
|
+
};
|
|
73
|
+
state.position = constrainToViewport(state, centered, viewport, edgeMargin);
|
|
74
|
+
updateAnchorFromPosition(state, viewport, edgeMargin);
|
|
75
|
+
return state.position;
|
|
76
|
+
}
|
|
77
|
+
function updateAnchorFromPosition(state, viewport, edgeMargin) {
|
|
78
|
+
const centerX = state.position.x + state.size.width / 2;
|
|
79
|
+
const centerY = state.position.y + state.size.height / 2;
|
|
80
|
+
const horizontal = centerX < viewport.width / 2 ? "left" : "right";
|
|
81
|
+
const vertical = centerY < viewport.height / 2 ? "top" : "bottom";
|
|
82
|
+
state.anchor = { horizontal, vertical };
|
|
83
|
+
const maxHorizontalOffset = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
84
|
+
const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
85
|
+
state.anchorOffset = {
|
|
86
|
+
x: horizontal === "left" ? clamp(state.position.x, edgeMargin, maxHorizontalOffset) : clamp(viewport.width - state.position.x - state.size.width, edgeMargin, maxHorizontalOffset),
|
|
87
|
+
y: vertical === "top" ? clamp(state.position.y, edgeMargin, maxVerticalOffset) : clamp(viewport.height - state.position.y - state.size.height, edgeMargin, maxVerticalOffset)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function applyAnchorPosition(state, viewport, edgeMargin) {
|
|
91
|
+
const maxHorizontalOffset = Math.max(edgeMargin, viewport.width - state.size.width - edgeMargin);
|
|
92
|
+
const maxVerticalOffset = Math.max(edgeMargin, viewport.height - state.size.height - edgeMargin);
|
|
93
|
+
const horizontalOffset = clamp(state.anchorOffset.x, edgeMargin, maxHorizontalOffset);
|
|
94
|
+
const verticalOffset = clamp(state.anchorOffset.y, edgeMargin, maxVerticalOffset);
|
|
95
|
+
const x = state.anchor.horizontal === "left" ? horizontalOffset : viewport.width - state.size.width - horizontalOffset;
|
|
96
|
+
const y = state.anchor.vertical === "top" ? verticalOffset : viewport.height - state.size.height - verticalOffset;
|
|
97
|
+
state.anchorOffset = { x: horizontalOffset, y: verticalOffset };
|
|
98
|
+
state.position = constrainToViewport(state, { x, y }, viewport, edgeMargin);
|
|
99
|
+
return state.position;
|
|
100
|
+
}
|
|
101
|
+
function clamp(value, min, max) {
|
|
102
|
+
return Math.min(Math.max(min, value), max);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/lib/persistence.ts
|
|
106
|
+
function loadInspectorState(cookieName) {
|
|
107
|
+
if (typeof document === "undefined") {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const prefix = `${cookieName}=`;
|
|
111
|
+
const entry = document.cookie.split("; ").find((cookie) => cookie.startsWith(prefix));
|
|
112
|
+
if (!entry) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const raw = entry.substring(prefix.length);
|
|
116
|
+
if (!raw) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const parsed = JSON.parse(decodeURIComponent(raw));
|
|
121
|
+
if (parsed && typeof parsed === "object") {
|
|
122
|
+
return parsed;
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
function saveInspectorState(cookieName, state, maxAgeSeconds) {
|
|
130
|
+
if (typeof document === "undefined") {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const encoded = encodeURIComponent(JSON.stringify(state));
|
|
134
|
+
document.cookie = `${cookieName}=${encoded}; path=/; max-age=${maxAgeSeconds}; SameSite=Lax`;
|
|
135
|
+
}
|
|
136
|
+
function isValidAnchor(value) {
|
|
137
|
+
if (!value || typeof value !== "object") {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
const candidate = value;
|
|
141
|
+
return (candidate.horizontal === "left" || candidate.horizontal === "right") && (candidate.vertical === "top" || candidate.vertical === "bottom");
|
|
142
|
+
}
|
|
143
|
+
function isValidPosition(value) {
|
|
144
|
+
if (!value || typeof value !== "object") {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const candidate = value;
|
|
148
|
+
return isFiniteNumber(candidate.x) && isFiniteNumber(candidate.y);
|
|
149
|
+
}
|
|
150
|
+
function isValidSize(value) {
|
|
151
|
+
if (!value || typeof value !== "object") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const candidate = value;
|
|
155
|
+
return isFiniteNumber(candidate.width) && isFiniteNumber(candidate.height);
|
|
156
|
+
}
|
|
157
|
+
function isFiniteNumber(value) {
|
|
158
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/index.ts
|
|
162
|
+
var WEB_INSPECTOR_TAG = "web-inspector";
|
|
163
|
+
var EDGE_MARGIN = 16;
|
|
164
|
+
var DRAG_THRESHOLD = 6;
|
|
165
|
+
var MIN_WINDOW_WIDTH = 260;
|
|
166
|
+
var MIN_WINDOW_HEIGHT = 200;
|
|
167
|
+
var COOKIE_NAME = "copilotkit_inspector_state";
|
|
168
|
+
var COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 30;
|
|
169
|
+
var DEFAULT_BUTTON_SIZE = { width: 48, height: 48 };
|
|
170
|
+
var DEFAULT_WINDOW_SIZE = { width: 320, height: 380 };
|
|
171
|
+
var MAX_AGENT_EVENTS = 200;
|
|
172
|
+
var MAX_TOTAL_EVENTS = 500;
|
|
173
|
+
var WebInspectorElement = class extends import_lit.LitElement {
|
|
174
|
+
constructor() {
|
|
175
|
+
super(...arguments);
|
|
176
|
+
this._core = null;
|
|
177
|
+
this.coreSubscriber = null;
|
|
178
|
+
this.coreUnsubscribe = null;
|
|
179
|
+
this.agentSubscriptions = /* @__PURE__ */ new Map();
|
|
180
|
+
this.agentEvents = /* @__PURE__ */ new Map();
|
|
181
|
+
this.flattenedEvents = [];
|
|
182
|
+
this.eventCounter = 0;
|
|
183
|
+
this.pointerId = null;
|
|
184
|
+
this.dragStart = null;
|
|
185
|
+
this.dragOffset = { x: 0, y: 0 };
|
|
186
|
+
this.isDragging = false;
|
|
187
|
+
this.pointerContext = null;
|
|
188
|
+
this.isOpen = false;
|
|
189
|
+
this.draggedDuringInteraction = false;
|
|
190
|
+
this.ignoreNextButtonClick = false;
|
|
191
|
+
this.selectedMenu = "ag-ui-events";
|
|
192
|
+
this.contextMenuOpen = false;
|
|
193
|
+
this.contextState = {
|
|
194
|
+
button: {
|
|
195
|
+
position: { x: EDGE_MARGIN, y: EDGE_MARGIN },
|
|
196
|
+
size: { ...DEFAULT_BUTTON_SIZE },
|
|
197
|
+
anchor: { horizontal: "right", vertical: "bottom" },
|
|
198
|
+
anchorOffset: { x: EDGE_MARGIN, y: EDGE_MARGIN }
|
|
199
|
+
},
|
|
200
|
+
window: {
|
|
201
|
+
position: { x: EDGE_MARGIN, y: EDGE_MARGIN },
|
|
202
|
+
size: { ...DEFAULT_WINDOW_SIZE },
|
|
203
|
+
anchor: { horizontal: "right", vertical: "bottom" },
|
|
204
|
+
anchorOffset: { x: EDGE_MARGIN, y: EDGE_MARGIN }
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
this.hasCustomPosition = {
|
|
208
|
+
button: false,
|
|
209
|
+
window: false
|
|
210
|
+
};
|
|
211
|
+
this.resizePointerId = null;
|
|
212
|
+
this.resizeStart = null;
|
|
213
|
+
this.resizeInitialSize = null;
|
|
214
|
+
this.isResizing = false;
|
|
215
|
+
this.menuItems = [
|
|
216
|
+
{ key: "ag-ui-events", label: "AG-UI Events", icon: "Zap" },
|
|
217
|
+
{ key: "agents", label: "Agents", icon: "Bot" },
|
|
218
|
+
{ key: "frontend-tools", label: "Frontend Tools", icon: "Hammer" },
|
|
219
|
+
{ key: "agent-context", label: "Agent Context", icon: "FileText" }
|
|
220
|
+
];
|
|
221
|
+
this.handlePointerDown = (event) => {
|
|
222
|
+
const target = event.currentTarget;
|
|
223
|
+
const contextAttr = target?.dataset.dragContext;
|
|
224
|
+
const context = contextAttr === "window" ? "window" : "button";
|
|
225
|
+
this.pointerContext = context;
|
|
226
|
+
this.measureContext(context);
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
this.pointerId = event.pointerId;
|
|
229
|
+
this.dragStart = { x: event.clientX, y: event.clientY };
|
|
230
|
+
const state = this.contextState[context];
|
|
231
|
+
this.dragOffset = {
|
|
232
|
+
x: event.clientX - state.position.x,
|
|
233
|
+
y: event.clientY - state.position.y
|
|
234
|
+
};
|
|
235
|
+
this.isDragging = false;
|
|
236
|
+
this.draggedDuringInteraction = false;
|
|
237
|
+
this.ignoreNextButtonClick = false;
|
|
238
|
+
target?.setPointerCapture?.(this.pointerId);
|
|
239
|
+
};
|
|
240
|
+
this.handlePointerMove = (event) => {
|
|
241
|
+
if (this.pointerId !== event.pointerId || !this.dragStart || !this.pointerContext) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const distance = Math.hypot(event.clientX - this.dragStart.x, event.clientY - this.dragStart.y);
|
|
245
|
+
if (!this.isDragging && distance < DRAG_THRESHOLD) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
event.preventDefault();
|
|
249
|
+
this.setDragging(true);
|
|
250
|
+
this.draggedDuringInteraction = true;
|
|
251
|
+
const desired = {
|
|
252
|
+
x: event.clientX - this.dragOffset.x,
|
|
253
|
+
y: event.clientY - this.dragOffset.y
|
|
254
|
+
};
|
|
255
|
+
const constrained = this.constrainToViewport(desired, this.pointerContext);
|
|
256
|
+
this.contextState[this.pointerContext].position = constrained;
|
|
257
|
+
this.updateHostTransform(this.pointerContext);
|
|
258
|
+
};
|
|
259
|
+
this.handlePointerUp = (event) => {
|
|
260
|
+
if (this.pointerId !== event.pointerId) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const target = event.currentTarget;
|
|
264
|
+
if (target?.hasPointerCapture(this.pointerId)) {
|
|
265
|
+
target.releasePointerCapture(this.pointerId);
|
|
266
|
+
}
|
|
267
|
+
const context = this.pointerContext ?? this.activeContext;
|
|
268
|
+
if (this.isDragging && this.pointerContext) {
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
this.setDragging(false);
|
|
271
|
+
this.updateAnchorFromPosition(this.pointerContext);
|
|
272
|
+
if (this.pointerContext === "window") {
|
|
273
|
+
this.hasCustomPosition.window = true;
|
|
274
|
+
} else if (this.pointerContext === "button") {
|
|
275
|
+
this.hasCustomPosition.button = true;
|
|
276
|
+
if (this.draggedDuringInteraction) {
|
|
277
|
+
this.ignoreNextButtonClick = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
this.applyAnchorPosition(this.pointerContext);
|
|
281
|
+
} else if (context === "button" && !this.isOpen && !this.draggedDuringInteraction) {
|
|
282
|
+
this.openInspector();
|
|
283
|
+
}
|
|
284
|
+
this.resetPointerTracking();
|
|
285
|
+
};
|
|
286
|
+
this.handlePointerCancel = (event) => {
|
|
287
|
+
if (this.pointerId !== event.pointerId) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const target = event.currentTarget;
|
|
291
|
+
if (target?.hasPointerCapture(this.pointerId)) {
|
|
292
|
+
target.releasePointerCapture(this.pointerId);
|
|
293
|
+
}
|
|
294
|
+
this.resetPointerTracking();
|
|
295
|
+
};
|
|
296
|
+
this.handleButtonClick = (event) => {
|
|
297
|
+
if (this.isDragging) {
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (this.ignoreNextButtonClick) {
|
|
302
|
+
event.preventDefault();
|
|
303
|
+
this.ignoreNextButtonClick = false;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (!this.isOpen) {
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
this.openInspector();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
this.handleClosePointerDown = (event) => {
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
event.preventDefault();
|
|
314
|
+
};
|
|
315
|
+
this.handleCloseClick = () => {
|
|
316
|
+
this.closeInspector();
|
|
317
|
+
};
|
|
318
|
+
this.handleResizePointerDown = (event) => {
|
|
319
|
+
event.stopPropagation();
|
|
320
|
+
event.preventDefault();
|
|
321
|
+
this.hasCustomPosition.window = true;
|
|
322
|
+
this.isResizing = true;
|
|
323
|
+
this.resizePointerId = event.pointerId;
|
|
324
|
+
this.resizeStart = { x: event.clientX, y: event.clientY };
|
|
325
|
+
this.resizeInitialSize = { ...this.contextState.window.size };
|
|
326
|
+
const target = event.currentTarget;
|
|
327
|
+
target?.setPointerCapture?.(event.pointerId);
|
|
328
|
+
};
|
|
329
|
+
this.handleResizePointerMove = (event) => {
|
|
330
|
+
if (!this.isResizing || this.resizePointerId !== event.pointerId || !this.resizeStart || !this.resizeInitialSize) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
event.preventDefault();
|
|
334
|
+
const deltaX = event.clientX - this.resizeStart.x;
|
|
335
|
+
const deltaY = event.clientY - this.resizeStart.y;
|
|
336
|
+
const state = this.contextState.window;
|
|
337
|
+
state.size = this.clampWindowSize({
|
|
338
|
+
width: this.resizeInitialSize.width + deltaX,
|
|
339
|
+
height: this.resizeInitialSize.height + deltaY
|
|
340
|
+
});
|
|
341
|
+
this.keepPositionWithinViewport("window");
|
|
342
|
+
this.updateAnchorFromPosition("window");
|
|
343
|
+
this.requestUpdate();
|
|
344
|
+
this.updateHostTransform("window");
|
|
345
|
+
};
|
|
346
|
+
this.handleResizePointerUp = (event) => {
|
|
347
|
+
if (this.resizePointerId !== event.pointerId) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const target = event.currentTarget;
|
|
351
|
+
if (target?.hasPointerCapture(this.resizePointerId)) {
|
|
352
|
+
target.releasePointerCapture(this.resizePointerId);
|
|
353
|
+
}
|
|
354
|
+
this.updateAnchorFromPosition("window");
|
|
355
|
+
this.applyAnchorPosition("window");
|
|
356
|
+
this.resetResizeTracking();
|
|
357
|
+
};
|
|
358
|
+
this.handleResizePointerCancel = (event) => {
|
|
359
|
+
if (this.resizePointerId !== event.pointerId) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const target = event.currentTarget;
|
|
363
|
+
if (target?.hasPointerCapture(this.resizePointerId)) {
|
|
364
|
+
target.releasePointerCapture(this.resizePointerId);
|
|
365
|
+
}
|
|
366
|
+
this.updateAnchorFromPosition("window");
|
|
367
|
+
this.applyAnchorPosition("window");
|
|
368
|
+
this.resetResizeTracking();
|
|
369
|
+
};
|
|
370
|
+
this.handleResize = () => {
|
|
371
|
+
this.measureContext("button");
|
|
372
|
+
this.applyAnchorPosition("button");
|
|
373
|
+
this.measureContext("window");
|
|
374
|
+
if (this.hasCustomPosition.window) {
|
|
375
|
+
this.applyAnchorPosition("window");
|
|
376
|
+
} else {
|
|
377
|
+
this.centerContext("window");
|
|
378
|
+
}
|
|
379
|
+
this.updateHostTransform();
|
|
380
|
+
};
|
|
381
|
+
this.contextOptions = [
|
|
382
|
+
{ key: "all-agents", label: "All Agents" }
|
|
383
|
+
];
|
|
384
|
+
this.selectedContext = "all-agents";
|
|
385
|
+
this.expandedRows = /* @__PURE__ */ new Set();
|
|
386
|
+
this.handleGlobalPointerDown = (event) => {
|
|
387
|
+
if (!this.contextMenuOpen) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const clickedDropdown = event.composedPath().some((node) => {
|
|
391
|
+
return node instanceof HTMLElement && node.dataset?.contextDropdownRoot === "true";
|
|
392
|
+
});
|
|
393
|
+
if (!clickedDropdown) {
|
|
394
|
+
this.contextMenuOpen = false;
|
|
395
|
+
this.requestUpdate();
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
static {
|
|
400
|
+
this.properties = {
|
|
401
|
+
core: { attribute: false }
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
get core() {
|
|
405
|
+
return this._core;
|
|
406
|
+
}
|
|
407
|
+
set core(value) {
|
|
408
|
+
const oldValue = this._core;
|
|
409
|
+
if (oldValue === value) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
this.detachFromCore();
|
|
413
|
+
this._core = value ?? null;
|
|
414
|
+
this.requestUpdate("core", oldValue);
|
|
415
|
+
if (this._core) {
|
|
416
|
+
this.attachToCore(this._core);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
attachToCore(core) {
|
|
420
|
+
this.coreSubscriber = {
|
|
421
|
+
onAgentsChanged: ({ agents }) => {
|
|
422
|
+
this.processAgentsChanged(agents);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
this.coreUnsubscribe = core.subscribe(this.coreSubscriber);
|
|
426
|
+
this.processAgentsChanged(core.agents);
|
|
427
|
+
}
|
|
428
|
+
detachFromCore() {
|
|
429
|
+
if (this.coreUnsubscribe) {
|
|
430
|
+
this.coreUnsubscribe();
|
|
431
|
+
this.coreUnsubscribe = null;
|
|
432
|
+
}
|
|
433
|
+
this.coreSubscriber = null;
|
|
434
|
+
this.teardownAgentSubscriptions();
|
|
435
|
+
}
|
|
436
|
+
teardownAgentSubscriptions() {
|
|
437
|
+
for (const unsubscribe of this.agentSubscriptions.values()) {
|
|
438
|
+
unsubscribe();
|
|
439
|
+
}
|
|
440
|
+
this.agentSubscriptions.clear();
|
|
441
|
+
this.agentEvents.clear();
|
|
442
|
+
this.flattenedEvents = [];
|
|
443
|
+
this.eventCounter = 0;
|
|
444
|
+
}
|
|
445
|
+
processAgentsChanged(agents) {
|
|
446
|
+
const seenAgentIds = /* @__PURE__ */ new Set();
|
|
447
|
+
for (const agent of Object.values(agents)) {
|
|
448
|
+
if (!agent?.agentId) {
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
seenAgentIds.add(agent.agentId);
|
|
452
|
+
this.subscribeToAgent(agent);
|
|
453
|
+
}
|
|
454
|
+
for (const agentId of Array.from(this.agentSubscriptions.keys())) {
|
|
455
|
+
if (!seenAgentIds.has(agentId)) {
|
|
456
|
+
this.unsubscribeFromAgent(agentId);
|
|
457
|
+
this.agentEvents.delete(agentId);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
this.updateContextOptions(seenAgentIds);
|
|
461
|
+
this.requestUpdate();
|
|
462
|
+
}
|
|
463
|
+
subscribeToAgent(agent) {
|
|
464
|
+
if (!agent.agentId) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const agentId = agent.agentId;
|
|
468
|
+
this.unsubscribeFromAgent(agentId);
|
|
469
|
+
const subscriber = {
|
|
470
|
+
onRunStartedEvent: ({ event }) => {
|
|
471
|
+
this.recordAgentEvent(agentId, "RUN_STARTED", event);
|
|
472
|
+
},
|
|
473
|
+
onRunFinishedEvent: ({ event, result }) => {
|
|
474
|
+
this.recordAgentEvent(agentId, "RUN_FINISHED", { event, result });
|
|
475
|
+
},
|
|
476
|
+
onRunErrorEvent: ({ event }) => {
|
|
477
|
+
this.recordAgentEvent(agentId, "RUN_ERROR", event);
|
|
478
|
+
},
|
|
479
|
+
onTextMessageStartEvent: ({ event }) => {
|
|
480
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_START", event);
|
|
481
|
+
},
|
|
482
|
+
onTextMessageContentEvent: ({ event, textMessageBuffer }) => {
|
|
483
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_CONTENT", { event, textMessageBuffer });
|
|
484
|
+
},
|
|
485
|
+
onTextMessageEndEvent: ({ event, textMessageBuffer }) => {
|
|
486
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_END", { event, textMessageBuffer });
|
|
487
|
+
},
|
|
488
|
+
onToolCallStartEvent: ({ event }) => {
|
|
489
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_START", event);
|
|
490
|
+
},
|
|
491
|
+
onToolCallArgsEvent: ({ event, toolCallBuffer, toolCallName, partialToolCallArgs }) => {
|
|
492
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_ARGS", { event, toolCallBuffer, toolCallName, partialToolCallArgs });
|
|
493
|
+
},
|
|
494
|
+
onToolCallEndEvent: ({ event, toolCallArgs, toolCallName }) => {
|
|
495
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_END", { event, toolCallArgs, toolCallName });
|
|
496
|
+
},
|
|
497
|
+
onToolCallResultEvent: ({ event }) => {
|
|
498
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_RESULT", event);
|
|
499
|
+
},
|
|
500
|
+
onStateSnapshotEvent: ({ event }) => {
|
|
501
|
+
this.recordAgentEvent(agentId, "STATE_SNAPSHOT", event);
|
|
502
|
+
},
|
|
503
|
+
onStateDeltaEvent: ({ event }) => {
|
|
504
|
+
this.recordAgentEvent(agentId, "STATE_DELTA", event);
|
|
505
|
+
},
|
|
506
|
+
onMessagesSnapshotEvent: ({ event }) => {
|
|
507
|
+
this.recordAgentEvent(agentId, "MESSAGES_SNAPSHOT", event);
|
|
508
|
+
},
|
|
509
|
+
onRawEvent: ({ event }) => {
|
|
510
|
+
this.recordAgentEvent(agentId, "RAW_EVENT", event);
|
|
511
|
+
},
|
|
512
|
+
onCustomEvent: ({ event }) => {
|
|
513
|
+
this.recordAgentEvent(agentId, "CUSTOM_EVENT", event);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const { unsubscribe } = agent.subscribe(subscriber);
|
|
517
|
+
this.agentSubscriptions.set(agentId, unsubscribe);
|
|
518
|
+
if (!this.agentEvents.has(agentId)) {
|
|
519
|
+
this.agentEvents.set(agentId, []);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
unsubscribeFromAgent(agentId) {
|
|
523
|
+
const unsubscribe = this.agentSubscriptions.get(agentId);
|
|
524
|
+
if (unsubscribe) {
|
|
525
|
+
unsubscribe();
|
|
526
|
+
this.agentSubscriptions.delete(agentId);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
recordAgentEvent(agentId, type, payload) {
|
|
530
|
+
const eventId = `${agentId}:${++this.eventCounter}`;
|
|
531
|
+
const event = {
|
|
532
|
+
id: eventId,
|
|
533
|
+
agentId,
|
|
534
|
+
type,
|
|
535
|
+
timestamp: Date.now(),
|
|
536
|
+
payload
|
|
537
|
+
};
|
|
538
|
+
const currentAgentEvents = this.agentEvents.get(agentId) ?? [];
|
|
539
|
+
const nextAgentEvents = [event, ...currentAgentEvents].slice(0, MAX_AGENT_EVENTS);
|
|
540
|
+
this.agentEvents.set(agentId, nextAgentEvents);
|
|
541
|
+
this.flattenedEvents = [event, ...this.flattenedEvents].slice(0, MAX_TOTAL_EVENTS);
|
|
542
|
+
this.requestUpdate();
|
|
543
|
+
}
|
|
544
|
+
updateContextOptions(agentIds) {
|
|
545
|
+
const nextOptions = [
|
|
546
|
+
{ key: "all-agents", label: "All Agents" },
|
|
547
|
+
...Array.from(agentIds).sort((a, b) => a.localeCompare(b)).map((id) => ({ key: id, label: id }))
|
|
548
|
+
];
|
|
549
|
+
const optionsChanged = this.contextOptions.length !== nextOptions.length || this.contextOptions.some((option, index) => option.key !== nextOptions[index]?.key);
|
|
550
|
+
if (optionsChanged) {
|
|
551
|
+
this.contextOptions = nextOptions;
|
|
552
|
+
}
|
|
553
|
+
if (!nextOptions.some((option) => option.key === this.selectedContext)) {
|
|
554
|
+
this.selectedContext = "all-agents";
|
|
555
|
+
this.expandedRows.clear();
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
getEventsForSelectedContext() {
|
|
559
|
+
if (this.selectedContext === "all-agents") {
|
|
560
|
+
return this.flattenedEvents;
|
|
561
|
+
}
|
|
562
|
+
return this.agentEvents.get(this.selectedContext) ?? [];
|
|
563
|
+
}
|
|
564
|
+
getEventBadgeClasses(type) {
|
|
565
|
+
const base = "font-mono text-[10px] font-medium inline-flex items-center rounded-sm px-1.5 py-0.5 border";
|
|
566
|
+
if (type.startsWith("RUN_")) {
|
|
567
|
+
return `${base} bg-blue-50 text-blue-700 border-blue-200`;
|
|
568
|
+
}
|
|
569
|
+
if (type.startsWith("TEXT_MESSAGE")) {
|
|
570
|
+
return `${base} bg-emerald-50 text-emerald-700 border-emerald-200`;
|
|
571
|
+
}
|
|
572
|
+
if (type.startsWith("TOOL_CALL")) {
|
|
573
|
+
return `${base} bg-amber-50 text-amber-700 border-amber-200`;
|
|
574
|
+
}
|
|
575
|
+
if (type.startsWith("STATE")) {
|
|
576
|
+
return `${base} bg-violet-50 text-violet-700 border-violet-200`;
|
|
577
|
+
}
|
|
578
|
+
if (type.startsWith("MESSAGES")) {
|
|
579
|
+
return `${base} bg-sky-50 text-sky-700 border-sky-200`;
|
|
580
|
+
}
|
|
581
|
+
if (type === "RUN_ERROR") {
|
|
582
|
+
return `${base} bg-rose-50 text-rose-700 border-rose-200`;
|
|
583
|
+
}
|
|
584
|
+
return `${base} bg-gray-100 text-gray-600 border-gray-200`;
|
|
585
|
+
}
|
|
586
|
+
stringifyPayload(payload, pretty) {
|
|
587
|
+
try {
|
|
588
|
+
if (payload === void 0) {
|
|
589
|
+
return pretty ? "undefined" : "undefined";
|
|
590
|
+
}
|
|
591
|
+
if (typeof payload === "string") {
|
|
592
|
+
return payload;
|
|
593
|
+
}
|
|
594
|
+
return JSON.stringify(payload, null, pretty ? 2 : 0) ?? "";
|
|
595
|
+
} catch (error) {
|
|
596
|
+
console.warn("Failed to stringify inspector payload", error);
|
|
597
|
+
return String(payload);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
static {
|
|
601
|
+
this.styles = [
|
|
602
|
+
(0, import_lit.unsafeCSS)(generated_default),
|
|
603
|
+
import_lit.css`
|
|
604
|
+
:host {
|
|
605
|
+
position: fixed;
|
|
606
|
+
top: 0;
|
|
607
|
+
left: 0;
|
|
608
|
+
z-index: 2147483646;
|
|
609
|
+
display: block;
|
|
610
|
+
will-change: transform;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.console-button {
|
|
614
|
+
transition:
|
|
615
|
+
transform 160ms ease,
|
|
616
|
+
opacity 160ms ease;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.resize-handle {
|
|
620
|
+
touch-action: none;
|
|
621
|
+
user-select: none;
|
|
622
|
+
}
|
|
623
|
+
`
|
|
624
|
+
];
|
|
625
|
+
}
|
|
626
|
+
connectedCallback() {
|
|
627
|
+
super.connectedCallback();
|
|
628
|
+
if (typeof window !== "undefined") {
|
|
629
|
+
window.addEventListener("resize", this.handleResize);
|
|
630
|
+
window.addEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
disconnectedCallback() {
|
|
634
|
+
super.disconnectedCallback();
|
|
635
|
+
if (typeof window !== "undefined") {
|
|
636
|
+
window.removeEventListener("resize", this.handleResize);
|
|
637
|
+
window.removeEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
638
|
+
}
|
|
639
|
+
this.detachFromCore();
|
|
640
|
+
}
|
|
641
|
+
firstUpdated() {
|
|
642
|
+
if (typeof window === "undefined") {
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
this.measureContext("button");
|
|
646
|
+
this.measureContext("window");
|
|
647
|
+
this.contextState.button.anchor = { horizontal: "right", vertical: "bottom" };
|
|
648
|
+
this.contextState.button.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
649
|
+
this.contextState.window.anchor = { horizontal: "right", vertical: "bottom" };
|
|
650
|
+
this.contextState.window.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
651
|
+
this.hydrateStateFromCookie();
|
|
652
|
+
this.applyAnchorPosition("button");
|
|
653
|
+
if (this.hasCustomPosition.window) {
|
|
654
|
+
this.applyAnchorPosition("window");
|
|
655
|
+
} else {
|
|
656
|
+
this.centerContext("window");
|
|
657
|
+
}
|
|
658
|
+
this.updateHostTransform("button");
|
|
659
|
+
}
|
|
660
|
+
render() {
|
|
661
|
+
return this.isOpen ? this.renderWindow() : this.renderButton();
|
|
662
|
+
}
|
|
663
|
+
renderButton() {
|
|
664
|
+
const buttonClasses = [
|
|
665
|
+
"console-button",
|
|
666
|
+
"group",
|
|
667
|
+
"pointer-events-auto",
|
|
668
|
+
"inline-flex",
|
|
669
|
+
"h-12",
|
|
670
|
+
"w-12",
|
|
671
|
+
"items-center",
|
|
672
|
+
"justify-center",
|
|
673
|
+
"rounded-full",
|
|
674
|
+
"border",
|
|
675
|
+
"border-white/20",
|
|
676
|
+
"bg-slate-950/95",
|
|
677
|
+
"text-xs",
|
|
678
|
+
"font-medium",
|
|
679
|
+
"text-white",
|
|
680
|
+
"ring-1",
|
|
681
|
+
"ring-white/10",
|
|
682
|
+
"backdrop-blur-md",
|
|
683
|
+
"transition",
|
|
684
|
+
"hover:border-white/30",
|
|
685
|
+
"hover:bg-slate-900/95",
|
|
686
|
+
"hover:scale-105",
|
|
687
|
+
"focus-visible:outline",
|
|
688
|
+
"focus-visible:outline-2",
|
|
689
|
+
"focus-visible:outline-offset-2",
|
|
690
|
+
"focus-visible:outline-rose-500",
|
|
691
|
+
"touch-none",
|
|
692
|
+
"select-none",
|
|
693
|
+
this.isDragging ? "cursor-grabbing" : "cursor-grab"
|
|
694
|
+
].join(" ");
|
|
695
|
+
return import_lit.html`
|
|
696
|
+
<button
|
|
697
|
+
class=${buttonClasses}
|
|
698
|
+
type="button"
|
|
699
|
+
aria-label="Web Inspector"
|
|
700
|
+
data-drag-context="button"
|
|
701
|
+
@pointerdown=${this.handlePointerDown}
|
|
702
|
+
@pointermove=${this.handlePointerMove}
|
|
703
|
+
@pointerup=${this.handlePointerUp}
|
|
704
|
+
@pointercancel=${this.handlePointerCancel}
|
|
705
|
+
@click=${this.handleButtonClick}
|
|
706
|
+
>
|
|
707
|
+
<img src=${logo_mark_default} alt="" class="h-7 w-7" loading="lazy" />
|
|
708
|
+
</button>
|
|
709
|
+
`;
|
|
710
|
+
}
|
|
711
|
+
renderWindow() {
|
|
712
|
+
const windowState = this.contextState.window;
|
|
713
|
+
const windowStyles = {
|
|
714
|
+
width: `${Math.round(windowState.size.width)}px`,
|
|
715
|
+
height: `${Math.round(windowState.size.height)}px`,
|
|
716
|
+
minWidth: `${MIN_WINDOW_WIDTH}px`,
|
|
717
|
+
minHeight: `${MIN_WINDOW_HEIGHT}px`
|
|
718
|
+
};
|
|
719
|
+
const contextDropdown = this.renderContextDropdown();
|
|
720
|
+
const hasContextDropdown = contextDropdown !== import_lit.nothing;
|
|
721
|
+
return import_lit.html`
|
|
722
|
+
<section
|
|
723
|
+
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"
|
|
724
|
+
style=${(0, import_style_map.styleMap)(windowStyles)}
|
|
725
|
+
>
|
|
726
|
+
<div class="flex flex-1 overflow-hidden bg-white text-gray-800">
|
|
727
|
+
<nav
|
|
728
|
+
class="flex w-56 shrink-0 flex-col justify-between border-r border-gray-200 bg-gray-50/50 px-3 pb-3 pt-3 text-xs"
|
|
729
|
+
aria-label="Inspector sections"
|
|
730
|
+
>
|
|
731
|
+
<div class="flex flex-col gap-4 overflow-y-auto">
|
|
732
|
+
<div
|
|
733
|
+
class="flex items-center gap-2 pl-1 touch-none select-none ${this.isDragging && this.pointerContext === "window" ? "cursor-grabbing" : "cursor-grab"}"
|
|
734
|
+
data-drag-context="window"
|
|
735
|
+
@pointerdown=${this.handlePointerDown}
|
|
736
|
+
@pointermove=${this.handlePointerMove}
|
|
737
|
+
@pointerup=${this.handlePointerUp}
|
|
738
|
+
@pointercancel=${this.handlePointerCancel}
|
|
739
|
+
>
|
|
740
|
+
<span
|
|
741
|
+
class="flex h-8 w-8 items-center justify-center rounded-lg bg-gray-900 text-white pointer-events-none"
|
|
742
|
+
>
|
|
743
|
+
${this.renderIcon("Building2")}
|
|
744
|
+
</span>
|
|
745
|
+
<div class="flex flex-1 flex-col leading-tight pointer-events-none">
|
|
746
|
+
<span class="text-sm font-semibold text-gray-900">Acme Inc</span>
|
|
747
|
+
<span class="text-[10px] text-gray-500">Enterprise</span>
|
|
748
|
+
</div>
|
|
749
|
+
</div>
|
|
750
|
+
|
|
751
|
+
<div class="flex flex-col gap-2 pt-2">
|
|
752
|
+
<div class="px-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400">Platform</div>
|
|
753
|
+
<div class="flex flex-col gap-0.5">
|
|
754
|
+
${this.menuItems.map(({ key, label, icon }) => {
|
|
755
|
+
const isSelected = this.selectedMenu === key;
|
|
756
|
+
const buttonClasses = [
|
|
757
|
+
"group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300",
|
|
758
|
+
isSelected ? "bg-gray-900 text-white" : "text-gray-600 hover:bg-gray-100 hover:text-gray-900"
|
|
759
|
+
].join(" ");
|
|
760
|
+
const badgeClasses = isSelected ? "bg-gray-800 text-white" : "bg-white border border-gray-200 text-gray-500 group-hover:border-gray-300 group-hover:text-gray-700";
|
|
761
|
+
return import_lit.html`
|
|
762
|
+
<button
|
|
763
|
+
type="button"
|
|
764
|
+
class=${buttonClasses}
|
|
765
|
+
aria-pressed=${isSelected}
|
|
766
|
+
@click=${() => this.handleMenuSelect(key)}
|
|
767
|
+
>
|
|
768
|
+
<span
|
|
769
|
+
class="flex h-6 w-6 items-center justify-center rounded ${badgeClasses}"
|
|
770
|
+
aria-hidden="true"
|
|
771
|
+
>
|
|
772
|
+
${this.renderIcon(icon)}
|
|
773
|
+
</span>
|
|
774
|
+
<span class="flex-1">${label}</span>
|
|
775
|
+
<span class="text-gray-400 opacity-60">${this.renderIcon("ChevronRight")}</span>
|
|
776
|
+
</button>
|
|
777
|
+
`;
|
|
778
|
+
})}
|
|
779
|
+
</div>
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
|
|
783
|
+
<div
|
|
784
|
+
class="relative flex items-center rounded-lg border border-gray-200 bg-white px-2 py-2 text-left text-xs text-gray-700 cursor-pointer hover:bg-gray-50 transition"
|
|
785
|
+
>
|
|
786
|
+
<span
|
|
787
|
+
class="w-6 h-6 flex items-center justify-center overflow-hidden rounded bg-gray-100 text-[10px] font-semibold text-gray-700"
|
|
788
|
+
>
|
|
789
|
+
JS
|
|
790
|
+
</span>
|
|
791
|
+
<div class="pl-2 flex flex-1 flex-col leading-tight">
|
|
792
|
+
<span class="font-medium text-gray-900">John Snow</span>
|
|
793
|
+
<span class="text-[10px] text-gray-500">john@snow.com</span>
|
|
794
|
+
</div>
|
|
795
|
+
<span class="text-gray-300">${this.renderIcon("ChevronRight")}</span>
|
|
796
|
+
</div>
|
|
797
|
+
</nav>
|
|
798
|
+
<div class="relative flex flex-1 flex-col overflow-hidden">
|
|
799
|
+
<div
|
|
800
|
+
class="drag-handle flex items-center justify-between border-b border-gray-200 px-4 py-3 touch-none select-none ${this.isDragging && this.pointerContext === "window" ? "cursor-grabbing" : "cursor-grab"}"
|
|
801
|
+
data-drag-context="window"
|
|
802
|
+
@pointerdown=${this.handlePointerDown}
|
|
803
|
+
@pointermove=${this.handlePointerMove}
|
|
804
|
+
@pointerup=${this.handlePointerUp}
|
|
805
|
+
@pointercancel=${this.handlePointerCancel}
|
|
806
|
+
>
|
|
807
|
+
<div class="flex items-center gap-2 text-xs text-gray-500">
|
|
808
|
+
<span class="text-gray-400">
|
|
809
|
+
${this.renderIcon(this.getSelectedMenu().icon)}
|
|
810
|
+
</span>
|
|
811
|
+
<div class="flex items-center text-xs text-gray-600">
|
|
812
|
+
<span class="pr-3">${this.getSelectedMenu().label}</span>
|
|
813
|
+
${hasContextDropdown ? import_lit.html`
|
|
814
|
+
<span class="h-3 w-px bg-gray-200"></span>
|
|
815
|
+
<div class="pl-3">${contextDropdown}</div>
|
|
816
|
+
` : import_lit.nothing}
|
|
817
|
+
</div>
|
|
818
|
+
</div>
|
|
819
|
+
<button
|
|
820
|
+
class="flex h-6 w-6 items-center justify-center rounded 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"
|
|
821
|
+
type="button"
|
|
822
|
+
aria-label="Close Web Inspector"
|
|
823
|
+
@pointerdown=${this.handleClosePointerDown}
|
|
824
|
+
@click=${this.handleCloseClick}
|
|
825
|
+
>
|
|
826
|
+
${this.renderIcon("X")}
|
|
827
|
+
</button>
|
|
828
|
+
</div>
|
|
829
|
+
<div class="flex-1 overflow-auto">
|
|
830
|
+
${this.renderMainContent()}
|
|
831
|
+
<slot></slot>
|
|
832
|
+
</div>
|
|
833
|
+
</div>
|
|
834
|
+
</div>
|
|
835
|
+
<div
|
|
836
|
+
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"
|
|
837
|
+
role="presentation"
|
|
838
|
+
aria-hidden="true"
|
|
839
|
+
@pointerdown=${this.handleResizePointerDown}
|
|
840
|
+
@pointermove=${this.handleResizePointerMove}
|
|
841
|
+
@pointerup=${this.handleResizePointerUp}
|
|
842
|
+
@pointercancel=${this.handleResizePointerCancel}
|
|
843
|
+
>
|
|
844
|
+
<svg
|
|
845
|
+
class="h-3 w-3"
|
|
846
|
+
viewBox="0 0 16 16"
|
|
847
|
+
fill="none"
|
|
848
|
+
stroke="currentColor"
|
|
849
|
+
stroke-linecap="round"
|
|
850
|
+
stroke-width="1.5"
|
|
851
|
+
>
|
|
852
|
+
<path d="M5 15L15 5" />
|
|
853
|
+
<path d="M9 15L15 9" />
|
|
854
|
+
</svg>
|
|
855
|
+
</div>
|
|
856
|
+
</section>
|
|
857
|
+
`;
|
|
858
|
+
}
|
|
859
|
+
hydrateStateFromCookie() {
|
|
860
|
+
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const persisted = loadInspectorState(COOKIE_NAME);
|
|
864
|
+
if (!persisted) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
const persistedButton = persisted.button;
|
|
868
|
+
if (persistedButton) {
|
|
869
|
+
if (isValidAnchor(persistedButton.anchor)) {
|
|
870
|
+
this.contextState.button.anchor = persistedButton.anchor;
|
|
871
|
+
}
|
|
872
|
+
if (isValidPosition(persistedButton.anchorOffset)) {
|
|
873
|
+
this.contextState.button.anchorOffset = persistedButton.anchorOffset;
|
|
874
|
+
}
|
|
875
|
+
if (typeof persistedButton.hasCustomPosition === "boolean") {
|
|
876
|
+
this.hasCustomPosition.button = persistedButton.hasCustomPosition;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
const persistedWindow = persisted.window;
|
|
880
|
+
if (persistedWindow) {
|
|
881
|
+
if (isValidAnchor(persistedWindow.anchor)) {
|
|
882
|
+
this.contextState.window.anchor = persistedWindow.anchor;
|
|
883
|
+
}
|
|
884
|
+
if (isValidPosition(persistedWindow.anchorOffset)) {
|
|
885
|
+
this.contextState.window.anchorOffset = persistedWindow.anchorOffset;
|
|
886
|
+
}
|
|
887
|
+
if (isValidSize(persistedWindow.size)) {
|
|
888
|
+
this.contextState.window.size = this.clampWindowSize(persistedWindow.size);
|
|
889
|
+
}
|
|
890
|
+
if (typeof persistedWindow.hasCustomPosition === "boolean") {
|
|
891
|
+
this.hasCustomPosition.window = persistedWindow.hasCustomPosition;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
get activeContext() {
|
|
896
|
+
return this.isOpen ? "window" : "button";
|
|
897
|
+
}
|
|
898
|
+
measureContext(context) {
|
|
899
|
+
const selector = context === "window" ? ".inspector-window" : ".console-button";
|
|
900
|
+
const element = this.renderRoot?.querySelector(selector);
|
|
901
|
+
if (!element) {
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const fallback = context === "window" ? DEFAULT_WINDOW_SIZE : DEFAULT_BUTTON_SIZE;
|
|
905
|
+
updateSizeFromElement(this.contextState[context], element, fallback);
|
|
906
|
+
}
|
|
907
|
+
centerContext(context) {
|
|
908
|
+
if (typeof window === "undefined") {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
const viewport = this.getViewportSize();
|
|
912
|
+
centerContext(this.contextState[context], viewport, EDGE_MARGIN);
|
|
913
|
+
if (context === this.activeContext) {
|
|
914
|
+
this.updateHostTransform(context);
|
|
915
|
+
}
|
|
916
|
+
this.hasCustomPosition[context] = false;
|
|
917
|
+
this.persistState();
|
|
918
|
+
}
|
|
919
|
+
ensureWindowPlacement() {
|
|
920
|
+
if (typeof window === "undefined") {
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (!this.hasCustomPosition.window) {
|
|
924
|
+
this.centerContext("window");
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const viewport = this.getViewportSize();
|
|
928
|
+
keepPositionWithinViewport(this.contextState.window, viewport, EDGE_MARGIN);
|
|
929
|
+
updateAnchorFromPosition(this.contextState.window, viewport, EDGE_MARGIN);
|
|
930
|
+
this.updateHostTransform("window");
|
|
931
|
+
this.persistState();
|
|
932
|
+
}
|
|
933
|
+
constrainToViewport(position, context) {
|
|
934
|
+
if (typeof window === "undefined") {
|
|
935
|
+
return position;
|
|
936
|
+
}
|
|
937
|
+
const viewport = this.getViewportSize();
|
|
938
|
+
return constrainToViewport(this.contextState[context], position, viewport, EDGE_MARGIN);
|
|
939
|
+
}
|
|
940
|
+
keepPositionWithinViewport(context) {
|
|
941
|
+
if (typeof window === "undefined") {
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const viewport = this.getViewportSize();
|
|
945
|
+
keepPositionWithinViewport(this.contextState[context], viewport, EDGE_MARGIN);
|
|
946
|
+
}
|
|
947
|
+
getViewportSize() {
|
|
948
|
+
if (typeof window === "undefined") {
|
|
949
|
+
return { ...DEFAULT_WINDOW_SIZE };
|
|
950
|
+
}
|
|
951
|
+
return { width: window.innerWidth, height: window.innerHeight };
|
|
952
|
+
}
|
|
953
|
+
persistState() {
|
|
954
|
+
const state = {
|
|
955
|
+
button: {
|
|
956
|
+
anchor: this.contextState.button.anchor,
|
|
957
|
+
anchorOffset: this.contextState.button.anchorOffset,
|
|
958
|
+
hasCustomPosition: this.hasCustomPosition.button
|
|
959
|
+
},
|
|
960
|
+
window: {
|
|
961
|
+
anchor: this.contextState.window.anchor,
|
|
962
|
+
anchorOffset: this.contextState.window.anchorOffset,
|
|
963
|
+
size: {
|
|
964
|
+
width: Math.round(this.contextState.window.size.width),
|
|
965
|
+
height: Math.round(this.contextState.window.size.height)
|
|
966
|
+
},
|
|
967
|
+
hasCustomPosition: this.hasCustomPosition.window
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
saveInspectorState(COOKIE_NAME, state, COOKIE_MAX_AGE_SECONDS);
|
|
971
|
+
}
|
|
972
|
+
clampWindowSize(size) {
|
|
973
|
+
if (typeof window === "undefined") {
|
|
974
|
+
return {
|
|
975
|
+
width: Math.max(MIN_WINDOW_WIDTH, size.width),
|
|
976
|
+
height: Math.max(MIN_WINDOW_HEIGHT, size.height)
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
const viewport = this.getViewportSize();
|
|
980
|
+
return clampSize(size, viewport, EDGE_MARGIN, MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT);
|
|
981
|
+
}
|
|
982
|
+
updateHostTransform(context = this.activeContext) {
|
|
983
|
+
if (context !== this.activeContext) {
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
const { position } = this.contextState[context];
|
|
987
|
+
this.style.transform = `translate3d(${position.x}px, ${position.y}px, 0)`;
|
|
988
|
+
}
|
|
989
|
+
setDragging(value) {
|
|
990
|
+
if (this.isDragging !== value) {
|
|
991
|
+
this.isDragging = value;
|
|
992
|
+
this.requestUpdate();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
updateAnchorFromPosition(context) {
|
|
996
|
+
if (typeof window === "undefined") {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
const viewport = this.getViewportSize();
|
|
1000
|
+
updateAnchorFromPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1001
|
+
}
|
|
1002
|
+
applyAnchorPosition(context) {
|
|
1003
|
+
if (typeof window === "undefined") {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
const viewport = this.getViewportSize();
|
|
1007
|
+
applyAnchorPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1008
|
+
this.updateHostTransform(context);
|
|
1009
|
+
this.persistState();
|
|
1010
|
+
}
|
|
1011
|
+
resetResizeTracking() {
|
|
1012
|
+
this.resizePointerId = null;
|
|
1013
|
+
this.resizeStart = null;
|
|
1014
|
+
this.resizeInitialSize = null;
|
|
1015
|
+
this.isResizing = false;
|
|
1016
|
+
}
|
|
1017
|
+
resetPointerTracking() {
|
|
1018
|
+
this.pointerId = null;
|
|
1019
|
+
this.dragStart = null;
|
|
1020
|
+
this.pointerContext = null;
|
|
1021
|
+
this.setDragging(false);
|
|
1022
|
+
this.draggedDuringInteraction = false;
|
|
1023
|
+
}
|
|
1024
|
+
openInspector() {
|
|
1025
|
+
if (this.isOpen) {
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
this.isOpen = true;
|
|
1029
|
+
this.ensureWindowPlacement();
|
|
1030
|
+
this.requestUpdate();
|
|
1031
|
+
void this.updateComplete.then(() => {
|
|
1032
|
+
this.measureContext("window");
|
|
1033
|
+
if (this.hasCustomPosition.window) {
|
|
1034
|
+
this.applyAnchorPosition("window");
|
|
1035
|
+
} else {
|
|
1036
|
+
this.centerContext("window");
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
closeInspector() {
|
|
1041
|
+
if (!this.isOpen) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
this.isOpen = false;
|
|
1045
|
+
this.updateHostTransform("button");
|
|
1046
|
+
this.requestUpdate();
|
|
1047
|
+
void this.updateComplete.then(() => {
|
|
1048
|
+
this.measureContext("button");
|
|
1049
|
+
this.applyAnchorPosition("button");
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
renderIcon(name) {
|
|
1053
|
+
const iconNode = import_lucide.icons[name];
|
|
1054
|
+
if (!iconNode) {
|
|
1055
|
+
return import_lit.nothing;
|
|
1056
|
+
}
|
|
1057
|
+
const svgAttrs = {
|
|
1058
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1059
|
+
viewBox: "0 0 24 24",
|
|
1060
|
+
fill: "none",
|
|
1061
|
+
stroke: "currentColor",
|
|
1062
|
+
"stroke-width": "1.5",
|
|
1063
|
+
"stroke-linecap": "round",
|
|
1064
|
+
"stroke-linejoin": "round",
|
|
1065
|
+
class: "h-3.5 w-3.5"
|
|
1066
|
+
};
|
|
1067
|
+
const svgMarkup = `<svg ${this.serializeAttributes(svgAttrs)}>${iconNode.map(([tag, attrs]) => `<${tag} ${this.serializeAttributes(attrs)} />`).join("")}</svg>`;
|
|
1068
|
+
return (0, import_unsafe_html.unsafeHTML)(svgMarkup);
|
|
1069
|
+
}
|
|
1070
|
+
serializeAttributes(attributes) {
|
|
1071
|
+
return Object.entries(attributes).filter(([key, value]) => key !== "key" && value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key}="${String(value).replace(/"/g, """)}"`).join(" ");
|
|
1072
|
+
}
|
|
1073
|
+
getSelectedMenu() {
|
|
1074
|
+
const found = this.menuItems.find((item) => item.key === this.selectedMenu);
|
|
1075
|
+
return found ?? this.menuItems[0];
|
|
1076
|
+
}
|
|
1077
|
+
renderMainContent() {
|
|
1078
|
+
if (this.selectedMenu === "ag-ui-events") {
|
|
1079
|
+
return this.renderEventsTable();
|
|
1080
|
+
}
|
|
1081
|
+
return import_lit.html`
|
|
1082
|
+
<div class="flex flex-col gap-3 p-4">
|
|
1083
|
+
<div class="h-24 rounded-lg bg-gray-50"></div>
|
|
1084
|
+
<div class="h-20 rounded-lg bg-gray-50"></div>
|
|
1085
|
+
</div>
|
|
1086
|
+
`;
|
|
1087
|
+
}
|
|
1088
|
+
renderEventsTable() {
|
|
1089
|
+
const events = this.getEventsForSelectedContext();
|
|
1090
|
+
if (events.length === 0) {
|
|
1091
|
+
return import_lit.html`
|
|
1092
|
+
<div class="flex h-full items-center justify-center px-4 py-8 text-xs text-gray-500">
|
|
1093
|
+
No events yet. Trigger an agent run to see live activity.
|
|
1094
|
+
</div>
|
|
1095
|
+
`;
|
|
1096
|
+
}
|
|
1097
|
+
return import_lit.html`
|
|
1098
|
+
<div class="overflow-hidden">
|
|
1099
|
+
<table class="w-full border-collapse text-xs">
|
|
1100
|
+
<thead>
|
|
1101
|
+
<tr class="bg-white">
|
|
1102
|
+
<th class="border-r border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
1103
|
+
Type
|
|
1104
|
+
</th>
|
|
1105
|
+
<th class="border-r border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
1106
|
+
Time
|
|
1107
|
+
</th>
|
|
1108
|
+
<th class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900">
|
|
1109
|
+
Payload
|
|
1110
|
+
</th>
|
|
1111
|
+
</tr>
|
|
1112
|
+
</thead>
|
|
1113
|
+
<tbody>
|
|
1114
|
+
${events.map((event, index) => {
|
|
1115
|
+
const isLastRow = index === events.length - 1;
|
|
1116
|
+
const rowBg = index % 2 === 0 ? "bg-white" : "bg-gray-50/50";
|
|
1117
|
+
const badgeClasses = this.getEventBadgeClasses(event.type);
|
|
1118
|
+
const inlinePayload = this.stringifyPayload(event.payload, false) || "\u2014";
|
|
1119
|
+
const prettyPayload = this.stringifyPayload(event.payload, true) || inlinePayload;
|
|
1120
|
+
const isExpanded = this.expandedRows.has(event.id);
|
|
1121
|
+
return import_lit.html`
|
|
1122
|
+
<tr
|
|
1123
|
+
class="${rowBg} transition hover:bg-blue-50/50"
|
|
1124
|
+
@click=${() => this.toggleRowExpansion(event.id)}
|
|
1125
|
+
>
|
|
1126
|
+
<td class="border-r ${!isLastRow ? "border-b" : ""} border-gray-200 px-3 py-2">
|
|
1127
|
+
<div class="flex flex-col gap-1">
|
|
1128
|
+
<span class=${badgeClasses}>${event.type}</span>
|
|
1129
|
+
<span class="font-mono text-[10px] text-gray-400">${event.agentId}</span>
|
|
1130
|
+
</div>
|
|
1131
|
+
</td>
|
|
1132
|
+
<td class="border-r ${!isLastRow ? "border-b" : ""} border-gray-200 px-3 py-2 font-mono text-[11px] text-gray-600">
|
|
1133
|
+
<span title=${new Date(event.timestamp).toLocaleString()}>
|
|
1134
|
+
${new Date(event.timestamp).toLocaleTimeString()}
|
|
1135
|
+
</span>
|
|
1136
|
+
</td>
|
|
1137
|
+
<td class="${!isLastRow ? "border-b" : ""} border-gray-200 px-3 py-2 font-mono text-[10px] text-gray-600 ${isExpanded ? "" : "truncate max-w-xs"}">
|
|
1138
|
+
${isExpanded ? import_lit.html`<pre class="m-0 whitespace-pre-wrap text-[10px] font-mono text-gray-600">${prettyPayload}</pre>` : inlinePayload}
|
|
1139
|
+
</td>
|
|
1140
|
+
</tr>
|
|
1141
|
+
`;
|
|
1142
|
+
})}
|
|
1143
|
+
</tbody>
|
|
1144
|
+
</table>
|
|
1145
|
+
</div>
|
|
1146
|
+
`;
|
|
1147
|
+
}
|
|
1148
|
+
renderContextDropdown() {
|
|
1149
|
+
if (this.selectedMenu !== "ag-ui-events") {
|
|
1150
|
+
return import_lit.nothing;
|
|
1151
|
+
}
|
|
1152
|
+
const selectedLabel = this.contextOptions.find((opt) => opt.key === this.selectedContext)?.label ?? "";
|
|
1153
|
+
return import_lit.html`
|
|
1154
|
+
<div class="relative" data-context-dropdown-root="true">
|
|
1155
|
+
<button
|
|
1156
|
+
type="button"
|
|
1157
|
+
class="flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-medium text-gray-600 transition hover:bg-gray-100 hover:text-gray-900"
|
|
1158
|
+
@pointerdown=${this.handleContextDropdownToggle}
|
|
1159
|
+
>
|
|
1160
|
+
<span>${selectedLabel}</span>
|
|
1161
|
+
<span class="text-gray-400">${this.renderIcon("ChevronDown")}</span>
|
|
1162
|
+
</button>
|
|
1163
|
+
${this.contextMenuOpen ? import_lit.html`
|
|
1164
|
+
<div
|
|
1165
|
+
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"
|
|
1166
|
+
data-context-dropdown-root="true"
|
|
1167
|
+
>
|
|
1168
|
+
${this.contextOptions.map(
|
|
1169
|
+
(option) => import_lit.html`
|
|
1170
|
+
<button
|
|
1171
|
+
type="button"
|
|
1172
|
+
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"
|
|
1173
|
+
data-context-dropdown-root="true"
|
|
1174
|
+
@click=${() => this.handleContextOptionSelect(option.key)}
|
|
1175
|
+
>
|
|
1176
|
+
<span class="${option.key === this.selectedContext ? "text-gray-900 font-medium" : "text-gray-600"}">${option.label}</span>
|
|
1177
|
+
${option.key === this.selectedContext ? import_lit.html`<span class="text-gray-500">${this.renderIcon("Check")}</span>` : import_lit.nothing}
|
|
1178
|
+
</button>
|
|
1179
|
+
`
|
|
1180
|
+
)}
|
|
1181
|
+
</div>
|
|
1182
|
+
` : import_lit.nothing}
|
|
1183
|
+
</div>
|
|
1184
|
+
`;
|
|
1185
|
+
}
|
|
1186
|
+
handleMenuSelect(key) {
|
|
1187
|
+
if (!this.menuItems.some((item) => item.key === key)) {
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
this.selectedMenu = key;
|
|
1191
|
+
this.contextMenuOpen = false;
|
|
1192
|
+
this.requestUpdate();
|
|
1193
|
+
}
|
|
1194
|
+
handleContextDropdownToggle(event) {
|
|
1195
|
+
event.preventDefault();
|
|
1196
|
+
event.stopPropagation();
|
|
1197
|
+
this.contextMenuOpen = !this.contextMenuOpen;
|
|
1198
|
+
this.requestUpdate();
|
|
1199
|
+
}
|
|
1200
|
+
handleContextOptionSelect(key) {
|
|
1201
|
+
if (!this.contextOptions.some((option) => option.key === key)) {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (this.selectedContext !== key) {
|
|
1205
|
+
this.selectedContext = key;
|
|
1206
|
+
this.expandedRows.clear();
|
|
1207
|
+
}
|
|
1208
|
+
this.contextMenuOpen = false;
|
|
1209
|
+
this.requestUpdate();
|
|
1210
|
+
}
|
|
1211
|
+
toggleRowExpansion(eventId) {
|
|
1212
|
+
if (this.expandedRows.has(eventId)) {
|
|
1213
|
+
this.expandedRows.delete(eventId);
|
|
1214
|
+
} else {
|
|
1215
|
+
this.expandedRows.add(eventId);
|
|
1216
|
+
}
|
|
1217
|
+
this.requestUpdate();
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
function defineWebInspector() {
|
|
1221
|
+
if (!customElements.get(WEB_INSPECTOR_TAG)) {
|
|
1222
|
+
customElements.define(WEB_INSPECTOR_TAG, WebInspectorElement);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
defineWebInspector();
|
|
1226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1227
|
+
0 && (module.exports = {
|
|
1228
|
+
WEB_INSPECTOR_TAG,
|
|
1229
|
+
WebInspectorElement,
|
|
1230
|
+
defineWebInspector
|
|
1231
|
+
});
|
|
1232
|
+
//# sourceMappingURL=index.js.map
|