@base44-preview/platform 0.3.0-pr.340.d4da942 → 0.3.0-pr.341.adc3ff5

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 (29) hide show
  1. package/README.md +35 -34
  2. package/dist/client/client.d.ts +5 -5
  3. package/dist/client/client.js +7 -8
  4. package/dist/client/client.types.d.ts +3 -8
  5. package/dist/client/errors.d.ts +3 -3
  6. package/dist/client/errors.js +3 -3
  7. package/dist/client/index.d.ts +3 -4
  8. package/dist/client/modules/{chat-protocol.d.ts → builder-protocol.d.ts} +2 -2
  9. package/dist/client/modules/{chat-protocol.js → builder-protocol.js} +1 -1
  10. package/dist/client/modules/{chat-socket.d.ts → builder-socket.d.ts} +3 -3
  11. package/dist/client/modules/{chat-socket.js → builder-socket.js} +4 -4
  12. package/dist/client/modules/{chat-subscription.d.ts → builder-subscription.d.ts} +2 -2
  13. package/dist/client/modules/builder.d.ts +3 -0
  14. package/dist/client/modules/{chat.events.types.d.ts → builder.events.types.d.ts} +1 -1
  15. package/dist/client/modules/builder.js +7 -0
  16. package/dist/client/modules/{chat.types.d.ts → builder.types.d.ts} +18 -33
  17. package/dist/react/chat-items.d.ts +4 -4
  18. package/dist/react/chat-items.js +3 -3
  19. package/dist/react/chat.types.d.ts +1 -1
  20. package/dist/react/index.d.ts +1 -1
  21. package/dist/react/useBase44Chat.js +4 -4
  22. package/package.json +2 -2
  23. package/dist/client/modules/chat.d.ts +0 -3
  24. package/dist/client/modules/chat.js +0 -7
  25. /package/dist/client/modules/{chat-subscription.js → builder-subscription.js} +0 -0
  26. /package/dist/client/modules/{chat.events.generated.d.ts → builder.events.generated.d.ts} +0 -0
  27. /package/dist/client/modules/{chat.events.generated.js → builder.events.generated.js} +0 -0
  28. /package/dist/client/modules/{chat.events.types.js → builder.events.types.js} +0 -0
  29. /package/dist/client/modules/{chat.types.js → builder.types.js} +0 -0
package/README.md CHANGED
@@ -7,8 +7,8 @@ npm install @base44/platform
7
7
  The Platform SDK for white-label platforms built on Base44. It is independent of the app SDK
8
8
  (`@base44/sdk`) and has two entrypoints:
9
9
 
10
- - `@base44/platform`, for the browser: implements the read-only white-label live AI chat
11
- contract. A partner's browser watches the AI chat of up to eight apps over the platform's
10
+ - `@base44/platform`, for the browser: implements the read-only white-label builder socket
11
+ contract. A partner's browser watches the builder chat of up to eight apps over the platform's
12
12
  shared socket. The workspace must have white-label sockets enabled; this SDK does not open sessions.
13
13
  - `@base44/platform/server`, for your backend: verify the webhooks Base44 sends when apps are
14
14
  created, published, unpublished, trashed or restored. See
@@ -18,24 +18,24 @@ The Platform SDK for white-label platforms built on Base44. It is independent of
18
18
  import { createPlatformClient } from "@base44/platform";
19
19
 
20
20
  const client = createPlatformClient();
21
- const chat = client.chat.init({
22
- // Returns the body of POST /api/service/socket-sessions, unchanged.
21
+ const builder = client.builder.init({
22
+ // Returns the body of POST /api/v1/socket-sessions, unchanged.
23
23
  async getSession() {
24
- const response = await fetch("/api/chat-socket-session", { method: "POST" });
24
+ const response = await fetch("/api/builder-socket-session", { method: "POST" });
25
25
  if (!response.ok) throw new Error("Session request failed");
26
26
  return response.json();
27
27
  },
28
28
  onError(error) { showConnectionError(error.code); },
29
29
  });
30
- const subscription = chat.subscribe(appId, {
30
+ const subscription = builder.subscribe(appId, {
31
31
  onSnapshot(snapshot) { replaceAppState(snapshot); },
32
32
  async onEvent(event) { await applyEvent(event); }, // awaited before the next event
33
33
  onError(error) { showSubscriptionError(error.code); },
34
34
  });
35
- await chat.connect();
35
+ await builder.connect();
36
36
  // On view teardown:
37
37
  subscription.unsubscribe();
38
- chat.close();
38
+ builder.close();
39
39
  ```
40
40
 
41
41
  ## Receiving webhooks (server)
@@ -97,17 +97,18 @@ Delivery is at least once with no ordering guarantee: deduplicate on `event.id`,
97
97
 
98
98
  ## Sessions
99
99
 
100
- `/api/chat-socket-session` is your backend's route, not an SDK endpoint. It opens a
101
- socket session with its workspace key (`apps:watch` scope) through
102
- `POST /api/service/socket-sessions` with `{ app_ids }`, and returns the response body
103
- to the browser. `getSession` returns that body unchanged: the SDK reads `session_token`,
100
+ `/api/builder-socket-session` is your backend's route, not an SDK endpoint. It opens a
101
+ socket session through `POST /api/v1/socket-sessions` with `{ app_ids }`, and returns the
102
+ response body to the browser. It authenticates as `Authorization: Bearer` with either a
103
+ personal access token, which can watch the apps its owner can edit in its workspace, or a
104
+ workspace API key with the `apps:watch` scope. The workspace needs the Builder plan or higher. `getSession` returns that body unchanged: the SDK reads `session_token`,
104
105
  `socket_url` and `socket_path` and ignores other keys such as `session_id` and
105
- `expires_in`. Never pass the workspace key or any other server credential to this client. Subscribe only to apps on the session's allowlist; your
106
- backend adds or removes apps with `PUT`/`DELETE /api/service/socket-sessions/{session_id}/rooms/{app_id}`.
106
+ `expires_in`. Never pass the token, the workspace key or any other server credential to this client. Subscribe only to apps on the session's allowlist; your
107
+ backend adds or removes apps with `PUT`/`DELETE /api/v1/socket-sessions/{session_id}/apps/{app_id}`.
107
108
 
108
109
  A session lasts one hour and is never extended. The token goes exclusively in
109
110
  CONNECT `auth.session_token`, never a URL, and the SDK keeps it in memory only. It
110
- is reused across automatic reconnects. `getSession` is called when a chat
111
+ is reused across automatic reconnects. `getSession` is called when a builder
111
112
  session first connects, and again only when the server rejects the cached token or
112
113
  expires the session; the SDK then reconnects once with the new session. If the new
113
114
  session has a different `socket_url` or `socket_path`, the SDK closes the old socket,
@@ -123,26 +124,26 @@ older one, which stops with `session_replaced`. Open one session per page.
123
124
 
124
125
  `createPlatformClient()` creates a lightweight module container: no Socket.IO
125
126
  instance, timers, session request or network activity. It takes no options. Its
126
- `chat` module follows the server SDK's module-factory pattern.
127
+ `builder` module follows the server SDK's module-factory pattern.
127
128
 
128
- `client.chat.init({ getSession, onError })` synchronously creates an independent
129
- `ChatSession` without connecting or creating a socket. Repeated calls create separate sessions, each owning its own
129
+ `client.builder.init({ getSession, onError })` synchronously creates an independent
130
+ `BuilderSession` without connecting or creating a socket. Repeated calls create separate sessions, each owning its own
130
131
  socket, listeners, subscriptions and cleanup. Close the returned session when its
131
132
  view is disposed; the root client and other sessions remain usable.
132
133
 
133
- `chat.connect()` fetches the first session, creates the socket at its address and
134
+ `builder.connect()` fetches the first session, creates the socket at its address and
134
135
  resolves on CONNECT, before any snapshot. The socket uses the default namespace on the
135
136
  session's `socket_path`, WebSocket only, with a dedicated manager.
136
137
  Transport reconnection uses five attempts, starting at one second and capped at ten
137
138
  seconds with jitter; each attempt has a twenty-second timeout. A temporary server
138
139
  refusal is retried the same way. After exhaustion, a refusal or `session_replaced`,
139
- fix the cause and call `chat.connect()`.
140
+ fix the cause and call `builder.connect()`.
140
141
 
141
- `chat.subscribe(appId, options)` returns a handle with `appId`, `active` and
142
+ `builder.subscribe(appId, options)` returns a handle with `appId`, `active` and
142
143
  idempotent `unsubscribe()`. App IDs are 24 lowercase hexadecimal characters. One
143
- subscription per app and at most eight subscriptions are allowed per chat session.
144
- Subscriptions can be created before connecting. `chat.close()` is terminal for that
145
- session; call `client.chat.init(...)` again to start another.
144
+ subscription per app and at most eight subscriptions are allowed per builder session.
145
+ Subscriptions can be created before connecting. `builder.close()` is terminal for that
146
+ session; call `client.builder.init(...)` again to start another.
146
147
 
147
148
  ## Snapshots and events
148
149
 
@@ -161,15 +162,15 @@ their exceptions are isolated so they cannot interrupt another app's delivery.
161
162
 
162
163
  ## Public shapes
163
164
 
164
- - `PlatformClient` (`client.types.ts`): the `chat` module (`builder` is a deprecated alias).
165
- - `ChatModule` (`modules/chat.types.ts`): lazy `init(options)` factory.
166
- - `ChatInitOptions`: `getSession` and the connection-level `onError` observer.
165
+ - `PlatformClient` (`client.types.ts`): the `builder` module.
166
+ - `BuilderModule` (`modules/builder.types.ts`): lazy `init(options)` factory.
167
+ - `BuilderInitOptions`: `getSession` and the connection-level `onError` observer.
167
168
  - `SocketSession`: the `session_token`, `socket_url` and `socket_path` that `getSession` returns.
168
- - `ChatSession`: `connect()`, `subscribe(appId, options)`, `close()`.
169
+ - `BuilderSession`: `connect()`, `subscribe(appId, options)`, `close()`.
169
170
  - `SubscriptionOptions`: required `onSnapshot`, `onEvent` and `onError`.
170
171
  - `PlatformSubscription`: read-only `appId`, `active`, and `unsubscribe()`.
171
172
  - `PlatformEvent`, `PlatformEventMap`, `PlatformSnapshot`, `ToolCall`, `GuardApproval`
172
- (`modules/chat.events.types.ts`), derived from the generated event types.
173
+ (`modules/builder.events.types.ts`), derived from the generated event types.
173
174
  - Error codes in `errors.types.ts`.
174
175
 
175
176
  `PlatformEvent` is a **discriminated union**: switch on `event.type` to narrow
@@ -186,7 +187,7 @@ redaction of generated prose or user content.
186
187
  ## Event types
187
188
 
188
189
  The socket protocol is defined by the service's AsyncAPI document, committed as
189
- `asyncapi.json`. `src/client/modules/chat.events.generated.ts` is generated from it with
190
+ `asyncapi.json`. `src/client/modules/builder.events.generated.ts` is generated from it with
190
191
  `json-schema-to-typescript`: one type per schema, named after the backend model
191
192
  (`Message`, `StatusObject`, `QueueState`, one `*Call` per tool, one `*Approval` per
192
193
  guard), plus `ServerEventMap` and `ClientMessageMap`. Never edit it by hand.
@@ -229,16 +230,16 @@ exceptions, payloads and credentials are never attached.
229
230
  | `delivery_overflow` | 1,000 deliveries queued for the app; subscribe again for a fresh snapshot. |
230
231
  | `protocol_error` | Invalid routing or envelope. Stop and investigate. |
231
232
  | `handler_failed` | An application callback failed; fix it and subscribe again. |
232
- | `client_closed` | The chat session was explicitly closed; initialize another session. |
233
+ | `client_closed` | The builder session was explicitly closed; initialize another session. |
233
234
 
234
235
  No SDK dependency, package version or lockfile changes are required. Socket.IO
235
236
  remains the existing SDK dependency. Chat commands and HTTP APIs are outside this entry point.
236
237
 
237
238
  ## React
238
239
 
239
- `@base44/platform/react` adds one hook, `useBase44Chat`, that runs the AI chat for one
240
+ `@base44/platform/react` adds one hook, `useBase44Chat`, that runs a builder chat for one
240
241
  app on top of this client: it opens the live session and renews it, turns messages into items
241
- made for rendering, binds every question the AI asks to the step it belongs to. It renders nothing. React is an optional peer dependency, loaded only by this
242
+ made for rendering, binds every question the builder asks to the step it belongs to. It renders nothing. React is an optional peer dependency, loaded only by this
242
243
  entry; the root entry stays framework-free.
243
244
 
244
245
  ```tsx
@@ -258,5 +259,5 @@ call with your credentials, so the browser never holds a key. The hook returns `
258
259
  the first, and the chat watches it while `appId` is `null`. A sent prompt shows at once as a
259
260
  `pending` item until Base44's own message arrives; a prompt sent mid-build waits in Base44's
260
261
  queue meanwhile. A question is a union on `kind` (`choice`, `secrets`, `approval`) and carries only the
261
- actions its kind allows, and declining is always one of them. As in Base44's app editor, only the
262
+ actions its kind allows, and declining is always one of them. As in Base44's builder, only the
262
263
  last assistant message makes the chat wait; a kind this release doesn't know is declined for you. Every shape has JSDoc in `src/react/chat.types.ts`.
@@ -3,8 +3,8 @@ import type { PlatformClient } from "./client.types.js";
3
3
  * Creates a platform client.
4
4
  *
5
5
  * This is the entry point of the Platform SDK. The client gives your white-label app editor
6
- * access to the platform's modules, such as [`chat`](/developers/references/platform-sdk/docs/interfaces/chat).
7
- * It takes no options and opens nothing: each chat session gets its socket session from the
6
+ * access to the platform's modules, such as [`builder`](/developers/references/platform-sdk/docs/interfaces/builder).
7
+ * It takes no options and opens nothing: each builder session gets its socket session from the
8
8
  * `getSession` you pass to `init()`.
9
9
  *
10
10
  * @returns A platform client with access to the platform's modules.
@@ -17,14 +17,14 @@ import type { PlatformClient } from "./client.types.js";
17
17
  * const client = createPlatformClient();
18
18
  *
19
19
  * // Use the client to follow the AI chat in an app
20
- * const chat = client.chat.init({
20
+ * const builder = client.builder.init({
21
21
  * async getSession() {
22
- * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
22
+ * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
23
23
  * return response.json();
24
24
  * },
25
25
  * onError: (error) => console.error(error.code),
26
26
  * });
27
- * await chat.connect();
27
+ * await builder.connect();
28
28
  * ```
29
29
  */
30
30
  export declare function createPlatformClient(): PlatformClient;
@@ -1,10 +1,10 @@
1
- import { createChat } from "./modules/chat.js";
1
+ import { createBuilder } from "./modules/builder.js";
2
2
  /**
3
3
  * Creates a platform client.
4
4
  *
5
5
  * This is the entry point of the Platform SDK. The client gives your white-label app editor
6
- * access to the platform's modules, such as [`chat`](/developers/references/platform-sdk/docs/interfaces/chat).
7
- * It takes no options and opens nothing: each chat session gets its socket session from the
6
+ * access to the platform's modules, such as [`builder`](/developers/references/platform-sdk/docs/interfaces/builder).
7
+ * It takes no options and opens nothing: each builder session gets its socket session from the
8
8
  * `getSession` you pass to `init()`.
9
9
  *
10
10
  * @returns A platform client with access to the platform's modules.
@@ -17,17 +17,16 @@ import { createChat } from "./modules/chat.js";
17
17
  * const client = createPlatformClient();
18
18
  *
19
19
  * // Use the client to follow the AI chat in an app
20
- * const chat = client.chat.init({
20
+ * const builder = client.builder.init({
21
21
  * async getSession() {
22
- * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
22
+ * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
23
23
  * return response.json();
24
24
  * },
25
25
  * onError: (error) => console.error(error.code),
26
26
  * });
27
- * await chat.connect();
27
+ * await builder.connect();
28
28
  * ```
29
29
  */
30
30
  export function createPlatformClient() {
31
- const chat = Object.freeze(createChat());
32
- return Object.freeze({ chat, builder: chat });
31
+ return Object.freeze({ builder: Object.freeze(createBuilder()) });
33
32
  }
@@ -1,15 +1,10 @@
1
- import type { ChatModule } from "./modules/chat.types.js";
1
+ import type { BuilderModule } from "./modules/builder.types.js";
2
2
  /**
3
3
  * The platform client.
4
4
  *
5
5
  * Provides access to the platform's modules.
6
6
  */
7
7
  export interface PlatformClient {
8
- /** [Chat module](/developers/references/platform-sdk/docs/interfaces/chat) for following the AI chat in your users' apps live. */
9
- readonly chat: ChatModule;
10
- /**
11
- * @deprecated Renamed to {@linkcode chat}, the same module. Removed in 1.0.
12
- * @hidden
13
- */
14
- readonly builder: ChatModule;
8
+ /** [Builder module](/developers/references/platform-sdk/docs/interfaces/builder) for following the AI chat in your users' apps live. */
9
+ readonly builder: BuilderModule;
15
10
  }
@@ -1,6 +1,6 @@
1
1
  import type { PlatformSocketErrorCode } from "./errors.types.js";
2
2
  /**
3
- * The error the SDK reports when something goes wrong in a chat session.
3
+ * The error the SDK reports when something goes wrong in a builder session.
4
4
  *
5
5
  * You don't create it. The SDK passes it to your `onError` callbacks, `connect()` rejects with it,
6
6
  * and `subscribe()` throws it. Check `code` to see what happened, then look the code up below:
@@ -14,14 +14,14 @@ import type { PlatformSocketErrorCode } from "./errors.types.js";
14
14
  * @example
15
15
  * ```typescript
16
16
  * // Handle session and app errors
17
- * const chat = client.chat.init({
17
+ * const builder = client.builder.init({
18
18
  * // Session error codes: the whole session is affected
19
19
  * onError(error) {
20
20
  * if (error.code === 'session_revoked') showSignedOut();
21
21
  * },
22
22
  * });
23
23
  *
24
- * chat.subscribe(appId, {
24
+ * builder.subscribe(appId, {
25
25
  * onSnapshot: renderChat,
26
26
  * onEvent: applyEvent,
27
27
  * // App error codes: only this app is affected, and error.appId says which
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The error the SDK reports when something goes wrong in a chat session.
2
+ * The error the SDK reports when something goes wrong in a builder session.
3
3
  *
4
4
  * You don't create it. The SDK passes it to your `onError` callbacks, `connect()` rejects with it,
5
5
  * and `subscribe()` throws it. Check `code` to see what happened, then look the code up below:
@@ -13,14 +13,14 @@
13
13
  * @example
14
14
  * ```typescript
15
15
  * // Handle session and app errors
16
- * const chat = client.chat.init({
16
+ * const builder = client.builder.init({
17
17
  * // Session error codes: the whole session is affected
18
18
  * onError(error) {
19
19
  * if (error.code === 'session_revoked') showSignedOut();
20
20
  * },
21
21
  * });
22
22
  *
23
- * chat.subscribe(appId, {
23
+ * builder.subscribe(appId, {
24
24
  * onSnapshot: renderChat,
25
25
  * onEvent: applyEvent,
26
26
  * // App error codes: only this app is affected, and error.appId says which
@@ -3,7 +3,6 @@ export { createPlatformClient } from "./client.js";
3
3
  export { PlatformSocketError } from "./errors.js";
4
4
  export type { AppErrorCode, PlatformSocketErrorCode, SessionErrorCode } from "./errors.types.js";
5
5
  export type { PlatformClient } from "./client.types.js";
6
- export type { ChatModule, ChatInitOptions, ChatSession, PlatformSubscription, SocketSession, SubscriptionOptions } from "./modules/chat.types.js";
7
- export type { BuilderInitOptions, BuilderModule, BuilderSession } from "./modules/chat.types.js";
8
- export type { GuardApproval, PlatformEvent, PlatformEventMap, PlatformSnapshot, ToolCall } from "./modules/chat.events.types.js";
9
- export type * from "./modules/chat.events.generated.js";
6
+ export type { BuilderModule, BuilderInitOptions, BuilderSession, PlatformSubscription, SocketSession, SubscriptionOptions } from "./modules/builder.types.js";
7
+ export type { GuardApproval, PlatformEvent, PlatformEventMap, PlatformSnapshot, ToolCall } from "./modules/builder.events.types.js";
8
+ export type * from "./modules/builder.events.generated.js";
@@ -1,5 +1,5 @@
1
- import type { PlatformEvent, PlatformSnapshot } from "./chat.events.types.js";
2
- import type { SocketSession } from "./chat.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./builder.events.types.js";
2
+ import type { SocketSession } from "./builder.types.js";
3
3
  /** App events delivered to `onEvent`: every server event except the session events the socket handles. */
4
4
  export declare const eventNames: ("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")[];
5
5
  /** A name newer than this SDK's protocol, delivered to `onEvent` as `unknown`. New `room.*` notices have no error code, so they are dropped. */
@@ -1,4 +1,4 @@
1
- import { serverEventNames } from "./chat.events.generated.js";
1
+ import { serverEventNames } from "./builder.events.generated.js";
2
2
  const sessionEvents = ["app.snapshot", "session.ended"];
3
3
  /** App events delivered to `onEvent`: every server event except the session events the socket handles. */
4
4
  export const eventNames = serverEventNames.filter((name) => !sessionEvents.includes(name) && !name.startsWith("room."));
@@ -1,6 +1,6 @@
1
- import type { ChatInitOptions, ChatSession, PlatformSubscription, SubscriptionOptions } from "./chat.types.js";
1
+ import type { BuilderInitOptions, BuilderSession, PlatformSubscription, SubscriptionOptions } from "./builder.types.js";
2
2
  /** @internal */
3
- export declare class ChatSocket implements ChatSession {
3
+ export declare class BuilderSocket implements BuilderSession {
4
4
  private socket?;
5
5
  private address?;
6
6
  private readonly subscriptions;
@@ -16,7 +16,7 @@ export declare class ChatSocket implements ChatSession {
16
16
  private connecting?;
17
17
  private resolveConnect?;
18
18
  private rejectConnect?;
19
- constructor(options: ChatInitOptions);
19
+ constructor(options: BuilderInitOptions);
20
20
  /** Connect with the session's token. Resolves on CONNECT, before snapshots arrive.
21
21
  * The first call fetches the session, whose address the socket opens on.
22
22
  * Transport loss retries up to five times and rejoins active subscriptions.
@@ -1,10 +1,10 @@
1
1
  import { io } from "socket.io-client";
2
2
  import { PlatformSocketError } from "../errors.js";
3
- import { appFromRoom, appPattern, decode, decodeSession, decodeSnapshot, eventNames, isUnknownEvent, object, roomFor, roomNotices, sessionEndings } from "./chat-protocol.js";
4
- import { notify, Subscription } from "./chat-subscription.js";
3
+ import { appFromRoom, appPattern, decode, decodeSession, decodeSnapshot, eventNames, isUnknownEvent, object, roomFor, roomNotices, sessionEndings } from "./builder-protocol.js";
4
+ import { notify, Subscription } from "./builder-subscription.js";
5
5
  const MAX_DENIAL_RETRIES = 5;
6
6
  /** @internal */
7
- export class ChatSocket {
7
+ export class BuilderSocket {
8
8
  constructor(options) {
9
9
  this.subscriptions = new Map();
10
10
  this.closed = false;
@@ -48,7 +48,7 @@ export class ChatSocket {
48
48
  if (!appPattern.test(appId))
49
49
  throw new TypeError("appId must be 24 lowercase hexadecimal characters");
50
50
  if (this.subscriptions.has(appId))
51
- throw new TypeError("An app may only have one subscription per chat session");
51
+ throw new TypeError("An app may only have one subscription per builder session");
52
52
  if (this.subscriptions.size >= 8)
53
53
  throw new PlatformSocketError("subscription_limit", appId);
54
54
  const subscription = new Subscription(appId, { ...options }, () => {
@@ -1,7 +1,7 @@
1
- import type { PlatformEvent, PlatformSnapshot } from "./chat.events.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./builder.events.types.js";
2
2
  import { PlatformSocketError } from "../errors.js";
3
3
  import type { PlatformSocketErrorCode } from "../errors.types.js";
4
- import type { PlatformSubscription, SubscriptionOptions } from "./chat.types.js";
4
+ import type { PlatformSubscription, SubscriptionOptions } from "./builder.types.js";
5
5
  /** @internal */
6
6
  export declare function notify(callback: (error: PlatformSocketError) => void, error: PlatformSocketError): void;
7
7
  /** @internal */
@@ -0,0 +1,3 @@
1
+ import type { BuilderModule } from "./builder.types.js";
2
+ /** @internal */
3
+ export declare function createBuilder(): BuilderModule;
@@ -1,4 +1,4 @@
1
- import type { Message, QueueState, ServerEventMap, Snapshot } from "./chat.events.generated.js";
1
+ import type { Message, QueueState, ServerEventMap, Snapshot } from "./builder.events.generated.js";
2
2
  /**
3
3
  * Maps each live event name to the type of its `data` payload.
4
4
  *
@@ -0,0 +1,7 @@
1
+ import { BuilderSocket } from "./builder-socket.js";
2
+ /** @internal */
3
+ export function createBuilder() {
4
+ return {
5
+ init(options) { return new BuilderSocket(options); },
6
+ };
7
+ }
@@ -1,4 +1,4 @@
1
- import type { PlatformEvent, PlatformSnapshot } from "./chat.events.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./builder.events.types.js";
2
2
  import type { PlatformSocketError } from "../errors.js";
3
3
  /**
4
4
  * The socket session your server opened, as [Create socket session](/api-reference/create-socket-session) returned it.
@@ -14,8 +14,8 @@ export interface SocketSession {
14
14
  /** Absolute path the socket connects on, such as `/ws/socket.io/`. */
15
15
  socket_path: string;
16
16
  }
17
- /** Options for {@linkcode ChatModule.init | init()}. */
18
- export interface ChatInitOptions {
17
+ /** Options for {@linkcode BuilderModule.init | init()}. */
18
+ export interface BuilderInitOptions {
19
19
  /**
20
20
  * Returns a new socket session from your server.
21
21
  *
@@ -36,7 +36,7 @@ export interface ChatInitOptions {
36
36
  onError: (error: PlatformSocketError) => void;
37
37
  }
38
38
  /**
39
- * Chat module for following the AI chat in your users' apps live.
39
+ * Builder module for following the AI chat in your users' apps live.
40
40
  *
41
41
  * Each session holds one socket and up to eight app subscriptions. For each app you get a
42
42
  * snapshot of its chat, then every change as it happens:
@@ -46,11 +46,11 @@ export interface ChatInitOptions {
46
46
  *
47
47
  * The module does nothing until you call {@linkcode init | init()}.
48
48
  */
49
- export interface ChatModule {
49
+ export interface BuilderModule {
50
50
  /**
51
- * Creates a chat session without connecting it.
51
+ * Creates a builder session without connecting it.
52
52
  *
53
- * Call {@linkcode ChatSession.connect | connect()} on the returned session to open the socket.
53
+ * Call {@linkcode BuilderSession.connect | connect()} on the returned session to open the socket.
54
54
  * Each session is independent, with its own socket, socket session and subscriptions.
55
55
  *
56
56
  * @param options - Session options.
@@ -59,25 +59,25 @@ export interface ChatModule {
59
59
  * @example
60
60
  * ```typescript
61
61
  * // Create and connect a session
62
- * const chat = client.chat.init({
62
+ * const builder = client.builder.init({
63
63
  * async getSession() {
64
- * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
64
+ * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
65
65
  * return response.json();
66
66
  * },
67
67
  * onError(error) {
68
- * console.error('Chat session error', error.code);
68
+ * console.error('Builder session error', error.code);
69
69
  * },
70
70
  * });
71
- * await chat.connect();
71
+ * await builder.connect();
72
72
  * ```
73
73
  */
74
- init(options: ChatInitOptions): ChatSession;
74
+ init(options: BuilderInitOptions): BuilderSession;
75
75
  }
76
76
  /**
77
- * A `ChatSession`: one socket with its app subscriptions and its reconnection. Use its methods
77
+ * A `BuilderSession`: one socket with its app subscriptions and its reconnection. Use its methods
78
78
  * to connect, follow apps and close.
79
79
  */
80
- export interface ChatSession {
80
+ export interface BuilderSession {
81
81
  /**
82
82
  * Connects the session's socket.
83
83
  *
@@ -94,7 +94,7 @@ export interface ChatSession {
94
94
  * ```typescript
95
95
  * // Connect and handle failure
96
96
  * try {
97
- * await chat.connect();
97
+ * await builder.connect();
98
98
  * } catch (error) {
99
99
  * console.error('Could not connect', error.code);
100
100
  * }
@@ -121,7 +121,7 @@ export interface ChatSession {
121
121
  * @example
122
122
  * ```typescript
123
123
  * // Follow an app
124
- * const subscription = chat.subscribe(appId, {
124
+ * const subscription = builder.subscribe(appId, {
125
125
  * onSnapshot(snapshot) {
126
126
  * renderChat(snapshot.messages);
127
127
  * },
@@ -139,13 +139,13 @@ export interface ChatSession {
139
139
  * Closes the session.
140
140
  *
141
141
  * Ends every subscription, stops reconnecting and disconnects the socket. Calling it again does
142
- * nothing. A closed session can't be reused, so call [`init()`](/developers/references/platform-sdk/docs/interfaces/chat#init)
142
+ * nothing. A closed session can't be reused, so call [`init()`](/developers/references/platform-sdk/docs/interfaces/builder#init)
143
143
  * for a new one.
144
144
  *
145
145
  * @example
146
146
  * ```typescript
147
147
  * // Close a session
148
- * chat.close();
148
+ * builder.close();
149
149
  * ```
150
150
  */
151
151
  close(): void;
@@ -191,18 +191,3 @@ export interface PlatformSubscription {
191
191
  */
192
192
  unsubscribe(): void;
193
193
  }
194
- /**
195
- * @deprecated Renamed to {@linkcode ChatModule}. Removed in 1.0.
196
- * @hidden
197
- */
198
- export type BuilderModule = ChatModule;
199
- /**
200
- * @deprecated Renamed to {@linkcode ChatSession}. Removed in 1.0.
201
- * @hidden
202
- */
203
- export type BuilderSession = ChatSession;
204
- /**
205
- * @deprecated Renamed to {@linkcode ChatInitOptions}. Removed in 1.0.
206
- * @hidden
207
- */
208
- export type BuilderInitOptions = ChatInitOptions;
@@ -1,5 +1,5 @@
1
- import type { Message } from "../client/modules/chat.events.generated.js";
2
- import type { ToolCall } from "../client/modules/chat.events.types.js";
1
+ import type { Message } from "../client/modules/builder.events.generated.js";
2
+ import type { ToolCall } from "../client/modules/builder.events.types.js";
3
3
  import type { ChatItem, ChatQuestion, ChatStep } from "./chat.types.js";
4
4
  /** @internal Sends the answer to the one tool call a question belongs to. */
5
5
  export type AnswerToolCall = (approve: boolean, extraUserInput?: Record<string, unknown>) => Promise<void>;
@@ -20,7 +20,7 @@ export declare function mergeSnapshot(heldMessages: Message[], snapshotMessages:
20
20
  export declare function toItems(sortedMessages: Message[], answeredToolCallIds: string[], submitAnswer: SubmitAnswer): ChatItem[];
21
21
  /** @internal Base44's tool call status, as a step's. */
22
22
  export declare function stepStatus(toolCall: ToolCall): ChatStep["status"];
23
- /** @internal Whether the chat waits on the user. Like Base44's app editor, only the last turn reply
23
+ /** @internal Whether the chat waits on the user. Like Base44's builder, only the last turn reply
24
24
  * counts, and a call answered or declined here stops counting. */
25
25
  export declare function isWaitingForUser(sortedMessages: Message[], answeredToolCallIds: string[]): boolean;
26
26
  /** @internal Waiting calls on the last turn reply whose kind Base44 names and this release doesn't
@@ -46,6 +46,6 @@ export declare function settlePendingPrompts(pendingPrompts: PendingPrompt[], ap
46
46
  export declare function pendingPromptItems(pendingPrompts: PendingPrompt[]): ChatItem[];
47
47
  /** @internal Base44's question formats, as one simple shape per kind, each bound to the call that
48
48
  * answers it. Base44 keys choice answers by position, so `picked` and `texts` follow `questions`,
49
- * and like Base44's app editor a single pick goes in `selected_label`, several in `selected_labels`,
49
+ * and like Base44's builder a single pick goes in `selected_label`, several in `selected_labels`,
50
50
  * and free text in `custom_text`. A kind this release doesn't know has no shape. */
51
51
  export declare function toQuestion(toolCall: ToolCall, answerToolCall: AnswerToolCall): ChatQuestion | undefined;
@@ -27,7 +27,7 @@ function isTurnReply(message) {
27
27
  var _a;
28
28
  return (message === null || message === void 0 ? void 0 : message.role) === "assistant" && !((_a = message.additional_message_params) === null || _a === void 0 ? void 0 : _a.skip_ai_response);
29
29
  }
30
- /** @internal The last assistant message that answers a turn, as Base44's app editor finds it. */
30
+ /** @internal The last assistant message that answers a turn, as Base44's own builder finds it. */
31
31
  function lastTurnReply(sortedMessages) {
32
32
  return [...sortedMessages].reverse().find(isTurnReply);
33
33
  }
@@ -110,7 +110,7 @@ export function stepStatus(toolCall) {
110
110
  return "error";
111
111
  return "done";
112
112
  }
113
- /** @internal Whether the chat waits on the user. Like Base44's app editor, only the last turn reply
113
+ /** @internal Whether the chat waits on the user. Like Base44's builder, only the last turn reply
114
114
  * counts, and a call answered or declined here stops counting. */
115
115
  export function isWaitingForUser(sortedMessages, answeredToolCallIds) {
116
116
  var _a;
@@ -155,7 +155,7 @@ export function pendingPromptItems(pendingPrompts) {
155
155
  }
156
156
  /** @internal Base44's question formats, as one simple shape per kind, each bound to the call that
157
157
  * answers it. Base44 keys choice answers by position, so `picked` and `texts` follow `questions`,
158
- * and like Base44's app editor a single pick goes in `selected_label`, several in `selected_labels`,
158
+ * and like Base44's builder a single pick goes in `selected_label`, several in `selected_labels`,
159
159
  * and free text in `custom_text`. A kind this release doesn't know has no shape. */
160
160
  export function toQuestion(toolCall, answerToolCall) {
161
161
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -1,4 +1,4 @@
1
- import type { SocketSession } from "../client/modules/chat.types.js";
1
+ import type { SocketSession } from "../client/modules/builder.types.js";
2
2
  /** An app the AI chat works on. */
3
3
  export interface Base44App {
4
4
  /** ID of the app, 24 lowercase hexadecimal characters. */
@@ -1,4 +1,4 @@
1
1
  /** The `@base44/platform/react` entry: the AI chat for one app, as a React hook. React is an optional peer, loaded only here. */
2
2
  export { useBase44Chat } from "./useBase44Chat.js";
3
3
  export type { ApprovalDetails, ApprovalQuestion, Base44App, Base44Chat, Base44ChatOptions, Base44ChatBackend, ChatAnswer, ChatConnection, ChatError, ChatItem, ChatQuestion, ChatStatus, ChatStep, ChoiceEntry, ChoiceQuestion, SecretField, SecretsQuestion, ToolCallAnswer, } from "./chat.types.js";
4
- export type { SocketSession } from "../client/modules/chat.types.js";
4
+ export type { SocketSession } from "../client/modules/builder.types.js";
@@ -168,7 +168,7 @@ export function useBase44Chat({ appId, backend, onAppCreated }) {
168
168
  // The client asks for a session on the first connect and whenever one expires, and forwards
169
169
  // no detail of a failed call, so the backend's own error is kept to report.
170
170
  let lastSessionError;
171
- const chatSession = createPlatformClient().chat.init({
171
+ const builderSession = createPlatformClient().builder.init({
172
172
  getSession: () => backendRef.current.openLiveSession(followedAppId).then(socketSession => {
173
173
  lastSessionError = undefined;
174
174
  return socketSession;
@@ -185,7 +185,7 @@ export function useBase44Chat({ appId, backend, onAppCreated }) {
185
185
  setConnection("disconnected");
186
186
  },
187
187
  });
188
- chatSession.subscribe(followedAppId, {
188
+ builderSession.subscribe(followedAppId, {
189
189
  onSnapshot: snapshot => {
190
190
  // A snapshot holds old prompts too, so only an exact match settles one.
191
191
  handleIncomingMessages(snapshot.messages);
@@ -220,10 +220,10 @@ export function useBase44Chat({ appId, backend, onAppCreated }) {
220
220
  onError: error => (error.code === "snapshot_unavailable" ? reportConnectionError(error) : endLiveUpdates(error)),
221
221
  });
222
222
  // A failed connect also reaches onError, which reports it.
223
- chatSession.connect().catch(() => { });
223
+ builderSession.connect().catch(() => { });
224
224
  return () => {
225
225
  closed = true;
226
- chatSession.close();
226
+ builderSession.close();
227
227
  };
228
228
  }, [currentAppId]);
229
229
  // Answers one tool call. Its id leaves the answered list again if the submit fails, so the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@base44-preview/platform",
3
- "version": "0.3.0-pr.340.d4da942",
4
- "description": "Base44 Platform SDK for white-label platforms: a browser client for following the AI chat and a server entrypoint for webhooks",
3
+ "version": "0.3.0-pr.341.adc3ff5",
4
+ "description": "Base44 Platform SDK for white-label platforms: a browser client for watching the builder and a server entrypoint for webhooks",
5
5
  "main": "dist/client/index.js",
6
6
  "types": "dist/client/index.d.ts",
7
7
  "type": "module",
@@ -1,3 +0,0 @@
1
- import type { ChatModule } from "./chat.types.js";
2
- /** @internal */
3
- export declare function createChat(): ChatModule;
@@ -1,7 +0,0 @@
1
- import { ChatSocket } from "./chat-socket.js";
2
- /** @internal */
3
- export function createChat() {
4
- return {
5
- init(options) { return new ChatSocket(options); },
6
- };
7
- }