@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
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
 
3
3
  /** An Agent Skill (Agent Skills Discovery RFC v0.2.0) published by this app. */
4
4
  interface AgentSkill {
5
- /** Stable slug, e.g. `imejis-api`. */
5
+ /** Stable slug, e.g. `acme-api`. */
6
6
  name: string;
7
7
  /** One-line human/agent-readable summary. */
8
8
  description: string;
@@ -18,7 +18,7 @@ interface AgentSkill {
18
18
  }
19
19
  /** One API described in an API Catalog (RFC 9727 / RFC 9264 linkset). */
20
20
  interface ApiCatalogApi {
21
- /** Anchor URL identifying the API, e.g. `https://api.imejis.io`. */
21
+ /** Anchor URL identifying the API, e.g. `https://api.example.com`. */
22
22
  anchor: string;
23
23
  /** OpenAPI / machine-readable description URL (link rel `service-desc`). */
24
24
  serviceDesc?: string;
@@ -39,7 +39,7 @@ interface McpServerCard {
39
39
  endpoint: string;
40
40
  /** Transport type. Defaults to `"streamable-http"`. */
41
41
  transport?: string;
42
- /** MCP protocol version the server speaks. Defaults to `"2025-06-18"`. */
42
+ /** MCP protocol version the server speaks. Defaults to `"2025-11-25"`. */
43
43
  protocolVersion?: string;
44
44
  /**
45
45
  * Capability flags. Booleans per SEP-1649 v1.0; a legacy object value
@@ -143,7 +143,7 @@ interface AgentReadyConfig {
143
143
  /** The org id (24-hex) whose agent-readiness config to serve. */
144
144
  orgId: string;
145
145
  /**
146
- * This app's public origin, e.g. `https://imejis.io`. Used to build absolute
146
+ * This app's public origin, e.g. `https://example.com`. Used to build absolute
147
147
  * URLs in the Agent Card and to match RFC 9728 resource paths.
148
148
  */
149
149
  siteUrl: string;
@@ -307,14 +307,14 @@ interface DiscoveryDocument {
307
307
  */
308
308
 
309
309
  /** Every built-in tool, keyed by name. */
310
- declare const builtinMcpTools: ReadonlyMap<string, McpToolDefinition<any>>;
310
+ declare const builtinMcpTools: ReadonlyMap<string, AnyMcpTool>;
311
311
  /** The name of a built-in BuildBase MCP tool. */
312
312
  type BuiltinMcpToolName = 'list_workspaces' | 'get_workspace' | 'get_user_profile' | 'list_workspace_users' | 'get_subscription' | 'get_plans' | 'get_plan_versions' | 'get_public_plans' | 'get_plan_version' | 'list_invoices' | 'get_invoice' | 'get_quota_usage' | 'get_all_quota_usage' | 'get_usage_logs' | 'get_credit_balance' | 'list_credit_transactions' | 'get_credit_packages' | 'get_credit_buckets' | 'get_expiring_credits' | 'get_public_credit_packages' | 'check_feature_flag' | 'check_permission' | 'resolve_permissions' | 'get_settings' | 'record_usage' | 'record_usage_batch' | 'consume_credits' | 'send_notification' | 'create_workspace' | 'update_workspace' | 'delete_workspace' | 'invite_workspace_user' | 'remove_workspace_user' | 'update_workspace_user_role' | 'update_user_profile' | 'update_feature_flag' | 'create_subscription_checkout' | 'update_subscription' | 'cancel_subscription' | 'resume_subscription' | 'get_billing_portal_url' | 'purchase_credits';
313
313
  /** Resolve a `builtinTools` config value to the tools it selects. */
314
314
  declare function selectBuiltinTools(selection: 'all' | 'readonly' | false | {
315
315
  include?: BuiltinMcpToolName[];
316
316
  exclude?: BuiltinMcpToolName[];
317
- }): McpToolDefinition<any>[];
317
+ }): AnyMcpTool[];
318
318
 
319
319
  interface IDocument {
320
320
  _id: string;
@@ -1088,7 +1088,7 @@ interface ISettings {
1088
1088
  /** Auto-create workspace on first login */
1089
1089
  autoCreateFirst: boolean;
1090
1090
  };
1091
- [key: string]: any;
1091
+ [key: string]: unknown;
1092
1092
  }
1093
1093
 
1094
1094
  /** Data passed to a notification template for merge tag replacement. */
@@ -1147,7 +1147,7 @@ interface NotificationData {
1147
1147
  push?: boolean;
1148
1148
  };
1149
1149
  /** Any additional merge tags available as {{key}} in the email template. */
1150
- [key: string]: any;
1150
+ [key: string]: unknown;
1151
1151
  }
1152
1152
  /** Result of sending a notification. */
1153
1153
  interface NotificationResult {
@@ -1163,6 +1163,88 @@ interface NotificationResult {
1163
1163
  reason?: string;
1164
1164
  }
1165
1165
 
1166
+ /**
1167
+ * API client for the signed-in user's devices — the browsers/apps they have
1168
+ * signed in from. Session-authed (x-session-id + x-device-id), scoped to the
1169
+ * current user. Extends BaseApi for shared URL/auth/request handling.
1170
+ *
1171
+ * A device row is login history. Signing a device out revokes its live sessions
1172
+ * but keeps the row (shown as signed-out); "forget" also removes the row.
1173
+ */
1174
+
1175
+ /** Coarse geo/network info resolved from the request IP (a lightweight subset). */
1176
+ interface IIpInfoLite {
1177
+ ip?: string;
1178
+ hostname?: string;
1179
+ country?: string;
1180
+ city?: string;
1181
+ region?: string;
1182
+ /** "lat,long" string, as provided by the IP lookup. */
1183
+ loc?: string;
1184
+ timezone?: string;
1185
+ }
1186
+ /** A device the current user has signed in from. */
1187
+ interface IDeviceView {
1188
+ /** Stable per-browser/app identifier (the `x-device-id` the client sends). */
1189
+ deviceId: string;
1190
+ /** User-editable label (falls back to a derived name). */
1191
+ name: string;
1192
+ /** IP the device was last seen from. */
1193
+ ip: string;
1194
+ /** Resolved geo/network info for `ip`, when available. */
1195
+ ipInfo: IIpInfoLite | null;
1196
+ userAgent: string;
1197
+ origin: string;
1198
+ /** Whether the user marked this device trusted (longer sessions, fewer prompts). */
1199
+ trusted: boolean;
1200
+ /** ISO string — first time this device was seen. */
1201
+ firstSeenAt?: string;
1202
+ /** ISO string — most recent activity from this device. */
1203
+ lastActiveAt?: string;
1204
+ /** True when this is the device the request came from. */
1205
+ current: boolean;
1206
+ /** Number of live sessions currently on this device. */
1207
+ activeSessions: number;
1208
+ /** Whether this device has an active push-notification subscription. */
1209
+ pushEnabled: boolean;
1210
+ }
1211
+
1212
+ /**
1213
+ * API client for the signed-in user's active sessions. Session-authed
1214
+ * (x-session-id), scoped to the current user. Extends BaseApi for shared
1215
+ * URL/auth/request handling.
1216
+ *
1217
+ * The raw session id is never exposed — a session's public handle is its
1218
+ * mirror-row id (`ISessionView.id`), which is what `revoke` takes.
1219
+ * "Sign out everywhere" / "sign out current" stay on the auth logout flow.
1220
+ */
1221
+
1222
+ /** One live session of the current user, joined to its device's label. */
1223
+ interface ISessionView {
1224
+ /** Public handle (mirror-row id) — NOT the raw session id. Use for `revoke`. */
1225
+ id: string;
1226
+ /** The device this session was born on. */
1227
+ deviceId: string;
1228
+ /** OAuth client id, or 'first-party' for a normal app sign-in. */
1229
+ clientId: string;
1230
+ ip: string;
1231
+ ipInfo: IIpInfoLite | null;
1232
+ userAgent: string;
1233
+ origin: string;
1234
+ /** ISO string. */
1235
+ createdAt?: string;
1236
+ /** ISO string. */
1237
+ lastActiveAt?: string;
1238
+ /** ISO string — when the session expires (reflects the org session policy). */
1239
+ expiresAt?: string;
1240
+ /** True when this is the session making the request. */
1241
+ current: boolean;
1242
+ /** The device's label only; ip/userAgent/etc. live on the session itself. */
1243
+ device: {
1244
+ name: string;
1245
+ } | null;
1246
+ }
1247
+
1166
1248
  interface WorkspaceActions {
1167
1249
  list(): Promise<IWorkspace[]>;
1168
1250
  get(workspaceId: string): Promise<IWorkspace>;
@@ -1259,6 +1341,28 @@ interface PermissionActions {
1259
1341
  /** Resolve all permissions for a user in a workspace. Returns both platform and app permissions. */
1260
1342
  resolve(workspaceId: string, userId: string): Promise<Set<string>>;
1261
1343
  }
1344
+ /** Manage the signed-in user's devices (login history + per-device sign-out). */
1345
+ interface DeviceActions {
1346
+ /** List the devices the user has signed in from. */
1347
+ list(): Promise<IDeviceView[]>;
1348
+ /** Rename a device's user-facing label. */
1349
+ rename(deviceId: string, name: string): Promise<void>;
1350
+ /** Sign a device out (revoke its live sessions; keep the history row). */
1351
+ signOut(deviceId: string): Promise<{
1352
+ revokedSessions: number;
1353
+ }>;
1354
+ /** Sign a device out AND remove its history row ("forget"). */
1355
+ forget(deviceId: string): Promise<{
1356
+ revokedSessions: number;
1357
+ }>;
1358
+ }
1359
+ /** Manage the signed-in user's active sessions. */
1360
+ interface SessionActions {
1361
+ /** List the user's live sessions (each joined to its device label). */
1362
+ list(): Promise<ISessionView[]>;
1363
+ /** Sign out one session by its public handle (`ISessionView.id`). */
1364
+ revoke(id: string): Promise<void>;
1365
+ }
1262
1366
  interface NotificationActions {
1263
1367
  /**
1264
1368
  * Send a notification to a user or all workspace members.
@@ -1315,6 +1419,8 @@ interface ScopedActions {
1315
1419
  permissions: PermissionActions;
1316
1420
  notification: NotificationActions;
1317
1421
  credits: CreditActions;
1422
+ devices: DeviceActions;
1423
+ sessions: SessionActions;
1318
1424
  }
1319
1425
 
1320
1426
  /**
@@ -1349,13 +1455,20 @@ interface ScopedActions {
1349
1455
  *
1350
1456
  * export const mcp = createMcpHandler({
1351
1457
  * buildbase,
1352
- * serverInfo: { name: 'imejis', version: '1.0.0' },
1458
+ * serverInfo: { name: 'acme', version: '1.0.0' },
1353
1459
  * auth: {
1354
1460
  * verify: (token) => {
1355
1461
  * const c = verifyClientJwt(token, process.env.BUILDBASE_CLIENT_SECRET!);
1356
- * return { sessionId: String(c.sid), userId: String(c.sub), scopes: c.scope };
1462
+ * // Claims beyond RFC 7519 are `unknown` — narrow before use.
1463
+ * return {
1464
+ * sessionId: typeof c.sid === 'string' ? c.sid : '',
1465
+ * userId: c.sub,
1466
+ * scopes: Array.isArray(c.scope)
1467
+ * ? c.scope.filter((s): s is string => typeof s === 'string')
1468
+ * : undefined,
1469
+ * };
1357
1470
  * },
1358
- * resourceMetadataUrl: 'https://imejis.io/.well-known/oauth-protected-resource',
1471
+ * resourceMetadataUrl: 'https://example.com/.well-known/oauth-protected-resource',
1359
1472
  * },
1360
1473
  * });
1361
1474
  *
@@ -1422,6 +1535,14 @@ interface McpToolContext<TCustom = unknown> {
1422
1535
  */
1423
1536
  custom: TCustom;
1424
1537
  }
1538
+ /** An icon for display in host UIs (SEP-973, protocol 2025-11-25). */
1539
+ interface McpIcon {
1540
+ /** Icon URL (https or data URI). */
1541
+ src: string;
1542
+ mimeType?: string;
1543
+ /** e.g. `['48x48']` or `['any']` for scalable formats. */
1544
+ sizes?: string[];
1545
+ }
1425
1546
  /** MCP tool annotations (behavior hints for agents). */
1426
1547
  interface McpToolAnnotations {
1427
1548
  title?: string;
@@ -1430,6 +1551,70 @@ interface McpToolAnnotations {
1430
1551
  idempotentHint?: boolean;
1431
1552
  openWorldHint?: boolean;
1432
1553
  }
1554
+ /** Plain text block. */
1555
+ interface McpTextContent {
1556
+ type: 'text';
1557
+ text: string;
1558
+ }
1559
+ /** Base64-encoded image (`data` has no data-URI prefix). */
1560
+ interface McpImageContent {
1561
+ type: 'image';
1562
+ data: string;
1563
+ mimeType: string;
1564
+ }
1565
+ /** Base64-encoded audio (`data` has no data-URI prefix). */
1566
+ interface McpAudioContent {
1567
+ type: 'audio';
1568
+ data: string;
1569
+ mimeType: string;
1570
+ }
1571
+ /** Link to a resource the client may fetch — the content itself is not embedded. */
1572
+ interface McpResourceLinkContent {
1573
+ type: 'resource_link';
1574
+ uri: string;
1575
+ name: string;
1576
+ title?: string;
1577
+ description?: string;
1578
+ mimeType?: string;
1579
+ size?: number;
1580
+ }
1581
+ /** Resource contents embedded directly in the result (text or base64 blob). */
1582
+ interface McpEmbeddedResourceContent {
1583
+ type: 'resource';
1584
+ resource: {
1585
+ uri: string;
1586
+ mimeType?: string;
1587
+ title?: string;
1588
+ } & ({
1589
+ text: string;
1590
+ } | {
1591
+ blob: string;
1592
+ });
1593
+ }
1594
+ /** Any content block a tool result may carry. */
1595
+ type McpContentBlock = McpTextContent | McpImageContent | McpAudioContent | McpResourceLinkContent | McpEmbeddedResourceContent;
1596
+ /**
1597
+ * Full wire-shaped tool result. Return this from `execute` to control the
1598
+ * result exactly — mixed content blocks (text + images + resource links),
1599
+ * `structuredContent`, and the `isError` flag. Any other return value keeps
1600
+ * the legacy behavior: strings become one text block, objects become
1601
+ * JSON text + `structuredContent`.
1602
+ */
1603
+ interface McpToolResult {
1604
+ content: McpContentBlock[];
1605
+ structuredContent?: Record<string, unknown>;
1606
+ isError?: boolean;
1607
+ }
1608
+ /** Text content block (`mcpText('done')`). */
1609
+ declare const mcpText: (text: string) => McpTextContent;
1610
+ /** Image content block from base64 data (`mcpImage(pngBase64, 'image/png')`). */
1611
+ declare const mcpImage: (data: string, mimeType: string) => McpImageContent;
1612
+ /** Audio content block from base64 data (`mcpAudio(wavBase64, 'audio/wav')`). */
1613
+ declare const mcpAudio: (data: string, mimeType: string) => McpAudioContent;
1614
+ /** Resource-link content block (`mcpResourceLink('https://…/report.pdf', 'report')`). */
1615
+ declare const mcpResourceLink: (uri: string, name: string, extra?: Omit<McpResourceLinkContent, "type" | "uri" | "name">) => McpResourceLinkContent;
1616
+ /** Embedded-resource content block (`mcpEmbeddedResource({ uri, text })`). */
1617
+ declare const mcpEmbeddedResource: (resource: McpEmbeddedResourceContent["resource"]) => McpEmbeddedResourceContent;
1433
1618
  /** A tool exposed over MCP. Use {@link defineMcpTool} for inferred input types. */
1434
1619
  interface McpToolDefinition<S extends z.ZodType = z.ZodType, TCustom = any> {
1435
1620
  /** Tool name: `[a-zA-Z0-9_-]`, 1–128 chars. */
@@ -1441,6 +1626,8 @@ interface McpToolDefinition<S extends z.ZodType = z.ZodType, TCustom = any> {
1441
1626
  */
1442
1627
  inputSchema: S | Record<string, unknown>;
1443
1628
  annotations?: McpToolAnnotations;
1629
+ /** Optional icons for host UIs (protocol 2025-11-25). */
1630
+ icons?: McpIcon[];
1444
1631
  /**
1445
1632
  * Scopes required to see/call this tool. The token must carry ALL of them
1446
1633
  * (`McpAuthInfo.scopes`) for the tool to be visible or callable; a token
@@ -1448,8 +1635,98 @@ interface McpToolDefinition<S extends z.ZodType = z.ZodType, TCustom = any> {
1448
1635
  * no scopes and are governed by `builtinTools` + the user's own permissions.
1449
1636
  */
1450
1637
  requiredScopes?: string[];
1638
+ /**
1639
+ * Runs the tool. Return an {@link McpToolResult} for full control over the
1640
+ * wire result (images, resource links, mixed blocks); any other value is
1641
+ * auto-wrapped (string → text block; object → JSON text + structuredContent).
1642
+ */
1451
1643
  execute: (input: z.output<S>, ctx: McpToolContext<TCustom>) => unknown | Promise<unknown>;
1452
1644
  }
1645
+ /**
1646
+ * Existential tool type for heterogeneous lists (registries, config arrays).
1647
+ * Each tool keeps its precise schema/context types at its definition site
1648
+ * (use {@link defineMcpTool}); `any` here only erases them for storage —
1649
+ * never use it to define a tool.
1650
+ */
1651
+ type AnyMcpTool = McpToolDefinition<any, any>;
1652
+ /**
1653
+ * What a resource `read` may return. Strings become text contents, plain
1654
+ * objects become pretty-printed JSON (`application/json`), and an explicit
1655
+ * `{ text }` or `{ blob }` shape is used as-is (blob = base64).
1656
+ */
1657
+ type McpResourceReadResult = string | {
1658
+ text: string;
1659
+ mimeType?: string;
1660
+ } | {
1661
+ blob: string;
1662
+ mimeType?: string;
1663
+ } | object;
1664
+ /** A fixed-URI resource served via `resources/list` + `resources/read`. */
1665
+ interface McpResourceDefinition<TCustom = any> {
1666
+ /** Unique resource URI (custom schemes welcome, e.g. `app://orders`). */
1667
+ uri: string;
1668
+ name: string;
1669
+ title?: string;
1670
+ description?: string;
1671
+ mimeType?: string;
1672
+ icons?: McpIcon[];
1673
+ /** Same gating semantics as tools: token must carry ALL listed scopes. */
1674
+ requiredScopes?: string[];
1675
+ read: (ctx: McpToolContext<TCustom>) => McpResourceReadResult | Promise<McpResourceReadResult>;
1676
+ }
1677
+ /**
1678
+ * A parameterized resource (RFC 6570 level-1 `{var}` templates only), served
1679
+ * via `resources/templates/list` and matched on `resources/read`.
1680
+ */
1681
+ interface McpResourceTemplateDefinition<TCustom = any> {
1682
+ /** e.g. `buildbase://workspace/{workspaceId}` — `{var}` matches one segment. */
1683
+ uriTemplate: string;
1684
+ name: string;
1685
+ title?: string;
1686
+ description?: string;
1687
+ mimeType?: string;
1688
+ icons?: McpIcon[];
1689
+ requiredScopes?: string[];
1690
+ read: (params: Record<string, string>, uri: string, ctx: McpToolContext<TCustom>) => McpResourceReadResult | Promise<McpResourceReadResult>;
1691
+ }
1692
+ /** Message content allowed in prompts (spec: text, image, audio, embedded resource). */
1693
+ type McpPromptContent = McpTextContent | McpImageContent | McpAudioContent | McpEmbeddedResourceContent;
1694
+ /** One message of a prompt template. */
1695
+ interface McpPromptMessage {
1696
+ role: 'user' | 'assistant';
1697
+ content: McpPromptContent;
1698
+ }
1699
+ /** A prompt template served via `prompts/list` + `prompts/get`. */
1700
+ interface McpPromptDefinition<TCustom = any> {
1701
+ /** Unique prompt name (same charset rules as tool names). */
1702
+ name: string;
1703
+ title?: string;
1704
+ description?: string;
1705
+ icons?: McpIcon[];
1706
+ arguments?: Array<{
1707
+ name: string;
1708
+ description?: string;
1709
+ required?: boolean;
1710
+ }>;
1711
+ requiredScopes?: string[];
1712
+ /**
1713
+ * Build the messages. A plain string return becomes one user text message;
1714
+ * an array is used as the messages; the object form also sets `description`.
1715
+ */
1716
+ get: (args: Record<string, string>, ctx: McpToolContext<TCustom>) => string | McpPromptMessage[] | {
1717
+ description?: string;
1718
+ messages: McpPromptMessage[];
1719
+ } | Promise<string | McpPromptMessage[] | {
1720
+ description?: string;
1721
+ messages: McpPromptMessage[];
1722
+ }>;
1723
+ }
1724
+ /** Identity helper for inferred types (mirror of {@link defineMcpTool}). */
1725
+ declare const defineMcpResource: <TCustom = any>(resource: McpResourceDefinition<TCustom>) => McpResourceDefinition<TCustom>;
1726
+ /** Identity helper for inferred types (mirror of {@link defineMcpTool}). */
1727
+ declare const defineMcpResourceTemplate: <TCustom = any>(template: McpResourceTemplateDefinition<TCustom>) => McpResourceTemplateDefinition<TCustom>;
1728
+ /** Identity helper for inferred types (mirror of {@link defineMcpTool}). */
1729
+ declare const defineMcpPrompt: <TCustom = any>(prompt: McpPromptDefinition<TCustom>) => McpPromptDefinition<TCustom>;
1453
1730
  /** Configuration for {@link createMcpHandler}. */
1454
1731
  interface CreateMcpHandlerConfig {
1455
1732
  /**
@@ -1486,7 +1763,28 @@ interface CreateMcpHandlerConfig {
1486
1763
  * built-in (your definition wins); duplicate custom names or invalid names
1487
1764
  * throw at create time.
1488
1765
  */
1489
- tools?: McpToolDefinition<any, any>[];
1766
+ tools?: AnyMcpTool[];
1767
+ /**
1768
+ * App-defined resources (`resources/list` + `resources/read`). The
1769
+ * `resources` capability is advertised only when at least one resource,
1770
+ * template, or `builtinResources` is configured.
1771
+ */
1772
+ resources?: McpResourceDefinition[];
1773
+ /** App-defined parameterized resources (`resources/templates/list`). */
1774
+ resourceTemplates?: McpResourceTemplateDefinition[];
1775
+ /**
1776
+ * Built-in BuildBase context resources (opt-in; requires `buildbase`):
1777
+ * `buildbase://profile`, `buildbase://workspaces`, and the
1778
+ * `buildbase://workspace/{workspaceId}` template — read-only context a host
1779
+ * can load without spending tool calls. Richer data (subscription, usage,
1780
+ * credits) stays tools-only.
1781
+ */
1782
+ builtinResources?: boolean;
1783
+ /**
1784
+ * App-defined prompt templates (`prompts/list` + `prompts/get`). The
1785
+ * `prompts` capability is advertised only when at least one is configured.
1786
+ */
1787
+ prompts?: McpPromptDefinition[];
1490
1788
  /**
1491
1789
  * Which built-in BuildBase tools to expose. **Defaults to `'readonly'`**
1492
1790
  * when a `buildbase` client is configured (`false` otherwise) — reads only,
@@ -1661,6 +1959,24 @@ interface AppTokenRequestClaims {
1661
1959
  sessionId?: string;
1662
1960
  [claim: string]: unknown;
1663
1961
  }
1962
+ /**
1963
+ * A verified JWT payload: registered claims (RFC 7519) are typed AND
1964
+ * runtime-validated by {@link verifyClientJwt} (a signed token whose `sub` is
1965
+ * a number is rejected, so the types here are real guarantees). Every other
1966
+ * claim is `unknown` — custom claims are attacker-influenced input until you
1967
+ * narrow them (`typeof payload.sid === 'string'`), even after the signature
1968
+ * checks out.
1969
+ */
1970
+ interface VerifiedJwtPayload {
1971
+ iss?: string;
1972
+ sub?: string;
1973
+ aud?: string | string[];
1974
+ exp?: number;
1975
+ nbf?: number;
1976
+ iat?: number;
1977
+ jti?: string;
1978
+ [claim: string]: unknown;
1979
+ }
1664
1980
  /** Options for {@link verifyClientJwt} (all optional; secure defaults). */
1665
1981
  interface VerifyClientJwtOptions {
1666
1982
  /** Allowed clock skew in seconds for `exp`/`nbf`. Default 60. */
@@ -1682,7 +1998,7 @@ interface VerifyClientJwtOptions {
1682
1998
  * and — by default — that an `exp` is present at all. Optionally pins `iss`/`aud`.
1683
1999
  * Throws {@link AppBridgeError} on any failure.
1684
2000
  */
1685
- declare function verifyClientJwt(token: string, clientSecret: string, options?: VerifyClientJwtOptions): Record<string, any>;
2001
+ declare function verifyClientJwt(token: string, clientSecret: string, options?: VerifyClientJwtOptions): VerifiedJwtPayload;
1686
2002
  /** Extract the token from an `Authorization: Bearer <token>` header. */
1687
2003
  declare function extractBearerToken(authorization: string | null | undefined): string | null;
1688
2004
  /**
@@ -1782,7 +2098,7 @@ interface AgentStackConfig {
1782
2098
  version: string;
1783
2099
  };
1784
2100
  /** Your custom tools. */
1785
- tools?: McpToolDefinition<any, any>[];
2101
+ tools?: AnyMcpTool[];
1786
2102
  /** Built-in tool selection. Default `'readonly'`. */
1787
2103
  builtinTools?: CreateMcpHandlerConfig['builtinTools'];
1788
2104
  /** Scopes advertised on the protected-resource metadata. */
@@ -1952,5 +2268,5 @@ declare function buildbaseAuth(options: BuildBaseAuthOptions): {
1952
2268
  resourceMetadataUrl?: string;
1953
2269
  };
1954
2270
 
1955
- export { AppBridgeError, bearerChallenge, buildbaseAuth, builtinMcpTools, createAgentStack, createMcpHandler, createSessionRefCrypto, defineMcpTool, extractBearerToken, mintAgentToken, selectBuiltinTools, signClientJwt, verifyClientJwt };
1956
- export type { AgentStack, AgentStackConfig, BuildBaseAuthOptions, BuiltinMcpToolName, CreateMcpHandlerConfig, McpAuthInfo, McpBuildBaseClient, McpHandler, McpHttpRequest, McpHttpResponse, McpServerCard, McpToolAnnotations, McpToolContext, McpToolDefinition, MintAgentTokenOptions, ScopedActions, SessionRefCrypto };
2271
+ export { AppBridgeError, bearerChallenge, buildbaseAuth, builtinMcpTools, createAgentStack, createMcpHandler, createSessionRefCrypto, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineMcpTool, extractBearerToken, mcpAudio, mcpEmbeddedResource, mcpImage, mcpResourceLink, mcpText, mintAgentToken, selectBuiltinTools, signClientJwt, verifyClientJwt };
2272
+ export type { AgentStack, AgentStackConfig, AnyMcpTool, BuildBaseAuthOptions, BuiltinMcpToolName, CreateMcpHandlerConfig, McpAudioContent, McpAuthInfo, McpBuildBaseClient, McpContentBlock, McpEmbeddedResourceContent, McpHandler, McpHttpRequest, McpHttpResponse, McpIcon, McpImageContent, McpPromptContent, McpPromptDefinition, McpPromptMessage, McpResourceDefinition, McpResourceLinkContent, McpResourceReadResult, McpResourceTemplateDefinition, McpServerCard, McpTextContent, McpToolAnnotations, McpToolContext, McpToolDefinition, McpToolResult, MintAgentTokenOptions, ScopedActions, SessionRefCrypto, VerifiedJwtPayload };