@nestcorehq/js 0.9.0 → 0.10.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 +39 -0
- package/dist/index.d.mts +233 -27
- package/dist/index.d.ts +233 -27
- package/dist/index.global.js +5 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -192,6 +192,45 @@ const { data } = await client.db.from('articles').eq('published', true).semantic
|
|
|
192
192
|
|
|
193
193
|
See https://nestcore.io/docs/memory-api, /docs/collections, /docs/threads and /docs/embeddings.
|
|
194
194
|
|
|
195
|
+
#### Your own embeddings, trust and batches
|
|
196
|
+
|
|
197
|
+
Memory and collections also take vectors from your own (e.g. local) embedding model; the server then calls no provider and charges nothing. Search compares only vectors of the same `model` and size.
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const model = 'nomic-embed-text-v1.5';
|
|
201
|
+
await client.memory.add('Prefers tea', { embedding: vec, model, metadata: { trust: 'user' } });
|
|
202
|
+
await client.memory.search({ queryEmbedding: q, model, trust: ['user', 'tool'] }); // text query optional
|
|
203
|
+
|
|
204
|
+
// Batches: up to 100 adds, 20 searches, 500 ids / 20 subjects per call
|
|
205
|
+
await client.memory.addMany([{ content: 'a', embedding: va, model }, { content: 'b', embedding: vb, model }]);
|
|
206
|
+
const { data: batch } = await client.memory.searchMany([{ queryEmbedding: q1, model }, { query: 'tea' }]);
|
|
207
|
+
await client.memory.forgetMany({ ids: ['…'], subjects: ['owner:…'] });
|
|
208
|
+
|
|
209
|
+
// A collection document from chunks you embedded (ready at once; the first chunks fix the collection's model)
|
|
210
|
+
await client.collections.from('notes').addChunks([{ content: 'Refunds take 5 days', embedding: v }], { model, title: 'FAQ' });
|
|
211
|
+
await client.collections.from('notes').search({ queryEmbedding: q, model, trust: 'user' });
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### AI credits and the OpenAI-compatible API
|
|
215
|
+
|
|
216
|
+
A project's own provider key always wins. Without one, the workspace's prepaid AI credit can pay (bought in Console → Settings → Billing).
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
const { data: credits } = await client.ai.credits();
|
|
220
|
+
// { available, active, balanceUsd, monthlyCapUsd, spentThisMonthUsd, ownKeys, creditProviders }
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
unwrap(await client.ai.chat({ messages }));
|
|
224
|
+
} catch (e) {
|
|
225
|
+
if (e instanceof NestCoreError && e.isCreditsExhausted) {
|
|
226
|
+
// e.reason: 'balance' | 'spend_cap'. Don't retry: offer e.buyUrl, or adding your own key.
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Any OpenAI client works against the gateway (anon key as `apikey`, the user's token as the API key)
|
|
231
|
+
new OpenAI({ baseURL: client.ai.openaiBaseUrl, apiKey: accessToken, defaultHeaders: { apikey: anonKey } });
|
|
232
|
+
```
|
|
233
|
+
|
|
195
234
|
## Realtime
|
|
196
235
|
|
|
197
236
|
Browsers can't set WebSocket request headers, so the API key is sent via the
|
package/dist/index.d.mts
CHANGED
|
@@ -1361,8 +1361,23 @@ interface AiMemoryMatch extends AiMemory {
|
|
|
1361
1361
|
/** Similarity nudged by importance and recency; results are sorted by it. */
|
|
1362
1362
|
score: number;
|
|
1363
1363
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1364
|
+
/** `metadata.trust` (and the search `trust` filter): a lowercase word such as `user`, `tool` or `web`. */
|
|
1365
|
+
type AiTrust = string | string[];
|
|
1366
|
+
/**
|
|
1367
|
+
* A vector you computed with your own (e.g. local) embedding model. The server
|
|
1368
|
+
* then calls no model provider and charges nothing. Search compares only
|
|
1369
|
+
* vectors of the same `model` and size, so switching models means re-sending.
|
|
1370
|
+
*/
|
|
1371
|
+
interface ClientEmbedding {
|
|
1372
|
+
/** 1–2000 finite numbers, not all zeros. Needs `model`. */
|
|
1373
|
+
embedding?: number[];
|
|
1374
|
+
/** The model that produced the vector (names the vector space), e.g. `nomic-embed-text-v1.5`. */
|
|
1375
|
+
model?: string;
|
|
1376
|
+
/** Checked against the vector length. */
|
|
1377
|
+
dims?: number;
|
|
1378
|
+
}
|
|
1379
|
+
interface MemoryAddOptions extends ClientEmbedding {
|
|
1380
|
+
/** Service key only: `type:id`, e.g. `user:<id>`, `agent:support`. Signed-in users are always `user:<their id>`; device and phone tokens default to `owner:<owner id>`. */
|
|
1366
1381
|
subject?: string;
|
|
1367
1382
|
/** fact (default), preference, episode, summary, or your own word. */
|
|
1368
1383
|
kind?: string;
|
|
@@ -1370,11 +1385,47 @@ interface MemoryAddOptions {
|
|
|
1370
1385
|
importance?: number;
|
|
1371
1386
|
/** ISO date; the memory is deleted after it. */
|
|
1372
1387
|
expiresAt?: string | null;
|
|
1388
|
+
/** `trust` is reserved: a lowercase word (`^[a-z][a-z0-9_-]{0,31}$`). */
|
|
1373
1389
|
metadata?: Record<string, unknown>;
|
|
1374
1390
|
sourceThreadId?: string;
|
|
1375
1391
|
/** Update a near-identical memory (cosine ≥ 0.92) instead of adding one. Default true. */
|
|
1376
1392
|
dedupe?: boolean;
|
|
1377
1393
|
}
|
|
1394
|
+
/** One item of {@link MemoryClient.addMany}. */
|
|
1395
|
+
interface MemoryAddItem extends MemoryAddOptions {
|
|
1396
|
+
content: string;
|
|
1397
|
+
}
|
|
1398
|
+
interface MemorySearchOptions {
|
|
1399
|
+
subject?: string;
|
|
1400
|
+
/** 1–50, default 5. */
|
|
1401
|
+
k?: number;
|
|
1402
|
+
kind?: string;
|
|
1403
|
+
minSimilarity?: number;
|
|
1404
|
+
/** Only memories whose `metadata.trust` is this word (or one of these words). */
|
|
1405
|
+
trust?: AiTrust;
|
|
1406
|
+
/** Your own query vector; `query` text is then optional. Needs `model`. */
|
|
1407
|
+
queryEmbedding?: number[];
|
|
1408
|
+
/** The model of `queryEmbedding`. */
|
|
1409
|
+
model?: string;
|
|
1410
|
+
dims?: number;
|
|
1411
|
+
}
|
|
1412
|
+
/** One query of {@link MemoryClient.searchMany}: `query` text, `queryEmbedding`, or both. */
|
|
1413
|
+
interface MemorySearchItem extends MemorySearchOptions {
|
|
1414
|
+
query?: string;
|
|
1415
|
+
}
|
|
1416
|
+
interface MemorySearchResult {
|
|
1417
|
+
results: AiMemoryMatch[];
|
|
1418
|
+
/** true = the model provider was down and keyword search answered. */
|
|
1419
|
+
degraded: boolean;
|
|
1420
|
+
model: string | null;
|
|
1421
|
+
}
|
|
1422
|
+
interface MemoryUpdatePatch extends ClientEmbedding {
|
|
1423
|
+
content?: string;
|
|
1424
|
+
kind?: string;
|
|
1425
|
+
importance?: number;
|
|
1426
|
+
expiresAt?: string | null;
|
|
1427
|
+
metadata?: Record<string, unknown>;
|
|
1428
|
+
}
|
|
1378
1429
|
/**
|
|
1379
1430
|
* Memory API: facts about a user (or an agent, an org…) with semantic search.
|
|
1380
1431
|
* A signed-in user reads and writes only their own memory; the service key may
|
|
@@ -1383,27 +1434,48 @@ interface MemoryAddOptions {
|
|
|
1383
1434
|
* ```ts
|
|
1384
1435
|
* await client.memory.add('Prefers vegetarian recipes', { kind: 'preference' });
|
|
1385
1436
|
* const { data } = await client.memory.search('what should I cook?');
|
|
1437
|
+
*
|
|
1438
|
+
* // Your own embeddings (no provider call, nothing charged):
|
|
1439
|
+
* await client.memory.add('Prefers tea', { embedding: vec, model: 'nomic-embed-text-v1.5' });
|
|
1440
|
+
* await client.memory.search({ queryEmbedding: q, model: 'nomic-embed-text-v1.5', trust: 'user' });
|
|
1386
1441
|
* ```
|
|
1387
1442
|
*/
|
|
1388
1443
|
declare class MemoryClient {
|
|
1389
1444
|
private client;
|
|
1390
1445
|
constructor(client: HttpClient);
|
|
1391
1446
|
private path;
|
|
1392
|
-
/**
|
|
1447
|
+
/**
|
|
1448
|
+
* Remember something. `deduped: true` means an existing near-identical memory was updated.
|
|
1449
|
+
* Pass `embedding` + `model` to use your own vector.
|
|
1450
|
+
*/
|
|
1393
1451
|
add(content: string, options?: MemoryAddOptions): Promise<ApiResult<{
|
|
1394
1452
|
memory: AiMemory;
|
|
1395
1453
|
deduped: boolean;
|
|
1396
1454
|
}>>;
|
|
1397
|
-
/**
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1455
|
+
/**
|
|
1456
|
+
* Most relevant memories. `degraded: true` = the model provider was down and keyword search answered.
|
|
1457
|
+
* With `queryEmbedding` + `model` the text is optional: `search({ queryEmbedding, model })`
|
|
1458
|
+
* or `search(null, { queryEmbedding, model })`.
|
|
1459
|
+
*/
|
|
1460
|
+
search(query: string | null | undefined, options?: MemorySearchOptions): Promise<ApiResult<MemorySearchResult>>;
|
|
1461
|
+
search(options: MemorySearchItem): Promise<ApiResult<MemorySearchResult>>;
|
|
1462
|
+
/** Up to 100 memories in one call (each counts against the memory quota). An invalid item fails the whole call with `400 "item <i>: …"`. */
|
|
1463
|
+
addMany(items: MemoryAddItem[]): Promise<ApiResult<{
|
|
1464
|
+
results: Array<{
|
|
1465
|
+
memory: AiMemory;
|
|
1466
|
+
deduped: boolean;
|
|
1467
|
+
}>;
|
|
1468
|
+
}>>;
|
|
1469
|
+
/** Up to 20 searches in one call; `results[i]` answers `queries[i]`. */
|
|
1470
|
+
searchMany(queries: MemorySearchItem[]): Promise<ApiResult<{
|
|
1471
|
+
results: MemorySearchResult[];
|
|
1472
|
+
}>>;
|
|
1473
|
+
/** Delete memories by id (up to 500) and/or whole subjects (up to 20; users and agents only their own). */
|
|
1474
|
+
forgetMany(target: {
|
|
1475
|
+
ids?: string[];
|
|
1476
|
+
subjects?: string[];
|
|
1403
1477
|
}): Promise<ApiResult<{
|
|
1404
|
-
|
|
1405
|
-
degraded: boolean;
|
|
1406
|
-
model: string | null;
|
|
1478
|
+
deleted: number;
|
|
1407
1479
|
}>>;
|
|
1408
1480
|
list(options?: {
|
|
1409
1481
|
subject?: string;
|
|
@@ -1415,13 +1487,8 @@ declare class MemoryClient {
|
|
|
1415
1487
|
total: number;
|
|
1416
1488
|
}>>;
|
|
1417
1489
|
get(id: string): Promise<ApiResult<AiMemory>>;
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
kind?: string;
|
|
1421
|
-
importance?: number;
|
|
1422
|
-
expiresAt?: string | null;
|
|
1423
|
-
metadata?: Record<string, unknown>;
|
|
1424
|
-
}): Promise<ApiResult<AiMemory>>;
|
|
1490
|
+
/** `embedding` + `model` only together with new `content`. */
|
|
1491
|
+
update(id: string, patch: MemoryUpdatePatch): Promise<ApiResult<AiMemory>>;
|
|
1425
1492
|
remove(id: string): Promise<ApiResult<{
|
|
1426
1493
|
deleted: boolean;
|
|
1427
1494
|
}>>;
|
|
@@ -1509,6 +1576,38 @@ type DocumentSource = {
|
|
|
1509
1576
|
path: string;
|
|
1510
1577
|
};
|
|
1511
1578
|
};
|
|
1579
|
+
/** A chunk you split and embedded yourself (see {@link CollectionRef.addChunks}). */
|
|
1580
|
+
interface ClientChunk {
|
|
1581
|
+
content: string;
|
|
1582
|
+
embedding: number[];
|
|
1583
|
+
/** Chunk metadata, e.g. `{ trust: 'user' }`. */
|
|
1584
|
+
metadata?: Record<string, unknown>;
|
|
1585
|
+
}
|
|
1586
|
+
interface AddChunksOptions {
|
|
1587
|
+
/** The embedding model of every chunk. The first client chunks fix the collection's model; another model answers 409. */
|
|
1588
|
+
model: string;
|
|
1589
|
+
/** Checked against each vector's length. */
|
|
1590
|
+
dims?: number;
|
|
1591
|
+
title?: string;
|
|
1592
|
+
metadata?: Record<string, unknown>;
|
|
1593
|
+
/** Service key only: the user who owns (and alone can read) this document. */
|
|
1594
|
+
ownerUserId?: string;
|
|
1595
|
+
}
|
|
1596
|
+
interface CollectionSearchOptions {
|
|
1597
|
+
/** 1–50, default 8. */
|
|
1598
|
+
k?: number;
|
|
1599
|
+
/** Vector + keyword (default); `false` = vector only. */
|
|
1600
|
+
hybrid?: boolean;
|
|
1601
|
+
/** Documents whose metadata contains this object. */
|
|
1602
|
+
filter?: Record<string, unknown>;
|
|
1603
|
+
minSimilarity?: number;
|
|
1604
|
+
/** Only chunks (or their document) whose `metadata.trust` is this word (or one of these words). */
|
|
1605
|
+
trust?: AiTrust;
|
|
1606
|
+
/** Your own query vector; `query` text is then optional. Needs `model` (the collection's). */
|
|
1607
|
+
queryEmbedding?: number[];
|
|
1608
|
+
model?: string;
|
|
1609
|
+
dims?: number;
|
|
1610
|
+
}
|
|
1512
1611
|
interface IngestOptions {
|
|
1513
1612
|
title?: string;
|
|
1514
1613
|
metadata?: Record<string, unknown>;
|
|
@@ -1531,17 +1630,30 @@ declare class CollectionRef {
|
|
|
1531
1630
|
* text files are read from storage or a URL.
|
|
1532
1631
|
*/
|
|
1533
1632
|
ingest(source: DocumentSource, options?: IngestOptions): Promise<ApiResult<AiDocument>>;
|
|
1633
|
+
/**
|
|
1634
|
+
* Add a document from chunks you embedded yourself (1–500; the body limit is 2 MB).
|
|
1635
|
+
* It is `ready` at once; the server calls no provider and charges nothing.
|
|
1636
|
+
*
|
|
1637
|
+
* ```ts
|
|
1638
|
+
* await kb.addChunks([{ content: 'Refunds take 5 days', embedding: vec }], { model: 'nomic-embed-text-v1.5', title: 'FAQ' });
|
|
1639
|
+
* ```
|
|
1640
|
+
*/
|
|
1641
|
+
addChunks(chunks: ClientChunk[], options: AddChunksOptions): Promise<ApiResult<AiDocument>>;
|
|
1534
1642
|
/** Poll a document until it is `ready` or `failed`. */
|
|
1535
1643
|
waitFor(documentId: string, { timeoutMs, intervalMs }?: {
|
|
1536
1644
|
timeoutMs?: number;
|
|
1537
1645
|
intervalMs?: number;
|
|
1538
1646
|
}): Promise<ApiResult<AiDocument>>;
|
|
1539
|
-
/**
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1647
|
+
/**
|
|
1648
|
+
* Hybrid search (vector + keyword). `hybrid: false` is vector only; `filter` matches document metadata.
|
|
1649
|
+
* With your own vector: `search({ queryEmbedding, model })` or `search('text', { queryEmbedding, model })`.
|
|
1650
|
+
*/
|
|
1651
|
+
search(query: string | null | undefined, options?: CollectionSearchOptions): Promise<ApiResult<{
|
|
1652
|
+
results: AiSearchResult[];
|
|
1653
|
+
model: string | null;
|
|
1654
|
+
}>>;
|
|
1655
|
+
search(options: CollectionSearchOptions & {
|
|
1656
|
+
query?: string;
|
|
1545
1657
|
}): Promise<ApiResult<{
|
|
1546
1658
|
results: AiSearchResult[];
|
|
1547
1659
|
model: string | null;
|
|
@@ -1695,6 +1807,7 @@ type ThreadRunEvent = {
|
|
|
1695
1807
|
code?: string;
|
|
1696
1808
|
message: string;
|
|
1697
1809
|
status?: number;
|
|
1810
|
+
details?: Record<string, unknown>;
|
|
1698
1811
|
};
|
|
1699
1812
|
interface ThreadRunResult {
|
|
1700
1813
|
messageId: string;
|
|
@@ -1876,6 +1989,7 @@ type AiStreamEvent = {
|
|
|
1876
1989
|
code?: string;
|
|
1877
1990
|
message: string;
|
|
1878
1991
|
status?: number;
|
|
1992
|
+
details?: Record<string, unknown>;
|
|
1879
1993
|
};
|
|
1880
1994
|
interface AiEmbedResult {
|
|
1881
1995
|
model: string;
|
|
@@ -1889,6 +2003,27 @@ interface AiModel {
|
|
|
1889
2003
|
provider: AiProviderId;
|
|
1890
2004
|
kind: 'chat' | 'embed';
|
|
1891
2005
|
default?: boolean;
|
|
2006
|
+
/** `credits`: paid from the workspace's prepaid AI credit (no project key for this provider). */
|
|
2007
|
+
source?: 'credits';
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Whether this project's AI calls can be paid from its workspace's prepaid
|
|
2011
|
+
* credit (when the project has no key of its own for a provider). A project's
|
|
2012
|
+
* own key always wins.
|
|
2013
|
+
*/
|
|
2014
|
+
interface AiCredits {
|
|
2015
|
+
/** There is credit to spend now. */
|
|
2016
|
+
available: boolean;
|
|
2017
|
+
/** The workspace has bought credit at some point. */
|
|
2018
|
+
active: boolean;
|
|
2019
|
+
balanceUsd: number;
|
|
2020
|
+
/** null = no monthly cap. */
|
|
2021
|
+
monthlyCapUsd: number | null;
|
|
2022
|
+
spentThisMonthUsd: number;
|
|
2023
|
+
/** Providers the project has its own key for. */
|
|
2024
|
+
ownKeys: AiProviderId[];
|
|
2025
|
+
/** Providers the credit can pay for. */
|
|
2026
|
+
creditProviders: AiProviderId[];
|
|
1892
2027
|
}
|
|
1893
2028
|
/**
|
|
1894
2029
|
* AI Gateway: chat and embeddings through the project's own provider keys.
|
|
@@ -1907,6 +2042,16 @@ declare class AiClient {
|
|
|
1907
2042
|
readonly threads: ThreadsClient;
|
|
1908
2043
|
constructor(client: HttpClient);
|
|
1909
2044
|
private path;
|
|
2045
|
+
/**
|
|
2046
|
+
* Base URL of the OpenAI-compatible API (`chat/completions` with `stream`,
|
|
2047
|
+
* `embeddings`, `models`) for any OpenAI client. Send the project key as the
|
|
2048
|
+
* `apikey` header and the user's (or device's) access token as the API key:
|
|
2049
|
+
*
|
|
2050
|
+
* ```ts
|
|
2051
|
+
* new OpenAI({ baseURL: client.ai.openaiBaseUrl, apiKey: accessToken, defaultHeaders: { apikey: anonKey } });
|
|
2052
|
+
* ```
|
|
2053
|
+
*/
|
|
2054
|
+
get openaiBaseUrl(): string;
|
|
1910
2055
|
private body;
|
|
1911
2056
|
chat(options: AiChatOptions): Promise<ApiResult<AiChatResult>>;
|
|
1912
2057
|
/**
|
|
@@ -1922,7 +2067,13 @@ declare class AiClient {
|
|
|
1922
2067
|
model?: string;
|
|
1923
2068
|
provider?: AiProviderId;
|
|
1924
2069
|
}): Promise<ApiResult<AiEmbedResult>>;
|
|
1925
|
-
/**
|
|
2070
|
+
/**
|
|
2071
|
+
* The workspace's prepaid AI credit as this project sees it. When a call is
|
|
2072
|
+
* paid from credit and none is left, it fails with 402 `CREDITS_EXHAUSTED`
|
|
2073
|
+
* (see `NestCoreError.isCreditsExhausted`, `reason` and `buyUrl`).
|
|
2074
|
+
*/
|
|
2075
|
+
credits(): Promise<ApiResult<AiCredits>>;
|
|
2076
|
+
/** Models the project can call with its saved provider keys (and, `source: 'credits'`, those its workspace's credit pays for). */
|
|
1926
2077
|
models(): Promise<ApiResult<AiModel[]>>;
|
|
1927
2078
|
/** Service key: per-call traces (model, tokens, latency, cost, status), newest first. */
|
|
1928
2079
|
traces(options?: {
|
|
@@ -1980,10 +2131,30 @@ declare function sanitizePath(path: string): string;
|
|
|
1980
2131
|
declare class NestCoreError extends Error {
|
|
1981
2132
|
readonly code?: string;
|
|
1982
2133
|
readonly status?: number;
|
|
2134
|
+
/** The API's error body, e.g. QUOTA_EXCEEDED's `quota`/`plan`/`limit`/`upgradeUrl`. */
|
|
2135
|
+
readonly details?: Record<string, unknown>;
|
|
1983
2136
|
constructor(message: string, opts?: {
|
|
1984
2137
|
code?: string;
|
|
1985
2138
|
status?: number;
|
|
2139
|
+
details?: Record<string, unknown>;
|
|
1986
2140
|
});
|
|
2141
|
+
/** 423: the project is paused (plan limit or owner) or compromised (kill switch). */
|
|
2142
|
+
get isProjectPaused(): boolean;
|
|
2143
|
+
/** 402 QUOTA_EXCEEDED: where to send the user to upgrade, when the API gave one. */
|
|
2144
|
+
get upgradeUrl(): string | undefined;
|
|
2145
|
+
/**
|
|
2146
|
+
* 402: an AI call paid from the workspace's prepaid credit found none left
|
|
2147
|
+
* (`reason` `balance`) or hit the monthly cap (`spend_cap`). Don't retry:
|
|
2148
|
+
* offer `buyUrl`, or adding the project's own provider key.
|
|
2149
|
+
*/
|
|
2150
|
+
get isCreditsExhausted(): boolean;
|
|
2151
|
+
/**
|
|
2152
|
+
* Why the call was refused, when the API said: `balance` | `spend_cap` for
|
|
2153
|
+
* CREDITS_EXHAUSTED, the quota reason (e.g. `ai_collections`) for QUOTA_EXCEEDED.
|
|
2154
|
+
*/
|
|
2155
|
+
get reason(): string | undefined;
|
|
2156
|
+
/** 402 CREDITS_EXHAUSTED: where to buy more AI credit. */
|
|
2157
|
+
get buyUrl(): string | undefined;
|
|
1987
2158
|
}
|
|
1988
2159
|
/** @deprecated Renamed to {@link NestCoreError}; kept so existing `instanceof` checks keep working. */
|
|
1989
2160
|
declare const OrbitNestError: typeof NestCoreError;
|
|
@@ -2018,6 +2189,41 @@ declare const AuthLimitCodes: {
|
|
|
2018
2189
|
/** Too many wrong passwords: the email is locked for the lockout duration. */
|
|
2019
2190
|
readonly ACCOUNT_LOCKED: "ACCOUNT_LOCKED";
|
|
2020
2191
|
};
|
|
2192
|
+
/**
|
|
2193
|
+
* `error.code` values about the project itself (any endpoint can answer them).
|
|
2194
|
+
* Project kinds: an App project is a backend for an app; an Agent project is
|
|
2195
|
+
* the private backend of one PC running NestCore Agent.
|
|
2196
|
+
*/
|
|
2197
|
+
declare const ProjectErrorCodes: {
|
|
2198
|
+
/**
|
|
2199
|
+
* 402: a plan limit was reached. `details` has quota, plan, limit, usage and, for projects, kind/reason/upgradeUrl
|
|
2200
|
+
* (`reason: 'ai_collections'` = the plan's collections per project).
|
|
2201
|
+
*/
|
|
2202
|
+
readonly QUOTA_EXCEEDED: "QUOTA_EXCEEDED";
|
|
2203
|
+
/**
|
|
2204
|
+
* 402: an AI call paid from prepaid credit found none left. `details`: reason (`balance` | `spend_cap`),
|
|
2205
|
+
* balanceUsd, monthlyCapUsd, spentThisMonthUsd, buyUrl. See {@link CreditsExhaustedDetails}.
|
|
2206
|
+
*/
|
|
2207
|
+
readonly CREDITS_EXHAUSTED: "CREDITS_EXHAUSTED";
|
|
2208
|
+
/** 423: the project is paused (downgrade or owner) or compromised (kill switch). Nothing was deleted. */
|
|
2209
|
+
readonly PROJECT_PAUSED: "PROJECT_PAUSED";
|
|
2210
|
+
/** 403: not allowed on an Agent project (only the agent schema, agent-* buckets and the agent functions). */
|
|
2211
|
+
readonly AGENT_PROJECT_RESTRICTED: "AGENT_PROJECT_RESTRICTED";
|
|
2212
|
+
/** 409: agent-only operation (agent template, agent functions) on an App project. */
|
|
2213
|
+
readonly NOT_AN_AGENT_PROJECT: "NOT_AN_AGENT_PROJECT";
|
|
2214
|
+
};
|
|
2215
|
+
/** `balance`: no credit left; `spend_cap`: the workspace's monthly AI credit cap is reached. */
|
|
2216
|
+
type CreditsExhaustedReason = 'balance' | 'spend_cap';
|
|
2217
|
+
/** The body of a 402 `CREDITS_EXHAUSTED` (in `error.details` / `NestCoreError.details`). */
|
|
2218
|
+
interface CreditsExhaustedDetails {
|
|
2219
|
+
code: 'CREDITS_EXHAUSTED';
|
|
2220
|
+
reason: CreditsExhaustedReason;
|
|
2221
|
+
message: string;
|
|
2222
|
+
balanceUsd: number;
|
|
2223
|
+
monthlyCapUsd: number | null;
|
|
2224
|
+
spentThisMonthUsd: number;
|
|
2225
|
+
buyUrl: string;
|
|
2226
|
+
}
|
|
2021
2227
|
|
|
2022
2228
|
/** @deprecated Renamed to {@link NestCoreClient}. */
|
|
2023
2229
|
type OrbitNestClient = NestCoreClient;
|
|
@@ -2085,4 +2291,4 @@ declare function createClient(config: NestCoreConfig & {
|
|
|
2085
2291
|
storage?: StorageAdapter;
|
|
2086
2292
|
}): NestCoreClient;
|
|
2087
2293
|
|
|
2088
|
-
export { type AiChatOptions, type AiChatResult, type AiCitation, AiClient, type AiCollection, type AiContentPart, type AiDocument, type AiEmbedResult, type AiMemory, type AiMemoryMatch, type AiMessage, type AiModel, type AiProviderId, type AiSearchResult, type AiStreamEvent, type AiThread, type AiThreadMessage, type AiThreadPart, type AiTool, type AiToolCall, type AiTrace, AnalyticsClient, type AnalyticsEvent, type AnalyticsOptions, type ApiError, type ApiResponse, type ApiResult, AuthClient, AuthLimitCodes, type AuthSession, type AuthUser, type BackgroundJob, type BackgroundJobRun, type BroadcastPayload, CollectionRef, CollectionsClient, type CreateJobOptions, DatabaseClient, type DocumentSource, EnvironmentClient, type EnvironmentVariable, type FilterValue, type FunctionInvokeOptions, type FunctionResponse, FunctionsClient, type GenerateTypesOptions, HttpClient, type ImageTransformOptions, type IngestOptions, type IngestionResult, JobsClient, type LogEntry, type LogQueryOptions, LoggingClient, type MemoryAddOptions, MemoryClient, type MfaChallenge, type MfaFactor, type NestCoreClient, type NestCoreConfig, NestCoreError, type OrbitNestClient, type OrbitNestConfig, OrbitNestError, type PaginationOptions, type PasskeyAuthenticateVerifyOptions, type PasskeyAuthenticationOptions, type PasskeyDevice, type PasskeyRegisterVerifyOptions, type PasskeyRegistrationOptions, type PasskeySignUpOptions, type PasskeySignUpVerifyOptions, type PasswordRecoveryOptions, type PasswordResetOptions, type PgChangesFilter, type PgChangesPayload, type PgEvent, type PresenceJoinCallback, type PresenceLeaveCallback, PresenceManager, type PresenceState, type PresenceSyncCallback, type QueryResult, RealtimeChannel, RealtimeClient, type RealtimeOptions, type RealtimeStatus, type RequestOptions, type RlsPolicy, type SignInCredentials, type SignUpCredentials, type StorageAdapter, StorageBucket, StorageClient, type StorageFile, type StorageListItem, type TableMetadata, ThreadRef, type ThreadRunEvent, type ThreadRunOptions, type ThreadRunResult, ThreadsClient, type UpdateJobOptions, type UpdateUserOptions, type UploadOptions, createClient, createLocalStorageAdapter, createMemoryAdapter, generateTypes, isMfaChallenge, localStorageAdapter, memoryAdapter, sanitizePath, unwrap, validatePath, validateRequired };
|
|
2294
|
+
export { type AddChunksOptions, type AiChatOptions, type AiChatResult, type AiCitation, AiClient, type AiCollection, type AiContentPart, type AiCredits, type AiDocument, type AiEmbedResult, type AiMemory, type AiMemoryMatch, type AiMessage, type AiModel, type AiProviderId, type AiSearchResult, type AiStreamEvent, type AiThread, type AiThreadMessage, type AiThreadPart, type AiTool, type AiToolCall, type AiTrace, type AiTrust, AnalyticsClient, type AnalyticsEvent, type AnalyticsOptions, type ApiError, type ApiResponse, type ApiResult, AuthClient, AuthLimitCodes, type AuthSession, type AuthUser, type BackgroundJob, type BackgroundJobRun, type BroadcastPayload, type ClientChunk, type ClientEmbedding, CollectionRef, type CollectionSearchOptions, CollectionsClient, type CreateJobOptions, type CreditsExhaustedDetails, type CreditsExhaustedReason, DatabaseClient, type DocumentSource, EnvironmentClient, type EnvironmentVariable, type FilterValue, type FunctionInvokeOptions, type FunctionResponse, FunctionsClient, type GenerateTypesOptions, HttpClient, type ImageTransformOptions, type IngestOptions, type IngestionResult, JobsClient, type LogEntry, type LogQueryOptions, LoggingClient, type MemoryAddItem, type MemoryAddOptions, MemoryClient, type MemorySearchItem, type MemorySearchOptions, type MemorySearchResult, type MemoryUpdatePatch, type MfaChallenge, type MfaFactor, type NestCoreClient, type NestCoreConfig, NestCoreError, type OrbitNestClient, type OrbitNestConfig, OrbitNestError, type PaginationOptions, type PasskeyAuthenticateVerifyOptions, type PasskeyAuthenticationOptions, type PasskeyDevice, type PasskeyRegisterVerifyOptions, type PasskeyRegistrationOptions, type PasskeySignUpOptions, type PasskeySignUpVerifyOptions, type PasswordRecoveryOptions, type PasswordResetOptions, type PgChangesFilter, type PgChangesPayload, type PgEvent, type PresenceJoinCallback, type PresenceLeaveCallback, PresenceManager, type PresenceState, type PresenceSyncCallback, ProjectErrorCodes, type QueryResult, RealtimeChannel, RealtimeClient, type RealtimeOptions, type RealtimeStatus, type RequestOptions, type RlsPolicy, type SignInCredentials, type SignUpCredentials, type StorageAdapter, StorageBucket, StorageClient, type StorageFile, type StorageListItem, type TableMetadata, ThreadRef, type ThreadRunEvent, type ThreadRunOptions, type ThreadRunResult, ThreadsClient, type UpdateJobOptions, type UpdateUserOptions, type UploadOptions, createClient, createLocalStorageAdapter, createMemoryAdapter, generateTypes, isMfaChallenge, localStorageAdapter, memoryAdapter, sanitizePath, unwrap, validatePath, validateRequired };
|