@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/dist/index.d.cts
CHANGED
|
@@ -101,6 +101,17 @@ interface MemoryItem {
|
|
|
101
101
|
/** Nesting depth in agent hierarchy */
|
|
102
102
|
depth?: number;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Potential response (sub-agent intermediate AI response)
|
|
106
|
+
*/
|
|
107
|
+
interface PotentialResponse {
|
|
108
|
+
id: string;
|
|
109
|
+
content: string;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
agentName?: string | null;
|
|
112
|
+
parentAgent?: string | null;
|
|
113
|
+
depth?: number;
|
|
114
|
+
}
|
|
104
115
|
/**
|
|
105
116
|
* Status update information from the agent
|
|
106
117
|
*/
|
|
@@ -162,6 +173,10 @@ interface AgentResponseState {
|
|
|
162
173
|
memory: MemoryItem[];
|
|
163
174
|
/** Status updates from the agent */
|
|
164
175
|
statusUpdates: StatusItem[];
|
|
176
|
+
/** Potential responses (sub-agent intermediate AI responses) */
|
|
177
|
+
potentialResponses?: PotentialResponse[];
|
|
178
|
+
/** Custom timeline entries (consumer-provided) */
|
|
179
|
+
customTimelineEntries?: TimelineEntry[];
|
|
165
180
|
/** Final response text */
|
|
166
181
|
response: string;
|
|
167
182
|
/** Timeline entries derived from all accumulator arrays (for AgentTimeline) */
|
|
@@ -177,7 +192,7 @@ interface AgentResponseState {
|
|
|
177
192
|
* WebSocket message payload for agent responses
|
|
178
193
|
*/
|
|
179
194
|
interface AgentMessage {
|
|
180
|
-
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update";
|
|
195
|
+
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update" | "potential_response";
|
|
181
196
|
/** Message content - for simple string payloads */
|
|
182
197
|
message?: string;
|
|
183
198
|
/** Alternative content field */
|
|
@@ -369,6 +384,11 @@ interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
369
384
|
* />
|
|
370
385
|
*/
|
|
371
386
|
renderThinkingMarkdown?: (content: string) => React.ReactNode;
|
|
387
|
+
/**
|
|
388
|
+
* Maximum height of the AgentTimeline scrollable container.
|
|
389
|
+
* Defaults to "300px". Set to "none" to disable the constraint.
|
|
390
|
+
*/
|
|
391
|
+
timelineMaxHeight?: string;
|
|
372
392
|
}
|
|
373
393
|
/**
|
|
374
394
|
* AgentResponse Component
|
|
@@ -893,4 +913,4 @@ declare function parseResponseSegments(text: string): ResponseSegment[];
|
|
|
893
913
|
*/
|
|
894
914
|
declare const INLINE_ACTION_PROMPT = "\n<inline_actions>\nWhen your response should include interactive components (like query viewers,\ndata tables, or executable actions), embed them as fenced code blocks using\nthe `json:action` language tag:\n\n```json:action\n{\n \"type\": \"action-type-here\",\n ...action-specific fields\n}\n```\n\nRules:\n- Each block must contain valid JSON with a \"type\" field.\n- The \"type\" must match a registered action component on the frontend.\n- Multiple action blocks per response are allowed.\n- Surround action blocks with normal markdown text for user context.\n- The action block is rendered as an interactive component in the chat UI.\n- SQL strings inside JSON must be properly escaped (newlines as \\n, quotes as \\\").\n\nAvailable action types:\n\n- \"optimap-query\": Displays SQL queries with a button to execute them and\n update the 3D globe map.\n Required fields:\n - type: \"optimap-query\"\n - locations_sql: string (the validated locations SQL query)\n - routes_sql: string (the validated routes SQL query)\n - database_name: string (the target database name)\n</inline_actions>\n";
|
|
895
915
|
|
|
896
|
-
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseProps, type AgentResponseState, type AgentResponseStatus, type AgentRun, AgentTimeline, type DisplayEntry, type FeedbackValue, type GenericWebSocketMessage, type HITLInteraction, HITLInteractionRecord, type HITLInteractionRecordProps, type HITLQuestion, HITLQuestionPanel, type HITLQuestionPanelProps, type HITLResponseData, HITLSection, type HITLSectionProps, INLINE_ACTION_PROMPT, type InlineActionProps, type KnowledgeItem, type MarkdownSegment, type MemoryItem, MetadataRow, type MetadataRowProps, type ResponseSegment, type StatusItem, type ThinkingContent, ThinkingSection, type ThinkingSectionProps, type ThinkingStep, type TimelineEntry, type TimelineEntryType, type TimelineUIState, type ToolCall, TruncatedMessage, type TruncatedMessageProps, type UseAgentResponseAccumulatorOptions, type UseAgentResponseAccumulatorReturn, type UseThinkingTimerOptions, UserPrompt, UserPromptInput, type UserPromptInputProps, type UserPromptInputRef, type UserPromptProps, buildResponseString, buildTimelineEntries, createTimelineUIState, deduplicateEntries, formatTime, formatTotalTime, groupIntoAgentRuns, initialAgentResponseState, parseResponseSegments, useAgentResponseAccumulator, useThinkingTimer };
|
|
916
|
+
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseProps, type AgentResponseState, type AgentResponseStatus, type AgentRun, AgentTimeline, type DisplayEntry, type FeedbackValue, type GenericWebSocketMessage, type HITLInteraction, HITLInteractionRecord, type HITLInteractionRecordProps, type HITLQuestion, HITLQuestionPanel, type HITLQuestionPanelProps, type HITLResponseData, HITLSection, type HITLSectionProps, INLINE_ACTION_PROMPT, type InlineActionProps, type KnowledgeItem, type MarkdownSegment, type MemoryItem, MetadataRow, type MetadataRowProps, type PotentialResponse, type ResponseSegment, type StatusItem, type ThinkingContent, ThinkingSection, type ThinkingSectionProps, type ThinkingStep, type TimelineEntry, type TimelineEntryType, type TimelineUIState, type ToolCall, TruncatedMessage, type TruncatedMessageProps, type UseAgentResponseAccumulatorOptions, type UseAgentResponseAccumulatorReturn, type UseThinkingTimerOptions, UserPrompt, UserPromptInput, type UserPromptInputProps, type UserPromptInputRef, type UserPromptProps, buildResponseString, buildTimelineEntries, createTimelineUIState, deduplicateEntries, formatTime, formatTotalTime, groupIntoAgentRuns, initialAgentResponseState, parseResponseSegments, useAgentResponseAccumulator, useThinkingTimer };
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,17 @@ interface MemoryItem {
|
|
|
101
101
|
/** Nesting depth in agent hierarchy */
|
|
102
102
|
depth?: number;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Potential response (sub-agent intermediate AI response)
|
|
106
|
+
*/
|
|
107
|
+
interface PotentialResponse {
|
|
108
|
+
id: string;
|
|
109
|
+
content: string;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
agentName?: string | null;
|
|
112
|
+
parentAgent?: string | null;
|
|
113
|
+
depth?: number;
|
|
114
|
+
}
|
|
104
115
|
/**
|
|
105
116
|
* Status update information from the agent
|
|
106
117
|
*/
|
|
@@ -162,6 +173,10 @@ interface AgentResponseState {
|
|
|
162
173
|
memory: MemoryItem[];
|
|
163
174
|
/** Status updates from the agent */
|
|
164
175
|
statusUpdates: StatusItem[];
|
|
176
|
+
/** Potential responses (sub-agent intermediate AI responses) */
|
|
177
|
+
potentialResponses?: PotentialResponse[];
|
|
178
|
+
/** Custom timeline entries (consumer-provided) */
|
|
179
|
+
customTimelineEntries?: TimelineEntry[];
|
|
165
180
|
/** Final response text */
|
|
166
181
|
response: string;
|
|
167
182
|
/** Timeline entries derived from all accumulator arrays (for AgentTimeline) */
|
|
@@ -177,7 +192,7 @@ interface AgentResponseState {
|
|
|
177
192
|
* WebSocket message payload for agent responses
|
|
178
193
|
*/
|
|
179
194
|
interface AgentMessage {
|
|
180
|
-
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update";
|
|
195
|
+
type: "status" | "thinking" | "tool_call" | "knowledge" | "memory" | "response" | "status_update" | "potential_response";
|
|
181
196
|
/** Message content - for simple string payloads */
|
|
182
197
|
message?: string;
|
|
183
198
|
/** Alternative content field */
|
|
@@ -369,6 +384,11 @@ interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
369
384
|
* />
|
|
370
385
|
*/
|
|
371
386
|
renderThinkingMarkdown?: (content: string) => React.ReactNode;
|
|
387
|
+
/**
|
|
388
|
+
* Maximum height of the AgentTimeline scrollable container.
|
|
389
|
+
* Defaults to "300px". Set to "none" to disable the constraint.
|
|
390
|
+
*/
|
|
391
|
+
timelineMaxHeight?: string;
|
|
372
392
|
}
|
|
373
393
|
/**
|
|
374
394
|
* AgentResponse Component
|
|
@@ -893,4 +913,4 @@ declare function parseResponseSegments(text: string): ResponseSegment[];
|
|
|
893
913
|
*/
|
|
894
914
|
declare const INLINE_ACTION_PROMPT = "\n<inline_actions>\nWhen your response should include interactive components (like query viewers,\ndata tables, or executable actions), embed them as fenced code blocks using\nthe `json:action` language tag:\n\n```json:action\n{\n \"type\": \"action-type-here\",\n ...action-specific fields\n}\n```\n\nRules:\n- Each block must contain valid JSON with a \"type\" field.\n- The \"type\" must match a registered action component on the frontend.\n- Multiple action blocks per response are allowed.\n- Surround action blocks with normal markdown text for user context.\n- The action block is rendered as an interactive component in the chat UI.\n- SQL strings inside JSON must be properly escaped (newlines as \\n, quotes as \\\").\n\nAvailable action types:\n\n- \"optimap-query\": Displays SQL queries with a button to execute them and\n update the 3D globe map.\n Required fields:\n - type: \"optimap-query\"\n - locations_sql: string (the validated locations SQL query)\n - routes_sql: string (the validated routes SQL query)\n - database_name: string (the target database name)\n</inline_actions>\n";
|
|
895
915
|
|
|
896
|
-
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseProps, type AgentResponseState, type AgentResponseStatus, type AgentRun, AgentTimeline, type DisplayEntry, type FeedbackValue, type GenericWebSocketMessage, type HITLInteraction, HITLInteractionRecord, type HITLInteractionRecordProps, type HITLQuestion, HITLQuestionPanel, type HITLQuestionPanelProps, type HITLResponseData, HITLSection, type HITLSectionProps, INLINE_ACTION_PROMPT, type InlineActionProps, type KnowledgeItem, type MarkdownSegment, type MemoryItem, MetadataRow, type MetadataRowProps, type ResponseSegment, type StatusItem, type ThinkingContent, ThinkingSection, type ThinkingSectionProps, type ThinkingStep, type TimelineEntry, type TimelineEntryType, type TimelineUIState, type ToolCall, TruncatedMessage, type TruncatedMessageProps, type UseAgentResponseAccumulatorOptions, type UseAgentResponseAccumulatorReturn, type UseThinkingTimerOptions, UserPrompt, UserPromptInput, type UserPromptInputProps, type UserPromptInputRef, type UserPromptProps, buildResponseString, buildTimelineEntries, createTimelineUIState, deduplicateEntries, formatTime, formatTotalTime, groupIntoAgentRuns, initialAgentResponseState, parseResponseSegments, useAgentResponseAccumulator, useThinkingTimer };
|
|
916
|
+
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseProps, type AgentResponseState, type AgentResponseStatus, type AgentRun, AgentTimeline, type DisplayEntry, type FeedbackValue, type GenericWebSocketMessage, type HITLInteraction, HITLInteractionRecord, type HITLInteractionRecordProps, type HITLQuestion, HITLQuestionPanel, type HITLQuestionPanelProps, type HITLResponseData, HITLSection, type HITLSectionProps, INLINE_ACTION_PROMPT, type InlineActionProps, type KnowledgeItem, type MarkdownSegment, type MemoryItem, MetadataRow, type MetadataRowProps, type PotentialResponse, type ResponseSegment, type StatusItem, type ThinkingContent, ThinkingSection, type ThinkingSectionProps, type ThinkingStep, type TimelineEntry, type TimelineEntryType, type TimelineUIState, type ToolCall, TruncatedMessage, type TruncatedMessageProps, type UseAgentResponseAccumulatorOptions, type UseAgentResponseAccumulatorReturn, type UseThinkingTimerOptions, UserPrompt, UserPromptInput, type UserPromptInputProps, type UserPromptInputRef, type UserPromptProps, buildResponseString, buildTimelineEntries, createTimelineUIState, deduplicateEntries, formatTime, formatTotalTime, groupIntoAgentRuns, initialAgentResponseState, parseResponseSegments, useAgentResponseAccumulator, useThinkingTimer };
|
package/dist/index.js
CHANGED
|
@@ -234,7 +234,7 @@ var ThinkingSection = React11.forwardRef(
|
|
|
234
234
|
ref,
|
|
235
235
|
className: cn("px-3 pb-3 border-t border-border", className),
|
|
236
236
|
...props,
|
|
237
|
-
children: /* @__PURE__ */ jsx("div", { className: "mt-2 max-h-[200px] overflow-y-auto
|
|
237
|
+
children: /* @__PURE__ */ jsx("div", { className: "mt-2 max-h-[200px] overflow-y-auto", children: isStructured ? /* @__PURE__ */ jsx("div", { className: "space-y-0", children: content.map((step) => /* @__PURE__ */ jsx(
|
|
238
238
|
ThinkingStepItem,
|
|
239
239
|
{
|
|
240
240
|
step,
|
|
@@ -678,6 +678,8 @@ var initialAgentResponseState = {
|
|
|
678
678
|
knowledge: [],
|
|
679
679
|
memory: [],
|
|
680
680
|
statusUpdates: [],
|
|
681
|
+
potentialResponses: [],
|
|
682
|
+
customTimelineEntries: [],
|
|
681
683
|
response: "",
|
|
682
684
|
thinkingStartTime: null,
|
|
683
685
|
responseCompleteTime: null,
|
|
@@ -765,6 +767,24 @@ function buildTimelineEntries(state) {
|
|
|
765
767
|
timestamp: item.timestamp
|
|
766
768
|
});
|
|
767
769
|
}
|
|
770
|
+
if (state.potentialResponses) {
|
|
771
|
+
let respIdx = 0;
|
|
772
|
+
for (const resp of state.potentialResponses) {
|
|
773
|
+
entries.push({
|
|
774
|
+
id: `tl-resp-${respIdx++}`,
|
|
775
|
+
type: "ai_response",
|
|
776
|
+
agentName: resp.agentName ?? null,
|
|
777
|
+
parentAgent: resp.parentAgent ?? null,
|
|
778
|
+
depth: resp.depth ?? 0,
|
|
779
|
+
content: resp.content,
|
|
780
|
+
title: null,
|
|
781
|
+
timestamp: resp.timestamp
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (state.customTimelineEntries) {
|
|
786
|
+
entries.push(...state.customTimelineEntries);
|
|
787
|
+
}
|
|
768
788
|
entries.sort((a, b) => a.timestamp - b.timestamp);
|
|
769
789
|
return entries;
|
|
770
790
|
}
|
|
@@ -972,6 +992,27 @@ function useAgentResponseAccumulator(options) {
|
|
|
972
992
|
}
|
|
973
993
|
return { ...prev, status: newStatus, firstMessageTime };
|
|
974
994
|
}
|
|
995
|
+
case "potential_response": {
|
|
996
|
+
const respContent = payload.message || payload.content || "";
|
|
997
|
+
if (respContent) {
|
|
998
|
+
const newResp = {
|
|
999
|
+
id: `resp-${Date.now()}`,
|
|
1000
|
+
content: respContent,
|
|
1001
|
+
timestamp: Date.now(),
|
|
1002
|
+
agentName: payload.agentName,
|
|
1003
|
+
parentAgent: payload.parentAgent,
|
|
1004
|
+
depth: payload.depth
|
|
1005
|
+
};
|
|
1006
|
+
const next = {
|
|
1007
|
+
...prev,
|
|
1008
|
+
status: newStatus,
|
|
1009
|
+
potentialResponses: [...prev.potentialResponses || [], newResp],
|
|
1010
|
+
firstMessageTime
|
|
1011
|
+
};
|
|
1012
|
+
return { ...next, timelineEntries: buildTimelineEntries(next) };
|
|
1013
|
+
}
|
|
1014
|
+
return { ...prev, status: newStatus, firstMessageTime };
|
|
1015
|
+
}
|
|
975
1016
|
default:
|
|
976
1017
|
return { ...prev, status: newStatus, firstMessageTime };
|
|
977
1018
|
}
|
|
@@ -1183,7 +1224,7 @@ function AgentTimeline({ entries, renderMarkdown, uiState, maxHeight = "300px" }
|
|
|
1183
1224
|
"div",
|
|
1184
1225
|
{
|
|
1185
1226
|
ref: containerRef,
|
|
1186
|
-
className:
|
|
1227
|
+
className: maxHeight !== "none" ? "overflow-y-auto" : "",
|
|
1187
1228
|
style: scrollStyle,
|
|
1188
1229
|
children: [
|
|
1189
1230
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-10 bg-background flex items-center gap-1 py-1.5 mb-1 border-b border-border/50 flex-wrap", children: [
|
|
@@ -1282,6 +1323,7 @@ var AgentResponse = React11.forwardRef(
|
|
|
1282
1323
|
statusContent,
|
|
1283
1324
|
renderMarkdown,
|
|
1284
1325
|
renderThinkingMarkdown,
|
|
1326
|
+
timelineMaxHeight,
|
|
1285
1327
|
className,
|
|
1286
1328
|
...props
|
|
1287
1329
|
}, ref) => {
|
|
@@ -1343,12 +1385,13 @@ var AgentResponse = React11.forwardRef(
|
|
|
1343
1385
|
elapsedTime
|
|
1344
1386
|
}
|
|
1345
1387
|
),
|
|
1346
|
-
hasTimelineEntries ? thinkingExpanded && /* @__PURE__ */ jsx("div", { className: "
|
|
1388
|
+
hasTimelineEntries ? thinkingExpanded && /* @__PURE__ */ jsx("div", { className: "pl-3 pb-3 border-t border-border", children: /* @__PURE__ */ jsx(
|
|
1347
1389
|
AgentTimeline,
|
|
1348
1390
|
{
|
|
1349
1391
|
entries: state.timelineEntries,
|
|
1350
1392
|
renderMarkdown: renderThinkingMarkdown,
|
|
1351
|
-
uiState: timelineUIStateRef.current
|
|
1393
|
+
uiState: timelineUIStateRef.current,
|
|
1394
|
+
maxHeight: timelineMaxHeight
|
|
1352
1395
|
}
|
|
1353
1396
|
) }) : /* @__PURE__ */ jsx(
|
|
1354
1397
|
ThinkingSection,
|