@useago/sdk 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +53 -6
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +89 -5
- package/dist/angular.d.ts +89 -5
- package/dist/angular.js +11 -7
- package/dist/{createConversationSession-Bgvx753t.js → createConversationSession-BaaXBQ5b.js} +3 -3
- package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
- package/dist/{createFormCollector-CM3qjGcM.js → createFormCollector-Cf7kGhCB.js} +1 -1
- package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
- package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
- package/dist/createMockClient-BZbOe-23.cjs +1 -0
- package/dist/devtools.cjs +61 -12
- package/dist/devtools.d.cts +90 -5
- package/dist/devtools.d.ts +90 -5
- package/dist/devtools.js +225 -73
- package/dist/errors-BLfjXnLB.js +32 -0
- package/dist/errors-o1IB5fEu.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +100 -3
- package/dist/index.d.ts +100 -3
- package/dist/index.js +77 -75
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +197 -3
- package/dist/react.d.ts +197 -3
- package/dist/react.js +1034 -752
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +80 -3
- package/dist/testing.d.ts +80 -3
- package/dist/testing.js +1 -1
- package/dist/{AgoClient-BJjLTOw4.js → types-CPga11Of.js} +489 -386
- package/dist/types-D3YQl1jx.cjs +9 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +110 -3
- package/dist/vue.d.ts +110 -3
- package/dist/vue.js +202 -154
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +148 -3
- package/dist/widget.d.ts +148 -3
- package/dist/widget.js +871 -651
- package/llms-full.txt +144 -30
- package/package.json +1 -1
- package/dist/AgoClient-B_u_d-XS.cjs +0 -9
- package/dist/createConversationSession-BCdwAhLF.cjs +0 -1
- package/dist/createFormCollector-ssBP8u0p.cjs +0 -1
- package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -330,9 +330,40 @@ declare class AgoClient {
|
|
|
330
330
|
*/
|
|
331
331
|
submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
|
|
332
332
|
/**
|
|
333
|
-
*
|
|
333
|
+
* Report an answer: thumbs up/down, optionally with what went wrong.
|
|
334
|
+
*
|
|
335
|
+
* ```ts
|
|
336
|
+
* await client.submitFeedback(message.id, "negative", {
|
|
337
|
+
* reasons: ["inaccurate"],
|
|
338
|
+
* comment: "The price it quoted is from last year.",
|
|
339
|
+
* });
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
|
|
343
|
+
* reason or a comment also files it in the feedback list, the analytics and
|
|
344
|
+
* the CSV export, so someone can act on it.
|
|
334
345
|
*/
|
|
335
|
-
submitFeedback(messageId: string, rating:
|
|
346
|
+
submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Report a whole conversation ("this chat is not working").
|
|
349
|
+
*
|
|
350
|
+
* ```ts
|
|
351
|
+
* await client.submitConversationFeedback(conversationId, "negative", {
|
|
352
|
+
* reasons: ["information_not_found"],
|
|
353
|
+
* comment: "It never answered my question.",
|
|
354
|
+
* });
|
|
355
|
+
* ```
|
|
356
|
+
*
|
|
357
|
+
* Feedback is stored per message, so this attaches the report to the last
|
|
358
|
+
* answer of the conversation, which is the one the user is reacting to.
|
|
359
|
+
* Returns the message id it landed on.
|
|
360
|
+
*
|
|
361
|
+
* Pass `lastMessageId` when you already have it (the widget does) to skip the
|
|
362
|
+
* lookup round-trip.
|
|
363
|
+
*/
|
|
364
|
+
submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
|
|
365
|
+
lastMessageId?: string;
|
|
366
|
+
}): Promise<string>;
|
|
336
367
|
/**
|
|
337
368
|
* Register a client-side function that AGO can call.
|
|
338
369
|
* Accepts either a definition object or (name, handler, schema) args.
|
|
@@ -1048,12 +1079,27 @@ export declare interface AgoStateControl<T = unknown> {
|
|
|
1048
1079
|
enum?: (string | number)[];
|
|
1049
1080
|
};
|
|
1050
1081
|
};
|
|
1082
|
+
/** String-only: `""` means "clear" instead of being dropped as filler. */
|
|
1083
|
+
clearable?: boolean;
|
|
1051
1084
|
/** Current value → pushed as dynamic context so the agent knows what to change. */
|
|
1052
1085
|
get?: () => T;
|
|
1053
1086
|
/** Apply the state change on the page. May be async. */
|
|
1054
|
-
set: (value: T) => void | Promise<void>;
|
|
1087
|
+
set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
|
|
1055
1088
|
}
|
|
1056
1089
|
|
|
1090
|
+
/**
|
|
1091
|
+
* Tagged outcome a page setter may return to reject or mark unchanged.
|
|
1092
|
+
*
|
|
1093
|
+
* Returning nothing (void) means APPLY. Returning an unrecognized JS value
|
|
1094
|
+
* (e.g. a string from an assignment expression) is also treated as APPLY.
|
|
1095
|
+
*/
|
|
1096
|
+
declare type AgoStateSetResult = {
|
|
1097
|
+
result: "rejected";
|
|
1098
|
+
reason: string;
|
|
1099
|
+
} | {
|
|
1100
|
+
result: "unchanged";
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1057
1103
|
/**
|
|
1058
1104
|
* Chat input component with send button
|
|
1059
1105
|
*/
|
|
@@ -1133,6 +1179,17 @@ export declare interface ChatWidgetProps {
|
|
|
1133
1179
|
* fetch the definition from the backend ({@link loadFormCollector}).
|
|
1134
1180
|
*/
|
|
1135
1181
|
forms?: Array<CreateFormCollectorOptions | LoadFormCollectorOptions>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Let the user report an answer that did not work: thumbs under each finished
|
|
1184
|
+
* answer, and after a thumbs-down a panel to say what went wrong. Off by
|
|
1185
|
+
* default. `true` uses the English labels; pass the `<MessageFeedback>` props
|
|
1186
|
+
* to translate the strings or observe what was sent.
|
|
1187
|
+
*
|
|
1188
|
+
* ```tsx
|
|
1189
|
+
* <ChatWidget feedback />
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
feedback?: boolean | Omit<MessageFeedbackProps, "messageId" | "client">;
|
|
1136
1193
|
/**
|
|
1137
1194
|
* How clicking a suggested follow-up reply behaves. Defaults to sending the
|
|
1138
1195
|
* reply as a new user message. Pass a handler to override, or `false` to
|
|
@@ -1377,6 +1434,8 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
|
|
|
1377
1434
|
*/
|
|
1378
1435
|
export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
|
|
1379
1436
|
|
|
1437
|
+
export declare const DEFAULT_MESSAGE_FEEDBACK_LABELS: MessageFeedbackLabels;
|
|
1438
|
+
|
|
1380
1439
|
/**
|
|
1381
1440
|
* Compute which required fields are still empty and whether the form is complete.
|
|
1382
1441
|
* Pure — the single home for the "required + non-empty" rule, shared by the update
|
|
@@ -1404,6 +1463,40 @@ declare interface ElementProps {
|
|
|
1404
1463
|
attrs: Record<string, string | null>;
|
|
1405
1464
|
}
|
|
1406
1465
|
|
|
1466
|
+
/** The four values of {@link FeedbackReason}, in dashboard order. */
|
|
1467
|
+
export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Why the user is reporting a message (see `AgoClient.submitFeedback`).
|
|
1471
|
+
*
|
|
1472
|
+
* A rating on its own is a reaction (the thumbs count). Add a reason or a
|
|
1473
|
+
* comment and the report also lands in the feedback dashboard, the analytics
|
|
1474
|
+
* and the CSV export, where someone can act on it.
|
|
1475
|
+
*/
|
|
1476
|
+
export declare interface FeedbackDetails {
|
|
1477
|
+
/** What went wrong. Several can apply at once. */
|
|
1478
|
+
reasons?: FeedbackReason[];
|
|
1479
|
+
/** The user's own words. Trimmed server-side; 5000 characters max. */
|
|
1480
|
+
comment?: string;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/** Thumbs up / thumbs down on an answer. */
|
|
1484
|
+
export declare type FeedbackRating = "positive" | "negative";
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* What went wrong with an answer. These are the four buckets the AGO feedback
|
|
1488
|
+
* dashboard filters and charts on.
|
|
1489
|
+
*/
|
|
1490
|
+
export declare type FeedbackReason =
|
|
1491
|
+
/** The answer states something false. */
|
|
1492
|
+
"inaccurate"
|
|
1493
|
+
/** The answer is right but stops short. */
|
|
1494
|
+
| "incomplete"
|
|
1495
|
+
/** The agent could not find the information. */
|
|
1496
|
+
| "information_not_found"
|
|
1497
|
+
/** Something broke: the widget, a tool call, the stream. */
|
|
1498
|
+
| "technical_issue";
|
|
1499
|
+
|
|
1407
1500
|
export declare interface FormCollector<V = Record<string, unknown>> {
|
|
1408
1501
|
name: string;
|
|
1409
1502
|
/** Observable store driving the form UI (read via `useAgoStore`). */
|
|
@@ -1656,6 +1749,60 @@ export declare interface MarkdownProps {
|
|
|
1656
1749
|
|
|
1657
1750
|
export declare const Message: default_2.FC<MessageProps>;
|
|
1658
1751
|
|
|
1752
|
+
/**
|
|
1753
|
+
* Thumbs under an answer, and a "what went wrong?" panel after a thumbs-down.
|
|
1754
|
+
*
|
|
1755
|
+
* ```tsx
|
|
1756
|
+
* <MessageFeedback messageId={message.id} />
|
|
1757
|
+
* ```
|
|
1758
|
+
*
|
|
1759
|
+
* The thumb is sent as soon as it is clicked, so the signal survives a user who
|
|
1760
|
+
* ignores the panel; sending the panel then files the detailed report (reasons
|
|
1761
|
+
* and comment), which is what shows up in the AGO feedback dashboard.
|
|
1762
|
+
*/
|
|
1763
|
+
export declare const MessageFeedback: default_2.FC<MessageFeedbackProps>;
|
|
1764
|
+
|
|
1765
|
+
/** Every string the feedback row shows, so a non-English app can translate it. */
|
|
1766
|
+
export declare interface MessageFeedbackLabels {
|
|
1767
|
+
helpful: string;
|
|
1768
|
+
notHelpful: string;
|
|
1769
|
+
whatWentWrong: string;
|
|
1770
|
+
reasons: Record<FeedbackReason, string>;
|
|
1771
|
+
commentPlaceholder: string;
|
|
1772
|
+
send: string;
|
|
1773
|
+
thanks: string;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
export declare interface MessageFeedbackProps {
|
|
1777
|
+
/** The answer being judged. */
|
|
1778
|
+
messageId: string;
|
|
1779
|
+
/** The AGO client. If omitted, reads from AgoProvider context. */
|
|
1780
|
+
client?: AgoClient;
|
|
1781
|
+
/**
|
|
1782
|
+
* After a thumbs-down, open the panel asking what went wrong. Defaults to
|
|
1783
|
+
* `true`; pass `false` to collect thumbs only.
|
|
1784
|
+
*/
|
|
1785
|
+
askWhy?: boolean;
|
|
1786
|
+
/** Override any of the strings (reason labels can be overridden one by one). */
|
|
1787
|
+
labels?: Partial<Omit<MessageFeedbackLabels, "reasons">> & {
|
|
1788
|
+
reasons?: Partial<Record<FeedbackReason, string>>;
|
|
1789
|
+
};
|
|
1790
|
+
/**
|
|
1791
|
+
* Called after a report was accepted by the API. Fires once per accepted
|
|
1792
|
+
* report, so a thumbs-down followed by the panel calls it twice: first for
|
|
1793
|
+
* the bare thumb, then for the detailed report.
|
|
1794
|
+
*/
|
|
1795
|
+
onSubmit?: (report: {
|
|
1796
|
+
messageId: string;
|
|
1797
|
+
rating: FeedbackRating;
|
|
1798
|
+
reasons: FeedbackReason[];
|
|
1799
|
+
comment?: string;
|
|
1800
|
+
}) => void;
|
|
1801
|
+
/** Called when a report could not be sent. */
|
|
1802
|
+
onError?: (error: Error) => void;
|
|
1803
|
+
className?: string;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1659
1806
|
export declare interface MessageProps {
|
|
1660
1807
|
message: AgoMessage;
|
|
1661
1808
|
className?: string;
|
|
@@ -1678,6 +1825,11 @@ export declare interface MessageProps {
|
|
|
1678
1825
|
* bubble is then dropped entirely rather than left as a blank box.
|
|
1679
1826
|
*/
|
|
1680
1827
|
showStreamingDots?: boolean;
|
|
1828
|
+
/**
|
|
1829
|
+
* Rendered under an assistant bubble, above the suggested replies. Meant for
|
|
1830
|
+
* `<MessageFeedback messageId={message.id} />`, but takes any node.
|
|
1831
|
+
*/
|
|
1832
|
+
feedback?: default_2.ReactNode;
|
|
1681
1833
|
}
|
|
1682
1834
|
|
|
1683
1835
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
@@ -2545,6 +2697,48 @@ export declare interface UseConversationResult {
|
|
|
2545
2697
|
refreshConversations: () => Promise<void>;
|
|
2546
2698
|
}
|
|
2547
2699
|
|
|
2700
|
+
/**
|
|
2701
|
+
* Hook to report answers that did not work.
|
|
2702
|
+
*
|
|
2703
|
+
* ```tsx
|
|
2704
|
+
* const { ratings, submitFeedback } = useFeedback();
|
|
2705
|
+
*
|
|
2706
|
+
* <button onClick={() => submitFeedback(message.id, "negative", {
|
|
2707
|
+
* reasons: ["inaccurate"],
|
|
2708
|
+
* })} aria-pressed={ratings[message.id] === "negative"}>
|
|
2709
|
+
* 👎
|
|
2710
|
+
* </button>
|
|
2711
|
+
* ```
|
|
2712
|
+
*
|
|
2713
|
+
* A bare rating is a reaction. Adding a reason or a comment files the report in
|
|
2714
|
+
* the AGO feedback dashboard, where someone can act on it.
|
|
2715
|
+
*/
|
|
2716
|
+
export declare function useFeedback({ client: clientProp, }?: UseFeedbackOptions): UseFeedbackResult;
|
|
2717
|
+
|
|
2718
|
+
export declare interface UseFeedbackOptions {
|
|
2719
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
2720
|
+
client?: AgoClient;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
export declare interface UseFeedbackResult {
|
|
2724
|
+
/**
|
|
2725
|
+
* The rating already sent for each message, keyed by message id. Use it to
|
|
2726
|
+
* light up the thumb the user picked (and to re-render after a change of
|
|
2727
|
+
* mind: sending a new rating overwrites the previous one).
|
|
2728
|
+
*/
|
|
2729
|
+
ratings: Record<string, FeedbackRating>;
|
|
2730
|
+
/** Report one answer. */
|
|
2731
|
+
submitFeedback: (messageId: string, rating: FeedbackRating, details?: FeedbackDetails) => Promise<void>;
|
|
2732
|
+
/** Report the conversation; lands on its last answer, whose id is returned. */
|
|
2733
|
+
submitConversationFeedback: (conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
|
|
2734
|
+
lastMessageId?: string;
|
|
2735
|
+
}) => Promise<string>;
|
|
2736
|
+
/** True while a report is in flight. */
|
|
2737
|
+
isSubmitting: boolean;
|
|
2738
|
+
/** The last failure, or null. Cleared when a new report starts. */
|
|
2739
|
+
error: Error | null;
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2548
2742
|
/**
|
|
2549
2743
|
* React wiring for {@link createFormCollector}: registers the collector's client
|
|
2550
2744
|
* functions + dynamic context on mount, removes them on unmount, and returns the
|