@base44-preview/sdk 0.8.52-pr.286.2dbb896 → 0.8.52-pr.286.58a3186

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.
@@ -1,2 +1,2 @@
1
1
  /** Server refusals and client transport/processing failures. */
2
- export type PlatformSocketErrorCode = "connection_denied" | "connection_failed" | "session_unavailable" | "session_replaced" | "access_denied" | "access_revoked" | "snapshot_unavailable" | "subscription_limit" | "delivery_overflow" | "protocol_error" | "handler_failed" | "client_closed";
2
+ export type PlatformSocketErrorCode = "connection_denied" | "connection_failed" | "session_unavailable" | "session_revoked" | "session_replaced" | "access_denied" | "access_revoked" | "snapshot_unavailable" | "subscription_limit" | "delivery_overflow" | "protocol_error" | "handler_failed" | "client_closed";
@@ -4,4 +4,4 @@ export { PlatformSocketError } from "./errors.js";
4
4
  export type { PlatformSocketErrorCode } from "./errors.types.js";
5
5
  export type { PlatformClientOptions } from "./client.types.js";
6
6
  export type { BuilderModule, BuilderInitOptions, BuilderSession, PlatformSubscription, SubscriptionOptions } from "./modules/builder.types.js";
7
- export type { AppUpdate, AppStatus, ChatMessage, MessageParams, ToolCall, ToolDisplayProjection, ToolQuestionOption, ToolQuestion, ToolQuestionArguments, ToolSecretField, ToolSecretArguments, ToolPackageOperation, ToolPackageArguments, ToolPlanUpdate, ToolPlanArguments, ToolPrdArguments, ToolMediaArguments, ToolMediaResult, ToolQuestionAnswer, ToolQuestionInput, ToolOutcome, ToolGuardApproval, ToolResult, QueueItem, QueueUpdate, TaskUpdate, ImageReady, Directive, PlatformEventMap, PlatformEvent, Snapshot } from "./modules/builder.events.types.js";
7
+ export type { AppStatus, AppStatusChanged, BranchScoped, ChatMessage, ImageResolved, MessageParams, MessageRemoved, MessageUpdated, PlatformEvent, PlatformEventMap, PreviewNavigationRequested, QueueItem, QueueUpdated, Snapshot, SnapshotQueue, TaskProgressed, ToolArguments, ToolCall, ToolDisplay, ToolEntityMutationArguments, ToolGuardApproval, ToolMediaArguments, ToolMediaResult, ToolPackageArguments, ToolPackageOperation, ToolPlanArguments, ToolPlanUpdate, ToolPrdArguments, ToolQuestion, ToolQuestionAnswer, ToolQuestionArguments, ToolQuestionInput, ToolQuestionOption, ToolSecretArguments, ToolSecretField, } from "./modules/builder.events.types.js";
@@ -1,11 +1,15 @@
1
1
  import type { PlatformEvent, PlatformEventMap, Snapshot } from "./builder.events.types.js";
2
- export declare const eventNames: readonly ["update_model", "directive", "queue_update", "task_update", "image_ready"];
3
- /** Error frames that name an app room. */
4
- export declare const roomErrorCodes: readonly ["access_denied", "access_revoked", "snapshot_unavailable"];
2
+ export declare const eventNames: readonly ["message.updated", "message.removed", "app.status_changed", "preview.reload_requested", "preview.navigation_requested", "queue.updated", "task.progressed", "image.resolved", "conversation.changed", "files.changed", "branch.deleted", "repository.changed", "pull_request.changed"];
3
+ /** Notices that name an app room, by the error code each one reports. */
4
+ export declare const roomNotices: {
5
+ readonly "room.access_denied": "access_denied";
6
+ readonly "room.access_revoked": "access_revoked";
7
+ readonly "room.snapshot_unavailable": "snapshot_unavailable";
8
+ };
5
9
  export declare const appPattern: RegExp;
6
10
  export declare const roomFor: (appId: string) => string;
7
11
  export declare function object(value: unknown): Record<string, unknown>;
8
- export declare function string(value: unknown): string;
9
12
  export declare function appFromRoom(value: unknown): string | undefined;
13
+ /** Every event is `{room, data}`; payload schemas are the service's, so only the envelope is validated. */
10
14
  export declare function decode(type: keyof PlatformEventMap, appId: string, raw: unknown): PlatformEvent;
11
15
  export declare function decodeSnapshot(raw: unknown): Snapshot;
@@ -1,6 +1,14 @@
1
- export const eventNames = ["update_model", "directive", "queue_update", "task_update", "image_ready"];
2
- /** Error frames that name an app room. */
3
- export const roomErrorCodes = ["access_denied", "access_revoked", "snapshot_unavailable"];
1
+ export const eventNames = [
2
+ "message.updated", "message.removed", "app.status_changed", "preview.reload_requested",
3
+ "preview.navigation_requested", "queue.updated", "task.progressed", "image.resolved",
4
+ "conversation.changed", "files.changed", "branch.deleted", "repository.changed", "pull_request.changed",
5
+ ];
6
+ /** Notices that name an app room, by the error code each one reports. */
7
+ export const roomNotices = {
8
+ "room.access_denied": "access_denied",
9
+ "room.access_revoked": "access_revoked",
10
+ "room.snapshot_unavailable": "snapshot_unavailable",
11
+ };
4
12
  export const appPattern = /^[a-f0-9]{24}$/;
5
13
  export const roomFor = (appId) => `/apps/${appId}`;
6
14
  export function object(value) {
@@ -8,25 +16,19 @@ export function object(value) {
8
16
  throw new Error("Invalid frame");
9
17
  return value;
10
18
  }
11
- export function string(value) {
12
- if (typeof value !== "string" || !value)
13
- throw new Error("Invalid string");
14
- return value;
15
- }
16
19
  export function appFromRoom(value) {
17
20
  return typeof value === "string" && /^\/apps\/[a-f0-9]{24}$/.test(value) ? value.slice(6) : undefined;
18
21
  }
22
+ /** Every event is `{room, data}`; payload schemas are the service's, so only the envelope is validated. */
19
23
  export function decode(type, appId, raw) {
20
- const frame = object(raw);
21
- const wrapped = type === "update_model" || type === "task_update" || type === "image_ready";
22
- const data = wrapped ? object(JSON.parse(string(frame.data))) : frame;
23
- // Payload schemas are owned by the service; only decode/validate the transport envelope here.
24
- return { type, appId, data };
24
+ return { type, appId, data: object(object(raw).data) };
25
25
  }
26
26
  export function decodeSnapshot(raw) {
27
27
  const frame = object(raw);
28
- if (!appFromRoom(frame.room) || !Array.isArray(frame.messages) || (frame.status !== null && typeof frame.status !== "object")) {
28
+ const data = object(frame.data);
29
+ if (!appFromRoom(frame.room) || !Array.isArray(data.messages) || (data.status !== null && typeof data.status !== "object")) {
29
30
  throw new Error("Invalid snapshot");
30
31
  }
31
- return frame;
32
+ const queue = data.queue !== null && typeof data.queue === "object" ? { queue: data.queue } : {};
33
+ return { room: frame.room, status: data.status, messages: data.messages, ...queue };
32
34
  }
@@ -36,6 +36,7 @@ export declare class BuilderSocket implements BuilderSession {
36
36
  private retryDenied;
37
37
  private clearConnecting;
38
38
  private connectionError;
39
- private serverError;
39
+ private sessionEnded;
40
+ private roomNotice;
40
41
  private protocolError;
41
42
  }
@@ -1,6 +1,6 @@
1
1
  import { io } from "socket.io-client";
2
2
  import { PlatformSocketError } from "../errors.js";
3
- import { appFromRoom, appPattern, decode, decodeSnapshot, eventNames, object, roomErrorCodes, roomFor } from "./builder-protocol.js";
3
+ import { appFromRoom, appPattern, decode, decodeSnapshot, eventNames, object, roomFor, roomNotices } from "./builder-protocol.js";
4
4
  import { notify, Subscription } from "./builder-subscription.js";
5
5
  const MAX_DENIAL_RETRIES = 5;
6
6
  /** @internal */
@@ -36,11 +36,11 @@ export class BuilderSocket {
36
36
  if (ending === "session_expired")
37
37
  this.socket.connect(); // Renew through getSessionToken.
38
38
  else
39
- this.connectionError(new PlatformSocketError(ending === "session_replaced" ? "session_replaced" : "connection_failed"));
39
+ this.connectionError(new PlatformSocketError(ending !== null && ending !== void 0 ? ending : "connection_failed"));
40
40
  });
41
41
  this.socket.on("connect_error", (error) => this.refused(error));
42
42
  this.socket.io.on("reconnect_failed", () => this.connectionError(new PlatformSocketError("connection_failed")));
43
- this.socket.on("joined", (raw) => {
43
+ this.socket.on("app.snapshot", (raw) => {
44
44
  var _a;
45
45
  try {
46
46
  const snapshot = decodeSnapshot(raw);
@@ -50,17 +50,23 @@ export class BuilderSocket {
50
50
  this.protocolError(raw);
51
51
  }
52
52
  });
53
- this.socket.on("error", (raw) => this.serverError(raw));
53
+ this.socket.on("session.ended", (raw) => this.sessionEnded(raw));
54
+ for (const [name, code] of Object.entries(roomNotices))
55
+ this.socket.on(name, (raw) => this.roomNotice(code, raw));
54
56
  for (const type of eventNames)
55
57
  this.socket.on(type, (raw) => {
56
- var _a;
57
58
  try {
58
59
  const appId = appFromRoom(object(raw).room);
59
60
  if (!appId)
60
61
  throw new Error("Invalid app");
61
- (_a = this.subscriptions.get(appId)) === null || _a === void 0 ? void 0 : _a.event(decode(type, appId, raw));
62
+ const event = decode(type, appId, raw);
63
+ const subscription = this.subscriptions.get(appId);
64
+ subscription === null || subscription === void 0 ? void 0 : subscription.event(event);
65
+ // The server does not resend a snapshot after a rewrite of main: rejoining asks for one.
66
+ if (subscription && event.type === "conversation.changed" && event.data.branch_id == null)
67
+ this.join(subscription);
62
68
  }
63
- catch (_b) {
69
+ catch (_a) {
64
70
  this.protocolError(raw);
65
71
  }
66
72
  });
@@ -199,19 +205,27 @@ export class BuilderSocket {
199
205
  if (!this.closed)
200
206
  notify(this.options.onError, error);
201
207
  }
202
- serverError(raw) {
208
+ sessionEnded(raw) {
203
209
  try {
204
- const frame = object(raw);
205
- if (frame.room === null && (frame.code === "session_expired" || frame.code === "session_replaced")) {
206
- // The server disconnects next; the disconnect handler renews or stops.
207
- this.token = undefined;
208
- this.ending = frame.code;
209
- return;
210
- }
211
- const appId = appFromRoom(frame.room);
212
- const code = roomErrorCodes.find((code) => code === frame.code);
213
- if (!appId || !code)
214
- throw new Error("Unknown error");
210
+ const reason = object(object(raw).data).reason;
211
+ const ending = reason === "expired" ? "session_expired"
212
+ : reason === "revoked" ? "session_revoked"
213
+ : reason === "replaced" ? "session_replaced" : undefined;
214
+ if (!ending)
215
+ throw new Error("Unknown reason");
216
+ // The server disconnects next; the disconnect handler renews or stops.
217
+ this.token = undefined;
218
+ this.ending = ending;
219
+ }
220
+ catch (_a) {
221
+ this.protocolError(raw);
222
+ }
223
+ }
224
+ roomNotice(code, raw) {
225
+ try {
226
+ const appId = appFromRoom(object(raw).room);
227
+ if (!appId)
228
+ throw new Error("Invalid app");
215
229
  const subscription = this.subscriptions.get(appId);
216
230
  if (code === "snapshot_unavailable")
217
231
  subscription === null || subscription === void 0 ? void 0 : subscription.warn(code);
@@ -1,5 +1,5 @@
1
- /** A reviewed file, execution, or entity activity summary. */
2
- export interface ToolDisplayProjection {
1
+ /** Activity a file, execution or entity tool declared public. */
2
+ export interface ToolDisplay {
3
3
  /** Changed file paths for a file operation. Source bodies and diffs are never included. */
4
4
  file_paths?: string[];
5
5
  /** Whether a file write intentionally used empty content. */
@@ -13,75 +13,74 @@ export interface ToolDisplayProjection {
13
13
  /** Number of records affected when supplied by the producer. */
14
14
  record_count?: number;
15
15
  }
16
- /** A reviewed selectable answer to a builder question. */
16
+ /** A selectable answer to a builder question. */
17
17
  export interface ToolQuestionOption {
18
18
  /** Visible option label. */
19
- label: string;
19
+ label?: string;
20
20
  }
21
- /** A reviewed builder question. Image/HTML source and private design context are excluded. */
21
+ /** A builder question. Image/HTML source and private design context are excluded. */
22
22
  export interface ToolQuestion {
23
23
  /** Visible question text. */
24
24
  question?: string;
25
- /** Existing question category. */
25
+ /** Question category. */
26
26
  type?: string;
27
27
  /** Optional visible supporting text. */
28
28
  description?: string;
29
29
  /** Whether more than one answer may be selected. */
30
30
  multi_select?: boolean;
31
- /** Optional existing plan section identifier. */
31
+ /** Plan section the question covers. */
32
32
  covers?: string;
33
- /** Reviewed selectable options. */
34
- options?: ToolQuestionOption[];
33
+ /** Selectable options; a bare string option is its label. */
34
+ options?: (ToolQuestionOption | string)[];
35
35
  }
36
- /** Reviewed question arguments, serialized in `ToolCall.arguments_string`. */
36
+ /** `ask_clarifying_questions` and `ask_plan_questions` arguments. */
37
37
  export interface ToolQuestionArguments {
38
- /** Questions presented by a clarifying-question tool. */
39
- questions: ToolQuestion[];
38
+ /** Questions presented to the user. */
39
+ questions?: ToolQuestion[];
40
40
  }
41
41
  /** A requested secret field. The secret value is never sent over the socket. */
42
42
  export interface ToolSecretField {
43
43
  /** Requested secret name. */
44
- secretName: string;
44
+ secretName?: string;
45
45
  /** Optional explanation of where to obtain it. */
46
46
  description?: string;
47
47
  }
48
- /** Reviewed secret-form arguments, serialized in `ToolCall.arguments_string`. */
48
+ /** `set_secrets` arguments. */
49
49
  export interface ToolSecretArguments {
50
50
  /** Requested secret fields. */
51
- secrets_schema: ToolSecretField[];
51
+ secrets_schema?: ToolSecretField[];
52
52
  }
53
- /** A reviewed package operation. Versions and package-manager output are excluded. */
53
+ /** A package operation. Versions and package-manager output are excluded. */
54
54
  export interface ToolPackageOperation {
55
55
  /** Package name. */
56
- name: string;
56
+ name?: string;
57
57
  /** Requested package operation. */
58
58
  action?: string;
59
59
  }
60
- /** Reviewed package arguments, serialized in `ToolCall.arguments_string`. */
60
+ /** `install_npm_package` arguments. */
61
61
  export interface ToolPackageArguments {
62
62
  /** Requested package operations. */
63
- packages: ToolPackageOperation[];
63
+ packages?: ToolPackageOperation[];
64
64
  }
65
- /** A reviewed add-only builder plan update. */
65
+ /** An add-only builder plan update. */
66
66
  export interface ToolPlanUpdate {
67
- /** Existing update action. */
67
+ /** Update action. */
68
68
  action?: string;
69
69
  /** Plan section key. */
70
70
  section?: string;
71
71
  /** Optional user-facing section label. */
72
72
  section_label?: string;
73
- /** Reviewed plan point. */
73
+ /** Plan point. */
74
74
  text?: string;
75
75
  }
76
- /** Reviewed plan arguments, serialized in `ToolCall.arguments_string`. */
76
+ /** `update_plan` arguments. */
77
77
  export interface ToolPlanArguments {
78
78
  /** Plan updates in their emitted order. */
79
79
  updates?: ToolPlanUpdate[];
80
80
  /** Base plan sections the builder considers sufficiently specified. */
81
81
  sections_with_enough?: string[];
82
82
  }
83
- /** A reviewed plan, serialized in `generate_prd`'s `ToolCall.arguments_string`. The plan is the
84
- * user's own spec; in plan mode the message `content` beside it can be empty. */
83
+ /** `generate_prd` arguments: the user's own plan. In plan mode the message `content` beside it can be empty. */
85
84
  export interface ToolPrdArguments {
86
85
  /** App or feature name. */
87
86
  app_name?: string;
@@ -102,45 +101,52 @@ export interface ToolPrdArguments {
102
101
  /** Engine settled in planning, for game plans. */
103
102
  game_engine?: string;
104
103
  }
105
- /** Reviewed generated-media arguments, serialized in `ToolCall.arguments_string`. */
104
+ /** Image, game-image and video generation arguments. */
106
105
  export interface ToolMediaArguments {
107
106
  /** Visible media label. */
108
107
  label?: string;
109
108
  /** Requested image or video aspect ratio. */
110
109
  aspect_ratio?: string;
111
110
  }
112
- /** Reviewed state of generated media. Raw generation prompts and IDs are never included. */
111
+ /** `update_entities` and `delete_entities` arguments; the entity is in `display.entity_name`. */
112
+ export interface ToolEntityMutationArguments {
113
+ /** The agent's summary of the change. Queries and record values are never included. */
114
+ summary?: string;
115
+ }
116
+ /** The public arguments of a tool that declares them; narrow by the tool call's `name`. */
117
+ export type ToolArguments = ToolQuestionArguments | ToolSecretArguments | ToolPackageArguments | ToolPlanArguments | ToolPrdArguments | ToolMediaArguments | ToolEntityMutationArguments;
118
+ /** Generated-media state. Raw generation prompts and IDs are never included. */
113
119
  export interface ToolMediaResult {
114
- /** Existing placeholder URL, used to associate an `image_ready` event with this tool. */
115
- placeholder_url: string;
120
+ /** Placeholder URL, used to associate an `image.resolved` event with this tool. */
121
+ placeholder_url?: string;
116
122
  /** Current media-generation status. */
117
- status: "pending" | "completed" | "failed";
118
- /** Approved generated asset URL, once available. */
119
- image_url: string | null;
123
+ status?: "pending" | "completed" | "failed";
124
+ /** Generated asset URL, once available. */
125
+ image_url?: string | null;
120
126
  }
121
- /** A reviewed answer to a clarifying question. Secret-form input is never included. */
127
+ /** An answer to a clarifying question. Secret-form input is never included. */
122
128
  export interface ToolQuestionAnswer {
123
129
  /** Zero-based question index. */
124
130
  question_index?: number;
125
- /** Labels selected by the user. */
131
+ /** Label selected for a single-select question. */
132
+ selected_label?: string;
133
+ /** Labels selected for a multi-select question. */
126
134
  selected_labels?: string[];
127
135
  /** User-provided free-text answer. Structural filtering does not redact prose. */
128
136
  custom_text?: string;
129
137
  }
130
- /** Reviewed clarifying-question input. */
138
+ /** Clarifying-question answers. */
131
139
  export interface ToolQuestionInput {
132
140
  /** Answers supplied to the question card. */
133
- answers: ToolQuestionAnswer[];
141
+ answers?: ToolQuestionAnswer[];
134
142
  }
135
- /** Fixed reviewed completion text. Raw tool results and errors are never included. */
136
- export type ToolOutcome = "Secret configuration completed." | "Package installation completed." | "Plan updated.";
137
143
  /** Why a safety guard parked a call for approval. Only present while the call waits. */
138
144
  export interface ToolGuardApproval {
139
145
  /** Guard identifier, e.g. `exec_tool_send_email` or `bash_approval`. */
140
146
  guard: string;
141
- /** Human-readable reason. Omitted for shell commands, whose reason can quote the command. */
147
+ /** Human-readable reason, for guards whose reason never quotes input (not shell commands). */
142
148
  reason?: string;
143
- /** Reviewed details for the guard; commands and record data are never included. */
149
+ /** The details the guard declares public; commands and record data are never included. */
144
150
  details?: {
145
151
  /** Entity method the code calls, e.g. `delete`. */
146
152
  method?: string;
@@ -158,61 +164,38 @@ export interface ToolGuardApproval {
158
164
  inspection_failed?: boolean;
159
165
  };
160
166
  }
161
- /** A fixed reviewed outcome, reviewed generated-media state, or a guard's approval reason. */
162
- export type ToolResult = ToolOutcome | ToolMediaResult | ToolGuardApproval;
163
- /** Public progress of an existing builder tool. */
167
+ /** Public progress of a builder tool call. Only what the tool and its guard declare public is present. */
164
168
  export interface ToolCall {
165
- /** Stable tool call identifier, when included in the update. */
169
+ /** Stable tool call identifier. */
166
170
  id?: string;
167
- /** Tool name displayed by the builder. */
171
+ /** Tool name. */
168
172
  name?: string;
169
173
  /** Current execution state. */
170
174
  status?: "running" | "success" | "error" | "stopped" | "waiting_for_user_input";
171
175
  /** Whether the tool needs a user response through the partner backend. */
172
176
  requires_user_input?: boolean;
173
- /** Whether the builder auto-approved the reviewed operation. */
174
- auto_approved?: boolean | null;
175
- /** Whether the reviewed mutation was applied. */
177
+ /** Whether the builder auto-approved the operation. */
178
+ auto_approved?: boolean;
179
+ /** Whether the mutation was applied. */
176
180
  mutation_applied?: boolean | null;
177
- /** Existing serialized interaction category; no raw interaction payload. */
181
+ /** Kind of response a parked call waits for. */
178
182
  waiting_on?: {
179
183
  /** Kind of response expected. */
180
- kind?: "approval" | "choice" | "input" | null;
181
- } | null;
182
- /**
183
- * JSON containing one reviewed argument shape: ToolQuestionArguments, ToolSecretArguments,
184
- * ToolPackageArguments, ToolPlanArguments, ToolPrdArguments, or ToolMediaArguments.
185
- * It is omitted for all other tools and malformed/partial streaming arguments.
186
- */
187
- arguments_string?: string;
188
- /** Reviewed activity metadata for file, execution, or entity tools. */
189
- display_projection?: ToolDisplayProjection;
190
- /** Reviewed clarifying-question answers only. */
184
+ kind?: "approval" | "choice" | "input";
185
+ };
186
+ /** The tool's public arguments; absent for tools that declare none and for partial streaming arguments. */
187
+ arguments?: ToolArguments;
188
+ /** What a file, execution or entity tool touched. */
189
+ display?: ToolDisplay;
190
+ /** Clarifying-question answers. */
191
191
  user_input?: ToolQuestionInput;
192
- /** Fixed reviewed success outcome, generated-media state, or a parked call's guard reason. */
193
- results?: ToolResult;
192
+ /** Generated media, once the call is not waiting on a guard: the image tool's state, or a URL alone
193
+ * (a game asset's placeholder, which `image.resolved` replaces, or a finished video). */
194
+ results?: ToolMediaResult | string;
195
+ /** A parked call's guard, and its reason and details where the guard declares them. */
196
+ approval?: ToolGuardApproval;
194
197
  }
195
- /** Public message replacement. Omitted properties are not synthesized by the SDK. */
196
- export interface ChatMessage {
197
- /** Existing message identifier; replace a message with the same identifier. */
198
- id?: string;
199
- /** Public message author category. System messages are never delivered. */
200
- role?: "user" | "assistant";
201
- /** Generated or user-authored text. Structural filtering is not prose redaction. */
202
- content?: string | null;
203
- /** Public tool progress with optional reviewed interaction details. */
204
- tool_calls?: ToolCall[] | null;
205
- /** Message timestamp, without author identity. */
206
- metadata?: {
207
- /** Existing timestamp string. */
208
- created_date?: string | null;
209
- } | null;
210
- /** Existing checkpoint reference; mutations remain on the partner backend. */
211
- checkpoint_id?: string | null;
212
- /** Reviewed scalar message parameters. */
213
- additional_message_params?: MessageParams;
214
- }
215
- /** Reviewed scalar parameters a chat UI needs while a turn runs. */
198
+ /** Scalar parameters a chat UI needs while a turn runs. */
216
199
  export interface MessageParams {
217
200
  /** Identifier the sending client attached, to match its optimistic message. */
218
201
  client_creation_id?: string;
@@ -225,67 +208,95 @@ export interface MessageParams {
225
208
  /** System message category. */
226
209
  system_message_type?: string;
227
210
  }
211
+ /** A public chat message. Replace the message with the same `id` as a whole. */
212
+ export interface ChatMessage {
213
+ /** Message identifier. */
214
+ id?: string;
215
+ /** Author category. System and hidden messages are never delivered. */
216
+ role?: "user" | "assistant";
217
+ /** Message text; structured content is withheld. Structural filtering is not prose redaction. */
218
+ content?: string | null;
219
+ /** Public tool progress. */
220
+ tool_calls?: ToolCall[] | null;
221
+ /** Message timestamp, without author identity. */
222
+ metadata?: {
223
+ /** ISO timestamp string. */
224
+ created_date?: string;
225
+ };
226
+ /** Checkpoint reference; mutations remain on the partner backend. */
227
+ checkpoint_id?: string | null;
228
+ /** Scalar message parameters. */
229
+ additional_message_params?: MessageParams;
230
+ }
228
231
  /** Public builder state, without error diagnostics or billing context. */
229
232
  export interface AppStatus {
230
233
  /** Current builder state. */
231
234
  state?: "ready" | "processing" | "error";
232
- /** Existing state timestamp. */
235
+ /** State timestamp. */
233
236
  last_updated_date?: string | null;
237
+ /** The user message that started the turn, when a turn set this state. Quote it to Base44 support. */
238
+ turn_id?: string | null;
239
+ }
240
+ /** Branch scope carried by app events. Null or absent is the main branch. */
241
+ export interface BranchScoped {
242
+ /** Branch the change belongs to; null is main. */
243
+ branch_id?: string | null;
244
+ }
245
+ /** `message.updated`: a chat message was added or replaced. */
246
+ export interface MessageUpdated extends BranchScoped {
247
+ /** The whole message; replace the one with the same `id`. */
248
+ message: ChatMessage;
249
+ /** Conversation containing the message. */
250
+ conversation_id?: string | null;
251
+ }
252
+ /** `message.removed`: a message was removed or hidden. An `id` the viewer never saw is a no-op. */
253
+ export interface MessageRemoved extends BranchScoped {
254
+ /** Identifier of the message to remove. */
255
+ message_id: string;
256
+ /** Conversation that contained the message. */
257
+ conversation_id?: string | null;
258
+ }
259
+ /** `app.status_changed`: a turn started, finished or failed. */
260
+ export interface AppStatusChanged extends BranchScoped {
261
+ /** The new state; null clears it. */
262
+ status: AppStatus | null;
263
+ }
264
+ /** `preview.navigation_requested`: show this page of the app in the preview. */
265
+ export interface PreviewNavigationRequested extends BranchScoped {
266
+ /** App path to show. */
267
+ path: string;
268
+ /** Navigate even when the user has moved away from the page. */
269
+ force: boolean;
234
270
  }
235
- /** Partial app update. Omitted keys mean unchanged; explicit null means clear. */
236
- export interface AppUpdate {
237
- /** Public builder state. */
238
- status?: AppStatus | null;
239
- /** Whole-message replacement by identifier, not a recursive message patch. */
240
- _last_msg?: ChatMessage | null;
241
- /** Conversation containing the replacement message. */
242
- _last_msg_conversation_id?: string | null;
243
- /** Existing branch scope, if supplied by the producer. */
244
- _scope_branch_id?: string | null;
245
- /** Whether to reload the app preview. */
246
- sandbox_should_reload?: boolean | null;
247
- /** Existing preview navigation target. */
248
- navigate_preview_to?: string | null;
249
- /** Existing forced preview navigation target. */
250
- navigate_preview_force_to?: string | null;
251
- }
252
- /** Public queued builder request. */
271
+ /** A queued builder request. */
253
272
  export interface QueueItem {
254
- /** Stable queue item identifier. */
255
- id: string;
273
+ /** Queue item identifier. */
274
+ id?: string;
256
275
  /** User-authored request text. */
257
- content: string;
258
- /** Existing creation timestamp. */
259
- created_at: string;
260
- /** Existing branch scope. */
276
+ content?: string;
277
+ /** Creation timestamp. */
278
+ created_at?: string;
279
+ /** Branch the request belongs to. */
261
280
  branch_id?: string | null;
262
281
  }
263
- /** Full public queue snapshot, replacing the previous queue. */
264
- export interface QueueUpdate {
265
- /** Canonical app room. */
266
- room: string;
267
- /** App owning this queue. */
268
- app_id: string;
269
- /** Existing branch scope. */
270
- branch_id?: string | null;
271
- /** Current pending items. */
272
- items: QueueItem[];
282
+ /** `queue.updated`: the whole prompt queue, replacing the previous one. */
283
+ export interface QueueUpdated extends BranchScoped {
284
+ /** Pending items. */
285
+ items?: QueueItem[];
273
286
  /** Whether queue processing is paused. */
274
- is_paused: boolean;
287
+ is_paused?: boolean;
275
288
  /** Identifier of the item just processed, when supplied. */
276
289
  processed_item_id?: string | null;
277
290
  }
278
- /** Public tool task progress. */
279
- export interface TaskUpdate {
280
- /** Existing task lifecycle event. */
281
- event_type: "task_started" | "task_progress" | "task_completed" | "task_failed" | "task_cancelled";
291
+ /** `task.progressed`: progress of a long-running tool. */
292
+ export interface TaskProgressed extends BranchScoped {
282
293
  /** Associated tool call. */
283
294
  tool_call_id?: string | null;
284
295
  /** Associated chat message. */
285
296
  message_id?: string | null;
286
- /** Existing branch scope. */
287
- branch_id?: string | null;
288
- /** Numeric progress only; diagnostic/free-text messages are withheld. */
297
+ /** Task lifecycle event, e.g. `task_progress`. */
298
+ event_type?: string | null;
299
+ /** Numeric progress only; diagnostic text is withheld. */
289
300
  progress?: {
290
301
  /** Completed work units. */
291
302
  current?: number | null;
@@ -295,49 +306,49 @@ export interface TaskUpdate {
295
306
  percentage?: number | null;
296
307
  } | null;
297
308
  }
298
- /** Placeholder resolution or image-generation completion. */
299
- export interface ImageReady {
300
- /** Placeholder being resolved. */
301
- placeholder_url: string;
302
- /** Existing generation state. */
303
- status: "pending" | "completed" | "failed";
304
- /** Resolved image URL, or null when unavailable. */
305
- image_url?: string | null;
306
- }
307
- /** Invalidation notice. A main-conversation `conversation_changed` is followed by a snapshot. */
308
- export interface Directive {
309
- /** Canonical app room. */
310
- room: string;
311
- /** Public invalidation category. */
312
- type: "conversation_changed" | "app_files_changed" | "branch_deleted" | "imported_git_changed" | "imported_pull_request_changed";
313
- /** Existing branch scope. */
314
- branch_id?: string | null;
315
- }
316
- /** Mapping of wire event names to decoded public payloads. */
309
+ /** `image.resolved`: a generated image finished or failed. Replace its `placeholder_url` wherever it appears. */
310
+ export type ImageResolved = ToolMediaResult;
311
+ /** Mapping of public event names to their payloads. */
317
312
  export interface PlatformEventMap {
318
- /** Partial builder/app update. */
319
- update_model: AppUpdate;
320
- /** Conversation or file invalidation. */
321
- directive: Directive;
322
- /** Full queue snapshot. */
323
- queue_update: QueueUpdate;
324
- /** Numeric tool progress. */
325
- task_update: TaskUpdate;
326
- /** Image placeholder resolution. */
327
- image_ready: ImageReady;
328
- }
329
- /** Ordered delivery with decoded data and the original event name. */
313
+ /** A chat message was added or replaced. */
314
+ "message.updated": MessageUpdated;
315
+ /** A chat message was removed or hidden. */
316
+ "message.removed": MessageRemoved;
317
+ /** The builder started, finished or failed a turn. */
318
+ "app.status_changed": AppStatusChanged;
319
+ /** Reload the app preview. */
320
+ "preview.reload_requested": BranchScoped;
321
+ /** Show a page of the app in the preview. */
322
+ "preview.navigation_requested": PreviewNavigationRequested;
323
+ /** The whole prompt queue. */
324
+ "queue.updated": QueueUpdated;
325
+ /** Progress of a long-running tool. */
326
+ "task.progressed": TaskProgressed;
327
+ /** A generated image finished or failed. */
328
+ "image.resolved": ImageResolved;
329
+ /** The conversation was rewritten (undo, restore, sync). On main, the SDK rejoins for a fresh snapshot. */
330
+ "conversation.changed": BranchScoped;
331
+ /** The app's files changed outside a chat turn. Re-read them. */
332
+ "files.changed": BranchScoped;
333
+ /** A branch was deleted. */
334
+ "branch.deleted": BranchScoped;
335
+ /** The imported app's repository changed. */
336
+ "repository.changed": BranchScoped;
337
+ /** The imported app's pull request changed. */
338
+ "pull_request.changed": BranchScoped;
339
+ }
340
+ /** Ordered delivery of one public event. */
330
341
  export type PlatformEvent = {
331
342
  [K in keyof PlatformEventMap]: {
332
- /** Original socket event name; narrows the payload type. */
343
+ /** Public event name; narrows the payload type. */
333
344
  type: K;
334
345
  /** Authorized app receiving this event. */
335
346
  appId: string;
336
- /** Decoded payload; existing field names and omission/null semantics are retained. */
347
+ /** Event payload. Omitted keys mean unchanged; explicit null clears. */
337
348
  data: PlatformEventMap[K];
338
349
  };
339
350
  }[keyof PlatformEventMap];
340
- /** An app's current state: sent after each join and rejoin, and after a main-conversation rewrite. */
351
+ /** An app's current state: sent after every join and rejoin, and after a main-conversation rewrite. */
341
352
  export interface Snapshot {
342
353
  /** Canonical app room. */
343
354
  room: string;
@@ -345,4 +356,13 @@ export interface Snapshot {
345
356
  status: AppStatus | null;
346
357
  /** The last 50 public messages, oldest first. */
347
358
  messages: ChatMessage[];
359
+ /** The main branch's prompt queue. Replace it, as with `queue.updated`. Absent from older servers. */
360
+ queue?: SnapshotQueue;
361
+ }
362
+ /** The prompt queue in a snapshot. */
363
+ export interface SnapshotQueue {
364
+ /** Pending items. */
365
+ items: QueueItem[];
366
+ /** Whether queue processing is paused. */
367
+ is_paused: boolean;
348
368
  }
@@ -28,7 +28,7 @@ export interface BuilderSession {
28
28
  /** One app subscription; at most eight may be active per builder session. */
29
29
  export interface SubscriptionOptions {
30
30
  /** Replace this app's state. Arrives after every join and rejoin, and after a main-conversation
31
- * rewrite (undo, restore, sync). Live events may precede it; merge its messages by `id`.
31
+ * rewrite (undo, restore, sync). Live events follow it; it holds only the last 50 messages.
32
32
  */
33
33
  onSnapshot: (snapshot: Snapshot) => void | Promise<void>;
34
34
  /** Apply each live event. Delivery is serial per app; a rejection ends this subscription. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.52-pr.286.2dbb896",
3
+ "version": "0.8.52-pr.286.58a3186",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",