@astralbeam/sdk 0.9.0 → 0.11.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @astralbeam/sdk
2
2
 
3
- A drop-in agent chat sidebar for your web app, from [AstralBeam](https://astralbeam.ai), with a headless core underneath when you want to own the UI. The widget renders in a shadow root so its styles never mix with yours, and it streams from an AstralBeam chat endpoint.
3
+ Embed an agent chat sidebar or read-only tenant directories in your web app, or build your own chat UI with the headless core. The widgets isolate their styles in shadow roots.
4
4
 
5
5
  ```sh
6
6
  npm install @astralbeam/sdk
@@ -22,75 +22,76 @@ export function Sidebar() {
22
22
  import { mountAstralBeamChat } from "@astralbeam/sdk/client"
23
23
 
24
24
  const handle = mountAstralBeamChat(document.getElementById("sidebar"), {})
25
- // handle.update({ colorScheme: "dark" }) — handle.unmount()
25
+ // Update with handle.update({ colorScheme: "dark" }), then clean up with handle.unmount().
26
26
  ```
27
27
 
28
28
  - The widget fills its container, so give it a parent with a definite height (`min-h-0` in a flex column).
29
- - Two origins by design: chat streams to the hosted cloud by default, while the token comes from your own app's endpoint. Self-hosted deployments set `apiUrl` to their own origin.
30
- - `@astralbeam/sdk/client` ships no React; the chat loads as a lazy chunk with its own bundled copy.
31
- - No runtime dependencies; `react` and `react-dom` are optional peers used only by `@astralbeam/sdk/react`.
29
+ - Chat uses the hosted cloud by default. Tokens come from your application. For self-hosting, set `apiUrl` to your deployment’s `/api` base.
30
+ - `@astralbeam/sdk/client` ships no React. The chat loads as a lazy chunk with its own bundled copy.
31
+ - No runtime dependencies. `react` and `react-dom` are optional peers used only by `@astralbeam/sdk/react`.
32
32
  - Mount it above your router if the transcript should survive page navigation.
33
33
 
34
34
  ## Authentication
35
35
 
36
- The widget will not chat until your app mints it a short-lived chat auth token; it never sees your API key. That token is the credential your server signs for AstralBeam, never your app's own session cookie or access token. See [Authentication](https://app.astralbeam.ai/docs/sdk/authentication).
36
+ Your server must authenticate the host session and mint a chat token before the widget can chat. Keep the API key server-only. See [Authentication](https://app.astralbeam.ai/docs/sdk/authentication).
37
37
 
38
38
  ```ts
39
39
  import { createAstralBeamToken } from "@astralbeam/sdk/server"
40
40
 
41
- const apiKey = process.env.ASTRALBEAM_API_KEY // key_<organization>_<key>_abo_<secret>
41
+ const apiKey = process.env.ASTRALBEAM_API_KEY // key_<organizationId>_<id>_abo_<secret>
42
42
 
43
43
  export async function POST(request: Request) {
44
- if (!apiKey) return Response.json({ error: "Not configured" }, { status: 503 })
44
+ const headers = { "Cache-Control": "no-store" }
45
+ if (!apiKey) return Response.json({ error: "Not configured" }, { status: 503, headers })
45
46
  const session = await getApplicationSession(request)
46
- if (!session) return Response.json({ error: "Unauthenticated" }, { status: 401 })
47
- const token = await createAstralBeamToken({
48
- apiKey,
49
- user: {
50
- id: session.user.id,
51
- name: session.user.name,
52
- metadata: { email: session.user.email },
53
- },
54
- tenant: {
55
- id: session.tenant.id,
56
- name: session.tenant.name,
57
- metadata: { plan: session.tenant.plan },
58
- },
59
- })
60
- return Response.json({ token }, { headers: { "cache-control": "no-store" } })
47
+ if (!session) return Response.json({ error: "Unauthenticated" }, { status: 401, headers })
48
+ try {
49
+ const token = await createAstralBeamToken({
50
+ apiKey,
51
+ user: {
52
+ id: session.user.id,
53
+ name: session.user.name,
54
+ metadata: { email: session.user.email },
55
+ },
56
+ tenant: {
57
+ id: session.tenant.id,
58
+ name: session.tenant.name,
59
+ metadata: { plan: session.tenant.plan },
60
+ },
61
+ })
62
+ return Response.json({ token }, { headers })
63
+ } catch {
64
+ return Response.json({ error: "Token could not be issued" }, { status: 500, headers })
65
+ }
61
66
  }
62
67
  ```
63
68
 
64
- - Add one endpoint, `/api/astralbeam/token` by default, that authenticates your own session first.
65
- - Your handler owns the response: answer `cache-control: no-store`, and fail closed with a 401 or 503.
66
- - Authenticate once, then derive `user` and `tenant` separately from that same application session.
67
- - Derive `user` and `tenant` from trusted server-side state, never from anything the browser sent.
68
- - Provide stable tenant-local `user.id` and stable `tenant.id` values; names are optional, and set `user.admin` only from trusted state.
69
- - Put custom tenant and tenant-user fields in their respective `metadata` JSON objects; never include secrets.
70
- - SDK fields use camelCase; AstralBeam-owned JWT claims use snake_case, while `metadata` keys are preserved verbatim.
71
- - Tokens use the API key's organization slug as issuer and the platform audience `astralbeam`; AstralBeam does not require or interpret `sub`.
72
- - Tokens are signed, not encrypted: never put a secret in them.
73
- - Lifetimes are 60–600 seconds; the SDK renews in memory before expiry.
74
- - `fetchAstralBeamToken` says where the chat auth token comes from: `{ url, ...init }`, which the widget calls as `fetch(url, init)` with a standard `RequestInit`, or a function returning `{ token }` (or a promise of it, or `undefined` when it cannot mint one).
75
- - It defaults to `{ url: "/api/astralbeam/token" }`, posted with the page's cookies, and runs again on every renewal, so a rotating credential stays current.
69
+ - Authenticate once and derive stable `user.id` and `tenant.id` values from that trusted session.
70
+ - Keep API keys server-only. Tokens are signed, not encrypted, so their claims must contain no secrets.
71
+ - Return `Cache-Control: no-store` and fail closed when configuration or authentication is missing.
72
+ - Directory access additionally requires signed `user.admin: true`, derived from trusted tenant permissions, and persisted records. Follow [Tenant directories](https://app.astralbeam.ai/docs/sdk/listings).
73
+ - For employee-facing Tenant management, use `createAstralBeamOrganizationToken`. The [API client guide](https://app.astralbeam.ai/docs/sdk/api) covers database-backed roles and browser integration.
74
+
75
+ Existing token props and the default chat endpoint keep working. After acquiring a token, components call `POST /api/v1/me` and renew before expiry. See [authentication and refresh behavior](https://app.astralbeam.ai/docs/sdk/authentication).
76
76
 
77
77
  ## Options
78
78
 
79
- Every option is also a prop on `<AstralBeamChat>`; `handle.update(options)` applies any subset in place, and no option is fixed at mount. Details in [Configuration](https://app.astralbeam.ai/docs/sdk/configuration).
80
-
81
- | Option | Default | Meaning |
82
- | ------------------------------------ | ---------------------------------- | ------------------------------------------------------------------ |
83
- | `agentId` | organization's default | `agent_<uuid>`, copied from the dashboard |
84
- | `apiUrl` | `https://app.astralbeam.ai/api` | Base URL of the AstralBeam API; the widget calls `/v1/chat` there |
85
- | `fetchAstralBeamToken` | `{ url: "/api/astralbeam/token" }` | Chat auth token endpoint as `{ url, ...RequestInit }`, or a minter |
86
- | `title`, `showHeader` | `"AstralBeam"`, `true` | Header text, and whether the header and reset button show |
87
- | `emptyTitle`, `emptyDescription` | generic copy | Headline and subtitle of the empty transcript |
88
- | `colorScheme`, `theme` | `"system"`, built-in palette | Light/dark/system, and shadcn token overrides |
89
- | `attachments` | `true` | `false` hides the feature, or pass limits |
90
- | `tools`, `widgets` | none | What the agent can do and draw in your app |
91
- | `sandboxPanel` | `false` | Collected sandbox panel: files with downloads, command log |
92
- | `header`, `empty`, `composerActions` | widget's own chrome | Host-rendered replacements (React props; `slots` on the handle) |
93
- | `debug` | `false` | Log every SDK action in the browser and on the server |
79
+ Every option is also a prop on `<AstralBeamChat>`. `handle.update(options)` applies any subset in place, and no option is fixed at mount. Details in [Configuration](https://app.astralbeam.ai/docs/sdk/configuration).
80
+
81
+ | Option | Default | Meaning |
82
+ | --- | --- | --- |
83
+ | `agentId` | organization's default | `agent_<orgId>_<id>`, copied from the dashboard |
84
+ | `apiUrl` | `https://app.astralbeam.ai/api` | Base URL of the AstralBeam API. The widget calls `/v1/chat` there |
85
+ | `fetchAstralBeamToken` | `{ url: "/api/astralbeam/token" }` | Chat auth token endpoint as `{ url, ...RequestInit }`, or a minter |
86
+ | `title`, `showHeader` | `"AstralBeam"`, `true` | Header text, and whether the header and reset button show |
87
+ | `emptyTitle`, `emptyDescription` | generic copy | Headline and subtitle of the empty transcript |
88
+ | `colorScheme`, `theme` | `"system"`, built-in palette | Light/dark/system, and shadcn token overrides |
89
+ | `customCss` | None | Trusted CSS inside the widget's Shadow DOM |
90
+ | `attachments` | `true` | `false` hides the feature, or pass limits |
91
+ | `tools`, `widgets` | none | What the agent can do and draw in your app |
92
+ | `sandboxPanel` | `false` | Collected sandbox panel: files with downloads, command log |
93
+ | `header`, `empty`, `composerActions` | widget's own chrome | Host-rendered replacements (React props. `slots` on the handle) |
94
+ | `debug` | `false` | Log SDK actions in the browser, with server logs in development only |
94
95
 
95
96
  A `ref` on `<AstralBeamChat>` (and the vanilla handle) exposes `reset()` and `stop()` for hosts that draw their own controls.
96
97
 
@@ -117,41 +118,44 @@ widgets: {
117
118
  ```
118
119
 
119
120
  - Schemas are plain JSON Schema, or any [Standard Schema](https://standardschema.dev) validator (Zod, Valibot, ArkType).
120
- - Only a Standard Schema validates input in the browser; with plain JSON Schema, treat input as untrusted.
121
- - `defineTool` and `defineWidget` type `execute`/`render` input from a Standard Schema's output.
122
- - In React, `render` returns JSX in your own tree, so state, context, and handlers keep working.
123
- - New tools and widgets reach the agent on its next run.
121
+ - Only a Standard Schema validates input in the browser. With plain JSON Schema, treat input as untrusted.
124
122
 
125
123
  ## Documentation
126
124
 
127
- Each guide is short and self-contained.
128
-
129
- - [Getting started](https://app.astralbeam.ai/docs/sdk/getting-started) — install, mount, layout requirements.
130
- - [Authentication](https://app.astralbeam.ai/docs/sdk/authentication) — the token endpoint and its security rules.
131
- - [Configuration](https://app.astralbeam.ai/docs/sdk/configuration) — every option, and what `update` can change.
132
- - [Theming](https://app.astralbeam.ai/docs/sdk/theming) — color schemes, CSS tokens, the shadow-root boundary.
133
- - [Tools and widgets](https://app.astralbeam.ai/docs/sdk/tools-and-widgets) — schemas, live state, rendering into the transcript.
134
- - [Attachments](https://app.astralbeam.ai/docs/sdk/attachments) — file kinds, limits, what the endpoint enforces.
135
- - [Sandbox](https://app.astralbeam.ai/docs/sdk/sandbox) — steps, the opt-in panel, downloads, inline images.
136
- - [Headless](https://app.astralbeam.ai/docs/sdk/headless) — own the whole chat UI on the same session.
137
- - [Security model](https://app.astralbeam.ai/docs/sdk/security) — who grants, who enforces, what the client can change.
125
+ | Guide | Covers |
126
+ | --- | --- |
127
+ | [API client](https://app.astralbeam.ai/docs/sdk/api) | Typed resource and chat requests with API keys or JWTs. |
128
+ | [Getting started](https://app.astralbeam.ai/docs/sdk/getting-started) | install, mount, layout requirements. |
129
+ | [Authentication](https://app.astralbeam.ai/docs/sdk/authentication) | the token endpoint and its security rules. |
130
+ | [Tenant directories](https://app.astralbeam.ai/docs/sdk/listings) | provisioning, tenant-user and Tenant listings, lifecycle, and options. |
131
+ | [Configuration](https://app.astralbeam.ai/docs/sdk/configuration) | every option, and what `update` can change. |
132
+ | [Theming](https://app.astralbeam.ai/docs/sdk/theming) | color schemes, CSS tokens, the shadow-root boundary. |
133
+ | [Tools and widgets](https://app.astralbeam.ai/docs/sdk/tools-and-widgets) | schemas, live state, rendering into the transcript. |
134
+ | [Attachments](https://app.astralbeam.ai/docs/sdk/attachments) | file kinds, limits, what the endpoint enforces. |
135
+ | [Limits](https://app.astralbeam.ai/docs/sdk/limits) | request, attachment, and sandbox limits. |
136
+ | [Sandbox](https://app.astralbeam.ai/docs/sdk/sandbox) | steps, the opt-in panel, downloads, inline images. |
137
+ | [Headless](https://app.astralbeam.ai/docs/sdk/headless) | own the whole chat UI on the same session. |
138
+ | [Security model](https://app.astralbeam.ai/docs/sdk/security) | who grants, who enforces, what the client can change. |
138
139
 
139
140
  ## Entry points
140
141
 
142
+ Read-only Tenant and TenantUser widgets are available from `/client` and `/react`. See [Tenant directories](https://app.astralbeam.ai/docs/sdk/listings) for setup and embedding examples.
143
+
141
144
  There is no root export. Conversation history is not built yet.
142
145
 
143
146
  | Entry point | Contents | Peer dependency |
144
147
  | ------------------------ | -------------------------------------------- | -------------------- |
145
- | `@astralbeam/sdk/client` | `mountAstralBeamChat`, the vanilla loader | none |
148
+ | `@astralbeam/sdk/client` | Chat and Tenant directory mounts | none |
146
149
  | `@astralbeam/sdk/core` | `createAstralBeamChat`, the headless session | none |
147
- | `@astralbeam/sdk/react` | `<AstralBeamChat>`, `useAstralBeamChat` | `react`, `react-dom` |
148
- | `@astralbeam/sdk/server` | `createAstralBeamToken`, the token minter | none |
150
+ | `@astralbeam/sdk/react` | Chat hooks and isolated UI wrappers | `react`, `react-dom` |
151
+ | `@astralbeam/sdk/server` | Tenant and organization token minters | none |
152
+ | `@astralbeam/sdk/api` | Resource and chat HTTP helpers | none |
149
153
 
150
- Types resolve under every TypeScript module resolution mode, including the classic `"moduleResolution": "node"` that Ionic, Capacitor, and Create React App templates still ship. TypeScript 5.0 or later is required, because the declarations use `const` type parameters; on TypeScript 4.x the `.d.ts` files fail to parse.
154
+ Types resolve under every TypeScript module resolution mode, including classic `"moduleResolution": "node"`. Requires TypeScript 5.0 or later because declarations use `const` type parameters, which fail to parse on TypeScript 4.x.
151
155
 
152
156
  ## Example
153
157
 
154
- [`examples/todos`](../examples/todos) embeds the sidebar in a minimal TanStack Start app: a demo token route, host tools over live React state, and a `todoCard` widget. It uses no Tailwind or shadcn/ui of its own, to show the shadow-root boundary.
158
+ [`examples/todos`](../examples/todos) embeds the sidebar and a tenant-scoped user listing in a minimal TanStack Start app. Both use the same demo token route. The app also demonstrates host tools over live React state and a `todoCard` widget, with no Tailwind or shadcn/ui of its own.
155
159
 
156
160
  ## License
157
161
 
@@ -0,0 +1,358 @@
1
+ //#region src/api/api.d.ts
2
+ interface ApiRequestOptions extends RequestInit {
3
+ apiUrl?: string | undefined;
4
+ fetchClient?: typeof globalThis.fetch;
5
+ }
6
+ type ApiKeyOptions = ApiRequestOptions & {
7
+ apiKey: string;
8
+ astralBeamToken?: never;
9
+ };
10
+ type JwtOptions = ApiRequestOptions & {
11
+ astralBeamToken: string;
12
+ apiKey?: never;
13
+ };
14
+ type ApiOptions = ApiKeyOptions | JwtOptions;
15
+ type FileOptions = ApiRequestOptions & {
16
+ apiKey?: never;
17
+ astralBeamToken?: never;
18
+ };
19
+ interface AstralBeamApiError$1 extends Error {
20
+ name: "AstralBeamApiError";
21
+ status: number;
22
+ headers: Headers;
23
+ body?: AstralBeamApiError;
24
+ }
25
+ declare function isAstralBeamApiError(error: unknown): error is AstralBeamApiError$1;
26
+ declare function astralBeamApiFetch<T>(path: string, options: ApiOptions): Promise<T>;
27
+ declare function astralBeamJwtFetch<T>(path: string, options: JwtOptions): Promise<T>;
28
+ declare function astralBeamChatFetch<_T>(path: string, options: JwtOptions): Promise<Response>;
29
+ declare function astralBeamFileFetch<_T>(path: string, options?: FileOptions): Promise<Response>;
30
+ //#endregion
31
+ //#region src/api/generated/api.d.ts
32
+ /**
33
+ * Customer-defined JSON object; keys are preserved.
34
+ */
35
+ type TenantRecordEncodedMetadata = {
36
+ [key: string]: unknown;
37
+ };
38
+ /**
39
+ * Persisted Tenant; id is internal, external_id is the customer's exact identity.
40
+ */
41
+ interface TenantRecordEncoded {
42
+ id: string;
43
+ external_id: string;
44
+ name: string | null;
45
+ /** Customer-defined JSON object; keys are preserved. */
46
+ metadata: TenantRecordEncodedMetadata;
47
+ created_at: string;
48
+ updated_at: string;
49
+ }
50
+ /**
51
+ * Live keyset page. Pass either non-null continuation value as the same-named request parameter.
52
+ */
53
+ interface TenantPage {
54
+ items: TenantRecordEncoded[];
55
+ /** Pass as page_after to fetch the next page; null means no next page. */
56
+ page_after: string | null;
57
+ /** Pass as page_before to fetch the previous page; null means no previous page. */
58
+ page_before: string | null;
59
+ }
60
+ type AstralBeamApiErrorIssuesItem = {
61
+ path: string;
62
+ message: string;
63
+ };
64
+ interface AstralBeamApiError {
65
+ type: string;
66
+ title: string;
67
+ status: number;
68
+ detail: string;
69
+ issues?: AstralBeamApiErrorIssuesItem[];
70
+ }
71
+ /**
72
+ * Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
73
+ */
74
+ type CreateTenantInputMetadata = {
75
+ [key: string]: unknown;
76
+ };
77
+ interface CreateTenantInput {
78
+ /**
79
+ * Your stable external identity. Exact and case-sensitive; whitespace is preserved. Immutable after creation.
80
+ * @minLength 1
81
+ * @maxLength 255
82
+ */
83
+ external_id: string;
84
+ /** Defaults to null on creation. Send null to clear the name. */
85
+ name?: string | null;
86
+ /** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
87
+ metadata?: CreateTenantInputMetadata;
88
+ }
89
+ /**
90
+ * Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
91
+ */
92
+ type UpdateTenantInputMetadata = {
93
+ [key: string]: unknown;
94
+ };
95
+ interface UpdateTenantInput {
96
+ /** Defaults to null on creation. Send null to clear the name. */
97
+ name?: string | null;
98
+ /** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
99
+ metadata?: UpdateTenantInputMetadata;
100
+ }
101
+ /**
102
+ * Customer-defined JSON object; keys are preserved.
103
+ */
104
+ type TenantUserRecordEncodedMetadata = {
105
+ [key: string]: unknown;
106
+ };
107
+ /**
108
+ * Persisted TenantUser. Stored admin does not grant or revoke signed JWT authority.
109
+ */
110
+ interface TenantUserRecordEncoded {
111
+ id: string;
112
+ external_id: string;
113
+ name: string | null;
114
+ /** Customer-defined JSON object; keys are preserved. */
115
+ metadata: TenantUserRecordEncodedMetadata;
116
+ created_at: string;
117
+ updated_at: string;
118
+ tenant_id: string;
119
+ admin: boolean;
120
+ }
121
+ /**
122
+ * Live keyset page in ascending ID order within one Tenant. Pass either non-null continuation value as the same-named request parameter.
123
+ */
124
+ interface TenantUserPage {
125
+ items: TenantUserRecordEncoded[];
126
+ /** Pass as page_after to fetch the next page; null means no next page. */
127
+ page_after: string | null;
128
+ /** Pass as page_before to fetch the previous page; null means no previous page. */
129
+ page_before: string | null;
130
+ }
131
+ /**
132
+ * Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
133
+ */
134
+ type CreateTenantUserInputMetadata = {
135
+ [key: string]: unknown;
136
+ };
137
+ interface CreateTenantUserInput {
138
+ /**
139
+ * Your stable external identity. Exact and case-sensitive; whitespace is preserved. Immutable after creation.
140
+ * @minLength 1
141
+ * @maxLength 255
142
+ */
143
+ external_id: string;
144
+ /** Defaults to null on creation. Send null to clear the name. */
145
+ name?: string | null;
146
+ /** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
147
+ metadata?: CreateTenantUserInputMetadata;
148
+ /** Defaults to false on creation. Stored admin does not change signed JWT authority. */
149
+ admin?: boolean;
150
+ }
151
+ /**
152
+ * Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
153
+ */
154
+ type UpdateTenantUserInputMetadata = {
155
+ [key: string]: unknown;
156
+ };
157
+ interface UpdateTenantUserInput {
158
+ /** Defaults to null on creation. Send null to clear the name. */
159
+ name?: string | null;
160
+ /** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
161
+ metadata?: UpdateTenantUserInputMetadata;
162
+ /** Defaults to false on creation. Stored admin does not change signed JWT authority. */
163
+ admin?: boolean;
164
+ }
165
+ type ChatRunInputForwardedProps = {
166
+ [key: string]: unknown;
167
+ };
168
+ /**
169
+ * Legacy mirror of forwardedProps sent by TanStack AI clients.
170
+ */
171
+ type ChatRunInputData = {
172
+ [key: string]: unknown;
173
+ };
174
+ /**
175
+ * AG-UI RunAgentInput, validated by TanStack AI. Messages, tools, context, and resume entries follow AG-UI. forwardedProps accepts agentId and development-only debug. systemPrompt is rejected. Maximum request size: 32 MiB.
176
+ */
177
+ interface ChatRunInput {
178
+ threadId: string;
179
+ runId: string;
180
+ messages: unknown[];
181
+ tools: unknown[];
182
+ context: unknown[];
183
+ forwardedProps?: ChatRunInputForwardedProps;
184
+ /** Legacy mirror of forwardedProps sent by TanStack AI clients. */
185
+ data?: ChatRunInputData;
186
+ state?: unknown;
187
+ parentRunId?: string;
188
+ resume?: unknown[];
189
+ }
190
+ type ChatConfigurationCapabilities = {
191
+ attachments: boolean;
192
+ };
193
+ interface ChatConfiguration {
194
+ capabilities: ChatConfigurationCapabilities;
195
+ }
196
+ type CurrentUser = {
197
+ scope: "tenant";
198
+ organization: {
199
+ id: string;
200
+ };
201
+ tenant: TenantRecordEncoded;
202
+ user: TenantUserRecordEncoded;
203
+ } | {
204
+ scope: "organization";
205
+ organization: {
206
+ id: string;
207
+ };
208
+ user: {
209
+ id: string;
210
+ name: string;
211
+ email: string;
212
+ role: string;
213
+ };
214
+ };
215
+ type ListTenantsParams = {
216
+ /**
217
+ * Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
218
+ * @maxLength 255
219
+ * @pattern ^[^\u0000]*$
220
+ */
221
+ q?: string;
222
+ /**
223
+ * Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
224
+ * @minLength 1
225
+ * @maxLength 255
226
+ */
227
+ "filter[external_id]"?: string;
228
+ /**
229
+ * Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
230
+ * @minimum 1
231
+ */
232
+ page_size?: number;
233
+ /**
234
+ * @minLength 1
235
+ * @maxLength 2048
236
+ */
237
+ page_after?: string;
238
+ /**
239
+ * @minLength 1
240
+ * @maxLength 2048
241
+ */
242
+ page_before?: string;
243
+ };
244
+ type ListUsersForTenantParams = {
245
+ /**
246
+ * Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
247
+ * @maxLength 255
248
+ * @pattern ^[^\u0000]*$
249
+ */
250
+ q?: string;
251
+ /**
252
+ * Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
253
+ * @minLength 1
254
+ * @maxLength 255
255
+ */
256
+ "filter[external_id]"?: string;
257
+ /**
258
+ * Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
259
+ * @minimum 1
260
+ */
261
+ page_size?: number;
262
+ /**
263
+ * @minLength 1
264
+ * @maxLength 2048
265
+ */
266
+ page_after?: string;
267
+ /**
268
+ * @minLength 1
269
+ * @maxLength 2048
270
+ */
271
+ page_before?: string;
272
+ "filter[admin]"?: ListUsersForTenantFilterAdmin;
273
+ };
274
+ type ListUsersForTenantFilterAdmin = (typeof ListUsersForTenantFilterAdmin)[keyof typeof ListUsersForTenantFilterAdmin];
275
+ declare const ListUsersForTenantFilterAdmin: {
276
+ readonly true: "true";
277
+ readonly false: "false";
278
+ };
279
+ type GetChatConfigParams = {
280
+ agentId?: string;
281
+ };
282
+ type GetChatFileParams = {
283
+ ticket: string;
284
+ };
285
+ declare const getListTenantsUrl: (params: ListTenantsParams) => string;
286
+ /**
287
+ * List Tenants in internal ID order. q searches name or external ID as a case-insensitive literal substring. filter[external_id] adds an exact match. Organization keys and organization-management JWTs see their organization; admin tenant JWTs see only their signed Tenant. Keep filters unchanged when reusing cursors. Live listing, not a snapshot.
288
+ * @summary List Tenants
289
+ */
290
+ declare const listTenants: (params: ListTenantsParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantPage>;
291
+ declare const getCreateTenantUrl: () => string;
292
+ /**
293
+ * Create a Tenant with an exact customer-provided external_id. Requires an organization API key or organization-management JWT with a current owner/developer role. An external_id already used in this organization returns 409; creation never upserts.
294
+ * @summary Create a Tenant
295
+ */
296
+ declare const createTenant: (createTenantInput: CreateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
297
+ declare const getGetTenantUrl: (id: string) => string;
298
+ /**
299
+ * Get a Tenant by internal UUID, not external_id.
300
+ * @summary Get a Tenant
301
+ */
302
+ declare const getTenant: (id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
303
+ declare const getUpdateTenantUrl: (id: string) => string;
304
+ /**
305
+ * Update supplied name/metadata fields only. Requires an organization API key or organization-management JWT with a current owner/developer role. name:null clears the name; metadata replaces the object. Last-write-wins; no upsert.
306
+ * @summary Update a Tenant
307
+ */
308
+ declare const updateTenant: (id: string, updateTenantInput: UpdateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
309
+ declare const getListUsersForTenantUrl: (tenantId: string, params: ListUsersForTenantParams) => string;
310
+ /**
311
+ * List users of one Tenant in internal ID order. q searches name or external ID as a case-insensitive literal substring. Exact filter[external_id] and filter[admin] combine with AND. No matching user returns an empty page; missing and out-of-scope Tenants return 404. Cursors cannot be reused for another Tenant or filter. Live listing, not a snapshot.
312
+ * @summary List TenantUsers
313
+ */
314
+ declare const listUsersForTenant: (tenantId: string, params: ListUsersForTenantParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserPage>;
315
+ declare const getCreateTenantUserUrl: (tenantId: string) => string;
316
+ /**
317
+ * Create a TenantUser under the internal tenant_id path identifier, with a customer-provided tenant-local external_id. An external_id already used in this Tenant returns 409; the same external_id in another Tenant is allowed. Stored admin does not change signed JWT authority.
318
+ * @summary Create a TenantUser
319
+ */
320
+ declare const createTenantUser: (tenantId: string, createTenantUserInput: CreateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
321
+ declare const getGetTenantUserUrl: (tenantId: string, id: string) => string;
322
+ /**
323
+ * Get a TenantUser by the internal tenant_id and id pair within the authorized scope. No identity upsert.
324
+ * @summary Get a TenantUser
325
+ */
326
+ declare const getTenantUser: (tenantId: string, id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
327
+ declare const getUpdateTenantUserUrl: (tenantId: string, id: string) => string;
328
+ /**
329
+ * Update supplied name/metadata/admin fields only. Stored admin does not grant or revoke JWT authority. name:null clears the name; metadata replaces the object.
330
+ * @summary Update a TenantUser
331
+ */
332
+ declare const updateTenantUser: (tenantId: string, id: string, updateTenantUserInput: UpdateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
333
+ declare const getRunChatUrl: () => string;
334
+ /**
335
+ * Stream an AG-UI agent run using a tenant user JWT. No admin claim required. HTTP failures before streaming use AstralBeamApiError. Once streaming starts, failures use RUN_ERROR events. Tool results continue in a subsequent request. Disconnecting cancels the run. Limited to 20 requests per minute per organization, tenant, and user.
336
+ * @summary Run chat
337
+ */
338
+ declare const runChat: (chatRunInput: ChatRunInput, options: Parameters<typeof astralBeamChatFetch>[1]) => Promise<Response>;
339
+ declare const getGetChatConfigUrl: (params: GetChatConfigParams) => string;
340
+ /**
341
+ * Read the selected agent's attachment grant using a tenant user JWT. Omit agentId to use the organization's default agent. Client settings may narrow this grant, never widen it.
342
+ * @summary Get chat capabilities
343
+ */
344
+ declare const getChatConfig: (params: GetChatConfigParams, options: Parameters<typeof astralBeamJwtFetch>[1]) => Promise<ChatConfiguration>;
345
+ declare const getGetChatFileUrl: (params: GetChatFileParams) => string;
346
+ /**
347
+ * Use the signed ticket returned when chat publishes an artifact. No bearer token is required. Returns the original bytes with a content-sniffed Content-Type and Content-Disposition filename. Invalid or expired tickets, a missing sandbox, and rejected artifact checks return 404. Provider or file-read failures return 500.
348
+ * @summary Download a chat artifact
349
+ */
350
+ declare const getChatFile: (params: GetChatFileParams, options?: Parameters<typeof astralBeamFileFetch>[1]) => Promise<Response>;
351
+ declare const getGetCurrentUserUrl: () => string;
352
+ /**
353
+ * Use a tenant JWT to upsert its own Tenant and TenantUser atomically, without requiring admin authority. Supplied names and metadata replace stored values, omitted profile fields and admin are preserved, and an explicit admin claim updates stored admin. An organization JWT returns existing user membership and the current database role without provisioning identities. API keys and cookies are not accepted. Limited to 100 requests per five minutes per identity.
354
+ * @summary Get the current user
355
+ */
356
+ declare const getCurrentUser: (options: Parameters<typeof astralBeamJwtFetch>[1]) => Promise<CurrentUser>;
357
+ //#endregion
358
+ export { ApiOptions as $, getChatConfig as A, getListTenantsUrl as B, TenantUserRecordEncodedMetadata as C, UpdateTenantUserInputMetadata as D, UpdateTenantUserInput as E, getGetChatConfigUrl as F, getUpdateTenantUrl as G, getRunChatUrl as H, getGetChatFileUrl as I, listUsersForTenant as J, getUpdateTenantUserUrl as K, getGetCurrentUserUrl as L, getCreateTenantUrl as M, getCreateTenantUserUrl as N, createTenant as O, getCurrentUser as P, ApiKeyOptions as Q, getGetTenantUrl as R, TenantUserRecordEncoded as S, UpdateTenantInputMetadata as T, getTenant as U, getListUsersForTenantUrl as V, getTenantUser as W, updateTenant as X, runChat as Y, updateTenantUser as Z, ListUsersForTenantParams as _, ChatRunInput as a, TenantRecordEncodedMetadata as b, CreateTenantInput as c, CreateTenantUserInputMetadata as d, ApiRequestOptions as et, CurrentUser as f, ListUsersForTenantFilterAdmin as g, ListTenantsParams as h, ChatConfigurationCapabilities as i, isAstralBeamApiError as it, getChatFile as j, createTenantUser as k, CreateTenantInputMetadata as l, GetChatFileParams as m, AstralBeamApiErrorIssuesItem as n, FileOptions as nt, ChatRunInputData as o, GetChatConfigParams as p, listTenants as q, ChatConfiguration as r, JwtOptions as rt, ChatRunInputForwardedProps as s, AstralBeamApiError as t, AstralBeamApiError$1 as tt, CreateTenantUserInput as u, TenantPage as v, UpdateTenantInput as w, TenantUserPage as x, TenantRecordEncoded as y, getGetTenantUserUrl as z };