@ai-matrx/chat 0.3.11 → 0.3.19

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/dist/agent-copy/export.d.ts +10 -2
  3. package/dist/agent-copy/export.js +3 -2
  4. package/dist/agents/components/agent-widgets/chat-assistant/CompactAssistantInput.js +1 -1
  5. package/dist/agents/components/debug/SandboxFileViewer.js +1 -3
  6. package/dist/agents/components/inputs/AgentVariablesInline.js +1 -1
  7. package/dist/agents/components/inputs/smart-input/AgentTextarea.js +1 -1
  8. package/dist/agents/components/inputs/smart-input/InputActionButtons.js +1 -1
  9. package/dist/agents/components/inputs/smart-input/composer/ComposerAgentPeek.js +6 -6
  10. package/dist/agents/components/messages-display/TranscriptIntegrityCopyButton.js +4 -4
  11. package/dist/agents/components/messages-display/user/UserActionBar.js +3 -18
  12. package/dist/agents/components/run/AgentRunHeader.js +1 -2
  13. package/dist/agents/components/shared/AgentConversationColumn.js +1 -1
  14. package/dist/agents/components/shared/AgentHeader.js +1 -2
  15. package/dist/agents/components/shared/AgentHeaderMobile.js +1 -2
  16. package/dist/agents/components/working-document/DocumentLinkPicker.d.ts +1 -1
  17. package/dist/agents/components/working-document/WorkingDocumentPanel.js +1 -1
  18. package/dist/agents/components/working-document/documents-workspace/DocumentsListRail.js +2 -2
  19. package/dist/agents/components/working-document/documents-workspace/DocumentsWorkspace.js +2 -2
  20. package/dist/agents/hooks/useInstanceInputUndoRedo.d.ts +1 -1
  21. package/dist/agents/hooks/useInstanceInputUndoRedo.js +1 -1
  22. package/dist/agents/hooks/useWorkingDocument.js +7 -6
  23. package/dist/agents/model-registry/model-classes.d.ts +1 -43
  24. package/dist/agents/model-registry/model-classes.js +1 -40
  25. package/dist/agents/model-registry/parse.d.ts +1 -88
  26. package/dist/agents/model-registry/parse.js +1 -246
  27. package/dist/agents/prompt-preview/PromptPreviewContent.js +1 -3
  28. package/dist/agents/redux/agent-definition/selectors.d.ts +8 -8
  29. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +14 -0
  30. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.js +30 -0
  31. package/dist/agents/redux/execution-system/client-capabilities/desktop-native.provider.js +10 -1
  32. package/dist/agents/redux/execution-system/instance-working-document/cx-working-document.service.d.ts +18 -16
  33. package/dist/agents/redux/execution-system/instance-working-document/cx-working-document.service.js +101 -52
  34. package/dist/agents/redux/execution-system/instance-working-document/instance-working-document.slice.d.ts +2 -2
  35. package/dist/agents/redux/execution-system/instance-working-document/instance-working-document.thunks.d.ts +1 -1
  36. package/dist/agents/redux/execution-system/instance-working-document/scratchpad.thunks.d.ts +1 -1
  37. package/dist/agents/redux/execution-system/message-crud/refetch-single-message.thunk.js +5 -0
  38. package/dist/agents/redux/execution-system/thunks/process-stream.js +2 -2
  39. package/dist/agents/redux/execution-system/utils/stream-block-accumulator.d.ts +14 -0
  40. package/dist/agents/redux/execution-system/utils/stream-block-accumulator.js +28 -0
  41. package/dist/agents/utils/platform-keys.d.ts +15 -0
  42. package/dist/agents/utils/platform-keys.js +69 -0
  43. package/dist/context/sources/scopes.d.ts +1 -1
  44. package/dist/cx-chat/components/user-input/ConversationInput.js +1 -1
  45. package/dist/cx-conversation/ConversationInput.js +1 -1
  46. package/dist/host/db-types.d.ts +23242 -23071
  47. package/dist/host/ui-slots.d.ts +50 -64
  48. package/dist/host/ui-slots.js +12 -52
  49. package/dist/public-chat/components/GuidedVariableInputs.js +1 -1
  50. package/dist/public-chat/components/PublicVariableInputs.js +1 -1
  51. package/dist/react.cjs +11 -23
  52. package/dist/react.cjs.map +1 -1
  53. package/dist/react.js +11 -23
  54. package/dist/react.js.map +1 -1
  55. package/dist/surfaces/manifests/_conversation-document.manifest.js +1 -1
  56. package/dist/tool-call-visualization/registry/registry.js +13 -0
  57. package/dist/ui/composer/useTouchOnlyDevice.js +1 -1
  58. package/dist/ui/skills-types.d.ts +1 -275
  59. package/dist/ui/skills-types.js +1 -0
  60. package/dist/voice-agent/components/VoiceDebugPanel.js +1 -3
  61. package/package.json +60 -34
  62. package/dist/agents/components/run/run-sidebar/AgentRunsSidebar.d.ts +0 -15
  63. package/dist/agents/components/run/run-sidebar/AgentRunsSidebar.js +0 -201
  64. package/dist/agents/components/run-controls/AgentExecutionTestModal.d.ts +0 -36
  65. package/dist/agents/components/run-controls/AgentExecutionTestModal.js +0 -440
  66. package/dist/agents/components/run-controls/AgentLauncherSidebarTester.d.ts +0 -6
  67. package/dist/agents/components/run-controls/AgentLauncherSidebarTester.js +0 -127
  68. package/dist/agents/components/run-controls/AgentWidgetInvokerTester.d.ts +0 -6
  69. package/dist/agents/components/run-controls/AgentWidgetInvokerTester.js +0 -84
  70. package/dist/agents/components/run-controls/CreatorRunPanel.d.ts +0 -22
  71. package/dist/agents/components/run-controls/CreatorRunPanel.js +0 -108
  72. package/dist/agents/components/run-controls/CreatorRunTabContent.d.ts +0 -30
  73. package/dist/agents/components/run-controls/CreatorRunTabContent.js +0 -319
  74. package/dist/agents/components/run-controls/PayloadTab.d.ts +0 -5
  75. package/dist/agents/components/run-controls/PayloadTab.js +0 -388
  76. package/dist/agents/components/run-controls/TesterSettingsPanel.d.ts +0 -71
  77. package/dist/agents/components/run-controls/TesterSettingsPanel.js +0 -470
  78. package/dist/agents/components/shared/AgentOptionsMenu.d.ts +0 -8
  79. package/dist/agents/components/shared/AgentOptionsMenu.js +0 -776
  80. package/dist/agents/components/shared/AgentPeekDuplicateButton.d.ts +0 -8
  81. package/dist/agents/components/shared/AgentPeekDuplicateButton.js +0 -66
  82. package/dist/agents/components/shared/AgentSaveStatus.d.ts +0 -7
  83. package/dist/agents/components/shared/AgentSaveStatus.js +0 -128
  84. package/dist/agents/components/shared/AgentSaveTapButton.d.ts +0 -18
  85. package/dist/agents/components/shared/AgentSaveTapButton.js +0 -105
  86. package/dist/agents/components/shared/useAgentSaveAction.d.ts +0 -33
  87. package/dist/agents/components/shared/useAgentSaveAction.js +0 -179
  88. package/dist/agents/components/shell/AgentsListHeader.d.ts +0 -1
  89. package/dist/agents/components/shell/AgentsListHeader.js +0 -69
  90. package/dist/agents/components/undo-history/AgentEditHistory.d.ts +0 -9
  91. package/dist/agents/components/undo-history/AgentEditHistory.js +0 -244
  92. package/dist/agents/components/unused/AgentSharedHeader.d.ts +0 -3
  93. package/dist/agents/components/unused/AgentSharedHeader.js +0 -134
  94. package/dist/agents/components/widgets/AgentWidgetsPage.d.ts +0 -11
  95. package/dist/agents/components/widgets/AgentWidgetsPage.js +0 -571
  96. package/dist/agents/components/widgets/WidgetVariableInputs.d.ts +0 -8
  97. package/dist/agents/components/widgets/WidgetVariableInputs.js +0 -80
  98. package/dist/agents/components/widgets/build-widget-launch.d.ts +0 -70
  99. package/dist/agents/components/widgets/build-widget-launch.js +0 -90
  100. package/dist/agents/hooks/useAgentAutoSave.d.ts +0 -1
  101. package/dist/agents/hooks/useAgentAutoSave.js +0 -127
  102. package/dist/agents/hooks/useAgentBuilderWriteHandlers.d.ts +0 -9
  103. package/dist/agents/hooks/useAgentBuilderWriteHandlers.js +0 -102
  104. package/dist/agents/hooks/useAgentDuplicateFlow.d.ts +0 -25
  105. package/dist/agents/hooks/useAgentDuplicateFlow.js +0 -133
  106. package/dist/agents/hooks/useAgentUndoRedo.d.ts +0 -31
  107. package/dist/agents/hooks/useAgentUndoRedo.js +0 -134
  108. package/dist/agents/hooks/useAgentUsages.d.ts +0 -17
  109. package/dist/agents/hooks/useAgentUsages.js +0 -36
  110. package/dist/agents/hooks/useDriftAlerts.d.ts +0 -11
  111. package/dist/agents/hooks/useDriftAlerts.js +0 -36
  112. package/dist/agents/hooks/useDriftReport.d.ts +0 -20
  113. package/dist/agents/hooks/useDriftReport.js +0 -34
  114. package/dist/agents/lifecycle/useAgentLifecycleActions.d.ts +0 -17
  115. package/dist/agents/lifecycle/useAgentLifecycleActions.js +0 -63
  116. package/dist/agents/message-flags/useMessageFlags.d.ts +0 -8
  117. package/dist/agents/message-flags/useMessageFlags.js +0 -68
  118. package/dist/agents/services/agent-definition-snapshot.service.d.ts +0 -15
  119. package/dist/agents/services/agent-definition-snapshot.service.js +0 -20
  120. package/dist/agents/surface-catalog-profile.d.ts +0 -96
  121. package/dist/agents/surface-catalog-profile.js +0 -79
  122. package/dist/cx-chat/hooks/useAgentBootstrap.d.ts +0 -1
  123. package/dist/cx-chat/hooks/useAgentBootstrap.js +0 -110
  124. package/dist/host/builder-door.d.ts +0 -61
  125. package/dist/host/builder-door.js +0 -25
  126. package/dist/next/lazy/CreatorRunPanel.d.ts +0 -1
  127. package/dist/next/lazy/CreatorRunPanel.js +0 -11
  128. package/dist/ui/composer/composerSubmit.d.ts +0 -50
  129. package/dist/ui/composer/composerSubmit.js +0 -32
@@ -1,201 +0,0 @@
1
- "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useMemo, useState } from "react";
4
- import { ArchivedDisclosure } from "@ai-matrx/design-system";
5
- import { useRouter, usePathname, useSearchParams } from "../../../../host/navigation.js";
6
- import { Loader2, ChevronRight, MessageSquare } from "lucide-react";
7
- import { useAppDispatch, useAppSelector } from "../../../../store/hooks.js";
8
- import {
9
- selectAgentById,
10
- selectAgentName
11
- } from "../../../redux/agent-definition/selectors.js";
12
- import { selectLatestConversationId } from "../../../redux/execution-system/selectors/aggregate.selectors.js";
13
- import { fetchAgentConversations } from "../../../redux/conversation-list/conversation-list.thunks.js";
14
- import { makeSelectAgentConversations } from "../../../redux/conversation-list/conversation-list.selectors.js";
15
- import { AgentLauncherSidebarTester } from "../../run-controls/AgentLauncherSidebarTester.js";
16
- import { SidebarHeader } from "./SidebarHeader.js";
17
- import { ConversationHoverPreview } from "../../../../host/ui-slots.js";
18
- import { ItemRow } from "../../../../host/ui-slots.js";
19
- import { buildConversationMenu } from "../../conversation-actions/conversationActionRegistry.js";
20
- import { renameConversation } from "../../../redux/conversation-list/conversation-row-actions.thunks.js";
21
- import { pushAddressWithoutNavigating } from "../../../../ui/addressWithoutNavigating.js";
22
- import { ErrorAlchemyMenu } from "../../../../host/ui-slots.js";
23
- function AgentRunsSidebar({
24
- agentId,
25
- conversationId,
26
- surfaceKey,
27
- conversationIdFromUrl,
28
- onToggleSidebar,
29
- basePath,
30
- backHref
31
- }) {
32
- const dispatch = useAppDispatch();
33
- const router = useRouter();
34
- const pathname = usePathname();
35
- const searchParams = useSearchParams();
36
- const canonicalAgentId = useAppSelector((state) => {
37
- const agent = selectAgentById(state, agentId);
38
- return agent?.parentAgentId ?? agent?.id ?? agentId;
39
- });
40
- const selectConversations = useMemo(
41
- () => makeSelectAgentConversations(canonicalAgentId, null),
42
- [canonicalAgentId]
43
- );
44
- const {
45
- status: convStatus,
46
- conversations,
47
- archived,
48
- error: convError
49
- } = useAppSelector((state) => selectConversations(state));
50
- const [showArchived, setShowArchived] = useState(false);
51
- useEffect(() => {
52
- if (convStatus === "idle") {
53
- dispatch(
54
- fetchAgentConversations({
55
- agentId: canonicalAgentId,
56
- versionFilter: null
57
- })
58
- );
59
- }
60
- }, [canonicalAgentId, convStatus, dispatch]);
61
- const liveConversationId = useAppSelector(
62
- (state) => conversationId ? selectLatestConversationId(conversationId)(state) : null
63
- );
64
- const activeConversationId = conversationIdFromUrl ?? liveConversationId ?? void 0;
65
- const handleConversationSelect = (conversationId2) => {
66
- const params = new URLSearchParams(searchParams.toString());
67
- params.set("conversationId", conversationId2);
68
- pushAddressWithoutNavigating(`${pathname}?${params.toString()}`);
69
- };
70
- const agentName = useAppSelector((state) => selectAgentName(state, agentId));
71
- const conversationSectionLoading = convStatus === "loading";
72
- const conversationSectionFailed = convStatus === "failed";
73
- const sourceFeature = "agent-runner";
74
- const launcherSurfaceKey = `${sourceFeature}-launcher:${agentId}`;
75
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 min-h-0", children: [
76
- /* @__PURE__ */ jsx(
77
- SidebarHeader,
78
- {
79
- agentId,
80
- conversationId,
81
- surfaceKey,
82
- conversationIdFromUrl,
83
- onToggleSidebar,
84
- basePath,
85
- backHref
86
- }
87
- ),
88
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 flex flex-col", children: /* @__PURE__ */ jsxs("div", { className: "shrink-0 pt-2", children: [
89
- /* @__PURE__ */ jsx("div", { className: "px-3 py-1.5 flex items-center justify-between", children: /* @__PURE__ */ jsxs("span", { className: "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: [
90
- agentName,
91
- " History"
92
- ] }) }),
93
- conversationSectionLoading && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin text-muted-foreground" }) }),
94
- conversationSectionFailed && /* @__PURE__ */ jsxs("p", { className: "px-3 pb-2 text-[10px] text-destructive", children: [
95
- convError ?? "Failed to load conversations",
96
- /* @__PURE__ */ jsx(ErrorAlchemyMenu, { error: convError })
97
- ] }),
98
- convStatus === "succeeded" && conversations.length === 0 && archived.length === 0 && /* @__PURE__ */ jsx("div", { className: "px-3 pb-3 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground", children: "No conversations yet" }) }),
99
- conversations.map((conv) => /* @__PURE__ */ jsx(
100
- ConversationListRow,
101
- {
102
- conv,
103
- agentId,
104
- surfaceKey,
105
- isActive: conv.conversationId === activeConversationId,
106
- onSelect: () => handleConversationSelect(conv.conversationId)
107
- },
108
- conv.conversationId
109
- )),
110
- /* @__PURE__ */ jsx(
111
- ArchivedDisclosure,
112
- {
113
- count: archived.length,
114
- open: showArchived,
115
- onOpenChange: setShowArchived,
116
- className: "mx-1 mt-1",
117
- children: archived.map((conv) => /* @__PURE__ */ jsx(
118
- ConversationListRow,
119
- {
120
- conv,
121
- agentId,
122
- surfaceKey,
123
- isActive: conv.conversationId === activeConversationId,
124
- onSelect: () => handleConversationSelect(conv.conversationId)
125
- },
126
- conv.conversationId
127
- ))
128
- }
129
- )
130
- ] }) }),
131
- /* @__PURE__ */ jsx("div", { className: "shrink-0 border-t border-border pb-2", children: /* @__PURE__ */ jsx(
132
- AgentLauncherSidebarTester,
133
- {
134
- conversationId,
135
- surfaceKey: launcherSurfaceKey
136
- }
137
- ) })
138
- ] });
139
- }
140
- function ConversationListRow({
141
- conv,
142
- agentId,
143
- surfaceKey,
144
- isActive,
145
- onSelect
146
- }) {
147
- const dispatch = useAppDispatch();
148
- const title = conv.title?.trim() ? conv.title : "Untitled";
149
- const date = conv.updatedAt ? new Date(conv.updatedAt).toLocaleDateString(void 0, {
150
- month: "short",
151
- day: "numeric"
152
- }) : null;
153
- const meta = `${conv.messageCount} msg${conv.messageCount === 1 ? "" : "s"}${date ? ` \xB7 ${date}` : ""}`;
154
- const href = `/agents/go/${agentId}/run?conversationId=${conv.conversationId}`;
155
- return /* @__PURE__ */ jsx(
156
- ConversationHoverPreview,
157
- {
158
- conversationId: conv.conversationId,
159
- side: "right",
160
- align: "start",
161
- onOpen: onSelect,
162
- children: /* @__PURE__ */ jsx(
163
- ItemRow,
164
- {
165
- sourceFeature: "agent-runner",
166
- className: "mx-1",
167
- size: "md",
168
- label: title,
169
- leading: /* @__PURE__ */ jsx(MessageSquare, { className: "w-2.5 h-2.5 text-muted-foreground shrink-0" }),
170
- secondaryLabel: meta,
171
- active: isActive,
172
- onOpen: onSelect,
173
- menu: () => buildConversationMenu({
174
- conversationId: conv.conversationId,
175
- title: conv.title,
176
- isFavorite: conv.isFavorite ?? false,
177
- isArchived: conv.status === "archived",
178
- excludeFromKg: conv.excludeFromKg ?? false,
179
- href,
180
- surfaceKey,
181
- dispatch
182
- }),
183
- rename: {
184
- value: conv.title ?? "",
185
- emptyFallback: "Untitled",
186
- onCommit: (next) => void dispatch(
187
- renameConversation({
188
- conversationId: conv.conversationId,
189
- title: next
190
- })
191
- )
192
- },
193
- trailing: isActive ? /* @__PURE__ */ jsx(ChevronRight, { className: "w-3 h-3 text-primary shrink-0" }) : void 0
194
- }
195
- )
196
- }
197
- );
198
- }
199
- export {
200
- AgentRunsSidebar
201
- };
@@ -1,36 +0,0 @@
1
- import type { VariablesPanelStyle } from "../../types/instance.types.js";
2
- import type { ApiEndpointMode } from "../../types/instance.types.js";
3
- interface AgentExecutionTestModalProps {
4
- surfaceKey: string;
5
- isOpen: boolean;
6
- onClose: () => void;
7
- testType: "direct" | "inline" | "background";
8
- agentId: string;
9
- sourceInstanceId: string;
10
- autoRun: boolean;
11
- allowChat: boolean;
12
- showVariables: boolean;
13
- applyVariables: boolean;
14
- apiEndpointMode: ApiEndpointMode;
15
- variablesPanelStyle?: VariablesPanelStyle;
16
- variables: Record<string, unknown>;
17
- userInput: string;
18
- }
19
- /** Exported for the kind-never-raw harness test. */
20
- export declare function DirectTestMode({ agentId, surfaceKey, variables, userInput, apiEndpointMode, }: {
21
- agentId: string;
22
- surfaceKey: string;
23
- variables: Record<string, unknown>;
24
- userInput: string;
25
- apiEndpointMode: ApiEndpointMode;
26
- }): import("react").JSX.Element;
27
- /** Exported for the kind-never-raw harness test. */
28
- export declare function InlineTestMode({ agentId, surfaceKey, variables, userInput, apiEndpointMode, }: {
29
- agentId: string;
30
- surfaceKey: string;
31
- variables: Record<string, unknown>;
32
- userInput: string;
33
- apiEndpointMode: ApiEndpointMode;
34
- }): import("react").JSX.Element;
35
- export declare function AgentExecutionTestModal({ surfaceKey, isOpen, onClose, testType, agentId, variables, userInput, apiEndpointMode, }: AgentExecutionTestModalProps): import("react").JSX.Element;
36
- export {};
@@ -1,440 +0,0 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useClipboard } from "@ai-matrx/kit/clipboard";
4
- import { toast as copyToast } from "../../../host/notify.js";
5
- import { useState, useEffect, useCallback } from "react";
6
- import { kindTextToMarkdown } from "../../../utils/content-ir/surfaces/kind-text-to-markdown.js";
7
- import { useAppSelector } from "../../../store/hooks.js";
8
- import { selectAgentName } from "../../redux/agent-definition/selectors.js";
9
- import { EntityDoorControls } from "../../../host/ui-slots.js";
10
- import { useAgentLauncher } from "../../hooks/useAgentLauncher.js";
11
- import { useWidgetHandle } from "../../hooks/useWidgetHandle.js";
12
- import {
13
- selectLatestAccumulatedText,
14
- selectLatestRequestStatus
15
- } from "../../redux/execution-system/selectors/aggregate.selectors.js";
16
- import { useRetainLatestRequestForViewer } from "../../redux/execution-system/active-requests/useRetainRequestForViewer.js";
17
- import {
18
- Dialog,
19
- DialogContent,
20
- DialogHeader,
21
- DialogTitle
22
- } from "@ai-matrx/design-system";
23
- import { Button } from "@ai-matrx/design-system/controls";
24
- import { Badge } from "@ai-matrx/design-system";
25
- import { Textarea } from "@ai-matrx/design-system";
26
- import { ScrollArea } from "@ai-matrx/design-system";
27
- import { Separator } from "@ai-matrx/design-system";
28
- import {
29
- Play,
30
- Copy,
31
- Check,
32
- Loader2,
33
- ArrowRight,
34
- Replace,
35
- ArrowUpFromLine,
36
- ArrowDownFromLine,
37
- X
38
- } from "lucide-react";
39
- import { toast } from "../../../host/notify.js";
40
- import { AnswerValueView } from "../../../host/ui-slots.js";
41
- function DirectTestMode({
42
- agentId,
43
- surfaceKey,
44
- variables,
45
- userInput,
46
- apiEndpointMode
47
- }) {
48
- const { copyText } = useClipboard({
49
- notify: (message, kind) => kind === "error" ? copyToast.error(message) : copyToast.success(message)
50
- });
51
- const { launchAgent, close } = useAgentLauncher();
52
- const [conversationId, setConversationId] = useState(null);
53
- const [copied, setCopied] = useState(false);
54
- const responseText = useAppSelector(
55
- conversationId ? selectLatestAccumulatedText(conversationId) : () => ""
56
- );
57
- useRetainLatestRequestForViewer(conversationId, "InlineTestMode");
58
- useRetainLatestRequestForViewer(conversationId, "DirectTestMode");
59
- const status = useAppSelector(
60
- conversationId ? selectLatestRequestStatus(conversationId) : () => void 0
61
- );
62
- const handleExecute = useCallback(async () => {
63
- if (conversationId) close(conversationId);
64
- try {
65
- const result = await launchAgent(agentId, {
66
- surfaceKey,
67
- sourceFeature: "agent-builder",
68
- apiEndpointMode,
69
- config: {
70
- displayMode: "direct",
71
- autoRun: true,
72
- defaultVariables: variables
73
- },
74
- runtime: {
75
- surfaceName: null,
76
- userInput: userInput || "Hello, please respond briefly."
77
- }
78
- });
79
- setConversationId(result.conversationId);
80
- } catch (err) {
81
- toast.error("Direct run failed", {
82
- description: err instanceof Error ? err.message : String(err)
83
- });
84
- }
85
- }, [
86
- agentId,
87
- variables,
88
- userInput,
89
- apiEndpointMode,
90
- launchAgent,
91
- close,
92
- conversationId
93
- ]);
94
- const handleCopy = useCallback(async () => {
95
- if (responseText) {
96
- if (!await copyText(kindTextToMarkdown(responseText))) return;
97
- setCopied(true);
98
- setTimeout(() => setCopied(false), 2e3);
99
- }
100
- }, [responseText]);
101
- useEffect(() => {
102
- return () => {
103
- if (conversationId) close(conversationId);
104
- };
105
- }, []);
106
- const isStreaming = status === "streaming" || status === "pending" || status === "connecting";
107
- return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
108
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
109
- /* @__PURE__ */ jsx(Button, { icon: isStreaming ? /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) : /* @__PURE__ */ jsx(Play, {}), variant: "primary", onClick: handleExecute, disabled: isStreaming, children: isStreaming ? "Streaming..." : "Execute" }),
110
- status && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-[10px]", children: status })
111
- ] }),
112
- /* @__PURE__ */ jsx(ScrollArea, { className: "h-64 rounded-md border border-border bg-muted/20 p-3", children: responseText ? (
113
- // The harness shows the answer as a person sees it — a kind as its
114
- // kind, never JSON (kind-never-raw R1). Copy hands over its markdown.
115
- /* @__PURE__ */ jsx("div", { className: "text-xs text-foreground", children: /* @__PURE__ */ jsx(AnswerValueView, { text: responseText }) })
116
- ) : /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: isStreaming ? "Waiting for response..." : "Press Execute to run the agent in direct mode." }) }),
117
- responseText && /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { icon: copied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), variant: "outline", onClick: handleCopy, children: copied ? "Copied" : "Copy" }) })
118
- ] });
119
- }
120
- function InlineTestMode({
121
- agentId,
122
- surfaceKey,
123
- variables,
124
- userInput,
125
- apiEndpointMode
126
- }) {
127
- const { launchAgent, close } = useAgentLauncher();
128
- const [conversationId, setConversationId] = useState(null);
129
- const [editorText, setEditorText] = useState(
130
- "The quick brown fox jumps over the lazy dog.\n\nThis is sample text that simulates a document editor.\nSelect a portion of text and run the inline test to see how the agent processes it.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit."
131
- );
132
- const [selectionRange] = useState({ start: 4, end: 19 });
133
- const selectedText = editorText.substring(
134
- selectionRange.start,
135
- selectionRange.end
136
- );
137
- const responseText = useAppSelector(
138
- conversationId ? selectLatestAccumulatedText(conversationId) : () => ""
139
- );
140
- const status = useAppSelector(
141
- conversationId ? selectLatestRequestStatus(conversationId) : () => void 0
142
- );
143
- const isStreaming = status === "streaming" || status === "pending" || status === "connecting";
144
- const isComplete = status === "complete";
145
- const handleExecute = useCallback(async () => {
146
- if (conversationId) close(conversationId);
147
- try {
148
- const result = await launchAgent(agentId, {
149
- surfaceKey,
150
- sourceFeature: "agent-builder",
151
- apiEndpointMode,
152
- config: {
153
- displayMode: "inline",
154
- autoRun: true,
155
- defaultVariables: { ...variables, selection: selectedText }
156
- },
157
- runtime: {
158
- surfaceName: null,
159
- userInput: userInput || `Process this text: "${selectedText}"`
160
- }
161
- });
162
- setConversationId(result.conversationId);
163
- } catch (err) {
164
- toast.error("Inline run failed", {
165
- description: err instanceof Error ? err.message : String(err)
166
- });
167
- }
168
- }, [
169
- agentId,
170
- variables,
171
- userInput,
172
- selectedText,
173
- apiEndpointMode,
174
- launchAgent,
175
- close,
176
- conversationId
177
- ]);
178
- const handleReplace = useCallback(() => {
179
- if (!responseText) return;
180
- const before = editorText.substring(0, selectionRange.start);
181
- const after = editorText.substring(selectionRange.end);
182
- setEditorText(before + responseText.trim() + after);
183
- if (conversationId) close(conversationId);
184
- setConversationId(null);
185
- }, [responseText, editorText, selectionRange, conversationId, close]);
186
- const handleInsertBefore = useCallback(() => {
187
- if (!responseText) return;
188
- const before = editorText.substring(0, selectionRange.start);
189
- const after = editorText.substring(selectionRange.start);
190
- setEditorText(before + responseText.trim() + "\n" + after);
191
- if (conversationId) close(conversationId);
192
- setConversationId(null);
193
- }, [responseText, editorText, selectionRange, conversationId, close]);
194
- const handleInsertAfter = useCallback(() => {
195
- if (!responseText) return;
196
- const before = editorText.substring(0, selectionRange.end);
197
- const after = editorText.substring(selectionRange.end);
198
- setEditorText(before + "\n" + responseText.trim() + after);
199
- if (conversationId) close(conversationId);
200
- setConversationId(null);
201
- }, [responseText, editorText, selectionRange, conversationId, close]);
202
- const handleCancel = useCallback(() => {
203
- if (conversationId) close(conversationId);
204
- setConversationId(null);
205
- }, [conversationId, close]);
206
- useEffect(() => {
207
- return () => {
208
- if (conversationId) close(conversationId);
209
- };
210
- }, []);
211
- return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
212
- /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
213
- "Simulated editor with selection: \u201C",
214
- selectedText,
215
- "\u201D"
216
- ] }),
217
- /* @__PURE__ */ jsx(
218
- Textarea,
219
- {
220
- value: editorText,
221
- onChange: (e) => setEditorText(e.target.value),
222
- rows: 6,
223
- className: "text-xs font-mono",
224
- style: { fontSize: "16px" }
225
- }
226
- ),
227
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
228
- /* @__PURE__ */ jsx(Button, { icon: isStreaming ? /* @__PURE__ */ jsx(Loader2, { className: "animate-spin" }) : /* @__PURE__ */ jsx(ArrowRight, {}), variant: "primary", onClick: handleExecute, disabled: isStreaming, children: isStreaming ? "Processing..." : "Run Inline" }),
229
- status && /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-[10px]", children: status })
230
- ] }),
231
- isComplete && responseText && /* @__PURE__ */ jsxs(Fragment, { children: [
232
- /* @__PURE__ */ jsx(Separator, {}),
233
- /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border bg-muted/20 p-3", children: [
234
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-2", children: "Agent response:" }),
235
- /* @__PURE__ */ jsx("div", { className: "mb-3 text-xs text-foreground", children: /* @__PURE__ */ jsx(AnswerValueView, { text: responseText }) }),
236
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
237
- /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(Replace, {}), variant: "primary", onClick: handleReplace, children: "Replace" }),
238
- /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(ArrowUpFromLine, {}), variant: "outline", onClick: handleInsertBefore, children: "Insert Before" }),
239
- /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(ArrowDownFromLine, {}), variant: "outline", onClick: handleInsertAfter, children: "Insert After" }),
240
- /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(X, {}), variant: "quiet", onClick: handleCancel, children: "Cancel" })
241
- ] })
242
- ] })
243
- ] })
244
- ] });
245
- }
246
- function BackgroundTestMode({
247
- agentId,
248
- surfaceKey,
249
- variables,
250
- userInput,
251
- apiEndpointMode
252
- }) {
253
- const { launchAgent, close } = useAgentLauncher();
254
- const [tasks, setTasks] = useState([]);
255
- const widgetHandleId = useWidgetHandle({
256
- onComplete: (launchResult) => {
257
- setTasks(
258
- (prev) => prev.map(
259
- (t) => t.conversationId === launchResult.conversationId ? {
260
- ...t,
261
- status: "complete",
262
- preview: launchResult.responseText?.substring(0, 200)
263
- } : t
264
- )
265
- );
266
- }
267
- });
268
- const handleExecute = useCallback(async () => {
269
- try {
270
- const result = await launchAgent(agentId, {
271
- surfaceKey,
272
- sourceFeature: "agent-builder",
273
- apiEndpointMode,
274
- config: {
275
- displayMode: "background",
276
- autoRun: true,
277
- defaultVariables: variables
278
- },
279
- runtime: {
280
- surfaceName: null,
281
- userInput: userInput || "Respond briefly with one sentence.",
282
- widgetHandleId
283
- }
284
- });
285
- setTasks((prev) => [
286
- {
287
- conversationId: result.conversationId,
288
- startedAt: (/* @__PURE__ */ new Date()).toLocaleTimeString(),
289
- status: "running"
290
- },
291
- ...prev
292
- ]);
293
- } catch (err) {
294
- toast.error("Background run failed", {
295
- description: err instanceof Error ? err.message : String(err)
296
- });
297
- }
298
- }, [
299
- agentId,
300
- variables,
301
- userInput,
302
- apiEndpointMode,
303
- launchAgent,
304
- surfaceKey,
305
- widgetHandleId
306
- ]);
307
- useEffect(() => {
308
- return () => {
309
- tasks.forEach((t) => {
310
- if (t.status === "running") close(t.conversationId);
311
- });
312
- };
313
- }, []);
314
- return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
315
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
316
- /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(Play, {}), variant: "primary", onClick: handleExecute, children: "Run Background Task" }),
317
- /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
318
- tasks.length,
319
- " task(s)"
320
- ] })
321
- ] }),
322
- tasks.length > 0 && /* @__PURE__ */ jsx(ScrollArea, { className: "h-48 rounded-md border border-border", children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-border", children: tasks.map((task) => /* @__PURE__ */ jsxs(
323
- "div",
324
- {
325
- className: "group flex items-start gap-2 px-3 py-2",
326
- children: [
327
- /* @__PURE__ */ jsxs(
328
- Badge,
329
- {
330
- variant: task.status === "complete" ? "default" : "secondary",
331
- className: "text-[10px] shrink-0 mt-0.5",
332
- children: [
333
- task.status === "running" && /* @__PURE__ */ jsx(Loader2, { className: "w-2.5 h-2.5 mr-1 animate-spin" }),
334
- task.status === "complete" && /* @__PURE__ */ jsx(Check, { className: "w-2.5 h-2.5 mr-1" }),
335
- task.status
336
- ]
337
- }
338
- ),
339
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
340
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1 text-[10px] text-muted-foreground font-mono", children: [
341
- /* @__PURE__ */ jsxs("span", { className: "shrink-0", children: [
342
- task.startedAt,
343
- " \u2014 ",
344
- task.conversationId.substring(0, 8)
345
- ] }),
346
- /* @__PURE__ */ jsx(
347
- EntityDoorControls,
348
- {
349
- token: "conversation",
350
- id: task.conversationId,
351
- name: task.conversationId.substring(0, 8),
352
- className: "shrink-0"
353
- }
354
- )
355
- ] }),
356
- task.preview && /* @__PURE__ */ jsx("p", { className: "text-xs text-foreground mt-0.5 line-clamp-2", children: task.preview })
357
- ] })
358
- ]
359
- },
360
- task.conversationId
361
- )) }) })
362
- ] });
363
- }
364
- function AgentUnderTest({ agentId }) {
365
- const agentName = useAppSelector((state) => selectAgentName(state, agentId));
366
- if (!agentId) {
367
- return /* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "No agent" });
368
- }
369
- return /* @__PURE__ */ jsxs(Fragment, { children: [
370
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate font-medium", children: agentName || `${agentId.slice(0, 8)}\u2026` }),
371
- /* @__PURE__ */ jsx(
372
- EntityDoorControls,
373
- {
374
- token: "agent",
375
- id: agentId,
376
- name: agentName,
377
- alwaysShowActions: true,
378
- className: "shrink-0"
379
- }
380
- )
381
- ] });
382
- }
383
- const MODE_TITLES = {
384
- direct: "Direct Stream Test",
385
- inline: "Inline Overlay Test",
386
- background: "Background Execution Test"
387
- };
388
- function AgentExecutionTestModal({
389
- surfaceKey,
390
- isOpen,
391
- onClose,
392
- testType,
393
- agentId,
394
- variables,
395
- userInput,
396
- apiEndpointMode
397
- }) {
398
- return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-2xl", children: [
399
- /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex min-w-0 items-center gap-1.5 pr-14 text-sm", children: [
400
- /* @__PURE__ */ jsx("span", { className: "shrink-0", children: MODE_TITLES[testType] ?? "Test Execution" }),
401
- /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: "\u2014" }),
402
- /* @__PURE__ */ jsx(AgentUnderTest, { agentId })
403
- ] }) }),
404
- testType === "direct" && /* @__PURE__ */ jsx(
405
- DirectTestMode,
406
- {
407
- agentId,
408
- surfaceKey,
409
- variables,
410
- userInput,
411
- apiEndpointMode
412
- }
413
- ),
414
- testType === "inline" && /* @__PURE__ */ jsx(
415
- InlineTestMode,
416
- {
417
- agentId,
418
- surfaceKey,
419
- variables,
420
- userInput,
421
- apiEndpointMode
422
- }
423
- ),
424
- testType === "background" && /* @__PURE__ */ jsx(
425
- BackgroundTestMode,
426
- {
427
- agentId,
428
- surfaceKey,
429
- variables,
430
- userInput,
431
- apiEndpointMode
432
- }
433
- )
434
- ] }) });
435
- }
436
- export {
437
- AgentExecutionTestModal,
438
- DirectTestMode,
439
- InlineTestMode
440
- };
@@ -1,6 +0,0 @@
1
- interface AgentLauncherSidebarTesterProps {
2
- conversationId: string;
3
- surfaceKey: string;
4
- }
5
- export declare function AgentLauncherSidebarTester({ conversationId, surfaceKey, }: AgentLauncherSidebarTesterProps): import("react").JSX.Element;
6
- export {};