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,265 @@
1
+ import { fromBytes } from "../drive.js";
2
+ import { Marmot } from "./index.js";
3
+ export const ATTACHMENT_TYPES = {
4
+ 'image/jpeg': 'image',
5
+ 'image/png': 'image',
6
+ 'image/webp': 'image',
7
+ 'image/heic': 'image',
8
+ 'image/heif': 'image',
9
+ 'audio/mpeg': 'audio_file',
10
+ 'audio/wav': 'audio_file',
11
+ 'video/mp4': 'movie',
12
+ 'video/webm': 'movie',
13
+ 'video/quicktime': 'movie',
14
+ 'application/pdf': 'picture_as_pdf',
15
+ 'text/plain': 'description',
16
+ 'text/markdown': 'description',
17
+ 'text/csv': 'table_chart',
18
+ 'text/html': 'language',
19
+ 'application/json': 'data_object',
20
+ 'application/xml': 'code',
21
+ };
22
+ /** Resolve a usable MIME when the browser leaves `File.type` empty (common for HEIC). */
23
+ export function mimeFromFileName(name) {
24
+ const ext = name.includes('.') ? name.split('.').pop().toLowerCase() : '';
25
+ switch (ext) {
26
+ case 'jpg':
27
+ case 'jpeg': return 'image/jpeg';
28
+ case 'png': return 'image/png';
29
+ case 'webp': return 'image/webp';
30
+ case 'heic': return 'image/heic';
31
+ case 'heif': return 'image/heif';
32
+ case 'mp3': return 'audio/mpeg';
33
+ case 'wav': return 'audio/wav';
34
+ case 'mp4': return 'video/mp4';
35
+ case 'webm': return 'video/webm';
36
+ case 'mov':
37
+ case 'qt': return 'video/quicktime';
38
+ case 'pdf': return 'application/pdf';
39
+ case 'txt': return 'text/plain';
40
+ case 'md':
41
+ case 'markdown': return 'text/markdown';
42
+ case 'csv': return 'text/csv';
43
+ case 'html':
44
+ case 'htm': return 'text/html';
45
+ case 'json': return 'application/json';
46
+ case 'xml': return 'application/xml';
47
+ default: return undefined;
48
+ }
49
+ }
50
+ let TYPES_CACHE = null;
51
+ export async function getTypes() {
52
+ if (TYPES_CACHE)
53
+ return TYPES_CACHE;
54
+ const response = await fetch(`${Marmot.getURL()}/media/types`, { method: "GET" });
55
+ if (!response.ok)
56
+ throw new Error(await response.text());
57
+ TYPES_CACHE = await response.json();
58
+ return TYPES_CACHE;
59
+ }
60
+ export async function query(authorization, query, options) {
61
+ const response = await fetch(`${Marmot.getURL()}/media/query`, {
62
+ method: "POST",
63
+ headers: {
64
+ "Content-Type": "application/json",
65
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
66
+ },
67
+ body: JSON.stringify({
68
+ query: query,
69
+ cursor: options.cursor,
70
+ max: options.max,
71
+ ...(options.start ? { start: options.start.toISOString() } : {}),
72
+ ...(options.end ? { end: options.end.toISOString() } : {}),
73
+ })
74
+ });
75
+ return await response.json();
76
+ }
77
+ export async function pull(authorization, url, request, options = {}) {
78
+ const effectiveOptions = { ...options, proxy: options.proxy ?? 'datacenter' };
79
+ const response = await fetch(`${Marmot.getURL()}/media/pull`, {
80
+ method: "POST",
81
+ headers: {
82
+ "Content-Type": "application/json",
83
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
84
+ "Url": url,
85
+ ...(request ? { "Request": JSON.stringify(request) } : {}),
86
+ "Options": JSON.stringify(effectiveOptions)
87
+ }
88
+ });
89
+ if (!response.ok)
90
+ throw new Error(`Failed to fetch website at ${url}.`);
91
+ const contentType = response.headers.get('Content-Type') || 'application/octet-stream';
92
+ const buffer = await parseStream(response);
93
+ return { contentType, data: Array.isArray(buffer) ? buffer[0] : buffer };
94
+ }
95
+ function chatParts(authorization, raw) {
96
+ return raw.map((part) => part?.type === 'FILE'
97
+ ? { type: 'FILE', file: fromBytes(authorization, String(part.name ?? 'file'), String(part.contentType ?? 'application/octet-stream'), Uint8Array.from(atob(String(part.data ?? '')), (c) => c.charCodeAt(0))) }
98
+ : { type: 'TEXT', text: String(part?.text ?? '') });
99
+ }
100
+ /**
101
+ * A media file as message parts for a model that takes `takes` natively (images only
102
+ * by default). What it takes passes through; the rest becomes what it can take: a
103
+ * video becomes a line, its frames and its sound (audio, or a description of it),
104
+ * audio becomes a description, and documents become their text. With `split`, one
105
+ * list of parts per segment of that many milliseconds. Undefined when it can't be read.
106
+ */
107
+ export async function chat(authorization, contentType, data, options = {}) {
108
+ const response = await fetch(`${Marmot.getURL()}/media/chat`, {
109
+ method: "POST",
110
+ headers: {
111
+ "Content-Type": contentType,
112
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
113
+ "Takes": (options.takes ?? ['image']).join(','),
114
+ ...(options.name ? { "Name": encodeURIComponent(options.name) } : {}),
115
+ ...(options.segment ? { "Segment": `${options.segment[0]},${options.segment[1]}` } : {}),
116
+ ...(options.split ? { "Split": options.split.toString() } : {})
117
+ },
118
+ body: data.buffer
119
+ });
120
+ if (!response.ok) {
121
+ return undefined;
122
+ }
123
+ const json = await response.json();
124
+ if (!Array.isArray(json))
125
+ return undefined;
126
+ if (options.split)
127
+ return json.map((segment) => chatParts(authorization, Array.isArray(segment) ? segment : []));
128
+ return chatParts(authorization, json);
129
+ }
130
+ export async function parse(authorization, contentType, data, onProgress) {
131
+ return new Promise((resolve, reject) => {
132
+ const xhr = new XMLHttpRequest();
133
+ xhr.open("POST", `${Marmot.getURL()}/media/parse`);
134
+ xhr.setRequestHeader("Authorization", 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`);
135
+ xhr.setRequestHeader("Content-Type", contentType || "application/octet-stream");
136
+ xhr.upload.onprogress = (event) => {
137
+ if (event.lengthComputable && onProgress) {
138
+ onProgress(event.loaded / event.total);
139
+ }
140
+ };
141
+ xhr.onload = () => {
142
+ if (xhr.status >= 200 && xhr.status < 300) {
143
+ resolve(xhr.responseText);
144
+ }
145
+ else {
146
+ reject(new Error(`Failed to parse media: ${xhr.status}`));
147
+ }
148
+ };
149
+ xhr.onerror = () => reject(new Error(`Failed to parse media.`));
150
+ xhr.send(data.buffer);
151
+ });
152
+ }
153
+ export async function slice(authorization, contentType, data, options) {
154
+ const response = await fetch(`${Marmot.getURL()}/media/slice`, {
155
+ method: "POST",
156
+ headers: {
157
+ "Content-Type": contentType || "application/octet-stream",
158
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
159
+ ...(options.segment ? { "Segment": `${options.segment[0]},${options.segment[1]}` } : {}),
160
+ ...(options.split ? { "Split": options.split.toString() } : {})
161
+ },
162
+ body: data.buffer
163
+ });
164
+ if (!response.ok) {
165
+ return undefined;
166
+ }
167
+ return await parseStream(response);
168
+ }
169
+ export async function duration(authorization, contentType, data, onProgress) {
170
+ return new Promise((resolve, reject) => {
171
+ const xhr = new XMLHttpRequest();
172
+ xhr.open("POST", `${Marmot.getURL()}/media/duration`);
173
+ xhr.setRequestHeader("Authorization", 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`);
174
+ xhr.setRequestHeader("Content-Type", contentType || "application/octet-stream");
175
+ xhr.upload.onprogress = (event) => {
176
+ if (event.lengthComputable && onProgress) {
177
+ onProgress(event.loaded / event.total);
178
+ }
179
+ };
180
+ xhr.onload = () => {
181
+ if (xhr.status >= 200 && xhr.status < 300) {
182
+ resolve(Number.parseFloat(xhr.responseText));
183
+ }
184
+ else {
185
+ reject(new Error(`Failed to duration media: ${xhr.status}`));
186
+ }
187
+ };
188
+ xhr.onerror = () => reject(new Error(`Failed to duration media.`));
189
+ xhr.send(data.buffer);
190
+ });
191
+ }
192
+ async function parseStream(response) {
193
+ const encodingSize = response.headers.get('Encoding-Size');
194
+ if (encodingSize && parseInt(encodingSize) > 1) {
195
+ const reader = response.body.getReader();
196
+ let buffer = new Uint8Array(0);
197
+ const boundaryBytes = new TextEncoder().encode('--BOUNDARY');
198
+ const parts = [];
199
+ while (true) {
200
+ const { done, value } = await reader.read();
201
+ if (done)
202
+ break;
203
+ if (value) {
204
+ const tmp = new Uint8Array(buffer.length + value.length);
205
+ tmp.set(buffer, 0);
206
+ tmp.set(value, buffer.length);
207
+ buffer = tmp;
208
+ }
209
+ }
210
+ function indexOfBoundary(buf, startPos = 0) {
211
+ for (let i = startPos; i <= buf.length - boundaryBytes.length; i++) {
212
+ let match = true;
213
+ for (let j = 0; j < boundaryBytes.length; j++) {
214
+ if (buf[i + j] !== boundaryBytes[j]) {
215
+ match = false;
216
+ break;
217
+ }
218
+ }
219
+ if (match) {
220
+ return i;
221
+ }
222
+ }
223
+ return -1;
224
+ }
225
+ let currentPos = 0;
226
+ let boundaryCount = 0;
227
+ while (true) {
228
+ const idx = indexOfBoundary(buffer, currentPos);
229
+ if (idx === -1) {
230
+ if (currentPos < buffer.length) {
231
+ const part = buffer.slice(currentPos);
232
+ if (part.length > 0) {
233
+ parts.push(part);
234
+ }
235
+ }
236
+ break;
237
+ }
238
+ else {
239
+ boundaryCount++;
240
+ const part = buffer.slice(currentPos, idx);
241
+ if (part.length > 0) {
242
+ parts.push(part);
243
+ }
244
+ currentPos = idx + boundaryBytes.length;
245
+ }
246
+ }
247
+ return parts;
248
+ }
249
+ else {
250
+ const reader = response.body.getReader();
251
+ let buffer = new Uint8Array(0);
252
+ while (true) {
253
+ const { done, value } = await reader.read();
254
+ if (done)
255
+ break;
256
+ if (value) {
257
+ const tmp = new Uint8Array(buffer.length + value.length);
258
+ tmp.set(buffer, 0);
259
+ tmp.set(value, buffer.length);
260
+ buffer = tmp;
261
+ }
262
+ }
263
+ return buffer;
264
+ }
265
+ }
@@ -0,0 +1,337 @@
1
+ import { Fauna } from "../../index.js";
2
+ import { ApiKey, Credentials } from "../authentification.js";
3
+ import { Group } from "../groups.js";
4
+ import type { ProxyMode, DocumentMode } from "./media.js";
5
+ import type { BrowserTool } from "./browser.js";
6
+ import { Scraper, ScraperSettings } from "./scraper.js";
7
+ export type SchemaLeaf = {
8
+ value: Fauna.Parrot.Format.Format<any> | SchemaLeaf | Record<string, SchemaLeaf>;
9
+ prompt?: string;
10
+ sources?: number;
11
+ optional?: boolean;
12
+ array?: {
13
+ minimum: number;
14
+ maximum: number;
15
+ };
16
+ maxIterations?: number;
17
+ filters?: string | string[];
18
+ };
19
+ export declare abstract class Schema {
20
+ abstract readonly type: string;
21
+ abstract readonly schema: SchemaLeaf | Record<string, SchemaLeaf>;
22
+ abstract serialize(): any;
23
+ static deserialize(data: any): Schema;
24
+ }
25
+ export declare class SchemaJSON extends Schema {
26
+ readonly type = "json";
27
+ readonly schema: SchemaLeaf;
28
+ constructor(schema: SchemaLeaf);
29
+ serialize(): any;
30
+ }
31
+ export declare class SchemaCSV extends Schema {
32
+ readonly type = "csv";
33
+ readonly schema: Record<string, SchemaLeaf>;
34
+ readonly minimum: number;
35
+ readonly maximum: number;
36
+ readonly prompt: string;
37
+ constructor(schema: Record<string, SchemaLeaf>, minimum: number, maximum: number, prompt?: string);
38
+ serialize(): any;
39
+ }
40
+ /**
41
+ * Flatten a schema to a map of `leaf path → type signature`.
42
+ * - CSV: each column key is a path, signature is its Format type.
43
+ * - JSON: object keys descend with `.`, array leaves append `[]`, Format
44
+ * leaves terminate. e.g. "name", "address.city", "awards[].year".
45
+ */
46
+ export declare function schemaPaths(schema: Schema): Map<string, string>;
47
+ /**
48
+ * Diff two schema versions for a dataset migration. A path whose type
49
+ * signature changed shows up in BOTH lists (drop the old, add the new) — we
50
+ * deliberately do not attempt rename/retype detection. Renames and tree-shape
51
+ * changes therefore fall out naturally as drop + add.
52
+ */
53
+ export declare function diffSchema(baseline: Schema, target: Schema): {
54
+ added: string[];
55
+ dropped: string[];
56
+ };
57
+ export interface Termination {
58
+ type: string;
59
+ }
60
+ export interface TokenTermination extends Termination {
61
+ type: 'tokens';
62
+ max: number;
63
+ }
64
+ export interface TimeTermination extends Termination {
65
+ type: 'time';
66
+ max: number;
67
+ }
68
+ export interface CostTermination extends Termination {
69
+ type: 'cost';
70
+ max: number;
71
+ }
72
+ /** How `/data` writes rows: CSV with a header row, or a JSON array. */
73
+ export type DataFormat = 'csv' | 'json';
74
+ export type DataOptions = {
75
+ format?: DataFormat;
76
+ /** A snapshot id. The dataset's current data when absent. */
77
+ snapshot?: string;
78
+ /** Add each row's sources. */
79
+ sources?: boolean;
80
+ };
81
+ /** A row pushed into a dataset, numbered by `seq`, which rises within the dataset. */
82
+ export type FeedRow = {
83
+ seq: number;
84
+ value: any;
85
+ sources: any;
86
+ created: Date;
87
+ };
88
+ export declare const FeedRow: {
89
+ fromJSON(json: any): FeedRow;
90
+ };
91
+ /** What a push stored, and the rows it left out with why. */
92
+ export type PushResult = {
93
+ added: number;
94
+ first: number | null;
95
+ last: number | null;
96
+ invalid: {
97
+ index: number;
98
+ reason: string;
99
+ }[];
100
+ };
101
+ export declare const PushResult: {
102
+ fromJSON(json: any): PushResult;
103
+ };
104
+ /** A push nothing in was let through: why, and each row's reason. */
105
+ export declare class PushRefused extends Error {
106
+ readonly status: number;
107
+ readonly invalid: {
108
+ index: number;
109
+ reason: string;
110
+ }[];
111
+ constructor(status: number, message: string, invalid: {
112
+ index: number;
113
+ reason: string;
114
+ }[]);
115
+ }
116
+ export declare class Snapshot {
117
+ readonly id: string;
118
+ readonly createdAt: Date;
119
+ readonly valid: boolean;
120
+ protected _authorization: Credentials | ApiKey;
121
+ protected _workspaceId: string;
122
+ protected _datasetId: string;
123
+ protected _group?: Group;
124
+ protected _schema: Schema | null;
125
+ protected _data: any | null;
126
+ constructor(authorization: Credentials | ApiKey, workspaceId: string, datasetId: string, id: string, createdAt: Date, valid?: boolean, group?: Group);
127
+ download(assets?: boolean, revalidate?: boolean): Promise<any>;
128
+ /** This snapshot's rows as CSV text or, by default, a JSON array. */
129
+ data(options?: {
130
+ format?: DataFormat;
131
+ sources?: boolean;
132
+ }): Promise<any>;
133
+ downloadSchema(revalidate?: boolean): Promise<Schema>;
134
+ downloadLog(): Promise<Blob>;
135
+ downloadEmbeddings(): Promise<Blob>;
136
+ delete(): Promise<void>;
137
+ }
138
+ export type ResearchCallbacks = {
139
+ onConnection?: (ongoing: boolean) => void;
140
+ onQuery?: (query: string) => void;
141
+ onSource?: (url: string, title: string, contentType: string) => void;
142
+ onAnswer?: (field: string, value: any, converged: boolean, answersCount: number, sources?: string[]) => void;
143
+ onNomination?: (scope: string, row: any, committedCount: number, sources?: string[]) => void;
144
+ onSupervisorQuery?: (question: string) => void;
145
+ onSupervisorSearch?: (query: string) => void;
146
+ onSupervisorAnswer?: (question: string, answer: string) => void;
147
+ onSupervisorRefused?: (question: string) => void;
148
+ onBrowser?: (frame: {
149
+ url: string;
150
+ reference: string;
151
+ code: string;
152
+ mode: 'render' | 'virtualized';
153
+ }) => void;
154
+ onBrowserStep?: (url: string, step: number, action: BrowserTool) => void;
155
+ onCompress?: () => void;
156
+ onInfo?: (message: string) => void;
157
+ onDone?: (snapshot: Snapshot) => void;
158
+ onCancelled?: (reason: 'user' | 'tokens' | 'time' | 'cost') => void;
159
+ onConvergenceFailed?: (field: string, reason: string, candidates: {
160
+ value: any;
161
+ source: string;
162
+ }[]) => void;
163
+ onError?: (message: string) => void;
164
+ };
165
+ export type ResearchOptions = {
166
+ text?: Fauna.Parrot.Generative.Text;
167
+ embedding?: Fauna.Parrot.Generative.Embedding;
168
+ };
169
+ export type { ProxyMode, DocumentMode };
170
+ export type { BrowserTool };
171
+ export declare class Dataset {
172
+ readonly id: string;
173
+ readonly workspaceId: string;
174
+ name: string;
175
+ schema: Schema;
176
+ readonly termination: Termination[];
177
+ contentTypes: string[];
178
+ proxy: ProxyMode;
179
+ documentModes: DocumentMode[];
180
+ snapshots: Snapshot[];
181
+ private _authorization;
182
+ private _group?;
183
+ private _ws;
184
+ constructor(authorization: Credentials | ApiKey, workspaceId: string, id: string, name: string, schema: Schema, termination: Termination[], contentTypes: string[], proxy: ProxyMode, documentModes: DocumentMode[], snapshots: Snapshot[], group?: Group);
185
+ research(callbacks: ResearchCallbacks, options?: ResearchOptions): Promise<void>;
186
+ /** Join a live BrowserRoom opened by a research run. */
187
+ joinBrowser(accessCode: string): Promise<{
188
+ room: Fauna.Marmot.Browser.BrowserRoom;
189
+ self: Fauna.Live.Presence;
190
+ }>;
191
+ /**
192
+ * Attach to an *already-running* research/migration session for this
193
+ * dataset and replay its live timeline from the start, then keep streaming.
194
+ *
195
+ * Unlike `research`, this NEVER starts a new run: if nothing is in flight
196
+ * the returned promise rejects, so callers can `try/catch` it on load
197
+ * (e.g. to passively re-bind a run after a page reload). It otherwise
198
+ * resolves on the same terminal events as `research` (done / cancelled /
199
+ * convergence_failed / error).
200
+ */
201
+ reconnect(callbacks: ResearchCallbacks, options?: ResearchOptions): Promise<void>;
202
+ private _runSocket;
203
+ cancel(): Promise<void>;
204
+ rename(name: string): Promise<void>;
205
+ /**
206
+ * Persist a new schema WITHOUT producing a snapshot. Use for edits that
207
+ * don't change the set of columns (prompt / sources / optional tweaks);
208
+ * for column add/drop use `migrate` instead so existing data is reconciled.
209
+ */
210
+ saveSchema(schema: Schema): Promise<void>;
211
+ /**
212
+ * Migrate the dataset to a new schema, producing a fresh snapshot. Runs
213
+ * over the research WebSocket so the caller sees the same live timeline.
214
+ *
215
+ * - `seedSnapshotId` = a snapshot id: the migration starts from that
216
+ * snapshot's rows, drops removed columns, and backfills added columns
217
+ * (researching only the new fields per row, reusing each row's stored
218
+ * source URLs first).
219
+ * - `seedSnapshotId` = null: a from-scratch research run with the new
220
+ * schema (no backfill).
221
+ *
222
+ * The diff between the seed snapshot's schema and `schema` is recomputed
223
+ * authoritatively on the server. On completion the dataset's schema is
224
+ * updated to `schema`.
225
+ */
226
+ migrate(schema: Schema, seedSnapshotId: string | null, callbacks: ResearchCallbacks, options?: ResearchOptions): Promise<void>;
227
+ setTermination(termination: Termination[]): Promise<void>;
228
+ setContentTypes(contentTypes: string[]): Promise<void>;
229
+ setProxy(proxy: ProxyMode): Promise<void>;
230
+ setDocumentModes(documentModes: DocumentMode[]): Promise<void>;
231
+ remove(): Promise<void>;
232
+ /**
233
+ * The dataset's data as CSV text or, by default, a JSON array: its live
234
+ * snapshot when new rows are stored into it, else its newest valid snapshot.
235
+ */
236
+ data(options?: DataOptions): Promise<any>;
237
+ /** The `/data` address, for pipelines and curl. Calls to it still need your authorization. */
238
+ dataURL(options?: DataOptions): string;
239
+ /**
240
+ * Push rows into the dataset: objects shaped like its rows, or CSV text with a
241
+ * header row. Rows that don't fit come back in `invalid`; when none fit, it
242
+ * throws a PushRefused listing them.
243
+ */
244
+ addRows(rows: any[] | string, options?: {
245
+ source?: string;
246
+ }): Promise<PushResult>;
247
+ /** Rows pushed after `since`, oldest first, at most `max`. The next page starts at the last `seq` here. */
248
+ updates(query: {
249
+ since: number;
250
+ max: number;
251
+ }): Promise<FeedRow[]>;
252
+ /**
253
+ * Every row pushed after `since`, then each new one as it lands. It opens the
254
+ * live socket first, catches up through `updates`, and skips rows it already
255
+ * gave, so nothing is missed or repeated. It reconnects by itself until `signal` aborts.
256
+ */
257
+ live(options?: {
258
+ since?: number;
259
+ signal?: AbortSignal;
260
+ }): AsyncGenerator<FeedRow>;
261
+ /** Whether this dataset is kept updated, and how it's going. Null when it isn't. */
262
+ scraper(): Promise<Scraper | null>;
263
+ /** Keep this dataset updated by its workspace's scraper agent. You become the person the agent runs as. */
264
+ keepUpdated(settings?: ScraperSettings): Promise<Scraper>;
265
+ updateScraper(settings: ScraperSettings): Promise<Scraper>;
266
+ /** Ask the agent to go over this dataset's scraper again, with a note for it. */
267
+ rebuildScraper(note?: string): Promise<void>;
268
+ /** Stop keeping this dataset updated. */
269
+ stopKeepingUpdated(): Promise<void>;
270
+ }
271
+ export declare function listDatasets(authorization: Credentials | ApiKey, workspaceId: string, opts?: {
272
+ group?: Group;
273
+ }): Promise<Dataset[]>;
274
+ export declare function createDataset(authorization: Credentials | ApiKey, workspaceId: string, options: {
275
+ name: string;
276
+ schema: Schema;
277
+ termination?: Termination[];
278
+ contentTypes?: string[];
279
+ proxy?: ProxyMode;
280
+ documentModes?: DocumentMode[];
281
+ }, opts?: {
282
+ group?: Group;
283
+ }): Promise<string>;
284
+ export type WorkspaceFile = {
285
+ name: string;
286
+ contentType: string;
287
+ size: number;
288
+ key: string;
289
+ };
290
+ export declare class Workspace {
291
+ readonly id: string;
292
+ name: string;
293
+ description: string;
294
+ readonly createdAt: number;
295
+ datasets: number;
296
+ files: number;
297
+ private _authorization;
298
+ private _group?;
299
+ constructor(authorization: Credentials | ApiKey, id: string, name: string, description: string, createdAt: number, datasets?: number, files?: number, group?: Group);
300
+ listDatasets(): Promise<Dataset[]>;
301
+ createDataset(options: {
302
+ name: string;
303
+ schema: Schema;
304
+ termination?: Termination[];
305
+ contentTypes?: string[];
306
+ proxy?: ProxyMode;
307
+ documentModes?: DocumentMode[];
308
+ }): Promise<string>;
309
+ rename(name: string): Promise<void>;
310
+ setDescription(description: string): Promise<void>;
311
+ remove(): Promise<void>;
312
+ getFiles(): Promise<WorkspaceFile[]>;
313
+ uploadFile(name: string, contentType: string, data: Uint8Array): Promise<WorkspaceFile>;
314
+ downloadFile(file: WorkspaceFile): Promise<Blob>;
315
+ removeFile(key: string): Promise<void>;
316
+ }
317
+ export declare function listWorkspaces(authorization: Credentials | ApiKey, opts?: {
318
+ group?: Group;
319
+ }): Promise<Workspace[]>;
320
+ export declare function getWorkspace(authorization: Credentials | ApiKey, id: string, opts?: {
321
+ group?: Group;
322
+ }): Promise<{
323
+ id: string;
324
+ name: string;
325
+ description: string;
326
+ createdAt: number;
327
+ files: WorkspaceFile[];
328
+ }>;
329
+ export declare function createWorkspace(authorization: Credentials | ApiKey, name: string, description?: string, opts?: {
330
+ group?: Group;
331
+ }): Promise<string>;
332
+ export declare function updateWorkspace(authorization: Credentials | ApiKey, id: string, update: Partial<{
333
+ name: string;
334
+ description: string;
335
+ }>, opts?: {
336
+ group?: Group;
337
+ }): Promise<void>;