palbase 0.65.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.
Files changed (72) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai-sdk/index.js +4 -0
  3. package/dist/backend/engine.js +2 -2
  4. package/dist/backend/env.js +1 -1
  5. package/dist/backend/index.js +3 -3
  6. package/dist/backend/stack.js +1 -1
  7. package/dist/backend/test.js +2 -2
  8. package/dist/chunks/{G2JBUBZO.js → 243727GR.js} +2 -2
  9. package/dist/chunks/{DLMWZYLL.js → 2DGYQO2K.js} +2 -2
  10. package/dist/chunks/{X6JMSZBD.js → 47OT2TAE.js} +2 -2
  11. package/dist/chunks/{ARRJICH3.js → 4DOKNJUJ.js} +2 -2
  12. package/dist/chunks/{TEF7WS37.js → 7JAVCOPA.js} +1 -1
  13. package/dist/chunks/{6GRY63N6.js → FFRCUMXB.js} +2 -2
  14. package/dist/chunks/GS7AQ2KQ.js +2 -0
  15. package/dist/chunks/GVC6OZMF.js +13 -0
  16. package/dist/chunks/{CZGZTOK7.js → GYB7XBYV.js} +2 -2
  17. package/dist/chunks/{ZF3WKPVM.js → HECZUS65.js} +2 -2
  18. package/dist/chunks/{CTWUVLVE.js → L5DVXXH3.js} +1 -1
  19. package/dist/chunks/{4NHRUBEF.js → MTOW4UUP.js} +2 -2
  20. package/dist/chunks/PQ23MXWT.js +18 -0
  21. package/dist/chunks/{JHM7GTPD.js → PZXACOXA.js} +1 -1
  22. package/dist/chunks/{KZZ3Y3DC.js → QKAKVJLA.js} +1 -1
  23. package/dist/chunks/{5HMDOBEH.js → QT7PHIRR.js} +2 -2
  24. package/dist/chunks/{DFX37NU3.js → REON7CA7.js} +1 -1
  25. package/dist/chunks/UZERPL37.js +2 -0
  26. package/dist/chunks/V7X2RHTR.js +21 -0
  27. package/dist/chunks/{YP3QTS4L.js → YO7F2OI2.js} +1 -1
  28. package/dist/chunks/ZA5NYGQH.js +22 -0
  29. package/dist/chunks/{XSOQNHZ5.js → ZV6WG4DE.js} +1 -1
  30. package/dist/chunks/{ZZRRJOEP.js → ZY6P5WKM.js} +2 -2
  31. package/dist/cli.js +356 -371
  32. package/dist/cloud/index.js +2 -2
  33. package/dist/refuse/ai-sdk.js +2 -0
  34. package/dist/refuse/ai.js +1 -1
  35. package/dist/refuse/backend.js +1 -1
  36. package/dist/refuse/cloud.js +1 -1
  37. package/dist/refuse/server.js +1 -1
  38. package/dist/server/index.js +2 -2
  39. package/dist/server/testing.js +2 -2
  40. package/dist/web/index.js +2 -2
  41. package/dist/web/message.js +2 -2
  42. package/dist/web/palbe.js +2 -2
  43. package/dist/web/paywall.js +2 -2
  44. package/dist/web/push-sw.js +1 -1
  45. package/dist/web/ssr.js +2 -2
  46. package/dist/web/vite.js +4 -3
  47. package/package.json +14 -2
  48. package/types/ai/src/ai.d.ts +55 -29
  49. package/types/ai/src/chats.d.ts +163 -171
  50. package/types/ai/src/index.d.ts +5 -5
  51. package/types/ai/src/pools.d.ts +17 -7
  52. package/types/ai/src/tools.d.ts +6 -64
  53. package/types/ai-sdk/src/index.d.ts +166 -0
  54. package/types/backend/src/decorators.d.ts +2 -1
  55. package/types/backend/src/services.d.ts +2 -2
  56. package/types/backend/src/stack.d.ts +2 -4
  57. package/types/backend/src/upload.d.ts +2 -1
  58. package/types/cloud/src/generated/project.d.ts +1 -1
  59. package/types/internal/src/chat.d.ts +56 -2
  60. package/types/internal/src/modules/ai.d.ts +938 -1132
  61. package/types/internal/src/modules/events.d.ts +2 -2
  62. package/types/internal/src/modules/workspaces.d.ts +22 -0
  63. package/types/web/src/chat.d.ts +30 -4
  64. package/types/web/src/client.d.ts +7 -7
  65. package/types/web/src/index.d.ts +2 -1
  66. package/types/web/src/vite.d.ts +8 -0
  67. package/dist/chunks/2HJQSGOO.js +0 -13
  68. package/dist/chunks/3TXOVBZP.js +0 -22
  69. package/dist/chunks/63TUW6P7.js +0 -18
  70. package/dist/chunks/BYXX373R.js +0 -21
  71. package/dist/chunks/GFG7WVN2.js +0 -2
  72. package/dist/chunks/KU6B2OXP.js +0 -2
@@ -3,9 +3,9 @@ import { type RetryPolicy } from '../../internal/src/retry.js';
3
3
  import * as modules from '../../internal/src/modules/index.js';
4
4
  import { type Infer, type PreparedSchema, type StandardSchema } from './schema.js';
5
5
  import type { ToolResult } from '../../internal/src/tool-output.js';
6
- import { type Agents, type Chats, type Endpoints, type Repos, type Settings } from './chats.js';
6
+ import { type Agents, type Chats, type Endpoints, type Environments, type Settings } from './chats.js';
7
7
  import { type EnvVariables, type PoolMachines, type Pools } from './pools.js';
8
- import { type AgentContext, type BackendAgent, type BackendAgentOptions, type BackendRepo, type BackendTool, type BackendToolOptions, type DeferredAnswer, type ToolReply, type WorkspaceTree, type RepoTokenContext, type RepoTokens, type ClientTool, type ClientToolOptions, type HttpsToolRef, type McpToolRef, type TurnDefinition } from './tools.js';
8
+ import { type AgentContext, type BackendAgent, type BackendAgentOptions, type BackendTool, type BackendToolOptions, type DeferredAnswer, type ToolReply, type WorkspaceTree, type ClientTool, type ClientToolOptions, type HttpsToolRef, type McpToolRef, type TurnDefinition } from './tools.js';
9
9
  type Module = ReturnType<typeof modules.ai.client>;
10
10
  export type Response = Awaited<ReturnType<Module['getResponse']>>['data'];
11
11
  export type Usage = Awaited<ReturnType<Module['listUsage']>>['data']['usage'][number];
@@ -15,10 +15,51 @@ export type Usage = Awaited<ReturnType<Module['listUsage']>>['data']['usage'][nu
15
15
  * project now — and if not, why (reason).
16
16
  */
17
17
  export type Spend = modules.ai.Spend;
18
- /** What the project may name (ai.models()): its text, embedding and image models, the default and a deprecated one marked. */
18
+ /** What the project may name (ai.models()): its text, embedding, image, video, speech-to-text and text-to-speech models, the default and a deprecated one marked. */
19
19
  export type Models = modules.ai.Models;
20
20
  /** A text model a turn may name, as the engine's catalogue says it (ai.models().chat): `name` is what a call names it by. */
21
21
  export type ChatModel = modules.ai.ChatModel;
22
+ /** Every usage modality tracked in the unified AI ledger. */
23
+ export type UsageKind = 'text' | 'embedding' | 'image' | 'video' | 'stt' | 'tts' | 'voice' | 'web_search' | 'machine';
24
+ export type VideoRequest = modules.ai.VideoRequest;
25
+ export type VideoJob = modules.ai.VideoJob;
26
+ export type VideoCancelResult = modules.ai.VideoCancelResult;
27
+ export type TranscriptionRequest = modules.ai.TranscriptionRequest;
28
+ export type TranscriptionResponse = modules.ai.TranscriptionResponse;
29
+ export type TranscriptionSegment = modules.ai.TranscriptionSegment;
30
+ export type SpeechRequest = modules.ai.SpeechRequest;
31
+ export interface SpeechAudio {
32
+ mediaType: string;
33
+ bytes: Uint8Array;
34
+ }
35
+ export interface Videos {
36
+ /** Starts a durable asynchronous video generation job (Google Veo, Kling). */
37
+ create(request: VideoRequest, options?: {
38
+ signal?: AbortSignal;
39
+ }): Promise<VideoJob>;
40
+ /** Reads a video job's status, storage location, output URL, and settled cost. */
41
+ get(id: string, options?: {
42
+ signal?: AbortSignal;
43
+ }): Promise<VideoJob>;
44
+ /** Cancels a queued or running video job. */
45
+ cancel(id: string, options?: {
46
+ signal?: AbortSignal;
47
+ }): Promise<VideoCancelResult>;
48
+ }
49
+ export interface Audio {
50
+ /** Transcribes a stored audio file via OpenAI or Deepgram with optional timestamps and diarization. */
51
+ transcribe(request: TranscriptionRequest, options?: {
52
+ signal?: AbortSignal;
53
+ }): Promise<TranscriptionResponse>;
54
+ /** Synthesizes speech via OpenAI or ElevenLabs, returning the complete audio bytes and media type. */
55
+ speak(request: SpeechRequest, options?: {
56
+ signal?: AbortSignal;
57
+ }): Promise<SpeechAudio>;
58
+ /** Synthesizes speech and returns the raw streaming HTTP Response for low-latency forwarding. */
59
+ speakStream(request: SpeechRequest, options?: {
60
+ signal?: AbortSignal;
61
+ }): Promise<globalThis.Response>;
62
+ }
22
63
  export interface AIOptions {
23
64
  /** The project's address (https://<ref>.<domain>); default PALBASE_URL. */
24
65
  url?: string;
@@ -225,10 +266,14 @@ export interface AI {
225
266
  embed(text: string, options?: Embed): Promise<number[]>;
226
267
  /** Pictures for a prompt: waits for the job (it takes the provider up to minutes). */
227
268
  image(request: ImageRequest): Promise<Images>;
269
+ /** Durable asynchronous video generation jobs (Google Veo, Kling). */
270
+ readonly videos: Videos;
271
+ /** Audio transcription (STT via OpenAI, Deepgram) and speech synthesis (TTS via OpenAI, ElevenLabs). */
272
+ readonly audio: Audio;
228
273
  /**
229
274
  * What the project may name: every text model a turn may name (chat: an agent's, a response's) with the efforts it
230
275
  * takes, its window, its token limits and its price — the default, and a deprecated one marked with what to name
231
- * instead: what a model picker offers a person —, and the embedding and picture models. unavailable: the providers
276
+ * instead: what a model picker offers a person —, and the embedding, image, video, transcription and speech models. unavailable: the providers
232
277
  * whose models could not be listed just now. Each model's `name` is what a call names it by.
233
278
  */
234
279
  models(): Promise<Models>;
@@ -239,7 +284,7 @@ export interface AI {
239
284
  * a reasoning call cut before its answer, whose hidden thinking its provider never counted.
240
285
  */
241
286
  usage(options?: {
242
- kind?: 'text' | 'embedding' | 'image';
287
+ kind?: UsageKind;
243
288
  metadata?: Record<string, string>;
244
289
  limit?: number;
245
290
  cursor?: string;
@@ -291,8 +336,8 @@ export interface AI {
291
336
  expiresInSeconds?: number;
292
337
  }): DeferredAnswer;
293
338
  /**
294
- * What a backend tool's run returns when it wrote the chat's workspace (chats.workspace.write): its output, and the
295
- * tree its writes left (what the write answered) — the session's machine takes it before the agent's next command,
339
+ * What a backend tool's run returns when it wrote the chat's workspace: its output, and the
340
+ * tree its writes left — the session's machine takes it before the agent's next command,
296
341
  * so the agent sees what the tool wrote. A tool that wrote and then failed says it with new ToolError(message, {
297
342
  * workspaceTree }).
298
343
  */
@@ -307,29 +352,10 @@ export interface AI {
307
352
  * Made once, at a module's top level.
308
353
  */
309
354
  agent(name: string, define: (ctx: AgentContext) => TurnDefinition | Promise<TurnDefinition>, options?: BackendAgentOptions): BackendAgent;
355
+ /** First-class runtime environments (`ephemeral` or `always_on`) and their pre-bake builds. */
356
+ readonly environments: Environments;
310
357
  /**
311
- * A GitHub repository a chat's workspace works in, whose tokens this
312
- * backend gives (token, asked at each clone and each push): put it with
313
- * ai.repos.put(repo). Made once, at a module's top level.
314
- */
315
- repo(options: {
316
- name: string;
317
- repository: string;
318
- defaultBranch?: string;
319
- machine?: string;
320
- token: (ctx: RepoTokenContext) => string | Promise<string>;
321
- }): BackendRepo;
322
- /**
323
- * The tokens of the repositories put by name at run time (ai.repos.put(name, { repository, backend })) — one a
324
- * product makes for itself — that no ai.repo of this backend names: each clone and push of a chat's workspace asks
325
- * this machine, and give answers with a token for that one operation, or null for one it gives none for. Given
326
- * once, at a module's top level; an ai.repo answers for its own repository first.
327
- */
328
- repoTokens(give: RepoTokens): void;
329
- /** The project's repositories a chat's workspace works in (chats.create({ workspace })). */
330
- readonly repos: Repos;
331
- /**
332
- * The project's own runner pools — machines of its own, a Mac or a Linux box, enrolled with palai and a single-use
358
+ * The project's own runner pools — machines of its own, a Mac or a Linux box, enrolled with palbase-agent and a single-use
333
359
  * key — that a chat's workspace runs on (chats.create({ pool })), read as its scaling loop reads them (state).
334
360
  */
335
361
  readonly pools: Pools;
@@ -1,6 +1,7 @@
1
1
  import type * as modules from '../../internal/src/modules/index.js';
2
2
  import { type ToolResult } from '../../internal/src/tool-output.js';
3
- import { type AgentDefinitionInput, type BackendAgent, type BackendRepo, type WorkspaceTree } from './tools.js';
3
+ import { type MachineHarness } from './pools.js';
4
+ import { type AgentDefinitionInput, type BackendAgent, type WorkspaceTree } from './tools.js';
4
5
  type Module = ReturnType<typeof modules.ai.client>;
5
6
  export type Chat = modules.ai.Chat;
6
7
  export type ChatMessage = modules.ai.ChatMessage;
@@ -47,6 +48,103 @@ export interface AISettings {
47
48
  * person_required).
48
49
  */
49
50
  openSecretsForAppUsers: boolean;
51
+ /**
52
+ * Whether signed-in app users may trigger session handoffs (`POST /ai/chats/{chat_id}/handoff`) directly. Off by
53
+ * default (server-only). Enabling it is a person's alone (403 person_required for keys/tokens).
54
+ */
55
+ allowClientHandoff: boolean;
56
+ /**
57
+ * Whether newly created chats automatically attach a Realtime pipe (`chat:<chat_id>`) unless `live: false` is passed.
58
+ */
59
+ autoPipeChats: boolean;
60
+ }
61
+ /** Where a portable chat session executes (orthogonal to ExecutorTarget). */
62
+ export interface ComputeTarget {
63
+ kind: 'serverless' | 'cloud' | 'pool' | 'machine';
64
+ /** Runner pool id or name when kind is `pool` or `machine`. */
65
+ poolId?: string;
66
+ /** Specific enrolled runner machine id when kind is `machine`. */
67
+ machineId?: string;
68
+ /** Optional hosted cloud environment profile name when kind is `cloud`. */
69
+ environment?: string;
70
+ }
71
+ /** Which runtime executes turns on the chosen compute target. */
72
+ export interface ExecutorTarget {
73
+ kind: 'palbase' | 'acp';
74
+ /** Official local ACP CLI harness when kind is `acp`. */
75
+ harness?: 'claude-code' | 'codex' | 'gemini-cli';
76
+ /** Optional default model override. */
77
+ model?: string;
78
+ /** Optional default reasoning effort override. */
79
+ effort?: string;
80
+ }
81
+ /** Two-axis portable session execution target (compute + executor). */
82
+ export interface ExecutionTarget {
83
+ compute: ComputeTarget;
84
+ executor: ExecutorTarget;
85
+ }
86
+ /** Opt-in automatic failover policy when a targeted machine stays offline. */
87
+ export interface AutoFailoverPolicy {
88
+ afterOfflineSeconds: number;
89
+ to: ExecutionTarget;
90
+ requireWorkspaceCleanBeforeCut?: boolean;
91
+ }
92
+ /** A handoff queued to take effect after the current active turn finishes. */
93
+ export interface PendingHandoff {
94
+ to: ExecutionTarget;
95
+ reason: string;
96
+ idempotencyKey?: string;
97
+ requestedAt: string;
98
+ }
99
+ /** Compact target badge returned on chats and live `session.summary.v1` broadcasts. */
100
+ export interface TargetSummary {
101
+ compute: 'mac' | 'cloud' | 'linux' | 'serverless' | (string & {});
102
+ machineId?: string;
103
+ machineName?: string;
104
+ machineOnline?: boolean;
105
+ executor: 'palbase' | 'acp' | (string & {});
106
+ harness?: string;
107
+ }
108
+ /** Parameters for teleporting a chat session to a new execution target (`chats.handoff`). */
109
+ export interface HandoffOptions {
110
+ to: ExecutionTarget;
111
+ /** When to cut over: `idle` (default), `after_turn`, or `now`. */
112
+ when?: 'idle' | 'after_turn' | 'now';
113
+ /** Grace window in seconds for parking an active turn when `when: 'now'`. */
114
+ graceSeconds?: number;
115
+ /** Caller idempotency key so retries return the same target generation without double-teleporting. */
116
+ idempotencyKey?: string;
117
+ signal?: AbortSignal;
118
+ }
119
+ /** Result of a session teleport (`chats.handoff`). */
120
+ export interface HandoffResult {
121
+ chatId: string;
122
+ targetGeneration: number;
123
+ target: ExecutionTarget;
124
+ workspaceSeq: number;
125
+ activeRunAction: 'none' | 'queued_after_turn' | 'parked_and_resumed' | (string & {});
126
+ resumedResponseId?: string;
127
+ }
128
+ /** Live execution state of a chat (`chats.execution`). */
129
+ export interface ChatExecution {
130
+ chatId: string;
131
+ target: ExecutionTarget;
132
+ targetGeneration: number;
133
+ workspaceId?: string;
134
+ workspaceSeq: number;
135
+ machineStatus?: 'online' | 'offline' | 'waking' | (string & {});
136
+ machineName?: string;
137
+ harnesses?: MachineHarness[];
138
+ autoFailover: AutoFailoverPolicy | null;
139
+ failoverAt: string | null;
140
+ pendingHandoff?: PendingHandoff;
141
+ }
142
+ /** Mutable execution settings updated via `chats.updateExecution`. */
143
+ export interface UpdateExecutionOptions {
144
+ autoFailover?: AutoFailoverPolicy | null;
145
+ model?: string;
146
+ effort?: string;
147
+ signal?: AbortSignal;
50
148
  }
51
149
  export interface EndpointInput {
52
150
  /** https: a tool at that address, called with a signed POST; mcp: an MCP server (streamable HTTP). */
@@ -82,13 +180,6 @@ export interface MemberInput {
82
180
  /** The owner deletes the chat. */
83
181
  owner?: boolean;
84
182
  }
85
- /** A git trailer every commit of a chat's workspace carries at its message's end: PalCore-Task: #12, Co-authored-by: …. */
86
- export interface CommitTrailer {
87
- /** Its token, as git takes one: letters, digits and -, at most 64. */
88
- key: string;
89
- /** One line, 512 bytes at most. */
90
- value: string;
91
- }
92
183
  export interface CreateChat {
93
184
  /**
94
185
  * One of the project's agents by name — its backend's (a backend's ai.agent itself names it), or one it keeps, whose
@@ -104,60 +195,59 @@ export interface CreateChat {
104
195
  /** Who reads it and writes to it (64 at most). */
105
196
  members?: MemberInput[];
106
197
  /**
107
- * The project's repositories the chat works in (ai.repos.put), each at a
108
- * branch (its default unless said): its turns run on a machine of the
109
- * platform's with them checked out, and what its agent commits is pushed
110
- * to that branch — with a token the backend gives at each push (ai.repo).
111
- */
112
- workspace?: {
113
- repos: {
114
- repo: string | BackendRepo;
115
- branch?: string;
116
- }[];
117
- /** 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. */
118
- autoPush?: boolean;
119
- /**
120
- * What each of its commits carries at its message's end (16 at most): a task, a link back to the
121
- * conversation, a co-author. A commit is written as the member its turn is for (MemberInput.email); a turn
122
- * that is no member's commits as the platform.
123
- */
124
- trailers?: CommitTrailer[];
125
- };
126
- /**
127
- * The project's runner pool its workspace runs on (ai.pools), by its id or its name: its sessions run on the
128
- * project's own machines enrolled there, a Mac or a Linux box. Left out, the platform's own Linux machines. A chat
129
- * that names one works in a workspace; one the project has not is refused (400).
198
+ * The project's runner pool its workspace runs on (ai.pools), by its id or its name: shorthand for
199
+ * `target: { compute: { kind: 'pool', poolId }, executor: { kind: 'palbase' } }`.
130
200
  */
131
201
  pool?: string;
202
+ /** Standalone workspaces module id (`ws_<24hex>`) bound to this chat. */
203
+ workspaceId?: string;
204
+ /** Portable two-axis execution target (compute + executor). Defaults to serverless Palbase engine. */
205
+ target?: ExecutionTarget;
206
+ /** Opt-in automatic failover policy when a pinned machine goes offline. Default null (off). */
207
+ autoFailover?: AutoFailoverPolicy | null;
208
+ /** Attach a Realtime pipe (`chat:<chat_id>`) automatically at creation. Defaults to `settings.autoPipeChats`. */
209
+ live?: boolean;
132
210
  signal?: AbortSignal;
133
211
  }
134
- /** A repository the project's chats work in, as the module keeps it. */
135
- export interface Repo {
136
- name: string;
137
- repository: string;
138
- defaultBranch: string;
139
- /** The project's machine that gives its tokens. */
140
- backend: string;
141
- createdAt: string;
142
- }
143
- export interface Repos {
144
- /** Puts a backend's ai.repo (its tokens asked of that backend at each clone and push), or a repository by name. */
145
- put(repo: BackendRepo): Promise<Repo>;
146
- put(name: string, repo: {
147
- repository: string;
148
- defaultBranch?: string;
149
- backend?: string;
150
- }): Promise<Repo>;
151
- /** A page of the project's repositories, by name (100 unless said, at most 1000; a project puts 10 000): nextCursor pages on. */
212
+ /** A first-class project runtime environment for AI agents (`ephemeral` or `always_on`). */
213
+ export type Environment = modules.ai.Environment;
214
+ /** An immutable pre-bake build record for a runtime environment. */
215
+ export type EnvironmentBuild = modules.ai.EnvironmentBuild;
216
+ /** Configuration for creating or updating a project runtime environment. */
217
+ export type EnvironmentRequest = modules.ai.EnvironmentRequest;
218
+ /** Container image, Dockerfile, Mac VM profile, and pre-install setup commands. */
219
+ export type EnvironmentRuntime = modules.ai.EnvironmentRuntime;
220
+ /** Compute and idle lifecycle limits for an environment. */
221
+ export type EnvironmentResources = modules.ai.EnvironmentResources;
222
+ /** Warm pool and concurrency scaling bounds. */
223
+ export type EnvironmentScaling = modules.ai.EnvironmentScaling;
224
+ /** Outbound network egress policy and Palbase DB connectivity. */
225
+ export type EnvironmentNetwork = modules.ai.EnvironmentNetwork;
226
+ /** The project's runtime environments (`ephemeral` or `always_on`) and their pre-bake builds. */
227
+ export interface Environments {
152
228
  list(options?: {
153
- limit?: number;
154
- cursor?: string;
155
- }): Promise<{
156
- repos: Repo[];
157
- nextCursor?: string;
158
- }>;
159
- /** A chat's workspace checks it out no more. */
160
- delete(name: string): Promise<void>;
229
+ signal?: AbortSignal;
230
+ }): Promise<Environment[]>;
231
+ create(environment: EnvironmentRequest & {
232
+ name: string;
233
+ }, options?: {
234
+ signal?: AbortSignal;
235
+ }): Promise<Environment>;
236
+ get(name: string, options?: {
237
+ signal?: AbortSignal;
238
+ }): Promise<Environment>;
239
+ put(name: string, environment: Omit<EnvironmentRequest, 'name'>, options?: {
240
+ signal?: AbortSignal;
241
+ }): Promise<Environment>;
242
+ delete(name: string, options?: {
243
+ signal?: AbortSignal;
244
+ }): Promise<void>;
245
+ createBuild(name: string, options?: {
246
+ signal?: AbortSignal;
247
+ }): Promise<EnvironmentBuild>;
248
+ getBuild(name: string, buildId: string, options?: {
249
+ signal?: AbortSignal;
250
+ }): Promise<EnvironmentBuild>;
161
251
  }
162
252
  export interface SendMessage {
163
253
  text: string;
@@ -518,113 +608,6 @@ export interface Voices {
518
608
  signal?: AbortSignal;
519
609
  }): Promise<ChatVoice>;
520
610
  }
521
- /** What a write of a chat's workspace left: the tree it is at now — what a tool answers with ai.answer(output, { workspaceTree }). */
522
- export interface WorkspaceWrite {
523
- /** The file. */
524
- path: string;
525
- /** The tree the workspace is at now: a file of it is read by it (workspace.file's manifest). */
526
- manifestId: string;
527
- /** Its place in the workspace's history. */
528
- seq: number;
529
- }
530
- /** A token of a chat's workspace, never said again: what it may do, what it is for, when it expires. */
531
- export interface WorkspaceToken {
532
- /** Its id: revoked by it. */
533
- id: string;
534
- /** read: the workspace followed; write: followed and written, both ways. */
535
- access: 'read' | 'write' | (string & {});
536
- /** What it is for — the machine's name: a conflict names its writer by it. */
537
- label?: string;
538
- expiresAt: string;
539
- /** The workspace's id in the store. */
540
- workspaceId: string;
541
- }
542
- /**
543
- * A workspace token as it is minted: the token and where it syncs, said once — on the machine,
544
- * `PALAI_WORKSPACE_TOKEN=<token> palai workspace sync --url <syncUrl> <dir>`, or the token on standard input with
545
- * `--token-file -`; never on the command line (palai has no --token: any process on the machine could read it).
546
- */
547
- export interface WorkspaceTokenMinted extends WorkspaceToken {
548
- /** The token, said once: given palai workspace sync in PALAI_WORKSPACE_TOKEN, or on its standard input (--token-file -). */
549
- token: string;
550
- /** Where the workspace's token routes are, at the project's own address: `palai workspace sync --url <syncUrl> <dir>`. */
551
- syncUrl: string;
552
- }
553
- /**
554
- * The tokens of a chat's workspace, from its server: a machine of the customer's — a developer's computer, a CI
555
- * runner — syncs the workspace with one (palai workspace sync), live and both ways (write) or followed (read). While
556
- * one lives the chat's workspace events are told (ai.workspace.published, ai.workspace.conflict).
557
- */
558
- export interface WorkspaceTokens {
559
- /**
560
- * Mints one, said once: it lives ttlSeconds (1 to 604 800; an hour when left out) — no longer than an environment's
561
- * token it is minted with — and answers at the project's own address alone (syncUrl). A member who mints one (the
562
- * project letting its app's users in) mints it for an hour at most; it is theirs alone, and stops answering when they
563
- * leave the chat or the project turns clients off. A chat whose first turn has not opened its workspace has it opened
564
- * now; a chat of no workspace: 409 no_workspace.
565
- */
566
- create(id: string, token: {
567
- access: 'read' | 'write';
568
- ttlSeconds?: number;
569
- label?: string;
570
- signal?: AbortSignal;
571
- }): Promise<WorkspaceTokenMinted>;
572
- /** Its tokens — access, label, when each expires — none of them said again: the server's every one, a member's their own. */
573
- list(id: string, options?: {
574
- signal?: AbortSignal;
575
- }): Promise<WorkspaceToken[]>;
576
- /** Revoked at once: every token route refuses it from then, and an event stream open with it ends. A member revokes their own. */
577
- revoke(id: string, tokenId: string, options?: {
578
- signal?: AbortSignal;
579
- }): Promise<void>;
580
- }
581
- /**
582
- * A file's bytes as a workspace write takes them: text (written as UTF-8), bytes, a Blob, or a stream of bytes — a
583
- * stream is read here whole first (64 MiB at most), so the write says its length, as the workspace's store asks.
584
- */
585
- export type WorkspaceFileBody = string | Uint8Array | Blob | ReadableStream<Uint8Array>;
586
- /** A chat's workspace, from its server: a file of a tree it published, written or removed, a repository put in it at work, its sync tokens. */
587
- export interface Workspaces {
588
- /**
589
- * A file of the chat's workspace, its bytes: from the tree it is at now, or from the one an ai.workspace.published
590
- * event named (manifest) — a build's product as that publish left it. 64 MiB at most (413 file_too_large: publish a
591
- * larger one as the turn's artifact); its digest is the answer's Content-Digest. Read the Response as it comes.
592
- */
593
- file(id: string, path: string, options?: {
594
- manifest?: string;
595
- signal?: AbortSignal;
596
- }): Promise<globalThis.Response>;
597
- /**
598
- * Puts one more of the project's repositories (ai.repos.put — one born at work too) in an open chat's workspace,
599
- * beside its others, at a branch (its default unless said): cloned before the chat's next turn, and every chat
600
- * working in the workspace has it (a fork too). Put again, the same. A chat of no workspace: 409 no_workspace.
601
- */
602
- addRepo(id: string, repo: {
603
- repo: string | BackendRepo;
604
- branch?: string;
605
- signal?: AbortSignal;
606
- }): Promise<Chat>;
607
- /**
608
- * Writes one file of the chat's workspace, its bytes the body (64 MiB at most: a larger one is refused here, before it
609
- * is sent — a stream as soon as it passes the bound — and by the module, 413 file_too_large): published over
610
- * whatever the workspace's head holds — the write is deliberate, no conflict is made of it — and synced to every
611
- * machine that holds the workspace, the session's own before the agent's next command; it is told as
612
- * ai.workspace.published. path is relative to its root (repo/src/config.json): 1 to 2048 bytes, each segment 255 at
613
- * most. A stream body is read whole before the write is sent, so it says its length. A backend tool that writes answers
614
- * the tree it left: ai.answer(output, { workspaceTree: written }). A chat whose first turn has not opened its
615
- * workspace has it opened now; a chat of no workspace: 409 no_workspace.
616
- */
617
- write(id: string, path: string, body: WorkspaceFileBody, options?: {
618
- contentType?: string;
619
- signal?: AbortSignal;
620
- }): Promise<WorkspaceWrite>;
621
- /** Removes one file of the chat's workspace, as a write is made: synced to every machine that holds it. */
622
- remove(id: string, path: string, options?: {
623
- signal?: AbortSignal;
624
- }): Promise<WorkspaceWrite>;
625
- /** The tokens a machine of the customer's syncs the workspace with (palai workspace sync). */
626
- readonly tokens: WorkspaceTokens;
627
- }
628
611
  export interface Chats {
629
612
  create(chat: CreateChat): Promise<Chat>;
630
613
  get(id: string, options?: {
@@ -633,12 +616,14 @@ export interface Chats {
633
616
  /**
634
617
  * A page of the chats, the newest first (100 unless said, at most 100):
635
618
  * every chat, or a member's — and, with metadata, only those labelled with
636
- * every one of its labels (a product's chats: { project_id: id }).
619
+ * every one of its labels (a product's chats: { project_id: id }), or with
620
+ * `status: 'active'` only chats with an active/waiting turn.
637
621
  * nextCursor pages on.
638
622
  */
639
623
  list(options?: {
640
624
  member?: string;
641
625
  metadata?: Record<string, string>;
626
+ status?: 'active' | 'all';
642
627
  limit?: number;
643
628
  cursor?: string;
644
629
  signal?: AbortSignal;
@@ -646,6 +631,14 @@ export interface Chats {
646
631
  chats: Chat[];
647
632
  nextCursor?: string;
648
633
  }>;
634
+ /** Teleports this chat session to a new execution target (compute and/or executor), atomically advancing `targetGeneration`. */
635
+ handoff(id: string, options: HandoffOptions): Promise<HandoffResult>;
636
+ /** Reads the chat's live execution target, target generation, machine online status, probed harnesses, and auto-failover state. */
637
+ execution(id: string, options?: {
638
+ signal?: AbortSignal;
639
+ }): Promise<ChatExecution>;
640
+ /** Updates the chat's auto-failover policy and/or default model/effort without changing its compute target. */
641
+ updateExecution(id: string, patch: UpdateExecutionOptions): Promise<ChatExecution>;
649
642
  /** A turn still running is stopped; its history no longer counts. */
650
643
  delete(id: string): Promise<void>;
651
644
  members: {
@@ -719,8 +712,6 @@ export interface Chats {
719
712
  toolCalls: TurnToolCall[];
720
713
  nextCursor?: string;
721
714
  }>;
722
- /** The chat's workspace: a file of a tree it published, a repository put in it at work. */
723
- readonly workspace: Workspaces;
724
715
  /**
725
716
  * What happens in the chat — its messages, its turns, the answer as it is written, the tools and subagents — as a
726
717
  * source a gateway pipes into its channel: `ctx.pipe(Palbase.ai.chats.events(id))`. The platform writes the chat
@@ -752,9 +743,8 @@ export interface Chats {
752
743
  * first. As a member (as): the app of the member whose turn it is answers it (403 not_your_turn otherwise). A
753
744
  * backend tool that returned ai.deferred() — its ToolContext's chatId and callId — is answered here too, by the
754
745
  * server as itself (never as a member), within the while it named. A tool that wrote the chat's workspace names the
755
- * tree its writes left (workspaceTree: chats.workspace.write's answer, { manifestId, seq }, either or both), as an
756
- * answer given at once does (ai.answer(output, { workspaceTree })): the agent's next command waits for the session's
757
- * machine to have it.
746
+ * tree its writes left ({ manifestId, seq }, either or both), as an answer given at once does
747
+ * (ai.answer(output, { workspaceTree })): the agent's next command waits for the session's machine to have it.
758
748
  */
759
749
  answer(id: string, callId: string, output: ToolResult, options?: {
760
750
  isError?: boolean;
@@ -895,6 +885,8 @@ export interface Settings {
895
885
  userMessagesPerMinute?: number;
896
886
  historyLimitBytes?: number | null;
897
887
  openSecretsForAppUsers?: boolean;
888
+ allowClientHandoff?: boolean;
889
+ autoPipeChats?: boolean;
898
890
  }): Promise<AISettings>;
899
891
  }
900
892
  /**
@@ -907,6 +899,6 @@ export declare function chatsOf(raw: Module): {
907
899
  agents: Agents;
908
900
  endpoints: Endpoints;
909
901
  settings: Settings;
910
- repos: Repos;
902
+ environments: Environments;
911
903
  };
912
904
  export {};
@@ -1,11 +1,11 @@
1
1
  export { createAI, AIResponseError } from './ai.js';
2
- export type { AI, AIOptions, AgentGenerate, Ask, AskImage, AskTool, ChatModel, DeepPartial, Embed, Generate, ImageRequest, Images, Job, Message, Model, Models, ObjectStream, Picture, Response, Schema, Spend, TextStream, Uploader, Usage, } from './ai.js';
2
+ export type { AI, AIOptions, AgentGenerate, Ask, AskImage, AskTool, Audio, ChatModel, DeepPartial, Embed, Generate, ImageRequest, Images, Job, Message, Model, Models, ObjectStream, Picture, Response, Schema, SpeechAudio, SpeechRequest, Spend, TextStream, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, Uploader, Usage, UsageKind, VideoCancelResult, VideoJob, VideoRequest, Videos, } 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, AgentTool, AgentVersion, 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, TurnAdvisorCost, TurnArtifact, TurnCost, TurnRunCost, TurnToolCall, VoiceCommand, Voices, WorkspaceFileBody, WorkspaceToken, WorkspaceTokenMinted, WorkspaceTokens, WorkspaceWrite, Workspaces, } from './chats.js';
8
- export type { EnvVariable, EnvVariableOptions, EnvVariables, Pool, PoolKey, PoolKeyEnroll, PoolKeyMinted, PoolKeys, PoolMachine, PoolMachines, PoolState, Pools, SecretHostAllowance, SecretHostAllowances, SecretHostRequest, SecretHostRequests, } from './pools.js';
9
- export type { AdvisorDefinition, AgentContext, AgentDefinitionInput, AgentEnvEntry, BackendAgent, BackendAgentOptions, BackendRepo, BackendTool, BackendToolOptions, ChatContext, ClientTool, ClientToolOptions, DeferredAnswer, Effort, HttpsToolRef, McpToolRef, EnvInject, PlatformToolName, PlatformToolRef, PreparedOutput, RepoTokenContext, RepoTokens, SecretDescription, SubagentDefinition, Thinking, Tool, ToolAnswer, ToolContext, ToolReply, ToolWorkspace, TurnDefinition, TurnMessage, WorkspaceTree, } from './tools.js';
10
- 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';
7
+ export type { AISettings, Agent, AgentTool, AgentVersion, Agents, AutoFailoverPolicy, Chat, ChatEvents, ChatExecution, ChatGoal, ChatMessage, ChatStreamPart, ChatToolCall, ChatVoice, Chats, ComputeTarget, CreateChat, Decision, Endpoint, EndpointInput, Endpoints, Environment, EnvironmentBuild, EnvironmentNetwork, EnvironmentRequest, EnvironmentResources, EnvironmentRuntime, EnvironmentScaling, Environments, ExecutionTarget, ExecutorTarget, ForkChat, GoalChange, Goals, HandoffOptions, HandoffResult, MemberInput, MessageAttachment, MessageFile, MessageImage, PendingHandoff, SendMessage, SetGoal, Settings, StartVoice, TargetSummary, TurnAdvisorCost, TurnArtifact, TurnCost, TurnRunCost, TurnToolCall, UpdateExecutionOptions, VoiceCommand, Voices, } from './chats.js';
8
+ export type { EnvVariable, EnvVariableOptions, EnvVariables, MachineHarness, Pool, PoolKey, PoolKeyEnroll, PoolKeyMinted, PoolKeys, PoolMachine, PoolMachines, PoolState, Pools, SecretHostAllowance, SecretHostAllowances, SecretHostRequest, SecretHostRequests, } from './pools.js';
9
+ export type { AdvisorDefinition, AgentContext, AgentDefinitionInput, AgentEnvEntry, BackendAgent, BackendAgentOptions, BackendTool, BackendToolOptions, ChatContext, ClientTool, ClientToolOptions, DeferredAnswer, Effort, HttpsToolRef, McpToolRef, EnvInject, PlatformToolName, PlatformToolRef, PreparedOutput, SecretDescription, SubagentDefinition, Thinking, Tool, ToolAnswer, ToolContext, ToolReply, ToolWorkspace, TurnDefinition, TurnMessage, WorkspaceTree, } from './tools.js';
10
+ export type { AgentEvent, ChatEvent, ContextCompactedEvent, ContextOffloadedEvent, GoalEvent, GoalKind, HistoryEvent, HistoryItem, MessageEvent, Publication, ResetEvent, SessionHandedOffEvent, SessionMachineStatusEvent, SessionSummaryEvent, TextEvent, ThinkingEvent, ToolEvent, ToolStatus, TranscriptEvent, TurnEnd, TurnEvent, TurnStatus, VoiceEvent, WaitingReason, } from '../../internal/src/chat.js';
11
11
  export type { ToolPart, ToolResult } from '../../internal/src/tool-output.js';
@@ -30,30 +30,37 @@ export interface PoolKey {
30
30
  revokedAt?: string;
31
31
  }
32
32
  /**
33
- * Where a machine enrols, said with a key as it is minted: `palai enroll --url <url> --key-file <file>`, with
33
+ * Where a machine enrols, said with a key as it is minted: `palbase-agent enroll --url <url> --key-file <file>`, with
34
34
  * `--server-name <serverName>` when the door's certificate names another host, and `--ca-file <file>` holding
35
35
  * caCertificate when the door's certificate is not publicly trusted.
36
36
  */
37
37
  export interface PoolKeyEnroll {
38
38
  url: string;
39
39
  serverName?: string;
40
- /** The CA the door's certificate is signed by (PEM): saved to a file, palai enroll --ca-file. */
40
+ /** The CA the door's certificate is signed by (PEM): saved to a file, palbase-agent enroll --ca-file. */
41
41
  caCertificate?: string;
42
42
  }
43
43
  /** A key as it is minted: the key, said once, and where a machine enrols with it. */
44
44
  export interface PoolKeyMinted extends PoolKey {
45
45
  key: string;
46
- /** The enrolment address: palai enroll --url. */
46
+ /** The enrolment address: palbase-agent enroll --url. */
47
47
  enrollUrl?: string;
48
48
  enroll?: PoolKeyEnroll;
49
49
  }
50
+ /** An official local ACP CLI harness probed by palbase-agent on an enrolled machine (never reads OAuth tokens). */
51
+ export interface MachineHarness {
52
+ name: 'claude-code' | 'codex' | 'gemini-cli' | (string & {});
53
+ acpVersion?: string;
54
+ cliVersion?: string;
55
+ status: 'ready' | 'unauthenticated' | 'not_installed' | (string & {});
56
+ }
50
57
  /** A machine of a pool: what it takes and holds, and whether it takes a new session. */
51
58
  export interface PoolMachine {
52
59
  /** Its id: cordoned, resumed and deleted by it (ai.machines). */
53
60
  id: string;
54
61
  /** online, offline, or cordoned (it takes no new session). */
55
62
  state: 'online' | 'offline' | 'cordoned' | (string & {});
56
- /** How many sessions it takes at once (palai enroll --capacity), and holds now. */
63
+ /** How many sessions it takes at once (palbase-agent enroll --capacity), and holds now. */
57
64
  capacity: number;
58
65
  used: number;
59
66
  /** Its label, as it enrolled. */
@@ -64,6 +71,8 @@ export interface PoolMachine {
64
71
  idleSince: string | null;
65
72
  lastSeenAt: string | null;
66
73
  registeredAt: string | null;
74
+ /** Official local ACP CLI harnesses reported by palbase-agent on this machine. */
75
+ harnesses?: MachineHarness[];
67
76
  }
68
77
  /** A pool's state: what the project's own scaling loop reads to add a machine or take one away. */
69
78
  export interface PoolState {
@@ -80,11 +89,11 @@ export interface PoolState {
80
89
  oldestWaitingSince: string | null;
81
90
  machines: PoolMachine[];
82
91
  }
83
- /** A pool's enrolment keys: a machine enrols with one once (`palai enroll --url <enrollUrl> --key-file <file> --capacity <n>`). */
92
+ /** A pool's enrolment keys: a machine enrols with one once (`palbase-agent enroll --url <enrollUrl> --key-file <file> --capacity <n>`). */
84
93
  export interface PoolKeys {
85
94
  /**
86
95
  * Mints one, said once — here, never again — with where a machine enrols (enrollUrl, enroll): saved to a file on the
87
- * machine, `palai enroll --url <enrollUrl> --key-file <file> --capacity <n>` (and --server-name, --ca-file when enroll
96
+ * machine, `palbase-agent enroll --url <enrollUrl> --key-file <file> --capacity <n>` (and --server-name, --ca-file when enroll
88
97
  * says them) — never on a command line, where any process on the machine could read it; n is how many sessions the
89
98
  * machine runs at once (1 or more, default 1). A machine enrolled with it serves the project's sessions once whoever
90
99
  * minted it is gone: it is never minted for an environment's token.
@@ -138,7 +147,7 @@ export interface PoolMachines {
138
147
  resume(id: string, options?: {
139
148
  signal?: AbortSignal;
140
149
  }): Promise<void>;
141
- /** A cordoned machine that holds no session leaves its pool, its palai agent refused from then (409 machine_not_cordoned, machine_busy). */
150
+ /** A cordoned machine that holds no session leaves its pool, its palbase-agent refused from then (409 machine_not_cordoned, machine_busy). */
142
151
  delete(id: string, options?: {
143
152
  signal?: AbortSignal;
144
153
  }): Promise<void>;
@@ -318,6 +327,7 @@ export interface EnvVariables {
318
327
  /** The hosts its agents' own secrets are allowed beside their definitions'. */
319
328
  readonly allowances: SecretHostAllowances;
320
329
  }
330
+ export declare function harnessOf(h: modules.ai.MachineHarness): MachineHarness;
321
331
  export declare function poolsOf(module: Module): {
322
332
  pools: Pools;
323
333
  machines: PoolMachines;