@base44-preview/platform 0.5.0-pr.355.b5f7fe5 → 0.6.0-pr.364.6994ab8
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/dist/client/client.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { PlatformClient } from "./client.types.js";
|
|
|
11
11
|
* [`createPlatformServer()`](/developers/references/platform-sdk/docs/functions/createPlatformServer)
|
|
12
12
|
* from `@base44/platform/server`.
|
|
13
13
|
*
|
|
14
|
-
* @returns A new platform client.
|
|
14
|
+
* @returns A new platform client, with one property for each module.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
package/dist/client/client.js
CHANGED
|
@@ -11,7 +11,7 @@ import { createChat } from "./modules/chat.js";
|
|
|
11
11
|
* [`createPlatformServer()`](/developers/references/platform-sdk/docs/functions/createPlatformServer)
|
|
12
12
|
* from `@base44/platform/server`.
|
|
13
13
|
*
|
|
14
|
-
* @returns A new platform client.
|
|
14
|
+
* @returns A new platform client, with one property for each module.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
@@ -34,12 +34,14 @@ export interface ToolCallAnswer {
|
|
|
34
34
|
* `X-Request-ID` built from the tool call ID, so a retry resumes the turn only once.
|
|
35
35
|
*
|
|
36
36
|
* Base44 keeps the Send chat message and Submit tool-call input requests open until the AI
|
|
37
|
-
* finishes the turn, which can take minutes. Forward
|
|
38
|
-
* learns from the live updates as soon as Base44 has the prompt or the answer,
|
|
39
|
-
* that, such as a timeout on your server, doesn't set an error. A rejected promise
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
37
|
+
* finishes the turn, which can take minutes. Forward each request and return its result. The hook
|
|
38
|
+
* learns from the live updates as soon as Base44 has the prompt or the answer, so a failure after
|
|
39
|
+
* that, such as a timeout on your server, doesn't set an error. A rejected promise before then sets
|
|
40
|
+
* [`error`](#error).
|
|
41
|
+
*
|
|
42
|
+
* Next.js server actions run one at a time, so one that waits out the turn holds up every later
|
|
43
|
+
* call. In a server action, wait a few seconds for a refusal instead, and resolve if none comes.
|
|
44
|
+
* Base44 refuses a request right away.
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
45
47
|
* ```typescript
|
|
@@ -87,7 +89,8 @@ export interface ChatBackend {
|
|
|
87
89
|
* whenever the session expires. Sessions last one hour.
|
|
88
90
|
*
|
|
89
91
|
* @param appId - ID of the app to follow.
|
|
90
|
-
* @returns Promise resolving to the session
|
|
92
|
+
* @returns Promise resolving to the three fields of a [Create socket session](/api-reference/create-socket-session)
|
|
93
|
+
* response that the browser needs. Keep the response's `session_id` on your server.
|
|
91
94
|
*
|
|
92
95
|
* @example
|
|
93
96
|
* ```typescript
|
|
@@ -116,6 +119,54 @@ export interface ChatBackend {
|
|
|
116
119
|
* @param appId - ID of the app.
|
|
117
120
|
* @param content - The prompt.
|
|
118
121
|
* @returns Promise resolving when Base44 answers the request, which can be when the turn ends.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Your route handler for sendMessage(), forwarding the request
|
|
126
|
+
* export async function POST(request: Request) {
|
|
127
|
+
* const { appId, content } = await request.json();
|
|
128
|
+
* // Check that the signed-in user may use this app before you forward anything
|
|
129
|
+
* const response = await fetch(`https://app.base44.com/api/apps/${appId}/chat/message`, {
|
|
130
|
+
* method: "POST",
|
|
131
|
+
* headers: {
|
|
132
|
+
* Authorization: `Bearer ${process.env.BASE44_ACCESS_TOKEN}`,
|
|
133
|
+
* "Content-Type": "application/json",
|
|
134
|
+
* "X-Request-ID": crypto.randomUUID(),
|
|
135
|
+
* },
|
|
136
|
+
* body: JSON.stringify({ content }),
|
|
137
|
+
* });
|
|
138
|
+
* return new Response(response.body, { status: response.status });
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Your server action for sendMessage(), waiting a few seconds for a refusal
|
|
143
|
+
* "use server";
|
|
144
|
+
*
|
|
145
|
+
* export async function sendMessage(appId: string, content: string) {
|
|
146
|
+
* const sent = fetch(`https://app.base44.com/api/apps/${appId}/chat/message`, {
|
|
147
|
+
* method: "POST",
|
|
148
|
+
* headers: {
|
|
149
|
+
* Authorization: `Bearer ${process.env.BASE44_ACCESS_TOKEN}`,
|
|
150
|
+
* "Content-Type": "application/json",
|
|
151
|
+
* "X-Request-ID": crypto.randomUUID(),
|
|
152
|
+
* },
|
|
153
|
+
* body: JSON.stringify({ content }),
|
|
154
|
+
* });
|
|
155
|
+
* const timeout = new Promise<null>((resolve) => setTimeout(resolve, 3000, null));
|
|
156
|
+
* const response = await Promise.race([sent, timeout]);
|
|
157
|
+
* if (response === null) {
|
|
158
|
+
* // The caller has moved on, so a later failure can only be logged
|
|
159
|
+
* sent.then(
|
|
160
|
+
* (late) => {
|
|
161
|
+
* if (!late.ok) console.error(`Send chat message failed: ${late.status}`);
|
|
162
|
+
* },
|
|
163
|
+
* (error) => console.error("Send chat message failed", error),
|
|
164
|
+
* );
|
|
165
|
+
* return;
|
|
166
|
+
* }
|
|
167
|
+
* if (!response.ok) throw new Error(`Send chat message failed: ${response.status}`);
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
119
170
|
*/
|
|
120
171
|
sendMessage(appId: string, content: string): Promise<void>;
|
|
121
172
|
/**
|
|
@@ -125,6 +176,30 @@ export interface ChatBackend {
|
|
|
125
176
|
* @param appId - ID of the app.
|
|
126
177
|
* @param answer - The tool call and the answer to it.
|
|
127
178
|
* @returns Promise resolving when Base44 answers the request, which can be when the turn ends.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* // Your route handler for submitToolCallInput(), forwarding the answer
|
|
183
|
+
* export async function POST(request: Request) {
|
|
184
|
+
* const { appId, answer } = await request.json();
|
|
185
|
+
* // Check that the signed-in user may use this app before you forward anything
|
|
186
|
+
* const response = await fetch(`https://app.base44.com/api/apps/${appId}/chat/submit-tool-call-input`, {
|
|
187
|
+
* method: "POST",
|
|
188
|
+
* headers: {
|
|
189
|
+
* Authorization: `Bearer ${process.env.BASE44_ACCESS_TOKEN}`,
|
|
190
|
+
* "Content-Type": "application/json",
|
|
191
|
+
* "X-Request-ID": `submit-${answer.toolCallId}`,
|
|
192
|
+
* },
|
|
193
|
+
* body: JSON.stringify({
|
|
194
|
+
* tool_call_id: answer.toolCallId,
|
|
195
|
+
* action: answer.approve ? "approved" : "rejected",
|
|
196
|
+
* // A choice's answers or a secrets request's values, and nothing for an approval or a decline
|
|
197
|
+
* extra_user_input: answer.extraUserInput,
|
|
198
|
+
* }),
|
|
199
|
+
* });
|
|
200
|
+
* return new Response(response.body, { status: response.status });
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
128
203
|
*/
|
|
129
204
|
submitToolCallInput(appId: string, answer: ToolCallAnswer): Promise<void>;
|
|
130
205
|
}
|
|
@@ -194,8 +269,9 @@ export interface ChatAnswer {
|
|
|
194
269
|
*
|
|
195
270
|
* Each kind has only the actions that fit it, and every kind can be declined. Calling an action
|
|
196
271
|
* closes the question right away and sends the answer through your
|
|
197
|
-
* [`submitToolCallInput()`](#submittoolcallinput). The actions never throw.
|
|
198
|
-
* [`error`](#error)
|
|
272
|
+
* [`submitToolCallInput()`](#submittoolcallinput). The actions never throw. If Base44 refuses an
|
|
273
|
+
* answer, or your backend fails before Base44 has it, [`error`](#error) is set and the question
|
|
274
|
+
* opens again.
|
|
199
275
|
*
|
|
200
276
|
* The hook declines a question kind this release doesn't know, once per tool call, when Base44
|
|
201
277
|
* names that kind on the last assistant message. If the decline fails, [`error`](#error) says
|
|
@@ -450,7 +526,8 @@ export interface ChatOptions {
|
|
|
450
526
|
*
|
|
451
527
|
* @groupDescription Methods
|
|
452
528
|
* Functions on the same object, which you call to act on the chat, as in `chat.send(prompt)`. They
|
|
453
|
-
* never throw.
|
|
529
|
+
* never throw. If Base44 refuses the request, or your backend fails before Base44 has the prompt or
|
|
530
|
+
* answer, [`error`](#error) is set.
|
|
454
531
|
*/
|
|
455
532
|
export interface UseChatResult {
|
|
456
533
|
/** The conversation, oldest first. Each open question appears with the step that asked it. */
|
package/dist/server/server.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { PlatformServer } from "./server.types.js";
|
|
|
7
7
|
* such as [`webhooks`](/developers/references/platform-sdk/docs/interfaces/webhooks). It takes no
|
|
8
8
|
* options and makes no network requests. Each module takes what it needs when you call it.
|
|
9
9
|
*
|
|
10
|
-
* @returns A new platform server client.
|
|
10
|
+
* @returns A new platform server client, with one property for each module.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
package/dist/server/server.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createWebhooks } from "./modules/webhooks.js";
|
|
|
7
7
|
* such as [`webhooks`](/developers/references/platform-sdk/docs/interfaces/webhooks). It takes no
|
|
8
8
|
* options and makes no network requests. Each module takes what it needs when you call it.
|
|
9
9
|
*
|
|
10
|
-
* @returns A new platform server client.
|
|
10
|
+
* @returns A new platform server client, with one property for each module.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-pr.364.6994ab8",
|
|
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",
|