korely-memory 0.1.18 → 0.2.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 +14 -7
- package/dist/chunk-VT7GXOPS.js +1131 -0
- package/dist/index.cjs +147 -27
- package/dist/index.d.cts +72 -20
- package/dist/index.d.ts +72 -20
- package/dist/index.js +13 -992
- package/dist/index.node.cjs +1185 -0
- package/dist/index.node.js +34 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -99,12 +99,12 @@ Every method maps to one REST endpoint.
|
|
|
99
99
|
| `getAll(opts?)` | `GET /v1/memories` | List a scope, newest first. The page is iterable; `limit` up to 200. |
|
|
100
100
|
| `get(id)` | `GET /v1/memories/:id` | One memory, with its facts. |
|
|
101
101
|
| `update(id, { content })` | `PATCH /v1/memories/:id` | Re-runs extraction. |
|
|
102
|
-
| `delete(id)` | `DELETE /v1/memories/:id` | Forget one (audited). |
|
|
102
|
+
| `delete(id)` | `DELETE /v1/memories/:id` | Forget one (audited). `facts_reopened` counts the facts it made true again. |
|
|
103
103
|
| `deleteAll({ user_id })` | `DELETE /v1/users/:user_id/memories` | Erase everything about one end user in one call. The receipt counts `memories_deleted` and `facts_deleted`. |
|
|
104
104
|
| `history(id)` | `GET /v1/memories/:id/history` | A memory's timeline + the facts it produced. |
|
|
105
105
|
| `users(opts?)` | `GET /v1/users` | Your end users, with counts. |
|
|
106
106
|
| `listAgents(opts?)` | `GET /v1/agents` | This project's agent namespaces, with counts. `total` counts this project's names, `used` the cap slots taken across the account. Call after `agent_cap_exceeded` to reuse an id. |
|
|
107
|
-
| `deleteAgent(agentId)` | `DELETE /v1/agents/:agent_id` | Purge an agent namespace of this project. `NotFoundError` for a name the project does not use; `slot_freed`
|
|
107
|
+
| `deleteAgent(agentId)` | `DELETE /v1/agents/:agent_id` | Purge an agent namespace of this project. `NotFoundError` for a name the project does not use; the receipt's `slot_freed` is always undefined, because no Korely server sends it: read `cap` and `used` from `listAgents()` to see whether a slot is free. |
|
|
108
108
|
| `getFacts(opts?)` | `GET /v1/facts` | Typed facts; `as_of` for what was true on a date, `known_as_of` for what the store knew on it. The array also carries `total`. |
|
|
109
109
|
| `addFactTriple(s, p, o, opts?)` | `POST /v1/facts` | Write a fact directly (bi-temporal; `tense: "past"` for one that is over). |
|
|
110
110
|
| `correctFact(id, changes)` | `PATCH /v1/facts/:id` | Supersede a fact with a corrected one; `invalidated` lists what it closed. Restating the fact as it stands reconfirms it (`invalidated: []`). |
|
|
@@ -116,8 +116,8 @@ Every method maps to one REST endpoint.
|
|
|
116
116
|
| `batchStatus(jobId)` | `GET /v1/batch/:id` | Poll an import job. |
|
|
117
117
|
| `ping()` | `GET /v1/ping` | Check a key without spending anything (no scope, rate limit or quota): its `tier`, `region` and `scopes`. Both products. |
|
|
118
118
|
| `Korely.initAgent(agentCaller?, opts?)` | `POST /v1/agents/init` | Cloud only. Static, no key needed: sign up for a free hobby key (shown once, save it), then `new Korely({ apiKey: result.api_key })`. `opts` takes `baseUrl`, `region`, `timeoutMs`, `fetch`. |
|
|
119
|
-
| `deleteAccount({ confirm:
|
|
120
|
-
| `audit(opts?)` | `GET /v1/audit` | The trail of the key's project, newest first: `user_id`, `action`, `since` / `until` (ISO text or `Date`), `limit` up to 1000. Ids, never content. Both products; needs `memories:read`, costs no quota. |
|
|
119
|
+
| `deleteAccount({ confirm: "<account id>" })` | `DELETE /v1/account` | Cloud only. Delete the key's account for good, every key, memory and fact; for an account `korely init --agent` made, which nobody signs in to. One with a login rejects with `ConflictError` (`account_has_login`). `confirm` is the account's id, typed (`tenant_id` of `GET /admin/whoami`): the DELETE is sent only when it is a UUID equal, spaces trimmed, to the id `GET /admin/whoami` gives the key. Missing, `true`, `"true"` or another id: nothing is sent but that GET, and it rejects with `KorelyError` `confirmation_required`, whose message names the id to type. Only the answer `deleted: true` is a deletion; any other rejects. A server older than 1.0.23 takes only `?confirm=true`: the client does not fall back to it, deletes nothing and rejects with `APIError` `server_too_old` (upgrade the server, or use korely-memory 0.1.18). A key that may not read `GET /admin/whoami` (403, a key without the `admin` scope) deletes nothing: with no id typed it rejects with that `confirmation_required`, whose message says whoami could not be read; with the id typed, with the whoami's refusal, `NamespaceForbiddenError` (an `APIError`, `status` 403, `code` `forbidden`). The Self-hosted, which has no such route, stops at that 403 for a key without the `admin` scope, else answers 404 (405 where it serves its dashboard). |
|
|
120
|
+
| `audit(opts?)` | `GET /v1/audit` | The trail of the key's project, newest first: `user_id`, `action`, `since` / `until` (ISO text or `Date`), `limit` up to 1000. Ids, never content. Each event's `api_key_id` names the key that made the call (Korely 1.0.23); `action` is `forget` for a memory forgotten with its text kept, `erase` for one gone for good, `fact_invalidate` for a fact closed (a forget was filed as `erase` before 1.0.23). Both products; needs `memories:read`, costs no quota. |
|
|
121
121
|
| `iterAudit(opts?)` | `GET /v1/audit`, every page | `for await (const e of korely.iterAudit({ user_id }))`: an export, `page_size` events per request, `until` pinned when it starts. |
|
|
122
122
|
|
|
123
123
|
## Bi-temporal facts (the moat)
|
|
@@ -181,6 +181,12 @@ later, and this client sends only the ids each call names). Every `APIError` has
|
|
|
181
181
|
503 `writes_paused` (writes that need a model are paused until 00:00 UTC). The
|
|
182
182
|
SDK does not retry on its own.
|
|
183
183
|
|
|
184
|
+
A call that is not a `GET` (`add`, `update`, `delete`...) is never redirected:
|
|
185
|
+
a 3xx rejects with an `APIError` of that status, its message naming the origin
|
|
186
|
+
the redirect pointed to (in a browser, which hides it, `status` is 0). A `GET`
|
|
187
|
+
follows a redirect; on the way to another origin `fetch` drops the key, and the
|
|
188
|
+
401 that follows says where the call went: point `baseUrl` at that address.
|
|
189
|
+
|
|
184
190
|
## Configuration
|
|
185
191
|
|
|
186
192
|
```ts
|
|
@@ -198,10 +204,11 @@ default. A memory written to a Global project is read by Google's model.
|
|
|
198
204
|
|
|
199
205
|
In Node, `new Korely()` with no key and no `KORELY_API_KEY` reads what
|
|
200
206
|
`korely init` saved (the key and the server, in `~/.korely/config.json`, or
|
|
201
|
-
`$KORELY_CONFIG_HOME/config.json`), as the Python client does
|
|
202
|
-
comes first, then the
|
|
207
|
+
`$KORELY_CONFIG_HOME/config.json`), as the Python client does, with `import`
|
|
208
|
+
and with `require`, from Node 18. An argument comes first, then the
|
|
209
|
+
environment, then that file. A browser or an edge runtime has no such file.
|
|
203
210
|
|
|
204
|
-
### Your own server (
|
|
211
|
+
### Your own server (Self-hosted)
|
|
205
212
|
|
|
206
213
|
Point the client at your install with `baseUrl`, or with the `KORELY_BASE_URL`
|
|
207
214
|
env var, and use the key your install issued (`kor_self_...`):
|