@copilotkit/web-inspector 1.77.0 → 1.77.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -30,13 +30,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30
30
  intelligence: ["enabled", "disabled"],
31
31
  deployment: ["managed", "self-hosted"]
32
32
  };
33
- function record(value) {
33
+ function record$1(value) {
34
34
  return value !== null && typeof value === "object" && !Array.isArray(value);
35
35
  }
36
- function onlyKeys(value, keys) {
36
+ function onlyKeys$1(value, keys) {
37
37
  return Object.keys(value).every((key) => keys.includes(key));
38
38
  }
39
- function text(value, max = 256) {
39
+ function text$1(value, max = 256) {
40
40
  return typeof value === "string" && value.trim().length > 0 && value.length <= max;
41
41
  }
42
42
  function isNotificationId(value) {
@@ -47,11 +47,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
47
  }
48
48
  /** Validate authored conditions; unsupported predicates cannot broaden the audience. */
49
49
  function validNotificationConditions(value) {
50
- if (!record(value)) return false;
50
+ if (!record$1(value)) return false;
51
51
  if (value.sdkVersion !== void 0 && value.framework === void 0) return false;
52
52
  return Object.entries(value).every(([key, expected]) => {
53
53
  var _conditionValues$key$, _conditionValues$key;
54
- if (!text(expected)) return false;
54
+ if (!text$1(expected)) return false;
55
55
  if (key === "sdkVersion") return (0, semver.validRange)(expected) !== null;
56
56
  if (key === "plan") return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(expected);
57
57
  return Object.prototype.hasOwnProperty.call(conditionValues, key) && ((_conditionValues$key$ = (_conditionValues$key = conditionValues[key]) === null || _conditionValues$key === void 0 ? void 0 : _conditionValues$key.includes(expected)) !== null && _conditionValues$key$ !== void 0 ? _conditionValues$key$ : false);
@@ -59,11 +59,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
59
59
  }
60
60
  /** Parse the public envelope. Any invalid entry rejects the whole feed. */
61
61
  function parseNotificationFeed(value) {
62
- if (!record(value) || !onlyKeys(value, ["schemaVersion", "notifications"]) || value.schemaVersion !== 1) return null;
62
+ if (!record$1(value) || !onlyKeys$1(value, ["schemaVersion", "notifications"]) || value.schemaVersion !== 1) return null;
63
63
  if (!Array.isArray(value.notifications) || value.notifications.length > 100) return null;
64
64
  const notifications = [];
65
65
  for (const notice of value.notifications) {
66
- if (!record(notice) || !onlyKeys(notice, [
66
+ if (!record$1(notice) || !onlyKeys$1(notice, [
67
67
  "id",
68
68
  "title",
69
69
  "body",
@@ -72,10 +72,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
72
72
  "priority",
73
73
  "priorityOverride"
74
74
  ])) return null;
75
- if (!isNotificationId(notice.id) || !text(notice.title) || !text(notice.body, 1e5) || !text(notice.publishedAt)) return null;
75
+ if (!isNotificationId(notice.id) || !text$1(notice.title) || !text$1(notice.body, 1e5) || !text$1(notice.publishedAt)) return null;
76
76
  if (!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(notice.publishedAt) || !Number.isFinite(Date.parse(notice.publishedAt)) || new Date(notice.publishedAt).toISOString() !== notice.publishedAt) return null;
77
77
  if (!Array.isArray(notice.audiences) || !notice.audiences.length || notice.audiences.length > 100 || !notice.audiences.every(validNotificationConditions)) return null;
78
- if (!text(notice.priority) || !Object.prototype.hasOwnProperty.call(priorities, notice.priority)) return null;
78
+ if (!text$1(notice.priority) || !Object.prototype.hasOwnProperty.call(priorities, notice.priority)) return null;
79
79
  if (notice.priorityOverride !== void 0 && (typeof notice.priorityOverride !== "number" || !Number.isSafeInteger(notice.priorityOverride) || notice.priorityOverride < 0)) return null;
80
80
  if (notifications.some((n) => n.id === notice.id)) return null;
81
81
  notifications.push({
@@ -95,7 +95,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
95
95
  }
96
96
  /** Ignore malformed or incompatible browser state. */
97
97
  function parseNotificationState(value) {
98
- if (!record(value) || value.schemaVersion !== 1 || !ids(value.eligibleIds) || !ids(value.readIds) || !ids(value.suppressedIds) || value.activeId !== null && !isNotificationId(value.activeId)) return null;
98
+ if (!record$1(value) || value.schemaVersion !== 1 || !ids(value.eligibleIds) || !ids(value.readIds) || !ids(value.suppressedIds) || value.activeId !== null && !isNotificationId(value.activeId)) return null;
99
99
  return {
100
100
  schemaVersion: 1,
101
101
  eligibleIds: value.eligibleIds,
@@ -205,6 +205,135 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
205
205
  return request;
206
206
  }
207
207
 
208
+ //#endregion
209
+ //#region src/lib/hud-config.ts
210
+ const HUD_FEATURE_IDS = ["threads", "learning"];
211
+ const HUD_LABEL_MAX_LENGTH = 32;
212
+ const HUD_DESCRIPTION_MAX_LENGTH = 140;
213
+ const frameworkPattern = /^[a-z][a-z0-9-]{0,31}$/;
214
+ const featureIdPattern = /^[a-z][a-z0-9-]{0,31}$/;
215
+ const destinationPattern = /^[a-z][a-z0-9-]{0,63}$/;
216
+ const controlCharacters = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
217
+ function record(value) {
218
+ return value !== null && typeof value === "object" && !Array.isArray(value);
219
+ }
220
+ function onlyKeys(value, keys) {
221
+ return Object.keys(value).every((key) => keys.includes(key));
222
+ }
223
+ function text(value, max) {
224
+ return typeof value === "string" && value.trim().length > 0 && value.length <= max && !controlCharacters.test(value);
225
+ }
226
+ function parseFeature(value) {
227
+ if (!record(value) || !Object.keys(value).length || !onlyKeys(value, [
228
+ "label",
229
+ "description",
230
+ "destination"
231
+ ])) return null;
232
+ if (value.label !== void 0 && !text(value.label, HUD_LABEL_MAX_LENGTH)) return null;
233
+ if (value.description !== void 0 && !text(value.description, HUD_DESCRIPTION_MAX_LENGTH)) return null;
234
+ if (value.destination !== void 0 && (typeof value.destination !== "string" || !destinationPattern.test(value.destination))) return null;
235
+ return {
236
+ ...value.label === void 0 ? {} : { label: value.label },
237
+ ...value.description === void 0 ? {} : { description: value.description },
238
+ ...value.destination === void 0 ? {} : { destination: value.destination }
239
+ };
240
+ }
241
+ function parseRule(value) {
242
+ if (!record(value) || !onlyKeys(value, [
243
+ "framework",
244
+ "sdkVersion",
245
+ "features"
246
+ ]) || typeof value.framework !== "string" || !frameworkPattern.test(value.framework) || !text(value.sdkVersion, 256) || (0, semver.validRange)(value.sdkVersion) === null || !record(value.features) || !Object.keys(value.features).length) return null;
247
+ const features = {};
248
+ for (const [id, entry] of Object.entries(value.features)) {
249
+ if (!featureIdPattern.test(id)) return null;
250
+ const feature = parseFeature(entry);
251
+ if (!feature) return null;
252
+ features[id] = feature;
253
+ }
254
+ return {
255
+ framework: value.framework,
256
+ sdkVersion: value.sdkVersion,
257
+ features
258
+ };
259
+ }
260
+ /** Parse the public envelope. Any invalid entry rejects the whole feed. */
261
+ function parseHudFeed(value) {
262
+ if (!record(value) || !onlyKeys(value, ["schemaVersion", "rules"]) || value.schemaVersion !== 1 || !Array.isArray(value.rules) || value.rules.length > 100) return null;
263
+ const rules = [];
264
+ for (const entry of value.rules) {
265
+ const rule = parseRule(entry);
266
+ if (!rule) return null;
267
+ rules.push(rule);
268
+ }
269
+ return {
270
+ schemaVersion: 1,
271
+ rules
272
+ };
273
+ }
274
+ /** Return the first rule for a development client with a known stable SDK. */
275
+ function matchHudRule(feed, context) {
276
+ var _feed$rules$find;
277
+ const { development, framework, sdkVersion } = context;
278
+ if (!development || !framework || !sdkVersion || (0, semver.valid)(sdkVersion) === null || (0, semver.prerelease)(sdkVersion) !== null) return null;
279
+ return (_feed$rules$find = feed.rules.find((rule) => rule.framework === framework && (0, semver.satisfies)(sdkVersion, rule.sdkVersion))) !== null && _feed$rules$find !== void 0 ? _feed$rules$find : null;
280
+ }
281
+ /** Overlay the matching rule on the built-in content, field by field. */
282
+ function resolveHudContent(feed, context, options) {
283
+ const rule = feed ? matchHudRule(feed, context) : null;
284
+ const content = {};
285
+ for (const id of HUD_FEATURE_IDS) {
286
+ var _override$label, _override$description;
287
+ const fallback = options.defaults[id];
288
+ const override = rule === null || rule === void 0 ? void 0 : rule.features[id];
289
+ content[id] = {
290
+ label: (_override$label = override === null || override === void 0 ? void 0 : override.label) !== null && _override$label !== void 0 ? _override$label : fallback.label,
291
+ description: (_override$description = override === null || override === void 0 ? void 0 : override.description) !== null && _override$description !== void 0 ? _override$description : fallback.description,
292
+ destination: (override === null || override === void 0 ? void 0 : override.destination) !== void 0 && options.supportedDestinations.includes(override.destination) ? override.destination : fallback.destination
293
+ };
294
+ }
295
+ return content;
296
+ }
297
+
298
+ //#endregion
299
+ //#region src/lib/hud-loader.ts
300
+ const HUD_FEED_URL = "https://cdn.copilotkit.ai/inspector-hud/v1.json";
301
+ let request = null;
302
+ /** Load the HUD feed once per page. The request carries no client data. */
303
+ function loadHudFeed() {
304
+ var _request;
305
+ if (typeof window === "undefined" || typeof fetch === "undefined") return Promise.resolve(null);
306
+ (_request = request) !== null && _request !== void 0 || (request = Promise.resolve().then(() => fetch(HUD_FEED_URL, {
307
+ cache: "no-cache",
308
+ credentials: "omit"
309
+ })).then(async (response) => {
310
+ if (!response.ok) throw new Error(`Feed request failed (${response.status})`);
311
+ const feed = parseHudFeed(await response.json());
312
+ if (!feed) throw new Error("Feed failed validation");
313
+ return feed;
314
+ }).catch((error) => {
315
+ console.warn("[CopilotKit Inspector] Failed to load HUD content", error);
316
+ return null;
317
+ }));
318
+ return request;
319
+ }
320
+
321
+ //#endregion
322
+ //#region src/lib/hud-defaults.ts
323
+ /** Built-in HUD copy and destinations; a matching feed rule overrides fields. */
324
+ const HUD_DEFAULT_CONTENT = {
325
+ threads: {
326
+ label: "Rich Threads",
327
+ description: "Click to learn more",
328
+ destination: "threads"
329
+ },
330
+ learning: {
331
+ label: "Automatic Learning",
332
+ description: "Click to learn more",
333
+ destination: "memories"
334
+ }
335
+ };
336
+
208
337
  //#endregion
209
338
  //#region src/lib/persistence.ts
210
339
  function loadInspectorState(storageKey) {
@@ -2935,7 +3064,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2935
3064
 
2936
3065
  //#endregion
2937
3066
  //#region package.json
2938
- var version = "1.77.0";
3067
+ var version = "1.77.1";
2939
3068
 
2940
3069
  //#endregion
2941
3070
  //#region src/lib/telemetry.ts
@@ -3601,9 +3730,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3601
3730
  const PILL_SUBLINE_LABEL = "Open Inspector for details";
3602
3731
  const HUD_INSPECTOR_LABEL = "CopilotKit Inspector";
3603
3732
  const HUD_ANNOUNCEMENT_TITLE_LIMIT = 80;
3604
- const HUD_THREADS_LABEL = "Rich Threads";
3605
- const HUD_LEARNING_LABEL = "Automatic Learning";
3606
- const HUD_LEARN_MORE_LABEL = "Click to learn more";
3607
3733
  const INSPECTOR_DISMISSAL_MS = {
3608
3734
  day: 1440 * 60 * 1e3,
3609
3735
  week: 10080 * 60 * 1e3,
@@ -8744,6 +8870,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
8744
8870
  this.announcementId = null;
8745
8871
  this.announcementLoaded = false;
8746
8872
  this.announcementPromise = null;
8873
+ this.hudFeed = null;
8874
+ this.hudFeedPromise = null;
8875
+ this.hudContent = HUD_DEFAULT_CONTENT;
8747
8876
  this.newsSignalArmed = false;
8748
8877
  this.pulsingSignal = null;
8749
8878
  this.pendingPulseSignal = null;
@@ -9091,7 +9220,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
9091
9220
  control,
9092
9221
  trigger
9093
9222
  }));
9094
- this.hudLandingMenu = row === "threads" ? "threads" : row === "learning" ? "memories" : "home";
9223
+ const destination = this.hudContent[row].destination;
9224
+ this.hudLandingMenu = isInspectorMenuKey(destination) && this.menuItems.some((item) => item.key === destination) ? destination : row === "threads" ? "threads" : "memories";
9095
9225
  this.closeLauncherHud();
9096
9226
  this.openInspector("floating_button");
9097
9227
  };
@@ -11239,7 +11369,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11239
11369
  <div data-inspector-portal-anchor></div>
11240
11370
  ` : this.renderButton();
11241
11371
  }
11242
- willUpdate() {
11372
+ willUpdate(changed) {
11373
+ if (changed.has("notificationContext")) this.refreshHudContent();
11243
11374
  this.evaluateErrorSignals();
11244
11375
  this.reconcileSelectedMenuVisibility();
11245
11376
  if (this.isOpen && this.dockMode === "docked-left") this.setAttribute("data-docked", "true");
@@ -11630,6 +11761,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11630
11761
  renderHudRow(args) {
11631
11762
  if (args.connected) return lit.nothing;
11632
11763
  const detailId = `cpk-hud-detail-${args.id}`;
11764
+ const { label, description } = this.hudContent[args.id];
11633
11765
  return lit.html`
11634
11766
  <li
11635
11767
  class="cpk-launcher-hud__row"
@@ -11643,7 +11775,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11643
11775
  type="button"
11644
11776
  class="cpk-launcher-hud__action"
11645
11777
  data-cpk-hud-action
11646
- aria-label=${`Open ${args.label} in Inspector`}
11778
+ aria-label=${`Open ${label} in Inspector`}
11647
11779
  @click=${(event) => this.handleHudActionClick(event, args.id, "action")}
11648
11780
  @pointerdown=${(event) => event.stopPropagation()}
11649
11781
  >
@@ -11653,13 +11785,13 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11653
11785
  aria-hidden="true"
11654
11786
  >${this.renderIcon(args.icon)}</span
11655
11787
  >
11656
- <span class="cpk-launcher-hud__label">${args.label}</span>
11788
+ <span class="cpk-launcher-hud__label">${label}</span>
11657
11789
  </button>
11658
11790
  <span
11659
11791
  class="cpk-launcher-hud__tooltip"
11660
11792
  id=${detailId}
11661
11793
  role="tooltip"
11662
- >${HUD_LEARN_MORE_LABEL}</span
11794
+ >${description}</span
11663
11795
  >
11664
11796
  </span>
11665
11797
  <span class="cpk-launcher-hud__controls">
@@ -11667,7 +11799,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11667
11799
  type="button"
11668
11800
  class="cpk-launcher-hud__learn-more"
11669
11801
  data-cpk-hud-learn-more=${args.id}
11670
- aria-label=${`Learn more about ${args.label}`}
11802
+ aria-label=${`Learn more about ${label}`}
11671
11803
  aria-describedby=${detailId}
11672
11804
  @click=${(event) => this.handleHudActionClick(event, args.id, "learn_more")}
11673
11805
  @pointerdown=${(event) => event.stopPropagation()}
@@ -11679,7 +11811,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11679
11811
  class="cpk-launcher-hud__toggle"
11680
11812
  data-cpk-hud-toggle=${args.id}
11681
11813
  data-enabled=${args.connected ? "true" : "false"}
11682
- aria-label=${args.connected ? `${args.label} is enabled` : `Open ${args.label} in Inspector`}
11814
+ aria-label=${args.connected ? `${label} is enabled` : `Open ${label} in Inspector`}
11683
11815
  ?disabled=${args.connected}
11684
11816
  @click=${(event) => this.handleHudActionClick(event, args.id, "toggle")}
11685
11817
  @pointerdown=${(event) => event.stopPropagation()}
@@ -11765,14 +11897,12 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
11765
11897
  >
11766
11898
  ${this.renderHudRow({
11767
11899
  id: "threads",
11768
- label: HUD_THREADS_LABEL,
11769
11900
  icon: "MessageSquare",
11770
11901
  connected: threadsOn,
11771
11902
  introIndex: featureBlockIntroIndex + 1
11772
11903
  })}
11773
11904
  ${this.renderHudRow({
11774
11905
  id: "learning",
11775
- label: HUD_LEARNING_LABEL,
11776
11906
  icon: "Brain",
11777
11907
  connected: learningOn,
11778
11908
  introIndex: featureBlockIntroIndex + (threadsOn ? 1 : 2)
@@ -17722,9 +17852,24 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
17722
17852
  trackWhatsNewSignalViewed(props);
17723
17853
  }
17724
17854
  }
17855
+ /** Start the development-only remote feeds; neither blocks rendering. */
17725
17856
  ensureAnnouncementLoading() {
17726
- if (this.isInspectorDismissed || !this.notificationContext.development || !this.isConnected || this.announcementPromise || typeof window === "undefined" || typeof fetch === "undefined") return;
17727
- this.announcementPromise = this.fetchAnnouncement();
17857
+ var _this$announcementPro, _this$hudFeedPromise;
17858
+ if (this.isInspectorDismissed || !this.notificationContext.development || !this.isConnected || typeof window === "undefined" || typeof fetch === "undefined") return;
17859
+ (_this$announcementPro = this.announcementPromise) !== null && _this$announcementPro !== void 0 || (this.announcementPromise = this.fetchAnnouncement());
17860
+ (_this$hudFeedPromise = this.hudFeedPromise) !== null && _this$hudFeedPromise !== void 0 || (this.hudFeedPromise = this.fetchHudFeed());
17861
+ }
17862
+ async fetchHudFeed() {
17863
+ this.hudFeed = await loadHudFeed();
17864
+ this.refreshHudContent();
17865
+ this.requestUpdate();
17866
+ }
17867
+ /** Overlay the matching feed rule on the built-in HUD content. */
17868
+ refreshHudContent() {
17869
+ this.hudContent = resolveHudContent(this.hudFeed, this.notificationContext, {
17870
+ defaults: HUD_DEFAULT_CONTENT,
17871
+ supportedDestinations: INSPECTOR_MENU_KEYS
17872
+ });
17728
17873
  }
17729
17874
  async fetchAnnouncement() {
17730
17875
  try {
@@ -19212,6 +19357,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(parsed))}</pre
19212
19357
 
19213
19358
  .cpk-launcher-hud__label {
19214
19359
  min-width: 0;
19360
+ /* Remote copy can be one long word; wrap it inside the row. */
19361
+ overflow-wrap: anywhere;
19215
19362
  }
19216
19363
 
19217
19364
  .cpk-launcher-hud__feature-icon {