@anuma/sdk 6.15.0 → 6.15.2
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-3V3BBJLH.mjs → chunk-4Z2X4UYQ.mjs} +7 -1
- package/dist/expo/{chunk-DIUQLXEH.mjs → chunk-A2G6TRUK.mjs} +1 -1
- package/dist/expo/{chunk-LUSKQQDD.mjs → chunk-JXN7LD6B.mjs} +41 -17
- package/dist/{react/consolidate-Y2XWEZRQ.mjs → expo/consolidate-ZM5JNULQ.mjs} +2 -2
- package/dist/expo/index.cjs +179 -104
- package/dist/expo/index.mjs +143 -92
- package/dist/expo/{recall-GKYVPD2B.mjs → recall-TGRI5MN4.mjs} +2 -2
- package/dist/react/{chunk-3V3BBJLH.mjs → chunk-4Z2X4UYQ.mjs} +7 -1
- package/dist/react/{chunk-2GNOTRG4.mjs → chunk-7X7BNMGS.mjs} +1 -1
- package/dist/react/{chunk-PDKKPAXP.mjs → chunk-TVPCH7ZZ.mjs} +45 -21
- package/dist/{expo/consolidate-GTMXZZ4C.mjs → react/consolidate-7NMKF7UC.mjs} +2 -2
- package/dist/react/index.cjs +183 -108
- package/dist/react/index.mjs +143 -92
- package/dist/react/{recall-5HNAFHLL.mjs → recall-OKNLU335.mjs} +2 -2
- package/dist/server/{chunk-JPLFOSB2.mjs → chunk-4LPSEROP.mjs} +1 -1
- package/dist/server/{chunk-H4G3DLDJ.mjs → chunk-BSCEZOIW.mjs} +7 -1
- package/dist/server/{chunk-2QFK4L7Y.mjs → chunk-K7H7ICPK.mjs} +21 -21
- package/dist/server/{consolidate-CMMDTZ37.mjs → consolidate-MSAXASHL.mjs} +2 -2
- package/dist/server/index.cjs +136 -93
- package/dist/server/index.mjs +118 -77
- package/dist/server/{recall-EODNEKIA.mjs → recall-YXJATOSD.mjs} +2 -2
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -111,6 +111,7 @@ import {
|
|
|
111
111
|
getMessageSkeletonsOp,
|
|
112
112
|
getMessagesOp,
|
|
113
113
|
getMessagesPageOp,
|
|
114
|
+
getToolCallEventIdsOp,
|
|
114
115
|
getToolCallEvents,
|
|
115
116
|
getToolsChecksum,
|
|
116
117
|
getUnfiledVaultMemoriesOp,
|
|
@@ -178,28 +179,30 @@ import {
|
|
|
178
179
|
updateVaultMemoryOp,
|
|
179
180
|
useEncryption,
|
|
180
181
|
vaultMemoryToStored
|
|
181
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-TVPCH7ZZ.mjs";
|
|
182
183
|
import {
|
|
183
184
|
PiiRedactor,
|
|
184
185
|
createStreamingDeAnonymizer,
|
|
185
186
|
isPiiRedactor,
|
|
186
187
|
notifyConsolidationFallback,
|
|
187
188
|
resolvePiiRedactor
|
|
188
|
-
} from "./chunk-
|
|
189
|
+
} from "./chunk-7X7BNMGS.mjs";
|
|
189
190
|
import {
|
|
190
191
|
INTERNAL_FLOW_MARKER,
|
|
191
192
|
callPortalJsonCompletion,
|
|
192
193
|
consoleLogger,
|
|
194
|
+
extractCompletionContent,
|
|
193
195
|
extractJsonCandidate,
|
|
194
196
|
getLogger,
|
|
195
197
|
noopLogger,
|
|
198
|
+
requiresResponsesTransport,
|
|
196
199
|
resolvePortalAuthHeaders,
|
|
197
200
|
setLogger,
|
|
198
201
|
supportsResponseFormat,
|
|
199
202
|
taskTypeHeader,
|
|
200
203
|
validateEndpointOverride,
|
|
201
204
|
withInternalFlowMarker
|
|
202
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-4Z2X4UYQ.mjs";
|
|
203
206
|
import {
|
|
204
207
|
BASE_URL,
|
|
205
208
|
MCP_R2_DOMAIN,
|
|
@@ -7686,7 +7689,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
7686
7689
|
content: m.content,
|
|
7687
7690
|
similarity: m.similarity
|
|
7688
7691
|
}));
|
|
7689
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
7692
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-7NMKF7UC.mjs");
|
|
7690
7693
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
7691
7694
|
if (decision.action === "create") return null;
|
|
7692
7695
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -8910,6 +8913,9 @@ var DEFAULT_BASE_URL = BASE_URL;
|
|
|
8910
8913
|
var DEFAULT_MODEL3 = "anthropic/claude-sonnet-4-6";
|
|
8911
8914
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
8912
8915
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
8916
|
+
var MIN_RETRY_BUDGET_MS = 2e3;
|
|
8917
|
+
var MIN_RESPONSES_OUTPUT_TOKENS = 2048;
|
|
8918
|
+
var SCHEMA_FALLBACK_SKIP_STATUSES = /* @__PURE__ */ new Set([401, 403, 404, 408, 409, 413, 425, 429]);
|
|
8913
8919
|
var DEFAULT_SYSTEM_PROMPT = `You are a personal assistant with access to the user's memory. Answer the user's question using the supplied memories as evidence.
|
|
8914
8920
|
|
|
8915
8921
|
Rules:
|
|
@@ -8941,14 +8947,9 @@ ${m.content}`).join("\n\n");
|
|
|
8941
8947
|
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
8942
8948
|
const model = options.llmModel ?? DEFAULT_MODEL3;
|
|
8943
8949
|
const wantsStructured = !!options.responseSchema;
|
|
8944
|
-
const
|
|
8950
|
+
const useResponsesTransport = requiresResponsesTransport(model);
|
|
8951
|
+
const sendResponseFormat = wantsStructured && !useResponsesTransport && supportsResponseFormat(model, "json_schema");
|
|
8945
8952
|
const basePrompt = options.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
8946
|
-
const systemPrompt = wantsStructured && !sendResponseFormat ? `${basePrompt}
|
|
8947
|
-
|
|
8948
|
-
Respond with ONLY a single JSON object conforming to this JSON Schema, with no prose, comments, or code fences:
|
|
8949
|
-
${JSON.stringify(
|
|
8950
|
-
options.responseSchema
|
|
8951
|
-
)}` : basePrompt;
|
|
8952
8953
|
const userMessage = [
|
|
8953
8954
|
`Question:
|
|
8954
8955
|
${trimmed}`,
|
|
@@ -8958,85 +8959,121 @@ ${evidence}`
|
|
|
8958
8959
|
].join("\n\n");
|
|
8959
8960
|
const maxTokens = options.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
8960
8961
|
const fetchImpl = options.fetchFn ?? fetch;
|
|
8962
|
+
const buildBody = (useResponseFormat) => {
|
|
8963
|
+
const systemPrompt = wantsStructured && !useResponseFormat ? `${basePrompt}
|
|
8964
|
+
|
|
8965
|
+
Respond with ONLY a single JSON object conforming to this JSON Schema, with no prose, comments, or code fences:
|
|
8966
|
+
${JSON.stringify(
|
|
8967
|
+
options.responseSchema
|
|
8968
|
+
)}` : basePrompt;
|
|
8969
|
+
const messages = [
|
|
8970
|
+
{ role: "system", content: systemPrompt },
|
|
8971
|
+
{ role: "user", content: userMessage }
|
|
8972
|
+
];
|
|
8973
|
+
if (useResponsesTransport) {
|
|
8974
|
+
return JSON.stringify({
|
|
8975
|
+
model,
|
|
8976
|
+
// Same system+user pair under the Responses-API field names: `input`
|
|
8977
|
+
// for the turns, `max_output_tokens` for the cap. Sending the
|
|
8978
|
+
// chat-completions spelling here is silently ignored, which caps the
|
|
8979
|
+
// answer at the portal default.
|
|
8980
|
+
input: messages,
|
|
8981
|
+
max_output_tokens: Math.max(maxTokens, MIN_RESPONSES_OUTPUT_TOKENS)
|
|
8982
|
+
});
|
|
8983
|
+
}
|
|
8984
|
+
return JSON.stringify({
|
|
8985
|
+
model,
|
|
8986
|
+
// Modern OpenAI field; the portal reads only `max_completion_tokens`
|
|
8987
|
+
// (the deprecated `max_tokens` is silently ignored → falls back to the
|
|
8988
|
+
// portal's default output cap and truncates the answer).
|
|
8989
|
+
max_completion_tokens: maxTokens,
|
|
8990
|
+
messages,
|
|
8991
|
+
...useResponseFormat && {
|
|
8992
|
+
response_format: {
|
|
8993
|
+
type: "json_schema",
|
|
8994
|
+
json_schema: { name: "reflect_output", schema: options.responseSchema }
|
|
8995
|
+
}
|
|
8996
|
+
}
|
|
8997
|
+
});
|
|
8998
|
+
};
|
|
8961
8999
|
const log = getLogger();
|
|
8962
9000
|
const authHeaders = await resolvePortalAuthHeaders(options, "memory/reflect");
|
|
8963
9001
|
if (authHeaders === null) return baseResult;
|
|
8964
|
-
const controller = new AbortController();
|
|
8965
9002
|
const deadline = Date.now() + REQUEST_TIMEOUT_MS;
|
|
8966
9003
|
const remaining = () => Math.max(0, deadline - Date.now());
|
|
8967
|
-
const
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
}
|
|
8994
|
-
}
|
|
8995
|
-
}),
|
|
8996
|
-
signal: controller.signal
|
|
8997
|
-
});
|
|
8998
|
-
} catch (err) {
|
|
9004
|
+
const endpoint = useResponsesTransport ? "/api/v1/responses" : "/api/v1/chat/completions";
|
|
9005
|
+
const sendOnce = async (useResponseFormat) => {
|
|
9006
|
+
const controller = new AbortController();
|
|
9007
|
+
const timer = setTimeout(() => controller.abort(), remaining());
|
|
9008
|
+
let response;
|
|
9009
|
+
try {
|
|
9010
|
+
response = await fetchImpl(`${baseUrl}${endpoint}`, {
|
|
9011
|
+
method: "POST",
|
|
9012
|
+
// No task type unless the caller named one — an undeclared task adds no
|
|
9013
|
+
// header at all, which is what keeps user-facing reflect() unlabelled.
|
|
9014
|
+
headers: {
|
|
9015
|
+
...authHeaders,
|
|
9016
|
+
...taskTypeHeader(options.taskType),
|
|
9017
|
+
"Content-Type": "application/json"
|
|
9018
|
+
},
|
|
9019
|
+
body: buildBody(useResponseFormat),
|
|
9020
|
+
signal: controller.signal
|
|
9021
|
+
});
|
|
9022
|
+
} catch (err) {
|
|
9023
|
+
clearTimeout(timer);
|
|
9024
|
+
log.warn("[memory/reflect] portal request failed", {
|
|
9025
|
+
err: err instanceof Error ? err.message : String(err),
|
|
9026
|
+
baseUrl
|
|
9027
|
+
});
|
|
9028
|
+
return { kind: "error" };
|
|
9029
|
+
}
|
|
8999
9030
|
clearTimeout(timer);
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9031
|
+
if (!response.ok) {
|
|
9032
|
+
return { kind: "http", status: response.status, statusText: response.statusText };
|
|
9033
|
+
}
|
|
9034
|
+
const bodyTimer = setTimeout(() => controller.abort(), remaining());
|
|
9035
|
+
try {
|
|
9036
|
+
const body = await response.json();
|
|
9037
|
+
clearTimeout(bodyTimer);
|
|
9038
|
+
return { kind: "ok", body };
|
|
9039
|
+
} catch (err) {
|
|
9040
|
+
clearTimeout(bodyTimer);
|
|
9041
|
+
log.warn("[memory/reflect] failed to parse portal response body", {
|
|
9042
|
+
err: err instanceof Error ? err.message : String(err)
|
|
9043
|
+
});
|
|
9044
|
+
return { kind: "error" };
|
|
9045
|
+
}
|
|
9046
|
+
};
|
|
9047
|
+
let attempt = await sendOnce(sendResponseFormat);
|
|
9048
|
+
let schemaFallbackUsed = false;
|
|
9049
|
+
const budgetLeftMs = remaining();
|
|
9050
|
+
if (attempt.kind === "http" && sendResponseFormat && !SCHEMA_FALLBACK_SKIP_STATUSES.has(attempt.status) && budgetLeftMs >= MIN_RETRY_BUDGET_MS) {
|
|
9051
|
+
log.warn("[memory/reflect] response_format json_schema rejected; retrying schema-in-prompt", {
|
|
9052
|
+
status: attempt.status,
|
|
9053
|
+
statusText: attempt.statusText,
|
|
9054
|
+
model,
|
|
9055
|
+
taskType: options.taskType,
|
|
9056
|
+
budgetLeftMs
|
|
9003
9057
|
});
|
|
9004
|
-
|
|
9058
|
+
schemaFallbackUsed = true;
|
|
9059
|
+
attempt = await sendOnce(false);
|
|
9005
9060
|
}
|
|
9006
|
-
|
|
9007
|
-
if (
|
|
9061
|
+
if (attempt.kind === "error") return baseResult;
|
|
9062
|
+
if (attempt.kind === "http") {
|
|
9008
9063
|
log.warn("[memory/reflect] portal returned non-OK", {
|
|
9009
|
-
status:
|
|
9010
|
-
statusText:
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
}
|
|
9014
|
-
const bodyTimer = setTimeout(() => controller.abort(), remaining());
|
|
9015
|
-
let body;
|
|
9016
|
-
try {
|
|
9017
|
-
body = await response.json();
|
|
9018
|
-
} catch (err) {
|
|
9019
|
-
clearTimeout(bodyTimer);
|
|
9020
|
-
log.warn("[memory/reflect] failed to parse portal response body", {
|
|
9021
|
-
err: err instanceof Error ? err.message : String(err)
|
|
9064
|
+
status: attempt.status,
|
|
9065
|
+
statusText: attempt.statusText,
|
|
9066
|
+
// Distinguishes "the fallback ran and still failed" from "never tried".
|
|
9067
|
+
schemaFallbackUsed
|
|
9022
9068
|
});
|
|
9023
9069
|
return baseResult;
|
|
9024
9070
|
}
|
|
9025
|
-
|
|
9026
|
-
return parseAnswer(body, baseResult, !!options.responseSchema);
|
|
9071
|
+
return parseAnswer(attempt.body, baseResult, !!options.responseSchema);
|
|
9027
9072
|
}
|
|
9028
9073
|
function parseAnswer(body, base, parseSchema) {
|
|
9029
9074
|
if (typeof body !== "object" || body === null) return base;
|
|
9030
9075
|
const obj = body;
|
|
9031
|
-
const
|
|
9032
|
-
let text12 = "";
|
|
9033
|
-
if (Array.isArray(choices) && choices.length > 0) {
|
|
9034
|
-
const message = choices[0].message;
|
|
9035
|
-
if (typeof message === "object" && message !== null) {
|
|
9036
|
-
const content = message.content;
|
|
9037
|
-
if (typeof content === "string") text12 = content;
|
|
9038
|
-
}
|
|
9039
|
-
}
|
|
9076
|
+
const text12 = extractCompletionContent(obj) ?? "";
|
|
9040
9077
|
const usage = obj.usage;
|
|
9041
9078
|
let structuredOutput;
|
|
9042
9079
|
if (parseSchema && text12) {
|
|
@@ -9048,14 +9085,19 @@ function parseAnswer(body, base, parseSchema) {
|
|
|
9048
9085
|
});
|
|
9049
9086
|
}
|
|
9050
9087
|
}
|
|
9088
|
+
const promptTokens = usage?.prompt_tokens ?? usage?.input_tokens ?? 0;
|
|
9089
|
+
const completionTokens = usage?.completion_tokens ?? usage?.output_tokens ?? 0;
|
|
9051
9090
|
return {
|
|
9052
9091
|
text: text12,
|
|
9053
9092
|
...structuredOutput !== void 0 && { structuredOutput },
|
|
9054
9093
|
basedOn: base.basedOn,
|
|
9055
9094
|
usage: {
|
|
9056
|
-
promptTokens
|
|
9057
|
-
completionTokens
|
|
9058
|
-
|
|
9095
|
+
promptTokens,
|
|
9096
|
+
completionTokens,
|
|
9097
|
+
// Derived when absent: the Responses API reports the two component counts
|
|
9098
|
+
// and does not always send a total, which would otherwise report zero
|
|
9099
|
+
// spend for a call that plainly cost something.
|
|
9100
|
+
totalTokens: usage?.total_tokens ?? promptTokens + completionTokens
|
|
9059
9101
|
}
|
|
9060
9102
|
};
|
|
9061
9103
|
}
|
|
@@ -13650,22 +13692,31 @@ function useChatStorage(options) {
|
|
|
13650
13692
|
}
|
|
13651
13693
|
})() : null;
|
|
13652
13694
|
let messagesToSend;
|
|
13653
|
-
const
|
|
13654
|
-
const knownToolCallEventIds = /* @__PURE__ */ new Set();
|
|
13655
|
-
for (const msg of storedMessages) {
|
|
13656
|
-
if (msg.toolCallEvents) {
|
|
13657
|
-
for (const evt of msg.toolCallEvents) {
|
|
13658
|
-
if (evt.id) knownToolCallEventIds.add(evt.id);
|
|
13659
|
-
}
|
|
13660
|
-
}
|
|
13661
|
-
}
|
|
13695
|
+
const knownToolCallEventIds = await getToolCallEventIdsOp(storageCtx, convId);
|
|
13662
13696
|
if (includeHistory) {
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13697
|
+
let tail = [];
|
|
13698
|
+
let replayableMessages = [];
|
|
13699
|
+
let beforeMessageId;
|
|
13700
|
+
let boundaryExcludeUniqueIds;
|
|
13701
|
+
for (; ; ) {
|
|
13702
|
+
const page = await getMessagesPageOp(storageCtx, convId, {
|
|
13703
|
+
limit: maxHistoryMessages,
|
|
13704
|
+
beforeMessageId,
|
|
13705
|
+
boundaryExcludeUniqueIds
|
|
13706
|
+
});
|
|
13707
|
+
if (page.length === 0) break;
|
|
13708
|
+
tail = [...page, ...tail];
|
|
13709
|
+
const validMessages = tail.filter((msg) => !msg.error);
|
|
13710
|
+
replayableMessages = prepareToolResultsForReplay(validMessages, {
|
|
13711
|
+
fold: foldToolResultsInHistoryRef.current === true,
|
|
13712
|
+
exclude: toolResultsHistoryExcludeRef.current,
|
|
13713
|
+
placeholder: DISPLAY_CARD_PLACEHOLDER
|
|
13714
|
+
});
|
|
13715
|
+
if (replayableMessages.length >= maxHistoryMessages) break;
|
|
13716
|
+
if (page.length < maxHistoryMessages) break;
|
|
13717
|
+
beforeMessageId = page[0].messageId;
|
|
13718
|
+
boundaryExcludeUniqueIds = tail.filter((msg) => msg.messageId === beforeMessageId).map((msg) => msg.uniqueId);
|
|
13719
|
+
}
|
|
13669
13720
|
const limitedMessages = replayableMessages.slice(-maxHistoryMessages);
|
|
13670
13721
|
if (!fileContextForRequest) {
|
|
13671
13722
|
for (let i = limitedMessages.length - 1; i >= 0; i--) {
|
|
@@ -57,6 +57,10 @@ function supportsResponseFormat(model, variant = "json_object") {
|
|
|
57
57
|
const allow = variant === "json_schema" ? RESPONSE_SCHEMA_OK : RESPONSE_FORMAT_OK;
|
|
58
58
|
return model.split("/").some((seg) => allow.has(seg));
|
|
59
59
|
}
|
|
60
|
+
var RESPONSES_ONLY_MODEL_PREFIXES = ["gpt-5.6"];
|
|
61
|
+
function requiresResponsesTransport(model) {
|
|
62
|
+
return model.split("/").some((seg) => RESPONSES_ONLY_MODEL_PREFIXES.some((prefix) => seg.startsWith(prefix)));
|
|
63
|
+
}
|
|
60
64
|
var CHAT_TO_RESPONSES_FIELDS = {
|
|
61
65
|
max_completion_tokens: "max_output_tokens"
|
|
62
66
|
};
|
|
@@ -408,7 +412,9 @@ export {
|
|
|
408
412
|
taskTypeHeader,
|
|
409
413
|
validateEndpointOverride,
|
|
410
414
|
supportsResponseFormat,
|
|
415
|
+
requiresResponsesTransport,
|
|
411
416
|
resolvePortalAuthHeaders,
|
|
412
417
|
callPortalJsonCompletion,
|
|
413
|
-
extractJsonCandidate
|
|
418
|
+
extractJsonCandidate,
|
|
419
|
+
extractCompletionContent
|
|
414
420
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callPortalJsonCompletion,
|
|
3
3
|
getLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BSCEZOIW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
__commonJS,
|
|
@@ -16072,14 +16072,14 @@ function resolveChunkText(content, chunk, chunksInRow) {
|
|
|
16072
16072
|
if (covered !== content.length) return content;
|
|
16073
16073
|
return content.slice(start, end);
|
|
16074
16074
|
}
|
|
16075
|
-
async function
|
|
16076
|
-
const
|
|
16077
|
-
if (!
|
|
16078
|
-
if (walletAddress && isEncrypted(
|
|
16079
|
-
return await decryptJsonField(
|
|
16075
|
+
async function readRawJsonField(raw, column, walletAddress) {
|
|
16076
|
+
const value = raw[column];
|
|
16077
|
+
if (!value) return void 0;
|
|
16078
|
+
if (walletAddress && isEncrypted(value)) {
|
|
16079
|
+
return await decryptJsonField(value, walletAddress);
|
|
16080
16080
|
}
|
|
16081
16081
|
try {
|
|
16082
|
-
return JSON.parse(
|
|
16082
|
+
return JSON.parse(value);
|
|
16083
16083
|
} catch {
|
|
16084
16084
|
return void 0;
|
|
16085
16085
|
}
|
|
@@ -16092,12 +16092,12 @@ async function searchMessagesOp(ctx, queryVector, options) {
|
|
|
16092
16092
|
activeConversations.map((c) => String(c._getRaw("conversation_id")))
|
|
16093
16093
|
);
|
|
16094
16094
|
const queryConditions = conversationId ? [import_watermelondb.Q.where("conversation_id", conversationId)] : [];
|
|
16095
|
-
const messages = await ctx.messagesCollection.query(...queryConditions).
|
|
16095
|
+
const messages = await ctx.messagesCollection.query(...queryConditions).unsafeFetchRaw();
|
|
16096
16096
|
const candidates = [];
|
|
16097
16097
|
for (const message of messages) {
|
|
16098
|
-
const msgConvId = String(message.
|
|
16098
|
+
const msgConvId = String(message.conversation_id);
|
|
16099
16099
|
if (!activeConversationIds.has(msgConvId)) continue;
|
|
16100
|
-
const messageVector = await
|
|
16100
|
+
const messageVector = await readRawJsonField(message, "vector", ctx.walletAddress);
|
|
16101
16101
|
if (!messageVector || messageVector.length === 0) continue;
|
|
16102
16102
|
const similarity = cosineSimilarity(queryVector, messageVector);
|
|
16103
16103
|
if (similarity >= minSimilarity) {
|
|
@@ -16107,7 +16107,7 @@ async function searchMessagesOp(ctx, queryVector, options) {
|
|
|
16107
16107
|
const topK = candidates.sort((a, b) => b.similarity - a.similarity).slice(0, limit);
|
|
16108
16108
|
return Promise.all(
|
|
16109
16109
|
topK.map(async ({ message, similarity }) => {
|
|
16110
|
-
const stored = await
|
|
16110
|
+
const stored = await messageRawToStored(
|
|
16111
16111
|
message,
|
|
16112
16112
|
ctx.walletAddress,
|
|
16113
16113
|
ctx.signMessage,
|
|
@@ -16131,21 +16131,21 @@ async function searchChunksOp(ctx, queryVector, options) {
|
|
|
16131
16131
|
activeConversations.map((c) => String(c._getRaw("conversation_id")))
|
|
16132
16132
|
);
|
|
16133
16133
|
const queryConditions = conversationId ? [import_watermelondb.Q.where("conversation_id", conversationId)] : [];
|
|
16134
|
-
const messages = await ctx.messagesCollection.query(...queryConditions).
|
|
16134
|
+
const messages = await ctx.messagesCollection.query(...queryConditions).unsafeFetchRaw();
|
|
16135
16135
|
const candidates = [];
|
|
16136
16136
|
let staleSkipped = 0;
|
|
16137
16137
|
let unreadableVectors = 0;
|
|
16138
16138
|
for (const message of messages) {
|
|
16139
|
-
const msgConvId = String(message.
|
|
16139
|
+
const msgConvId = String(message.conversation_id);
|
|
16140
16140
|
if (!activeConversationIds.has(msgConvId)) continue;
|
|
16141
16141
|
if (embeddingModel) {
|
|
16142
|
-
const storedModel = message.
|
|
16142
|
+
const storedModel = message.embedding_model;
|
|
16143
16143
|
if (storedModel !== null && storedModel !== void 0 && storedModel !== embeddingModel) {
|
|
16144
16144
|
staleSkipped++;
|
|
16145
16145
|
continue;
|
|
16146
16146
|
}
|
|
16147
16147
|
}
|
|
16148
|
-
const version = Number(message.
|
|
16148
|
+
const version = Number(message.updated_at) || 0;
|
|
16149
16149
|
const cached = chunkCache?.get(message.id);
|
|
16150
16150
|
if (cached && cached.version === version) {
|
|
16151
16151
|
if (cached.chunks.length > 0) {
|
|
@@ -16169,7 +16169,7 @@ async function searchChunksOp(ctx, queryVector, options) {
|
|
|
16169
16169
|
}
|
|
16170
16170
|
continue;
|
|
16171
16171
|
}
|
|
16172
|
-
const chunks = await
|
|
16172
|
+
const chunks = await readRawJsonField(message, "chunks", ctx.walletAddress);
|
|
16173
16173
|
if (chunks && chunks.length > 0) {
|
|
16174
16174
|
const vectors = chunks.map(
|
|
16175
16175
|
(chunk) => decodeChunkVector(chunk.vector, () => {
|
|
@@ -16190,7 +16190,7 @@ async function searchChunksOp(ctx, queryVector, options) {
|
|
|
16190
16190
|
}
|
|
16191
16191
|
}
|
|
16192
16192
|
} else {
|
|
16193
|
-
const messageVector = await
|
|
16193
|
+
const messageVector = await readRawJsonField(message, "vector", ctx.walletAddress);
|
|
16194
16194
|
if (!messageVector || messageVector.length === 0) continue;
|
|
16195
16195
|
const fallback = Float32Array.from(messageVector);
|
|
16196
16196
|
chunkCache?.set(message.id, { version, chunks: [], fallback });
|
|
@@ -16216,7 +16216,7 @@ async function searchChunksOp(ctx, queryVector, options) {
|
|
|
16216
16216
|
const storedById = new Map(
|
|
16217
16217
|
await Promise.all(
|
|
16218
16218
|
Array.from(uniqueMessages, async ([id, m]) => {
|
|
16219
|
-
const stored = await
|
|
16219
|
+
const stored = await messageRawToStored(
|
|
16220
16220
|
m,
|
|
16221
16221
|
ctx.walletAddress,
|
|
16222
16222
|
ctx.signMessage,
|
|
@@ -16234,8 +16234,8 @@ async function searchChunksOp(ctx, queryVector, options) {
|
|
|
16234
16234
|
await Promise.all(
|
|
16235
16235
|
Array.from(needsChunkText, async (id) => {
|
|
16236
16236
|
const m = uniqueMessages.get(id);
|
|
16237
|
-
const parsed = await
|
|
16238
|
-
const version = Number(m.
|
|
16237
|
+
const parsed = await readRawJsonField(m, "chunks", ctx.walletAddress);
|
|
16238
|
+
const version = Number(m.updated_at) || 0;
|
|
16239
16239
|
if (parsed) chunkStateByMsgId.set(id, { version, chunks: parsed });
|
|
16240
16240
|
})
|
|
16241
16241
|
);
|
|
@@ -20923,7 +20923,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
20923
20923
|
subQueries = decomp.subQueries;
|
|
20924
20924
|
}
|
|
20925
20925
|
}
|
|
20926
|
-
const { recall: recall2 } = await import("./recall-
|
|
20926
|
+
const { recall: recall2 } = await import("./recall-YXJATOSD.mjs");
|
|
20927
20927
|
let recallDegraded = [];
|
|
20928
20928
|
const result = await recall2(
|
|
20929
20929
|
query,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
notifyConsolidationFallback,
|
|
3
3
|
resolvePiiRedactor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4LPSEROP.mjs";
|
|
5
5
|
import {
|
|
6
6
|
callPortalJsonCompletion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BSCEZOIW.mjs";
|
|
8
8
|
import "./chunk-3RPGXXPZ.mjs";
|
|
9
9
|
|
|
10
10
|
// src/lib/memory/consolidate.ts
|