@paymanai/payman-ask-sdk 4.0.27 → 4.0.28
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 +40 -0
- package/dist/index.d.mts +18 -10
- package/dist/index.d.ts +18 -10
- package/dist/index.js +1337 -182
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1338 -184
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +2 -1
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +613 -1
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -230,6 +230,46 @@ function MyShell() {
|
|
|
230
230
|
}
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
+
> The example above (`SessionHistorySidebar`, `ui.sessionHistory`, `chat.loadSession()`) documents a config shape that isn't implemented in this package yet. For the sidebar that actually ships today, see **Sessions sidebar** below.
|
|
234
|
+
|
|
235
|
+
## Sessions sidebar
|
|
236
|
+
|
|
237
|
+
Set `config.sessions.enabled = true` and `<PaymanChat/>` renders a "continue a chat" sidebar next to the conversation — fetching the list, loading a picked session's messages, and remounting the chat onto it are all handled internally. No extra state, endpoints, or loading/error UI to build in the host app.
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
<PaymanChat
|
|
241
|
+
config={{
|
|
242
|
+
api: { baseUrl, authToken, headers }, // same credential already used for streaming — JWT or API key, doesn't matter
|
|
243
|
+
agentId,
|
|
244
|
+
sessionParams,
|
|
245
|
+
sessions: {
|
|
246
|
+
enabled: true,
|
|
247
|
+
// Both default to these paths if omitted:
|
|
248
|
+
listEndpoint: "/api/ask/sessions",
|
|
249
|
+
messagesEndpoint: "/api/ask/sessions/{sessionId}/messages",
|
|
250
|
+
title: "Chats",
|
|
251
|
+
newChatLabel: "Start New Chat",
|
|
252
|
+
defaultOpen: true,
|
|
253
|
+
// Optional per-row "..." menu. Omit `actions` entirely to hide it.
|
|
254
|
+
actions: [
|
|
255
|
+
{
|
|
256
|
+
key: "delete",
|
|
257
|
+
label: "Delete",
|
|
258
|
+
destructive: true,
|
|
259
|
+
onSelect: async (session) => { /* ... */ },
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
}}
|
|
264
|
+
/>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
`listEndpoint` is appended to `api.baseUrl` and expected to return `{ data: ChatSessionSummary[] }` (`sessionId`, `title?`, `messageCount?`, `lastMessageAt?`, `status?`). `messagesEndpoint` (with `{sessionId}` substituted) is expected to return `{ data: ChatSessionMessageEntry[] }` (`id`, `sessionUserIntent`, `agentResponse?`, `status?`, `startTime?`, `endTime?`) — the same `PageResponse<AgentUser...Response>` shape K2's `/conversations/sessions` endpoint already returns. If your backend's JSON looks different, pass `parseSessionsResponse` / `parseMessagesResponse` to adapt it.
|
|
268
|
+
|
|
269
|
+
Auth is whatever you already pass in `api.headers` / `api.authToken` for streaming — there's no separate sessions-specific credential. `ref.refreshSessions()` force-refetches the list (e.g. after an out-of-band mutation); `onStreamComplete` triggers an automatic refetch after every turn.
|
|
270
|
+
|
|
271
|
+
Styling: see [`docs/v2-styling-reference.md`](docs/v2-styling-reference.md#sessions-sidebar) for the full `payman-v2-sessions-*` class list and CSS vars.
|
|
272
|
+
|
|
233
273
|
## `usePaymanChat()` hook
|
|
234
274
|
|
|
235
275
|
Call from any descendant of `<PaymanChat/>`:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
-
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
3
|
+
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, AgentConfigProbeConfig, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, ActiveUserAction, AgentAvailabilityStatus, AgentConfigProbeConfig, AgentStage, ChatSessionAction, ChatSessionMessageEntry, ChatSessionSummary, ChatSessionsConfig, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseAgentConfigOptions, UseAgentConfigReturn, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useAgentConfig, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
5
5
|
import { ClassValue } from 'clsx';
|
|
6
6
|
|
|
7
7
|
declare const NEGATIVE_FEEDBACK_REASONS: readonly [{
|
|
@@ -74,6 +74,20 @@ type SlashCommandConfig = {
|
|
|
74
74
|
requiredAnyPermissions?: string[];
|
|
75
75
|
};
|
|
76
76
|
type ChatConfig = ChatConfig$1 & {
|
|
77
|
+
/**
|
|
78
|
+
* Availability probe. When `availability.enabled` is set, PaymanChat calls
|
|
79
|
+
* GET `/api/agent/config` itself and takes over the chat with a friendly,
|
|
80
|
+
* built-in notice whenever the agent is off or the agent-user is blocked —
|
|
81
|
+
* so hosts don't have to wire the check by hand. Provide `disabledComponent`
|
|
82
|
+
* / `blockedComponent` to render your own UI per state. See
|
|
83
|
+
* `AgentConfigProbeConfig` in @paymanai/payman-typescript-ask-sdk.
|
|
84
|
+
*/
|
|
85
|
+
availability?: AgentConfigProbeConfig & {
|
|
86
|
+
/** Custom body shown when the agent itself is disabled. Defaults to a built-in notice. */
|
|
87
|
+
disabledComponent?: React__default.ReactNode;
|
|
88
|
+
/** Custom body shown when this agent-user is blocked. Defaults to a built-in notice. */
|
|
89
|
+
blockedComponent?: React__default.ReactNode;
|
|
90
|
+
};
|
|
77
91
|
/** Custom React component to render above the empty state text (e.g. logo, illustration). */
|
|
78
92
|
emptyStateComponent?: React__default.ReactNode;
|
|
79
93
|
/** Enable voice input (default: true) */
|
|
@@ -198,6 +212,8 @@ type PaymanChatRef = {
|
|
|
198
212
|
getSessionId: () => string | undefined;
|
|
199
213
|
/** Get all messages */
|
|
200
214
|
getMessages: () => MessageDisplay[];
|
|
215
|
+
/** Re-fetch the sessions sidebar list (no-op when `config.sessions.enabled` is not set) */
|
|
216
|
+
refreshSessions: () => void;
|
|
201
217
|
};
|
|
202
218
|
type PaymanChatProps = {
|
|
203
219
|
/** Chat configuration - includes API config */
|
|
@@ -480,14 +496,6 @@ type ChatHeaderProps = {
|
|
|
480
496
|
className?: string;
|
|
481
497
|
};
|
|
482
498
|
|
|
483
|
-
/**
|
|
484
|
-
* PaymanChat — the public component. Delegates to `PaymanChatInner`
|
|
485
|
-
* with a chat hook instance from `useChatV2`. The `config.uiVersion`
|
|
486
|
-
* prop used to gate an older V1 render path; the V1 code has been
|
|
487
|
-
* removed since nothing in the SDK's current consumers (paygent-studio
|
|
488
|
-
* etc.) opted into it. The `uiVersion` prop is still accepted on
|
|
489
|
-
* `ChatConfig` for type compatibility but is now ignored at runtime.
|
|
490
|
-
*/
|
|
491
499
|
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
492
500
|
|
|
493
501
|
interface PaymanChatContextValue {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
-
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
3
|
+
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, AgentConfigProbeConfig, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, ActiveUserAction, AgentAvailabilityStatus, AgentConfigProbeConfig, AgentStage, ChatSessionAction, ChatSessionMessageEntry, ChatSessionSummary, ChatSessionsConfig, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseAgentConfigOptions, UseAgentConfigReturn, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useAgentConfig, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
5
5
|
import { ClassValue } from 'clsx';
|
|
6
6
|
|
|
7
7
|
declare const NEGATIVE_FEEDBACK_REASONS: readonly [{
|
|
@@ -74,6 +74,20 @@ type SlashCommandConfig = {
|
|
|
74
74
|
requiredAnyPermissions?: string[];
|
|
75
75
|
};
|
|
76
76
|
type ChatConfig = ChatConfig$1 & {
|
|
77
|
+
/**
|
|
78
|
+
* Availability probe. When `availability.enabled` is set, PaymanChat calls
|
|
79
|
+
* GET `/api/agent/config` itself and takes over the chat with a friendly,
|
|
80
|
+
* built-in notice whenever the agent is off or the agent-user is blocked —
|
|
81
|
+
* so hosts don't have to wire the check by hand. Provide `disabledComponent`
|
|
82
|
+
* / `blockedComponent` to render your own UI per state. See
|
|
83
|
+
* `AgentConfigProbeConfig` in @paymanai/payman-typescript-ask-sdk.
|
|
84
|
+
*/
|
|
85
|
+
availability?: AgentConfigProbeConfig & {
|
|
86
|
+
/** Custom body shown when the agent itself is disabled. Defaults to a built-in notice. */
|
|
87
|
+
disabledComponent?: React__default.ReactNode;
|
|
88
|
+
/** Custom body shown when this agent-user is blocked. Defaults to a built-in notice. */
|
|
89
|
+
blockedComponent?: React__default.ReactNode;
|
|
90
|
+
};
|
|
77
91
|
/** Custom React component to render above the empty state text (e.g. logo, illustration). */
|
|
78
92
|
emptyStateComponent?: React__default.ReactNode;
|
|
79
93
|
/** Enable voice input (default: true) */
|
|
@@ -198,6 +212,8 @@ type PaymanChatRef = {
|
|
|
198
212
|
getSessionId: () => string | undefined;
|
|
199
213
|
/** Get all messages */
|
|
200
214
|
getMessages: () => MessageDisplay[];
|
|
215
|
+
/** Re-fetch the sessions sidebar list (no-op when `config.sessions.enabled` is not set) */
|
|
216
|
+
refreshSessions: () => void;
|
|
201
217
|
};
|
|
202
218
|
type PaymanChatProps = {
|
|
203
219
|
/** Chat configuration - includes API config */
|
|
@@ -480,14 +496,6 @@ type ChatHeaderProps = {
|
|
|
480
496
|
className?: string;
|
|
481
497
|
};
|
|
482
498
|
|
|
483
|
-
/**
|
|
484
|
-
* PaymanChat — the public component. Delegates to `PaymanChatInner`
|
|
485
|
-
* with a chat hook instance from `useChatV2`. The `config.uiVersion`
|
|
486
|
-
* prop used to gate an older V1 render path; the V1 code has been
|
|
487
|
-
* removed since nothing in the SDK's current consumers (paygent-studio
|
|
488
|
-
* etc.) opted into it. The `uiVersion` prop is still accepted on
|
|
489
|
-
* `ChatConfig` for type compatibility but is now ignored at runtime.
|
|
490
|
-
*/
|
|
491
499
|
declare const PaymanChat: React.ForwardRefExoticComponent<PaymanChatProps & React.RefAttributes<PaymanChatRef>>;
|
|
492
500
|
|
|
493
501
|
interface PaymanChatContextValue {
|