@awesomate/sdk 0.19.0 → 0.20.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/dist/index.d.ts +32 -1
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* Docs: https://hub.awesomate.ai/docs/sdk/
|
|
25
25
|
*/
|
|
26
26
|
/** This package's version, sent to the hub with every server call. */
|
|
27
|
-
export declare const VERSION = "0.
|
|
27
|
+
export declare const VERSION = "0.20.0";
|
|
28
28
|
/** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
|
|
29
29
|
export interface Kinds {
|
|
30
30
|
}
|
|
@@ -260,6 +260,22 @@ export interface FilesUsage {
|
|
|
260
260
|
partial: boolean;
|
|
261
261
|
measured_at: string;
|
|
262
262
|
}
|
|
263
|
+
/** An answer from the app's agent to a typed question (app.ask()). */
|
|
264
|
+
export interface AgentAnswer {
|
|
265
|
+
/** answered: from the business's content, with sources; none: the content has no answer (or not for this person). */
|
|
266
|
+
status: 'answered' | 'none';
|
|
267
|
+
answer: string;
|
|
268
|
+
/** Where the answer came from: show them with it. */
|
|
269
|
+
sources: Array<{
|
|
270
|
+
title: string;
|
|
271
|
+
url: string | null;
|
|
272
|
+
}>;
|
|
273
|
+
/**
|
|
274
|
+
* The platform's sentence about keeping questions it could not answer. It comes with a person's
|
|
275
|
+
* first answer only: show it with that answer.
|
|
276
|
+
*/
|
|
277
|
+
questionNotice: string | null;
|
|
278
|
+
}
|
|
263
279
|
/** A file uploaded from an app. Keep `handle` in a record (a kind's file attribute); it opens the file again. */
|
|
264
280
|
export interface AppFile {
|
|
265
281
|
handle: string;
|
|
@@ -1100,6 +1116,21 @@ export declare class AwesomateAppClient {
|
|
|
1100
1116
|
/** The file a handle names, for someone signed in to this app. */
|
|
1101
1117
|
download: (handle: string) => Promise<Blob>;
|
|
1102
1118
|
};
|
|
1119
|
+
/**
|
|
1120
|
+
* Ask the app's agent a typed question, as this signed-in person: a help box that answers from
|
|
1121
|
+
* the business's content, with sources. The agent is the one the account picked for the app (the
|
|
1122
|
+
* same one Talk uses). Show `questionNotice` with the answer when it comes (a person's first).
|
|
1123
|
+
* The agent answers only from content this person may see; the voice persona does not apply.
|
|
1124
|
+
* A refusal's serverCode says why: no_agent, channel_off, person_daily (30 a day per person),
|
|
1125
|
+
* agent_daily, answers_used_up; personMessage is the sentence to show.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* const a = await app.ask('What time do you open on Saturday?');
|
|
1129
|
+
* render(a.answer, a.sources, a.questionNotice);
|
|
1130
|
+
*/
|
|
1131
|
+
ask(question: string, options?: {
|
|
1132
|
+
session?: string;
|
|
1133
|
+
}): Promise<AgentAnswer>;
|
|
1103
1134
|
/**
|
|
1104
1135
|
* The agent this app talks with by voice, or null when the account has not picked one. Pass it
|
|
1105
1136
|
* to AwesomateAgent.mount as agentId; the hub decides which agent answers, never the page.
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* Docs: https://hub.awesomate.ai/docs/sdk/
|
|
25
25
|
*/
|
|
26
26
|
/** This package's version, sent to the hub with every server call. */
|
|
27
|
-
export const VERSION = '0.
|
|
27
|
+
export const VERSION = '0.20.0';
|
|
28
28
|
const DEFAULT_BASE = 'https://hub.awesomate.ai';
|
|
29
29
|
const ERROR_CODES = ['unauthenticated', 'forbidden', 'not_found', 'validation', 'consent_blocked', 'rate_limited', 'conflict', 'unavailable'];
|
|
30
30
|
/**
|
|
@@ -809,6 +809,22 @@ export class AwesomateAppClient {
|
|
|
809
809
|
/** The file a handle names, for someone signed in to this app. */
|
|
810
810
|
download: async (handle) => this.authed(async (token) => (await this.rawData('GET', `/files/${encodeURIComponent(handle)}`, token)).blob()),
|
|
811
811
|
};
|
|
812
|
+
/**
|
|
813
|
+
* Ask the app's agent a typed question, as this signed-in person: a help box that answers from
|
|
814
|
+
* the business's content, with sources. The agent is the one the account picked for the app (the
|
|
815
|
+
* same one Talk uses). Show `questionNotice` with the answer when it comes (a person's first).
|
|
816
|
+
* The agent answers only from content this person may see; the voice persona does not apply.
|
|
817
|
+
* A refusal's serverCode says why: no_agent, channel_off, person_daily (30 a day per person),
|
|
818
|
+
* agent_daily, answers_used_up; personMessage is the sentence to show.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* const a = await app.ask('What time do you open on Saturday?');
|
|
822
|
+
* render(a.answer, a.sources, a.questionNotice);
|
|
823
|
+
*/
|
|
824
|
+
async ask(question, options = {}) {
|
|
825
|
+
const r = await this.data('POST', '/agents/ask', { question, ...(options.session ? { session: options.session } : {}) });
|
|
826
|
+
return { status: r.status, answer: r.answer, sources: r.sources ?? [], questionNotice: r.question_notice ?? null };
|
|
827
|
+
}
|
|
812
828
|
/**
|
|
813
829
|
* The agent this app talks with by voice, or null when the account has not picked one. Pass it
|
|
814
830
|
* to AwesomateAgent.mount as agentId; the hub decides which agent answers, never the page.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesomate/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Your own Awesomate data from Node and the browser: query contacts and app data with generated types, and sign your app's own users in",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|