@anuma/sdk 6.17.1 → 6.18.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/dist/expo/index.cjs +78 -6
- package/dist/expo/index.d.mts +73 -1
- package/dist/expo/index.d.ts +73 -1
- package/dist/expo/index.mjs +78 -6
- package/dist/react/index.cjs +69 -2
- package/dist/react/index.d.mts +73 -1
- package/dist/react/index.d.ts +73 -1
- package/dist/react/index.mjs +69 -2
- package/dist/server/index.cjs +41 -0
- package/dist/server/index.d.mts +64 -0
- package/dist/server/index.d.ts +64 -0
- package/dist/server/index.mjs +41 -0
- package/package.json +5 -4
package/dist/server/index.d.ts
CHANGED
|
@@ -7792,6 +7792,41 @@ declare function createMemoryEngineTool(storageCtx: StorageOperationsContext, em
|
|
|
7792
7792
|
* Each operation can be intercepted by the host app for confirmation/cancellation.
|
|
7793
7793
|
*/
|
|
7794
7794
|
|
|
7795
|
+
/**
|
|
7796
|
+
* The 7 FactTypes a manual save may self-classify into (PR5). Mirrors the
|
|
7797
|
+
* extractor's `FactType` union in `memory/autoExtract` — kept as a local const
|
|
7798
|
+
* (not imported) to avoid a memoryVault → memory runtime import cycle. Only used
|
|
7799
|
+
* to validate the optional `type` tool argument; an unrecognized value is
|
|
7800
|
+
* dropped (persisted as null, the untyped/medium-decay bucket).
|
|
7801
|
+
*/
|
|
7802
|
+
declare const MANUAL_FACT_TYPES: readonly ["identity", "preference", "relationship", "plan", "ongoing_context", "constraint", "other"];
|
|
7803
|
+
/** A FactType the save tool's optional `type` argument may carry. */
|
|
7804
|
+
type ManualFactType = (typeof MANUAL_FACT_TYPES)[number];
|
|
7805
|
+
/**
|
|
7806
|
+
* What a {@link VaultMemoryWriter} reports back. The action set mirrors
|
|
7807
|
+
* `RetainResult.action` in `memory/retain` — restated here rather than imported
|
|
7808
|
+
* for the same reason MANUAL_FACT_TYPES is (memoryVault → memory import cycle).
|
|
7809
|
+
*/
|
|
7810
|
+
type VaultWriteAction = "create" | "merge" | "update" | "supersede" | "suppressed" | "skip";
|
|
7811
|
+
interface VaultWriteOutcome {
|
|
7812
|
+
/** The memory the write landed on: the fresh row, or the existing one it merged into. */
|
|
7813
|
+
memoryId: string;
|
|
7814
|
+
action: VaultWriteAction;
|
|
7815
|
+
}
|
|
7816
|
+
/** A NEW memory the tool wants written — `id`-addressed updates never come here. */
|
|
7817
|
+
interface VaultWriteInput {
|
|
7818
|
+
content: string;
|
|
7819
|
+
scope: string;
|
|
7820
|
+
folderId?: string;
|
|
7821
|
+
factType?: ManualFactType;
|
|
7822
|
+
}
|
|
7823
|
+
/**
|
|
7824
|
+
* The seam through which the tool writes NEW memories when the host supplies one.
|
|
7825
|
+
* `useChatStorage` (react + expo) passes a `retain()`-backed writer so a
|
|
7826
|
+
* model-initiated save gets the same cosine auto-merge the background extractor
|
|
7827
|
+
* gets, instead of a bare insert that trusts the model to have de-duplicated.
|
|
7828
|
+
*/
|
|
7829
|
+
type VaultMemoryWriter = (input: VaultWriteInput) => Promise<VaultWriteOutcome>;
|
|
7795
7830
|
/**
|
|
7796
7831
|
* Describes a pending vault save operation for UI confirmation.
|
|
7797
7832
|
*/
|
|
@@ -7830,6 +7865,35 @@ interface MemoryVaultToolOptions {
|
|
|
7830
7865
|
* When provided, the LLM can specify a folderName argument.
|
|
7831
7866
|
*/
|
|
7832
7867
|
folderMap?: Map<string, string>;
|
|
7868
|
+
/**
|
|
7869
|
+
* Writer for NEW memories. When set, a save without an `id` goes through it
|
|
7870
|
+
* instead of a bare `createVaultMemoryOp`, and the tool phrases its reply from
|
|
7871
|
+
* the reported action (a merge reads as "already known", not "saved").
|
|
7872
|
+
*
|
|
7873
|
+
* The hooks supply a `retain()`-backed writer, which is what makes this tool
|
|
7874
|
+
* stop being a dedup bypass: until then the only thing standing between the
|
|
7875
|
+
* model and a duplicate row was the prompt asking it to pass an `id`. Omit it
|
|
7876
|
+
* (as a bare `createMemoryVaultTool(vaultCtx, …)` caller must — retain needs
|
|
7877
|
+
* embeddings) and the direct insert path is unchanged.
|
|
7878
|
+
*
|
|
7879
|
+
* Updates addressed by `id` never come here: the model has already named the
|
|
7880
|
+
* row, so there is nothing to de-duplicate against.
|
|
7881
|
+
*/
|
|
7882
|
+
write?: VaultMemoryWriter;
|
|
7883
|
+
/**
|
|
7884
|
+
* Fires after a NEW memory's write settles, with what was asked and what the
|
|
7885
|
+
* writer did. The host's analytics hook: `onSave` runs BEFORE the write and so
|
|
7886
|
+
* cannot tell a fresh create from a merge into an existing memory — and that
|
|
7887
|
+
* split is the one number that says whether model-initiated saves duplicate
|
|
7888
|
+
* the vault. Fires on both write paths (a `write` seam, or the direct insert
|
|
7889
|
+
* when none is supplied — reported as `create`). Not called for
|
|
7890
|
+
* `id`-addressed updates or cancelled saves. A throwing or rejecting listener
|
|
7891
|
+
* is awaited and swallowed so it can never fail the tool call.
|
|
7892
|
+
*/
|
|
7893
|
+
onWritten?: (event: {
|
|
7894
|
+
input: VaultWriteInput;
|
|
7895
|
+
outcome: VaultWriteOutcome;
|
|
7896
|
+
}) => void | Promise<void>;
|
|
7833
7897
|
}
|
|
7834
7898
|
/**
|
|
7835
7899
|
* Creates a memory vault tool for use with chat completions.
|
package/dist/server/index.mjs
CHANGED
|
@@ -4890,6 +4890,26 @@ var MANUAL_FACT_TYPES = [
|
|
|
4890
4890
|
function normalizeManualFactType(value) {
|
|
4891
4891
|
return typeof value === "string" && MANUAL_FACT_TYPES.includes(value) ? value : void 0;
|
|
4892
4892
|
}
|
|
4893
|
+
async function notifyWritten(options, input, outcome) {
|
|
4894
|
+
try {
|
|
4895
|
+
await options?.onWritten?.({ input, outcome });
|
|
4896
|
+
} catch {
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
function describeWriteOutcome(outcome) {
|
|
4900
|
+
switch (outcome.action) {
|
|
4901
|
+
case "create":
|
|
4902
|
+
return `Memory saved successfully (ID: ${outcome.memoryId}).`;
|
|
4903
|
+
case "update":
|
|
4904
|
+
case "supersede":
|
|
4905
|
+
return `Memory saved successfully (ID: ${outcome.memoryId}); it replaces an earlier version of this fact.`;
|
|
4906
|
+
case "merge":
|
|
4907
|
+
case "skip":
|
|
4908
|
+
return `The vault already holds this fact (ID: ${outcome.memoryId}); it was noted as re-observed. Nothing new was created \u2014 do not save it again.`;
|
|
4909
|
+
case "suppressed":
|
|
4910
|
+
return "Not saved: this matches a memory the user previously deleted. Do not re-save it.";
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4893
4913
|
function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
4894
4914
|
const hasOnSave = !!options?.onSave;
|
|
4895
4915
|
const folderNames = options?.folderMap ? Array.from(options.folderMap.keys()) : [];
|
|
@@ -4982,6 +5002,17 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
4982
5002
|
return `Memory updated successfully (ID: ${updated.uniqueId}).`;
|
|
4983
5003
|
} else {
|
|
4984
5004
|
const folderId = folderName ? options?.folderMap?.get(folderName) : void 0;
|
|
5005
|
+
if (options?.write) {
|
|
5006
|
+
const input = {
|
|
5007
|
+
content,
|
|
5008
|
+
scope,
|
|
5009
|
+
...folderId !== void 0 && { folderId },
|
|
5010
|
+
...factType !== void 0 && { factType }
|
|
5011
|
+
};
|
|
5012
|
+
const outcome = await options.write(input);
|
|
5013
|
+
await notifyWritten(options, input, outcome);
|
|
5014
|
+
return describeWriteOutcome(outcome);
|
|
5015
|
+
}
|
|
4985
5016
|
const created = await createVaultMemoryOp(vaultCtx, {
|
|
4986
5017
|
content,
|
|
4987
5018
|
scope,
|
|
@@ -5001,6 +5032,16 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
5001
5032
|
}
|
|
5002
5033
|
);
|
|
5003
5034
|
}
|
|
5035
|
+
await notifyWritten(
|
|
5036
|
+
options,
|
|
5037
|
+
{
|
|
5038
|
+
content,
|
|
5039
|
+
scope,
|
|
5040
|
+
...folderId !== void 0 && { folderId },
|
|
5041
|
+
...factType !== void 0 && { factType }
|
|
5042
|
+
},
|
|
5043
|
+
{ memoryId: created.uniqueId, action: "create" }
|
|
5044
|
+
);
|
|
5004
5045
|
return `Memory saved successfully (ID: ${created.uniqueId}).`;
|
|
5005
5046
|
}
|
|
5006
5047
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anuma/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.18.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -259,13 +259,14 @@
|
|
|
259
259
|
"react-dom": ">=19.0.1 <19.1.0 || >=19.1.2 <19.2.0 || >=19.2.1",
|
|
260
260
|
"tar": ">=7.5.16",
|
|
261
261
|
"picomatch": ">=2.3.2 <3.0.0 || >=4.0.4",
|
|
262
|
-
"@xmldom/xmldom": ">=0.8.
|
|
262
|
+
"@xmldom/xmldom": ">=0.8.15 <0.9.0",
|
|
263
263
|
"protobufjs": ">=7.6.1 <8.0.0",
|
|
264
264
|
"tmp": ">=0.2.7",
|
|
265
265
|
"ws@6": ">=6.2.4 <7.0.0",
|
|
266
266
|
"ws@7": ">=7.5.11 <8.0.0",
|
|
267
267
|
"ws@8": ">=8.21.0 <9.0.0",
|
|
268
268
|
"shell-quote": ">=1.10.0 <2.0.0",
|
|
269
|
+
"browserslist": ">=4.28.7 <5.0.0",
|
|
269
270
|
"axios": ">=1.16.0 <2.0.0",
|
|
270
271
|
"hono": ">=4.12.21 <5.0.0",
|
|
271
272
|
"js-cookie": ">=3.0.7 <4.0.0",
|
|
@@ -278,8 +279,8 @@
|
|
|
278
279
|
"undici@>=7 <7.28.0": ">=7.28.0 <8.0.0",
|
|
279
280
|
"vite@>=7 <7.3.5": ">=7.3.5",
|
|
280
281
|
"esbuild@>=0.27.3 <0.28.1": ">=0.28.1",
|
|
281
|
-
"js-yaml@>=4 <4.3.
|
|
282
|
-
"js-yaml@>=3 <3.15.
|
|
282
|
+
"js-yaml@>=4 <4.3.2": ">=4.3.2 <5.0.0",
|
|
283
|
+
"js-yaml@>=3 <3.15.2": ">=3.15.2 <4.0.0",
|
|
283
284
|
"markdown-it@<14.2.0": ">=14.2.0",
|
|
284
285
|
"brace-expansion@1": ">=1.1.18 <2.0.0",
|
|
285
286
|
"brace-expansion@2": ">=2.1.4 <3.0.0"
|