@copilotkit/web-inspector 1.69.1 → 1.69.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.
Files changed (39) hide show
  1. package/dist/index.cjs +36 -634
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +2 -44
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.mts +2 -44
  6. package/dist/index.d.mts.map +1 -1
  7. package/dist/index.mjs +39 -634
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.umd.js +85 -1253
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/lib/inspector-nav.cjs +0 -1
  12. package/dist/lib/inspector-nav.cjs.map +1 -1
  13. package/dist/lib/inspector-nav.mjs +0 -1
  14. package/dist/lib/inspector-nav.mjs.map +1 -1
  15. package/dist/lib/telemetry.cjs +1 -19
  16. package/dist/lib/telemetry.cjs.map +1 -1
  17. package/dist/lib/telemetry.d.cts.map +1 -1
  18. package/dist/lib/telemetry.d.mts.map +1 -1
  19. package/dist/lib/telemetry.mjs +2 -18
  20. package/dist/lib/telemetry.mjs.map +1 -1
  21. package/dist/package.cjs +1 -1
  22. package/dist/package.mjs +1 -1
  23. package/dist/styles/generated.cjs +1 -1
  24. package/dist/styles/generated.cjs.map +1 -1
  25. package/dist/styles/generated.mjs +1 -1
  26. package/dist/styles/generated.mjs.map +1 -1
  27. package/package.json +3 -3
  28. package/dist/lib/event-snippets.cjs +0 -559
  29. package/dist/lib/event-snippets.cjs.map +0 -1
  30. package/dist/lib/event-snippets.d.cts +0 -61
  31. package/dist/lib/event-snippets.d.cts.map +0 -1
  32. package/dist/lib/event-snippets.d.mts +0 -61
  33. package/dist/lib/event-snippets.d.mts.map +0 -1
  34. package/dist/lib/event-snippets.mjs +0 -537
  35. package/dist/lib/event-snippets.mjs.map +0 -1
  36. package/dist/lib/inspector-nav.d.cts +0 -11
  37. package/dist/lib/inspector-nav.d.cts.map +0 -1
  38. package/dist/lib/inspector-nav.d.mts +0 -11
  39. package/dist/lib/inspector-nav.d.mts.map +0 -1
package/dist/index.mjs CHANGED
@@ -8,14 +8,13 @@ import { projectInspectorMetadata } from "./lib/inspector-metadata.mjs";
8
8
  import { buildHomeModel, runtimeConnectionNeedsAttention } from "./lib/home-briefing.mjs";
9
9
  import { INSPECTOR_GROUPS, INSPECTOR_NAV_SECTIONS, getGroupForMenu, isInspectorMenuKey, shouldUseIconRail } from "./lib/inspector-nav.mjs";
10
10
  import { selectVisibleRealThreadId } from "./lib/thread-selection.mjs";
11
- import { ACTIVITY_STARTERS, compileActivityRecipe, compileChatSnippet, compileFromActivityMessage, compileReasoningRecipe, compileTextRecipe, compileToolCallRecipe, createSnippetId, deleteEventSnippet, editorStateFromSnippet, expandSnippetEventsForRun, exportEventSnippetsJson, groupEventSnippets, importEventSnippets, loadEventSnippets, parseSnippetEvents, recipeIconName, recipeIconWrapClass, recipeLabel, snippetContainsToolCall, snippetJsonIsRunnable, upsertEventSnippet } from "./lib/event-snippets.mjs";
12
- import { TELEMETRY_DOCS_URL, ensureTelemetryDistinctId, getRuntimeUrlType, getTelemetryDistinctIdForUrl, maybeShowDisclosure, trackErrorSignalViewed, trackEventSnippetsRun, trackEventSnippetsSaved, trackHomeCtaClicked, trackHomeViewed, trackInspectorOpened, trackMemoriesTabClicked, trackMetadataActionClicked, trackMetadataModuleViewed, trackTalkToEngineerClicked, trackThreadsEmptyEnabledViewed, trackThreadsEnabledViewed, trackThreadsExampleSelected, trackThreadsExampleTourCompleted, trackThreadsExampleTourDismissed, trackThreadsExampleTourReopened, trackThreadsExampleTourStarted, trackThreadsExampleTourStepViewed, trackThreadsExampleViewed, trackThreadsIntelligenceSignupClicked, trackThreadsLockedViewed, trackThreadsTabClicked, trackThreadsTalkToEngineerClicked, trackWhatsNewClicked, trackWhatsNewSignalViewed, trackWhatsNewViewed } from "./lib/telemetry.mjs";
11
+ import { TELEMETRY_DOCS_URL, ensureTelemetryDistinctId, getRuntimeUrlType, getTelemetryDistinctIdForUrl, maybeShowDisclosure, trackErrorSignalViewed, trackHomeCtaClicked, trackHomeViewed, trackInspectorOpened, trackMemoriesTabClicked, trackMetadataActionClicked, trackMetadataModuleViewed, trackTalkToEngineerClicked, trackThreadsEmptyEnabledViewed, trackThreadsEnabledViewed, trackThreadsExampleSelected, trackThreadsExampleTourCompleted, trackThreadsExampleTourDismissed, trackThreadsExampleTourReopened, trackThreadsExampleTourStarted, trackThreadsExampleTourStepViewed, trackThreadsExampleViewed, trackThreadsIntelligenceSignupClicked, trackThreadsLockedViewed, trackThreadsTabClicked, trackThreadsTalkToEngineerClicked, trackWhatsNewClicked, trackWhatsNewSignalViewed, trackWhatsNewViewed } from "./lib/telemetry.mjs";
13
12
  import { LitElement, css, html, nothing, render, unsafeCSS } from "lit";
14
13
  import { marked } from "marked";
15
14
  import { styleMap } from "lit/directives/style-map.js";
16
15
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
17
16
  import { icons } from "lucide";
18
- import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, createInspectorThreadRequestId, emitInspectorStopViewing, emitInspectorViewThread, isInspectorThreadBridgeEnabled, onInspectorActiveThread, onInspectorViewThreadResult, ɵcreateThreadStore, ɵinjectInspectorEvents, ɵresetInspectorInject, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
17
+ import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, createInspectorThreadRequestId, emitInspectorStopViewing, emitInspectorViewThread, isInspectorThreadBridgeEnabled, onInspectorActiveThread, onInspectorViewThreadResult, ɵcreateThreadStore, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
19
18
 
20
19
  //#region src/index.ts
21
20
  const WEB_INSPECTOR_TAG = "cpk-web-inspector";
@@ -4405,26 +4404,6 @@ var WebInspectorElement = class WebInspectorElement extends LitElement {
4405
4404
  inspect: "ag-ui-events"
4406
4405
  };
4407
4406
  this.lastScrolledAgentNavigationLayout = null;
4408
- this.eventSnippets = [];
4409
- this.selectedSnippetId = null;
4410
- this.snippetRecipe = "tool-call";
4411
- this.snippetName = "";
4412
- this.snippetJson = "[]";
4413
- this.snippetToolName = "";
4414
- this.snippetToolArgs = "{}";
4415
- this.snippetReasoningText = "";
4416
- this.snippetTextContent = "";
4417
- this.snippetActivityType = "a2ui-surface";
4418
- this.snippetActivityContent = "{}";
4419
- this.snippetError = null;
4420
- this.snippetBanner = null;
4421
- this.snippetConfirmOpen = false;
4422
- this.lastInject = null;
4423
- this.snippetListWidth = 200;
4424
- this.snippetDividerResizing = false;
4425
- this.snippetDividerPointerId = -1;
4426
- this.snippetDividerStartX = 0;
4427
- this.snippetDividerStartWidth = 0;
4428
4407
  this.selectedThreadId = null;
4429
4408
  this.inAppThreadId = null;
4430
4409
  this.inAppAgentId = null;
@@ -5025,19 +5004,6 @@ var WebInspectorElement = class WebInspectorElement extends LitElement {
5025
5004
  this.handlePlaygroundStop = () => {
5026
5005
  this.playgroundAgent?.abortRun();
5027
5006
  };
5028
- this.handleSnippetImportChange = async (event) => {
5029
- const input = event.target;
5030
- const file = input.files?.[0];
5031
- input.value = "";
5032
- if (!file) return;
5033
- try {
5034
- this.eventSnippets = importEventSnippets(await file.text());
5035
- this.snippetError = null;
5036
- } catch (error) {
5037
- this.snippetError = error instanceof Error ? error.message : "Import failed.";
5038
- }
5039
- this.requestUpdate();
5040
- };
5041
5007
  this.handleInspectorMetadataActionClick = (action, placement) => {
5042
5008
  if (!this.isOpen || this.runtimeStatus !== CopilotKitCoreRuntimeConnectionStatus.Connected || this.core?.telemetryDisabled) return;
5043
5009
  if (action.kind === "enable_intelligence") {
@@ -5065,26 +5031,6 @@ var WebInspectorElement = class WebInspectorElement extends LitElement {
5065
5031
  if (this.core?.telemetryDisabled) return;
5066
5032
  trackThreadsTalkToEngineerClicked(this.getThreadsCtaTelemetryProps("talk_to_engineer", "threads_locked"));
5067
5033
  };
5068
- this.handleSnippetListDividerPointerDown = (event) => {
5069
- this.snippetDividerResizing = true;
5070
- this.snippetDividerPointerId = event.pointerId;
5071
- this.snippetDividerStartX = event.clientX;
5072
- this.snippetDividerStartWidth = this.snippetListWidth;
5073
- event.currentTarget.setPointerCapture(event.pointerId);
5074
- event.preventDefault();
5075
- };
5076
- this.handleSnippetListDividerPointerMove = (event) => {
5077
- if (!this.snippetDividerResizing || this.snippetDividerPointerId !== event.pointerId) return;
5078
- const delta = event.clientX - this.snippetDividerStartX;
5079
- this.snippetListWidth = Math.max(160, Math.min(360, this.snippetDividerStartWidth + delta));
5080
- this.requestUpdate();
5081
- };
5082
- this.handleSnippetListDividerPointerUp = (event) => {
5083
- if (this.snippetDividerPointerId !== event.pointerId) return;
5084
- const target = event.currentTarget;
5085
- if (target.hasPointerCapture(this.snippetDividerPointerId)) target.releasePointerCapture(this.snippetDividerPointerId);
5086
- this.snippetDividerResizing = false;
5087
- };
5088
5034
  this.handleThreadDividerPointerDown = (event) => {
5089
5035
  this.threadDividerResizing = true;
5090
5036
  this.threadDividerPointerId = event.pointerId;
@@ -5341,11 +5287,6 @@ var WebInspectorElement = class WebInspectorElement extends LitElement {
5341
5287
  label: "AG-UI Events",
5342
5288
  icon: "Zap"
5343
5289
  },
5344
- {
5345
- key: "event-snippets",
5346
- label: "Event Snippets",
5347
- icon: "Code"
5348
- },
5349
5290
  {
5350
5291
  key: "agents",
5351
5292
  label: "Agent",
@@ -6276,19 +6217,6 @@ var WebInspectorElement = class WebInspectorElement extends LitElement {
6276
6217
  this.persistState();
6277
6218
  this.requestUpdate();
6278
6219
  }
6279
- focusEventSnippets(options) {
6280
- this.pendingPersistedMenu = null;
6281
- this.selectedMenu = "event-snippets";
6282
- this.settingsOpen = false;
6283
- this.lastSelectedMenuByGroup.inspect = "event-snippets";
6284
- this.contextMenuOpen = false;
6285
- this.layoutMenuOpen = false;
6286
- this.reloadEventSnippets();
6287
- if (options.snippetId) this.selectEventSnippet(options.snippetId);
6288
- if (options.agentId && this.contextOptions.some((option) => option.key === options.agentId)) this.selectedContext = options.agentId;
6289
- this.persistState();
6290
- this.requestUpdate();
6291
- }
6292
6220
  filterEvents(events) {
6293
6221
  const query = this.eventFilterText.trim().toLowerCase();
6294
6222
  return events.filter((event) => {
@@ -6511,8 +6439,8 @@ ${argsString}</pre
6511
6439
  the two cannot drift apart. A dark grey rather than near-black: the
6512
6440
  launcher sits on a customer's page, and 1,5,7 against white is a
6513
6441
  harder edge than this surface needs. */
6514
- --cpk-launcher-face: rgba(28, 31, 36, 0.95);
6515
- --cpk-launcher-face-solid: rgb(28, 31, 36);
6442
+ --cpk-launcher-face: rgba(24, 28, 31, 0.95);
6443
+ --cpk-launcher-face-solid: rgb(24, 28, 31);
6516
6444
  --cpk-launcher-edge: rgba(190, 194, 255, 0.25);
6517
6445
  /* The launcher's own size, exposed so the signal dot can be placed
6518
6446
  against the OUTER rim with a length rather than a percentage.
@@ -6932,9 +6860,24 @@ ${argsString}</pre
6932
6860
  .console-button {
6933
6861
  background-color: var(--cpk-launcher-face) !important;
6934
6862
  border-color: var(--cpk-launcher-edge) !important;
6863
+ /* One hairline, not two. The border above is it; a second ring used to
6864
+ sit 1px outside as a box-shadow and hardcoded the lilac instead of
6865
+ reading the --cpk-launcher-edge token, so it could not follow it.
6866
+ What replaces it is a one-pixel light edge along the top, which is
6867
+ what keeps the face from reading flat without drawing a frame.
6868
+
6869
+ The border is not decoration: the face is #181C1F, which against a
6870
+ dark host page (GitHub dark 1.10:1, Tailwind slate-900 1.04:1) is
6871
+ indistinguishable from the page. It is the only thing that gives the
6872
+ launcher an outline there, so it stays. */
6935
6873
  box-shadow:
6936
- 0 0 0 1px rgba(190, 194, 255, 0.15),
6874
+ inset 0 1px 0 rgba(255, 255, 255, 0.07),
6937
6875
  0 4px 14px rgba(1, 5, 7, 0.28) !important;
6876
+ /* Promotes the launcher to its own compositing layer, which the
6877
+ backdrop-filter this replaces used to do as a side effect. Without
6878
+ a layer the hover scale re-rasterises the mark every frame and it
6879
+ visibly jitters; with one, the compositor scales it as a texture. */
6880
+ will-change: transform;
6938
6881
  }
6939
6882
  .console-button:hover {
6940
6883
  background-color: var(--cpk-launcher-face-solid) !important;
@@ -7060,8 +7003,23 @@ ${argsString}</pre
7060
7003
  width: 19%;
7061
7004
  height: 19%;
7062
7005
  border-radius: 50%;
7063
- background: var(--cpk-launcher-signal);
7064
- box-shadow: 0 0 0 1.5px var(--cpk-launcher-face);
7006
+ /* Lit from the upper left and shaded at the lower right, so the dot
7007
+ reads as a lens rather than a flat disc. Both stops are derived from
7008
+ the signal colour, so a new tone needs no new values. */
7009
+ background: radial-gradient(
7010
+ circle at 32% 28%,
7011
+ color-mix(in srgb, var(--cpk-launcher-signal), white 40%) 0%,
7012
+ var(--cpk-launcher-signal) 60%,
7013
+ color-mix(in srgb, var(--cpk-launcher-signal), black 20%) 100%
7014
+ );
7015
+ /* Replaces an opaque 1.5px collar in the launcher's own face. That
7016
+ collar was 21% of the dot's footprint, and because the dot's centre
7017
+ sits *on* the rim, its outer half painted a hard dark crescent onto
7018
+ the host page rather than onto the launcher. A hairline plus a soft
7019
+ drop does the same separating job without the hard edge. */
7020
+ box-shadow:
7021
+ 0 0 0 0.5px rgba(1, 5, 7, 0.4),
7022
+ 0 1px 2.5px rgba(1, 5, 7, 0.5);
7065
7023
  }
7066
7024
 
7067
7025
  /* ── Launcher pill: the launcher opens sideways and says what ─── */
@@ -7962,17 +7920,10 @@ ${argsString}</pre
7962
7920
  "justify-center",
7963
7921
  "rounded-full",
7964
7922
  "border",
7965
- "border-white/20",
7966
- "bg-slate-950/95",
7967
7923
  "text-xs",
7968
7924
  "font-medium",
7969
7925
  "text-white",
7970
- "ring-1",
7971
- "ring-white/10",
7972
- "backdrop-blur-md",
7973
7926
  "transition",
7974
- "hover:border-white/30",
7975
- "hover:bg-slate-900/95",
7976
7927
  "hover:scale-105",
7977
7928
  "focus-visible:outline",
7978
7929
  "focus-visible:outline-2",
@@ -9533,8 +9484,7 @@ ${argsString}</pre
9533
9484
  this.draggedDuringInteraction = false;
9534
9485
  }
9535
9486
  openInspector(source, options = {}) {
9536
- if (options.snippetId || options.menu === "event-snippets") this.focusEventSnippets(options);
9537
- else if (options.threadId) this.focusThread(options);
9487
+ if (options.threadId) this.focusThread(options);
9538
9488
  if (this.isPoppedOut) return;
9539
9489
  if (this.isOpen) return;
9540
9490
  const hadUnseenAnnouncement = this.newsSignalArmed;
@@ -9999,549 +9949,6 @@ ${argsString}</pre
9999
9949
  AI can make mistakes. Please verify important information.
10000
9950
  </p>
10001
9951
  </form>
10002
- `;
10003
- }
10004
- reloadEventSnippets() {
10005
- this.eventSnippets = loadEventSnippets();
10006
- }
10007
- renderSnippetImportControl() {
10008
- return html`
10009
- <label
10010
- class="inline-flex shrink-0 cursor-pointer items-center rounded-md border border-gray-300 bg-white px-3 py-1.5 text-[11px] text-gray-700"
10011
- data-testid="cpk-snippet-import"
10012
- >
10013
- Import
10014
- <input
10015
- type="file"
10016
- accept="application/json"
10017
- class="hidden"
10018
- @change=${this.handleSnippetImportChange}
10019
- />
10020
- </label>
10021
- `;
10022
- }
10023
- selectEventSnippet(id) {
10024
- const snippet = this.eventSnippets.find((item) => item.id === id);
10025
- this.selectedSnippetId = id;
10026
- if (!snippet) {
10027
- this.requestUpdate();
10028
- return;
10029
- }
10030
- const editor = editorStateFromSnippet(snippet);
10031
- this.snippetRecipe = editor.recipe;
10032
- this.snippetName = editor.name;
10033
- this.snippetJson = editor.json;
10034
- this.snippetToolName = editor.draft.toolName;
10035
- this.snippetToolArgs = editor.draft.toolArgs;
10036
- this.snippetReasoningText = editor.draft.reasoningText;
10037
- this.snippetTextContent = editor.draft.textContent;
10038
- this.snippetActivityType = editor.draft.activityType;
10039
- this.snippetActivityContent = editor.draft.activityContent;
10040
- this.snippetError = null;
10041
- this.requestUpdate();
10042
- }
10043
- compileSnippetDraft() {
10044
- switch (this.snippetRecipe) {
10045
- case "tool-call": return compileToolCallRecipe({
10046
- toolName: this.snippetToolName,
10047
- argsJson: this.snippetToolArgs,
10048
- threadId: this.getSnippetThreadId(),
10049
- runId: this.getSnippetRunId()
10050
- });
10051
- case "reasoning": return compileReasoningRecipe({
10052
- text: this.snippetReasoningText,
10053
- threadId: this.getSnippetThreadId(),
10054
- runId: this.getSnippetRunId()
10055
- });
10056
- case "text": return compileTextRecipe({
10057
- text: this.snippetTextContent,
10058
- threadId: this.getSnippetThreadId(),
10059
- runId: this.getSnippetRunId()
10060
- });
10061
- case "activity": return compileActivityRecipe({
10062
- activityType: this.snippetActivityType,
10063
- contentJson: this.snippetActivityContent,
10064
- threadId: this.getSnippetThreadId(),
10065
- runId: this.getSnippetRunId()
10066
- });
10067
- case "raw": return parseSnippetEvents(this.snippetJson);
10068
- }
10069
- }
10070
- getSnippetThreadId() {
10071
- return this.selectedThreadId ?? "inspector-snippet";
10072
- }
10073
- getSnippetRunId() {
10074
- return `inspector-snippet-${Date.now()}`;
10075
- }
10076
- getSnippetTargetAgent() {
10077
- const core = this._core;
10078
- if (!core) return null;
10079
- const selected = this.selectedContext !== "all-agents" ? this.selectedContext : null;
10080
- if (selected) return core.getAgent(selected) ?? null;
10081
- const first = this.contextOptions.find((option) => option.key !== "all-agents");
10082
- return first ? core.getAgent(first.key) ?? null : null;
10083
- }
10084
- applyRecipeToEditor() {
10085
- try {
10086
- const events = this.compileSnippetDraft();
10087
- this.snippetJson = JSON.stringify(events, null, 2);
10088
- this.snippetError = null;
10089
- } catch (error) {
10090
- this.snippetError = error instanceof Error ? error.message : "Could not compile recipe.";
10091
- }
10092
- this.requestUpdate();
10093
- }
10094
- handleSnippetRecipeChange(event) {
10095
- const value = event.target.value;
10096
- if (value === "tool-call" || value === "reasoning" || value === "text" || value === "activity" || value === "raw") {
10097
- this.snippetRecipe = value;
10098
- if (value !== "raw") this.applyRecipeToEditor();
10099
- else this.requestUpdate();
10100
- }
10101
- }
10102
- saveCurrentSnippet(source) {
10103
- try {
10104
- const events = parseSnippetEvents(this.snippetJson);
10105
- const now = (/* @__PURE__ */ new Date()).toISOString();
10106
- const snippet = {
10107
- id: this.selectedSnippetId ?? createSnippetId(),
10108
- name: this.snippetName.trim() || recipeLabel(this.snippetRecipe),
10109
- recipe: this.snippetRecipe,
10110
- events,
10111
- createdAt: this.eventSnippets.find((item) => item.id === this.selectedSnippetId)?.createdAt ?? now,
10112
- updatedAt: now
10113
- };
10114
- this.eventSnippets = upsertEventSnippet(snippet);
10115
- this.selectedSnippetId = snippet.id;
10116
- this.snippetBanner = "Snippet saved.";
10117
- this.snippetError = null;
10118
- if (!this.core?.telemetryDisabled) trackEventSnippetsSaved({
10119
- recipe: this.snippetRecipe,
10120
- source,
10121
- success: true
10122
- });
10123
- } catch (error) {
10124
- this.snippetError = error instanceof Error ? error.message : "Could not save snippet.";
10125
- if (!this.core?.telemetryDisabled) trackEventSnippetsSaved({
10126
- recipe: this.snippetRecipe,
10127
- source,
10128
- success: false
10129
- });
10130
- }
10131
- this.requestUpdate();
10132
- }
10133
- async runCurrentSnippet() {
10134
- this.snippetError = null;
10135
- this.snippetBanner = null;
10136
- let events;
10137
- try {
10138
- events = expandSnippetEventsForRun(parseSnippetEvents(this.snippetJson));
10139
- } catch (error) {
10140
- this.snippetError = error instanceof Error ? error.message : "Snippet JSON is invalid.";
10141
- this.requestUpdate();
10142
- return;
10143
- }
10144
- if (snippetContainsToolCall(events) && !this.snippetConfirmOpen) {
10145
- this.snippetConfirmOpen = true;
10146
- this.requestUpdate();
10147
- return;
10148
- }
10149
- this.snippetConfirmOpen = false;
10150
- const core = this._core;
10151
- const agent = this.getSnippetTargetAgent();
10152
- if (!core || !agent) {
10153
- this.snippetError = "No agent is available to inject into.";
10154
- this.requestUpdate();
10155
- return;
10156
- }
10157
- if (agent.isRunning) {
10158
- this.snippetError = "The agent is running. Wait for the current run to end.";
10159
- this.requestUpdate();
10160
- return;
10161
- }
10162
- try {
10163
- const result = await ɵinjectInspectorEvents({
10164
- core,
10165
- agent,
10166
- events
10167
- });
10168
- this.lastInject = {
10169
- snippetId: this.selectedSnippetId ?? "unsaved",
10170
- agentId: agent.agentId ?? "default",
10171
- runId: this.getSnippetRunId(),
10172
- messageIds: result.messageIds
10173
- };
10174
- this.snippetBanner = "Inspector injected these events into the live thread.";
10175
- if (!this.core?.telemetryDisabled) trackEventSnippetsRun({
10176
- recipe: this.snippetRecipe,
10177
- source: "pane",
10178
- success: true
10179
- });
10180
- } catch (error) {
10181
- this.snippetError = error instanceof Error ? error.message : "Could not run snippet.";
10182
- if (!this.core?.telemetryDisabled) trackEventSnippetsRun({
10183
- recipe: this.snippetRecipe,
10184
- source: "pane",
10185
- success: false
10186
- });
10187
- }
10188
- this.requestUpdate();
10189
- }
10190
- resetLastSnippetRun() {
10191
- const last = this.lastInject;
10192
- const core = this._core;
10193
- if (!last || !core) return;
10194
- const agent = core.getAgent(last.agentId);
10195
- if (!agent) {
10196
- this.snippetError = "The injected agent is no longer available.";
10197
- this.requestUpdate();
10198
- return;
10199
- }
10200
- ɵresetInspectorInject({
10201
- agent,
10202
- messageIds: last.messageIds
10203
- });
10204
- this.lastInject = null;
10205
- this.snippetBanner = "Last inject was removed from the thread. App state from a tool handler was not undone.";
10206
- this.requestUpdate();
10207
- }
10208
- renderEventSnippetsView() {
10209
- if (this.eventSnippets.length === 0 && this.selectedSnippetId === null) this.reloadEventSnippets();
10210
- const agent = this.getSnippetTargetAgent();
10211
- const runBlocked = agent?.isRunning === true;
10212
- const canRunJson = snippetJsonIsRunnable(this.snippetJson);
10213
- const canRun = canRunJson && !!agent && !runBlocked;
10214
- const canSave = canRunJson;
10215
- const canDelete = this.selectedSnippetId !== null;
10216
- const canExport = this.eventSnippets.length > 0;
10217
- const canReset = this.lastInject !== null;
10218
- const snippetGroups = groupEventSnippets(this.eventSnippets);
10219
- const tools = this._core?.tools ?? [];
10220
- return html`
10221
- <div class="flex h-full min-h-0 flex-col bg-white">
10222
- <div
10223
- class="flex items-center justify-between gap-4 border-b border-gray-200 px-4 py-3"
10224
- >
10225
- <div class="min-w-0">
10226
- <h2 class="text-sm font-semibold text-gray-900">Event Snippets</h2>
10227
- <p class="mt-1 text-[11px] text-gray-500">
10228
- Compile AG-UI events, run them on the live agent, and save them
10229
- for later. Tool-call runs use the real frontend-tool handler.
10230
- </p>
10231
- </div>
10232
- ${this.renderSnippetImportControl()}
10233
- </div>
10234
- ${this.snippetBanner ? html`<div
10235
- class="border-b border-emerald-200 bg-emerald-50 px-4 py-2 text-[11px] text-emerald-800"
10236
- role="status"
10237
- >
10238
- ${this.snippetBanner}
10239
- </div>` : nothing}
10240
- ${this.snippetError ? html`<div
10241
- class="border-b border-rose-200 bg-rose-50 px-4 py-2 text-[11px] text-rose-800"
10242
- role="alert"
10243
- >
10244
- ${this.snippetError}
10245
- </div>` : nothing}
10246
- ${this.snippetConfirmOpen ? html`<div
10247
- class="border-b border-amber-200 bg-amber-50 px-4 py-2 text-[11px] text-amber-900"
10248
- role="alertdialog"
10249
- aria-label="Confirm tool-call run"
10250
- >
10251
- <p>
10252
- This snippet contains a tool call. Run will execute the real
10253
- handler on the live thread.
10254
- </p>
10255
- <div class="mt-2 flex gap-2">
10256
- <button
10257
- type="button"
10258
- class="rounded-md bg-gray-900 px-2 py-1 text-[11px] text-white"
10259
- data-testid="cpk-snippet-run-handler"
10260
- @click=${() => {
10261
- this.snippetConfirmOpen = true;
10262
- this.runCurrentSnippet();
10263
- }}
10264
- >
10265
- Run handler
10266
- </button>
10267
- <button
10268
- type="button"
10269
- class="rounded-md border border-gray-300 bg-white px-2 py-1 text-[11px]"
10270
- @click=${() => {
10271
- this.snippetConfirmOpen = false;
10272
- this.requestUpdate();
10273
- }}
10274
- >
10275
- Cancel
10276
- </button>
10277
- </div>
10278
- </div>` : nothing}
10279
- <div class="flex min-h-0 flex-1">
10280
- <div
10281
- class="inspector-snippet-sidebar shrink-0"
10282
- style="width:${this.snippetListWidth}px"
10283
- data-testid="cpk-snippet-list"
10284
- >
10285
- ${snippetGroups.length === 0 ? html`
10286
- <p class="px-2 py-2 text-[11px] text-gray-500">No saved snippets yet.</p>
10287
- ` : html`
10288
- <nav class="inspector-sidebar-nav" aria-label="Saved snippets">
10289
- ${snippetGroups.map((group) => html`
10290
- <div class="inspector-sidebar-section">
10291
- <div
10292
- class="inspector-sidebar-label"
10293
- data-testid="cpk-snippet-category"
10294
- data-recipe=${group.recipe}
10295
- >
10296
- ${group.label}
10297
- </div>
10298
- ${group.snippets.map((snippet) => {
10299
- const isSelected = snippet.id === this.selectedSnippetId;
10300
- return html`
10301
- <button
10302
- type="button"
10303
- class="inspector-nav-control inspector-sidebar-control ${isSelected ? "inspector-nav-control-active" : ""}"
10304
- data-testid="cpk-snippet-item"
10305
- data-recipe=${snippet.recipe}
10306
- aria-current=${isSelected ? "page" : nothing}
10307
- aria-label="${recipeLabel(snippet.recipe)}: ${snippet.name}"
10308
- style=${INTERACTIVE_FOCUS_BASE_STYLE}
10309
- @click=${() => this.selectEventSnippet(snippet.id)}
10310
- >
10311
- <span
10312
- class="inspector-nav-icon"
10313
- aria-hidden="true"
10314
- >
10315
- <span
10316
- class="flex h-6 w-6 items-center justify-center rounded-md ${recipeIconWrapClass(snippet.recipe)}"
10317
- >
10318
- ${this.renderIcon(recipeIconName(snippet.recipe))}
10319
- </span>
10320
- </span>
10321
- <span class="inspector-nav-label"
10322
- >${snippet.name}</span
10323
- >
10324
- </button>
10325
- `;
10326
- })}
10327
- </div>
10328
- `)}
10329
- </nav>
10330
- `}
10331
- </div>
10332
- <div
10333
- class="w-1.5 shrink-0 cursor-col-resize bg-gray-200 hover:bg-gray-400"
10334
- role="separator"
10335
- aria-orientation="vertical"
10336
- aria-label="Resize snippet list"
10337
- title="Drag to resize"
10338
- data-testid="cpk-snippet-list-resize"
10339
- style="touch-action:none"
10340
- @pointerdown=${this.handleSnippetListDividerPointerDown}
10341
- @pointermove=${this.handleSnippetListDividerPointerMove}
10342
- @pointerup=${this.handleSnippetListDividerPointerUp}
10343
- @pointercancel=${this.handleSnippetListDividerPointerUp}
10344
- ></div>
10345
- <div class="flex min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-auto p-4">
10346
- <label class="text-[11px] text-gray-600">
10347
- Name
10348
- <input
10349
- class="mt-1 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10350
- data-testid="cpk-snippet-name"
10351
- .value=${this.snippetName}
10352
- @input=${(event) => {
10353
- this.snippetName = event.target.value;
10354
- }}
10355
- />
10356
- </label>
10357
- <label class="text-[11px] text-gray-600">
10358
- Recipe
10359
- <select
10360
- class="mt-1 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10361
- data-testid="cpk-snippet-recipe"
10362
- .value=${this.snippetRecipe}
10363
- @change=${this.handleSnippetRecipeChange}
10364
- >
10365
- ${[
10366
- "tool-call",
10367
- "reasoning",
10368
- "text",
10369
- "activity",
10370
- "raw"
10371
- ].map((recipe) => html`<option
10372
- value=${recipe}
10373
- ?selected=${recipe === this.snippetRecipe}
10374
- >
10375
- ${recipeLabel(recipe)}
10376
- </option>`)}
10377
- </select>
10378
- </label>
10379
- ${this.snippetRecipe === "tool-call" ? html`
10380
- <label class="text-[11px] text-gray-600">
10381
- Tool
10382
- <input
10383
- list="cpk-snippet-tools"
10384
- class="mt-1 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10385
- data-testid="cpk-snippet-tool-name"
10386
- .value=${this.snippetToolName}
10387
- @input=${(event) => {
10388
- this.snippetToolName = event.target.value;
10389
- this.applyRecipeToEditor();
10390
- }}
10391
- />
10392
- <datalist id="cpk-snippet-tools">
10393
- ${tools.map((tool) => html`<option value=${tool.name}></option>`)}
10394
- </datalist>
10395
- </label>
10396
- <label class="text-[11px] text-gray-600">
10397
- Args JSON
10398
- <textarea
10399
- class="mt-1 h-20 w-full rounded-md border border-gray-200 px-2 py-1 font-mono text-[11px]"
10400
- data-testid="cpk-snippet-tool-args"
10401
- .value=${this.snippetToolArgs}
10402
- @input=${(event) => {
10403
- this.snippetToolArgs = event.target.value;
10404
- this.applyRecipeToEditor();
10405
- }}
10406
- ></textarea>
10407
- </label>
10408
- ` : nothing}
10409
- ${this.snippetRecipe === "reasoning" ? html`<label class="text-[11px] text-gray-600">
10410
- Reasoning
10411
- <textarea
10412
- class="mt-1 h-20 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10413
- data-testid="cpk-snippet-reasoning"
10414
- .value=${this.snippetReasoningText}
10415
- @input=${(event) => {
10416
- this.snippetReasoningText = event.target.value;
10417
- this.applyRecipeToEditor();
10418
- }}
10419
- ></textarea>
10420
- </label>` : nothing}
10421
- ${this.snippetRecipe === "text" ? html`<label class="text-[11px] text-gray-600">
10422
- Assistant text
10423
- <textarea
10424
- class="mt-1 h-20 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10425
- data-testid="cpk-snippet-text"
10426
- .value=${this.snippetTextContent}
10427
- @input=${(event) => {
10428
- this.snippetTextContent = event.target.value;
10429
- this.applyRecipeToEditor();
10430
- }}
10431
- ></textarea>
10432
- </label>` : nothing}
10433
- ${this.snippetRecipe === "activity" ? html`
10434
- <label class="text-[11px] text-gray-600">
10435
- Activity type
10436
- <input
10437
- list="cpk-snippet-activity"
10438
- class="mt-1 w-full rounded-md border border-gray-200 px-2 py-1 text-[11px]"
10439
- data-testid="cpk-snippet-activity-type"
10440
- .value=${this.snippetActivityType}
10441
- @input=${(event) => {
10442
- this.snippetActivityType = event.target.value;
10443
- this.applyRecipeToEditor();
10444
- }}
10445
- />
10446
- <datalist id="cpk-snippet-activity">
10447
- ${ACTIVITY_STARTERS.map((type) => html`<option value=${type}></option>`)}
10448
- </datalist>
10449
- </label>
10450
- <label class="text-[11px] text-gray-600">
10451
- Content JSON
10452
- <textarea
10453
- class="mt-1 h-24 w-full rounded-md border border-gray-200 px-2 py-1 font-mono text-[11px]"
10454
- data-testid="cpk-snippet-activity-content"
10455
- .value=${this.snippetActivityContent}
10456
- @input=${(event) => {
10457
- this.snippetActivityContent = event.target.value;
10458
- this.applyRecipeToEditor();
10459
- }}
10460
- ></textarea>
10461
- </label>
10462
- ` : nothing}
10463
- <label class="text-[11px] text-gray-600">
10464
- Events JSON
10465
- <textarea
10466
- class="mt-1 h-40 w-full rounded-md border border-gray-200 px-2 py-1 font-mono text-[11px]"
10467
- data-testid="cpk-snippet-json"
10468
- .value=${this.snippetJson}
10469
- @input=${(event) => {
10470
- this.snippetJson = event.target.value;
10471
- this.requestUpdate();
10472
- }}
10473
- ></textarea>
10474
- </label>
10475
- <div class="flex flex-wrap gap-2">
10476
- <button
10477
- type="button"
10478
- class="rounded-md bg-gray-900 px-3 py-1.5 text-[11px] text-white disabled:opacity-50"
10479
- data-testid="cpk-snippet-run"
10480
- ?disabled=${!canRun}
10481
- title=${runBlocked ? "The agent is running. Wait for the current run to end." : !agent ? "No agent is available to inject into." : !canRunJson ? "Events JSON must be a non-empty event array." : "Run snippet"}
10482
- @click=${() => void this.runCurrentSnippet()}
10483
- >
10484
- ${runBlocked ? "Agent running" : "Run"}
10485
- </button>
10486
- <button
10487
- type="button"
10488
- class="rounded-md border border-gray-300 bg-white px-3 py-1.5 text-[11px] disabled:opacity-50"
10489
- data-testid="cpk-snippet-save"
10490
- ?disabled=${!canSave}
10491
- title=${canSave ? "Save snippet" : "Events JSON must be a non-empty event array."}
10492
- @click=${() => this.saveCurrentSnippet("pane")}
10493
- >
10494
- Save
10495
- </button>
10496
- <button
10497
- type="button"
10498
- class="rounded-md border border-gray-300 bg-white px-3 py-1.5 text-[11px] disabled:opacity-50"
10499
- data-testid="cpk-snippet-reset"
10500
- ?disabled=${!canReset}
10501
- title=${canReset ? "Remove the last inject from the thread" : "No Inspector inject to reset."}
10502
- @click=${() => this.resetLastSnippetRun()}
10503
- >
10504
- Reset last run
10505
- </button>
10506
- <button
10507
- type="button"
10508
- class="rounded-md border border-gray-300 bg-white px-3 py-1.5 text-[11px] disabled:opacity-50"
10509
- data-testid="cpk-snippet-delete"
10510
- ?disabled=${!canDelete}
10511
- title=${canDelete ? "Delete this snippet" : "Select a snippet to delete."}
10512
- @click=${() => {
10513
- if (!this.selectedSnippetId) return;
10514
- if (!window.confirm("Delete this snippet?")) return;
10515
- this.eventSnippets = deleteEventSnippet(this.selectedSnippetId);
10516
- this.selectedSnippetId = null;
10517
- this.requestUpdate();
10518
- }}
10519
- >
10520
- Delete
10521
- </button>
10522
- <button
10523
- type="button"
10524
- class="rounded-md border border-gray-300 bg-white px-3 py-1.5 text-[11px] disabled:opacity-50"
10525
- data-testid="cpk-snippet-export"
10526
- ?disabled=${!canExport}
10527
- title=${canExport ? "Export snippets" : "Save a snippet before you export."}
10528
- @click=${() => {
10529
- if (!canExport) return;
10530
- const blob = new Blob([exportEventSnippetsJson(this.eventSnippets)], { type: "application/json" });
10531
- const url = URL.createObjectURL(blob);
10532
- const link = document.createElement("a");
10533
- link.href = url;
10534
- link.download = "event-snippets.json";
10535
- link.click();
10536
- URL.revokeObjectURL(url);
10537
- }}
10538
- >
10539
- Export
10540
- </button>
10541
- </div>
10542
- </div>
10543
- </div>
10544
- </div>
10545
9952
  `;
10546
9953
  }
10547
9954
  renderMainContent() {
@@ -10557,7 +9964,6 @@ ${argsString}</pre
10557
9964
  </div>
10558
9965
  `;
10559
9966
  if (this.selectedMenu === "playground") return this.renderPlaygroundView();
10560
- if (this.selectedMenu === "event-snippets") return this.renderEventSnippetsView();
10561
9967
  if (this.selectedMenu === "agents") return this.renderAgentsView();
10562
9968
  if (this.selectedMenu === "frontend-tools") return this.renderToolsView();
10563
9969
  if (this.selectedMenu === "capabilities") return this.renderCapabilitiesView();
@@ -12764,7 +12170,6 @@ ${prettyEvent}</pre
12764
12170
  if (previousMenu !== "memories" && !this.core?.telemetryDisabled) trackMemoriesTabClicked(this.getMemoriesTelemetryProps());
12765
12171
  }
12766
12172
  if (key === "home" && previousMenu !== "home") this.homeViewedThisOpen = false;
12767
- if (key === "event-snippets") this.reloadEventSnippets();
12768
12173
  if (key === "ag-ui-events" || key === "agents") {
12769
12174
  if (!(this.pendingScrollToEventId !== null || this.pendingScrollToToolCallId !== null)) requestAnimationFrame(() => {
12770
12175
  const scroller = this.activeRoot.querySelector("#cpk-main-scroll");
@@ -14025,5 +13430,5 @@ function defineWebInspector(registry = globalThis.customElements) {
14025
13430
  defineWebInspector();
14026
13431
 
14027
13432
  //#endregion
14028
- export { CpkThreadInspector, THREAD_INSPECTOR_TAG, WEB_INSPECTOR_TAG, WebInspectorElement, compileChatSnippet, compileFromActivityMessage, defineWebInspector, upsertEventSnippet, ɵCpkThreadDetails, buildCapabilityRows as ɵbuildCapabilityRows, maxRecallScore as ɵmaxRecallScore, normalizeRelevance as ɵnormalizeRelevance, relevanceBarWidth as ɵrelevanceBarWidth };
13433
+ export { CpkThreadInspector, THREAD_INSPECTOR_TAG, WEB_INSPECTOR_TAG, WebInspectorElement, defineWebInspector, ɵCpkThreadDetails, buildCapabilityRows as ɵbuildCapabilityRows, maxRecallScore as ɵmaxRecallScore, normalizeRelevance as ɵnormalizeRelevance, relevanceBarWidth as ɵrelevanceBarWidth };
14029
13434
  //# sourceMappingURL=index.mjs.map