@xinghunm/ai-chat 1.2.1 → 1.3.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/dist/index.d.mts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +3711 -524
- package/dist/index.mjs +3713 -526
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -264,6 +264,7 @@ interface ChatMessage {
|
|
|
264
264
|
sessionId: string;
|
|
265
265
|
role: ChatRole;
|
|
266
266
|
content: string;
|
|
267
|
+
skills?: string[];
|
|
267
268
|
blocks?: ChatMessageBlock[];
|
|
268
269
|
attachments?: ChatImageAttachment[];
|
|
269
270
|
localOnly?: boolean;
|
|
@@ -297,6 +298,8 @@ interface ChatTransportStartStreamArgs {
|
|
|
297
298
|
mode: ChatAgentMode;
|
|
298
299
|
/** User message content that should be sent to the backend. */
|
|
299
300
|
content: string;
|
|
301
|
+
/** Optional skills selected in the composer and sent alongside the user message. */
|
|
302
|
+
skills?: string[];
|
|
300
303
|
/**
|
|
301
304
|
* Optional image attachments selected in the composer and sent alongside the text.
|
|
302
305
|
*/
|
|
@@ -318,6 +321,8 @@ interface ChatTransportStartStreamArgs {
|
|
|
318
321
|
interface ChatTransport {
|
|
319
322
|
/** Loads the model list shown by the composer model selector. */
|
|
320
323
|
getModels: () => Promise<ChatModelsResponse>;
|
|
324
|
+
/** Optional skill catalog loader used by the composer slash menu. */
|
|
325
|
+
getSkills?: () => Promise<ChatSkillsResponse>;
|
|
321
326
|
/** Starts a single assistant response stream for the current user message. */
|
|
322
327
|
startStream: (args: ChatTransportStartStreamArgs) => Promise<void>;
|
|
323
328
|
/** Requests termination of the active backend stream for a session. */
|
|
@@ -364,6 +369,12 @@ interface ChatModel {
|
|
|
364
369
|
interface ChatModelsResponse {
|
|
365
370
|
data: ChatModel[];
|
|
366
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Response payload returned by the optional chat skills endpoint.
|
|
374
|
+
*/
|
|
375
|
+
interface ChatSkillsResponse {
|
|
376
|
+
skills: string[];
|
|
377
|
+
}
|
|
367
378
|
/**
|
|
368
379
|
* Response payload returned after a terminate request has been processed.
|
|
369
380
|
*/
|
|
@@ -430,6 +441,9 @@ interface AiChatLabels {
|
|
|
430
441
|
questionnaireMultiSelectHint?: string;
|
|
431
442
|
questionnaireOtherOptionLabel?: string;
|
|
432
443
|
questionnaireOtherPlaceholder?: string;
|
|
444
|
+
skillLoading?: string;
|
|
445
|
+
skillEmpty?: string;
|
|
446
|
+
removeSkillAriaLabel?: string;
|
|
433
447
|
}
|
|
434
448
|
/**
|
|
435
449
|
* State and actions exposed to custom new-chat trigger renderers.
|
|
@@ -507,12 +521,24 @@ type AiChatProps = Omit<AiChatProviderProps, 'children'> & {
|
|
|
507
521
|
showNewChatButton?: boolean;
|
|
508
522
|
/** Optional renderer used to override the lightweight new-chat trigger UI. */
|
|
509
523
|
renderNewChatTrigger?: (props: NewChatTriggerRenderProps) => ReactNode;
|
|
524
|
+
/**
|
|
525
|
+
* When true, only renders the composer before the first message is sent.
|
|
526
|
+
* Once a conversation starts, the full thread layout is shown automatically.
|
|
527
|
+
*/
|
|
528
|
+
showComposerOnlyBeforeFirstMessage?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Called whenever the "conversation started" state changes.
|
|
531
|
+
*
|
|
532
|
+
* A conversation is considered started after the active session has messages,
|
|
533
|
+
* a streaming message, or an error to render.
|
|
534
|
+
*/
|
|
535
|
+
onConversationStartedChange?: (started: boolean) => void;
|
|
510
536
|
};
|
|
511
537
|
/**
|
|
512
538
|
* Top-level AI chat component. Wraps AiChatProvider and composes the full
|
|
513
539
|
* chat UI: optional conversation sidebar + thread + composer.
|
|
514
540
|
*/
|
|
515
|
-
declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatTrigger, ...providerProps }: AiChatProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
541
|
+
declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatTrigger, showComposerOnlyBeforeFirstMessage, onConversationStartedChange, ...providerProps }: AiChatProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
516
542
|
|
|
517
543
|
/**
|
|
518
544
|
* Endpoint overrides for the built-in HTTP transport adapter.
|
|
@@ -520,6 +546,8 @@ declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatT
|
|
|
520
546
|
interface DefaultChatTransportEndpoints {
|
|
521
547
|
/** Relative path used to fetch the available model list. */
|
|
522
548
|
models?: string;
|
|
549
|
+
/** Relative path used to fetch the available skills. */
|
|
550
|
+
skills?: string;
|
|
523
551
|
/** Relative path used to start a streaming chat completion. */
|
|
524
552
|
completions?: string;
|
|
525
553
|
/** Relative path used to request stream termination. */
|
|
@@ -544,6 +572,7 @@ interface DefaultChatTransportRequestBodyBuilderArgs {
|
|
|
544
572
|
model: string;
|
|
545
573
|
mode: ChatAgentMode;
|
|
546
574
|
content: string;
|
|
575
|
+
skills?: string[];
|
|
547
576
|
attachments?: ChatImageAttachment[];
|
|
548
577
|
}
|
|
549
578
|
/**
|
|
@@ -555,6 +584,7 @@ type DefaultChatTransportRequestBodyBuilder = (args: DefaultChatTransportRequest
|
|
|
555
584
|
* Optional model resolver used to override the default `/models` request.
|
|
556
585
|
*/
|
|
557
586
|
type DefaultChatTransportModelsResolver = () => Promise<ChatModelsResponse>;
|
|
587
|
+
type DefaultChatTransportSkillsResolver = () => Promise<ChatSkillsResponse>;
|
|
558
588
|
/**
|
|
559
589
|
* Options for the built-in HTTP transport adapter.
|
|
560
590
|
*/
|
|
@@ -563,12 +593,16 @@ interface CreateDefaultChatTransportOptions {
|
|
|
563
593
|
apiBaseUrl: string;
|
|
564
594
|
/** Authorization header value forwarded to the backend. */
|
|
565
595
|
authToken: string;
|
|
596
|
+
/** Optional extra headers appended to every request sent by the default transport. */
|
|
597
|
+
headers?: Record<string, string>;
|
|
566
598
|
/** Optional tool execution policy translated into stream request headers. */
|
|
567
599
|
toolExecutionPolicy?: ChatToolExecutionPolicy;
|
|
568
600
|
/** Optional extra headers appended to each streaming chat completion request. */
|
|
569
601
|
streamHeaders?: Record<string, string>;
|
|
570
602
|
/** Optional resolver used to override the built-in model catalog request. */
|
|
571
603
|
resolveModels?: DefaultChatTransportModelsResolver;
|
|
604
|
+
/** Optional resolver used to override the built-in skills catalog request. */
|
|
605
|
+
resolveSkills?: DefaultChatTransportSkillsResolver;
|
|
572
606
|
/** Optional builder used to override the built-in chat completion request body. */
|
|
573
607
|
buildRequestBody?: DefaultChatTransportRequestBodyBuilder;
|
|
574
608
|
/** Optional transformer used to normalize custom stream packets. */
|
|
@@ -581,7 +615,7 @@ interface CreateDefaultChatTransportOptions {
|
|
|
581
615
|
/**
|
|
582
616
|
* Creates the built-in transport backed by the current HTTP chat API.
|
|
583
617
|
*/
|
|
584
|
-
declare const createDefaultChatTransport: ({ apiBaseUrl, authToken, toolExecutionPolicy, streamHeaders, resolveModels, buildRequestBody, transformStreamPacket, endpoints, axiosInstance, }: CreateDefaultChatTransportOptions) => ChatTransport;
|
|
618
|
+
declare const createDefaultChatTransport: ({ apiBaseUrl, authToken, headers, toolExecutionPolicy, streamHeaders, resolveModels, resolveSkills, buildRequestBody, transformStreamPacket, endpoints, axiosInstance, }: CreateDefaultChatTransportOptions) => ChatTransport;
|
|
585
619
|
|
|
586
620
|
declare const ChatThread: () => _emotion_react_jsx_runtime.JSX.Element;
|
|
587
621
|
|
|
@@ -594,10 +628,13 @@ interface ChatComposerViewProps {
|
|
|
594
628
|
attachments: ChatImageAttachment[];
|
|
595
629
|
attachmentNotice?: 'limit_reached' | null;
|
|
596
630
|
attachmentLimitNotice: string;
|
|
631
|
+
selectedSkills: string[];
|
|
597
632
|
selectedModel: string;
|
|
598
633
|
selectedMode: ChatAgentMode;
|
|
599
634
|
availableModels: ChatModel[];
|
|
635
|
+
availableSkills: string[];
|
|
600
636
|
isModelsLoading: boolean;
|
|
637
|
+
isSkillsLoading: boolean;
|
|
601
638
|
isModelsError: boolean;
|
|
602
639
|
hasModels: boolean;
|
|
603
640
|
/** Whether a streaming response is currently in progress. */
|
|
@@ -613,13 +650,19 @@ interface ChatComposerViewProps {
|
|
|
613
650
|
};
|
|
614
651
|
expandComposerAriaLabel: string;
|
|
615
652
|
collapseComposerAriaLabel: string;
|
|
653
|
+
skillLoadingLabel: string;
|
|
654
|
+
skillEmptyLabel: string;
|
|
655
|
+
removeSkillAriaLabel: string;
|
|
616
656
|
onValueChange: (value: string) => void;
|
|
617
657
|
onPickImages: (files: FileList | File[]) => void;
|
|
618
658
|
onPasteImages: (files: File[]) => void;
|
|
619
659
|
onRemoveAttachment: (attachmentId: string) => void;
|
|
660
|
+
onAddSkill: (skill: string) => void;
|
|
661
|
+
onRemoveSkill: (skill: string) => void;
|
|
620
662
|
onSelectedModelChange: (value: string) => void;
|
|
621
663
|
onSelectedModeChange: (value: ChatAgentMode) => void;
|
|
622
664
|
onReloadModels: () => void;
|
|
665
|
+
onOpenSkillPicker: () => void;
|
|
623
666
|
/** Called to abort the active streaming response. */
|
|
624
667
|
onStop: () => void | Promise<void>;
|
|
625
668
|
/** Called to send a new user message. */
|
|
@@ -666,6 +709,8 @@ interface ChatSendRefOptions {
|
|
|
666
709
|
sessionId?: string;
|
|
667
710
|
/** Whether to consume the composer attachment draft. Defaults to true for composer sends. */
|
|
668
711
|
includeComposerAttachments?: boolean;
|
|
712
|
+
/** Whether to consume the composer skill draft. Defaults to true for composer sends. */
|
|
713
|
+
includeComposerSkills?: boolean;
|
|
669
714
|
}
|
|
670
715
|
interface ChatContextValue {
|
|
671
716
|
store: ChatStoreInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ interface ChatMessage {
|
|
|
264
264
|
sessionId: string;
|
|
265
265
|
role: ChatRole;
|
|
266
266
|
content: string;
|
|
267
|
+
skills?: string[];
|
|
267
268
|
blocks?: ChatMessageBlock[];
|
|
268
269
|
attachments?: ChatImageAttachment[];
|
|
269
270
|
localOnly?: boolean;
|
|
@@ -297,6 +298,8 @@ interface ChatTransportStartStreamArgs {
|
|
|
297
298
|
mode: ChatAgentMode;
|
|
298
299
|
/** User message content that should be sent to the backend. */
|
|
299
300
|
content: string;
|
|
301
|
+
/** Optional skills selected in the composer and sent alongside the user message. */
|
|
302
|
+
skills?: string[];
|
|
300
303
|
/**
|
|
301
304
|
* Optional image attachments selected in the composer and sent alongside the text.
|
|
302
305
|
*/
|
|
@@ -318,6 +321,8 @@ interface ChatTransportStartStreamArgs {
|
|
|
318
321
|
interface ChatTransport {
|
|
319
322
|
/** Loads the model list shown by the composer model selector. */
|
|
320
323
|
getModels: () => Promise<ChatModelsResponse>;
|
|
324
|
+
/** Optional skill catalog loader used by the composer slash menu. */
|
|
325
|
+
getSkills?: () => Promise<ChatSkillsResponse>;
|
|
321
326
|
/** Starts a single assistant response stream for the current user message. */
|
|
322
327
|
startStream: (args: ChatTransportStartStreamArgs) => Promise<void>;
|
|
323
328
|
/** Requests termination of the active backend stream for a session. */
|
|
@@ -364,6 +369,12 @@ interface ChatModel {
|
|
|
364
369
|
interface ChatModelsResponse {
|
|
365
370
|
data: ChatModel[];
|
|
366
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Response payload returned by the optional chat skills endpoint.
|
|
374
|
+
*/
|
|
375
|
+
interface ChatSkillsResponse {
|
|
376
|
+
skills: string[];
|
|
377
|
+
}
|
|
367
378
|
/**
|
|
368
379
|
* Response payload returned after a terminate request has been processed.
|
|
369
380
|
*/
|
|
@@ -430,6 +441,9 @@ interface AiChatLabels {
|
|
|
430
441
|
questionnaireMultiSelectHint?: string;
|
|
431
442
|
questionnaireOtherOptionLabel?: string;
|
|
432
443
|
questionnaireOtherPlaceholder?: string;
|
|
444
|
+
skillLoading?: string;
|
|
445
|
+
skillEmpty?: string;
|
|
446
|
+
removeSkillAriaLabel?: string;
|
|
433
447
|
}
|
|
434
448
|
/**
|
|
435
449
|
* State and actions exposed to custom new-chat trigger renderers.
|
|
@@ -507,12 +521,24 @@ type AiChatProps = Omit<AiChatProviderProps, 'children'> & {
|
|
|
507
521
|
showNewChatButton?: boolean;
|
|
508
522
|
/** Optional renderer used to override the lightweight new-chat trigger UI. */
|
|
509
523
|
renderNewChatTrigger?: (props: NewChatTriggerRenderProps) => ReactNode;
|
|
524
|
+
/**
|
|
525
|
+
* When true, only renders the composer before the first message is sent.
|
|
526
|
+
* Once a conversation starts, the full thread layout is shown automatically.
|
|
527
|
+
*/
|
|
528
|
+
showComposerOnlyBeforeFirstMessage?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Called whenever the "conversation started" state changes.
|
|
531
|
+
*
|
|
532
|
+
* A conversation is considered started after the active session has messages,
|
|
533
|
+
* a streaming message, or an error to render.
|
|
534
|
+
*/
|
|
535
|
+
onConversationStartedChange?: (started: boolean) => void;
|
|
510
536
|
};
|
|
511
537
|
/**
|
|
512
538
|
* Top-level AI chat component. Wraps AiChatProvider and composes the full
|
|
513
539
|
* chat UI: optional conversation sidebar + thread + composer.
|
|
514
540
|
*/
|
|
515
|
-
declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatTrigger, ...providerProps }: AiChatProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
541
|
+
declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatTrigger, showComposerOnlyBeforeFirstMessage, onConversationStartedChange, ...providerProps }: AiChatProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
516
542
|
|
|
517
543
|
/**
|
|
518
544
|
* Endpoint overrides for the built-in HTTP transport adapter.
|
|
@@ -520,6 +546,8 @@ declare const AiChat: ({ showConversationList, showNewChatButton, renderNewChatT
|
|
|
520
546
|
interface DefaultChatTransportEndpoints {
|
|
521
547
|
/** Relative path used to fetch the available model list. */
|
|
522
548
|
models?: string;
|
|
549
|
+
/** Relative path used to fetch the available skills. */
|
|
550
|
+
skills?: string;
|
|
523
551
|
/** Relative path used to start a streaming chat completion. */
|
|
524
552
|
completions?: string;
|
|
525
553
|
/** Relative path used to request stream termination. */
|
|
@@ -544,6 +572,7 @@ interface DefaultChatTransportRequestBodyBuilderArgs {
|
|
|
544
572
|
model: string;
|
|
545
573
|
mode: ChatAgentMode;
|
|
546
574
|
content: string;
|
|
575
|
+
skills?: string[];
|
|
547
576
|
attachments?: ChatImageAttachment[];
|
|
548
577
|
}
|
|
549
578
|
/**
|
|
@@ -555,6 +584,7 @@ type DefaultChatTransportRequestBodyBuilder = (args: DefaultChatTransportRequest
|
|
|
555
584
|
* Optional model resolver used to override the default `/models` request.
|
|
556
585
|
*/
|
|
557
586
|
type DefaultChatTransportModelsResolver = () => Promise<ChatModelsResponse>;
|
|
587
|
+
type DefaultChatTransportSkillsResolver = () => Promise<ChatSkillsResponse>;
|
|
558
588
|
/**
|
|
559
589
|
* Options for the built-in HTTP transport adapter.
|
|
560
590
|
*/
|
|
@@ -563,12 +593,16 @@ interface CreateDefaultChatTransportOptions {
|
|
|
563
593
|
apiBaseUrl: string;
|
|
564
594
|
/** Authorization header value forwarded to the backend. */
|
|
565
595
|
authToken: string;
|
|
596
|
+
/** Optional extra headers appended to every request sent by the default transport. */
|
|
597
|
+
headers?: Record<string, string>;
|
|
566
598
|
/** Optional tool execution policy translated into stream request headers. */
|
|
567
599
|
toolExecutionPolicy?: ChatToolExecutionPolicy;
|
|
568
600
|
/** Optional extra headers appended to each streaming chat completion request. */
|
|
569
601
|
streamHeaders?: Record<string, string>;
|
|
570
602
|
/** Optional resolver used to override the built-in model catalog request. */
|
|
571
603
|
resolveModels?: DefaultChatTransportModelsResolver;
|
|
604
|
+
/** Optional resolver used to override the built-in skills catalog request. */
|
|
605
|
+
resolveSkills?: DefaultChatTransportSkillsResolver;
|
|
572
606
|
/** Optional builder used to override the built-in chat completion request body. */
|
|
573
607
|
buildRequestBody?: DefaultChatTransportRequestBodyBuilder;
|
|
574
608
|
/** Optional transformer used to normalize custom stream packets. */
|
|
@@ -581,7 +615,7 @@ interface CreateDefaultChatTransportOptions {
|
|
|
581
615
|
/**
|
|
582
616
|
* Creates the built-in transport backed by the current HTTP chat API.
|
|
583
617
|
*/
|
|
584
|
-
declare const createDefaultChatTransport: ({ apiBaseUrl, authToken, toolExecutionPolicy, streamHeaders, resolveModels, buildRequestBody, transformStreamPacket, endpoints, axiosInstance, }: CreateDefaultChatTransportOptions) => ChatTransport;
|
|
618
|
+
declare const createDefaultChatTransport: ({ apiBaseUrl, authToken, headers, toolExecutionPolicy, streamHeaders, resolveModels, resolveSkills, buildRequestBody, transformStreamPacket, endpoints, axiosInstance, }: CreateDefaultChatTransportOptions) => ChatTransport;
|
|
585
619
|
|
|
586
620
|
declare const ChatThread: () => _emotion_react_jsx_runtime.JSX.Element;
|
|
587
621
|
|
|
@@ -594,10 +628,13 @@ interface ChatComposerViewProps {
|
|
|
594
628
|
attachments: ChatImageAttachment[];
|
|
595
629
|
attachmentNotice?: 'limit_reached' | null;
|
|
596
630
|
attachmentLimitNotice: string;
|
|
631
|
+
selectedSkills: string[];
|
|
597
632
|
selectedModel: string;
|
|
598
633
|
selectedMode: ChatAgentMode;
|
|
599
634
|
availableModels: ChatModel[];
|
|
635
|
+
availableSkills: string[];
|
|
600
636
|
isModelsLoading: boolean;
|
|
637
|
+
isSkillsLoading: boolean;
|
|
601
638
|
isModelsError: boolean;
|
|
602
639
|
hasModels: boolean;
|
|
603
640
|
/** Whether a streaming response is currently in progress. */
|
|
@@ -613,13 +650,19 @@ interface ChatComposerViewProps {
|
|
|
613
650
|
};
|
|
614
651
|
expandComposerAriaLabel: string;
|
|
615
652
|
collapseComposerAriaLabel: string;
|
|
653
|
+
skillLoadingLabel: string;
|
|
654
|
+
skillEmptyLabel: string;
|
|
655
|
+
removeSkillAriaLabel: string;
|
|
616
656
|
onValueChange: (value: string) => void;
|
|
617
657
|
onPickImages: (files: FileList | File[]) => void;
|
|
618
658
|
onPasteImages: (files: File[]) => void;
|
|
619
659
|
onRemoveAttachment: (attachmentId: string) => void;
|
|
660
|
+
onAddSkill: (skill: string) => void;
|
|
661
|
+
onRemoveSkill: (skill: string) => void;
|
|
620
662
|
onSelectedModelChange: (value: string) => void;
|
|
621
663
|
onSelectedModeChange: (value: ChatAgentMode) => void;
|
|
622
664
|
onReloadModels: () => void;
|
|
665
|
+
onOpenSkillPicker: () => void;
|
|
623
666
|
/** Called to abort the active streaming response. */
|
|
624
667
|
onStop: () => void | Promise<void>;
|
|
625
668
|
/** Called to send a new user message. */
|
|
@@ -666,6 +709,8 @@ interface ChatSendRefOptions {
|
|
|
666
709
|
sessionId?: string;
|
|
667
710
|
/** Whether to consume the composer attachment draft. Defaults to true for composer sends. */
|
|
668
711
|
includeComposerAttachments?: boolean;
|
|
712
|
+
/** Whether to consume the composer skill draft. Defaults to true for composer sends. */
|
|
713
|
+
includeComposerSkills?: boolean;
|
|
669
714
|
}
|
|
670
715
|
interface ChatContextValue {
|
|
671
716
|
store: ChatStoreInstance;
|