@rungent/react 0.6.0 → 0.7.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.
- package/dist/{client-BxNE_rPk.js → client-mUY72akp.js} +26 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/{index-B2fKzvt5.d.ts → index-BuUWmx0G.d.ts} +194 -173
- package/dist/index.d.ts +8 -1
- package/dist/index.js +209 -20
- package/dist/styles.css +53 -1
- package/package.json +1 -1
|
@@ -422,6 +422,30 @@ z.strictObject({
|
|
|
422
422
|
description: z.string().max(200),
|
|
423
423
|
value: z.string()
|
|
424
424
|
});
|
|
425
|
+
z.strictObject({
|
|
426
|
+
/** The assistant's display name. */
|
|
427
|
+
name: z.string(),
|
|
428
|
+
/** Some model of the chain in effect declares `thinking`, so a user may switch it on. */
|
|
429
|
+
thinking: z.boolean()
|
|
430
|
+
}).meta({
|
|
431
|
+
id: "info",
|
|
432
|
+
title: "Info"
|
|
433
|
+
});
|
|
434
|
+
z.strictObject({
|
|
435
|
+
/** Let models that declare `thinking` reason before they answer. Default false. */
|
|
436
|
+
thinking: z.boolean().optional() }).meta({
|
|
437
|
+
id: "run-options",
|
|
438
|
+
title: "Run options"
|
|
439
|
+
});
|
|
440
|
+
/** Options passed to a model's provider, keyed by provider name (the AI SDK's `providerOptions`). */
|
|
441
|
+
const ProviderOptions = z.record(z.string(), z.record(z.string(), z.unknown()));
|
|
442
|
+
z.strictObject({
|
|
443
|
+
on: ProviderOptions,
|
|
444
|
+
off: ProviderOptions
|
|
445
|
+
}).meta({
|
|
446
|
+
id: "model-thinking",
|
|
447
|
+
title: "Model thinking"
|
|
448
|
+
});
|
|
425
449
|
z.strictObject({
|
|
426
450
|
instructions: z.string().max(2e4).optional(),
|
|
427
451
|
input: z.string().min(1).max(2e5),
|
|
@@ -619,7 +643,8 @@ function createClient(options = {}) {
|
|
|
619
643
|
}],
|
|
620
644
|
tools: [],
|
|
621
645
|
context: input.context ?? [],
|
|
622
|
-
...input.resume ? { resume: input.resume } : {}
|
|
646
|
+
...input.resume ? { resume: input.resume } : {},
|
|
647
|
+
...input.thinking ? { forwardedProps: { rungent: { thinking: true } } } : {}
|
|
623
648
|
};
|
|
624
649
|
return {
|
|
625
650
|
runId,
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
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 };
|
|
1
|
+
import { $ as createClient, A as openInterrupt, B as Info, C as Timed, D as attachmentPart, E as appendUserMessage, F as Feedback, G as RungentClient, H as ModelEndpointUpdate, I as FeedbackItem, J as Settings, K as RungentRequestError, L as FeedbackPage, M as CatalogOperation, N as ClientOptions, O as attachmentsOf, P as CooldownSeconds, Q as ThreadSummary, R as FeedbackQuery, S as ThreadState, T as UserItem, U as RunRequest, V as ModelEndpointSettings, W as RunStream, X as ThreadDetail, Y as SettingsUpdate, Z as ThreadPage, _ as ProgressItem, a as answerInput, b as TaskInterrupt, c as submitFormAnswers, d as Attachment, et as RungentEvent, f as Citation, g as OtherInterrupt, h as OpenInterrupt, i as answerApproval, j as reduceThread, k as initialThreadState, l as ApprovalInterrupt, m as InputInterrupt, n as Context, o as cancelAll, ot as ModelThinking, p as FormInterrupt, q as SearchOptions, r as ResumeEntry, s as submitForm, st as ProviderOptions, t as ContentPart, tt as RungentProtocolError, u as AssistantItem, v as ReasoningItem, w as ToolItem, x as ThreadItem, y as RunStatus, z as FeedbackRating } from "./index-BuUWmx0G.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 ModelThinking, type OpenInterrupt, type OtherInterrupt, type ProgressItem, type ProviderOptions, 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
CHANGED
|
@@ -1 +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-
|
|
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-mUY72akp.js";
|
|
@@ -1,5 +1,188 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
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
|
+
/**
|
|
4
|
+
* `TOOL_CALL_START.metadata.rungent`: the call's operation, beside the event's `seq` (which a
|
|
5
|
+
* reader may have taken out already). Built-in tools (`search`, `request_input`) use their own
|
|
6
|
+
* name as op.
|
|
7
|
+
*/
|
|
8
|
+
declare const ToolCallMeta: z.ZodObject<{
|
|
9
|
+
seq: z.ZodOptional<z.ZodInt>;
|
|
10
|
+
op: z.ZodString;
|
|
11
|
+
title: z.ZodString;
|
|
12
|
+
effect: z.ZodEnum<{
|
|
13
|
+
create: "create";
|
|
14
|
+
delete: "delete";
|
|
15
|
+
external: "external";
|
|
16
|
+
read: "read";
|
|
17
|
+
update: "update";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
type ToolCallMeta = z.infer<typeof ToolCallMeta>;
|
|
21
|
+
/** `Interrupt.metadata.rungent` for `rungent:approval`. */
|
|
22
|
+
declare const ApprovalInterruptMeta: z.ZodObject<{
|
|
23
|
+
op: z.ZodString;
|
|
24
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
25
|
+
argsHash: z.ZodString;
|
|
26
|
+
impact: z.ZodObject<{
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
target: z.ZodNullable<z.ZodString>;
|
|
29
|
+
effect: z.ZodEnum<{
|
|
30
|
+
create: "create";
|
|
31
|
+
delete: "delete";
|
|
32
|
+
external: "external";
|
|
33
|
+
read: "read";
|
|
34
|
+
update: "update";
|
|
35
|
+
}>;
|
|
36
|
+
risk: z.ZodNullable<z.ZodEnum<{
|
|
37
|
+
high: "high";
|
|
38
|
+
low: "low";
|
|
39
|
+
medium: "medium";
|
|
40
|
+
}>>;
|
|
41
|
+
costHint: z.ZodNullable<z.ZodString>;
|
|
42
|
+
changes: z.ZodArray<z.ZodString>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
type ApprovalInterruptMeta = z.infer<typeof ApprovalInterruptMeta>;
|
|
46
|
+
declare const Form: z.ZodObject<{
|
|
47
|
+
prompt: z.ZodString;
|
|
48
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
prompt: z.ZodString;
|
|
51
|
+
kind: z.ZodLiteral<"text">;
|
|
52
|
+
required: z.ZodBoolean;
|
|
53
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
54
|
+
default: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
prompt: z.ZodString;
|
|
58
|
+
kind: z.ZodLiteral<"choice">;
|
|
59
|
+
required: z.ZodBoolean;
|
|
60
|
+
options: z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
label: z.ZodString;
|
|
63
|
+
description: z.ZodOptional<z.ZodString>;
|
|
64
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
69
|
+
}, z.core.$strict>], "kind">>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
type Form = z.infer<typeof Form>;
|
|
72
|
+
declare const FormAnswers: z.ZodObject<{
|
|
73
|
+
answers: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
74
|
+
selected: z.ZodArray<z.ZodString>;
|
|
75
|
+
custom: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strict>]>>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
type FormAnswers = z.infer<typeof FormAnswers>;
|
|
79
|
+
/** A problem with one argument of a submitted host form, by its dotted path. */
|
|
80
|
+
declare const FormIssue: z.ZodObject<{
|
|
81
|
+
path: z.ZodString;
|
|
82
|
+
message: z.ZodString;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
type FormIssue = z.infer<typeof FormIssue>;
|
|
85
|
+
/**
|
|
86
|
+
* `Interrupt.metadata.rungent` for `rungent:form`: the host form of an operation. `arguments` are the
|
|
87
|
+
* call's arguments so far, which the form starts from; `form` is the host's generic form, for a
|
|
88
|
+
* client that has no form of its own for `op`; `issues` explain why a submission was refused.
|
|
89
|
+
*/
|
|
90
|
+
declare const FormInterruptMeta: z.ZodObject<{
|
|
91
|
+
op: z.ZodString;
|
|
92
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
93
|
+
form: z.ZodObject<{
|
|
94
|
+
prompt: z.ZodString;
|
|
95
|
+
questions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
prompt: z.ZodString;
|
|
98
|
+
kind: z.ZodLiteral<"text">;
|
|
99
|
+
required: z.ZodBoolean;
|
|
100
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
101
|
+
default: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
103
|
+
id: z.ZodString;
|
|
104
|
+
prompt: z.ZodString;
|
|
105
|
+
kind: z.ZodLiteral<"choice">;
|
|
106
|
+
required: z.ZodBoolean;
|
|
107
|
+
options: z.ZodArray<z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
label: z.ZodString;
|
|
110
|
+
description: z.ZodOptional<z.ZodString>;
|
|
111
|
+
recommended: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
multiple: z.ZodOptional<z.ZodBoolean>;
|
|
114
|
+
allowCustom: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
116
|
+
}, z.core.$strict>], "kind">>;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
119
|
+
path: z.ZodString;
|
|
120
|
+
message: z.ZodString;
|
|
121
|
+
}, z.core.$strict>>>;
|
|
122
|
+
}, z.core.$strict>;
|
|
123
|
+
type FormInterruptMeta = z.infer<typeof FormInterruptMeta>;
|
|
124
|
+
declare const CustomEvents: {
|
|
125
|
+
readonly 'rungent.ui.open': z.ZodObject<{
|
|
126
|
+
path: z.ZodString;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
readonly 'rungent.citation': z.ZodObject<{
|
|
129
|
+
messageId: z.ZodString;
|
|
130
|
+
citations: z.ZodArray<z.ZodObject<{
|
|
131
|
+
n: z.ZodInt;
|
|
132
|
+
hit: z.ZodObject<{
|
|
133
|
+
type: z.ZodString;
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
title: z.ZodString;
|
|
136
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
137
|
+
url: z.ZodString;
|
|
138
|
+
updatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
139
|
+
}, z.core.$strict>;
|
|
140
|
+
}, z.core.$strict>>;
|
|
141
|
+
}, z.core.$strict>;
|
|
142
|
+
readonly 'rungent.context': z.ZodObject<{
|
|
143
|
+
usedTokens: z.ZodInt;
|
|
144
|
+
budgetTokens: z.ZodInt;
|
|
145
|
+
source: z.ZodEnum<{
|
|
146
|
+
estimated: "estimated";
|
|
147
|
+
provider: "provider";
|
|
148
|
+
}>;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
readonly 'rungent.model.retry': z.ZodObject<{
|
|
151
|
+
step: z.ZodInt;
|
|
152
|
+
attempt: z.ZodInt;
|
|
153
|
+
maxAttempts: z.ZodInt;
|
|
154
|
+
reason: z.ZodString;
|
|
155
|
+
endpoint: z.ZodString;
|
|
156
|
+
fallback: z.ZodBoolean;
|
|
157
|
+
}, z.core.$strict>;
|
|
158
|
+
readonly 'rungent.message.discard': z.ZodObject<{
|
|
159
|
+
messageId: z.ZodString;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
readonly 'rungent.task': z.ZodObject<{
|
|
162
|
+
taskId: z.ZodString;
|
|
163
|
+
status: z.ZodEnum<{
|
|
164
|
+
cancelled: "cancelled";
|
|
165
|
+
failed: "failed";
|
|
166
|
+
running: "running";
|
|
167
|
+
succeeded: "succeeded";
|
|
168
|
+
}>;
|
|
169
|
+
message: z.ZodOptional<z.ZodString>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
};
|
|
172
|
+
type CustomEventName = keyof typeof CustomEvents;
|
|
173
|
+
type CustomEventValue<N extends CustomEventName> = z.infer<(typeof CustomEvents)[N]>;
|
|
174
|
+
/** Options passed to a model's provider, keyed by provider name (the AI SDK's `providerOptions`). */
|
|
175
|
+
declare const ProviderOptions: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
176
|
+
type ProviderOptions = z.infer<typeof ProviderOptions>;
|
|
177
|
+
/**
|
|
178
|
+
* A model's thinking switch: the provider options that turn its reasoning on and off. The one a
|
|
179
|
+
* call uses is merged over the model's own `providerOptions`, per provider.
|
|
180
|
+
*/
|
|
181
|
+
declare const ModelThinking: z.ZodObject<{
|
|
182
|
+
on: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
183
|
+
off: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
184
|
+
}, z.core.$strict>;
|
|
185
|
+
type ModelThinking = z.infer<typeof ModelThinking>;
|
|
3
186
|
declare const Effect: z.ZodEnum<{
|
|
4
187
|
create: "create";
|
|
5
188
|
delete: "delete";
|
|
@@ -85,6 +268,8 @@ interface ThreadDetail extends ThreadSummary {
|
|
|
85
268
|
interface Info {
|
|
86
269
|
/** The assistant's display name (`createRungent({ name })`). */
|
|
87
270
|
readonly name: string;
|
|
271
|
+
/** A model of the chain declares `thinking`: the user may switch it on for a run. */
|
|
272
|
+
readonly thinking: boolean;
|
|
88
273
|
}
|
|
89
274
|
interface CatalogOperation {
|
|
90
275
|
readonly name: string;
|
|
@@ -109,7 +294,9 @@ interface ModelEndpointFields {
|
|
|
109
294
|
readonly temperature?: number;
|
|
110
295
|
readonly maxOutputTokens?: number;
|
|
111
296
|
readonly cooldownSeconds?: CooldownSeconds;
|
|
112
|
-
readonly providerOptions?:
|
|
297
|
+
readonly providerOptions?: ProviderOptions;
|
|
298
|
+
/** Provider options that switch the model's reasoning on and off, merged over `providerOptions`. */
|
|
299
|
+
readonly thinking?: ModelThinking;
|
|
113
300
|
}
|
|
114
301
|
/**
|
|
115
302
|
* A model endpoint as `GET /settings` shows it: the key itself is never returned. A model the
|
|
@@ -140,6 +327,11 @@ interface RunRequest {
|
|
|
140
327
|
readonly context?: Context$1[];
|
|
141
328
|
/** Answers to the thread's open interrupts. */
|
|
142
329
|
readonly resume?: ResumeEntry$1[];
|
|
330
|
+
/**
|
|
331
|
+
* Let models that declare `thinking` reason before they answer, sent as
|
|
332
|
+
* `forwardedProps.rungent.thinking`. Default false.
|
|
333
|
+
*/
|
|
334
|
+
readonly thinking?: boolean;
|
|
143
335
|
}
|
|
144
336
|
/** A run's events. The request is sent when iteration starts. */
|
|
145
337
|
interface RunStream extends AsyncIterable<RungentEvent> {
|
|
@@ -215,177 +407,6 @@ declare function createClient(options?: ClientOptions): {
|
|
|
215
407
|
listFeedback(query?: FeedbackQuery): Promise<FeedbackPage>;
|
|
216
408
|
};
|
|
217
409
|
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
410
|
/** A hit an answer cites as `[n]`. */
|
|
390
411
|
interface Citation {
|
|
391
412
|
readonly n: number;
|
|
@@ -536,4 +557,4 @@ declare function submitForm(interrupt: FormInterrupt, args: Record<string, unkno
|
|
|
536
557
|
declare function submitFormAnswers(interrupt: FormInterrupt, answers: FormAnswers['answers']): ResumeEntry$1;
|
|
537
558
|
/** Cancels every open interrupt, as a new user message must. */
|
|
538
559
|
declare function cancelAll(interrupts: readonly OpenInterrupt[]): ResumeEntry$1[];
|
|
539
|
-
export {
|
|
560
|
+
export { createClient as $, openInterrupt as A, Info as B, Timed as C, attachmentPart as D, appendUserMessage as E, Feedback as F, RungentClient as G, ModelEndpointUpdate as H, FeedbackItem as I, Settings as J, RungentRequestError as K, FeedbackPage as L, CatalogOperation as M, ClientOptions as N, attachmentsOf as O, CooldownSeconds as P, ThreadSummary as Q, FeedbackQuery as R, ThreadState as S, UserItem as T, RunRequest as U, ModelEndpointSettings as V, RunStream as W, ThreadDetail as X, SettingsUpdate as Y, ThreadPage as Z, ProgressItem as _, answerInput as a, FormIssue as at, TaskInterrupt as b, submitFormAnswers as c, Attachment as d, RungentEvent as et, Citation as f, OtherInterrupt as g, OpenInterrupt as h, answerApproval as i, FormAnswers as it, reduceThread as j, initialThreadState as k, ApprovalInterrupt as l, InputInterrupt as m, Context as n, FederatedSearchResponse as nt, cancelAll as o, ModelThinking as ot, FormInterrupt as p, SearchOptions as q, ResumeEntry as r, Form as rt, submitForm as s, ProviderOptions as st, ContentPart as t, RungentProtocolError as tt, AssistantItem as u, ReasoningItem as v, ToolItem as w, ThreadItem as x, RunStatus as y, FeedbackRating as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as RungentClient, M as CatalogOperation, Q as ThreadSummary, S as ThreadState, at as FormIssue, f as Citation, it as FormAnswers, l as ApprovalInterrupt, n as Context, nt as FederatedSearchResponse, r as ResumeEntry, rt as Form, t as ContentPart } from "./index-BuUWmx0G.js";
|
|
2
2
|
import { ComponentType, ReactNode, RefObject } from "react";
|
|
3
3
|
interface ApprovalCardProps {
|
|
4
4
|
readonly interrupt: ApprovalInterrupt;
|
|
@@ -33,6 +33,9 @@ declare const en: {
|
|
|
33
33
|
composerLabel: string;
|
|
34
34
|
send: string;
|
|
35
35
|
stop: string;
|
|
36
|
+
think: string;
|
|
37
|
+
thinkOffHint: string;
|
|
38
|
+
thinkOnHint: string;
|
|
36
39
|
thinking: string;
|
|
37
40
|
retrying: string;
|
|
38
41
|
cancelled: string;
|
|
@@ -112,6 +115,10 @@ declare const en: {
|
|
|
112
115
|
apiKey: string;
|
|
113
116
|
apiKeySaved: string;
|
|
114
117
|
vision: string;
|
|
118
|
+
thinkingOn: string;
|
|
119
|
+
thinkingOff: string;
|
|
120
|
+
thinkingHint: string;
|
|
121
|
+
thinkingInvalid: string;
|
|
115
122
|
moveUp: string;
|
|
116
123
|
moveDown: string;
|
|
117
124
|
remove: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as submitFormAnswers, c as attachmentsOf, d as reduceThread, f as RungentRequestError, h as checkAnswers, i as submitForm, l as initialThreadState, n as answerInput, o as appendUserMessage, r as cancelAll, s as attachmentPart, t as answerApproval } from "./client-
|
|
1
|
+
import { a as submitFormAnswers, c as attachmentsOf, d as reduceThread, f as RungentRequestError, h as checkAnswers, i as submitForm, l as initialThreadState, n as answerInput, o as appendUserMessage, r as cancelAll, s as attachmentPart, t as answerApproval } from "./client-mUY72akp.js";
|
|
2
2
|
import { createContext, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import ReactMarkdown from "react-markdown";
|
|
@@ -134,6 +134,9 @@ const en = {
|
|
|
134
134
|
composerLabel: "Message",
|
|
135
135
|
send: "Send",
|
|
136
136
|
stop: "Stop",
|
|
137
|
+
think: "Think",
|
|
138
|
+
thinkOffHint: "Let the model think before it answers: slower, for harder questions",
|
|
139
|
+
thinkOnHint: "The model thinks before it answers. Turn off for faster answers",
|
|
137
140
|
thinking: "Thinking…",
|
|
138
141
|
retrying: "Model busy, retrying ({attempt}/{max})…",
|
|
139
142
|
cancelled: "Stopped.",
|
|
@@ -213,6 +216,10 @@ const en = {
|
|
|
213
216
|
apiKey: "API key",
|
|
214
217
|
apiKeySaved: "Saved — leave empty to keep",
|
|
215
218
|
vision: "Images",
|
|
219
|
+
thinkingOn: "Thinking on",
|
|
220
|
+
thinkingOff: "Thinking off",
|
|
221
|
+
thinkingHint: "Provider options that turn the model’s reasoning on and off, as JSON. Users see a Think switch when a model has both; it is off unless they turn it on. Leave both empty for a model that cannot think.",
|
|
222
|
+
thinkingInvalid: "Thinking on and off must both be JSON objects of provider options, or both empty.",
|
|
216
223
|
moveUp: "Move up",
|
|
217
224
|
moveDown: "Move down",
|
|
218
225
|
remove: "Remove",
|
|
@@ -273,6 +280,9 @@ const zhCN = {
|
|
|
273
280
|
composerLabel: "消息",
|
|
274
281
|
send: "发送",
|
|
275
282
|
stop: "停止",
|
|
283
|
+
think: "深度思考",
|
|
284
|
+
thinkOffHint: "让模型先思考再回答:更慢,适合较难的问题",
|
|
285
|
+
thinkOnHint: "模型会先思考再回答。关闭可更快得到回答",
|
|
276
286
|
thinking: "思考中…",
|
|
277
287
|
retrying: "模型繁忙,重试中({attempt}/{max})…",
|
|
278
288
|
cancelled: "已停止。",
|
|
@@ -352,6 +362,10 @@ const zhCN = {
|
|
|
352
362
|
apiKey: "API 密钥",
|
|
353
363
|
apiKeySaved: "已保存,留空则不变",
|
|
354
364
|
vision: "图片",
|
|
365
|
+
thinkingOn: "开启思考",
|
|
366
|
+
thinkingOff: "关闭思考",
|
|
367
|
+
thinkingHint: "开启和关闭模型推理的服务商参数,JSON 格式。两项都填写后,用户会看到“深度思考”开关,默认关闭。不能思考的模型两项都留空。",
|
|
368
|
+
thinkingInvalid: "开启思考和关闭思考须同为服务商参数的 JSON 对象,或同为空。",
|
|
355
369
|
moveUp: "上移",
|
|
356
370
|
moveDown: "下移",
|
|
357
371
|
remove: "移除",
|
|
@@ -478,9 +492,42 @@ function useControlledOpen(toggle, open, onOpenChange) {
|
|
|
478
492
|
return [open ?? toggle.isOpen, set];
|
|
479
493
|
}
|
|
480
494
|
const DEFAULT_NAME = "Assistant";
|
|
495
|
+
function readFlag(key) {
|
|
496
|
+
try {
|
|
497
|
+
return window.localStorage.getItem(key) === "on";
|
|
498
|
+
} catch {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
/** The user's thinking switch, kept in `localStorage` under `key`; off until they turn it on. */
|
|
503
|
+
function useThinking(key, available) {
|
|
504
|
+
const [on, store] = useState(() => typeof window === "undefined" ? false : readFlag(key));
|
|
505
|
+
const [storedKey, setStoredKey] = useState(key);
|
|
506
|
+
if (storedKey !== key) {
|
|
507
|
+
setStoredKey(key);
|
|
508
|
+
store(readFlag(key));
|
|
509
|
+
}
|
|
510
|
+
const set = useCallback((next) => {
|
|
511
|
+
store(next);
|
|
512
|
+
try {
|
|
513
|
+
if (next) window.localStorage.setItem(key, "on");
|
|
514
|
+
else window.localStorage.removeItem(key);
|
|
515
|
+
} catch {}
|
|
516
|
+
}, [key]);
|
|
517
|
+
return useMemo(() => ({
|
|
518
|
+
available,
|
|
519
|
+
on,
|
|
520
|
+
set
|
|
521
|
+
}), [
|
|
522
|
+
available,
|
|
523
|
+
on,
|
|
524
|
+
set
|
|
525
|
+
]);
|
|
526
|
+
}
|
|
481
527
|
const NO_FORMS = {};
|
|
482
528
|
function RungentProvider({ client, locale = "en", strings, upload, context, onOpen, theme = "system", forms = NO_FORMS, suggestions, children }) {
|
|
483
|
-
const
|
|
529
|
+
const instance = client.baseUrl || (typeof window === "undefined" ? "" : window.location.origin);
|
|
530
|
+
const dockKey = `rungent:dock:${instance}`;
|
|
484
531
|
const dock = useDockToggle(dockKey);
|
|
485
532
|
const palette = useToggle();
|
|
486
533
|
const paletteSeed = useRef("");
|
|
@@ -491,9 +538,15 @@ function RungentProvider({ client, locale = "en", strings, upload, context, onOp
|
|
|
491
538
|
const onOpenLatest = useLatest(onOpen);
|
|
492
539
|
const uploadLatest = useLatest(upload);
|
|
493
540
|
const [name, setName] = useState(DEFAULT_NAME);
|
|
541
|
+
const [canThink, setCanThink] = useState(false);
|
|
542
|
+
const thinking = useThinking(`rungent:thinking:${instance}`, canThink);
|
|
494
543
|
useEffect(() => {
|
|
495
544
|
let live = true;
|
|
496
|
-
client.info().then((info) =>
|
|
545
|
+
client.info().then((info) => {
|
|
546
|
+
if (!live) return;
|
|
547
|
+
setName(info.name);
|
|
548
|
+
setCanThink(info.thinking === true);
|
|
549
|
+
}, () => {});
|
|
497
550
|
return () => {
|
|
498
551
|
live = false;
|
|
499
552
|
};
|
|
@@ -533,7 +586,8 @@ function RungentProvider({ client, locale = "en", strings, upload, context, onOp
|
|
|
533
586
|
paletteSeed,
|
|
534
587
|
ask,
|
|
535
588
|
askTaken,
|
|
536
|
-
askAssistant
|
|
589
|
+
askAssistant,
|
|
590
|
+
thinking
|
|
537
591
|
}), [
|
|
538
592
|
client,
|
|
539
593
|
locale,
|
|
@@ -548,7 +602,8 @@ function RungentProvider({ client, locale = "en", strings, upload, context, onOp
|
|
|
548
602
|
dockKey,
|
|
549
603
|
palette,
|
|
550
604
|
ask,
|
|
551
|
-
askAssistant
|
|
605
|
+
askAssistant,
|
|
606
|
+
thinking
|
|
552
607
|
]);
|
|
553
608
|
return /* @__PURE__ */ jsx(RungentContext, {
|
|
554
609
|
value,
|
|
@@ -723,6 +778,10 @@ function ApprovalCard({ interrupt, onAnswer }) {
|
|
|
723
778
|
function threadReducer(state, action) {
|
|
724
779
|
if (action.type === "load") return action.state;
|
|
725
780
|
if (action.type === "user") return appendUserMessage(state, action.item);
|
|
781
|
+
if (action.type === "interrupts") return {
|
|
782
|
+
...state,
|
|
783
|
+
interrupts: action.interrupts
|
|
784
|
+
};
|
|
726
785
|
return reduceThread(state, action.event);
|
|
727
786
|
}
|
|
728
787
|
function textOf(message) {
|
|
@@ -754,7 +813,8 @@ async function start(run) {
|
|
|
754
813
|
* (`rungent.ui.open`) that runs started here ask for.
|
|
755
814
|
*/
|
|
756
815
|
function useThread(threadId) {
|
|
757
|
-
const { client, navigate, context } = useRungent();
|
|
816
|
+
const { client, navigate, context, thinking } = useRungent();
|
|
817
|
+
const think = thinking.available && thinking.on;
|
|
758
818
|
const [createdId, setCreatedId] = useState(null);
|
|
759
819
|
const [shownProp, setShownProp] = useState(threadId);
|
|
760
820
|
if (shownProp !== threadId) {
|
|
@@ -828,7 +888,8 @@ function useThread(threadId) {
|
|
|
828
888
|
const run = client.run(target, {
|
|
829
889
|
message,
|
|
830
890
|
context: context?.() ?? [],
|
|
831
|
-
...open.length > 0 ? { resume: cancelAll(open) } : {}
|
|
891
|
+
...open.length > 0 ? { resume: cancelAll(open) } : {},
|
|
892
|
+
...think ? { thinking: true } : {}
|
|
832
893
|
});
|
|
833
894
|
if (run.messageId) dispatch({
|
|
834
895
|
type: "user",
|
|
@@ -847,24 +908,37 @@ function useThread(threadId) {
|
|
|
847
908
|
}, [
|
|
848
909
|
client,
|
|
849
910
|
context,
|
|
850
|
-
id
|
|
911
|
+
id,
|
|
912
|
+
think
|
|
851
913
|
]),
|
|
852
914
|
resume: useCallback(async (entries) => {
|
|
853
915
|
if (!id) return;
|
|
854
916
|
setError(null);
|
|
855
917
|
openAfter.current = stateRef.current.lastSeq;
|
|
918
|
+
const open = stateRef.current.interrupts;
|
|
919
|
+
const answered = new Set(entries.map((entry) => entry.interruptId));
|
|
920
|
+
dispatch({
|
|
921
|
+
type: "interrupts",
|
|
922
|
+
interrupts: open.filter((item) => !answered.has(item.id))
|
|
923
|
+
});
|
|
856
924
|
try {
|
|
857
925
|
await start(client.run(id, {
|
|
858
926
|
resume: entries,
|
|
859
|
-
context: context?.() ?? []
|
|
927
|
+
context: context?.() ?? [],
|
|
928
|
+
...think ? { thinking: true } : {}
|
|
860
929
|
}));
|
|
861
930
|
} catch (reason) {
|
|
931
|
+
dispatch({
|
|
932
|
+
type: "interrupts",
|
|
933
|
+
interrupts: open
|
|
934
|
+
});
|
|
862
935
|
setError(reason);
|
|
863
936
|
}
|
|
864
937
|
}, [
|
|
865
938
|
client,
|
|
866
939
|
context,
|
|
867
|
-
id
|
|
940
|
+
id,
|
|
941
|
+
think
|
|
868
942
|
]),
|
|
869
943
|
cancel: useCallback(async () => {
|
|
870
944
|
const runId = stateRef.current.runId;
|
|
@@ -2160,6 +2234,33 @@ function PendingList({ attachments }) {
|
|
|
2160
2234
|
children: t("uploadFailed", { file: item.name })
|
|
2161
2235
|
}, item.key))] });
|
|
2162
2236
|
}
|
|
2237
|
+
function ThinkIcon() {
|
|
2238
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
2239
|
+
viewBox: "0 0 24 24",
|
|
2240
|
+
width: "16",
|
|
2241
|
+
height: "16",
|
|
2242
|
+
"aria-hidden": "true",
|
|
2243
|
+
className: "rungent-icon",
|
|
2244
|
+
children: [
|
|
2245
|
+
/* @__PURE__ */ jsx("path", { d: "M9 18h6" }),
|
|
2246
|
+
/* @__PURE__ */ jsx("path", { d: "M10 22h4" }),
|
|
2247
|
+
/* @__PURE__ */ jsx("path", { d: "M15.1 14c.2-1 .7-1.7 1.4-2.5A5.5 5.5 0 0 0 12 2.5a5.5 5.5 0 0 0-4.5 9c.7.8 1.2 1.5 1.4 2.5" })
|
|
2248
|
+
]
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
/** The user's thinking switch: off by default, remembered per browser, sent with each run. */
|
|
2252
|
+
function ThinkToggle() {
|
|
2253
|
+
const { t, thinking } = useRungent();
|
|
2254
|
+
if (!thinking.available) return null;
|
|
2255
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
2256
|
+
type: "button",
|
|
2257
|
+
className: "rungent-think",
|
|
2258
|
+
"aria-pressed": thinking.on,
|
|
2259
|
+
title: t(thinking.on ? "thinkOnHint" : "thinkOffHint"),
|
|
2260
|
+
onClick: () => thinking.set(!thinking.on),
|
|
2261
|
+
children: [/* @__PURE__ */ jsx(ThinkIcon, {}), /* @__PURE__ */ jsx("span", { children: t("think") })]
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2163
2264
|
function SendIcon() {
|
|
2164
2265
|
return /* @__PURE__ */ jsxs("svg", {
|
|
2165
2266
|
viewBox: "0 0 24 24",
|
|
@@ -2188,7 +2289,8 @@ function StopIcon() {
|
|
|
2188
2289
|
}
|
|
2189
2290
|
/**
|
|
2190
2291
|
* The message box: one card with the text, which grows with it and then scrolls, and a row
|
|
2191
|
-
* under it with attachments and the context ring on the left and send or
|
|
2292
|
+
* under it with attachments, the thinking switch and the context ring on the left and send or
|
|
2293
|
+
* stop on the right.
|
|
2192
2294
|
*/
|
|
2193
2295
|
function Composer({ thread, attachments }) {
|
|
2194
2296
|
const { t, upload } = useRungent();
|
|
@@ -2279,6 +2381,7 @@ function Composer({ thread, attachments }) {
|
|
|
2279
2381
|
})
|
|
2280
2382
|
]
|
|
2281
2383
|
}) : null,
|
|
2384
|
+
/* @__PURE__ */ jsx(ThinkToggle, {}),
|
|
2282
2385
|
context && started ? /* @__PURE__ */ jsx(ContextRing, { usage: context }) : null,
|
|
2283
2386
|
/* @__PURE__ */ jsx("span", { className: "rungent-composer-spacer" }),
|
|
2284
2387
|
running ? /* @__PURE__ */ jsx("button", {
|
|
@@ -3278,23 +3381,59 @@ const PROVIDERS = [
|
|
|
3278
3381
|
"openai",
|
|
3279
3382
|
"anthropic"
|
|
3280
3383
|
];
|
|
3384
|
+
/** What each provider's thinking options usually are, shown as placeholders. */
|
|
3385
|
+
const THINKING_EXAMPLES = {
|
|
3386
|
+
"openai-compatible": {
|
|
3387
|
+
on: "{\"openai-compatible\": {\"enable_thinking\": true}}",
|
|
3388
|
+
off: "{\"openai-compatible\": {\"enable_thinking\": false}}"
|
|
3389
|
+
},
|
|
3390
|
+
openai: {
|
|
3391
|
+
on: "{\"openai\": {\"reasoningEffort\": \"medium\"}}",
|
|
3392
|
+
off: "{\"openai\": {\"reasoningEffort\": \"none\"}}"
|
|
3393
|
+
},
|
|
3394
|
+
anthropic: {
|
|
3395
|
+
on: "{\"anthropic\": {\"thinking\": {\"type\": \"enabled\", \"budgetTokens\": 4000}}}",
|
|
3396
|
+
off: "{\"anthropic\": {\"thinking\": {\"type\": \"disabled\"}}}"
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3281
3399
|
let nextKey = 0;
|
|
3282
3400
|
const row = (endpoint) => ({
|
|
3283
3401
|
key: nextKey++,
|
|
3284
3402
|
endpoint,
|
|
3285
|
-
apiKey: ""
|
|
3403
|
+
apiKey: "",
|
|
3404
|
+
thinkingOn: endpoint.thinking ? JSON.stringify(endpoint.thinking.on) : "",
|
|
3405
|
+
thinkingOff: endpoint.thinking ? JSON.stringify(endpoint.thinking.off) : ""
|
|
3286
3406
|
});
|
|
3407
|
+
/** Provider options typed as JSON: an object of objects, or undefined when it is not one. */
|
|
3408
|
+
function providerOptions(text) {
|
|
3409
|
+
try {
|
|
3410
|
+
const value = JSON.parse(text);
|
|
3411
|
+
const isObject = (item) => typeof item === "object" && item !== null && !Array.isArray(item);
|
|
3412
|
+
return isObject(value) && Object.values(value).every(isObject) ? value : void 0;
|
|
3413
|
+
} catch {
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
/** The row's thinking options; null when they are not both empty or both provider options. */
|
|
3418
|
+
function thinkingOf(item) {
|
|
3419
|
+
if (!item.thinkingOn.trim() && !item.thinkingOff.trim()) return void 0;
|
|
3420
|
+
const on = providerOptions(item.thinkingOn);
|
|
3421
|
+
const off = providerOptions(item.thinkingOff);
|
|
3422
|
+
return on && off ? {
|
|
3423
|
+
on,
|
|
3424
|
+
off
|
|
3425
|
+
} : null;
|
|
3426
|
+
}
|
|
3287
3427
|
/** The endpoint as PUT takes it; models configured in code (provider `custom`) stay out. */
|
|
3288
|
-
function update(
|
|
3289
|
-
const { hasApiKey: _, provider, ...fields } = endpoint;
|
|
3428
|
+
function update(item) {
|
|
3429
|
+
const { hasApiKey: _, thinking: __, provider, ...fields } = item.endpoint;
|
|
3290
3430
|
if (provider === "custom") return [];
|
|
3291
|
-
|
|
3431
|
+
const thinking = thinkingOf(item);
|
|
3432
|
+
return [{
|
|
3292
3433
|
...fields,
|
|
3293
3434
|
provider,
|
|
3294
|
-
apiKey
|
|
3295
|
-
|
|
3296
|
-
...fields,
|
|
3297
|
-
provider
|
|
3435
|
+
...item.apiKey ? { apiKey: item.apiKey } : {},
|
|
3436
|
+
...thinking ? { thinking } : {}
|
|
3298
3437
|
}];
|
|
3299
3438
|
}
|
|
3300
3439
|
/** An id no other row has, `model-N`. */
|
|
@@ -3351,6 +3490,10 @@ function ModelSettings() {
|
|
|
3351
3490
|
const save = async (event) => {
|
|
3352
3491
|
event.preventDefault();
|
|
3353
3492
|
if (!rows) return;
|
|
3493
|
+
if (rows.some((item) => item.endpoint.provider !== "custom" && thinkingOf(item) === null)) {
|
|
3494
|
+
setStatus("invalidThinking");
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
3354
3497
|
setStatus("saving");
|
|
3355
3498
|
try {
|
|
3356
3499
|
const saved = await client.putSettings({ models: { chain: rows.flatMap(update) } });
|
|
@@ -3412,6 +3555,8 @@ function ModelSettings() {
|
|
|
3412
3555
|
children: t("configuredInCode")
|
|
3413
3556
|
})]
|
|
3414
3557
|
}, item.key);
|
|
3558
|
+
const example = THINKING_EXAMPLES[endpoint.provider];
|
|
3559
|
+
const thinkingInvalid = status === "invalidThinking" && thinkingOf(item) === null;
|
|
3415
3560
|
return /* @__PURE__ */ jsxs("li", {
|
|
3416
3561
|
className: "rungent-card rungent-endpoint",
|
|
3417
3562
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -3572,6 +3717,50 @@ function ModelSettings() {
|
|
|
3572
3717
|
checked: endpoint.vision ?? false,
|
|
3573
3718
|
onChange: (event) => field(index, { vision: event.target.checked })
|
|
3574
3719
|
}), /* @__PURE__ */ jsx("span", { children: t("vision") })]
|
|
3720
|
+
}),
|
|
3721
|
+
/* @__PURE__ */ jsx("label", {
|
|
3722
|
+
htmlFor: `${id}-thinking-on`,
|
|
3723
|
+
className: "rungent-label",
|
|
3724
|
+
children: t("thinkingOn")
|
|
3725
|
+
}),
|
|
3726
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
3727
|
+
id: `${id}-thinking-on`,
|
|
3728
|
+
className: "rungent-input rungent-json",
|
|
3729
|
+
rows: 1,
|
|
3730
|
+
spellCheck: false,
|
|
3731
|
+
placeholder: example.on,
|
|
3732
|
+
"aria-invalid": thinkingInvalid || void 0,
|
|
3733
|
+
"aria-describedby": `${id}-thinking-hint`,
|
|
3734
|
+
value: item.thinkingOn,
|
|
3735
|
+
onChange: (event) => edit(index, (other) => ({
|
|
3736
|
+
...other,
|
|
3737
|
+
thinkingOn: event.target.value
|
|
3738
|
+
}))
|
|
3739
|
+
}),
|
|
3740
|
+
/* @__PURE__ */ jsx("label", {
|
|
3741
|
+
htmlFor: `${id}-thinking-off`,
|
|
3742
|
+
className: "rungent-label",
|
|
3743
|
+
children: t("thinkingOff")
|
|
3744
|
+
}),
|
|
3745
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
3746
|
+
id: `${id}-thinking-off`,
|
|
3747
|
+
className: "rungent-input rungent-json",
|
|
3748
|
+
rows: 1,
|
|
3749
|
+
spellCheck: false,
|
|
3750
|
+
placeholder: example.off,
|
|
3751
|
+
"aria-invalid": thinkingInvalid || void 0,
|
|
3752
|
+
"aria-describedby": `${id}-thinking-hint`,
|
|
3753
|
+
value: item.thinkingOff,
|
|
3754
|
+
onChange: (event) => edit(index, (other) => ({
|
|
3755
|
+
...other,
|
|
3756
|
+
thinkingOff: event.target.value
|
|
3757
|
+
}))
|
|
3758
|
+
}),
|
|
3759
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
3760
|
+
/* @__PURE__ */ jsx("p", {
|
|
3761
|
+
id: `${id}-thinking-hint`,
|
|
3762
|
+
className: "rungent-muted rungent-small",
|
|
3763
|
+
children: t("thinkingHint")
|
|
3575
3764
|
})
|
|
3576
3765
|
]
|
|
3577
3766
|
})]
|
|
@@ -3608,7 +3797,7 @@ function ModelSettings() {
|
|
|
3608
3797
|
/* @__PURE__ */ jsx("span", {
|
|
3609
3798
|
className: "rungent-small",
|
|
3610
3799
|
role: "status",
|
|
3611
|
-
children: status === "saved" ? t("saved") : status === "reset" ? t("resetDone") : typeof status === "object" ? t("saveFailed", { status: status.failed }) : null
|
|
3800
|
+
children: status === "saved" ? t("saved") : status === "reset" ? t("resetDone") : status === "invalidThinking" ? t("thinkingInvalid") : typeof status === "object" ? t("saveFailed", { status: status.failed }) : null
|
|
3612
3801
|
}),
|
|
3613
3802
|
/* @__PURE__ */ jsx("button", {
|
|
3614
3803
|
type: "button",
|
package/dist/styles.css
CHANGED
|
@@ -1069,8 +1069,14 @@ button.rungent-step-row {
|
|
|
1069
1069
|
color: var(--rungent-muted);
|
|
1070
1070
|
}
|
|
1071
1071
|
|
|
1072
|
+
/* The card shows focus (focus-within above). Host form styles (`textarea:focus { border; box-shadow }`)
|
|
1073
|
+
must not draw a second ring around the text area alone. */
|
|
1074
|
+
.rungent-root .rungent-composer-input,
|
|
1075
|
+
.rungent-root .rungent-composer-input:focus,
|
|
1072
1076
|
.rungent-root .rungent-composer-input:focus-visible {
|
|
1077
|
+
border: 0;
|
|
1073
1078
|
outline: none;
|
|
1079
|
+
box-shadow: none;
|
|
1074
1080
|
}
|
|
1075
1081
|
|
|
1076
1082
|
.rungent-composer-bar {
|
|
@@ -1090,6 +1096,37 @@ button.rungent-step-row {
|
|
|
1090
1096
|
flex: 1;
|
|
1091
1097
|
}
|
|
1092
1098
|
|
|
1099
|
+
/* The thinking switch: as quiet as the other controls while off, the accent while on. */
|
|
1100
|
+
.rungent-think {
|
|
1101
|
+
display: inline-flex;
|
|
1102
|
+
align-items: center;
|
|
1103
|
+
gap: 4px;
|
|
1104
|
+
height: 28px;
|
|
1105
|
+
flex: none;
|
|
1106
|
+
padding: 0 9px 0 7px;
|
|
1107
|
+
border: 1px solid transparent;
|
|
1108
|
+
border-radius: 999px;
|
|
1109
|
+
background: transparent;
|
|
1110
|
+
color: var(--rungent-muted);
|
|
1111
|
+
font: inherit;
|
|
1112
|
+
font-size: 12px;
|
|
1113
|
+
line-height: 1;
|
|
1114
|
+
cursor: pointer;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
@media (hover: hover) {
|
|
1118
|
+
.rungent-think:hover {
|
|
1119
|
+
background: var(--rungent-surface);
|
|
1120
|
+
color: var(--rungent-fg);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
.rungent-think[aria-pressed="true"] {
|
|
1125
|
+
border-color: color-mix(in srgb, var(--rungent-accent) 35%, transparent);
|
|
1126
|
+
background: var(--rungent-accent-soft);
|
|
1127
|
+
color: var(--rungent-accent);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1093
1130
|
.rungent-send {
|
|
1094
1131
|
display: grid;
|
|
1095
1132
|
place-items: center;
|
|
@@ -1619,8 +1656,11 @@ button.rungent-step-row {
|
|
|
1619
1656
|
font-size: 16px;
|
|
1620
1657
|
}
|
|
1621
1658
|
|
|
1622
|
-
.rungent-palette-input:focus
|
|
1659
|
+
.rungent-root .rungent-palette-input:focus,
|
|
1660
|
+
.rungent-root .rungent-palette-input:focus-visible {
|
|
1623
1661
|
outline: none;
|
|
1662
|
+
box-shadow: none;
|
|
1663
|
+
border-bottom-color: var(--rungent-border);
|
|
1624
1664
|
}
|
|
1625
1665
|
|
|
1626
1666
|
.rungent-options {
|
|
@@ -1764,6 +1804,18 @@ button.rungent-step-row {
|
|
|
1764
1804
|
gap: 8px 12px;
|
|
1765
1805
|
}
|
|
1766
1806
|
|
|
1807
|
+
.rungent-fields > p {
|
|
1808
|
+
margin: 0;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/* Provider options typed as JSON. */
|
|
1812
|
+
.rungent-json {
|
|
1813
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1814
|
+
font-size: 12px;
|
|
1815
|
+
line-height: 1.5;
|
|
1816
|
+
resize: vertical;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1767
1819
|
.rungent-fields .rungent-label {
|
|
1768
1820
|
margin: 0;
|
|
1769
1821
|
color: var(--rungent-muted);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rungent/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "rungent's frontend: the React dock, thread, forms and ⌘K palette, and the HTTP client any frontend can use.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://rungent.acahti.dev",
|