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.
- package/dist/brands.d.ts +2 -0
- package/dist/brands.js +2 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +121 -0
- package/dist/src/ant/chat.d.ts +130 -0
- package/dist/src/ant/chat.js +467 -0
- package/dist/src/ant/format.d.ts +40 -0
- package/dist/src/ant/format.js +143 -0
- package/dist/src/ant/graph.d.ts +130 -0
- package/dist/src/ant/graph.js +449 -0
- package/dist/src/ant/index.d.ts +16 -0
- package/dist/src/ant/index.js +61 -0
- package/dist/src/ant/persona.d.ts +151 -0
- package/dist/src/ant/persona.js +136 -0
- package/dist/src/ant/timeline.d.ts +283 -0
- package/dist/src/ant/timeline.js +1025 -0
- package/dist/src/authentification.d.ts +45 -0
- package/dist/src/authentification.js +194 -0
- package/dist/src/billing.d.ts +135 -0
- package/dist/src/billing.js +128 -0
- package/dist/src/calendar.d.ts +83 -0
- package/dist/src/calendar.js +133 -0
- package/dist/src/chats.d.ts +113 -0
- package/dist/src/chats.js +100 -0
- package/dist/src/cicada/contacts.d.ts +31 -0
- package/dist/src/cicada/contacts.js +28 -0
- package/dist/src/cicada/conversations.d.ts +73 -0
- package/dist/src/cicada/conversations.js +236 -0
- package/dist/src/cicada/inboxes.d.ts +48 -0
- package/dist/src/cicada/inboxes.js +82 -0
- package/dist/src/cicada/index.d.ts +16 -0
- package/dist/src/cicada/index.js +61 -0
- package/dist/src/cicada/phone.d.ts +48 -0
- package/dist/src/cicada/phone.js +306 -0
- package/dist/src/drive.d.ts +80 -0
- package/dist/src/drive.js +472 -0
- package/dist/src/extensions/index.d.ts +4 -0
- package/dist/src/extensions/index.js +5 -0
- package/dist/src/extensions/web/index.d.ts +6 -0
- package/dist/src/extensions/web/index.js +7 -0
- package/dist/src/extensions/web/session.d.ts +106 -0
- package/dist/src/extensions/web/session.js +469 -0
- package/dist/src/extensions/web/tools.d.ts +13 -0
- package/dist/src/extensions/web/tools.js +72 -0
- package/dist/src/friends.d.ts +39 -0
- package/dist/src/friends.js +119 -0
- package/dist/src/groups.d.ts +82 -0
- package/dist/src/groups.js +269 -0
- package/dist/src/inbox.d.ts +11 -0
- package/dist/src/inbox.js +35 -0
- package/dist/src/integrations.d.ts +52 -0
- package/dist/src/integrations.js +205 -0
- package/dist/src/magpie/explorer.d.ts +14 -0
- package/dist/src/magpie/explorer.js +36 -0
- package/dist/src/magpie/index.d.ts +16 -0
- package/dist/src/magpie/index.js +61 -0
- package/dist/src/magpie/portfolio.d.ts +52 -0
- package/dist/src/magpie/portfolio.js +179 -0
- package/dist/src/magpie/quotes.d.ts +35 -0
- package/dist/src/magpie/quotes.js +47 -0
- package/dist/src/magpie/room.d.ts +61 -0
- package/dist/src/magpie/room.js +238 -0
- package/dist/src/maps.d.ts +159 -0
- package/dist/src/maps.js +171 -0
- package/dist/src/marmot/browser.d.ts +139 -0
- package/dist/src/marmot/browser.js +389 -0
- package/dist/src/marmot/index.d.ts +20 -0
- package/dist/src/marmot/index.js +65 -0
- package/dist/src/marmot/media.d.ts +56 -0
- package/dist/src/marmot/media.js +265 -0
- package/dist/src/marmot/research.d.ts +337 -0
- package/dist/src/marmot/research.js +1138 -0
- package/dist/src/marmot/scraper.d.ts +59 -0
- package/dist/src/marmot/scraper.js +94 -0
- package/dist/src/marmot/web.d.ts +402 -0
- package/dist/src/marmot/web.js +2586 -0
- package/dist/src/marmot/workspace.d.ts +81 -0
- package/dist/src/marmot/workspace.js +263 -0
- package/dist/src/parrot/agent.d.ts +53 -0
- package/dist/src/parrot/agent.js +93 -0
- package/dist/src/parrot/chat.d.ts +84 -0
- package/dist/src/parrot/chat.js +237 -0
- package/dist/src/parrot/format.d.ts +128 -0
- package/dist/src/parrot/format.js +639 -0
- package/dist/src/parrot/generative.d.ts +261 -0
- package/dist/src/parrot/generative.js +185 -0
- package/dist/src/parrot/index.d.ts +22 -0
- package/dist/src/parrot/index.js +67 -0
- package/dist/src/parrot/room.d.ts +225 -0
- package/dist/src/parrot/room.js +466 -0
- package/dist/src/parrot/routing.d.ts +90 -0
- package/dist/src/parrot/routing.js +78 -0
- package/dist/src/parrot/share.d.ts +126 -0
- package/dist/src/parrot/share.js +261 -0
- package/dist/src/parrot/socket.d.ts +41 -0
- package/dist/src/parrot/socket.js +478 -0
- package/dist/src/payments.d.ts +73 -0
- package/dist/src/payments.js +107 -0
- package/dist/src/private/cards.css +75 -0
- package/dist/src/rooms.d.ts +76 -0
- package/dist/src/rooms.js +168 -0
- package/dist/src/shared/schema.d.ts +24 -0
- package/dist/src/shared/schema.js +1 -0
- package/dist/src/shared/server.d.ts +65 -0
- package/dist/src/shared/server.js +302 -0
- package/dist/src/termite/environment.d.ts +110 -0
- package/dist/src/termite/environment.js +263 -0
- package/dist/src/termite/index.d.ts +14 -0
- package/dist/src/termite/index.js +59 -0
- package/dist/src/termite/os.d.ts +326 -0
- package/dist/src/termite/os.js +572 -0
- package/dist/src/termite/versioning.d.ts +94 -0
- package/dist/src/termite/versioning.js +217 -0
- package/dist/src/tickets.d.ts +43 -0
- package/dist/src/tickets.js +138 -0
- package/dist/src/travel.d.ts +85 -0
- package/dist/src/travel.js +44 -0
- package/dist/src/ui/authentification.d.ts +24 -0
- package/dist/src/ui/authentification.js +177 -0
- package/dist/src/ui/brands.css +11 -0
- package/dist/src/ui/brands.d.ts +7 -0
- package/dist/src/ui/brands.js +14 -0
- package/dist/src/ui/browser.d.ts +74 -0
- package/dist/src/ui/browser.js +470 -0
- package/dist/src/ui/chat.d.ts +183 -0
- package/dist/src/ui/chat.js +2379 -0
- package/dist/src/ui/chatPanel.d.ts +109 -0
- package/dist/src/ui/chatPanel.js +768 -0
- package/dist/src/ui/chatSequence.d.ts +36 -0
- package/dist/src/ui/chatSequence.js +42 -0
- package/dist/src/ui/crown.d.ts +19 -0
- package/dist/src/ui/crown.js +199 -0
- package/dist/src/ui/cursor.d.ts +73 -0
- package/dist/src/ui/cursor.js +175 -0
- package/dist/src/ui/device.d.ts +33 -0
- package/dist/src/ui/device.js +49 -0
- package/dist/src/ui/drive.d.ts +69 -0
- package/dist/src/ui/drive.js +1243 -0
- package/dist/src/ui/generative.d.ts +39 -0
- package/dist/src/ui/generative.js +313 -0
- package/dist/src/ui/hover.d.ts +6 -0
- package/dist/src/ui/hover.js +210 -0
- package/dist/src/ui/index.d.ts +42 -0
- package/dist/src/ui/index.js +87 -0
- package/dist/src/ui/integrations.d.ts +13 -0
- package/dist/src/ui/integrations.js +175 -0
- package/dist/src/ui/maps.d.ts +87 -0
- package/dist/src/ui/maps.js +547 -0
- package/dist/src/ui/roster.d.ts +32 -0
- package/dist/src/ui/roster.js +163 -0
- package/dist/src/ui/talk.d.ts +12 -0
- package/dist/src/ui/talk.js +560 -0
- package/dist/src/ui/tickets.d.ts +13 -0
- package/dist/src/ui/tickets.js +966 -0
- package/dist/src/ui/toast.d.ts +7 -0
- package/dist/src/ui/toast.js +258 -0
- package/dist/src/ui/tokenText.d.ts +18 -0
- package/dist/src/ui/tokenText.js +96 -0
- package/dist/src/ui/tokenized.d.ts +42 -0
- package/dist/src/ui/tokenized.js +622 -0
- package/dist/src/ui/ui.css +4763 -0
- package/dist/src/ui/view.d.ts +23 -0
- package/dist/src/ui/view.js +584 -0
- package/dist/src/view.d.ts +113 -0
- package/dist/src/view.js +386 -0
- package/dist/src/webhooks.d.ts +66 -0
- package/dist/src/webhooks.js +78 -0
- package/dist/ui.d.ts +1 -0
- package/dist/ui.js +1 -0
- package/package.json +89 -6
- package/README.md +0 -3
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Parrot } from "./index.js";
|
|
2
|
+
import { Profile } from "../authentification.js";
|
|
3
|
+
import * as Drive from "../drive.js";
|
|
4
|
+
import { openRoom } from "./share.js";
|
|
5
|
+
import { connectRoom } from "./room.js";
|
|
6
|
+
/**
|
|
7
|
+
* Open a chat as a live room: host it server-side, seed the newest window from
|
|
8
|
+
* durable, then connect. Pass a durable `chatId` to bind the room
|
|
9
|
+
* (`parrot:chat:{chatId}`, persisted + billed to the chat's balance-holder);
|
|
10
|
+
* omit it for an unbound ephemeral room. `share: true` also mints an access code
|
|
11
|
+
* others can redeem. Every chat — solo or group — opens through this single
|
|
12
|
+
* always-host path. Returns the connected `ChatRoom`, the caller's `Presence`,
|
|
13
|
+
* the room `reference`, and the access `code` when shared.
|
|
14
|
+
*/
|
|
15
|
+
export async function openChat(authorization, options = {}) {
|
|
16
|
+
const opened = await openRoom(authorization, {
|
|
17
|
+
chatId: options.chatId,
|
|
18
|
+
messages: options.messages,
|
|
19
|
+
share: options.share,
|
|
20
|
+
});
|
|
21
|
+
const target = opened.code ? { code: opened.code } : { reference: opened.reference };
|
|
22
|
+
const { room, self } = await connectRoom(authorization, target, options.hooks ?? {});
|
|
23
|
+
return { room, self, reference: opened.reference, code: opened.code };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a chat, owned by the caller or by `group`. `human: true` makes it a
|
|
27
|
+
* people only chat for good: sends never start a model reply. `systemPrompt`
|
|
28
|
+
* instructs every model reply in the chat. `locked: true` lets only you delete
|
|
29
|
+
* it or move it to another group; it still goes away with its group.
|
|
30
|
+
* `repository` is a Termite repository Parrot works in during replies: yours
|
|
31
|
+
* for a personal chat, the group's for a group chat.
|
|
32
|
+
*/
|
|
33
|
+
export async function createChat(authorization, name = 'New Chat', group, options = {}) {
|
|
34
|
+
const response = await fetch(`${Parrot.getURL()}/chat/create`, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
39
|
+
...(group ? { "Group": group.id } : {})
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
name,
|
|
43
|
+
human: options.human === true,
|
|
44
|
+
systemPrompt: options.systemPrompt,
|
|
45
|
+
locked: options.locked === true,
|
|
46
|
+
repository: options.repository?.id,
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok)
|
|
50
|
+
throw new Error(await response.text());
|
|
51
|
+
const json = await response.json();
|
|
52
|
+
return json.id;
|
|
53
|
+
}
|
|
54
|
+
export async function deleteChat(authorization, id, group) {
|
|
55
|
+
const response = await fetch(`${Parrot.getURL()}/chat/delete`, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
60
|
+
...(group ? { "Group": group.id } : {})
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify({ id })
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok)
|
|
65
|
+
throw new Error(await response.text());
|
|
66
|
+
}
|
|
67
|
+
export const LastMessage = {
|
|
68
|
+
fromJSON(json) {
|
|
69
|
+
if (!json || typeof json !== "object")
|
|
70
|
+
return null;
|
|
71
|
+
const row = json;
|
|
72
|
+
const createdAt = row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt);
|
|
73
|
+
if (Number.isNaN(createdAt.getTime()) || typeof row.position !== "number")
|
|
74
|
+
return null;
|
|
75
|
+
return {
|
|
76
|
+
parts: Array.isArray(row.parts) ? row.parts : [],
|
|
77
|
+
role: String(row.role ?? ""),
|
|
78
|
+
createdAt,
|
|
79
|
+
position: row.position,
|
|
80
|
+
author: Profile.fromJSON(row.author),
|
|
81
|
+
model: row.model ? String(row.model) : undefined,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
export async function listChats(authorization, group) {
|
|
86
|
+
const response = await fetch(`${Parrot.getURL()}/chat/all`, {
|
|
87
|
+
method: "GET",
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
91
|
+
...(group ? { "Group": group.id } : {})
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (!response.ok)
|
|
95
|
+
throw new Error(await response.text());
|
|
96
|
+
const rows = await response.json();
|
|
97
|
+
return (Array.isArray(rows) ? rows : []).map((row) => ({
|
|
98
|
+
...row,
|
|
99
|
+
human: row.human === true,
|
|
100
|
+
locked: row.locked === true,
|
|
101
|
+
repository: typeof row.repository === 'number' && row.repository > 0 ? row.repository : null,
|
|
102
|
+
last: LastMessage.fromJSON(row.last),
|
|
103
|
+
unread: typeof row.unread === 'number' ? row.unread : 0,
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
export async function renameChat(authorization, id, name, group) {
|
|
107
|
+
const response = await fetch(`${Parrot.getURL()}/chat/rename`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
112
|
+
...(group ? { "Group": group.id } : {})
|
|
113
|
+
},
|
|
114
|
+
body: JSON.stringify({ id, name })
|
|
115
|
+
});
|
|
116
|
+
if (!response.ok)
|
|
117
|
+
throw new Error(await response.text());
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Mark a chat read for the caller, up to `position` (the next unread one) or all
|
|
121
|
+
* of it. Signed in with an API key, the key keeps its own place, apart from its
|
|
122
|
+
* person. Sending a message reads the chat for its sender. Returns what's left unread.
|
|
123
|
+
*/
|
|
124
|
+
export async function markRead(authorization, id, position, group) {
|
|
125
|
+
const response = await fetch(`${Parrot.getURL()}/chat/mark-read`, {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
130
|
+
...(group ? { "Group": group.id } : {})
|
|
131
|
+
},
|
|
132
|
+
body: JSON.stringify({ id, position })
|
|
133
|
+
});
|
|
134
|
+
if (!response.ok)
|
|
135
|
+
throw new Error(await response.text());
|
|
136
|
+
const json = await response.json();
|
|
137
|
+
return typeof json.unread === 'number' ? json.unread : 0;
|
|
138
|
+
}
|
|
139
|
+
function fileRef(file) {
|
|
140
|
+
const authorization = file.authorization;
|
|
141
|
+
if ('accessCode' in authorization) {
|
|
142
|
+
return { type: 'FILE', name: file.name, contentType: file.contentType, accessCode: authorization.accessCode };
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
type: 'FILE',
|
|
146
|
+
name: file.name,
|
|
147
|
+
contentType: file.contentType,
|
|
148
|
+
path: authorization.path,
|
|
149
|
+
...(authorization.group ? { group: authorization.group } : {}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function hydrateFilePart(authorization, part, group) {
|
|
153
|
+
const name = part.name ?? 'file';
|
|
154
|
+
const contentType = part.contentType ?? 'application/octet-stream';
|
|
155
|
+
if (part.accessCode) {
|
|
156
|
+
return { type: 'FILE', file: Drive.File.fromJSON({ ...part, name, contentType }, { authorization, accessCode: part.accessCode }) };
|
|
157
|
+
}
|
|
158
|
+
if (part.path) {
|
|
159
|
+
return { type: 'FILE', file: Drive.File.fromJSON({ ...part, name, contentType }, { authorization, path: part.path, group: part.group ?? group?.id }) };
|
|
160
|
+
}
|
|
161
|
+
return { type: 'FILE', file: Drive.fromBytes(authorization, name, contentType, new Uint8Array()) };
|
|
162
|
+
}
|
|
163
|
+
/** One page of a chat, newest first. */
|
|
164
|
+
export async function readChat(authorization, id, group, query) {
|
|
165
|
+
const response = await fetch(`${Parrot.getURL()}/chat/read`, {
|
|
166
|
+
method: "POST",
|
|
167
|
+
headers: {
|
|
168
|
+
"Content-Type": "application/json",
|
|
169
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
170
|
+
...(group ? { "Group": group.id } : {})
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({ id, cursor: query.cursor, max: query.max })
|
|
173
|
+
});
|
|
174
|
+
if (!response.ok)
|
|
175
|
+
throw new Error(await response.text());
|
|
176
|
+
const json = await response.json();
|
|
177
|
+
const messages = [];
|
|
178
|
+
for (const message of Array.isArray(json) ? json : []) {
|
|
179
|
+
const parts = [];
|
|
180
|
+
for (const part of message.parts ?? []) {
|
|
181
|
+
if (part.type === 'FILE') {
|
|
182
|
+
parts.push(hydrateFilePart(authorization, part, group));
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
parts.push(part);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
messages.push({
|
|
189
|
+
parts,
|
|
190
|
+
role: message.role,
|
|
191
|
+
author: message.author,
|
|
192
|
+
model: message.model,
|
|
193
|
+
createdAt: new Date(message.createdAt),
|
|
194
|
+
...(message.via ? { via: String(message.via) } : {}),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return messages;
|
|
198
|
+
}
|
|
199
|
+
export async function writeChat(authorization, id, messages, group) {
|
|
200
|
+
const serializedMessages = [];
|
|
201
|
+
for (const message of messages) {
|
|
202
|
+
const serializedParts = [];
|
|
203
|
+
for (const part of message.parts) {
|
|
204
|
+
if (part.type === 'FILE') {
|
|
205
|
+
let file = part.file;
|
|
206
|
+
if (!file.online) {
|
|
207
|
+
const dest = `tmp/${crypto.randomUUID()}-${file.name}`;
|
|
208
|
+
const bytes = await file.download();
|
|
209
|
+
file = Drive.fromBytes(authorization, dest, file.contentType, bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes));
|
|
210
|
+
await file.upload();
|
|
211
|
+
}
|
|
212
|
+
serializedParts.push(fileRef(file));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
serializedParts.push(part);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
serializedMessages.push({
|
|
219
|
+
parts: serializedParts,
|
|
220
|
+
role: message.role,
|
|
221
|
+
author: message.author,
|
|
222
|
+
model: message.model,
|
|
223
|
+
createdAt: message.createdAt,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
const response = await fetch(`${Parrot.getURL()}/chat/write`, {
|
|
227
|
+
method: "POST",
|
|
228
|
+
headers: {
|
|
229
|
+
"Content-Type": "application/json",
|
|
230
|
+
"Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
231
|
+
...(group ? { "Group": group.id } : {})
|
|
232
|
+
},
|
|
233
|
+
body: JSON.stringify({ id, messages: serializedMessages })
|
|
234
|
+
});
|
|
235
|
+
if (!response.ok)
|
|
236
|
+
throw new Error(await response.text());
|
|
237
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Embedding, Text, TextResponse, Tool, type Content } from "./generative.js";
|
|
2
|
+
import { Credentials, ApiKey } from "../authentification.js";
|
|
3
|
+
export declare abstract class Format<T> {
|
|
4
|
+
readonly instruction: string;
|
|
5
|
+
tool: Tool;
|
|
6
|
+
protected response: T | undefined;
|
|
7
|
+
constructor(instruction: string, tool: Tool);
|
|
8
|
+
abstract clone(): Format<T>;
|
|
9
|
+
answer(response: T): void;
|
|
10
|
+
abstract toJSON(): any;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a unit-length numerical representation of the format's current
|
|
13
|
+
* response. Used by the research agent's per-scope rank-dedup matrix to
|
|
14
|
+
* detect linearly-dependent rows (duplicates). Concatenated across an
|
|
15
|
+
* entity's atomic fields, the resulting vector is the row's identifier.
|
|
16
|
+
*
|
|
17
|
+
* Contract: all implementations return a vector with L2 norm == 1 when
|
|
18
|
+
* a response is present. If the response is missing or empty, an
|
|
19
|
+
* implementation may return a zero-length array — callers MUST skip such
|
|
20
|
+
* fields when concatenating (they correspond to optional / unfilled
|
|
21
|
+
* fields and are excluded from the rank check).
|
|
22
|
+
*/
|
|
23
|
+
abstract toVector(): number[];
|
|
24
|
+
llm(authorization: Credentials | ApiKey, model: Text, options?: Partial<{
|
|
25
|
+
content: Content[];
|
|
26
|
+
}>): Promise<TextResponse>;
|
|
27
|
+
getResponse(): T | undefined;
|
|
28
|
+
static optional<T>(format: Format<T>): Format<T>;
|
|
29
|
+
static calculateDistance(a: Format<any>, b: Format<any>): number;
|
|
30
|
+
static fromJSON(json: any): Format<any>;
|
|
31
|
+
}
|
|
32
|
+
export declare class NumericalFormat extends Format<number> {
|
|
33
|
+
readonly bounds: [number | undefined, number | undefined] | undefined;
|
|
34
|
+
constructor(instruction: string, bounds?: [number | undefined, number | undefined]);
|
|
35
|
+
clone(): NumericalFormat;
|
|
36
|
+
getResponse(): number | undefined;
|
|
37
|
+
toJSON(): {
|
|
38
|
+
type: string;
|
|
39
|
+
instruction: string;
|
|
40
|
+
bounds: [number | undefined, number | undefined] | undefined;
|
|
41
|
+
answer: number | undefined;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Encode the scalar as a 2-dim unit vector `[x, 1] / sqrt(x²+1)`. Direct
|
|
45
|
+
* unit-norm on a 1-dim scalar would collapse to just the sign and discard
|
|
46
|
+
* magnitude; the 2-dim wrap preserves magnitude as the vector's angle so
|
|
47
|
+
* two identical scalars yield identical unit vectors and different scalars
|
|
48
|
+
* yield distinguishable directions.
|
|
49
|
+
*/
|
|
50
|
+
toVector(): number[];
|
|
51
|
+
static compare(a: number, b: number): number;
|
|
52
|
+
static distance(a: Format<number>, b: Format<number>): number;
|
|
53
|
+
static tool(bounds?: [number | undefined, number | undefined]): Tool;
|
|
54
|
+
}
|
|
55
|
+
export declare class VectorFormat extends Format<number[]> {
|
|
56
|
+
readonly dimension: number;
|
|
57
|
+
readonly bounds: ([number | undefined, number | undefined] | undefined)[] | undefined;
|
|
58
|
+
constructor(instruction: string, dimension: number, bounds?: ([number | undefined, number | undefined] | undefined)[]);
|
|
59
|
+
clone(): VectorFormat;
|
|
60
|
+
getResponse(): number[] | undefined;
|
|
61
|
+
toJSON(): {
|
|
62
|
+
type: string;
|
|
63
|
+
instruction: string;
|
|
64
|
+
dimension: number;
|
|
65
|
+
bounds: ([number | undefined, number | undefined] | undefined)[] | undefined;
|
|
66
|
+
answer: number[] | undefined;
|
|
67
|
+
};
|
|
68
|
+
toVector(): number[];
|
|
69
|
+
static distance(a: Format<number[]>, b: Format<number[]>): number;
|
|
70
|
+
static tool(dimension: number, bounds?: ([number | undefined, number | undefined] | undefined)[]): Tool;
|
|
71
|
+
}
|
|
72
|
+
export declare class CategoricalFormat extends Format<string> {
|
|
73
|
+
private categories;
|
|
74
|
+
constructor(instruction: string, categories: string[]);
|
|
75
|
+
clone(): CategoricalFormat;
|
|
76
|
+
getCategories(): string[];
|
|
77
|
+
getResponse(): string | undefined;
|
|
78
|
+
toJSON(): {
|
|
79
|
+
type: string;
|
|
80
|
+
instruction: string;
|
|
81
|
+
categories: string[];
|
|
82
|
+
answer: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
/** One-hot over the category set — already unit-length. */
|
|
85
|
+
toVector(): number[];
|
|
86
|
+
static distance(a: Format<string>, b: Format<string>): number;
|
|
87
|
+
static tool(categories: string[]): Tool;
|
|
88
|
+
}
|
|
89
|
+
export declare class SelectionFormat extends Format<string[]> {
|
|
90
|
+
private options;
|
|
91
|
+
constructor(instruction: string, options: string[]);
|
|
92
|
+
clone(): SelectionFormat;
|
|
93
|
+
getOptions(): string[];
|
|
94
|
+
getResponse(): string[] | undefined;
|
|
95
|
+
toJSON(): {
|
|
96
|
+
type: string;
|
|
97
|
+
instruction: string;
|
|
98
|
+
options: string[];
|
|
99
|
+
answer: string[] | undefined;
|
|
100
|
+
};
|
|
101
|
+
/** Multi-hot scaled by 1/sqrt(count) so the vector is unit-length. */
|
|
102
|
+
toVector(): number[];
|
|
103
|
+
static distance(a: Format<string[]>, b: Format<string[]>): number;
|
|
104
|
+
static tool(options: string[]): Tool;
|
|
105
|
+
}
|
|
106
|
+
export declare class UtteranceFormat extends Format<string> {
|
|
107
|
+
readonly time: number | undefined;
|
|
108
|
+
embedding?: number[];
|
|
109
|
+
constructor(instruction: string, time?: number);
|
|
110
|
+
clone(): UtteranceFormat;
|
|
111
|
+
toJSON(): {
|
|
112
|
+
type: string;
|
|
113
|
+
instruction: string;
|
|
114
|
+
time: number | undefined;
|
|
115
|
+
answer: string | undefined;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Returns the unit-normalized embedding. The caller MUST have populated
|
|
119
|
+
* `embedding` first (via `embed()` or the research agent's extraction
|
|
120
|
+
* pipeline) — otherwise we return an empty slice and the field is
|
|
121
|
+
* excluded from the rank check. Embedding-less utterances cannot
|
|
122
|
+
* participate in dedup.
|
|
123
|
+
*/
|
|
124
|
+
toVector(): number[];
|
|
125
|
+
embed(authorization: Credentials | ApiKey, model: Embedding): Promise<void>;
|
|
126
|
+
static distance(a: UtteranceFormat, b: UtteranceFormat): number;
|
|
127
|
+
static tool(time?: number): Tool;
|
|
128
|
+
}
|