@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,134 +0,0 @@
1
- "use client";
2
- import { useEffect, useCallback } from "react";
3
- import { keyEventInside } from "@ai-matrx/kit/keyboard-scope";
4
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
5
- import {
6
- undoAgentEdit,
7
- redoAgentEdit
8
- } from "../redux/agent-definition/slice.js";
9
- import {
10
- selectAgentCanUndo,
11
- selectAgentCanRedo
12
- } from "../redux/agent-definition/selectors.js";
13
- let _cachedPlatform = null;
14
- function getPlatform() {
15
- if (_cachedPlatform) return _cachedPlatform;
16
- if (typeof navigator === "undefined") return "unknown";
17
- const ua = navigator.userAgent.toLowerCase();
18
- if (/iphone|ipad|ipod/.test(ua)) {
19
- _cachedPlatform = "ios";
20
- } else if (/android/.test(ua)) {
21
- _cachedPlatform = "android";
22
- } else if (/mac/.test(ua)) {
23
- _cachedPlatform = "mac";
24
- } else if (/win/.test(ua)) {
25
- _cachedPlatform = "windows";
26
- } else if (/linux/.test(ua)) {
27
- _cachedPlatform = "linux";
28
- } else {
29
- _cachedPlatform = "unknown";
30
- }
31
- return _cachedPlatform;
32
- }
33
- function isMacLike() {
34
- const p = getPlatform();
35
- return p === "mac" || p === "ios";
36
- }
37
- function isTouchDevice() {
38
- const p = getPlatform();
39
- return p === "ios" || p === "android";
40
- }
41
- function getUndoShortcutHint() {
42
- const p = getPlatform();
43
- switch (p) {
44
- case "mac":
45
- return "\u2318Z";
46
- case "ios":
47
- return "Shake to Undo";
48
- case "android":
49
- return "Ctrl+Z";
50
- case "windows":
51
- return "Ctrl+Z";
52
- case "linux":
53
- return "Ctrl+Z";
54
- default:
55
- return "Ctrl+Z";
56
- }
57
- }
58
- function getRedoShortcutHint() {
59
- const p = getPlatform();
60
- switch (p) {
61
- case "mac":
62
- return "\u21E7\u2318Z";
63
- case "ios":
64
- return "Shake to Redo";
65
- case "android":
66
- return "Ctrl+Shift+Z";
67
- case "windows":
68
- return "Ctrl+Y";
69
- case "linux":
70
- return "Ctrl+Shift+Z";
71
- default:
72
- return "Ctrl+Shift+Z";
73
- }
74
- }
75
- function useAgentUndoRedo({
76
- agentId,
77
- scope,
78
- enabled = true
79
- }) {
80
- const dispatch = useAppDispatch();
81
- const canUndo = useAppSelector(
82
- (state) => agentId ? selectAgentCanUndo(state, agentId) : false
83
- );
84
- const canRedo = useAppSelector(
85
- (state) => agentId ? selectAgentCanRedo(state, agentId) : false
86
- );
87
- const undo = useCallback(() => {
88
- if (agentId && canUndo) dispatch(undoAgentEdit({ id: agentId }));
89
- }, [dispatch, agentId, canUndo]);
90
- const redo = useCallback(() => {
91
- if (agentId && canRedo) dispatch(redoAgentEdit({ id: agentId }));
92
- }, [dispatch, agentId, canRedo]);
93
- useEffect(() => {
94
- if (!enabled || !agentId) return void 0;
95
- function handleKeyDown(e) {
96
- const mod = isMacLike() ? e.metaKey : e.ctrlKey;
97
- if (!mod) return;
98
- if (!keyEventInside(e, scope())) return;
99
- if (e.key === "z" || e.key === "Z") {
100
- if (e.shiftKey) {
101
- e.preventDefault();
102
- if (canRedo) dispatch(redoAgentEdit({ id: agentId }));
103
- } else {
104
- e.preventDefault();
105
- if (canUndo) dispatch(undoAgentEdit({ id: agentId }));
106
- }
107
- return;
108
- }
109
- if ((e.key === "y" || e.key === "Y") && !isMacLike()) {
110
- e.preventDefault();
111
- if (canRedo) dispatch(redoAgentEdit({ id: agentId }));
112
- }
113
- }
114
- document.addEventListener("keydown", handleKeyDown, true);
115
- return () => document.removeEventListener("keydown", handleKeyDown, true);
116
- }, [enabled, agentId, canUndo, canRedo, dispatch, scope]);
117
- return {
118
- canUndo,
119
- canRedo,
120
- undo,
121
- redo,
122
- undoHint: getUndoShortcutHint(),
123
- redoHint: getRedoShortcutHint(),
124
- platform: getPlatform()
125
- };
126
- }
127
- export {
128
- getPlatform,
129
- getRedoShortcutHint,
130
- getUndoShortcutHint,
131
- isMacLike,
132
- isTouchDevice,
133
- useAgentUndoRedo
134
- };
@@ -1,17 +0,0 @@
1
- /**
2
- * useAgentUsages — dispatch-on-idle hook for one agent's find-usages scan.
3
- * Every consumer (user window, admin window, report detail pane) reads through
4
- * this hook so no component fetches ad hoc.
5
- */
6
- import type { UsageScope } from "../../ui/usages/usages.slice.js";
7
- export declare function useAgentUsages(agentId: string | null, scope: UsageScope): {
8
- readonly status: import("../../ui/usages/usages.types.js").UsagesLoadStatus;
9
- readonly error: string | null;
10
- readonly groups: {
11
- usageType: string;
12
- items: import("../../ui/usages/usages.types.js").AgentUsageRow[];
13
- }[];
14
- readonly aggregates: import("../../ui/usages/usages.types.js").AgentUsageAggregate[];
15
- readonly summary: import("../../host/ui-slots.js").RedFlagSummary;
16
- readonly refresh: () => void;
17
- };
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { useEffect, useCallback } from "react";
3
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
4
- import { fetchAgentUsages } from "../../host/ui-slots.js";
5
- import { makeSelectUsageCache, makeSelectUsageGroups, makeSelectUsageAggregates, makeSelectRedFlagSummary } from "../../host/ui-slots.js";
6
- import { useMemo } from "react";
7
- function useAgentUsages(agentId, scope) {
8
- const dispatch = useAppDispatch();
9
- const id = agentId ?? "";
10
- const selectCache = useMemo(() => makeSelectUsageCache(scope, id), [scope, id]);
11
- const selectGroups = useMemo(() => makeSelectUsageGroups(scope, id), [scope, id]);
12
- const selectAggregates = useMemo(() => makeSelectUsageAggregates(scope, id), [scope, id]);
13
- const selectSummary = useMemo(() => makeSelectRedFlagSummary(scope, id), [scope, id]);
14
- const cache = useAppSelector(selectCache);
15
- const groups = useAppSelector(selectGroups);
16
- const aggregates = useAppSelector(selectAggregates);
17
- const summary = useAppSelector(selectSummary);
18
- useEffect(() => {
19
- if (!agentId) return;
20
- dispatch(fetchAgentUsages({ agentId, scope }));
21
- }, [dispatch, agentId, scope]);
22
- const refresh = useCallback(() => {
23
- if (agentId) dispatch(fetchAgentUsages({ agentId, scope, force: true }));
24
- }, [dispatch, agentId, scope]);
25
- return {
26
- status: cache?.status ?? "idle",
27
- error: cache?.error ?? null,
28
- groups,
29
- aggregates,
30
- summary,
31
- refresh
32
- };
33
- }
34
- export {
35
- useAgentUsages
36
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * useDriftAlerts — dispatch-on-idle hook for the caller's open drift alerts,
3
- * powering the agents-page header drift indicator. Exposes dismiss + view-stamp actions.
4
- */
5
- import type { DriftAlertRow } from "../../ui/usages/usages.types.js";
6
- export declare function useDriftAlerts(): {
7
- readonly alerts: DriftAlertRow[];
8
- readonly status: import("../../ui/usages/usages.types.js").UsagesLoadStatus;
9
- readonly dismiss: (alert: DriftAlertRow) => void;
10
- readonly markViewed: (alertId: string) => void;
11
- };
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { useEffect, useCallback } from "react";
3
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
4
- import { dismissDriftAlert, fetchDriftAlerts, markDriftAlertViewed } from "../../host/ui-slots.js";
5
- import { selectActiveBannerAlerts, selectDriftAlertsStatus } from "../../host/ui-slots.js";
6
- import { selectAccessToken, selectAuthReady, selectUserId } from "../../host/identity.js";
7
- function useDriftAlerts() {
8
- const dispatch = useAppDispatch();
9
- const alerts = useAppSelector(selectActiveBannerAlerts);
10
- const status = useAppSelector(selectDriftAlertsStatus);
11
- const authReady = useAppSelector(selectAuthReady);
12
- const userId = useAppSelector(selectUserId);
13
- const accessToken = useAppSelector(selectAccessToken);
14
- useEffect(() => {
15
- if (authReady && userId && accessToken) {
16
- dispatch(fetchDriftAlerts());
17
- }
18
- }, [dispatch, authReady, userId, accessToken]);
19
- const dismiss = useCallback(
20
- (alert) => {
21
- const prev = alert.status === "acknowledged" ? "acknowledged" : "pending";
22
- dispatch(dismissDriftAlert({ alertId: alert.id, previousStatus: prev }));
23
- },
24
- [dispatch]
25
- );
26
- const markViewed = useCallback(
27
- (alertId) => {
28
- dispatch(markDriftAlertViewed(alertId));
29
- },
30
- [dispatch]
31
- );
32
- return { alerts, status, dismiss, markViewed };
33
- }
34
- export {
35
- useDriftAlerts
36
- };
@@ -1,20 +0,0 @@
1
- /**
2
- * useDriftReport — dispatch-on-idle hook for the drift report rollup.
3
- */
4
- import type { ReportSortKey } from "../../ui/usages/usages.types.js";
5
- import type { UsageScope } from "../../ui/usages/usages.slice.js";
6
- export declare function useDriftReport(scope: UsageScope, sort?: {
7
- key: ReportSortKey;
8
- desc: boolean;
9
- }): {
10
- readonly status: import("../../ui/usages/usages.types.js").UsagesLoadStatus;
11
- readonly error: string | null;
12
- readonly rows: import("../../ui/usages/usages.types.js").AgentDriftReportRow[];
13
- readonly adminRows: import("../../ui/usages/usages.types.js").AgentDriftReportAdminRow[];
14
- readonly totals: {
15
- totals: Record<import("../../ui/usages/usages.types.js").DriftSeverity, number>;
16
- agents: number;
17
- order: import("../../ui/usages/usages.types.js").DriftSeverity[];
18
- };
19
- readonly refresh: () => void;
20
- };
@@ -1,34 +0,0 @@
1
- "use client";
2
- import { useEffect, useCallback, useMemo } from "react";
3
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
4
- import { fetchAgentUsageReport } from "../../host/ui-slots.js";
5
- import { makeSelectReport, makeSelectReportSorted, makeSelectReportTotals } from "../../host/ui-slots.js";
6
- function useDriftReport(scope, sort = { key: "breaking", desc: true }) {
7
- const dispatch = useAppDispatch();
8
- const selectEntry = useMemo(() => makeSelectReport(scope), [scope]);
9
- const selectSorted = useMemo(
10
- () => makeSelectReportSorted(scope, sort.key, sort.desc),
11
- [scope, sort.key, sort.desc]
12
- );
13
- const selectTotals = useMemo(() => makeSelectReportTotals(scope), [scope]);
14
- const entry = useAppSelector(selectEntry);
15
- const sorted = useAppSelector(selectSorted);
16
- const totals = useAppSelector(selectTotals);
17
- useEffect(() => {
18
- dispatch(fetchAgentUsageReport({ scope }));
19
- }, [dispatch, scope]);
20
- const refresh = useCallback(() => {
21
- dispatch(fetchAgentUsageReport({ scope, force: true }));
22
- }, [dispatch, scope]);
23
- return {
24
- status: entry.status,
25
- error: entry.error,
26
- rows: sorted.rows,
27
- adminRows: sorted.adminRows,
28
- totals,
29
- refresh
30
- };
31
- }
32
- export {
33
- useDriftReport
34
- };
@@ -1,17 +0,0 @@
1
- export interface AgentLifecycleActions {
2
- /** Whether the agent is archived right now (false while it is still loading). */
3
- isArchived: boolean;
4
- /** "Archive" or "Unarchive" — the label for the control, never a guess. */
5
- archiveLabel: string;
6
- /** Flip the archive flag. Resolves when the write has landed or failed loudly. */
7
- toggleArchived: () => Promise<void>;
8
- /** Confirm, soft-delete, then leave the agent's own page. */
9
- remove: () => Promise<void>;
10
- /** True while either write is in flight, so a menu can disable both. */
11
- isBusy: boolean;
12
- /** False in a host that registered no builder door: the menu leaves archive and delete out (reported once). */
13
- available: boolean;
14
- }
15
- export declare function useAgentLifecycleActions(agentId: string,
16
- /** Where to land after a delete — the agent's page no longer has a subject. */
17
- basePath?: string): AgentLifecycleActions;
@@ -1,63 +0,0 @@
1
- "use client";
2
- import { useCallback, useState } from "react";
3
- import { useRouter } from "../../host/navigation.js";
4
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
5
- import { getBuilderDoor, requireBuilderDoor } from "../../host/builder-door.js";
6
- import { selectAgentById } from "../redux/agent-definition/selectors.js";
7
- import { confirm } from "../../host/ui-slots.js";
8
- import { buildAgentDeleteConfirm } from "../../ui/agentDeleteConfirm.js";
9
- import { toast } from "../../host/notify.js";
10
- function useAgentLifecycleActions(agentId, basePath = "/agents") {
11
- const dispatch = useAppDispatch();
12
- const router = useRouter();
13
- const agent = useAppSelector((state) => selectAgentById(state, agentId));
14
- const [isBusy, setIsBusy] = useState(false);
15
- const available = getBuilderDoor() !== null;
16
- const isArchived = Boolean(agent?.isArchived);
17
- const name = agent?.name ?? "";
18
- const toggleArchived = useCallback(async () => {
19
- setIsBusy(true);
20
- try {
21
- await dispatch(
22
- requireBuilderDoor().saveAgentField({ agentId, field: "isArchived", value: !isArchived })
23
- ).unwrap();
24
- toast.success(
25
- isArchived ? `"${name || "Agent"}" is back in your lists` : `"${name || "Agent"}" archived \u2014 it stays in your archive and can be restored`
26
- );
27
- } catch (err) {
28
- toast.error(
29
- isArchived ? "Could not unarchive this agent" : "Could not archive this agent",
30
- { description: err instanceof Error ? err.message : void 0 }
31
- );
32
- } finally {
33
- setIsBusy(false);
34
- }
35
- }, [agentId, dispatch, isArchived, name]);
36
- const remove = useCallback(async () => {
37
- const ok = await confirm(buildAgentDeleteConfirm(name));
38
- if (!ok) return;
39
- setIsBusy(true);
40
- try {
41
- await dispatch(requireBuilderDoor().deleteAgent(agentId)).unwrap();
42
- toast.success(name ? `Deleted "${name}"` : "Agent deleted");
43
- router.push(basePath);
44
- } catch (err) {
45
- toast.error("Could not delete agent", {
46
- description: err instanceof Error ? err.message : void 0
47
- });
48
- } finally {
49
- setIsBusy(false);
50
- }
51
- }, [agentId, basePath, dispatch, name, router]);
52
- return {
53
- isArchived,
54
- archiveLabel: isArchived ? "Unarchive" : "Archive",
55
- toggleArchived,
56
- remove,
57
- isBusy,
58
- available
59
- };
60
- }
61
- export {
62
- useAgentLifecycleActions
63
- };
@@ -1,8 +0,0 @@
1
- import { type MessageFlagKey, type MessageFlags } from "./flags.js";
2
- import type { FlagToggleState } from "./MessageFlagToggles.js";
3
- export interface MessageFlagsController {
4
- flags: MessageFlags;
5
- states: Partial<Record<MessageFlagKey, FlagToggleState>>;
6
- onToggle: (flag: MessageFlagKey) => void;
7
- }
8
- export declare function useMessageFlags(agentId: string, messageIndex: number): MessageFlagsController;
@@ -1,68 +0,0 @@
1
- "use client";
2
- import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
3
- import {
4
- selectAgentMessages,
5
- selectAgentModelId,
6
- selectAgentOfferingPin
7
- } from "../redux/agent-definition/selectors.js";
8
- import { setAgentMessages } from "../redux/agent-definition/slice.js";
9
- import { useModelFull } from "../../host/ui-slots.js";
10
- import { useSessionKnob } from "../../host/prefs-react.js";
11
- import {
12
- FLAG_COMPATIBILITY_KNOB,
13
- cacheBoundaryVerdict,
14
- flagPlacementProblem,
15
- flagsOf,
16
- prefillVerdict,
17
- resolveFlagCompatibilityMode,
18
- toggleMessageFlag
19
- } from "./flags.js";
20
- import { useMessageFlagProfile } from "./useMessageFlagProfile.js";
21
- function useMessageFlags(agentId, messageIndex) {
22
- const dispatch = useAppDispatch();
23
- const messages = useAppSelector((state) => selectAgentMessages(state, agentId));
24
- const modelId = useAppSelector((state) => selectAgentModelId(state, agentId));
25
- const model = useModelFull(modelId);
26
- const offeringPin = useAppSelector((state) => selectAgentOfferingPin(state, agentId));
27
- const profile = useMessageFlagProfile(modelId, offeringPin);
28
- const mode = resolveFlagCompatibilityMode(useSessionKnob(FLAG_COMPATIBILITY_KNOB));
29
- const list = messages ?? [];
30
- const message = list[messageIndex];
31
- const flags = flagsOf(message);
32
- const role = message?.role;
33
- const isLast = messageIndex === list.length - 1;
34
- const states = {
35
- cache_boundary: {
36
- verdict: cacheBoundaryVerdict(model, profile),
37
- placementProblem: flags.cache_boundary ? flagPlacementProblem(list, messageIndex, "cache_boundary") : null
38
- },
39
- example: {
40
- hidden: role !== "user" && role !== "assistant",
41
- verdict: {
42
- verdict: "native",
43
- reason: "Sent as an ordinary turn; the paired user and assistant messages toggle together."
44
- },
45
- placementProblem: flags.example ? flagPlacementProblem(list, messageIndex, "example") : null
46
- },
47
- prefill: {
48
- // Absent unless it can be lawful here — or it is set and now misplaced,
49
- // so the author can see why and switch it off.
50
- hidden: !flags.prefill && !(role === "assistant" && isLast),
51
- verdict: prefillVerdict(model, mode),
52
- placementProblem: flags.prefill ? flagPlacementProblem(list, messageIndex, "prefill") : null
53
- }
54
- };
55
- const onToggle = (flag) => {
56
- if (!messages) return;
57
- dispatch(
58
- setAgentMessages({
59
- id: agentId,
60
- messages: toggleMessageFlag(messages, messageIndex, flag)
61
- })
62
- );
63
- };
64
- return { flags, states, onToggle };
65
- }
66
- export {
67
- useMessageFlags
68
- };
@@ -1,15 +0,0 @@
1
- import type { AgentDefinition } from "../types/agent-definition.types.js";
2
- /**
3
- * Read the currently saved agent definition without hydrating Redux.
4
- *
5
- * Comparison and review surfaces must use this instead of `fetchFullAgent`:
6
- * that builder thunk intentionally marks its Redux record clean and clears
7
- * undo history, which would destroy unrelated unsaved edits in another view.
8
- *
9
- * Failures never carry database text to a person (features/access-gate THE
10
- * LAW): zero rows throws `recordUnavailable` with the `agent` token, so a
11
- * surface can render `<AccessGate token id/>` and ASK which of deleted /
12
- * missing / no access / signed out it really is; a real fault throws
13
- * `operationFailed` with the raw response as `cause` for the inspector.
14
- */
15
- export declare function fetchSavedAgentDefinition(agentId: string): Promise<AgentDefinition>;
@@ -1,20 +0,0 @@
1
- import { dbRowToAgentDefinition } from "../redux/agent-definition/converters.js";
2
- import { supabase } from "../../host/db.js";
3
- import { recordUnavailable } from "../../host/diagnostics.js";
4
- import { operationFailed } from "@ai-matrx/kit/errors";
5
- async function fetchSavedAgentDefinition(agentId) {
6
- const { data, error } = await supabase.schema("agent").from("definition").select("*").eq("id", agentId).maybeSingle();
7
- if (error) throw operationFailed("load this agent", error);
8
- if (!data)
9
- throw recordUnavailable({
10
- entity: "agent",
11
- reason: "unknown",
12
- recordId: agentId,
13
- token: "agent",
14
- relation: "agent.definition"
15
- });
16
- return dbRowToAgentDefinition(data);
17
- }
18
- export {
19
- fetchSavedAgentDefinition
20
- };
@@ -1,96 +0,0 @@
1
- /**
2
- * features/agents/surface-catalog-profile.ts
3
- *
4
- * The ONE definition of the composite "agent catalog profile" write contract —
5
- * `{description?, category?, tags?}` — shared by every surface that lets an
6
- * agent rewrite how ANOTHER agent is described and filed.
7
- *
8
- * WHY THIS FILE EXISTS. Two surfaces edit the same three columns on the same
9
- * `agent.definition` row from two different windows:
10
- *
11
- * - `matrx-user/agent-advanced-editor` — the floating Agent Advanced Editor
12
- * (`AgentContentWindow`), which shipped this contract first as
13
- * `editor_catalog_profile`.
14
- * - `matrx-user/agent-settings` — the floating Agent Settings window
15
- * (`AgentSettingsWindow` → `AgentSettingsForm`), as
16
- * `settings_catalog_profile`.
17
- *
18
- * Two target definitions over the same fields is a defect, not a coincidence:
19
- * the campaign's own precedent is `matrx-user/pick-lists` / `matrx-user/pick-list-manager`,
20
- * whose shared targets were lifted into `features/data-tables/pick-lists/`. So the CONTRACT
21
- * — the accepted keys, the per-field bounds, the replace-vs-patch semantics,
22
- * and the model-facing prose that states them — is defined exactly once, here.
23
- *
24
- * WHAT IS **NOT** SHARED, AND WHY. The lists precedent shares the target NAME
25
- * and the HANDLER as well. This one deliberately cannot, for two structural
26
- * reasons that do not apply there:
27
- *
28
- * 1. **The two mounts have different draft containers.** The advanced editor
29
- * stages into the `agent-definition` Redux slice (`setAgentField`) and
30
- * commits on its own footer Save. `AgentSettingsForm` stages into REACT
31
- * COMPONENT STATE (`draft` / `tagsInput` `useState`) and commits by
32
- * dispatching `saveAgentField` per changed field. There is no one handler
33
- * that serves both — one dispatches an action, the other calls a setState.
34
- * `ListDetailClient`, by contrast, is literally the same component driving
35
- * the same server actions from both of its mounts.
36
- * 2. **A shared NAME would land the write in the wrong window.** These are
37
- * both floating windows, they can be open at once — `AgentSettingsForm`'s
38
- * own Messages / Variables / Tools tiles OPEN the advanced editor — and
39
- * each has its own agent picker, so the agent open in one is frequently not
40
- * the agent open in the other. `applySurfaceWrite` resolves a bare target
41
- * name DEEPEST-FIRST across the mounted stack
42
- * (`features/surfaces/runtime/surface-writeback.ts`), so one shared name
43
- * would be captured by whichever window happened to be deeper and stage the
44
- * text into a record the user who pressed Apply cannot see. That is the
45
- * exact hazard `agent-advanced-editor` invented its `editor_` prefix for;
46
- * re-using its name here would re-open it.
47
- *
48
- * So: one contract, two names, two handlers. The names differ because they must;
49
- * everything a model is told and everything that is enforced comes from here, so
50
- * the two cannot drift.
51
- *
52
- * BOUNDS COME FROM `agent-identity-metadata.ts`, the canonical validators for
53
- * these columns (already used by `matrx-admin/system-agents`). This module adds
54
- * the composite envelope around them and nothing else — it does not re-type a
55
- * single bound, and the prose below interpolates the real constants so the
56
- * contract the model SEES is the contract that is ENFORCED.
57
- *
58
- * Deliberately React-free and Redux-free: surface manifests import it for the
59
- * description prose, and the manifest registry is loaded by
60
- * `scripts/check-surface-drift.ts` outside any React/Next runtime.
61
- */
62
- /** The patch a catalog-profile target produces. Every key is optional; at
63
- * least one is always present (an empty patch throws). */
64
- export interface AgentCatalogProfilePatch {
65
- description?: string;
66
- category?: string;
67
- tags?: string[];
68
- }
69
- /** The ONLY keys any catalog-profile target accepts. */
70
- export declare const AGENT_CATALOG_PROFILE_KEYS: readonly ["description", "category", "tags"];
71
- /**
72
- * Validate a catalog-profile value, WHOLE, before any of it is applied.
73
- *
74
- * Nothing here mutates page state: the caller dispatches only after this
75
- * returns, so a bad `tags` array can never leave a new description already
76
- * staged. One confirm, one all-or-nothing write.
77
- *
78
- * Unknown keys THROW and are named in the message rather than being dropped.
79
- * An agent reaching for `is_public` or `name` inside this object must hear a
80
- * refusal — silently ignoring it would let the model report a change it never
81
- * made.
82
- */
83
- export declare function parseAgentCatalogProfile(value: unknown, targetName: string): AgentCatalogProfilePatch;
84
- /**
85
- * The model-facing contract prose for a catalog-profile target.
86
- *
87
- * `tagsReadTwin` names the surface's own read value for the current tag set,
88
- * because `tags` is a FULL replacement and an agent that does not re-read first
89
- * will silently drop the tags it did not think to re-send. `landing` is the one
90
- * sentence that differs per surface: WHERE the staged value shows up and what
91
- * the user presses to commit it.
92
- */
93
- export declare function agentCatalogProfileTargetDescription(options: {
94
- tagsReadTwin: string;
95
- landing: string;
96
- }): string;
@@ -1,79 +0,0 @@
1
- import {
2
- AGENT_CATEGORY_MAX_CHARS,
3
- AGENT_DESCRIPTION_MAX_CHARS,
4
- AGENT_TAGS_MAX_COUNT,
5
- AGENT_TAG_MAX_CHARS,
6
- normalizeAgentCategory,
7
- normalizeAgentDescription,
8
- normalizeAgentTags
9
- } from "./constants/agent-identity-metadata.js";
10
- const AGENT_CATALOG_PROFILE_KEYS = [
11
- "description",
12
- "category",
13
- "tags"
14
- ];
15
- function isPlainObject(value) {
16
- return typeof value === "object" && value !== null && !Array.isArray(value);
17
- }
18
- function describe(value) {
19
- if (value === null) return "null";
20
- if (Array.isArray(value)) return "an array";
21
- return `a ${typeof value}`;
22
- }
23
- function rethrowAsProfileKey(error, targetName) {
24
- const message = error instanceof Error ? error.message : String(error);
25
- throw new Error(
26
- message.replace(/^agent_(description|category|tags)/, `${targetName}.$1`)
27
- );
28
- }
29
- function parseAgentCatalogProfile(value, targetName) {
30
- if (!isPlainObject(value)) {
31
- throw new Error(
32
- `${targetName} expects an OBJECT like {"description": "...", "category": "...", "tags": ["..."]} \u2014 received ${describe(value)}. Send structured JSON, not a JSON-encoded string, and not the description on its own.`
33
- );
34
- }
35
- const unknownKeys = Object.keys(value).filter(
36
- (key) => !AGENT_CATALOG_PROFILE_KEYS.includes(key)
37
- );
38
- if (unknownKeys.length > 0) {
39
- throw new Error(
40
- `${targetName} does not accept ${unknownKeys.map((key) => `"${key}"`).join(", ")}. The only accepted keys are description, category and tags. The agent's name, model, tools, web state and lifecycle flags are not writable from this surface.`
41
- );
42
- }
43
- const patch = {};
44
- if (value.description !== void 0) {
45
- try {
46
- patch.description = normalizeAgentDescription(value.description);
47
- } catch (error) {
48
- rethrowAsProfileKey(error, targetName);
49
- }
50
- }
51
- if (value.category !== void 0) {
52
- try {
53
- patch.category = normalizeAgentCategory(value.category);
54
- } catch (error) {
55
- rethrowAsProfileKey(error, targetName);
56
- }
57
- }
58
- if (value.tags !== void 0) {
59
- try {
60
- patch.tags = normalizeAgentTags(value.tags);
61
- } catch (error) {
62
- rethrowAsProfileKey(error, targetName);
63
- }
64
- }
65
- if (Object.keys(patch).length === 0) {
66
- throw new Error(
67
- `${targetName} needs at least one of description, category or tags. An empty object changes nothing.`
68
- );
69
- }
70
- return patch;
71
- }
72
- function agentCatalogProfileTargetDescription(options) {
73
- return `Updates how the agent is described and filed in the catalog, in ONE atomic write. Value: an OBJECT (structured JSON, never a JSON-encoded string) with at least one of {"description": "a few sentences of plain prose, no markdown headings, up to ${AGENT_DESCRIPTION_MAX_CHARS} characters", "category": "a single short free-text label on one line, up to ${AGENT_CATEGORY_MAX_CHARS} characters \u2014 reuse an existing category rather than inventing a near-duplicate", "tags": ["short", "free-text"]}. Keys you omit are left alone. \`tags\` is a FULL replacement of the tag set, so read the \`${options.tagsReadTwin}\` value first and include every tag you want kept (pass [] to clear them all); at most ${AGENT_TAGS_MAX_COUNT} tags, each up to ${AGENT_TAG_MAX_CHARS} characters, no duplicates and no commas inside a tag. Empty strings are rejected rather than treated as "clear this field" \u2014 blanking a description or a category stays a human edit. No other keys are accepted: the agent's name, model, tools, web state and lifecycle flags are not writable here. ` + options.landing;
74
- }
75
- export {
76
- AGENT_CATALOG_PROFILE_KEYS,
77
- agentCatalogProfileTargetDescription,
78
- parseAgentCatalogProfile
79
- };
@@ -1 +0,0 @@
1
- export declare function useAgentBootstrap(): void;