@useago/sdk 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/AgoClient-DF7M2WAz.js +575 -0
  2. package/dist/AgoClient-bjN-z2ZQ.cjs +6 -0
  3. package/dist/angular.cjs +1 -143
  4. package/dist/angular.d.cts +530 -0
  5. package/dist/angular.d.ts +530 -2
  6. package/dist/angular.js +71 -139
  7. package/dist/createMockClient-D6uVh-B9.js +254 -0
  8. package/dist/createMockClient-DecMEUcK.cjs +1 -0
  9. package/dist/devtools.cjs +4 -78
  10. package/dist/devtools.d.cts +443 -0
  11. package/dist/devtools.d.ts +443 -2
  12. package/dist/devtools.js +46 -71
  13. package/dist/functions-Bz-1Bs3I.cjs +1 -0
  14. package/dist/functions-DdROP6Ui.js +312 -0
  15. package/dist/helpers.cjs +1 -15
  16. package/dist/{helpers/functions.d.ts → helpers.d.cts} +121 -62
  17. package/dist/helpers.d.ts +121 -2
  18. package/dist/helpers.js +16 -2
  19. package/dist/index.cjs +1 -347
  20. package/dist/index.d.cts +1150 -0
  21. package/dist/index.d.ts +1150 -20
  22. package/dist/index.js +128 -298
  23. package/dist/react.cjs +31 -22438
  24. package/dist/react.d.cts +960 -0
  25. package/dist/react.d.ts +960 -2
  26. package/dist/react.js +8401 -22376
  27. package/dist/rolldown-runtime-CaekUdDJ.cjs +1 -0
  28. package/dist/rolldown-runtime-DxmricAu.js +25 -0
  29. package/dist/vue.cjs +1 -336
  30. package/dist/vue.d.cts +1063 -0
  31. package/dist/vue.d.ts +1063 -2
  32. package/dist/vue.js +174 -316
  33. package/dist/{widget/types.d.ts → widget.d.cts} +41 -43
  34. package/dist/widget.d.ts +41 -2
  35. package/package.json +35 -24
  36. package/dist/AgoClient-DPZdN5n2.js +0 -905
  37. package/dist/AgoClient-DPZdN5n2.js.map +0 -1
  38. package/dist/AgoClient-wMVUQqCD.cjs +0 -976
  39. package/dist/AgoClient-wMVUQqCD.cjs.map +0 -1
  40. package/dist/angular/ago.service.d.ts +0 -98
  41. package/dist/angular/index.d.ts +0 -4
  42. package/dist/angular/provide.d.ts +0 -27
  43. package/dist/angular.cjs.map +0 -1
  44. package/dist/angular.js.map +0 -1
  45. package/dist/api/HttpClient.d.ts +0 -31
  46. package/dist/api/index.d.ts +0 -1
  47. package/dist/auto/createAgo.d.ts +0 -39
  48. package/dist/auto/index.d.ts +0 -1
  49. package/dist/client/AgoClient.d.ts +0 -169
  50. package/dist/client/errors.d.ts +0 -48
  51. package/dist/client/index.d.ts +0 -3
  52. package/dist/client/types.d.ts +0 -205
  53. package/dist/createMockClient-Ci_N2tH8.cjs +0 -104
  54. package/dist/createMockClient-Ci_N2tH8.cjs.map +0 -1
  55. package/dist/createMockClient-U0ae_AYy.js +0 -99
  56. package/dist/createMockClient-U0ae_AYy.js.map +0 -1
  57. package/dist/devtools/index.d.ts +0 -2
  58. package/dist/devtools/initDevPanel.d.ts +0 -15
  59. package/dist/devtools.cjs.map +0 -1
  60. package/dist/devtools.js.map +0 -1
  61. package/dist/functions/FunctionRegistry.d.ts +0 -41
  62. package/dist/functions/defineFunction.d.ts +0 -22
  63. package/dist/functions/index.d.ts +0 -2
  64. package/dist/functions/types.d.ts +0 -50
  65. package/dist/functions--c6lx3ic.cjs +0 -480
  66. package/dist/functions--c6lx3ic.cjs.map +0 -1
  67. package/dist/functions-C9F1dnmh.js +0 -398
  68. package/dist/functions-C9F1dnmh.js.map +0 -1
  69. package/dist/helpers/factory.d.ts +0 -20
  70. package/dist/helpers/index.d.ts +0 -1
  71. package/dist/index.cjs.map +0 -1
  72. package/dist/index.js.map +0 -1
  73. package/dist/react/components/ChatInput.d.ts +0 -12
  74. package/dist/react/components/ChatWidget.d.ts +0 -35
  75. package/dist/react/components/Markdown.d.ts +0 -12
  76. package/dist/react/components/Message.d.ts +0 -9
  77. package/dist/react/components/index.d.ts +0 -8
  78. package/dist/react/context/AgoContext.d.ts +0 -62
  79. package/dist/react/context/index.d.ts +0 -2
  80. package/dist/react/hooks/index.d.ts +0 -7
  81. package/dist/react/hooks/useAgo.d.ts +0 -14
  82. package/dist/react/hooks/useAgoContext.d.ts +0 -40
  83. package/dist/react/hooks/useAgoFunction.d.ts +0 -58
  84. package/dist/react/hooks/useAgoStore.d.ts +0 -17
  85. package/dist/react/hooks/useChat.d.ts +0 -45
  86. package/dist/react/hooks/useConversation.d.ts +0 -28
  87. package/dist/react/hooks/useMessages.d.ts +0 -26
  88. package/dist/react/index.d.ts +0 -24
  89. package/dist/react/testing.d.ts +0 -2
  90. package/dist/react.cjs.map +0 -1
  91. package/dist/react.js.map +0 -1
  92. package/dist/rolldown-runtime-BqCkTl7Q.cjs +0 -50
  93. package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
  94. package/dist/state/ClientContextRegistry.d.ts +0 -64
  95. package/dist/state/createStore.d.ts +0 -30
  96. package/dist/streaming/SSEHandler.d.ts +0 -46
  97. package/dist/streaming/helpers.d.ts +0 -67
  98. package/dist/streaming/index.d.ts +0 -2
  99. package/dist/testing/createMockClient.d.ts +0 -42
  100. package/dist/testing/index.d.ts +0 -2
  101. package/dist/utils/eventEmitter.d.ts +0 -23
  102. package/dist/utils/index.d.ts +0 -2
  103. package/dist/utils/logger.d.ts +0 -14
  104. package/dist/vue/composables/useAgo.d.ts +0 -17
  105. package/dist/vue/composables/useAgoEvents.d.ts +0 -11
  106. package/dist/vue/composables/useAgoFunction.d.ts +0 -34
  107. package/dist/vue/composables/useAgoStore.d.ts +0 -18
  108. package/dist/vue/composables/useChat.d.ts +0 -251
  109. package/dist/vue/composables/useConversation.d.ts +0 -178
  110. package/dist/vue/composables/useMessages.d.ts +0 -89
  111. package/dist/vue/index.d.ts +0 -11
  112. package/dist/vue/plugin.d.ts +0 -16
  113. package/dist/vue/symbols.d.ts +0 -3
  114. package/dist/vue.cjs.map +0 -1
  115. package/dist/vue.js.map +0 -1
  116. package/dist/widget/index.d.ts +0 -1
@@ -0,0 +1,960 @@
1
+ import { default as default_2 } from 'react';
2
+
3
+ /**
4
+ * Agent information
5
+ */
6
+ export declare interface AgoAgent {
7
+ id: string;
8
+ name: string;
9
+ displayName?: string;
10
+ }
11
+
12
+ /**
13
+ * Main SDK client for AGO Chat integration
14
+ */
15
+ declare class AgoClient {
16
+ private httpClient;
17
+ private functionRegistry;
18
+ private contextRegistry;
19
+ private eventEmitter;
20
+ private config;
21
+ constructor(config: AgoConfig);
22
+ /**
23
+ * Send a message and receive a streaming response
24
+ */
25
+ sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
26
+ private processSSEResponse;
27
+ private handleClientFunctionInvocation;
28
+ /**
29
+ * Get list of conversations
30
+ */
31
+ getConversations(): Promise<Conversation[]>;
32
+ /**
33
+ * Get a specific conversation with messages
34
+ */
35
+ getConversation(conversationId: string): Promise<Conversation>;
36
+ /**
37
+ * Get messages for a conversation
38
+ */
39
+ getMessages(conversationId: string): Promise<AgoMessage[]>;
40
+ /**
41
+ * Submit form data for a tool call
42
+ */
43
+ submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<void>;
44
+ /**
45
+ * Confirm a tool call
46
+ */
47
+ confirmToolCall(toolCallId: string): Promise<void>;
48
+ /**
49
+ * Reject a tool call
50
+ */
51
+ rejectToolCall(toolCallId: string): Promise<void>;
52
+ /**
53
+ * Relay a completed form collector's values to a server-configured destination.
54
+ *
55
+ * Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
56
+ * the browser never holds the destination URL or its secret — the backend resolves
57
+ * `destination` (a named, opted-in tool) and forwards the values from the server.
58
+ */
59
+ submitFormCollector(destination: string, values: Record<string, unknown>): Promise<unknown>;
60
+ /**
61
+ * Submit feedback for a message
62
+ */
63
+ submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
64
+ /**
65
+ * Register a client-side function that AGO can call.
66
+ * Accepts either a definition object or (name, handler, schema) args.
67
+ *
68
+ * ```ts
69
+ * // Single-object (preferred)
70
+ * client.registerFunction({
71
+ * name: "lookupOrder",
72
+ * description: "Look up an order",
73
+ * parameters: { type: "object", properties: { id: { type: "string" } } },
74
+ * handler: async (args) => fetchOrder(args.id),
75
+ * });
76
+ *
77
+ * // Classic 3-arg form
78
+ * client.registerFunction("lookupOrder", handler, schema);
79
+ * ```
80
+ */
81
+ registerFunction(definition: ClientFunctionDefinition): void;
82
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
83
+ /**
84
+ * Short alias for `registerFunction`. Also accepts an array of definitions.
85
+ *
86
+ * ```ts
87
+ * client.register(lookupOrder);
88
+ * client.register([lookupOrder, cancelOrder]);
89
+ * ```
90
+ */
91
+ register(definition: ClientFunctionDefinition | ClientFunctionDefinition[]): void;
92
+ /**
93
+ * Unregister a client-side function
94
+ */
95
+ unregisterFunction(name: string): boolean;
96
+ /**
97
+ * Get all registered function schemas
98
+ */
99
+ getRegisteredFunctions(): ClientFunctionSchema[];
100
+ /**
101
+ * Register a navigation function that lets AGO navigate users to different pages.
102
+ * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
103
+ * @param routes - Map of route names to paths, with descriptions for the LLM
104
+ */
105
+ registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
106
+ name: string;
107
+ path: string;
108
+ description: string;
109
+ }>): void;
110
+ /**
111
+ * Register or update a piece of client-side context.
112
+ * This context is sent with every message so the AI understands the user's situation.
113
+ *
114
+ * ```ts
115
+ * client.setContext("order-page", {
116
+ * name: "Order detail",
117
+ * description: "User is viewing order #123",
118
+ * data: { orderId: "123", status: "shipped" },
119
+ * });
120
+ * ```
121
+ */
122
+ setContext(key: string, entry: ContextEntry): void;
123
+ /**
124
+ * Remove a previously registered context entry.
125
+ */
126
+ removeContext(key: string): boolean;
127
+ /**
128
+ * Register a dynamic context provider. The callback is invoked every time
129
+ * a message is sent, so the AI always gets the freshest data.
130
+ *
131
+ * Use this for context that lives outside React state — global stores,
132
+ * refs, or computed values.
133
+ *
134
+ * ```ts
135
+ * client.addDynamicContext("cart", () => ({
136
+ * name: "Checkout",
137
+ * data: { itemCount: cart.items.length, total: cart.total },
138
+ * }));
139
+ * ```
140
+ */
141
+ addDynamicContext(key: string, provider: DynamicContextProvider): void;
142
+ /**
143
+ * Remove a dynamic context provider.
144
+ */
145
+ removeDynamicContext(key: string): boolean;
146
+ /**
147
+ * Enable automatic capture of the current browser page (URL + title).
148
+ * Injected as a dynamic context entry named `browser-page`.
149
+ */
150
+ enableAutoPageContext(): void;
151
+ /**
152
+ * Get the current context snapshot.
153
+ */
154
+ getContextSnapshot(): ContextSnapshot | null;
155
+ /**
156
+ * Subscribe to an event
157
+ */
158
+ on<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
159
+ /**
160
+ * Unsubscribe from an event
161
+ */
162
+ off<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
163
+ /**
164
+ * Subscribe to an event once — auto-unsubscribes after the first call.
165
+ */
166
+ once<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
167
+ /**
168
+ * Returns a Promise that resolves the next time `event` fires.
169
+ *
170
+ * ```ts
171
+ * const msg = await client.waitFor("message:complete", { timeout: 10000 });
172
+ * ```
173
+ */
174
+ waitFor<K extends AgoEventName>(event: K, options?: {
175
+ timeout?: number;
176
+ }): Promise<AgoClientEvents[K]>;
177
+ /**
178
+ * Update client configuration
179
+ */
180
+ updateConfig(config: Partial<AgoConfig>): void;
181
+ /**
182
+ * Clean up resources
183
+ */
184
+ destroy(): void;
185
+ }
186
+
187
+ /**
188
+ * SDK Events
189
+ */
190
+ declare interface AgoClientEvents {
191
+ "message:start": {
192
+ conversationId: string;
193
+ messageId: string;
194
+ };
195
+ "message:chunk": {
196
+ content: string;
197
+ conversationId: string;
198
+ messageId: string;
199
+ };
200
+ "message:complete": AgoMessage;
201
+ "message:error": {
202
+ error: string;
203
+ conversationId?: string;
204
+ messageId?: string;
205
+ };
206
+ "toolCall:received": ToolCallData;
207
+ "toolCall:form": ToolCallData;
208
+ "function:invoke": ClientFunctionInvocation;
209
+ "function:result": {
210
+ invocationId: string;
211
+ result: unknown;
212
+ error?: string;
213
+ };
214
+ "connection:status": {
215
+ connected: boolean;
216
+ };
217
+ }
218
+
219
+ /**
220
+ * SDK Configuration
221
+ */
222
+ export declare interface AgoConfig {
223
+ /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
224
+ baseUrl: string;
225
+ /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
226
+ widgetId?: string;
227
+ /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
228
+ agent?: string;
229
+ /** Default agent ID for new conversations. Prefer `agent`. */
230
+ defaultAgentId?: string;
231
+ /** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
232
+ permission?: string;
233
+ /** User email for identification */
234
+ userEmail?: string;
235
+ /** JWT token for authenticated users */
236
+ userJwt?: string;
237
+ /** Enable debug logging */
238
+ debug?: boolean;
239
+ }
240
+
241
+ /**
242
+ * Top-level declarative configuration for the `AgoProvider`.
243
+ *
244
+ * - `tools` — full function definitions to expose to the AI app-wide
245
+ * - `helpers` — map of pre-built helper name → handler override (or `true` for default)
246
+ * - `pageContext` — `"auto"` enables automatic URL/title capture
247
+ */
248
+ export declare interface AgoDeclarativeConfig {
249
+ tools?: ClientFunctionDefinition[];
250
+ helpers?: Record<string, ClientFunctionHandler | true>;
251
+ pageContext?: "auto" | "manual";
252
+ }
253
+
254
+ declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
255
+
256
+ declare type AgoEventName = keyof AgoClientEvents;
257
+
258
+ /**
259
+ * Message from AGO
260
+ */
261
+ export declare interface AgoMessage {
262
+ id: string;
263
+ conversationId: string;
264
+ content: string;
265
+ role: "user" | "assistant";
266
+ status: MessageStatus;
267
+ agent?: AgoAgent;
268
+ sources?: AgoSource[];
269
+ toolCalls?: ToolCallData[];
270
+ followUpReplies?: string[];
271
+ createdAt: Date;
272
+ }
273
+
274
+ /**
275
+ * Provides an AgoClient to all descendant components via React context.
276
+ *
277
+ * ```tsx
278
+ * // Minimal setup
279
+ * <AgoProvider baseUrl="https://YOUR-DOMAIN.useago.com">
280
+ * <App />
281
+ * </AgoProvider>
282
+ *
283
+ * // Declarative config — tools, helpers, page context
284
+ * <AgoProvider
285
+ * baseUrl="https://YOUR-DOMAIN.useago.com"
286
+ * tools={[lookupOrder, cancelOrder]}
287
+ * helpers={{
288
+ * showToast: (args) => toast(args.message as string),
289
+ * copyToClipboard: true, // use default handler
290
+ * }}
291
+ * pageContext="auto"
292
+ * >
293
+ * <App />
294
+ * </AgoProvider>
295
+ *
296
+ * // With a pre-built client (useful for testing)
297
+ * <AgoProvider client={myClient}>
298
+ * <App />
299
+ * </AgoProvider>
300
+ * ```
301
+ */
302
+ export declare const AgoProvider: default_2.FC<AgoProviderProps>;
303
+
304
+ export declare type AgoProviderProps = {
305
+ children: default_2.ReactNode;
306
+ } & AgoDeclarativeConfig & (({
307
+ client: AgoClient;
308
+ } & Partial<Record<keyof AgoConfig, never>>) | ({
309
+ client?: never;
310
+ } & AgoConfig));
311
+
312
+ export declare interface AgoRoute {
313
+ name: string;
314
+ path: string;
315
+ description: string;
316
+ }
317
+
318
+ /**
319
+ * Knowledge source citation
320
+ */
321
+ export declare interface AgoSource {
322
+ id: string;
323
+ title: string;
324
+ url?: string;
325
+ }
326
+
327
+ /**
328
+ * Chat input component with send button
329
+ */
330
+ export declare const ChatInput: default_2.FC<ChatInputProps>;
331
+
332
+ export declare interface ChatInputProps {
333
+ onSend: (message: string, files?: File[]) => void;
334
+ disabled?: boolean;
335
+ placeholder?: string;
336
+ allowFiles?: boolean;
337
+ className?: string;
338
+ }
339
+
340
+ /**
341
+ * Pre-built chat widget component
342
+ */
343
+ export declare const ChatWidget: default_2.FC<ChatWidgetProps>;
344
+
345
+ export declare interface ChatWidgetProps {
346
+ /** The AGO client instance. If omitted, reads from AgoProvider context. */
347
+ client?: AgoClient;
348
+ /** Initial conversation ID */
349
+ conversationId?: string;
350
+ /** Widget title */
351
+ title?: string;
352
+ /** Welcome message shown when no messages */
353
+ welcomeMessage?: string;
354
+ /** Input placeholder */
355
+ placeholder?: string;
356
+ /** Enable file attachments */
357
+ allowFiles?: boolean;
358
+ /** Widget height */
359
+ height?: string | number;
360
+ /** URL of a logo to display in the header */
361
+ logoUrl?: string;
362
+ /** Show the agent name above assistant messages. Defaults to `true`. */
363
+ showAgentName?: boolean;
364
+ /** Additional CSS class */
365
+ className?: string;
366
+ /** Callback when a message is sent */
367
+ onMessageSent?: (content: string) => void;
368
+ /** Callback when a message is received */
369
+ onMessageReceived?: (message: {
370
+ id: string;
371
+ content: string;
372
+ }) => void;
373
+ }
374
+
375
+ /**
376
+ * Single-object function definition — combines name, schema, and handler.
377
+ *
378
+ * ```ts
379
+ * const fn = defineFunction({
380
+ * name: "lookupOrder",
381
+ * description: "Look up an order by ID",
382
+ * parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
383
+ * handler: async (args) => fetchOrder(args.id as string),
384
+ * });
385
+ * client.registerFunction(fn);
386
+ * ```
387
+ */
388
+ declare interface ClientFunctionDefinition {
389
+ name: string;
390
+ description: string;
391
+ parameters: ClientFunctionSchema["parameters"];
392
+ handler: ClientFunctionHandler;
393
+ }
394
+
395
+ /**
396
+ * Function handler type
397
+ */
398
+ declare type ClientFunctionHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
399
+
400
+ declare interface ClientFunctionInvocation {
401
+ invocationId: string;
402
+ functionName: string;
403
+ arguments: Record<string, unknown>;
404
+ conversationId: string;
405
+ }
406
+
407
+ /**
408
+ * Schema for a client-side function that AGO can call
409
+ */
410
+ declare interface ClientFunctionSchema {
411
+ /** Function name (must be unique) */
412
+ name: string;
413
+ /** Description for the LLM to understand when to call this function */
414
+ description: string;
415
+ /** JSON Schema for function parameters */
416
+ parameters: {
417
+ type: "object";
418
+ properties: Record<string, {
419
+ type: string;
420
+ description?: string;
421
+ enum?: string[];
422
+ default?: unknown;
423
+ }>;
424
+ required?: string[];
425
+ };
426
+ }
427
+
428
+ /**
429
+ * A single piece of context the client wants the LLM to know about.
430
+ */
431
+ declare interface ContextEntry {
432
+ /** Human-readable label (e.g. "Order detail", "Current user") */
433
+ name?: string;
434
+ /** Short description of what this context represents */
435
+ description?: string;
436
+ /** Arbitrary structured data the AI should know about */
437
+ data?: Record<string, unknown>;
438
+ }
439
+
440
+ /**
441
+ * Serialised client context sent with each message.
442
+ */
443
+ declare interface ContextSnapshot {
444
+ /** All active context entries keyed by their registration key */
445
+ entries: Record<string, ContextEntry>;
446
+ }
447
+
448
+ /**
449
+ * Conversation/Thread
450
+ */
451
+ export declare interface Conversation {
452
+ id: string;
453
+ title: string;
454
+ lastMessageDate: Date;
455
+ messages?: AgoMessage[];
456
+ }
457
+
458
+ declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
459
+ /** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
460
+ name: string;
461
+ /** What the form is, for the LLM. */
462
+ description: string;
463
+ /** The single source of truth for the form's fields. */
464
+ schema: FormCollectorSchema;
465
+ /** How the completed form is submitted. Default: `false` (collect only). */
466
+ submit?: SubmitConfig<V>;
467
+ /** Pre-filled values. */
468
+ initialValues?: Partial<V>;
469
+ }
470
+
471
+ /**
472
+ * Create a mock AgoClient for testing. Works with any framework.
473
+ *
474
+ * ```ts
475
+ * import { createMockClient } from "@useago/sdk/testing";
476
+ *
477
+ * const mock = createMockClient();
478
+ * mock.__emitEvent("message:complete", someMessage);
479
+ * expect(mock.__callsFor("sendMessage")).toHaveLength(1);
480
+ * ```
481
+ */
482
+ export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
483
+
484
+ /**
485
+ * A function that returns a fresh context entry on demand.
486
+ * Evaluated every time a message is sent — use it to pull data from stores,
487
+ * refs, or any source that isn't captured by React state.
488
+ */
489
+ declare type DynamicContextProvider = () => ContextEntry | null | undefined;
490
+
491
+ declare interface FormCollector<V = Record<string, unknown>> {
492
+ name: string;
493
+ /** Observable store driving the form UI (read via `useAgoStore`). */
494
+ store: Store<FormCollectorState<V>>;
495
+ /** Client functions to register: `[update]` or `[update, submit]`. */
496
+ functions: ClientFunctionDefinition[];
497
+ /** Dynamic-context key under which the form state is exposed. */
498
+ contextKey: string;
499
+ /** Dynamic-context provider — re-read on every message. */
500
+ contextProvider: () => ContextEntry;
501
+ /** Register the functions + dynamic context on a client. Returns an uninstall fn. */
502
+ install: (client: AgoClient) => () => void;
503
+ /** Submit the form now (e.g. from a UI button). Blocks until required fields are filled. */
504
+ submit: () => Promise<FormSubmitResult>;
505
+ getValues: () => Partial<V>;
506
+ setValues: (patch: Partial<V>) => void;
507
+ reset: () => void;
508
+ }
509
+
510
+ /**
511
+ * JSON-schema shape of a form's fields — identical to a client function's
512
+ * `parameters`, so one schema feeds the store, the update function, and the
513
+ * dynamic context with no second type.
514
+ */
515
+ declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
516
+
517
+ /** Live state held in the collector's store. */
518
+ declare interface FormCollectorState<V = Record<string, unknown>> {
519
+ /** Field values collected so far. */
520
+ values: Partial<V>;
521
+ /** Required field names still empty. */
522
+ missing: string[];
523
+ /** True when no required field is missing. */
524
+ complete: boolean;
525
+ /** True once a submit succeeded. */
526
+ submitted: boolean;
527
+ }
528
+
529
+ declare interface FormField {
530
+ type: "string" | "number" | "boolean" | "array";
531
+ title?: string;
532
+ description?: string;
533
+ enum?: string[];
534
+ default?: unknown;
535
+ }
536
+
537
+ /**
538
+ * Form schema for tool calls requiring user input
539
+ */
540
+ declare interface FormSchema {
541
+ type: "object";
542
+ properties: Record<string, FormField>;
543
+ required?: string[];
544
+ }
545
+
546
+ /** Result returned by `submit()` / the generated `submit_<name>` function. */
547
+ declare interface FormSubmitResult {
548
+ ok: boolean;
549
+ missing?: string[];
550
+ result?: unknown;
551
+ error?: string;
552
+ }
553
+
554
+ /**
555
+ * Renders markdown content with GitHub-flavored markdown support
556
+ * (tables, task lists, strikethrough, autolinks) and inline-styled
557
+ * element renderers. Used by {@link Message} but exported so consumers
558
+ * building a custom chat UI can render assistant content the same way.
559
+ */
560
+ export declare const Markdown: default_2.FC<MarkdownProps>;
561
+
562
+ export declare interface MarkdownProps {
563
+ /** Raw markdown string to render. */
564
+ content: string;
565
+ }
566
+
567
+ export declare const Message: default_2.FC<MessageProps>;
568
+
569
+ export declare interface MessageProps {
570
+ message: AgoMessage;
571
+ className?: string;
572
+ /** Show the agent name above assistant messages. Defaults to `true`. */
573
+ showAgentName?: boolean;
574
+ }
575
+
576
+ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
577
+
578
+ declare interface MockAgoClient extends AgoClient {
579
+ /**
580
+ * Simulate a server-pushed event.
581
+ * ```ts
582
+ * mock.__emitEvent("message:complete", { id: "1", content: "hi", ... });
583
+ * ```
584
+ */
585
+ __emitEvent<K extends AgoEventName>(event: K, data: AgoClientEvents[K]): void;
586
+ /**
587
+ * All recorded method calls: `[methodName, ...args][]`
588
+ */
589
+ __calls: Array<{
590
+ method: string;
591
+ args: unknown[];
592
+ }>;
593
+ /**
594
+ * Get calls for a specific method.
595
+ */
596
+ __callsFor(method: string): Array<{
597
+ method: string;
598
+ args: unknown[];
599
+ }>;
600
+ }
601
+
602
+ declare interface MockAgoClientOptions {
603
+ overrides?: Partial<Record<string, MockFn>>;
604
+ }
605
+
606
+ declare type MockFn = (...args: any[]) => any;
607
+
608
+ /**
609
+ * Options for sending a message
610
+ */
611
+ declare interface SendMessageOptions {
612
+ /** Existing conversation ID */
613
+ conversationId?: string;
614
+ /** Override default agent */
615
+ agentId?: string;
616
+ /** File attachments */
617
+ files?: File[];
618
+ }
619
+
620
+ /**
621
+ * A minimal observable store: one value, synchronous subscriptions, and
622
+ * optional persistence via {@link PersistOptions} (localStorage by default).
623
+ *
624
+ * ```ts
625
+ * const store = createStore({ count: 0 });
626
+ * store.subscribe((state) => save(state));
627
+ * store.set({ count: 1 }); // listeners fire synchronously
628
+ *
629
+ * const cart = createStore({ items: [] }, { key: "cart" }); // persisted
630
+ * ```
631
+ */
632
+ declare interface Store<T> {
633
+ /** Current state. */
634
+ get(): T;
635
+ /** Replace the state and notify subscribers synchronously. */
636
+ set(next: T): void;
637
+ /** Register a listener; returns a function that removes it. */
638
+ subscribe(listener: (state: T) => void): () => void;
639
+ }
640
+
641
+ /**
642
+ * Where a completed form is sent.
643
+ * - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
644
+ * POSTs the values to that URL.
645
+ * - `{ via: "client", url }` — same, written out.
646
+ * - `{ via: "client", handler }` — the browser runs your own submit logic.
647
+ * - `{ via: "backend", destination }` — the browser relays the values to the backend,
648
+ * which forwards them to the server-configured destination (URL + secret stay server-side).
649
+ * - `false` — collect only, no submit function.
650
+ */
651
+ declare type SubmitConfig<V = Record<string, unknown>> = string | {
652
+ via: "client";
653
+ url: string;
654
+ } | {
655
+ via: "client";
656
+ handler: (values: V) => Promise<unknown> | unknown;
657
+ } | {
658
+ via: "backend";
659
+ destination: string;
660
+ } | false;
661
+
662
+ /**
663
+ * Tool call data from SSE stream
664
+ */
665
+ export declare interface ToolCallData {
666
+ id: string;
667
+ type: ToolCallType;
668
+ status: string;
669
+ toolName: string;
670
+ toolDisplayName?: string;
671
+ message?: string;
672
+ formSchema?: FormSchema;
673
+ data?: Record<string, unknown>;
674
+ functionName?: string;
675
+ arguments?: Record<string, unknown>;
676
+ }
677
+
678
+ declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
679
+
680
+ /**
681
+ * Hook to create and manage an AgoClient instance
682
+ */
683
+ export declare function useAgo(config: UseAgoOptions): UseAgoResult;
684
+
685
+ /**
686
+ * Returns the AgoClient from the nearest AgoProvider.
687
+ * Throws if used outside of an AgoProvider.
688
+ */
689
+ export declare function useAgoClient(): AgoClient;
690
+
691
+ /**
692
+ * Declaratively expose a piece of context to the AI agent with every message.
693
+ *
694
+ * Accepts either:
695
+ * - An **object** — sent as-is on every message (re-registered when it changes).
696
+ * Use for data that already lives in React state.
697
+ * - A **function** — called lazily at each message send, so the AI always gets
698
+ * the freshest value. Use for data outside React state (global stores, refs,
699
+ * computed values).
700
+ *
701
+ * A unique key is auto-generated per component instance via `useId()`. Pass an
702
+ * explicit key as second argument to share context across components or
703
+ * reference it from elsewhere.
704
+ *
705
+ * ```tsx
706
+ * // Static object — captured at render time
707
+ * function OrderPage({ order }) {
708
+ * useAgoContext({
709
+ * name: "Order detail",
710
+ * description: "The user is viewing a specific order",
711
+ * data: { orderId: order.id, status: order.status },
712
+ * });
713
+ * }
714
+ *
715
+ * // Dynamic function — evaluated at each sendMessage
716
+ * function App() {
717
+ * const storeRef = useRef(reduxStore);
718
+ * useAgoContext(() => {
719
+ * const state = storeRef.current.getState();
720
+ * return { name: "App shell", data: { userId: state.auth.userId } };
721
+ * });
722
+ * }
723
+ *
724
+ * // With an explicit key
725
+ * useAgoContext({ name: "Sidebar filter", data: { filter } }, "sidebar-filter");
726
+ * ```
727
+ */
728
+ export declare function useAgoContext(entry: ContextEntry, key?: string): void;
729
+
730
+ export declare function useAgoContext(provider: DynamicContextProvider, key?: string): void;
731
+
732
+ /**
733
+ * Declaratively register a client-side function with the AGO agent.
734
+ * Automatically unregisters on unmount and re-registers when deps change.
735
+ *
736
+ * Accepts either a full definition object (preferred) or classic (name, options) args.
737
+ *
738
+ * ```tsx
739
+ * // Preferred — pass the whole definition
740
+ * useAgoFunction({
741
+ * name: "showToast",
742
+ * description: "Show a notification to the user",
743
+ * parameters: { type: "object", properties: { message: { type: "string" } } },
744
+ * handler: async (args) => { toast(args.message); return { shown: true }; },
745
+ * });
746
+ *
747
+ * // Or reuse a pre-defined function
748
+ * const lookupOrder = defineFunction({ name: "lookupOrder", ... });
749
+ * useAgoFunction(lookupOrder);
750
+ *
751
+ * // Classic form
752
+ * useAgoFunction("showToast", { description: "...", parameters: {...}, handler: async (args) => ... });
753
+ * ```
754
+ */
755
+ export declare function useAgoFunction(definition: ClientFunctionDefinition): void;
756
+
757
+ export declare function useAgoFunction(name: string, options: UseAgoFunctionOptions): void;
758
+
759
+ export declare interface UseAgoFunctionOptions {
760
+ description: string;
761
+ parameters: {
762
+ type: "object";
763
+ properties: Record<string, {
764
+ type: string;
765
+ description?: string;
766
+ enum?: string[];
767
+ default?: unknown;
768
+ }>;
769
+ required?: string[];
770
+ };
771
+ handler: ClientFunctionHandler;
772
+ }
773
+
774
+ /**
775
+ * Declaratively register navigation routes with the AGO agent.
776
+ * Wraps `registerNavigationFunction` with React lifecycle management.
777
+ *
778
+ * ```tsx
779
+ * const navigate = useNavigate();
780
+ * useAgoNavigation(navigate, [
781
+ * { name: "dashboard", path: "/dashboard", description: "Main dashboard" },
782
+ * { name: "settings", path: "/settings", description: "User settings" },
783
+ * ]);
784
+ * ```
785
+ */
786
+ export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
787
+
788
+ export declare interface UseAgoOptions extends AgoConfig {
789
+ }
790
+
791
+ export declare interface UseAgoResult {
792
+ /** The AGO client instance */
793
+ client: AgoClient;
794
+ /** Whether the client is ready */
795
+ isReady: boolean;
796
+ }
797
+
798
+ /**
799
+ * Read a framework-agnostic AGO store (`createStore`) reactively in React.
800
+ *
801
+ * Re-renders the component whenever the store's value changes. Mutate the store
802
+ * via `store.set(...)`, not the value returned here.
803
+ *
804
+ * ```tsx
805
+ * const cart = createStore({ items: [] as string[] });
806
+ *
807
+ * function CartBadge() {
808
+ * const { items } = useAgoStore(cart);
809
+ * return <span>{items.length}</span>;
810
+ * }
811
+ * ```
812
+ */
813
+ export declare function useAgoStore<T>(store: Store<T>): T;
814
+
815
+ /**
816
+ * All-in-one hook for building a custom chat UI.
817
+ * Composes useMessages + useConversation.
818
+ *
819
+ * ```tsx
820
+ * const { messages, sendMessage, conversations, selectConversation } = useChat();
821
+ * ```
822
+ */
823
+ export declare function useChat(options?: UseChatOptions): UseChatResult;
824
+
825
+ export declare interface UseChatOptions {
826
+ /** AgoClient instance. If omitted, reads from AgoProvider context. */
827
+ client?: AgoClient;
828
+ /** Initial conversation ID to load */
829
+ conversationId?: string;
830
+ /** Auto-load conversation list on mount (default: true) */
831
+ autoLoad?: boolean;
832
+ }
833
+
834
+ export declare interface UseChatResult {
835
+ /** Messages in the current conversation */
836
+ messages: AgoMessage[];
837
+ /** Whether a message is being sent/streamed */
838
+ isLoading: boolean;
839
+ /** Current error */
840
+ error: Error | null;
841
+ /** Send a message */
842
+ sendMessage: (content: string, files?: File[]) => Promise<AgoMessage | null>;
843
+ /** Clear current messages */
844
+ clearMessages: () => void;
845
+ /** Current conversation ID */
846
+ conversationId: string | undefined;
847
+ /** All conversations */
848
+ conversations: Conversation[];
849
+ /** Currently selected conversation */
850
+ currentConversation: Conversation | null;
851
+ /** Whether conversations are loading */
852
+ isConversationsLoading: boolean;
853
+ /** Select a conversation by ID */
854
+ selectConversation: (conversationId: string) => Promise<void>;
855
+ /** Start a new conversation */
856
+ startNewConversation: () => void;
857
+ /** Refresh conversations list */
858
+ refreshConversations: () => Promise<void>;
859
+ }
860
+
861
+ /**
862
+ * Hook to manage conversations
863
+ */
864
+ export declare function useConversation({ client: clientProp, autoLoad, }?: UseConversationOptions): UseConversationResult;
865
+
866
+ export declare interface UseConversationOptions {
867
+ /** The AGO client instance. If omitted, reads from AgoProvider context. */
868
+ client?: AgoClient;
869
+ /** Auto-load conversations on mount */
870
+ autoLoad?: boolean;
871
+ }
872
+
873
+ export declare interface UseConversationResult {
874
+ /** List of conversations */
875
+ conversations: Conversation[];
876
+ /** Currently selected conversation */
877
+ currentConversation: Conversation | null;
878
+ /** Whether conversations are loading */
879
+ isLoading: boolean;
880
+ /** Current error, if any */
881
+ error: Error | null;
882
+ /** Select a conversation */
883
+ selectConversation: (conversationId: string) => Promise<void>;
884
+ /** Clear current conversation (start new) */
885
+ startNewConversation: () => void;
886
+ /** Refresh conversations list */
887
+ refreshConversations: () => Promise<void>;
888
+ }
889
+
890
+ /**
891
+ * React wiring for {@link createFormCollector}: registers the collector's client
892
+ * functions + dynamic context on mount, removes them on unmount, and returns the
893
+ * live store state.
894
+ *
895
+ * The collector is recreated only when `name`, the schema, or the submit target
896
+ * changes. Keep the schema and submit object stable (declare them outside render
897
+ * or memoize them) so an inline `handler` isn't captured stale.
898
+ *
899
+ * ```tsx
900
+ * const order = useFormCollector({
901
+ * name: "order",
902
+ * description: "The order the user wants to place",
903
+ * schema: {
904
+ * type: "object",
905
+ * properties: { product: { type: "string" }, quantity: { type: "number" } },
906
+ * required: ["product", "quantity"],
907
+ * },
908
+ * submit: { via: "backend", destination: "order_webhook" },
909
+ * });
910
+ *
911
+ * return (
912
+ * <div>
913
+ * {order.state.missing.length > 0
914
+ * ? `Still need: ${order.state.missing.join(", ")}`
915
+ * : "Ready to submit"}
916
+ * </div>
917
+ * );
918
+ * ```
919
+ */
920
+ export declare function useFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): UseFormCollectorResult<V>;
921
+
922
+ export declare interface UseFormCollectorResult<V = Record<string, unknown>> extends FormCollector<V> {
923
+ /** Live form state from the collector's store — re-renders on every change. */
924
+ state: FormCollectorState<V>;
925
+ }
926
+
927
+ /**
928
+ * Hook to manage messages in a conversation
929
+ */
930
+ export declare function useMessages({ client: clientProp, conversationId: initialConversationId, }?: UseMessagesOptions): UseMessagesResult;
931
+
932
+ export declare interface UseMessagesOptions {
933
+ /** The AGO client instance. If omitted, reads from AgoProvider context. */
934
+ client?: AgoClient;
935
+ /** Conversation ID to load messages for */
936
+ conversationId?: string;
937
+ }
938
+
939
+ export declare interface UseMessagesResult {
940
+ /** List of messages */
941
+ messages: AgoMessage[];
942
+ /** Whether a message is being sent */
943
+ isLoading: boolean;
944
+ /** Current error, if any */
945
+ error: Error | null;
946
+ /** Send a new message */
947
+ sendMessage: (content: string, files?: File[]) => Promise<AgoMessage | null>;
948
+ /** Clear messages */
949
+ clearMessages: () => void;
950
+ /** Current conversation ID */
951
+ conversationId: string | undefined;
952
+ }
953
+
954
+ /**
955
+ * Returns the AgoClient from context, or null if no provider exists.
956
+ * Use this when client access is optional.
957
+ */
958
+ export declare function useOptionalAgoClient(): AgoClient | null;
959
+
960
+ export { }