@ai-matrx/chat 0.4.2 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/agent-copy/RichCopySplit.d.ts +17 -0
- package/dist/agent-copy/RichCopySplit.js +34 -0
- package/dist/agents/components/agent-widgets/chat-assistant/AssistantMessageCard.js +1 -1
- package/dist/agents/components/chat/ConversationRecordsChip.js +1 -1
- package/dist/agents/components/context-items/bodies/WorkingDocumentBody.d.ts +5 -2
- package/dist/agents/components/context-items/bodies/WorkingDocumentBody.js +6 -1
- package/dist/agents/components/context-policies-display/ContextValueBody.js +1 -1
- package/dist/agents/components/context-preview/ContextCompareView.js +1 -1
- package/dist/agents/components/custom-agent/CustomAgentWindow.js +1 -1
- package/dist/agents/components/inputs/smart-input/AgentTextarea.d.ts +6 -1
- package/dist/agents/components/inputs/smart-input/AgentTextarea.js +2 -2
- package/dist/agents/components/inputs/smart-input/ComposerToolsNotice.d.ts +1 -0
- package/dist/agents/components/inputs/smart-input/ComposerToolsNotice.js +5 -0
- package/dist/agents/components/inputs/smart-input/ConversationContextRail.d.ts +5 -1
- package/dist/agents/components/inputs/smart-input/ConversationContextRail.js +6 -1
- package/dist/agents/components/inputs/smart-input/InboxQueueStrip.d.ts +6 -1
- package/dist/agents/components/inputs/smart-input/InboxQueueStrip.js +6 -1
- package/dist/agents/components/inputs/smart-input/InputActionButtons.js +8 -6
- package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.d.ts +5 -1
- package/dist/agents/components/inputs/smart-input/SmartInputFileDropTarget.js +8 -1
- package/dist/agents/components/inputs/smart-input/composer/ComposerAgentPill.js +2 -2
- package/dist/agents/components/inputs/smart-input/composer/ComposerChipsRow.d.ts +5 -2
- package/dist/agents/components/inputs/smart-input/composer/ComposerChipsRow.js +6 -1
- package/dist/agents/components/inputs/smart-input/composer/ComposerMetaRow.d.ts +6 -8
- package/dist/agents/components/inputs/smart-input/composer/ComposerMetaRow.js +13 -1
- package/dist/agents/components/inputs/smart-input/composer/useOutputShapeCatalog.d.ts +1 -1
- package/dist/agents/components/inputs/smart-input/composer/useOutputShapeCatalog.js +1 -1
- package/dist/agents/components/live-run/LiveRunDisplay.js +1 -1
- package/dist/agents/components/live-run/RunSetDisplay.js +1 -1
- package/dist/agents/components/memory/components/AgentMemoryAllView.js +1 -1
- package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.d.ts +1 -0
- package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.js +4 -3
- package/dist/agents/components/messages-display/assistant/AgentEmptyMessageDisplay.js +1 -1
- package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.d.ts +2 -2
- package/dist/agents/components/messages-display/assistant/AssistantMessageFooter.js +4 -7
- package/dist/agents/components/messages-display/assistant/InPlaceAnswerEditor.js +2 -2
- package/dist/agents/components/messages-display/citations/MessageSourcesRow.js +1 -1
- package/dist/agents/components/messages-display/rich-document/chat-message-source.d.ts +2 -0
- package/dist/agents/components/messages-display/rich-document/chat-message-source.js +41 -0
- package/dist/agents/components/messages-display/rich-document/chatMessageActions.d.ts +31 -0
- package/dist/agents/components/messages-display/rich-document/chatMessageActions.js +39 -0
- package/dist/agents/components/messages-display/user/AgentUserMessage.d.ts +1 -0
- package/dist/agents/components/messages-display/user/AgentUserMessage.js +7 -4
- package/dist/agents/components/messages-display/user/CollabNoteMessage.js +1 -1
- package/dist/agents/components/messages-display/user/UserActionBar.js +49 -39
- package/dist/agents/components/working-document/WorkingDocumentEditor.d.ts +1 -1
- package/dist/agents/components/working-document/WorkingDocumentPanel.js +2 -1
- package/dist/agents/identity/run-tier-store.js +3 -0
- package/dist/agents/redux/agent-definition/cache-bust-middleware.js +2 -0
- package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +0 -4
- package/dist/agents/redux/agent-settings/agentSettingsSlice.js +12 -5
- package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.d.ts +4 -1
- package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.js +45 -0
- package/dist/agents/redux/execution-system/inbox/inbox-turn-end.middleware.js +2 -1
- package/dist/agents/redux/execution-system/instance-ui-state/run-configuration-persist.js +2 -0
- package/dist/agents/redux/execution-system/messages/messages.selectors.js +1 -1
- package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +6 -0
- package/dist/agents/redux/execution-system/thunks/process-stream.js +25 -12
- package/dist/agents/redux/execution-system/thunks/run-headless-agent-json.d.ts +2 -0
- package/dist/agents/redux/execution-system/thunks/run-headless-agent-json.js +25 -4
- package/dist/agents/redux/execution-system/utils/assemble-cx-content-blocks.js +2 -1
- package/dist/agents/redux/execution-system/utils/inbound-render-block.d.ts +8 -0
- package/dist/agents/redux/execution-system/utils/inbound-render-block.js +17 -2
- package/dist/agents/redux/execution-system/utils/normalize-content-blocks.js +1 -1
- package/dist/agents/redux/execution-system/utils/progress-data-block.d.ts +11 -0
- package/dist/agents/redux/execution-system/utils/progress-data-block.js +37 -0
- package/dist/agents/redux/execution-system/utils/stream-block-accumulator.js +10 -8
- package/dist/agents/redux/mcp/mcp.slice.js +15 -7
- package/dist/agents/redux/tools/tools.thunks.js +3 -0
- package/dist/agents/runtime-reconnect/ServerOperationBanner.d.ts +6 -1
- package/dist/agents/runtime-reconnect/ServerOperationBanner.js +6 -1
- package/dist/agents/runtime-reconnect/reconnect-server-operation.thunk.js +10 -6
- package/dist/agents/ui-first-tools/ui/ApprovalCard.js +1 -1
- package/dist/agents/ui-first-tools/ui/AskCard.js +1 -1
- package/dist/agents/ui-first-tools/ui/lists/TaskPanel.js +1 -1
- package/dist/conversation/hooks/useDomCapturePrint.js +1 -1
- package/dist/conversation/utils/markdown-print.js +1 -1
- package/dist/cx-chat/components/messages/AssistantMessage.js +3 -5
- package/dist/cx-conversation/AssistantMessage.js +3 -5
- package/dist/host/app-data-slots.d.ts +85 -0
- package/dist/host/app-data-slots.js +42 -0
- package/dist/host/bare-host-chrome.js +1 -0
- package/dist/host/defaults/prefs.d.ts +19 -0
- package/dist/host/defaults/prefs.js +52 -0
- package/dist/host/defaults/workspace-gate.js +2 -1
- package/dist/host/index.d.ts +1 -1
- package/dist/host/index.js +2 -1
- package/dist/host/react.js +16 -1
- package/dist/host/source.d.ts +21 -0
- package/dist/host/ui-slots.d.ts +1 -23
- package/dist/host/ui-slots.js +0 -34
- package/dist/public-chat/components/PublicMessageOptionsMenu.js +2 -1
- package/dist/surfaces/redux/surfaceConfigSlice.js +2 -0
- package/dist/surfaces/redux/userStateSlice.js +3 -1
- package/dist/surfaces/runtime/agent-offer.js +1 -1
- package/dist/surfaces/runtime/surface-writeback.js +1 -1
- package/dist/tool-call-visualization/db-renderer/fetchToolRendererRow.js +2 -0
- package/dist/tool-call-visualization/renderers/agent-call/AgentCallInline.js +1 -1
- package/dist/tool-call-visualization/renderers/agent-call/CollabCallCard.js +1 -1
- package/dist/tool-call-visualization/renderers/fs/FsInline.js +1 -1
- package/dist/tool-call-visualization/renderers/random-wheel/RandomWheelInline.js +1 -1
- package/dist/tool-call-visualization/renderers/research/ResearchOverlay.js +4 -4
- package/dist/tool-call-visualization/renderers/research/SubagentReportBlock.js +2 -2
- package/dist/tool-call-visualization/renderers/scrape/ScrapeOverlay.js +1 -1
- package/dist/tool-call-visualization/renderers/search/SearchInline.js +1 -1
- package/dist/tool-call-visualization/renderers/search/SearchOverlay.js +1 -1
- package/dist/tool-call-visualization/renderers/sql/SqlInline.js +1 -1
- package/dist/tool-call-visualization/result-fields/KeyValueGrid.js +1 -1
- package/dist/tool-call-visualization/result-fields/ResultMarkdown.js +1 -1
- package/dist/tool-call-visualization/result-fields/ResultValue.js +1 -1
- package/dist/tool-call-visualization/surface-write/SurfaceWriteDiff.js +1 -1
- package/dist/ui/AudioOutputBlockSkeleton.d.ts +17 -0
- package/dist/ui/AudioOutputBlockSkeleton.js +78 -0
- package/dist/ui/chat-protocol-from-stream.d.ts +60 -0
- package/dist/ui/chat-protocol-from-stream.js +135 -0
- package/dist/ui/markdown-stream/EnhancedChatMarkdown.d.ts +59 -0
- package/dist/ui/markdown-stream/EnhancedChatMarkdown.js +1108 -0
- package/dist/ui/markdown-stream/MarkdownStream.d.ts +88 -0
- package/dist/ui/markdown-stream/MarkdownStream.js +14 -0
- package/dist/ui/markdown-stream/MarkdownStreamImpl.d.ts +4 -0
- package/dist/ui/markdown-stream/MarkdownStreamImpl.js +86 -0
- package/dist/ui/markdown-stream/StreamAwareChatMarkdown.d.ts +58 -0
- package/dist/ui/markdown-stream/StreamAwareChatMarkdown.js +294 -0
- package/dist/ui/markdown-stream/internal-handlers/AgentCallChildTrace.d.ts +22 -0
- package/dist/ui/markdown-stream/internal-handlers/AgentCallChildTrace.js +128 -0
- package/dist/ui/markdown-stream/internal-handlers/InlineAssistantError.d.ts +3 -0
- package/dist/ui/markdown-stream/internal-handlers/InlineAssistantError.js +26 -0
- package/dist/ui/markdown-stream/internal-handlers/InlineThinkingSlot.d.ts +14 -0
- package/dist/ui/markdown-stream/internal-handlers/InlineThinkingSlot.js +23 -0
- package/dist/ui/markdown-stream/internal-handlers/ToolHandlers.d.ts +42 -0
- package/dist/ui/markdown-stream/internal-handlers/ToolHandlers.js +109 -0
- package/dist/ui/markdown-stream/useBoundAgentOutputSchema.d.ts +2 -0
- package/dist/ui/markdown-stream/useBoundAgentOutputSchema.js +33 -0
- package/dist/window-panels/windows/agents/AgentAssistantMarkdownDebugWindow.js +1 -1
- package/package.json +10 -8
- package/dist/host/content-ir-slots.d.ts +0 -235
- package/dist/host/content-ir-slots.js +0 -135
- package/dist/host/markdown-slots.d.ts +0 -53
- package/dist/host/markdown-slots.js +0 -32
- package/dist/host/rich-document-slots.d.ts +0 -123
- package/dist/host/rich-document-slots.js +0 -36
- package/dist/utils/content-ir/report-kind-at-raw-renderer.d.ts +0 -19
- package/dist/utils/content-ir/report-kind-at-raw-renderer.js +0 -32
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
useState,
|
|
8
8
|
useEffect
|
|
9
9
|
} from "react";
|
|
10
|
-
import { MarkdownStream } from "../../../../
|
|
11
|
-
import
|
|
10
|
+
import { MarkdownStream } from "../../../../ui/markdown-stream/MarkdownStream.js";
|
|
11
|
+
import "../rich-document/chat-message-source.js";
|
|
12
|
+
import { RecordAnnotations, annotationRecordOf } from "@ai-matrx/rich-content/host/app-bindings";
|
|
12
13
|
import { useAppDispatch, useAppSelector } from "../../../../store/hooks.js";
|
|
13
14
|
import { PrefillNote } from "../../../message-flags/PrefillNote.js";
|
|
14
15
|
import { StoppedNote } from "../../../message-flags/StoppedNote.js";
|
|
@@ -74,7 +75,6 @@ import { retryConversationTurn } from "../../../redux/execution-system/message-c
|
|
|
74
75
|
import { commitInlineContentEdit } from "../../../redux/execution-system/message-crud/commit-inline-edit.thunk.js";
|
|
75
76
|
import { InPlaceAnswerEditor } from "./InPlaceAnswerEditor.js";
|
|
76
77
|
import { updateMessageRecord } from "../../../redux/execution-system/messages/messages.slice.js";
|
|
77
|
-
import { useInPlaceTrigger } from "../../../../host/ui-slots.js";
|
|
78
78
|
import { handInPlaceCaret } from "../../../../utils/rich-editor/in-place/caret-handoff.js";
|
|
79
79
|
import { toast } from "../../../../host/notify.js";
|
|
80
80
|
import { useDomCapturePrint } from "../../../../conversation/hooks/useDomCapturePrint.js";
|
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
traceWarRoomRenderPath
|
|
89
89
|
} from "../../../../host/ui-slots.js";
|
|
90
90
|
import { ErrorAlchemyMenu } from "../../../../host/ui-slots.js";
|
|
91
|
+
import { useInPlaceTrigger } from "@ai-matrx/rich-editor/in-place/EditInPlace";
|
|
91
92
|
const _NO_LIVE_SOURCES = [];
|
|
92
93
|
const _selectNoLiveSources = () => _NO_LIVE_SOURCES;
|
|
93
94
|
function retryErrorMessage(err) {
|
|
@@ -4,10 +4,10 @@ import { selectInstanceAgentName } from "../../../redux/execution-system/instanc
|
|
|
4
4
|
import { selectInstanceAgentDescription } from "../../../redux/execution-system/instance-ui-state/instance-ui-state.selectors.js";
|
|
5
5
|
import { Webhook } from "lucide-react";
|
|
6
6
|
import { IconResolver } from "../../../../next/lazy/IconResolver.js";
|
|
7
|
-
import { RichContent } from "../../../../host/ui-slots.js";
|
|
8
7
|
import { selectVisibleInputDefinitions } from "../../../redux/execution-system/instance-variable-values/bound-variable.selectors.js";
|
|
9
8
|
import { selectIsVariableFormShown } from "../../../redux/execution-system/selectors/aggregate.selectors.js";
|
|
10
9
|
import { emptyStateInstruction } from "./empty-state-instruction.js";
|
|
10
|
+
import { RichContent } from "@ai-matrx/rich-content/levels/RichContent";
|
|
11
11
|
const LONG_DESCRIPTION_CHAR_THRESHOLD = 1e3;
|
|
12
12
|
function AgentEmptyMessageDisplay({
|
|
13
13
|
conversationId
|
|
@@ -39,8 +39,8 @@ export interface AssistantMessageFooterProps {
|
|
|
39
39
|
* same actions over the same facts.
|
|
40
40
|
*/
|
|
41
41
|
export declare function useAssistantMessageActions({ messageId, conversationId, onFullPrint, isCapturing, surfaceKey, groupMessageIds, }: AssistantMessageFooterProps): {
|
|
42
|
-
config: import("
|
|
43
|
-
dialogsHost:
|
|
42
|
+
config: import("../rich-document/chatMessageActions.js").ChatMessageActionConfig;
|
|
43
|
+
dialogsHost: any;
|
|
44
44
|
record: import("../../../redux/execution-system/messages/messages.slice.js").MessageRecord | undefined;
|
|
45
45
|
content: string;
|
|
46
46
|
turnText: string;
|
|
@@ -3,13 +3,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useAppSelector } from "../../../../store/hooks.js";
|
|
5
5
|
import { cn } from "@ai-matrx/design-system";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
convertOriginForSource,
|
|
11
|
-
useDocumentDialogsHost
|
|
12
|
-
} from "../../../../host/rich-document-slots.js";
|
|
6
|
+
import { RichDocumentActions } from "@ai-matrx/rich-content/rich-document/RichDocumentActions";
|
|
7
|
+
import { RegistryContextMenu } from "@ai-matrx/rich-content/rich-document/RegistryContextMenu";
|
|
8
|
+
import { convertOriginForSource, useDocumentDialogsHost } from "@ai-matrx/rich-content/host/app-bindings";
|
|
9
|
+
import { buildChatMessageActions } from "../rich-document/chatMessageActions.js";
|
|
13
10
|
import { useOutputFeedback } from "../../../../host/ui-slots.js";
|
|
14
11
|
import { NegativeVerdictFollowUp } from "../../../../host/ui-slots.js";
|
|
15
12
|
import { RulebookNudge } from "../../../../host/ui-slots.js";
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { Loader2 } from "lucide-react";
|
|
5
|
-
import { InPlaceEditor } from "../../../../host/ui-slots.js";
|
|
6
5
|
import { takeInPlaceCaret } from "../../../../utils/rich-editor/in-place/caret-handoff.js";
|
|
7
6
|
import { useAppDispatch } from "../../../../store/hooks.js";
|
|
8
7
|
import { updateMessageRecord } from "../../../redux/execution-system/messages/messages.slice.js";
|
|
@@ -12,7 +11,8 @@ import {
|
|
|
12
11
|
} from "../../../redux/execution-system/message-crud/save-answer-edit.thunk.js";
|
|
13
12
|
import { toast } from "../../../../host/notify.js";
|
|
14
13
|
import { rebaseEdit } from "../../../redux/execution-system/message-crud/answer-text-splice.js";
|
|
15
|
-
import {
|
|
14
|
+
import { InPlaceEditor } from "@ai-matrx/rich-editor/in-place/InPlaceEditor";
|
|
15
|
+
import { copyRichContent } from "@ai-matrx/rich-content/copy/copy-commands";
|
|
16
16
|
function InPlaceAnswerEditor({ conversationId, messageId, startExpanded = false }) {
|
|
17
17
|
const dispatch = useAppDispatch();
|
|
18
18
|
const [openedOn, setOpenedOn] = useState(null);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
citationSourceDisplayKind
|
|
8
8
|
} from "../../../redux/execution-system/messages/message-citations.js";
|
|
9
9
|
import { citationSourceIsOpenable, citationSourceLabel, citationSourceLocator } from "./citation-source.js";
|
|
10
|
-
import { useOpenCitationSource } from "../../../../host/
|
|
10
|
+
import { useOpenCitationSource } from "../../../../host/app-data-slots.js";
|
|
11
11
|
function MessageSourcesRow({
|
|
12
12
|
sources,
|
|
13
13
|
className
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { registerSourceAdapter } from "@ai-matrx/rich-content/rich-document/actions/sources/index";
|
|
2
|
+
const chatMessageAdapter = {
|
|
3
|
+
instanceKeyPrefix: (source) => {
|
|
4
|
+
if (source.type !== "chat-message") {
|
|
5
|
+
throw new Error(
|
|
6
|
+
`chatMessageAdapter received non-chat source: ${source.type}`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return `msg-${source.messageId}`;
|
|
10
|
+
},
|
|
11
|
+
edit: async ({ newContent, previousContent, source, dispatch }) => {
|
|
12
|
+
if (source.type !== "chat-message") {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`chatMessageAdapter.edit received non-chat source: ${source.type}`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const { conversationId, messageId } = source;
|
|
18
|
+
if (!conversationId || !messageId) {
|
|
19
|
+
throw new Error("chat-message edit requires conversationId + messageId");
|
|
20
|
+
}
|
|
21
|
+
const { saveAnswerEdit } = await import("../../../redux/execution-system/message-crud/save-answer-edit.thunk.js");
|
|
22
|
+
if (previousContent === void 0) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"This editor did not say what text it opened on, so the answer was not saved (it could drop hidden reasoning). Edit the answer in place instead."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const result = await dispatch(
|
|
28
|
+
saveAnswerEdit({ conversationId, messageId, displayEdit: { previous: previousContent, next: newContent } })
|
|
29
|
+
).unwrap();
|
|
30
|
+
return {
|
|
31
|
+
kind: "chat-answer",
|
|
32
|
+
written: result.written,
|
|
33
|
+
changedSpans: result.changedSpans,
|
|
34
|
+
mostlyRewritten: result.mostlyRewritten
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
registerSourceAdapter("chat-message", chatMessageAdapter);
|
|
39
|
+
export {
|
|
40
|
+
chatMessageAdapter
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ChatMessageExtensions, ContentSource, RichDocumentActionContextCallbacks, RichDocumentActionsProp } from "@ai-matrx/rich-content/rich-document/types";
|
|
2
|
+
import "./chat-message-source.js";
|
|
3
|
+
export interface ChatMessageActionFacts {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
messageId: string;
|
|
6
|
+
role: "assistant" | "user";
|
|
7
|
+
/** Inspectable text of THIS cx_message row (the write-back target). */
|
|
8
|
+
messageContent: string;
|
|
9
|
+
/** True when `messageContent` is the JSON raw view of a structured payload. */
|
|
10
|
+
contentIsStructuredRaw?: boolean;
|
|
11
|
+
/** Aggregated text of the whole multi-iteration turn, when the host groups one. */
|
|
12
|
+
turnContent?: string | null;
|
|
13
|
+
/** Text-bearing row the assistant editor saves to (defaults to this row). */
|
|
14
|
+
editTarget?: ChatMessageExtensions["editTarget"];
|
|
15
|
+
metadata?: Record<string, unknown> | null;
|
|
16
|
+
streamRequestId?: string | null;
|
|
17
|
+
contentHistoryCount?: number;
|
|
18
|
+
groupMessageIds?: string[];
|
|
19
|
+
isCreator?: boolean;
|
|
20
|
+
surfaceKey?: string | null;
|
|
21
|
+
showFullPrint?: boolean;
|
|
22
|
+
isCapturing?: boolean;
|
|
23
|
+
callbacks?: RichDocumentActionContextCallbacks;
|
|
24
|
+
}
|
|
25
|
+
export interface ChatMessageActionConfig {
|
|
26
|
+
/** What the reader sees — the turn when grouped, else the message. */
|
|
27
|
+
content: string;
|
|
28
|
+
source: ContentSource;
|
|
29
|
+
actions: RichDocumentActionsProp;
|
|
30
|
+
}
|
|
31
|
+
export declare function buildChatMessageActions(facts: ChatMessageActionFacts): ChatMessageActionConfig;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "./chat-message-source.js";
|
|
2
|
+
function buildChatMessageActions(facts) {
|
|
3
|
+
const isStructuredRaw = facts.contentIsStructuredRaw ?? false;
|
|
4
|
+
const editTarget = facts.role === "assistant" ? facts.editTarget ?? {
|
|
5
|
+
messageId: facts.messageId,
|
|
6
|
+
content: facts.messageContent,
|
|
7
|
+
isStructuredRaw
|
|
8
|
+
} : null;
|
|
9
|
+
return {
|
|
10
|
+
content: facts.turnContent ?? facts.messageContent,
|
|
11
|
+
source: {
|
|
12
|
+
type: "chat-message",
|
|
13
|
+
messageId: facts.messageId,
|
|
14
|
+
conversationId: facts.conversationId,
|
|
15
|
+
streamRequestId: facts.streamRequestId ?? null
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
metadata: facts.metadata ?? null,
|
|
19
|
+
isCreator: facts.isCreator ?? false,
|
|
20
|
+
surfaceKey: facts.surfaceKey ?? null,
|
|
21
|
+
callbacks: facts.callbacks,
|
|
22
|
+
extensions: {
|
|
23
|
+
type: "chat-message",
|
|
24
|
+
role: facts.role,
|
|
25
|
+
messageContent: facts.messageContent,
|
|
26
|
+
contentIsStructuredRaw: isStructuredRaw,
|
|
27
|
+
editTarget,
|
|
28
|
+
streamRequestId: facts.streamRequestId ?? null,
|
|
29
|
+
contentHistoryCount: facts.contentHistoryCount ?? 0,
|
|
30
|
+
showFullPrint: facts.showFullPrint ?? false,
|
|
31
|
+
isCapturing: facts.isCapturing ?? false,
|
|
32
|
+
groupMessageIds: facts.groupMessageIds ?? [facts.messageId]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
buildChatMessageActions
|
|
39
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../rich-document/chat-message-source.js";
|
|
1
2
|
import type { MessagePart, RenderBlockPayload } from "@ai-matrx/agents/generated/stream-events";
|
|
2
3
|
export declare function AgentUserMessageContent({ conversationId, text, attachmentParts, bodyBlocks, variables, }: {
|
|
3
4
|
conversationId: string;
|
|
@@ -4,7 +4,6 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
4
4
|
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
5
5
|
import { cn } from "@ai-matrx/design-system";
|
|
6
6
|
import { useAppDispatch, useAppSelector } from "../../../../store/hooks.js";
|
|
7
|
-
import { EditInPlace } from "../../../../host/ui-slots.js";
|
|
8
7
|
import { USER_EDIT_ACTIONS, routeUserEditAction } from "../message-options/userEditActions.js";
|
|
9
8
|
import {
|
|
10
9
|
selectMessageById,
|
|
@@ -37,7 +36,8 @@ import {
|
|
|
37
36
|
} from "../../../redux/execution-system/instance-variable-values/instance-variable-values.selectors.js";
|
|
38
37
|
import { MessageAttachmentStrip } from "../MessageAttachmentStrip.js";
|
|
39
38
|
import { isAttachmentMessagePart } from "../../context-items/normalize.js";
|
|
40
|
-
import { MarkdownStream } from "../../../../
|
|
39
|
+
import { MarkdownStream } from "../../../../ui/markdown-stream/MarkdownStream.js";
|
|
40
|
+
import "../rich-document/chat-message-source.js";
|
|
41
41
|
import { literalUserText } from "./literal-user-text.js";
|
|
42
42
|
import { buildVariableDisplayLines } from "../../../utils/variable-display-lines.js";
|
|
43
43
|
import {
|
|
@@ -46,6 +46,8 @@ import {
|
|
|
46
46
|
} from "../../../redux/execution-system/messages/transcript-journal.js";
|
|
47
47
|
import { selectIsSuperAdmin } from "../../../../host/identity.js";
|
|
48
48
|
import { Button } from "@ai-matrx/design-system/controls";
|
|
49
|
+
import { useConversationAbilities } from "../../../redux/execution-system/host-conversations/conversation-abilities.js";
|
|
50
|
+
import { EditInPlace } from "@ai-matrx/rich-editor/in-place/EditInPlace";
|
|
49
51
|
function AgentUserMessageContent({
|
|
50
52
|
conversationId,
|
|
51
53
|
text,
|
|
@@ -128,6 +130,7 @@ function AgentUserMessage({
|
|
|
128
130
|
const [isHovered, setIsHovered] = useState(false);
|
|
129
131
|
const dispatch = useAppDispatch();
|
|
130
132
|
const [editingText, setEditingText] = useState(false);
|
|
133
|
+
const { database } = useConversationAbilities();
|
|
131
134
|
const content = extractFlatText(record);
|
|
132
135
|
const inspectable = extractInspectableText(record);
|
|
133
136
|
const attachmentParts = extractContentBlocks(record).filter(
|
|
@@ -140,7 +143,7 @@ function AgentUserMessage({
|
|
|
140
143
|
[record]
|
|
141
144
|
);
|
|
142
145
|
const trimmedText = content.trim();
|
|
143
|
-
const canEditText = !inspectable.isStructuredRaw && trimmedText.length > 0;
|
|
146
|
+
const canEditText = database && !inspectable.isStructuredRaw && trimmedText.length > 0;
|
|
144
147
|
const metadata = record?.metadata && typeof record.metadata === "object" ? record.metadata : null;
|
|
145
148
|
const contextReceipt = useAppSelector(
|
|
146
149
|
useMemo(() => selectMessageContextReceipt(conversationId, messageId), [conversationId, messageId])
|
|
@@ -301,7 +304,7 @@ function AgentUserMessage({
|
|
|
301
304
|
}
|
|
302
305
|
}
|
|
303
306
|
),
|
|
304
|
-
machineFramesVisible && contextReceipt && (contextReceipt.rows?.length ?? 0) > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: /* @__PURE__ */ jsx(
|
|
307
|
+
!database ? null : machineFramesVisible && contextReceipt && (contextReceipt.rows?.length ?? 0) > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5", children: /* @__PURE__ */ jsx(
|
|
305
308
|
MessageContextReceipt,
|
|
306
309
|
{
|
|
307
310
|
conversationId,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
extractFlatText,
|
|
8
8
|
selectMessageById
|
|
9
9
|
} from "../../../redux/execution-system/messages/messages.selectors.js";
|
|
10
|
-
import { BasicMarkdownContent } from "
|
|
10
|
+
import { BasicMarkdownContent } from "@ai-matrx/rich-content/display/chat-markdown/BasicMarkdownContent";
|
|
11
11
|
const PREFIX_RE = /^\[Collaboration note\]\s+Agent\s+'([^']+)'[^\n]*(?:\n|$)/;
|
|
12
12
|
function CollabNoteMessage({
|
|
13
13
|
conversationId,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useDocumentDialogsHost } from "@ai-matrx/rich-content/host/app-bindings";
|
|
4
|
+
import { buildChatMessageActions } from "../rich-document/chatMessageActions.js";
|
|
5
|
+
import { useState, Suspense, useCallback, lazy } from "react";
|
|
6
|
+
const RegistryActionMenu = lazy(
|
|
7
|
+
() => import("@ai-matrx/rich-content/rich-document/variants/RegistryActionMenu").then((m) => ({ default: m.RegistryActionMenu }))
|
|
8
|
+
);
|
|
5
9
|
import { Edit, Send, MoreHorizontal, Pin, PinOff, Loader2 } from "lucide-react";
|
|
6
10
|
import {
|
|
7
11
|
togglePinnedMessage,
|
|
@@ -12,7 +16,9 @@ import {
|
|
|
12
16
|
TapTargetButtonForGroup,
|
|
13
17
|
TapTargetButtonGroup
|
|
14
18
|
} from "@ai-matrx/tap-target";
|
|
15
|
-
import {
|
|
19
|
+
import { SpeakerButton } from "../../../../host/ui-slots.js";
|
|
20
|
+
import { CopySplitButton } from "@ai-matrx/rich-content/copy/CopySplitButton";
|
|
21
|
+
import { copyRichContent } from "@ai-matrx/rich-content/copy/copy-commands";
|
|
16
22
|
import { useAppDispatch, useAppSelector, useAppStore } from "../../../../store/hooks.js";
|
|
17
23
|
import { useOpenFullScreenMarkdownEditorBridge } from "../../../../host/window-openers.js";
|
|
18
24
|
import { selectMessagePosition } from "../../../redux/execution-system/messages/messages.selectors.js";
|
|
@@ -21,6 +27,7 @@ import { toast } from "../../../../host/notify.js";
|
|
|
21
27
|
import { DeleteMessageDialog } from "../message-options/DeleteMessageDialog.js";
|
|
22
28
|
import { openStructuredRawViewer } from "../message-options/openAssistantMessageEditor.js";
|
|
23
29
|
import { extractErrorMessage } from "@ai-matrx/data/net";
|
|
30
|
+
import { useConversationAbilities } from "../../../redux/execution-system/host-conversations/conversation-abilities.js";
|
|
24
31
|
import {
|
|
25
32
|
USER_EDIT_ACTIONS,
|
|
26
33
|
routeUserEditAction
|
|
@@ -68,6 +75,7 @@ function UserActionBar({
|
|
|
68
75
|
const dispatch = useAppDispatch();
|
|
69
76
|
const store = useAppStore();
|
|
70
77
|
const openEditor = useOpenFullScreenMarkdownEditorBridge();
|
|
78
|
+
const { database } = useConversationAbilities();
|
|
71
79
|
const isPinned = usePinnedMessageIds().has(messageId);
|
|
72
80
|
const pinPending = usePendingPinMessageIds().has(messageId);
|
|
73
81
|
const [showOptionsMenu, setShowOptionsMenu] = useState(false);
|
|
@@ -175,44 +183,46 @@ function UserActionBar({
|
|
|
175
183
|
const canFork = (messagePosition ?? 0) > 0;
|
|
176
184
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
177
185
|
/* @__PURE__ */ jsxs(TapTargetButtonGroup, { surface: "solid", children: [
|
|
178
|
-
/* @__PURE__ */ jsx(
|
|
186
|
+
/* @__PURE__ */ jsx(CopySplitButton, { copy: (flavor) => copyRichContent(content, flavor), label: "Copy message" }),
|
|
179
187
|
/* @__PURE__ */ jsx(SpeakerButton, { text: content, variant: "group" }),
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
database ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
TapTargetButtonForGroup,
|
|
191
|
+
{
|
|
192
|
+
onClick: handleEdit,
|
|
193
|
+
ariaLabel: "Edit message",
|
|
194
|
+
icon: /* @__PURE__ */ jsx(Edit, { className: "w-4 h-4 text-muted-foreground" })
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ jsx(
|
|
198
|
+
TapTargetButtonForGroup,
|
|
199
|
+
{
|
|
200
|
+
onClick: handleEdit,
|
|
201
|
+
ariaLabel: "Edit and resubmit",
|
|
202
|
+
icon: /* @__PURE__ */ jsx(Send, { className: "w-4 h-4 text-cyan-500 dark:text-cyan-400" })
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ jsx(
|
|
206
|
+
TapTargetButtonForGroup,
|
|
207
|
+
{
|
|
208
|
+
onClick: () => void togglePinnedMessage(messageId),
|
|
209
|
+
ariaLabel: pinPending ? isPinned ? "Unpinning\u2026" : "Pinning\u2026" : isPinned ? "Unpin message" : "Pin message",
|
|
210
|
+
disabled: pinPending,
|
|
211
|
+
icon: pinPending ? /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin text-muted-foreground" }) : isPinned ? /* @__PURE__ */ jsx(PinOff, { className: "w-4 h-4 text-amber-500 dark:text-amber-400" }) : /* @__PURE__ */ jsx(Pin, { className: "w-4 h-4 text-muted-foreground" })
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
showOptions && /* @__PURE__ */ jsx(
|
|
215
|
+
TapTargetButtonForGroup,
|
|
216
|
+
{
|
|
217
|
+
ref: setMoreOptionsAnchor,
|
|
218
|
+
onClick: () => setShowOptionsMenu(true),
|
|
219
|
+
ariaLabel: "More options",
|
|
220
|
+
icon: /* @__PURE__ */ jsx(MoreHorizontal, { className: "w-4 h-4 text-muted-foreground" })
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] }) : null
|
|
214
224
|
] }),
|
|
215
|
-
showOptions && showOptionsMenu && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
225
|
+
database && showOptions && showOptionsMenu && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
|
|
216
226
|
RegistryActionMenu,
|
|
217
227
|
{
|
|
218
228
|
isOpen: showOptionsMenu,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RichDocumentSource } from "
|
|
1
|
+
import type { ContentSource as RichDocumentSource } from "@ai-matrx/rich-content/rich-document/types";
|
|
2
2
|
import type { WorkingDocumentKind } from "../../redux/execution-system/instance-working-document/instance-working-document.slice.js";
|
|
3
3
|
import { type WorkingDocumentSurfaceContext } from "./workingDocumentSurface.js";
|
|
4
4
|
interface WorkingDocumentEditorProps {
|
|
@@ -31,7 +31,8 @@ import {
|
|
|
31
31
|
detachScratchpadFromConversationThunk,
|
|
32
32
|
setScratchpadGateThunk
|
|
33
33
|
} from "../../redux/execution-system/instance-working-document/scratchpad.thunks.js";
|
|
34
|
-
import { RichDocumentActionProvider
|
|
34
|
+
import { RichDocumentActionProvider } from "@ai-matrx/rich-content/rich-document/RichDocumentActionProvider";
|
|
35
|
+
import { RichDocumentActionSurface } from "@ai-matrx/rich-content/rich-document/RichDocumentActionSurface";
|
|
35
36
|
import { WorkingDocumentEditor } from "./WorkingDocumentEditor.js";
|
|
36
37
|
import {
|
|
37
38
|
sourceFeatureForKind
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createRunTierStore } from "@ai-matrx/agents/runtime";
|
|
2
2
|
import { supabase } from "../../host/db.js";
|
|
3
3
|
import { runWithSessionRetry } from "../../host/session-retry.js";
|
|
4
|
+
import { chatHostHasDatabase } from "../../host/configure.js";
|
|
5
|
+
import { ChatNoDatabaseError } from "../../host/no-database.js";
|
|
4
6
|
const KEY = /* @__PURE__ */ Symbol.for("ai-matrx.chat.run-tier-stores");
|
|
5
7
|
function getRunTierStore() {
|
|
8
|
+
if (!chatHostHasDatabase()) throw new ChatNoDatabaseError("agent run tier");
|
|
6
9
|
const db = supabase;
|
|
7
10
|
const g = globalThis;
|
|
8
11
|
const stores = g[KEY] ??= /* @__PURE__ */ new WeakMap();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { chatHostHasDatabase } from "../../../host/configure.js";
|
|
1
2
|
import {
|
|
2
3
|
postInvalidateAgentCache,
|
|
3
4
|
resolveAgentCacheBustBackend
|
|
@@ -52,6 +53,7 @@ const agentCacheBustMiddleware = (storeApi) => (next) => (action) => {
|
|
|
52
53
|
const result = next(action);
|
|
53
54
|
const agentId = extractAgentId(action);
|
|
54
55
|
if (!agentId) return result;
|
|
56
|
+
if (!chatHostHasDatabase()) return result;
|
|
55
57
|
const existing = debounceTimers.get(agentId);
|
|
56
58
|
if (existing) clearTimeout(existing);
|
|
57
59
|
const timer = setTimeout(() => {
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type PayloadAction } from "@reduxjs/toolkit";
|
|
14
14
|
import type { AgentContext, AgentSettings, AgentSettingsState, AgentSource, AgentVariable, ConflictAction, ResolutionMode } from "./types.js";
|
|
15
|
-
/**
|
|
16
|
-
* Fetch all active tools from the `tools` table.
|
|
17
|
-
* Shared across all agents — only needs to run once per session.
|
|
18
|
-
*/
|
|
19
15
|
export declare const fetchAvailableTools: import("@reduxjs/toolkit").AsyncThunk<{
|
|
20
16
|
id: string;
|
|
21
17
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
|
2
2
|
import { tryWriteOne } from "@ai-matrx/data/db";
|
|
3
3
|
import { createClient } from "../../../host/db.js";
|
|
4
|
+
import { chatHostHasDatabase } from "../../../host/configure.js";
|
|
4
5
|
import { recordUnavailable } from "../../../host/diagnostics.js";
|
|
5
6
|
import { readModelRecords, selectModelById } from "../model-registry.js";
|
|
6
7
|
import {
|
|
@@ -65,6 +66,7 @@ const initialState = {
|
|
|
65
66
|
isLoadingTools: false,
|
|
66
67
|
toolsError: null
|
|
67
68
|
};
|
|
69
|
+
const NEEDS_DATABASE = { condition: () => chatHostHasDatabase() };
|
|
68
70
|
const fetchAvailableTools = createAsyncThunk(
|
|
69
71
|
"agentSettings/fetchAvailableTools",
|
|
70
72
|
async (_, { rejectWithValue }) => {
|
|
@@ -78,7 +80,8 @@ const fetchAvailableTools = createAsyncThunk(
|
|
|
78
80
|
err instanceof Error ? err.message : "Failed to fetch tools"
|
|
79
81
|
);
|
|
80
82
|
}
|
|
81
|
-
}
|
|
83
|
+
},
|
|
84
|
+
NEEDS_DATABASE
|
|
82
85
|
);
|
|
83
86
|
const loadAgentSettings = createAsyncThunk(
|
|
84
87
|
"agentSettings/loadAgentSettings",
|
|
@@ -133,7 +136,8 @@ const loadAgentSettings = createAsyncThunk(
|
|
|
133
136
|
err instanceof Error ? err.message : "Failed to load agent settings"
|
|
134
137
|
);
|
|
135
138
|
}
|
|
136
|
-
}
|
|
139
|
+
},
|
|
140
|
+
NEEDS_DATABASE
|
|
137
141
|
);
|
|
138
142
|
const loadAgentSettingsDirect = createAsyncThunk(
|
|
139
143
|
"agentSettings/loadAgentSettingsDirect",
|
|
@@ -150,7 +154,8 @@ const loadAgentSettingsDirect = createAsyncThunk(
|
|
|
150
154
|
rawSettings: data.settings ?? null,
|
|
151
155
|
rawVariableDefaults: data.variable_defaults ?? null
|
|
152
156
|
};
|
|
153
|
-
}
|
|
157
|
+
},
|
|
158
|
+
NEEDS_DATABASE
|
|
154
159
|
);
|
|
155
160
|
const requestModelSwitch = createAsyncThunk(
|
|
156
161
|
"agentSettings/requestModelSwitch",
|
|
@@ -207,7 +212,8 @@ const requestModelSwitch = createAsyncThunk(
|
|
|
207
212
|
},
|
|
208
213
|
newDefaults
|
|
209
214
|
};
|
|
210
|
-
}
|
|
215
|
+
},
|
|
216
|
+
NEEDS_DATABASE
|
|
211
217
|
);
|
|
212
218
|
const saveAgentSettings = createAsyncThunk(
|
|
213
219
|
"agentSettings/saveAgentSettings",
|
|
@@ -253,7 +259,8 @@ const saveAgentSettings = createAsyncThunk(
|
|
|
253
259
|
err instanceof Error ? err.message : "Failed to save agent settings"
|
|
254
260
|
);
|
|
255
261
|
}
|
|
256
|
-
}
|
|
262
|
+
},
|
|
263
|
+
NEEDS_DATABASE
|
|
257
264
|
);
|
|
258
265
|
const agentSettingsSlice = createSlice({
|
|
259
266
|
name: "agentSettings",
|
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
* Nothing here reaches `host/db` or the server port.
|
|
13
13
|
*/
|
|
14
14
|
import type { ChatDispatch, ChatRootState } from "../../../../store/root-state.js";
|
|
15
|
-
import { type ChatMessageSource, type HostMessageRecord, type HostTurn } from "../../../../host/source.js";
|
|
15
|
+
import { type ChatMessageSource, type HostMessageRecord, type HostToolCall, type HostTurn } from "../../../../host/source.js";
|
|
16
|
+
import { type CxToolCallRecord } from "../observability/observability.slice.js";
|
|
16
17
|
import { type MessageRecord } from "../messages/messages.slice.js";
|
|
17
18
|
type Dispatch = ChatDispatch;
|
|
18
19
|
type GetState = () => ChatRootState;
|
|
19
20
|
export declare function hostRecordToMessageRecord(conversationId: string, record: HostMessageRecord): MessageRecord;
|
|
21
|
+
/** A host's tool call as the record a saved `tool_call` part's card reads (no database row). */
|
|
22
|
+
export declare function hostToolCallToRecord(conversationId: string, call: HostToolCall): CxToolCallRecord;
|
|
20
23
|
/** Read (or re-read) the host's history into the store. The host's sentence on failure. */
|
|
21
24
|
export declare function loadHostHistory(dispatch: Dispatch, getState: GetState, conversationId: string, options?: {
|
|
22
25
|
older?: boolean;
|
|
@@ -3,6 +3,7 @@ import { mintClientTempId } from "@ai-matrx/kit/ids";
|
|
|
3
3
|
import {
|
|
4
4
|
hostTurnResponse
|
|
5
5
|
} from "../../../../host/source.js";
|
|
6
|
+
import { upsertToolCall } from "../observability/observability.slice.js";
|
|
6
7
|
import { createInstanceFull } from "../create-instance-full.js";
|
|
7
8
|
import {
|
|
8
9
|
addOptimisticUserMessage,
|
|
@@ -52,6 +53,46 @@ function hostRecordToMessageRecord(conversationId, record) {
|
|
|
52
53
|
error: record.error ? { type: record.error.code ?? "host_error", message: record.error.message } : null
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
function hostToolCallToRecord(conversationId, call) {
|
|
57
|
+
const at = (/* @__PURE__ */ new Date(0)).toISOString();
|
|
58
|
+
return {
|
|
59
|
+
id: `host-tool-${conversationId}-${call.callId}`,
|
|
60
|
+
conversationId,
|
|
61
|
+
userRequestId: null,
|
|
62
|
+
messageId: call.messageId ?? null,
|
|
63
|
+
userId: "",
|
|
64
|
+
callId: call.callId,
|
|
65
|
+
toolName: call.name,
|
|
66
|
+
toolNameAsCalled: call.displayName ?? null,
|
|
67
|
+
toolType: "host",
|
|
68
|
+
iteration: 0,
|
|
69
|
+
status: call.status,
|
|
70
|
+
success: call.status === "completed" && !call.isError,
|
|
71
|
+
isError: call.isError,
|
|
72
|
+
errorType: call.isError ? "tool_error" : null,
|
|
73
|
+
errorMessage: call.isError ? call.output : null,
|
|
74
|
+
arguments: call.arguments,
|
|
75
|
+
output: call.isError ? null : call.output,
|
|
76
|
+
outputChars: call.output?.length ?? 0,
|
|
77
|
+
outputPreview: null,
|
|
78
|
+
outputType: null,
|
|
79
|
+
inputTokens: null,
|
|
80
|
+
outputTokens: null,
|
|
81
|
+
totalTokens: null,
|
|
82
|
+
costUsd: null,
|
|
83
|
+
durationMs: 0,
|
|
84
|
+
startedAt: at,
|
|
85
|
+
completedAt: at,
|
|
86
|
+
parentCallId: null,
|
|
87
|
+
retryCount: null,
|
|
88
|
+
persistKey: null,
|
|
89
|
+
filePath: null,
|
|
90
|
+
executionEvents: call.displayName ? [{ event: "tool_started", call_id: call.callId, tool_name: call.name, data: { display_name: call.displayName } }] : null,
|
|
91
|
+
metadata: {},
|
|
92
|
+
createdAt: at,
|
|
93
|
+
deletedAt: null
|
|
94
|
+
};
|
|
95
|
+
}
|
|
55
96
|
function applyHistory(dispatch, conversationId, page, older) {
|
|
56
97
|
const records = page.records.map((r) => hostRecordToMessageRecord(conversationId, r));
|
|
57
98
|
const oldestPosition = records.reduce(
|
|
@@ -59,6 +100,9 @@ function applyHistory(dispatch, conversationId, page, older) {
|
|
|
59
100
|
null
|
|
60
101
|
);
|
|
61
102
|
const pagination = { oldestPosition, hasMoreOlder: page.hasMoreOlder };
|
|
103
|
+
for (const call of page.toolCalls ?? []) {
|
|
104
|
+
dispatch(upsertToolCall(hostToolCallToRecord(conversationId, call)));
|
|
105
|
+
}
|
|
62
106
|
if (older) dispatch(prependMessages({ conversationId, messages: records, pagination }));
|
|
63
107
|
else dispatch(hydrateMessages({ conversationId, messages: records, pagination }));
|
|
64
108
|
dispatch(hostConversationUnavailable({ conversationId, reason: page.unavailable ?? null }));
|
|
@@ -360,6 +404,7 @@ export {
|
|
|
360
404
|
bindHostConversation,
|
|
361
405
|
hostConversationOf,
|
|
362
406
|
hostRecordToMessageRecord,
|
|
407
|
+
hostToolCallToRecord,
|
|
363
408
|
loadHostHistory,
|
|
364
409
|
runHostTurn,
|
|
365
410
|
sendToHost,
|