@astralbeam/sdk 0.10.1 → 0.12.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
- Embed an agent chat sidebar in your web app, or build your own UI with the headless core. The widget isolates its styles in a shadow root.
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
@@ -25,6 +25,16 @@ const handle = mountAstralBeamChat(document.getElementById("sidebar"), {})
25
25
  // Update with handle.update({ colorScheme: "dark" }), then clean up with handle.unmount().
26
26
  ```
27
27
 
28
+ Without npm or a bundler, import the same entry from jsDelivr in a module script. Pin an exact version and the full `/dist/client.js` path, because the loader imports its lazy chunks relative to itself. See [Script tag](https://app.astralbeam.ai/docs/sdk/script-tag).
29
+
30
+ ```html
31
+ <script type="module">
32
+ import { mountAstralBeamChat } from "https://cdn.jsdelivr.net/npm/@astralbeam/sdk@0.12.0/dist/client.js"
33
+
34
+ mountAstralBeamChat(document.getElementById("sidebar"), {})
35
+ </script>
36
+ ```
37
+
28
38
  - The widget fills its container, so give it a parent with a definite height (`min-h-0` in a flex column).
29
39
  - Chat uses the hosted cloud by default. Tokens come from your application. For self-hosting, set `apiUrl` to your deployment’s `/api` base.
30
40
  - `@astralbeam/sdk/client` ships no React. The chat loads as a lazy chunk with its own bundled copy.
@@ -41,48 +51,57 @@ import { createAstralBeamToken } from "@astralbeam/sdk/server"
41
51
  const apiKey = process.env.ASTRALBEAM_API_KEY // key_<organizationId>_<id>_abo_<secret>
42
52
 
43
53
  export async function POST(request: Request) {
44
- if (!apiKey) return Response.json({ error: "Not configured" }, { status: 503 })
54
+ const headers = { "Cache-Control": "no-store" }
55
+ if (!apiKey) return Response.json({ error: "Not configured" }, { status: 503, headers })
45
56
  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" } })
57
+ if (!session) return Response.json({ error: "Unauthenticated" }, { status: 401, headers })
58
+ try {
59
+ const token = await createAstralBeamToken({
60
+ apiKey,
61
+ user: {
62
+ id: session.user.id,
63
+ name: session.user.name,
64
+ metadata: { email: session.user.email },
65
+ },
66
+ tenant: {
67
+ id: session.tenant.id,
68
+ name: session.tenant.name,
69
+ metadata: { plan: session.tenant.plan },
70
+ },
71
+ })
72
+ return Response.json({ token }, { headers })
73
+ } catch {
74
+ return Response.json({ error: "Token could not be issued" }, { status: 500, headers })
75
+ }
61
76
  }
62
77
  ```
63
78
 
64
79
  - Authenticate once and derive stable `user.id` and `tenant.id` values from that trusted session.
65
80
  - Keep API keys server-only. Tokens are signed, not encrypted, so their claims must contain no secrets.
66
81
  - Return `Cache-Control: no-store` and fail closed when configuration or authentication is missing.
82
+ - 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).
67
83
  - 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.
68
84
 
85
+ 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).
86
+
69
87
  ## Options
70
88
 
71
89
  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).
72
90
 
73
- | Option | Default | Meaning |
74
- | ------------------------------------ | ---------------------------------- | -------------------------------------------------------------------- |
75
- | `agentId` | organization's default | `agent_<orgId>_<id>`, copied from the dashboard |
76
- | `apiUrl` | `https://app.astralbeam.ai/api` | Base URL of the AstralBeam API. The widget calls `/v1/chat` there |
77
- | `fetchAstralBeamToken` | `{ url: "/api/astralbeam/token" }` | Chat auth token endpoint as `{ url, ...RequestInit }`, or a minter |
78
- | `title`, `showHeader` | `"AstralBeam"`, `true` | Header text, and whether the header and reset button show |
79
- | `emptyTitle`, `emptyDescription` | generic copy | Headline and subtitle of the empty transcript |
80
- | `colorScheme`, `theme` | `"system"`, built-in palette | Light/dark/system, and shadcn token overrides |
81
- | `attachments` | `true` | `false` hides the feature, or pass limits |
82
- | `tools`, `widgets` | none | What the agent can do and draw in your app |
83
- | `sandboxPanel` | `false` | Collected sandbox panel: files with downloads, command log |
84
- | `header`, `empty`, `composerActions` | widget's own chrome | Host-rendered replacements (React props. `slots` on the handle) |
85
- | `debug` | `false` | Log SDK actions in the browser, with server logs in development only |
91
+ | Option | Default | Meaning |
92
+ | --- | --- | --- |
93
+ | `agentId` | organization's default | `agent_<orgId>_<id>`, copied from the dashboard |
94
+ | `apiUrl` | `https://app.astralbeam.ai/api` | Base URL of the AstralBeam API. The widget calls `/v1/chat` there |
95
+ | `fetchAstralBeamToken` | `{ url: "/api/astralbeam/token" }` | Chat auth token endpoint as `{ url, ...RequestInit }`, or a minter |
96
+ | `title`, `showHeader` | `"AstralBeam"`, `true` | Header text, and whether the header and reset button show |
97
+ | `emptyTitle`, `emptyDescription` | generic copy | Headline and subtitle of the empty transcript |
98
+ | `colorScheme`, `theme` | `"system"`, built-in palette | Light/dark/system, and shadcn token overrides |
99
+ | `customCss` | None | Trusted CSS inside the widget's Shadow DOM |
100
+ | `attachments` | `true` | `false` hides the feature, or pass limits |
101
+ | `tools`, `widgets` | none | What the agent can do and draw in your app |
102
+ | `sandboxPanel` | `false` | Collected sandbox panel: files with downloads, command log |
103
+ | `header`, `empty`, `composerActions` | widget's own chrome | Host-rendered replacements (React props. `slots` on the handle) |
104
+ | `debug` | `false` | Log SDK actions in the browser, with server logs in development only |
86
105
 
87
106
  A `ref` on `<AstralBeamChat>` (and the vanilla handle) exposes `reset()` and `stop()` for hosts that draw their own controls.
88
107
 
@@ -113,29 +132,33 @@ widgets: {
113
132
 
114
133
  ## Documentation
115
134
 
116
- | Guide | Covers |
117
- | ------------------------------------------------------------------------- | ------------------------------------------------------- |
118
- | [API client](https://app.astralbeam.ai/docs/sdk/api) | Typed resource and chat requests with API keys or JWTs. |
119
- | [Getting started](https://app.astralbeam.ai/docs/sdk/getting-started) | install, mount, layout requirements. |
120
- | [Authentication](https://app.astralbeam.ai/docs/sdk/authentication) | the token endpoint and its security rules. |
121
- | [Configuration](https://app.astralbeam.ai/docs/sdk/configuration) | every option, and what `update` can change. |
122
- | [Theming](https://app.astralbeam.ai/docs/sdk/theming) | color schemes, CSS tokens, the shadow-root boundary. |
123
- | [Tools and widgets](https://app.astralbeam.ai/docs/sdk/tools-and-widgets) | schemas, live state, rendering into the transcript. |
124
- | [Attachments](https://app.astralbeam.ai/docs/sdk/attachments) | file kinds, limits, what the endpoint enforces. |
125
- | [Limits](https://app.astralbeam.ai/docs/sdk/limits) | request, attachment, and sandbox limits. |
126
- | [Sandbox](https://app.astralbeam.ai/docs/sdk/sandbox) | steps, the opt-in panel, downloads, inline images. |
127
- | [Headless](https://app.astralbeam.ai/docs/sdk/headless) | own the whole chat UI on the same session. |
128
- | [Security model](https://app.astralbeam.ai/docs/sdk/security) | who grants, who enforces, what the client can change. |
135
+ | Guide | Covers |
136
+ | --- | --- |
137
+ | [API client](https://app.astralbeam.ai/docs/sdk/api) | Typed resource and chat requests with API keys or JWTs. |
138
+ | [Getting started](https://app.astralbeam.ai/docs/sdk/getting-started) | install, mount, layout requirements. |
139
+ | [Script tag](https://app.astralbeam.ai/docs/sdk/script-tag) | loading from jsDelivr without a bundler, and Ruby on Rails. |
140
+ | [Authentication](https://app.astralbeam.ai/docs/sdk/authentication) | the token endpoint, its security rules, and minting in other languages. |
141
+ | [Tenant directories](https://app.astralbeam.ai/docs/sdk/listings) | provisioning, tenant-user and Tenant listings, lifecycle, and options. |
142
+ | [Configuration](https://app.astralbeam.ai/docs/sdk/configuration) | every option, and what `update` can change. |
143
+ | [Theming](https://app.astralbeam.ai/docs/sdk/theming) | color schemes, CSS tokens, the shadow-root boundary. |
144
+ | [Tools and widgets](https://app.astralbeam.ai/docs/sdk/tools-and-widgets) | schemas, live state, rendering into the transcript. |
145
+ | [Attachments](https://app.astralbeam.ai/docs/sdk/attachments) | file kinds, limits, what the endpoint enforces. |
146
+ | [Limits](https://app.astralbeam.ai/docs/sdk/limits) | request, attachment, and sandbox limits. |
147
+ | [Sandbox](https://app.astralbeam.ai/docs/sdk/sandbox) | steps, the opt-in panel, downloads, inline images. |
148
+ | [Headless](https://app.astralbeam.ai/docs/sdk/headless) | own the whole chat UI on the same session. |
149
+ | [Security model](https://app.astralbeam.ai/docs/sdk/security) | who grants, who enforces, what the client can change. |
129
150
 
130
151
  ## Entry points
131
152
 
153
+ 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.
154
+
132
155
  There is no root export. Conversation history is not built yet.
133
156
 
134
157
  | Entry point | Contents | Peer dependency |
135
158
  | ------------------------ | -------------------------------------------- | -------------------- |
136
- | `@astralbeam/sdk/client` | `mountAstralBeamChat`, the vanilla loader | none |
159
+ | `@astralbeam/sdk/client` | Chat and Tenant directory mounts | none |
137
160
  | `@astralbeam/sdk/core` | `createAstralBeamChat`, the headless session | none |
138
- | `@astralbeam/sdk/react` | `<AstralBeamChat>`, `useAstralBeamChat` | `react`, `react-dom` |
161
+ | `@astralbeam/sdk/react` | Chat hooks and isolated UI wrappers | `react`, `react-dom` |
139
162
  | `@astralbeam/sdk/server` | Tenant and organization token minters | none |
140
163
  | `@astralbeam/sdk/api` | Resource and chat HTTP helpers | none |
141
164
 
@@ -143,7 +166,9 @@ Types resolve under every TypeScript module resolution mode, including classic `
143
166
 
144
167
  ## Example
145
168
 
146
- [`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.
169
+ [`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.
170
+
171
+ [`examples/todos-rails`](../examples/todos-rails) is the same app in Ruby on Rails 8. It loads the SDK from jsDelivr through an import map, mounts it from a plain ES module, mints tokens with the `jwt` gem, and gives the agent tools over the app's JSON API.
147
172
 
148
173
  ## License
149
174
 
@@ -29,7 +29,8 @@ async function apiResponse(path, options) {
29
29
  if (astralBeamToken) headers.set("authorization", `Bearer ${astralBeamToken}`);
30
30
  const response = await fetchClient(resolveApiUrl(path, apiUrl), {
31
31
  ...init,
32
- headers
32
+ headers,
33
+ ...apiKey ? { redirect: "error" } : {}
33
34
  });
34
35
  if (response.ok) return response;
35
36
  const value = await response.json().catch((error) => {
@@ -230,6 +231,19 @@ const updateTenantUser = (tenantId, id, updateTenantUserInput, options) => {
230
231
  body: JSON.stringify(updateTenantUserInput)
231
232
  });
232
233
  };
234
+ const getGetOrganizationUrl = () => {
235
+ return `/api/v1/organization`;
236
+ };
237
+ /**
238
+ * Return the id, name, and slug of the Organization that owns the credential. Accepts an organization API key or organization-management JWT, including a viewer's. Tenant JWTs are forbidden.
239
+ * @summary Get the current Organization
240
+ */
241
+ const getOrganization = (options) => {
242
+ return astralBeamApiFetch(getGetOrganizationUrl(), {
243
+ ...options,
244
+ method: "GET"
245
+ });
246
+ };
233
247
  const getRunChatUrl = () => {
234
248
  return `/api/v1/chat`;
235
249
  };
@@ -292,5 +306,18 @@ const getChatFile = (params, options) => {
292
306
  method: "GET"
293
307
  });
294
308
  };
309
+ const getGetCurrentUserUrl = () => {
310
+ return `/api/v1/me`;
311
+ };
312
+ /**
313
+ * 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.
314
+ * @summary Get the current user
315
+ */
316
+ const getCurrentUser = (options) => {
317
+ return astralBeamJwtFetch(getGetCurrentUserUrl(), {
318
+ ...options,
319
+ method: "POST"
320
+ });
321
+ };
295
322
  //#endregion
296
- export { updateTenantUser as C, DEFAULT_CHAT_AUTH_TOKEN_URL as D, resolveApiUrl as E, DEFAULT_COLOR_SCHEME as O, updateTenant as S, isAstralBeamApiError as T, getUpdateTenantUrl as _, getChatFile as a, listUsersForTenant as b, getGetChatConfigUrl as c, getGetTenantUserUrl as d, getListTenantsUrl as f, getTenantUser as g, getTenant as h, getChatConfig as i, getGetChatFileUrl as l, getRunChatUrl as m, createTenant as n, getCreateTenantUrl as o, getListUsersForTenantUrl as p, createTenantUser as r, getCreateTenantUserUrl as s, ListUsersForTenantFilterAdmin as t, getGetTenantUrl as u, getUpdateTenantUserUrl as v, astralBeamChatFetch as w, runChat as x, listTenants as y };
323
+ export { resolveApiUrl as A, listTenants as C, updateTenantUser as D, updateTenant as E, DEFAULT_COLOR_SCHEME as M, astralBeamChatFetch as O, getUpdateTenantUserUrl as S, runChat as T, getOrganization as _, getChatFile as a, getTenantUser as b, getCurrentUser as c, getGetCurrentUserUrl as d, getGetOrganizationUrl as f, getListUsersForTenantUrl as g, getListTenantsUrl as h, getChatConfig as i, DEFAULT_CHAT_AUTH_TOKEN_URL as j, isAstralBeamApiError as k, getGetChatConfigUrl as l, getGetTenantUserUrl as m, createTenant as n, getCreateTenantUrl as o, getGetTenantUrl as p, createTenantUser as r, getCreateTenantUserUrl as s, ListUsersForTenantFilterAdmin as t, getGetChatFileUrl as u, getRunChatUrl as v, listUsersForTenant as w, getUpdateTenantUrl as x, getTenant as y };
@@ -0,0 +1,370 @@
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
+ interface Organization {
166
+ id: string;
167
+ name: string;
168
+ /** Editable dashboard URL segment. Use id, not slug, as the stable identity. */
169
+ slug: string;
170
+ }
171
+ type ChatRunInputForwardedProps = {
172
+ [key: string]: unknown;
173
+ };
174
+ /**
175
+ * Legacy mirror of forwardedProps sent by TanStack AI clients.
176
+ */
177
+ type ChatRunInputData = {
178
+ [key: string]: unknown;
179
+ };
180
+ /**
181
+ * 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.
182
+ */
183
+ interface ChatRunInput {
184
+ threadId: string;
185
+ runId: string;
186
+ messages: unknown[];
187
+ tools: unknown[];
188
+ context: unknown[];
189
+ forwardedProps?: ChatRunInputForwardedProps;
190
+ /** Legacy mirror of forwardedProps sent by TanStack AI clients. */
191
+ data?: ChatRunInputData;
192
+ state?: unknown;
193
+ parentRunId?: string;
194
+ resume?: unknown[];
195
+ }
196
+ type ChatConfigurationCapabilities = {
197
+ attachments: boolean;
198
+ };
199
+ interface ChatConfiguration {
200
+ capabilities: ChatConfigurationCapabilities;
201
+ }
202
+ type CurrentUser = {
203
+ scope: "tenant";
204
+ organization: {
205
+ id: string;
206
+ };
207
+ tenant: TenantRecordEncoded;
208
+ user: TenantUserRecordEncoded;
209
+ } | {
210
+ scope: "organization";
211
+ organization: {
212
+ id: string;
213
+ };
214
+ user: {
215
+ id: string;
216
+ name: string;
217
+ email: string;
218
+ role: string;
219
+ };
220
+ };
221
+ type ListTenantsParams = {
222
+ /**
223
+ * Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
224
+ * @maxLength 255
225
+ * @pattern ^[^\u0000]*$
226
+ */
227
+ q?: string;
228
+ /**
229
+ * Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
230
+ * @minLength 1
231
+ * @maxLength 255
232
+ */
233
+ "filter[external_id]"?: string;
234
+ /**
235
+ * Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
236
+ * @minimum 1
237
+ */
238
+ page_size?: number;
239
+ /**
240
+ * @minLength 1
241
+ * @maxLength 2048
242
+ */
243
+ page_after?: string;
244
+ /**
245
+ * @minLength 1
246
+ * @maxLength 2048
247
+ */
248
+ page_before?: string;
249
+ };
250
+ type ListUsersForTenantParams = {
251
+ /**
252
+ * Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
253
+ * @maxLength 255
254
+ * @pattern ^[^\u0000]*$
255
+ */
256
+ q?: string;
257
+ /**
258
+ * Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
259
+ * @minLength 1
260
+ * @maxLength 255
261
+ */
262
+ "filter[external_id]"?: string;
263
+ /**
264
+ * Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
265
+ * @minimum 1
266
+ */
267
+ page_size?: number;
268
+ /**
269
+ * @minLength 1
270
+ * @maxLength 2048
271
+ */
272
+ page_after?: string;
273
+ /**
274
+ * @minLength 1
275
+ * @maxLength 2048
276
+ */
277
+ page_before?: string;
278
+ "filter[admin]"?: ListUsersForTenantFilterAdmin;
279
+ };
280
+ type ListUsersForTenantFilterAdmin = (typeof ListUsersForTenantFilterAdmin)[keyof typeof ListUsersForTenantFilterAdmin];
281
+ declare const ListUsersForTenantFilterAdmin: {
282
+ readonly true: "true";
283
+ readonly false: "false";
284
+ };
285
+ type GetChatConfigParams = {
286
+ agentId?: string;
287
+ };
288
+ type GetChatFileParams = {
289
+ ticket: string;
290
+ };
291
+ declare const getListTenantsUrl: (params: ListTenantsParams) => string;
292
+ /**
293
+ * 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.
294
+ * @summary List Tenants
295
+ */
296
+ declare const listTenants: (params: ListTenantsParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantPage>;
297
+ declare const getCreateTenantUrl: () => string;
298
+ /**
299
+ * 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.
300
+ * @summary Create a Tenant
301
+ */
302
+ declare const createTenant: (createTenantInput: CreateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
303
+ declare const getGetTenantUrl: (id: string) => string;
304
+ /**
305
+ * Get a Tenant by internal UUID, not external_id.
306
+ * @summary Get a Tenant
307
+ */
308
+ declare const getTenant: (id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
309
+ declare const getUpdateTenantUrl: (id: string) => string;
310
+ /**
311
+ * 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.
312
+ * @summary Update a Tenant
313
+ */
314
+ declare const updateTenant: (id: string, updateTenantInput: UpdateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
315
+ declare const getListUsersForTenantUrl: (tenantId: string, params: ListUsersForTenantParams) => string;
316
+ /**
317
+ * 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.
318
+ * @summary List TenantUsers
319
+ */
320
+ declare const listUsersForTenant: (tenantId: string, params: ListUsersForTenantParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserPage>;
321
+ declare const getCreateTenantUserUrl: (tenantId: string) => string;
322
+ /**
323
+ * 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.
324
+ * @summary Create a TenantUser
325
+ */
326
+ declare const createTenantUser: (tenantId: string, createTenantUserInput: CreateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
327
+ declare const getGetTenantUserUrl: (tenantId: string, id: string) => string;
328
+ /**
329
+ * Get a TenantUser by the internal tenant_id and id pair within the authorized scope. No identity upsert.
330
+ * @summary Get a TenantUser
331
+ */
332
+ declare const getTenantUser: (tenantId: string, id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
333
+ declare const getUpdateTenantUserUrl: (tenantId: string, id: string) => string;
334
+ /**
335
+ * 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.
336
+ * @summary Update a TenantUser
337
+ */
338
+ declare const updateTenantUser: (tenantId: string, id: string, updateTenantUserInput: UpdateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
339
+ declare const getGetOrganizationUrl: () => string;
340
+ /**
341
+ * Return the id, name, and slug of the Organization that owns the credential. Accepts an organization API key or organization-management JWT, including a viewer's. Tenant JWTs are forbidden.
342
+ * @summary Get the current Organization
343
+ */
344
+ declare const getOrganization: (options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<Organization>;
345
+ declare const getRunChatUrl: () => string;
346
+ /**
347
+ * 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.
348
+ * @summary Run chat
349
+ */
350
+ declare const runChat: (chatRunInput: ChatRunInput, options: Parameters<typeof astralBeamChatFetch>[1]) => Promise<Response>;
351
+ declare const getGetChatConfigUrl: (params: GetChatConfigParams) => string;
352
+ /**
353
+ * 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.
354
+ * @summary Get chat capabilities
355
+ */
356
+ declare const getChatConfig: (params: GetChatConfigParams, options: Parameters<typeof astralBeamJwtFetch>[1]) => Promise<ChatConfiguration>;
357
+ declare const getGetChatFileUrl: (params: GetChatFileParams) => string;
358
+ /**
359
+ * 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.
360
+ * @summary Download a chat artifact
361
+ */
362
+ declare const getChatFile: (params: GetChatFileParams, options?: Parameters<typeof astralBeamFileFetch>[1]) => Promise<Response>;
363
+ declare const getGetCurrentUserUrl: () => string;
364
+ /**
365
+ * 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.
366
+ * @summary Get the current user
367
+ */
368
+ declare const getCurrentUser: (options: Parameters<typeof astralBeamJwtFetch>[1]) => Promise<CurrentUser>;
369
+ //#endregion
370
+ export { updateTenant as $, createTenantUser as A, getGetTenantUrl as B, TenantUserRecordEncoded as C, UpdateTenantUserInput as D, UpdateTenantInputMetadata as E, getCurrentUser as F, getRunChatUrl as G, getListTenantsUrl as H, getGetChatConfigUrl as I, getUpdateTenantUrl as J, getTenant as K, getGetChatFileUrl as L, getChatFile as M, getCreateTenantUrl as N, UpdateTenantUserInputMetadata as O, getCreateTenantUserUrl as P, runChat as Q, getGetCurrentUserUrl as R, TenantUserPage as S, UpdateTenantInput as T, getListUsersForTenantUrl as U, getGetTenantUserUrl as V, getOrganization as W, listTenants as X, getUpdateTenantUserUrl as Y, listUsersForTenant as Z, ListUsersForTenantParams as _, ChatRunInput as a, FileOptions as at, TenantRecordEncoded as b, CreateTenantInput as c, CreateTenantUserInputMetadata as d, updateTenantUser as et, CurrentUser as f, ListUsersForTenantFilterAdmin as g, ListTenantsParams as h, ChatConfigurationCapabilities as i, AstralBeamApiError$1 as it, getChatConfig as j, createTenant as k, CreateTenantInputMetadata as l, GetChatFileParams as m, AstralBeamApiErrorIssuesItem as n, ApiOptions as nt, ChatRunInputData as o, JwtOptions as ot, GetChatConfigParams as p, getTenantUser as q, ChatConfiguration as r, ApiRequestOptions as rt, ChatRunInputForwardedProps as s, isAstralBeamApiError as st, AstralBeamApiError as t, ApiKeyOptions as tt, CreateTenantUserInput as u, Organization as v, TenantUserRecordEncodedMetadata as w, TenantRecordEncodedMetadata as x, TenantPage as y, getGetOrganizationUrl as z };