@base44-preview/sdk 0.8.44-pr.265.8da157e → 0.8.44-pr.265.a1a63b2
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/{build-session.d.ts → builder-session.d.ts} +12 -12
- package/dist/{build-session.js → builder-session.js} +9 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/modules/{build.d.ts → builder.d.ts} +7 -7
- package/dist/modules/{build.js → builder.js} +10 -10
- package/dist/modules/{build.types.d.ts → builder.types.d.ts} +83 -83
- package/dist/platform-client.d.ts +4 -4
- package/dist/platform-client.js +11 -11
- package/dist/platform-client.types.d.ts +9 -9
- package/package.json +1 -1
- /package/dist/modules/{build.types.js → builder.types.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BuilderSessionReader } from "./modules/builder.types.js";
|
|
2
2
|
import type { CreateClientOptions } from "./client.types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Configuration for reading a
|
|
4
|
+
* Configuration for reading a builder session with a grant.
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
7
|
-
/** The app being built. A
|
|
6
|
+
export interface CreateBuilderSessionConfig {
|
|
7
|
+
/** The app being built. A builder session *is* an app — there is nothing separate to open. */
|
|
8
8
|
appId: string;
|
|
9
9
|
/**
|
|
10
10
|
* The Base44 server URL.
|
|
@@ -15,7 +15,7 @@ export interface CreateBuildSessionConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* A grant token.
|
|
17
17
|
*
|
|
18
|
-
* Use {@link
|
|
18
|
+
* Use {@link CreateBuilderSessionConfig.getToken | getToken} instead for anything
|
|
19
19
|
* that outlives one grant, which most builds do.
|
|
20
20
|
*/
|
|
21
21
|
token?: string;
|
|
@@ -32,10 +32,10 @@ export interface CreateBuildSessionConfig {
|
|
|
32
32
|
options?: CreateClientOptions;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Reads one
|
|
35
|
+
* Reads one builder session with a grant.
|
|
36
36
|
*
|
|
37
37
|
* The browser's entry point. A grant is read-only, scoped to one session and
|
|
38
|
-
* short-lived, so this returns the read half of a
|
|
38
|
+
* short-lived, so this returns the read half of a builder session and nothing else
|
|
39
39
|
* — the writes live on the server, where the credential that can start a turn
|
|
40
40
|
* belongs.
|
|
41
41
|
*
|
|
@@ -46,16 +46,16 @@ export interface CreateBuildSessionConfig {
|
|
|
46
46
|
* browser credential spend your workspace's credits.
|
|
47
47
|
*
|
|
48
48
|
* Mint the grant on your server with
|
|
49
|
-
* {@link
|
|
49
|
+
* {@link BuilderSession.createGrant | createGrant()}.
|
|
50
50
|
*
|
|
51
51
|
* @param config - The app, and how to get a grant for it.
|
|
52
52
|
* @returns The read-only session.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```typescript
|
|
56
|
-
* import {
|
|
56
|
+
* import { createBuilderSession } from '@base44/sdk';
|
|
57
57
|
*
|
|
58
|
-
* const
|
|
58
|
+
* const builder = createBuilderSession({
|
|
59
59
|
* appId,
|
|
60
60
|
* // Re-read on every reconnect, so a build outliving its grant just works.
|
|
61
61
|
* getToken: () =>
|
|
@@ -64,7 +64,7 @@ export interface CreateBuildSessionConfig {
|
|
|
64
64
|
* .then((grant) => grant.token),
|
|
65
65
|
* });
|
|
66
66
|
*
|
|
67
|
-
* const unsubscribe =
|
|
67
|
+
* const unsubscribe = builder.subscribe((event) => {
|
|
68
68
|
* switch (event.type) {
|
|
69
69
|
* case 'message.updated': upsertMessage(event.data); break; // by messageId
|
|
70
70
|
* case 'state.changed': setStatus(event.data); break;
|
|
@@ -76,4 +76,4 @@ export interface CreateBuildSessionConfig {
|
|
|
76
76
|
* await fetch('/api/base44/message', { method: 'POST', body: … });
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
export declare function
|
|
79
|
+
export declare function createBuilderSession(config: CreateBuilderSessionConfig): BuilderSessionReader;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createAxiosClient } from "./utils/axios-client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createBuilderSessionReader } from "./modules/builder.js";
|
|
3
3
|
/**
|
|
4
|
-
* Reads one
|
|
4
|
+
* Reads one builder session with a grant.
|
|
5
5
|
*
|
|
6
6
|
* The browser's entry point. A grant is read-only, scoped to one session and
|
|
7
|
-
* short-lived, so this returns the read half of a
|
|
7
|
+
* short-lived, so this returns the read half of a builder session and nothing else
|
|
8
8
|
* — the writes live on the server, where the credential that can start a turn
|
|
9
9
|
* belongs.
|
|
10
10
|
*
|
|
@@ -15,16 +15,16 @@ import { createBuildSessionReader } from "./modules/build.js";
|
|
|
15
15
|
* browser credential spend your workspace's credits.
|
|
16
16
|
*
|
|
17
17
|
* Mint the grant on your server with
|
|
18
|
-
* {@link
|
|
18
|
+
* {@link BuilderSession.createGrant | createGrant()}.
|
|
19
19
|
*
|
|
20
20
|
* @param config - The app, and how to get a grant for it.
|
|
21
21
|
* @returns The read-only session.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```typescript
|
|
25
|
-
* import {
|
|
25
|
+
* import { createBuilderSession } from '@base44/sdk';
|
|
26
26
|
*
|
|
27
|
-
* const
|
|
27
|
+
* const builder = createBuilderSession({
|
|
28
28
|
* appId,
|
|
29
29
|
* // Re-read on every reconnect, so a build outliving its grant just works.
|
|
30
30
|
* getToken: () =>
|
|
@@ -33,7 +33,7 @@ import { createBuildSessionReader } from "./modules/build.js";
|
|
|
33
33
|
* .then((grant) => grant.token),
|
|
34
34
|
* });
|
|
35
35
|
*
|
|
36
|
-
* const unsubscribe =
|
|
36
|
+
* const unsubscribe = builder.subscribe((event) => {
|
|
37
37
|
* switch (event.type) {
|
|
38
38
|
* case 'message.updated': upsertMessage(event.data); break; // by messageId
|
|
39
39
|
* case 'state.changed': setStatus(event.data); break;
|
|
@@ -45,9 +45,9 @@ import { createBuildSessionReader } from "./modules/build.js";
|
|
|
45
45
|
* await fetch('/api/base44/message', { method: 'POST', body: … });
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
export function
|
|
48
|
+
export function createBuilderSession(config) {
|
|
49
49
|
const { appId, serverUrl = "https://base44.app", token, getToken, options, } = config;
|
|
50
|
-
return
|
|
50
|
+
return createBuilderSessionReader({
|
|
51
51
|
axios: createAxiosClient({
|
|
52
52
|
baseURL: `${serverUrl}/api`,
|
|
53
53
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createClient, createClientFromRequest, type Base44Client, type CreateClientConfig, type CreateClientOptions } from "./client.js";
|
|
2
2
|
import { createPlatformClient, type CreatePlatformClientConfig, type PlatformClient, type PrincipalClient } from "./platform-client.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createBuilderSession, type CreateBuilderSessionConfig } from "./builder-session.js";
|
|
4
4
|
import { Base44Error, type Base44ErrorJSON } from "./utils/axios-client.js";
|
|
5
5
|
import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from "./utils/auth-utils.js";
|
|
6
|
-
export { createClient, createClientFromRequest, createPlatformClient,
|
|
7
|
-
export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, CreatePlatformClientConfig, PlatformClient, PrincipalClient,
|
|
6
|
+
export { createClient, createClientFromRequest, createPlatformClient, createBuilderSession, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
7
|
+
export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, CreatePlatformClientConfig, PlatformClient, PrincipalClient, CreateBuilderSessionConfig, };
|
|
8
8
|
export * from "./types.js";
|
|
9
9
|
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityRecord, EntityTypeRegistry, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
|
|
10
10
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
|
@@ -16,7 +16,7 @@ export type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
|
16
16
|
export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, } from "./modules/actors.types.js";
|
|
17
17
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
18
18
|
export type { PlatformsModule, PrincipalRole, ProvisionPrincipalParams, ServicePrincipal, DeprovisionResult, } from "./modules/platforms.types.js";
|
|
19
|
-
export type {
|
|
19
|
+
export type { BuilderEvent, BuilderEventType, BuilderGrant, BuilderMessage, BuilderMessagePage, BuilderResponse, BuilderSession, BuilderSessionReader, BuilderState, BuilderStatus, BuilderToolCall, BuilderTurn, BuilderTurnRef, BuilderWaitingKind, BuilderWaitingOn, CreateBuilderGrantOptions, ListBuilderMessagesOptions, RespondToBuilderOptions, SendBuilderMessageOptions, SubscribeToBuilderOptions, WaitForTurnOptions, } from "./modules/builder.types.js";
|
|
20
20
|
export { Actor, type Conn } from "./actor.js";
|
|
21
21
|
export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
|
|
22
22
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createClient, createClientFromRequest, } from "./client.js";
|
|
2
2
|
import { createPlatformClient, } from "./platform-client.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createBuilderSession, } from "./builder-session.js";
|
|
4
4
|
import { Base44Error } from "./utils/axios-client.js";
|
|
5
5
|
import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, } from "./utils/auth-utils.js";
|
|
6
|
-
export { createClient, createClientFromRequest, createPlatformClient,
|
|
6
|
+
export { createClient, createClientFromRequest, createPlatformClient, createBuilderSession, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
7
7
|
export * from "./types.js";
|
|
8
8
|
export { Actor } from "./actor.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuilderSession, BuilderSessionReader } from "./builder.types.js";
|
|
3
3
|
/** What the build module needs to talk to one app's session. @internal */
|
|
4
|
-
export interface
|
|
4
|
+
export interface BuilderSessionDeps {
|
|
5
5
|
/** An Axios client based at `${serverUrl}/api`. */
|
|
6
6
|
axios: AxiosInstance;
|
|
7
|
-
/** The app whose
|
|
7
|
+
/** The app whose builder session this is. */
|
|
8
8
|
appId: string;
|
|
9
9
|
/** Used to build the absolute stream URL, which `fetch` needs. */
|
|
10
10
|
serverUrl: string;
|
|
@@ -21,18 +21,18 @@ export interface BuildSessionDeps {
|
|
|
21
21
|
getToken?: () => string | Promise<string> | undefined;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* The read half of a
|
|
24
|
+
* The read half of a builder session — what a grant can do.
|
|
25
25
|
*
|
|
26
26
|
* @param deps - Transport, app id and credential.
|
|
27
27
|
* @returns The read-only session.
|
|
28
28
|
* @internal
|
|
29
29
|
*/
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function createBuilderSessionReader(deps: BuilderSessionDeps): BuilderSessionReader;
|
|
31
31
|
/**
|
|
32
|
-
* A
|
|
32
|
+
* A builder session with the writes, for a credential that may start turns.
|
|
33
33
|
*
|
|
34
34
|
* @param deps - Transport, app id and credential.
|
|
35
35
|
* @returns The full session.
|
|
36
36
|
* @internal
|
|
37
37
|
*/
|
|
38
|
-
export declare function
|
|
38
|
+
export declare function createBuilderSessionModule(deps: BuilderSessionDeps): BuilderSession;
|
|
@@ -79,7 +79,7 @@ function toMessage(raw) {
|
|
|
79
79
|
*
|
|
80
80
|
* Unrecognised types are dropped here rather than passed through. The contract
|
|
81
81
|
* requires clients to ignore them, so doing it once at the boundary is what lets
|
|
82
|
-
* {@link
|
|
82
|
+
* {@link BuilderEvent} stay a closed union that narrows on `type` — the alternative
|
|
83
83
|
* is an open union whose `data` is `unknown` in every branch.
|
|
84
84
|
*/
|
|
85
85
|
function toBuildEvent(data, frameId) {
|
|
@@ -120,10 +120,10 @@ async function streamFailure(response) {
|
|
|
120
120
|
catch (_b) {
|
|
121
121
|
/* a non-JSON error body is still the best message available */
|
|
122
122
|
}
|
|
123
|
-
return new Base44Error(detail || `Build stream failed with ${response.status}`, response.status, "
|
|
123
|
+
return new Base44Error(detail || `Build stream failed with ${response.status}`, response.status, "BUILDER_STREAM_FAILED", body, undefined);
|
|
124
124
|
}
|
|
125
125
|
/** Every route in the family hangs off this. */
|
|
126
|
-
const
|
|
126
|
+
const builderPath = (appId) => `/v1/apps/${encodeURIComponent(appId)}/build`;
|
|
127
127
|
/**
|
|
128
128
|
* The credential, resolved per call.
|
|
129
129
|
*
|
|
@@ -146,15 +146,15 @@ function delay(ms, signal) {
|
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* The read half of a
|
|
149
|
+
* The read half of a builder session — what a grant can do.
|
|
150
150
|
*
|
|
151
151
|
* @param deps - Transport, app id and credential.
|
|
152
152
|
* @returns The read-only session.
|
|
153
153
|
* @internal
|
|
154
154
|
*/
|
|
155
|
-
export function
|
|
155
|
+
export function createBuilderSessionReader(deps) {
|
|
156
156
|
const { axios, appId, getToken } = deps;
|
|
157
|
-
const path =
|
|
157
|
+
const path = builderPath(appId);
|
|
158
158
|
const eventsUrl = `${deps.serverUrl.replace(/\/+$/, "")}/api${path}/events`;
|
|
159
159
|
const authHeaders = () => bearer(getToken);
|
|
160
160
|
const getState = async () => {
|
|
@@ -401,16 +401,16 @@ export function createBuildSessionReader(deps) {
|
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
|
-
* A
|
|
404
|
+
* A builder session with the writes, for a credential that may start turns.
|
|
405
405
|
*
|
|
406
406
|
* @param deps - Transport, app id and credential.
|
|
407
407
|
* @returns The full session.
|
|
408
408
|
* @internal
|
|
409
409
|
*/
|
|
410
|
-
export function
|
|
410
|
+
export function createBuilderSessionModule(deps) {
|
|
411
411
|
const { axios, appId, getToken, serverUrl } = deps;
|
|
412
|
-
const path =
|
|
413
|
-
const reader =
|
|
412
|
+
const path = builderPath(appId);
|
|
413
|
+
const reader = createBuilderSessionReader(deps);
|
|
414
414
|
const authHeaders = () => bearer(getToken);
|
|
415
415
|
const writeHeaders = async (idempotencyKey) => ({
|
|
416
416
|
...(await authHeaders()),
|
|
@@ -5,35 +5,35 @@
|
|
|
5
5
|
* no answer clears — being out of credits is the one that exists today — and it
|
|
6
6
|
* resumes once that condition does. `reason` says which.
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type BuilderStatus = "idle" | "running" | "waiting" | "blocked" | "error";
|
|
9
9
|
/**
|
|
10
10
|
* Why a turn is suspended, and therefore what to render.
|
|
11
11
|
*
|
|
12
|
-
* All three are answerable with {@link
|
|
12
|
+
* All three are answerable with {@link BuilderSession.respond | respond()}, and each
|
|
13
13
|
* wants a different affordance: a form, a picker, an approve/reject. Being out of
|
|
14
14
|
* credits is deliberately *not* one of these — it is `blocked`, because no
|
|
15
15
|
* response resolves it.
|
|
16
16
|
*/
|
|
17
|
-
export type
|
|
17
|
+
export type BuilderWaitingKind = "input" | "choice" | "approval";
|
|
18
18
|
/**
|
|
19
19
|
* The waitpoint holding a turn open.
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
21
|
+
export interface BuilderWaitingOn {
|
|
22
22
|
/** What kind of answer resolves it. */
|
|
23
|
-
kind:
|
|
23
|
+
kind: BuilderWaitingKind;
|
|
24
24
|
/** The id to answer with. It is the tool call's id, and it goes stale when the turn moves on. */
|
|
25
25
|
waitpointId: string;
|
|
26
26
|
/** The tool that asked, when the server names one. Display only. */
|
|
27
27
|
toolName?: string;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* A
|
|
30
|
+
* A builder session's current state.
|
|
31
31
|
*/
|
|
32
|
-
export interface
|
|
32
|
+
export interface BuilderState {
|
|
33
33
|
/** Where the turn stands. */
|
|
34
|
-
status:
|
|
34
|
+
status: BuilderStatus;
|
|
35
35
|
/** Present only while `status` is `"waiting"`. */
|
|
36
|
-
waitingOn?:
|
|
36
|
+
waitingOn?: BuilderWaitingOn;
|
|
37
37
|
/** Why a `blocked` turn is blocked. `"quota"` is out of credits. */
|
|
38
38
|
reason?: string;
|
|
39
39
|
/** The turn this state belongs to, so a state arriving after a reconnect can be told from a stale one. */
|
|
@@ -52,7 +52,7 @@ export interface BuildState {
|
|
|
52
52
|
/**
|
|
53
53
|
* One tool call inside a streamed message.
|
|
54
54
|
*/
|
|
55
|
-
export interface
|
|
55
|
+
export interface BuilderToolCall {
|
|
56
56
|
/** The call's id. When this call is a waitpoint, this is the `waitpointId` to answer with. */
|
|
57
57
|
id: string;
|
|
58
58
|
/** The tool's name. */
|
|
@@ -62,7 +62,7 @@ export interface BuildToolCall {
|
|
|
62
62
|
/** Whether this call is waiting on a person. */
|
|
63
63
|
requiresUserInput: boolean;
|
|
64
64
|
/** What kind of answer it wants, when it is waiting. */
|
|
65
|
-
waitingOnKind:
|
|
65
|
+
waitingOnKind: BuilderWaitingKind | null;
|
|
66
66
|
/**
|
|
67
67
|
* The call's arguments, as the raw JSON string the model produced.
|
|
68
68
|
*
|
|
@@ -81,11 +81,11 @@ export interface BuildToolCall {
|
|
|
81
81
|
/**
|
|
82
82
|
* One message in a build conversation.
|
|
83
83
|
*
|
|
84
|
-
* The same shape from the stream and from {@link
|
|
84
|
+
* The same shape from the stream and from {@link BuilderSessionReader.listMessages | listMessages()},
|
|
85
85
|
* so reconciling after an outage cannot produce a different transcript than the
|
|
86
86
|
* one that was streamed.
|
|
87
87
|
*/
|
|
88
|
-
export interface
|
|
88
|
+
export interface BuilderMessage {
|
|
89
89
|
/** The message's id, and the key it is replaced under. */
|
|
90
90
|
messageId: string;
|
|
91
91
|
/** Who wrote it. A partner's own user messages come back on the stream too. */
|
|
@@ -93,14 +93,14 @@ export interface BuildMessage {
|
|
|
93
93
|
/** The message text. */
|
|
94
94
|
content: string;
|
|
95
95
|
/** The tool calls this message carries. */
|
|
96
|
-
toolCalls:
|
|
96
|
+
toolCalls: BuilderToolCall[];
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* The event types a
|
|
99
|
+
* The event types a builder session emits.
|
|
100
100
|
*/
|
|
101
|
-
export type
|
|
101
|
+
export type BuilderEventType = "state.changed" | "turn.started" | "turn.finished" | "message.updated" | "error" | "conversation.reset" | "files.changed";
|
|
102
102
|
/** Fields every event carries. */
|
|
103
|
-
interface
|
|
103
|
+
interface BuilderEventBase {
|
|
104
104
|
/**
|
|
105
105
|
* The journal sequence. Monotonic per session, and the resume cursor — the SDK
|
|
106
106
|
* tracks it for you across reconnects.
|
|
@@ -110,7 +110,7 @@ interface BuildEventBase {
|
|
|
110
110
|
turnId?: string;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
* One event from a
|
|
113
|
+
* One event from a builder session.
|
|
114
114
|
*
|
|
115
115
|
* A discriminated union: switch on `type` and `data` narrows with it.
|
|
116
116
|
*
|
|
@@ -118,18 +118,18 @@ interface BuildEventBase {
|
|
|
118
118
|
* in-progress assistant message on every tick, so the contract is last-write-wins
|
|
119
119
|
* per `messageId` — replace what you hold, never append. Text still arrives
|
|
120
120
|
* progressively; there is simply no delta event.
|
|
121
|
-
* {@link
|
|
121
|
+
* {@link BuilderSessionReader.streamText | streamText()} is the append-shaped view,
|
|
122
122
|
* for UIs that want one.
|
|
123
123
|
*/
|
|
124
|
-
export type
|
|
124
|
+
export type BuilderEvent = ({
|
|
125
125
|
/** A turn started, finished, changed state, or failed. */
|
|
126
126
|
type: "turn.started" | "turn.finished" | "state.changed" | "error";
|
|
127
|
-
data:
|
|
128
|
-
} &
|
|
127
|
+
data: BuilderState;
|
|
128
|
+
} & BuilderEventBase) | ({
|
|
129
129
|
/** A message was written or rewritten. Replace what you hold for this `messageId`. */
|
|
130
130
|
type: "message.updated";
|
|
131
|
-
data:
|
|
132
|
-
} &
|
|
131
|
+
data: BuilderMessage;
|
|
132
|
+
} & BuilderEventBase) | ({
|
|
133
133
|
/**
|
|
134
134
|
* The conversation was rewritten underneath you (a checkpoint restore, a
|
|
135
135
|
* branch sync), or the app's files changed outside a turn. Both carry no
|
|
@@ -137,16 +137,16 @@ export type BuildEvent = ({
|
|
|
137
137
|
*/
|
|
138
138
|
type: "conversation.reset" | "files.changed";
|
|
139
139
|
data: Record<string, never>;
|
|
140
|
-
} &
|
|
140
|
+
} & BuilderEventBase);
|
|
141
141
|
/**
|
|
142
142
|
* An answer to a waitpoint.
|
|
143
143
|
*
|
|
144
144
|
* Discriminated on `kind`, which is checked against the *live* waitpoint: sending
|
|
145
145
|
* an approval to a question is a 409 rather than a silent coercion. `waitpointId`
|
|
146
|
-
* comes from {@link
|
|
146
|
+
* comes from {@link BuilderWaitingOn.waitpointId}, and a stale one is also a 409 —
|
|
147
147
|
* so read the current state rather than remembering an id across turns.
|
|
148
148
|
*/
|
|
149
|
-
export type
|
|
149
|
+
export type BuilderResponse = {
|
|
150
150
|
/** Answering an approval: a decision, and nothing else. */
|
|
151
151
|
kind: "approval";
|
|
152
152
|
/** The waitpoint to answer. */
|
|
@@ -166,8 +166,8 @@ export type BuildResponse = {
|
|
|
166
166
|
*/
|
|
167
167
|
value?: Record<string, unknown>;
|
|
168
168
|
};
|
|
169
|
-
/** Options for {@link
|
|
170
|
-
export interface
|
|
169
|
+
/** Options for {@link BuilderSession.sendMessage | sendMessage()}. */
|
|
170
|
+
export interface SendBuilderMessageOptions {
|
|
171
171
|
/** Attachments, as URLs the builder can fetch. */
|
|
172
172
|
fileUrls?: string[];
|
|
173
173
|
/**
|
|
@@ -183,35 +183,35 @@ export interface SendBuildMessageOptions {
|
|
|
183
183
|
*/
|
|
184
184
|
idempotencyKey?: string;
|
|
185
185
|
}
|
|
186
|
-
/** Options for {@link
|
|
187
|
-
export interface
|
|
188
|
-
/** See {@link
|
|
186
|
+
/** Options for {@link BuilderSession.respond | respond()}. */
|
|
187
|
+
export interface RespondToBuilderOptions {
|
|
188
|
+
/** See {@link SendBuilderMessageOptions.idempotencyKey}. */
|
|
189
189
|
idempotencyKey?: string;
|
|
190
190
|
}
|
|
191
191
|
/** The turn a write started. */
|
|
192
|
-
export interface
|
|
192
|
+
export interface BuilderTurnRef {
|
|
193
193
|
/** The session the turn runs in. Always the app id. */
|
|
194
194
|
sessionId: string;
|
|
195
195
|
/**
|
|
196
196
|
* The turn's id.
|
|
197
197
|
*
|
|
198
198
|
* Carried on every event the turn emits, and the id
|
|
199
|
-
* {@link
|
|
200
|
-
* {@link
|
|
199
|
+
* {@link BuilderSessionReader.getTurn | getTurn()} and
|
|
200
|
+
* {@link BuilderSessionReader.waitForTurn | waitForTurn()} take.
|
|
201
201
|
*/
|
|
202
202
|
turnId: string;
|
|
203
203
|
}
|
|
204
204
|
/** One turn's outcome. */
|
|
205
|
-
export interface
|
|
205
|
+
export interface BuilderTurn {
|
|
206
206
|
/** The turn asked about. */
|
|
207
207
|
turnId: string;
|
|
208
208
|
/** Whether this is the turn running right now, rather than a settled one read back from the journal. */
|
|
209
209
|
live: boolean;
|
|
210
210
|
/** The state the turn is in, or the last one it reached. */
|
|
211
|
-
state:
|
|
211
|
+
state: BuilderState;
|
|
212
212
|
}
|
|
213
|
-
/** Options for {@link
|
|
214
|
-
export interface
|
|
213
|
+
/** Options for {@link BuilderSession.createGrant | createGrant()}. */
|
|
214
|
+
export interface CreateBuilderGrantOptions {
|
|
215
215
|
/**
|
|
216
216
|
* How long the grant lives.
|
|
217
217
|
*
|
|
@@ -230,17 +230,17 @@ export interface CreateBuildGrantOptions {
|
|
|
230
230
|
subject?: string;
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
-
* A read-only credential for one
|
|
233
|
+
* A read-only credential for one builder session.
|
|
234
234
|
*
|
|
235
235
|
* The only Base44 credential that should ever reach a browser: it cannot send a
|
|
236
236
|
* message, answer a waitpoint, cancel a turn, or touch any other app. That
|
|
237
237
|
* asymmetry is the design — reads go browser to Base44 directly, writes go
|
|
238
238
|
* through your server — and it is why a leaked grant cannot spend your credits.
|
|
239
239
|
*/
|
|
240
|
-
export interface
|
|
240
|
+
export interface BuilderGrant {
|
|
241
241
|
/** The session it reads. Always the app id. */
|
|
242
242
|
sessionId: string;
|
|
243
|
-
/** The grant's id, for {@link
|
|
243
|
+
/** The grant's id, for {@link BuilderSession.revokeGrant | revokeGrant()}. */
|
|
244
244
|
grantId: string;
|
|
245
245
|
/** The token itself. Hand this to the browser; hand it nothing else. */
|
|
246
246
|
token: string;
|
|
@@ -251,8 +251,8 @@ export interface BuildGrant {
|
|
|
251
251
|
/** The stream endpoint, absolute. Useful for a client that is not this SDK. */
|
|
252
252
|
eventsUrl: string;
|
|
253
253
|
}
|
|
254
|
-
/** Options for {@link
|
|
255
|
-
export interface
|
|
254
|
+
/** Options for {@link BuilderSessionReader.listMessages | listMessages()}. */
|
|
255
|
+
export interface ListBuilderMessagesOptions {
|
|
256
256
|
/**
|
|
257
257
|
* The cursor from a previous page's `nextAfter`.
|
|
258
258
|
*
|
|
@@ -272,14 +272,14 @@ export interface ListBuildMessagesOptions {
|
|
|
272
272
|
limit?: number;
|
|
273
273
|
}
|
|
274
274
|
/** One page of conversation history. */
|
|
275
|
-
export interface
|
|
275
|
+
export interface BuilderMessagePage {
|
|
276
276
|
/** The page, oldest first. */
|
|
277
|
-
messages:
|
|
277
|
+
messages: BuilderMessage[];
|
|
278
278
|
/** The cursor for the next page, or `null` at the end of the history. */
|
|
279
279
|
nextAfter: string | null;
|
|
280
280
|
}
|
|
281
281
|
/** Options for the subscription forms. */
|
|
282
|
-
export interface
|
|
282
|
+
export interface SubscribeToBuilderOptions {
|
|
283
283
|
/**
|
|
284
284
|
* Where to resume from.
|
|
285
285
|
*
|
|
@@ -303,31 +303,31 @@ export interface SubscribeToBuildOptions {
|
|
|
303
303
|
/** Stops the subscription when aborted, the same as calling the returned unsubscribe. */
|
|
304
304
|
signal?: AbortSignal;
|
|
305
305
|
}
|
|
306
|
-
/** Options for {@link
|
|
306
|
+
/** Options for {@link BuilderSessionReader.waitForTurn | waitForTurn()}. */
|
|
307
307
|
export interface WaitForTurnOptions {
|
|
308
|
-
/** Gives up waiting when aborted. The turn itself is unaffected — use {@link
|
|
308
|
+
/** Gives up waiting when aborted. The turn itself is unaffected — use {@link BuilderSession.cancel | cancel()} to stop it. */
|
|
309
309
|
signal?: AbortSignal;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
|
-
* A
|
|
312
|
+
* A builder session, read-only.
|
|
313
313
|
*
|
|
314
314
|
* What a grant can do. Obtained from
|
|
315
|
-
* {@link
|
|
316
|
-
* point; the server-side {@link
|
|
315
|
+
* {@link createBuilderSession | createBuilderSession()}, which is the browser's entry
|
|
316
|
+
* point; the server-side {@link BuilderSession} adds the writes on top.
|
|
317
317
|
*/
|
|
318
|
-
export interface
|
|
319
|
-
/** The app this session builds. A
|
|
318
|
+
export interface BuilderSessionReader {
|
|
319
|
+
/** The app this session builds. A builder session *is* an app — there is no separate session to open. */
|
|
320
320
|
readonly appId: string;
|
|
321
321
|
/**
|
|
322
322
|
* The session's current state.
|
|
323
323
|
*
|
|
324
324
|
* The supported polling floor, for a client that cannot hold a connection open.
|
|
325
|
-
* Anything that can should {@link
|
|
325
|
+
* Anything that can should {@link BuilderSessionReader.subscribe | subscribe()}
|
|
326
326
|
* instead — this answers from the app itself on every call.
|
|
327
327
|
*
|
|
328
328
|
* @returns Where the build stands right now.
|
|
329
329
|
*/
|
|
330
|
-
getState(): Promise<
|
|
330
|
+
getState(): Promise<BuilderState>;
|
|
331
331
|
/**
|
|
332
332
|
* Reads conversation history, newest page first and oldest-first within a page.
|
|
333
333
|
*
|
|
@@ -341,13 +341,13 @@ export interface BuildSessionReader {
|
|
|
341
341
|
* ```typescript
|
|
342
342
|
* let after: string | null | undefined = undefined;
|
|
343
343
|
* do {
|
|
344
|
-
* const page = await
|
|
344
|
+
* const page = await builder.listMessages({ after });
|
|
345
345
|
* render(page.messages);
|
|
346
346
|
* after = page.nextAfter;
|
|
347
347
|
* } while (after);
|
|
348
348
|
* ```
|
|
349
349
|
*/
|
|
350
|
-
listMessages(options?:
|
|
350
|
+
listMessages(options?: ListBuilderMessagesOptions): Promise<BuilderMessagePage>;
|
|
351
351
|
/**
|
|
352
352
|
* One turn's outcome, so a write's `turnId` is followable without the stream.
|
|
353
353
|
*
|
|
@@ -359,7 +359,7 @@ export interface BuildSessionReader {
|
|
|
359
359
|
*
|
|
360
360
|
* @throws {Base44Error} 404 if the turn is not in the retained window.
|
|
361
361
|
*/
|
|
362
|
-
getTurn(turnId: string): Promise<
|
|
362
|
+
getTurn(turnId: string): Promise<BuilderTurn>;
|
|
363
363
|
/**
|
|
364
364
|
* Waits for a turn to stop, and resolves with the state it stopped in.
|
|
365
365
|
*
|
|
@@ -374,18 +374,18 @@ export interface BuildSessionReader {
|
|
|
374
374
|
* Resolves on `idle`, `error` *and* `blocked` — a build that ran out of credits
|
|
375
375
|
* has stopped, and waiting for it to finish would wait forever.
|
|
376
376
|
*
|
|
377
|
-
* @param turnId - The turn to wait for, from {@link
|
|
377
|
+
* @param turnId - The turn to wait for, from {@link BuilderTurnRef.turnId}.
|
|
378
378
|
* @param options - An abort signal.
|
|
379
379
|
* @returns The state the turn came to rest in.
|
|
380
380
|
*
|
|
381
381
|
* @example
|
|
382
382
|
* ```typescript
|
|
383
|
-
* const { turnId } = await
|
|
384
|
-
* const outcome = await
|
|
383
|
+
* const { turnId } = await builder.sendMessage('add a footer');
|
|
384
|
+
* const outcome = await builder.waitForTurn(turnId);
|
|
385
385
|
* if (outcome.status === 'waiting') await answer(outcome.waitingOn);
|
|
386
386
|
* ```
|
|
387
387
|
*/
|
|
388
|
-
waitForTurn(turnId: string, options?: WaitForTurnOptions): Promise<
|
|
388
|
+
waitForTurn(turnId: string, options?: WaitForTurnOptions): Promise<BuilderState>;
|
|
389
389
|
/**
|
|
390
390
|
* Streams the build, calling back on every event.
|
|
391
391
|
*
|
|
@@ -405,7 +405,7 @@ export interface BuildSessionReader {
|
|
|
405
405
|
*
|
|
406
406
|
* @example
|
|
407
407
|
* ```typescript
|
|
408
|
-
* const unsubscribe =
|
|
408
|
+
* const unsubscribe = builder.subscribe((event) => {
|
|
409
409
|
* switch (event.type) {
|
|
410
410
|
* case 'message.updated': upsert(event.data); break; // by messageId
|
|
411
411
|
* case 'state.changed': setStatus(event.data); break;
|
|
@@ -418,7 +418,7 @@ export interface BuildSessionReader {
|
|
|
418
418
|
* unsubscribe();
|
|
419
419
|
* ```
|
|
420
420
|
*/
|
|
421
|
-
subscribe(onEvent: (event:
|
|
421
|
+
subscribe(onEvent: (event: BuilderEvent) => void, options?: SubscribeToBuilderOptions): () => void;
|
|
422
422
|
/**
|
|
423
423
|
* The same stream, as an async iterable.
|
|
424
424
|
*
|
|
@@ -435,12 +435,12 @@ export interface BuildSessionReader {
|
|
|
435
435
|
*
|
|
436
436
|
* @example
|
|
437
437
|
* ```typescript
|
|
438
|
-
* for await (const event of
|
|
438
|
+
* for await (const event of builder.stream()) {
|
|
439
439
|
* if (event.type === 'turn.finished') break;
|
|
440
440
|
* }
|
|
441
441
|
* ```
|
|
442
442
|
*/
|
|
443
|
-
stream(options?:
|
|
443
|
+
stream(options?: SubscribeToBuilderOptions): AsyncIterable<BuilderEvent>;
|
|
444
444
|
/**
|
|
445
445
|
* The assistant's prose, as text to append.
|
|
446
446
|
*
|
|
@@ -454,8 +454,8 @@ export interface BuildSessionReader {
|
|
|
454
454
|
* made immutable.
|
|
455
455
|
*
|
|
456
456
|
* Ends when the turn does. Tool calls and waitpoints are not text and are not
|
|
457
|
-
* yielded: read them from {@link
|
|
458
|
-
* {@link
|
|
457
|
+
* yielded: read them from {@link BuilderSessionReader.subscribe | subscribe()} or
|
|
458
|
+
* {@link BuilderSessionReader.getState | getState()} and render them as whatever
|
|
459
459
|
* your surface calls a card.
|
|
460
460
|
*
|
|
461
461
|
* @param options - Resume point and abort signal.
|
|
@@ -463,26 +463,26 @@ export interface BuildSessionReader {
|
|
|
463
463
|
*
|
|
464
464
|
* @example
|
|
465
465
|
* ```typescript
|
|
466
|
-
* for await (const chunk of
|
|
466
|
+
* for await (const chunk of builder.streamText()) {
|
|
467
467
|
* process.stdout.write(chunk);
|
|
468
468
|
* }
|
|
469
469
|
* ```
|
|
470
470
|
*/
|
|
471
|
-
streamText(options?:
|
|
471
|
+
streamText(options?: SubscribeToBuilderOptions): AsyncIterable<string>;
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
|
-
* A
|
|
474
|
+
* A builder session, with the writes.
|
|
475
475
|
*
|
|
476
476
|
* What a principal's own credential can do, and therefore what belongs on your
|
|
477
|
-
* server. Obtained from {@link PrincipalClient.
|
|
477
|
+
* server. Obtained from {@link PrincipalClient.builder | asPrincipal(id).builder(appId)}.
|
|
478
478
|
*
|
|
479
479
|
* Every write returns as soon as the turn is *accepted*, not when it is done: a
|
|
480
480
|
* build takes minutes and no caller should hold a request open through one. The
|
|
481
481
|
* turn's progress arrives on the stream, and
|
|
482
|
-
* {@link
|
|
482
|
+
* {@link BuilderSessionReader.waitForTurn | waitForTurn()} is how a long-lived
|
|
483
483
|
* worker awaits the end of it.
|
|
484
484
|
*/
|
|
485
|
-
export interface
|
|
485
|
+
export interface BuilderSession extends BuilderSessionReader {
|
|
486
486
|
/**
|
|
487
487
|
* Starts a build turn.
|
|
488
488
|
*
|
|
@@ -495,12 +495,12 @@ export interface BuildSession extends BuildSessionReader {
|
|
|
495
495
|
*
|
|
496
496
|
* @example
|
|
497
497
|
* ```typescript
|
|
498
|
-
* const { turnId } = await
|
|
498
|
+
* const { turnId } = await builder.sendMessage('add a footer', {
|
|
499
499
|
* idempotencyKey: requestId,
|
|
500
500
|
* });
|
|
501
501
|
* ```
|
|
502
502
|
*/
|
|
503
|
-
sendMessage(content: string, options?:
|
|
503
|
+
sendMessage(content: string, options?: SendBuilderMessageOptions): Promise<BuilderTurnRef>;
|
|
504
504
|
/**
|
|
505
505
|
* Answers the waitpoint holding the turn open, and resumes it.
|
|
506
506
|
*
|
|
@@ -513,13 +513,13 @@ export interface BuildSession extends BuildSessionReader {
|
|
|
513
513
|
*
|
|
514
514
|
* @example
|
|
515
515
|
* ```typescript
|
|
516
|
-
* const { waitingOn } = await
|
|
516
|
+
* const { waitingOn } = await builder.getState();
|
|
517
517
|
* if (waitingOn?.kind === 'approval') {
|
|
518
|
-
* await
|
|
518
|
+
* await builder.respond({ ...waitingOn, approved: true });
|
|
519
519
|
* }
|
|
520
520
|
* ```
|
|
521
521
|
*/
|
|
522
|
-
respond(response:
|
|
522
|
+
respond(response: BuilderResponse, options?: RespondToBuilderOptions): Promise<BuilderTurnRef>;
|
|
523
523
|
/**
|
|
524
524
|
* Stops the running turn.
|
|
525
525
|
*
|
|
@@ -529,7 +529,7 @@ export interface BuildSession extends BuildSessionReader {
|
|
|
529
529
|
* Returns nothing rather than the state. The endpoint answers with the
|
|
530
530
|
* builder's own internal status vocabulary, which the rest of this surface
|
|
531
531
|
* deliberately renames, and the settled state arrives on the stream — or from
|
|
532
|
-
* {@link
|
|
532
|
+
* {@link BuilderSessionReader.getState | getState()} — in the public one.
|
|
533
533
|
*/
|
|
534
534
|
cancel(): Promise<void>;
|
|
535
535
|
/**
|
|
@@ -547,12 +547,12 @@ export interface BuildSession extends BuildSessionReader {
|
|
|
547
547
|
* ```typescript
|
|
548
548
|
* // POST /api/base44/grant, on your server
|
|
549
549
|
* const userId = await requireSession(req);
|
|
550
|
-
* const grant = await base44.asPrincipal(userId).
|
|
550
|
+
* const grant = await base44.asPrincipal(userId).builder(appId)
|
|
551
551
|
* .createGrant({ ttlSeconds: 900 });
|
|
552
552
|
* return Response.json(grant);
|
|
553
553
|
* ```
|
|
554
554
|
*/
|
|
555
|
-
createGrant(options?:
|
|
555
|
+
createGrant(options?: CreateBuilderGrantOptions): Promise<BuilderGrant>;
|
|
556
556
|
/**
|
|
557
557
|
* Withdraws a grant before it expires.
|
|
558
558
|
*
|
|
@@ -27,7 +27,7 @@ export type { CreatePlatformClientConfig, PlatformClient, PrincipalClient };
|
|
|
27
27
|
*
|
|
28
28
|
* Nor a principal's own token: it can start builds and spend credits. The one
|
|
29
29
|
* credential meant for a browser is a *grant* —
|
|
30
|
-
* {@linkcode
|
|
30
|
+
* {@linkcode BuilderSession.createGrant | createGrant()} — which reads one builder
|
|
31
31
|
* session, expires in minutes, and cannot write.
|
|
32
32
|
*
|
|
33
33
|
* @param config - Configuration object for the platform client.
|
|
@@ -51,9 +51,9 @@ export type { CreatePlatformClientConfig, PlatformClient, PrincipalClient };
|
|
|
51
51
|
* const asDana = base44.asPrincipal('user_42');
|
|
52
52
|
*
|
|
53
53
|
* // Drive the builder as them, and watch it happen.
|
|
54
|
-
* const
|
|
55
|
-
* const { turnId } = await
|
|
56
|
-
* const outcome = await
|
|
54
|
+
* const builder = asDana.builder(appId);
|
|
55
|
+
* const { turnId } = await builder.sendMessage('add a footer');
|
|
56
|
+
* const outcome = await builder.waitForTurn(turnId);
|
|
57
57
|
*
|
|
58
58
|
* // Or use the rest of the SDK as them.
|
|
59
59
|
* const app = await asDana.forApp(appId);
|
package/dist/platform-client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAxiosClient } from "./utils/axios-client.js";
|
|
2
2
|
import { createPlatformsModule } from "./modules/platforms.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createBuilderSessionModule } from "./modules/builder.js";
|
|
4
4
|
import { createPrincipalTokenStore } from "./utils/principal-tokens.js";
|
|
5
5
|
import { createClient } from "./client.js";
|
|
6
6
|
/**
|
|
@@ -30,7 +30,7 @@ import { createClient } from "./client.js";
|
|
|
30
30
|
*
|
|
31
31
|
* Nor a principal's own token: it can start builds and spend credits. The one
|
|
32
32
|
* credential meant for a browser is a *grant* —
|
|
33
|
-
* {@linkcode
|
|
33
|
+
* {@linkcode BuilderSession.createGrant | createGrant()} — which reads one builder
|
|
34
34
|
* session, expires in minutes, and cannot write.
|
|
35
35
|
*
|
|
36
36
|
* @param config - Configuration object for the platform client.
|
|
@@ -54,9 +54,9 @@ import { createClient } from "./client.js";
|
|
|
54
54
|
* const asDana = base44.asPrincipal('user_42');
|
|
55
55
|
*
|
|
56
56
|
* // Drive the builder as them, and watch it happen.
|
|
57
|
-
* const
|
|
58
|
-
* const { turnId } = await
|
|
59
|
-
* const outcome = await
|
|
57
|
+
* const builder = asDana.builder(appId);
|
|
58
|
+
* const { turnId } = await builder.sendMessage('add a footer');
|
|
59
|
+
* const outcome = await builder.waitForTurn(turnId);
|
|
60
60
|
*
|
|
61
61
|
* // Or use the rest of the SDK as them.
|
|
62
62
|
* const app = await asDana.forApp(appId);
|
|
@@ -84,9 +84,9 @@ export function createPlatformClient(config) {
|
|
|
84
84
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
85
85
|
});
|
|
86
86
|
// A fourth, and for the same reason as the third: it carries no static
|
|
87
|
-
// credential. Every
|
|
87
|
+
// credential. Every builder call is made as a *principal*, whose token rotates,
|
|
88
88
|
// so the token goes on the request rather than into the client.
|
|
89
|
-
const
|
|
89
|
+
const builderAxios = createAxiosClient({
|
|
90
90
|
baseURL: `${serverUrl}/api`,
|
|
91
91
|
onError: options === null || options === void 0 ? void 0 : options.onError,
|
|
92
92
|
});
|
|
@@ -106,12 +106,12 @@ export function createPlatformClient(config) {
|
|
|
106
106
|
return {
|
|
107
107
|
externalId,
|
|
108
108
|
getToken,
|
|
109
|
-
// Not cached, unlike `forApp`. A
|
|
109
|
+
// Not cached, unlike `forApp`. A builder session is a handful of closures
|
|
110
110
|
// over the token store rather than a client with sockets and an analytics
|
|
111
111
|
// session, so there is nothing to reuse and nothing to leak.
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
axios:
|
|
112
|
+
builder(appId) {
|
|
113
|
+
return createBuilderSessionModule({
|
|
114
|
+
axios: builderAxios,
|
|
115
115
|
appId,
|
|
116
116
|
serverUrl,
|
|
117
117
|
getToken,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Base44Client, CreateClientOptions } from "./client.types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuilderSession } from "./modules/builder.types.js";
|
|
3
3
|
import type { PlatformsModule } from "./modules/platforms.types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Configuration for creating a Base44 platform client.
|
|
@@ -48,7 +48,7 @@ export interface PrincipalClient {
|
|
|
48
48
|
/** The identifier this principal was provisioned under. */
|
|
49
49
|
readonly externalId: string;
|
|
50
50
|
/**
|
|
51
|
-
* The
|
|
51
|
+
* The builder session for one app, driven as this principal.
|
|
52
52
|
*
|
|
53
53
|
* This is the partner-facing builder: send a message, answer what the agent
|
|
54
54
|
* asks, stop a turn, and watch the whole thing happen over one resumable
|
|
@@ -69,16 +69,16 @@ export interface PrincipalClient {
|
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* ```typescript
|
|
72
|
-
* const
|
|
72
|
+
* const builder = base44.asPrincipal('user_42').builder(appId);
|
|
73
73
|
*
|
|
74
|
-
* const { turnId } = await
|
|
75
|
-
* const outcome = await
|
|
74
|
+
* const { turnId } = await builder.sendMessage('add a footer');
|
|
75
|
+
* const outcome = await builder.waitForTurn(turnId);
|
|
76
76
|
*
|
|
77
77
|
* // The browser gets a read-only grant, and nothing else.
|
|
78
|
-
* const grant = await
|
|
78
|
+
* const grant = await builder.createGrant({ ttlSeconds: 900 });
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
builder(appId: string): BuilderSession;
|
|
82
82
|
/**
|
|
83
83
|
* A Base44 client for one app, acting as this principal.
|
|
84
84
|
*
|
|
@@ -108,12 +108,12 @@ export interface PrincipalClient {
|
|
|
108
108
|
* The raw access token for this principal, minting or renewing as needed.
|
|
109
109
|
*
|
|
110
110
|
* Most code should use {@link PrincipalClient.forApp | forApp()} or
|
|
111
|
-
* {@link PrincipalClient.
|
|
111
|
+
* {@link PrincipalClient.builder | builder()} instead. Reach for this when you need
|
|
112
112
|
* to authenticate a request the SDK does not make for you.
|
|
113
113
|
*
|
|
114
114
|
* **Not the thing to send to a browser.** This token can start builds and spend
|
|
115
115
|
* your credits. What a browser gets is a grant from
|
|
116
|
-
* {@link
|
|
116
|
+
* {@link BuilderSession.createGrant | createGrant()}, which reads one session and
|
|
117
117
|
* writes nothing.
|
|
118
118
|
*
|
|
119
119
|
* Do not cache what this returns — it is already cached, and holding a copy is
|
package/package.json
CHANGED
|
File without changes
|