@yushaw/sanqian-chat 0.2.14 → 0.2.17
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/core/index.d.mts +53 -1
- package/dist/core/index.d.ts +53 -1
- package/dist/renderer/index.d.mts +88 -4
- package/dist/renderer/index.d.ts +88 -4
- package/dist/renderer/index.js +103 -50
- package/dist/renderer/index.mjs +149 -96
- package/package.json +1 -1
package/dist/core/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ResourceType, HitlInterruptPayload, ContextListItem, HitlResponse, ResourceListOptions, SanqianSDK } from '@yushaw/sanqian-sdk';
|
|
2
3
|
export { ChatStreamEvent, ContextListItem, HitlInterruptPayload, HitlInterruptType, HitlResponse, HitlRiskLevel, ResourceListOptions, ResourceListResult, ResourceType, ChatMessage as SdkChatMessage, ConversationDetail as SdkConversationDetail, ConversationInfo as SdkConversationInfo, ToolCall as SdkToolCall } from '@yushaw/sanqian-sdk';
|
|
3
4
|
|
|
@@ -434,6 +435,57 @@ type SessionResourceEvent = {
|
|
|
434
435
|
type: 'resources_cleared';
|
|
435
436
|
appName: string;
|
|
436
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Link click event with parsed URL information
|
|
440
|
+
*/
|
|
441
|
+
interface LinkClickEvent {
|
|
442
|
+
/** Original href string */
|
|
443
|
+
href: string;
|
|
444
|
+
/** Parsed URL object (undefined if invalid URL) */
|
|
445
|
+
url?: URL;
|
|
446
|
+
/** Original React mouse event */
|
|
447
|
+
originalEvent: React.MouseEvent;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Link handler configuration for custom protocol support
|
|
451
|
+
*
|
|
452
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
453
|
+
* in chat messages.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```tsx
|
|
457
|
+
* <CompactChat
|
|
458
|
+
* linkHandler={{
|
|
459
|
+
* allowedProtocols: ['sanqian-notes:', 'obsidian:'],
|
|
460
|
+
* onLinkClick: (event) => {
|
|
461
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
462
|
+
* // Handle note navigation
|
|
463
|
+
* return true; // Prevent default behavior
|
|
464
|
+
* }
|
|
465
|
+
* return false; // Let default behavior handle it
|
|
466
|
+
* }
|
|
467
|
+
* }}
|
|
468
|
+
* />
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
interface LinkHandlerConfig {
|
|
472
|
+
/**
|
|
473
|
+
* Additional protocols to allow in markdown links.
|
|
474
|
+
* These will be merged with default protocols ['workspace:', 'download:'].
|
|
475
|
+
* Without this, rehype-harden will strip links with unknown protocols.
|
|
476
|
+
*
|
|
477
|
+
* @example ['sanqian-notes:', 'obsidian:', 'bear:']
|
|
478
|
+
*/
|
|
479
|
+
allowedProtocols?: string[];
|
|
480
|
+
/**
|
|
481
|
+
* Callback when a link is clicked.
|
|
482
|
+
*
|
|
483
|
+
* @param event - Link click event with href and parsed URL
|
|
484
|
+
* @returns true if handled (prevents default and legacy onLinkClick),
|
|
485
|
+
* false/void to fall back to legacy onLinkClick prop or browser default
|
|
486
|
+
*/
|
|
487
|
+
onLinkClick?: (event: LinkClickEvent) => boolean | void;
|
|
488
|
+
}
|
|
437
489
|
|
|
438
490
|
/**
|
|
439
491
|
* Chat Adapter Interface
|
|
@@ -630,4 +682,4 @@ declare function parseToolCalls(toolCalls: unknown): ToolCall[] | undefined;
|
|
|
630
682
|
*/
|
|
631
683
|
declare function mergeConsecutiveAssistantMessages(rawMessages: ApiMessage[]): ChatMessage[];
|
|
632
684
|
|
|
633
|
-
export { type ApiMessage, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, type ChatMessage, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfigSerializable, type ChatUiStrings, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, type FloatingWindowConfig, type HitlInterruptData, type Locale, type MessageBlock, type MessageRole, type ResourcePickerItem, type ResourcePickerState, type SdkAdapterConfig, type SendMessage, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, type ToolCall, type ToolCallStatus, type WindowPosition, createChatAdapter, createSdkAdapter, mergeConsecutiveAssistantMessages, parseToolCalls };
|
|
685
|
+
export { type ApiMessage, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, type ChatMessage, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfigSerializable, type ChatUiStrings, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, type FloatingWindowConfig, type HitlInterruptData, type LinkClickEvent, type LinkHandlerConfig, type Locale, type MessageBlock, type MessageRole, type ResourcePickerItem, type ResourcePickerState, type SdkAdapterConfig, type SendMessage, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, type ToolCall, type ToolCallStatus, type WindowPosition, createChatAdapter, createSdkAdapter, mergeConsecutiveAssistantMessages, parseToolCalls };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ResourceType, HitlInterruptPayload, ContextListItem, HitlResponse, ResourceListOptions, SanqianSDK } from '@yushaw/sanqian-sdk';
|
|
2
3
|
export { ChatStreamEvent, ContextListItem, HitlInterruptPayload, HitlInterruptType, HitlResponse, HitlRiskLevel, ResourceListOptions, ResourceListResult, ResourceType, ChatMessage as SdkChatMessage, ConversationDetail as SdkConversationDetail, ConversationInfo as SdkConversationInfo, ToolCall as SdkToolCall } from '@yushaw/sanqian-sdk';
|
|
3
4
|
|
|
@@ -434,6 +435,57 @@ type SessionResourceEvent = {
|
|
|
434
435
|
type: 'resources_cleared';
|
|
435
436
|
appName: string;
|
|
436
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Link click event with parsed URL information
|
|
440
|
+
*/
|
|
441
|
+
interface LinkClickEvent {
|
|
442
|
+
/** Original href string */
|
|
443
|
+
href: string;
|
|
444
|
+
/** Parsed URL object (undefined if invalid URL) */
|
|
445
|
+
url?: URL;
|
|
446
|
+
/** Original React mouse event */
|
|
447
|
+
originalEvent: React.MouseEvent;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Link handler configuration for custom protocol support
|
|
451
|
+
*
|
|
452
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
453
|
+
* in chat messages.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```tsx
|
|
457
|
+
* <CompactChat
|
|
458
|
+
* linkHandler={{
|
|
459
|
+
* allowedProtocols: ['sanqian-notes:', 'obsidian:'],
|
|
460
|
+
* onLinkClick: (event) => {
|
|
461
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
462
|
+
* // Handle note navigation
|
|
463
|
+
* return true; // Prevent default behavior
|
|
464
|
+
* }
|
|
465
|
+
* return false; // Let default behavior handle it
|
|
466
|
+
* }
|
|
467
|
+
* }}
|
|
468
|
+
* />
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
interface LinkHandlerConfig {
|
|
472
|
+
/**
|
|
473
|
+
* Additional protocols to allow in markdown links.
|
|
474
|
+
* These will be merged with default protocols ['workspace:', 'download:'].
|
|
475
|
+
* Without this, rehype-harden will strip links with unknown protocols.
|
|
476
|
+
*
|
|
477
|
+
* @example ['sanqian-notes:', 'obsidian:', 'bear:']
|
|
478
|
+
*/
|
|
479
|
+
allowedProtocols?: string[];
|
|
480
|
+
/**
|
|
481
|
+
* Callback when a link is clicked.
|
|
482
|
+
*
|
|
483
|
+
* @param event - Link click event with href and parsed URL
|
|
484
|
+
* @returns true if handled (prevents default and legacy onLinkClick),
|
|
485
|
+
* false/void to fall back to legacy onLinkClick prop or browser default
|
|
486
|
+
*/
|
|
487
|
+
onLinkClick?: (event: LinkClickEvent) => boolean | void;
|
|
488
|
+
}
|
|
437
489
|
|
|
438
490
|
/**
|
|
439
491
|
* Chat Adapter Interface
|
|
@@ -630,4 +682,4 @@ declare function parseToolCalls(toolCalls: unknown): ToolCall[] | undefined;
|
|
|
630
682
|
*/
|
|
631
683
|
declare function mergeConsecutiveAssistantMessages(rawMessages: ApiMessage[]): ChatMessage[];
|
|
632
684
|
|
|
633
|
-
export { type ApiMessage, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, type ChatMessage, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfigSerializable, type ChatUiStrings, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, type FloatingWindowConfig, type HitlInterruptData, type Locale, type MessageBlock, type MessageRole, type ResourcePickerItem, type ResourcePickerState, type SdkAdapterConfig, type SendMessage, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, type ToolCall, type ToolCallStatus, type WindowPosition, createChatAdapter, createSdkAdapter, mergeConsecutiveAssistantMessages, parseToolCalls };
|
|
685
|
+
export { type ApiMessage, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, type ChatMessage, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfigSerializable, type ChatUiStrings, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, type FloatingWindowConfig, type HitlInterruptData, type LinkClickEvent, type LinkHandlerConfig, type Locale, type MessageBlock, type MessageRole, type ResourcePickerItem, type ResourcePickerState, type SdkAdapterConfig, type SendMessage, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, type ToolCall, type ToolCallStatus, type WindowPosition, createChatAdapter, createSdkAdapter, mergeConsecutiveAssistantMessages, parseToolCalls };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ReactNode, RefObject, CSSProperties } from 'react';
|
|
1
3
|
import { ResourceType, HitlInterruptPayload, ContextListItem, HitlResponse, ResourceListOptions, SanqianSDK } from '@yushaw/sanqian-sdk';
|
|
2
4
|
export { ContextListItem, HitlInterruptPayload, HitlInterruptType, HitlResponse, HitlRiskLevel, ResourceListOptions, ResourceListResult, ResourceType, ChatMessage as SdkChatMessage, ConversationDetail as SdkConversationDetail, ConversationInfo as SdkConversationInfo, ToolCall as SdkToolCall } from '@yushaw/sanqian-sdk';
|
|
3
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import * as react from 'react';
|
|
5
|
-
import { ReactNode, RefObject, CSSProperties } from 'react';
|
|
6
6
|
export { ChatMessage, ChatStreamEvent, SDKConfig, SanqianSDK, ToolDefinition } from '@yushaw/sanqian-sdk/browser';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -438,6 +438,57 @@ type SessionResourceEvent = {
|
|
|
438
438
|
type: 'resources_cleared';
|
|
439
439
|
appName: string;
|
|
440
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* Link click event with parsed URL information
|
|
443
|
+
*/
|
|
444
|
+
interface LinkClickEvent {
|
|
445
|
+
/** Original href string */
|
|
446
|
+
href: string;
|
|
447
|
+
/** Parsed URL object (undefined if invalid URL) */
|
|
448
|
+
url?: URL;
|
|
449
|
+
/** Original React mouse event */
|
|
450
|
+
originalEvent: react__default.MouseEvent;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Link handler configuration for custom protocol support
|
|
454
|
+
*
|
|
455
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
456
|
+
* in chat messages.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```tsx
|
|
460
|
+
* <CompactChat
|
|
461
|
+
* linkHandler={{
|
|
462
|
+
* allowedProtocols: ['sanqian-notes:', 'obsidian:'],
|
|
463
|
+
* onLinkClick: (event) => {
|
|
464
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
465
|
+
* // Handle note navigation
|
|
466
|
+
* return true; // Prevent default behavior
|
|
467
|
+
* }
|
|
468
|
+
* return false; // Let default behavior handle it
|
|
469
|
+
* }
|
|
470
|
+
* }}
|
|
471
|
+
* />
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
interface LinkHandlerConfig {
|
|
475
|
+
/**
|
|
476
|
+
* Additional protocols to allow in markdown links.
|
|
477
|
+
* These will be merged with default protocols ['workspace:', 'download:'].
|
|
478
|
+
* Without this, rehype-harden will strip links with unknown protocols.
|
|
479
|
+
*
|
|
480
|
+
* @example ['sanqian-notes:', 'obsidian:', 'bear:']
|
|
481
|
+
*/
|
|
482
|
+
allowedProtocols?: string[];
|
|
483
|
+
/**
|
|
484
|
+
* Callback when a link is clicked.
|
|
485
|
+
*
|
|
486
|
+
* @param event - Link click event with href and parsed URL
|
|
487
|
+
* @returns true if handled (prevents default and legacy onLinkClick),
|
|
488
|
+
* false/void to fall back to legacy onLinkClick prop or browser default
|
|
489
|
+
*/
|
|
490
|
+
onLinkClick?: (event: LinkClickEvent) => boolean | void;
|
|
491
|
+
}
|
|
441
492
|
|
|
442
493
|
/**
|
|
443
494
|
* Chat Adapter Interface
|
|
@@ -1267,6 +1318,27 @@ interface CompactChatProps {
|
|
|
1267
1318
|
getErrorMessage?: (errorCode: string) => string;
|
|
1268
1319
|
/** Use floating window container style (for transparent Electron windows) */
|
|
1269
1320
|
floating?: boolean;
|
|
1321
|
+
/**
|
|
1322
|
+
* Link handler configuration for custom protocol support.
|
|
1323
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
1324
|
+
* in chat message content.
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```tsx
|
|
1328
|
+
* <CompactChat
|
|
1329
|
+
* linkHandler={{
|
|
1330
|
+
* allowedProtocols: ['sanqian-notes:'],
|
|
1331
|
+
* onLinkClick: (event) => {
|
|
1332
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
1333
|
+
* // Handle navigation
|
|
1334
|
+
* return true;
|
|
1335
|
+
* }
|
|
1336
|
+
* }
|
|
1337
|
+
* }}
|
|
1338
|
+
* />
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
linkHandler?: LinkHandlerConfig;
|
|
1270
1342
|
}
|
|
1271
1343
|
declare const CompactChat: react.NamedExoticComponent<CompactChatProps>;
|
|
1272
1344
|
|
|
@@ -1392,6 +1464,8 @@ interface ResourcePickerProps {
|
|
|
1392
1464
|
anchorRef?: React.RefObject<HTMLElement>;
|
|
1393
1465
|
/** Locale for i18n */
|
|
1394
1466
|
locale?: 'en' | 'zh';
|
|
1467
|
+
/** Additional class name (for theme support) */
|
|
1468
|
+
className?: string;
|
|
1395
1469
|
}
|
|
1396
1470
|
declare const ResourcePicker: react.NamedExoticComponent<ResourcePickerProps>;
|
|
1397
1471
|
|
|
@@ -1454,6 +1528,8 @@ interface AddResourceButtonProps {
|
|
|
1454
1528
|
disabled?: boolean;
|
|
1455
1529
|
/** Locale */
|
|
1456
1530
|
locale?: 'en' | 'zh';
|
|
1531
|
+
/** Theme class for dark mode support */
|
|
1532
|
+
themeClass?: string;
|
|
1457
1533
|
}
|
|
1458
1534
|
declare const AddResourceButton: react.NamedExoticComponent<AddResourceButtonProps>;
|
|
1459
1535
|
|
|
@@ -1519,8 +1595,16 @@ interface MarkdownRendererProps {
|
|
|
1519
1595
|
children?: ReactNode;
|
|
1520
1596
|
}>;
|
|
1521
1597
|
};
|
|
1522
|
-
/**
|
|
1598
|
+
/**
|
|
1599
|
+
* Callback when a link is clicked (legacy, use linkHandler for new code)
|
|
1600
|
+
* @deprecated Use linkHandler.onLinkClick instead
|
|
1601
|
+
*/
|
|
1523
1602
|
onLinkClick?: (href: string, event: React.MouseEvent) => void;
|
|
1603
|
+
/**
|
|
1604
|
+
* Link handler configuration for custom protocol support.
|
|
1605
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
1606
|
+
*/
|
|
1607
|
+
linkHandler?: LinkHandlerConfig;
|
|
1524
1608
|
}
|
|
1525
1609
|
declare const MarkdownRenderer: react.NamedExoticComponent<MarkdownRendererProps>;
|
|
1526
1610
|
|
|
@@ -1551,4 +1635,4 @@ declare function ensureChatBaseStyles(): void;
|
|
|
1551
1635
|
*/
|
|
1552
1636
|
declare function ensureFullChatStyles(): void;
|
|
1553
1637
|
|
|
1554
|
-
export { AddResourceButton, type AddResourceButtonProps, type AlertAction, AlertBanner, type AlertBannerProps, type AlertConfig, type AlertType, AttachButton, type AttachButtonProps, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, AttachedResourceTags, type AttachedResourceTagsProps, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, ChatInput, type ChatInputHandle, type ChatInputProps, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfig, type ChatUiConfigSerializable, type ChatUiStrings, CompactChat, type CompactChatProps, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, FloatingChat, type FloatingChatProps, type FloatingWindowConfig, HistoryList, type HistoryListProps, HistoryModal, type HistoryModalProps, HitlCard, type HitlCardProps, type HitlInterruptData, I18nProvider, type I18nProviderProps, IntermediateSteps, type IntermediateStepsProps, type Locale, MarkdownRenderer, type MarkdownRendererProps, type MessageBlock, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MessageRole, ModeToggleButton, type ModeToggleButtonProps, PanelControls, type PanelControlsProps, PanelHeaderButtons, PanelResizer, Resizer, type ResizerProps, type ResolvedTheme, ResourceChip, ResourceChipList, type ResourceChipListProps, type ResourceChipProps, ResourcePicker, type ResourcePickerItem, type ResourcePickerProps, type ResourcePickerState, SanqianChat, SanqianChatMessage, type SanqianChatMessageProps, type SanqianChatProps, SanqianMessageList, type SanqianMessageListHandle, type SanqianMessageListProps, type SdkAdapterConfig, type SendMessage, type SendMessageOptions, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, StreamingTimeline, type StreamingTimelineProps, type ThemeMode, ThemeProvider, type ThemeProviderProps, ThinkingSection, type ThinkingSectionProps, ToolArgumentsDisplay, type ToolArgumentsDisplayProps, type ToolCall, type ToolCallStatus, type Translations, type UseAttachStateReturn, type UseChatOptions, type UseChatPanelReturn, type UseChatReturn, type UseConnectionOptions, type UseConnectionReturn, type UseConversationsOptions, type UseConversationsReturn, type UseFocusPersistenceOptions, type UseResourcePickerOptions, type UseResourcePickerReturn, type WindowPosition, createChatAdapter, createIpcAdapter, createSdkAdapter, ensureChatBaseStyles, ensureFullChatStyles, getTranslations, resolveChatStrings, useAttachState, useChat, useChatPanel, useChatStyles, useConnection, useConversations, useFocusPersistence, useI18n, useIpcUiConfig, useResolvedUiConfig, useResourcePicker, useStandaloneI18n, useStandaloneTheme, useTheme };
|
|
1638
|
+
export { AddResourceButton, type AddResourceButtonProps, type AlertAction, AlertBanner, type AlertBannerProps, type AlertConfig, type AlertType, AttachButton, type AttachButtonProps, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, AttachedResourceTags, type AttachedResourceTagsProps, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, ChatInput, type ChatInputHandle, type ChatInputProps, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfig, type ChatUiConfigSerializable, type ChatUiStrings, CompactChat, type CompactChatProps, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, FloatingChat, type FloatingChatProps, type FloatingWindowConfig, HistoryList, type HistoryListProps, HistoryModal, type HistoryModalProps, HitlCard, type HitlCardProps, type HitlInterruptData, I18nProvider, type I18nProviderProps, IntermediateSteps, type IntermediateStepsProps, type LinkClickEvent, type LinkHandlerConfig, type Locale, MarkdownRenderer, type MarkdownRendererProps, type MessageBlock, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MessageRole, ModeToggleButton, type ModeToggleButtonProps, PanelControls, type PanelControlsProps, PanelHeaderButtons, PanelResizer, Resizer, type ResizerProps, type ResolvedTheme, ResourceChip, ResourceChipList, type ResourceChipListProps, type ResourceChipProps, ResourcePicker, type ResourcePickerItem, type ResourcePickerProps, type ResourcePickerState, SanqianChat, SanqianChatMessage, type SanqianChatMessageProps, type SanqianChatProps, SanqianMessageList, type SanqianMessageListHandle, type SanqianMessageListProps, type SdkAdapterConfig, type SendMessage, type SendMessageOptions, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, StreamingTimeline, type StreamingTimelineProps, type ThemeMode, ThemeProvider, type ThemeProviderProps, ThinkingSection, type ThinkingSectionProps, ToolArgumentsDisplay, type ToolArgumentsDisplayProps, type ToolCall, type ToolCallStatus, type Translations, type UseAttachStateReturn, type UseChatOptions, type UseChatPanelReturn, type UseChatReturn, type UseConnectionOptions, type UseConnectionReturn, type UseConversationsOptions, type UseConversationsReturn, type UseFocusPersistenceOptions, type UseResourcePickerOptions, type UseResourcePickerReturn, type WindowPosition, createChatAdapter, createIpcAdapter, createSdkAdapter, ensureChatBaseStyles, ensureFullChatStyles, getTranslations, resolveChatStrings, useAttachState, useChat, useChatPanel, useChatStyles, useConnection, useConversations, useFocusPersistence, useI18n, useIpcUiConfig, useResolvedUiConfig, useResourcePicker, useStandaloneI18n, useStandaloneTheme, useTheme };
|
package/dist/renderer/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ReactNode, RefObject, CSSProperties } from 'react';
|
|
1
3
|
import { ResourceType, HitlInterruptPayload, ContextListItem, HitlResponse, ResourceListOptions, SanqianSDK } from '@yushaw/sanqian-sdk';
|
|
2
4
|
export { ContextListItem, HitlInterruptPayload, HitlInterruptType, HitlResponse, HitlRiskLevel, ResourceListOptions, ResourceListResult, ResourceType, ChatMessage as SdkChatMessage, ConversationDetail as SdkConversationDetail, ConversationInfo as SdkConversationInfo, ToolCall as SdkToolCall } from '@yushaw/sanqian-sdk';
|
|
3
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import * as react from 'react';
|
|
5
|
-
import { ReactNode, RefObject, CSSProperties } from 'react';
|
|
6
6
|
export { ChatMessage, ChatStreamEvent, SDKConfig, SanqianSDK, ToolDefinition } from '@yushaw/sanqian-sdk/browser';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -438,6 +438,57 @@ type SessionResourceEvent = {
|
|
|
438
438
|
type: 'resources_cleared';
|
|
439
439
|
appName: string;
|
|
440
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* Link click event with parsed URL information
|
|
443
|
+
*/
|
|
444
|
+
interface LinkClickEvent {
|
|
445
|
+
/** Original href string */
|
|
446
|
+
href: string;
|
|
447
|
+
/** Parsed URL object (undefined if invalid URL) */
|
|
448
|
+
url?: URL;
|
|
449
|
+
/** Original React mouse event */
|
|
450
|
+
originalEvent: react__default.MouseEvent;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Link handler configuration for custom protocol support
|
|
454
|
+
*
|
|
455
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
456
|
+
* in chat messages.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```tsx
|
|
460
|
+
* <CompactChat
|
|
461
|
+
* linkHandler={{
|
|
462
|
+
* allowedProtocols: ['sanqian-notes:', 'obsidian:'],
|
|
463
|
+
* onLinkClick: (event) => {
|
|
464
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
465
|
+
* // Handle note navigation
|
|
466
|
+
* return true; // Prevent default behavior
|
|
467
|
+
* }
|
|
468
|
+
* return false; // Let default behavior handle it
|
|
469
|
+
* }
|
|
470
|
+
* }}
|
|
471
|
+
* />
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
interface LinkHandlerConfig {
|
|
475
|
+
/**
|
|
476
|
+
* Additional protocols to allow in markdown links.
|
|
477
|
+
* These will be merged with default protocols ['workspace:', 'download:'].
|
|
478
|
+
* Without this, rehype-harden will strip links with unknown protocols.
|
|
479
|
+
*
|
|
480
|
+
* @example ['sanqian-notes:', 'obsidian:', 'bear:']
|
|
481
|
+
*/
|
|
482
|
+
allowedProtocols?: string[];
|
|
483
|
+
/**
|
|
484
|
+
* Callback when a link is clicked.
|
|
485
|
+
*
|
|
486
|
+
* @param event - Link click event with href and parsed URL
|
|
487
|
+
* @returns true if handled (prevents default and legacy onLinkClick),
|
|
488
|
+
* false/void to fall back to legacy onLinkClick prop or browser default
|
|
489
|
+
*/
|
|
490
|
+
onLinkClick?: (event: LinkClickEvent) => boolean | void;
|
|
491
|
+
}
|
|
441
492
|
|
|
442
493
|
/**
|
|
443
494
|
* Chat Adapter Interface
|
|
@@ -1267,6 +1318,27 @@ interface CompactChatProps {
|
|
|
1267
1318
|
getErrorMessage?: (errorCode: string) => string;
|
|
1268
1319
|
/** Use floating window container style (for transparent Electron windows) */
|
|
1269
1320
|
floating?: boolean;
|
|
1321
|
+
/**
|
|
1322
|
+
* Link handler configuration for custom protocol support.
|
|
1323
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
1324
|
+
* in chat message content.
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```tsx
|
|
1328
|
+
* <CompactChat
|
|
1329
|
+
* linkHandler={{
|
|
1330
|
+
* allowedProtocols: ['sanqian-notes:'],
|
|
1331
|
+
* onLinkClick: (event) => {
|
|
1332
|
+
* if (event.href.startsWith('sanqian-notes://')) {
|
|
1333
|
+
* // Handle navigation
|
|
1334
|
+
* return true;
|
|
1335
|
+
* }
|
|
1336
|
+
* }
|
|
1337
|
+
* }}
|
|
1338
|
+
* />
|
|
1339
|
+
* ```
|
|
1340
|
+
*/
|
|
1341
|
+
linkHandler?: LinkHandlerConfig;
|
|
1270
1342
|
}
|
|
1271
1343
|
declare const CompactChat: react.NamedExoticComponent<CompactChatProps>;
|
|
1272
1344
|
|
|
@@ -1392,6 +1464,8 @@ interface ResourcePickerProps {
|
|
|
1392
1464
|
anchorRef?: React.RefObject<HTMLElement>;
|
|
1393
1465
|
/** Locale for i18n */
|
|
1394
1466
|
locale?: 'en' | 'zh';
|
|
1467
|
+
/** Additional class name (for theme support) */
|
|
1468
|
+
className?: string;
|
|
1395
1469
|
}
|
|
1396
1470
|
declare const ResourcePicker: react.NamedExoticComponent<ResourcePickerProps>;
|
|
1397
1471
|
|
|
@@ -1454,6 +1528,8 @@ interface AddResourceButtonProps {
|
|
|
1454
1528
|
disabled?: boolean;
|
|
1455
1529
|
/** Locale */
|
|
1456
1530
|
locale?: 'en' | 'zh';
|
|
1531
|
+
/** Theme class for dark mode support */
|
|
1532
|
+
themeClass?: string;
|
|
1457
1533
|
}
|
|
1458
1534
|
declare const AddResourceButton: react.NamedExoticComponent<AddResourceButtonProps>;
|
|
1459
1535
|
|
|
@@ -1519,8 +1595,16 @@ interface MarkdownRendererProps {
|
|
|
1519
1595
|
children?: ReactNode;
|
|
1520
1596
|
}>;
|
|
1521
1597
|
};
|
|
1522
|
-
/**
|
|
1598
|
+
/**
|
|
1599
|
+
* Callback when a link is clicked (legacy, use linkHandler for new code)
|
|
1600
|
+
* @deprecated Use linkHandler.onLinkClick instead
|
|
1601
|
+
*/
|
|
1523
1602
|
onLinkClick?: (href: string, event: React.MouseEvent) => void;
|
|
1603
|
+
/**
|
|
1604
|
+
* Link handler configuration for custom protocol support.
|
|
1605
|
+
* Allows third-party apps to handle custom URL schemes (e.g., sanqian-notes://)
|
|
1606
|
+
*/
|
|
1607
|
+
linkHandler?: LinkHandlerConfig;
|
|
1524
1608
|
}
|
|
1525
1609
|
declare const MarkdownRenderer: react.NamedExoticComponent<MarkdownRendererProps>;
|
|
1526
1610
|
|
|
@@ -1551,4 +1635,4 @@ declare function ensureChatBaseStyles(): void;
|
|
|
1551
1635
|
*/
|
|
1552
1636
|
declare function ensureFullChatStyles(): void;
|
|
1553
1637
|
|
|
1554
|
-
export { AddResourceButton, type AddResourceButtonProps, type AlertAction, AlertBanner, type AlertBannerProps, type AlertConfig, type AlertType, AttachButton, type AttachButtonProps, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, AttachedResourceTags, type AttachedResourceTagsProps, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, ChatInput, type ChatInputHandle, type ChatInputProps, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfig, type ChatUiConfigSerializable, type ChatUiStrings, CompactChat, type CompactChatProps, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, FloatingChat, type FloatingChatProps, type FloatingWindowConfig, HistoryList, type HistoryListProps, HistoryModal, type HistoryModalProps, HitlCard, type HitlCardProps, type HitlInterruptData, I18nProvider, type I18nProviderProps, IntermediateSteps, type IntermediateStepsProps, type Locale, MarkdownRenderer, type MarkdownRendererProps, type MessageBlock, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MessageRole, ModeToggleButton, type ModeToggleButtonProps, PanelControls, type PanelControlsProps, PanelHeaderButtons, PanelResizer, Resizer, type ResizerProps, type ResolvedTheme, ResourceChip, ResourceChipList, type ResourceChipListProps, type ResourceChipProps, ResourcePicker, type ResourcePickerItem, type ResourcePickerProps, type ResourcePickerState, SanqianChat, SanqianChatMessage, type SanqianChatMessageProps, type SanqianChatProps, SanqianMessageList, type SanqianMessageListHandle, type SanqianMessageListProps, type SdkAdapterConfig, type SendMessage, type SendMessageOptions, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, StreamingTimeline, type StreamingTimelineProps, type ThemeMode, ThemeProvider, type ThemeProviderProps, ThinkingSection, type ThinkingSectionProps, ToolArgumentsDisplay, type ToolArgumentsDisplayProps, type ToolCall, type ToolCallStatus, type Translations, type UseAttachStateReturn, type UseChatOptions, type UseChatPanelReturn, type UseChatReturn, type UseConnectionOptions, type UseConnectionReturn, type UseConversationsOptions, type UseConversationsReturn, type UseFocusPersistenceOptions, type UseResourcePickerOptions, type UseResourcePickerReturn, type WindowPosition, createChatAdapter, createIpcAdapter, createSdkAdapter, ensureChatBaseStyles, ensureFullChatStyles, getTranslations, resolveChatStrings, useAttachState, useChat, useChatPanel, useChatStyles, useConnection, useConversations, useFocusPersistence, useI18n, useIpcUiConfig, useResolvedUiConfig, useResourcePicker, useStandaloneI18n, useStandaloneTheme, useTheme };
|
|
1638
|
+
export { AddResourceButton, type AddResourceButtonProps, type AlertAction, AlertBanner, type AlertBannerProps, type AlertConfig, type AlertType, AttachButton, type AttachButtonProps, type AttachConfig, type AttachPosition, type AttachState, type AttachedResource, AttachedResourceTags, type AttachedResourceTagsProps, type AttachmentMenuItem, type AttachmentMenuItemType, type ChatAdapter, type ChatAdapterConfig, type ChatFontSize, ChatInput, type ChatInputHandle, type ChatInputProps, type ChatPanelConfig, type ChatPanelMode, type ChatPanelPosition, type ChatThemeMode, type ChatUiConfig, type ChatUiConfigSerializable, type ChatUiStrings, CompactChat, type CompactChatProps, type ConnectionErrorCode, type ConnectionStatus, type ContextProviderInfo, type ConversationDetail, type ConversationInfo, FloatingChat, type FloatingChatProps, type FloatingWindowConfig, HistoryList, type HistoryListProps, HistoryModal, type HistoryModalProps, HitlCard, type HitlCardProps, type HitlInterruptData, I18nProvider, type I18nProviderProps, IntermediateSteps, type IntermediateStepsProps, type LinkClickEvent, type LinkHandlerConfig, type Locale, MarkdownRenderer, type MarkdownRendererProps, type MessageBlock, MessageBubble, type MessageBubbleProps, MessageList, type MessageListProps, type MessageRole, ModeToggleButton, type ModeToggleButtonProps, PanelControls, type PanelControlsProps, PanelHeaderButtons, PanelResizer, Resizer, type ResizerProps, type ResolvedTheme, ResourceChip, ResourceChipList, type ResourceChipListProps, type ResourceChipProps, ResourcePicker, type ResourcePickerItem, type ResourcePickerProps, type ResourcePickerState, SanqianChat, SanqianChatMessage, type SanqianChatMessageProps, type SanqianChatProps, SanqianMessageList, type SanqianMessageListHandle, type SanqianMessageListProps, type SdkAdapterConfig, type SendMessage, type SendMessageOptions, type SessionResource, type SessionResourceEvent, type StoredSessionResource, type StreamEvent, StreamingTimeline, type StreamingTimelineProps, type ThemeMode, ThemeProvider, type ThemeProviderProps, ThinkingSection, type ThinkingSectionProps, ToolArgumentsDisplay, type ToolArgumentsDisplayProps, type ToolCall, type ToolCallStatus, type Translations, type UseAttachStateReturn, type UseChatOptions, type UseChatPanelReturn, type UseChatReturn, type UseConnectionOptions, type UseConnectionReturn, type UseConversationsOptions, type UseConversationsReturn, type UseFocusPersistenceOptions, type UseResourcePickerOptions, type UseResourcePickerReturn, type WindowPosition, createChatAdapter, createIpcAdapter, createSdkAdapter, ensureChatBaseStyles, ensureFullChatStyles, getTranslations, resolveChatStrings, useAttachState, useChat, useChatPanel, useChatStyles, useConnection, useConversations, useFocusPersistence, useI18n, useIpcUiConfig, useResolvedUiConfig, useResourcePicker, useStandaloneI18n, useStandaloneTheme, useTheme };
|