@base44-preview/platform 0.2.0-pr.315.ebc1eb8 → 0.2.0-pr.315.f940d50
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 +3 -6
- package/dist/client/modules/builder-socket.d.ts +0 -1
- package/dist/client/modules/builder-socket.js +5 -19
- package/dist/client/modules/builder.types.d.ts +0 -6
- package/dist/react/chat-items.d.ts +33 -28
- package/dist/react/chat-items.js +186 -90
- package/dist/react/chat.types.d.ts +256 -106
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/useBase44Chat.d.ts +16 -14
- package/dist/react/useBase44Chat.js +244 -170
- package/package.json +1 -1
|
@@ -1,202 +1,352 @@
|
|
|
1
1
|
import type { SocketSession } from "../client/modules/builder.types.js";
|
|
2
|
-
/** An app the
|
|
2
|
+
/** An app the AI chat works on. */
|
|
3
3
|
export interface Base44App {
|
|
4
|
-
/**
|
|
4
|
+
/** ID of the app, 24 lowercase hexadecimal characters. */
|
|
5
5
|
id: string;
|
|
6
|
-
/** Display name. */
|
|
6
|
+
/** Display name of the app. */
|
|
7
7
|
name: string;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/** An answer to a question the AI waits on. Declining is `approve: false`. */
|
|
10
10
|
export interface ToolCallAnswer {
|
|
11
|
-
/**
|
|
11
|
+
/** ID of the tool call being answered. */
|
|
12
12
|
toolCallId: string;
|
|
13
|
-
/**
|
|
13
|
+
/** ID of the assistant message that holds the tool call. */
|
|
14
14
|
messageId: string;
|
|
15
|
-
/** Whether to let the call run (`true`) or turn it down (`false`). */
|
|
15
|
+
/** Whether to let the tool call run (`true`) or turn it down (`false`). */
|
|
16
16
|
approve: boolean;
|
|
17
|
-
/**
|
|
17
|
+
/** What the question asked for. A choice sends `{ answers }`, and a secrets question sends `{ secrets }`. */
|
|
18
18
|
extraUserInput?: Record<string, unknown>;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The four calls your backend
|
|
22
|
-
* credentials, so the hook never holds a workspace key or an access token, and the
|
|
23
|
-
* backend can be written in any language:
|
|
21
|
+
* The four calls your backend makes to Base44 for the chat.
|
|
24
22
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* Base44's response body unchanged. Called again whenever the session expires; sessions last
|
|
28
|
-
* one hour. The body holds a session token, never the workspace key.
|
|
29
|
-
* - `sendMessage`: `POST /api/apps/{id}/chat/message`. Base44 queues a prompt sent while the
|
|
30
|
-
* builder is busy, or refuses it with a 409 where the app has no queue: reject then.
|
|
31
|
-
* - `submitToolCallInput`: `POST /api/apps/{id}/chat/submit-tool-call-input`, with an
|
|
32
|
-
* `X-Request-ID` derived from the tool call id so a retry resumes the turn only once.
|
|
23
|
+
* Each call wraps one Base44 API request with your credentials, so the browser never holds a
|
|
24
|
+
* workspace API key or an access token. Your backend can be written in any language.
|
|
33
25
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
26
|
+
* - `createApp`: [Create app](/api-reference/create-app), with the first prompt as `initial_message`.
|
|
27
|
+
* - `openLiveSession`: [Create socket session](/api-reference/create-socket-session) with `{ app_ids: [appId] }`.
|
|
28
|
+
* Return the response body unchanged. It holds a session token, never the workspace API key.
|
|
29
|
+
* - `sendMessage`: [Send chat message](/api-reference/send-chat-message).
|
|
30
|
+
* - `submitToolCallInput`: [Submit tool-call input](/api-reference/submit-tool-call-input). Send an
|
|
31
|
+
* `X-Request-ID` built from the tool call ID, so a retry resumes the turn only once.
|
|
32
|
+
*
|
|
33
|
+
* Base44 keeps the Send chat message and Submit tool-call input requests open until the AI
|
|
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 {@link Base44Chat.error}.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Your four calls, behind your own API routes
|
|
40
|
+
* async function post<T>(path: string, body: unknown): Promise<T> {
|
|
41
|
+
* const response = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
42
|
+
* if (!response.ok) throw new Error(`${path} failed: ${response.status}`);
|
|
43
|
+
* return response.json();
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* const backend: Base44ChatBackend = {
|
|
47
|
+
* createApp: (prompt) => post("/api/chat/apps", { prompt }),
|
|
48
|
+
* openLiveSession: (appId) => post("/api/chat/session", { appId }),
|
|
49
|
+
* sendMessage: (appId, content) => post("/api/chat/message", { appId, content }),
|
|
50
|
+
* submitToolCallInput: (appId, answer) => post("/api/chat/answer", { appId, answer }),
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
37
53
|
*/
|
|
38
54
|
export interface Base44ChatBackend {
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Creates an app from its first prompt. The AI starts building inside this call.
|
|
57
|
+
*
|
|
58
|
+
* @param prompt - The first prompt, which describes the app.
|
|
59
|
+
* @returns Promise resolving to the new app.
|
|
60
|
+
*/
|
|
61
|
+
createApp(prompt: string): Promise<Base44App>;
|
|
62
|
+
/**
|
|
63
|
+
* Opens a read-only socket session for one app. The chat calls it on the first connect and again
|
|
64
|
+
* whenever the session expires. Sessions last one hour.
|
|
65
|
+
*
|
|
66
|
+
* @param appId - ID of the app to follow.
|
|
67
|
+
* @returns Promise resolving to the Create socket session response body, unchanged.
|
|
68
|
+
*/
|
|
42
69
|
openLiveSession(appId: string): Promise<SocketSession>;
|
|
43
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Sends a prompt to an existing app. Base44 queues a prompt sent while the AI is working. When the
|
|
72
|
+
* app has no queue, Base44 refuses it with a 409, so reject the promise.
|
|
73
|
+
*
|
|
74
|
+
* @param appId - ID of the app.
|
|
75
|
+
* @param content - The prompt.
|
|
76
|
+
* @returns Promise resolving once Base44 accepts the prompt.
|
|
77
|
+
*/
|
|
44
78
|
sendMessage(appId: string, content: string): Promise<void>;
|
|
45
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Answers or declines a question the AI waits on.
|
|
81
|
+
*
|
|
82
|
+
* @param appId - ID of the app.
|
|
83
|
+
* @param answer - The tool call and the answer to it.
|
|
84
|
+
* @returns Promise resolving once Base44 accepts the answer.
|
|
85
|
+
*/
|
|
46
86
|
submitToolCallInput(appId: string, answer: ToolCallAnswer): Promise<void>;
|
|
47
87
|
}
|
|
48
|
-
/** One message of the chat,
|
|
88
|
+
/** One message of the chat, shaped for rendering. */
|
|
49
89
|
export interface ChatItem {
|
|
50
|
-
/**
|
|
90
|
+
/** ID of the message. */
|
|
51
91
|
id: string;
|
|
52
|
-
/** Who wrote
|
|
92
|
+
/** Who wrote the message. */
|
|
53
93
|
role: "user" | "assistant";
|
|
54
|
-
/**
|
|
94
|
+
/** The message text, as raw markdown. It comes before the steps, and is empty when the message only holds tool calls. */
|
|
55
95
|
text: string;
|
|
56
|
-
/**
|
|
57
|
-
|
|
96
|
+
/** ID of the checkpoint Base44 ties to the message: the app before a user's turn, or after the AI's final reply. Absent when the turn made none. */
|
|
97
|
+
checkpointId?: string;
|
|
98
|
+
/** When the message was created, as an ISO timestamp. Base44's timestamps are UTC with no time zone. A pending prompt carries the browser's time. */
|
|
58
99
|
createdAt: string;
|
|
59
|
-
/** One per tool call, in order. */
|
|
100
|
+
/** One step per tool call, in order. */
|
|
60
101
|
steps: ChatStep[];
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
102
|
+
/**
|
|
103
|
+
* Whether this is a prompt sent from this chat that Base44 hasn't confirmed yet. It shows at once,
|
|
104
|
+
* and Base44's own message replaces it. A failed send removes it. A prompt sent while the AI is
|
|
105
|
+
* working waits in Base44's queue and stays pending until it runs.
|
|
106
|
+
*/
|
|
64
107
|
pending: boolean;
|
|
65
108
|
}
|
|
66
109
|
/** One tool call, as a line of activity. */
|
|
67
110
|
export interface ChatStep {
|
|
68
|
-
/**
|
|
111
|
+
/** ID of the tool call. */
|
|
69
112
|
id: string;
|
|
70
|
-
/**
|
|
113
|
+
/** Name of the tool, such as `write_file`. */
|
|
71
114
|
tool: string;
|
|
72
|
-
/** The paths
|
|
115
|
+
/** The file paths the tool call touched. */
|
|
73
116
|
files: string[];
|
|
74
|
-
/**
|
|
117
|
+
/** A line ready to show. It's Base44's description of the step when there is one, then the entity it touched, then the tool name and its files. */
|
|
75
118
|
label: string;
|
|
76
|
-
/**
|
|
119
|
+
/** Base44's description of what the step did, such as what a command or code run did. */
|
|
120
|
+
summary?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Where the tool call is. A `waiting` step waits on the user. A `stopped` step was declined, or the
|
|
123
|
+
* turn was stopped.
|
|
124
|
+
*/
|
|
77
125
|
status: "running" | "waiting" | "done" | "stopped" | "error";
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
126
|
+
/**
|
|
127
|
+
* The question this step waits on, with the actions that answer it. Present only while the step is
|
|
128
|
+
* `waiting` in the last assistant message, which is the one that makes the chat wait. It goes away
|
|
129
|
+
* once answered, and is absent for a question kind this release doesn't know.
|
|
130
|
+
*/
|
|
81
131
|
question?: ChatQuestion;
|
|
132
|
+
/** What the user answered on a choice question, once answered. It stays after the question closes, so the chat's history shows it. */
|
|
133
|
+
answered?: ChatAnswer[];
|
|
134
|
+
}
|
|
135
|
+
/** One answer to a choice question, next to the question it answers. */
|
|
136
|
+
export interface ChatAnswer {
|
|
137
|
+
/** The question text. */
|
|
138
|
+
question: string;
|
|
139
|
+
/** The labels the user picked. */
|
|
140
|
+
labels: string[];
|
|
141
|
+
/** The free text the user wrote, if any. */
|
|
142
|
+
text?: string;
|
|
82
143
|
}
|
|
83
144
|
/**
|
|
84
145
|
* An open question, with the actions that answer this question and no other.
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
146
|
+
*
|
|
147
|
+
* Each kind carries only the actions that make sense for it, and every kind can be declined. The
|
|
148
|
+
* actions never throw. A failure sets {@link Base44Chat.error}, and the question opens again.
|
|
149
|
+
*
|
|
150
|
+
* The chat declines a question kind this release doesn't know, once per tool call, when Base44
|
|
151
|
+
* names that kind on the last assistant message. If the decline fails, {@link Base44Chat.error} says
|
|
152
|
+
* so, and the chat tries again after it reconnects.
|
|
89
153
|
*/
|
|
90
154
|
export type ChatQuestion = ChoiceQuestion | SecretsQuestion | ApprovalQuestion;
|
|
91
|
-
/** One of the questions a
|
|
155
|
+
/** One of the questions in a {@link ChoiceQuestion}. */
|
|
92
156
|
export interface ChoiceEntry {
|
|
93
157
|
/** The question text. */
|
|
94
158
|
text: string;
|
|
95
|
-
/**
|
|
159
|
+
/** Supporting text for the question. */
|
|
96
160
|
description?: string;
|
|
161
|
+
/** Base44's type of question, such as `text_input` for one that takes only a free-text answer. */
|
|
162
|
+
type?: string;
|
|
97
163
|
/** The option labels to pick from. */
|
|
98
164
|
options: string[];
|
|
99
|
-
/** Whether more than one option
|
|
165
|
+
/** Whether more than one option can be picked. */
|
|
100
166
|
multi: boolean;
|
|
101
167
|
}
|
|
102
|
-
/** The
|
|
168
|
+
/** The AI offers options and waits for the user to pick. */
|
|
103
169
|
export interface ChoiceQuestion {
|
|
104
|
-
/**
|
|
170
|
+
/** Kind of question. */
|
|
105
171
|
kind: "choice";
|
|
106
|
-
/**
|
|
172
|
+
/** ID of the tool call this question belongs to, for logging or storing it. */
|
|
173
|
+
toolCallId: string;
|
|
174
|
+
/** ID of the assistant message that holds the tool call. */
|
|
175
|
+
messageId: string;
|
|
176
|
+
/** The questions, in order. */
|
|
107
177
|
questions: ChoiceEntry[];
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Answers with the picked labels, and free text where the user wrote some.
|
|
180
|
+
*
|
|
181
|
+
* @param picked - One list of picked labels per question, in the order of `questions`.
|
|
182
|
+
* @param texts - One free-text answer per question, in the same order. Use it for a `text_input` question, or as a note beside a pick. A question with no pick and no text is skipped.
|
|
183
|
+
* @returns Promise resolving once the answer is sent.
|
|
184
|
+
*/
|
|
185
|
+
answer(picked: string[][], texts?: string[]): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Declines the question. The AI continues without the answer.
|
|
188
|
+
*
|
|
189
|
+
* @returns Promise resolving once the decline is sent.
|
|
190
|
+
*/
|
|
111
191
|
decline(): Promise<void>;
|
|
112
192
|
}
|
|
113
|
-
/** A value the
|
|
193
|
+
/** A value the AI needs, such as an API key. */
|
|
114
194
|
export interface SecretField {
|
|
115
|
-
/**
|
|
195
|
+
/** Name of the field, used as its key in `submit`. */
|
|
116
196
|
name: string;
|
|
117
|
-
/**
|
|
197
|
+
/** Where to get the value. */
|
|
118
198
|
description?: string;
|
|
119
199
|
}
|
|
120
|
-
/** The
|
|
200
|
+
/** The AI needs secrets, such as API keys. The values go to Base44 and the chat keeps none of them. */
|
|
121
201
|
export interface SecretsQuestion {
|
|
122
|
-
/**
|
|
202
|
+
/** Kind of question. */
|
|
123
203
|
kind: "secrets";
|
|
204
|
+
/** ID of the tool call this question belongs to, for logging or storing it. */
|
|
205
|
+
toolCallId: string;
|
|
206
|
+
/** ID of the assistant message that holds the tool call. */
|
|
207
|
+
messageId: string;
|
|
124
208
|
/** The fields to fill. */
|
|
125
209
|
fields: SecretField[];
|
|
126
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* Submits the values.
|
|
212
|
+
*
|
|
213
|
+
* @param values - The values, keyed by field name.
|
|
214
|
+
* @returns Promise resolving once the values are sent.
|
|
215
|
+
*/
|
|
127
216
|
submit(values: Record<string, string>): Promise<void>;
|
|
128
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Declines the question. The AI continues without the values.
|
|
219
|
+
*
|
|
220
|
+
* @returns Promise resolving once the decline is sent.
|
|
221
|
+
*/
|
|
129
222
|
decline(): Promise<void>;
|
|
130
223
|
}
|
|
131
|
-
/** The
|
|
224
|
+
/** The AI asks for permission to run an action. */
|
|
132
225
|
export interface ApprovalQuestion {
|
|
133
|
-
/**
|
|
226
|
+
/** Kind of question. */
|
|
134
227
|
kind: "approval";
|
|
135
|
-
/**
|
|
228
|
+
/** ID of the tool call this question belongs to, for logging or storing it. */
|
|
229
|
+
toolCallId: string;
|
|
230
|
+
/** ID of the assistant message that holds the tool call. */
|
|
231
|
+
messageId: string;
|
|
232
|
+
/** Name of the tool that wants to run. */
|
|
136
233
|
action: string;
|
|
137
|
-
/** Why
|
|
234
|
+
/** Why the action needs approval, when Base44 gives a reason. Empty otherwise. */
|
|
138
235
|
reason: string;
|
|
139
|
-
/**
|
|
236
|
+
/** The check that paused the action, such as `exec_tool_send_email` or `entity_rls_guard`. */
|
|
237
|
+
guard: string;
|
|
238
|
+
/** What the action would do, as far as the check publishes it. Show it so the user knows what they approve. */
|
|
239
|
+
details: ApprovalDetails;
|
|
240
|
+
/**
|
|
241
|
+
* Lets the action run.
|
|
242
|
+
*
|
|
243
|
+
* @returns Promise resolving once the approval is sent.
|
|
244
|
+
*/
|
|
140
245
|
approve(): Promise<void>;
|
|
141
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Declines the action. It never runs, and the AI continues.
|
|
248
|
+
*
|
|
249
|
+
* @returns Promise resolving once the decline is sent.
|
|
250
|
+
*/
|
|
142
251
|
decline(): Promise<void>;
|
|
143
252
|
}
|
|
253
|
+
/** What an action that waits for approval would do. Each check publishes only some of these. */
|
|
254
|
+
export interface ApprovalDetails {
|
|
255
|
+
/** The AI's summary of what the code does. */
|
|
256
|
+
summary?: string;
|
|
257
|
+
/** The entity whose records or access rules change. */
|
|
258
|
+
entityName?: string;
|
|
259
|
+
/** How the access rules change. */
|
|
260
|
+
changeType?: string;
|
|
261
|
+
/** The access operations whose rules change. */
|
|
262
|
+
changedOps?: string[];
|
|
263
|
+
/** The backend function under test. */
|
|
264
|
+
functionName?: string;
|
|
265
|
+
/** The entity method the code calls, such as `delete`. */
|
|
266
|
+
method?: string;
|
|
267
|
+
/** Whether the check couldn't verify the function's source. */
|
|
268
|
+
inspectionFailed?: boolean;
|
|
269
|
+
}
|
|
144
270
|
/**
|
|
145
|
-
* What the
|
|
271
|
+
* What the AI is doing. When several hold at once, the first in this list wins.
|
|
146
272
|
*
|
|
147
|
-
* - `error`: Base44 reports the
|
|
148
|
-
* - `waiting`: a
|
|
149
|
-
* - `building`: the
|
|
150
|
-
* - `submitted`: a prompt, a new app or an answer is on its way
|
|
151
|
-
*
|
|
152
|
-
* - `ready`: everything else.
|
|
153
|
-
|
|
273
|
+
* - `error`: Base44 reports that the last build failed.
|
|
274
|
+
* - `waiting`: a question waits on the user.
|
|
275
|
+
* - `building`: the AI is working.
|
|
276
|
+
* - `submitted`: a prompt, a new app or an answer is on its way. It lasts until Base44 reports work, a reply or a queue change, or the call fails.
|
|
277
|
+
* - `ready`: none of the above.
|
|
154
278
|
*/
|
|
155
279
|
export type ChatStatus = "ready" | "submitted" | "building" | "waiting" | "error";
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
|
|
162
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Whether the chat follows the app live.
|
|
282
|
+
*
|
|
283
|
+
* - `connecting`: until the first snapshot arrives.
|
|
284
|
+
* - `connected`: after the first snapshot.
|
|
285
|
+
* - `disconnected`: live updates stopped for good. The session couldn't open, the retries ran out,
|
|
286
|
+
* or Base44 ended the session or the app's subscription. {@link Base44Chat.error} says why.
|
|
287
|
+
*
|
|
288
|
+
* Watching another app, or mounting the chat again, starts over.
|
|
289
|
+
*/
|
|
290
|
+
export type ChatConnection = "connecting" | "connected" | "disconnected";
|
|
291
|
+
/** A failure of a call, of the live connection, or of the build. */
|
|
163
292
|
export interface ChatError {
|
|
164
293
|
/** What went wrong, for people. */
|
|
165
294
|
message: string;
|
|
166
|
-
/**
|
|
167
|
-
*
|
|
295
|
+
/**
|
|
296
|
+
* What went wrong, for code. A connection error carries a `PlatformSocketErrorCode`, and a failed
|
|
297
|
+
* build carries `build_failed`. A failed call to your backend carries none.
|
|
298
|
+
*/
|
|
168
299
|
code?: string;
|
|
169
300
|
/** The original error, for logging. */
|
|
170
301
|
cause?: unknown;
|
|
171
302
|
}
|
|
172
|
-
/** Options
|
|
303
|
+
/** Options for {@link useBase44Chat}. */
|
|
173
304
|
export interface Base44ChatOptions {
|
|
174
|
-
/**
|
|
175
|
-
* app
|
|
305
|
+
/**
|
|
306
|
+
* ID of the app to follow, or `null` until an app exists. While it's `null`, the chat follows the
|
|
307
|
+
* app {@link Base44Chat.create} made. Any change to `appId` forgets that app.
|
|
308
|
+
*/
|
|
176
309
|
appId: string | null;
|
|
177
|
-
/**
|
|
310
|
+
/** The four calls your backend makes to Base44. The chat reads the latest on every action, so an inline object works. */
|
|
178
311
|
backend: Base44ChatBackend;
|
|
179
|
-
/**
|
|
180
|
-
*
|
|
312
|
+
/**
|
|
313
|
+
* Called with the new app after {@link Base44Chat.create} succeeds. The chat already follows it.
|
|
314
|
+
* Pass its ID back as `appId` to keep it in your own state.
|
|
315
|
+
*/
|
|
181
316
|
onAppCreated?: (app: Base44App) => void;
|
|
182
317
|
}
|
|
183
|
-
/**
|
|
318
|
+
/** The chat that {@link useBase44Chat} returns. */
|
|
184
319
|
export interface Base44Chat {
|
|
185
320
|
/** The conversation, oldest first, with open questions bound to their steps. */
|
|
186
321
|
items: ChatItem[];
|
|
187
|
-
/** What the
|
|
322
|
+
/** What the AI is doing. */
|
|
188
323
|
status: ChatStatus;
|
|
189
|
-
/** Whether the chat
|
|
324
|
+
/** Whether the chat follows the app live. */
|
|
190
325
|
connection: ChatConnection;
|
|
191
|
-
/**
|
|
192
|
-
|
|
326
|
+
/** ID of the user message whose turn the current status belongs to, or `null` when Base44 reports none. */
|
|
327
|
+
turnId: string | null;
|
|
328
|
+
/**
|
|
329
|
+
* The last failure. It's set whenever `status` is `error`, and on any failed call or connection
|
|
330
|
+
* error. A failed call's error clears on the next action. A connection error stays until
|
|
331
|
+
* {@link Base44Chat.clearError}. A failed build stays while Base44 reports it.
|
|
332
|
+
*/
|
|
193
333
|
error: ChatError | null;
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
334
|
+
/**
|
|
335
|
+
* Sends a prompt to the current app. Base44 queues it while the AI is working. The prompt shows
|
|
336
|
+
* at once as a pending item, and the reply arrives through `items`. Without an app, it sets
|
|
337
|
+
* `error`. Use {@link Base44Chat.create} for the first prompt.
|
|
338
|
+
*
|
|
339
|
+
* @param prompt - The prompt to send.
|
|
340
|
+
* @returns Promise resolving once Base44 accepts the prompt. It never rejects.
|
|
341
|
+
*/
|
|
342
|
+
send(prompt: string): Promise<void>;
|
|
343
|
+
/**
|
|
344
|
+
* Creates an app from its first prompt and reports it through `onAppCreated`.
|
|
345
|
+
*
|
|
346
|
+
* @param prompt - The first prompt, which describes the app.
|
|
347
|
+
* @returns Promise resolving once the app exists. It never rejects.
|
|
348
|
+
*/
|
|
349
|
+
create(prompt: string): Promise<void>;
|
|
350
|
+
/** Clears {@link Base44Chat.error}. A failed build's error stays while Base44 reports it. */
|
|
201
351
|
clearError(): void;
|
|
202
352
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The `@base44/platform/react` entry: one app
|
|
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
|
-
export type { ApprovalQuestion, Base44App, Base44Chat, Base44ChatOptions, Base44ChatBackend, ChatConnection, ChatError, ChatItem, ChatQuestion, ChatStatus, ChatStep, ChoiceEntry, ChoiceQuestion, SecretField, SecretsQuestion, ToolCallAnswer, } from "./chat.types.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";
|
|
4
4
|
export type { SocketSession } from "../client/modules/builder.types.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** The `@base44/platform/react` entry: one app
|
|
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";
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import type { Base44Chat, Base44ChatOptions } from "./chat.types.js";
|
|
2
2
|
/**
|
|
3
|
-
* Runs
|
|
4
|
-
* the platform client, turns Base44's messages into {@link ChatItem | items}, binds
|
|
5
|
-
* every open question to the step it belongs to. You render the items.
|
|
3
|
+
* Runs the AI chat for one app in your own UI.
|
|
6
4
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* {@link
|
|
10
|
-
*
|
|
5
|
+
* The hook renders nothing. It gives you the conversation and the actions, and you draw them:
|
|
6
|
+
* - Follows the app live, and renews its socket session when it expires.
|
|
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.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The actions never throw. A failure sets {@link Base44Chat.error}, and a question whose answer
|
|
12
|
+
* failed opens again. The chat declines a question kind this release doesn't know.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
* {@link Base44Chat.create} just made, so passing the new id back is optional; any change to
|
|
17
|
-
* `appId` forgets that app, so setting `appId` back to `null` starts a new chat.
|
|
14
|
+
* Requires a browser environment and can't be used in the backend.
|
|
18
15
|
*
|
|
19
|
-
*
|
|
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`
|
|
18
|
+
* forgets that app, so setting it back to `null` starts a new chat. Switching apps closes the old
|
|
19
|
+
* session and starts over.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The app to follow, your backend's calls, and what to do with a created app.
|
|
20
22
|
* @returns The conversation, its status, connection and error, and the actions `send`, `create` and `clearError`.
|
|
21
23
|
*
|
|
22
24
|
* @example
|
|
23
25
|
* ```typescript
|
|
24
|
-
* //
|
|
26
|
+
* // Draw the chat and answer an approval
|
|
25
27
|
* const chat = useBase44Chat({ appId, backend, onAppCreated: selectApp });
|
|
26
28
|
* return (
|
|
27
29
|
* <>
|