@paymanai/payman-ask-sdk 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.
- package/README.md +184 -0
- package/dist/index.d.mts +388 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.js +820 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +798 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.native.js +1178 -0
- package/dist/index.native.js.map +1 -0
- package/dist/styles.css +86 -0
- package/dist/styles.css.map +1 -0
- package/package.json +106 -0
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Payman Ask SDK
|
|
2
|
+
|
|
3
|
+
A reusable React component library for building chat interfaces powered by Payman workflows.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✅ **Fully Self-Contained** - Handles all API calls, streaming, and state management
|
|
8
|
+
✅ **Type-Safe** - Built with TypeScript for full type safety
|
|
9
|
+
✅ **SSE Streaming** - Real-time message streaming with Server-Sent Events
|
|
10
|
+
✅ **Context API** - Control chat programmatically from parent components
|
|
11
|
+
✅ **Customizable** - Flexible configuration and custom headers
|
|
12
|
+
✅ **Execution Tracing** - Built-in support for execution trace data
|
|
13
|
+
✅ **Session Management** - Automatic session ID generation and tracking
|
|
14
|
+
✅ **Markdown Support** - Rich message formatting with react-markdown
|
|
15
|
+
✅ **Animations** - Smooth animations with Framer Motion
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @paymanai/payman-ask-sdk
|
|
21
|
+
# or
|
|
22
|
+
yarn add @paymanai/payman-ask-sdk
|
|
23
|
+
# or
|
|
24
|
+
bun add @paymanai/payman-ask-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### For Playground/Testing
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { PaymanChat } from "@paymanai/payman-ask-sdk";
|
|
33
|
+
|
|
34
|
+
function MyApp() {
|
|
35
|
+
return (
|
|
36
|
+
<PaymanChat
|
|
37
|
+
config={{
|
|
38
|
+
api: {
|
|
39
|
+
baseUrl: "https://api.example.com",
|
|
40
|
+
authToken: "your-token",
|
|
41
|
+
streamEndpoint: "/api/playground/ask/stream", // Important!
|
|
42
|
+
},
|
|
43
|
+
workflowName: "my-workflow",
|
|
44
|
+
workflowVersion: 1,
|
|
45
|
+
stage: "DEV",
|
|
46
|
+
sessionParams: {
|
|
47
|
+
id: "user-123",
|
|
48
|
+
name: "John Doe",
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
callbacks={{
|
|
52
|
+
onError: (error) => console.error(error),
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### For Production
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
<PaymanChat
|
|
63
|
+
config={{
|
|
64
|
+
api: {
|
|
65
|
+
baseUrl: "https://api.example.com",
|
|
66
|
+
authToken: "your-api-key", // API key with stage configured
|
|
67
|
+
},
|
|
68
|
+
workflowName: "my-workflow",
|
|
69
|
+
stage: "PROD",
|
|
70
|
+
sessionParams: {
|
|
71
|
+
id: "user-123",
|
|
72
|
+
name: "John Doe",
|
|
73
|
+
},
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Custom Header
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { PaymanChat, usePaymanChat } from "@paymanai/payman-ask-sdk";
|
|
82
|
+
|
|
83
|
+
function ChatHeader() {
|
|
84
|
+
const chat = usePaymanChat();
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="header">
|
|
88
|
+
<h2>My Chat</h2>
|
|
89
|
+
<button onClick={chat.resetSession}>Reset</button>
|
|
90
|
+
<button onClick={chat.clearMessages}>Clear</button>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function MyApp() {
|
|
96
|
+
return (
|
|
97
|
+
<PaymanChat config={config}>
|
|
98
|
+
<ChatHeader />
|
|
99
|
+
</PaymanChat>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### `config` (required)
|
|
107
|
+
|
|
108
|
+
| Property | Type | Required | Description |
|
|
109
|
+
|----------|------|----------|-------------|
|
|
110
|
+
| `api` | `APIConfig` | ✅ | API configuration |
|
|
111
|
+
| `workflowName` | `string` | ✅ | Workflow name |
|
|
112
|
+
| `workflowVersion` | `number` | | Workflow version (default: 1) |
|
|
113
|
+
| `stage` | `WorkflowStage` | | Stage (DEV/SANDBOX/PROD) |
|
|
114
|
+
| `sessionParams` | `SessionParams` | | User session info |
|
|
115
|
+
| `autoGenerateSessionId` | `boolean` | | Auto-generate session ID |
|
|
116
|
+
| `hasAskPermission` | `boolean` | | Show/hide input (default: true) |
|
|
117
|
+
|
|
118
|
+
### `APIConfig`
|
|
119
|
+
|
|
120
|
+
| Property | Type | Required | Description |
|
|
121
|
+
|----------|------|----------|-------------|
|
|
122
|
+
| `baseUrl` | `string` | ✅ | API base URL |
|
|
123
|
+
| `authToken` | `string` | | Auth token |
|
|
124
|
+
| `headers` | `Record<string, string>` | | Custom headers |
|
|
125
|
+
| `streamEndpoint` | `string` | | Stream endpoint path |
|
|
126
|
+
|
|
127
|
+
### `callbacks` (optional)
|
|
128
|
+
|
|
129
|
+
| Callback | Type | Description |
|
|
130
|
+
|----------|------|-------------|
|
|
131
|
+
| `onSessionIdChange` | `(sessionId: string) => void` | Session ID changed |
|
|
132
|
+
| `onError` | `(error: Error) => void` | Error occurred |
|
|
133
|
+
| `onMessageSent` | `(message: MessageDisplay) => void` | Message sent |
|
|
134
|
+
| `onStreamStart` | `() => void` | Stream started |
|
|
135
|
+
| `onStreamComplete` | `(message: MessageDisplay) => void` | Stream completed |
|
|
136
|
+
| `onExecutionTraceClick` | `(data: unknown) => void` | Trace button clicked |
|
|
137
|
+
|
|
138
|
+
### Context API: `usePaymanChat()`
|
|
139
|
+
|
|
140
|
+
| Method | Type | Description |
|
|
141
|
+
|--------|------|-------------|
|
|
142
|
+
| `resetSession()` | `() => void` | Clear messages & reset session |
|
|
143
|
+
| `clearMessages()` | `() => void` | Clear messages only |
|
|
144
|
+
| `cancelStream()` | `() => void` | Cancel current stream |
|
|
145
|
+
| `getSessionId()` | `() => string \| undefined` | Get session ID |
|
|
146
|
+
| `getMessages()` | `() => MessageDisplay[]` | Get all messages |
|
|
147
|
+
| `isWaitingForResponse` | `boolean` | Check if waiting |
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
- **[USAGE.md](./USAGE.md)** - Comprehensive usage guide
|
|
152
|
+
- **[CONTEXT_API.md](./CONTEXT_API.md)** - Context API reference
|
|
153
|
+
- **[ENDPOINTS.md](./ENDPOINTS.md)** - API endpoints guide
|
|
154
|
+
- **[CHANGELOG.md](./CHANGELOG.md)** - Version history
|
|
155
|
+
|
|
156
|
+
## Common Issues
|
|
157
|
+
|
|
158
|
+
### 401 Error: "Workflow stage is not set"
|
|
159
|
+
|
|
160
|
+
Add `streamEndpoint` to your config:
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
api: {
|
|
164
|
+
baseUrl: "...",
|
|
165
|
+
authToken: "...",
|
|
166
|
+
streamEndpoint: "/api/playground/ask/stream", // Add this
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
See [ENDPOINTS.md](./ENDPOINTS.md) for details.
|
|
171
|
+
|
|
172
|
+
## Examples
|
|
173
|
+
|
|
174
|
+
Check the integration examples:
|
|
175
|
+
- `src/components/Playground/PlaygroundChatColumn/` - Playground integration
|
|
176
|
+
- `src/components/Builder/ChatInterface/` - Builder integration
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|
|
181
|
+
|
|
182
|
+
## Support
|
|
183
|
+
|
|
184
|
+
For issues and questions, please file an issue on GitHub.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
5
|
+
export { StreamEvent, StreamOptions, generateId, streamWorkflowEvents, useChat } from '@paymanai/payman-typescript-ask-sdk';
|
|
6
|
+
|
|
7
|
+
type MessageRole = "user" | "assistant" | "system";
|
|
8
|
+
type StreamProgress = "started" | "processing" | "completed" | "error";
|
|
9
|
+
type WorkflowStage = "DEV" | "SANDBOX" | "PROD" | "ARCHIVED";
|
|
10
|
+
type StreamingStep = {
|
|
11
|
+
id: string;
|
|
12
|
+
eventType: string;
|
|
13
|
+
message: string;
|
|
14
|
+
status: "in_progress" | "completed" | "error" | "pending";
|
|
15
|
+
timestamp: number;
|
|
16
|
+
elapsedMs?: number;
|
|
17
|
+
};
|
|
18
|
+
type ChunkDisplay = {
|
|
19
|
+
id?: string;
|
|
20
|
+
text?: string;
|
|
21
|
+
similarityScore?: number;
|
|
22
|
+
rrfScore?: number;
|
|
23
|
+
};
|
|
24
|
+
type MessageDisplay = {
|
|
25
|
+
id: string;
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
role: MessageRole;
|
|
28
|
+
content: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
isError?: boolean;
|
|
31
|
+
errorDetails?: string;
|
|
32
|
+
chunks?: ChunkDisplay[];
|
|
33
|
+
tracingData?: unknown;
|
|
34
|
+
executionId?: string;
|
|
35
|
+
isStreaming?: boolean;
|
|
36
|
+
streamingContent?: string;
|
|
37
|
+
currentWorker?: string;
|
|
38
|
+
currentMessage?: string;
|
|
39
|
+
streamProgress?: StreamProgress;
|
|
40
|
+
steps?: StreamingStep[];
|
|
41
|
+
isCancelled?: boolean;
|
|
42
|
+
currentExecutingStepId?: string;
|
|
43
|
+
};
|
|
44
|
+
type SessionParams = {
|
|
45
|
+
id?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
attributes?: Record<string, string>;
|
|
48
|
+
};
|
|
49
|
+
type APIConfig = {
|
|
50
|
+
/** Base API URL */
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
/** Auth token */
|
|
53
|
+
authToken?: string;
|
|
54
|
+
/** Custom headers */
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
/** API endpoint for streaming (default: /api/workflows/ask/stream) */
|
|
57
|
+
streamEndpoint?: string;
|
|
58
|
+
};
|
|
59
|
+
type ChatConfig = {
|
|
60
|
+
/** API configuration - required for the library to make calls */
|
|
61
|
+
api: APIConfig;
|
|
62
|
+
/** Workflow name */
|
|
63
|
+
workflowName: string;
|
|
64
|
+
/** Workflow version */
|
|
65
|
+
workflowVersion?: number;
|
|
66
|
+
/** Stage/Environment */
|
|
67
|
+
stage?: WorkflowStage;
|
|
68
|
+
/** Session params */
|
|
69
|
+
sessionParams?: SessionParams;
|
|
70
|
+
/** Custom placeholder text */
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
/** Empty state text */
|
|
73
|
+
emptyStateText?: string;
|
|
74
|
+
/** Show icon in empty state */
|
|
75
|
+
showEmptyStateIcon?: boolean;
|
|
76
|
+
/** Show agent name */
|
|
77
|
+
showAgentName?: boolean;
|
|
78
|
+
/** Agent name */
|
|
79
|
+
agentName?: string;
|
|
80
|
+
/** Show avatars for user and assistant messages */
|
|
81
|
+
showAvatars?: boolean;
|
|
82
|
+
/** Show user avatar only (overrides showAvatars for user messages) */
|
|
83
|
+
showUserAvatar?: boolean;
|
|
84
|
+
/** Show assistant avatar only (overrides showAvatars for assistant messages) */
|
|
85
|
+
showAssistantAvatar?: boolean;
|
|
86
|
+
/** Show execution steps section with "Completed in X.Xs" */
|
|
87
|
+
showExecutionSteps?: boolean;
|
|
88
|
+
/** Show animated dot indicator during streaming */
|
|
89
|
+
showStreamingDot?: boolean;
|
|
90
|
+
/** Custom text format for streaming steps button. Use {count} for step count. Default: "View progress ({count} steps)" */
|
|
91
|
+
streamingStepsText?: string;
|
|
92
|
+
/** Custom text format for completed steps button. Use {count} for step count, {time} for elapsed time. Default: "Completed in {time}s ({count} steps)" */
|
|
93
|
+
completedStepsText?: string;
|
|
94
|
+
/** Input style variant: "rounded" (yaak style) or "flat" (paygent-central style). Default: "rounded" */
|
|
95
|
+
inputStyle?: "rounded" | "flat";
|
|
96
|
+
/** Layout style: "centered" (durango style) or "full-width" (default). Default: "full-width" */
|
|
97
|
+
layout?: "centered" | "full-width";
|
|
98
|
+
/** Show timestamps on messages */
|
|
99
|
+
showTimestamps?: boolean;
|
|
100
|
+
/** Enable animations */
|
|
101
|
+
animated?: boolean;
|
|
102
|
+
/** Disable input */
|
|
103
|
+
disableInput?: boolean;
|
|
104
|
+
/** Has permission to ask */
|
|
105
|
+
hasAskPermission?: boolean;
|
|
106
|
+
/** Auto-generate session ID */
|
|
107
|
+
autoGenerateSessionId?: boolean;
|
|
108
|
+
/** Disable the entire chat and show disabled state */
|
|
109
|
+
isChatDisabled?: boolean;
|
|
110
|
+
/** Custom component to render when chat is disabled. If not provided, default disabled UI will be shown */
|
|
111
|
+
disabledComponent?: React__default.ReactNode;
|
|
112
|
+
};
|
|
113
|
+
type ChatCallbacks = {
|
|
114
|
+
/** Called when a message is sent (before API call) */
|
|
115
|
+
onMessageSent?: (message: string) => void;
|
|
116
|
+
/** Called when streaming starts */
|
|
117
|
+
onStreamStart?: () => void;
|
|
118
|
+
/** Called when streaming completes */
|
|
119
|
+
onStreamComplete?: (message: MessageDisplay) => void;
|
|
120
|
+
/** Called when an error occurs */
|
|
121
|
+
onError?: (error: Error) => void;
|
|
122
|
+
/** Called when execution trace is clicked - provides data instead of UI */
|
|
123
|
+
onExecutionTraceClick?: (data: {
|
|
124
|
+
message: MessageDisplay;
|
|
125
|
+
tracingData?: unknown;
|
|
126
|
+
executionId?: string;
|
|
127
|
+
}) => void;
|
|
128
|
+
/** Called when session ID changes */
|
|
129
|
+
onSessionIdChange?: (sessionId: string) => void;
|
|
130
|
+
};
|
|
131
|
+
type PaymanChatProps = {
|
|
132
|
+
/** Chat configuration - includes API config */
|
|
133
|
+
config: ChatConfig;
|
|
134
|
+
/** Callbacks for events */
|
|
135
|
+
callbacks?: ChatCallbacks;
|
|
136
|
+
/** Custom class name */
|
|
137
|
+
className?: string;
|
|
138
|
+
/** Custom style */
|
|
139
|
+
style?: React__default.CSSProperties;
|
|
140
|
+
/** Custom children to render (e.g., header) */
|
|
141
|
+
children?: React__default.ReactNode;
|
|
142
|
+
};
|
|
143
|
+
type ChatInputProps = {
|
|
144
|
+
/** Input value */
|
|
145
|
+
value: string;
|
|
146
|
+
/** On change handler */
|
|
147
|
+
onChange: (value: string) => void;
|
|
148
|
+
/** On send handler */
|
|
149
|
+
onSend: () => void;
|
|
150
|
+
/** On pause/cancel handler */
|
|
151
|
+
onPause?: () => void;
|
|
152
|
+
/** Disabled state */
|
|
153
|
+
disabled?: boolean;
|
|
154
|
+
/** Placeholder text */
|
|
155
|
+
placeholder?: string;
|
|
156
|
+
/** Is waiting for response */
|
|
157
|
+
isWaitingForResponse?: boolean;
|
|
158
|
+
/** Has selected session */
|
|
159
|
+
hasSelectedSession?: boolean;
|
|
160
|
+
/** Is session params configured */
|
|
161
|
+
isSessionParamsConfigured?: boolean;
|
|
162
|
+
/** On input click handler */
|
|
163
|
+
onClick?: () => void;
|
|
164
|
+
/** Input style variant */
|
|
165
|
+
inputStyle?: "rounded" | "flat";
|
|
166
|
+
/** Layout style */
|
|
167
|
+
layout?: "centered" | "full-width";
|
|
168
|
+
/** Custom class name */
|
|
169
|
+
className?: string;
|
|
170
|
+
};
|
|
171
|
+
type MessageListProps = {
|
|
172
|
+
/** Messages to display */
|
|
173
|
+
messages: MessageDisplay[];
|
|
174
|
+
/** Loading state */
|
|
175
|
+
isLoading?: boolean;
|
|
176
|
+
/** Empty state text */
|
|
177
|
+
emptyStateText?: string;
|
|
178
|
+
/** Show icon in empty state */
|
|
179
|
+
showEmptyStateIcon?: boolean;
|
|
180
|
+
/** Layout style */
|
|
181
|
+
layout?: "centered" | "full-width";
|
|
182
|
+
/** Show timestamps on messages */
|
|
183
|
+
showTimestamps?: boolean;
|
|
184
|
+
/** Stage */
|
|
185
|
+
stage?: WorkflowStage;
|
|
186
|
+
/** Animated */
|
|
187
|
+
animated?: boolean;
|
|
188
|
+
/** Show agent name */
|
|
189
|
+
showAgentName?: boolean;
|
|
190
|
+
/** Agent name */
|
|
191
|
+
agentName?: string;
|
|
192
|
+
/** Show avatars */
|
|
193
|
+
showAvatars?: boolean;
|
|
194
|
+
/** Show user avatar only (overrides showAvatars) */
|
|
195
|
+
showUserAvatar?: boolean;
|
|
196
|
+
/** Show assistant avatar only (overrides showAvatars) */
|
|
197
|
+
showAssistantAvatar?: boolean;
|
|
198
|
+
/** Show execution steps */
|
|
199
|
+
showExecutionSteps?: boolean;
|
|
200
|
+
/** Show streaming dot */
|
|
201
|
+
showStreamingDot?: boolean;
|
|
202
|
+
/** Custom streaming steps text */
|
|
203
|
+
streamingStepsText?: string;
|
|
204
|
+
/** Custom completed steps text */
|
|
205
|
+
completedStepsText?: string;
|
|
206
|
+
/** On execution trace click */
|
|
207
|
+
onExecutionTraceClick?: (data: {
|
|
208
|
+
message: MessageDisplay;
|
|
209
|
+
tracingData?: unknown;
|
|
210
|
+
executionId?: string;
|
|
211
|
+
}) => void;
|
|
212
|
+
/** Custom class name */
|
|
213
|
+
className?: string;
|
|
214
|
+
};
|
|
215
|
+
type MessageRowProps = {
|
|
216
|
+
/** Message to display */
|
|
217
|
+
message: MessageDisplay;
|
|
218
|
+
/** Stage */
|
|
219
|
+
stage?: WorkflowStage;
|
|
220
|
+
/** Animated */
|
|
221
|
+
animated?: boolean;
|
|
222
|
+
/** Show agent name */
|
|
223
|
+
showAgentName?: boolean;
|
|
224
|
+
/** Agent name */
|
|
225
|
+
agentName?: string;
|
|
226
|
+
/** Show avatars */
|
|
227
|
+
showAvatars?: boolean;
|
|
228
|
+
/** Show user avatar only (overrides showAvatars) */
|
|
229
|
+
showUserAvatar?: boolean;
|
|
230
|
+
/** Show assistant avatar only (overrides showAvatars) */
|
|
231
|
+
showAssistantAvatar?: boolean;
|
|
232
|
+
/** Show execution steps */
|
|
233
|
+
showExecutionSteps?: boolean;
|
|
234
|
+
/** Show streaming dot */
|
|
235
|
+
showStreamingDot?: boolean;
|
|
236
|
+
/** Custom streaming steps text */
|
|
237
|
+
streamingStepsText?: string;
|
|
238
|
+
/** Custom completed steps text */
|
|
239
|
+
completedStepsText?: string;
|
|
240
|
+
/** On execution trace click */
|
|
241
|
+
onExecutionTraceClick?: (data: {
|
|
242
|
+
message: MessageDisplay;
|
|
243
|
+
tracingData?: unknown;
|
|
244
|
+
executionId?: string;
|
|
245
|
+
}) => void;
|
|
246
|
+
};
|
|
247
|
+
type UserMessageProps = {
|
|
248
|
+
/** Message to display */
|
|
249
|
+
message: MessageDisplay;
|
|
250
|
+
/** Animated */
|
|
251
|
+
animated?: boolean;
|
|
252
|
+
/** Show avatar */
|
|
253
|
+
showAvatar?: boolean;
|
|
254
|
+
};
|
|
255
|
+
type AgentMessageProps = {
|
|
256
|
+
/** Message to display */
|
|
257
|
+
message: MessageDisplay;
|
|
258
|
+
/** Stage */
|
|
259
|
+
stage?: WorkflowStage;
|
|
260
|
+
/** Animated */
|
|
261
|
+
animated?: boolean;
|
|
262
|
+
/** Show agent name */
|
|
263
|
+
showAgentName?: boolean;
|
|
264
|
+
/** Agent name */
|
|
265
|
+
agentName?: string;
|
|
266
|
+
/** Show avatar */
|
|
267
|
+
showAvatar?: boolean;
|
|
268
|
+
/** Layout style */
|
|
269
|
+
layout?: "centered" | "full-width";
|
|
270
|
+
/** Show timestamp */
|
|
271
|
+
showTimestamp?: boolean;
|
|
272
|
+
/** Show execution steps */
|
|
273
|
+
showExecutionSteps?: boolean;
|
|
274
|
+
/** Show streaming dot */
|
|
275
|
+
showStreamingDot?: boolean;
|
|
276
|
+
/** Custom streaming steps text */
|
|
277
|
+
streamingStepsText?: string;
|
|
278
|
+
/** Custom completed steps text */
|
|
279
|
+
completedStepsText?: string;
|
|
280
|
+
/** On execution trace click */
|
|
281
|
+
onExecutionTraceClick?: (data: {
|
|
282
|
+
message: MessageDisplay;
|
|
283
|
+
tracingData?: unknown;
|
|
284
|
+
executionId?: string;
|
|
285
|
+
}) => void;
|
|
286
|
+
};
|
|
287
|
+
type StreamingMessageProps = {
|
|
288
|
+
/** Streaming content */
|
|
289
|
+
content: string;
|
|
290
|
+
/** Is currently streaming */
|
|
291
|
+
isStreaming: boolean;
|
|
292
|
+
/** Current worker */
|
|
293
|
+
currentWorker?: string;
|
|
294
|
+
/** Current message */
|
|
295
|
+
currentMessage?: string;
|
|
296
|
+
/** Stream progress */
|
|
297
|
+
streamProgress: StreamProgress;
|
|
298
|
+
/** Error message */
|
|
299
|
+
error?: string;
|
|
300
|
+
/** Streaming steps */
|
|
301
|
+
steps?: StreamingStep[];
|
|
302
|
+
};
|
|
303
|
+
type ChatHeaderProps = {
|
|
304
|
+
/** Session ID */
|
|
305
|
+
sessionId?: string;
|
|
306
|
+
/** On copy session ID */
|
|
307
|
+
onCopySessionId?: (sessionId: string) => void;
|
|
308
|
+
/** On load session click */
|
|
309
|
+
onLoadSession?: () => void;
|
|
310
|
+
/** On new session click */
|
|
311
|
+
onNewSession?: () => void;
|
|
312
|
+
/** On session params click */
|
|
313
|
+
onSessionParamsClick?: () => void;
|
|
314
|
+
/** Show load session button */
|
|
315
|
+
showLoadSession?: boolean;
|
|
316
|
+
/** Show reset session button */
|
|
317
|
+
showResetSession?: boolean;
|
|
318
|
+
/** Show session params button */
|
|
319
|
+
showSessionParams?: boolean;
|
|
320
|
+
/** Show session params tooltip */
|
|
321
|
+
showSessionParamsTooltip?: boolean;
|
|
322
|
+
/** Session params button ref */
|
|
323
|
+
sessionParamsButtonRef?: React__default.RefObject<HTMLButtonElement | null> | undefined;
|
|
324
|
+
/** Custom children */
|
|
325
|
+
children?: React__default.ReactNode;
|
|
326
|
+
/** Custom class name */
|
|
327
|
+
className?: string;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
declare function PaymanChat({ config, callbacks, className, style, children, }: PaymanChatProps): react_jsx_runtime.JSX.Element;
|
|
331
|
+
|
|
332
|
+
interface PaymanChatContextValue {
|
|
333
|
+
/**
|
|
334
|
+
* Clear all messages and reset the chat
|
|
335
|
+
*/
|
|
336
|
+
resetSession: () => void;
|
|
337
|
+
/**
|
|
338
|
+
* Clear all messages without resetting session ID
|
|
339
|
+
*/
|
|
340
|
+
clearMessages: () => void;
|
|
341
|
+
/**
|
|
342
|
+
* Cancel current streaming operation
|
|
343
|
+
*/
|
|
344
|
+
cancelStream: () => void;
|
|
345
|
+
/**
|
|
346
|
+
* Get current session ID
|
|
347
|
+
*/
|
|
348
|
+
getSessionId: () => string | undefined;
|
|
349
|
+
/**
|
|
350
|
+
* Get all messages
|
|
351
|
+
*/
|
|
352
|
+
getMessages: () => MessageDisplay[];
|
|
353
|
+
/**
|
|
354
|
+
* Check if currently waiting for response
|
|
355
|
+
*/
|
|
356
|
+
isWaitingForResponse: boolean;
|
|
357
|
+
}
|
|
358
|
+
declare const PaymanChatContext: React.Context<PaymanChatContextValue | undefined>;
|
|
359
|
+
/**
|
|
360
|
+
* Hook to access PaymanChat controls from parent components
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```tsx
|
|
364
|
+
* function MyComponent() {
|
|
365
|
+
* const chat = usePaymanChat();
|
|
366
|
+
*
|
|
367
|
+
* return (
|
|
368
|
+
* <>
|
|
369
|
+
* <button onClick={chat.resetSession}>Reset</button>
|
|
370
|
+
* <button onClick={chat.clearMessages}>Clear</button>
|
|
371
|
+
* </>
|
|
372
|
+
* );
|
|
373
|
+
* }
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
declare function usePaymanChat(): PaymanChatContextValue;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Utility function to merge Tailwind CSS classes
|
|
380
|
+
*/
|
|
381
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Format a timestamp to a readable date/time string
|
|
385
|
+
*/
|
|
386
|
+
declare function formatDate(timestamp: string | Date): string;
|
|
387
|
+
|
|
388
|
+
export { type APIConfig, type AgentMessageProps, type ChatCallbacks, type ChatConfig, type ChatHeaderProps, type ChatInputProps, type ChunkDisplay, type MessageDisplay, type MessageListProps, type MessageRole, type MessageRowProps, PaymanChat, PaymanChatContext, type PaymanChatContextValue, type PaymanChatProps, type SessionParams, type StreamProgress, type StreamingMessageProps, type StreamingStep, type UserMessageProps, type WorkflowStage, cn, formatDate, usePaymanChat };
|