mnemocyte 0.1.3 → 0.1.4
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 +33 -7
- package/dist/embedders/openai.d.mts +31 -0
- package/dist/embedders/openai.d.mts.map +1 -0
- package/dist/embedders/openai.mjs +78 -0
- package/dist/embedders/openai.mjs.map +1 -0
- package/dist/errors-BG3-mNur.mjs +53 -0
- package/dist/errors-BG3-mNur.mjs.map +1 -0
- package/dist/index.d.mts +2 -843
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -50
- package/dist/index.mjs.map +1 -1
- package/dist/types-QK_43oKJ.d.mts +845 -0
- package/dist/types-QK_43oKJ.d.mts.map +1 -0
- package/package.json +7 -3
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/client.ts","../src/errors.ts"],"mappings":";;;;;AAqCA;;;;;;;;AAAyE;;;;ACzBzE;;;;AAA8B;AA6B9B;;;;;;;;iBDJgB,eAAA,CAAgB,MAAA,EAAQ,eAAA,GAAkB,eAAe;;;;;;AAAzE;;;;;;;;AAAyE;KCzB7D,kBAAA;;;AAAZ;;;;AAA8B;AA6B9B;;;;;;;;;;;;cAAa,cAAA,SAAuB,KAAA;EAWvB;EAAA,SATH,IAAA,EAAM,kBAAA;EASc;EAAA,SAPX,KAAA;EAOoD;AAAA;AAiBvE;;;cAjBa,OAAA,UAAiB,IAAA,EAAM,kBAAA,EAAoB,KAAA;AAAA;;;;AAiBiB;;;;;;iBAAzD,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,cAAc"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as isMnemocyteError, t as MnemocyteError } from "./errors-BG3-mNur.mjs";
|
|
1
2
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
3
|
import postgres from "postgres";
|
|
3
4
|
import { and, count, countDistinct, desc, eq, gt, inArray, isNotNull, isNull, lt, or, sql } from "drizzle-orm";
|
|
@@ -93,56 +94,6 @@ function createDatabase(databaseUrl) {
|
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
//#endregion
|
|
96
|
-
//#region src/errors.ts
|
|
97
|
-
/**
|
|
98
|
-
* Error type thrown by every public Mnemocyte API.
|
|
99
|
-
*
|
|
100
|
-
* Use the {@link MnemocyteError.code} property — not the message — to branch
|
|
101
|
-
* on failure modes, or call {@link isMnemocyteError} as a type guard when
|
|
102
|
-
* working with `unknown` errors.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* try {
|
|
107
|
-
* await client.recall({ entityId: "u1", query: "hi" });
|
|
108
|
-
* } catch (err) {
|
|
109
|
-
* if (isMnemocyteError(err) && err.code === "DB") {
|
|
110
|
-
* // handle database failure
|
|
111
|
-
* }
|
|
112
|
-
* throw err;
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
var MnemocyteError = class extends Error {
|
|
117
|
-
/** Stable, machine-readable failure code. See {@link MnemocyteErrorCode}. */
|
|
118
|
-
code;
|
|
119
|
-
/** Underlying cause, if any (e.g. an original driver or embedder error). */
|
|
120
|
-
cause;
|
|
121
|
-
/**
|
|
122
|
-
* @param message - Human-readable error message.
|
|
123
|
-
* @param code - Stable failure code; see {@link MnemocyteErrorCode}.
|
|
124
|
-
* @param cause - Optional underlying cause (driver error, network error, etc.).
|
|
125
|
-
*/
|
|
126
|
-
constructor(message, code, cause) {
|
|
127
|
-
super(message);
|
|
128
|
-
this.name = "MnemocyteError";
|
|
129
|
-
this.code = code;
|
|
130
|
-
this.cause = cause;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Type guard for {@link MnemocyteError}.
|
|
135
|
-
*
|
|
136
|
-
* Prefer this over `instanceof` when working across module boundaries or
|
|
137
|
-
* bundlers where multiple copies of the class may exist.
|
|
138
|
-
*
|
|
139
|
-
* @param error - Value to test (typically a caught `unknown`).
|
|
140
|
-
* @returns `true` if `error` is a {@link MnemocyteError}.
|
|
141
|
-
*/
|
|
142
|
-
function isMnemocyteError(error) {
|
|
143
|
-
return error instanceof MnemocyteError;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
97
|
//#region src/context/formatter.ts
|
|
147
98
|
function escapeXml(value) {
|
|
148
99
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
@@ -328,6 +279,13 @@ function defaultShouldRetry(error) {
|
|
|
328
279
|
if (error.code === "VALIDATION" || error.code === "CONFIG" || error.code === "ABORTED") return false;
|
|
329
280
|
return true;
|
|
330
281
|
}
|
|
282
|
+
if (typeof error === "object" && error !== null && "status" in error && typeof error.status === "number" && [
|
|
283
|
+
429,
|
|
284
|
+
500,
|
|
285
|
+
502,
|
|
286
|
+
503,
|
|
287
|
+
504
|
|
288
|
+
].includes(error.status)) return true;
|
|
331
289
|
if (error instanceof Error) {
|
|
332
290
|
const message = error.message.toLowerCase();
|
|
333
291
|
if (message.includes("econn") || message.includes("etimedout") || message.includes("network") || message.includes("timeout") || message.includes("temporarily") || message.includes("rate limit") || message.includes("503") || message.includes("502") || message.includes("504") || message.includes("500")) return true;
|