@anuma/sdk 6.17.2 → 6.19.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/{chunk-JXN7LD6B.mjs → chunk-L253L67R.mjs} +2 -2
- package/dist/expo/{chunk-4Z2X4UYQ.mjs → chunk-WUG6GTHO.mjs} +10 -1
- package/dist/expo/{chunk-A2G6TRUK.mjs → chunk-XDBX4FZY.mjs} +1 -1
- package/dist/{react/consolidate-7NMKF7UC.mjs → expo/consolidate-XBYKAFKT.mjs} +2 -2
- package/dist/expo/index.cjs +90 -8
- package/dist/expo/index.d.mts +100 -2
- package/dist/expo/index.d.ts +100 -2
- package/dist/expo/index.mjs +84 -11
- package/dist/expo/{recall-TGRI5MN4.mjs → recall-B3PUQHJK.mjs} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react/{chunk-7X7BNMGS.mjs → chunk-AVYB5IXC.mjs} +1 -1
- package/dist/react/{chunk-TVPCH7ZZ.mjs → chunk-JRJRRO4P.mjs} +2 -2
- package/dist/react/{chunk-4Z2X4UYQ.mjs → chunk-WUG6GTHO.mjs} +10 -1
- package/dist/{expo/consolidate-ZM5JNULQ.mjs → react/consolidate-URHGJT7I.mjs} +2 -2
- package/dist/react/index.cjs +81 -4
- package/dist/react/index.d.mts +100 -2
- package/dist/react/index.d.ts +100 -2
- package/dist/react/index.mjs +75 -7
- package/dist/react/{recall-OKNLU335.mjs → recall-WPYCG4ED.mjs} +2 -2
- package/dist/server/{chunk-K7H7ICPK.mjs → chunk-2A6HXY4P.mjs} +2 -2
- package/dist/server/{chunk-4LPSEROP.mjs → chunk-RKQ4MRS2.mjs} +1 -1
- package/dist/server/{chunk-BSCEZOIW.mjs → chunk-YXL5VKCO.mjs} +10 -1
- package/dist/server/{consolidate-MSAXASHL.mjs → consolidate-54P6QZKU.mjs} +2 -2
- package/dist/server/index.cjs +53 -2
- package/dist/server/index.d.mts +91 -1
- package/dist/server/index.d.ts +91 -1
- package/dist/server/index.mjs +47 -5
- package/dist/server/{recall-YXJATOSD.mjs → recall-JPIWNKA7.mjs} +2 -2
- package/package.json +1 -1
package/dist/server/index.d.mts
CHANGED
|
@@ -4766,7 +4766,7 @@ interface EntityOperationsContext {
|
|
|
4766
4766
|
*
|
|
4767
4767
|
* @public
|
|
4768
4768
|
*/
|
|
4769
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
4769
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
4770
4770
|
|
|
4771
4771
|
/**
|
|
4772
4772
|
* Shared portal LLM call for the memory pipeline.
|
|
@@ -4863,6 +4863,26 @@ type PortalLlmFailureReason =
|
|
|
4863
4863
|
| "null-completion"
|
|
4864
4864
|
/** `totalTimeoutMs` was spent before the next attempt could run. */
|
|
4865
4865
|
| "time-budget-exhausted";
|
|
4866
|
+
/**
|
|
4867
|
+
* One attempt of a {@link callPortalJsonCompletion} call, reported to
|
|
4868
|
+
* `onAttempt` as it settles — success included. The wire-level diagnostic the
|
|
4869
|
+
* give-up hook cannot provide: a call that succeeds on its third try returns a
|
|
4870
|
+
* value and fires no `onFailure`, yet it cost three completions and its first
|
|
4871
|
+
* two answers were unusable. Extraction quality regressions have hidden in
|
|
4872
|
+
* exactly that shape (a prompt change that made the model answer `NONE` first,
|
|
4873
|
+
* JSON on retry), so the extraction eval gates on the first-attempt clean rate.
|
|
4874
|
+
*
|
|
4875
|
+
* @public
|
|
4876
|
+
*/
|
|
4877
|
+
interface PortalLlmAttempt {
|
|
4878
|
+
/** 1-based attempt index. */
|
|
4879
|
+
attempt: number;
|
|
4880
|
+
/** Whether this attempt produced a parseable JSON value. */
|
|
4881
|
+
ok: boolean;
|
|
4882
|
+
/** Classification when `ok` is false. */
|
|
4883
|
+
reason?: PortalLlmFailureReason;
|
|
4884
|
+
httpStatus?: number;
|
|
4885
|
+
}
|
|
4866
4886
|
/**
|
|
4867
4887
|
* A give-up report: the classified {@link PortalLlmFailureReason} plus the
|
|
4868
4888
|
* little context worth carrying into telemetry. Both extra fields are bounded
|
|
@@ -6133,6 +6153,12 @@ interface ExtractFactsOptions extends PortalLlmAuth {
|
|
|
6133
6153
|
* (i.e. redaction silently eating facts) is alarmable.
|
|
6134
6154
|
*/
|
|
6135
6155
|
onCandidatesDropped?: () => void;
|
|
6156
|
+
/**
|
|
6157
|
+
* Per-attempt wire diagnostic, forwarded to {@link callPortalJsonCompletion}.
|
|
6158
|
+
* The extraction eval gates on it (first-attempt clean rate); production
|
|
6159
|
+
* callers may leave it unset.
|
|
6160
|
+
*/
|
|
6161
|
+
onAttempt?: (attempt: PortalLlmAttempt) => void;
|
|
6136
6162
|
}
|
|
6137
6163
|
/**
|
|
6138
6164
|
* Stage 1 — call the LLM to extract candidate facts from the recent
|
|
@@ -7792,6 +7818,41 @@ declare function createMemoryEngineTool(storageCtx: StorageOperationsContext, em
|
|
|
7792
7818
|
* Each operation can be intercepted by the host app for confirmation/cancellation.
|
|
7793
7819
|
*/
|
|
7794
7820
|
|
|
7821
|
+
/**
|
|
7822
|
+
* The 7 FactTypes a manual save may self-classify into (PR5). Mirrors the
|
|
7823
|
+
* extractor's `FactType` union in `memory/autoExtract` — kept as a local const
|
|
7824
|
+
* (not imported) to avoid a memoryVault → memory runtime import cycle. Only used
|
|
7825
|
+
* to validate the optional `type` tool argument; an unrecognized value is
|
|
7826
|
+
* dropped (persisted as null, the untyped/medium-decay bucket).
|
|
7827
|
+
*/
|
|
7828
|
+
declare const MANUAL_FACT_TYPES: readonly ["identity", "preference", "relationship", "plan", "ongoing_context", "constraint", "other"];
|
|
7829
|
+
/** A FactType the save tool's optional `type` argument may carry. */
|
|
7830
|
+
type ManualFactType = (typeof MANUAL_FACT_TYPES)[number];
|
|
7831
|
+
/**
|
|
7832
|
+
* What a {@link VaultMemoryWriter} reports back. The action set mirrors
|
|
7833
|
+
* `RetainResult.action` in `memory/retain` — restated here rather than imported
|
|
7834
|
+
* for the same reason MANUAL_FACT_TYPES is (memoryVault → memory import cycle).
|
|
7835
|
+
*/
|
|
7836
|
+
type VaultWriteAction = "create" | "merge" | "update" | "supersede" | "suppressed" | "skip";
|
|
7837
|
+
interface VaultWriteOutcome {
|
|
7838
|
+
/** The memory the write landed on: the fresh row, or the existing one it merged into. */
|
|
7839
|
+
memoryId: string;
|
|
7840
|
+
action: VaultWriteAction;
|
|
7841
|
+
}
|
|
7842
|
+
/** A NEW memory the tool wants written — `id`-addressed updates never come here. */
|
|
7843
|
+
interface VaultWriteInput {
|
|
7844
|
+
content: string;
|
|
7845
|
+
scope: string;
|
|
7846
|
+
folderId?: string;
|
|
7847
|
+
factType?: ManualFactType;
|
|
7848
|
+
}
|
|
7849
|
+
/**
|
|
7850
|
+
* The seam through which the tool writes NEW memories when the host supplies one.
|
|
7851
|
+
* `useChatStorage` (react + expo) passes a `retain()`-backed writer so a
|
|
7852
|
+
* model-initiated save gets the same cosine auto-merge the background extractor
|
|
7853
|
+
* gets, instead of a bare insert that trusts the model to have de-duplicated.
|
|
7854
|
+
*/
|
|
7855
|
+
type VaultMemoryWriter = (input: VaultWriteInput) => Promise<VaultWriteOutcome>;
|
|
7795
7856
|
/**
|
|
7796
7857
|
* Describes a pending vault save operation for UI confirmation.
|
|
7797
7858
|
*/
|
|
@@ -7830,6 +7891,35 @@ interface MemoryVaultToolOptions {
|
|
|
7830
7891
|
* When provided, the LLM can specify a folderName argument.
|
|
7831
7892
|
*/
|
|
7832
7893
|
folderMap?: Map<string, string>;
|
|
7894
|
+
/**
|
|
7895
|
+
* Writer for NEW memories. When set, a save without an `id` goes through it
|
|
7896
|
+
* instead of a bare `createVaultMemoryOp`, and the tool phrases its reply from
|
|
7897
|
+
* the reported action (a merge reads as "already known", not "saved").
|
|
7898
|
+
*
|
|
7899
|
+
* The hooks supply a `retain()`-backed writer, which is what makes this tool
|
|
7900
|
+
* stop being a dedup bypass: until then the only thing standing between the
|
|
7901
|
+
* model and a duplicate row was the prompt asking it to pass an `id`. Omit it
|
|
7902
|
+
* (as a bare `createMemoryVaultTool(vaultCtx, …)` caller must — retain needs
|
|
7903
|
+
* embeddings) and the direct insert path is unchanged.
|
|
7904
|
+
*
|
|
7905
|
+
* Updates addressed by `id` never come here: the model has already named the
|
|
7906
|
+
* row, so there is nothing to de-duplicate against.
|
|
7907
|
+
*/
|
|
7908
|
+
write?: VaultMemoryWriter;
|
|
7909
|
+
/**
|
|
7910
|
+
* Fires after a NEW memory's write settles, with what was asked and what the
|
|
7911
|
+
* writer did. The host's analytics hook: `onSave` runs BEFORE the write and so
|
|
7912
|
+
* cannot tell a fresh create from a merge into an existing memory — and that
|
|
7913
|
+
* split is the one number that says whether model-initiated saves duplicate
|
|
7914
|
+
* the vault. Fires on both write paths (a `write` seam, or the direct insert
|
|
7915
|
+
* when none is supplied — reported as `create`). Not called for
|
|
7916
|
+
* `id`-addressed updates or cancelled saves. A throwing or rejecting listener
|
|
7917
|
+
* is awaited and swallowed so it can never fail the tool call.
|
|
7918
|
+
*/
|
|
7919
|
+
onWritten?: (event: {
|
|
7920
|
+
input: VaultWriteInput;
|
|
7921
|
+
outcome: VaultWriteOutcome;
|
|
7922
|
+
}) => void | Promise<void>;
|
|
7833
7923
|
}
|
|
7834
7924
|
/**
|
|
7835
7925
|
* Creates a memory vault tool for use with chat completions.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4766,7 +4766,7 @@ interface EntityOperationsContext {
|
|
|
4766
4766
|
*
|
|
4767
4767
|
* @public
|
|
4768
4768
|
*/
|
|
4769
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
4769
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
4770
4770
|
|
|
4771
4771
|
/**
|
|
4772
4772
|
* Shared portal LLM call for the memory pipeline.
|
|
@@ -4863,6 +4863,26 @@ type PortalLlmFailureReason =
|
|
|
4863
4863
|
| "null-completion"
|
|
4864
4864
|
/** `totalTimeoutMs` was spent before the next attempt could run. */
|
|
4865
4865
|
| "time-budget-exhausted";
|
|
4866
|
+
/**
|
|
4867
|
+
* One attempt of a {@link callPortalJsonCompletion} call, reported to
|
|
4868
|
+
* `onAttempt` as it settles — success included. The wire-level diagnostic the
|
|
4869
|
+
* give-up hook cannot provide: a call that succeeds on its third try returns a
|
|
4870
|
+
* value and fires no `onFailure`, yet it cost three completions and its first
|
|
4871
|
+
* two answers were unusable. Extraction quality regressions have hidden in
|
|
4872
|
+
* exactly that shape (a prompt change that made the model answer `NONE` first,
|
|
4873
|
+
* JSON on retry), so the extraction eval gates on the first-attempt clean rate.
|
|
4874
|
+
*
|
|
4875
|
+
* @public
|
|
4876
|
+
*/
|
|
4877
|
+
interface PortalLlmAttempt {
|
|
4878
|
+
/** 1-based attempt index. */
|
|
4879
|
+
attempt: number;
|
|
4880
|
+
/** Whether this attempt produced a parseable JSON value. */
|
|
4881
|
+
ok: boolean;
|
|
4882
|
+
/** Classification when `ok` is false. */
|
|
4883
|
+
reason?: PortalLlmFailureReason;
|
|
4884
|
+
httpStatus?: number;
|
|
4885
|
+
}
|
|
4866
4886
|
/**
|
|
4867
4887
|
* A give-up report: the classified {@link PortalLlmFailureReason} plus the
|
|
4868
4888
|
* little context worth carrying into telemetry. Both extra fields are bounded
|
|
@@ -6133,6 +6153,12 @@ interface ExtractFactsOptions extends PortalLlmAuth {
|
|
|
6133
6153
|
* (i.e. redaction silently eating facts) is alarmable.
|
|
6134
6154
|
*/
|
|
6135
6155
|
onCandidatesDropped?: () => void;
|
|
6156
|
+
/**
|
|
6157
|
+
* Per-attempt wire diagnostic, forwarded to {@link callPortalJsonCompletion}.
|
|
6158
|
+
* The extraction eval gates on it (first-attempt clean rate); production
|
|
6159
|
+
* callers may leave it unset.
|
|
6160
|
+
*/
|
|
6161
|
+
onAttempt?: (attempt: PortalLlmAttempt) => void;
|
|
6136
6162
|
}
|
|
6137
6163
|
/**
|
|
6138
6164
|
* Stage 1 — call the LLM to extract candidate facts from the recent
|
|
@@ -7792,6 +7818,41 @@ declare function createMemoryEngineTool(storageCtx: StorageOperationsContext, em
|
|
|
7792
7818
|
* Each operation can be intercepted by the host app for confirmation/cancellation.
|
|
7793
7819
|
*/
|
|
7794
7820
|
|
|
7821
|
+
/**
|
|
7822
|
+
* The 7 FactTypes a manual save may self-classify into (PR5). Mirrors the
|
|
7823
|
+
* extractor's `FactType` union in `memory/autoExtract` — kept as a local const
|
|
7824
|
+
* (not imported) to avoid a memoryVault → memory runtime import cycle. Only used
|
|
7825
|
+
* to validate the optional `type` tool argument; an unrecognized value is
|
|
7826
|
+
* dropped (persisted as null, the untyped/medium-decay bucket).
|
|
7827
|
+
*/
|
|
7828
|
+
declare const MANUAL_FACT_TYPES: readonly ["identity", "preference", "relationship", "plan", "ongoing_context", "constraint", "other"];
|
|
7829
|
+
/** A FactType the save tool's optional `type` argument may carry. */
|
|
7830
|
+
type ManualFactType = (typeof MANUAL_FACT_TYPES)[number];
|
|
7831
|
+
/**
|
|
7832
|
+
* What a {@link VaultMemoryWriter} reports back. The action set mirrors
|
|
7833
|
+
* `RetainResult.action` in `memory/retain` — restated here rather than imported
|
|
7834
|
+
* for the same reason MANUAL_FACT_TYPES is (memoryVault → memory import cycle).
|
|
7835
|
+
*/
|
|
7836
|
+
type VaultWriteAction = "create" | "merge" | "update" | "supersede" | "suppressed" | "skip";
|
|
7837
|
+
interface VaultWriteOutcome {
|
|
7838
|
+
/** The memory the write landed on: the fresh row, or the existing one it merged into. */
|
|
7839
|
+
memoryId: string;
|
|
7840
|
+
action: VaultWriteAction;
|
|
7841
|
+
}
|
|
7842
|
+
/** A NEW memory the tool wants written — `id`-addressed updates never come here. */
|
|
7843
|
+
interface VaultWriteInput {
|
|
7844
|
+
content: string;
|
|
7845
|
+
scope: string;
|
|
7846
|
+
folderId?: string;
|
|
7847
|
+
factType?: ManualFactType;
|
|
7848
|
+
}
|
|
7849
|
+
/**
|
|
7850
|
+
* The seam through which the tool writes NEW memories when the host supplies one.
|
|
7851
|
+
* `useChatStorage` (react + expo) passes a `retain()`-backed writer so a
|
|
7852
|
+
* model-initiated save gets the same cosine auto-merge the background extractor
|
|
7853
|
+
* gets, instead of a bare insert that trusts the model to have de-duplicated.
|
|
7854
|
+
*/
|
|
7855
|
+
type VaultMemoryWriter = (input: VaultWriteInput) => Promise<VaultWriteOutcome>;
|
|
7795
7856
|
/**
|
|
7796
7857
|
* Describes a pending vault save operation for UI confirmation.
|
|
7797
7858
|
*/
|
|
@@ -7830,6 +7891,35 @@ interface MemoryVaultToolOptions {
|
|
|
7830
7891
|
* When provided, the LLM can specify a folderName argument.
|
|
7831
7892
|
*/
|
|
7832
7893
|
folderMap?: Map<string, string>;
|
|
7894
|
+
/**
|
|
7895
|
+
* Writer for NEW memories. When set, a save without an `id` goes through it
|
|
7896
|
+
* instead of a bare `createVaultMemoryOp`, and the tool phrases its reply from
|
|
7897
|
+
* the reported action (a merge reads as "already known", not "saved").
|
|
7898
|
+
*
|
|
7899
|
+
* The hooks supply a `retain()`-backed writer, which is what makes this tool
|
|
7900
|
+
* stop being a dedup bypass: until then the only thing standing between the
|
|
7901
|
+
* model and a duplicate row was the prompt asking it to pass an `id`. Omit it
|
|
7902
|
+
* (as a bare `createMemoryVaultTool(vaultCtx, …)` caller must — retain needs
|
|
7903
|
+
* embeddings) and the direct insert path is unchanged.
|
|
7904
|
+
*
|
|
7905
|
+
* Updates addressed by `id` never come here: the model has already named the
|
|
7906
|
+
* row, so there is nothing to de-duplicate against.
|
|
7907
|
+
*/
|
|
7908
|
+
write?: VaultMemoryWriter;
|
|
7909
|
+
/**
|
|
7910
|
+
* Fires after a NEW memory's write settles, with what was asked and what the
|
|
7911
|
+
* writer did. The host's analytics hook: `onSave` runs BEFORE the write and so
|
|
7912
|
+
* cannot tell a fresh create from a merge into an existing memory — and that
|
|
7913
|
+
* split is the one number that says whether model-initiated saves duplicate
|
|
7914
|
+
* the vault. Fires on both write paths (a `write` seam, or the direct insert
|
|
7915
|
+
* when none is supplied — reported as `create`). Not called for
|
|
7916
|
+
* `id`-addressed updates or cancelled saves. A throwing or rejecting listener
|
|
7917
|
+
* is awaited and swallowed so it can never fail the tool call.
|
|
7918
|
+
*/
|
|
7919
|
+
onWritten?: (event: {
|
|
7920
|
+
input: VaultWriteInput;
|
|
7921
|
+
outcome: VaultWriteOutcome;
|
|
7922
|
+
}) => void | Promise<void>;
|
|
7833
7923
|
}
|
|
7834
7924
|
/**
|
|
7835
7925
|
* Creates a memory vault tool for use with chat completions.
|
package/dist/server/index.mjs
CHANGED
|
@@ -141,12 +141,12 @@ import {
|
|
|
141
141
|
updateVaultMemoryOp,
|
|
142
142
|
upsertMessageOp,
|
|
143
143
|
vaultMemoryToStored
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-2A6HXY4P.mjs";
|
|
145
145
|
import {
|
|
146
146
|
createStreamingDeAnonymizer,
|
|
147
147
|
notifyConsolidationFallback,
|
|
148
148
|
resolvePiiRedactor
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-RKQ4MRS2.mjs";
|
|
150
150
|
import {
|
|
151
151
|
INTERNAL_FLOW_MARKER,
|
|
152
152
|
callPortalJsonCompletion,
|
|
@@ -159,7 +159,7 @@ import {
|
|
|
159
159
|
taskTypeHeader,
|
|
160
160
|
validateEndpointOverride,
|
|
161
161
|
withInternalFlowMarker
|
|
162
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-YXL5VKCO.mjs";
|
|
163
163
|
import {
|
|
164
164
|
BASE_URL,
|
|
165
165
|
__commonJS,
|
|
@@ -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) {
|
|
@@ -5702,7 +5743,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5702
5743
|
content: m.content,
|
|
5703
5744
|
similarity: m.similarity
|
|
5704
5745
|
}));
|
|
5705
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
5746
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-54P6QZKU.mjs");
|
|
5706
5747
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
5707
5748
|
if (decision.action === "create") return null;
|
|
5708
5749
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -5944,7 +5985,8 @@ Extract durable user facts.`,
|
|
|
5944
5985
|
...options.maxAttempts !== void 0 && { maxAttempts: options.maxAttempts },
|
|
5945
5986
|
...options.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
5946
5987
|
...options.totalTimeoutMs !== void 0 && { totalTimeoutMs: options.totalTimeoutMs },
|
|
5947
|
-
...options.backoffMs && { backoffMs: options.backoffMs }
|
|
5988
|
+
...options.backoffMs && { backoffMs: options.backoffMs },
|
|
5989
|
+
...options.onAttempt && { onAttempt: options.onAttempt }
|
|
5948
5990
|
});
|
|
5949
5991
|
if (parsed === null) {
|
|
5950
5992
|
options.onExhaustedEmpty?.(failure ?? { reason: "empty-content", attempts: 1 });
|