@optilogic/chat 1.3.3 → 1.3.5
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 +233 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -2
- package/dist/index.d.ts +132 -2
- package/dist/index.js +233 -185
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/agent-response/AgentResponse.tsx +63 -1
- package/src/components/agent-response/components/ActionBar.tsx +15 -0
- package/src/components/agent-response/components/ActivityIndicators.tsx +27 -1
- package/src/components/agent-response/components/MetadataRow.tsx +20 -0
- package/src/components/agent-response/hooks/useAgentResponseAccumulator.ts +6 -216
- package/src/components/agent-response/index.ts +8 -1
- package/src/components/agent-response/reducer.ts +252 -0
- package/src/components/agent-response/types.ts +8 -0
- package/src/components/user-prompt-input/UserPromptInput.tsx +3 -0
- package/src/components/user-prompt-input/types.ts +13 -0
- package/src/index.ts +5 -0
package/dist/index.d.cts
CHANGED
|
@@ -197,6 +197,14 @@ interface AgentMessage {
|
|
|
197
197
|
message?: string;
|
|
198
198
|
/** Alternative content field */
|
|
199
199
|
content?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Optional event timestamp (epoch ms). When supplied, the reducer uses this
|
|
202
|
+
* for the item's `timestamp` and any state-level timing fields it sets
|
|
203
|
+
* (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`) instead
|
|
204
|
+
* of `Date.now()`. Provide this when replaying historical events so durations
|
|
205
|
+
* reflect the original run rather than load time.
|
|
206
|
+
*/
|
|
207
|
+
timestamp?: number;
|
|
200
208
|
/** For status messages */
|
|
201
209
|
status?: string;
|
|
202
210
|
/** Agent name (multi-agent scenarios) */
|
|
@@ -324,6 +332,41 @@ interface AgentResponseClassNames {
|
|
|
324
332
|
/** Classes for the response content section (background, padding) */
|
|
325
333
|
response?: string;
|
|
326
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Tour anchors (`data-tour` attribute values) to attach to specific elements
|
|
337
|
+
* inside an AgentResponse so a tour or test harness can target them.
|
|
338
|
+
*
|
|
339
|
+
* Each value, when provided, is rendered as `data-tour={value}` on the
|
|
340
|
+
* corresponding element. Omit a field to skip stamping the attribute on that
|
|
341
|
+
* element. Pair with the matching CSS selector form:
|
|
342
|
+
*
|
|
343
|
+
* <AgentResponse anchors={{ copyAction: "chat-action-copy" }} />
|
|
344
|
+
* // selector: '[data-tour="chat-action-copy"]'
|
|
345
|
+
*
|
|
346
|
+
* This is the standard convention in the @optilogic component library for
|
|
347
|
+
* threading tour IDs into elements that are rendered by internal
|
|
348
|
+
* sub-components and not otherwise reachable from the caller.
|
|
349
|
+
*/
|
|
350
|
+
interface AgentResponseAnchors {
|
|
351
|
+
/** Status updates popover trigger in the metadata row (live status indicator). */
|
|
352
|
+
statusUpdate?: string;
|
|
353
|
+
/** Thinking expand/collapse toggle button in the metadata row. */
|
|
354
|
+
thinkingToggle?: string;
|
|
355
|
+
/** Thinking section content panel (when expanded). */
|
|
356
|
+
thinkingSection?: string;
|
|
357
|
+
/** Tool calls popover trigger in the metadata row. */
|
|
358
|
+
toolCalls?: string;
|
|
359
|
+
/** Knowledge popover trigger in the metadata row. */
|
|
360
|
+
knowledge?: string;
|
|
361
|
+
/** Memory popover trigger in the metadata row. */
|
|
362
|
+
memory?: string;
|
|
363
|
+
/** Copy button in the action bar. */
|
|
364
|
+
copyAction?: string;
|
|
365
|
+
/** Thumbs up button in the action bar. */
|
|
366
|
+
thumbsUp?: string;
|
|
367
|
+
/** Thumbs down button in the action bar. */
|
|
368
|
+
thumbsDown?: string;
|
|
369
|
+
}
|
|
327
370
|
interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
328
371
|
/** The response state to render */
|
|
329
372
|
state: AgentResponseState;
|
|
@@ -410,6 +453,21 @@ interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
410
453
|
* />
|
|
411
454
|
*/
|
|
412
455
|
classNames?: AgentResponseClassNames;
|
|
456
|
+
/**
|
|
457
|
+
* Tour anchors threaded into internal sub-components. See
|
|
458
|
+
* {@link AgentResponseAnchors} for the available element keys.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* <AgentResponse
|
|
462
|
+
* state={state}
|
|
463
|
+
* anchors={{
|
|
464
|
+
* copyAction: "chat-action-copy",
|
|
465
|
+
* thumbsUp: "chat-action-thumbs-up",
|
|
466
|
+
* thumbsDown: "chat-action-thumbs-down",
|
|
467
|
+
* }}
|
|
468
|
+
* />
|
|
469
|
+
*/
|
|
470
|
+
anchors?: AgentResponseAnchors;
|
|
413
471
|
}
|
|
414
472
|
/**
|
|
415
473
|
* AgentResponse Component
|
|
@@ -460,6 +518,14 @@ interface ActivityIndicatorsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
460
518
|
memory: MemoryItem[];
|
|
461
519
|
/** Status updates to display */
|
|
462
520
|
statusUpdates?: StatusItem[];
|
|
521
|
+
/** Tour anchor (`data-tour`) on the status updates popover trigger. */
|
|
522
|
+
statusUpdateAnchor?: string;
|
|
523
|
+
/** Tour anchor (`data-tour`) on the tool calls popover trigger. */
|
|
524
|
+
toolCallsAnchor?: string;
|
|
525
|
+
/** Tour anchor (`data-tour`) on the knowledge popover trigger. */
|
|
526
|
+
knowledgeAnchor?: string;
|
|
527
|
+
/** Tour anchor (`data-tour`) on the memory popover trigger. */
|
|
528
|
+
memoryAnchor?: string;
|
|
463
529
|
}
|
|
464
530
|
/**
|
|
465
531
|
* ActivityIndicators Component
|
|
@@ -503,6 +569,16 @@ interface MetadataRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
503
569
|
status: AgentResponseStatus;
|
|
504
570
|
/** Elapsed time in seconds */
|
|
505
571
|
elapsedTime: number;
|
|
572
|
+
/** Tour anchor (`data-tour`) on the thinking expand/collapse toggle button. */
|
|
573
|
+
thinkingToggleAnchor?: string;
|
|
574
|
+
/** Tour anchor forwarded to the status updates popover trigger inside ActivityIndicators. */
|
|
575
|
+
statusUpdateAnchor?: string;
|
|
576
|
+
/** Tour anchor forwarded to the tool calls popover trigger inside ActivityIndicators. */
|
|
577
|
+
toolCallsAnchor?: string;
|
|
578
|
+
/** Tour anchor forwarded to the knowledge popover trigger inside ActivityIndicators. */
|
|
579
|
+
knowledgeAnchor?: string;
|
|
580
|
+
/** Tour anchor forwarded to the memory popover trigger inside ActivityIndicators. */
|
|
581
|
+
memoryAnchor?: string;
|
|
506
582
|
}
|
|
507
583
|
/**
|
|
508
584
|
* MetadataRow Component
|
|
@@ -583,6 +659,15 @@ interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
583
659
|
onFeedbackChange?: (feedback: FeedbackValue) => void;
|
|
584
660
|
/** Callback when response is copied */
|
|
585
661
|
onResponseCopy?: (response: string) => void;
|
|
662
|
+
/**
|
|
663
|
+
* Tour anchor (rendered as `data-tour`) on the copy button.
|
|
664
|
+
* Use with the `data-tour` convention to target this button from a tour step.
|
|
665
|
+
*/
|
|
666
|
+
copyAnchor?: string;
|
|
667
|
+
/** Tour anchor (`data-tour`) on the thumbs up button. */
|
|
668
|
+
thumbsUpAnchor?: string;
|
|
669
|
+
/** Tour anchor (`data-tour`) on the thumbs down button. */
|
|
670
|
+
thumbsDownAnchor?: string;
|
|
586
671
|
}
|
|
587
672
|
/**
|
|
588
673
|
* ActionBar Component
|
|
@@ -672,7 +757,10 @@ declare function useThinkingTimer({ startTime, endTime, status, }: UseThinkingTi
|
|
|
672
757
|
/**
|
|
673
758
|
* useAgentResponseAccumulator Hook
|
|
674
759
|
*
|
|
675
|
-
* Accumulates agent response messages into a unified state
|
|
760
|
+
* Accumulates agent response messages into a unified state.
|
|
761
|
+
*
|
|
762
|
+
* Thin wrapper around `reduceAgentMessage` — the pure reducer can be used
|
|
763
|
+
* directly outside React for replaying historical events.
|
|
676
764
|
*/
|
|
677
765
|
|
|
678
766
|
interface UseAgentResponseAccumulatorOptions {
|
|
@@ -700,6 +788,36 @@ interface UseAgentResponseAccumulatorReturn {
|
|
|
700
788
|
*/
|
|
701
789
|
declare function useAgentResponseAccumulator(options?: UseAgentResponseAccumulatorOptions): UseAgentResponseAccumulatorReturn;
|
|
702
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Pure reducer for agent response messages.
|
|
793
|
+
*
|
|
794
|
+
* Used by `useAgentResponseAccumulator` for live streaming, and exported so
|
|
795
|
+
* non-React callers (e.g. server-side or store-based replay of historical
|
|
796
|
+
* conversations) can rebuild the same `AgentResponseState` from a sequence of
|
|
797
|
+
* `AgentMessage` events without rendering a component.
|
|
798
|
+
*
|
|
799
|
+
* Replay note on stable IDs: when a payload omits a per-item id
|
|
800
|
+
* (`tool.id`, `thinkingStep.id`, `knowledge.id`, `memory.id`,
|
|
801
|
+
* `statusUpdate.id`), the reducer falls back to `${type}-${Date.now()}`. That
|
|
802
|
+
* is fine for live streams but will produce different React keys on each
|
|
803
|
+
* replay. Callers reconstructing `AgentMessage` events from persisted rows
|
|
804
|
+
* should populate these ids from a stable source (e.g. the supplement-row
|
|
805
|
+
* primary key) so timeline keys remain consistent across reloads.
|
|
806
|
+
*/
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Pure reducer: apply a single `AgentMessage` to the accumulated state.
|
|
810
|
+
*
|
|
811
|
+
* `payload.timestamp` (epoch ms), if supplied, is used for the new item's
|
|
812
|
+
* `timestamp` and any state-level timing fields this call sets
|
|
813
|
+
* (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`). When
|
|
814
|
+
* absent, `Date.now()` is used — matching the prior live-streaming behaviour.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* const state = events.reduce(reduceAgentMessage, initialAgentResponseState);
|
|
818
|
+
*/
|
|
819
|
+
declare function reduceAgentMessage(prev: AgentResponseState, payload: AgentMessage): AgentResponseState;
|
|
820
|
+
|
|
703
821
|
/**
|
|
704
822
|
* Agent Response Utility Functions
|
|
705
823
|
*/
|
|
@@ -832,6 +950,18 @@ interface UserPromptInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
832
950
|
onTagCreate?: (tag: string) => void;
|
|
833
951
|
/** Callback when a tag is deleted */
|
|
834
952
|
onTagDelete?: (tag: string) => void;
|
|
953
|
+
/** Tour anchors threaded onto internal sub-elements. */
|
|
954
|
+
anchors?: UserPromptInputAnchors;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Tour anchors (`data-tour` attribute values) for elements inside the
|
|
958
|
+
* UserPromptInput that the caller cannot otherwise reach.
|
|
959
|
+
*/
|
|
960
|
+
interface UserPromptInputAnchors {
|
|
961
|
+
/** Send button (rendered when not submitting). */
|
|
962
|
+
sendButton?: string;
|
|
963
|
+
/** Stop button (rendered while submitting if `onStop` is provided). */
|
|
964
|
+
stopButton?: string;
|
|
835
965
|
}
|
|
836
966
|
interface UserPromptInputRef {
|
|
837
967
|
/** Focus the editor */
|
|
@@ -938,4 +1068,4 @@ declare function parseResponseSegments(text: string): ResponseSegment[];
|
|
|
938
1068
|
*/
|
|
939
1069
|
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";
|
|
940
1070
|
|
|
941
|
-
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 };
|
|
1071
|
+
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseAnchors, type AgentResponseClassNames, 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, reduceAgentMessage, useAgentResponseAccumulator, useThinkingTimer };
|
package/dist/index.d.ts
CHANGED
|
@@ -197,6 +197,14 @@ interface AgentMessage {
|
|
|
197
197
|
message?: string;
|
|
198
198
|
/** Alternative content field */
|
|
199
199
|
content?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Optional event timestamp (epoch ms). When supplied, the reducer uses this
|
|
202
|
+
* for the item's `timestamp` and any state-level timing fields it sets
|
|
203
|
+
* (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`) instead
|
|
204
|
+
* of `Date.now()`. Provide this when replaying historical events so durations
|
|
205
|
+
* reflect the original run rather than load time.
|
|
206
|
+
*/
|
|
207
|
+
timestamp?: number;
|
|
200
208
|
/** For status messages */
|
|
201
209
|
status?: string;
|
|
202
210
|
/** Agent name (multi-agent scenarios) */
|
|
@@ -324,6 +332,41 @@ interface AgentResponseClassNames {
|
|
|
324
332
|
/** Classes for the response content section (background, padding) */
|
|
325
333
|
response?: string;
|
|
326
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Tour anchors (`data-tour` attribute values) to attach to specific elements
|
|
337
|
+
* inside an AgentResponse so a tour or test harness can target them.
|
|
338
|
+
*
|
|
339
|
+
* Each value, when provided, is rendered as `data-tour={value}` on the
|
|
340
|
+
* corresponding element. Omit a field to skip stamping the attribute on that
|
|
341
|
+
* element. Pair with the matching CSS selector form:
|
|
342
|
+
*
|
|
343
|
+
* <AgentResponse anchors={{ copyAction: "chat-action-copy" }} />
|
|
344
|
+
* // selector: '[data-tour="chat-action-copy"]'
|
|
345
|
+
*
|
|
346
|
+
* This is the standard convention in the @optilogic component library for
|
|
347
|
+
* threading tour IDs into elements that are rendered by internal
|
|
348
|
+
* sub-components and not otherwise reachable from the caller.
|
|
349
|
+
*/
|
|
350
|
+
interface AgentResponseAnchors {
|
|
351
|
+
/** Status updates popover trigger in the metadata row (live status indicator). */
|
|
352
|
+
statusUpdate?: string;
|
|
353
|
+
/** Thinking expand/collapse toggle button in the metadata row. */
|
|
354
|
+
thinkingToggle?: string;
|
|
355
|
+
/** Thinking section content panel (when expanded). */
|
|
356
|
+
thinkingSection?: string;
|
|
357
|
+
/** Tool calls popover trigger in the metadata row. */
|
|
358
|
+
toolCalls?: string;
|
|
359
|
+
/** Knowledge popover trigger in the metadata row. */
|
|
360
|
+
knowledge?: string;
|
|
361
|
+
/** Memory popover trigger in the metadata row. */
|
|
362
|
+
memory?: string;
|
|
363
|
+
/** Copy button in the action bar. */
|
|
364
|
+
copyAction?: string;
|
|
365
|
+
/** Thumbs up button in the action bar. */
|
|
366
|
+
thumbsUp?: string;
|
|
367
|
+
/** Thumbs down button in the action bar. */
|
|
368
|
+
thumbsDown?: string;
|
|
369
|
+
}
|
|
327
370
|
interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
328
371
|
/** The response state to render */
|
|
329
372
|
state: AgentResponseState;
|
|
@@ -410,6 +453,21 @@ interface AgentResponseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
410
453
|
* />
|
|
411
454
|
*/
|
|
412
455
|
classNames?: AgentResponseClassNames;
|
|
456
|
+
/**
|
|
457
|
+
* Tour anchors threaded into internal sub-components. See
|
|
458
|
+
* {@link AgentResponseAnchors} for the available element keys.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* <AgentResponse
|
|
462
|
+
* state={state}
|
|
463
|
+
* anchors={{
|
|
464
|
+
* copyAction: "chat-action-copy",
|
|
465
|
+
* thumbsUp: "chat-action-thumbs-up",
|
|
466
|
+
* thumbsDown: "chat-action-thumbs-down",
|
|
467
|
+
* }}
|
|
468
|
+
* />
|
|
469
|
+
*/
|
|
470
|
+
anchors?: AgentResponseAnchors;
|
|
413
471
|
}
|
|
414
472
|
/**
|
|
415
473
|
* AgentResponse Component
|
|
@@ -460,6 +518,14 @@ interface ActivityIndicatorsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
460
518
|
memory: MemoryItem[];
|
|
461
519
|
/** Status updates to display */
|
|
462
520
|
statusUpdates?: StatusItem[];
|
|
521
|
+
/** Tour anchor (`data-tour`) on the status updates popover trigger. */
|
|
522
|
+
statusUpdateAnchor?: string;
|
|
523
|
+
/** Tour anchor (`data-tour`) on the tool calls popover trigger. */
|
|
524
|
+
toolCallsAnchor?: string;
|
|
525
|
+
/** Tour anchor (`data-tour`) on the knowledge popover trigger. */
|
|
526
|
+
knowledgeAnchor?: string;
|
|
527
|
+
/** Tour anchor (`data-tour`) on the memory popover trigger. */
|
|
528
|
+
memoryAnchor?: string;
|
|
463
529
|
}
|
|
464
530
|
/**
|
|
465
531
|
* ActivityIndicators Component
|
|
@@ -503,6 +569,16 @@ interface MetadataRowProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
503
569
|
status: AgentResponseStatus;
|
|
504
570
|
/** Elapsed time in seconds */
|
|
505
571
|
elapsedTime: number;
|
|
572
|
+
/** Tour anchor (`data-tour`) on the thinking expand/collapse toggle button. */
|
|
573
|
+
thinkingToggleAnchor?: string;
|
|
574
|
+
/** Tour anchor forwarded to the status updates popover trigger inside ActivityIndicators. */
|
|
575
|
+
statusUpdateAnchor?: string;
|
|
576
|
+
/** Tour anchor forwarded to the tool calls popover trigger inside ActivityIndicators. */
|
|
577
|
+
toolCallsAnchor?: string;
|
|
578
|
+
/** Tour anchor forwarded to the knowledge popover trigger inside ActivityIndicators. */
|
|
579
|
+
knowledgeAnchor?: string;
|
|
580
|
+
/** Tour anchor forwarded to the memory popover trigger inside ActivityIndicators. */
|
|
581
|
+
memoryAnchor?: string;
|
|
506
582
|
}
|
|
507
583
|
/**
|
|
508
584
|
* MetadataRow Component
|
|
@@ -583,6 +659,15 @@ interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
583
659
|
onFeedbackChange?: (feedback: FeedbackValue) => void;
|
|
584
660
|
/** Callback when response is copied */
|
|
585
661
|
onResponseCopy?: (response: string) => void;
|
|
662
|
+
/**
|
|
663
|
+
* Tour anchor (rendered as `data-tour`) on the copy button.
|
|
664
|
+
* Use with the `data-tour` convention to target this button from a tour step.
|
|
665
|
+
*/
|
|
666
|
+
copyAnchor?: string;
|
|
667
|
+
/** Tour anchor (`data-tour`) on the thumbs up button. */
|
|
668
|
+
thumbsUpAnchor?: string;
|
|
669
|
+
/** Tour anchor (`data-tour`) on the thumbs down button. */
|
|
670
|
+
thumbsDownAnchor?: string;
|
|
586
671
|
}
|
|
587
672
|
/**
|
|
588
673
|
* ActionBar Component
|
|
@@ -672,7 +757,10 @@ declare function useThinkingTimer({ startTime, endTime, status, }: UseThinkingTi
|
|
|
672
757
|
/**
|
|
673
758
|
* useAgentResponseAccumulator Hook
|
|
674
759
|
*
|
|
675
|
-
* Accumulates agent response messages into a unified state
|
|
760
|
+
* Accumulates agent response messages into a unified state.
|
|
761
|
+
*
|
|
762
|
+
* Thin wrapper around `reduceAgentMessage` — the pure reducer can be used
|
|
763
|
+
* directly outside React for replaying historical events.
|
|
676
764
|
*/
|
|
677
765
|
|
|
678
766
|
interface UseAgentResponseAccumulatorOptions {
|
|
@@ -700,6 +788,36 @@ interface UseAgentResponseAccumulatorReturn {
|
|
|
700
788
|
*/
|
|
701
789
|
declare function useAgentResponseAccumulator(options?: UseAgentResponseAccumulatorOptions): UseAgentResponseAccumulatorReturn;
|
|
702
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Pure reducer for agent response messages.
|
|
793
|
+
*
|
|
794
|
+
* Used by `useAgentResponseAccumulator` for live streaming, and exported so
|
|
795
|
+
* non-React callers (e.g. server-side or store-based replay of historical
|
|
796
|
+
* conversations) can rebuild the same `AgentResponseState` from a sequence of
|
|
797
|
+
* `AgentMessage` events without rendering a component.
|
|
798
|
+
*
|
|
799
|
+
* Replay note on stable IDs: when a payload omits a per-item id
|
|
800
|
+
* (`tool.id`, `thinkingStep.id`, `knowledge.id`, `memory.id`,
|
|
801
|
+
* `statusUpdate.id`), the reducer falls back to `${type}-${Date.now()}`. That
|
|
802
|
+
* is fine for live streams but will produce different React keys on each
|
|
803
|
+
* replay. Callers reconstructing `AgentMessage` events from persisted rows
|
|
804
|
+
* should populate these ids from a stable source (e.g. the supplement-row
|
|
805
|
+
* primary key) so timeline keys remain consistent across reloads.
|
|
806
|
+
*/
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Pure reducer: apply a single `AgentMessage` to the accumulated state.
|
|
810
|
+
*
|
|
811
|
+
* `payload.timestamp` (epoch ms), if supplied, is used for the new item's
|
|
812
|
+
* `timestamp` and any state-level timing fields this call sets
|
|
813
|
+
* (`firstMessageTime`, `thinkingStartTime`, `responseCompleteTime`). When
|
|
814
|
+
* absent, `Date.now()` is used — matching the prior live-streaming behaviour.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* const state = events.reduce(reduceAgentMessage, initialAgentResponseState);
|
|
818
|
+
*/
|
|
819
|
+
declare function reduceAgentMessage(prev: AgentResponseState, payload: AgentMessage): AgentResponseState;
|
|
820
|
+
|
|
703
821
|
/**
|
|
704
822
|
* Agent Response Utility Functions
|
|
705
823
|
*/
|
|
@@ -832,6 +950,18 @@ interface UserPromptInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
832
950
|
onTagCreate?: (tag: string) => void;
|
|
833
951
|
/** Callback when a tag is deleted */
|
|
834
952
|
onTagDelete?: (tag: string) => void;
|
|
953
|
+
/** Tour anchors threaded onto internal sub-elements. */
|
|
954
|
+
anchors?: UserPromptInputAnchors;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Tour anchors (`data-tour` attribute values) for elements inside the
|
|
958
|
+
* UserPromptInput that the caller cannot otherwise reach.
|
|
959
|
+
*/
|
|
960
|
+
interface UserPromptInputAnchors {
|
|
961
|
+
/** Send button (rendered when not submitting). */
|
|
962
|
+
sendButton?: string;
|
|
963
|
+
/** Stop button (rendered while submitting if `onStop` is provided). */
|
|
964
|
+
stopButton?: string;
|
|
835
965
|
}
|
|
836
966
|
interface UserPromptInputRef {
|
|
837
967
|
/** Focus the editor */
|
|
@@ -938,4 +1068,4 @@ declare function parseResponseSegments(text: string): ResponseSegment[];
|
|
|
938
1068
|
*/
|
|
939
1069
|
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";
|
|
940
1070
|
|
|
941
|
-
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 };
|
|
1071
|
+
export { ActionBar, type ActionBarProps, type ActionComponentRegistry, ActionMarkdownRenderer, type ActionMarkdownRendererProps, type ActionSegment, ActivityIndicators, type ActivityIndicatorsProps, type AgentMessage, AgentResponse, type AgentResponseAnchors, type AgentResponseClassNames, 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, reduceAgentMessage, useAgentResponseAccumulator, useThinkingTimer };
|