@copilotkit/web-inspector 2.0.0-rc.0 → 2.0.0-rc.10
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 +23 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +24 -102
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +601 -110
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/icons.cjs +408 -0
- package/dist/lib/icons.cjs.map +1 -0
- package/dist/lib/icons.mjs +407 -0
- package/dist/lib/icons.mjs.map +1 -0
- package/dist/lib/json-block.cjs +0 -1
- package/dist/lib/json-block.mjs +1 -1
- package/dist/lib/markdown.cjs +170 -0
- package/dist/lib/markdown.cjs.map +1 -0
- package/dist/lib/markdown.mjs +170 -0
- package/dist/lib/markdown.mjs.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/styles/generated.cjs +1 -1
- package/dist/styles/generated.cjs.map +1 -1
- package/dist/styles/generated.mjs +1 -1
- package/dist/styles/generated.mjs.map +1 -1
- package/package.json +5 -6
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
|
/**
|
|
@@ -1218,8 +1219,7 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
1218
1219
|
this.provider = null;
|
|
1219
1220
|
this.thread = null;
|
|
1220
1221
|
this.runtimeUrl = "";
|
|
1221
|
-
this.
|
|
1222
|
-
this.resolveHeaders = CpkThreadInspector.ɵdefaultResolveHeaders;
|
|
1222
|
+
this.resolveHeaders = () => ({});
|
|
1223
1223
|
this.headersGeneration = 0;
|
|
1224
1224
|
this.threadInspectionAvailable = false;
|
|
1225
1225
|
this.agentStateInput = null;
|
|
@@ -1359,9 +1359,6 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
1359
1359
|
static {
|
|
1360
1360
|
this.nextDomId = 1;
|
|
1361
1361
|
}
|
|
1362
|
-
static {
|
|
1363
|
-
this.ɵdefaultResolveHeaders = () => ({});
|
|
1364
|
-
}
|
|
1365
1362
|
static {
|
|
1366
1363
|
this.COLLAPSE_THRESHOLD = 800;
|
|
1367
1364
|
}
|
|
@@ -3092,16 +3089,9 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3092
3089
|
if (!controller.signal.aborted && this.threadId === threadId) this._loadingState = false;
|
|
3093
3090
|
}
|
|
3094
3091
|
}
|
|
3095
|
-
/**
|
|
3096
|
-
* `resolveHeaders` when a host actually set it; otherwise the deprecated
|
|
3097
|
-
* `headers` fallback. Never both — see the `headers` field's doc.
|
|
3098
|
-
*/
|
|
3099
|
-
ɵresolveInspectorHeaders() {
|
|
3100
|
-
return this.resolveHeaders === CpkThreadInspector.ɵdefaultResolveHeaders ? this.headers : this.resolveHeaders();
|
|
3101
|
-
}
|
|
3102
3092
|
async fetchRuntimeMessages(threadId, signal) {
|
|
3103
3093
|
const res = await fetch(this.getThreadInspectionUrl(threadId, "messages"), {
|
|
3104
|
-
headers: { ...await this
|
|
3094
|
+
headers: { ...await this.resolveHeaders() },
|
|
3105
3095
|
signal
|
|
3106
3096
|
});
|
|
3107
3097
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
@@ -3109,7 +3099,7 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3109
3099
|
}
|
|
3110
3100
|
async fetchRuntimeEvents(threadId, signal) {
|
|
3111
3101
|
const res = await fetch(this.getThreadInspectionUrl(threadId, "events"), {
|
|
3112
|
-
headers: { ...await this
|
|
3102
|
+
headers: { ...await this.resolveHeaders() },
|
|
3113
3103
|
signal
|
|
3114
3104
|
});
|
|
3115
3105
|
if (res.status === 501) return { status: "not-available" };
|
|
@@ -3121,7 +3111,7 @@ var CpkThreadInspector = class CpkThreadInspector extends PortableLitElement {
|
|
|
3121
3111
|
}
|
|
3122
3112
|
async fetchRuntimeState(threadId, signal) {
|
|
3123
3113
|
const res = await fetch(this.getThreadInspectionUrl(threadId, "state"), {
|
|
3124
|
-
headers: { ...await this
|
|
3114
|
+
headers: { ...await this.resolveHeaders() },
|
|
3125
3115
|
signal
|
|
3126
3116
|
});
|
|
3127
3117
|
if (res.status === 501) return { status: "not-available" };
|
|
@@ -12181,7 +12171,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
12181
12171
|
});
|
|
12182
12172
|
}
|
|
12183
12173
|
renderIcon(name) {
|
|
12184
|
-
const iconNode =
|
|
12174
|
+
const iconNode = require_icons.ICON_NODES[name];
|
|
12185
12175
|
if (!iconNode) return lit.nothing;
|
|
12186
12176
|
return (0, lit_directives_unsafe_html_js.unsafeHTML)(`<svg ${this.serializeAttributes({
|
|
12187
12177
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -15326,33 +15316,15 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
15326
15316
|
extractSchemaInfo(parameters) {
|
|
15327
15317
|
const result = { properties: [] };
|
|
15328
15318
|
if (!parameters || typeof parameters !== "object") return result;
|
|
15329
|
-
|
|
15330
|
-
if (
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
if (candidate?._def && !this.isZodOptional(candidate)) requiredKeys.add(key);
|
|
15339
|
-
});
|
|
15340
|
-
for (const [key, value] of Object.entries(shape || {})) {
|
|
15341
|
-
const fieldInfo = this.extractZodFieldInfo(value);
|
|
15342
|
-
result.properties.push({
|
|
15343
|
-
name: key,
|
|
15344
|
-
type: fieldInfo.type,
|
|
15345
|
-
description: fieldInfo.description,
|
|
15346
|
-
required: requiredKeys.has(key),
|
|
15347
|
-
defaultValue: fieldInfo.defaultValue,
|
|
15348
|
-
enum: fieldInfo.enum
|
|
15349
|
-
});
|
|
15350
|
-
}
|
|
15351
|
-
}
|
|
15352
|
-
} else if (parameters.type === "object" && parameters.properties) {
|
|
15353
|
-
const props = parameters.properties;
|
|
15354
|
-
const required = new Set(Array.isArray(parameters.required) ? parameters.required : []);
|
|
15355
|
-
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)) {
|
|
15356
15328
|
const prop = value;
|
|
15357
15329
|
result.properties.push({
|
|
15358
15330
|
name: key,
|
|
@@ -15366,44 +15338,6 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
15366
15338
|
}
|
|
15367
15339
|
return result;
|
|
15368
15340
|
}
|
|
15369
|
-
isZodOptional(zodSchema) {
|
|
15370
|
-
const schema = zodSchema;
|
|
15371
|
-
if (!schema?._def) return false;
|
|
15372
|
-
const def = schema._def;
|
|
15373
|
-
if (def.typeName === "ZodOptional" || def.typeName === "ZodNullable") return true;
|
|
15374
|
-
if (def.defaultValue !== void 0) return true;
|
|
15375
|
-
return false;
|
|
15376
|
-
}
|
|
15377
|
-
extractZodFieldInfo(zodSchema) {
|
|
15378
|
-
const info = {};
|
|
15379
|
-
const schema = zodSchema;
|
|
15380
|
-
if (!schema?._def) return info;
|
|
15381
|
-
let currentSchema = schema;
|
|
15382
|
-
let def = currentSchema._def;
|
|
15383
|
-
while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
|
|
15384
|
-
if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
15385
|
-
currentSchema = def.innerType ?? currentSchema;
|
|
15386
|
-
if (!currentSchema?._def) break;
|
|
15387
|
-
def = currentSchema._def;
|
|
15388
|
-
}
|
|
15389
|
-
info.description = typeof def.description === "string" ? def.description : void 0;
|
|
15390
|
-
const typeName = typeof def.typeName === "string" ? def.typeName : void 0;
|
|
15391
|
-
info.type = typeName ? {
|
|
15392
|
-
ZodString: "string",
|
|
15393
|
-
ZodNumber: "number",
|
|
15394
|
-
ZodBoolean: "boolean",
|
|
15395
|
-
ZodArray: "array",
|
|
15396
|
-
ZodObject: "object",
|
|
15397
|
-
ZodEnum: "enum",
|
|
15398
|
-
ZodLiteral: "literal",
|
|
15399
|
-
ZodUnion: "union",
|
|
15400
|
-
ZodAny: "any",
|
|
15401
|
-
ZodUnknown: "unknown"
|
|
15402
|
-
}[typeName] || typeName.replace("Zod", "").toLowerCase() : void 0;
|
|
15403
|
-
if (typeName === "ZodEnum" && Array.isArray(def.values)) info.enum = def.values;
|
|
15404
|
-
else if (typeName === "ZodLiteral" && def.value !== void 0) info.enum = [def.value];
|
|
15405
|
-
return info;
|
|
15406
|
-
}
|
|
15407
15341
|
toggleToolExpansion(toolId) {
|
|
15408
15342
|
if (this.expandedTools.has(toolId)) this.expandedTools.delete(toolId);
|
|
15409
15343
|
else this.expandedTools.add(toolId);
|
|
@@ -16142,8 +16076,7 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
16142
16076
|
try {
|
|
16143
16077
|
const feed = await require_notification_loader.loadNotificationFeed(this.notificationContext);
|
|
16144
16078
|
if (feed) {
|
|
16145
|
-
|
|
16146
|
-
this.notificationDocuments = new Map(documents);
|
|
16079
|
+
this.notificationDocuments = new Map(feed.notifications.map((notice) => [notice.id, this.convertMarkdownToHtml(notice.body)]));
|
|
16147
16080
|
this.notificationFeed = feed;
|
|
16148
16081
|
}
|
|
16149
16082
|
} catch {}
|
|
@@ -16188,19 +16121,11 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
16188
16121
|
this.refreshNotifications();
|
|
16189
16122
|
this.handleMenuSelect(WHATS_NEW_MENU_KEY);
|
|
16190
16123
|
}
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
renderer.html = (html) => require_json_block.escapeHtml(html);
|
|
16197
|
-
renderer.code = (code, lang) => {
|
|
16198
|
-
const safeLang = (lang ?? "").replace(/[^a-z0-9-]/gi, "");
|
|
16199
|
-
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>`;
|
|
16200
|
-
};
|
|
16201
|
-
return marked.marked.parse(markdown, {
|
|
16202
|
-
renderer,
|
|
16203
|
-
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)
|
|
16204
16129
|
});
|
|
16205
16130
|
}
|
|
16206
16131
|
isSafeAnnouncementHref(href) {
|
|
@@ -16244,9 +16169,6 @@ var WebInspectorElement = class WebInspectorElement extends lit.LitElement {
|
|
|
16244
16169
|
const hostname = url.hostname.toLowerCase();
|
|
16245
16170
|
return hostname === "copilotkit.ai" || hostname.endsWith(".copilotkit.ai");
|
|
16246
16171
|
}
|
|
16247
|
-
escapeHtmlAttr(value) {
|
|
16248
|
-
return require_json_block.escapeHtml(value).replace(/"/g, """).replace(/'/g, "'");
|
|
16249
|
-
}
|
|
16250
16172
|
};
|
|
16251
16173
|
function defineWebInspector(registry = globalThis.customElements) {
|
|
16252
16174
|
if (!registry) return;
|