@ragable/sdk 0.0.3 → 0.3.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/dist/index.d.mts +207 -1
- package/dist/index.d.ts +207 -1
- package/dist/index.js +274 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase-style schema types for `createBrowserClient<Database>()`.
|
|
3
|
+
* Define `Row` (and optionally `Insert` / `Update`) per table, then use
|
|
4
|
+
* `Tables<Database, 'my_table'>` with `database.query<...>()`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://supabase.com/docs/reference/javascript/typescript-support
|
|
7
|
+
*/
|
|
8
|
+
/** JSON-serializable values (matches common Supabase `Json` definition). */
|
|
9
|
+
type Json = string | number | boolean | null | {
|
|
10
|
+
[key: string]: Json | undefined;
|
|
11
|
+
} | Json[];
|
|
12
|
+
/** One table’s type bundle — at minimum provide `Row`. */
|
|
13
|
+
type RagableTableDefinition<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> = {
|
|
14
|
+
Row: Row;
|
|
15
|
+
Insert?: Insert;
|
|
16
|
+
Update?: Update;
|
|
17
|
+
Relationships?: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Top-level database shape (Supabase `Database` pattern).
|
|
21
|
+
* Consumers extend `public.Tables` with table names → {@link RagableTableDefinition}.
|
|
22
|
+
*/
|
|
23
|
+
interface RagableDatabase {
|
|
24
|
+
public: {
|
|
25
|
+
Tables: Record<string, RagableTableDefinition>;
|
|
26
|
+
Views?: Record<string, {
|
|
27
|
+
Row: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
Enums?: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Default schema when no generic is passed to `createBrowserClient`.
|
|
34
|
+
* `Record<string, never>` for `Tables` is assignable to `Record<string, RagableTableDefinition>`;
|
|
35
|
+
* use `database.query<YourRow>()` or pass a concrete `Database` generic.
|
|
36
|
+
*/
|
|
37
|
+
interface DefaultRagableDatabase extends RagableDatabase {
|
|
38
|
+
public: {
|
|
39
|
+
Tables: Record<string, never>;
|
|
40
|
+
Views: Record<string, never>;
|
|
41
|
+
Enums: Record<string, never>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Row type for a table name (Supabase `Tables<'x'>` pattern). */
|
|
45
|
+
type Tables<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
46
|
+
Row: infer R;
|
|
47
|
+
} ? R extends Record<string, unknown> ? R : Record<string, unknown> : Record<string, unknown>;
|
|
48
|
+
/** Insert payload type when declared; otherwise a partial of `Row`. */
|
|
49
|
+
type TablesInsert<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
50
|
+
Insert: infer I;
|
|
51
|
+
} ? I extends Record<string, unknown> ? I : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
52
|
+
/** Update payload type when declared; otherwise partial `Row`. */
|
|
53
|
+
type TablesUpdate<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
54
|
+
Update: infer U;
|
|
55
|
+
} ? U extends Record<string, unknown> ? U : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
56
|
+
|
|
1
57
|
interface RagableClientOptions {
|
|
2
58
|
apiKey: string;
|
|
3
59
|
baseUrl?: string;
|
|
@@ -166,6 +222,151 @@ declare class AgentsClient {
|
|
|
166
222
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
167
223
|
}
|
|
168
224
|
|
|
225
|
+
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
226
|
+
interface RagableBrowserClientOptions {
|
|
227
|
+
/** Organization id (UUID) — public agent chat URLs. */
|
|
228
|
+
organizationId: string;
|
|
229
|
+
/**
|
|
230
|
+
* Authentication group id when using {@link RagableBrowserAuthClient} or
|
|
231
|
+
* {@link RagableBrowserDatabaseClient}.
|
|
232
|
+
*/
|
|
233
|
+
authGroupId?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Returns the end-user access JWT (from login/register/refresh).
|
|
236
|
+
* Required for `auth.getMe`, `auth.updateMe`, and `database.query`.
|
|
237
|
+
*/
|
|
238
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
239
|
+
/**
|
|
240
|
+
* API base URL including `/api`, e.g. `https://api.example.com/api`.
|
|
241
|
+
* @default "http://localhost:8080/api"
|
|
242
|
+
*/
|
|
243
|
+
baseUrl?: string;
|
|
244
|
+
fetch?: typeof fetch;
|
|
245
|
+
headers?: HeadersInit;
|
|
246
|
+
}
|
|
247
|
+
/** Successful register/login response (typed `user` via `AuthUser` generic). */
|
|
248
|
+
interface BrowserAuthSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
249
|
+
user: AuthUser;
|
|
250
|
+
accessToken: string;
|
|
251
|
+
refreshToken: string;
|
|
252
|
+
expiresIn: string;
|
|
253
|
+
}
|
|
254
|
+
interface BrowserAuthTokens {
|
|
255
|
+
accessToken: string;
|
|
256
|
+
refreshToken: string;
|
|
257
|
+
expiresIn: string;
|
|
258
|
+
}
|
|
259
|
+
/** End-user auth (email/password) for a linked authentication group — no org API key. */
|
|
260
|
+
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
261
|
+
private readonly options;
|
|
262
|
+
constructor(options: RagableBrowserClientOptions);
|
|
263
|
+
private get fetchImpl();
|
|
264
|
+
private toUrl;
|
|
265
|
+
private baseHeaders;
|
|
266
|
+
private authPrefix;
|
|
267
|
+
register(body: {
|
|
268
|
+
email: string;
|
|
269
|
+
password: string;
|
|
270
|
+
name?: string;
|
|
271
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
272
|
+
login(body: {
|
|
273
|
+
email: string;
|
|
274
|
+
password: string;
|
|
275
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
276
|
+
refresh(body: {
|
|
277
|
+
refreshToken: string;
|
|
278
|
+
}): Promise<BrowserAuthTokens>;
|
|
279
|
+
getMe(): Promise<{
|
|
280
|
+
user: AuthUser;
|
|
281
|
+
}>;
|
|
282
|
+
updateMe(body: {
|
|
283
|
+
name?: string | null;
|
|
284
|
+
password?: string;
|
|
285
|
+
}): Promise<{
|
|
286
|
+
user: AuthUser;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
interface BrowserSqlQueryParams {
|
|
290
|
+
databaseInstanceId: string;
|
|
291
|
+
sql: string;
|
|
292
|
+
params?: unknown[];
|
|
293
|
+
/** Ignored — the API only allows safe read-only SQL for end users. */
|
|
294
|
+
readOnly?: true;
|
|
295
|
+
timeoutMs?: number;
|
|
296
|
+
rowLimit?: number;
|
|
297
|
+
}
|
|
298
|
+
interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
299
|
+
command: string;
|
|
300
|
+
rowCount: number;
|
|
301
|
+
truncated: boolean;
|
|
302
|
+
rows: Row[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Run SQL against a Postgres instance linked to a website that uses the same `authGroupId`,
|
|
306
|
+
* authenticated as the signed-in end-user (access token).
|
|
307
|
+
*
|
|
308
|
+
* Pass `createBrowserClient<YourDatabase>()` and use `query<Tables<YourDatabase, 't'>>()`
|
|
309
|
+
* for Supabase-style row typing.
|
|
310
|
+
*/
|
|
311
|
+
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
312
|
+
private readonly options;
|
|
313
|
+
constructor(options: RagableBrowserClientOptions);
|
|
314
|
+
private get fetchImpl();
|
|
315
|
+
private toUrl;
|
|
316
|
+
query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
|
|
317
|
+
private baseHeaders;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Browser-safe client: **no org API key**. Uses public routes and end-user JWTs
|
|
321
|
+
* from {@link RagableBrowserAuthClient}.
|
|
322
|
+
*/
|
|
323
|
+
declare class RagableBrowserAgentsClient {
|
|
324
|
+
private readonly options;
|
|
325
|
+
constructor(options: RagableBrowserClientOptions);
|
|
326
|
+
private get fetchImpl();
|
|
327
|
+
private toUrl;
|
|
328
|
+
/**
|
|
329
|
+
* Stream agent execution as SSE (`POST /public/organizations/:orgId/agents/:agentId/chat/stream`).
|
|
330
|
+
*/
|
|
331
|
+
chatStream(agentId: string, params: AgentPublicChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
332
|
+
}
|
|
333
|
+
/** Public chat params — same shape as {@link AgentChatParams} plus optional trigger fields. */
|
|
334
|
+
interface AgentPublicChatParams extends AgentChatParams {
|
|
335
|
+
triggerSubtype?: string;
|
|
336
|
+
triggerNodeId?: string;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Browser client root. Use `createBrowserClient<Database, AuthUser>()` for Supabase-style
|
|
340
|
+
* typing on {@link RagableBrowserDatabaseClient.query} and auth `user` payloads.
|
|
341
|
+
*/
|
|
342
|
+
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
343
|
+
readonly agents: RagableBrowserAgentsClient;
|
|
344
|
+
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
345
|
+
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
346
|
+
constructor(options: RagableBrowserClientOptions);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Browser client: **no org `ragable_*` API key**.
|
|
350
|
+
* - {@link RagableBrowser.agents} — public agent SSE.
|
|
351
|
+
* - {@link RagableBrowser.auth} / {@link RagableBrowser.database} — need `authGroupId` (+ `getAccessToken` for protected calls).
|
|
352
|
+
*
|
|
353
|
+
* Pass schema and user types like Supabase: `createBrowserClient<Database, AuthUser>({ ... })`.
|
|
354
|
+
* For Shift and `/v1/*`, use {@link createClient} on a server.
|
|
355
|
+
*/
|
|
356
|
+
declare function createBrowserClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Shared SSE parsing for `data: {json}` lines (Ragable agent streams).
|
|
360
|
+
*/
|
|
361
|
+
type SseJsonEvent = Record<string, unknown> & {
|
|
362
|
+
type: string;
|
|
363
|
+
};
|
|
364
|
+
declare function parseSseDataLine(line: string): SseJsonEvent | null;
|
|
365
|
+
/**
|
|
366
|
+
* Read an SSE body and yield parsed `data:` JSON objects (double-newline framed).
|
|
367
|
+
*/
|
|
368
|
+
declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator<SseJsonEvent, void, undefined>;
|
|
369
|
+
|
|
169
370
|
/** Minimal client surface for {@link createRagPipeline} (implemented by {@link Ragable}). */
|
|
170
371
|
interface RagClientForPipeline {
|
|
171
372
|
shift: {
|
|
@@ -225,6 +426,11 @@ declare class Ragable {
|
|
|
225
426
|
};
|
|
226
427
|
constructor(options: RagableClientOptions);
|
|
227
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Server-side client with your **secret** `ragable_*` API key.
|
|
431
|
+
* Use from Node, Edge, or your Engine — never in browser bundles.
|
|
432
|
+
* For public agent streaming from the browser without a key, use {@link createBrowserClient}.
|
|
433
|
+
*/
|
|
228
434
|
declare function createClient(options: RagableClientOptions): Ragable;
|
|
229
435
|
|
|
230
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentStreamEvent, type AgentSummary, AgentsClient, type FormatContextOptions, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, type RagableClientOptions, RagableError, RagableRequestClient, type RequestOptions, type RetrieveParams, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext };
|
|
436
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RequestOptions, type RetrieveParams, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type Tables, type TablesInsert, type TablesUpdate, createBrowserClient, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase-style schema types for `createBrowserClient<Database>()`.
|
|
3
|
+
* Define `Row` (and optionally `Insert` / `Update`) per table, then use
|
|
4
|
+
* `Tables<Database, 'my_table'>` with `database.query<...>()`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://supabase.com/docs/reference/javascript/typescript-support
|
|
7
|
+
*/
|
|
8
|
+
/** JSON-serializable values (matches common Supabase `Json` definition). */
|
|
9
|
+
type Json = string | number | boolean | null | {
|
|
10
|
+
[key: string]: Json | undefined;
|
|
11
|
+
} | Json[];
|
|
12
|
+
/** One table’s type bundle — at minimum provide `Row`. */
|
|
13
|
+
type RagableTableDefinition<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> = {
|
|
14
|
+
Row: Row;
|
|
15
|
+
Insert?: Insert;
|
|
16
|
+
Update?: Update;
|
|
17
|
+
Relationships?: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Top-level database shape (Supabase `Database` pattern).
|
|
21
|
+
* Consumers extend `public.Tables` with table names → {@link RagableTableDefinition}.
|
|
22
|
+
*/
|
|
23
|
+
interface RagableDatabase {
|
|
24
|
+
public: {
|
|
25
|
+
Tables: Record<string, RagableTableDefinition>;
|
|
26
|
+
Views?: Record<string, {
|
|
27
|
+
Row: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
Enums?: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Default schema when no generic is passed to `createBrowserClient`.
|
|
34
|
+
* `Record<string, never>` for `Tables` is assignable to `Record<string, RagableTableDefinition>`;
|
|
35
|
+
* use `database.query<YourRow>()` or pass a concrete `Database` generic.
|
|
36
|
+
*/
|
|
37
|
+
interface DefaultRagableDatabase extends RagableDatabase {
|
|
38
|
+
public: {
|
|
39
|
+
Tables: Record<string, never>;
|
|
40
|
+
Views: Record<string, never>;
|
|
41
|
+
Enums: Record<string, never>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Row type for a table name (Supabase `Tables<'x'>` pattern). */
|
|
45
|
+
type Tables<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
46
|
+
Row: infer R;
|
|
47
|
+
} ? R extends Record<string, unknown> ? R : Record<string, unknown> : Record<string, unknown>;
|
|
48
|
+
/** Insert payload type when declared; otherwise a partial of `Row`. */
|
|
49
|
+
type TablesInsert<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
50
|
+
Insert: infer I;
|
|
51
|
+
} ? I extends Record<string, unknown> ? I : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
52
|
+
/** Update payload type when declared; otherwise partial `Row`. */
|
|
53
|
+
type TablesUpdate<D extends RagableDatabase, TableName extends keyof D["public"]["Tables"] & string> = [D["public"]["Tables"][TableName]] extends [never] ? Record<string, unknown> : D["public"]["Tables"][TableName] extends {
|
|
54
|
+
Update: infer U;
|
|
55
|
+
} ? U extends Record<string, unknown> ? U : Record<string, unknown> : Partial<Tables<D, TableName>>;
|
|
56
|
+
|
|
1
57
|
interface RagableClientOptions {
|
|
2
58
|
apiKey: string;
|
|
3
59
|
baseUrl?: string;
|
|
@@ -166,6 +222,151 @@ declare class AgentsClient {
|
|
|
166
222
|
chatStream(agentId: string, params: AgentChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
167
223
|
}
|
|
168
224
|
|
|
225
|
+
declare function normalizeBrowserApiBase(baseUrl?: string): string;
|
|
226
|
+
interface RagableBrowserClientOptions {
|
|
227
|
+
/** Organization id (UUID) — public agent chat URLs. */
|
|
228
|
+
organizationId: string;
|
|
229
|
+
/**
|
|
230
|
+
* Authentication group id when using {@link RagableBrowserAuthClient} or
|
|
231
|
+
* {@link RagableBrowserDatabaseClient}.
|
|
232
|
+
*/
|
|
233
|
+
authGroupId?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Returns the end-user access JWT (from login/register/refresh).
|
|
236
|
+
* Required for `auth.getMe`, `auth.updateMe`, and `database.query`.
|
|
237
|
+
*/
|
|
238
|
+
getAccessToken?: () => string | null | Promise<string | null>;
|
|
239
|
+
/**
|
|
240
|
+
* API base URL including `/api`, e.g. `https://api.example.com/api`.
|
|
241
|
+
* @default "http://localhost:8080/api"
|
|
242
|
+
*/
|
|
243
|
+
baseUrl?: string;
|
|
244
|
+
fetch?: typeof fetch;
|
|
245
|
+
headers?: HeadersInit;
|
|
246
|
+
}
|
|
247
|
+
/** Successful register/login response (typed `user` via `AuthUser` generic). */
|
|
248
|
+
interface BrowserAuthSession<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
249
|
+
user: AuthUser;
|
|
250
|
+
accessToken: string;
|
|
251
|
+
refreshToken: string;
|
|
252
|
+
expiresIn: string;
|
|
253
|
+
}
|
|
254
|
+
interface BrowserAuthTokens {
|
|
255
|
+
accessToken: string;
|
|
256
|
+
refreshToken: string;
|
|
257
|
+
expiresIn: string;
|
|
258
|
+
}
|
|
259
|
+
/** End-user auth (email/password) for a linked authentication group — no org API key. */
|
|
260
|
+
declare class RagableBrowserAuthClient<AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
261
|
+
private readonly options;
|
|
262
|
+
constructor(options: RagableBrowserClientOptions);
|
|
263
|
+
private get fetchImpl();
|
|
264
|
+
private toUrl;
|
|
265
|
+
private baseHeaders;
|
|
266
|
+
private authPrefix;
|
|
267
|
+
register(body: {
|
|
268
|
+
email: string;
|
|
269
|
+
password: string;
|
|
270
|
+
name?: string;
|
|
271
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
272
|
+
login(body: {
|
|
273
|
+
email: string;
|
|
274
|
+
password: string;
|
|
275
|
+
}): Promise<BrowserAuthSession<AuthUser>>;
|
|
276
|
+
refresh(body: {
|
|
277
|
+
refreshToken: string;
|
|
278
|
+
}): Promise<BrowserAuthTokens>;
|
|
279
|
+
getMe(): Promise<{
|
|
280
|
+
user: AuthUser;
|
|
281
|
+
}>;
|
|
282
|
+
updateMe(body: {
|
|
283
|
+
name?: string | null;
|
|
284
|
+
password?: string;
|
|
285
|
+
}): Promise<{
|
|
286
|
+
user: AuthUser;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
interface BrowserSqlQueryParams {
|
|
290
|
+
databaseInstanceId: string;
|
|
291
|
+
sql: string;
|
|
292
|
+
params?: unknown[];
|
|
293
|
+
/** Ignored — the API only allows safe read-only SQL for end users. */
|
|
294
|
+
readOnly?: true;
|
|
295
|
+
timeoutMs?: number;
|
|
296
|
+
rowLimit?: number;
|
|
297
|
+
}
|
|
298
|
+
interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
299
|
+
command: string;
|
|
300
|
+
rowCount: number;
|
|
301
|
+
truncated: boolean;
|
|
302
|
+
rows: Row[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Run SQL against a Postgres instance linked to a website that uses the same `authGroupId`,
|
|
306
|
+
* authenticated as the signed-in end-user (access token).
|
|
307
|
+
*
|
|
308
|
+
* Pass `createBrowserClient<YourDatabase>()` and use `query<Tables<YourDatabase, 't'>>()`
|
|
309
|
+
* for Supabase-style row typing.
|
|
310
|
+
*/
|
|
311
|
+
declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
|
|
312
|
+
private readonly options;
|
|
313
|
+
constructor(options: RagableBrowserClientOptions);
|
|
314
|
+
private get fetchImpl();
|
|
315
|
+
private toUrl;
|
|
316
|
+
query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
|
|
317
|
+
private baseHeaders;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Browser-safe client: **no org API key**. Uses public routes and end-user JWTs
|
|
321
|
+
* from {@link RagableBrowserAuthClient}.
|
|
322
|
+
*/
|
|
323
|
+
declare class RagableBrowserAgentsClient {
|
|
324
|
+
private readonly options;
|
|
325
|
+
constructor(options: RagableBrowserClientOptions);
|
|
326
|
+
private get fetchImpl();
|
|
327
|
+
private toUrl;
|
|
328
|
+
/**
|
|
329
|
+
* Stream agent execution as SSE (`POST /public/organizations/:orgId/agents/:agentId/chat/stream`).
|
|
330
|
+
*/
|
|
331
|
+
chatStream(agentId: string, params: AgentPublicChatParams): AsyncGenerator<AgentStreamEvent, void, undefined>;
|
|
332
|
+
}
|
|
333
|
+
/** Public chat params — same shape as {@link AgentChatParams} plus optional trigger fields. */
|
|
334
|
+
interface AgentPublicChatParams extends AgentChatParams {
|
|
335
|
+
triggerSubtype?: string;
|
|
336
|
+
triggerNodeId?: string;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Browser client root. Use `createBrowserClient<Database, AuthUser>()` for Supabase-style
|
|
340
|
+
* typing on {@link RagableBrowserDatabaseClient.query} and auth `user` payloads.
|
|
341
|
+
*/
|
|
342
|
+
declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>> {
|
|
343
|
+
readonly agents: RagableBrowserAgentsClient;
|
|
344
|
+
readonly auth: RagableBrowserAuthClient<AuthUser>;
|
|
345
|
+
readonly database: RagableBrowserDatabaseClient<Database>;
|
|
346
|
+
constructor(options: RagableBrowserClientOptions);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Browser client: **no org `ragable_*` API key**.
|
|
350
|
+
* - {@link RagableBrowser.agents} — public agent SSE.
|
|
351
|
+
* - {@link RagableBrowser.auth} / {@link RagableBrowser.database} — need `authGroupId` (+ `getAccessToken` for protected calls).
|
|
352
|
+
*
|
|
353
|
+
* Pass schema and user types like Supabase: `createBrowserClient<Database, AuthUser>({ ... })`.
|
|
354
|
+
* For Shift and `/v1/*`, use {@link createClient} on a server.
|
|
355
|
+
*/
|
|
356
|
+
declare function createBrowserClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Shared SSE parsing for `data: {json}` lines (Ragable agent streams).
|
|
360
|
+
*/
|
|
361
|
+
type SseJsonEvent = Record<string, unknown> & {
|
|
362
|
+
type: string;
|
|
363
|
+
};
|
|
364
|
+
declare function parseSseDataLine(line: string): SseJsonEvent | null;
|
|
365
|
+
/**
|
|
366
|
+
* Read an SSE body and yield parsed `data:` JSON objects (double-newline framed).
|
|
367
|
+
*/
|
|
368
|
+
declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator<SseJsonEvent, void, undefined>;
|
|
369
|
+
|
|
169
370
|
/** Minimal client surface for {@link createRagPipeline} (implemented by {@link Ragable}). */
|
|
170
371
|
interface RagClientForPipeline {
|
|
171
372
|
shift: {
|
|
@@ -225,6 +426,11 @@ declare class Ragable {
|
|
|
225
426
|
};
|
|
226
427
|
constructor(options: RagableClientOptions);
|
|
227
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Server-side client with your **secret** `ragable_*` API key.
|
|
431
|
+
* Use from Node, Edge, or your Engine — never in browser bundles.
|
|
432
|
+
* For public agent streaming from the browser without a key, use {@link createBrowserClient}.
|
|
433
|
+
*/
|
|
228
434
|
declare function createClient(options: RagableClientOptions): Ragable;
|
|
229
435
|
|
|
230
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentStreamEvent, type AgentSummary, AgentsClient, type FormatContextOptions, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, type RagableClientOptions, RagableError, RagableRequestClient, type RequestOptions, type RetrieveParams, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext };
|
|
436
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, type BrowserAuthSession, type BrowserAuthTokens, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type DefaultRagableDatabase, type FormatContextOptions, type Json, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableRequestClient, type RagableTableDefinition, type RequestOptions, type RetrieveParams, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type Tables, type TablesInsert, type TablesUpdate, createBrowserClient, createClient, createRagPipeline, extractErrorMessage, formatRetrievalContext, normalizeBrowserApiBase, parseSseDataLine, readSseStream };
|