@copilotkit/web-inspector 2.0.0-rc.7 → 2.0.0-rc.9

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.cjs CHANGED
@@ -9,6 +9,8 @@ const require_generated = require('./styles/generated.cjs');
9
9
  const require_notification_article = require('./styles/notification-article.cjs');
10
10
  const require_inspector_logo = require('./assets/inspector-logo.cjs');
11
11
  const require_inspector_logo_kite = require('./assets/inspector-logo-kite.cjs');
12
+ const require_icons = require('./lib/icons.cjs');
13
+ const require_markdown = require('./lib/markdown.cjs');
12
14
  const require_learning_view = require('./components/learning-view.cjs');
13
15
  const require_json_block = require('./lib/json-block.cjs');
14
16
  require('./components/generative-ui-view.cjs');
@@ -23,11 +25,10 @@ const require_thread_selection = require('./lib/thread-selection.cjs');
23
25
  const require_telemetry = require('./lib/telemetry.cjs');
24
26
  const require_onboarding_prompt = require('./lib/onboarding-prompt.cjs');
25
27
  let lit = require("lit");
26
- let marked = require("marked");
27
28
  let lit_directives_style_map_js = require("lit/directives/style-map.js");
28
29
  let lit_directives_unsafe_html_js = require("lit/directives/unsafe-html.js");
29
- let lucide = require("lucide");
30
30
  let _copilotkit_core = require("@copilotkit/core");
31
+ let _copilotkit_shared = require("@copilotkit/shared");
31
32
 
32
33
  //#region src/index.ts
33
34
  /**
@@ -12170,7 +12171,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
12170
12171
  });
12171
12172
  }
12172
12173
  renderIcon(name) {
12173
- const iconNode = lucide.icons[name];
12174
+ const iconNode = require_icons.ICON_NODES[name];
12174
12175
  if (!iconNode) return lit.nothing;
12175
12176
  return (0, lit_directives_unsafe_html_js.unsafeHTML)(`<svg ${this.serializeAttributes({
12176
12177
  xmlns: "http://www.w3.org/2000/svg",
@@ -15315,33 +15316,15 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
15315
15316
  extractSchemaInfo(parameters) {
15316
15317
  const result = { properties: [] };
15317
15318
  if (!parameters || typeof parameters !== "object") return result;
15318
- const zodDef = parameters._def;
15319
- if (zodDef && typeof zodDef === "object") {
15320
- if (zodDef.typeName === "ZodObject") {
15321
- const rawShape = zodDef.shape;
15322
- const shape = typeof rawShape === "function" ? rawShape() : rawShape;
15323
- if (!shape || typeof shape !== "object") return result;
15324
- const requiredKeys = /* @__PURE__ */ new Set();
15325
- if (zodDef.unknownKeys === "strict" || !zodDef.catchall) Object.keys(shape || {}).forEach((key) => {
15326
- const candidate = shape[key];
15327
- if (candidate?._def && !this.isZodOptional(candidate)) requiredKeys.add(key);
15328
- });
15329
- for (const [key, value] of Object.entries(shape || {})) {
15330
- const fieldInfo = this.extractZodFieldInfo(value);
15331
- result.properties.push({
15332
- name: key,
15333
- type: fieldInfo.type,
15334
- description: fieldInfo.description,
15335
- required: requiredKeys.has(key),
15336
- defaultValue: fieldInfo.defaultValue,
15337
- enum: fieldInfo.enum
15338
- });
15339
- }
15340
- }
15341
- } else if (parameters.type === "object" && parameters.properties) {
15342
- const props = parameters.properties;
15343
- const required = new Set(Array.isArray(parameters.required) ? parameters.required : []);
15344
- for (const [key, value] of Object.entries(props ?? {})) {
15319
+ let jsonSchema = parameters;
15320
+ if ("~standard" in parameters) try {
15321
+ jsonSchema = (0, _copilotkit_shared.schemaToJsonSchema)(parameters);
15322
+ } catch {
15323
+ return result;
15324
+ }
15325
+ if (jsonSchema.type === "object" && jsonSchema.properties) {
15326
+ const required = new Set(Array.isArray(jsonSchema.required) ? jsonSchema.required : []);
15327
+ for (const [key, value] of Object.entries(jsonSchema.properties)) {
15345
15328
  const prop = value;
15346
15329
  result.properties.push({
15347
15330
  name: key,
@@ -15355,44 +15338,6 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
15355
15338
  }
15356
15339
  return result;
15357
15340
  }
15358
- isZodOptional(zodSchema) {
15359
- const schema = zodSchema;
15360
- if (!schema?._def) return false;
15361
- const def = schema._def;
15362
- if (def.typeName === "ZodOptional" || def.typeName === "ZodNullable") return true;
15363
- if (def.defaultValue !== void 0) return true;
15364
- return false;
15365
- }
15366
- extractZodFieldInfo(zodSchema) {
15367
- const info = {};
15368
- const schema = zodSchema;
15369
- if (!schema?._def) return info;
15370
- let currentSchema = schema;
15371
- let def = currentSchema._def;
15372
- while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
15373
- if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
15374
- currentSchema = def.innerType ?? currentSchema;
15375
- if (!currentSchema?._def) break;
15376
- def = currentSchema._def;
15377
- }
15378
- info.description = typeof def.description === "string" ? def.description : void 0;
15379
- const typeName = typeof def.typeName === "string" ? def.typeName : void 0;
15380
- info.type = typeName ? {
15381
- ZodString: "string",
15382
- ZodNumber: "number",
15383
- ZodBoolean: "boolean",
15384
- ZodArray: "array",
15385
- ZodObject: "object",
15386
- ZodEnum: "enum",
15387
- ZodLiteral: "literal",
15388
- ZodUnion: "union",
15389
- ZodAny: "any",
15390
- ZodUnknown: "unknown"
15391
- }[typeName] || typeName.replace("Zod", "").toLowerCase() : void 0;
15392
- if (typeName === "ZodEnum" && Array.isArray(def.values)) info.enum = def.values;
15393
- else if (typeName === "ZodLiteral" && def.value !== void 0) info.enum = [def.value];
15394
- return info;
15395
- }
15396
15341
  toggleToolExpansion(toolId) {
15397
15342
  if (this.expandedTools.has(toolId)) this.expandedTools.delete(toolId);
15398
15343
  else this.expandedTools.add(toolId);
@@ -16131,8 +16076,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
16131
16076
  try {
16132
16077
  const feed = await require_notification_loader.loadNotificationFeed(this.notificationContext);
16133
16078
  if (feed) {
16134
- const documents = await Promise.all(feed.notifications.map(async (notice) => [notice.id, await this.convertMarkdownToHtml(notice.body) ?? ""]));
16135
- this.notificationDocuments = new Map(documents);
16079
+ this.notificationDocuments = new Map(feed.notifications.map((notice) => [notice.id, this.convertMarkdownToHtml(notice.body)]));
16136
16080
  this.notificationFeed = feed;
16137
16081
  }
16138
16082
  } catch {}
@@ -16177,19 +16121,11 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
16177
16121
  this.refreshNotifications();
16178
16122
  this.handleMenuSelect(WHATS_NEW_MENU_KEY);
16179
16123
  }
16180
- async convertMarkdownToHtml(markdown) {
16181
- const renderer = new marked.marked.Renderer();
16182
- renderer.link = (href, title, text) => {
16183
- return `<a href="${this.escapeHtmlAttr(this.isSafeAnnouncementHref(href ?? "") ? this.appendRefParam(href ?? "") : "#")}" target="_blank" rel="noopener"${title ? ` title="${this.escapeHtmlAttr(title)}"` : ""}>${text}</a>`;
16184
- };
16185
- renderer.html = (html) => require_json_block.escapeHtml(html);
16186
- renderer.code = (code, lang) => {
16187
- const safeLang = (lang ?? "").replace(/[^a-z0-9-]/gi, "");
16188
- return `<div class="announcement-code"><pre><code${safeLang ? ` class="language-${safeLang}"` : ""}>${require_json_block.escapeHtml(code)}</code></pre><div class="announcement-code__copy-shield"><button type="button" class="announcement-code__copy" data-copy="${this.encodeBase64(code)}" aria-label="Copy code">Copy</button></div></div>`;
16189
- };
16190
- return marked.marked.parse(markdown, {
16191
- renderer,
16192
- async: false
16124
+ convertMarkdownToHtml(markdown) {
16125
+ return require_markdown.renderMarkdownToHtml(markdown, {
16126
+ linkHref: (href) => this.isSafeAnnouncementHref(href) ? this.appendRefParam(href) : "#",
16127
+ imageSrc: (src) => this.isSafeAnnouncementHref(src) ? src : null,
16128
+ copyPayload: (code) => this.encodeBase64(code)
16193
16129
  });
16194
16130
  }
16195
16131
  isSafeAnnouncementHref(href) {
@@ -16233,9 +16169,6 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
16233
16169
  const hostname = url.hostname.toLowerCase();
16234
16170
  return hostname === "copilotkit.ai" || hostname.endsWith(".copilotkit.ai");
16235
16171
  }
16236
- escapeHtmlAttr(value) {
16237
- return require_json_block.escapeHtml(value).replace(/"/g, "&quot;").replace(/'/g, "&#39;");
16238
- }
16239
16172
  };
16240
16173
  function defineWebInspector(registry = globalThis.customElements) {
16241
16174
  if (!registry) return;