fauna-api 0.0.0-stage → 1.0.676

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.
Files changed (171) hide show
  1. package/dist/brands.d.ts +2 -0
  2. package/dist/brands.js +2 -0
  3. package/dist/index.d.ts +64 -0
  4. package/dist/index.js +121 -0
  5. package/dist/src/ant/chat.d.ts +130 -0
  6. package/dist/src/ant/chat.js +467 -0
  7. package/dist/src/ant/format.d.ts +40 -0
  8. package/dist/src/ant/format.js +143 -0
  9. package/dist/src/ant/graph.d.ts +130 -0
  10. package/dist/src/ant/graph.js +449 -0
  11. package/dist/src/ant/index.d.ts +16 -0
  12. package/dist/src/ant/index.js +61 -0
  13. package/dist/src/ant/persona.d.ts +151 -0
  14. package/dist/src/ant/persona.js +136 -0
  15. package/dist/src/ant/timeline.d.ts +283 -0
  16. package/dist/src/ant/timeline.js +1025 -0
  17. package/dist/src/authentification.d.ts +45 -0
  18. package/dist/src/authentification.js +194 -0
  19. package/dist/src/billing.d.ts +135 -0
  20. package/dist/src/billing.js +128 -0
  21. package/dist/src/calendar.d.ts +83 -0
  22. package/dist/src/calendar.js +133 -0
  23. package/dist/src/chats.d.ts +113 -0
  24. package/dist/src/chats.js +100 -0
  25. package/dist/src/cicada/contacts.d.ts +31 -0
  26. package/dist/src/cicada/contacts.js +28 -0
  27. package/dist/src/cicada/conversations.d.ts +73 -0
  28. package/dist/src/cicada/conversations.js +236 -0
  29. package/dist/src/cicada/inboxes.d.ts +48 -0
  30. package/dist/src/cicada/inboxes.js +82 -0
  31. package/dist/src/cicada/index.d.ts +16 -0
  32. package/dist/src/cicada/index.js +61 -0
  33. package/dist/src/cicada/phone.d.ts +48 -0
  34. package/dist/src/cicada/phone.js +306 -0
  35. package/dist/src/drive.d.ts +80 -0
  36. package/dist/src/drive.js +472 -0
  37. package/dist/src/extensions/index.d.ts +4 -0
  38. package/dist/src/extensions/index.js +5 -0
  39. package/dist/src/extensions/web/index.d.ts +6 -0
  40. package/dist/src/extensions/web/index.js +7 -0
  41. package/dist/src/extensions/web/session.d.ts +106 -0
  42. package/dist/src/extensions/web/session.js +469 -0
  43. package/dist/src/extensions/web/tools.d.ts +13 -0
  44. package/dist/src/extensions/web/tools.js +72 -0
  45. package/dist/src/friends.d.ts +39 -0
  46. package/dist/src/friends.js +119 -0
  47. package/dist/src/groups.d.ts +82 -0
  48. package/dist/src/groups.js +269 -0
  49. package/dist/src/inbox.d.ts +11 -0
  50. package/dist/src/inbox.js +35 -0
  51. package/dist/src/integrations.d.ts +52 -0
  52. package/dist/src/integrations.js +205 -0
  53. package/dist/src/magpie/explorer.d.ts +14 -0
  54. package/dist/src/magpie/explorer.js +36 -0
  55. package/dist/src/magpie/index.d.ts +16 -0
  56. package/dist/src/magpie/index.js +61 -0
  57. package/dist/src/magpie/portfolio.d.ts +52 -0
  58. package/dist/src/magpie/portfolio.js +179 -0
  59. package/dist/src/magpie/quotes.d.ts +35 -0
  60. package/dist/src/magpie/quotes.js +47 -0
  61. package/dist/src/magpie/room.d.ts +61 -0
  62. package/dist/src/magpie/room.js +238 -0
  63. package/dist/src/maps.d.ts +159 -0
  64. package/dist/src/maps.js +171 -0
  65. package/dist/src/marmot/browser.d.ts +139 -0
  66. package/dist/src/marmot/browser.js +389 -0
  67. package/dist/src/marmot/index.d.ts +20 -0
  68. package/dist/src/marmot/index.js +65 -0
  69. package/dist/src/marmot/media.d.ts +56 -0
  70. package/dist/src/marmot/media.js +265 -0
  71. package/dist/src/marmot/research.d.ts +337 -0
  72. package/dist/src/marmot/research.js +1138 -0
  73. package/dist/src/marmot/scraper.d.ts +59 -0
  74. package/dist/src/marmot/scraper.js +94 -0
  75. package/dist/src/marmot/web.d.ts +402 -0
  76. package/dist/src/marmot/web.js +2586 -0
  77. package/dist/src/marmot/workspace.d.ts +81 -0
  78. package/dist/src/marmot/workspace.js +263 -0
  79. package/dist/src/parrot/agent.d.ts +53 -0
  80. package/dist/src/parrot/agent.js +93 -0
  81. package/dist/src/parrot/chat.d.ts +84 -0
  82. package/dist/src/parrot/chat.js +237 -0
  83. package/dist/src/parrot/format.d.ts +128 -0
  84. package/dist/src/parrot/format.js +639 -0
  85. package/dist/src/parrot/generative.d.ts +261 -0
  86. package/dist/src/parrot/generative.js +185 -0
  87. package/dist/src/parrot/index.d.ts +22 -0
  88. package/dist/src/parrot/index.js +67 -0
  89. package/dist/src/parrot/room.d.ts +225 -0
  90. package/dist/src/parrot/room.js +466 -0
  91. package/dist/src/parrot/routing.d.ts +90 -0
  92. package/dist/src/parrot/routing.js +78 -0
  93. package/dist/src/parrot/share.d.ts +126 -0
  94. package/dist/src/parrot/share.js +261 -0
  95. package/dist/src/parrot/socket.d.ts +41 -0
  96. package/dist/src/parrot/socket.js +478 -0
  97. package/dist/src/payments.d.ts +73 -0
  98. package/dist/src/payments.js +107 -0
  99. package/dist/src/private/cards.css +75 -0
  100. package/dist/src/rooms.d.ts +76 -0
  101. package/dist/src/rooms.js +168 -0
  102. package/dist/src/shared/schema.d.ts +24 -0
  103. package/dist/src/shared/schema.js +1 -0
  104. package/dist/src/shared/server.d.ts +65 -0
  105. package/dist/src/shared/server.js +302 -0
  106. package/dist/src/termite/environment.d.ts +110 -0
  107. package/dist/src/termite/environment.js +263 -0
  108. package/dist/src/termite/index.d.ts +14 -0
  109. package/dist/src/termite/index.js +59 -0
  110. package/dist/src/termite/os.d.ts +326 -0
  111. package/dist/src/termite/os.js +572 -0
  112. package/dist/src/termite/versioning.d.ts +94 -0
  113. package/dist/src/termite/versioning.js +217 -0
  114. package/dist/src/tickets.d.ts +43 -0
  115. package/dist/src/tickets.js +138 -0
  116. package/dist/src/travel.d.ts +85 -0
  117. package/dist/src/travel.js +44 -0
  118. package/dist/src/ui/authentification.d.ts +24 -0
  119. package/dist/src/ui/authentification.js +177 -0
  120. package/dist/src/ui/brands.css +11 -0
  121. package/dist/src/ui/brands.d.ts +7 -0
  122. package/dist/src/ui/brands.js +14 -0
  123. package/dist/src/ui/browser.d.ts +74 -0
  124. package/dist/src/ui/browser.js +470 -0
  125. package/dist/src/ui/chat.d.ts +183 -0
  126. package/dist/src/ui/chat.js +2379 -0
  127. package/dist/src/ui/chatPanel.d.ts +109 -0
  128. package/dist/src/ui/chatPanel.js +768 -0
  129. package/dist/src/ui/chatSequence.d.ts +36 -0
  130. package/dist/src/ui/chatSequence.js +42 -0
  131. package/dist/src/ui/crown.d.ts +19 -0
  132. package/dist/src/ui/crown.js +199 -0
  133. package/dist/src/ui/cursor.d.ts +73 -0
  134. package/dist/src/ui/cursor.js +175 -0
  135. package/dist/src/ui/device.d.ts +33 -0
  136. package/dist/src/ui/device.js +49 -0
  137. package/dist/src/ui/drive.d.ts +69 -0
  138. package/dist/src/ui/drive.js +1243 -0
  139. package/dist/src/ui/generative.d.ts +39 -0
  140. package/dist/src/ui/generative.js +313 -0
  141. package/dist/src/ui/hover.d.ts +6 -0
  142. package/dist/src/ui/hover.js +210 -0
  143. package/dist/src/ui/index.d.ts +42 -0
  144. package/dist/src/ui/index.js +87 -0
  145. package/dist/src/ui/integrations.d.ts +13 -0
  146. package/dist/src/ui/integrations.js +175 -0
  147. package/dist/src/ui/maps.d.ts +87 -0
  148. package/dist/src/ui/maps.js +547 -0
  149. package/dist/src/ui/roster.d.ts +32 -0
  150. package/dist/src/ui/roster.js +163 -0
  151. package/dist/src/ui/talk.d.ts +12 -0
  152. package/dist/src/ui/talk.js +560 -0
  153. package/dist/src/ui/tickets.d.ts +13 -0
  154. package/dist/src/ui/tickets.js +966 -0
  155. package/dist/src/ui/toast.d.ts +7 -0
  156. package/dist/src/ui/toast.js +258 -0
  157. package/dist/src/ui/tokenText.d.ts +18 -0
  158. package/dist/src/ui/tokenText.js +96 -0
  159. package/dist/src/ui/tokenized.d.ts +42 -0
  160. package/dist/src/ui/tokenized.js +622 -0
  161. package/dist/src/ui/ui.css +4763 -0
  162. package/dist/src/ui/view.d.ts +23 -0
  163. package/dist/src/ui/view.js +584 -0
  164. package/dist/src/view.d.ts +113 -0
  165. package/dist/src/view.js +386 -0
  166. package/dist/src/webhooks.d.ts +66 -0
  167. package/dist/src/webhooks.js +78 -0
  168. package/dist/ui.d.ts +1 -0
  169. package/dist/ui.js +1 -0
  170. package/package.json +89 -6
  171. package/README.md +0 -3
@@ -0,0 +1,81 @@
1
+ import { ApiKey, Credentials } from "../authentification.js";
2
+ import { Group } from "../groups.js";
3
+ import { Authorization, Presence, Room, Hooks as ServerHooks } from "../shared/server.js";
4
+ import { ChatRoom, RoomHooks } from "../parrot/room.js";
5
+ import { Scraper } from "./scraper.js";
6
+ export type WorkspaceFile = {
7
+ name: string;
8
+ contentType: string;
9
+ size: number;
10
+ key: string;
11
+ };
12
+ export type WorkspaceDatasetMeta = {
13
+ id: string;
14
+ name: string;
15
+ schema: unknown;
16
+ termination: unknown[];
17
+ contentTypes: string[];
18
+ proxy: string;
19
+ documentModes: string[];
20
+ createdAt: number;
21
+ };
22
+ export type WorkspaceSummary = {
23
+ id: string;
24
+ name: string;
25
+ description: string;
26
+ createdAt: number;
27
+ datasets: number;
28
+ files: number;
29
+ };
30
+ export declare function listWorkspaces(authorization: Credentials | ApiKey, opts?: {
31
+ group?: Group;
32
+ }): Promise<WorkspaceSummary[]>;
33
+ export declare function createWorkspace(authorization: Credentials | ApiKey, name: string, description?: string, opts?: {
34
+ group?: Group;
35
+ }): Promise<string>;
36
+ export declare function updateWorkspace(authorization: Credentials | ApiKey, id: string, update: Partial<{
37
+ name: string;
38
+ description: string;
39
+ }>, opts?: {
40
+ group?: Group;
41
+ }): Promise<void>;
42
+ export declare function removeWorkspace(authorization: Credentials | ApiKey, id: string, opts?: {
43
+ group?: Group;
44
+ }): Promise<void>;
45
+ export declare class WorkspaceRoom extends Room {
46
+ workspaceId: string;
47
+ name: string;
48
+ description: string;
49
+ files: Map<string, WorkspaceFile>;
50
+ datasets: Map<string, WorkspaceDatasetMeta>;
51
+ /** Kept datasets, by dataset id. */
52
+ scrapers: Map<string, Scraper>;
53
+ /** The Termite repository whose machine runs the workspace's scrapers, once there is one. */
54
+ repositoryId: number | null;
55
+ /** The model the workspace's scraper agent thinks with. */
56
+ agentText: string;
57
+ constructor(endpoint: string, ws: WebSocket, authorization: Authorization, id: string);
58
+ hydrate(state: any): void;
59
+ handleEvent(packet: any): void;
60
+ getChat(hooks?: RoomHooks): Promise<{
61
+ room: ChatRoom;
62
+ self: Presence;
63
+ chatId: string;
64
+ }>;
65
+ static connect(authorization: Credentials | ApiKey, target: {
66
+ id: string;
67
+ }, opts?: {
68
+ group?: Group;
69
+ hooks?: ServerHooks;
70
+ server?: string;
71
+ }): Promise<{
72
+ room: WorkspaceRoom;
73
+ self: Presence;
74
+ }>;
75
+ static join(authorization: Credentials | ApiKey, target: {
76
+ accessCode: string;
77
+ }, hooks?: ServerHooks): Promise<{
78
+ room: WorkspaceRoom;
79
+ self: Presence;
80
+ }>;
81
+ }
@@ -0,0 +1,263 @@
1
+ import { Marmot } from "./index.js";
2
+ import { Room, connect as connectServer } from "../shared/server.js";
3
+ import { connectRoom } from "../parrot/room.js";
4
+ import { Scraper } from "./scraper.js";
5
+ export async function listWorkspaces(authorization, opts) {
6
+ const response = await fetch(`${Marmot.getURL()}/marmot/workspace/list`, {
7
+ method: "POST",
8
+ headers: {
9
+ "Content-Type": "application/json",
10
+ Authorization: "email" in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
11
+ ...(opts?.group ? { Group: opts.group.id } : {}),
12
+ },
13
+ });
14
+ if (!response.ok)
15
+ throw new Error(await response.text());
16
+ return await response.json();
17
+ }
18
+ export async function createWorkspace(authorization, name, description = "", opts) {
19
+ const response = await fetch(`${Marmot.getURL()}/marmot/workspace/create`, {
20
+ method: "POST",
21
+ headers: {
22
+ "Content-Type": "application/json",
23
+ Authorization: "email" in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
24
+ ...(opts?.group ? { Group: opts.group.id } : {}),
25
+ },
26
+ body: JSON.stringify({ name, description }),
27
+ });
28
+ if (!response.ok)
29
+ throw new Error(await response.text());
30
+ return await response.text();
31
+ }
32
+ export async function updateWorkspace(authorization, id, update, opts) {
33
+ const response = await fetch(`${Marmot.getURL()}/marmot/workspace/update`, {
34
+ method: "POST",
35
+ headers: {
36
+ "Content-Type": "application/json",
37
+ Authorization: "email" in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
38
+ ...(opts?.group ? { Group: opts.group.id } : {}),
39
+ },
40
+ body: JSON.stringify({ id, ...update }),
41
+ });
42
+ if (!response.ok)
43
+ throw new Error(await response.text());
44
+ }
45
+ export async function removeWorkspace(authorization, id, opts) {
46
+ const response = await fetch(`${Marmot.getURL()}/marmot/workspace/remove`, {
47
+ method: "POST",
48
+ headers: {
49
+ "Content-Type": "application/json",
50
+ Authorization: "email" in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
51
+ ...(opts?.group ? { Group: opts.group.id } : {}),
52
+ },
53
+ body: JSON.stringify({ id }),
54
+ });
55
+ if (!response.ok)
56
+ throw new Error(await response.text());
57
+ }
58
+ export class WorkspaceRoom extends Room {
59
+ constructor(endpoint, ws, authorization, id) {
60
+ super(endpoint, ws, authorization, id);
61
+ Object.defineProperty(this, "workspaceId", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: void 0
66
+ });
67
+ Object.defineProperty(this, "name", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ Object.defineProperty(this, "description", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+ Object.defineProperty(this, "files", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: void 0
84
+ });
85
+ Object.defineProperty(this, "datasets", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: void 0
90
+ });
91
+ /** Kept datasets, by dataset id. */
92
+ Object.defineProperty(this, "scrapers", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: void 0
97
+ });
98
+ /** The Termite repository whose machine runs the workspace's scrapers, once there is one. */
99
+ Object.defineProperty(this, "repositoryId", {
100
+ enumerable: true,
101
+ configurable: true,
102
+ writable: true,
103
+ value: void 0
104
+ });
105
+ /** The model the workspace's scraper agent thinks with. */
106
+ Object.defineProperty(this, "agentText", {
107
+ enumerable: true,
108
+ configurable: true,
109
+ writable: true,
110
+ value: void 0
111
+ });
112
+ this.workspaceId = id;
113
+ this.name = "";
114
+ this.description = "";
115
+ this.files = new Map();
116
+ this.datasets = new Map();
117
+ this.scrapers = new Map();
118
+ this.repositoryId = null;
119
+ this.agentText = "";
120
+ }
121
+ hydrate(state) {
122
+ this.workspaceId = state?.id ?? this.workspaceId;
123
+ this.name = state?.name ?? this.name;
124
+ this.description = state?.description ?? this.description;
125
+ this.files.clear();
126
+ for (const f of state?.files ?? []) {
127
+ if (f?.key)
128
+ this.files.set(f.key, f);
129
+ }
130
+ this.datasets.clear();
131
+ for (const d of state?.datasets ?? []) {
132
+ if (d?.id)
133
+ this.datasets.set(d.id, d);
134
+ }
135
+ this.scrapers.clear();
136
+ for (const s of state?.scrapers ?? []) {
137
+ if (s?.datasetId)
138
+ this.scrapers.set(String(s.datasetId), Scraper.fromJSON(s));
139
+ }
140
+ this.repositoryId = state?.repositoryId ? Number(state.repositoryId) : null;
141
+ this.agentText = state?.agentText ?? "";
142
+ }
143
+ handleEvent(packet) {
144
+ switch (packet.event) {
145
+ case "upsert-file": {
146
+ const file = packet.file ?? packet.data?.file;
147
+ if (file?.key)
148
+ this.files.set(file.key, file);
149
+ break;
150
+ }
151
+ case "remove-file": {
152
+ const key = packet.key ?? packet.data?.key;
153
+ if (key)
154
+ this.files.delete(key);
155
+ break;
156
+ }
157
+ case "upsert-dataset": {
158
+ const dataset = packet.dataset ?? packet.data?.dataset;
159
+ if (dataset?.id)
160
+ this.datasets.set(dataset.id, dataset);
161
+ break;
162
+ }
163
+ case "remove-dataset": {
164
+ const id = packet.id ?? packet.data?.id;
165
+ if (id)
166
+ this.datasets.delete(id);
167
+ break;
168
+ }
169
+ case "upsert-snapshot":
170
+ case "remove-snapshot":
171
+ break;
172
+ case "upsert-scraper": {
173
+ const scraper = packet.scraper ?? packet.data?.scraper;
174
+ if (scraper?.datasetId)
175
+ this.scrapers.set(String(scraper.datasetId), Scraper.fromJSON(scraper));
176
+ break;
177
+ }
178
+ case "remove-scraper": {
179
+ const datasetId = packet.datasetId ?? packet.data?.datasetId;
180
+ if (datasetId)
181
+ this.scrapers.delete(String(datasetId));
182
+ break;
183
+ }
184
+ case "update-workspace": {
185
+ const workspace = packet.workspace ?? packet.data?.workspace;
186
+ if (workspace?.name)
187
+ this.name = workspace.name;
188
+ if (workspace?.description !== undefined)
189
+ this.description = workspace.description;
190
+ if (workspace?.repositoryId !== undefined)
191
+ this.repositoryId = workspace.repositoryId ? Number(workspace.repositoryId) : null;
192
+ if (workspace?.agentText !== undefined)
193
+ this.agentText = workspace.agentText;
194
+ break;
195
+ }
196
+ }
197
+ }
198
+ async getChat(hooks) {
199
+ const auth = this.authorization;
200
+ const response = await fetch(`${Marmot.getURL()}/marmot/workspace/chat/ensure`, {
201
+ method: "POST",
202
+ headers: {
203
+ "Content-Type": "application/json",
204
+ Authorization: "email" in auth.authorization ? `Token ${auth.authorization.token}` : `ApiKey ${auth.authorization.id}`,
205
+ ...("accessCode" in auth
206
+ ? { "Access-Code": auth.accessCode }
207
+ : { Server: this.workspaceId, ...(auth.group ? { Group: auth.group } : {}) }),
208
+ },
209
+ });
210
+ if (!response.ok)
211
+ throw new Error(await response.text());
212
+ const { chatId, reference, code } = await response.json();
213
+ if (!chatId || !code)
214
+ throw new Error("Invalid ensure response.");
215
+ const guest = "accessCode" in this.authorization;
216
+ const target = guest
217
+ ? { code }
218
+ : { reference: reference || `parrot:chat:${chatId}` };
219
+ const { room, self } = await connectRoom(this.authorization.authorization, target, hooks ?? {});
220
+ return { room, self, chatId };
221
+ }
222
+ static async connect(authorization, target, opts) {
223
+ const server = opts?.server ?? target.id;
224
+ let room;
225
+ const user = opts?.hooks ?? {};
226
+ const self = await connectServer({ authorization, server, ...(opts?.group ? { group: opts.group.id } : {}) }, `${Marmot.getURL()}/marmot/workspace`, {
227
+ ...user,
228
+ createRoom: (endpoint, ws, a, id, state) => {
229
+ room = (user.createRoom?.(endpoint, ws, a, id, state)
230
+ ?? new WorkspaceRoom(endpoint, ws, a, id));
231
+ return room;
232
+ },
233
+ onConnection: (r, state) => {
234
+ r.hydrate(state);
235
+ user.onConnection?.(r, state);
236
+ },
237
+ onEvent: (r, packet) => applyWorkspaceEvent(r, packet, user),
238
+ });
239
+ return { room, self };
240
+ }
241
+ static async join(authorization, target, hooks) {
242
+ let room;
243
+ const user = hooks ?? {};
244
+ const self = await connectServer({ authorization, accessCode: target.accessCode }, `${Marmot.getURL()}/marmot/workspace`, {
245
+ ...user,
246
+ createRoom: (endpoint, ws, a, id, state) => {
247
+ room = (user.createRoom?.(endpoint, ws, a, id, state)
248
+ ?? new WorkspaceRoom(endpoint, ws, a, id));
249
+ return room;
250
+ },
251
+ onConnection: (r, state) => {
252
+ r.hydrate(state);
253
+ user.onConnection?.(r, state);
254
+ },
255
+ onEvent: (r, packet) => applyWorkspaceEvent(r, packet, user),
256
+ });
257
+ return { room, self };
258
+ }
259
+ }
260
+ function applyWorkspaceEvent(room, packet, user) {
261
+ room.handleEvent(packet);
262
+ return user.onEvent?.(room, packet) ?? true;
263
+ }
@@ -0,0 +1,53 @@
1
+ import { Credentials, ApiKey } from "../authentification.js";
2
+ import { Group } from "../groups.js";
3
+ import type { Text, Voice, Image, Video, Content, Tool, StreamEvent, VoiceEvent, TextResponse, Demographic } from "./generative.js";
4
+ export type Memory = {
5
+ id: number;
6
+ memory: string;
7
+ scope: string;
8
+ embedding: number[];
9
+ };
10
+ export type Memories = {
11
+ nodes: Memory[];
12
+ edges: [number, number][];
13
+ scopes: string[];
14
+ };
15
+ export declare function observe(authorization: Credentials | ApiKey, content: string, group?: Group): Promise<Memory>;
16
+ export declare function recall(authorization: Credentials | ApiKey, query: string, scope?: string, group?: Group): Promise<Memory[]>;
17
+ export declare function exportMemory(authorization: Credentials | ApiKey, group?: Group): Promise<Memories>;
18
+ export declare function removeMemory(authorization: Credentials | ApiKey, id: number, group?: Group): Promise<void>;
19
+ export declare function clearMemory(authorization: Credentials | ApiKey, group?: Group): Promise<void>;
20
+ export declare function generateText(authorization: Credentials | ApiKey, model: Text, options?: Partial<{
21
+ content: Content[];
22
+ tools: Tool[] | Tool;
23
+ maxTools: number;
24
+ memories: number;
25
+ reasoning: string;
26
+ group: Group;
27
+ signal: AbortSignal;
28
+ }>): AsyncGenerator<StreamEvent>;
29
+ export declare function generateTextSync(authorization: Credentials | ApiKey, model: Text, options?: Parameters<typeof generateText>[2]): Promise<TextResponse>;
30
+ export declare function generateVoice(authorization: Credentials | ApiKey, model: Voice, options?: Partial<{
31
+ content: Content[];
32
+ audio: AsyncIterable<Uint8Array>;
33
+ tools: Tool[] | Tool;
34
+ maxTools: number;
35
+ voice: Partial<Demographic>;
36
+ memories: number;
37
+ group: Group;
38
+ signal: AbortSignal;
39
+ }>): AsyncGenerator<VoiceEvent>;
40
+ export declare function generateVoiceSync(authorization: Credentials | ApiKey, model: Voice, options?: Parameters<typeof generateVoice>[2]): Promise<TextResponse>;
41
+ export declare function generateImage(authorization: Credentials | ApiKey, model: Image, options?: Partial<{
42
+ content: Content[];
43
+ size: [number, number];
44
+ memories: number;
45
+ group: Group;
46
+ }>): Promise<TextResponse>;
47
+ export declare function generateVideo(authorization: Credentials | ApiKey, model: Video, options?: Partial<{
48
+ content: Content[];
49
+ duration: number;
50
+ size: [number, number];
51
+ memories: number;
52
+ group: Group;
53
+ }>): Promise<TextResponse>;
@@ -0,0 +1,93 @@
1
+ import { Parrot } from "./index.js";
2
+ import { collectText, collectVoice, generateMedia, streamText, streamVoice } from "./socket.js";
3
+ // Observe — store a new memory. Pass `group` to act on that group's shared
4
+ // memory graph instead of the caller's personal one (caller must be a member).
5
+ export async function observe(authorization, content, group) {
6
+ const response = await fetch(`${Parrot.getURL()}/agent/memories`, {
7
+ method: "POST",
8
+ headers: {
9
+ "Content-Type": "application/json",
10
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
11
+ ...(group ? { "Group": group.id } : {})
12
+ },
13
+ body: JSON.stringify({ content })
14
+ });
15
+ if (!response.ok)
16
+ throw new Error(await response.text());
17
+ return await response.json();
18
+ }
19
+ // Recall — query associative memory. Pass `group` for that group's shared graph.
20
+ export async function recall(authorization, query, scope, group) {
21
+ const response = await fetch(`${Parrot.getURL()}/agent/recall`, {
22
+ method: "POST",
23
+ headers: {
24
+ "Content-Type": "application/json",
25
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
26
+ ...(group ? { "Group": group.id } : {})
27
+ },
28
+ body: JSON.stringify({ query, scope })
29
+ });
30
+ if (!response.ok)
31
+ throw new Error(await response.text());
32
+ return await response.json();
33
+ }
34
+ // Export — get full memory graph. Pass `group` for that group's shared graph.
35
+ export async function exportMemory(authorization, group) {
36
+ const response = await fetch(`${Parrot.getURL()}/agent/memories`, {
37
+ method: "GET",
38
+ headers: {
39
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
40
+ ...(group ? { "Group": group.id } : {})
41
+ }
42
+ });
43
+ if (!response.ok)
44
+ throw new Error(await response.text());
45
+ return await response.json();
46
+ }
47
+ // Remove — delete a specific memory node. Pass `group` for that group's graph.
48
+ export async function removeMemory(authorization, id, group) {
49
+ const response = await fetch(`${Parrot.getURL()}/agent/memories/${encodeURIComponent(id)}`, {
50
+ method: "DELETE",
51
+ headers: {
52
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
53
+ ...(group ? { "Group": group.id } : {})
54
+ }
55
+ });
56
+ if (!response.ok)
57
+ throw new Error(await response.text());
58
+ }
59
+ // Clear — wipe entire memory graph. Pass `group` for that group's graph.
60
+ export async function clearMemory(authorization, group) {
61
+ const response = await fetch(`${Parrot.getURL()}/agent/memories`, {
62
+ method: "DELETE",
63
+ headers: {
64
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
65
+ ...(group ? { "Group": group.id } : {})
66
+ }
67
+ });
68
+ if (!response.ok)
69
+ throw new Error(await response.text());
70
+ }
71
+ // Agent generation: each mirrors its Generative function, plus `memories` (how
72
+ // many to recall on the latest request) and `group` (whose memory graph). Where
73
+ // the model can call tools it can also save memories with observe_memory.
74
+ // Streaming text generation. A singular Tool forces it; an array lets the model choose.
75
+ export async function* generateText(authorization, model, options) {
76
+ yield* streamText(authorization, '/agent/text', model, options);
77
+ }
78
+ export async function generateTextSync(authorization, model, options) {
79
+ return collectText(generateText(authorization, model, options));
80
+ }
81
+ // Realtime voice: PCM16 16 kHz in from `audio`, PCM16 24 kHz out as audio events.
82
+ export async function* generateVoice(authorization, model, options) {
83
+ yield* streamVoice(authorization, '/agent/voice', model, options);
84
+ }
85
+ export async function generateVoiceSync(authorization, model, options) {
86
+ return collectVoice(authorization, generateVoice(authorization, model, options));
87
+ }
88
+ export async function generateImage(authorization, model, options = {}) {
89
+ return generateMedia(authorization, '/agent/image', model, options, 'image/png');
90
+ }
91
+ export async function generateVideo(authorization, model, options = {}) {
92
+ return generateMedia(authorization, '/agent/video', model, options, 'video/mp4');
93
+ }
@@ -0,0 +1,84 @@
1
+ import { Parrot } from "./index.js";
2
+ import { Content } from "./generative.js";
3
+ import { Credentials, ApiKey, Profile } from "../authentification.js";
4
+ import { Group } from "../groups.js";
5
+ import { ChatRoom, RoomHooks } from "./room.js";
6
+ import { Presence } from "../shared/server.js";
7
+ import type { Repository } from "../termite/versioning.js";
8
+ /**
9
+ * Open a chat as a live room: host it server-side, seed the newest window from
10
+ * durable, then connect. Pass a durable `chatId` to bind the room
11
+ * (`parrot:chat:{chatId}`, persisted + billed to the chat's balance-holder);
12
+ * omit it for an unbound ephemeral room. `share: true` also mints an access code
13
+ * others can redeem. Every chat — solo or group — opens through this single
14
+ * always-host path. Returns the connected `ChatRoom`, the caller's `Presence`,
15
+ * the room `reference`, and the access `code` when shared.
16
+ */
17
+ export declare function openChat(authorization: Credentials | ApiKey, options?: {
18
+ chatId?: string;
19
+ messages?: Content[];
20
+ share?: boolean;
21
+ hooks?: RoomHooks;
22
+ }): Promise<{
23
+ room: ChatRoom;
24
+ self: Presence;
25
+ reference: string;
26
+ code?: string;
27
+ }>;
28
+ /**
29
+ * Create a chat, owned by the caller or by `group`. `human: true` makes it a
30
+ * people only chat for good: sends never start a model reply. `systemPrompt`
31
+ * instructs every model reply in the chat. `locked: true` lets only you delete
32
+ * it or move it to another group; it still goes away with its group.
33
+ * `repository` is a Termite repository Parrot works in during replies: yours
34
+ * for a personal chat, the group's for a group chat.
35
+ */
36
+ export declare function createChat(authorization: Credentials | ApiKey, name?: string, group?: Group, options?: {
37
+ human?: boolean;
38
+ systemPrompt?: string;
39
+ locked?: boolean;
40
+ repository?: Repository;
41
+ }): Promise<string>;
42
+ export declare function deleteChat(authorization: Credentials | ApiKey, id: string, group?: Group): Promise<void>;
43
+ export type LastMessage = {
44
+ parts: unknown[];
45
+ role: string;
46
+ createdAt: Date;
47
+ position: number;
48
+ author?: Profile;
49
+ model?: string;
50
+ };
51
+ export declare const LastMessage: {
52
+ fromJSON(json: unknown): LastMessage | null;
53
+ };
54
+ export type ChatSummary = {
55
+ id: string;
56
+ name: string;
57
+ principalId: string;
58
+ /** People only: sends never start a model reply. */
59
+ human: boolean;
60
+ /** Only whoever made it can delete it or move it. */
61
+ locked: boolean;
62
+ /** The repository Parrot works in, by id. */
63
+ repository: number | null;
64
+ created: number;
65
+ updated: number;
66
+ last: LastMessage | null;
67
+ /** Messages the caller hasn't read. A person and each of their API keys keep
68
+ * their own place; one that never marked the chat sees only its newest 20. */
69
+ unread: number;
70
+ };
71
+ export declare function listChats(authorization: Credentials | ApiKey, group?: Group): Promise<ChatSummary[]>;
72
+ export declare function renameChat(authorization: Credentials | ApiKey, id: string, name: string, group?: Group): Promise<void>;
73
+ /**
74
+ * Mark a chat read for the caller, up to `position` (the next unread one) or all
75
+ * of it. Signed in with an API key, the key keeps its own place, apart from its
76
+ * person. Sending a message reads the chat for its sender. Returns what's left unread.
77
+ */
78
+ export declare function markRead(authorization: Credentials | ApiKey, id: string, position?: number, group?: Group): Promise<number>;
79
+ /** One page of a chat, newest first. */
80
+ export declare function readChat(authorization: Credentials | ApiKey, id: string, group: Group | undefined, query: {
81
+ cursor: number;
82
+ max: number;
83
+ }): Promise<Content[]>;
84
+ export declare function writeChat(authorization: Credentials | ApiKey, id: string, messages: Content[], group?: Group): Promise<void>;