@optilogic/chat 1.0.0-beta.11 → 1.0.0-beta.13
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/index.cjs +47 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/agent-response/AgentResponse.tsx +9 -1
- package/src/components/agent-response/components/ThinkingSection.tsx +1 -1
- package/src/components/agent-response/hooks/useAgentResponseAccumulator.ts +23 -0
- package/src/components/agent-response/index.ts +1 -0
- package/src/components/agent-response/types.ts +19 -1
- package/src/components/agent-timeline/AgentTimeline.tsx +1 -1
- package/src/components/agent-timeline/utils.ts +22 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optilogic/chat",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
4
|
"description": "Chat UI components for Optilogic - AgentResponse and related components for LLM interactions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@optilogic/
|
|
28
|
-
"@optilogic/
|
|
27
|
+
"@optilogic/editor": "1.0.0-beta.13",
|
|
28
|
+
"@optilogic/core": "1.0.0-beta.13"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -92,6 +92,12 @@ export interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
92
92
|
* />
|
|
93
93
|
*/
|
|
94
94
|
renderThinkingMarkdown?: (content: string) => React.ReactNode;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Maximum height of the AgentTimeline scrollable container.
|
|
98
|
+
* Defaults to "300px". Set to "none" to disable the constraint.
|
|
99
|
+
*/
|
|
100
|
+
timelineMaxHeight?: string;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
/**
|
|
@@ -144,6 +150,7 @@ const AgentResponse = React.forwardRef<HTMLDivElement, AgentResponseProps>(
|
|
|
144
150
|
statusContent,
|
|
145
151
|
renderMarkdown,
|
|
146
152
|
renderThinkingMarkdown,
|
|
153
|
+
timelineMaxHeight,
|
|
147
154
|
className,
|
|
148
155
|
...props
|
|
149
156
|
},
|
|
@@ -254,11 +261,12 @@ const AgentResponse = React.forwardRef<HTMLDivElement, AgentResponseProps>(
|
|
|
254
261
|
{/* Thinking Content - AgentTimeline when timeline entries exist, ThinkingSection otherwise */}
|
|
255
262
|
{hasTimelineEntries ? (
|
|
256
263
|
thinkingExpanded && (
|
|
257
|
-
<div className="
|
|
264
|
+
<div className="pl-3 pb-3 border-t border-border">
|
|
258
265
|
<AgentTimeline
|
|
259
266
|
entries={state.timelineEntries!}
|
|
260
267
|
renderMarkdown={renderThinkingMarkdown}
|
|
261
268
|
uiState={timelineUIStateRef.current}
|
|
269
|
+
maxHeight={timelineMaxHeight}
|
|
262
270
|
/>
|
|
263
271
|
</div>
|
|
264
272
|
)
|
|
@@ -110,7 +110,7 @@ const ThinkingSection = React.forwardRef<HTMLDivElement, ThinkingSectionProps>(
|
|
|
110
110
|
className={cn("px-3 pb-3 border-t border-border", className)}
|
|
111
111
|
{...props}
|
|
112
112
|
>
|
|
113
|
-
<div className="mt-2 max-h-[200px] overflow-y-auto
|
|
113
|
+
<div className="mt-2 max-h-[200px] overflow-y-auto">
|
|
114
114
|
{isStructured ? (
|
|
115
115
|
<div className="space-y-0">
|
|
116
116
|
{content.map((step) => (
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type MemoryItem,
|
|
16
16
|
type StatusItem,
|
|
17
17
|
type ThinkingStep,
|
|
18
|
+
type PotentialResponse,
|
|
18
19
|
} from "../types";
|
|
19
20
|
import { buildTimelineEntries } from "../../agent-timeline/utils";
|
|
20
21
|
|
|
@@ -245,6 +246,28 @@ export function useAgentResponseAccumulator(
|
|
|
245
246
|
return { ...prev, status: newStatus, firstMessageTime };
|
|
246
247
|
}
|
|
247
248
|
|
|
249
|
+
case "potential_response": {
|
|
250
|
+
const respContent = payload.message || payload.content || "";
|
|
251
|
+
if (respContent) {
|
|
252
|
+
const newResp: PotentialResponse = {
|
|
253
|
+
id: `resp-${Date.now()}`,
|
|
254
|
+
content: respContent,
|
|
255
|
+
timestamp: Date.now(),
|
|
256
|
+
agentName: payload.agentName,
|
|
257
|
+
parentAgent: payload.parentAgent,
|
|
258
|
+
depth: payload.depth,
|
|
259
|
+
};
|
|
260
|
+
const next = {
|
|
261
|
+
...prev,
|
|
262
|
+
status: newStatus,
|
|
263
|
+
potentialResponses: [...(prev.potentialResponses || []), newResp],
|
|
264
|
+
firstMessageTime,
|
|
265
|
+
};
|
|
266
|
+
return { ...next, timelineEntries: buildTimelineEntries(next) };
|
|
267
|
+
}
|
|
268
|
+
return { ...prev, status: newStatus, firstMessageTime };
|
|
269
|
+
}
|
|
270
|
+
|
|
248
271
|
default:
|
|
249
272
|
return { ...prev, status: newStatus, firstMessageTime };
|
|
250
273
|
}
|
|
@@ -64,6 +64,18 @@ export interface MemoryItem {
|
|
|
64
64
|
depth?: number;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Potential response (sub-agent intermediate AI response)
|
|
69
|
+
*/
|
|
70
|
+
export interface PotentialResponse {
|
|
71
|
+
id: string;
|
|
72
|
+
content: string;
|
|
73
|
+
timestamp: number;
|
|
74
|
+
agentName?: string | null;
|
|
75
|
+
parentAgent?: string | null;
|
|
76
|
+
depth?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
/**
|
|
68
80
|
* Status update information from the agent
|
|
69
81
|
*/
|
|
@@ -128,6 +140,10 @@ export interface AgentResponseState {
|
|
|
128
140
|
memory: MemoryItem[];
|
|
129
141
|
/** Status updates from the agent */
|
|
130
142
|
statusUpdates: StatusItem[];
|
|
143
|
+
/** Potential responses (sub-agent intermediate AI responses) */
|
|
144
|
+
potentialResponses?: PotentialResponse[];
|
|
145
|
+
/** Custom timeline entries (consumer-provided) */
|
|
146
|
+
customTimelineEntries?: TimelineEntry[];
|
|
131
147
|
/** Final response text */
|
|
132
148
|
response: string;
|
|
133
149
|
/** Timeline entries derived from all accumulator arrays (for AgentTimeline) */
|
|
@@ -144,7 +160,7 @@ export interface AgentResponseState {
|
|
|
144
160
|
* WebSocket message payload for agent responses
|
|
145
161
|
*/
|
|
146
162
|
export interface AgentMessage {
|
|
147
|
-
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update";
|
|
163
|
+
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update" | "potential_response";
|
|
148
164
|
/** Message content - for simple string payloads */
|
|
149
165
|
message?: string;
|
|
150
166
|
/** Alternative content field */
|
|
@@ -212,6 +228,8 @@ export const initialAgentResponseState: AgentResponseState = {
|
|
|
212
228
|
knowledge: [],
|
|
213
229
|
memory: [],
|
|
214
230
|
statusUpdates: [],
|
|
231
|
+
potentialResponses: [],
|
|
232
|
+
customTimelineEntries: [],
|
|
215
233
|
response: "",
|
|
216
234
|
thinkingStartTime: null,
|
|
217
235
|
responseCompleteTime: null,
|
|
@@ -151,7 +151,7 @@ export function AgentTimeline({ entries, renderMarkdown, uiState, maxHeight = "3
|
|
|
151
151
|
return (
|
|
152
152
|
<div
|
|
153
153
|
ref={containerRef}
|
|
154
|
-
className={
|
|
154
|
+
className={maxHeight !== "none" ? "overflow-y-auto" : ""}
|
|
155
155
|
style={scrollStyle}
|
|
156
156
|
>
|
|
157
157
|
{/* Filter + controls bar (sticky within scroll container) */}
|
|
@@ -98,6 +98,28 @@ export function buildTimelineEntries(state: AgentResponseState): TimelineEntry[]
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
// Potential responses → ai_response timeline entries
|
|
102
|
+
if (state.potentialResponses) {
|
|
103
|
+
let respIdx = 0;
|
|
104
|
+
for (const resp of state.potentialResponses) {
|
|
105
|
+
entries.push({
|
|
106
|
+
id: `tl-resp-${respIdx++}`,
|
|
107
|
+
type: "ai_response",
|
|
108
|
+
agentName: resp.agentName ?? null,
|
|
109
|
+
parentAgent: resp.parentAgent ?? null,
|
|
110
|
+
depth: resp.depth ?? 0,
|
|
111
|
+
content: resp.content,
|
|
112
|
+
title: null,
|
|
113
|
+
timestamp: resp.timestamp,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Merge any custom timeline entries (consumer-provided)
|
|
119
|
+
if (state.customTimelineEntries) {
|
|
120
|
+
entries.push(...state.customTimelineEntries);
|
|
121
|
+
}
|
|
122
|
+
|
|
101
123
|
// Sort chronologically
|
|
102
124
|
entries.sort((a, b) => a.timestamp - b.timestamp);
|
|
103
125
|
|