@witqq/agent-sdk 0.8.0 → 0.9.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/{agent-DxY68NZL.d.cts → agent-C6H2CgJA.d.cts} +2 -0
- package/dist/{agent-CW9XbmG_.d.ts → agent-F7oB6eKp.d.ts} +2 -0
- package/dist/backends/claude.cjs.map +1 -1
- package/dist/backends/claude.d.cts +2 -2
- package/dist/backends/claude.d.ts +2 -2
- package/dist/backends/claude.js.map +1 -1
- package/dist/backends/copilot.cjs +8 -15
- package/dist/backends/copilot.cjs.map +1 -1
- package/dist/backends/copilot.d.cts +2 -2
- package/dist/backends/copilot.d.ts +2 -2
- package/dist/backends/copilot.js +8 -15
- package/dist/backends/copilot.js.map +1 -1
- package/dist/backends/mock-llm.cjs +719 -0
- package/dist/backends/mock-llm.cjs.map +1 -0
- package/dist/backends/mock-llm.d.cts +37 -0
- package/dist/backends/mock-llm.d.ts +37 -0
- package/dist/backends/mock-llm.js +717 -0
- package/dist/backends/mock-llm.js.map +1 -0
- package/dist/backends/vercel-ai.cjs +8 -1
- package/dist/backends/vercel-ai.cjs.map +1 -1
- package/dist/backends/vercel-ai.d.cts +2 -2
- package/dist/backends/vercel-ai.d.ts +2 -2
- package/dist/backends/vercel-ai.js +8 -1
- package/dist/backends/vercel-ai.js.map +1 -1
- package/dist/backends-Cno0gZjy.d.cts +114 -0
- package/dist/backends-Cno0gZjy.d.ts +114 -0
- package/dist/chat/accumulator.cjs.map +1 -1
- package/dist/chat/accumulator.d.cts +2 -2
- package/dist/chat/accumulator.d.ts +2 -2
- package/dist/chat/accumulator.js.map +1 -1
- package/dist/chat/backends.cjs +350 -77
- package/dist/chat/backends.cjs.map +1 -1
- package/dist/chat/backends.d.cts +7 -7
- package/dist/chat/backends.d.ts +7 -7
- package/dist/chat/backends.js +349 -78
- package/dist/chat/backends.js.map +1 -1
- package/dist/chat/context.d.cts +2 -2
- package/dist/chat/context.d.ts +2 -2
- package/dist/chat/core.cjs +35 -25
- package/dist/chat/core.cjs.map +1 -1
- package/dist/chat/core.d.cts +15 -5
- package/dist/chat/core.d.ts +15 -5
- package/dist/chat/core.js +35 -26
- package/dist/chat/core.js.map +1 -1
- package/dist/chat/events.d.cts +2 -2
- package/dist/chat/events.d.ts +2 -2
- package/dist/chat/index.cjs +418 -122
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +7 -7
- package/dist/chat/index.d.ts +7 -7
- package/dist/chat/index.js +418 -124
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.cjs +216 -12
- package/dist/chat/react.cjs.map +1 -1
- package/dist/chat/react.d.cts +78 -4
- package/dist/chat/react.d.ts +78 -4
- package/dist/chat/react.js +215 -13
- package/dist/chat/react.js.map +1 -1
- package/dist/chat/runtime.cjs +6 -2
- package/dist/chat/runtime.cjs.map +1 -1
- package/dist/chat/runtime.d.cts +2 -2
- package/dist/chat/runtime.d.ts +2 -2
- package/dist/chat/runtime.js +6 -2
- package/dist/chat/runtime.js.map +1 -1
- package/dist/chat/server.cjs +15 -5
- package/dist/chat/server.cjs.map +1 -1
- package/dist/chat/server.d.cts +3 -3
- package/dist/chat/server.d.ts +3 -3
- package/dist/chat/server.js +15 -5
- package/dist/chat/server.js.map +1 -1
- package/dist/chat/sessions.cjs +39 -23
- package/dist/chat/sessions.cjs.map +1 -1
- package/dist/chat/sessions.d.cts +2 -2
- package/dist/chat/sessions.d.ts +2 -2
- package/dist/chat/sessions.js +40 -24
- package/dist/chat/sessions.js.map +1 -1
- package/dist/chat/sqlite.cjs +95 -0
- package/dist/chat/sqlite.cjs.map +1 -1
- package/dist/chat/sqlite.d.cts +39 -3
- package/dist/chat/sqlite.d.ts +39 -3
- package/dist/chat/sqlite.js +93 -1
- package/dist/chat/sqlite.js.map +1 -1
- package/dist/chat/state.d.cts +2 -2
- package/dist/chat/state.d.ts +2 -2
- package/dist/chat/storage.cjs +39 -23
- package/dist/chat/storage.cjs.map +1 -1
- package/dist/chat/storage.d.cts +7 -3
- package/dist/chat/storage.d.ts +7 -3
- package/dist/chat/storage.js +40 -24
- package/dist/chat/storage.js.map +1 -1
- package/dist/{in-process-transport-C1JnJGVR.d.ts → in-process-transport-7EIit9Xk.d.ts} +51 -17
- package/dist/{in-process-transport-C7DSqPyX.d.cts → in-process-transport-Ct9YcX8I.d.cts} +51 -17
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +724 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +14 -2
- package/dist/testing.d.ts +14 -2
- package/dist/testing.js +724 -0
- package/dist/testing.js.map +1 -1
- package/dist/{transport-Cdh3M0tS.d.cts → transport-DLWCN18G.d.cts} +1 -1
- package/dist/{transport-Ciap4PWK.d.ts → transport-DsuS-GeM.d.ts} +1 -1
- package/dist/{types-ajANVzf7.d.ts → types-DgtI1hzh.d.ts} +2 -1
- package/dist/{types-DRgd_9R7.d.cts → types-DkSXALKg.d.cts} +2 -1
- package/package.json +18 -7
- package/LICENSE +0 -21
- package/README.md +0 -1054
- package/dist/backends-BSrsBYFn.d.cts +0 -39
- package/dist/backends-BSrsBYFn.d.ts +0 -39
package/dist/chat/react.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
3
|
import { IChatClient, BackendInfo, SelectionChangeCallback } from './runtime.cjs';
|
|
4
|
-
import { c as ChatMessage, R as RuntimeStatus, r as SessionInfo, u as TextPart, q as ReasoningPart, v as ToolCallPart, t as SourcePart, F as FilePart, g as ChatSession, a as ChatEvent, b as ChatId, f as ChatIdLike, S as SendMessageOptions } from '../types-
|
|
4
|
+
import { c as ChatMessage, R as RuntimeStatus, r as SessionInfo, u as TextPart, q as ReasoningPart, v as ToolCallPart, t as SourcePart, F as FilePart, g as ChatSession, a as ChatEvent, b as ChatId, f as ChatIdLike, S as SendMessageOptions } from '../types-DkSXALKg.cjs';
|
|
5
5
|
import { A as AuthToken } from '../types-4vbcmPTp.cjs';
|
|
6
6
|
import { P as ProviderConfig } from '../provider-types-PTSlRPNB.cjs';
|
|
7
7
|
import { ContextStats } from './context.cjs';
|
|
8
|
-
import { M as ModelInfo } from '../agent-
|
|
8
|
+
import { M as ModelInfo } from '../agent-C6H2CgJA.cjs';
|
|
9
9
|
import { CreateSessionOptions, SessionListOptions } from './sessions.cjs';
|
|
10
10
|
import '../errors-C-so0M4t.cjs';
|
|
11
11
|
import 'zod';
|
|
@@ -206,19 +206,67 @@ interface MarkdownRendererProps {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function MarkdownRenderer(props: MarkdownRendererProps): ReactNode;
|
|
208
208
|
|
|
209
|
+
/** Configuration for message list virtualization. */
|
|
210
|
+
interface VirtualizeOptions {
|
|
211
|
+
/** Estimated height of each message item in pixels (default: 80). */
|
|
212
|
+
estimatedItemHeight?: number;
|
|
213
|
+
/** Number of extra items to render above and below the visible area (default: 3). */
|
|
214
|
+
overscan?: number;
|
|
215
|
+
}
|
|
216
|
+
/** Result of the useVirtualMessages hook. */
|
|
217
|
+
interface VirtualMessagesResult<T> {
|
|
218
|
+
/** Slice of items to actually render. */
|
|
219
|
+
visibleItems: T[];
|
|
220
|
+
/** Start index in the original array. */
|
|
221
|
+
startIndex: number;
|
|
222
|
+
/** End index (exclusive) in the original array. */
|
|
223
|
+
endIndex: number;
|
|
224
|
+
/** Height of the spacer above rendered items (px). */
|
|
225
|
+
topSpacerHeight: number;
|
|
226
|
+
/** Height of the spacer below rendered items (px). */
|
|
227
|
+
bottomSpacerHeight: number;
|
|
228
|
+
/** Total estimated height of all items (px). */
|
|
229
|
+
totalHeight: number;
|
|
230
|
+
/** Scroll event handler to attach to the container. */
|
|
231
|
+
onScroll: (event: {
|
|
232
|
+
currentTarget: {
|
|
233
|
+
scrollTop: number;
|
|
234
|
+
clientHeight: number;
|
|
235
|
+
};
|
|
236
|
+
}) => void;
|
|
237
|
+
/** Ref callback to measure container on mount. */
|
|
238
|
+
containerRef: (el: HTMLElement | null) => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Hook providing windowed rendering for a list of items.
|
|
242
|
+
*
|
|
243
|
+
* Only items within the visible viewport (plus overscan) are returned.
|
|
244
|
+
* Consumers render top/bottom spacer divs to preserve scroll position.
|
|
245
|
+
*
|
|
246
|
+
* @param items - Full array of items
|
|
247
|
+
* @param options - Virtualization config
|
|
248
|
+
*/
|
|
249
|
+
declare function useVirtualMessages<T>(items: readonly T[], options?: VirtualizeOptions): VirtualMessagesResult<T>;
|
|
250
|
+
|
|
209
251
|
/** Props for the Thread component. */
|
|
210
252
|
interface ThreadProps {
|
|
211
253
|
messages: ChatMessage[];
|
|
212
254
|
isGenerating?: boolean;
|
|
213
255
|
autoScroll?: boolean;
|
|
214
256
|
className?: string;
|
|
257
|
+
/**
|
|
258
|
+
* Enable windowed rendering for large message lists.
|
|
259
|
+
* Pass `true` for defaults or an options object.
|
|
260
|
+
* When enabled, only visible messages (plus overscan) are mounted.
|
|
261
|
+
*/
|
|
262
|
+
virtualize?: boolean | VirtualizeOptions;
|
|
215
263
|
}
|
|
216
264
|
/**
|
|
217
265
|
* Headless thread component wrapping a scrollable message list.
|
|
218
266
|
* Auto-scrolls to bottom when new messages arrive unless user has scrolled up.
|
|
219
267
|
* Shows a scroll-to-bottom button when scrolled up and an empty state when no messages.
|
|
220
268
|
*/
|
|
221
|
-
declare function Thread({ messages, isGenerating, autoScroll, className, }: ThreadProps): ReactNode;
|
|
269
|
+
declare function Thread({ messages, isGenerating, autoScroll, className, virtualize, }: ThreadProps): ReactNode;
|
|
222
270
|
|
|
223
271
|
/** Props for the Composer component. */
|
|
224
272
|
interface ComposerProps {
|
|
@@ -884,6 +932,32 @@ interface UsageBadgeProps {
|
|
|
884
932
|
/** Compact token usage display. Shows prompt/completion/total tokens. */
|
|
885
933
|
declare function UsageBadge({ usage, className }: UsageBadgeProps): ReactNode;
|
|
886
934
|
|
|
935
|
+
/** Props for PermissionDialog. */
|
|
936
|
+
interface PermissionDialogProps {
|
|
937
|
+
/** List of pending tool requests awaiting approval. */
|
|
938
|
+
requests: PendingToolRequest[];
|
|
939
|
+
/** Called when user approves a tool call. */
|
|
940
|
+
onApprove: (toolCallId: string) => void;
|
|
941
|
+
/** Called when user denies a tool call. */
|
|
942
|
+
onDeny: (toolCallId: string) => void;
|
|
943
|
+
/** Optional: approve all pending at once. */
|
|
944
|
+
onApproveAll?: () => void;
|
|
945
|
+
/** Optional: deny all pending at once. */
|
|
946
|
+
onDenyAll?: () => void;
|
|
947
|
+
/** Custom renderer for tool arguments. */
|
|
948
|
+
renderArgs?: (args: Record<string, unknown>, toolName: string) => ReactNode;
|
|
949
|
+
className?: string;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Headless permission dialog component for tool approval flows.
|
|
953
|
+
*
|
|
954
|
+
* Renders a list of pending tool calls with approve/deny buttons.
|
|
955
|
+
* Uses `data-*` attributes for styling — no built-in styles.
|
|
956
|
+
*
|
|
957
|
+
* Returns `null` when there are no pending requests.
|
|
958
|
+
*/
|
|
959
|
+
declare function PermissionDialog({ requests, onApprove, onDeny, onApproveAll, onDenyAll, renderArgs, className, }: PermissionDialogProps): ReactNode;
|
|
960
|
+
|
|
887
961
|
/**
|
|
888
962
|
* Client-side adapter that implements IChatClient by delegating
|
|
889
963
|
* operations over HTTP/SSE to a remote server.
|
|
@@ -1085,4 +1159,4 @@ interface UseApiKeyAuthReturn {
|
|
|
1085
1159
|
*/
|
|
1086
1160
|
declare function useApiKeyAuth(options: UseApiKeyAuthOptions): UseApiKeyAuthReturn;
|
|
1087
1161
|
|
|
1088
|
-
export { type AuthFormComponent, type AuthFormProps, BackendSelector, type BackendSelectorProps, ChatHeader, type ChatHeaderProps, ChatInputArea, type ChatInputAreaProps, ChatLayout, type ChatLayoutProps, ChatProvider, ChatSettingsOverlay, type ChatSettingsOverlayProps, ChatUI, type ChatUIProps, type ChatUISlots, type ChatUsage, ClaudeAuthForm, Composer, type ComposerProps, ContextStatsDisplay, type ContextStatsDisplayProps, CopilotAuthForm, MarkdownRenderer, type MarkdownRendererProps, Message, type MessageProps, type ModelOption, ModelSelector, type ModelSelectorProps, type PendingToolRequest, type ProviderModelItem, ProviderModelSelector, type ProviderModelSelectorProps, ProviderSelector, type ProviderSelectorProps, ProviderSettings, type ProviderSettingsProps, type RemoteAuthBackend, type RemoteAuthStatus, RemoteChatClient, type RemoteChatClientOptions, type RemoteChatPhase, type SSEStatus, ThinkingBlock, type ThinkingBlockProps, Thread, ThreadList, type ThreadListProps, type ThreadProps, ThreadProvider, type ThreadProviderProps, type ThreadSlotOverrides, ToolCallView, type ToolCallViewProps, UsageBadge, type UsageBadgeProps, type UseApiKeyAuthOptions, type UseApiKeyAuthReturn, type UseBackendsReturn, type UseChatOptions, type UseChatReturn, type UseClaudeAuthOptions, type UseClaudeAuthReturn, type UseCopilotAuthOptions, type UseCopilotAuthReturn, type UseMessagesOptions, type UseMessagesReturn, type UseModelsReturn, type UseProvidersReturn, type UseRemoteAuthOptions, type UseRemoteAuthReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSSEOptions, type UseSSEReturn, type UseSessionsReturn, type UseToolApprovalReturn, VercelAIAuthForm, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval };
|
|
1162
|
+
export { type AuthFormComponent, type AuthFormProps, BackendSelector, type BackendSelectorProps, ChatHeader, type ChatHeaderProps, ChatInputArea, type ChatInputAreaProps, ChatLayout, type ChatLayoutProps, ChatProvider, ChatSettingsOverlay, type ChatSettingsOverlayProps, ChatUI, type ChatUIProps, type ChatUISlots, type ChatUsage, ClaudeAuthForm, Composer, type ComposerProps, ContextStatsDisplay, type ContextStatsDisplayProps, CopilotAuthForm, MarkdownRenderer, type MarkdownRendererProps, Message, type MessageProps, type ModelOption, ModelSelector, type ModelSelectorProps, type PendingToolRequest, PermissionDialog, type PermissionDialogProps, type ProviderModelItem, ProviderModelSelector, type ProviderModelSelectorProps, ProviderSelector, type ProviderSelectorProps, ProviderSettings, type ProviderSettingsProps, type RemoteAuthBackend, type RemoteAuthStatus, RemoteChatClient, type RemoteChatClientOptions, type RemoteChatPhase, type SSEStatus, ThinkingBlock, type ThinkingBlockProps, Thread, ThreadList, type ThreadListProps, type ThreadProps, ThreadProvider, type ThreadProviderProps, type ThreadSlotOverrides, ToolCallView, type ToolCallViewProps, UsageBadge, type UsageBadgeProps, type UseApiKeyAuthOptions, type UseApiKeyAuthReturn, type UseBackendsReturn, type UseChatOptions, type UseChatReturn, type UseClaudeAuthOptions, type UseClaudeAuthReturn, type UseCopilotAuthOptions, type UseCopilotAuthReturn, type UseMessagesOptions, type UseMessagesReturn, type UseModelsReturn, type UseProvidersReturn, type UseRemoteAuthOptions, type UseRemoteAuthReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSSEOptions, type UseSSEReturn, type UseSessionsReturn, type UseToolApprovalReturn, VercelAIAuthForm, type VirtualMessagesResult, type VirtualizeOptions, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval, useVirtualMessages };
|
package/dist/chat/react.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ComponentType } from 'react';
|
|
3
3
|
import { IChatClient, BackendInfo, SelectionChangeCallback } from './runtime.js';
|
|
4
|
-
import { c as ChatMessage, R as RuntimeStatus, r as SessionInfo, u as TextPart, q as ReasoningPart, v as ToolCallPart, t as SourcePart, F as FilePart, g as ChatSession, a as ChatEvent, b as ChatId, f as ChatIdLike, S as SendMessageOptions } from '../types-
|
|
4
|
+
import { c as ChatMessage, R as RuntimeStatus, r as SessionInfo, u as TextPart, q as ReasoningPart, v as ToolCallPart, t as SourcePart, F as FilePart, g as ChatSession, a as ChatEvent, b as ChatId, f as ChatIdLike, S as SendMessageOptions } from '../types-DgtI1hzh.js';
|
|
5
5
|
import { A as AuthToken } from '../types-BxggH0Yh.js';
|
|
6
6
|
import { P as ProviderConfig } from '../provider-types-PTSlRPNB.js';
|
|
7
7
|
import { ContextStats } from './context.js';
|
|
8
|
-
import { M as ModelInfo } from '../agent-
|
|
8
|
+
import { M as ModelInfo } from '../agent-F7oB6eKp.js';
|
|
9
9
|
import { CreateSessionOptions, SessionListOptions } from './sessions.js';
|
|
10
10
|
import '../errors-C-so0M4t.js';
|
|
11
11
|
import 'zod';
|
|
@@ -206,19 +206,67 @@ interface MarkdownRendererProps {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function MarkdownRenderer(props: MarkdownRendererProps): ReactNode;
|
|
208
208
|
|
|
209
|
+
/** Configuration for message list virtualization. */
|
|
210
|
+
interface VirtualizeOptions {
|
|
211
|
+
/** Estimated height of each message item in pixels (default: 80). */
|
|
212
|
+
estimatedItemHeight?: number;
|
|
213
|
+
/** Number of extra items to render above and below the visible area (default: 3). */
|
|
214
|
+
overscan?: number;
|
|
215
|
+
}
|
|
216
|
+
/** Result of the useVirtualMessages hook. */
|
|
217
|
+
interface VirtualMessagesResult<T> {
|
|
218
|
+
/** Slice of items to actually render. */
|
|
219
|
+
visibleItems: T[];
|
|
220
|
+
/** Start index in the original array. */
|
|
221
|
+
startIndex: number;
|
|
222
|
+
/** End index (exclusive) in the original array. */
|
|
223
|
+
endIndex: number;
|
|
224
|
+
/** Height of the spacer above rendered items (px). */
|
|
225
|
+
topSpacerHeight: number;
|
|
226
|
+
/** Height of the spacer below rendered items (px). */
|
|
227
|
+
bottomSpacerHeight: number;
|
|
228
|
+
/** Total estimated height of all items (px). */
|
|
229
|
+
totalHeight: number;
|
|
230
|
+
/** Scroll event handler to attach to the container. */
|
|
231
|
+
onScroll: (event: {
|
|
232
|
+
currentTarget: {
|
|
233
|
+
scrollTop: number;
|
|
234
|
+
clientHeight: number;
|
|
235
|
+
};
|
|
236
|
+
}) => void;
|
|
237
|
+
/** Ref callback to measure container on mount. */
|
|
238
|
+
containerRef: (el: HTMLElement | null) => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Hook providing windowed rendering for a list of items.
|
|
242
|
+
*
|
|
243
|
+
* Only items within the visible viewport (plus overscan) are returned.
|
|
244
|
+
* Consumers render top/bottom spacer divs to preserve scroll position.
|
|
245
|
+
*
|
|
246
|
+
* @param items - Full array of items
|
|
247
|
+
* @param options - Virtualization config
|
|
248
|
+
*/
|
|
249
|
+
declare function useVirtualMessages<T>(items: readonly T[], options?: VirtualizeOptions): VirtualMessagesResult<T>;
|
|
250
|
+
|
|
209
251
|
/** Props for the Thread component. */
|
|
210
252
|
interface ThreadProps {
|
|
211
253
|
messages: ChatMessage[];
|
|
212
254
|
isGenerating?: boolean;
|
|
213
255
|
autoScroll?: boolean;
|
|
214
256
|
className?: string;
|
|
257
|
+
/**
|
|
258
|
+
* Enable windowed rendering for large message lists.
|
|
259
|
+
* Pass `true` for defaults or an options object.
|
|
260
|
+
* When enabled, only visible messages (plus overscan) are mounted.
|
|
261
|
+
*/
|
|
262
|
+
virtualize?: boolean | VirtualizeOptions;
|
|
215
263
|
}
|
|
216
264
|
/**
|
|
217
265
|
* Headless thread component wrapping a scrollable message list.
|
|
218
266
|
* Auto-scrolls to bottom when new messages arrive unless user has scrolled up.
|
|
219
267
|
* Shows a scroll-to-bottom button when scrolled up and an empty state when no messages.
|
|
220
268
|
*/
|
|
221
|
-
declare function Thread({ messages, isGenerating, autoScroll, className, }: ThreadProps): ReactNode;
|
|
269
|
+
declare function Thread({ messages, isGenerating, autoScroll, className, virtualize, }: ThreadProps): ReactNode;
|
|
222
270
|
|
|
223
271
|
/** Props for the Composer component. */
|
|
224
272
|
interface ComposerProps {
|
|
@@ -884,6 +932,32 @@ interface UsageBadgeProps {
|
|
|
884
932
|
/** Compact token usage display. Shows prompt/completion/total tokens. */
|
|
885
933
|
declare function UsageBadge({ usage, className }: UsageBadgeProps): ReactNode;
|
|
886
934
|
|
|
935
|
+
/** Props for PermissionDialog. */
|
|
936
|
+
interface PermissionDialogProps {
|
|
937
|
+
/** List of pending tool requests awaiting approval. */
|
|
938
|
+
requests: PendingToolRequest[];
|
|
939
|
+
/** Called when user approves a tool call. */
|
|
940
|
+
onApprove: (toolCallId: string) => void;
|
|
941
|
+
/** Called when user denies a tool call. */
|
|
942
|
+
onDeny: (toolCallId: string) => void;
|
|
943
|
+
/** Optional: approve all pending at once. */
|
|
944
|
+
onApproveAll?: () => void;
|
|
945
|
+
/** Optional: deny all pending at once. */
|
|
946
|
+
onDenyAll?: () => void;
|
|
947
|
+
/** Custom renderer for tool arguments. */
|
|
948
|
+
renderArgs?: (args: Record<string, unknown>, toolName: string) => ReactNode;
|
|
949
|
+
className?: string;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Headless permission dialog component for tool approval flows.
|
|
953
|
+
*
|
|
954
|
+
* Renders a list of pending tool calls with approve/deny buttons.
|
|
955
|
+
* Uses `data-*` attributes for styling — no built-in styles.
|
|
956
|
+
*
|
|
957
|
+
* Returns `null` when there are no pending requests.
|
|
958
|
+
*/
|
|
959
|
+
declare function PermissionDialog({ requests, onApprove, onDeny, onApproveAll, onDenyAll, renderArgs, className, }: PermissionDialogProps): ReactNode;
|
|
960
|
+
|
|
887
961
|
/**
|
|
888
962
|
* Client-side adapter that implements IChatClient by delegating
|
|
889
963
|
* operations over HTTP/SSE to a remote server.
|
|
@@ -1085,4 +1159,4 @@ interface UseApiKeyAuthReturn {
|
|
|
1085
1159
|
*/
|
|
1086
1160
|
declare function useApiKeyAuth(options: UseApiKeyAuthOptions): UseApiKeyAuthReturn;
|
|
1087
1161
|
|
|
1088
|
-
export { type AuthFormComponent, type AuthFormProps, BackendSelector, type BackendSelectorProps, ChatHeader, type ChatHeaderProps, ChatInputArea, type ChatInputAreaProps, ChatLayout, type ChatLayoutProps, ChatProvider, ChatSettingsOverlay, type ChatSettingsOverlayProps, ChatUI, type ChatUIProps, type ChatUISlots, type ChatUsage, ClaudeAuthForm, Composer, type ComposerProps, ContextStatsDisplay, type ContextStatsDisplayProps, CopilotAuthForm, MarkdownRenderer, type MarkdownRendererProps, Message, type MessageProps, type ModelOption, ModelSelector, type ModelSelectorProps, type PendingToolRequest, type ProviderModelItem, ProviderModelSelector, type ProviderModelSelectorProps, ProviderSelector, type ProviderSelectorProps, ProviderSettings, type ProviderSettingsProps, type RemoteAuthBackend, type RemoteAuthStatus, RemoteChatClient, type RemoteChatClientOptions, type RemoteChatPhase, type SSEStatus, ThinkingBlock, type ThinkingBlockProps, Thread, ThreadList, type ThreadListProps, type ThreadProps, ThreadProvider, type ThreadProviderProps, type ThreadSlotOverrides, ToolCallView, type ToolCallViewProps, UsageBadge, type UsageBadgeProps, type UseApiKeyAuthOptions, type UseApiKeyAuthReturn, type UseBackendsReturn, type UseChatOptions, type UseChatReturn, type UseClaudeAuthOptions, type UseClaudeAuthReturn, type UseCopilotAuthOptions, type UseCopilotAuthReturn, type UseMessagesOptions, type UseMessagesReturn, type UseModelsReturn, type UseProvidersReturn, type UseRemoteAuthOptions, type UseRemoteAuthReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSSEOptions, type UseSSEReturn, type UseSessionsReturn, type UseToolApprovalReturn, VercelAIAuthForm, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval };
|
|
1162
|
+
export { type AuthFormComponent, type AuthFormProps, BackendSelector, type BackendSelectorProps, ChatHeader, type ChatHeaderProps, ChatInputArea, type ChatInputAreaProps, ChatLayout, type ChatLayoutProps, ChatProvider, ChatSettingsOverlay, type ChatSettingsOverlayProps, ChatUI, type ChatUIProps, type ChatUISlots, type ChatUsage, ClaudeAuthForm, Composer, type ComposerProps, ContextStatsDisplay, type ContextStatsDisplayProps, CopilotAuthForm, MarkdownRenderer, type MarkdownRendererProps, Message, type MessageProps, type ModelOption, ModelSelector, type ModelSelectorProps, type PendingToolRequest, PermissionDialog, type PermissionDialogProps, type ProviderModelItem, ProviderModelSelector, type ProviderModelSelectorProps, ProviderSelector, type ProviderSelectorProps, ProviderSettings, type ProviderSettingsProps, type RemoteAuthBackend, type RemoteAuthStatus, RemoteChatClient, type RemoteChatClientOptions, type RemoteChatPhase, type SSEStatus, ThinkingBlock, type ThinkingBlockProps, Thread, ThreadList, type ThreadListProps, type ThreadProps, ThreadProvider, type ThreadProviderProps, type ThreadSlotOverrides, ToolCallView, type ToolCallViewProps, UsageBadge, type UsageBadgeProps, type UseApiKeyAuthOptions, type UseApiKeyAuthReturn, type UseBackendsReturn, type UseChatOptions, type UseChatReturn, type UseClaudeAuthOptions, type UseClaudeAuthReturn, type UseCopilotAuthOptions, type UseCopilotAuthReturn, type UseMessagesOptions, type UseMessagesReturn, type UseModelsReturn, type UseProvidersReturn, type UseRemoteAuthOptions, type UseRemoteAuthReturn, type UseRemoteChatOptions, type UseRemoteChatReturn, type UseSSEOptions, type UseSSEReturn, type UseSessionsReturn, type UseToolApprovalReturn, VercelAIAuthForm, type VirtualMessagesResult, type VirtualizeOptions, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval, useVirtualMessages };
|
package/dist/chat/react.js
CHANGED
|
@@ -281,6 +281,9 @@ function useChat(options = {}) {
|
|
|
281
281
|
}
|
|
282
282
|
const agentEvent = chatEventToAgentEvent(event);
|
|
283
283
|
if (agentEvent) {
|
|
284
|
+
if (agentEvent.type === "error" && !agentEvent.recoverable) {
|
|
285
|
+
throw new Error(agentEvent.error || "Stream error");
|
|
286
|
+
}
|
|
284
287
|
accumulator.apply(agentEvent);
|
|
285
288
|
hasEvents = true;
|
|
286
289
|
const snapshot = accumulator.snapshot();
|
|
@@ -799,25 +802,98 @@ function useThreadSlots() {
|
|
|
799
802
|
function useOptionalThreadSlots() {
|
|
800
803
|
return useContext(ThreadSlotsContext);
|
|
801
804
|
}
|
|
805
|
+
function useVirtualMessages(items, options = {}) {
|
|
806
|
+
const { estimatedItemHeight = 80, overscan = 3 } = options;
|
|
807
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
808
|
+
const [containerHeight, setContainerHeight] = useState(0);
|
|
809
|
+
const containerElRef = useRef(null);
|
|
810
|
+
const containerRef = useCallback((el) => {
|
|
811
|
+
containerElRef.current = el;
|
|
812
|
+
if (el) {
|
|
813
|
+
setContainerHeight(el.clientHeight);
|
|
814
|
+
}
|
|
815
|
+
}, []);
|
|
816
|
+
useEffect(() => {
|
|
817
|
+
const el = containerElRef.current;
|
|
818
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
819
|
+
const ro = new ResizeObserver(() => {
|
|
820
|
+
setContainerHeight(el.clientHeight);
|
|
821
|
+
});
|
|
822
|
+
ro.observe(el);
|
|
823
|
+
return () => ro.disconnect();
|
|
824
|
+
}, []);
|
|
825
|
+
const onScroll = useCallback(
|
|
826
|
+
(event) => {
|
|
827
|
+
setScrollTop(event.currentTarget.scrollTop);
|
|
828
|
+
setContainerHeight(event.currentTarget.clientHeight);
|
|
829
|
+
},
|
|
830
|
+
[]
|
|
831
|
+
);
|
|
832
|
+
const result = useMemo(() => {
|
|
833
|
+
const totalCount = items.length;
|
|
834
|
+
const totalHeight = totalCount * estimatedItemHeight;
|
|
835
|
+
if (totalCount === 0 || containerHeight === 0) {
|
|
836
|
+
return {
|
|
837
|
+
visibleItems: items.slice(),
|
|
838
|
+
startIndex: 0,
|
|
839
|
+
endIndex: totalCount,
|
|
840
|
+
topSpacerHeight: 0,
|
|
841
|
+
bottomSpacerHeight: 0,
|
|
842
|
+
totalHeight
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
const rawStart = Math.floor(scrollTop / estimatedItemHeight) - overscan;
|
|
846
|
+
const startIndex = Math.max(0, rawStart);
|
|
847
|
+
const visibleCount = Math.ceil(containerHeight / estimatedItemHeight);
|
|
848
|
+
const rawEnd = Math.floor(scrollTop / estimatedItemHeight) + visibleCount + overscan;
|
|
849
|
+
const endIndex = Math.min(totalCount, rawEnd);
|
|
850
|
+
return {
|
|
851
|
+
visibleItems: items.slice(startIndex, endIndex),
|
|
852
|
+
startIndex,
|
|
853
|
+
endIndex,
|
|
854
|
+
topSpacerHeight: startIndex * estimatedItemHeight,
|
|
855
|
+
bottomSpacerHeight: (totalCount - endIndex) * estimatedItemHeight,
|
|
856
|
+
totalHeight
|
|
857
|
+
};
|
|
858
|
+
}, [items, scrollTop, containerHeight, estimatedItemHeight, overscan]);
|
|
859
|
+
return {
|
|
860
|
+
...result,
|
|
861
|
+
onScroll,
|
|
862
|
+
containerRef
|
|
863
|
+
};
|
|
864
|
+
}
|
|
802
865
|
|
|
803
866
|
// src/chat/react/Thread.ts
|
|
804
867
|
function Thread({
|
|
805
868
|
messages,
|
|
806
869
|
isGenerating,
|
|
807
870
|
autoScroll = true,
|
|
808
|
-
className
|
|
871
|
+
className,
|
|
872
|
+
virtualize
|
|
809
873
|
}) {
|
|
810
874
|
const sentinelRef = useRef(null);
|
|
811
875
|
const containerRef = useRef(null);
|
|
812
876
|
const [userScrolledUp, setUserScrolledUp] = useState(false);
|
|
813
877
|
const isScrollingProgrammatically = useRef(false);
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
878
|
+
const isVirtualized = virtualize != null && virtualize !== false;
|
|
879
|
+
const virtualizeOpts = virtualize === true ? {} : !isVirtualized ? false : virtualize;
|
|
880
|
+
const virtual = useVirtualMessages(
|
|
881
|
+
messages,
|
|
882
|
+
virtualizeOpts || void 0
|
|
883
|
+
);
|
|
884
|
+
const handleScroll = useCallback(
|
|
885
|
+
(e) => {
|
|
886
|
+
if (isVirtualized) {
|
|
887
|
+
virtual.onScroll(e);
|
|
888
|
+
}
|
|
889
|
+
if (isScrollingProgrammatically.current) return;
|
|
890
|
+
const el = containerRef.current;
|
|
891
|
+
if (!el) return;
|
|
892
|
+
const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 1;
|
|
893
|
+
setUserScrolledUp(!atBottom);
|
|
894
|
+
},
|
|
895
|
+
[isVirtualized, virtual.onScroll]
|
|
896
|
+
);
|
|
821
897
|
const scrollToBottom = useCallback(() => {
|
|
822
898
|
isScrollingProgrammatically.current = true;
|
|
823
899
|
sentinelRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
@@ -831,11 +907,23 @@ function Thread({
|
|
|
831
907
|
sentinelRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
832
908
|
}, [messages, autoScroll, userScrolledUp]);
|
|
833
909
|
const slots = useOptionalThreadSlots();
|
|
910
|
+
const mergedRef = useCallback(
|
|
911
|
+
(el) => {
|
|
912
|
+
containerRef.current = el;
|
|
913
|
+
if (isVirtualized) {
|
|
914
|
+
virtual.containerRef(el);
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
[isVirtualized, virtual.containerRef]
|
|
918
|
+
);
|
|
834
919
|
const attrs = { "data-thread": "true", className };
|
|
835
920
|
if (isGenerating) {
|
|
836
921
|
attrs["data-thread-loading"] = "true";
|
|
837
922
|
}
|
|
838
|
-
|
|
923
|
+
if (virtualizeOpts) {
|
|
924
|
+
attrs["data-thread-virtualized"] = "true";
|
|
925
|
+
}
|
|
926
|
+
attrs.ref = mergedRef;
|
|
839
927
|
attrs.onScroll = handleScroll;
|
|
840
928
|
const children = [];
|
|
841
929
|
if (messages.length === 0 && !isGenerating) {
|
|
@@ -847,9 +935,21 @@ function Thread({
|
|
|
847
935
|
)
|
|
848
936
|
);
|
|
849
937
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
938
|
+
const renderMessages = virtualizeOpts ? virtual.visibleItems : messages;
|
|
939
|
+
const startOffset = virtualizeOpts ? virtual.startIndex : 0;
|
|
940
|
+
if (virtualizeOpts && virtual.topSpacerHeight > 0) {
|
|
941
|
+
children.push(
|
|
942
|
+
createElement("div", {
|
|
943
|
+
key: "__virtual-top",
|
|
944
|
+
"data-virtual-spacer": "top",
|
|
945
|
+
style: { height: virtual.topSpacerHeight }
|
|
946
|
+
})
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
for (let i = 0; i < renderMessages.length; i++) {
|
|
950
|
+
const msg = renderMessages[i];
|
|
951
|
+
const originalIndex = startOffset + i;
|
|
952
|
+
const content = slots?.renderMessage ? slots.renderMessage(msg, originalIndex) : createElement(Message, {
|
|
853
953
|
key: msg.id,
|
|
854
954
|
message: msg,
|
|
855
955
|
renderToolCall: slots?.renderToolCall,
|
|
@@ -863,6 +963,15 @@ function Thread({
|
|
|
863
963
|
)
|
|
864
964
|
);
|
|
865
965
|
}
|
|
966
|
+
if (virtualizeOpts && virtual.bottomSpacerHeight > 0) {
|
|
967
|
+
children.push(
|
|
968
|
+
createElement("div", {
|
|
969
|
+
key: "__virtual-bottom",
|
|
970
|
+
"data-virtual-spacer": "bottom",
|
|
971
|
+
style: { height: virtual.bottomSpacerHeight }
|
|
972
|
+
})
|
|
973
|
+
);
|
|
974
|
+
}
|
|
866
975
|
if (isGenerating) {
|
|
867
976
|
children.push(
|
|
868
977
|
createElement(
|
|
@@ -3541,7 +3650,100 @@ function ChatUI({ runtime, ...rest }) {
|
|
|
3541
3650
|
children: createElement(ChatUIInner, rest)
|
|
3542
3651
|
});
|
|
3543
3652
|
}
|
|
3653
|
+
function PermissionDialog({
|
|
3654
|
+
requests,
|
|
3655
|
+
onApprove,
|
|
3656
|
+
onDeny,
|
|
3657
|
+
onApproveAll,
|
|
3658
|
+
onDenyAll,
|
|
3659
|
+
renderArgs,
|
|
3660
|
+
className
|
|
3661
|
+
}) {
|
|
3662
|
+
if (requests.length === 0) return null;
|
|
3663
|
+
const items = requests.map(
|
|
3664
|
+
(req) => createElement(
|
|
3665
|
+
"div",
|
|
3666
|
+
{
|
|
3667
|
+
key: req.toolCallId,
|
|
3668
|
+
"data-permission-request": "true",
|
|
3669
|
+
"data-tool-name": req.toolName
|
|
3670
|
+
},
|
|
3671
|
+
// Tool name
|
|
3672
|
+
createElement(
|
|
3673
|
+
"div",
|
|
3674
|
+
{ "data-permission-tool-name": "true" },
|
|
3675
|
+
req.toolName
|
|
3676
|
+
),
|
|
3677
|
+
// Arguments display
|
|
3678
|
+
createElement(
|
|
3679
|
+
"div",
|
|
3680
|
+
{ "data-permission-tool-args": "true" },
|
|
3681
|
+
renderArgs ? renderArgs(req.toolArgs, req.toolName) : createElement("pre", null, JSON.stringify(req.toolArgs, null, 2))
|
|
3682
|
+
),
|
|
3683
|
+
// Action buttons
|
|
3684
|
+
createElement(
|
|
3685
|
+
"div",
|
|
3686
|
+
{ "data-permission-actions": "true" },
|
|
3687
|
+
createElement(
|
|
3688
|
+
"button",
|
|
3689
|
+
{
|
|
3690
|
+
type: "button",
|
|
3691
|
+
"data-action": "approve",
|
|
3692
|
+
onClick: () => onApprove(req.toolCallId),
|
|
3693
|
+
"aria-label": `Approve ${req.toolName}`
|
|
3694
|
+
},
|
|
3695
|
+
"Allow"
|
|
3696
|
+
),
|
|
3697
|
+
createElement(
|
|
3698
|
+
"button",
|
|
3699
|
+
{
|
|
3700
|
+
type: "button",
|
|
3701
|
+
"data-action": "deny",
|
|
3702
|
+
onClick: () => onDeny(req.toolCallId),
|
|
3703
|
+
"aria-label": `Deny ${req.toolName}`
|
|
3704
|
+
},
|
|
3705
|
+
"Deny"
|
|
3706
|
+
)
|
|
3707
|
+
)
|
|
3708
|
+
)
|
|
3709
|
+
);
|
|
3710
|
+
const bulkActions = requests.length > 1 && (onApproveAll || onDenyAll) ? createElement(
|
|
3711
|
+
"div",
|
|
3712
|
+
{ "data-permission-bulk-actions": "true" },
|
|
3713
|
+
onApproveAll ? createElement(
|
|
3714
|
+
"button",
|
|
3715
|
+
{
|
|
3716
|
+
type: "button",
|
|
3717
|
+
"data-action": "approve-all",
|
|
3718
|
+
onClick: onApproveAll,
|
|
3719
|
+
"aria-label": "Approve all tool calls"
|
|
3720
|
+
},
|
|
3721
|
+
"Allow All"
|
|
3722
|
+
) : null,
|
|
3723
|
+
onDenyAll ? createElement(
|
|
3724
|
+
"button",
|
|
3725
|
+
{
|
|
3726
|
+
type: "button",
|
|
3727
|
+
"data-action": "deny-all",
|
|
3728
|
+
onClick: onDenyAll,
|
|
3729
|
+
"aria-label": "Deny all tool calls"
|
|
3730
|
+
},
|
|
3731
|
+
"Deny All"
|
|
3732
|
+
) : null
|
|
3733
|
+
) : null;
|
|
3734
|
+
return createElement(
|
|
3735
|
+
"div",
|
|
3736
|
+
{
|
|
3737
|
+
"data-permission-dialog": "true",
|
|
3738
|
+
role: "dialog",
|
|
3739
|
+
"aria-label": "Tool permission requests",
|
|
3740
|
+
className
|
|
3741
|
+
},
|
|
3742
|
+
...items,
|
|
3743
|
+
bulkActions
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3544
3746
|
|
|
3545
|
-
export { BackendSelector, ChatHeader, ChatInputArea, ChatLayout, ChatProvider, ChatSettingsOverlay, ChatUI, ClaudeAuthForm, Composer, ContextStatsDisplay, CopilotAuthForm, MarkdownRenderer, Message, ModelSelector, ProviderModelSelector, ProviderSelector, ProviderSettings, RemoteChatClient, ThinkingBlock, Thread, ThreadList, ThreadProvider, ToolCallView, UsageBadge, VercelAIAuthForm, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval };
|
|
3747
|
+
export { BackendSelector, ChatHeader, ChatInputArea, ChatLayout, ChatProvider, ChatSettingsOverlay, ChatUI, ClaudeAuthForm, Composer, ContextStatsDisplay, CopilotAuthForm, MarkdownRenderer, Message, ModelSelector, PermissionDialog, ProviderModelSelector, ProviderSelector, ProviderSettings, RemoteChatClient, ThinkingBlock, Thread, ThreadList, ThreadProvider, ToolCallView, UsageBadge, VercelAIAuthForm, useApiKeyAuth, useBackends, useChat, useChatRuntime, useClaudeAuth, useCopilotAuth, useMessages, useModels, useOptionalThreadSlots, useProviders, useRemoteAuth, useRemoteChat, useSSE, useSessions, useThreadSlots, useToolApproval, useVirtualMessages };
|
|
3546
3748
|
//# sourceMappingURL=react.js.map
|
|
3547
3749
|
//# sourceMappingURL=react.js.map
|