connectbase-client 3.27.0 → 3.28.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 CHANGED
@@ -3859,27 +3859,36 @@ declare class OAuthAPI {
3859
3859
  * `error=account_not_found` 를 받아 가입 안내 UX 로 분기해야 한다. 신규 가입까지 한 번에
3860
3860
  * 처리하려면 [signUp] 을 사용한다.
3861
3861
  *
3862
+ * 기본적으로 미가입 사용자는 콜백에서 `error=account_not_found` 로 돌아온다(신규 자동가입 안 됨).
3863
+ * 로그인/가입을 한 버튼으로 처리하려면 `{ createIfNotExists: true }` 를 주거나, 별도 "회원가입"
3864
+ * 버튼에서 [signUp] 을 호출한다.
3865
+ *
3862
3866
  * @param provider - OAuth 프로바이더 (google, naver, github, discord)
3863
3867
  * @param callbackUrl - OAuth 완료 후 리다이렉트될 앱의 URL
3864
3868
  * @param state - 선택적 state 파라미터 (CSRF 방지 등)
3869
+ * @param options - `createIfNotExists: true` 면 미가입 사용자를 자동 가입시킨다([signUp] 과 동일 동작).
3865
3870
  *
3866
3871
  * @example
3867
3872
  * ```typescript
3868
- * // "로그인" 버튼 클릭
3873
+ * // "로그인" 버튼 기존 회원만. 신규는 account_not_found.
3869
3874
  * await cb.oauth.signIn('google', 'https://myapp.com/oauth/callback')
3875
+ *
3876
+ * // 로그인=가입 통합 버튼 — 신규면 자동 가입
3877
+ * await cb.oauth.signIn('google', cb, undefined, { createIfNotExists: true })
3870
3878
  * ```
3871
3879
  *
3872
3880
  * @example
3873
3881
  * ```typescript
3874
- * // callback 페이지에서
3882
+ * // callback 페이지에서 — 미가입이면 가입 화면으로 안내
3875
3883
  * const result = await cb.oauth.getCallbackResult()
3876
3884
  * if (result?.error === 'account_not_found') {
3877
- * // 가입되지 않은 사용자 — 회원가입 화면으로 안내
3878
3885
  * window.location.href = '/signup'
3879
3886
  * }
3880
3887
  * ```
3881
3888
  */
3882
- signIn(provider: OAuthProvider, callbackUrl: string, state?: string): Promise<void>;
3889
+ signIn(provider: OAuthProvider, callbackUrl: string, state?: string, options?: {
3890
+ createIfNotExists?: boolean;
3891
+ }): Promise<void>;
3883
3892
  /**
3884
3893
  * 소셜 회원가입 (리다이렉트 방식) — 사용자가 명시적으로 가입 의사를 표시한 경우에만 호출.
3885
3894
  *
@@ -7500,6 +7509,47 @@ interface AIChatRequest {
7500
7509
  agentic?: boolean;
7501
7510
  toolGroupId?: string;
7502
7511
  }
7512
+ /**
7513
+ * `chatStream` 콜백.
7514
+ *
7515
+ * 대부분 콜백은 SSE 이벤트 종류별로 매핑되며, `onAbort` 는 호출자가 전달한
7516
+ * `AbortSignal` 로 스트림을 취소했을 때 호출된다(에러가 아니므로 `onError` 와 구분).
7517
+ */
7518
+ interface AIChatStreamCallbacks {
7519
+ onSources?: (sources: AISource[]) => void;
7520
+ /**
7521
+ * 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
7522
+ * 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
7523
+ */
7524
+ onReasoning?: (reasoning: string) => void;
7525
+ onToken?: (content: string) => void;
7526
+ onToolEvent?: (event: AIToolEvent) => void;
7527
+ /**
7528
+ * Agentic 검색(`agentic: true`) 진행 상황. agentic 검색이 검색어를
7529
+ * 생성하고 다중 라운드로 검색하는 각 단계마다 호출되어, "검색 중…"
7530
+ * 진행 UI 를 구성할 수 있다. agentic 미사용 시 호출되지 않는다.
7531
+ */
7532
+ onSearching?: (progress: AgenticSearchProgress) => void;
7533
+ onDone?: () => void;
7534
+ onError?: (error: string) => void;
7535
+ /**
7536
+ * `options.signal` 로 스트림을 취소(abort)했을 때 호출된다. 정상적인
7537
+ * 사용자 취소이므로 `onError` 대신 본 콜백이 호출되며, `onDone` 은 호출되지
7538
+ * 않는다. 미지정 시 abort 는 조용히(예외 없이) 종료된다.
7539
+ */
7540
+ onAbort?: () => void;
7541
+ }
7542
+ /**
7543
+ * `chatStream` 호출 옵션. `signal` 로 진행 중인 SSE 스트림을 취소할 수 있다.
7544
+ */
7545
+ interface AIChatStreamOptions {
7546
+ /**
7547
+ * 진행 중인 스트림을 취소하기 위한 `AbortSignal`. abort 하면 SSE 연결이
7548
+ * 닫히고, 서버는 요청 컨텍스트 취소를 통해 server-side agent tool loop
7549
+ * (`toolGroupId` 사용 시)까지 중단한다.
7550
+ */
7551
+ signal?: AbortSignal;
7552
+ }
7503
7553
  interface AIToolEvent {
7504
7554
  type: 'tool_start' | 'tool_end' | 'heartbeat';
7505
7555
  name?: string;
@@ -7569,6 +7619,8 @@ interface AIStreamChunk {
7569
7619
  success?: boolean;
7570
7620
  durationMs?: number;
7571
7621
  searching?: AgenticSearchProgress;
7622
+ error?: string;
7623
+ message?: string;
7572
7624
  }
7573
7625
 
7574
7626
  /**
@@ -7631,6 +7683,15 @@ declare class AIAPI {
7631
7683
  /**
7632
7684
  * AI 채팅 스트리밍 (SSE)
7633
7685
  *
7686
+ * @param request AI 채팅 요청
7687
+ * @param callbacks 스트림 이벤트 콜백 (토큰/추론/도구/검색/완료/에러/취소)
7688
+ * @param options 선택적 옵션. `options.signal` 에 `AbortSignal` 을 전달하면
7689
+ * 호출자가 진행 중인 스트림을 취소할 수 있다. abort 시 SSE 연결이 닫히고,
7690
+ * 서버는 요청 컨텍스트(`c.Request.Context()`) 취소를 통해 server-side agent
7691
+ * tool loop (`toolGroupId` 사용 시)까지 함께 중단한다. abort 는 정상적인
7692
+ * 사용자 취소이므로 `onError` 가 아니라 `callbacks.onAbort?.()` 가 호출되며
7693
+ * (지정 시), `onDone` 은 호출되지 않는다.
7694
+ *
7634
7695
  * @example
7635
7696
  * ```typescript
7636
7697
  * await cb.ai.chatStream({
@@ -7644,25 +7705,19 @@ declare class AIAPI {
7644
7705
  * onError: (error) => console.error('에러:', error)
7645
7706
  * })
7646
7707
  * ```
7708
+ *
7709
+ * @example 취소(stop 버튼)
7710
+ * ```typescript
7711
+ * const controller = new AbortController()
7712
+ * // stop 버튼: controller.abort()
7713
+ * await cb.ai.chatStream(
7714
+ * { messages: [{ role: 'user', content: '...' }], toolGroupId: 'tg-id' },
7715
+ * { onToken: (c) => process.stdout.write(c), onAbort: () => console.log('취소됨') },
7716
+ * { signal: controller.signal },
7717
+ * )
7718
+ * ```
7647
7719
  */
7648
- chatStream(request: AIChatRequest, callbacks: {
7649
- onSources?: (sources: AISource[]) => void;
7650
- /**
7651
- * 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
7652
- * 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
7653
- */
7654
- onReasoning?: (reasoning: string) => void;
7655
- onToken?: (content: string) => void;
7656
- onToolEvent?: (event: AIToolEvent) => void;
7657
- /**
7658
- * Agentic 검색(`agentic: true`) 진행 상황. agentic 검색이 검색어를
7659
- * 생성하고 다중 라운드로 검색하는 각 단계마다 호출되어, "검색 중…"
7660
- * 진행 UI 를 구성할 수 있다. agentic 미사용 시 호출되지 않는다.
7661
- */
7662
- onSearching?: (progress: AgenticSearchProgress) => void;
7663
- onDone?: () => void;
7664
- onError?: (error: string) => void;
7665
- }): Promise<void>;
7720
+ chatStream(request: AIChatRequest, callbacks: AIChatStreamCallbacks, options?: AIChatStreamOptions): Promise<void>;
7666
7721
  }
7667
7722
 
7668
7723
  /**
@@ -8776,4 +8831,4 @@ declare class ConnectBase {
8776
8831
  updateConfig(config: Partial<ConnectBaseConfig>): void;
8777
8832
  }
8778
8833
 
8779
- export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
8834
+ export { AIAPI, type AIChatRequest, type AIChatResponse, type AIChatStreamCallbacks, type AIChatStreamOptions, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
package/dist/index.d.ts CHANGED
@@ -3859,27 +3859,36 @@ declare class OAuthAPI {
3859
3859
  * `error=account_not_found` 를 받아 가입 안내 UX 로 분기해야 한다. 신규 가입까지 한 번에
3860
3860
  * 처리하려면 [signUp] 을 사용한다.
3861
3861
  *
3862
+ * 기본적으로 미가입 사용자는 콜백에서 `error=account_not_found` 로 돌아온다(신규 자동가입 안 됨).
3863
+ * 로그인/가입을 한 버튼으로 처리하려면 `{ createIfNotExists: true }` 를 주거나, 별도 "회원가입"
3864
+ * 버튼에서 [signUp] 을 호출한다.
3865
+ *
3862
3866
  * @param provider - OAuth 프로바이더 (google, naver, github, discord)
3863
3867
  * @param callbackUrl - OAuth 완료 후 리다이렉트될 앱의 URL
3864
3868
  * @param state - 선택적 state 파라미터 (CSRF 방지 등)
3869
+ * @param options - `createIfNotExists: true` 면 미가입 사용자를 자동 가입시킨다([signUp] 과 동일 동작).
3865
3870
  *
3866
3871
  * @example
3867
3872
  * ```typescript
3868
- * // "로그인" 버튼 클릭
3873
+ * // "로그인" 버튼 기존 회원만. 신규는 account_not_found.
3869
3874
  * await cb.oauth.signIn('google', 'https://myapp.com/oauth/callback')
3875
+ *
3876
+ * // 로그인=가입 통합 버튼 — 신규면 자동 가입
3877
+ * await cb.oauth.signIn('google', cb, undefined, { createIfNotExists: true })
3870
3878
  * ```
3871
3879
  *
3872
3880
  * @example
3873
3881
  * ```typescript
3874
- * // callback 페이지에서
3882
+ * // callback 페이지에서 — 미가입이면 가입 화면으로 안내
3875
3883
  * const result = await cb.oauth.getCallbackResult()
3876
3884
  * if (result?.error === 'account_not_found') {
3877
- * // 가입되지 않은 사용자 — 회원가입 화면으로 안내
3878
3885
  * window.location.href = '/signup'
3879
3886
  * }
3880
3887
  * ```
3881
3888
  */
3882
- signIn(provider: OAuthProvider, callbackUrl: string, state?: string): Promise<void>;
3889
+ signIn(provider: OAuthProvider, callbackUrl: string, state?: string, options?: {
3890
+ createIfNotExists?: boolean;
3891
+ }): Promise<void>;
3883
3892
  /**
3884
3893
  * 소셜 회원가입 (리다이렉트 방식) — 사용자가 명시적으로 가입 의사를 표시한 경우에만 호출.
3885
3894
  *
@@ -7500,6 +7509,47 @@ interface AIChatRequest {
7500
7509
  agentic?: boolean;
7501
7510
  toolGroupId?: string;
7502
7511
  }
7512
+ /**
7513
+ * `chatStream` 콜백.
7514
+ *
7515
+ * 대부분 콜백은 SSE 이벤트 종류별로 매핑되며, `onAbort` 는 호출자가 전달한
7516
+ * `AbortSignal` 로 스트림을 취소했을 때 호출된다(에러가 아니므로 `onError` 와 구분).
7517
+ */
7518
+ interface AIChatStreamCallbacks {
7519
+ onSources?: (sources: AISource[]) => void;
7520
+ /**
7521
+ * 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
7522
+ * 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
7523
+ */
7524
+ onReasoning?: (reasoning: string) => void;
7525
+ onToken?: (content: string) => void;
7526
+ onToolEvent?: (event: AIToolEvent) => void;
7527
+ /**
7528
+ * Agentic 검색(`agentic: true`) 진행 상황. agentic 검색이 검색어를
7529
+ * 생성하고 다중 라운드로 검색하는 각 단계마다 호출되어, "검색 중…"
7530
+ * 진행 UI 를 구성할 수 있다. agentic 미사용 시 호출되지 않는다.
7531
+ */
7532
+ onSearching?: (progress: AgenticSearchProgress) => void;
7533
+ onDone?: () => void;
7534
+ onError?: (error: string) => void;
7535
+ /**
7536
+ * `options.signal` 로 스트림을 취소(abort)했을 때 호출된다. 정상적인
7537
+ * 사용자 취소이므로 `onError` 대신 본 콜백이 호출되며, `onDone` 은 호출되지
7538
+ * 않는다. 미지정 시 abort 는 조용히(예외 없이) 종료된다.
7539
+ */
7540
+ onAbort?: () => void;
7541
+ }
7542
+ /**
7543
+ * `chatStream` 호출 옵션. `signal` 로 진행 중인 SSE 스트림을 취소할 수 있다.
7544
+ */
7545
+ interface AIChatStreamOptions {
7546
+ /**
7547
+ * 진행 중인 스트림을 취소하기 위한 `AbortSignal`. abort 하면 SSE 연결이
7548
+ * 닫히고, 서버는 요청 컨텍스트 취소를 통해 server-side agent tool loop
7549
+ * (`toolGroupId` 사용 시)까지 중단한다.
7550
+ */
7551
+ signal?: AbortSignal;
7552
+ }
7503
7553
  interface AIToolEvent {
7504
7554
  type: 'tool_start' | 'tool_end' | 'heartbeat';
7505
7555
  name?: string;
@@ -7569,6 +7619,8 @@ interface AIStreamChunk {
7569
7619
  success?: boolean;
7570
7620
  durationMs?: number;
7571
7621
  searching?: AgenticSearchProgress;
7622
+ error?: string;
7623
+ message?: string;
7572
7624
  }
7573
7625
 
7574
7626
  /**
@@ -7631,6 +7683,15 @@ declare class AIAPI {
7631
7683
  /**
7632
7684
  * AI 채팅 스트리밍 (SSE)
7633
7685
  *
7686
+ * @param request AI 채팅 요청
7687
+ * @param callbacks 스트림 이벤트 콜백 (토큰/추론/도구/검색/완료/에러/취소)
7688
+ * @param options 선택적 옵션. `options.signal` 에 `AbortSignal` 을 전달하면
7689
+ * 호출자가 진행 중인 스트림을 취소할 수 있다. abort 시 SSE 연결이 닫히고,
7690
+ * 서버는 요청 컨텍스트(`c.Request.Context()`) 취소를 통해 server-side agent
7691
+ * tool loop (`toolGroupId` 사용 시)까지 함께 중단한다. abort 는 정상적인
7692
+ * 사용자 취소이므로 `onError` 가 아니라 `callbacks.onAbort?.()` 가 호출되며
7693
+ * (지정 시), `onDone` 은 호출되지 않는다.
7694
+ *
7634
7695
  * @example
7635
7696
  * ```typescript
7636
7697
  * await cb.ai.chatStream({
@@ -7644,25 +7705,19 @@ declare class AIAPI {
7644
7705
  * onError: (error) => console.error('에러:', error)
7645
7706
  * })
7646
7707
  * ```
7708
+ *
7709
+ * @example 취소(stop 버튼)
7710
+ * ```typescript
7711
+ * const controller = new AbortController()
7712
+ * // stop 버튼: controller.abort()
7713
+ * await cb.ai.chatStream(
7714
+ * { messages: [{ role: 'user', content: '...' }], toolGroupId: 'tg-id' },
7715
+ * { onToken: (c) => process.stdout.write(c), onAbort: () => console.log('취소됨') },
7716
+ * { signal: controller.signal },
7717
+ * )
7718
+ * ```
7647
7719
  */
7648
- chatStream(request: AIChatRequest, callbacks: {
7649
- onSources?: (sources: AISource[]) => void;
7650
- /**
7651
- * 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
7652
- * 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
7653
- */
7654
- onReasoning?: (reasoning: string) => void;
7655
- onToken?: (content: string) => void;
7656
- onToolEvent?: (event: AIToolEvent) => void;
7657
- /**
7658
- * Agentic 검색(`agentic: true`) 진행 상황. agentic 검색이 검색어를
7659
- * 생성하고 다중 라운드로 검색하는 각 단계마다 호출되어, "검색 중…"
7660
- * 진행 UI 를 구성할 수 있다. agentic 미사용 시 호출되지 않는다.
7661
- */
7662
- onSearching?: (progress: AgenticSearchProgress) => void;
7663
- onDone?: () => void;
7664
- onError?: (error: string) => void;
7665
- }): Promise<void>;
7720
+ chatStream(request: AIChatRequest, callbacks: AIChatStreamCallbacks, options?: AIChatStreamOptions): Promise<void>;
7666
7721
  }
7667
7722
 
7668
7723
  /**
@@ -8776,4 +8831,4 @@ declare class ConnectBase {
8776
8831
  updateConfig(config: Partial<ConnectBaseConfig>): void;
8777
8832
  }
8778
8833
 
8779
- export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
8834
+ export { AIAPI, type AIChatRequest, type AIChatResponse, type AIChatStreamCallbacks, type AIChatStreamOptions, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AIToolEvent, AUTH_MEMBER_ID_TOKEN, type AckMessagesRequest, type AdMobDailyReport, type AdMobReportResponse, type AdMobReportSummary, type AdReportResponse, type AdReportSummary, type AdmobConnectionInfo, AdsAPI, type AdsenseConnectionInfo, type AgenticSearchProgress, type AggregateResult, type AggregateStage, type AnalyticsConfig, type AnalyticsEvent, ApiError, type ApiErrorDetail, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchOperationResult, type BatchSetPageMetaRequest, type BatchWriteResult, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsentOptions, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateCheckoutSessionRequest, type CreateCheckoutSessionResponse, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreatePublicKeyRequest, type CreatePublicKeyResponse, type CreateRelationRequest, type CreateRoomResult, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, EndpointAPI, type EndpointCallInit, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchDataResponse, type FetchFilesResponse, type FetchPublicKeysResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConfig, GameConfigAPI, type GameConfigPatch, type GameConnectionState, type GameConnectionStatus, type GameDelta, GameError, type GameErrorCode, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, GuestSessionConflictError, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LeaderboardListResponse, type LeaderboardScoreEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MatchqueueListResponse, type MatchqueueTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PollUntilOptions, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublicKeyItem, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStaleMessage, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type ScriptDetailResponse, type ScriptListResponse, type ScriptMeta, type ScriptVersion, type ScriptVersionListResponse, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, SessionManager, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamContentPart, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamImageURLPart, type StreamMessage, type StreamOptions, type StreamSession, type StreamTextPart, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableAccessLevel, type TableColumnDef, type TableIndex, type TableRelation, type TableSchema, type TableSchemaDefinition, type TokenPersistence, type TransactionRead, type TransactionResult, type TransactionWrite, type TransactionWriteResult, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateDocumentRequest, type UpdateLobbyRequest, type UpdatePublicKeyRequest, type UpdatePublicKeyResponse, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type ValidationSchema, type ValidationSchemaField, type ValidationStateTransitions, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, detectInAppBrowser, escapeToExternalBrowser, isWebTransportSupported, toCreateRoomWire };
package/dist/index.js CHANGED
@@ -4822,28 +4822,35 @@ var OAuthAPI = class {
4822
4822
  * `error=account_not_found` 를 받아 가입 안내 UX 로 분기해야 한다. 신규 가입까지 한 번에
4823
4823
  * 처리하려면 [signUp] 을 사용한다.
4824
4824
  *
4825
+ * 기본적으로 미가입 사용자는 콜백에서 `error=account_not_found` 로 돌아온다(신규 자동가입 안 됨).
4826
+ * 로그인/가입을 한 버튼으로 처리하려면 `{ createIfNotExists: true }` 를 주거나, 별도 "회원가입"
4827
+ * 버튼에서 [signUp] 을 호출한다.
4828
+ *
4825
4829
  * @param provider - OAuth 프로바이더 (google, naver, github, discord)
4826
4830
  * @param callbackUrl - OAuth 완료 후 리다이렉트될 앱의 URL
4827
4831
  * @param state - 선택적 state 파라미터 (CSRF 방지 등)
4832
+ * @param options - `createIfNotExists: true` 면 미가입 사용자를 자동 가입시킨다([signUp] 과 동일 동작).
4828
4833
  *
4829
4834
  * @example
4830
4835
  * ```typescript
4831
- * // "로그인" 버튼 클릭
4836
+ * // "로그인" 버튼 기존 회원만. 신규는 account_not_found.
4832
4837
  * await cb.oauth.signIn('google', 'https://myapp.com/oauth/callback')
4838
+ *
4839
+ * // 로그인=가입 통합 버튼 — 신규면 자동 가입
4840
+ * await cb.oauth.signIn('google', cb, undefined, { createIfNotExists: true })
4833
4841
  * ```
4834
4842
  *
4835
4843
  * @example
4836
4844
  * ```typescript
4837
- * // callback 페이지에서
4845
+ * // callback 페이지에서 — 미가입이면 가입 화면으로 안내
4838
4846
  * const result = await cb.oauth.getCallbackResult()
4839
4847
  * if (result?.error === 'account_not_found') {
4840
- * // 가입되지 않은 사용자 — 회원가입 화면으로 안내
4841
4848
  * window.location.href = '/signup'
4842
4849
  * }
4843
4850
  * ```
4844
4851
  */
4845
- async signIn(provider, callbackUrl, state) {
4846
- return this.startCentralOAuth(provider, callbackUrl, state, "signin");
4852
+ async signIn(provider, callbackUrl, state, options) {
4853
+ return this.startCentralOAuth(provider, callbackUrl, state, options?.createIfNotExists ? "signup" : "signin");
4847
4854
  }
4848
4855
  /**
4849
4856
  * 소셜 회원가입 (리다이렉트 방식) — 사용자가 명시적으로 가입 의사를 표시한 경우에만 호출.
@@ -8542,6 +8549,15 @@ var AIAPI = class {
8542
8549
  /**
8543
8550
  * AI 채팅 스트리밍 (SSE)
8544
8551
  *
8552
+ * @param request AI 채팅 요청
8553
+ * @param callbacks 스트림 이벤트 콜백 (토큰/추론/도구/검색/완료/에러/취소)
8554
+ * @param options 선택적 옵션. `options.signal` 에 `AbortSignal` 을 전달하면
8555
+ * 호출자가 진행 중인 스트림을 취소할 수 있다. abort 시 SSE 연결이 닫히고,
8556
+ * 서버는 요청 컨텍스트(`c.Request.Context()`) 취소를 통해 server-side agent
8557
+ * tool loop (`toolGroupId` 사용 시)까지 함께 중단한다. abort 는 정상적인
8558
+ * 사용자 취소이므로 `onError` 가 아니라 `callbacks.onAbort?.()` 가 호출되며
8559
+ * (지정 시), `onDone` 은 호출되지 않는다.
8560
+ *
8545
8561
  * @example
8546
8562
  * ```typescript
8547
8563
  * await cb.ai.chatStream({
@@ -8555,72 +8571,109 @@ var AIAPI = class {
8555
8571
  * onError: (error) => console.error('에러:', error)
8556
8572
  * })
8557
8573
  * ```
8574
+ *
8575
+ * @example 취소(stop 버튼)
8576
+ * ```typescript
8577
+ * const controller = new AbortController()
8578
+ * // stop 버튼: controller.abort()
8579
+ * await cb.ai.chatStream(
8580
+ * { messages: [{ role: 'user', content: '...' }], toolGroupId: 'tg-id' },
8581
+ * { onToken: (c) => process.stdout.write(c), onAbort: () => console.log('취소됨') },
8582
+ * { signal: controller.signal },
8583
+ * )
8584
+ * ```
8558
8585
  */
8559
- async chatStream(request, callbacks) {
8560
- const response = await this.http.fetchRaw(
8561
- "/v1/public/ai/chat/stream",
8562
- {
8563
- method: "POST",
8564
- headers: { "Content-Type": "application/json" },
8565
- body: JSON.stringify(request)
8566
- }
8567
- );
8568
- if (!response.ok) {
8569
- const errorData = await response.json().catch(() => ({ error: "Stream request failed" }));
8570
- callbacks.onError?.(errorData.error || "Stream request failed");
8571
- return;
8572
- }
8573
- const reader = response.body?.getReader();
8574
- if (!reader) {
8575
- callbacks.onError?.("ReadableStream not supported");
8576
- return;
8577
- }
8578
- const decoder = new TextDecoder();
8579
- let buffer = "";
8580
- while (true) {
8581
- const { done, value } = await reader.read();
8582
- if (done) break;
8583
- buffer += decoder.decode(value, { stream: true });
8584
- const lines = buffer.split("\n");
8585
- buffer = lines.pop() || "";
8586
- for (const line of lines) {
8587
- if (!line.startsWith("data: ")) continue;
8588
- const data = line.slice(6).trim();
8589
- if (data === "[DONE]") {
8590
- callbacks.onDone?.();
8591
- return;
8586
+ async chatStream(request, callbacks, options) {
8587
+ const signal = options?.signal;
8588
+ const isAbort = (err) => signal?.aborted === true || err instanceof DOMException && err.name === "AbortError" || typeof err === "object" && err !== null && err.name === "AbortError";
8589
+ let reader;
8590
+ try {
8591
+ const response = await this.http.fetchRaw(
8592
+ "/v1/public/ai/chat/stream",
8593
+ {
8594
+ method: "POST",
8595
+ headers: { "Content-Type": "application/json" },
8596
+ body: JSON.stringify(request),
8597
+ // 외부 AbortSignal 그대로 전달. fetchRaw 는 init 을 spread 하므로
8598
+ // 시그니처 변경 없이 signal 이 fetch 까지 도달한다. abort 시 fetch 가
8599
+ // SSE 연결을 닫고, 서버는 요청 컨텍스트 취소로 tool loop 까지 중단한다.
8600
+ signal
8592
8601
  }
8593
- try {
8594
- const event = JSON.parse(data);
8595
- if (event.type === "sources" && event.sources) {
8596
- callbacks.onSources?.(event.sources);
8597
- continue;
8598
- }
8599
- if (event.type === "tool_start" || event.type === "tool_end") {
8600
- callbacks.onToolEvent?.({
8601
- type: event.type,
8602
- name: event.name,
8603
- toolCallId: event.toolCallId,
8604
- arguments: event.arguments,
8605
- result: event.result,
8606
- success: event.success,
8607
- durationMs: event.durationMs
8608
- });
8609
- continue;
8610
- }
8611
- if (event.type === "searching") {
8612
- if (event.searching) callbacks.onSearching?.(event.searching);
8613
- continue;
8614
- }
8615
- if (event.type === "heartbeat") {
8616
- continue;
8617
- }
8618
- if (event.reasoning) callbacks.onReasoning?.(event.reasoning);
8619
- if (event.content) callbacks.onToken?.(event.content);
8620
- if (event.done) {
8602
+ );
8603
+ if (!response.ok) {
8604
+ const errorData = await response.json().catch(() => ({ error: "Stream request failed" }));
8605
+ callbacks.onError?.(errorData.error || "Stream request failed");
8606
+ return;
8607
+ }
8608
+ reader = response.body?.getReader();
8609
+ if (!reader) {
8610
+ callbacks.onError?.("ReadableStream not supported");
8611
+ return;
8612
+ }
8613
+ const decoder = new TextDecoder();
8614
+ let buffer = "";
8615
+ while (true) {
8616
+ const { done, value } = await reader.read();
8617
+ if (done) break;
8618
+ buffer += decoder.decode(value, { stream: true });
8619
+ const lines = buffer.split("\n");
8620
+ buffer = lines.pop() || "";
8621
+ for (const line of lines) {
8622
+ if (!line.startsWith("data: ")) continue;
8623
+ const data = line.slice(6).trim();
8624
+ if (data === "[DONE]") {
8621
8625
  callbacks.onDone?.();
8622
8626
  return;
8623
8627
  }
8628
+ try {
8629
+ const event = JSON.parse(data);
8630
+ if (event.error) {
8631
+ callbacks.onError?.(event.message || event.error || "stream error");
8632
+ return;
8633
+ }
8634
+ if (event.type === "sources" && event.sources) {
8635
+ callbacks.onSources?.(event.sources);
8636
+ continue;
8637
+ }
8638
+ if (event.type === "tool_start" || event.type === "tool_end") {
8639
+ callbacks.onToolEvent?.({
8640
+ type: event.type,
8641
+ name: event.name,
8642
+ toolCallId: event.toolCallId,
8643
+ arguments: event.arguments,
8644
+ result: event.result,
8645
+ success: event.success,
8646
+ durationMs: event.durationMs
8647
+ });
8648
+ continue;
8649
+ }
8650
+ if (event.type === "searching") {
8651
+ if (event.searching) callbacks.onSearching?.(event.searching);
8652
+ continue;
8653
+ }
8654
+ if (event.type === "heartbeat") {
8655
+ continue;
8656
+ }
8657
+ if (event.reasoning) callbacks.onReasoning?.(event.reasoning);
8658
+ if (event.content) callbacks.onToken?.(event.content);
8659
+ if (event.done) {
8660
+ callbacks.onDone?.();
8661
+ return;
8662
+ }
8663
+ } catch {
8664
+ }
8665
+ }
8666
+ }
8667
+ } catch (err) {
8668
+ if (isAbort(err)) {
8669
+ callbacks.onAbort?.();
8670
+ return;
8671
+ }
8672
+ throw err;
8673
+ } finally {
8674
+ if (reader) {
8675
+ try {
8676
+ await reader.cancel();
8624
8677
  } catch {
8625
8678
  }
8626
8679
  }