korely-memory 0.1.0 → 0.1.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 CHANGED
@@ -40,7 +40,7 @@ Every method maps to one REST endpoint.
40
40
 
41
41
  | Method | Endpoint | |
42
42
  |---|---|---|
43
- | `add(content, opts?)` | `POST /v1/memories` | Write. `content` is a string or a list of chat messages. |
43
+ | `add(content, opts?)` | `POST /v1/memories` | Write. `content` is a string or a list of chat messages. `opts.timestamp` (ISO) backfills the past — facts inherit it as `valid_from`. |
44
44
  | `search(query, opts?)` | `POST /v1/memories/search` | Hybrid search over memories. |
45
45
  | `getAll(opts?)` | `GET /v1/memories` | List a scope, newest first. |
46
46
  | `get(id)` | `GET /v1/memories/:id` | One memory, with its facts. |
@@ -49,6 +49,8 @@ Every method maps to one REST endpoint.
49
49
  | `deleteAll({ user_id })` | `DELETE /v1/users/:user_id/memories` | Forget everything for a user (GDPR). |
50
50
  | `history(id)` | `GET /v1/memories/:id/history` | A memory's timeline + the facts it produced. |
51
51
  | `users(opts?)` | `GET /v1/users` | Your end users, with counts. |
52
+ | `listAgents(opts?)` | `GET /v1/agents` | Your agent namespaces, with counts + the tier `cap`/`used`. Call after `agent_cap_exceeded` to reuse an id. |
53
+ | `deleteAgent(agentId)` | `DELETE /v1/agents/:agent_id` | Purge an agent namespace and free its cap slot. |
52
54
  | `getFacts(opts?)` | `GET /v1/facts` | Typed facts; `as_of` for point-in-time. |
53
55
  | `addFactTriple(s, p, o, opts?)` | `POST /v1/facts` | Write a fact directly (bi-temporal). |
54
56
  | `getProfile({ user_id, as_of? })` | `GET /v1/profile` | The assembled profile of one end user. |
package/dist/index.cjs CHANGED
@@ -87,7 +87,7 @@ var APIError = class _APIError extends KorelyError {
87
87
  };
88
88
 
89
89
  // src/client.ts
90
- var VERSION = "0.1.0";
90
+ var VERSION = "0.1.1";
91
91
  var REGIONS = { eu: "https://api.korely.ai" };
92
92
  function coerceContent(content) {
93
93
  if (typeof content === "string") return content;
@@ -201,7 +201,8 @@ var Korely = class {
201
201
  /**
202
202
  * POST /v1/memories — store a memory; resolves to it with extracted facts.
203
203
  * `content` is a string, or a list of chat messages (role/content), joined
204
- * into one block before sending.
204
+ * into one block before sending. Pass `timestamp` (ISO date/datetime) for
205
+ * backfill: facts extracted inherit it as `valid_from`.
205
206
  */
206
207
  async add(content, opts = {}) {
207
208
  const text = coerceContent(content);
@@ -216,18 +217,22 @@ var Korely = class {
216
217
  agent_id: opts.agent_id,
217
218
  user_id: opts.user_id,
218
219
  run_id: opts.run_id,
219
- metadata: opts.metadata
220
+ metadata: opts.metadata,
221
+ timestamp: opts.timestamp
220
222
  }
221
223
  });
222
224
  }
223
- /** POST /v1/memories/search — hybrid retrieval, ranked by score. */
225
+ /**
226
+ * POST /v1/memories/search — hybrid retrieval, ranked by score. `limit`
227
+ * defaults to the server default (15) when not passed.
228
+ */
224
229
  async search(query, opts = {}) {
225
230
  const body = await this.request("POST", "/v1/memories/search", {
226
231
  body: {
227
232
  query,
228
233
  user_id: opts.user_id,
229
234
  agent_id: opts.agent_id,
230
- limit: opts.limit ?? 10
235
+ limit: opts.limit
231
236
  }
232
237
  });
233
238
  return body.results ?? [];
@@ -293,6 +298,32 @@ var Korely = class {
293
298
  }
294
299
  });
295
300
  }
301
+ // ── agents ────────────────────────────────────────────────────────────────
302
+ /**
303
+ * GET /v1/agents — the agent namespaces you've written under (the distinct
304
+ * non-null agent_id values), each with active memory + fact counts and
305
+ * last-active time, plus the tier agent `cap` and how many slots are `used`.
306
+ * The antidote to the agent-cap trap: when a write is rejected with
307
+ * `agent_cap_exceeded`, call this to see which namespaces already exist and
308
+ * reuse one instead of minting a new id.
309
+ */
310
+ async listAgents(opts = {}) {
311
+ return this.request("GET", "/v1/agents", {
312
+ params: {
313
+ limit: opts.limit ?? 50,
314
+ offset: opts.offset ?? 0
315
+ }
316
+ });
317
+ }
318
+ /**
319
+ * DELETE /v1/agents/:agent_id — hard-delete an agent namespace: purge every
320
+ * memory + fact written under this agent_id and FREE its cap slot
321
+ * (soft-forgetting its data does NOT free the slot). Resolves to the purge
322
+ * counts + an audit id.
323
+ */
324
+ async deleteAgent(agentId) {
325
+ return this.request("DELETE", `/v1/agents/${agentId}`);
326
+ }
296
327
  // ── facts ─────────────────────────────────────────────────────────────────
297
328
  /**
298
329
  * GET /v1/facts — typed (subject, predicate, object) triples with bi-temporal
package/dist/index.d.cts CHANGED
@@ -111,11 +111,38 @@ interface UsersPage {
111
111
  users: UserScope[];
112
112
  total: number;
113
113
  }
114
+ interface AgentScope {
115
+ agent_id?: string;
116
+ memories: number;
117
+ facts: number;
118
+ last_active?: string;
119
+ }
120
+ interface AgentsPage {
121
+ agents: AgentScope[];
122
+ /** Distinct agent namespaces == `used` slots. */
123
+ total: number;
124
+ /** The tier agent cap. */
125
+ cap: number;
126
+ /** Agent slots consumed — reconciles with the `agent_cap_exceeded` 403. */
127
+ used: number;
128
+ }
129
+ interface AgentDeleteReceipt {
130
+ agent_id?: string;
131
+ memories_deleted?: number;
132
+ facts_deleted?: number;
133
+ audit_id?: string;
134
+ }
114
135
  interface AddOptions {
115
136
  agent_id?: string;
116
137
  user_id?: string;
117
138
  run_id?: string;
118
139
  metadata?: Record<string, unknown>;
140
+ /**
141
+ * ISO date/datetime the events happened (for backfill / migration). Facts
142
+ * extracted inherit it as `valid_from`, so `as_of` point-in-time queries
143
+ * reflect when things were true, not when they were ingested. Defaults to now.
144
+ */
145
+ timestamp?: string;
119
146
  }
120
147
  interface SearchOptions {
121
148
  user_id?: string;
@@ -138,6 +165,10 @@ interface UsersOptions {
138
165
  limit?: number;
139
166
  offset?: number;
140
167
  }
168
+ interface ListAgentsOptions {
169
+ limit?: number;
170
+ offset?: number;
171
+ }
141
172
  interface GetFactsOptions {
142
173
  subject?: string;
143
174
  /** Matches the subject OR object side. */
@@ -175,7 +206,7 @@ interface GetContextOptions {
175
206
  token_budget?: number;
176
207
  }
177
208
 
178
- declare const VERSION = "0.1.0";
209
+ declare const VERSION = "0.1.1";
179
210
  interface KorelyOptions {
180
211
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
181
212
  apiKey?: string;
@@ -199,10 +230,14 @@ declare class Korely {
199
230
  /**
200
231
  * POST /v1/memories — store a memory; resolves to it with extracted facts.
201
232
  * `content` is a string, or a list of chat messages (role/content), joined
202
- * into one block before sending.
233
+ * into one block before sending. Pass `timestamp` (ISO date/datetime) for
234
+ * backfill: facts extracted inherit it as `valid_from`.
203
235
  */
204
236
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
205
- /** POST /v1/memories/search — hybrid retrieval, ranked by score. */
237
+ /**
238
+ * POST /v1/memories/search — hybrid retrieval, ranked by score. `limit`
239
+ * defaults to the server default (15) when not passed.
240
+ */
206
241
  search(query: string, opts?: SearchOptions): Promise<SearchHit[]>;
207
242
  /** GET /v1/memories — list a scope, newest first. */
208
243
  getAll(opts?: ListOptions): Promise<MemoryPage>;
@@ -232,6 +267,22 @@ declare class Korely {
232
267
  * namespaces), each with active memory + fact counts and last-active time.
233
268
  */
234
269
  users(opts?: UsersOptions): Promise<UsersPage>;
270
+ /**
271
+ * GET /v1/agents — the agent namespaces you've written under (the distinct
272
+ * non-null agent_id values), each with active memory + fact counts and
273
+ * last-active time, plus the tier agent `cap` and how many slots are `used`.
274
+ * The antidote to the agent-cap trap: when a write is rejected with
275
+ * `agent_cap_exceeded`, call this to see which namespaces already exist and
276
+ * reuse one instead of minting a new id.
277
+ */
278
+ listAgents(opts?: ListAgentsOptions): Promise<AgentsPage>;
279
+ /**
280
+ * DELETE /v1/agents/:agent_id — hard-delete an agent namespace: purge every
281
+ * memory + fact written under this agent_id and FREE its cap slot
282
+ * (soft-forgetting its data does NOT free the slot). Resolves to the purge
283
+ * counts + an audit id.
284
+ */
285
+ deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
235
286
  /**
236
287
  * GET /v1/facts — typed (subject, predicate, object) triples with bi-temporal
237
288
  * validity. Pass `as_of` (ISO date) for a point-in-time query.
@@ -302,4 +353,4 @@ declare class APIError extends KorelyError {
302
353
  constructor(message?: string, opts?: KorelyErrorOptions);
303
354
  }
304
355
 
305
- export { APIError, type AddFactTripleOptions, type AddOptions, AuthenticationError, type BatchJob, type BulkReceipt, type Context, type DeleteReceipt, type Fact, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, Korely, KorelyError, type KorelyOptions, type ListOptions, type Memory, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
356
+ export { APIError, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentScope, type AgentsPage, AuthenticationError, type BatchJob, type BulkReceipt, type Context, type DeleteReceipt, type Fact, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
package/dist/index.d.ts CHANGED
@@ -111,11 +111,38 @@ interface UsersPage {
111
111
  users: UserScope[];
112
112
  total: number;
113
113
  }
114
+ interface AgentScope {
115
+ agent_id?: string;
116
+ memories: number;
117
+ facts: number;
118
+ last_active?: string;
119
+ }
120
+ interface AgentsPage {
121
+ agents: AgentScope[];
122
+ /** Distinct agent namespaces == `used` slots. */
123
+ total: number;
124
+ /** The tier agent cap. */
125
+ cap: number;
126
+ /** Agent slots consumed — reconciles with the `agent_cap_exceeded` 403. */
127
+ used: number;
128
+ }
129
+ interface AgentDeleteReceipt {
130
+ agent_id?: string;
131
+ memories_deleted?: number;
132
+ facts_deleted?: number;
133
+ audit_id?: string;
134
+ }
114
135
  interface AddOptions {
115
136
  agent_id?: string;
116
137
  user_id?: string;
117
138
  run_id?: string;
118
139
  metadata?: Record<string, unknown>;
140
+ /**
141
+ * ISO date/datetime the events happened (for backfill / migration). Facts
142
+ * extracted inherit it as `valid_from`, so `as_of` point-in-time queries
143
+ * reflect when things were true, not when they were ingested. Defaults to now.
144
+ */
145
+ timestamp?: string;
119
146
  }
120
147
  interface SearchOptions {
121
148
  user_id?: string;
@@ -138,6 +165,10 @@ interface UsersOptions {
138
165
  limit?: number;
139
166
  offset?: number;
140
167
  }
168
+ interface ListAgentsOptions {
169
+ limit?: number;
170
+ offset?: number;
171
+ }
141
172
  interface GetFactsOptions {
142
173
  subject?: string;
143
174
  /** Matches the subject OR object side. */
@@ -175,7 +206,7 @@ interface GetContextOptions {
175
206
  token_budget?: number;
176
207
  }
177
208
 
178
- declare const VERSION = "0.1.0";
209
+ declare const VERSION = "0.1.1";
179
210
  interface KorelyOptions {
180
211
  /** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
181
212
  apiKey?: string;
@@ -199,10 +230,14 @@ declare class Korely {
199
230
  /**
200
231
  * POST /v1/memories — store a memory; resolves to it with extracted facts.
201
232
  * `content` is a string, or a list of chat messages (role/content), joined
202
- * into one block before sending.
233
+ * into one block before sending. Pass `timestamp` (ISO date/datetime) for
234
+ * backfill: facts extracted inherit it as `valid_from`.
203
235
  */
204
236
  add(content: string | Message[], opts?: AddOptions): Promise<Memory>;
205
- /** POST /v1/memories/search — hybrid retrieval, ranked by score. */
237
+ /**
238
+ * POST /v1/memories/search — hybrid retrieval, ranked by score. `limit`
239
+ * defaults to the server default (15) when not passed.
240
+ */
206
241
  search(query: string, opts?: SearchOptions): Promise<SearchHit[]>;
207
242
  /** GET /v1/memories — list a scope, newest first. */
208
243
  getAll(opts?: ListOptions): Promise<MemoryPage>;
@@ -232,6 +267,22 @@ declare class Korely {
232
267
  * namespaces), each with active memory + fact counts and last-active time.
233
268
  */
234
269
  users(opts?: UsersOptions): Promise<UsersPage>;
270
+ /**
271
+ * GET /v1/agents — the agent namespaces you've written under (the distinct
272
+ * non-null agent_id values), each with active memory + fact counts and
273
+ * last-active time, plus the tier agent `cap` and how many slots are `used`.
274
+ * The antidote to the agent-cap trap: when a write is rejected with
275
+ * `agent_cap_exceeded`, call this to see which namespaces already exist and
276
+ * reuse one instead of minting a new id.
277
+ */
278
+ listAgents(opts?: ListAgentsOptions): Promise<AgentsPage>;
279
+ /**
280
+ * DELETE /v1/agents/:agent_id — hard-delete an agent namespace: purge every
281
+ * memory + fact written under this agent_id and FREE its cap slot
282
+ * (soft-forgetting its data does NOT free the slot). Resolves to the purge
283
+ * counts + an audit id.
284
+ */
285
+ deleteAgent(agentId: string): Promise<AgentDeleteReceipt>;
235
286
  /**
236
287
  * GET /v1/facts — typed (subject, predicate, object) triples with bi-temporal
237
288
  * validity. Pass `as_of` (ISO date) for a point-in-time query.
@@ -302,4 +353,4 @@ declare class APIError extends KorelyError {
302
353
  constructor(message?: string, opts?: KorelyErrorOptions);
303
354
  }
304
355
 
305
- export { APIError, type AddFactTripleOptions, type AddOptions, AuthenticationError, type BatchJob, type BulkReceipt, type Context, type DeleteReceipt, type Fact, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, Korely, KorelyError, type KorelyOptions, type ListOptions, type Memory, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
356
+ export { APIError, type AddFactTripleOptions, type AddOptions, type AgentDeleteReceipt, type AgentScope, type AgentsPage, AuthenticationError, type BatchJob, type BulkReceipt, type Context, type DeleteReceipt, type Fact, type GetContextOptions, type GetFactsOptions, type GetProfileOptions, type HistoryEvent, type HistoryEventType, Korely, KorelyError, type KorelyOptions, type ListAgentsOptions, type ListOptions, type Memory, type MemoryHistory, type MemoryPage, type Message, NamespaceForbiddenError, NotFoundError, type Profile, QuotaExceededError, type SearchHit, type SearchOptions, StaleWriteError, type UpdateOptions, type UserScope, type UsersOptions, type UsersPage, VERSION };
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ var APIError = class _APIError extends KorelyError {
53
53
  };
54
54
 
55
55
  // src/client.ts
56
- var VERSION = "0.1.0";
56
+ var VERSION = "0.1.1";
57
57
  var REGIONS = { eu: "https://api.korely.ai" };
58
58
  function coerceContent(content) {
59
59
  if (typeof content === "string") return content;
@@ -167,7 +167,8 @@ var Korely = class {
167
167
  /**
168
168
  * POST /v1/memories — store a memory; resolves to it with extracted facts.
169
169
  * `content` is a string, or a list of chat messages (role/content), joined
170
- * into one block before sending.
170
+ * into one block before sending. Pass `timestamp` (ISO date/datetime) for
171
+ * backfill: facts extracted inherit it as `valid_from`.
171
172
  */
172
173
  async add(content, opts = {}) {
173
174
  const text = coerceContent(content);
@@ -182,18 +183,22 @@ var Korely = class {
182
183
  agent_id: opts.agent_id,
183
184
  user_id: opts.user_id,
184
185
  run_id: opts.run_id,
185
- metadata: opts.metadata
186
+ metadata: opts.metadata,
187
+ timestamp: opts.timestamp
186
188
  }
187
189
  });
188
190
  }
189
- /** POST /v1/memories/search — hybrid retrieval, ranked by score. */
191
+ /**
192
+ * POST /v1/memories/search — hybrid retrieval, ranked by score. `limit`
193
+ * defaults to the server default (15) when not passed.
194
+ */
190
195
  async search(query, opts = {}) {
191
196
  const body = await this.request("POST", "/v1/memories/search", {
192
197
  body: {
193
198
  query,
194
199
  user_id: opts.user_id,
195
200
  agent_id: opts.agent_id,
196
- limit: opts.limit ?? 10
201
+ limit: opts.limit
197
202
  }
198
203
  });
199
204
  return body.results ?? [];
@@ -259,6 +264,32 @@ var Korely = class {
259
264
  }
260
265
  });
261
266
  }
267
+ // ── agents ────────────────────────────────────────────────────────────────
268
+ /**
269
+ * GET /v1/agents — the agent namespaces you've written under (the distinct
270
+ * non-null agent_id values), each with active memory + fact counts and
271
+ * last-active time, plus the tier agent `cap` and how many slots are `used`.
272
+ * The antidote to the agent-cap trap: when a write is rejected with
273
+ * `agent_cap_exceeded`, call this to see which namespaces already exist and
274
+ * reuse one instead of minting a new id.
275
+ */
276
+ async listAgents(opts = {}) {
277
+ return this.request("GET", "/v1/agents", {
278
+ params: {
279
+ limit: opts.limit ?? 50,
280
+ offset: opts.offset ?? 0
281
+ }
282
+ });
283
+ }
284
+ /**
285
+ * DELETE /v1/agents/:agent_id — hard-delete an agent namespace: purge every
286
+ * memory + fact written under this agent_id and FREE its cap slot
287
+ * (soft-forgetting its data does NOT free the slot). Resolves to the purge
288
+ * counts + an audit id.
289
+ */
290
+ async deleteAgent(agentId) {
291
+ return this.request("DELETE", `/v1/agents/${agentId}`);
292
+ }
262
293
  // ── facts ─────────────────────────────────────────────────────────────────
263
294
  /**
264
295
  * GET /v1/facts — typed (subject, predicate, object) triples with bi-temporal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korely-memory",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "JavaScript / TypeScript SDK for Korely Agents — memory for AI agents with bi-temporal typed facts.",
5
5
  "keywords": [
6
6
  "ai",