@agentskit/chat 0.1.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 +22 -0
- package/README.md +31 -0
- package/dist/index.cjs +1664 -0
- package/dist/index.d.cts +618 -0
- package/dist/index.d.ts +618 -0
- package/dist/index.js +1614 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import * as _agentskit_chat_protocol from '@agentskit/chat-protocol';
|
|
2
|
+
import { AskToolEvent, ComponentRenderFrame, AskEvent, VerifiedLocalKnowledgeArtifact, DeterministicSiteConfig, AnswerResponse, SessionConfirmation, SessionSnapshot, ComponentInteractionEvent, ComponentSelectionEvent } from '@agentskit/chat-protocol';
|
|
3
|
+
export { AskEvent, AskEventSchema, AskToolEvent, decodeAskEvents } from '@agentskit/chat-protocol';
|
|
4
|
+
import { AdapterFactory, ChatMemory, Message, AdapterRequest, StreamSource, ChatReturn, ToolAuthorizer, ChatConfig } from '@agentskit/core';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { WebStorageLike } from '@agentskit/memory/web-storage';
|
|
7
|
+
|
|
8
|
+
declare const CHOICE_LIST_COMPONENT_KEY: "choice-list";
|
|
9
|
+
interface ComponentEventDefinition {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly value: 'none' | 'id' | 'form' | 'url';
|
|
12
|
+
}
|
|
13
|
+
interface ComponentAccessibilityDefinition {
|
|
14
|
+
readonly role: string;
|
|
15
|
+
readonly keyboard: boolean;
|
|
16
|
+
readonly live: 'none' | 'polite' | 'assertive';
|
|
17
|
+
}
|
|
18
|
+
type ComponentCapability = 'display' | 'selection' | 'input' | 'action' | 'navigation' | 'progress' | 'download';
|
|
19
|
+
interface ComponentDefinition<T> {
|
|
20
|
+
readonly key: string;
|
|
21
|
+
readonly propsSchema: z.ZodType<T>;
|
|
22
|
+
readonly events?: readonly ComponentEventDefinition[];
|
|
23
|
+
readonly accessibility?: ComponentAccessibilityDefinition;
|
|
24
|
+
readonly capabilities?: readonly ComponentCapability[];
|
|
25
|
+
fallback?(props: T): string;
|
|
26
|
+
}
|
|
27
|
+
declare const ChoiceListPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
28
|
+
prompt: z.ZodString;
|
|
29
|
+
choices: z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
label: z.ZodString;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
action: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
input: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
36
|
+
}, z.core.$strict>>>;
|
|
37
|
+
}, z.core.$strict>>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
declare const ButtonGroupPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
40
|
+
label: z.ZodString;
|
|
41
|
+
buttons: z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
label: z.ZodString;
|
|
44
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
danger: "danger";
|
|
47
|
+
primary: "primary";
|
|
48
|
+
secondary: "secondary";
|
|
49
|
+
}>>;
|
|
50
|
+
}, z.core.$strict>>>;
|
|
51
|
+
}, z.core.$strict>>;
|
|
52
|
+
declare const FormPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
53
|
+
title: z.ZodOptional<z.ZodString>;
|
|
54
|
+
fields: z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
label: z.ZodString;
|
|
57
|
+
type: z.ZodEnum<{
|
|
58
|
+
number: "number";
|
|
59
|
+
text: "text";
|
|
60
|
+
select: "select";
|
|
61
|
+
email: "email";
|
|
62
|
+
checkbox: "checkbox";
|
|
63
|
+
}>;
|
|
64
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
66
|
+
options: z.ZodOptional<z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
label: z.ZodString;
|
|
69
|
+
}, z.core.$strict>>>>;
|
|
70
|
+
}, z.core.$strict>>>;
|
|
71
|
+
submitLabel: z.ZodString;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
declare const ConfirmationPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
74
|
+
title: z.ZodString;
|
|
75
|
+
message: z.ZodString;
|
|
76
|
+
confirmLabel: z.ZodString;
|
|
77
|
+
cancelLabel: z.ZodString;
|
|
78
|
+
}, z.core.$strict>>;
|
|
79
|
+
declare const ProgressPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
80
|
+
label: z.ZodString;
|
|
81
|
+
value: z.ZodNumber;
|
|
82
|
+
status: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, z.core.$strict>>;
|
|
84
|
+
declare const SourceListPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
sources: z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
title: z.ZodString;
|
|
89
|
+
url: z.ZodOptional<z.ZodString>;
|
|
90
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strict>>>;
|
|
92
|
+
}, z.core.$strict>>;
|
|
93
|
+
declare const LinkCardPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
94
|
+
title: z.ZodString;
|
|
95
|
+
description: z.ZodOptional<z.ZodString>;
|
|
96
|
+
href: z.ZodString;
|
|
97
|
+
label: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
declare const ErrorNoticePropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
100
|
+
title: z.ZodString;
|
|
101
|
+
message: z.ZodString;
|
|
102
|
+
code: z.ZodOptional<z.ZodString>;
|
|
103
|
+
retryLabel: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strict>>;
|
|
105
|
+
declare const ToolCallPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
106
|
+
name: z.ZodString;
|
|
107
|
+
status: z.ZodEnum<{
|
|
108
|
+
error: "error";
|
|
109
|
+
pending: "pending";
|
|
110
|
+
running: "running";
|
|
111
|
+
complete: "complete";
|
|
112
|
+
}>;
|
|
113
|
+
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
114
|
+
result: z.ZodOptional<z.ZodJSONSchema>;
|
|
115
|
+
}, z.core.$strict>>;
|
|
116
|
+
declare const ApprovalRequestPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
117
|
+
title: z.ZodString;
|
|
118
|
+
description: z.ZodString;
|
|
119
|
+
approveLabel: z.ZodString;
|
|
120
|
+
denyLabel: z.ZodString;
|
|
121
|
+
}, z.core.$strict>>;
|
|
122
|
+
declare const TablePropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
123
|
+
caption: z.ZodString;
|
|
124
|
+
columns: z.ZodArray<z.ZodReadonly<z.ZodObject<{
|
|
125
|
+
key: z.ZodString;
|
|
126
|
+
label: z.ZodString;
|
|
127
|
+
}, z.core.$strict>>>;
|
|
128
|
+
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
129
|
+
}, z.core.$strict>>;
|
|
130
|
+
declare const FileAttachmentPropsSchema: z.ZodReadonly<z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
mimeType: z.ZodString;
|
|
133
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
url: z.ZodOptional<z.ZodString>;
|
|
135
|
+
}, z.core.$strict>>;
|
|
136
|
+
type ChoiceListProps = z.infer<typeof ChoiceListPropsSchema>;
|
|
137
|
+
type ChoiceAction = NonNullable<ChoiceListProps['choices'][number]['action']>;
|
|
138
|
+
declare const ChoiceListComponent: ComponentDefinition<Readonly<{
|
|
139
|
+
prompt: string;
|
|
140
|
+
choices: Readonly<{
|
|
141
|
+
id: string;
|
|
142
|
+
label: string;
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
action?: Readonly<{
|
|
145
|
+
name: string;
|
|
146
|
+
input: Record<string, z.core.util.JSONType>;
|
|
147
|
+
}> | undefined;
|
|
148
|
+
}>[];
|
|
149
|
+
}>>;
|
|
150
|
+
declare const ButtonGroupComponent: ComponentDefinition<Readonly<{
|
|
151
|
+
label: string;
|
|
152
|
+
buttons: Readonly<{
|
|
153
|
+
id: string;
|
|
154
|
+
label: string;
|
|
155
|
+
disabled?: boolean | undefined;
|
|
156
|
+
variant?: "danger" | "primary" | "secondary" | undefined;
|
|
157
|
+
}>[];
|
|
158
|
+
}>>;
|
|
159
|
+
declare const FormComponent: ComponentDefinition<Readonly<{
|
|
160
|
+
fields: Readonly<{
|
|
161
|
+
id: string;
|
|
162
|
+
label: string;
|
|
163
|
+
type: "number" | "text" | "select" | "email" | "checkbox";
|
|
164
|
+
required?: boolean | undefined;
|
|
165
|
+
placeholder?: string | undefined;
|
|
166
|
+
options?: Readonly<{
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
}>[] | undefined;
|
|
170
|
+
}>[];
|
|
171
|
+
submitLabel: string;
|
|
172
|
+
title?: string | undefined;
|
|
173
|
+
}>>;
|
|
174
|
+
declare const ConfirmationComponent: ComponentDefinition<Readonly<{
|
|
175
|
+
title: string;
|
|
176
|
+
message: string;
|
|
177
|
+
confirmLabel: string;
|
|
178
|
+
cancelLabel: string;
|
|
179
|
+
}>>;
|
|
180
|
+
declare const ProgressComponent: ComponentDefinition<Readonly<{
|
|
181
|
+
label: string;
|
|
182
|
+
value: number;
|
|
183
|
+
status?: string | undefined;
|
|
184
|
+
}>>;
|
|
185
|
+
declare const SourceListComponent: ComponentDefinition<Readonly<{
|
|
186
|
+
label: string;
|
|
187
|
+
sources: Readonly<{
|
|
188
|
+
id: string;
|
|
189
|
+
title: string;
|
|
190
|
+
url?: string | undefined;
|
|
191
|
+
snippet?: string | undefined;
|
|
192
|
+
}>[];
|
|
193
|
+
}>>;
|
|
194
|
+
declare const LinkCardComponent: ComponentDefinition<Readonly<{
|
|
195
|
+
title: string;
|
|
196
|
+
href: string;
|
|
197
|
+
description?: string | undefined;
|
|
198
|
+
label?: string | undefined;
|
|
199
|
+
}>>;
|
|
200
|
+
declare const ErrorNoticeComponent: ComponentDefinition<Readonly<{
|
|
201
|
+
title: string;
|
|
202
|
+
message: string;
|
|
203
|
+
code?: string | undefined;
|
|
204
|
+
retryLabel?: string | undefined;
|
|
205
|
+
}>>;
|
|
206
|
+
declare const ToolCallComponent: ComponentDefinition<Readonly<{
|
|
207
|
+
name: string;
|
|
208
|
+
status: "error" | "pending" | "running" | "complete";
|
|
209
|
+
arguments?: Record<string, z.core.util.JSONType> | undefined;
|
|
210
|
+
result?: z.core.util.JSONType | undefined;
|
|
211
|
+
}>>;
|
|
212
|
+
declare const ApprovalRequestComponent: ComponentDefinition<Readonly<{
|
|
213
|
+
title: string;
|
|
214
|
+
description: string;
|
|
215
|
+
approveLabel: string;
|
|
216
|
+
denyLabel: string;
|
|
217
|
+
}>>;
|
|
218
|
+
declare const TableComponent: ComponentDefinition<Readonly<{
|
|
219
|
+
caption: string;
|
|
220
|
+
columns: Readonly<{
|
|
221
|
+
key: string;
|
|
222
|
+
label: string;
|
|
223
|
+
}>[];
|
|
224
|
+
rows: Record<string, string | number | boolean | null>[];
|
|
225
|
+
}>>;
|
|
226
|
+
declare const FileAttachmentComponent: ComponentDefinition<Readonly<{
|
|
227
|
+
name: string;
|
|
228
|
+
mimeType: string;
|
|
229
|
+
sizeBytes?: number | undefined;
|
|
230
|
+
url?: string | undefined;
|
|
231
|
+
}>>;
|
|
232
|
+
declare const StandardComponentCatalog: readonly [ComponentDefinition<Readonly<{
|
|
233
|
+
label: string;
|
|
234
|
+
buttons: Readonly<{
|
|
235
|
+
id: string;
|
|
236
|
+
label: string;
|
|
237
|
+
disabled?: boolean | undefined;
|
|
238
|
+
variant?: "danger" | "primary" | "secondary" | undefined;
|
|
239
|
+
}>[];
|
|
240
|
+
}>>, ComponentDefinition<Readonly<{
|
|
241
|
+
prompt: string;
|
|
242
|
+
choices: Readonly<{
|
|
243
|
+
id: string;
|
|
244
|
+
label: string;
|
|
245
|
+
description?: string | undefined;
|
|
246
|
+
action?: Readonly<{
|
|
247
|
+
name: string;
|
|
248
|
+
input: Record<string, z.core.util.JSONType>;
|
|
249
|
+
}> | undefined;
|
|
250
|
+
}>[];
|
|
251
|
+
}>>, ComponentDefinition<Readonly<{
|
|
252
|
+
fields: Readonly<{
|
|
253
|
+
id: string;
|
|
254
|
+
label: string;
|
|
255
|
+
type: "number" | "text" | "select" | "email" | "checkbox";
|
|
256
|
+
required?: boolean | undefined;
|
|
257
|
+
placeholder?: string | undefined;
|
|
258
|
+
options?: Readonly<{
|
|
259
|
+
id: string;
|
|
260
|
+
label: string;
|
|
261
|
+
}>[] | undefined;
|
|
262
|
+
}>[];
|
|
263
|
+
submitLabel: string;
|
|
264
|
+
title?: string | undefined;
|
|
265
|
+
}>>, ComponentDefinition<Readonly<{
|
|
266
|
+
title: string;
|
|
267
|
+
message: string;
|
|
268
|
+
confirmLabel: string;
|
|
269
|
+
cancelLabel: string;
|
|
270
|
+
}>>, ComponentDefinition<Readonly<{
|
|
271
|
+
label: string;
|
|
272
|
+
value: number;
|
|
273
|
+
status?: string | undefined;
|
|
274
|
+
}>>, ComponentDefinition<Readonly<{
|
|
275
|
+
label: string;
|
|
276
|
+
sources: Readonly<{
|
|
277
|
+
id: string;
|
|
278
|
+
title: string;
|
|
279
|
+
url?: string | undefined;
|
|
280
|
+
snippet?: string | undefined;
|
|
281
|
+
}>[];
|
|
282
|
+
}>>, ComponentDefinition<Readonly<{
|
|
283
|
+
title: string;
|
|
284
|
+
href: string;
|
|
285
|
+
description?: string | undefined;
|
|
286
|
+
label?: string | undefined;
|
|
287
|
+
}>>, ComponentDefinition<Readonly<{
|
|
288
|
+
title: string;
|
|
289
|
+
message: string;
|
|
290
|
+
code?: string | undefined;
|
|
291
|
+
retryLabel?: string | undefined;
|
|
292
|
+
}>>, ComponentDefinition<Readonly<{
|
|
293
|
+
name: string;
|
|
294
|
+
status: "error" | "pending" | "running" | "complete";
|
|
295
|
+
arguments?: Record<string, z.core.util.JSONType> | undefined;
|
|
296
|
+
result?: z.core.util.JSONType | undefined;
|
|
297
|
+
}>>, ComponentDefinition<Readonly<{
|
|
298
|
+
title: string;
|
|
299
|
+
description: string;
|
|
300
|
+
approveLabel: string;
|
|
301
|
+
denyLabel: string;
|
|
302
|
+
}>>, ComponentDefinition<Readonly<{
|
|
303
|
+
caption: string;
|
|
304
|
+
columns: Readonly<{
|
|
305
|
+
key: string;
|
|
306
|
+
label: string;
|
|
307
|
+
}>[];
|
|
308
|
+
rows: Record<string, string | number | boolean | null>[];
|
|
309
|
+
}>>, ComponentDefinition<Readonly<{
|
|
310
|
+
name: string;
|
|
311
|
+
mimeType: string;
|
|
312
|
+
sizeBytes?: number | undefined;
|
|
313
|
+
url?: string | undefined;
|
|
314
|
+
}>>];
|
|
315
|
+
declare const STANDARD_COMPONENT_KEYS: readonly string[];
|
|
316
|
+
declare const validateStandardComponentInteraction: (componentKey: string, props: unknown, event: string, value?: unknown) => boolean;
|
|
317
|
+
|
|
318
|
+
type AskToolProjector = (event: AskToolEvent) => ComponentRenderFrame | undefined;
|
|
319
|
+
type AskProjection = {
|
|
320
|
+
readonly kind: 'text';
|
|
321
|
+
readonly text: string;
|
|
322
|
+
} | {
|
|
323
|
+
readonly kind: 'component';
|
|
324
|
+
readonly frame: ComponentRenderFrame;
|
|
325
|
+
} | {
|
|
326
|
+
readonly kind: 'error';
|
|
327
|
+
readonly message: string;
|
|
328
|
+
} | {
|
|
329
|
+
readonly kind: 'done';
|
|
330
|
+
};
|
|
331
|
+
interface AskAdapterOptions {
|
|
332
|
+
readonly endpoint?: string;
|
|
333
|
+
readonly corpus?: string;
|
|
334
|
+
readonly persona?: string;
|
|
335
|
+
readonly projectTool?: AskToolProjector;
|
|
336
|
+
}
|
|
337
|
+
interface AskMemoryOptions {
|
|
338
|
+
readonly key: string;
|
|
339
|
+
readonly legacyKeys?: readonly string[];
|
|
340
|
+
readonly maxMessages?: number;
|
|
341
|
+
readonly maxRecordBytes?: number;
|
|
342
|
+
readonly getStorage?: () => WebStorageLike | undefined;
|
|
343
|
+
readonly projectTool?: AskToolProjector;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Projects a validated Ask wire event into canonical ordered assistant content. */
|
|
347
|
+
declare function projectAskEvent(event: AskEvent, projectTool?: AskToolProjector): AskProjection | undefined;
|
|
348
|
+
declare function projectAskMessages(messages: readonly Message[]): Array<{
|
|
349
|
+
readonly role: 'user' | 'assistant';
|
|
350
|
+
readonly content: string;
|
|
351
|
+
}>;
|
|
352
|
+
/** Creates the shared Ask adapter without replacing the AgentsKit controller or message model. */
|
|
353
|
+
declare function createAskAdapter(options?: AskAdapterOptions): AdapterFactory;
|
|
354
|
+
/** Composes Ask legacy migration over the released, validated Web Storage ChatMemory. */
|
|
355
|
+
declare function createAskSessionMemory({ key, legacyKeys, maxMessages, maxRecordBytes, getStorage, projectTool, }: AskMemoryOptions): ChatMemory;
|
|
356
|
+
|
|
357
|
+
declare const normalizeDeterministicQuery: (value: string) => string;
|
|
358
|
+
interface DeterministicAnswerResolver {
|
|
359
|
+
readonly resolve: (query: string) => AnswerResponse;
|
|
360
|
+
readonly resolveChoice: (choiceId: string, query: string) => AnswerResponse;
|
|
361
|
+
}
|
|
362
|
+
interface DeterministicAnswerResolverOptions {
|
|
363
|
+
readonly now?: () => number;
|
|
364
|
+
readonly expectedContentHash: string;
|
|
365
|
+
readonly expectedSiteId: string;
|
|
366
|
+
}
|
|
367
|
+
/** Builds a bounded exact-match index once; no semantic or probabilistic matching is performed. */
|
|
368
|
+
declare const createDeterministicAnswerResolver: (artifactInput: VerifiedLocalKnowledgeArtifact | null, options: DeterministicAnswerResolverOptions) => DeterministicAnswerResolver;
|
|
369
|
+
interface DeterministicAnswerAdapterOptions extends DeterministicAnswerResolverOptions {
|
|
370
|
+
readonly artifact: VerifiedLocalKnowledgeArtifact | null;
|
|
371
|
+
readonly fallbackMode: DeterministicSiteConfig['fallback']['mode'];
|
|
372
|
+
readonly fallback?: AdapterFactory;
|
|
373
|
+
readonly backend?: {
|
|
374
|
+
readonly provider?: string;
|
|
375
|
+
readonly model?: string;
|
|
376
|
+
};
|
|
377
|
+
readonly onDecision?: (decision: AnswerResponse) => void | Promise<void>;
|
|
378
|
+
}
|
|
379
|
+
interface DeterministicAnswerAdapter extends AdapterFactory {
|
|
380
|
+
readonly createSourceForSession: (request: AdapterRequest, sessionId: string) => StreamSource;
|
|
381
|
+
readonly releaseChoiceSession: (sessionId: string) => void;
|
|
382
|
+
readonly resolveChoiceSubmission: (frame: ComponentRenderFrame, choiceId: string, context: {
|
|
383
|
+
readonly sessionId: string;
|
|
384
|
+
}) => ChoiceSubmissionReservation | ChoiceSubmissionUnavailable | undefined;
|
|
385
|
+
}
|
|
386
|
+
/** Composes the local answer plane in front of an existing AgentsKit adapter. */
|
|
387
|
+
declare const createDeterministicAnswerAdapter: (options: DeterministicAnswerAdapterOptions) => DeterministicAnswerAdapter;
|
|
388
|
+
|
|
389
|
+
type ChatMessagePresentation = {
|
|
390
|
+
readonly kind: 'message';
|
|
391
|
+
readonly message: Message;
|
|
392
|
+
} | {
|
|
393
|
+
readonly kind: 'component';
|
|
394
|
+
readonly frame: ComponentRenderFrame;
|
|
395
|
+
} | {
|
|
396
|
+
readonly kind: 'diagnostic';
|
|
397
|
+
readonly code: string;
|
|
398
|
+
readonly message: string;
|
|
399
|
+
};
|
|
400
|
+
/** Decodes ordered assistant content and legacy direct component frames for every renderer. */
|
|
401
|
+
declare const presentChatMessage: (message: Message) => readonly ChatMessagePresentation[];
|
|
402
|
+
|
|
403
|
+
declare const ChatThemeSchema: z.ZodReadonly<z.ZodObject<{
|
|
404
|
+
colors: z.ZodReadonly<z.ZodObject<{
|
|
405
|
+
background: z.ZodString;
|
|
406
|
+
surface: z.ZodString;
|
|
407
|
+
border: z.ZodString;
|
|
408
|
+
text: z.ZodString;
|
|
409
|
+
muted: z.ZodString;
|
|
410
|
+
accent: z.ZodString;
|
|
411
|
+
onAccent: z.ZodString;
|
|
412
|
+
danger: z.ZodString;
|
|
413
|
+
}, z.core.$strict>>;
|
|
414
|
+
spacing: z.ZodReadonly<z.ZodObject<{
|
|
415
|
+
small: z.ZodNumber;
|
|
416
|
+
medium: z.ZodNumber;
|
|
417
|
+
large: z.ZodNumber;
|
|
418
|
+
}, z.core.$strict>>;
|
|
419
|
+
radius: z.ZodReadonly<z.ZodObject<{
|
|
420
|
+
medium: z.ZodNumber;
|
|
421
|
+
large: z.ZodNumber;
|
|
422
|
+
}, z.core.$strict>>;
|
|
423
|
+
fontFamily: z.ZodString;
|
|
424
|
+
}, z.core.$strict>>;
|
|
425
|
+
type ChatTheme = z.infer<typeof ChatThemeSchema>;
|
|
426
|
+
type ChatThemeInput = {
|
|
427
|
+
readonly colors?: Partial<ChatTheme['colors']>;
|
|
428
|
+
readonly spacing?: Partial<ChatTheme['spacing']>;
|
|
429
|
+
readonly radius?: Partial<ChatTheme['radius']>;
|
|
430
|
+
readonly fontFamily?: string;
|
|
431
|
+
};
|
|
432
|
+
declare const defaultChatTheme: ChatTheme;
|
|
433
|
+
declare const resolveChatTheme: (input?: unknown) => ChatTheme;
|
|
434
|
+
declare const getLifecycleTargets: (messages: readonly Message[]) => {
|
|
435
|
+
readonly userId: string | undefined;
|
|
436
|
+
readonly assistantId: string | undefined;
|
|
437
|
+
};
|
|
438
|
+
interface TrustedActionContext {
|
|
439
|
+
readonly sessionId: string;
|
|
440
|
+
readonly capabilities: readonly string[];
|
|
441
|
+
}
|
|
442
|
+
type ActionPolicyReason = 'allowed' | 'missing-context' | 'session-mismatch' | 'action-unregistered' | 'missing-capability' | 'composed-policy-denied' | 'policy-failure';
|
|
443
|
+
interface ActionPolicyTrace {
|
|
444
|
+
readonly id: string;
|
|
445
|
+
readonly toolCallId: string;
|
|
446
|
+
readonly action: string;
|
|
447
|
+
readonly phase: 'propose' | 'execute';
|
|
448
|
+
readonly decision: 'allow' | 'deny';
|
|
449
|
+
readonly reason: ActionPolicyReason;
|
|
450
|
+
readonly requiredCapabilities: readonly string[];
|
|
451
|
+
readonly timestamp: number;
|
|
452
|
+
}
|
|
453
|
+
interface ActionPolicy {
|
|
454
|
+
readonly authorizeToolCall: ToolAuthorizer;
|
|
455
|
+
readonly compose: (authorizer?: ToolAuthorizer) => ToolAuthorizer;
|
|
456
|
+
readonly getTrace: () => readonly ActionPolicyTrace[];
|
|
457
|
+
}
|
|
458
|
+
interface CapabilityPolicyOptions {
|
|
459
|
+
readonly sessionId: string;
|
|
460
|
+
readonly getContext: () => TrustedActionContext | undefined;
|
|
461
|
+
readonly requirements: Readonly<Record<string, readonly string[]>>;
|
|
462
|
+
readonly onTrace?: (trace: ActionPolicyTrace) => void | Promise<void>;
|
|
463
|
+
readonly now?: () => number;
|
|
464
|
+
}
|
|
465
|
+
declare const createCapabilityPolicy: ({ sessionId, getContext, requirements, onTrace, now }: CapabilityPolicyOptions) => ActionPolicy;
|
|
466
|
+
declare const withActionPolicy: (chat: ChatConfig, policy: ActionPolicy) => ChatConfig;
|
|
467
|
+
declare const resolveChoiceAction: (frame: ComponentRenderFrame, choiceId: string) => ChoiceAction | undefined;
|
|
468
|
+
type ActionConfirmationStatus = 'pending' | 'approving' | 'rejecting' | 'expiring' | 'approved' | 'rejected' | 'expired';
|
|
469
|
+
interface ActionConfirmation {
|
|
470
|
+
readonly token: string;
|
|
471
|
+
readonly sessionId: string;
|
|
472
|
+
readonly action: string;
|
|
473
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
474
|
+
readonly toolCallId: string;
|
|
475
|
+
readonly expiresAt: number;
|
|
476
|
+
readonly status: ActionConfirmationStatus;
|
|
477
|
+
}
|
|
478
|
+
interface ActionConfirmationCoordinator {
|
|
479
|
+
readonly propose: (action: ChoiceAction) => Promise<ActionConfirmation>;
|
|
480
|
+
readonly approve: (token: string, sessionId: string) => Promise<ActionConfirmation>;
|
|
481
|
+
readonly reject: (token: string, sessionId: string, reason?: string) => Promise<ActionConfirmation>;
|
|
482
|
+
readonly getByToolCall: (toolCallId: string) => ActionConfirmation | undefined;
|
|
483
|
+
readonly getSnapshot: () => readonly ActionConfirmation[];
|
|
484
|
+
}
|
|
485
|
+
interface ActionConfirmationOptions {
|
|
486
|
+
readonly sessionId: string;
|
|
487
|
+
readonly chat: Pick<ChatReturn, 'proposeToolCall' | 'approve' | 'deny'>;
|
|
488
|
+
readonly ttlMs?: number;
|
|
489
|
+
readonly now?: () => number;
|
|
490
|
+
readonly createId?: () => string;
|
|
491
|
+
readonly initialRecords?: readonly SessionConfirmation[];
|
|
492
|
+
readonly onChange?: (records: readonly ActionConfirmation[]) => void | Promise<void>;
|
|
493
|
+
readonly claimStatus?: (record: ActionConfirmation, status: Exclude<ActionConfirmationStatus, 'pending'>) => boolean | Promise<boolean>;
|
|
494
|
+
}
|
|
495
|
+
declare const createActionConfirmation: ({ sessionId, chat, ttlMs, now, createId, initialRecords, onChange, claimStatus, }: ActionConfirmationOptions) => ActionConfirmationCoordinator;
|
|
496
|
+
type ComponentManifest = Readonly<Record<string, ComponentDefinition<unknown>>>;
|
|
497
|
+
declare const defineComponentManifest: (components: readonly ComponentDefinition<unknown>[]) => ComponentManifest;
|
|
498
|
+
type ResolveComponentFrameResult<T = unknown> = {
|
|
499
|
+
readonly ok: true;
|
|
500
|
+
readonly frame: ComponentRenderFrame;
|
|
501
|
+
readonly props: T;
|
|
502
|
+
} | {
|
|
503
|
+
readonly ok: false;
|
|
504
|
+
readonly diagnostic: {
|
|
505
|
+
readonly code: 'COMPONENT_UNKNOWN' | 'COMPONENT_INVALID_PROPS' | _agentskit_chat_protocol.ComponentDecodeCode;
|
|
506
|
+
readonly message: string;
|
|
507
|
+
readonly retryable: false;
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
declare const resolveComponentFrame: (input: unknown, manifest: ComponentManifest) => ResolveComponentFrameResult;
|
|
511
|
+
declare const createComponentInteraction: (frame: ComponentRenderFrame, manifest: ComponentManifest, event: string, value?: unknown) => ComponentInteractionEvent;
|
|
512
|
+
declare const resolveComponentFallback: (input: unknown, manifest: ComponentManifest) => string | undefined;
|
|
513
|
+
type ResolveChoiceListFrameResult = ResolveComponentFrameResult<ChoiceListProps>;
|
|
514
|
+
declare const resolveChoiceListFrame: (input: unknown, manifest: ComponentManifest) => ResolveChoiceListFrameResult;
|
|
515
|
+
declare const selectChoice: (frame: ComponentRenderFrame, choiceId: string) => ComponentSelectionEvent;
|
|
516
|
+
type TurnTraceKind = 'deterministic' | 'agentic' | 'repaired' | 'fallback';
|
|
517
|
+
interface TurnTrace {
|
|
518
|
+
readonly kind: TurnTraceKind;
|
|
519
|
+
readonly routeId?: string;
|
|
520
|
+
readonly fromState: string;
|
|
521
|
+
readonly toState: string;
|
|
522
|
+
}
|
|
523
|
+
interface ConversationStateDefinition {
|
|
524
|
+
readonly on?: Readonly<Record<string, string>>;
|
|
525
|
+
readonly actions?: readonly string[];
|
|
526
|
+
}
|
|
527
|
+
interface DeterministicRoute {
|
|
528
|
+
readonly id: string;
|
|
529
|
+
readonly event: string;
|
|
530
|
+
readonly states?: readonly string[];
|
|
531
|
+
readonly match: (input: string) => boolean;
|
|
532
|
+
readonly response: (input: string, context: DeterministicRouteContext) => string;
|
|
533
|
+
readonly traceKind?: Exclude<TurnTraceKind, 'agentic'>;
|
|
534
|
+
}
|
|
535
|
+
interface DeterministicRouteContext {
|
|
536
|
+
readonly sessionId: string;
|
|
537
|
+
readonly messageId?: string;
|
|
538
|
+
}
|
|
539
|
+
interface ConversationDefinition {
|
|
540
|
+
readonly initial: string;
|
|
541
|
+
readonly states: Readonly<Record<string, ConversationStateDefinition>>;
|
|
542
|
+
readonly routes: readonly DeterministicRoute[];
|
|
543
|
+
readonly onTrace?: (trace: TurnTrace) => void | Promise<void>;
|
|
544
|
+
}
|
|
545
|
+
interface ChatDefinition {
|
|
546
|
+
readonly id: string;
|
|
547
|
+
readonly revision?: number;
|
|
548
|
+
readonly chat: ChatConfig;
|
|
549
|
+
readonly conversation?: ConversationDefinition;
|
|
550
|
+
readonly components?: ComponentManifest;
|
|
551
|
+
readonly choiceSubmission?: (frame: ComponentRenderFrame, choiceId: string, context: {
|
|
552
|
+
readonly sessionId: string;
|
|
553
|
+
}) => ChoiceSubmissionReservation | ChoiceSubmissionUnavailable | undefined;
|
|
554
|
+
}
|
|
555
|
+
interface ChoiceSubmissionReservation {
|
|
556
|
+
readonly value: string;
|
|
557
|
+
readonly commit: () => void;
|
|
558
|
+
readonly release: () => void;
|
|
559
|
+
}
|
|
560
|
+
interface ChoiceSubmissionUnavailable {
|
|
561
|
+
readonly unavailable: true;
|
|
562
|
+
}
|
|
563
|
+
declare const defineChat: <const T extends ChatDefinition>(definition: T) => T;
|
|
564
|
+
interface ConversationSnapshot {
|
|
565
|
+
readonly state: string;
|
|
566
|
+
readonly events: readonly string[];
|
|
567
|
+
readonly actions: readonly string[];
|
|
568
|
+
}
|
|
569
|
+
interface ChatSession {
|
|
570
|
+
readonly sessionId: string;
|
|
571
|
+
readonly definitionId: string;
|
|
572
|
+
readonly definitionRevision: number;
|
|
573
|
+
readonly chat: ChatConfig;
|
|
574
|
+
readonly updateChat: (chat: ChatConfig) => ChatConfig;
|
|
575
|
+
readonly getConversationSnapshot: () => ConversationSnapshot | undefined;
|
|
576
|
+
readonly createConfirmation: (options: Omit<ActionConfirmationOptions, 'sessionId' | 'initialRecords' | 'onChange' | 'claimStatus'>) => ActionConfirmationCoordinator;
|
|
577
|
+
readonly persist: (signal?: AbortSignal) => Promise<void>;
|
|
578
|
+
readonly getCursor: () => number;
|
|
579
|
+
readonly claimTurn: (turnId: string, leaseMs: number, signal?: AbortSignal) => Promise<boolean>;
|
|
580
|
+
readonly releaseTurn: (turnId: string, outcome: 'completed' | 'indeterminate', signal?: AbortSignal) => Promise<void>;
|
|
581
|
+
}
|
|
582
|
+
interface SessionStorage {
|
|
583
|
+
readonly load: (sessionId: string, signal?: AbortSignal) => unknown | Promise<unknown>;
|
|
584
|
+
readonly save: (snapshot: SessionSnapshot, expectedCursor: number | undefined, signal?: AbortSignal) => boolean | Promise<boolean>;
|
|
585
|
+
readonly delete?: (sessionId: string, signal?: AbortSignal) => void | Promise<void>;
|
|
586
|
+
}
|
|
587
|
+
interface ChatSessionOptions {
|
|
588
|
+
readonly sessionId?: string;
|
|
589
|
+
readonly snapshot?: SessionSnapshot;
|
|
590
|
+
readonly storage?: SessionStorage;
|
|
591
|
+
readonly now?: () => Date;
|
|
592
|
+
readonly signal?: AbortSignal;
|
|
593
|
+
readonly onConfirmationChange?: (records: readonly ActionConfirmation[]) => void | Promise<void>;
|
|
594
|
+
}
|
|
595
|
+
interface ResumeChatSessionOptions {
|
|
596
|
+
readonly sessionId: string;
|
|
597
|
+
readonly storage: SessionStorage;
|
|
598
|
+
readonly now?: () => Date;
|
|
599
|
+
readonly signal?: AbortSignal;
|
|
600
|
+
}
|
|
601
|
+
declare class SessionConflictError extends Error {
|
|
602
|
+
constructor();
|
|
603
|
+
}
|
|
604
|
+
declare const createChatSession: (definition: ChatDefinition, options?: ChatSessionOptions) => ChatSession;
|
|
605
|
+
declare const resumeChatSession: (definition: ChatDefinition, options: ResumeChatSessionOptions) => Promise<ChatSession>;
|
|
606
|
+
declare const resolveChatSession: (definition: ChatDefinition, session?: ChatSession) => ChatSession;
|
|
607
|
+
declare const commandRoute: (options: Omit<DeterministicRoute, "match"> & {
|
|
608
|
+
readonly command: string;
|
|
609
|
+
}) => DeterministicRoute;
|
|
610
|
+
declare const SemanticFallbackSchema: z.ZodReadonly<z.ZodObject<{
|
|
611
|
+
kind: z.ZodString;
|
|
612
|
+
summary: z.ZodString;
|
|
613
|
+
}, z.core.$strip>>;
|
|
614
|
+
type SemanticFallback = z.infer<typeof SemanticFallbackSchema>;
|
|
615
|
+
declare const parseSemanticFallback: (input: unknown) => SemanticFallback;
|
|
616
|
+
declare const formatSemanticFallback: (fallback: SemanticFallback) => string;
|
|
617
|
+
|
|
618
|
+
export { type ActionConfirmation, type ActionConfirmationCoordinator, type ActionConfirmationOptions, type ActionConfirmationStatus, type ActionPolicy, type ActionPolicyReason, type ActionPolicyTrace, ApprovalRequestComponent, ApprovalRequestPropsSchema, type AskAdapterOptions, type AskMemoryOptions, type AskProjection, type AskToolProjector, ButtonGroupComponent, ButtonGroupPropsSchema, CHOICE_LIST_COMPONENT_KEY, type CapabilityPolicyOptions, type ChatDefinition, type ChatMessagePresentation, type ChatSession, type ChatSessionOptions, type ChatTheme, type ChatThemeInput, ChatThemeSchema, type ChoiceAction, ChoiceListComponent, type ChoiceListProps, ChoiceListPropsSchema, type ChoiceSubmissionReservation, type ChoiceSubmissionUnavailable, type ComponentAccessibilityDefinition, type ComponentCapability, type ComponentDefinition, type ComponentEventDefinition, type ComponentManifest, ConfirmationComponent, ConfirmationPropsSchema, type ConversationDefinition, type ConversationSnapshot, type ConversationStateDefinition, type DeterministicAnswerAdapter, type DeterministicAnswerAdapterOptions, type DeterministicAnswerResolver, type DeterministicAnswerResolverOptions, type DeterministicRoute, type DeterministicRouteContext, ErrorNoticeComponent, ErrorNoticePropsSchema, FileAttachmentComponent, FileAttachmentPropsSchema, FormComponent, FormPropsSchema, LinkCardComponent, LinkCardPropsSchema, ProgressComponent, ProgressPropsSchema, type ResolveChoiceListFrameResult, type ResolveComponentFrameResult, type ResumeChatSessionOptions, STANDARD_COMPONENT_KEYS, type SemanticFallback, SemanticFallbackSchema, SessionConflictError, type SessionStorage, SourceListComponent, SourceListPropsSchema, StandardComponentCatalog, TableComponent, TablePropsSchema, ToolCallComponent, ToolCallPropsSchema, type TrustedActionContext, type TurnTrace, type TurnTraceKind, commandRoute, createActionConfirmation, createAskAdapter, createAskSessionMemory, createCapabilityPolicy, createChatSession, createComponentInteraction, createDeterministicAnswerAdapter, createDeterministicAnswerResolver, defaultChatTheme, defineChat, defineComponentManifest, formatSemanticFallback, getLifecycleTargets, normalizeDeterministicQuery, parseSemanticFallback, presentChatMessage, projectAskEvent, projectAskMessages, resolveChatSession, resolveChatTheme, resolveChoiceAction, resolveChoiceListFrame, resolveComponentFallback, resolveComponentFrame, resumeChatSession, selectChoice, validateStandardComponentInteraction, withActionPolicy };
|