@optilogic/chat 1.0.0-beta.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +136 -0
  2. package/dist/index.cjs +989 -58
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +361 -2
  5. package/dist/index.d.ts +361 -2
  6. package/dist/index.js +964 -46
  7. package/dist/index.js.map +1 -1
  8. package/package.json +3 -3
  9. package/src/components/agent-response/AgentResponse.tsx +86 -14
  10. package/src/components/agent-response/components/HITLSection.tsx +95 -0
  11. package/src/components/agent-response/components/MetadataRow.tsx +15 -4
  12. package/src/components/agent-response/components/TruncatedMessage.tsx +52 -0
  13. package/src/components/agent-response/components/index.ts +6 -0
  14. package/src/components/agent-response/hooks/useAgentResponseAccumulator.ts +65 -8
  15. package/src/components/agent-response/index.ts +21 -0
  16. package/src/components/agent-response/types.ts +61 -1
  17. package/src/components/agent-timeline/AgentTimeline.tsx +256 -0
  18. package/src/components/agent-timeline/TimelineAgentBlock.tsx +84 -0
  19. package/src/components/agent-timeline/TimelineItem.tsx +97 -0
  20. package/src/components/agent-timeline/index.ts +14 -0
  21. package/src/components/agent-timeline/types.ts +49 -0
  22. package/src/components/agent-timeline/utils.ts +189 -0
  23. package/src/components/hitl-interactions/HITLInteractionRecord.tsx +139 -0
  24. package/src/components/hitl-interactions/HITLQuestionPanel.tsx +270 -0
  25. package/src/components/hitl-interactions/index.ts +18 -0
  26. package/src/components/inline-actions/ActionMarkdownRenderer.tsx +60 -0
  27. package/src/components/inline-actions/index.ts +18 -0
  28. package/src/components/inline-actions/parseResponseSegments.ts +66 -0
  29. package/src/components/inline-actions/prompts.ts +41 -0
  30. package/src/components/inline-actions/types.ts +57 -0
  31. package/src/components/user-prompt-input/UserPromptInput.tsx +13 -8
  32. package/src/components/user-prompt-input/types.ts +4 -0
  33. package/src/index.ts +42 -0
package/README.md CHANGED
@@ -70,6 +70,113 @@ function ChatInput() {
70
70
  }
71
71
  ```
72
72
 
73
+ ### HITLQuestionPanel
74
+
75
+ Display an interactive panel for human-in-the-loop clarifying questions. Replaces the input area when the agent needs user clarification:
76
+
77
+ ```tsx
78
+ import { HITLQuestionPanel, type HITLQuestion } from '@optilogic/chat';
79
+
80
+ const question: HITLQuestion = {
81
+ reason: "I need clarification before proceeding with the data mapping.",
82
+ questions: [
83
+ "Which table should I load the shipment data into?",
84
+ "Should I overwrite existing rows or append?",
85
+ ],
86
+ options: {
87
+ "Which table should I load the shipment data into?": ["Customers", "Demand", "Shipments"],
88
+ "Should I overwrite existing rows or append?": ["Overwrite", "Append"],
89
+ },
90
+ context: "Source file has 1,200 rows with columns: origin, destination, quantity, date",
91
+ timeoutSeconds: 300,
92
+ receivedAt: Date.now(),
93
+ };
94
+
95
+ function ChatInput() {
96
+ return (
97
+ <HITLQuestionPanel
98
+ question={question}
99
+ onSubmit={(response) => console.log('Response:', response)}
100
+ onStop={() => console.log('Agent stopped')}
101
+ />
102
+ );
103
+ }
104
+ ```
105
+
106
+ ### HITLInteractionRecord
107
+
108
+ Display a completed HITL Q&A interaction in the chat history:
109
+
110
+ ```tsx
111
+ import { HITLInteractionRecord, type HITLInteraction } from '@optilogic/chat';
112
+
113
+ const interaction: HITLInteraction = {
114
+ question: { /* HITLQuestion object */ },
115
+ response: "Q: Which table?\nA: Shipments",
116
+ respondedAt: Date.now(),
117
+ };
118
+
119
+ function CompletedInteraction() {
120
+ return <HITLInteractionRecord interaction={interaction} />;
121
+ }
122
+ ```
123
+
124
+ ### AgentResponse with HITL Interactions
125
+
126
+ HITL interactions can also be displayed as a collapsible section within AgentResponse:
127
+
128
+ ```tsx
129
+ import { AgentResponse, type HITLInteraction } from '@optilogic/chat';
130
+
131
+ function ChatView() {
132
+ const hitlInteractions: HITLInteraction[] = [/* completed interactions */];
133
+
134
+ return (
135
+ <AgentResponse
136
+ state={state}
137
+ hitlInteractions={hitlInteractions}
138
+ defaultHITLExpanded={false}
139
+ />
140
+ );
141
+ }
142
+ ```
143
+
144
+ ### AgentResponse with Status Content
145
+
146
+ Display ephemeral status messages in the metadata row during agent processing:
147
+
148
+ ```tsx
149
+ import { AgentResponse, TruncatedMessage } from '@optilogic/chat';
150
+
151
+ function ChatView() {
152
+ const [statusMessage, setStatusMessage] = useState<string>();
153
+
154
+ // Parent controls when to show/clear status content
155
+ // e.g., set during processing, clear on completion
156
+
157
+ return (
158
+ <AgentResponse
159
+ state={state}
160
+ statusContent={
161
+ statusMessage
162
+ ? <TruncatedMessage message={statusMessage} />
163
+ : undefined
164
+ }
165
+ />
166
+ );
167
+ }
168
+ ```
169
+
170
+ ### TruncatedMessage
171
+
172
+ Standalone component that renders a single-line string with CSS-based truncation:
173
+
174
+ ```tsx
175
+ import { TruncatedMessage } from '@optilogic/chat';
176
+
177
+ <TruncatedMessage message="Searching the knowledge base for relevant documents..." />
178
+ ```
179
+
73
180
  ## Components
74
181
 
75
182
  ### AgentResponse
@@ -79,6 +186,8 @@ Main component for displaying AI agent responses with:
79
186
  - Tool call visualization
80
187
  - Copy and feedback actions
81
188
  - Metadata display (tokens, timing)
189
+ - Ephemeral status content slot in metadata row
190
+ - Optional collapsible HITL interaction history
82
191
 
83
192
  ### UserPrompt
84
193
  Component for displaying user messages in the chat interface.
@@ -86,6 +195,28 @@ Component for displaying user messages in the chat interface.
86
195
  ### UserPromptInput
87
196
  Input component for composing user messages with tag support.
88
197
 
198
+ ### HITLQuestionPanel
199
+ Interactive panel for displaying agent clarifying questions with:
200
+ - Predefined option buttons (toggleable selection)
201
+ - Free-form text input
202
+ - Countdown timer with visual warning state
203
+ - Keyboard support (Enter to submit, Shift+Enter for newlines)
204
+
205
+ ### HITLInteractionRecord
206
+ Read-only display of a completed HITL Q&A interaction with:
207
+ - Per-question inline answers
208
+ - Context display
209
+ - Fallback for non-structured response formats
210
+
211
+ ### HITLSection
212
+ Collapsible sub-component for rendering HITL interactions within AgentResponse. Follows the same expand/collapse pattern as ThinkingSection.
213
+
214
+ ### TruncatedMessage
215
+ Standalone utility component for single-line text truncation with:
216
+ - CSS-based ellipsis truncation
217
+ - Native title tooltip for full text on hover
218
+ - Designed for use in MetadataRow status slot or anywhere else
219
+
89
220
  ## Hooks
90
221
 
91
222
  ### useAgentResponseAccumulator
@@ -94,6 +225,11 @@ Manages state for streaming agent responses, handling incremental updates and me
94
225
  ### useThinkingTimer
95
226
  Tracks elapsed time during agent thinking phases.
96
227
 
228
+ ## Utilities
229
+
230
+ ### buildResponseString
231
+ Combines selected options and free-form text into a single formatted string for the backend. Used internally by HITLQuestionPanel and can be used to construct responses programmatically.
232
+
97
233
  ## License
98
234
 
99
235
  MIT