korely-memory 0.1.18 → 0.2.1
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 +25 -12
- package/dist/chunk-MZLXQMBY.js +1177 -0
- package/dist/index.cjs +209 -43
- package/dist/index.d.cts +133 -29
- package/dist/index.d.ts +133 -29
- package/dist/index.js +13 -992
- package/dist/index.node.cjs +1231 -0
- package/dist/index.node.js +34 -0
- package/package.json +10 -2
package/dist/index.d.cts
CHANGED
|
@@ -78,13 +78,25 @@ interface Memory {
|
|
|
78
78
|
/** "note" or "session" (Korely Agent 0.1.42); absent from an older server. */
|
|
79
79
|
kind?: "note" | "session";
|
|
80
80
|
}
|
|
81
|
+
/** What `search()` may search, each once in `types`: the memories, or the
|
|
82
|
+
* facts true now (Korely 1.0.13 and later). */
|
|
83
|
+
type SearchKind = "memories" | "facts";
|
|
81
84
|
interface SearchHit {
|
|
82
85
|
id?: string;
|
|
83
86
|
score?: number;
|
|
87
|
+
/** The first 280 characters of the text. */
|
|
84
88
|
snippet?: string;
|
|
85
89
|
user_id?: string;
|
|
86
90
|
agent_id?: string;
|
|
87
91
|
metadata?: Record<string, unknown>;
|
|
92
|
+
/** "memory" or "fact": in every result when the search names `types`
|
|
93
|
+
* (Korely 1.0.13 and later), absent otherwise. */
|
|
94
|
+
type?: "memory" | "fact" | string;
|
|
95
|
+
/** The whole text (a memory's as stored, a fact's line): only with
|
|
96
|
+
* `full_text: true` (Korely 1.0.13 and later). */
|
|
97
|
+
content?: string;
|
|
98
|
+
/** A fact's result: the fact as `getFacts()` shows it. Absent for a memory. */
|
|
99
|
+
fact?: Fact;
|
|
88
100
|
}
|
|
89
101
|
/** Iterable like the Python SDK's MemoryPage: `for (const m of page)` works,
|
|
90
102
|
* and `page.memories` / `page.total` still do. */
|
|
@@ -92,11 +104,18 @@ interface MemoryPage extends Iterable<Memory> {
|
|
|
92
104
|
memories: Memory[];
|
|
93
105
|
total: number;
|
|
94
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* What `delete()` did to one memory. `facts_invalidated` counts the facts it
|
|
109
|
+
* ended; `facts_reopened` the facts that are true again: facts of other
|
|
110
|
+
* memories that this one's facts had closed, given back as new rows
|
|
111
|
+
* (undefined from a server older than Korely 1.0.2, which does not send it).
|
|
112
|
+
*/
|
|
95
113
|
interface DeleteReceipt {
|
|
96
114
|
id?: string;
|
|
97
115
|
status?: string;
|
|
98
116
|
facts_invalidated?: number;
|
|
99
117
|
audit_id?: string;
|
|
118
|
+
facts_reopened?: number;
|
|
100
119
|
}
|
|
101
120
|
/**
|
|
102
121
|
* What `deleteAll` erased. Every row is physically deleted, and `erasure` is
|
|
@@ -273,13 +292,18 @@ interface AgentDeleteReceipt {
|
|
|
273
292
|
facts_deleted?: number;
|
|
274
293
|
audit_id?: string;
|
|
275
294
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
295
|
+
* @deprecated Always undefined: no Korely server sends this field, and none
|
|
296
|
+
* ever has. It stays in the type so that code reading it keeps compiling. To see
|
|
297
|
+
* whether a cap slot is free, read `cap` and `used` from `listAgents()`; the
|
|
298
|
+
* cap counts a name across the account, so the slot stays taken while
|
|
299
|
+
* another project of the account still uses the same agent_id.
|
|
281
300
|
*/
|
|
282
301
|
slot_freed?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* The facts of other agents that the namespace's facts had closed, true
|
|
304
|
+
* again as new rows (undefined from a server older than Korely 1.0.2).
|
|
305
|
+
*/
|
|
306
|
+
facts_reopened?: number;
|
|
283
307
|
}
|
|
284
308
|
/** What `ping()` answers: the key works. */
|
|
285
309
|
interface PingResponse {
|
|
@@ -306,7 +330,7 @@ interface PingResponse {
|
|
|
306
330
|
/** What the key may do, e.g. "memories:read". */
|
|
307
331
|
scopes: string[];
|
|
308
332
|
}
|
|
309
|
-
/** What `Korely.initAgent()` answers: a new
|
|
333
|
+
/** What `Korely.initAgent()` answers: a new key, when it ends, and what the account may do. */
|
|
310
334
|
interface AgentInitResult {
|
|
311
335
|
/** The key, shown this once and never again: save it. */
|
|
312
336
|
api_key: string;
|
|
@@ -315,7 +339,16 @@ interface AgentInitResult {
|
|
|
315
339
|
/** Where the new project's memories are read by a model. */
|
|
316
340
|
processing_region?: "eu" | "global";
|
|
317
341
|
scopes: string[];
|
|
318
|
-
/**
|
|
342
|
+
/** When the key stops working (ISO 8601, with its time zone). Absent from a
|
|
343
|
+
* server older than Korely Agent 1.0.10. */
|
|
344
|
+
expires_at?: string;
|
|
345
|
+
/** The same in the server's words: how long the key lasts, the trial's
|
|
346
|
+
* limits until the account is adopted, and how to adopt it. Absent from a
|
|
347
|
+
* server older than Korely Agent 1.0.10. */
|
|
348
|
+
note?: string;
|
|
349
|
+
/** The free plan's monthly allowance: writes_per_month, queries_per_month,
|
|
350
|
+
* agents, the monthly AI budget. With a `note`, it applies once the account
|
|
351
|
+
* is adopted; until then the trial's limits do. */
|
|
319
352
|
quotas: Record<string, unknown>;
|
|
320
353
|
/** The Terms of Service that creating the account accepts. Absent from a
|
|
321
354
|
* server older than Korely Agent 0.1.27. */
|
|
@@ -342,7 +375,9 @@ type AuditActor = "rest" | "mcp" | "dashboard" | "manage" | "worker" | string;
|
|
|
342
375
|
* What happened, in an audit event. An open string for the same reason as
|
|
343
376
|
* AuditActor; "tenant_create" is the Self-hosted's only.
|
|
344
377
|
*/
|
|
345
|
-
type AuditAction = "read" | "write" | "fact_write" | "fact_invalidate"
|
|
378
|
+
type AuditAction = "read" | "write" | "fact_write" | "fact_invalidate"
|
|
379
|
+
/** A memory forgotten: out of every read, its text kept (Korely 1.0.23; filed as "erase" before). */
|
|
380
|
+
| "forget" | "erase" | "key_create" | "key_revoke" | "tenant_create" | string;
|
|
346
381
|
/** For a read: what the call returned, by public id, at most 100 of each kind. Ids only, never content. */
|
|
347
382
|
interface AuditRead {
|
|
348
383
|
memories: string[];
|
|
@@ -364,6 +399,13 @@ interface AuditEvent {
|
|
|
364
399
|
ip?: string | null;
|
|
365
400
|
/** On a read, what it returned; with `known_as_of` on getFacts() or getContext() (Korely Agent 0.1.26) it rebuilds what an agent knew when it decided. */
|
|
366
401
|
read?: AuditRead | null;
|
|
402
|
+
/**
|
|
403
|
+
* The key that made the call, by the id the dashboard's Keys page lists it
|
|
404
|
+
* with, never the key itself. Null for an act with no key (a person signed
|
|
405
|
+
* in to the dashboard, the command line, the worker); undefined from a
|
|
406
|
+
* server older than Korely 1.0.23.
|
|
407
|
+
*/
|
|
408
|
+
api_key_id?: string | null;
|
|
367
409
|
}
|
|
368
410
|
/** Iterable page of the audit trail, newest first. `total` counts the matches across every page. */
|
|
369
411
|
interface AuditPage extends Iterable<AuditEvent> {
|
|
@@ -397,6 +439,14 @@ interface AddOptions {
|
|
|
397
439
|
* field with a 422.
|
|
398
440
|
*/
|
|
399
441
|
kind?: "note" | "session";
|
|
442
|
+
/**
|
|
443
|
+
* Send the same write again with the same key and it is made once (Korely
|
|
444
|
+
* Agent 1.0.27 and later; an older server ignores it). One new key per
|
|
445
|
+
* write, the same one only to send that write again: a write whose answer
|
|
446
|
+
* never came (a timeout, a 502 while the server restarted) may have been
|
|
447
|
+
* made, and without a key a resend makes it twice.
|
|
448
|
+
*/
|
|
449
|
+
idempotency_key?: string;
|
|
400
450
|
}
|
|
401
451
|
/** What `declareName` declared: in `user_id`'s memory (`agent_id` the
|
|
402
452
|
* namespace, none for the end user's own) the facts about `name` read as the
|
|
@@ -429,6 +479,22 @@ interface SearchOptions {
|
|
|
429
479
|
min_score?: number;
|
|
430
480
|
/** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
|
|
431
481
|
exclude_sessions?: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* What to search, each kind once: `["memories"]` (what the server searches
|
|
484
|
+
* when it is not sent), `["facts"]`, the facts true now, or both, each kind
|
|
485
|
+
* ranked by its own score and the rankings merged by rank (a fact's score
|
|
486
|
+
* and a memory's are not to be compared). Every result then says its
|
|
487
|
+
* `type`, and a fact's carries `fact`. `run_id`, `metadata` and `min_score`
|
|
488
|
+
* narrow the memories only: with `"facts"` the server answers 422. Sent
|
|
489
|
+
* only when given: Korely 1.0.13 and later; an older server answers 422.
|
|
490
|
+
*/
|
|
491
|
+
types?: SearchKind[];
|
|
492
|
+
/**
|
|
493
|
+
* Also return each result's whole text as `content`; `snippet` stays its
|
|
494
|
+
* first 280 characters. A memory can hold 16,000 characters. Sent only
|
|
495
|
+
* when true: Korely 1.0.13 and later; an older server answers 422.
|
|
496
|
+
*/
|
|
497
|
+
full_text?: boolean;
|
|
432
498
|
}
|
|
433
499
|
interface ListOptions {
|
|
434
500
|
user_id?: string;
|
|
@@ -559,7 +625,7 @@ interface ForgetReceipt {
|
|
|
559
625
|
|
|
560
626
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
561
627
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
562
|
-
declare const VERSION = "0.1
|
|
628
|
+
declare const VERSION = "0.2.1";
|
|
563
629
|
interface KorelyOptions {
|
|
564
630
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
565
631
|
apiKey?: string;
|
|
@@ -601,15 +667,18 @@ declare class Korely {
|
|
|
601
667
|
private readonly fetchImpl;
|
|
602
668
|
constructor(opts?: KorelyOptions);
|
|
603
669
|
/**
|
|
604
|
-
* POST /v1/agents/init, with no key: sign up for a
|
|
670
|
+
* POST /v1/agents/init, with no key: sign up for a key that costs nothing.
|
|
605
671
|
*
|
|
606
672
|
* The one call that runs without a key, because it is how one is obtained,
|
|
607
673
|
* so it is static: `await Korely.initAgent("my-app")`, then
|
|
608
674
|
* `new Korely({ apiKey: result.api_key })`. `agentCaller` is a free-form
|
|
609
675
|
* label of who signed up, kept for your reference. The answer carries the
|
|
610
|
-
* key, shown once (save it),
|
|
676
|
+
* key, shown once (save it), when it stops working (`expires_at`), the
|
|
677
|
+
* trial in words (`note`: its limits until the account is adopted, and how
|
|
678
|
+
* to adopt it), its `tier`, `region`, `scopes` and `quotas` (the monthly
|
|
679
|
+
* numbers once adopted).
|
|
611
680
|
* The account it creates has no login: the key is the account, and
|
|
612
|
-
* `deleteAccount({ confirm:
|
|
681
|
+
* `deleteAccount({ confirm: "<the account's id>" })` closes it.
|
|
613
682
|
*
|
|
614
683
|
* Cloud only. The server is `baseUrl`, else KORELY_BASE_URL, else the
|
|
615
684
|
* region's. Refusals: 403 `signup_disabled` (NamespaceForbiddenError) when
|
|
@@ -631,15 +700,36 @@ declare class Korely {
|
|
|
631
700
|
*/
|
|
632
701
|
ping(): Promise<PingResponse>;
|
|
633
702
|
/**
|
|
634
|
-
* DELETE /v1/account?confirm
|
|
635
|
-
* with every key, project, memory, fact and webhook of it; the
|
|
636
|
-
* working. Cloud only, for an account made by `Korely.initAgent()`
|
|
637
|
-
* `korely init --agent`, which nobody signs in to: the key is the
|
|
638
|
-
* and this is how it is closed (GDPR Art. 17).
|
|
703
|
+
* DELETE /v1/account?confirm=<the account's id>: delete the account of this
|
|
704
|
+
* key for good, with every key, project, memory, fact and webhook of it; the
|
|
705
|
+
* key stops working. Cloud only, for an account made by `Korely.initAgent()`
|
|
706
|
+
* or `korely init --agent`, which nobody signs in to: the key is the
|
|
707
|
+
* account, and this is how it is closed (GDPR Art. 17).
|
|
708
|
+
*
|
|
709
|
+
* `confirm` is the account's id, typed by whoever means it, as the
|
|
710
|
+
* dashboard has the email typed: `tenant_id` of GET /admin/whoami, which the
|
|
711
|
+
* error below gives. So a key that leaked, or a script pointed at the wrong
|
|
712
|
+
* key, is not enough with a flag (Korely 1.0.23 asks the same of the
|
|
713
|
+
* server's route). Nothing is deleted, and the DELETE is not sent, unless
|
|
714
|
+
* `confirm` is a UUID equal, spaces trimmed, to the `tenant_id` that GET
|
|
715
|
+
* /admin/whoami gives this key: a missing, `true`, `"true"` or wrong
|
|
716
|
+
* `confirm` rejects with a KorelyError whose `code` is
|
|
717
|
+
* `confirmation_required` (the server's code for the same refusal) and
|
|
718
|
+
* whose message names the id to type when the key may read it. A key that
|
|
719
|
+
* may not read GET /admin/whoami (403, a key without the `admin` scope)
|
|
720
|
+
* deletes nothing: with no id typed it rejects with that same
|
|
721
|
+
* `confirmation_required`, whose message says whoami could not be read;
|
|
722
|
+
* with the id typed, with the server's refusal of the whoami,
|
|
723
|
+
* NamespaceForbiddenError (an APIError, `status` 403, `code` `forbidden`).
|
|
639
724
|
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
725
|
+
* The account is deleted only on the server's answer that says so
|
|
726
|
+
* (`deleted: true`); any other answer, a redirect (never followed: the
|
|
727
|
+
* DELETE is not a GET) or a 2xx without it, rejects, and the account may
|
|
728
|
+
* still be there. A server older
|
|
729
|
+
* than 1.0.23 takes only `?confirm=true` and refuses the id (422): that
|
|
730
|
+
* rejects with an APIError whose `code` is `server_too_old`, nothing is
|
|
731
|
+
* deleted, and the client does not fall back to the flag. Upgrade the
|
|
732
|
+
* server, or use korely-memory 0.1.18.
|
|
643
733
|
*
|
|
644
734
|
* An account with a Korely login rejects with 409 `account_has_login`
|
|
645
735
|
* (ConflictError): a key that ended up in a log must not be able to delete
|
|
@@ -648,8 +738,15 @@ declare class Korely {
|
|
|
648
738
|
* dashboard. No audit event survives: the trail is part of what goes.
|
|
649
739
|
*/
|
|
650
740
|
deleteAccount(opts?: {
|
|
651
|
-
confirm?:
|
|
741
|
+
confirm?: string;
|
|
652
742
|
}): Promise<AccountDeleteReceipt>;
|
|
743
|
+
/** The id of this key's account: `tenant_id` of GET /admin/whoami, checked
|
|
744
|
+
* as an account id (`accountId`). The errors of the call reject as they
|
|
745
|
+
* come. */
|
|
746
|
+
private accountOfThisKey;
|
|
747
|
+
/** The refusal of a deletion not confirmed, naming the id to type when this
|
|
748
|
+
* key may read it. */
|
|
749
|
+
private notConfirmed;
|
|
653
750
|
/**
|
|
654
751
|
* GET /v1/audit: what this key's project did, and what its agents read,
|
|
655
752
|
* newest first (`ts` descending, then the event's id, so paging with
|
|
@@ -696,9 +793,11 @@ declare class Korely {
|
|
|
696
793
|
add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
|
|
697
794
|
/**
|
|
698
795
|
* POST /v1/memories/search: semantic search over raw memories, ranked by
|
|
699
|
-
* score (vector similarity to the query)
|
|
700
|
-
*
|
|
701
|
-
*
|
|
796
|
+
* score (vector similarity to the query); with `types`, over the facts too,
|
|
797
|
+
* or the facts only. `run_id` scopes to one session, `metadata` filters on
|
|
798
|
+
* what you stored at write time. `limit` defaults to the server default
|
|
799
|
+
* (15), max 50. `full_text: true` adds each result's whole text as
|
|
800
|
+
* `content`.
|
|
702
801
|
*/
|
|
703
802
|
search(query: string, opts?: SearchOptions): Promise<SearchHit[]>;
|
|
704
803
|
/**
|
|
@@ -728,7 +827,8 @@ declare class Korely {
|
|
|
728
827
|
/**
|
|
729
828
|
* DELETE /v1/memories/:id: forget one memory. It drops out of every default
|
|
730
829
|
* read, and the facts only it asserted are invalidated (kept as history,
|
|
731
|
-
* audited).
|
|
830
|
+
* audited). The facts its facts had closed are true again: the receipt
|
|
831
|
+
* counts them in `facts_reopened`. For erasure use `deleteAll`.
|
|
732
832
|
*/
|
|
733
833
|
delete(memoryId: string): Promise<DeleteReceipt>;
|
|
734
834
|
/**
|
|
@@ -771,14 +871,16 @@ declare class Korely {
|
|
|
771
871
|
* DELETE /v1/agents/:agent_id: hard-delete an agent namespace, purging every
|
|
772
872
|
* memory + fact written under this agent_id in this key's project
|
|
773
873
|
* (soft-forgetting its data does NOT free its cap slot; this does). Resolves
|
|
774
|
-
* to the purge counts
|
|
874
|
+
* to the purge counts and an audit id. Its `slot_freed` is always
|
|
875
|
+
* undefined: no Korely server sends it, and none ever has. To see whether a
|
|
876
|
+
* cap slot is free, read `cap` and `used` from `listAgents()`.
|
|
775
877
|
*
|
|
776
878
|
* The namespace must be one `listAgents()` shows for this key: anything else
|
|
777
879
|
* rejects with NotFoundError, including a name only another project of the
|
|
778
880
|
* account uses (the server answered 200 with zero counts for it before
|
|
779
881
|
* 2026-09-28, and freed nothing). The cap counts a name across the account,
|
|
780
882
|
* so while another project still uses the same agent_id its rows stay and
|
|
781
|
-
*
|
|
883
|
+
* the slot stays taken.
|
|
782
884
|
*/
|
|
783
885
|
deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
|
|
784
886
|
/**
|
|
@@ -884,7 +986,9 @@ declare class Korely {
|
|
|
884
986
|
* `too_many_batches` (TooManyBatchesError) while three batches are still
|
|
885
987
|
* being imported. The Self-hosted meters nothing and refuses neither.
|
|
886
988
|
*/
|
|
887
|
-
batch(memories: Array<BatchMemory | Record<string, unknown
|
|
989
|
+
batch(memories: Array<BatchMemory | Record<string, unknown>>, opts?: {
|
|
990
|
+
idempotency_key?: string;
|
|
991
|
+
}): Promise<BatchJob>;
|
|
888
992
|
/** GET /v1/batch/:id: poll an import job. */
|
|
889
993
|
batchStatus(jobId: string): Promise<BatchJob>;
|
|
890
994
|
}
|
|
@@ -1033,4 +1137,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
|
|
|
1033
1137
|
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
1034
1138
|
}
|
|
1035
1139
|
|
|
1036
|
-
export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
|
|
1140
|
+
export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchKind, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,13 +78,25 @@ interface Memory {
|
|
|
78
78
|
/** "note" or "session" (Korely Agent 0.1.42); absent from an older server. */
|
|
79
79
|
kind?: "note" | "session";
|
|
80
80
|
}
|
|
81
|
+
/** What `search()` may search, each once in `types`: the memories, or the
|
|
82
|
+
* facts true now (Korely 1.0.13 and later). */
|
|
83
|
+
type SearchKind = "memories" | "facts";
|
|
81
84
|
interface SearchHit {
|
|
82
85
|
id?: string;
|
|
83
86
|
score?: number;
|
|
87
|
+
/** The first 280 characters of the text. */
|
|
84
88
|
snippet?: string;
|
|
85
89
|
user_id?: string;
|
|
86
90
|
agent_id?: string;
|
|
87
91
|
metadata?: Record<string, unknown>;
|
|
92
|
+
/** "memory" or "fact": in every result when the search names `types`
|
|
93
|
+
* (Korely 1.0.13 and later), absent otherwise. */
|
|
94
|
+
type?: "memory" | "fact" | string;
|
|
95
|
+
/** The whole text (a memory's as stored, a fact's line): only with
|
|
96
|
+
* `full_text: true` (Korely 1.0.13 and later). */
|
|
97
|
+
content?: string;
|
|
98
|
+
/** A fact's result: the fact as `getFacts()` shows it. Absent for a memory. */
|
|
99
|
+
fact?: Fact;
|
|
88
100
|
}
|
|
89
101
|
/** Iterable like the Python SDK's MemoryPage: `for (const m of page)` works,
|
|
90
102
|
* and `page.memories` / `page.total` still do. */
|
|
@@ -92,11 +104,18 @@ interface MemoryPage extends Iterable<Memory> {
|
|
|
92
104
|
memories: Memory[];
|
|
93
105
|
total: number;
|
|
94
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* What `delete()` did to one memory. `facts_invalidated` counts the facts it
|
|
109
|
+
* ended; `facts_reopened` the facts that are true again: facts of other
|
|
110
|
+
* memories that this one's facts had closed, given back as new rows
|
|
111
|
+
* (undefined from a server older than Korely 1.0.2, which does not send it).
|
|
112
|
+
*/
|
|
95
113
|
interface DeleteReceipt {
|
|
96
114
|
id?: string;
|
|
97
115
|
status?: string;
|
|
98
116
|
facts_invalidated?: number;
|
|
99
117
|
audit_id?: string;
|
|
118
|
+
facts_reopened?: number;
|
|
100
119
|
}
|
|
101
120
|
/**
|
|
102
121
|
* What `deleteAll` erased. Every row is physically deleted, and `erasure` is
|
|
@@ -273,13 +292,18 @@ interface AgentDeleteReceipt {
|
|
|
273
292
|
facts_deleted?: number;
|
|
274
293
|
audit_id?: string;
|
|
275
294
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
295
|
+
* @deprecated Always undefined: no Korely server sends this field, and none
|
|
296
|
+
* ever has. It stays in the type so that code reading it keeps compiling. To see
|
|
297
|
+
* whether a cap slot is free, read `cap` and `used` from `listAgents()`; the
|
|
298
|
+
* cap counts a name across the account, so the slot stays taken while
|
|
299
|
+
* another project of the account still uses the same agent_id.
|
|
281
300
|
*/
|
|
282
301
|
slot_freed?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* The facts of other agents that the namespace's facts had closed, true
|
|
304
|
+
* again as new rows (undefined from a server older than Korely 1.0.2).
|
|
305
|
+
*/
|
|
306
|
+
facts_reopened?: number;
|
|
283
307
|
}
|
|
284
308
|
/** What `ping()` answers: the key works. */
|
|
285
309
|
interface PingResponse {
|
|
@@ -306,7 +330,7 @@ interface PingResponse {
|
|
|
306
330
|
/** What the key may do, e.g. "memories:read". */
|
|
307
331
|
scopes: string[];
|
|
308
332
|
}
|
|
309
|
-
/** What `Korely.initAgent()` answers: a new
|
|
333
|
+
/** What `Korely.initAgent()` answers: a new key, when it ends, and what the account may do. */
|
|
310
334
|
interface AgentInitResult {
|
|
311
335
|
/** The key, shown this once and never again: save it. */
|
|
312
336
|
api_key: string;
|
|
@@ -315,7 +339,16 @@ interface AgentInitResult {
|
|
|
315
339
|
/** Where the new project's memories are read by a model. */
|
|
316
340
|
processing_region?: "eu" | "global";
|
|
317
341
|
scopes: string[];
|
|
318
|
-
/**
|
|
342
|
+
/** When the key stops working (ISO 8601, with its time zone). Absent from a
|
|
343
|
+
* server older than Korely Agent 1.0.10. */
|
|
344
|
+
expires_at?: string;
|
|
345
|
+
/** The same in the server's words: how long the key lasts, the trial's
|
|
346
|
+
* limits until the account is adopted, and how to adopt it. Absent from a
|
|
347
|
+
* server older than Korely Agent 1.0.10. */
|
|
348
|
+
note?: string;
|
|
349
|
+
/** The free plan's monthly allowance: writes_per_month, queries_per_month,
|
|
350
|
+
* agents, the monthly AI budget. With a `note`, it applies once the account
|
|
351
|
+
* is adopted; until then the trial's limits do. */
|
|
319
352
|
quotas: Record<string, unknown>;
|
|
320
353
|
/** The Terms of Service that creating the account accepts. Absent from a
|
|
321
354
|
* server older than Korely Agent 0.1.27. */
|
|
@@ -342,7 +375,9 @@ type AuditActor = "rest" | "mcp" | "dashboard" | "manage" | "worker" | string;
|
|
|
342
375
|
* What happened, in an audit event. An open string for the same reason as
|
|
343
376
|
* AuditActor; "tenant_create" is the Self-hosted's only.
|
|
344
377
|
*/
|
|
345
|
-
type AuditAction = "read" | "write" | "fact_write" | "fact_invalidate"
|
|
378
|
+
type AuditAction = "read" | "write" | "fact_write" | "fact_invalidate"
|
|
379
|
+
/** A memory forgotten: out of every read, its text kept (Korely 1.0.23; filed as "erase" before). */
|
|
380
|
+
| "forget" | "erase" | "key_create" | "key_revoke" | "tenant_create" | string;
|
|
346
381
|
/** For a read: what the call returned, by public id, at most 100 of each kind. Ids only, never content. */
|
|
347
382
|
interface AuditRead {
|
|
348
383
|
memories: string[];
|
|
@@ -364,6 +399,13 @@ interface AuditEvent {
|
|
|
364
399
|
ip?: string | null;
|
|
365
400
|
/** On a read, what it returned; with `known_as_of` on getFacts() or getContext() (Korely Agent 0.1.26) it rebuilds what an agent knew when it decided. */
|
|
366
401
|
read?: AuditRead | null;
|
|
402
|
+
/**
|
|
403
|
+
* The key that made the call, by the id the dashboard's Keys page lists it
|
|
404
|
+
* with, never the key itself. Null for an act with no key (a person signed
|
|
405
|
+
* in to the dashboard, the command line, the worker); undefined from a
|
|
406
|
+
* server older than Korely 1.0.23.
|
|
407
|
+
*/
|
|
408
|
+
api_key_id?: string | null;
|
|
367
409
|
}
|
|
368
410
|
/** Iterable page of the audit trail, newest first. `total` counts the matches across every page. */
|
|
369
411
|
interface AuditPage extends Iterable<AuditEvent> {
|
|
@@ -397,6 +439,14 @@ interface AddOptions {
|
|
|
397
439
|
* field with a 422.
|
|
398
440
|
*/
|
|
399
441
|
kind?: "note" | "session";
|
|
442
|
+
/**
|
|
443
|
+
* Send the same write again with the same key and it is made once (Korely
|
|
444
|
+
* Agent 1.0.27 and later; an older server ignores it). One new key per
|
|
445
|
+
* write, the same one only to send that write again: a write whose answer
|
|
446
|
+
* never came (a timeout, a 502 while the server restarted) may have been
|
|
447
|
+
* made, and without a key a resend makes it twice.
|
|
448
|
+
*/
|
|
449
|
+
idempotency_key?: string;
|
|
400
450
|
}
|
|
401
451
|
/** What `declareName` declared: in `user_id`'s memory (`agent_id` the
|
|
402
452
|
* namespace, none for the end user's own) the facts about `name` read as the
|
|
@@ -429,6 +479,22 @@ interface SearchOptions {
|
|
|
429
479
|
min_score?: number;
|
|
430
480
|
/** Leave out the work sessions (`kind: "session"`) and what only they stated (Korely Agent 0.1.42). */
|
|
431
481
|
exclude_sessions?: boolean;
|
|
482
|
+
/**
|
|
483
|
+
* What to search, each kind once: `["memories"]` (what the server searches
|
|
484
|
+
* when it is not sent), `["facts"]`, the facts true now, or both, each kind
|
|
485
|
+
* ranked by its own score and the rankings merged by rank (a fact's score
|
|
486
|
+
* and a memory's are not to be compared). Every result then says its
|
|
487
|
+
* `type`, and a fact's carries `fact`. `run_id`, `metadata` and `min_score`
|
|
488
|
+
* narrow the memories only: with `"facts"` the server answers 422. Sent
|
|
489
|
+
* only when given: Korely 1.0.13 and later; an older server answers 422.
|
|
490
|
+
*/
|
|
491
|
+
types?: SearchKind[];
|
|
492
|
+
/**
|
|
493
|
+
* Also return each result's whole text as `content`; `snippet` stays its
|
|
494
|
+
* first 280 characters. A memory can hold 16,000 characters. Sent only
|
|
495
|
+
* when true: Korely 1.0.13 and later; an older server answers 422.
|
|
496
|
+
*/
|
|
497
|
+
full_text?: boolean;
|
|
432
498
|
}
|
|
433
499
|
interface ListOptions {
|
|
434
500
|
user_id?: string;
|
|
@@ -559,7 +625,7 @@ interface ForgetReceipt {
|
|
|
559
625
|
|
|
560
626
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
561
627
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
562
|
-
declare const VERSION = "0.1
|
|
628
|
+
declare const VERSION = "0.2.1";
|
|
563
629
|
interface KorelyOptions {
|
|
564
630
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
565
631
|
apiKey?: string;
|
|
@@ -601,15 +667,18 @@ declare class Korely {
|
|
|
601
667
|
private readonly fetchImpl;
|
|
602
668
|
constructor(opts?: KorelyOptions);
|
|
603
669
|
/**
|
|
604
|
-
* POST /v1/agents/init, with no key: sign up for a
|
|
670
|
+
* POST /v1/agents/init, with no key: sign up for a key that costs nothing.
|
|
605
671
|
*
|
|
606
672
|
* The one call that runs without a key, because it is how one is obtained,
|
|
607
673
|
* so it is static: `await Korely.initAgent("my-app")`, then
|
|
608
674
|
* `new Korely({ apiKey: result.api_key })`. `agentCaller` is a free-form
|
|
609
675
|
* label of who signed up, kept for your reference. The answer carries the
|
|
610
|
-
* key, shown once (save it),
|
|
676
|
+
* key, shown once (save it), when it stops working (`expires_at`), the
|
|
677
|
+
* trial in words (`note`: its limits until the account is adopted, and how
|
|
678
|
+
* to adopt it), its `tier`, `region`, `scopes` and `quotas` (the monthly
|
|
679
|
+
* numbers once adopted).
|
|
611
680
|
* The account it creates has no login: the key is the account, and
|
|
612
|
-
* `deleteAccount({ confirm:
|
|
681
|
+
* `deleteAccount({ confirm: "<the account's id>" })` closes it.
|
|
613
682
|
*
|
|
614
683
|
* Cloud only. The server is `baseUrl`, else KORELY_BASE_URL, else the
|
|
615
684
|
* region's. Refusals: 403 `signup_disabled` (NamespaceForbiddenError) when
|
|
@@ -631,15 +700,36 @@ declare class Korely {
|
|
|
631
700
|
*/
|
|
632
701
|
ping(): Promise<PingResponse>;
|
|
633
702
|
/**
|
|
634
|
-
* DELETE /v1/account?confirm
|
|
635
|
-
* with every key, project, memory, fact and webhook of it; the
|
|
636
|
-
* working. Cloud only, for an account made by `Korely.initAgent()`
|
|
637
|
-
* `korely init --agent`, which nobody signs in to: the key is the
|
|
638
|
-
* and this is how it is closed (GDPR Art. 17).
|
|
703
|
+
* DELETE /v1/account?confirm=<the account's id>: delete the account of this
|
|
704
|
+
* key for good, with every key, project, memory, fact and webhook of it; the
|
|
705
|
+
* key stops working. Cloud only, for an account made by `Korely.initAgent()`
|
|
706
|
+
* or `korely init --agent`, which nobody signs in to: the key is the
|
|
707
|
+
* account, and this is how it is closed (GDPR Art. 17).
|
|
708
|
+
*
|
|
709
|
+
* `confirm` is the account's id, typed by whoever means it, as the
|
|
710
|
+
* dashboard has the email typed: `tenant_id` of GET /admin/whoami, which the
|
|
711
|
+
* error below gives. So a key that leaked, or a script pointed at the wrong
|
|
712
|
+
* key, is not enough with a flag (Korely 1.0.23 asks the same of the
|
|
713
|
+
* server's route). Nothing is deleted, and the DELETE is not sent, unless
|
|
714
|
+
* `confirm` is a UUID equal, spaces trimmed, to the `tenant_id` that GET
|
|
715
|
+
* /admin/whoami gives this key: a missing, `true`, `"true"` or wrong
|
|
716
|
+
* `confirm` rejects with a KorelyError whose `code` is
|
|
717
|
+
* `confirmation_required` (the server's code for the same refusal) and
|
|
718
|
+
* whose message names the id to type when the key may read it. A key that
|
|
719
|
+
* may not read GET /admin/whoami (403, a key without the `admin` scope)
|
|
720
|
+
* deletes nothing: with no id typed it rejects with that same
|
|
721
|
+
* `confirmation_required`, whose message says whoami could not be read;
|
|
722
|
+
* with the id typed, with the server's refusal of the whoami,
|
|
723
|
+
* NamespaceForbiddenError (an APIError, `status` 403, `code` `forbidden`).
|
|
639
724
|
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
725
|
+
* The account is deleted only on the server's answer that says so
|
|
726
|
+
* (`deleted: true`); any other answer, a redirect (never followed: the
|
|
727
|
+
* DELETE is not a GET) or a 2xx without it, rejects, and the account may
|
|
728
|
+
* still be there. A server older
|
|
729
|
+
* than 1.0.23 takes only `?confirm=true` and refuses the id (422): that
|
|
730
|
+
* rejects with an APIError whose `code` is `server_too_old`, nothing is
|
|
731
|
+
* deleted, and the client does not fall back to the flag. Upgrade the
|
|
732
|
+
* server, or use korely-memory 0.1.18.
|
|
643
733
|
*
|
|
644
734
|
* An account with a Korely login rejects with 409 `account_has_login`
|
|
645
735
|
* (ConflictError): a key that ended up in a log must not be able to delete
|
|
@@ -648,8 +738,15 @@ declare class Korely {
|
|
|
648
738
|
* dashboard. No audit event survives: the trail is part of what goes.
|
|
649
739
|
*/
|
|
650
740
|
deleteAccount(opts?: {
|
|
651
|
-
confirm?:
|
|
741
|
+
confirm?: string;
|
|
652
742
|
}): Promise<AccountDeleteReceipt>;
|
|
743
|
+
/** The id of this key's account: `tenant_id` of GET /admin/whoami, checked
|
|
744
|
+
* as an account id (`accountId`). The errors of the call reject as they
|
|
745
|
+
* come. */
|
|
746
|
+
private accountOfThisKey;
|
|
747
|
+
/** The refusal of a deletion not confirmed, naming the id to type when this
|
|
748
|
+
* key may read it. */
|
|
749
|
+
private notConfirmed;
|
|
653
750
|
/**
|
|
654
751
|
* GET /v1/audit: what this key's project did, and what its agents read,
|
|
655
752
|
* newest first (`ts` descending, then the event's id, so paging with
|
|
@@ -696,9 +793,11 @@ declare class Korely {
|
|
|
696
793
|
add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
|
|
697
794
|
/**
|
|
698
795
|
* POST /v1/memories/search: semantic search over raw memories, ranked by
|
|
699
|
-
* score (vector similarity to the query)
|
|
700
|
-
*
|
|
701
|
-
*
|
|
796
|
+
* score (vector similarity to the query); with `types`, over the facts too,
|
|
797
|
+
* or the facts only. `run_id` scopes to one session, `metadata` filters on
|
|
798
|
+
* what you stored at write time. `limit` defaults to the server default
|
|
799
|
+
* (15), max 50. `full_text: true` adds each result's whole text as
|
|
800
|
+
* `content`.
|
|
702
801
|
*/
|
|
703
802
|
search(query: string, opts?: SearchOptions): Promise<SearchHit[]>;
|
|
704
803
|
/**
|
|
@@ -728,7 +827,8 @@ declare class Korely {
|
|
|
728
827
|
/**
|
|
729
828
|
* DELETE /v1/memories/:id: forget one memory. It drops out of every default
|
|
730
829
|
* read, and the facts only it asserted are invalidated (kept as history,
|
|
731
|
-
* audited).
|
|
830
|
+
* audited). The facts its facts had closed are true again: the receipt
|
|
831
|
+
* counts them in `facts_reopened`. For erasure use `deleteAll`.
|
|
732
832
|
*/
|
|
733
833
|
delete(memoryId: string): Promise<DeleteReceipt>;
|
|
734
834
|
/**
|
|
@@ -771,14 +871,16 @@ declare class Korely {
|
|
|
771
871
|
* DELETE /v1/agents/:agent_id: hard-delete an agent namespace, purging every
|
|
772
872
|
* memory + fact written under this agent_id in this key's project
|
|
773
873
|
* (soft-forgetting its data does NOT free its cap slot; this does). Resolves
|
|
774
|
-
* to the purge counts
|
|
874
|
+
* to the purge counts and an audit id. Its `slot_freed` is always
|
|
875
|
+
* undefined: no Korely server sends it, and none ever has. To see whether a
|
|
876
|
+
* cap slot is free, read `cap` and `used` from `listAgents()`.
|
|
775
877
|
*
|
|
776
878
|
* The namespace must be one `listAgents()` shows for this key: anything else
|
|
777
879
|
* rejects with NotFoundError, including a name only another project of the
|
|
778
880
|
* account uses (the server answered 200 with zero counts for it before
|
|
779
881
|
* 2026-09-28, and freed nothing). The cap counts a name across the account,
|
|
780
882
|
* so while another project still uses the same agent_id its rows stay and
|
|
781
|
-
*
|
|
883
|
+
* the slot stays taken.
|
|
782
884
|
*/
|
|
783
885
|
deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
|
|
784
886
|
/**
|
|
@@ -884,7 +986,9 @@ declare class Korely {
|
|
|
884
986
|
* `too_many_batches` (TooManyBatchesError) while three batches are still
|
|
885
987
|
* being imported. The Self-hosted meters nothing and refuses neither.
|
|
886
988
|
*/
|
|
887
|
-
batch(memories: Array<BatchMemory | Record<string, unknown
|
|
989
|
+
batch(memories: Array<BatchMemory | Record<string, unknown>>, opts?: {
|
|
990
|
+
idempotency_key?: string;
|
|
991
|
+
}): Promise<BatchJob>;
|
|
888
992
|
/** GET /v1/batch/:id: poll an import job. */
|
|
889
993
|
batchStatus(jobId: string): Promise<BatchJob>;
|
|
890
994
|
}
|
|
@@ -1033,4 +1137,4 @@ declare class TooManyBatchesError extends QuotaExceededError {
|
|
|
1033
1137
|
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
1034
1138
|
}
|
|
1035
1139
|
|
|
1036
|
-
export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
|
|
1140
|
+
export { APIError, type AccountDeleteReceipt, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentInitResult, type AgentScope, type AgentsPage, type AuditAction, type AuditActor, type AuditEvent, type AuditOptions, type AuditPage, type AuditRead, AuthenticationError, type BatchJob, type BatchMemory, type BulkReceipt, ConflictError, type Context, type DeclareNameOptions, type DeclaredName, type DeleteReceipt, type EventsOptions, type EventsResponse, type Fact, type FactList, type ForgetReceipt, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, type InitAgentOptions, type IterAuditOptions, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryEvent, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type PingResponse, type Profile, QuotaExceededError, type SearchHit, type SearchKind, type SearchOptions, StaleWriteError, TooManyBatchesError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
|