fauna-api 1.0.692 → 1.0.693

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.
@@ -1,7 +1,7 @@
1
1
  import { Cicada } from "./index.js";
2
2
  import { Platform } from "../integrations.js";
3
3
  import { Credentials, ApiKey } from "../authentification.js";
4
- import type { Text } from "../parrot/generative.js";
4
+ import type { Text, Voice } from "../parrot/generative.js";
5
5
  export type InboxGroup = {
6
6
  id: string;
7
7
  name: string;
@@ -30,8 +30,12 @@ export declare function assign(authorization: Credentials | ApiKey, inboxId: str
30
30
  }): Promise<void>;
31
31
  export declare function listAccounts(authorization: Credentials | ApiKey, inboxId: string): Promise<InboxAccount[]>;
32
32
  /** `dailyLimit` and `spentToday` are dollars per UTC day; at the limit the agent pauses until midnight UTC. */
33
+ /** `reasoning` is one of the text model's catalog tiers, empty for its default; `voiceModel`
34
+ * is the realtime voice the agent talks with on calls, empty for the catalog's first. */
33
35
  export type AgentSettings = {
34
36
  model: Text;
37
+ reasoning: string;
38
+ voiceModel: Voice | '';
35
39
  instructions: string;
36
40
  dailyLimit: number;
37
41
  spentToday: number;
@@ -44,6 +48,8 @@ export declare function getAgent(authorization: Credentials | ApiKey, inbox: str
44
48
  /** Turns the agent on (it answers messages sent from now on) or updates it. */
45
49
  export declare function setAgent(authorization: Credentials | ApiKey, inbox: string, settings: {
46
50
  model: Text;
51
+ reasoning?: string;
52
+ voiceModel?: Voice;
47
53
  instructions: string;
48
54
  dailyLimit: number;
49
55
  }): Promise<AgentSettings>;
@@ -61,6 +61,8 @@ export const AgentSettings = {
61
61
  fromJSON(json) {
62
62
  return {
63
63
  model: json.model,
64
+ reasoning: String(json.reasoning ?? ''),
65
+ voiceModel: String(json.voiceModel ?? ''),
64
66
  instructions: String(json.instructions ?? ''),
65
67
  dailyLimit: Number(json.dailyLimit ?? 0),
66
68
  spentToday: Number(json.spentToday ?? 0),
@@ -1,3 +1,4 @@
1
+ import { Cicada } from "./index.js";
1
2
  import { Credentials, ApiKey } from "../authentification.js";
2
3
  import WebSocket from "isomorphic-ws";
3
4
  export type CallEnd = {
@@ -46,3 +47,47 @@ export declare function listen(authorization: Credentials | ApiKey, inbox: strin
46
47
  }>;
47
48
  /** Calls `to` from one of the inbox's phone lines: `from`, or its first line. */
48
49
  export declare function call(authorization: Credentials | ApiKey, inbox: string, to: string, from?: string): Promise<PhoneCall>;
50
+ /** Where in a recording something was said, in milliseconds from its start. */
51
+ export type CallSpan = {
52
+ startMs: number;
53
+ endMs: number;
54
+ };
55
+ /** One side speaking in a recorded call, each word timed. `You` is the inbox's side on a
56
+ * call a person took or placed; `Agent` is the inbox's agent. */
57
+ export type CallSegment = CallSpan & {
58
+ speaker: 'Them' | 'You' | 'Agent';
59
+ text: string;
60
+ words: CallSpan[];
61
+ };
62
+ /** A call on one of the inbox's lines, with its recording's timed transcript. */
63
+ export type CallRecord = {
64
+ id: string;
65
+ direction: 'IN' | 'OUT';
66
+ /** The other party, E.164. */
67
+ peer: string;
68
+ /** The inbox's line, E.164. */
69
+ line: string;
70
+ status: string;
71
+ startedAt: Date;
72
+ /** Seconds it was connected. */
73
+ duration: number;
74
+ /** The inbox's agent took or placed it. */
75
+ agent: boolean;
76
+ /** A message left on the line, or a call that reached their voicemail. */
77
+ voicemail: boolean;
78
+ /** Its audio can be fetched with recording(). */
79
+ recorded: boolean;
80
+ segments: CallSegment[];
81
+ };
82
+ export declare const CallRecord: {
83
+ fromJSON(json: any): CallRecord;
84
+ };
85
+ /** The inbox's calls, newest first. `voicemails` keeps only voicemails; `query` matches what was said, the number, or the contact's name. */
86
+ export declare function history(authorization: Credentials | ApiKey, inbox: string, opts?: {
87
+ voicemails?: boolean;
88
+ query?: string;
89
+ cursor?: number;
90
+ max?: number;
91
+ }): Promise<CallRecord[]>;
92
+ /** A recorded call's audio, MP3. */
93
+ export declare function recording(authorization: Credentials | ApiKey, call: string): Promise<Blob>;
@@ -304,3 +304,49 @@ export async function listen(authorization, inbox, onIncoming) {
304
304
  export async function call(authorization, inbox, to, from) {
305
305
  return openCall(authorization, { event: 'dial', inbox, to, ...(from ? { from } : {}) });
306
306
  }
307
+ export const CallRecord = {
308
+ fromJSON(json) {
309
+ return {
310
+ id: String(json.id),
311
+ direction: json.direction === 'in' ? 'IN' : 'OUT',
312
+ peer: String(json.peer ?? ''),
313
+ line: String(json.line ?? ''),
314
+ status: String(json.status ?? ''),
315
+ startedAt: new Date(json.startedAt),
316
+ duration: Number(json.duration ?? 0),
317
+ agent: Boolean(json.agent),
318
+ voicemail: Boolean(json.voicemail),
319
+ recorded: Boolean(json.recorded),
320
+ segments: Array.isArray(json.segments) ? json.segments : [],
321
+ };
322
+ },
323
+ };
324
+ /** The inbox's calls, newest first. `voicemails` keeps only voicemails; `query` matches what was said, the number, or the contact's name. */
325
+ export async function history(authorization, inbox, opts = {}) {
326
+ const response = await fetch(`${Cicada.getURL()}/cicada/phone/history`, {
327
+ method: 'POST',
328
+ headers: {
329
+ 'Content-Type': 'application/json',
330
+ Authorization: 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
331
+ },
332
+ body: JSON.stringify({ inbox, ...opts }),
333
+ });
334
+ if (!response.ok)
335
+ throw new Error(await response.text());
336
+ const json = await response.json();
337
+ return (Array.isArray(json) ? json : []).map(CallRecord.fromJSON);
338
+ }
339
+ /** A recorded call's audio, MP3. */
340
+ export async function recording(authorization, call) {
341
+ const response = await fetch(`${Cicada.getURL()}/cicada/phone/recording`, {
342
+ method: 'POST',
343
+ headers: {
344
+ 'Content-Type': 'application/json',
345
+ Authorization: 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
346
+ },
347
+ body: JSON.stringify({ call }),
348
+ });
349
+ if (!response.ok)
350
+ throw new Error(await response.text());
351
+ return await response.blob();
352
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fauna-api",
3
- "version": "1.0.692",
3
+ "version": "1.0.693",
4
4
  "description": "The Fauna SDK: accounts, Drive, groups, calendar, chats, payments and every Fauna app (Parrot, Marmot, Magpie, Cicada, Ant, Termite), plus React UI.",
5
5
  "homepage": "https://docs.faunakit.com",
6
6
  "repository": {