fauna-api 1.0.771 → 1.0.780

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,3 +1,4 @@
1
+ import { Cicada } from "./index.js";
1
2
  import { Credentials, ApiKey } from "../authentification.js";
2
3
  export type AddressKind = 'email' | 'phone' | 'discord';
3
4
  export type Address = {
@@ -14,6 +15,19 @@ export type Contact = {
14
15
  /** That Fauna account's picture. */
15
16
  icon?: string;
16
17
  };
18
+ /** One of the inbox's owners, behind one of their verified addresses: show "You" when
19
+ * `owner` is your own email, else their name. */
20
+ export type Owner = {
21
+ /** The owner's email. */
22
+ owner: string;
23
+ displayName?: string;
24
+ icon?: string;
25
+ /** The address as it appeared. */
26
+ address: string;
27
+ };
28
+ export declare const Owner: {
29
+ fromJSON(json: any): Owner;
30
+ };
17
31
  /** Every contact, sorted by display name. */
18
32
  export declare function list(authorization: Credentials | ApiKey): Promise<Contact[]>;
19
33
  /** Creates a contact, or with `id` renames one and replaces its addresses. */
@@ -1,4 +1,14 @@
1
1
  import { Cicada } from "./index.js";
2
+ export const Owner = {
3
+ fromJSON(json) {
4
+ return {
5
+ owner: String(json.owner),
6
+ ...(json.displayName ? { displayName: String(json.displayName) } : {}),
7
+ ...(json.icon ? { icon: String(json.icon) } : {}),
8
+ address: String(json.address ?? ''),
9
+ };
10
+ },
11
+ };
2
12
  /** Every contact, sorted by display name. */
3
13
  export async function list(authorization) {
4
14
  const response = await fetch(`${Cicada.getURL()}/cicada/contacts`, {
@@ -1,11 +1,11 @@
1
- import { Contact } from "./contacts.js";
1
+ import { Contact, Owner } from "./contacts.js";
2
2
  import { Platform } from "../integrations.js";
3
3
  import { Credentials, ApiKey } from "../authentification.js";
4
4
  import { File as FaunaFile } from "../drive.js";
5
5
  export type Conversation = {
6
6
  id: string;
7
7
  inboxId?: string;
8
- participants: (Contact | string)[];
8
+ participants: (Contact | Owner | string)[];
9
9
  activeAt: Date;
10
10
  unread: number;
11
11
  };
@@ -22,14 +22,14 @@ export type ScheduledSend = {
22
22
  conversation: string;
23
23
  platform?: Platform;
24
24
  } | {
25
- recipients: (Contact | string)[];
25
+ recipients: (Contact | Owner | string)[];
26
26
  mode: 'broadcast' | 'group';
27
27
  platform: Platform;
28
28
  };
29
29
  };
30
30
  export type Message = {
31
31
  id: string;
32
- author: Contact | string;
32
+ author: Contact | Owner | string;
33
33
  platform: Platform;
34
34
  createdAt: Date;
35
35
  message: string;
@@ -1,4 +1,5 @@
1
1
  import { Cicada } from "./index.js";
2
+ import { Owner } from "./contacts.js";
2
3
  import { Credentials, ApiKey } from "../authentification.js";
3
4
  import WebSocket from "isomorphic-ws";
4
5
  export type CallEnd = {
@@ -65,6 +66,8 @@ export type CallRecord = {
65
66
  direction: 'IN' | 'OUT';
66
67
  /** The other party, E.164. */
67
68
  peer: string;
69
+ /** When `peer` is one of the inbox's owners: who they are. */
70
+ peerOwner?: Owner;
68
71
  /** The inbox's line, E.164. */
69
72
  line: string;
70
73
  status: string;
@@ -11,6 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _PhoneCall_instances, _PhoneCall_ws, _PhoneCall_statusListeners, _PhoneCall_queue, _PhoneCall_wake, _PhoneCall_closed, _PhoneCall_ended, _PhoneCall_setStatus, _IncomingCall_authorization, _IncomingCall_ringing, _IncomingCall_accepted;
13
13
  import { Cicada } from "./index.js";
14
+ import { Owner } from "./contacts.js";
14
15
  import WebSocket from "isomorphic-ws";
15
16
  function toBytes(data) {
16
17
  if (data instanceof Uint8Array)
@@ -310,6 +311,7 @@ export const CallRecord = {
310
311
  id: String(json.id),
311
312
  direction: json.direction === 'in' ? 'IN' : 'OUT',
312
313
  peer: String(json.peer ?? ''),
314
+ ...(json.peerOwner ? { peerOwner: Owner.fromJSON(json.peerOwner) } : {}),
313
315
  line: String(json.line ?? ''),
314
316
  status: String(json.status ?? ''),
315
317
  startedAt: new Date(json.startedAt),
@@ -30,10 +30,13 @@ export declare function generateTextSync(authorization: Credentials | ApiKey, mo
30
30
  export declare function generateVoice(authorization: Credentials | ApiKey, model: Voice, options?: Partial<{
31
31
  content: Content[];
32
32
  audio: AsyncIterable<Uint8Array>;
33
+ notes: AsyncIterable<string>;
33
34
  tools: Tool[] | Tool;
34
35
  maxTools: number;
35
36
  voice: Partial<Demographic>;
36
37
  memories: number;
38
+ brain: Text;
39
+ reasoning: string;
37
40
  group: Group;
38
41
  signal: AbortSignal;
39
42
  }>): AsyncGenerator<VoiceEvent>;
@@ -78,7 +78,10 @@ export async function* generateText(authorization, model, options) {
78
78
  export async function generateTextSync(authorization, model, options) {
79
79
  return collectText(generateText(authorization, model, options));
80
80
  }
81
- // Realtime voice: PCM16 16 kHz in from `audio`, PCM16 24 kHz out as audio events.
81
+ // Realtime voice: PCM16 16 kHz in from `audio`, PCM16 24 kHz out as audio events. Each of
82
+ // `notes` tells the model something to act on now. An ElevenLabs voice thinks with `brain`
83
+ // (a text model, through Fauna) at `reasoning`, and needs one; OpenAI and xAI voices are their
84
+ // own brain.
82
85
  export async function* generateVoice(authorization, model, options) {
83
86
  yield* streamVoice(authorization, '/agent/voice', model, options);
84
87
  }
@@ -54,7 +54,7 @@ export declare enum Speech {
54
54
  }
55
55
  export declare enum Transcription {
56
56
  GPT_TRANSCRIBE = "gpt-transcribe",
57
- GROK_STT = "grok-stt",
57
+ GROK_VOICE_TRANSCRIBE_2_0 = "grok-voice-transcribe-2.0",
58
58
  SCRIBE_V2 = "scribe_v2"
59
59
  }
60
60
  export declare enum Embedding {
@@ -245,17 +245,23 @@ export declare function generateTranscription(authorization: Credentials | ApiKe
245
245
  export declare function generateVoice(authorization: Credentials | ApiKey, model: Voice, options?: Partial<{
246
246
  content: Content[];
247
247
  audio: AsyncIterable<Uint8Array>;
248
+ notes: AsyncIterable<string>;
248
249
  tools: Tool[] | Tool;
249
250
  maxTools: number;
250
251
  voice: Partial<Demographic>;
252
+ brain: Text;
253
+ reasoning: string;
251
254
  signal: AbortSignal;
252
255
  group: Group;
253
256
  }>): AsyncGenerator<VoiceEvent>;
254
257
  export declare function generateVoiceSync(authorization: Credentials | ApiKey, model: Voice, options?: Partial<{
255
258
  content: Content[];
256
259
  audio: AsyncIterable<Uint8Array>;
260
+ notes: AsyncIterable<string>;
257
261
  tools: Tool[] | Tool;
258
262
  maxTools: number;
259
263
  voice: Partial<Demographic>;
264
+ brain: Text;
265
+ reasoning: string;
260
266
  group: Group;
261
267
  }>): Promise<TextResponse>;
@@ -68,7 +68,7 @@ export var Transcription;
68
68
  // OpenAI
69
69
  Transcription["GPT_TRANSCRIBE"] = "gpt-transcribe";
70
70
  // xAI
71
- Transcription["GROK_STT"] = "grok-stt";
71
+ Transcription["GROK_VOICE_TRANSCRIBE_2_0"] = "grok-voice-transcribe-2.0";
72
72
  // ElevenLabs
73
73
  Transcription["SCRIBE_V2"] = "scribe_v2";
74
74
  })(Transcription || (Transcription = {}));
@@ -176,7 +176,9 @@ export async function generateSpeech(authorization, model, options = {}) {
176
176
  export async function generateTranscription(authorization, model, options = {}) {
177
177
  return generateMedia(authorization, '/generative/transcription', model, options, 'application/octet-stream');
178
178
  }
179
- // Streaming Voice Generation
179
+ // Streaming Voice Generation. Each of `notes` tells the model something to act on now. An
180
+ // ElevenLabs voice thinks with `brain` (a text model, through Fauna) at `reasoning`, and needs
181
+ // one; OpenAI and xAI voices are their own brain.
180
182
  export async function* generateVoice(authorization, model, options = {}) {
181
183
  yield* streamVoice(authorization, '/generative/voice', model, options);
182
184
  }
@@ -1,7 +1,7 @@
1
1
  import { Credentials, ApiKey } from "../authentification.js";
2
2
  import type { Group } from "../groups.js";
3
3
  import type { Demographic } from "../ant/persona.js";
4
- import { type Content, type StreamEvent, type TextResponse, type Tool, type VoiceEvent } from "./generative.js";
4
+ import { type Content, type StreamEvent, type Text, type TextResponse, type Tool, type VoiceEvent } from "./generative.js";
5
5
  /** A Parrot socket URL; `group` adds the Group header (shared memory, group billing). */
6
6
  export declare function socketUrl(path: string, authorization: Credentials | ApiKey, group?: Group): string;
7
7
  /** FILE parts become path or access code refs (uploading offline files first); no binaries go up. */
@@ -27,10 +27,13 @@ export declare function collectText(stream: AsyncGenerator<StreamEvent>): Promis
27
27
  type VoiceOptions = Partial<{
28
28
  content: Content[];
29
29
  audio: AsyncIterable<Uint8Array>;
30
+ notes: AsyncIterable<string>;
30
31
  tools: Tool[] | Tool;
31
32
  maxTools: number;
32
33
  voice: Partial<Demographic>;
33
34
  memories: number;
35
+ brain: Text;
36
+ reasoning: string;
34
37
  group: Group;
35
38
  signal: AbortSignal;
36
39
  }>;
@@ -393,6 +393,8 @@ export async function* streamVoice(authorization, path, model, options = {}) {
393
393
  maxTools: options.maxTools,
394
394
  voice: options.voice,
395
395
  memories: options.memories,
396
+ brain: options.brain,
397
+ reasoning: options.reasoning,
396
398
  }));
397
399
  ws.send(JSON.stringify({ event: 'start' }));
398
400
  if (options.audio) {
@@ -407,6 +409,18 @@ export async function* streamVoice(authorization, path, model, options = {}) {
407
409
  catch { }
408
410
  })();
409
411
  }
412
+ if (options.notes) {
413
+ void (async () => {
414
+ try {
415
+ for await (const text of options.notes) {
416
+ if (ws.readyState !== WebSocket.OPEN)
417
+ break;
418
+ ws.send(JSON.stringify({ event: 'note', text }));
419
+ }
420
+ }
421
+ catch { }
422
+ })();
423
+ }
410
424
  yield* readEvents(ws, (msg, queue) => {
411
425
  const data = msg.data;
412
426
  if (typeof data !== 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fauna-api",
3
- "version": "1.0.771",
3
+ "version": "1.0.780",
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": {