@agent-native/toolkit 0.198.8 → 0.199.0-nightly-20261001064935
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/app/agentkit/react/components.d.ts.map +1 -1
- package/dist/app/agentkit/react/components.js +142 -56
- package/dist/app/agentkit/react/components.js.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/AgentKitAssistantChat.js +34 -27
- package/dist/app/chat/AgentKitAssistantChat.js.map +1 -1
- package/dist/app/chat/AgentPanel.d.ts +2 -1
- package/dist/app/chat/AgentPanel.d.ts.map +1 -1
- package/dist/app/chat/AgentPanel.js +7 -4
- package/dist/app/chat/AgentPanel.js.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/app/chat/MultiTabAssistantChat.js +21 -4
- package/dist/app/chat/MultiTabAssistantChat.js.map +1 -1
- package/dist/app/chat/chat/run-recovery.d.ts +2 -1
- package/dist/app/chat/chat/run-recovery.d.ts.map +1 -1
- package/dist/app/chat/chat/run-recovery.js +13 -9
- package/dist/app/chat/chat/run-recovery.js.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ar-SA.js +24 -2
- package/dist/app/i18n/catalogs/ar-SA.js.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/de-DE.js +24 -2
- package/dist/app/i18n/catalogs/de-DE.js.map +1 -1
- package/dist/app/i18n/catalogs/en-US.d.ts +24 -2
- package/dist/app/i18n/catalogs/en-US.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/en-US.js +24 -2
- package/dist/app/i18n/catalogs/en-US.js.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/es-ES.js +24 -2
- package/dist/app/i18n/catalogs/es-ES.js.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/fr-FR.js +24 -2
- package/dist/app/i18n/catalogs/fr-FR.js.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/hi-IN.js +24 -2
- package/dist/app/i18n/catalogs/hi-IN.js.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ja-JP.js +24 -2
- package/dist/app/i18n/catalogs/ja-JP.js.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/ko-KR.js +24 -2
- package/dist/app/i18n/catalogs/ko-KR.js.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/pt-BR.js +24 -2
- package/dist/app/i18n/catalogs/pt-BR.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-CN.js +24 -2
- package/dist/app/i18n/catalogs/zh-CN.js.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.d.ts.map +1 -1
- package/dist/app/i18n/catalogs/zh-TW.js +24 -2
- package/dist/app/i18n/catalogs/zh-TW.js.map +1 -1
- package/dist/app/labs/LabsSettings.d.ts.map +1 -1
- package/dist/app/labs/LabsSettings.js +10 -2
- package/dist/app/labs/LabsSettings.js.map +1 -1
- package/dist/app/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/app/org/OrgSwitcher.js +51 -9
- package/dist/app/org/OrgSwitcher.js.map +1 -1
- package/dist/app/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/app/settings/SettingsPanel.js +4 -145
- package/dist/app/settings/SettingsPanel.js.map +1 -1
- package/dist/app/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/app/settings/SettingsTabsPage.js +27 -16
- package/dist/app/settings/SettingsTabsPage.js.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts +24 -2
- package/dist/app/settings/model/ChatGPTSubscriptionRow.d.ts.map +1 -1
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js +97 -26
- package/dist/app/settings/model/ChatGPTSubscriptionRow.js.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.d.ts.map +1 -1
- package/dist/app/settings/model/ModelSettingsPage.js +73 -22
- package/dist/app/settings/model/ModelSettingsPage.js.map +1 -1
- package/dist/app/settings/model/model-page-state.d.ts +12 -2
- package/dist/app/settings/model/model-page-state.d.ts.map +1 -1
- package/dist/app/settings/model/model-page-state.js +14 -1
- package/dist/app/settings/model/model-page-state.js.map +1 -1
- package/dist/app/settings/shell/bridge.d.ts +1 -1
- package/dist/app/settings/shell/bridge.d.ts.map +1 -1
- package/dist/app/settings/shell/bridge.js +1 -4
- package/dist/app/settings/shell/bridge.js.map +1 -1
- package/dist/app/settings/usage/UsagePage.d.ts.map +1 -1
- package/dist/app/settings/usage/UsagePage.js +3 -2
- package/dist/app/settings/usage/UsagePage.js.map +1 -1
- package/dist/composer/TiptapComposer.d.ts +1 -0
- package/dist/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/composer/TiptapComposer.js +10 -4
- package/dist/composer/TiptapComposer.js.map +1 -1
- package/dist/composer/runtime-adapters.d.ts +1 -0
- package/dist/composer/runtime-adapters.d.ts.map +1 -1
- package/dist/composer/runtime-adapters.js.map +1 -1
- package/package.json +4 -4
- package/src/app/agentkit/react/components.tsx +295 -98
- package/src/app/agentkit/react/lifecycle.spec.tsx +758 -17
- package/src/app/chat/AgentKitAssistantChat.spec.tsx +116 -7
- package/src/app/chat/AgentKitAssistantChat.tsx +100 -45
- package/src/app/chat/AgentPanel.header.spec.ts +9 -0
- package/src/app/chat/AgentPanel.tsx +10 -1
- package/src/app/chat/MultiTabAssistantChat.spec.tsx +115 -1
- package/src/app/chat/MultiTabAssistantChat.tsx +24 -4
- package/src/app/chat/chat/run-recovery.spec.tsx +31 -0
- package/src/app/chat/chat/run-recovery.tsx +22 -5
- package/src/app/i18n/catalogs/ar-SA.ts +31 -2
- package/src/app/i18n/catalogs/de-DE.ts +33 -2
- package/src/app/i18n/catalogs/en-US.ts +33 -2
- package/src/app/i18n/catalogs/es-ES.ts +34 -2
- package/src/app/i18n/catalogs/fr-FR.ts +33 -2
- package/src/app/i18n/catalogs/hi-IN.ts +34 -2
- package/src/app/i18n/catalogs/ja-JP.ts +31 -2
- package/src/app/i18n/catalogs/ko-KR.ts +31 -2
- package/src/app/i18n/catalogs/pt-BR.ts +33 -2
- package/src/app/i18n/catalogs/zh-CN.ts +32 -2
- package/src/app/i18n/catalogs/zh-TW.ts +32 -2
- package/src/app/labs/LabsSettings.tsx +13 -3
- package/src/app/org/OrgSwitcher.spec.tsx +75 -0
- package/src/app/org/OrgSwitcher.tsx +104 -34
- package/src/app/settings/SettingsPanel.connections.spec.tsx +25 -5
- package/src/app/settings/SettingsPanel.tsx +3 -286
- package/src/app/settings/SettingsTabsPage.spec.tsx +110 -17
- package/src/app/settings/SettingsTabsPage.tsx +36 -20
- package/src/app/settings/model/ChatGPTSubscriptionRow.tsx +316 -60
- package/src/app/settings/model/ModelSettingsPage.spec.tsx +599 -20
- package/src/app/settings/model/ModelSettingsPage.tsx +114 -25
- package/src/app/settings/model/model-page-state.spec.ts +46 -0
- package/src/app/settings/model/model-page-state.ts +27 -2
- package/src/app/settings/shell/bridge.spec.ts +3 -13
- package/src/app/settings/shell/bridge.ts +2 -5
- package/src/app/settings/shell/pages/app-group-pages.spec.tsx +50 -2
- package/src/app/settings/usage/UsagePage.spec.tsx +25 -1
- package/src/app/settings/usage/UsagePage.tsx +21 -1
- package/src/composer/PromptComposer.context.spec.tsx +22 -3
- package/src/composer/TiptapComposer.tsx +13 -4
- package/src/composer/runtime-adapters.tsx +1 -0
|
@@ -13,7 +13,14 @@ import type {
|
|
|
13
13
|
AgentToolCall,
|
|
14
14
|
AgentTransport,
|
|
15
15
|
} from "@agent-native/agentkit/protocol";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
StrictMode,
|
|
18
|
+
act,
|
|
19
|
+
useEffect,
|
|
20
|
+
useRef,
|
|
21
|
+
type ComponentProps,
|
|
22
|
+
type ReactNode,
|
|
23
|
+
} from "react";
|
|
17
24
|
import { createRoot, type Root } from "react-dom/client";
|
|
18
25
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
19
26
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
@@ -946,7 +953,672 @@ describe("AgentChat lifecycle", () => {
|
|
|
946
953
|
expect(tree.container.querySelector(".agentkit-reasoning")).toBeNull();
|
|
947
954
|
});
|
|
948
955
|
|
|
949
|
-
it("
|
|
956
|
+
it("shows one stable Thinking row before work events arrive", async () => {
|
|
957
|
+
const threadId = "thread-run-before-work";
|
|
958
|
+
const runId = "run-before-work";
|
|
959
|
+
const thread = {
|
|
960
|
+
...createAgentThreadState(threadId),
|
|
961
|
+
runs: {
|
|
962
|
+
[runId]: {
|
|
963
|
+
id: runId,
|
|
964
|
+
status: "running" as const,
|
|
965
|
+
lastSequence: 0,
|
|
966
|
+
startedAt: "2026-09-30T00:00:00.000Z",
|
|
967
|
+
},
|
|
968
|
+
},
|
|
969
|
+
activeRunIds: [runId],
|
|
970
|
+
};
|
|
971
|
+
const observable = observableController({
|
|
972
|
+
connection: "connected",
|
|
973
|
+
capabilities: {},
|
|
974
|
+
capabilitiesStatus: "ready",
|
|
975
|
+
threads: { [threadId]: thread },
|
|
976
|
+
revision: 0,
|
|
977
|
+
});
|
|
978
|
+
const tree = mount();
|
|
979
|
+
|
|
980
|
+
await tree.render(
|
|
981
|
+
<AgentKitProvider controller={observable.controller} threadId={threadId}>
|
|
982
|
+
<AgentKitChat composer={false} />
|
|
983
|
+
</AgentKitProvider>,
|
|
984
|
+
);
|
|
985
|
+
|
|
986
|
+
const work = tree.container.querySelector<HTMLDetailsElement>(
|
|
987
|
+
".agentkit-activities",
|
|
988
|
+
);
|
|
989
|
+
expect(
|
|
990
|
+
work?.querySelector("[data-agentkit-current-activity]")?.textContent,
|
|
991
|
+
).toBe("Thinking");
|
|
992
|
+
expect(
|
|
993
|
+
tree.container.querySelectorAll(".agentkit-activities"),
|
|
994
|
+
).toHaveLength(1);
|
|
995
|
+
expect(tree.container.textContent).not.toContain("Working for");
|
|
996
|
+
|
|
997
|
+
const assistantMessage = {
|
|
998
|
+
id: "assistant-empty-stream",
|
|
999
|
+
role: "assistant" as const,
|
|
1000
|
+
status: "streaming" as const,
|
|
1001
|
+
parts: [],
|
|
1002
|
+
};
|
|
1003
|
+
const messageCreatedEvent = {
|
|
1004
|
+
id: "event-message-created",
|
|
1005
|
+
threadId,
|
|
1006
|
+
runId,
|
|
1007
|
+
sequence: 1,
|
|
1008
|
+
occurredAt: "2026-09-30T00:00:01.000Z",
|
|
1009
|
+
type: "message.created" as const,
|
|
1010
|
+
message: assistantMessage,
|
|
1011
|
+
};
|
|
1012
|
+
observable.update({
|
|
1013
|
+
connection: "connected",
|
|
1014
|
+
capabilities: {},
|
|
1015
|
+
capabilitiesStatus: "ready",
|
|
1016
|
+
threads: {
|
|
1017
|
+
[threadId]: {
|
|
1018
|
+
...thread,
|
|
1019
|
+
messages: [assistantMessage],
|
|
1020
|
+
events: [messageCreatedEvent],
|
|
1021
|
+
runs: {
|
|
1022
|
+
[runId]: { ...thread.runs[runId], lastSequence: 1 },
|
|
1023
|
+
},
|
|
1024
|
+
},
|
|
1025
|
+
},
|
|
1026
|
+
revision: 1,
|
|
1027
|
+
});
|
|
1028
|
+
await flush();
|
|
1029
|
+
|
|
1030
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBe(work);
|
|
1031
|
+
expect(
|
|
1032
|
+
work?.querySelector("[data-agentkit-current-activity]")?.textContent,
|
|
1033
|
+
).toBe("Thinking");
|
|
1034
|
+
|
|
1035
|
+
observable.update({
|
|
1036
|
+
connection: "connected",
|
|
1037
|
+
capabilities: {},
|
|
1038
|
+
capabilitiesStatus: "ready",
|
|
1039
|
+
threads: {
|
|
1040
|
+
[threadId]: {
|
|
1041
|
+
...thread,
|
|
1042
|
+
messages: [assistantMessage],
|
|
1043
|
+
events: [
|
|
1044
|
+
messageCreatedEvent,
|
|
1045
|
+
{
|
|
1046
|
+
id: "event-read",
|
|
1047
|
+
threadId,
|
|
1048
|
+
runId,
|
|
1049
|
+
sequence: 2,
|
|
1050
|
+
occurredAt: "2026-09-30T00:00:02.000Z",
|
|
1051
|
+
type: "activity.started",
|
|
1052
|
+
activity: {
|
|
1053
|
+
id: "read-components",
|
|
1054
|
+
kind: "read",
|
|
1055
|
+
label: "Reading components.tsx",
|
|
1056
|
+
status: "running",
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
],
|
|
1060
|
+
runs: {
|
|
1061
|
+
[runId]: { ...thread.runs[runId], lastSequence: 2 },
|
|
1062
|
+
},
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
revision: 2,
|
|
1066
|
+
});
|
|
1067
|
+
await flush();
|
|
1068
|
+
|
|
1069
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBe(work);
|
|
1070
|
+
expect(
|
|
1071
|
+
work?.querySelector("[data-agentkit-current-activity]")?.textContent,
|
|
1072
|
+
).toBe("Reading components.tsx");
|
|
1073
|
+
expect(
|
|
1074
|
+
tree.container.querySelectorAll(".agentkit-activities"),
|
|
1075
|
+
).toHaveLength(1);
|
|
1076
|
+
|
|
1077
|
+
await tree.unmount();
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
it("does not show Thinking after visible output before its run finishes", async () => {
|
|
1081
|
+
const threadId = "thread-completed-output-before-run";
|
|
1082
|
+
const runId = "run-completed-output-before-run";
|
|
1083
|
+
const response = {
|
|
1084
|
+
id: "assistant-response",
|
|
1085
|
+
role: "assistant" as const,
|
|
1086
|
+
status: "complete" as const,
|
|
1087
|
+
parts: [{ type: "text" as const, text: "Here is the result." }],
|
|
1088
|
+
};
|
|
1089
|
+
const responseEvent = {
|
|
1090
|
+
id: "event-response-completed",
|
|
1091
|
+
threadId,
|
|
1092
|
+
runId,
|
|
1093
|
+
sequence: 1,
|
|
1094
|
+
occurredAt: "2026-09-30T00:00:01.000Z",
|
|
1095
|
+
type: "message.completed" as const,
|
|
1096
|
+
message: response,
|
|
1097
|
+
};
|
|
1098
|
+
const thread = {
|
|
1099
|
+
...createAgentThreadState(threadId),
|
|
1100
|
+
messages: [response],
|
|
1101
|
+
events: [responseEvent],
|
|
1102
|
+
runs: {
|
|
1103
|
+
[runId]: {
|
|
1104
|
+
id: runId,
|
|
1105
|
+
status: "running" as const,
|
|
1106
|
+
lastSequence: 1,
|
|
1107
|
+
startedAt: "2026-09-30T00:00:00.000Z",
|
|
1108
|
+
},
|
|
1109
|
+
},
|
|
1110
|
+
activeRunIds: [runId],
|
|
1111
|
+
};
|
|
1112
|
+
const observable = observableController({
|
|
1113
|
+
connection: "connected",
|
|
1114
|
+
capabilities: {},
|
|
1115
|
+
capabilitiesStatus: "ready",
|
|
1116
|
+
threads: { [threadId]: thread },
|
|
1117
|
+
revision: 0,
|
|
1118
|
+
});
|
|
1119
|
+
const tree = mount();
|
|
1120
|
+
|
|
1121
|
+
await tree.render(
|
|
1122
|
+
<AgentKitProvider controller={observable.controller} threadId={threadId}>
|
|
1123
|
+
<AgentKitChat composer={false} />
|
|
1124
|
+
</AgentKitProvider>,
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
expect(tree.container.textContent).toContain("Here is the result.");
|
|
1128
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1129
|
+
|
|
1130
|
+
const statuslessResponse = {
|
|
1131
|
+
id: response.id,
|
|
1132
|
+
role: "assistant" as const,
|
|
1133
|
+
parts: response.parts,
|
|
1134
|
+
};
|
|
1135
|
+
observable.update({
|
|
1136
|
+
connection: "connected",
|
|
1137
|
+
capabilities: {},
|
|
1138
|
+
capabilitiesStatus: "ready",
|
|
1139
|
+
threads: {
|
|
1140
|
+
[threadId]: {
|
|
1141
|
+
...thread,
|
|
1142
|
+
messages: [statuslessResponse],
|
|
1143
|
+
events: [{ ...responseEvent, message: statuslessResponse }],
|
|
1144
|
+
},
|
|
1145
|
+
},
|
|
1146
|
+
revision: 1,
|
|
1147
|
+
});
|
|
1148
|
+
await flush();
|
|
1149
|
+
|
|
1150
|
+
expect(tree.container.textContent).toContain("Here is the result.");
|
|
1151
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1152
|
+
|
|
1153
|
+
const fileResponse = {
|
|
1154
|
+
id: response.id,
|
|
1155
|
+
role: "assistant" as const,
|
|
1156
|
+
parts: [{ type: "file" as const, name: "result.csv" }],
|
|
1157
|
+
};
|
|
1158
|
+
observable.update({
|
|
1159
|
+
connection: "connected",
|
|
1160
|
+
capabilities: {},
|
|
1161
|
+
capabilitiesStatus: "ready",
|
|
1162
|
+
threads: {
|
|
1163
|
+
[threadId]: {
|
|
1164
|
+
...thread,
|
|
1165
|
+
messages: [fileResponse],
|
|
1166
|
+
events: [{ ...responseEvent, message: fileResponse }],
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
revision: 2,
|
|
1170
|
+
});
|
|
1171
|
+
await flush();
|
|
1172
|
+
|
|
1173
|
+
expect(tree.container.textContent).toContain("result.csv");
|
|
1174
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1175
|
+
|
|
1176
|
+
const dataResponse = {
|
|
1177
|
+
id: response.id,
|
|
1178
|
+
role: "assistant" as const,
|
|
1179
|
+
parts: [{ type: "data" as const, data: { value: "hidden" } }],
|
|
1180
|
+
};
|
|
1181
|
+
observable.update({
|
|
1182
|
+
connection: "connected",
|
|
1183
|
+
capabilities: {},
|
|
1184
|
+
capabilitiesStatus: "ready",
|
|
1185
|
+
threads: {
|
|
1186
|
+
[threadId]: {
|
|
1187
|
+
...thread,
|
|
1188
|
+
messages: [dataResponse],
|
|
1189
|
+
events: [{ ...responseEvent, message: dataResponse }],
|
|
1190
|
+
},
|
|
1191
|
+
},
|
|
1192
|
+
revision: 3,
|
|
1193
|
+
});
|
|
1194
|
+
await flush();
|
|
1195
|
+
|
|
1196
|
+
expect(
|
|
1197
|
+
tree.container.querySelector("[data-agentkit-current-activity]")
|
|
1198
|
+
?.textContent,
|
|
1199
|
+
).toBe("Thinking");
|
|
1200
|
+
|
|
1201
|
+
await tree.render(
|
|
1202
|
+
<AgentKitProvider
|
|
1203
|
+
controller={observable.controller}
|
|
1204
|
+
threadId={threadId}
|
|
1205
|
+
slots={{ data: () => <span>Visible data</span> }}
|
|
1206
|
+
>
|
|
1207
|
+
<AgentKitChat composer={false} />
|
|
1208
|
+
</AgentKitProvider>,
|
|
1209
|
+
);
|
|
1210
|
+
|
|
1211
|
+
expect(tree.container.textContent).toContain("Visible data");
|
|
1212
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1213
|
+
|
|
1214
|
+
await tree.render(
|
|
1215
|
+
<AgentKitProvider
|
|
1216
|
+
controller={observable.controller}
|
|
1217
|
+
threadId={threadId}
|
|
1218
|
+
registry={{
|
|
1219
|
+
messageParts: {
|
|
1220
|
+
data: () => <span>Registered data</span>,
|
|
1221
|
+
},
|
|
1222
|
+
}}
|
|
1223
|
+
>
|
|
1224
|
+
<AgentKitChat composer={false} />
|
|
1225
|
+
</AgentKitProvider>,
|
|
1226
|
+
);
|
|
1227
|
+
|
|
1228
|
+
expect(tree.container.textContent).toContain("Registered data");
|
|
1229
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1230
|
+
|
|
1231
|
+
const emptyWidgetResponse = {
|
|
1232
|
+
...response,
|
|
1233
|
+
parts: [
|
|
1234
|
+
{
|
|
1235
|
+
type: "widget" as const,
|
|
1236
|
+
widget: { id: "empty-widget", kind: "empty", data: "" },
|
|
1237
|
+
},
|
|
1238
|
+
],
|
|
1239
|
+
};
|
|
1240
|
+
observable.update({
|
|
1241
|
+
connection: "connected",
|
|
1242
|
+
capabilities: {},
|
|
1243
|
+
capabilitiesStatus: "ready",
|
|
1244
|
+
threads: {
|
|
1245
|
+
[threadId]: {
|
|
1246
|
+
...thread,
|
|
1247
|
+
messages: [emptyWidgetResponse],
|
|
1248
|
+
events: [{ ...responseEvent, message: emptyWidgetResponse }],
|
|
1249
|
+
},
|
|
1250
|
+
},
|
|
1251
|
+
revision: 4,
|
|
1252
|
+
});
|
|
1253
|
+
await flush();
|
|
1254
|
+
|
|
1255
|
+
expect(tree.container.querySelector(".agentkit-widget-shell")).toBeNull();
|
|
1256
|
+
expect(
|
|
1257
|
+
tree.container.querySelector("[data-agentkit-current-activity]")
|
|
1258
|
+
?.textContent,
|
|
1259
|
+
).toBe("Thinking");
|
|
1260
|
+
|
|
1261
|
+
await tree.render(
|
|
1262
|
+
<AgentKitProvider
|
|
1263
|
+
controller={observable.controller}
|
|
1264
|
+
threadId={threadId}
|
|
1265
|
+
registry={{
|
|
1266
|
+
widgets: {
|
|
1267
|
+
empty: () => <span data-visible-empty-widget>Rendered widget</span>,
|
|
1268
|
+
},
|
|
1269
|
+
}}
|
|
1270
|
+
>
|
|
1271
|
+
<AgentKitChat composer={false} />
|
|
1272
|
+
</AgentKitProvider>,
|
|
1273
|
+
);
|
|
1274
|
+
|
|
1275
|
+
expect(
|
|
1276
|
+
tree.container.querySelector("[data-visible-empty-widget]")?.textContent,
|
|
1277
|
+
).toBe("Rendered widget");
|
|
1278
|
+
expect(tree.container.querySelector(".agentkit-activities")).toBeNull();
|
|
1279
|
+
|
|
1280
|
+
const attachedWidgetMessage = {
|
|
1281
|
+
...response,
|
|
1282
|
+
status: "streaming" as const,
|
|
1283
|
+
parts: [],
|
|
1284
|
+
};
|
|
1285
|
+
const attachedWidget = {
|
|
1286
|
+
id: "attached-empty-widget",
|
|
1287
|
+
kind: "empty",
|
|
1288
|
+
data: "",
|
|
1289
|
+
};
|
|
1290
|
+
observable.update({
|
|
1291
|
+
connection: "connected",
|
|
1292
|
+
capabilities: {},
|
|
1293
|
+
capabilitiesStatus: "ready",
|
|
1294
|
+
threads: {
|
|
1295
|
+
[threadId]: {
|
|
1296
|
+
...thread,
|
|
1297
|
+
messages: [attachedWidgetMessage],
|
|
1298
|
+
events: [
|
|
1299
|
+
{
|
|
1300
|
+
...responseEvent,
|
|
1301
|
+
type: "message.created" as const,
|
|
1302
|
+
message: attachedWidgetMessage,
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
id: "event-attached-widget-work",
|
|
1306
|
+
threadId,
|
|
1307
|
+
runId,
|
|
1308
|
+
sequence: 2,
|
|
1309
|
+
occurredAt: "2026-09-30T00:00:02.000Z",
|
|
1310
|
+
type: "activity.completed" as const,
|
|
1311
|
+
activity: {
|
|
1312
|
+
id: "attached-widget-work",
|
|
1313
|
+
kind: "read",
|
|
1314
|
+
label: "Reading components.tsx",
|
|
1315
|
+
status: "completed" as const,
|
|
1316
|
+
},
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
id: "event-attached-widget",
|
|
1320
|
+
threadId,
|
|
1321
|
+
runId,
|
|
1322
|
+
sequence: 3,
|
|
1323
|
+
occurredAt: "2026-09-30T00:00:03.000Z",
|
|
1324
|
+
type: "widget.updated" as const,
|
|
1325
|
+
messageId: attachedWidgetMessage.id,
|
|
1326
|
+
widget: attachedWidget,
|
|
1327
|
+
},
|
|
1328
|
+
],
|
|
1329
|
+
activities: {
|
|
1330
|
+
"attached-widget-work": {
|
|
1331
|
+
id: "attached-widget-work",
|
|
1332
|
+
kind: "read",
|
|
1333
|
+
label: "Reading components.tsx",
|
|
1334
|
+
status: "completed",
|
|
1335
|
+
},
|
|
1336
|
+
},
|
|
1337
|
+
widgets: { [attachedWidget.id]: attachedWidget },
|
|
1338
|
+
widgetMessageIds: {
|
|
1339
|
+
[attachedWidget.id]: attachedWidgetMessage.id,
|
|
1340
|
+
},
|
|
1341
|
+
runs: {
|
|
1342
|
+
[runId]: { ...thread.runs[runId], lastSequence: 3 },
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
},
|
|
1346
|
+
revision: 5,
|
|
1347
|
+
});
|
|
1348
|
+
await flush();
|
|
1349
|
+
|
|
1350
|
+
expect(
|
|
1351
|
+
tree.container.querySelector("[data-visible-empty-widget]")?.textContent,
|
|
1352
|
+
).toBe("Rendered widget");
|
|
1353
|
+
expect(tree.container.textContent).toContain("Reading components.tsx");
|
|
1354
|
+
expect(
|
|
1355
|
+
tree.container.querySelector("[data-agentkit-current-activity]"),
|
|
1356
|
+
).toBeNull();
|
|
1357
|
+
|
|
1358
|
+
await tree.unmount();
|
|
1359
|
+
});
|
|
1360
|
+
|
|
1361
|
+
it("recomputes output boundaries when message renderers change", async () => {
|
|
1362
|
+
const threadId = "thread-renderer-output-boundary";
|
|
1363
|
+
const runId = "run-renderer-output-boundary";
|
|
1364
|
+
const response = {
|
|
1365
|
+
id: "assistant-data-response",
|
|
1366
|
+
role: "assistant" as const,
|
|
1367
|
+
status: "complete" as const,
|
|
1368
|
+
parts: [
|
|
1369
|
+
{ type: "data" as const, data: { value: "visible" } },
|
|
1370
|
+
{ type: "text" as const, text: " " },
|
|
1371
|
+
],
|
|
1372
|
+
};
|
|
1373
|
+
const activityEvent = {
|
|
1374
|
+
id: "event-renderer-boundary-activity",
|
|
1375
|
+
threadId,
|
|
1376
|
+
runId,
|
|
1377
|
+
sequence: 1,
|
|
1378
|
+
occurredAt: "2026-09-30T00:00:00.000Z",
|
|
1379
|
+
type: "activity.started" as const,
|
|
1380
|
+
activity: {
|
|
1381
|
+
id: "activity-renderer-boundary",
|
|
1382
|
+
kind: "model",
|
|
1383
|
+
label: "Contacting model",
|
|
1384
|
+
status: "running" as const,
|
|
1385
|
+
},
|
|
1386
|
+
};
|
|
1387
|
+
const responseEvent = {
|
|
1388
|
+
id: "event-renderer-boundary-response",
|
|
1389
|
+
threadId,
|
|
1390
|
+
runId,
|
|
1391
|
+
sequence: 2,
|
|
1392
|
+
occurredAt: "2026-09-30T00:00:01.000Z",
|
|
1393
|
+
type: "message.completed" as const,
|
|
1394
|
+
message: response,
|
|
1395
|
+
};
|
|
1396
|
+
const thread = {
|
|
1397
|
+
...createAgentThreadState(threadId),
|
|
1398
|
+
messages: [response],
|
|
1399
|
+
events: [activityEvent, responseEvent],
|
|
1400
|
+
runs: {
|
|
1401
|
+
[runId]: {
|
|
1402
|
+
id: runId,
|
|
1403
|
+
status: "running" as const,
|
|
1404
|
+
lastSequence: 2,
|
|
1405
|
+
startedAt: "2026-09-30T00:00:00.000Z",
|
|
1406
|
+
},
|
|
1407
|
+
},
|
|
1408
|
+
activeRunIds: [runId],
|
|
1409
|
+
};
|
|
1410
|
+
const observable = observableController({
|
|
1411
|
+
connection: "connected",
|
|
1412
|
+
capabilities: {},
|
|
1413
|
+
capabilitiesStatus: "ready",
|
|
1414
|
+
threads: { [threadId]: thread },
|
|
1415
|
+
revision: 0,
|
|
1416
|
+
});
|
|
1417
|
+
const tree = mount();
|
|
1418
|
+
const render = (
|
|
1419
|
+
props: Pick<
|
|
1420
|
+
ComponentProps<typeof AgentKitProvider>,
|
|
1421
|
+
"slots" | "registry"
|
|
1422
|
+
> = {},
|
|
1423
|
+
) =>
|
|
1424
|
+
tree.render(
|
|
1425
|
+
<AgentKitProvider
|
|
1426
|
+
controller={observable.controller}
|
|
1427
|
+
threadId={threadId}
|
|
1428
|
+
{...props}
|
|
1429
|
+
>
|
|
1430
|
+
<AgentKitChat composer={false} />
|
|
1431
|
+
</AgentKitProvider>,
|
|
1432
|
+
);
|
|
1433
|
+
const expectActivityBeforeOutput = (selector = "[data-rendered-data]") => {
|
|
1434
|
+
const work = tree.container.querySelector(".agentkit-activities");
|
|
1435
|
+
const output = tree.container.querySelector(selector);
|
|
1436
|
+
expect(work).not.toBeNull();
|
|
1437
|
+
expect(output).not.toBeNull();
|
|
1438
|
+
expect(
|
|
1439
|
+
work!.compareDocumentPosition(output!) &
|
|
1440
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
1441
|
+
).toBeTruthy();
|
|
1442
|
+
expect(
|
|
1443
|
+
tree.container.querySelector("[data-agentkit-current-activity]"),
|
|
1444
|
+
).toBeNull();
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
await render();
|
|
1448
|
+
expect(
|
|
1449
|
+
tree.container.querySelector("[data-agentkit-current-activity]")
|
|
1450
|
+
?.textContent,
|
|
1451
|
+
).toBe("Thinking");
|
|
1452
|
+
|
|
1453
|
+
await render({
|
|
1454
|
+
slots: { data: () => <span data-rendered-data>Visible data</span> },
|
|
1455
|
+
});
|
|
1456
|
+
expectActivityBeforeOutput();
|
|
1457
|
+
|
|
1458
|
+
await render();
|
|
1459
|
+
await render({
|
|
1460
|
+
registry: {
|
|
1461
|
+
messageParts: {
|
|
1462
|
+
data: () => <span data-rendered-data>Registered data</span>,
|
|
1463
|
+
},
|
|
1464
|
+
},
|
|
1465
|
+
});
|
|
1466
|
+
expect(
|
|
1467
|
+
tree.container.querySelector("[data-rendered-data]")?.textContent,
|
|
1468
|
+
).toBe("Registered data");
|
|
1469
|
+
expectActivityBeforeOutput();
|
|
1470
|
+
|
|
1471
|
+
await render({
|
|
1472
|
+
slots: {
|
|
1473
|
+
message: () => <span data-rendered-data>Message renderer output</span>,
|
|
1474
|
+
},
|
|
1475
|
+
});
|
|
1476
|
+
expect(
|
|
1477
|
+
tree.container.querySelector("[data-rendered-data]")?.textContent,
|
|
1478
|
+
).toBe("Message renderer output");
|
|
1479
|
+
expectActivityBeforeOutput();
|
|
1480
|
+
|
|
1481
|
+
await render({
|
|
1482
|
+
slots: {
|
|
1483
|
+
text: () => <span data-rendered-text>Rendered blank text</span>,
|
|
1484
|
+
},
|
|
1485
|
+
});
|
|
1486
|
+
expect(
|
|
1487
|
+
tree.container.querySelector("[data-rendered-text]")?.textContent,
|
|
1488
|
+
).toBe("Rendered blank text");
|
|
1489
|
+
const work = tree.container.querySelector(".agentkit-activities")!;
|
|
1490
|
+
const textOutput = tree.container.querySelector("[data-rendered-text]")!;
|
|
1491
|
+
expect(
|
|
1492
|
+
work.compareDocumentPosition(textOutput) &
|
|
1493
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
1494
|
+
).toBeTruthy();
|
|
1495
|
+
expect(
|
|
1496
|
+
tree.container.querySelector("[data-agentkit-current-activity]"),
|
|
1497
|
+
).toBeNull();
|
|
1498
|
+
|
|
1499
|
+
await render({
|
|
1500
|
+
registry: {
|
|
1501
|
+
messageParts: {
|
|
1502
|
+
text: () => <span data-rendered-text>Registered blank text</span>,
|
|
1503
|
+
},
|
|
1504
|
+
},
|
|
1505
|
+
});
|
|
1506
|
+
expect(
|
|
1507
|
+
tree.container.querySelector("[data-rendered-text]")?.textContent,
|
|
1508
|
+
).toBe("Registered blank text");
|
|
1509
|
+
expectActivityBeforeOutput("[data-rendered-text]");
|
|
1510
|
+
|
|
1511
|
+
await render();
|
|
1512
|
+
expect(
|
|
1513
|
+
tree.container.querySelector("[data-agentkit-current-activity]")
|
|
1514
|
+
?.textContent,
|
|
1515
|
+
).toBe("Thinking");
|
|
1516
|
+
await tree.unmount();
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
it("preserves whitespace text for custom message and text renderers", async () => {
|
|
1520
|
+
const threadId = "thread-whitespace-text-delta";
|
|
1521
|
+
const runId = "run-whitespace-text-delta";
|
|
1522
|
+
const response = {
|
|
1523
|
+
id: "assistant-whitespace-delta",
|
|
1524
|
+
role: "assistant" as const,
|
|
1525
|
+
status: "streaming" as const,
|
|
1526
|
+
parts: [{ type: "text" as const, text: " " }],
|
|
1527
|
+
};
|
|
1528
|
+
const events: AgentEvent[] = [
|
|
1529
|
+
{
|
|
1530
|
+
id: "event-before-whitespace-delta",
|
|
1531
|
+
threadId,
|
|
1532
|
+
runId,
|
|
1533
|
+
sequence: 1,
|
|
1534
|
+
occurredAt: "2026-09-30T00:00:00.000Z",
|
|
1535
|
+
type: "activity.started",
|
|
1536
|
+
activity: {
|
|
1537
|
+
id: "activity-before-whitespace-delta",
|
|
1538
|
+
kind: "model",
|
|
1539
|
+
label: "Contacting model",
|
|
1540
|
+
status: "running",
|
|
1541
|
+
},
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
id: "event-whitespace-delta",
|
|
1545
|
+
threadId,
|
|
1546
|
+
runId,
|
|
1547
|
+
sequence: 2,
|
|
1548
|
+
occurredAt: "2026-09-30T00:00:01.000Z",
|
|
1549
|
+
type: "message.delta",
|
|
1550
|
+
messageId: response.id,
|
|
1551
|
+
text: " ",
|
|
1552
|
+
},
|
|
1553
|
+
];
|
|
1554
|
+
const thread = {
|
|
1555
|
+
...createAgentThreadState(threadId),
|
|
1556
|
+
messages: [response],
|
|
1557
|
+
events,
|
|
1558
|
+
runs: {
|
|
1559
|
+
[runId]: {
|
|
1560
|
+
id: runId,
|
|
1561
|
+
status: "running" as const,
|
|
1562
|
+
lastSequence: 2,
|
|
1563
|
+
startedAt: "2026-09-30T00:00:00.000Z",
|
|
1564
|
+
},
|
|
1565
|
+
},
|
|
1566
|
+
activeRunIds: [runId],
|
|
1567
|
+
};
|
|
1568
|
+
const observable = observableController({
|
|
1569
|
+
connection: "connected",
|
|
1570
|
+
capabilities: {},
|
|
1571
|
+
capabilitiesStatus: "ready",
|
|
1572
|
+
threads: { [threadId]: thread },
|
|
1573
|
+
revision: 0,
|
|
1574
|
+
});
|
|
1575
|
+
const tree = mount();
|
|
1576
|
+
await tree.render(
|
|
1577
|
+
<AgentKitProvider
|
|
1578
|
+
controller={observable.controller}
|
|
1579
|
+
threadId={threadId}
|
|
1580
|
+
slots={{
|
|
1581
|
+
message: ({ value }) => (
|
|
1582
|
+
<span data-whitespace-message>
|
|
1583
|
+
{value.parts
|
|
1584
|
+
.filter((part) => part.type === "text")
|
|
1585
|
+
.map((part) => (part.type === "text" ? part.text : ""))
|
|
1586
|
+
.join("")}
|
|
1587
|
+
</span>
|
|
1588
|
+
),
|
|
1589
|
+
}}
|
|
1590
|
+
>
|
|
1591
|
+
<AgentKitChat composer={false} />
|
|
1592
|
+
</AgentKitProvider>,
|
|
1593
|
+
);
|
|
1594
|
+
|
|
1595
|
+
const work = tree.container.querySelector(".agentkit-activities")!;
|
|
1596
|
+
const messageOutput = tree.container.querySelector(
|
|
1597
|
+
"[data-whitespace-message]",
|
|
1598
|
+
)!;
|
|
1599
|
+
expect(messageOutput.textContent).toBe(" ");
|
|
1600
|
+
expect(
|
|
1601
|
+
work.compareDocumentPosition(messageOutput) &
|
|
1602
|
+
Node.DOCUMENT_POSITION_FOLLOWING,
|
|
1603
|
+
).toBeTruthy();
|
|
1604
|
+
|
|
1605
|
+
await tree.render(
|
|
1606
|
+
<AgentKitProvider
|
|
1607
|
+
controller={observable.controller}
|
|
1608
|
+
threadId={threadId}
|
|
1609
|
+
slots={{
|
|
1610
|
+
text: () => <span data-whitespace-delta>Custom text output</span>,
|
|
1611
|
+
}}
|
|
1612
|
+
>
|
|
1613
|
+
<AgentKitChat composer={false} />
|
|
1614
|
+
</AgentKitProvider>,
|
|
1615
|
+
);
|
|
1616
|
+
const textOutput = tree.container.querySelector("[data-whitespace-delta]")!;
|
|
1617
|
+
expect(textOutput.textContent).toBe("Custom text output");
|
|
1618
|
+
await tree.unmount();
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
it("preserves visible reasoning without a Thinking history row", async () => {
|
|
950
1622
|
const threadId = "thread-reasoning-work";
|
|
951
1623
|
const runId = "run-reasoning-work";
|
|
952
1624
|
const base = (sequence: number, seconds: number = sequence) => ({
|
|
@@ -980,6 +1652,36 @@ describe("AgentChat lifecycle", () => {
|
|
|
980
1652
|
{
|
|
981
1653
|
...base(4),
|
|
982
1654
|
type: "activity.started",
|
|
1655
|
+
activity: {
|
|
1656
|
+
id: "protocol-reasoning",
|
|
1657
|
+
kind: "reasoning",
|
|
1658
|
+
label: "Planning response",
|
|
1659
|
+
status: "running",
|
|
1660
|
+
},
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
...base(5),
|
|
1664
|
+
type: "activity.updated",
|
|
1665
|
+
activity: {
|
|
1666
|
+
id: "protocol-reasoning",
|
|
1667
|
+
kind: "reasoning",
|
|
1668
|
+
label: "Checking assumptions",
|
|
1669
|
+
status: "running",
|
|
1670
|
+
},
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
...base(6),
|
|
1674
|
+
type: "activity.completed",
|
|
1675
|
+
activity: {
|
|
1676
|
+
id: "protocol-reasoning",
|
|
1677
|
+
kind: "reasoning",
|
|
1678
|
+
label: "Checking assumptions",
|
|
1679
|
+
status: "completed",
|
|
1680
|
+
},
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
...base(7),
|
|
1684
|
+
type: "activity.started",
|
|
983
1685
|
activity: {
|
|
984
1686
|
id: "search",
|
|
985
1687
|
kind: "search",
|
|
@@ -1005,6 +1707,13 @@ describe("AgentChat lifecycle", () => {
|
|
|
1005
1707
|
<AgentKitProvider
|
|
1006
1708
|
controller={observable.controller}
|
|
1007
1709
|
threadId={threadId}
|
|
1710
|
+
registry={{
|
|
1711
|
+
activities: {
|
|
1712
|
+
reasoning: ({ value }) => (
|
|
1713
|
+
<span data-protocol-reasoning>{value.label}</span>
|
|
1714
|
+
),
|
|
1715
|
+
},
|
|
1716
|
+
}}
|
|
1008
1717
|
slots={{
|
|
1009
1718
|
reasoning: ({ value, active, resetKey }) => (
|
|
1010
1719
|
<span data-thought={resetKey} data-active={active}>
|
|
@@ -1025,8 +1734,23 @@ describe("AgentChat lifecycle", () => {
|
|
|
1025
1734
|
).toHaveLength(1);
|
|
1026
1735
|
expect(tree.container.querySelectorAll("article")).toHaveLength(0);
|
|
1027
1736
|
expect(
|
|
1028
|
-
work.querySelectorAll(
|
|
1737
|
+
work.querySelectorAll(
|
|
1738
|
+
'[data-activity-bucket="reasoning-content"] [data-thought]',
|
|
1739
|
+
),
|
|
1029
1740
|
).toHaveLength(2);
|
|
1741
|
+
expect(
|
|
1742
|
+
work.querySelector(
|
|
1743
|
+
'[data-activity-bucket="reasoning-content"] [data-thought]',
|
|
1744
|
+
)?.textContent,
|
|
1745
|
+
).toContain("First thought");
|
|
1746
|
+
expect(
|
|
1747
|
+
work.querySelector(
|
|
1748
|
+
'[data-activity-bucket="reasoning-content"] [data-thought][data-thought$="assistant-2:0"]',
|
|
1749
|
+
)?.textContent,
|
|
1750
|
+
).toContain("Second thought");
|
|
1751
|
+
expect(work.querySelector("[data-protocol-reasoning]")?.textContent).toBe(
|
|
1752
|
+
"Checking assumptions",
|
|
1753
|
+
);
|
|
1030
1754
|
expect(tree.container.textContent).not.toContain("Hidden thought");
|
|
1031
1755
|
expect(
|
|
1032
1756
|
work.querySelector("[data-agentkit-current-activity]")?.textContent,
|
|
@@ -1036,14 +1760,10 @@ describe("AgentChat lifecycle", () => {
|
|
|
1036
1760
|
".agentkit-activities-summary > .agentkit-summary-chevron",
|
|
1037
1761
|
),
|
|
1038
1762
|
).not.toBeNull();
|
|
1039
|
-
expect(
|
|
1040
|
-
work
|
|
1041
|
-
.querySelector('[data-thought="thread-reasoning-work:assistant-2:0"]')
|
|
1042
|
-
?.getAttribute("data-active"),
|
|
1043
|
-
).toBe("false");
|
|
1763
|
+
expect(work.querySelector('[data-activity-bucket="thinking"]')).toBeNull();
|
|
1044
1764
|
|
|
1045
1765
|
thread = reduceAgentEvent(thread, {
|
|
1046
|
-
...base(
|
|
1766
|
+
...base(8, 18),
|
|
1047
1767
|
type: "message.completed",
|
|
1048
1768
|
message: {
|
|
1049
1769
|
id: "assistant-2",
|
|
@@ -1056,7 +1776,7 @@ describe("AgentChat lifecycle", () => {
|
|
|
1056
1776
|
},
|
|
1057
1777
|
});
|
|
1058
1778
|
thread = reduceAgentEvent(thread, {
|
|
1059
|
-
...base(
|
|
1779
|
+
...base(9, 19),
|
|
1060
1780
|
type: "run.completed",
|
|
1061
1781
|
});
|
|
1062
1782
|
await act(async () => observable.update(snapshot(1)));
|
|
@@ -1074,9 +1794,21 @@ describe("AgentChat lifecycle", () => {
|
|
|
1074
1794
|
expect(
|
|
1075
1795
|
work.compareDocumentPosition(answer) & Node.DOCUMENT_POSITION_FOLLOWING,
|
|
1076
1796
|
).not.toBe(0);
|
|
1797
|
+
expect(work.querySelector('[data-activity-bucket="thinking"]')).toBeNull();
|
|
1798
|
+
expect(
|
|
1799
|
+
work.querySelectorAll(
|
|
1800
|
+
'[data-activity-bucket="reasoning-content"] [data-thought]',
|
|
1801
|
+
),
|
|
1802
|
+
).toHaveLength(2);
|
|
1077
1803
|
await act(async () => work.querySelector("summary")!.click());
|
|
1078
1804
|
expect(work.open).toBe(true);
|
|
1079
|
-
expect(work.querySelectorAll("[data-thought]")).toHaveLength(
|
|
1805
|
+
expect(work.querySelectorAll("[data-thought]")).toHaveLength(2);
|
|
1806
|
+
expect(work.querySelector("[data-protocol-reasoning]")?.textContent).toBe(
|
|
1807
|
+
"Checking assumptions",
|
|
1808
|
+
);
|
|
1809
|
+
expect(work.textContent).toContain("First thought");
|
|
1810
|
+
expect(work.textContent).toContain("Second thought");
|
|
1811
|
+
expect(work.textContent).not.toContain("Hidden thought");
|
|
1080
1812
|
expect(work.querySelector('[data-activity-bucket="thinking"]')).toBeNull();
|
|
1081
1813
|
await act(async () => work.querySelector("summary")!.click());
|
|
1082
1814
|
expect(work.open).toBe(false);
|
|
@@ -1345,8 +2077,13 @@ describe("AgentChat lifecycle", () => {
|
|
|
1345
2077
|
const work = tree.container.querySelector<HTMLDetailsElement>(
|
|
1346
2078
|
".agentkit-activities",
|
|
1347
2079
|
);
|
|
1348
|
-
expect(work).toBeNull();
|
|
1349
|
-
expect(
|
|
2080
|
+
expect(work).not.toBeNull();
|
|
2081
|
+
expect(work?.open).toBe(false);
|
|
2082
|
+
expect(work?.querySelector("summary")?.textContent).toBe(
|
|
2083
|
+
"Worked for 18s",
|
|
2084
|
+
);
|
|
2085
|
+
expect(work?.textContent).toContain("Reviewing the request");
|
|
2086
|
+
expect(work?.textContent).not.toContain("Thinking");
|
|
1350
2087
|
expect(tree.container.querySelector(".agentkit-reasoning")).toBeNull();
|
|
1351
2088
|
expect(tree.container.querySelector("article")).toBeNull();
|
|
1352
2089
|
},
|
|
@@ -1396,9 +2133,9 @@ describe("AgentChat lifecycle", () => {
|
|
|
1396
2133
|
)!;
|
|
1397
2134
|
expect(work.open).toBe(false);
|
|
1398
2135
|
expect(work.querySelector("summary")?.textContent).toBe("Worked");
|
|
1399
|
-
expect(work.
|
|
1400
|
-
|
|
1401
|
-
);
|
|
2136
|
+
expect(work.textContent).toContain("Earlier thought");
|
|
2137
|
+
expect(work.textContent).not.toContain("Thinking");
|
|
2138
|
+
expect(work.querySelector(".agentkit-reasoning")).toBeNull();
|
|
1402
2139
|
expect(tree.container.textContent).not.toContain("Not public");
|
|
1403
2140
|
expect(tree.container.querySelector("[data-supplement]")).not.toBeNull();
|
|
1404
2141
|
expect(tree.container.querySelector("article")).toBeNull();
|
|
@@ -1425,7 +2162,11 @@ describe("AgentChat lifecycle", () => {
|
|
|
1425
2162
|
role: "assistant" as const,
|
|
1426
2163
|
status: "complete" as const,
|
|
1427
2164
|
parts: [
|
|
1428
|
-
{
|
|
2165
|
+
{
|
|
2166
|
+
type: "reasoning" as const,
|
|
2167
|
+
text: "Private reasoning text",
|
|
2168
|
+
visibility: "hidden" as const,
|
|
2169
|
+
},
|
|
1429
2170
|
],
|
|
1430
2171
|
},
|
|
1431
2172
|
],
|