@paymanai/payman-typescript-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/dist/index.d.mts +194 -1
- package/dist/index.d.ts +194 -1
- package/dist/index.js +280 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +279 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +280 -0
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -241,6 +241,115 @@ type APIConfig = {
|
|
|
241
241
|
/** API endpoint for resolving RAG image URLs (default derived from stream endpoint) */
|
|
242
242
|
resolveImagesEndpoint?: string;
|
|
243
243
|
};
|
|
244
|
+
/** One row in the sessions list. */
|
|
245
|
+
type ChatSessionSummary = {
|
|
246
|
+
sessionId: string;
|
|
247
|
+
title?: string | null;
|
|
248
|
+
messageCount?: number;
|
|
249
|
+
lastMessageAt?: string;
|
|
250
|
+
status?: string;
|
|
251
|
+
};
|
|
252
|
+
/** One turn's worth of raw history, as returned by the messages endpoint. */
|
|
253
|
+
type ChatSessionMessageEntry = {
|
|
254
|
+
id: string;
|
|
255
|
+
sessionUserIntent: string;
|
|
256
|
+
agentResponse?: string | null;
|
|
257
|
+
status?: string;
|
|
258
|
+
startTime?: string;
|
|
259
|
+
endTime?: string;
|
|
260
|
+
/** Persisted end-user thumbs-up/down; hydrates the feedback buttons on resume. */
|
|
261
|
+
feedback?: {
|
|
262
|
+
feedback?: string | null;
|
|
263
|
+
details?: string | null;
|
|
264
|
+
} | null;
|
|
265
|
+
};
|
|
266
|
+
/** Overflow-menu ("...") action rendered on a session row by consuming UIs. */
|
|
267
|
+
type ChatSessionAction = {
|
|
268
|
+
key: string;
|
|
269
|
+
label: string;
|
|
270
|
+
destructive?: boolean;
|
|
271
|
+
onSelect: (session: ChatSessionSummary) => void | Promise<void>;
|
|
272
|
+
};
|
|
273
|
+
type ChatSessionsConfig = {
|
|
274
|
+
/** Turn on session listing / history loading. Default: false. */
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Path appended to `api.baseUrl` that returns a page of the current
|
|
278
|
+
* user's sessions. Reuses `api.headers` / `api.authToken` — the same
|
|
279
|
+
* credential already configured for streaming, whether that's a JWT
|
|
280
|
+
* bearer token or a custom API-key header. No separate auth config.
|
|
281
|
+
* Default: "/api/conversations/sessions".
|
|
282
|
+
*/
|
|
283
|
+
listEndpoint?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Path template for a single session's messages. The literal token
|
|
286
|
+
* `{sessionId}` is replaced with the selected session's id.
|
|
287
|
+
* Default: "/api/conversations/sessions/{sessionId}/messages".
|
|
288
|
+
*/
|
|
289
|
+
messagesEndpoint?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Sessions fetched per page. `useChatSessions` sends `page` + `limit`
|
|
292
|
+
* query params and appends each page via `loadMore`. Default: 20.
|
|
293
|
+
*/
|
|
294
|
+
pageSize?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Messages fetched for a selected session (sent as `limit`). Loaded in
|
|
297
|
+
* one request; the backend caps this at 100. Default: 100.
|
|
298
|
+
*/
|
|
299
|
+
messagesPageSize?: number;
|
|
300
|
+
/** Sidebar header title (UI-facing; a plain string, not markup). Default: "Chats". */
|
|
301
|
+
title?: string;
|
|
302
|
+
/** Label for the create-new-session control. Default: "Start New Chat". */
|
|
303
|
+
newChatLabel?: string;
|
|
304
|
+
/** Whether a host UI's sessions panel starts open. Default: true. */
|
|
305
|
+
defaultOpen?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Parse the list endpoint's JSON body into session rows. Defaults to
|
|
308
|
+
* reading `{ data: ChatSessionSummary[] }`, matching every
|
|
309
|
+
* PageResponse-shaped endpoint in this workspace.
|
|
310
|
+
*/
|
|
311
|
+
parseSessionsResponse?: (json: unknown) => {
|
|
312
|
+
data: ChatSessionSummary[];
|
|
313
|
+
total?: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Parse the messages endpoint's JSON body into raw entries. Defaults
|
|
317
|
+
* to reading `{ data: ChatSessionMessageEntry[] }`.
|
|
318
|
+
*/
|
|
319
|
+
parseMessagesResponse?: (json: unknown) => {
|
|
320
|
+
data: ChatSessionMessageEntry[];
|
|
321
|
+
};
|
|
322
|
+
/** Per-session overflow-menu actions (e.g. rename, delete). Omit to hide the "..." menu in host UIs that render one. */
|
|
323
|
+
actions?: ChatSessionAction[];
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Why an agent is (un)available. "blocked" = this agent-user is blocked;
|
|
327
|
+
* "disabled" = the agent itself is off; "unknown" = loading or unreported.
|
|
328
|
+
* A machine code, not display text — the consumer owns the wording.
|
|
329
|
+
*/
|
|
330
|
+
type AgentAvailabilityStatus = "available" | "disabled" | "blocked" | "unknown";
|
|
331
|
+
/** Config for `useAgentConfig` — the GET /api/agent/config probe. */
|
|
332
|
+
type AgentConfigProbeConfig = {
|
|
333
|
+
/** Turn on the availability probe. Default: false. */
|
|
334
|
+
enabled?: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Path appended to `api.baseUrl` returning the agent's `AgentConfigResponse`
|
|
337
|
+
* (`{ enabled, blocked, ... }` — `blocked` is only populated when the host's
|
|
338
|
+
* proxy passes `sessionOwnerId` upstream). Reuses `api.headers` /
|
|
339
|
+
* `api.authToken`. Default: "/api/agent/config".
|
|
340
|
+
*/
|
|
341
|
+
endpoint?: string;
|
|
342
|
+
/**
|
|
343
|
+
* Parse the response into `{ available, status, config }`. Defaults to
|
|
344
|
+
* reading `{ enabled, blocked }` and deriving `available`/`status` from
|
|
345
|
+
* them, passing the whole body through as `config`.
|
|
346
|
+
*/
|
|
347
|
+
parseResponse?: (json: unknown) => {
|
|
348
|
+
available: boolean;
|
|
349
|
+
status?: AgentAvailabilityStatus;
|
|
350
|
+
config?: unknown;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
244
353
|
type ChatConfig = {
|
|
245
354
|
/** API configuration - required for the library to make calls */
|
|
246
355
|
api: APIConfig;
|
|
@@ -314,6 +423,12 @@ type ChatConfig = {
|
|
|
314
423
|
initialMessages?: MessageDisplay[];
|
|
315
424
|
/** Resume an existing session by providing its ID */
|
|
316
425
|
initialSessionId?: string;
|
|
426
|
+
/**
|
|
427
|
+
* Session listing / history loading (list of past sessions + a
|
|
428
|
+
* selected session's messages). See `useChatSessions` — UI packages
|
|
429
|
+
* (e.g. `@paymanai/payman-ask-sdk`) build a picker on top of it.
|
|
430
|
+
*/
|
|
431
|
+
sessions?: ChatSessionsConfig;
|
|
317
432
|
};
|
|
318
433
|
type ChatCallbacks = {
|
|
319
434
|
/** Called when a message is sent (before API call) */
|
|
@@ -457,6 +572,84 @@ declare global {
|
|
|
457
572
|
}
|
|
458
573
|
declare function useVoice(config?: VoiceConfig, callbacks?: VoiceCallbacks): UseVoiceReturn;
|
|
459
574
|
|
|
575
|
+
type UseChatSessionsOptions = {
|
|
576
|
+
api: APIConfig;
|
|
577
|
+
sessions?: ChatSessionsConfig;
|
|
578
|
+
/** Seed the active session from the host's own config on first mount. */
|
|
579
|
+
initialSessionId?: string;
|
|
580
|
+
};
|
|
581
|
+
type UseChatSessionsReturn = {
|
|
582
|
+
enabled: boolean;
|
|
583
|
+
sessionsList: ChatSessionSummary[];
|
|
584
|
+
isLoadingList: boolean;
|
|
585
|
+
listError: string | null;
|
|
586
|
+
/** Total sessions available server-side, or null if the endpoint omits it. */
|
|
587
|
+
total: number | null;
|
|
588
|
+
/** Whether another page can be loaded via `loadMore`. */
|
|
589
|
+
hasMore: boolean;
|
|
590
|
+
/** True while a `loadMore` page (page > 0) is in flight. */
|
|
591
|
+
isLoadingMore: boolean;
|
|
592
|
+
/** Fetch and append the next page of sessions. No-op when already loading or `!hasMore`. */
|
|
593
|
+
loadMore: () => void;
|
|
594
|
+
/**
|
|
595
|
+
* Optimistically reflect a just-sent message in the list: moves the active
|
|
596
|
+
* session to the top (bumping its count/timestamp) or prepends a new row.
|
|
597
|
+
* The next `refetch` reconciles with the server.
|
|
598
|
+
*/
|
|
599
|
+
noteSentMessage: (text: string) => void;
|
|
600
|
+
selectedSessionId: string | null;
|
|
601
|
+
/** The session id the chat should currently be bound to — either the selected history entry or the live draft. */
|
|
602
|
+
activeSessionId: string;
|
|
603
|
+
selectSession: (sessionId: string) => void;
|
|
604
|
+
startNewSession: () => void;
|
|
605
|
+
selectedMessages: MessageDisplay[];
|
|
606
|
+
isLoadingMessages: boolean;
|
|
607
|
+
messagesError: string | null;
|
|
608
|
+
refetch: () => void;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Lists the caller's sessions (paginated — call `loadMore` for older
|
|
612
|
+
* entries) and, once one is picked, its message history. Reuses whatever
|
|
613
|
+
* `api.headers` / `api.authToken` the host already configured for
|
|
614
|
+
* streaming — the same credential, JWT or API key, works here too, so
|
|
615
|
+
* there's nothing extra to authenticate.
|
|
616
|
+
*/
|
|
617
|
+
declare function useChatSessions({ api, sessions, initialSessionId, }: UseChatSessionsOptions): UseChatSessionsReturn;
|
|
618
|
+
|
|
619
|
+
type UseAgentConfigOptions = {
|
|
620
|
+
api: APIConfig;
|
|
621
|
+
availability?: AgentConfigProbeConfig;
|
|
622
|
+
};
|
|
623
|
+
type UseAgentConfigReturn = {
|
|
624
|
+
/** Whether the probe is turned on. */
|
|
625
|
+
enabled: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* The agent's availability, or `null` while unknown (loading, not yet
|
|
628
|
+
* fetched, or the probe failed). Callers should only hard-disable on an
|
|
629
|
+
* explicit `false` — never on `null` — so a flaky probe can't lock a
|
|
630
|
+
* working agent out.
|
|
631
|
+
*/
|
|
632
|
+
available: boolean | null;
|
|
633
|
+
/**
|
|
634
|
+
* Machine-readable reason: "blocked" (this agent-user) vs "disabled" (the
|
|
635
|
+
* agent itself), so callers can show state-specific copy. "unknown" while
|
|
636
|
+
* loading or when the endpoint omits a status. Never a human string —
|
|
637
|
+
* consumers own the wording.
|
|
638
|
+
*/
|
|
639
|
+
status: AgentAvailabilityStatus;
|
|
640
|
+
/** The raw parsed response body (the AgentConfigResponse shape), for hosts that need more than `available`/`status`. */
|
|
641
|
+
config: unknown;
|
|
642
|
+
isLoading: boolean;
|
|
643
|
+
error: string | null;
|
|
644
|
+
refetch: () => void;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Probes GET `/api/agent/config` and returns the agent's availability.
|
|
648
|
+
* Reuses whatever `api.headers` / `api.authToken` the host already
|
|
649
|
+
* configured for streaming — same credential, JWT or API key.
|
|
650
|
+
*/
|
|
651
|
+
declare function useAgentConfig({ api, availability }: UseAgentConfigOptions): UseAgentConfigReturn;
|
|
652
|
+
|
|
460
653
|
/**
|
|
461
654
|
* Cross-platform UUID v4 generator
|
|
462
655
|
* Works in both browser and React Native environments
|
|
@@ -667,4 +860,4 @@ declare function isUserActionExpired(prompt: ActiveUserAction): boolean;
|
|
|
667
860
|
|
|
668
861
|
declare function migrateActiveStream(oldUserId: string, newUserId: string): void;
|
|
669
862
|
|
|
670
|
-
export { type APIConfig, type ActiveUserAction, type AgentStage, type AnalysisMode, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type FieldWidget, type JsonSchemaField, type JsonSchemaOption, type MessageDisplay, type MessageFeedbackState, type MessageRole, type RequestedSchema, type SendMessageOptions, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatV2Return, type UseVoiceReturn, type UserActionKind, type UserActionRequest, UserActionStaleError, type UserActionState, type UserActionStatus, type UserActionSubAction, type UserNotification, type V2EventProcessorState, type VerificationType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, buildContent, cancelUserAction, classifyField, classifyUserActionKind, coerceValue, createInitialV2State, defaultValueFor, expireUserAction, generateId, getOptions, getUserActionSecondsLeft, isNestedOrUnsupported, isRequired, isUserActionExpired, migrateActiveStream, processStreamEventV2, renderableFields, resendUserAction, resolveUserActionExpiresAt, streamWorkflowEvents, submitUserAction, useChatV2, useVoice, validateField, validateForm };
|
|
863
|
+
export { type APIConfig, type ActiveUserAction, type AgentAvailabilityStatus, type AgentConfigProbeConfig, type AgentStage, type AnalysisMode, type ChatCallbacks, type ChatConfig, type ChatSessionAction, type ChatSessionMessageEntry, type ChatSessionSummary, type ChatSessionsConfig, type ChunkDisplay, type FieldWidget, type JsonSchemaField, type JsonSchemaOption, type MessageDisplay, type MessageFeedbackState, type MessageRole, type RequestedSchema, type SendMessageOptions, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseAgentConfigOptions, type UseAgentConfigReturn, type UseChatSessionsOptions, type UseChatSessionsReturn, type UseChatV2Return, type UseVoiceReturn, type UserActionKind, type UserActionRequest, UserActionStaleError, type UserActionState, type UserActionStatus, type UserActionSubAction, type UserNotification, type V2EventProcessorState, type VerificationType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, buildContent, cancelUserAction, classifyField, classifyUserActionKind, coerceValue, createInitialV2State, defaultValueFor, expireUserAction, generateId, getOptions, getUserActionSecondsLeft, isNestedOrUnsupported, isRequired, isUserActionExpired, migrateActiveStream, processStreamEventV2, renderableFields, resendUserAction, resolveUserActionExpiresAt, streamWorkflowEvents, submitUserAction, useAgentConfig, useChatSessions, useChatV2, useVoice, validateField, validateForm };
|
package/dist/index.d.ts
CHANGED
|
@@ -241,6 +241,115 @@ type APIConfig = {
|
|
|
241
241
|
/** API endpoint for resolving RAG image URLs (default derived from stream endpoint) */
|
|
242
242
|
resolveImagesEndpoint?: string;
|
|
243
243
|
};
|
|
244
|
+
/** One row in the sessions list. */
|
|
245
|
+
type ChatSessionSummary = {
|
|
246
|
+
sessionId: string;
|
|
247
|
+
title?: string | null;
|
|
248
|
+
messageCount?: number;
|
|
249
|
+
lastMessageAt?: string;
|
|
250
|
+
status?: string;
|
|
251
|
+
};
|
|
252
|
+
/** One turn's worth of raw history, as returned by the messages endpoint. */
|
|
253
|
+
type ChatSessionMessageEntry = {
|
|
254
|
+
id: string;
|
|
255
|
+
sessionUserIntent: string;
|
|
256
|
+
agentResponse?: string | null;
|
|
257
|
+
status?: string;
|
|
258
|
+
startTime?: string;
|
|
259
|
+
endTime?: string;
|
|
260
|
+
/** Persisted end-user thumbs-up/down; hydrates the feedback buttons on resume. */
|
|
261
|
+
feedback?: {
|
|
262
|
+
feedback?: string | null;
|
|
263
|
+
details?: string | null;
|
|
264
|
+
} | null;
|
|
265
|
+
};
|
|
266
|
+
/** Overflow-menu ("...") action rendered on a session row by consuming UIs. */
|
|
267
|
+
type ChatSessionAction = {
|
|
268
|
+
key: string;
|
|
269
|
+
label: string;
|
|
270
|
+
destructive?: boolean;
|
|
271
|
+
onSelect: (session: ChatSessionSummary) => void | Promise<void>;
|
|
272
|
+
};
|
|
273
|
+
type ChatSessionsConfig = {
|
|
274
|
+
/** Turn on session listing / history loading. Default: false. */
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Path appended to `api.baseUrl` that returns a page of the current
|
|
278
|
+
* user's sessions. Reuses `api.headers` / `api.authToken` — the same
|
|
279
|
+
* credential already configured for streaming, whether that's a JWT
|
|
280
|
+
* bearer token or a custom API-key header. No separate auth config.
|
|
281
|
+
* Default: "/api/conversations/sessions".
|
|
282
|
+
*/
|
|
283
|
+
listEndpoint?: string;
|
|
284
|
+
/**
|
|
285
|
+
* Path template for a single session's messages. The literal token
|
|
286
|
+
* `{sessionId}` is replaced with the selected session's id.
|
|
287
|
+
* Default: "/api/conversations/sessions/{sessionId}/messages".
|
|
288
|
+
*/
|
|
289
|
+
messagesEndpoint?: string;
|
|
290
|
+
/**
|
|
291
|
+
* Sessions fetched per page. `useChatSessions` sends `page` + `limit`
|
|
292
|
+
* query params and appends each page via `loadMore`. Default: 20.
|
|
293
|
+
*/
|
|
294
|
+
pageSize?: number;
|
|
295
|
+
/**
|
|
296
|
+
* Messages fetched for a selected session (sent as `limit`). Loaded in
|
|
297
|
+
* one request; the backend caps this at 100. Default: 100.
|
|
298
|
+
*/
|
|
299
|
+
messagesPageSize?: number;
|
|
300
|
+
/** Sidebar header title (UI-facing; a plain string, not markup). Default: "Chats". */
|
|
301
|
+
title?: string;
|
|
302
|
+
/** Label for the create-new-session control. Default: "Start New Chat". */
|
|
303
|
+
newChatLabel?: string;
|
|
304
|
+
/** Whether a host UI's sessions panel starts open. Default: true. */
|
|
305
|
+
defaultOpen?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Parse the list endpoint's JSON body into session rows. Defaults to
|
|
308
|
+
* reading `{ data: ChatSessionSummary[] }`, matching every
|
|
309
|
+
* PageResponse-shaped endpoint in this workspace.
|
|
310
|
+
*/
|
|
311
|
+
parseSessionsResponse?: (json: unknown) => {
|
|
312
|
+
data: ChatSessionSummary[];
|
|
313
|
+
total?: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Parse the messages endpoint's JSON body into raw entries. Defaults
|
|
317
|
+
* to reading `{ data: ChatSessionMessageEntry[] }`.
|
|
318
|
+
*/
|
|
319
|
+
parseMessagesResponse?: (json: unknown) => {
|
|
320
|
+
data: ChatSessionMessageEntry[];
|
|
321
|
+
};
|
|
322
|
+
/** Per-session overflow-menu actions (e.g. rename, delete). Omit to hide the "..." menu in host UIs that render one. */
|
|
323
|
+
actions?: ChatSessionAction[];
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Why an agent is (un)available. "blocked" = this agent-user is blocked;
|
|
327
|
+
* "disabled" = the agent itself is off; "unknown" = loading or unreported.
|
|
328
|
+
* A machine code, not display text — the consumer owns the wording.
|
|
329
|
+
*/
|
|
330
|
+
type AgentAvailabilityStatus = "available" | "disabled" | "blocked" | "unknown";
|
|
331
|
+
/** Config for `useAgentConfig` — the GET /api/agent/config probe. */
|
|
332
|
+
type AgentConfigProbeConfig = {
|
|
333
|
+
/** Turn on the availability probe. Default: false. */
|
|
334
|
+
enabled?: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Path appended to `api.baseUrl` returning the agent's `AgentConfigResponse`
|
|
337
|
+
* (`{ enabled, blocked, ... }` — `blocked` is only populated when the host's
|
|
338
|
+
* proxy passes `sessionOwnerId` upstream). Reuses `api.headers` /
|
|
339
|
+
* `api.authToken`. Default: "/api/agent/config".
|
|
340
|
+
*/
|
|
341
|
+
endpoint?: string;
|
|
342
|
+
/**
|
|
343
|
+
* Parse the response into `{ available, status, config }`. Defaults to
|
|
344
|
+
* reading `{ enabled, blocked }` and deriving `available`/`status` from
|
|
345
|
+
* them, passing the whole body through as `config`.
|
|
346
|
+
*/
|
|
347
|
+
parseResponse?: (json: unknown) => {
|
|
348
|
+
available: boolean;
|
|
349
|
+
status?: AgentAvailabilityStatus;
|
|
350
|
+
config?: unknown;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
244
353
|
type ChatConfig = {
|
|
245
354
|
/** API configuration - required for the library to make calls */
|
|
246
355
|
api: APIConfig;
|
|
@@ -314,6 +423,12 @@ type ChatConfig = {
|
|
|
314
423
|
initialMessages?: MessageDisplay[];
|
|
315
424
|
/** Resume an existing session by providing its ID */
|
|
316
425
|
initialSessionId?: string;
|
|
426
|
+
/**
|
|
427
|
+
* Session listing / history loading (list of past sessions + a
|
|
428
|
+
* selected session's messages). See `useChatSessions` — UI packages
|
|
429
|
+
* (e.g. `@paymanai/payman-ask-sdk`) build a picker on top of it.
|
|
430
|
+
*/
|
|
431
|
+
sessions?: ChatSessionsConfig;
|
|
317
432
|
};
|
|
318
433
|
type ChatCallbacks = {
|
|
319
434
|
/** Called when a message is sent (before API call) */
|
|
@@ -457,6 +572,84 @@ declare global {
|
|
|
457
572
|
}
|
|
458
573
|
declare function useVoice(config?: VoiceConfig, callbacks?: VoiceCallbacks): UseVoiceReturn;
|
|
459
574
|
|
|
575
|
+
type UseChatSessionsOptions = {
|
|
576
|
+
api: APIConfig;
|
|
577
|
+
sessions?: ChatSessionsConfig;
|
|
578
|
+
/** Seed the active session from the host's own config on first mount. */
|
|
579
|
+
initialSessionId?: string;
|
|
580
|
+
};
|
|
581
|
+
type UseChatSessionsReturn = {
|
|
582
|
+
enabled: boolean;
|
|
583
|
+
sessionsList: ChatSessionSummary[];
|
|
584
|
+
isLoadingList: boolean;
|
|
585
|
+
listError: string | null;
|
|
586
|
+
/** Total sessions available server-side, or null if the endpoint omits it. */
|
|
587
|
+
total: number | null;
|
|
588
|
+
/** Whether another page can be loaded via `loadMore`. */
|
|
589
|
+
hasMore: boolean;
|
|
590
|
+
/** True while a `loadMore` page (page > 0) is in flight. */
|
|
591
|
+
isLoadingMore: boolean;
|
|
592
|
+
/** Fetch and append the next page of sessions. No-op when already loading or `!hasMore`. */
|
|
593
|
+
loadMore: () => void;
|
|
594
|
+
/**
|
|
595
|
+
* Optimistically reflect a just-sent message in the list: moves the active
|
|
596
|
+
* session to the top (bumping its count/timestamp) or prepends a new row.
|
|
597
|
+
* The next `refetch` reconciles with the server.
|
|
598
|
+
*/
|
|
599
|
+
noteSentMessage: (text: string) => void;
|
|
600
|
+
selectedSessionId: string | null;
|
|
601
|
+
/** The session id the chat should currently be bound to — either the selected history entry or the live draft. */
|
|
602
|
+
activeSessionId: string;
|
|
603
|
+
selectSession: (sessionId: string) => void;
|
|
604
|
+
startNewSession: () => void;
|
|
605
|
+
selectedMessages: MessageDisplay[];
|
|
606
|
+
isLoadingMessages: boolean;
|
|
607
|
+
messagesError: string | null;
|
|
608
|
+
refetch: () => void;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Lists the caller's sessions (paginated — call `loadMore` for older
|
|
612
|
+
* entries) and, once one is picked, its message history. Reuses whatever
|
|
613
|
+
* `api.headers` / `api.authToken` the host already configured for
|
|
614
|
+
* streaming — the same credential, JWT or API key, works here too, so
|
|
615
|
+
* there's nothing extra to authenticate.
|
|
616
|
+
*/
|
|
617
|
+
declare function useChatSessions({ api, sessions, initialSessionId, }: UseChatSessionsOptions): UseChatSessionsReturn;
|
|
618
|
+
|
|
619
|
+
type UseAgentConfigOptions = {
|
|
620
|
+
api: APIConfig;
|
|
621
|
+
availability?: AgentConfigProbeConfig;
|
|
622
|
+
};
|
|
623
|
+
type UseAgentConfigReturn = {
|
|
624
|
+
/** Whether the probe is turned on. */
|
|
625
|
+
enabled: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* The agent's availability, or `null` while unknown (loading, not yet
|
|
628
|
+
* fetched, or the probe failed). Callers should only hard-disable on an
|
|
629
|
+
* explicit `false` — never on `null` — so a flaky probe can't lock a
|
|
630
|
+
* working agent out.
|
|
631
|
+
*/
|
|
632
|
+
available: boolean | null;
|
|
633
|
+
/**
|
|
634
|
+
* Machine-readable reason: "blocked" (this agent-user) vs "disabled" (the
|
|
635
|
+
* agent itself), so callers can show state-specific copy. "unknown" while
|
|
636
|
+
* loading or when the endpoint omits a status. Never a human string —
|
|
637
|
+
* consumers own the wording.
|
|
638
|
+
*/
|
|
639
|
+
status: AgentAvailabilityStatus;
|
|
640
|
+
/** The raw parsed response body (the AgentConfigResponse shape), for hosts that need more than `available`/`status`. */
|
|
641
|
+
config: unknown;
|
|
642
|
+
isLoading: boolean;
|
|
643
|
+
error: string | null;
|
|
644
|
+
refetch: () => void;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Probes GET `/api/agent/config` and returns the agent's availability.
|
|
648
|
+
* Reuses whatever `api.headers` / `api.authToken` the host already
|
|
649
|
+
* configured for streaming — same credential, JWT or API key.
|
|
650
|
+
*/
|
|
651
|
+
declare function useAgentConfig({ api, availability }: UseAgentConfigOptions): UseAgentConfigReturn;
|
|
652
|
+
|
|
460
653
|
/**
|
|
461
654
|
* Cross-platform UUID v4 generator
|
|
462
655
|
* Works in both browser and React Native environments
|
|
@@ -667,4 +860,4 @@ declare function isUserActionExpired(prompt: ActiveUserAction): boolean;
|
|
|
667
860
|
|
|
668
861
|
declare function migrateActiveStream(oldUserId: string, newUserId: string): void;
|
|
669
862
|
|
|
670
|
-
export { type APIConfig, type ActiveUserAction, type AgentStage, type AnalysisMode, type ChatCallbacks, type ChatConfig, type ChunkDisplay, type FieldWidget, type JsonSchemaField, type JsonSchemaOption, type MessageDisplay, type MessageFeedbackState, type MessageRole, type RequestedSchema, type SendMessageOptions, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseChatV2Return, type UseVoiceReturn, type UserActionKind, type UserActionRequest, UserActionStaleError, type UserActionState, type UserActionStatus, type UserActionSubAction, type UserNotification, type V2EventProcessorState, type VerificationType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, buildContent, cancelUserAction, classifyField, classifyUserActionKind, coerceValue, createInitialV2State, defaultValueFor, expireUserAction, generateId, getOptions, getUserActionSecondsLeft, isNestedOrUnsupported, isRequired, isUserActionExpired, migrateActiveStream, processStreamEventV2, renderableFields, resendUserAction, resolveUserActionExpiresAt, streamWorkflowEvents, submitUserAction, useChatV2, useVoice, validateField, validateForm };
|
|
863
|
+
export { type APIConfig, type ActiveUserAction, type AgentAvailabilityStatus, type AgentConfigProbeConfig, type AgentStage, type AnalysisMode, type ChatCallbacks, type ChatConfig, type ChatSessionAction, type ChatSessionMessageEntry, type ChatSessionSummary, type ChatSessionsConfig, type ChunkDisplay, type FieldWidget, type JsonSchemaField, type JsonSchemaOption, type MessageDisplay, type MessageFeedbackState, type MessageRole, type RequestedSchema, type SendMessageOptions, type SessionParams, type StreamEvent, type StreamOptions, type StreamProgress, type StreamingStep, type UseAgentConfigOptions, type UseAgentConfigReturn, type UseChatSessionsOptions, type UseChatSessionsReturn, type UseChatV2Return, type UseVoiceReturn, type UserActionKind, type UserActionRequest, UserActionStaleError, type UserActionState, type UserActionStatus, type UserActionSubAction, type UserNotification, type V2EventProcessorState, type VerificationType, type VoiceCallbacks, type VoiceConfig, type VoicePermissions, type VoiceResult, type VoiceState, buildContent, cancelUserAction, classifyField, classifyUserActionKind, coerceValue, createInitialV2State, defaultValueFor, expireUserAction, generateId, getOptions, getUserActionSecondsLeft, isNestedOrUnsupported, isRequired, isUserActionExpired, migrateActiveStream, processStreamEventV2, renderableFields, resendUserAction, resolveUserActionExpiresAt, streamWorkflowEvents, submitUserAction, useAgentConfig, useChatSessions, useChatV2, useVoice, validateField, validateForm };
|