@rungent/react 0.0.0-stage → 0.6.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/LICENSE +18 -0
- package/README.md +45 -2
- package/dist/client-BxNE_rPk.js +1167 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +1 -0
- package/dist/index-B2fKzvt5.d.ts +539 -0
- package/dist/index.d.ts +375 -0
- package/dist/index.js +3643 -0
- package/dist/styles.css +1833 -0
- package/package.json +77 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { F as CatalogOperation, J as RungentClient, M as Form, N as FormAnswers, P as FormIssue, S as ThreadState, at as FederatedSearchResponse, f as Citation, l as ApprovalInterrupt, n as Context, r as ResumeEntry, t as ContentPart, tt as ThreadSummary } from "./index-B2fKzvt5.js";
|
|
2
|
+
import { ComponentType, ReactNode, RefObject } from "react";
|
|
3
|
+
interface ApprovalCardProps {
|
|
4
|
+
readonly interrupt: ApprovalInterrupt;
|
|
5
|
+
readonly onAnswer: (approved: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
/** Asks the user to approve one write, showing exactly what will run. */
|
|
8
|
+
export declare function ApprovalCard({ interrupt, onAnswer }: ApprovalCardProps): import("react").JSX.Element;
|
|
9
|
+
declare const en: {
|
|
10
|
+
assistant: string;
|
|
11
|
+
openAssistant: string;
|
|
12
|
+
close: string;
|
|
13
|
+
history: string;
|
|
14
|
+
newChat: string;
|
|
15
|
+
noThreads: string;
|
|
16
|
+
untitled: string;
|
|
17
|
+
deleteThread: string;
|
|
18
|
+
loadMore: string;
|
|
19
|
+
welcomeTitle: string;
|
|
20
|
+
welcome: string;
|
|
21
|
+
suggestions: string;
|
|
22
|
+
expand: string;
|
|
23
|
+
collapse: string;
|
|
24
|
+
resize: string;
|
|
25
|
+
jumpToLatest: string;
|
|
26
|
+
contextTitle: string;
|
|
27
|
+
contextDetail: string;
|
|
28
|
+
contextOver: string;
|
|
29
|
+
contextEstimated: string;
|
|
30
|
+
formCancel: string;
|
|
31
|
+
formIssues: string;
|
|
32
|
+
composerPlaceholder: string;
|
|
33
|
+
composerLabel: string;
|
|
34
|
+
send: string;
|
|
35
|
+
stop: string;
|
|
36
|
+
thinking: string;
|
|
37
|
+
retrying: string;
|
|
38
|
+
cancelled: string;
|
|
39
|
+
contextUsed: string;
|
|
40
|
+
toolAwaitingApproval: string;
|
|
41
|
+
toolAwaitingInput: string;
|
|
42
|
+
toolFailed: string;
|
|
43
|
+
toolNotExecuted: string;
|
|
44
|
+
toolDeduplicated: string;
|
|
45
|
+
traceWorking: string;
|
|
46
|
+
traceWriting: string;
|
|
47
|
+
traceThought: string;
|
|
48
|
+
traceSearching: string;
|
|
49
|
+
traceSearched: string;
|
|
50
|
+
traceSearchedPlain: string;
|
|
51
|
+
traceResult: string;
|
|
52
|
+
traceResults: string;
|
|
53
|
+
traceItem: string;
|
|
54
|
+
traceItems: string;
|
|
55
|
+
traceAsked: string;
|
|
56
|
+
traceAwaitingAnswer: string;
|
|
57
|
+
traceWorked: string;
|
|
58
|
+
traceSeparator: string;
|
|
59
|
+
traceMore: string;
|
|
60
|
+
traceDetails: string;
|
|
61
|
+
traceArguments: string;
|
|
62
|
+
traceResultJson: string;
|
|
63
|
+
sources: string;
|
|
64
|
+
'error.model_unavailable': string;
|
|
65
|
+
'error.max_steps': string;
|
|
66
|
+
'error.open_interrupts': string;
|
|
67
|
+
'error.history_conflict': string;
|
|
68
|
+
'error.invalid_interaction': string;
|
|
69
|
+
'error.internal': string;
|
|
70
|
+
'error.request': string;
|
|
71
|
+
approvalNeeded: string;
|
|
72
|
+
approve: string;
|
|
73
|
+
reject: string;
|
|
74
|
+
expired: string;
|
|
75
|
+
expiresAt: string;
|
|
76
|
+
target: string;
|
|
77
|
+
risk: string;
|
|
78
|
+
'risk.low': string;
|
|
79
|
+
'risk.medium': string;
|
|
80
|
+
'risk.high': string;
|
|
81
|
+
cost: string;
|
|
82
|
+
changes: string;
|
|
83
|
+
arguments: string;
|
|
84
|
+
'effect.read': string;
|
|
85
|
+
'effect.create': string;
|
|
86
|
+
'effect.update': string;
|
|
87
|
+
'effect.delete': string;
|
|
88
|
+
'effect.external': string;
|
|
89
|
+
submit: string;
|
|
90
|
+
required: string;
|
|
91
|
+
optional: string;
|
|
92
|
+
recommended: string;
|
|
93
|
+
other: string;
|
|
94
|
+
otherPlaceholder: string;
|
|
95
|
+
'issue.required': string;
|
|
96
|
+
'issue.one': string;
|
|
97
|
+
taskRunning: string;
|
|
98
|
+
cancelTask: string;
|
|
99
|
+
searchPlaceholder: string;
|
|
100
|
+
searchLabel: string;
|
|
101
|
+
searching: string;
|
|
102
|
+
noResults: string;
|
|
103
|
+
failedSources: string;
|
|
104
|
+
askAssistant: string;
|
|
105
|
+
loading: string;
|
|
106
|
+
loadFailed: string;
|
|
107
|
+
models: string;
|
|
108
|
+
modelsHint: string;
|
|
109
|
+
provider: string;
|
|
110
|
+
model: string;
|
|
111
|
+
baseURL: string;
|
|
112
|
+
apiKey: string;
|
|
113
|
+
apiKeySaved: string;
|
|
114
|
+
vision: string;
|
|
115
|
+
moveUp: string;
|
|
116
|
+
moveDown: string;
|
|
117
|
+
remove: string;
|
|
118
|
+
addModel: string;
|
|
119
|
+
save: string;
|
|
120
|
+
saved: string;
|
|
121
|
+
saveFailed: string;
|
|
122
|
+
temperature: string;
|
|
123
|
+
maxOutputTokens: string;
|
|
124
|
+
configuredInCode: string;
|
|
125
|
+
saveReplacesCode: string;
|
|
126
|
+
resetDefaults: string;
|
|
127
|
+
resetConfirm: string;
|
|
128
|
+
resetDone: string;
|
|
129
|
+
cancel: string;
|
|
130
|
+
attach: string;
|
|
131
|
+
attachments: string;
|
|
132
|
+
dropFiles: string;
|
|
133
|
+
uploading: string;
|
|
134
|
+
uploadFailed: string;
|
|
135
|
+
removeAttachment: string;
|
|
136
|
+
openAttachment: string;
|
|
137
|
+
image: string;
|
|
138
|
+
file: string;
|
|
139
|
+
rateAnswer: string;
|
|
140
|
+
goodAnswer: string;
|
|
141
|
+
badAnswer: string;
|
|
142
|
+
feedbackComment: string;
|
|
143
|
+
feedbackSend: string;
|
|
144
|
+
feedbackSkip: string;
|
|
145
|
+
feedbackThanks: string;
|
|
146
|
+
feedbackFailed: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Every string the components show. `type.<hit type>` keys name search result groups, e.g.
|
|
150
|
+
* `{ 'type.work_item': 'Work items' }`; a type without one shows humanized (`Work item`).
|
|
151
|
+
*/
|
|
152
|
+
type Strings = typeof en & {
|
|
153
|
+
readonly [type: `type.${string}`]: string;
|
|
154
|
+
};
|
|
155
|
+
/** The built-in string tables, by locale. */
|
|
156
|
+
export declare const locales: {
|
|
157
|
+
readonly en: Strings;
|
|
158
|
+
readonly 'zh-CN': Strings;
|
|
159
|
+
};
|
|
160
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
161
|
+
/** A file the host stored for a message: a URL the model and the user can fetch it by. */
|
|
162
|
+
interface UploadedFile {
|
|
163
|
+
readonly url: string;
|
|
164
|
+
readonly mimeType: string;
|
|
165
|
+
readonly name?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* What a host's own form gets when rungent asks for an operation's input: the same form component
|
|
169
|
+
* as the product's page, so the user sees the fields, options and checks they know.
|
|
170
|
+
*/
|
|
171
|
+
interface HostFormProps {
|
|
172
|
+
readonly op: string;
|
|
173
|
+
/** The arguments to start from: what the user said, or what they submitted before. */
|
|
174
|
+
readonly arguments: Readonly<Record<string, unknown>>;
|
|
175
|
+
/** Why rungent refused the last submission, by argument path. */
|
|
176
|
+
readonly issues: readonly FormIssue[];
|
|
177
|
+
/** Submits the operation's complete arguments; approval follows where the operation asks. */
|
|
178
|
+
readonly submit: (args: Record<string, unknown>) => void;
|
|
179
|
+
readonly cancel: () => void;
|
|
180
|
+
}
|
|
181
|
+
interface RungentProviderProps {
|
|
182
|
+
readonly client: RungentClient;
|
|
183
|
+
/** A BCP 47 tag; `zh-CN` has its own strings, anything else speaks English. */
|
|
184
|
+
readonly locale?: string;
|
|
185
|
+
/** Replaces built-in strings by key, e.g. `{ assistant: 'Copilot' }`. */
|
|
186
|
+
readonly strings?: Partial<Strings>;
|
|
187
|
+
/** Stores a file the user attaches. Without it the composer offers no attachments. */
|
|
188
|
+
readonly upload?: (file: File) => Promise<UploadedFile>;
|
|
189
|
+
/** What the user is looking at; called as each run starts and sent as its AG-UI `context`. */
|
|
190
|
+
readonly context?: () => Context[];
|
|
191
|
+
/** Shows a product page. Receives only same-origin paths (`/path?query#hash`). */
|
|
192
|
+
readonly onOpen?: (path: string) => void;
|
|
193
|
+
/** The color scheme; `system` follows `prefers-color-scheme`. Colors are CSS variables. */
|
|
194
|
+
readonly theme?: Theme;
|
|
195
|
+
/**
|
|
196
|
+
* The host's own forms, by operation name. An operation's form opens one of these, prefilled;
|
|
197
|
+
* an operation without one gets the generic form its `role: form` operation describes.
|
|
198
|
+
*/
|
|
199
|
+
readonly forms?: Readonly<Record<string, ComponentType<HostFormProps>>>;
|
|
200
|
+
/** Questions an empty conversation offers, e.g. for the page the user is on. */
|
|
201
|
+
readonly suggestions?: () => readonly string[];
|
|
202
|
+
readonly children: ReactNode;
|
|
203
|
+
}
|
|
204
|
+
export declare function RungentProvider({ client, locale, strings, upload, context, onOpen, theme, forms, suggestions, children }: RungentProviderProps): import("react").JSX.Element;
|
|
205
|
+
interface DockHandle {
|
|
206
|
+
readonly open: boolean;
|
|
207
|
+
readonly setOpen: (open: boolean) => void;
|
|
208
|
+
/** Opens the dock on a new conversation that starts with `query`. */
|
|
209
|
+
readonly ask: (query: string) => void;
|
|
210
|
+
}
|
|
211
|
+
/** Controls the dock from the host page, e.g. an "Ask the assistant" button. */
|
|
212
|
+
export declare function useDock(): DockHandle;
|
|
213
|
+
interface SearchPaletteHandle {
|
|
214
|
+
readonly isOpen: boolean;
|
|
215
|
+
/** Opens the palette, with `query` typed in. */
|
|
216
|
+
readonly open: (query?: string) => void;
|
|
217
|
+
readonly close: () => void;
|
|
218
|
+
}
|
|
219
|
+
/** Controls the search palette from the host page, e.g. a search button in the header. */
|
|
220
|
+
export declare function useSearchPalette(): SearchPaletteHandle;
|
|
221
|
+
/** How the dock sits beside the page. */
|
|
222
|
+
type DockLayout = 'closed' | 'panel' | 'expanded';
|
|
223
|
+
interface RungentDockProps {
|
|
224
|
+
/**
|
|
225
|
+
* The product's page: the open panel takes its room from the page's right side. Without it
|
|
226
|
+
* (a page the host cannot wrap, such as a static site's), the panel is fixed at the window's
|
|
227
|
+
* right edge and reserves its width on the document instead.
|
|
228
|
+
*/
|
|
229
|
+
readonly children?: ReactNode;
|
|
230
|
+
/** Whether the panel is open; controlled when given. Else it is remembered per `baseUrl`. */
|
|
231
|
+
readonly open?: boolean;
|
|
232
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
233
|
+
/** The thread shown, null for a new one; controlled when given. Else it is remembered. */
|
|
234
|
+
readonly threadId?: string | null;
|
|
235
|
+
readonly onThreadChange?: (threadId: string | null) => void;
|
|
236
|
+
/** Told when the layout changes, e.g. to fold the product's own navigation beside the panel. */
|
|
237
|
+
readonly onLayoutChange?: (layout: DockLayout) => void;
|
|
238
|
+
/** Shows the round launcher while closed. Off when the product has its own button (`useDock`). */
|
|
239
|
+
readonly launcher?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The assistant beside the product's page. Open, the panel takes its room from the page instead
|
|
243
|
+
* of covering it, so what rungent opens or changes stays in view; its width can be dragged and is
|
|
244
|
+
* remembered. Expanded, the conversation fills the area with the history beside it. On narrow
|
|
245
|
+
* screens it fills the screen. ⌘J / Ctrl+J toggles it, Escape closes it (or leaves expanded).
|
|
246
|
+
*
|
|
247
|
+
* Mount it once, with `RungentProvider`, in the app's root layout: outside per-route layouts
|
|
248
|
+
* (Next.js `app/layout.tsx`, a React Router root route), so that navigating never mounts it
|
|
249
|
+
* again. Whether it is open, its width, thread and view live in a store that outlives the dock
|
|
250
|
+
* (and `localStorage`), and the first paint shows them, so even a dock mounted again stays put:
|
|
251
|
+
* it animates only when the user opens it.
|
|
252
|
+
*/
|
|
253
|
+
export declare function RungentDock({ children, open: openProp, onOpenChange, threadId: threadProp, onThreadChange, onLayoutChange, launcher }: RungentDockProps): import("react").JSX.Element;
|
|
254
|
+
/** The panel's width: its default, and the range the user can drag it in. */
|
|
255
|
+
export declare const DOCK_WIDTH: {
|
|
256
|
+
readonly initial: 420;
|
|
257
|
+
readonly min: 360;
|
|
258
|
+
readonly max: 640;
|
|
259
|
+
};
|
|
260
|
+
interface RungentFormProps {
|
|
261
|
+
readonly form: Form;
|
|
262
|
+
/** Values to start from by question id (a dotted argument path), over the questions' defaults. */
|
|
263
|
+
readonly values?: Readonly<Record<string, unknown>>;
|
|
264
|
+
/** Problems with the last submission, by question id; others show above the questions. */
|
|
265
|
+
readonly issues?: readonly FormIssue[];
|
|
266
|
+
readonly onSubmit: (answers: FormAnswers['answers']) => void;
|
|
267
|
+
readonly onCancel?: () => void;
|
|
268
|
+
}
|
|
269
|
+
/** A form the agent or an operation asks the user to fill in. */
|
|
270
|
+
export declare function RungentForm({ form, values: given, issues: refused, onSubmit, onCancel }: RungentFormProps): import("react").JSX.Element;
|
|
271
|
+
interface HelpViewerProps {
|
|
272
|
+
/** The Markdown page to show; relative links and images resolve against it. */
|
|
273
|
+
readonly url: string;
|
|
274
|
+
}
|
|
275
|
+
/** Fetches and renders one Markdown help page. */
|
|
276
|
+
export declare function HelpViewer({ url }: HelpViewerProps): import("react").JSX.Element;
|
|
277
|
+
interface ThreadHandle {
|
|
278
|
+
/** The thread shown; set once `send` created one. */
|
|
279
|
+
readonly threadId: string | null;
|
|
280
|
+
readonly state: ThreadState;
|
|
281
|
+
/** A request that failed before its run started. */
|
|
282
|
+
readonly error: unknown;
|
|
283
|
+
/**
|
|
284
|
+
* Sends a message (text, or text and attachment parts), creating the thread when there is
|
|
285
|
+
* none and cancelling open interrupts.
|
|
286
|
+
*/
|
|
287
|
+
readonly send: (message: string | ContentPart[]) => Promise<void>;
|
|
288
|
+
/** Answers open interrupts. */
|
|
289
|
+
readonly resume: (entries: ResumeEntry[]) => Promise<void>;
|
|
290
|
+
/** Cancels the running run. */
|
|
291
|
+
readonly cancel: () => Promise<void>;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* A thread's live state: it replays the thread's events and follows them, and opens the pages
|
|
295
|
+
* (`rungent.ui.open`) that runs started here ask for.
|
|
296
|
+
*/
|
|
297
|
+
export declare function useThread(threadId: string | null): ThreadHandle;
|
|
298
|
+
interface ThreadsHandle {
|
|
299
|
+
readonly threads: readonly ThreadSummary[];
|
|
300
|
+
readonly loading: boolean;
|
|
301
|
+
readonly error: unknown;
|
|
302
|
+
/** Whether `loadMore` has another page. */
|
|
303
|
+
readonly hasMore: boolean;
|
|
304
|
+
readonly reload: () => void;
|
|
305
|
+
readonly loadMore: () => void;
|
|
306
|
+
readonly remove: (id: string) => Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
/** The user's threads, newest first. */
|
|
309
|
+
export declare function useThreads(): ThreadsHandle;
|
|
310
|
+
interface SearchHandle {
|
|
311
|
+
/** The answer for the current query; null while it is empty or not yet answered. */
|
|
312
|
+
readonly result: FederatedSearchResponse | null;
|
|
313
|
+
readonly loading: boolean;
|
|
314
|
+
readonly error: unknown;
|
|
315
|
+
}
|
|
316
|
+
/** Federated search, debounced; a newer query aborts the older request. */
|
|
317
|
+
export declare function useSearch(query: string): SearchHandle;
|
|
318
|
+
interface CatalogHandle {
|
|
319
|
+
readonly operations: readonly CatalogOperation[];
|
|
320
|
+
readonly loading: boolean;
|
|
321
|
+
readonly error: unknown;
|
|
322
|
+
}
|
|
323
|
+
/** The operations visible to this user. */
|
|
324
|
+
export declare function useCatalog(): CatalogHandle;
|
|
325
|
+
interface MarkdownProps {
|
|
326
|
+
readonly text: string;
|
|
327
|
+
/** What the answer's `[n]` markers cite, by `n`. */
|
|
328
|
+
readonly citations?: readonly Citation[];
|
|
329
|
+
/** Resolves relative links, e.g. against a help page's URL. */
|
|
330
|
+
readonly baseUrl?: string;
|
|
331
|
+
/** Text still arriving: a caret follows it, and only its last block renders again. */
|
|
332
|
+
readonly streaming?: boolean;
|
|
333
|
+
}
|
|
334
|
+
/** Safe Markdown: raw HTML is not rendered, and same-origin links route through `onOpen`. */
|
|
335
|
+
export declare function Markdown({ text, citations, baseUrl, streaming }: MarkdownProps): import("react").JSX.Element;
|
|
336
|
+
interface SearchPaletteProps {
|
|
337
|
+
/** Whether the palette is open; controlled when given. `useSearchPalette()` opens it too. */
|
|
338
|
+
readonly open?: boolean;
|
|
339
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
340
|
+
/** Takes the query of the last row; by default it opens the dock with it as a question. */
|
|
341
|
+
readonly onAsk?: (query: string) => void;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* ⌘K / Ctrl+K search over every source, grouped by type. Arrow keys move, Enter opens, and the
|
|
345
|
+
* last row hands the query to the assistant.
|
|
346
|
+
*/
|
|
347
|
+
export declare function SearchPalette({ open: openProp, onOpenChange, onAsk }?: SearchPaletteProps): import("react").JSX.Element | null;
|
|
348
|
+
/** The class that gives a scroll container rungent's scrollbar. */
|
|
349
|
+
export declare const SCROLL_CLASS = "rungent-scroll";
|
|
350
|
+
/** Set on the container while the user scrolls it; styles.css shows the thumb then. */
|
|
351
|
+
export declare const SCROLLING_ATTRIBUTE = "data-rungent-scrolling";
|
|
352
|
+
/**
|
|
353
|
+
* Gives `element` rungent's scrollbar and shows its thumb while the user scrolls it. Works on any
|
|
354
|
+
* element, React or not; returns a function that stops watching.
|
|
355
|
+
*/
|
|
356
|
+
export declare function watchScrollbar(element: HTMLElement): () => void;
|
|
357
|
+
/**
|
|
358
|
+
* `watchScrollbar` for the element in `ref`, also when it mounts later or changes (a list shown
|
|
359
|
+
* only while open). Put `SCROLL_CLASS` in its `className` as well, so the first paint already
|
|
360
|
+
* has the thin, hidden scrollbar.
|
|
361
|
+
*/
|
|
362
|
+
export declare function useScrollbar(ref: RefObject<HTMLElement | null>): void;
|
|
363
|
+
/** The admin form for the model chain. Keys are write-only: it shows whether one is stored. */
|
|
364
|
+
export declare function ModelSettings(): import("react").JSX.Element;
|
|
365
|
+
interface RungentThreadProps {
|
|
366
|
+
/** The thread to show; null starts a new one with the first message. */
|
|
367
|
+
readonly threadId: string | null;
|
|
368
|
+
/** Called when the first message created a thread. */
|
|
369
|
+
readonly onThreadCreated?: (threadId: string) => void;
|
|
370
|
+
/** A message to send once, as soon as the thread mounts. */
|
|
371
|
+
readonly initialMessage?: string;
|
|
372
|
+
}
|
|
373
|
+
/** One conversation: messages, tool activity, open requests and the composer. */
|
|
374
|
+
export declare function RungentThread({ threadId, onThreadCreated, initialMessage }: RungentThreadProps): import("react").JSX.Element;
|
|
375
|
+
export type { ApprovalCardProps, CatalogHandle, DockHandle, DockLayout, HelpViewerProps, HostFormProps, MarkdownProps, RungentDockProps, RungentFormProps, RungentProviderProps, RungentThreadProps, SearchHandle, SearchPaletteHandle, SearchPaletteProps, Strings, Theme, ThreadHandle, ThreadsHandle, UploadedFile };
|