korely-memory 0.1.11 → 0.1.13
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 +4 -2
- package/dist/index.cjs +29 -6
- package/dist/index.d.cts +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +29 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ Every method maps to one REST endpoint.
|
|
|
95
95
|
| Method | Endpoint | |
|
|
96
96
|
|---|---|---|
|
|
97
97
|
| `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`. |
|
|
98
|
-
| `search(query, opts?)` | `POST /v1/memories/search` | Semantic search over memories; filter by `user_id`, `agent_id`, `run_id`, `metadata
|
|
98
|
+
| `search(query, opts?)` | `POST /v1/memories/search` | Semantic search over memories; filter by `user_id`, `agent_id`, `run_id`, `metadata`; `min_score` (0 to 1) leaves out hits scored below it. |
|
|
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. |
|
|
@@ -163,7 +163,9 @@ try {
|
|
|
163
163
|
|
|
164
164
|
`AuthenticationError` (401) · `NamespaceForbiddenError` (403, e.g.
|
|
165
165
|
`agent_cap_exceeded`) · `NotFoundError` (404) · `ConflictError` (409, e.g.
|
|
166
|
-
`account_has_login`; `
|
|
166
|
+
`account_has_login`; `fact_not_current` from `correctFact()` of a fact that is
|
|
167
|
+
history, with `currentFactId` the fact to correct instead; `stale_write` is its
|
|
168
|
+
subclass `StaleWriteError`) ·
|
|
167
169
|
`QuotaExceededError` (429: `retryAfter` is set for `rate_limit_exceeded`,
|
|
168
170
|
undefined for the monthly `quota_exceeded`) · `TooManyBatchesError` (a
|
|
169
171
|
`QuotaExceededError`: `too_many_batches` from `batch()`, Cloud only, three
|
package/dist/index.cjs
CHANGED
|
@@ -77,6 +77,7 @@ var ConflictError = class extends APIError {
|
|
|
77
77
|
constructor(message = "", opts = {}) {
|
|
78
78
|
super(message, opts);
|
|
79
79
|
this.name = "ConflictError";
|
|
80
|
+
this.currentFactId = opts.currentFactId;
|
|
80
81
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
81
82
|
}
|
|
82
83
|
};
|
|
@@ -91,6 +92,9 @@ var QuotaExceededError = class extends APIError {
|
|
|
91
92
|
constructor(message = "", opts = {}) {
|
|
92
93
|
super(message, opts);
|
|
93
94
|
this.name = "QuotaExceededError";
|
|
95
|
+
this.limit = opts.limit;
|
|
96
|
+
this.used = opts.used;
|
|
97
|
+
this.resetsAt = opts.resetsAt;
|
|
94
98
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
95
99
|
}
|
|
96
100
|
};
|
|
@@ -122,12 +126,12 @@ function unknownOption(method, opts, known) {
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
// src/client.ts
|
|
125
|
-
var VERSION = "0.1.
|
|
129
|
+
var VERSION = "0.1.13";
|
|
126
130
|
var REGIONS = { eu: "https://api.korely.ai" };
|
|
127
131
|
var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
|
|
128
132
|
var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
|
|
129
133
|
var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp");
|
|
130
|
-
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit");
|
|
134
|
+
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit", "min_score");
|
|
131
135
|
var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
|
|
132
136
|
var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
|
|
133
137
|
var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
|
|
@@ -239,6 +243,23 @@ function errorFields(status, body) {
|
|
|
239
243
|
const message = text2(b.message) ?? text2(pair.message) ?? detailLine(b.detail) ?? code ?? `HTTP ${status}`;
|
|
240
244
|
return { code, message };
|
|
241
245
|
}
|
|
246
|
+
function quotaFields(body) {
|
|
247
|
+
const b = body && typeof body === "object" ? body : {};
|
|
248
|
+
const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
|
|
249
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
250
|
+
const str = (v) => typeof v === "string" && v ? v : void 0;
|
|
251
|
+
return {
|
|
252
|
+
limit: num(b.limit ?? d.limit),
|
|
253
|
+
used: num(b.used ?? d.used),
|
|
254
|
+
resetsAt: str(b.resets_at ?? d.resets_at)
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function conflictFields(body) {
|
|
258
|
+
const b = body && typeof body === "object" ? body : {};
|
|
259
|
+
const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
|
|
260
|
+
const v = b.current_fact_id ?? d.current_fact_id;
|
|
261
|
+
return { currentFactId: typeof v === "string" && v ? v : void 0 };
|
|
262
|
+
}
|
|
242
263
|
function retryAfterSeconds(raw) {
|
|
243
264
|
if (raw == null) return void 0;
|
|
244
265
|
const n = Math.ceil(Number(raw));
|
|
@@ -360,11 +381,12 @@ function raiseFor(status, body, retryAfter) {
|
|
|
360
381
|
if (status === 404) throw new NotFoundError(msg, opts);
|
|
361
382
|
if (status === 409) {
|
|
362
383
|
if (code === "stale_write") throw new StaleWriteError(msg, opts);
|
|
363
|
-
throw new ConflictError(msg, opts);
|
|
384
|
+
throw new ConflictError(msg, { ...opts, ...conflictFields(body) });
|
|
364
385
|
}
|
|
365
386
|
if (status === 429) {
|
|
366
|
-
|
|
367
|
-
throw new
|
|
387
|
+
const quota = { ...opts, ...quotaFields(body) };
|
|
388
|
+
if (code === "too_many_batches") throw new TooManyBatchesError(msg, quota);
|
|
389
|
+
throw new QuotaExceededError(msg, quota);
|
|
368
390
|
}
|
|
369
391
|
throw new APIError(msg, opts);
|
|
370
392
|
}
|
|
@@ -613,7 +635,8 @@ var Korely = class {
|
|
|
613
635
|
agent_id: opts.agent_id,
|
|
614
636
|
run_id: opts.run_id,
|
|
615
637
|
metadata: opts.metadata,
|
|
616
|
-
limit: opts.limit
|
|
638
|
+
limit: opts.limit,
|
|
639
|
+
min_score: opts.min_score
|
|
617
640
|
}
|
|
618
641
|
});
|
|
619
642
|
return body.results ?? [];
|
package/dist/index.d.cts
CHANGED
|
@@ -370,6 +370,13 @@ interface SearchOptions {
|
|
|
370
370
|
metadata?: Record<string, unknown>;
|
|
371
371
|
/** Server default 15, max 50. */
|
|
372
372
|
limit?: number;
|
|
373
|
+
/**
|
|
374
|
+
* Leave out the memories whose `score` is below this, 0 to 1 (a cosine
|
|
375
|
+
* similarity, compared as the response shows it). Absent: no floor. Fewer
|
|
376
|
+
* than `limit` results can come back. 0.20 is the value measured on
|
|
377
|
+
* LongMemEval with EmbeddingGemma; the right one depends on your texts.
|
|
378
|
+
*/
|
|
379
|
+
min_score?: number;
|
|
373
380
|
}
|
|
374
381
|
interface ListOptions {
|
|
375
382
|
user_id?: string;
|
|
@@ -474,7 +481,7 @@ interface ForgetReceipt {
|
|
|
474
481
|
|
|
475
482
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
476
483
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
477
|
-
declare const VERSION = "0.1.
|
|
484
|
+
declare const VERSION = "0.1.13";
|
|
478
485
|
interface KorelyOptions {
|
|
479
486
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
480
487
|
apiKey?: string;
|
|
@@ -838,12 +845,18 @@ declare class NamespaceForbiddenError extends APIError {
|
|
|
838
845
|
declare class NotFoundError extends APIError {
|
|
839
846
|
constructor(message?: string, opts?: APIErrorOptions);
|
|
840
847
|
}
|
|
848
|
+
interface ConflictErrorOptions extends APIErrorOptions {
|
|
849
|
+
currentFactId?: string;
|
|
850
|
+
}
|
|
841
851
|
/**
|
|
842
852
|
* 409: the request conflicts with what the server holds. `code` names the
|
|
843
853
|
* conflict: `stale_write` (update() with an expected_updated_at older than the
|
|
844
854
|
* record, thrown as the subclass StaleWriteError), `account_has_login`
|
|
845
855
|
* (`deleteAccount()` with the key of an account somebody signs in to, Cloud
|
|
846
|
-
* only)
|
|
856
|
+
* only), `fact_not_current` (`correctFact()` of a fact that is history:
|
|
857
|
+
* superseded, forgotten or ended; `currentFactId` is the fact to correct
|
|
858
|
+
* instead) or `conflict` (the Self-hosted's code for a 409 that names no
|
|
859
|
+
* other).
|
|
847
860
|
*
|
|
848
861
|
* Until 2026-10-06 every 409 was a StaleWriteError, so a refusal that has
|
|
849
862
|
* nothing to do with an update read as a lost write, and code written to
|
|
@@ -851,7 +864,15 @@ declare class NotFoundError extends APIError {
|
|
|
851
864
|
* changes.
|
|
852
865
|
*/
|
|
853
866
|
declare class ConflictError extends APIError {
|
|
854
|
-
|
|
867
|
+
/**
|
|
868
|
+
* On `fact_not_current` (2026-10-07): the id of the fact that holds now, the
|
|
869
|
+
* one to correct instead. Undefined when nothing superseded the fact asked
|
|
870
|
+
* (it was forgotten or ended: write the value of now with `addFactTriple()`),
|
|
871
|
+
* on any other conflict, and from a server that does not send it. Read
|
|
872
|
+
* this, never the message.
|
|
873
|
+
*/
|
|
874
|
+
readonly currentFactId?: string;
|
|
875
|
+
constructor(message?: string, opts?: ConflictErrorOptions);
|
|
855
876
|
}
|
|
856
877
|
/**
|
|
857
878
|
* 409 `stale_write`: update() with an expected_updated_at older than the
|
|
@@ -869,8 +890,22 @@ declare class StaleWriteError extends ConflictError {
|
|
|
869
890
|
* `retryAfter` comes from APIError, which every error the server answers with
|
|
870
891
|
* carries.
|
|
871
892
|
*/
|
|
893
|
+
interface QuotaErrorOptions extends APIErrorOptions {
|
|
894
|
+
limit?: number;
|
|
895
|
+
used?: number;
|
|
896
|
+
resetsAt?: string;
|
|
897
|
+
}
|
|
872
898
|
declare class QuotaExceededError extends APIError {
|
|
873
|
-
|
|
899
|
+
/**
|
|
900
|
+
* On the Cloud's `quota_exceeded` (2026-10-07): the month's allowance (the
|
|
901
|
+
* plan plus the month's top-ups), what was used, and when it starts again
|
|
902
|
+
* (ISO date). Undefined from a server that does not send them. Read these,
|
|
903
|
+
* never the message, which says the same in words that change.
|
|
904
|
+
*/
|
|
905
|
+
readonly limit?: number;
|
|
906
|
+
readonly used?: number;
|
|
907
|
+
readonly resetsAt?: string;
|
|
908
|
+
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
874
909
|
}
|
|
875
910
|
/**
|
|
876
911
|
* 429 `too_many_batches` (Cloud only): three `batch()` imports of the account
|
|
@@ -884,7 +919,7 @@ declare class QuotaExceededError extends APIError {
|
|
|
884
919
|
* docs tell you to stop on that one, while this one clears in minutes.
|
|
885
920
|
*/
|
|
886
921
|
declare class TooManyBatchesError extends QuotaExceededError {
|
|
887
|
-
constructor(message?: string, opts?:
|
|
922
|
+
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
888
923
|
}
|
|
889
924
|
|
|
890
925
|
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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -370,6 +370,13 @@ interface SearchOptions {
|
|
|
370
370
|
metadata?: Record<string, unknown>;
|
|
371
371
|
/** Server default 15, max 50. */
|
|
372
372
|
limit?: number;
|
|
373
|
+
/**
|
|
374
|
+
* Leave out the memories whose `score` is below this, 0 to 1 (a cosine
|
|
375
|
+
* similarity, compared as the response shows it). Absent: no floor. Fewer
|
|
376
|
+
* than `limit` results can come back. 0.20 is the value measured on
|
|
377
|
+
* LongMemEval with EmbeddingGemma; the right one depends on your texts.
|
|
378
|
+
*/
|
|
379
|
+
min_score?: number;
|
|
373
380
|
}
|
|
374
381
|
interface ListOptions {
|
|
375
382
|
user_id?: string;
|
|
@@ -474,7 +481,7 @@ interface ForgetReceipt {
|
|
|
474
481
|
|
|
475
482
|
/** Must equal `version` in package.json (a test checks). It goes out in the
|
|
476
483
|
* X-Korely-Client header, and said 0.1.1 from 0.1.1 to 0.1.6. */
|
|
477
|
-
declare const VERSION = "0.1.
|
|
484
|
+
declare const VERSION = "0.1.13";
|
|
478
485
|
interface KorelyOptions {
|
|
479
486
|
/** Your `kor_live_...` key. Falls back to the KORELY_API_KEY env var. */
|
|
480
487
|
apiKey?: string;
|
|
@@ -838,12 +845,18 @@ declare class NamespaceForbiddenError extends APIError {
|
|
|
838
845
|
declare class NotFoundError extends APIError {
|
|
839
846
|
constructor(message?: string, opts?: APIErrorOptions);
|
|
840
847
|
}
|
|
848
|
+
interface ConflictErrorOptions extends APIErrorOptions {
|
|
849
|
+
currentFactId?: string;
|
|
850
|
+
}
|
|
841
851
|
/**
|
|
842
852
|
* 409: the request conflicts with what the server holds. `code` names the
|
|
843
853
|
* conflict: `stale_write` (update() with an expected_updated_at older than the
|
|
844
854
|
* record, thrown as the subclass StaleWriteError), `account_has_login`
|
|
845
855
|
* (`deleteAccount()` with the key of an account somebody signs in to, Cloud
|
|
846
|
-
* only)
|
|
856
|
+
* only), `fact_not_current` (`correctFact()` of a fact that is history:
|
|
857
|
+
* superseded, forgotten or ended; `currentFactId` is the fact to correct
|
|
858
|
+
* instead) or `conflict` (the Self-hosted's code for a 409 that names no
|
|
859
|
+
* other).
|
|
847
860
|
*
|
|
848
861
|
* Until 2026-10-06 every 409 was a StaleWriteError, so a refusal that has
|
|
849
862
|
* nothing to do with an update read as a lost write, and code written to
|
|
@@ -851,7 +864,15 @@ declare class NotFoundError extends APIError {
|
|
|
851
864
|
* changes.
|
|
852
865
|
*/
|
|
853
866
|
declare class ConflictError extends APIError {
|
|
854
|
-
|
|
867
|
+
/**
|
|
868
|
+
* On `fact_not_current` (2026-10-07): the id of the fact that holds now, the
|
|
869
|
+
* one to correct instead. Undefined when nothing superseded the fact asked
|
|
870
|
+
* (it was forgotten or ended: write the value of now with `addFactTriple()`),
|
|
871
|
+
* on any other conflict, and from a server that does not send it. Read
|
|
872
|
+
* this, never the message.
|
|
873
|
+
*/
|
|
874
|
+
readonly currentFactId?: string;
|
|
875
|
+
constructor(message?: string, opts?: ConflictErrorOptions);
|
|
855
876
|
}
|
|
856
877
|
/**
|
|
857
878
|
* 409 `stale_write`: update() with an expected_updated_at older than the
|
|
@@ -869,8 +890,22 @@ declare class StaleWriteError extends ConflictError {
|
|
|
869
890
|
* `retryAfter` comes from APIError, which every error the server answers with
|
|
870
891
|
* carries.
|
|
871
892
|
*/
|
|
893
|
+
interface QuotaErrorOptions extends APIErrorOptions {
|
|
894
|
+
limit?: number;
|
|
895
|
+
used?: number;
|
|
896
|
+
resetsAt?: string;
|
|
897
|
+
}
|
|
872
898
|
declare class QuotaExceededError extends APIError {
|
|
873
|
-
|
|
899
|
+
/**
|
|
900
|
+
* On the Cloud's `quota_exceeded` (2026-10-07): the month's allowance (the
|
|
901
|
+
* plan plus the month's top-ups), what was used, and when it starts again
|
|
902
|
+
* (ISO date). Undefined from a server that does not send them. Read these,
|
|
903
|
+
* never the message, which says the same in words that change.
|
|
904
|
+
*/
|
|
905
|
+
readonly limit?: number;
|
|
906
|
+
readonly used?: number;
|
|
907
|
+
readonly resetsAt?: string;
|
|
908
|
+
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
874
909
|
}
|
|
875
910
|
/**
|
|
876
911
|
* 429 `too_many_batches` (Cloud only): three `batch()` imports of the account
|
|
@@ -884,7 +919,7 @@ declare class QuotaExceededError extends APIError {
|
|
|
884
919
|
* docs tell you to stop on that one, while this one clears in minutes.
|
|
885
920
|
*/
|
|
886
921
|
declare class TooManyBatchesError extends QuotaExceededError {
|
|
887
|
-
constructor(message?: string, opts?:
|
|
922
|
+
constructor(message?: string, opts?: QuotaErrorOptions);
|
|
888
923
|
}
|
|
889
924
|
|
|
890
925
|
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 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 };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ var ConflictError = class extends APIError {
|
|
|
47
47
|
constructor(message = "", opts = {}) {
|
|
48
48
|
super(message, opts);
|
|
49
49
|
this.name = "ConflictError";
|
|
50
|
+
this.currentFactId = opts.currentFactId;
|
|
50
51
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
@@ -61,6 +62,9 @@ var QuotaExceededError = class extends APIError {
|
|
|
61
62
|
constructor(message = "", opts = {}) {
|
|
62
63
|
super(message, opts);
|
|
63
64
|
this.name = "QuotaExceededError";
|
|
65
|
+
this.limit = opts.limit;
|
|
66
|
+
this.used = opts.used;
|
|
67
|
+
this.resetsAt = opts.resetsAt;
|
|
64
68
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
65
69
|
}
|
|
66
70
|
};
|
|
@@ -73,12 +77,12 @@ var TooManyBatchesError = class _TooManyBatchesError extends QuotaExceededError
|
|
|
73
77
|
};
|
|
74
78
|
|
|
75
79
|
// src/client.ts
|
|
76
|
-
var VERSION = "0.1.
|
|
80
|
+
var VERSION = "0.1.13";
|
|
77
81
|
var REGIONS = { eu: "https://api.korely.ai" };
|
|
78
82
|
var CLIENT_KEYS = keysOf()("apiKey", "region", "baseUrl", "timeoutMs", "fetch");
|
|
79
83
|
var INIT_KEYS = keysOf()("region", "baseUrl", "timeoutMs", "fetch", "processingRegion");
|
|
80
84
|
var ADD_KEYS = keysOf()("agent_id", "user_id", "run_id", "metadata", "timestamp");
|
|
81
|
-
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit");
|
|
85
|
+
var SEARCH_KEYS = keysOf()("user_id", "agent_id", "run_id", "metadata", "limit", "min_score");
|
|
82
86
|
var LIST_KEYS = keysOf()("user_id", "agent_id", "run_id", "limit", "offset");
|
|
83
87
|
var UPDATE_KEYS = keysOf()("content", "expected_updated_at");
|
|
84
88
|
var USERS_KEYS = keysOf()("agent_id", "limit", "offset");
|
|
@@ -190,6 +194,23 @@ function errorFields(status, body) {
|
|
|
190
194
|
const message = text2(b.message) ?? text2(pair.message) ?? detailLine(b.detail) ?? code ?? `HTTP ${status}`;
|
|
191
195
|
return { code, message };
|
|
192
196
|
}
|
|
197
|
+
function quotaFields(body) {
|
|
198
|
+
const b = body && typeof body === "object" ? body : {};
|
|
199
|
+
const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
|
|
200
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
201
|
+
const str = (v) => typeof v === "string" && v ? v : void 0;
|
|
202
|
+
return {
|
|
203
|
+
limit: num(b.limit ?? d.limit),
|
|
204
|
+
used: num(b.used ?? d.used),
|
|
205
|
+
resetsAt: str(b.resets_at ?? d.resets_at)
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function conflictFields(body) {
|
|
209
|
+
const b = body && typeof body === "object" ? body : {};
|
|
210
|
+
const d = b.detail && typeof b.detail === "object" && !Array.isArray(b.detail) ? b.detail : {};
|
|
211
|
+
const v = b.current_fact_id ?? d.current_fact_id;
|
|
212
|
+
return { currentFactId: typeof v === "string" && v ? v : void 0 };
|
|
213
|
+
}
|
|
193
214
|
function retryAfterSeconds(raw) {
|
|
194
215
|
if (raw == null) return void 0;
|
|
195
216
|
const n = Math.ceil(Number(raw));
|
|
@@ -311,11 +332,12 @@ function raiseFor(status, body, retryAfter) {
|
|
|
311
332
|
if (status === 404) throw new NotFoundError(msg, opts);
|
|
312
333
|
if (status === 409) {
|
|
313
334
|
if (code === "stale_write") throw new StaleWriteError(msg, opts);
|
|
314
|
-
throw new ConflictError(msg, opts);
|
|
335
|
+
throw new ConflictError(msg, { ...opts, ...conflictFields(body) });
|
|
315
336
|
}
|
|
316
337
|
if (status === 429) {
|
|
317
|
-
|
|
318
|
-
throw new
|
|
338
|
+
const quota = { ...opts, ...quotaFields(body) };
|
|
339
|
+
if (code === "too_many_batches") throw new TooManyBatchesError(msg, quota);
|
|
340
|
+
throw new QuotaExceededError(msg, quota);
|
|
319
341
|
}
|
|
320
342
|
throw new APIError(msg, opts);
|
|
321
343
|
}
|
|
@@ -564,7 +586,8 @@ var Korely = class {
|
|
|
564
586
|
agent_id: opts.agent_id,
|
|
565
587
|
run_id: opts.run_id,
|
|
566
588
|
metadata: opts.metadata,
|
|
567
|
-
limit: opts.limit
|
|
589
|
+
limit: opts.limit,
|
|
590
|
+
min_score: opts.min_score
|
|
568
591
|
}
|
|
569
592
|
});
|
|
570
593
|
return body.results ?? [];
|