@anvia/react-ui 1.3.0 → 1.3.1

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.
Files changed (131) hide show
  1. package/dist/attachment/index.d.ts +3 -21
  2. package/dist/attachment/index.js +3 -12
  3. package/dist/attachment-DsKTPumt.js +89 -0
  4. package/dist/attachment-DsKTPumt.js.map +1 -0
  5. package/dist/chat/index.d.ts +3 -152
  6. package/dist/chat/index.js +3 -25
  7. package/dist/chat-CAnvUEAv.js +1210 -0
  8. package/dist/chat-CAnvUEAv.js.map +1 -0
  9. package/dist/completion/index.d.ts +3 -29
  10. package/dist/completion/index.js +3 -16
  11. package/dist/completion-DDTKoZRJ.js +124 -0
  12. package/dist/completion-DDTKoZRJ.js.map +1 -0
  13. package/dist/connection-DeNq8wHS.js +203 -0
  14. package/dist/connection-DeNq8wHS.js.map +1 -0
  15. package/dist/contexts-B4ijG24z.js +212 -0
  16. package/dist/contexts-B4ijG24z.js.map +1 -0
  17. package/dist/elements-D4vmkkF8.js +19 -0
  18. package/dist/elements-D4vmkkF8.js.map +1 -0
  19. package/dist/graph-explorer/index.d.ts +54 -73
  20. package/dist/graph-explorer/index.d.ts.map +1 -0
  21. package/dist/graph-explorer/index.js +181 -248
  22. package/dist/graph-explorer/index.js.map +1 -1
  23. package/dist/human-input/index.d.ts +3 -78
  24. package/dist/human-input/index.js +3 -21
  25. package/dist/human-input-CsCbZomZ.js +314 -0
  26. package/dist/human-input-CsCbZomZ.js.map +1 -0
  27. package/dist/image/index.d.ts +3 -40
  28. package/dist/image/index.js +3 -12
  29. package/dist/image-D_7vaQCR.js +302 -0
  30. package/dist/image-D_7vaQCR.js.map +1 -0
  31. package/dist/index-B1Qs2Cjv.d.ts +145 -0
  32. package/dist/index-B1Qs2Cjv.d.ts.map +1 -0
  33. package/dist/index-BCBVcl0D.d.ts +277 -0
  34. package/dist/index-BCBVcl0D.d.ts.map +1 -0
  35. package/dist/index-CE22tsua.d.ts +20 -0
  36. package/dist/index-CE22tsua.d.ts.map +1 -0
  37. package/dist/index-CGqtpc6b.d.ts +25 -0
  38. package/dist/index-CGqtpc6b.d.ts.map +1 -0
  39. package/dist/index-DqdyM0Jm.d.ts +7 -0
  40. package/dist/index-DqdyM0Jm.d.ts.map +1 -0
  41. package/dist/index-Mw3ltwSG.d.ts +318 -0
  42. package/dist/index-Mw3ltwSG.d.ts.map +1 -0
  43. package/dist/index.d.ts +7 -40
  44. package/dist/index.js +34 -118
  45. package/dist/index.js.map +1 -1
  46. package/dist/message/index.d.ts +3 -105
  47. package/dist/message/index.js +3 -20
  48. package/dist/message-Dn3wW6yy.js +783 -0
  49. package/dist/message-Dn3wW6yy.js.map +1 -0
  50. package/dist/primitives-xfE7zfwJ.js +15 -0
  51. package/dist/primitives-xfE7zfwJ.js.map +1 -0
  52. package/dist/refs-Djj9rSvB.js +10 -0
  53. package/dist/refs-Djj9rSvB.js.map +1 -0
  54. package/dist/sandbox-desktop/index.d.ts +100 -104
  55. package/dist/sandbox-desktop/index.d.ts.map +1 -0
  56. package/dist/sandbox-desktop/index.js +344 -342
  57. package/dist/sandbox-desktop/index.js.map +1 -1
  58. package/dist/sandbox-terminal/index.d.ts +52 -56
  59. package/dist/sandbox-terminal/index.d.ts.map +1 -0
  60. package/dist/sandbox-terminal/index.js +217 -208
  61. package/dist/sandbox-terminal/index.js.map +1 -1
  62. package/dist/selection-toolbar/index.d.ts +3 -21
  63. package/dist/selection-toolbar/index.js +3 -13
  64. package/dist/selection-toolbar-CIkOoM-7.js +171 -0
  65. package/dist/selection-toolbar-CIkOoM-7.js.map +1 -0
  66. package/dist/shared-BSYElFU2.d.ts +2 -0
  67. package/dist/shared.d.ts +4 -14
  68. package/dist/shared.js +1 -43
  69. package/dist/stream/index.d.ts +2 -22
  70. package/dist/stream/index.js +1 -8
  71. package/dist/stream-CAO0x8_1.js +298 -0
  72. package/dist/stream-CAO0x8_1.js.map +1 -0
  73. package/dist/thread-list/index.d.ts +3 -47
  74. package/dist/thread-list/index.js +3 -18
  75. package/dist/thread-list-xJbGXFrE.js +228 -0
  76. package/dist/thread-list-xJbGXFrE.js.map +1 -0
  77. package/dist/ticket-CoJHBpdF.d.ts +32 -0
  78. package/dist/ticket-CoJHBpdF.d.ts.map +1 -0
  79. package/dist/value-BGGrx72L.js +13 -0
  80. package/dist/value-BGGrx72L.js.map +1 -0
  81. package/package.json +22 -22
  82. package/dist/attachment/index.js.map +0 -1
  83. package/dist/attachment-mbjsroli.d.ts +0 -9
  84. package/dist/chat/index.js.map +0 -1
  85. package/dist/chat-PSj1Fo4W.d.ts +0 -88
  86. package/dist/chunk-22EZJUPM.js +0 -120
  87. package/dist/chunk-22EZJUPM.js.map +0 -1
  88. package/dist/chunk-5FZKTDZR.js +0 -201
  89. package/dist/chunk-5FZKTDZR.js.map +0 -1
  90. package/dist/chunk-6XOJFLX4.js +0 -22
  91. package/dist/chunk-6XOJFLX4.js.map +0 -1
  92. package/dist/chunk-CKA4CE26.js +0 -25
  93. package/dist/chunk-CKA4CE26.js.map +0 -1
  94. package/dist/chunk-DLBNFBXQ.js +0 -425
  95. package/dist/chunk-DLBNFBXQ.js.map +0 -1
  96. package/dist/chunk-E73S3SOF.js +0 -404
  97. package/dist/chunk-E73S3SOF.js.map +0 -1
  98. package/dist/chunk-F6AKBUO3.js +0 -380
  99. package/dist/chunk-F6AKBUO3.js.map +0 -1
  100. package/dist/chunk-HGOPGZNQ.js +0 -195
  101. package/dist/chunk-HGOPGZNQ.js.map +0 -1
  102. package/dist/chunk-KHB5CHAU.js +0 -220
  103. package/dist/chunk-KHB5CHAU.js.map +0 -1
  104. package/dist/chunk-LHABOAOP.js +0 -316
  105. package/dist/chunk-LHABOAOP.js.map +0 -1
  106. package/dist/chunk-N5XQU36W.js +0 -410
  107. package/dist/chunk-N5XQU36W.js.map +0 -1
  108. package/dist/chunk-T3ZFZ3NP.js +0 -30
  109. package/dist/chunk-T3ZFZ3NP.js.map +0 -1
  110. package/dist/chunk-T4IYUEPH.js +0 -1612
  111. package/dist/chunk-T4IYUEPH.js.map +0 -1
  112. package/dist/chunk-W2AHKMRS.js +0 -1092
  113. package/dist/chunk-W2AHKMRS.js.map +0 -1
  114. package/dist/completion/index.js.map +0 -1
  115. package/dist/completion-input-DHlwrhxB.d.ts +0 -24
  116. package/dist/composer-6iCSIq6L.d.ts +0 -111
  117. package/dist/human-input/index.js.map +0 -1
  118. package/dist/human-input-CkLrZ8IC.d.ts +0 -27
  119. package/dist/image/index.js.map +0 -1
  120. package/dist/image-VZv6Ddsn.d.ts +0 -14
  121. package/dist/message/index.js.map +0 -1
  122. package/dist/message-CNRnZQwU.d.ts +0 -14
  123. package/dist/render-CRKWam2v.d.ts +0 -8
  124. package/dist/selection-toolbar/index.js.map +0 -1
  125. package/dist/selection-toolbar-Cwjbuv5S.d.ts +0 -14
  126. package/dist/shared.js.map +0 -1
  127. package/dist/stream/index.js.map +0 -1
  128. package/dist/thread-Bz6-1zaJ.d.ts +0 -12
  129. package/dist/thread-list/index.js.map +0 -1
  130. package/dist/thread-list-On8db4XL.d.ts +0 -34
  131. package/dist/ticket-pexI1zIa.d.ts +0 -33
@@ -0,0 +1,318 @@
1
+ import { MutableRefObject, ReactElement, ReactNode } from "react";
2
+ import { UseChatResult, UseCompletionResult } from "@anvia/react";
3
+ import { ClientDataMap, ClientInteraction, ClientMetadata, ClientStreamRequest, ClientTransport, CreateUIAttachment, UIAttachment, UIMessage, UIMessagePart } from "@anvia/client";
4
+ import { GraphExploreNode, GraphSchemaLike } from "@anvia/graph";
5
+ import { GraphExplorerController, GraphExplorerExpandNodeOptions, GraphExplorerStatus } from "@anvia/react/graph-explorer";
6
+ type AttachmentContextValue = {
7
+ attachment: UIAttachment;
8
+ remove?(): void;
9
+ };
10
+ declare function useAttachment(): AttachmentContextValue;
11
+ type JsonPrimitive = string | number | boolean | null;
12
+ /** Any JSON-compatible value: primitives, objects, or readonly arrays of JSON values. */
13
+ type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
14
+ type JsonObject = {
15
+ [key: string]: JsonValue;
16
+ };
17
+ /** Answer to one question asked by a tool suspended on a human interaction. */
18
+ type ToolQuestionAnswer = Readonly<{
19
+ questionId: string;
20
+ value: string;
21
+ }>;
22
+ type AgentQuestionChoice = Readonly<{
23
+ label: string;
24
+ value: string;
25
+ }>;
26
+ type AgentQuestionPrompt = Readonly<{
27
+ id: string;
28
+ text: string;
29
+ choices?: readonly AgentQuestionChoice[];
30
+ allowCustom?: boolean;
31
+ }>;
32
+ type AgentQuestionAnswer = ToolQuestionAnswer;
33
+ type AgentInteractionRequestBase = Readonly<{
34
+ id: string;
35
+ toolName: string;
36
+ toolCallId: string;
37
+ callId?: string;
38
+ internalCallId: string;
39
+ }>;
40
+ type AgentToolApprovalRequest = AgentInteractionRequestBase & Readonly<{
41
+ type: "tool-approval";
42
+ input: JsonValue;
43
+ reason?: string;
44
+ }>;
45
+ type AgentToolQuestionRequest = AgentInteractionRequestBase & Readonly<{
46
+ type: "tool-question";
47
+ questions: readonly AgentQuestionPrompt[];
48
+ }>;
49
+ type AgentInteractionRequest = AgentToolApprovalRequest | AgentToolQuestionRequest;
50
+ type ChatController<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap> = UseChatResult<ClientTransport<ClientStreamRequest, Data, Metadata>>;
51
+ type ChatProviderProps<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap> = {
52
+ controller: ChatController<Metadata, Data>;
53
+ children?: ReactNode;
54
+ };
55
+ declare function ChatProvider<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap>({ controller, children }: ChatProviderProps<Metadata, Data>): ReactElement;
56
+ declare function useChatContext<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap>(): ChatController<Metadata, Data>;
57
+ declare function useHumanInput(): {
58
+ approvals: {
59
+ all: (Readonly<{
60
+ request: AgentInteractionRequest;
61
+ runId: string;
62
+ status: "pending" | "responded" | "cancelled";
63
+ }> & {
64
+ request: AgentToolApprovalRequest;
65
+ })[];
66
+ pending: (Readonly<{
67
+ request: AgentInteractionRequest;
68
+ runId: string;
69
+ status: "pending" | "responded" | "cancelled";
70
+ }> & {
71
+ request: AgentToolApprovalRequest;
72
+ })[];
73
+ };
74
+ questions: {
75
+ all: (Readonly<{
76
+ request: AgentInteractionRequest;
77
+ runId: string;
78
+ status: "pending" | "responded" | "cancelled";
79
+ }> & {
80
+ request: AgentToolQuestionRequest;
81
+ })[];
82
+ pending: (Readonly<{
83
+ request: AgentInteractionRequest;
84
+ runId: string;
85
+ status: "pending" | "responded" | "cancelled";
86
+ }> & {
87
+ request: AgentToolQuestionRequest;
88
+ })[];
89
+ };
90
+ };
91
+ type CompletionController<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap> = UseCompletionResult<Metadata, Data>;
92
+ type CompletionProviderProps<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap> = {
93
+ controller: CompletionController<Metadata, Data>;
94
+ children?: ReactNode;
95
+ };
96
+ declare function CompletionProvider<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap>({ controller, children }: CompletionProviderProps<Metadata, Data>): ReactElement;
97
+ declare function useCompletionContext<Metadata extends ClientMetadata = ClientMetadata, Data extends ClientDataMap = ClientDataMap>(): CompletionController<Metadata, Data>;
98
+ type GraphExplorerProviderProps<Schema extends GraphSchemaLike = GraphSchemaLike> = {
99
+ controller: GraphExplorerController<Schema>;
100
+ children?: ReactNode;
101
+ };
102
+ type GraphExplorerNodeContextValue = {
103
+ node: GraphExploreNode;
104
+ selected: boolean;
105
+ matched: boolean;
106
+ };
107
+ declare function GraphExplorerProvider<Schema extends GraphSchemaLike = GraphSchemaLike>({ controller, children }: GraphExplorerProviderProps<Schema>): ReactElement;
108
+ declare function useGraphExplorerContext<Schema extends GraphSchemaLike = GraphSchemaLike>(): GraphExplorerController<Schema>;
109
+ declare function useGraphExplorerNode(): GraphExplorerNodeContextValue;
110
+ type CompletionInputContextValue = {
111
+ input: string;
112
+ setInput(input: string): void;
113
+ submit(): Promise<void>;
114
+ stop(): void;
115
+ status: CompletionController["status"];
116
+ canSubmit: boolean;
117
+ canStop: boolean;
118
+ };
119
+ declare function useCompletionInput(): CompletionInputContextValue;
120
+ type ComposerEntityData = string | number | boolean | null | readonly ComposerEntityData[] | {
121
+ [key: string]: ComposerEntityData;
122
+ };
123
+ type ComposerAttachmentInput = File | CreateUIAttachment;
124
+ type ComposerAttachmentsUpdate = UIAttachment[] | ((attachments: UIAttachment[]) => UIAttachment[]);
125
+ type ComposerEntitiesUpdate = ComposerEntity[] | ((entities: ComposerEntity[]) => ComposerEntity[]);
126
+ type ComposerQuote = {
127
+ text: string;
128
+ messageId: string;
129
+ };
130
+ type ComposerTriggerItem = {
131
+ id: string;
132
+ label: string;
133
+ text?: string | undefined;
134
+ detail?: ReactNode | undefined;
135
+ data?: ComposerEntityData | undefined;
136
+ disabled?: boolean | undefined;
137
+ };
138
+ type ComposerTriggerItemsArgs = {
139
+ trigger: ComposerTriggerDefinition;
140
+ query: string;
141
+ input: string;
142
+ entities: ComposerEntity[];
143
+ signal: AbortSignal;
144
+ };
145
+ type ComposerTriggerItems = ComposerTriggerItem[] | ((args: ComposerTriggerItemsArgs) => ComposerTriggerItem[] | Promise<ComposerTriggerItem[]>);
146
+ type ComposerTriggerDefinition = {
147
+ id: string;
148
+ char: string;
149
+ items: ComposerTriggerItems;
150
+ minQueryLength?: number | undefined;
151
+ allowedPrefixes?: string[] | null | undefined;
152
+ startOfLine?: boolean | undefined;
153
+ allowSpaces?: boolean | undefined;
154
+ };
155
+ type ComposerEntity = {
156
+ id: string;
157
+ triggerId: string;
158
+ trigger: string;
159
+ label: string;
160
+ text: string;
161
+ range: {
162
+ from: number;
163
+ to: number;
164
+ };
165
+ data?: ComposerEntityData | undefined;
166
+ };
167
+ type ComposerMessageEntity = ClientMetadata & {
168
+ id: string;
169
+ triggerId: string;
170
+ trigger: string;
171
+ label: string;
172
+ text: string;
173
+ range: ClientMetadata & {
174
+ from: number;
175
+ to: number;
176
+ };
177
+ data?: ComposerEntityData | undefined;
178
+ };
179
+ type ComposerMessageMetadata = ClientMetadata & {
180
+ composer: ClientMetadata & {
181
+ entities: readonly ComposerMessageEntity[];
182
+ };
183
+ };
184
+ type ComposerTriggerState = {
185
+ trigger: ComposerTriggerDefinition;
186
+ query: string;
187
+ items: ComposerTriggerItem[];
188
+ loading: boolean;
189
+ selectedIndex: number;
190
+ rect?: {
191
+ top: number;
192
+ right: number;
193
+ bottom: number;
194
+ left: number;
195
+ width: number;
196
+ height: number;
197
+ };
198
+ selectItem(item: ComposerTriggerItem): void;
199
+ setSelectedIndex(index: number): void;
200
+ };
201
+ type ComposerTriggerStateUpdate = ComposerTriggerState | undefined | ((state: ComposerTriggerState | undefined) => ComposerTriggerState | undefined);
202
+ type ComposerContextValue = {
203
+ input: string;
204
+ setInput(input: string): void;
205
+ attachments: UIAttachment[];
206
+ setAttachments(update: ComposerAttachmentsUpdate): void;
207
+ addAttachment(attachment: ComposerAttachmentInput): Promise<void>;
208
+ removeAttachment(id: string): void;
209
+ clearAttachments(): void;
210
+ entities: ComposerEntity[];
211
+ setEntities(update: ComposerEntitiesUpdate): void;
212
+ quote?: ComposerQuote | undefined;
213
+ setQuote(quote: ComposerQuote | undefined): void;
214
+ clearQuote(): void;
215
+ triggers: ComposerTriggerDefinition[];
216
+ activeTrigger?: ComposerTriggerState | undefined;
217
+ setActiveTrigger(update: ComposerTriggerStateUpdate): void;
218
+ submit(): Promise<void>;
219
+ stop(): void;
220
+ status: ChatController["status"];
221
+ canSubmit: boolean;
222
+ canStop: boolean;
223
+ };
224
+ declare function useComposer(): ComposerContextValue;
225
+ type ApprovalContextValue = {
226
+ approval: ApprovalInteraction;
227
+ reason: string;
228
+ setReason(reason: string): void;
229
+ };
230
+ type QuestionContextValue = {
231
+ question: QuestionInteraction;
232
+ answers: Record<string, AgentQuestionAnswer>;
233
+ setAnswer(prompt: AgentQuestionPrompt, answer: AgentQuestionAnswer): void;
234
+ };
235
+ type QuestionPromptContextValue = {
236
+ prompt: AgentQuestionPrompt;
237
+ };
238
+ type ApprovalInteraction = ClientInteraction & {
239
+ request: AgentToolApprovalRequest;
240
+ };
241
+ type QuestionInteraction = ClientInteraction & {
242
+ request: AgentToolQuestionRequest;
243
+ };
244
+ declare function useApproval(): ApprovalContextValue;
245
+ declare function useQuestion(): QuestionContextValue;
246
+ declare function useQuestionPrompt(): QuestionPromptContextValue;
247
+ type ImageContextValue = {
248
+ attachment: UIAttachment;
249
+ src?: string;
250
+ name?: string;
251
+ mediaType?: string;
252
+ isImage: boolean;
253
+ zoomOpen: boolean;
254
+ setZoomOpen(open: boolean): void;
255
+ };
256
+ declare function useImage(): ImageContextValue;
257
+ type MessageContextValue = {
258
+ message: UIMessage;
259
+ };
260
+ type MessagePartContextValue = {
261
+ isLive: boolean;
262
+ part: UIMessagePart;
263
+ streamControlled: boolean;
264
+ };
265
+ declare function useMessage(): MessageContextValue;
266
+ declare function useMessagePart(): MessagePartContextValue;
267
+ type SelectionToolbarSelection = {
268
+ text: string;
269
+ messageId: string;
270
+ rect: DOMRect;
271
+ };
272
+ type SelectionToolbarContextValue = {
273
+ selection?: SelectionToolbarSelection;
274
+ quote(): void;
275
+ copy(): Promise<void>;
276
+ clear(): void;
277
+ };
278
+ declare function useSelectionToolbar(): SelectionToolbarContextValue;
279
+ type ThreadContextValue = {
280
+ viewportRef: MutableRefObject<HTMLElement | null>;
281
+ messagesRef: MutableRefObject<HTMLElement | null>;
282
+ atBottom: boolean;
283
+ setAtBottom(atBottom: boolean): void;
284
+ scrollToBottom(behavior?: ScrollBehavior): void;
285
+ };
286
+ declare function useThread(): ThreadContextValue;
287
+ type ThreadListRecord = {
288
+ id: string;
289
+ title?: string;
290
+ createdAt?: string | Date;
291
+ updatedAt?: string | Date;
292
+ archived?: boolean;
293
+ metadata?: unknown;
294
+ };
295
+ type ThreadListController = {
296
+ threads: ThreadListRecord[];
297
+ activeThreadId?: string;
298
+ status?: "idle" | "loading" | "error";
299
+ error?: unknown;
300
+ createThread(): Promise<void> | void;
301
+ switchThread(threadId: string): Promise<void> | void;
302
+ archiveThread?(threadId: string): Promise<void> | void;
303
+ unarchiveThread?(threadId: string): Promise<void> | void;
304
+ deleteThread?(threadId: string): Promise<void> | void;
305
+ };
306
+ type ThreadListItemContextValue = {
307
+ thread: ThreadListRecord;
308
+ active: boolean;
309
+ };
310
+ type ThreadListProviderProps = {
311
+ controller: ThreadListController;
312
+ children?: ReactNode;
313
+ };
314
+ declare function ThreadListProvider({ controller, children }: ThreadListProviderProps): ReactElement;
315
+ declare function useThreadList(): ThreadListController;
316
+ declare function useThreadListItem(): ThreadListItemContextValue;
317
+ export { CompletionProvider as $, ComposerEntitiesUpdate as A, ComposerTriggerStateUpdate as B, QuestionPromptContextValue as C, ComposerAttachmentInput as D, useQuestionPrompt as E, ComposerTriggerDefinition as F, GraphExplorerExpandNodeOptions as G, CompletionInputContextValue as H, ComposerTriggerItem as I, GraphExplorerProviderProps as J, GraphExplorerNodeContextValue as K, ComposerTriggerItems as L, ComposerEntityData as M, ComposerMessageMetadata as N, ComposerAttachmentsUpdate as O, ComposerQuote as P, CompletionController as Q, ComposerTriggerItemsArgs as R, QuestionInteraction as S, useQuestion as T, useCompletionInput as U, useComposer as V, GraphExplorerController as W, useGraphExplorerContext as X, GraphExplorerStatus as Y, useGraphExplorerNode as Z, ImageContextValue as _, ThreadListRecord as a, useChatContext as at, ApprovalInteraction as b, ThreadContextValue as c, useAttachment as ct, SelectionToolbarSelection as d, CompletionProviderProps as et, useSelectionToolbar as f, useMessagePart as g, useMessage as h, ThreadListProviderProps as i, ChatProviderProps as it, ComposerEntity as j, ComposerContextValue as k, useThread as l, MessagePartContextValue as m, ThreadListItemContextValue as n, ChatController as nt, useThreadList as o, useHumanInput as ot, MessageContextValue as p, GraphExplorerProvider as q, ThreadListProvider as r, ChatProvider as rt, useThreadListItem as s, AttachmentContextValue as st, ThreadListController as t, useCompletionContext as tt, SelectionToolbarContextValue as u, useImage as v, useApproval as w, QuestionContextValue as x, ApprovalContextValue as y, ComposerTriggerState as z };
318
+ //# sourceMappingURL=index-Mw3ltwSG.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Mw3ltwSG.d.ts","names":["_$_anvia_core_agent_interactions0.AgentInteractionRequest"],"sources":["../src/contexts/attachment.tsx","../../core/src/completion/types.ts","../../core/src/agent/interactions.ts","../src/contexts/chat.tsx","../src/contexts/completion.tsx","../src/contexts/graph-explorer.tsx","../src/contexts/completion-input.tsx","../src/contexts/composer.tsx","../src/contexts/human-input.tsx","../src/contexts/image.tsx","../src/contexts/message.tsx","../src/contexts/selection-toolbar.tsx","../src/contexts/thread.tsx","../src/contexts/thread-list.tsx"],"mappings":"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"}
package/dist/index.d.ts CHANGED
@@ -1,40 +1,7 @@
1
- export { AttachmentPrimitive } from './attachment/index.js';
2
- export { A as AttachmentContextValue, u as useAttachment } from './attachment-mbjsroli.js';
3
- export { C as ChatController, a as ChatProvider, b as ChatProviderProps, u as useChatContext, c as useHumanInput } from './chat-PSj1Fo4W.js';
4
- export { C as CompletionController, a as CompletionInputContextValue, b as CompletionProvider, c as CompletionProviderProps, u as useCompletionContext, d as useCompletionInput } from './completion-input-DHlwrhxB.js';
5
- export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, c as ComposerEntitiesUpdate, d as ComposerEntity, e as ComposerEntityData, f as ComposerMessageMetadata, g as ComposerQuote, h as ComposerTriggerDefinition, i as ComposerTriggerItem, j as ComposerTriggerItems, k as ComposerTriggerItemsArgs, l as ComposerTriggerState, m as ComposerTriggerStateUpdate, u as useComposer } from './composer-6iCSIq6L.js';
6
- export { A as ApprovalContextValue, Q as QuestionContextValue, a as QuestionPromptContextValue, u as useApproval, b as useQuestion, c as useQuestionPrompt } from './human-input-CkLrZ8IC.js';
7
- export { I as ImageContextValue, u as useImage } from './image-VZv6Ddsn.js';
8
- export { M as MessageContextValue, a as MessagePartContextValue, u as useMessage, b as useMessagePart } from './message-CNRnZQwU.js';
9
- export { S as SelectionToolbarContextValue, a as SelectionToolbarSelection, u as useSelectionToolbar } from './selection-toolbar-Cwjbuv5S.js';
10
- export { T as ThreadContextValue, u as useThread } from './thread-Bz6-1zaJ.js';
11
- export { T as ThreadListController, a as ThreadListItemContextValue, b as ThreadListProvider, c as ThreadListProviderProps, d as ThreadListRecord, u as useThreadList, e as useThreadListItem } from './thread-list-On8db4XL.js';
12
- export { ComposerInputEntity, ComposerPrimitive, ComposerSubmitMessage, ComposerSubmitMessageArgs, ThreadPrimitive } from './chat/index.js';
13
- export { CompletionPrimitive } from './completion/index.js';
14
- import * as react from 'react';
15
- import { ReactNode } from 'react';
16
- import { UseChatResult } from '@anvia/react';
17
- import { P as PrimitiveProps } from './render-CRKWam2v.js';
18
- export { a as PrimitiveRef } from './render-CRKWam2v.js';
19
- export { HumanInputPrimitive } from './human-input/index.js';
20
- export { ImagePrimitive } from './image/index.js';
21
- export { MessageAttachmentPart, MessageEntityProps, MessagePartsFilter, MessagePrimitive, MessageStreamOptions, MessageToolPart, MessageToolRenderWhen } from './message/index.js';
22
- export { SelectionToolbarPrimitive } from './selection-toolbar/index.js';
23
- export { StreamMarkdown, StreamMarkdownProps } from './stream/index.js';
24
- export { ThreadListItemPrimitive, ThreadListPrimitive } from './thread-list/index.js';
25
- import '@anvia/client';
26
- import 'react-markdown';
27
-
28
- type ContextUsage = NonNullable<UseChatResult["contextUsage"]>;
29
- type ContextMeterProps = Omit<PrimitiveProps<"div">, "children"> & {
30
- usage?: ContextUsage;
31
- display?: "remaining" | "used";
32
- children?: ReactNode | ((usage: ContextUsage) => ReactNode);
33
- };
34
- declare const ContextMeterPrimitive: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
35
- usage?: ContextUsage;
36
- display?: "remaining" | "used";
37
- children?: ReactNode | ((usage: ContextUsage) => ReactNode);
38
- } & react.RefAttributes<HTMLDivElement>>;
39
-
40
- export { ContextMeterPrimitive, type ContextMeterProps, PrimitiveProps };
1
+ import { $ as CompletionProvider, A as ComposerEntitiesUpdate, B as ComposerTriggerStateUpdate, C as QuestionPromptContextValue, D as ComposerAttachmentInput, E as useQuestionPrompt, F as ComposerTriggerDefinition, H as CompletionInputContextValue, I as ComposerTriggerItem, L as ComposerTriggerItems, M as ComposerEntityData, N as ComposerMessageMetadata, O as ComposerAttachmentsUpdate, P as ComposerQuote, Q as CompletionController, R as ComposerTriggerItemsArgs, T as useQuestion, U as useCompletionInput, V as useComposer, _ as ImageContextValue, a as ThreadListRecord, at as useChatContext, c as ThreadContextValue, ct as useAttachment, d as SelectionToolbarSelection, et as CompletionProviderProps, f as useSelectionToolbar, g as useMessagePart, h as useMessage, i as ThreadListProviderProps, it as ChatProviderProps, j as ComposerEntity, k as ComposerContextValue, l as useThread, m as MessagePartContextValue, n as ThreadListItemContextValue, nt as ChatController, o as useThreadList, ot as useHumanInput, p as MessageContextValue, r as ThreadListProvider, rt as ChatProvider, s as useThreadListItem, st as AttachmentContextValue, t as ThreadListController, tt as useCompletionContext, u as SelectionToolbarContextValue, v as useImage, w as useApproval, x as QuestionContextValue, y as ApprovalContextValue, z as ComposerTriggerState } from "./index-Mw3ltwSG.js";
2
+ import { n as PrimitiveRef, t as PrimitiveProps } from "./index-DqdyM0Jm.js";
3
+ import { a as ComposerSubmitMessageArgs, i as ComposerSubmitMessage, n as ComposerInputEntity, r as ComposerPrimitive, t as ThreadPrimitive } from "./index-B1Qs2Cjv.js";
4
+ import { t as CompletionPrimitive } from "./index-CGqtpc6b.js";
5
+ import { a as MessagePrimitive, c as MessagePartsFilter, d as MessageToolRenderWhen, f as ImagePrimitive, h as ContextMeterProps, i as SelectionToolbarPrimitive, l as MessageStreamOptions, m as ContextMeterPrimitive, n as ThreadListItemPrimitive, o as MessageEntityProps, p as HumanInputPrimitive, r as ThreadListPrimitive, s as MessageAttachmentPart, t as AttachmentPrimitive, u as MessageToolPart } from "./index-BCBVcl0D.js";
6
+ import { n as StreamMarkdownProps, t as StreamMarkdown } from "./index-CE22tsua.js";
7
+ export { type ApprovalContextValue, type AttachmentContextValue, AttachmentPrimitive, type ChatController, ChatProvider, type ChatProviderProps, type CompletionController, type CompletionInputContextValue, CompletionPrimitive, CompletionProvider, type CompletionProviderProps, type ComposerAttachmentInput, type ComposerAttachmentsUpdate, type ComposerContextValue, type ComposerEntitiesUpdate, type ComposerEntity, type ComposerEntityData, type ComposerInputEntity, type ComposerMessageMetadata, ComposerPrimitive, type ComposerQuote, type ComposerSubmitMessage, type ComposerSubmitMessageArgs, type ComposerTriggerDefinition, type ComposerTriggerItem, type ComposerTriggerItems, type ComposerTriggerItemsArgs, type ComposerTriggerState, type ComposerTriggerStateUpdate, ContextMeterPrimitive, type ContextMeterProps, HumanInputPrimitive, type ImageContextValue, ImagePrimitive, type MessageAttachmentPart, type MessageContextValue, type MessageEntityProps, type MessagePartContextValue, type MessagePartsFilter, MessagePrimitive, type MessageStreamOptions, type MessageToolPart, type MessageToolRenderWhen, type PrimitiveProps, type PrimitiveRef, type QuestionContextValue, type QuestionPromptContextValue, type SelectionToolbarContextValue, SelectionToolbarPrimitive, type SelectionToolbarSelection, StreamMarkdown, type StreamMarkdownProps, type ThreadContextValue, type ThreadListController, type ThreadListItemContextValue, ThreadListItemPrimitive, ThreadListPrimitive, ThreadListProvider, type ThreadListProviderProps, type ThreadListRecord, ThreadPrimitive, useApproval, useAttachment, useChatContext, useCompletionContext, useCompletionInput, useComposer, useHumanInput, useImage, useMessage, useMessagePart, useQuestion, useQuestionPrompt, useSelectionToolbar, useThread, useThreadList, useThreadListItem };
package/dist/index.js CHANGED
@@ -1,120 +1,36 @@
1
- import {
2
- SelectionToolbarPrimitive
3
- } from "./chunk-KHB5CHAU.js";
4
- import {
5
- ThreadListItemPrimitive,
6
- ThreadListPrimitive
7
- } from "./chunk-LHABOAOP.js";
8
- import {
9
- ComposerPrimitive,
10
- ThreadPrimitive
11
- } from "./chunk-T4IYUEPH.js";
12
- import {
13
- MessagePrimitive
14
- } from "./chunk-W2AHKMRS.js";
15
- import "./chunk-6XOJFLX4.js";
16
- import {
17
- StreamMarkdown
18
- } from "./chunk-F6AKBUO3.js";
19
- import {
20
- AttachmentPrimitive
21
- } from "./chunk-22EZJUPM.js";
22
- import {
23
- CompletionPrimitive
24
- } from "./chunk-HGOPGZNQ.js";
25
- import {
26
- HumanInputPrimitive
27
- } from "./chunk-N5XQU36W.js";
28
- import "./chunk-CKA4CE26.js";
29
- import {
30
- ImagePrimitive
31
- } from "./chunk-DLBNFBXQ.js";
32
- import {
33
- renderPrimitive
34
- } from "./chunk-T3ZFZ3NP.js";
35
- import {
36
- ChatProvider,
37
- CompletionProvider,
38
- ThreadListProvider,
39
- useApproval,
40
- useAttachment,
41
- useChatContext,
42
- useCompletionContext,
43
- useCompletionInput,
44
- useComposer,
45
- useHumanInput,
46
- useImage,
47
- useMessage,
48
- useMessagePart,
49
- useQuestion,
50
- useQuestionPrompt,
51
- useSelectionToolbar,
52
- useThread,
53
- useThreadList,
54
- useThreadListItem
55
- } from "./chunk-E73S3SOF.js";
56
-
57
- // src/context-meter.tsx
1
+ import { C as useQuestionPrompt, D as useCompletionInput, F as ChatProvider, I as useChatContext, L as useHumanInput, N as CompletionProvider, P as useCompletionContext, S as useQuestion, T as useComposer, _ as useImage, a as useThreadList, c as useThread, m as useMessagePart, o as useThreadListItem, p as useMessage, r as ThreadListProvider, u as useSelectionToolbar, x as useApproval, z as useAttachment } from "./contexts-B4ijG24z.js";
2
+ import { t as AttachmentPrimitive } from "./attachment-DsKTPumt.js";
3
+ import { n as ComposerPrimitive, t as ThreadPrimitive } from "./chat-CAnvUEAv.js";
4
+ import { t as CompletionPrimitive } from "./completion-DDTKoZRJ.js";
5
+ import { t as renderPrimitive } from "./primitives-xfE7zfwJ.js";
6
+ import { t as HumanInputPrimitive } from "./human-input-CsCbZomZ.js";
7
+ import { t as ImagePrimitive } from "./image-D_7vaQCR.js";
8
+ import { t as MessagePrimitive } from "./message-Dn3wW6yy.js";
9
+ import { t as SelectionToolbarPrimitive } from "./selection-toolbar-CIkOoM-7.js";
10
+ import { t as StreamMarkdown } from "./stream-CAO0x8_1.js";
11
+ import { n as ThreadListPrimitive, t as ThreadListItemPrimitive } from "./thread-list-xJbGXFrE.js";
58
12
  import { forwardRef } from "react";
59
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
60
- var ContextMeterPrimitive = forwardRef(
61
- function ContextMeter({ usage, display = "remaining", children, ...props }, ref) {
62
- if (usage === void 0) {
63
- return null;
64
- }
65
- const percent = display === "remaining" ? usage.remainingPercent : usage.usedPercent;
66
- const roundedPercent = Math.round(percent);
67
- const label = `${roundedPercent}% context ${display === "remaining" ? "left" : "used"}`;
68
- const content = typeof children === "function" ? children(usage) : children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
69
- /* @__PURE__ */ jsx("span", { children: label }),
70
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { style: { width: `${Math.min(100, Math.max(0, percent))}%` } }) })
71
- ] });
72
- return renderPrimitive(
73
- "div",
74
- {
75
- ...props,
76
- children: content,
77
- "aria-label": props["aria-label"] ?? label,
78
- "aria-valuemax": 100,
79
- "aria-valuemin": 0,
80
- "aria-valuenow": roundedPercent,
81
- role: props.role ?? "progressbar"
82
- },
83
- ref
84
- );
85
- }
86
- );
87
- export {
88
- AttachmentPrimitive,
89
- ChatProvider,
90
- CompletionPrimitive,
91
- CompletionProvider,
92
- ComposerPrimitive,
93
- ContextMeterPrimitive,
94
- HumanInputPrimitive,
95
- ImagePrimitive,
96
- MessagePrimitive,
97
- SelectionToolbarPrimitive,
98
- StreamMarkdown,
99
- ThreadListItemPrimitive,
100
- ThreadListPrimitive,
101
- ThreadListProvider,
102
- ThreadPrimitive,
103
- useApproval,
104
- useAttachment,
105
- useChatContext,
106
- useCompletionContext,
107
- useCompletionInput,
108
- useComposer,
109
- useHumanInput,
110
- useImage,
111
- useMessage,
112
- useMessagePart,
113
- useQuestion,
114
- useQuestionPrompt,
115
- useSelectionToolbar,
116
- useThread,
117
- useThreadList,
118
- useThreadListItem
119
- };
13
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
+ // src/context-meter.tsx
15
+ const ContextMeterPrimitive = forwardRef(function ContextMeter({ usage, display = "remaining", children, ...props }, ref) {
16
+ if (usage === void 0) return null;
17
+ const percent = display === "remaining" ? usage.remainingPercent : usage.usedPercent;
18
+ const roundedPercent = Math.round(percent);
19
+ const label = `${roundedPercent}% context ${display === "remaining" ? "left" : "used"}`;
20
+ const content = typeof children === "function" ? children(usage) : children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx("span", {
21
+ "aria-hidden": "true",
22
+ children: /* @__PURE__ */ jsx("span", { style: { width: `${Math.min(100, Math.max(0, percent))}%` } })
23
+ })] });
24
+ return renderPrimitive("div", {
25
+ ...props,
26
+ children: content,
27
+ "aria-label": props["aria-label"] ?? label,
28
+ "aria-valuemax": 100,
29
+ "aria-valuemin": 0,
30
+ "aria-valuenow": roundedPercent,
31
+ role: props.role ?? "progressbar"
32
+ }, ref);
33
+ });
34
+ export { AttachmentPrimitive, ChatProvider, CompletionPrimitive, CompletionProvider, ComposerPrimitive, ContextMeterPrimitive, HumanInputPrimitive, ImagePrimitive, MessagePrimitive, SelectionToolbarPrimitive, StreamMarkdown, ThreadListItemPrimitive, ThreadListPrimitive, ThreadListProvider, ThreadPrimitive, useApproval, useAttachment, useChatContext, useCompletionContext, useCompletionInput, useComposer, useHumanInput, useImage, useMessage, useMessagePart, useQuestion, useQuestionPrompt, useSelectionToolbar, useThread, useThreadList, useThreadListItem };
35
+
120
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/context-meter.tsx"],"sourcesContent":["import type { UseChatResult } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { type PrimitiveProps, renderPrimitive } from \"./primitives\";\n\ntype ContextUsage = NonNullable<UseChatResult[\"contextUsage\"]>;\n\nexport type ContextMeterProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n usage?: ContextUsage;\n display?: \"remaining\" | \"used\";\n children?: ReactNode | ((usage: ContextUsage) => ReactNode);\n};\n\nexport const ContextMeterPrimitive = forwardRef<HTMLDivElement, ContextMeterProps>(\n function ContextMeter({ usage, display = \"remaining\", children, ...props }, ref) {\n if (usage === undefined) {\n return null;\n }\n\n const percent = display === \"remaining\" ? usage.remainingPercent : usage.usedPercent;\n const roundedPercent = Math.round(percent);\n const label = `${roundedPercent}% context ${display === \"remaining\" ? \"left\" : \"used\"}`;\n const content =\n typeof children === \"function\"\n ? children(usage)\n : (children ?? (\n <>\n <span>{label}</span>\n <span aria-hidden=\"true\">\n <span style={{ width: `${Math.min(100, Math.max(0, percent))}%` }} />\n </span>\n </>\n ));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: content,\n \"aria-label\": props[\"aria-label\"] ?? label,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": roundedPercent,\n role: props.role ?? \"progressbar\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,kBAAkC;AAyB/B,mBACE,KADF;AAbL,IAAM,wBAAwB;AAAA,EACnC,SAAS,aAAa,EAAE,OAAO,UAAU,aAAa,UAAU,GAAG,MAAM,GAAG,KAAK;AAC/E,QAAI,UAAU,QAAW;AACvB,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,YAAY,cAAc,MAAM,mBAAmB,MAAM;AACzE,UAAM,iBAAiB,KAAK,MAAM,OAAO;AACzC,UAAM,QAAQ,GAAG,cAAc,aAAa,YAAY,cAAc,SAAS,MAAM;AACrF,UAAM,UACJ,OAAO,aAAa,aAChB,SAAS,KAAK,IACb,YACC,iCACE;AAAA,0BAAC,UAAM,iBAAM;AAAA,MACb,oBAAC,UAAK,eAAY,QAChB,8BAAC,UAAK,OAAO,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,IAAI,GAAG,GACrE;AAAA,OACF;AAGR,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU;AAAA,QACV,cAAc,MAAM,YAAY,KAAK;AAAA,QACrC,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,MAAM,MAAM,QAAQ;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/context-meter.tsx"],"sourcesContent":["import type { UseChatResult } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { type PrimitiveProps, renderPrimitive } from \"./primitives\";\n\ntype ContextUsage = NonNullable<UseChatResult[\"contextUsage\"]>;\n\nexport type ContextMeterProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n usage?: ContextUsage;\n display?: \"remaining\" | \"used\";\n children?: ReactNode | ((usage: ContextUsage) => ReactNode);\n};\n\nexport const ContextMeterPrimitive = forwardRef<HTMLDivElement, ContextMeterProps>(\n function ContextMeter({ usage, display = \"remaining\", children, ...props }, ref) {\n if (usage === undefined) {\n return null;\n }\n\n const percent = display === \"remaining\" ? usage.remainingPercent : usage.usedPercent;\n const roundedPercent = Math.round(percent);\n const label = `${roundedPercent}% context ${display === \"remaining\" ? \"left\" : \"used\"}`;\n const content =\n typeof children === \"function\"\n ? children(usage)\n : (children ?? (\n <>\n <span>{label}</span>\n <span aria-hidden=\"true\">\n <span style={{ width: `${Math.min(100, Math.max(0, percent))}%` }} />\n </span>\n </>\n ));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: content,\n \"aria-label\": props[\"aria-label\"] ?? label,\n \"aria-valuemax\": 100,\n \"aria-valuemin\": 0,\n \"aria-valuenow\": roundedPercent,\n role: props.role ?? \"progressbar\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,wBAAwB,WACnC,SAAS,aAAa,EAAE,OAAO,UAAU,aAAa,UAAU,GAAG,SAAS,KAAK;CAC/E,IAAI,UAAU,KAAA,GACZ,OAAO;CAGT,MAAM,UAAU,YAAY,cAAc,MAAM,mBAAmB,MAAM;CACzE,MAAM,iBAAiB,KAAK,MAAM,OAAO;CACzC,MAAM,QAAQ,GAAG,eAAe,YAAY,YAAY,cAAc,SAAS;CAC/E,MAAM,UACJ,OAAO,aAAa,aAChB,SAAS,KAAK,IACb,YACC,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,GACnB,oBAAC,QAAD;EAAM,eAAY;EAChB,UAAA,oBAAC,QAAD,EAAM,OAAO,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,EAAE,GAAG,EAAI,CAAA;CAChE,CAAA,CACN,EAAA,CAAA;CAGV,OAAO,gBACL,OACA;EACE,GAAG;EACH,UAAU;EACV,cAAc,MAAM,iBAAiB;EACrC,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;EACjB,MAAM,MAAM,QAAQ;CACtB,GACA,GACF;AACF,CACF"}