@useago/sdk 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgoClient-B6PsfMeg.cjs +6 -0
- package/dist/{AgoClient-DF7M2WAz.js → AgoClient-BerJvssl.js} +235 -219
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +12 -0
- package/dist/angular.d.ts +12 -0
- package/dist/angular.js +1 -1
- package/dist/createConversationSession-CLZvxyuu.js +58 -0
- package/dist/createConversationSession-D3K5Gf1k.cjs +1 -0
- package/dist/createFormCollector-CD1rqRG4.js +208 -0
- package/dist/createFormCollector-D1FfiSgA.cjs +1 -0
- package/dist/createMockClient-DMFGIOtc.cjs +1 -0
- package/dist/createMockClient-tVsApEAh.js +72 -0
- package/dist/devtools.cjs +26 -26
- package/dist/devtools.d.cts +16 -26
- package/dist/devtools.d.ts +16 -26
- package/dist/devtools.js +55 -55
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +102 -1
- package/dist/index.d.ts +102 -1
- package/dist/index.js +46 -43
- package/dist/react.cjs +19 -19
- package/dist/react.d.cts +67 -8
- package/dist/react.d.ts +67 -8
- package/dist/react.js +1066 -1051
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +12 -0
- package/dist/vue.d.ts +12 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +1 -0
- package/dist/widget.d.cts +635 -0
- package/dist/widget.d.ts +635 -0
- package/dist/widget.js +418 -0
- package/package.json +58 -15
- package/dist/AgoClient-bjN-z2ZQ.cjs +0 -6
- package/dist/createMockClient-D6uVh-B9.js +0 -254
- package/dist/createMockClient-DecMEUcK.cjs +0 -1
- /package/dist/{functions-DdROP6Ui.js → functions-C1-5vadY.js} +0 -0
- /package/dist/{functions-Bz-1Bs3I.cjs → functions-DsmzgHjC.cjs} +0 -0
package/dist/react.d.cts
CHANGED
|
@@ -33,6 +33,12 @@ declare class AgoClient {
|
|
|
33
33
|
* Get a specific conversation with messages
|
|
34
34
|
*/
|
|
35
35
|
getConversation(conversationId: string): Promise<Conversation>;
|
|
36
|
+
/**
|
|
37
|
+
* Map the backend's snake_case `tool_call_data` entries onto the camelCase
|
|
38
|
+
* {@link ToolCallData} shape used everywhere else in the SDK. Mirrors
|
|
39
|
+
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
40
|
+
*/
|
|
41
|
+
private static mapPersistedToolCalls;
|
|
36
42
|
/**
|
|
37
43
|
* Get messages for a conversation
|
|
38
44
|
*/
|
|
@@ -203,6 +209,12 @@ declare interface AgoClientEvents {
|
|
|
203
209
|
conversationId?: string;
|
|
204
210
|
messageId?: string;
|
|
205
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* A full conversation was loaded from the server (e.g. after a page reload).
|
|
214
|
+
* Carries the messages and their persisted tool calls so stateful helpers —
|
|
215
|
+
* notably `createFormCollector` — can replay them to restore their state.
|
|
216
|
+
*/
|
|
217
|
+
"conversation:loaded": Conversation;
|
|
206
218
|
"toolCall:received": ToolCallData;
|
|
207
219
|
"toolCall:form": ToolCallData;
|
|
208
220
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -359,8 +371,20 @@ export declare interface ChatWidgetProps {
|
|
|
359
371
|
height?: string | number;
|
|
360
372
|
/** URL of a logo to display in the header */
|
|
361
373
|
logoUrl?: string;
|
|
362
|
-
/** Show the agent name above assistant messages. Defaults to `
|
|
374
|
+
/** Show the agent name above assistant messages. Defaults to `false`. */
|
|
363
375
|
showAgentName?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Conversational forms the agent can fill and submit during the chat. Each
|
|
378
|
+
* config is installed as a {@link createFormCollector} (its `update_<name>` /
|
|
379
|
+
* `submit_<name>` functions + dynamic context) for the lifetime of the widget.
|
|
380
|
+
*/
|
|
381
|
+
forms?: CreateFormCollectorOptions[];
|
|
382
|
+
/**
|
|
383
|
+
* How clicking a suggested follow-up reply behaves. Defaults to sending the
|
|
384
|
+
* reply as a new user message. Pass a handler to override, or `false` to
|
|
385
|
+
* render the suggestions as non-interactive.
|
|
386
|
+
*/
|
|
387
|
+
onFollowUpClick?: ((reply: string) => void) | false;
|
|
364
388
|
/** Additional CSS class */
|
|
365
389
|
className?: string;
|
|
366
390
|
/** Callback when a message is sent */
|
|
@@ -455,7 +479,29 @@ export declare interface Conversation {
|
|
|
455
479
|
messages?: AgoMessage[];
|
|
456
480
|
}
|
|
457
481
|
|
|
458
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Wire one schema into a conversational form: an observable store, an
|
|
484
|
+
* `update_<name>` client function the agent calls to fill fields, a dynamic-context
|
|
485
|
+
* provider that tells the agent what's still missing, and an optional submit.
|
|
486
|
+
*
|
|
487
|
+
* ```ts
|
|
488
|
+
* const order = createFormCollector({
|
|
489
|
+
* name: "order",
|
|
490
|
+
* description: "The order the user wants to place",
|
|
491
|
+
* schema: {
|
|
492
|
+
* type: "object",
|
|
493
|
+
* properties: { product: { type: "string" }, quantity: { type: "number" } },
|
|
494
|
+
* required: ["product", "quantity"],
|
|
495
|
+
* },
|
|
496
|
+
* submit: { via: "client", url: "/api/orders" },
|
|
497
|
+
* });
|
|
498
|
+
* order.install(client);
|
|
499
|
+
* order.store.subscribe((s) => render(s));
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
export declare function createFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): FormCollector<V>;
|
|
503
|
+
|
|
504
|
+
export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
|
|
459
505
|
/** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
|
|
460
506
|
name: string;
|
|
461
507
|
/** What the form is, for the LLM. */
|
|
@@ -488,7 +534,7 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
|
|
|
488
534
|
*/
|
|
489
535
|
declare type DynamicContextProvider = () => ContextEntry | null | undefined;
|
|
490
536
|
|
|
491
|
-
declare interface FormCollector<V = Record<string, unknown>> {
|
|
537
|
+
export declare interface FormCollector<V = Record<string, unknown>> {
|
|
492
538
|
name: string;
|
|
493
539
|
/** Observable store driving the form UI (read via `useAgoStore`). */
|
|
494
540
|
store: Store<FormCollectorState<V>>;
|
|
@@ -500,6 +546,14 @@ declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
500
546
|
contextProvider: () => ContextEntry;
|
|
501
547
|
/** Register the functions + dynamic context on a client. Returns an uninstall fn. */
|
|
502
548
|
install: (client: AgoClient) => () => void;
|
|
549
|
+
/**
|
|
550
|
+
* Rebuild the state by replaying the persisted `update_<name>` / `submit_<name>`
|
|
551
|
+
* tool-call arguments of a loaded conversation — restoring what the agent had
|
|
552
|
+
* collected after a page reload. Replays from the initial values, so it is
|
|
553
|
+
* idempotent. `install` wires this to the client's `conversation:loaded` event,
|
|
554
|
+
* so a custom front rarely needs to call it directly.
|
|
555
|
+
*/
|
|
556
|
+
hydrate: (toolCalls: readonly ToolCallData[]) => void;
|
|
503
557
|
/** Submit the form now (e.g. from a UI button). Blocks until required fields are filled. */
|
|
504
558
|
submit: () => Promise<FormSubmitResult>;
|
|
505
559
|
getValues: () => Partial<V>;
|
|
@@ -512,10 +566,10 @@ declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
512
566
|
* `parameters`, so one schema feeds the store, the update function, and the
|
|
513
567
|
* dynamic context with no second type.
|
|
514
568
|
*/
|
|
515
|
-
declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
|
|
569
|
+
export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
|
|
516
570
|
|
|
517
571
|
/** Live state held in the collector's store. */
|
|
518
|
-
declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
572
|
+
export declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
519
573
|
/** Field values collected so far. */
|
|
520
574
|
values: Partial<V>;
|
|
521
575
|
/** Required field names still empty. */
|
|
@@ -544,7 +598,7 @@ declare interface FormSchema {
|
|
|
544
598
|
}
|
|
545
599
|
|
|
546
600
|
/** Result returned by `submit()` / the generated `submit_<name>` function. */
|
|
547
|
-
declare interface FormSubmitResult {
|
|
601
|
+
export declare interface FormSubmitResult {
|
|
548
602
|
ok: boolean;
|
|
549
603
|
missing?: string[];
|
|
550
604
|
result?: unknown;
|
|
@@ -569,8 +623,13 @@ export declare const Message: default_2.FC<MessageProps>;
|
|
|
569
623
|
export declare interface MessageProps {
|
|
570
624
|
message: AgoMessage;
|
|
571
625
|
className?: string;
|
|
572
|
-
/** Show the agent name above assistant messages. Defaults to `
|
|
626
|
+
/** Show the agent name above assistant messages. Defaults to `false`. */
|
|
573
627
|
showAgentName?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Called when the user clicks a suggested follow-up reply. When omitted the
|
|
630
|
+
* follow-up buttons render but are not interactive (backwards-compatible).
|
|
631
|
+
*/
|
|
632
|
+
onFollowUpClick?: (reply: string) => void;
|
|
574
633
|
}
|
|
575
634
|
|
|
576
635
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
|
|
@@ -648,7 +707,7 @@ declare interface Store<T> {
|
|
|
648
707
|
* which forwards them to the server-configured destination (URL + secret stay server-side).
|
|
649
708
|
* - `false` — collect only, no submit function.
|
|
650
709
|
*/
|
|
651
|
-
declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
710
|
+
export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
652
711
|
via: "client";
|
|
653
712
|
url: string;
|
|
654
713
|
} | {
|
package/dist/react.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ declare class AgoClient {
|
|
|
33
33
|
* Get a specific conversation with messages
|
|
34
34
|
*/
|
|
35
35
|
getConversation(conversationId: string): Promise<Conversation>;
|
|
36
|
+
/**
|
|
37
|
+
* Map the backend's snake_case `tool_call_data` entries onto the camelCase
|
|
38
|
+
* {@link ToolCallData} shape used everywhere else in the SDK. Mirrors
|
|
39
|
+
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
40
|
+
*/
|
|
41
|
+
private static mapPersistedToolCalls;
|
|
36
42
|
/**
|
|
37
43
|
* Get messages for a conversation
|
|
38
44
|
*/
|
|
@@ -203,6 +209,12 @@ declare interface AgoClientEvents {
|
|
|
203
209
|
conversationId?: string;
|
|
204
210
|
messageId?: string;
|
|
205
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* A full conversation was loaded from the server (e.g. after a page reload).
|
|
214
|
+
* Carries the messages and their persisted tool calls so stateful helpers —
|
|
215
|
+
* notably `createFormCollector` — can replay them to restore their state.
|
|
216
|
+
*/
|
|
217
|
+
"conversation:loaded": Conversation;
|
|
206
218
|
"toolCall:received": ToolCallData;
|
|
207
219
|
"toolCall:form": ToolCallData;
|
|
208
220
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -359,8 +371,20 @@ export declare interface ChatWidgetProps {
|
|
|
359
371
|
height?: string | number;
|
|
360
372
|
/** URL of a logo to display in the header */
|
|
361
373
|
logoUrl?: string;
|
|
362
|
-
/** Show the agent name above assistant messages. Defaults to `
|
|
374
|
+
/** Show the agent name above assistant messages. Defaults to `false`. */
|
|
363
375
|
showAgentName?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Conversational forms the agent can fill and submit during the chat. Each
|
|
378
|
+
* config is installed as a {@link createFormCollector} (its `update_<name>` /
|
|
379
|
+
* `submit_<name>` functions + dynamic context) for the lifetime of the widget.
|
|
380
|
+
*/
|
|
381
|
+
forms?: CreateFormCollectorOptions[];
|
|
382
|
+
/**
|
|
383
|
+
* How clicking a suggested follow-up reply behaves. Defaults to sending the
|
|
384
|
+
* reply as a new user message. Pass a handler to override, or `false` to
|
|
385
|
+
* render the suggestions as non-interactive.
|
|
386
|
+
*/
|
|
387
|
+
onFollowUpClick?: ((reply: string) => void) | false;
|
|
364
388
|
/** Additional CSS class */
|
|
365
389
|
className?: string;
|
|
366
390
|
/** Callback when a message is sent */
|
|
@@ -455,7 +479,29 @@ export declare interface Conversation {
|
|
|
455
479
|
messages?: AgoMessage[];
|
|
456
480
|
}
|
|
457
481
|
|
|
458
|
-
|
|
482
|
+
/**
|
|
483
|
+
* Wire one schema into a conversational form: an observable store, an
|
|
484
|
+
* `update_<name>` client function the agent calls to fill fields, a dynamic-context
|
|
485
|
+
* provider that tells the agent what's still missing, and an optional submit.
|
|
486
|
+
*
|
|
487
|
+
* ```ts
|
|
488
|
+
* const order = createFormCollector({
|
|
489
|
+
* name: "order",
|
|
490
|
+
* description: "The order the user wants to place",
|
|
491
|
+
* schema: {
|
|
492
|
+
* type: "object",
|
|
493
|
+
* properties: { product: { type: "string" }, quantity: { type: "number" } },
|
|
494
|
+
* required: ["product", "quantity"],
|
|
495
|
+
* },
|
|
496
|
+
* submit: { via: "client", url: "/api/orders" },
|
|
497
|
+
* });
|
|
498
|
+
* order.install(client);
|
|
499
|
+
* order.store.subscribe((s) => render(s));
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
export declare function createFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): FormCollector<V>;
|
|
503
|
+
|
|
504
|
+
export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
|
|
459
505
|
/** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
|
|
460
506
|
name: string;
|
|
461
507
|
/** What the form is, for the LLM. */
|
|
@@ -488,7 +534,7 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
|
|
|
488
534
|
*/
|
|
489
535
|
declare type DynamicContextProvider = () => ContextEntry | null | undefined;
|
|
490
536
|
|
|
491
|
-
declare interface FormCollector<V = Record<string, unknown>> {
|
|
537
|
+
export declare interface FormCollector<V = Record<string, unknown>> {
|
|
492
538
|
name: string;
|
|
493
539
|
/** Observable store driving the form UI (read via `useAgoStore`). */
|
|
494
540
|
store: Store<FormCollectorState<V>>;
|
|
@@ -500,6 +546,14 @@ declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
500
546
|
contextProvider: () => ContextEntry;
|
|
501
547
|
/** Register the functions + dynamic context on a client. Returns an uninstall fn. */
|
|
502
548
|
install: (client: AgoClient) => () => void;
|
|
549
|
+
/**
|
|
550
|
+
* Rebuild the state by replaying the persisted `update_<name>` / `submit_<name>`
|
|
551
|
+
* tool-call arguments of a loaded conversation — restoring what the agent had
|
|
552
|
+
* collected after a page reload. Replays from the initial values, so it is
|
|
553
|
+
* idempotent. `install` wires this to the client's `conversation:loaded` event,
|
|
554
|
+
* so a custom front rarely needs to call it directly.
|
|
555
|
+
*/
|
|
556
|
+
hydrate: (toolCalls: readonly ToolCallData[]) => void;
|
|
503
557
|
/** Submit the form now (e.g. from a UI button). Blocks until required fields are filled. */
|
|
504
558
|
submit: () => Promise<FormSubmitResult>;
|
|
505
559
|
getValues: () => Partial<V>;
|
|
@@ -512,10 +566,10 @@ declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
512
566
|
* `parameters`, so one schema feeds the store, the update function, and the
|
|
513
567
|
* dynamic context with no second type.
|
|
514
568
|
*/
|
|
515
|
-
declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
|
|
569
|
+
export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
|
|
516
570
|
|
|
517
571
|
/** Live state held in the collector's store. */
|
|
518
|
-
declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
572
|
+
export declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
519
573
|
/** Field values collected so far. */
|
|
520
574
|
values: Partial<V>;
|
|
521
575
|
/** Required field names still empty. */
|
|
@@ -544,7 +598,7 @@ declare interface FormSchema {
|
|
|
544
598
|
}
|
|
545
599
|
|
|
546
600
|
/** Result returned by `submit()` / the generated `submit_<name>` function. */
|
|
547
|
-
declare interface FormSubmitResult {
|
|
601
|
+
export declare interface FormSubmitResult {
|
|
548
602
|
ok: boolean;
|
|
549
603
|
missing?: string[];
|
|
550
604
|
result?: unknown;
|
|
@@ -569,8 +623,13 @@ export declare const Message: default_2.FC<MessageProps>;
|
|
|
569
623
|
export declare interface MessageProps {
|
|
570
624
|
message: AgoMessage;
|
|
571
625
|
className?: string;
|
|
572
|
-
/** Show the agent name above assistant messages. Defaults to `
|
|
626
|
+
/** Show the agent name above assistant messages. Defaults to `false`. */
|
|
573
627
|
showAgentName?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Called when the user clicks a suggested follow-up reply. When omitted the
|
|
630
|
+
* follow-up buttons render but are not interactive (backwards-compatible).
|
|
631
|
+
*/
|
|
632
|
+
onFollowUpClick?: (reply: string) => void;
|
|
574
633
|
}
|
|
575
634
|
|
|
576
635
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED";
|
|
@@ -648,7 +707,7 @@ declare interface Store<T> {
|
|
|
648
707
|
* which forwards them to the server-configured destination (URL + secret stay server-side).
|
|
649
708
|
* - `false` — collect only, no submit function.
|
|
650
709
|
*/
|
|
651
|
-
declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
710
|
+
export declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
652
711
|
via: "client";
|
|
653
712
|
url: string;
|
|
654
713
|
} | {
|