@base44-preview/platform 0.3.0-pr.338.12ff73f → 0.3.0-pr.338.9cd34e2

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 (31) hide show
  1. package/README.md +28 -28
  2. package/dist/client/client.d.ts +5 -5
  3. package/dist/client/client.js +7 -7
  4. package/dist/client/client.types.d.ts +3 -3
  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 -3
  8. package/dist/client/modules/{builder-protocol.d.ts → chat-protocol.d.ts} +2 -2
  9. package/dist/client/modules/{builder-protocol.js → chat-protocol.js} +1 -1
  10. package/dist/client/modules/{builder-socket.d.ts → chat-socket.d.ts} +3 -3
  11. package/dist/client/modules/{builder-socket.js → chat-socket.js} +4 -4
  12. package/dist/client/modules/{builder-subscription.d.ts → chat-subscription.d.ts} +2 -2
  13. package/dist/client/modules/chat.d.ts +3 -0
  14. package/dist/client/modules/{builder.events.types.d.ts → chat.events.types.d.ts} +1 -1
  15. package/dist/client/modules/chat.js +7 -0
  16. package/dist/client/modules/{builder.types.d.ts → chat.types.d.ts} +18 -18
  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/dist/server/modules/webhooks.events.generated.d.ts +12 -12
  23. package/dist/server/modules/webhooks.events.generated.js +1 -1
  24. package/package.json +2 -2
  25. package/dist/client/modules/builder.d.ts +0 -3
  26. package/dist/client/modules/builder.js +0 -7
  27. /package/dist/client/modules/{builder-subscription.js → chat-subscription.js} +0 -0
  28. /package/dist/client/modules/{builder.events.generated.d.ts → chat.events.generated.d.ts} +0 -0
  29. /package/dist/client/modules/{builder.events.generated.js → chat.events.generated.js} +0 -0
  30. /package/dist/client/modules/{builder.events.types.js → chat.events.types.js} +0 -0
  31. /package/dist/client/modules/{builder.types.js → chat.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 builder socket
11
- contract. A partner's browser watches the builder chat of up to eight apps over the platform's
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
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 builder = client.builder.init({
21
+ const chat = client.chat.init({
22
22
  // Returns the body of POST /api/service/socket-sessions, unchanged.
23
23
  async getSession() {
24
- const response = await fetch("/api/builder-socket-session", { method: "POST" });
24
+ const response = await fetch("/api/chat-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 = builder.subscribe(appId, {
30
+ const subscription = chat.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 builder.connect();
35
+ await chat.connect();
36
36
  // On view teardown:
37
37
  subscription.unsubscribe();
38
- builder.close();
38
+ chat.close();
39
39
  ```
40
40
 
41
41
  ## Receiving webhooks (server)
@@ -97,7 +97,7 @@ Delivery is at least once with no ordering guarantee: deduplicate on `event.id`,
97
97
 
98
98
  ## Sessions
99
99
 
100
- `/api/builder-socket-session` is your backend's route, not an SDK endpoint. It opens a
100
+ `/api/chat-socket-session` is your backend's route, not an SDK endpoint. It opens a
101
101
  socket session with its workspace key (`apps:watch` scope) through
102
102
  `POST /api/service/socket-sessions` with `{ app_ids }`, and returns the response body
103
103
  to the browser. `getSession` returns that body unchanged: the SDK reads `session_token`,
@@ -107,7 +107,7 @@ backend adds or removes apps with `PUT`/`DELETE /api/service/socket-sessions/{se
107
107
 
108
108
  A session lasts one hour and is never extended. The token goes exclusively in
109
109
  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 builder
110
+ is reused across automatic reconnects. `getSession` is called when a chat
111
111
  session first connects, and again only when the server rejects the cached token or
112
112
  expires the session; the SDK then reconnects once with the new session. If the new
113
113
  session has a different `socket_url` or `socket_path`, the SDK closes the old socket,
@@ -123,26 +123,26 @@ older one, which stops with `session_replaced`. Open one session per page.
123
123
 
124
124
  `createPlatformClient()` creates a lightweight module container: no Socket.IO
125
125
  instance, timers, session request or network activity. It takes no options. Its
126
- `builder` module follows the server SDK's module-factory pattern.
126
+ `chat` module follows the server SDK's module-factory pattern.
127
127
 
128
- `client.builder.init({ getSession, onError })` synchronously creates an independent
129
- `BuilderSession` without connecting or creating a socket. Repeated calls create separate sessions, each owning its own
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
130
130
  socket, listeners, subscriptions and cleanup. Close the returned session when its
131
131
  view is disposed; the root client and other sessions remain usable.
132
132
 
133
- `builder.connect()` fetches the first session, creates the socket at its address and
133
+ `chat.connect()` fetches the first session, creates the socket at its address and
134
134
  resolves on CONNECT, before any snapshot. The socket uses the default namespace on the
135
135
  session's `socket_path`, WebSocket only, with a dedicated manager.
136
136
  Transport reconnection uses five attempts, starting at one second and capped at ten
137
137
  seconds with jitter; each attempt has a twenty-second timeout. A temporary server
138
138
  refusal is retried the same way. After exhaustion, a refusal or `session_replaced`,
139
- fix the cause and call `builder.connect()`.
139
+ fix the cause and call `chat.connect()`.
140
140
 
141
- `builder.subscribe(appId, options)` returns a handle with `appId`, `active` and
141
+ `chat.subscribe(appId, options)` returns a handle with `appId`, `active` and
142
142
  idempotent `unsubscribe()`. App IDs are 24 lowercase hexadecimal characters. One
143
- subscription per app and at most eight subscriptions are allowed per builder session.
144
- Subscriptions can be created before connecting. `builder.close()` is terminal for that
145
- session; call `client.builder.init(...)` again to start another.
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.
146
146
 
147
147
  ## Snapshots and events
148
148
 
@@ -161,15 +161,15 @@ their exceptions are isolated so they cannot interrupt another app's delivery.
161
161
 
162
162
  ## Public shapes
163
163
 
164
- - `PlatformClient` (`client.types.ts`): the `builder` module.
165
- - `BuilderModule` (`modules/builder.types.ts`): lazy `init(options)` factory.
166
- - `BuilderInitOptions`: `getSession` and the connection-level `onError` observer.
164
+ - `PlatformClient` (`client.types.ts`): the `chat` module.
165
+ - `ChatModule` (`modules/chat.types.ts`): lazy `init(options)` factory.
166
+ - `ChatInitOptions`: `getSession` and the connection-level `onError` observer.
167
167
  - `SocketSession`: the `session_token`, `socket_url` and `socket_path` that `getSession` returns.
168
- - `BuilderSession`: `connect()`, `subscribe(appId, options)`, `close()`.
168
+ - `ChatSession`: `connect()`, `subscribe(appId, options)`, `close()`.
169
169
  - `SubscriptionOptions`: required `onSnapshot`, `onEvent` and `onError`.
170
170
  - `PlatformSubscription`: read-only `appId`, `active`, and `unsubscribe()`.
171
171
  - `PlatformEvent`, `PlatformEventMap`, `PlatformSnapshot`, `ToolCall`, `GuardApproval`
172
- (`modules/builder.events.types.ts`), derived from the generated event types.
172
+ (`modules/chat.events.types.ts`), derived from the generated event types.
173
173
  - Error codes in `errors.types.ts`.
174
174
 
175
175
  `PlatformEvent` is a **discriminated union**: switch on `event.type` to narrow
@@ -186,7 +186,7 @@ redaction of generated prose or user content.
186
186
  ## Event types
187
187
 
188
188
  The socket protocol is defined by the service's AsyncAPI document, committed as
189
- `asyncapi.json`. `src/client/modules/builder.events.generated.ts` is generated from it with
189
+ `asyncapi.json`. `src/client/modules/chat.events.generated.ts` is generated from it with
190
190
  `json-schema-to-typescript`: one type per schema, named after the backend model
191
191
  (`Message`, `StatusObject`, `QueueState`, one `*Call` per tool, one `*Approval` per
192
192
  guard), plus `ServerEventMap` and `ClientMessageMap`. Never edit it by hand.
@@ -229,16 +229,16 @@ exceptions, payloads and credentials are never attached.
229
229
  | `delivery_overflow` | 1,000 deliveries queued for the app; subscribe again for a fresh snapshot. |
230
230
  | `protocol_error` | Invalid routing or envelope. Stop and investigate. |
231
231
  | `handler_failed` | An application callback failed; fix it and subscribe again. |
232
- | `client_closed` | The builder session was explicitly closed; initialize another session. |
232
+ | `client_closed` | The chat session was explicitly closed; initialize another session. |
233
233
 
234
234
  No SDK dependency, package version or lockfile changes are required. Socket.IO
235
235
  remains the existing SDK dependency. Chat commands and HTTP APIs are outside this entry point.
236
236
 
237
237
  ## React
238
238
 
239
- `@base44/platform/react` adds one hook, `useBase44Chat`, that runs a builder chat for one
239
+ `@base44/platform/react` adds one hook, `useBase44Chat`, that runs the AI chat for one
240
240
  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 builder asks to the step it belongs to. It renders nothing. React is an optional peer dependency, loaded only by this
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
242
  entry; the root entry stays framework-free.
243
243
 
244
244
  ```tsx
@@ -258,5 +258,5 @@ call with your credentials, so the browser never holds a key. The hook returns `
258
258
  the first, and the chat watches it while `appId` is `null`. A sent prompt shows at once as a
259
259
  `pending` item until Base44's own message arrives; a prompt sent mid-build waits in Base44's
260
260
  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 builder, only the
261
+ actions its kind allows, and declining is always one of them. As in Base44's app editor, only the
262
262
  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 [`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
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
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 builder = client.builder.init({
20
+ * const chat = client.chat.init({
21
21
  * async getSession() {
22
- * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
22
+ * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
23
23
  * return response.json();
24
24
  * },
25
25
  * onError: (error) => console.error(error.code),
26
26
  * });
27
- * await builder.connect();
27
+ * await chat.connect();
28
28
  * ```
29
29
  */
30
30
  export declare function createPlatformClient(): PlatformClient;
@@ -1,10 +1,10 @@
1
- import { createBuilder } from "./modules/builder.js";
1
+ import { createChat } from "./modules/chat.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 [`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
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
8
8
  * `getSession` you pass to `init()`.
9
9
  *
10
10
  * @returns A platform client with access to the platform's modules.
@@ -17,16 +17,16 @@ import { createBuilder } from "./modules/builder.js";
17
17
  * const client = createPlatformClient();
18
18
  *
19
19
  * // Use the client to follow the AI chat in an app
20
- * const builder = client.builder.init({
20
+ * const chat = client.chat.init({
21
21
  * async getSession() {
22
- * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
22
+ * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
23
23
  * return response.json();
24
24
  * },
25
25
  * onError: (error) => console.error(error.code),
26
26
  * });
27
- * await builder.connect();
27
+ * await chat.connect();
28
28
  * ```
29
29
  */
30
30
  export function createPlatformClient() {
31
- return Object.freeze({ builder: Object.freeze(createBuilder()) });
31
+ return Object.freeze({ chat: Object.freeze(createChat()) });
32
32
  }
@@ -1,10 +1,10 @@
1
- import type { BuilderModule } from "./modules/builder.types.js";
1
+ import type { ChatModule } from "./modules/chat.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
- /** [Builder module](/developers/references/platform-sdk/docs/interfaces/builder) for following the AI chat in your users' apps live. */
9
- readonly builder: BuilderModule;
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
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 builder session.
3
+ * The error the SDK reports when something goes wrong in a chat 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 builder = client.builder.init({
17
+ * const chat = client.chat.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
- * builder.subscribe(appId, {
24
+ * chat.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 builder session.
2
+ * The error the SDK reports when something goes wrong in a chat 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 builder = client.builder.init({
16
+ * const chat = client.chat.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
- * builder.subscribe(appId, {
23
+ * chat.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,6 +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 { 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";
6
+ export type { ChatModule, ChatInitOptions, ChatSession, PlatformSubscription, SocketSession, SubscriptionOptions } from "./modules/chat.types.js";
7
+ export type { GuardApproval, PlatformEvent, PlatformEventMap, PlatformSnapshot, ToolCall } from "./modules/chat.events.types.js";
8
+ export type * from "./modules/chat.events.generated.js";
@@ -1,5 +1,5 @@
1
- import type { PlatformEvent, PlatformSnapshot } from "./builder.events.types.js";
2
- import type { SocketSession } from "./builder.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./chat.events.types.js";
2
+ import type { SocketSession } from "./chat.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 "./builder.events.generated.js";
1
+ import { serverEventNames } from "./chat.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 { BuilderInitOptions, BuilderSession, PlatformSubscription, SubscriptionOptions } from "./builder.types.js";
1
+ import type { ChatInitOptions, ChatSession, PlatformSubscription, SubscriptionOptions } from "./chat.types.js";
2
2
  /** @internal */
3
- export declare class BuilderSocket implements BuilderSession {
3
+ export declare class ChatSocket implements ChatSession {
4
4
  private socket?;
5
5
  private address?;
6
6
  private readonly subscriptions;
@@ -16,7 +16,7 @@ export declare class BuilderSocket implements BuilderSession {
16
16
  private connecting?;
17
17
  private resolveConnect?;
18
18
  private rejectConnect?;
19
- constructor(options: BuilderInitOptions);
19
+ constructor(options: ChatInitOptions);
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 "./builder-protocol.js";
4
- import { notify, Subscription } from "./builder-subscription.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";
5
5
  const MAX_DENIAL_RETRIES = 5;
6
6
  /** @internal */
7
- export class BuilderSocket {
7
+ export class ChatSocket {
8
8
  constructor(options) {
9
9
  this.subscriptions = new Map();
10
10
  this.closed = false;
@@ -48,7 +48,7 @@ export class BuilderSocket {
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 builder session");
51
+ throw new TypeError("An app may only have one subscription per chat 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 "./builder.events.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./chat.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 "./builder.types.js";
4
+ import type { PlatformSubscription, SubscriptionOptions } from "./chat.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 { ChatModule } from "./chat.types.js";
2
+ /** @internal */
3
+ export declare function createChat(): ChatModule;
@@ -1,4 +1,4 @@
1
- import type { Message, QueueState, ServerEventMap, Snapshot } from "./builder.events.generated.js";
1
+ import type { Message, QueueState, ServerEventMap, Snapshot } from "./chat.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 { ChatSocket } from "./chat-socket.js";
2
+ /** @internal */
3
+ export function createChat() {
4
+ return {
5
+ init(options) { return new ChatSocket(options); },
6
+ };
7
+ }
@@ -1,4 +1,4 @@
1
- import type { PlatformEvent, PlatformSnapshot } from "./builder.events.types.js";
1
+ import type { PlatformEvent, PlatformSnapshot } from "./chat.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 BuilderModule.init | init()}. */
18
- export interface BuilderInitOptions {
17
+ /** Options for {@linkcode ChatModule.init | init()}. */
18
+ export interface ChatInitOptions {
19
19
  /**
20
20
  * Returns a new socket session from your server.
21
21
  *
@@ -36,7 +36,7 @@ export interface BuilderInitOptions {
36
36
  onError: (error: PlatformSocketError) => void;
37
37
  }
38
38
  /**
39
- * Builder module for following the AI chat in your users' apps live.
39
+ * Chat 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 BuilderInitOptions {
46
46
  *
47
47
  * The module does nothing until you call {@linkcode init | init()}.
48
48
  */
49
- export interface BuilderModule {
49
+ export interface ChatModule {
50
50
  /**
51
- * Creates a builder session without connecting it.
51
+ * Creates a chat session without connecting it.
52
52
  *
53
- * Call {@linkcode BuilderSession.connect | connect()} on the returned session to open the socket.
53
+ * Call {@linkcode ChatSession.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 BuilderModule {
59
59
  * @example
60
60
  * ```typescript
61
61
  * // Create and connect a session
62
- * const builder = client.builder.init({
62
+ * const chat = client.chat.init({
63
63
  * async getSession() {
64
- * const response = await fetch('/api/builder-socket-session', { method: 'POST' });
64
+ * const response = await fetch('/api/chat-socket-session', { method: 'POST' });
65
65
  * return response.json();
66
66
  * },
67
67
  * onError(error) {
68
- * console.error('Builder session error', error.code);
68
+ * console.error('Chat session error', error.code);
69
69
  * },
70
70
  * });
71
- * await builder.connect();
71
+ * await chat.connect();
72
72
  * ```
73
73
  */
74
- init(options: BuilderInitOptions): BuilderSession;
74
+ init(options: ChatInitOptions): ChatSession;
75
75
  }
76
76
  /**
77
- * A `BuilderSession`: one socket with its app subscriptions and its reconnection. Use its methods
77
+ * A `ChatSession`: 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 BuilderSession {
80
+ export interface ChatSession {
81
81
  /**
82
82
  * Connects the session's socket.
83
83
  *
@@ -94,7 +94,7 @@ export interface BuilderSession {
94
94
  * ```typescript
95
95
  * // Connect and handle failure
96
96
  * try {
97
- * await builder.connect();
97
+ * await chat.connect();
98
98
  * } catch (error) {
99
99
  * console.error('Could not connect', error.code);
100
100
  * }
@@ -121,7 +121,7 @@ export interface BuilderSession {
121
121
  * @example
122
122
  * ```typescript
123
123
  * // Follow an app
124
- * const subscription = builder.subscribe(appId, {
124
+ * const subscription = chat.subscribe(appId, {
125
125
  * onSnapshot(snapshot) {
126
126
  * renderChat(snapshot.messages);
127
127
  * },
@@ -139,13 +139,13 @@ export interface BuilderSession {
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/builder#init)
142
+ * nothing. A closed session can't be reused, so call [`init()`](/developers/references/platform-sdk/docs/interfaces/chat#init)
143
143
  * for a new one.
144
144
  *
145
145
  * @example
146
146
  * ```typescript
147
147
  * // Close a session
148
- * builder.close();
148
+ * chat.close();
149
149
  * ```
150
150
  */
151
151
  close(): void;
@@ -1,5 +1,5 @@
1
- import type { Message } from "../client/modules/builder.events.generated.js";
2
- import type { ToolCall } from "../client/modules/builder.events.types.js";
1
+ import type { Message } from "../client/modules/chat.events.generated.js";
2
+ import type { ToolCall } from "../client/modules/chat.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 builder, only the last turn reply
23
+ /** @internal Whether the chat waits on the user. Like Base44's app editor, 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 builder a single pick goes in `selected_label`, several in `selected_labels`,
49
+ * and like Base44's app editor 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 own builder finds it. */
30
+ /** @internal The last assistant message that answers a turn, as Base44's app editor 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 builder, only the last turn reply
113
+ /** @internal Whether the chat waits on the user. Like Base44's app editor, 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 builder a single pick goes in `selected_label`, several in `selected_labels`,
158
+ * and like Base44's app editor 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/builder.types.js";
1
+ import type { SocketSession } from "../client/modules/chat.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/builder.types.js";
4
+ export type { SocketSession } from "../client/modules/chat.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 builderSession = createPlatformClient().builder.init({
171
+ const chatSession = createPlatformClient().chat.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
- builderSession.subscribe(followedAppId, {
188
+ chatSession.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
- builderSession.connect().catch(() => { });
223
+ chatSession.connect().catch(() => { });
224
224
  return () => {
225
225
  closed = true;
226
- builderSession.close();
226
+ chatSession.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
@@ -138,10 +138,10 @@ export interface WebhookTestV1Data {
138
138
  challenge: string;
139
139
  }
140
140
  /**
141
- * Sent when the builder picks the message up, not when it is received: a
141
+ * Sent when the AI picks the message up, not when it is received: a
142
142
  * message sent while another turn runs waits in the queue until then.
143
143
  */
144
- export interface BuilderTurnStartedV1Data {
144
+ export interface ChatTurnStartedV1Data {
145
145
  /**
146
146
  * The app the event is about.
147
147
  */
@@ -163,7 +163,7 @@ export interface BuilderTurnStartedV1Data {
163
163
  */
164
164
  conversation_id?: string;
165
165
  /**
166
- * When the builder started working on the message (UTC).
166
+ * When the AI started working on the message (UTC).
167
167
  */
168
168
  started_at: string;
169
169
  /**
@@ -172,9 +172,9 @@ export interface BuilderTurnStartedV1Data {
172
172
  continues_message_id?: string;
173
173
  }
174
174
  /**
175
- * The `data` object of `builder.turn_ended.v1`. The builder finished responding to a message.
175
+ * The `data` object of `chat.turn_ended.v1`. The AI finished responding to a message.
176
176
  */
177
- export interface BuilderTurnEndedV1Data {
177
+ export interface ChatTurnEndedV1Data {
178
178
  /**
179
179
  * The app the event is about.
180
180
  */
@@ -196,7 +196,7 @@ export interface BuilderTurnEndedV1Data {
196
196
  */
197
197
  conversation_id?: string;
198
198
  /**
199
- * When the builder started working on the message (UTC).
199
+ * When the AI started working on the message (UTC).
200
200
  */
201
201
  started_at: string;
202
202
  /**
@@ -204,7 +204,7 @@ export interface BuilderTurnEndedV1Data {
204
204
  */
205
205
  continues_message_id?: string;
206
206
  /**
207
- * How the turn ended. `finished`: the builder replied and has nothing pending. `waiting_for_user_input`: the builder stopped to ask something, such as a clarifying question or a plan to approve, and continues when the next message answers it. `failed`: the turn hit an error. `cancelled`: the turn was stopped before it ended. `interrupted`: the builder was interrupted, for example by a restart, and continues the work in a new turn whose `continues_message_id` is this message.
207
+ * How the turn ended. `finished`: the AI replied and has nothing pending. `waiting_for_user_input`: the AI stopped to ask something, such as a clarifying question or a plan to approve, and continues when the next message answers it. `failed`: the turn hit an error. `cancelled`: the turn was stopped before it ended. `interrupted`: the AI was interrupted, for example by a restart, and continues the work in a new turn whose `continues_message_id` is this message.
208
208
  */
209
209
  status: "finished" | "waiting_for_user_input" | "failed" | "cancelled" | "interrupted";
210
210
  /**
@@ -226,10 +226,10 @@ export interface WebhookEventMap {
226
226
  "app.restored.v1": AppRestoredV1Data;
227
227
  /** Carries no domain data — its only job is to be verifiable and echoed. */
228
228
  "webhook.test.v1": WebhookTestV1Data;
229
- /** Sent when the builder picks the message up, not when it is received: a */
230
- "builder.turn_started.v1": BuilderTurnStartedV1Data;
231
- /** The builder finished responding to a message. */
232
- "builder.turn_ended.v1": BuilderTurnEndedV1Data;
229
+ /** Sent when the AI picks the message up, not when it is received: a */
230
+ "chat.turn_started.v1": ChatTurnStartedV1Data;
231
+ /** The AI finished responding to a message. */
232
+ "chat.turn_ended.v1": ChatTurnEndedV1Data;
233
233
  }
234
234
  /** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
235
- export declare const WEBHOOK_EVENT_TYPES: readonly ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "builder.turn_started.v1", "builder.turn_ended.v1"];
235
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
@@ -1,4 +1,4 @@
1
1
  // Generated by scripts/generate-webhook-types.mjs from the schemas published at
2
2
  // https://base44.com/webhooks/schemas. Do not edit by hand; run `npm run generate:webhooks`.
3
3
  /** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
4
- export const WEBHOOK_EVENT_TYPES = ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "builder.turn_started.v1", "builder.turn_ended.v1"];
4
+ export const WEBHOOK_EVENT_TYPES = ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@base44-preview/platform",
3
- "version": "0.3.0-pr.338.12ff73f",
4
- "description": "Base44 Platform SDK for white-label platforms: a browser client for watching the builder and a server entrypoint for webhooks",
3
+ "version": "0.3.0-pr.338.9cd34e2",
4
+ "description": "Base44 Platform SDK for white-label platforms: a browser client for following the AI chat 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 { BuilderModule } from "./builder.types.js";
2
- /** @internal */
3
- export declare function createBuilder(): BuilderModule;
@@ -1,7 +0,0 @@
1
- import { BuilderSocket } from "./builder-socket.js";
2
- /** @internal */
3
- export function createBuilder() {
4
- return {
5
- init(options) { return new BuilderSocket(options); },
6
- };
7
- }