@copilotkit/web-inspector 1.63.3-canary.rc-1 → 1.64.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.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +10 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +2 -2
- package/src/__tests__/web-inspector.spec.ts +64 -1
- package/src/index.ts +15 -7
package/dist/package.cjs
CHANGED
package/dist/package.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/web-inspector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.64.1",
|
|
4
4
|
"description": "Lit-based web component for the CopilotKit web inspector",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lit": "^3.2.0",
|
|
28
28
|
"lucide": "^0.525.0",
|
|
29
29
|
"marked": "^12.0.2",
|
|
30
|
-
"@copilotkit/core": "1.
|
|
30
|
+
"@copilotkit/core": "1.64.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@tailwindcss/cli": "^4.1.11",
|
|
@@ -411,6 +411,19 @@ type ThreadDetailsInternals = {
|
|
|
411
411
|
timelineItemsFromEvents: (
|
|
412
412
|
events: Array<Record<string, unknown>>,
|
|
413
413
|
) => Array<Record<string, unknown>>;
|
|
414
|
+
mapMessages: (
|
|
415
|
+
messages: Array<{
|
|
416
|
+
id: string;
|
|
417
|
+
role: string;
|
|
418
|
+
content?: string | null;
|
|
419
|
+
toolCallId?: string | null;
|
|
420
|
+
toolCalls?: Array<{
|
|
421
|
+
id: string;
|
|
422
|
+
name: string;
|
|
423
|
+
args: string;
|
|
424
|
+
}>;
|
|
425
|
+
}>,
|
|
426
|
+
) => Array<Record<string, unknown>>;
|
|
414
427
|
};
|
|
415
428
|
|
|
416
429
|
function createThreadDetails(): {
|
|
@@ -453,7 +466,6 @@ function createDeferred<T>(): {
|
|
|
453
466
|
});
|
|
454
467
|
return { promise, resolve, reject };
|
|
455
468
|
}
|
|
456
|
-
|
|
457
469
|
describe("ɵCpkThreadDetails caching", () => {
|
|
458
470
|
beforeEach(() => {
|
|
459
471
|
document.body.innerHTML = "";
|
|
@@ -749,6 +761,57 @@ describe("ɵCpkThreadDetails caching", () => {
|
|
|
749
761
|
expect(internals.renderState()).not.toBe(stateA);
|
|
750
762
|
expect(internals.renderEvents()).not.toBe(eventsA);
|
|
751
763
|
});
|
|
764
|
+
|
|
765
|
+
it("maps empty tool arguments and results as empty objects", () => {
|
|
766
|
+
const { internals } = createThreadDetails();
|
|
767
|
+
|
|
768
|
+
const items = internals.mapMessages([
|
|
769
|
+
{
|
|
770
|
+
id: "assistant-1",
|
|
771
|
+
role: "assistant",
|
|
772
|
+
content: "",
|
|
773
|
+
toolCalls: [
|
|
774
|
+
{
|
|
775
|
+
id: "call-empty",
|
|
776
|
+
name: "lookupUser",
|
|
777
|
+
args: "",
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
id: "call-whitespace",
|
|
781
|
+
name: "lookupOrder",
|
|
782
|
+
args: " ",
|
|
783
|
+
},
|
|
784
|
+
],
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
id: "tool-empty",
|
|
788
|
+
role: "tool",
|
|
789
|
+
toolCallId: "call-empty",
|
|
790
|
+
content: "",
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
id: "tool-whitespace",
|
|
794
|
+
role: "tool",
|
|
795
|
+
toolCallId: "call-whitespace",
|
|
796
|
+
content: " ",
|
|
797
|
+
},
|
|
798
|
+
]);
|
|
799
|
+
|
|
800
|
+
expect(items).toMatchObject([
|
|
801
|
+
{
|
|
802
|
+
type: "tool_call",
|
|
803
|
+
toolCallId: "call-empty",
|
|
804
|
+
arguments: {},
|
|
805
|
+
result: {},
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
type: "tool_call",
|
|
809
|
+
toolCallId: "call-whitespace",
|
|
810
|
+
arguments: {},
|
|
811
|
+
result: {},
|
|
812
|
+
},
|
|
813
|
+
]);
|
|
814
|
+
});
|
|
752
815
|
});
|
|
753
816
|
|
|
754
817
|
describe("CpkThreadInspector provider contract", () => {
|
package/src/index.ts
CHANGED
|
@@ -2327,10 +2327,10 @@ export class CpkThreadInspector extends LitElement {
|
|
|
2327
2327
|
let args: Record<string, unknown> = {};
|
|
2328
2328
|
if (typeof tc.args === "string") {
|
|
2329
2329
|
try {
|
|
2330
|
-
args =
|
|
2330
|
+
args = this.parseToolCallContent(tc.args);
|
|
2331
2331
|
} catch (err) {
|
|
2332
|
-
//
|
|
2333
|
-
//
|
|
2332
|
+
// Empty content is normalized to `{}` for both tool arguments
|
|
2333
|
+
// and results. The inspector still surfaces malformed JSON.
|
|
2334
2334
|
console.error(
|
|
2335
2335
|
"[CopilotKit Inspector] Failed to parse tool-call arguments",
|
|
2336
2336
|
{ toolCallId: tc.id, raw: tc.args, error: err },
|
|
@@ -2372,10 +2372,7 @@ export class CpkThreadInspector extends LitElement {
|
|
|
2372
2372
|
const tc = toolCallMap.get(msg.toolCallId);
|
|
2373
2373
|
if (tc) {
|
|
2374
2374
|
try {
|
|
2375
|
-
tc.result =
|
|
2376
|
-
string,
|
|
2377
|
-
unknown
|
|
2378
|
-
>;
|
|
2375
|
+
tc.result = this.parseToolCallContent(msg.content);
|
|
2379
2376
|
} catch (err) {
|
|
2380
2377
|
// See the comment on the assistant tool-call args parse above —
|
|
2381
2378
|
// same rationale, same sentinel shape so the renderer can treat
|
|
@@ -2392,6 +2389,17 @@ export class CpkThreadInspector extends LitElement {
|
|
|
2392
2389
|
return items;
|
|
2393
2390
|
}
|
|
2394
2391
|
|
|
2392
|
+
private parseToolCallContent(
|
|
2393
|
+
content: string | null | undefined,
|
|
2394
|
+
): Record<string, unknown> {
|
|
2395
|
+
const normalizedContent = content?.trim();
|
|
2396
|
+
if (!normalizedContent) {
|
|
2397
|
+
return {};
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
return JSON.parse(normalizedContent) as Record<string, unknown>;
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2395
2403
|
private mapApiEvents(events: ThreadDebuggerEvent[]): ApiAgentEvent[] {
|
|
2396
2404
|
return events.map((event, index) => {
|
|
2397
2405
|
const { type, timestamp, payload, ...rest } = event;
|