@base44-preview/sdk 0.8.59-pr.372.0aefdf1 → 0.8.59-pr.373.e530673
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.js +0 -2
- package/dist/client.types.d.ts +0 -3
- package/dist/index.d.ts +0 -1
- package/dist/modules/payments.types.d.ts +5 -7
- package/package.json +1 -1
- package/dist/modules/voice.d.ts +0 -23
- package/dist/modules/voice.js +0 -56
- package/dist/modules/voice.types.d.ts +0 -191
- package/dist/modules/voice.types.js +0 -4
package/dist/client.js
CHANGED
|
@@ -4,7 +4,6 @@ import { createIntegrationsModule } from "./modules/integrations.js";
|
|
|
4
4
|
import { createAuthModule } from "./modules/auth.js";
|
|
5
5
|
import { createSsoModule } from "./modules/sso.js";
|
|
6
6
|
import { createBrowserModule } from "./modules/browser.js";
|
|
7
|
-
import { createVoiceModule } from "./modules/voice.js";
|
|
8
7
|
import { createConnectorsModule, createUserConnectorsModule, } from "./modules/connectors.js";
|
|
9
8
|
import { getAccessToken } from "./utils/auth-utils.js";
|
|
10
9
|
import { createFetchWithAuth } from "./utils/fetch-with-auth.js";
|
|
@@ -231,7 +230,6 @@ export function createClient(config) {
|
|
|
231
230
|
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
|
|
232
231
|
sso: createSsoModule(serviceRoleAxiosClient, appId),
|
|
233
232
|
browser: createBrowserModule(serviceRoleAxiosClient),
|
|
234
|
-
voice: createVoiceModule(serviceRoleAxiosClient, { functionsVersion }),
|
|
235
233
|
connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
|
|
236
234
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId, {
|
|
237
235
|
getAuthHeaders: () => {
|
package/dist/client.types.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { IntegrationsModule } from "./modules/integrations.types.js";
|
|
|
3
3
|
import type { AuthModule } from "./modules/auth.types.js";
|
|
4
4
|
import type { SsoModule } from "./modules/sso.types.js";
|
|
5
5
|
import type { BrowserModule } from "./modules/browser.types.js";
|
|
6
|
-
import type { VoiceModule } from "./modules/voice.types.js";
|
|
7
6
|
import type { PaymentsModule, ServiceRolePaymentsModule } from "./modules/payments.types.js";
|
|
8
7
|
import type { ConnectorsModule, UserConnectorsModule } from "./modules/connectors.types.js";
|
|
9
8
|
import type { FunctionsModule } from "./modules/functions.types.js";
|
|
@@ -246,8 +245,6 @@ export interface Base44Client {
|
|
|
246
245
|
payments: ServiceRolePaymentsModule;
|
|
247
246
|
/** {@link SsoModule | SSO module} for generating SSO tokens. */
|
|
248
247
|
sso: SsoModule;
|
|
249
|
-
/** {@link VoiceModule | Voice module} for live voice sessions. */
|
|
250
|
-
voice: VoiceModule;
|
|
251
248
|
/** Cleanup function to disconnect WebSocket connections. */
|
|
252
249
|
cleanup: () => void;
|
|
253
250
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription
|
|
|
16
16
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
17
17
|
export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutShipping, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalCheckoutOnClick, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, ShippingAddress, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
|
|
18
18
|
export type { BrowserModule, BrowserSession, BrowserSessionOptions, } from "./modules/browser.types.js";
|
|
19
|
-
export type { VoiceModule, VoiceSession, VoiceSessionMessage, VoiceSessionOptions, } from "./modules/voice.types.js";
|
|
20
19
|
export { Actor, type Conn } from "./actor.js";
|
|
21
20
|
export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
|
|
22
21
|
export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
|
|
@@ -361,7 +361,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
361
361
|
/** Whether the checkout is a one-time payment or a subscription. */
|
|
362
362
|
intent: "capture" | "subscription";
|
|
363
363
|
/**
|
|
364
|
-
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls
|
|
364
|
+
* Creates the checkout when the buyer clicks, usually by calling the backend function that calls [`createCheckout()`](#createcheckout). Resolve with its result. It must be an embedded PayPal checkout with the same `currency` and `intent` you set here, or `onError` receives an error. Reject to stop, for example when a required form field is empty. PayPal's window then closes and `onError` receives the error.
|
|
365
365
|
*/
|
|
366
366
|
createCheckout: () => Promise<MountableCheckout>;
|
|
367
367
|
}
|
|
@@ -371,7 +371,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
371
371
|
export interface CheckoutMount {
|
|
372
372
|
/** Removes the checkout from the page. Call it when the component that holds it unmounts. For Stripe, mounting another checkout destroys this one for you. */
|
|
373
373
|
destroy: () => void;
|
|
374
|
-
/**
|
|
374
|
+
/** Grays out PayPal's button and ignores clicks, for example until a required form is filled in. After a payment completes the button stays off, so `setDisabled(false)` can't start a second payment. Stripe ignores it. */
|
|
375
375
|
setDisabled: (disabled: boolean) => void;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
@@ -425,7 +425,7 @@ export interface PaymentsModule {
|
|
|
425
425
|
/**
|
|
426
426
|
* Renders an embedded checkout inside an element on the page.
|
|
427
427
|
*
|
|
428
|
-
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page.
|
|
428
|
+
* Pass the result of a {@linkcode ServiceRolePaymentsModule.createCheckout | createCheckout()} call made with `presentation: 'embedded'`. Because only the service role can create checkouts, create it in a backend function and return the result to the page. For PayPal, you can instead pass a {@linkcode PayPalCheckoutOnClick} to show the button before any checkout exists. The SDK creates the checkout only when the buyer clicks the button, so visitors who don't buy don't leave unused checkouts behind.
|
|
429
429
|
*
|
|
430
430
|
* The SDK loads the provider's library and renders the checkout for you:
|
|
431
431
|
* - PayPal: Renders a PayPal button. When the buyer approves the payment, the SDK calls {@linkcode completeCheckout | completeCheckout()} and then `onComplete`.
|
|
@@ -433,8 +433,6 @@ export interface PaymentsModule {
|
|
|
433
433
|
*
|
|
434
434
|
* To make the checkout appear faster, load the library ahead of time with [`preloadCheckout()`](#preloadcheckout) when the page opens.
|
|
435
435
|
*
|
|
436
|
-
* For PayPal, pass a {@linkcode PayPalCheckoutOnClick} instead of a created checkout to show PayPal's button right away and create the checkout only when the buyer clicks it. The buyer clicks once, and page views create no orders.
|
|
437
|
-
*
|
|
438
436
|
* Requires a browser environment and can't be used in the backend. Rejects when the checkout isn't embedded, when an on-click PayPal checkout is mounted before the app's PayPal can take payments, when the payments config can't be fetched or has no valid script URL for the provider, when the provider's library fails to load, or when PayPal isn't available for the checkout's currency.
|
|
439
437
|
*
|
|
440
438
|
* The checkout's callbacks run in the buyer's browser, where they can be faked. Grant access to what the buyer paid for only after your backend confirms the purchase, for example with [`listPurchases()`](#service-role-methods) in a backend function.
|
|
@@ -465,7 +463,7 @@ export interface PaymentsModule {
|
|
|
465
463
|
*
|
|
466
464
|
* @example
|
|
467
465
|
* ```typescript
|
|
468
|
-
* //
|
|
466
|
+
* // Create a PayPal checkout on click
|
|
469
467
|
* const mount = await base44.payments.mountCheckout(
|
|
470
468
|
* document.getElementById('paypal')!,
|
|
471
469
|
* {
|
|
@@ -478,7 +476,7 @@ export interface PaymentsModule {
|
|
|
478
476
|
* { onComplete: ({ checkout_id }) => confirmPurchase(checkout_id) }
|
|
479
477
|
* );
|
|
480
478
|
*
|
|
481
|
-
* //
|
|
479
|
+
* // Gray out the button until the shipping form is valid
|
|
482
480
|
* mount.setDisabled(!formIsValid);
|
|
483
481
|
* ```
|
|
484
482
|
*
|
package/package.json
CHANGED
package/dist/modules/voice.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
|
-
import { VoiceModule } from "./voice.types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Options for {@linkcode createVoiceModule}.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export interface VoiceModuleConfig {
|
|
9
|
-
/** Sent as `Base44-Functions-Version` so the backend can pick the draft MCP profile. */
|
|
10
|
-
functionsVersion?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Creates the Voice module for the Base44 SDK.
|
|
14
|
-
*
|
|
15
|
-
* The module passes every value through unchanged. Base44 validates them, so
|
|
16
|
-
* a backend rule change never needs an SDK release.
|
|
17
|
-
*
|
|
18
|
-
* @param axios - Axios instance (should be service role client)
|
|
19
|
-
* @param config - Module configuration
|
|
20
|
-
* @returns Voice module with methods to start and end live voice sessions
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare function createVoiceModule(axios: AxiosInstance, { functionsVersion }?: VoiceModuleConfig): VoiceModule;
|
package/dist/modules/voice.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates the Voice module for the Base44 SDK.
|
|
3
|
-
*
|
|
4
|
-
* The module passes every value through unchanged. Base44 validates them, so
|
|
5
|
-
* a backend rule change never needs an SDK release.
|
|
6
|
-
*
|
|
7
|
-
* @param axios - Axios instance (should be service role client)
|
|
8
|
-
* @param config - Module configuration
|
|
9
|
-
* @returns Voice module with methods to start and end live voice sessions
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export function createVoiceModule(axios, { functionsVersion } = {}) {
|
|
13
|
-
const endSession = async (sessionId) => {
|
|
14
|
-
if (!sessionId || typeof sessionId !== "string") {
|
|
15
|
-
throw new Error("Session ID is required and must be a string");
|
|
16
|
-
}
|
|
17
|
-
await axios.delete(`/v1/voice-sessions/${encodeURIComponent(sessionId)}`);
|
|
18
|
-
};
|
|
19
|
-
return {
|
|
20
|
-
async startSession(options) {
|
|
21
|
-
// The app is derived from the service token, so the route isn't app-scoped.
|
|
22
|
-
const response = await axios.post("/v1/voice-sessions", {
|
|
23
|
-
sdp: options.sdp,
|
|
24
|
-
mcp_profile_id: options.mcpProfileId,
|
|
25
|
-
voice_instructions: options.voiceInstructions,
|
|
26
|
-
agent_instructions: options.agentInstructions,
|
|
27
|
-
// Send optional keys only when set, so the backend applies its defaults.
|
|
28
|
-
...(options.voiceModel !== undefined && {
|
|
29
|
-
voice_model: options.voiceModel,
|
|
30
|
-
}),
|
|
31
|
-
...(options.agentModel !== undefined && {
|
|
32
|
-
agent_model: options.agentModel,
|
|
33
|
-
}),
|
|
34
|
-
...(options.voice !== undefined && { voice: options.voice }),
|
|
35
|
-
...(options.initialMessages !== undefined && {
|
|
36
|
-
initial_messages: options.initialMessages,
|
|
37
|
-
}),
|
|
38
|
-
}, {
|
|
39
|
-
// The backend picks the draft or published MCP profile from this
|
|
40
|
-
// header. The service-role client doesn't send it by default.
|
|
41
|
-
headers: functionsVersion
|
|
42
|
-
? { "Base44-Functions-Version": functionsVersion }
|
|
43
|
-
: undefined,
|
|
44
|
-
});
|
|
45
|
-
const data = response;
|
|
46
|
-
return {
|
|
47
|
-
sessionId: data.session_id,
|
|
48
|
-
sdp: data.sdp,
|
|
49
|
-
expiresAt: data.expires_at,
|
|
50
|
-
environment: data.environment,
|
|
51
|
-
end: () => endSession(data.session_id),
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
endSession,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A text message placed in the conversation before the call starts.
|
|
3
|
-
*/
|
|
4
|
-
export interface VoiceSessionMessage {
|
|
5
|
-
/**
|
|
6
|
-
* Who wrote the message, such as:
|
|
7
|
-
*
|
|
8
|
-
* - `'developer'`: Context for the voice agent, such as what the current user is looking at.
|
|
9
|
-
* - `'user'`: An earlier turn by the current user.
|
|
10
|
-
* - `'assistant'`: An earlier turn by the voice agent.
|
|
11
|
-
*/
|
|
12
|
-
role: string;
|
|
13
|
-
/** The message text. */
|
|
14
|
-
text: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Options for {@linkcode VoiceModule.startSession | startSession()}.
|
|
18
|
-
*/
|
|
19
|
-
export interface VoiceSessionOptions {
|
|
20
|
-
/**
|
|
21
|
-
* The browser's WebRTC SDP offer.
|
|
22
|
-
*
|
|
23
|
-
* Create it in the browser with [`RTCPeerConnection.createOffer()`](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer) and send it to your backend function. A new offer is needed for every session.
|
|
24
|
-
*/
|
|
25
|
-
sdp: string;
|
|
26
|
-
/**
|
|
27
|
-
* ID of the app's MCP profile whose tools the voice agent can use.
|
|
28
|
-
*
|
|
29
|
-
* The AI inserts this ID into your backend function when it sets up voice for the app.
|
|
30
|
-
*/
|
|
31
|
-
mcpProfileId: string;
|
|
32
|
-
/**
|
|
33
|
-
* Model that talks with the current user, as an AI Gateway model ID. Defaults to Base44's default voice model.
|
|
34
|
-
*/
|
|
35
|
-
voiceModel?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Model behind the voice that calls the app's tools, as an AI Gateway model ID, such as `'gpt_6_luna'`. Defaults to Base44's default agent model.
|
|
38
|
-
*/
|
|
39
|
-
agentModel?: string;
|
|
40
|
-
/**
|
|
41
|
-
* How the voice model speaks with the current user, such as its persona, tone, and turn-taking.
|
|
42
|
-
*/
|
|
43
|
-
voiceInstructions: string;
|
|
44
|
-
/**
|
|
45
|
-
* How the agent behind the voice uses the app's tools to answer and act.
|
|
46
|
-
*/
|
|
47
|
-
agentInstructions: string;
|
|
48
|
-
/**
|
|
49
|
-
* Built-in voice to speak with, such as `'cedar'`. The voice is fixed for the whole session. Defaults to the provider's default voice.
|
|
50
|
-
*/
|
|
51
|
-
voice?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Text conversation placed before the call starts, oldest first.
|
|
54
|
-
*
|
|
55
|
-
* Use it to give the voice agent context, or to continue a conversation the current user started in text.
|
|
56
|
-
*/
|
|
57
|
-
initialMessages?: VoiceSessionMessage[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A live voice session returned by {@linkcode VoiceModule.startSession | startSession()}.
|
|
61
|
-
*/
|
|
62
|
-
export interface VoiceSession {
|
|
63
|
-
/**
|
|
64
|
-
* Opaque session identifier issued to your app.
|
|
65
|
-
*
|
|
66
|
-
* Pass it unchanged to [`endSession()`](#endsession) to end the session from a different request.
|
|
67
|
-
*/
|
|
68
|
-
sessionId: string;
|
|
69
|
-
/**
|
|
70
|
-
* The SDP answer.
|
|
71
|
-
*
|
|
72
|
-
* Return it to the browser and apply it with [`RTCPeerConnection.setRemoteDescription()`](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setRemoteDescription). Audio then flows directly between the browser and the voice model.
|
|
73
|
-
*/
|
|
74
|
-
sdp: string;
|
|
75
|
-
/** ISO 8601 timestamp when the session ends at the latest. */
|
|
76
|
-
expiresAt: string;
|
|
77
|
-
/**
|
|
78
|
-
* Where the voice agent's tools come from.
|
|
79
|
-
*
|
|
80
|
-
* - `'live'`: The published MCP profile.
|
|
81
|
-
* - `'draft'`: The current draft of the MCP profile. Served when the app's owner or an editor starts the session from the app editor preview, so voice works before the app is published.
|
|
82
|
-
*/
|
|
83
|
-
environment: "live" | "draft";
|
|
84
|
-
/**
|
|
85
|
-
* Ends the session. Equivalent to calling [`endSession()`](#endsession) with this session's ID.
|
|
86
|
-
*/
|
|
87
|
-
end: () => Promise<void>;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Voice module for live voice conversations between your app's users and an AI agent.
|
|
91
|
-
*
|
|
92
|
-
* This module starts and ends live voice sessions. The voice agent can use your app's tools through one of the app's MCP profiles, acting as the current user. Audio flows directly between the browser and the voice model over [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API), so your backend only handles the start and the end of a session.
|
|
93
|
-
*
|
|
94
|
-
* A session takes three steps:
|
|
95
|
-
* - The browser creates a WebRTC SDP offer and sends it to one of your backend functions.
|
|
96
|
-
* - The backend function calls {@linkcode startSession | startSession()} with the offer and your voice settings, and returns the SDP answer to the browser.
|
|
97
|
-
* - The browser applies the answer, and the conversation starts.
|
|
98
|
-
*
|
|
99
|
-
* Keep the instructions, models, and MCP profile ID in the backend function. Only the SDP offer should come from the browser.
|
|
100
|
-
*
|
|
101
|
-
* This module is in beta and may change.
|
|
102
|
-
*
|
|
103
|
-
* ## Authentication modes
|
|
104
|
-
*
|
|
105
|
-
* This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.voice`), which means it can only be used in backend environments. The app's tools run as the current user of the request that created the client. Without a current user, they run as a guest, which only works in apps that allow anonymous access.
|
|
106
|
-
*/
|
|
107
|
-
export interface VoiceModule {
|
|
108
|
-
/**
|
|
109
|
-
* Starts a live voice session and returns the SDP answer for the browser.
|
|
110
|
-
*
|
|
111
|
-
* Each call starts a new session, which uses credits from the workspace that owns the app. The session ends on its own when it's idle or reaches its maximum duration. When the current user hangs up, call `end()` on the session. To end it from a different request, use {@linkcode endSession | endSession()}.
|
|
112
|
-
*
|
|
113
|
-
* @param options - The browser's SDP offer and the voice settings.
|
|
114
|
-
* @returns Promise resolving to the new voice session. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws).
|
|
115
|
-
* @throws `insufficient_credits`: The workspace is out of credits.
|
|
116
|
-
* @throws `authentication_required`: The app requires a current user, and the request had none.
|
|
117
|
-
* @throws `unsupported_voice_model`: The voice model isn't supported.
|
|
118
|
-
* @throws `unsupported_agent_model`: The agent model isn't supported.
|
|
119
|
-
* @throws `voice_settings_rejected`: The voice provider rejected the settings, for example because the instructions are too long.
|
|
120
|
-
* @throws `invalid_request`: A value in the options is invalid.
|
|
121
|
-
* @throws `rate_limited`: You started too many sessions in a short time.
|
|
122
|
-
* @throws `voice_capacity_exceeded`: Voice capacity is temporarily unavailable.
|
|
123
|
-
* @throws `voice_connection_failed`: The voice provider couldn't be reached or rejected the request.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* // Backend function that starts a voice session for the current user
|
|
128
|
-
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
129
|
-
*
|
|
130
|
-
* const VOICE_PROFILE_ID = '6a1f0c2b9d8e7f6a5b4c3d2e';
|
|
131
|
-
*
|
|
132
|
-
* Deno.serve(async (req) => {
|
|
133
|
-
* const base44 = createClientFromRequest(req);
|
|
134
|
-
* // Only the SDP offer comes from the browser.
|
|
135
|
-
* const { sdp } = await req.json();
|
|
136
|
-
*
|
|
137
|
-
* const session = await base44.asServiceRole.voice.startSession({
|
|
138
|
-
* sdp,
|
|
139
|
-
* mcpProfileId: VOICE_PROFILE_ID,
|
|
140
|
-
* voiceInstructions: 'You are the shop assistant. Speak briefly and let the person interrupt.',
|
|
141
|
-
* agentInstructions: 'Use the app tools to look up orders. Report only what the tools return.',
|
|
142
|
-
* });
|
|
143
|
-
*
|
|
144
|
-
* return Response.json({ sessionId: session.sessionId, sdp: session.sdp });
|
|
145
|
-
* });
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```typescript
|
|
150
|
-
* // Pick the models and voice, and give the agent context about the current page
|
|
151
|
-
* const session = await base44.asServiceRole.voice.startSession({
|
|
152
|
-
* sdp,
|
|
153
|
-
* mcpProfileId: VOICE_PROFILE_ID,
|
|
154
|
-
* voiceModel: 'gpt_live_1',
|
|
155
|
-
* agentModel: 'gpt_6_luna',
|
|
156
|
-
* voiceInstructions: 'You are the shop assistant.',
|
|
157
|
-
* agentInstructions: 'Use the app tools to look up orders.',
|
|
158
|
-
* voice: 'cedar',
|
|
159
|
-
* initialMessages: [
|
|
160
|
-
* { role: 'developer', text: 'The person is viewing order 1042 on the checkout page.' },
|
|
161
|
-
* ],
|
|
162
|
-
* });
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
startSession(options: VoiceSessionOptions): Promise<VoiceSession>;
|
|
166
|
-
/**
|
|
167
|
-
* Ends a voice session started by your app.
|
|
168
|
-
*
|
|
169
|
-
* Use this when the session was started in a different request, such as when the browser reports that the current user hung up. Otherwise call `end()` on the session returned by {@linkcode startSession | startSession()}. Ending a session that has already ended succeeds, so it's safe to call more than once.
|
|
170
|
-
*
|
|
171
|
-
* @param sessionId - The `sessionId` returned by {@linkcode startSession | startSession()}.
|
|
172
|
-
* @returns Promise that resolves when Base44 accepts the request. The session closes in the background. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws-2).
|
|
173
|
-
* @throws `voice_session_not_found`: The session ID wasn't issued to your app.
|
|
174
|
-
* @throws `voice_connection_failed`: Base44 couldn't reach its background processing. It closes the session directly where possible, and retrying is safe.
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
* ```typescript
|
|
178
|
-
* // End a session from a later request, using the ID sent in the request body
|
|
179
|
-
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
180
|
-
*
|
|
181
|
-
* Deno.serve(async (req) => {
|
|
182
|
-
* const base44 = createClientFromRequest(req);
|
|
183
|
-
* const { sessionId } = await req.json();
|
|
184
|
-
* await base44.asServiceRole.voice.endSession(sessionId);
|
|
185
|
-
*
|
|
186
|
-
* return new Response(null, { status: 204 });
|
|
187
|
-
* });
|
|
188
|
-
* ```
|
|
189
|
-
*/
|
|
190
|
-
endSession(sessionId: string): Promise<void>;
|
|
191
|
-
}
|