@optilogic/chat 1.0.0-beta.10 → 1.0.0-beta.12
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 +616 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +223 -3
- package/dist/index.d.ts +223 -3
- package/dist/index.js +610 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/agent-response/AgentResponse.tsx +31 -13
- package/src/components/agent-response/components/ThinkingSection.tsx +1 -1
- package/src/components/agent-response/hooks/useAgentResponseAccumulator.ts +65 -8
- package/src/components/agent-response/index.ts +17 -0
- package/src/components/agent-response/types.ts +61 -1
- package/src/components/agent-timeline/AgentTimeline.tsx +256 -0
- package/src/components/agent-timeline/TimelineAgentBlock.tsx +84 -0
- package/src/components/agent-timeline/TimelineItem.tsx +97 -0
- package/src/components/agent-timeline/index.ts +14 -0
- package/src/components/agent-timeline/types.ts +49 -0
- package/src/components/agent-timeline/utils.ts +189 -0
- package/src/components/hitl-interactions/HITLQuestionPanel.tsx +9 -2
- package/src/components/hitl-interactions/index.ts +1 -1
- package/src/components/inline-actions/ActionMarkdownRenderer.tsx +60 -0
- package/src/components/inline-actions/index.ts +18 -0
- package/src/components/inline-actions/parseResponseSegments.ts +66 -0
- package/src/components/inline-actions/prompts.ts +41 -0
- package/src/components/inline-actions/types.ts +57 -0
- package/src/index.ts +27 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactNode, ComponentType } from "react";
|
|
2
|
+
|
|
3
|
+
// --- Segment types (output of parser) ---
|
|
4
|
+
|
|
5
|
+
export interface MarkdownSegment {
|
|
6
|
+
kind: "markdown";
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ActionSegment {
|
|
11
|
+
kind: "action";
|
|
12
|
+
actionType: string;
|
|
13
|
+
payload: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ResponseSegment = MarkdownSegment | ActionSegment;
|
|
17
|
+
|
|
18
|
+
// --- Component props ---
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Props passed to every inline action component.
|
|
22
|
+
* T is the shape of the payload for this specific action type.
|
|
23
|
+
*/
|
|
24
|
+
export interface InlineActionProps<T = Record<string, unknown>> {
|
|
25
|
+
/** The parsed payload from the json:action block */
|
|
26
|
+
payload: T;
|
|
27
|
+
/** Callback to send results back to the page (e.g., map data) */
|
|
28
|
+
onAction?: (actionType: string, result: unknown) => void;
|
|
29
|
+
/** True for the most recent agent message; affects button labels */
|
|
30
|
+
isLatest?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// --- Registry ---
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Maps action type strings to React components that render them.
|
|
37
|
+
* The consuming page owns this registry.
|
|
38
|
+
*/
|
|
39
|
+
export type ActionComponentRegistry = Record<
|
|
40
|
+
string,
|
|
41
|
+
ComponentType<InlineActionProps<any>>
|
|
42
|
+
>;
|
|
43
|
+
|
|
44
|
+
// --- Renderer props ---
|
|
45
|
+
|
|
46
|
+
export interface ActionMarkdownRendererProps {
|
|
47
|
+
/** The raw response text (may contain json:action blocks) */
|
|
48
|
+
content: string;
|
|
49
|
+
/** Registry of action type -> component */
|
|
50
|
+
registry: ActionComponentRegistry;
|
|
51
|
+
/** The existing renderMarkdown function for plain markdown segments */
|
|
52
|
+
renderMarkdown: (content: string) => ReactNode;
|
|
53
|
+
/** Callback forwarded to action components */
|
|
54
|
+
onAction?: (actionType: string, result: unknown) => void;
|
|
55
|
+
/** Whether this is the latest (most recent) agent message */
|
|
56
|
+
isLatest?: boolean;
|
|
57
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ export {
|
|
|
41
41
|
type StatusItem,
|
|
42
42
|
type ThinkingStep,
|
|
43
43
|
type ThinkingContent,
|
|
44
|
+
type PotentialResponse,
|
|
44
45
|
type AgentMessage,
|
|
45
46
|
type GenericWebSocketMessage,
|
|
46
47
|
|
|
@@ -50,6 +51,18 @@ export {
|
|
|
50
51
|
// Utilities
|
|
51
52
|
formatTime,
|
|
52
53
|
formatTotalTime,
|
|
54
|
+
|
|
55
|
+
// Agent Timeline (replaces ThinkingSection for rich execution visibility)
|
|
56
|
+
AgentTimeline,
|
|
57
|
+
createTimelineUIState,
|
|
58
|
+
buildTimelineEntries,
|
|
59
|
+
groupIntoAgentRuns,
|
|
60
|
+
deduplicateEntries,
|
|
61
|
+
type TimelineUIState,
|
|
62
|
+
type TimelineEntry,
|
|
63
|
+
type TimelineEntryType,
|
|
64
|
+
type AgentRun,
|
|
65
|
+
type DisplayEntry,
|
|
53
66
|
} from "./components/agent-response";
|
|
54
67
|
|
|
55
68
|
// User Prompt - Component for displaying user messages
|
|
@@ -70,5 +83,19 @@ export {
|
|
|
70
83
|
type HITLInteractionRecordProps,
|
|
71
84
|
type HITLQuestion,
|
|
72
85
|
type HITLInteraction,
|
|
86
|
+
type HITLResponseData,
|
|
73
87
|
buildResponseString,
|
|
74
88
|
} from "./components/hitl-interactions";
|
|
89
|
+
|
|
90
|
+
// Inline Actions - Components for rendering interactive actions within markdown
|
|
91
|
+
export {
|
|
92
|
+
ActionMarkdownRenderer,
|
|
93
|
+
parseResponseSegments,
|
|
94
|
+
INLINE_ACTION_PROMPT,
|
|
95
|
+
type ResponseSegment,
|
|
96
|
+
type MarkdownSegment,
|
|
97
|
+
type ActionSegment,
|
|
98
|
+
type InlineActionProps,
|
|
99
|
+
type ActionComponentRegistry,
|
|
100
|
+
type ActionMarkdownRendererProps,
|
|
101
|
+
} from "./components/inline-actions";
|