@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/client.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as ThreadDetail, A as openInterrupt, B as FeedbackPage, C as Timed, D as attachmentPart, E as appendUserMessage, F as CatalogOperation, G as ModelEndpointUpdate, H as FeedbackRating, I as ClientOptions, J as RungentClient, K as RunRequest, L as CooldownSeconds, O as attachmentsOf, Q as SettingsUpdate, R as Feedback, S as ThreadState, T as UserItem, U as Info, V as FeedbackQuery, W as ModelEndpointSettings, X as SearchOptions, Y as RungentRequestError, Z as Settings, _ as ProgressItem, a as answerInput, b as TaskInterrupt, c as submitFormAnswers, d as Attachment, et as ThreadPage, f as Citation, g as OtherInterrupt, h as OpenInterrupt, i as answerApproval, it as RungentProtocolError, j as reduceThread, k as initialThreadState, l as ApprovalInterrupt, m as InputInterrupt, n as Context, nt as createClient, o as cancelAll, p as FormInterrupt, q as RunStream, r as ResumeEntry, rt as RungentEvent, s as submitForm, t as ContentPart, tt as ThreadSummary, u as AssistantItem, v as ReasoningItem, w as ToolItem, x as ThreadItem, y as RunStatus, z as FeedbackItem } from "./index-B2fKzvt5.js";
|
|
2
|
+
export { type ApprovalInterrupt, type AssistantItem, type Attachment, type CatalogOperation, type Citation, type ClientOptions, type ContentPart, type Context, type CooldownSeconds, type Feedback, type FeedbackItem, type FeedbackPage, type FeedbackQuery, type FeedbackRating, type FormInterrupt, type Info, type InputInterrupt, type ModelEndpointSettings, type ModelEndpointUpdate, type OpenInterrupt, type OtherInterrupt, type ProgressItem, type ReasoningItem, type ResumeEntry, type RunRequest, type RunStatus, type RunStream, type RungentClient, type RungentEvent, RungentProtocolError, RungentRequestError, type SearchOptions, type Settings, type SettingsUpdate, type TaskInterrupt, type ThreadDetail, type ThreadItem, type ThreadPage, type ThreadState, type ThreadSummary, type Timed, type ToolItem, type UserItem, answerApproval, answerInput, appendUserMessage, attachmentPart, attachmentsOf, cancelAll, createClient, initialThreadState, openInterrupt, reduceThread, submitForm, submitFormAnswers };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { m as RungentProtocolError, f as RungentRequestError, t as answerApproval, n as answerInput, o as appendUserMessage, s as attachmentPart, c as attachmentsOf, r as cancelAll, p as createClient, l as initialThreadState, u as openInterrupt, d as reduceThread, i as submitForm, a as submitFormAnswers } from "./client-BxNE_rPk.js";
|
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ContentPart, ContentPart as ContentPart$1, Context, Context as Context$1, Event, Interrupt, Message, ResumeEntry, ResumeEntry as ResumeEntry$1, TokenUsage } from "@ag-ui/core";
|
|
3
|
+
declare const Effect: z.ZodEnum<{
|
|
4
|
+
create: "create";
|
|
5
|
+
delete: "delete";
|
|
6
|
+
external: "external";
|
|
7
|
+
read: "read";
|
|
8
|
+
update: "update";
|
|
9
|
+
}>;
|
|
10
|
+
type Effect = z.infer<typeof Effect>;
|
|
11
|
+
declare const Approval: z.ZodEnum<{
|
|
12
|
+
always: "always";
|
|
13
|
+
never: "never";
|
|
14
|
+
}>;
|
|
15
|
+
type Approval = z.infer<typeof Approval>;
|
|
16
|
+
declare const Surface: z.ZodEnum<{
|
|
17
|
+
agent: "agent";
|
|
18
|
+
cli: "cli";
|
|
19
|
+
mcp: "mcp";
|
|
20
|
+
}>;
|
|
21
|
+
type Surface = z.infer<typeof Surface>;
|
|
22
|
+
type JsonSchema = Record<string, unknown>;
|
|
23
|
+
/** A hit as users see it: `content` is for the model only. */
|
|
24
|
+
declare const PublicHit: z.ZodObject<{
|
|
25
|
+
type: z.ZodString;
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
29
|
+
url: z.ZodString;
|
|
30
|
+
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
type PublicHit = z.infer<typeof PublicHit>;
|
|
33
|
+
declare const FederatedSearchResponse: z.ZodObject<{
|
|
34
|
+
hits: z.ZodArray<z.ZodObject<{
|
|
35
|
+
type: z.ZodString;
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
39
|
+
url: z.ZodString;
|
|
40
|
+
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
41
|
+
source: z.ZodString;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
failed: z.ZodArray<z.ZodObject<{
|
|
44
|
+
source: z.ZodString;
|
|
45
|
+
code: z.ZodString;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
type FederatedSearchResponse = z.infer<typeof FederatedSearchResponse>;
|
|
49
|
+
/** An AG-UI event as rungent sends it: `metadata.rungent.seq` is always present. */
|
|
50
|
+
type RungentEvent = Event & {
|
|
51
|
+
metadata: {
|
|
52
|
+
rungent: {
|
|
53
|
+
seq: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare class RungentProtocolError extends Error {
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
interface ClientOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Where rungent is mounted: an origin, a path prefix (the host's `basePath`), or both, e.g.
|
|
63
|
+
* `https://console.example.com` or `/assistant`. The client adds `/rungent/v0` itself.
|
|
64
|
+
* Default `''`: the page's own origin.
|
|
65
|
+
*/
|
|
66
|
+
readonly baseUrl?: string;
|
|
67
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
68
|
+
/** Called before every request, e.g. to add the user's `Authorization`. */
|
|
69
|
+
readonly headers?: () => HeadersInit | Promise<HeadersInit>;
|
|
70
|
+
}
|
|
71
|
+
interface ThreadSummary {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly title: string | null;
|
|
74
|
+
readonly createdAt: string;
|
|
75
|
+
}
|
|
76
|
+
interface ThreadPage {
|
|
77
|
+
readonly items: ThreadSummary[];
|
|
78
|
+
readonly next?: string;
|
|
79
|
+
}
|
|
80
|
+
interface ThreadDetail extends ThreadSummary {
|
|
81
|
+
readonly messages: Message[];
|
|
82
|
+
readonly interrupts: Interrupt[];
|
|
83
|
+
}
|
|
84
|
+
/** `GET /info`: what the UI shows of this rungent instance. */
|
|
85
|
+
interface Info {
|
|
86
|
+
/** The assistant's display name (`createRungent({ name })`). */
|
|
87
|
+
readonly name: string;
|
|
88
|
+
}
|
|
89
|
+
interface CatalogOperation {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly title: string;
|
|
92
|
+
readonly effect: Effect;
|
|
93
|
+
readonly approval: Approval;
|
|
94
|
+
readonly surfaces: Surface[];
|
|
95
|
+
readonly input: JsonSchema;
|
|
96
|
+
}
|
|
97
|
+
/** How long a failing endpoint rests before it is tried again, by kind of failure. */
|
|
98
|
+
interface CooldownSeconds {
|
|
99
|
+
readonly quota?: number;
|
|
100
|
+
readonly rateLimit?: number;
|
|
101
|
+
readonly error?: number;
|
|
102
|
+
}
|
|
103
|
+
interface ModelEndpointFields {
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly provider: 'openai-compatible' | 'openai' | 'anthropic';
|
|
106
|
+
readonly model: string;
|
|
107
|
+
readonly baseURL?: string;
|
|
108
|
+
readonly vision?: boolean;
|
|
109
|
+
readonly temperature?: number;
|
|
110
|
+
readonly maxOutputTokens?: number;
|
|
111
|
+
readonly cooldownSeconds?: CooldownSeconds;
|
|
112
|
+
readonly providerOptions?: Record<string, unknown>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A model endpoint as `GET /settings` shows it: the key itself is never returned. A model the
|
|
116
|
+
* host configured in code shows as provider `custom`.
|
|
117
|
+
*/
|
|
118
|
+
interface ModelEndpointSettings extends Omit<ModelEndpointFields, 'provider'> {
|
|
119
|
+
readonly provider: ModelEndpointFields['provider'] | 'custom';
|
|
120
|
+
readonly hasApiKey: boolean;
|
|
121
|
+
}
|
|
122
|
+
/** A model endpoint in `PUT /settings`: an absent `apiKey` keeps the stored one. */
|
|
123
|
+
interface ModelEndpointUpdate extends ModelEndpointFields {
|
|
124
|
+
readonly apiKey?: string;
|
|
125
|
+
}
|
|
126
|
+
interface Settings {
|
|
127
|
+
readonly models: {
|
|
128
|
+
readonly chain: ModelEndpointSettings[];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
interface SettingsUpdate {
|
|
132
|
+
readonly models: {
|
|
133
|
+
readonly chain: ModelEndpointUpdate[];
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
interface RunRequest {
|
|
137
|
+
/** A new user message: text, or AG-UI content parts (text, images, documents). */
|
|
138
|
+
readonly message?: string | ContentPart$1[];
|
|
139
|
+
/** What the user is looking at, sent as AG-UI `context`; rungent adds it to this run's prompt. */
|
|
140
|
+
readonly context?: Context$1[];
|
|
141
|
+
/** Answers to the thread's open interrupts. */
|
|
142
|
+
readonly resume?: ResumeEntry$1[];
|
|
143
|
+
}
|
|
144
|
+
/** A run's events. The request is sent when iteration starts. */
|
|
145
|
+
interface RunStream extends AsyncIterable<RungentEvent> {
|
|
146
|
+
readonly runId: string;
|
|
147
|
+
/** The id given to `RunRequest.message`. */
|
|
148
|
+
readonly messageId?: string;
|
|
149
|
+
}
|
|
150
|
+
interface SearchOptions {
|
|
151
|
+
readonly limit?: number;
|
|
152
|
+
readonly types?: readonly string[];
|
|
153
|
+
readonly signal?: AbortSignal;
|
|
154
|
+
}
|
|
155
|
+
type FeedbackRating = 'up' | 'down';
|
|
156
|
+
interface Feedback {
|
|
157
|
+
readonly rating: FeedbackRating;
|
|
158
|
+
readonly comment?: string;
|
|
159
|
+
}
|
|
160
|
+
/** A user's rating of an assistant message, as `GET /feedback` lists it. */
|
|
161
|
+
interface FeedbackItem extends Feedback {
|
|
162
|
+
readonly threadId: string;
|
|
163
|
+
readonly messageId: string;
|
|
164
|
+
readonly subject: string;
|
|
165
|
+
readonly createdAt: string;
|
|
166
|
+
}
|
|
167
|
+
interface FeedbackPage {
|
|
168
|
+
readonly items: FeedbackItem[];
|
|
169
|
+
readonly next?: string;
|
|
170
|
+
}
|
|
171
|
+
interface FeedbackQuery {
|
|
172
|
+
/** Only feedback given at or after this RFC 3339 time. */
|
|
173
|
+
readonly since?: string;
|
|
174
|
+
readonly limit?: number;
|
|
175
|
+
/** The `next` of the previous page. */
|
|
176
|
+
readonly cursor?: string;
|
|
177
|
+
}
|
|
178
|
+
declare class RungentRequestError extends Error {
|
|
179
|
+
readonly status: number;
|
|
180
|
+
readonly body: unknown;
|
|
181
|
+
name: string;
|
|
182
|
+
constructor(status: number, body: unknown);
|
|
183
|
+
}
|
|
184
|
+
declare function createClient(options?: ClientOptions): {
|
|
185
|
+
/** `ClientOptions.baseUrl` without a trailing slash, e.g. to key what a UI remembers. */
|
|
186
|
+
baseUrl: string;
|
|
187
|
+
createThread(): Promise<ThreadSummary>;
|
|
188
|
+
listThreads(cursor?: string): Promise<ThreadPage>;
|
|
189
|
+
getThread(id: string): Promise<ThreadDetail>;
|
|
190
|
+
renameThread(id: string, title: string): Promise<void>;
|
|
191
|
+
deleteThread(id: string): Promise<void>;
|
|
192
|
+
/** Starts a run. Leaving the iteration early detaches from it; the run goes on. */
|
|
193
|
+
run(threadId: string, input: RunRequest, init?: {
|
|
194
|
+
signal?: AbortSignal;
|
|
195
|
+
}): RunStream;
|
|
196
|
+
/**
|
|
197
|
+
* Replays the thread's events after `after`, then follows them live. It reconnects with
|
|
198
|
+
* `Last-Event-ID` and exponential backoff until `signal` aborts, never yielding a seq twice.
|
|
199
|
+
*/
|
|
200
|
+
follow(threadId: string, init: {
|
|
201
|
+
after: number;
|
|
202
|
+
signal?: AbortSignal;
|
|
203
|
+
}): AsyncGenerator<RungentEvent>;
|
|
204
|
+
cancel(runId: string): Promise<void>;
|
|
205
|
+
info(): Promise<Info>;
|
|
206
|
+
catalog(): Promise<CatalogOperation[]>;
|
|
207
|
+
search(query: string, init?: SearchOptions): Promise<FederatedSearchResponse>;
|
|
208
|
+
getSettings(): Promise<Settings>;
|
|
209
|
+
putSettings(settings: SettingsUpdate): Promise<Settings>;
|
|
210
|
+
/** Forgets the saved settings; the configured defaults apply again. Needs `rungent:admin`. */
|
|
211
|
+
resetSettings(): Promise<Settings>;
|
|
212
|
+
/** Rates an assistant message; a later rating of the same message replaces it. */
|
|
213
|
+
setFeedback(threadId: string, messageId: string, feedback: Feedback): Promise<FeedbackItem>;
|
|
214
|
+
/** Every user's feedback, oldest first; needs `rungent:admin`. */
|
|
215
|
+
listFeedback(query?: FeedbackQuery): Promise<FeedbackPage>;
|
|
216
|
+
};
|
|
217
|
+
type RungentClient = ReturnType<typeof createClient>;
|
|
218
|
+
/**
|
|
219
|
+
* `TOOL_CALL_START.metadata.rungent`: the call's operation, beside the event's `seq` (which a
|
|
220
|
+
* reader may have taken out already). Built-in tools (`search`, `request_input`) use their own
|
|
221
|
+
* name as op.
|
|
222
|
+
*/
|
|
223
|
+
declare const ToolCallMeta: z.ZodObject<{
|
|
224
|
+
seq: z.ZodOptional<z.ZodInt>;
|
|
225
|
+
op: z.ZodString;
|
|
226
|
+
title: z.ZodString;
|
|
227
|
+
effect: z.ZodEnum<{
|
|
228
|
+
create: "create";
|
|
229
|
+
delete: "delete";
|
|
230
|
+
external: "external";
|
|
231
|
+
read: "read";
|
|
232
|
+
update: "update";
|
|
233
|
+
}>;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
type ToolCallMeta = z.infer<typeof ToolCallMeta>;
|
|
236
|
+
/** `Interrupt.metadata.rungent` for `rungent:approval`. */
|
|
237
|
+
declare const ApprovalInterruptMeta: z.ZodObject<{
|
|
238
|
+
op: z.ZodString;
|
|
239
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
240
|
+
argsHash: z.ZodString;
|
|
241
|
+
impact: z.ZodObject<{
|
|
242
|
+
title: z.ZodString;
|
|
243
|
+
target: z.ZodNullable<z.ZodString>;
|
|
244
|
+
effect: z.ZodEnum<{
|
|
245
|
+
create: "create";
|
|
246
|
+
delete: "delete";
|
|
247
|
+
external: "external";
|
|
248
|
+
read: "read";
|
|
249
|
+
update: "update";
|
|
250
|
+
}>;
|
|
251
|
+
risk: z.ZodNullable<z.ZodEnum<{
|
|
252
|
+
high: "high";
|
|
253
|
+
low: "low";
|
|
254
|
+
medium: "medium";
|
|
255
|
+
}>>;
|
|
256
|
+
costHint: z.ZodNullable<z.ZodString>;
|
|
257
|
+
changes: z.ZodArray<z.ZodString>;
|
|
258
|
+
}, z.core.$strict>;
|
|
259
|
+
}, z.core.$strict>;
|
|
260
|
+
type ApprovalInterruptMeta = z.infer<typeof ApprovalInterruptMeta>;
|
|
261
|
+
declare const Form: z.ZodObject<{
|
|
262
|
+
prompt: z.ZodString;
|
|
263
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
264
|
+
id: z.ZodString;
|
|
265
|
+
prompt: z.ZodString;
|
|
266
|
+
kind: z.ZodLiteral<"text">;
|
|
267
|
+
required: z.ZodBoolean;
|
|
268
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
269
|
+
default: z.ZodOptional<z.ZodString>;
|
|
270
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
prompt: z.ZodString;
|
|
273
|
+
kind: z.ZodLiteral<"choice">;
|
|
274
|
+
required: z.ZodBoolean;
|
|
275
|
+
options: z.ZodArray<z.ZodObject<{
|
|
276
|
+
id: z.ZodString;
|
|
277
|
+
label: z.ZodString;
|
|
278
|
+
description: z.ZodOptional<z.ZodString>;
|
|
279
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
280
|
+
}, z.core.$strict>>;
|
|
281
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
282
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
283
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
284
|
+
}, z.core.$strict>], "kind">>;
|
|
285
|
+
}, z.core.$strict>;
|
|
286
|
+
type Form = z.infer<typeof Form>;
|
|
287
|
+
declare const FormAnswers: z.ZodObject<{
|
|
288
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
289
|
+
selected: z.ZodArray<z.ZodString>;
|
|
290
|
+
custom: z.ZodOptional<z.ZodString>;
|
|
291
|
+
}, z.core.$strict>]>>;
|
|
292
|
+
}, z.core.$strict>;
|
|
293
|
+
type FormAnswers = z.infer<typeof FormAnswers>;
|
|
294
|
+
/** A problem with one argument of a submitted host form, by its dotted path. */
|
|
295
|
+
declare const FormIssue: z.ZodObject<{
|
|
296
|
+
path: z.ZodString;
|
|
297
|
+
message: z.ZodString;
|
|
298
|
+
}, z.core.$strict>;
|
|
299
|
+
type FormIssue = z.infer<typeof FormIssue>;
|
|
300
|
+
/**
|
|
301
|
+
* `Interrupt.metadata.rungent` for `rungent:form`: the host form of an operation. `arguments` are the
|
|
302
|
+
* call's arguments so far, which the form starts from; `form` is the host's generic form, for a
|
|
303
|
+
* client that has no form of its own for `op`; `issues` explain why a submission was refused.
|
|
304
|
+
*/
|
|
305
|
+
declare const FormInterruptMeta: z.ZodObject<{
|
|
306
|
+
op: z.ZodString;
|
|
307
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
308
|
+
form: z.ZodObject<{
|
|
309
|
+
prompt: z.ZodString;
|
|
310
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
prompt: z.ZodString;
|
|
313
|
+
kind: z.ZodLiteral<"text">;
|
|
314
|
+
required: z.ZodBoolean;
|
|
315
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
316
|
+
default: z.ZodOptional<z.ZodString>;
|
|
317
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
318
|
+
id: z.ZodString;
|
|
319
|
+
prompt: z.ZodString;
|
|
320
|
+
kind: z.ZodLiteral<"choice">;
|
|
321
|
+
required: z.ZodBoolean;
|
|
322
|
+
options: z.ZodArray<z.ZodObject<{
|
|
323
|
+
id: z.ZodString;
|
|
324
|
+
label: z.ZodString;
|
|
325
|
+
description: z.ZodOptional<z.ZodString>;
|
|
326
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
327
|
+
}, z.core.$strict>>;
|
|
328
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
329
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
330
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
331
|
+
}, z.core.$strict>], "kind">>;
|
|
332
|
+
}, z.core.$strict>;
|
|
333
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
334
|
+
path: z.ZodString;
|
|
335
|
+
message: z.ZodString;
|
|
336
|
+
}, z.core.$strict>>>;
|
|
337
|
+
}, z.core.$strict>;
|
|
338
|
+
type FormInterruptMeta = z.infer<typeof FormInterruptMeta>;
|
|
339
|
+
declare const CustomEvents: {
|
|
340
|
+
readonly 'rungent.ui.open': z.ZodObject<{
|
|
341
|
+
path: z.ZodString;
|
|
342
|
+
}, z.core.$strict>;
|
|
343
|
+
readonly 'rungent.citation': z.ZodObject<{
|
|
344
|
+
messageId: z.ZodString;
|
|
345
|
+
citations: z.ZodArray<z.ZodObject<{
|
|
346
|
+
n: z.ZodInt;
|
|
347
|
+
hit: z.ZodObject<{
|
|
348
|
+
type: z.ZodString;
|
|
349
|
+
id: z.ZodString;
|
|
350
|
+
title: z.ZodString;
|
|
351
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
352
|
+
url: z.ZodString;
|
|
353
|
+
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
354
|
+
}, z.core.$strict>;
|
|
355
|
+
}, z.core.$strict>>;
|
|
356
|
+
}, z.core.$strict>;
|
|
357
|
+
readonly 'rungent.context': z.ZodObject<{
|
|
358
|
+
usedTokens: z.ZodInt;
|
|
359
|
+
budgetTokens: z.ZodInt;
|
|
360
|
+
source: z.ZodEnum<{
|
|
361
|
+
estimated: "estimated";
|
|
362
|
+
provider: "provider";
|
|
363
|
+
}>;
|
|
364
|
+
}, z.core.$strict>;
|
|
365
|
+
readonly 'rungent.model.retry': z.ZodObject<{
|
|
366
|
+
step: z.ZodInt;
|
|
367
|
+
attempt: z.ZodInt;
|
|
368
|
+
maxAttempts: z.ZodInt;
|
|
369
|
+
reason: z.ZodString;
|
|
370
|
+
endpoint: z.ZodString;
|
|
371
|
+
fallback: z.ZodBoolean;
|
|
372
|
+
}, z.core.$strict>;
|
|
373
|
+
readonly 'rungent.message.discard': z.ZodObject<{
|
|
374
|
+
messageId: z.ZodString;
|
|
375
|
+
}, z.core.$strict>;
|
|
376
|
+
readonly 'rungent.task': z.ZodObject<{
|
|
377
|
+
taskId: z.ZodString;
|
|
378
|
+
status: z.ZodEnum<{
|
|
379
|
+
cancelled: "cancelled";
|
|
380
|
+
failed: "failed";
|
|
381
|
+
running: "running";
|
|
382
|
+
succeeded: "succeeded";
|
|
383
|
+
}>;
|
|
384
|
+
message: z.ZodOptional<z.ZodString>;
|
|
385
|
+
}, z.core.$strict>;
|
|
386
|
+
};
|
|
387
|
+
type CustomEventName = keyof typeof CustomEvents;
|
|
388
|
+
type CustomEventValue<N extends CustomEventName> = z.infer<(typeof CustomEvents)[N]>;
|
|
389
|
+
/** A hit an answer cites as `[n]`. */
|
|
390
|
+
interface Citation {
|
|
391
|
+
readonly n: number;
|
|
392
|
+
readonly hit: PublicHit;
|
|
393
|
+
}
|
|
394
|
+
/** An image or file a user message carries. */
|
|
395
|
+
interface Attachment {
|
|
396
|
+
readonly kind: 'image' | 'file';
|
|
397
|
+
/** A URL to show or download it by: a product path, an absolute URL, or a `data:` URL. */
|
|
398
|
+
readonly url: string;
|
|
399
|
+
readonly mimeType?: string;
|
|
400
|
+
readonly name?: string;
|
|
401
|
+
}
|
|
402
|
+
interface UserItem {
|
|
403
|
+
readonly kind: 'user';
|
|
404
|
+
readonly id: string;
|
|
405
|
+
readonly text: string;
|
|
406
|
+
readonly attachments: readonly Attachment[];
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* When an item started and ended, in epoch milliseconds from the events' `timestamp` (the
|
|
410
|
+
* server's clock); null where an event carried none, and `endedAt` while it goes on.
|
|
411
|
+
*/
|
|
412
|
+
interface Timed {
|
|
413
|
+
readonly startedAt: number | null;
|
|
414
|
+
readonly endedAt: number | null;
|
|
415
|
+
}
|
|
416
|
+
interface AssistantItem extends Timed {
|
|
417
|
+
readonly kind: 'assistant';
|
|
418
|
+
readonly id: string;
|
|
419
|
+
readonly text: string;
|
|
420
|
+
readonly streaming: boolean;
|
|
421
|
+
}
|
|
422
|
+
/** The model's reasoning (AG-UI `REASONING_MESSAGE_*`), where the server sends it. */
|
|
423
|
+
interface ReasoningItem extends Timed {
|
|
424
|
+
readonly kind: 'reasoning';
|
|
425
|
+
readonly id: string;
|
|
426
|
+
readonly text: string;
|
|
427
|
+
readonly streaming: boolean;
|
|
428
|
+
}
|
|
429
|
+
interface ToolItem extends Timed {
|
|
430
|
+
readonly kind: 'tool';
|
|
431
|
+
/** The tool call id. */
|
|
432
|
+
readonly id: string;
|
|
433
|
+
readonly name: string;
|
|
434
|
+
/** From `TOOL_CALL_START.metadata.rungent`; null when the runtime sent none. */
|
|
435
|
+
readonly meta: ToolCallMeta | null;
|
|
436
|
+
/** The redacted arguments, once they arrived and parse as a JSON object. */
|
|
437
|
+
readonly arguments: Record<string, unknown> | null;
|
|
438
|
+
readonly status: 'running' | 'succeeded' | 'failed';
|
|
439
|
+
readonly error: {
|
|
440
|
+
readonly code: string;
|
|
441
|
+
readonly message: string;
|
|
442
|
+
} | null;
|
|
443
|
+
readonly deduplicated: boolean;
|
|
444
|
+
/** The redacted JSON result. */
|
|
445
|
+
readonly result: string | null;
|
|
446
|
+
}
|
|
447
|
+
interface ProgressItem {
|
|
448
|
+
readonly kind: 'progress';
|
|
449
|
+
readonly id: string;
|
|
450
|
+
readonly message: string;
|
|
451
|
+
/** When the progress was first reported, as `Timed.startedAt`. */
|
|
452
|
+
readonly startedAt: number | null;
|
|
453
|
+
}
|
|
454
|
+
type ThreadItem = UserItem | AssistantItem | ReasoningItem | ToolItem | ProgressItem;
|
|
455
|
+
interface InterruptBase {
|
|
456
|
+
readonly id: string;
|
|
457
|
+
readonly interrupt: Interrupt;
|
|
458
|
+
}
|
|
459
|
+
interface ApprovalInterrupt extends InterruptBase {
|
|
460
|
+
readonly kind: 'approval';
|
|
461
|
+
readonly meta: ApprovalInterruptMeta;
|
|
462
|
+
}
|
|
463
|
+
interface InputInterrupt extends InterruptBase {
|
|
464
|
+
readonly kind: 'input';
|
|
465
|
+
readonly form: Form;
|
|
466
|
+
}
|
|
467
|
+
/** An operation's host form: the operation, the arguments it starts from, the generic form. */
|
|
468
|
+
interface FormInterrupt extends InterruptBase {
|
|
469
|
+
readonly kind: 'form';
|
|
470
|
+
readonly meta: FormInterruptMeta;
|
|
471
|
+
}
|
|
472
|
+
interface TaskInterrupt extends InterruptBase {
|
|
473
|
+
readonly kind: 'task';
|
|
474
|
+
readonly taskId: string;
|
|
475
|
+
readonly op: string;
|
|
476
|
+
/** The latest `rungent.task` progress. */
|
|
477
|
+
readonly progress: CustomEventValue<'rungent.task'> | null;
|
|
478
|
+
}
|
|
479
|
+
/** An interrupt rungent's profile does not describe; it can only be cancelled. */
|
|
480
|
+
interface OtherInterrupt extends InterruptBase {
|
|
481
|
+
readonly kind: 'other';
|
|
482
|
+
}
|
|
483
|
+
type OpenInterrupt = ApprovalInterrupt | InputInterrupt | FormInterrupt | TaskInterrupt | OtherInterrupt;
|
|
484
|
+
type RunStatus = 'idle' | 'running' | 'interrupted' | 'succeeded' | 'cancelled' | 'failed';
|
|
485
|
+
interface ThreadState {
|
|
486
|
+
/** The highest seq applied; events at or below it are ignored. */
|
|
487
|
+
readonly lastSeq: number;
|
|
488
|
+
readonly status: RunStatus;
|
|
489
|
+
readonly runId: string | null;
|
|
490
|
+
readonly items: readonly ThreadItem[];
|
|
491
|
+
readonly interrupts: readonly OpenInterrupt[];
|
|
492
|
+
/** The hits each assistant message cites, by message id: each under the `n` of its `[n]`. */
|
|
493
|
+
readonly citations: Readonly<Record<string, readonly Citation[]>>;
|
|
494
|
+
/** Product pages the runs asked to show (`rungent.ui.open`), with the seq that asked. */
|
|
495
|
+
readonly opens: readonly {
|
|
496
|
+
readonly seq: number;
|
|
497
|
+
readonly path: string;
|
|
498
|
+
}[];
|
|
499
|
+
readonly context: CustomEventValue<'rungent.context'> | null;
|
|
500
|
+
/** The model retry in progress, cleared when text arrives or the run ends. */
|
|
501
|
+
readonly retry: CustomEventValue<'rungent.model.retry'> | null;
|
|
502
|
+
readonly error: {
|
|
503
|
+
readonly code: string | null;
|
|
504
|
+
readonly message: string;
|
|
505
|
+
} | null;
|
|
506
|
+
readonly usage: readonly TokenUsage[];
|
|
507
|
+
}
|
|
508
|
+
declare const initialThreadState: ThreadState;
|
|
509
|
+
/** The images and documents of a message's content, as attachments. */
|
|
510
|
+
declare function attachmentsOf(content: string | ContentPart$1[]): Attachment[];
|
|
511
|
+
/**
|
|
512
|
+
* The content part of an uploaded file: an image part for `image/*`, otherwise a document
|
|
513
|
+
* part. The file name travels in `metadata.rungent.name`.
|
|
514
|
+
*/
|
|
515
|
+
declare function attachmentPart(file: {
|
|
516
|
+
readonly url: string;
|
|
517
|
+
readonly mimeType: string;
|
|
518
|
+
readonly name?: string;
|
|
519
|
+
}): ContentPart$1;
|
|
520
|
+
/** Reads an AG-UI interrupt as one of rungent's kinds. */
|
|
521
|
+
declare function openInterrupt(interrupt: Interrupt): OpenInterrupt;
|
|
522
|
+
/** Applies one event. Pure; an event at or below `lastSeq` (a replay) changes nothing. */
|
|
523
|
+
declare function reduceThread(state: ThreadState, event: RungentEvent): ThreadState;
|
|
524
|
+
/** Shows a message the user just sent before the run echoes it; the echo is then ignored. */
|
|
525
|
+
declare function appendUserMessage(state: ThreadState, message: UserItem): ThreadState;
|
|
526
|
+
/** Answers an approval, echoing the `argsHash` the user saw so rungent runs exactly those arguments. */
|
|
527
|
+
declare function answerApproval(interrupt: ApprovalInterrupt, approved: boolean): ResumeEntry$1;
|
|
528
|
+
/** Answers `request_input`. Throws when the answers fail `checkAnswers`. */
|
|
529
|
+
declare function answerInput(interrupt: InputInterrupt, answers: FormAnswers['answers']): ResumeEntry$1;
|
|
530
|
+
/** Submits a host form with the operation's complete arguments, as the host's own form made them. */
|
|
531
|
+
declare function submitForm(interrupt: FormInterrupt, args: Record<string, unknown>): ResumeEntry$1;
|
|
532
|
+
/**
|
|
533
|
+
* Submits a host form from the answers to its generic questions, set over the arguments it
|
|
534
|
+
* started from. Throws when the answers fail `checkAnswers`.
|
|
535
|
+
*/
|
|
536
|
+
declare function submitFormAnswers(interrupt: FormInterrupt, answers: FormAnswers['answers']): ResumeEntry$1;
|
|
537
|
+
/** Cancels every open interrupt, as a new user message must. */
|
|
538
|
+
declare function cancelAll(interrupts: readonly OpenInterrupt[]): ResumeEntry$1[];
|
|
539
|
+
export { ThreadDetail as $, openInterrupt as A, FeedbackPage as B, Timed as C, attachmentPart as D, appendUserMessage as E, CatalogOperation as F, ModelEndpointUpdate as G, FeedbackRating as H, ClientOptions as I, RungentClient as J, RunRequest as K, CooldownSeconds as L, Form as M, FormAnswers as N, attachmentsOf as O, FormIssue as P, SettingsUpdate as Q, Feedback as R, ThreadState as S, UserItem as T, Info as U, FeedbackQuery as V, ModelEndpointSettings as W, SearchOptions as X, RungentRequestError as Y, Settings as Z, ProgressItem as _, answerInput as a, FederatedSearchResponse as at, TaskInterrupt as b, submitFormAnswers as c, Attachment as d, ThreadPage as et, Citation as f, OtherInterrupt as g, OpenInterrupt as h, answerApproval as i, RungentProtocolError as it, reduceThread as j, initialThreadState as k, ApprovalInterrupt as l, InputInterrupt as m, Context as n, createClient as nt, cancelAll as o, FormInterrupt as p, RunStream as q, ResumeEntry as r, RungentEvent as rt, submitForm as s, ContentPart as t, ThreadSummary as tt, AssistantItem as u, ReasoningItem as v, ToolItem as w, ThreadItem as x, RunStatus as y, FeedbackItem as z };
|