@copilotkit/web-inspector 1.66.4 → 1.67.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/README.md +92 -13
- package/dist/index.cjs +1436 -429
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +118 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1438 -431
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1721 -533
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/inspector-metadata.cjs +60 -0
- package/dist/lib/inspector-metadata.cjs.map +1 -0
- package/dist/lib/inspector-metadata.mjs +60 -0
- package/dist/lib/inspector-metadata.mjs.map +1 -0
- package/dist/lib/telemetry.cjs +117 -32
- package/dist/lib/telemetry.cjs.map +1 -1
- package/dist/lib/telemetry.mjs +116 -33
- package/dist/lib/telemetry.mjs.map +1 -1
- package/dist/lib/thread-selection.cjs +36 -0
- package/dist/lib/thread-selection.cjs.map +1 -0
- package/dist/lib/thread-selection.mjs +35 -0
- package/dist/lib/thread-selection.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 +9 -4
- package/CHANGELOG.md +0 -505
- package/dev/css-raw-import.spec.ts +0 -31
- package/dev/index.html +0 -115
- package/dev/main.ts +0 -165
- package/dev/vite.config.ts +0 -30
- package/src/__tests__/memory-recall.spec.ts +0 -76
- package/src/__tests__/telemetry-egress-guard.spec.ts +0 -41
- package/src/__tests__/web-inspector.spec.ts +0 -3935
- package/src/assets/inspector-logo-icon.svg +0 -8
- package/src/assets/inspector-logo.svg +0 -40
- package/src/components.d.ts +0 -20
- package/src/index.ts +0 -11849
- package/src/lib/__tests__/telemetry.test.ts +0 -557
- package/src/lib/context-helpers.ts +0 -166
- package/src/lib/persistence.ts +0 -206
- package/src/lib/telemetry.ts +0 -474
- package/src/lib/testing/telemetry-egress-guard.ts +0 -33
- package/src/lib/types.ts +0 -19
- package/src/styles/generated.css +0 -2
- package/src/styles/tailwind.css +0 -23
- package/src/types/css.d.ts +0 -4
- package/src/types/svg.d.ts +0 -4
- package/tsconfig.json +0 -14
- package/tsdown.config.ts +0 -45
- package/vitest.config.ts +0 -66
- package/vitest.setup.ts +0 -84
package/dev/main.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import "../src/index.ts";
|
|
2
|
-
import type {
|
|
3
|
-
CpkThreadInspector,
|
|
4
|
-
ThreadDebuggerProvider,
|
|
5
|
-
} from "../src/index.ts";
|
|
6
|
-
|
|
7
|
-
type Scenario = "events" | "messages" | "raw";
|
|
8
|
-
|
|
9
|
-
const host = document.querySelector<HTMLElement>("#inspector-host");
|
|
10
|
-
|
|
11
|
-
if (!host) {
|
|
12
|
-
throw new Error("Missing standalone inspector host element.");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const inspector = document.createElement(
|
|
16
|
-
"cpk-thread-inspector",
|
|
17
|
-
) as CpkThreadInspector;
|
|
18
|
-
|
|
19
|
-
host.appendChild(inspector);
|
|
20
|
-
|
|
21
|
-
const scenarios: Record<
|
|
22
|
-
Scenario,
|
|
23
|
-
{
|
|
24
|
-
label: string;
|
|
25
|
-
threadId: string;
|
|
26
|
-
provider: ThreadDebuggerProvider;
|
|
27
|
-
}
|
|
28
|
-
> = {
|
|
29
|
-
events: {
|
|
30
|
-
label: "AG-UI events",
|
|
31
|
-
threadId: "demo-events-thread",
|
|
32
|
-
provider: {
|
|
33
|
-
getThreadMetadata: async () => ({
|
|
34
|
-
id: "demo-events-thread",
|
|
35
|
-
name: "AG-UI event-backed thread",
|
|
36
|
-
agentId: "demo-agent",
|
|
37
|
-
endUserId: "demo-user",
|
|
38
|
-
status: "completed",
|
|
39
|
-
createdAt: "2026-06-25T10:00:00.000Z",
|
|
40
|
-
updatedAt: "2026-06-25T10:00:04.000Z",
|
|
41
|
-
}),
|
|
42
|
-
getEvents: async () => [
|
|
43
|
-
{
|
|
44
|
-
type: "RUN_STARTED",
|
|
45
|
-
timestamp: "2026-06-25T10:00:00.000Z",
|
|
46
|
-
payload: { runId: "run-1" },
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
type: "TEXT_MESSAGE_START",
|
|
50
|
-
timestamp: "2026-06-25T10:00:01.000Z",
|
|
51
|
-
payload: { messageId: "m1", role: "assistant" },
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "TEXT_MESSAGE_CONTENT",
|
|
55
|
-
timestamp: "2026-06-25T10:00:02.000Z",
|
|
56
|
-
payload: {
|
|
57
|
-
messageId: "m1",
|
|
58
|
-
delta: "Here is the event-derived timeline row.",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
type: "TOOL_CALL_START",
|
|
63
|
-
timestamp: "2026-06-25T10:00:03.000Z",
|
|
64
|
-
payload: { toolCallId: "tc1", toolCallName: "lookup_docs" },
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
type: "TOOL_CALL_ARGS",
|
|
68
|
-
timestamp: "2026-06-25T10:00:03.250Z",
|
|
69
|
-
payload: { toolCallId: "tc1", args: { query: "threads" } },
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: "RUN_FINISHED",
|
|
73
|
-
timestamp: "2026-06-25T10:00:04.000Z",
|
|
74
|
-
payload: { runId: "run-1" },
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
getState: async () => ({ phase: "complete", selectedScenario: "events" }),
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
messages: {
|
|
81
|
-
label: "Messages only",
|
|
82
|
-
threadId: "demo-messages-thread",
|
|
83
|
-
provider: {
|
|
84
|
-
getThreadMetadata: async () => ({
|
|
85
|
-
id: "demo-messages-thread",
|
|
86
|
-
name: "Message-backed thread",
|
|
87
|
-
agentId: "demo-agent",
|
|
88
|
-
endUserId: "demo-user",
|
|
89
|
-
status: "completed",
|
|
90
|
-
}),
|
|
91
|
-
getEvents: async () => [],
|
|
92
|
-
getMessages: async () => [
|
|
93
|
-
{
|
|
94
|
-
id: "u1",
|
|
95
|
-
role: "user",
|
|
96
|
-
content: "Show me the thread timeline.",
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: "a1",
|
|
100
|
-
role: "assistant",
|
|
101
|
-
content: "This fallback is rendered from persisted messages.",
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
getState: async () => ({ selectedScenario: "messages" }),
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
raw: {
|
|
108
|
-
label: "Raw event only",
|
|
109
|
-
threadId: "demo-raw-thread",
|
|
110
|
-
provider: {
|
|
111
|
-
getThreadMetadata: async () => ({
|
|
112
|
-
id: "demo-raw-thread",
|
|
113
|
-
name: "Raw event-backed thread",
|
|
114
|
-
agentId: "demo-agent",
|
|
115
|
-
endUserId: "demo-user",
|
|
116
|
-
status: "active",
|
|
117
|
-
}),
|
|
118
|
-
getEvents: async () => [
|
|
119
|
-
{
|
|
120
|
-
type: "THREAD_STATE_WRITTEN",
|
|
121
|
-
timestamp: "2026-06-25T10:00:00.000Z",
|
|
122
|
-
payload: {
|
|
123
|
-
checkpointId: "checkpoint-1",
|
|
124
|
-
note: "Unsupported event types still render as raw timeline rows.",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
getState: async () => ({ selectedScenario: "raw" }),
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
function selectScenario(scenario: Scenario): void {
|
|
134
|
-
const selected = scenarios[scenario];
|
|
135
|
-
inspector.provider = selected.provider;
|
|
136
|
-
inspector.threadId = selected.threadId;
|
|
137
|
-
inspector.thread = null;
|
|
138
|
-
|
|
139
|
-
for (const button of document.querySelectorAll<HTMLButtonElement>(
|
|
140
|
-
"[data-scenario]",
|
|
141
|
-
)) {
|
|
142
|
-
const active = button.dataset.scenario === scenario;
|
|
143
|
-
button.setAttribute("aria-pressed", String(active));
|
|
144
|
-
button.style.background = active ? "#eee6fe" : "#ffffff";
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
document.title = `CopilotKit Web Inspector Standalone - ${selected.label}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
for (const button of document.querySelectorAll<HTMLButtonElement>(
|
|
151
|
-
"[data-scenario]",
|
|
152
|
-
)) {
|
|
153
|
-
button.addEventListener("click", () => {
|
|
154
|
-
const scenario = button.dataset.scenario;
|
|
155
|
-
if (
|
|
156
|
-
scenario === "events" ||
|
|
157
|
-
scenario === "messages" ||
|
|
158
|
-
scenario === "raw"
|
|
159
|
-
) {
|
|
160
|
-
selectScenario(scenario);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
selectScenario("events");
|
package/dev/vite.config.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mirrors the package bundler's CSS-as-string behavior for the standalone
|
|
5
|
-
* harness. The inspector injects generated.css into Shadow DOM via unsafeCSS,
|
|
6
|
-
* so the dev server rewrites that package-local import to Vite's raw string
|
|
7
|
-
* loader without changing production source.
|
|
8
|
-
*/
|
|
9
|
-
export default defineConfig({
|
|
10
|
-
plugins: [
|
|
11
|
-
{
|
|
12
|
-
name: "web-inspector-css-raw-import",
|
|
13
|
-
enforce: "pre",
|
|
14
|
-
transform(code, id) {
|
|
15
|
-
if (!id.endsWith("/src/index.ts")) return null;
|
|
16
|
-
const cssImport =
|
|
17
|
-
'import tailwindStyles from "./styles/generated.css";';
|
|
18
|
-
if (!code.includes(cssImport)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
"web-inspector dev CSS transform expected src/index.ts to include the generated.css import",
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return code.replace(
|
|
24
|
-
cssImport,
|
|
25
|
-
'import tailwindStyles from "./styles/generated.css?raw";',
|
|
26
|
-
);
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import type { Memory } from "@copilotkit/core";
|
|
3
|
-
import {
|
|
4
|
-
ɵnormalizeRelevance,
|
|
5
|
-
ɵmaxRecallScore,
|
|
6
|
-
ɵrelevanceBarWidth,
|
|
7
|
-
} from "../index.js";
|
|
8
|
-
|
|
9
|
-
function mem(id: string, score?: number): Memory {
|
|
10
|
-
return {
|
|
11
|
-
id,
|
|
12
|
-
kind: "topical",
|
|
13
|
-
scope: "user",
|
|
14
|
-
content: `content ${id}`,
|
|
15
|
-
sourceThreadIds: [],
|
|
16
|
-
invalidatedAt: null,
|
|
17
|
-
...(score !== undefined ? { score } : {}),
|
|
18
|
-
} as Memory;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe("ɵmaxRecallScore", () => {
|
|
22
|
-
it("returns 0 for an empty set", () => {
|
|
23
|
-
expect(ɵmaxRecallScore([])).toBe(0);
|
|
24
|
-
});
|
|
25
|
-
it("returns 0 when no memory carries a score", () => {
|
|
26
|
-
expect(ɵmaxRecallScore([mem("a"), mem("b")])).toBe(0);
|
|
27
|
-
});
|
|
28
|
-
it("returns the largest finite score", () => {
|
|
29
|
-
expect(ɵmaxRecallScore([mem("a", 0.2), mem("b", 0.9), mem("c", 0.5)])).toBe(
|
|
30
|
-
0.9,
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
it("ignores non-finite scores", () => {
|
|
34
|
-
expect(
|
|
35
|
-
ɵmaxRecallScore([
|
|
36
|
-
mem("a", Number.NaN),
|
|
37
|
-
mem("b", Infinity),
|
|
38
|
-
mem("c", 0.3),
|
|
39
|
-
]),
|
|
40
|
-
).toBe(0.3);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe("ɵnormalizeRelevance", () => {
|
|
45
|
-
it("returns undefined when maxScore is non-positive", () => {
|
|
46
|
-
expect(ɵnormalizeRelevance(0.5, 0)).toBeUndefined();
|
|
47
|
-
expect(ɵnormalizeRelevance(0.5, -1)).toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
it("returns undefined when the score is missing or non-finite", () => {
|
|
50
|
-
expect(ɵnormalizeRelevance(undefined, 1)).toBeUndefined();
|
|
51
|
-
expect(ɵnormalizeRelevance(Number.NaN, 1)).toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
it("normalizes against the set max", () => {
|
|
54
|
-
expect(ɵnormalizeRelevance(0.45, 0.9)).toBeCloseTo(0.5, 5);
|
|
55
|
-
expect(ɵnormalizeRelevance(0.9, 0.9)).toBe(1);
|
|
56
|
-
});
|
|
57
|
-
it("clamps into [0, 1]", () => {
|
|
58
|
-
expect(ɵnormalizeRelevance(2, 1)).toBe(1);
|
|
59
|
-
expect(ɵnormalizeRelevance(-0.3, 1)).toBe(0);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("ɵrelevanceBarWidth", () => {
|
|
64
|
-
it("floors at 6 for weak-but-matched results", () => {
|
|
65
|
-
expect(ɵrelevanceBarWidth(0)).toBe(6);
|
|
66
|
-
expect(ɵrelevanceBarWidth(0.01)).toBe(6);
|
|
67
|
-
});
|
|
68
|
-
it("rounds the percentage", () => {
|
|
69
|
-
expect(ɵrelevanceBarWidth(0.5)).toBe(50);
|
|
70
|
-
expect(ɵrelevanceBarWidth(0.734)).toBe(73);
|
|
71
|
-
});
|
|
72
|
-
it("caps at 100", () => {
|
|
73
|
-
expect(ɵrelevanceBarWidth(1)).toBe(100);
|
|
74
|
-
expect(ɵrelevanceBarWidth(1.5)).toBe(100);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { createTelemetryEgressGuard } from "../lib/testing/telemetry-egress-guard.js";
|
|
4
|
-
|
|
5
|
-
// The inspector's telemetry is browser-side and fire-and-forget, and jsdom has a
|
|
6
|
-
// real `fetch`. The setup-file guard is what keeps unit runs — local and CI —
|
|
7
|
-
// from POSTing real `oss.inspector.*` events to the live sink.
|
|
8
|
-
|
|
9
|
-
describe("telemetry egress guard", () => {
|
|
10
|
-
it("swallows requests to the telemetry sink without touching the network", async () => {
|
|
11
|
-
const realFetch = vi.fn(() =>
|
|
12
|
-
Promise.resolve(new Response(null, { status: 200 })),
|
|
13
|
-
) as unknown as typeof fetch;
|
|
14
|
-
|
|
15
|
-
const guarded = createTelemetryEgressGuard(realFetch);
|
|
16
|
-
const response = await guarded("https://telemetry.copilotkit.ai/ingest", {
|
|
17
|
-
method: "POST",
|
|
18
|
-
body: "{}",
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
expect(response.status).toBe(204);
|
|
22
|
-
expect(realFetch).not.toHaveBeenCalled();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("passes every other request through untouched", async () => {
|
|
26
|
-
const realFetch = vi.fn(() =>
|
|
27
|
-
Promise.resolve(new Response(null, { status: 200 })),
|
|
28
|
-
) as unknown as typeof fetch;
|
|
29
|
-
|
|
30
|
-
const guarded = createTelemetryEgressGuard(realFetch);
|
|
31
|
-
await guarded("https://cdn.copilotkit.ai/announcements.json");
|
|
32
|
-
await guarded(new URL("http://localhost/api/threads"));
|
|
33
|
-
|
|
34
|
-
expect(realFetch).toHaveBeenCalledTimes(2);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("is installed on the global fetch for every test in this package", () => {
|
|
38
|
-
// A raw platform fetch would stringify as native code; the guard doesn't.
|
|
39
|
-
expect(String(globalThis.fetch)).not.toContain("[native code]");
|
|
40
|
-
});
|
|
41
|
-
});
|