@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,776 +0,0 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useAppDispatch, useAppSelector } from "../../../store/hooks.js";
4
- import { applyOrganizationContextHeader } from "../../../host/server/organization-context.js";
5
- import { getBuilderDoor } from "../../../host/builder-door.js";
6
- import { invalidateAgentCache } from "../../redux/agent-definition/invalidate-agent-cache.thunk.js";
7
- import { selectAgentById } from "../../redux/agent-definition/selectors.js";
8
- import { useOpenAgentSettingsWindow } from "../../../host/window-openers.js";
9
- import { useOpenAgentRunHistoryWindow } from "../../../host/window-openers.js";
10
- import { useOpenAgentContentWindow } from "../../../host/window-openers.js";
11
- import { useOpenAgentRunWindow } from "../../../host/window-openers.js";
12
- import { useOpenAgentOptimizerWindow } from "../../../host/window-openers.js";
13
- import { useOpenAgentFindUsagesWindow } from "../../../host/window-openers.js";
14
- import { useOpenAgentCreateAppWindow } from "../../../host/window-openers.js";
15
- import { useOpenAgentDataStorageWindow } from "../../../host/window-openers.js";
16
- import { useOpenAgentConvertSystemWindow } from "../../../host/window-openers.js";
17
- import { useOpenAgentShortcutQuickCreateWindow } from "../../../host/window-openers.js";
18
- import { useOpenAgentAdminFindUsagesWindow } from "../../../host/window-openers.js";
19
- import { useOpenAgentImportWindow } from "../../../host/window-openers.js";
20
- import { useOpenAgentInterfaceVariationsWindow } from "../../../host/window-openers.js";
21
- import { useOpenSaveTemplateDialog } from "../../../host/window-openers.js";
22
- const SAVE_AS_TEMPLATE_LABEL = "Save as template";
23
- import { useCallback, useState } from "react";
24
- import { Link } from "../../../host/navigation.js";
25
- import {
26
- MoreHorizontal,
27
- FileText,
28
- History,
29
- GitBranch,
30
- SlidersHorizontal,
31
- Atom,
32
- Maximize2,
33
- Play,
34
- Copy,
35
- AppWindow,
36
- Database,
37
- Layers,
38
- ChevronRight,
39
- Shield,
40
- RefreshCw,
41
- Link2,
42
- Search,
43
- Upload,
44
- ExternalLink,
45
- FileChartColumn,
46
- RotateCcw,
47
- Archive,
48
- ArchiveRestore,
49
- Trash2,
50
- PackagePlus
51
- } from "lucide-react";
52
- import { toast } from "../../../host/notify.js";
53
- import { cn } from "@ai-matrx/design-system";
54
- import { useIsMobile } from "@ai-matrx/kit/media-query";
55
- import { TapTargetButtonTransparent } from "@ai-matrx/tap-target";
56
- import {
57
- DropdownMenu,
58
- DropdownMenuContent,
59
- DropdownMenuItem,
60
- DropdownMenuTrigger,
61
- DropdownMenuSeparator,
62
- DropdownMenuSub,
63
- DropdownMenuSubTrigger,
64
- DropdownMenuSubContent,
65
- DropdownMenuLabel
66
- } from "@ai-matrx/design-system";
67
- import { Drawer, DrawerContent, DrawerTitle } from "@ai-matrx/design-system";
68
- import { MenuTapButton } from "@ai-matrx/tap-target/buttons";
69
- import { useAgentDuplicateFlow } from "../../hooks/useAgentDuplicateFlow.js";
70
- import { ReferenceCopyMenuItem } from "../../../host/ui-slots.js";
71
- import { useAgentLifecycleActions } from "../../lifecycle/useAgentLifecycleActions.js";
72
- import { selectIsSuperAdmin } from "../../../host/identity.js";
73
- import { selectOrganizationId } from "../../../host/org.js";
74
- import { Button, Tile } from "@ai-matrx/design-system/controls";
75
- const INTERFACE_VARIATIONS = [
76
- "Full Modal",
77
- "Compact Modal",
78
- "Inline",
79
- "Sidebar",
80
- "Flexible Panel",
81
- "Background",
82
- "Toast",
83
- "Direct",
84
- "Background Process"
85
- ];
86
- const THIS_AGENT_ITEMS = [
87
- { label: "Edit Agent Info", icon: FileText },
88
- { label: "View Run History", icon: History },
89
- { label: "Advanced Settings View", icon: SlidersHorizontal },
90
- { label: "View All Versions", icon: GitBranch },
91
- { label: "Open Run Modal", icon: Play },
92
- { label: "Full Screen Editor", icon: Maximize2, soon: true },
93
- { label: "Matrx Agent Optimizer", icon: Atom },
94
- { label: "Find Usages", icon: Search },
95
- { label: "Drift Report", icon: FileChartColumn },
96
- { label: "Refresh Server Cache", icon: RotateCcw }
97
- ];
98
- const AGENT_MANAGEMENT_ITEMS = [
99
- { label: "Create Shortcut", icon: Link2 },
100
- { label: "Duplicate", icon: Copy },
101
- // Unified link surface (user agent ⇄ system agent): create/open my personal
102
- // copy, pull system updates, push to system, or convert a user agent into a
103
- // new system agent. Valid on both user and builtin agents — the window
104
- // resolves the relationship and gates each action.
105
- { label: "Linked Agent Sync", icon: RefreshCw },
106
- { label: "Convert to Template", icon: Shield },
107
- { label: "Create App", icon: AppWindow },
108
- { label: "Add Data Storage Support", icon: Database },
109
- // Share this agent + the tables its variables read (+ the agents that share
110
- // them) as a template for the organization. The dialog says so plainly
111
- // when the agent reads no tables yet.
112
- { label: SAVE_AS_TEMPLATE_LABEL, icon: PackagePlus }
113
- ];
114
- const GLOBAL_AGENT_ITEMS = [
115
- { label: "Import Agent", icon: Upload }
116
- ];
117
- const NEW_TAB_ITEMS = [
118
- {
119
- label: "Open in Chat",
120
- icon: ExternalLink,
121
- getHref: (id) => `/chat/a/${encodeURIComponent(id)}`
122
- },
123
- {
124
- label: "View Agent",
125
- icon: ExternalLink,
126
- getHref: (id, base) => `${base}/${id}`
127
- },
128
- {
129
- label: "Build Agent",
130
- icon: ExternalLink,
131
- getHref: (id, base) => `${base}/${id}/build`
132
- },
133
- {
134
- label: "Run Agent",
135
- icon: ExternalLink,
136
- getHref: (id, base) => `${base}/${id}/run`
137
- },
138
- {
139
- label: "View Versions",
140
- icon: ExternalLink,
141
- getHref: (id, base) => `${base}/${id}/latest`
142
- }
143
- ];
144
- const ADMIN_ITEMS = [
145
- { label: "Find Usages (Admin)", icon: Search }
146
- ];
147
- function comingSoon() {
148
- toast.info("Coming Soon");
149
- }
150
- function SoonBadge() {
151
- return /* @__PURE__ */ jsx("span", { className: "ml-2 text-[10px] font-medium text-muted-foreground/60 bg-muted rounded px-1 py-0.5 leading-none", children: "soon" });
152
- }
153
- async function convertToTemplate(agentId, organizationId) {
154
- const response = await fetch(`/api/agents/${agentId}/convert-to-template`, {
155
- method: "POST",
156
- // The template is filed in the organization the person selected — the
157
- // route refuses without it rather than filing in a own organization.
158
- headers: applyOrganizationContextHeader({}, organizationId)
159
- });
160
- if (!response.ok) {
161
- const data2 = await response.json().catch(() => ({ error: "Unknown error" }));
162
- throw new Error(
163
- data2.details ? `${data2.error}: ${data2.details}` : data2.error || "Failed"
164
- );
165
- }
166
- const data = await response.json();
167
- toast.success(data.message ?? "Saved as template!");
168
- }
169
- function AgentOptionsMenu({
170
- agentId,
171
- asTapTarget,
172
- basePath = "/agents"
173
- }) {
174
- const isMobile = useIsMobile();
175
- const [open, setOpen] = useState(false);
176
- const [isConverting, setIsConverting] = useState(false);
177
- const [isRefreshingCache, setIsRefreshingCache] = useState(false);
178
- const dispatch = useAppDispatch();
179
- const openSettings = useOpenAgentSettingsWindow();
180
- const openRunHistory = useOpenAgentRunHistoryWindow();
181
- const openAdvancedEditor = useOpenAgentContentWindow();
182
- const openRun = useOpenAgentRunWindow();
183
- const openOptimizer = useOpenAgentOptimizerWindow();
184
- const openFindUsages = useOpenAgentFindUsagesWindow();
185
- const openCreateApp = useOpenAgentCreateAppWindow();
186
- const openDataStorage = useOpenAgentDataStorageWindow();
187
- const openConvertSystem = useOpenAgentConvertSystemWindow();
188
- const openShortcut = useOpenAgentShortcutQuickCreateWindow();
189
- const openSaveTemplate = useOpenSaveTemplateDialog();
190
- const openAdminFindUsages = useOpenAgentAdminFindUsagesWindow();
191
- const openImport = useOpenAgentImportWindow();
192
- const openInterfaceVariations = useOpenAgentInterfaceVariationsWindow();
193
- const duplicateFlow = useAgentDuplicateFlow(agentId, {
194
- basePath,
195
- fallbackSuffix: ""
196
- });
197
- const agent = useAppSelector((state) => selectAgentById(state, agentId));
198
- const isBuiltin = agent?.agentType === "builtin";
199
- const runDuplicate = duplicateFlow.openChooser;
200
- const hasBuilderDoor = getBuilderDoor() !== null;
201
- const managementItems = AGENT_MANAGEMENT_ITEMS.filter(
202
- (item) => (!isBuiltin || item.label !== "Convert to Template") && (hasBuilderDoor || item.label !== "Duplicate")
203
- );
204
- const isSuperAdmin = useAppSelector(selectIsSuperAdmin);
205
- const lifecycle = useAgentLifecycleActions(agentId, basePath);
206
- const selectedOrganizationId = useAppSelector(selectOrganizationId);
207
- const adminItems = isSuperAdmin ? ADMIN_ITEMS : [];
208
- const runRefreshServerCache = useCallback(async () => {
209
- setIsRefreshingCache(true);
210
- try {
211
- const result = await dispatch(invalidateAgentCache({ agentId })).unwrap();
212
- if (result.cleared) {
213
- toast.success(
214
- "Server cache cleared. The next run will load the latest agent definition."
215
- );
216
- } else {
217
- toast.error("Server did not confirm cache clearance.");
218
- }
219
- } catch (err) {
220
- toast.error(
221
- err instanceof Error ? err.message : "Failed to refresh server cache."
222
- );
223
- } finally {
224
- setIsRefreshingCache(false);
225
- }
226
- }, [agentId, dispatch]);
227
- const handleDesktopItemClick = async (label) => {
228
- console.log("[AGENT OPTIONS MENU] Clicked item:", label);
229
- if (label === "Edit Agent Info") {
230
- console.log(
231
- "[AGENT OPTIONS MENU] Editing agent info, Agent ID:",
232
- agentId
233
- );
234
- openSettings({ initialAgentId: agentId });
235
- setOpen(false);
236
- } else if (label === "View Run History") {
237
- console.log(
238
- "[AGENT OPTIONS MENU] Viewing run history, Agent ID:",
239
- agentId
240
- );
241
- openRunHistory({
242
- agentId: agentId ?? null,
243
- initialSelectedConversationId: null
244
- });
245
- setOpen(false);
246
- } else if (label === "Advanced Settings View") {
247
- console.log(
248
- "[AGENT OPTIONS MENU] Viewing advanced settings, Agent ID:",
249
- agentId
250
- );
251
- openAdvancedEditor({
252
- initialAgentId: agentId ?? null,
253
- initialTab: void 0,
254
- tabs: null
255
- });
256
- setOpen(false);
257
- } else if (label === "Open Run Modal") {
258
- console.log("[AGENT OPTIONS MENU] Opening run modal, Agent ID:", agentId);
259
- openRun({
260
- initialAgentId: agentId ?? null,
261
- initialSelectedConversationId: null
262
- });
263
- setOpen(false);
264
- } else if (label === "Matrx Agent Optimizer") {
265
- console.log(
266
- "[AGENT OPTIONS MENU] Opening matrx agent optimizer, Agent ID:",
267
- agentId
268
- );
269
- openOptimizer({ agentId: agentId ?? null });
270
- setOpen(false);
271
- } else if (label === "Find Usages") {
272
- console.log("[AGENT OPTIONS MENU] Finding usages, Agent ID:", agentId);
273
- openFindUsages({ agentId: agentId ?? null });
274
- setOpen(false);
275
- } else if (label === "Create App") {
276
- console.log("[AGENT OPTIONS MENU] Creating app, Agent ID:", agentId);
277
- openCreateApp();
278
- setOpen(false);
279
- } else if (label === "Add Data Storage Support") {
280
- console.log(
281
- "[AGENT OPTIONS MENU] Adding data storage support, Agent ID:",
282
- agentId
283
- );
284
- openDataStorage({ agentId: agentId ?? null });
285
- setOpen(false);
286
- } else if (label === "Linked Agent Sync") {
287
- console.log(
288
- "[AGENT OPTIONS MENU] Opening linked agent sync, Agent ID:",
289
- agentId
290
- );
291
- openConvertSystem({ agentId: agentId ?? null });
292
- setOpen(false);
293
- } else if (label === SAVE_AS_TEMPLATE_LABEL) {
294
- openSaveTemplate({ initialAgentId: agentId ?? null });
295
- setOpen(false);
296
- } else if (label === "Create Shortcut") {
297
- console.log("[AGENT OPTIONS MENU] Creating shortcut, Agent ID:", agentId);
298
- openShortcut({ agentId: agentId ?? null });
299
- setOpen(false);
300
- } else if (label === "Find Usages (Admin)") {
301
- console.log(
302
- "[AGENT OPTIONS MENU] Finding usages (admin), Agent ID:",
303
- agentId
304
- );
305
- openAdminFindUsages({ agentId: agentId ?? null });
306
- setOpen(false);
307
- } else if (label === "Import Agent") {
308
- console.log("[AGENT OPTIONS MENU] Importing agent, Agent ID:", agentId);
309
- openImport({});
310
- setOpen(false);
311
- } else if (label === "Duplicate") {
312
- console.log("[AGENT OPTIONS MENU] Duplicating agent, Agent ID:", agentId);
313
- setOpen(false);
314
- void runDuplicate();
315
- } else if (label === "Refresh Server Cache") {
316
- setOpen(false);
317
- void runRefreshServerCache();
318
- } else if (label === "Convert to Template") {
319
- console.log(
320
- "[AGENT OPTIONS MENU] Converting to template, Agent ID:",
321
- agentId
322
- );
323
- if (!selectedOrganizationId) {
324
- toast.error(
325
- "Select an organization from the avatar menu, then try again."
326
- );
327
- return;
328
- }
329
- setIsConverting(true);
330
- try {
331
- await convertToTemplate(agentId, selectedOrganizationId);
332
- } catch (err) {
333
- toast.error(
334
- err instanceof Error ? err.message : "Failed to save as template"
335
- );
336
- } finally {
337
- setIsConverting(false);
338
- setOpen(false);
339
- }
340
- } else {
341
- console.log(
342
- "[AGENT OPTIONS MENU] Unknow Clicked Item: ",
343
- label,
344
- "Coming soon, Agent ID:",
345
- agentId
346
- );
347
- comingSoon();
348
- }
349
- };
350
- const handleInterfaceVariationClick = () => {
351
- console.log(
352
- "[AGENT OPTIONS MENU] Handling interface variation click, Agent ID:",
353
- agentId
354
- );
355
- openInterfaceVariations({ agentId: agentId ?? null });
356
- setOpen(false);
357
- };
358
- const trigger = /* @__PURE__ */ jsx(MenuTapButton, { variant: "transparent" });
359
- const duplicateDialog = duplicateFlow.dialog;
360
- if (isMobile) {
361
- return /* @__PURE__ */ jsxs(Fragment, { children: [
362
- /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange: setOpen, children: [
363
- asTapTarget ? /* @__PURE__ */ jsx(
364
- TapTargetButtonTransparent,
365
- {
366
- icon: /* @__PURE__ */ jsx(MoreHorizontal, { className: "w-4 h-4" }),
367
- ariaLabel: "Agent options",
368
- onClick: () => setOpen(true)
369
- }
370
- ) : /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(MoreHorizontal, {}), "aria-label": "Agent options", onClick: () => setOpen(true) }),
371
- /* @__PURE__ */ jsxs(DrawerContent, { className: "max-h-[85dvh]", children: [
372
- /* @__PURE__ */ jsx(DrawerTitle, { className: "sr-only", children: "Agent Options" }),
373
- /* @__PURE__ */ jsx(
374
- MobileMenuContent,
375
- {
376
- onClose: () => setOpen(false),
377
- agentId,
378
- basePath,
379
- onTriggerDuplicate: runDuplicate,
380
- onTriggerRefreshCache: runRefreshServerCache,
381
- isRefreshingCache
382
- }
383
- )
384
- ] })
385
- ] }),
386
- duplicateDialog
387
- ] });
388
- }
389
- return /* @__PURE__ */ jsxs(Fragment, { children: [
390
- /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
391
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: trigger }),
392
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-80", children: [
393
- /* @__PURE__ */ jsx(
394
- ReferenceCopyMenuItem,
395
- {
396
- referenceType: "agent",
397
- id: agentId,
398
- label: agent?.name ?? void 0,
399
- toastLabel: agent?.name ?? "Agent",
400
- onCopied: () => setOpen(false)
401
- }
402
- ),
403
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
404
- THIS_AGENT_ITEMS.map(({ label, icon: Icon, soon }) => {
405
- if (label === "View All Versions" || label === "Drift Report") {
406
- const href = label === "Drift Report" ? "/reports/agent-drift" : `${basePath}/${agentId}/latest?tab=history`;
407
- return /* @__PURE__ */ jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxs(
408
- Link,
409
- {
410
- href,
411
- className: "flex items-center gap-2 cursor-pointer",
412
- onClick: () => setOpen(false),
413
- children: [
414
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
415
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: label })
416
- ]
417
- }
418
- ) }, label);
419
- }
420
- return /* @__PURE__ */ jsxs(
421
- DropdownMenuItem,
422
- {
423
- disabled: label === "Refresh Server Cache" && isRefreshingCache,
424
- onClick: () => handleDesktopItemClick(label),
425
- className: cn(soon && "text-muted-foreground"),
426
- children: [
427
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
428
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: label === "Refresh Server Cache" && isRefreshingCache ? "Refreshing..." : label }),
429
- soon && /* @__PURE__ */ jsx(SoonBadge, {})
430
- ]
431
- },
432
- label
433
- );
434
- }),
435
- /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
436
- /* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [
437
- /* @__PURE__ */ jsx(Layers, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
438
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: "Try Interface Variations" })
439
- ] }),
440
- /* @__PURE__ */ jsx(DropdownMenuSubContent, { className: "w-48", children: INTERFACE_VARIATIONS.map((v) => /* @__PURE__ */ jsx(
441
- DropdownMenuItem,
442
- {
443
- onClick: handleInterfaceVariationClick,
444
- children: v
445
- },
446
- v
447
- )) })
448
- ] }),
449
- /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
450
- /* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { children: [
451
- /* @__PURE__ */ jsx(ExternalLink, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
452
- "Open in New Tab"
453
- ] }),
454
- /* @__PURE__ */ jsx(DropdownMenuSubContent, { className: "w-44", children: NEW_TAB_ITEMS.map(({ label, icon: Icon, getHref }) => /* @__PURE__ */ jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxs(
455
- Link,
456
- {
457
- href: getHref(agentId, basePath),
458
- target: "_blank",
459
- rel: "noopener noreferrer",
460
- className: "flex items-center gap-2",
461
- children: [
462
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 text-muted-foreground" }),
463
- label
464
- ]
465
- }
466
- ) }, label)) })
467
- ] }),
468
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
469
- /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Manage" }),
470
- managementItems.map(({ label, icon: Icon, soon }) => {
471
- const duplicateInFlight = duplicateFlow.isDuplicating;
472
- const isLoading = label === "Convert to Template" && isConverting || label === "Duplicate" && duplicateInFlight;
473
- const displayLabel = label === "Convert to Template" && isConverting ? "Saving..." : label === "Duplicate" && duplicateInFlight ? "Duplicating..." : label;
474
- return /* @__PURE__ */ jsxs(
475
- DropdownMenuItem,
476
- {
477
- disabled: isLoading,
478
- onClick: () => handleDesktopItemClick(label),
479
- className: cn(soon && "text-muted-foreground"),
480
- children: [
481
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
482
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: displayLabel }),
483
- soon && /* @__PURE__ */ jsx(SoonBadge, {})
484
- ]
485
- },
486
- label
487
- );
488
- }),
489
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
490
- /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Agents" }),
491
- GLOBAL_AGENT_ITEMS.map(({ label, icon: Icon, soon }) => /* @__PURE__ */ jsxs(
492
- DropdownMenuItem,
493
- {
494
- onClick: () => handleDesktopItemClick(label),
495
- className: cn(soon && "text-muted-foreground"),
496
- children: [
497
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
498
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: label }),
499
- soon && /* @__PURE__ */ jsx(SoonBadge, {})
500
- ]
501
- },
502
- label
503
- )),
504
- adminItems.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
505
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
506
- /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Admin" }),
507
- adminItems.map(({ label, icon: Icon }) => /* @__PURE__ */ jsxs(
508
- DropdownMenuItem,
509
- {
510
- onClick: () => handleDesktopItemClick(label),
511
- children: [
512
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
513
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: label })
514
- ]
515
- },
516
- label
517
- ))
518
- ] }),
519
- lifecycle.available && /* @__PURE__ */ jsxs(Fragment, { children: [
520
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
521
- /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Manage" }),
522
- /* @__PURE__ */ jsxs(
523
- DropdownMenuItem,
524
- {
525
- disabled: lifecycle.isBusy,
526
- onClick: () => {
527
- setOpen(false);
528
- void lifecycle.toggleArchived();
529
- },
530
- children: [
531
- lifecycle.isArchived ? /* @__PURE__ */ jsx(ArchiveRestore, { className: "w-4 h-4 mr-2 text-muted-foreground" }) : /* @__PURE__ */ jsx(Archive, { className: "w-4 h-4 mr-2 text-muted-foreground" }),
532
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: lifecycle.archiveLabel })
533
- ]
534
- }
535
- ),
536
- /* @__PURE__ */ jsxs(
537
- DropdownMenuItem,
538
- {
539
- disabled: lifecycle.isBusy,
540
- onClick: () => {
541
- setOpen(false);
542
- void lifecycle.remove();
543
- },
544
- className: "text-destructive focus:text-destructive",
545
- children: [
546
- /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4 mr-2" }),
547
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: "Delete" })
548
- ]
549
- }
550
- )
551
- ] })
552
- ] })
553
- ] }),
554
- duplicateDialog
555
- ] });
556
- }
557
- function MobileMenuContent({
558
- onClose,
559
- agentId,
560
- basePath,
561
- onTriggerDuplicate,
562
- onTriggerRefreshCache,
563
- isRefreshingCache
564
- }) {
565
- const [variationsOpen, setVariationsOpen] = useState(false);
566
- const [isBusy, setIsBusy] = useState(false);
567
- const openSettings = useOpenAgentSettingsWindow();
568
- const openRunHistory = useOpenAgentRunHistoryWindow();
569
- const openAdvancedEditor = useOpenAgentContentWindow();
570
- const openRun = useOpenAgentRunWindow();
571
- const openOptimizer = useOpenAgentOptimizerWindow();
572
- const openFindUsages = useOpenAgentFindUsagesWindow();
573
- const openCreateApp = useOpenAgentCreateAppWindow();
574
- const openDataStorage = useOpenAgentDataStorageWindow();
575
- const openConvertSystem = useOpenAgentConvertSystemWindow();
576
- const openShortcut = useOpenAgentShortcutQuickCreateWindow();
577
- const openSaveTemplate = useOpenSaveTemplateDialog();
578
- const openAdminFindUsages = useOpenAgentAdminFindUsagesWindow();
579
- const openImport = useOpenAgentImportWindow();
580
- const openInterfaceVariations = useOpenAgentInterfaceVariationsWindow();
581
- const agent = useAppSelector((state) => selectAgentById(state, agentId));
582
- const isBuiltin = agent?.agentType === "builtin";
583
- const hasBuilderDoor = getBuilderDoor() !== null;
584
- const managementItems = AGENT_MANAGEMENT_ITEMS.filter(
585
- (item) => (!isBuiltin || item.label !== "Convert to Template") && (hasBuilderDoor || item.label !== "Duplicate")
586
- );
587
- const isSuperAdmin = useAppSelector(selectIsSuperAdmin);
588
- const lifecycle = useAgentLifecycleActions(agentId, basePath);
589
- const selectedOrganizationId = useAppSelector(selectOrganizationId);
590
- const adminItems = isSuperAdmin ? ADMIN_ITEMS : [];
591
- const handleItem = async (label) => {
592
- if (label === "Edit Agent Info") {
593
- openSettings({ initialAgentId: agentId });
594
- onClose();
595
- } else if (label === "View Run History") {
596
- openRunHistory({
597
- agentId: agentId ?? null,
598
- initialSelectedConversationId: null
599
- });
600
- onClose();
601
- } else if (label === "Advanced Settings View") {
602
- openAdvancedEditor({
603
- initialAgentId: agentId ?? null,
604
- initialTab: void 0,
605
- tabs: null
606
- });
607
- onClose();
608
- } else if (label === "Open Run Modal") {
609
- openRun({
610
- initialAgentId: agentId ?? null,
611
- initialSelectedConversationId: null
612
- });
613
- onClose();
614
- } else if (label === "Matrx Agent Optimizer") {
615
- openOptimizer({ agentId: agentId ?? null });
616
- onClose();
617
- } else if (label === "Find Usages") {
618
- openFindUsages({ agentId: agentId ?? null });
619
- onClose();
620
- } else if (label === "Create App") {
621
- openCreateApp();
622
- onClose();
623
- } else if (label === "Add Data Storage Support") {
624
- openDataStorage({ agentId: agentId ?? null });
625
- onClose();
626
- } else if (label === "Linked Agent Sync") {
627
- openConvertSystem({ agentId: agentId ?? null });
628
- onClose();
629
- } else if (label === SAVE_AS_TEMPLATE_LABEL) {
630
- openSaveTemplate({ initialAgentId: agentId ?? null });
631
- onClose();
632
- } else if (label === "Create Shortcut") {
633
- openShortcut({ agentId: agentId ?? null });
634
- onClose();
635
- } else if (label === "Find Usages (Admin)") {
636
- openAdminFindUsages({ agentId: agentId ?? null });
637
- onClose();
638
- } else if (label === "Import Agent") {
639
- openImport({});
640
- onClose();
641
- } else if (label === "Duplicate") {
642
- onClose();
643
- void onTriggerDuplicate();
644
- } else if (label === "Refresh Server Cache") {
645
- onClose();
646
- void onTriggerRefreshCache();
647
- } else if (label === "Convert to Template") {
648
- if (!selectedOrganizationId) {
649
- toast.error(
650
- "Select an organization from the avatar menu, then try again."
651
- );
652
- return;
653
- }
654
- setIsBusy(true);
655
- try {
656
- await convertToTemplate(agentId, selectedOrganizationId);
657
- } catch (err) {
658
- toast.error(
659
- err instanceof Error ? err.message : "Failed to save as template"
660
- );
661
- } finally {
662
- setIsBusy(false);
663
- onClose();
664
- }
665
- } else {
666
- comingSoon();
667
- onClose();
668
- }
669
- };
670
- const handleVariationClick = () => {
671
- openInterfaceVariations({ agentId: agentId ?? null });
672
- onClose();
673
- };
674
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-y-auto max-h-[calc(85dvh-2rem)] pb-safe", children: [
675
- /* @__PURE__ */ jsxs("div", { className: "py-1", children: [
676
- THIS_AGENT_ITEMS.map(({ label, icon: Icon, soon }) => {
677
- if (label === "View All Versions" || label === "Drift Report") {
678
- const href = label === "Drift Report" ? "/reports/agent-drift" : `${basePath}/${agentId}/latest?tab=history`;
679
- return /* @__PURE__ */ jsxs(
680
- Link,
681
- {
682
- href,
683
- onClick: onClose,
684
- className: "flex items-center gap-3 w-full px-4 py-2.5 text-sm text-foreground hover:bg-muted/50 active:bg-muted/70 transition-colors",
685
- children: [
686
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 text-muted-foreground shrink-0" }),
687
- /* @__PURE__ */ jsx("span", { className: "flex-1 text-left", children: label })
688
- ]
689
- },
690
- label
691
- );
692
- }
693
- return /* @__PURE__ */ jsx(
694
- Tile,
695
- {
696
- variant: "quiet",
697
- onClick: () => handleItem(label),
698
- disabled: label === "Refresh Server Cache" && isRefreshingCache,
699
- icon: /* @__PURE__ */ jsx(Icon, {}),
700
- title: label === "Refresh Server Cache" && isRefreshingCache ? "Refreshing..." : label,
701
- end: soon ? /* @__PURE__ */ jsx(SoonBadge, {}) : void 0
702
- },
703
- label
704
- );
705
- }),
706
- /* @__PURE__ */ jsx(Tile, { variant: "quiet", icon: /* @__PURE__ */ jsx(Layers, {}), title: "Try Interface Variations", end: /* @__PURE__ */ jsx(ChevronRight, {}), onClick: () => setVariationsOpen(!variationsOpen) }),
707
- variationsOpen && /* @__PURE__ */ jsx("div", { className: "pl-6 bg-muted/20", children: INTERFACE_VARIATIONS.map((v) => /* @__PURE__ */ jsx(Button, { variant: "quiet", onClick: handleVariationClick, className: "w-full", children: v }, v)) })
708
- ] }),
709
- /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
710
- /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Open in New Tab" }) }),
711
- /* @__PURE__ */ jsx("div", { className: "py-1", children: NEW_TAB_ITEMS.map(({ label, icon: Icon, getHref }) => /* @__PURE__ */ jsxs(
712
- Link,
713
- {
714
- href: getHref(agentId, basePath),
715
- target: "_blank",
716
- rel: "noopener noreferrer",
717
- onClick: onClose,
718
- className: "flex items-center gap-3 w-full px-4 py-2.5 text-sm text-foreground hover:bg-muted/50 active:bg-muted/70 transition-colors",
719
- children: [
720
- /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 text-muted-foreground shrink-0" }),
721
- label
722
- ]
723
- },
724
- label
725
- )) }),
726
- /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
727
- /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Manage" }) }),
728
- /* @__PURE__ */ jsx("div", { className: "py-1", children: managementItems.map(({ label, icon: Icon, soon }) => /* @__PURE__ */ jsx(
729
- Tile,
730
- {
731
- variant: "quiet",
732
- onClick: () => handleItem(label),
733
- disabled: isBusy && label === "Convert to Template",
734
- icon: /* @__PURE__ */ jsx(Icon, {}),
735
- title: label,
736
- end: soon ? /* @__PURE__ */ jsx(SoonBadge, {}) : void 0
737
- },
738
- label
739
- )) }),
740
- /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
741
- /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Agents" }) }),
742
- /* @__PURE__ */ jsx("div", { className: "py-1", children: GLOBAL_AGENT_ITEMS.map(({ label, icon: Icon, soon }) => /* @__PURE__ */ jsx(
743
- Tile,
744
- {
745
- variant: "quiet",
746
- onClick: () => handleItem(label),
747
- icon: /* @__PURE__ */ jsx(Icon, {}),
748
- title: label,
749
- end: soon ? /* @__PURE__ */ jsx(SoonBadge, {}) : void 0
750
- },
751
- label
752
- )) }),
753
- adminItems.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
754
- /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
755
- /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Admin" }) }),
756
- /* @__PURE__ */ jsx("div", { className: "py-1", children: adminItems.map(({ label, icon: Icon }) => /* @__PURE__ */ jsx(Tile, { variant: "quiet", icon: /* @__PURE__ */ jsx(Icon, {}), title: label, onClick: () => handleItem(label) }, label)) })
757
- ] }),
758
- lifecycle.available && /* @__PURE__ */ jsxs(Fragment, { children: [
759
- /* @__PURE__ */ jsx("div", { className: "h-px bg-border mx-3 my-1" }),
760
- /* @__PURE__ */ jsx("div", { className: "px-4 py-1.5", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider text-muted-foreground/60 font-semibold", children: "Manage" }) }),
761
- /* @__PURE__ */ jsxs("div", { className: "py-1", children: [
762
- /* @__PURE__ */ jsx(Tile, { variant: "quiet", icon: lifecycle.isArchived ? /* @__PURE__ */ jsx(ArchiveRestore, {}) : /* @__PURE__ */ jsx(Archive, {}), title: lifecycle.archiveLabel, disabled: lifecycle.isBusy, onClick: () => {
763
- onClose();
764
- void lifecycle.toggleArchived();
765
- } }),
766
- /* @__PURE__ */ jsx(Button, { variant: "quiet", icon: /* @__PURE__ */ jsx(Trash2, {}), disabled: lifecycle.isBusy, onClick: () => {
767
- onClose();
768
- void lifecycle.remove();
769
- }, className: "w-full", children: /* @__PURE__ */ jsx("span", { className: "flex-1 text-left", children: "Delete" }) })
770
- ] })
771
- ] })
772
- ] });
773
- }
774
- export {
775
- AgentOptionsMenu
776
- };