@copilotkit/web-inspector 1.61.2 → 1.62.0
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 +21 -0
- package/dev/css-raw-import.spec.ts +31 -0
- package/dev/index.html +115 -0
- package/dev/main.ts +165 -0
- package/dev/vite.config.ts +30 -0
- package/dist/index.cjs +752 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +90 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +751 -137
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +807 -163
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +4 -2
- package/src/__tests__/web-inspector.spec.ts +717 -13
- package/src/index.ts +1017 -193
package/dist/index.umd.js
CHANGED
|
@@ -191,7 +191,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
191
191
|
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region package.json
|
|
194
|
-
var version = "1.
|
|
194
|
+
var version = "1.62.0";
|
|
195
195
|
|
|
196
196
|
//#endregion
|
|
197
197
|
//#region src/lib/telemetry.ts
|
|
@@ -356,6 +356,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
356
356
|
//#endregion
|
|
357
357
|
//#region src/index.ts
|
|
358
358
|
const WEB_INSPECTOR_TAG = "cpk-web-inspector";
|
|
359
|
+
const THREAD_INSPECTOR_TAG = "cpk-thread-inspector";
|
|
359
360
|
const EDGE_MARGIN = 16;
|
|
360
361
|
const DRAG_THRESHOLD = 6;
|
|
361
362
|
const MIN_WINDOW_WIDTH = 600;
|
|
@@ -555,28 +556,30 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
555
556
|
${filtered.length === 0 ? lit.html`
|
|
556
557
|
<div class="cpk-tl__empty">
|
|
557
558
|
${this.errorMessage ? lit.html`
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
559
|
+
<svg
|
|
560
|
+
width="24"
|
|
561
|
+
height="24"
|
|
562
|
+
viewBox="0 0 24 24"
|
|
563
|
+
fill="none"
|
|
564
|
+
stroke="currentColor"
|
|
565
|
+
stroke-width="1.5"
|
|
566
|
+
stroke-linecap="round"
|
|
567
|
+
stroke-linejoin="round"
|
|
568
|
+
class="cpk-tl__empty-icon"
|
|
569
|
+
>
|
|
570
|
+
<circle cx="12" cy="12" r="10" />
|
|
571
|
+
<line x1="12" y1="8" x2="12" y2="12" />
|
|
572
|
+
<line x1="12" y1="16" x2="12.01" y2="16" />
|
|
573
|
+
</svg>
|
|
574
|
+
<div>
|
|
575
|
+
Failed to load threads
|
|
576
|
+
<div
|
|
577
|
+
style="font-size:11px;margin-top:4px;color:#c0333a;"
|
|
568
578
|
>
|
|
569
|
-
|
|
570
|
-
<line x1="12" y1="8" x2="12" y2="12" />
|
|
571
|
-
<line x1="12" y1="16" x2="12.01" y2="16" />
|
|
572
|
-
</svg>
|
|
573
|
-
<div>
|
|
574
|
-
Failed to load threads
|
|
575
|
-
<div style="font-size:11px;margin-top:4px;color:#c0333a;">
|
|
576
|
-
${this.errorMessage}
|
|
577
|
-
</div>
|
|
579
|
+
${this.errorMessage}
|
|
578
580
|
</div>
|
|
579
|
-
|
|
581
|
+
</div>
|
|
582
|
+
` : this.threads.length === 0 ? lit.html`
|
|
580
583
|
<svg
|
|
581
584
|
width="24"
|
|
582
585
|
height="24"
|
|
@@ -744,10 +747,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
744
747
|
color: #c0c0c8;
|
|
745
748
|
}
|
|
746
749
|
`;
|
|
747
|
-
var
|
|
750
|
+
var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
|
|
748
751
|
constructor(..._args2) {
|
|
749
752
|
super(..._args2);
|
|
750
753
|
this.threadId = null;
|
|
754
|
+
this.provider = null;
|
|
751
755
|
this.thread = null;
|
|
752
756
|
this.runtimeUrl = "";
|
|
753
757
|
this.headers = {};
|
|
@@ -755,7 +759,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
755
759
|
this.agentStateInput = null;
|
|
756
760
|
this.agentEventsInput = [];
|
|
757
761
|
this.liveMessageVersion = 0;
|
|
758
|
-
this._tab = "
|
|
762
|
+
this._tab = "timeline";
|
|
763
|
+
this._fetchedMetadata = null;
|
|
759
764
|
this._conversation = [];
|
|
760
765
|
this._fetchedEvents = null;
|
|
761
766
|
this._fetchedState = null;
|
|
@@ -772,12 +777,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
772
777
|
this._eventsNotAvailable = false;
|
|
773
778
|
this._stateNotAvailable = false;
|
|
774
779
|
this._panelInitializing = false;
|
|
775
|
-
this._activatedTabs = new Set(["
|
|
780
|
+
this._activatedTabs = new Set(["timeline"]);
|
|
776
781
|
this._panelTplCache = /* @__PURE__ */ new Map();
|
|
782
|
+
this._timelineItemsCache = null;
|
|
783
|
+
this._liveEventsWithSourceIndexCache = null;
|
|
777
784
|
this._eventsFetched = false;
|
|
778
785
|
this._stateFetched = false;
|
|
779
|
-
this.
|
|
786
|
+
this._lastLoadKey = null;
|
|
780
787
|
this._lastSeenLiveMessageVersion = 0;
|
|
788
|
+
this._metadataAbort = null;
|
|
781
789
|
this._messagesAbort = null;
|
|
782
790
|
this._eventsAbort = null;
|
|
783
791
|
this._stateAbort = null;
|
|
@@ -805,9 +813,33 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
805
813
|
this._dividerResizing = false;
|
|
806
814
|
};
|
|
807
815
|
}
|
|
816
|
+
static providerLoadKey(provider) {
|
|
817
|
+
if (!provider) return "provider:none";
|
|
818
|
+
let id = CpkThreadInspector.providerIds.get(provider);
|
|
819
|
+
if (!id) {
|
|
820
|
+
id = CpkThreadInspector.nextProviderId;
|
|
821
|
+
CpkThreadInspector.nextProviderId += 1;
|
|
822
|
+
CpkThreadInspector.providerIds.set(provider, id);
|
|
823
|
+
}
|
|
824
|
+
return [
|
|
825
|
+
`provider:${id}`,
|
|
826
|
+
provider.getThreadMetadata ? "metadata:1" : "metadata:0",
|
|
827
|
+
provider.getMessages ? "messages:1" : "messages:0",
|
|
828
|
+
provider.getEvents ? "events:1" : "events:0",
|
|
829
|
+
provider.getState ? "state:1" : "state:0"
|
|
830
|
+
].join("|");
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Build a deterministic signature for runtime fetch headers so auth/CSRF
|
|
834
|
+
* changes invalidate cached thread data even when the selected thread is
|
|
835
|
+
* otherwise unchanged.
|
|
836
|
+
*/
|
|
837
|
+
static headersLoadKey(headers) {
|
|
838
|
+
return JSON.stringify(Object.entries(headers).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
|
|
839
|
+
}
|
|
808
840
|
renderTabContent(id) {
|
|
809
|
-
if (id === "
|
|
810
|
-
if (id === "
|
|
841
|
+
if (id === "timeline") return this.renderTimeline();
|
|
842
|
+
if (id === "state") return this.renderState();
|
|
811
843
|
return this.renderEvents();
|
|
812
844
|
}
|
|
813
845
|
activateTab(id) {
|
|
@@ -825,44 +857,108 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
825
857
|
}
|
|
826
858
|
maybeFetchTabData(id) {
|
|
827
859
|
if (!this.threadId) return;
|
|
828
|
-
if (id === "
|
|
860
|
+
if ((id === "timeline" || id === "raw-events") && !this._eventsFetched) {
|
|
829
861
|
this._eventsFetched = true;
|
|
830
862
|
this.fetchEvents(this.threadId);
|
|
831
|
-
} else if (id === "
|
|
863
|
+
} else if (id === "state" && !this._stateFetched) {
|
|
832
864
|
this._stateFetched = true;
|
|
833
865
|
this.fetchState(this.threadId);
|
|
834
866
|
}
|
|
835
867
|
}
|
|
836
868
|
updated(_changed) {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
this.
|
|
869
|
+
const loadKey = this.currentLoadKey();
|
|
870
|
+
if (loadKey !== this._lastLoadKey) {
|
|
871
|
+
this._lastLoadKey = loadKey;
|
|
840
872
|
this._lastSeenLiveMessageVersion = this.liveMessageVersion;
|
|
841
|
-
this.
|
|
842
|
-
this.
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
this._eventsFetched = false;
|
|
853
|
-
this._stateFetched = false;
|
|
854
|
-
this._fetchedEvents = null;
|
|
855
|
-
this._fetchedState = null;
|
|
856
|
-
if (this.threadId) this.fetchMessages(this.threadId);
|
|
857
|
-
else this._conversation = [];
|
|
873
|
+
this.resetLoadedThreadData();
|
|
874
|
+
if (this.threadId) {
|
|
875
|
+
this.fetchMetadata(this.threadId);
|
|
876
|
+
if (this.canFetchEvents()) {
|
|
877
|
+
this._eventsFetched = true;
|
|
878
|
+
this.fetchEvents(this.threadId);
|
|
879
|
+
} else this.fetchMessages(this.threadId);
|
|
880
|
+
} else {
|
|
881
|
+
this._fetchedMetadata = null;
|
|
882
|
+
this._conversation = [];
|
|
883
|
+
}
|
|
858
884
|
} else if (this.threadId && this.liveMessageVersion !== this._lastSeenLiveMessageVersion) {
|
|
859
|
-
var _this$
|
|
885
|
+
var _this$_messagesAbort;
|
|
860
886
|
this._lastSeenLiveMessageVersion = this.liveMessageVersion;
|
|
861
|
-
(_this$
|
|
887
|
+
(_this$_messagesAbort = this._messagesAbort) === null || _this$_messagesAbort === void 0 || _this$_messagesAbort.abort();
|
|
862
888
|
this._messagesAbort = null;
|
|
863
889
|
this.fetchMessages(this.threadId, true);
|
|
864
890
|
}
|
|
865
891
|
}
|
|
892
|
+
canFetchMessages() {
|
|
893
|
+
var _this$provider;
|
|
894
|
+
return !!((_this$provider = this.provider) === null || _this$provider === void 0 ? void 0 : _this$provider.getMessages) || !!this.runtimeUrl && this.threadInspectionAvailable;
|
|
895
|
+
}
|
|
896
|
+
canFetchEvents() {
|
|
897
|
+
var _this$provider2;
|
|
898
|
+
return !!((_this$provider2 = this.provider) === null || _this$provider2 === void 0 ? void 0 : _this$provider2.getEvents) || !!this.runtimeUrl && this.threadInspectionAvailable;
|
|
899
|
+
}
|
|
900
|
+
canFetchState() {
|
|
901
|
+
var _this$provider3;
|
|
902
|
+
return !!((_this$provider3 = this.provider) === null || _this$provider3 === void 0 ? void 0 : _this$provider3.getState) || !!this.runtimeUrl && this.threadInspectionAvailable;
|
|
903
|
+
}
|
|
904
|
+
currentLoadKey() {
|
|
905
|
+
var _this$threadId;
|
|
906
|
+
return [
|
|
907
|
+
(_this$threadId = this.threadId) !== null && _this$threadId !== void 0 ? _this$threadId : "thread:none",
|
|
908
|
+
CpkThreadInspector.providerLoadKey(this.provider),
|
|
909
|
+
`runtime:${this.runtimeUrl}`,
|
|
910
|
+
`headers:${CpkThreadInspector.headersLoadKey(this.headers)}`,
|
|
911
|
+
`inspect:${this.threadInspectionAvailable ? "1" : "0"}`
|
|
912
|
+
].join("||");
|
|
913
|
+
}
|
|
914
|
+
resetLoadedThreadData() {
|
|
915
|
+
var _this$_metadataAbort, _this$_messagesAbort2, _this$_eventsAbort, _this$_stateAbort;
|
|
916
|
+
this._tab = "timeline";
|
|
917
|
+
this._activatedTabs = new Set(["timeline"]);
|
|
918
|
+
this._panelTplCache = /* @__PURE__ */ new Map();
|
|
919
|
+
this._timelineItemsCache = null;
|
|
920
|
+
this._liveEventsWithSourceIndexCache = null;
|
|
921
|
+
this._expandedTools = /* @__PURE__ */ new Set();
|
|
922
|
+
this._expandedMessages = /* @__PURE__ */ new Set();
|
|
923
|
+
(_this$_metadataAbort = this._metadataAbort) === null || _this$_metadataAbort === void 0 || _this$_metadataAbort.abort();
|
|
924
|
+
this._metadataAbort = null;
|
|
925
|
+
(_this$_messagesAbort2 = this._messagesAbort) === null || _this$_messagesAbort2 === void 0 || _this$_messagesAbort2.abort();
|
|
926
|
+
this._messagesAbort = null;
|
|
927
|
+
(_this$_eventsAbort = this._eventsAbort) === null || _this$_eventsAbort === void 0 || _this$_eventsAbort.abort();
|
|
928
|
+
this._eventsAbort = null;
|
|
929
|
+
(_this$_stateAbort = this._stateAbort) === null || _this$_stateAbort === void 0 || _this$_stateAbort.abort();
|
|
930
|
+
this._stateAbort = null;
|
|
931
|
+
this._eventsFetched = false;
|
|
932
|
+
this._stateFetched = false;
|
|
933
|
+
this._eventsNotAvailable = false;
|
|
934
|
+
this._stateNotAvailable = false;
|
|
935
|
+
this._loadingMessages = false;
|
|
936
|
+
this._loadingEvents = false;
|
|
937
|
+
this._loadingState = false;
|
|
938
|
+
this._messagesError = null;
|
|
939
|
+
this._eventsError = null;
|
|
940
|
+
this._stateError = null;
|
|
941
|
+
this._fetchedMetadata = null;
|
|
942
|
+
this._conversation = [];
|
|
943
|
+
this._fetchedEvents = null;
|
|
944
|
+
this._fetchedState = null;
|
|
945
|
+
}
|
|
946
|
+
async fetchMetadata(threadId) {
|
|
947
|
+
var _this$provider4, _this$_metadataAbort2;
|
|
948
|
+
if (!((_this$provider4 = this.provider) === null || _this$provider4 === void 0 ? void 0 : _this$provider4.getThreadMetadata)) return;
|
|
949
|
+
(_this$_metadataAbort2 = this._metadataAbort) === null || _this$_metadataAbort2 === void 0 || _this$_metadataAbort2.abort();
|
|
950
|
+
const controller = new AbortController();
|
|
951
|
+
this._metadataAbort = controller;
|
|
952
|
+
try {
|
|
953
|
+
const metadata = await this.provider.getThreadMetadata(threadId, { signal: controller.signal });
|
|
954
|
+
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
955
|
+
this._fetchedMetadata = metadata;
|
|
956
|
+
} catch (err) {
|
|
957
|
+
if (err instanceof Error && err.name === "AbortError") return;
|
|
958
|
+
if (this.threadId !== threadId) return;
|
|
959
|
+
this._fetchedMetadata = null;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
866
962
|
/**
|
|
867
963
|
* Fetch the canonical conversation for `threadId` from the runtime.
|
|
868
964
|
*
|
|
@@ -874,10 +970,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
874
970
|
* so users see an explicit loading indicator on first load.
|
|
875
971
|
*/
|
|
876
972
|
async fetchMessages(threadId, silent = false) {
|
|
877
|
-
|
|
973
|
+
var _this$_messagesAbort3;
|
|
974
|
+
if (!this.canFetchMessages()) {
|
|
878
975
|
if (!silent) this._conversation = [];
|
|
879
976
|
return;
|
|
880
977
|
}
|
|
978
|
+
(_this$_messagesAbort3 = this._messagesAbort) === null || _this$_messagesAbort3 === void 0 || _this$_messagesAbort3.abort();
|
|
881
979
|
const controller = new AbortController();
|
|
882
980
|
this._messagesAbort = controller;
|
|
883
981
|
if (!silent) {
|
|
@@ -885,15 +983,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
885
983
|
this._messagesError = null;
|
|
886
984
|
}
|
|
887
985
|
try {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
signal: controller.signal
|
|
891
|
-
});
|
|
892
|
-
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
893
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
894
|
-
const data = await res.json();
|
|
986
|
+
var _this$provider5;
|
|
987
|
+
const messages = ((_this$provider5 = this.provider) === null || _this$provider5 === void 0 ? void 0 : _this$provider5.getMessages) ? await this.provider.getMessages(threadId, { signal: controller.signal }) : await this.fetchRuntimeMessages(threadId, controller.signal);
|
|
895
988
|
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
896
|
-
this._conversation = this.mapMessages(
|
|
989
|
+
this._conversation = this.mapMessages(messages);
|
|
897
990
|
} catch (err) {
|
|
898
991
|
if (err instanceof Error && err.name === "AbortError") return;
|
|
899
992
|
if (!silent) {
|
|
@@ -905,65 +998,66 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
905
998
|
}
|
|
906
999
|
}
|
|
907
1000
|
async fetchEvents(threadId) {
|
|
908
|
-
|
|
909
|
-
if (!this.
|
|
1001
|
+
var _this$_eventsAbort2;
|
|
1002
|
+
if (!this.canFetchEvents()) {
|
|
910
1003
|
this._fetchedEvents = null;
|
|
911
1004
|
return;
|
|
912
1005
|
}
|
|
1006
|
+
(_this$_eventsAbort2 = this._eventsAbort) === null || _this$_eventsAbort2 === void 0 || _this$_eventsAbort2.abort();
|
|
913
1007
|
const controller = new AbortController();
|
|
914
1008
|
this._eventsAbort = controller;
|
|
915
1009
|
this._loadingEvents = true;
|
|
916
1010
|
this._eventsError = null;
|
|
917
1011
|
try {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
1012
|
+
var _this$provider6;
|
|
1013
|
+
const result = ((_this$provider6 = this.provider) === null || _this$provider6 === void 0 ? void 0 : _this$provider6.getEvents) ? {
|
|
1014
|
+
status: "available",
|
|
1015
|
+
events: await this.provider.getEvents(threadId, { signal: controller.signal })
|
|
1016
|
+
} : await this.fetchRuntimeEvents(threadId, controller.signal);
|
|
922
1017
|
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
923
|
-
if (
|
|
1018
|
+
if (result.status === "not-available") {
|
|
924
1019
|
this._eventsNotAvailable = true;
|
|
925
|
-
this._fetchedEvents =
|
|
1020
|
+
this._fetchedEvents = [];
|
|
1021
|
+
if (this.canFetchMessages()) this.fetchMessages(threadId);
|
|
926
1022
|
return;
|
|
927
1023
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
if (
|
|
931
|
-
this._fetchedEvents = this.mapApiEvents(data.events);
|
|
1024
|
+
const mappedEvents = this.mapApiEvents(result.events);
|
|
1025
|
+
this._fetchedEvents = mappedEvents;
|
|
1026
|
+
if (mappedEvents.length === 0 && this.canFetchMessages()) this.fetchMessages(threadId);
|
|
932
1027
|
} catch (err) {
|
|
933
1028
|
if (err instanceof Error && err.name === "AbortError") return;
|
|
934
1029
|
if (this.threadId !== threadId) return;
|
|
935
1030
|
this._eventsError = err instanceof Error ? err.message : "Failed to load events";
|
|
936
1031
|
this._fetchedEvents = [];
|
|
1032
|
+
if (this.canFetchMessages()) this.fetchMessages(threadId);
|
|
937
1033
|
} finally {
|
|
938
1034
|
if (!controller.signal.aborted && this.threadId === threadId) this._loadingEvents = false;
|
|
939
1035
|
}
|
|
940
1036
|
}
|
|
941
1037
|
async fetchState(threadId) {
|
|
942
|
-
|
|
943
|
-
if (!this.
|
|
1038
|
+
var _this$_stateAbort2;
|
|
1039
|
+
if (!this.canFetchState()) {
|
|
944
1040
|
this._fetchedState = null;
|
|
945
1041
|
return;
|
|
946
1042
|
}
|
|
1043
|
+
(_this$_stateAbort2 = this._stateAbort) === null || _this$_stateAbort2 === void 0 || _this$_stateAbort2.abort();
|
|
947
1044
|
const controller = new AbortController();
|
|
948
1045
|
this._stateAbort = controller;
|
|
949
1046
|
this._loadingState = true;
|
|
950
1047
|
this._stateError = null;
|
|
951
1048
|
try {
|
|
952
|
-
var
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
signal: controller.signal
|
|
956
|
-
});
|
|
1049
|
+
var _this$provider7, _result$state;
|
|
1050
|
+
const result = ((_this$provider7 = this.provider) === null || _this$provider7 === void 0 ? void 0 : _this$provider7.getState) ? {
|
|
1051
|
+
status: "available",
|
|
1052
|
+
state: await this.provider.getState(threadId, { signal: controller.signal })
|
|
1053
|
+
} : await this.fetchRuntimeState(threadId, controller.signal);
|
|
957
1054
|
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
958
|
-
if (
|
|
1055
|
+
if (result.status === "not-available") {
|
|
959
1056
|
this._stateNotAvailable = true;
|
|
960
1057
|
this._fetchedState = null;
|
|
961
1058
|
return;
|
|
962
1059
|
}
|
|
963
|
-
|
|
964
|
-
const data = await res.json();
|
|
965
|
-
if (controller.signal.aborted || this.threadId !== threadId) return;
|
|
966
|
-
this._fetchedState = (_data$state = data.state) !== null && _data$state !== void 0 ? _data$state : null;
|
|
1060
|
+
this._fetchedState = (_result$state = result.state) !== null && _result$state !== void 0 ? _result$state : null;
|
|
967
1061
|
} catch (err) {
|
|
968
1062
|
if (err instanceof Error && err.name === "AbortError") return;
|
|
969
1063
|
if (this.threadId !== threadId) return;
|
|
@@ -973,6 +1067,39 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
973
1067
|
if (!controller.signal.aborted && this.threadId === threadId) this._loadingState = false;
|
|
974
1068
|
}
|
|
975
1069
|
}
|
|
1070
|
+
async fetchRuntimeMessages(threadId, signal) {
|
|
1071
|
+
const res = await fetch(this.getThreadInspectionUrl(threadId, "messages"), {
|
|
1072
|
+
headers: { ...this.headers },
|
|
1073
|
+
signal
|
|
1074
|
+
});
|
|
1075
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
1076
|
+
return (await res.json()).messages;
|
|
1077
|
+
}
|
|
1078
|
+
async fetchRuntimeEvents(threadId, signal) {
|
|
1079
|
+
const res = await fetch(this.getThreadInspectionUrl(threadId, "events"), {
|
|
1080
|
+
headers: { ...this.headers },
|
|
1081
|
+
signal
|
|
1082
|
+
});
|
|
1083
|
+
if (res.status === 501) return { status: "not-available" };
|
|
1084
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
1085
|
+
return {
|
|
1086
|
+
status: "available",
|
|
1087
|
+
events: (await res.json()).events
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
async fetchRuntimeState(threadId, signal) {
|
|
1091
|
+
var _data$state;
|
|
1092
|
+
const res = await fetch(this.getThreadInspectionUrl(threadId, "state"), {
|
|
1093
|
+
headers: { ...this.headers },
|
|
1094
|
+
signal
|
|
1095
|
+
});
|
|
1096
|
+
if (res.status === 501) return { status: "not-available" };
|
|
1097
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
1098
|
+
return {
|
|
1099
|
+
status: "available",
|
|
1100
|
+
state: (_data$state = (await res.json()).state) !== null && _data$state !== void 0 ? _data$state : null
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
976
1103
|
getThreadInspectionUrl(threadId, resource) {
|
|
977
1104
|
return `${this.runtimeUrl.replace(/\/+$/, "")}/threads/${encodeURIComponent(threadId)}/${resource}`;
|
|
978
1105
|
}
|
|
@@ -989,7 +1116,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
989
1116
|
var _msg$toolCalls;
|
|
990
1117
|
if ((_msg$toolCalls = msg.toolCalls) === null || _msg$toolCalls === void 0 ? void 0 : _msg$toolCalls.length) for (const tc of msg.toolCalls) {
|
|
991
1118
|
let args = {};
|
|
992
|
-
try {
|
|
1119
|
+
if (typeof tc.args === "string") try {
|
|
993
1120
|
args = JSON.parse(tc.args);
|
|
994
1121
|
} catch (err) {
|
|
995
1122
|
console.error("[CopilotKit Inspector] Failed to parse tool-call arguments", {
|
|
@@ -1002,6 +1129,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1002
1129
|
__raw: tc.args
|
|
1003
1130
|
};
|
|
1004
1131
|
}
|
|
1132
|
+
else args = tc.args;
|
|
1005
1133
|
const item = {
|
|
1006
1134
|
id: tc.id,
|
|
1007
1135
|
type: "tool_call",
|
|
@@ -1049,15 +1177,245 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1049
1177
|
return items;
|
|
1050
1178
|
}
|
|
1051
1179
|
mapApiEvents(events) {
|
|
1052
|
-
return events.map((event) => {
|
|
1053
|
-
const { type, timestamp, ...rest } = event;
|
|
1180
|
+
return events.map((event, index) => {
|
|
1181
|
+
const { type, timestamp, payload, ...rest } = event;
|
|
1054
1182
|
return {
|
|
1055
1183
|
type: typeof type === "string" ? type : "UNKNOWN",
|
|
1056
1184
|
timestamp: typeof timestamp === "string" || typeof timestamp === "number" ? timestamp : Date.now(),
|
|
1057
|
-
payload: rest
|
|
1185
|
+
payload: payload !== null && payload !== void 0 ? payload : rest,
|
|
1186
|
+
sourceIndex: index + 1,
|
|
1187
|
+
rawEvent: event
|
|
1058
1188
|
};
|
|
1059
1189
|
});
|
|
1060
1190
|
}
|
|
1191
|
+
get activeTimelineItems() {
|
|
1192
|
+
return this.timelineItemsForEvents(this.activeEvents);
|
|
1193
|
+
}
|
|
1194
|
+
timelineItemsForEvents(events) {
|
|
1195
|
+
var _this$_timelineItemsC;
|
|
1196
|
+
if (((_this$_timelineItemsC = this._timelineItemsCache) === null || _this$_timelineItemsC === void 0 ? void 0 : _this$_timelineItemsC.events) === events) return this._timelineItemsCache.items;
|
|
1197
|
+
const items = this.timelineItemsFromEvents(events);
|
|
1198
|
+
this._timelineItemsCache = {
|
|
1199
|
+
events,
|
|
1200
|
+
items
|
|
1201
|
+
};
|
|
1202
|
+
return items;
|
|
1203
|
+
}
|
|
1204
|
+
timelineItemsFromEvents(events) {
|
|
1205
|
+
if (events.length === 0) return [];
|
|
1206
|
+
const items = [];
|
|
1207
|
+
const messageItems = /* @__PURE__ */ new Map();
|
|
1208
|
+
const toolItems = /* @__PURE__ */ new Map();
|
|
1209
|
+
const readString = (payload, keys) => {
|
|
1210
|
+
for (const key of keys) {
|
|
1211
|
+
const value = payload[key];
|
|
1212
|
+
if (typeof value === "string") return value;
|
|
1213
|
+
}
|
|
1214
|
+
return null;
|
|
1215
|
+
};
|
|
1216
|
+
const sourceIndexFor = (event) => {
|
|
1217
|
+
var _event$sourceIndex;
|
|
1218
|
+
return (_event$sourceIndex = event.sourceIndex) !== null && _event$sourceIndex !== void 0 ? _event$sourceIndex : 0;
|
|
1219
|
+
};
|
|
1220
|
+
const appendWarning = (event, title, body, severity = "warning") => {
|
|
1221
|
+
const sourceIndex = sourceIndexFor(event);
|
|
1222
|
+
items.push({
|
|
1223
|
+
id: `warning-${sourceIndex}-${items.length}`,
|
|
1224
|
+
kind: "warning",
|
|
1225
|
+
title,
|
|
1226
|
+
body,
|
|
1227
|
+
timestamp: event.timestamp,
|
|
1228
|
+
sourceIndex,
|
|
1229
|
+
severity
|
|
1230
|
+
});
|
|
1231
|
+
};
|
|
1232
|
+
const ensureMessage = (event, role) => {
|
|
1233
|
+
var _readString;
|
|
1234
|
+
const sourceIndex = sourceIndexFor(event);
|
|
1235
|
+
const key = (_readString = readString(event.payload, [
|
|
1236
|
+
"messageId",
|
|
1237
|
+
"message_id",
|
|
1238
|
+
"id"
|
|
1239
|
+
])) !== null && _readString !== void 0 ? _readString : `message-${sourceIndex}`;
|
|
1240
|
+
let item = messageItems.get(key);
|
|
1241
|
+
if (!item) {
|
|
1242
|
+
item = {
|
|
1243
|
+
id: `message-${key}`,
|
|
1244
|
+
kind: "message",
|
|
1245
|
+
title: `${role || "message"} message`,
|
|
1246
|
+
body: "",
|
|
1247
|
+
timestamp: event.timestamp,
|
|
1248
|
+
sourceIndex
|
|
1249
|
+
};
|
|
1250
|
+
messageItems.set(key, item);
|
|
1251
|
+
items.push(item);
|
|
1252
|
+
}
|
|
1253
|
+
return item;
|
|
1254
|
+
};
|
|
1255
|
+
const ensureTool = (event) => {
|
|
1256
|
+
var _readString2;
|
|
1257
|
+
const sourceIndex = sourceIndexFor(event);
|
|
1258
|
+
const key = (_readString2 = readString(event.payload, [
|
|
1259
|
+
"toolCallId",
|
|
1260
|
+
"tool_call_id",
|
|
1261
|
+
"id",
|
|
1262
|
+
"callId"
|
|
1263
|
+
])) !== null && _readString2 !== void 0 ? _readString2 : `tool-${sourceIndex}`;
|
|
1264
|
+
let item = toolItems.get(key);
|
|
1265
|
+
if (!item) {
|
|
1266
|
+
var _readString3;
|
|
1267
|
+
item = {
|
|
1268
|
+
id: `tool-${key}`,
|
|
1269
|
+
kind: "tool",
|
|
1270
|
+
title: (_readString3 = readString(event.payload, [
|
|
1271
|
+
"toolCallName",
|
|
1272
|
+
"toolName",
|
|
1273
|
+
"name",
|
|
1274
|
+
"functionName"
|
|
1275
|
+
])) !== null && _readString3 !== void 0 ? _readString3 : "Tool call",
|
|
1276
|
+
body: "",
|
|
1277
|
+
timestamp: event.timestamp,
|
|
1278
|
+
sourceIndex
|
|
1279
|
+
};
|
|
1280
|
+
toolItems.set(key, item);
|
|
1281
|
+
items.push(item);
|
|
1282
|
+
}
|
|
1283
|
+
return item;
|
|
1284
|
+
};
|
|
1285
|
+
for (const event of events) {
|
|
1286
|
+
const { type, payload } = event;
|
|
1287
|
+
const sourceIndex = sourceIndexFor(event);
|
|
1288
|
+
if (type === "UNKNOWN") {
|
|
1289
|
+
appendWarning(event, "Unknown AG-UI event", "The event is missing a string type and could not be normalized.");
|
|
1290
|
+
continue;
|
|
1291
|
+
}
|
|
1292
|
+
if (type === "RUN_STARTED" || type === "STEP_STARTED") {
|
|
1293
|
+
items.push({
|
|
1294
|
+
id: `${type}-${sourceIndex}`,
|
|
1295
|
+
kind: "run",
|
|
1296
|
+
title: type === "RUN_STARTED" ? "Run started" : "Step started",
|
|
1297
|
+
timestamp: event.timestamp,
|
|
1298
|
+
sourceIndex,
|
|
1299
|
+
details: payload
|
|
1300
|
+
});
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
if (type === "RUN_FINISHED" || type === "STEP_FINISHED") {
|
|
1304
|
+
items.push({
|
|
1305
|
+
id: `${type}-${sourceIndex}`,
|
|
1306
|
+
kind: "run",
|
|
1307
|
+
title: type === "RUN_FINISHED" ? "Run finished" : "Step finished",
|
|
1308
|
+
timestamp: event.timestamp,
|
|
1309
|
+
sourceIndex,
|
|
1310
|
+
details: payload
|
|
1311
|
+
});
|
|
1312
|
+
continue;
|
|
1313
|
+
}
|
|
1314
|
+
if (type === "RUN_ERROR" || type === "ERROR") {
|
|
1315
|
+
var _readString4;
|
|
1316
|
+
items.push({
|
|
1317
|
+
id: `${type}-${sourceIndex}`,
|
|
1318
|
+
kind: "warning",
|
|
1319
|
+
title: "Run error",
|
|
1320
|
+
body: (_readString4 = readString(payload, [
|
|
1321
|
+
"message",
|
|
1322
|
+
"error",
|
|
1323
|
+
"description"
|
|
1324
|
+
])) !== null && _readString4 !== void 0 ? _readString4 : "",
|
|
1325
|
+
timestamp: event.timestamp,
|
|
1326
|
+
sourceIndex,
|
|
1327
|
+
severity: "error",
|
|
1328
|
+
details: payload
|
|
1329
|
+
});
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (type === "TEXT_MESSAGE_START") {
|
|
1333
|
+
var _readString5;
|
|
1334
|
+
ensureMessage(event, (_readString5 = readString(payload, ["role"])) !== null && _readString5 !== void 0 ? _readString5 : "assistant");
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (type === "TEXT_MESSAGE_CONTENT") {
|
|
1338
|
+
var _readString6, _item$body, _readString7;
|
|
1339
|
+
const item = ensureMessage(event, (_readString6 = readString(payload, ["role"])) !== null && _readString6 !== void 0 ? _readString6 : "assistant");
|
|
1340
|
+
item.body = `${(_item$body = item.body) !== null && _item$body !== void 0 ? _item$body : ""}${(_readString7 = readString(payload, [
|
|
1341
|
+
"delta",
|
|
1342
|
+
"content",
|
|
1343
|
+
"text"
|
|
1344
|
+
])) !== null && _readString7 !== void 0 ? _readString7 : ""}`;
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
if (type === "TEXT_MESSAGE_END") {
|
|
1348
|
+
var _readString8;
|
|
1349
|
+
ensureMessage(event, (_readString8 = readString(payload, ["role"])) !== null && _readString8 !== void 0 ? _readString8 : "assistant");
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
if (type === "TOOL_CALL_START") {
|
|
1353
|
+
ensureTool(event);
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
if (type === "TOOL_CALL_ARGS") {
|
|
1357
|
+
var _readString9;
|
|
1358
|
+
const item = ensureTool(event);
|
|
1359
|
+
const chunk = (_readString9 = readString(payload, [
|
|
1360
|
+
"args",
|
|
1361
|
+
"arguments",
|
|
1362
|
+
"delta"
|
|
1363
|
+
])) !== null && _readString9 !== void 0 ? _readString9 : typeof payload.args === "object" ? JSON.stringify(payload.args) : null;
|
|
1364
|
+
if (chunk) {
|
|
1365
|
+
var _item$rawArgs;
|
|
1366
|
+
item.rawArgs = `${(_item$rawArgs = item.rawArgs) !== null && _item$rawArgs !== void 0 ? _item$rawArgs : ""}${chunk}`;
|
|
1367
|
+
item.body = item.rawArgs;
|
|
1368
|
+
}
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1371
|
+
if (type === "TOOL_CALL_END") {
|
|
1372
|
+
const item = ensureTool(event);
|
|
1373
|
+
if (item.rawArgs) try {
|
|
1374
|
+
JSON.parse(item.rawArgs);
|
|
1375
|
+
} catch (_unused) {
|
|
1376
|
+
appendWarning(event, "Could not decode tool call arguments", item.rawArgs);
|
|
1377
|
+
}
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
if (type === "TOOL_CALL_RESULT") {
|
|
1381
|
+
const item = ensureTool(event);
|
|
1382
|
+
const result = readString(payload, [
|
|
1383
|
+
"result",
|
|
1384
|
+
"content",
|
|
1385
|
+
"delta"
|
|
1386
|
+
]);
|
|
1387
|
+
if (result) {
|
|
1388
|
+
item.body = item.body ? `${item.body}\nResult: ${result}` : `Result: ${result}`;
|
|
1389
|
+
try {
|
|
1390
|
+
JSON.parse(result);
|
|
1391
|
+
} catch (_unused2) {
|
|
1392
|
+
appendWarning(event, "Could not decode tool result", result);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
if (type.startsWith("STATE_")) {
|
|
1398
|
+
items.push({
|
|
1399
|
+
id: `${type}-${sourceIndex}`,
|
|
1400
|
+
kind: "state",
|
|
1401
|
+
title: type === "STATE_SNAPSHOT" ? "State snapshot captured" : "State delta captured",
|
|
1402
|
+
timestamp: event.timestamp,
|
|
1403
|
+
sourceIndex,
|
|
1404
|
+
details: payload
|
|
1405
|
+
});
|
|
1406
|
+
continue;
|
|
1407
|
+
}
|
|
1408
|
+
items.push({
|
|
1409
|
+
id: `event-${sourceIndex}`,
|
|
1410
|
+
kind: "event",
|
|
1411
|
+
title: type,
|
|
1412
|
+
timestamp: event.timestamp,
|
|
1413
|
+
sourceIndex,
|
|
1414
|
+
details: payload
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
return items;
|
|
1418
|
+
}
|
|
1061
1419
|
get renderItems() {
|
|
1062
1420
|
const items = this._conversation;
|
|
1063
1421
|
const result = [];
|
|
@@ -1095,7 +1453,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1095
1453
|
};
|
|
1096
1454
|
}
|
|
1097
1455
|
get duration() {
|
|
1098
|
-
const t = this.
|
|
1456
|
+
const t = this.metadata;
|
|
1099
1457
|
if (!(t === null || t === void 0 ? void 0 : t.createdAt) || !(t === null || t === void 0 ? void 0 : t.updatedAt)) return "—";
|
|
1100
1458
|
const ms = new Date(t.updatedAt).getTime() - new Date(t.createdAt).getTime();
|
|
1101
1459
|
if (ms < 0) return "—";
|
|
@@ -1117,9 +1475,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1117
1475
|
this._expandedMessages = next;
|
|
1118
1476
|
}
|
|
1119
1477
|
get activeEvents() {
|
|
1120
|
-
var _ref, _this$_fetchedEvents;
|
|
1478
|
+
var _ref, _this$_fetchedEvents, _this$_liveEventsWith;
|
|
1121
1479
|
if (this._eventsNotAvailable) return [];
|
|
1122
|
-
|
|
1480
|
+
const events = (_ref = (_this$_fetchedEvents = this._fetchedEvents) !== null && _this$_fetchedEvents !== void 0 ? _this$_fetchedEvents : this.agentEventsInput) !== null && _ref !== void 0 ? _ref : [];
|
|
1481
|
+
if (events.every((event) => event.sourceIndex != null)) return events;
|
|
1482
|
+
if (((_this$_liveEventsWith = this._liveEventsWithSourceIndexCache) === null || _this$_liveEventsWith === void 0 ? void 0 : _this$_liveEventsWith.events) === events) return this._liveEventsWithSourceIndexCache.indexedEvents;
|
|
1483
|
+
const indexedEvents = events.map((event, index) => event.sourceIndex == null ? {
|
|
1484
|
+
...event,
|
|
1485
|
+
sourceIndex: index + 1
|
|
1486
|
+
} : event);
|
|
1487
|
+
this._liveEventsWithSourceIndexCache = {
|
|
1488
|
+
events,
|
|
1489
|
+
indexedEvents
|
|
1490
|
+
};
|
|
1491
|
+
return indexedEvents;
|
|
1123
1492
|
}
|
|
1124
1493
|
get activeState() {
|
|
1125
1494
|
var _ref2, _this$_fetchedState;
|
|
@@ -1134,6 +1503,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1134
1503
|
if (!id) return "—";
|
|
1135
1504
|
return id.length > 20 ? id.slice(0, 8) + "…" : id;
|
|
1136
1505
|
}
|
|
1506
|
+
get metadata() {
|
|
1507
|
+
var _ref3, _this$_fetchedMetadat;
|
|
1508
|
+
return (_ref3 = (_this$_fetchedMetadat = this._fetchedMetadata) !== null && _this$_fetchedMetadat !== void 0 ? _this$_fetchedMetadat : this.thread) !== null && _ref3 !== void 0 ? _ref3 : null;
|
|
1509
|
+
}
|
|
1137
1510
|
fmtTime(dateStr) {
|
|
1138
1511
|
if (!dateStr) return "—";
|
|
1139
1512
|
const d = new Date(dateStr);
|
|
@@ -1153,7 +1526,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1153
1526
|
<!-- Tab bar -->
|
|
1154
1527
|
<div class="cpk-td__tabs-header">
|
|
1155
1528
|
<div class="cpk-td__tab-group" role="tablist">
|
|
1156
|
-
${
|
|
1529
|
+
${CpkThreadInspector.TAB_LIST.map((tab) => lit.html`
|
|
1157
1530
|
<button
|
|
1158
1531
|
role="tab"
|
|
1159
1532
|
class="cpk-td__tab ${this._tab === tab.id ? "cpk-td__tab--active" : ""}"
|
|
@@ -1165,18 +1538,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1165
1538
|
</div>
|
|
1166
1539
|
${this.renderPanelToggle()}
|
|
1167
1540
|
</div>
|
|
1541
|
+
${this.renderMetadataStrip()}
|
|
1168
1542
|
|
|
1169
1543
|
<!-- Scrollable content -->
|
|
1170
1544
|
<div class="cpk-td__content">
|
|
1171
1545
|
${this._panelInitializing ? lit.html`
|
|
1172
1546
|
<div class="cpk-td__status">Loading…</div>
|
|
1173
1547
|
` : lit.nothing}
|
|
1174
|
-
${
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1548
|
+
${CpkThreadInspector.TAB_LIST.map((tab) => this._activatedTabs.has(tab.id) ? lit.html`<div
|
|
1549
|
+
class="cpk-td__panel"
|
|
1550
|
+
style=${this._tab === tab.id && !this._panelInitializing ? "" : "display:none"}
|
|
1551
|
+
>
|
|
1552
|
+
${this.renderTabContent(tab.id)}
|
|
1553
|
+
</div>` : lit.nothing)}
|
|
1180
1554
|
</div>
|
|
1181
1555
|
</div>
|
|
1182
1556
|
|
|
@@ -1204,6 +1578,122 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1204
1578
|
${this.renderDetailPanel()}
|
|
1205
1579
|
</div>
|
|
1206
1580
|
</div>
|
|
1581
|
+
`;
|
|
1582
|
+
}
|
|
1583
|
+
renderMetadataStrip() {
|
|
1584
|
+
var _metadata$id, _metadata$endUserId;
|
|
1585
|
+
const metadata = this.metadata;
|
|
1586
|
+
const pills = [
|
|
1587
|
+
{
|
|
1588
|
+
label: "Thread",
|
|
1589
|
+
value: (_metadata$id = metadata === null || metadata === void 0 ? void 0 : metadata.id) !== null && _metadata$id !== void 0 ? _metadata$id : this.threadId
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
label: "Agent",
|
|
1593
|
+
value: metadata === null || metadata === void 0 ? void 0 : metadata.agentId
|
|
1594
|
+
},
|
|
1595
|
+
{
|
|
1596
|
+
label: "End user",
|
|
1597
|
+
value: (_metadata$endUserId = metadata === null || metadata === void 0 ? void 0 : metadata.endUserId) !== null && _metadata$endUserId !== void 0 ? _metadata$endUserId : metadata === null || metadata === void 0 ? void 0 : metadata.createdById
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
label: "Status",
|
|
1601
|
+
value: metadata === null || metadata === void 0 ? void 0 : metadata.status
|
|
1602
|
+
}
|
|
1603
|
+
].filter((pill) => pill.value != null && pill.value !== "");
|
|
1604
|
+
if (pills.length === 0) return lit.nothing;
|
|
1605
|
+
return lit.html`
|
|
1606
|
+
<div class="cpk-td__metadata-strip" aria-label="Thread metadata">
|
|
1607
|
+
${pills.map((pill) => {
|
|
1608
|
+
var _pill$value;
|
|
1609
|
+
return lit.html`
|
|
1610
|
+
<span class="cpk-td__metadata-pill" title=${(_pill$value = pill.value) !== null && _pill$value !== void 0 ? _pill$value : ""}>
|
|
1611
|
+
<span class="cpk-td__metadata-label">${pill.label}</span>
|
|
1612
|
+
<span class="cpk-td__metadata-value"
|
|
1613
|
+
>${this.shortId(pill.value)}</span
|
|
1614
|
+
>
|
|
1615
|
+
</span>
|
|
1616
|
+
`;
|
|
1617
|
+
})}
|
|
1618
|
+
</div>
|
|
1619
|
+
`;
|
|
1620
|
+
}
|
|
1621
|
+
revealSourceEvent(sourceIndex) {
|
|
1622
|
+
this._activatedTabs = new Set([...this._activatedTabs, "raw-events"]);
|
|
1623
|
+
this._tab = "raw-events";
|
|
1624
|
+
this.requestUpdate();
|
|
1625
|
+
requestAnimationFrame(() => {
|
|
1626
|
+
var _this$shadowRoot, _source$scrollIntoVie;
|
|
1627
|
+
const source = (_this$shadowRoot = this.shadowRoot) === null || _this$shadowRoot === void 0 ? void 0 : _this$shadowRoot.querySelector(`[data-source-index="${sourceIndex}"]`);
|
|
1628
|
+
source === null || source === void 0 || (_source$scrollIntoVie = source.scrollIntoView) === null || _source$scrollIntoVie === void 0 || _source$scrollIntoVie.call(source, { block: "center" });
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
renderTimeline() {
|
|
1632
|
+
if (this._loadingEvents) return lit.html`
|
|
1633
|
+
<div class="cpk-td__status">Loading timeline…</div>
|
|
1634
|
+
`;
|
|
1635
|
+
if (this._eventsError) return lit.html`<div class="cpk-td__status cpk-td__status--error">
|
|
1636
|
+
${this._eventsError}
|
|
1637
|
+
</div>`;
|
|
1638
|
+
if (this._eventsNotAvailable) {
|
|
1639
|
+
if (this._conversation.length > 0) return this.renderConversation();
|
|
1640
|
+
if (this._loadingMessages) return this.renderConversation();
|
|
1641
|
+
return lit.html`
|
|
1642
|
+
<div class="cpk-td__empty-state">
|
|
1643
|
+
<span>Timeline event history not available</span>
|
|
1644
|
+
<span class="cpk-td__empty-hint"
|
|
1645
|
+
>This runtime doesn't yet expose per-thread AG-UI events. Check State for
|
|
1646
|
+
the latest snapshot when available.</span
|
|
1647
|
+
>
|
|
1648
|
+
</div>
|
|
1649
|
+
`;
|
|
1650
|
+
}
|
|
1651
|
+
const events = this.activeEvents;
|
|
1652
|
+
const cachedTimeline = this.getCachedPanelTpl("timeline", [events]);
|
|
1653
|
+
if (cachedTimeline) return cachedTimeline;
|
|
1654
|
+
const timelineItems = this.timelineItemsForEvents(events);
|
|
1655
|
+
if (timelineItems.length === 0) {
|
|
1656
|
+
if (this._conversation.length > 0) return this.renderConversation();
|
|
1657
|
+
if (this._loadingMessages) return this.renderConversation();
|
|
1658
|
+
return lit.html`
|
|
1659
|
+
<div class="cpk-td__empty-state">
|
|
1660
|
+
<span>No timeline events captured</span>
|
|
1661
|
+
<span class="cpk-td__empty-hint"
|
|
1662
|
+
>Timeline rows are normalized from AG-UI events. Open Raw AG-UI Events or
|
|
1663
|
+
State to inspect the available thread data.</span
|
|
1664
|
+
>
|
|
1665
|
+
</div>
|
|
1666
|
+
`;
|
|
1667
|
+
}
|
|
1668
|
+
return this.cachedPanelTpl("timeline", [events], () => {
|
|
1669
|
+
return lit.html`${timelineItems.map((item) => this.renderTimelineItem(item))}`;
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
renderTimelineItem(item) {
|
|
1673
|
+
return lit.html`
|
|
1674
|
+
<div
|
|
1675
|
+
class="cpk-td__timeline-item ${item.kind === "warning" ? "cpk-td__timeline-item--warning" : ""}"
|
|
1676
|
+
>
|
|
1677
|
+
<div class="cpk-td__timeline-header">
|
|
1678
|
+
<span class="cpk-td__timeline-kind"
|
|
1679
|
+
>${item.severity === "error" ? "error" : item.kind}</span
|
|
1680
|
+
>
|
|
1681
|
+
<span class="cpk-td__timeline-title">${item.title}</span>
|
|
1682
|
+
<button
|
|
1683
|
+
type="button"
|
|
1684
|
+
class="cpk-td__source-link"
|
|
1685
|
+
@click=${() => this.revealSourceEvent(item.sourceIndex)}
|
|
1686
|
+
>
|
|
1687
|
+
Source event #${item.sourceIndex}
|
|
1688
|
+
</button>
|
|
1689
|
+
<span class="cpk-td__timeline-time"
|
|
1690
|
+
>${formatTimestamp(item.timestamp)}</span
|
|
1691
|
+
>
|
|
1692
|
+
</div>
|
|
1693
|
+
${item.body ? lit.html`<div class="cpk-td__timeline-body">${item.body}</div>` : item.details ? lit.html`<pre class="cpk-td__timeline-body">
|
|
1694
|
+
${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.details))}</pre
|
|
1695
|
+
>` : lit.nothing}
|
|
1696
|
+
</div>
|
|
1207
1697
|
`;
|
|
1208
1698
|
}
|
|
1209
1699
|
renderConversation() {
|
|
@@ -1230,7 +1720,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1230
1720
|
<span>No messages yet</span>
|
|
1231
1721
|
</div>
|
|
1232
1722
|
`;
|
|
1233
|
-
return this.cachedPanelTpl("
|
|
1723
|
+
return this.cachedPanelTpl("timeline-fallback", [
|
|
1234
1724
|
this._conversation,
|
|
1235
1725
|
this._expandedTools,
|
|
1236
1726
|
this._expandedMessages
|
|
@@ -1248,8 +1738,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1248
1738
|
* change without the listed key flipping.
|
|
1249
1739
|
*/
|
|
1250
1740
|
cachedPanelTpl(slot, key, build) {
|
|
1251
|
-
const cached = this.
|
|
1252
|
-
if (cached
|
|
1741
|
+
const cached = this.getCachedPanelTpl(slot, key);
|
|
1742
|
+
if (cached) return cached;
|
|
1253
1743
|
const tpl = build();
|
|
1254
1744
|
this._panelTplCache.set(slot, {
|
|
1255
1745
|
key,
|
|
@@ -1257,6 +1747,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1257
1747
|
});
|
|
1258
1748
|
return tpl;
|
|
1259
1749
|
}
|
|
1750
|
+
getCachedPanelTpl(slot, key) {
|
|
1751
|
+
const cached = this._panelTplCache.get(slot);
|
|
1752
|
+
if (cached && cached.key.length === key.length && cached.key.every((v, i) => v === key[i])) return cached.tpl;
|
|
1753
|
+
return null;
|
|
1754
|
+
}
|
|
1260
1755
|
renderRenderItem(item) {
|
|
1261
1756
|
switch (item.type) {
|
|
1262
1757
|
case "user":
|
|
@@ -1277,7 +1772,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1277
1772
|
}
|
|
1278
1773
|
renderBubble(item) {
|
|
1279
1774
|
const isUser = item.type === "user";
|
|
1280
|
-
const threshold =
|
|
1775
|
+
const threshold = CpkThreadInspector.COLLAPSE_THRESHOLD;
|
|
1281
1776
|
const expanded = this._expandedMessages.has(item.id);
|
|
1282
1777
|
const tooLong = item.content.length > threshold;
|
|
1283
1778
|
const shown = tooLong && !expanded ? item.content.slice(0, threshold) + "…" : item.content;
|
|
@@ -1423,7 +1918,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(item.result))}</
|
|
|
1423
1918
|
</div>
|
|
1424
1919
|
`;
|
|
1425
1920
|
const stateValue = this.activeState;
|
|
1426
|
-
return this.cachedPanelTpl("
|
|
1921
|
+
return this.cachedPanelTpl("state", [stateValue], () => {
|
|
1427
1922
|
return lit.html`<pre class="cpk-td__json-block">
|
|
1428
1923
|
${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</pre
|
|
1429
1924
|
>`;
|
|
@@ -1454,11 +1949,12 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
|
|
|
1454
1949
|
>
|
|
1455
1950
|
</div>
|
|
1456
1951
|
`;
|
|
1457
|
-
return this.cachedPanelTpl("
|
|
1952
|
+
return this.cachedPanelTpl("raw-events", [events], () => {
|
|
1458
1953
|
return lit.html`${events.map((event) => {
|
|
1954
|
+
var _event$rawEvent;
|
|
1459
1955
|
const { bg, fg } = eventColors(event.type);
|
|
1460
1956
|
return lit.html`
|
|
1461
|
-
<div class="cpk-td__event">
|
|
1957
|
+
<div class="cpk-td__event" data-source-index=${event.sourceIndex}>
|
|
1462
1958
|
<div class="cpk-td__event-header" style="background:${bg}">
|
|
1463
1959
|
<span class="cpk-td__event-type" style="color:${fg}"
|
|
1464
1960
|
>${event.type}</span
|
|
@@ -1468,7 +1964,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(stateValue))}</p
|
|
|
1468
1964
|
>
|
|
1469
1965
|
</div>
|
|
1470
1966
|
<pre class="cpk-td__event-payload">
|
|
1471
|
-
${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.
|
|
1967
|
+
${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson((_event$rawEvent = event.rawEvent) !== null && _event$rawEvent !== void 0 ? _event$rawEvent : event))}</pre
|
|
1472
1968
|
>
|
|
1473
1969
|
</div>
|
|
1474
1970
|
`;
|
|
@@ -1502,31 +1998,44 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1502
1998
|
`;
|
|
1503
1999
|
}
|
|
1504
2000
|
renderDetailPanel() {
|
|
1505
|
-
var
|
|
2001
|
+
var _metadata$name, _metadata$agentId, _metadata$endUserId2, _metadata$createdById, _metadata$status;
|
|
1506
2002
|
const counts = this.activityCounts;
|
|
2003
|
+
const metadata = this.metadata;
|
|
1507
2004
|
return lit.html`
|
|
1508
2005
|
<!-- Thread -->
|
|
1509
2006
|
<div class="cpk-tdp__section-title">Thread</div>
|
|
1510
2007
|
<div class="cpk-tdp__row">
|
|
1511
2008
|
<span class="cpk-tdp__label">ID</span>
|
|
1512
2009
|
<span class="cpk-tdp__value cpk-tdp__value--wrap"
|
|
1513
|
-
>${this.shortId(
|
|
2010
|
+
>${this.shortId(metadata === null || metadata === void 0 ? void 0 : metadata.id)}</span
|
|
1514
2011
|
>
|
|
1515
2012
|
</div>
|
|
1516
2013
|
<div class="cpk-tdp__row">
|
|
1517
2014
|
<span class="cpk-tdp__label">Name</span>
|
|
1518
|
-
<span class="cpk-tdp__value">${(
|
|
2015
|
+
<span class="cpk-tdp__value">${(_metadata$name = metadata === null || metadata === void 0 ? void 0 : metadata.name) !== null && _metadata$name !== void 0 ? _metadata$name : "—"}</span>
|
|
1519
2016
|
</div>
|
|
1520
2017
|
<div class="cpk-tdp__row">
|
|
1521
2018
|
<span class="cpk-tdp__label">Agent</span>
|
|
1522
2019
|
<span class="cpk-tdp__value cpk-tdp__value--truncate"
|
|
1523
|
-
>${(
|
|
2020
|
+
>${(_metadata$agentId = metadata === null || metadata === void 0 ? void 0 : metadata.agentId) !== null && _metadata$agentId !== void 0 ? _metadata$agentId : "—"}</span
|
|
2021
|
+
>
|
|
2022
|
+
</div>
|
|
2023
|
+
<div class="cpk-tdp__row">
|
|
2024
|
+
<span class="cpk-tdp__label">End user</span>
|
|
2025
|
+
<span class="cpk-tdp__value cpk-tdp__value--truncate"
|
|
2026
|
+
>${(_metadata$endUserId2 = metadata === null || metadata === void 0 ? void 0 : metadata.endUserId) !== null && _metadata$endUserId2 !== void 0 ? _metadata$endUserId2 : "—"}</span
|
|
1524
2027
|
>
|
|
1525
2028
|
</div>
|
|
1526
2029
|
<div class="cpk-tdp__row">
|
|
1527
2030
|
<span class="cpk-tdp__label">Created by</span>
|
|
1528
2031
|
<span class="cpk-tdp__value cpk-tdp__value--truncate"
|
|
1529
|
-
>${(
|
|
2032
|
+
>${(_metadata$createdById = metadata === null || metadata === void 0 ? void 0 : metadata.createdById) !== null && _metadata$createdById !== void 0 ? _metadata$createdById : "—"}</span
|
|
2033
|
+
>
|
|
2034
|
+
</div>
|
|
2035
|
+
<div class="cpk-tdp__row">
|
|
2036
|
+
<span class="cpk-tdp__label">Status</span>
|
|
2037
|
+
<span class="cpk-tdp__value cpk-tdp__value--truncate"
|
|
2038
|
+
>${(_metadata$status = metadata === null || metadata === void 0 ? void 0 : metadata.status) !== null && _metadata$status !== void 0 ? _metadata$status : "—"}</span
|
|
1530
2039
|
>
|
|
1531
2040
|
</div>
|
|
1532
2041
|
|
|
@@ -1536,11 +2045,11 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1536
2045
|
<div class="cpk-tdp__section-title">Timestamps</div>
|
|
1537
2046
|
<div class="cpk-tdp__row">
|
|
1538
2047
|
<span class="cpk-tdp__label">Created</span>
|
|
1539
|
-
<span class="cpk-tdp__value">${this.fmtTime(
|
|
2048
|
+
<span class="cpk-tdp__value">${this.fmtTime(metadata === null || metadata === void 0 ? void 0 : metadata.createdAt)}</span>
|
|
1540
2049
|
</div>
|
|
1541
2050
|
<div class="cpk-tdp__row">
|
|
1542
2051
|
<span class="cpk-tdp__label">Updated</span>
|
|
1543
|
-
<span class="cpk-tdp__value">${this.fmtTime(
|
|
2052
|
+
<span class="cpk-tdp__value">${this.fmtTime(metadata === null || metadata === void 0 ? void 0 : metadata.updatedAt)}</span>
|
|
1544
2053
|
</div>
|
|
1545
2054
|
<div class="cpk-tdp__row">
|
|
1546
2055
|
<span class="cpk-tdp__label">Duration</span>
|
|
@@ -1566,8 +2075,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1566
2075
|
`;
|
|
1567
2076
|
}
|
|
1568
2077
|
};
|
|
1569
|
-
|
|
2078
|
+
CpkThreadInspector.properties = {
|
|
1570
2079
|
threadId: { attribute: false },
|
|
2080
|
+
provider: { attribute: false },
|
|
1571
2081
|
thread: { attribute: false },
|
|
1572
2082
|
runtimeUrl: { attribute: false },
|
|
1573
2083
|
headers: { attribute: false },
|
|
@@ -1576,6 +2086,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1576
2086
|
agentEventsInput: { attribute: false },
|
|
1577
2087
|
liveMessageVersion: { attribute: false },
|
|
1578
2088
|
_tab: { state: true },
|
|
2089
|
+
_fetchedMetadata: { state: true },
|
|
1579
2090
|
_conversation: { state: true },
|
|
1580
2091
|
_fetchedEvents: { state: true },
|
|
1581
2092
|
_fetchedState: { state: true },
|
|
@@ -1594,22 +2105,24 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1594
2105
|
_panelInitializing: { state: true },
|
|
1595
2106
|
_activatedTabs: { state: true }
|
|
1596
2107
|
};
|
|
1597
|
-
|
|
1598
|
-
|
|
2108
|
+
CpkThreadInspector.COLLAPSE_THRESHOLD = 800;
|
|
2109
|
+
CpkThreadInspector.TAB_LIST = [
|
|
1599
2110
|
{
|
|
1600
|
-
id: "
|
|
1601
|
-
label: "
|
|
2111
|
+
id: "timeline",
|
|
2112
|
+
label: "Timeline"
|
|
1602
2113
|
},
|
|
1603
2114
|
{
|
|
1604
|
-
id: "
|
|
1605
|
-
label: "
|
|
2115
|
+
id: "raw-events",
|
|
2116
|
+
label: "Raw AG-UI Events"
|
|
1606
2117
|
},
|
|
1607
2118
|
{
|
|
1608
|
-
id: "
|
|
1609
|
-
label: "
|
|
2119
|
+
id: "state",
|
|
2120
|
+
label: "State"
|
|
1610
2121
|
}
|
|
1611
2122
|
];
|
|
1612
|
-
|
|
2123
|
+
CpkThreadInspector.providerIds = /* @__PURE__ */ new WeakMap();
|
|
2124
|
+
CpkThreadInspector.nextProviderId = 1;
|
|
2125
|
+
CpkThreadInspector.styles = lit.css`
|
|
1613
2126
|
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&family=Spline+Sans+Mono:wght@400;500&display=swap");
|
|
1614
2127
|
|
|
1615
2128
|
/* ── Root ────────────────────────────────────────────────────────── */
|
|
@@ -1735,6 +2248,42 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1735
2248
|
flex-shrink: 0;
|
|
1736
2249
|
}
|
|
1737
2250
|
|
|
2251
|
+
.cpk-td__metadata-strip {
|
|
2252
|
+
display: flex;
|
|
2253
|
+
gap: 6px;
|
|
2254
|
+
flex-wrap: wrap;
|
|
2255
|
+
padding: 10px 16px;
|
|
2256
|
+
border-bottom: 1px solid #e9e9ef;
|
|
2257
|
+
background: #fbfbfd;
|
|
2258
|
+
flex-shrink: 0;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
.cpk-td__metadata-pill {
|
|
2262
|
+
display: inline-flex;
|
|
2263
|
+
align-items: center;
|
|
2264
|
+
gap: 5px;
|
|
2265
|
+
max-width: 220px;
|
|
2266
|
+
padding: 3px 7px;
|
|
2267
|
+
border: 1px solid #e9e9ef;
|
|
2268
|
+
border-radius: 5px;
|
|
2269
|
+
background: #ffffff;
|
|
2270
|
+
color: #57575b;
|
|
2271
|
+
font-family: "Spline Sans Mono", monospace;
|
|
2272
|
+
font-size: 10px;
|
|
2273
|
+
white-space: nowrap;
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
.cpk-td__metadata-label {
|
|
2277
|
+
color: #838389;
|
|
2278
|
+
text-transform: uppercase;
|
|
2279
|
+
font-size: 9px;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
.cpk-td__metadata-value {
|
|
2283
|
+
overflow: hidden;
|
|
2284
|
+
text-overflow: ellipsis;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
1738
2287
|
/*
|
|
1739
2288
|
* Each tab's content is wrapped in this panel so the keep-mounted
|
|
1740
2289
|
* inactive panels can be hidden via display:none without disturbing
|
|
@@ -1955,6 +2504,81 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
1955
2504
|
background: #e9e9ef;
|
|
1956
2505
|
}
|
|
1957
2506
|
|
|
2507
|
+
/* ── Interaction timeline ───────────────────────────────────────── */
|
|
2508
|
+
.cpk-td__timeline-item {
|
|
2509
|
+
border: 1px solid #e9e9ef;
|
|
2510
|
+
border-radius: 6px;
|
|
2511
|
+
background: #ffffff;
|
|
2512
|
+
overflow: hidden;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
.cpk-td__timeline-item--warning {
|
|
2516
|
+
border-color: rgba(250, 95, 103, 0.35);
|
|
2517
|
+
background: rgba(250, 95, 103, 0.04);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
.cpk-td__timeline-header {
|
|
2521
|
+
display: flex;
|
|
2522
|
+
align-items: center;
|
|
2523
|
+
gap: 8px;
|
|
2524
|
+
padding: 7px 10px;
|
|
2525
|
+
background: #f7f7f9;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
.cpk-td__timeline-kind {
|
|
2529
|
+
font-family: "Spline Sans Mono", monospace;
|
|
2530
|
+
font-size: 9px;
|
|
2531
|
+
font-weight: 600;
|
|
2532
|
+
text-transform: uppercase;
|
|
2533
|
+
color: #5558b2;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
.cpk-td__timeline-title {
|
|
2537
|
+
flex: 1;
|
|
2538
|
+
min-width: 0;
|
|
2539
|
+
font-size: 12px;
|
|
2540
|
+
font-weight: 500;
|
|
2541
|
+
color: #010507;
|
|
2542
|
+
overflow: hidden;
|
|
2543
|
+
text-overflow: ellipsis;
|
|
2544
|
+
white-space: nowrap;
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
.cpk-td__timeline-time {
|
|
2548
|
+
font-family: "Spline Sans Mono", monospace;
|
|
2549
|
+
font-size: 9px;
|
|
2550
|
+
color: #838389;
|
|
2551
|
+
flex-shrink: 0;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.cpk-td__timeline-body {
|
|
2555
|
+
padding: 9px 10px;
|
|
2556
|
+
font-size: 12px;
|
|
2557
|
+
line-height: 1.55;
|
|
2558
|
+
color: #57575b;
|
|
2559
|
+
white-space: pre-wrap;
|
|
2560
|
+
word-break: break-word;
|
|
2561
|
+
border-top: 1px solid #e9e9ef;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
.cpk-td__source-link {
|
|
2565
|
+
margin: 0;
|
|
2566
|
+
padding: 0;
|
|
2567
|
+
border: none;
|
|
2568
|
+
background: transparent;
|
|
2569
|
+
color: #5558b2;
|
|
2570
|
+
cursor: pointer;
|
|
2571
|
+
font-family: "Spline Sans Mono", monospace;
|
|
2572
|
+
font-size: 9px;
|
|
2573
|
+
text-decoration: underline;
|
|
2574
|
+
text-underline-offset: 2px;
|
|
2575
|
+
flex-shrink: 0;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
.cpk-td__source-link:hover {
|
|
2579
|
+
color: #010507;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
1958
2582
|
/* ── Generative UI ──────────────────────────────────────────────── */
|
|
1959
2583
|
@keyframes cpk-genui-enter {
|
|
1960
2584
|
from {
|
|
@@ -2162,7 +2786,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
2162
2786
|
text-align: right;
|
|
2163
2787
|
}
|
|
2164
2788
|
`;
|
|
2789
|
+
var ɵCpkThreadDetails = class extends CpkThreadInspector {};
|
|
2165
2790
|
if (!customElements.get("cpk-thread-list")) customElements.define("cpk-thread-list", CpkThreadList);
|
|
2791
|
+
if (!customElements.get(THREAD_INSPECTOR_TAG)) customElements.define(THREAD_INSPECTOR_TAG, CpkThreadInspector);
|
|
2166
2792
|
if (!customElements.get("cpk-thread-details")) customElements.define("cpk-thread-details", ɵCpkThreadDetails);
|
|
2167
2793
|
var WebInspectorElement = class extends lit.LitElement {
|
|
2168
2794
|
constructor(..._args3) {
|
|
@@ -2737,6 +3363,7 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
2737
3363
|
},
|
|
2738
3364
|
onHeadersChanged: ({ headers }) => {
|
|
2739
3365
|
this.updateOwnedThreadStoreHeaders(headers);
|
|
3366
|
+
this.requestUpdate();
|
|
2740
3367
|
},
|
|
2741
3368
|
onError: ({ code, error }) => {
|
|
2742
3369
|
this.lastCoreError = {
|
|
@@ -2748,6 +3375,9 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
2748
3375
|
onAgentsChanged: ({ agents }) => {
|
|
2749
3376
|
this.processAgentsChanged(agents);
|
|
2750
3377
|
},
|
|
3378
|
+
onAgentRunStarted: ({ agent }) => {
|
|
3379
|
+
if (agent === null || agent === void 0 ? void 0 : agent.agentId) this.subscribeToAgent(agent);
|
|
3380
|
+
},
|
|
2751
3381
|
onContextChanged: ({ context }) => {
|
|
2752
3382
|
this.contextStore = this.normalizeContextStore(context);
|
|
2753
3383
|
this.requestUpdate();
|
|
@@ -3135,8 +3765,8 @@ ${(0, lit_directives_unsafe_html_js.unsafeHTML)(highlightedJson(event.payload))}
|
|
|
3135
3765
|
return lit.html`
|
|
3136
3766
|
<div class="mt-2 space-y-2">
|
|
3137
3767
|
${toolCalls.map((call, index) => {
|
|
3138
|
-
var
|
|
3139
|
-
const functionName = (
|
|
3768
|
+
var _ref4, _call$function$name, _call$function, _call$function2;
|
|
3769
|
+
const functionName = (_ref4 = (_call$function$name = (_call$function = call.function) === null || _call$function === void 0 ? void 0 : _call$function.name) !== null && _call$function$name !== void 0 ? _call$function$name : call.toolName) !== null && _ref4 !== void 0 ? _ref4 : "Unknown function";
|
|
3140
3770
|
const callId = typeof (call === null || call === void 0 ? void 0 : call.id) === "string" ? call.id : `tool-call-${index + 1}`;
|
|
3141
3771
|
const argsString = this.formatToolCallArguments((_call$function2 = call.function) === null || _call$function2 === void 0 ? void 0 : _call$function2.arguments);
|
|
3142
3772
|
return lit.html`
|
|
@@ -3165,12 +3795,12 @@ ${argsString}</pre
|
|
|
3165
3795
|
if (typeof args === "string") try {
|
|
3166
3796
|
const parsed = JSON.parse(args);
|
|
3167
3797
|
return JSON.stringify(parsed, null, 2);
|
|
3168
|
-
} catch (
|
|
3798
|
+
} catch (_unused3) {
|
|
3169
3799
|
return args;
|
|
3170
3800
|
}
|
|
3171
3801
|
if (typeof args === "object") try {
|
|
3172
3802
|
return JSON.stringify(args, null, 2);
|
|
3173
|
-
} catch (
|
|
3803
|
+
} catch (_unused4) {
|
|
3174
3804
|
return String(args);
|
|
3175
3805
|
}
|
|
3176
3806
|
return String(args);
|
|
@@ -3193,13 +3823,13 @@ ${argsString}</pre
|
|
|
3193
3823
|
try {
|
|
3194
3824
|
const parsed = JSON.parse(trimmed);
|
|
3195
3825
|
return JSON.stringify(parsed, null, 2);
|
|
3196
|
-
} catch (
|
|
3826
|
+
} catch (_unused5) {
|
|
3197
3827
|
return state;
|
|
3198
3828
|
}
|
|
3199
3829
|
}
|
|
3200
3830
|
if (typeof state === "object") try {
|
|
3201
3831
|
return JSON.stringify(state, null, 2);
|
|
3202
|
-
} catch (
|
|
3832
|
+
} catch (_unused6) {
|
|
3203
3833
|
return String(state);
|
|
3204
3834
|
}
|
|
3205
3835
|
return String(state);
|
|
@@ -3884,7 +4514,7 @@ ${argsString}</pre
|
|
|
3884
4514
|
if (content === null || content === void 0) return "";
|
|
3885
4515
|
if (typeof content === "object") try {
|
|
3886
4516
|
return JSON.stringify(this.sanitizeForLogging(content));
|
|
3887
|
-
} catch (
|
|
4517
|
+
} catch (_unused7) {
|
|
3888
4518
|
return "";
|
|
3889
4519
|
}
|
|
3890
4520
|
return String(content);
|
|
@@ -4012,7 +4642,9 @@ ${argsString}</pre
|
|
|
4012
4642
|
|
|
4013
4643
|
<div class="space-y-2">
|
|
4014
4644
|
<h3 class="text-sm text-slate-500">Privacy</h3>
|
|
4015
|
-
<div
|
|
4645
|
+
<div
|
|
4646
|
+
class="rounded-lg border border-slate-200 bg-white p-4 space-y-3"
|
|
4647
|
+
>
|
|
4016
4648
|
<p class="text-sm text-gray-600 flex items-start gap-2">
|
|
4017
4649
|
<span>${optedOut ? "❌" : "✅"}</span>
|
|
4018
4650
|
<span>
|
|
@@ -4024,7 +4656,8 @@ ${argsString}</pre
|
|
|
4024
4656
|
href=${TELEMETRY_DOCS_URL}
|
|
4025
4657
|
target="_blank"
|
|
4026
4658
|
rel="noopener"
|
|
4027
|
-
|
|
4659
|
+
>Learn more →</a
|
|
4660
|
+
>
|
|
4028
4661
|
</div>
|
|
4029
4662
|
</div>
|
|
4030
4663
|
</div>
|
|
@@ -4563,10 +5196,10 @@ ${argsString}</pre
|
|
|
4563
5196
|
<div class="relative h-full w-full overflow-y-auto overflow-x-hidden">
|
|
4564
5197
|
<table class="w-full table-fixed border-collapse text-xs box-border">
|
|
4565
5198
|
<colgroup>
|
|
4566
|
-
<col style="width:${this.evtColWidths[0]}px"
|
|
4567
|
-
<col style="width:${this.evtColWidths[1]}px"
|
|
4568
|
-
<col style="width:${this.evtColWidths[2]}px"
|
|
4569
|
-
<col
|
|
5199
|
+
<col style="width:${this.evtColWidths[0]}px" />
|
|
5200
|
+
<col style="width:${this.evtColWidths[1]}px" />
|
|
5201
|
+
<col style="width:${this.evtColWidths[2]}px" />
|
|
5202
|
+
<col />
|
|
4570
5203
|
</colgroup>
|
|
4571
5204
|
<thead class="sticky top-0 z-10">
|
|
4572
5205
|
<tr class="bg-white">
|
|
@@ -4574,20 +5207,19 @@ ${argsString}</pre
|
|
|
4574
5207
|
"Agent",
|
|
4575
5208
|
"Time",
|
|
4576
5209
|
"Event Type"
|
|
4577
|
-
].map((label, col) => lit.html`
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
</th>`)}
|
|
5210
|
+
].map((label, col) => lit.html` <th
|
|
5211
|
+
class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
|
|
5212
|
+
style="position:relative;overflow:hidden;"
|
|
5213
|
+
>
|
|
5214
|
+
${label}
|
|
5215
|
+
<div
|
|
5216
|
+
style="position:absolute;top:0;right:0;width:5px;height:100%;cursor:col-resize;user-select:none;background:transparent;"
|
|
5217
|
+
@pointerdown=${(e) => this._onEvtColResizeStart(e, col)}
|
|
5218
|
+
@pointermove=${(e) => this._onEvtColResizeMove(e)}
|
|
5219
|
+
@pointerup=${() => this._onEvtColResizeEnd()}
|
|
5220
|
+
@pointercancel=${() => this._onEvtColResizeEnd()}
|
|
5221
|
+
></div>
|
|
5222
|
+
</th>`)}
|
|
4591
5223
|
<th
|
|
4592
5224
|
class="border-b border-gray-200 bg-white px-3 py-2 text-left font-medium text-gray-900"
|
|
4593
5225
|
>
|
|
@@ -4848,8 +5480,14 @@ ${prettyEvent}</pre
|
|
|
4848
5480
|
${messages && messages.length > 0 ? lit.html`
|
|
4849
5481
|
<div class="w-full text-xs">
|
|
4850
5482
|
<div class="flex bg-gray-50">
|
|
4851
|
-
<div
|
|
4852
|
-
|
|
5483
|
+
<div
|
|
5484
|
+
class="w-40 shrink-0 px-4 py-2 font-medium text-gray-700"
|
|
5485
|
+
>
|
|
5486
|
+
Role
|
|
5487
|
+
</div>
|
|
5488
|
+
<div class="flex-1 px-4 py-2 font-medium text-gray-700">
|
|
5489
|
+
Content
|
|
5490
|
+
</div>
|
|
4853
5491
|
</div>
|
|
4854
5492
|
<div class="divide-y divide-gray-200">
|
|
4855
5493
|
${messages.map((msg) => {
|
|
@@ -4979,8 +5617,8 @@ ${prettyEvent}</pre
|
|
|
4979
5617
|
this.autoSelectLatestThread();
|
|
4980
5618
|
}
|
|
4981
5619
|
if (key === "ag-ui-events" || key === "agents") requestAnimationFrame(() => {
|
|
4982
|
-
var _this$
|
|
4983
|
-
const scroller = (_this$
|
|
5620
|
+
var _this$shadowRoot2;
|
|
5621
|
+
const scroller = (_this$shadowRoot2 = this.shadowRoot) === null || _this$shadowRoot2 === void 0 ? void 0 : _this$shadowRoot2.getElementById("cpk-main-scroll");
|
|
4984
5622
|
if (scroller) scroller.scrollTop = 0;
|
|
4985
5623
|
});
|
|
4986
5624
|
this.contextMenuOpen = false;
|
|
@@ -5280,9 +5918,9 @@ ${prettyEvent}</pre
|
|
|
5280
5918
|
let currentSchema = schema;
|
|
5281
5919
|
let def = currentSchema._def;
|
|
5282
5920
|
while (def.typeName === "ZodOptional" || def.typeName === "ZodNullable" || def.typeName === "ZodDefault") {
|
|
5283
|
-
var
|
|
5921
|
+
var _ref5;
|
|
5284
5922
|
if (def.typeName === "ZodDefault" && def.defaultValue !== void 0) info.defaultValue = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
5285
|
-
currentSchema = (
|
|
5923
|
+
currentSchema = (_ref5 = def.innerType) !== null && _ref5 !== void 0 ? _ref5 : currentSchema;
|
|
5286
5924
|
if (!(currentSchema === null || currentSchema === void 0 ? void 0 : currentSchema._def)) break;
|
|
5287
5925
|
def = currentSchema._def;
|
|
5288
5926
|
}
|
|
@@ -5452,7 +6090,7 @@ ${prettyEvent}</pre
|
|
|
5452
6090
|
if (typeof value === "function") return value.toString();
|
|
5453
6091
|
try {
|
|
5454
6092
|
return JSON.stringify(value, null, 2);
|
|
5455
|
-
} catch (
|
|
6093
|
+
} catch (_unused8) {
|
|
5456
6094
|
return String(value);
|
|
5457
6095
|
}
|
|
5458
6096
|
}
|
|
@@ -5500,7 +6138,9 @@ ${prettyEvent}</pre
|
|
|
5500
6138
|
<span>Loading latest announcement…</span>
|
|
5501
6139
|
</div>`;
|
|
5502
6140
|
if (!this.announcementHtml) return lit.nothing;
|
|
5503
|
-
return lit.html`<div
|
|
6141
|
+
return lit.html`<div
|
|
6142
|
+
class="mx-4 mt-3 mb-3 rounded-xl border border-slate-200 bg-white px-4 py-3"
|
|
6143
|
+
>
|
|
5504
6144
|
<div
|
|
5505
6145
|
class="mb-2 flex items-center gap-2 text-xs font-semibold text-slate-900"
|
|
5506
6146
|
>
|
|
@@ -5519,7 +6159,9 @@ ${prettyEvent}</pre
|
|
|
5519
6159
|
${this.renderIcon("X")}
|
|
5520
6160
|
</button>
|
|
5521
6161
|
</div>
|
|
5522
|
-
<div
|
|
6162
|
+
<div
|
|
6163
|
+
class="announcement-body ${this.announcementExpanded ? "announcement-body--expanded" : "announcement-body--collapsed"}"
|
|
6164
|
+
>
|
|
5523
6165
|
<div
|
|
5524
6166
|
class="announcement-content"
|
|
5525
6167
|
@click=${this.handleAnnouncementContentClick}
|
|
@@ -5632,7 +6274,7 @@ ${prettyEvent}</pre
|
|
|
5632
6274
|
try {
|
|
5633
6275
|
const url = new URL(href, typeof window !== "undefined" ? window.location.href : "https://copilotkit.ai");
|
|
5634
6276
|
return url.protocol === "http:" || url.protocol === "https:" || url.protocol === "mailto:";
|
|
5635
|
-
} catch (
|
|
6277
|
+
} catch (_unused9) {
|
|
5636
6278
|
return false;
|
|
5637
6279
|
}
|
|
5638
6280
|
}
|
|
@@ -5662,7 +6304,7 @@ ${prettyEvent}</pre
|
|
|
5662
6304
|
}
|
|
5663
6305
|
if (isRootRelative) return `${url.pathname}${url.search}${url.hash}`;
|
|
5664
6306
|
return url.toString();
|
|
5665
|
-
} catch (
|
|
6307
|
+
} catch (_unused10) {
|
|
5666
6308
|
return href;
|
|
5667
6309
|
}
|
|
5668
6310
|
}
|
|
@@ -5681,7 +6323,7 @@ ${prettyEvent}</pre
|
|
|
5681
6323
|
const parsed = JSON.parse(raw);
|
|
5682
6324
|
if (parsed && typeof parsed.timestamp === "string") return parsed.timestamp;
|
|
5683
6325
|
return null;
|
|
5684
|
-
} catch (
|
|
6326
|
+
} catch (_unused11) {}
|
|
5685
6327
|
return null;
|
|
5686
6328
|
}
|
|
5687
6329
|
persistAnnouncementTimestamp(timestamp) {
|
|
@@ -5689,7 +6331,7 @@ ${prettyEvent}</pre
|
|
|
5689
6331
|
try {
|
|
5690
6332
|
const payload = JSON.stringify({ timestamp });
|
|
5691
6333
|
window.localStorage.setItem(ANNOUNCEMENT_STORAGE_KEY, payload);
|
|
5692
|
-
} catch (
|
|
6334
|
+
} catch (_unused12) {}
|
|
5693
6335
|
}
|
|
5694
6336
|
markAnnouncementSeen() {
|
|
5695
6337
|
this.hasUnseenAnnouncement = false;
|
|
@@ -6443,6 +7085,8 @@ ${prettyEvent}</pre
|
|
|
6443
7085
|
defineWebInspector();
|
|
6444
7086
|
|
|
6445
7087
|
//#endregion
|
|
7088
|
+
exports.CpkThreadInspector = CpkThreadInspector;
|
|
7089
|
+
exports.THREAD_INSPECTOR_TAG = THREAD_INSPECTOR_TAG;
|
|
6446
7090
|
exports.WEB_INSPECTOR_TAG = WEB_INSPECTOR_TAG;
|
|
6447
7091
|
exports.WebInspectorElement = WebInspectorElement;
|
|
6448
7092
|
exports.defineWebInspector = defineWebInspector;
|