@base44-preview/platform 0.4.0-pr.343.fe53e54 → 0.4.0-pr.345.2183bda

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -237,15 +237,15 @@ remains the existing SDK dependency. Chat commands and HTTP APIs are outside thi
237
237
 
238
238
  ## React
239
239
 
240
- `@base44/platform/react` adds one hook, `useBase44Chat`, that runs the AI chat for one
240
+ `@base44/platform/react` adds one hook, `useChat`, that runs the AI chat for one
241
241
  app on top of this client: it opens the live session and renews it, turns messages into items
242
242
  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
243
243
  entry; the root entry stays framework-free.
244
244
 
245
245
  ```tsx
246
- import { useBase44Chat } from "@base44/platform/react";
246
+ import { useChat } from "@base44/platform/react";
247
247
 
248
- const chat = useBase44Chat({ appId, backend, onAppCreated });
248
+ const chat = useChat({ appId, backend, onAppCreated });
249
249
  chat.items.map((item) =>
250
250
  item.steps.map((step) => step.question?.kind === "approval" && <button onClick={step.question.approve}>Allow</button>),
251
251
  );
@@ -1,6 +1,6 @@
1
1
  import type { SocketSession } from "../client/modules/chat.types.js";
2
2
  /** An app the AI chat works on. */
3
- export interface Base44App {
3
+ export interface ChatApp {
4
4
  /** ID of the app, 24 lowercase hexadecimal characters. */
5
5
  id: string;
6
6
  /** Display name of the app. */
@@ -32,7 +32,7 @@ export interface ToolCallAnswer {
32
32
  *
33
33
  * Base44 keeps the Send chat message and Submit tool-call input requests open until the AI
34
34
  * finishes the turn. Resolve your call once Base44 accepts the request, not when it returns. The
35
- * chat follows the rest live. A rejected promise from any call sets `error` on the {@link useBase44Chat | chat}.
35
+ * chat follows the rest live. A rejected promise from any call sets `error` on the {@link useChat | chat}.
36
36
  *
37
37
  * @example
38
38
  * ```typescript
@@ -43,7 +43,7 @@ export interface ToolCallAnswer {
43
43
  * return response.json();
44
44
  * }
45
45
  *
46
- * const backend: Base44ChatBackend = {
46
+ * const backend: ChatBackend = {
47
47
  * createApp: (prompt) => post("/api/chat/apps", { prompt }),
48
48
  * openLiveSession: (appId) => post("/api/chat/session", { appId }),
49
49
  * sendMessage: (appId, content) => post("/api/chat/message", { appId, content }),
@@ -51,14 +51,14 @@ export interface ToolCallAnswer {
51
51
  * };
52
52
  * ```
53
53
  */
54
- export interface Base44ChatBackend {
54
+ export interface ChatBackend {
55
55
  /**
56
56
  * Creates an app from its first prompt. The AI starts building inside this call.
57
57
  *
58
58
  * @param prompt - The first prompt, which describes the app.
59
59
  * @returns Promise resolving to the new app.
60
60
  */
61
- createApp(prompt: string): Promise<Base44App>;
61
+ createApp(prompt: string): Promise<ChatApp>;
62
62
  /**
63
63
  * Opens a read-only socket session for one app. The chat calls it on the first connect and again
64
64
  * whenever the session expires. Sessions last one hour.
@@ -141,7 +141,7 @@ export interface ChatAnswer {
141
141
  * An open question, with the actions that answer this question and no other.
142
142
  *
143
143
  * Each kind carries only the actions that make sense for it, and every kind can be declined. The
144
- * actions never throw. A failure sets `error` on the {@link useBase44Chat | chat}, and the question opens again.
144
+ * actions never throw. A failure sets `error` on the {@link useChat | chat}, and the question opens again.
145
145
  *
146
146
  * The chat declines a question kind this release doesn't know, once per tool call, when Base44
147
147
  * names that kind on the last assistant message. If the decline fails, the chat's `error` says
@@ -267,7 +267,7 @@ export type ChatStatus = "ready" | "submitted" | "building" | "waiting" | "error
267
267
  * - `connecting`: until the first snapshot arrives.
268
268
  * - `connected`: after the first snapshot.
269
269
  * - `disconnected`: live updates stopped for good. The session couldn't open, the retries ran out,
270
- * or Base44 ended the session or the app's subscription. {@link Base44Chat.error} says why.
270
+ * or Base44 ended the session or the app's subscription. {@link UseChatResult.error} says why.
271
271
  *
272
272
  * Watching another app, or mounting the chat again, starts over.
273
273
  */
@@ -284,23 +284,23 @@ export interface ChatError {
284
284
  /** The original error, for logging. */
285
285
  cause?: unknown;
286
286
  }
287
- /** Options for {@link useBase44Chat}. */
288
- export interface Base44ChatOptions {
287
+ /** Options for {@link useChat}. */
288
+ export interface ChatOptions {
289
289
  /**
290
290
  * ID of the app to follow, or `null` until an app exists. While it's `null`, the chat follows the
291
- * app {@link Base44Chat.create} made. Any change to `appId` forgets that app.
291
+ * app {@link UseChatResult.create} made. Any change to `appId` forgets that app.
292
292
  */
293
293
  appId: string | null;
294
294
  /** The four calls your backend makes to Base44. The chat reads the latest on every action, so an inline object works. */
295
- backend: Base44ChatBackend;
295
+ backend: ChatBackend;
296
296
  /**
297
- * Called with the new app after {@link Base44Chat.create} succeeds. The chat already follows it.
297
+ * Called with the new app after {@link UseChatResult.create} succeeds. The chat already follows it.
298
298
  * Pass its ID back as `appId` to keep it in your own state.
299
299
  */
300
- onAppCreated?: (app: Base44App) => void;
300
+ onAppCreated?: (app: ChatApp) => void;
301
301
  }
302
- /** The chat that {@link useBase44Chat} returns. */
303
- export interface Base44Chat {
302
+ /** The chat that {@link useChat} returns. */
303
+ export interface UseChatResult {
304
304
  /** The conversation, oldest first, with open questions bound to their steps. */
305
305
  items: ChatItem[];
306
306
  /** What the AI is doing. */
@@ -310,13 +310,13 @@ export interface Base44Chat {
310
310
  /**
311
311
  * The last failure. It's set whenever `status` is `error`, and on any failed call or connection
312
312
  * error. A failed call's error clears on the next action. A connection error stays until
313
- * {@link Base44Chat.clearError}. A failed build stays while Base44 reports it.
313
+ * {@link UseChatResult.clearError}. A failed build stays while Base44 reports it.
314
314
  */
315
315
  error: ChatError | null;
316
316
  /**
317
317
  * Sends a prompt to the current app. Base44 queues it while the AI is working. The prompt shows
318
318
  * at once as a pending item, and the reply arrives through `items`. Without an app, it sets
319
- * `error`. Use {@link Base44Chat.create} for the first prompt.
319
+ * `error`. Use {@link UseChatResult.create} for the first prompt.
320
320
  *
321
321
  * @param prompt - The prompt to send.
322
322
  * @returns Promise resolving once Base44 accepts the prompt. It never rejects.
@@ -329,6 +329,6 @@ export interface Base44Chat {
329
329
  * @returns Promise resolving once the app exists. It never rejects.
330
330
  */
331
331
  create(prompt: string): Promise<void>;
332
- /** Clears {@link Base44Chat.error}. A failed build's error stays while Base44 reports it. */
332
+ /** Clears {@link UseChatResult.error}. A failed build's error stays while Base44 reports it. */
333
333
  clearError(): void;
334
334
  }
@@ -1,4 +1,16 @@
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
- export { useBase44Chat } from "./useBase44Chat.js";
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";
2
+ import { useChat } from "./useChat.js";
3
+ import type { UseChatResult, ChatApp, ChatBackend, ChatOptions } from "./chat.types.js";
4
+ export { useChat };
5
+ export type { ApprovalDetails, ApprovalQuestion, ChatApp, UseChatResult, ChatOptions, ChatBackend, ChatAnswer, ChatConnection, ChatError, ChatItem, ChatQuestion, ChatStatus, ChatStep, ChoiceEntry, ChoiceQuestion, SecretField, SecretsQuestion, ToolCallAnswer, } from "./chat.types.js";
4
6
  export type { SocketSession } from "../client/modules/chat.types.js";
7
+ /** @deprecated Renamed to {@link useChat}. Removed in 0.6.0. @hidden */
8
+ export declare const useBase44Chat: typeof useChat;
9
+ /** @deprecated Renamed to {@link UseChatResult}. Removed in 0.6.0. @hidden */
10
+ export type Base44Chat = UseChatResult;
11
+ /** @deprecated Renamed to {@link ChatOptions}. Removed in 0.6.0. @hidden */
12
+ export type Base44ChatOptions = ChatOptions;
13
+ /** @deprecated Renamed to {@link ChatBackend}. Removed in 0.6.0. @hidden */
14
+ export type Base44ChatBackend = ChatBackend;
15
+ /** @deprecated Renamed to {@link ChatApp}. Removed in 0.6.0. @hidden */
16
+ export type Base44App = ChatApp;
@@ -1,2 +1,6 @@
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
- export { useBase44Chat } from "./useBase44Chat.js";
2
+ import { useChat } from "./useChat.js";
3
+ export { useChat };
4
+ // The names before 0.5.0, kept for one release so existing code keeps working.
5
+ /** @deprecated Renamed to {@link useChat}. Removed in 0.6.0. @hidden */
6
+ export const useBase44Chat = useChat;
@@ -1,20 +1,20 @@
1
- import type { Base44Chat, Base44ChatOptions } from "./chat.types.js";
1
+ import type { UseChatResult, ChatOptions } from "./chat.types.js";
2
2
  /**
3
3
  * Runs the AI chat for one app in your own UI.
4
4
  *
5
5
  * The hook renders nothing. It gives you the conversation and the actions, and you draw them:
6
6
  * - Follows the app live, and renews its socket session when it expires.
7
7
  * - Turns Base44's messages into {@link ChatItem | items}, with each open question bound to the step it belongs to.
8
- * - Reports what the AI is doing in {@link Base44Chat.status}, and the live connection in {@link Base44Chat.connection}.
9
- * - Sends prompts, creates apps and answers questions through the {@link Base44ChatBackend | backend} you pass, so no credential reaches the browser.
8
+ * - Reports what the AI is doing in {@link UseChatResult.status}, and the live connection in {@link UseChatResult.connection}.
9
+ * - Sends prompts, creates apps and answers questions through the {@link ChatBackend | backend} you pass, so no credential reaches the browser.
10
10
  *
11
- * The actions never throw. A failure sets {@link Base44Chat.error}, and a question whose answer
11
+ * The actions never throw. A failure sets {@link UseChatResult.error}, and a question whose answer
12
12
  * failed opens again. The chat declines a question kind this release doesn't know.
13
13
  *
14
14
  * Requires a browser environment and can't be used in the backend.
15
15
  *
16
16
  * The chat follows `appId` when it's set. While `appId` is `null`, it follows the app
17
- * {@link Base44Chat.create} made, so passing the new ID back is optional. Any change to `appId`
17
+ * {@link UseChatResult.create} made, so passing the new ID back is optional. Any change to `appId`
18
18
  * forgets that app, so setting it back to `null` starts a new chat. Switching apps closes the old
19
19
  * session and starts over.
20
20
  *
@@ -24,7 +24,7 @@ import type { Base44Chat, Base44ChatOptions } from "./chat.types.js";
24
24
  * @example
25
25
  * ```typescript
26
26
  * // Draw the chat and answer an approval
27
- * const chat = useBase44Chat({ appId, backend, onAppCreated: selectApp });
27
+ * const chat = useChat({ appId, backend, onAppCreated: selectApp });
28
28
  * return (
29
29
  * <>
30
30
  * {chat.items.map((item) => (
@@ -45,4 +45,4 @@ import type { Base44Chat, Base44ChatOptions } from "./chat.types.js";
45
45
  * );
46
46
  * ```
47
47
  */
48
- export declare function useBase44Chat({ appId, backend, onAppCreated }: Base44ChatOptions): Base44Chat;
48
+ export declare function useChat({ appId, backend, onAppCreated }: ChatOptions): UseChatResult;
@@ -12,16 +12,16 @@ const NEW_APP = "new-app";
12
12
  * The hook renders nothing. It gives you the conversation and the actions, and you draw them:
13
13
  * - Follows the app live, and renews its socket session when it expires.
14
14
  * - Turns Base44's messages into {@link ChatItem | items}, with each open question bound to the step it belongs to.
15
- * - Reports what the AI is doing in {@link Base44Chat.status}, and the live connection in {@link Base44Chat.connection}.
16
- * - Sends prompts, creates apps and answers questions through the {@link Base44ChatBackend | backend} you pass, so no credential reaches the browser.
15
+ * - Reports what the AI is doing in {@link UseChatResult.status}, and the live connection in {@link UseChatResult.connection}.
16
+ * - Sends prompts, creates apps and answers questions through the {@link ChatBackend | backend} you pass, so no credential reaches the browser.
17
17
  *
18
- * The actions never throw. A failure sets {@link Base44Chat.error}, and a question whose answer
18
+ * The actions never throw. A failure sets {@link UseChatResult.error}, and a question whose answer
19
19
  * failed opens again. The chat declines a question kind this release doesn't know.
20
20
  *
21
21
  * Requires a browser environment and can't be used in the backend.
22
22
  *
23
23
  * The chat follows `appId` when it's set. While `appId` is `null`, it follows the app
24
- * {@link Base44Chat.create} made, so passing the new ID back is optional. Any change to `appId`
24
+ * {@link UseChatResult.create} made, so passing the new ID back is optional. Any change to `appId`
25
25
  * forgets that app, so setting it back to `null` starts a new chat. Switching apps closes the old
26
26
  * session and starts over.
27
27
  *
@@ -31,7 +31,7 @@ const NEW_APP = "new-app";
31
31
  * @example
32
32
  * ```typescript
33
33
  * // Draw the chat and answer an approval
34
- * const chat = useBase44Chat({ appId, backend, onAppCreated: selectApp });
34
+ * const chat = useChat({ appId, backend, onAppCreated: selectApp });
35
35
  * return (
36
36
  * <>
37
37
  * {chat.items.map((item) => (
@@ -52,7 +52,7 @@ const NEW_APP = "new-app";
52
52
  * );
53
53
  * ```
54
54
  */
55
- export function useBase44Chat({ appId, backend, onAppCreated }) {
55
+ export function useChat({ appId, backend, onAppCreated }) {
56
56
  var _a;
57
57
  const [messages, setMessages] = useState([]);
58
58
  const [buildState, setBuildState] = useState();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/platform",
3
- "version": "0.4.0-pr.343.fe53e54",
3
+ "version": "0.4.0-pr.345.2183bda",
4
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",