palbase 0.64.0 → 0.66.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 -2
- package/dist/ai-sdk/index.js +4 -0
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +3 -3
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{ZO7BWXF3.js → 243727GR.js} +2 -2
- package/dist/chunks/{KRYGPGVB.js → 2DGYQO2K.js} +2 -2
- package/dist/chunks/{U6S2T2FE.js → 47OT2TAE.js} +2 -2
- package/dist/chunks/{ZZLCBUNM.js → 4DOKNJUJ.js} +2 -2
- package/dist/chunks/{TTDCC4FL.js → 7JAVCOPA.js} +1 -1
- package/dist/chunks/{7WLAMFND.js → FFRCUMXB.js} +2 -2
- package/dist/chunks/GS7AQ2KQ.js +2 -0
- package/dist/chunks/GVC6OZMF.js +13 -0
- package/dist/chunks/{2FPPZ3A3.js → GYB7XBYV.js} +2 -2
- package/dist/chunks/{TNY6UGJZ.js → HECZUS65.js} +2 -2
- package/dist/chunks/{B6FEEB5R.js → L5DVXXH3.js} +1 -1
- package/dist/chunks/{AUCNHNPD.js → MTOW4UUP.js} +2 -2
- package/dist/chunks/PQ23MXWT.js +18 -0
- package/dist/chunks/{XDGXREXS.js → PZXACOXA.js} +1 -1
- package/dist/chunks/{D2Z5R7ZP.js → QKAKVJLA.js} +1 -1
- package/dist/chunks/{MVHF5I2L.js → QT7PHIRR.js} +2 -2
- package/dist/chunks/{RCV4YOM6.js → REON7CA7.js} +1 -1
- package/dist/chunks/UZERPL37.js +2 -0
- package/dist/chunks/V7X2RHTR.js +21 -0
- package/dist/chunks/{MUHCCKSS.js → YO7F2OI2.js} +1 -1
- package/dist/chunks/ZA5NYGQH.js +22 -0
- package/dist/chunks/{XIHO4HVO.js → ZV6WG4DE.js} +1 -1
- package/dist/chunks/ZY6P5WKM.js +2 -0
- package/dist/cli.js +356 -371
- package/dist/cloud/index.js +2 -2
- package/dist/refuse/ai-sdk.js +2 -0
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/cloud.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/message.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/push-sw.js +1 -1
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +4 -3
- package/package.json +14 -2
- package/types/ai/src/ai.d.ts +55 -29
- package/types/ai/src/chats.d.ts +163 -171
- package/types/ai/src/index.d.ts +5 -5
- package/types/ai/src/pools.d.ts +17 -7
- package/types/ai/src/tools.d.ts +6 -64
- package/types/ai-sdk/src/index.d.ts +166 -0
- package/types/backend/src/decorators.d.ts +2 -1
- package/types/backend/src/services.d.ts +2 -2
- package/types/backend/src/stack.d.ts +2 -4
- package/types/backend/src/upload.d.ts +2 -1
- package/types/cloud/src/generated/project.d.ts +2 -1
- package/types/internal/src/chat.d.ts +56 -2
- package/types/internal/src/modules/ai.d.ts +960 -1140
- package/types/internal/src/modules/events.d.ts +4 -3
- package/types/internal/src/modules/index.d.ts +1 -0
- package/types/internal/src/modules/storage.d.ts +1 -1
- package/types/internal/src/modules/workspaces.d.ts +626 -0
- package/types/server/src/server.d.ts +5 -0
- package/types/web/src/chat.d.ts +30 -4
- package/types/web/src/client.d.ts +7 -7
- package/types/web/src/index.d.ts +2 -1
- package/types/web/src/vite.d.ts +8 -0
- package/dist/chunks/47YRZOKH.js +0 -2
- package/dist/chunks/73CKSYD7.js +0 -21
- package/dist/chunks/HWDOVTN4.js +0 -22
- package/dist/chunks/K4E27V7K.js +0 -2
- package/dist/chunks/QDAQJXBR.js +0 -18
- package/dist/chunks/SKPSBDXT.js +0 -2
- package/dist/chunks/UAD4XPIB.js +0 -13
package/types/ai/src/tools.d.ts
CHANGED
|
@@ -48,9 +48,8 @@ export interface ToolContext extends ChatContext {
|
|
|
48
48
|
subagent: string | null;
|
|
49
49
|
/**
|
|
50
50
|
* The chat's workspace as the session last wrote it, its writes flushed before the call — absent when the chat
|
|
51
|
-
* works in none. Read a file of it
|
|
52
|
-
*
|
|
53
|
-
* workspaceTree }), and the agent's next command sees it.
|
|
51
|
+
* works in none. Read a file of it via the workspaces module; a tool that writes the workspace answers the tree its
|
|
52
|
+
* writes left with ai.answer(output, { workspaceTree }), and the agent's next command sees it.
|
|
54
53
|
*/
|
|
55
54
|
workspace?: ToolWorkspace;
|
|
56
55
|
}
|
|
@@ -58,13 +57,13 @@ export interface ToolContext extends ChatContext {
|
|
|
58
57
|
export interface ToolWorkspace {
|
|
59
58
|
/** The chat whose workspace it is. */
|
|
60
59
|
chatId: string;
|
|
61
|
-
/** The tree
|
|
60
|
+
/** The tree manifest id. */
|
|
62
61
|
manifestId?: string;
|
|
63
62
|
/** Its place in the workspace's history. */
|
|
64
63
|
seq?: number;
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
|
-
* The tree a tool's writes left a chat's workspace at
|
|
66
|
+
* The tree a tool's writes left a chat's workspace at ({ manifestId, seq }),
|
|
68
67
|
* either or both: the session's machine takes it before the agent's next command.
|
|
69
68
|
*/
|
|
70
69
|
export interface WorkspaceTree {
|
|
@@ -175,7 +174,7 @@ export interface ToolReply {
|
|
|
175
174
|
/** The tree a tool says its writes left, as the platform takes it — refused here when the platform would drop it. */
|
|
176
175
|
export declare function workspaceTreeOf(t: unknown, what: string): WireWorkspaceTree;
|
|
177
176
|
/**
|
|
178
|
-
* A backend tool's output with the tree its writes left the chat's workspace at
|
|
177
|
+
* A backend tool's output with the tree its writes left the chat's workspace at:
|
|
179
178
|
* the session's machine takes that tree before the agent's next command, so the agent sees what the tool wrote. A
|
|
180
179
|
* tool that wrote and then failed says it with its ToolError (new ToolError(message, { workspaceTree })).
|
|
181
180
|
*/
|
|
@@ -393,46 +392,13 @@ export interface BackendAgent {
|
|
|
393
392
|
tools: BackendTool[];
|
|
394
393
|
}>;
|
|
395
394
|
}
|
|
396
|
-
/** What one clone or one push of a chat's workspace asks a repository's token with: an ai.repo's token, ai.repoTokens' give. */
|
|
397
|
-
export interface RepoTokenContext {
|
|
398
|
-
/** The repository's name in the project (ai.repos.put). */
|
|
399
|
-
repo: string;
|
|
400
|
-
/** The GitHub repository, owner/name. */
|
|
401
|
-
repository: string;
|
|
402
|
-
/** Ended when the platform stops waiting for the token. */
|
|
403
|
-
signal: AbortSignal;
|
|
404
|
-
/**
|
|
405
|
-
* The app's instance of a provider, as a tool's run is given it
|
|
406
|
-
* (ChatContext.inject): a token a service of the app's mints — its GitHub
|
|
407
|
-
* App's, its sealed credentials' — from the container of the app that
|
|
408
|
-
* serves the ask. A class no module provides is refused, by name.
|
|
409
|
-
*/
|
|
410
|
-
inject<T extends object>(provider: abstract new (...args: never[]) => T): T;
|
|
411
|
-
}
|
|
412
|
-
/** What gives a repository's token when no ai.repo of its name was made: ai.repoTokens(give). */
|
|
413
|
-
export type RepoTokens = (ctx: RepoTokenContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
414
|
-
/** A repository a chat's workspace works in, whose tokens the backend gives (ai.repo). */
|
|
415
|
-
export interface BackendRepo {
|
|
416
|
-
readonly kind: 'repo';
|
|
417
|
-
readonly name: string;
|
|
418
|
-
/** The GitHub repository, owner/name. */
|
|
419
|
-
readonly repository: string;
|
|
420
|
-
readonly defaultBranch: string;
|
|
421
|
-
/** The project's machine that gives its tokens (default backend). */
|
|
422
|
-
readonly machine?: string;
|
|
423
|
-
/** A token for one clone or one push of it: asked at each — a GitHub App's installation token, minted then. */
|
|
424
|
-
token(ctx: RepoTokenContext): Promise<string>;
|
|
425
|
-
}
|
|
426
395
|
/** What this process declared, for the framework to serve and to write into its build's contract. */
|
|
427
396
|
export interface DeclaredAI {
|
|
428
397
|
tools: Map<string, BackendTool>;
|
|
429
398
|
/** The app's client tools: in its contract, answered by the app — never served here. */
|
|
430
399
|
clientTools: Map<string, ClientTool>;
|
|
431
400
|
agents: Map<string, BackendAgent>;
|
|
432
|
-
|
|
433
|
-
/** The tokens of a repository put by name at run time, which no ai.repo of this process names. */
|
|
434
|
-
repoTokens?: RepoTokens;
|
|
435
|
-
/** Names declared twice (tool:<name> — a backend tool's or a client tool's —, agent:<name>, repoTokens): the framework refuses to start with one, and to write its contract. */
|
|
401
|
+
/** Names declared twice (tool:<name> — a backend tool's or a client tool's —, agent:<name>): the framework refuses to start with one, and to write its contract. */
|
|
436
402
|
twice: Set<string>;
|
|
437
403
|
}
|
|
438
404
|
/**
|
|
@@ -457,30 +423,6 @@ export declare function shownAsWritten(label: unknown): label is string;
|
|
|
457
423
|
export declare function parametersOf(schema: StandardSchema | undefined, what: string): Record<string, unknown>;
|
|
458
424
|
export declare function backendTool<S extends StandardSchema>(o: BackendToolOptions<S>): BackendTool<S>;
|
|
459
425
|
export declare function clientTool<S extends StandardSchema>(o: ClientToolOptions<S>): ClientTool;
|
|
460
|
-
/**
|
|
461
|
-
* A repository a chat's workspace works in, whose tokens this backend gives:
|
|
462
|
-
* put it with ai.repos.put(repo), and each clone and each push of a chat's
|
|
463
|
-
* workspace asks this machine for a token then (token) — a GitHub App's
|
|
464
|
-
* installation token for that one repository, say — kept nowhere. Made once,
|
|
465
|
-
* at a module's top level.
|
|
466
|
-
*/
|
|
467
|
-
export declare function backendRepo(options: {
|
|
468
|
-
name: string;
|
|
469
|
-
repository: string;
|
|
470
|
-
defaultBranch?: string;
|
|
471
|
-
machine?: string;
|
|
472
|
-
token: (ctx: RepoTokenContext) => string | Promise<string>;
|
|
473
|
-
}): BackendRepo;
|
|
474
|
-
/**
|
|
475
|
-
* The tokens of the project's repositories put by name at run time
|
|
476
|
-
* (ai.repos.put(name, { repository, backend })) — one a product makes for
|
|
477
|
-
* itself — which no ai.repo of this backend names: each clone and each push
|
|
478
|
-
* of a chat's workspace asks this machine, and give answers with a token for
|
|
479
|
-
* that one operation, or null for a repository it gives none for (the
|
|
480
|
-
* workspace is refused it). An ai.repo of the name answers for its own
|
|
481
|
-
* repository first. Given once, at a module's top level.
|
|
482
|
-
*/
|
|
483
|
-
export declare function repoTokens(give: RepoTokens): void;
|
|
484
426
|
/** What an agent of the code says of itself beside its function: what it is for, and the machine that defines it. */
|
|
485
427
|
export interface BackendAgentOptions {
|
|
486
428
|
/** What it is for, in a sentence or two (1024 characters at most): its build's contract says it, and Studio shows it. */
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export interface PalbaseProviderOptions {
|
|
2
|
+
/** Base project URL (e.g. https://<ref>.palbase.studio); defaults to process.env.PALBASE_URL. */
|
|
3
|
+
url?: string;
|
|
4
|
+
/** Project secret key (pb_<ref>_s...); defaults to process.env.PALBASE_SECRET_KEY. */
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
/** Custom fetch implementation (useful for tests or edge runtimes). */
|
|
7
|
+
fetch?: typeof globalThis.fetch;
|
|
8
|
+
/** Extra headers appended to every gateway request. */
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export interface PalbaseModelSettings {
|
|
12
|
+
/** Routes into Palbase's single engine with persistent memory, compaction, and live Studio visibility. */
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
/** Runs a defined Palbase agent on the single engine. */
|
|
15
|
+
agent?: string;
|
|
16
|
+
/** End-user identifier for attribution and per-user budgets. */
|
|
17
|
+
userId?: string;
|
|
18
|
+
/** Binds an encrypted workspace to the stateful run. */
|
|
19
|
+
workspaceId?: string;
|
|
20
|
+
/** Ordered explicit fallback models used only before first byte on 429/5xx. */
|
|
21
|
+
fallbacks?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface PalbasePromptMessage {
|
|
24
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
25
|
+
content: string | Array<{
|
|
26
|
+
type: string;
|
|
27
|
+
text?: string;
|
|
28
|
+
toolCallId?: string;
|
|
29
|
+
toolName?: string;
|
|
30
|
+
input?: unknown;
|
|
31
|
+
output?: unknown;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export interface PalbaseLanguageCallOptions {
|
|
35
|
+
prompt: PalbasePromptMessage[];
|
|
36
|
+
maxOutputTokens?: number;
|
|
37
|
+
temperature?: number;
|
|
38
|
+
topP?: number;
|
|
39
|
+
tools?: Array<{
|
|
40
|
+
type: 'function';
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
inputSchema?: Record<string, unknown>;
|
|
44
|
+
}>;
|
|
45
|
+
abortSignal?: AbortSignal;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
export interface PalbaseGenerateResult {
|
|
49
|
+
content: Array<{
|
|
50
|
+
type: 'text';
|
|
51
|
+
text: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'tool-call';
|
|
54
|
+
toolCallId: string;
|
|
55
|
+
toolName: string;
|
|
56
|
+
input: string;
|
|
57
|
+
}>;
|
|
58
|
+
finishReason: 'stop' | 'length' | 'tool-calls' | 'error' | 'unknown';
|
|
59
|
+
usage: {
|
|
60
|
+
inputTokens: number;
|
|
61
|
+
outputTokens: number;
|
|
62
|
+
totalTokens: number;
|
|
63
|
+
};
|
|
64
|
+
warnings: unknown[];
|
|
65
|
+
}
|
|
66
|
+
export type PalbaseStreamPart = {
|
|
67
|
+
type: 'text-delta';
|
|
68
|
+
id: string;
|
|
69
|
+
delta: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'tool-call';
|
|
72
|
+
toolCallId: string;
|
|
73
|
+
toolName: string;
|
|
74
|
+
input: string;
|
|
75
|
+
} | {
|
|
76
|
+
type: 'finish';
|
|
77
|
+
finishReason: PalbaseGenerateResult['finishReason'];
|
|
78
|
+
usage: PalbaseGenerateResult['usage'];
|
|
79
|
+
} | {
|
|
80
|
+
type: 'error';
|
|
81
|
+
error: unknown;
|
|
82
|
+
};
|
|
83
|
+
export interface PalbaseLanguageModel {
|
|
84
|
+
readonly specificationVersion: 'v2';
|
|
85
|
+
readonly provider: 'palbase';
|
|
86
|
+
readonly modelId: string;
|
|
87
|
+
doGenerate(options: PalbaseLanguageCallOptions): Promise<PalbaseGenerateResult>;
|
|
88
|
+
doStream(options: PalbaseLanguageCallOptions): Promise<{
|
|
89
|
+
stream: ReadableStream<PalbaseStreamPart>;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
export interface PalbaseEmbeddingModel {
|
|
93
|
+
readonly specificationVersion: 'v2';
|
|
94
|
+
readonly provider: 'palbase';
|
|
95
|
+
readonly modelId: string;
|
|
96
|
+
readonly maxEmbeddingsPerCall: number;
|
|
97
|
+
doEmbed(options: {
|
|
98
|
+
values: string[];
|
|
99
|
+
abortSignal?: AbortSignal;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
embeddings: number[][];
|
|
102
|
+
usage: {
|
|
103
|
+
tokens: number;
|
|
104
|
+
};
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
export interface PalbaseImageModel {
|
|
108
|
+
readonly specificationVersion: 'v2';
|
|
109
|
+
readonly provider: 'palbase';
|
|
110
|
+
readonly modelId: string;
|
|
111
|
+
doGenerate(options: {
|
|
112
|
+
prompt: string;
|
|
113
|
+
n?: number;
|
|
114
|
+
size?: string;
|
|
115
|
+
abortSignal?: AbortSignal;
|
|
116
|
+
}): Promise<{
|
|
117
|
+
images: string[];
|
|
118
|
+
warnings: unknown[];
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
export interface PalbaseTranscriptionModel {
|
|
122
|
+
readonly specificationVersion: 'v1';
|
|
123
|
+
readonly provider: 'palbase';
|
|
124
|
+
readonly modelId: string;
|
|
125
|
+
doGenerate(options: {
|
|
126
|
+
audio: Uint8Array;
|
|
127
|
+
mediaType: string;
|
|
128
|
+
language?: string;
|
|
129
|
+
diarization?: boolean;
|
|
130
|
+
abortSignal?: AbortSignal;
|
|
131
|
+
}): Promise<{
|
|
132
|
+
text: string;
|
|
133
|
+
language?: string;
|
|
134
|
+
durationInSeconds?: number;
|
|
135
|
+
segments: Array<{
|
|
136
|
+
speaker?: string;
|
|
137
|
+
startSecond: number;
|
|
138
|
+
endSecond: number;
|
|
139
|
+
text: string;
|
|
140
|
+
}>;
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
143
|
+
export interface PalbaseSpeechModel {
|
|
144
|
+
readonly specificationVersion: 'v1';
|
|
145
|
+
readonly provider: 'palbase';
|
|
146
|
+
readonly modelId: string;
|
|
147
|
+
doGenerate(options: {
|
|
148
|
+
text: string;
|
|
149
|
+
voice?: string;
|
|
150
|
+
outputFormat?: string;
|
|
151
|
+
speed?: number;
|
|
152
|
+
abortSignal?: AbortSignal;
|
|
153
|
+
}): Promise<{
|
|
154
|
+
audio: Uint8Array;
|
|
155
|
+
mediaType: string;
|
|
156
|
+
}>;
|
|
157
|
+
}
|
|
158
|
+
export interface PalbaseProvider {
|
|
159
|
+
(modelId: string, settings?: PalbaseModelSettings): PalbaseLanguageModel;
|
|
160
|
+
languageModel(modelId: string, settings?: PalbaseModelSettings): PalbaseLanguageModel;
|
|
161
|
+
textEmbeddingModel(modelId: string): PalbaseEmbeddingModel;
|
|
162
|
+
image(modelId: string): PalbaseImageModel;
|
|
163
|
+
transcription(modelId: string): PalbaseTranscriptionModel;
|
|
164
|
+
speech(modelId: string): PalbaseSpeechModel;
|
|
165
|
+
}
|
|
166
|
+
export declare function createPalbase(options?: PalbaseProviderOptions): PalbaseProvider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AttestedDevice as AttestedDeviceOf } from './attest.js';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import type { EventType, PalbaseEvent } from '../../server/src/index.js';
|
|
4
|
+
import type { PalbaseBucketOption } from './stack.js';
|
|
4
5
|
import type { UserT } from './engine.js';
|
|
5
6
|
import type { UploadConfig } from './upload.js';
|
|
6
7
|
/** A validator the framework runs: any Standard Schema (zod, valibot, arktype, …). */
|
|
@@ -205,7 +206,7 @@ export interface OnOptions {
|
|
|
205
206
|
* the machine when no handler of their type takes every bucket. Left out,
|
|
206
207
|
* every bucket's.
|
|
207
208
|
*/
|
|
208
|
-
bucket?:
|
|
209
|
+
bucket?: PalbaseBucketOption;
|
|
209
210
|
}
|
|
210
211
|
/** One @On: the event it takes, its method, and the bucket a storage event's is kept to. */
|
|
211
212
|
export interface EventDeclaration {
|
|
@@ -206,7 +206,7 @@ export interface PalbaseClearAllOverridesResult {
|
|
|
206
206
|
}
|
|
207
207
|
export interface PalbaseBatchOverrideOperation {
|
|
208
208
|
userId: string;
|
|
209
|
-
values: Record<
|
|
209
|
+
values: Partial<Record<PalbaseFlagKey, PalbaseFlagValue>>;
|
|
210
210
|
}
|
|
211
211
|
export interface PalbaseBatchSetOverridesResult {
|
|
212
212
|
applied: number;
|
|
@@ -214,7 +214,7 @@ export interface PalbaseBatchSetOverridesResult {
|
|
|
214
214
|
/** Any user's values, by id — the writes of a service, not of the user it serves. */
|
|
215
215
|
export interface PalbaseFlagsServiceClient {
|
|
216
216
|
setOverrideForUser(userId: string, key: PalbaseFlagKey, value: PalbaseFlagValue): Answer<PalbaseSetOverrideResult>;
|
|
217
|
-
setOverridesForUser(userId: string, values: Record<
|
|
217
|
+
setOverridesForUser(userId: string, values: Partial<Record<PalbaseFlagKey, PalbaseFlagValue>>): Answer<PalbaseSetOverridesResult>;
|
|
218
218
|
clearOverrideForUser(userId: string, key: PalbaseFlagKey): Answer<PalbaseClearOverrideResult>;
|
|
219
219
|
clearAllOverridesForUser(userId: string): Answer<PalbaseClearAllOverridesResult>;
|
|
220
220
|
/** 1000 operations at most. */
|
|
@@ -11,10 +11,8 @@ export interface BucketTypes {
|
|
|
11
11
|
/** The project's buckets, by name, each with its renditions. */
|
|
12
12
|
export interface Buckets {
|
|
13
13
|
}
|
|
14
|
-
/** The project's roles, by name. */
|
|
15
|
-
export interface Roles {
|
|
16
|
-
}
|
|
17
14
|
export type PalbaseSecretName = keyof Secrets & string;
|
|
18
15
|
export type PalbaseFlagKey = keyof Flags & string;
|
|
19
16
|
export type PalbaseBucketName = keyof Buckets & string;
|
|
20
|
-
|
|
17
|
+
/** Strict bucket union when `palbase types:pull` has populated `Buckets`, else `string`. */
|
|
18
|
+
export type PalbaseBucketOption = [PalbaseBucketName] extends [never] ? string : PalbaseBucketName;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type RouteOptions } from './decorators.js';
|
|
2
2
|
import type { Route } from './router.js';
|
|
3
3
|
import { type SignedUser } from './platform-calls.js';
|
|
4
|
+
import type { PalbaseBucketOption } from './stack.js';
|
|
4
5
|
/** Where an @Upload route's files go. */
|
|
5
6
|
export interface UploadConfig {
|
|
6
7
|
/**
|
|
@@ -9,7 +10,7 @@ export interface UploadConfig {
|
|
|
9
10
|
* its renditions — are the bucket's, and storage holds every upload to them
|
|
10
11
|
* as it writes: the one check a client cannot step around.
|
|
11
12
|
*/
|
|
12
|
-
bucket:
|
|
13
|
+
bucket: PalbaseBucketOption;
|
|
13
14
|
/**
|
|
14
15
|
* The object's path, made here for each upload — the client never chooses
|
|
15
16
|
* it. `{userId}` is the signed-in user's id ("anonymous" for nobody),
|
|
@@ -2,7 +2,7 @@ import * as modules from '../../../internal/src/modules/index.js';
|
|
|
2
2
|
import type { Transport } from '../../../internal/src/transport.js';
|
|
3
3
|
/** A project's environment as an access token reaches it: each module's operations under the paths the edge opens to one, a server's calls. */
|
|
4
4
|
export interface Project {
|
|
5
|
-
ai: Pick<modules.ai.Client, "draftAgent" | "listAgents" | "getAgent" | "putAgent" | "deleteAgent" | "publishAgent" | "rollbackAgent" | "listAgentVersions" | "listChats" | "createChat" | "getChat" | "deleteChat" | "decideChatApproval" | "forkChat" | "getChatGoal" | "setChatGoal" | "clearChatGoal" | "updateChatGoal" | "putChatMember" | "deleteChatMember" | "listChatMessages" | "sendChatMessage" | "getChatMessageAttachment" | "listChatParts" | "putChatPipe" | "deleteChatPipe" | "sendSubagentMessage" | "stopSubagent" | "stopChat" | "listTurnToolCalls" | "getChatToolCall" | "answerChatToolCall" | "listChatTurnArtifacts" | "getChatTurnArtifact" | "getChatTurnCost" | "startChatVoice" | "getChatVoice" | "closeChatVoice" | "commandChatVoice" | "
|
|
5
|
+
ai: Pick<modules.ai.Client, "draftAgent" | "listAgents" | "getAgent" | "putAgent" | "deleteAgent" | "publishAgent" | "rollbackAgent" | "listAgentVersions" | "createAudioSpeech" | "createAudioTranscription" | "listChats" | "createChat" | "getChat" | "deleteChat" | "decideChatApproval" | "getChatExecution" | "patchChatExecution" | "forkChat" | "getChatGoal" | "setChatGoal" | "clearChatGoal" | "updateChatGoal" | "handoffChat" | "putChatMember" | "deleteChatMember" | "listChatMessages" | "sendChatMessage" | "getChatMessageAttachment" | "listChatParts" | "putChatPipe" | "deleteChatPipe" | "sendSubagentMessage" | "stopSubagent" | "stopChat" | "listTurnToolCalls" | "getChatToolCall" | "answerChatToolCall" | "listChatTurnArtifacts" | "getChatTurnArtifact" | "getChatTurnCost" | "startChatVoice" | "getChatVoice" | "closeChatVoice" | "commandChatVoice" | "createEmbeddings" | "listEndpoints" | "putEndpoint" | "deleteEndpoint" | "listEnv" | "listEnvAllowances" | "deleteEnvAllowance" | "listEnvHostRequests" | "allowEnvHostRequest" | "dismissEnvHostRequest" | "putEnv" | "deleteEnv" | "allowEnvHost" | "listEnvironments" | "createEnvironment" | "getEnvironment" | "putEnvironment" | "deleteEnvironment" | "createEnvironmentBuild" | "getEnvironmentBuild" | "createImage" | "getImage" | "getImageFile" | "deleteMachine" | "cordonMachine" | "resumeMachine" | "listModels" | "revokePoolKey" | "listPools" | "createPool" | "deletePool" | "listPoolKeys" | "createPoolKey" | "getPoolState" | "listProviders" | "connectProvider" | "disconnectProvider" | "createResponse" | "getResponse" | "cancelResponse" | "followResponse" | "getSettings" | "putSettings" | "getSpend" | "askSupport" | "listTools" | "listUsage" | "gatewayAudioSpeech" | "gatewayAudioTranscriptions" | "gatewayChatCompletions" | "gatewayEmbeddings" | "gatewayImagesGenerations" | "gatewayAnthropicMessages" | "gatewayListModels" | "gatewayResponses" | "createVideo" | "getVideo" | "cancelVideo">;
|
|
6
6
|
analytics: Pick<modules.analytics.Client, "listAudiences" | "createAudience" | "previewAudience" | "getAudience" | "deleteAudience" | "updateAudience" | "listAudienceMembers" | "alias" | "batch" | "getEventBreakdown" | "capture" | "sendConsoleHistory" | "getConsoleConfig" | "listConsoleRecords" | "listEventNames" | "listEvents" | "getEventTimeline" | "runFunnel" | "identify" | "page" | "sendPerf" | "listPerfGroups" | "getPerfConfig" | "getPerfTimeline" | "listRequestLines" | "getMachineTraffic" | "runRetention" | "screen" | "getSettings" | "putSettings" | "getSummary" | "listTraces" | "sendTrace" | "sendTraceBatch" | "getTraceHops" | "listSessionTraces" | "getTraceSummary" | "getTraceTimeline" | "searchPeople" | "setPersonProperties" | "getPerson" | "listPersonEvents" | "getEventCatalog" | "defineEvent">;
|
|
7
7
|
auth: Pick<modules.auth.Client, "adminVerifyDeviceAssertion" | "adminGetAttestPolicy" | "adminGetAttestObservations" | "adminRecordAttestObservations" | "adminListAuditEvents" | "adminExportAuditEvents" | "adminVerifyAuditTrail" | "adminGetAuthSettings" | "adminUpdateAuthSettings" | "adminGetBreachWatch" | "adminListHooks" | "adminCreateHook" | "adminUpdateHook" | "adminDeleteHook" | "adminListHookExecutions" | "adminListIntegrations" | "adminPutIntegration" | "adminDeleteIntegration" | "adminListOAuthClients" | "adminCreateOAuthClient" | "adminGetOAuthClient" | "adminDeleteOAuthClient" | "adminUpdateOAuthClient" | "adminListProviders" | "adminGetPhoneSettings" | "adminUpdatePhoneSettings" | "adminToggleProvider" | "adminListRoles" | "adminUpsertRole" | "adminDeleteRole" | "adminListServiceAccounts" | "adminCreateServiceAccount" | "adminGetServiceAccount" | "adminRevokeServiceAccount" | "adminRotateServiceAccount" | "adminListSessions" | "adminRevokeSession" | "adminListSigningKeys" | "adminRotateSigningKey" | "socialAdminConfig" | "socialCredentialPut" | "socialCredentialDelete" | "socialProviderPatch" | "adminGetStats" | "adminSendTestTemplate" | "adminListTestUsers" | "adminCreateTestUsers" | "adminSetTestUserPhone" | "adminCreateTestSignupAddress" | "adminDeleteTestUser" | "adminCreateCustomToken" | "adminListUsers" | "adminCreateUser" | "adminImportUsers" | "adminGetUser" | "adminDeleteUser" | "adminUpdateUser" | "adminBanUser" | "adminGetUserConsents" | "adminRevokeUserCredentials" | "adminExportUser" | "adminListUserMfaFactors" | "adminResetUserMfa" | "adminResetUserPassword" | "adminListUserRoles" | "adminAssignUserRole" | "adminRevokeUserRole" | "adminRevokeUserSessions" | "adminUnbanUser" | "adminGetInstallationConsents" | "adminRefuseConsents" | "adminInviteUser">;
|
|
8
8
|
calls: Pick<modules.calls.Client, "adminListCalls" | "adminGetCall" | "adminEndCall" | "createCallTicket" | "getCallSettings" | "putCallSettings" | "rotateCallHookSecret">;
|
|
@@ -16,5 +16,6 @@ export interface Project {
|
|
|
16
16
|
secrets: Pick<modules.secrets.Client, "listSecretAudit" | "listFieldKeys" | "getFieldKeys" | "openFields" | "sealPlaceholder" | "rotateFieldKeys" | "listTransitKeys" | "getTransitKeys" | "getTransitPublicKeys" | "rotateTransitKeys" | "retireTransitKey" | "listSecrets" | "getEnvironmentValues" | "getSecret" | "putSecret" | "deleteSecret" | "rollbackSecret" | "listSecretVersions">;
|
|
17
17
|
storage: Pick<modules.storage.Client, "listBuckets" | "getBucket" | "putBucket" | "deleteBucket" | "copyObject" | "moveObject" | "listObjects" | "getObject" | "putObject" | "deleteObject" | "headObject" | "createSignedUrl" | "createUploadUrl" | "getStorageStats">;
|
|
18
18
|
stores: Pick<modules.stores.Client, "listActions" | "getAction" | "confirmAction" | "declineAction" | "getAppleAccount" | "disconnectApple" | "checkAppleAccount" | "createAppleGrant" | "getSandboxReadiness" | "listSandboxTesters" | "clearSandboxPurchaseHistory" | "updateSandboxTester" | "listApps" | "listFeedback" | "getFeedback" | "listGroups" | "createGroup" | "linkApp" | "getListing" | "setListing" | "planListing" | "createPackage" | "uploadScreenshot" | "getReviewInfo" | "setReviewInfo" | "getUploadKey" | "getAppStoreVersion" | "prepareAppStoreVersion" | "planPhasedRelease" | "planReleaseVersion" | "planSubmitReview" | "planWithdrawReview" | "getAppVitals" | "getAppWebhook" | "makeAppWebhook" | "pingAppWebhook" | "getGoogleAccount" | "connectGoogle" | "disconnectGoogle" | "checkGoogleAccount" | "deleteGroup" | "renameGroup" | "addGroupBuild" | "listTesters" | "setTesters" | "listPackages" | "getPackage" | "planBetaReview" | "listDeliveries" | "deliver" | "getSignedBundleLink" | "planExpire" | "planExportCompliance" | "setWhatToTest" | "getAppleSession" | "disconnectAppleSession" | "checkAppleSession" | "createAppleIdGrant" | "getAppReview" | "getReviewAttachment" | "setReviewDraft" | "sendReviewDraft" | "getAppPrivacy" | "setAppPrivacy" | "makeAppRecord" | "removeAppRecord" | "listMadeAppleKeys" | "makeAppleKey" | "revokeMadeAppleKey" | "shareAppleSession" | "unshareAppleSession" | "listInvitations" | "invitePerson" | "revokeInvitation" | "listDevices">;
|
|
19
|
+
workspaces: Pick<modules.workspaces.Client, "listWorkspaces" | "createWorkspace" | "testWorkspaceByos" | "listProjectS3Keys" | "createProjectS3Key" | "deleteProjectS3Key" | "getWorkspace" | "deleteWorkspace" | "updateWorkspaceStorage" | "getWorkspaceFiles" | "putWorkspaceFile" | "deleteWorkspaceFile" | "listWorkspaceTokens" | "createWorkspaceToken" | "deleteWorkspaceToken" | "listWorkspaceLocks" | "acquireWorkspaceLock" | "releaseWorkspaceLock">;
|
|
19
20
|
}
|
|
20
21
|
export declare function project(t: Transport): Project;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatMessage, MessageAttachment } from './modules/ai.js';
|
|
1
|
+
import type { ChatMessage, ExecutionTarget, MessageAttachment, TargetSummary } from './modules/ai.js';
|
|
2
2
|
export type TurnStatus = 'running' | 'waiting' | 'completed' | 'failed' | 'canceled' | 'timed_out' | 'budget_exceeded';
|
|
3
3
|
export type WaitingReason = 'approval' | 'tool_output' | 'subagents' | 'message';
|
|
4
4
|
export type ToolStatus = 'running' | 'awaiting_output' | 'awaiting_approval' | 'approved' | 'denied' | 'expired' | 'completed' | 'failed' | 'canceled';
|
|
@@ -253,7 +253,59 @@ export interface TranscriptEvent {
|
|
|
253
253
|
final: boolean;
|
|
254
254
|
created_at: string;
|
|
255
255
|
}
|
|
256
|
-
|
|
256
|
+
/** A session teleported to a new compute or executor target: generation advanced atomically. */
|
|
257
|
+
export interface SessionHandedOffEvent {
|
|
258
|
+
type: 'session.handed_off';
|
|
259
|
+
seq: number;
|
|
260
|
+
chat_id: string;
|
|
261
|
+
generation: number;
|
|
262
|
+
from_target?: ExecutionTarget;
|
|
263
|
+
to_target: ExecutionTarget;
|
|
264
|
+
reason: string;
|
|
265
|
+
workspace_seq: number;
|
|
266
|
+
}
|
|
267
|
+
/** A target machine went online, offline, or waking — with failover_at when auto-failover is counting down. */
|
|
268
|
+
export interface SessionMachineStatusEvent {
|
|
269
|
+
type: 'session.machine_status';
|
|
270
|
+
seq: number;
|
|
271
|
+
chat_id: string;
|
|
272
|
+
machine_id: string;
|
|
273
|
+
status: 'online' | 'offline' | 'waking' | (string & {});
|
|
274
|
+
failover_at?: string | null;
|
|
275
|
+
}
|
|
276
|
+
/** Tier 1 compaction offloaded a bulky tool output to workspace/artifact storage and replaced it with a compact stub. */
|
|
277
|
+
export interface ContextOffloadedEvent {
|
|
278
|
+
type: 'context.offloaded';
|
|
279
|
+
seq: number;
|
|
280
|
+
call_id: string;
|
|
281
|
+
storage?: string;
|
|
282
|
+
ref?: string;
|
|
283
|
+
original_bytes?: number;
|
|
284
|
+
stub_bytes?: number;
|
|
285
|
+
}
|
|
286
|
+
/** Tier 3 compaction anchored earlier history into a structured summary while preserving project directives and attachments. */
|
|
287
|
+
export interface ContextCompactedEvent {
|
|
288
|
+
type: 'context.compacted';
|
|
289
|
+
seq: number;
|
|
290
|
+
format?: string;
|
|
291
|
+
messages_compacted?: number;
|
|
292
|
+
tokens_before?: number;
|
|
293
|
+
tokens_after?: number;
|
|
294
|
+
preserved_attachments_count?: number;
|
|
295
|
+
project_directives_count?: number;
|
|
296
|
+
cache_friendly?: boolean;
|
|
297
|
+
}
|
|
298
|
+
/** Live sidebar update broadcast on ai:sessions and ai:sessions:<user_id> (event: session.summary.v1). */
|
|
299
|
+
export interface SessionSummaryEvent {
|
|
300
|
+
chat_id: string;
|
|
301
|
+
run_status: 'idle' | 'running' | 'awaiting_approval' | 'awaiting_tool' | 'offline_parked' | (string & {});
|
|
302
|
+
active_run_id?: string;
|
|
303
|
+
workspace_id?: string;
|
|
304
|
+
target_generation: number;
|
|
305
|
+
target_summary: TargetSummary;
|
|
306
|
+
updated_at: string;
|
|
307
|
+
}
|
|
308
|
+
export type ChatEvent = MessageEvent | TurnEvent | TextEvent | ResetEvent | ThinkingEvent | ToolEvent | AgentEvent | GoalEvent | HistoryEvent | VoiceEvent | TranscriptEvent | SessionHandedOffEvent | SessionMachineStatusEvent | ContextOffloadedEvent | ContextCompactedEvent;
|
|
257
309
|
/** A chat refusal of the module's, said in words its caller can act on; anything else (or one said already) as it was. */
|
|
258
310
|
export declare function chatRefusal(e: unknown): unknown;
|
|
259
311
|
/** The same promise, its chat refusals said as chatRefusal says them. */
|
|
@@ -264,3 +316,5 @@ export declare function told<T>(p: Promise<T>): Promise<T>;
|
|
|
264
316
|
* part, or one that is not a part at all.
|
|
265
317
|
*/
|
|
266
318
|
export declare function chatPart(payload: unknown): ChatEvent | undefined;
|
|
319
|
+
/** Decodes one `session.summary.v1` payload broadcast on `ai:sessions` or `ai:sessions:<user_id>`. */
|
|
320
|
+
export declare function sessionSummary(payload: unknown): SessionSummaryEvent | undefined;
|