@buildbase/sdk 0.0.54 → 0.0.56

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.
Files changed (60) hide show
  1. package/AGENTS.md +8 -4
  2. package/CHANGELOG.md +55 -0
  3. package/LICENSE +21 -0
  4. package/README.md +294 -47
  5. package/dist/css/styles.css +1 -1
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +367 -88
  8. package/dist/index.mjs +1 -1
  9. package/dist/mcp/index.cjs +1 -1
  10. package/dist/mcp/index.d.ts +332 -16
  11. package/dist/mcp/index.mjs +1 -1
  12. package/dist/react/chunks/SettingsDialog-CvoDs5eM.cjs +2 -0
  13. package/dist/react/chunks/SettingsDialog-VaOW2jtS.mjs +2 -0
  14. package/dist/react/chunks/SubscriptionDialog-8CagFA_V.cjs +2 -0
  15. package/dist/react/chunks/SubscriptionDialog-C5EgpXE0.mjs +2 -0
  16. package/dist/react/chunks/ar-CGbuXEeR.cjs +2 -0
  17. package/dist/react/chunks/ar-DnShbYvQ.mjs +2 -0
  18. package/dist/react/chunks/de-C3iuiLAz.mjs +2 -0
  19. package/dist/react/chunks/de-a1mX2rR4.cjs +2 -0
  20. package/dist/react/chunks/es-D4T7YE7x.cjs +2 -0
  21. package/dist/react/chunks/es-u9vKMeaX.mjs +2 -0
  22. package/dist/react/chunks/fr-Bnnz2yJZ.cjs +2 -0
  23. package/dist/react/chunks/fr-DjgpP202.mjs +2 -0
  24. package/dist/react/chunks/hi-B8Mjr8rU.cjs +2 -0
  25. package/dist/react/chunks/hi-Cu_9iCjb.mjs +2 -0
  26. package/dist/react/chunks/ja-B0eCVKdZ.cjs +2 -0
  27. package/dist/react/chunks/ja-DfJ5WUrG.mjs +2 -0
  28. package/dist/react/chunks/react-BBY-Vuzr.cjs +2 -0
  29. package/dist/react/chunks/react-CvU8uS25.mjs +2 -0
  30. package/dist/react/chunks/zh-BnPZ0j4w.cjs +2 -0
  31. package/dist/react/chunks/zh-JjoMmHmK.mjs +2 -0
  32. package/dist/react/index.cjs +1 -1
  33. package/dist/react/index.d.ts +728 -142
  34. package/dist/react/index.mjs +1 -1
  35. package/docs/ARCHITECTURE.md +419 -0
  36. package/docs/ERROR_CODES.md +96 -0
  37. package/docs/MCP-AND-AGENT-READINESS.md +893 -0
  38. package/docs/THEMING.md +67 -0
  39. package/docs/UI-CONFIG.md +207 -0
  40. package/package.json +14 -3
  41. package/dist/react/chunks/SettingsDialog-B28WJsAr.cjs +0 -2
  42. package/dist/react/chunks/SettingsDialog-blhppbNm.mjs +0 -2
  43. package/dist/react/chunks/SubscriptionDialog-BTWVX3cH.mjs +0 -2
  44. package/dist/react/chunks/SubscriptionDialog-QKmwvJU1.cjs +0 -2
  45. package/dist/react/chunks/ar-1Z1MOGAP.mjs +0 -2
  46. package/dist/react/chunks/ar-VGzBv3AZ.cjs +0 -2
  47. package/dist/react/chunks/de-BjdDg60Y.cjs +0 -2
  48. package/dist/react/chunks/de-CXUItplO.mjs +0 -2
  49. package/dist/react/chunks/es-BBPsSZUp.cjs +0 -2
  50. package/dist/react/chunks/es-BTbzVutz.mjs +0 -2
  51. package/dist/react/chunks/fr-Cax48X_S.cjs +0 -2
  52. package/dist/react/chunks/fr-DPMeOQu3.mjs +0 -2
  53. package/dist/react/chunks/hi-BJqvpG6d.cjs +0 -2
  54. package/dist/react/chunks/hi-JfJx-LV7.mjs +0 -2
  55. package/dist/react/chunks/ja-CDGtLzTk.mjs +0 -2
  56. package/dist/react/chunks/ja-DvVyj5xX.cjs +0 -2
  57. package/dist/react/chunks/react-6QJCOE-D.cjs +0 -2
  58. package/dist/react/chunks/react-CC6T7Zky.mjs +0 -2
  59. package/dist/react/chunks/zh-BAcqxkxk.cjs +0 -2
  60. package/dist/react/chunks/zh-BNZ2Ooe8.mjs +0 -2
package/dist/index.d.ts CHANGED
@@ -1003,7 +1003,7 @@ interface ISettings {
1003
1003
  /** Auto-create workspace on first login */
1004
1004
  autoCreateFirst: boolean;
1005
1005
  };
1006
- [key: string]: any;
1006
+ [key: string]: unknown;
1007
1007
  }
1008
1008
 
1009
1009
  /**
@@ -1017,9 +1017,14 @@ interface IOsConfig {
1017
1017
  version: ApiVersion;
1018
1018
  orgId: string;
1019
1019
  }
1020
+ /** Lifecycle of the one-time org-settings fetch. */
1021
+ type SettingsStatus = 'idle' | 'loading' | 'loaded' | 'error';
1020
1022
  interface IOsState extends IOsConfig {
1021
1023
  auth?: IAuthConfig;
1022
1024
  settings?: ISettings | null;
1025
+ /** State of the settings fetch — lets UI wait instead of guessing with `?? true` defaults. */
1026
+ settingsStatus?: SettingsStatus;
1027
+ settingsError?: string | null;
1023
1028
  }
1024
1029
 
1025
1030
  /**
@@ -1082,6 +1087,7 @@ interface IBaseApiConfig {
1082
1087
  * - getAuthHeaders()
1083
1088
  * - fetchJson<T>(path, init, errorMessage): GET/POST/etc. with handleApiResponse
1084
1089
  * - fetchResponse(path, init): raw Response for custom parsing (e.g. non-JSON or custom error handling)
1090
+ * - fetchUnwrapped<T>(path, init, errorMessage): fetch → throw on !ok → unwrap { success, data } envelope
1085
1091
  */
1086
1092
  declare abstract class BaseApi {
1087
1093
  protected readonly serverUrl: string;
@@ -1130,6 +1136,12 @@ declare abstract class BaseApi {
1130
1136
  * Caller is responsible for checking response.ok and parsing body.
1131
1137
  */
1132
1138
  protected fetchResponse(path: string, init?: RequestInit): Promise<Response>;
1139
+ /**
1140
+ * Execute request, throw a parsed error on !response.ok, and unwrap the
1141
+ * `{ success, data }` envelope. Shorthand for the common
1142
+ * fetchResponse → throwResponseError → unwrapResponse sequence.
1143
+ */
1144
+ protected fetchUnwrapped<T>(path: string, init?: RequestInit, errorMessage?: string): Promise<T>;
1133
1145
  /**
1134
1146
  * Execute request against an absolute URL (bypasses baseUrl).
1135
1147
  * Useful for endpoints outside the default basePath (e.g. /auth vs /public).
@@ -1171,21 +1183,26 @@ interface AuthRequestParams {
1171
1183
  };
1172
1184
  state?: string;
1173
1185
  }
1186
+ /**
1187
+ * Unwrapped payload of a successful auth request.
1188
+ * ⚠️ Prior to the envelope unification this type described the raw
1189
+ * `{ success, data, message }` wire envelope; `requestAuth` now unwraps the
1190
+ * envelope like every other SDK method and resolves with the payload only.
1191
+ */
1174
1192
  interface AuthRequestResponse {
1175
- success: boolean;
1176
- data: {
1177
- redirectUrl: string;
1178
- };
1179
- message: string;
1193
+ redirectUrl: string;
1180
1194
  }
1181
1195
  declare class AuthApi extends BaseApi {
1182
1196
  constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'> & {
1183
1197
  sessionId?: string;
1184
1198
  });
1185
1199
  /**
1186
- * Initiate OAuth sign-in flow. Returns redirect URL to the auth provider.
1200
+ * Initiate OAuth sign-in flow. Resolves with the redirect URL to the auth provider.
1187
1201
  * Auth endpoints sit at /api/v1/auth/ (outside the /public basePath),
1188
- * so we use fetchAbsoluteUrl to get timeout, retry, and error handling via BaseApi.
1202
+ * so we use fetchAbsoluteUrl to get timeout, retry, and error handling via
1203
+ * BaseApi, then apply the standard throwResponseError → unwrapResponse
1204
+ * sequence (the fetchUnwrapped convention). Non-2xx responses and 2xx
1205
+ * envelopes with `success: false` both throw a structured Error.
1189
1206
  */
1190
1207
  requestAuth(params: AuthRequestParams): Promise<AuthRequestResponse>;
1191
1208
  /** Fetch user profile with the given session ID (used after OAuth redirect or from storage). */
@@ -1238,6 +1255,75 @@ declare class BetaForm {
1238
1255
  }): Promise<ApiResponse>;
1239
1256
  }
1240
1257
 
1258
+ /**
1259
+ * API client for the signed-in user's devices — the browsers/apps they have
1260
+ * signed in from. Session-authed (x-session-id + x-device-id), scoped to the
1261
+ * current user. Extends BaseApi for shared URL/auth/request handling.
1262
+ *
1263
+ * A device row is login history. Signing a device out revokes its live sessions
1264
+ * but keeps the row (shown as signed-out); "forget" also removes the row.
1265
+ */
1266
+
1267
+ /** Coarse geo/network info resolved from the request IP (a lightweight subset). */
1268
+ interface IIpInfoLite {
1269
+ ip?: string;
1270
+ hostname?: string;
1271
+ country?: string;
1272
+ city?: string;
1273
+ region?: string;
1274
+ /** "lat,long" string, as provided by the IP lookup. */
1275
+ loc?: string;
1276
+ timezone?: string;
1277
+ }
1278
+ /** A device the current user has signed in from. */
1279
+ interface IDeviceView {
1280
+ /** Stable per-browser/app identifier (the `x-device-id` the client sends). */
1281
+ deviceId: string;
1282
+ /** User-editable label (falls back to a derived name). */
1283
+ name: string;
1284
+ /** IP the device was last seen from. */
1285
+ ip: string;
1286
+ /** Resolved geo/network info for `ip`, when available. */
1287
+ ipInfo: IIpInfoLite | null;
1288
+ userAgent: string;
1289
+ origin: string;
1290
+ /** Whether the user marked this device trusted (longer sessions, fewer prompts). */
1291
+ trusted: boolean;
1292
+ /** ISO string — first time this device was seen. */
1293
+ firstSeenAt?: string;
1294
+ /** ISO string — most recent activity from this device. */
1295
+ lastActiveAt?: string;
1296
+ /** True when this is the device the request came from. */
1297
+ current: boolean;
1298
+ /** Number of live sessions currently on this device. */
1299
+ activeSessions: number;
1300
+ /** Whether this device has an active push-notification subscription. */
1301
+ pushEnabled: boolean;
1302
+ }
1303
+ declare class DevicesApi extends BaseApi {
1304
+ constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'> & {
1305
+ sessionId?: string;
1306
+ });
1307
+ /** List the devices the current user has signed in from. */
1308
+ list(signal?: AbortSignal): Promise<IDeviceView[]>;
1309
+ /** Rename a device (its user-facing label). */
1310
+ rename(deviceId: string, name: string, signal?: AbortSignal): Promise<void>;
1311
+ /**
1312
+ * Sign a device out: revoke every live session born on it. The device stays
1313
+ * in the list as a signed-out device. Returns the number of sessions revoked.
1314
+ */
1315
+ signOut(deviceId: string, signal?: AbortSignal): Promise<{
1316
+ revokedSessions: number;
1317
+ }>;
1318
+ /**
1319
+ * Forget a device: sign it out AND remove the history row entirely.
1320
+ * Returns the number of sessions revoked in the process.
1321
+ */
1322
+ forget(deviceId: string, signal?: AbortSignal): Promise<{
1323
+ revokedSessions: number;
1324
+ }>;
1325
+ }
1326
+
1241
1327
  declare class PushApi extends BaseApi {
1242
1328
  constructor(config: Pick<IBaseApiConfig, 'serverUrl' | 'version' | 'orgId' | 'sessionId'>);
1243
1329
  getVapidPublicKey(): Promise<{
@@ -1253,6 +1339,51 @@ declare class PushApi extends BaseApi {
1253
1339
  unsubscribe(endpoint: string): Promise<void>;
1254
1340
  }
1255
1341
 
1342
+ /**
1343
+ * API client for the signed-in user's active sessions. Session-authed
1344
+ * (x-session-id), scoped to the current user. Extends BaseApi for shared
1345
+ * URL/auth/request handling.
1346
+ *
1347
+ * The raw session id is never exposed — a session's public handle is its
1348
+ * mirror-row id (`ISessionView.id`), which is what `revoke` takes.
1349
+ * "Sign out everywhere" / "sign out current" stay on the auth logout flow.
1350
+ */
1351
+
1352
+ /** One live session of the current user, joined to its device's label. */
1353
+ interface ISessionView {
1354
+ /** Public handle (mirror-row id) — NOT the raw session id. Use for `revoke`. */
1355
+ id: string;
1356
+ /** The device this session was born on. */
1357
+ deviceId: string;
1358
+ /** OAuth client id, or 'first-party' for a normal app sign-in. */
1359
+ clientId: string;
1360
+ ip: string;
1361
+ ipInfo: IIpInfoLite | null;
1362
+ userAgent: string;
1363
+ origin: string;
1364
+ /** ISO string. */
1365
+ createdAt?: string;
1366
+ /** ISO string. */
1367
+ lastActiveAt?: string;
1368
+ /** ISO string — when the session expires (reflects the org session policy). */
1369
+ expiresAt?: string;
1370
+ /** True when this is the session making the request. */
1371
+ current: boolean;
1372
+ /** The device's label only; ip/userAgent/etc. live on the session itself. */
1373
+ device: {
1374
+ name: string;
1375
+ } | null;
1376
+ }
1377
+ declare class SessionsApi extends BaseApi {
1378
+ constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'> & {
1379
+ sessionId?: string;
1380
+ });
1381
+ /** List the current user's live sessions (each joined to its device label). */
1382
+ list(signal?: AbortSignal): Promise<ISessionView[]>;
1383
+ /** Sign out one session by its public handle (`ISessionView.id`). */
1384
+ revoke(id: string, signal?: AbortSignal): Promise<void>;
1385
+ }
1386
+
1256
1387
  /**
1257
1388
  * Centralized API client for organization (OS) settings.
1258
1389
  * Extends BaseApi for shared URL/auth/request handling.
@@ -1336,7 +1467,7 @@ interface NotificationData {
1336
1467
  push?: boolean;
1337
1468
  };
1338
1469
  /** Any additional merge tags available as {{key}} in the email template. */
1339
- [key: string]: any;
1470
+ [key: string]: unknown;
1340
1471
  }
1341
1472
  /** Result of sending a notification. */
1342
1473
  interface NotificationResult {
@@ -1367,64 +1498,64 @@ declare class WorkspaceApi extends BaseApi {
1367
1498
  sessionId?: string;
1368
1499
  onUnauthorized?: () => void;
1369
1500
  });
1370
- getWorkspaces(): Promise<IWorkspace[]>;
1501
+ getWorkspaces(signal?: AbortSignal): Promise<IWorkspace[]>;
1371
1502
  createWorkspace(data: {
1372
1503
  name: string;
1373
1504
  image?: string;
1374
- }): Promise<IWorkspace>;
1375
- updateWorkspace(id: string, data: Partial<IWorkspace>): Promise<IWorkspace>;
1376
- deleteWorkspace(id: string): Promise<{
1505
+ }, signal?: AbortSignal): Promise<IWorkspace>;
1506
+ updateWorkspace(id: string, data: Partial<IWorkspace>, signal?: AbortSignal): Promise<IWorkspace>;
1507
+ deleteWorkspace(id: string, signal?: AbortSignal): Promise<{
1377
1508
  success: boolean;
1378
1509
  }>;
1379
- getWorkspaceUsers(workspaceId: string): Promise<IWorkspaceUser[]>;
1510
+ getWorkspaceUsers(workspaceId: string, signal?: AbortSignal): Promise<IWorkspaceUser[]>;
1380
1511
  addUser(workspaceId: string, config: {
1381
1512
  email: string;
1382
1513
  role: string;
1383
- }): Promise<{
1514
+ }, signal?: AbortSignal): Promise<{
1384
1515
  userId: string;
1385
1516
  workspace: IWorkspace;
1386
1517
  message: string;
1387
1518
  }>;
1388
- removeUser(workspaceId: string, userId: string): Promise<{
1519
+ removeUser(workspaceId: string, userId: string, signal?: AbortSignal): Promise<{
1389
1520
  userId: string;
1390
1521
  workspace: IWorkspace;
1391
1522
  message: string;
1392
1523
  }>;
1393
- updateUser(workspaceId: string, userId: string, data: Partial<IWorkspaceUser>): Promise<{
1524
+ updateUser(workspaceId: string, userId: string, data: Partial<IWorkspaceUser>, signal?: AbortSignal): Promise<{
1394
1525
  userId: string;
1395
1526
  workspace: IWorkspace;
1396
1527
  message: string;
1397
1528
  }>;
1398
1529
  updateSettings(data: {
1399
1530
  permissions: Record<string, string[]>;
1400
- }): Promise<any>;
1401
- updateWorkspacePermissions(workspaceId: string, permissions: Record<string, string[]>): Promise<any>;
1402
- getFeatures(): Promise<IWorkspaceFeature[]>;
1403
- updateFeature(workspaceId: string, key: string, value: boolean): Promise<IWorkspace>;
1404
- getWorkspace(workspaceId: string): Promise<IWorkspace>;
1405
- getProfile(): Promise<IUser>;
1406
- updateUserProfile(config: Partial<IUser>): Promise<IUser>;
1407
- getPasskeys(): Promise<IPasskeySummary[]>;
1408
- renamePasskey(passkeyId: string, name: string): Promise<void>;
1409
- deletePasskey(passkeyId: string): Promise<void>;
1531
+ }, signal?: AbortSignal): Promise<any>;
1532
+ updateWorkspacePermissions(workspaceId: string, permissions: Record<string, string[]>, signal?: AbortSignal): Promise<any>;
1533
+ getFeatures(signal?: AbortSignal): Promise<IWorkspaceFeature[]>;
1534
+ updateFeature(workspaceId: string, key: string, value: boolean, signal?: AbortSignal): Promise<IWorkspace>;
1535
+ getWorkspace(workspaceId: string, signal?: AbortSignal): Promise<IWorkspace>;
1536
+ getProfile(signal?: AbortSignal): Promise<IUser>;
1537
+ updateUserProfile(config: Partial<IUser>, signal?: AbortSignal): Promise<IUser>;
1538
+ getPasskeys(signal?: AbortSignal): Promise<IPasskeySummary[]>;
1539
+ renamePasskey(passkeyId: string, name: string, signal?: AbortSignal): Promise<void>;
1540
+ deletePasskey(passkeyId: string, signal?: AbortSignal): Promise<void>;
1410
1541
  /**
1411
1542
  * Get current subscription for a workspace
1412
1543
  * Returns subscription details including plan, plan version, and group information
1413
1544
  */
1414
- getCurrentSubscription(workspaceId: string): Promise<ISubscriptionResponse>;
1545
+ getCurrentSubscription(workspaceId: string, signal?: AbortSignal): Promise<ISubscriptionResponse>;
1415
1546
  /**
1416
1547
  * Get plan group for a workspace
1417
1548
  * Returns the plan group containing the current plan if subscription exists,
1418
1549
  * otherwise returns the latest published group
1419
1550
  */
1420
- getPlanGroup(workspaceId: string): Promise<IPlanGroupResponse>;
1551
+ getPlanGroup(workspaceId: string, signal?: AbortSignal): Promise<IPlanGroupResponse>;
1421
1552
  /**
1422
1553
  * Get plan group for a workspace with a specific version
1423
1554
  * @param workspaceId - The workspace ID
1424
1555
  * @param groupVersionId - The plan group version ID to fetch
1425
1556
  * @returns Plan group response with the specified version
1426
1557
  */
1427
- getPlanGroupByVersion(workspaceId: string, groupVersionId: string): Promise<IPlanGroupResponse>;
1558
+ getPlanGroupByVersion(workspaceId: string, groupVersionId: string, signal?: AbortSignal): Promise<IPlanGroupResponse>;
1428
1559
  /**
1429
1560
  * Get current group version and available newer versions of the same group
1430
1561
  * - If user has active subscription: returns their current group version + newer versions
@@ -1434,7 +1565,7 @@ declare class WorkspaceApi extends BaseApi {
1434
1565
  * @param workspaceId - The workspace ID
1435
1566
  * @returns Plan group versions response with currentVersion and availableVersions
1436
1567
  */
1437
- getPlanGroupVersions(workspaceId: string): Promise<IPlanGroupVersionsResponse>;
1568
+ getPlanGroupVersions(workspaceId: string, signal?: AbortSignal): Promise<IPlanGroupVersionsResponse>;
1438
1569
  /**
1439
1570
  * Get plan group versions by slug (public, no auth required).
1440
1571
  * Returns the latest published plan group versions for the given plan group slug.
@@ -1443,7 +1574,7 @@ declare class WorkspaceApi extends BaseApi {
1443
1574
  * @param slug - Plan group slug (e.g. 'default', 'enterprise')
1444
1575
  * @returns Plan group versions response with currentVersion and availableVersions
1445
1576
  */
1446
- getPublicPlans(slug: string): Promise<IPublicPlansResponse>;
1577
+ getPublicPlans(slug: string, signal?: AbortSignal): Promise<IPublicPlansResponse>;
1447
1578
  /**
1448
1579
  * Get credit packages (public, no auth required).
1449
1580
  * Returns active credit packages for the org with pricing info.
@@ -1451,7 +1582,7 @@ declare class WorkspaceApi extends BaseApi {
1451
1582
  *
1452
1583
  * @returns Credit packages with pricing variants
1453
1584
  */
1454
- getPublicCreditPackages(): Promise<IPublicCreditPackagesResponse>;
1585
+ getPublicCreditPackages(signal?: AbortSignal): Promise<IPublicCreditPackagesResponse>;
1455
1586
  /**
1456
1587
  * Get plan group version details by ID (public, no auth required).
1457
1588
  * Returns the full plan group version with populated plan versions.
@@ -1460,15 +1591,24 @@ declare class WorkspaceApi extends BaseApi {
1460
1591
  * @param groupVersionId - The plan group version ID to fetch
1461
1592
  * @returns Plan group version with populated plan versions
1462
1593
  */
1463
- getPlanGroupVersion(groupVersionId: string): Promise<IPlanGroupVersion>;
1594
+ getPlanGroupVersion(groupVersionId: string, signal?: AbortSignal): Promise<IPlanGroupVersion>;
1464
1595
  /**
1465
1596
  * Create checkout session for new subscription
1466
1597
  * @param workspaceId - The workspace ID
1467
1598
  * @param request - Checkout session request with planVersionId and optional billing interval/URLs
1468
1599
  * @returns Checkout session response with checkoutUrl to redirect user
1469
1600
  */
1470
- createCheckoutSession(workspaceId: string, request: ICheckoutSessionRequest): Promise<CheckoutResult>;
1471
- selectFreePlan(workspaceId: string, planVersionId: string): Promise<{
1601
+ createCheckoutSession(workspaceId: string, request: ICheckoutSessionRequest, signal?: AbortSignal): Promise<CheckoutResult>;
1602
+ /**
1603
+ * Assign a free (freemium) plan to the workspace without a Stripe checkout.
1604
+ *
1605
+ * This endpoint's envelope carries no `data` payload — it is
1606
+ * `{ success, message }` — so `fetchUnwrapped` resolves with the envelope
1607
+ * itself (its unwrap only extracts `data` when present). On resolution
1608
+ * `success` is therefore always `true`: non-2xx responses and 2xx envelopes
1609
+ * with `success: false` both throw a structured Error.
1610
+ */
1611
+ selectFreePlan(workspaceId: string, planVersionId: string, signal?: AbortSignal): Promise<{
1472
1612
  success: boolean;
1473
1613
  message: string;
1474
1614
  }>;
@@ -1477,12 +1617,12 @@ declare class WorkspaceApi extends BaseApi {
1477
1617
  * Only allows plan changes within the same plan group
1478
1618
  * Returns checkout session if payment is required, otherwise returns subscription update response
1479
1619
  */
1480
- updateSubscription(workspaceId: string, request: ISubscriptionUpdateRequest): Promise<ISubscriptionUpdateResponse | ICheckoutSessionResponse>;
1620
+ updateSubscription(workspaceId: string, request: ISubscriptionUpdateRequest, signal?: AbortSignal): Promise<ISubscriptionUpdateResponse | ICheckoutSessionResponse>;
1481
1621
  /**
1482
1622
  * Create a Stripe Customer Portal session for managing payment methods, invoices, etc.
1483
1623
  * Returns the portal URL — redirect user to it.
1484
1624
  */
1485
- createBillingPortalSession(workspaceId: string, returnUrl?: string): Promise<{
1625
+ createBillingPortalSession(workspaceId: string, returnUrl?: string, signal?: AbortSignal): Promise<{
1486
1626
  url: string;
1487
1627
  }>;
1488
1628
  /**
@@ -1492,35 +1632,35 @@ declare class WorkspaceApi extends BaseApi {
1492
1632
  * @param startingAfter - Invoice ID to start after (for pagination)
1493
1633
  * @returns List of invoices with pagination info
1494
1634
  */
1495
- listInvoices(workspaceId: string, limit?: number, startingAfter?: string): Promise<IInvoiceListResponse>;
1635
+ listInvoices(workspaceId: string, limit?: number, startingAfter?: string, signal?: AbortSignal): Promise<IInvoiceListResponse>;
1496
1636
  /**
1497
1637
  * Get a single invoice by ID
1498
1638
  * @param workspaceId - The workspace ID
1499
1639
  * @param invoiceId - The invoice ID
1500
1640
  * @returns Invoice details
1501
1641
  */
1502
- getInvoice(workspaceId: string, invoiceId: string): Promise<IInvoiceResponse>;
1642
+ getInvoice(workspaceId: string, invoiceId: string, signal?: AbortSignal): Promise<IInvoiceResponse>;
1503
1643
  /**
1504
1644
  * Cancel subscription at the end of the current billing period
1505
1645
  * Sets cancelAtPeriodEnd: true - subscription remains active until period ends
1506
1646
  * @param workspaceId - The workspace ID
1507
1647
  * @returns Updated subscription with cancelAtPeriodEnd and stripeCurrentPeriodEnd
1508
1648
  */
1509
- cancelSubscriptionAtPeriodEnd(workspaceId: string): Promise<ISubscriptionResponse>;
1649
+ cancelSubscriptionAtPeriodEnd(workspaceId: string, signal?: AbortSignal): Promise<ISubscriptionResponse>;
1510
1650
  /**
1511
1651
  * Resume a subscription that was scheduled for cancellation
1512
1652
  * Sets cancelAtPeriodEnd: false - subscription will continue after period ends
1513
1653
  * @param workspaceId - The workspace ID
1514
1654
  * @returns Updated subscription with cancelAtPeriodEnd set to false
1515
1655
  */
1516
- resumeSubscription(workspaceId: string): Promise<ISubscriptionResponse>;
1656
+ resumeSubscription(workspaceId: string, signal?: AbortSignal): Promise<ISubscriptionResponse>;
1517
1657
  /**
1518
1658
  * Record quota usage for a workspace
1519
1659
  * @param workspaceId - The workspace ID
1520
1660
  * @param request - Usage request with quotaSlug, quantity, and optional metadata/source
1521
1661
  * @returns Usage result with consumed/included/available/overage
1522
1662
  */
1523
- recordUsage(workspaceId: string, request: IRecordUsageRequest): Promise<IRecordUsageResponse>;
1663
+ recordUsage(workspaceId: string, request: IRecordUsageRequest, signal?: AbortSignal): Promise<IRecordUsageResponse>;
1524
1664
  /**
1525
1665
  * Record multiple quota usage entries in a single request.
1526
1666
  * Designed for backend-to-backend high-volume scenarios (bulk exports, batch jobs).
@@ -1544,7 +1684,7 @@ declare class WorkspaceApi extends BaseApi {
1544
1684
  source?: string;
1545
1685
  idempotencyKey?: string;
1546
1686
  }>;
1547
- }): Promise<{
1687
+ }, signal?: AbortSignal): Promise<{
1548
1688
  success: boolean;
1549
1689
  total: number;
1550
1690
  succeeded: number;
@@ -1562,20 +1702,20 @@ declare class WorkspaceApi extends BaseApi {
1562
1702
  * @param quotaSlug - The quota slug to check
1563
1703
  * @returns Quota usage status with consumed/included/available/overage/hasOverage
1564
1704
  */
1565
- getQuotaUsageStatus(workspaceId: string, quotaSlug: string): Promise<IQuotaUsageStatusResponse>;
1705
+ getQuotaUsageStatus(workspaceId: string, quotaSlug: string, signal?: AbortSignal): Promise<IQuotaUsageStatusResponse>;
1566
1706
  /**
1567
1707
  * Get usage status for all quotas in the workspace's current plan
1568
1708
  * @param workspaceId - The workspace ID
1569
1709
  * @returns All quota usage statuses keyed by quota slug
1570
1710
  */
1571
- getAllQuotaUsage(workspaceId: string): Promise<IAllQuotaUsageResponse>;
1711
+ getAllQuotaUsage(workspaceId: string, signal?: AbortSignal): Promise<IAllQuotaUsageResponse>;
1572
1712
  /**
1573
1713
  * Get paginated usage logs for a workspace
1574
1714
  * @param workspaceId - The workspace ID
1575
1715
  * @param query - Optional filters: quotaSlug, from, to, source, page, limit
1576
1716
  * @returns Paginated usage log entries
1577
1717
  */
1578
- getUsageLogs(workspaceId: string, query?: IUsageLogsQuery): Promise<IUsageLogsResponse>;
1718
+ getUsageLogs(workspaceId: string, query?: IUsageLogsQuery, signal?: AbortSignal): Promise<IUsageLogsResponse>;
1579
1719
  /**
1580
1720
  * Trigger a notification event for a workspace.
1581
1721
  * Respects all notification gates (org settings, event config, workspace preferences).
@@ -1598,16 +1738,16 @@ declare class WorkspaceApi extends BaseApi {
1598
1738
  * });
1599
1739
  * ```
1600
1740
  */
1601
- sendNotification(workspaceId: string, event: string, userId?: string, data?: NotificationData): Promise<NotificationResult>;
1602
- getNotificationEvents(workspaceId: string): Promise<NotificationEvent[]>;
1603
- getNotificationPreferences(workspaceId: string): Promise<Record<string, {
1741
+ sendNotification(workspaceId: string, event: string, userId?: string, data?: NotificationData, signal?: AbortSignal): Promise<NotificationResult>;
1742
+ getNotificationEvents(workspaceId: string, signal?: AbortSignal): Promise<NotificationEvent[]>;
1743
+ getNotificationPreferences(workspaceId: string, signal?: AbortSignal): Promise<Record<string, {
1604
1744
  email?: boolean;
1605
1745
  push?: boolean;
1606
1746
  }>>;
1607
1747
  updateNotificationPreferences(workspaceId: string, preferences: Record<string, {
1608
1748
  email?: boolean;
1609
1749
  push?: boolean;
1610
- }>): Promise<Record<string, {
1750
+ }>, signal?: AbortSignal): Promise<Record<string, {
1611
1751
  email?: boolean;
1612
1752
  push?: boolean;
1613
1753
  }>>;
@@ -1616,7 +1756,7 @@ declare class WorkspaceApi extends BaseApi {
1616
1756
  * @param workspaceId - The workspace ID
1617
1757
  * @returns Credit balance with available, totalGranted, totalConsumed, totalExpired, totalRefunded
1618
1758
  */
1619
- getCreditBalance(workspaceId: string): Promise<ICreditBalance>;
1759
+ getCreditBalance(workspaceId: string, signal?: AbortSignal): Promise<ICreditBalance>;
1620
1760
  /**
1621
1761
  * Consume credits from a workspace balance.
1622
1762
  * Throws an error with `code: 'INSUFFICIENT_CREDITS'` and `available`/`requested` fields on 402.
@@ -1624,7 +1764,7 @@ declare class WorkspaceApi extends BaseApi {
1624
1764
  * @param request - Consume request with amount, optional description, idempotencyKey, metadata
1625
1765
  * @returns Consume result with consumed amount and balanceAfter
1626
1766
  */
1627
- consumeCredits(workspaceId: string, request: IConsumeCreditsRequest): Promise<IConsumeCreditsResponse>;
1767
+ consumeCredits(workspaceId: string, request: IConsumeCreditsRequest, signal?: AbortSignal): Promise<IConsumeCreditsResponse>;
1628
1768
  /**
1629
1769
  * Create a Stripe checkout session for purchasing a credit package.
1630
1770
  * Returns a checkout URL to redirect the user to.
@@ -1632,35 +1772,35 @@ declare class WorkspaceApi extends BaseApi {
1632
1772
  * @param request - Purchase request with creditPackageId, successUrl, cancelUrl, optional currency
1633
1773
  * @returns Checkout session ID and URL
1634
1774
  */
1635
- purchaseCredits(workspaceId: string, request: ICreditPurchaseRequest): Promise<ICreditPurchaseResponse>;
1775
+ purchaseCredits(workspaceId: string, request: ICreditPurchaseRequest, signal?: AbortSignal): Promise<ICreditPurchaseResponse>;
1636
1776
  /**
1637
1777
  * List available credit packages for purchase.
1638
1778
  * Returns active, non-archived packages sorted by sortOrder then creditAmount.
1639
1779
  * @param workspaceId - The workspace ID
1640
1780
  * @returns Array of credit packages
1641
1781
  */
1642
- getCreditPackages(workspaceId: string): Promise<ICreditPackage[]>;
1782
+ getCreditPackages(workspaceId: string, signal?: AbortSignal): Promise<ICreditPackage[]>;
1643
1783
  /**
1644
1784
  * Get paginated credit transaction history.
1645
1785
  * @param workspaceId - The workspace ID
1646
1786
  * @param query - Optional filters: type, page, limit
1647
1787
  * @returns Paginated credit transactions
1648
1788
  */
1649
- getCreditTransactions(workspaceId: string, query?: ICreditTransactionsQuery): Promise<ICreditTransactionsResponse>;
1789
+ getCreditTransactions(workspaceId: string, query?: ICreditTransactionsQuery, signal?: AbortSignal): Promise<ICreditTransactionsResponse>;
1650
1790
  /**
1651
1791
  * Get paginated credit buckets.
1652
1792
  * @param workspaceId - The workspace ID
1653
1793
  * @param query - Optional filters: status, source, page, limit
1654
1794
  * @returns Paginated credit buckets
1655
1795
  */
1656
- getCreditBuckets(workspaceId: string, query?: ICreditBucketsQuery): Promise<ICreditBucketsResponse>;
1796
+ getCreditBuckets(workspaceId: string, query?: ICreditBucketsQuery, signal?: AbortSignal): Promise<ICreditBucketsResponse>;
1657
1797
  /**
1658
1798
  * Get credits expiring within N days.
1659
1799
  * @param workspaceId - The workspace ID
1660
1800
  * @param days - Look-ahead window in days (1-90, default 7)
1661
1801
  * @returns Expiring credits summary with bucket list
1662
1802
  */
1663
- getExpiringCredits(workspaceId: string, days?: number): Promise<IExpiringCreditsResponse>;
1803
+ getExpiringCredits(workspaceId: string, days?: number, signal?: AbortSignal): Promise<IExpiringCreditsResponse>;
1664
1804
  }
1665
1805
 
1666
1806
  /**
@@ -1787,6 +1927,7 @@ declare const BBAction: {
1787
1927
  readonly SelectPlan: "selectPlan";
1788
1928
  readonly CreditPurchase: "creditPurchase";
1789
1929
  readonly OpenCreditStore: "openCreditStore";
1930
+ readonly OpenConnectGuide: "openConnectGuide";
1790
1931
  readonly Invite: "invite";
1791
1932
  };
1792
1933
  type BBActionType = (typeof BBAction)[keyof typeof BBAction];
@@ -1944,14 +2085,33 @@ declare const PLAN_CURRENCY_OPTIONS: {
1944
2085
  value: "usd" | "eur" | "gbp" | "jpy" | "cad" | "aud" | "chf" | "cny" | "hkd" | "sgd" | "inr" | "mxn" | "brl" | "nzd" | "sek" | "nok" | "dkk" | "pln" | "thb";
1945
2086
  label: string;
1946
2087
  }[];
2088
+ /**
2089
+ * Minor-unit digits for a currency per ISO 4217: 0 (JPY, KRW, …), 2 (most),
2090
+ * or 3 (KWD, BHD, …). The zero- and three-decimal sets are pinned to Stripe's
2091
+ * treatment (the billing backend defines amount semantics); ISK is pinned to 2
2092
+ * (Stripe legacy — ISO 4217 says 0). Any other code defers to the runtime's
2093
+ * CLDR data (IQD/LYD → 3, CLF/UYW → 4, UYI → 0), falling back to 2 for codes
2094
+ * unknown to Intl or malformed.
2095
+ */
2096
+ declare function getCurrencyDecimals(currency: string | null | undefined): number;
1947
2097
  /** True when `currency` has no minor unit (JPY, KRW, …) — amounts are whole units, not cents. */
1948
2098
  declare function isZeroDecimalCurrency(currency: string | null | undefined): boolean;
1949
2099
  /**
1950
2100
  * Convert a minor-unit amount to its display number for `currency`:
1951
2101
  * `minorAmountToDisplay(1999, 'usd')` → `"19.99"`,
1952
- * `minorAmountToDisplay(1000, 'jpy')` → `"1,000"` (zero-decimal — no division).
2102
+ * `minorAmountToDisplay(1000, 'jpy')` → `"1,000"` (zero-decimal — no division),
2103
+ * `minorAmountToDisplay(12345, 'kwd')` → `"12.345"` (three-decimal — ÷1000).
1953
2104
  */
1954
2105
  declare function minorAmountToDisplay(amount: number, currency: string): string;
2106
+ /**
2107
+ * Locale-aware currency formatting of a minor-unit amount via `Intl.NumberFormat`
2108
+ * (`(1999, 'usd', 'en-US')` → `"$19.99"`; `(1000, 'jpy', 'ja-JP')` → `"¥1,000"`;
2109
+ * `(12345, 'kwd')` → `"KWD 12.345"`). The divisor follows the currency's ISO 4217
2110
+ * minor-unit digits (see `getCurrencyDecimals`) — zero-decimal currencies are
2111
+ * never divided, three-decimal divide by 1000. Falls back to the symbol table
2112
+ * when the currency code is empty or malformed.
2113
+ */
2114
+ declare function formatMinorAmountIntl(amount: number, currency: string, locale?: string): string;
1955
2115
  /** Format cents as money string (e.g. 1999, "usd" -> "$19.99"; 1000, "jpy" -> "¥1,000"). Caller must pass currency (e.g. from plan or workspace). */
1956
2116
  declare function formatCents(cents: number, currency: string): string;
1957
2117
  /** Translatable labels for overage/quota formatting */
@@ -1971,15 +2131,16 @@ interface OverageLabels {
1971
2131
  }
1972
2132
  /**
1973
2133
  * Format overage rate for display. When unitSize > 1: "$1.00/1,000 units"; else "$1.00/unit".
1974
- * Pass `labels` for i18n support.
2134
+ * Pass `labels` for i18n support and `locale` to group numbers in the display locale.
1975
2135
  */
1976
- declare function formatOverageRate(overageCents: number | undefined, unitSize: number | undefined, currency: string, labels?: Partial<OverageLabels>): string | null;
2136
+ declare function formatOverageRate(overageCents: number | undefined, unitSize: number | undefined, currency: string, labels?: Partial<OverageLabels>, locale?: string): string | null;
1977
2137
  /**
1978
2138
  * Format overage rate with optional unit label for comparison/preview UIs.
1979
2139
  * e.g. formatOverageRateWithLabel(50, 1000, "video", "usd") -> "$0.50/1,000 videos"
1980
2140
  * Pass `labels` for i18n support. Pass `pluralUnitLabel` to avoid English "s" pluralization.
2141
+ * Pass `locale` to group numbers in the display locale.
1981
2142
  */
1982
- declare function formatOverageRateWithLabel(overageCents: number | undefined, unitSize: number | undefined, unitLabel: string | undefined, currency: string, pluralUnitLabel?: string, labels?: Partial<OverageLabels>): string | null;
2143
+ declare function formatOverageRateWithLabel(overageCents: number | undefined, unitSize: number | undefined, unitLabel: string | undefined, currency: string, pluralUnitLabel?: string, labels?: Partial<OverageLabels>, locale?: string): string | null;
1983
2144
  /**
1984
2145
  * Get singular unit label from item name or slug (e.g. "Videos" -> "video", "reels" -> "reel").
1985
2146
  * Used for quota display in comparison and preview.
@@ -1988,9 +2149,10 @@ declare function formatOverageRateWithLabel(overageCents: number | undefined, un
1988
2149
  declare function getQuotaUnitLabelFromName(nameOrSlug: string, fallback?: string): string;
1989
2150
  /**
1990
2151
  * Format quota "included + overage" for display.
1991
- * Pass `labels` and `pluralUnitLabel` for i18n support.
2152
+ * Pass `labels` and `pluralUnitLabel` for i18n support, and `locale` to group
2153
+ * numbers in the display locale.
1992
2154
  */
1993
- declare function formatQuotaIncludedOverage(included: number | undefined, overageCents: number | undefined, unitLabel: string, currency: string, unitSize?: number, pluralUnitLabel?: string, labels?: Partial<OverageLabels>, allowOverage?: boolean): string;
2155
+ declare function formatQuotaIncludedOverage(included: number | undefined, overageCents: number | undefined, unitLabel: string, currency: string, unitSize?: number, pluralUnitLabel?: string, labels?: Partial<OverageLabels>, allowOverage?: boolean, locale?: string): string;
1994
2156
 
1995
2157
  type QuotaDisplayValue = {
1996
2158
  included: number;
@@ -2022,6 +2184,8 @@ interface QuotaLabels {
2022
2184
  included: string;
2023
2185
  /** e.g. "then" — separator between included and price */
2024
2186
  then: string;
2187
+ /** e.g. "hard limit" — shown when overage is not allowed */
2188
+ hardLimit?: string;
2025
2189
  }
2026
2190
  /**
2027
2191
  * Format a quota display value as "X included, then $Y.YY / unit".
@@ -2149,6 +2313,18 @@ declare function validateInvite(opts: {
2149
2313
  requireSubscription?: boolean;
2150
2314
  }): InviteValidation;
2151
2315
 
2316
+ /** Minimal workspace shape needed for ownership/role checks. Extended by `permissions.WorkspaceLike`. */
2317
+ interface WorkspaceLike$1 {
2318
+ _id: string;
2319
+ createdBy: string | {
2320
+ _id: string;
2321
+ } | null | undefined;
2322
+ users?: Array<string | {
2323
+ _id: string;
2324
+ role?: string;
2325
+ }>;
2326
+ }
2327
+
2152
2328
  /**
2153
2329
  * Role-based permission system.
2154
2330
  * Framework-agnostic — used by both React hooks and server-side BuildBase.
@@ -2166,6 +2342,7 @@ declare function validateInvite(opts: {
2166
2342
  * Both are resolved from the same role→permission map. Owner always gets all
2167
2343
  * platform permissions + any app permissions defined in the config.
2168
2344
  */
2345
+
2169
2346
  declare const Permission: {
2170
2347
  readonly WORKSPACE_SETTINGS_VIEW: "workspace:settings:view";
2171
2348
  readonly WORKSPACE_SETTINGS_EDIT: "workspace:settings:edit";
@@ -2183,15 +2360,7 @@ declare const Permission: {
2183
2360
  type PermissionKey = (typeof Permission)[keyof typeof Permission];
2184
2361
  type RolePermissionMap = Record<string, string[]>;
2185
2362
  declare const DEFAULT_ROLE_PERMISSIONS: RolePermissionMap;
2186
- interface WorkspaceLike {
2187
- _id: string;
2188
- createdBy: string | {
2189
- _id: string;
2190
- } | null | undefined;
2191
- users?: Array<string | {
2192
- _id: string;
2193
- role?: string;
2194
- }>;
2363
+ interface WorkspaceLike extends WorkspaceLike$1 {
2195
2364
  permissions?: Record<string, string[]>;
2196
2365
  }
2197
2366
  interface SettingsLike {
@@ -2248,7 +2417,7 @@ declare function hasPermission(permission: string | string[], ctx: PermissionCon
2248
2417
  *
2249
2418
  * Or manually create `public/push-sw.js` with this content.
2250
2419
  */
2251
- declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n try {\n const payload = event.data.json();\n const title = payload.title || 'Notification';\n const options = {\n body: payload.body || '',\n icon: payload.icon || undefined,\n badge: payload.icon || undefined,\n data: { url: payload.url, ...(payload.data || {}) },\n tag: 'buildbase-push-' + Date.now(),\n };\n\n event.waitUntil(\n self.registration.showNotification(title, options)\n );\n } catch (e) {\n console.error('[PushSW] Failed to show notification:', e);\n }\n});\n\nself.addEventListener('notificationclick', function(event) {\n event.notification.close();\n\n const url = event.notification.data && event.notification.data.url;\n if (url) {\n event.waitUntil(\n clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) {\n for (let i = 0; i < clientList.length; i++) {\n const client = clientList[i];\n if (client.url === url && 'focus' in client) {\n return client.focus();\n }\n }\n if (clients.openWindow) {\n return clients.openWindow(url);\n }\n })\n );\n }\n});\n";
2420
+ declare const PUSH_SERVICE_WORKER_SCRIPT = "\n// BuildBase Push Notification Service Worker\n// Place this file in your app's public directory (e.g. public/push-sw.js)\n\nself.addEventListener('push', function(event) {\n if (!event.data) return;\n\n try {\n const payload = event.data.json();\n // i18n exception: service workers run outside the SDK's translation\n // provider, so this last-resort fallback stays English. The server should\n // always send a localized payload.title.\n const title = payload.title || 'Notification';\n const options = {\n body: payload.body || '',\n icon: payload.icon || undefined,\n badge: payload.icon || undefined,\n data: { url: payload.url, ...(payload.data || {}) },\n tag: 'buildbase-push-' + Date.now(),\n };\n\n event.waitUntil(\n self.registration.showNotification(title, options)\n );\n } catch (e) {\n console.error('[PushSW] Failed to show notification:', e);\n }\n});\n\nself.addEventListener('notificationclick', function(event) {\n event.notification.close();\n\n const url = event.notification.data && event.notification.data.url;\n if (url) {\n event.waitUntil(\n clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) {\n for (let i = 0; i < clientList.length; i++) {\n const client = clientList[i];\n if (client.url === url && 'focus' in client) {\n return client.focus();\n }\n }\n if (clients.openWindow) {\n return clients.openWindow(url);\n }\n })\n );\n }\n});\n";
2252
2421
 
2253
2422
  interface BetaFormData {
2254
2423
  name?: string;
@@ -2271,6 +2440,24 @@ interface SDKMessages {
2271
2440
  connectedAgentsEmpty: string;
2272
2441
  connectedAgentsAccess: string;
2273
2442
  connectedAgentsGranted: string;
2443
+ connectedAgentsLoadFailed: string;
2444
+ connectedAgentsRevokeFailed: string;
2445
+ mcpConnectAction: string;
2446
+ mcpGuideTitle: string;
2447
+ mcpGuideDescription: string;
2448
+ mcpServerUrlLabel: string;
2449
+ mcpServerUrlHint: string;
2450
+ mcpPromptLabel: string;
2451
+ mcpPromptHint: string;
2452
+ mcpPromptTemplate: string;
2453
+ mcpClientsLabel: string;
2454
+ mcpAddToConfigFile: string;
2455
+ mcpClientChatgptInstructions: string;
2456
+ mcpClientClaudeInstructions: string;
2457
+ mcpClientClineInstructions: string;
2458
+ mcpCopy: string;
2459
+ mcpCopied: string;
2460
+ mcpLearnMore: string;
2274
2461
  inactive: string;
2275
2462
  inactiveHint: string;
2276
2463
  passkeysTitle: string;
@@ -2284,11 +2471,41 @@ interface SDKMessages {
2284
2471
  renamePlaceholder: string;
2285
2472
  lastUsed: string;
2286
2473
  added: string;
2474
+ devicesTitle: string;
2475
+ devicesDescription: string;
2476
+ devicesEmpty: string;
2477
+ devicesLoadFailed: string;
2478
+ deviceCurrent: string;
2479
+ deviceTrusted: string;
2480
+ deviceActiveSessions: string;
2481
+ devicePushEnabled: string;
2482
+ deviceLastActive: string;
2483
+ deviceRename: string;
2484
+ deviceRenamePlaceholder: string;
2485
+ deviceRenameFailed: string;
2486
+ deviceSave: string;
2487
+ deviceCancel: string;
2488
+ deviceSignOut: string;
2489
+ deviceSignOutFailed: string;
2490
+ deviceForget: string;
2491
+ deviceForgetFailed: string;
2492
+ deviceForgetConfirmTitle: string;
2493
+ deviceForgetConfirmBody: string;
2494
+ sessionsTitle: string;
2495
+ sessionsDescription: string;
2496
+ sessionsEmpty: string;
2497
+ sessionsLoadFailed: string;
2498
+ sessionCurrent: string;
2499
+ sessionExpires: string;
2500
+ sessionLastActive: string;
2501
+ sessionSignOut: string;
2502
+ sessionSignOutFailed: string;
2287
2503
  };
2288
2504
  settings: {
2289
2505
  titles: {
2290
2506
  profile: string;
2291
2507
  security: string;
2508
+ devices: string;
2292
2509
  general: string;
2293
2510
  users: string;
2294
2511
  subscription: string;
@@ -2304,6 +2521,7 @@ interface SDKMessages {
2304
2521
  workspace: string;
2305
2522
  profile: string;
2306
2523
  security: string;
2524
+ devices: string;
2307
2525
  general: string;
2308
2526
  users: string;
2309
2527
  subscription: string;
@@ -2334,6 +2552,7 @@ interface SDKMessages {
2334
2552
  billingManageOnly: string;
2335
2553
  openSettings: string;
2336
2554
  back: string;
2555
+ close: string;
2337
2556
  };
2338
2557
  };
2339
2558
  subscription: {
@@ -2620,6 +2839,7 @@ interface SDKMessages {
2620
2839
  featureSuccess: string;
2621
2840
  updateSuccess: string;
2622
2841
  actionStatus: string;
2842
+ fallbackName: string;
2623
2843
  };
2624
2844
  danger: {
2625
2845
  title: string;
@@ -2840,6 +3060,7 @@ interface SDKMessages {
2840
3060
  purchaseFailed: string;
2841
3061
  errorLoading: string;
2842
3062
  insufficientCredits: string;
3063
+ insufficientDetail: string;
2843
3064
  };
2844
3065
  loading: {
2845
3066
  restoringSession: string;
@@ -2875,6 +3096,7 @@ interface SDKMessages {
2875
3096
  fetchCreditPackages: string;
2876
3097
  fetchCreditTransactions: string;
2877
3098
  fetchExpiringCredits: string;
3099
+ fetchWorkspaces: string;
2878
3100
  };
2879
3101
  }
2880
3102
  /**
@@ -3019,8 +3241,8 @@ declare function parseWebhookEvent(options: {
3019
3241
  * export const agentConfig: AgentReadyConfig = {
3020
3242
  * serverUrl: process.env.BUILDBASE_URL!,
3021
3243
  * orgId: process.env.BUILDBASE_ORG_ID!,
3022
- * siteUrl: "https://imejis.io",
3023
- * site: { name: "Imejis", description: "Generate images from templates via API." },
3244
+ * siteUrl: "https://example.com",
3245
+ * site: { name: "Acme", description: "Generate images from templates via API." },
3024
3246
  * robots: { contentSignals: { search: true, aiInput: true, aiTrain: false } },
3025
3247
  * };
3026
3248
  * export async function serveAgentPath(req: Request): Promise<Response> {
@@ -3063,7 +3285,7 @@ interface AgentReadinessBundle {
3063
3285
  }
3064
3286
  /** An Agent Skill (Agent Skills Discovery RFC v0.2.0) published by this app. */
3065
3287
  interface AgentSkill {
3066
- /** Stable slug, e.g. `imejis-api`. */
3288
+ /** Stable slug, e.g. `acme-api`. */
3067
3289
  name: string;
3068
3290
  /** One-line human/agent-readable summary. */
3069
3291
  description: string;
@@ -3079,7 +3301,7 @@ interface AgentSkill {
3079
3301
  }
3080
3302
  /** One API described in an API Catalog (RFC 9727 / RFC 9264 linkset). */
3081
3303
  interface ApiCatalogApi {
3082
- /** Anchor URL identifying the API, e.g. `https://api.imejis.io`. */
3304
+ /** Anchor URL identifying the API, e.g. `https://api.example.com`. */
3083
3305
  anchor: string;
3084
3306
  /** OpenAPI / machine-readable description URL (link rel `service-desc`). */
3085
3307
  serviceDesc?: string;
@@ -3100,7 +3322,7 @@ interface McpServerCard {
3100
3322
  endpoint: string;
3101
3323
  /** Transport type. Defaults to `"streamable-http"`. */
3102
3324
  transport?: string;
3103
- /** MCP protocol version the server speaks. Defaults to `"2025-06-18"`. */
3325
+ /** MCP protocol version the server speaks. Defaults to `"2025-11-25"`. */
3104
3326
  protocolVersion?: string;
3105
3327
  /**
3106
3328
  * Capability flags. Booleans per SEP-1649 v1.0; a legacy object value
@@ -3204,7 +3426,7 @@ interface AgentReadyConfig {
3204
3426
  /** The org id (24-hex) whose agent-readiness config to serve. */
3205
3427
  orgId: string;
3206
3428
  /**
3207
- * This app's public origin, e.g. `https://imejis.io`. Used to build absolute
3429
+ * This app's public origin, e.g. `https://example.com`. Used to build absolute
3208
3430
  * URLs in the Agent Card and to match RFC 9728 resource paths.
3209
3431
  */
3210
3432
  siteUrl: string;
@@ -3518,14 +3740,20 @@ declare function resolveWellKnown(requestPath: string, config: AgentReadyConfig)
3518
3740
  * agent-readiness surface. Returns null for paths this app doesn't serve.
3519
3741
  */
3520
3742
  declare function resolveAgentPath(requestPath: string, config: AgentReadyConfig): Promise<DiscoveryDocument | null>;
3521
- /** A WebMCP tool definition exposed to in-page agents via `navigator.modelContext`. */
3522
- interface WebMcpTool {
3743
+ /**
3744
+ * A WebMCP tool definition exposed to in-page agents via `navigator.modelContext`.
3745
+ * `TInput` is the shape your `inputSchema` describes — type your `execute`
3746
+ * parameter inline (`execute: (input: { path: string }) => …`) or pin it with
3747
+ * `WebMcpTool<{ path: string }>`. The default is deliberately loose: the input
3748
+ * arrives from the agent unvalidated, so treat it as untrusted regardless.
3749
+ */
3750
+ interface WebMcpTool<TInput = any> {
3523
3751
  name: string;
3524
3752
  description: string;
3525
3753
  /** JSON Schema for the tool's input. */
3526
3754
  inputSchema: Record<string, unknown>;
3527
3755
  /** Called when an agent invokes the tool. */
3528
- execute: (input: any) => unknown | Promise<unknown>;
3756
+ execute: (input: TInput) => unknown | Promise<unknown>;
3529
3757
  }
3530
3758
  /**
3531
3759
  * Register WebMCP tools with the browser so in-page AI agents can invoke your
@@ -3620,6 +3848,24 @@ interface AppRevokeRequestClaims {
3620
3848
  reason: string;
3621
3849
  [claim: string]: unknown;
3622
3850
  }
3851
+ /**
3852
+ * A verified JWT payload: registered claims (RFC 7519) are typed AND
3853
+ * runtime-validated by {@link verifyClientJwt} (a signed token whose `sub` is
3854
+ * a number is rejected, so the types here are real guarantees). Every other
3855
+ * claim is `unknown` — custom claims are attacker-influenced input until you
3856
+ * narrow them (`typeof payload.sid === 'string'`), even after the signature
3857
+ * checks out.
3858
+ */
3859
+ interface VerifiedJwtPayload {
3860
+ iss?: string;
3861
+ sub?: string;
3862
+ aud?: string | string[];
3863
+ exp?: number;
3864
+ nbf?: number;
3865
+ iat?: number;
3866
+ jti?: string;
3867
+ [claim: string]: unknown;
3868
+ }
3623
3869
  /** Options for {@link verifyClientJwt} (all optional; secure defaults). */
3624
3870
  interface VerifyClientJwtOptions {
3625
3871
  /** Allowed clock skew in seconds for `exp`/`nbf`. Default 60. */
@@ -3641,7 +3887,7 @@ interface VerifyClientJwtOptions {
3641
3887
  * and — by default — that an `exp` is present at all. Optionally pins `iss`/`aud`.
3642
3888
  * Throws {@link AppBridgeError} on any failure.
3643
3889
  */
3644
- declare function verifyClientJwt(token: string, clientSecret: string, options?: VerifyClientJwtOptions): Record<string, any>;
3890
+ declare function verifyClientJwt(token: string, clientSecret: string, options?: VerifyClientJwtOptions): VerifiedJwtPayload;
3645
3891
  /** Extract the token from an `Authorization: Bearer <token>` header. */
3646
3892
  declare function extractBearerToken(authorization: string | null | undefined): string | null;
3647
3893
  /**
@@ -3918,6 +4164,28 @@ interface PermissionActions {
3918
4164
  /** Resolve all permissions for a user in a workspace. Returns both platform and app permissions. */
3919
4165
  resolve(workspaceId: string, userId: string): Promise<Set<string>>;
3920
4166
  }
4167
+ /** Manage the signed-in user's devices (login history + per-device sign-out). */
4168
+ interface DeviceActions {
4169
+ /** List the devices the user has signed in from. */
4170
+ list(): Promise<IDeviceView[]>;
4171
+ /** Rename a device's user-facing label. */
4172
+ rename(deviceId: string, name: string): Promise<void>;
4173
+ /** Sign a device out (revoke its live sessions; keep the history row). */
4174
+ signOut(deviceId: string): Promise<{
4175
+ revokedSessions: number;
4176
+ }>;
4177
+ /** Sign a device out AND remove its history row ("forget"). */
4178
+ forget(deviceId: string): Promise<{
4179
+ revokedSessions: number;
4180
+ }>;
4181
+ }
4182
+ /** Manage the signed-in user's active sessions. */
4183
+ interface SessionActions {
4184
+ /** List the user's live sessions (each joined to its device label). */
4185
+ list(): Promise<ISessionView[]>;
4186
+ /** Sign out one session by its public handle (`ISessionView.id`). */
4187
+ revoke(id: string): Promise<void>;
4188
+ }
3921
4189
  interface NotificationActions {
3922
4190
  /**
3923
4191
  * Send a notification to a user or all workspace members.
@@ -3974,6 +4242,8 @@ interface ScopedActions {
3974
4242
  permissions: PermissionActions;
3975
4243
  notification: NotificationActions;
3976
4244
  credits: CreditActions;
4245
+ devices: DeviceActions;
4246
+ sessions: SessionActions;
3977
4247
  }
3978
4248
  interface BuildBaseResult extends ScopedActions {
3979
4249
  /**
@@ -4017,6 +4287,8 @@ interface BuildBaseResult extends ScopedActions {
4017
4287
  user: UserApi;
4018
4288
  settings: SettingsApi;
4019
4289
  push: PushApi;
4290
+ devices: DevicesApi;
4291
+ sessions: SessionsApi;
4020
4292
  };
4021
4293
  };
4022
4294
  }
@@ -4054,13 +4326,20 @@ declare function BuildBase(config: BuildBaseConfig): BuildBaseResult;
4054
4326
  *
4055
4327
  * export const mcp = createMcpHandler({
4056
4328
  * buildbase,
4057
- * serverInfo: { name: 'imejis', version: '1.0.0' },
4329
+ * serverInfo: { name: 'acme', version: '1.0.0' },
4058
4330
  * auth: {
4059
4331
  * verify: (token) => {
4060
4332
  * const c = verifyClientJwt(token, process.env.BUILDBASE_CLIENT_SECRET!);
4061
- * return { sessionId: String(c.sid), userId: String(c.sub), scopes: c.scope };
4333
+ * // Claims beyond RFC 7519 are `unknown` — narrow before use.
4334
+ * return {
4335
+ * sessionId: typeof c.sid === 'string' ? c.sid : '',
4336
+ * userId: c.sub,
4337
+ * scopes: Array.isArray(c.scope)
4338
+ * ? c.scope.filter((s): s is string => typeof s === 'string')
4339
+ * : undefined,
4340
+ * };
4062
4341
  * },
4063
- * resourceMetadataUrl: 'https://imejis.io/.well-known/oauth-protected-resource',
4342
+ * resourceMetadataUrl: 'https://example.com/.well-known/oauth-protected-resource',
4064
4343
  * },
4065
4344
  * });
4066
4345
  *
@@ -4215,5 +4494,5 @@ declare function buildbaseAuth(options: BuildBaseAuthOptions): {
4215
4494
  resourceMetadataUrl?: string;
4216
4495
  };
4217
4496
 
4218
- export { AI_BOT_USER_AGENTS, ApiVersion, AppBridgeError, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditBucketSource, CreditBucketStatus, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UserApi, WorkspaceApi, appTokenFailure, appTokenSuccess, bearerChallenge, buildA2AAgentCard, buildAgentCard, buildAgentSkillsIndex, buildApiCatalog, buildAuthMd, buildDiscoveryLinkHeader, buildDnsAidRecords, buildLlmsFullTxt, buildLlmsTxt, buildMcpDiscoveryManifest, buildMcpServerCard, buildProtectedResourceMetadata, buildRobotsTxt, buildSecurityTxt, buildSitemap, buildSkillMd, buildWebBotAuthDirectory, buildbaseAuth, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAgentReadinessCache, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, createSessionRefCrypto, BuildBase as default, eventEmitter, extractBearerToken, fetchAgentReadiness, formatCents, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, handleAppRevokeRequest, handleAppTokenRequest, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, isZeroDecimalCurrency, minorAmountToDisplay, mintAgentToken, negotiateMarkdown, parseWebhookEvent, provideWebMcpTools, readBBParams, resolveAgentPath, resolveMaxUsers, resolvePermissions, resolveWellKnown, safeRedirect, saveAuthIntent, sha256Digest, signClientJwt, validateInvite, validateRedirectUrl, verifyAppRevokeRequest, verifyAppTokenRequest, verifyClientJwt, verifyWebhookSignature, wantsMarkdown };
4497
+ export { AI_BOT_USER_AGENTS, ApiVersion, AppBridgeError, AuthApi, AuthStatus, BBAction, BBScreen, BBStatus, BB_PARAM, BaseApi, BetaForm, BillingIntervals, BuildBase, CURRENCY_DISPLAY, CURRENCY_FLAG, CreditBucketSource, CreditBucketStatus, CreditTransactionType, DEFAULT_ROLE_PERMISSIONS, DunningState, EventEmitter, InvoiceStatuses, PLAN_CURRENCY_CODES, PLAN_CURRENCY_OPTIONS, PUSH_SERVICE_WORKER_SCRIPT, Permission, PushApi, SDKEvent, SettingsApi, SubscriptionItemType, SubscriptionStatus, UserApi, WorkspaceApi, appTokenFailure, appTokenSuccess, bearerChallenge, buildA2AAgentCard, buildAgentCard, buildAgentSkillsIndex, buildApiCatalog, buildAuthMd, buildDiscoveryLinkHeader, buildDnsAidRecords, buildLlmsFullTxt, buildLlmsTxt, buildMcpDiscoveryManifest, buildMcpServerCard, buildProtectedResourceMetadata, buildRobotsTxt, buildSecurityTxt, buildSitemap, buildSkillMd, buildWebBotAuthDirectory, buildbaseAuth, calculateBillableSeats, calculateSeatOverageCents, calculateTotalSubscriptionCents, cleanBBParams, clearAgentReadinessCache, clearAuthIntent, consumeAuthIntent, createBBUrl, createCheckoutRedirectUrls, createCreditPurchaseRedirectUrls, createSessionRefCrypto, BuildBase as default, eventEmitter, extractBearerToken, fetchAgentReadiness, formatCents, formatMinorAmountIntl, formatOverageRate, formatOverageRateWithLabel, formatQuotaIncludedOverage, formatQuotaWithPrice, getAvailableCurrenciesFromPlans, getBasePriceCents, getBillingIntervalAndCurrencyFromPriceId, getCurrencyDecimals, getCurrencyFlag, getCurrencySymbol, getDisplayCurrency, getPerSeatPriceCents, getPricingVariant, getQuotaDisplayValue, getQuotaDisplayWithVariant, getQuotaOverageCents, getQuotaUnitLabelFromName, getSeatPricing, getStripePriceIdForInterval, handleAppRevokeRequest, handleAppTokenRequest, hasPermission, invalidateCreditBalance, invalidateQuotaUsage, invalidateSubscription, isZeroDecimalCurrency, minorAmountToDisplay, mintAgentToken, negotiateMarkdown, parseWebhookEvent, provideWebMcpTools, readBBParams, resolveAgentPath, resolveMaxUsers, resolvePermissions, resolveWellKnown, safeRedirect, saveAuthIntent, sha256Digest, signClientJwt, validateInvite, validateRedirectUrl, verifyAppRevokeRequest, verifyAppTokenRequest, verifyClientJwt, verifyWebhookSignature, wantsMarkdown };
4219
4498
  export type { A2ACardConfig, A2ACardSkill, AgentReadinessBundle, AgentReadyConfig, AgentSkill, ApiCatalogApi, AppRevokeRequestClaims, AppScope, AppTokenRequestClaims, AppTokenResponseBody, AppTokenResult, BBActionType, BBScreenType, BBStatusType, BetaFormData, BetaFormResponse, BillingInterval, BuildBaseAuthOptions, BuildBaseConfig, BuildBaseResult, BuildBaseSession, CheckoutResult, ContentSignals, CreditActions, CreditBucketSourceType, CreditBucketStatusType, CreditTransactionTypeValue, DiscoveryDocument, DnsAidRecord, DunningStateType, EventData, EventType, FeatureActions, FormatQuotaWithPriceOptions, GetCheckoutStripeParams, HandlerResult, IAllQuotaUsageResponse, IBaseApiConfig, IBasePricing, IBetaConfig, ICheckoutSessionRequest, ICheckoutSessionResponse, ICheckoutStripeOptions, IConsumeCreditsRequest, IConsumeCreditsResponse, ICreditBalance, ICreditBucket, ICreditBucketsQuery, ICreditBucketsResponse, ICreditPackage, ICreditPackagePricingVariant, ICreditPurchaseRequest, ICreditPurchaseResponse, ICreditTransaction, ICreditTransactionsQuery, ICreditTransactionsResponse, IEventCallbacks, IExpiringCreditsResponse, IInvoice, IInvoiceListResponse, IInvoiceResponse, IOsConfig, IOsState, IPlan, IPlanGroup, IPlanGroupInfo, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionWithPlans, IPlanGroupVersionsResponse, IPlanVersion, IPlanVersionSummary, IPlanVersionWithPlan, IPricingVariant, IPublicCreditPackage, IPublicCreditPackagesResponse, IPublicPlanItem, IPublicPlanItemCategory, IPublicPlanVersion, IPublicPlansResponse, IQuotaByInterval, IQuotaIntervalValue, IQuotaOveragePriceIdsByInterval, IQuotaOveragesByInterval, IQuotaUsageStatus, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, ISettings, IStripePricesByInterval, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogEntry, IUsageLogsQuery, IUsageLogsResponse, IUser, IWorkspace, InviteBlockReason, InviteValidation, InvoiceActions, InvoiceStatus, InvoiceStatusType, MaxUsersConfig, McpServerCard, MintAgentTokenOptions, NotificationData, NotificationEvent, NotificationResult, OnWorkspaceChangeParams, PermissionActions, PermissionContext, PermissionKey, PlanActions, PlanVersionWithPricingVariants, QuotaDisplayValue, QuotaDisplayWithOverage, RedirectValidationOptions, RobotsConfig, RobotsPolicy, RolePermissionMap, ScopedActions, SessionRefCrypto, SettingsActions, SitemapUrl, SubscriptionActions, SubscriptionItemTypeValue, SubscriptionStatusType, TranslationKey, UsageActions, UserActions, UserCreatedEventData, UserUpdatedEventData, WebMcpTool, WorkspaceActions, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };