@awesomate/sdk 0.19.0 → 0.21.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 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.19.0";
27
+ export declare const VERSION = "0.21.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;
@@ -585,7 +601,10 @@ export interface BusinessMapJob {
585
601
  /** active: someone holds it. open: nobody does. hire_next: the owner's next hire. */
586
602
  state: 'active' | 'open' | 'hire_next';
587
603
  isOwnerJob: boolean;
604
+ /** Runs its division: the division manager, above its departments, so departmentNo is null (the owner's job excepted). */
588
605
  headsDivision: boolean;
606
+ /** Runs its department: the person responsible for it, and for its department-level KPIs. */
607
+ headsDepartment: boolean;
589
608
  departmentNo: number | null;
590
609
  reportsTo: {
591
610
  id: number;
@@ -650,10 +669,20 @@ export interface BusinessMapDivision {
650
669
  helpers: Array<BusinessMapHelper & {
651
670
  placedBy: string;
652
671
  }>;
672
+ /** Each department and who runs it: the holder of the job that heads it, else whoever runs the division (byDefault). */
653
673
  departments: Array<{
654
674
  no: number;
655
675
  name: string;
656
676
  gloss: string;
677
+ runBy: {
678
+ name: string;
679
+ byDefault: boolean;
680
+ };
681
+ headJob: {
682
+ id: number;
683
+ slug: string;
684
+ title: string;
685
+ } | null;
657
686
  }>;
658
687
  ideas: Array<{
659
688
  label: string;
@@ -1100,6 +1129,21 @@ export declare class AwesomateAppClient {
1100
1129
  /** The file a handle names, for someone signed in to this app. */
1101
1130
  download: (handle: string) => Promise<Blob>;
1102
1131
  };
1132
+ /**
1133
+ * Ask the app's agent a typed question, as this signed-in person: a help box that answers from
1134
+ * the business's content, with sources. The agent is the one the account picked for the app (the
1135
+ * same one Talk uses). Show `questionNotice` with the answer when it comes (a person's first).
1136
+ * The agent answers only from content this person may see; the voice persona does not apply.
1137
+ * A refusal's serverCode says why: no_agent, channel_off, person_daily (30 a day per person),
1138
+ * agent_daily, answers_used_up; personMessage is the sentence to show.
1139
+ *
1140
+ * @example
1141
+ * const a = await app.ask('What time do you open on Saturday?');
1142
+ * render(a.answer, a.sources, a.questionNotice);
1143
+ */
1144
+ ask(question: string, options?: {
1145
+ session?: string;
1146
+ }): Promise<AgentAnswer>;
1103
1147
  /**
1104
1148
  * The agent this app talks with by voice, or null when the account has not picked one. Pass it
1105
1149
  * 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.19.0';
27
+ export const VERSION = '0.21.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.19.0",
3
+ "version": "0.21.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",