@flamingo-stack/openframe-frontend-core 0.0.172 → 0.0.173-snapshot.20260513212448
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AY3E5FKM.cjs → chunk-TX2C3PJM.cjs} +2227 -1649
- package/dist/chunk-TX2C3PJM.cjs.map +1 -0
- package/dist/{chunk-FEEPEOW2.js → chunk-X7AOT3WQ.js} +5770 -5192
- package/dist/chunk-X7AOT3WQ.js.map +1 -0
- package/dist/components/chat/approval-batch-message.d.ts +10 -0
- package/dist/components/chat/approval-batch-message.d.ts.map +1 -0
- package/dist/components/chat/chat-input.d.ts.map +1 -1
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/chat-message-loader.d.ts +23 -0
- package/dist/components/chat/chat-message-loader.d.ts.map +1 -0
- package/dist/components/chat/hooks/index.d.ts +1 -0
- package/dist/components/chat/hooks/index.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-collapsible.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-delayed-flag.d.ts +25 -0
- package/dist/components/chat/hooks/use-delayed-flag.d.ts.map +1 -0
- package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts.map +1 -1
- package/dist/components/chat/index.d.ts +3 -0
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/thinking-display.d.ts.map +1 -1
- package/dist/components/chat/tool-call-blocks.d.ts +18 -0
- package/dist/components/chat/tool-call-blocks.d.ts.map +1 -0
- package/dist/components/chat/tool-execution-display.d.ts +1 -1
- package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
- package/dist/components/chat/types/api.types.d.ts +16 -1
- package/dist/components/chat/types/api.types.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +2 -2
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +54 -1
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/network.types.d.ts +2 -0
- package/dist/components/chat/types/network.types.d.ts.map +1 -1
- package/dist/components/chat/types/processing.types.d.ts +14 -1
- package/dist/components/chat/types/processing.types.d.ts.map +1 -1
- package/dist/components/chat/utils/chunk-parser.d.ts.map +1 -1
- package/dist/components/chat/utils/extract-incomplete-message-state.d.ts.map +1 -1
- package/dist/components/chat/utils/index.d.ts +1 -0
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/chat/utils/message-segment-accumulator.d.ts +32 -4
- package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
- package/dist/components/chat/utils/process-historical-messages.d.ts +2 -1
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/chat/utils/tool-call-helpers.d.ts +38 -0
- package/dist/components/chat/utils/tool-call-helpers.d.ts.map +1 -0
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/index.cjs +14 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +13 -1
- package/dist/components/navigation/index.cjs +2 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/ui/index.cjs +14 -2
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +13 -1
- package/dist/components/ui/textarea.d.ts +11 -0
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -1
- package/package.json +3 -3
- package/src/components/chat/approval-batch-message.tsx +237 -0
- package/src/components/chat/chat-input.tsx +34 -106
- package/src/components/chat/chat-message-enhanced.tsx +11 -0
- package/src/components/chat/chat-message-list.tsx +100 -37
- package/src/components/chat/chat-message-loader.tsx +67 -0
- package/src/components/chat/hooks/index.ts +1 -0
- package/src/components/chat/hooks/use-collapsible.ts +10 -1
- package/src/components/chat/hooks/use-delayed-flag.ts +56 -0
- package/src/components/chat/hooks/use-realtime-chunk-processor.ts +109 -20
- package/src/components/chat/index.ts +3 -0
- package/src/components/chat/thinking-display.tsx +76 -12
- package/src/components/chat/tool-call-blocks.tsx +58 -0
- package/src/components/chat/tool-execution-display.tsx +60 -81
- package/src/components/chat/types/api.types.ts +22 -3
- package/src/components/chat/types/component.types.ts +2 -2
- package/src/components/chat/types/message.types.ts +58 -1
- package/src/components/chat/types/network.types.ts +2 -0
- package/src/components/chat/types/processing.types.ts +13 -2
- package/src/components/chat/utils/chunk-parser.ts +40 -5
- package/src/components/chat/utils/extract-incomplete-message-state.ts +19 -1
- package/src/components/chat/utils/index.ts +3 -0
- package/src/components/chat/utils/message-segment-accumulator.ts +136 -12
- package/src/components/chat/utils/process-historical-messages.ts +88 -13
- package/src/components/chat/utils/tool-call-helpers.ts +105 -0
- package/src/components/ui/textarea.tsx +107 -25
- package/dist/chunk-AY3E5FKM.cjs.map +0 -1
- package/dist/chunk-FEEPEOW2.js.map +0 -1
|
@@ -4,21 +4,75 @@ import { forwardRef, useState } from "react"
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "../../utils/cn"
|
|
6
6
|
import { PulseDots } from "../ui/pulse-dots"
|
|
7
|
+
import { SimpleMarkdownRenderer } from "../ui/simple-markdown-renderer"
|
|
7
8
|
import { ExpandChevron } from "./expand-chevron"
|
|
8
9
|
import { useCollapsible } from "./hooks/use-collapsible"
|
|
9
10
|
import type { ThinkingDisplayProps } from "./types"
|
|
10
11
|
|
|
12
|
+
// Tame SimpleMarkdownRenderer for the muted "thought" aesthetic:
|
|
13
|
+
// - all text in secondary tone with small size
|
|
14
|
+
// - bold pops back to primary so emphasis still reads
|
|
15
|
+
// - tighter paragraph/list/heading spacing (renderer ships with mt-8 mb-4)
|
|
16
|
+
// - flatter horizontal rules
|
|
17
|
+
// - inline-code visually quieter inside thoughts
|
|
18
|
+
// - fenced code blocks (`.code-block-container`) lose the renderer's `my-6`
|
|
19
|
+
// and inner `p-4` so they sit flush with surrounding paragraphs
|
|
20
|
+
const thoughtMdClasses = [
|
|
21
|
+
// Body & lists — muted grey, never white.
|
|
22
|
+
"[&_p]:!text-sm [&_p]:!text-ods-text-secondary [&_p]:!leading-snug [&_p]:!my-2 [&_p:first-child]:!mt-0 [&_p:last-child]:!mb-0",
|
|
23
|
+
"[&_li]:!text-sm [&_li]:!text-ods-text-secondary [&_li]:!leading-snug",
|
|
24
|
+
"[&_ul]:!my-2 [&_ol]:!my-2 [&_ul]:!pl-5 [&_ol]:!pl-5",
|
|
25
|
+
// Inline emphasis stays grey too. Bold pops via weight (no color shift),
|
|
26
|
+
// italic via slant — neither is allowed to brighten into white.
|
|
27
|
+
"[&_strong]:!text-ods-text-secondary [&_strong]:!font-semibold",
|
|
28
|
+
"[&_em]:!text-ods-text-secondary",
|
|
29
|
+
// Headings — SimpleMarkdownRenderer paints them `text-ods-text-primary`
|
|
30
|
+
// by default. Override every level back to secondary grey so headings
|
|
31
|
+
// don't suddenly turn white inside a thought block.
|
|
32
|
+
"[&_h1]:!text-sm [&_h1]:!text-ods-text-secondary [&_h1]:!font-semibold [&_h1]:!mt-3 [&_h1]:!mb-1 [&_h1]:!pb-0 [&_h1]:!border-0",
|
|
33
|
+
"[&_h2]:!text-sm [&_h2]:!text-ods-text-secondary [&_h2]:!font-semibold [&_h2]:!mt-3 [&_h2]:!mb-1 [&_h2]:!pb-0 [&_h2]:!border-0",
|
|
34
|
+
"[&_h3]:!text-sm [&_h3]:!text-ods-text-secondary [&_h3]:!font-semibold [&_h3]:!mt-3 [&_h3]:!mb-1",
|
|
35
|
+
"[&_h4]:!text-sm [&_h4]:!text-ods-text-secondary [&_h4]:!font-semibold [&_h4]:!mt-2 [&_h4]:!mb-1",
|
|
36
|
+
"[&_h5]:!text-sm [&_h5]:!text-ods-text-secondary [&_h5]:!font-semibold [&_h5]:!mt-2 [&_h5]:!mb-1",
|
|
37
|
+
"[&_h6]:!text-sm [&_h6]:!text-ods-text-secondary [&_h6]:!font-semibold [&_h6]:!mt-2 [&_h6]:!mb-1",
|
|
38
|
+
// Rules
|
|
39
|
+
"[&_hr]:!my-3 [&_hr]:!border-ods-border [&_hr]:!opacity-40",
|
|
40
|
+
// Inline code — Cursor-style chip: no border, background a notch
|
|
41
|
+
// LIGHTER than the surrounding thought card (`bg-ods-border` is the
|
|
42
|
+
// brightest neutral grey in the palette and sits above `bg-ods-card`),
|
|
43
|
+
// small rounded corners, tight padding. Reads as a clearly raised token
|
|
44
|
+
// without the loud bordered chip of the default renderer.
|
|
45
|
+
"[&_code]:!text-[12px] [&_code]:!text-ods-text-secondary",
|
|
46
|
+
"[&_code]:!border-0 [&_code]:!bg-ods-border [&_code]:!rounded",
|
|
47
|
+
"[&_code]:!px-1.5 [&_code]:!py-0.5",
|
|
48
|
+
"[&_.code-block-container]:!my-2",
|
|
49
|
+
"[&_.code-block-container_.code-header]:!py-1 [&_.code-block-container_.code-header]:!px-3",
|
|
50
|
+
"[&_.code-block-container_>div:last-child]:!p-3",
|
|
51
|
+
].join(" ")
|
|
52
|
+
|
|
11
53
|
const ThinkingDisplay = forwardRef<HTMLDivElement, ThinkingDisplayProps>(
|
|
12
54
|
({ className, text, isStreaming = false, ...props }, ref) => {
|
|
13
55
|
const [expanded, setExpanded] = useState(false)
|
|
56
|
+
// 26px ≈ one line of `text-sm leading-snug` (~19px) + space for the
|
|
57
|
+
// bordered/padded `<code>` badges that markdown renders inline. With
|
|
58
|
+
// exact 1lh the bottom of those badges gets clipped.
|
|
14
59
|
const { innerRef, isOverflowing, containerStyle } = useCollapsible({
|
|
15
60
|
expanded,
|
|
16
|
-
collapsedHeight:
|
|
61
|
+
collapsedHeight: 19,
|
|
17
62
|
disableTransition: isStreaming,
|
|
18
63
|
})
|
|
19
64
|
const label = isStreaming ? "Thinking" : "Thought"
|
|
20
65
|
const canToggle = isOverflowing || expanded
|
|
21
66
|
|
|
67
|
+
const toggle = () => canToggle && setExpanded(!expanded)
|
|
68
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
69
|
+
if (!canToggle) return
|
|
70
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
71
|
+
e.preventDefault()
|
|
72
|
+
setExpanded(!expanded)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
22
76
|
return (
|
|
23
77
|
<div
|
|
24
78
|
ref={ref}
|
|
@@ -28,29 +82,39 @@ const ThinkingDisplay = forwardRef<HTMLDivElement, ThinkingDisplayProps>(
|
|
|
28
82
|
)}
|
|
29
83
|
{...props}
|
|
30
84
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
85
|
+
<div
|
|
86
|
+
role="button"
|
|
87
|
+
tabIndex={canToggle ? 0 : -1}
|
|
88
|
+
aria-expanded={expanded}
|
|
89
|
+
onClick={toggle}
|
|
90
|
+
onKeyDown={handleKeyDown}
|
|
33
91
|
className={cn(
|
|
34
92
|
"w-full flex items-start gap-3 text-left",
|
|
35
93
|
canToggle ? "cursor-pointer" : "cursor-default"
|
|
36
94
|
)}
|
|
37
|
-
onClick={() => canToggle && setExpanded(!expanded)}
|
|
38
95
|
>
|
|
39
|
-
<div className="flex items-center gap-1 shrink-0
|
|
40
|
-
<span className="text-sm font-medium text-ods-text-secondary">
|
|
41
|
-
{label}
|
|
96
|
+
<div className="flex items-center gap-1 shrink-0 h-[19px]">
|
|
97
|
+
<span className="text-sm font-medium leading-snug text-ods-text-secondary">
|
|
98
|
+
{label}:
|
|
42
99
|
</span>
|
|
43
100
|
{isStreaming && <PulseDots size="sm" />}
|
|
44
101
|
</div>
|
|
45
102
|
|
|
46
|
-
<div className="flex-1 min-w-0
|
|
47
|
-
<div
|
|
48
|
-
{
|
|
103
|
+
<div className="flex-1 min-w-0" style={containerStyle}>
|
|
104
|
+
<div
|
|
105
|
+
ref={innerRef}
|
|
106
|
+
className={cn("text-sm leading-snug text-ods-text-secondary", thoughtMdClasses)}
|
|
107
|
+
>
|
|
108
|
+
<SimpleMarkdownRenderer content={text} textSize="compact" />
|
|
49
109
|
</div>
|
|
50
110
|
</div>
|
|
51
111
|
|
|
52
|
-
{canToggle &&
|
|
53
|
-
|
|
112
|
+
{canToggle && (
|
|
113
|
+
<div className="h-[19px] flex items-center shrink-0">
|
|
114
|
+
<ExpandChevron expanded={expanded} />
|
|
115
|
+
</div>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
54
118
|
</div>
|
|
55
119
|
)
|
|
56
120
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../utils/cn"
|
|
4
|
+
import { formatToolArgValue, formatToolResult } from "./utils/tool-call-helpers"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Single arg row: inline `key: value` or labeled `<pre>` block.
|
|
8
|
+
* Shared between ApprovalBatchMessage and ToolExecutionDisplay so both
|
|
9
|
+
* surfaces render long script bodies / JSON the same way.
|
|
10
|
+
*/
|
|
11
|
+
export function ArgRow({ argKey, value }: { argKey: string; value: unknown }) {
|
|
12
|
+
const formatted = formatToolArgValue(value)
|
|
13
|
+
|
|
14
|
+
if (formatted.kind === "inline") {
|
|
15
|
+
return (
|
|
16
|
+
<div className="flex gap-1 items-start w-full">
|
|
17
|
+
<span className="shrink-0 text-ods-text-secondary">{argKey}:</span>
|
|
18
|
+
<span className="flex-1 min-w-0 text-ods-text-primary break-all">{formatted.text}</span>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className="flex flex-col gap-1 items-start w-full">
|
|
25
|
+
<span className="text-ods-text-secondary">{argKey}:</span>
|
|
26
|
+
<pre className="bg-ods-bg border border-ods-border rounded-md p-3 w-full max-h-64 overflow-auto text-xs leading-5 text-ods-text-primary font-mono whitespace-pre">
|
|
27
|
+
<code>{formatted.text}</code>
|
|
28
|
+
</pre>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Result block for a tool execution. Renders inline for short single-line
|
|
35
|
+
* output and as a scrollable `<pre>` for code / JSON / multiline output.
|
|
36
|
+
*/
|
|
37
|
+
export function ResultBlock({ result, className }: { result: string | undefined | null; className?: string }) {
|
|
38
|
+
const formatted = formatToolResult(result)
|
|
39
|
+
if (!formatted.text) return null
|
|
40
|
+
|
|
41
|
+
if (formatted.kind === "inline") {
|
|
42
|
+
return (
|
|
43
|
+
<div className={cn("flex flex-col gap-1 items-start w-full", className)}>
|
|
44
|
+
<span className="text-ods-text-secondary">Result:</span>
|
|
45
|
+
<span className="text-ods-text-primary break-all">{formatted.text}</span>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className={cn("flex flex-col gap-1 items-start w-full", className)}>
|
|
52
|
+
<span className="text-ods-text-secondary">Result:</span>
|
|
53
|
+
<pre className="bg-ods-bg border border-ods-border rounded-md p-3 w-full max-h-64 overflow-auto text-xs leading-5 text-ods-text-primary font-mono whitespace-pre">
|
|
54
|
+
<code>{formatted.text}</code>
|
|
55
|
+
</pre>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -9,119 +9,98 @@ import { ToolIcon } from "../tool-icon"
|
|
|
9
9
|
import { PulseDots } from "../ui/pulse-dots"
|
|
10
10
|
import { ExpandChevron } from "./expand-chevron"
|
|
11
11
|
import { useCollapsible } from "./hooks/use-collapsible"
|
|
12
|
+
import { ArgRow, ResultBlock } from "./tool-call-blocks"
|
|
13
|
+
import { COMMAND_BODY_ARG_KEYS } from "./utils/tool-call-helpers"
|
|
12
14
|
import type { ToolExecutionDisplayProps } from "./types"
|
|
13
15
|
|
|
14
|
-
const
|
|
16
|
+
const COMMAND_BODY_KEYS = new Set<string>(COMMAND_BODY_ARG_KEYS)
|
|
17
|
+
|
|
18
|
+
const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProps>(
|
|
15
19
|
({ className, message, ...props }, ref) => {
|
|
16
20
|
const [expanded, setExpanded] = useState(false)
|
|
17
21
|
const { innerRef, containerStyle } = useCollapsible({ expanded })
|
|
18
22
|
|
|
19
23
|
const isExecuting = message.type === "EXECUTING_TOOL"
|
|
20
24
|
const isExecuted = message.type === "EXECUTED_TOOL"
|
|
21
|
-
const integratedToolType = message.integratedToolType ||
|
|
25
|
+
const integratedToolType = (message.integratedToolType as ToolType) || ("OPENFRAME" as ToolType)
|
|
22
26
|
|
|
23
27
|
const previewText = useMemo(() => {
|
|
24
28
|
const command = message.parameters?.command ?? message.parameters?.query
|
|
25
29
|
if (command) return String(command)
|
|
26
|
-
return message.toolFunction ??
|
|
30
|
+
return message.toolFunction ?? ""
|
|
27
31
|
}, [message.toolFunction, message.parameters])
|
|
28
32
|
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
33
|
+
const argEntries = useMemo<Array<[string, unknown]>>(() => {
|
|
34
|
+
if (!message.parameters || typeof message.parameters !== "object") return []
|
|
35
|
+
return Object.entries(message.parameters).filter(
|
|
36
|
+
([k, v]) => !COMMAND_BODY_KEYS.has(k) && v !== null && v !== undefined && v !== "",
|
|
37
|
+
)
|
|
38
|
+
}, [message.parameters])
|
|
35
39
|
|
|
36
|
-
const
|
|
37
|
-
const
|
|
40
|
+
const hasResult = isExecuted && typeof message.result === "string" && message.result.length > 0
|
|
41
|
+
const hasBody = argEntries.length > 0 || hasResult || isExecuting
|
|
38
42
|
|
|
39
43
|
const renderStatusIcon = () => {
|
|
40
|
-
if (isExecuting)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (isExecuted && message.success === true) {
|
|
44
|
-
return <CheckCircleIcon className="w-4 h-4 text-ods-success" />
|
|
45
|
-
}
|
|
46
|
-
if (isExecuted && message.success === false) {
|
|
47
|
-
return <XmarkCircleIcon className="w-4 h-4 text-ods-error" />
|
|
48
|
-
}
|
|
44
|
+
if (isExecuting) return <PulseDots size="sm" />
|
|
45
|
+
if (isExecuted && message.success === true) return <CheckCircleIcon className="w-4 h-4 text-ods-success" />
|
|
46
|
+
if (isExecuted && message.success === false) return <XmarkCircleIcon className="w-4 h-4 text-ods-error" />
|
|
49
47
|
return null
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
return (
|
|
53
|
-
<
|
|
51
|
+
<div
|
|
54
52
|
ref={ref}
|
|
55
|
-
type="button"
|
|
56
53
|
className={cn(
|
|
57
|
-
"bg-ods-card border border-ods-border rounded-[6px]
|
|
58
|
-
className
|
|
54
|
+
"bg-ods-card border border-ods-border rounded-[6px] overflow-hidden w-full flex flex-col",
|
|
55
|
+
className,
|
|
59
56
|
)}
|
|
60
|
-
onClick={() => setExpanded(!expanded)}
|
|
61
57
|
{...props}
|
|
62
58
|
>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<div className="flex
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{expanded ? message.toolFunction : previewText}
|
|
78
|
-
</div>
|
|
79
|
-
{hasStatus && (
|
|
80
|
-
<div className="flex items-center justify-center shrink-0 w-5 h-5">
|
|
81
|
-
{renderStatusIcon()}
|
|
82
|
-
</div>
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
className="flex gap-[var(--spacing-system-xs)] items-start p-[var(--spacing-system-s)] cursor-pointer text-left w-full"
|
|
62
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
63
|
+
>
|
|
64
|
+
<div className="flex items-center justify-center shrink-0 w-5 h-5">
|
|
65
|
+
<ToolIcon toolType={integratedToolType} size={16} />
|
|
66
|
+
</div>
|
|
67
|
+
<div
|
|
68
|
+
className={cn(
|
|
69
|
+
"flex-1 min-w-0 text-sm font-medium leading-5",
|
|
70
|
+
expanded
|
|
71
|
+
? "text-ods-text-primary whitespace-pre-wrap break-all"
|
|
72
|
+
: "text-ods-text-secondary line-clamp-2 max-h-10 break-all",
|
|
83
73
|
)}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</div>
|
|
74
|
+
>
|
|
75
|
+
{expanded ? message.toolFunction || previewText : previewText}
|
|
87
76
|
</div>
|
|
77
|
+
<div className="flex items-center justify-center shrink-0 w-5 h-5">{renderStatusIcon()}</div>
|
|
78
|
+
<div className="flex items-center justify-center shrink-0 w-5 h-5">
|
|
79
|
+
<ExpandChevron expanded={expanded} />
|
|
80
|
+
</div>
|
|
81
|
+
</button>
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{(isExecuting || (isExecuted && message.result)) && (
|
|
107
|
-
<div className="flex flex-col items-start w-full">
|
|
108
|
-
<p className="text-sm font-medium leading-5 text-ods-text-secondary">
|
|
109
|
-
Result:
|
|
110
|
-
</p>
|
|
111
|
-
{isExecuted && message.result && (
|
|
112
|
-
<div className="text-sm font-medium leading-5 text-ods-text-primary whitespace-pre-wrap break-all">
|
|
113
|
-
{message.result}
|
|
114
|
-
</div>
|
|
115
|
-
)}
|
|
116
|
-
{isExecuting && <PulseDots size="sm" />}
|
|
117
|
-
</div>
|
|
118
|
-
)}
|
|
119
|
-
</div>
|
|
83
|
+
<div className="w-full" style={containerStyle}>
|
|
84
|
+
<div ref={innerRef}>
|
|
85
|
+
{hasBody && (
|
|
86
|
+
<div className="flex flex-col gap-2 items-start w-full text-sm font-medium leading-5 p-3 bg-ods-card">
|
|
87
|
+
{argEntries.map(([key, value]) => (
|
|
88
|
+
<ArgRow key={key} argKey={key} value={value} />
|
|
89
|
+
))}
|
|
90
|
+
{hasResult && <ResultBlock result={message.result} />}
|
|
91
|
+
{isExecuting && (
|
|
92
|
+
<div className="flex flex-col gap-1 items-start w-full">
|
|
93
|
+
<span className="text-ods-text-secondary">Result:</span>
|
|
94
|
+
<PulseDots size="sm" />
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
120
99
|
</div>
|
|
121
100
|
</div>
|
|
122
|
-
</
|
|
101
|
+
</div>
|
|
123
102
|
)
|
|
124
|
-
}
|
|
103
|
+
},
|
|
125
104
|
)
|
|
126
105
|
|
|
127
106
|
ToolExecutionDisplay.displayName = "ToolExecutionDisplay"
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ChunkData, NatsMessageType, FetchChunksFunction } from './network.types'
|
|
7
7
|
import type { ChatType, ChatApprovalStatus } from './chat.types'
|
|
8
|
-
import type { MessageSegment, TokenUsageData } from './message.types'
|
|
8
|
+
import type { MessageSegment, PendingToolCallData, TokenUsageData } from './message.types'
|
|
9
9
|
|
|
10
10
|
// ========== Hook Options ==========
|
|
11
11
|
|
|
@@ -152,7 +152,10 @@ export interface UseRealtimeChunkProcessorOptions {
|
|
|
152
152
|
/** Executing tools waiting for completion */
|
|
153
153
|
executingTools?: Map<string, { integratedToolType: string; toolFunction: string; parameters?: Record<string, any> }>
|
|
154
154
|
/** Escalated approvals */
|
|
155
|
-
escalatedApprovals?: Map<
|
|
155
|
+
escalatedApprovals?: Map<
|
|
156
|
+
string,
|
|
157
|
+
{ command: string; explanation?: string; approvalType: string; toolCalls?: PendingToolCallData[] }
|
|
158
|
+
>
|
|
156
159
|
}
|
|
157
160
|
/**
|
|
158
161
|
* When true, THINKING chunks are processed into thinking segments. When false
|
|
@@ -160,6 +163,19 @@ export interface UseRealtimeChunkProcessorOptions {
|
|
|
160
163
|
* accumulator or store.
|
|
161
164
|
*/
|
|
162
165
|
enableThinking?: boolean
|
|
166
|
+
/**
|
|
167
|
+
* Consumer-owned (e.g. set in `openframe-oss-tenant` chat client via the
|
|
168
|
+
* `'batch-approvals'` feature flag and forwarded here). The lib does NOT
|
|
169
|
+
* default this to a batch-on behavior — when omitted it falls back to the
|
|
170
|
+
* legacy single-card rendering.
|
|
171
|
+
*
|
|
172
|
+
* When true: `APPROVAL_REQUEST` chunks containing `toolCalls[]` are rendered
|
|
173
|
+
* as a single batch card. When false / omitted: the batch is split into N
|
|
174
|
+
* legacy approval cards (one per tool that requires approval), all sharing
|
|
175
|
+
* the same `approvalRequestId`. Tools with `requiresApproval=false` are
|
|
176
|
+
* dropped from the UI in the unfolded mode.
|
|
177
|
+
*/
|
|
178
|
+
batchApprovalsEnabled?: boolean
|
|
163
179
|
}
|
|
164
180
|
|
|
165
181
|
export interface UseRealtimeChunkProcessorReturn {
|
|
@@ -172,7 +188,10 @@ export interface UseRealtimeChunkProcessorReturn {
|
|
|
172
188
|
/** Update approval status for a request */
|
|
173
189
|
updateApprovalStatus: (requestId: string, status: ChatApprovalStatus) => MessageSegment[]
|
|
174
190
|
/** Get pending approval requests */
|
|
175
|
-
getPendingApprovals: () => Map<
|
|
191
|
+
getPendingApprovals: () => Map<
|
|
192
|
+
string,
|
|
193
|
+
{ command: string; explanation?: string; approvalType: string; toolCalls?: PendingToolCallData[] }
|
|
194
|
+
>
|
|
176
195
|
}
|
|
177
196
|
|
|
178
197
|
// ========== API Request Types ==========
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Component prop types
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { ComponentType, HTMLAttributes, TextareaHTMLAttributes } from 'react'
|
|
6
6
|
import type { AssistantType, AuthorType, ChatApprovalStatus, ConnectionStatus } from './chat.types'
|
|
7
7
|
import type { ApprovalRequestData, Message, MessageSegment, ToolExecutionData } from './message.types'
|
|
8
8
|
import type { ChatRef } from '../chat-ref.types'
|
|
@@ -242,7 +242,7 @@ export interface ChatTypingIndicatorProps extends HTMLAttributes<HTMLDivElement>
|
|
|
242
242
|
|
|
243
243
|
// ========== Tool Execution Display Props ==========
|
|
244
244
|
|
|
245
|
-
export interface ToolExecutionDisplayProps extends
|
|
245
|
+
export interface ToolExecutionDisplayProps extends HTMLAttributes<HTMLDivElement> {
|
|
246
246
|
message: ToolExecutionData
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -38,6 +38,12 @@ export interface ToolExecutionData {
|
|
|
38
38
|
parameters?: Record<string, any>
|
|
39
39
|
result?: string
|
|
40
40
|
success?: boolean
|
|
41
|
+
/**
|
|
42
|
+
* Backend-issued id (matches `PendingToolCallData.toolExecutionRequestId`).
|
|
43
|
+
* When present, lets the accumulator merge this execution event into the
|
|
44
|
+
* matching approval batch row instead of emitting a standalone segment.
|
|
45
|
+
*/
|
|
46
|
+
toolExecutionRequestId?: string
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
// ========== Approval Request Types ==========
|
|
@@ -57,6 +63,45 @@ export interface ApprovalResultData {
|
|
|
57
63
|
approvalType?: string
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Single tool call inside a batch approval request.
|
|
68
|
+
* Mirrors backend PendingToolCallDto.
|
|
69
|
+
*/
|
|
70
|
+
export interface PendingToolCallData {
|
|
71
|
+
toolExecutionRequestId: string
|
|
72
|
+
toolName: string
|
|
73
|
+
toolTitle?: string
|
|
74
|
+
toolExplanation?: string
|
|
75
|
+
toolType?: string
|
|
76
|
+
requiresApproval: boolean
|
|
77
|
+
approvalType?: string | null
|
|
78
|
+
toolCallArguments?: Record<string, any> | null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Per-tool execution state inside an approval batch.
|
|
83
|
+
* Populated by EXECUTING_TOOL / EXECUTED_TOOL chunks that carry a
|
|
84
|
+
* `toolExecutionRequestId` matching one of the batch's tool calls.
|
|
85
|
+
*/
|
|
86
|
+
export interface ApprovalBatchExecutionState {
|
|
87
|
+
status: 'executing' | 'done'
|
|
88
|
+
result?: string
|
|
89
|
+
success?: boolean
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ApprovalBatchData {
|
|
93
|
+
approvalRequestId: string
|
|
94
|
+
/** Highest approval type required across the batch (e.g. ADMIN beats CLIENT). */
|
|
95
|
+
approvalType: string
|
|
96
|
+
toolCalls: PendingToolCallData[]
|
|
97
|
+
/**
|
|
98
|
+
* Keyed by `PendingToolCallData.toolExecutionRequestId`. Absent before
|
|
99
|
+
* approval; rows without an entry render as "queued" (loader) once the
|
|
100
|
+
* batch itself is approved.
|
|
101
|
+
*/
|
|
102
|
+
executions?: Record<string, ApprovalBatchExecutionState>
|
|
103
|
+
}
|
|
104
|
+
|
|
60
105
|
// ========== Message Segment Types ==========
|
|
61
106
|
|
|
62
107
|
export type TextSegment = {
|
|
@@ -82,6 +127,14 @@ export type ApprovalRequestSegment = {
|
|
|
82
127
|
onReject?: (requestId?: string) => void | Promise<void>
|
|
83
128
|
}
|
|
84
129
|
|
|
130
|
+
export type ApprovalBatchSegment = {
|
|
131
|
+
type: 'approval_batch'
|
|
132
|
+
data: ApprovalBatchData
|
|
133
|
+
status?: ChatApprovalStatus
|
|
134
|
+
onApprove?: (requestId?: string) => void | Promise<void>
|
|
135
|
+
onReject?: (requestId?: string) => void | Promise<void>
|
|
136
|
+
}
|
|
137
|
+
|
|
85
138
|
export type ErrorSegment = {
|
|
86
139
|
type: 'error'
|
|
87
140
|
title: string
|
|
@@ -94,7 +147,7 @@ export type ContextCompactionSegment = {
|
|
|
94
147
|
summary?: string
|
|
95
148
|
}
|
|
96
149
|
|
|
97
|
-
export type MessageSegment = TextSegment | ThinkingSegment | ToolExecutionSegment | ApprovalRequestSegment | ErrorSegment | ContextCompactionSegment
|
|
150
|
+
export type MessageSegment = TextSegment | ThinkingSegment | ToolExecutionSegment | ApprovalRequestSegment | ApprovalBatchSegment | ErrorSegment | ContextCompactionSegment
|
|
98
151
|
|
|
99
152
|
export type MessageContent = string | MessageSegment[]
|
|
100
153
|
|
|
@@ -119,6 +172,7 @@ export interface ExecutingToolMessageData extends MessageDataBase {
|
|
|
119
172
|
integratedToolType?: string
|
|
120
173
|
toolFunction?: string
|
|
121
174
|
parameters?: Record<string, any>
|
|
175
|
+
toolExecutionRequestId?: string
|
|
122
176
|
}
|
|
123
177
|
|
|
124
178
|
export interface ExecutedToolMessageData extends MessageDataBase {
|
|
@@ -128,6 +182,7 @@ export interface ExecutedToolMessageData extends MessageDataBase {
|
|
|
128
182
|
parameters?: Record<string, any>
|
|
129
183
|
result?: string
|
|
130
184
|
success?: boolean
|
|
185
|
+
toolExecutionRequestId?: string
|
|
131
186
|
}
|
|
132
187
|
|
|
133
188
|
export interface ApprovalRequestMessageData extends MessageDataBase {
|
|
@@ -136,6 +191,8 @@ export interface ApprovalRequestMessageData extends MessageDataBase {
|
|
|
136
191
|
approvalType?: string
|
|
137
192
|
command?: string
|
|
138
193
|
explanation?: string
|
|
194
|
+
/** Present when the approval is a batch of tool calls (new format). */
|
|
195
|
+
toolCalls?: PendingToolCallData[]
|
|
139
196
|
}
|
|
140
197
|
|
|
141
198
|
export interface ApprovalResultMessageData extends MessageDataBase {
|
|
@@ -41,6 +41,7 @@ export interface ChunkData {
|
|
|
41
41
|
parameters?: Record<string, any>
|
|
42
42
|
result?: string
|
|
43
43
|
success?: boolean
|
|
44
|
+
toolExecutionRequestId?: string
|
|
44
45
|
error?: string
|
|
45
46
|
details?: string
|
|
46
47
|
approvalRequestId?: string
|
|
@@ -49,6 +50,7 @@ export interface ChunkData {
|
|
|
49
50
|
command?: string
|
|
50
51
|
explanation?: string
|
|
51
52
|
approved?: boolean
|
|
53
|
+
toolCalls?: any[]
|
|
52
54
|
modelName?: string
|
|
53
55
|
providerName?: string
|
|
54
56
|
provider?: string
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Contains types for message parsing, accumulation, and processing
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { MessageSegment, ProcessedMessage, ToolExecutionSegment, TokenUsageData } from './message.types'
|
|
6
|
+
import type { MessageSegment, ProcessedMessage, ToolExecutionSegment, TokenUsageData, PendingToolCallData } from './message.types'
|
|
7
7
|
import type { ChatApprovalStatus, AssistantType } from './chat.types'
|
|
8
8
|
import type { ChunkData, NatsMessageType } from './network.types'
|
|
9
9
|
|
|
@@ -18,6 +18,7 @@ export type ParsedChunkAction =
|
|
|
18
18
|
| { action: 'thinking'; text: string }
|
|
19
19
|
| { action: 'tool_execution'; segment: ToolExecutionSegment }
|
|
20
20
|
| { action: 'approval_request'; requestId: string; command: string; explanation?: string; approvalType: string }
|
|
21
|
+
| { action: 'approval_batch'; requestId: string; approvalType: string; toolCalls: PendingToolCallData[] }
|
|
21
22
|
| { action: 'approval_result'; requestId: string; approved: boolean; approvalType: string }
|
|
22
23
|
| { action: 'message_request'; text: string; ownerType?: string; displayName?: string }
|
|
23
24
|
| { action: 'token_usage'; data: TokenUsageData }
|
|
@@ -43,7 +44,10 @@ export interface AccumulatorState {
|
|
|
43
44
|
toolFunction: string
|
|
44
45
|
parameters?: Record<string, any>
|
|
45
46
|
}>
|
|
46
|
-
escalatedApprovals?: Map<
|
|
47
|
+
escalatedApprovals?: Map<
|
|
48
|
+
string,
|
|
49
|
+
{ command: string; explanation?: string; approvalType: string; toolCalls?: PendingToolCallData[] }
|
|
50
|
+
>
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
// ========== Message Processing Options ==========
|
|
@@ -65,6 +69,13 @@ export interface MessageProcessingOptions {
|
|
|
65
69
|
approvalStatuses?: Record<string, ChatApprovalStatus>
|
|
66
70
|
/** Approval types to display directly (others get escalated) - defaults to all types */
|
|
67
71
|
displayApprovalTypes?: string[]
|
|
72
|
+
/**
|
|
73
|
+
* Consumer-owned. Forwarded by the host app (e.g. oss-tenant chat client
|
|
74
|
+
* reads its `'batch-approvals'` feature flag and passes it down). The lib
|
|
75
|
+
* defaults to legacy single-card rendering when this is omitted — it will
|
|
76
|
+
* not enable the batch UI on its own.
|
|
77
|
+
*/
|
|
78
|
+
batchApprovalsEnabled?: boolean
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
// ========== Chunk Processing Types ==========
|