@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
package/dist/index.d.ts CHANGED
@@ -1,20 +1,1150 @@
1
- export { AgoClient } from "./client/AgoClient";
2
- export type { AgoAgent, AgoClientEvents, AgoConfig, AgoEventHandler, AgoEventName, AgoMessage, AgoSource, ClientFunction, ClientFunctionInvocation, Conversation, FormField, FormSchema, FunctionDefinition, FunctionSchema, MessageStatus, SendMessageOptions, SSEChunkData, ToolCallData, ToolCallType, } from "./client/types";
3
- export { AgoApiError, AgoError, AgoFunctionError, AgoNetworkError, AgoStreamError, } from "./client/errors";
4
- export { createStore } from "./state/createStore";
5
- export type { Store, PersistOptions } from "./state/createStore";
6
- export { ClientContextRegistry } from "./state/ClientContextRegistry";
7
- export type { ContextEntry, ContextSnapshot, DynamicContextProvider, } from "./state/ClientContextRegistry";
8
- export { defineFunction } from "./functions/defineFunction";
9
- export { FunctionRegistry } from "./functions/FunctionRegistry";
10
- export type { ClientFunctionDefinition, ClientFunctionHandler, ClientFunctionSchema, RegisteredFunction, } from "./functions/types";
11
- export { createMockClient } from "./testing";
12
- export type { MockAgoClient, MockAgoClientOptions } from "./testing";
13
- export { isStreamNetworkError, SSEHandler } from "./streaming/SSEHandler";
14
- export type { AgoWidgetColors, AgoWidgetConfig } from "./widget/types";
15
- export { createMessageStream, onFunctionInvoke, onMessage, onMessageChunk, onMessageError, onMessageStart, onToolCall, } from "./streaming/helpers";
16
- export { autoDetectConfig, createAgo } from "./auto/createAgo";
17
- export { copyToClipboard, getLocalStorage, getUserLocation, highlightElement, openUrl, scrollToElement, setLocalStorage, setTheme, showConfirmDialog, showNotification, showToast, submitForm, trackEvent, } from "./helpers/functions";
18
- export { withHandler } from "./helpers/factory";
19
- export { EventEmitter } from "./utils/eventEmitter";
20
- export { logger } from "./utils/logger";
1
+ /**
2
+ * Agent information
3
+ */
4
+ export declare interface AgoAgent {
5
+ id: string;
6
+ name: string;
7
+ displayName?: string;
8
+ }
9
+
10
+ /**
11
+ * Error from API response
12
+ */
13
+ export declare class AgoApiError extends AgoError {
14
+ type: string;
15
+ param?: string | undefined;
16
+ docUrl?: string | undefined;
17
+ constructor(message: string, code: string, statusCode: number, type: string, param?: string | undefined, docUrl?: string | undefined);
18
+ static fromResponse(data: ApiErrorResponse, statusCode: number): AgoApiError;
19
+ }
20
+
21
+ /**
22
+ * Main SDK client for AGO Chat integration
23
+ */
24
+ export declare class AgoClient {
25
+ private httpClient;
26
+ private functionRegistry;
27
+ private contextRegistry;
28
+ private eventEmitter;
29
+ private config;
30
+ constructor(config: AgoConfig);
31
+ /**
32
+ * Send a message and receive a streaming response
33
+ */
34
+ sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
35
+ private processSSEResponse;
36
+ private handleClientFunctionInvocation;
37
+ /**
38
+ * Get list of conversations
39
+ */
40
+ getConversations(): Promise<Conversation[]>;
41
+ /**
42
+ * Get a specific conversation with messages
43
+ */
44
+ getConversation(conversationId: string): Promise<Conversation>;
45
+ /**
46
+ * Get messages for a conversation
47
+ */
48
+ getMessages(conversationId: string): Promise<AgoMessage[]>;
49
+ /**
50
+ * Submit form data for a tool call
51
+ */
52
+ submitToolCallForm(toolCallId: string, formData: Record<string, unknown>): Promise<void>;
53
+ /**
54
+ * Confirm a tool call
55
+ */
56
+ confirmToolCall(toolCallId: string): Promise<void>;
57
+ /**
58
+ * Reject a tool call
59
+ */
60
+ rejectToolCall(toolCallId: string): Promise<void>;
61
+ /**
62
+ * Relay a completed form collector's values to a server-configured destination.
63
+ *
64
+ * Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
65
+ * the browser never holds the destination URL or its secret — the backend resolves
66
+ * `destination` (a named, opted-in tool) and forwards the values from the server.
67
+ */
68
+ submitFormCollector(destination: string, values: Record<string, unknown>): Promise<unknown>;
69
+ /**
70
+ * Submit feedback for a message
71
+ */
72
+ submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
73
+ /**
74
+ * Register a client-side function that AGO can call.
75
+ * Accepts either a definition object or (name, handler, schema) args.
76
+ *
77
+ * ```ts
78
+ * // Single-object (preferred)
79
+ * client.registerFunction({
80
+ * name: "lookupOrder",
81
+ * description: "Look up an order",
82
+ * parameters: { type: "object", properties: { id: { type: "string" } } },
83
+ * handler: async (args) => fetchOrder(args.id),
84
+ * });
85
+ *
86
+ * // Classic 3-arg form
87
+ * client.registerFunction("lookupOrder", handler, schema);
88
+ * ```
89
+ */
90
+ registerFunction(definition: ClientFunctionDefinition): void;
91
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
92
+ /**
93
+ * Short alias for `registerFunction`. Also accepts an array of definitions.
94
+ *
95
+ * ```ts
96
+ * client.register(lookupOrder);
97
+ * client.register([lookupOrder, cancelOrder]);
98
+ * ```
99
+ */
100
+ register(definition: ClientFunctionDefinition | ClientFunctionDefinition[]): void;
101
+ /**
102
+ * Unregister a client-side function
103
+ */
104
+ unregisterFunction(name: string): boolean;
105
+ /**
106
+ * Get all registered function schemas
107
+ */
108
+ getRegisteredFunctions(): ClientFunctionSchema[];
109
+ /**
110
+ * Register a navigation function that lets AGO navigate users to different pages.
111
+ * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
112
+ * @param routes - Map of route names to paths, with descriptions for the LLM
113
+ */
114
+ registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
115
+ name: string;
116
+ path: string;
117
+ description: string;
118
+ }>): void;
119
+ /**
120
+ * Register or update a piece of client-side context.
121
+ * This context is sent with every message so the AI understands the user's situation.
122
+ *
123
+ * ```ts
124
+ * client.setContext("order-page", {
125
+ * name: "Order detail",
126
+ * description: "User is viewing order #123",
127
+ * data: { orderId: "123", status: "shipped" },
128
+ * });
129
+ * ```
130
+ */
131
+ setContext(key: string, entry: ContextEntry): void;
132
+ /**
133
+ * Remove a previously registered context entry.
134
+ */
135
+ removeContext(key: string): boolean;
136
+ /**
137
+ * Register a dynamic context provider. The callback is invoked every time
138
+ * a message is sent, so the AI always gets the freshest data.
139
+ *
140
+ * Use this for context that lives outside React state — global stores,
141
+ * refs, or computed values.
142
+ *
143
+ * ```ts
144
+ * client.addDynamicContext("cart", () => ({
145
+ * name: "Checkout",
146
+ * data: { itemCount: cart.items.length, total: cart.total },
147
+ * }));
148
+ * ```
149
+ */
150
+ addDynamicContext(key: string, provider: DynamicContextProvider): void;
151
+ /**
152
+ * Remove a dynamic context provider.
153
+ */
154
+ removeDynamicContext(key: string): boolean;
155
+ /**
156
+ * Enable automatic capture of the current browser page (URL + title).
157
+ * Injected as a dynamic context entry named `browser-page`.
158
+ */
159
+ enableAutoPageContext(): void;
160
+ /**
161
+ * Get the current context snapshot.
162
+ */
163
+ getContextSnapshot(): ContextSnapshot | null;
164
+ /**
165
+ * Subscribe to an event
166
+ */
167
+ on<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
168
+ /**
169
+ * Unsubscribe from an event
170
+ */
171
+ off<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
172
+ /**
173
+ * Subscribe to an event once — auto-unsubscribes after the first call.
174
+ */
175
+ once<K extends AgoEventName>(event: K, handler: AgoEventHandler<K>): void;
176
+ /**
177
+ * Returns a Promise that resolves the next time `event` fires.
178
+ *
179
+ * ```ts
180
+ * const msg = await client.waitFor("message:complete", { timeout: 10000 });
181
+ * ```
182
+ */
183
+ waitFor<K extends AgoEventName>(event: K, options?: {
184
+ timeout?: number;
185
+ }): Promise<AgoClientEvents[K]>;
186
+ /**
187
+ * Update client configuration
188
+ */
189
+ updateConfig(config: Partial<AgoConfig>): void;
190
+ /**
191
+ * Clean up resources
192
+ */
193
+ destroy(): void;
194
+ }
195
+
196
+ /**
197
+ * SDK Events
198
+ */
199
+ export declare interface AgoClientEvents {
200
+ "message:start": {
201
+ conversationId: string;
202
+ messageId: string;
203
+ };
204
+ "message:chunk": {
205
+ content: string;
206
+ conversationId: string;
207
+ messageId: string;
208
+ };
209
+ "message:complete": AgoMessage;
210
+ "message:error": {
211
+ error: string;
212
+ conversationId?: string;
213
+ messageId?: string;
214
+ };
215
+ "toolCall:received": ToolCallData;
216
+ "toolCall:form": ToolCallData;
217
+ "function:invoke": ClientFunctionInvocation;
218
+ "function:result": {
219
+ invocationId: string;
220
+ result: unknown;
221
+ error?: string;
222
+ };
223
+ "connection:status": {
224
+ connected: boolean;
225
+ };
226
+ }
227
+
228
+ /**
229
+ * SDK Configuration
230
+ */
231
+ export declare interface AgoConfig {
232
+ /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
233
+ baseUrl: string;
234
+ /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
235
+ widgetId?: string;
236
+ /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
237
+ agent?: string;
238
+ /** Default agent ID for new conversations. Prefer `agent`. */
239
+ defaultAgentId?: string;
240
+ /** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
241
+ permission?: string;
242
+ /** User email for identification */
243
+ userEmail?: string;
244
+ /** JWT token for authenticated users */
245
+ userJwt?: string;
246
+ /** Enable debug logging */
247
+ debug?: boolean;
248
+ }
249
+
250
+ /**
251
+ * Base error class for AGO SDK
252
+ */
253
+ export declare class AgoError extends Error {
254
+ code: string;
255
+ statusCode?: number | undefined;
256
+ constructor(message: string, code: string, statusCode?: number | undefined);
257
+ }
258
+
259
+ export declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
260
+
261
+ export declare type AgoEventName = keyof AgoClientEvents;
262
+
263
+ /**
264
+ * Function execution error
265
+ */
266
+ export declare class AgoFunctionError extends AgoError {
267
+ functionName: string;
268
+ originalError?: Error | undefined;
269
+ constructor(message: string, functionName: string, originalError?: Error | undefined);
270
+ }
271
+
272
+ /**
273
+ * Message from AGO
274
+ */
275
+ export declare interface AgoMessage {
276
+ id: string;
277
+ conversationId: string;
278
+ content: string;
279
+ role: "user" | "assistant";
280
+ status: MessageStatus;
281
+ agent?: AgoAgent;
282
+ sources?: AgoSource[];
283
+ toolCalls?: ToolCallData[];
284
+ followUpReplies?: string[];
285
+ createdAt: Date;
286
+ }
287
+
288
+ /**
289
+ * Network/connection error
290
+ */
291
+ export declare class AgoNetworkError extends AgoError {
292
+ originalError?: Error | undefined;
293
+ constructor(message: string, originalError?: Error | undefined);
294
+ }
295
+
296
+ /**
297
+ * Knowledge source citation
298
+ */
299
+ export declare interface AgoSource {
300
+ id: string;
301
+ title: string;
302
+ url?: string;
303
+ }
304
+
305
+ /**
306
+ * SSE stream error
307
+ */
308
+ export declare class AgoStreamError extends AgoError {
309
+ constructor(message: string);
310
+ }
311
+
312
+ /**
313
+ * Widget configuration types.
314
+ *
315
+ * These types describe the `window.AGO` configuration object
316
+ * used by the embeddable chat widget snippet.
317
+ *
318
+ * @example
319
+ * ```ts
320
+ * import type { AgoWidgetConfig } from "@useago/sdk/widget";
321
+ * ```
322
+ */
323
+ export declare interface AgoWidgetColors {
324
+ button?: string;
325
+ header?: string;
326
+ agentMessage?: string;
327
+ agentMessageFont?: string;
328
+ background?: string;
329
+ font?: string;
330
+ userMessage?: string;
331
+ userMessageFont?: string;
332
+ }
333
+
334
+ export declare interface AgoWidgetConfig {
335
+ basepath: string;
336
+ widgetApiKey: string;
337
+ defaultAgent?: string;
338
+ email?: string;
339
+ title?: string;
340
+ icon?: string;
341
+ prompt?: string;
342
+ notifications?: boolean;
343
+ notificationMessage?: string;
344
+ colors?: AgoWidgetColors;
345
+ hideFooter?: boolean;
346
+ jwt?: string;
347
+ authToken?: string;
348
+ permission?: string;
349
+ metadata?: Record<string, unknown>;
350
+ }
351
+
352
+ declare interface ApiErrorResponse {
353
+ error: {
354
+ type: string;
355
+ code: string;
356
+ message: string;
357
+ param?: string;
358
+ doc_url?: string;
359
+ };
360
+ }
361
+
362
+ /**
363
+ * Auto-detect AGO configuration from the DOM environment.
364
+ *
365
+ * Checks (in order of priority):
366
+ * 1. `window.AGO` global object (widget config)
367
+ * 2. `<meta>` tags: `<meta name="ago-api-key" content="...">`
368
+ * 3. `data-ago-*` attributes on `<body>` or `<script data-ago-api-key="...">`
369
+ * 4. Explicit overrides passed as argument
370
+ *
371
+ * Returns null if no API key can be found.
372
+ */
373
+ export declare function autoDetectConfig(overrides?: Partial<AgoConfig>): AgoConfig | null;
374
+
375
+ /**
376
+ * Registry that collects client-side context from across the component tree.
377
+ *
378
+ * Components register/unregister context slices via unique keys.
379
+ * When a message is sent the registry produces a single snapshot.
380
+ */
381
+ export declare class ClientContextRegistry {
382
+ private entries;
383
+ private dynamicProviders;
384
+ /**
385
+ * Register or update a static context entry.
386
+ */
387
+ set(key: string, entry: ContextEntry): void;
388
+ /**
389
+ * Remove a static context entry (typically on component unmount).
390
+ */
391
+ remove(key: string): boolean;
392
+ /**
393
+ * Register a dynamic context provider. The function is called every time
394
+ * a message is sent, so it always returns the freshest data.
395
+ *
396
+ * Use this for context that lives outside React state — global stores,
397
+ * refs, or computed values that shouldn't trigger re-renders.
398
+ */
399
+ addDynamicProvider(key: string, provider: DynamicContextProvider): void;
400
+ /**
401
+ * Remove a dynamic context provider.
402
+ */
403
+ removeDynamicProvider(key: string): boolean;
404
+ /**
405
+ * Build a snapshot of the current client context.
406
+ * Evaluates every registered dynamic provider. Returns `null` when there is
407
+ * nothing to report.
408
+ */
409
+ getSnapshot(): ContextSnapshot | null;
410
+ /**
411
+ * Remove all entries and dynamic providers.
412
+ */
413
+ clear(): void;
414
+ }
415
+
416
+ export declare type ClientFunction = (args: Record<string, unknown>) => Promise<unknown> | unknown;
417
+
418
+ /**
419
+ * Single-object function definition — combines name, schema, and handler.
420
+ *
421
+ * ```ts
422
+ * const fn = defineFunction({
423
+ * name: "lookupOrder",
424
+ * description: "Look up an order by ID",
425
+ * parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
426
+ * handler: async (args) => fetchOrder(args.id as string),
427
+ * });
428
+ * client.registerFunction(fn);
429
+ * ```
430
+ */
431
+ export declare interface ClientFunctionDefinition {
432
+ name: string;
433
+ description: string;
434
+ parameters: ClientFunctionSchema["parameters"];
435
+ handler: ClientFunctionHandler;
436
+ }
437
+
438
+ /**
439
+ * Function handler type
440
+ */
441
+ export declare type ClientFunctionHandler = (args: Record<string, unknown>) => Promise<unknown> | unknown;
442
+
443
+ export declare interface ClientFunctionInvocation {
444
+ invocationId: string;
445
+ functionName: string;
446
+ arguments: Record<string, unknown>;
447
+ conversationId: string;
448
+ }
449
+
450
+ /**
451
+ * Schema for a client-side function that AGO can call
452
+ */
453
+ export declare interface ClientFunctionSchema {
454
+ /** Function name (must be unique) */
455
+ name: string;
456
+ /** Description for the LLM to understand when to call this function */
457
+ description: string;
458
+ /** JSON Schema for function parameters */
459
+ parameters: {
460
+ type: "object";
461
+ properties: Record<string, {
462
+ type: string;
463
+ description?: string;
464
+ enum?: string[];
465
+ default?: unknown;
466
+ }>;
467
+ required?: string[];
468
+ };
469
+ }
470
+
471
+ /**
472
+ * A single piece of context the client wants the LLM to know about.
473
+ */
474
+ export declare interface ContextEntry {
475
+ /** Human-readable label (e.g. "Order detail", "Current user") */
476
+ name?: string;
477
+ /** Short description of what this context represents */
478
+ description?: string;
479
+ /** Arbitrary structured data the AI should know about */
480
+ data?: Record<string, unknown>;
481
+ }
482
+
483
+ /**
484
+ * Serialised client context sent with each message.
485
+ */
486
+ export declare interface ContextSnapshot {
487
+ /** All active context entries keyed by their registration key */
488
+ entries: Record<string, ContextEntry>;
489
+ }
490
+
491
+ /**
492
+ * Conversation/Thread
493
+ */
494
+ export declare interface Conversation {
495
+ id: string;
496
+ title: string;
497
+ lastMessageDate: Date;
498
+ messages?: AgoMessage[];
499
+ }
500
+
501
+ /**
502
+ * Copy text to clipboard.
503
+ */
504
+ export declare const copyToClipboard: ClientFunctionDefinition;
505
+
506
+ /**
507
+ * Create an AgoClient with zero configuration.
508
+ * Auto-detects config from window.AGO, meta tags, and data-ago-* attributes.
509
+ *
510
+ * ```html
511
+ * <!-- In your HTML -->
512
+ * <meta name="ago-base-url" content="https://YOUR-DOMAIN.useago.com">
513
+ *
514
+ * <!-- Or on a script tag -->
515
+ * <script src="app.js" data-ago-base-url="https://YOUR-DOMAIN.useago.com"></script>
516
+ * ```
517
+ *
518
+ * ```ts
519
+ * import { createAgo } from "@useago/sdk";
520
+ *
521
+ * // Zero config — picks up from DOM
522
+ * const client = createAgo();
523
+ *
524
+ * // Or with partial overrides
525
+ * const client = createAgo({ debug: true });
526
+ * ```
527
+ *
528
+ * Throws if no base URL can be detected.
529
+ */
530
+ export declare function createAgo(overrides?: Partial<AgoConfig>): AgoClient;
531
+
532
+ /**
533
+ * Wire one schema into a conversational form: an observable store, an
534
+ * `update_<name>` client function the agent calls to fill fields, a dynamic-context
535
+ * provider that tells the agent what's still missing, and an optional submit.
536
+ *
537
+ * ```ts
538
+ * const order = createFormCollector({
539
+ * name: "order",
540
+ * description: "The order the user wants to place",
541
+ * schema: {
542
+ * type: "object",
543
+ * properties: { product: { type: "string" }, quantity: { type: "number" } },
544
+ * required: ["product", "quantity"],
545
+ * },
546
+ * submit: { via: "client", url: "/api/orders" },
547
+ * });
548
+ * order.install(client);
549
+ * order.store.subscribe((s) => render(s));
550
+ * ```
551
+ */
552
+ export declare function createFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): FormCollector<V>;
553
+
554
+ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
555
+ /** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
556
+ name: string;
557
+ /** What the form is, for the LLM. */
558
+ description: string;
559
+ /** The single source of truth for the form's fields. */
560
+ schema: FormCollectorSchema;
561
+ /** How the completed form is submitted. Default: `false` (collect only). */
562
+ submit?: SubmitConfig<V>;
563
+ /** Pre-filled values. */
564
+ initialValues?: Partial<V>;
565
+ }
566
+
567
+ /**
568
+ * Send a message and iterate over chunks as an async generator.
569
+ * Gives you full control over how you process the stream.
570
+ *
571
+ * ```ts
572
+ * for await (const chunk of createMessageStream(client, "Hello!")) {
573
+ * console.log(chunk.type, chunk.data);
574
+ * }
575
+ * ```
576
+ */
577
+ export declare function createMessageStream(client: AgoClient, content: string, options?: {
578
+ conversationId?: string;
579
+ agentId?: string;
580
+ files?: File[];
581
+ }): AsyncGenerator<{
582
+ type: "start";
583
+ data: AgoClientEvents["message:start"];
584
+ } | {
585
+ type: "chunk";
586
+ data: AgoClientEvents["message:chunk"];
587
+ } | {
588
+ type: "complete";
589
+ data: AgoMessage;
590
+ } | {
591
+ type: "error";
592
+ data: AgoClientEvents["message:error"];
593
+ } | {
594
+ type: "toolCall";
595
+ data: ToolCallData;
596
+ }>;
597
+
598
+ /**
599
+ * Create a mock AgoClient for testing. Works with any framework.
600
+ *
601
+ * ```ts
602
+ * import { createMockClient } from "@useago/sdk/testing";
603
+ *
604
+ * const mock = createMockClient();
605
+ * mock.__emitEvent("message:complete", someMessage);
606
+ * expect(mock.__callsFor("sendMessage")).toHaveLength(1);
607
+ * ```
608
+ */
609
+ export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
610
+
611
+ export declare function createStore<T>(initial: T, persist?: PersistOptions): Store<T>;
612
+
613
+ /**
614
+ * Create a reusable function definition.
615
+ * Returns the same object — this is an identity function for discoverability and type-checking.
616
+ *
617
+ * ```ts
618
+ * // Define once, reuse anywhere
619
+ * export const lookupOrder = defineFunction({
620
+ * name: "lookupOrder",
621
+ * description: "Look up an order by ID",
622
+ * parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
623
+ * handler: async (args) => fetchOrder(args.id as string),
624
+ * });
625
+ *
626
+ * // Register with client
627
+ * client.registerFunction(lookupOrder);
628
+ *
629
+ * // Or use in React
630
+ * useAgoFunction(lookupOrder.name, lookupOrder);
631
+ * ```
632
+ */
633
+ export declare function defineFunction(definition: ClientFunctionDefinition): ClientFunctionDefinition;
634
+
635
+ /**
636
+ * A function that returns a fresh context entry on demand.
637
+ * Evaluated every time a message is sent — use it to pull data from stores,
638
+ * refs, or any source that isn't captured by React state.
639
+ */
640
+ export declare type DynamicContextProvider = () => ContextEntry | null | undefined;
641
+
642
+ /**
643
+ * Simple typed event emitter
644
+ */
645
+ export declare class EventEmitter<Events extends Record<string, any> = Record<string, unknown>> {
646
+ private handlers;
647
+ on<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
648
+ off<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
649
+ emit<K extends keyof Events>(event: K, data: Events[K]): void;
650
+ /**
651
+ * Subscribe to an event and auto-unsubscribe after the first call.
652
+ */
653
+ once<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
654
+ /**
655
+ * Returns a Promise that resolves the next time `event` fires.
656
+ * Rejects if `timeout` (ms) is reached first.
657
+ */
658
+ waitFor<K extends keyof Events>(event: K, options?: {
659
+ timeout?: number;
660
+ }): Promise<Events[K]>;
661
+ removeAllListeners(event?: keyof Events): void;
662
+ }
663
+
664
+ declare type EventHandler<T = unknown> = (data: T) => void;
665
+
666
+ export declare interface FormCollector<V = Record<string, unknown>> {
667
+ name: string;
668
+ /** Observable store driving the form UI (read via `useAgoStore`). */
669
+ store: Store<FormCollectorState<V>>;
670
+ /** Client functions to register: `[update]` or `[update, submit]`. */
671
+ functions: ClientFunctionDefinition[];
672
+ /** Dynamic-context key under which the form state is exposed. */
673
+ contextKey: string;
674
+ /** Dynamic-context provider — re-read on every message. */
675
+ contextProvider: () => ContextEntry;
676
+ /** Register the functions + dynamic context on a client. Returns an uninstall fn. */
677
+ install: (client: AgoClient) => () => void;
678
+ /** Submit the form now (e.g. from a UI button). Blocks until required fields are filled. */
679
+ submit: () => Promise<FormSubmitResult>;
680
+ getValues: () => Partial<V>;
681
+ setValues: (patch: Partial<V>) => void;
682
+ reset: () => void;
683
+ }
684
+
685
+ /**
686
+ * JSON-schema shape of a form's fields — identical to a client function's
687
+ * `parameters`, so one schema feeds the store, the update function, and the
688
+ * dynamic context with no second type.
689
+ */
690
+ export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
691
+
692
+ /** Live state held in the collector's store. */
693
+ export declare interface FormCollectorState<V = Record<string, unknown>> {
694
+ /** Field values collected so far. */
695
+ values: Partial<V>;
696
+ /** Required field names still empty. */
697
+ missing: string[];
698
+ /** True when no required field is missing. */
699
+ complete: boolean;
700
+ /** True once a submit succeeded. */
701
+ submitted: boolean;
702
+ }
703
+
704
+ export declare interface FormField {
705
+ type: "string" | "number" | "boolean" | "array";
706
+ title?: string;
707
+ description?: string;
708
+ enum?: string[];
709
+ default?: unknown;
710
+ }
711
+
712
+ /**
713
+ * Form schema for tool calls requiring user input
714
+ */
715
+ export declare interface FormSchema {
716
+ type: "object";
717
+ properties: Record<string, FormField>;
718
+ required?: string[];
719
+ }
720
+
721
+ /** Result returned by `submit()` / the generated `submit_<name>` function. */
722
+ export declare interface FormSubmitResult {
723
+ ok: boolean;
724
+ missing?: string[];
725
+ result?: unknown;
726
+ error?: string;
727
+ }
728
+
729
+ export declare interface FunctionDefinition {
730
+ name: string;
731
+ schema: FunctionSchema;
732
+ handler: ClientFunction;
733
+ }
734
+
735
+ /**
736
+ * Registry for client-side functions that AGO can call
737
+ */
738
+ export declare class FunctionRegistry {
739
+ private functions;
740
+ /**
741
+ * Register a function that AGO can call.
742
+ * Accepts either a single definition object or (name, handler, schema) args.
743
+ */
744
+ register(definition: ClientFunctionDefinition): void;
745
+ register(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
746
+ /**
747
+ * Unregister a function
748
+ */
749
+ unregister(name: string): boolean;
750
+ /**
751
+ * Get a registered function
752
+ */
753
+ get(name: string): RegisteredFunction | undefined;
754
+ /**
755
+ * Check if a function is registered
756
+ */
757
+ has(name: string): boolean;
758
+ /**
759
+ * Get all registered function schemas (for sending to backend)
760
+ */
761
+ getSchemas(): ClientFunctionSchema[];
762
+ /**
763
+ * Execute a registered function
764
+ */
765
+ execute(name: string, args: Record<string, unknown>): Promise<unknown>;
766
+ /**
767
+ * Clear all registered functions
768
+ */
769
+ clear(): void;
770
+ /**
771
+ * Get the number of registered functions
772
+ */
773
+ get size(): number;
774
+ }
775
+
776
+ /**
777
+ * Client-side function types
778
+ */
779
+ export declare interface FunctionSchema {
780
+ name: string;
781
+ description: string;
782
+ parameters: {
783
+ type: "object";
784
+ properties: Record<string, {
785
+ type: string;
786
+ description?: string;
787
+ enum?: string[];
788
+ }>;
789
+ required?: string[];
790
+ };
791
+ }
792
+
793
+ /**
794
+ * Get a value from localStorage.
795
+ */
796
+ export declare const getLocalStorage: ClientFunctionDefinition;
797
+
798
+ /**
799
+ * Get the user's geolocation.
800
+ */
801
+ export declare const getUserLocation: ClientFunctionDefinition;
802
+
803
+ /**
804
+ * Highlight an element on the page (useful for guided tours).
805
+ */
806
+ export declare const highlightElement: ClientFunctionDefinition;
807
+
808
+ /**
809
+ * Check if an error is a network error that should trigger polling fallback
810
+ */
811
+ export declare function isStreamNetworkError(error: Error): boolean;
812
+
813
+ /**
814
+ * Debug logger for SDK
815
+ */
816
+ declare class Logger {
817
+ private enabled;
818
+ constructor(enabled?: boolean);
819
+ enable(): void;
820
+ disable(): void;
821
+ log(...args: unknown[]): void;
822
+ warn(...args: unknown[]): void;
823
+ error(...args: unknown[]): void;
824
+ debug(...args: unknown[]): void;
825
+ }
826
+
827
+ export declare const logger: Logger;
828
+
829
+ export declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
830
+
831
+ export declare interface MockAgoClient extends AgoClient {
832
+ /**
833
+ * Simulate a server-pushed event.
834
+ * ```ts
835
+ * mock.__emitEvent("message:complete", { id: "1", content: "hi", ... });
836
+ * ```
837
+ */
838
+ __emitEvent<K extends AgoEventName>(event: K, data: AgoClientEvents[K]): void;
839
+ /**
840
+ * All recorded method calls: `[methodName, ...args][]`
841
+ */
842
+ __calls: Array<{
843
+ method: string;
844
+ args: unknown[];
845
+ }>;
846
+ /**
847
+ * Get calls for a specific method.
848
+ */
849
+ __callsFor(method: string): Array<{
850
+ method: string;
851
+ args: unknown[];
852
+ }>;
853
+ }
854
+
855
+ export declare interface MockAgoClientOptions {
856
+ overrides?: Partial<Record<string, MockFn>>;
857
+ }
858
+
859
+ declare type MockFn = (...args: any[]) => any;
860
+
861
+ /**
862
+ * Subscribe to client function invocations.
863
+ */
864
+ export declare function onFunctionInvoke(client: AgoClient, callback: (data: ClientFunctionInvocation) => void): () => void;
865
+
866
+ /**
867
+ * Subscribe to complete messages with a simple callback. Returns an unsubscribe function.
868
+ *
869
+ * ```ts
870
+ * const unsub = onMessage(client, (msg) => console.log(msg.content));
871
+ * // later: unsub();
872
+ * ```
873
+ */
874
+ export declare function onMessage(client: AgoClient, callback: (message: AgoMessage) => void): () => void;
875
+
876
+ /**
877
+ * Subscribe to streaming text chunks.
878
+ *
879
+ * ```ts
880
+ * onMessageChunk(client, ({ content }) => {
881
+ * outputEl.textContent += content;
882
+ * });
883
+ * ```
884
+ */
885
+ export declare function onMessageChunk(client: AgoClient, callback: (data: AgoClientEvents["message:chunk"]) => void): () => void;
886
+
887
+ /**
888
+ * Subscribe to message errors.
889
+ */
890
+ export declare function onMessageError(client: AgoClient, callback: (data: AgoClientEvents["message:error"]) => void): () => void;
891
+
892
+ /**
893
+ * Subscribe to message start events.
894
+ */
895
+ export declare function onMessageStart(client: AgoClient, callback: (data: AgoClientEvents["message:start"]) => void): () => void;
896
+
897
+ /**
898
+ * Subscribe to tool call events.
899
+ */
900
+ export declare function onToolCall(client: AgoClient, callback: (toolCall: ToolCallData) => void): () => void;
901
+
902
+ /**
903
+ * Open a URL in a new tab.
904
+ */
905
+ export declare const openUrl: ClientFunctionDefinition;
906
+
907
+ export declare interface PersistOptions {
908
+ /** Key under which the state is JSON-serialized. */
909
+ key: string;
910
+ /** Storage backend; defaults to `globalThis.localStorage`. */
911
+ storage?: StorageLike;
912
+ }
913
+
914
+ /**
915
+ * Registered function with handler
916
+ */
917
+ export declare interface RegisteredFunction {
918
+ schema: ClientFunctionSchema;
919
+ handler: ClientFunctionHandler;
920
+ }
921
+
922
+ /**
923
+ * Scroll to an element on the page.
924
+ */
925
+ export declare const scrollToElement: ClientFunctionDefinition;
926
+
927
+ /**
928
+ * Options for sending a message
929
+ */
930
+ export declare interface SendMessageOptions {
931
+ /** Existing conversation ID */
932
+ conversationId?: string;
933
+ /** Override default agent */
934
+ agentId?: string;
935
+ /** File attachments */
936
+ files?: File[];
937
+ }
938
+
939
+ /**
940
+ * Set a value in localStorage.
941
+ */
942
+ export declare const setLocalStorage: ClientFunctionDefinition;
943
+
944
+ /**
945
+ * Set the application theme (light/dark/system).
946
+ * Default handler toggles a `data-theme` attribute on `<html>`.
947
+ */
948
+ export declare const setTheme: ClientFunctionDefinition;
949
+
950
+ /**
951
+ * Show a confirm dialog and return the user's choice.
952
+ */
953
+ export declare const showConfirmDialog: ClientFunctionDefinition;
954
+
955
+ /**
956
+ * Show a browser notification (requires permission).
957
+ */
958
+ export declare const showNotification: ClientFunctionDefinition;
959
+
960
+ /**
961
+ * Show a toast/notification to the user.
962
+ * The handler is a no-op by default — wire it up to your toast library.
963
+ *
964
+ * ```ts
965
+ * import { showToast } from "@useago/sdk/helpers";
966
+ * showToast.handler = async (args) => { myToast(args.message); return { shown: true }; };
967
+ * client.registerFunction(showToast);
968
+ * ```
969
+ */
970
+ export declare const showToast: ClientFunctionDefinition;
971
+
972
+ /**
973
+ * SSE stream chunk data
974
+ */
975
+ export declare interface SSEChunkData {
976
+ content?: string;
977
+ full_content?: string;
978
+ message_id?: string;
979
+ status?: MessageStatus;
980
+ thread?: {
981
+ id: string;
982
+ };
983
+ agent?: {
984
+ id: string;
985
+ name: string;
986
+ display_name?: string;
987
+ };
988
+ knowledge_sources?: Array<{
989
+ knowledge_document: {
990
+ id: string;
991
+ title: string;
992
+ use_external_link: boolean;
993
+ external_link_url?: string;
994
+ internal_link_url?: string;
995
+ };
996
+ position: number;
997
+ }>;
998
+ tool_call_data?: boolean;
999
+ type?: string;
1000
+ id?: string;
1001
+ tool_name?: string;
1002
+ tool_display_name?: string;
1003
+ function_name?: string;
1004
+ arguments?: Record<string, unknown>;
1005
+ form_schema?: FormSchema;
1006
+ message?: string;
1007
+ data?: Record<string, unknown>;
1008
+ follow_up_replies?: string[];
1009
+ satisfaction_feedback?: unknown;
1010
+ ask_to_talk_to_human?: boolean;
1011
+ }
1012
+
1013
+ /**
1014
+ * Handles SSE streaming responses from AGO backend
1015
+ */
1016
+ export declare class SSEHandler {
1017
+ private callbacks;
1018
+ private buffer;
1019
+ private message;
1020
+ private toolCalls;
1021
+ private sources;
1022
+ private followUpReplies;
1023
+ private isFirstChunk;
1024
+ constructor(callbacks: SSEHandlerCallbacks);
1025
+ /**
1026
+ * Process a streaming response
1027
+ */
1028
+ processStream(response: Response): Promise<AgoMessage>;
1029
+ private processBuffer;
1030
+ private handleChunk;
1031
+ private parseToolCall;
1032
+ private buildFinalMessage;
1033
+ }
1034
+
1035
+ declare interface SSEHandlerCallbacks {
1036
+ onStart?: (data: {
1037
+ conversationId: string;
1038
+ messageId: string;
1039
+ }) => void;
1040
+ onChunk?: (data: {
1041
+ content: string;
1042
+ conversationId: string;
1043
+ messageId: string;
1044
+ }) => void;
1045
+ onToolCall?: (toolCall: ToolCallData) => void;
1046
+ onClientFunction?: (data: {
1047
+ invocationId: string;
1048
+ functionName: string;
1049
+ arguments: Record<string, unknown>;
1050
+ conversationId: string;
1051
+ }) => void;
1052
+ onComplete?: (message: AgoMessage) => void;
1053
+ onError?: (error: Error) => void;
1054
+ }
1055
+
1056
+ /** The slice of the Web Storage API that {@link createStore} relies on. */
1057
+ declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
1058
+
1059
+ /**
1060
+ * A minimal observable store: one value, synchronous subscriptions, and
1061
+ * optional persistence via {@link PersistOptions} (localStorage by default).
1062
+ *
1063
+ * ```ts
1064
+ * const store = createStore({ count: 0 });
1065
+ * store.subscribe((state) => save(state));
1066
+ * store.set({ count: 1 }); // listeners fire synchronously
1067
+ *
1068
+ * const cart = createStore({ items: [] }, { key: "cart" }); // persisted
1069
+ * ```
1070
+ */
1071
+ export declare interface Store<T> {
1072
+ /** Current state. */
1073
+ get(): T;
1074
+ /** Replace the state and notify subscribers synchronously. */
1075
+ set(next: T): void;
1076
+ /** Register a listener; returns a function that removes it. */
1077
+ subscribe(listener: (state: T) => void): () => void;
1078
+ }
1079
+
1080
+ /**
1081
+ * Where a completed form is sent.
1082
+ * - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
1083
+ * POSTs the values to that URL.
1084
+ * - `{ via: "client", url }` — same, written out.
1085
+ * - `{ via: "client", handler }` — the browser runs your own submit logic.
1086
+ * - `{ via: "backend", destination }` — the browser relays the values to the backend,
1087
+ * which forwards them to the server-configured destination (URL + secret stay server-side).
1088
+ * - `false` — collect only, no submit function.
1089
+ */
1090
+ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
1091
+ via: "client";
1092
+ url: string;
1093
+ } | {
1094
+ via: "client";
1095
+ handler: (values: V) => Promise<unknown> | unknown;
1096
+ } | {
1097
+ via: "backend";
1098
+ destination: string;
1099
+ } | false;
1100
+
1101
+ /**
1102
+ * Submit a form on the page programmatically.
1103
+ */
1104
+ export declare const submitForm: ClientFunctionDefinition;
1105
+
1106
+ /**
1107
+ * Tool call data from SSE stream
1108
+ */
1109
+ export declare interface ToolCallData {
1110
+ id: string;
1111
+ type: ToolCallType;
1112
+ status: string;
1113
+ toolName: string;
1114
+ toolDisplayName?: string;
1115
+ message?: string;
1116
+ formSchema?: FormSchema;
1117
+ data?: Record<string, unknown>;
1118
+ functionName?: string;
1119
+ arguments?: Record<string, unknown>;
1120
+ }
1121
+
1122
+ export declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
1123
+
1124
+ /**
1125
+ * Track a custom analytics event.
1126
+ * Default handler logs to console — replace with your analytics provider.
1127
+ */
1128
+ export declare const trackEvent: ClientFunctionDefinition;
1129
+
1130
+ /**
1131
+ * Attach a handler to a pre-built function definition.
1132
+ *
1133
+ * Pre-built helpers (`showToast`, `trackEvent`, ...) ship with a no-op or
1134
+ * console-logging default handler. Use `withHandler` to wire them up to
1135
+ * your actual implementation without mutating the original definition.
1136
+ *
1137
+ * ```ts
1138
+ * import { showToast, withHandler } from "@useago/sdk";
1139
+ *
1140
+ * client.register(
1141
+ * withHandler(showToast, (args) => {
1142
+ * myToast(args.message as string);
1143
+ * return { shown: true };
1144
+ * })
1145
+ * );
1146
+ * ```
1147
+ */
1148
+ export declare function withHandler<T extends ClientFunctionDefinition>(definition: T, handler: ClientFunctionHandler): T;
1149
+
1150
+ export { }