palbase 0.6.2 → 0.8.0
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/ai/index.js +2 -14
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +9 -9
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/5VTGMNPL.js +20 -0
- package/dist/chunks/{SXH5AIQX.js → BO5KR2EQ.js} +2 -2
- package/dist/chunks/{AYY4J3B2.js → BRBCWPR3.js} +1 -1
- package/dist/chunks/DB3SIBKB.js +2 -0
- package/dist/chunks/EGNEXFTZ.js +2 -0
- package/dist/chunks/{VP7V7YRH.js → FZ3MQOVA.js} +2 -2
- package/dist/chunks/{A3CDCPXX.js → JSJVV43D.js} +1 -1
- package/dist/chunks/K6RRNI23.js +4 -0
- package/dist/chunks/{SUX2BJG4.js → KDWDPSL2.js} +1 -1
- package/dist/chunks/P4Z5E6ZI.js +2 -0
- package/dist/chunks/PDOHT46N.js +2 -0
- package/dist/chunks/PGPQGKH2.js +18 -0
- package/dist/chunks/{DRTZ33XF.js → RBA6V3UO.js} +2 -2
- package/dist/chunks/{KLANM6M6.js → RO5Y5YU4.js} +1 -1
- package/dist/chunks/{53FS342F.js → TUGRIOFX.js} +2 -2
- package/dist/chunks/WEI32SAJ.js +13 -0
- package/dist/chunks/{GVFZM4BI.js → WINBISC2.js} +3 -3
- package/dist/chunks/Z5JVQNAZ.js +2 -0
- package/dist/cli.js +140 -139
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +2 -2
- package/types/ai/src/ai.d.ts +46 -19
- package/types/ai/src/chats.d.ts +478 -18
- package/types/ai/src/index.d.ts +4 -4
- package/types/ai/src/tools.d.ts +161 -29
- package/types/backend/src/bootstrap.d.ts +8 -0
- package/types/backend/src/container.d.ts +11 -2
- package/types/backend/src/database.d.ts +17 -2
- package/types/backend/src/engine.d.ts +3 -4
- package/types/backend/src/gateways.d.ts +269 -0
- package/types/backend/src/index.d.ts +3 -2
- package/types/backend/src/openapi.d.ts +3 -6
- package/types/backend/src/runtime.d.ts +51 -2
- package/types/backend/src/testing/unit.d.ts +3 -1
- package/types/internal/src/chat.d.ts +168 -35
- package/types/internal/src/modules/ai.d.ts +1826 -545
- package/types/internal/src/modules/auth.d.ts +14 -2
- package/types/internal/src/modules/events.d.ts +2 -2
- package/types/internal/src/modules/machines.d.ts +57 -1
- package/types/internal/src/modules/notify.d.ts +6 -6
- package/types/internal/src/modules/purchases.d.ts +357 -13
- package/types/internal/src/modules/realtime.d.ts +45 -1
- package/types/internal/src/modules/stores.d.ts +259 -22
- package/types/internal/src/transport.d.ts +5 -0
- package/types/server/src/auth/jwt.d.ts +1 -6
- package/types/web/src/auth.d.ts +15 -4
- package/types/web/src/backends.d.ts +20 -13
- package/types/web/src/chat.d.ts +329 -0
- package/types/web/src/client.d.ts +28 -3
- package/types/web/src/gateways.d.ts +90 -0
- package/types/web/src/index.d.ts +5 -4
- package/types/web/src/session.d.ts +11 -1
- package/types/web/src/socket.d.ts +18 -2
- package/types/web/src/voice.d.ts +36 -0
- package/dist/chunks/2RG3I7LX.js +0 -6
- package/dist/chunks/A76UZBAF.js +0 -2
- package/dist/chunks/AD5LBZAB.js +0 -4
- package/dist/chunks/DRGYTL6T.js +0 -20
- package/dist/chunks/IVEAUFGE.js +0 -13
- package/dist/chunks/IYCW6PWG.js +0 -2
- package/dist/chunks/KL7FIRII.js +0 -2
- package/dist/chunks/U4OZ4HOF.js +0 -2
- package/types/backend/src/channels.d.ts +0 -81
- package/types/backend/src/rooms.d.ts +0 -178
- package/types/web/src/ai.d.ts +0 -224
- package/types/web/src/rooms.d.ts +0 -61
package/types/ai/src/chats.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ChatStream, type FollowChatOptions } from '../../internal/src/chat.js';
|
|
2
1
|
import type * as modules from '../../internal/src/modules/index.js';
|
|
3
2
|
import { type ToolResult } from '../../internal/src/tool-output.js';
|
|
4
3
|
import { type AgentDefinitionInput, type BackendAgent, type BackendRepo } from './tools.js';
|
|
@@ -10,12 +9,17 @@ export type Endpoint = modules.ai.Endpoint;
|
|
|
10
9
|
export type Decision = modules.ai.Decision;
|
|
11
10
|
/** What the project allows its chats. */
|
|
12
11
|
export interface AISettings {
|
|
13
|
-
/** The app's users
|
|
12
|
+
/** The app's users reach the chats they are members of with their own session (the server starts every chat). */
|
|
14
13
|
clients: boolean;
|
|
15
14
|
/** How many messages one user sends a minute. */
|
|
16
15
|
userMessagesPerMinute: number;
|
|
17
|
-
/**
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* How much chat history the project keeps; a message past it is refused
|
|
18
|
+
* (409 history_full) until chats are deleted. A free project keeps 500 MiB
|
|
19
|
+
* at most; null: no fixed limit — a project with paid rights keeps all of
|
|
20
|
+
* it, unless it sets a limit of its own.
|
|
21
|
+
*/
|
|
22
|
+
historyLimitBytes: number | null;
|
|
19
23
|
/** How much it keeps now. */
|
|
20
24
|
historyBytes: number;
|
|
21
25
|
}
|
|
@@ -35,9 +39,22 @@ export interface MemberInput {
|
|
|
35
39
|
userId: string;
|
|
36
40
|
/** How the agent and the others are told who wrote. */
|
|
37
41
|
name?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Their address: what the commits their turns' agent makes in the chat's workspace are written as, with their
|
|
44
|
+
* name. Kept, never served to the chat's other members; their own session says it again, verified, as they write.
|
|
45
|
+
* Left out: an address of the platform's that names them and reaches no one.
|
|
46
|
+
*/
|
|
47
|
+
email?: string;
|
|
38
48
|
/** The owner deletes the chat. */
|
|
39
49
|
owner?: boolean;
|
|
40
50
|
}
|
|
51
|
+
/** A git trailer every commit of a chat's workspace carries at its message's end: PalCore-Task: #12, Co-authored-by: …. */
|
|
52
|
+
export interface CommitTrailer {
|
|
53
|
+
/** Its token, as git takes one: letters, digits and -, at most 64. */
|
|
54
|
+
key: string;
|
|
55
|
+
/** One line, 512 bytes at most. */
|
|
56
|
+
value: string;
|
|
57
|
+
}
|
|
41
58
|
export interface CreateChat {
|
|
42
59
|
/** A named agent of the project (or a backend's ai.agent, put); with a definition, the chat's name for it (default assistant). */
|
|
43
60
|
agent?: string | BackendAgent;
|
|
@@ -61,6 +78,12 @@ export interface CreateChat {
|
|
|
61
78
|
}[];
|
|
62
79
|
/** The agent pushes its commits without a person's yes (the chat's members' messages then reach the repository); otherwise a push waits for a member's approval. */
|
|
63
80
|
autoPush?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* What each of its commits carries at its message's end (16 at most): a task, a link back to the
|
|
83
|
+
* conversation, a co-author. A commit is written as the member its turn is for (MemberInput.email); a turn
|
|
84
|
+
* that is no member's commits as the platform.
|
|
85
|
+
*/
|
|
86
|
+
trailers?: CommitTrailer[];
|
|
64
87
|
};
|
|
65
88
|
signal?: AbortSignal;
|
|
66
89
|
}
|
|
@@ -81,7 +104,14 @@ export interface Repos {
|
|
|
81
104
|
defaultBranch?: string;
|
|
82
105
|
backend?: string;
|
|
83
106
|
}): Promise<Repo>;
|
|
84
|
-
|
|
107
|
+
/** A page of the project's repositories, by name (100 unless said, at most 1000; a project puts 10 000): nextCursor pages on. */
|
|
108
|
+
list(options?: {
|
|
109
|
+
limit?: number;
|
|
110
|
+
cursor?: string;
|
|
111
|
+
}): Promise<{
|
|
112
|
+
repos: Repo[];
|
|
113
|
+
nextCursor?: string;
|
|
114
|
+
}>;
|
|
85
115
|
/** A chat's workspace checks it out no more. */
|
|
86
116
|
delete(name: string): Promise<void>;
|
|
87
117
|
}
|
|
@@ -97,8 +127,165 @@ export interface SendMessage {
|
|
|
97
127
|
budget?: {
|
|
98
128
|
maxCostUsd: number;
|
|
99
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Its writer's labels for it (16 at most, snake_case keys, values of 512 bytes at most) — what an app draws it by:
|
|
132
|
+
* the files it names, the kind of row it is, the model its writer chose. Kept with it, shown with it in the chat's
|
|
133
|
+
* stream and its list, and given to the backend that defines the agent of the turn it opens (AgentContext.message).
|
|
134
|
+
* Sent again with the same clientId, the first message's stand.
|
|
135
|
+
*/
|
|
136
|
+
metadata?: Record<string, string>;
|
|
137
|
+
/**
|
|
138
|
+
* What the model reads with the message and no member does (64 KiB at most): a document the agent needs, how to
|
|
139
|
+
* open a file the message names. The agent is told it as the project's own words, apart from the writer's; the
|
|
140
|
+
* chat's stream and its list never show it.
|
|
141
|
+
*/
|
|
142
|
+
context?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Pictures of the project's storage the model is shown with the message (4 at most; png, jpeg, webp or gif by their
|
|
145
|
+
* bytes, 5 MiB each). Each is copied for the chat as the message is written — what it carried is what the agent
|
|
146
|
+
* reads, whatever becomes of the file. The server attaches any file of its storage; a member, and the server writing
|
|
147
|
+
* as one, their own files and a public bucket's (404 attachment_not_found otherwise).
|
|
148
|
+
*/
|
|
149
|
+
images?: MessageImage[];
|
|
150
|
+
/**
|
|
151
|
+
* Files of the project's storage put in the chat's workspace before the agent reads the message, at
|
|
152
|
+
* .palbase/attachments/<message id>/<filename> (8 at most, 15 MiB each) — the agent is told where. A chat that works
|
|
153
|
+
* in no workspace takes none (409 no_workspace). Copied, and who may attach which, as images.
|
|
154
|
+
*/
|
|
155
|
+
files?: MessageFile[];
|
|
156
|
+
signal?: AbortSignal;
|
|
157
|
+
}
|
|
158
|
+
/** A picture of the project's storage, for the model to be shown with a message. */
|
|
159
|
+
export interface MessageImage {
|
|
160
|
+
bucket: string;
|
|
161
|
+
path: string;
|
|
162
|
+
}
|
|
163
|
+
/** A file of the project's storage, for a message to put in its chat's workspace. */
|
|
164
|
+
export interface MessageFile {
|
|
165
|
+
bucket: string;
|
|
166
|
+
path: string;
|
|
167
|
+
/** Its name in the workspace, and what the message calls it; left out, its path's last segment. */
|
|
168
|
+
filename?: string;
|
|
169
|
+
/** What the agent is told it is (a media type); left out, what the project's storage says. */
|
|
170
|
+
contentType?: string;
|
|
171
|
+
}
|
|
172
|
+
/** A picture or a file a message carries ([] for none), its images first — its place among them is its position. */
|
|
173
|
+
export type MessageAttachment = modules.ai.MessageAttachment;
|
|
174
|
+
/** Where to fork a chat: before one of its messages (chats.fork). */
|
|
175
|
+
export interface ForkChat {
|
|
176
|
+
/** The message the fork is cut before (a message's id): it, and all that came after it, are not the fork's. */
|
|
177
|
+
beforeMessage: string;
|
|
178
|
+
/** The fork's title; left out: the chat's. */
|
|
179
|
+
title?: string;
|
|
180
|
+
/** Who is in the fork (64 at most); left out: the chat's members, as they are. */
|
|
181
|
+
members?: MemberInput[];
|
|
182
|
+
signal?: AbortSignal;
|
|
183
|
+
}
|
|
184
|
+
/** A chat's goal: what it works toward by itself, a turn at a time, and where it stands. */
|
|
185
|
+
export interface ChatGoal {
|
|
186
|
+
/** The goal's id: a new goal, a new id. */
|
|
187
|
+
id: string;
|
|
188
|
+
chatId: string;
|
|
189
|
+
objective: string;
|
|
190
|
+
/** What a claimed completion is checked against. */
|
|
191
|
+
rubric: string;
|
|
192
|
+
status: 'active' | 'paused' | 'blocked' | 'budget_limited' | 'achieved' | (string & {});
|
|
193
|
+
/**
|
|
194
|
+
* Why it last left active, as a stable code (empty while active): paused_by_person, paused_by_client, turn_stopped,
|
|
195
|
+
* turns_failed, no_progress, judge_unreadable, check_unreadable, needs_person, credit_hold, not_admitted,
|
|
196
|
+
* budget_spent, turns_used, time_used, achieved.
|
|
197
|
+
*/
|
|
198
|
+
stopCode: string;
|
|
199
|
+
/** Why, in a sentence. */
|
|
200
|
+
stopReason: string;
|
|
201
|
+
/** What its next turn is: work, or verify (the check of a completion its agent claimed). */
|
|
202
|
+
phase: 'work' | 'verify' | (string & {});
|
|
203
|
+
/** The member it was set as; null: the server. */
|
|
204
|
+
setBy: string | null;
|
|
205
|
+
/** The most turns it opens; null: no limit. */
|
|
206
|
+
maxTurns: number | null;
|
|
207
|
+
/** What it may cost at most, all its turns and their subagents together; null: no limit. */
|
|
208
|
+
budget: {
|
|
209
|
+
maxCostUsd: number;
|
|
210
|
+
} | null;
|
|
211
|
+
/** What it has used so far: work turns, checks of a claimed completion, dollars (a lower bound while some use has no price), seconds at work. */
|
|
212
|
+
usage: {
|
|
213
|
+
turns: number;
|
|
214
|
+
verifications: number;
|
|
215
|
+
costUsd: number;
|
|
216
|
+
costIsLowerBound: boolean;
|
|
217
|
+
activeSeconds: number;
|
|
218
|
+
};
|
|
219
|
+
/** When it was met; null: not yet. */
|
|
220
|
+
achievedAt: string | null;
|
|
221
|
+
createdAt: string;
|
|
222
|
+
updatedAt: string;
|
|
223
|
+
}
|
|
224
|
+
export interface SetGoal {
|
|
225
|
+
/** What the chat works toward, in words (4000 characters at most). */
|
|
226
|
+
objective: string;
|
|
227
|
+
/** What a claimed completion is checked against (8000 characters at most); left out: the objective itself. */
|
|
228
|
+
rubric?: string;
|
|
229
|
+
/** The most turns it opens (1–10 000); left out: no limit. */
|
|
230
|
+
maxTurns?: number;
|
|
231
|
+
/** What all its turns may cost at most, in US dollars, their subagents counted. */
|
|
232
|
+
budget?: {
|
|
233
|
+
maxCostUsd: number;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* The member it is set as: the goal and its turns are theirs, as their message's turn is — they decide and answer
|
|
237
|
+
* its turns' approvals and app tools, and change and clear it — while they stand where they stood: in the chat and,
|
|
238
|
+
* its agent defined for them alone, the chat theirs alone. Left out, the server's.
|
|
239
|
+
*/
|
|
240
|
+
as?: string;
|
|
241
|
+
signal?: AbortSignal;
|
|
242
|
+
}
|
|
243
|
+
/** What changes of a chat's goal: a field left out is left as it is. */
|
|
244
|
+
export interface GoalChange {
|
|
245
|
+
/** paused: the goal waits; active: it goes on, its next turn opened at once when none is at work. */
|
|
246
|
+
status?: 'paused' | 'active';
|
|
247
|
+
/** Why it is paused, with status paused (500 characters at most): said in its stopReason and its event. */
|
|
248
|
+
reason?: string;
|
|
249
|
+
objective?: string;
|
|
250
|
+
rubric?: string;
|
|
251
|
+
/** null: no limit. */
|
|
252
|
+
maxTurns?: number | null;
|
|
253
|
+
/** null: no limit. */
|
|
254
|
+
budget?: {
|
|
255
|
+
maxCostUsd: number;
|
|
256
|
+
} | null;
|
|
257
|
+
/** The member the server changes it as: the one it was set as (403 not_your_turn otherwise). */
|
|
258
|
+
as?: string;
|
|
100
259
|
signal?: AbortSignal;
|
|
101
260
|
}
|
|
261
|
+
/** A chat's goal, from its server: the engine works the chat toward it by itself, a turn at a time. */
|
|
262
|
+
export interface Goals {
|
|
263
|
+
/**
|
|
264
|
+
* Sets the chat's goal — replacing any it had: each of its turns is the chat's agent as it is defined now (a
|
|
265
|
+
* backend's agent is asked, told of the goal: AgentContext.goal), judged when it ends, a claimed completion checked
|
|
266
|
+
* against the rubric — until it is met, or maxTurns, the budget or a brake stops it. Its first turn opens at once
|
|
267
|
+
* when no turn of the chat is at work; a member's message goes before its next one. Its turns are the chat's: in its
|
|
268
|
+
* stream (a turn part that names the goal), billed, stopped by chats.stop. Each change of its status is the event
|
|
269
|
+
* ai.goal.updated (@On('ai.goal.updated')), and its words are goal parts of the chat's stream.
|
|
270
|
+
*/
|
|
271
|
+
set(id: string, goal: SetGoal): Promise<ChatGoal>;
|
|
272
|
+
/** The chat's goal (a 404 when it has none): its status, why it stopped, its next turn, its limits and its use. */
|
|
273
|
+
get(id: string, options?: {
|
|
274
|
+
as?: string;
|
|
275
|
+
signal?: AbortSignal;
|
|
276
|
+
}): Promise<ChatGoal>;
|
|
277
|
+
/**
|
|
278
|
+
* Pauses it (with a reason) or resumes it, edits its words, or changes a limit. An achieved goal is not changed
|
|
279
|
+
* (409 goal_achieved: set a new one); one whose member no longer stands where they stood when it was set is not
|
|
280
|
+
* resumed (409 goal_lapsed: clear it, or set another for the chat as it is now).
|
|
281
|
+
*/
|
|
282
|
+
update(id: string, change: GoalChange): Promise<ChatGoal>;
|
|
283
|
+
/** No turn of it opens again; one at work finishes as an ordinary turn. ai.goal.updated says it cleared. */
|
|
284
|
+
clear(id: string, options?: {
|
|
285
|
+
as?: string;
|
|
286
|
+
signal?: AbortSignal;
|
|
287
|
+
}): Promise<void>;
|
|
288
|
+
}
|
|
102
289
|
/** What one turn of a chat cost so far, its subagents' calls counted; final once nothing more of it can be settled. */
|
|
103
290
|
export interface TurnCost {
|
|
104
291
|
chatId: string;
|
|
@@ -107,9 +294,77 @@ export interface TurnCost {
|
|
|
107
294
|
outputTokens: number;
|
|
108
295
|
/** In billionths of a US dollar. */
|
|
109
296
|
costNanoUsd: number;
|
|
297
|
+
/** costNanoUsd in dollars. */
|
|
298
|
+
usd: number;
|
|
110
299
|
/** A model of the turn has no price: the cost is a lower bound. */
|
|
111
300
|
unpriced: boolean;
|
|
112
301
|
final: boolean;
|
|
302
|
+
/** The cost run by run so far — the turn's own and each subagent's, by its name and model: a turn at work is read as it spends. */
|
|
303
|
+
runs: TurnRunCost[];
|
|
304
|
+
}
|
|
305
|
+
/** What one run of a turn — its own, or a subagent's — cost so far. */
|
|
306
|
+
export interface TurnRunCost {
|
|
307
|
+
runId: string;
|
|
308
|
+
/** Its response: the turn's, or the subagent's (an agent part's response_id). */
|
|
309
|
+
responseId: string;
|
|
310
|
+
/** The run that started it; null for the turn's own. */
|
|
311
|
+
parentRunId: string | null;
|
|
312
|
+
/** The subagent it is; '' for the turn's own run. */
|
|
313
|
+
subagent: string;
|
|
314
|
+
/** provider:model. */
|
|
315
|
+
model: string;
|
|
316
|
+
/** running, completed, failed… */
|
|
317
|
+
state: string;
|
|
318
|
+
inputTokens: number;
|
|
319
|
+
outputTokens: number;
|
|
320
|
+
cacheReadTokens: number;
|
|
321
|
+
cacheWriteTokens: number;
|
|
322
|
+
costNanoUsd: number;
|
|
323
|
+
usd: number;
|
|
324
|
+
/** Some of its use had no rate: the cost is a floor. */
|
|
325
|
+
unpriced: boolean;
|
|
326
|
+
}
|
|
327
|
+
/** One tool call of a chat, its whole answer: the stream shows its end (its last 16 KiB); read whole, its secret shapes masked. */
|
|
328
|
+
export interface ChatToolCall {
|
|
329
|
+
callId: string;
|
|
330
|
+
name: string;
|
|
331
|
+
/** pending, executing, completed, failed… */
|
|
332
|
+
status: string;
|
|
333
|
+
/** The run that made it: the turn's, or a subagent's. */
|
|
334
|
+
runId: string;
|
|
335
|
+
/** The turn — or the subagent's work in it — that made it. */
|
|
336
|
+
responseId: string;
|
|
337
|
+
/** What the agent called it with; null when its arguments, masked, are no JSON. */
|
|
338
|
+
input: unknown;
|
|
339
|
+
/** Its answer's text, whole; null: none yet. */
|
|
340
|
+
output: string | null;
|
|
341
|
+
outputBytes: number;
|
|
342
|
+
/** How many pictures it returned. */
|
|
343
|
+
imageCount: number;
|
|
344
|
+
isError: boolean;
|
|
345
|
+
}
|
|
346
|
+
/** A tool call of a turn as the engine committed it: what a diff of the files the turn wrote is made of. */
|
|
347
|
+
export interface TurnToolCall {
|
|
348
|
+
callId: string;
|
|
349
|
+
name: string;
|
|
350
|
+
state: string;
|
|
351
|
+
createdAt: string;
|
|
352
|
+
updatedAt: string;
|
|
353
|
+
/** What the agent called it with, as JSON. */
|
|
354
|
+
arguments: unknown;
|
|
355
|
+
/** What it returned, as the engine committed it ({ output: [...], is_error } — a platform tool's own JSON); undefined: nothing yet. */
|
|
356
|
+
result?: unknown;
|
|
357
|
+
}
|
|
358
|
+
/** One part of a chat's stream as its channel carried it: what a page of the chat's past holds (chats.parts). */
|
|
359
|
+
export interface ChatStreamPart {
|
|
360
|
+
/** message, turn, text, reset, thinking, tool, agent, goal, voice, transcript, history — as the stream says them. */
|
|
361
|
+
type: string;
|
|
362
|
+
/** The journal's sequence it was told at; absent for an answer's text, placed by its offset. */
|
|
363
|
+
id?: number;
|
|
364
|
+
/** The id the channel told it under. */
|
|
365
|
+
partId: string;
|
|
366
|
+
/** What the part says, as the stream says it. */
|
|
367
|
+
data: Record<string, unknown>;
|
|
113
368
|
}
|
|
114
369
|
/** One artifact a turn's agent published: a build's product from the workspace's Mac, a screenshot, a report. */
|
|
115
370
|
export interface TurnArtifact {
|
|
@@ -121,21 +376,127 @@ export interface TurnArtifact {
|
|
|
121
376
|
checksum: string;
|
|
122
377
|
createdAt: string;
|
|
123
378
|
}
|
|
379
|
+
/** A chat's voice: whose it is, what becomes of what is asked of it out loud, whether it is live, how long, why it ended. */
|
|
380
|
+
export interface ChatVoice {
|
|
381
|
+
id: string;
|
|
382
|
+
chatId: string;
|
|
383
|
+
/** Its member; null: the server's own. */
|
|
384
|
+
userId: string | null;
|
|
385
|
+
/** chat: what the person asks for is a turn of the chat as its member, whose answer the voice says; events: ai.voice.delegated. */
|
|
386
|
+
delegation: 'chat' | 'events' | (string & {});
|
|
387
|
+
status: 'active' | 'closed' | (string & {});
|
|
388
|
+
/** How long it has lasted. */
|
|
389
|
+
seconds: number;
|
|
390
|
+
startedAt: string;
|
|
391
|
+
/** null: live. */
|
|
392
|
+
closedAt: string | null;
|
|
393
|
+
/** Why it ended: close_requested, member_removed, chat_deleted, replaced, lost, or the provider's word ('' while live). */
|
|
394
|
+
closeReason: string;
|
|
395
|
+
}
|
|
396
|
+
export interface StartVoice {
|
|
397
|
+
/** The app's WebRTC offer (an SDP) — the browser's peer connection's (palbase/web's connectVoice makes it). */
|
|
398
|
+
sdp: string;
|
|
399
|
+
/** The voice it speaks in; left out, the provider's default. */
|
|
400
|
+
voice?: string;
|
|
401
|
+
/**
|
|
402
|
+
* What becomes of what the person asks for out loud: chat (the default) — a message of the voice's member to the
|
|
403
|
+
* chat's agent, a turn of the chat, whose answer the voice says back; events — the event ai.voice.delegated, for the
|
|
404
|
+
* backend to have done and answer with command({ type: 'speak' | 'tell', delegationId }).
|
|
405
|
+
*/
|
|
406
|
+
delegation?: 'chat' | 'events';
|
|
407
|
+
/** The member the server starts it for: the voice is theirs (they read, tell and close it), and counts toward their starts (5 an hour). */
|
|
408
|
+
as?: string;
|
|
409
|
+
signal?: AbortSignal;
|
|
410
|
+
}
|
|
411
|
+
export interface VoiceCommand {
|
|
412
|
+
/**
|
|
413
|
+
* speak: say this exactly and nothing else — once what the voice is saying ends, in the order they came; tell: say it
|
|
414
|
+
* in your own words; know: keep it in mind; instruct: behave so from now on.
|
|
415
|
+
*/
|
|
416
|
+
type: 'speak' | 'tell' | 'know' | 'instruct';
|
|
417
|
+
/** 16 KiB at most. */
|
|
418
|
+
text: string;
|
|
419
|
+
/** speak or tell: the request it answers (ai.voice.delegated's delegation_id). */
|
|
420
|
+
delegationId?: string;
|
|
421
|
+
/** speak only: cut what the voice is saying and say the text at once. */
|
|
422
|
+
interrupt?: boolean;
|
|
423
|
+
/** The voice's member the server tells it as. */
|
|
424
|
+
as?: string;
|
|
425
|
+
signal?: AbortSignal;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* A chat's live voice, from its server: the app's WebRTC offer in, the provider's answer out — the audio then goes
|
|
429
|
+
* between the app and the platform's voice provider. What is said either way is the chat's: transcript parts of its
|
|
430
|
+
* stream and messages of kind voice of its history. One voice talks in a chat at a time.
|
|
431
|
+
*/
|
|
432
|
+
export interface Voices {
|
|
433
|
+
/** Starts it: its id and the answer (sdp) for the app's peer connection. Its start is the event ai.voice.started. */
|
|
434
|
+
start(id: string, voice: StartVoice): Promise<ChatVoice & {
|
|
435
|
+
sdp: string;
|
|
436
|
+
}>;
|
|
437
|
+
/** The voice: its member's, or the server's (403 not_your_voice). */
|
|
438
|
+
get(id: string, voiceId: string, options?: {
|
|
439
|
+
as?: string;
|
|
440
|
+
signal?: AbortSignal;
|
|
441
|
+
}): Promise<ChatVoice>;
|
|
442
|
+
/** Gives it text — the server's alone, as itself or as the voice's member; one that has ended is 409 voice_closed. */
|
|
443
|
+
command(id: string, voiceId: string, command: VoiceCommand): Promise<ChatVoice>;
|
|
444
|
+
/** Ends it: how long it lasted and why it ended. Its end is the event ai.voice.closed, once. */
|
|
445
|
+
close(id: string, voiceId: string, options?: {
|
|
446
|
+
as?: string;
|
|
447
|
+
signal?: AbortSignal;
|
|
448
|
+
}): Promise<ChatVoice>;
|
|
449
|
+
}
|
|
450
|
+
/** A chat's workspace, from its server: a file of a tree it published, a repository put in it at work. */
|
|
451
|
+
export interface Workspaces {
|
|
452
|
+
/**
|
|
453
|
+
* A file of the chat's workspace, its bytes: from the tree it is at now, or from the one an ai.workspace.published
|
|
454
|
+
* event named (manifest) — a build's product as that publish left it. 64 MiB at most (413 file_too_large: publish a
|
|
455
|
+
* larger one as the turn's artifact); its digest is the answer's Content-Digest. Read the Response as it comes.
|
|
456
|
+
*/
|
|
457
|
+
file(id: string, path: string, options?: {
|
|
458
|
+
manifest?: string;
|
|
459
|
+
signal?: AbortSignal;
|
|
460
|
+
}): Promise<globalThis.Response>;
|
|
461
|
+
/**
|
|
462
|
+
* Puts one more of the project's repositories (ai.repos.put — one born at work too) in an open chat's workspace,
|
|
463
|
+
* beside its others, at a branch (its default unless said): cloned before the chat's next turn, and every chat
|
|
464
|
+
* working in the workspace has it (a fork too). Put again, the same. A chat of no workspace: 409 no_workspace.
|
|
465
|
+
*/
|
|
466
|
+
addRepo(id: string, repo: {
|
|
467
|
+
repo: string | BackendRepo;
|
|
468
|
+
branch?: string;
|
|
469
|
+
signal?: AbortSignal;
|
|
470
|
+
}): Promise<Chat>;
|
|
471
|
+
}
|
|
124
472
|
export interface Chats {
|
|
125
473
|
create(chat: CreateChat): Promise<Chat>;
|
|
126
474
|
get(id: string, options?: {
|
|
127
475
|
signal?: AbortSignal;
|
|
128
476
|
}): Promise<Chat>;
|
|
129
|
-
/**
|
|
477
|
+
/**
|
|
478
|
+
* A page of the chats, the newest first (100 unless said, at most 100):
|
|
479
|
+
* every chat, or a member's — and, with metadata, only those labelled with
|
|
480
|
+
* every one of its labels (a product's chats: { project_id: id }).
|
|
481
|
+
* nextCursor pages on.
|
|
482
|
+
*/
|
|
130
483
|
list(options?: {
|
|
131
484
|
member?: string;
|
|
485
|
+
metadata?: Record<string, string>;
|
|
486
|
+
limit?: number;
|
|
487
|
+
cursor?: string;
|
|
132
488
|
signal?: AbortSignal;
|
|
133
|
-
}): Promise<
|
|
489
|
+
}): Promise<{
|
|
490
|
+
chats: Chat[];
|
|
491
|
+
nextCursor?: string;
|
|
492
|
+
}>;
|
|
134
493
|
/** A turn still running is stopped; its history no longer counts. */
|
|
135
494
|
delete(id: string): Promise<void>;
|
|
136
495
|
members: {
|
|
496
|
+
/** Puts a member in, or changes one: a field left out is left as it is (email: what their turns' commits are written as). */
|
|
137
497
|
put(id: string, userId: string, member: {
|
|
138
498
|
name?: string;
|
|
499
|
+
email?: string;
|
|
139
500
|
owner?: boolean;
|
|
140
501
|
}): Promise<Chat>;
|
|
141
502
|
delete(id: string, userId: string): Promise<void>;
|
|
@@ -163,28 +524,126 @@ export interface Chats {
|
|
|
163
524
|
messages: ChatMessage[];
|
|
164
525
|
nextCursor?: string;
|
|
165
526
|
}>;
|
|
166
|
-
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
527
|
+
/**
|
|
528
|
+
* The chat's past as its stream told it, a page at a time from its newest end back: the same parts, in their
|
|
529
|
+
* order, each under the id the channel told it (partId) — what a client's chat reads past the day its channel
|
|
530
|
+
* keeps (palbase/web's chat.loadOlder, given this page through the app's backend). A page reads limit of the
|
|
531
|
+
* chat's events (1–1000; 300) before the cursor, or before the oldest part the app holds of the channel (before:
|
|
532
|
+
* that part's id — the first page then does not read again the day the channel told); neither, from the newest
|
|
533
|
+
* end. The one that reaches the chat's start begins where a fork began.
|
|
534
|
+
*/
|
|
535
|
+
parts(id: string, options?: {
|
|
536
|
+
limit?: number;
|
|
537
|
+
cursor?: string;
|
|
538
|
+
before?: number;
|
|
539
|
+
signal?: AbortSignal;
|
|
540
|
+
}): Promise<{
|
|
541
|
+
parts: ChatStreamPart[];
|
|
542
|
+
nextCursor?: string;
|
|
543
|
+
}>;
|
|
544
|
+
/** One tool call of the chat, its whole answer — the stream shows its end — its secret shapes masked as the stream masks them. */
|
|
545
|
+
toolCall(id: string, callId: string, options?: {
|
|
546
|
+
signal?: AbortSignal;
|
|
547
|
+
}): Promise<ChatToolCall>;
|
|
548
|
+
/**
|
|
549
|
+
* A turn's tool calls as the engine committed them — their arguments and results as they were — in their order,
|
|
550
|
+
* a page at a time (1–500; 100): turn is a message's responseId, or a turn's or an agent part's (a subagent's work).
|
|
551
|
+
*/
|
|
552
|
+
toolCalls(id: string, options: {
|
|
553
|
+
turn: string;
|
|
554
|
+
limit?: number;
|
|
555
|
+
cursor?: string;
|
|
556
|
+
signal?: AbortSignal;
|
|
557
|
+
}): Promise<{
|
|
558
|
+
toolCalls: TurnToolCall[];
|
|
559
|
+
nextCursor?: string;
|
|
560
|
+
}>;
|
|
561
|
+
/** The chat's workspace: a file of a tree it published, a repository put in it at work. */
|
|
562
|
+
readonly workspace: Workspaces;
|
|
563
|
+
/**
|
|
564
|
+
* What happens in the chat — its messages, its turns, the answer as it is written, the tools and subagents — as a
|
|
565
|
+
* source a gateway pipes into its channel: `ctx.pipe(Palbase.ai.chats.events(id))`. The platform writes the chat
|
|
566
|
+
* into the channel itself from then on; the backend is not in the stream, and the gateway's members hear it.
|
|
567
|
+
*/
|
|
568
|
+
events(id: string): ChatEvents;
|
|
569
|
+
/** Stops the turn it is working on: what it wrote stays. Its response's id, or null when none ran. As a member (as), or as the server. */
|
|
570
|
+
stop(id: string, options?: {
|
|
571
|
+
as?: string;
|
|
572
|
+
signal?: AbortSignal;
|
|
573
|
+
}): Promise<string | null>;
|
|
574
|
+
/**
|
|
575
|
+
* A tool call that waits for a person's yes (a tool event's approval_id): made — a push, a pull request or a merge the
|
|
576
|
+
* agent asked for too (a tool part named so, its publication saying what and where). As a member (as), the server is
|
|
577
|
+
* held to their rules — a turn another member began is not theirs to decide (403 not_your_turn); without it, the
|
|
578
|
+
* server decides any.
|
|
579
|
+
*/
|
|
580
|
+
approve(id: string, approvalId: string, options?: {
|
|
581
|
+
reason?: string;
|
|
582
|
+
as?: string;
|
|
583
|
+
}): Promise<Decision>;
|
|
172
584
|
/** Not made: the agent is told, with the reason, and goes on. */
|
|
173
|
-
deny(id: string, approvalId: string,
|
|
174
|
-
|
|
585
|
+
deny(id: string, approvalId: string, options?: {
|
|
586
|
+
reason?: string;
|
|
587
|
+
as?: string;
|
|
588
|
+
}): Promise<Decision>;
|
|
589
|
+
/**
|
|
590
|
+
* The answer of a client tool's call (a tool event's call_id): true when it is the one taken, false when another came
|
|
591
|
+
* first. As a member (as): the app of the member whose turn it is answers it (403 not_your_turn otherwise). A
|
|
592
|
+
* backend tool that returned ai.deferred() — its ToolContext's chatId and callId — is answered here too, by the
|
|
593
|
+
* server as itself (never as a member), within the while it named.
|
|
594
|
+
*/
|
|
175
595
|
answer(id: string, callId: string, output: ToolResult, options?: {
|
|
176
596
|
isError?: boolean;
|
|
597
|
+
as?: string;
|
|
177
598
|
}): Promise<boolean>;
|
|
178
|
-
/** A message for one of the agent's subagents at work (an agent event's run_id), at its next step. */
|
|
599
|
+
/** A message for one of the agent's subagents at work (an agent event's run_id, a tool call's ctx.runId), at its next step — as a member, held to their rules. */
|
|
179
600
|
sendToSubagent(id: string, runId: string, text: string, options?: {
|
|
180
601
|
clientId?: string;
|
|
602
|
+
as?: string;
|
|
181
603
|
}): Promise<{
|
|
182
604
|
runId: string;
|
|
183
605
|
clientId: string;
|
|
184
606
|
}>;
|
|
607
|
+
/**
|
|
608
|
+
* Stops one subagent at work (an agent event's run_id) — with the subagents it started and its background work:
|
|
609
|
+
* the agent that started it is told a person stopped it, and not to start that work again unless asked, and the
|
|
610
|
+
* rest of the turn goes on. As a member (as), or as the server; a run that is not a subagent at work in this chat
|
|
611
|
+
* is a 404. Asked again, the same stop answers as it did.
|
|
612
|
+
*/
|
|
613
|
+
stopSubagent(id: string, runId: string, options?: {
|
|
614
|
+
as?: string;
|
|
615
|
+
signal?: AbortSignal;
|
|
616
|
+
}): Promise<{
|
|
617
|
+
runId: string;
|
|
618
|
+
}>;
|
|
619
|
+
/**
|
|
620
|
+
* A new chat that begins where this one was before one of its messages — what a person's "edit this message"
|
|
621
|
+
* makes: send the edited message into it. Its agent, its labels and (unless members says) its members are the
|
|
622
|
+
* chat's; it begins with the chat's messages and its agent's answers before that message (its subagents' work left
|
|
623
|
+
* out), which the model reads with the fork's first turn and its pipe writes first (history parts). A chat whose
|
|
624
|
+
* agent is at work is not forked (409 turn_running); more than 512 KiB before the message is 409 fork_too_large.
|
|
625
|
+
*/
|
|
626
|
+
fork(id: string, fork: ForkChat): Promise<Chat>;
|
|
627
|
+
/** The chat's goal: set, read, paused, resumed, changed, cleared. */
|
|
628
|
+
readonly goal: Goals;
|
|
629
|
+
/** The chat's live voice: started from the app's WebRTC offer, read, told, closed. */
|
|
630
|
+
readonly voice: Voices;
|
|
631
|
+
}
|
|
632
|
+
/** A chat's stream as a gateway pipes it into its channel (gateways' PipeSource). */
|
|
633
|
+
export interface ChatEvents {
|
|
634
|
+
readonly kind: 'ai.chat';
|
|
635
|
+
readonly chatId: string;
|
|
636
|
+
/** Writes the chat into the channel from now on — from its start, for a channel that had not been its own. */
|
|
637
|
+
pipe(topic: string, options?: {
|
|
638
|
+
signal?: AbortSignal;
|
|
639
|
+
}): Promise<void>;
|
|
640
|
+
/** Writes it nowhere from now on. */
|
|
641
|
+
unpipe(options?: {
|
|
642
|
+
signal?: AbortSignal;
|
|
643
|
+
}): Promise<void>;
|
|
185
644
|
}
|
|
186
645
|
export interface Agents {
|
|
187
|
-
/** Names an agent: its definition, or a backend's ai.agent (its chats' turns ask the backend's machine)
|
|
646
|
+
/** Names an agent: its definition, or a backend's ai.agent (its chats' turns ask the backend's machine). */
|
|
188
647
|
put(name: string, definition: AgentDefinitionInput | BackendAgent): Promise<Agent>;
|
|
189
648
|
put(agent: BackendAgent): Promise<Agent>;
|
|
190
649
|
list(): Promise<Agent[]>;
|
|
@@ -200,10 +659,11 @@ export interface Endpoints {
|
|
|
200
659
|
export interface Settings {
|
|
201
660
|
get(): Promise<AISettings>;
|
|
202
661
|
/** A field left out is left as it is; the history kept may be lowered, not raised past the plan's. */
|
|
662
|
+
/** A field left out is left as it is; historyLimitBytes null clears the project's own limit (the plan's is kept). */
|
|
203
663
|
put(change: {
|
|
204
664
|
clients?: boolean;
|
|
205
665
|
userMessagesPerMinute?: number;
|
|
206
|
-
historyLimitBytes?: number;
|
|
666
|
+
historyLimitBytes?: number | null;
|
|
207
667
|
}): Promise<AISettings>;
|
|
208
668
|
}
|
|
209
669
|
/**
|
package/types/ai/src/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { createAI, AIResponseError } from './ai.js';
|
|
2
|
-
export type { AI, AIOptions, Ask, AskImage, AskTool, DeepPartial, Embed, Generate, ImageRequest, Images, Job, Message, Model, ObjectStream, Picture, Response, Schema, TextStream, Uploader, Usage, } from './ai.js';
|
|
2
|
+
export type { AI, AIOptions, Ask, AskImage, AskTool, ChatModel, DeepPartial, Embed, Generate, ImageRequest, Images, Job, Message, Model, Models, ObjectStream, Picture, Response, Schema, TextStream, Uploader, Usage, } from './ai.js';
|
|
3
3
|
export { AISchemaError, prepare } from './schema.js';
|
|
4
4
|
export { ToolError } from './tools.js';
|
|
5
5
|
export type { Infer, StandardSchema } from './schema.js';
|
|
6
6
|
export { partial } from './partial.js';
|
|
7
|
-
export type { AISettings, Agent, Agents, Chat, ChatMessage, Chats, CreateChat, Decision, Endpoint, EndpointInput, Endpoints, MemberInput, Repo, Repos, SendMessage, Settings, TurnArtifact, TurnCost } from './chats.js';
|
|
8
|
-
export type { AgentContext, AgentDefinitionInput, BackendAgent, BackendRepo, BackendTool, BackendToolOptions, ChatContext, ClientTool, ClientToolOptions, HttpsToolRef, McpToolRef, SubagentDefinition, Tool, ToolContext, TurnDefinition, } from './tools.js';
|
|
9
|
-
export type { AgentEvent, ChatEvent,
|
|
7
|
+
export type { AISettings, Agent, Agents, Chat, ChatEvents, ChatGoal, ChatMessage, ChatStreamPart, ChatToolCall, ChatVoice, Chats, CommitTrailer, CreateChat, Decision, Endpoint, EndpointInput, Endpoints, ForkChat, GoalChange, Goals, MemberInput, MessageAttachment, MessageFile, MessageImage, Repo, Repos, SendMessage, SetGoal, Settings, StartVoice, TurnArtifact, TurnCost, TurnRunCost, TurnToolCall, VoiceCommand, Voices, Workspaces, } from './chats.js';
|
|
8
|
+
export type { AgentContext, AgentDefinitionInput, BackendAgent, BackendRepo, BackendTool, BackendToolOptions, ChatContext, ClientTool, ClientToolOptions, DeferredAnswer, Effort, HttpsToolRef, McpToolRef, PlatformToolName, PlatformToolRef, RepoTokenContext, RepoTokens, SubagentDefinition, Thinking, Tool, ToolAnswer, ToolContext, TurnDefinition, TurnMessage, } from './tools.js';
|
|
9
|
+
export type { AgentEvent, ChatEvent, GoalEvent, GoalKind, HistoryEvent, HistoryItem, MessageEvent, Publication, ResetEvent, TextEvent, ThinkingEvent, ToolEvent, ToolStatus, TranscriptEvent, TurnEnd, TurnEvent, TurnStatus, VoiceEvent, WaitingReason, } from '../../internal/src/chat.js';
|
|
10
10
|
export type { ToolPart, ToolResult } from '../../internal/src/tool-output.js';
|