@copilotkitnext/web-inspector 1.51.5-next.0 → 1.51.5-next.2
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/CHANGELOG.md +12 -0
- package/dist/assets/inspector-logo-icon.cjs +12 -0
- package/dist/assets/inspector-logo-icon.cjs.map +1 -0
- package/dist/assets/inspector-logo-icon.mjs +6 -0
- package/dist/assets/inspector-logo-icon.mjs.map +1 -0
- package/dist/assets/inspector-logo.cjs +12 -0
- package/dist/assets/inspector-logo.cjs.map +1 -0
- package/dist/assets/inspector-logo.mjs +6 -0
- package/dist/assets/inspector-logo.mjs.map +1 -0
- package/dist/index.cjs +2862 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +207 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +199 -197
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1762 -2414
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2100 -229
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/context-helpers.cjs +82 -0
- package/dist/lib/context-helpers.cjs.map +1 -0
- package/dist/lib/context-helpers.mjs +75 -0
- package/dist/lib/context-helpers.mjs.map +1 -0
- package/dist/lib/persistence.cjs +62 -0
- package/dist/lib/persistence.cjs.map +1 -0
- package/dist/lib/persistence.mjs +56 -0
- package/dist/lib/persistence.mjs.map +1 -0
- package/dist/styles/generated.cjs +12 -0
- package/dist/styles/generated.cjs.map +1 -0
- package/dist/styles/generated.mjs +6 -0
- package/dist/styles/generated.mjs.map +1 -0
- package/package.json +19 -16
- package/tsdown.config.ts +45 -0
- package/dist/7a3b31978162670a.svg +0 -40
- package/dist/a1f6528fccd26dea.svg +0 -8
- package/dist/index.d.ts +0 -205
- package/dist/index.js +0 -3536
- package/dist/index.js.map +0 -1
- package/rollup.config.mjs +0 -41
- package/tsup.config.ts +0 -15
package/dist/index.mjs
CHANGED
|
@@ -1,977 +1,710 @@
|
|
|
1
|
-
|
|
1
|
+
import generated_default from "./styles/generated.mjs";
|
|
2
|
+
import inspector_logo_default from "./assets/inspector-logo.mjs";
|
|
3
|
+
import inspector_logo_icon_default from "./assets/inspector-logo-icon.mjs";
|
|
4
|
+
import { applyAnchorPosition, centerContext, clampSize, constrainToViewport, keepPositionWithinViewport, updateAnchorFromPosition, updateSizeFromElement } from "./lib/context-helpers.mjs";
|
|
5
|
+
import { isValidAnchor, isValidDockMode, isValidPosition, isValidSize, loadInspectorState, saveInspectorState } from "./lib/persistence.mjs";
|
|
2
6
|
import { LitElement, css, html, nothing, unsafeCSS } from "lit";
|
|
3
7
|
import { styleMap } from "lit/directives/style-map.js";
|
|
4
|
-
|
|
5
|
-
// src/styles/generated.css
|
|
6
|
-
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-fuchsia-50:oklch(97.7% .017 320.058);--color-fuchsia-200:oklch(90.3% .076 319.62);--color-fuchsia-700:oklch(51.8% .253 323.949);--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-fuchsia-200{border-color:var(--color-fuchsia-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-fuchsia-50{background-color:var(--color-fuchsia-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-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-fuchsia-700{color:var(--color-fuchsia-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}}';
|
|
7
|
-
|
|
8
|
-
// src/assets/inspector-logo.svg
|
|
9
|
-
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';
|
|
10
|
-
|
|
11
|
-
// src/assets/inspector-logo-icon.svg
|
|
12
|
-
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';
|
|
13
|
-
|
|
14
|
-
// src/index.ts
|
|
15
8
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
16
9
|
import { marked } from "marked";
|
|
17
10
|
import { icons } from "lucide";
|
|
18
|
-
import {
|
|
19
|
-
CopilotKitCoreRuntimeConnectionStatus
|
|
20
|
-
} from "@copilotkitnext/core";
|
|
21
|
-
|
|
22
|
-
// src/lib/context-helpers.ts
|
|
23
|
-
function updateSizeFromElement(state, element, fallback) {
|
|
24
|
-
const rect = element.getBoundingClientRect();
|
|
25
|
-
state.size = {
|
|
26
|
-
width: rect.width || fallback.width,
|
|
27
|
-
height: rect.height || fallback.height
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function clampSize(size, viewport, edgeMargin, minWidth, minHeight) {
|
|
31
|
-
const maxWidth = Math.max(minWidth, viewport.width - edgeMargin * 2);
|
|
32
|
-
const maxHeight = Math.max(minHeight, viewport.height - edgeMargin * 2);
|
|
33
|
-
return {
|
|
34
|
-
width: clamp(size.width, minWidth, maxWidth),
|
|
35
|
-
height: clamp(size.height, minHeight, maxHeight)
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function constrainToViewport(state, position, viewport, edgeMargin) {
|
|
39
|
-
const maxX = Math.max(
|
|
40
|
-
edgeMargin,
|
|
41
|
-
viewport.width - state.size.width - edgeMargin
|
|
42
|
-
);
|
|
43
|
-
const maxY = Math.max(
|
|
44
|
-
edgeMargin,
|
|
45
|
-
viewport.height - state.size.height - edgeMargin
|
|
46
|
-
);
|
|
47
|
-
return {
|
|
48
|
-
x: clamp(position.x, edgeMargin, maxX),
|
|
49
|
-
y: clamp(position.y, edgeMargin, maxY)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function keepPositionWithinViewport(state, viewport, edgeMargin) {
|
|
53
|
-
state.position = constrainToViewport(
|
|
54
|
-
state,
|
|
55
|
-
state.position,
|
|
56
|
-
viewport,
|
|
57
|
-
edgeMargin
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
function centerContext(state, viewport, edgeMargin) {
|
|
61
|
-
const centered = {
|
|
62
|
-
x: Math.round((viewport.width - state.size.width) / 2),
|
|
63
|
-
y: Math.round((viewport.height - state.size.height) / 2)
|
|
64
|
-
};
|
|
65
|
-
state.position = constrainToViewport(state, centered, viewport, edgeMargin);
|
|
66
|
-
updateAnchorFromPosition(state, viewport, edgeMargin);
|
|
67
|
-
return state.position;
|
|
68
|
-
}
|
|
69
|
-
function updateAnchorFromPosition(state, viewport, edgeMargin) {
|
|
70
|
-
const centerX = state.position.x + state.size.width / 2;
|
|
71
|
-
const centerY = state.position.y + state.size.height / 2;
|
|
72
|
-
const horizontal = centerX < viewport.width / 2 ? "left" : "right";
|
|
73
|
-
const vertical = centerY < viewport.height / 2 ? "top" : "bottom";
|
|
74
|
-
state.anchor = { horizontal, vertical };
|
|
75
|
-
const maxHorizontalOffset = Math.max(
|
|
76
|
-
edgeMargin,
|
|
77
|
-
viewport.width - state.size.width - edgeMargin
|
|
78
|
-
);
|
|
79
|
-
const maxVerticalOffset = Math.max(
|
|
80
|
-
edgeMargin,
|
|
81
|
-
viewport.height - state.size.height - edgeMargin
|
|
82
|
-
);
|
|
83
|
-
state.anchorOffset = {
|
|
84
|
-
x: horizontal === "left" ? clamp(state.position.x, edgeMargin, maxHorizontalOffset) : clamp(
|
|
85
|
-
viewport.width - state.position.x - state.size.width,
|
|
86
|
-
edgeMargin,
|
|
87
|
-
maxHorizontalOffset
|
|
88
|
-
),
|
|
89
|
-
y: vertical === "top" ? clamp(state.position.y, edgeMargin, maxVerticalOffset) : clamp(
|
|
90
|
-
viewport.height - state.position.y - state.size.height,
|
|
91
|
-
edgeMargin,
|
|
92
|
-
maxVerticalOffset
|
|
93
|
-
)
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function applyAnchorPosition(state, viewport, edgeMargin) {
|
|
97
|
-
const maxHorizontalOffset = Math.max(
|
|
98
|
-
edgeMargin,
|
|
99
|
-
viewport.width - state.size.width - edgeMargin
|
|
100
|
-
);
|
|
101
|
-
const maxVerticalOffset = Math.max(
|
|
102
|
-
edgeMargin,
|
|
103
|
-
viewport.height - state.size.height - edgeMargin
|
|
104
|
-
);
|
|
105
|
-
const horizontalOffset = clamp(
|
|
106
|
-
state.anchorOffset.x,
|
|
107
|
-
edgeMargin,
|
|
108
|
-
maxHorizontalOffset
|
|
109
|
-
);
|
|
110
|
-
const verticalOffset = clamp(
|
|
111
|
-
state.anchorOffset.y,
|
|
112
|
-
edgeMargin,
|
|
113
|
-
maxVerticalOffset
|
|
114
|
-
);
|
|
115
|
-
const x = state.anchor.horizontal === "left" ? horizontalOffset : viewport.width - state.size.width - horizontalOffset;
|
|
116
|
-
const y = state.anchor.vertical === "top" ? verticalOffset : viewport.height - state.size.height - verticalOffset;
|
|
117
|
-
state.anchorOffset = { x: horizontalOffset, y: verticalOffset };
|
|
118
|
-
state.position = constrainToViewport(state, { x, y }, viewport, edgeMargin);
|
|
119
|
-
return state.position;
|
|
120
|
-
}
|
|
121
|
-
function clamp(value, min, max) {
|
|
122
|
-
return Math.min(Math.max(min, value), max);
|
|
123
|
-
}
|
|
11
|
+
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
|
|
124
12
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (!value || typeof value !== "object") {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
const candidate = value;
|
|
172
|
-
return (candidate.horizontal === "left" || candidate.horizontal === "right") && (candidate.vertical === "top" || candidate.vertical === "bottom");
|
|
173
|
-
}
|
|
174
|
-
function isValidPosition(value) {
|
|
175
|
-
if (!value || typeof value !== "object") {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
const candidate = value;
|
|
179
|
-
return isFiniteNumber(candidate.x) && isFiniteNumber(candidate.y);
|
|
180
|
-
}
|
|
181
|
-
function isValidSize(value) {
|
|
182
|
-
if (!value || typeof value !== "object") {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
const candidate = value;
|
|
186
|
-
return isFiniteNumber(candidate.width) && isFiniteNumber(candidate.height);
|
|
187
|
-
}
|
|
188
|
-
function isFiniteNumber(value) {
|
|
189
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
190
|
-
}
|
|
191
|
-
function isValidDockMode(value) {
|
|
192
|
-
return value === "floating" || value === "docked-left";
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/index.ts
|
|
196
|
-
var WEB_INSPECTOR_TAG = "cpk-web-inspector";
|
|
197
|
-
var EDGE_MARGIN = 16;
|
|
198
|
-
var DRAG_THRESHOLD = 6;
|
|
199
|
-
var MIN_WINDOW_WIDTH = 600;
|
|
200
|
-
var MIN_WINDOW_WIDTH_DOCKED_LEFT = 420;
|
|
201
|
-
var MIN_WINDOW_HEIGHT = 200;
|
|
202
|
-
var INSPECTOR_STORAGE_KEY = "cpk:inspector:state";
|
|
203
|
-
var ANNOUNCEMENT_STORAGE_KEY = "cpk:inspector:announcements";
|
|
204
|
-
var ANNOUNCEMENT_URL = "https://cdn.copilotkit.ai/announcements.json";
|
|
205
|
-
var DEFAULT_BUTTON_SIZE = { width: 48, height: 48 };
|
|
206
|
-
var DEFAULT_WINDOW_SIZE = { width: 840, height: 560 };
|
|
207
|
-
var DOCKED_LEFT_WIDTH = 500;
|
|
208
|
-
var MAX_AGENT_EVENTS = 200;
|
|
209
|
-
var MAX_TOTAL_EVENTS = 500;
|
|
210
|
-
var AGENT_EVENT_TYPES = [
|
|
211
|
-
"RUN_STARTED",
|
|
212
|
-
"RUN_FINISHED",
|
|
213
|
-
"RUN_ERROR",
|
|
214
|
-
"TEXT_MESSAGE_START",
|
|
215
|
-
"TEXT_MESSAGE_CONTENT",
|
|
216
|
-
"TEXT_MESSAGE_END",
|
|
217
|
-
"TOOL_CALL_START",
|
|
218
|
-
"TOOL_CALL_ARGS",
|
|
219
|
-
"TOOL_CALL_END",
|
|
220
|
-
"TOOL_CALL_RESULT",
|
|
221
|
-
"STATE_SNAPSHOT",
|
|
222
|
-
"STATE_DELTA",
|
|
223
|
-
"MESSAGES_SNAPSHOT",
|
|
224
|
-
"RAW_EVENT",
|
|
225
|
-
"CUSTOM_EVENT",
|
|
226
|
-
"REASONING_START",
|
|
227
|
-
"REASONING_MESSAGE_START",
|
|
228
|
-
"REASONING_MESSAGE_CONTENT",
|
|
229
|
-
"REASONING_MESSAGE_END",
|
|
230
|
-
"REASONING_END",
|
|
231
|
-
"REASONING_ENCRYPTED_VALUE"
|
|
13
|
+
//#region src/index.ts
|
|
14
|
+
const WEB_INSPECTOR_TAG = "cpk-web-inspector";
|
|
15
|
+
const EDGE_MARGIN = 16;
|
|
16
|
+
const DRAG_THRESHOLD = 6;
|
|
17
|
+
const MIN_WINDOW_WIDTH = 600;
|
|
18
|
+
const MIN_WINDOW_WIDTH_DOCKED_LEFT = 420;
|
|
19
|
+
const MIN_WINDOW_HEIGHT = 200;
|
|
20
|
+
const INSPECTOR_STORAGE_KEY = "cpk:inspector:state";
|
|
21
|
+
const ANNOUNCEMENT_STORAGE_KEY = "cpk:inspector:announcements";
|
|
22
|
+
const ANNOUNCEMENT_URL = "https://cdn.copilotkit.ai/announcements.json";
|
|
23
|
+
const DEFAULT_BUTTON_SIZE = {
|
|
24
|
+
width: 48,
|
|
25
|
+
height: 48
|
|
26
|
+
};
|
|
27
|
+
const DEFAULT_WINDOW_SIZE = {
|
|
28
|
+
width: 840,
|
|
29
|
+
height: 560
|
|
30
|
+
};
|
|
31
|
+
const DOCKED_LEFT_WIDTH = 500;
|
|
32
|
+
const MAX_AGENT_EVENTS = 200;
|
|
33
|
+
const MAX_TOTAL_EVENTS = 500;
|
|
34
|
+
const AGENT_EVENT_TYPES = [
|
|
35
|
+
"RUN_STARTED",
|
|
36
|
+
"RUN_FINISHED",
|
|
37
|
+
"RUN_ERROR",
|
|
38
|
+
"TEXT_MESSAGE_START",
|
|
39
|
+
"TEXT_MESSAGE_CONTENT",
|
|
40
|
+
"TEXT_MESSAGE_END",
|
|
41
|
+
"TOOL_CALL_START",
|
|
42
|
+
"TOOL_CALL_ARGS",
|
|
43
|
+
"TOOL_CALL_END",
|
|
44
|
+
"TOOL_CALL_RESULT",
|
|
45
|
+
"STATE_SNAPSHOT",
|
|
46
|
+
"STATE_DELTA",
|
|
47
|
+
"MESSAGES_SNAPSHOT",
|
|
48
|
+
"RAW_EVENT",
|
|
49
|
+
"CUSTOM_EVENT",
|
|
50
|
+
"REASONING_START",
|
|
51
|
+
"REASONING_MESSAGE_START",
|
|
52
|
+
"REASONING_MESSAGE_CONTENT",
|
|
53
|
+
"REASONING_MESSAGE_END",
|
|
54
|
+
"REASONING_END",
|
|
55
|
+
"REASONING_ENCRYPTED_VALUE"
|
|
232
56
|
];
|
|
233
57
|
var WebInspectorElement = class extends LitElement {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
if (this.selectedContext !== nextSelected) {
|
|
880
|
-
this.selectedContext = nextSelected;
|
|
881
|
-
this.expandedRows.clear();
|
|
882
|
-
this.persistState();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
getEventsForSelectedContext() {
|
|
887
|
-
if (this.selectedContext === "all-agents") {
|
|
888
|
-
return this.flattenedEvents;
|
|
889
|
-
}
|
|
890
|
-
return this.agentEvents.get(this.selectedContext) ?? [];
|
|
891
|
-
}
|
|
892
|
-
filterEvents(events) {
|
|
893
|
-
const query = this.eventFilterText.trim().toLowerCase();
|
|
894
|
-
return events.filter((event) => {
|
|
895
|
-
if (this.eventTypeFilter !== "all" && event.type !== this.eventTypeFilter) {
|
|
896
|
-
return false;
|
|
897
|
-
}
|
|
898
|
-
if (!query) {
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
const payloadText = this.stringifyPayload(
|
|
902
|
-
event.payload,
|
|
903
|
-
false
|
|
904
|
-
).toLowerCase();
|
|
905
|
-
return event.type.toLowerCase().includes(query) || event.agentId.toLowerCase().includes(query) || payloadText.includes(query);
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
getLatestStateForAgent(agentId) {
|
|
909
|
-
if (this.agentStates.has(agentId)) {
|
|
910
|
-
const value = this.agentStates.get(agentId);
|
|
911
|
-
return value === void 0 ? null : value;
|
|
912
|
-
}
|
|
913
|
-
const events = this.agentEvents.get(agentId) ?? [];
|
|
914
|
-
const stateEvent = events.find((e) => e.type === "STATE_SNAPSHOT");
|
|
915
|
-
if (!stateEvent) {
|
|
916
|
-
return null;
|
|
917
|
-
}
|
|
918
|
-
return stateEvent.payload;
|
|
919
|
-
}
|
|
920
|
-
getLatestMessagesForAgent(agentId) {
|
|
921
|
-
const messages = this.agentMessages.get(agentId);
|
|
922
|
-
return messages ?? null;
|
|
923
|
-
}
|
|
924
|
-
getAgentStatus(agentId) {
|
|
925
|
-
const events = this.agentEvents.get(agentId) ?? [];
|
|
926
|
-
if (events.length === 0) {
|
|
927
|
-
return "idle";
|
|
928
|
-
}
|
|
929
|
-
const runEvent = events.find(
|
|
930
|
-
(e) => e.type === "RUN_STARTED" || e.type === "RUN_FINISHED" || e.type === "RUN_ERROR"
|
|
931
|
-
);
|
|
932
|
-
if (!runEvent) {
|
|
933
|
-
return "idle";
|
|
934
|
-
}
|
|
935
|
-
if (runEvent.type === "RUN_ERROR") {
|
|
936
|
-
return "error";
|
|
937
|
-
}
|
|
938
|
-
if (runEvent.type === "RUN_STARTED") {
|
|
939
|
-
const finishedAfter = events.find(
|
|
940
|
-
(e) => e.type === "RUN_FINISHED" && e.timestamp > runEvent.timestamp
|
|
941
|
-
);
|
|
942
|
-
return finishedAfter ? "idle" : "running";
|
|
943
|
-
}
|
|
944
|
-
return "idle";
|
|
945
|
-
}
|
|
946
|
-
getAgentStats(agentId) {
|
|
947
|
-
const events = this.agentEvents.get(agentId) ?? [];
|
|
948
|
-
const messages = this.agentMessages.get(agentId);
|
|
949
|
-
const toolCallCount = messages ? messages.reduce(
|
|
950
|
-
(count, message) => count + (message.toolCalls?.length ?? 0),
|
|
951
|
-
0
|
|
952
|
-
) : events.filter((e) => e.type === "TOOL_CALL_END").length;
|
|
953
|
-
const messageCount = messages?.length ?? 0;
|
|
954
|
-
return {
|
|
955
|
-
totalEvents: events.length,
|
|
956
|
-
lastActivity: events[0]?.timestamp ?? null,
|
|
957
|
-
messages: messageCount,
|
|
958
|
-
toolCalls: toolCallCount,
|
|
959
|
-
errors: events.filter((e) => e.type === "RUN_ERROR").length
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
renderToolCallDetails(toolCalls) {
|
|
963
|
-
if (!Array.isArray(toolCalls) || toolCalls.length === 0) {
|
|
964
|
-
return nothing;
|
|
965
|
-
}
|
|
966
|
-
return html`
|
|
58
|
+
constructor(..._args) {
|
|
59
|
+
super(..._args);
|
|
60
|
+
this._core = null;
|
|
61
|
+
this.coreSubscriber = null;
|
|
62
|
+
this.coreUnsubscribe = null;
|
|
63
|
+
this.runtimeStatus = null;
|
|
64
|
+
this.coreProperties = {};
|
|
65
|
+
this.lastCoreError = null;
|
|
66
|
+
this.agentSubscriptions = /* @__PURE__ */ new Map();
|
|
67
|
+
this.agentEvents = /* @__PURE__ */ new Map();
|
|
68
|
+
this.agentMessages = /* @__PURE__ */ new Map();
|
|
69
|
+
this.agentStates = /* @__PURE__ */ new Map();
|
|
70
|
+
this.flattenedEvents = [];
|
|
71
|
+
this.eventCounter = 0;
|
|
72
|
+
this.contextStore = {};
|
|
73
|
+
this.pointerId = null;
|
|
74
|
+
this.dragStart = null;
|
|
75
|
+
this.dragOffset = {
|
|
76
|
+
x: 0,
|
|
77
|
+
y: 0
|
|
78
|
+
};
|
|
79
|
+
this.isDragging = false;
|
|
80
|
+
this.pointerContext = null;
|
|
81
|
+
this.isOpen = false;
|
|
82
|
+
this.draggedDuringInteraction = false;
|
|
83
|
+
this.ignoreNextButtonClick = false;
|
|
84
|
+
this.selectedMenu = "ag-ui-events";
|
|
85
|
+
this.contextMenuOpen = false;
|
|
86
|
+
this.dockMode = "floating";
|
|
87
|
+
this.previousBodyMargins = null;
|
|
88
|
+
this.transitionTimeoutId = null;
|
|
89
|
+
this.pendingSelectedContext = null;
|
|
90
|
+
this.autoAttachCore = true;
|
|
91
|
+
this.attemptedAutoAttach = false;
|
|
92
|
+
this.cachedTools = [];
|
|
93
|
+
this.toolSignature = "";
|
|
94
|
+
this.eventFilterText = "";
|
|
95
|
+
this.eventTypeFilter = "all";
|
|
96
|
+
this.announcementMarkdown = null;
|
|
97
|
+
this.announcementHtml = null;
|
|
98
|
+
this.announcementTimestamp = null;
|
|
99
|
+
this.announcementPreviewText = null;
|
|
100
|
+
this.hasUnseenAnnouncement = false;
|
|
101
|
+
this.announcementLoaded = false;
|
|
102
|
+
this.announcementLoadError = null;
|
|
103
|
+
this.announcementPromise = null;
|
|
104
|
+
this.showAnnouncementPreview = true;
|
|
105
|
+
this.contextState = {
|
|
106
|
+
button: {
|
|
107
|
+
position: {
|
|
108
|
+
x: EDGE_MARGIN,
|
|
109
|
+
y: EDGE_MARGIN
|
|
110
|
+
},
|
|
111
|
+
size: { ...DEFAULT_BUTTON_SIZE },
|
|
112
|
+
anchor: {
|
|
113
|
+
horizontal: "right",
|
|
114
|
+
vertical: "top"
|
|
115
|
+
},
|
|
116
|
+
anchorOffset: {
|
|
117
|
+
x: EDGE_MARGIN,
|
|
118
|
+
y: EDGE_MARGIN
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
window: {
|
|
122
|
+
position: {
|
|
123
|
+
x: EDGE_MARGIN,
|
|
124
|
+
y: EDGE_MARGIN
|
|
125
|
+
},
|
|
126
|
+
size: { ...DEFAULT_WINDOW_SIZE },
|
|
127
|
+
anchor: {
|
|
128
|
+
horizontal: "right",
|
|
129
|
+
vertical: "top"
|
|
130
|
+
},
|
|
131
|
+
anchorOffset: {
|
|
132
|
+
x: EDGE_MARGIN,
|
|
133
|
+
y: EDGE_MARGIN
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
this.hasCustomPosition = {
|
|
138
|
+
button: false,
|
|
139
|
+
window: false
|
|
140
|
+
};
|
|
141
|
+
this.resizePointerId = null;
|
|
142
|
+
this.resizeStart = null;
|
|
143
|
+
this.resizeInitialSize = null;
|
|
144
|
+
this.isResizing = false;
|
|
145
|
+
this.menuItems = [
|
|
146
|
+
{
|
|
147
|
+
key: "ag-ui-events",
|
|
148
|
+
label: "AG-UI Events",
|
|
149
|
+
icon: "Zap"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: "agents",
|
|
153
|
+
label: "Agent",
|
|
154
|
+
icon: "Bot"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
key: "frontend-tools",
|
|
158
|
+
label: "Frontend Tools",
|
|
159
|
+
icon: "Hammer"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
key: "agent-context",
|
|
163
|
+
label: "Context",
|
|
164
|
+
icon: "FileText"
|
|
165
|
+
}
|
|
166
|
+
];
|
|
167
|
+
this.handlePointerDown = (event) => {
|
|
168
|
+
if (this.dockMode !== "floating" && this.isOpen) return;
|
|
169
|
+
const target = event.currentTarget;
|
|
170
|
+
const context = target?.dataset.dragContext === "window" ? "window" : "button";
|
|
171
|
+
const eventTarget = event.target;
|
|
172
|
+
if (context === "window" && eventTarget?.closest("button")) return;
|
|
173
|
+
this.pointerContext = context;
|
|
174
|
+
this.measureContext(context);
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
this.pointerId = event.pointerId;
|
|
177
|
+
this.dragStart = {
|
|
178
|
+
x: event.clientX,
|
|
179
|
+
y: event.clientY
|
|
180
|
+
};
|
|
181
|
+
const state = this.contextState[context];
|
|
182
|
+
this.dragOffset = {
|
|
183
|
+
x: event.clientX - state.position.x,
|
|
184
|
+
y: event.clientY - state.position.y
|
|
185
|
+
};
|
|
186
|
+
this.isDragging = false;
|
|
187
|
+
this.draggedDuringInteraction = false;
|
|
188
|
+
this.ignoreNextButtonClick = false;
|
|
189
|
+
target?.setPointerCapture?.(this.pointerId);
|
|
190
|
+
};
|
|
191
|
+
this.handlePointerMove = (event) => {
|
|
192
|
+
if (this.pointerId !== event.pointerId || !this.dragStart || !this.pointerContext) return;
|
|
193
|
+
const distance = Math.hypot(event.clientX - this.dragStart.x, event.clientY - this.dragStart.y);
|
|
194
|
+
if (!this.isDragging && distance < DRAG_THRESHOLD) return;
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
this.setDragging(true);
|
|
197
|
+
this.draggedDuringInteraction = true;
|
|
198
|
+
const desired = {
|
|
199
|
+
x: event.clientX - this.dragOffset.x,
|
|
200
|
+
y: event.clientY - this.dragOffset.y
|
|
201
|
+
};
|
|
202
|
+
const constrained = this.constrainToViewport(desired, this.pointerContext);
|
|
203
|
+
this.contextState[this.pointerContext].position = constrained;
|
|
204
|
+
this.updateHostTransform(this.pointerContext);
|
|
205
|
+
};
|
|
206
|
+
this.handlePointerUp = (event) => {
|
|
207
|
+
if (this.pointerId !== event.pointerId) return;
|
|
208
|
+
const target = event.currentTarget;
|
|
209
|
+
if (target?.hasPointerCapture(this.pointerId)) target.releasePointerCapture(this.pointerId);
|
|
210
|
+
const context = this.pointerContext ?? this.activeContext;
|
|
211
|
+
if (this.isDragging && this.pointerContext) {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
this.setDragging(false);
|
|
214
|
+
if (this.pointerContext === "window") {
|
|
215
|
+
this.updateAnchorFromPosition(this.pointerContext);
|
|
216
|
+
this.hasCustomPosition.window = true;
|
|
217
|
+
this.applyAnchorPosition(this.pointerContext);
|
|
218
|
+
} else if (this.pointerContext === "button") {
|
|
219
|
+
this.snapButtonToCorner();
|
|
220
|
+
this.hasCustomPosition.button = true;
|
|
221
|
+
if (this.draggedDuringInteraction) this.ignoreNextButtonClick = true;
|
|
222
|
+
}
|
|
223
|
+
} else if (context === "button" && !this.isOpen && !this.draggedDuringInteraction) this.openInspector();
|
|
224
|
+
this.resetPointerTracking();
|
|
225
|
+
};
|
|
226
|
+
this.handlePointerCancel = (event) => {
|
|
227
|
+
if (this.pointerId !== event.pointerId) return;
|
|
228
|
+
const target = event.currentTarget;
|
|
229
|
+
if (target?.hasPointerCapture(this.pointerId)) target.releasePointerCapture(this.pointerId);
|
|
230
|
+
this.resetPointerTracking();
|
|
231
|
+
};
|
|
232
|
+
this.handleButtonClick = (event) => {
|
|
233
|
+
if (this.isDragging) {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (this.ignoreNextButtonClick) {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
this.ignoreNextButtonClick = false;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!this.isOpen) {
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
this.openInspector();
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
this.handleClosePointerDown = (event) => {
|
|
248
|
+
event.stopPropagation();
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
};
|
|
251
|
+
this.handleCloseClick = () => {
|
|
252
|
+
this.closeInspector();
|
|
253
|
+
};
|
|
254
|
+
this.handleResizePointerDown = (event) => {
|
|
255
|
+
event.stopPropagation();
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
this.hasCustomPosition.window = true;
|
|
258
|
+
this.isResizing = true;
|
|
259
|
+
this.resizePointerId = event.pointerId;
|
|
260
|
+
this.resizeStart = {
|
|
261
|
+
x: event.clientX,
|
|
262
|
+
y: event.clientY
|
|
263
|
+
};
|
|
264
|
+
this.resizeInitialSize = { ...this.contextState.window.size };
|
|
265
|
+
if (document.body && this.dockMode !== "floating") document.body.style.transition = "";
|
|
266
|
+
event.currentTarget?.setPointerCapture?.(event.pointerId);
|
|
267
|
+
};
|
|
268
|
+
this.handleResizePointerMove = (event) => {
|
|
269
|
+
if (!this.isResizing || this.resizePointerId !== event.pointerId || !this.resizeStart || !this.resizeInitialSize) return;
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
const deltaX = event.clientX - this.resizeStart.x;
|
|
272
|
+
const deltaY = event.clientY - this.resizeStart.y;
|
|
273
|
+
const state = this.contextState.window;
|
|
274
|
+
if (this.dockMode === "docked-left") {
|
|
275
|
+
state.size = this.clampWindowSize({
|
|
276
|
+
width: this.resizeInitialSize.width + deltaX,
|
|
277
|
+
height: state.size.height
|
|
278
|
+
});
|
|
279
|
+
if (document.body) document.body.style.marginLeft = `${state.size.width}px`;
|
|
280
|
+
} else {
|
|
281
|
+
state.size = this.clampWindowSize({
|
|
282
|
+
width: this.resizeInitialSize.width + deltaX,
|
|
283
|
+
height: this.resizeInitialSize.height + deltaY
|
|
284
|
+
});
|
|
285
|
+
this.keepPositionWithinViewport("window");
|
|
286
|
+
this.updateAnchorFromPosition("window");
|
|
287
|
+
}
|
|
288
|
+
this.requestUpdate();
|
|
289
|
+
this.updateHostTransform("window");
|
|
290
|
+
};
|
|
291
|
+
this.handleResizePointerUp = (event) => {
|
|
292
|
+
if (this.resizePointerId !== event.pointerId) return;
|
|
293
|
+
const target = event.currentTarget;
|
|
294
|
+
if (target?.hasPointerCapture(this.resizePointerId)) target.releasePointerCapture(this.resizePointerId);
|
|
295
|
+
if (this.dockMode === "floating") {
|
|
296
|
+
this.updateAnchorFromPosition("window");
|
|
297
|
+
this.applyAnchorPosition("window");
|
|
298
|
+
}
|
|
299
|
+
this.persistState();
|
|
300
|
+
this.resetResizeTracking();
|
|
301
|
+
};
|
|
302
|
+
this.handleResizePointerCancel = (event) => {
|
|
303
|
+
if (this.resizePointerId !== event.pointerId) return;
|
|
304
|
+
const target = event.currentTarget;
|
|
305
|
+
if (target?.hasPointerCapture(this.resizePointerId)) target.releasePointerCapture(this.resizePointerId);
|
|
306
|
+
if (this.dockMode === "floating") {
|
|
307
|
+
this.updateAnchorFromPosition("window");
|
|
308
|
+
this.applyAnchorPosition("window");
|
|
309
|
+
}
|
|
310
|
+
this.persistState();
|
|
311
|
+
this.resetResizeTracking();
|
|
312
|
+
};
|
|
313
|
+
this.handleResize = () => {
|
|
314
|
+
this.measureContext("button");
|
|
315
|
+
this.applyAnchorPosition("button");
|
|
316
|
+
this.measureContext("window");
|
|
317
|
+
if (this.hasCustomPosition.window) this.applyAnchorPosition("window");
|
|
318
|
+
else this.centerContext("window");
|
|
319
|
+
this.updateHostTransform();
|
|
320
|
+
};
|
|
321
|
+
this.contextOptions = [{
|
|
322
|
+
key: "all-agents",
|
|
323
|
+
label: "All Agents"
|
|
324
|
+
}];
|
|
325
|
+
this.selectedContext = "all-agents";
|
|
326
|
+
this.expandedRows = /* @__PURE__ */ new Set();
|
|
327
|
+
this.copiedEvents = /* @__PURE__ */ new Set();
|
|
328
|
+
this.expandedTools = /* @__PURE__ */ new Set();
|
|
329
|
+
this.expandedContextItems = /* @__PURE__ */ new Set();
|
|
330
|
+
this.copiedContextItems = /* @__PURE__ */ new Set();
|
|
331
|
+
this.handleClearEvents = () => {
|
|
332
|
+
if (this.selectedContext === "all-agents") {
|
|
333
|
+
this.agentEvents.clear();
|
|
334
|
+
this.flattenedEvents = [];
|
|
335
|
+
} else {
|
|
336
|
+
this.agentEvents.delete(this.selectedContext);
|
|
337
|
+
this.flattenedEvents = this.flattenedEvents.filter((event) => event.agentId !== this.selectedContext);
|
|
338
|
+
}
|
|
339
|
+
this.expandedRows.clear();
|
|
340
|
+
this.copiedEvents.clear();
|
|
341
|
+
this.requestUpdate();
|
|
342
|
+
};
|
|
343
|
+
this.handleGlobalPointerDown = (event) => {
|
|
344
|
+
if (!this.contextMenuOpen) return;
|
|
345
|
+
if (!event.composedPath().some((node) => {
|
|
346
|
+
return node instanceof HTMLElement && node.dataset?.contextDropdownRoot === "true";
|
|
347
|
+
})) {
|
|
348
|
+
this.contextMenuOpen = false;
|
|
349
|
+
this.requestUpdate();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
this.handleDismissAnnouncement = () => {
|
|
353
|
+
this.markAnnouncementSeen();
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
static {
|
|
357
|
+
this.properties = {
|
|
358
|
+
core: { attribute: false },
|
|
359
|
+
autoAttachCore: {
|
|
360
|
+
type: Boolean,
|
|
361
|
+
attribute: "auto-attach-core"
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
get core() {
|
|
366
|
+
return this._core;
|
|
367
|
+
}
|
|
368
|
+
set core(value) {
|
|
369
|
+
const oldValue = this._core;
|
|
370
|
+
if (oldValue === value) return;
|
|
371
|
+
this.detachFromCore();
|
|
372
|
+
this._core = value ?? null;
|
|
373
|
+
this.requestUpdate("core", oldValue);
|
|
374
|
+
if (this._core) this.attachToCore(this._core);
|
|
375
|
+
}
|
|
376
|
+
attachToCore(core) {
|
|
377
|
+
this.runtimeStatus = core.runtimeConnectionStatus;
|
|
378
|
+
this.coreProperties = core.properties;
|
|
379
|
+
this.lastCoreError = null;
|
|
380
|
+
this.coreSubscriber = {
|
|
381
|
+
onRuntimeConnectionStatusChanged: ({ status }) => {
|
|
382
|
+
this.runtimeStatus = status;
|
|
383
|
+
this.requestUpdate();
|
|
384
|
+
},
|
|
385
|
+
onPropertiesChanged: ({ properties }) => {
|
|
386
|
+
this.coreProperties = properties;
|
|
387
|
+
this.requestUpdate();
|
|
388
|
+
},
|
|
389
|
+
onError: ({ code, error }) => {
|
|
390
|
+
this.lastCoreError = {
|
|
391
|
+
code,
|
|
392
|
+
message: error.message
|
|
393
|
+
};
|
|
394
|
+
this.requestUpdate();
|
|
395
|
+
},
|
|
396
|
+
onAgentsChanged: ({ agents }) => {
|
|
397
|
+
this.processAgentsChanged(agents);
|
|
398
|
+
},
|
|
399
|
+
onContextChanged: ({ context }) => {
|
|
400
|
+
this.contextStore = this.normalizeContextStore(context);
|
|
401
|
+
this.requestUpdate();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
this.coreUnsubscribe = core.subscribe(this.coreSubscriber).unsubscribe;
|
|
405
|
+
this.processAgentsChanged(core.agents);
|
|
406
|
+
if (core.context) this.contextStore = this.normalizeContextStore(core.context);
|
|
407
|
+
}
|
|
408
|
+
detachFromCore() {
|
|
409
|
+
if (this.coreUnsubscribe) {
|
|
410
|
+
this.coreUnsubscribe();
|
|
411
|
+
this.coreUnsubscribe = null;
|
|
412
|
+
}
|
|
413
|
+
this.coreSubscriber = null;
|
|
414
|
+
this.runtimeStatus = null;
|
|
415
|
+
this.lastCoreError = null;
|
|
416
|
+
this.coreProperties = {};
|
|
417
|
+
this.cachedTools = [];
|
|
418
|
+
this.toolSignature = "";
|
|
419
|
+
this.teardownAgentSubscriptions();
|
|
420
|
+
}
|
|
421
|
+
teardownAgentSubscriptions() {
|
|
422
|
+
for (const unsubscribe of this.agentSubscriptions.values()) unsubscribe();
|
|
423
|
+
this.agentSubscriptions.clear();
|
|
424
|
+
this.agentEvents.clear();
|
|
425
|
+
this.agentMessages.clear();
|
|
426
|
+
this.agentStates.clear();
|
|
427
|
+
this.flattenedEvents = [];
|
|
428
|
+
this.eventCounter = 0;
|
|
429
|
+
}
|
|
430
|
+
processAgentsChanged(agents) {
|
|
431
|
+
const seenAgentIds = /* @__PURE__ */ new Set();
|
|
432
|
+
for (const agent of Object.values(agents)) {
|
|
433
|
+
if (!agent?.agentId) continue;
|
|
434
|
+
seenAgentIds.add(agent.agentId);
|
|
435
|
+
this.subscribeToAgent(agent);
|
|
436
|
+
}
|
|
437
|
+
for (const agentId of Array.from(this.agentSubscriptions.keys())) if (!seenAgentIds.has(agentId)) {
|
|
438
|
+
this.unsubscribeFromAgent(agentId);
|
|
439
|
+
this.agentEvents.delete(agentId);
|
|
440
|
+
this.agentMessages.delete(agentId);
|
|
441
|
+
this.agentStates.delete(agentId);
|
|
442
|
+
}
|
|
443
|
+
this.updateContextOptions(seenAgentIds);
|
|
444
|
+
this.refreshToolsSnapshot();
|
|
445
|
+
this.requestUpdate();
|
|
446
|
+
}
|
|
447
|
+
refreshToolsSnapshot() {
|
|
448
|
+
if (!this._core) {
|
|
449
|
+
if (this.cachedTools.length > 0) {
|
|
450
|
+
this.cachedTools = [];
|
|
451
|
+
this.toolSignature = "";
|
|
452
|
+
this.requestUpdate();
|
|
453
|
+
}
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const tools = this.extractToolsFromAgents();
|
|
457
|
+
const signature = JSON.stringify(tools.map((tool) => ({
|
|
458
|
+
agentId: tool.agentId,
|
|
459
|
+
name: tool.name,
|
|
460
|
+
type: tool.type,
|
|
461
|
+
hasDescription: Boolean(tool.description),
|
|
462
|
+
hasParameters: Boolean(tool.parameters)
|
|
463
|
+
})));
|
|
464
|
+
if (signature !== this.toolSignature) {
|
|
465
|
+
this.toolSignature = signature;
|
|
466
|
+
this.cachedTools = tools;
|
|
467
|
+
this.requestUpdate();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
tryAutoAttachCore() {
|
|
471
|
+
if (this.attemptedAutoAttach || this._core || !this.autoAttachCore || typeof window === "undefined") return;
|
|
472
|
+
this.attemptedAutoAttach = true;
|
|
473
|
+
const globalWindow = window;
|
|
474
|
+
const foundCore = [
|
|
475
|
+
globalWindow.__COPILOTKIT_CORE__,
|
|
476
|
+
globalWindow.copilotkit?.core,
|
|
477
|
+
globalWindow.copilotkitCore
|
|
478
|
+
].find((candidate) => !!candidate && typeof candidate === "object");
|
|
479
|
+
if (foundCore) this.core = foundCore;
|
|
480
|
+
}
|
|
481
|
+
subscribeToAgent(agent) {
|
|
482
|
+
if (!agent.agentId) return;
|
|
483
|
+
const agentId = agent.agentId;
|
|
484
|
+
this.unsubscribeFromAgent(agentId);
|
|
485
|
+
const { unsubscribe } = agent.subscribe({
|
|
486
|
+
onRunStartedEvent: ({ event }) => {
|
|
487
|
+
this.recordAgentEvent(agentId, "RUN_STARTED", event);
|
|
488
|
+
},
|
|
489
|
+
onRunFinishedEvent: ({ event, result }) => {
|
|
490
|
+
this.recordAgentEvent(agentId, "RUN_FINISHED", {
|
|
491
|
+
event,
|
|
492
|
+
result
|
|
493
|
+
});
|
|
494
|
+
},
|
|
495
|
+
onRunErrorEvent: ({ event }) => {
|
|
496
|
+
this.recordAgentEvent(agentId, "RUN_ERROR", event);
|
|
497
|
+
},
|
|
498
|
+
onTextMessageStartEvent: ({ event }) => {
|
|
499
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_START", event);
|
|
500
|
+
},
|
|
501
|
+
onTextMessageContentEvent: ({ event, textMessageBuffer }) => {
|
|
502
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_CONTENT", {
|
|
503
|
+
event,
|
|
504
|
+
textMessageBuffer
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
onTextMessageEndEvent: ({ event, textMessageBuffer }) => {
|
|
508
|
+
this.recordAgentEvent(agentId, "TEXT_MESSAGE_END", {
|
|
509
|
+
event,
|
|
510
|
+
textMessageBuffer
|
|
511
|
+
});
|
|
512
|
+
},
|
|
513
|
+
onToolCallStartEvent: ({ event }) => {
|
|
514
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_START", event);
|
|
515
|
+
},
|
|
516
|
+
onToolCallArgsEvent: ({ event, toolCallBuffer, toolCallName, partialToolCallArgs }) => {
|
|
517
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_ARGS", {
|
|
518
|
+
event,
|
|
519
|
+
toolCallBuffer,
|
|
520
|
+
toolCallName,
|
|
521
|
+
partialToolCallArgs
|
|
522
|
+
});
|
|
523
|
+
},
|
|
524
|
+
onToolCallEndEvent: ({ event, toolCallArgs, toolCallName }) => {
|
|
525
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_END", {
|
|
526
|
+
event,
|
|
527
|
+
toolCallArgs,
|
|
528
|
+
toolCallName
|
|
529
|
+
});
|
|
530
|
+
},
|
|
531
|
+
onToolCallResultEvent: ({ event }) => {
|
|
532
|
+
this.recordAgentEvent(agentId, "TOOL_CALL_RESULT", event);
|
|
533
|
+
},
|
|
534
|
+
onStateSnapshotEvent: ({ event }) => {
|
|
535
|
+
this.recordAgentEvent(agentId, "STATE_SNAPSHOT", event);
|
|
536
|
+
this.syncAgentState(agent);
|
|
537
|
+
},
|
|
538
|
+
onStateDeltaEvent: ({ event }) => {
|
|
539
|
+
this.recordAgentEvent(agentId, "STATE_DELTA", event);
|
|
540
|
+
this.syncAgentState(agent);
|
|
541
|
+
},
|
|
542
|
+
onMessagesSnapshotEvent: ({ event }) => {
|
|
543
|
+
this.recordAgentEvent(agentId, "MESSAGES_SNAPSHOT", event);
|
|
544
|
+
this.syncAgentMessages(agent);
|
|
545
|
+
},
|
|
546
|
+
onMessagesChanged: () => {
|
|
547
|
+
this.syncAgentMessages(agent);
|
|
548
|
+
},
|
|
549
|
+
onRawEvent: ({ event }) => {
|
|
550
|
+
this.recordAgentEvent(agentId, "RAW_EVENT", event);
|
|
551
|
+
},
|
|
552
|
+
onCustomEvent: ({ event }) => {
|
|
553
|
+
this.recordAgentEvent(agentId, "CUSTOM_EVENT", event);
|
|
554
|
+
},
|
|
555
|
+
onReasoningStartEvent: ({ event }) => {
|
|
556
|
+
this.recordAgentEvent(agentId, "REASONING_START", event);
|
|
557
|
+
},
|
|
558
|
+
onReasoningMessageStartEvent: ({ event }) => {
|
|
559
|
+
this.recordAgentEvent(agentId, "REASONING_MESSAGE_START", event);
|
|
560
|
+
},
|
|
561
|
+
onReasoningMessageContentEvent: ({ event, reasoningMessageBuffer }) => {
|
|
562
|
+
this.recordAgentEvent(agentId, "REASONING_MESSAGE_CONTENT", {
|
|
563
|
+
event,
|
|
564
|
+
reasoningMessageBuffer
|
|
565
|
+
});
|
|
566
|
+
},
|
|
567
|
+
onReasoningMessageEndEvent: ({ event, reasoningMessageBuffer }) => {
|
|
568
|
+
this.recordAgentEvent(agentId, "REASONING_MESSAGE_END", {
|
|
569
|
+
event,
|
|
570
|
+
reasoningMessageBuffer
|
|
571
|
+
});
|
|
572
|
+
},
|
|
573
|
+
onReasoningEndEvent: ({ event }) => {
|
|
574
|
+
this.recordAgentEvent(agentId, "REASONING_END", event);
|
|
575
|
+
},
|
|
576
|
+
onReasoningEncryptedValueEvent: ({ event }) => {
|
|
577
|
+
this.recordAgentEvent(agentId, "REASONING_ENCRYPTED_VALUE", event);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
this.agentSubscriptions.set(agentId, unsubscribe);
|
|
581
|
+
this.syncAgentMessages(agent);
|
|
582
|
+
this.syncAgentState(agent);
|
|
583
|
+
if (!this.agentEvents.has(agentId)) this.agentEvents.set(agentId, []);
|
|
584
|
+
}
|
|
585
|
+
unsubscribeFromAgent(agentId) {
|
|
586
|
+
const unsubscribe = this.agentSubscriptions.get(agentId);
|
|
587
|
+
if (unsubscribe) {
|
|
588
|
+
unsubscribe();
|
|
589
|
+
this.agentSubscriptions.delete(agentId);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
recordAgentEvent(agentId, type, payload) {
|
|
593
|
+
const eventId = `${agentId}:${++this.eventCounter}`;
|
|
594
|
+
const normalizedPayload = this.normalizeEventPayload(type, payload);
|
|
595
|
+
const event = {
|
|
596
|
+
id: eventId,
|
|
597
|
+
agentId,
|
|
598
|
+
type,
|
|
599
|
+
timestamp: Date.now(),
|
|
600
|
+
payload: normalizedPayload
|
|
601
|
+
};
|
|
602
|
+
const nextAgentEvents = [event, ...this.agentEvents.get(agentId) ?? []].slice(0, MAX_AGENT_EVENTS);
|
|
603
|
+
this.agentEvents.set(agentId, nextAgentEvents);
|
|
604
|
+
this.flattenedEvents = [event, ...this.flattenedEvents].slice(0, MAX_TOTAL_EVENTS);
|
|
605
|
+
this.refreshToolsSnapshot();
|
|
606
|
+
this.requestUpdate();
|
|
607
|
+
}
|
|
608
|
+
syncAgentMessages(agent) {
|
|
609
|
+
if (!agent?.agentId) return;
|
|
610
|
+
const messages = this.normalizeAgentMessages(agent.messages);
|
|
611
|
+
if (messages) this.agentMessages.set(agent.agentId, messages);
|
|
612
|
+
else this.agentMessages.delete(agent.agentId);
|
|
613
|
+
this.requestUpdate();
|
|
614
|
+
}
|
|
615
|
+
syncAgentState(agent) {
|
|
616
|
+
if (!agent?.agentId) return;
|
|
617
|
+
const state = agent.state;
|
|
618
|
+
if (state === void 0 || state === null) this.agentStates.delete(agent.agentId);
|
|
619
|
+
else this.agentStates.set(agent.agentId, this.sanitizeForLogging(state));
|
|
620
|
+
this.requestUpdate();
|
|
621
|
+
}
|
|
622
|
+
updateContextOptions(agentIds) {
|
|
623
|
+
const nextOptions = [{
|
|
624
|
+
key: "all-agents",
|
|
625
|
+
label: "All Agents"
|
|
626
|
+
}, ...Array.from(agentIds).sort((a, b) => a.localeCompare(b)).map((id) => ({
|
|
627
|
+
key: id,
|
|
628
|
+
label: id
|
|
629
|
+
}))];
|
|
630
|
+
if (this.contextOptions.length !== nextOptions.length || this.contextOptions.some((option, index) => option.key !== nextOptions[index]?.key)) this.contextOptions = nextOptions;
|
|
631
|
+
const pendingContext = this.pendingSelectedContext;
|
|
632
|
+
if (pendingContext) {
|
|
633
|
+
if (pendingContext === "all-agents" || agentIds.has(pendingContext)) {
|
|
634
|
+
if (this.selectedContext !== pendingContext) {
|
|
635
|
+
this.selectedContext = pendingContext;
|
|
636
|
+
this.expandedRows.clear();
|
|
637
|
+
}
|
|
638
|
+
this.pendingSelectedContext = null;
|
|
639
|
+
} else if (agentIds.size > 0) this.pendingSelectedContext = null;
|
|
640
|
+
}
|
|
641
|
+
if (!nextOptions.some((option) => option.key === this.selectedContext) && this.pendingSelectedContext === null) {
|
|
642
|
+
let nextSelected = "all-agents";
|
|
643
|
+
if (agentIds.has("default")) nextSelected = "default";
|
|
644
|
+
else if (agentIds.size > 0) nextSelected = Array.from(agentIds).sort((a, b) => a.localeCompare(b))[0];
|
|
645
|
+
if (this.selectedContext !== nextSelected) {
|
|
646
|
+
this.selectedContext = nextSelected;
|
|
647
|
+
this.expandedRows.clear();
|
|
648
|
+
this.persistState();
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
getEventsForSelectedContext() {
|
|
653
|
+
if (this.selectedContext === "all-agents") return this.flattenedEvents;
|
|
654
|
+
return this.agentEvents.get(this.selectedContext) ?? [];
|
|
655
|
+
}
|
|
656
|
+
filterEvents(events) {
|
|
657
|
+
const query = this.eventFilterText.trim().toLowerCase();
|
|
658
|
+
return events.filter((event) => {
|
|
659
|
+
if (this.eventTypeFilter !== "all" && event.type !== this.eventTypeFilter) return false;
|
|
660
|
+
if (!query) return true;
|
|
661
|
+
const payloadText = this.stringifyPayload(event.payload, false).toLowerCase();
|
|
662
|
+
return event.type.toLowerCase().includes(query) || event.agentId.toLowerCase().includes(query) || payloadText.includes(query);
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
getLatestStateForAgent(agentId) {
|
|
666
|
+
if (this.agentStates.has(agentId)) {
|
|
667
|
+
const value = this.agentStates.get(agentId);
|
|
668
|
+
return value === void 0 ? null : value;
|
|
669
|
+
}
|
|
670
|
+
const stateEvent = (this.agentEvents.get(agentId) ?? []).find((e) => e.type === "STATE_SNAPSHOT");
|
|
671
|
+
if (!stateEvent) return null;
|
|
672
|
+
return stateEvent.payload;
|
|
673
|
+
}
|
|
674
|
+
getLatestMessagesForAgent(agentId) {
|
|
675
|
+
return this.agentMessages.get(agentId) ?? null;
|
|
676
|
+
}
|
|
677
|
+
getAgentStatus(agentId) {
|
|
678
|
+
const events = this.agentEvents.get(agentId) ?? [];
|
|
679
|
+
if (events.length === 0) return "idle";
|
|
680
|
+
const runEvent = events.find((e) => e.type === "RUN_STARTED" || e.type === "RUN_FINISHED" || e.type === "RUN_ERROR");
|
|
681
|
+
if (!runEvent) return "idle";
|
|
682
|
+
if (runEvent.type === "RUN_ERROR") return "error";
|
|
683
|
+
if (runEvent.type === "RUN_STARTED") return events.find((e) => e.type === "RUN_FINISHED" && e.timestamp > runEvent.timestamp) ? "idle" : "running";
|
|
684
|
+
return "idle";
|
|
685
|
+
}
|
|
686
|
+
getAgentStats(agentId) {
|
|
687
|
+
const events = this.agentEvents.get(agentId) ?? [];
|
|
688
|
+
const messages = this.agentMessages.get(agentId);
|
|
689
|
+
const toolCallCount = messages ? messages.reduce((count, message) => count + (message.toolCalls?.length ?? 0), 0) : events.filter((e) => e.type === "TOOL_CALL_END").length;
|
|
690
|
+
const messageCount = messages?.length ?? 0;
|
|
691
|
+
return {
|
|
692
|
+
totalEvents: events.length,
|
|
693
|
+
lastActivity: events[0]?.timestamp ?? null,
|
|
694
|
+
messages: messageCount,
|
|
695
|
+
toolCalls: toolCallCount,
|
|
696
|
+
errors: events.filter((e) => e.type === "RUN_ERROR").length
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
renderToolCallDetails(toolCalls) {
|
|
700
|
+
if (!Array.isArray(toolCalls) || toolCalls.length === 0) return nothing;
|
|
701
|
+
return html`
|
|
967
702
|
<div class="mt-2 space-y-2">
|
|
968
703
|
${toolCalls.map((call, index) => {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
);
|
|
974
|
-
return html`
|
|
704
|
+
const functionName = call.function?.name ?? call.toolName ?? "Unknown function";
|
|
705
|
+
const callId = typeof call?.id === "string" ? call.id : `tool-call-${index + 1}`;
|
|
706
|
+
const argsString = this.formatToolCallArguments(call.function?.arguments);
|
|
707
|
+
return html`
|
|
975
708
|
<div
|
|
976
709
|
class="rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-700"
|
|
977
710
|
>
|
|
@@ -988,134 +721,94 @@ ${argsString}</pre
|
|
|
988
721
|
>` : nothing}
|
|
989
722
|
</div>
|
|
990
723
|
`;
|
|
991
|
-
|
|
724
|
+
})}
|
|
992
725
|
</div>
|
|
993
726
|
`;
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
}
|
|
1080
|
-
return `${base} bg-gray-100 text-gray-600 border-gray-200`;
|
|
1081
|
-
}
|
|
1082
|
-
stringifyPayload(payload, pretty) {
|
|
1083
|
-
try {
|
|
1084
|
-
if (payload === void 0) {
|
|
1085
|
-
return pretty ? "undefined" : "undefined";
|
|
1086
|
-
}
|
|
1087
|
-
if (typeof payload === "string") {
|
|
1088
|
-
return payload;
|
|
1089
|
-
}
|
|
1090
|
-
return JSON.stringify(payload, null, pretty ? 2 : 0) ?? "";
|
|
1091
|
-
} catch (error) {
|
|
1092
|
-
console.warn("Failed to stringify inspector payload", error);
|
|
1093
|
-
return String(payload);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
extractEventFromPayload(payload) {
|
|
1097
|
-
if (payload && typeof payload === "object" && "event" in payload) {
|
|
1098
|
-
return payload.event;
|
|
1099
|
-
}
|
|
1100
|
-
return payload;
|
|
1101
|
-
}
|
|
1102
|
-
async copyToClipboard(text, eventId) {
|
|
1103
|
-
try {
|
|
1104
|
-
await navigator.clipboard.writeText(text);
|
|
1105
|
-
this.copiedEvents.add(eventId);
|
|
1106
|
-
this.requestUpdate();
|
|
1107
|
-
setTimeout(() => {
|
|
1108
|
-
this.copiedEvents.delete(eventId);
|
|
1109
|
-
this.requestUpdate();
|
|
1110
|
-
}, 2e3);
|
|
1111
|
-
} catch (err) {
|
|
1112
|
-
console.error("Failed to copy to clipboard:", err);
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
static {
|
|
1116
|
-
this.styles = [
|
|
1117
|
-
unsafeCSS(generated_default),
|
|
1118
|
-
css`
|
|
727
|
+
}
|
|
728
|
+
formatToolCallArguments(args) {
|
|
729
|
+
if (args === void 0 || args === null || args === "") return null;
|
|
730
|
+
if (typeof args === "string") try {
|
|
731
|
+
const parsed = JSON.parse(args);
|
|
732
|
+
return JSON.stringify(parsed, null, 2);
|
|
733
|
+
} catch {
|
|
734
|
+
return args;
|
|
735
|
+
}
|
|
736
|
+
if (typeof args === "object") try {
|
|
737
|
+
return JSON.stringify(args, null, 2);
|
|
738
|
+
} catch {
|
|
739
|
+
return String(args);
|
|
740
|
+
}
|
|
741
|
+
return String(args);
|
|
742
|
+
}
|
|
743
|
+
hasRenderableState(state) {
|
|
744
|
+
if (state === null || state === void 0) return false;
|
|
745
|
+
if (Array.isArray(state)) return state.length > 0;
|
|
746
|
+
if (typeof state === "object") return Object.keys(state).length > 0;
|
|
747
|
+
if (typeof state === "string") {
|
|
748
|
+
const trimmed = state.trim();
|
|
749
|
+
return trimmed.length > 0 && trimmed !== "{}";
|
|
750
|
+
}
|
|
751
|
+
return true;
|
|
752
|
+
}
|
|
753
|
+
formatStateForDisplay(state) {
|
|
754
|
+
if (state === null || state === void 0) return "";
|
|
755
|
+
if (typeof state === "string") {
|
|
756
|
+
const trimmed = state.trim();
|
|
757
|
+
if (trimmed.length === 0) return "";
|
|
758
|
+
try {
|
|
759
|
+
const parsed = JSON.parse(trimmed);
|
|
760
|
+
return JSON.stringify(parsed, null, 2);
|
|
761
|
+
} catch {
|
|
762
|
+
return state;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
if (typeof state === "object") try {
|
|
766
|
+
return JSON.stringify(state, null, 2);
|
|
767
|
+
} catch {
|
|
768
|
+
return String(state);
|
|
769
|
+
}
|
|
770
|
+
return String(state);
|
|
771
|
+
}
|
|
772
|
+
getEventBadgeClasses(type) {
|
|
773
|
+
const base = "font-mono text-[10px] font-medium inline-flex items-center rounded-sm px-1.5 py-0.5 border";
|
|
774
|
+
if (type.startsWith("RUN_")) return `${base} bg-blue-50 text-blue-700 border-blue-200`;
|
|
775
|
+
if (type.startsWith("TEXT_MESSAGE")) return `${base} bg-emerald-50 text-emerald-700 border-emerald-200`;
|
|
776
|
+
if (type.startsWith("TOOL_CALL")) return `${base} bg-amber-50 text-amber-700 border-amber-200`;
|
|
777
|
+
if (type.startsWith("REASONING")) return `${base} bg-fuchsia-50 text-fuchsia-700 border-fuchsia-200`;
|
|
778
|
+
if (type.startsWith("STATE")) return `${base} bg-violet-50 text-violet-700 border-violet-200`;
|
|
779
|
+
if (type.startsWith("MESSAGES")) return `${base} bg-sky-50 text-sky-700 border-sky-200`;
|
|
780
|
+
if (type === "RUN_ERROR") return `${base} bg-rose-50 text-rose-700 border-rose-200`;
|
|
781
|
+
return `${base} bg-gray-100 text-gray-600 border-gray-200`;
|
|
782
|
+
}
|
|
783
|
+
stringifyPayload(payload, pretty) {
|
|
784
|
+
try {
|
|
785
|
+
if (payload === void 0) return pretty ? "undefined" : "undefined";
|
|
786
|
+
if (typeof payload === "string") return payload;
|
|
787
|
+
return JSON.stringify(payload, null, pretty ? 2 : 0) ?? "";
|
|
788
|
+
} catch (error) {
|
|
789
|
+
console.warn("Failed to stringify inspector payload", error);
|
|
790
|
+
return String(payload);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
extractEventFromPayload(payload) {
|
|
794
|
+
if (payload && typeof payload === "object" && "event" in payload) return payload.event;
|
|
795
|
+
return payload;
|
|
796
|
+
}
|
|
797
|
+
async copyToClipboard(text, eventId) {
|
|
798
|
+
try {
|
|
799
|
+
await navigator.clipboard.writeText(text);
|
|
800
|
+
this.copiedEvents.add(eventId);
|
|
801
|
+
this.requestUpdate();
|
|
802
|
+
setTimeout(() => {
|
|
803
|
+
this.copiedEvents.delete(eventId);
|
|
804
|
+
this.requestUpdate();
|
|
805
|
+
}, 2e3);
|
|
806
|
+
} catch (err) {
|
|
807
|
+
console.error("Failed to copy to clipboard:", err);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
static {
|
|
811
|
+
this.styles = [unsafeCSS(generated_default), css`
|
|
1119
812
|
:host {
|
|
1120
813
|
position: fixed;
|
|
1121
814
|
top: 0;
|
|
@@ -1316,101 +1009,94 @@ ${argsString}</pre
|
|
|
1316
1009
|
color: #0f766e;
|
|
1317
1010
|
text-decoration: underline;
|
|
1318
1011
|
}
|
|
1319
|
-
`
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
}
|
|
1375
|
-
render() {
|
|
1376
|
-
return this.isOpen ? this.renderWindow() : this.renderButton();
|
|
1377
|
-
}
|
|
1378
|
-
renderButton() {
|
|
1379
|
-
const buttonClasses = [
|
|
1380
|
-
"console-button",
|
|
1381
|
-
"group",
|
|
1382
|
-
"relative",
|
|
1383
|
-
"pointer-events-auto",
|
|
1384
|
-
"inline-flex",
|
|
1385
|
-
"h-12",
|
|
1386
|
-
"w-12",
|
|
1387
|
-
"items-center",
|
|
1388
|
-
"justify-center",
|
|
1389
|
-
"rounded-full",
|
|
1390
|
-
"border",
|
|
1391
|
-
"border-white/20",
|
|
1392
|
-
"bg-slate-950/95",
|
|
1393
|
-
"text-xs",
|
|
1394
|
-
"font-medium",
|
|
1395
|
-
"text-white",
|
|
1396
|
-
"ring-1",
|
|
1397
|
-
"ring-white/10",
|
|
1398
|
-
"backdrop-blur-md",
|
|
1399
|
-
"transition",
|
|
1400
|
-
"hover:border-white/30",
|
|
1401
|
-
"hover:bg-slate-900/95",
|
|
1402
|
-
"hover:scale-105",
|
|
1403
|
-
"focus-visible:outline",
|
|
1404
|
-
"focus-visible:outline-2",
|
|
1405
|
-
"focus-visible:outline-offset-2",
|
|
1406
|
-
"focus-visible:outline-rose-500",
|
|
1407
|
-
"touch-none",
|
|
1408
|
-
"select-none",
|
|
1409
|
-
this.isDragging ? "cursor-grabbing" : "cursor-grab"
|
|
1410
|
-
].join(" ");
|
|
1411
|
-
return html`
|
|
1012
|
+
`];
|
|
1013
|
+
}
|
|
1014
|
+
connectedCallback() {
|
|
1015
|
+
super.connectedCallback();
|
|
1016
|
+
if (typeof window !== "undefined") {
|
|
1017
|
+
window.addEventListener("resize", this.handleResize);
|
|
1018
|
+
window.addEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
1019
|
+
this.hydrateStateFromStorageEarly();
|
|
1020
|
+
this.tryAutoAttachCore();
|
|
1021
|
+
this.ensureAnnouncementLoading();
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
disconnectedCallback() {
|
|
1025
|
+
super.disconnectedCallback();
|
|
1026
|
+
if (typeof window !== "undefined") {
|
|
1027
|
+
window.removeEventListener("resize", this.handleResize);
|
|
1028
|
+
window.removeEventListener("pointerdown", this.handleGlobalPointerDown);
|
|
1029
|
+
}
|
|
1030
|
+
this.removeDockStyles();
|
|
1031
|
+
this.detachFromCore();
|
|
1032
|
+
}
|
|
1033
|
+
firstUpdated() {
|
|
1034
|
+
if (typeof window === "undefined") return;
|
|
1035
|
+
if (!this._core) this.tryAutoAttachCore();
|
|
1036
|
+
this.measureContext("button");
|
|
1037
|
+
this.measureContext("window");
|
|
1038
|
+
this.contextState.button.anchor = {
|
|
1039
|
+
horizontal: "right",
|
|
1040
|
+
vertical: "top"
|
|
1041
|
+
};
|
|
1042
|
+
this.contextState.button.anchorOffset = {
|
|
1043
|
+
x: EDGE_MARGIN,
|
|
1044
|
+
y: EDGE_MARGIN
|
|
1045
|
+
};
|
|
1046
|
+
this.contextState.window.anchor = {
|
|
1047
|
+
horizontal: "right",
|
|
1048
|
+
vertical: "top"
|
|
1049
|
+
};
|
|
1050
|
+
this.contextState.window.anchorOffset = {
|
|
1051
|
+
x: EDGE_MARGIN,
|
|
1052
|
+
y: EDGE_MARGIN
|
|
1053
|
+
};
|
|
1054
|
+
this.hydrateStateFromStorage();
|
|
1055
|
+
if (this.isOpen && this.dockMode !== "floating") this.applyDockStyles(true);
|
|
1056
|
+
this.applyAnchorPosition("button");
|
|
1057
|
+
if (this.dockMode === "floating") if (this.hasCustomPosition.window) this.applyAnchorPosition("window");
|
|
1058
|
+
else this.centerContext("window");
|
|
1059
|
+
this.ensureAnnouncementLoading();
|
|
1060
|
+
this.updateHostTransform(this.isOpen ? "window" : "button");
|
|
1061
|
+
}
|
|
1062
|
+
render() {
|
|
1063
|
+
return this.isOpen ? this.renderWindow() : this.renderButton();
|
|
1064
|
+
}
|
|
1065
|
+
renderButton() {
|
|
1066
|
+
return html`
|
|
1412
1067
|
<button
|
|
1413
|
-
class=${
|
|
1068
|
+
class=${[
|
|
1069
|
+
"console-button",
|
|
1070
|
+
"group",
|
|
1071
|
+
"relative",
|
|
1072
|
+
"pointer-events-auto",
|
|
1073
|
+
"inline-flex",
|
|
1074
|
+
"h-12",
|
|
1075
|
+
"w-12",
|
|
1076
|
+
"items-center",
|
|
1077
|
+
"justify-center",
|
|
1078
|
+
"rounded-full",
|
|
1079
|
+
"border",
|
|
1080
|
+
"border-white/20",
|
|
1081
|
+
"bg-slate-950/95",
|
|
1082
|
+
"text-xs",
|
|
1083
|
+
"font-medium",
|
|
1084
|
+
"text-white",
|
|
1085
|
+
"ring-1",
|
|
1086
|
+
"ring-white/10",
|
|
1087
|
+
"backdrop-blur-md",
|
|
1088
|
+
"transition",
|
|
1089
|
+
"hover:border-white/30",
|
|
1090
|
+
"hover:bg-slate-900/95",
|
|
1091
|
+
"hover:scale-105",
|
|
1092
|
+
"focus-visible:outline",
|
|
1093
|
+
"focus-visible:outline-2",
|
|
1094
|
+
"focus-visible:outline-offset-2",
|
|
1095
|
+
"focus-visible:outline-rose-500",
|
|
1096
|
+
"touch-none",
|
|
1097
|
+
"select-none",
|
|
1098
|
+
this.isDragging ? "cursor-grabbing" : "cursor-grab"
|
|
1099
|
+
].join(" ")}
|
|
1414
1100
|
type="button"
|
|
1415
1101
|
aria-label="Web Inspector"
|
|
1416
1102
|
data-drag-context="button"
|
|
@@ -1430,21 +1116,21 @@ ${argsString}</pre
|
|
|
1430
1116
|
/>
|
|
1431
1117
|
</button>
|
|
1432
1118
|
`;
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1119
|
+
}
|
|
1120
|
+
renderWindow() {
|
|
1121
|
+
const windowState = this.contextState.window;
|
|
1122
|
+
const isDocked = this.dockMode !== "floating";
|
|
1123
|
+
const isTransitioning = this.hasAttribute("data-transitioning");
|
|
1124
|
+
const windowStyles = isDocked ? this.getDockedWindowStyles() : {
|
|
1125
|
+
width: `${Math.round(windowState.size.width)}px`,
|
|
1126
|
+
height: `${Math.round(windowState.size.height)}px`,
|
|
1127
|
+
minWidth: `${MIN_WINDOW_WIDTH}px`,
|
|
1128
|
+
minHeight: `${MIN_WINDOW_HEIGHT}px`
|
|
1129
|
+
};
|
|
1130
|
+
const hasContextDropdown = this.contextOptions.length > 0;
|
|
1131
|
+
const contextDropdown = hasContextDropdown ? this.renderContextDropdown() : nothing;
|
|
1132
|
+
const coreStatus = this.getCoreStatusSummary();
|
|
1133
|
+
const agentSelector = hasContextDropdown ? contextDropdown : html`
|
|
1448
1134
|
<div
|
|
1449
1135
|
class="flex items-center gap-2 rounded-md border border-dashed border-gray-200 px-2 py-1 text-xs text-gray-400"
|
|
1450
1136
|
>
|
|
@@ -1452,7 +1138,7 @@ ${argsString}</pre
|
|
|
1452
1138
|
<span class="truncate">No agents available</span>
|
|
1453
1139
|
</div>
|
|
1454
1140
|
`;
|
|
1455
|
-
|
|
1141
|
+
return html`
|
|
1456
1142
|
<section
|
|
1457
1143
|
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"
|
|
1458
1144
|
style=${styleMap(windowStyles)}
|
|
@@ -1510,15 +1196,11 @@ ${argsString}</pre
|
|
|
1510
1196
|
class="flex flex-wrap items-center gap-2 border-t border-gray-100 px-3 py-2 text-xs"
|
|
1511
1197
|
>
|
|
1512
1198
|
${this.menuItems.map(({ key, label, icon }) => {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
"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",
|
|
1516
|
-
isSelected ? "bg-gray-900 text-white shadow-sm" : "text-gray-600 hover:bg-gray-100 hover:text-gray-900"
|
|
1517
|
-
].join(" ");
|
|
1518
|
-
return html`
|
|
1199
|
+
const isSelected = this.selectedMenu === key;
|
|
1200
|
+
return html`
|
|
1519
1201
|
<button
|
|
1520
1202
|
type="button"
|
|
1521
|
-
class=${
|
|
1203
|
+
class=${["inline-flex items-center gap-2 rounded-md px-3 py-2 transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-300", isSelected ? "bg-gray-900 text-white shadow-sm" : "text-gray-600 hover:bg-gray-100 hover:text-gray-900"].join(" ")}
|
|
1522
1204
|
aria-pressed=${isSelected}
|
|
1523
1205
|
@click=${() => this.handleMenuSelect(key)}
|
|
1524
1206
|
>
|
|
@@ -1530,7 +1212,7 @@ ${argsString}</pre
|
|
|
1530
1212
|
<span>${label}</span>
|
|
1531
1213
|
</button>
|
|
1532
1214
|
`;
|
|
1533
|
-
|
|
1215
|
+
})}
|
|
1534
1216
|
</div>
|
|
1535
1217
|
</div>
|
|
1536
1218
|
<div class="flex flex-1 flex-col overflow-hidden">
|
|
@@ -1580,396 +1262,275 @@ ${argsString}</pre
|
|
|
1580
1262
|
</div>
|
|
1581
1263
|
</section>
|
|
1582
1264
|
`;
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
setDragging(value) {
|
|
1853
|
-
if (this.isDragging !== value) {
|
|
1854
|
-
this.isDragging = value;
|
|
1855
|
-
this.requestUpdate();
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
updateAnchorFromPosition(context) {
|
|
1859
|
-
if (typeof window === "undefined") {
|
|
1860
|
-
return;
|
|
1861
|
-
}
|
|
1862
|
-
const viewport = this.getViewportSize();
|
|
1863
|
-
updateAnchorFromPosition(
|
|
1864
|
-
this.contextState[context],
|
|
1865
|
-
viewport,
|
|
1866
|
-
EDGE_MARGIN
|
|
1867
|
-
);
|
|
1868
|
-
}
|
|
1869
|
-
snapButtonToCorner() {
|
|
1870
|
-
if (typeof window === "undefined") {
|
|
1871
|
-
return;
|
|
1872
|
-
}
|
|
1873
|
-
const viewport = this.getViewportSize();
|
|
1874
|
-
const state = this.contextState.button;
|
|
1875
|
-
const centerX = state.position.x + state.size.width / 2;
|
|
1876
|
-
const centerY = state.position.y + state.size.height / 2;
|
|
1877
|
-
const horizontal = centerX < viewport.width / 2 ? "left" : "right";
|
|
1878
|
-
const vertical = centerY < viewport.height / 2 ? "top" : "bottom";
|
|
1879
|
-
state.anchor = { horizontal, vertical };
|
|
1880
|
-
state.anchorOffset = { x: EDGE_MARGIN, y: EDGE_MARGIN };
|
|
1881
|
-
this.startHostTransition();
|
|
1882
|
-
this.applyAnchorPosition("button");
|
|
1883
|
-
}
|
|
1884
|
-
applyAnchorPosition(context) {
|
|
1885
|
-
if (typeof window === "undefined") {
|
|
1886
|
-
return;
|
|
1887
|
-
}
|
|
1888
|
-
const viewport = this.getViewportSize();
|
|
1889
|
-
applyAnchorPosition(
|
|
1890
|
-
this.contextState[context],
|
|
1891
|
-
viewport,
|
|
1892
|
-
EDGE_MARGIN
|
|
1893
|
-
);
|
|
1894
|
-
this.updateHostTransform(context);
|
|
1895
|
-
this.persistState();
|
|
1896
|
-
}
|
|
1897
|
-
resetResizeTracking() {
|
|
1898
|
-
this.resizePointerId = null;
|
|
1899
|
-
this.resizeStart = null;
|
|
1900
|
-
this.resizeInitialSize = null;
|
|
1901
|
-
this.isResizing = false;
|
|
1902
|
-
}
|
|
1903
|
-
resetPointerTracking() {
|
|
1904
|
-
this.pointerId = null;
|
|
1905
|
-
this.dragStart = null;
|
|
1906
|
-
this.pointerContext = null;
|
|
1907
|
-
this.setDragging(false);
|
|
1908
|
-
this.draggedDuringInteraction = false;
|
|
1909
|
-
}
|
|
1910
|
-
openInspector() {
|
|
1911
|
-
if (this.isOpen) {
|
|
1912
|
-
return;
|
|
1913
|
-
}
|
|
1914
|
-
this.showAnnouncementPreview = false;
|
|
1915
|
-
this.ensureAnnouncementLoading();
|
|
1916
|
-
this.isOpen = true;
|
|
1917
|
-
this.persistState();
|
|
1918
|
-
if (this.dockMode !== "floating") {
|
|
1919
|
-
this.applyDockStyles();
|
|
1920
|
-
}
|
|
1921
|
-
this.ensureWindowPlacement();
|
|
1922
|
-
this.requestUpdate();
|
|
1923
|
-
void this.updateComplete.then(() => {
|
|
1924
|
-
this.measureContext("window");
|
|
1925
|
-
if (this.dockMode === "floating") {
|
|
1926
|
-
if (this.hasCustomPosition.window) {
|
|
1927
|
-
this.applyAnchorPosition("window");
|
|
1928
|
-
} else {
|
|
1929
|
-
this.centerContext("window");
|
|
1930
|
-
}
|
|
1931
|
-
} else {
|
|
1932
|
-
this.updateHostTransform("window");
|
|
1933
|
-
}
|
|
1934
|
-
});
|
|
1935
|
-
}
|
|
1936
|
-
closeInspector() {
|
|
1937
|
-
if (!this.isOpen) {
|
|
1938
|
-
return;
|
|
1939
|
-
}
|
|
1940
|
-
this.isOpen = false;
|
|
1941
|
-
if (this.dockMode !== "floating") {
|
|
1942
|
-
this.removeDockStyles();
|
|
1943
|
-
}
|
|
1944
|
-
this.persistState();
|
|
1945
|
-
this.updateHostTransform("button");
|
|
1946
|
-
this.requestUpdate();
|
|
1947
|
-
void this.updateComplete.then(() => {
|
|
1948
|
-
this.measureContext("button");
|
|
1949
|
-
this.applyAnchorPosition("button");
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
renderIcon(name) {
|
|
1953
|
-
const iconNode = icons[name];
|
|
1954
|
-
if (!iconNode) {
|
|
1955
|
-
return nothing;
|
|
1956
|
-
}
|
|
1957
|
-
const svgAttrs = {
|
|
1958
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1959
|
-
viewBox: "0 0 24 24",
|
|
1960
|
-
fill: "none",
|
|
1961
|
-
stroke: "currentColor",
|
|
1962
|
-
"stroke-width": "1.5",
|
|
1963
|
-
"stroke-linecap": "round",
|
|
1964
|
-
"stroke-linejoin": "round",
|
|
1965
|
-
class: "h-3.5 w-3.5"
|
|
1966
|
-
};
|
|
1967
|
-
const svgMarkup = `<svg ${this.serializeAttributes(svgAttrs)}>${iconNode.map(([tag, attrs]) => `<${tag} ${this.serializeAttributes(attrs)} />`).join("")}</svg>`;
|
|
1968
|
-
return unsafeHTML(svgMarkup);
|
|
1969
|
-
}
|
|
1970
|
-
renderDockControls() {
|
|
1971
|
-
if (this.dockMode === "floating") {
|
|
1972
|
-
return html`
|
|
1265
|
+
}
|
|
1266
|
+
hydrateStateFromStorageEarly() {
|
|
1267
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
1268
|
+
const persisted = loadInspectorState(INSPECTOR_STORAGE_KEY);
|
|
1269
|
+
if (!persisted) return;
|
|
1270
|
+
if (typeof persisted.isOpen === "boolean") this.isOpen = persisted.isOpen;
|
|
1271
|
+
if (isValidDockMode(persisted.dockMode)) this.dockMode = persisted.dockMode;
|
|
1272
|
+
if (typeof persisted.selectedMenu === "string") {
|
|
1273
|
+
const validMenu = this.menuItems.find((item) => item.key === persisted.selectedMenu);
|
|
1274
|
+
if (validMenu) this.selectedMenu = validMenu.key;
|
|
1275
|
+
}
|
|
1276
|
+
if (typeof persisted.selectedContext === "string") {
|
|
1277
|
+
this.selectedContext = persisted.selectedContext;
|
|
1278
|
+
this.pendingSelectedContext = persisted.selectedContext;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
hydrateStateFromStorage() {
|
|
1282
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
1283
|
+
const persisted = loadInspectorState(INSPECTOR_STORAGE_KEY);
|
|
1284
|
+
if (!persisted) return;
|
|
1285
|
+
const persistedButton = persisted.button;
|
|
1286
|
+
if (persistedButton) {
|
|
1287
|
+
if (isValidAnchor(persistedButton.anchor)) this.contextState.button.anchor = persistedButton.anchor;
|
|
1288
|
+
if (isValidPosition(persistedButton.anchorOffset)) this.contextState.button.anchorOffset = persistedButton.anchorOffset;
|
|
1289
|
+
if (typeof persistedButton.hasCustomPosition === "boolean") this.hasCustomPosition.button = persistedButton.hasCustomPosition;
|
|
1290
|
+
}
|
|
1291
|
+
const persistedWindow = persisted.window;
|
|
1292
|
+
if (persistedWindow) {
|
|
1293
|
+
if (isValidAnchor(persistedWindow.anchor)) this.contextState.window.anchor = persistedWindow.anchor;
|
|
1294
|
+
if (isValidPosition(persistedWindow.anchorOffset)) this.contextState.window.anchorOffset = persistedWindow.anchorOffset;
|
|
1295
|
+
if (isValidSize(persistedWindow.size)) this.contextState.window.size = this.clampWindowSize(persistedWindow.size);
|
|
1296
|
+
if (typeof persistedWindow.hasCustomPosition === "boolean") this.hasCustomPosition.window = persistedWindow.hasCustomPosition;
|
|
1297
|
+
}
|
|
1298
|
+
if (typeof persisted.selectedContext === "string") {
|
|
1299
|
+
this.selectedContext = persisted.selectedContext;
|
|
1300
|
+
this.pendingSelectedContext = persisted.selectedContext;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
get activeContext() {
|
|
1304
|
+
return this.isOpen ? "window" : "button";
|
|
1305
|
+
}
|
|
1306
|
+
measureContext(context) {
|
|
1307
|
+
const selector = context === "window" ? ".inspector-window" : ".console-button";
|
|
1308
|
+
const element = this.renderRoot?.querySelector(selector);
|
|
1309
|
+
if (!element) return;
|
|
1310
|
+
const fallback = context === "window" ? DEFAULT_WINDOW_SIZE : DEFAULT_BUTTON_SIZE;
|
|
1311
|
+
updateSizeFromElement(this.contextState[context], element, fallback);
|
|
1312
|
+
}
|
|
1313
|
+
centerContext(context) {
|
|
1314
|
+
if (typeof window === "undefined") return;
|
|
1315
|
+
const viewport = this.getViewportSize();
|
|
1316
|
+
centerContext(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1317
|
+
if (context === this.activeContext) this.updateHostTransform(context);
|
|
1318
|
+
this.hasCustomPosition[context] = false;
|
|
1319
|
+
this.persistState();
|
|
1320
|
+
}
|
|
1321
|
+
ensureWindowPlacement() {
|
|
1322
|
+
if (typeof window === "undefined") return;
|
|
1323
|
+
if (!this.hasCustomPosition.window) {
|
|
1324
|
+
this.centerContext("window");
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const viewport = this.getViewportSize();
|
|
1328
|
+
keepPositionWithinViewport(this.contextState.window, viewport, EDGE_MARGIN);
|
|
1329
|
+
updateAnchorFromPosition(this.contextState.window, viewport, EDGE_MARGIN);
|
|
1330
|
+
this.updateHostTransform("window");
|
|
1331
|
+
this.persistState();
|
|
1332
|
+
}
|
|
1333
|
+
constrainToViewport(position, context) {
|
|
1334
|
+
if (typeof window === "undefined") return position;
|
|
1335
|
+
const viewport = this.getViewportSize();
|
|
1336
|
+
return constrainToViewport(this.contextState[context], position, viewport, EDGE_MARGIN);
|
|
1337
|
+
}
|
|
1338
|
+
keepPositionWithinViewport(context) {
|
|
1339
|
+
if (typeof window === "undefined") return;
|
|
1340
|
+
const viewport = this.getViewportSize();
|
|
1341
|
+
keepPositionWithinViewport(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1342
|
+
}
|
|
1343
|
+
getViewportSize() {
|
|
1344
|
+
if (typeof window === "undefined") return { ...DEFAULT_WINDOW_SIZE };
|
|
1345
|
+
return {
|
|
1346
|
+
width: window.innerWidth,
|
|
1347
|
+
height: window.innerHeight
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
persistState() {
|
|
1351
|
+
const state = {
|
|
1352
|
+
button: {
|
|
1353
|
+
anchor: this.contextState.button.anchor,
|
|
1354
|
+
anchorOffset: this.contextState.button.anchorOffset,
|
|
1355
|
+
hasCustomPosition: this.hasCustomPosition.button
|
|
1356
|
+
},
|
|
1357
|
+
window: {
|
|
1358
|
+
anchor: this.contextState.window.anchor,
|
|
1359
|
+
anchorOffset: this.contextState.window.anchorOffset,
|
|
1360
|
+
size: {
|
|
1361
|
+
width: Math.round(this.contextState.window.size.width),
|
|
1362
|
+
height: Math.round(this.contextState.window.size.height)
|
|
1363
|
+
},
|
|
1364
|
+
hasCustomPosition: this.hasCustomPosition.window
|
|
1365
|
+
},
|
|
1366
|
+
isOpen: this.isOpen,
|
|
1367
|
+
dockMode: this.dockMode,
|
|
1368
|
+
selectedMenu: this.selectedMenu,
|
|
1369
|
+
selectedContext: this.selectedContext
|
|
1370
|
+
};
|
|
1371
|
+
saveInspectorState(INSPECTOR_STORAGE_KEY, state);
|
|
1372
|
+
this.pendingSelectedContext = state.selectedContext ?? null;
|
|
1373
|
+
}
|
|
1374
|
+
clampWindowSize(size) {
|
|
1375
|
+
const minWidth = this.dockMode === "docked-left" ? MIN_WINDOW_WIDTH_DOCKED_LEFT : MIN_WINDOW_WIDTH;
|
|
1376
|
+
if (typeof window === "undefined") return {
|
|
1377
|
+
width: Math.max(minWidth, size.width),
|
|
1378
|
+
height: Math.max(MIN_WINDOW_HEIGHT, size.height)
|
|
1379
|
+
};
|
|
1380
|
+
return clampSize(size, this.getViewportSize(), EDGE_MARGIN, minWidth, MIN_WINDOW_HEIGHT);
|
|
1381
|
+
}
|
|
1382
|
+
setDockMode(mode) {
|
|
1383
|
+
if (this.dockMode === mode) return;
|
|
1384
|
+
this.startHostTransition();
|
|
1385
|
+
this.removeDockStyles();
|
|
1386
|
+
this.dockMode = mode;
|
|
1387
|
+
if (mode !== "floating") {
|
|
1388
|
+
if (mode === "docked-left") this.contextState.window.size.width = DOCKED_LEFT_WIDTH;
|
|
1389
|
+
this.applyDockStyles();
|
|
1390
|
+
} else {
|
|
1391
|
+
this.contextState.window.size = { ...DEFAULT_WINDOW_SIZE };
|
|
1392
|
+
this.centerContext("window");
|
|
1393
|
+
}
|
|
1394
|
+
this.persistState();
|
|
1395
|
+
this.requestUpdate();
|
|
1396
|
+
this.updateHostTransform("window");
|
|
1397
|
+
}
|
|
1398
|
+
startHostTransition(duration = 300) {
|
|
1399
|
+
this.setAttribute("data-transitioning", "true");
|
|
1400
|
+
if (this.transitionTimeoutId !== null) clearTimeout(this.transitionTimeoutId);
|
|
1401
|
+
this.transitionTimeoutId = setTimeout(() => {
|
|
1402
|
+
this.removeAttribute("data-transitioning");
|
|
1403
|
+
this.transitionTimeoutId = null;
|
|
1404
|
+
}, duration);
|
|
1405
|
+
}
|
|
1406
|
+
applyDockStyles(skipTransition = false) {
|
|
1407
|
+
if (typeof document === "undefined" || !document.body) return;
|
|
1408
|
+
const computedStyle = window.getComputedStyle(document.body);
|
|
1409
|
+
this.previousBodyMargins = {
|
|
1410
|
+
left: computedStyle.marginLeft,
|
|
1411
|
+
bottom: computedStyle.marginBottom
|
|
1412
|
+
};
|
|
1413
|
+
if (!this.isResizing && !skipTransition) document.body.style.transition = "margin 300ms ease";
|
|
1414
|
+
if (this.dockMode === "docked-left") document.body.style.marginLeft = `${this.contextState.window.size.width}px`;
|
|
1415
|
+
if (!this.isResizing && !skipTransition) setTimeout(() => {
|
|
1416
|
+
if (document.body) document.body.style.transition = "";
|
|
1417
|
+
}, 300);
|
|
1418
|
+
}
|
|
1419
|
+
removeDockStyles() {
|
|
1420
|
+
if (typeof document === "undefined" || !document.body) return;
|
|
1421
|
+
if (!this.isResizing) document.body.style.transition = "margin 300ms ease";
|
|
1422
|
+
if (this.previousBodyMargins) {
|
|
1423
|
+
document.body.style.marginLeft = this.previousBodyMargins.left;
|
|
1424
|
+
document.body.style.marginBottom = this.previousBodyMargins.bottom;
|
|
1425
|
+
this.previousBodyMargins = null;
|
|
1426
|
+
} else {
|
|
1427
|
+
document.body.style.marginLeft = "";
|
|
1428
|
+
document.body.style.marginBottom = "";
|
|
1429
|
+
}
|
|
1430
|
+
setTimeout(() => {
|
|
1431
|
+
if (document.body) document.body.style.transition = "";
|
|
1432
|
+
}, 300);
|
|
1433
|
+
}
|
|
1434
|
+
updateHostTransform(context = this.activeContext) {
|
|
1435
|
+
if (context !== this.activeContext) return;
|
|
1436
|
+
if (this.isOpen && this.dockMode === "docked-left") this.style.transform = `translate3d(0, 0, 0)`;
|
|
1437
|
+
else {
|
|
1438
|
+
const { position } = this.contextState[context];
|
|
1439
|
+
this.style.transform = `translate3d(${position.x}px, ${position.y}px, 0)`;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
setDragging(value) {
|
|
1443
|
+
if (this.isDragging !== value) {
|
|
1444
|
+
this.isDragging = value;
|
|
1445
|
+
this.requestUpdate();
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
updateAnchorFromPosition(context) {
|
|
1449
|
+
if (typeof window === "undefined") return;
|
|
1450
|
+
const viewport = this.getViewportSize();
|
|
1451
|
+
updateAnchorFromPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1452
|
+
}
|
|
1453
|
+
snapButtonToCorner() {
|
|
1454
|
+
if (typeof window === "undefined") return;
|
|
1455
|
+
const viewport = this.getViewportSize();
|
|
1456
|
+
const state = this.contextState.button;
|
|
1457
|
+
const centerX = state.position.x + state.size.width / 2;
|
|
1458
|
+
const centerY = state.position.y + state.size.height / 2;
|
|
1459
|
+
state.anchor = {
|
|
1460
|
+
horizontal: centerX < viewport.width / 2 ? "left" : "right",
|
|
1461
|
+
vertical: centerY < viewport.height / 2 ? "top" : "bottom"
|
|
1462
|
+
};
|
|
1463
|
+
state.anchorOffset = {
|
|
1464
|
+
x: EDGE_MARGIN,
|
|
1465
|
+
y: EDGE_MARGIN
|
|
1466
|
+
};
|
|
1467
|
+
this.startHostTransition();
|
|
1468
|
+
this.applyAnchorPosition("button");
|
|
1469
|
+
}
|
|
1470
|
+
applyAnchorPosition(context) {
|
|
1471
|
+
if (typeof window === "undefined") return;
|
|
1472
|
+
const viewport = this.getViewportSize();
|
|
1473
|
+
applyAnchorPosition(this.contextState[context], viewport, EDGE_MARGIN);
|
|
1474
|
+
this.updateHostTransform(context);
|
|
1475
|
+
this.persistState();
|
|
1476
|
+
}
|
|
1477
|
+
resetResizeTracking() {
|
|
1478
|
+
this.resizePointerId = null;
|
|
1479
|
+
this.resizeStart = null;
|
|
1480
|
+
this.resizeInitialSize = null;
|
|
1481
|
+
this.isResizing = false;
|
|
1482
|
+
}
|
|
1483
|
+
resetPointerTracking() {
|
|
1484
|
+
this.pointerId = null;
|
|
1485
|
+
this.dragStart = null;
|
|
1486
|
+
this.pointerContext = null;
|
|
1487
|
+
this.setDragging(false);
|
|
1488
|
+
this.draggedDuringInteraction = false;
|
|
1489
|
+
}
|
|
1490
|
+
openInspector() {
|
|
1491
|
+
if (this.isOpen) return;
|
|
1492
|
+
this.showAnnouncementPreview = false;
|
|
1493
|
+
this.ensureAnnouncementLoading();
|
|
1494
|
+
this.isOpen = true;
|
|
1495
|
+
this.persistState();
|
|
1496
|
+
if (this.dockMode !== "floating") this.applyDockStyles();
|
|
1497
|
+
this.ensureWindowPlacement();
|
|
1498
|
+
this.requestUpdate();
|
|
1499
|
+
this.updateComplete.then(() => {
|
|
1500
|
+
this.measureContext("window");
|
|
1501
|
+
if (this.dockMode === "floating") if (this.hasCustomPosition.window) this.applyAnchorPosition("window");
|
|
1502
|
+
else this.centerContext("window");
|
|
1503
|
+
else this.updateHostTransform("window");
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
closeInspector() {
|
|
1507
|
+
if (!this.isOpen) return;
|
|
1508
|
+
this.isOpen = false;
|
|
1509
|
+
if (this.dockMode !== "floating") this.removeDockStyles();
|
|
1510
|
+
this.persistState();
|
|
1511
|
+
this.updateHostTransform("button");
|
|
1512
|
+
this.requestUpdate();
|
|
1513
|
+
this.updateComplete.then(() => {
|
|
1514
|
+
this.measureContext("button");
|
|
1515
|
+
this.applyAnchorPosition("button");
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
renderIcon(name) {
|
|
1519
|
+
const iconNode = icons[name];
|
|
1520
|
+
if (!iconNode) return nothing;
|
|
1521
|
+
return unsafeHTML(`<svg ${this.serializeAttributes({
|
|
1522
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1523
|
+
viewBox: "0 0 24 24",
|
|
1524
|
+
fill: "none",
|
|
1525
|
+
stroke: "currentColor",
|
|
1526
|
+
"stroke-width": "1.5",
|
|
1527
|
+
"stroke-linecap": "round",
|
|
1528
|
+
"stroke-linejoin": "round",
|
|
1529
|
+
class: "h-3.5 w-3.5"
|
|
1530
|
+
})}>${iconNode.map(([tag, attrs]) => `<${tag} ${this.serializeAttributes(attrs)} />`).join("")}</svg>`);
|
|
1531
|
+
}
|
|
1532
|
+
renderDockControls() {
|
|
1533
|
+
if (this.dockMode === "floating") return html`
|
|
1973
1534
|
<button
|
|
1974
1535
|
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"
|
|
1975
1536
|
type="button"
|
|
@@ -1980,8 +1541,7 @@ ${argsString}</pre
|
|
|
1980
1541
|
${this.renderIcon("PanelLeft")}
|
|
1981
1542
|
</button>
|
|
1982
1543
|
`;
|
|
1983
|
-
|
|
1984
|
-
return html`
|
|
1544
|
+
else return html`
|
|
1985
1545
|
<button
|
|
1986
1546
|
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"
|
|
1987
1547
|
type="button"
|
|
@@ -1992,184 +1552,132 @@ ${argsString}</pre
|
|
|
1992
1552
|
${this.renderIcon("Maximize2")}
|
|
1993
1553
|
</button>
|
|
1994
1554
|
`;
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
}
|
|
2122
|
-
return normalized;
|
|
2123
|
-
}).filter((call) => Boolean(call));
|
|
2124
|
-
}
|
|
2125
|
-
normalizeAgentMessage(message) {
|
|
2126
|
-
if (!message || typeof message !== "object") {
|
|
2127
|
-
return null;
|
|
2128
|
-
}
|
|
2129
|
-
const raw = message;
|
|
2130
|
-
const role = typeof raw.role === "string" ? raw.role : "unknown";
|
|
2131
|
-
const contentText = this.normalizeMessageContent(raw.content);
|
|
2132
|
-
const toolCalls = this.normalizeToolCalls(raw.toolCalls);
|
|
2133
|
-
return {
|
|
2134
|
-
id: typeof raw.id === "string" ? raw.id : void 0,
|
|
2135
|
-
role,
|
|
2136
|
-
contentText,
|
|
2137
|
-
contentRaw: raw.content !== void 0 ? this.sanitizeForLogging(raw.content) : void 0,
|
|
2138
|
-
toolCalls
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
normalizeAgentMessages(messages) {
|
|
2142
|
-
if (!Array.isArray(messages)) {
|
|
2143
|
-
return null;
|
|
2144
|
-
}
|
|
2145
|
-
const normalized = messages.map((message) => this.normalizeAgentMessage(message)).filter((msg) => msg !== null);
|
|
2146
|
-
return normalized;
|
|
2147
|
-
}
|
|
2148
|
-
normalizeContextStore(context) {
|
|
2149
|
-
if (!context || typeof context !== "object") {
|
|
2150
|
-
return {};
|
|
2151
|
-
}
|
|
2152
|
-
const normalized = {};
|
|
2153
|
-
for (const [key, entry] of Object.entries(context)) {
|
|
2154
|
-
if (entry && typeof entry === "object" && "value" in entry) {
|
|
2155
|
-
const candidate = entry;
|
|
2156
|
-
const description = typeof candidate.description === "string" && candidate.description.trim().length > 0 ? candidate.description : void 0;
|
|
2157
|
-
normalized[key] = { description, value: candidate.value };
|
|
2158
|
-
} else {
|
|
2159
|
-
normalized[key] = { value: entry };
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
return normalized;
|
|
2163
|
-
}
|
|
2164
|
-
getSelectedMenu() {
|
|
2165
|
-
const found = this.menuItems.find((item) => item.key === this.selectedMenu);
|
|
2166
|
-
return found ?? this.menuItems[0];
|
|
2167
|
-
}
|
|
2168
|
-
renderCoreWarningBanner() {
|
|
2169
|
-
if (this._core) {
|
|
2170
|
-
return nothing;
|
|
2171
|
-
}
|
|
2172
|
-
return html`
|
|
1555
|
+
}
|
|
1556
|
+
getDockedWindowStyles() {
|
|
1557
|
+
if (this.dockMode === "docked-left") return {
|
|
1558
|
+
position: "fixed",
|
|
1559
|
+
top: "0",
|
|
1560
|
+
left: "0",
|
|
1561
|
+
bottom: "0",
|
|
1562
|
+
width: `${Math.round(this.contextState.window.size.width)}px`,
|
|
1563
|
+
height: "100vh",
|
|
1564
|
+
minWidth: `${MIN_WINDOW_WIDTH_DOCKED_LEFT}px`,
|
|
1565
|
+
borderRadius: "0"
|
|
1566
|
+
};
|
|
1567
|
+
return {
|
|
1568
|
+
width: `${Math.round(this.contextState.window.size.width)}px`,
|
|
1569
|
+
height: `${Math.round(this.contextState.window.size.height)}px`,
|
|
1570
|
+
minWidth: `${MIN_WINDOW_WIDTH}px`,
|
|
1571
|
+
minHeight: `${MIN_WINDOW_HEIGHT}px`
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
handleDockClick(mode) {
|
|
1575
|
+
this.setDockMode(mode);
|
|
1576
|
+
}
|
|
1577
|
+
serializeAttributes(attributes) {
|
|
1578
|
+
return Object.entries(attributes).filter(([key, value]) => key !== "key" && value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key}="${String(value).replace(/"/g, """)}"`).join(" ");
|
|
1579
|
+
}
|
|
1580
|
+
sanitizeForLogging(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
1581
|
+
if (value === void 0) return "[undefined]";
|
|
1582
|
+
if (value === null || typeof value === "number" || typeof value === "boolean") return value;
|
|
1583
|
+
if (typeof value === "string") return value;
|
|
1584
|
+
if (typeof value === "bigint" || typeof value === "symbol" || typeof value === "function") return String(value);
|
|
1585
|
+
if (value instanceof Date) return value.toISOString();
|
|
1586
|
+
if (Array.isArray(value)) {
|
|
1587
|
+
if (depth >= 4) return "[Truncated depth]";
|
|
1588
|
+
return value.map((item) => this.sanitizeForLogging(item, depth + 1, seen));
|
|
1589
|
+
}
|
|
1590
|
+
if (typeof value === "object") {
|
|
1591
|
+
if (seen.has(value)) return "[Circular]";
|
|
1592
|
+
seen.add(value);
|
|
1593
|
+
if (depth >= 4) return "[Truncated depth]";
|
|
1594
|
+
const result = {};
|
|
1595
|
+
for (const [key, entry] of Object.entries(value)) result[key] = this.sanitizeForLogging(entry, depth + 1, seen);
|
|
1596
|
+
return result;
|
|
1597
|
+
}
|
|
1598
|
+
return String(value);
|
|
1599
|
+
}
|
|
1600
|
+
normalizeEventPayload(_type, payload) {
|
|
1601
|
+
if (payload && typeof payload === "object" && "event" in payload) {
|
|
1602
|
+
const { event, ...rest } = payload;
|
|
1603
|
+
const cleaned = Object.keys(rest).length === 0 ? event : {
|
|
1604
|
+
event,
|
|
1605
|
+
...rest
|
|
1606
|
+
};
|
|
1607
|
+
return this.sanitizeForLogging(cleaned);
|
|
1608
|
+
}
|
|
1609
|
+
return this.sanitizeForLogging(payload);
|
|
1610
|
+
}
|
|
1611
|
+
normalizeMessageContent(content) {
|
|
1612
|
+
if (typeof content === "string") return content;
|
|
1613
|
+
if (content && typeof content === "object" && "text" in content) {
|
|
1614
|
+
const maybeText = content.text;
|
|
1615
|
+
if (typeof maybeText === "string") return maybeText;
|
|
1616
|
+
}
|
|
1617
|
+
if (content === null || content === void 0) return "";
|
|
1618
|
+
if (typeof content === "object") try {
|
|
1619
|
+
return JSON.stringify(this.sanitizeForLogging(content));
|
|
1620
|
+
} catch {
|
|
1621
|
+
return "";
|
|
1622
|
+
}
|
|
1623
|
+
return String(content);
|
|
1624
|
+
}
|
|
1625
|
+
normalizeToolCalls(raw) {
|
|
1626
|
+
if (!Array.isArray(raw)) return [];
|
|
1627
|
+
return raw.map((entry) => {
|
|
1628
|
+
if (!entry || typeof entry !== "object") return null;
|
|
1629
|
+
const call = entry;
|
|
1630
|
+
const fn = call.function;
|
|
1631
|
+
const functionName = typeof fn?.name === "string" ? fn.name : typeof call.toolName === "string" ? call.toolName : void 0;
|
|
1632
|
+
const args = fn && "arguments" in fn ? fn.arguments : call.arguments;
|
|
1633
|
+
const normalized = {
|
|
1634
|
+
id: typeof call.id === "string" ? call.id : void 0,
|
|
1635
|
+
toolName: typeof call.toolName === "string" ? call.toolName : functionName,
|
|
1636
|
+
status: typeof call.status === "string" ? call.status : void 0
|
|
1637
|
+
};
|
|
1638
|
+
if (functionName) normalized.function = {
|
|
1639
|
+
name: functionName,
|
|
1640
|
+
arguments: this.sanitizeForLogging(args)
|
|
1641
|
+
};
|
|
1642
|
+
return normalized;
|
|
1643
|
+
}).filter((call) => Boolean(call));
|
|
1644
|
+
}
|
|
1645
|
+
normalizeAgentMessage(message) {
|
|
1646
|
+
if (!message || typeof message !== "object") return null;
|
|
1647
|
+
const raw = message;
|
|
1648
|
+
const role = typeof raw.role === "string" ? raw.role : "unknown";
|
|
1649
|
+
const contentText = this.normalizeMessageContent(raw.content);
|
|
1650
|
+
const toolCalls = this.normalizeToolCalls(raw.toolCalls);
|
|
1651
|
+
return {
|
|
1652
|
+
id: typeof raw.id === "string" ? raw.id : void 0,
|
|
1653
|
+
role,
|
|
1654
|
+
contentText,
|
|
1655
|
+
contentRaw: raw.content !== void 0 ? this.sanitizeForLogging(raw.content) : void 0,
|
|
1656
|
+
toolCalls
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
normalizeAgentMessages(messages) {
|
|
1660
|
+
if (!Array.isArray(messages)) return null;
|
|
1661
|
+
return messages.map((message) => this.normalizeAgentMessage(message)).filter((msg) => msg !== null);
|
|
1662
|
+
}
|
|
1663
|
+
normalizeContextStore(context) {
|
|
1664
|
+
if (!context || typeof context !== "object") return {};
|
|
1665
|
+
const normalized = {};
|
|
1666
|
+
for (const [key, entry] of Object.entries(context)) if (entry && typeof entry === "object" && "value" in entry) {
|
|
1667
|
+
const candidate = entry;
|
|
1668
|
+
normalized[key] = {
|
|
1669
|
+
description: typeof candidate.description === "string" && candidate.description.trim().length > 0 ? candidate.description : void 0,
|
|
1670
|
+
value: candidate.value
|
|
1671
|
+
};
|
|
1672
|
+
} else normalized[key] = { value: entry };
|
|
1673
|
+
return normalized;
|
|
1674
|
+
}
|
|
1675
|
+
getSelectedMenu() {
|
|
1676
|
+
return this.menuItems.find((item) => item.key === this.selectedMenu) ?? this.menuItems[0];
|
|
1677
|
+
}
|
|
1678
|
+
renderCoreWarningBanner() {
|
|
1679
|
+
if (this._core) return nothing;
|
|
1680
|
+
return html`
|
|
2173
1681
|
<div
|
|
2174
1682
|
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"
|
|
2175
1683
|
>
|
|
@@ -2188,65 +1696,48 @@ ${argsString}</pre
|
|
|
2188
1696
|
</div>
|
|
2189
1697
|
</div>
|
|
2190
1698
|
`;
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
if (this.selectedMenu === "agents") {
|
|
2234
|
-
return this.renderAgentsView();
|
|
2235
|
-
}
|
|
2236
|
-
if (this.selectedMenu === "frontend-tools") {
|
|
2237
|
-
return this.renderToolsView();
|
|
2238
|
-
}
|
|
2239
|
-
if (this.selectedMenu === "agent-context") {
|
|
2240
|
-
return this.renderContextView();
|
|
2241
|
-
}
|
|
2242
|
-
return nothing;
|
|
2243
|
-
}
|
|
2244
|
-
renderEventsTable() {
|
|
2245
|
-
const events = this.getEventsForSelectedContext();
|
|
2246
|
-
const filteredEvents = this.filterEvents(events);
|
|
2247
|
-
const selectedLabel = this.selectedContext === "all-agents" ? "all agents" : `agent ${this.selectedContext}`;
|
|
2248
|
-
if (events.length === 0) {
|
|
2249
|
-
return html`
|
|
1699
|
+
}
|
|
1700
|
+
getCoreStatusSummary() {
|
|
1701
|
+
if (!this._core) return {
|
|
1702
|
+
label: "Core not attached",
|
|
1703
|
+
tone: "border border-amber-200 bg-amber-50 text-amber-800",
|
|
1704
|
+
description: "Pass a CopilotKitCore instance to <cpk-web-inspector> or enable auto-attach."
|
|
1705
|
+
};
|
|
1706
|
+
const status = this.runtimeStatus ?? CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
1707
|
+
const lastErrorMessage = this.lastCoreError?.message;
|
|
1708
|
+
if (status === CopilotKitCoreRuntimeConnectionStatus.Error) return {
|
|
1709
|
+
label: "Runtime error",
|
|
1710
|
+
tone: "border border-rose-200 bg-rose-50 text-rose-700",
|
|
1711
|
+
description: lastErrorMessage ?? "CopilotKit runtime reported an error."
|
|
1712
|
+
};
|
|
1713
|
+
if (status === CopilotKitCoreRuntimeConnectionStatus.Connecting) return {
|
|
1714
|
+
label: "Connecting",
|
|
1715
|
+
tone: "border border-amber-200 bg-amber-50 text-amber-800",
|
|
1716
|
+
description: "Waiting for CopilotKit runtime to finish connecting."
|
|
1717
|
+
};
|
|
1718
|
+
if (status === CopilotKitCoreRuntimeConnectionStatus.Connected) return {
|
|
1719
|
+
label: "Connected",
|
|
1720
|
+
tone: "border border-emerald-200 bg-emerald-50 text-emerald-700",
|
|
1721
|
+
description: "Live runtime connection established."
|
|
1722
|
+
};
|
|
1723
|
+
return {
|
|
1724
|
+
label: "Disconnected",
|
|
1725
|
+
tone: "border border-gray-200 bg-gray-50 text-gray-700",
|
|
1726
|
+
description: lastErrorMessage ?? "Waiting for CopilotKit runtime to connect."
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
renderMainContent() {
|
|
1730
|
+
if (this.selectedMenu === "ag-ui-events") return this.renderEventsTable();
|
|
1731
|
+
if (this.selectedMenu === "agents") return this.renderAgentsView();
|
|
1732
|
+
if (this.selectedMenu === "frontend-tools") return this.renderToolsView();
|
|
1733
|
+
if (this.selectedMenu === "agent-context") return this.renderContextView();
|
|
1734
|
+
return nothing;
|
|
1735
|
+
}
|
|
1736
|
+
renderEventsTable() {
|
|
1737
|
+
const events = this.getEventsForSelectedContext();
|
|
1738
|
+
const filteredEvents = this.filterEvents(events);
|
|
1739
|
+
const selectedLabel = this.selectedContext === "all-agents" ? "all agents" : `agent ${this.selectedContext}`;
|
|
1740
|
+
if (events.length === 0) return html`
|
|
2250
1741
|
<div
|
|
2251
1742
|
class="flex h-full items-center justify-center px-4 py-8 text-center"
|
|
2252
1743
|
>
|
|
@@ -2263,9 +1754,7 @@ ${argsString}</pre
|
|
|
2263
1754
|
</div>
|
|
2264
1755
|
</div>
|
|
2265
1756
|
`;
|
|
2266
|
-
|
|
2267
|
-
if (filteredEvents.length === 0) {
|
|
2268
|
-
return html`
|
|
1757
|
+
if (filteredEvents.length === 0) return html`
|
|
2269
1758
|
<div
|
|
2270
1759
|
class="flex h-full items-center justify-center px-4 py-8 text-center"
|
|
2271
1760
|
>
|
|
@@ -2291,8 +1780,7 @@ ${argsString}</pre
|
|
|
2291
1780
|
</div>
|
|
2292
1781
|
</div>
|
|
2293
1782
|
`;
|
|
2294
|
-
|
|
2295
|
-
return html`
|
|
1783
|
+
return html`
|
|
2296
1784
|
<div class="flex h-full flex-col">
|
|
2297
1785
|
<div
|
|
2298
1786
|
class="flex flex-col gap-1.5 border-b border-gray-200 bg-white px-4 py-2.5"
|
|
@@ -2313,11 +1801,9 @@ ${argsString}</pre
|
|
|
2313
1801
|
@change=${this.handleEventTypeChange}
|
|
2314
1802
|
>
|
|
2315
1803
|
<option value="all">All event types</option>
|
|
2316
|
-
${AGENT_EVENT_TYPES.map(
|
|
2317
|
-
(type) => html`<option value=${type}>
|
|
1804
|
+
${AGENT_EVENT_TYPES.map((type) => html`<option value=${type}>
|
|
2318
1805
|
${type.toLowerCase().replace(/_/g, " ")}
|
|
2319
|
-
</option>`
|
|
2320
|
-
)}
|
|
1806
|
+
</option>`)}
|
|
2321
1807
|
</select>
|
|
2322
1808
|
<div class="flex items-center gap-1 text-[11px]">
|
|
2323
1809
|
<button
|
|
@@ -2388,15 +1874,13 @@ ${argsString}</pre
|
|
|
2388
1874
|
</thead>
|
|
2389
1875
|
<tbody>
|
|
2390
1876
|
${filteredEvents.map((event, index) => {
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
const isExpanded = this.expandedRows.has(event.id);
|
|
2399
|
-
return html`
|
|
1877
|
+
const rowBg = index % 2 === 0 ? "bg-white" : "bg-gray-50/50";
|
|
1878
|
+
const badgeClasses = this.getEventBadgeClasses(event.type);
|
|
1879
|
+
const extractedEvent = this.extractEventFromPayload(event.payload);
|
|
1880
|
+
const inlineEvent = this.stringifyPayload(extractedEvent, false) || "—";
|
|
1881
|
+
const prettyEvent = this.stringifyPayload(extractedEvent, true) || inlineEvent;
|
|
1882
|
+
const isExpanded = this.expandedRows.has(event.id);
|
|
1883
|
+
return html`
|
|
2400
1884
|
<tr
|
|
2401
1885
|
class="${rowBg} cursor-pointer transition hover:bg-blue-50/50"
|
|
2402
1886
|
@click=${() => this.toggleRowExpansion(event.id)}
|
|
@@ -2429,13 +1913,11 @@ ${argsString}</pre
|
|
|
2429
1913
|
${prettyEvent}</pre
|
|
2430
1914
|
>
|
|
2431
1915
|
<button
|
|
2432
|
-
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(
|
|
2433
|
-
event.id
|
|
2434
|
-
) ? "bg-green-100 text-green-700" : "bg-gray-100 text-gray-600 hover:bg-gray-200 hover:text-gray-900"}"
|
|
1916
|
+
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"}"
|
|
2435
1917
|
@click=${(e) => {
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
1918
|
+
e.stopPropagation();
|
|
1919
|
+
this.copyToClipboard(prettyEvent, event.id);
|
|
1920
|
+
}}
|
|
2439
1921
|
>
|
|
2440
1922
|
${this.copiedEvents.has(event.id) ? html`<span>✓ Copied</span>` : html`<span>Copy</span>`}
|
|
2441
1923
|
</button>
|
|
@@ -2444,49 +1926,44 @@ ${prettyEvent}</pre
|
|
|
2444
1926
|
</td>
|
|
2445
1927
|
</tr>
|
|
2446
1928
|
`;
|
|
2447
|
-
|
|
1929
|
+
})}
|
|
2448
1930
|
</tbody>
|
|
2449
1931
|
</table>
|
|
2450
1932
|
</div>
|
|
2451
1933
|
</div>
|
|
2452
1934
|
`;
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
renderAgentsView() {
|
|
2488
|
-
if (this.selectedContext === "all-agents") {
|
|
2489
|
-
return html`
|
|
1935
|
+
}
|
|
1936
|
+
handleEventFilterInput(event) {
|
|
1937
|
+
this.eventFilterText = event.target?.value ?? "";
|
|
1938
|
+
this.requestUpdate();
|
|
1939
|
+
}
|
|
1940
|
+
handleEventTypeChange(event) {
|
|
1941
|
+
const value = event.target?.value;
|
|
1942
|
+
if (!value) return;
|
|
1943
|
+
this.eventTypeFilter = value;
|
|
1944
|
+
this.requestUpdate();
|
|
1945
|
+
}
|
|
1946
|
+
resetEventFilters() {
|
|
1947
|
+
this.eventFilterText = "";
|
|
1948
|
+
this.eventTypeFilter = "all";
|
|
1949
|
+
this.requestUpdate();
|
|
1950
|
+
}
|
|
1951
|
+
exportEvents(events) {
|
|
1952
|
+
try {
|
|
1953
|
+
const payload = JSON.stringify(events, null, 2);
|
|
1954
|
+
const blob = new Blob([payload], { type: "application/json" });
|
|
1955
|
+
const url = URL.createObjectURL(blob);
|
|
1956
|
+
const anchor = document.createElement("a");
|
|
1957
|
+
anchor.href = url;
|
|
1958
|
+
anchor.download = `copilotkit-events-${Date.now()}.json`;
|
|
1959
|
+
anchor.click();
|
|
1960
|
+
URL.revokeObjectURL(url);
|
|
1961
|
+
} catch (error) {
|
|
1962
|
+
console.error("Failed to export events", error);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
renderAgentsView() {
|
|
1966
|
+
if (this.selectedContext === "all-agents") return html`
|
|
2490
1967
|
<div
|
|
2491
1968
|
class="flex h-full items-center justify-center px-4 py-8 text-center"
|
|
2492
1969
|
>
|
|
@@ -2503,18 +1980,12 @@ ${prettyEvent}</pre
|
|
|
2503
1980
|
</div>
|
|
2504
1981
|
</div>
|
|
2505
1982
|
`;
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
const statusColors = {
|
|
2513
|
-
running: "bg-emerald-50 text-emerald-700",
|
|
2514
|
-
idle: "bg-gray-100 text-gray-600",
|
|
2515
|
-
error: "bg-rose-50 text-rose-700"
|
|
2516
|
-
};
|
|
2517
|
-
return html`
|
|
1983
|
+
const agentId = this.selectedContext;
|
|
1984
|
+
const status = this.getAgentStatus(agentId);
|
|
1985
|
+
const stats = this.getAgentStats(agentId);
|
|
1986
|
+
const state = this.getLatestStateForAgent(agentId);
|
|
1987
|
+
const messages = this.getLatestMessagesForAgent(agentId);
|
|
1988
|
+
return html`
|
|
2518
1989
|
<div class="flex flex-col gap-4 p-4 overflow-auto">
|
|
2519
1990
|
<!-- Agent Overview Card -->
|
|
2520
1991
|
<div class="rounded-lg border border-gray-200 bg-white p-4">
|
|
@@ -2528,7 +1999,11 @@ ${prettyEvent}</pre
|
|
|
2528
1999
|
<div>
|
|
2529
2000
|
<h3 class="font-semibold text-sm text-gray-900">${agentId}</h3>
|
|
2530
2001
|
<span
|
|
2531
|
-
class="inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${
|
|
2002
|
+
class="inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${{
|
|
2003
|
+
running: "bg-emerald-50 text-emerald-700",
|
|
2004
|
+
idle: "bg-gray-100 text-gray-600",
|
|
2005
|
+
error: "bg-rose-50 text-rose-700"
|
|
2006
|
+
}[status]} relative -translate-y-[2px]"
|
|
2532
2007
|
>
|
|
2533
2008
|
<span
|
|
2534
2009
|
class="h-1.5 w-1.5 rounded-full ${status === "running" ? "bg-emerald-500 animate-pulse" : status === "error" ? "bg-rose-500" : "bg-gray-400"}"
|
|
@@ -2634,19 +2109,19 @@ ${prettyEvent}</pre
|
|
|
2634
2109
|
</thead>
|
|
2635
2110
|
<tbody class="divide-y divide-gray-200">
|
|
2636
2111
|
${messages.map((msg) => {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2112
|
+
const role = msg.role || "unknown";
|
|
2113
|
+
const roleColors = {
|
|
2114
|
+
user: "bg-blue-100 text-blue-800",
|
|
2115
|
+
assistant: "bg-green-100 text-green-800",
|
|
2116
|
+
system: "bg-gray-100 text-gray-800",
|
|
2117
|
+
tool: "bg-amber-100 text-amber-800",
|
|
2118
|
+
unknown: "bg-gray-100 text-gray-600"
|
|
2119
|
+
};
|
|
2120
|
+
const rawContent = msg.contentText ?? "";
|
|
2121
|
+
const toolCalls = msg.toolCalls ?? [];
|
|
2122
|
+
const hasContent = rawContent.trim().length > 0;
|
|
2123
|
+
const contentFallback = toolCalls.length > 0 ? "Invoked tool call" : "—";
|
|
2124
|
+
return html`
|
|
2650
2125
|
<tr>
|
|
2651
2126
|
<td class="px-4 py-2 align-top">
|
|
2652
2127
|
<span
|
|
@@ -2669,7 +2144,7 @@ ${prettyEvent}</pre
|
|
|
2669
2144
|
</td>
|
|
2670
2145
|
</tr>
|
|
2671
2146
|
`;
|
|
2672
|
-
|
|
2147
|
+
})}
|
|
2673
2148
|
</tbody>
|
|
2674
2149
|
</table>
|
|
2675
2150
|
` : html`
|
|
@@ -2688,11 +2163,11 @@ ${prettyEvent}</pre
|
|
|
2688
2163
|
</div>
|
|
2689
2164
|
</div>
|
|
2690
2165
|
`;
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2166
|
+
}
|
|
2167
|
+
renderContextDropdown() {
|
|
2168
|
+
const filteredOptions = this.selectedMenu === "agents" ? this.contextOptions.filter((opt) => opt.key !== "all-agents") : this.contextOptions;
|
|
2169
|
+
const selectedLabel = filteredOptions.find((opt) => opt.key === this.selectedContext)?.label ?? "";
|
|
2170
|
+
return html`
|
|
2696
2171
|
<div
|
|
2697
2172
|
class="relative z-40 min-w-0 flex-1"
|
|
2698
2173
|
data-context-dropdown-root="true"
|
|
@@ -2712,8 +2187,7 @@ ${prettyEvent}</pre
|
|
|
2712
2187
|
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"
|
|
2713
2188
|
data-context-dropdown-root="true"
|
|
2714
2189
|
>
|
|
2715
|
-
${filteredOptions.map(
|
|
2716
|
-
(option) => html`
|
|
2190
|
+
${filteredOptions.map((option) => html`
|
|
2717
2191
|
<button
|
|
2718
2192
|
type="button"
|
|
2719
2193
|
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"
|
|
@@ -2728,63 +2202,53 @@ ${prettyEvent}</pre
|
|
|
2728
2202
|
>${this.renderIcon("Check")}</span
|
|
2729
2203
|
>` : nothing}
|
|
2730
2204
|
</button>
|
|
2731
|
-
`
|
|
2732
|
-
)}
|
|
2205
|
+
`)}
|
|
2733
2206
|
</div>
|
|
2734
2207
|
` : nothing}
|
|
2735
2208
|
</div>
|
|
2736
2209
|
`;
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
this.contextMenuOpen = false;
|
|
2771
|
-
this.persistState();
|
|
2772
|
-
this.requestUpdate();
|
|
2773
|
-
}
|
|
2774
|
-
renderToolsView() {
|
|
2775
|
-
if (!this._core) {
|
|
2776
|
-
return html`
|
|
2210
|
+
}
|
|
2211
|
+
handleMenuSelect(key) {
|
|
2212
|
+
if (!this.menuItems.some((item) => item.key === key)) return;
|
|
2213
|
+
this.selectedMenu = key;
|
|
2214
|
+
if (key === "agents" && this.selectedContext === "all-agents") {
|
|
2215
|
+
const agentOptions = this.contextOptions.filter((opt) => opt.key !== "all-agents");
|
|
2216
|
+
if (agentOptions.length > 0) {
|
|
2217
|
+
const defaultAgent = agentOptions.find((opt) => opt.key === "default");
|
|
2218
|
+
this.selectedContext = defaultAgent ? defaultAgent.key : agentOptions[0].key;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
this.contextMenuOpen = false;
|
|
2222
|
+
this.persistState();
|
|
2223
|
+
this.requestUpdate();
|
|
2224
|
+
}
|
|
2225
|
+
handleContextDropdownToggle(event) {
|
|
2226
|
+
event.preventDefault();
|
|
2227
|
+
event.stopPropagation();
|
|
2228
|
+
this.contextMenuOpen = !this.contextMenuOpen;
|
|
2229
|
+
this.requestUpdate();
|
|
2230
|
+
}
|
|
2231
|
+
handleContextOptionSelect(key) {
|
|
2232
|
+
if (!this.contextOptions.some((option) => option.key === key)) return;
|
|
2233
|
+
if (this.selectedContext !== key) {
|
|
2234
|
+
this.selectedContext = key;
|
|
2235
|
+
this.expandedRows.clear();
|
|
2236
|
+
}
|
|
2237
|
+
this.contextMenuOpen = false;
|
|
2238
|
+
this.persistState();
|
|
2239
|
+
this.requestUpdate();
|
|
2240
|
+
}
|
|
2241
|
+
renderToolsView() {
|
|
2242
|
+
if (!this._core) return html`
|
|
2777
2243
|
<div
|
|
2778
2244
|
class="flex h-full items-center justify-center px-4 py-8 text-xs text-gray-500"
|
|
2779
2245
|
>
|
|
2780
2246
|
No core instance available
|
|
2781
2247
|
</div>
|
|
2782
2248
|
`;
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
if (allTools.length === 0) {
|
|
2787
|
-
return html`
|
|
2249
|
+
this.refreshToolsSnapshot();
|
|
2250
|
+
const allTools = this.cachedTools;
|
|
2251
|
+
if (allTools.length === 0) return html`
|
|
2788
2252
|
<div
|
|
2789
2253
|
class="flex h-full items-center justify-center px-4 py-8 text-center"
|
|
2790
2254
|
>
|
|
@@ -2802,83 +2266,67 @@ ${prettyEvent}</pre
|
|
|
2802
2266
|
</div>
|
|
2803
2267
|
</div>
|
|
2804
2268
|
`;
|
|
2805
|
-
|
|
2806
|
-
const filteredTools = this.selectedContext === "all-agents" ? allTools : allTools.filter(
|
|
2807
|
-
(tool) => !tool.agentId || tool.agentId === this.selectedContext
|
|
2808
|
-
);
|
|
2809
|
-
return html`
|
|
2269
|
+
return html`
|
|
2810
2270
|
<div class="flex h-full flex-col overflow-hidden">
|
|
2811
2271
|
<div class="overflow-auto p-4">
|
|
2812
2272
|
<div class="space-y-3">
|
|
2813
|
-
${
|
|
2273
|
+
${(this.selectedContext === "all-agents" ? allTools : allTools.filter((tool) => !tool.agentId || tool.agentId === this.selectedContext)).map((tool) => this.renderToolCard(tool))}
|
|
2814
2274
|
</div>
|
|
2815
2275
|
</div>
|
|
2816
2276
|
</div>
|
|
2817
2277
|
`;
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
if (agentCompare !== 0) return agentCompare;
|
|
2871
|
-
return a.name.localeCompare(b.name);
|
|
2872
|
-
});
|
|
2873
|
-
}
|
|
2874
|
-
renderToolCard(tool) {
|
|
2875
|
-
const isExpanded = this.expandedTools.has(`${tool.agentId}:${tool.name}`);
|
|
2876
|
-
const schema = this.extractSchemaInfo(tool.parameters);
|
|
2877
|
-
const typeColors = {
|
|
2878
|
-
handler: "bg-blue-50 text-blue-700 border-blue-200",
|
|
2879
|
-
renderer: "bg-purple-50 text-purple-700 border-purple-200"
|
|
2880
|
-
};
|
|
2881
|
-
return html`
|
|
2278
|
+
}
|
|
2279
|
+
extractToolsFromAgents() {
|
|
2280
|
+
if (!this._core) return [];
|
|
2281
|
+
const tools = [];
|
|
2282
|
+
for (const coreTool of this._core.tools ?? []) tools.push({
|
|
2283
|
+
agentId: coreTool.agentId ?? "",
|
|
2284
|
+
name: coreTool.name,
|
|
2285
|
+
description: coreTool.description,
|
|
2286
|
+
parameters: coreTool.parameters,
|
|
2287
|
+
type: "handler"
|
|
2288
|
+
});
|
|
2289
|
+
for (const [agentId, agent] of Object.entries(this._core.agents)) {
|
|
2290
|
+
if (!agent) continue;
|
|
2291
|
+
const handlers = agent.toolHandlers;
|
|
2292
|
+
if (handlers && typeof handlers === "object") {
|
|
2293
|
+
for (const [toolName, handler] of Object.entries(handlers)) if (handler && typeof handler === "object") {
|
|
2294
|
+
const handlerObj = handler;
|
|
2295
|
+
tools.push({
|
|
2296
|
+
agentId,
|
|
2297
|
+
name: toolName,
|
|
2298
|
+
description: typeof handlerObj.description === "string" && handlerObj.description || handlerObj.tool?.description,
|
|
2299
|
+
parameters: handlerObj.parameters ?? handlerObj.tool?.parameters,
|
|
2300
|
+
type: "handler"
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
const renderers = agent.toolRenderers;
|
|
2305
|
+
if (renderers && typeof renderers === "object") {
|
|
2306
|
+
for (const [toolName, renderer] of Object.entries(renderers)) if (!tools.some((t) => t.agentId === agentId && t.name === toolName)) {
|
|
2307
|
+
if (renderer && typeof renderer === "object") {
|
|
2308
|
+
const rendererObj = renderer;
|
|
2309
|
+
tools.push({
|
|
2310
|
+
agentId,
|
|
2311
|
+
name: toolName,
|
|
2312
|
+
description: typeof rendererObj.description === "string" && rendererObj.description || rendererObj.tool?.description,
|
|
2313
|
+
parameters: rendererObj.parameters ?? rendererObj.tool?.parameters,
|
|
2314
|
+
type: "renderer"
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
return tools.sort((a, b) => {
|
|
2321
|
+
const agentCompare = a.agentId.localeCompare(b.agentId);
|
|
2322
|
+
if (agentCompare !== 0) return agentCompare;
|
|
2323
|
+
return a.name.localeCompare(b.name);
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
renderToolCard(tool) {
|
|
2327
|
+
const isExpanded = this.expandedTools.has(`${tool.agentId}:${tool.name}`);
|
|
2328
|
+
const schema = this.extractSchemaInfo(tool.parameters);
|
|
2329
|
+
return html`
|
|
2882
2330
|
<div class="rounded-lg border border-gray-200 bg-white overflow-hidden">
|
|
2883
2331
|
<button
|
|
2884
2332
|
type="button"
|
|
@@ -2892,7 +2340,10 @@ ${prettyEvent}</pre
|
|
|
2892
2340
|
>${tool.name}</span
|
|
2893
2341
|
>
|
|
2894
2342
|
<span
|
|
2895
|
-
class="inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[10px] font-medium ${
|
|
2343
|
+
class="inline-flex items-center rounded-sm border px-1.5 py-0.5 text-[10px] font-medium ${{
|
|
2344
|
+
handler: "bg-blue-50 text-blue-700 border-blue-200",
|
|
2345
|
+
renderer: "bg-purple-50 text-purple-700 border-purple-200"
|
|
2346
|
+
}[tool.type]}"
|
|
2896
2347
|
>
|
|
2897
2348
|
${tool.type}
|
|
2898
2349
|
</span>
|
|
@@ -2929,8 +2380,7 @@ ${prettyEvent}</pre
|
|
|
2929
2380
|
Parameters
|
|
2930
2381
|
</h5>
|
|
2931
2382
|
<div class="space-y-3">
|
|
2932
|
-
${schema.properties.map(
|
|
2933
|
-
(prop) => html`
|
|
2383
|
+
${schema.properties.map((prop) => html`
|
|
2934
2384
|
<div
|
|
2935
2385
|
class="rounded-md border border-gray-200 bg-white p-3"
|
|
2936
2386
|
>
|
|
@@ -2965,9 +2415,7 @@ ${prettyEvent}</pre
|
|
|
2965
2415
|
<span>Default:</span>
|
|
2966
2416
|
<code
|
|
2967
2417
|
class="rounded bg-gray-100 px-1 py-0.5 font-mono"
|
|
2968
|
-
>${JSON.stringify(
|
|
2969
|
-
prop.defaultValue
|
|
2970
|
-
)}</code
|
|
2418
|
+
>${JSON.stringify(prop.defaultValue)}</code
|
|
2971
2419
|
>
|
|
2972
2420
|
</div>
|
|
2973
2421
|
` : nothing}
|
|
@@ -2977,20 +2425,17 @@ ${prettyEvent}</pre
|
|
|
2977
2425
|
>Allowed values:</span
|
|
2978
2426
|
>
|
|
2979
2427
|
<div class="mt-1 flex flex-wrap gap-1">
|
|
2980
|
-
${prop.enum.map(
|
|
2981
|
-
(val) => html`
|
|
2428
|
+
${prop.enum.map((val) => html`
|
|
2982
2429
|
<code
|
|
2983
2430
|
class="rounded border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[10px] font-mono text-gray-700"
|
|
2984
2431
|
>${JSON.stringify(val)}</code
|
|
2985
2432
|
>
|
|
2986
|
-
`
|
|
2987
|
-
)}
|
|
2433
|
+
`)}
|
|
2988
2434
|
</div>
|
|
2989
2435
|
</div>
|
|
2990
2436
|
` : nothing}
|
|
2991
2437
|
</div>
|
|
2992
|
-
`
|
|
2993
|
-
)}
|
|
2438
|
+
`)}
|
|
2994
2439
|
</div>
|
|
2995
2440
|
` : html`
|
|
2996
2441
|
<div
|
|
@@ -3003,121 +2448,96 @@ ${prettyEvent}</pre
|
|
|
3003
2448
|
` : nothing}
|
|
3004
2449
|
</div>
|
|
3005
2450
|
`;
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
ZodLiteral: "literal",
|
|
3097
|
-
ZodUnion: "union",
|
|
3098
|
-
ZodAny: "any",
|
|
3099
|
-
ZodUnknown: "unknown"
|
|
3100
|
-
};
|
|
3101
|
-
info.type = typeName ? typeMap[typeName] || typeName.replace("Zod", "").toLowerCase() : void 0;
|
|
3102
|
-
if (typeName === "ZodEnum" && Array.isArray(def.values)) {
|
|
3103
|
-
info.enum = def.values;
|
|
3104
|
-
} else if (typeName === "ZodLiteral" && def.value !== void 0) {
|
|
3105
|
-
info.enum = [def.value];
|
|
3106
|
-
}
|
|
3107
|
-
return info;
|
|
3108
|
-
}
|
|
3109
|
-
toggleToolExpansion(toolId) {
|
|
3110
|
-
if (this.expandedTools.has(toolId)) {
|
|
3111
|
-
this.expandedTools.delete(toolId);
|
|
3112
|
-
} else {
|
|
3113
|
-
this.expandedTools.add(toolId);
|
|
3114
|
-
}
|
|
3115
|
-
this.requestUpdate();
|
|
3116
|
-
}
|
|
3117
|
-
renderContextView() {
|
|
3118
|
-
const contextEntries = Object.entries(this.contextStore);
|
|
3119
|
-
if (contextEntries.length === 0) {
|
|
3120
|
-
return html`
|
|
2451
|
+
}
|
|
2452
|
+
extractSchemaInfo(parameters) {
|
|
2453
|
+
const result = { properties: [] };
|
|
2454
|
+
if (!parameters || typeof parameters !== "object") return result;
|
|
2455
|
+
const zodDef = parameters._def;
|
|
2456
|
+
if (zodDef && typeof zodDef === "object") {
|
|
2457
|
+
if (zodDef.typeName === "ZodObject") {
|
|
2458
|
+
const rawShape = zodDef.shape;
|
|
2459
|
+
const shape = typeof rawShape === "function" ? rawShape() : rawShape;
|
|
2460
|
+
if (!shape || typeof shape !== "object") return result;
|
|
2461
|
+
const requiredKeys = /* @__PURE__ */ new Set();
|
|
2462
|
+
if (zodDef.unknownKeys === "strict" || !zodDef.catchall) Object.keys(shape || {}).forEach((key) => {
|
|
2463
|
+
const candidate = shape[key];
|
|
2464
|
+
if (candidate?._def && !this.isZodOptional(candidate)) requiredKeys.add(key);
|
|
2465
|
+
});
|
|
2466
|
+
for (const [key, value] of Object.entries(shape || {})) {
|
|
2467
|
+
const fieldInfo = this.extractZodFieldInfo(value);
|
|
2468
|
+
result.properties.push({
|
|
2469
|
+
name: key,
|
|
2470
|
+
type: fieldInfo.type,
|
|
2471
|
+
description: fieldInfo.description,
|
|
2472
|
+
required: requiredKeys.has(key),
|
|
2473
|
+
defaultValue: fieldInfo.defaultValue,
|
|
2474
|
+
enum: fieldInfo.enum
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
} else if (parameters.type === "object" && parameters.properties) {
|
|
2479
|
+
const props = parameters.properties;
|
|
2480
|
+
const required = new Set(Array.isArray(parameters.required) ? parameters.required : []);
|
|
2481
|
+
for (const [key, value] of Object.entries(props ?? {})) {
|
|
2482
|
+
const prop = value;
|
|
2483
|
+
result.properties.push({
|
|
2484
|
+
name: key,
|
|
2485
|
+
type: prop.type,
|
|
2486
|
+
description: typeof prop.description === "string" ? prop.description : void 0,
|
|
2487
|
+
required: required.has(key),
|
|
2488
|
+
defaultValue: prop.default,
|
|
2489
|
+
enum: Array.isArray(prop.enum) ? prop.enum : void 0
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
return result;
|
|
2494
|
+
}
|
|
2495
|
+
isZodOptional(zodSchema) {
|
|
2496
|
+
const schema = zodSchema;
|
|
2497
|
+
if (!schema?._def) return false;
|
|
2498
|
+
const def = schema._def;
|
|
2499
|
+
if (def.typeName === "ZodOptional" || def.typeName === "ZodNullable") return true;
|
|
2500
|
+
if (def.defaultValue !== void 0) return true;
|
|
2501
|
+
return false;
|
|
2502
|
+
}
|
|
2503
|
+
extractZodFieldInfo(zodSchema) {
|
|
2504
|
+
const info = {};
|
|
2505
|
+
const schema = zodSchema;
|
|
2506
|
+
if (!schema?._def) return info;
|
|
2507
|
+
let currentSchema = schema;
|
|
2508
|
+
let def = currentSchema._def;
|
|
2509
|
+
while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
|
|
2510
|
+
if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
2511
|
+
currentSchema = def.innerType ?? currentSchema;
|
|
2512
|
+
if (!currentSchema?._def) break;
|
|
2513
|
+
def = currentSchema._def;
|
|
2514
|
+
}
|
|
2515
|
+
info.description = typeof def.description === "string" ? def.description : void 0;
|
|
2516
|
+
const typeName = typeof def.typeName === "string" ? def.typeName : void 0;
|
|
2517
|
+
info.type = typeName ? {
|
|
2518
|
+
ZodString: "string",
|
|
2519
|
+
ZodNumber: "number",
|
|
2520
|
+
ZodBoolean: "boolean",
|
|
2521
|
+
ZodArray: "array",
|
|
2522
|
+
ZodObject: "object",
|
|
2523
|
+
ZodEnum: "enum",
|
|
2524
|
+
ZodLiteral: "literal",
|
|
2525
|
+
ZodUnion: "union",
|
|
2526
|
+
ZodAny: "any",
|
|
2527
|
+
ZodUnknown: "unknown"
|
|
2528
|
+
}[typeName] || typeName.replace("Zod", "").toLowerCase() : void 0;
|
|
2529
|
+
if (typeName === "ZodEnum" && Array.isArray(def.values)) info.enum = def.values;
|
|
2530
|
+
else if (typeName === "ZodLiteral" && def.value !== void 0) info.enum = [def.value];
|
|
2531
|
+
return info;
|
|
2532
|
+
}
|
|
2533
|
+
toggleToolExpansion(toolId) {
|
|
2534
|
+
if (this.expandedTools.has(toolId)) this.expandedTools.delete(toolId);
|
|
2535
|
+
else this.expandedTools.add(toolId);
|
|
2536
|
+
this.requestUpdate();
|
|
2537
|
+
}
|
|
2538
|
+
renderContextView() {
|
|
2539
|
+
const contextEntries = Object.entries(this.contextStore);
|
|
2540
|
+
if (contextEntries.length === 0) return html`
|
|
3121
2541
|
<div
|
|
3122
2542
|
class="flex h-full items-center justify-center px-4 py-8 text-center"
|
|
3123
2543
|
>
|
|
@@ -3134,25 +2554,21 @@ ${prettyEvent}</pre
|
|
|
3134
2554
|
</div>
|
|
3135
2555
|
</div>
|
|
3136
2556
|
`;
|
|
3137
|
-
|
|
3138
|
-
return html`
|
|
2557
|
+
return html`
|
|
3139
2558
|
<div class="flex h-full flex-col overflow-hidden">
|
|
3140
2559
|
<div class="overflow-auto p-4">
|
|
3141
2560
|
<div class="space-y-3">
|
|
3142
|
-
${contextEntries.map(
|
|
3143
|
-
([id, context]) => this.renderContextCard(id, context)
|
|
3144
|
-
)}
|
|
2561
|
+
${contextEntries.map(([id, context]) => this.renderContextCard(id, context))}
|
|
3145
2562
|
</div>
|
|
3146
2563
|
</div>
|
|
3147
2564
|
</div>
|
|
3148
2565
|
`;
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
return html`
|
|
2566
|
+
}
|
|
2567
|
+
renderContextCard(id, context) {
|
|
2568
|
+
const isExpanded = this.expandedContextItems.has(id);
|
|
2569
|
+
const valuePreview = this.getContextValuePreview(context.value);
|
|
2570
|
+
const hasValue = context.value !== void 0 && context.value !== null;
|
|
2571
|
+
return html`
|
|
3156
2572
|
<div class="rounded-lg border border-gray-200 bg-white overflow-hidden">
|
|
3157
2573
|
<button
|
|
3158
2574
|
type="button"
|
|
@@ -3161,7 +2577,7 @@ ${prettyEvent}</pre
|
|
|
3161
2577
|
>
|
|
3162
2578
|
<div class="flex items-start justify-between gap-3">
|
|
3163
2579
|
<div class="flex-1 min-w-0">
|
|
3164
|
-
<p class="text-sm font-medium text-gray-900 mb-1">${
|
|
2580
|
+
<p class="text-sm font-medium text-gray-900 mb-1">${context.description?.trim() || id}</p>
|
|
3165
2581
|
<div class="flex items-center gap-2 text-xs text-gray-500">
|
|
3166
2582
|
<span
|
|
3167
2583
|
class="font-mono truncate inline-block align-middle"
|
|
@@ -3200,9 +2616,9 @@ ${prettyEvent}</pre
|
|
|
3200
2616
|
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"
|
|
3201
2617
|
type="button"
|
|
3202
2618
|
@click=${(e) => {
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
2619
|
+
e.stopPropagation();
|
|
2620
|
+
this.copyContextValue(context.value, id);
|
|
2621
|
+
}}
|
|
3206
2622
|
>
|
|
3207
2623
|
${this.copiedContextItems.has(id) ? "Copied" : "Copy JSON"}
|
|
3208
2624
|
</button>
|
|
@@ -3212,9 +2628,7 @@ ${prettyEvent}</pre
|
|
|
3212
2628
|
>
|
|
3213
2629
|
<pre
|
|
3214
2630
|
class="overflow-auto text-xs text-gray-800 max-h-96"
|
|
3215
|
-
><code>${this.formatContextValue(
|
|
3216
|
-
context.value
|
|
3217
|
-
)}</code></pre>
|
|
2631
|
+
><code>${this.formatContextValue(context.value)}</code></pre>
|
|
3218
2632
|
</div>
|
|
3219
2633
|
` : html`
|
|
3220
2634
|
<div
|
|
@@ -3227,93 +2641,64 @@ ${prettyEvent}</pre
|
|
|
3227
2641
|
` : nothing}
|
|
3228
2642
|
</div>
|
|
3229
2643
|
`;
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
if (this.expandedContextItems.has(contextId)) {
|
|
3289
|
-
this.expandedContextItems.delete(contextId);
|
|
3290
|
-
} else {
|
|
3291
|
-
this.expandedContextItems.add(contextId);
|
|
3292
|
-
}
|
|
3293
|
-
this.requestUpdate();
|
|
3294
|
-
}
|
|
3295
|
-
toggleRowExpansion(eventId) {
|
|
3296
|
-
const selection = window.getSelection();
|
|
3297
|
-
if (selection && selection.toString().length > 0) {
|
|
3298
|
-
return;
|
|
3299
|
-
}
|
|
3300
|
-
if (this.expandedRows.has(eventId)) {
|
|
3301
|
-
this.expandedRows.delete(eventId);
|
|
3302
|
-
} else {
|
|
3303
|
-
this.expandedRows.add(eventId);
|
|
3304
|
-
}
|
|
3305
|
-
this.requestUpdate();
|
|
3306
|
-
}
|
|
3307
|
-
renderAnnouncementPanel() {
|
|
3308
|
-
if (!this.isOpen) {
|
|
3309
|
-
return nothing;
|
|
3310
|
-
}
|
|
3311
|
-
this.ensureAnnouncementLoading();
|
|
3312
|
-
if (!this.hasUnseenAnnouncement) {
|
|
3313
|
-
return nothing;
|
|
3314
|
-
}
|
|
3315
|
-
if (!this.announcementLoaded && !this.announcementMarkdown) {
|
|
3316
|
-
return html`<div
|
|
2644
|
+
}
|
|
2645
|
+
getContextValuePreview(value) {
|
|
2646
|
+
if (value === void 0 || value === null) return "—";
|
|
2647
|
+
if (typeof value === "string") return value.length > 50 ? `${value.substring(0, 50)}...` : value;
|
|
2648
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
2649
|
+
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
2650
|
+
if (typeof value === "object") {
|
|
2651
|
+
const keys = Object.keys(value);
|
|
2652
|
+
return `Object with ${keys.length} key${keys.length !== 1 ? "s" : ""}`;
|
|
2653
|
+
}
|
|
2654
|
+
if (typeof value === "function") return "Function";
|
|
2655
|
+
return String(value);
|
|
2656
|
+
}
|
|
2657
|
+
formatContextValue(value) {
|
|
2658
|
+
if (value === void 0) return "undefined";
|
|
2659
|
+
if (value === null) return "null";
|
|
2660
|
+
if (typeof value === "function") return value.toString();
|
|
2661
|
+
try {
|
|
2662
|
+
return JSON.stringify(value, null, 2);
|
|
2663
|
+
} catch {
|
|
2664
|
+
return String(value);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
async copyContextValue(value, contextId) {
|
|
2668
|
+
if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
|
|
2669
|
+
console.warn("Clipboard API is not available in this environment.");
|
|
2670
|
+
return;
|
|
2671
|
+
}
|
|
2672
|
+
const serialized = this.formatContextValue(value);
|
|
2673
|
+
try {
|
|
2674
|
+
await navigator.clipboard.writeText(serialized);
|
|
2675
|
+
this.copiedContextItems.add(contextId);
|
|
2676
|
+
this.requestUpdate();
|
|
2677
|
+
setTimeout(() => {
|
|
2678
|
+
this.copiedContextItems.delete(contextId);
|
|
2679
|
+
this.requestUpdate();
|
|
2680
|
+
}, 1500);
|
|
2681
|
+
} catch (error) {
|
|
2682
|
+
console.error("Failed to copy context value:", error);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
toggleContextExpansion(contextId) {
|
|
2686
|
+
if (this.expandedContextItems.has(contextId)) this.expandedContextItems.delete(contextId);
|
|
2687
|
+
else this.expandedContextItems.add(contextId);
|
|
2688
|
+
this.requestUpdate();
|
|
2689
|
+
}
|
|
2690
|
+
toggleRowExpansion(eventId) {
|
|
2691
|
+
const selection = window.getSelection();
|
|
2692
|
+
if (selection && selection.toString().length > 0) return;
|
|
2693
|
+
if (this.expandedRows.has(eventId)) this.expandedRows.delete(eventId);
|
|
2694
|
+
else this.expandedRows.add(eventId);
|
|
2695
|
+
this.requestUpdate();
|
|
2696
|
+
}
|
|
2697
|
+
renderAnnouncementPanel() {
|
|
2698
|
+
if (!this.isOpen) return nothing;
|
|
2699
|
+
this.ensureAnnouncementLoading();
|
|
2700
|
+
if (!this.hasUnseenAnnouncement) return nothing;
|
|
2701
|
+
if (!this.announcementLoaded && !this.announcementMarkdown) return html`<div
|
|
3317
2702
|
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)]"
|
|
3318
2703
|
>
|
|
3319
2704
|
<div class="flex items-center gap-2 font-semibold">
|
|
@@ -3325,9 +2710,7 @@ ${prettyEvent}</pre
|
|
|
3325
2710
|
<span>Loading latest announcement…</span>
|
|
3326
2711
|
</div>
|
|
3327
2712
|
</div>`;
|
|
3328
|
-
|
|
3329
|
-
if (this.announcementLoadError) {
|
|
3330
|
-
return html`<div
|
|
2713
|
+
if (this.announcementLoadError) return html`<div
|
|
3331
2714
|
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)]"
|
|
3332
2715
|
>
|
|
3333
2716
|
<div class="flex items-center gap-2 font-semibold">
|
|
@@ -3343,14 +2726,11 @@ ${prettyEvent}</pre
|
|
|
3343
2726
|
again.
|
|
3344
2727
|
</p>
|
|
3345
2728
|
</div>`;
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
return nothing;
|
|
3349
|
-
}
|
|
3350
|
-
const content = this.announcementHtml ? unsafeHTML(this.announcementHtml) : html`<pre class="whitespace-pre-wrap text-sm text-gray-900">
|
|
2729
|
+
if (!this.announcementMarkdown) return nothing;
|
|
2730
|
+
const content = this.announcementHtml ? unsafeHTML(this.announcementHtml) : html`<pre class="whitespace-pre-wrap text-sm text-gray-900">
|
|
3351
2731
|
${this.announcementMarkdown}</pre
|
|
3352
2732
|
>`;
|
|
3353
|
-
|
|
2733
|
+
return html`<div
|
|
3354
2734
|
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)]"
|
|
3355
2735
|
>
|
|
3356
2736
|
<div
|
|
@@ -3375,137 +2755,105 @@ ${this.announcementMarkdown}</pre
|
|
|
3375
2755
|
${content}
|
|
3376
2756
|
</div>
|
|
3377
2757
|
</div>`;
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
if (!this.hasUnseenAnnouncement || !this.showAnnouncementPreview || !this.announcementPreviewText) {
|
|
3387
|
-
return nothing;
|
|
3388
|
-
}
|
|
3389
|
-
const side = this.contextState.button.anchor.horizontal === "left" ? "right" : "left";
|
|
3390
|
-
return html`<div
|
|
2758
|
+
}
|
|
2759
|
+
ensureAnnouncementLoading() {
|
|
2760
|
+
if (this.announcementPromise || typeof window === "undefined" || typeof fetch === "undefined") return;
|
|
2761
|
+
this.announcementPromise = this.fetchAnnouncement();
|
|
2762
|
+
}
|
|
2763
|
+
renderAnnouncementPreview() {
|
|
2764
|
+
if (!this.hasUnseenAnnouncement || !this.showAnnouncementPreview || !this.announcementPreviewText) return nothing;
|
|
2765
|
+
return html`<div
|
|
3391
2766
|
class="announcement-preview"
|
|
3392
|
-
data-side=${
|
|
2767
|
+
data-side=${this.contextState.button.anchor.horizontal === "left" ? "right" : "left"}
|
|
3393
2768
|
role="note"
|
|
3394
2769
|
@click=${() => this.handleAnnouncementPreviewClick()}
|
|
3395
2770
|
>
|
|
3396
2771
|
<span>${this.announcementPreviewText}</span>
|
|
3397
2772
|
<span class="announcement-preview__arrow"></span>
|
|
3398
2773
|
</div>`;
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
persistAnnouncementTimestamp(timestamp) {
|
|
3477
|
-
if (typeof window === "undefined" || !window.localStorage) {
|
|
3478
|
-
return;
|
|
3479
|
-
}
|
|
3480
|
-
try {
|
|
3481
|
-
const payload = JSON.stringify({ timestamp });
|
|
3482
|
-
window.localStorage.setItem(ANNOUNCEMENT_STORAGE_KEY, payload);
|
|
3483
|
-
} catch {
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
markAnnouncementSeen() {
|
|
3487
|
-
this.hasUnseenAnnouncement = false;
|
|
3488
|
-
this.showAnnouncementPreview = false;
|
|
3489
|
-
if (!this.announcementTimestamp) {
|
|
3490
|
-
if (this.announcementPromise && !this.announcementLoaded) {
|
|
3491
|
-
void this.announcementPromise.then(() => this.markAnnouncementSeen()).catch(() => void 0);
|
|
3492
|
-
}
|
|
3493
|
-
this.requestUpdate();
|
|
3494
|
-
return;
|
|
3495
|
-
}
|
|
3496
|
-
this.persistAnnouncementTimestamp(this.announcementTimestamp);
|
|
3497
|
-
this.requestUpdate();
|
|
3498
|
-
}
|
|
2774
|
+
}
|
|
2775
|
+
handleAnnouncementPreviewClick() {
|
|
2776
|
+
this.showAnnouncementPreview = false;
|
|
2777
|
+
this.openInspector();
|
|
2778
|
+
}
|
|
2779
|
+
async fetchAnnouncement() {
|
|
2780
|
+
try {
|
|
2781
|
+
const response = await fetch(ANNOUNCEMENT_URL, { cache: "no-cache" });
|
|
2782
|
+
if (!response.ok) throw new Error(`Failed to load announcement (${response.status})`);
|
|
2783
|
+
const data = await response.json();
|
|
2784
|
+
const timestamp = typeof data?.timestamp === "string" ? data.timestamp : null;
|
|
2785
|
+
const previewText = typeof data?.previewText === "string" ? data.previewText : null;
|
|
2786
|
+
const markdown = typeof data?.announcement === "string" ? data.announcement : null;
|
|
2787
|
+
if (!timestamp || !markdown) throw new Error("Malformed announcement payload");
|
|
2788
|
+
const storedTimestamp = this.loadStoredAnnouncementTimestamp();
|
|
2789
|
+
this.announcementTimestamp = timestamp;
|
|
2790
|
+
this.announcementPreviewText = previewText ?? "";
|
|
2791
|
+
this.announcementMarkdown = markdown;
|
|
2792
|
+
this.hasUnseenAnnouncement = (!storedTimestamp || storedTimestamp !== timestamp) && !!this.announcementPreviewText;
|
|
2793
|
+
this.showAnnouncementPreview = this.hasUnseenAnnouncement;
|
|
2794
|
+
this.announcementHtml = await this.convertMarkdownToHtml(markdown);
|
|
2795
|
+
this.announcementLoaded = true;
|
|
2796
|
+
this.requestUpdate();
|
|
2797
|
+
} catch (error) {
|
|
2798
|
+
this.announcementLoadError = error;
|
|
2799
|
+
this.announcementLoaded = true;
|
|
2800
|
+
this.requestUpdate();
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
async convertMarkdownToHtml(markdown) {
|
|
2804
|
+
const renderer = new marked.Renderer();
|
|
2805
|
+
renderer.link = (href, title, text) => {
|
|
2806
|
+
return `<a href="${this.escapeHtmlAttr(this.appendRefParam(href ?? ""))}" target="_blank" rel="noopener"${title ? ` title="${this.escapeHtmlAttr(title)}"` : ""}>${text}</a>`;
|
|
2807
|
+
};
|
|
2808
|
+
return marked.parse(markdown, { renderer });
|
|
2809
|
+
}
|
|
2810
|
+
appendRefParam(href) {
|
|
2811
|
+
try {
|
|
2812
|
+
const url = new URL(href, typeof window !== "undefined" ? window.location.href : "https://copilotkit.ai");
|
|
2813
|
+
if (!url.searchParams.has("ref")) url.searchParams.append("ref", "cpk-inspector");
|
|
2814
|
+
return url.toString();
|
|
2815
|
+
} catch {
|
|
2816
|
+
return href;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
escapeHtmlAttr(value) {
|
|
2820
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """).replace(/'/g, "'");
|
|
2821
|
+
}
|
|
2822
|
+
loadStoredAnnouncementTimestamp() {
|
|
2823
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
2824
|
+
try {
|
|
2825
|
+
const raw = window.localStorage.getItem(ANNOUNCEMENT_STORAGE_KEY);
|
|
2826
|
+
if (!raw) return null;
|
|
2827
|
+
const parsed = JSON.parse(raw);
|
|
2828
|
+
if (parsed && typeof parsed.timestamp === "string") return parsed.timestamp;
|
|
2829
|
+
return null;
|
|
2830
|
+
} catch {}
|
|
2831
|
+
return null;
|
|
2832
|
+
}
|
|
2833
|
+
persistAnnouncementTimestamp(timestamp) {
|
|
2834
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
2835
|
+
try {
|
|
2836
|
+
const payload = JSON.stringify({ timestamp });
|
|
2837
|
+
window.localStorage.setItem(ANNOUNCEMENT_STORAGE_KEY, payload);
|
|
2838
|
+
} catch {}
|
|
2839
|
+
}
|
|
2840
|
+
markAnnouncementSeen() {
|
|
2841
|
+
this.hasUnseenAnnouncement = false;
|
|
2842
|
+
this.showAnnouncementPreview = false;
|
|
2843
|
+
if (!this.announcementTimestamp) {
|
|
2844
|
+
if (this.announcementPromise && !this.announcementLoaded) this.announcementPromise.then(() => this.markAnnouncementSeen()).catch(() => void 0);
|
|
2845
|
+
this.requestUpdate();
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
this.persistAnnouncementTimestamp(this.announcementTimestamp);
|
|
2849
|
+
this.requestUpdate();
|
|
2850
|
+
}
|
|
3499
2851
|
};
|
|
3500
2852
|
function defineWebInspector() {
|
|
3501
|
-
|
|
3502
|
-
customElements.define(WEB_INSPECTOR_TAG, WebInspectorElement);
|
|
3503
|
-
}
|
|
2853
|
+
if (!customElements.get(WEB_INSPECTOR_TAG)) customElements.define(WEB_INSPECTOR_TAG, WebInspectorElement);
|
|
3504
2854
|
}
|
|
3505
2855
|
defineWebInspector();
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
defineWebInspector
|
|
3510
|
-
};
|
|
2856
|
+
|
|
2857
|
+
//#endregion
|
|
2858
|
+
export { WEB_INSPECTOR_TAG, WebInspectorElement, defineWebInspector };
|
|
3511
2859
|
//# sourceMappingURL=index.mjs.map
|